@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,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} EditorFacadeDeps
|
|
3
|
+
* @property {import('./types.js').IBlockManager} blocks Live block collection.
|
|
4
|
+
* @property {import('./types.js').ISelectionManager} selection Selection service.
|
|
5
|
+
* @property {import('./types.js').IEventBus} events Internal event bus.
|
|
6
|
+
* @property {string} defaultBlockType Fallback block type for insertions.
|
|
7
|
+
* @property {import('./CommandDispatcher.js').CommandDispatcher} commands Command boundary.
|
|
8
|
+
* @property {import('./DocumentSchema.js').DocumentSchema} documentSchema Document validator and migrator.
|
|
9
|
+
* @property {import('./Diagnostics.js').Diagnostics} diagnostics Diagnostic reporter.
|
|
10
|
+
* @property {import('./DocumentSnapshotStore.js').DocumentSnapshotStore} snapshots Document snapshot store.
|
|
11
|
+
* @property {import('./PublicEditorApi.js').EditorBlocksApi} publicBlocks Public block API.
|
|
12
|
+
* @property {import('./PublicEditorApi.js').EditorEventSubscriptions} publicEvents Public event subscriptions.
|
|
13
|
+
* @property {boolean} readOnly Initial interaction mode.
|
|
14
|
+
* @property {import('./types.js').IInlinePluginRegistry} [inlinePluginRegistry] Inline plugin registry.
|
|
15
|
+
* @property {import('./types.js').InlinePluginContext} [inlinePluginCtx] Inline plugin runtime context.
|
|
16
|
+
* @property {import('./types.js').ICrossBlockSelection} [crossBlockSelection] Cross-block selection service.
|
|
17
|
+
*/
|
|
18
|
+
export class EditorFacade {
|
|
19
|
+
/**
|
|
20
|
+
* @param {HTMLElement} rootEl
|
|
21
|
+
* @param {EditorFacadeDeps} deps
|
|
22
|
+
*/
|
|
23
|
+
constructor(rootEl: HTMLElement, deps: EditorFacadeDeps);
|
|
24
|
+
/**
|
|
25
|
+
* Register a module for cleanup on destroy.
|
|
26
|
+
* @param {{ destroy(): void }} module
|
|
27
|
+
*/
|
|
28
|
+
registerDestroyable(module: {
|
|
29
|
+
destroy(): void;
|
|
30
|
+
}): void;
|
|
31
|
+
/** @param {import('./UndoManager.js').UndoManager} history */
|
|
32
|
+
configureHistory(history: import("./UndoManager.js").UndoManager): void;
|
|
33
|
+
/** @param {(readOnly: boolean) => void} transition */
|
|
34
|
+
configureReadOnlyTransition(transition: (readOnly: boolean) => void): void;
|
|
35
|
+
/**
|
|
36
|
+
* Mark the editor as ready.
|
|
37
|
+
*/
|
|
38
|
+
markReady(): void;
|
|
39
|
+
get isReady(): boolean;
|
|
40
|
+
get blocks(): import("./PublicEditorApi.js").EditorBlocksApi;
|
|
41
|
+
get events(): import("./PublicEditorApi.js").EditorEventSubscriptions;
|
|
42
|
+
get rootElement(): HTMLElement;
|
|
43
|
+
get readOnly(): boolean;
|
|
44
|
+
get canUndo(): boolean;
|
|
45
|
+
get canRedo(): boolean;
|
|
46
|
+
undo(): boolean;
|
|
47
|
+
redo(): boolean;
|
|
48
|
+
/** @param {boolean} readOnly */
|
|
49
|
+
setReadOnly(readOnly: boolean): void;
|
|
50
|
+
/**
|
|
51
|
+
* Save editor content.
|
|
52
|
+
*
|
|
53
|
+
* Each block's raw `data` is post-processed through the plugin's
|
|
54
|
+
* `mapTextFields` hook to tokenize any committed inline-widget spans
|
|
55
|
+
* (e.g. mentions). Widget data is lifted into the block-level `inline`
|
|
56
|
+
* map keyed by each widget's stable instance id — `data` ends up
|
|
57
|
+
* carrying only `{{<id>}}` text placeholders, polymorphically
|
|
58
|
+
* reconstructible on load.
|
|
59
|
+
*
|
|
60
|
+
* @returns {import('./types.js').EditorDocument}
|
|
61
|
+
*/
|
|
62
|
+
save(): import("./types.js").EditorDocument;
|
|
63
|
+
/**
|
|
64
|
+
* Render data into the editor, replacing existing content.
|
|
65
|
+
* @param {import('./types.js').EditorDocument} data
|
|
66
|
+
* @param {{ blockId: string, offset: number }} [caret] - optional caret position to restore
|
|
67
|
+
* @param {{ focus?: boolean, notifyChange?: boolean }} [options]
|
|
68
|
+
*/
|
|
69
|
+
render(data: import("./types.js").EditorDocument, caret?: {
|
|
70
|
+
blockId: string;
|
|
71
|
+
offset: number;
|
|
72
|
+
}, options?: {
|
|
73
|
+
focus?: boolean;
|
|
74
|
+
notifyChange?: boolean;
|
|
75
|
+
}): void;
|
|
76
|
+
/**
|
|
77
|
+
* Clear all blocks and insert an empty default block.
|
|
78
|
+
*/
|
|
79
|
+
clear(): void;
|
|
80
|
+
/**
|
|
81
|
+
* Focus the editor (first block or current block).
|
|
82
|
+
*/
|
|
83
|
+
focus(): void;
|
|
84
|
+
/**
|
|
85
|
+
* Insert an inline plugin widget at the current caret position.
|
|
86
|
+
* @param {string} type
|
|
87
|
+
* @param {Record<string, string>} [data]
|
|
88
|
+
* @returns {boolean} whether editor DOM was changed
|
|
89
|
+
*/
|
|
90
|
+
insertInlinePlugin(type: string, data?: Record<string, string>): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Destroy the editor and clean up all modules.
|
|
93
|
+
*/
|
|
94
|
+
destroy(): void;
|
|
95
|
+
#private;
|
|
96
|
+
}
|
|
97
|
+
export type EditorFacadeDeps = {
|
|
98
|
+
/**
|
|
99
|
+
* Live block collection.
|
|
100
|
+
*/
|
|
101
|
+
blocks: import("./types.js").IBlockManager;
|
|
102
|
+
/**
|
|
103
|
+
* Selection service.
|
|
104
|
+
*/
|
|
105
|
+
selection: import("./types.js").ISelectionManager;
|
|
106
|
+
/**
|
|
107
|
+
* Internal event bus.
|
|
108
|
+
*/
|
|
109
|
+
events: import("./types.js").IEventBus;
|
|
110
|
+
/**
|
|
111
|
+
* Fallback block type for insertions.
|
|
112
|
+
*/
|
|
113
|
+
defaultBlockType: string;
|
|
114
|
+
/**
|
|
115
|
+
* Command boundary.
|
|
116
|
+
*/
|
|
117
|
+
commands: import("./CommandDispatcher.js").CommandDispatcher;
|
|
118
|
+
/**
|
|
119
|
+
* Document validator and migrator.
|
|
120
|
+
*/
|
|
121
|
+
documentSchema: import("./DocumentSchema.js").DocumentSchema;
|
|
122
|
+
/**
|
|
123
|
+
* Diagnostic reporter.
|
|
124
|
+
*/
|
|
125
|
+
diagnostics: import("./Diagnostics.js").Diagnostics;
|
|
126
|
+
/**
|
|
127
|
+
* Document snapshot store.
|
|
128
|
+
*/
|
|
129
|
+
snapshots: import("./DocumentSnapshotStore.js").DocumentSnapshotStore;
|
|
130
|
+
/**
|
|
131
|
+
* Public block API.
|
|
132
|
+
*/
|
|
133
|
+
publicBlocks: import("./PublicEditorApi.js").EditorBlocksApi;
|
|
134
|
+
/**
|
|
135
|
+
* Public event subscriptions.
|
|
136
|
+
*/
|
|
137
|
+
publicEvents: import("./PublicEditorApi.js").EditorEventSubscriptions;
|
|
138
|
+
/**
|
|
139
|
+
* Initial interaction mode.
|
|
140
|
+
*/
|
|
141
|
+
readOnly: boolean;
|
|
142
|
+
/**
|
|
143
|
+
* Inline plugin registry.
|
|
144
|
+
*/
|
|
145
|
+
inlinePluginRegistry?: import("./types.js").IInlinePluginRegistry;
|
|
146
|
+
/**
|
|
147
|
+
* Inline plugin runtime context.
|
|
148
|
+
*/
|
|
149
|
+
inlinePluginCtx?: import("./types.js").InlinePluginContext;
|
|
150
|
+
/**
|
|
151
|
+
* Cross-block selection service.
|
|
152
|
+
*/
|
|
153
|
+
crossBlockSelection?: import("./types.js").ICrossBlockSelection;
|
|
154
|
+
};
|
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
import { EditorEvent } from './editorEvents.js'
|
|
2
|
+
import { hydrateInlinePlugins } from './hydrateInlinePlugins.js'
|
|
3
|
+
import { insertInlinePluginAtCaret } from './inlinePluginInsert.js'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {Object} EditorFacadeDeps
|
|
7
|
+
* @property {import('./types').IBlockManager} blocks Live block collection.
|
|
8
|
+
* @property {import('./types').ISelectionManager} selection Selection service.
|
|
9
|
+
* @property {import('./types').IEventBus} events Internal event bus.
|
|
10
|
+
* @property {string} defaultBlockType Fallback block type for insertions.
|
|
11
|
+
* @property {import('./CommandDispatcher').CommandDispatcher} commands Command boundary.
|
|
12
|
+
* @property {import('./DocumentSchema').DocumentSchema} documentSchema Document validator and migrator.
|
|
13
|
+
* @property {import('./Diagnostics').Diagnostics} diagnostics Diagnostic reporter.
|
|
14
|
+
* @property {import('./DocumentSnapshotStore').DocumentSnapshotStore} snapshots Document snapshot store.
|
|
15
|
+
* @property {import('./PublicEditorApi').EditorBlocksApi} publicBlocks Public block API.
|
|
16
|
+
* @property {import('./PublicEditorApi').EditorEventSubscriptions} publicEvents Public event subscriptions.
|
|
17
|
+
* @property {boolean} readOnly Initial interaction mode.
|
|
18
|
+
* @property {import('./types').IInlinePluginRegistry} [inlinePluginRegistry] Inline plugin registry.
|
|
19
|
+
* @property {import('./types').InlinePluginContext} [inlinePluginCtx] Inline plugin runtime context.
|
|
20
|
+
* @property {import('./types').ICrossBlockSelection} [crossBlockSelection] Cross-block selection service.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
export class EditorFacade {
|
|
24
|
+
/** @type {HTMLElement} */
|
|
25
|
+
#rootEl
|
|
26
|
+
|
|
27
|
+
/** @type {import('./types').IBlockManager} */
|
|
28
|
+
#blocks
|
|
29
|
+
|
|
30
|
+
/** @type {import('./PublicEditorApi').EditorBlocksApi} */
|
|
31
|
+
#publicBlocks
|
|
32
|
+
|
|
33
|
+
/** @type {import('./types').ISelectionManager} */
|
|
34
|
+
#selection
|
|
35
|
+
|
|
36
|
+
/** @type {import('./types').IEventBus} */
|
|
37
|
+
#events
|
|
38
|
+
|
|
39
|
+
/** @type {import('./PublicEditorApi').EditorEventSubscriptions} */
|
|
40
|
+
#publicEvents
|
|
41
|
+
|
|
42
|
+
/** @type {import('./DocumentSnapshotStore').DocumentSnapshotStore} */
|
|
43
|
+
#snapshots
|
|
44
|
+
|
|
45
|
+
/** @type {import('./DocumentSchema').DocumentSchema} */
|
|
46
|
+
#documentSchema
|
|
47
|
+
|
|
48
|
+
/** @type {import('./CommandDispatcher').CommandDispatcher} */
|
|
49
|
+
#commands
|
|
50
|
+
|
|
51
|
+
/** @type {import('./Diagnostics').Diagnostics} */
|
|
52
|
+
#diagnostics
|
|
53
|
+
|
|
54
|
+
/** @type {boolean} */
|
|
55
|
+
#ready = false
|
|
56
|
+
|
|
57
|
+
/** @type {string} */
|
|
58
|
+
#defaultBlockType
|
|
59
|
+
|
|
60
|
+
/** @type {Array<{ destroy(): void }>} */
|
|
61
|
+
#destroyables = []
|
|
62
|
+
|
|
63
|
+
/** @type {import('./types').IInlinePluginRegistry | null} */
|
|
64
|
+
#inlinePluginRegistry
|
|
65
|
+
|
|
66
|
+
/** @type {import('./types').InlinePluginContext | null} */
|
|
67
|
+
#inlinePluginCtx
|
|
68
|
+
|
|
69
|
+
/** @type {import('./types').ICrossBlockSelection | null} */
|
|
70
|
+
#crossBlockSelection
|
|
71
|
+
|
|
72
|
+
/** @type {import('./UndoManager').UndoManager | null} */
|
|
73
|
+
#history = null
|
|
74
|
+
|
|
75
|
+
/** @type {boolean} */
|
|
76
|
+
#readOnly
|
|
77
|
+
|
|
78
|
+
/** @type {((readOnly: boolean) => void) | null} */
|
|
79
|
+
#readOnlyTransition = null
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @param {HTMLElement} rootEl
|
|
83
|
+
* @param {EditorFacadeDeps} deps
|
|
84
|
+
*/
|
|
85
|
+
constructor(rootEl, deps) {
|
|
86
|
+
const {
|
|
87
|
+
blocks,
|
|
88
|
+
selection,
|
|
89
|
+
events,
|
|
90
|
+
defaultBlockType,
|
|
91
|
+
commands,
|
|
92
|
+
documentSchema,
|
|
93
|
+
diagnostics,
|
|
94
|
+
snapshots,
|
|
95
|
+
publicBlocks,
|
|
96
|
+
publicEvents,
|
|
97
|
+
readOnly,
|
|
98
|
+
inlinePluginRegistry,
|
|
99
|
+
inlinePluginCtx,
|
|
100
|
+
crossBlockSelection,
|
|
101
|
+
} = deps
|
|
102
|
+
this.#rootEl = rootEl
|
|
103
|
+
this.#blocks = blocks
|
|
104
|
+
this.#selection = selection
|
|
105
|
+
this.#events = events
|
|
106
|
+
this.#commands = commands
|
|
107
|
+
this.#documentSchema = documentSchema
|
|
108
|
+
this.#diagnostics = diagnostics
|
|
109
|
+
this.#snapshots = snapshots
|
|
110
|
+
this.#publicBlocks = publicBlocks
|
|
111
|
+
this.#publicEvents = publicEvents
|
|
112
|
+
this.#defaultBlockType = defaultBlockType
|
|
113
|
+
this.#inlinePluginRegistry = inlinePluginRegistry ?? null
|
|
114
|
+
this.#inlinePluginCtx = inlinePluginCtx ?? null
|
|
115
|
+
this.#crossBlockSelection = crossBlockSelection ?? null
|
|
116
|
+
this.#readOnly = readOnly
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Register a module for cleanup on destroy.
|
|
121
|
+
* @param {{ destroy(): void }} module
|
|
122
|
+
*/
|
|
123
|
+
registerDestroyable(module) {
|
|
124
|
+
this.#destroyables.push(module)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** @param {import('./UndoManager').UndoManager} history */
|
|
128
|
+
configureHistory(history) {
|
|
129
|
+
this.#history = history
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** @param {(readOnly: boolean) => void} transition */
|
|
133
|
+
configureReadOnlyTransition(transition) {
|
|
134
|
+
this.#readOnlyTransition = transition
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Mark the editor as ready.
|
|
139
|
+
*/
|
|
140
|
+
markReady() {
|
|
141
|
+
this.#ready = true
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
get isReady() {
|
|
145
|
+
return this.#ready
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
get blocks() {
|
|
149
|
+
return this.#publicBlocks
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
get events() {
|
|
153
|
+
return this.#publicEvents
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
get rootElement() {
|
|
157
|
+
return this.#rootEl
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
get readOnly() {
|
|
161
|
+
return this.#readOnly
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
get canUndo() {
|
|
165
|
+
return !this.#readOnly && Boolean(this.#history?.canUndo)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
get canRedo() {
|
|
169
|
+
return !this.#readOnly && Boolean(this.#history?.canRedo)
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
undo() {
|
|
173
|
+
if (this.#readOnly) return false
|
|
174
|
+
return this.#history?.undo() ?? false
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
redo() {
|
|
178
|
+
if (this.#readOnly) return false
|
|
179
|
+
return this.#history?.redo() ?? false
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** @param {boolean} readOnly */
|
|
183
|
+
setReadOnly(readOnly) {
|
|
184
|
+
if (typeof readOnly !== 'boolean') throw new TypeError('setReadOnly() requires a boolean')
|
|
185
|
+
if (readOnly === this.#readOnly) return
|
|
186
|
+
if (!this.#readOnlyTransition) throw new Error('Editor read-only transition is not configured')
|
|
187
|
+
this.#readOnlyTransition(readOnly)
|
|
188
|
+
this.#readOnly = readOnly
|
|
189
|
+
this.#events.emit(EditorEvent.READ_ONLY_CHANGED, { readOnly })
|
|
190
|
+
this.#events.emit(EditorEvent.HISTORY_CHANGED, {
|
|
191
|
+
canUndo: this.canUndo,
|
|
192
|
+
canRedo: this.canRedo,
|
|
193
|
+
})
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Save editor content.
|
|
198
|
+
*
|
|
199
|
+
* Each block's raw `data` is post-processed through the plugin's
|
|
200
|
+
* `mapTextFields` hook to tokenize any committed inline-widget spans
|
|
201
|
+
* (e.g. mentions). Widget data is lifted into the block-level `inline`
|
|
202
|
+
* map keyed by each widget's stable instance id — `data` ends up
|
|
203
|
+
* carrying only `{{<id>}}` text placeholders, polymorphically
|
|
204
|
+
* reconstructible on load.
|
|
205
|
+
*
|
|
206
|
+
* @returns {import('./types').EditorDocument}
|
|
207
|
+
*/
|
|
208
|
+
save() {
|
|
209
|
+
return this.#snapshots.save()
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Render data into the editor, replacing existing content.
|
|
214
|
+
* @param {import('./types').EditorDocument} data
|
|
215
|
+
* @param {{ blockId: string, offset: number }} [caret] - optional caret position to restore
|
|
216
|
+
* @param {{ focus?: boolean, notifyChange?: boolean }} [options]
|
|
217
|
+
*/
|
|
218
|
+
render(data, caret, options = {}) {
|
|
219
|
+
const startedAt = this.#diagnostics.enabled ? this.#diagnostics.now() : 0
|
|
220
|
+
const normalized = this.#documentSchema.normalize(data)
|
|
221
|
+
const replacement = this.#blocks.prepareReplacement(
|
|
222
|
+
normalized.blocks,
|
|
223
|
+
this.#defaultBlockType,
|
|
224
|
+
'EditorFacade',
|
|
225
|
+
)
|
|
226
|
+
|
|
227
|
+
try {
|
|
228
|
+
if (this.#inlinePluginRegistry && this.#inlinePluginCtx && this.#inlinePluginRegistry.size > 0) {
|
|
229
|
+
for (const block of replacement.blocks) {
|
|
230
|
+
hydrateInlinePlugins(block.contentElement, this.#inlinePluginRegistry, this.#inlinePluginCtx)
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
} catch (error) {
|
|
234
|
+
replacement.dispose()
|
|
235
|
+
throw error
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
this.#events.emit(EditorEvent.UNDO_BATCH_START)
|
|
239
|
+
try {
|
|
240
|
+
// Clear transient selection state before replacing content.
|
|
241
|
+
// Without this, InlineToolbar refuses to hide (checks crossBlockSelection.range)
|
|
242
|
+
// and CSS highlights remain painted on detached DOM nodes.
|
|
243
|
+
if (this.#crossBlockSelection) this.#crossBlockSelection.deactivate(this.#rootEl)
|
|
244
|
+
this.#blocks.clearSelection()
|
|
245
|
+
|
|
246
|
+
replacement.commit({ notifyChange: options.notifyChange })
|
|
247
|
+
this.#snapshots.setDocumentVersion(normalized.version)
|
|
248
|
+
|
|
249
|
+
// Restore caret position
|
|
250
|
+
if (caret) {
|
|
251
|
+
const targetBlock = this.#blocks.getBlockById(caret.blockId)
|
|
252
|
+
if (targetBlock) {
|
|
253
|
+
const idx = this.#blocks.getBlockIndex(caret.blockId)
|
|
254
|
+
if (idx >= 0) this.#blocks.setCurrentIndex(idx)
|
|
255
|
+
targetBlock.focus()
|
|
256
|
+
this.#selection.setCaretToOffset(caret.blockId, caret.offset)
|
|
257
|
+
return
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// Mode transitions rebuild plugin DOM without stealing browser focus.
|
|
262
|
+
this.#blocks.setCurrentIndex(0)
|
|
263
|
+
if (options.focus === false) return
|
|
264
|
+
|
|
265
|
+
// Fallback: focus first block
|
|
266
|
+
const first = this.#blocks.getBlockByIndex(0)
|
|
267
|
+
if (first) {
|
|
268
|
+
first.focus()
|
|
269
|
+
this.#selection.setCaretToBlock(first.id, 'end')
|
|
270
|
+
}
|
|
271
|
+
} finally {
|
|
272
|
+
this.#events.emit(EditorEvent.UNDO_BATCH_END)
|
|
273
|
+
if (startedAt) {
|
|
274
|
+
const durationMs = this.#diagnostics.now() - startedAt
|
|
275
|
+
if (durationMs >= this.#diagnostics.threshold('renderMs')) {
|
|
276
|
+
this.#diagnostics.emit('render.slow', { durationMs })
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Clear all blocks and insert an empty default block.
|
|
284
|
+
*/
|
|
285
|
+
clear() {
|
|
286
|
+
const replacement = this.#blocks.prepareReplacement(undefined, this.#defaultBlockType, 'EditorFacade.clear')
|
|
287
|
+
this.#events.emit(EditorEvent.UNDO_BATCH_START)
|
|
288
|
+
try {
|
|
289
|
+
replacement.commit()
|
|
290
|
+
this.#blocks.setCurrentIndex(0)
|
|
291
|
+
} finally {
|
|
292
|
+
this.#events.emit(EditorEvent.UNDO_BATCH_END)
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Focus the editor (first block or current block).
|
|
298
|
+
*/
|
|
299
|
+
focus() {
|
|
300
|
+
const block = this.#blocks.getCurrentBlock() || this.#blocks.getBlockByIndex(0)
|
|
301
|
+
if (block) {
|
|
302
|
+
block.focus()
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Insert an inline plugin widget at the current caret position.
|
|
308
|
+
* @param {string} type
|
|
309
|
+
* @param {Record<string, string>} [data]
|
|
310
|
+
* @returns {boolean} whether editor DOM was changed
|
|
311
|
+
*/
|
|
312
|
+
insertInlinePlugin(type, data = {}) {
|
|
313
|
+
if (this.#readOnly || !this.#inlinePluginRegistry || !this.#inlinePluginCtx) return false
|
|
314
|
+
|
|
315
|
+
const selection = window.getSelection()
|
|
316
|
+
const range = selection?.rangeCount ? selection.getRangeAt(0) : null
|
|
317
|
+
if (!range || !this.#rootEl.contains(range.commonAncestorContainer)) return false
|
|
318
|
+
const block = this.#blocks.getBlockByChildNode(range.commonAncestorContainer)
|
|
319
|
+
if (
|
|
320
|
+
!block
|
|
321
|
+
|| typeof block.plugin.mapTextFields !== 'function'
|
|
322
|
+
|| !this.#inlinePluginRegistry.get(type)
|
|
323
|
+
) return false
|
|
324
|
+
|
|
325
|
+
return this.#commands.runForBlock(block, () => insertInlinePluginAtCaret(
|
|
326
|
+
this.#inlinePluginRegistry,
|
|
327
|
+
this.#inlinePluginCtx,
|
|
328
|
+
type,
|
|
329
|
+
data,
|
|
330
|
+
this.#rootEl,
|
|
331
|
+
))
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Destroy the editor and clean up all modules.
|
|
336
|
+
*/
|
|
337
|
+
destroy() {
|
|
338
|
+
// Blocks own plugin-created DOM, listeners and external instances. Release
|
|
339
|
+
// them while plugin registries, shared styles and editor services are still
|
|
340
|
+
// alive; shared ownership is released by the destroyables below.
|
|
341
|
+
this.#blocks.clear()
|
|
342
|
+
|
|
343
|
+
for (let i = this.#destroyables.length - 1; i >= 0; i--) {
|
|
344
|
+
try {
|
|
345
|
+
this.#destroyables[i]?.destroy()
|
|
346
|
+
} catch (err) {
|
|
347
|
+
this.#diagnostics.emit('cleanup.failed', {
|
|
348
|
+
operation: this.#destroyables[i]?.constructor?.name || 'destroyable',
|
|
349
|
+
errorName: this.#diagnostics.errorName(err),
|
|
350
|
+
})
|
|
351
|
+
console.warn('[EditorFacade] Error destroying module:', err)
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
this.#destroyables = []
|
|
355
|
+
this.#events.emit(EditorEvent.DESTROYED)
|
|
356
|
+
this.#events.clear()
|
|
357
|
+
|
|
358
|
+
this.#rootEl.remove()
|
|
359
|
+
this.#ready = false
|
|
360
|
+
}
|
|
361
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claim an editor holder until the returned lease is destroyed.
|
|
3
|
+
*
|
|
4
|
+
* The WeakMap does not keep detached holders alive, while the private token
|
|
5
|
+
* prevents an old lease from releasing a newer editor accidentally.
|
|
6
|
+
*
|
|
7
|
+
* @param {HTMLElement} holder
|
|
8
|
+
* @returns {{ destroy(): void }}
|
|
9
|
+
*/
|
|
10
|
+
export function claimEditorHolder(holder: HTMLElement): {
|
|
11
|
+
destroy(): void;
|
|
12
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const activeHolders = new WeakMap()
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Claim an editor holder until the returned lease is destroyed.
|
|
5
|
+
*
|
|
6
|
+
* The WeakMap does not keep detached holders alive, while the private token
|
|
7
|
+
* prevents an old lease from releasing a newer editor accidentally.
|
|
8
|
+
*
|
|
9
|
+
* @param {HTMLElement} holder
|
|
10
|
+
* @returns {{ destroy(): void }}
|
|
11
|
+
*/
|
|
12
|
+
export function claimEditorHolder(holder) {
|
|
13
|
+
if (activeHolders.has(holder)) {
|
|
14
|
+
throw new Error('The editor holder already owns a live editor instance')
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const token = Object.freeze({})
|
|
18
|
+
activeHolders.set(holder, token)
|
|
19
|
+
let released = false
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
destroy() {
|
|
23
|
+
if (released) return
|
|
24
|
+
released = true
|
|
25
|
+
if (activeHolders.get(holder) === token) activeHolders.delete(holder)
|
|
26
|
+
},
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Translation dictionary with:
|
|
3
|
+
* - fallback chain (primary → fallback language → key)
|
|
4
|
+
* - explicit `has()` for missing-key detection
|
|
5
|
+
* - plural rules per language (CLDR categories)
|
|
6
|
+
* - scoped sub-instances for plugin namespacing
|
|
7
|
+
* - immutable freeze after init
|
|
8
|
+
* - dev-mode warnings on missing keys
|
|
9
|
+
*
|
|
10
|
+
* Architecturally: ONE instance per editor, shared by core and all plugins.
|
|
11
|
+
* Plugins receive a `ScopedI18n` wrapper that auto-prefixes keys with their
|
|
12
|
+
* type (e.g. `plugin.heading.*`), so plugin code uses short local keys
|
|
13
|
+
* without worrying about cross-plugin collisions.
|
|
14
|
+
*/
|
|
15
|
+
export class I18n {
|
|
16
|
+
/**
|
|
17
|
+
* @param {Partial<I18nMessages>} [messages] primary locale (e.g. ru)
|
|
18
|
+
* @param {Partial<I18nMessages>} [fallback] fallback locale (e.g. en) used when a key is missing in primary
|
|
19
|
+
* @param {string} [lang] language code for plural rules ('en', 'ru', ...)
|
|
20
|
+
*/
|
|
21
|
+
constructor(messages?: Partial<I18nMessages>, fallback?: Partial<I18nMessages>, lang?: string);
|
|
22
|
+
/**
|
|
23
|
+
* Merge additional messages into the primary dictionary.
|
|
24
|
+
* Plugins call this to register their own keys at runtime.
|
|
25
|
+
* Throws after `freeze()`.
|
|
26
|
+
*
|
|
27
|
+
* @param {Partial<I18nMessages>} messages
|
|
28
|
+
*/
|
|
29
|
+
merge(messages: Partial<I18nMessages>): void;
|
|
30
|
+
/**
|
|
31
|
+
* Merge additional messages into the fallback dictionary.
|
|
32
|
+
* Used so plugin English locales become the fallback for other languages.
|
|
33
|
+
* Throws after `freeze()`.
|
|
34
|
+
*
|
|
35
|
+
* @param {Partial<I18nMessages>} messages
|
|
36
|
+
*/
|
|
37
|
+
mergeFallback(messages: Partial<I18nMessages>): void;
|
|
38
|
+
/**
|
|
39
|
+
* Lock the dictionary against further mutation. Called by `createEditor`
|
|
40
|
+
* after all plugins have registered. Subsequent `merge()` calls throw,
|
|
41
|
+
* and the underlying objects are deep-frozen.
|
|
42
|
+
*/
|
|
43
|
+
freeze(): void;
|
|
44
|
+
/**
|
|
45
|
+
* @returns {boolean} true if the i18n dictionary has been frozen
|
|
46
|
+
*/
|
|
47
|
+
get isFrozen(): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Check whether a key resolves to anything (primary or fallback).
|
|
50
|
+
* Use this to distinguish "missing" from "intentionally returns the key".
|
|
51
|
+
*
|
|
52
|
+
* @param {MessageKey | (string & {})} key
|
|
53
|
+
* @returns {boolean}
|
|
54
|
+
*/
|
|
55
|
+
has(key: MessageKey | (string & {})): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Resolve a translation key with optional `{name}` interpolation.
|
|
58
|
+
*
|
|
59
|
+
* Resolution order:
|
|
60
|
+
* 1. primary dictionary
|
|
61
|
+
* 2. fallback dictionary (if set)
|
|
62
|
+
* 3. `defaultValue` from options (if provided)
|
|
63
|
+
* 4. the key itself, verbatim
|
|
64
|
+
*
|
|
65
|
+
* For string values, returns the interpolated message.
|
|
66
|
+
* For plural-form values (object with `one`/`few`/`many`/`other`), returns the
|
|
67
|
+
* `other` form interpolated — callers wanting count-aware selection should use `plural()`.
|
|
68
|
+
*
|
|
69
|
+
* @param {MessageKey | (string & {})} key
|
|
70
|
+
* @param {Record<string, string | number>} [params] interpolation params
|
|
71
|
+
* @returns {string}
|
|
72
|
+
*/
|
|
73
|
+
t(key: MessageKey | (string & {}), params?: Record<string, string | number>): string;
|
|
74
|
+
/**
|
|
75
|
+
* Resolve a key as a pluralized message.
|
|
76
|
+
*
|
|
77
|
+
* The locale value should be a `PluralForms` object (`{ one, few, many, other }`).
|
|
78
|
+
* If it's a plain string, it's interpolated with `{count}` like a regular message.
|
|
79
|
+
*
|
|
80
|
+
* The plural form is chosen by CLDR rules for the current language. `count` is
|
|
81
|
+
* automatically merged into `params` so messages can use `{count}`.
|
|
82
|
+
*
|
|
83
|
+
* @param {MessageKey | (string & {})} key
|
|
84
|
+
* @param {number} count
|
|
85
|
+
* @param {Record<string, string | number>} [params]
|
|
86
|
+
* @returns {string}
|
|
87
|
+
*/
|
|
88
|
+
plural(key: MessageKey | (string & {}), count: number, params?: Record<string, string | number>): string;
|
|
89
|
+
/**
|
|
90
|
+
* Create a scoped wrapper that auto-prefixes every key with `prefix.`
|
|
91
|
+
* (e.g. `i18n.scope('plugin.heading')` makes `t('title')` resolve `plugin.heading.title`).
|
|
92
|
+
*
|
|
93
|
+
* Backward-compat: keys that already start with `prefix.` are passed through
|
|
94
|
+
* untouched, so legacy plugin code using full keys keeps working alongside
|
|
95
|
+
* new code using short keys.
|
|
96
|
+
*
|
|
97
|
+
* @param {string} prefix
|
|
98
|
+
* @returns {ScopedI18n}
|
|
99
|
+
*/
|
|
100
|
+
scope(prefix: string): ScopedI18n;
|
|
101
|
+
#private;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Plugin-facing i18n wrapper. Auto-prefixes every key with the plugin's
|
|
105
|
+
* namespace, so plugin code can write `_t('title')` instead of
|
|
106
|
+
* `_t('plugin.heading.title')`.
|
|
107
|
+
*
|
|
108
|
+
* Backward-compat: if a caller passes a key that already starts with the
|
|
109
|
+
* prefix, it's left untouched. This lets old code coexist with new code
|
|
110
|
+
* during incremental migration.
|
|
111
|
+
*/
|
|
112
|
+
export class ScopedI18n {
|
|
113
|
+
/**
|
|
114
|
+
* @param {I18n} parent
|
|
115
|
+
* @param {string} prefix
|
|
116
|
+
*/
|
|
117
|
+
constructor(parent: I18n, prefix: string);
|
|
118
|
+
/**
|
|
119
|
+
* @param {string} key
|
|
120
|
+
* @param {Record<string, string | number>} [params]
|
|
121
|
+
* @returns {string}
|
|
122
|
+
*/
|
|
123
|
+
t(key: string, params?: Record<string, string | number>): string;
|
|
124
|
+
/**
|
|
125
|
+
* @param {string} key
|
|
126
|
+
* @returns {boolean}
|
|
127
|
+
*/
|
|
128
|
+
has(key: string): boolean;
|
|
129
|
+
/**
|
|
130
|
+
* @param {string} key
|
|
131
|
+
* @param {number} count
|
|
132
|
+
* @param {Record<string, string | number>} [params]
|
|
133
|
+
* @returns {string}
|
|
134
|
+
*/
|
|
135
|
+
plural(key: string, count: number, params?: Record<string, string | number>): string;
|
|
136
|
+
/**
|
|
137
|
+
* Create a sub-scope under the current prefix.
|
|
138
|
+
* @param {string} sub
|
|
139
|
+
* @returns {ScopedI18n}
|
|
140
|
+
*/
|
|
141
|
+
scope(sub: string): ScopedI18n;
|
|
142
|
+
#private;
|
|
143
|
+
}
|
|
144
|
+
export type I18nMessages = import("./types.js").I18nMessages;
|
|
145
|
+
export type MessageKey = import("./types.js").MessageKey;
|
|
146
|
+
export type PluralForms = import("./types.js").PluralForms;
|
|
147
|
+
export type LocaleValue = import("./types.js").LocaleValue;
|