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
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "default", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _onChange.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _onChange = _interopRequireDefault(require("./on-change.plugin"));
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _LexicalComposerContext = require("@lexical/react/LexicalComposerContext");
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
/**
|
|
10
|
+
* This plugin listens to changes in the editor and calls the `onChange` prop with the new editor state.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const OnChangePlugin = props => {
|
|
14
|
+
// Get the editor instance
|
|
15
|
+
const [editor] = (0, _LexicalComposerContext.useLexicalComposerContext)();
|
|
16
|
+
const {
|
|
17
|
+
onChange
|
|
18
|
+
} = props;
|
|
19
|
+
|
|
20
|
+
// Register an update listener to call the `onChange` prop
|
|
21
|
+
(0, _react.useEffect)(() => {
|
|
22
|
+
return editor.registerUpdateListener(({
|
|
23
|
+
editorState
|
|
24
|
+
}) => {
|
|
25
|
+
const isEditable = editor.isEditable();
|
|
26
|
+
/* istanbul ignore else */
|
|
27
|
+
if (isEditable) onChange(editorState);
|
|
28
|
+
});
|
|
29
|
+
}, [editor, onChange]);
|
|
30
|
+
return null;
|
|
31
|
+
};
|
|
32
|
+
var _default = exports.default = OnChangePlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./placeholder.component";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "default", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _placeholder.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _placeholder = _interopRequireDefault(require("./placeholder.component"));
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
package/lib/components/text-editor/__internal__/plugins/Placeholder/placeholder.component.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The placeholder component does not reside in the editor in a traditional sense, but is instead rendered
|
|
3
|
+
* in a separate component which is then styled to appear as if it is part of the editor. This is by design
|
|
4
|
+
* in the Lexical project to allow for greater flexibility in the design of the editor (apparently).
|
|
5
|
+
*/
|
|
6
|
+
import React from "react";
|
|
7
|
+
interface PlaceholderProps {
|
|
8
|
+
/** The namespace of the editor that this placeholder belongs to */
|
|
9
|
+
namespace: string;
|
|
10
|
+
/** The text to display in the placeholder */
|
|
11
|
+
text: string | undefined;
|
|
12
|
+
}
|
|
13
|
+
declare const Placeholder: ({ namespace, text }: PlaceholderProps) => React.JSX.Element;
|
|
14
|
+
export default Placeholder;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _placeholder = _interopRequireDefault(require("./placeholder.style"));
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
/**
|
|
12
|
+
* The placeholder component does not reside in the editor in a traditional sense, but is instead rendered
|
|
13
|
+
* in a separate component which is then styled to appear as if it is part of the editor. This is by design
|
|
14
|
+
* in the Lexical project to allow for greater flexibility in the design of the editor (apparently).
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const Placeholder = ({
|
|
18
|
+
namespace,
|
|
19
|
+
text = ""
|
|
20
|
+
}) => {
|
|
21
|
+
return /*#__PURE__*/_react.default.createElement(_placeholder.default, {
|
|
22
|
+
"data-role": `${namespace}-placeholder`
|
|
23
|
+
}, text);
|
|
24
|
+
};
|
|
25
|
+
var _default = exports.default = Placeholder;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
const StyledPlaceholder = _styledComponents.default.div`
|
|
10
|
+
position: absolute;
|
|
11
|
+
top: 16px;
|
|
12
|
+
color: var(--colorsUtilityYin055);
|
|
13
|
+
left: 10px;
|
|
14
|
+
`;
|
|
15
|
+
var _default = exports.default = StyledPlaceholder;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _LexicalComposerContext = require("@lexical/react/LexicalComposerContext");
|
|
8
|
+
var _lexical = require("lexical");
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
var _toolbar = require("../toolbar.style");
|
|
12
|
+
var _constants = require("../../../constants");
|
|
13
|
+
var _useLocale = _interopRequireDefault(require("../../../../../../hooks/__internal__/useLocale"));
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
+
// The `BoldButton` component is a button that applies bold formatting to the selected text in the editor.
|
|
16
|
+
const BoldButton = ({
|
|
17
|
+
isActive,
|
|
18
|
+
namespace
|
|
19
|
+
}) => {
|
|
20
|
+
// Get the locale to enable translations
|
|
21
|
+
const locale = (0, _useLocale.default)();
|
|
22
|
+
// Get the editor instance
|
|
23
|
+
const [editor] = (0, _LexicalComposerContext.useLexicalComposerContext)();
|
|
24
|
+
|
|
25
|
+
// When the button is clicked, dispatch the `FORMAT_TEXT_COMMAND` with the `Bold` action
|
|
26
|
+
const handleClick = () => {
|
|
27
|
+
const isEditable = editor.isEditable();
|
|
28
|
+
|
|
29
|
+
/* istanbul ignore else */
|
|
30
|
+
if (isEditable) {
|
|
31
|
+
// Focus the editor before dispatching the command
|
|
32
|
+
editor.focus();
|
|
33
|
+
editor.dispatchCommand(_lexical.FORMAT_TEXT_COMMAND, _constants.TextEditorActionTypes.Bold);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
return /*#__PURE__*/_react.default.createElement(_toolbar.FormattingButton, {
|
|
37
|
+
size: "small",
|
|
38
|
+
"aria-label": locale.textEditor.boldAria(),
|
|
39
|
+
onClick: () => handleClick(),
|
|
40
|
+
iconType: "bold",
|
|
41
|
+
buttonType: isActive ? "primary" : "tertiary",
|
|
42
|
+
isActive: isActive,
|
|
43
|
+
"aria-pressed": isActive,
|
|
44
|
+
"data-role": `${namespace}-bold-button`,
|
|
45
|
+
tabIndex: 0
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
var _default = exports.default = BoldButton;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "BoldButton", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _bold.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "ItalicButton", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _italic.default;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "ListControls", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _list.default;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "SaveButton", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _save.default;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
var _bold = _interopRequireDefault(require("./bold.component"));
|
|
31
|
+
var _italic = _interopRequireDefault(require("./italic.component"));
|
|
32
|
+
var _list = _interopRequireDefault(require("./list.component"));
|
|
33
|
+
var _save = _interopRequireDefault(require("./save.component"));
|
|
34
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _LexicalComposerContext = require("@lexical/react/LexicalComposerContext");
|
|
8
|
+
var _lexical = require("lexical");
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
var _toolbar = require("../toolbar.style");
|
|
12
|
+
var _constants = require("../../../constants");
|
|
13
|
+
var _useLocale = _interopRequireDefault(require("../../../../../../hooks/__internal__/useLocale"));
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
+
// The `ItalicButton` component is a button that applies italic formatting to the selected text in the editor.
|
|
16
|
+
const ItalicButton = ({
|
|
17
|
+
isActive,
|
|
18
|
+
namespace
|
|
19
|
+
}) => {
|
|
20
|
+
// Get the editor instance
|
|
21
|
+
const [editor] = (0, _LexicalComposerContext.useLexicalComposerContext)();
|
|
22
|
+
// Get the locale to enable translations
|
|
23
|
+
const locale = (0, _useLocale.default)();
|
|
24
|
+
|
|
25
|
+
// When the button is clicked, dispatch the `FORMAT_TEXT_COMMAND` with the `Italic` action
|
|
26
|
+
const handleClick = () => {
|
|
27
|
+
const isEditable = editor.isEditable();
|
|
28
|
+
|
|
29
|
+
/* istanbul ignore else */
|
|
30
|
+
if (isEditable)
|
|
31
|
+
// Focus the editor before dispatching the command
|
|
32
|
+
editor.focus();
|
|
33
|
+
editor.dispatchCommand(_lexical.FORMAT_TEXT_COMMAND, _constants.TextEditorActionTypes.Italic);
|
|
34
|
+
};
|
|
35
|
+
return /*#__PURE__*/_react.default.createElement(_toolbar.FormattingButton, {
|
|
36
|
+
size: "small",
|
|
37
|
+
"aria-label": locale.textEditor.italicAria(),
|
|
38
|
+
onClick: () => handleClick(),
|
|
39
|
+
iconType: "italic",
|
|
40
|
+
buttonType: isActive ? "primary" : "tertiary",
|
|
41
|
+
isActive: isActive,
|
|
42
|
+
"aria-pressed": isActive,
|
|
43
|
+
"data-role": `${namespace}-italic-button`,
|
|
44
|
+
tabIndex: -1
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
var _default = exports.default = ItalicButton;
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _list = require("@lexical/list");
|
|
8
|
+
var _LexicalComposerContext = require("@lexical/react/LexicalComposerContext");
|
|
9
|
+
var _utils = require("@lexical/utils");
|
|
10
|
+
var _lexical = require("lexical");
|
|
11
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
+
var _toolbar = require("../toolbar.style");
|
|
14
|
+
var _constants = require("../../../constants");
|
|
15
|
+
var _useLocale = _interopRequireDefault(require("../../../../../../hooks/__internal__/useLocale"));
|
|
16
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
18
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
19
|
+
// The `ListControls` component is a set of buttons that allow the user to insert ordered and unordered lists into the editor.
|
|
20
|
+
const ListControls = ({
|
|
21
|
+
namespace
|
|
22
|
+
}) => {
|
|
23
|
+
// Get the editor instance
|
|
24
|
+
const [editor] = (0, _LexicalComposerContext.useLexicalComposerContext)();
|
|
25
|
+
// Get the locale to enable translations
|
|
26
|
+
const locale = (0, _useLocale.default)();
|
|
27
|
+
// Set the initial state of the list buttons
|
|
28
|
+
const [isOLActive, setIsOLActive] = (0, _react.useState)(false);
|
|
29
|
+
const [isULActive, setIsULActive] = (0, _react.useState)(false);
|
|
30
|
+
|
|
31
|
+
// Register the commands for inserting and removing lists
|
|
32
|
+
editor.registerCommand(_list.INSERT_ORDERED_LIST_COMMAND, () => {
|
|
33
|
+
(0, _list.insertList)(editor, _constants.TextEditorActionTypes.OrderedList);
|
|
34
|
+
return true;
|
|
35
|
+
}, _lexical.COMMAND_PRIORITY_LOW);
|
|
36
|
+
editor.registerCommand(_list.INSERT_UNORDERED_LIST_COMMAND, () => {
|
|
37
|
+
(0, _list.insertList)(editor, _constants.TextEditorActionTypes.UnorderedList);
|
|
38
|
+
return true;
|
|
39
|
+
}, _lexical.COMMAND_PRIORITY_LOW);
|
|
40
|
+
editor.registerCommand(_list.REMOVE_LIST_COMMAND, () => {
|
|
41
|
+
(0, _list.removeList)(editor);
|
|
42
|
+
return true;
|
|
43
|
+
}, _lexical.COMMAND_PRIORITY_LOW);
|
|
44
|
+
|
|
45
|
+
// Recursive function to find the closest list item ancestor
|
|
46
|
+
const findListItemAncestor = node => {
|
|
47
|
+
let currentNode = node;
|
|
48
|
+
while (currentNode !== null) {
|
|
49
|
+
if (currentNode instanceof _list.ListItemNode) {
|
|
50
|
+
return currentNode;
|
|
51
|
+
}
|
|
52
|
+
currentNode = currentNode?.getParent();
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
};
|
|
56
|
+
const updateToolbar = (0, _react.useCallback)(() => {
|
|
57
|
+
const selection = (0, _lexical.$getSelection)();
|
|
58
|
+
if (!selection) {
|
|
59
|
+
setIsOLActive(false);
|
|
60
|
+
setIsULActive(false);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const selectedNodes = selection.getNodes();
|
|
64
|
+
|
|
65
|
+
/* istanbul ignore if */
|
|
66
|
+
if (selectedNodes.length === 0) {
|
|
67
|
+
setIsOLActive(false);
|
|
68
|
+
setIsULActive(false);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const listItemNode = selectedNodes.map(findListItemAncestor).find(node => node !== null);
|
|
72
|
+
if (!listItemNode) {
|
|
73
|
+
setIsOLActive(false);
|
|
74
|
+
setIsULActive(false);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
let listNode = listItemNode.getParent();
|
|
78
|
+
/* istanbul ignore next */
|
|
79
|
+
while (listNode && !(listNode instanceof _list.ListNode)) {
|
|
80
|
+
listNode = listNode.getParent();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/* istanbul ignore else */
|
|
84
|
+
if (listNode instanceof _list.ListNode) {
|
|
85
|
+
setIsOLActive(listNode.getListType() === "number");
|
|
86
|
+
setIsULActive(listNode.getListType() === "bullet");
|
|
87
|
+
} else {
|
|
88
|
+
setIsOLActive(false);
|
|
89
|
+
setIsULActive(false);
|
|
90
|
+
}
|
|
91
|
+
}, []);
|
|
92
|
+
|
|
93
|
+
// Register an update listener to update the toolbar when the editor state changes
|
|
94
|
+
(0, _react.useEffect)(() => {
|
|
95
|
+
return (0, _utils.mergeRegister)(editor.registerUpdateListener(({
|
|
96
|
+
editorState
|
|
97
|
+
}) => {
|
|
98
|
+
editorState.read(() => {
|
|
99
|
+
const isEditable = editor.isEditable();
|
|
100
|
+
/* istanbul ignore else */
|
|
101
|
+
if (isEditable) updateToolbar();
|
|
102
|
+
});
|
|
103
|
+
}));
|
|
104
|
+
}, [updateToolbar, editor]);
|
|
105
|
+
|
|
106
|
+
// When the ordered list button is clicked, insert or remove an ordered list
|
|
107
|
+
const handleOLClick = () => {
|
|
108
|
+
const isEditable = editor.isEditable();
|
|
109
|
+
/* istanbul ignore if */
|
|
110
|
+
if (!isEditable) return;
|
|
111
|
+
|
|
112
|
+
// Focus the editor before dispatching the command
|
|
113
|
+
editor.focus();
|
|
114
|
+
if (isOLActive) {
|
|
115
|
+
editor.dispatchCommand(_list.REMOVE_LIST_COMMAND, undefined);
|
|
116
|
+
setIsOLActive(false);
|
|
117
|
+
} else {
|
|
118
|
+
editor.dispatchCommand(_list.INSERT_ORDERED_LIST_COMMAND, undefined);
|
|
119
|
+
setIsOLActive(true);
|
|
120
|
+
}
|
|
121
|
+
// If the unordered list button is active, deactivate it
|
|
122
|
+
setIsULActive(false);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
// When the unordered list button is clicked, insert or remove an unordered list
|
|
126
|
+
const handleULClick = () => {
|
|
127
|
+
const isEditable = editor.isEditable();
|
|
128
|
+
/* istanbul ignore if */
|
|
129
|
+
if (!isEditable) return;
|
|
130
|
+
|
|
131
|
+
// Focus the editor before dispatching the command
|
|
132
|
+
editor.focus();
|
|
133
|
+
if (isULActive) {
|
|
134
|
+
editor.dispatchCommand(_list.REMOVE_LIST_COMMAND, undefined);
|
|
135
|
+
setIsULActive(false);
|
|
136
|
+
} else {
|
|
137
|
+
editor.dispatchCommand(_list.INSERT_UNORDERED_LIST_COMMAND, undefined);
|
|
138
|
+
setIsULActive(true);
|
|
139
|
+
}
|
|
140
|
+
// If the ordered list button is active, deactivate it
|
|
141
|
+
setIsOLActive(false);
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
// Split an array into three parts: before a subset, the subset, and after the subset
|
|
145
|
+
function splitArray(allEntries, subsetEntries) {
|
|
146
|
+
let startIndex = -1;
|
|
147
|
+
for (let i = 0; i <= allEntries.length - subsetEntries.length; i++) {
|
|
148
|
+
if (allEntries.slice(i, i + subsetEntries.length).toString() === subsetEntries.toString()) {
|
|
149
|
+
startIndex = i;
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/* istanbul ignore if */
|
|
155
|
+
if (startIndex === -1) {
|
|
156
|
+
throw new Error("Subset B not found in array A");
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// If the subset matches the full selection, return the original subset
|
|
160
|
+
if (startIndex === 0 && subsetEntries.length === allEntries.length) {
|
|
161
|
+
return {
|
|
162
|
+
beforeSubset: [],
|
|
163
|
+
subset: allEntries,
|
|
164
|
+
afterSubset: []
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Split A into three parts
|
|
169
|
+
const beforeSubset = allEntries.slice(0, startIndex);
|
|
170
|
+
const subset = allEntries.slice(startIndex, startIndex + subsetEntries.length);
|
|
171
|
+
const afterSubset = allEntries.slice(startIndex + subsetEntries.length);
|
|
172
|
+
return {
|
|
173
|
+
beforeSubset,
|
|
174
|
+
subset,
|
|
175
|
+
afterSubset
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/* istanbul ignore next */
|
|
180
|
+
const alignListTypes = (lists, listType) => {
|
|
181
|
+
lists.forEach(list => {
|
|
182
|
+
editor.update(() => {
|
|
183
|
+
list.setListType(listType);
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
/* istanbul ignore next */
|
|
189
|
+
const convertListType = newType => {
|
|
190
|
+
editor.update(() => {
|
|
191
|
+
// Get the current selection
|
|
192
|
+
const selection = (0, _lexical.$getSelection)();
|
|
193
|
+
// If the selection is not a range selection, return
|
|
194
|
+
if (!(0, _lexical.$isRangeSelection)(selection)) return;
|
|
195
|
+
|
|
196
|
+
// Get the anchor node
|
|
197
|
+
const anchorNode = selection.anchor.getNode();
|
|
198
|
+
|
|
199
|
+
// Find the parent list node
|
|
200
|
+
let currentList = anchorNode.getParent();
|
|
201
|
+
while (currentList && !(0, _list.$isListNode)(currentList)) {
|
|
202
|
+
currentList = currentList.getParent();
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// If the parent node is not a list node, return
|
|
206
|
+
if (!currentList) {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Determine how many lists have been selected
|
|
211
|
+
const numberOfListsSelected = selection.getNodes().map(node => {
|
|
212
|
+
return node.getType() === "list" ? node : null;
|
|
213
|
+
}).filter(node => node !== null);
|
|
214
|
+
|
|
215
|
+
// If more than one list is selected, just align the list types to use the selected type
|
|
216
|
+
if (numberOfListsSelected.length > 1) {
|
|
217
|
+
alignListTypes(numberOfListsSelected, newType);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
const preSelectionList = [];
|
|
221
|
+
const selectionList = [];
|
|
222
|
+
const postSelectionList = [];
|
|
223
|
+
|
|
224
|
+
// Get the keys of the nodes in the selection, filtering out the current list node (the parent)
|
|
225
|
+
const selectionKeys = selection.getNodes().map(node => {
|
|
226
|
+
let _p = node.getParent();
|
|
227
|
+
// If we're not in a list item directly, get the parent of the node
|
|
228
|
+
if (!(0, _list.$isListItemNode)(_p)) {
|
|
229
|
+
const nodeType = _p?.getType();
|
|
230
|
+
// If the node is a link or autolink, use the parent of the link node instead
|
|
231
|
+
if (nodeType && ["link", "autolink"].includes(nodeType)) {
|
|
232
|
+
_p = _p?.getParent() ?? null;
|
|
233
|
+
} else {
|
|
234
|
+
// This node is useless, return null
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
const _k = _p?.getKey();
|
|
239
|
+
if (_k !== currentList?.getKey()) return _k;
|
|
240
|
+
return null;
|
|
241
|
+
}).filter(key => key !== null && key !== undefined);
|
|
242
|
+
// Get the keys of the nodes in the current list node
|
|
243
|
+
const listKeys = currentList.getChildrenKeys();
|
|
244
|
+
|
|
245
|
+
// Remove duplicate keys from the selection
|
|
246
|
+
const uniqueSelectionKeys = Array.from(new Set(selectionKeys));
|
|
247
|
+
|
|
248
|
+
// Split the list keys into three parts: before the selection, the selection, and after the selection
|
|
249
|
+
const {
|
|
250
|
+
beforeSubset,
|
|
251
|
+
subset,
|
|
252
|
+
afterSubset
|
|
253
|
+
} = splitArray(listKeys, uniqueSelectionKeys);
|
|
254
|
+
|
|
255
|
+
// Get the nodes of the three parts
|
|
256
|
+
beforeSubset.forEach(key => {
|
|
257
|
+
const node = (0, _lexical.$getNodeByKey)(key);
|
|
258
|
+
if ((0, _list.$isListItemNode)(node)) preSelectionList.push(node);
|
|
259
|
+
});
|
|
260
|
+
subset.forEach(key => {
|
|
261
|
+
const node = (0, _lexical.$getNodeByKey)(key);
|
|
262
|
+
if ((0, _list.$isListItemNode)(node)) selectionList.push(node);
|
|
263
|
+
});
|
|
264
|
+
afterSubset.forEach(key => {
|
|
265
|
+
const node = (0, _lexical.$getNodeByKey)(key);
|
|
266
|
+
if ((0, _list.$isListItemNode)(node)) postSelectionList.push(node);
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
// Create new list nodes with the new list type
|
|
270
|
+
const originalListType = currentList.getListType();
|
|
271
|
+
const newPreNode = (0, _list.$createListNode)(originalListType);
|
|
272
|
+
const newSelectionNode = (0, _list.$createListNode)(newType);
|
|
273
|
+
const newPostNode = (0, _list.$createListNode)(originalListType);
|
|
274
|
+
newPreNode.append(...preSelectionList);
|
|
275
|
+
newSelectionNode.append(...selectionList);
|
|
276
|
+
newPostNode.append(...postSelectionList);
|
|
277
|
+
|
|
278
|
+
// Insert the new nodes before the current list node if they have children
|
|
279
|
+
if (newPreNode.getChildren().length > 0) {
|
|
280
|
+
currentList.insertBefore(newPreNode);
|
|
281
|
+
}
|
|
282
|
+
if (newSelectionNode.getChildren().length > 0) {
|
|
283
|
+
if (newPreNode.getChildren().length > 0) {
|
|
284
|
+
newPreNode.insertAfter(newSelectionNode);
|
|
285
|
+
} else {
|
|
286
|
+
currentList.insertBefore(newSelectionNode);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
if (newPostNode.getChildren().length > 0) {
|
|
290
|
+
if (newSelectionNode.getChildren().length > 0) {
|
|
291
|
+
newSelectionNode.insertAfter(newPostNode);
|
|
292
|
+
} else if (newPreNode.getChildren().length > 0) {
|
|
293
|
+
newPreNode.insertAfter(newPostNode);
|
|
294
|
+
} else {
|
|
295
|
+
currentList.insertBefore(newPostNode);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// Remove the current list node
|
|
300
|
+
currentList.remove();
|
|
301
|
+
});
|
|
302
|
+
};
|
|
303
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_toolbar.FormattingButton, {
|
|
304
|
+
size: "small",
|
|
305
|
+
"aria-label": locale.textEditor.unorderedListAria(),
|
|
306
|
+
onClick: () => isOLActive ? convertListType("bullet") : handleULClick(),
|
|
307
|
+
iconType: "bullet_list_dotted",
|
|
308
|
+
buttonType: isULActive ? "primary" : "tertiary",
|
|
309
|
+
isActive: isULActive,
|
|
310
|
+
"aria-pressed": isULActive,
|
|
311
|
+
"data-role": `${namespace}-unordered-list-button`,
|
|
312
|
+
tabIndex: -1
|
|
313
|
+
}), /*#__PURE__*/_react.default.createElement(_toolbar.FormattingButton, {
|
|
314
|
+
size: "small",
|
|
315
|
+
"aria-label": locale.textEditor.orderedListAria(),
|
|
316
|
+
onClick: () => isULActive ? convertListType("number") : handleOLClick(),
|
|
317
|
+
iconType: "bullet_list_numbers",
|
|
318
|
+
buttonType: isOLActive ? "primary" : "tertiary",
|
|
319
|
+
isActive: isOLActive,
|
|
320
|
+
"aria-pressed": isOLActive,
|
|
321
|
+
"data-role": `${namespace}-ordered-list-button`,
|
|
322
|
+
tabIndex: -1
|
|
323
|
+
}));
|
|
324
|
+
};
|
|
325
|
+
var _default = exports.default = ListControls;
|