@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,238 @@
|
|
|
1
|
+
import { EditorEvent } from './editorEvents.js'
|
|
2
|
+
|
|
3
|
+
/** @typedef {import('./types').IBlockOperations} IBlockOperationsContract */
|
|
4
|
+
/** @implements {IBlockOperationsContract} */
|
|
5
|
+
export class BlockOperations {
|
|
6
|
+
/** @type {import('./types').IBlockManager} */
|
|
7
|
+
#blocks
|
|
8
|
+
|
|
9
|
+
/** @type {import('./types').ISelectionManager} */
|
|
10
|
+
#selection
|
|
11
|
+
|
|
12
|
+
/** @type {string} */
|
|
13
|
+
#defaultBlockType
|
|
14
|
+
|
|
15
|
+
/** @type {import('./types').IEventBus} */
|
|
16
|
+
#events
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @param {import('./types').IBlockManager} blocks
|
|
20
|
+
* @param {import('./types').ISelectionManager} selection
|
|
21
|
+
* @param {string} defaultBlockType
|
|
22
|
+
* @param {import('./types').IEventBus} events
|
|
23
|
+
*/
|
|
24
|
+
constructor(blocks, selection, defaultBlockType, events) {
|
|
25
|
+
this.#blocks = blocks
|
|
26
|
+
this.#selection = selection
|
|
27
|
+
this.#defaultBlockType = defaultBlockType
|
|
28
|
+
this.#events = events
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Insert a new block, set it as current, place the caret, and focus.
|
|
33
|
+
* @param {string} type
|
|
34
|
+
* @param {Record<string, unknown>} [data]
|
|
35
|
+
* @param {number} [index]
|
|
36
|
+
* @param {'start' | 'end'} [caretPosition='start']
|
|
37
|
+
* @returns {import('./types').IBlock}
|
|
38
|
+
*/
|
|
39
|
+
insertAndFocus(type, data, index, caretPosition = 'start') {
|
|
40
|
+
const newBlock = this.#blocks.insert(type, data, index)
|
|
41
|
+
const newIndex = this.#blocks.getBlockIndex(newBlock.id)
|
|
42
|
+
this.#blocks.setCurrentIndex(newIndex)
|
|
43
|
+
this.#selection.setCaretToBlock(newBlock.id, caretPosition)
|
|
44
|
+
newBlock.focus()
|
|
45
|
+
return newBlock
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* If the current block is empty and of the default type, convert it in place.
|
|
50
|
+
* Otherwise, insert a new block after it. Focuses the result.
|
|
51
|
+
* @param {string} type
|
|
52
|
+
* @param {Record<string, unknown>} [data]
|
|
53
|
+
* @param {'start' | 'end'} [caretPosition='start']
|
|
54
|
+
* @returns {import('./types').IBlock}
|
|
55
|
+
*/
|
|
56
|
+
replaceEmptyOrInsert(type, data, caretPosition = 'start') {
|
|
57
|
+
const currentIndex = this.#blocks.getCurrentIndex()
|
|
58
|
+
const currentBlock = this.#blocks.getBlockByIndex(currentIndex)
|
|
59
|
+
|
|
60
|
+
if (currentBlock?.isEmpty()
|
|
61
|
+
&& currentBlock.type === this.#defaultBlockType
|
|
62
|
+
&& currentBlock.type !== type) {
|
|
63
|
+
const converted = this.#blocks.convert(currentIndex, type, data)
|
|
64
|
+
if (converted) {
|
|
65
|
+
this.#blocks.setCurrentIndex(currentIndex)
|
|
66
|
+
this.#selection.setCaretToBlock(converted.id, caretPosition)
|
|
67
|
+
converted.focus()
|
|
68
|
+
return converted
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return this.insertAndFocus(type, data, currentIndex + 1, caretPosition)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Split the current block at the caret position (Enter key).
|
|
77
|
+
* Extracts content after caret into a new block of the same type.
|
|
78
|
+
*/
|
|
79
|
+
splitBlock() {
|
|
80
|
+
const blocks = this.#blocks
|
|
81
|
+
const current = blocks.getCurrentBlock()
|
|
82
|
+
if (!current) return
|
|
83
|
+
|
|
84
|
+
this.#events.emit(EditorEvent.UNDO_BATCH_START)
|
|
85
|
+
try {
|
|
86
|
+
const fragmentHtml = this.#selection.extractFragmentAfterCaret()
|
|
87
|
+
current.markDirty()
|
|
88
|
+
this.#events.emit(EditorEvent.BLOCK_CHANGED, { blockId: current.id })
|
|
89
|
+
|
|
90
|
+
const currentIndex = blocks.getCurrentIndex()
|
|
91
|
+
const data = fragmentHtml ? { text: fragmentHtml } : {}
|
|
92
|
+
this.insertAndFocus(this.#defaultBlockType, data, currentIndex + 1)
|
|
93
|
+
} finally {
|
|
94
|
+
this.#events.emit(EditorEvent.UNDO_BATCH_END)
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Convert the current empty non-default block to the configured default
|
|
100
|
+
* block and preserve focus. This is the common "exit block" operation used
|
|
101
|
+
* by list-like plugins and by Backspace handling.
|
|
102
|
+
* @returns {boolean} Whether a block was converted.
|
|
103
|
+
*/
|
|
104
|
+
exitEmptyBlock() {
|
|
105
|
+
const current = this.#blocks.getCurrentBlock()
|
|
106
|
+
if (!current || !current.isEmpty() || current.type === this.#defaultBlockType) return false
|
|
107
|
+
|
|
108
|
+
const index = this.#blocks.getCurrentIndex()
|
|
109
|
+
const converted = this.#blocks.convert(index, this.#defaultBlockType)
|
|
110
|
+
if (!converted) return false
|
|
111
|
+
|
|
112
|
+
this.#blocks.setCurrentIndex(index)
|
|
113
|
+
converted.focus()
|
|
114
|
+
this.#selection.setCaretToBlock(converted.id, 'start')
|
|
115
|
+
return true
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Merge the current block with the previous one (Backspace at start).
|
|
120
|
+
* If current block is empty — removes it and focuses previous.
|
|
121
|
+
* If both are the same type and support merge — merges content.
|
|
122
|
+
* @returns {boolean} Whether the merge was handled
|
|
123
|
+
*/
|
|
124
|
+
mergeWithPrevious() {
|
|
125
|
+
if (!this.#selection.isAtStart()) return false
|
|
126
|
+
|
|
127
|
+
const blocks = this.#blocks
|
|
128
|
+
const currentIndex = blocks.getCurrentIndex()
|
|
129
|
+
if (currentIndex <= 0) return false
|
|
130
|
+
|
|
131
|
+
const current = blocks.getCurrentBlock()
|
|
132
|
+
const prev = blocks.getBlockByIndex(currentIndex - 1)
|
|
133
|
+
if (!current || !prev) return false
|
|
134
|
+
|
|
135
|
+
if (current.isEmpty()) {
|
|
136
|
+
blocks.remove(currentIndex)
|
|
137
|
+
blocks.setCurrentIndex(currentIndex - 1)
|
|
138
|
+
this.#selection.setCaretToBlock(prev.id, 'end')
|
|
139
|
+
prev.focus()
|
|
140
|
+
return true
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (prev.type === current.type && prev.canMerge) {
|
|
144
|
+
this.#events.emit(EditorEvent.UNDO_BATCH_START)
|
|
145
|
+
try {
|
|
146
|
+
const currentData = current.save().data
|
|
147
|
+
const mergeOffset = prev.contentElement.textContent?.length ?? 0
|
|
148
|
+
prev.merge(currentData)
|
|
149
|
+
blocks.remove(currentIndex)
|
|
150
|
+
blocks.setCurrentIndex(currentIndex - 1)
|
|
151
|
+
prev.focus()
|
|
152
|
+
const actualLength = prev.contentElement.textContent?.length ?? 0
|
|
153
|
+
this.#selection.setCaretToOffset(prev.id, Math.min(mergeOffset, actualLength))
|
|
154
|
+
} finally {
|
|
155
|
+
this.#events.emit(EditorEvent.UNDO_BATCH_END)
|
|
156
|
+
}
|
|
157
|
+
return true
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return false
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Merge the next block into the current one (Delete at end).
|
|
165
|
+
* If next block is empty - removes it.
|
|
166
|
+
* If both are the same type and support merge - merges content.
|
|
167
|
+
* @returns {boolean} Whether the merge was handled
|
|
168
|
+
*/
|
|
169
|
+
mergeWithNext() {
|
|
170
|
+
if (!this.#selection.isAtEnd()) return false
|
|
171
|
+
|
|
172
|
+
const blocks = this.#blocks
|
|
173
|
+
const currentIndex = blocks.getCurrentIndex()
|
|
174
|
+
const current = blocks.getCurrentBlock()
|
|
175
|
+
const next = blocks.getBlockByIndex(currentIndex + 1)
|
|
176
|
+
if (!current || !next) return false
|
|
177
|
+
|
|
178
|
+
if (next.isEmpty()) {
|
|
179
|
+
blocks.remove(currentIndex + 1)
|
|
180
|
+
return true
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (current.type === next.type && current.canMerge) {
|
|
184
|
+
this.#events.emit(EditorEvent.UNDO_BATCH_START)
|
|
185
|
+
try {
|
|
186
|
+
const nextData = next.save().data
|
|
187
|
+
const mergeOffset = current.contentElement.textContent?.length ?? 0
|
|
188
|
+
current.merge(nextData)
|
|
189
|
+
blocks.remove(currentIndex + 1)
|
|
190
|
+
const actualLength = current.contentElement.textContent?.length ?? 0
|
|
191
|
+
this.#selection.setCaretToOffset(current.id, Math.min(mergeOffset, actualLength))
|
|
192
|
+
} finally {
|
|
193
|
+
this.#events.emit(EditorEvent.UNDO_BATCH_END)
|
|
194
|
+
}
|
|
195
|
+
return true
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return false
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Move the caret to the end of the previous block (ArrowUp at start).
|
|
203
|
+
* @returns {boolean} Whether navigation happened
|
|
204
|
+
*/
|
|
205
|
+
navigateToPrevious() {
|
|
206
|
+
if (!this.#selection.isAtStart()) return false
|
|
207
|
+
|
|
208
|
+
const blocks = this.#blocks
|
|
209
|
+
const currentIndex = blocks.getCurrentIndex()
|
|
210
|
+
if (currentIndex <= 0) return false
|
|
211
|
+
|
|
212
|
+
const prev = blocks.getBlockByIndex(currentIndex - 1)
|
|
213
|
+
if (!prev) return false
|
|
214
|
+
|
|
215
|
+
blocks.setCurrentIndex(currentIndex - 1)
|
|
216
|
+
this.#selection.setCaretToBlock(prev.id, 'end')
|
|
217
|
+
prev.focus()
|
|
218
|
+
return true
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Move the caret to the start of the next block (ArrowDown at end).
|
|
223
|
+
* @returns {boolean} Whether navigation happened
|
|
224
|
+
*/
|
|
225
|
+
navigateToNext() {
|
|
226
|
+
if (!this.#selection.isAtEnd()) return false
|
|
227
|
+
|
|
228
|
+
const blocks = this.#blocks
|
|
229
|
+
const currentIndex = blocks.getCurrentIndex()
|
|
230
|
+
const next = blocks.getBlockByIndex(currentIndex + 1)
|
|
231
|
+
if (!next) return false
|
|
232
|
+
|
|
233
|
+
blocks.setCurrentIndex(currentIndex + 1)
|
|
234
|
+
this.#selection.setCaretToBlock(next.id, 'start')
|
|
235
|
+
next.focus()
|
|
236
|
+
return true
|
|
237
|
+
}
|
|
238
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Debounced change notification.
|
|
3
|
+
* Calls the onChange callback after a quiet period following editor changes.
|
|
4
|
+
*/
|
|
5
|
+
export class ChangeNotifier {
|
|
6
|
+
/**
|
|
7
|
+
* @param {() => import('./types.js').EditorDocument | Promise<import('./types.js').EditorDocument>} saveFn
|
|
8
|
+
* @param {((data: import('./types.js').EditorDocument) => void)} [onChange]
|
|
9
|
+
* @param {number} [delay]
|
|
10
|
+
*/
|
|
11
|
+
constructor(saveFn: () => import("./types.js").EditorDocument | Promise<import("./types.js").EditorDocument>, onChange?: ((data: import("./types.js").EditorDocument) => void), delay?: number);
|
|
12
|
+
schedule(): void;
|
|
13
|
+
destroy(): void;
|
|
14
|
+
#private;
|
|
15
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Debounced change notification.
|
|
3
|
+
* Calls the onChange callback after a quiet period following editor changes.
|
|
4
|
+
*/
|
|
5
|
+
export class ChangeNotifier {
|
|
6
|
+
/** @type {ReturnType<typeof setTimeout> | null} */
|
|
7
|
+
#timer = null
|
|
8
|
+
|
|
9
|
+
/** @type {() => import('./types').EditorDocument | Promise<import('./types').EditorDocument>} */
|
|
10
|
+
#saveFn
|
|
11
|
+
|
|
12
|
+
/** @type {((data: import('./types').EditorDocument) => void) | undefined} */
|
|
13
|
+
#onChange
|
|
14
|
+
|
|
15
|
+
/** @type {number} */
|
|
16
|
+
#delay
|
|
17
|
+
|
|
18
|
+
/** @type {boolean} */
|
|
19
|
+
#destroyed = false
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @param {() => import('./types').EditorDocument | Promise<import('./types').EditorDocument>} saveFn
|
|
23
|
+
* @param {((data: import('./types').EditorDocument) => void)} [onChange]
|
|
24
|
+
* @param {number} [delay]
|
|
25
|
+
*/
|
|
26
|
+
constructor(saveFn, onChange, delay = 250) {
|
|
27
|
+
this.#saveFn = saveFn
|
|
28
|
+
this.#onChange = onChange
|
|
29
|
+
this.#delay = delay
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
schedule() {
|
|
33
|
+
if (this.#destroyed || !this.#onChange) return
|
|
34
|
+
if (this.#timer) clearTimeout(this.#timer)
|
|
35
|
+
this.#timer = setTimeout(async () => {
|
|
36
|
+
this.#timer = null
|
|
37
|
+
if (this.#onChange) {
|
|
38
|
+
try {
|
|
39
|
+
const data = await this.#saveFn()
|
|
40
|
+
if (!this.#destroyed) this.#onChange?.(data)
|
|
41
|
+
} catch (err) {
|
|
42
|
+
console.warn('[ChangeNotifier] Failed to save:', err)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}, this.#delay)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
destroy() {
|
|
49
|
+
this.#destroyed = true
|
|
50
|
+
if (this.#timer) {
|
|
51
|
+
clearTimeout(this.#timer)
|
|
52
|
+
this.#timer = null
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single execution boundary for editor commands.
|
|
3
|
+
*
|
|
4
|
+
* Commands may provide a cheap inverse rollback. Otherwise, the dispatcher
|
|
5
|
+
* restores the canonical pre-command checkpoint configured by the composition
|
|
6
|
+
* root. Nested commands join the outer command and produce one history entry.
|
|
7
|
+
*/
|
|
8
|
+
export class CommandDispatcher {
|
|
9
|
+
/**
|
|
10
|
+
* @param {import('./types.js').IBlockManager} blocks Block manager whose
|
|
11
|
+
* affected instances are marked dirty after a successful command.
|
|
12
|
+
* @param {import('./types.js').IEventBus} events Event bus used to delimit
|
|
13
|
+
* document changes and history transactions.
|
|
14
|
+
* @param {import('./Diagnostics.js').Diagnostics} [diagnostics] Optional
|
|
15
|
+
* diagnostics sink for failed and slow commands.
|
|
16
|
+
*/
|
|
17
|
+
constructor(blocks: import("./types.js").IBlockManager, events: import("./types.js").IEventBus, diagnostics?: import("./Diagnostics.js").Diagnostics);
|
|
18
|
+
/** Configure the canonical fallback used when a command throws. */
|
|
19
|
+
configureRollback(capture: any, restore: any): void;
|
|
20
|
+
get active(): boolean;
|
|
21
|
+
runForRange(range: any, operation: any): any;
|
|
22
|
+
runForBlock(block: any, operation: any): any;
|
|
23
|
+
runForBlocks(blocks: any, operation: any): any;
|
|
24
|
+
/** Commit a mutation performed by an integration callback outside execute(). */
|
|
25
|
+
commitExternal(block: any): void;
|
|
26
|
+
/** Commit a callback that already changed a known set of blocks. */
|
|
27
|
+
commitExternalMany(blocks: any): void;
|
|
28
|
+
/**
|
|
29
|
+
* Execute a command object.
|
|
30
|
+
* @template T
|
|
31
|
+
* @param {{
|
|
32
|
+
* name: string,
|
|
33
|
+
* affected?: Iterable<import('./types.js').IBlock>,
|
|
34
|
+
* apply: () => T,
|
|
35
|
+
* rollback?: () => void,
|
|
36
|
+
* markDirty?: boolean,
|
|
37
|
+
* notifyChange?: boolean,
|
|
38
|
+
* notify?: (result: T) => void,
|
|
39
|
+
* }} command
|
|
40
|
+
* @returns {T}
|
|
41
|
+
*/
|
|
42
|
+
execute<T>(command: {
|
|
43
|
+
name: string;
|
|
44
|
+
affected?: Iterable<import("./types.js").IBlock>;
|
|
45
|
+
apply: () => T;
|
|
46
|
+
rollback?: () => void;
|
|
47
|
+
markDirty?: boolean;
|
|
48
|
+
notifyChange?: boolean;
|
|
49
|
+
notify?: (result: T) => void;
|
|
50
|
+
}): T;
|
|
51
|
+
#private;
|
|
52
|
+
}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { EditorEvent } from './editorEvents.js'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Single execution boundary for editor commands.
|
|
5
|
+
*
|
|
6
|
+
* Commands may provide a cheap inverse rollback. Otherwise, the dispatcher
|
|
7
|
+
* restores the canonical pre-command checkpoint configured by the composition
|
|
8
|
+
* root. Nested commands join the outer command and produce one history entry.
|
|
9
|
+
*/
|
|
10
|
+
export class CommandDispatcher {
|
|
11
|
+
/** @type {import('./types').IBlockManager} */ #blocks
|
|
12
|
+
/** @type {import('./types').IEventBus} */ #events
|
|
13
|
+
/** @type {number} */ #depth = 0
|
|
14
|
+
/** @type {Set<import('./types').IBlock>} */ #affected = new Set()
|
|
15
|
+
/** @type {(() => import('./types').EditorDocument) | null} */ #capture = null
|
|
16
|
+
/** @type {((document: import('./types').EditorDocument) => void) | null} */ #restore = null
|
|
17
|
+
/** @type {boolean} */ #restoring = false
|
|
18
|
+
/** @type {unknown} */ #nestedFailure = null
|
|
19
|
+
/** @type {import('./Diagnostics').Diagnostics | null} */ #diagnostics
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @param {import('./types').IBlockManager} blocks Block manager whose
|
|
23
|
+
* affected instances are marked dirty after a successful command.
|
|
24
|
+
* @param {import('./types').IEventBus} events Event bus used to delimit
|
|
25
|
+
* document changes and history transactions.
|
|
26
|
+
* @param {import('./Diagnostics').Diagnostics} [diagnostics] Optional
|
|
27
|
+
* diagnostics sink for failed and slow commands.
|
|
28
|
+
*/
|
|
29
|
+
constructor(blocks, events, diagnostics) {
|
|
30
|
+
this.#blocks = blocks
|
|
31
|
+
this.#events = events
|
|
32
|
+
this.#diagnostics = diagnostics ?? null
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Propagate a nested command failure to the outer transaction even when an
|
|
37
|
+
* intermediate caller caught it.
|
|
38
|
+
* @param {boolean} outermost Whether the current command owns the transaction.
|
|
39
|
+
* @throws {unknown} The first failure raised by a nested command.
|
|
40
|
+
*/
|
|
41
|
+
#throwNestedFailure(outermost) {
|
|
42
|
+
if (outermost && this.#nestedFailure) throw this.#nestedFailure
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Configure the canonical fallback used when a command throws. */
|
|
46
|
+
configureRollback(capture, restore) {
|
|
47
|
+
this.#capture = capture
|
|
48
|
+
this.#restore = restore
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
get active() { return this.#depth > 0 }
|
|
52
|
+
|
|
53
|
+
runForRange(range, operation) {
|
|
54
|
+
return this.execute({
|
|
55
|
+
name: 'inline-range',
|
|
56
|
+
affected: this.#blocksForRange(range),
|
|
57
|
+
apply: operation,
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
runForBlock(block, operation) {
|
|
62
|
+
return this.execute({ name: `block:${block.type}`, affected: [block], apply: operation })
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
runForBlocks(blocks, operation) {
|
|
66
|
+
return this.execute({ name: 'blocks', affected: blocks, apply: operation })
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Commit a mutation performed by an integration callback outside execute(). */
|
|
70
|
+
commitExternal(block) {
|
|
71
|
+
this.commitExternalMany([block])
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Commit a callback that already changed a known set of blocks. */
|
|
75
|
+
commitExternalMany(blocks) {
|
|
76
|
+
for (const block of blocks) this.#affected.add(block)
|
|
77
|
+
if (this.#depth > 0) return
|
|
78
|
+
const affected = [...this.#affected]
|
|
79
|
+
this.#affected.clear()
|
|
80
|
+
this.#markAndCommit(affected)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Execute a command object.
|
|
85
|
+
* @template T
|
|
86
|
+
* @param {{
|
|
87
|
+
* name: string,
|
|
88
|
+
* affected?: Iterable<import('./types').IBlock>,
|
|
89
|
+
* apply: () => T,
|
|
90
|
+
* rollback?: () => void,
|
|
91
|
+
* markDirty?: boolean,
|
|
92
|
+
* notifyChange?: boolean,
|
|
93
|
+
* notify?: (result: T) => void,
|
|
94
|
+
* }} command
|
|
95
|
+
* @returns {T}
|
|
96
|
+
*/
|
|
97
|
+
execute(command) {
|
|
98
|
+
if (this.#restoring) return command.apply()
|
|
99
|
+
|
|
100
|
+
const outermost = this.#depth === 0
|
|
101
|
+
const startedAt = outermost && this.#diagnostics?.enabled ? this.#diagnostics.now() : 0
|
|
102
|
+
if (outermost) this.#nestedFailure = null
|
|
103
|
+
for (const block of command.affected ?? []) this.#affected.add(block)
|
|
104
|
+
const checkpoint = outermost && this.#capture ? this.#capture() : null
|
|
105
|
+
if (outermost && command.notifyChange !== false) this.#events.emit(EditorEvent.WILL_CHANGE)
|
|
106
|
+
|
|
107
|
+
let failed = false
|
|
108
|
+
this.#depth++
|
|
109
|
+
try {
|
|
110
|
+
const result = command.apply()
|
|
111
|
+
command.notify?.(result)
|
|
112
|
+
// A nested command cannot be made successful by catching its error in
|
|
113
|
+
// the caller: the outer transaction is poisoned and rolls back whole.
|
|
114
|
+
this.#throwNestedFailure(outermost)
|
|
115
|
+
return result
|
|
116
|
+
} catch (cause) {
|
|
117
|
+
failed = true
|
|
118
|
+
this.#nestedFailure ??= cause
|
|
119
|
+
if (outermost) {
|
|
120
|
+
this.#diagnostics?.emit('command.failed', {
|
|
121
|
+
operation: command.name,
|
|
122
|
+
errorName: this.#diagnostics.errorName(cause),
|
|
123
|
+
})
|
|
124
|
+
}
|
|
125
|
+
if (outermost) this.#rollback(command, checkpoint, cause)
|
|
126
|
+
throw cause
|
|
127
|
+
} finally {
|
|
128
|
+
this.#depth--
|
|
129
|
+
if (outermost) {
|
|
130
|
+
const affected = [...this.#affected]
|
|
131
|
+
this.#affected.clear()
|
|
132
|
+
// A failed command was restored and must not create a history entry.
|
|
133
|
+
if (!failed && command.notifyChange !== false) {
|
|
134
|
+
this.#markAndCommit(command.markDirty === false ? [] : affected)
|
|
135
|
+
}
|
|
136
|
+
if (startedAt && this.#diagnostics) {
|
|
137
|
+
const durationMs = this.#diagnostics.now() - startedAt
|
|
138
|
+
if (durationMs >= this.#diagnostics.threshold('commandMs')) {
|
|
139
|
+
this.#diagnostics.emit('command.slow', { operation: command.name, durationMs })
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
this.#nestedFailure = null
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
#rollback(command, checkpoint, cause) {
|
|
148
|
+
let inverseError = null
|
|
149
|
+
if (command.rollback) {
|
|
150
|
+
try {
|
|
151
|
+
command.rollback()
|
|
152
|
+
return
|
|
153
|
+
} catch (error) {
|
|
154
|
+
inverseError = error
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (!checkpoint || !this.#restore) {
|
|
159
|
+
if (inverseError) throw new AggregateError([cause, inverseError], `Command "${command.name}" and its rollback failed`)
|
|
160
|
+
return
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
this.#restoring = true
|
|
164
|
+
try {
|
|
165
|
+
this.#restore(checkpoint)
|
|
166
|
+
} catch (restoreError) {
|
|
167
|
+
throw new AggregateError(
|
|
168
|
+
inverseError ? [cause, inverseError, restoreError] : [cause, restoreError],
|
|
169
|
+
`Command "${command.name}" failed and its checkpoint could not be restored`,
|
|
170
|
+
)
|
|
171
|
+
} finally {
|
|
172
|
+
this.#restoring = false
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
#markAndCommit(affected) {
|
|
177
|
+
const seen = new Set()
|
|
178
|
+
for (const block of affected) {
|
|
179
|
+
if (seen.has(block) || this.#blocks.getBlockById(block.id) !== block) continue
|
|
180
|
+
seen.add(block)
|
|
181
|
+
block.markDirty()
|
|
182
|
+
this.#events.emit(EditorEvent.BLOCK_CHANGED, { blockId: block.id })
|
|
183
|
+
}
|
|
184
|
+
this.#events.emit(EditorEvent.CHANGED)
|
|
185
|
+
this.#events.emit(EditorEvent.HISTORY_COMMIT)
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
#blocksForRange(range) {
|
|
189
|
+
const result = []
|
|
190
|
+
for (const block of this.#blocks) {
|
|
191
|
+
const content = block.contentElement
|
|
192
|
+
let intersects = content.contains(range.startContainer)
|
|
193
|
+
|| content.contains(range.endContainer)
|
|
194
|
+
try {
|
|
195
|
+
intersects ||= range.intersectsNode(content)
|
|
196
|
+
} catch { /* detached node */ }
|
|
197
|
+
if (intersects) result.push(block)
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (result.length === 0) {
|
|
201
|
+
const start = this.#blocks.getBlockByChildNode(range.startContainer)
|
|
202
|
+
const end = this.#blocks.getBlockByChildNode(range.endContainer)
|
|
203
|
+
if (start) result.push(start)
|
|
204
|
+
if (end && end !== start) result.push(end)
|
|
205
|
+
}
|
|
206
|
+
return result
|
|
207
|
+
}
|
|
208
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export class CrossBlockSelection {
|
|
2
|
+
/**
|
|
3
|
+
* Show a visual-only CSS Highlight for a range (no state change).
|
|
4
|
+
* @param {Range} range
|
|
5
|
+
*/
|
|
6
|
+
static showHighlight(range: Range): void;
|
|
7
|
+
/**
|
|
8
|
+
* Remove the visual-only CSS Highlight (no state change).
|
|
9
|
+
*/
|
|
10
|
+
static hideHighlight(): void;
|
|
11
|
+
/** @returns {Range | null} */
|
|
12
|
+
get range(): Range | null;
|
|
13
|
+
/** @param {Range} range */
|
|
14
|
+
set(range: Range): void;
|
|
15
|
+
clear(): void;
|
|
16
|
+
/** @returns {Range | null} */
|
|
17
|
+
clone(): Range | null;
|
|
18
|
+
/**
|
|
19
|
+
* Store the range and activate visual highlight.
|
|
20
|
+
* @param {Range} range
|
|
21
|
+
* @param {HTMLElement} rootEl - `.oe-editor` element
|
|
22
|
+
*/
|
|
23
|
+
activate(range: Range, rootEl: HTMLElement): void;
|
|
24
|
+
/**
|
|
25
|
+
* Clear the stored range and remove visual highlight.
|
|
26
|
+
* @param {HTMLElement} [rootEl] - `.oe-editor` element
|
|
27
|
+
*/
|
|
28
|
+
deactivate(rootEl?: HTMLElement): void;
|
|
29
|
+
#private;
|
|
30
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stores the cross-block Range that native Selection cannot represent.
|
|
3
|
+
* Browsers clip Selection to the focused contentEditable, so this service
|
|
4
|
+
* preserves the full range across editing hosts for copy/cut/format/convert.
|
|
5
|
+
*
|
|
6
|
+
* Also manages the visual side-effects: CSS Highlight API painting and
|
|
7
|
+
* the `.oe-editor--cross-selecting` class that suppresses `::selection`.
|
|
8
|
+
*/
|
|
9
|
+
/** Highlight key used across the editor for cross-block visual highlight. */
|
|
10
|
+
const HIGHLIGHT_KEY = 'oe-cross-select'
|
|
11
|
+
|
|
12
|
+
export class CrossBlockSelection {
|
|
13
|
+
/** @type {Range | null} */
|
|
14
|
+
#range = null
|
|
15
|
+
|
|
16
|
+
/** @returns {Range | null} */
|
|
17
|
+
get range() {
|
|
18
|
+
return this.#range
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** @param {Range} range */
|
|
22
|
+
set(range) {
|
|
23
|
+
this.#range = range
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
clear() {
|
|
27
|
+
this.#range = null
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** @returns {Range | null} */
|
|
31
|
+
clone() {
|
|
32
|
+
return this.#range?.cloneRange() ?? null
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Show a visual-only CSS Highlight for a range (no state change).
|
|
37
|
+
* @param {Range} range
|
|
38
|
+
*/
|
|
39
|
+
static showHighlight(range) {
|
|
40
|
+
if (typeof Highlight !== 'undefined' && CSS.highlights) {
|
|
41
|
+
CSS.highlights.set(HIGHLIGHT_KEY, new Highlight(range))
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Remove the visual-only CSS Highlight (no state change).
|
|
47
|
+
*/
|
|
48
|
+
static hideHighlight() {
|
|
49
|
+
if (typeof CSS !== 'undefined' && CSS.highlights) {
|
|
50
|
+
CSS.highlights.delete(HIGHLIGHT_KEY)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Store the range and activate visual highlight.
|
|
56
|
+
* @param {Range} range
|
|
57
|
+
* @param {HTMLElement} rootEl - `.oe-editor` element
|
|
58
|
+
*/
|
|
59
|
+
activate(range, rootEl) {
|
|
60
|
+
this.#range = range
|
|
61
|
+
rootEl.classList.add('oe-editor--cross-selecting')
|
|
62
|
+
CrossBlockSelection.showHighlight(range)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Clear the stored range and remove visual highlight.
|
|
67
|
+
* @param {HTMLElement} [rootEl] - `.oe-editor` element
|
|
68
|
+
*/
|
|
69
|
+
deactivate(rootEl) {
|
|
70
|
+
this.#range = null
|
|
71
|
+
if (rootEl) rootEl.classList.remove('oe-editor--cross-selecting')
|
|
72
|
+
CrossBlockSelection.hideHighlight()
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content-free, opt-in production diagnostics.
|
|
3
|
+
* Consumer callbacks are isolated and can never break editor execution.
|
|
4
|
+
*/
|
|
5
|
+
export class Diagnostics {
|
|
6
|
+
/**
|
|
7
|
+
* @param {import('./types.js').EditorConfig['onDiagnostic']} report
|
|
8
|
+
* @param {import('./types.js').EditorConfig['diagnosticThresholds']} thresholds
|
|
9
|
+
*/
|
|
10
|
+
constructor(report: import("./types.js").EditorConfig["onDiagnostic"], thresholds?: import("./types.js").EditorConfig["diagnosticThresholds"]);
|
|
11
|
+
get enabled(): boolean;
|
|
12
|
+
/** @param {keyof import('./types.js').DiagnosticThresholds} name */
|
|
13
|
+
threshold(name: keyof import("./types.js").DiagnosticThresholds): number;
|
|
14
|
+
now(): number;
|
|
15
|
+
/**
|
|
16
|
+
* @param {import('./types.js').EditorDiagnosticCode} code
|
|
17
|
+
* @param {Omit<import('./types.js').EditorDiagnostic, 'code' | 'timestamp'>} [details]
|
|
18
|
+
*/
|
|
19
|
+
emit(code: import("./types.js").EditorDiagnosticCode, details?: Omit<import("./types.js").EditorDiagnostic, "code" | "timestamp">): void;
|
|
20
|
+
/** @param {unknown} error */
|
|
21
|
+
errorName(error: unknown): string;
|
|
22
|
+
#private;
|
|
23
|
+
}
|