@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,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inline widget marshalling.
|
|
3
|
+
*
|
|
4
|
+
* Model:
|
|
5
|
+
* Every committed inline widget carries a stable instance id on its DOM
|
|
6
|
+
* (`data-id` attribute), generated once at creation time and preserved
|
|
7
|
+
* through save / load round-trips. That id is simultaneously:
|
|
8
|
+
* - the key under which the widget's data is stored in the block-level
|
|
9
|
+
* `inline` map on save;
|
|
10
|
+
* - the placeholder referenced inline in the block's text field, as
|
|
11
|
+
* `{{<id>}}`;
|
|
12
|
+
* - the value written back to `data-id` when the widget is rehydrated
|
|
13
|
+
* on load.
|
|
14
|
+
*
|
|
15
|
+
* Storage on save:
|
|
16
|
+
* Live DOM → `<span data-inline-plugin="mention" data-id="w_3k7a"
|
|
17
|
+
* data-value="1" class="oe-ip oe-ip--mention">@Anna</span>`
|
|
18
|
+
* Serialized → text field becomes `... {{w_3k7a}} ...` plus
|
|
19
|
+
* `inline["w_3k7a"] = { type: "mention", data: { id: "1", name: "Anna" } }`.
|
|
20
|
+
*
|
|
21
|
+
* Both directions dispatch polymorphically through the registered inline
|
|
22
|
+
* plugin's own `getData` (save) / `createWidget(data, id)` (load).
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* @typedef {import('../renderer/types.js').InlineWidget} InlineWidget
|
|
26
|
+
* @typedef {import('../renderer/types.js').InlinePluginLike & { isCommitted?(element: HTMLElement): boolean }} MarshalInlinePlugin
|
|
27
|
+
* @typedef {{ get(type: string): MarshalInlinePlugin | undefined }} PluginLookup
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* Generate a new inline widget instance id. Not cryptographic — just
|
|
31
|
+
* collision-resistant enough within a single document (a few tens of
|
|
32
|
+
* widgets per block at most).
|
|
33
|
+
*
|
|
34
|
+
* Implementation: two independent `Math.random()` samples concatenated
|
|
35
|
+
* and fixed-length padded. The two samples defend against the rare case
|
|
36
|
+
* where a single `Math.random()` yields a value whose base36 text form is
|
|
37
|
+
* unusually short (e.g. `(0.5).toString(36) === "0.i"`) — padding +
|
|
38
|
+
* doubling guarantees ~48 bits of entropy and a stable 10-char body.
|
|
39
|
+
*
|
|
40
|
+
* @returns {string}
|
|
41
|
+
*/
|
|
42
|
+
export function generateInlineId(): string;
|
|
43
|
+
/**
|
|
44
|
+
* Walk `html` for inline-plugin widget spans, replace each with a
|
|
45
|
+
* `{{<widget-id>}}` text placeholder, and collect their data into an
|
|
46
|
+
* `inline` map keyed by widget id. Widgets without `data-id` get one
|
|
47
|
+
* generated on the fly.
|
|
48
|
+
*
|
|
49
|
+
* @param {string} html
|
|
50
|
+
* @param {PluginLookup | null | undefined} registry
|
|
51
|
+
* @param {Set<string>} [usedIds] IDs already allocated in sibling text fields
|
|
52
|
+
* @returns {{ html: string, inline: Record<string, InlineWidget> }}
|
|
53
|
+
*/
|
|
54
|
+
export function serializeInlineHtml(html: string, registry: PluginLookup | null | undefined, usedIds?: Set<string>): {
|
|
55
|
+
html: string;
|
|
56
|
+
inline: Record<string, InlineWidget>;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Expand `{{<id>}}` tokens back into widget DOM.
|
|
60
|
+
*
|
|
61
|
+
* For each token:
|
|
62
|
+
* - look up `inline[id]` — if missing, leave the token text in place
|
|
63
|
+
* (the user may have typed something that happens to look like one);
|
|
64
|
+
* - dispatch to `registry.get(type).createWidget(data, id)` —
|
|
65
|
+
* rebuilding the widget with its STABLE id preserved.
|
|
66
|
+
*
|
|
67
|
+
* Built as a DOM walk (not regex-over-string) so inserted widget
|
|
68
|
+
* elements don't disturb surrounding markup / nested elements.
|
|
69
|
+
*
|
|
70
|
+
* @param {string} html
|
|
71
|
+
* @param {Record<string, InlineWidget> | null | undefined} inline
|
|
72
|
+
* @param {PluginLookup | null | undefined} registry
|
|
73
|
+
* @returns {string}
|
|
74
|
+
*/
|
|
75
|
+
export function deserializeInlineHtml(html: string, inline: Record<string, InlineWidget> | null | undefined, registry: PluginLookup | null | undefined): string;
|
|
76
|
+
export type InlineWidget = import("../renderer/types.js").InlineWidget;
|
|
77
|
+
export type MarshalInlinePlugin = import("../renderer/types.js").InlinePluginLike & {
|
|
78
|
+
isCommitted?(element: HTMLElement): boolean;
|
|
79
|
+
};
|
|
80
|
+
export type PluginLookup = {
|
|
81
|
+
get(type: string): MarshalInlinePlugin | undefined;
|
|
82
|
+
};
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
/**
|
|
3
|
+
* Inline widget marshalling.
|
|
4
|
+
*
|
|
5
|
+
* Model:
|
|
6
|
+
* Every committed inline widget carries a stable instance id on its DOM
|
|
7
|
+
* (`data-id` attribute), generated once at creation time and preserved
|
|
8
|
+
* through save / load round-trips. That id is simultaneously:
|
|
9
|
+
* - the key under which the widget's data is stored in the block-level
|
|
10
|
+
* `inline` map on save;
|
|
11
|
+
* - the placeholder referenced inline in the block's text field, as
|
|
12
|
+
* `{{<id>}}`;
|
|
13
|
+
* - the value written back to `data-id` when the widget is rehydrated
|
|
14
|
+
* on load.
|
|
15
|
+
*
|
|
16
|
+
* Storage on save:
|
|
17
|
+
* Live DOM → `<span data-inline-plugin="mention" data-id="w_3k7a"
|
|
18
|
+
* data-value="1" class="oe-ip oe-ip--mention">@Anna</span>`
|
|
19
|
+
* Serialized → text field becomes `... {{w_3k7a}} ...` plus
|
|
20
|
+
* `inline["w_3k7a"] = { type: "mention", data: { id: "1", name: "Anna" } }`.
|
|
21
|
+
*
|
|
22
|
+
* Both directions dispatch polymorphically through the registered inline
|
|
23
|
+
* plugin's own `getData` (save) / `createWidget(data, id)` (load).
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @typedef {import('../renderer/types').InlineWidget} InlineWidget
|
|
28
|
+
* @typedef {import('../renderer/types').InlinePluginLike & { isCommitted?(element: HTMLElement): boolean }} MarshalInlinePlugin
|
|
29
|
+
* @typedef {{ get(type: string): MarshalInlinePlugin | undefined }} PluginLookup
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Generate a new inline widget instance id. Not cryptographic — just
|
|
34
|
+
* collision-resistant enough within a single document (a few tens of
|
|
35
|
+
* widgets per block at most).
|
|
36
|
+
*
|
|
37
|
+
* Implementation: two independent `Math.random()` samples concatenated
|
|
38
|
+
* and fixed-length padded. The two samples defend against the rare case
|
|
39
|
+
* where a single `Math.random()` yields a value whose base36 text form is
|
|
40
|
+
* unusually short (e.g. `(0.5).toString(36) === "0.i"`) — padding +
|
|
41
|
+
* doubling guarantees ~48 bits of entropy and a stable 10-char body.
|
|
42
|
+
*
|
|
43
|
+
* @returns {string}
|
|
44
|
+
*/
|
|
45
|
+
export function generateInlineId() {
|
|
46
|
+
const a = Math.random().toString(36).slice(2).padEnd(6, '0').slice(0, 6)
|
|
47
|
+
const b = Math.random().toString(36).slice(2).padEnd(4, '0').slice(0, 4)
|
|
48
|
+
return 'w_' + a + b
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Matches `{{<id>}}` tokens. Ids are alphanumeric + `_` + `-` (matches
|
|
53
|
+
* our own `generateInlineId` output plus any reasonable external id).
|
|
54
|
+
*/
|
|
55
|
+
const PLACEHOLDER_RE = /\{\{([A-Za-z0-9_-]+)\}\}/g
|
|
56
|
+
const INLINE_ID_RE = /^[A-Za-z0-9_-]+$/
|
|
57
|
+
const RESERVED_INLINE_IDS = new Set(['__proto__', 'constructor', 'prototype'])
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @param {string | null} preferred
|
|
61
|
+
* @param {Set<string>} usedIds
|
|
62
|
+
*/
|
|
63
|
+
function allocateInlineId(preferred, usedIds) {
|
|
64
|
+
let id = preferred
|
|
65
|
+
if (!id || !INLINE_ID_RE.test(id) || RESERVED_INLINE_IDS.has(id) || usedIds.has(id)) {
|
|
66
|
+
do {
|
|
67
|
+
id = generateInlineId()
|
|
68
|
+
} while (usedIds.has(id) || RESERVED_INLINE_IDS.has(id))
|
|
69
|
+
}
|
|
70
|
+
usedIds.add(id)
|
|
71
|
+
return id
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Walk `html` for inline-plugin widget spans, replace each with a
|
|
76
|
+
* `{{<widget-id>}}` text placeholder, and collect their data into an
|
|
77
|
+
* `inline` map keyed by widget id. Widgets without `data-id` get one
|
|
78
|
+
* generated on the fly.
|
|
79
|
+
*
|
|
80
|
+
* @param {string} html
|
|
81
|
+
* @param {PluginLookup | null | undefined} registry
|
|
82
|
+
* @param {Set<string>} [usedIds] IDs already allocated in sibling text fields
|
|
83
|
+
* @returns {{ html: string, inline: Record<string, InlineWidget> }}
|
|
84
|
+
*/
|
|
85
|
+
export function serializeInlineHtml(html, registry, usedIds = new Set()) {
|
|
86
|
+
/** @type {Array<[string, InlineWidget]>} */
|
|
87
|
+
const entries = []
|
|
88
|
+
const source = String(html || '')
|
|
89
|
+
if (!source || !registry) return { html: source, inline: {} }
|
|
90
|
+
|
|
91
|
+
const tpl = document.createElement('template')
|
|
92
|
+
tpl.innerHTML = source
|
|
93
|
+
|
|
94
|
+
const widgets = tpl.content.querySelectorAll('[data-inline-plugin]')
|
|
95
|
+
for (const widget of widgets) {
|
|
96
|
+
const el = /** @type {HTMLElement} */ (widget)
|
|
97
|
+
const type = el.getAttribute('data-inline-plugin')
|
|
98
|
+
if (!type) continue
|
|
99
|
+
const plugin = registry.get(type)
|
|
100
|
+
if (!plugin) continue
|
|
101
|
+
|
|
102
|
+
// Trigger-driven widgets can temporarily look like a widget while the
|
|
103
|
+
// user is editing a query, but they do not yet have valid persistent
|
|
104
|
+
// identity. Save their visible text instead of manufacturing an invalid
|
|
105
|
+
// inline-map entry. The plugin owns this decision because only it knows
|
|
106
|
+
// when its transient state becomes committed.
|
|
107
|
+
if (plugin.isCommitted?.(el) === false) {
|
|
108
|
+
el.replaceWith(document.createTextNode(el.textContent || ''))
|
|
109
|
+
continue
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const id = allocateInlineId(el.getAttribute('data-id'), usedIds)
|
|
113
|
+
const data = plugin.getData(el)
|
|
114
|
+
if (!data || typeof data !== 'object' || Array.isArray(data)) {
|
|
115
|
+
throw new TypeError(`Inline plugin "${type}" getData() must return a data object`)
|
|
116
|
+
}
|
|
117
|
+
entries.push([id, {
|
|
118
|
+
type,
|
|
119
|
+
data,
|
|
120
|
+
}])
|
|
121
|
+
|
|
122
|
+
// Placeholder is a plain text token. It survives sanitization as-is
|
|
123
|
+
// (text content is untouched by the tag/attribute allowlist) and
|
|
124
|
+
// round-trips cleanly through innerHTML serialization.
|
|
125
|
+
el.replaceWith(document.createTextNode(`{{${id}}}`))
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return { html: tpl.innerHTML, inline: Object.fromEntries(entries) }
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Expand `{{<id>}}` tokens back into widget DOM.
|
|
133
|
+
*
|
|
134
|
+
* For each token:
|
|
135
|
+
* - look up `inline[id]` — if missing, leave the token text in place
|
|
136
|
+
* (the user may have typed something that happens to look like one);
|
|
137
|
+
* - dispatch to `registry.get(type).createWidget(data, id)` —
|
|
138
|
+
* rebuilding the widget with its STABLE id preserved.
|
|
139
|
+
*
|
|
140
|
+
* Built as a DOM walk (not regex-over-string) so inserted widget
|
|
141
|
+
* elements don't disturb surrounding markup / nested elements.
|
|
142
|
+
*
|
|
143
|
+
* @param {string} html
|
|
144
|
+
* @param {Record<string, InlineWidget> | null | undefined} inline
|
|
145
|
+
* @param {PluginLookup | null | undefined} registry
|
|
146
|
+
* @returns {string}
|
|
147
|
+
*/
|
|
148
|
+
export function deserializeInlineHtml(html, inline, registry) {
|
|
149
|
+
const source = String(html || '')
|
|
150
|
+
if (!source) return ''
|
|
151
|
+
if (!inline || typeof inline !== 'object' || !registry || !source.includes('{{')) return source
|
|
152
|
+
|
|
153
|
+
const tpl = document.createElement('template')
|
|
154
|
+
tpl.innerHTML = source
|
|
155
|
+
|
|
156
|
+
/** Visit every text node and expand placeholder tokens in place. */
|
|
157
|
+
const walker = document.createTreeWalker(tpl.content, NodeFilter.SHOW_TEXT)
|
|
158
|
+
/** @type {Text[]} */
|
|
159
|
+
const textNodes = []
|
|
160
|
+
let cur = walker.nextNode()
|
|
161
|
+
while (cur) {
|
|
162
|
+
textNodes.push(/** @type {Text} */ (cur))
|
|
163
|
+
cur = walker.nextNode()
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
for (const textNode of textNodes) {
|
|
167
|
+
const text = textNode.data
|
|
168
|
+
if (!text.includes('{{')) continue
|
|
169
|
+
|
|
170
|
+
// Build a fragment: alternating plain-text runs + widget nodes.
|
|
171
|
+
const frag = document.createDocumentFragment()
|
|
172
|
+
let lastIndex = 0
|
|
173
|
+
PLACEHOLDER_RE.lastIndex = 0
|
|
174
|
+
/** @type {RegExpExecArray | null} */
|
|
175
|
+
let match
|
|
176
|
+
while ((match = PLACEHOLDER_RE.exec(text)) !== null) {
|
|
177
|
+
const [token, id] = match
|
|
178
|
+
const ref = Object.prototype.hasOwnProperty.call(inline, id) ? inline[id] : undefined
|
|
179
|
+
if (!ref || typeof ref !== 'object' || typeof ref.type !== 'string') continue
|
|
180
|
+
const plugin = registry.get(ref.type)
|
|
181
|
+
if (!plugin) continue // leave untouched text — user-typed lookalike
|
|
182
|
+
|
|
183
|
+
let widget
|
|
184
|
+
try {
|
|
185
|
+
const data = ref.data && typeof ref.data === 'object'
|
|
186
|
+
? /** @type {Record<string, unknown>} */ (ref.data)
|
|
187
|
+
: {}
|
|
188
|
+
widget = plugin.createWidget(data, id)
|
|
189
|
+
} catch {
|
|
190
|
+
// Preserve malformed legacy entries as their original plain token.
|
|
191
|
+
continue
|
|
192
|
+
}
|
|
193
|
+
if (!(widget instanceof HTMLElement)) continue
|
|
194
|
+
|
|
195
|
+
// Preserve the text before the placeholder.
|
|
196
|
+
if (match.index > lastIndex) {
|
|
197
|
+
frag.appendChild(document.createTextNode(text.slice(lastIndex, match.index)))
|
|
198
|
+
}
|
|
199
|
+
// Instantiate the widget with its stable id preserved.
|
|
200
|
+
frag.appendChild(widget)
|
|
201
|
+
lastIndex = match.index + token.length
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Nothing matched → leave the text node alone.
|
|
205
|
+
if (lastIndex === 0) continue
|
|
206
|
+
|
|
207
|
+
// Trailing text after the last match.
|
|
208
|
+
if (lastIndex < text.length) {
|
|
209
|
+
frag.appendChild(document.createTextNode(text.slice(lastIndex)))
|
|
210
|
+
}
|
|
211
|
+
textNode.replaceWith(frag)
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
return tpl.innerHTML
|
|
215
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Assert that a value can cross the persisted Rector document boundary
|
|
3
|
+
* without changing meaning during JSON serialization.
|
|
4
|
+
*
|
|
5
|
+
* Shared references are allowed (JSON duplicates them), circular references
|
|
6
|
+
* and non-JSON objects are not.
|
|
7
|
+
*
|
|
8
|
+
* @param {unknown} value
|
|
9
|
+
* @param {string} [path]
|
|
10
|
+
*/
|
|
11
|
+
export function assertJsonValue(value: unknown, path?: string): void;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Assert that a value can cross the persisted Rector document boundary
|
|
5
|
+
* without changing meaning during JSON serialization.
|
|
6
|
+
*
|
|
7
|
+
* Shared references are allowed (JSON duplicates them), circular references
|
|
8
|
+
* and non-JSON objects are not.
|
|
9
|
+
*
|
|
10
|
+
* @param {unknown} value
|
|
11
|
+
* @param {string} [path]
|
|
12
|
+
*/
|
|
13
|
+
export function assertJsonValue(value, path = '$') {
|
|
14
|
+
/** @type {Set<object>} */
|
|
15
|
+
const ancestors = new Set()
|
|
16
|
+
|
|
17
|
+
/** @param {unknown} current @param {string} currentPath */
|
|
18
|
+
const visit = (current, currentPath) => {
|
|
19
|
+
if (current === null || typeof current === 'string' || typeof current === 'boolean') return
|
|
20
|
+
if (typeof current === 'number') {
|
|
21
|
+
if (!Number.isFinite(current)) throw new TypeError(`${currentPath} must contain a finite JSON number`)
|
|
22
|
+
return
|
|
23
|
+
}
|
|
24
|
+
if (typeof current !== 'object') {
|
|
25
|
+
throw new TypeError(`${currentPath} contains a non-JSON ${typeof current} value`)
|
|
26
|
+
}
|
|
27
|
+
if (ancestors.has(current)) throw new TypeError(`${currentPath} contains a circular reference`)
|
|
28
|
+
|
|
29
|
+
const prototype = Object.getPrototypeOf(current)
|
|
30
|
+
if (!Array.isArray(current) && prototype !== Object.prototype && prototype !== null) {
|
|
31
|
+
const name = /** @type {{ constructor?: { name?: string } }} */ (current).constructor?.name || 'object'
|
|
32
|
+
throw new TypeError(`${currentPath} contains non-JSON object ${name}`)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
ancestors.add(current)
|
|
36
|
+
if (Array.isArray(current)) {
|
|
37
|
+
for (let index = 0; index < current.length; index++) {
|
|
38
|
+
if (!(index in current)) throw new TypeError(`${currentPath}[${index}] is an array hole`)
|
|
39
|
+
visit(current[index], `${currentPath}[${index}]`)
|
|
40
|
+
}
|
|
41
|
+
} else {
|
|
42
|
+
for (const key of Object.keys(current)) visit(current[key], `${currentPath}.${key}`)
|
|
43
|
+
for (const key of Object.getOwnPropertySymbols(current)) {
|
|
44
|
+
if (Object.prototype.propertyIsEnumerable.call(current, key)) {
|
|
45
|
+
throw new TypeError(`${currentPath} contains an enumerable symbol key`)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
ancestors.delete(current)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
visit(value, path)
|
|
53
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text-field traversal belongs to the document model, not to either the
|
|
3
|
+
* editable plugin layer or the document renderer layer. Keeping the mappers
|
|
4
|
+
* here makes both sides consume the same transformation contract.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* @param {{ text?: string }} data
|
|
8
|
+
* @param {(html: string) => string} transform
|
|
9
|
+
* @returns {void}
|
|
10
|
+
*/
|
|
11
|
+
export function mapParagraphTextFields(data: {
|
|
12
|
+
text?: string;
|
|
13
|
+
}, transform: (html: string) => string): void;
|
|
14
|
+
/**
|
|
15
|
+
* @param {{ text?: string }} data
|
|
16
|
+
* @param {(html: string) => string} transform
|
|
17
|
+
* @returns {void}
|
|
18
|
+
*/
|
|
19
|
+
export function mapHeadingTextFields(data: {
|
|
20
|
+
text?: string;
|
|
21
|
+
}, transform: (html: string) => string): void;
|
|
22
|
+
/**
|
|
23
|
+
* @param {{ items?: unknown }} data
|
|
24
|
+
* @param {(html: string) => string} transform
|
|
25
|
+
* @returns {void}
|
|
26
|
+
*/
|
|
27
|
+
export function mapListTextFields(data: {
|
|
28
|
+
items?: unknown;
|
|
29
|
+
}, transform: (html: string) => string): void;
|
|
30
|
+
/**
|
|
31
|
+
* @param {{ text?: string, caption?: string }} data
|
|
32
|
+
* @param {(html: string) => string} transform
|
|
33
|
+
* @returns {void}
|
|
34
|
+
*/
|
|
35
|
+
export function mapQuoteTextFields(data: {
|
|
36
|
+
text?: string;
|
|
37
|
+
caption?: string;
|
|
38
|
+
}, transform: (html: string) => string): void;
|
|
39
|
+
/**
|
|
40
|
+
* @param {{ items?: unknown }} data
|
|
41
|
+
* @param {(html: string) => string} transform
|
|
42
|
+
* @returns {void}
|
|
43
|
+
*/
|
|
44
|
+
export function mapChecklistTextFields(data: {
|
|
45
|
+
items?: unknown;
|
|
46
|
+
}, transform: (html: string) => string): void;
|
|
47
|
+
/**
|
|
48
|
+
* @param {{ content?: unknown }} data
|
|
49
|
+
* @param {(html: string) => string} transform
|
|
50
|
+
* @returns {void}
|
|
51
|
+
*/
|
|
52
|
+
export function mapTableTextFields(data: {
|
|
53
|
+
content?: unknown;
|
|
54
|
+
}, transform: (html: string) => string): void;
|
|
55
|
+
/**
|
|
56
|
+
* @param {{ columns?: unknown }} data
|
|
57
|
+
* @param {(html: string) => string} transform
|
|
58
|
+
* @returns {void}
|
|
59
|
+
*/
|
|
60
|
+
export function mapColumnsTextFields(data: {
|
|
61
|
+
columns?: unknown;
|
|
62
|
+
}, transform: (html: string) => string): void;
|
|
63
|
+
/**
|
|
64
|
+
* @param {{ title?: string, message?: string }} data
|
|
65
|
+
* @param {(html: string) => string} transform
|
|
66
|
+
* @returns {void}
|
|
67
|
+
*/
|
|
68
|
+
export function mapWarningTextFields(data: {
|
|
69
|
+
title?: string;
|
|
70
|
+
message?: string;
|
|
71
|
+
}, transform: (html: string) => string): void;
|
|
72
|
+
/**
|
|
73
|
+
* @param {{ title?: string, content?: string }} data
|
|
74
|
+
* @param {(html: string) => string} transform
|
|
75
|
+
* @returns {void}
|
|
76
|
+
*/
|
|
77
|
+
export function mapToggleTextFields(data: {
|
|
78
|
+
title?: string;
|
|
79
|
+
content?: string;
|
|
80
|
+
}, transform: (html: string) => string): void;
|
|
81
|
+
/**
|
|
82
|
+
* @param {{ label?: string, content?: string }} data
|
|
83
|
+
* @param {(html: string) => string} transform
|
|
84
|
+
* @returns {void}
|
|
85
|
+
*/
|
|
86
|
+
export function mapSpoilerTextFields(data: {
|
|
87
|
+
label?: string;
|
|
88
|
+
content?: string;
|
|
89
|
+
}, transform: (html: string) => string): void;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
import { normalizeTextValue } from './textFormat.js'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Text-field traversal belongs to the document model, not to either the
|
|
6
|
+
* editable plugin layer or the document renderer layer. Keeping the mappers
|
|
7
|
+
* here makes both sides consume the same transformation contract.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @param {{ text?: string }} data
|
|
12
|
+
* @param {(html: string) => string} transform
|
|
13
|
+
* @returns {void}
|
|
14
|
+
*/
|
|
15
|
+
export function mapParagraphTextFields(data, transform) {
|
|
16
|
+
data.text = transform(normalizeTextValue(data.text))
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @param {{ text?: string }} data
|
|
21
|
+
* @param {(html: string) => string} transform
|
|
22
|
+
* @returns {void}
|
|
23
|
+
*/
|
|
24
|
+
export function mapHeadingTextFields(data, transform) {
|
|
25
|
+
data.text = transform(normalizeTextValue(data.text))
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @param {{ items?: unknown }} data
|
|
30
|
+
* @param {(html: string) => string} transform
|
|
31
|
+
* @returns {void}
|
|
32
|
+
*/
|
|
33
|
+
export function mapListTextFields(data, transform) {
|
|
34
|
+
if (Array.isArray(data.items)) {
|
|
35
|
+
data.items = data.items.map(item => typeof item === 'string' ? transform(item) : item)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @param {{ text?: string, caption?: string }} data
|
|
41
|
+
* @param {(html: string) => string} transform
|
|
42
|
+
* @returns {void}
|
|
43
|
+
*/
|
|
44
|
+
export function mapQuoteTextFields(data, transform) {
|
|
45
|
+
if (typeof data.text === 'string') data.text = transform(data.text)
|
|
46
|
+
if (typeof data.caption === 'string') data.caption = transform(data.caption)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @param {{ items?: unknown }} data
|
|
51
|
+
* @param {(html: string) => string} transform
|
|
52
|
+
* @returns {void}
|
|
53
|
+
*/
|
|
54
|
+
export function mapChecklistTextFields(data, transform) {
|
|
55
|
+
if (!Array.isArray(data.items)) return
|
|
56
|
+
for (const item of data.items) {
|
|
57
|
+
if (item && typeof item === 'object' && typeof (/** @type {{ text?: unknown }} */ (item)).text === 'string') {
|
|
58
|
+
const checklistItem = /** @type {{ text: string }} */ (item)
|
|
59
|
+
checklistItem.text = transform(checklistItem.text)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @param {{ content?: unknown }} data
|
|
66
|
+
* @param {(html: string) => string} transform
|
|
67
|
+
* @returns {void}
|
|
68
|
+
*/
|
|
69
|
+
export function mapTableTextFields(data, transform) {
|
|
70
|
+
if (!Array.isArray(data.content)) return
|
|
71
|
+
data.content = data.content.map(row => Array.isArray(row)
|
|
72
|
+
? row.map(cell => typeof cell === 'string' ? transform(cell) : cell)
|
|
73
|
+
: row)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* @param {{ columns?: unknown }} data
|
|
78
|
+
* @param {(html: string) => string} transform
|
|
79
|
+
* @returns {void}
|
|
80
|
+
*/
|
|
81
|
+
export function mapColumnsTextFields(data, transform) {
|
|
82
|
+
if (!Array.isArray(data.columns)) return
|
|
83
|
+
for (const column of data.columns) {
|
|
84
|
+
if (column && typeof column === 'object' && typeof (/** @type {{ content?: unknown }} */ (column)).content === 'string') {
|
|
85
|
+
const richTextColumn = /** @type {{ content: string }} */ (column)
|
|
86
|
+
richTextColumn.content = transform(richTextColumn.content)
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @param {{ title?: string, message?: string }} data
|
|
93
|
+
* @param {(html: string) => string} transform
|
|
94
|
+
* @returns {void}
|
|
95
|
+
*/
|
|
96
|
+
export function mapWarningTextFields(data, transform) {
|
|
97
|
+
if (typeof data.title === 'string') data.title = transform(data.title)
|
|
98
|
+
if (typeof data.message === 'string') data.message = transform(data.message)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @param {{ title?: string, content?: string }} data
|
|
103
|
+
* @param {(html: string) => string} transform
|
|
104
|
+
* @returns {void}
|
|
105
|
+
*/
|
|
106
|
+
export function mapToggleTextFields(data, transform) {
|
|
107
|
+
if (typeof data.title === 'string') data.title = transform(data.title)
|
|
108
|
+
if (typeof data.content === 'string') data.content = transform(data.content)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* @param {{ label?: string, content?: string }} data
|
|
113
|
+
* @param {(html: string) => string} transform
|
|
114
|
+
* @returns {void}
|
|
115
|
+
*/
|
|
116
|
+
export function mapSpoilerTextFields(data, transform) {
|
|
117
|
+
if (typeof data.label === 'string') data.label = transform(data.label)
|
|
118
|
+
if (typeof data.content === 'string') data.content = transform(data.content)
|
|
119
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalize an untrusted runtime result without retaining arbitrary fields.
|
|
3
|
+
* Unknown option ids and active avatar URLs are discarded.
|
|
4
|
+
* @param {unknown} input
|
|
5
|
+
* @param {string[]} optionIds
|
|
6
|
+
* @param {number} [maxVoters]
|
|
7
|
+
* @param {'single' | 'multiple'} [selectionType]
|
|
8
|
+
* @returns {PollResults}
|
|
9
|
+
*/
|
|
10
|
+
export function normalizePollResults(input: unknown, optionIds: string[], maxVoters?: number, selectionType?: "single" | "multiple"): PollResults;
|
|
11
|
+
/**
|
|
12
|
+
* @param {unknown} input
|
|
13
|
+
* @param {() => string} createId
|
|
14
|
+
* @returns {PollData}
|
|
15
|
+
*/
|
|
16
|
+
export function normalizePollData(input: unknown, createId: () => string): PollData;
|
|
17
|
+
/** @param {unknown} data */
|
|
18
|
+
export function validatePollData(data: unknown): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Apply a local vote and return a new immutable runtime snapshot.
|
|
21
|
+
* @param {PollResults | undefined} current
|
|
22
|
+
* @param {string[]} previousIds
|
|
23
|
+
* @param {string[]} nextIds
|
|
24
|
+
* @param {string[]} optionIds
|
|
25
|
+
* @returns {PollResults}
|
|
26
|
+
*/
|
|
27
|
+
export function applyLocalPollVote(current: PollResults | undefined, previousIds: string[], nextIds: string[], optionIds: string[]): PollResults;
|
|
28
|
+
/**
|
|
29
|
+
* Decide whether a runtime result may replace the currently displayed revision.
|
|
30
|
+
* Opaque unequal revisions follow arrival order unless the host supplies an
|
|
31
|
+
* ordering function. Equal revisions are idempotent and therefore ignored.
|
|
32
|
+
*
|
|
33
|
+
* @param {string | undefined} next
|
|
34
|
+
* @param {string | undefined} current
|
|
35
|
+
* @param {((next: string, current: string) => number) | undefined} compare
|
|
36
|
+
*/
|
|
37
|
+
export function shouldAcceptPollRevision(next: string | undefined, current: string | undefined, compare: ((next: string, current: string) => number) | undefined): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* @typedef {{ id: string, text: string }} PollOption Author-owned option with a stable document id and inline-text label.
|
|
40
|
+
* @typedef {{ id: string, votes: number }} PollOptionResult Vote count for one author-owned option id.
|
|
41
|
+
* @typedef {{ id: string, name?: string, avatar?: string, optionIds?: string[] }} PollVoter Optional application-owned voter summary.
|
|
42
|
+
* @typedef {{ revision?: string, total: number, options: PollOptionResult[], voters?: PollVoter[], votersTotal?: number, currentUserVote?: string[] }} PollResults Runtime result snapshot. `total` is the ballot-count denominator used for percentages; multiple-choice option percentages may therefore sum above 100%.
|
|
43
|
+
* @typedef {{ pollId?: string, question: string, type: 'single' | 'multiple', options: PollOption[], resultsMode: 'always' | 'afterVote' | 'hidden', initialResults?: PollResults }} PollData Persisted poll authoring data plus an optional initial/local result snapshot.
|
|
44
|
+
*/
|
|
45
|
+
export const POLL_RESULTS_MODES: readonly string[];
|
|
46
|
+
/**
|
|
47
|
+
* Author-owned option with a stable document id and inline-text label.
|
|
48
|
+
*/
|
|
49
|
+
export type PollOption = {
|
|
50
|
+
id: string;
|
|
51
|
+
text: string;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Vote count for one author-owned option id.
|
|
55
|
+
*/
|
|
56
|
+
export type PollOptionResult = {
|
|
57
|
+
id: string;
|
|
58
|
+
votes: number;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Optional application-owned voter summary.
|
|
62
|
+
*/
|
|
63
|
+
export type PollVoter = {
|
|
64
|
+
id: string;
|
|
65
|
+
name?: string;
|
|
66
|
+
avatar?: string;
|
|
67
|
+
optionIds?: string[];
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Runtime result snapshot. `total` is the ballot-count denominator used for percentages; multiple-choice option percentages may therefore sum above 100%.
|
|
71
|
+
*/
|
|
72
|
+
export type PollResults = {
|
|
73
|
+
revision?: string;
|
|
74
|
+
total: number;
|
|
75
|
+
options: PollOptionResult[];
|
|
76
|
+
voters?: PollVoter[];
|
|
77
|
+
votersTotal?: number;
|
|
78
|
+
currentUserVote?: string[];
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Persisted poll authoring data plus an optional initial/local result snapshot.
|
|
82
|
+
*/
|
|
83
|
+
export type PollData = {
|
|
84
|
+
pollId?: string;
|
|
85
|
+
question: string;
|
|
86
|
+
type: "single" | "multiple";
|
|
87
|
+
options: PollOption[];
|
|
88
|
+
resultsMode: "always" | "afterVote" | "hidden";
|
|
89
|
+
initialResults?: PollResults;
|
|
90
|
+
};
|