@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 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.js","sourceRoot":"","sources":["../../../../src/nile-wysiwyg-editor/engine/markdown.ts"],"names":[],"mappings":"AASA,8EAA8E;AAC9E,SAAS,UAAU,CAAC,IAAY;IAC9B,OAAO,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;AACjD,CAAC;AAED,2EAA2E;AAC3E,SAAS,cAAc,CAAC,IAAY,EAAE,KAAsB;IAC1D,MAAM,GAAG,GAAG,CAAC,IAAY,EAAW,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IAC7E,IAAI,GAAW,CAAC;IAChB,IAAI,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;QAChB,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC;QAC9C,GAAG,GAAG,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,EAAE,CAAC;IAClC,CAAC;SAAM,CAAC;QACN,GAAG,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IACD,IAAI,GAAG,CAAC,WAAW,CAAC;QAAE,GAAG,GAAG,QAAQ,GAAG,Q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AAI,CAAC,CAAC,CAAC;QACpE,KAAK,WAAW;YACd,OAAO,iBAAiB,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACrC,KAAK,OAAO;YACV,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC;QAC9B,KAAK,OAAO;YACV,OAAO,IAAI,CAAC,KAAK,CAAC,GAAa,CAAC;QAClC;YACE,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAC9E,CAAC;AACH,CAAC;AAED,uDAAuD;AACvD,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,MAAM,IAAI,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;IACtE,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;AACjC,CAAC","sourcesContent":["/**\n * Document → Markdown projection. A best-effort, dependency-free serializer\n * covering the structural nodes and the marks Markdown can represent. Styling\n * marks with no Markdown equivalent (color, background, font family/size) are\n * dropped to plain text; underline/sub/sup fall back to inline HTML, which\n * GitHub-flavored Markdown renders. For loss-free round-trips use getHTML().\n */\nimport { Node as PMNode, Mark } from 'prosemirror-model';\n\n/** Escapes the inline characters that would otherwise be read as Markdown. */\nfunction escapeText(text: string): string {\n return text.replace(/([\\\\`*_[\\]<>])/g, '\\\\$1');\n}\n\n/** Wraps a text run in its marks, innermost (code) to outermost (link). */\nfunction serializeMarks(text: string, marks: readonly Mark[]): string {\n const has = (name: string): boolean => marks.some(m => m.type.name === name);\n let out: string;\n if (has('code')) {\n const ticks = text.includes('`') ? '``' : '`';\n out = `${ticks}${text}${ticks}`;\n } else {\n out = escapeText(text);\n }\n if (has('subscript')) out = `<sub>${out}</sub>`;\n if (has('superscript')) out = `<sup>${out}</sup>`;\n if (has('underline')) out = `<u>${out}</u>`;\n if (has('strike')) out = `~~${out}~~`;\n if (has('italic')) out = `*${out}*`;\n if (has('bold')) out = `**${out}**`;\n const link = marks.find(m => m.type.name === 'link');\n if (link) out = `[${out}](${link.attrs.href})`;\n return out;\n}\n\n/** Inline content of a textblock (text runs, breaks, images, mentions). */\nfunction serializeInline(node: PMNode): string {\n let result = '';\n node.forEach(child => {\n if (child.isText) {\n result += serializeMarks(child.text ?? '', child.marks);\n } else if (child.type.name === 'hard_break') {\n result += ' \\n';\n } else if (child.type.name === 'image') {\n result += ``;\n } else if (child.type.name === 'mention') {\n result += `${child.attrs.trigger}${child.attrs.label}`;\n }\n });\n return result;\n}\n\nfunction serializeChildren(node: PMNode): string {\n const parts: string[] = [];\n node.forEach(child => parts.push(serializeBlock(child)));\n return parts.join('\\n\\n');\n}\n\n/** One list item: first paragraph on the marker line, the rest indented. */\nfunction serializeListItem(item: PMNode, marker: string, indent: string): string {\n const contPad = indent + ' '.repeat(marker.length);\n const parts: string[] = [];\n item.forEach(child => {\n const name = child.type.name;\n if (name === 'bullet_list') {\n parts.push(serializeList(child, contPad, null));\n } else if (name === 'ordered_list') {\n parts.push(serializeList(child, contPad, child.attrs.order ?? 1));\n } else if (name === 'task_list') {\n parts.push(serializeTaskList(child, contPad));\n } else {\n parts.push(\n serializeBlock(child)\n .split('\\n')\n .map(line => contPad + line)\n .join('\\n')\n );\n }\n });\n // The first line was padded like a continuation; swap that pad for the\n // marker (same width, so nested content stays aligned).\n const body = parts.join('\\n');\n return indent + marker + body.slice(contPad.length);\n}\n\nfunction serializeList(list: PMNode, indent: string, startOrder: number | null): string {\n const lines: string[] = [];\n let order = startOrder ?? 1;\n list.forEach(item => {\n lines.push(serializeListItem(item, startOrder === null ? '- ' : `${order}. `, indent));\n order += 1;\n });\n return lines.join('\\n');\n}\n\nfunction serializeTaskList(list: PMNode, indent: string): string {\n const lines: string[] = [];\n list.forEach(item => {\n const box = item.attrs.checked ? '[x] ' : '[ ] ';\n lines.push(serializeListItem(item, `- ${box}`, indent));\n });\n return lines.join('\\n');\n}\n\n/** GitHub-flavored table. Cells use the first paragraph's inline text. */\nfunction serializeTable(table: PMNode): string {\n const rows: string[][] = [];\n table.forEach(row => {\n const cells: string[] = [];\n row.forEach(cell => {\n const text = cell.firstChild ? serializeInline(cell.firstChild) : '';\n cells.push(text.replace(/\\n/g, ' ').replace(/\\|/g, '\\\\|').trim());\n });\n rows.push(cells);\n });\n if (rows.length === 0) return '';\n const cols = Math.max(...rows.map(r => r.length));\n const pad = (r: string[]): string[] => {\n const copy = r.slice();\n while (copy.length < cols) copy.push('');\n return copy;\n };\n const fmt = (r: string[]): string => `| ${pad(r).join(' | ')} |`;\n return [\n fmt(rows[0]),\n fmt(new Array(cols).fill('---')),\n ...rows.slice(1).map(fmt),\n ].join('\\n');\n}\n\nfunction serializeBlock(node: PMNode): string {\n switch (node.type.name) {\n case 'paragraph':\n return serializeInline(node);\n case 'heading':\n return `${'#'.repeat(node.attrs.level as number)} ${serializeInline(node)}`;\n case 'blockquote':\n return serializeChildren(node)\n .split('\\n')\n .map(line => (line ? `> ${line}` : '>'))\n .join('\\n');\n case 'code_block':\n return `\\`\\`\\`${node.attrs.language ?? ''}\\n${node.textContent}\\n\\`\\`\\``;\n case 'horizontal_rule':\n return '---';\n case 'bullet_list':\n return serializeList(node, '', null);\n case 'ordered_list':\n return serializeList(node, '', (node.attrs.order as number) ?? 1);\n case 'task_list':\n return serializeTaskList(node, '');\n case 'table':\n return serializeTable(node);\n case 'embed':\n return node.attrs.src as string;\n default:\n return node.isTextblock ? serializeInline(node) : serializeChildren(node);\n }\n}\n\n/** Serializes a document node to a Markdown string. */\nexport function docToMarkdown(doc: PMNode): string {\n const body = serializeChildren(doc).replace(/\\n{3,}/g, '\\n\\n').trim();\n return body ? `${body}\\n` : '';\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Paste-from-Office cleanup. Word and Google Docs clipboard HTML carries
|
|
3
|
+
* heavy proprietary markup — conditional comments, o:/w:/v: namespaced tags,
|
|
4
|
+
* mso-* styles, and (in Word's case) lists faked as styled paragraphs. This
|
|
5
|
+
* pre-pass normalizes that into plain HTML *before* the sanitizer runs, so
|
|
6
|
+
* the schema receives real <ul>/<ol> structures instead of paragraph soup.
|
|
7
|
+
*/
|
|
8
|
+
/** Does this clipboard HTML come from Word, Outlook or Google Docs? */
|
|
9
|
+
export declare function isOfficeHtml(html: string): boolean;
|
|
10
|
+
/** Does this clipboard HTML come from Excel (or another spreadsheet)? */
|
|
11
|
+
export declare function isExcelHtml(html: string): boolean;
|
|
12
|
+
/** Normalizes Word/Google Docs clipboard HTML into plain semantic HTML. */
|
|
13
|
+
export declare function cleanOfficeHtml(html: string): string;
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Paste-from-Office cleanup. Word and Google Docs clipboard HTML carries
|
|
3
|
+
* heavy proprietary markup — conditional comments, o:/w:/v: namespaced tags,
|
|
4
|
+
* mso-* styles, and (in Word's case) lists faked as styled paragraphs. This
|
|
5
|
+
* pre-pass normalizes that into plain HTML *before* the sanitizer runs, so
|
|
6
|
+
* the schema receives real <ul>/<ol> structures instead of paragraph soup.
|
|
7
|
+
*/
|
|
8
|
+
/** Does this clipboard HTML come from Word, Outlook or Google Docs? */
|
|
9
|
+
export function isOfficeHtml(html) {
|
|
10
|
+
return (/class="?Mso|style=["'][^"']*mso-|urn:schemas-microsoft-com|<o:p>|<w:WordDocument/i.test(html) || /id="?docs-internal-guid/i.test(html));
|
|
11
|
+
}
|
|
12
|
+
/** Does this clipboard HTML come from Excel (or another spreadsheet)? */
|
|
13
|
+
export function isExcelHtml(html) {
|
|
14
|
+
return /urn:schemas-microsoft-com:office:excel|ProgId["']?[^>]*Excel\.Sheet|<x:ExcelWorkbook/i.test(html);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Excel clipboard tables carry cell formatting as `align`/`bgcolor` attributes
|
|
18
|
+
* and inline styles. The schema keeps a cell's background and a paragraph's
|
|
19
|
+
* alignment/fonts — so promote the cell's background to a style the cell node
|
|
20
|
+
* reads, and wrap bare cell text in a paragraph carrying the alignment.
|
|
21
|
+
*/
|
|
22
|
+
function convertExcelCells(body) {
|
|
23
|
+
const doc = body.ownerDocument;
|
|
24
|
+
for (const cell of Array.from(body.querySelectorAll('td, th'))) {
|
|
25
|
+
const bg = cell.getAttribute('bgcolor');
|
|
26
|
+
if (bg && !/background/i.test(cell.getAttribute('style') ?? '')) {
|
|
27
|
+
cell.style.backgroundColor = bg;
|
|
28
|
+
}
|
|
29
|
+
const align = cell.getAttribute('align') || cell.style.textAlign;
|
|
30
|
+
const hasBlock = cell.querySelector('p, div, ul, ol, table, h1, h2, h3, h4, h5, h6');
|
|
31
|
+
if (!hasBlock && cell.childNodes.length > 0) {
|
|
32
|
+
const p = doc.createElement('p');
|
|
33
|
+
if (align)
|
|
34
|
+
p.style.textAlign = align;
|
|
35
|
+
while (cell.firstChild)
|
|
36
|
+
p.appendChild(cell.firstChild);
|
|
37
|
+
cell.appendChild(p);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/** Word marks list paragraphs with an `mso-list: lX levelY` style. */
|
|
42
|
+
function wordListInfo(el) {
|
|
43
|
+
const style = el.getAttribute('style') ?? '';
|
|
44
|
+
const match = /mso-list:[^;"]*\blevel(\d+)/i.exec(style);
|
|
45
|
+
if (match)
|
|
46
|
+
return { level: Number(match[1]) };
|
|
47
|
+
// Some Word variants only set the class.
|
|
48
|
+
if (/\bMsoListParagraph/i.test(el.className) && /mso-list/i.test(style)) {
|
|
49
|
+
return { level: 1 };
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The bullet/number marker Word renders as a literal span. Ordered markers
|
|
55
|
+
* look like "1." / "a)" / "iv."; bullets are symbol characters (·, o, §).
|
|
56
|
+
*/
|
|
57
|
+
function extractWordMarker(paragraph) {
|
|
58
|
+
let ordered = false;
|
|
59
|
+
// The marker lives in a span with mso-list:Ignore (or inside the
|
|
60
|
+
// conditional comment we already stripped, leaving the bare text).
|
|
61
|
+
const spans = paragraph.querySelectorAll('span');
|
|
62
|
+
for (const span of Array.from(spans)) {
|
|
63
|
+
if (/mso-list:\s*ignore/i.test(span.getAttribute('style') ?? '')) {
|
|
64
|
+
ordered = /^\s*(\d+|[a-z]{1,4}|[ivxlc]+)[.)]/i.test(span.textContent ?? '');
|
|
65
|
+
span.remove();
|
|
66
|
+
return { ordered };
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// Fallback: leading "1." / "a)" text in the paragraph itself.
|
|
70
|
+
const text = paragraph.textContent ?? '';
|
|
71
|
+
const lead = /^\s*(\d+|[a-z])[.)]\s+/i.exec(text);
|
|
72
|
+
if (lead) {
|
|
73
|
+
ordered = true;
|
|
74
|
+
const first = paragraph.firstChild;
|
|
75
|
+
if (first?.nodeType === Node.TEXT_NODE) {
|
|
76
|
+
first.textContent = (first.textContent ?? '').replace(/^\s*\S+[.)]\s+/, '');
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return { ordered };
|
|
80
|
+
}
|
|
81
|
+
/** Converts consecutive Word list paragraphs into real nested ul/ol lists. */
|
|
82
|
+
function convertWordLists(body) {
|
|
83
|
+
const doc = body.ownerDocument;
|
|
84
|
+
const paragraphs = Array.from(body.querySelectorAll('p'));
|
|
85
|
+
let run = [];
|
|
86
|
+
const flush = () => {
|
|
87
|
+
if (run.length === 0)
|
|
88
|
+
return;
|
|
89
|
+
const anchor = run[0].paragraph;
|
|
90
|
+
// Build nested lists by level (Word levels start at 1).
|
|
91
|
+
const roots = [];
|
|
92
|
+
const stack = [];
|
|
93
|
+
for (const item of run) {
|
|
94
|
+
while (stack.length > 0 && stack[stack.length - 1].level > item.level) {
|
|
95
|
+
stack.pop();
|
|
96
|
+
}
|
|
97
|
+
if (stack.length === 0 || stack[stack.length - 1].level < item.level) {
|
|
98
|
+
const list = doc.createElement(item.ordered ? 'ol' : 'ul');
|
|
99
|
+
if (stack.length === 0) {
|
|
100
|
+
roots.push(list);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
const parentItems = stack[stack.length - 1].list.children;
|
|
104
|
+
const parentLi = parentItems[parentItems.length - 1] ?? null;
|
|
105
|
+
(parentLi ?? stack[stack.length - 1].list).appendChild(list);
|
|
106
|
+
}
|
|
107
|
+
stack.push({ level: item.level, list });
|
|
108
|
+
}
|
|
109
|
+
const li = doc.createElement('li');
|
|
110
|
+
const p = doc.createElement('p');
|
|
111
|
+
p.innerHTML = item.paragraph.innerHTML;
|
|
112
|
+
li.appendChild(p);
|
|
113
|
+
stack[stack.length - 1].list.appendChild(li);
|
|
114
|
+
}
|
|
115
|
+
anchor.before(...roots);
|
|
116
|
+
for (const item of run)
|
|
117
|
+
item.paragraph.remove();
|
|
118
|
+
run = [];
|
|
119
|
+
};
|
|
120
|
+
for (const paragraph of paragraphs) {
|
|
121
|
+
const info = wordListInfo(paragraph);
|
|
122
|
+
if (info) {
|
|
123
|
+
const { ordered } = extractWordMarker(paragraph);
|
|
124
|
+
run.push({ level: info.level, ordered, paragraph });
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
flush();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
flush();
|
|
131
|
+
}
|
|
132
|
+
/** Normalizes Word/Google Docs clipboard HTML into plain semantic HTML. */
|
|
133
|
+
export function cleanOfficeHtml(html) {
|
|
134
|
+
// Conditional comments carry list markers and VML — drop them first, while
|
|
135
|
+
// this is still a string ("<![if !supportLists]>…<![endif]>" variants too).
|
|
136
|
+
let cleaned = html
|
|
137
|
+
.replace(/<!--\[if[\s\S]*?<!\[endif\]-->/gi, '')
|
|
138
|
+
.replace(/<!\[if[\s\S]*?<!\[endif\]>/gi, '')
|
|
139
|
+
.replace(/<!--[\s\S]*?-->/g, '');
|
|
140
|
+
const doc = new DOMParser().parseFromString(cleaned, 'text/html');
|
|
141
|
+
const body = doc.body;
|
|
142
|
+
// Namespaced Office elements (<o:p>, <w:…>, <v:…>): unwrap, keeping text.
|
|
143
|
+
for (const el of Array.from(body.querySelectorAll('*'))) {
|
|
144
|
+
if (el.tagName.includes(':')) {
|
|
145
|
+
el.replaceWith(...Array.from(el.childNodes));
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
// Google Docs wraps the payload in <b id="docs-internal-guid-…"
|
|
149
|
+
// style="font-weight:normal"> — unwrap so nothing reads it as bold.
|
|
150
|
+
for (const el of Array.from(body.querySelectorAll('b[id^="docs-internal-guid"]'))) {
|
|
151
|
+
el.replaceWith(...Array.from(el.childNodes));
|
|
152
|
+
}
|
|
153
|
+
convertWordLists(body);
|
|
154
|
+
// Excel: preserve cell background and per-cell text alignment.
|
|
155
|
+
if (isExcelHtml(html))
|
|
156
|
+
convertExcelCells(body);
|
|
157
|
+
// Strip Mso classes and mso-* style declarations; the sanitizer would drop
|
|
158
|
+
// most of this anyway, but clearing it here keeps parsing predictable.
|
|
159
|
+
for (const el of Array.from(body.querySelectorAll('*'))) {
|
|
160
|
+
if (/\bMso/i.test(el.className))
|
|
161
|
+
el.removeAttribute('class');
|
|
162
|
+
const style = el.getAttribute('style');
|
|
163
|
+
if (style && /mso-/i.test(style)) {
|
|
164
|
+
const kept = style
|
|
165
|
+
.split(';')
|
|
166
|
+
.filter(decl => decl.trim() && !/^\s*mso-/i.test(decl))
|
|
167
|
+
.join(';');
|
|
168
|
+
if (kept.trim())
|
|
169
|
+
el.setAttribute('style', kept);
|
|
170
|
+
else
|
|
171
|
+
el.removeAttribute('style');
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
// Empty paragraphs Word uses for spacing (only inside).
|
|
175
|
+
for (const p of Array.from(body.querySelectorAll('p'))) {
|
|
176
|
+
if ((p.textContent ?? '').replace(/ /g, '').trim() === '' && !p.querySelector('img')) {
|
|
177
|
+
p.remove();
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return body.innerHTML;
|
|
181
|
+
}
|
|
182
|
+
//# sourceMappingURL=office-paste.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"office-paste.js","sourceRoot":"","sources":["../../../../src/nile-wysiwyg-editor/engine/office-paste.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,uEAAuE;AACvE,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,OAAO,CACL,mFAAmF,CAAC,IAAI,CACtF,IAAI,CACL,IAAI,0BAA0B,CAAC,IAAI,CAAC,IAAI,CAAC,CAC3C,CAAC;AACJ,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,OAAO,uFAAuF,CAAC,IAAI,CACjG,IAAI,CACL,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAS,iBAAiB,CAAC,IAAiB;IAC1C,MAAM,GAAG,GAAG,IAAI,CAAC,aAAa,CAAC;IAC/B,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAc,QAAQ,CAAC,CAAC,EAAE,CAAC;QAC5E,MAAM,EAAE,GAAG,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QACxC,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;YAChE,IAAI,CAAC,KAAK,CAAC,eAAe,GAAG,EAAE,CAAC;QAClC,CAAC;QACD,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC;QACjE,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,+CAA+C,CAAC,CAAC;QACrF,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,C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CAAC,IAAI,EAAE;gBAAE,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;;gBAC3C,EAAE,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;IAED,+DAA+D;IAC/D,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;QACvD,IAAI,CAAC,CAAC,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;YACrF,CAAC,CAAC,MAAM,EAAE,CAAC;QACb,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC,SAAS,CAAC;AACxB,CAAC","sourcesContent":["/**\n * Paste-from-Office cleanup. Word and Google Docs clipboard HTML carries\n * heavy proprietary markup — conditional comments, o:/w:/v: namespaced tags,\n * mso-* styles, and (in Word's case) lists faked as styled paragraphs. This\n * pre-pass normalizes that into plain HTML *before* the sanitizer runs, so\n * the schema receives real <ul>/<ol> structures instead of paragraph soup.\n */\n\n/** Does this clipboard HTML come from Word, Outlook or Google Docs? */\nexport function isOfficeHtml(html: string): boolean {\n return (\n /class=\"?Mso|style=[\"'][^\"']*mso-|urn:schemas-microsoft-com|<o:p>|<w:WordDocument/i.test(\n html\n ) || /id=\"?docs-internal-guid/i.test(html)\n );\n}\n\n/** Does this clipboard HTML come from Excel (or another spreadsheet)? */\nexport function isExcelHtml(html: string): boolean {\n return /urn:schemas-microsoft-com:office:excel|ProgId[\"']?[^>]*Excel\\.Sheet|<x:ExcelWorkbook/i.test(\n html\n );\n}\n\n/**\n * Excel clipboard tables carry cell formatting as `align`/`bgcolor` attributes\n * and inline styles. The schema keeps a cell's background and a paragraph's\n * alignment/fonts — so promote the cell's background to a style the cell node\n * reads, and wrap bare cell text in a paragraph carrying the alignment.\n */\nfunction convertExcelCells(body: HTMLElement): void {\n const doc = body.ownerDocument;\n for (const cell of Array.from(body.querySelectorAll<HTMLElement>('td, th'))) {\n const bg = cell.getAttribute('bgcolor');\n if (bg && !/background/i.test(cell.getAttribute('style') ?? '')) {\n cell.style.backgroundColor = bg;\n }\n const align = cell.getAttribute('align') || cell.style.textAlign;\n const hasBlock = cell.querySelector('p, div, ul, ol, table, h1, h2, h3, h4, h5, h6');\n if (!hasBlock && cell.childNodes.length > 0) {\n const p = doc.createElement('p');\n if (align) p.style.textAlign = align;\n while (cell.firstChild) p.appendChild(cell.firstChild);\n cell.appendChild(p);\n }\n }\n}\n\ninterface WordListItem {\n level: number;\n ordered: boolean;\n paragraph: HTMLElement;\n}\n\n/** Word marks list paragraphs with an `mso-list: lX levelY` style. */\nfunction wordListInfo(el: HTMLElement): { level: number } | null {\n const style = el.getAttribute('style') ?? '';\n const match = /mso-list:[^;\"]*\\blevel(\\d+)/i.exec(style);\n if (match) return { level: Number(match[1]) };\n // Some Word variants only set the class.\n if (/\\bMsoListParagraph/i.test(el.className) && /mso-list/i.test(style)) {\n return { level: 1 };\n }\n return null;\n}\n\n/**\n * The bullet/number marker Word renders as a literal span. Ordered markers\n * look like \"1.\" / \"a)\" / \"iv.\"; bullets are symbol characters (·, o, §).\n */\nfunction extractWordMarker(paragraph: HTMLElement): { ordered: boolean } {\n let ordered = false;\n // The marker lives in a span with mso-list:Ignore (or inside the\n // conditional comment we already stripped, leaving the bare text).\n const spans = paragraph.querySelectorAll('span');\n for (const span of Array.from(spans)) {\n if (/mso-list:\\s*ignore/i.test(span.getAttribute('style') ?? '')) {\n ordered = /^\\s*(\\d+|[a-z]{1,4}|[ivxlc]+)[.)]/i.test(span.textContent ?? '');\n span.remove();\n return { ordered };\n }\n }\n // Fallback: leading \"1.\" / \"a)\" text in the paragraph itself.\n const text = paragraph.textContent ?? '';\n const lead = /^\\s*(\\d+|[a-z])[.)]\\s+/i.exec(text);\n if (lead) {\n ordered = true;\n const first = paragraph.firstChild;\n if (first?.nodeType === Node.TEXT_NODE) {\n first.textContent = (first.textContent ?? '').replace(/^\\s*\\S+[.)]\\s+/, '');\n }\n }\n return { ordered };\n}\n\n/** Converts consecutive Word list paragraphs into real nested ul/ol lists. */\nfunction convertWordLists(body: HTMLElement): void {\n const doc = body.ownerDocument;\n const paragraphs = Array.from(body.querySelectorAll('p'));\n let run: WordListItem[] = [];\n\n const flush = (): void => {\n if (run.length === 0) return;\n const anchor = run[0].paragraph;\n // Build nested lists by level (Word levels start at 1).\n const roots: HTMLElement[] = [];\n const stack: { level: number; list: HTMLElement }[] = [];\n for (const item of run) {\n while (stack.length > 0 && stack[stack.length - 1].level > item.level) {\n stack.pop();\n }\n if (stack.length === 0 || stack[stack.length - 1].level < item.level) {\n const list = doc.createElement(item.ordered ? 'ol' : 'ul');\n if (stack.length === 0) {\n roots.push(list);\n } else {\n const parentItems = stack[stack.length - 1].list.children;\n const parentLi = parentItems[parentItems.length - 1] ?? null;\n (parentLi ?? stack[stack.length - 1].list).appendChild(list);\n }\n stack.push({ level: item.level, list });\n }\n const li = doc.createElement('li');\n const p = doc.createElement('p');\n p.innerHTML = item.paragraph.innerHTML;\n li.appendChild(p);\n stack[stack.length - 1].list.appendChild(li);\n }\n anchor.before(...roots);\n for (const item of run) item.paragraph.remove();\n run = [];\n };\n\n for (const paragraph of paragraphs) {\n const info = wordListInfo(paragraph);\n if (info) {\n const { ordered } = extractWordMarker(paragraph);\n run.push({ level: info.level, ordered, paragraph });\n } else {\n flush();\n }\n }\n flush();\n}\n\n/** Normalizes Word/Google Docs clipboard HTML into plain semantic HTML. */\nexport function cleanOfficeHtml(html: string): string {\n // Conditional comments carry list markers and VML — drop them first, while\n // this is still a string (\"<![if !supportLists]>…<![endif]>\" variants too).\n let cleaned = html\n .replace(/<!--\\[if[\\s\\S]*?<!\\[endif\\]-->/gi, '')\n .replace(/<!\\[if[\\s\\S]*?<!\\[endif\\]>/gi, '')\n .replace(/<!--[\\s\\S]*?-->/g, '');\n\n const doc = new DOMParser().parseFromString(cleaned, 'text/html');\n const body = doc.body;\n\n // Namespaced Office elements (<o:p>, <w:…>, <v:…>): unwrap, keeping text.\n for (const el of Array.from(body.querySelectorAll('*'))) {\n if (el.tagName.includes(':')) {\n el.replaceWith(...Array.from(el.childNodes));\n }\n }\n\n // Google Docs wraps the payload in <b id=\"docs-internal-guid-…\"\n // style=\"font-weight:normal\"> — unwrap so nothing reads it as bold.\n for (const el of Array.from(body.querySelectorAll('b[id^=\"docs-internal-guid\"]'))) {\n el.replaceWith(...Array.from(el.childNodes));\n }\n\n convertWordLists(body);\n\n // Excel: preserve cell background and per-cell text alignment.\n if (isExcelHtml(html)) convertExcelCells(body);\n\n // Strip Mso classes and mso-* style declarations; the sanitizer would drop\n // most of this anyway, but clearing it here keeps parsing predictable.\n for (const el of Array.from(body.querySelectorAll<HTMLElement>('*'))) {\n if (/\\bMso/i.test(el.className)) el.removeAttribute('class');\n const style = el.getAttribute('style');\n if (style && /mso-/i.test(style)) {\n const kept = style\n .split(';')\n .filter(decl => decl.trim() && !/^\\s*mso-/i.test(decl))\n .join(';');\n if (kept.trim()) el.setAttribute('style', kept);\n else el.removeAttribute('style');\n }\n }\n\n // Empty paragraphs Word uses for spacing (only inside).\n for (const p of Array.from(body.querySelectorAll('p'))) {\n if ((p.textContent ?? '').replace(/ /g, '').trim() === '' && !p.querySelector('img')) {\n p.remove();\n }\n }\n\n return body.innerHTML;\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Plugin, PluginKey } from 'prosemirror-state';
|
|
2
|
+
import { DecorationSet } from 'prosemirror-view';
|
|
3
|
+
export declare const codeHighlightKey: PluginKey<DecorationSet>;
|
|
4
|
+
/** Languages offered in the code block language picker. '' = auto-detect. */
|
|
5
|
+
export declare const CODE_LANGUAGES: {
|
|
6
|
+
value: string;
|
|
7
|
+
label: string;
|
|
8
|
+
}[];
|
|
9
|
+
/** Syntax highlighting for code blocks, recomputed on document changes. */
|
|
10
|
+
export declare function codeHighlightPlugin(): Plugin<DecorationSet>;
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { Plugin, PluginKey } from 'prosemirror-state';
|
|
2
|
+
import { Decoration, DecorationSet } from 'prosemirror-view';
|
|
3
|
+
import hljs from 'highlight.js/lib/core';
|
|
4
|
+
import javascript from 'highlight.js/lib/languages/javascript';
|
|
5
|
+
import typescript from 'highlight.js/lib/languages/typescript';
|
|
6
|
+
import json from 'highlight.js/lib/languages/json';
|
|
7
|
+
import xml from 'highlight.js/lib/languages/xml';
|
|
8
|
+
import css from 'highlight.js/lib/languages/css';
|
|
9
|
+
import scss from 'highlight.js/lib/languages/scss';
|
|
10
|
+
import sql from 'highlight.js/lib/languages/sql';
|
|
11
|
+
import python from 'highlight.js/lib/languages/python';
|
|
12
|
+
import java from 'highlight.js/lib/languages/java';
|
|
13
|
+
import bash from 'highlight.js/lib/languages/bash';
|
|
14
|
+
import shell from 'highlight.js/lib/languages/shell';
|
|
15
|
+
import markdown from 'highlight.js/lib/languages/markdown';
|
|
16
|
+
import plaintext from 'highlight.js/lib/languages/plaintext';
|
|
17
|
+
import c from 'highlight.js/lib/languages/c';
|
|
18
|
+
import cpp from 'highlight.js/lib/languages/cpp';
|
|
19
|
+
import csharp from 'highlight.js/lib/languages/csharp';
|
|
20
|
+
import go from 'highlight.js/lib/languages/go';
|
|
21
|
+
import rust from 'highlight.js/lib/languages/rust';
|
|
22
|
+
import php from 'highlight.js/lib/languages/php';
|
|
23
|
+
import ruby from 'highlight.js/lib/languages/ruby';
|
|
24
|
+
import kotlin from 'highlight.js/lib/languages/kotlin';
|
|
25
|
+
import swift from 'highlight.js/lib/languages/swift';
|
|
26
|
+
import yaml from 'highlight.js/lib/languages/yaml';
|
|
27
|
+
import dockerfile from 'highlight.js/lib/languages/dockerfile';
|
|
28
|
+
import diff from 'highlight.js/lib/languages/diff';
|
|
29
|
+
import graphql from 'highlight.js/lib/languages/graphql';
|
|
30
|
+
hljs.registerLanguage('javascript', javascript);
|
|
31
|
+
hljs.registerLanguage('typescript', typescript);
|
|
32
|
+
hljs.registerLanguage('json', json);
|
|
33
|
+
hljs.registerLanguage('xml', xml);
|
|
34
|
+
hljs.registerAliases(['html'], { languageName: 'xml' });
|
|
35
|
+
hljs.registerLanguage('css', css);
|
|
36
|
+
hljs.registerLanguage('scss', scss);
|
|
37
|
+
hljs.registerLanguage('sql', sql);
|
|
38
|
+
hljs.registerLanguage('python', python);
|
|
39
|
+
hljs.registerLanguage('java', java);
|
|
40
|
+
hljs.registerLanguage('bash', bash);
|
|
41
|
+
hljs.registerLanguage('shell', shell);
|
|
42
|
+
hljs.registerLanguage('markdown', markdown);
|
|
43
|
+
hljs.registerLanguage('plaintext', plaintext);
|
|
44
|
+
hljs.registerLanguage('c', c);
|
|
45
|
+
hljs.registerLanguage('cpp', cpp);
|
|
46
|
+
hljs.registerLanguage('csharp', csharp);
|
|
47
|
+
hljs.registerLanguage('go', go);
|
|
48
|
+
hljs.registerLanguage('rust', rust);
|
|
49
|
+
hljs.registerLanguage('php', php);
|
|
50
|
+
hljs.registerLanguage('ruby', ruby);
|
|
51
|
+
hljs.registerLanguage('kotlin', kotlin);
|
|
52
|
+
hljs.registerLanguage('swift', swift);
|
|
53
|
+
hljs.registerLanguage('yaml', yaml);
|
|
54
|
+
hljs.registerLanguage('dockerfile', dockerfile);
|
|
55
|
+
hljs.registerLanguage('diff', diff);
|
|
56
|
+
hljs.registerLanguage('graphql', graphql);
|
|
57
|
+
export const codeHighlightKey = new PluginKey('nileCodeHighlight');
|
|
58
|
+
/** Languages offered in the code block language picker. '' = auto-detect. */
|
|
59
|
+
export const CODE_LANGUAGES = [
|
|
60
|
+
{ value: '', label: 'Auto' },
|
|
61
|
+
{ value: 'plaintext', label: 'Plain text' },
|
|
62
|
+
{ value: 'javascript', label: 'JavaScript' },
|
|
63
|
+
{ value: 'typescript', label: 'TypeScript' },
|
|
64
|
+
{ value: 'json', label: 'JSON' },
|
|
65
|
+
{ value: 'html', label: 'HTML' },
|
|
66
|
+
{ value: 'css', label: 'CSS' },
|
|
67
|
+
{ value: 'scss', label: 'SCSS' },
|
|
68
|
+
{ value: 'sql', label: 'SQL' },
|
|
69
|
+
{ value: 'python', label: 'Python' },
|
|
70
|
+
{ value: 'java', label: 'Java' },
|
|
71
|
+
{ value: 'c', label: 'C' },
|
|
72
|
+
{ value: 'cpp', label: 'C++' },
|
|
73
|
+
{ value: 'csharp', label: 'C#' },
|
|
74
|
+
{ value: 'go', label: 'Go' },
|
|
75
|
+
{ value: 'rust', label: 'Rust' },
|
|
76
|
+
{ value: 'php', label: 'PHP' },
|
|
77
|
+
{ value: 'ruby', label: 'Ruby' },
|
|
78
|
+
{ value: 'kotlin', label: 'Kotlin' },
|
|
79
|
+
{ value: 'swift', label: 'Swift' },
|
|
80
|
+
{ value: 'bash', label: 'Bash' },
|
|
81
|
+
{ value: 'shell', label: 'Shell' },
|
|
82
|
+
{ value: 'yaml', label: 'YAML' },
|
|
83
|
+
{ value: 'dockerfile', label: 'Dockerfile' },
|
|
84
|
+
{ value: 'graphql', label: 'GraphQL' },
|
|
85
|
+
{ value: 'diff', label: 'Diff' },
|
|
86
|
+
{ value: 'markdown', label: 'Markdown' },
|
|
87
|
+
];
|
|
88
|
+
const AUTO_DETECT_SUBSET = [
|
|
89
|
+
'javascript', 'typescript', 'json', 'xml', 'css', 'sql', 'python', 'java',
|
|
90
|
+
'bash', 'go', 'rust', 'ruby',
|
|
91
|
+
];
|
|
92
|
+
const MAX_HIGHLIGHT_LENGTH = 20000;
|
|
93
|
+
/**
|
|
94
|
+
* Converts highlight.js' emitted HTML into inline decorations. hljs escapes
|
|
95
|
+
* but never reorders text, so parsed text offsets map 1:1 onto the node.
|
|
96
|
+
*/
|
|
97
|
+
function decorationsForCode(text, language, base) {
|
|
98
|
+
if (!text || text.length > MAX_HIGHLIGHT_LENGTH)
|
|
99
|
+
return [];
|
|
100
|
+
let value;
|
|
101
|
+
try {
|
|
102
|
+
if (language && hljs.getLanguage(language)) {
|
|
103
|
+
value = hljs.highlight(text, { language }).value;
|
|
104
|
+
}
|
|
105
|
+
else if (language === 'plaintext') {
|
|
106
|
+
return [];
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
value = hljs.highlightAuto(text, AUTO_DETECT_SUBSET).value;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
return [];
|
|
114
|
+
}
|
|
115
|
+
const template = document.createElement('template');
|
|
116
|
+
template.innerHTML = value;
|
|
117
|
+
const decorations = [];
|
|
118
|
+
let offset = 0;
|
|
119
|
+
const walk = (node, classes) => {
|
|
120
|
+
node.childNodes.forEach(child => {
|
|
121
|
+
if (child.nodeType === 3) {
|
|
122
|
+
const length = child.nodeValue?.length ?? 0;
|
|
123
|
+
if (classes.length && length) {
|
|
124
|
+
decorations.push(Decoration.inline(base + offset, base + offset + length, {
|
|
125
|
+
class: classes.join(' '),
|
|
126
|
+
}));
|
|
127
|
+
}
|
|
128
|
+
offset += length;
|
|
129
|
+
}
|
|
130
|
+
else if (child.nodeType === 1) {
|
|
131
|
+
const el = child;
|
|
132
|
+
walk(el, [...classes, ...el.className.split(/\s+/).filter(Boolean)]);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
walk(template.content, []);
|
|
137
|
+
return decorations;
|
|
138
|
+
}
|
|
139
|
+
function buildDecorations(doc) {
|
|
140
|
+
const decorations = [];
|
|
141
|
+
doc.descendants((node, pos) => {
|
|
142
|
+
if (node.type.name === 'code_block') {
|
|
143
|
+
decorations.push(...decorationsForCode(node.textContent, node.attrs.language, pos + 1));
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
return true;
|
|
147
|
+
});
|
|
148
|
+
return decorations.length ? DecorationSet.create(doc, decorations) : DecorationSet.empty;
|
|
149
|
+
}
|
|
150
|
+
/** Syntax highlighting for code blocks, recomputed on document changes. */
|
|
151
|
+
export function codeHighlightPlugin() {
|
|
152
|
+
return new Plugin({
|
|
153
|
+
key: codeHighlightKey,
|
|
154
|
+
state: {
|
|
155
|
+
init: (_config, state) => buildDecorations(state.doc),
|
|
156
|
+
apply: (tr, old) => (tr.docChanged ? buildDecorations(tr.doc) : old),
|
|
157
|
+
},
|
|
158
|
+
props: {
|
|
159
|
+
decorations(state) {
|
|
160
|
+
return codeHighlightKey.getState(state);
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=code-highlight.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-highlight.js","sourceRoot":"","sources":["../../../../../src/nile-wysiwyg-editor/engine/plugins/code-highlight.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAE7D,OAAO,IAAI,MAAM,uBAAuB,CAAC;AACzC,OAAO,UAAU,MAAM,uCAAuC,CAAC;AAC/D,OAAO,UAAU,MAAM,uCAAuC,CAAC;AAC/D,OAAO,IAAI,MAAM,iCAAiC,CAAC;AACnD,OAAO,GAAG,MAAM,gCAAgC,CAAC;AACjD,OAAO,GAAG,MAAM,gCAAgC,CAAC;AACjD,OAAO,IAAI,MAAM,iCAAiC,CAAC;AACnD,OAAO,GAAG,MAAM,gCAAgC,CAAC;AACjD,OAAO,MAAM,MAAM,mCAAmC,CAAC;AACvD,OAAO,IAAI,MAAM,iCAAiC,CAAC;AACnD,OAAO,IAAI,MAAM,iCAAiC,CAAC;AACnD,OAAO,KAAK,MAAM,kCAAkC,CAAC;AACrD,OAAO,QAAQ,MAAM,qCAAqC,CAAC;AAC3D,OAAO,SAAS,MAAM,sCAAsC,CAAC;AAC7D,OAAO,CAAC,MAAM,8BAA8B,CAAC;AAC7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,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;YACpC,WAAW,CAAC,IAAI,CACd,GAAG,kBAAkB,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,GAAG,CAAC,CAAC,CACtE,CAAC;YACF,OAAO,KAAK,CAAC;QACf,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;IACH,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC;AAC3F,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,mBAAmB;IACjC,OAAO,IAAI,MAAM,CAAgB;QAC/B,GAAG,EAAE,gBAAgB;QACrB,KAAK,EAAE;YACL,IAAI,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC;YACrD,KAAK,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,gBAAgB,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;SACrE;QACD,KAAK,EAAE;YACL,WAAW,CAAC,KAAK;gBACf,OAAO,gBAAgB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YAC1C,CAAC;SACF;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { Plugin, PluginKey } from 'prosemirror-state';\nimport { Decoration, DecorationSet } from 'prosemirror-view';\nimport { Node as PMNode } from 'prosemirror-model';\nimport hljs from 'highlight.js/lib/core';\nimport javascript from 'highlight.js/lib/languages/javascript';\nimport typescript from 'highlight.js/lib/languages/typescript';\nimport json from 'highlight.js/lib/languages/json';\nimport xml from 'highlight.js/lib/languages/xml';\nimport css from 'highlight.js/lib/languages/css';\nimport scss from 'highlight.js/lib/languages/scss';\nimport sql from 'highlight.js/lib/languages/sql';\nimport python from 'highlight.js/lib/languages/python';\nimport java from 'highlight.js/lib/languages/java';\nimport bash from 'highlight.js/lib/languages/bash';\nimport shell from 'highlight.js/lib/languages/shell';\nimport markdown from 'highlight.js/lib/languages/markdown';\nimport plaintext from 'highlight.js/lib/languages/plaintext';\nimport c from 'highlight.js/lib/languages/c';\nimport cpp from 'highlight.js/lib/languages/cpp';\nimport csharp from 'highlight.js/lib/languages/csharp';\nimport go from 'highlight.js/lib/languages/go';\nimport rust from 'highlight.js/lib/languages/rust';\nimport php from 'highlight.js/lib/languages/php';\nimport ruby from 'highlight.js/lib/languages/ruby';\nimport kotlin from 'highlight.js/lib/languages/kotlin';\nimport swift from 'highlight.js/lib/languages/swift';\nimport yaml from 'highlight.js/lib/languages/yaml';\nimport dockerfile from 'highlight.js/lib/languages/dockerfile';\nimport diff from 'highlight.js/lib/languages/diff';\nimport graphql from 'highlight.js/lib/languages/graphql';\n\nhljs.registerLanguage('javascript', javascript);\nhljs.registerLanguage('typescript', typescript);\nhljs.registerLanguage('json', json);\nhljs.registerLanguage('xml', xml);\nhljs.registerAliases(['html'], { languageName: 'xml' });\nhljs.registerLanguage('css', css);\nhljs.registerLanguage('scss', scss);\nhljs.registerLanguage('sql', sql);\nhljs.registerLanguage('python', python);\nhljs.registerLanguage('java', java);\nhljs.registerLanguage('bash', bash);\nhljs.registerLanguage('shell', shell);\nhljs.registerLanguage('markdown', markdown);\nhljs.registerLanguage('plaintext', plaintext);\nhljs.registerLanguage('c', c);\nhljs.registerLanguage('cpp', cpp);\nhljs.registerLanguage('csharp', csharp);\nhljs.registerLanguage('go', go);\nhljs.registerLanguage('rust', rust);\nhljs.registerLanguage('php', php);\nhljs.registerLanguage('ruby', ruby);\nhljs.registerLanguage('kotlin', kotlin);\nhljs.registerLanguage('swift', swift);\nhljs.registerLanguage('yaml', yaml);\nhljs.registerLanguage('dockerfile', dockerfile);\nhljs.registerLanguage('diff', diff);\nhljs.registerLanguage('graphql', graphql);\n\nexport const codeHighlightKey = new PluginKey<DecorationSet>('nileCodeHighlight');\n\n/** Languages offered in the code block language picker. '' = auto-detect. */\nexport const CODE_LANGUAGES: { value: string; label: string }[] = [\n { value: '', label: 'Auto' },\n { value: 'plaintext', label: 'Plain text' },\n { value: 'javascript', label: 'JavaScript' },\n { value: 'typescript', label: 'TypeScript' },\n { value: 'json', label: 'JSON' },\n { value: 'html', label: 'HTML' },\n { value: 'css', label: 'CSS' },\n { value: 'scss', label: 'SCSS' },\n { value: 'sql', label: 'SQL' },\n { value: 'python', label: 'Python' },\n { value: 'java', label: 'Java' },\n { value: 'c', label: 'C' },\n { value: 'cpp', label: 'C++' },\n { value: 'csharp', label: 'C#' },\n { value: 'go', label: 'Go' },\n { value: 'rust', label: 'Rust' },\n { value: 'php', label: 'PHP' },\n { value: 'ruby', label: 'Ruby' },\n { value: 'kotlin', label: 'Kotlin' },\n { value: 'swift', label: 'Swift' },\n { value: 'bash', label: 'Bash' },\n { value: 'shell', label: 'Shell' },\n { value: 'yaml', label: 'YAML' },\n { value: 'dockerfile', label: 'Dockerfile' },\n { value: 'graphql', label: 'GraphQL' },\n { value: 'diff', label: 'Diff' },\n { value: 'markdown', label: 'Markdown' },\n];\n\nconst AUTO_DETECT_SUBSET = [\n 'javascript', 'typescript', 'json', 'xml', 'css', 'sql', 'python', 'java',\n 'bash', 'go', 'rust', 'ruby',\n];\n\nconst MAX_HIGHLIGHT_LENGTH = 20000;\n\n/**\n * Converts highlight.js' emitted HTML into inline decorations. hljs escapes\n * but never reorders text, so parsed text offsets map 1:1 onto the node.\n */\nfunction decorationsForCode(text: string, language: string | null, base: number): Decoration[] {\n if (!text || text.length > MAX_HIGHLIGHT_LENGTH) return [];\n let value: string;\n try {\n if (language && hljs.getLanguage(language)) {\n value = hljs.highlight(text, { language }).value;\n } else if (language === 'plaintext') {\n return [];\n } else {\n value = hljs.highlightAuto(text, AUTO_DETECT_SUBSET).value;\n }\n } catch {\n return [];\n }\n\n const template = document.createElement('template');\n template.innerHTML = value;\n const decorations: Decoration[] = [];\n let offset = 0;\n const walk = (node: globalThis.Node, classes: string[]): void => {\n node.childNodes.forEach(child => {\n if (child.nodeType === 3) {\n const length = child.nodeValue?.length ?? 0;\n if (classes.length && length) {\n decorations.push(\n Decoration.inline(base + offset, base + offset + length, {\n class: classes.join(' '),\n })\n );\n }\n offset += length;\n } else if (child.nodeType === 1) {\n const el = child as Element;\n walk(el, [...classes, ...el.className.split(/\\s+/).filter(Boolean)]);\n }\n });\n };\n walk(template.content, []);\n return decorations;\n}\n\nfunction buildDecorations(doc: PMNode): DecorationSet {\n const decorations: Decoration[] = [];\n doc.descendants((node, pos) => {\n if (node.type.name === 'code_block') {\n decorations.push(\n ...decorationsForCode(node.textContent, node.attrs.language, pos + 1)\n );\n return false;\n }\n return true;\n });\n return decorations.length ? DecorationSet.create(doc, decorations) : DecorationSet.empty;\n}\n\n/** Syntax highlighting for code blocks, recomputed on document changes. */\nexport function codeHighlightPlugin(): Plugin<DecorationSet> {\n return new Plugin<DecorationSet>({\n key: codeHighlightKey,\n state: {\n init: (_config, state) => buildDecorations(state.doc),\n apply: (tr, old) => (tr.docChanged ? buildDecorations(tr.doc) : old),\n },\n props: {\n decorations(state) {\n return codeHighlightKey.getState(state);\n },\n },\n });\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Node as PMNode } from 'prosemirror-model';
|
|
2
|
+
import { EditorView, NodeView } from 'prosemirror-view';
|
|
3
|
+
/**
|
|
4
|
+
* Video embed (YouTube/Vimeo/Loom) with the same corner drag-resize handles
|
|
5
|
+
* as images. Only the width is dragged; the 16:9 aspect ratio comes from CSS,
|
|
6
|
+
* so the height follows automatically.
|
|
7
|
+
*/
|
|
8
|
+
export declare class EmbedView implements NodeView {
|
|
9
|
+
private node;
|
|
10
|
+
dom: HTMLDivElement;
|
|
11
|
+
private iframe;
|
|
12
|
+
constructor(node: PMNode, view: EditorView, getPos: () => number | undefined);
|
|
13
|
+
private applyAttrs;
|
|
14
|
+
update(node: PMNode): boolean;
|
|
15
|
+
stopEvent(event: Event): boolean;
|
|
16
|
+
ignoreMutation(): boolean;
|
|
17
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { attachResizeHandles, isResizeEvent } from './image-view';
|
|
2
|
+
/** Below this a 16:9 player is unusable and its own controls stop fitting. */
|
|
3
|
+
const MIN_EMBED_WIDTH = 160;
|
|
4
|
+
/**
|
|
5
|
+
* Video embed (YouTube/Vimeo/Loom) with the same corner drag-resize handles
|
|
6
|
+
* as images. Only the width is dragged; the 16:9 aspect ratio comes from CSS,
|
|
7
|
+
* so the height follows automatically.
|
|
8
|
+
*/
|
|
9
|
+
export class EmbedView {
|
|
10
|
+
constructor(node, view, getPos) {
|
|
11
|
+
this.node = node;
|
|
12
|
+
this.dom = document.createElement('div');
|
|
13
|
+
this.dom.className = 'nile-wysiwyg__embed';
|
|
14
|
+
this.iframe = document.createElement('iframe');
|
|
15
|
+
this.iframe.setAttribute('frameborder', '0');
|
|
16
|
+
this.iframe.setAttribute('allowfullscreen', 'true');
|
|
17
|
+
this.iframe.setAttribute('allow', 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture');
|
|
18
|
+
this.dom.appendChild(this.iframe);
|
|
19
|
+
this.applyAttrs(node);
|
|
20
|
+
attachResizeHandles(this.dom, this.dom, width => {
|
|
21
|
+
const pos = getPos();
|
|
22
|
+
if (pos === undefined || !view.editable)
|
|
23
|
+
return;
|
|
24
|
+
const current = view.state.doc.nodeAt(pos);
|
|
25
|
+
if (!current)
|
|
26
|
+
return;
|
|
27
|
+
view.dispatch(view.state.tr.setNodeMarkup(pos, undefined, { ...current.attrs, width }));
|
|
28
|
+
}, MIN_EMBED_WIDTH);
|
|
29
|
+
}
|
|
30
|
+
applyAttrs(node) {
|
|
31
|
+
const { src, provider, title, width, align } = node.attrs;
|
|
32
|
+
if (this.iframe.getAttribute('src') !== src)
|
|
33
|
+
this.iframe.setAttribute('src', src);
|
|
34
|
+
this.dom.setAttribute('data-embed-provider', provider ?? 'generic');
|
|
35
|
+
if (title)
|
|
36
|
+
this.iframe.title = title;
|
|
37
|
+
else
|
|
38
|
+
this.iframe.removeAttribute('title');
|
|
39
|
+
if (width) {
|
|
40
|
+
this.dom.setAttribute('data-width', String(width));
|
|
41
|
+
this.dom.style.width = `${width}px`;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
this.dom.removeAttribute('data-width');
|
|
45
|
+
this.dom.style.width = '';
|
|
46
|
+
}
|
|
47
|
+
// Block alignment via auto margins (mirrors the image figure).
|
|
48
|
+
if (align)
|
|
49
|
+
this.dom.setAttribute('data-align', align);
|
|
50
|
+
else
|
|
51
|
+
this.dom.removeAttribute('data-align');
|
|
52
|
+
this.dom.style.marginLeft = align === 'center' || align === 'right' ? 'auto' : '';
|
|
53
|
+
this.dom.style.marginRight = align === 'center' ? 'auto' : '';
|
|
54
|
+
}
|
|
55
|
+
update(node) {
|
|
56
|
+
if (node.type !== this.node.type)
|
|
57
|
+
return false;
|
|
58
|
+
this.node = node;
|
|
59
|
+
this.applyAttrs(node);
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
stopEvent(event) {
|
|
63
|
+
return isResizeEvent(event);
|
|
64
|
+
}
|
|
65
|
+
ignoreMutation() {
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=embed-view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embed-view.js","sourceRoot":"","sources":["../../../../../src/nile-wysiwyg-editor/engine/plugins/embed-view.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElE,8EAA8E;AAC9E,MAAM,eAAe,GAAG,GAAG,CAAC;AAE5B;;;;GAIG;AACH,MAAM,OAAO,SAAS;IAKpB,YACU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,CAAC;IAChE,CAAC;IAED,MAAM,CAAC,IAAY;QACjB,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC,IAAI;YAAE,OAAO,KAAK,CAAC;QAC/C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,SAAS,CAAC,KAAY;QACpB,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["import { Node as PMNode } from 'prosemirror-model';\nimport { EditorView, NodeView } from 'prosemirror-view';\nimport { attachResizeHandles, isResizeEvent } from './image-view';\n\n/** Below this a 16:9 player is unusable and its own controls stop fitting. */\nconst MIN_EMBED_WIDTH = 160;\n\n/**\n * Video embed (YouTube/Vimeo/Loom) with the same corner drag-resize handles\n * as images. Only the width is dragged; the 16:9 aspect ratio comes from CSS,\n * so the height follows automatically.\n */\nexport class EmbedView implements NodeView {\n dom: HTMLDivElement;\n\n private iframe: HTMLIFrameElement;\n\n constructor(\n private node: PMNode,\n view: EditorView,\n getPos: () => number | undefined\n ) {\n this.dom = document.createElement('div');\n this.dom.className = 'nile-wysiwyg__embed';\n this.iframe = document.createElement('iframe');\n this.iframe.setAttribute('frameborder', '0');\n this.iframe.setAttribute('allowfullscreen', 'true');\n this.iframe.setAttribute(\n 'allow',\n 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture'\n );\n this.dom.appendChild(this.iframe);\n this.applyAttrs(node);\n\n attachResizeHandles(\n this.dom,\n this.dom,\n width => {\n const pos = getPos();\n if (pos === undefined || !view.editable) return;\n const current = view.state.doc.nodeAt(pos);\n if (!current) return;\n view.dispatch(\n view.state.tr.setNodeMarkup(pos, undefined, { ...current.attrs, width })\n );\n },\n MIN_EMBED_WIDTH\n );\n }\n\n private applyAttrs(node: PMNode): void {\n const { src, provider, title, width, align } = node.attrs;\n if (this.iframe.getAttribute('src') !== src) this.iframe.setAttribute('src', src);\n this.dom.setAttribute('data-embed-provider', provider ?? 'generic');\n if (title) this.iframe.title = title;\n else this.iframe.removeAttribute('title');\n if (width) {\n this.dom.setAttribute('data-width', String(width));\n this.dom.style.width = `${width}px`;\n } else {\n this.dom.removeAttribute('data-width');\n this.dom.style.width = '';\n }\n // Block alignment via auto margins (mirrors the image figure).\n if (align) this.dom.setAttribute('data-align', align);\n else this.dom.removeAttribute('data-align');\n this.dom.style.marginLeft = align === 'center' || align === 'right' ? 'auto' : '';\n this.dom.style.marginRight = align === 'center' ? 'auto' : '';\n }\n\n update(node: PMNode): boolean {\n if (node.type !== this.node.type) return false;\n this.node = node;\n this.applyAttrs(node);\n return true;\n }\n\n stopEvent(event: Event): boolean {\n return isResizeEvent(event);\n }\n\n ignoreMutation(): boolean {\n return true;\n }\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Plugin } from 'prosemirror-state';
|
|
2
|
+
export interface EmbedTarget {
|
|
3
|
+
src: string;
|
|
4
|
+
provider: 'youtube' | 'vimeo' | 'loom';
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Converts share/watch URLs from supported providers into their embed URLs.
|
|
8
|
+
* Returns null for anything unrecognized — only these providers are allowed.
|
|
9
|
+
*/
|
|
10
|
+
export declare function toEmbedUrl(url: string): EmbedTarget | null;
|
|
11
|
+
/** True when a URL is already a permitted embed src (sanitizer check). */
|
|
12
|
+
export declare function isAllowedEmbedSrc(src: string): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Pasting a bare provider URL onto an empty selection inserts an embed
|
|
15
|
+
* instead of plain text. (Pasting over selected text still creates a link.)
|
|
16
|
+
*/
|
|
17
|
+
export declare function embedPastePlugin(): Plugin;
|