@aquera/nile-elements 1.9.5 → 1.9.7
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/README.md +9 -0
- package/dist/index-178e1e57.cjs.js +2 -0
- package/dist/index-178e1e57.cjs.js.map +1 -0
- package/dist/index-1faa963c.esm.js +1 -0
- package/dist/index-249de90a.esm.js +1 -0
- package/dist/index-353172ed.esm.js +1 -0
- package/dist/index-6f3fa4ab.esm.js +1 -0
- package/dist/index-89c520e9.cjs.js +5 -0
- package/dist/index-89c520e9.cjs.js.map +1 -0
- package/dist/index-920675c4.esm.js +1 -0
- package/dist/index-b387a9f4.cjs.js +2 -0
- package/dist/index-b387a9f4.cjs.js.map +1 -0
- package/dist/index-cc1385e0.cjs.js +2 -0
- package/dist/index-cc1385e0.cjs.js.map +1 -0
- package/dist/index-dedc38a6.esm.js +1 -0
- package/dist/index-df196058.cjs.js +2 -0
- package/dist/index-df196058.cjs.js.map +1 -0
- package/dist/index-f956f56d.cjs.js +7 -0
- package/dist/index-f956f56d.cjs.js.map +1 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +3802 -664
- package/dist/internal/glyph.cjs.js +2 -0
- package/dist/internal/glyph.cjs.js.map +1 -0
- package/dist/internal/glyph.esm.js +5 -0
- package/dist/nile-auto-complete/index.cjs.js +1 -1
- package/dist/nile-auto-complete/nile-auto-complete.cjs.js +1 -1
- package/dist/nile-auto-complete/portal-manager.cjs.js +1 -1
- package/dist/nile-auto-complete/portal-utils.cjs.js +1 -1
- package/dist/nile-chip/nile-chip.css.cjs.js +1 -1
- package/dist/nile-chip/nile-chip.css.cjs.js.map +1 -1
- package/dist/nile-chip/nile-chip.css.esm.js +8 -1
- package/dist/nile-code-editor/extensionSetup.cjs.js +7 -7
- package/dist/nile-code-editor/extensionSetup.cjs.js.map +1 -1
- package/dist/nile-code-editor/extensionSetup.esm.js +1 -1
- package/dist/nile-code-editor/index.cjs.js +1 -1
- package/dist/nile-code-editor/index.esm.js +1 -1
- package/dist/nile-code-editor/nile-code-editor.cjs.js +2 -2
- package/dist/nile-code-editor/nile-code-editor.cjs.js.map +1 -1
- package/dist/nile-code-editor/nile-code-editor.esm.js +4 -4
- package/dist/nile-color-picker/index.cjs.js +1 -1
- package/dist/nile-color-picker/nile-color-picker.cjs.js +1 -1
- package/dist/nile-combobox/index.cjs.js +1 -1
- package/dist/nile-combobox/index.esm.js +1 -1
- package/dist/nile-combobox/nile-combobox.cjs.js +1 -1
- package/dist/nile-combobox/nile-combobox.esm.js +1 -1
- package/dist/nile-combobox/portal-manager.cjs.js +1 -1
- package/dist/nile-context-menu/index.cjs.js +1 -1
- package/dist/nile-context-menu/nile-context-menu.cjs.js +1 -1
- package/dist/nile-context-submenu/index.cjs.js +1 -1
- package/dist/nile-context-submenu/nile-context-submenu.cjs.js +1 -1
- package/dist/nile-detail/index.cjs.js +1 -1
- package/dist/nile-detail/index.esm.js +1 -1
- package/dist/nile-detail/nile-detail.cjs.js +1 -1
- package/dist/nile-detail/nile-detail.esm.js +1 -1
- package/dist/nile-dropdown/index.cjs.js +1 -1
- package/dist/nile-dropdown/nile-dropdown.cjs.js +1 -1
- package/dist/nile-dropdown/portal-manager.cjs.js +1 -1
- package/dist/nile-file-upload/index.cjs.js +1 -1
- package/dist/nile-file-upload/nile-file-upload.cjs.js +1 -1
- package/dist/nile-file-upload/nile-file-upload.template.cjs.js +1 -1
- package/dist/nile-floating-panel/index.cjs.js +1 -1
- package/dist/nile-floating-panel/nile-floating-panel.cjs.js +1 -1
- package/dist/nile-hero/nile-hero.cjs.js +1 -1
- package/dist/nile-hero/nile-hero.cjs.js.map +1 -1
- package/dist/nile-hero/nile-hero.css.cjs.js +1 -1
- package/dist/nile-hero/nile-hero.css.cjs.js.map +1 -1
- package/dist/nile-hero/nile-hero.css.esm.js +14 -14
- package/dist/nile-hero/nile-hero.esm.js +1 -1
- package/dist/nile-hero-header/nile-hero-header.cjs.js +1 -1
- package/dist/nile-hero-header/nile-hero-header.cjs.js.map +1 -1
- package/dist/nile-hero-header/nile-hero-header.css.cjs.js +1 -1
- package/dist/nile-hero-header/nile-hero-header.css.cjs.js.map +1 -1
- package/dist/nile-hero-header/nile-hero-header.css.esm.js +11 -11
- package/dist/nile-hero-header/nile-hero-header.esm.js +3 -3
- package/dist/nile-lite-tooltip/index.cjs.js +1 -1
- package/dist/nile-lite-tooltip/nile-lite-tooltip.cjs.js +1 -1
- package/dist/nile-markdown-editor/index.cjs.js +1 -1
- package/dist/nile-markdown-editor/nile-markdown-editor.cjs.js +1 -1
- package/dist/nile-popover/index.cjs.js +1 -1
- package/dist/nile-popover/nile-popover.cjs.js +1 -1
- package/dist/nile-popover/portal-manager.cjs.js +1 -1
- package/dist/nile-popup/index.cjs.js +1 -1
- package/dist/nile-popup/nile-popup.cjs.js +1 -1
- package/dist/nile-rich-text-editor/index.cjs.js +1 -1
- package/dist/nile-rich-text-editor/index.esm.js +1 -1
- package/dist/nile-rich-text-editor/nile-rich-text-editor.cjs.js +1 -1
- package/dist/nile-rich-text-editor/nile-rich-text-editor.cjs.js.map +1 -1
- package/dist/nile-rich-text-editor/nile-rich-text-editor.css.cjs.js +1 -1
- package/dist/nile-rich-text-editor/nile-rich-text-editor.css.cjs.js.map +1 -1
- package/dist/nile-rich-text-editor/nile-rich-text-editor.css.esm.js +70 -0
- package/dist/nile-rich-text-editor/nile-rich-text-editor.esm.js +1 -1
- package/dist/nile-rich-text-editor/nile-rte-image.cjs.js +3 -0
- package/dist/nile-rich-text-editor/nile-rte-image.cjs.js.map +1 -0
- package/dist/nile-rich-text-editor/nile-rte-image.esm.js +96 -0
- package/dist/nile-select/index.cjs.js +1 -1
- package/dist/nile-select/nile-select.cjs.js +1 -1
- package/dist/nile-select/portal-manager.cjs.js +1 -1
- package/dist/nile-side-bar-action/index.cjs.js +1 -1
- package/dist/nile-side-bar-action/nile-side-bar-action.cjs.js +1 -1
- package/dist/nile-side-bar-action/portal-manager.cjs.js +1 -1
- package/dist/nile-tooltip/index.cjs.js +1 -1
- package/dist/nile-tooltip/nile-tooltip.cjs.js +1 -1
- package/dist/nile-virtual-select/index.cjs.js +1 -1
- package/dist/nile-virtual-select/nile-virtual-select.cjs.js +1 -1
- package/dist/nile-virtual-select/portal-manager.cjs.js +1 -1
- package/dist/nile-virtual-select/renderer.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/emoji.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/emoji.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/emoji.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/engine/commands.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/engine/commands.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/engine/commands.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/engine/create-state.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/engine/create-state.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/engine/create-state.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/engine/export.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/engine/export.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/engine/export.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/engine/index.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/engine/index.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/engine/index.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/engine/inputrules.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/engine/inputrules.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/engine/inputrules.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/engine/keymap.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/engine/keymap.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/engine/keymap.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/engine/markdown-parse.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/engine/markdown-parse.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/engine/markdown-parse.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/engine/markdown.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/engine/markdown.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/engine/markdown.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/engine/office-paste.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/engine/office-paste.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/engine/office-paste.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/code-highlight.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/code-highlight.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/code-highlight.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/embed-view.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/embed-view.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/embed-view.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/embeds.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/embeds.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/embeds.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/find-replace.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/find-replace.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/find-replace.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/format-painter.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/format-painter.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/format-painter.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/image-view.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/image-view.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/image-view.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/image.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/image.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/image.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/link.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/link.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/link.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/math-view.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/math-view.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/math-view.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/max-length.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/max-length.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/max-length.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/paste.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/paste.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/paste.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/placeholder.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/placeholder.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/placeholder.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/single-line.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/single-line.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/single-line.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/suggestions.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/suggestions.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/suggestions.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/tables.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/tables.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/tables.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/task-list.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/task-list.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/task-list.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/engine/sanitize.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/engine/sanitize.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/engine/sanitize.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/engine/schema.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/engine/schema.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/engine/schema.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/engine/selection-state.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/engine/selection-state.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/engine/selection-state.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/engine/serializer.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/engine/serializer.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/engine/serializer.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/index.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/index.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/index.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.css.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.css.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.css.esm.js +780 -0
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.esm.js +97 -0
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/index.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/index.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/index.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.css.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.css.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.css.esm.js +244 -0
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.esm.js +137 -0
- package/dist/nile-wysiwyg-editor/types.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/types.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/types.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/ui/bookmark-panel.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/ui/bookmark-panel.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/ui/bookmark-panel.esm.js +97 -0
- package/dist/nile-wysiwyg-editor/ui/bubble-menu.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/ui/bubble-menu.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/ui/bubble-menu.esm.js +67 -0
- package/dist/nile-wysiwyg-editor/ui/code-block-menu.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/ui/code-block-menu.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/ui/code-block-menu.esm.js +65 -0
- package/dist/nile-wysiwyg-editor/ui/embed-menu.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/ui/embed-menu.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/ui/embed-menu.esm.js +64 -0
- package/dist/nile-wysiwyg-editor/ui/embed-panel.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/ui/embed-panel.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/ui/embed-panel.esm.js +68 -0
- package/dist/nile-wysiwyg-editor/ui/emoji-picker.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/ui/emoji-picker.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/ui/emoji-picker.esm.js +96 -0
- package/dist/nile-wysiwyg-editor/ui/find-replace.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/ui/find-replace.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/ui/find-replace.esm.js +112 -0
- package/dist/nile-wysiwyg-editor/ui/image-menu.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/ui/image-menu.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/ui/image-menu.esm.js +64 -0
- package/dist/nile-wysiwyg-editor/ui/image-panel.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/ui/image-panel.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/ui/image-panel.esm.js +171 -0
- package/dist/nile-wysiwyg-editor/ui/insert-menu.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/ui/insert-menu.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/ui/insert-menu.esm.js +90 -0
- package/dist/nile-wysiwyg-editor/ui/link-editor.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/ui/link-editor.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/ui/link-editor.esm.js +114 -0
- package/dist/nile-wysiwyg-editor/ui/markdown-panel.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/ui/markdown-panel.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/ui/markdown-panel.esm.js +80 -0
- package/dist/nile-wysiwyg-editor/ui/math-panel.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/ui/math-panel.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/ui/math-panel.esm.js +92 -0
- package/dist/nile-wysiwyg-editor/ui/shortcut-help.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/ui/shortcut-help.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/ui/shortcut-help.esm.js +147 -0
- package/dist/nile-wysiwyg-editor/ui/source-view.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/ui/source-view.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/ui/source-view.esm.js +79 -0
- package/dist/nile-wysiwyg-editor/ui/special-chars.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/ui/special-chars.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/ui/special-chars.esm.js +96 -0
- package/dist/nile-wysiwyg-editor/ui/suggest-list.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/ui/suggest-list.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/ui/suggest-list.esm.js +67 -0
- package/dist/nile-wysiwyg-editor/ui/table-grid-picker.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/ui/table-grid-picker.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/ui/table-grid-picker.esm.js +100 -0
- package/dist/nile-wysiwyg-editor/ui/table-menu.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/ui/table-menu.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/ui/table-menu.esm.js +58 -0
- package/dist/src/index.d.ts +24 -0
- package/dist/src/index.js +19 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/internal/glyph.d.ts +6 -0
- package/dist/src/internal/glyph.js +13 -0
- package/dist/src/internal/glyph.js.map +1 -0
- package/dist/src/nile-chip/nile-chip.css.js +8 -1
- package/dist/src/nile-chip/nile-chip.css.js.map +1 -1
- package/dist/src/nile-code-editor/nile-code-editor.js +3 -3
- package/dist/src/nile-code-editor/nile-code-editor.js.map +1 -1
- package/dist/src/nile-hero/nile-hero.css.js +12 -12
- package/dist/src/nile-hero/nile-hero.css.js.map +1 -1
- package/dist/src/nile-hero/nile-hero.js +1 -1
- package/dist/src/nile-hero/nile-hero.js.map +1 -1
- package/dist/src/nile-hero-header/nile-hero-header.css.js +9 -9
- package/dist/src/nile-hero-header/nile-hero-header.css.js.map +1 -1
- package/dist/src/nile-hero-header/nile-hero-header.js +1 -1
- package/dist/src/nile-hero-header/nile-hero-header.js.map +1 -1
- package/dist/src/nile-rich-text-editor/nile-rich-text-editor.css.js +70 -0
- package/dist/src/nile-rich-text-editor/nile-rich-text-editor.css.js.map +1 -1
- package/dist/src/nile-rich-text-editor/nile-rich-text-editor.d.ts +3 -0
- package/dist/src/nile-rich-text-editor/nile-rich-text-editor.js +81 -3
- package/dist/src/nile-rich-text-editor/nile-rich-text-editor.js.map +1 -1
- package/dist/src/nile-rich-text-editor/nile-rte-image.d.ts +87 -0
- package/dist/src/nile-rich-text-editor/nile-rte-image.js +1073 -0
- package/dist/src/nile-rich-text-editor/nile-rte-image.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/emoji.d.ts +5 -0
- package/dist/src/nile-wysiwyg-editor/emoji.js +138 -0
- package/dist/src/nile-wysiwyg-editor/emoji.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/commands.d.ts +69 -0
- package/dist/src/nile-wysiwyg-editor/engine/commands.js +863 -0
- package/dist/src/nile-wysiwyg-editor/engine/commands.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/create-state.d.ts +35 -0
- package/dist/src/nile-wysiwyg-editor/engine/create-state.js +67 -0
- package/dist/src/nile-wysiwyg-editor/engine/create-state.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/export.d.ts +38 -0
- package/dist/src/nile-wysiwyg-editor/engine/export.js +208 -0
- package/dist/src/nile-wysiwyg-editor/engine/export.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/export.test.d.ts +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/export.test.js +96 -0
- package/dist/src/nile-wysiwyg-editor/engine/export.test.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/index.d.ts +37 -0
- package/dist/src/nile-wysiwyg-editor/engine/index.js +29 -0
- package/dist/src/nile-wysiwyg-editor/engine/index.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/inputrules.d.ts +12 -0
- package/dist/src/nile-wysiwyg-editor/engine/inputrules.js +144 -0
- package/dist/src/nile-wysiwyg-editor/engine/inputrules.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/keymap.d.ts +15 -0
- package/dist/src/nile-wysiwyg-editor/engine/keymap.js +94 -0
- package/dist/src/nile-wysiwyg-editor/engine/keymap.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/markdown-parse.d.ts +22 -0
- package/dist/src/nile-wysiwyg-editor/engine/markdown-parse.js +287 -0
- package/dist/src/nile-wysiwyg-editor/engine/markdown-parse.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/markdown-parse.test.d.ts +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/markdown-parse.test.js +106 -0
- package/dist/src/nile-wysiwyg-editor/engine/markdown-parse.test.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/markdown.d.ts +10 -0
- package/dist/src/nile-wysiwyg-editor/engine/markdown.js +162 -0
- package/dist/src/nile-wysiwyg-editor/engine/markdown.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/office-paste.d.ts +13 -0
- package/dist/src/nile-wysiwyg-editor/engine/office-paste.js +182 -0
- package/dist/src/nile-wysiwyg-editor/engine/office-paste.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/code-highlight.d.ts +10 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/code-highlight.js +165 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/code-highlight.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/embed-view.d.ts +17 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/embed-view.js +69 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/embed-view.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/embeds.d.ts +17 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/embeds.js +96 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/embeds.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/find-replace.d.ts +26 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/find-replace.js +123 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/find-replace.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/format-painter.d.ts +28 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/format-painter.js +72 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/format-painter.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/image-view.d.ts +41 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/image-view.js +176 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/image-view.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/image.d.ts +15 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/image.js +64 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/image.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/link.d.ts +11 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/link.js +42 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/link.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/math-view.d.ts +18 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/math-view.js +46 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/math-view.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/max-length.d.ts +7 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/max-length.js +26 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/max-length.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/paste.d.ts +31 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/paste.js +55 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/paste.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/placeholder.d.ts +7 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/placeholder.js +25 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/placeholder.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/single-line.d.ts +10 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/single-line.js +48 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/single-line.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/suggestions.d.ts +29 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/suggestions.js +87 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/suggestions.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/tables.d.ts +8 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/tables.js +11 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/tables.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/task-list.d.ts +16 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/task-list.js +49 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/task-list.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/pm.test.d.ts +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/pm.test.js +883 -0
- package/dist/src/nile-wysiwyg-editor/engine/pm.test.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/productivity.test.d.ts +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/productivity.test.js +129 -0
- package/dist/src/nile-wysiwyg-editor/engine/productivity.test.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/sanitize.d.ts +13 -0
- package/dist/src/nile-wysiwyg-editor/engine/sanitize.js +155 -0
- package/dist/src/nile-wysiwyg-editor/engine/sanitize.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/schema.d.ts +20 -0
- package/dist/src/nile-wysiwyg-editor/engine/schema.js +823 -0
- package/dist/src/nile-wysiwyg-editor/engine/schema.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/selection-state.d.ts +70 -0
- package/dist/src/nile-wysiwyg-editor/engine/selection-state.js +138 -0
- package/dist/src/nile-wysiwyg-editor/engine/selection-state.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/serializer.d.ts +18 -0
- package/dist/src/nile-wysiwyg-editor/engine/serializer.js +63 -0
- package/dist/src/nile-wysiwyg-editor/engine/serializer.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/index.d.ts +3 -0
- package/dist/src/nile-wysiwyg-editor/index.js +3 -0
- package/dist/src/nile-wysiwyg-editor/index.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.css.d.ts +1 -0
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.css.js +782 -0
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.css.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.d.ts +364 -0
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.js +2038 -0
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.test.d.ts +1 -0
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.test.js +636 -0
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.test.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/index.d.ts +1 -0
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/index.js +2 -0
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/index.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.css.d.ts +6 -0
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.css.js +251 -0
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.css.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.d.ts +41 -0
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.js +700 -0
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/types.d.ts +49 -0
- package/dist/src/nile-wysiwyg-editor/types.js +8 -0
- package/dist/src/nile-wysiwyg-editor/types.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/ui/bookmark-panel.d.ts +20 -0
- package/dist/src/nile-wysiwyg-editor/ui/bookmark-panel.js +159 -0
- package/dist/src/nile-wysiwyg-editor/ui/bookmark-panel.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/ui/bubble-menu.d.ts +21 -0
- package/dist/src/nile-wysiwyg-editor/ui/bubble-menu.js +125 -0
- package/dist/src/nile-wysiwyg-editor/ui/bubble-menu.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/ui/code-block-menu.d.ts +18 -0
- package/dist/src/nile-wysiwyg-editor/ui/code-block-menu.js +107 -0
- package/dist/src/nile-wysiwyg-editor/ui/code-block-menu.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/ui/embed-menu.d.ts +19 -0
- package/dist/src/nile-wysiwyg-editor/ui/embed-menu.js +123 -0
- package/dist/src/nile-wysiwyg-editor/ui/embed-menu.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/ui/embed-panel.d.ts +27 -0
- package/dist/src/nile-wysiwyg-editor/ui/embed-panel.js +146 -0
- package/dist/src/nile-wysiwyg-editor/ui/embed-panel.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/ui/emoji-picker.d.ts +21 -0
- package/dist/src/nile-wysiwyg-editor/ui/emoji-picker.js +154 -0
- package/dist/src/nile-wysiwyg-editor/ui/emoji-picker.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/ui/find-replace.d.ts +26 -0
- package/dist/src/nile-wysiwyg-editor/ui/find-replace.js +178 -0
- package/dist/src/nile-wysiwyg-editor/ui/find-replace.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/ui/image-menu.d.ts +18 -0
- package/dist/src/nile-wysiwyg-editor/ui/image-menu.js +129 -0
- package/dist/src/nile-wysiwyg-editor/ui/image-menu.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/ui/image-panel.d.ts +56 -0
- package/dist/src/nile-wysiwyg-editor/ui/image-panel.js +349 -0
- package/dist/src/nile-wysiwyg-editor/ui/image-panel.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/ui/insert-menu.d.ts +25 -0
- package/dist/src/nile-wysiwyg-editor/ui/insert-menu.js +142 -0
- package/dist/src/nile-wysiwyg-editor/ui/insert-menu.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/ui/link-editor.d.ts +30 -0
- package/dist/src/nile-wysiwyg-editor/ui/link-editor.js +189 -0
- package/dist/src/nile-wysiwyg-editor/ui/link-editor.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/ui/markdown-panel.d.ts +24 -0
- package/dist/src/nile-wysiwyg-editor/ui/markdown-panel.js +144 -0
- package/dist/src/nile-wysiwyg-editor/ui/markdown-panel.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/ui/math-panel.d.ts +31 -0
- package/dist/src/nile-wysiwyg-editor/ui/math-panel.js +172 -0
- package/dist/src/nile-wysiwyg-editor/ui/math-panel.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/ui/shortcut-help.d.ts +30 -0
- package/dist/src/nile-wysiwyg-editor/ui/shortcut-help.js +296 -0
- package/dist/src/nile-wysiwyg-editor/ui/shortcut-help.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/ui/source-view.d.ts +19 -0
- package/dist/src/nile-wysiwyg-editor/ui/source-view.js +120 -0
- package/dist/src/nile-wysiwyg-editor/ui/source-view.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/ui/special-chars.d.ts +20 -0
- package/dist/src/nile-wysiwyg-editor/ui/special-chars.js +199 -0
- package/dist/src/nile-wysiwyg-editor/ui/special-chars.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/ui/suggest-list.d.ts +31 -0
- package/dist/src/nile-wysiwyg-editor/ui/suggest-list.js +133 -0
- package/dist/src/nile-wysiwyg-editor/ui/suggest-list.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/ui/table-grid-picker.d.ts +23 -0
- package/dist/src/nile-wysiwyg-editor/ui/table-grid-picker.js +177 -0
- package/dist/src/nile-wysiwyg-editor/ui/table-grid-picker.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/ui/table-menu.d.ts +16 -0
- package/dist/src/nile-wysiwyg-editor/ui/table-menu.js +101 -0
- package/dist/src/nile-wysiwyg-editor/ui/table-menu.js.map +1 -0
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +18 -2
- package/src/index.ts +57 -1
- package/src/internal/glyph.ts +13 -0
- package/src/nile-chip/nile-chip.css.ts +8 -1
- package/src/nile-code-editor/nile-code-editor.ts +3 -3
- package/src/nile-hero/nile-hero.css.ts +12 -12
- package/src/nile-hero/nile-hero.ts +1 -1
- package/src/nile-hero-header/nile-hero-header.css.ts +9 -9
- package/src/nile-hero-header/nile-hero-header.ts +1 -1
- package/src/nile-rich-text-editor/nile-rich-text-editor.css.ts +70 -0
- package/src/nile-rich-text-editor/nile-rich-text-editor.ts +89 -3
- package/src/nile-rich-text-editor/nile-rte-image.ts +1132 -0
- package/src/nile-wysiwyg-editor/emoji.ts +137 -0
- package/src/nile-wysiwyg-editor/engine/commands.ts +1035 -0
- package/src/nile-wysiwyg-editor/engine/create-state.ts +117 -0
- package/src/nile-wysiwyg-editor/engine/export.test.ts +113 -0
- package/src/nile-wysiwyg-editor/engine/export.ts +242 -0
- package/src/nile-wysiwyg-editor/engine/index.ts +69 -0
- package/src/nile-wysiwyg-editor/engine/inputrules.ts +169 -0
- package/src/nile-wysiwyg-editor/engine/keymap.ts +146 -0
- package/src/nile-wysiwyg-editor/engine/markdown-parse.test.ts +148 -0
- package/src/nile-wysiwyg-editor/engine/markdown-parse.ts +337 -0
- package/src/nile-wysiwyg-editor/engine/markdown.ts +165 -0
- package/src/nile-wysiwyg-editor/engine/office-paste.ts +199 -0
- package/src/nile-wysiwyg-editor/engine/plugins/code-highlight.ts +173 -0
- package/src/nile-wysiwyg-editor/engine/plugins/embed-view.ts +85 -0
- package/src/nile-wysiwyg-editor/engine/plugins/embeds.ts +99 -0
- package/src/nile-wysiwyg-editor/engine/plugins/find-replace.ts +155 -0
- package/src/nile-wysiwyg-editor/engine/plugins/format-painter.ts +80 -0
- package/src/nile-wysiwyg-editor/engine/plugins/image-view.ts +220 -0
- package/src/nile-wysiwyg-editor/engine/plugins/image.ts +80 -0
- package/src/nile-wysiwyg-editor/engine/plugins/link.ts +42 -0
- package/src/nile-wysiwyg-editor/engine/plugins/math-view.ts +56 -0
- package/src/nile-wysiwyg-editor/engine/plugins/max-length.ts +24 -0
- package/src/nile-wysiwyg-editor/engine/plugins/paste.ts +74 -0
- package/src/nile-wysiwyg-editor/engine/plugins/placeholder.ts +24 -0
- package/src/nile-wysiwyg-editor/engine/plugins/single-line.ts +47 -0
- package/src/nile-wysiwyg-editor/engine/plugins/suggestions.ts +110 -0
- package/src/nile-wysiwyg-editor/engine/plugins/tables.ts +12 -0
- package/src/nile-wysiwyg-editor/engine/plugins/task-list.ts +65 -0
- package/src/nile-wysiwyg-editor/engine/pm.test.ts +1088 -0
- package/src/nile-wysiwyg-editor/engine/productivity.test.ts +163 -0
- package/src/nile-wysiwyg-editor/engine/sanitize.ts +156 -0
- package/src/nile-wysiwyg-editor/engine/schema.ts +859 -0
- package/src/nile-wysiwyg-editor/engine/selection-state.ts +210 -0
- package/src/nile-wysiwyg-editor/engine/serializer.ts +78 -0
- package/src/nile-wysiwyg-editor/index.ts +3 -0
- package/src/nile-wysiwyg-editor/nile-wysiwyg-editor.css.ts +782 -0
- package/src/nile-wysiwyg-editor/nile-wysiwyg-editor.test.ts +750 -0
- package/src/nile-wysiwyg-editor/nile-wysiwyg-editor.ts +2155 -0
- package/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/index.ts +1 -0
- package/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.css.ts +251 -0
- package/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.ts +772 -0
- package/src/nile-wysiwyg-editor/types.ts +83 -0
- package/src/nile-wysiwyg-editor/ui/bookmark-panel.ts +155 -0
- package/src/nile-wysiwyg-editor/ui/bubble-menu.ts +135 -0
- package/src/nile-wysiwyg-editor/ui/code-block-menu.ts +105 -0
- package/src/nile-wysiwyg-editor/ui/embed-menu.ts +133 -0
- package/src/nile-wysiwyg-editor/ui/embed-panel.ts +143 -0
- package/src/nile-wysiwyg-editor/ui/emoji-picker.ts +152 -0
- package/src/nile-wysiwyg-editor/ui/find-replace.ts +174 -0
- package/src/nile-wysiwyg-editor/ui/image-menu.ts +140 -0
- package/src/nile-wysiwyg-editor/ui/image-panel.ts +337 -0
- package/src/nile-wysiwyg-editor/ui/insert-menu.ts +142 -0
- package/src/nile-wysiwyg-editor/ui/link-editor.ts +180 -0
- package/src/nile-wysiwyg-editor/ui/markdown-panel.ts +143 -0
- package/src/nile-wysiwyg-editor/ui/math-panel.ts +169 -0
- package/src/nile-wysiwyg-editor/ui/shortcut-help.ts +311 -0
- package/src/nile-wysiwyg-editor/ui/source-view.ts +119 -0
- package/src/nile-wysiwyg-editor/ui/special-chars.ts +209 -0
- package/src/nile-wysiwyg-editor/ui/suggest-list.ts +138 -0
- package/src/nile-wysiwyg-editor/ui/table-grid-picker.ts +173 -0
- package/src/nile-wysiwyg-editor/ui/table-menu.ts +109 -0
- package/vscode-html-custom-data.json +491 -1
- package/web-dev-server.config.mjs +6 -2
- package/dist/index-5fef1a0d.esm.js +0 -1
- package/dist/index-8f38fae3.cjs.js +0 -2
- package/dist/index-8f38fae3.cjs.js.map +0 -1
|
@@ -0,0 +1,1035 @@
|
|
|
1
|
+
import { toggleMark, setBlockType, wrapIn, lift, chainCommands } from 'prosemirror-commands';
|
|
2
|
+
import { wrapInList, liftListItem, sinkListItem } from 'prosemirror-schema-list';
|
|
3
|
+
import { undo, redo } from 'prosemirror-history';
|
|
4
|
+
import {
|
|
5
|
+
addRowBefore,
|
|
6
|
+
addRowAfter,
|
|
7
|
+
addColumnBefore,
|
|
8
|
+
addColumnAfter,
|
|
9
|
+
deleteRow,
|
|
10
|
+
deleteColumn,
|
|
11
|
+
deleteTable,
|
|
12
|
+
mergeCells,
|
|
13
|
+
splitCell,
|
|
14
|
+
toggleHeaderRow,
|
|
15
|
+
} from 'prosemirror-tables';
|
|
16
|
+
import { Command, EditorState, TextSelection, NodeSelection } from 'prosemirror-state';
|
|
17
|
+
import { MarkType, NodeType, ResolvedPos, Attrs, Schema, Node as PMNode, Mark } from 'prosemirror-model';
|
|
18
|
+
import type { Alignment } from './schema';
|
|
19
|
+
import { MAX_INDENT, MULTILEVEL_STYLE } from './schema';
|
|
20
|
+
|
|
21
|
+
export type CommandName =
|
|
22
|
+
| 'bold'
|
|
23
|
+
| 'italic'
|
|
24
|
+
| 'underline'
|
|
25
|
+
| 'strike'
|
|
26
|
+
| 'subscript'
|
|
27
|
+
| 'superscript'
|
|
28
|
+
| 'code'
|
|
29
|
+
| 'paragraph'
|
|
30
|
+
| 'heading'
|
|
31
|
+
| 'blockquote'
|
|
32
|
+
| 'align'
|
|
33
|
+
| 'lineHeight'
|
|
34
|
+
| 'bulletList'
|
|
35
|
+
| 'orderedList'
|
|
36
|
+
| 'taskList'
|
|
37
|
+
| 'indent'
|
|
38
|
+
| 'outdent'
|
|
39
|
+
| 'setListStyle'
|
|
40
|
+
| 'setListStart'
|
|
41
|
+
| 'toggleImageCaption'
|
|
42
|
+
| 'setImageAlign'
|
|
43
|
+
| 'setImageWidth'
|
|
44
|
+
| 'deleteImage'
|
|
45
|
+
| 'updateImage'
|
|
46
|
+
| 'setEmbedAlign'
|
|
47
|
+
| 'deleteEmbed'
|
|
48
|
+
| 'link'
|
|
49
|
+
| 'unlink'
|
|
50
|
+
| 'insertBookmark'
|
|
51
|
+
| 'textColor'
|
|
52
|
+
| 'bgColor'
|
|
53
|
+
| 'fontFamily'
|
|
54
|
+
| 'fontSize'
|
|
55
|
+
| 'horizontalRule'
|
|
56
|
+
| 'clearFormatting'
|
|
57
|
+
| 'undo'
|
|
58
|
+
| 'redo'
|
|
59
|
+
| 'codeBlock'
|
|
60
|
+
| 'setCodeBlockLanguage'
|
|
61
|
+
| 'insertEmbed'
|
|
62
|
+
| 'insertImage'
|
|
63
|
+
| 'insertTable'
|
|
64
|
+
| 'addRowBefore'
|
|
65
|
+
| 'addRowAfter'
|
|
66
|
+
| 'addColumnBefore'
|
|
67
|
+
| 'addColumnAfter'
|
|
68
|
+
| 'deleteRow'
|
|
69
|
+
| 'deleteColumn'
|
|
70
|
+
| 'mergeCells'
|
|
71
|
+
| 'splitCell'
|
|
72
|
+
| 'toggleHeaderRow'
|
|
73
|
+
| 'toggleLayoutTable'
|
|
74
|
+
| 'deleteTable'
|
|
75
|
+
| 'changeCase'
|
|
76
|
+
| 'insertMergeField'
|
|
77
|
+
| 'insertMath';
|
|
78
|
+
|
|
79
|
+
export interface CommandAttrs {
|
|
80
|
+
level?: number;
|
|
81
|
+
align?: Alignment | null;
|
|
82
|
+
href?: string;
|
|
83
|
+
title?: string;
|
|
84
|
+
target?: string | null;
|
|
85
|
+
color?: string | null;
|
|
86
|
+
family?: string | null;
|
|
87
|
+
size?: string | null;
|
|
88
|
+
/** insertImage / updateImage */
|
|
89
|
+
src?: string;
|
|
90
|
+
alt?: string | null;
|
|
91
|
+
/** insertImage / updateImage: figcaption text; empty/null = plain inline image */
|
|
92
|
+
caption?: string | null;
|
|
93
|
+
/** insertTable */
|
|
94
|
+
rows?: number;
|
|
95
|
+
cols?: number;
|
|
96
|
+
withHeaderRow?: boolean;
|
|
97
|
+
/** codeBlock */
|
|
98
|
+
language?: string | null;
|
|
99
|
+
/** insertEmbed */
|
|
100
|
+
provider?: string | null;
|
|
101
|
+
/** setListStyle: a CSS list-style-type, null = default */
|
|
102
|
+
style?: string | null;
|
|
103
|
+
/** setListStart */
|
|
104
|
+
start?: number;
|
|
105
|
+
/** setImageWidth: px, null = natural size */
|
|
106
|
+
width?: number | null;
|
|
107
|
+
/** lineHeight: unitless multiplier ('1.5'), null = default */
|
|
108
|
+
lineHeight?: string | null;
|
|
109
|
+
/** insertBookmark / insertMergeField: the anchor or field id */
|
|
110
|
+
id?: string;
|
|
111
|
+
/** changeCase: which transform to apply */
|
|
112
|
+
textCase?: 'upper' | 'lower' | 'title' | 'sentence';
|
|
113
|
+
/** insertMergeField: human-readable label */
|
|
114
|
+
label?: string | null;
|
|
115
|
+
/** insertMath: LaTeX source */
|
|
116
|
+
latex?: string;
|
|
117
|
+
/** insertMath: inline vs block presentation */
|
|
118
|
+
mathDisplay?: 'inline' | 'block';
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** Finds the extent of a mark around a resolved position (cursor in a link). */
|
|
122
|
+
export function getMarkRange(
|
|
123
|
+
$pos: ResolvedPos,
|
|
124
|
+
markType: MarkType
|
|
125
|
+
): { from: number; to: number } | null {
|
|
126
|
+
const { parent, parentOffset } = $pos;
|
|
127
|
+
const start = parent.childAfter(parentOffset);
|
|
128
|
+
if (!start.node || !markType.isInSet(start.node.marks)) return null;
|
|
129
|
+
|
|
130
|
+
let startIndex = start.index;
|
|
131
|
+
let from = $pos.start() + start.offset;
|
|
132
|
+
while (startIndex > 0 && markType.isInSet(parent.child(startIndex - 1).marks)) {
|
|
133
|
+
startIndex -= 1;
|
|
134
|
+
from -= parent.child(startIndex).nodeSize;
|
|
135
|
+
}
|
|
136
|
+
let endIndex = start.index + 1;
|
|
137
|
+
let to = from + start.node.nodeSize;
|
|
138
|
+
while (endIndex < parent.childCount && markType.isInSet(parent.child(endIndex).marks)) {
|
|
139
|
+
to += parent.child(endIndex).nodeSize;
|
|
140
|
+
endIndex += 1;
|
|
141
|
+
}
|
|
142
|
+
return { from, to };
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Sets (attrs given) or removes (attrs null) an attribute-carrying mark such
|
|
147
|
+
* as text color or font size. On an empty selection the mark is stored so it
|
|
148
|
+
* applies to the next typed text.
|
|
149
|
+
*/
|
|
150
|
+
function setAttrMark(markType: MarkType, attrs: Attrs | null): Command {
|
|
151
|
+
return (state, dispatch) => {
|
|
152
|
+
const { empty, ranges, $from } = state.selection;
|
|
153
|
+
if (empty && !(state.selection instanceof TextSelection && state.selection.$cursor)) {
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
if (!empty && !state.selection.content().content.firstChild) return false;
|
|
157
|
+
if (dispatch) {
|
|
158
|
+
const tr = state.tr;
|
|
159
|
+
if (empty) {
|
|
160
|
+
tr.removeStoredMark(markType);
|
|
161
|
+
if (attrs) tr.addStoredMark(markType.create(attrs));
|
|
162
|
+
} else {
|
|
163
|
+
for (const range of ranges) {
|
|
164
|
+
tr.removeMark(range.$from.pos, range.$to.pos, markType);
|
|
165
|
+
if (attrs) tr.addMark(range.$from.pos, range.$to.pos, markType.create(attrs));
|
|
166
|
+
}
|
|
167
|
+
tr.scrollIntoView();
|
|
168
|
+
}
|
|
169
|
+
dispatch(tr);
|
|
170
|
+
}
|
|
171
|
+
return true;
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** Applies a link mark over the selection, or over the link under the cursor. */
|
|
176
|
+
function setLink(markType: MarkType, attrs: CommandAttrs): Command {
|
|
177
|
+
return (state, dispatch) => {
|
|
178
|
+
if (!attrs.href) return false;
|
|
179
|
+
const { empty, $from, from, to } = state.selection;
|
|
180
|
+
let range = { from, to };
|
|
181
|
+
if (empty) {
|
|
182
|
+
const existing = getMarkRange($from, markType);
|
|
183
|
+
if (!existing) return false;
|
|
184
|
+
range = existing;
|
|
185
|
+
}
|
|
186
|
+
if (dispatch) {
|
|
187
|
+
const tr = state.tr;
|
|
188
|
+
tr.removeMark(range.from, range.to, markType);
|
|
189
|
+
tr.addMark(
|
|
190
|
+
range.from,
|
|
191
|
+
range.to,
|
|
192
|
+
markType.create({
|
|
193
|
+
href: attrs.href,
|
|
194
|
+
title: attrs.title ?? null,
|
|
195
|
+
target: attrs.target ?? null,
|
|
196
|
+
})
|
|
197
|
+
);
|
|
198
|
+
dispatch(tr.scrollIntoView());
|
|
199
|
+
}
|
|
200
|
+
return true;
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/** Removes the link mark from the selection or the link under the cursor. */
|
|
205
|
+
function unsetLink(markType: MarkType): Command {
|
|
206
|
+
return (state, dispatch) => {
|
|
207
|
+
const { empty, $from, from, to } = state.selection;
|
|
208
|
+
let range = { from, to };
|
|
209
|
+
if (empty) {
|
|
210
|
+
const existing = getMarkRange($from, markType);
|
|
211
|
+
if (!existing) return false;
|
|
212
|
+
range = existing;
|
|
213
|
+
} else if (!state.doc.rangeHasMark(from, to, markType)) {
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
if (dispatch) {
|
|
217
|
+
dispatch(state.tr.removeMark(range.from, range.to, markType));
|
|
218
|
+
}
|
|
219
|
+
return true;
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function findParentList(
|
|
224
|
+
state: EditorState
|
|
225
|
+
): { node: import('prosemirror-model').Node; pos: number; depth: number } | null {
|
|
226
|
+
const { $from } = state.selection;
|
|
227
|
+
const { bullet_list: bullet, ordered_list: ordered, task_list: task } = state.schema.nodes;
|
|
228
|
+
for (let depth = $from.depth; depth > 0; depth -= 1) {
|
|
229
|
+
const node = $from.node(depth);
|
|
230
|
+
if (node.type === bullet || node.type === ordered || node.type === task) {
|
|
231
|
+
return { node, pos: $from.before(depth), depth };
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return null;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/** The item node type a given list type expects as children. */
|
|
238
|
+
function itemTypeFor(listType: NodeType): NodeType {
|
|
239
|
+
const { schema } = listType;
|
|
240
|
+
return listType === schema.nodes.task_list
|
|
241
|
+
? schema.nodes.task_item
|
|
242
|
+
: schema.nodes.list_item;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Toggles a list: wraps when outside, lifts when already in the same list
|
|
247
|
+
* type, converts in place when in another list type. Conversion also remaps
|
|
248
|
+
* the item nodes (list_item <-> task_item) so the content stays valid.
|
|
249
|
+
*/
|
|
250
|
+
function toggleList(listType: NodeType, itemType: NodeType): Command {
|
|
251
|
+
return (state, dispatch, view) => {
|
|
252
|
+
const parentList = findParentList(state);
|
|
253
|
+
if (parentList) {
|
|
254
|
+
if (parentList.node.type === listType) {
|
|
255
|
+
return liftListItem(itemTypeFor(parentList.node.type))(state, dispatch, view);
|
|
256
|
+
}
|
|
257
|
+
if (dispatch) {
|
|
258
|
+
// Build the fully converted list and swap it in one step — converting
|
|
259
|
+
// the list node or its items separately fails content validation.
|
|
260
|
+
const fromItem = itemTypeFor(parentList.node.type);
|
|
261
|
+
const items: import('prosemirror-model').Node[] = [];
|
|
262
|
+
parentList.node.forEach(child => {
|
|
263
|
+
items.push(
|
|
264
|
+
child.type === fromItem && fromItem !== itemType
|
|
265
|
+
? itemType.create(null, child.content, child.marks)
|
|
266
|
+
: child
|
|
267
|
+
);
|
|
268
|
+
});
|
|
269
|
+
const converted = listType.create(parentList.node.attrs, items);
|
|
270
|
+
const tr = state.tr;
|
|
271
|
+
const { from, to } = state.selection;
|
|
272
|
+
tr.replaceWith(
|
|
273
|
+
parentList.pos,
|
|
274
|
+
parentList.pos + parentList.node.nodeSize,
|
|
275
|
+
converted
|
|
276
|
+
);
|
|
277
|
+
// Item node sizes are identical, so the old positions stay valid.
|
|
278
|
+
tr.setSelection(TextSelection.create(tr.doc, from, to));
|
|
279
|
+
dispatch(tr);
|
|
280
|
+
}
|
|
281
|
+
return true;
|
|
282
|
+
}
|
|
283
|
+
return wrapInList(listType)(state, dispatch, view);
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function isInNode(state: EditorState, type: NodeType): boolean {
|
|
288
|
+
const { $from } = state.selection;
|
|
289
|
+
for (let depth = $from.depth; depth > 0; depth -= 1) {
|
|
290
|
+
if ($from.node(depth).type === type) return true;
|
|
291
|
+
}
|
|
292
|
+
return false;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/** Wraps in blockquote, or lifts out when already inside one. */
|
|
296
|
+
function toggleBlockquote(type: NodeType): Command {
|
|
297
|
+
return (state, dispatch, view) => {
|
|
298
|
+
if (isInNode(state, type)) return lift(state, dispatch, view);
|
|
299
|
+
return wrapIn(type)(state, dispatch, view);
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/** Sets the `align` attribute on every textblock in the selection. */
|
|
304
|
+
function setAlignment(align: Alignment | null): Command {
|
|
305
|
+
return (state, dispatch) => {
|
|
306
|
+
const { from, to } = state.selection;
|
|
307
|
+
const targets: { pos: number; node: import('prosemirror-model').Node }[] = [];
|
|
308
|
+
state.doc.nodesBetween(from, to, (node, pos) => {
|
|
309
|
+
if (node.isTextblock && node.type.spec.attrs && 'align' in node.type.spec.attrs) {
|
|
310
|
+
targets.push({ pos, node });
|
|
311
|
+
}
|
|
312
|
+
return true;
|
|
313
|
+
});
|
|
314
|
+
if (targets.length === 0) return false;
|
|
315
|
+
if (dispatch) {
|
|
316
|
+
const tr = state.tr;
|
|
317
|
+
for (const { pos, node } of targets) {
|
|
318
|
+
tr.setNodeMarkup(pos, undefined, { ...node.attrs, align });
|
|
319
|
+
}
|
|
320
|
+
dispatch(tr);
|
|
321
|
+
}
|
|
322
|
+
return true;
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/** Sets the `lineHeight` attribute on every textblock in the selection. */
|
|
327
|
+
function setLineHeight(lineHeight: string | null): Command {
|
|
328
|
+
return (state, dispatch) => {
|
|
329
|
+
const { from, to } = state.selection;
|
|
330
|
+
const targets: { pos: number; node: PMNode }[] = [];
|
|
331
|
+
state.doc.nodesBetween(from, to, (node, pos) => {
|
|
332
|
+
if (node.isTextblock && node.type.spec.attrs && 'lineHeight' in node.type.spec.attrs) {
|
|
333
|
+
targets.push({ pos, node });
|
|
334
|
+
}
|
|
335
|
+
return true;
|
|
336
|
+
});
|
|
337
|
+
if (targets.length === 0) return false;
|
|
338
|
+
if (dispatch) {
|
|
339
|
+
const tr = state.tr;
|
|
340
|
+
for (const { pos, node } of targets) {
|
|
341
|
+
tr.setNodeMarkup(pos, undefined, { ...node.attrs, lineHeight });
|
|
342
|
+
}
|
|
343
|
+
dispatch(tr);
|
|
344
|
+
}
|
|
345
|
+
return true;
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/** Inserts a named in-text anchor (bookmark) at the selection. */
|
|
350
|
+
function insertBookmark(schema: Schema, attrs: CommandAttrs): Command {
|
|
351
|
+
return (state, dispatch) => {
|
|
352
|
+
const id = attrs.id?.trim();
|
|
353
|
+
if (!id) return false;
|
|
354
|
+
if (dispatch) {
|
|
355
|
+
const bookmark = schema.nodes.bookmark.create({ id });
|
|
356
|
+
dispatch(state.tr.replaceSelectionWith(bookmark, false).scrollIntoView());
|
|
357
|
+
}
|
|
358
|
+
return true;
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/** Toggles the surrounding table between content and layout (presentation) mode. */
|
|
363
|
+
function toggleLayoutTable(): Command {
|
|
364
|
+
return (state, dispatch) => {
|
|
365
|
+
const { $from } = state.selection;
|
|
366
|
+
for (let depth = $from.depth; depth > 0; depth -= 1) {
|
|
367
|
+
const node = $from.node(depth);
|
|
368
|
+
if (node.type === state.schema.nodes.table) {
|
|
369
|
+
if (dispatch) {
|
|
370
|
+
dispatch(
|
|
371
|
+
state.tr.setNodeMarkup($from.before(depth), undefined, {
|
|
372
|
+
...node.attrs,
|
|
373
|
+
layout: !node.attrs.layout,
|
|
374
|
+
})
|
|
375
|
+
);
|
|
376
|
+
}
|
|
377
|
+
return true;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
return false;
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
function insertHorizontalRule(type: NodeType): Command {
|
|
385
|
+
return (state, dispatch) => {
|
|
386
|
+
if (dispatch) {
|
|
387
|
+
dispatch(state.tr.replaceSelectionWith(type.create()).scrollIntoView());
|
|
388
|
+
}
|
|
389
|
+
return true;
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/** Toggles between code block and paragraph. */
|
|
394
|
+
function toggleCodeBlock(schema: Schema, language: string | null): Command {
|
|
395
|
+
return (state, dispatch, view) => {
|
|
396
|
+
const { $from } = state.selection;
|
|
397
|
+
if ($from.parent.type === schema.nodes.code_block) {
|
|
398
|
+
return setBlockType(schema.nodes.paragraph)(state, dispatch, view);
|
|
399
|
+
}
|
|
400
|
+
return setBlockType(schema.nodes.code_block, { language })(state, dispatch, view);
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/** Updates the language attr of the code block around the selection. */
|
|
405
|
+
function setCodeBlockLanguage(schema: Schema, language: string | null): Command {
|
|
406
|
+
return (state, dispatch) => {
|
|
407
|
+
const { $from } = state.selection;
|
|
408
|
+
for (let depth = $from.depth; depth > 0; depth -= 1) {
|
|
409
|
+
if ($from.node(depth).type === schema.nodes.code_block) {
|
|
410
|
+
if (dispatch) {
|
|
411
|
+
dispatch(
|
|
412
|
+
state.tr.setNodeMarkup($from.before(depth), undefined, { language })
|
|
413
|
+
);
|
|
414
|
+
}
|
|
415
|
+
return true;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
return false;
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/** Inserts a provider embed. The src must already be an embed URL. */
|
|
423
|
+
function insertEmbed(schema: Schema, attrs: CommandAttrs): Command {
|
|
424
|
+
return (state, dispatch) => {
|
|
425
|
+
if (!attrs.src) return false;
|
|
426
|
+
const embed = schema.nodes.embed.create({
|
|
427
|
+
src: attrs.src,
|
|
428
|
+
provider: attrs.provider ?? null,
|
|
429
|
+
title: attrs.title ?? null,
|
|
430
|
+
});
|
|
431
|
+
if (dispatch) {
|
|
432
|
+
dispatch(state.tr.replaceSelectionWith(embed).scrollIntoView());
|
|
433
|
+
}
|
|
434
|
+
return true;
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Inserts an image at the selection. With a non-empty caption it inserts a
|
|
440
|
+
* captioned `figure` (like the alt/caption flow in toggleImageCaption);
|
|
441
|
+
* otherwise a plain inline `image`.
|
|
442
|
+
*/
|
|
443
|
+
function insertImage(schema: Schema, attrs: CommandAttrs): Command {
|
|
444
|
+
return (state, dispatch) => {
|
|
445
|
+
if (!attrs.src) return false;
|
|
446
|
+
const src = attrs.src;
|
|
447
|
+
const alt = attrs.alt ?? null;
|
|
448
|
+
const title = attrs.title ?? null;
|
|
449
|
+
const caption = attrs.caption != null ? String(attrs.caption).trim() : '';
|
|
450
|
+
const node = caption
|
|
451
|
+
? schema.nodes.figure.create({ src, alt, title, width: null, align: null }, schema.text(caption))
|
|
452
|
+
: schema.nodes.image.create({ src, alt, title });
|
|
453
|
+
if (dispatch) {
|
|
454
|
+
dispatch(state.tr.replaceSelectionWith(node).scrollIntoView());
|
|
455
|
+
}
|
|
456
|
+
return true;
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* Updates the selected image/figure's src, alt and caption in place. A
|
|
462
|
+
* non-empty caption promotes an inline image to a captioned figure; an empty
|
|
463
|
+
* caption demotes a figure back to an inline image. Width/alignment are kept.
|
|
464
|
+
*/
|
|
465
|
+
function updateImage(schema: Schema, attrs: CommandAttrs): Command {
|
|
466
|
+
return (state, dispatch) => {
|
|
467
|
+
const info = selectedImageInfo(state);
|
|
468
|
+
if (!info || !attrs.src) return false;
|
|
469
|
+
const src = attrs.src;
|
|
470
|
+
const alt = attrs.alt ?? null;
|
|
471
|
+
const title = attrs.title ?? null;
|
|
472
|
+
const caption = attrs.caption != null ? String(attrs.caption).trim() : '';
|
|
473
|
+
const width = info.node.attrs.width ?? null;
|
|
474
|
+
const align = info.isFigure ? info.node.attrs.align ?? null : null;
|
|
475
|
+
if (dispatch) {
|
|
476
|
+
const tr = state.tr;
|
|
477
|
+
if (caption) {
|
|
478
|
+
const figure = schema.nodes.figure.create(
|
|
479
|
+
{ src, alt, title, width, align },
|
|
480
|
+
schema.text(caption)
|
|
481
|
+
);
|
|
482
|
+
if (info.isFigure) {
|
|
483
|
+
tr.replaceWith(info.pos, info.pos + info.node.nodeSize, figure);
|
|
484
|
+
tr.setSelection(NodeSelection.create(tr.doc, info.pos));
|
|
485
|
+
} else {
|
|
486
|
+
const $pos = state.doc.resolve(info.pos);
|
|
487
|
+
const parent = $pos.parent;
|
|
488
|
+
const replaceWhole = parent.childCount === 1 && parent.type.name === 'paragraph';
|
|
489
|
+
const from = replaceWhole ? $pos.before() : info.pos;
|
|
490
|
+
const to = replaceWhole ? $pos.after() : info.pos + info.node.nodeSize;
|
|
491
|
+
tr.replaceWith(from, to, figure);
|
|
492
|
+
tr.setSelection(NodeSelection.create(tr.doc, from));
|
|
493
|
+
}
|
|
494
|
+
} else if (info.isFigure) {
|
|
495
|
+
const image = schema.nodes.image.create({ src, alt, title, width });
|
|
496
|
+
tr.replaceWith(
|
|
497
|
+
info.pos,
|
|
498
|
+
info.pos + info.node.nodeSize,
|
|
499
|
+
schema.nodes.paragraph.create(null, image)
|
|
500
|
+
);
|
|
501
|
+
tr.setSelection(NodeSelection.create(tr.doc, info.pos + 1));
|
|
502
|
+
} else {
|
|
503
|
+
tr.setNodeMarkup(info.pos, undefined, { src, alt, title, width });
|
|
504
|
+
if (state.selection instanceof NodeSelection) {
|
|
505
|
+
tr.setSelection(NodeSelection.create(tr.doc, info.pos));
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
dispatch(tr.scrollIntoView());
|
|
509
|
+
}
|
|
510
|
+
return true;
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
/** Inserts an empty rows × cols table, optionally with a header row. */
|
|
515
|
+
function insertTable(schema: Schema, attrs: CommandAttrs): Command {
|
|
516
|
+
const rows = Math.max(1, attrs.rows ?? 3);
|
|
517
|
+
const cols = Math.max(1, attrs.cols ?? 3);
|
|
518
|
+
const withHeaderRow = attrs.withHeaderRow ?? true;
|
|
519
|
+
return (state, dispatch) => {
|
|
520
|
+
const { table, table_row: tableRow, table_cell: cell, table_header: header } =
|
|
521
|
+
schema.nodes;
|
|
522
|
+
const rowNodes = [];
|
|
523
|
+
for (let r = 0; r < rows; r += 1) {
|
|
524
|
+
const cellType = r === 0 && withHeaderRow ? header : cell;
|
|
525
|
+
const cells = [];
|
|
526
|
+
for (let c = 0; c < cols; c += 1) {
|
|
527
|
+
cells.push(cellType.createAndFill()!);
|
|
528
|
+
}
|
|
529
|
+
rowNodes.push(tableRow.create(null, cells));
|
|
530
|
+
}
|
|
531
|
+
if (dispatch) {
|
|
532
|
+
dispatch(state.tr.replaceSelectionWith(table.create(null, rowNodes)).scrollIntoView());
|
|
533
|
+
}
|
|
534
|
+
return true;
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
/**
|
|
539
|
+
* Adjusts the `indent` attr on textblocks in the selection by ±1 step.
|
|
540
|
+
* Returns false when nothing can change (e.g. outdent at level 0), letting
|
|
541
|
+
* chained commands (blockquote lift) take over.
|
|
542
|
+
*/
|
|
543
|
+
function changeBlockIndent(delta: number): Command {
|
|
544
|
+
return (state, dispatch) => {
|
|
545
|
+
const { from, to } = state.selection;
|
|
546
|
+
const targets: { pos: number; node: PMNode; next: number }[] = [];
|
|
547
|
+
state.doc.nodesBetween(from, to, (node, pos) => {
|
|
548
|
+
if (node.isTextblock && node.type.spec.attrs && 'indent' in node.type.spec.attrs) {
|
|
549
|
+
const current = (node.attrs.indent as number) ?? 0;
|
|
550
|
+
const next = Math.max(0, Math.min(MAX_INDENT, current + delta));
|
|
551
|
+
if (next !== current) targets.push({ pos, node, next });
|
|
552
|
+
}
|
|
553
|
+
return true;
|
|
554
|
+
});
|
|
555
|
+
if (targets.length === 0) return false;
|
|
556
|
+
if (dispatch) {
|
|
557
|
+
const tr = state.tr;
|
|
558
|
+
for (const { pos, node, next } of targets) {
|
|
559
|
+
tr.setNodeMarkup(pos, undefined, { ...node.attrs, indent: next });
|
|
560
|
+
}
|
|
561
|
+
dispatch(tr);
|
|
562
|
+
}
|
|
563
|
+
return true;
|
|
564
|
+
};
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
/** Sets the marker style (list-style-type) on the surrounding list. */
|
|
568
|
+
function setListStyle(style: string | null): Command {
|
|
569
|
+
return (state, dispatch) => {
|
|
570
|
+
const parentList = findParentList(state);
|
|
571
|
+
if (!parentList) return false;
|
|
572
|
+
let target = parentList;
|
|
573
|
+
// Multilevel (legal) numbering covers the whole tree from the outermost
|
|
574
|
+
// ordered list: apply it there, and clear it from wherever it sits.
|
|
575
|
+
const { $from } = state.selection;
|
|
576
|
+
const ordered = state.schema.nodes.ordered_list;
|
|
577
|
+
for (let depth = 1; depth <= $from.depth; depth += 1) {
|
|
578
|
+
const node = $from.node(depth);
|
|
579
|
+
if (
|
|
580
|
+
node.type === ordered &&
|
|
581
|
+
(style === MULTILEVEL_STYLE || node.attrs.style === MULTILEVEL_STYLE)
|
|
582
|
+
) {
|
|
583
|
+
target = { node, pos: $from.before(depth), depth };
|
|
584
|
+
break;
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
if (dispatch) {
|
|
588
|
+
dispatch(
|
|
589
|
+
state.tr.setNodeMarkup(target.pos, undefined, {
|
|
590
|
+
...target.node.attrs,
|
|
591
|
+
style,
|
|
592
|
+
})
|
|
593
|
+
);
|
|
594
|
+
}
|
|
595
|
+
return true;
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
/** Sets the start number of the surrounding ordered list. */
|
|
600
|
+
function setListStart(start: number): Command {
|
|
601
|
+
return (state, dispatch) => {
|
|
602
|
+
const parentList = findParentList(state);
|
|
603
|
+
if (!parentList || parentList.node.type !== state.schema.nodes.ordered_list) {
|
|
604
|
+
return false;
|
|
605
|
+
}
|
|
606
|
+
if (dispatch) {
|
|
607
|
+
dispatch(
|
|
608
|
+
state.tr.setNodeMarkup(parentList.pos, undefined, {
|
|
609
|
+
...parentList.node.attrs,
|
|
610
|
+
order: Math.max(1, Math.round(start)),
|
|
611
|
+
})
|
|
612
|
+
);
|
|
613
|
+
}
|
|
614
|
+
return true;
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
/**
|
|
619
|
+
* The image (inline `image` or block `figure`) the selection points at:
|
|
620
|
+
* a NodeSelection on either type, or a cursor inside a figure's caption.
|
|
621
|
+
*/
|
|
622
|
+
export function selectedImageInfo(
|
|
623
|
+
state: EditorState
|
|
624
|
+
): { node: PMNode; pos: number; isFigure: boolean } | null {
|
|
625
|
+
const { image, figure } = state.schema.nodes;
|
|
626
|
+
const sel = state.selection;
|
|
627
|
+
if (sel instanceof NodeSelection) {
|
|
628
|
+
if (sel.node.type === image) return { node: sel.node, pos: sel.from, isFigure: false };
|
|
629
|
+
if (sel.node.type === figure) return { node: sel.node, pos: sel.from, isFigure: true };
|
|
630
|
+
}
|
|
631
|
+
const { $from } = sel;
|
|
632
|
+
for (let depth = $from.depth; depth > 0; depth -= 1) {
|
|
633
|
+
if ($from.node(depth).type === figure) {
|
|
634
|
+
return { node: $from.node(depth), pos: $from.before(depth), isFigure: true };
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
return null;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
* Toggles the caption: inline image → figure (caption prefilled from alt,
|
|
642
|
+
* cursor placed inside), figure → plain inline image (caption dropped).
|
|
643
|
+
*/
|
|
644
|
+
function toggleImageCaption(schema: Schema): Command {
|
|
645
|
+
return (state, dispatch) => {
|
|
646
|
+
const info = selectedImageInfo(state);
|
|
647
|
+
if (!info) return false;
|
|
648
|
+
if (dispatch) {
|
|
649
|
+
const tr = state.tr;
|
|
650
|
+
if (info.isFigure) {
|
|
651
|
+
const { src, alt, title, width } = info.node.attrs;
|
|
652
|
+
const image = schema.nodes.image.create({ src, alt, title, width });
|
|
653
|
+
tr.replaceWith(
|
|
654
|
+
info.pos,
|
|
655
|
+
info.pos + info.node.nodeSize,
|
|
656
|
+
schema.nodes.paragraph.create(null, image)
|
|
657
|
+
);
|
|
658
|
+
tr.setSelection(NodeSelection.create(tr.doc, info.pos + 1));
|
|
659
|
+
} else {
|
|
660
|
+
const { src, alt, title, width } = info.node.attrs;
|
|
661
|
+
const caption = alt ? schema.text(alt) : null;
|
|
662
|
+
const figure = schema.nodes.figure.create(
|
|
663
|
+
{ src, alt, title, width, align: null },
|
|
664
|
+
caption
|
|
665
|
+
);
|
|
666
|
+
// An inline image sits inside a textblock; if it is the block's only
|
|
667
|
+
// child, replace the whole block, otherwise just the image.
|
|
668
|
+
const $pos = state.doc.resolve(info.pos);
|
|
669
|
+
const parent = $pos.parent;
|
|
670
|
+
const replaceWhole = parent.childCount === 1 && parent.type.name === 'paragraph';
|
|
671
|
+
const from = replaceWhole ? $pos.before() : info.pos;
|
|
672
|
+
const to = replaceWhole ? $pos.after() : info.pos + info.node.nodeSize;
|
|
673
|
+
tr.replaceWith(from, to, figure);
|
|
674
|
+
// Cursor into the caption (figure start + 1).
|
|
675
|
+
tr.setSelection(TextSelection.create(tr.doc, from + 1 + figure.content.size));
|
|
676
|
+
}
|
|
677
|
+
dispatch(tr.scrollIntoView());
|
|
678
|
+
}
|
|
679
|
+
return true;
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
/**
|
|
684
|
+
* Aligns the selected image. Inline images are promoted to a figure first,
|
|
685
|
+
* since alignment is a block concept.
|
|
686
|
+
*/
|
|
687
|
+
function setImageAlign(schema: Schema, align: string | null): Command {
|
|
688
|
+
return (state, dispatch) => {
|
|
689
|
+
const info = selectedImageInfo(state);
|
|
690
|
+
if (!info) return false;
|
|
691
|
+
const clamped =
|
|
692
|
+
align === 'left' || align === 'center' || align === 'right' ? align : null;
|
|
693
|
+
if (dispatch) {
|
|
694
|
+
const tr = state.tr;
|
|
695
|
+
if (info.isFigure) {
|
|
696
|
+
tr.setNodeMarkup(info.pos, undefined, { ...info.node.attrs, align: clamped });
|
|
697
|
+
if (state.selection instanceof NodeSelection) {
|
|
698
|
+
tr.setSelection(NodeSelection.create(tr.doc, info.pos));
|
|
699
|
+
}
|
|
700
|
+
} else {
|
|
701
|
+
const { src, alt, title, width } = info.node.attrs;
|
|
702
|
+
const figure = schema.nodes.figure.create({ src, alt, title, width, align: clamped });
|
|
703
|
+
const $pos = state.doc.resolve(info.pos);
|
|
704
|
+
const parent = $pos.parent;
|
|
705
|
+
const replaceWhole = parent.childCount === 1 && parent.type.name === 'paragraph';
|
|
706
|
+
const from = replaceWhole ? $pos.before() : info.pos;
|
|
707
|
+
const to = replaceWhole ? $pos.after() : info.pos + info.node.nodeSize;
|
|
708
|
+
tr.replaceWith(from, to, figure);
|
|
709
|
+
tr.setSelection(NodeSelection.create(tr.doc, from));
|
|
710
|
+
}
|
|
711
|
+
dispatch(tr.scrollIntoView());
|
|
712
|
+
}
|
|
713
|
+
return true;
|
|
714
|
+
};
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
/** Sets the display width (px) of the selected image or figure. */
|
|
718
|
+
function setImageWidth(width: number | null): Command {
|
|
719
|
+
return (state, dispatch) => {
|
|
720
|
+
const info = selectedImageInfo(state);
|
|
721
|
+
if (!info) return false;
|
|
722
|
+
if (dispatch) {
|
|
723
|
+
const tr = state.tr.setNodeMarkup(info.pos, undefined, {
|
|
724
|
+
...info.node.attrs,
|
|
725
|
+
width: width && width > 0 ? Math.round(width) : null,
|
|
726
|
+
});
|
|
727
|
+
// setNodeMarkup degrades a NodeSelection — restore it so follow-up
|
|
728
|
+
// image commands still see the node as selected.
|
|
729
|
+
if (state.selection instanceof NodeSelection) {
|
|
730
|
+
tr.setSelection(NodeSelection.create(tr.doc, info.pos));
|
|
731
|
+
}
|
|
732
|
+
dispatch(tr);
|
|
733
|
+
}
|
|
734
|
+
return true;
|
|
735
|
+
};
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
/** Deletes the selected image or the figure around the cursor. */
|
|
739
|
+
function deleteImage(): Command {
|
|
740
|
+
return (state, dispatch) => {
|
|
741
|
+
const info = selectedImageInfo(state);
|
|
742
|
+
if (!info) return false;
|
|
743
|
+
if (dispatch) {
|
|
744
|
+
dispatch(
|
|
745
|
+
state.tr.delete(info.pos, info.pos + info.node.nodeSize).scrollIntoView()
|
|
746
|
+
);
|
|
747
|
+
}
|
|
748
|
+
return true;
|
|
749
|
+
};
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
/** The selected embed node (a NodeSelection on an `embed`), or null. */
|
|
753
|
+
export function selectedEmbedInfo(
|
|
754
|
+
state: EditorState
|
|
755
|
+
): { node: PMNode; pos: number } | null {
|
|
756
|
+
const sel = state.selection;
|
|
757
|
+
if (sel instanceof NodeSelection && sel.node.type === state.schema.nodes.embed) {
|
|
758
|
+
return { node: sel.node, pos: sel.from };
|
|
759
|
+
}
|
|
760
|
+
return null;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
/** Aligns the selected video embed (left/center/right, or null to reset). */
|
|
764
|
+
function setEmbedAlign(align: string | null): Command {
|
|
765
|
+
return (state, dispatch) => {
|
|
766
|
+
const info = selectedEmbedInfo(state);
|
|
767
|
+
if (!info) return false;
|
|
768
|
+
const clamped =
|
|
769
|
+
align === 'left' || align === 'center' || align === 'right' ? align : null;
|
|
770
|
+
if (dispatch) {
|
|
771
|
+
const tr = state.tr.setNodeMarkup(info.pos, undefined, {
|
|
772
|
+
...info.node.attrs,
|
|
773
|
+
align: clamped,
|
|
774
|
+
});
|
|
775
|
+
// setNodeMarkup degrades a NodeSelection — restore it so follow-up
|
|
776
|
+
// align commands still see the embed as selected.
|
|
777
|
+
tr.setSelection(NodeSelection.create(tr.doc, info.pos));
|
|
778
|
+
dispatch(tr.scrollIntoView());
|
|
779
|
+
}
|
|
780
|
+
return true;
|
|
781
|
+
};
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
/** Deletes the selected video embed. */
|
|
785
|
+
function deleteEmbed(): Command {
|
|
786
|
+
return (state, dispatch) => {
|
|
787
|
+
const info = selectedEmbedInfo(state);
|
|
788
|
+
if (!info) return false;
|
|
789
|
+
if (dispatch) {
|
|
790
|
+
dispatch(state.tr.delete(info.pos, info.pos + info.node.nodeSize).scrollIntoView());
|
|
791
|
+
}
|
|
792
|
+
return true;
|
|
793
|
+
};
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
/** Strips all marks and stored marks from the selection. */
|
|
797
|
+
function clearFormatting(): Command {
|
|
798
|
+
return (state, dispatch) => {
|
|
799
|
+
const { from, to, empty } = state.selection;
|
|
800
|
+
if (dispatch) {
|
|
801
|
+
const tr = state.tr;
|
|
802
|
+
if (!empty) tr.removeMark(from, to, null);
|
|
803
|
+
tr.setStoredMarks([]);
|
|
804
|
+
// Also reset alignment and line height on touched textblocks.
|
|
805
|
+
state.doc.nodesBetween(from, to, (node, pos) => {
|
|
806
|
+
if (
|
|
807
|
+
node.isTextblock &&
|
|
808
|
+
node.type.spec.attrs &&
|
|
809
|
+
'align' in node.type.spec.attrs &&
|
|
810
|
+
(node.attrs.align || node.attrs.lineHeight)
|
|
811
|
+
) {
|
|
812
|
+
tr.setNodeMarkup(pos, undefined, { ...node.attrs, align: null, lineHeight: null });
|
|
813
|
+
}
|
|
814
|
+
return true;
|
|
815
|
+
});
|
|
816
|
+
dispatch(tr);
|
|
817
|
+
}
|
|
818
|
+
return true;
|
|
819
|
+
};
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
/** Transforms a string per the case mode. Title/sentence are word-aware. */
|
|
823
|
+
function transformCase(text: string, mode: 'upper' | 'lower' | 'title' | 'sentence'): string {
|
|
824
|
+
switch (mode) {
|
|
825
|
+
case 'upper':
|
|
826
|
+
return text.toUpperCase();
|
|
827
|
+
case 'lower':
|
|
828
|
+
return text.toLowerCase();
|
|
829
|
+
case 'title':
|
|
830
|
+
// Capitalize the first letter of each word run.
|
|
831
|
+
return text.toLowerCase().replace(/(^|\s)(\p{L})/gu, (_m, sep, ch) => sep + ch.toUpperCase());
|
|
832
|
+
case 'sentence':
|
|
833
|
+
// Capitalize the first letter after start or sentence-ending punctuation.
|
|
834
|
+
return text
|
|
835
|
+
.toLowerCase()
|
|
836
|
+
.replace(/(^|[.!?]\s+)(\p{L})/gu, (_m, sep, ch) => sep + ch.toUpperCase());
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
/**
|
|
841
|
+
* Changes the case of the selected text, preserving marks. No-op on an empty
|
|
842
|
+
* selection. Replacements run back-to-front so earlier positions stay valid.
|
|
843
|
+
*/
|
|
844
|
+
function changeCase(mode: 'upper' | 'lower' | 'title' | 'sentence'): Command {
|
|
845
|
+
return (state, dispatch) => {
|
|
846
|
+
const { from, to, empty } = state.selection;
|
|
847
|
+
if (empty) return false;
|
|
848
|
+
const edits: { from: number; to: number; text: string; marks: readonly Mark[] }[] = [];
|
|
849
|
+
state.doc.nodesBetween(from, to, (node, pos) => {
|
|
850
|
+
if (!node.isText || !node.text) return;
|
|
851
|
+
const start = Math.max(from, pos);
|
|
852
|
+
const end = Math.min(to, pos + node.nodeSize);
|
|
853
|
+
if (start >= end) return;
|
|
854
|
+
const slice = node.text.slice(start - pos, end - pos);
|
|
855
|
+
const next = transformCase(slice, mode);
|
|
856
|
+
if (next !== slice) edits.push({ from: start, to: end, text: next, marks: node.marks });
|
|
857
|
+
});
|
|
858
|
+
if (edits.length === 0) return false;
|
|
859
|
+
if (dispatch) {
|
|
860
|
+
const tr = state.tr;
|
|
861
|
+
for (const edit of edits.reverse()) {
|
|
862
|
+
tr.replaceWith(edit.from, edit.to, state.schema.text(edit.text, edit.marks));
|
|
863
|
+
}
|
|
864
|
+
dispatch(tr.scrollIntoView());
|
|
865
|
+
}
|
|
866
|
+
return true;
|
|
867
|
+
};
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
/** Inserts a merge-field atom at the selection. */
|
|
871
|
+
function insertMergeField(schema: Schema, attrs: CommandAttrs): Command {
|
|
872
|
+
return (state, dispatch) => {
|
|
873
|
+
const type = schema.nodes.merge_field;
|
|
874
|
+
if (!type || !attrs.id) return false;
|
|
875
|
+
if (dispatch) {
|
|
876
|
+
const node = type.create({ id: attrs.id, label: attrs.label ?? null });
|
|
877
|
+
dispatch(state.tr.replaceSelectionWith(node).scrollIntoView());
|
|
878
|
+
}
|
|
879
|
+
return true;
|
|
880
|
+
};
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
/** Inserts a math atom at the selection. */
|
|
884
|
+
function insertMath(schema: Schema, attrs: CommandAttrs): Command {
|
|
885
|
+
return (state, dispatch) => {
|
|
886
|
+
const type = schema.nodes.math;
|
|
887
|
+
const latex = (attrs.latex ?? '').trim();
|
|
888
|
+
if (!type || !latex) return false;
|
|
889
|
+
if (dispatch) {
|
|
890
|
+
const node = type.create({ latex, display: attrs.mathDisplay ?? 'inline' });
|
|
891
|
+
dispatch(state.tr.replaceSelectionWith(node).scrollIntoView());
|
|
892
|
+
}
|
|
893
|
+
return true;
|
|
894
|
+
};
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
/**
|
|
898
|
+
* Resolves a named command against a schema. Returns null for unknown names
|
|
899
|
+
* so callers can treat the registry as data.
|
|
900
|
+
*/
|
|
901
|
+
export function getCommand(
|
|
902
|
+
state: EditorState,
|
|
903
|
+
name: CommandName,
|
|
904
|
+
attrs: CommandAttrs = {}
|
|
905
|
+
): Command | null {
|
|
906
|
+
const { schema } = state;
|
|
907
|
+
const { nodes, marks } = schema;
|
|
908
|
+
switch (name) {
|
|
909
|
+
case 'bold':
|
|
910
|
+
return toggleMark(marks.bold);
|
|
911
|
+
case 'italic':
|
|
912
|
+
return toggleMark(marks.italic);
|
|
913
|
+
case 'underline':
|
|
914
|
+
return toggleMark(marks.underline);
|
|
915
|
+
case 'strike':
|
|
916
|
+
return toggleMark(marks.strike);
|
|
917
|
+
case 'subscript':
|
|
918
|
+
return toggleMark(marks.subscript);
|
|
919
|
+
case 'superscript':
|
|
920
|
+
return toggleMark(marks.superscript);
|
|
921
|
+
case 'code':
|
|
922
|
+
return toggleMark(marks.code);
|
|
923
|
+
case 'paragraph':
|
|
924
|
+
return setBlockType(nodes.paragraph);
|
|
925
|
+
case 'heading':
|
|
926
|
+
return setBlockType(nodes.heading, { level: attrs.level ?? 1 });
|
|
927
|
+
case 'blockquote':
|
|
928
|
+
return toggleBlockquote(nodes.blockquote);
|
|
929
|
+
case 'align':
|
|
930
|
+
return setAlignment(attrs.align ?? null);
|
|
931
|
+
case 'lineHeight':
|
|
932
|
+
return setLineHeight(attrs.lineHeight ?? null);
|
|
933
|
+
case 'bulletList':
|
|
934
|
+
return toggleList(nodes.bullet_list, nodes.list_item);
|
|
935
|
+
case 'orderedList':
|
|
936
|
+
return toggleList(nodes.ordered_list, nodes.list_item);
|
|
937
|
+
case 'taskList':
|
|
938
|
+
return toggleList(nodes.task_list, nodes.task_item);
|
|
939
|
+
case 'indent':
|
|
940
|
+
// List item sink first, then paragraph/heading margin indent.
|
|
941
|
+
return chainCommands(
|
|
942
|
+
sinkListItem(nodes.task_item),
|
|
943
|
+
sinkListItem(nodes.list_item),
|
|
944
|
+
changeBlockIndent(1)
|
|
945
|
+
);
|
|
946
|
+
case 'outdent':
|
|
947
|
+
// List lift, then margin outdent, then blockquote lift.
|
|
948
|
+
return chainCommands(
|
|
949
|
+
liftListItem(nodes.task_item),
|
|
950
|
+
liftListItem(nodes.list_item),
|
|
951
|
+
changeBlockIndent(-1),
|
|
952
|
+
lift
|
|
953
|
+
);
|
|
954
|
+
case 'setListStyle':
|
|
955
|
+
return setListStyle(attrs.style ?? null);
|
|
956
|
+
case 'setListStart':
|
|
957
|
+
return setListStart(attrs.start ?? 1);
|
|
958
|
+
case 'toggleImageCaption':
|
|
959
|
+
return toggleImageCaption(schema);
|
|
960
|
+
case 'setImageAlign':
|
|
961
|
+
return setImageAlign(schema, (attrs.align as string | null) ?? null);
|
|
962
|
+
case 'setImageWidth':
|
|
963
|
+
return setImageWidth(attrs.width ?? null);
|
|
964
|
+
case 'deleteImage':
|
|
965
|
+
return deleteImage();
|
|
966
|
+
case 'setEmbedAlign':
|
|
967
|
+
return setEmbedAlign((attrs.align as string | null) ?? null);
|
|
968
|
+
case 'deleteEmbed':
|
|
969
|
+
return deleteEmbed();
|
|
970
|
+
case 'link':
|
|
971
|
+
return setLink(marks.link, attrs);
|
|
972
|
+
case 'unlink':
|
|
973
|
+
return unsetLink(marks.link);
|
|
974
|
+
case 'insertBookmark':
|
|
975
|
+
return insertBookmark(schema, attrs);
|
|
976
|
+
case 'textColor':
|
|
977
|
+
return setAttrMark(marks.text_color, attrs.color ? { color: attrs.color } : null);
|
|
978
|
+
case 'bgColor':
|
|
979
|
+
return setAttrMark(marks.bg_color, attrs.color ? { color: attrs.color } : null);
|
|
980
|
+
case 'fontFamily':
|
|
981
|
+
return setAttrMark(marks.font_family, attrs.family ? { family: attrs.family } : null);
|
|
982
|
+
case 'fontSize':
|
|
983
|
+
return setAttrMark(marks.font_size, attrs.size ? { size: attrs.size } : null);
|
|
984
|
+
case 'horizontalRule':
|
|
985
|
+
return insertHorizontalRule(nodes.horizontal_rule);
|
|
986
|
+
case 'clearFormatting':
|
|
987
|
+
return clearFormatting();
|
|
988
|
+
case 'undo':
|
|
989
|
+
return undo;
|
|
990
|
+
case 'redo':
|
|
991
|
+
return redo;
|
|
992
|
+
case 'codeBlock':
|
|
993
|
+
return toggleCodeBlock(schema, attrs.language ?? null);
|
|
994
|
+
case 'setCodeBlockLanguage':
|
|
995
|
+
return setCodeBlockLanguage(schema, attrs.language ?? null);
|
|
996
|
+
case 'insertEmbed':
|
|
997
|
+
return insertEmbed(schema, attrs);
|
|
998
|
+
case 'insertImage':
|
|
999
|
+
return insertImage(schema, attrs);
|
|
1000
|
+
case 'updateImage':
|
|
1001
|
+
return updateImage(schema, attrs);
|
|
1002
|
+
case 'insertTable':
|
|
1003
|
+
return insertTable(schema, attrs);
|
|
1004
|
+
case 'addRowBefore':
|
|
1005
|
+
return addRowBefore;
|
|
1006
|
+
case 'addRowAfter':
|
|
1007
|
+
return addRowAfter;
|
|
1008
|
+
case 'addColumnBefore':
|
|
1009
|
+
return addColumnBefore;
|
|
1010
|
+
case 'addColumnAfter':
|
|
1011
|
+
return addColumnAfter;
|
|
1012
|
+
case 'deleteRow':
|
|
1013
|
+
return deleteRow;
|
|
1014
|
+
case 'deleteColumn':
|
|
1015
|
+
return deleteColumn;
|
|
1016
|
+
case 'mergeCells':
|
|
1017
|
+
return mergeCells;
|
|
1018
|
+
case 'splitCell':
|
|
1019
|
+
return splitCell;
|
|
1020
|
+
case 'toggleHeaderRow':
|
|
1021
|
+
return toggleHeaderRow;
|
|
1022
|
+
case 'toggleLayoutTable':
|
|
1023
|
+
return toggleLayoutTable();
|
|
1024
|
+
case 'deleteTable':
|
|
1025
|
+
return deleteTable;
|
|
1026
|
+
case 'changeCase':
|
|
1027
|
+
return changeCase(attrs.textCase ?? 'upper');
|
|
1028
|
+
case 'insertMergeField':
|
|
1029
|
+
return insertMergeField(schema, attrs);
|
|
1030
|
+
case 'insertMath':
|
|
1031
|
+
return insertMath(schema, attrs);
|
|
1032
|
+
default:
|
|
1033
|
+
return null;
|
|
1034
|
+
}
|
|
1035
|
+
}
|