@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,747 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
EditorBlockData,
|
|
3
|
+
EditorInlineWidget,
|
|
4
|
+
EditorOutputData,
|
|
5
|
+
} from '../shared/documentTypes.js'
|
|
6
|
+
import type { LocaleValue } from '../shared/localeTypes.js'
|
|
7
|
+
export type { LocaleValue, PluralForms } from '../shared/localeTypes.js'
|
|
8
|
+
|
|
9
|
+
/** Explicit DOM aliases used by JavaScript JSDoc without colliding with Node.js types. */
|
|
10
|
+
export type DOMNode = Node
|
|
11
|
+
export type DOMText = Text
|
|
12
|
+
|
|
13
|
+
export interface EditorDocument extends EditorOutputData<BlockData> {
|
|
14
|
+
time?: number
|
|
15
|
+
version: string
|
|
16
|
+
blocks: BlockData[]
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface BlockData<
|
|
20
|
+
T extends string = string,
|
|
21
|
+
D extends Record<string, unknown> = Record<string, unknown>
|
|
22
|
+
> extends EditorBlockData<T, D> {
|
|
23
|
+
id: string
|
|
24
|
+
type: T
|
|
25
|
+
data: D
|
|
26
|
+
revision?: string | number
|
|
27
|
+
tunes?: Record<string, unknown>
|
|
28
|
+
/**
|
|
29
|
+
* Inline widget map for text-carrying blocks. Populated by the editor's
|
|
30
|
+
* save pipeline when `data` contains `{{<id>}}` placeholder tokens.
|
|
31
|
+
* Each entry is `{ type, data }` — the inline plugin used to build the
|
|
32
|
+
* widget plus the plugin-specific data captured from its DOM. The map
|
|
33
|
+
* key is the widget's stable instance id (the same value that appears
|
|
34
|
+
* inside `{{...}}` in the text and as `data-id` on the live widget).
|
|
35
|
+
*/
|
|
36
|
+
inline?: Record<string, EditorInlineWidget>
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// ── Plugin API ───────────────────────────────────────────────────────────────
|
|
40
|
+
|
|
41
|
+
/** Shared base for all plugin types (block plugins, inline widget plugins). */
|
|
42
|
+
export interface BasePlugin {
|
|
43
|
+
readonly type: string
|
|
44
|
+
readonly title: string
|
|
45
|
+
readonly icon: string
|
|
46
|
+
/** Locale metadata for composition roots that aggregate dictionaries. */
|
|
47
|
+
readonly locale?: Record<string, Record<string, LocaleValue>>
|
|
48
|
+
/** Receive i18n instance for localized titles, labels, and placeholders. */
|
|
49
|
+
setI18n?(i18n: { t(key: string): string }): void
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Block plugin interface.
|
|
54
|
+
*
|
|
55
|
+
* Required: type, title, icon, render(), save().
|
|
56
|
+
* Everything else is opt-in — the editor checks for each capability
|
|
57
|
+
* at runtime via `typeof plugin.method === 'function'`.
|
|
58
|
+
* `BlockPluginAbstract` provides a convenient base class with i18n support.
|
|
59
|
+
*/
|
|
60
|
+
export interface BlockPlugin<D extends Record<string, unknown> = Record<string, unknown>> extends BasePlugin {
|
|
61
|
+
readonly inlineTools?: boolean | string[]
|
|
62
|
+
|
|
63
|
+
/** Return the immutable constructor options owned by this plugin instance. */
|
|
64
|
+
getPluginConfig?(): PluginRuntimeConfig
|
|
65
|
+
/** Override the empty-state prompt of the default text block. */
|
|
66
|
+
setPlaceholder?(placeholder: string): void
|
|
67
|
+
|
|
68
|
+
// ── Core (required) ──────────────────────────────────────────────────────
|
|
69
|
+
render(data: D, context: BlockMutationContext): HTMLElement
|
|
70
|
+
save(element: HTMLElement): D
|
|
71
|
+
|
|
72
|
+
// ── Lifecycle ────────────────────────────────────────────────────────────
|
|
73
|
+
validate?(data: D): boolean
|
|
74
|
+
/** Release resources shared by all mounted blocks when the editor is destroyed. */
|
|
75
|
+
dispose?(): void
|
|
76
|
+
/** Release resources owned by one rendered block. */
|
|
77
|
+
destroy?(element: HTMLElement): void
|
|
78
|
+
isEmpty?(element: HTMLElement): boolean
|
|
79
|
+
|
|
80
|
+
// ── Toolbox & shortcuts ──────────────────────────────────────────────────
|
|
81
|
+
toolbox?: ToolboxEntry | ToolboxEntry[]
|
|
82
|
+
shortcuts?: ShortcutEntry[]
|
|
83
|
+
|
|
84
|
+
// ── Merge ────────────────────────────────────────────────────────────────
|
|
85
|
+
merge?(element: HTMLElement, data: D): void
|
|
86
|
+
|
|
87
|
+
// ── Settings UI ──────────────────────────────────────────────────────────
|
|
88
|
+
renderSettings?(element: HTMLElement): HTMLElement | HTMLElement[] | null
|
|
89
|
+
changeLevel?(element: HTMLElement, level: number): HTMLElement
|
|
90
|
+
onSettingsAction?(element: HTMLElement, action: string): Record<string, unknown> | null
|
|
91
|
+
|
|
92
|
+
// ── Paste ────────────────────────────────────────────────────────────────
|
|
93
|
+
pasteConfig?: PasteConfig
|
|
94
|
+
onPaste?(event: PasteEvent): D | null
|
|
95
|
+
/** Wait for asynchronous state created by a paste before committing history. */
|
|
96
|
+
waitForPaste?(element: HTMLElement): Promise<void>
|
|
97
|
+
|
|
98
|
+
// ── Conversion ───────────────────────────────────────────────────────────
|
|
99
|
+
/**
|
|
100
|
+
* Return neutral fields that can initialize another block type during a
|
|
101
|
+
* conversion. This is not a search-index hook: preserve meaningful text and
|
|
102
|
+
* safe inline HTML under conventional keys such as `text` where possible.
|
|
103
|
+
*/
|
|
104
|
+
exportData?(element: HTMLElement): Record<string, unknown>
|
|
105
|
+
/**
|
|
106
|
+
* Describe a partial selection using plugin-owned data boundaries.
|
|
107
|
+
* The method must not mutate `element`. The core replaces the source with
|
|
108
|
+
* `remainingData` and creates the target block from `selectedData`. A plugin
|
|
109
|
+
* whose root is not itself `contenteditable="true"` must implement this
|
|
110
|
+
* method to support partial conversion; the generic HTML splitter is used
|
|
111
|
+
* only for a single editable root that serializes to `{ text }`.
|
|
112
|
+
*/
|
|
113
|
+
splitSelection?(element: HTMLElement, range: Range): {
|
|
114
|
+
remainingData: D | null
|
|
115
|
+
selectedData: Record<string, unknown>
|
|
116
|
+
} | null
|
|
117
|
+
|
|
118
|
+
// ── Inline toolbar controls ──────────────────────────────────────────────
|
|
119
|
+
renderInlineControls?(contentElement: HTMLElement, ctx: InlineControlContext): InlineControlGroup | null
|
|
120
|
+
|
|
121
|
+
// ── Inline widget marshalling (text blocks only) ─────────────────────────
|
|
122
|
+
/**
|
|
123
|
+
* Walk every HTML-bearing field in `data` and apply `transform` to each.
|
|
124
|
+
* The core calls this before `render(data)` (to rehydrate placeholder
|
|
125
|
+
* tokens back into widget DOM) and after `save(element)` (to replace
|
|
126
|
+
* committed widget spans with placeholder refs while the core collects
|
|
127
|
+
* an `inline` widget map at the block level).
|
|
128
|
+
*
|
|
129
|
+
* Implement on every block that enables inline tools and stores HTML,
|
|
130
|
+
* including structured blocks with several text fields. Media-only blocks
|
|
131
|
+
* should leave this undefined; the core then skips widget marshalling.
|
|
132
|
+
*
|
|
133
|
+
* `transform` is opaque to the plugin: it hides the tokenize / rehydrate
|
|
134
|
+
* mechanism and the widget registry entirely. The plugin only knows its
|
|
135
|
+
* own data shape and where text lives in it.
|
|
136
|
+
*/
|
|
137
|
+
mapTextFields?(data: D, transform: (html: string) => string): void
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** Runtime services available to a block plugin's interactive handlers. */
|
|
141
|
+
export interface BlockMutationContext {
|
|
142
|
+
/** Execute one synchronous block-local command as one undo/redo step. */
|
|
143
|
+
mutate<T>(operation: () => T): T | undefined
|
|
144
|
+
/** Split the current block through the core structural command pipeline. */
|
|
145
|
+
splitBlock(): void
|
|
146
|
+
/** Convert the current empty non-default block to the default block type. */
|
|
147
|
+
exitEmptyBlock(): boolean
|
|
148
|
+
/**
|
|
149
|
+
* True when document mutations and application side effects are forbidden.
|
|
150
|
+
* A presentation-only button may remain enabled by adding
|
|
151
|
+
* `data-oe-read-only-interactive` to that control.
|
|
152
|
+
*/
|
|
153
|
+
readonly readOnly: boolean
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** Common runtime options consumed by the editor composition root. */
|
|
157
|
+
export interface PluginRuntimeConfig extends Record<string, unknown> {
|
|
158
|
+
/** Disable automatic injection of the plugin constructor's `styles` URLs. */
|
|
159
|
+
injectStyles?: boolean
|
|
160
|
+
/** Additional stylesheet URL injected after the plugin's default styles. */
|
|
161
|
+
css?: string
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/** Static properties on block plugin constructors. */
|
|
165
|
+
export interface BlockPluginConstructor<D extends Record<string, unknown> = Record<string, unknown>> {
|
|
166
|
+
new (): BlockPlugin<D>
|
|
167
|
+
/** CSS stylesheet URLs injected via <link> tags. */
|
|
168
|
+
styles?: string[]
|
|
169
|
+
/** Locale messages per language, merged into i18n on registration. */
|
|
170
|
+
locale?: Record<string, Record<string, LocaleValue>>
|
|
171
|
+
/**
|
|
172
|
+
* Whether this block accepts neutral rich text during conversion and can
|
|
173
|
+
* participate in text-target cross-block conversion. This does not require
|
|
174
|
+
* the plugin root itself to be contenteditable; structured text plugins use
|
|
175
|
+
* `splitSelection()` to describe partial selections.
|
|
176
|
+
*/
|
|
177
|
+
isTextBlock?: boolean
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export interface InlineControlContext {
|
|
181
|
+
/** Call before DOM swaps to prevent toolbar from hiding */
|
|
182
|
+
suppressSelectionChange(): void
|
|
183
|
+
/** Execute one synchronous block-local command as one undo/redo step. */
|
|
184
|
+
mutate<T>(operation: () => T): T
|
|
185
|
+
/** Call after DOM swap when contentElement was replaced (e.g. heading level change) */
|
|
186
|
+
onContentElementChanged(newElement: HTMLElement): void
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export interface InlineControlGroup {
|
|
190
|
+
/** Elements to render in the plugin controls zone (plugin manages its own events) */
|
|
191
|
+
elements: HTMLElement[]
|
|
192
|
+
/** Called when plugin controls are removed from the toolbar */
|
|
193
|
+
destroy?(): void
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export interface ToolboxEntry {
|
|
197
|
+
title: string
|
|
198
|
+
icon: string
|
|
199
|
+
data?: Record<string, unknown>
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// ── Paste ────────────────────────────────────────────────────────────────────
|
|
203
|
+
|
|
204
|
+
export interface PasteConfig {
|
|
205
|
+
/** HTML tags this plugin handles (e.g. ['pre', 'code'], ['h1', 'h2', 'h3']) */
|
|
206
|
+
tags?: string[]
|
|
207
|
+
/** MIME patterns for file paste (e.g. ['image/*', 'application/pdf']) */
|
|
208
|
+
files?: string[]
|
|
209
|
+
/** Regex patterns matched against plain text (e.g. URL detection) */
|
|
210
|
+
patterns?: RegExp[]
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export interface TagPasteEvent {
|
|
214
|
+
type: 'tag'
|
|
215
|
+
/** The original DOM element from parsed clipboard HTML */
|
|
216
|
+
element: HTMLElement
|
|
217
|
+
/** Lowercase tag name */
|
|
218
|
+
tag: string
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export interface FilePasteEvent {
|
|
222
|
+
type: 'file'
|
|
223
|
+
file: File
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export interface PatternPasteEvent {
|
|
227
|
+
type: 'pattern'
|
|
228
|
+
/** The matched text */
|
|
229
|
+
data: string
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export type PasteEvent = TagPasteEvent | FilePasteEvent | PatternPasteEvent
|
|
233
|
+
|
|
234
|
+
// ── Shortcuts ────────────────────────────────────────────────────────────────
|
|
235
|
+
|
|
236
|
+
export interface ShortcutEntry {
|
|
237
|
+
/** Normalized combo: 'Mod+Shift+1', 'Tab', 'Shift+Tab' */
|
|
238
|
+
combo: string
|
|
239
|
+
/** Handler receives the block's content element */
|
|
240
|
+
handler: (contentElement: HTMLElement) => void
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// ── Inline Tool ──────────────────────────────────────────────────────────────
|
|
244
|
+
|
|
245
|
+
export interface InlineTool {
|
|
246
|
+
readonly type: string
|
|
247
|
+
/** Human-readable title for tooltip (e.g. "Bold", "Italic"). Falls back to type. */
|
|
248
|
+
readonly title?: string
|
|
249
|
+
readonly icon: string
|
|
250
|
+
readonly shortcut?: string
|
|
251
|
+
readonly tag?: string
|
|
252
|
+
|
|
253
|
+
isActive(selection: InlineSelection): boolean
|
|
254
|
+
toggle(selection: InlineSelection): void
|
|
255
|
+
/** Optional drill-down panel. Return null to signal toggle() should be called instead. */
|
|
256
|
+
renderActions?(ctx: InlineToolActionContext): HTMLElement | null
|
|
257
|
+
/** Dynamic icon - reflects current state (e.g. alignment direction, link toggle). */
|
|
258
|
+
getIcon?(active: boolean): string
|
|
259
|
+
/** Dynamic title for tooltip (e.g. current alignment name, link/unlink). */
|
|
260
|
+
getTitle?(active: boolean): string
|
|
261
|
+
/** Called after the tool button is mounted in the DOM. */
|
|
262
|
+
onMount?(button: HTMLElement, mutations?: InlineMutationContext): void
|
|
263
|
+
/** Whether the tool's dropdown is currently open (prevents toolbar from hiding). */
|
|
264
|
+
isDropdownOpen?(): boolean
|
|
265
|
+
destroy?(): void
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
export interface InlineMutationContext {
|
|
269
|
+
/** Execute one synchronous range mutation as one undo/redo step. */
|
|
270
|
+
mutate<T>(range: Range, operation: () => T): T
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export interface InlineToolActionContext {
|
|
274
|
+
/** Cloned selection range saved before opening the panel */
|
|
275
|
+
range: Range
|
|
276
|
+
/** Execute a mutation of the saved range as one undo/redo step. */
|
|
277
|
+
mutate<T>(operation: () => T): T
|
|
278
|
+
/** Restore the saved selection (call before applying changes) */
|
|
279
|
+
restoreSelection(): void
|
|
280
|
+
/** Close the actions panel and return to the buttons view */
|
|
281
|
+
close(): void
|
|
282
|
+
/** Show tooltip on an anchor element */
|
|
283
|
+
showTooltip(anchor: HTMLElement, label: string): void
|
|
284
|
+
/** Hide tooltip */
|
|
285
|
+
hideTooltip(): void
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// ── Selection ────────────────────────────────────────────────────────────────
|
|
289
|
+
|
|
290
|
+
export interface CaretPosition {
|
|
291
|
+
blockId: string
|
|
292
|
+
offset: number
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export interface InlineSelection {
|
|
296
|
+
blockId: string
|
|
297
|
+
range: Range
|
|
298
|
+
text: string
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// ── Events ───────────────────────────────────────────────────────────────────
|
|
302
|
+
|
|
303
|
+
export interface EditorEvents {
|
|
304
|
+
'block:added': { blockId: string; index: number }
|
|
305
|
+
'block:removed': { blockId: string; index: number }
|
|
306
|
+
'block:moved': { blockId: string; from: number; to: number }
|
|
307
|
+
'block:converted': { blockId: string; from: string; to: string }
|
|
308
|
+
'block:changed': { blockId: string }
|
|
309
|
+
'block:focused': { blockId: string }
|
|
310
|
+
'block:blurred': { blockId: string }
|
|
311
|
+
'block:selected': { blockIds: string[] }
|
|
312
|
+
'editor:ready': undefined
|
|
313
|
+
'editor:willChange': undefined
|
|
314
|
+
'editor:changed': undefined
|
|
315
|
+
'history:commit': undefined
|
|
316
|
+
'history:changed': { canUndo: boolean; canRedo: boolean }
|
|
317
|
+
'readOnly:changed': { readOnly: boolean }
|
|
318
|
+
'editor:destroyed': undefined
|
|
319
|
+
'toolbar:opened': { type: 'block' | 'inline' }
|
|
320
|
+
'toolbar:closed': { type: 'block' | 'inline' }
|
|
321
|
+
'paste:applied': { startBlockId?: string; endBlockId?: string }
|
|
322
|
+
'dragHandle:clicked': undefined
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// ── Config ───────────────────────────────────────────────────────────────────
|
|
326
|
+
|
|
327
|
+
export interface EditorTuning {
|
|
328
|
+
/** Drag-and-drop — minimum pixel movement before mousedown becomes a drag. */
|
|
329
|
+
drag: { threshold: number }
|
|
330
|
+
/** Undo stack — max history depth and coalescing debounce. */
|
|
331
|
+
undo: { maxStack: number, debounceMs: number }
|
|
332
|
+
/** `onChange` coalescing window for ChangeNotifier. */
|
|
333
|
+
change: { debounceMs: number }
|
|
334
|
+
/** TypeSelector search — minimum plugin count before filter input appears. */
|
|
335
|
+
toolbar: { filterThreshold: number }
|
|
336
|
+
/** Block insert/move/remove animation durations (ms). */
|
|
337
|
+
animations: { blockInsertMs: number, blockMoveMs: number, blockRemoveMs: number }
|
|
338
|
+
/** Width below which the UI switches to mobile layout. Matches CSS media queries. */
|
|
339
|
+
mobileBreakpoint: number
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
export interface BlockValidationIssue {
|
|
343
|
+
blockId: string
|
|
344
|
+
type: string
|
|
345
|
+
data: Record<string, unknown>
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/** One directed, synchronous document-format migration. */
|
|
349
|
+
export interface DocumentMigration {
|
|
350
|
+
from: string
|
|
351
|
+
to: string
|
|
352
|
+
migrate(document: EditorDocument): EditorDocument
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
export type EditorDiagnosticCode =
|
|
356
|
+
| 'command.failed'
|
|
357
|
+
| 'command.slow'
|
|
358
|
+
| 'paste.failed'
|
|
359
|
+
| 'paste.slow'
|
|
360
|
+
| 'migration.applied'
|
|
361
|
+
| 'migration.failed'
|
|
362
|
+
| 'migration.unavailable'
|
|
363
|
+
| 'save.failed'
|
|
364
|
+
| 'save.slow'
|
|
365
|
+
| 'render.slow'
|
|
366
|
+
| 'editor.create.failed'
|
|
367
|
+
| 'cleanup.failed'
|
|
368
|
+
|
|
369
|
+
export interface DiagnosticThresholds {
|
|
370
|
+
commandMs: number
|
|
371
|
+
saveMs: number
|
|
372
|
+
renderMs: number
|
|
373
|
+
pasteMs: number
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/** Content-free operational signal. No document/plugin payload is exposed. */
|
|
377
|
+
export interface EditorDiagnostic {
|
|
378
|
+
code: EditorDiagnosticCode
|
|
379
|
+
timestamp: number
|
|
380
|
+
durationMs?: number
|
|
381
|
+
operation?: string
|
|
382
|
+
pluginType?: string
|
|
383
|
+
blockType?: string
|
|
384
|
+
fromVersion?: string
|
|
385
|
+
toVersion?: string
|
|
386
|
+
errorName?: string
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
export interface EditorConfig {
|
|
390
|
+
holder: HTMLElement
|
|
391
|
+
plugins: BlockPlugin[]
|
|
392
|
+
/** Custom inline tools. String types filter defaults, objects are used as-is. If omitted, all defaults are used. */
|
|
393
|
+
inlineTools?: Array<string | InlineTool>
|
|
394
|
+
/** Inline plugins (widgets inside text: color swatch, mention, etc.) */
|
|
395
|
+
inlinePlugins?: InlinePlugin[]
|
|
396
|
+
data?: EditorDocument
|
|
397
|
+
/** Ordered through `from`/`to` links before initial load and every render(). */
|
|
398
|
+
migrations?: DocumentMigration[]
|
|
399
|
+
/** Apply reachable migrations; strict also requires a complete path to the current version. */
|
|
400
|
+
documentVersionPolicy?: 'preserve' | 'strict'
|
|
401
|
+
readOnly?: boolean
|
|
402
|
+
placeholder?: string
|
|
403
|
+
autofocus?: boolean
|
|
404
|
+
minHeight?: number
|
|
405
|
+
defaultBlock?: string
|
|
406
|
+
/** Full locale dictionary (core + all plugins). Pass the aggregated
|
|
407
|
+
* object from `locale/ru.js` etc. Defaults to built-in English.
|
|
408
|
+
* Include `__lang: 'ru'` key for automatic plural rule selection. */
|
|
409
|
+
locale?: Record<string, LocaleValue>
|
|
410
|
+
/** UX/behavior tuning knobs. Merged onto `DEFAULT_TUNING`. */
|
|
411
|
+
tuning?: DeepPartial<EditorTuning>
|
|
412
|
+
onChange?: (data: EditorDocument) => void
|
|
413
|
+
onReady?: () => void
|
|
414
|
+
/** Preserve invalid blocks by default; strict mode rejects save. */
|
|
415
|
+
validationMode?: 'preserve' | 'strict'
|
|
416
|
+
/** Receives validation diagnostics without changing the saved document. */
|
|
417
|
+
onValidationError?: (issue: BlockValidationIssue) => void
|
|
418
|
+
/** Opt-in, content-free operational diagnostics. Disabled when omitted. */
|
|
419
|
+
onDiagnostic?: (diagnostic: EditorDiagnostic) => void
|
|
420
|
+
/** Slow-operation thresholds; omitted values do not emit timing diagnostics. */
|
|
421
|
+
diagnosticThresholds?: Partial<DiagnosticThresholds>
|
|
422
|
+
theme?: string
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
type DeepPartial<T> = T extends object ? { [K in keyof T]?: DeepPartial<T[K]> } : T
|
|
426
|
+
|
|
427
|
+
// ── I18n ─────────────────────────────────────────────────────────────────────
|
|
428
|
+
|
|
429
|
+
import enLocale from './locale/en.js'
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* CLDR plural categories. Locales declare which forms are populated based on
|
|
433
|
+
* their language rules (e.g. English uses `one`/`other`, Russian uses
|
|
434
|
+
* `one`/`few`/`many`).
|
|
435
|
+
*/
|
|
436
|
+
// The shared PluralForms type is re-exported above.
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* A locale entry — either a plain string (with optional `{name}` placeholders)
|
|
440
|
+
* or a plural-form object (selected by `i18n.plural(key, count)`).
|
|
441
|
+
*/
|
|
442
|
+
// The shared LocaleValue type is re-exported above.
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Built-in editor messages, auto-derived from the core English locale.
|
|
446
|
+
* Includes only the keys defined in `core/locale/en.js`.
|
|
447
|
+
* @internal
|
|
448
|
+
*/
|
|
449
|
+
type CoreMessages = { [K in keyof typeof enLocale]: LocaleValue }
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* Translation message dictionary.
|
|
453
|
+
*
|
|
454
|
+
* Plugins extend this interface via TypeScript declaration merging,
|
|
455
|
+
* deriving their keys from their own `locale/en.js` file. Each plugin
|
|
456
|
+
* keeps a `locale/keys.d.ts` file alongside its locale data.
|
|
457
|
+
*
|
|
458
|
+
* **Type-safety is best-effort**, not strict — the union of `MessageKey` is
|
|
459
|
+
* built at compile time from declaration-merged plugins, but the runtime
|
|
460
|
+
* dictionary contains only the plugins actually passed to `createEditor`.
|
|
461
|
+
* `i18n.t()` accepts both known `MessageKey` values (for autocomplete) and
|
|
462
|
+
* arbitrary `string` (for forward compatibility), and emits a runtime warning
|
|
463
|
+
* when a key is missing.
|
|
464
|
+
*
|
|
465
|
+
* @example
|
|
466
|
+
* // core/plugins/myPlugin/locale/keys.d.ts
|
|
467
|
+
* import enLocale from './en.js'
|
|
468
|
+
* declare module '../../../types' {
|
|
469
|
+
* interface I18nMessages extends Record<keyof typeof enLocale, LocaleValue> {}
|
|
470
|
+
* }
|
|
471
|
+
*/
|
|
472
|
+
export interface I18nMessages extends CoreMessages {}
|
|
473
|
+
|
|
474
|
+
/** Union of all known message keys (core + every loaded plugin). */
|
|
475
|
+
export type MessageKey = keyof I18nMessages
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* Plugin-facing i18n surface — auto-prefixes every key with the plugin's
|
|
479
|
+
* namespace. Backward-compatible with full keys (passed through untouched).
|
|
480
|
+
*/
|
|
481
|
+
export interface IScopedI18n {
|
|
482
|
+
t(key: string, params?: Record<string, string | number>): string
|
|
483
|
+
has(key: string): boolean
|
|
484
|
+
plural(key: string, count: number, params?: Record<string, string | number>): string
|
|
485
|
+
scope(sub: string): IScopedI18n
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
// ── Block Instance ───────────────────────────────────────────────────────────
|
|
489
|
+
|
|
490
|
+
export interface IBlock {
|
|
491
|
+
readonly id: string
|
|
492
|
+
readonly type: string
|
|
493
|
+
readonly plugin: BlockPlugin
|
|
494
|
+
readonly element: HTMLElement
|
|
495
|
+
readonly contentElement: HTMLElement
|
|
496
|
+
readonly hasInlineTools: boolean
|
|
497
|
+
/** Explicit per-block allowlist, or null when the editor-wide set applies. */
|
|
498
|
+
readonly inlineToolTypes: readonly string[] | null
|
|
499
|
+
/** Whether this block's plugin supports merge. */
|
|
500
|
+
readonly canMerge: boolean
|
|
501
|
+
readonly version: number
|
|
502
|
+
focused: boolean
|
|
503
|
+
selected: boolean
|
|
504
|
+
|
|
505
|
+
save(): BlockData
|
|
506
|
+
merge(data: Record<string, unknown>): void
|
|
507
|
+
markDirty(): void
|
|
508
|
+
/** Replace the content element with a new one, updating the DOM. */
|
|
509
|
+
replaceContentElement(newEl: HTMLElement): void
|
|
510
|
+
/** Clean up the plugin without removing the block element from DOM. */
|
|
511
|
+
disposePlugin(): void
|
|
512
|
+
/** Focus the first editable or focusable element within the block. */
|
|
513
|
+
focus(): void
|
|
514
|
+
destroy(): void
|
|
515
|
+
/** Delegates to plugin.isEmpty() if defined, else checks textContent. */
|
|
516
|
+
isEmpty(): boolean
|
|
517
|
+
/** Get the block's settings UI (if plugin provides one). */
|
|
518
|
+
renderSettings(): HTMLElement | HTMLElement[] | null
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
// ── Narrow Dependency Interfaces (DIP) ───────────────────────────────────────
|
|
522
|
+
|
|
523
|
+
/** Read-only block access. For modules that query but don't mutate. */
|
|
524
|
+
export interface IBlockReader {
|
|
525
|
+
getBlockByIndex(index: number): IBlock | undefined
|
|
526
|
+
getBlockById(id: string): IBlock | undefined
|
|
527
|
+
getBlockByChildNode(node: DOMNode): IBlock | undefined
|
|
528
|
+
getBlockByY(y: number): IBlock | undefined
|
|
529
|
+
getCurrentBlock(): IBlock | undefined
|
|
530
|
+
getCurrentIndex(): number
|
|
531
|
+
getBlockCount(): number
|
|
532
|
+
getBlockIndex(id: string): number
|
|
533
|
+
/** Get all blocks in selected state. */
|
|
534
|
+
getSelectedBlocks(): IBlock[]
|
|
535
|
+
/** Check if any blocks are in selected state. */
|
|
536
|
+
hasSelectedBlocks(): boolean
|
|
537
|
+
[Symbol.iterator](): Iterator<IBlock>
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
/** Full block CRUD. Extends IBlockReader. */
|
|
541
|
+
export interface IBlockManager extends IBlockReader {
|
|
542
|
+
setReadOnly(readOnly: boolean): void
|
|
543
|
+
insert(
|
|
544
|
+
type: string,
|
|
545
|
+
data?: Record<string, unknown>,
|
|
546
|
+
index?: number,
|
|
547
|
+
id?: string,
|
|
548
|
+
inline?: Record<string, EditorInlineWidget>,
|
|
549
|
+
): IBlock
|
|
550
|
+
prepareReplacement(blockList: BlockData[] | undefined, defaultBlockType: string, logPrefix?: string): {
|
|
551
|
+
blocks: readonly IBlock[]
|
|
552
|
+
commit(options?: { notifyChange?: boolean }): void
|
|
553
|
+
dispose(): void
|
|
554
|
+
}
|
|
555
|
+
remove(index: number): void
|
|
556
|
+
move(fromIndex: number, toIndex: number): void
|
|
557
|
+
convert(index: number, newType: string, extraData?: Record<string, unknown>): IBlock | undefined
|
|
558
|
+
setCurrentIndex(index: number): void
|
|
559
|
+
/** Clear selection state from all blocks. */
|
|
560
|
+
clearSelection(): void
|
|
561
|
+
/** Remove all selected blocks; insert defaultBlockType if none remain. */
|
|
562
|
+
removeSelected(defaultBlockType: string): { focusIndex: number } | null
|
|
563
|
+
clear(): void
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
export interface ISelectionManager {
|
|
567
|
+
getCaret(): CaretPosition | null
|
|
568
|
+
setCaretToBlock(blockId: string, position: 'start' | 'end'): void
|
|
569
|
+
setCaretToOffset(blockId: string, textOffset: number): void
|
|
570
|
+
getSelection(): InlineSelection | null
|
|
571
|
+
isAtStart(): boolean
|
|
572
|
+
isAtEnd(): boolean
|
|
573
|
+
extractFragmentAfterCaret(): string | null
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
/** Block-level structural operations (split, merge, navigate). */
|
|
577
|
+
export interface IBlockOperations {
|
|
578
|
+
splitBlock(): void
|
|
579
|
+
exitEmptyBlock(): boolean
|
|
580
|
+
mergeWithPrevious(): boolean
|
|
581
|
+
mergeWithNext(): boolean
|
|
582
|
+
navigateToPrevious(): boolean
|
|
583
|
+
navigateToNext(): boolean
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
export interface IEventBus {
|
|
587
|
+
on(event: string, handler: (data?: any) => void): () => void
|
|
588
|
+
off(event: string, handler: (data?: any) => void): void
|
|
589
|
+
once(event: string, handler: (data?: any) => void): () => void
|
|
590
|
+
emit(event: string, data?: unknown): void
|
|
591
|
+
clear(event?: string): void
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
// ── Cross-Block Selection ────────────────────────────────────────────────────
|
|
595
|
+
|
|
596
|
+
export interface ICrossBlockSelection {
|
|
597
|
+
readonly range: Range | null
|
|
598
|
+
set(range: Range): void
|
|
599
|
+
clear(): void
|
|
600
|
+
clone(): Range | null
|
|
601
|
+
activate(range: Range, rootEl: HTMLElement): void
|
|
602
|
+
deactivate(rootEl?: HTMLElement): void
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
// ── Public Editor API ────────────────────────────────────────────────────────
|
|
606
|
+
|
|
607
|
+
/** Public block handle without manager-integrity mutation methods. */
|
|
608
|
+
export interface EditorBlockView {
|
|
609
|
+
readonly id: string
|
|
610
|
+
readonly type: string
|
|
611
|
+
readonly element: HTMLElement
|
|
612
|
+
readonly contentElement: HTMLElement
|
|
613
|
+
readonly focused: boolean
|
|
614
|
+
readonly selected: boolean
|
|
615
|
+
readonly hasInlineTools: boolean
|
|
616
|
+
readonly canMerge: boolean
|
|
617
|
+
readonly version: number
|
|
618
|
+
focus(): void
|
|
619
|
+
isEmpty(): boolean
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
/** Intentional public query/command surface for document blocks. */
|
|
623
|
+
export interface EditorBlocksApi {
|
|
624
|
+
getBlockByIndex(index: number): EditorBlockView | undefined
|
|
625
|
+
getBlockById(id: string): EditorBlockView | undefined
|
|
626
|
+
getCurrentBlock(): EditorBlockView | undefined
|
|
627
|
+
getCurrentIndex(): number
|
|
628
|
+
getBlockCount(): number
|
|
629
|
+
getBlockIndex(id: string): number
|
|
630
|
+
getSelectedBlocks(): EditorBlockView[]
|
|
631
|
+
hasSelectedBlocks(): boolean
|
|
632
|
+
setCurrentIndex(index: number): void
|
|
633
|
+
selectBlocks(blockIds: string[]): void
|
|
634
|
+
clearSelection(): void
|
|
635
|
+
insert(
|
|
636
|
+
type: string,
|
|
637
|
+
data?: Record<string, unknown>,
|
|
638
|
+
index?: number,
|
|
639
|
+
id?: string,
|
|
640
|
+
inline?: Record<string, EditorInlineWidget>,
|
|
641
|
+
): EditorBlockView | undefined
|
|
642
|
+
remove(index: number): void
|
|
643
|
+
move(fromIndex: number, toIndex: number): void
|
|
644
|
+
convert(index: number, type: string, data?: Record<string, unknown>): EditorBlockView | undefined
|
|
645
|
+
[Symbol.iterator](): Iterator<EditorBlockView>
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
/** Subscription-only editor event API. */
|
|
649
|
+
export interface EditorEventSubscriptions {
|
|
650
|
+
on<K extends keyof EditorEvents>(event: K, handler: (data: EditorEvents[K]) => void): () => void
|
|
651
|
+
off<K extends keyof EditorEvents>(event: K, handler: (data: EditorEvents[K]) => void): void
|
|
652
|
+
once<K extends keyof EditorEvents>(event: K, handler: (data: EditorEvents[K]) => void): () => void
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
export interface IEditor {
|
|
656
|
+
save(): EditorDocument
|
|
657
|
+
render(data: EditorDocument): void
|
|
658
|
+
clear(): void
|
|
659
|
+
focus(): void
|
|
660
|
+
/**
|
|
661
|
+
* Restore exactly one previous committed history step.
|
|
662
|
+
* Returns false when the undo stack is empty or the editor is read-only.
|
|
663
|
+
*/
|
|
664
|
+
undo(): boolean
|
|
665
|
+
/**
|
|
666
|
+
* Restore exactly one next committed history step.
|
|
667
|
+
* Returns false when the redo stack is empty or the editor is read-only.
|
|
668
|
+
*/
|
|
669
|
+
redo(): boolean
|
|
670
|
+
/** Switch the live instance between interactive editing and read-only display. */
|
|
671
|
+
setReadOnly(readOnly: boolean): void
|
|
672
|
+
insertInlinePlugin(type: string, data?: Record<string, string>): boolean
|
|
673
|
+
destroy(): void
|
|
674
|
+
/** Remains readable after destroy() and then returns false. */
|
|
675
|
+
readonly isReady: boolean
|
|
676
|
+
readonly readOnly: boolean
|
|
677
|
+
/** Whether undo() can currently restore a step; false while read-only. */
|
|
678
|
+
readonly canUndo: boolean
|
|
679
|
+
/** Whether redo() can currently restore a step; false while read-only. */
|
|
680
|
+
readonly canRedo: boolean
|
|
681
|
+
readonly blocks: EditorBlocksApi
|
|
682
|
+
readonly events: EditorEventSubscriptions
|
|
683
|
+
readonly rootElement: HTMLElement
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
// ── Inline Plugins ───────────────────────────────────────────────────────────
|
|
687
|
+
|
|
688
|
+
export interface InlinePlugin extends BasePlugin {
|
|
689
|
+
/** Optional activation trigger. Must contain exactly one Unicode code point. */
|
|
690
|
+
readonly trigger?: string
|
|
691
|
+
/** Patterns that auto-convert pasted/typed text into this widget. */
|
|
692
|
+
readonly pasteConfig?: { patterns: RegExp[] }
|
|
693
|
+
/** Extract widget data from a matched pattern string. */
|
|
694
|
+
onPatternMatch?(match: string): Record<string, string>
|
|
695
|
+
|
|
696
|
+
/**
|
|
697
|
+
* Build a live widget DOM from saved data. `id` is the widget's stable
|
|
698
|
+
* instance identity (an `{{id}}` placeholder references it). When
|
|
699
|
+
* provided, the factory MUST set it on the root element as `data-id`;
|
|
700
|
+
* when omitted, the factory generates a fresh id (via `generateInlineId`).
|
|
701
|
+
*/
|
|
702
|
+
createWidget(data: Record<string, string>, id?: string): HTMLElement
|
|
703
|
+
/** Acquire editor-scoped resources after the editor root and context exist. */
|
|
704
|
+
mount?(rootElement: HTMLElement, ctx: InlinePluginContext): void
|
|
705
|
+
hydrate(element: HTMLElement, ctx: InlinePluginContext): void
|
|
706
|
+
getData(element: HTMLElement): Record<string, string>
|
|
707
|
+
/** Return false for an in-progress widget that must be serialized as plain text. */
|
|
708
|
+
isCommitted?(element: HTMLElement): boolean
|
|
709
|
+
onEdit?(element: HTMLElement, text: string, ctx: InlinePluginContext): void
|
|
710
|
+
/** Called when the editor cancels an active trigger session. */
|
|
711
|
+
onCancel?(): void
|
|
712
|
+
onCommit?(element: HTMLElement, data: Record<string, string>): void
|
|
713
|
+
destroy?(): void
|
|
714
|
+
|
|
715
|
+
/**
|
|
716
|
+
* Optional custom insertion hook for programmatic "+" (toolbox) clicks.
|
|
717
|
+
*
|
|
718
|
+
* When defined, `insertInlinePluginAtCaret` calls this INSTEAD of the
|
|
719
|
+
* default `createWidget`-based flow. Useful for trigger-based plugins
|
|
720
|
+
* (mention, hashtag, …) that want `+` to feel exactly like typing the
|
|
721
|
+
* trigger character manually — inserting just the trigger text and
|
|
722
|
+
* letting the usual onEdit / dropdown flow take over from there.
|
|
723
|
+
*/
|
|
724
|
+
insertFresh?(ctx: InlinePluginContext): void
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
export interface InlinePluginContext {
|
|
728
|
+
/** Current editor interaction mode. Mutation methods are inert when true. */
|
|
729
|
+
readonly readOnly: boolean
|
|
730
|
+
showPopup(anchor: HTMLElement, content: HTMLElement, cleanup?: () => void): void
|
|
731
|
+
hidePopup(): void
|
|
732
|
+
/** Execute one widget-local command as one undo/redo step. */
|
|
733
|
+
mutate<T>(target: DOMNode, operation: () => T): T | undefined
|
|
734
|
+
notifyChanged(target?: DOMNode): void
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
export interface IInlinePluginRegistry {
|
|
738
|
+
register(plugin: InlinePlugin): void
|
|
739
|
+
get(type: string): InlinePlugin | undefined
|
|
740
|
+
getByTrigger(char: string): InlinePlugin | undefined
|
|
741
|
+
values(): IterableIterator<InlinePlugin>
|
|
742
|
+
readonly size: number
|
|
743
|
+
readonly hasTriggers: boolean
|
|
744
|
+
mount(rootElement: HTMLElement, ctx: InlinePluginContext): void
|
|
745
|
+
triggerKeys(): string[]
|
|
746
|
+
destroy(): void
|
|
747
|
+
}
|