@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,165 @@
|
|
|
1
|
+
// =============================================================================
|
|
2
|
+
// Quote — blockquote with optional caption
|
|
3
|
+
// =============================================================================
|
|
4
|
+
|
|
5
|
+
import { sanitizeHtml } from '../../core/sanitize.js'
|
|
6
|
+
import { resolvePath } from '../../shared/resolvePath.js'
|
|
7
|
+
import { BlockPluginAbstract } from '../BlockPluginAbstract.js'
|
|
8
|
+
import { mapTextFields } from './mapTextFields.js'
|
|
9
|
+
import { validateQuoteData } from '../../shared/blockDataValidators.js'
|
|
10
|
+
import { normalizeTextValue } from '../../shared/textFormat.js'
|
|
11
|
+
|
|
12
|
+
const editorStyles = resolvePath('./quote.css', import.meta.url)
|
|
13
|
+
|
|
14
|
+
// Tabler icon: blockquote
|
|
15
|
+
const ICON = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="M9 5a2 2 0 0 1 2 2v6c0 3.13 -1.65 5.193 -4.757 5.97a1 1 0 1 1 -.486 -1.94c2.227 -.557 3.243 -1.827 3.243 -4.03v-1h-3a2 2 0 0 1 -1.995 -1.85l-.005 -.15v-3a2 2 0 0 1 2 -2z"/><path d="M18 5a2 2 0 0 1 2 2v6c0 3.13 -1.65 5.193 -4.757 5.97a1 1 0 1 1 -.486 -1.94c2.227 -.557 3.243 -1.827 3.243 -4.03v-1h-3a2 2 0 0 1 -1.995 -1.85l-.005 -.15v-3a2 2 0 0 1 2 -2z"/></svg>'
|
|
16
|
+
|
|
17
|
+
/** Editable quotation with optional attribution. */
|
|
18
|
+
export class Quote extends BlockPluginAbstract {
|
|
19
|
+
static isTextBlock = true
|
|
20
|
+
static styles = [editorStyles]
|
|
21
|
+
type = 'quote'
|
|
22
|
+
icon = ICON
|
|
23
|
+
inlineTools = true
|
|
24
|
+
mapTextFields = mapTextFields
|
|
25
|
+
pasteConfig = {
|
|
26
|
+
tags: ['blockquote'],
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Return the localized toolbox label for this block.
|
|
31
|
+
* @returns {string}
|
|
32
|
+
*/
|
|
33
|
+
get title() {
|
|
34
|
+
return this._t('title', 'Quote')
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Create the editable DOM owned by this block instance.
|
|
39
|
+
* @param {{ text?: string, caption?: string }} data
|
|
40
|
+
* @returns {HTMLElement}
|
|
41
|
+
*/
|
|
42
|
+
render(data) {
|
|
43
|
+
const wrapper = document.createElement('div')
|
|
44
|
+
wrapper.classList.add('oe-quote')
|
|
45
|
+
|
|
46
|
+
const blockquote = document.createElement('blockquote')
|
|
47
|
+
blockquote.classList.add('oe-quote__text')
|
|
48
|
+
blockquote.contentEditable = 'true'
|
|
49
|
+
blockquote.dataset.placeholder = this._t('textPlaceholder', 'Quote')
|
|
50
|
+
const text = normalizeTextValue(data?.text)
|
|
51
|
+
if (text) {
|
|
52
|
+
blockquote.innerHTML = sanitizeHtml(text)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const caption = document.createElement('cite')
|
|
56
|
+
caption.classList.add('oe-quote__caption')
|
|
57
|
+
caption.contentEditable = 'true'
|
|
58
|
+
caption.dataset.placeholder = this._t('captionPlaceholder', 'Caption')
|
|
59
|
+
const captionText = normalizeTextValue(data?.caption)
|
|
60
|
+
if (captionText) {
|
|
61
|
+
caption.innerHTML = sanitizeHtml(captionText)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Move between the two fields without trapping focus at block boundaries.
|
|
65
|
+
wrapper.addEventListener('keydown', (e) => {
|
|
66
|
+
if (e.key !== 'Tab') return
|
|
67
|
+
const active = document.activeElement
|
|
68
|
+
const inQuote = active === blockquote || blockquote.contains(/** @type {Node} */ (active))
|
|
69
|
+
const inCaption = active === caption || caption.contains(/** @type {Node} */ (active))
|
|
70
|
+
if (!e.shiftKey && inQuote) {
|
|
71
|
+
e.preventDefault()
|
|
72
|
+
e.stopPropagation()
|
|
73
|
+
caption.focus()
|
|
74
|
+
} else if (e.shiftKey && inCaption) {
|
|
75
|
+
e.preventDefault()
|
|
76
|
+
e.stopPropagation()
|
|
77
|
+
blockquote.focus()
|
|
78
|
+
}
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
wrapper.appendChild(blockquote)
|
|
82
|
+
wrapper.appendChild(caption)
|
|
83
|
+
|
|
84
|
+
return wrapper
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Serialize the current block DOM into document data.
|
|
89
|
+
* @param {HTMLElement} element
|
|
90
|
+
* @returns {{ text: string, caption: string }}
|
|
91
|
+
*/
|
|
92
|
+
save(element) {
|
|
93
|
+
const textEl = element.querySelector('.oe-quote__text')
|
|
94
|
+
const captionEl = element.querySelector('.oe-quote__caption')
|
|
95
|
+
return {
|
|
96
|
+
text: textEl?.innerHTML.trim() || '',
|
|
97
|
+
caption: captionEl?.innerHTML.trim() || '',
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Check whether serialized data satisfies this block's schema.
|
|
103
|
+
* @param {{ text?: string, caption?: string }} data
|
|
104
|
+
* @returns {boolean}
|
|
105
|
+
*/
|
|
106
|
+
validate(data) {
|
|
107
|
+
return validateQuoteData(data)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Merge incoming text into the current block.
|
|
112
|
+
* @param {HTMLElement} element
|
|
113
|
+
* @param {{ text?: string }} data
|
|
114
|
+
* @returns {void}
|
|
115
|
+
*/
|
|
116
|
+
merge(element, data) {
|
|
117
|
+
const textEl = element.querySelector('.oe-quote__text')
|
|
118
|
+
const text = normalizeTextValue(data.text)
|
|
119
|
+
if (textEl && text) {
|
|
120
|
+
textEl.innerHTML += sanitizeHtml(text)
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Extract neutral fields that can initialize another block type.
|
|
126
|
+
* @param {HTMLElement} element
|
|
127
|
+
* @returns {{ text: string, caption: string }}
|
|
128
|
+
*/
|
|
129
|
+
exportData(element) {
|
|
130
|
+
const textEl = element.querySelector('.oe-quote__text')
|
|
131
|
+
const captionEl = element.querySelector('.oe-quote__caption')
|
|
132
|
+
return {
|
|
133
|
+
text: textEl?.innerHTML.trim() || '',
|
|
134
|
+
caption: captionEl?.innerHTML.trim() || '',
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Check whether the block has no meaningful user content.
|
|
140
|
+
* @param {HTMLElement} element
|
|
141
|
+
* @returns {boolean}
|
|
142
|
+
*/
|
|
143
|
+
isEmpty(element) {
|
|
144
|
+
const textEl = element.querySelector('.oe-quote__text')
|
|
145
|
+
const captionEl = element.querySelector('.oe-quote__caption')
|
|
146
|
+
return !textEl?.textContent?.trim() && !captionEl?.textContent?.trim()
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Handle pasted blockquote elements.
|
|
151
|
+
* @param {import('../../types').TagPasteEvent} event
|
|
152
|
+
* @returns {{ text: string, caption: string } | null}
|
|
153
|
+
*/
|
|
154
|
+
onPaste(event) {
|
|
155
|
+
if (event.type !== 'tag') return null
|
|
156
|
+
// Clone to avoid mutating the original pasted element
|
|
157
|
+
const clone = /** @type {HTMLElement} */ (event.element.cloneNode(true))
|
|
158
|
+
// Extract cite if present
|
|
159
|
+
const cite = clone.querySelector('cite, footer, figcaption')
|
|
160
|
+
const caption = cite?.innerHTML?.trim() || ''
|
|
161
|
+
if (cite) cite.remove()
|
|
162
|
+
return { text: clone.innerHTML, caption }
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { mapQuoteTextFields as mapTextFields } from "../../shared/mapTextFields.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { mapQuoteTextFields as mapTextFields } from '../../shared/mapTextFields.js'
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/* =============================================================================
|
|
2
|
+
Quote plugin — edit mode styles
|
|
3
|
+
============================================================================= */
|
|
4
|
+
|
|
5
|
+
.oe-quote {
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
gap: 6px;
|
|
9
|
+
padding-left: 16px;
|
|
10
|
+
border-left: 3px solid var(--oe-accent, #4357b4);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.oe-quote__text {
|
|
14
|
+
margin: 0;
|
|
15
|
+
padding: 0;
|
|
16
|
+
font-size: var(--oe-font-size, 15px);
|
|
17
|
+
line-height: var(--oe-line-height, 1.7);
|
|
18
|
+
color: var(--oe-text-1, #f5f5f5);
|
|
19
|
+
font-family: var(--oe-font, inherit);
|
|
20
|
+
font-style: italic;
|
|
21
|
+
outline: none;
|
|
22
|
+
word-break: break-word;
|
|
23
|
+
white-space: pre-wrap;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.oe-quote__caption {
|
|
27
|
+
margin: 0;
|
|
28
|
+
padding: 0;
|
|
29
|
+
font-size: 0.85em;
|
|
30
|
+
line-height: 1.5;
|
|
31
|
+
color: var(--oe-text-3, #908c8c);
|
|
32
|
+
font-family: var(--oe-font, inherit);
|
|
33
|
+
font-style: normal;
|
|
34
|
+
outline: none;
|
|
35
|
+
word-break: break-word;
|
|
36
|
+
white-space: pre-wrap;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/* Placeholders */
|
|
40
|
+
.oe-quote__text:empty::before,
|
|
41
|
+
.oe-quote__caption:empty::before {
|
|
42
|
+
content: attr(data-placeholder);
|
|
43
|
+
color: var(--oe-text-3, #908c8c);
|
|
44
|
+
pointer-events: none;
|
|
45
|
+
font-weight: 400;
|
|
46
|
+
font-style: normal;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/* Inline formatting */
|
|
50
|
+
.oe-quote__text b,
|
|
51
|
+
.oe-quote__text strong {
|
|
52
|
+
font-weight: 600;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.oe-quote__text a {
|
|
56
|
+
color: var(--oe-text-2, #c4c4c4);
|
|
57
|
+
text-decoration: underline;
|
|
58
|
+
text-underline-offset: 3px;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.oe-quote__text a:hover {
|
|
62
|
+
color: var(--oe-text-1, #f5f5f5);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* font-style: normal for code inside italic quote text */
|
|
66
|
+
.oe-quote__text code { font-style: normal; }
|
|
67
|
+
|
|
68
|
+
.oe-quote__text mark {
|
|
69
|
+
padding: 1px 4px;
|
|
70
|
+
background: var(--oe-mark-bg, rgba(245, 166, 35, 0.2));
|
|
71
|
+
border-radius: 3px;
|
|
72
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Raw block plugin
|
|
2
|
+
|
|
3
|
+
Raw HTML authoring block.
|
|
4
|
+
|
|
5
|
+
## Install and register
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @shelamkoff/rector
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
import { createEditor } from '@shelamkoff/rector'
|
|
13
|
+
import { Raw } from '@shelamkoff/rector/plugins/raw'
|
|
14
|
+
import '@shelamkoff/rector/styles/editor.css'
|
|
15
|
+
|
|
16
|
+
const editor = createEditor({
|
|
17
|
+
holder: document.querySelector('#editor'),
|
|
18
|
+
plugins: [new Raw()],
|
|
19
|
+
})
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The registered block type is `raw`. The class is also exported by the complete `@shelamkoff/rector/plugins` preset and can be loaded through `@shelamkoff/rector/plugins/async`.
|
|
23
|
+
|
|
24
|
+
## Data
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
{ "html": "<section>Content</section>" }
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Field reference
|
|
31
|
+
|
|
32
|
+
| Field | Required | Meaning and constraints |
|
|
33
|
+
| --- | --- | --- |
|
|
34
|
+
| `html` | yes | Non-blank HTML source string. |
|
|
35
|
+
|
|
36
|
+
HTML stays inert in the source editor. Tab indents the selected lines and Shift+Tab removes one leading tab or up to two leading spaces; each indentation action is one history step. The preview is shown automatically in read-only mode and can be toggled while editing. Both the editor preview and the matching renderer sanitize the source before mounting it. The editor preview additionally uses a sandboxed iframe without script permissions. Active elements, unsafe URLs, event attributes, and unsafe CSS are removed, but allowed remote images and other safe resources can still cause browser requests, so the host remains responsible for its network and content policy. An empty draft does not pass strict persisted-data validation.
|
|
37
|
+
|
|
38
|
+
## Configuration
|
|
39
|
+
|
|
40
|
+
Every built-in block plugin accepts two style ownership options: `injectStyles?: boolean` defaults to `true`; set it to `false` when the host bundles that plugin's CSS. `css?: string` adds one host-provided stylesheet URL after the plugin default, or acts as the replacement URL when default injection is disabled.
|
|
41
|
+
|
|
42
|
+
## Capabilities
|
|
43
|
+
|
|
44
|
+
Raw text editing; multiline Tab and Shift+Tab indentation; sandboxed editor preview; sanitized document rendering; automatic preview in read-only mode.
|
|
45
|
+
|
|
46
|
+
## Undo, lifecycle, and styles
|
|
47
|
+
|
|
48
|
+
User actions exposed by the plugin enter the command pipeline through the supplied `context.mutate()` capability, so each completed action is one undo/redo step. The editor reference-counts the plugin's declared stylesheet URLs. Removing a block calls its cleanup hook; removing the editor calls `destroy()` for every remaining block and then releases shared plugin resources.
|
|
49
|
+
|
|
50
|
+
Do not remove the editor holder without first calling `editor.destroy()`.
|
|
51
|
+
|
|
52
|
+
## Document output
|
|
53
|
+
|
|
54
|
+
Use the matching renderer from `@shelamkoff/rector/renderer/renderers/raw`. The VitePress guide documents configuration, commands and history, extension contracts, document migrations, styling, security, and lifecycle in a sequential form.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Блочный плагин Raw
|
|
2
|
+
|
|
3
|
+
Блок для ввода произвольного HTML.
|
|
4
|
+
|
|
5
|
+
## Установка и регистрация
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @shelamkoff/rector
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
import { createEditor } from '@shelamkoff/rector'
|
|
13
|
+
import { Raw } from '@shelamkoff/rector/plugins/raw'
|
|
14
|
+
import '@shelamkoff/rector/styles/editor.css'
|
|
15
|
+
|
|
16
|
+
const editor = createEditor({
|
|
17
|
+
holder: document.querySelector('#editor'),
|
|
18
|
+
plugins: [new Raw()],
|
|
19
|
+
})
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Тип блока — `raw`. Класс также экспортируется общей точкой входа `@shelamkoff/rector/plugins` и может загружаться по типу документа через `@shelamkoff/rector/plugins/async`.
|
|
23
|
+
|
|
24
|
+
## Данные
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
{ "html": "<section>Содержимое</section>" }
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Поля данных
|
|
31
|
+
|
|
32
|
+
| Поле | Обязательно | Назначение и ограничения |
|
|
33
|
+
| --- | --- | --- |
|
|
34
|
+
| `html` | да | Непустая строка с исходным HTML. |
|
|
35
|
+
|
|
36
|
+
В поле исходного текста HTML остаётся неактивным. `Tab` добавляет отступ выбранным строкам, а `Shift+Tab` удаляет один начальный знак табуляции или до двух начальных пробелов; одно изменение отступа создаёт один шаг истории. В режиме только для просмотра предварительный результат открывается автоматически, а при редактировании его можно включить кнопкой. И предварительный просмотр, и соответствующий рендерер очищают исходный код до добавления в DOM. Предварительный просмотр дополнительно работает в изолированном `iframe` без разрешения на выполнение сценариев. Активные элементы, небезопасные адреса, атрибуты событий и небезопасные стили удаляются, но разрешённые удалённые изображения и другие безопасные ресурсы всё ещё могут создавать сетевые запросы браузера. Поэтому сетевую политику и политику содержимого задаёт приложение. Пустой черновик не проходит строгую проверку сохранённых данных.
|
|
37
|
+
|
|
38
|
+
## Конфигурация
|
|
39
|
+
|
|
40
|
+
Каждый встроенный блочный плагин принимает два параметра владения стилями: `injectStyles?: boolean` по умолчанию равен `true`; укажите `false`, если приложение само включает CSS этого плагина. `css?: string` добавляет URL таблицы стилей приложения после стандартной, а при отключённой стандартной инъекции служит URL замены.
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
## Возможности
|
|
44
|
+
|
|
45
|
+
Редактирование исходного текста; многострочные отступы через `Tab` и `Shift+Tab`; изолированный предварительный просмотр; очищенный итоговый DOM; автоматический предварительный просмотр в режиме только для чтения.
|
|
46
|
+
|
|
47
|
+
## История, жизненный цикл и стили
|
|
48
|
+
|
|
49
|
+
Действия плагина входят в конвейер команд через предоставленный контекст `mutate()`, поэтому одно завершённое действие создаёт один шаг отмены и повтора. Редактор подсчитывает владельцев объявленных URL стилей. Удаление блока вызывает его метод освобождения ресурсов; `editor.destroy()` освобождает оставшиеся блоки и общие ресурсы.
|
|
50
|
+
|
|
51
|
+
Не удаляйте контейнер редактора до вызова `editor.destroy()`.
|
|
52
|
+
|
|
53
|
+
## Вывод документа
|
|
54
|
+
|
|
55
|
+
Используйте фабричную функцию из `@shelamkoff/rector/renderer/renderers/raw`. Последовательное руководство VitePress описывает проверку данных, миграции, разработку расширений, диагностику, безопасность и стили.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type {} from './locale/keys.js'
|
|
2
|
+
/** Raw HTML source block with an optional sanitized editor preview. */
|
|
3
|
+
export class Raw extends BlockPluginAbstract<Record<string, any>> {
|
|
4
|
+
static isTextBlock: boolean;
|
|
5
|
+
static styles: string[];
|
|
6
|
+
constructor(config?: Record<string, any>);
|
|
7
|
+
type: string;
|
|
8
|
+
icon: string;
|
|
9
|
+
inlineTools: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Return the localized toolbox label for this block.
|
|
12
|
+
* @returns {string}
|
|
13
|
+
*/
|
|
14
|
+
get title(): string;
|
|
15
|
+
/**
|
|
16
|
+
* Create the editable DOM owned by this block instance.
|
|
17
|
+
* @param {{ html?: string }} data
|
|
18
|
+
* @param {import('../../core/types.js').BlockMutationContext} context
|
|
19
|
+
* @returns {HTMLElement}
|
|
20
|
+
*/
|
|
21
|
+
render(data: {
|
|
22
|
+
html?: string;
|
|
23
|
+
}, context: import("../../core/types.js").BlockMutationContext): HTMLElement;
|
|
24
|
+
/**
|
|
25
|
+
* Serialize the current block DOM into document data.
|
|
26
|
+
* @param {HTMLElement} element
|
|
27
|
+
* @returns {{ html: string }}
|
|
28
|
+
*/
|
|
29
|
+
save(element: HTMLElement): {
|
|
30
|
+
html: string;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Check whether serialized data satisfies this block's schema.
|
|
34
|
+
* @param {{ html?: string }} data
|
|
35
|
+
* @returns {boolean}
|
|
36
|
+
*/
|
|
37
|
+
validate(data: {
|
|
38
|
+
html?: string;
|
|
39
|
+
}): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Check whether the block has no meaningful user content.
|
|
42
|
+
* @param {HTMLElement} element
|
|
43
|
+
* @returns {boolean}
|
|
44
|
+
*/
|
|
45
|
+
isEmpty(element: HTMLElement): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Extract neutral text that can initialize another block type.
|
|
48
|
+
* @param {HTMLElement} element
|
|
49
|
+
* @returns {{ text: string }}
|
|
50
|
+
*/
|
|
51
|
+
exportData(element: HTMLElement): {
|
|
52
|
+
text: string;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Release listeners and resources owned by this block element.
|
|
56
|
+
* @param {HTMLElement} element
|
|
57
|
+
* @returns {void}
|
|
58
|
+
*/
|
|
59
|
+
destroy(element: HTMLElement): void;
|
|
60
|
+
#private;
|
|
61
|
+
}
|
|
62
|
+
import { BlockPluginAbstract } from '../BlockPluginAbstract.js';
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { resolvePath } from '../../shared/resolvePath.js'
|
|
2
|
+
import { BlockPluginAbstract } from '../BlockPluginAbstract.js'
|
|
3
|
+
import { validateRawData } from '../../shared/blockDataValidators.js'
|
|
4
|
+
import { normalizeTextValue } from '../../shared/textFormat.js'
|
|
5
|
+
import { sanitizeRawHtml } from '../../shared/sanitize/sanitizeRawHtml.js'
|
|
6
|
+
|
|
7
|
+
const editorStyles = resolvePath('./raw.css', import.meta.url)
|
|
8
|
+
|
|
9
|
+
const ICON = '<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="M13 16v-8l2 5l2-5v8"/><path d="M1 16v-8"/><path d="M5 8v8"/><path d="M1 12h4"/><path d="M7 8h4"/><path d="M9 8v8"/><path d="M20 8v8h3"/></svg>'
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
const stateMap = new WeakMap()
|
|
13
|
+
let rawSequence = 0
|
|
14
|
+
/** Raw HTML source block with an optional sanitized editor preview. */
|
|
15
|
+
export class Raw extends BlockPluginAbstract {
|
|
16
|
+
static isTextBlock = false
|
|
17
|
+
static styles = [editorStyles]
|
|
18
|
+
type = 'raw'
|
|
19
|
+
icon = ICON
|
|
20
|
+
inlineTools = false
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Return the localized toolbox label for this block.
|
|
24
|
+
* @returns {string}
|
|
25
|
+
*/
|
|
26
|
+
get title() {
|
|
27
|
+
return this._t('title', 'Raw HTML')
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Create the editable DOM owned by this block instance.
|
|
32
|
+
* @param {{ html?: string }} data
|
|
33
|
+
* @param {import('../../core/types').BlockMutationContext} context
|
|
34
|
+
* @returns {HTMLElement}
|
|
35
|
+
*/
|
|
36
|
+
render(data, context) {
|
|
37
|
+
const previewId = `oe-raw-preview-${++rawSequence}`
|
|
38
|
+
const wrapper = document.createElement('div')
|
|
39
|
+
wrapper.classList.add('oe-raw')
|
|
40
|
+
wrapper.contentEditable = 'false'
|
|
41
|
+
wrapper.tabIndex = -1
|
|
42
|
+
|
|
43
|
+
// Header bar
|
|
44
|
+
const bar = document.createElement('div')
|
|
45
|
+
bar.className = 'oe-raw__bar'
|
|
46
|
+
|
|
47
|
+
const label = document.createElement('span')
|
|
48
|
+
label.className = 'oe-raw__label'
|
|
49
|
+
label.textContent = 'HTML'
|
|
50
|
+
|
|
51
|
+
const toggleBtn = document.createElement('button')
|
|
52
|
+
toggleBtn.type = 'button'
|
|
53
|
+
toggleBtn.className = 'oe-raw__toggle'
|
|
54
|
+
toggleBtn.textContent = this._t('preview', 'Preview')
|
|
55
|
+
toggleBtn.setAttribute('aria-pressed', 'false')
|
|
56
|
+
toggleBtn.setAttribute('aria-controls', previewId)
|
|
57
|
+
toggleBtn.hidden = context.readOnly
|
|
58
|
+
toggleBtn.disabled = context.readOnly
|
|
59
|
+
toggleBtn.addEventListener('mousedown', (e) => e.preventDefault())
|
|
60
|
+
toggleBtn.addEventListener('click', () => {
|
|
61
|
+
const s = stateMap.get(wrapper)
|
|
62
|
+
if (s) {
|
|
63
|
+
s.showPreview = !s.showPreview
|
|
64
|
+
toggleBtn.setAttribute('aria-pressed', String(s.showPreview))
|
|
65
|
+
this.#syncPreview(wrapper)
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
bar.append(label, toggleBtn)
|
|
70
|
+
|
|
71
|
+
// Textarea (code input)
|
|
72
|
+
const textarea = document.createElement('textarea')
|
|
73
|
+
textarea.className = 'oe-raw__textarea'
|
|
74
|
+
textarea.placeholder = this._t('placeholder', 'Paste HTML code...')
|
|
75
|
+
textarea.value = normalizeTextValue(data?.html)
|
|
76
|
+
textarea.spellcheck = false
|
|
77
|
+
textarea.readOnly = context.readOnly
|
|
78
|
+
textarea.addEventListener('input', () => {
|
|
79
|
+
this.#autoResize(textarea)
|
|
80
|
+
})
|
|
81
|
+
textarea.addEventListener('keydown', (e) => {
|
|
82
|
+
if (e.key === 'Enter') e.stopPropagation()
|
|
83
|
+
if (e.key === 'Tab') {
|
|
84
|
+
e.preventDefault()
|
|
85
|
+
e.stopPropagation()
|
|
86
|
+
context.mutate(() => {
|
|
87
|
+
const start = textarea.selectionStart
|
|
88
|
+
const end = textarea.selectionEnd
|
|
89
|
+
const value = textarea.value
|
|
90
|
+
const lineStart = value.lastIndexOf('\n', start - 1) + 1
|
|
91
|
+
if (e.shiftKey) {
|
|
92
|
+
const selected = value.substring(lineStart, end)
|
|
93
|
+
const dedented = selected.replace(/^ {1,2}/gm, '')
|
|
94
|
+
if (selected === dedented) return
|
|
95
|
+
const firstIndent = selected.match(/^ {1,2}/)?.[0].length ?? 0
|
|
96
|
+
textarea.value = value.substring(0, lineStart) + dedented + value.substring(end)
|
|
97
|
+
textarea.selectionStart = Math.max(lineStart, start - firstIndent)
|
|
98
|
+
textarea.selectionEnd = end > start
|
|
99
|
+
? lineStart + dedented.length
|
|
100
|
+
: textarea.selectionStart
|
|
101
|
+
} else if (start !== end && value.substring(start, end).includes('\n')) {
|
|
102
|
+
const before = value.substring(0, start)
|
|
103
|
+
const selected = value.substring(start, end)
|
|
104
|
+
const after = value.substring(end)
|
|
105
|
+
const prefix = before.substring(lineStart)
|
|
106
|
+
const indented = ' ' + (prefix + selected).replace(/\n/g, '\n ')
|
|
107
|
+
textarea.value = before.substring(0, lineStart) + indented + after
|
|
108
|
+
textarea.selectionStart = lineStart
|
|
109
|
+
textarea.selectionEnd = lineStart + indented.length
|
|
110
|
+
} else {
|
|
111
|
+
textarea.value = value.substring(0, start) + ' ' + value.substring(end)
|
|
112
|
+
textarea.selectionStart = textarea.selectionEnd = start + 2
|
|
113
|
+
}
|
|
114
|
+
this.#autoResize(textarea)
|
|
115
|
+
})
|
|
116
|
+
}
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
// Preview container
|
|
120
|
+
const preview = document.createElement('div')
|
|
121
|
+
preview.className = 'oe-raw__preview'
|
|
122
|
+
preview.id = previewId
|
|
123
|
+
preview.style.display = 'none'
|
|
124
|
+
|
|
125
|
+
stateMap.set(wrapper, { textarea, preview, showPreview: context.readOnly })
|
|
126
|
+
|
|
127
|
+
wrapper.append(bar, textarea, preview)
|
|
128
|
+
|
|
129
|
+
requestAnimationFrame(() => this.#autoResize(textarea))
|
|
130
|
+
if (context.readOnly) this.#syncPreview(wrapper)
|
|
131
|
+
|
|
132
|
+
return wrapper
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Serialize the current block DOM into document data.
|
|
137
|
+
* @param {HTMLElement} element
|
|
138
|
+
* @returns {{ html: string }}
|
|
139
|
+
*/
|
|
140
|
+
save(element) {
|
|
141
|
+
const s = stateMap.get(element)
|
|
142
|
+
return { html: s?.textarea?.value || '' }
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Check whether serialized data satisfies this block's schema.
|
|
147
|
+
* @param {{ html?: string }} data
|
|
148
|
+
* @returns {boolean}
|
|
149
|
+
*/
|
|
150
|
+
validate(data) {
|
|
151
|
+
return validateRawData(data)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Check whether the block has no meaningful user content.
|
|
156
|
+
* @param {HTMLElement} element
|
|
157
|
+
* @returns {boolean}
|
|
158
|
+
*/
|
|
159
|
+
isEmpty(element) {
|
|
160
|
+
const s = stateMap.get(element)
|
|
161
|
+
return !s?.textarea?.value?.trim()
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Extract neutral text that can initialize another block type.
|
|
166
|
+
* @param {HTMLElement} element
|
|
167
|
+
* @returns {{ text: string }}
|
|
168
|
+
*/
|
|
169
|
+
exportData(element) {
|
|
170
|
+
const s = stateMap.get(element)
|
|
171
|
+
return { text: s?.textarea?.value || '' }
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Release listeners and resources owned by this block element.
|
|
176
|
+
* @param {HTMLElement} element
|
|
177
|
+
* @returns {void}
|
|
178
|
+
*/
|
|
179
|
+
destroy(element) {
|
|
180
|
+
stateMap.delete(element)
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// ── Private ─────────────────────────────────────────────────────────────────
|
|
184
|
+
|
|
185
|
+
/** @param {HTMLTextAreaElement} textarea @returns {void} */
|
|
186
|
+
#autoResize(textarea) {
|
|
187
|
+
textarea.style.height = 'auto'
|
|
188
|
+
textarea.style.height = textarea.scrollHeight + 'px'
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** @param {HTMLElement} wrapper @returns {void} */
|
|
192
|
+
#syncPreview(wrapper) {
|
|
193
|
+
const s = stateMap.get(wrapper)
|
|
194
|
+
if (!s) return
|
|
195
|
+
const toggle = /** @type {HTMLButtonElement | null} */ (wrapper.querySelector('.oe-raw__toggle'))
|
|
196
|
+
toggle?.setAttribute('aria-pressed', String(s.showPreview))
|
|
197
|
+
|
|
198
|
+
if (s.showPreview) {
|
|
199
|
+
s.textarea.style.display = 'none'
|
|
200
|
+
s.preview.style.display = ''
|
|
201
|
+
s.preview.textContent = ''
|
|
202
|
+
const iframe = document.createElement('iframe')
|
|
203
|
+
iframe.sandbox = ''
|
|
204
|
+
iframe.title = this._t('previewFrame', 'HTML preview')
|
|
205
|
+
iframe.style.cssText = 'width:100%;border:none;min-height:100px'
|
|
206
|
+
iframe.srcdoc = sanitizeRawHtml(s.textarea.value)
|
|
207
|
+
s.preview.appendChild(iframe)
|
|
208
|
+
const resizeIframe = () => {
|
|
209
|
+
try {
|
|
210
|
+
const h = iframe.contentDocument?.documentElement?.scrollHeight
|
|
211
|
+
if (h) iframe.style.height = h + 'px'
|
|
212
|
+
} catch {
|
|
213
|
+
// A sandboxed srcdoc intentionally has an opaque origin in browsers
|
|
214
|
+
// that enforce it here. The minimum height remains the safe fallback.
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
iframe.addEventListener('load', resizeIframe)
|
|
218
|
+
requestAnimationFrame(resizeIframe)
|
|
219
|
+
toggle?.classList.add('oe-raw__toggle--active')
|
|
220
|
+
} else {
|
|
221
|
+
s.textarea.style.display = ''
|
|
222
|
+
s.preview.style.display = 'none'
|
|
223
|
+
toggle?.classList.remove('oe-raw__toggle--active')
|
|
224
|
+
requestAnimationFrame(() => this.#autoResize(s.textarea))
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|