@shelamkoff/rector 1.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/LICENSE +21 -0
- package/NOTICE +17 -0
- package/README.md +23 -0
- package/THIRD_PARTY_LICENSES.txt +298 -0
- package/dist/I18n.d.ts +1 -0
- package/dist/core/Block.d.ts +110 -0
- package/dist/core/Block.js +390 -0
- package/dist/core/BlockAnimator.d.ts +39 -0
- package/dist/core/BlockAnimator.js +106 -0
- package/dist/core/BlockManager.d.ts +163 -0
- package/dist/core/BlockManager.js +640 -0
- package/dist/core/BlockOperations.d.ts +67 -0
- package/dist/core/BlockOperations.js +238 -0
- package/dist/core/ChangeNotifier.d.ts +15 -0
- package/dist/core/ChangeNotifier.js +55 -0
- package/dist/core/CommandDispatcher.d.ts +52 -0
- package/dist/core/CommandDispatcher.js +208 -0
- package/dist/core/CrossBlockSelection.d.ts +30 -0
- package/dist/core/CrossBlockSelection.js +74 -0
- package/dist/core/Diagnostics.d.ts +23 -0
- package/dist/core/Diagnostics.js +62 -0
- package/dist/core/DocumentSchema.d.ts +29 -0
- package/dist/core/DocumentSchema.js +147 -0
- package/dist/core/DocumentSnapshotStore.d.ts +34 -0
- package/dist/core/DocumentSnapshotStore.js +153 -0
- package/dist/core/DragManager.d.ts +17 -0
- package/dist/core/DragManager.js +223 -0
- package/dist/core/EditorFacade.d.ts +154 -0
- package/dist/core/EditorFacade.js +361 -0
- package/dist/core/EditorHolderOwnership.d.ts +12 -0
- package/dist/core/EditorHolderOwnership.js +28 -0
- package/dist/core/I18n.d.ts +147 -0
- package/dist/core/I18n.js +296 -0
- package/dist/core/InlinePatternMatcher.d.ts +26 -0
- package/dist/core/InlinePatternMatcher.js +267 -0
- package/dist/core/InlinePluginRegistry.d.ts +55 -0
- package/dist/core/InlinePluginRegistry.js +128 -0
- package/dist/core/KeyboardManager.d.ts +17 -0
- package/dist/core/KeyboardManager.js +231 -0
- package/dist/core/LifecycleScope.d.ts +19 -0
- package/dist/core/LifecycleScope.js +41 -0
- package/dist/core/MouseSelectionManager.d.ts +30 -0
- package/dist/core/MouseSelectionManager.js +307 -0
- package/dist/core/PluginOwnership.d.ts +9 -0
- package/dist/core/PluginOwnership.js +40 -0
- package/dist/core/PopupManager.d.ts +50 -0
- package/dist/core/PopupManager.js +183 -0
- package/dist/core/PreservedBlockPlugin.d.ts +11 -0
- package/dist/core/PreservedBlockPlugin.js +42 -0
- package/dist/core/PublicEditorApi.d.ts +82 -0
- package/dist/core/PublicEditorApi.js +158 -0
- package/dist/core/SelectionManager.d.ts +50 -0
- package/dist/core/SelectionManager.js +205 -0
- package/dist/core/ShortcutRegistry.d.ts +29 -0
- package/dist/core/ShortcutRegistry.js +106 -0
- package/dist/core/SlashCommands.d.ts +34 -0
- package/dist/core/SlashCommands.js +483 -0
- package/dist/core/StyleInjector.d.ts +1 -0
- package/dist/core/StyleInjector.js +1 -0
- package/dist/core/Tooltip.d.ts +17 -0
- package/dist/core/Tooltip.js +60 -0
- package/dist/core/TriggerManager.d.ts +17 -0
- package/dist/core/TriggerManager.js +159 -0
- package/dist/core/TypeSelector.d.ts +31 -0
- package/dist/core/TypeSelector.js +464 -0
- package/dist/core/UndoManager.d.ts +72 -0
- package/dist/core/UndoManager.js +383 -0
- package/dist/core/block-settings-menu/BlockActions.d.ts +81 -0
- package/dist/core/block-settings-menu/BlockActions.js +233 -0
- package/dist/core/block-settings-menu/BlockSettingsMenu.d.ts +46 -0
- package/dist/core/block-settings-menu/BlockSettingsMenu.js +205 -0
- package/dist/core/block-settings-menu/MenuBuilder.d.ts +43 -0
- package/dist/core/block-settings-menu/MenuBuilder.js +203 -0
- package/dist/core/block-settings-menu/MenuPositioner.d.ts +22 -0
- package/dist/core/block-settings-menu/MenuPositioner.js +79 -0
- package/dist/core/clipboard/Clipboard.d.ts +47 -0
- package/dist/core/clipboard/Clipboard.js +653 -0
- package/dist/core/clipboard/CrossBlockEditor.d.ts +43 -0
- package/dist/core/clipboard/CrossBlockEditor.js +198 -0
- package/dist/core/clipboard/PasteRouter.d.ts +27 -0
- package/dist/core/clipboard/PasteRouter.js +86 -0
- package/dist/core/clipboard/pasteInsert.d.ts +35 -0
- package/dist/core/clipboard/pasteInsert.js +215 -0
- package/dist/core/clipboard/pasteUtils.d.ts +25 -0
- package/dist/core/clipboard/pasteUtils.js +98 -0
- package/dist/core/config.d.ts +77 -0
- package/dist/core/config.js +100 -0
- package/dist/core/constants.d.ts +23 -0
- package/dist/core/constants.js +30 -0
- package/dist/core/crossBlockConvert.d.ts +38 -0
- package/dist/core/crossBlockConvert.js +253 -0
- package/dist/core/dom.d.ts +35 -0
- package/dist/core/dom.js +65 -0
- package/dist/core/editorEvents.d.ts +89 -0
- package/dist/core/editorEvents.js +60 -0
- package/dist/core/hydrateInlinePlugins.d.ts +9 -0
- package/dist/core/hydrateInlinePlugins.js +36 -0
- package/dist/core/icons.d.ts +10 -0
- package/dist/core/icons.js +21 -0
- package/dist/core/index.d.ts +59 -0
- package/dist/core/index.js +703 -0
- package/dist/core/inline-toolbar/ActionsPanel.d.ts +61 -0
- package/dist/core/inline-toolbar/ActionsPanel.js +132 -0
- package/dist/core/inline-toolbar/InlinePositioner.d.ts +20 -0
- package/dist/core/inline-toolbar/InlinePositioner.js +63 -0
- package/dist/core/inline-toolbar/InlineToolbar.d.ts +45 -0
- package/dist/core/inline-toolbar/InlineToolbar.js +456 -0
- package/dist/core/inline-toolbar/PluginControlsSlot.d.ts +52 -0
- package/dist/core/inline-toolbar/PluginControlsSlot.js +118 -0
- package/dist/core/inline-toolbar/SelectionTracker.d.ts +63 -0
- package/dist/core/inline-toolbar/SelectionTracker.js +173 -0
- package/dist/core/inlinePluginInsert.d.ts +13 -0
- package/dist/core/inlinePluginInsert.js +56 -0
- package/dist/core/locale/en.d.ts +35 -0
- package/dist/core/locale/en.js +37 -0
- package/dist/core/locale/ru.d.ts +35 -0
- package/dist/core/locale/ru.js +37 -0
- package/dist/core/menuKeyboardNav.d.ts +15 -0
- package/dist/core/menuKeyboardNav.js +52 -0
- package/dist/core/sanitize.d.ts +2 -0
- package/dist/core/sanitize.js +6 -0
- package/dist/core/splitConvert.d.ts +46 -0
- package/dist/core/splitConvert.js +190 -0
- package/dist/core/textOffset.d.ts +46 -0
- package/dist/core/textOffset.js +180 -0
- package/dist/core/themes/dark.css +30 -0
- package/dist/core/themes/light.css +33 -0
- package/dist/core/themes/variables.css +1170 -0
- package/dist/core/toolbar/OffcanvasRoot.d.ts +37 -0
- package/dist/core/toolbar/OffcanvasRoot.js +127 -0
- package/dist/core/toolbar/Toolbar.d.ts +70 -0
- package/dist/core/toolbar/Toolbar.js +432 -0
- package/dist/core/toolbar/ToolbarPositioner.d.ts +60 -0
- package/dist/core/toolbar/ToolbarPositioner.js +188 -0
- package/dist/core/toolbar/ToolboxBuilder.d.ts +44 -0
- package/dist/core/toolbar/ToolboxBuilder.js +260 -0
- package/dist/core/types.d.ts +747 -0
- package/dist/core/uid.d.ts +6 -0
- package/dist/core/uid.js +29 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/inline-plugins/README.md +35 -0
- package/dist/inline-plugins/README.ru.md +35 -0
- package/dist/inline-plugins/color/README.md +61 -0
- package/dist/inline-plugins/color/README.ru.md +61 -0
- package/dist/inline-plugins/color.d.ts +8 -0
- package/dist/inline-plugins/color.js +184 -0
- package/dist/inline-plugins/locale/en.d.ts +7 -0
- package/dist/inline-plugins/locale/en.js +6 -0
- package/dist/inline-plugins/locale/ru.d.ts +7 -0
- package/dist/inline-plugins/locale/ru.js +6 -0
- package/dist/inline-plugins/mention/README.md +97 -0
- package/dist/inline-plugins/mention/README.ru.md +97 -0
- package/dist/inline-plugins/mention/index.d.ts +110 -0
- package/dist/inline-plugins/mention/index.js +1897 -0
- package/dist/inline-plugins/mention/styles.css +183 -0
- package/dist/inline-plugins/mention/widget.d.ts +16 -0
- package/dist/inline-plugins/mention/widget.js +75 -0
- package/dist/inline-tools/align.d.ts +14 -0
- package/dist/inline-tools/align.js +120 -0
- package/dist/inline-tools/bold.d.ts +8 -0
- package/dist/inline-tools/bold.js +12 -0
- package/dist/inline-tools/caseTransform.d.ts +8 -0
- package/dist/inline-tools/caseTransform.js +87 -0
- package/dist/inline-tools/clearFormatting.d.ts +8 -0
- package/dist/inline-tools/clearFormatting.js +74 -0
- package/dist/inline-tools/code.d.ts +8 -0
- package/dist/inline-tools/code.js +12 -0
- package/dist/inline-tools/colorPicker.d.ts +7 -0
- package/dist/inline-tools/colorPicker.js +271 -0
- package/dist/inline-tools/defaults.d.ts +10 -0
- package/dist/inline-tools/defaults.js +57 -0
- package/dist/inline-tools/fontSize.d.ts +7 -0
- package/dist/inline-tools/fontSize.js +524 -0
- package/dist/inline-tools/italic.d.ts +8 -0
- package/dist/inline-tools/italic.js +12 -0
- package/dist/inline-tools/link.d.ts +12 -0
- package/dist/inline-tools/link.js +251 -0
- package/dist/inline-tools/marker.d.ts +8 -0
- package/dist/inline-tools/marker.js +12 -0
- package/dist/inline-tools/scriptTool.d.ts +11 -0
- package/dist/inline-tools/scriptTool.js +149 -0
- package/dist/inline-tools/strikethrough.d.ts +8 -0
- package/dist/inline-tools/strikethrough.js +12 -0
- package/dist/inline-tools/utils.d.ts +220 -0
- package/dist/inline-tools/utils.js +992 -0
- package/dist/locale/en.d.ts +311 -0
- package/dist/locale/en.js +52 -0
- package/dist/locale/ru.d.ts +315 -0
- package/dist/locale/ru.js +52 -0
- package/dist/plugins/BlockPluginAbstract.d.ts +82 -0
- package/dist/plugins/BlockPluginAbstract.js +111 -0
- package/dist/plugins/README.md +44 -0
- package/dist/plugins/README.ru.md +40 -0
- package/dist/plugins/async.d.ts +35 -0
- package/dist/plugins/async.js +79 -0
- package/dist/plugins/attaches/README.md +86 -0
- package/dist/plugins/attaches/README.ru.md +87 -0
- package/dist/plugins/attaches/attaches.css +374 -0
- package/dist/plugins/attaches/index.d.ts +133 -0
- package/dist/plugins/attaches/index.js +921 -0
- package/dist/plugins/attaches/locale/en.d.ts +23 -0
- package/dist/plugins/attaches/locale/en.js +19 -0
- package/dist/plugins/attaches/locale/keys.d.ts +5 -0
- package/dist/plugins/attaches/locale/ru.d.ts +25 -0
- package/dist/plugins/attaches/locale/ru.js +19 -0
- package/dist/plugins/carousel/README.md +108 -0
- package/dist/plugins/carousel/README.ru.md +109 -0
- package/dist/plugins/carousel/carousel.css +198 -0
- package/dist/plugins/carousel/icons.d.ts +12 -0
- package/dist/plugins/carousel/icons.js +13 -0
- package/dist/plugins/carousel/index.d.ts +137 -0
- package/dist/plugins/carousel/index.js +859 -0
- package/dist/plugins/carousel/locale/en.d.ts +41 -0
- package/dist/plugins/carousel/locale/en.js +40 -0
- package/dist/plugins/carousel/locale/keys.d.ts +2 -0
- package/dist/plugins/carousel/locale/ru.d.ts +41 -0
- package/dist/plugins/carousel/locale/ru.js +40 -0
- package/dist/plugins/carousel/state.d.ts +29 -0
- package/dist/plugins/carousel/state.js +42 -0
- package/dist/plugins/checklist/README.md +54 -0
- package/dist/plugins/checklist/README.ru.md +55 -0
- package/dist/plugins/checklist/checklist.css +80 -0
- package/dist/plugins/checklist/index.d.ts +75 -0
- package/dist/plugins/checklist/index.js +407 -0
- package/dist/plugins/checklist/locale/en.d.ts +5 -0
- package/dist/plugins/checklist/locale/en.js +4 -0
- package/dist/plugins/checklist/locale/keys.d.ts +5 -0
- package/dist/plugins/checklist/locale/ru.d.ts +5 -0
- package/dist/plugins/checklist/locale/ru.js +4 -0
- package/dist/plugins/checklist/mapTextFields.d.ts +1 -0
- package/dist/plugins/checklist/mapTextFields.js +1 -0
- package/dist/plugins/code/README.md +59 -0
- package/dist/plugins/code/README.ru.md +60 -0
- package/dist/plugins/code/code.css +360 -0
- package/dist/plugins/code/index.d.ts +109 -0
- package/dist/plugins/code/index.js +1012 -0
- package/dist/plugins/code/locale/en.d.ts +11 -0
- package/dist/plugins/code/locale/en.js +10 -0
- package/dist/plugins/code/locale/keys.d.ts +5 -0
- package/dist/plugins/code/locale/ru.d.ts +11 -0
- package/dist/plugins/code/locale/ru.js +10 -0
- package/dist/plugins/columns/README.md +55 -0
- package/dist/plugins/columns/README.ru.md +56 -0
- package/dist/plugins/columns/columns.css +103 -0
- package/dist/plugins/columns/index.d.ts +58 -0
- package/dist/plugins/columns/index.js +236 -0
- package/dist/plugins/columns/locale/en.d.ts +6 -0
- package/dist/plugins/columns/locale/en.js +5 -0
- package/dist/plugins/columns/locale/keys.d.ts +5 -0
- package/dist/plugins/columns/locale/ru.d.ts +6 -0
- package/dist/plugins/columns/locale/ru.js +5 -0
- package/dist/plugins/delimiter/README.md +48 -0
- package/dist/plugins/delimiter/README.ru.md +49 -0
- package/dist/plugins/delimiter/delimiter.css +22 -0
- package/dist/plugins/delimiter/index.d.ts +38 -0
- package/dist/plugins/delimiter/index.js +69 -0
- package/dist/plugins/delimiter/locale/en.d.ts +4 -0
- package/dist/plugins/delimiter/locale/en.js +3 -0
- package/dist/plugins/delimiter/locale/keys.d.ts +5 -0
- package/dist/plugins/delimiter/locale/ru.d.ts +4 -0
- package/dist/plugins/delimiter/locale/ru.js +3 -0
- package/dist/plugins/embed/README.md +81 -0
- package/dist/plugins/embed/README.ru.md +82 -0
- package/dist/plugins/embed/embed.css +558 -0
- package/dist/plugins/embed/index.d.ts +271 -0
- package/dist/plugins/embed/index.js +967 -0
- package/dist/plugins/embed/locale/en.d.ts +20 -0
- package/dist/plugins/embed/locale/en.js +19 -0
- package/dist/plugins/embed/locale/keys.d.ts +5 -0
- package/dist/plugins/embed/locale/ru.d.ts +20 -0
- package/dist/plugins/embed/locale/ru.js +19 -0
- package/dist/plugins/embed/player.d.ts +1 -0
- package/dist/plugins/embed/player.js +1 -0
- package/dist/plugins/gallery/README.md +92 -0
- package/dist/plugins/gallery/README.ru.md +93 -0
- package/dist/plugins/gallery/css.d.ts +52 -0
- package/dist/plugins/gallery/css.js +67 -0
- package/dist/plugins/gallery/gallery.css +860 -0
- package/dist/plugins/gallery/icons.d.ts +13 -0
- package/dist/plugins/gallery/icons.js +45 -0
- package/dist/plugins/gallery/index.d.ts +126 -0
- package/dist/plugins/gallery/index.js +355 -0
- package/dist/plugins/gallery/layout.d.ts +35 -0
- package/dist/plugins/gallery/layout.js +79 -0
- package/dist/plugins/gallery/locale/en.d.ts +36 -0
- package/dist/plugins/gallery/locale/en.js +35 -0
- package/dist/plugins/gallery/locale/keys.d.ts +5 -0
- package/dist/plugins/gallery/locale/ru.d.ts +36 -0
- package/dist/plugins/gallery/locale/ru.js +35 -0
- package/dist/plugins/gallery/settings.d.ts +25 -0
- package/dist/plugins/gallery/settings.js +199 -0
- package/dist/plugins/gallery/slot.d.ts +73 -0
- package/dist/plugins/gallery/slot.js +260 -0
- package/dist/plugins/gallery/state.d.ts +67 -0
- package/dist/plugins/gallery/state.js +133 -0
- package/dist/plugins/gallery/styles.d.ts +10 -0
- package/dist/plugins/gallery/styles.js +24 -0
- package/dist/plugins/gallery/uploader.d.ts +31 -0
- package/dist/plugins/gallery/uploader.js +111 -0
- package/dist/plugins/gallery/view-empty.d.ts +41 -0
- package/dist/plugins/gallery/view-empty.js +56 -0
- package/dist/plugins/gallery/view-filled.d.ts +55 -0
- package/dist/plugins/gallery/view-filled.js +353 -0
- package/dist/plugins/heading/HeadingLevelSelect.d.ts +16 -0
- package/dist/plugins/heading/HeadingLevelSelect.js +183 -0
- package/dist/plugins/heading/README.md +58 -0
- package/dist/plugins/heading/README.ru.md +59 -0
- package/dist/plugins/heading/heading.css +76 -0
- package/dist/plugins/heading/index.d.ts +124 -0
- package/dist/plugins/heading/index.js +273 -0
- package/dist/plugins/heading/locale/en.d.ts +11 -0
- package/dist/plugins/heading/locale/en.js +10 -0
- package/dist/plugins/heading/locale/keys.d.ts +5 -0
- package/dist/plugins/heading/locale/ru.d.ts +11 -0
- package/dist/plugins/heading/locale/ru.js +10 -0
- package/dist/plugins/heading/mapTextFields.d.ts +1 -0
- package/dist/plugins/heading/mapTextFields.js +1 -0
- package/dist/plugins/image/README.md +93 -0
- package/dist/plugins/image/README.ru.md +94 -0
- package/dist/plugins/image/css.d.ts +47 -0
- package/dist/plugins/image/css.js +47 -0
- package/dist/plugins/image/icons.d.ts +13 -0
- package/dist/plugins/image/icons.js +26 -0
- package/dist/plugins/image/image.css +559 -0
- package/dist/plugins/image/index.d.ts +129 -0
- package/dist/plugins/image/index.js +346 -0
- package/dist/plugins/image/locale/en.d.ts +39 -0
- package/dist/plugins/image/locale/en.js +38 -0
- package/dist/plugins/image/locale/keys.d.ts +5 -0
- package/dist/plugins/image/locale/ru.d.ts +39 -0
- package/dist/plugins/image/locale/ru.js +38 -0
- package/dist/plugins/image/settings.d.ts +23 -0
- package/dist/plugins/image/settings.js +347 -0
- package/dist/plugins/image/state.d.ts +86 -0
- package/dist/plugins/image/state.js +151 -0
- package/dist/plugins/image/styles.d.ts +21 -0
- package/dist/plugins/image/styles.js +58 -0
- package/dist/plugins/image/uploader.d.ts +31 -0
- package/dist/plugins/image/uploader.js +92 -0
- package/dist/plugins/image/view-empty.d.ts +44 -0
- package/dist/plugins/image/view-empty.js +61 -0
- package/dist/plugins/image/view-filled.d.ts +49 -0
- package/dist/plugins/image/view-filled.js +282 -0
- package/dist/plugins/index.d.ts +21 -0
- package/dist/plugins/index.js +22 -0
- package/dist/plugins/link-preview/README.md +69 -0
- package/dist/plugins/link-preview/README.ru.md +70 -0
- package/dist/plugins/link-preview/index.d.ts +169 -0
- package/dist/plugins/link-preview/index.js +698 -0
- package/dist/plugins/link-preview/link-preview.css +254 -0
- package/dist/plugins/link-preview/locale/en.d.ts +14 -0
- package/dist/plugins/link-preview/locale/en.js +13 -0
- package/dist/plugins/link-preview/locale/keys.d.ts +5 -0
- package/dist/plugins/link-preview/locale/ru.d.ts +14 -0
- package/dist/plugins/link-preview/locale/ru.js +13 -0
- package/dist/plugins/list/README.md +59 -0
- package/dist/plugins/list/README.ru.md +60 -0
- package/dist/plugins/list/index.d.ts +134 -0
- package/dist/plugins/list/index.js +566 -0
- package/dist/plugins/list/list.css +57 -0
- package/dist/plugins/list/locale/en.d.ts +5 -0
- package/dist/plugins/list/locale/en.js +4 -0
- package/dist/plugins/list/locale/keys.d.ts +5 -0
- package/dist/plugins/list/locale/ru.d.ts +5 -0
- package/dist/plugins/list/locale/ru.js +4 -0
- package/dist/plugins/list/mapTextFields.d.ts +1 -0
- package/dist/plugins/list/mapTextFields.js +1 -0
- package/dist/plugins/paragraph/README.md +57 -0
- package/dist/plugins/paragraph/README.ru.md +58 -0
- package/dist/plugins/paragraph/index.d.ts +112 -0
- package/dist/plugins/paragraph/index.js +158 -0
- package/dist/plugins/paragraph/locale/en.d.ts +5 -0
- package/dist/plugins/paragraph/locale/en.js +4 -0
- package/dist/plugins/paragraph/locale/keys.d.ts +5 -0
- package/dist/plugins/paragraph/locale/ru.d.ts +5 -0
- package/dist/plugins/paragraph/locale/ru.js +4 -0
- package/dist/plugins/paragraph/mapTextFields.d.ts +1 -0
- package/dist/plugins/paragraph/mapTextFields.js +1 -0
- package/dist/plugins/paragraph/paragraph.css +56 -0
- package/dist/plugins/person/README.md +72 -0
- package/dist/plugins/person/README.ru.md +73 -0
- package/dist/plugins/person/index.d.ts +189 -0
- package/dist/plugins/person/index.js +777 -0
- package/dist/plugins/person/locale/en.d.ts +18 -0
- package/dist/plugins/person/locale/en.js +17 -0
- package/dist/plugins/person/locale/keys.d.ts +5 -0
- package/dist/plugins/person/locale/ru.d.ts +18 -0
- package/dist/plugins/person/locale/ru.js +17 -0
- package/dist/plugins/person/person.css +431 -0
- package/dist/plugins/person/socialResolver.d.ts +18 -0
- package/dist/plugins/person/socialResolver.js +69 -0
- package/dist/plugins/poll/README.md +96 -0
- package/dist/plugins/poll/README.ru.md +97 -0
- package/dist/plugins/poll/index.d.ts +134 -0
- package/dist/plugins/poll/index.js +825 -0
- package/dist/plugins/poll/locale/en.d.ts +23 -0
- package/dist/plugins/poll/locale/en.js +22 -0
- package/dist/plugins/poll/locale/keys.d.ts +5 -0
- package/dist/plugins/poll/locale/ru.d.ts +23 -0
- package/dist/plugins/poll/locale/ru.js +22 -0
- package/dist/plugins/poll/poll.css +400 -0
- package/dist/plugins/quote/README.md +55 -0
- package/dist/plugins/quote/README.ru.md +56 -0
- package/dist/plugins/quote/index.d.ts +81 -0
- package/dist/plugins/quote/index.js +165 -0
- package/dist/plugins/quote/locale/en.d.ts +6 -0
- package/dist/plugins/quote/locale/en.js +5 -0
- package/dist/plugins/quote/locale/keys.d.ts +5 -0
- package/dist/plugins/quote/locale/ru.d.ts +6 -0
- package/dist/plugins/quote/locale/ru.js +5 -0
- package/dist/plugins/quote/mapTextFields.d.ts +1 -0
- package/dist/plugins/quote/mapTextFields.js +1 -0
- package/dist/plugins/quote/quote.css +72 -0
- package/dist/plugins/raw/README.md +54 -0
- package/dist/plugins/raw/README.ru.md +55 -0
- package/dist/plugins/raw/index.d.ts +62 -0
- package/dist/plugins/raw/index.js +227 -0
- package/dist/plugins/raw/locale/en.d.ts +7 -0
- package/dist/plugins/raw/locale/en.js +6 -0
- package/dist/plugins/raw/locale/keys.d.ts +5 -0
- package/dist/plugins/raw/locale/ru.d.ts +7 -0
- package/dist/plugins/raw/locale/ru.js +6 -0
- package/dist/plugins/raw/raw.css +127 -0
- package/dist/plugins/shared/actionBar.d.ts +19 -0
- package/dist/plugins/shared/actionBar.js +35 -0
- package/dist/plugins/shared/dropzone.d.ts +106 -0
- package/dist/plugins/shared/dropzone.js +107 -0
- package/dist/plugins/shared/fileInput.d.ts +44 -0
- package/dist/plugins/shared/fileInput.js +62 -0
- package/dist/plugins/spoiler/README.md +55 -0
- package/dist/plugins/spoiler/README.ru.md +56 -0
- package/dist/plugins/spoiler/index.d.ts +61 -0
- package/dist/plugins/spoiler/index.js +169 -0
- package/dist/plugins/spoiler/locale/en.d.ts +7 -0
- package/dist/plugins/spoiler/locale/en.js +6 -0
- package/dist/plugins/spoiler/locale/keys.d.ts +5 -0
- package/dist/plugins/spoiler/locale/ru.d.ts +7 -0
- package/dist/plugins/spoiler/locale/ru.js +6 -0
- package/dist/plugins/spoiler/spoiler.css +101 -0
- package/dist/plugins/table/README.md +55 -0
- package/dist/plugins/table/README.ru.md +56 -0
- package/dist/plugins/table/index.d.ts +85 -0
- package/dist/plugins/table/index.js +399 -0
- package/dist/plugins/table/locale/en.d.ts +9 -0
- package/dist/plugins/table/locale/en.js +8 -0
- package/dist/plugins/table/locale/keys.d.ts +5 -0
- package/dist/plugins/table/locale/ru.d.ts +9 -0
- package/dist/plugins/table/locale/ru.js +8 -0
- package/dist/plugins/table/table.css +58 -0
- package/dist/plugins/toggle/README.md +56 -0
- package/dist/plugins/toggle/README.ru.md +57 -0
- package/dist/plugins/toggle/index.d.ts +69 -0
- package/dist/plugins/toggle/index.js +191 -0
- package/dist/plugins/toggle/locale/en.d.ts +7 -0
- package/dist/plugins/toggle/locale/en.js +6 -0
- package/dist/plugins/toggle/locale/keys.d.ts +5 -0
- package/dist/plugins/toggle/locale/ru.d.ts +7 -0
- package/dist/plugins/toggle/locale/ru.js +6 -0
- package/dist/plugins/toggle/toggle.css +101 -0
- package/dist/plugins/warning/README.md +55 -0
- package/dist/plugins/warning/README.ru.md +56 -0
- package/dist/plugins/warning/index.d.ts +66 -0
- package/dist/plugins/warning/index.js +167 -0
- package/dist/plugins/warning/locale/en.d.ts +6 -0
- package/dist/plugins/warning/locale/en.js +5 -0
- package/dist/plugins/warning/locale/keys.d.ts +5 -0
- package/dist/plugins/warning/locale/ru.d.ts +6 -0
- package/dist/plugins/warning/locale/ru.js +5 -0
- package/dist/plugins/warning/warning.css +63 -0
- package/dist/renderer/async.d.ts +1 -0
- package/dist/renderer/async.js +7 -0
- package/dist/renderer/errors.d.ts +27 -0
- package/dist/renderer/errors.js +48 -0
- package/dist/renderer/index.d.ts +82 -0
- package/dist/renderer/index.js +413 -0
- package/dist/renderer/inline.d.ts +5 -0
- package/dist/renderer/inline.js +61 -0
- package/dist/renderer/locale/en.d.ts +35 -0
- package/dist/renderer/locale/en.js +29 -0
- package/dist/renderer/locale/ru.d.ts +37 -0
- package/dist/renderer/locale/ru.js +29 -0
- package/dist/renderer/renderers/README.md +7 -0
- package/dist/renderer/renderers/README.ru.md +5 -0
- package/dist/renderer/renderers/async.d.ts +51 -0
- package/dist/renderer/renderers/async.js +99 -0
- package/dist/renderer/renderers/attaches/README.md +48 -0
- package/dist/renderer/renderers/attaches/README.ru.md +48 -0
- package/dist/renderer/renderers/attaches/index.d.ts +37 -0
- package/dist/renderer/renderers/attaches/index.js +451 -0
- package/dist/renderer/renderers/attaches/locale/en.d.ts +11 -0
- package/dist/renderer/renderers/attaches/locale/en.js +7 -0
- package/dist/renderer/renderers/attaches/locale/ru.d.ts +13 -0
- package/dist/renderer/renderers/attaches/locale/ru.js +7 -0
- package/dist/renderer/renderers/attaches/styles.css +196 -0
- package/dist/renderer/renderers/carousel/README.md +43 -0
- package/dist/renderer/renderers/carousel/README.ru.md +43 -0
- package/dist/renderer/renderers/carousel/index.d.ts +7 -0
- package/dist/renderer/renderers/carousel/index.js +110 -0
- package/dist/renderer/renderers/carousel/styles.css +7 -0
- package/dist/renderer/renderers/checklist/README.md +33 -0
- package/dist/renderer/renderers/checklist/README.ru.md +33 -0
- package/dist/renderer/renderers/checklist/index.d.ts +7 -0
- package/dist/renderer/renderers/checklist/index.js +55 -0
- package/dist/renderer/renderers/checklist/styles.css +54 -0
- package/dist/renderer/renderers/code/README.md +33 -0
- package/dist/renderer/renderers/code/README.ru.md +33 -0
- package/dist/renderer/renderers/code/index.d.ts +9 -0
- package/dist/renderer/renderers/code/index.js +137 -0
- package/dist/renderer/renderers/code/locale/en.d.ts +5 -0
- package/dist/renderer/renderers/code/locale/en.js +4 -0
- package/dist/renderer/renderers/code/locale/ru.d.ts +5 -0
- package/dist/renderer/renderers/code/locale/ru.js +4 -0
- package/dist/renderer/renderers/code/styles.css +330 -0
- package/dist/renderer/renderers/columns/README.md +33 -0
- package/dist/renderer/renderers/columns/README.ru.md +33 -0
- package/dist/renderer/renderers/columns/index.d.ts +7 -0
- package/dist/renderer/renderers/columns/index.js +53 -0
- package/dist/renderer/renderers/columns/styles.css +5 -0
- package/dist/renderer/renderers/delimiter/README.md +33 -0
- package/dist/renderer/renderers/delimiter/README.ru.md +33 -0
- package/dist/renderer/renderers/delimiter/index.d.ts +7 -0
- package/dist/renderer/renderers/delimiter/index.js +28 -0
- package/dist/renderer/renderers/delimiter/styles.css +12 -0
- package/dist/renderer/renderers/embed/README.md +35 -0
- package/dist/renderer/renderers/embed/README.ru.md +35 -0
- package/dist/renderer/renderers/embed/index.d.ts +8 -0
- package/dist/renderer/renderers/embed/index.js +66 -0
- package/dist/renderer/renderers/embed/styles.css +217 -0
- package/dist/renderer/renderers/gallery/README.md +41 -0
- package/dist/renderer/renderers/gallery/README.ru.md +41 -0
- package/dist/renderer/renderers/gallery/index.d.ts +8 -0
- package/dist/renderer/renderers/gallery/index.js +329 -0
- package/dist/renderer/renderers/gallery/styles.css +419 -0
- package/dist/renderer/renderers/heading/README.md +33 -0
- package/dist/renderer/renderers/heading/README.ru.md +33 -0
- package/dist/renderer/renderers/heading/index.d.ts +8 -0
- package/dist/renderer/renderers/heading/index.js +38 -0
- package/dist/renderer/renderers/heading/styles.css +26 -0
- package/dist/renderer/renderers/image/README.md +42 -0
- package/dist/renderer/renderers/image/README.ru.md +42 -0
- package/dist/renderer/renderers/image/index.d.ts +7 -0
- package/dist/renderer/renderers/image/index.js +93 -0
- package/dist/renderer/renderers/image/styles.css +40 -0
- package/dist/renderer/renderers/index.d.ts +47 -0
- package/dist/renderer/renderers/index.js +125 -0
- package/dist/renderer/renderers/link-preview/README.md +43 -0
- package/dist/renderer/renderers/link-preview/README.ru.md +43 -0
- package/dist/renderer/renderers/link-preview/index.d.ts +9 -0
- package/dist/renderer/renderers/link-preview/index.js +118 -0
- package/dist/renderer/renderers/link-preview/styles.css +246 -0
- package/dist/renderer/renderers/list/README.md +33 -0
- package/dist/renderer/renderers/list/README.ru.md +33 -0
- package/dist/renderer/renderers/list/index.d.ts +8 -0
- package/dist/renderer/renderers/list/index.js +42 -0
- package/dist/renderer/renderers/list/styles.css +20 -0
- package/dist/renderer/renderers/paragraph/README.md +33 -0
- package/dist/renderer/renderers/paragraph/README.ru.md +33 -0
- package/dist/renderer/renderers/paragraph/index.d.ts +7 -0
- package/dist/renderer/renderers/paragraph/index.js +35 -0
- package/dist/renderer/renderers/paragraph/styles.css +3 -0
- package/dist/renderer/renderers/person/README.md +44 -0
- package/dist/renderer/renderers/person/README.ru.md +44 -0
- package/dist/renderer/renderers/person/index.d.ts +7 -0
- package/dist/renderer/renderers/person/index.js +213 -0
- package/dist/renderer/renderers/person/locale/en.d.ts +6 -0
- package/dist/renderer/renderers/person/locale/en.js +5 -0
- package/dist/renderer/renderers/person/locale/ru.d.ts +6 -0
- package/dist/renderer/renderers/person/locale/ru.js +5 -0
- package/dist/renderer/renderers/person/styles.css +47 -0
- package/dist/renderer/renderers/poll/README.md +68 -0
- package/dist/renderer/renderers/poll/README.ru.md +68 -0
- package/dist/renderer/renderers/poll/index.d.ts +9 -0
- package/dist/renderer/renderers/poll/index.js +339 -0
- package/dist/renderer/renderers/poll/styles.css +148 -0
- package/dist/renderer/renderers/quote/README.md +33 -0
- package/dist/renderer/renderers/quote/README.ru.md +33 -0
- package/dist/renderer/renderers/quote/index.d.ts +7 -0
- package/dist/renderer/renderers/quote/index.js +59 -0
- package/dist/renderer/renderers/quote/styles.css +43 -0
- package/dist/renderer/renderers/raw/README.md +33 -0
- package/dist/renderer/renderers/raw/README.ru.md +33 -0
- package/dist/renderer/renderers/raw/index.d.ts +7 -0
- package/dist/renderer/renderers/raw/index.js +27 -0
- package/dist/renderer/renderers/spoiler/README.md +33 -0
- package/dist/renderer/renderers/spoiler/README.ru.md +33 -0
- package/dist/renderer/renderers/spoiler/index.d.ts +9 -0
- package/dist/renderer/renderers/spoiler/index.js +84 -0
- package/dist/renderer/renderers/spoiler/locale/en.d.ts +4 -0
- package/dist/renderer/renderers/spoiler/locale/en.js +3 -0
- package/dist/renderer/renderers/spoiler/locale/ru.d.ts +4 -0
- package/dist/renderer/renderers/spoiler/locale/ru.js +3 -0
- package/dist/renderer/renderers/spoiler/styles.css +61 -0
- package/dist/renderer/renderers/table/README.md +33 -0
- package/dist/renderer/renderers/table/README.ru.md +33 -0
- package/dist/renderer/renderers/table/index.d.ts +7 -0
- package/dist/renderer/renderers/table/index.js +83 -0
- package/dist/renderer/renderers/table/styles.css +34 -0
- package/dist/renderer/renderers/toggle/README.md +33 -0
- package/dist/renderer/renderers/toggle/README.ru.md +33 -0
- package/dist/renderer/renderers/toggle/index.d.ts +7 -0
- package/dist/renderer/renderers/toggle/index.js +59 -0
- package/dist/renderer/renderers/toggle/styles.css +49 -0
- package/dist/renderer/renderers/warning/README.md +33 -0
- package/dist/renderer/renderers/warning/README.ru.md +33 -0
- package/dist/renderer/renderers/warning/index.d.ts +7 -0
- package/dist/renderer/renderers/warning/index.js +62 -0
- package/dist/renderer/renderers/warning/styles.css +41 -0
- package/dist/renderer/styles/base.css +168 -0
- package/dist/renderer/types.d.ts +464 -0
- package/dist/shared/blockDataNormalizers.d.ts +14 -0
- package/dist/shared/blockDataNormalizers.js +235 -0
- package/dist/shared/blockDataValidators.d.ts +81 -0
- package/dist/shared/blockDataValidators.js +313 -0
- package/dist/shared/blockTypes.d.ts +2 -0
- package/dist/shared/blockTypes.js +26 -0
- package/dist/shared/carouselData.d.ts +34 -0
- package/dist/shared/carouselData.js +111 -0
- package/dist/shared/cloneEditorData.d.ts +11 -0
- package/dist/shared/cloneEditorData.js +20 -0
- package/dist/shared/documentTypes.d.ts +35 -0
- package/dist/shared/embedPlayer.d.ts +42 -0
- package/dist/shared/embedPlayer.js +141 -0
- package/dist/shared/fileUtils.d.ts +33 -0
- package/dist/shared/fileUtils.js +109 -0
- package/dist/shared/highlightRuntime.d.ts +38 -0
- package/dist/shared/highlightRuntime.js +75 -0
- package/dist/shared/inlineMarshal.d.ts +82 -0
- package/dist/shared/inlineMarshal.js +215 -0
- package/dist/shared/jsonData.d.ts +11 -0
- package/dist/shared/jsonData.js +53 -0
- package/dist/shared/localeTypes.d.ts +11 -0
- package/dist/shared/mapTextFields.d.ts +89 -0
- package/dist/shared/mapTextFields.js +119 -0
- package/dist/shared/pollData.d.ts +90 -0
- package/dist/shared/pollData.js +231 -0
- package/dist/shared/resolvePath.d.ts +8 -0
- package/dist/shared/resolvePath.js +10 -0
- package/dist/shared/runtime/dompurify.js +2424 -0
- package/dist/shared/runtime/highlightBundle.js +10 -0
- package/dist/shared/runtime/jszip.js +13 -0
- package/dist/shared/sanitize/allowlist.d.ts +21 -0
- package/dist/shared/sanitize/allowlist.js +40 -0
- package/dist/shared/sanitize/escapeHtml.d.ts +6 -0
- package/dist/shared/sanitize/escapeHtml.js +11 -0
- package/dist/shared/sanitize/index.d.ts +8 -0
- package/dist/shared/sanitize/index.js +8 -0
- package/dist/shared/sanitize/parseInline.d.ts +11 -0
- package/dist/shared/sanitize/parseInline.js +25 -0
- package/dist/shared/sanitize/sanitizeHtml.d.ts +8 -0
- package/dist/shared/sanitize/sanitizeHtml.js +19 -0
- package/dist/shared/sanitize/sanitizeRawHtml.d.ts +15 -0
- package/dist/shared/sanitize/sanitizeRawHtml.js +162 -0
- package/dist/shared/sanitize/sanitizeStyle.d.ts +9 -0
- package/dist/shared/sanitize/sanitizeStyle.js +39 -0
- package/dist/shared/sanitize/sanitizeUrl.d.ts +28 -0
- package/dist/shared/sanitize/sanitizeUrl.js +86 -0
- package/dist/shared/sanitize/walker.d.ts +15 -0
- package/dist/shared/sanitize/walker.js +98 -0
- package/dist/shared/styleRegistry.d.ts +4 -0
- package/dist/shared/styleRegistry.js +38 -0
- package/dist/shared/textFormat.d.ts +32 -0
- package/dist/shared/textFormat.js +48 -0
- package/dist/shared/zipRuntime.d.ts +19 -0
- package/dist/shared/zipRuntime.js +54 -0
- package/dist/styles/editor.css +3 -0
- package/dist/types.d.ts +1 -0
- package/package.json +149 -0
|
@@ -0,0 +1,703 @@
|
|
|
1
|
+
import { el } from './dom.js'
|
|
2
|
+
import { EditorEvent } from './editorEvents.js'
|
|
3
|
+
import { EventBus } from '@shelamkoff/event-bus'
|
|
4
|
+
import { I18n } from './I18n.js'
|
|
5
|
+
import { BlockManager } from './BlockManager.js'
|
|
6
|
+
import { SelectionManager } from './SelectionManager.js'
|
|
7
|
+
import { EditorFacade } from './EditorFacade.js'
|
|
8
|
+
import { DocumentSnapshotStore } from './DocumentSnapshotStore.js'
|
|
9
|
+
import { DocumentSchema } from './DocumentSchema.js'
|
|
10
|
+
import { Diagnostics } from './Diagnostics.js'
|
|
11
|
+
import { EditorBlocksApi, EditorEventSubscriptions, EditorHandle } from './PublicEditorApi.js'
|
|
12
|
+
import { BlockOperations } from './BlockOperations.js'
|
|
13
|
+
import { ShortcutRegistry } from './ShortcutRegistry.js'
|
|
14
|
+
import { Toolbar } from './toolbar/Toolbar.js'
|
|
15
|
+
import { InlineToolbar } from './inline-toolbar/InlineToolbar.js'
|
|
16
|
+
import { TypeSelector } from './TypeSelector.js'
|
|
17
|
+
import { KeyboardManager } from './KeyboardManager.js'
|
|
18
|
+
import { UndoManager } from './UndoManager.js'
|
|
19
|
+
import { CommandDispatcher } from './CommandDispatcher.js'
|
|
20
|
+
import { Clipboard } from './clipboard/Clipboard.js'
|
|
21
|
+
import { DragManager } from './DragManager.js'
|
|
22
|
+
import { CrossBlockSelection } from './CrossBlockSelection.js'
|
|
23
|
+
import { ChangeNotifier } from './ChangeNotifier.js'
|
|
24
|
+
import { createDefaultInlineTools } from '../inline-tools/defaults.js'
|
|
25
|
+
import { SlashCommands } from './SlashCommands.js'
|
|
26
|
+
import { MouseSelectionManager } from './MouseSelectionManager.js'
|
|
27
|
+
import { InlinePluginRegistry } from './InlinePluginRegistry.js'
|
|
28
|
+
import { hydrateInlinePlugins } from './hydrateInlinePlugins.js'
|
|
29
|
+
import { TriggerManager } from './TriggerManager.js'
|
|
30
|
+
import { InlinePatternMatcher } from './InlinePatternMatcher.js'
|
|
31
|
+
import { PopupManager } from './PopupManager.js'
|
|
32
|
+
import { injectStyleUrls } from './StyleInjector.js'
|
|
33
|
+
import { resolveTuning } from './config.js'
|
|
34
|
+
import {DEFAULT_BLOCK_TYPE, DEFAULT_THEME} from './constants.js'
|
|
35
|
+
import { claimPluginInstances } from './PluginOwnership.js'
|
|
36
|
+
import { claimEditorHolder } from './EditorHolderOwnership.js'
|
|
37
|
+
import { LifecycleScope } from './LifecycleScope.js'
|
|
38
|
+
import en from './locale/en.js'
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Resolve inline tools config into tool instances.
|
|
42
|
+
* Supports: undefined (all defaults), string[] (filter defaults by name),
|
|
43
|
+
* or object[] (ready instances, passed through).
|
|
44
|
+
* @param {undefined | Array<string | import('./types').InlineTool>} config
|
|
45
|
+
* @param {import('./I18n').I18n} i18n
|
|
46
|
+
* @param {import('./types').ICrossBlockSelection} crossBlockSelection
|
|
47
|
+
* @returns {import('./types').InlineTool[]}
|
|
48
|
+
*/
|
|
49
|
+
function resolveInlineTools(config, i18n, crossBlockSelection) {
|
|
50
|
+
if (!config) return createDefaultInlineTools({ i18n, crossBlockSelection })
|
|
51
|
+
const defaultTypes = config.filter(item => typeof item === 'string')
|
|
52
|
+
const allDefaults = createDefaultInlineTools({ i18n, crossBlockSelection, types: defaultTypes })
|
|
53
|
+
|
|
54
|
+
/** @type {Map<string, import('./types').InlineTool>} */
|
|
55
|
+
const defaultMap = new Map()
|
|
56
|
+
for (const tool of allDefaults) defaultMap.set(tool.type, tool)
|
|
57
|
+
|
|
58
|
+
/** @type {import('./types').InlineTool[]} */
|
|
59
|
+
const resolved = []
|
|
60
|
+
/** @type {Map<string, number>} */
|
|
61
|
+
const indexes = new Map()
|
|
62
|
+
|
|
63
|
+
for (const item of config) {
|
|
64
|
+
let tool
|
|
65
|
+
if (typeof item === 'string') {
|
|
66
|
+
tool = defaultMap.get(item)
|
|
67
|
+
if (!tool) throw new Error(`Unknown inline tool: "${item}"`)
|
|
68
|
+
} else {
|
|
69
|
+
tool = item
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (!tool || typeof tool.type !== 'string' || tool.type.length === 0) {
|
|
73
|
+
throw new TypeError('Inline tool must have a non-empty string type')
|
|
74
|
+
}
|
|
75
|
+
if (
|
|
76
|
+
typeof tool.icon !== 'string'
|
|
77
|
+
|| typeof tool.isActive !== 'function'
|
|
78
|
+
|| typeof tool.toggle !== 'function'
|
|
79
|
+
) {
|
|
80
|
+
throw new TypeError(`Inline tool "${tool.type}" must define icon, isActive(), and toggle()`)
|
|
81
|
+
}
|
|
82
|
+
const existingIndex = indexes.get(tool.type)
|
|
83
|
+
if (existingIndex === undefined) {
|
|
84
|
+
indexes.set(tool.type, resolved.length)
|
|
85
|
+
resolved.push(tool)
|
|
86
|
+
} else {
|
|
87
|
+
resolved[existingIndex] = tool
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return resolved
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Inject a scoped I18n wrapper into a plugin so it can use short keys
|
|
96
|
+
* (`_t('title')` → resolves `plugin.<type>.title`).
|
|
97
|
+
*
|
|
98
|
+
* The locale dictionary is already fully populated by createEditor before
|
|
99
|
+
* this is called — plugins don't load their own locales.
|
|
100
|
+
*
|
|
101
|
+
* @param {any} plugin
|
|
102
|
+
* @param {import('./I18n').I18n} i18n
|
|
103
|
+
*/
|
|
104
|
+
function injectPluginI18n(plugin, i18n) {
|
|
105
|
+
if (!plugin.type || !plugin.setI18n) {
|
|
106
|
+
plugin.setI18n?.(i18n)
|
|
107
|
+
return
|
|
108
|
+
}
|
|
109
|
+
// Block plugins use `plugin.<type>.*`; inline plugins `inlinePlugin.<type>.*`.
|
|
110
|
+
const isInline = 'createWidget' in plugin
|
|
111
|
+
const prefix = isInline ? `inlinePlugin.${plugin.type}` : `plugin.${plugin.type}`
|
|
112
|
+
plugin.setI18n(i18n.scope(prefix))
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Build the editor DOM scaffold.
|
|
117
|
+
* @param {HTMLElement} holder
|
|
118
|
+
* @param {string} theme
|
|
119
|
+
* @param {number} [minHeight]
|
|
120
|
+
* @returns {{ rootEl: HTMLElement, blocksEl: HTMLElement, clickArea: HTMLElement }}
|
|
121
|
+
*/
|
|
122
|
+
function buildEditorDOM(holder, theme, minHeight) {
|
|
123
|
+
const rootEl = el('div', `oe-editor oe-theme-${theme}`, { tabindex: '-1' })
|
|
124
|
+
if (minHeight !== undefined) rootEl.style.minHeight = `${minHeight}px`
|
|
125
|
+
const blocksEl = el('div', 'oe-blocks')
|
|
126
|
+
const clickArea = el('div', 'oe-click-area')
|
|
127
|
+
rootEl.appendChild(blocksEl)
|
|
128
|
+
rootEl.appendChild(clickArea)
|
|
129
|
+
return { rootEl, blocksEl, clickArea }
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Synchronize the editor root's read-only class and accessibility state.
|
|
134
|
+
* @param {HTMLElement} rootEl Editor root element.
|
|
135
|
+
* @param {boolean} readOnly Whether document mutations are disabled.
|
|
136
|
+
*/
|
|
137
|
+
function applyReadOnlyAttributes(rootEl, readOnly) {
|
|
138
|
+
rootEl.classList.toggle('oe-editor--read-only', readOnly)
|
|
139
|
+
if (readOnly) rootEl.setAttribute('aria-readonly', 'true')
|
|
140
|
+
else rootEl.removeAttribute('aria-readonly')
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Wire focusin and input tracking on the editor root.
|
|
145
|
+
* @param {HTMLElement} rootEl
|
|
146
|
+
* @param {import('./BlockManager').BlockManager} blocks
|
|
147
|
+
* @param {import('./types').IEventBus} events
|
|
148
|
+
* @returns {{ destroy(): void }}
|
|
149
|
+
*/
|
|
150
|
+
function wireInputTracking(rootEl, blocks, events) {
|
|
151
|
+
const onFocusIn = (/** @type {FocusEvent} */ e) => {
|
|
152
|
+
const target = /** @type {import('./types').DOMNode} */ (e.target)
|
|
153
|
+
const block = blocks.getBlockByChildNode(target)
|
|
154
|
+
if (!block) return
|
|
155
|
+
const index = blocks.getBlockIndex(block.id)
|
|
156
|
+
if (index !== blocks.getCurrentIndex()) {
|
|
157
|
+
blocks.setCurrentIndex(index)
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const onInput = (/** @type {InputEvent} */ event) => {
|
|
162
|
+
const target = /** @type {import('./types').DOMNode} */ (event.target)
|
|
163
|
+
// Editor controls (URL/color/font inputs, filters, dialogs) also bubble
|
|
164
|
+
// `input` through rootEl. They are not document mutations and must never
|
|
165
|
+
// advance block history by falling back to the currently focused block.
|
|
166
|
+
const changed = blocks.getBlockByChildNode(target)
|
|
167
|
+
if (!changed) return
|
|
168
|
+
changed.markDirty()
|
|
169
|
+
events.emit(EditorEvent.BLOCK_CHANGED, { blockId: changed.id })
|
|
170
|
+
events.emit(EditorEvent.CHANGED)
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
rootEl.addEventListener('focusin', onFocusIn)
|
|
174
|
+
rootEl.addEventListener('input', onInput)
|
|
175
|
+
|
|
176
|
+
return {
|
|
177
|
+
destroy() {
|
|
178
|
+
rootEl.removeEventListener('focusin', onFocusIn)
|
|
179
|
+
rootEl.removeEventListener('input', onInput)
|
|
180
|
+
},
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Collect and inject plugin stylesheets via <link> tags (reference-counted).
|
|
186
|
+
*
|
|
187
|
+
* Per-plugin config knobs (passed via plugin constructor):
|
|
188
|
+
* - `injectStyles: false` — skip the default stylesheet for this plugin
|
|
189
|
+
* - `css: '/path/to.css'` — inject an additional stylesheet AFTER the default
|
|
190
|
+
*
|
|
191
|
+
* @param {Map<string, import('./types').BlockPlugin>} plugins
|
|
192
|
+
* @returns {{ destroy(): void } | null}
|
|
193
|
+
*/
|
|
194
|
+
function injectPluginStyles(plugins) {
|
|
195
|
+
/** @type {string[]} */
|
|
196
|
+
const styleUrls = []
|
|
197
|
+
for (const plugin of plugins.values()) {
|
|
198
|
+
const cfg = typeof plugin.getPluginConfig === 'function'
|
|
199
|
+
? plugin.getPluginConfig()
|
|
200
|
+
: undefined
|
|
201
|
+
if (cfg?.injectStyles !== false) {
|
|
202
|
+
const constructor = /** @type {import('./types').BlockPluginConstructor} */ (plugin.constructor)
|
|
203
|
+
const urls = constructor.styles
|
|
204
|
+
if (urls) styleUrls.push(...urls)
|
|
205
|
+
}
|
|
206
|
+
if (cfg?.css) styleUrls.push(cfg.css)
|
|
207
|
+
}
|
|
208
|
+
return styleUrls.length > 0 ? injectStyleUrls(styleUrls) : null
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* @typedef {Object} EditModeDeps
|
|
213
|
+
* @property {HTMLElement} rootEl
|
|
214
|
+
* @property {HTMLElement} blocksEl
|
|
215
|
+
* @property {HTMLElement} clickArea
|
|
216
|
+
* @property {Map<string, import('./types').BlockPlugin>} plugins
|
|
217
|
+
* @property {import('./BlockManager').BlockManager} blocks
|
|
218
|
+
* @property {import('./SelectionManager').SelectionManager} selection
|
|
219
|
+
* @property {import('./I18n').I18n} i18n
|
|
220
|
+
* @property {import('./types').IEventBus} events
|
|
221
|
+
* @property {CommandDispatcher} commands
|
|
222
|
+
* @property {import('./CrossBlockSelection').CrossBlockSelection} crossBlockSelection
|
|
223
|
+
* @property {string} defaultBlockType
|
|
224
|
+
* @property {import('./InlinePluginRegistry').InlinePluginRegistry} inlinePluginRegistry
|
|
225
|
+
* @property {import('./types').InlinePluginContext} inlinePluginCtx
|
|
226
|
+
* @property {EditorFacade} facade
|
|
227
|
+
* @property {DocumentSnapshotStore} snapshots
|
|
228
|
+
* @property {import('./config').EditorTuning} tuning
|
|
229
|
+
* @property {import('./types').EditorConfig} config
|
|
230
|
+
* @property {Diagnostics} diagnostics
|
|
231
|
+
* @property {LifecycleScope} scope
|
|
232
|
+
* @property {UndoManager} undoManager
|
|
233
|
+
*/
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Wire all edit-mode managers (toolbar, undo, clipboard, drag, keyboard, etc.).
|
|
237
|
+
* Only called when `readOnly` is false.
|
|
238
|
+
* @param {EditModeDeps} deps
|
|
239
|
+
*/
|
|
240
|
+
function wireEditMode(deps) {
|
|
241
|
+
const {
|
|
242
|
+
rootEl, blocksEl, clickArea, plugins, blocks, selection,
|
|
243
|
+
i18n, events, commands, crossBlockSelection, defaultBlockType,
|
|
244
|
+
inlinePluginRegistry, inlinePluginCtx, facade, snapshots, tuning, config, diagnostics,
|
|
245
|
+
scope, undoManager,
|
|
246
|
+
} = deps
|
|
247
|
+
|
|
248
|
+
const blockOps = new BlockOperations(blocks, selection, defaultBlockType, events)
|
|
249
|
+
blocks.setPluginStructuralCommands({
|
|
250
|
+
splitBlock: () => blockOps.splitBlock(),
|
|
251
|
+
exitEmptyBlock: () => blockOps.exitEmptyBlock(),
|
|
252
|
+
})
|
|
253
|
+
scope.register({
|
|
254
|
+
destroy: () => blocks.setPluginStructuralCommands({ splitBlock: null, exitEmptyBlock: null }),
|
|
255
|
+
})
|
|
256
|
+
const pluginMutations = commands
|
|
257
|
+
|
|
258
|
+
const duplicateBlock = (current, index) => {
|
|
259
|
+
const snapshot = snapshots.capture().blocks.find(block => block.id === current.id)
|
|
260
|
+
if (!snapshot) return undefined
|
|
261
|
+
|
|
262
|
+
const duplicate = blocks.insert(
|
|
263
|
+
snapshot.type,
|
|
264
|
+
snapshot.data,
|
|
265
|
+
index + 1,
|
|
266
|
+
undefined,
|
|
267
|
+
snapshot.inline,
|
|
268
|
+
)
|
|
269
|
+
hydrateInlinePlugins(duplicate.contentElement, inlinePluginRegistry, inlinePluginCtx)
|
|
270
|
+
const duplicateIndex = blocks.getBlockIndex(duplicate.id)
|
|
271
|
+
blocks.setCurrentIndex(duplicateIndex)
|
|
272
|
+
selection.setCaretToBlock(duplicate.id, 'end')
|
|
273
|
+
duplicate.focus()
|
|
274
|
+
return duplicate
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
const toolbar = new Toolbar(rootEl, {
|
|
278
|
+
plugins, blocks, selection, i18n, events, commands, crossBlockSelection,
|
|
279
|
+
blockOps, defaultBlockType, inlinePluginRegistry, duplicateBlock,
|
|
280
|
+
tuning: {
|
|
281
|
+
filterThreshold: tuning.toolbar.filterThreshold,
|
|
282
|
+
mobileBreakpoint: tuning.mobileBreakpoint,
|
|
283
|
+
moveAnimationMs: tuning.animations.blockMoveMs,
|
|
284
|
+
},
|
|
285
|
+
})
|
|
286
|
+
scope.register(toolbar)
|
|
287
|
+
|
|
288
|
+
const unsubscribeInlineInsert = events.on(EditorEvent.INLINE_PLUGIN_INSERT, (/** @type {{ type: string }} */ payload) => {
|
|
289
|
+
facade.insertInlinePlugin(payload.type)
|
|
290
|
+
})
|
|
291
|
+
scope.register({ destroy: unsubscribeInlineInsert })
|
|
292
|
+
|
|
293
|
+
const inlineTools = resolveInlineTools(config.inlineTools, i18n, crossBlockSelection)
|
|
294
|
+
|
|
295
|
+
const getInlineControls = (/** @type {string} */ type) => {
|
|
296
|
+
const p = plugins.get(type)
|
|
297
|
+
return p?.renderInlineControls ? p.renderInlineControls.bind(p) : undefined
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
const typeSelector = new TypeSelector(blocks, selection, plugins, i18n, crossBlockSelection, events, tuning.toolbar)
|
|
301
|
+
const inlineToolbar = new InlineToolbar(
|
|
302
|
+
rootEl,
|
|
303
|
+
selection,
|
|
304
|
+
blocks,
|
|
305
|
+
events,
|
|
306
|
+
inlineTools,
|
|
307
|
+
getInlineControls,
|
|
308
|
+
typeSelector,
|
|
309
|
+
crossBlockSelection,
|
|
310
|
+
commands,
|
|
311
|
+
)
|
|
312
|
+
scope.register(inlineToolbar)
|
|
313
|
+
|
|
314
|
+
const shortcuts = new ShortcutRegistry()
|
|
315
|
+
shortcuts.register('Mod+Z', () => undoManager.undo(), { scope: 'editor' })
|
|
316
|
+
shortcuts.register('Mod+Shift+Z', () => undoManager.redo(), { scope: 'editor' })
|
|
317
|
+
shortcuts.register('Mod+Y', () => undoManager.redo(), { scope: 'editor' })
|
|
318
|
+
|
|
319
|
+
const slashCommands = new SlashCommands(rootEl, {
|
|
320
|
+
plugins,
|
|
321
|
+
blocks,
|
|
322
|
+
selection,
|
|
323
|
+
events,
|
|
324
|
+
commands,
|
|
325
|
+
i18n,
|
|
326
|
+
inlinePluginRegistry,
|
|
327
|
+
inlinePluginCtx,
|
|
328
|
+
})
|
|
329
|
+
scope.register(slashCommands)
|
|
330
|
+
|
|
331
|
+
shortcuts.register('Escape', () => {
|
|
332
|
+
toolbar.closeToolbox()
|
|
333
|
+
toolbar.closeSettingsMenu()
|
|
334
|
+
inlineToolbar.hide()
|
|
335
|
+
slashCommands.close()
|
|
336
|
+
})
|
|
337
|
+
|
|
338
|
+
for (const tool of inlineTools) {
|
|
339
|
+
if (tool.shortcut) {
|
|
340
|
+
shortcuts.register(tool.shortcut, () => inlineToolbar.openTool(tool.type))
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
for (const plugin of plugins.values()) {
|
|
345
|
+
if (plugin.shortcuts) {
|
|
346
|
+
for (const sc of plugin.shortcuts) {
|
|
347
|
+
shortcuts.register(sc.combo, () => {
|
|
348
|
+
const current = blocks.getCurrentBlock()
|
|
349
|
+
if (current) {
|
|
350
|
+
pluginMutations.runForBlock(current, () => sc.handler(current.contentElement))
|
|
351
|
+
}
|
|
352
|
+
})
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
const uiActivePredicate = () => inlineToolbar.hasActiveUI() || slashCommands.isOpen
|
|
358
|
+
|
|
359
|
+
const keyboardManager = new KeyboardManager(rootEl, blockOps, shortcuts, blocks, events, defaultBlockType, uiActivePredicate)
|
|
360
|
+
scope.register(keyboardManager)
|
|
361
|
+
|
|
362
|
+
if (inlinePluginRegistry.hasTriggers) {
|
|
363
|
+
scope.register(new TriggerManager(rootEl, inlinePluginRegistry, inlinePluginCtx, events))
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
if (inlinePluginRegistry.size > 0) {
|
|
367
|
+
scope.register(new InlinePatternMatcher(
|
|
368
|
+
rootEl,
|
|
369
|
+
inlinePluginRegistry,
|
|
370
|
+
inlinePluginCtx,
|
|
371
|
+
events,
|
|
372
|
+
blocks,
|
|
373
|
+
commands,
|
|
374
|
+
))
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
const clipboard = new Clipboard(rootEl, {
|
|
378
|
+
blocks, selection, plugins, defaultBlockType, crossBlockSelection, events, commands,
|
|
379
|
+
blockOps, inlinePluginRegistry, inlinePluginCtx, diagnostics, uiActivePredicate,
|
|
380
|
+
captureSnapshot: () => snapshots.capture(),
|
|
381
|
+
})
|
|
382
|
+
scope.register(clipboard)
|
|
383
|
+
scope.register(new DragManager(rootEl, blocks, toolbar.dragHandle, events, tuning.drag))
|
|
384
|
+
scope.register(new MouseSelectionManager(rootEl, { blocksEl, clickArea, blocks, selection, events, crossBlockSelection, defaultBlockType }))
|
|
385
|
+
|
|
386
|
+
// Re-emit block:focused so Toolbar positions itself
|
|
387
|
+
// (initial setCurrentIndex fired before Toolbar was created)
|
|
388
|
+
const currentBlock = blocks.getCurrentBlock()
|
|
389
|
+
if (currentBlock) {
|
|
390
|
+
events.emit(EditorEvent.BLOCK_FOCUSED, { blockId: currentBlock.id })
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Initialize I18n from config.
|
|
396
|
+
* @param {import('./types').EditorConfig} config
|
|
397
|
+
* @returns {I18n}
|
|
398
|
+
*/
|
|
399
|
+
function initI18n(config) {
|
|
400
|
+
const localeMessages = /** @type {Record<string, import('./types').LocaleValue>} */ (
|
|
401
|
+
config.locale ?? en
|
|
402
|
+
)
|
|
403
|
+
const configuredLang = localeMessages.__lang
|
|
404
|
+
const lang = typeof configuredLang === 'string' ? configuredLang : 'en'
|
|
405
|
+
return new I18n(localeMessages, localeMessages === en ? undefined : en, lang)
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Build the plugin map, inject I18n and placeholder.
|
|
410
|
+
* @param {import('./types').BlockPlugin[]} pluginList
|
|
411
|
+
* @param {I18n} i18n
|
|
412
|
+
* @param {string} defaultBlockType
|
|
413
|
+
* @param {string} [placeholder]
|
|
414
|
+
* @returns {Map<string, import('./types').BlockPlugin>}
|
|
415
|
+
*/
|
|
416
|
+
function registerPlugins(pluginList, i18n, defaultBlockType, placeholder) {
|
|
417
|
+
/** @type {Map<string, import('./types').BlockPlugin>} */
|
|
418
|
+
const plugins = new Map()
|
|
419
|
+
for (const plugin of pluginList) {
|
|
420
|
+
if (!plugin || typeof plugin.type !== 'string' || !plugin.type) {
|
|
421
|
+
throw new TypeError('Every block plugin must have a non-empty string type')
|
|
422
|
+
}
|
|
423
|
+
if (typeof plugin.render !== 'function' || typeof plugin.save !== 'function') {
|
|
424
|
+
throw new TypeError(`Block plugin "${plugin.type}" must implement render() and save()`)
|
|
425
|
+
}
|
|
426
|
+
if (plugins.has(plugin.type)) {
|
|
427
|
+
throw new Error(`Duplicate block plugin type: "${plugin.type}"`)
|
|
428
|
+
}
|
|
429
|
+
injectPluginI18n(plugin, i18n)
|
|
430
|
+
if (placeholder !== undefined && plugin.type === defaultBlockType && typeof plugin.setPlaceholder === 'function') {
|
|
431
|
+
plugin.setPlaceholder(placeholder)
|
|
432
|
+
}
|
|
433
|
+
plugins.set(plugin.type, plugin)
|
|
434
|
+
}
|
|
435
|
+
if (!plugins.has(defaultBlockType)) {
|
|
436
|
+
throw new Error(`Default block plugin "${defaultBlockType}" is not registered`)
|
|
437
|
+
}
|
|
438
|
+
return plugins
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Create a new block editor instance.
|
|
443
|
+
*
|
|
444
|
+
* @param {import('./types').EditorConfig} config
|
|
445
|
+
* @returns {import('./types').IEditor}
|
|
446
|
+
*/
|
|
447
|
+
export function createEditor(config) {
|
|
448
|
+
if (!(config?.holder instanceof HTMLElement)) {
|
|
449
|
+
throw new TypeError('createEditor() requires an HTMLElement holder')
|
|
450
|
+
}
|
|
451
|
+
if (!Array.isArray(config.plugins)) {
|
|
452
|
+
throw new TypeError('createEditor() requires a plugins array')
|
|
453
|
+
}
|
|
454
|
+
if (config.readOnly !== undefined && typeof config.readOnly !== 'boolean') {
|
|
455
|
+
throw new TypeError('createEditor() readOnly must be a boolean')
|
|
456
|
+
}
|
|
457
|
+
if (config.placeholder !== undefined && typeof config.placeholder !== 'string') {
|
|
458
|
+
throw new TypeError('createEditor() placeholder must be a string')
|
|
459
|
+
}
|
|
460
|
+
if (
|
|
461
|
+
config.minHeight !== undefined
|
|
462
|
+
&& (typeof config.minHeight !== 'number' || !Number.isFinite(config.minHeight) || config.minHeight < 0)
|
|
463
|
+
) {
|
|
464
|
+
throw new RangeError('createEditor() minHeight must be a finite number greater than or equal to 0')
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
let readOnly = config.readOnly ?? false
|
|
468
|
+
const defaultBlockType = config.defaultBlock
|
|
469
|
+
|| (config.plugins?.some(plugin => plugin?.type === DEFAULT_BLOCK_TYPE)
|
|
470
|
+
? DEFAULT_BLOCK_TYPE
|
|
471
|
+
: config.plugins?.[0]?.type || DEFAULT_BLOCK_TYPE)
|
|
472
|
+
const theme = config.theme || DEFAULT_THEME
|
|
473
|
+
const tuning = resolveTuning(config.tuning)
|
|
474
|
+
|
|
475
|
+
let rootEl
|
|
476
|
+
let blocks
|
|
477
|
+
let inlinePluginRegistry
|
|
478
|
+
let facade
|
|
479
|
+
let pluginOwnership
|
|
480
|
+
const diagnostics = new Diagnostics(config.onDiagnostic, config.diagnosticThresholds)
|
|
481
|
+
const holderOwnership = claimEditorHolder(config.holder)
|
|
482
|
+
|
|
483
|
+
try {
|
|
484
|
+
pluginOwnership = claimPluginInstances([
|
|
485
|
+
...config.plugins,
|
|
486
|
+
...(config.inlinePlugins || []),
|
|
487
|
+
])
|
|
488
|
+
const events = new EventBus()
|
|
489
|
+
const documentSchema = new DocumentSchema({
|
|
490
|
+
migrations: config.migrations,
|
|
491
|
+
versionPolicy: config.documentVersionPolicy,
|
|
492
|
+
diagnostics,
|
|
493
|
+
})
|
|
494
|
+
const i18n = initI18n(config)
|
|
495
|
+
const plugins = registerPlugins(config.plugins, i18n, defaultBlockType, config.placeholder)
|
|
496
|
+
|
|
497
|
+
const dom = buildEditorDOM(config.holder, theme, config.minHeight)
|
|
498
|
+
rootEl = dom.rootEl
|
|
499
|
+
applyReadOnlyAttributes(rootEl, readOnly)
|
|
500
|
+
const { blocksEl, clickArea } = dom
|
|
501
|
+
|
|
502
|
+
blocks = new BlockManager(
|
|
503
|
+
blocksEl,
|
|
504
|
+
plugins,
|
|
505
|
+
events,
|
|
506
|
+
tuning.animations,
|
|
507
|
+
readOnly,
|
|
508
|
+
type => i18n.t('block.unsupported', { type }),
|
|
509
|
+
)
|
|
510
|
+
const commands = new CommandDispatcher(blocks, events, diagnostics)
|
|
511
|
+
blocks.setCommandDispatcher(commands)
|
|
512
|
+
const selection = new SelectionManager(rootEl, blocks)
|
|
513
|
+
|
|
514
|
+
// Register inline plugins before inserting blocks so saved inline widget
|
|
515
|
+
// placeholders can be rehydrated as each block enters the document.
|
|
516
|
+
inlinePluginRegistry = new InlinePluginRegistry(config.inlinePlugins || [])
|
|
517
|
+
for (const ip of inlinePluginRegistry.values()) {
|
|
518
|
+
injectPluginI18n(ip, i18n)
|
|
519
|
+
}
|
|
520
|
+
i18n.freeze()
|
|
521
|
+
blocks.setInlinePluginRegistry(inlinePluginRegistry)
|
|
522
|
+
|
|
523
|
+
const initialDocument = config.data ? documentSchema.normalize(config.data) : null
|
|
524
|
+
blocks.prepareReplacement(initialDocument?.blocks, defaultBlockType, 'createEditor').commit()
|
|
525
|
+
blocks.setCurrentIndex(0)
|
|
526
|
+
blocks.enableAnimations()
|
|
527
|
+
config.holder.appendChild(rootEl)
|
|
528
|
+
|
|
529
|
+
const crossBlockSelection = new CrossBlockSelection()
|
|
530
|
+
|
|
531
|
+
const inlinePluginCtx = new PopupManager(
|
|
532
|
+
events,
|
|
533
|
+
EditorEvent.CHANGED,
|
|
534
|
+
blocks,
|
|
535
|
+
commands,
|
|
536
|
+
() => readOnly,
|
|
537
|
+
)
|
|
538
|
+
inlinePluginCtx.setRoot(rootEl)
|
|
539
|
+
inlinePluginRegistry.mount(rootEl, inlinePluginCtx)
|
|
540
|
+
|
|
541
|
+
if (inlinePluginRegistry.size > 0) {
|
|
542
|
+
for (const block of blocks) {
|
|
543
|
+
hydrateInlinePlugins(block.contentElement, inlinePluginRegistry, inlinePluginCtx)
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
const snapshots = new DocumentSnapshotStore(
|
|
548
|
+
blocks,
|
|
549
|
+
inlinePluginRegistry,
|
|
550
|
+
config,
|
|
551
|
+
diagnostics,
|
|
552
|
+
initialDocument?.version ?? documentSchema.currentVersion,
|
|
553
|
+
)
|
|
554
|
+
const publicBlocks = new EditorBlocksApi(blocks, events)
|
|
555
|
+
const publicEvents = new EditorEventSubscriptions(events)
|
|
556
|
+
facade = new EditorFacade(rootEl, {
|
|
557
|
+
blocks,
|
|
558
|
+
selection,
|
|
559
|
+
events,
|
|
560
|
+
defaultBlockType,
|
|
561
|
+
inlinePluginRegistry,
|
|
562
|
+
inlinePluginCtx,
|
|
563
|
+
crossBlockSelection,
|
|
564
|
+
commands,
|
|
565
|
+
documentSchema,
|
|
566
|
+
diagnostics,
|
|
567
|
+
snapshots,
|
|
568
|
+
publicBlocks,
|
|
569
|
+
publicEvents,
|
|
570
|
+
readOnly,
|
|
571
|
+
})
|
|
572
|
+
facade.registerDestroyable(holderOwnership)
|
|
573
|
+
facade.registerDestroyable(pluginOwnership)
|
|
574
|
+
facade.registerDestroyable(inlinePluginCtx)
|
|
575
|
+
facade.registerDestroyable(inlinePluginRegistry)
|
|
576
|
+
commands.configureRollback(
|
|
577
|
+
() => snapshots.capture(),
|
|
578
|
+
document => facade.render(document),
|
|
579
|
+
)
|
|
580
|
+
const changeNotifier = new ChangeNotifier(() => facade.save(), config.onChange, tuning.change.debounceMs)
|
|
581
|
+
facade.registerDestroyable(changeNotifier)
|
|
582
|
+
events.on(EditorEvent.CHANGED, () => changeNotifier.schedule())
|
|
583
|
+
|
|
584
|
+
const undoManager = new UndoManager(
|
|
585
|
+
blocks, events,
|
|
586
|
+
() => snapshots.capture(),
|
|
587
|
+
(data, caret) => facade.render(data, caret),
|
|
588
|
+
() => selection.getCaret(),
|
|
589
|
+
tuning.undo,
|
|
590
|
+
)
|
|
591
|
+
undoManager.setCommandsEnabled(!readOnly, { notify: false })
|
|
592
|
+
facade.configureHistory(undoManager)
|
|
593
|
+
facade.registerDestroyable(undoManager)
|
|
594
|
+
|
|
595
|
+
/** @type {LifecycleScope | null} */
|
|
596
|
+
let editModeScope = null
|
|
597
|
+
const mountEditMode = () => {
|
|
598
|
+
if (editModeScope) return
|
|
599
|
+
const scope = new LifecycleScope()
|
|
600
|
+
try {
|
|
601
|
+
scope.register(wireInputTracking(rootEl, blocks, events))
|
|
602
|
+
wireEditMode({
|
|
603
|
+
rootEl, blocksEl, clickArea, plugins, blocks, selection,
|
|
604
|
+
i18n, events, commands, crossBlockSelection, defaultBlockType,
|
|
605
|
+
inlinePluginRegistry, inlinePluginCtx, facade, snapshots, tuning, config, diagnostics,
|
|
606
|
+
scope, undoManager,
|
|
607
|
+
})
|
|
608
|
+
editModeScope = scope
|
|
609
|
+
} catch (error) {
|
|
610
|
+
scope.destroy()
|
|
611
|
+
throw error
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
const unmountEditMode = () => {
|
|
616
|
+
editModeScope?.destroy()
|
|
617
|
+
editModeScope = null
|
|
618
|
+
crossBlockSelection.deactivate(rootEl)
|
|
619
|
+
blocks.clearSelection()
|
|
620
|
+
}
|
|
621
|
+
facade.registerDestroyable({ destroy: unmountEditMode })
|
|
622
|
+
|
|
623
|
+
facade.configureReadOnlyTransition(nextReadOnly => {
|
|
624
|
+
const previousReadOnly = facade.readOnly
|
|
625
|
+
// Cancel transient widget previews before capturing the canonical
|
|
626
|
+
// document. Otherwise a preview could be serialized as a committed edit.
|
|
627
|
+
inlinePluginCtx.hidePopup()
|
|
628
|
+
undoManager.commit()
|
|
629
|
+
const document = facade.save()
|
|
630
|
+
unmountEditMode()
|
|
631
|
+
readOnly = nextReadOnly
|
|
632
|
+
blocks.setReadOnly(nextReadOnly)
|
|
633
|
+
applyReadOnlyAttributes(rootEl, nextReadOnly)
|
|
634
|
+
|
|
635
|
+
try {
|
|
636
|
+
facade.render(document, undefined, { focus: false, notifyChange: false })
|
|
637
|
+
if (!nextReadOnly) mountEditMode()
|
|
638
|
+
undoManager.setCommandsEnabled(!nextReadOnly, { notify: false })
|
|
639
|
+
} catch (transitionError) {
|
|
640
|
+
unmountEditMode()
|
|
641
|
+
readOnly = previousReadOnly
|
|
642
|
+
blocks.setReadOnly(previousReadOnly)
|
|
643
|
+
applyReadOnlyAttributes(rootEl, previousReadOnly)
|
|
644
|
+
try {
|
|
645
|
+
facade.render(document, undefined, { focus: false, notifyChange: false })
|
|
646
|
+
if (!previousReadOnly) mountEditMode()
|
|
647
|
+
} catch (rollbackError) {
|
|
648
|
+
throw new AggregateError(
|
|
649
|
+
[transitionError, rollbackError],
|
|
650
|
+
'Editor read-only transition and rollback failed',
|
|
651
|
+
)
|
|
652
|
+
}
|
|
653
|
+
throw transitionError
|
|
654
|
+
}
|
|
655
|
+
})
|
|
656
|
+
|
|
657
|
+
if (!readOnly) mountEditMode()
|
|
658
|
+
|
|
659
|
+
const styleCleanup = injectPluginStyles(plugins)
|
|
660
|
+
if (styleCleanup) facade.registerDestroyable(styleCleanup)
|
|
661
|
+
|
|
662
|
+
if (config.autofocus && !readOnly) {
|
|
663
|
+
facade.focus()
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
facade.markReady()
|
|
667
|
+
events.emit(EditorEvent.READY)
|
|
668
|
+
|
|
669
|
+
if (config.onReady) {
|
|
670
|
+
queueMicrotask(() => {
|
|
671
|
+
if (facade.isReady) config.onReady()
|
|
672
|
+
})
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
return new EditorHandle(facade)
|
|
676
|
+
} catch (error) {
|
|
677
|
+
diagnostics.emit('editor.create.failed', { errorName: diagnostics.errorName(error) })
|
|
678
|
+
if (facade) {
|
|
679
|
+
facade.destroy()
|
|
680
|
+
} else {
|
|
681
|
+
blocks?.clear()
|
|
682
|
+
inlinePluginRegistry?.destroy()
|
|
683
|
+
pluginOwnership?.destroy()
|
|
684
|
+
holderOwnership.destroy()
|
|
685
|
+
rootEl?.remove()
|
|
686
|
+
}
|
|
687
|
+
throw error
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
export { DocumentSchema } from './DocumentSchema.js'
|
|
692
|
+
|
|
693
|
+
// ── Public API ──────────────────────────────────────────────────────────────
|
|
694
|
+
export { uid } from './uid.js'
|
|
695
|
+
export { sanitizeHtml, escapeHtml } from './sanitize.js'
|
|
696
|
+
export { createDefaultInlineTools } from '../inline-tools/defaults.js'
|
|
697
|
+
export { InlinePluginRegistry } from './InlinePluginRegistry.js'
|
|
698
|
+
export { createColorSwatchPlugin } from '../inline-plugins/color.js'
|
|
699
|
+
export { createMentionPlugin } from '../inline-plugins/mention/index.js'
|
|
700
|
+
|
|
701
|
+
// Block plugins are NOT re-exported here — import them directly from their
|
|
702
|
+
// own entry points to keep bundles tree-shakeable. See demo.html for the
|
|
703
|
+
// canonical import shape.
|