@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,346 @@
|
|
|
1
|
+
import { resolvePath } from '../../shared/resolvePath.js'
|
|
2
|
+
import { isSupportedImageFile, triggerFileInput } from '../shared/fileInput.js'
|
|
3
|
+
import { BlockPluginAbstract } from '../BlockPluginAbstract.js'
|
|
4
|
+
import { validateImageData } from '../../shared/blockDataValidators.js'
|
|
5
|
+
import { CSS } from './css.js'
|
|
6
|
+
import { ICON } from './icons.js'
|
|
7
|
+
import { ImageState, normalizeImageData, emptyImageData } from './state.js'
|
|
8
|
+
import { ImageUploader } from './uploader.js'
|
|
9
|
+
import { renderEmptyView } from './view-empty.js'
|
|
10
|
+
import { renderFilledView } from './view-filled.js'
|
|
11
|
+
import { sanitizeMediaUrl } from '../../shared/sanitize/index.js'
|
|
12
|
+
|
|
13
|
+
const editorStyles = resolvePath('./image.css', import.meta.url)
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @typedef {{ url: string, alt?: string }} ImageSourceResult
|
|
17
|
+
* @typedef {(file: File, context: { signal: AbortSignal }) => Promise<ImageSourceResult>} ImageUpload
|
|
18
|
+
* @typedef {(context: { signal: AbortSignal }) => Promise<ImageSourceResult | null>} ImageSourceHandler
|
|
19
|
+
* @typedef {{ icon?: string, label: string, handler: ImageSourceHandler }} ImageSourceAction
|
|
20
|
+
*
|
|
21
|
+
* @typedef {Object} ImageConfig
|
|
22
|
+
* @property {ImageUpload} [uploadFile] Uploads a browser file. Without this callback the plugin reads the file into a data URL stored in the document.
|
|
23
|
+
* @property {ImageSourceAction[]} [actions] Additional application-owned image sources. `icon` is trusted application markup; never pass user-authored HTML.
|
|
24
|
+
* @property {boolean} [injectStyles=true] Whether the editor should load the built-in image stylesheet.
|
|
25
|
+
* @property {string} [css] Additional stylesheet URL, or the replacement URL when `injectStyles` is `false`.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Block plugin for images. Public surface implements `BlockPlugin`.
|
|
30
|
+
* Internal logic is split across:
|
|
31
|
+
* - `state.js` — per-block state container (replaces module WeakMap)
|
|
32
|
+
* - `uploader.js` — file upload pipeline (HTTP or data-URL fallback)
|
|
33
|
+
* - `view-empty.js`/`view-filled.js` — DOM rendering for the two states
|
|
34
|
+
* - `settings.js` — settings dropdown form
|
|
35
|
+
* - `styles.js` — inline style application
|
|
36
|
+
*
|
|
37
|
+
* @extends {BlockPluginAbstract<ImageConfig>}
|
|
38
|
+
*/
|
|
39
|
+
export class Image extends BlockPluginAbstract {
|
|
40
|
+
static isTextBlock = false
|
|
41
|
+
static styles = [editorStyles]
|
|
42
|
+
|
|
43
|
+
type = 'image'
|
|
44
|
+
icon = ICON
|
|
45
|
+
inlineTools = false
|
|
46
|
+
|
|
47
|
+
pasteConfig = {
|
|
48
|
+
files: ['image/*'],
|
|
49
|
+
patterns: [/https?:\/\/\S+\.(gif|jpe?g|png|svg|webp)(\?\S*)?$/i],
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
#uploader
|
|
53
|
+
/** @type {ImageConfig} */
|
|
54
|
+
#config
|
|
55
|
+
/** Per-block state, keyed by wrapper element. Encapsulated to this instance. */
|
|
56
|
+
#states = /** @type {WeakMap<HTMLElement, ImageState>} */ (new WeakMap())
|
|
57
|
+
/** @type {WeakMap<HTMLElement, import('../../core/types').BlockMutationContext>} */
|
|
58
|
+
#contexts = new WeakMap()
|
|
59
|
+
/**
|
|
60
|
+
* Create an Image instance with the supplied consumer configuration.
|
|
61
|
+
* @param {ImageConfig} [config]
|
|
62
|
+
*/
|
|
63
|
+
constructor(config) {
|
|
64
|
+
super(config)
|
|
65
|
+
this.#config = /** @type {ImageConfig} */ (this.getPluginConfig())
|
|
66
|
+
this.#uploader = new ImageUploader(this.#config)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Return the localized toolbox label for this block.
|
|
71
|
+
* @returns {string}
|
|
72
|
+
*/
|
|
73
|
+
get title() {
|
|
74
|
+
return this._t('title', 'Image')
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// ── BlockPlugin contract ───────────────────────────────────────────────────
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Create the editable DOM owned by this block instance.
|
|
81
|
+
* @param {Record<string, unknown>} data
|
|
82
|
+
* @param {import('../../core/types').BlockMutationContext} context
|
|
83
|
+
* @returns {HTMLElement}
|
|
84
|
+
*/
|
|
85
|
+
render(data, context) {
|
|
86
|
+
const blockData = normalizeImageData(data)
|
|
87
|
+
const pendingFile = /** @type {File | null} */ (/** @type {any} */ (data)?._pendingFile || null)
|
|
88
|
+
|
|
89
|
+
const wrapper = document.createElement('div')
|
|
90
|
+
wrapper.classList.add(CSS.wrapper)
|
|
91
|
+
wrapper.contentEditable = 'false'
|
|
92
|
+
wrapper.tabIndex = -1
|
|
93
|
+
|
|
94
|
+
const state = new ImageState(blockData, pendingFile)
|
|
95
|
+
this.#states.set(wrapper, state)
|
|
96
|
+
this.#contexts.set(wrapper, context)
|
|
97
|
+
|
|
98
|
+
if (blockData.withBorder) wrapper.classList.add(CSS.withBorder)
|
|
99
|
+
if (blockData.expanded) wrapper.classList.add(CSS.expanded)
|
|
100
|
+
if (blockData.withBackground) wrapper.classList.add(CSS.withBackground)
|
|
101
|
+
|
|
102
|
+
if (blockData.file.url) {
|
|
103
|
+
this.#renderFilled(wrapper)
|
|
104
|
+
} else {
|
|
105
|
+
this.#renderEmpty(wrapper)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Drain pending file from paste (async; renders after upload completes).
|
|
109
|
+
if (state.pendingFile && !context.readOnly) {
|
|
110
|
+
const file = state.pendingFile
|
|
111
|
+
state.pendingFile = null
|
|
112
|
+
state.pendingUpload = this.#handleFile(wrapper, file).finally(() => {
|
|
113
|
+
if (this.#states.get(wrapper) === state) state.pendingUpload = null
|
|
114
|
+
})
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return wrapper
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Serialize the current block DOM into document data.
|
|
122
|
+
* @param {HTMLElement} element
|
|
123
|
+
* @returns {Record<string, unknown>}
|
|
124
|
+
*/
|
|
125
|
+
save(element) {
|
|
126
|
+
const state = this.#states.get(element)
|
|
127
|
+
if (!state) return emptyImageData()
|
|
128
|
+
return { ...state.data, styles: { ...state.data.styles } }
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Check whether serialized data satisfies this block's schema.
|
|
133
|
+
* @param {Record<string, unknown>} data
|
|
134
|
+
* @returns {boolean}
|
|
135
|
+
*/
|
|
136
|
+
validate(data) {
|
|
137
|
+
return validateImageData(data)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Check whether the block has no meaningful user content.
|
|
142
|
+
* @param {HTMLElement} element
|
|
143
|
+
* @returns {boolean}
|
|
144
|
+
*/
|
|
145
|
+
isEmpty(element) {
|
|
146
|
+
const state = this.#states.get(element)
|
|
147
|
+
return !state?.data.file.url
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Extract neutral text that can initialize another block type.
|
|
152
|
+
* @param {HTMLElement} element
|
|
153
|
+
* @returns {Record<string, unknown>}
|
|
154
|
+
*/
|
|
155
|
+
exportData(element) {
|
|
156
|
+
const state = this.#states.get(element)
|
|
157
|
+
return { text: state?.data.caption || '' }
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Handle supported pasted content for this block.
|
|
162
|
+
* @param {import('../../types').PasteEvent} event
|
|
163
|
+
* @returns {Record<string, unknown> | null}
|
|
164
|
+
*/
|
|
165
|
+
onPaste(event) {
|
|
166
|
+
if (event.type === 'file') {
|
|
167
|
+
// Pass the file through the _pendingFile marker; render() will pick it up.
|
|
168
|
+
const data = /** @type {any} */ (emptyImageData())
|
|
169
|
+
data._pendingFile = event.file
|
|
170
|
+
return data
|
|
171
|
+
}
|
|
172
|
+
if (event.type === 'pattern') {
|
|
173
|
+
const url = String(event.data)
|
|
174
|
+
if (url && /^https?:\/\/.+/i.test(url)) {
|
|
175
|
+
return { ...emptyImageData(), file: { url } }
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return null
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Keep a file paste inside one undo transaction until its upload finishes.
|
|
183
|
+
* @param {HTMLElement} element
|
|
184
|
+
* @returns {Promise<void>}
|
|
185
|
+
*/
|
|
186
|
+
waitForPaste(element) {
|
|
187
|
+
return this.#states.get(element)?.pendingUpload ?? Promise.resolve()
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Release listeners and resources owned by this block element.
|
|
192
|
+
* @param {HTMLElement} element
|
|
193
|
+
* @returns {void}
|
|
194
|
+
*/
|
|
195
|
+
destroy(element) {
|
|
196
|
+
const state = this.#states.get(element)
|
|
197
|
+
if (!state) return
|
|
198
|
+
state.dispose()
|
|
199
|
+
this.#states.delete(element)
|
|
200
|
+
this.#contexts.delete(element)
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// ── Internal coordination ──────────────────────────────────────────────────
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Resolve a localized image-plugin message.
|
|
207
|
+
* @param {string} key Translation key scoped to the image plugin.
|
|
208
|
+
* @param {string} fallback Message returned when the key is unavailable.
|
|
209
|
+
* @returns {string}
|
|
210
|
+
*/
|
|
211
|
+
#t = (key, fallback) => this._t(key, fallback)
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Execute one completed block mutation through the editor command context.
|
|
215
|
+
* @param {HTMLElement} wrapper Image block wrapper that owns the context.
|
|
216
|
+
* @param {() => void} operation Synchronous DOM and state mutation.
|
|
217
|
+
* @returns {void}
|
|
218
|
+
*/
|
|
219
|
+
#mutate = (wrapper, operation) => {
|
|
220
|
+
this.#contexts.get(wrapper)?.mutate(operation)
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/** @param {HTMLElement} wrapper @returns {void} */
|
|
224
|
+
#renderEmpty(wrapper) {
|
|
225
|
+
const state = this.#states.get(wrapper)
|
|
226
|
+
if (!state) return
|
|
227
|
+
renderEmptyView(wrapper, state, {
|
|
228
|
+
t: this.#t,
|
|
229
|
+
readOnly: Boolean(this.#contexts.get(wrapper)?.readOnly),
|
|
230
|
+
onUploadClick: () => this.#triggerFileInput(wrapper),
|
|
231
|
+
onFileDropped: (file) => { void this.#handleFile(wrapper, file) },
|
|
232
|
+
customActions: this.#config.actions || [],
|
|
233
|
+
runCustomAction: async (handler) => this.#runCustomAction(wrapper, handler),
|
|
234
|
+
})
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/** @param {HTMLElement} wrapper @returns {void} */
|
|
238
|
+
#renderFilled(wrapper) {
|
|
239
|
+
const state = this.#states.get(wrapper)
|
|
240
|
+
if (!state) return
|
|
241
|
+
renderFilledView(wrapper, state, {
|
|
242
|
+
t: this.#t,
|
|
243
|
+
readOnly: Boolean(this.#contexts.get(wrapper)?.readOnly),
|
|
244
|
+
mutate: (operation) => this.#mutate(wrapper, operation),
|
|
245
|
+
customActions: this.#config.actions || [],
|
|
246
|
+
onTriggerFileInput: () => this.#triggerFileInput(wrapper),
|
|
247
|
+
onPromptUrl: () => this.#promptUrl(wrapper),
|
|
248
|
+
onDelete: () => this.#deleteImage(wrapper),
|
|
249
|
+
runCustomAction: async (handler) => this.#runCustomAction(wrapper, handler),
|
|
250
|
+
})
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/** @param {HTMLElement} wrapper @returns {void} */
|
|
254
|
+
#triggerFileInput(wrapper) {
|
|
255
|
+
if (this.#contexts.get(wrapper)?.readOnly) return
|
|
256
|
+
triggerFileInput({
|
|
257
|
+
accept: 'image/*',
|
|
258
|
+
signal: this.#states.get(wrapper)?.abortController?.signal,
|
|
259
|
+
onFiles: (files) => {
|
|
260
|
+
if (files[0]) void this.#handleFile(wrapper, files[0])
|
|
261
|
+
},
|
|
262
|
+
})
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* @param {HTMLElement} wrapper
|
|
267
|
+
* @param {File} file
|
|
268
|
+
* @returns {Promise<void>}
|
|
269
|
+
*/
|
|
270
|
+
async #handleFile(wrapper, file) {
|
|
271
|
+
const state = this.#states.get(wrapper)
|
|
272
|
+
const context = this.#contexts.get(wrapper)
|
|
273
|
+
if (!state || !context || context.readOnly || !isSupportedImageFile(file)) return
|
|
274
|
+
const controller = state.beginTask()
|
|
275
|
+
wrapper.classList.add(CSS.loading)
|
|
276
|
+
try {
|
|
277
|
+
await this.#uploader.handle(file, (result) => {
|
|
278
|
+
if (controller.signal.aborted || this.#states.get(wrapper) !== state) return
|
|
279
|
+
this.#mutate(wrapper, () => {
|
|
280
|
+
state.data.file = { url: result.url }
|
|
281
|
+
if (result.alt && !state.data.caption) state.data.caption = result.alt
|
|
282
|
+
this.#renderFilled(wrapper)
|
|
283
|
+
})
|
|
284
|
+
}, controller.signal)
|
|
285
|
+
} finally {
|
|
286
|
+
if (state.finishTask(controller)) wrapper.classList.remove(CSS.loading)
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* @param {HTMLElement} wrapper
|
|
292
|
+
* @param {(context: { signal: AbortSignal }) => Promise<{url: string, alt?: string} | null>} handler
|
|
293
|
+
* @returns {Promise<void>}
|
|
294
|
+
*/
|
|
295
|
+
async #runCustomAction(wrapper, handler) {
|
|
296
|
+
const state = this.#states.get(wrapper)
|
|
297
|
+
if (!state || this.#contexts.get(wrapper)?.readOnly) return
|
|
298
|
+
const controller = state.beginTask()
|
|
299
|
+
wrapper.classList.add(CSS.loading)
|
|
300
|
+
try {
|
|
301
|
+
const result = await handler({ signal: controller.signal })
|
|
302
|
+
const url = sanitizeMediaUrl(result?.url || '')
|
|
303
|
+
if (!controller.signal.aborted && this.#states.get(wrapper) === state && url) {
|
|
304
|
+
this.#mutate(wrapper, () => {
|
|
305
|
+
state.data.file = { url }
|
|
306
|
+
if (typeof result?.alt === 'string' && result.alt && !state.data.caption) {
|
|
307
|
+
state.data.caption = result.alt
|
|
308
|
+
}
|
|
309
|
+
this.#renderFilled(wrapper)
|
|
310
|
+
})
|
|
311
|
+
}
|
|
312
|
+
} catch {
|
|
313
|
+
// Action was canceled or failed.
|
|
314
|
+
} finally {
|
|
315
|
+
if (state.finishTask(controller)) wrapper.classList.remove(CSS.loading)
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/** @param {HTMLElement} wrapper @returns {void} */
|
|
320
|
+
#promptUrl(wrapper) {
|
|
321
|
+
const state = this.#states.get(wrapper)
|
|
322
|
+
if (!state || this.#contexts.get(wrapper)?.readOnly) return
|
|
323
|
+
const url = sanitizeMediaUrl(prompt(this.#t('urlPrompt', 'Image URL:')) || '')
|
|
324
|
+
if (url) {
|
|
325
|
+
state.cancelTask()
|
|
326
|
+
wrapper.classList.remove(CSS.loading)
|
|
327
|
+
this.#mutate(wrapper, () => {
|
|
328
|
+
state.data.file = { url }
|
|
329
|
+
this.#renderFilled(wrapper)
|
|
330
|
+
})
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/** @param {HTMLElement} wrapper @returns {void} */
|
|
335
|
+
#deleteImage(wrapper) {
|
|
336
|
+
const state = this.#states.get(wrapper)
|
|
337
|
+
if (!state) return
|
|
338
|
+
state.cancelTask()
|
|
339
|
+
wrapper.classList.remove(CSS.loading)
|
|
340
|
+
this.#mutate(wrapper, () => {
|
|
341
|
+
state.data.file = { url: '' }
|
|
342
|
+
state.data.styles = {}
|
|
343
|
+
this.#renderEmpty(wrapper)
|
|
344
|
+
})
|
|
345
|
+
}
|
|
346
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
'plugin.image.title': string;
|
|
3
|
+
'plugin.image.upload': string;
|
|
4
|
+
'plugin.image.url': string;
|
|
5
|
+
'plugin.image.urlPrompt': string;
|
|
6
|
+
'plugin.image.dropzone': string;
|
|
7
|
+
'plugin.image.dropzoneUpload': string;
|
|
8
|
+
'plugin.image.dropzoneText': string;
|
|
9
|
+
'plugin.image.replace': string;
|
|
10
|
+
'plugin.image.delete': string;
|
|
11
|
+
'plugin.image.caption': string;
|
|
12
|
+
'plugin.image.settings': string;
|
|
13
|
+
'plugin.image.expand': string;
|
|
14
|
+
'plugin.image.background': string;
|
|
15
|
+
'plugin.image.back': string;
|
|
16
|
+
'plugin.image.dimensions': string;
|
|
17
|
+
'plugin.image.display': string;
|
|
18
|
+
'plugin.image.widthShort': string;
|
|
19
|
+
'plugin.image.heightShort': string;
|
|
20
|
+
'plugin.image.minWidth': string;
|
|
21
|
+
'plugin.image.minHeight': string;
|
|
22
|
+
'plugin.image.maxWidth': string;
|
|
23
|
+
'plugin.image.maxHeight': string;
|
|
24
|
+
'plugin.image.fit': string;
|
|
25
|
+
'plugin.image.position': string;
|
|
26
|
+
'plugin.image.color': string;
|
|
27
|
+
'plugin.image.border': string;
|
|
28
|
+
'plugin.image.width': string;
|
|
29
|
+
'plugin.image.radius': string;
|
|
30
|
+
'plugin.image.value.none': string;
|
|
31
|
+
'plugin.image.value.cover': string;
|
|
32
|
+
'plugin.image.value.contain': string;
|
|
33
|
+
'plugin.image.value.fill': string;
|
|
34
|
+
'plugin.image.value.scale-down': string;
|
|
35
|
+
'plugin.image.value.solid': string;
|
|
36
|
+
'plugin.image.value.dashed': string;
|
|
37
|
+
'plugin.image.emptyReadonly': string;
|
|
38
|
+
};
|
|
39
|
+
export default _default;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
'plugin.image.title': 'Image',
|
|
3
|
+
'plugin.image.upload': 'Upload',
|
|
4
|
+
'plugin.image.url': 'URL',
|
|
5
|
+
'plugin.image.urlPrompt': 'Image URL:',
|
|
6
|
+
'plugin.image.dropzone': 'or drag and drop a file here',
|
|
7
|
+
'plugin.image.dropzoneUpload': 'Upload',
|
|
8
|
+
'plugin.image.dropzoneText': 'an image from your device or drag and drop it here',
|
|
9
|
+
'plugin.image.replace': 'Replace',
|
|
10
|
+
'plugin.image.delete': 'Delete',
|
|
11
|
+
'plugin.image.caption': 'Caption',
|
|
12
|
+
'plugin.image.settings': 'Settings',
|
|
13
|
+
'plugin.image.expand': 'Expand',
|
|
14
|
+
'plugin.image.background': 'Background',
|
|
15
|
+
'plugin.image.back': 'Back',
|
|
16
|
+
'plugin.image.dimensions': 'Dimensions',
|
|
17
|
+
'plugin.image.display': 'Display',
|
|
18
|
+
'plugin.image.widthShort': 'W',
|
|
19
|
+
'plugin.image.heightShort': 'H',
|
|
20
|
+
'plugin.image.minWidth': 'Min W',
|
|
21
|
+
'plugin.image.minHeight': 'Min H',
|
|
22
|
+
'plugin.image.maxWidth': 'Max W',
|
|
23
|
+
'plugin.image.maxHeight': 'Max H',
|
|
24
|
+
'plugin.image.fit': 'Fit',
|
|
25
|
+
'plugin.image.position': 'Position',
|
|
26
|
+
'plugin.image.color': 'Color',
|
|
27
|
+
'plugin.image.border': 'Border',
|
|
28
|
+
'plugin.image.width': 'Width',
|
|
29
|
+
'plugin.image.radius': 'Radius',
|
|
30
|
+
'plugin.image.value.none': 'None',
|
|
31
|
+
'plugin.image.value.cover': 'Cover',
|
|
32
|
+
'plugin.image.value.contain': 'Contain',
|
|
33
|
+
'plugin.image.value.fill': 'Fill',
|
|
34
|
+
'plugin.image.value.scale-down': 'Scale down',
|
|
35
|
+
'plugin.image.value.solid': 'Solid',
|
|
36
|
+
'plugin.image.value.dashed': 'Dashed',
|
|
37
|
+
'plugin.image.emptyReadonly': 'No image',
|
|
38
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
'plugin.image.title': string;
|
|
3
|
+
'plugin.image.upload': string;
|
|
4
|
+
'plugin.image.url': string;
|
|
5
|
+
'plugin.image.urlPrompt': string;
|
|
6
|
+
'plugin.image.dropzone': string;
|
|
7
|
+
'plugin.image.dropzoneUpload': string;
|
|
8
|
+
'plugin.image.dropzoneText': string;
|
|
9
|
+
'plugin.image.replace': string;
|
|
10
|
+
'plugin.image.delete': string;
|
|
11
|
+
'plugin.image.caption': string;
|
|
12
|
+
'plugin.image.settings': string;
|
|
13
|
+
'plugin.image.expand': string;
|
|
14
|
+
'plugin.image.background': string;
|
|
15
|
+
'plugin.image.back': string;
|
|
16
|
+
'plugin.image.dimensions': string;
|
|
17
|
+
'plugin.image.display': string;
|
|
18
|
+
'plugin.image.widthShort': string;
|
|
19
|
+
'plugin.image.heightShort': string;
|
|
20
|
+
'plugin.image.minWidth': string;
|
|
21
|
+
'plugin.image.minHeight': string;
|
|
22
|
+
'plugin.image.maxWidth': string;
|
|
23
|
+
'plugin.image.maxHeight': string;
|
|
24
|
+
'plugin.image.fit': string;
|
|
25
|
+
'plugin.image.position': string;
|
|
26
|
+
'plugin.image.color': string;
|
|
27
|
+
'plugin.image.border': string;
|
|
28
|
+
'plugin.image.width': string;
|
|
29
|
+
'plugin.image.radius': string;
|
|
30
|
+
'plugin.image.value.none': string;
|
|
31
|
+
'plugin.image.value.cover': string;
|
|
32
|
+
'plugin.image.value.contain': string;
|
|
33
|
+
'plugin.image.value.fill': string;
|
|
34
|
+
'plugin.image.value.scale-down': string;
|
|
35
|
+
'plugin.image.value.solid': string;
|
|
36
|
+
'plugin.image.value.dashed': string;
|
|
37
|
+
'plugin.image.emptyReadonly': string;
|
|
38
|
+
};
|
|
39
|
+
export default _default;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
'plugin.image.title': 'Изображение',
|
|
3
|
+
'plugin.image.upload': 'Загрузить',
|
|
4
|
+
'plugin.image.url': 'URL',
|
|
5
|
+
'plugin.image.urlPrompt': 'URL изображения:',
|
|
6
|
+
'plugin.image.dropzone': 'или перетащите файл сюда',
|
|
7
|
+
'plugin.image.dropzoneUpload': 'Загрузите',
|
|
8
|
+
'plugin.image.dropzoneText': 'изображение с устройства или перетащите его сюда',
|
|
9
|
+
'plugin.image.replace': 'Заменить',
|
|
10
|
+
'plugin.image.delete': 'Удалить',
|
|
11
|
+
'plugin.image.caption': 'Подпись',
|
|
12
|
+
'plugin.image.settings': 'Настройки',
|
|
13
|
+
'plugin.image.expand': 'Расширить',
|
|
14
|
+
'plugin.image.background': 'Фон',
|
|
15
|
+
'plugin.image.back': 'Назад',
|
|
16
|
+
'plugin.image.dimensions': 'Размеры',
|
|
17
|
+
'plugin.image.display': 'Отображение',
|
|
18
|
+
'plugin.image.widthShort': 'Ш',
|
|
19
|
+
'plugin.image.heightShort': 'В',
|
|
20
|
+
'plugin.image.minWidth': 'Мин. ширина',
|
|
21
|
+
'plugin.image.minHeight': 'Мин. высота',
|
|
22
|
+
'plugin.image.maxWidth': 'Макс. ширина',
|
|
23
|
+
'plugin.image.maxHeight': 'Макс. высота',
|
|
24
|
+
'plugin.image.fit': 'Вписывание',
|
|
25
|
+
'plugin.image.position': 'Положение',
|
|
26
|
+
'plugin.image.color': 'Цвет',
|
|
27
|
+
'plugin.image.border': 'Рамка',
|
|
28
|
+
'plugin.image.width': 'Ширина',
|
|
29
|
+
'plugin.image.radius': 'Радиус',
|
|
30
|
+
'plugin.image.value.none': 'Нет',
|
|
31
|
+
'plugin.image.value.cover': 'Заполнить область',
|
|
32
|
+
'plugin.image.value.contain': 'Вписать целиком',
|
|
33
|
+
'plugin.image.value.fill': 'Растянуть',
|
|
34
|
+
'plugin.image.value.scale-down': 'Только уменьшать',
|
|
35
|
+
'plugin.image.value.solid': 'Сплошная',
|
|
36
|
+
'plugin.image.value.dashed': 'Штриховая',
|
|
37
|
+
'plugin.image.emptyReadonly': 'Нет изображения',
|
|
38
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} SettingsDeps
|
|
3
|
+
* @property {(key: string, fallback: string) => string} t
|
|
4
|
+
* @property {(operation: () => void) => void} mutate
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Build the settings dropdown panel: a styled form with width/height,
|
|
8
|
+
* object fit/position, expand toggle, background toggle/color, and border.
|
|
9
|
+
*
|
|
10
|
+
* Mutations write directly into `state.data.styles` (or `state.data.expanded`
|
|
11
|
+
* etc.) inside the core-owned mutation boundary so undo/save see each
|
|
12
|
+
* control action immediately.
|
|
13
|
+
*
|
|
14
|
+
* @param {HTMLElement} wrapper
|
|
15
|
+
* @param {import('./state.js').ImageState} state
|
|
16
|
+
* @param {SettingsDeps} deps
|
|
17
|
+
* @returns {HTMLElement}
|
|
18
|
+
*/
|
|
19
|
+
export function buildSettingsPanel(wrapper: HTMLElement, state: import("./state.js").ImageState, deps: SettingsDeps): HTMLElement;
|
|
20
|
+
export type SettingsDeps = {
|
|
21
|
+
t: (key: string, fallback: string) => string;
|
|
22
|
+
mutate: (operation: () => void) => void;
|
|
23
|
+
};
|