diff --git a/package-lock.json b/package-lock.json index 61d9acc..ebe254a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,7 @@ "@ckeditor/ckeditor5-react": "^3.0.0", "@helsenorge/ckeditor5-build-markdown": "^24.0.0", "@nosferatu500/react-sortable-tree": "^4.4.0", + "@types/remove-markdown": "^0.3.4", "axios": "^1.6.0", "crypto-js": "^4.2.0", "date-fns": "^2.17.0", @@ -4139,6 +4140,11 @@ "@types/react": "*" } }, + "node_modules/@types/remove-markdown": { + "version": "0.3.4", + "resolved": "https://registry.npmjs.org/@types/remove-markdown/-/remove-markdown-0.3.4.tgz", + "integrity": "sha512-i753EH/p02bw7bLlpfS/4CV1rdikbGiLabWyVsAvsFid3cA5RNU1frG7JycgY+NSnFwtoGlElvZVceCytecTDA==" + }, "node_modules/@types/semver": { "version": "7.5.8", "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.8.tgz", @@ -16388,6 +16394,11 @@ "@types/react": "*" } }, + "@types/remove-markdown": { + "version": "0.3.4", + "resolved": "https://registry.npmjs.org/@types/remove-markdown/-/remove-markdown-0.3.4.tgz", + "integrity": "sha512-i753EH/p02bw7bLlpfS/4CV1rdikbGiLabWyVsAvsFid3cA5RNU1frG7JycgY+NSnFwtoGlElvZVceCytecTDA==" + }, "@types/semver": { "version": "7.5.8", "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.8.tgz", diff --git a/package.json b/package.json index 42e3b66..b68f696 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "@ckeditor/ckeditor5-react": "^3.0.0", "@helsenorge/ckeditor5-build-markdown": "^24.0.0", "@nosferatu500/react-sortable-tree": "^4.4.0", + "@types/remove-markdown": "^0.3.4", "axios": "^1.6.0", "crypto-js": "^4.2.0", "date-fns": "^2.17.0", diff --git a/src/components/AnchorMenu/AnchorMenu.tsx b/src/components/AnchorMenu/AnchorMenu.tsx index 1647829..5b35e68 100644 --- a/src/components/AnchorMenu/AnchorMenu.tsx +++ b/src/components/AnchorMenu/AnchorMenu.tsx @@ -38,7 +38,7 @@ interface Node { interface ExtendedNode { node: Node; - path: string[]; + path: string[] | number[]; } // Event type definitions for moving nodes and toggling node visibility in the tree @@ -46,8 +46,8 @@ interface NodeMoveEvent { treeData: Node[]; nextParentNode: Node; node: Node; - nextPath: string[]; - prevPath: string[]; + nextPath: number[]; + prevPath: number[]; } interface NodeVisibilityToggleEvent { @@ -105,6 +105,11 @@ const YourExternalNodeComponent = ({ node }: { node: Node }): JSX.Element | null ); }; +// Add a helper function to handle both types of paths +const convertPath = (path: string[] | number[]): string[] => { + return path.map(String); +}; + // The main component "AnchorMenu" const AnchorMenu = (props: AnchorMenuProps): JSX.Element => { const { t } = useTranslation(); @@ -132,10 +137,11 @@ const AnchorMenu = (props: AnchorMenuProps): JSX.Element => { return extendedNode.node.title; }; - const treePathToOrderArray = (treePath: string[]): string[] => { + // Update treePathToOrderArray to use the helper + const treePathToOrderArray = (treePath: number[]): string[] => { const newPath = [...treePath]; newPath.splice(-1); - return newPath; + return convertPath(newPath); }; const hasValidationError = (linkId: string): boolean => { @@ -242,7 +248,7 @@ const AnchorMenu = (props: AnchorMenuProps): JSX.Element => { props.dispatch( updateMarkedLinkIdAction( extendedNode.node.title, - treePathToOrderArray(extendedNode.path), + convertPath(extendedNode.path), ), ); }} @@ -258,7 +264,7 @@ const AnchorMenu = (props: AnchorMenuProps): JSX.Element => { buttons: generateItemButtons( t, props.qItems[extendedNode.node.title], - treePathToOrderArray(extendedNode.path), + convertPath(extendedNode.path), false, props.dispatch, ), diff --git a/src/components/Languages/Translation/TranslationModal.tsx b/src/components/Languages/Translation/TranslationModal.tsx index 9d46eaf..2a8a6b7 100644 --- a/src/components/Languages/Translation/TranslationModal.tsx +++ b/src/components/Languages/Translation/TranslationModal.tsx @@ -262,7 +262,7 @@ const TranslationModal = (props: TranslationModalProps): JSX.Element => { )}
{t('Elements')}
- {renderItems(flattOrder.filter((val, i) => i <= count))} + {renderItems(flattOrder.filter((_, i) => i <= count))}
{ const [value, setValue] = useState(props.data); - const handleChange = (event: Event, editor: Editor) => { + const handleChange = (_unused: unknown, editor: Editor) => { setValue(editor.getData()); }; - const handleBlur = (event: Event, editor: Editor) => { + const handleBlur = (_unused: unknown, editor: Editor) => { if (props.onBlur) { props.onBlur(editor.getData()); } diff --git a/src/components/Metadata/MetadataEditor.tsx b/src/components/Metadata/MetadataEditor.tsx index b889cf3..f3b72c7 100644 --- a/src/components/Metadata/MetadataEditor.tsx +++ b/src/components/Metadata/MetadataEditor.tsx @@ -15,7 +15,6 @@ import { TreeContext } from '../../store/treeStore/treeStore'; import { updateQuestionnaireMetadataAction } from '../../store/treeStore/treeActions'; import RadioBtn from '../RadioBtn/RadioBtn'; import InputField from '../InputField/inputField'; -import { UseContextSystem } from '../../types/IQuestionnareItemType'; const MetadataEditor = (): JSX.Element => { const { t } = useTranslation(); @@ -31,17 +30,6 @@ const MetadataEditor = (): JSX.Element => { dispatch(updateQuestionnaireMetadataAction(propName, value)); }; - const getUseContextSystem = (): string => { - const system = - qMetadata.useContext && - qMetadata.useContext.length > 0 && - qMetadata.useContext[0].valueCodeableConcept?.coding && - qMetadata.useContext[0].valueCodeableConcept.coding.length > 0 && - qMetadata.useContext[0].valueCodeableConcept.coding[0].system; - - return system || UseContextSystem.helsetjeneste_full; - }; - return (
diff --git a/src/components/Question/Question.tsx b/src/components/Question/Question.tsx index 4e37fad..6744261 100644 --- a/src/components/Question/Question.tsx +++ b/src/components/Question/Question.tsx @@ -166,7 +166,7 @@ const Question = (props: QuestionProps): JSX.Element => { {instructionType()}
- {/* + Markdown not currently supported { } }} /> - */} + {canTypeBeRequired(props.item) && ( { } {isSlider && } - {/* Sublabel is not currently supported {canTypeHaveSublabel(props.item) && ( { }} /> - )} */} + )} {respondType()}
diff --git a/src/components/Question/QuestionType/Choice.tsx b/src/components/Question/QuestionType/Choice.tsx index a64b452..52e23f8 100644 --- a/src/components/Question/QuestionType/Choice.tsx +++ b/src/components/Question/QuestionType/Choice.tsx @@ -21,7 +21,7 @@ import SwitchBtn from '../../SwitchBtn/SwitchBtn'; import { createUriUUID } from '../../../helpers/uriHelper'; import DraggableAnswerOptions from '../../AnswerOption/DraggableAnswerOptions'; import PredefinedValueSets from './PredefinedValueSets'; -import { ItemControlType, isItemControlCheckbox, isItemControlDropDown } from '../../../helpers/itemControl'; +import { ItemControlType, isItemControlCheckbox } from '../../../helpers/itemControl'; import { checkboxExtension } from '../../../helpers/QuestionHelper'; type Props = { diff --git a/src/serviceWorker.ts b/src/serviceWorker.ts index b09523f..7eaa60a 100644 --- a/src/serviceWorker.ts +++ b/src/serviceWorker.ts @@ -29,7 +29,7 @@ export function register(config?: Config) { if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { // The URL constructor is available in all browsers that support SW. const publicUrl = new URL( - process.env.PUBLIC_URL, + process.env.PUBLIC_URL || '', // Provide empty string as fallback window.location.href ); if (publicUrl.origin !== window.location.origin) {