@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,251 @@
|
|
|
1
|
+
import { el } from '../core/dom.js'
|
|
2
|
+
import { sanitizeUrl } from '../shared/sanitize/sanitizeUrl.js'
|
|
3
|
+
import {
|
|
4
|
+
ICON_LINK, ICON_CHECK, ICON_UNLINK,
|
|
5
|
+
removeEmptyInlineTags,
|
|
6
|
+
saveSelectionOffsets,
|
|
7
|
+
restoreSelectionOffsets,
|
|
8
|
+
getContentEditable,
|
|
9
|
+
getWalkRoot,
|
|
10
|
+
collectTextTargets,
|
|
11
|
+
normalizeAfterEdit,
|
|
12
|
+
createBackButton,
|
|
13
|
+
} from './utils.js'
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Return every link touched by a range. The walk root is deliberately the
|
|
17
|
+
* contenteditable (or the common editor root for a cross-block selection),
|
|
18
|
+
* rather than the range's common ancestor: the latter can be the link itself,
|
|
19
|
+
* and querySelectorAll() never includes the element it is called on.
|
|
20
|
+
*
|
|
21
|
+
* Keeping detection, active-state rendering, and unlinking on this single
|
|
22
|
+
* query prevents the three code paths from disagreeing about the selection.
|
|
23
|
+
*
|
|
24
|
+
* @param {Range} range
|
|
25
|
+
* @returns {HTMLAnchorElement[]}
|
|
26
|
+
*/
|
|
27
|
+
function getIntersectingLinks(range) {
|
|
28
|
+
const walkRoot = getWalkRoot(range)
|
|
29
|
+
if (!walkRoot) return []
|
|
30
|
+
|
|
31
|
+
/** @type {HTMLAnchorElement[]} */
|
|
32
|
+
const candidates = []
|
|
33
|
+
if (walkRoot instanceof HTMLAnchorElement) candidates.push(walkRoot)
|
|
34
|
+
candidates.push(...walkRoot.querySelectorAll('a'))
|
|
35
|
+
|
|
36
|
+
return candidates.filter((candidate) => {
|
|
37
|
+
try {
|
|
38
|
+
return range.intersectsNode(candidate)
|
|
39
|
+
} catch {
|
|
40
|
+
return false
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Create the link inline tool with a drill-down URL input panel.
|
|
47
|
+
* @param {string} linkPlaceholder — i18n placeholder for the input
|
|
48
|
+
* @param {string} linkLabel — i18n label for the tool
|
|
49
|
+
* @param {{ apply?: string, unlink?: string }} [actionLabels]
|
|
50
|
+
* @param {import('../types').ICrossBlockSelection | null} [cbs]
|
|
51
|
+
* @returns {import('../types').InlineTool}
|
|
52
|
+
*/
|
|
53
|
+
export function createLinkTool(linkPlaceholder, linkLabel, actionLabels = {}, cbs = null) {
|
|
54
|
+
return {
|
|
55
|
+
type: 'link',
|
|
56
|
+
title: linkLabel,
|
|
57
|
+
icon: ICON_LINK,
|
|
58
|
+
tag: 'a',
|
|
59
|
+
shortcut: 'Mod+K',
|
|
60
|
+
getTitle(active) {
|
|
61
|
+
return active ? (actionLabels.unlink || 'Unlink') : linkLabel
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
getIcon(active) {
|
|
65
|
+
return active ? ICON_UNLINK : ICON_LINK
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
isActive(selection) {
|
|
69
|
+
const range = cbs?.range || selection?.range
|
|
70
|
+
if (!range) {
|
|
71
|
+
const sel = window.getSelection()
|
|
72
|
+
if (sel?.anchorNode) return !!sel.anchorNode.parentElement?.closest('a')
|
|
73
|
+
return false
|
|
74
|
+
}
|
|
75
|
+
return getIntersectingLinks(range).length > 0
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
toggle(selection) {
|
|
79
|
+
// Toggle: if links exist in selection — remove them all
|
|
80
|
+
const actualRange = cbs?.range || selection?.range
|
|
81
|
+
if (!actualRange) return
|
|
82
|
+
const saved = saveSelectionOffsets(actualRange)
|
|
83
|
+
|
|
84
|
+
const walkRoot = getWalkRoot(actualRange)
|
|
85
|
+
if (!walkRoot) return
|
|
86
|
+
|
|
87
|
+
for (const link of getIntersectingLinks(actualRange)) {
|
|
88
|
+
const parent = link.parentNode
|
|
89
|
+
while (link.firstChild) parent?.insertBefore(link.firstChild, link)
|
|
90
|
+
link.remove()
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
normalizeAfterEdit(getContentEditable(actualRange), walkRoot)
|
|
94
|
+
|
|
95
|
+
restoreSelectionOffsets(cbs, saved)
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Render the drill-down panel with URL input, apply, unlink buttons.
|
|
100
|
+
* Returns null when active (links in selection) — signals toggle behavior instead.
|
|
101
|
+
* @param {import('../types').InlineToolActionContext} ctx
|
|
102
|
+
* @returns {HTMLElement | null}
|
|
103
|
+
*/
|
|
104
|
+
renderActions(ctx) {
|
|
105
|
+
// When links exist, return null to trigger toggle() (remove links)
|
|
106
|
+
const currentSel = window.getSelection()
|
|
107
|
+
if (currentSel?.anchorNode) {
|
|
108
|
+
const range = cbs?.range || (currentSel.rangeCount ? currentSel.getRangeAt(0) : null)
|
|
109
|
+
if (range && getIntersectingLinks(range).length > 0) return null
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const panel = el('div', 'oe-inline-toolbar__panel oe-inline-toolbar__panel--link')
|
|
113
|
+
|
|
114
|
+
const backBtn = createBackButton(ctx)
|
|
115
|
+
|
|
116
|
+
// URL input
|
|
117
|
+
const input = /** @type {HTMLInputElement} */ (el('input', 'oe-inline-toolbar__link-input', {
|
|
118
|
+
type: 'url',
|
|
119
|
+
placeholder: linkPlaceholder,
|
|
120
|
+
}))
|
|
121
|
+
input.addEventListener('keydown', (e) => {
|
|
122
|
+
e.stopPropagation()
|
|
123
|
+
if (e.key === 'Enter') {
|
|
124
|
+
e.preventDefault()
|
|
125
|
+
applyLink()
|
|
126
|
+
}
|
|
127
|
+
if (e.key === 'Escape') {
|
|
128
|
+
e.preventDefault()
|
|
129
|
+
ctx.close()
|
|
130
|
+
}
|
|
131
|
+
})
|
|
132
|
+
// Prevent input events from bubbling to wireInputTracking
|
|
133
|
+
// (typing a URL is not a document content change).
|
|
134
|
+
input.addEventListener('input', (e) => e.stopPropagation())
|
|
135
|
+
|
|
136
|
+
// Apply button
|
|
137
|
+
const applyLabel = actionLabels.apply || 'Apply'
|
|
138
|
+
const applyBtn = el('button', 'oe-inline-tool oe-inline-tool--apply', { type: 'button' })
|
|
139
|
+
applyBtn.innerHTML = ICON_CHECK
|
|
140
|
+
applyBtn.addEventListener('mouseenter', () => ctx.showTooltip(applyBtn, applyLabel))
|
|
141
|
+
applyBtn.addEventListener('mouseleave', () => ctx.hideTooltip())
|
|
142
|
+
applyBtn.addEventListener('mousedown', (e) => {
|
|
143
|
+
e.preventDefault()
|
|
144
|
+
e.stopPropagation()
|
|
145
|
+
})
|
|
146
|
+
applyBtn.addEventListener('click', (e) => {
|
|
147
|
+
e.preventDefault()
|
|
148
|
+
e.stopPropagation()
|
|
149
|
+
applyLink()
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
// Unlink button
|
|
153
|
+
const unlinkLabel = actionLabels.unlink || 'Unlink'
|
|
154
|
+
const unlinkBtn = el('button', 'oe-inline-tool oe-inline-tool--unlink', { type: 'button' })
|
|
155
|
+
unlinkBtn.innerHTML = ICON_UNLINK
|
|
156
|
+
unlinkBtn.addEventListener('mouseenter', () => ctx.showTooltip(unlinkBtn, unlinkLabel))
|
|
157
|
+
unlinkBtn.addEventListener('mouseleave', () => ctx.hideTooltip())
|
|
158
|
+
unlinkBtn.addEventListener('mousedown', (e) => {
|
|
159
|
+
e.preventDefault()
|
|
160
|
+
e.stopPropagation()
|
|
161
|
+
})
|
|
162
|
+
unlinkBtn.addEventListener('click', (e) => {
|
|
163
|
+
e.preventDefault()
|
|
164
|
+
e.stopPropagation()
|
|
165
|
+
removeLink()
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
// Check if already inside a link
|
|
169
|
+
const sel = window.getSelection()
|
|
170
|
+
const existingAnchor = sel?.anchorNode?.parentElement?.closest('a')
|
|
171
|
+
if (existingAnchor) {
|
|
172
|
+
input.value = existingAnchor.getAttribute('href') || ''
|
|
173
|
+
unlinkBtn.style.display = ''
|
|
174
|
+
} else {
|
|
175
|
+
unlinkBtn.style.display = 'none'
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function applyLink() {
|
|
179
|
+
const url = input.value.trim()
|
|
180
|
+
if (!url) return
|
|
181
|
+
|
|
182
|
+
ctx.restoreSelection()
|
|
183
|
+
|
|
184
|
+
// Use cross-block range if available
|
|
185
|
+
const sel = window.getSelection()
|
|
186
|
+
const actualRange = cbs?.range || (sel && sel.rangeCount ? sel.getRangeAt(0) : null)
|
|
187
|
+
if (!actualRange) return
|
|
188
|
+
|
|
189
|
+
const saved = saveSelectionOffsets(actualRange)
|
|
190
|
+
|
|
191
|
+
ctx.mutate(() => {
|
|
192
|
+
// Wrap each text node in the range with an <a> tag
|
|
193
|
+
const walkRoot = getWalkRoot(actualRange)
|
|
194
|
+
if (walkRoot) {
|
|
195
|
+
const targets = collectTextTargets(walkRoot, actualRange)
|
|
196
|
+
for (let i = targets.length - 1; i >= 0; i--) {
|
|
197
|
+
const t = targets[i]
|
|
198
|
+
if (!t) continue
|
|
199
|
+
const { node, startOffset, endOffset } = t
|
|
200
|
+
let targetNode = node
|
|
201
|
+
if (endOffset < node.length) node.splitText(endOffset)
|
|
202
|
+
if (startOffset > 0) targetNode = /** @type {Text} */ (node.splitText(startOffset))
|
|
203
|
+
|
|
204
|
+
// Skip if already inside a link
|
|
205
|
+
if (targetNode.parentElement?.closest('a')) continue
|
|
206
|
+
|
|
207
|
+
const anchor = document.createElement('a')
|
|
208
|
+
anchor.href = sanitizeUrl(url)
|
|
209
|
+
anchor.rel = 'noopener noreferrer'
|
|
210
|
+
anchor.target = '_blank'
|
|
211
|
+
targetNode.parentNode?.insertBefore(anchor, targetNode)
|
|
212
|
+
anchor.appendChild(targetNode)
|
|
213
|
+
}
|
|
214
|
+
normalizeAfterEdit(getContentEditable(actualRange), walkRoot)
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
restoreSelectionOffsets(cbs, saved)
|
|
218
|
+
})
|
|
219
|
+
ctx.close()
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function removeLink() {
|
|
223
|
+
ctx.restoreSelection()
|
|
224
|
+
const s = window.getSelection()
|
|
225
|
+
const anchor = s?.anchorNode?.parentElement?.closest('a')
|
|
226
|
+
ctx.mutate(() => {
|
|
227
|
+
if (anchor) {
|
|
228
|
+
const parent = anchor.parentNode
|
|
229
|
+
const fragment = document.createDocumentFragment()
|
|
230
|
+
while (anchor.firstChild) {
|
|
231
|
+
fragment.appendChild(anchor.firstChild)
|
|
232
|
+
}
|
|
233
|
+
anchor.replaceWith(fragment)
|
|
234
|
+
removeEmptyInlineTags(parent)
|
|
235
|
+
}
|
|
236
|
+
})
|
|
237
|
+
ctx.close()
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
panel.appendChild(backBtn)
|
|
241
|
+
panel.appendChild(input)
|
|
242
|
+
panel.appendChild(applyBtn)
|
|
243
|
+
panel.appendChild(unlinkBtn)
|
|
244
|
+
|
|
245
|
+
// Focus input after panel is mounted
|
|
246
|
+
requestAnimationFrame(() => input.focus())
|
|
247
|
+
|
|
248
|
+
return panel
|
|
249
|
+
},
|
|
250
|
+
}
|
|
251
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create the built-in text-highlight control (`<mark>`, `Mod+Shift+H`).
|
|
3
|
+
*
|
|
4
|
+
* @param {string} label
|
|
5
|
+
* @param {import('../types.js').ICrossBlockSelection | null} [cbs]
|
|
6
|
+
* @returns {import('../types.js').InlineTool}
|
|
7
|
+
*/
|
|
8
|
+
export function createMarkerTool(label: string, cbs?: import("../types.js").ICrossBlockSelection | null): import("../types.js").InlineTool;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createSimpleInlineTool, ICON_HIGHLIGHT } from './utils.js'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Create the built-in text-highlight control (`<mark>`, `Mod+Shift+H`).
|
|
5
|
+
*
|
|
6
|
+
* @param {string} label
|
|
7
|
+
* @param {import('../types').ICrossBlockSelection | null} [cbs]
|
|
8
|
+
* @returns {import('../types').InlineTool}
|
|
9
|
+
*/
|
|
10
|
+
export function createMarkerTool(label, cbs) {
|
|
11
|
+
return createSimpleInlineTool('marker', label, ICON_HIGHLIGHT, 'mark', 'Mod+Shift+H', cbs ?? undefined)
|
|
12
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create combined superscript/subscript tool with a dropdown panel.
|
|
3
|
+
* @param {{ sup: string, sub: string, none: string }} labels
|
|
4
|
+
* @param {import('../types.js').ICrossBlockSelection | null} [cbs]
|
|
5
|
+
* @returns {import('../types.js').InlineTool}
|
|
6
|
+
*/
|
|
7
|
+
export function createScriptTool(labels: {
|
|
8
|
+
sup: string;
|
|
9
|
+
sub: string;
|
|
10
|
+
none: string;
|
|
11
|
+
}, cbs?: import("../types.js").ICrossBlockSelection | null): import("../types.js").InlineTool;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import {
|
|
2
|
+
toggleTag,
|
|
3
|
+
removeEmptyInlineTags,
|
|
4
|
+
saveSelectionOffsets,
|
|
5
|
+
restoreSelectionOffsets,
|
|
6
|
+
createBackButton,
|
|
7
|
+
getWalkRoot,
|
|
8
|
+
} from './utils.js'
|
|
9
|
+
|
|
10
|
+
const ICON_SUP = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 7l8 10m-8 0l8 -10"/><path d="M21 11h-4l3.5 -4a1.73 1.73 0 0 0 -3.5 -1"/></svg>'
|
|
11
|
+
const ICON_SUB = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 7l8 10m-8 0l8 -10"/><path d="M21 20h-4l3.5 -4a1.73 1.73 0 0 0 -3.5 -1"/></svg>'
|
|
12
|
+
const ICON_NONE = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 7l8 10m-8 0l8 -10"/></svg>'
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Detect which script mode the selection is in.
|
|
16
|
+
* @returns {'sup' | 'sub' | 'none'}
|
|
17
|
+
*/
|
|
18
|
+
function getCurrentScript() {
|
|
19
|
+
const sel = window.getSelection()
|
|
20
|
+
if (!sel?.anchorNode) return 'none'
|
|
21
|
+
const node = sel.anchorNode.nodeType === Node.ELEMENT_NODE
|
|
22
|
+
? /** @type {HTMLElement} */ (sel.anchorNode)
|
|
23
|
+
: sel.anchorNode.parentElement
|
|
24
|
+
if (node?.closest('sup')) return 'sup'
|
|
25
|
+
if (node?.closest('sub')) return 'sub'
|
|
26
|
+
return 'none'
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Remove all <sup> and <sub> tags that intersect the range by unwrapping them.
|
|
31
|
+
* Walks up to the contenteditable to ensure we find wrapping tags.
|
|
32
|
+
* @param {Range} range
|
|
33
|
+
*/
|
|
34
|
+
function removeAllScriptTags(range) {
|
|
35
|
+
// Use the contenteditable (or common editor root for cross-block ranges),
|
|
36
|
+
// not commonAncestorContainer. The common ancestor can itself be <sup> or
|
|
37
|
+
// <sub>, and querySelectorAll() does not include the receiver element.
|
|
38
|
+
const root = getWalkRoot(range)
|
|
39
|
+
if (!root) return
|
|
40
|
+
|
|
41
|
+
const tags = []
|
|
42
|
+
if (root.matches('sup, sub')) tags.push(root)
|
|
43
|
+
tags.push(...root.querySelectorAll('sup, sub'))
|
|
44
|
+
for (const tag of tags) {
|
|
45
|
+
if (!range.intersectsNode(tag)) continue
|
|
46
|
+
if (tag.closest('[data-inline-plugin]')) continue
|
|
47
|
+
const parent = tag.parentNode
|
|
48
|
+
if (!parent) continue
|
|
49
|
+
while (tag.firstChild) parent.insertBefore(tag.firstChild, tag)
|
|
50
|
+
tag.remove()
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Clean up empty inline tags and normalize
|
|
54
|
+
removeEmptyInlineTags(root)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Create combined superscript/subscript tool with a dropdown panel.
|
|
59
|
+
* @param {{ sup: string, sub: string, none: string }} labels
|
|
60
|
+
* @param {import('../types').ICrossBlockSelection | null} [cbs]
|
|
61
|
+
* @returns {import('../types').InlineTool}
|
|
62
|
+
*/
|
|
63
|
+
export function createScriptTool(labels, cbs = null) {
|
|
64
|
+
const modes = [
|
|
65
|
+
{ tag: 'sup', icon: ICON_SUP, title: labels.sup, key: 'sup' },
|
|
66
|
+
{ tag: 'sub', icon: ICON_SUB, title: labels.sub, key: 'sub' },
|
|
67
|
+
{ tag: '', icon: ICON_NONE, title: labels.none, key: 'none' },
|
|
68
|
+
]
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
type: 'script',
|
|
72
|
+
title: labels.sup,
|
|
73
|
+
icon: ICON_SUP,
|
|
74
|
+
|
|
75
|
+
getIcon() {
|
|
76
|
+
const c = getCurrentScript()
|
|
77
|
+
return c === 'sub' ? ICON_SUB : ICON_SUP
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
getTitle() {
|
|
81
|
+
const c = getCurrentScript()
|
|
82
|
+
if (c === 'sup') return labels.sup
|
|
83
|
+
if (c === 'sub') return labels.sub
|
|
84
|
+
return labels.sup
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
isActive() {
|
|
88
|
+
return getCurrentScript() !== 'none'
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
toggle() {
|
|
92
|
+
// no-op: opens renderActions panel
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
renderActions(ctx) {
|
|
96
|
+
const panel = document.createElement('div')
|
|
97
|
+
panel.className = 'oe-inline-toolbar__panel oe-inline-toolbar__script-panel'
|
|
98
|
+
|
|
99
|
+
panel.appendChild(createBackButton(ctx))
|
|
100
|
+
|
|
101
|
+
const current = getCurrentScript()
|
|
102
|
+
|
|
103
|
+
for (const mode of modes) {
|
|
104
|
+
const btn = document.createElement('button')
|
|
105
|
+
btn.type = 'button'
|
|
106
|
+
btn.className = 'oe-inline-tool'
|
|
107
|
+
btn.innerHTML = mode.icon
|
|
108
|
+
if (current === mode.key && mode.key !== 'none') btn.classList.add('oe-inline-tool--active')
|
|
109
|
+
|
|
110
|
+
btn.addEventListener('mouseenter', () => ctx.showTooltip(btn, mode.title))
|
|
111
|
+
btn.addEventListener('mouseleave', () => ctx.hideTooltip())
|
|
112
|
+
btn.addEventListener('mousedown', (e) => { e.preventDefault(); e.stopPropagation() })
|
|
113
|
+
btn.addEventListener('click', (e) => {
|
|
114
|
+
e.preventDefault()
|
|
115
|
+
e.stopPropagation()
|
|
116
|
+
ctx.restoreSelection()
|
|
117
|
+
|
|
118
|
+
const sel = window.getSelection()
|
|
119
|
+
if (!sel || !sel.rangeCount) { ctx.close(); return }
|
|
120
|
+
// Use cross-block range if available (native range is clipped to one contenteditable)
|
|
121
|
+
const range = cbs?.range || sel.getRangeAt(0)
|
|
122
|
+
|
|
123
|
+
const saved = saveSelectionOffsets(range)
|
|
124
|
+
|
|
125
|
+
ctx.mutate(() => {
|
|
126
|
+
// Step 1: Always remove ALL existing sup/sub tags in range
|
|
127
|
+
removeAllScriptTags(range)
|
|
128
|
+
|
|
129
|
+
// Restore selection after DOM cleanup (normalize invalidates range)
|
|
130
|
+
restoreSelectionOffsets(cbs, saved)
|
|
131
|
+
|
|
132
|
+
// Step 2: If target is different from current (not toggling off), wrap with new tag
|
|
133
|
+
if (mode.tag && mode.key !== current) {
|
|
134
|
+
const newRange = (saved.crossOffsets ? cbs?.range : null) || (sel.rangeCount ? sel.getRangeAt(0) : null)
|
|
135
|
+
if (newRange) {
|
|
136
|
+
toggleTag(mode.tag, newRange)
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
ctx.close()
|
|
142
|
+
})
|
|
143
|
+
panel.appendChild(btn)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return panel
|
|
147
|
+
},
|
|
148
|
+
}
|
|
149
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create the built-in strikethrough control (`<s>`, `Mod+Shift+S`).
|
|
3
|
+
*
|
|
4
|
+
* @param {string} label
|
|
5
|
+
* @param {import('../types.js').ICrossBlockSelection | null} [cbs]
|
|
6
|
+
* @returns {import('../types.js').InlineTool}
|
|
7
|
+
*/
|
|
8
|
+
export function createStrikethroughTool(label: string, cbs?: import("../types.js").ICrossBlockSelection | null): import("../types.js").InlineTool;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createSimpleInlineTool, ICON_STRIKETHROUGH } from './utils.js'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Create the built-in strikethrough control (`<s>`, `Mod+Shift+S`).
|
|
5
|
+
*
|
|
6
|
+
* @param {string} label
|
|
7
|
+
* @param {import('../types').ICrossBlockSelection | null} [cbs]
|
|
8
|
+
* @returns {import('../types').InlineTool}
|
|
9
|
+
*/
|
|
10
|
+
export function createStrikethroughTool(label, cbs) {
|
|
11
|
+
return createSimpleInlineTool('strikethrough', label, ICON_STRIKETHROUGH, 's', 'Mod+Shift+S', cbs ?? undefined)
|
|
12
|
+
}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remove empty inline wrapper tags and normalize text nodes.
|
|
3
|
+
* Called after any DOM mutation that unwraps/removes inline formatting.
|
|
4
|
+
* @param {Node | null} parent
|
|
5
|
+
* @returns {void}
|
|
6
|
+
*/
|
|
7
|
+
export function removeEmptyInlineTags(parent: Node | null): void;
|
|
8
|
+
/**
|
|
9
|
+
* Wrap or unwrap a selection with an inline tag.
|
|
10
|
+
* @param {string} tagName
|
|
11
|
+
* @param {Range} range
|
|
12
|
+
* @param {(element: HTMLElement) => boolean} [matches]
|
|
13
|
+
* @returns {void}
|
|
14
|
+
*/
|
|
15
|
+
export function toggleTag(tagName: string, range: Range, matches?: (element: HTMLElement) => boolean): void;
|
|
16
|
+
/**
|
|
17
|
+
* Find the closest .oe-editor root from a DOM node.
|
|
18
|
+
* Avoids global querySelector — works with multiple editor instances.
|
|
19
|
+
* @param {Node | null | undefined} [node]
|
|
20
|
+
* @returns {HTMLElement | null}
|
|
21
|
+
*/
|
|
22
|
+
export function getEditorRoot(node?: Node | null | undefined): HTMLElement | null;
|
|
23
|
+
/**
|
|
24
|
+
* Clear the stored cross-block range (call after DOM mutations that
|
|
25
|
+
* invalidate the range's node references).
|
|
26
|
+
* @param {import('../types.js').ICrossBlockSelection | null} [cbs]
|
|
27
|
+
* @param {Node} [contextNode] - any node inside the editor for scoping
|
|
28
|
+
* @returns {void}
|
|
29
|
+
*/
|
|
30
|
+
export function clearCrossBlockRange(cbs?: import("../types.js").ICrossBlockSelection | null, contextNode?: Node): void;
|
|
31
|
+
/**
|
|
32
|
+
* Find the text node and offset at a given character position.
|
|
33
|
+
* @param {Node} container
|
|
34
|
+
* @param {number} charOffset
|
|
35
|
+
* @param {'start' | 'end'} [bias='start'] - when the offset lands exactly at a
|
|
36
|
+
* node boundary, 'start' prefers the beginning of the next node (for range
|
|
37
|
+
* start points), 'end' prefers the end of the current node (for range end
|
|
38
|
+
* points). This avoids creating ranges that inadvertently cross into adjacent
|
|
39
|
+
* inline wrappers.
|
|
40
|
+
* @returns {{ node: Node, offset: number } | null}
|
|
41
|
+
*/
|
|
42
|
+
export function findNodeAtOffset(container: Node, charOffset: number, bias?: "start" | "end"): {
|
|
43
|
+
node: Node;
|
|
44
|
+
offset: number;
|
|
45
|
+
} | null;
|
|
46
|
+
/**
|
|
47
|
+
* Save cross-block range as block IDs + character offsets (survives DOM mutations).
|
|
48
|
+
* @param {Range} range
|
|
49
|
+
* @returns {{ editorRoot: HTMLElement, startBlockId: string, endBlockId: string, startFieldIndex: number, endFieldIndex: number, startOffset: number, endOffset: number } | null}
|
|
50
|
+
*/
|
|
51
|
+
export function saveCrossBlockOffsets(range: Range): {
|
|
52
|
+
editorRoot: HTMLElement;
|
|
53
|
+
startBlockId: string;
|
|
54
|
+
endBlockId: string;
|
|
55
|
+
startFieldIndex: number;
|
|
56
|
+
endFieldIndex: number;
|
|
57
|
+
startOffset: number;
|
|
58
|
+
endOffset: number;
|
|
59
|
+
} | null;
|
|
60
|
+
/**
|
|
61
|
+
* Restore cross-block range from saved offsets. Updates CrossBlockSelection and CSS Highlight.
|
|
62
|
+
* @param {import('../types.js').ICrossBlockSelection | null} cbs
|
|
63
|
+
* @param {{ editorRoot: HTMLElement, startBlockId: string, endBlockId: string, startFieldIndex?: number, endFieldIndex?: number, startOffset: number, endOffset: number }} offsets
|
|
64
|
+
* @returns {Range | null}
|
|
65
|
+
*/
|
|
66
|
+
export function restoreCrossBlockRange(cbs: import("../types.js").ICrossBlockSelection | null, offsets: {
|
|
67
|
+
editorRoot: HTMLElement;
|
|
68
|
+
startBlockId: string;
|
|
69
|
+
endBlockId: string;
|
|
70
|
+
startFieldIndex?: number;
|
|
71
|
+
endFieldIndex?: number;
|
|
72
|
+
startOffset: number;
|
|
73
|
+
endOffset: number;
|
|
74
|
+
}): Range | null;
|
|
75
|
+
/**
|
|
76
|
+
* Check if a selection spans multiple .oe-block elements.
|
|
77
|
+
* @param {import('../types.js').ICrossBlockSelection | null} [cbs]
|
|
78
|
+
* @returns {HTMLElement[] | null} Array of plugin-owned block roots, or null if single-block
|
|
79
|
+
*/
|
|
80
|
+
export function getSelectedBlockElements(cbs?: import("../types.js").ICrossBlockSelection | null): HTMLElement[] | null;
|
|
81
|
+
/**
|
|
82
|
+
* Dispatch a synthetic input event on the nearest contenteditable to trigger
|
|
83
|
+
* undo/redo snapshot via EditorFacade.onInput → editor:changed.
|
|
84
|
+
* @param {Node} [contextNode] - any node inside the editor for scoping
|
|
85
|
+
* @returns {void}
|
|
86
|
+
*/
|
|
87
|
+
export function notifyEditorChanged(contextNode?: Node): void;
|
|
88
|
+
/**
|
|
89
|
+
* Create a simple tag-based inline tool.
|
|
90
|
+
* @param {string} type
|
|
91
|
+
* @param {string} title
|
|
92
|
+
* @param {string} icon
|
|
93
|
+
* @param {string} tag
|
|
94
|
+
* @param {string} [shortcut]
|
|
95
|
+
* @param {import('../types.js').ICrossBlockSelection} [cbs]
|
|
96
|
+
* @returns {import('../types.js').InlineTool}
|
|
97
|
+
*/
|
|
98
|
+
export function createSimpleInlineTool(type: string, title: string, icon: string, tag: string, shortcut?: string, cbs?: import("../types.js").ICrossBlockSelection): import("../types.js").InlineTool;
|
|
99
|
+
/**
|
|
100
|
+
* Find the contentEditable block element from the current selection.
|
|
101
|
+
* @returns {HTMLElement | null}
|
|
102
|
+
*/
|
|
103
|
+
export function getBlockElement(): HTMLElement | null;
|
|
104
|
+
/**
|
|
105
|
+
* Find the plugin-owned root of the block containing the current selection.
|
|
106
|
+
* Unlike {@link getBlockElement}, this returns the block content root rather
|
|
107
|
+
* than one nested editable field, so block-level settings survive plugins
|
|
108
|
+
* with several text fields.
|
|
109
|
+
* @returns {HTMLElement | null}
|
|
110
|
+
*/
|
|
111
|
+
export function getBlockContentElement(): HTMLElement | null;
|
|
112
|
+
/**
|
|
113
|
+
* Find the contentEditable ancestor of a range's start.
|
|
114
|
+
* Returns null for cross-block ranges (start and end in different contenteditables).
|
|
115
|
+
* @param {Range} range
|
|
116
|
+
* @returns {HTMLElement | null}
|
|
117
|
+
*/
|
|
118
|
+
export function getContentEditable(range: Range): HTMLElement | null;
|
|
119
|
+
/**
|
|
120
|
+
* Resolve the DOM root to walk for range operations.
|
|
121
|
+
* Uses contenteditable for single-block ranges, commonAncestorContainer for cross-block.
|
|
122
|
+
* @param {Range} range
|
|
123
|
+
* @returns {HTMLElement | null}
|
|
124
|
+
*/
|
|
125
|
+
export function getWalkRoot(range: Range): HTMLElement | null;
|
|
126
|
+
/**
|
|
127
|
+
* Collect text nodes within a range, clipped to range boundaries.
|
|
128
|
+
* @param {HTMLElement} walkRoot
|
|
129
|
+
* @param {Range} range
|
|
130
|
+
* @returns {{ node: Text, startOffset: number, endOffset: number }[]}
|
|
131
|
+
*/
|
|
132
|
+
export function collectTextTargets(walkRoot: HTMLElement, range: Range): {
|
|
133
|
+
node: Text;
|
|
134
|
+
startOffset: number;
|
|
135
|
+
endOffset: number;
|
|
136
|
+
}[];
|
|
137
|
+
/**
|
|
138
|
+
* Normalize contenteditables after DOM manipulation.
|
|
139
|
+
* @param {HTMLElement | null} singleCe - single contenteditable (null for cross-block)
|
|
140
|
+
* @param {HTMLElement} walkRoot
|
|
141
|
+
* @returns {void}
|
|
142
|
+
*/
|
|
143
|
+
export function normalizeAfterEdit(singleCe: HTMLElement | null, walkRoot: HTMLElement): void;
|
|
144
|
+
/**
|
|
145
|
+
* @typedef {Object} SavedOffsets
|
|
146
|
+
* @property {{ editorRoot: HTMLElement, startBlockId: string, endBlockId: string, startFieldIndex: number, endFieldIndex: number, startOffset: number, endOffset: number } | null} crossOffsets - Serialized selection spanning multiple editable block fields.
|
|
147
|
+
* @property {{ ce: Node, start: number, end: number } | null} singleOffsets - Text offsets and owning editable node for a selection contained in one field.
|
|
148
|
+
*/
|
|
149
|
+
/**
|
|
150
|
+
* Save selection offsets (cross-block or single-block) before DOM mutation.
|
|
151
|
+
* @param {Range} range
|
|
152
|
+
* @returns {SavedOffsets}
|
|
153
|
+
*/
|
|
154
|
+
export function saveSelectionOffsets(range: Range): SavedOffsets;
|
|
155
|
+
/**
|
|
156
|
+
* Restore selection from saved offsets after DOM mutation.
|
|
157
|
+
* @param {import('../types.js').ICrossBlockSelection | null} cbs
|
|
158
|
+
* @param {SavedOffsets} saved
|
|
159
|
+
* @returns {void}
|
|
160
|
+
*/
|
|
161
|
+
export function restoreSelectionOffsets(cbs: import("../types.js").ICrossBlockSelection | null, saved: SavedOffsets): void;
|
|
162
|
+
/**
|
|
163
|
+
* Create a standard back button for inline toolbar drill-down panels.
|
|
164
|
+
* @param {{ close(): void }} ctx
|
|
165
|
+
* @returns {HTMLElement}
|
|
166
|
+
*/
|
|
167
|
+
export function createBackButton(ctx: {
|
|
168
|
+
close(): void;
|
|
169
|
+
}): HTMLElement;
|
|
170
|
+
/** SVG markup for the bold formatting control. */
|
|
171
|
+
export const ICON_BOLD: string;
|
|
172
|
+
/** SVG markup for the italic formatting control. */
|
|
173
|
+
export const ICON_ITALIC: string;
|
|
174
|
+
/** SVG markup for the link formatting control. */
|
|
175
|
+
export const ICON_LINK: string;
|
|
176
|
+
/** SVG markup for the inline-code formatting control. */
|
|
177
|
+
export const ICON_CODE: string;
|
|
178
|
+
/** SVG markup for the text-highlight formatting control. */
|
|
179
|
+
export const ICON_HIGHLIGHT: string;
|
|
180
|
+
/** SVG markup for the strikethrough formatting control. */
|
|
181
|
+
export const ICON_STRIKETHROUGH: string;
|
|
182
|
+
/** SVG markup for the left-alignment control. */
|
|
183
|
+
export const ICON_ALIGN_LEFT: string;
|
|
184
|
+
/** SVG markup for the center-alignment control. */
|
|
185
|
+
export const ICON_ALIGN_CENTER: string;
|
|
186
|
+
/** SVG markup for the right-alignment control. */
|
|
187
|
+
export const ICON_ALIGN_RIGHT: string;
|
|
188
|
+
/** SVG markup for the justified-alignment control. */
|
|
189
|
+
export const ICON_ALIGN_JUSTIFY: string;
|
|
190
|
+
/** SVG markup for the remove-link control. */
|
|
191
|
+
export const ICON_UNLINK: string;
|
|
192
|
+
/** SVG markup for confirmation controls. */
|
|
193
|
+
export const ICON_CHECK: string;
|
|
194
|
+
/** SVG markup for the clear-formatting control. */
|
|
195
|
+
export const ICON_CLEAR: string;
|
|
196
|
+
export type SavedOffsets = {
|
|
197
|
+
/**
|
|
198
|
+
* - Serialized selection spanning multiple editable block fields.
|
|
199
|
+
*/
|
|
200
|
+
crossOffsets: {
|
|
201
|
+
editorRoot: HTMLElement;
|
|
202
|
+
startBlockId: string;
|
|
203
|
+
endBlockId: string;
|
|
204
|
+
startFieldIndex: number;
|
|
205
|
+
endFieldIndex: number;
|
|
206
|
+
startOffset: number;
|
|
207
|
+
endOffset: number;
|
|
208
|
+
} | null;
|
|
209
|
+
/**
|
|
210
|
+
* - Text offsets and owning editable node for a selection contained in one field.
|
|
211
|
+
*/
|
|
212
|
+
singleOffsets: {
|
|
213
|
+
ce: Node;
|
|
214
|
+
start: number;
|
|
215
|
+
end: number;
|
|
216
|
+
} | null;
|
|
217
|
+
};
|
|
218
|
+
import { ICON_BACK } from '../core/icons.js';
|
|
219
|
+
import { getTextOffset } from '../core/textOffset.js';
|
|
220
|
+
export { ICON_BACK, getTextOffset };
|