carbon-react 148.0.0 → 149.0.0
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/esm/__internal__/label/label.component.js +4 -1
- package/esm/components/note/note.component.d.ts +1 -2
- package/esm/components/note/note.component.js +6 -9
- package/esm/components/tabs/__internal__/tab-title/tab-title.style.js +2 -1
- package/esm/components/text-editor/__internal__/constants.d.ts +21 -0
- package/esm/components/text-editor/__internal__/constants.js +29 -0
- package/esm/components/text-editor/__internal__/helpers.d.ts +20 -0
- package/esm/components/text-editor/__internal__/helpers.js +84 -0
- package/esm/components/text-editor/__internal__/index.d.ts +2 -0
- package/esm/components/text-editor/__internal__/index.js +2 -0
- package/esm/components/text-editor/__internal__/plugins/AutoLinker/auto-link.component.d.ts +3 -0
- package/esm/components/text-editor/__internal__/plugins/AutoLinker/auto-link.component.js +28 -0
- package/esm/components/text-editor/__internal__/plugins/AutoLinker/index.d.ts +1 -0
- package/esm/components/text-editor/__internal__/plugins/AutoLinker/index.js +1 -0
- package/esm/components/text-editor/__internal__/plugins/CharacterCounter/__test__/character-counter.component.d.ts +10 -0
- package/esm/components/text-editor/__internal__/plugins/CharacterCounter/__test__/character-counter.component.js +33 -0
- package/esm/components/text-editor/__internal__/plugins/CharacterCounter/character-counter.component.d.ts +9 -0
- package/esm/components/text-editor/__internal__/plugins/CharacterCounter/character-counter.component.js +59 -0
- package/esm/components/text-editor/__internal__/plugins/CharacterCounter/character-counter.style.d.ts +3 -0
- package/esm/components/text-editor/__internal__/plugins/CharacterCounter/character-counter.style.js +17 -0
- package/esm/components/text-editor/__internal__/plugins/CharacterCounter/index.d.ts +1 -0
- package/esm/components/text-editor/__internal__/plugins/CharacterCounter/index.js +1 -0
- package/esm/components/text-editor/__internal__/plugins/ContentEditor/content-editor.component.d.ts +17 -0
- package/esm/components/text-editor/__internal__/plugins/ContentEditor/content-editor.component.js +40 -0
- package/esm/components/text-editor/__internal__/plugins/ContentEditor/content-editor.style.d.ts +6 -0
- package/esm/components/text-editor/__internal__/plugins/ContentEditor/content-editor.style.js +34 -0
- package/esm/components/text-editor/__internal__/plugins/ContentEditor/index.d.ts +1 -0
- package/esm/components/text-editor/__internal__/plugins/ContentEditor/index.js +1 -0
- package/esm/components/text-editor/__internal__/plugins/LinkMonitor/index.d.ts +1 -0
- package/esm/components/text-editor/__internal__/plugins/LinkMonitor/index.js +1 -0
- package/esm/components/text-editor/__internal__/plugins/LinkMonitor/link-monitor.plugin.d.ts +2 -0
- package/esm/components/text-editor/__internal__/plugins/LinkMonitor/link-monitor.plugin.js +62 -0
- package/esm/components/text-editor/__internal__/plugins/LinkPreviewer/index.d.ts +1 -0
- package/esm/components/text-editor/__internal__/plugins/LinkPreviewer/index.js +1 -0
- package/esm/components/text-editor/__internal__/plugins/LinkPreviewer/link-previewer.component.d.ts +11 -0
- package/esm/components/text-editor/__internal__/plugins/LinkPreviewer/link-previewer.component.js +19 -0
- package/esm/components/text-editor/__internal__/plugins/LinkPreviewer/link-previewer.style.d.ts +6 -0
- package/esm/components/text-editor/__internal__/plugins/LinkPreviewer/link-previewer.style.js +29 -0
- package/esm/components/text-editor/__internal__/plugins/OnChange/index.d.ts +1 -0
- package/esm/components/text-editor/__internal__/plugins/OnChange/index.js +1 -0
- package/esm/components/text-editor/__internal__/plugins/OnChange/on-change.plugin.d.ts +5 -0
- package/esm/components/text-editor/__internal__/plugins/OnChange/on-change.plugin.js +25 -0
- package/esm/components/text-editor/__internal__/plugins/Placeholder/index.d.ts +1 -0
- package/esm/components/text-editor/__internal__/plugins/Placeholder/index.js +1 -0
- package/esm/components/text-editor/__internal__/plugins/Placeholder/placeholder.component.d.ts +14 -0
- package/esm/components/text-editor/__internal__/plugins/Placeholder/placeholder.component.js +17 -0
- package/esm/components/text-editor/__internal__/plugins/Placeholder/placeholder.style.d.ts +2 -0
- package/esm/components/text-editor/__internal__/plugins/Placeholder/placeholder.style.js +8 -0
- package/esm/components/text-editor/__internal__/plugins/Toolbar/buttons/bold.component.d.ts +4 -0
- package/esm/components/text-editor/__internal__/plugins/Toolbar/buttons/bold.component.js +41 -0
- package/esm/components/text-editor/__internal__/plugins/Toolbar/buttons/common.d.ts +6 -0
- package/esm/components/text-editor/__internal__/plugins/Toolbar/buttons/common.js +1 -0
- package/esm/components/text-editor/__internal__/plugins/Toolbar/buttons/index.d.ts +4 -0
- package/esm/components/text-editor/__internal__/plugins/Toolbar/buttons/index.js +4 -0
- package/esm/components/text-editor/__internal__/plugins/Toolbar/buttons/italic.component.d.ts +4 -0
- package/esm/components/text-editor/__internal__/plugins/Toolbar/buttons/italic.component.js +41 -0
- package/esm/components/text-editor/__internal__/plugins/Toolbar/buttons/list.component.d.ts +5 -0
- package/esm/components/text-editor/__internal__/plugins/Toolbar/buttons/list.component.js +317 -0
- package/esm/components/text-editor/__internal__/plugins/Toolbar/buttons/save.component.d.ts +34 -0
- package/esm/components/text-editor/__internal__/plugins/Toolbar/buttons/save.component.js +29 -0
- package/esm/components/text-editor/__internal__/plugins/Toolbar/index.d.ts +1 -0
- package/esm/components/text-editor/__internal__/plugins/Toolbar/toolbar.component.d.ts +12 -0
- package/esm/components/text-editor/__internal__/plugins/Toolbar/toolbar.component.js +111 -0
- package/esm/components/text-editor/__internal__/plugins/Toolbar/toolbar.style.d.ts +11 -0
- package/esm/components/text-editor/__internal__/plugins/Toolbar/toolbar.style.js +57 -0
- package/esm/components/text-editor/__internal__/plugins/index.d.ts +9 -0
- package/esm/components/text-editor/__internal__/plugins/index.js +9 -0
- package/esm/components/text-editor/__internal__/plugins/useCursorAtEnd/index.d.ts +2 -0
- package/esm/components/text-editor/__internal__/plugins/useCursorAtEnd/index.js +71 -0
- package/esm/components/text-editor/__internal__/read-only-rte.component.d.ts +4 -0
- package/esm/components/text-editor/__internal__/read-only-rte.component.js +62 -0
- package/esm/components/text-editor/__internal__/style.css +7 -0
- package/esm/components/text-editor/__internal__/utils.d.ts +4 -0
- package/esm/components/text-editor/__internal__/utils.js +14 -0
- package/esm/components/text-editor/index.d.ts +2 -1
- package/esm/components/text-editor/index.js +2 -1
- package/esm/components/text-editor/text-editor.component.d.ts +32 -28
- package/esm/components/text-editor/text-editor.component.js +139 -478
- package/esm/components/text-editor/text-editor.context.d.ts +6 -0
- package/esm/components/text-editor/text-editor.context.js +4 -0
- package/esm/components/text-editor/text-editor.style.d.ts +18 -11
- package/esm/components/text-editor/text-editor.style.js +55 -52
- package/esm/locales/de-de.js +0 -14
- package/esm/locales/en-gb.js +18 -14
- package/esm/locales/es-es.js +0 -14
- package/esm/locales/fr-ca.js +0 -14
- package/esm/locales/fr-fr.js +0 -14
- package/esm/locales/locale.d.ts +14 -14
- package/lib/__internal__/label/label.component.js +3 -0
- package/lib/components/note/note.component.d.ts +1 -2
- package/lib/components/note/note.component.js +6 -9
- package/lib/components/tabs/__internal__/tab-title/tab-title.style.js +2 -1
- package/lib/components/text-editor/__internal__/constants.d.ts +21 -0
- package/lib/components/text-editor/__internal__/constants.js +33 -0
- package/lib/components/text-editor/__internal__/helpers.d.ts +20 -0
- package/lib/components/text-editor/__internal__/helpers.js +91 -0
- package/lib/components/text-editor/__internal__/index.d.ts +2 -0
- package/lib/components/text-editor/__internal__/index.js +26 -0
- package/lib/components/text-editor/__internal__/package.json +6 -0
- package/lib/components/text-editor/__internal__/plugins/AutoLinker/auto-link.component.d.ts +3 -0
- package/lib/components/text-editor/__internal__/plugins/AutoLinker/auto-link.component.js +36 -0
- package/lib/components/text-editor/__internal__/plugins/AutoLinker/index.d.ts +1 -0
- package/lib/components/text-editor/__internal__/{editor-link → plugins/AutoLinker}/index.js +2 -2
- package/lib/components/text-editor/__internal__/{toolbar/toolbar-button → plugins/AutoLinker}/package.json +1 -1
- package/lib/components/text-editor/__internal__/plugins/CharacterCounter/__test__/character-counter.component.d.ts +10 -0
- package/lib/components/text-editor/__internal__/plugins/CharacterCounter/__test__/character-counter.component.js +42 -0
- package/lib/components/text-editor/__internal__/plugins/CharacterCounter/character-counter.component.d.ts +9 -0
- package/lib/components/text-editor/__internal__/plugins/CharacterCounter/character-counter.component.js +68 -0
- package/lib/components/text-editor/__internal__/plugins/CharacterCounter/character-counter.style.d.ts +3 -0
- package/lib/components/text-editor/__internal__/plugins/CharacterCounter/character-counter.style.js +24 -0
- package/lib/components/text-editor/__internal__/plugins/CharacterCounter/index.d.ts +1 -0
- package/lib/components/text-editor/__internal__/plugins/CharacterCounter/index.js +13 -0
- package/lib/components/text-editor/__internal__/plugins/CharacterCounter/package.json +6 -0
- package/lib/components/text-editor/__internal__/plugins/ContentEditor/content-editor.component.d.ts +17 -0
- package/lib/components/text-editor/__internal__/plugins/ContentEditor/content-editor.component.js +48 -0
- package/lib/components/text-editor/__internal__/plugins/ContentEditor/content-editor.style.d.ts +6 -0
- package/lib/components/text-editor/__internal__/plugins/ContentEditor/content-editor.style.js +42 -0
- package/lib/components/text-editor/__internal__/plugins/ContentEditor/index.d.ts +1 -0
- package/lib/components/text-editor/__internal__/{toolbar/toolbar-button → plugins/ContentEditor}/index.js +2 -2
- package/lib/components/text-editor/__internal__/plugins/ContentEditor/package.json +6 -0
- package/lib/components/text-editor/__internal__/plugins/LinkMonitor/index.d.ts +1 -0
- package/lib/components/text-editor/__internal__/{label-wrapper → plugins/LinkMonitor}/index.js +2 -2
- package/lib/components/text-editor/__internal__/plugins/LinkMonitor/link-monitor.plugin.d.ts +2 -0
- package/lib/components/text-editor/__internal__/plugins/LinkMonitor/link-monitor.plugin.js +70 -0
- package/lib/components/text-editor/__internal__/plugins/LinkMonitor/package.json +6 -0
- package/lib/components/text-editor/__internal__/plugins/LinkPreviewer/index.d.ts +1 -0
- package/lib/components/text-editor/__internal__/plugins/LinkPreviewer/index.js +13 -0
- package/lib/components/text-editor/__internal__/plugins/LinkPreviewer/link-previewer.component.d.ts +11 -0
- package/lib/components/text-editor/__internal__/plugins/LinkPreviewer/link-previewer.component.js +28 -0
- package/lib/components/text-editor/__internal__/plugins/LinkPreviewer/link-previewer.style.d.ts +6 -0
- package/lib/components/text-editor/__internal__/{toolbar/toolbar-button/toolbar-button.style.js → plugins/LinkPreviewer/link-previewer.style.js} +21 -31
- package/lib/components/text-editor/__internal__/plugins/LinkPreviewer/package.json +6 -0
- package/lib/components/text-editor/__internal__/plugins/OnChange/index.d.ts +1 -0
- package/lib/components/text-editor/__internal__/plugins/OnChange/index.js +13 -0
- package/lib/components/text-editor/__internal__/plugins/OnChange/on-change.plugin.d.ts +5 -0
- package/lib/components/text-editor/__internal__/plugins/OnChange/on-change.plugin.js +32 -0
- package/lib/components/text-editor/__internal__/plugins/OnChange/package.json +6 -0
- package/lib/components/text-editor/__internal__/plugins/Placeholder/index.d.ts +1 -0
- package/lib/components/text-editor/__internal__/plugins/Placeholder/index.js +13 -0
- package/lib/components/text-editor/__internal__/plugins/Placeholder/package.json +6 -0
- package/lib/components/text-editor/__internal__/plugins/Placeholder/placeholder.component.d.ts +14 -0
- package/lib/components/text-editor/__internal__/plugins/Placeholder/placeholder.component.js +25 -0
- package/lib/components/text-editor/__internal__/plugins/Placeholder/placeholder.style.d.ts +2 -0
- package/lib/components/text-editor/__internal__/plugins/Placeholder/placeholder.style.js +15 -0
- package/lib/components/text-editor/__internal__/plugins/Toolbar/buttons/bold.component.d.ts +4 -0
- package/lib/components/text-editor/__internal__/plugins/Toolbar/buttons/bold.component.js +48 -0
- package/lib/components/text-editor/__internal__/plugins/Toolbar/buttons/common.d.ts +6 -0
- package/lib/components/text-editor/__internal__/plugins/Toolbar/buttons/common.js +5 -0
- package/lib/components/text-editor/__internal__/plugins/Toolbar/buttons/index.d.ts +4 -0
- package/lib/components/text-editor/__internal__/plugins/Toolbar/buttons/index.js +34 -0
- package/lib/components/text-editor/__internal__/plugins/Toolbar/buttons/italic.component.d.ts +4 -0
- package/lib/components/text-editor/__internal__/plugins/Toolbar/buttons/italic.component.js +47 -0
- package/lib/components/text-editor/__internal__/plugins/Toolbar/buttons/list.component.d.ts +5 -0
- package/lib/components/text-editor/__internal__/plugins/Toolbar/buttons/list.component.js +325 -0
- package/lib/components/text-editor/__internal__/plugins/Toolbar/buttons/package.json +6 -0
- package/lib/components/text-editor/__internal__/plugins/Toolbar/buttons/save.component.d.ts +34 -0
- package/lib/components/text-editor/__internal__/plugins/Toolbar/buttons/save.component.js +36 -0
- package/lib/components/text-editor/__internal__/plugins/Toolbar/index.d.ts +1 -0
- package/lib/components/text-editor/__internal__/plugins/Toolbar/package.json +6 -0
- package/lib/components/text-editor/__internal__/plugins/Toolbar/toolbar.component.d.ts +12 -0
- package/lib/components/text-editor/__internal__/plugins/Toolbar/toolbar.component.js +120 -0
- package/lib/components/text-editor/__internal__/plugins/Toolbar/toolbar.style.d.ts +11 -0
- package/lib/components/text-editor/__internal__/plugins/Toolbar/toolbar.style.js +65 -0
- package/lib/components/text-editor/__internal__/plugins/index.d.ts +9 -0
- package/lib/components/text-editor/__internal__/plugins/index.js +69 -0
- package/lib/components/text-editor/__internal__/{toolbar → plugins}/package.json +1 -1
- package/lib/components/text-editor/__internal__/plugins/useCursorAtEnd/index.d.ts +2 -0
- package/lib/components/text-editor/__internal__/plugins/useCursorAtEnd/index.js +78 -0
- package/lib/components/text-editor/__internal__/plugins/useCursorAtEnd/package.json +6 -0
- package/lib/components/text-editor/__internal__/read-only-rte.component.d.ts +4 -0
- package/lib/components/text-editor/__internal__/read-only-rte.component.js +72 -0
- package/lib/components/text-editor/__internal__/style.css +7 -0
- package/lib/components/text-editor/__internal__/utils.d.ts +4 -0
- package/lib/components/text-editor/__internal__/utils.js +21 -0
- package/lib/components/text-editor/index.d.ts +2 -1
- package/lib/components/text-editor/index.js +7 -7
- package/lib/components/text-editor/text-editor.component.d.ts +32 -28
- package/lib/components/text-editor/text-editor.component.js +141 -477
- package/lib/components/text-editor/text-editor.context.d.ts +6 -0
- package/lib/components/text-editor/{__internal__/editor.context.js → text-editor.context.js} +1 -0
- package/lib/components/text-editor/text-editor.style.d.ts +18 -11
- package/lib/components/text-editor/text-editor.style.js +57 -53
- package/lib/locales/de-de.js +0 -14
- package/lib/locales/en-gb.js +18 -14
- package/lib/locales/es-es.js +0 -14
- package/lib/locales/fr-ca.js +0 -14
- package/lib/locales/fr-fr.js +0 -14
- package/lib/locales/locale.d.ts +14 -14
- package/package.json +7 -4
- package/esm/components/text-editor/__internal__/decorators/index.d.ts +0 -3
- package/esm/components/text-editor/__internal__/decorators/index.js +0 -3
- package/esm/components/text-editor/__internal__/decorators/link-decorator.d.ts +0 -8
- package/esm/components/text-editor/__internal__/decorators/link-decorator.js +0 -37
- package/esm/components/text-editor/__internal__/editor-link/editor-link.component.d.ts +0 -9
- package/esm/components/text-editor/__internal__/editor-link/editor-link.component.js +0 -36
- package/esm/components/text-editor/__internal__/editor-link/editor-link.style.d.ts +0 -3
- package/esm/components/text-editor/__internal__/editor-link/editor-link.style.js +0 -13
- package/esm/components/text-editor/__internal__/editor-link/index.d.ts +0 -2
- package/esm/components/text-editor/__internal__/editor-link/index.js +0 -1
- package/esm/components/text-editor/__internal__/editor-validation-wrapper/editor-validation-wrapper.component.d.ts +0 -11
- package/esm/components/text-editor/__internal__/editor-validation-wrapper/editor-validation-wrapper.component.js +0 -18
- package/esm/components/text-editor/__internal__/editor-validation-wrapper/editor-validation-wrapper.style.d.ts +0 -2
- package/esm/components/text-editor/__internal__/editor-validation-wrapper/editor-validation-wrapper.style.js +0 -11
- package/esm/components/text-editor/__internal__/editor-validation-wrapper/index.d.ts +0 -2
- package/esm/components/text-editor/__internal__/editor-validation-wrapper/index.js +0 -1
- package/esm/components/text-editor/__internal__/editor.context.d.ts +0 -6
- package/esm/components/text-editor/__internal__/editor.context.js +0 -2
- package/esm/components/text-editor/__internal__/label-wrapper/index.d.ts +0 -2
- package/esm/components/text-editor/__internal__/label-wrapper/index.js +0 -1
- package/esm/components/text-editor/__internal__/label-wrapper/label-wrapper.component.d.ts +0 -12
- package/esm/components/text-editor/__internal__/label-wrapper/label-wrapper.component.js +0 -18
- package/esm/components/text-editor/__internal__/toolbar/index.d.ts +0 -2
- package/esm/components/text-editor/__internal__/toolbar/toolbar-button/index.d.ts +0 -2
- package/esm/components/text-editor/__internal__/toolbar/toolbar-button/index.js +0 -1
- package/esm/components/text-editor/__internal__/toolbar/toolbar-button/toolbar-button.component.d.ts +0 -25
- package/esm/components/text-editor/__internal__/toolbar/toolbar-button/toolbar-button.component.js +0 -50
- package/esm/components/text-editor/__internal__/toolbar/toolbar-button/toolbar-button.style.d.ts +0 -6
- package/esm/components/text-editor/__internal__/toolbar/toolbar-button/toolbar-button.style.js +0 -38
- package/esm/components/text-editor/__internal__/toolbar/toolbar.component.d.ts +0 -16
- package/esm/components/text-editor/__internal__/toolbar/toolbar.component.js +0 -158
- package/esm/components/text-editor/__internal__/toolbar/toolbar.style.d.ts +0 -4
- package/esm/components/text-editor/__internal__/toolbar/toolbar.style.js +0 -28
- package/esm/components/text-editor/__internal__/utils/index.d.ts +0 -1
- package/esm/components/text-editor/__internal__/utils/index.js +0 -1
- package/esm/components/text-editor/__internal__/utils/utils.d.ts +0 -29
- package/esm/components/text-editor/__internal__/utils/utils.js +0 -174
- package/esm/components/text-editor/types.d.ts +0 -6
- package/esm/components/text-editor/types.js +0 -4
- package/lib/components/text-editor/__internal__/decorators/index.d.ts +0 -3
- package/lib/components/text-editor/__internal__/decorators/index.js +0 -10
- package/lib/components/text-editor/__internal__/decorators/link-decorator.d.ts +0 -8
- package/lib/components/text-editor/__internal__/decorators/link-decorator.js +0 -44
- package/lib/components/text-editor/__internal__/decorators/package.json +0 -6
- package/lib/components/text-editor/__internal__/editor-link/editor-link.component.d.ts +0 -9
- package/lib/components/text-editor/__internal__/editor-link/editor-link.component.js +0 -45
- package/lib/components/text-editor/__internal__/editor-link/editor-link.style.d.ts +0 -3
- package/lib/components/text-editor/__internal__/editor-link/editor-link.style.js +0 -20
- package/lib/components/text-editor/__internal__/editor-link/index.d.ts +0 -2
- package/lib/components/text-editor/__internal__/editor-link/package.json +0 -6
- package/lib/components/text-editor/__internal__/editor-validation-wrapper/editor-validation-wrapper.component.d.ts +0 -11
- package/lib/components/text-editor/__internal__/editor-validation-wrapper/editor-validation-wrapper.component.js +0 -25
- package/lib/components/text-editor/__internal__/editor-validation-wrapper/editor-validation-wrapper.style.d.ts +0 -2
- package/lib/components/text-editor/__internal__/editor-validation-wrapper/editor-validation-wrapper.style.js +0 -18
- package/lib/components/text-editor/__internal__/editor-validation-wrapper/index.d.ts +0 -2
- package/lib/components/text-editor/__internal__/editor-validation-wrapper/index.js +0 -13
- package/lib/components/text-editor/__internal__/editor-validation-wrapper/package.json +0 -6
- package/lib/components/text-editor/__internal__/editor.context.d.ts +0 -6
- package/lib/components/text-editor/__internal__/label-wrapper/index.d.ts +0 -2
- package/lib/components/text-editor/__internal__/label-wrapper/label-wrapper.component.d.ts +0 -12
- package/lib/components/text-editor/__internal__/label-wrapper/label-wrapper.component.js +0 -25
- package/lib/components/text-editor/__internal__/label-wrapper/package.json +0 -6
- package/lib/components/text-editor/__internal__/toolbar/index.d.ts +0 -2
- package/lib/components/text-editor/__internal__/toolbar/toolbar-button/index.d.ts +0 -2
- package/lib/components/text-editor/__internal__/toolbar/toolbar-button/toolbar-button.component.d.ts +0 -25
- package/lib/components/text-editor/__internal__/toolbar/toolbar-button/toolbar-button.component.js +0 -56
- package/lib/components/text-editor/__internal__/toolbar/toolbar-button/toolbar-button.style.d.ts +0 -6
- package/lib/components/text-editor/__internal__/toolbar/toolbar.component.d.ts +0 -16
- package/lib/components/text-editor/__internal__/toolbar/toolbar.component.js +0 -167
- package/lib/components/text-editor/__internal__/toolbar/toolbar.style.d.ts +0 -4
- package/lib/components/text-editor/__internal__/toolbar/toolbar.style.js +0 -34
- package/lib/components/text-editor/__internal__/utils/index.d.ts +0 -1
- package/lib/components/text-editor/__internal__/utils/index.js +0 -90
- package/lib/components/text-editor/__internal__/utils/package.json +0 -6
- package/lib/components/text-editor/__internal__/utils/utils.d.ts +0 -29
- package/lib/components/text-editor/__internal__/utils/utils.js +0 -197
- package/lib/components/text-editor/types.d.ts +0 -6
- package/lib/components/text-editor/types.js +0 -10
- /package/esm/components/text-editor/__internal__/{toolbar → plugins/Toolbar}/index.js +0 -0
- /package/lib/components/text-editor/__internal__/{toolbar → plugins/Toolbar}/index.js +0 -0
|
@@ -1,500 +1,161 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import { LexicalComposer } from "@lexical/react/LexicalComposer";
|
|
3
|
+
import { ClickableLinkPlugin } from "@lexical/react/LexicalClickableLinkPlugin";
|
|
4
|
+
import { EditorRefPlugin } from "@lexical/react/LexicalEditorRefPlugin";
|
|
5
|
+
import { LexicalErrorBoundary } from "@lexical/react/LexicalErrorBoundary";
|
|
6
|
+
import { HistoryPlugin } from "@lexical/react/LexicalHistoryPlugin";
|
|
7
|
+
import { MarkdownShortcutPlugin } from "@lexical/react/LexicalMarkdownShortcutPlugin";
|
|
8
|
+
import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
|
|
9
|
+
import { LinkPlugin } from "@lexical/react/LexicalLinkPlugin";
|
|
10
|
+
import { ListPlugin } from "@lexical/react/LexicalListPlugin";
|
|
11
|
+
import { $getRoot } from "lexical";
|
|
12
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
13
|
import PropTypes from "prop-types";
|
|
4
|
-
import { ContentState, EditorState, RichUtils, getDefaultKeyBinding, Modifier, Editor } from "draft-js";
|
|
5
|
-
import { computeBlockType, getContent, getContentInfo, getDecoratedValue, getSelectedLength, moveSelectionToEnd, resetBlockType, isASCIIChar, replaceText, hasInlineStyle, hasBlockStyle, blockStyleFn } from "./__internal__/utils";
|
|
6
|
-
import { StyledEditorWrapper, StyledEditorOutline, StyledEditorContainer } from "./text-editor.style";
|
|
7
|
-
import ValidationWrapper from "./__internal__/editor-validation-wrapper";
|
|
8
|
-
import Toolbar from "./__internal__/toolbar";
|
|
9
14
|
import Label from "../../__internal__/label";
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
|
|
19
|
-
import useCharacterCount from "../../hooks/__internal__/useCharacterCount";
|
|
20
|
-
import EditorContext from "./__internal__/editor.context";
|
|
21
|
-
const NUMBERS = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
|
|
22
|
-
const INLINE_STYLES = [BOLD, ITALIC];
|
|
23
|
-
const TextEditor = /*#__PURE__*/React.forwardRef(({
|
|
15
|
+
import useDebounce from "../../hooks/__internal__/useDebounce";
|
|
16
|
+
import useLocale from "../../hooks/__internal__/useLocale";
|
|
17
|
+
import { COMPONENT_PREFIX, markdownNodes, theme } from "./__internal__/constants";
|
|
18
|
+
import { validateUrl } from "./__internal__/helpers";
|
|
19
|
+
import { AutoLinkerPlugin, CharacterCounterPlugin, ContentEditor, LinkMonitorPlugin, OnChangePlugin, Placeholder, ToolbarPlugin } from "./__internal__/plugins";
|
|
20
|
+
import TextEditorContext from "./text-editor.context";
|
|
21
|
+
import StyledTextEditor, { StyledEditorToolbarWrapper, StyledHintText, StyledValidationMessage, StyledWrapper } from "./text-editor.style";
|
|
22
|
+
import { createEmpty } from "./__internal__";
|
|
23
|
+
export const TextEditor = ({
|
|
24
24
|
characterLimit = 3000,
|
|
25
|
+
error,
|
|
26
|
+
inputHint,
|
|
27
|
+
isOptional = false,
|
|
25
28
|
labelText,
|
|
29
|
+
namespace = COMPONENT_PREFIX,
|
|
30
|
+
onCancel,
|
|
26
31
|
onChange,
|
|
27
|
-
value,
|
|
28
|
-
required,
|
|
29
|
-
error,
|
|
30
|
-
warning,
|
|
31
|
-
info,
|
|
32
|
-
toolbarElements,
|
|
33
|
-
rows,
|
|
34
|
-
previews,
|
|
35
32
|
onLinkAdded,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
33
|
+
onSave,
|
|
34
|
+
placeholder,
|
|
35
|
+
previews = [],
|
|
36
|
+
readOnly = false,
|
|
37
|
+
required = false,
|
|
38
|
+
rows,
|
|
39
|
+
warning,
|
|
40
|
+
value
|
|
41
|
+
}) => {
|
|
42
|
+
const editorRef = useRef(undefined);
|
|
43
|
+
const locale = useLocale();
|
|
44
|
+
const [characterLimitWarning, setCharacterLimitWarning] = useState(undefined);
|
|
43
45
|
const [isFocused, setIsFocused] = useState(false);
|
|
44
|
-
const [
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
} = useRef(guid());
|
|
57
|
-
const {
|
|
58
|
-
labelId,
|
|
59
|
-
validationId,
|
|
60
|
-
ariaDescribedBy
|
|
61
|
-
} = useInputAccessibility({
|
|
62
|
-
id,
|
|
63
|
-
validationRedesignOptIn,
|
|
64
|
-
error,
|
|
65
|
-
warning,
|
|
66
|
-
info,
|
|
67
|
-
label: labelText
|
|
68
|
-
});
|
|
69
|
-
const [characterCount, visuallyHiddenHintId] = useCharacterCount(getContent(value).getPlainText(""), characterLimit, isFocused ? "polite" : "off");
|
|
70
|
-
const combinedAriaDescribedBy = [ariaDescribedBy, inputHint ? inputHintId.current : undefined, visuallyHiddenHintId].filter(Boolean).join(" ");
|
|
71
|
-
if (rows && (typeof rows !== "number" || rows < 2)) {
|
|
72
|
-
// eslint-disable-next-line no-console
|
|
73
|
-
console.warn(`Prop rows must be a number value that is 2 or greater to override the min-height of the \`${TextEditor.displayName}\``);
|
|
74
|
-
}
|
|
75
|
-
const keyBindingFn = ev => {
|
|
76
|
-
if (Events.isTabKey(ev) && !Events.isShiftKey(ev)) {
|
|
77
|
-
setFocusToolbar(true);
|
|
78
|
-
}
|
|
79
|
-
return getDefaultKeyBinding(ev);
|
|
80
|
-
};
|
|
81
|
-
const BLOCK_TYPES = ["unordered-list-item", "ordered-list-item"];
|
|
82
|
-
const handleKeyCommand = command => {
|
|
83
|
-
// bail out if the enter is pressed and limit has been reached
|
|
84
|
-
if (command.includes("split-block") && contentLength === characterLimit) {
|
|
85
|
-
return "handled";
|
|
86
|
-
}
|
|
46
|
+
const [cancelTrigger, setCancelTrigger] = useState(false);
|
|
47
|
+
const debounceWaitTime = 500;
|
|
48
|
+
const initialConfig = useMemo(() => {
|
|
49
|
+
return {
|
|
50
|
+
namespace,
|
|
51
|
+
nodes: markdownNodes,
|
|
52
|
+
onError: console.error,
|
|
53
|
+
theme,
|
|
54
|
+
editorState: value,
|
|
55
|
+
editable: !readOnly
|
|
56
|
+
};
|
|
57
|
+
}, [namespace, readOnly, value]);
|
|
87
58
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
// if a block control is active and there is no text, deactivate it and reset the block
|
|
96
|
-
if (BLOCK_TYPES.includes(blockType) && !blockLength) {
|
|
97
|
-
onChange(resetBlockType(value, "unstyled"));
|
|
98
|
-
return "handled";
|
|
99
|
-
}
|
|
59
|
+
// OnChangePlugin is tested separately
|
|
60
|
+
/* istanbul ignore next */
|
|
61
|
+
const handleChange = useDebounce(newState => {
|
|
62
|
+
const currentTextContent = newState.read(() => $getRoot().getTextContent());
|
|
63
|
+
if (onChange) {
|
|
64
|
+
onChange?.(currentTextContent);
|
|
100
65
|
}
|
|
101
|
-
const style = command.toUpperCase();
|
|
102
66
|
|
|
103
|
-
//
|
|
104
|
-
if (
|
|
105
|
-
const
|
|
67
|
+
// If the character limit is set, check if the limit has been exceeded
|
|
68
|
+
if (characterLimit > 0) {
|
|
69
|
+
const currentDiff = characterLimit - currentTextContent.length;
|
|
70
|
+
// If the character limit has been exceeded, show the character limit warning
|
|
71
|
+
setCharacterLimitWarning(currentDiff < 0 ? locale.textEditor.characterLimit(Math.abs(currentDiff)) : undefined);
|
|
72
|
+
}
|
|
73
|
+
}, debounceWaitTime);
|
|
74
|
+
const handleCancel = useCallback(() => {
|
|
75
|
+
const editor = editorRef.current;
|
|
76
|
+
/* istanbul ignore next */
|
|
77
|
+
const isEditable = editor?.isEditable() || false;
|
|
78
|
+
/* istanbul ignore if */
|
|
79
|
+
if (!isEditable) return;
|
|
106
80
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
...activeInlines,
|
|
112
|
-
[style]: !hasInlineStyle(value, style)
|
|
113
|
-
});
|
|
114
|
-
return "handled";
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
return "not-handled";
|
|
118
|
-
};
|
|
119
|
-
const handleBeforeInput = (str, newState) => {
|
|
120
|
-
// short circuit if exceeds character limit
|
|
121
|
-
if (contentLength >= characterLimit) {
|
|
122
|
-
return "handled";
|
|
81
|
+
/* istanbul ignore else */
|
|
82
|
+
if (onCancel) {
|
|
83
|
+
setCancelTrigger(prev => !prev);
|
|
84
|
+
onCancel();
|
|
123
85
|
}
|
|
124
|
-
|
|
86
|
+
}, [onCancel]);
|
|
125
87
|
|
|
126
|
-
|
|
127
|
-
// prevent the editor from crashing until a fix can be added to their codebase
|
|
128
|
-
if (lastKeyPressed.current === " " && !isASCIIChar(str)) {
|
|
129
|
-
lastKeyPressed.current = null;
|
|
130
|
-
onChange(replaceText(newState, " ", newState.getCurrentInlineStyle()));
|
|
131
|
-
return "handled";
|
|
132
|
-
}
|
|
133
|
-
if (str === " ") {
|
|
134
|
-
lastKeyPressed.current = str;
|
|
135
|
-
return "not-handled";
|
|
136
|
-
}
|
|
137
|
-
lastKeyPressed.current = null;
|
|
138
|
-
// short circuit if str does not match expected chars
|
|
139
|
-
if (![".", "*"].includes(str)) {
|
|
140
|
-
return "not-handled";
|
|
141
|
-
}
|
|
142
|
-
const {
|
|
143
|
-
blockType,
|
|
144
|
-
blockLength,
|
|
145
|
-
blockText
|
|
146
|
-
} = getContentInfo(value);
|
|
147
|
-
if (blockLength === 1 && NUMBERS.includes(blockText) && str === "." || blockLength === 0 && str === "*") {
|
|
148
|
-
const newBlockType = computeBlockType(str, blockType);
|
|
149
|
-
const hasNumberList = hasBlockStyle(value, ORDERED_LIST);
|
|
150
|
-
const hasBulletList = hasBlockStyle(value, UNORDERED_LIST);
|
|
151
|
-
if (BLOCK_TYPES.includes(newBlockType) && !hasNumberList && !hasBulletList) {
|
|
152
|
-
onChange(resetBlockType(value, newBlockType));
|
|
153
|
-
setActiveInlines({
|
|
154
|
-
BOLD: hasInlineStyle(value, BOLD),
|
|
155
|
-
ITALIC: hasInlineStyle(value, ITALIC)
|
|
156
|
-
});
|
|
157
|
-
return "handled";
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
onChange(value);
|
|
161
|
-
return "not-handled";
|
|
162
|
-
};
|
|
163
|
-
const handlePastedText = pastedText => {
|
|
164
|
-
const selectedTextLength = getSelectedLength(value);
|
|
165
|
-
const newLength = contentLength + pastedText?.length - selectedTextLength;
|
|
166
|
-
// if the pastedText will exceed the limit trim the excess
|
|
167
|
-
if (newLength > characterLimit) {
|
|
168
|
-
const newContentState = Modifier.insertText(getContent(value), value.getSelection(), pastedText.substring(0, characterLimit - contentLength));
|
|
169
|
-
const newState = EditorState.push(value, newContentState, "insert-fragment");
|
|
170
|
-
onChange(newState);
|
|
171
|
-
return "handled";
|
|
172
|
-
}
|
|
173
|
-
setActiveInlines({});
|
|
174
|
-
return "not-handled";
|
|
175
|
-
};
|
|
176
|
-
const getEditorState = () => {
|
|
177
|
-
let editorState = getDecoratedValue(value);
|
|
178
|
-
|
|
179
|
-
// should the cursor position be forced to the end of the content
|
|
180
|
-
if (contentLength > 0 && moveCursor.current && isFocused) {
|
|
181
|
-
editorState = moveSelectionToEnd(editorState);
|
|
182
|
-
moveCursor.current = false;
|
|
183
|
-
}
|
|
184
|
-
return editorState;
|
|
185
|
-
};
|
|
186
|
-
const editorState = getEditorState();
|
|
187
|
-
const activeControls = {
|
|
188
|
-
BOLD: activeInlines.BOLD !== undefined ? activeInlines.BOLD : hasInlineStyle(editorState, BOLD),
|
|
189
|
-
ITALIC: activeInlines.ITALIC !== undefined ? activeInlines.ITALIC : hasInlineStyle(editorState, ITALIC),
|
|
190
|
-
"unordered-list-item": hasBlockStyle(editorState, UNORDERED_LIST),
|
|
191
|
-
"ordered-list-item": hasBlockStyle(editorState, ORDERED_LIST)
|
|
192
|
-
};
|
|
193
|
-
const handleEditorFocus = useCallback(focusValue => {
|
|
194
|
-
moveCursor.current = true;
|
|
195
|
-
if (focusValue && typeof editor === "object" && editor.current !== document.activeElement) {
|
|
196
|
-
editor.current?.focus();
|
|
197
|
-
setFocusToolbar(false);
|
|
198
|
-
}
|
|
199
|
-
setIsFocused(focusValue);
|
|
200
|
-
}, [editor]);
|
|
201
|
-
const handleInlineStyleChange = (ev, style) => {
|
|
202
|
-
ev.preventDefault();
|
|
203
|
-
setActiveInlines({
|
|
204
|
-
...activeInlines,
|
|
205
|
-
[style]: !hasInlineStyle(value, style)
|
|
206
|
-
});
|
|
207
|
-
handleEditorFocus(true);
|
|
208
|
-
setInlines([...inlines, style]);
|
|
209
|
-
};
|
|
210
|
-
const handleBlockStyleChange = (ev, newBlockType) => {
|
|
211
|
-
ev.preventDefault();
|
|
212
|
-
handleEditorFocus(true);
|
|
213
|
-
onChange(RichUtils.toggleBlockType(value, newBlockType));
|
|
214
|
-
const temp = [];
|
|
215
|
-
INLINE_STYLES.forEach(style => {
|
|
216
|
-
if (activeInlines[style] !== undefined) {
|
|
217
|
-
temp.push(style);
|
|
218
|
-
}
|
|
219
|
-
});
|
|
220
|
-
setInlines(temp);
|
|
221
|
-
};
|
|
88
|
+
// Reset the value of the editor when the cancel trigger is updated (implements reset on cancel)
|
|
222
89
|
useEffect(() => {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
INLINE_STYLES.forEach(style => {
|
|
226
|
-
const preserveStyle = activeInlines[style] !== undefined && activeInlines[style] !== hasInlineStyle(value, style);
|
|
227
|
-
if (preserveStyle && value.getSelection().isCollapsed() || isFocused && inlines.includes(style)) {
|
|
228
|
-
onChange(RichUtils.toggleInlineStyle(value, style));
|
|
229
|
-
setInlines(inlines.filter(inline => inline !== style));
|
|
230
|
-
}
|
|
231
|
-
if (preserveStyle && !value.getSelection().isCollapsed()) {
|
|
232
|
-
setActiveInlines({
|
|
233
|
-
...activeInlines,
|
|
234
|
-
[style]: undefined
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
});
|
|
238
|
-
}, [activeInlines, contentLength, editorState, inlines, isFocused, onChange, value]);
|
|
239
|
-
const handlePreviewClose = (onClose, url) => {
|
|
240
|
-
// istanbul ignore else
|
|
241
|
-
if (url) onClose(url);
|
|
90
|
+
const editor = editorRef.current;
|
|
91
|
+
const safeValue = value || createEmpty();
|
|
242
92
|
|
|
243
|
-
|
|
244
|
-
if (
|
|
245
|
-
editor.
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
return /*#__PURE__*/React.createElement(EditorContext.Provider, {
|
|
93
|
+
/* istanbul ignore else */
|
|
94
|
+
if (editor) {
|
|
95
|
+
const newEditorState = editor.parseEditorState(safeValue);
|
|
96
|
+
editor.setEditorState(newEditorState);
|
|
97
|
+
}
|
|
98
|
+
}, [cancelTrigger, value]);
|
|
99
|
+
const toolbarProps = useMemo(() => ({
|
|
100
|
+
namespace,
|
|
101
|
+
onCancel: onCancel ? handleCancel : undefined,
|
|
102
|
+
onSave
|
|
103
|
+
}), [handleCancel, namespace, onCancel, onSave]);
|
|
104
|
+
return /*#__PURE__*/React.createElement(TextEditorContext.Provider, {
|
|
256
105
|
value: {
|
|
257
106
|
onLinkAdded,
|
|
258
|
-
|
|
107
|
+
readOnly
|
|
259
108
|
}
|
|
260
|
-
}, /*#__PURE__*/React.createElement(StyledEditorWrapper, _extends({
|
|
261
|
-
ref: wrapper,
|
|
262
|
-
"data-role": "text-editor-wrapper"
|
|
263
|
-
}, rest), /*#__PURE__*/React.createElement(LabelWrapper, {
|
|
264
|
-
onClick: () => handleEditorFocus(true)
|
|
265
109
|
}, /*#__PURE__*/React.createElement(Label, {
|
|
266
|
-
labelId: labelId,
|
|
267
110
|
isRequired: required,
|
|
268
|
-
optional: isOptional
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
},
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
}),
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
}, /*#__PURE__*/React.createElement(StyledEditorContainer, {
|
|
284
|
-
"data-component": "text-editor-container",
|
|
285
|
-
hasError: !!error,
|
|
286
|
-
rows: rows,
|
|
287
|
-
hasPreview: !!React.Children.count(previews)
|
|
288
|
-
}, !validationRedesignOptIn && (error || warning || info) && /*#__PURE__*/React.createElement(ValidationWrapper, {
|
|
111
|
+
optional: isOptional,
|
|
112
|
+
labelId: `${namespace}-label`
|
|
113
|
+
}, labelText), inputHint && /*#__PURE__*/React.createElement(StyledHintText, {
|
|
114
|
+
"data-role": `${namespace}-input-hint`,
|
|
115
|
+
id: `${namespace}-input-hint`
|
|
116
|
+
}, inputHint), /*#__PURE__*/React.createElement(LexicalComposer, {
|
|
117
|
+
initialConfig: initialConfig
|
|
118
|
+
}, /*#__PURE__*/React.createElement(EditorRefPlugin, {
|
|
119
|
+
editorRef: editorRef
|
|
120
|
+
}), /*#__PURE__*/React.createElement(StyledWrapper, {
|
|
121
|
+
"data-role": `${namespace}-wrapper`,
|
|
122
|
+
error: error || undefined,
|
|
123
|
+
namespace: namespace,
|
|
124
|
+
warning: characterLimitWarning || warning || undefined
|
|
125
|
+
}, (error || characterLimitWarning || warning) && /*#__PURE__*/React.createElement(StyledValidationMessage, {
|
|
289
126
|
error: error,
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
}), /*#__PURE__*/React.createElement(
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
});
|
|
325
|
-
if (process.env.NODE_ENV !== "production") {
|
|
326
|
-
TextEditor.propTypes = {
|
|
327
|
-
"characterLimit": PropTypes.number,
|
|
328
|
-
"error": PropTypes.string,
|
|
329
|
-
"info": PropTypes.string,
|
|
330
|
-
"inputHint": PropTypes.string,
|
|
331
|
-
"isOptional": PropTypes.bool,
|
|
332
|
-
"labelText": PropTypes.string.isRequired,
|
|
333
|
-
"m": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
334
|
-
"__@toStringTag": PropTypes.string.isRequired,
|
|
335
|
-
"description": PropTypes.string,
|
|
336
|
-
"toString": PropTypes.func.isRequired,
|
|
337
|
-
"valueOf": PropTypes.func.isRequired
|
|
338
|
-
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
339
|
-
"__@toStringTag": PropTypes.string.isRequired,
|
|
340
|
-
"description": PropTypes.string,
|
|
341
|
-
"toString": PropTypes.func.isRequired,
|
|
342
|
-
"valueOf": PropTypes.func.isRequired
|
|
343
|
-
}), PropTypes.string]),
|
|
344
|
-
"margin": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
345
|
-
"__@toStringTag": PropTypes.string.isRequired,
|
|
346
|
-
"description": PropTypes.string,
|
|
347
|
-
"toString": PropTypes.func.isRequired,
|
|
348
|
-
"valueOf": PropTypes.func.isRequired
|
|
349
|
-
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
350
|
-
"__@toStringTag": PropTypes.string.isRequired,
|
|
351
|
-
"description": PropTypes.string,
|
|
352
|
-
"toString": PropTypes.func.isRequired,
|
|
353
|
-
"valueOf": PropTypes.func.isRequired
|
|
354
|
-
}), PropTypes.string]),
|
|
355
|
-
"marginBottom": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
356
|
-
"__@toStringTag": PropTypes.string.isRequired,
|
|
357
|
-
"description": PropTypes.string,
|
|
358
|
-
"toString": PropTypes.func.isRequired,
|
|
359
|
-
"valueOf": PropTypes.func.isRequired
|
|
360
|
-
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
361
|
-
"__@toStringTag": PropTypes.string.isRequired,
|
|
362
|
-
"description": PropTypes.string,
|
|
363
|
-
"toString": PropTypes.func.isRequired,
|
|
364
|
-
"valueOf": PropTypes.func.isRequired
|
|
365
|
-
}), PropTypes.string]),
|
|
366
|
-
"marginLeft": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
367
|
-
"__@toStringTag": PropTypes.string.isRequired,
|
|
368
|
-
"description": PropTypes.string,
|
|
369
|
-
"toString": PropTypes.func.isRequired,
|
|
370
|
-
"valueOf": PropTypes.func.isRequired
|
|
371
|
-
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
372
|
-
"__@toStringTag": PropTypes.string.isRequired,
|
|
373
|
-
"description": PropTypes.string,
|
|
374
|
-
"toString": PropTypes.func.isRequired,
|
|
375
|
-
"valueOf": PropTypes.func.isRequired
|
|
376
|
-
}), PropTypes.string]),
|
|
377
|
-
"marginRight": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
378
|
-
"__@toStringTag": PropTypes.string.isRequired,
|
|
379
|
-
"description": PropTypes.string,
|
|
380
|
-
"toString": PropTypes.func.isRequired,
|
|
381
|
-
"valueOf": PropTypes.func.isRequired
|
|
382
|
-
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
383
|
-
"__@toStringTag": PropTypes.string.isRequired,
|
|
384
|
-
"description": PropTypes.string,
|
|
385
|
-
"toString": PropTypes.func.isRequired,
|
|
386
|
-
"valueOf": PropTypes.func.isRequired
|
|
387
|
-
}), PropTypes.string]),
|
|
388
|
-
"marginTop": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
389
|
-
"__@toStringTag": PropTypes.string.isRequired,
|
|
390
|
-
"description": PropTypes.string,
|
|
391
|
-
"toString": PropTypes.func.isRequired,
|
|
392
|
-
"valueOf": PropTypes.func.isRequired
|
|
393
|
-
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
394
|
-
"__@toStringTag": PropTypes.string.isRequired,
|
|
395
|
-
"description": PropTypes.string,
|
|
396
|
-
"toString": PropTypes.func.isRequired,
|
|
397
|
-
"valueOf": PropTypes.func.isRequired
|
|
398
|
-
}), PropTypes.string]),
|
|
399
|
-
"marginX": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
400
|
-
"__@toStringTag": PropTypes.string.isRequired,
|
|
401
|
-
"description": PropTypes.string,
|
|
402
|
-
"toString": PropTypes.func.isRequired,
|
|
403
|
-
"valueOf": PropTypes.func.isRequired
|
|
404
|
-
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
405
|
-
"__@toStringTag": PropTypes.string.isRequired,
|
|
406
|
-
"description": PropTypes.string,
|
|
407
|
-
"toString": PropTypes.func.isRequired,
|
|
408
|
-
"valueOf": PropTypes.func.isRequired
|
|
409
|
-
}), PropTypes.string]),
|
|
410
|
-
"marginY": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
411
|
-
"__@toStringTag": PropTypes.string.isRequired,
|
|
412
|
-
"description": PropTypes.string,
|
|
413
|
-
"toString": PropTypes.func.isRequired,
|
|
414
|
-
"valueOf": PropTypes.func.isRequired
|
|
415
|
-
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
416
|
-
"__@toStringTag": PropTypes.string.isRequired,
|
|
417
|
-
"description": PropTypes.string,
|
|
418
|
-
"toString": PropTypes.func.isRequired,
|
|
419
|
-
"valueOf": PropTypes.func.isRequired
|
|
420
|
-
}), PropTypes.string]),
|
|
421
|
-
"mb": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
422
|
-
"__@toStringTag": PropTypes.string.isRequired,
|
|
423
|
-
"description": PropTypes.string,
|
|
424
|
-
"toString": PropTypes.func.isRequired,
|
|
425
|
-
"valueOf": PropTypes.func.isRequired
|
|
426
|
-
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
427
|
-
"__@toStringTag": PropTypes.string.isRequired,
|
|
428
|
-
"description": PropTypes.string,
|
|
429
|
-
"toString": PropTypes.func.isRequired,
|
|
430
|
-
"valueOf": PropTypes.func.isRequired
|
|
431
|
-
}), PropTypes.string]),
|
|
432
|
-
"ml": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
433
|
-
"__@toStringTag": PropTypes.string.isRequired,
|
|
434
|
-
"description": PropTypes.string,
|
|
435
|
-
"toString": PropTypes.func.isRequired,
|
|
436
|
-
"valueOf": PropTypes.func.isRequired
|
|
437
|
-
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
438
|
-
"__@toStringTag": PropTypes.string.isRequired,
|
|
439
|
-
"description": PropTypes.string,
|
|
440
|
-
"toString": PropTypes.func.isRequired,
|
|
441
|
-
"valueOf": PropTypes.func.isRequired
|
|
442
|
-
}), PropTypes.string]),
|
|
443
|
-
"mr": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
444
|
-
"__@toStringTag": PropTypes.string.isRequired,
|
|
445
|
-
"description": PropTypes.string,
|
|
446
|
-
"toString": PropTypes.func.isRequired,
|
|
447
|
-
"valueOf": PropTypes.func.isRequired
|
|
448
|
-
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
449
|
-
"__@toStringTag": PropTypes.string.isRequired,
|
|
450
|
-
"description": PropTypes.string,
|
|
451
|
-
"toString": PropTypes.func.isRequired,
|
|
452
|
-
"valueOf": PropTypes.func.isRequired
|
|
453
|
-
}), PropTypes.string]),
|
|
454
|
-
"mt": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
455
|
-
"__@toStringTag": PropTypes.string.isRequired,
|
|
456
|
-
"description": PropTypes.string,
|
|
457
|
-
"toString": PropTypes.func.isRequired,
|
|
458
|
-
"valueOf": PropTypes.func.isRequired
|
|
459
|
-
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
460
|
-
"__@toStringTag": PropTypes.string.isRequired,
|
|
461
|
-
"description": PropTypes.string,
|
|
462
|
-
"toString": PropTypes.func.isRequired,
|
|
463
|
-
"valueOf": PropTypes.func.isRequired
|
|
464
|
-
}), PropTypes.string]),
|
|
465
|
-
"mx": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
466
|
-
"__@toStringTag": PropTypes.string.isRequired,
|
|
467
|
-
"description": PropTypes.string,
|
|
468
|
-
"toString": PropTypes.func.isRequired,
|
|
469
|
-
"valueOf": PropTypes.func.isRequired
|
|
470
|
-
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
471
|
-
"__@toStringTag": PropTypes.string.isRequired,
|
|
472
|
-
"description": PropTypes.string,
|
|
473
|
-
"toString": PropTypes.func.isRequired,
|
|
474
|
-
"valueOf": PropTypes.func.isRequired
|
|
475
|
-
}), PropTypes.string]),
|
|
476
|
-
"my": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
477
|
-
"__@toStringTag": PropTypes.string.isRequired,
|
|
478
|
-
"description": PropTypes.string,
|
|
479
|
-
"toString": PropTypes.func.isRequired,
|
|
480
|
-
"valueOf": PropTypes.func.isRequired
|
|
481
|
-
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
482
|
-
"__@toStringTag": PropTypes.string.isRequired,
|
|
483
|
-
"description": PropTypes.string,
|
|
484
|
-
"toString": PropTypes.func.isRequired,
|
|
485
|
-
"valueOf": PropTypes.func.isRequired
|
|
486
|
-
}), PropTypes.string]),
|
|
487
|
-
"onChange": PropTypes.func.isRequired,
|
|
488
|
-
"onLinkAdded": PropTypes.func,
|
|
489
|
-
"previews": PropTypes.node,
|
|
490
|
-
"required": PropTypes.bool,
|
|
491
|
-
"rows": PropTypes.number,
|
|
492
|
-
"toolbarElements": PropTypes.node,
|
|
493
|
-
"value": PropTypes.object.isRequired,
|
|
494
|
-
"warning": PropTypes.string
|
|
495
|
-
};
|
|
496
|
-
}
|
|
497
|
-
export { TextEditor };
|
|
498
|
-
export const TextEditorState = EditorState;
|
|
499
|
-
export const TextEditorContentState = ContentState;
|
|
127
|
+
"data-role": `${namespace}-validation-message`
|
|
128
|
+
}, error || characterLimitWarning || warning), /*#__PURE__*/React.createElement(StyledEditorToolbarWrapper, {
|
|
129
|
+
"data-role": `${namespace}-editor-toolbar-wrapper`,
|
|
130
|
+
id: `${namespace}-editor-toolbar-wrapper`,
|
|
131
|
+
onBlur: () => setIsFocused(false),
|
|
132
|
+
onFocus: () => setIsFocused(true),
|
|
133
|
+
focused: isFocused
|
|
134
|
+
}, /*#__PURE__*/React.createElement(StyledTextEditor, {
|
|
135
|
+
"data-role": `${namespace}-editor`
|
|
136
|
+
}, /*#__PURE__*/React.createElement(RichTextPlugin, {
|
|
137
|
+
contentEditable: /*#__PURE__*/React.createElement(ContentEditor, {
|
|
138
|
+
error: error,
|
|
139
|
+
inputHint: inputHint,
|
|
140
|
+
namespace: namespace,
|
|
141
|
+
previews: previews,
|
|
142
|
+
rows: rows,
|
|
143
|
+
warning: warning
|
|
144
|
+
}),
|
|
145
|
+
placeholder: /*#__PURE__*/React.createElement(Placeholder, {
|
|
146
|
+
namespace: namespace,
|
|
147
|
+
text: placeholder
|
|
148
|
+
}),
|
|
149
|
+
ErrorBoundary: LexicalErrorBoundary
|
|
150
|
+
}), /*#__PURE__*/React.createElement(ListPlugin, null), /*#__PURE__*/React.createElement(HistoryPlugin, null), /*#__PURE__*/React.createElement(MarkdownShortcutPlugin, null), /*#__PURE__*/React.createElement(OnChangePlugin, {
|
|
151
|
+
onChange: handleChange
|
|
152
|
+
}), /*#__PURE__*/React.createElement(LinkPlugin, {
|
|
153
|
+
validateUrl: validateUrl
|
|
154
|
+
}), /*#__PURE__*/React.createElement(ClickableLinkPlugin, {
|
|
155
|
+
newTab: true
|
|
156
|
+
}), /*#__PURE__*/React.createElement(AutoLinkerPlugin, null)), !readOnly && /*#__PURE__*/React.createElement(ToolbarPlugin, toolbarProps), /*#__PURE__*/React.createElement(LinkMonitorPlugin, null)), characterLimit > 0 && !readOnly && /*#__PURE__*/React.createElement(CharacterCounterPlugin, {
|
|
157
|
+
maxChars: characterLimit,
|
|
158
|
+
namespace: namespace
|
|
159
|
+
}))));
|
|
160
|
+
};
|
|
500
161
|
export default TextEditor;
|