@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,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Merge user-supplied tuning overrides onto defaults.
|
|
3
|
+
* Shallow per-group (one level deep) — each group is an object with primitive leaves.
|
|
4
|
+
*
|
|
5
|
+
* @param {import('./types.js').EditorConfig['tuning']} [overrides]
|
|
6
|
+
* @returns {EditorTuning}
|
|
7
|
+
*/
|
|
8
|
+
export function resolveTuning(overrides?: import("./types.js").EditorConfig["tuning"]): EditorTuning;
|
|
9
|
+
/**
|
|
10
|
+
* Default behavioral tuning for the editor.
|
|
11
|
+
*
|
|
12
|
+
* Pass overrides through the `tuning` property of `createEditor()`.
|
|
13
|
+
* These are UX/behavior defaults, not performance tuning — the name `tuning`
|
|
14
|
+
* reflects that.
|
|
15
|
+
*
|
|
16
|
+
* @typedef {Object} EditorTuning
|
|
17
|
+
* @property {{ threshold: number }} drag
|
|
18
|
+
* Drag-and-drop — minimum pixel movement before a mousedown becomes a drag.
|
|
19
|
+
* @property {{ maxStack: number, debounceMs: number }} undo
|
|
20
|
+
* Undo stack — max history depth and coalescing debounce.
|
|
21
|
+
* @property {{ debounceMs: number }} change
|
|
22
|
+
* `onChange` coalescing window for ChangeNotifier.
|
|
23
|
+
* @property {{ filterThreshold: number }} toolbar
|
|
24
|
+
* TypeSelector search — minimum plugin count before filter input appears.
|
|
25
|
+
* @property {{ blockInsertMs: number, blockMoveMs: number, blockRemoveMs: number }} animations
|
|
26
|
+
* Block insert/move/remove animation durations.
|
|
27
|
+
* @property {number} mobileBreakpoint
|
|
28
|
+
* Width below which the UI switches to mobile layout (matches CSS media queries).
|
|
29
|
+
*/
|
|
30
|
+
/** @type {EditorTuning} */
|
|
31
|
+
export const DEFAULT_TUNING: EditorTuning;
|
|
32
|
+
/**
|
|
33
|
+
* Default behavioral tuning for the editor.
|
|
34
|
+
*
|
|
35
|
+
* Pass overrides through the `tuning` property of `createEditor()`.
|
|
36
|
+
* These are UX/behavior defaults, not performance tuning — the name `tuning`
|
|
37
|
+
* reflects that.
|
|
38
|
+
*/
|
|
39
|
+
export type EditorTuning = {
|
|
40
|
+
/**
|
|
41
|
+
* Drag-and-drop — minimum pixel movement before a mousedown becomes a drag.
|
|
42
|
+
*/
|
|
43
|
+
drag: {
|
|
44
|
+
threshold: number;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Undo stack — max history depth and coalescing debounce.
|
|
48
|
+
*/
|
|
49
|
+
undo: {
|
|
50
|
+
maxStack: number;
|
|
51
|
+
debounceMs: number;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* `onChange` coalescing window for ChangeNotifier.
|
|
55
|
+
*/
|
|
56
|
+
change: {
|
|
57
|
+
debounceMs: number;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* TypeSelector search — minimum plugin count before filter input appears.
|
|
61
|
+
*/
|
|
62
|
+
toolbar: {
|
|
63
|
+
filterThreshold: number;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Block insert/move/remove animation durations.
|
|
67
|
+
*/
|
|
68
|
+
animations: {
|
|
69
|
+
blockInsertMs: number;
|
|
70
|
+
blockMoveMs: number;
|
|
71
|
+
blockRemoveMs: number;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Width below which the UI switches to mobile layout (matches CSS media queries).
|
|
75
|
+
*/
|
|
76
|
+
mobileBreakpoint: number;
|
|
77
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default behavioral tuning for the editor.
|
|
3
|
+
*
|
|
4
|
+
* Pass overrides through the `tuning` property of `createEditor()`.
|
|
5
|
+
* These are UX/behavior defaults, not performance tuning — the name `tuning`
|
|
6
|
+
* reflects that.
|
|
7
|
+
*
|
|
8
|
+
* @typedef {Object} EditorTuning
|
|
9
|
+
* @property {{ threshold: number }} drag
|
|
10
|
+
* Drag-and-drop — minimum pixel movement before a mousedown becomes a drag.
|
|
11
|
+
* @property {{ maxStack: number, debounceMs: number }} undo
|
|
12
|
+
* Undo stack — max history depth and coalescing debounce.
|
|
13
|
+
* @property {{ debounceMs: number }} change
|
|
14
|
+
* `onChange` coalescing window for ChangeNotifier.
|
|
15
|
+
* @property {{ filterThreshold: number }} toolbar
|
|
16
|
+
* TypeSelector search — minimum plugin count before filter input appears.
|
|
17
|
+
* @property {{ blockInsertMs: number, blockMoveMs: number, blockRemoveMs: number }} animations
|
|
18
|
+
* Block insert/move/remove animation durations.
|
|
19
|
+
* @property {number} mobileBreakpoint
|
|
20
|
+
* Width below which the UI switches to mobile layout (matches CSS media queries).
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/** @type {EditorTuning} */
|
|
24
|
+
export const DEFAULT_TUNING = {
|
|
25
|
+
drag: { threshold: 5 },
|
|
26
|
+
undo: { maxStack: 100, debounceMs: 300 },
|
|
27
|
+
change: { debounceMs: 250 },
|
|
28
|
+
toolbar: { filterThreshold: 7 },
|
|
29
|
+
animations: { blockInsertMs: 350, blockMoveMs: 200, blockRemoveMs: 350 },
|
|
30
|
+
mobileBreakpoint: 768,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Validate a numeric tuning value.
|
|
35
|
+
* @param {number} value Candidate value.
|
|
36
|
+
* @param {string} path Property path used in validation error messages.
|
|
37
|
+
* @param {{ integer?: boolean, min?: number }} [rules] Numeric constraints.
|
|
38
|
+
* @returns {void}
|
|
39
|
+
*/
|
|
40
|
+
function validateNumber(value, path, rules = {}) {
|
|
41
|
+
const min = rules.min ?? 0
|
|
42
|
+
if (
|
|
43
|
+
typeof value !== 'number'
|
|
44
|
+
|| !Number.isFinite(value)
|
|
45
|
+
|| value < min
|
|
46
|
+
|| (rules.integer && !Number.isInteger(value))
|
|
47
|
+
) {
|
|
48
|
+
const kind = rules.integer ? 'an integer' : 'a finite number'
|
|
49
|
+
throw new RangeError(`${path} must be ${kind} greater than or equal to ${min}`)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @param {unknown} value
|
|
55
|
+
* @param {string} path
|
|
56
|
+
* @returns {Record<string, unknown>}
|
|
57
|
+
*/
|
|
58
|
+
function validateGroup(value, path) {
|
|
59
|
+
if (Object.prototype.toString.call(value) !== '[object Object]') {
|
|
60
|
+
throw new TypeError(`${path} must be an object`)
|
|
61
|
+
}
|
|
62
|
+
return /** @type {Record<string, unknown>} */ (value)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Merge user-supplied tuning overrides onto defaults.
|
|
67
|
+
* Shallow per-group (one level deep) — each group is an object with primitive leaves.
|
|
68
|
+
*
|
|
69
|
+
* @param {import('./types').EditorConfig['tuning']} [overrides]
|
|
70
|
+
* @returns {EditorTuning}
|
|
71
|
+
*/
|
|
72
|
+
export function resolveTuning(overrides) {
|
|
73
|
+
const supplied = /** @type {Partial<EditorTuning>} */ (
|
|
74
|
+
overrides === undefined ? {} : validateGroup(overrides, 'tuning')
|
|
75
|
+
)
|
|
76
|
+
const drag = supplied.drag === undefined ? {} : validateGroup(supplied.drag, 'tuning.drag')
|
|
77
|
+
const undo = supplied.undo === undefined ? {} : validateGroup(supplied.undo, 'tuning.undo')
|
|
78
|
+
const change = supplied.change === undefined ? {} : validateGroup(supplied.change, 'tuning.change')
|
|
79
|
+
const toolbar = supplied.toolbar === undefined ? {} : validateGroup(supplied.toolbar, 'tuning.toolbar')
|
|
80
|
+
const animations = supplied.animations === undefined ? {} : validateGroup(supplied.animations, 'tuning.animations')
|
|
81
|
+
const resolved = {
|
|
82
|
+
drag: { ...DEFAULT_TUNING.drag, ...drag },
|
|
83
|
+
undo: { ...DEFAULT_TUNING.undo, ...undo },
|
|
84
|
+
change: { ...DEFAULT_TUNING.change, ...change },
|
|
85
|
+
toolbar: { ...DEFAULT_TUNING.toolbar, ...toolbar },
|
|
86
|
+
animations: { ...DEFAULT_TUNING.animations, ...animations },
|
|
87
|
+
mobileBreakpoint: supplied.mobileBreakpoint ?? DEFAULT_TUNING.mobileBreakpoint,
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
validateNumber(resolved.drag.threshold, 'tuning.drag.threshold')
|
|
91
|
+
validateNumber(resolved.undo.maxStack, 'tuning.undo.maxStack', { integer: true, min: 1 })
|
|
92
|
+
validateNumber(resolved.undo.debounceMs, 'tuning.undo.debounceMs')
|
|
93
|
+
validateNumber(resolved.change.debounceMs, 'tuning.change.debounceMs')
|
|
94
|
+
validateNumber(resolved.toolbar.filterThreshold, 'tuning.toolbar.filterThreshold', { integer: true })
|
|
95
|
+
validateNumber(resolved.animations.blockInsertMs, 'tuning.animations.blockInsertMs')
|
|
96
|
+
validateNumber(resolved.animations.blockMoveMs, 'tuning.animations.blockMoveMs')
|
|
97
|
+
validateNumber(resolved.animations.blockRemoveMs, 'tuning.animations.blockRemoveMs')
|
|
98
|
+
validateNumber(resolved.mobileBreakpoint, 'tuning.mobileBreakpoint')
|
|
99
|
+
return resolved
|
|
100
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Default block type used when no explicit default is configured. */
|
|
2
|
+
export const DEFAULT_BLOCK_TYPE: "paragraph";
|
|
3
|
+
export const DEFAULT_THEME: "dark";
|
|
4
|
+
/** CSS class applied to every block wrapper element. */
|
|
5
|
+
export const BLOCK_CLASS: "oe-block";
|
|
6
|
+
/** CSS selector for block wrapper elements (`.oe-block`). */
|
|
7
|
+
export const BLOCK_SELECTOR: ".oe-block";
|
|
8
|
+
/**
|
|
9
|
+
* Opt-in attribute for controls that remain usable in read-only mode because
|
|
10
|
+
* they only change transient presentation and never mutate document data or
|
|
11
|
+
* invoke application side effects.
|
|
12
|
+
*/
|
|
13
|
+
export const READ_ONLY_INTERACTIVE_ATTRIBUTE: "data-oe-read-only-interactive";
|
|
14
|
+
/**
|
|
15
|
+
* Internal marker used by the alignment tool and Block serializer. The value
|
|
16
|
+
* mirrors the canonical `tunes.textAlign` setting; an empty value explicitly
|
|
17
|
+
* removes that setting.
|
|
18
|
+
*/
|
|
19
|
+
export const TEXT_ALIGN_TUNE_ATTRIBUTE: "data-oe-text-align-tune";
|
|
20
|
+
/** Editor document format version — shared by EditorFacade.save() and UndoManager. */
|
|
21
|
+
export const EDITOR_VERSION: "1.0.0";
|
|
22
|
+
/** Duration of the offcanvas slide/backdrop-fade animation (ms). */
|
|
23
|
+
export const OFFCANVAS_ANIMATION_MS: 250;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** Default block type used when no explicit default is configured. */
|
|
2
|
+
export const DEFAULT_BLOCK_TYPE = 'paragraph'
|
|
3
|
+
|
|
4
|
+
export const DEFAULT_THEME = 'dark'
|
|
5
|
+
|
|
6
|
+
/** CSS class applied to every block wrapper element. */
|
|
7
|
+
export const BLOCK_CLASS = 'oe-block'
|
|
8
|
+
|
|
9
|
+
/** CSS selector for block wrapper elements (`.oe-block`). */
|
|
10
|
+
export const BLOCK_SELECTOR = '.oe-block'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Opt-in attribute for controls that remain usable in read-only mode because
|
|
14
|
+
* they only change transient presentation and never mutate document data or
|
|
15
|
+
* invoke application side effects.
|
|
16
|
+
*/
|
|
17
|
+
export const READ_ONLY_INTERACTIVE_ATTRIBUTE = 'data-oe-read-only-interactive'
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Internal marker used by the alignment tool and Block serializer. The value
|
|
21
|
+
* mirrors the canonical `tunes.textAlign` setting; an empty value explicitly
|
|
22
|
+
* removes that setting.
|
|
23
|
+
*/
|
|
24
|
+
export const TEXT_ALIGN_TUNE_ATTRIBUTE = 'data-oe-text-align-tune'
|
|
25
|
+
|
|
26
|
+
/** Editor document format version — shared by EditorFacade.save() and UndoManager. */
|
|
27
|
+
export const EDITOR_VERSION = '1.0.0'
|
|
28
|
+
|
|
29
|
+
/** Duration of the offcanvas slide/backdrop-fade animation (ms). */
|
|
30
|
+
export const OFFCANVAS_ANIMATION_MS = 250
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-block conversion shared by the inline type selector and the block
|
|
3
|
+
* settings menu. Endpoint analysis is completed before any command runs, so
|
|
4
|
+
* an unsupported structured selection is a safe no-op.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Check whether a block accepts neutral rich text during conversion.
|
|
8
|
+
* `isTextBlock` does not imply that the plugin root is contenteditable; list
|
|
9
|
+
* and checklist plugins are structured text targets as well.
|
|
10
|
+
* @param {Map<string, import('./types.js').BlockPlugin>} plugins
|
|
11
|
+
* @param {string} type
|
|
12
|
+
* @returns {boolean}
|
|
13
|
+
*/
|
|
14
|
+
export function isTextType(plugins: Map<string, import("./types.js").BlockPlugin>, type: string): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Convert a cross-block selection. A text target receives one converted block
|
|
17
|
+
* per selected source block. A non-text target replaces the selected interval
|
|
18
|
+
* with one block. Unselected endpoint data always stays in its source type.
|
|
19
|
+
*
|
|
20
|
+
* @param {object} ctx
|
|
21
|
+
* @param {import('./types.js').IBlockManager} ctx.blocks
|
|
22
|
+
* @param {import('./types.js').ISelectionManager} ctx.selection
|
|
23
|
+
* @param {Map<string, import('./types.js').BlockPlugin>} ctx.plugins
|
|
24
|
+
* @param {import('./types.js').ICrossBlockSelection} [ctx.crossBlockSelection]
|
|
25
|
+
* @param {import('./types.js').IEventBus} [ctx.events]
|
|
26
|
+
* @param {Range} crossRange
|
|
27
|
+
* @param {string} targetType
|
|
28
|
+
* @param {Record<string, unknown>} [targetData]
|
|
29
|
+
* @param {(() => void) | null} [onDone]
|
|
30
|
+
* @returns {boolean} whether the document was changed
|
|
31
|
+
*/
|
|
32
|
+
export function convertCrossBlockRange(ctx: {
|
|
33
|
+
blocks: import("./types.js").IBlockManager;
|
|
34
|
+
selection: import("./types.js").ISelectionManager;
|
|
35
|
+
plugins: Map<string, import("./types.js").BlockPlugin>;
|
|
36
|
+
crossBlockSelection?: import("./types.js").ICrossBlockSelection;
|
|
37
|
+
events?: import("./types.js").IEventBus;
|
|
38
|
+
}, crossRange: Range, targetType: string, targetData?: Record<string, unknown>, onDone?: (() => void) | null): boolean;
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { closestBlock } from './dom.js'
|
|
2
|
+
import { EditorEvent } from './editorEvents.js'
|
|
3
|
+
import { rangeStartsAtBeginning, rangeEndsAtEnd } from './splitConvert.js'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Cross-block conversion shared by the inline type selector and the block
|
|
7
|
+
* settings menu. Endpoint analysis is completed before any command runs, so
|
|
8
|
+
* an unsupported structured selection is a safe no-op.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Check whether a block accepts neutral rich text during conversion.
|
|
13
|
+
* `isTextBlock` does not imply that the plugin root is contenteditable; list
|
|
14
|
+
* and checklist plugins are structured text targets as well.
|
|
15
|
+
* @param {Map<string, import('./types').BlockPlugin>} plugins
|
|
16
|
+
* @param {string} type
|
|
17
|
+
* @returns {boolean}
|
|
18
|
+
*/
|
|
19
|
+
export function isTextType(plugins, type) {
|
|
20
|
+
const plugin = plugins.get(type)
|
|
21
|
+
if (!plugin) return false
|
|
22
|
+
const ctor = /** @type {import('./types').BlockPluginConstructor} */ (plugin.constructor)
|
|
23
|
+
return ctor?.isTextBlock === true
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** @param {Range} range @returns {string} */
|
|
27
|
+
function rangeHtml(range) {
|
|
28
|
+
const container = document.createElement('div')
|
|
29
|
+
container.appendChild(range.cloneContents())
|
|
30
|
+
return container.innerHTML
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** @param {string} html @returns {boolean} */
|
|
34
|
+
function hasTransferableContent(html) {
|
|
35
|
+
const container = document.createElement('div')
|
|
36
|
+
container.innerHTML = html
|
|
37
|
+
if ((container.textContent || '').replace(/\u00a0/g, ' ').trim()) return true
|
|
38
|
+
return !!container.querySelector('img, video, audio, iframe, [data-inline-plugin]')
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Describe one partially selected endpoint without mutating plugin DOM.
|
|
43
|
+
* Structured plugins own their data boundaries through `splitSelection()`;
|
|
44
|
+
* the generic path is intentionally limited to a single editable root whose
|
|
45
|
+
* serialized representation is `{ text }`.
|
|
46
|
+
*
|
|
47
|
+
* @param {import('./types').IBlock} block
|
|
48
|
+
* @param {Range} range
|
|
49
|
+
* @param {'first' | 'last'} side
|
|
50
|
+
* @returns {{ remainingData: Record<string, unknown> | null, selectedData: Record<string, unknown> } | null}
|
|
51
|
+
*/
|
|
52
|
+
function analyzePartialEndpoint(block, range, side) {
|
|
53
|
+
const content = block.contentElement
|
|
54
|
+
const pluginSplit = block.plugin.splitSelection?.(content, range)
|
|
55
|
+
if (pluginSplit) {
|
|
56
|
+
if (!pluginSplit.selectedData || typeof pluginSplit.selectedData !== 'object' || Array.isArray(pluginSplit.selectedData)) {
|
|
57
|
+
return null
|
|
58
|
+
}
|
|
59
|
+
if (pluginSplit.remainingData !== null && (
|
|
60
|
+
typeof pluginSplit.remainingData !== 'object' || Array.isArray(pluginSplit.remainingData)
|
|
61
|
+
)) return null
|
|
62
|
+
return pluginSplit
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (content.getAttribute('contenteditable') !== 'true') return null
|
|
66
|
+
|
|
67
|
+
try {
|
|
68
|
+
const selectedRange = document.createRange()
|
|
69
|
+
selectedRange.selectNodeContents(content)
|
|
70
|
+
const remainingRange = document.createRange()
|
|
71
|
+
remainingRange.selectNodeContents(content)
|
|
72
|
+
|
|
73
|
+
if (side === 'first') {
|
|
74
|
+
selectedRange.setStart(range.startContainer, range.startOffset)
|
|
75
|
+
remainingRange.setEnd(range.startContainer, range.startOffset)
|
|
76
|
+
} else {
|
|
77
|
+
selectedRange.setEnd(range.endContainer, range.endOffset)
|
|
78
|
+
remainingRange.setStart(range.endContainer, range.endOffset)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const selectedHtml = rangeHtml(selectedRange)
|
|
82
|
+
if (!hasTransferableContent(selectedHtml)) return null
|
|
83
|
+
const remainingHtml = rangeHtml(remainingRange)
|
|
84
|
+
return {
|
|
85
|
+
selectedData: { text: selectedHtml },
|
|
86
|
+
remainingData: hasTransferableContent(remainingHtml) ? { text: remainingHtml } : null,
|
|
87
|
+
}
|
|
88
|
+
} catch {
|
|
89
|
+
return null
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Convert a cross-block selection. A text target receives one converted block
|
|
95
|
+
* per selected source block. A non-text target replaces the selected interval
|
|
96
|
+
* with one block. Unselected endpoint data always stays in its source type.
|
|
97
|
+
*
|
|
98
|
+
* @param {object} ctx
|
|
99
|
+
* @param {import('./types').IBlockManager} ctx.blocks
|
|
100
|
+
* @param {import('./types').ISelectionManager} ctx.selection
|
|
101
|
+
* @param {Map<string, import('./types').BlockPlugin>} ctx.plugins
|
|
102
|
+
* @param {import('./types').ICrossBlockSelection} [ctx.crossBlockSelection]
|
|
103
|
+
* @param {import('./types').IEventBus} [ctx.events]
|
|
104
|
+
* @param {Range} crossRange
|
|
105
|
+
* @param {string} targetType
|
|
106
|
+
* @param {Record<string, unknown>} [targetData]
|
|
107
|
+
* @param {(() => void) | null} [onDone]
|
|
108
|
+
* @returns {boolean} whether the document was changed
|
|
109
|
+
*/
|
|
110
|
+
export function convertCrossBlockRange(ctx, crossRange, targetType, targetData, onDone) {
|
|
111
|
+
const { blocks, selection, plugins, crossBlockSelection, events } = ctx
|
|
112
|
+
|
|
113
|
+
const startBlockEl = closestBlock(/** @type {import('./types').DOMNode} */ (crossRange.startContainer))
|
|
114
|
+
const endBlockEl = closestBlock(/** @type {import('./types').DOMNode} */ (crossRange.endContainer))
|
|
115
|
+
if (!startBlockEl || !endBlockEl) return false
|
|
116
|
+
|
|
117
|
+
const startId = startBlockEl.dataset.blockId
|
|
118
|
+
const endId = endBlockEl.dataset.blockId
|
|
119
|
+
if (!startId || !endId) return false
|
|
120
|
+
const firstIdx = blocks.getBlockIndex(startId)
|
|
121
|
+
const lastIdx = blocks.getBlockIndex(endId)
|
|
122
|
+
if (firstIdx < 0 || lastIdx <= firstIdx) return false
|
|
123
|
+
|
|
124
|
+
const firstBlock = blocks.getBlockByIndex(firstIdx)
|
|
125
|
+
const lastBlock = blocks.getBlockByIndex(lastIdx)
|
|
126
|
+
if (!firstBlock || !lastBlock || !plugins.has(targetType)) return false
|
|
127
|
+
|
|
128
|
+
const firstFull = rangeStartsAtBeginning(firstBlock.contentElement, crossRange)
|
|
129
|
+
const lastFull = rangeEndsAtEnd(lastBlock.contentElement, crossRange)
|
|
130
|
+
const firstSplit = firstFull ? null : analyzePartialEndpoint(firstBlock, crossRange, 'first')
|
|
131
|
+
const lastSplit = lastFull ? null : analyzePartialEndpoint(lastBlock, crossRange, 'last')
|
|
132
|
+
|
|
133
|
+
// Do not start a batch or mutate any block until both endpoint contracts are
|
|
134
|
+
// known to be representable. This prevents partial corruption when only one
|
|
135
|
+
// structured plugin supports data-level splitting.
|
|
136
|
+
if ((!firstFull && !firstSplit) || (!lastFull && !lastSplit)) return false
|
|
137
|
+
|
|
138
|
+
const targetIsText = isTextType(plugins, targetType)
|
|
139
|
+
/** @type {import('./types').IBlock[]} */
|
|
140
|
+
const convertedBlocks = []
|
|
141
|
+
/** @type {import('./types').IBlock | null} */
|
|
142
|
+
let focusBlock = null
|
|
143
|
+
const recordConverted = (block) => {
|
|
144
|
+
if (block && !convertedBlocks.includes(block)) convertedBlocks.push(block)
|
|
145
|
+
return block
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
events?.emit(EditorEvent.UNDO_BATCH_START)
|
|
149
|
+
try {
|
|
150
|
+
if (targetIsText) {
|
|
151
|
+
// Process from the end so inserted endpoint remainders do not invalidate
|
|
152
|
+
// the model indices of earlier selected blocks.
|
|
153
|
+
if (lastSplit) {
|
|
154
|
+
const converted = blocks.convert(lastIdx, targetType, {
|
|
155
|
+
...lastSplit.selectedData,
|
|
156
|
+
...(targetData || {}),
|
|
157
|
+
})
|
|
158
|
+
if (converted) focusBlock = recordConverted(converted)
|
|
159
|
+
if (lastSplit.remainingData) blocks.insert(lastBlock.type, lastSplit.remainingData, lastIdx + 1)
|
|
160
|
+
} else {
|
|
161
|
+
const converted = blocks.convert(lastIdx, targetType, targetData)
|
|
162
|
+
if (converted) focusBlock = recordConverted(converted)
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
for (let index = lastIdx - 1; index > firstIdx; index--) {
|
|
166
|
+
const block = blocks.getBlockByIndex(index)
|
|
167
|
+
if (!block) continue
|
|
168
|
+
if (block.type === targetType) {
|
|
169
|
+
focusBlock = recordConverted(block)
|
|
170
|
+
continue
|
|
171
|
+
}
|
|
172
|
+
const converted = blocks.convert(index, targetType, targetData)
|
|
173
|
+
if (converted) focusBlock = recordConverted(converted)
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (firstSplit) {
|
|
177
|
+
if (firstSplit.remainingData) {
|
|
178
|
+
// Re-render the source from its plugin-owned remaining data. This is
|
|
179
|
+
// safer than rewriting structured DOM and keeps lifecycle ownership.
|
|
180
|
+
blocks.convert(firstIdx, firstBlock.type, firstSplit.remainingData)
|
|
181
|
+
focusBlock = recordConverted(blocks.insert(targetType, {
|
|
182
|
+
...firstSplit.selectedData,
|
|
183
|
+
...(targetData || {}),
|
|
184
|
+
}, firstIdx + 1))
|
|
185
|
+
} else {
|
|
186
|
+
const converted = blocks.convert(firstIdx, targetType, {
|
|
187
|
+
...firstSplit.selectedData,
|
|
188
|
+
...(targetData || {}),
|
|
189
|
+
})
|
|
190
|
+
if (converted) focusBlock = recordConverted(converted)
|
|
191
|
+
}
|
|
192
|
+
} else {
|
|
193
|
+
const converted = blocks.convert(firstIdx, targetType, targetData)
|
|
194
|
+
if (converted) focusBlock = recordConverted(converted)
|
|
195
|
+
}
|
|
196
|
+
} else {
|
|
197
|
+
// Keep only unselected endpoint data, remove every fully selected block,
|
|
198
|
+
// then place one non-text target between the surviving endpoint blocks.
|
|
199
|
+
if (lastSplit?.remainingData) {
|
|
200
|
+
blocks.convert(lastIdx, lastBlock.type, lastSplit.remainingData)
|
|
201
|
+
} else {
|
|
202
|
+
blocks.remove(lastIdx)
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
for (let index = lastIdx - 1; index > firstIdx; index--) blocks.remove(index)
|
|
206
|
+
|
|
207
|
+
let insertAt = firstIdx
|
|
208
|
+
if (firstSplit?.remainingData) {
|
|
209
|
+
blocks.convert(firstIdx, firstBlock.type, firstSplit.remainingData)
|
|
210
|
+
insertAt++
|
|
211
|
+
} else {
|
|
212
|
+
blocks.remove(firstIdx)
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
focusBlock = blocks.insert(targetType, /** @type {Record<string, unknown>} */ (targetData || {}), insertAt)
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
const liveConverted = convertedBlocks
|
|
219
|
+
.filter(block => blocks.getBlockById(block.id) === block)
|
|
220
|
+
.sort((a, b) => blocks.getBlockIndex(a.id) - blocks.getBlockIndex(b.id))
|
|
221
|
+
const newFirstBlock = liveConverted[0]
|
|
222
|
+
const newLastBlock = liveConverted[liveConverted.length - 1]
|
|
223
|
+
|
|
224
|
+
if (targetIsText && newFirstBlock && newLastBlock && newFirstBlock !== newLastBlock) {
|
|
225
|
+
try {
|
|
226
|
+
const newRange = document.createRange()
|
|
227
|
+
newRange.selectNodeContents(newFirstBlock.contentElement)
|
|
228
|
+
newRange.setEnd(newLastBlock.contentElement, newLastBlock.contentElement.childNodes.length)
|
|
229
|
+
const editor = /** @type {HTMLElement | null} */ (newFirstBlock.contentElement.closest('.oe-editor'))
|
|
230
|
+
if (crossBlockSelection && editor) crossBlockSelection.activate(newRange, editor)
|
|
231
|
+
} catch { /* focus fallback below */ }
|
|
232
|
+
|
|
233
|
+
const newLastIndex = blocks.getBlockIndex(newLastBlock.id)
|
|
234
|
+
if (newLastIndex >= 0) blocks.setCurrentIndex(newLastIndex)
|
|
235
|
+
newLastBlock.focus()
|
|
236
|
+
selection.setCaretToBlock(newLastBlock.id, 'end')
|
|
237
|
+
} else {
|
|
238
|
+
const editor = /** @type {HTMLElement | null} */ (startBlockEl.closest('.oe-editor'))
|
|
239
|
+
crossBlockSelection?.deactivate(editor ?? undefined)
|
|
240
|
+
if (focusBlock) {
|
|
241
|
+
const focusIndex = blocks.getBlockIndex(focusBlock.id)
|
|
242
|
+
if (focusIndex >= 0) blocks.setCurrentIndex(focusIndex)
|
|
243
|
+
selection.setCaretToBlock(focusBlock.id, 'start')
|
|
244
|
+
focusBlock.focus()
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
onDone?.()
|
|
249
|
+
return true
|
|
250
|
+
} finally {
|
|
251
|
+
events?.emit(EditorEvent.UNDO_BATCH_END)
|
|
252
|
+
}
|
|
253
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create an element with optional class name and attributes.
|
|
3
|
+
* @param {string} tag
|
|
4
|
+
* @param {string} [className]
|
|
5
|
+
* @param {Record<string, string>} [attrs]
|
|
6
|
+
* @returns {HTMLElement}
|
|
7
|
+
*/
|
|
8
|
+
export function el(tag: string, className?: string, attrs?: Record<string, string>): HTMLElement;
|
|
9
|
+
/**
|
|
10
|
+
* Find the closest `.oe-block` ancestor of a DOM node.
|
|
11
|
+
* Consolidates the repeated `node.closest('.oe-block')` pattern.
|
|
12
|
+
* @param {import('./types.js').DOMNode} node
|
|
13
|
+
* @returns {HTMLElement | null}
|
|
14
|
+
*/
|
|
15
|
+
export function closestBlock(node: import("./types.js").DOMNode): HTMLElement | null;
|
|
16
|
+
/**
|
|
17
|
+
* Position a popup element below (or above if no space) an anchor rect.
|
|
18
|
+
*
|
|
19
|
+
* Two modes:
|
|
20
|
+
* - `relative: false` (default) — sets absolute pixel values computed
|
|
21
|
+
* against `rootRect` (the editor root's bounding rect).
|
|
22
|
+
* - `relative: true` — sets CSS `calc(100% + …)` values, useful when
|
|
23
|
+
* the popup is a direct child of its anchor.
|
|
24
|
+
*
|
|
25
|
+
* @param {HTMLElement} popupEl
|
|
26
|
+
* @param {DOMRect} anchorRect
|
|
27
|
+
* @param {DOMRect | null} rootRect — required when `relative` is false
|
|
28
|
+
* @param {{ defaultHeight?: number, gap?: number, buffer?: number, relative?: boolean }} [options]
|
|
29
|
+
*/
|
|
30
|
+
export function positionPopup(popupEl: HTMLElement, anchorRect: DOMRect, rootRect: DOMRect | null, { defaultHeight, gap, buffer, relative }?: {
|
|
31
|
+
defaultHeight?: number;
|
|
32
|
+
gap?: number;
|
|
33
|
+
buffer?: number;
|
|
34
|
+
relative?: boolean;
|
|
35
|
+
}): void;
|
package/dist/core/dom.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { BLOCK_SELECTOR } from './constants.js'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Create an element with optional class name and attributes.
|
|
5
|
+
* @param {string} tag
|
|
6
|
+
* @param {string} [className]
|
|
7
|
+
* @param {Record<string, string>} [attrs]
|
|
8
|
+
* @returns {HTMLElement}
|
|
9
|
+
*/
|
|
10
|
+
export function el(tag, className, attrs) {
|
|
11
|
+
const element = document.createElement(tag)
|
|
12
|
+
if (className) element.className = className
|
|
13
|
+
if (attrs) {
|
|
14
|
+
for (const [key, value] of Object.entries(attrs)) {
|
|
15
|
+
element.setAttribute(key, value)
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return element
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Find the closest `.oe-block` ancestor of a DOM node.
|
|
23
|
+
* Consolidates the repeated `node.closest('.oe-block')` pattern.
|
|
24
|
+
* @param {import('./types').DOMNode} node
|
|
25
|
+
* @returns {HTMLElement | null}
|
|
26
|
+
*/
|
|
27
|
+
export function closestBlock(node) {
|
|
28
|
+
const el = node.nodeType === Node.ELEMENT_NODE
|
|
29
|
+
? /** @type {Element} */ (node)
|
|
30
|
+
: node.parentElement
|
|
31
|
+
return /** @type {HTMLElement | null} */ (el?.closest(BLOCK_SELECTOR) ?? null)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Position a popup element below (or above if no space) an anchor rect.
|
|
36
|
+
*
|
|
37
|
+
* Two modes:
|
|
38
|
+
* - `relative: false` (default) — sets absolute pixel values computed
|
|
39
|
+
* against `rootRect` (the editor root's bounding rect).
|
|
40
|
+
* - `relative: true` — sets CSS `calc(100% + …)` values, useful when
|
|
41
|
+
* the popup is a direct child of its anchor.
|
|
42
|
+
*
|
|
43
|
+
* @param {HTMLElement} popupEl
|
|
44
|
+
* @param {DOMRect} anchorRect
|
|
45
|
+
* @param {DOMRect | null} rootRect — required when `relative` is false
|
|
46
|
+
* @param {{ defaultHeight?: number, gap?: number, buffer?: number, relative?: boolean }} [options]
|
|
47
|
+
*/
|
|
48
|
+
export function positionPopup(popupEl, anchorRect, rootRect, { defaultHeight = 300, gap = 4, buffer = 8, relative = false } = {}) {
|
|
49
|
+
const height = popupEl.offsetHeight || defaultHeight
|
|
50
|
+
const spaceBelow = window.innerHeight - anchorRect.bottom - buffer
|
|
51
|
+
const spaceAbove = anchorRect.top - buffer
|
|
52
|
+
|
|
53
|
+
if (spaceBelow >= height || spaceBelow >= spaceAbove) {
|
|
54
|
+
popupEl.style.bottom = 'auto'
|
|
55
|
+
popupEl.style.top = relative
|
|
56
|
+
? `calc(100% + ${gap}px)`
|
|
57
|
+
: `${anchorRect.bottom - /** @type {DOMRect} */ (rootRect).top + gap}px`
|
|
58
|
+
} else {
|
|
59
|
+
popupEl.style.top = 'auto'
|
|
60
|
+
popupEl.style.bottom = relative
|
|
61
|
+
? `calc(100% + ${gap}px)`
|
|
62
|
+
: `${/** @type {DOMRect} */ (rootRect).bottom - anchorRect.top + gap}px`
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|