@uva-glass/component-library 3.52.11 → 3.53.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Lexical.prod-sd_e2sqT.js → Lexical.prod-CNQPQ6W-.js} +1428 -1410
- package/dist/Lexical.prod-CNQPQ6W-.js.map +1 -0
- package/dist/{LexicalClipboard.prod-Co2PF1UJ.js → LexicalClipboard.prod-BdghxvkJ.js} +75 -75
- package/dist/{LexicalClipboard.prod-Co2PF1UJ.js.map → LexicalClipboard.prod-BdghxvkJ.js.map} +1 -1
- package/dist/LexicalExtension.prod-qYTg6Mah.js +551 -0
- package/dist/LexicalExtension.prod-qYTg6Mah.js.map +1 -0
- package/dist/LexicalLink.prod-DjG5QZHP.js +502 -0
- package/dist/LexicalLink.prod-DjG5QZHP.js.map +1 -0
- package/dist/{LexicalList.prod-CIB0K0ja.js → LexicalList.prod-CzxWmBG3.js} +65 -65
- package/dist/LexicalList.prod-CzxWmBG3.js.map +1 -0
- package/dist/{LexicalSelection.prod-CCmcTP6S.js → LexicalSelection.prod-CqTp0hfr.js} +44 -44
- package/dist/LexicalSelection.prod-CqTp0hfr.js.map +1 -0
- package/dist/{LexicalTable.prod-Oa2YPHLl.js → LexicalTable.prod-C97KnedB.js} +331 -319
- package/dist/LexicalTable.prod-C97KnedB.js.map +1 -0
- package/dist/{LexicalUtils.prod-CjKjgnmx.js → LexicalUtils.prod-lqA_upYF.js} +39 -39
- package/dist/LexicalUtils.prod-lqA_upYF.js.map +1 -0
- package/dist/RteEditor.module-DaBh86FK.js +41 -0
- package/dist/RteEditor.module-DaBh86FK.js.map +1 -0
- package/dist/{TableCellResizerPlugin-DATbSzfg.js → TableCellResizerPlugin-BdgrIlKp.js} +57 -57
- package/dist/{TableCellResizerPlugin-DATbSzfg.js.map → TableCellResizerPlugin-BdgrIlKp.js.map} +1 -1
- package/dist/{TablePlugin-CqCjNBW_.js → TablePlugin-DBKzGTIm.js} +70 -70
- package/dist/{TablePlugin-CqCjNBW_.js.map → TablePlugin-DBKzGTIm.js.map} +1 -1
- package/dist/assets/AddCatalogueLinkForm.css +1 -0
- package/dist/assets/Flyout.css +1 -1
- package/dist/assets/RteEditor.css +1 -1
- package/dist/assets/variables.css +72 -72
- package/dist/chunk-GPBRNGY5-UqVYj0H5.js +4507 -0
- package/dist/chunk-GPBRNGY5-UqVYj0H5.js.map +1 -0
- package/dist/{client-CFLMKOFW.js → client-DkvV9jg_.js} +90 -90
- package/dist/{client-CFLMKOFW.js.map → client-DkvV9jg_.js.map} +1 -1
- package/dist/components/Accordion/Accordion.test.js +2 -2
- package/dist/components/AccordionCard/AccordionCard.test.js +2 -2
- package/dist/components/ActionList/ActionList.test.js +2 -2
- package/dist/components/AppStatusBar/AppStatusBar.test.js +1 -1
- package/dist/components/Attention/Attention.test.js +1 -1
- package/dist/components/Backdrop/Backdrop.test.js +1 -1
- package/dist/components/Buttons/Button.stories.js +1 -1
- package/dist/components/Buttons/Button.test.js +1 -1
- package/dist/components/Buttons/LinkButton.stories.js +1 -1
- package/dist/components/Buttons/LinkButton.test.js +1 -1
- package/dist/components/Buttons/MenuButton.stories.js +1 -1
- package/dist/components/Buttons/MenuButton.test.js +1 -1
- package/dist/components/Card/Card.test.js +1 -1
- package/dist/components/Checkbox/Checkbox.stories.js +1 -1
- package/dist/components/Checkbox/Checkbox.test.js +2 -2
- package/dist/components/CheckboxButtonBar/CheckboxButtonBar.stories.js +1 -1
- package/dist/components/CheckboxButtonBar/CheckboxButtonBar.test.js +1 -1
- package/dist/components/CheckboxTree/CheckboxTree.js +1 -1
- package/dist/components/CheckboxTree/CheckboxTree.stories.js +111 -55
- package/dist/components/CheckboxTree/CheckboxTree.stories.js.map +1 -1
- package/dist/components/Chip/Chip.stories.js +1 -1
- package/dist/components/ControlsButton/ControlsButton.stories.js +1 -1
- package/dist/components/Drawer/Drawer.stories.js +1 -1
- package/dist/components/FeedbackBar/FeedbackBar.test.js +1 -1
- package/dist/components/FormInput/FormInput.js +1 -1
- package/dist/components/FormInput/FormInput.stories.js +1 -1
- package/dist/components/IconButton/IconButton.stories.js +1 -1
- package/dist/components/InputField/InputField.stories.js +2 -2
- package/dist/components/Label/Label.test.js +1 -1
- package/dist/components/MetaDataBar/MetaDataBar.test.js +1 -1
- package/dist/components/ModalDialog/ModalDialog.stories.js +1 -1
- package/dist/components/MultiSelect/MultiSelect.js +1 -1
- package/dist/components/MultiSelect/MultiSelect.stories.js +2 -2
- package/dist/components/MultiSelect/components/MultiSelectHeader.js +1 -1
- package/dist/components/MultiSelect/index.js +1 -1
- package/dist/components/MultiSelectBox/MultiSelectBox.stories.js +1 -1
- package/dist/components/MultiSelectBox/MultiSelectBox.test.js +1 -1
- package/dist/components/Notification/Notification.stories.js +1 -1
- package/dist/components/Notification/Notification.test.js +1 -1
- package/dist/components/OverlayCloseButton/OverlayCloseButton.stories.js +1 -1
- package/dist/components/PeriodSelector/PeriodSelector.js +1 -1
- package/dist/components/PeriodSelector/PeriodSelector.stories.js +1 -1
- package/dist/components/ProgrammeCard/ProgrammeCard.stories.js +1 -1
- package/dist/components/RadioGroup/RadioGroup.stories.js +1 -1
- package/dist/components/RadioGroup/Radiogroup.test.js +1 -1
- package/dist/components/RadioTabSelector/RadioTabSelector.js +1 -1
- package/dist/components/RadioTabSelector/RadioTabSelector.stories.js +1 -1
- package/dist/components/RteEditor/EditorHeader/EditorHeader.js +1 -1
- package/dist/components/RteEditor/Plugins/BlockFormatPlugin/BlockFormatPlugin.js +2 -2
- package/dist/components/RteEditor/Plugins/CourseCataloguePlugin/AddCatalogueLinkForm/AddCatalogueLinkForm.d.ts +22 -0
- package/dist/components/RteEditor/Plugins/CourseCataloguePlugin/AddCatalogueLinkForm/AddCatalogueLinkForm.js +108 -0
- package/dist/components/RteEditor/Plugins/CourseCataloguePlugin/AddCatalogueLinkForm/AddCatalogueLinkForm.js.map +1 -0
- package/dist/components/RteEditor/Plugins/CourseCataloguePlugin/AddCatalogueLinkForm/index.d.ts +1 -0
- package/dist/components/RteEditor/Plugins/CourseCataloguePlugin/AddCatalogueLinkForm/index.js +5 -0
- package/dist/components/RteEditor/Plugins/CourseCataloguePlugin/AddCatalogueLinkForm/index.js.map +1 -0
- package/dist/components/RteEditor/Plugins/CourseCataloguePlugin/CourseCataloguePlugin.d.ts +8 -0
- package/dist/components/RteEditor/Plugins/CourseCataloguePlugin/CourseCataloguePlugin.js +182 -0
- package/dist/components/RteEditor/Plugins/CourseCataloguePlugin/CourseCataloguePlugin.js.map +1 -0
- package/dist/components/RteEditor/Plugins/CourseCataloguePlugin/index.d.ts +1 -0
- package/dist/components/RteEditor/Plugins/CourseCataloguePlugin/index.js +5 -0
- package/dist/components/RteEditor/Plugins/CourseCataloguePlugin/index.js.map +1 -0
- package/dist/components/RteEditor/Plugins/HistoryPlugin/HistoryPlugin.js +6 -6
- package/dist/components/RteEditor/Plugins/LinkPlugin/AddLinkForm/AddLinkFrom.js +2 -2
- package/dist/components/RteEditor/Plugins/LinkPlugin/LinkPlugin.d.ts +0 -2
- package/dist/components/RteEditor/Plugins/LinkPlugin/LinkPlugin.js +108 -128
- package/dist/components/RteEditor/Plugins/LinkPlugin/LinkPlugin.js.map +1 -1
- package/dist/components/RteEditor/Plugins/LinkPlugin/helpers.js +1 -1
- package/dist/components/RteEditor/Plugins/LinkPlugin/index.js +2 -3
- package/dist/components/RteEditor/Plugins/ListPlugin/ListPlugin.js +52 -57
- package/dist/components/RteEditor/Plugins/ListPlugin/ListPlugin.js.map +1 -1
- package/dist/components/RteEditor/Plugins/PasteHandlerPlugin/PasteHandlerPlugin.js +7 -7
- package/dist/components/RteEditor/Plugins/TableCellResizerPlugin/TableCellResizerPlugin.js +4 -4
- package/dist/components/RteEditor/Plugins/TableCellResizerPlugin/index.js +1 -1
- package/dist/components/RteEditor/Plugins/TablePlugin/AddTableFrom.js +2 -2
- package/dist/components/RteEditor/Plugins/TablePlugin/TablePlugin.js +6 -6
- package/dist/components/RteEditor/Plugins/TablePlugin/helpers.js +25 -24
- package/dist/components/RteEditor/Plugins/TablePlugin/helpers.js.map +1 -1
- package/dist/components/RteEditor/Plugins/TablePlugin/index.js +1 -1
- package/dist/components/RteEditor/Plugins/ToolbarPlugin/ToolbarPlugin.d.ts +4 -1
- package/dist/components/RteEditor/Plugins/ToolbarPlugin/ToolbarPlugin.js +66 -53
- package/dist/components/RteEditor/Plugins/ToolbarPlugin/ToolbarPlugin.js.map +1 -1
- package/dist/components/RteEditor/Plugins/index.js +8 -9
- package/dist/components/RteEditor/Providers/LanguageProvider.d.ts +2 -2
- package/dist/components/RteEditor/Providers/LanguageProvider.js +4 -4
- package/dist/components/RteEditor/Providers/LanguageProvider.js.map +1 -1
- package/dist/components/RteEditor/RteEditor.d.ts +8 -3
- package/dist/components/RteEditor/RteEditor.js +375 -347
- package/dist/components/RteEditor/RteEditor.js.map +1 -1
- package/dist/components/RteEditor/RteEditor.stories.js +69 -33
- package/dist/components/RteEditor/RteEditor.stories.js.map +1 -1
- package/dist/components/RteEditor/UvaTheme/UvaTheme.d.ts +1 -0
- package/dist/components/RteEditor/UvaTheme/UvaTheme.js +3 -2
- package/dist/components/RteEditor/UvaTheme/UvaTheme.js.map +1 -1
- package/dist/components/RteEditor/helpers.js +26 -23
- package/dist/components/RteEditor/helpers.js.map +1 -1
- package/dist/components/RteEditor/hooks/components/Flyout.js +6 -16
- package/dist/components/RteEditor/hooks/components/Flyout.js.map +1 -1
- package/dist/components/RteEditor/hooks/useTranslation.d.ts +39 -1
- package/dist/components/RteEditor/hooks/useTranslation.js +6 -6
- package/dist/components/RteEditor/hooks/useTranslation.js.map +1 -1
- package/dist/components/RteEditor/mockCatalogueSearchData.d.ts +18 -0
- package/dist/components/RteEditor/mockCatalogueSearchData.js +485 -0
- package/dist/components/RteEditor/mockCatalogueSearchData.js.map +1 -0
- package/dist/components/RteEditor/mockRteContent.d.ts +1 -1
- package/dist/components/RteEditor/mockRteContent.js +8 -6
- package/dist/components/RteEditor/mockRteContent.js.map +1 -1
- package/dist/components/RteEditor/nodes/CourseCatalogueNode/CourseCatalogueNode.d.ts +29 -0
- package/dist/components/RteEditor/nodes/CourseCatalogueNode/CourseCatalogueNode.js +126 -0
- package/dist/components/RteEditor/nodes/CourseCatalogueNode/CourseCatalogueNode.js.map +1 -0
- package/dist/components/RteEditor/nodes/CourseCatalogueNode/index.d.ts +1 -0
- package/dist/components/RteEditor/nodes/CourseCatalogueNode/index.js +11 -0
- package/dist/components/RteEditor/nodes/CourseCatalogueNode/index.js.map +1 -0
- package/dist/components/RteEditor/nodes/TableWrapperNode/TableWrapperNode.js +58 -52
- package/dist/components/RteEditor/nodes/TableWrapperNode/TableWrapperNode.js.map +1 -1
- package/dist/components/RteEditor/nodes/index.d.ts +1 -0
- package/dist/components/RteEditor/nodes/index.js +14 -6
- package/dist/components/RteEditor/nodes/index.js.map +1 -1
- package/dist/components/RteEditor/translations.d.ts +41 -3
- package/dist/components/RteEditor/translations.js +44 -6
- package/dist/components/RteEditor/translations.js.map +1 -1
- package/dist/components/SelectListbox/SelectListBox.stories.js +1 -1
- package/dist/components/Sortable/Sortable.stories.js +1 -1
- package/dist/components/StatusBadge/StatusBadge.test.js +1 -1
- package/dist/components/TextArea/TextArea.stories.js +1 -1
- package/dist/components/TextArea/TextArea.test.js +2 -2
- package/dist/components/ToggleSwitch/ToggleSwitch.stories.js +1 -1
- package/dist/components/VarIndicator/VarIndicator.stories.js +1 -1
- package/dist/components/VarIndicator/VarIndicator.test.js +2 -2
- package/dist/components/index.js +1 -1
- package/dist/{index-DRQMriwT.js → index-BmvI9fji.js} +8665 -10000
- package/dist/index-BmvI9fji.js.map +1 -0
- package/dist/{index-BKK3EWVW.js → index-Daa6JVq6.js} +2 -2
- package/dist/{index-BKK3EWVW.js.map → index-Daa6JVq6.js.map} +1 -1
- package/dist/index.js +1 -1
- package/dist/react-18-vQ75Numl.js +41 -0
- package/dist/react-18-vQ75Numl.js.map +1 -0
- package/dist/{react.esm-BjO203QT.js → react.esm-CzkD5JmE.js} +2 -2
- package/dist/{react.esm-BjO203QT.js.map → react.esm-CzkD5JmE.js.map} +1 -1
- package/dist/storybook__react.d.js +4252 -4509
- package/dist/storybook__react.d.js.map +1 -1
- package/package.json +27 -27
- package/dist/Lexical.prod-sd_e2sqT.js.map +0 -1
- package/dist/LexicalLink.prod-BCE6Bg2N.js +0 -1047
- package/dist/LexicalLink.prod-BCE6Bg2N.js.map +0 -1
- package/dist/LexicalList.prod-CIB0K0ja.js.map +0 -1
- package/dist/LexicalSelection.prod-CCmcTP6S.js.map +0 -1
- package/dist/LexicalTable.prod-Oa2YPHLl.js.map +0 -1
- package/dist/LexicalUtils.prod-CjKjgnmx.js.map +0 -1
- package/dist/RteEditor.module-CUi7Vqe8.js +0 -37
- package/dist/RteEditor.module-CUi7Vqe8.js.map +0 -1
- package/dist/chunk-HERDX7MO-DaYu-eWo.js +0 -11320
- package/dist/chunk-HERDX7MO-DaYu-eWo.js.map +0 -1
- package/dist/index-DRQMriwT.js.map +0 -1
- package/dist/react-18-C6foUf2n.js +0 -42
- package/dist/react-18-C6foUf2n.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListPlugin.js","sources":["../../../../../src/components/RteEditor/Plugins/ListPlugin/ListPlugin.tsx"],"sourcesContent":["import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';\nimport {\n $createListNode,\n $isListItemNode,\n $isListNode,\n INSERT_ORDERED_LIST_COMMAND,\n INSERT_UNORDERED_LIST_COMMAND,\n REMOVE_LIST_COMMAND,\n} from '@lexical/list';\nimport { useEffect, useState } from 'react';\nimport { clsx } from 'clsx';\nimport {\n $getSelection,\n $isRangeSelection,\n COMMAND_PRIORITY_EDITOR,\n COMMAND_PRIORITY_LOW,\n KEY_DOWN_COMMAND,\n KEY_TAB_COMMAND,\n} from 'lexical';\n\nimport type {
|
|
1
|
+
{"version":3,"file":"ListPlugin.js","sources":["../../../../../src/components/RteEditor/Plugins/ListPlugin/ListPlugin.tsx"],"sourcesContent":["import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';\nimport {\n $createListNode,\n $isListItemNode,\n $isListNode,\n INSERT_ORDERED_LIST_COMMAND,\n INSERT_UNORDERED_LIST_COMMAND,\n ListNode,\n REMOVE_LIST_COMMAND,\n} from '@lexical/list';\nimport { useEffect, useState } from 'react';\nimport { clsx } from 'clsx';\nimport {\n $getSelection,\n $isRangeSelection,\n COMMAND_PRIORITY_EDITOR,\n COMMAND_PRIORITY_LOW,\n KEY_DOWN_COMMAND,\n KEY_TAB_COMMAND,\n} from 'lexical';\nimport { $getNearestNodeOfType } from '@lexical/utils';\n\nimport type { RangeSelection } from 'lexical';\n\nimport { Icon } from 'components/Icon';\nimport styles from 'components/RteEditor/RteEditor.module.css';\nimport { useTranslation } from 'components/RteEditor/hooks/useTranslation';\n\ntype ListTypesType = 'bullet' | 'number' | null;\nconst LIST_TYPE_ICONS = {\n bullet: 'BulletList',\n number: 'NumberedList',\n};\n\nconst ListTypes = ['bullet', 'number'];\n\nexport const ListPlugin = () => {\n const t = useTranslation();\n const [editor] = useLexicalComposerContext();\n const [blockType, setBlockType] = useState<ListTypesType>(null);\n const [isUList, setIsUList] = useState<boolean>(false);\n const [isOList, setIsOList] = useState<boolean>(false);\n\n const formatList = (listType: ListTypesType): void => {\n if (listType === 'number' && blockType !== 'number') {\n editor.dispatchCommand(INSERT_ORDERED_LIST_COMMAND, undefined);\n setBlockType('number');\n } else if (listType === 'bullet' && blockType !== 'bullet') {\n editor.dispatchCommand(INSERT_UNORDERED_LIST_COMMAND, undefined);\n setBlockType('bullet');\n } else {\n editor.dispatchCommand(REMOVE_LIST_COMMAND, undefined);\n setBlockType(null);\n }\n };\n\n useEffect(() => {\n const removeKeyboardShortcut = editor.registerCommand(\n KEY_DOWN_COMMAND,\n (event: KeyboardEvent) => {\n if (event.ctrlKey && event.shiftKey && event.code === 'Digit7') {\n event.preventDefault();\n if (isOList) {\n editor.dispatchCommand(REMOVE_LIST_COMMAND, undefined);\n } else {\n editor.dispatchCommand(INSERT_ORDERED_LIST_COMMAND, undefined);\n }\n return true;\n }\n if (event.ctrlKey && event.shiftKey && event.code === 'Digit8') {\n event.preventDefault();\n if (isUList) {\n editor.dispatchCommand(REMOVE_LIST_COMMAND, undefined);\n } else {\n editor.dispatchCommand(INSERT_UNORDERED_LIST_COMMAND, undefined);\n }\n return true;\n }\n return false;\n },\n COMMAND_PRIORITY_EDITOR\n );\n\n return () => {\n removeKeyboardShortcut();\n };\n }, [editor, isOList, isUList]);\n\n useEffect(() => {\n const removeTabCommand = editor.registerCommand(\n KEY_TAB_COMMAND,\n (event) => {\n event.preventDefault();\n editor.update(() => {\n const selection = $getSelection() as RangeSelection;\n if (!$isRangeSelection(selection)) {\n return;\n }\n\n const currentNode = selection.anchor.getNode();\n const parent = currentNode.getParent();\n if (!$isListItemNode(parent)) {\n return;\n }\n\n const listParent = parent.getParent();\n if ($isListNode(listParent)) {\n const newList = $createListNode($isListNode(listParent) ? listParent.getListType() : 'bullet');\n parent.append(newList);\n newList.append(currentNode);\n }\n });\n return true;\n },\n COMMAND_PRIORITY_LOW\n );\n\n const removeStatusListener = editor.registerUpdateListener(({ editorState }) => {\n editorState.read(() => {\n const selection = $getSelection();\n if ($isRangeSelection(selection)) {\n const anchorNode = selection.anchor.getNode();\n const listNode = $getNearestNodeOfType(anchorNode, ListNode);\n if (listNode) {\n const tag = listNode.getTag();\n setIsUList(tag === 'ul');\n setIsOList(tag === 'ol');\n if (tag === 'ul') {\n setBlockType('bullet');\n }\n if (tag === 'ol') {\n setBlockType('number');\n }\n return;\n }\n setIsUList(false);\n setIsOList(false);\n setBlockType(null);\n }\n return false;\n });\n });\n\n return () => {\n removeStatusListener();\n removeTabCommand();\n };\n }, [editor]);\n\n return (\n <div className={styles['editor__toolbar-button-group']}>\n {ListTypes.map((listType) => (\n <button\n onClick={() => formatList(listType as ListTypesType)}\n key={listType}\n title={t.format[`${listType}Tooltip` as keyof typeof t.format]}\n className={clsx(\n styles['editor__toolbar-button'],\n styles[`editor__toolbar-button--${listType}`],\n listType === 'bullet' && isUList && styles['editor__toolbar-button--active'],\n listType === 'number' && isOList && styles['editor__toolbar-button--active']\n )}\n aria-label={t.aria.labels[listType as keyof typeof t.aria.labels]}\n aria-keyshortcuts={t.aria.keyshortcuts[listType as keyof typeof t.aria.keyshortcuts]}\n type=\"button\"\n >\n <Icon name={LIST_TYPE_ICONS[listType as keyof typeof Icon]} size={24} />\n </button>\n ))}\n </div>\n );\n};\n"],"names":["LIST_TYPE_ICONS","ListTypes","ListPlugin","t","useTranslation","editor","useLexicalComposerContext","blockType","setBlockType","useState","isUList","setIsUList","isOList","setIsOList","formatList","listType","INSERT_ORDERED_LIST_COMMAND","INSERT_UNORDERED_LIST_COMMAND","REMOVE_LIST_COMMAND","useEffect","removeKeyboardShortcut","KEY_DOWN_COMMAND","event","COMMAND_PRIORITY_EDITOR","removeTabCommand","KEY_TAB_COMMAND","selection","$getSelection","$isRangeSelection","currentNode","parent","$isListItemNode","listParent","$isListNode","newList","$createListNode","COMMAND_PRIORITY_LOW","removeStatusListener","editorState","anchorNode","listNode","$getNearestNodeOfType","ListNode","tag","jsx","styles","clsx","Icon"],"mappings":";;;;;;;;;;AA6BA,MAAMA,IAAkB;AAAA,EACtB,QAAQ;AAAA,EACR,QAAQ;AACV,GAEMC,IAAY,CAAC,UAAU,QAAQ,GAExBC,IAAa,MAAM;AAC9B,QAAMC,IAAIC,EAAA,GACJ,CAACC,CAAM,IAAIC,EAAA,GACX,CAACC,GAAWC,CAAY,IAAIC,EAAwB,IAAI,GACxD,CAACC,GAASC,CAAU,IAAIF,EAAkB,EAAK,GAC/C,CAACG,GAASC,CAAU,IAAIJ,EAAkB,EAAK,GAE/CK,IAAa,CAACC,MAAkC;AACpD,IAAIA,MAAa,YAAYR,MAAc,YACzCF,EAAO,gBAAgBW,GAA6B,MAAS,GAC7DR,EAAa,QAAQ,KACZO,MAAa,YAAYR,MAAc,YAChDF,EAA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AA;AAAA,IAZjEA;AAAA,EAAA,CAcR,GACH;AAEJ;"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { o as m } from "../../../../LexicalComposerContext.prod-DOyoZx0P.js";
|
|
2
2
|
import { useEffect as c } from "react";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { R as
|
|
3
|
+
import { n as f, ah as p, c as u } from "../../../../Lexical.prod-CNQPQ6W-.js";
|
|
4
|
+
import { P as i } from "../../../../LexicalUtils.prod-lqA_upYF.js";
|
|
5
|
+
import { R as d } from "../../../../LexicalClipboard.prod-BdghxvkJ.js";
|
|
6
6
|
import { d as D } from "../../../../index-yEhaxKq-.js";
|
|
7
|
-
const
|
|
7
|
+
const w = () => {
|
|
8
8
|
const [e] = m(), l = (t) => {
|
|
9
9
|
t.preventDefault(), e.update(() => {
|
|
10
|
-
const r =
|
|
10
|
+
const r = u(), a = i(t, InputEvent) || i(t, KeyboardEvent) ? null : t.clipboardData;
|
|
11
11
|
if (a != null && r !== null) {
|
|
12
12
|
const o = a.getData("text/html") || a.getData("text/plain"), n = new DataTransfer(), s = new D.MSWordNormalizer();
|
|
13
|
-
n.setData("text/html", o), s.isActive(o) && n.setData("text/html", s.normalize(o)),
|
|
13
|
+
n.setData("text/html", o), s.isActive(o) && n.setData("text/html", s.normalize(o)), d(n, r, e);
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
16
|
};
|
|
@@ -26,6 +26,6 @@ const L = () => {
|
|
|
26
26
|
}, [e]), null;
|
|
27
27
|
};
|
|
28
28
|
export {
|
|
29
|
-
|
|
29
|
+
w as PasteHandlerPlugin
|
|
30
30
|
};
|
|
31
31
|
//# sourceMappingURL=PasteHandlerPlugin.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
3
|
import "../../../../LexicalComposerContext.prod-DOyoZx0P.js";
|
|
4
|
-
import { T as b } from "../../../../TableCellResizerPlugin-
|
|
5
|
-
import "../../../../LexicalTable.prod-
|
|
6
|
-
import "../../../../LexicalUtils.prod-
|
|
7
|
-
import "../../../../Lexical.prod-
|
|
4
|
+
import { T as b } from "../../../../TableCellResizerPlugin-BdgrIlKp.js";
|
|
5
|
+
import "../../../../LexicalTable.prod-C97KnedB.js";
|
|
6
|
+
import "../../../../LexicalUtils.prod-lqA_upYF.js";
|
|
7
|
+
import "../../../../Lexical.prod-CNQPQ6W-.js";
|
|
8
8
|
import "react-dom";
|
|
9
9
|
import "../TablePlugin/helpers.js";
|
|
10
10
|
import "../../nodes/TableWrapperNode/TableWrapperNode.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
|
-
import { b as G } from "../../../../TablePlugin-
|
|
3
|
+
import { b as G } from "../../../../TablePlugin-DBKzGTIm.js";
|
|
4
4
|
import "../../../Accordion/Accordion.js";
|
|
5
5
|
import "../../../Buttons/Button.js";
|
|
6
6
|
import "../../../Buttons/LinkButton.js";
|
|
@@ -19,11 +19,11 @@ import "../../../InputField/InputField.js";
|
|
|
19
19
|
import "react-router";
|
|
20
20
|
import "../../helpers.js";
|
|
21
21
|
import "../../hooks/useTranslation.js";
|
|
22
|
+
import "../../Providers/LanguageProvider.js";
|
|
22
23
|
import "../LinkPlugin/LinkContextMenu/LinkContextMenu.js";
|
|
23
24
|
import "../../hooks/components/Flyout.js";
|
|
24
25
|
import "react-dom";
|
|
25
26
|
import "../../../../index-yEhaxKq-.js";
|
|
26
|
-
import "../../Providers/LanguageProvider.js";
|
|
27
27
|
import "../../../SearchField/SearchField.js";
|
|
28
28
|
import "../../../SelectListbox/SelectListbox.js";
|
|
29
29
|
import "../../../SelectListbox/SelectProvider.js";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import "react/jsx-runtime";
|
|
2
2
|
import "../../../../LexicalComposerContext.prod-DOyoZx0P.js";
|
|
3
3
|
import "../../../../clsx-OuTLNxxd.js";
|
|
4
|
-
import "../../../../LexicalTable.prod-
|
|
5
|
-
import "../../../../Lexical.prod-
|
|
6
|
-
import "../../../../LexicalUtils.prod-
|
|
4
|
+
import "../../../../LexicalTable.prod-C97KnedB.js";
|
|
5
|
+
import "../../../../Lexical.prod-CNQPQ6W-.js";
|
|
6
|
+
import "../../../../LexicalUtils.prod-lqA_upYF.js";
|
|
7
7
|
import "react";
|
|
8
|
-
import { T as L } from "../../../../TablePlugin-
|
|
8
|
+
import { T as L } from "../../../../TablePlugin-DBKzGTIm.js";
|
|
9
9
|
import "./helpers.js";
|
|
10
10
|
import "../../nodes/TableWrapperNode/TableWrapperNode.js";
|
|
11
11
|
import "../../hooks/useFlyout.js";
|
|
@@ -24,12 +24,12 @@ import "../../../IconButton/IconButton.js";
|
|
|
24
24
|
import "../../../Input/Input.js";
|
|
25
25
|
import "../../../InputField/InputField.js";
|
|
26
26
|
import "react-router";
|
|
27
|
-
import "../../../../RteEditor.module-
|
|
27
|
+
import "../../../../RteEditor.module-DaBh86FK.js";
|
|
28
28
|
import "../../hooks/useTranslation.js";
|
|
29
|
+
import "../../Providers/LanguageProvider.js";
|
|
29
30
|
import "../LinkPlugin/LinkContextMenu/LinkContextMenu.js";
|
|
30
31
|
import "react-dom";
|
|
31
32
|
import "../../../../index-yEhaxKq-.js";
|
|
32
|
-
import "../../Providers/LanguageProvider.js";
|
|
33
33
|
import "../../../SearchField/SearchField.js";
|
|
34
34
|
import "../../../SelectListbox/SelectListbox.js";
|
|
35
35
|
import "../../../SelectListbox/SelectProvider.js";
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { TableWrapperNode as
|
|
4
|
-
|
|
1
|
+
import { Z as p, A as i, I as w, s as T, J as u, U as b, e as E, D, $ as g, V as I, B as R, O as x } from "../../../../LexicalTable.prod-C97KnedB.js";
|
|
2
|
+
import { $ as S } from "../../../../Lexical.prod-CNQPQ6W-.js";
|
|
3
|
+
import { TableWrapperNode as N } from "../../nodes/TableWrapperNode/TableWrapperNode.js";
|
|
4
|
+
import "react";
|
|
5
|
+
const F = 32, a = 48, W = 1, B = 200, P = 320, A = (t, e) => {
|
|
5
6
|
const n = R(0, 0, !1);
|
|
6
7
|
for (let o = 0; o < t; o++) {
|
|
7
8
|
const r = g();
|
|
8
9
|
for (let s = 0; s < e; s++) {
|
|
9
10
|
const l = x(0, void 0, void 0);
|
|
10
|
-
l.append(
|
|
11
|
+
l.append(S()), r.append(l);
|
|
11
12
|
}
|
|
12
13
|
n.append(r);
|
|
13
14
|
}
|
|
@@ -18,12 +19,12 @@ const y = 32, a = 48, N = 1, P = 200, v = 320, M = (t, e) => {
|
|
|
18
19
|
const r = n.getFirstDescendant();
|
|
19
20
|
r && r.select();
|
|
20
21
|
}
|
|
21
|
-
},
|
|
22
|
-
const e =
|
|
22
|
+
}, O = (t) => {
|
|
23
|
+
const e = p(t);
|
|
23
24
|
if (!e)
|
|
24
25
|
throw new Error("Selected node is not a TableCellNode");
|
|
25
26
|
const n = e.getParent();
|
|
26
|
-
n instanceof
|
|
27
|
+
n instanceof N ? n.remove() : e.remove();
|
|
27
28
|
}, U = (t, e) => {
|
|
28
29
|
if (!i(t))
|
|
29
30
|
throw new Error("Selected node is not a TableCellNode");
|
|
@@ -31,7 +32,7 @@ const y = 32, a = 48, N = 1, P = 200, v = 320, M = (t, e) => {
|
|
|
31
32
|
I(e === "insertRowBelow");
|
|
32
33
|
const o = n.getFirstDescendant();
|
|
33
34
|
o && o.select();
|
|
34
|
-
},
|
|
35
|
+
}, M = (t, e) => {
|
|
35
36
|
if (!i(t))
|
|
36
37
|
throw new Error("Selected node is not a TableCellNode");
|
|
37
38
|
const n = w(t);
|
|
@@ -48,11 +49,11 @@ const y = 32, a = 48, N = 1, P = 200, v = 320, M = (t, e) => {
|
|
|
48
49
|
n.setColWidths(C), o = e === "insertColumnLeft" ? o : o + 1;
|
|
49
50
|
const f = r[s].getChildren()[o];
|
|
50
51
|
f && f.select();
|
|
51
|
-
},
|
|
52
|
+
}, $ = (t) => {
|
|
52
53
|
if (!i(t))
|
|
53
54
|
throw new Error("Selected node is not a TableCellNode");
|
|
54
|
-
(w(t).getFirstChild()?.getChildrenSize() || 0) === 1 ?
|
|
55
|
-
},
|
|
55
|
+
(w(t).getFirstChild()?.getChildrenSize() || 0) === 1 ? O(t) : T();
|
|
56
|
+
}, V = (t) => {
|
|
56
57
|
const e = t.getRootElement();
|
|
57
58
|
if (!e || typeof window > "u") return 0;
|
|
58
59
|
const n = e.getBoundingClientRect(), o = window.getComputedStyle(e), r = parseFloat(o.paddingLeft || "0") + parseFloat(o.paddingRight || "0") + a;
|
|
@@ -62,8 +63,8 @@ const y = 32, a = 48, N = 1, P = 200, v = 320, M = (t, e) => {
|
|
|
62
63
|
const o = n.getElementByKey(t.getKey());
|
|
63
64
|
if (!o) return 0;
|
|
64
65
|
const r = window.getComputedStyle(o);
|
|
65
|
-
return parseInt(r.width) - e *
|
|
66
|
-
},
|
|
66
|
+
return parseInt(r.width) - e * W - 1;
|
|
67
|
+
}, J = (t) => {
|
|
67
68
|
const e = t.getChildren();
|
|
68
69
|
for (const n of e) {
|
|
69
70
|
const o = n.getChildren();
|
|
@@ -74,19 +75,19 @@ const y = 32, a = 48, N = 1, P = 200, v = 320, M = (t, e) => {
|
|
|
74
75
|
return !1;
|
|
75
76
|
};
|
|
76
77
|
export {
|
|
77
|
-
|
|
78
|
+
W as BORDER_WIDTHS,
|
|
78
79
|
a as DEFAULT_COL_WIDTH,
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
P as DEFAULT_EDITOR_WIDTH,
|
|
81
|
+
F as MIN_COLUMN_WIDTH,
|
|
82
|
+
B as PREVENT_OPEN_DELAY,
|
|
83
|
+
A as createTable,
|
|
84
|
+
$ as deleteColumn,
|
|
84
85
|
H as deleteRow,
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
O as deleteTable,
|
|
87
|
+
V as getEditorContentWidth,
|
|
87
88
|
z as getEditorParrentCellWidth,
|
|
88
|
-
|
|
89
|
+
M as insertColumn,
|
|
89
90
|
U as insertRow,
|
|
90
|
-
|
|
91
|
+
J as tableHasContent
|
|
91
92
|
};
|
|
92
93
|
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sources":["../../../../../src/components/RteEditor/Plugins/TablePlugin/helpers.ts"],"sourcesContent":["import {\n $createTableNodeWithDimensions,\n $createTableRowNode,\n $createTableCellNode,\n $deleteTableColumnAtSelection,\n $isTableCellNode,\n $getTableNodeFromLexicalNodeOrThrow,\n $getTableRowNodeFromTableCellNodeOrThrow,\n $getTableRowIndexFromTableCellNode,\n $getTableColumnIndexFromTableCellNode,\n $insertTableColumnAtSelection,\n $insertTableRowAtSelection,\n $findTableNode,\n} from '@lexical/table';\nimport { $createParagraphNode } from 'lexical';\n\nimport type { TableCellNode, TableNode, TableRowNode } from '@lexical/table';\nimport type { TextNode, ElementNode, LexicalEditor } from 'lexical';\n\nimport { TableWrapperNode } from 'components/RteEditor/nodes';\n\nexport const MIN_COLUMN_WIDTH = 32;\nexport const DEFAULT_COL_WIDTH = 48;\nexport const BORDER_WIDTHS = 1;\nexport const PREVENT_OPEN_DELAY = 200;\nexport const DEFAULT_EDITOR_WIDTH = 320;\n\nexport const createTable = (nrOfRows: number, nrOfColumns: number): ElementNode => {\n const tableNode = $createTableNodeWithDimensions(0, 0, false);\n for (let rowIndex = 0; rowIndex < nrOfRows; rowIndex++) {\n const rowNode = $createTableRowNode();\n for (let colIndex = 0; colIndex < nrOfColumns; colIndex++) {\n const cellNode = $createTableCellNode(0, undefined, undefined);\n cellNode.append($createParagraphNode());\n rowNode.append(cellNode);\n }\n tableNode.append(rowNode);\n }\n return tableNode;\n};\n\nexport const deleteRow = (selectedNode: ElementNode) => {\n const currentRow = $getTableRowNodeFromTableCellNodeOrThrow(selectedNode);\n const nextRow = currentRow.getNextSibling() || currentRow.getPreviousSibling();\n const currentTable = currentRow.getParentOrThrow();\n currentTable.getChildrenSize() > 1 ? currentRow.remove() : currentTable.remove();\n\n if (nextRow !== null) {\n const firstDescendant = (nextRow as ElementNode).getFirstDescendant();\n if (firstDescendant) {\n (firstDescendant as TextNode).select();\n }\n }\n};\n\nexport const deleteTable = (selectedNode: ElementNode) => {\n const tableNode = $findTableNode(selectedNode);\n if (!tableNode) {\n throw new Error('Selected node is not a TableCellNode');\n }\n\n const wrapperNode = tableNode.getParent();\n if (wrapperNode instanceof TableWrapperNode) {\n wrapperNode.remove();\n } else {\n tableNode.remove();\n }\n};\n\nexport const insertRow = (selectedNode: ElementNode, position: 'insertRowAbove' | 'insertRowBelow') => {\n if (!$isTableCellNode(selectedNode)) {\n throw new Error('Selected node is not a TableCellNode');\n }\n const newRow = $createTableRowNode();\n\n $insertTableRowAtSelection(position === 'insertRowBelow');\n\n const firstDescendant = newRow.getFirstDescendant();\n if (firstDescendant) {\n (firstDescendant as TextNode).select();\n }\n};\n\nexport const insertColumn = (selectedNode: ElementNode, position: 'insertColumnLeft' | 'insertColumnRight') => {\n if (!$isTableCellNode(selectedNode)) {\n throw new Error('Selected node is not a TableCellNode');\n }\n const currentTable = $getTableNodeFromLexicalNodeOrThrow(selectedNode);\n let columnIndex = $getTableColumnIndexFromTableCellNode(selectedNode);\n const rowsInTable: TableCellNode[] = currentTable.getChildren();\n const rowIndex = $getTableRowIndexFromTableCellNode(selectedNode);\n const insertedCellNode = $insertTableColumnAtSelection(position === 'insertColumnLeft');\n\n if (!insertedCellNode) return;\n const insertedColumnIndex = $getTableColumnIndexFromTableCellNode(insertedCellNode);\n\n if (insertedColumnIndex === -1) return;\n const colWidths = currentTable.getColWidths();\n\n if (!colWidths) return;\n const newColWidths = colWidths.map((width, index) =>\n index === insertedColumnIndex ? DEFAULT_COL_WIDTH : width - Math.ceil(DEFAULT_COL_WIDTH / (colWidths.length - 1))\n );\n\n currentTable.setColWidths(newColWidths);\n\n columnIndex = position === 'insertColumnLeft' ? columnIndex : columnIndex + 1;\n const firstDescendant = rowsInTable[rowIndex].getChildren()[columnIndex];\n if (firstDescendant) {\n (firstDescendant as TextNode).select();\n }\n};\n\nexport const deleteColumn = (selectedNode: ElementNode) => {\n if (!$isTableCellNode(selectedNode)) {\n throw new Error('Selected node is not a TableCellNode');\n }\n const currentTable = $getTableNodeFromLexicalNodeOrThrow(selectedNode);\n const numberOfColumns = (currentTable.getFirstChild() as ElementNode)?.getChildrenSize() || 0;\n\n if (numberOfColumns === 1) {\n deleteTable(selectedNode);\n } else {\n $deleteTableColumnAtSelection();\n }\n};\n\nexport const getEditorContentWidth = (editor: LexicalEditor): number => {\n const rootEl = editor.getRootElement();\n if (!rootEl || typeof window === 'undefined') return 0;\n const rect = rootEl.getBoundingClientRect();\n const styles = window.getComputedStyle(rootEl);\n const insertX = parseFloat(styles.paddingLeft || '0') + parseFloat(styles.paddingRight || '0') + DEFAULT_COL_WIDTH;\n return Math.max(0, rect.width - insertX);\n};\n\nexport const getEditorParrentCellWidth = (\n node: TableCellNode | null,\n nrOfColumns: number,\n editor: LexicalEditor\n): number => {\n if (!node) return 0;\n\n const cell = editor.getElementByKey(node.getKey());\n if (!cell) return 0;\n\n const computedStyles = window.getComputedStyle(cell);\n return parseInt(computedStyles.width) - nrOfColumns * BORDER_WIDTHS - 1;\n};\n\nexport const tableHasContent = (tableNode: TableNode): boolean => {\n const rows = tableNode.getChildren();\n for (const row of rows) {\n const cells = (row as TableRowNode).getChildren();\n for (const cell of cells) {\n if ($isTableCellNode(cell)) {\n const cellText = cell.getTextContent().trim();\n if (cellText.length > 0) {\n return true;\n }\n }\n }\n }\n return false;\n};\n"],"names":["MIN_COLUMN_WIDTH","DEFAULT_COL_WIDTH","BORDER_WIDTHS","PREVENT_OPEN_DELAY","DEFAULT_EDITOR_WIDTH","createTable","nrOfRows","nrOfColumns","tableNode","$createTableNodeWithDimensions","rowIndex","rowNode","$createTableRowNode","colIndex","cellNode","$createTableCellNode","$createParagraphNode","deleteRow","selectedNode","currentRow","$getTableRowNodeFromTableCellNodeOrThrow","nextRow","currentTable","firstDescendant","deleteTable","$findTableNode","wrapperNode","TableWrapperNode","insertRow","position","$isTableCellNode","newRow","$insertTableRowAtSelection","insertColumn","$getTableNodeFromLexicalNodeOrThrow","columnIndex","$getTableColumnIndexFromTableCellNode","rowsInTable","$getTableRowIndexFromTableCellNode","insertedCellNode","$insertTableColumnAtSelection","insertedColumnIndex","colWidths","newColWidths","width","index","deleteColumn","$deleteTableColumnAtSelection","getEditorContentWidth","editor","rootEl","rect","styles","insertX","getEditorParrentCellWidth","node","cell","computedStyles","tableHasContent","rows","row","cells"],"mappings":"
|
|
1
|
+
{"version":3,"file":"helpers.js","sources":["../../../../../src/components/RteEditor/Plugins/TablePlugin/helpers.ts"],"sourcesContent":["import {\n $createTableNodeWithDimensions,\n $createTableRowNode,\n $createTableCellNode,\n $deleteTableColumnAtSelection,\n $isTableCellNode,\n $getTableNodeFromLexicalNodeOrThrow,\n $getTableRowNodeFromTableCellNodeOrThrow,\n $getTableRowIndexFromTableCellNode,\n $getTableColumnIndexFromTableCellNode,\n $insertTableColumnAtSelection,\n $insertTableRowAtSelection,\n $findTableNode,\n} from '@lexical/table';\nimport { $createParagraphNode } from 'lexical';\n\nimport type { TableCellNode, TableNode, TableRowNode } from '@lexical/table';\nimport type { TextNode, ElementNode, LexicalEditor } from 'lexical';\n\nimport { TableWrapperNode } from 'components/RteEditor/nodes';\n\nexport const MIN_COLUMN_WIDTH = 32;\nexport const DEFAULT_COL_WIDTH = 48;\nexport const BORDER_WIDTHS = 1;\nexport const PREVENT_OPEN_DELAY = 200;\nexport const DEFAULT_EDITOR_WIDTH = 320;\n\nexport const createTable = (nrOfRows: number, nrOfColumns: number): ElementNode => {\n const tableNode = $createTableNodeWithDimensions(0, 0, false);\n for (let rowIndex = 0; rowIndex < nrOfRows; rowIndex++) {\n const rowNode = $createTableRowNode();\n for (let colIndex = 0; colIndex < nrOfColumns; colIndex++) {\n const cellNode = $createTableCellNode(0, undefined, undefined);\n cellNode.append($createParagraphNode());\n rowNode.append(cellNode);\n }\n tableNode.append(rowNode);\n }\n return tableNode;\n};\n\nexport const deleteRow = (selectedNode: ElementNode) => {\n const currentRow = $getTableRowNodeFromTableCellNodeOrThrow(selectedNode);\n const nextRow = currentRow.getNextSibling() || currentRow.getPreviousSibling();\n const currentTable = currentRow.getParentOrThrow();\n currentTable.getChildrenSize() > 1 ? currentRow.remove() : currentTable.remove();\n\n if (nextRow !== null) {\n const firstDescendant = (nextRow as ElementNode).getFirstDescendant();\n if (firstDescendant) {\n (firstDescendant as TextNode).select();\n }\n }\n};\n\nexport const deleteTable = (selectedNode: ElementNode) => {\n const tableNode = $findTableNode(selectedNode);\n if (!tableNode) {\n throw new Error('Selected node is not a TableCellNode');\n }\n\n const wrapperNode = tableNode.getParent();\n if (wrapperNode instanceof TableWrapperNode) {\n wrapperNode.remove();\n } else {\n tableNode.remove();\n }\n};\n\nexport const insertRow = (selectedNode: ElementNode, position: 'insertRowAbove' | 'insertRowBelow') => {\n if (!$isTableCellNode(selectedNode)) {\n throw new Error('Selected node is not a TableCellNode');\n }\n const newRow = $createTableRowNode();\n\n $insertTableRowAtSelection(position === 'insertRowBelow');\n\n const firstDescendant = newRow.getFirstDescendant();\n if (firstDescendant) {\n (firstDescendant as TextNode).select();\n }\n};\n\nexport const insertColumn = (selectedNode: ElementNode, position: 'insertColumnLeft' | 'insertColumnRight') => {\n if (!$isTableCellNode(selectedNode)) {\n throw new Error('Selected node is not a TableCellNode');\n }\n const currentTable = $getTableNodeFromLexicalNodeOrThrow(selectedNode);\n let columnIndex = $getTableColumnIndexFromTableCellNode(selectedNode);\n const rowsInTable: TableCellNode[] = currentTable.getChildren();\n const rowIndex = $getTableRowIndexFromTableCellNode(selectedNode);\n const insertedCellNode = $insertTableColumnAtSelection(position === 'insertColumnLeft');\n\n if (!insertedCellNode) return;\n const insertedColumnIndex = $getTableColumnIndexFromTableCellNode(insertedCellNode);\n\n if (insertedColumnIndex === -1) return;\n const colWidths = currentTable.getColWidths();\n\n if (!colWidths) return;\n const newColWidths = colWidths.map((width, index) =>\n index === insertedColumnIndex ? DEFAULT_COL_WIDTH : width - Math.ceil(DEFAULT_COL_WIDTH / (colWidths.length - 1))\n );\n\n currentTable.setColWidths(newColWidths);\n\n columnIndex = position === 'insertColumnLeft' ? columnIndex : columnIndex + 1;\n const firstDescendant = rowsInTable[rowIndex].getChildren()[columnIndex];\n if (firstDescendant) {\n (firstDescendant as TextNode).select();\n }\n};\n\nexport const deleteColumn = (selectedNode: ElementNode) => {\n if (!$isTableCellNode(selectedNode)) {\n throw new Error('Selected node is not a TableCellNode');\n }\n const currentTable = $getTableNodeFromLexicalNodeOrThrow(selectedNode);\n const numberOfColumns = (currentTable.getFirstChild() as ElementNode)?.getChildrenSize() || 0;\n\n if (numberOfColumns === 1) {\n deleteTable(selectedNode);\n } else {\n $deleteTableColumnAtSelection();\n }\n};\n\nexport const getEditorContentWidth = (editor: LexicalEditor): number => {\n const rootEl = editor.getRootElement();\n if (!rootEl || typeof window === 'undefined') return 0;\n const rect = rootEl.getBoundingClientRect();\n const styles = window.getComputedStyle(rootEl);\n const insertX = parseFloat(styles.paddingLeft || '0') + parseFloat(styles.paddingRight || '0') + DEFAULT_COL_WIDTH;\n return Math.max(0, rect.width - insertX);\n};\n\nexport const getEditorParrentCellWidth = (\n node: TableCellNode | null,\n nrOfColumns: number,\n editor: LexicalEditor\n): number => {\n if (!node) return 0;\n\n const cell = editor.getElementByKey(node.getKey());\n if (!cell) return 0;\n\n const computedStyles = window.getComputedStyle(cell);\n return parseInt(computedStyles.width) - nrOfColumns * BORDER_WIDTHS - 1;\n};\n\nexport const tableHasContent = (tableNode: TableNode): boolean => {\n const rows = tableNode.getChildren();\n for (const row of rows) {\n const cells = (row as TableRowNode).getChildren();\n for (const cell of cells) {\n if ($isTableCellNode(cell)) {\n const cellText = cell.getTextContent().trim();\n if (cellText.length > 0) {\n return true;\n }\n }\n }\n }\n return false;\n};\n"],"names":["MIN_COLUMN_WIDTH","DEFAULT_COL_WIDTH","BORDER_WIDTHS","PREVENT_OPEN_DELAY","DEFAULT_EDITOR_WIDTH","createTable","nrOfRows","nrOfColumns","tableNode","$createTableNodeWithDimensions","rowIndex","rowNode","$createTableRowNode","colIndex","cellNode","$createTableCellNode","$createParagraphNode","deleteRow","selectedNode","currentRow","$getTableRowNodeFromTableCellNodeOrThrow","nextRow","currentTable","firstDescendant","deleteTable","$findTableNode","wrapperNode","TableWrapperNode","insertRow","position","$isTableCellNode","newRow","$insertTableRowAtSelection","insertColumn","$getTableNodeFromLexicalNodeOrThrow","columnIndex","$getTableColumnIndexFromTableCellNode","rowsInTable","$getTableRowIndexFromTableCellNode","insertedCellNode","$insertTableColumnAtSelection","insertedColumnIndex","colWidths","newColWidths","width","index","deleteColumn","$deleteTableColumnAtSelection","getEditorContentWidth","editor","rootEl","rect","styles","insertX","getEditorParrentCellWidth","node","cell","computedStyles","tableHasContent","rows","row","cells"],"mappings":";;;;AAqBO,MAAMA,IAAmB,IACnBC,IAAoB,IACpBC,IAAgB,GAChBC,IAAqB,KACrBC,IAAuB,KAEvBC,IAAc,CAACC,GAAkBC,MAAqC;AACjF,QAAMC,IAAYC,EAA+B,GAAG,GAAG,EAAK;AAC5D,WAASC,IAAW,GAAGA,IAAWJ,GAAUI,KAAY;AACtD,UAAMC,IAAUC,EAAA;AAChB,aAASC,IAAW,GAAGA,IAAWN,GAAaM,KAAY;AACzD,YAAMC,IAAWC,EAAqB,GAAG,QAAW,MAAS;AAC7D,MAAAD,EAAS,OAAOE,GAAsB,GACtCL,EAAQ,OAAOG,CAAQ;AAAA,IACzB;AACA,IAAAN,EAAU,OAAOG,CAAO;AAAA,EAC1B;AACA,SAAOH;AACT,GAEaS,IAAY,CAACC,MAA8B;AACtD,QAAMC,IAAaC,EAAyCF,CAAY,GAClEG,IAAUF,EAAW,eAAA,KAAoBA,EAAW,mBAAA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,4 +1,5 @@
|
|
|
1
1
|
import { JSX } from 'react';
|
|
2
|
+
import { SearchResponse } from 'components/RteEditor/Plugins/CourseCataloguePlugin/AddCatalogueLinkForm';
|
|
2
3
|
export type Position = {
|
|
3
4
|
xPos: number;
|
|
4
5
|
yPos: number;
|
|
@@ -6,6 +7,8 @@ export type Position = {
|
|
|
6
7
|
};
|
|
7
8
|
interface ToolBarProps {
|
|
8
9
|
editorScrollPosition: number;
|
|
10
|
+
onCatalogueLinkSearch?: (query: string, linkType: 'course' | 'programme') => void;
|
|
11
|
+
catalogueSearchResponse?: SearchResponse;
|
|
9
12
|
}
|
|
10
|
-
export declare const ToolBarPlugin: ({ editorScrollPosition }: ToolBarProps) => JSX.Element;
|
|
13
|
+
export declare const ToolBarPlugin: ({ editorScrollPosition, onCatalogueLinkSearch, catalogueSearchResponse, }: ToolBarProps) => JSX.Element;
|
|
11
14
|
export {};
|
|
@@ -1,72 +1,85 @@
|
|
|
1
|
-
import { jsxs as y, jsx as
|
|
2
|
-
import { o as
|
|
3
|
-
import {
|
|
4
|
-
import { useState as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
1
|
+
import { jsxs as y, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { o as E } from "../../../../LexicalComposerContext.prod-DOyoZx0P.js";
|
|
3
|
+
import { c as g, b, l as L } from "../../../../Lexical.prod-CNQPQ6W-.js";
|
|
4
|
+
import { useState as T, useRef as N, useCallback as x, useEffect as m } from "react";
|
|
5
|
+
import { P as w } from "../../../../LexicalTable.prod-C97KnedB.js";
|
|
6
|
+
import { CourseCataloguePlugin as B } from "../CourseCataloguePlugin/CourseCataloguePlugin.js";
|
|
7
|
+
import { BlockFormatPlugin as k } from "../BlockFormatPlugin/BlockFormatPlugin.js";
|
|
8
|
+
import { ListPlugin as S } from "../ListPlugin/ListPlugin.js";
|
|
9
|
+
import { LinkPlugin as z } from "../LinkPlugin/LinkPlugin.js";
|
|
10
|
+
import { HistoryPlugin as A } from "../HistoryPlugin/HistoryPlugin.js";
|
|
11
|
+
import { T as K } from "../../../../TablePlugin-DBKzGTIm.js";
|
|
12
|
+
import { TableCellContextMenu as R } from "../TablePlugin/TableCellContextMenu/TableCellContextMenu.js";
|
|
12
13
|
import "react-dom";
|
|
13
14
|
import "../../../../index-yEhaxKq-.js";
|
|
14
|
-
import { s as
|
|
15
|
-
import { setScrollableContainers as
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
import { s as j } from "../../../../RteEditor.module-DaBh86FK.js";
|
|
16
|
+
import { setScrollableContainers as v, removeScrollableContainers as _ } from "../../helpers.js";
|
|
17
|
+
const Z = ({
|
|
18
|
+
editorScrollPosition: r,
|
|
19
|
+
onCatalogueLinkSearch: d,
|
|
20
|
+
catalogueSearchResponse: u
|
|
21
|
+
}) => {
|
|
22
|
+
const [n] = E(), [i, s] = T(null), p = N(null), f = x(() => {
|
|
23
|
+
const o = g();
|
|
24
|
+
if (b(o)) {
|
|
25
|
+
const l = o.anchor.getNode(), a = w(l);
|
|
26
|
+
if (a) {
|
|
27
|
+
const h = n.getElementByKey(a.getKey()), c = h ? h.getBoundingClientRect() : { right: 0, bottom: 0, height: 0 };
|
|
28
|
+
s({ xPos: c.right, yPos: c.bottom, height: c.height });
|
|
24
29
|
} else
|
|
25
|
-
|
|
30
|
+
s(null);
|
|
26
31
|
}
|
|
27
|
-
}, [
|
|
28
|
-
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
if (
|
|
33
|
-
const
|
|
34
|
-
|
|
32
|
+
}, [n]), P = (o) => {
|
|
33
|
+
p.current?.mutateTable(o);
|
|
34
|
+
}, e = () => {
|
|
35
|
+
n.update(() => {
|
|
36
|
+
const o = g();
|
|
37
|
+
if (b(o)) {
|
|
38
|
+
const l = o.anchor.getNode();
|
|
39
|
+
w(l) && (L(null), s(null));
|
|
35
40
|
}
|
|
36
41
|
});
|
|
37
42
|
};
|
|
38
|
-
return
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
return m(() => {
|
|
44
|
+
n.registerUpdateListener(({ editorState: o }) => {
|
|
45
|
+
o.read(() => {
|
|
46
|
+
f();
|
|
42
47
|
});
|
|
43
48
|
});
|
|
44
|
-
}, [
|
|
45
|
-
window.removeEventListener("scroll",
|
|
46
|
-
}), [
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
+
}, [n, f]), m(() => (v(e), window.addEventListener("scroll", e), window.addEventListener("resize", e), () => {
|
|
50
|
+
window.removeEventListener("scroll", e), window.removeEventListener("resize", e), _(e);
|
|
51
|
+
}), [n]), m(() => {
|
|
52
|
+
const o = () => {
|
|
53
|
+
v(e);
|
|
49
54
|
};
|
|
50
|
-
return window.addEventListener("keydown",
|
|
51
|
-
window.removeEventListener("keydown",
|
|
55
|
+
return window.addEventListener("keydown", o, { capture: !0 }), () => {
|
|
56
|
+
window.removeEventListener("keydown", o);
|
|
52
57
|
};
|
|
53
|
-
}, []), /* @__PURE__ */ y("div", { className:
|
|
54
|
-
/* @__PURE__ */
|
|
55
|
-
/* @__PURE__ */
|
|
56
|
-
/* @__PURE__ */
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
}, []), /* @__PURE__ */ y("div", { className: j.editor__toolbar, children: [
|
|
59
|
+
/* @__PURE__ */ t(k, {}),
|
|
60
|
+
/* @__PURE__ */ t(S, {}),
|
|
61
|
+
/* @__PURE__ */ t(K, { isActive: !!i, ref: p }),
|
|
62
|
+
i && /* @__PURE__ */ t(
|
|
63
|
+
R,
|
|
59
64
|
{
|
|
60
|
-
position:
|
|
61
|
-
parentScrollPosition:
|
|
62
|
-
onAction:
|
|
65
|
+
position: i,
|
|
66
|
+
parentScrollPosition: r,
|
|
67
|
+
onAction: P
|
|
63
68
|
}
|
|
64
69
|
),
|
|
65
|
-
/* @__PURE__ */
|
|
66
|
-
/* @__PURE__ */
|
|
70
|
+
/* @__PURE__ */ t(z, { parentScrollPosition: r }),
|
|
71
|
+
d && u && /* @__PURE__ */ t(
|
|
72
|
+
B,
|
|
73
|
+
{
|
|
74
|
+
parentScrollPosition: r,
|
|
75
|
+
onSearch: d,
|
|
76
|
+
searchResponse: u
|
|
77
|
+
}
|
|
78
|
+
),
|
|
79
|
+
/* @__PURE__ */ t(A, {})
|
|
67
80
|
] });
|
|
68
81
|
};
|
|
69
82
|
export {
|
|
70
|
-
|
|
83
|
+
Z as ToolBarPlugin
|
|
71
84
|
};
|
|
72
85
|
//# sourceMappingURL=ToolbarPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolbarPlugin.js","sources":["../../../../../src/components/RteEditor/Plugins/ToolbarPlugin/ToolbarPlugin.tsx"],"sourcesContent":["import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';\nimport { $getSelection, $isRangeSelection, $setSelection } from 'lexical';\nimport { useCallback, useEffect, useRef, useState } from 'react';\nimport { $getTableCellNodeFromLexicalNode } from '@lexical/table';\n\nimport type { JSX } from 'react';\nimport type { Actions } from 'components/RteEditor/Plugins/TablePlugin/TableCellContextMenu/TableCellContextMenu';\nimport type { TableMutation } from 'components/RteEditor/Plugins/TablePlugin/TablePlugin';\n\nimport {\n LinkPlugin,\n BlockFormatPlugin,\n ListPlugin,\n HistoryPlugin,\n TablePlugin,\n TableCellContextMenu,\n} from 'components/RteEditor/Plugins';\nimport styles from 'components/RteEditor/RteEditor.module.css';\nimport { removeScrollableContainers, setScrollableContainers } from 'components/RteEditor/helpers';\n\nexport type Position = {\n xPos: number;\n yPos: number;\n height: number;\n};\n\ninterface ToolBarProps {\n editorScrollPosition: number;\n}\n\nexport const ToolBarPlugin = ({
|
|
1
|
+
{"version":3,"file":"ToolbarPlugin.js","sources":["../../../../../src/components/RteEditor/Plugins/ToolbarPlugin/ToolbarPlugin.tsx"],"sourcesContent":["import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';\nimport { $getSelection, $isRangeSelection, $setSelection } from 'lexical';\nimport { useCallback, useEffect, useRef, useState } from 'react';\nimport { $getTableCellNodeFromLexicalNode } from '@lexical/table';\n\nimport type { JSX } from 'react';\nimport type { Actions } from 'components/RteEditor/Plugins/TablePlugin/TableCellContextMenu/TableCellContextMenu';\nimport type { TableMutation } from 'components/RteEditor/Plugins/TablePlugin/TablePlugin';\nimport type { SearchResponse } from 'components/RteEditor/Plugins/CourseCataloguePlugin/AddCatalogueLinkForm';\n\nimport { CourseCataloguePlugin } from 'components/RteEditor/Plugins/CourseCataloguePlugin';\nimport {\n LinkPlugin,\n BlockFormatPlugin,\n ListPlugin,\n HistoryPlugin,\n TablePlugin,\n TableCellContextMenu,\n} from 'components/RteEditor/Plugins';\nimport styles from 'components/RteEditor/RteEditor.module.css';\nimport { removeScrollableContainers, setScrollableContainers } from 'components/RteEditor/helpers';\n\nexport type Position = {\n xPos: number;\n yPos: number;\n height: number;\n};\n\ninterface ToolBarProps {\n editorScrollPosition: number;\n onCatalogueLinkSearch?: (query: string, linkType: 'course' | 'programme') => void;\n catalogueSearchResponse?: SearchResponse;\n}\n\nexport const ToolBarPlugin = ({\n editorScrollPosition,\n onCatalogueLinkSearch,\n catalogueSearchResponse,\n}: ToolBarProps): JSX.Element => {\n const [editor] = useLexicalComposerContext();\n const [position, setPosition] = useState<Position | null>(null);\n const tableref = useRef<TableMutation>(null);\n\n const updateToolbar = useCallback(() => {\n const selection = $getSelection();\n if ($isRangeSelection(selection)) {\n const anchor = selection.anchor;\n const anchorNode = anchor.getNode();\n\n const tableCell = $getTableCellNodeFromLexicalNode(anchorNode);\n if (tableCell) {\n const domNode = editor.getElementByKey(tableCell.getKey());\n const position = domNode ? domNode.getBoundingClientRect() : { right: 0, bottom: 0, height: 0 };\n setPosition({ xPos: position.right, yPos: position.bottom, height: position.height });\n } else {\n setPosition(null);\n }\n }\n }, [editor]);\n\n const handleTableAction = (action: Actions) => {\n tableref.current?.mutateTable(action);\n };\n\n const handleResizeScroll = () => {\n editor.update(() => {\n const selection = $getSelection();\n\n if ($isRangeSelection(selection)) {\n const anchor = selection.anchor;\n const anchorNode = anchor.getNode();\n\n const tableCell = $getTableCellNodeFromLexicalNode(anchorNode);\n if (tableCell) {\n $setSelection(null);\n setPosition(null);\n }\n }\n });\n };\n\n useEffect(() => {\n editor.registerUpdateListener(({ editorState }) => {\n editorState.read(() => {\n updateToolbar();\n });\n });\n }, [editor, updateToolbar]);\n\n useEffect(() => {\n setScrollableContainers(handleResizeScroll);\n\n window.addEventListener('scroll', handleResizeScroll);\n window.addEventListener('resize', handleResizeScroll);\n\n return () => {\n window.removeEventListener('scroll', handleResizeScroll);\n window.removeEventListener('resize', handleResizeScroll);\n removeScrollableContainers(handleResizeScroll);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [editor]);\n\n useEffect(() => {\n const removeKeydown = () => {\n setScrollableContainers(handleResizeScroll);\n };\n\n window.addEventListener('keydown', removeKeydown, { capture: true });\n\n return () => {\n window.removeEventListener('keydown', removeKeydown);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return (\n <div className={styles['editor__toolbar']}>\n <BlockFormatPlugin />\n <ListPlugin />\n <TablePlugin isActive={Boolean(position)} ref={tableref} />\n {position && (\n <TableCellContextMenu\n position={position}\n parentScrollPosition={editorScrollPosition}\n onAction={handleTableAction}\n />\n )}\n <LinkPlugin parentScrollPosition={editorScrollPosition} />\n {onCatalogueLinkSearch && catalogueSearchResponse && (\n <CourseCataloguePlugin\n parentScrollPosition={editorScrollPosition}\n onSearch={onCatalogueLinkSearch}\n searchResponse={catalogueSearchResponse}\n />\n )}\n <HistoryPlugin />\n </div>\n );\n};\n"],"names":["ToolBarPlugin","editorScrollPosition","onCatalogueLinkSearch","catalogueSearchResponse","editor","useLexicalComposerContext","position","setPosition","useState","tableref","useRef","updateToolbar","useCallback","selection","$getSelection","$isRangeSelection","anchorNode","tableCell","$getTableCellNodeFromLexicalNode","domNode","handleTableAction","action","handleResizeScroll","$setSelection","useEffect","editorState","setScrollableContainers","removeScrollableContainers","removeKeydown","jsxs","styles","jsx","BlockFormatPlugin","ListPlugin","TablePlugin","TableCellContextMenu","LinkPlugin","CourseCataloguePlugin","HistoryPlugin"],"mappings":";;;;;;;;;;;;;;;;AAkCO,MAAMA,IAAgB,CAAC;AAAA,EAC5B,sBAAAC;AAAA,EACA,uBAAAC;AAAA,EACA,yBAAAC;AACF,MAAiC;AAC/B,QAAM,CAACC,CAAM,IAAIC,EAAA,GACX,CAACC,GAAUC,CAAW,IAAIC,EAA0B,IAAI,GACxDC,IAAWC,EAAsB,IAAI,GAErCC,IAAgBC,EAAY,MAAM;AACtC,UAAMC,IAAYC,EAAA;AAClB,QAAIC,EAAkBF,CAAS,GAAG;AAEhC,YAAMG,IADSH,EAAU,OACC,QAAA,GAEpBI,IAAYC,EAAiCF,CAAU;AAC7D,UAAIC,GAAW;AACb,cAAME,IAAUf,EAAO,gBAAgBa,EAAU,QAAQ,GACnDX,IAAWa,IAAUA,EAAQ,sBAAA,IAA0B,EAAE,OAAO,GAAG,QAAQ,GAAG,QAAQ,EAAA;AAC5F,QAAAZ,EAAY,EAAE,MAAMD,EAAS,OAAO,MAAMA,EAAS,QAAQ,QAAQA,EAAS,OAAA,CAAQ;AAAA,MACtF;AACE,QAAAC,EAAY,IAAI;AAAA,IAEpB;AAAA,EACF,GAAG,CAACH,CAAM,CAAC,GAELgB,IAAoB,CAACC,MAAoB;AAC7C,IAAAZ,EAAS,SAAS,YAAYY,CAAM;AAAA,EACtC,GAEMC,IAAqB,MAAM;AAC/B,IAAAlB,EAAO,OAAO,MAAM;AAClB,YAAMS,IAAYC,EAAA;AAElB,UAAIC,EAAkBF,CAAS,GAAG;AAEhC,cAAMG,IADSH,EAAU,OACC,QAAA;AAG1B,QADkBK,EAAiCF,CAAU,MAE3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C;AAAA,QACtB,UAAUC;AAAA,QACV,gBAAgBC;AAAA,MAAA;AAAA,IAAA;AAAA,sBAGnBmC,GAAA,CAAA,CAAc;AAAA,EAAA,GACjB;AAEJ;"}
|
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
import { ToolBarPlugin as e } from "./ToolbarPlugin/ToolbarPlugin.js";
|
|
2
2
|
import { BlockFormatPlugin as t } from "./BlockFormatPlugin/BlockFormatPlugin.js";
|
|
3
3
|
import { ListPlugin as n } from "./ListPlugin/ListPlugin.js";
|
|
4
|
-
import { LinkPlugin as
|
|
4
|
+
import { LinkPlugin as x } from "./LinkPlugin/LinkPlugin.js";
|
|
5
5
|
import { HistoryPlugin as f } from "./HistoryPlugin/HistoryPlugin.js";
|
|
6
|
-
import { T as u } from "../../../TablePlugin-
|
|
7
|
-
import { TableCellContextMenu as
|
|
8
|
-
import { T
|
|
6
|
+
import { T as u } from "../../../TablePlugin-DBKzGTIm.js";
|
|
7
|
+
import { TableCellContextMenu as g } from "./TablePlugin/TableCellContextMenu/TableCellContextMenu.js";
|
|
8
|
+
import { T } from "../../../TableCellResizerPlugin-BdgrIlKp.js";
|
|
9
9
|
import { PasteHandlerPlugin as C } from "./PasteHandlerPlugin/PasteHandlerPlugin.js";
|
|
10
10
|
export {
|
|
11
11
|
t as BlockFormatPlugin,
|
|
12
12
|
f as HistoryPlugin,
|
|
13
|
-
|
|
13
|
+
x as LinkPlugin,
|
|
14
14
|
n as ListPlugin,
|
|
15
15
|
C as PasteHandlerPlugin,
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
g as TableCellContextMenu,
|
|
17
|
+
T as TableCellResizerPlugin,
|
|
18
18
|
u as TablePlugin,
|
|
19
|
-
e as ToolBarPlugin
|
|
20
|
-
m as getLinkNodeTag
|
|
19
|
+
e as ToolBarPlugin
|
|
21
20
|
};
|
|
22
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
interface LanguageContextProps {
|
|
3
|
-
|
|
4
|
-
switchLanguage: (
|
|
3
|
+
currentLanguage: 'NL' | 'EN';
|
|
4
|
+
switchLanguage: (currentLanguage: 'NL' | 'EN') => void;
|
|
5
5
|
}
|
|
6
6
|
export declare const LanguageProvider: ({ children }: {
|
|
7
7
|
children: ReactNode;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as u } from "react/jsx-runtime";
|
|
2
|
-
import { createContext as g, useContext as s, useState as
|
|
2
|
+
import { createContext as g, useContext as s, useState as c } from "react";
|
|
3
3
|
const t = g(void 0), x = ({ children: e }) => {
|
|
4
|
-
const [n,
|
|
5
|
-
|
|
4
|
+
const [n, r] = c("EN"), o = (a) => {
|
|
5
|
+
r(a);
|
|
6
6
|
};
|
|
7
|
-
return /* @__PURE__ */ u(t.Provider, { value: {
|
|
7
|
+
return /* @__PURE__ */ u(t.Provider, { value: { currentLanguage: n, switchLanguage: o }, children: e });
|
|
8
8
|
}, d = () => {
|
|
9
9
|
const e = s(t);
|
|
10
10
|
if (!e)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LanguageProvider.js","sources":["../../../../src/components/RteEditor/Providers/LanguageProvider.tsx"],"sourcesContent":["import { createContext, useContext, useState } from 'react';\n\nimport type { ReactNode } from 'react';\n\ninterface LanguageContextProps {\n
|
|
1
|
+
{"version":3,"file":"LanguageProvider.js","sources":["../../../../src/components/RteEditor/Providers/LanguageProvider.tsx"],"sourcesContent":["import { createContext, useContext, useState } from 'react';\n\nimport type { ReactNode } from 'react';\n\ninterface LanguageContextProps {\n currentLanguage: 'NL' | 'EN';\n switchLanguage: (currentLanguage: 'NL' | 'EN') => void;\n}\n\nconst LanguageContext = createContext<LanguageContextProps | undefined>(undefined);\n\nexport const LanguageProvider = ({ children }: { children: ReactNode }) => {\n const [currentLanguage, setCurrentLanguage] = useState<'NL' | 'EN'>('EN');\n\n const switchLanguage = (currentLanguage: 'NL' | 'EN') => {\n setCurrentLanguage(currentLanguage);\n };\n\n return <LanguageContext.Provider value={{ currentLanguage, switchLanguage }}>{children}</LanguageContext.Provider>;\n};\n\nexport const useLanguage = (): LanguageContextProps => {\n const context = useContext(LanguageContext);\n if (!context) {\n throw new Error('useLanguage must be used within a LanguageProvider');\n }\n return context;\n};\n"],"names":["LanguageContext","createContext","LanguageProvider","children","currentLanguage","setCurrentLanguage","useState","switchLanguage","jsx","useLanguage","context","useContext"],"mappings":";;AASA,MAAMA,IAAkBC,EAAgD,MAAS,GAEpEC,IAAmB,CAAC,EAAE,UAAAC,QAAwC;AACzE,QAAM,CAACC,GAAiBC,CAAkB,IAAIC,EAAsB,IAAI,GAElEC,IAAiB,CAACH,MAAiC;AACvD,IAAAC,EAAmBD,CAAe;AAAA,EACpC;AAEA,SAAO,gBAAAI,EAACR,EAAgB,UAAhB,EAAyB,OAAO,EAAE,iBAAAI,GAAiB,gBAAAG,KAAmB,UAAAJ,GAAS;AACzF,GAEaM,IAAc,MAA4B;AACrD,QAAMC,IAAUC,EAAWX,CAAe;AAC1C,MAAI,CAACU;AACH,UAAM,IAAI,MAAM,oDAAoD;AAEtE,SAAOA;AACT;"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { RefObject } from 'react';
|
|
2
2
|
import { LexicalEditor } from 'lexical';
|
|
3
|
+
import { SearchResponse } from './Plugins/CourseCataloguePlugin/AddCatalogueLinkForm';
|
|
3
4
|
export interface RteEditorProps {
|
|
4
5
|
/** current language setting for the editor labels NOT title ans label */
|
|
5
|
-
currentLanguage?: 'NL' | 'EN';
|
|
6
|
+
currentLanguage?: 'NL' | 'EN' | 'nl' | 'en';
|
|
6
7
|
/** imported content to edit */
|
|
7
8
|
initialValue?: string;
|
|
8
9
|
/** placeholder text in current Language */
|
|
@@ -25,6 +26,10 @@ export interface RteEditorProps {
|
|
|
25
26
|
rteRef?: RefObject<LexicalEditor> | null;
|
|
26
27
|
/** updated output */
|
|
27
28
|
onChange: (content: string) => void;
|
|
29
|
+
/** callback for catalogue link search */
|
|
30
|
+
onCatalogueLinkSearch?: (query: string, type: 'course' | 'programme') => void;
|
|
31
|
+
/** updated catalogue search results */
|
|
32
|
+
catalogueSearchResponse?: SearchResponse;
|
|
28
33
|
}
|
|
29
|
-
export declare const Rte: ({ currentLanguage, initialValue, placeholder, label, info, required, notValid, notValidatedText, maxHeightInRem, maxWords, rteRef, onChange, }: RteEditorProps) => import("react/jsx-runtime").JSX.Element;
|
|
30
|
-
export declare const RteEditor: ({ currentLanguage, initialValue, placeholder, label, info, required, notValid, notValidatedText, maxWords, rteRef, onChange, }: RteEditorProps) => import("react/jsx-runtime").JSX.Element;
|
|
34
|
+
export declare const Rte: ({ currentLanguage, initialValue, placeholder, label, info, required, notValid, notValidatedText, maxHeightInRem, maxWords, rteRef, onChange, onCatalogueLinkSearch, catalogueSearchResponse, }: RteEditorProps) => import("react/jsx-runtime").JSX.Element;
|
|
35
|
+
export declare const RteEditor: ({ currentLanguage, initialValue, placeholder, label, info, required, notValid, notValidatedText, maxWords, rteRef, onChange, onCatalogueLinkSearch, catalogueSearchResponse, }: RteEditorProps) => import("react/jsx-runtime").JSX.Element;
|