@aquera/nile-elements 1.9.6 → 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 +3 -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 +3595 -629
- 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-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 +1 -1
- 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-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-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-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-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 +450 -0
- 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,883 @@
|
|
|
1
|
+
import { expect } from '@open-wc/testing';
|
|
2
|
+
import { TextSelection, NodeSelection, AllSelection } from 'prosemirror-state';
|
|
3
|
+
import { defaultSchema, htmlToDoc, htmlToSlice, docToHtml, isOfficeHtml, cleanOfficeHtml, docToMarkdown, sanitizeHtml, createEditorState, getCommand, computeToolbarState, isDocEmpty, countWords, getFindState, searchTr, findStepTr, replaceActiveTr, replaceAllTr, plainTextSlice, stripSliceFormatting, } from './index';
|
|
4
|
+
import { toEmbedUrl, isAllowedEmbedSrc } from './plugins/embeds';
|
|
5
|
+
import { codeHighlightKey } from './plugins/code-highlight';
|
|
6
|
+
/** Builds an editor state with the whole document selected. */
|
|
7
|
+
function stateWithAllSelected(html) {
|
|
8
|
+
const doc = htmlToDoc(defaultSchema, html);
|
|
9
|
+
const state = createEditorState({ doc });
|
|
10
|
+
const selection = TextSelection.create(state.doc, 1, state.doc.content.size - 1);
|
|
11
|
+
return state.apply(state.tr.setSelection(selection));
|
|
12
|
+
}
|
|
13
|
+
describe('sanitizeHtml', () => {
|
|
14
|
+
it('removes script elements entirely', () => {
|
|
15
|
+
expect(sanitizeHtml('<p>hi</p><script>alert(1)</script>')).to.equal('<p>hi</p>');
|
|
16
|
+
});
|
|
17
|
+
it('removes inline event handlers', () => {
|
|
18
|
+
const out = sanitizeHtml('<p onclick="alert(1)" onmouseover="x()">hi</p>');
|
|
19
|
+
expect(out).to.not.include('onclick').and.to.not.include('onmouseover');
|
|
20
|
+
});
|
|
21
|
+
it('drops javascript: URLs', () => {
|
|
22
|
+
const out = sanitizeHtml('<a href="javascript:alert(1)">x</a>');
|
|
23
|
+
expect(out).to.not.include('javascript:');
|
|
24
|
+
});
|
|
25
|
+
it('keeps safe links and forces noopener on _blank', () => {
|
|
26
|
+
const out = sanitizeHtml('<a href="https://example.com" target="_blank">x</a>');
|
|
27
|
+
expect(out).to.include('https://example.com');
|
|
28
|
+
expect(out).to.include('noopener');
|
|
29
|
+
});
|
|
30
|
+
it('filters style declarations to the allowed set', () => {
|
|
31
|
+
const out = sanitizeHtml('<span style="color: red; position: fixed; background-image: url(x)">x</span>');
|
|
32
|
+
expect(out).to.include('color: red');
|
|
33
|
+
expect(out).to.not.include('position');
|
|
34
|
+
expect(out).to.not.include('url(');
|
|
35
|
+
});
|
|
36
|
+
it('unwraps unknown elements but keeps their content', () => {
|
|
37
|
+
expect(sanitizeHtml('<article><p>kept</p></article>')).to.equal('<p>kept</p>');
|
|
38
|
+
});
|
|
39
|
+
it('drops iframes, styles and forms with content', () => {
|
|
40
|
+
const out = sanitizeHtml('<iframe src="x"></iframe><style>p{}</style><form><input></form><p>ok</p>');
|
|
41
|
+
expect(out).to.equal('<p>ok</p>');
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
describe('serializer round-trip', () => {
|
|
45
|
+
const cases = [
|
|
46
|
+
'<p>plain text</p>',
|
|
47
|
+
'<h2>heading</h2><p>body</p>',
|
|
48
|
+
'<p><strong>bold</strong> and <em>italic</em> and <u>underlined</u></p>',
|
|
49
|
+
'<ul><li><p>one</p></li><li><p>two</p></li></ul>',
|
|
50
|
+
'<ol><li><p>first</p></li></ol>',
|
|
51
|
+
'<blockquote><p>quoted</p></blockquote>',
|
|
52
|
+
'<p><a href="https://example.com">link</a></p>',
|
|
53
|
+
'<p style="text-align: center">centered</p>',
|
|
54
|
+
'<p><span style="color: rgb(255, 0, 0)">red</span></p>',
|
|
55
|
+
'<p>line<br>break</p>',
|
|
56
|
+
'<hr>',
|
|
57
|
+
];
|
|
58
|
+
for (const html of cases) {
|
|
59
|
+
it(`round-trips ${html.slice(0, 40)}`, () => {
|
|
60
|
+
const doc = htmlToDoc(defaultSchema, html);
|
|
61
|
+
const out = docToHtml(doc);
|
|
62
|
+
const reparsed = htmlToDoc(defaultSchema, out);
|
|
63
|
+
expect(reparsed.eq(doc), `stable parse for ${html}`).to.equal(true);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
it('parses Word-style font-weight styles as bold', () => {
|
|
67
|
+
const doc = htmlToDoc(defaultSchema, '<p><span style="font-weight: 700">x</span></p>');
|
|
68
|
+
expect(docToHtml(doc)).to.include('<strong>');
|
|
69
|
+
});
|
|
70
|
+
it('detects empty documents', () => {
|
|
71
|
+
expect(isDocEmpty(htmlToDoc(defaultSchema, ''))).to.equal(true);
|
|
72
|
+
expect(isDocEmpty(htmlToDoc(defaultSchema, '<p></p>'))).to.equal(true);
|
|
73
|
+
expect(isDocEmpty(htmlToDoc(defaultSchema, '<p>x</p>'))).to.equal(false);
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
describe('commands', () => {
|
|
77
|
+
it('toggles bold over a selection', () => {
|
|
78
|
+
let state = stateWithAllSelected('<p>hello</p>');
|
|
79
|
+
const bold = getCommand(state, 'bold');
|
|
80
|
+
bold(state, tr => {
|
|
81
|
+
state = state.apply(tr);
|
|
82
|
+
});
|
|
83
|
+
expect(docToHtml(state.doc)).to.equal('<p><strong>hello</strong></p>');
|
|
84
|
+
});
|
|
85
|
+
it('sets and clears headings', () => {
|
|
86
|
+
let state = stateWithAllSelected('<p>title</p>');
|
|
87
|
+
getCommand(state, 'heading', { level: 2 })(state, tr => {
|
|
88
|
+
state = state.apply(tr);
|
|
89
|
+
});
|
|
90
|
+
expect(docToHtml(state.doc)).to.equal('<h2>title</h2>');
|
|
91
|
+
getCommand(state, 'paragraph')(state, tr => {
|
|
92
|
+
state = state.apply(tr);
|
|
93
|
+
});
|
|
94
|
+
expect(docToHtml(state.doc)).to.equal('<p>title</p>');
|
|
95
|
+
});
|
|
96
|
+
it('wraps and lifts bullet lists', () => {
|
|
97
|
+
let state = stateWithAllSelected('<p>item</p>');
|
|
98
|
+
getCommand(state, 'bulletList')(state, tr => {
|
|
99
|
+
state = state.apply(tr);
|
|
100
|
+
});
|
|
101
|
+
expect(docToHtml(state.doc)).to.include('<ul>');
|
|
102
|
+
getCommand(state, 'bulletList')(state, tr => {
|
|
103
|
+
state = state.apply(tr);
|
|
104
|
+
});
|
|
105
|
+
expect(docToHtml(state.doc)).to.equal('<p>item</p>');
|
|
106
|
+
});
|
|
107
|
+
it('converts between list types in place', () => {
|
|
108
|
+
let state = stateWithAllSelected('<ul><li><p>item</p></li></ul>');
|
|
109
|
+
getCommand(state, 'orderedList')(state, tr => {
|
|
110
|
+
state = state.apply(tr);
|
|
111
|
+
});
|
|
112
|
+
expect(docToHtml(state.doc)).to.include('<ol>');
|
|
113
|
+
expect(docToHtml(state.doc)).to.not.include('<ul>');
|
|
114
|
+
});
|
|
115
|
+
it('sets alignment on textblocks', () => {
|
|
116
|
+
let state = stateWithAllSelected('<p>text</p>');
|
|
117
|
+
getCommand(state, 'align', { align: 'right' })(state, tr => {
|
|
118
|
+
state = state.apply(tr);
|
|
119
|
+
});
|
|
120
|
+
expect(docToHtml(state.doc)).to.include('text-align: right');
|
|
121
|
+
});
|
|
122
|
+
it('applies and removes links', () => {
|
|
123
|
+
let state = stateWithAllSelected('<p>click</p>');
|
|
124
|
+
getCommand(state, 'link', { href: 'https://example.com' })(state, tr => {
|
|
125
|
+
state = state.apply(tr);
|
|
126
|
+
});
|
|
127
|
+
expect(docToHtml(state.doc)).to.include('href="https://example.com"');
|
|
128
|
+
getCommand(state, 'unlink')(state, tr => {
|
|
129
|
+
state = state.apply(tr);
|
|
130
|
+
});
|
|
131
|
+
expect(docToHtml(state.doc)).to.equal('<p>click</p>');
|
|
132
|
+
});
|
|
133
|
+
it('applies text color and clears formatting', () => {
|
|
134
|
+
let state = stateWithAllSelected('<p>color</p>');
|
|
135
|
+
getCommand(state, 'textColor', { color: '#ff0000' })(state, tr => {
|
|
136
|
+
state = state.apply(tr);
|
|
137
|
+
});
|
|
138
|
+
// Browsers normalize hex colors to rgb() in style attributes.
|
|
139
|
+
expect(docToHtml(state.doc)).to.match(/color: (#ff0000|rgb\(255, 0, 0\))/);
|
|
140
|
+
getCommand(state, 'clearFormatting')(state, tr => {
|
|
141
|
+
state = state.apply(tr);
|
|
142
|
+
});
|
|
143
|
+
expect(docToHtml(state.doc)).to.equal('<p>color</p>');
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
describe('phase 2: rich content', () => {
|
|
147
|
+
it('round-trips tables', () => {
|
|
148
|
+
const html = '<table><tbody><tr><th><p>h1</p></th><th><p>h2</p></th></tr>' +
|
|
149
|
+
'<tr><td><p>a</p></td><td><p>b</p></td></tr></tbody></table>';
|
|
150
|
+
const doc = htmlToDoc(defaultSchema, html);
|
|
151
|
+
const out = docToHtml(doc);
|
|
152
|
+
expect(out).to.include('<table');
|
|
153
|
+
expect(out).to.include('<th');
|
|
154
|
+
expect(htmlToDoc(defaultSchema, out).eq(doc)).to.equal(true);
|
|
155
|
+
});
|
|
156
|
+
it('keeps colspan/rowspan through sanitization', () => {
|
|
157
|
+
const out = sanitizeHtml('<table><tr><td colspan="2" rowspan="3">x</td></tr></table>');
|
|
158
|
+
expect(out).to.include('colspan="2"');
|
|
159
|
+
expect(out).to.include('rowspan="3"');
|
|
160
|
+
});
|
|
161
|
+
it('round-trips inline images', () => {
|
|
162
|
+
const html = '<p>look: <img src="https://x.dev/a.png" alt="A"></p>';
|
|
163
|
+
const doc = htmlToDoc(defaultSchema, html);
|
|
164
|
+
const out = docToHtml(doc);
|
|
165
|
+
expect(out).to.include('src="https://x.dev/a.png"');
|
|
166
|
+
expect(out).to.include('alt="A"');
|
|
167
|
+
expect(htmlToDoc(defaultSchema, out).eq(doc)).to.equal(true);
|
|
168
|
+
});
|
|
169
|
+
it('parses bare pasted images', () => {
|
|
170
|
+
const doc = htmlToDoc(defaultSchema, '<p>before</p><img src="https://x.dev/a.png">');
|
|
171
|
+
expect(docToHtml(doc)).to.include('<img src="https://x.dev/a.png"');
|
|
172
|
+
});
|
|
173
|
+
it('drops images with unsafe URLs but allows raster data URLs', () => {
|
|
174
|
+
expect(sanitizeHtml('<img src="javascript:alert(1)">')).to.not.include('src');
|
|
175
|
+
expect(sanitizeHtml('<img src="data:image/png;base64,iVBORw0KGgo=">')).to.include('data:image/png');
|
|
176
|
+
expect(sanitizeHtml('<img src="data:image/svg+xml,<svg onload=alert(1)>">')).to.not.include('svg');
|
|
177
|
+
});
|
|
178
|
+
it('round-trips code blocks preserving whitespace', () => {
|
|
179
|
+
const doc = htmlToDoc(defaultSchema, '<pre data-language="js"><code>const a = 1;\n indent();</code></pre>');
|
|
180
|
+
const out = docToHtml(doc);
|
|
181
|
+
expect(out).to.include('data-language="js"');
|
|
182
|
+
expect(out).to.include('const a = 1;\n indent();');
|
|
183
|
+
});
|
|
184
|
+
it('toggles code blocks via the codeBlock command', () => {
|
|
185
|
+
let state = stateWithAllSelected('<p>snippet</p>');
|
|
186
|
+
getCommand(state, 'codeBlock')(state, tr => {
|
|
187
|
+
state = state.apply(tr);
|
|
188
|
+
});
|
|
189
|
+
expect(docToHtml(state.doc)).to.include('<pre');
|
|
190
|
+
getCommand(state, 'codeBlock')(state, tr => {
|
|
191
|
+
state = state.apply(tr);
|
|
192
|
+
});
|
|
193
|
+
expect(docToHtml(state.doc)).to.equal('<p>snippet</p>');
|
|
194
|
+
});
|
|
195
|
+
it('inserts tables and edits rows/columns', () => {
|
|
196
|
+
let state = stateWithAllSelected('<p></p>');
|
|
197
|
+
getCommand(state, 'insertTable', { rows: 2, cols: 2 })(state, tr => {
|
|
198
|
+
state = state.apply(tr);
|
|
199
|
+
});
|
|
200
|
+
let table = state.doc.firstChild;
|
|
201
|
+
expect(table.type.name).to.equal('table');
|
|
202
|
+
expect(table.childCount).to.equal(2);
|
|
203
|
+
// Put the cursor inside the first cell, then add a row.
|
|
204
|
+
const inside = TextSelection.near(state.doc.resolve(4));
|
|
205
|
+
state = state.apply(state.tr.setSelection(inside));
|
|
206
|
+
getCommand(state, 'addRowAfter')(state, tr => {
|
|
207
|
+
state = state.apply(tr);
|
|
208
|
+
});
|
|
209
|
+
table = state.doc.firstChild;
|
|
210
|
+
expect(table.childCount).to.equal(3);
|
|
211
|
+
getCommand(state, 'deleteTable')(state, tr => {
|
|
212
|
+
state = state.apply(tr);
|
|
213
|
+
});
|
|
214
|
+
expect(docToHtml(state.doc)).to.not.include('<table');
|
|
215
|
+
});
|
|
216
|
+
it('inserts inline images via the insertImage command', () => {
|
|
217
|
+
let state = stateWithAllSelected('<p></p>');
|
|
218
|
+
getCommand(state, 'insertImage', { src: 'https://x.dev/i.png', alt: 'pic' })(state, tr => {
|
|
219
|
+
state = state.apply(tr);
|
|
220
|
+
});
|
|
221
|
+
const out = docToHtml(state.doc);
|
|
222
|
+
expect(out).to.include('<img');
|
|
223
|
+
expect(out).to.include('alt="pic"');
|
|
224
|
+
});
|
|
225
|
+
it('reports inTable and inCodeBlock in toolbar state', () => {
|
|
226
|
+
let state = stateWithAllSelected('<p></p>');
|
|
227
|
+
getCommand(state, 'insertTable', { rows: 2, cols: 2 })(state, tr => {
|
|
228
|
+
state = state.apply(tr);
|
|
229
|
+
});
|
|
230
|
+
state = state.apply(state.tr.setSelection(TextSelection.near(state.doc.resolve(4))));
|
|
231
|
+
expect(computeToolbarState(state).inTable).to.equal(true);
|
|
232
|
+
const codeState = stateWithAllSelected('<pre><code>x</code></pre>');
|
|
233
|
+
expect(computeToolbarState(codeState).inCodeBlock).to.equal(true);
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
describe('phase 3: productivity', () => {
|
|
237
|
+
it('round-trips mention nodes', () => {
|
|
238
|
+
const html = '<p>ping <span data-mention-trigger="@" data-mention-key="u1" data-mention-label="Ada">@Ada</span> now</p>';
|
|
239
|
+
const doc = htmlToDoc(defaultSchema, html);
|
|
240
|
+
const out = docToHtml(doc);
|
|
241
|
+
expect(out).to.include('data-mention-key="u1"');
|
|
242
|
+
expect(out).to.include('data-mention-label="Ada"');
|
|
243
|
+
expect(out).to.include('@Ada');
|
|
244
|
+
expect(htmlToDoc(defaultSchema, out).eq(doc)).to.equal(true);
|
|
245
|
+
});
|
|
246
|
+
it('keeps mention data attributes through sanitization', () => {
|
|
247
|
+
const out = sanitizeHtml('<span data-mention-key="u1" data-mention-trigger="@" data-mention-label="Ada" onclick="x()">@Ada</span>');
|
|
248
|
+
expect(out).to.include('data-mention-key="u1"');
|
|
249
|
+
expect(out).to.not.include('onclick');
|
|
250
|
+
});
|
|
251
|
+
it('tracks trigger queries through the suggestion plugin', () => {
|
|
252
|
+
const seen = [];
|
|
253
|
+
let state = createEditorState({
|
|
254
|
+
doc: htmlToDoc(defaultSchema, '<p></p>'),
|
|
255
|
+
mentions: {
|
|
256
|
+
getTriggers: () => ['@'],
|
|
257
|
+
onChange: match => seen.push(match),
|
|
258
|
+
},
|
|
259
|
+
});
|
|
260
|
+
state = state.apply(state.tr.insertText('hello @ad', 1));
|
|
261
|
+
const last = seen[seen.length - 1];
|
|
262
|
+
expect(last.active).to.equal(true);
|
|
263
|
+
expect(last.trigger).to.equal('@');
|
|
264
|
+
expect(last.query).to.equal('ad');
|
|
265
|
+
// A space ends the suggestion.
|
|
266
|
+
state = state.apply(state.tr.insertText(' '));
|
|
267
|
+
expect(seen[seen.length - 1].active).to.equal(false);
|
|
268
|
+
});
|
|
269
|
+
it('does not trigger suggestions mid-word', () => {
|
|
270
|
+
const seen = [];
|
|
271
|
+
const state = createEditorState({
|
|
272
|
+
doc: htmlToDoc(defaultSchema, '<p></p>'),
|
|
273
|
+
mentions: { getTriggers: () => ['@'], onChange: m => seen.push(m) },
|
|
274
|
+
});
|
|
275
|
+
state.apply(state.tr.insertText('email@example', 1));
|
|
276
|
+
expect(seen.every(m => !m.active)).to.equal(true);
|
|
277
|
+
});
|
|
278
|
+
it('finds, steps through, and replaces matches', () => {
|
|
279
|
+
let state = createEditorState({
|
|
280
|
+
doc: htmlToDoc(defaultSchema, '<p>cat dog cat</p><p>Cat nap</p>'),
|
|
281
|
+
});
|
|
282
|
+
state = state.apply(searchTr(state, 'cat'));
|
|
283
|
+
expect(getFindState(state).matches.length).to.equal(3);
|
|
284
|
+
expect(getFindState(state).activeIndex).to.equal(0);
|
|
285
|
+
state = state.apply(findStepTr(state, 'next'));
|
|
286
|
+
expect(getFindState(state).activeIndex).to.equal(1);
|
|
287
|
+
state = state.apply(findStepTr(state, 'prev'));
|
|
288
|
+
expect(getFindState(state).activeIndex).to.equal(0);
|
|
289
|
+
state = state.apply(replaceActiveTr(state, 'ferret'));
|
|
290
|
+
expect(docToHtml(state.doc)).to.include('ferret dog cat');
|
|
291
|
+
// Matches recompute after the doc change.
|
|
292
|
+
expect(getFindState(state).matches.length).to.equal(2);
|
|
293
|
+
state = state.apply(replaceAllTr(state, 'newt'));
|
|
294
|
+
expect(getFindState(state).matches.length).to.equal(0);
|
|
295
|
+
expect(docToHtml(state.doc)).to.equal('<p>ferret dog newt</p><p>newt nap</p>');
|
|
296
|
+
});
|
|
297
|
+
it('respects case sensitivity in find', () => {
|
|
298
|
+
let state = createEditorState({
|
|
299
|
+
doc: htmlToDoc(defaultSchema, '<p>Cat cat CAT</p>'),
|
|
300
|
+
});
|
|
301
|
+
state = state.apply(searchTr(state, 'cat', true));
|
|
302
|
+
expect(getFindState(state).matches.length).to.equal(1);
|
|
303
|
+
});
|
|
304
|
+
it('counts words and characters', () => {
|
|
305
|
+
const doc = htmlToDoc(defaultSchema, '<p>one two</p><p>three</p>');
|
|
306
|
+
expect(countWords(doc)).to.deep.equal({ words: 3, characters: 12 });
|
|
307
|
+
expect(countWords(htmlToDoc(defaultSchema, ''))).to.deep.equal({
|
|
308
|
+
words: 0,
|
|
309
|
+
characters: 0,
|
|
310
|
+
});
|
|
311
|
+
});
|
|
312
|
+
});
|
|
313
|
+
describe('small features', () => {
|
|
314
|
+
it('round-trips checklists', () => {
|
|
315
|
+
const html = '<ul data-task-list="true"><li data-task-item="true" data-checked="true"><p>done</p></li>' +
|
|
316
|
+
'<li data-task-item="true" data-checked="false"><p>todo</p></li></ul>';
|
|
317
|
+
const doc = htmlToDoc(defaultSchema, html);
|
|
318
|
+
expect(doc.firstChild.type.name).to.equal('task_list');
|
|
319
|
+
expect(doc.firstChild.firstChild.attrs.checked).to.equal(true);
|
|
320
|
+
const out = docToHtml(doc);
|
|
321
|
+
expect(out).to.include('data-checked="true"');
|
|
322
|
+
expect(htmlToDoc(defaultSchema, out).eq(doc)).to.equal(true);
|
|
323
|
+
});
|
|
324
|
+
it('plain lists still parse as bullet lists', () => {
|
|
325
|
+
const doc = htmlToDoc(defaultSchema, '<ul><li><p>plain</p></li></ul>');
|
|
326
|
+
expect(doc.firstChild.type.name).to.equal('bullet_list');
|
|
327
|
+
});
|
|
328
|
+
it('toggles checklists and converts bullet lists in place', () => {
|
|
329
|
+
let state = stateWithAllSelected('<p>task</p>');
|
|
330
|
+
getCommand(state, 'taskList')(state, tr => {
|
|
331
|
+
state = state.apply(tr);
|
|
332
|
+
});
|
|
333
|
+
expect(state.doc.firstChild.type.name).to.equal('task_list');
|
|
334
|
+
// Convert to bullet list: items must be remapped too.
|
|
335
|
+
getCommand(state, 'bulletList')(state, tr => {
|
|
336
|
+
state = state.apply(tr);
|
|
337
|
+
});
|
|
338
|
+
expect(state.doc.firstChild.type.name).to.equal('bullet_list');
|
|
339
|
+
expect(state.doc.firstChild.firstChild.type.name).to.equal('list_item');
|
|
340
|
+
// And back to a checklist.
|
|
341
|
+
getCommand(state, 'taskList')(state, tr => {
|
|
342
|
+
state = state.apply(tr);
|
|
343
|
+
});
|
|
344
|
+
expect(state.doc.firstChild.firstChild.type.name).to.equal('task_item');
|
|
345
|
+
});
|
|
346
|
+
it('enforces maxLength but always allows shrinking', () => {
|
|
347
|
+
let state = createEditorState({
|
|
348
|
+
doc: htmlToDoc(defaultSchema, '<p>12345678</p>'),
|
|
349
|
+
getMaxLength: () => 10,
|
|
350
|
+
});
|
|
351
|
+
state = state.apply(state.tr.insertText('90', 9));
|
|
352
|
+
expect(state.doc.textContent).to.equal('1234567890');
|
|
353
|
+
// Growing past the limit is rejected: the state stays unchanged.
|
|
354
|
+
const attempted = state.apply(state.tr.insertText('x', 11));
|
|
355
|
+
expect(attempted.doc.textContent).to.equal('1234567890');
|
|
356
|
+
// Deleting is always allowed.
|
|
357
|
+
state = state.apply(state.tr.delete(1, 6));
|
|
358
|
+
expect(state.doc.textContent).to.equal('67890');
|
|
359
|
+
});
|
|
360
|
+
it('suggestion minQueryLength keeps short queries inactive', () => {
|
|
361
|
+
const seen = [];
|
|
362
|
+
let state = createEditorState({
|
|
363
|
+
doc: htmlToDoc(defaultSchema, '<p></p>'),
|
|
364
|
+
emoji: { onChange: m => seen.push(m) },
|
|
365
|
+
});
|
|
366
|
+
state = state.apply(state.tr.insertText(':s', 1));
|
|
367
|
+
expect(seen.filter(m => m.active)).to.have.length(0);
|
|
368
|
+
state = state.apply(state.tr.insertText('mi'));
|
|
369
|
+
const last = seen[seen.length - 1];
|
|
370
|
+
expect(last.active).to.equal(true);
|
|
371
|
+
expect(last.query).to.equal('smi');
|
|
372
|
+
});
|
|
373
|
+
});
|
|
374
|
+
describe('embeds', () => {
|
|
375
|
+
it('converts provider share URLs to embed URLs', () => {
|
|
376
|
+
expect(toEmbedUrl('https://www.youtube.com/watch?v=dQw4w9WgXcQ')).to.deep.equal({
|
|
377
|
+
src: 'https://www.youtube-nocookie.com/embed/dQw4w9WgXcQ',
|
|
378
|
+
provider: 'youtube',
|
|
379
|
+
});
|
|
380
|
+
expect(toEmbedUrl('https://youtu.be/dQw4w9WgXcQ').src).to.include('/embed/dQw4w9WgXcQ');
|
|
381
|
+
expect(toEmbedUrl('https://www.youtube.com/shorts/dQw4w9WgXcQ').provider).to.equal('youtube');
|
|
382
|
+
expect(toEmbedUrl('https://vimeo.com/123456789')).to.deep.equal({
|
|
383
|
+
src: 'https://player.vimeo.com/video/123456789',
|
|
384
|
+
provider: 'vimeo',
|
|
385
|
+
});
|
|
386
|
+
expect(toEmbedUrl('https://www.loom.com/share/abcdef0123456789abcdef0123456789').provider).to.equal('loom');
|
|
387
|
+
});
|
|
388
|
+
it('rejects non-provider and non-https URLs', () => {
|
|
389
|
+
expect(toEmbedUrl('https://evil.example.com/embed/x')).to.equal(null);
|
|
390
|
+
expect(toEmbedUrl('http://www.youtube.com/watch?v=dQw4w9WgXcQ')).to.equal(null);
|
|
391
|
+
expect(toEmbedUrl('javascript:alert(1)')).to.equal(null);
|
|
392
|
+
expect(toEmbedUrl('https://youtube.com.evil.com/watch?v=x')).to.equal(null);
|
|
393
|
+
expect(isAllowedEmbedSrc('https://evil.com/embed/x')).to.equal(false);
|
|
394
|
+
});
|
|
395
|
+
it('keeps allowlisted iframes through sanitization, drops the rest', () => {
|
|
396
|
+
const good = sanitizeHtml('<div data-embed-provider="youtube"><iframe src="https://www.youtube-nocookie.com/embed/abc123xyz"></iframe></div>');
|
|
397
|
+
expect(good).to.include('youtube-nocookie.com/embed');
|
|
398
|
+
const evil = sanitizeHtml('<iframe src="https://evil.example.com/steal"></iframe><p>ok</p>');
|
|
399
|
+
expect(evil).to.equal('<p>ok</p>');
|
|
400
|
+
});
|
|
401
|
+
it('round-trips embed nodes', () => {
|
|
402
|
+
const html = '<div data-embed-provider="youtube"><iframe src="https://www.youtube-nocookie.com/embed/abc123xyz" title="Demo"></iframe></div>';
|
|
403
|
+
const doc = htmlToDoc(defaultSchema, html);
|
|
404
|
+
expect(doc.firstChild.type.name).to.equal('embed');
|
|
405
|
+
const out = docToHtml(doc);
|
|
406
|
+
expect(out).to.include('data-embed-provider="youtube"');
|
|
407
|
+
expect(htmlToDoc(defaultSchema, out).eq(doc)).to.equal(true);
|
|
408
|
+
});
|
|
409
|
+
it('inserts embeds via the insertEmbed command', () => {
|
|
410
|
+
let state = stateWithAllSelected('<p></p>');
|
|
411
|
+
getCommand(state, 'insertEmbed', {
|
|
412
|
+
src: 'https://player.vimeo.com/video/123456789',
|
|
413
|
+
provider: 'vimeo',
|
|
414
|
+
})(state, tr => {
|
|
415
|
+
state = state.apply(tr);
|
|
416
|
+
});
|
|
417
|
+
expect(state.doc.firstChild.type.name).to.equal('embed');
|
|
418
|
+
});
|
|
419
|
+
});
|
|
420
|
+
describe('code highlighting', () => {
|
|
421
|
+
it('produces token decorations for code blocks', () => {
|
|
422
|
+
const state = createEditorState({
|
|
423
|
+
doc: htmlToDoc(defaultSchema, '<pre data-language="javascript"><code>const answer = 42; // why</code></pre>'),
|
|
424
|
+
});
|
|
425
|
+
const set = codeHighlightKey.getState(state);
|
|
426
|
+
const decos = set.find();
|
|
427
|
+
expect(decos.length).to.be.greaterThan(2);
|
|
428
|
+
});
|
|
429
|
+
it('skips plaintext blocks and updates the language attr', () => {
|
|
430
|
+
let state = createEditorState({
|
|
431
|
+
doc: htmlToDoc(defaultSchema, '<pre data-language="plaintext"><code>const answer = 42;</code></pre>'),
|
|
432
|
+
});
|
|
433
|
+
expect(codeHighlightKey.getState(state).find().length).to.equal(0);
|
|
434
|
+
state = state.apply(state.tr.setSelection(TextSelection.near(state.doc.resolve(1))));
|
|
435
|
+
getCommand(state, 'setCodeBlockLanguage', { language: 'javascript' })(state, tr => {
|
|
436
|
+
state = state.apply(tr);
|
|
437
|
+
});
|
|
438
|
+
expect(state.doc.firstChild.attrs.language).to.equal('javascript');
|
|
439
|
+
expect(codeHighlightKey.getState(state).find().length).to.be.greaterThan(1);
|
|
440
|
+
});
|
|
441
|
+
});
|
|
442
|
+
describe('phase 4: subscript & superscript', () => {
|
|
443
|
+
it('round-trips sub and sup marks', () => {
|
|
444
|
+
for (const html of ['<p>H<sub>2</sub>O</p>', '<p>x<sup>2</sup></p>']) {
|
|
445
|
+
const doc = htmlToDoc(defaultSchema, html);
|
|
446
|
+
expect(docToHtml(doc)).to.equal(html);
|
|
447
|
+
expect(htmlToDoc(defaultSchema, docToHtml(doc)).eq(doc)).to.equal(true);
|
|
448
|
+
}
|
|
449
|
+
});
|
|
450
|
+
it('parses vertical-align styles pasted from Word/Docs', () => {
|
|
451
|
+
expect(docToHtml(htmlToDoc(defaultSchema, '<p><span style="vertical-align: sub">2</span></p>'))).to.include('<sub>');
|
|
452
|
+
expect(docToHtml(htmlToDoc(defaultSchema, '<p><span style="vertical-align: super">2</span></p>'))).to.include('<sup>');
|
|
453
|
+
});
|
|
454
|
+
it('toggles sub/sup and keeps them mutually exclusive', () => {
|
|
455
|
+
let state = stateWithAllSelected('<p>x</p>');
|
|
456
|
+
getCommand(state, 'subscript')(state, tr => {
|
|
457
|
+
state = state.apply(tr);
|
|
458
|
+
});
|
|
459
|
+
expect(docToHtml(state.doc)).to.equal('<p><sub>x</sub></p>');
|
|
460
|
+
// Applying superscript over a subscript replaces it (excludes).
|
|
461
|
+
getCommand(state, 'superscript')(state, tr => {
|
|
462
|
+
state = state.apply(tr);
|
|
463
|
+
});
|
|
464
|
+
expect(docToHtml(state.doc)).to.equal('<p><sup>x</sup></p>');
|
|
465
|
+
});
|
|
466
|
+
it('reports sub/sup in toolbar state', () => {
|
|
467
|
+
expect(computeToolbarState(stateWithAllSelected('<p><sub>x</sub></p>')).subscript).to.equal(true);
|
|
468
|
+
expect(computeToolbarState(stateWithAllSelected('<p><sup>x</sup></p>')).superscript).to.equal(true);
|
|
469
|
+
});
|
|
470
|
+
});
|
|
471
|
+
describe('phase 4: paste as plain text', () => {
|
|
472
|
+
it('builds a plain-text slice splitting on newlines', () => {
|
|
473
|
+
const slice = plainTextSlice(defaultSchema, 'line1\nline2');
|
|
474
|
+
expect(slice.content.childCount).to.equal(2);
|
|
475
|
+
expect(slice.content.firstChild.textContent).to.equal('line1');
|
|
476
|
+
expect(slice.content.lastChild.textContent).to.equal('line2');
|
|
477
|
+
});
|
|
478
|
+
it('strips marks and block structure from a rich slice', () => {
|
|
479
|
+
const rich = htmlToSlice(defaultSchema, '<h2><strong>bold</strong> head</h2>');
|
|
480
|
+
const plain = stripSliceFormatting(defaultSchema, rich);
|
|
481
|
+
const para = plain.content.firstChild;
|
|
482
|
+
expect(para.type.name).to.equal('paragraph');
|
|
483
|
+
expect(para.textContent).to.equal('bold head');
|
|
484
|
+
expect(para.firstChild.marks.length).to.equal(0);
|
|
485
|
+
});
|
|
486
|
+
it('only strips when the toggle reads true', () => {
|
|
487
|
+
let force = false;
|
|
488
|
+
const state = createEditorState({ getForcePlainText: () => force });
|
|
489
|
+
const paste = state.plugins
|
|
490
|
+
.map(p => p.props?.transformPasted)
|
|
491
|
+
.find(Boolean);
|
|
492
|
+
const rich = htmlToSlice(defaultSchema, '<p><strong>bold</strong></p>');
|
|
493
|
+
// Off: slice passes through unchanged.
|
|
494
|
+
expect(paste(rich).eq(rich)).to.equal(true);
|
|
495
|
+
// On: formatting is dropped.
|
|
496
|
+
force = true;
|
|
497
|
+
const out = paste(rich);
|
|
498
|
+
expect(out.content.firstChild.firstChild.marks.length).to.equal(0);
|
|
499
|
+
});
|
|
500
|
+
});
|
|
501
|
+
describe('phase 4: more code languages', () => {
|
|
502
|
+
it('highlights newly registered languages', () => {
|
|
503
|
+
for (const language of ['go', 'rust', 'ruby', 'csharp']) {
|
|
504
|
+
const state = createEditorState({
|
|
505
|
+
doc: htmlToDoc(defaultSchema, `<pre data-language="${language}"><code>fn main() { let x = 1; }</code></pre>`),
|
|
506
|
+
});
|
|
507
|
+
expect(codeHighlightKey.getState(state).find().length, language).to.be.greaterThan(0);
|
|
508
|
+
}
|
|
509
|
+
});
|
|
510
|
+
});
|
|
511
|
+
describe('phase 4: markdown export', () => {
|
|
512
|
+
const cases = [
|
|
513
|
+
['<h2>Title</h2><p>Hello <strong>bold</strong> and <em>it</em></p>', '## Title\n\nHello **bold** and *it*\n'],
|
|
514
|
+
['<ul><li><p>one</p></li><li><p>two</p></li></ul>', '- one\n- two\n'],
|
|
515
|
+
['<ol><li><p>a</p></li><li><p>b</p></li></ol>', '1. a\n2. b\n'],
|
|
516
|
+
['<blockquote><p>quoted</p></blockquote>', '> quoted\n'],
|
|
517
|
+
['<p><a href="https://x.dev">link</a></p>', '[link](https://x.dev)\n'],
|
|
518
|
+
['<p><code>x()</code></p>', '`x()`\n'],
|
|
519
|
+
['<pre data-language="js"><code>const a = 1;</code></pre>', '```js\nconst a = 1;\n```\n'],
|
|
520
|
+
['<p><img src="https://x.dev/a.png" alt="A"></p>', '\n'],
|
|
521
|
+
['<hr>', '---\n'],
|
|
522
|
+
['<p>H<sub>2</sub>O and x<sup>2</sup></p>', 'H<sub>2</sub>O and x<sup>2</sup>\n'],
|
|
523
|
+
];
|
|
524
|
+
for (const [input, expected] of cases) {
|
|
525
|
+
it(`serializes ${input.slice(0, 36)}`, () => {
|
|
526
|
+
expect(docToMarkdown(htmlToDoc(defaultSchema, input))).to.equal(expected);
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
it('serializes checklists with checked state', () => {
|
|
530
|
+
const html = '<ul data-task-list="true"><li data-task-item="true" data-checked="true"><p>done</p></li>' +
|
|
531
|
+
'<li data-task-item="true" data-checked="false"><p>todo</p></li></ul>';
|
|
532
|
+
expect(docToMarkdown(htmlToDoc(defaultSchema, html))).to.equal('- [x] done\n- [ ] todo\n');
|
|
533
|
+
});
|
|
534
|
+
it('serializes a GitHub-flavored table', () => {
|
|
535
|
+
const html = '<table><tbody><tr><th><p>h1</p></th><th><p>h2</p></th></tr>' +
|
|
536
|
+
'<tr><td><p>a</p></td><td><p>b</p></td></tr></tbody></table>';
|
|
537
|
+
expect(docToMarkdown(htmlToDoc(defaultSchema, html))).to.equal('| h1 | h2 |\n| --- | --- |\n| a | b |\n');
|
|
538
|
+
});
|
|
539
|
+
it('returns an empty string for an empty document', () => {
|
|
540
|
+
expect(docToMarkdown(htmlToDoc(defaultSchema, '<p></p>'))).to.equal('');
|
|
541
|
+
});
|
|
542
|
+
});
|
|
543
|
+
describe('computeToolbarState', () => {
|
|
544
|
+
it('reports active marks and block info', () => {
|
|
545
|
+
const state = stateWithAllSelected('<h3><strong>bold heading</strong></h3>');
|
|
546
|
+
const ts = computeToolbarState(state);
|
|
547
|
+
expect(ts.bold).to.equal(true);
|
|
548
|
+
expect(ts.italic).to.equal(false);
|
|
549
|
+
expect(ts.blockType).to.equal('heading');
|
|
550
|
+
expect(ts.headingLevel).to.equal(3);
|
|
551
|
+
});
|
|
552
|
+
it('reports list and link context', () => {
|
|
553
|
+
const state = stateWithAllSelected('<ul><li><p><a href="https://x.dev">in list</a></p></li></ul>');
|
|
554
|
+
const ts = computeToolbarState(state);
|
|
555
|
+
expect(ts.inBulletList).to.equal(true);
|
|
556
|
+
expect(ts.linkActive).to.equal(true);
|
|
557
|
+
expect(ts.linkHref).to.equal('https://x.dev');
|
|
558
|
+
});
|
|
559
|
+
it('reports block info for a Ctrl+A AllSelection', () => {
|
|
560
|
+
const doc = htmlToDoc(defaultSchema, '<h1>sdasd</h1>');
|
|
561
|
+
const base = createEditorState({ doc });
|
|
562
|
+
const state = base.apply(base.tr.setSelection(new AllSelection(base.doc)));
|
|
563
|
+
const ts = computeToolbarState(state);
|
|
564
|
+
expect(ts.blockType).to.equal('heading');
|
|
565
|
+
expect(ts.headingLevel).to.equal(1);
|
|
566
|
+
});
|
|
567
|
+
});
|
|
568
|
+
describe('indent & outdent', () => {
|
|
569
|
+
/** Cursor inside the second item of a two-item bullet list. */
|
|
570
|
+
function stateInSecondItem() {
|
|
571
|
+
const doc = htmlToDoc(defaultSchema, '<ul><li><p>one</p></li><li><p>two</p></li></ul>');
|
|
572
|
+
const state = createEditorState({ doc });
|
|
573
|
+
// Position inside "two" (after "one" paragraph + item boundaries).
|
|
574
|
+
const pos = state.doc.content.size - 4;
|
|
575
|
+
return state.apply(state.tr.setSelection(TextSelection.create(state.doc, pos)));
|
|
576
|
+
}
|
|
577
|
+
it('indent sinks a list item into the previous one', () => {
|
|
578
|
+
let state = stateInSecondItem();
|
|
579
|
+
const applied = getCommand(state, 'indent')(state, tr => {
|
|
580
|
+
state = state.apply(tr);
|
|
581
|
+
});
|
|
582
|
+
expect(applied).to.equal(true);
|
|
583
|
+
expect(docToHtml(state.doc)).to.equal('<ul><li><p>one</p><ul><li><p>two</p></li></ul></li></ul>');
|
|
584
|
+
});
|
|
585
|
+
it('outdent lifts a nested item back out', () => {
|
|
586
|
+
let state = stateInSecondItem();
|
|
587
|
+
getCommand(state, 'indent')(state, tr => {
|
|
588
|
+
state = state.apply(tr);
|
|
589
|
+
});
|
|
590
|
+
getCommand(state, 'outdent')(state, tr => {
|
|
591
|
+
state = state.apply(tr);
|
|
592
|
+
});
|
|
593
|
+
expect(docToHtml(state.doc)).to.equal('<ul><li><p>one</p></li><li><p>two</p></li></ul>');
|
|
594
|
+
});
|
|
595
|
+
it('indent adds margin steps to plain paragraphs', () => {
|
|
596
|
+
let state = stateWithAllSelected('<p>text</p>');
|
|
597
|
+
getCommand(state, 'indent')(state, tr => {
|
|
598
|
+
state = state.apply(tr);
|
|
599
|
+
});
|
|
600
|
+
// Browsers may serialize style attributes with a trailing semicolon.
|
|
601
|
+
expect(docToHtml(state.doc)).to.include('margin-inline-start: 40px');
|
|
602
|
+
getCommand(state, 'indent')(state, tr => {
|
|
603
|
+
state = state.apply(tr);
|
|
604
|
+
});
|
|
605
|
+
expect(docToHtml(state.doc)).to.include('margin-inline-start: 80px');
|
|
606
|
+
getCommand(state, 'outdent')(state, tr => {
|
|
607
|
+
state = state.apply(tr);
|
|
608
|
+
});
|
|
609
|
+
getCommand(state, 'outdent')(state, tr => {
|
|
610
|
+
state = state.apply(tr);
|
|
611
|
+
});
|
|
612
|
+
expect(docToHtml(state.doc)).to.equal('<p>text</p>');
|
|
613
|
+
});
|
|
614
|
+
it('outdent at indent 0 outside lists and quotes does nothing', () => {
|
|
615
|
+
let state = stateWithAllSelected('<p>text</p>');
|
|
616
|
+
const applied = getCommand(state, 'outdent')(state, tr => {
|
|
617
|
+
state = state.apply(tr);
|
|
618
|
+
});
|
|
619
|
+
expect(applied).to.equal(false);
|
|
620
|
+
});
|
|
621
|
+
it('outdent lifts a block out of a blockquote', () => {
|
|
622
|
+
let state = stateWithAllSelected('<blockquote><p>quoted</p></blockquote>');
|
|
623
|
+
const applied = getCommand(state, 'outdent')(state, tr => {
|
|
624
|
+
state = state.apply(tr);
|
|
625
|
+
});
|
|
626
|
+
expect(applied).to.equal(true);
|
|
627
|
+
expect(docToHtml(state.doc)).to.equal('<p>quoted</p>');
|
|
628
|
+
});
|
|
629
|
+
});
|
|
630
|
+
describe('list properties', () => {
|
|
631
|
+
it('sets and clears bullet marker styles', () => {
|
|
632
|
+
let state = stateWithAllSelected('<ul><li><p>a</p></li></ul>');
|
|
633
|
+
getCommand(state, 'setListStyle', { style: 'square' })(state, tr => {
|
|
634
|
+
state = state.apply(tr);
|
|
635
|
+
});
|
|
636
|
+
expect(docToHtml(state.doc)).to.include('list-style-type: square');
|
|
637
|
+
getCommand(state, 'setListStyle', { style: null })(state, tr => {
|
|
638
|
+
state = state.apply(tr);
|
|
639
|
+
});
|
|
640
|
+
expect(docToHtml(state.doc)).to.equal('<ul><li><p>a</p></li></ul>');
|
|
641
|
+
});
|
|
642
|
+
it('sets numbering style as the HTML type attribute', () => {
|
|
643
|
+
let state = stateWithAllSelected('<ol><li><p>a</p></li></ol>');
|
|
644
|
+
getCommand(state, 'setListStyle', { style: 'lower-roman' })(state, tr => {
|
|
645
|
+
state = state.apply(tr);
|
|
646
|
+
});
|
|
647
|
+
expect(docToHtml(state.doc)).to.equal('<ol type="i"><li><p>a</p></li></ol>');
|
|
648
|
+
});
|
|
649
|
+
it('sets the start number of an ordered list', () => {
|
|
650
|
+
let state = stateWithAllSelected('<ol><li><p>a</p></li></ol>');
|
|
651
|
+
getCommand(state, 'setListStart', { start: 5 })(state, tr => {
|
|
652
|
+
state = state.apply(tr);
|
|
653
|
+
});
|
|
654
|
+
expect(docToHtml(state.doc)).to.equal('<ol start="5"><li><p>a</p></li></ol>');
|
|
655
|
+
});
|
|
656
|
+
it('round-trips ol type through parsing', () => {
|
|
657
|
+
const doc = htmlToDoc(defaultSchema, '<ol type="A" start="3"><li><p>x</p></li></ol>');
|
|
658
|
+
expect(docToHtml(doc)).to.equal('<ol start="3" type="A"><li><p>x</p></li></ol>');
|
|
659
|
+
});
|
|
660
|
+
});
|
|
661
|
+
describe('figure & image commands', () => {
|
|
662
|
+
/** State with a NodeSelection on the inline image. */
|
|
663
|
+
function stateWithImageSelected() {
|
|
664
|
+
const doc = htmlToDoc(defaultSchema, '<p><img src="https://x.co/i.png" alt="pic"></p>');
|
|
665
|
+
const state = createEditorState({ doc });
|
|
666
|
+
// Image node position: inside the paragraph at pos 1.
|
|
667
|
+
return state.apply(state.tr.setSelection(NodeSelection.create(state.doc, 1)));
|
|
668
|
+
}
|
|
669
|
+
it('parses and serializes a figure with caption', () => {
|
|
670
|
+
const html = '<figure><img src="https://x.co/i.png" alt="pic"><figcaption>My caption</figcaption></figure>';
|
|
671
|
+
const doc = htmlToDoc(defaultSchema, html);
|
|
672
|
+
const out = docToHtml(doc);
|
|
673
|
+
expect(out).to.include('<figure');
|
|
674
|
+
expect(out).to.include('src="https://x.co/i.png"');
|
|
675
|
+
expect(out).to.include('<figcaption');
|
|
676
|
+
expect(out).to.include('My caption');
|
|
677
|
+
});
|
|
678
|
+
it('parses image width from inline style', () => {
|
|
679
|
+
const doc = htmlToDoc(defaultSchema, '<p><img src="https://x.co/i.png" style="width: 240px"></p>');
|
|
680
|
+
expect(docToHtml(doc)).to.include('width: 240px');
|
|
681
|
+
});
|
|
682
|
+
it('toggleImageCaption converts an inline image into a figure', () => {
|
|
683
|
+
let state = stateWithImageSelected();
|
|
684
|
+
const applied = getCommand(state, 'toggleImageCaption')(state, tr => {
|
|
685
|
+
state = state.apply(tr);
|
|
686
|
+
});
|
|
687
|
+
expect(applied).to.equal(true);
|
|
688
|
+
const out = docToHtml(state.doc);
|
|
689
|
+
expect(out).to.include('<figure');
|
|
690
|
+
expect(out).to.include('pic'); // alt prefills the caption
|
|
691
|
+
});
|
|
692
|
+
it('toggleImageCaption converts a figure back to an inline image', () => {
|
|
693
|
+
let state = stateWithAllSelected('<figure><img src="https://x.co/i.png"><figcaption>cap</figcaption></figure>');
|
|
694
|
+
// Cursor is inside the caption — selectedImageInfo resolves the figure.
|
|
695
|
+
const applied = getCommand(state, 'toggleImageCaption')(state, tr => {
|
|
696
|
+
state = state.apply(tr);
|
|
697
|
+
});
|
|
698
|
+
expect(applied).to.equal(true);
|
|
699
|
+
const out = docToHtml(state.doc);
|
|
700
|
+
expect(out).to.not.include('<figure');
|
|
701
|
+
expect(out).to.include('<img');
|
|
702
|
+
});
|
|
703
|
+
it('setImageAlign promotes an inline image to an aligned figure', () => {
|
|
704
|
+
let state = stateWithImageSelected();
|
|
705
|
+
getCommand(state, 'setImageAlign', { align: 'center' })(state, tr => {
|
|
706
|
+
state = state.apply(tr);
|
|
707
|
+
});
|
|
708
|
+
expect(docToHtml(state.doc)).to.include('data-align="center"');
|
|
709
|
+
});
|
|
710
|
+
it('setImageWidth writes the width attr', () => {
|
|
711
|
+
let state = stateWithImageSelected();
|
|
712
|
+
getCommand(state, 'setImageWidth', { width: 320 })(state, tr => {
|
|
713
|
+
state = state.apply(tr);
|
|
714
|
+
});
|
|
715
|
+
expect(docToHtml(state.doc)).to.include('width: 320px');
|
|
716
|
+
});
|
|
717
|
+
it('deleteImage removes the selected image', () => {
|
|
718
|
+
let state = stateWithImageSelected();
|
|
719
|
+
getCommand(state, 'deleteImage')(state, tr => {
|
|
720
|
+
state = state.apply(tr);
|
|
721
|
+
});
|
|
722
|
+
expect(docToHtml(state.doc)).to.not.include('<img');
|
|
723
|
+
});
|
|
724
|
+
});
|
|
725
|
+
describe('paste from Office', () => {
|
|
726
|
+
it('detects Word and Google Docs clipboard HTML', () => {
|
|
727
|
+
expect(isOfficeHtml('<p class="MsoNormal">x</p>')).to.equal(true);
|
|
728
|
+
expect(isOfficeHtml('<b id="docs-internal-guid-abc"><p>x</p></b>')).to.equal(true);
|
|
729
|
+
expect(isOfficeHtml('<p>plain</p>')).to.equal(false);
|
|
730
|
+
});
|
|
731
|
+
it('converts Word list paragraphs into a real bullet list', () => {
|
|
732
|
+
const word = '<p class="MsoListParagraph" style="mso-list:l0 level1 lfo1">' +
|
|
733
|
+
'<span style="mso-list:Ignore">·<span> </span></span>Alpha</p>' +
|
|
734
|
+
'<p class="MsoListParagraph" style="mso-list:l0 level1 lfo1">' +
|
|
735
|
+
'<span style="mso-list:Ignore">·<span> </span></span>Beta</p>';
|
|
736
|
+
const out = cleanOfficeHtml(word);
|
|
737
|
+
expect(out).to.include('<ul>');
|
|
738
|
+
expect(out).to.include('Alpha');
|
|
739
|
+
expect(out).to.include('Beta');
|
|
740
|
+
expect(out).to.not.include('mso-list');
|
|
741
|
+
});
|
|
742
|
+
it('converts numbered Word paragraphs into an ordered list with nesting', () => {
|
|
743
|
+
const word = '<p style="mso-list:l0 level1 lfo1"><span style="mso-list:Ignore">1.</span>One</p>' +
|
|
744
|
+
'<p style="mso-list:l0 level2 lfo1"><span style="mso-list:Ignore">a.</span>Nested</p>' +
|
|
745
|
+
'<p style="mso-list:l0 level1 lfo1"><span style="mso-list:Ignore">2.</span>Two</p>';
|
|
746
|
+
const out = cleanOfficeHtml(word);
|
|
747
|
+
expect(out.indexOf('<ol>')).to.be.greaterThan(-1);
|
|
748
|
+
// Nested list sits inside the first item.
|
|
749
|
+
expect(out.indexOf('Nested')).to.be.greaterThan(out.indexOf('One'));
|
|
750
|
+
expect(out.indexOf('Two')).to.be.greaterThan(out.indexOf('Nested'));
|
|
751
|
+
});
|
|
752
|
+
it('unwraps the Google Docs bold guid wrapper', () => {
|
|
753
|
+
const gdocs = '<b id="docs-internal-guid-x" style="font-weight:normal"><p>hello</p></b>';
|
|
754
|
+
const out = cleanOfficeHtml(gdocs);
|
|
755
|
+
expect(out).to.equal('<p>hello</p>');
|
|
756
|
+
});
|
|
757
|
+
it('drops conditional comments and o:p tags', () => {
|
|
758
|
+
// Downlevel-hidden conditional: the marker content is inside the comment.
|
|
759
|
+
const word = '<p><!--[if !supportLists]>junk<![endif]-->text<o:p></o:p></p>';
|
|
760
|
+
const out = cleanOfficeHtml(word);
|
|
761
|
+
expect(out).to.not.include('junk');
|
|
762
|
+
expect(out).to.include('text');
|
|
763
|
+
});
|
|
764
|
+
});
|
|
765
|
+
describe('line height', () => {
|
|
766
|
+
it('sets and clears line height on textblocks', () => {
|
|
767
|
+
let state = stateWithAllSelected('<p>hello</p>');
|
|
768
|
+
getCommand(state, 'lineHeight', { lineHeight: '1.5' })(state, tr => {
|
|
769
|
+
state = state.apply(tr);
|
|
770
|
+
});
|
|
771
|
+
expect(docToHtml(state.doc)).to.include('line-height: 1.5');
|
|
772
|
+
expect(computeToolbarState(state).lineHeight).to.equal('1.5');
|
|
773
|
+
getCommand(state, 'lineHeight', { lineHeight: null })(state, tr => {
|
|
774
|
+
state = state.apply(tr);
|
|
775
|
+
});
|
|
776
|
+
expect(docToHtml(state.doc)).to.equal('<p>hello</p>');
|
|
777
|
+
});
|
|
778
|
+
it('parses line-height styles, converting percentages', () => {
|
|
779
|
+
const doc = htmlToDoc(defaultSchema, '<p style="line-height: 150%">a</p>');
|
|
780
|
+
expect(docToHtml(doc)).to.include('line-height: 1.5');
|
|
781
|
+
});
|
|
782
|
+
it('survives the sanitizer', () => {
|
|
783
|
+
expect(sanitizeHtml('<p style="line-height: 2">a</p>')).to.include('line-height: 2');
|
|
784
|
+
});
|
|
785
|
+
it('is cleared by clearFormatting', () => {
|
|
786
|
+
let state = stateWithAllSelected('<p style="line-height: 2">hello</p>');
|
|
787
|
+
getCommand(state, 'clearFormatting')(state, tr => {
|
|
788
|
+
state = state.apply(tr);
|
|
789
|
+
});
|
|
790
|
+
expect(docToHtml(state.doc)).to.equal('<p>hello</p>');
|
|
791
|
+
});
|
|
792
|
+
});
|
|
793
|
+
describe('bookmarks', () => {
|
|
794
|
+
it('inserts a bookmark anchor at the cursor', () => {
|
|
795
|
+
let state = createEditorState({ doc: htmlToDoc(defaultSchema, '<p>hello</p>') });
|
|
796
|
+
state = state.apply(state.tr.setSelection(TextSelection.create(state.doc, 1)));
|
|
797
|
+
getCommand(state, 'insertBookmark', { id: 'intro' })(state, tr => {
|
|
798
|
+
state = state.apply(tr);
|
|
799
|
+
});
|
|
800
|
+
expect(docToHtml(state.doc)).to.equal('<p><a id="intro" data-bookmark="true"></a>hello</p>');
|
|
801
|
+
});
|
|
802
|
+
it('rejects empty ids', () => {
|
|
803
|
+
const state = createEditorState({ doc: htmlToDoc(defaultSchema, '<p>hello</p>') });
|
|
804
|
+
expect(getCommand(state, 'insertBookmark', { id: ' ' })(state)).to.equal(false);
|
|
805
|
+
});
|
|
806
|
+
it('round-trips id and legacy name anchors, but not links', () => {
|
|
807
|
+
const doc = htmlToDoc(defaultSchema, '<p><a id="one"></a>x<a name="two"></a>y<a href="https://a.b">link</a></p>');
|
|
808
|
+
const out = docToHtml(doc);
|
|
809
|
+
expect(out).to.include('<a id="one" data-bookmark="true"></a>');
|
|
810
|
+
expect(out).to.include('<a id="two" data-bookmark="true"></a>');
|
|
811
|
+
expect(out).to.include('<a href="https://a.b">link</a>');
|
|
812
|
+
});
|
|
813
|
+
});
|
|
814
|
+
describe('layout tables', () => {
|
|
815
|
+
const table = '<table><tr><td><p>a</p></td></tr></table>';
|
|
816
|
+
function stateInTable(html) {
|
|
817
|
+
const doc = htmlToDoc(defaultSchema, html);
|
|
818
|
+
const state = createEditorState({ doc });
|
|
819
|
+
// Place the cursor inside the first cell's paragraph.
|
|
820
|
+
let pos = 0;
|
|
821
|
+
state.doc.descendants((node, p) => {
|
|
822
|
+
if (!pos && node.isTextblock)
|
|
823
|
+
pos = p + 1;
|
|
824
|
+
return !pos;
|
|
825
|
+
});
|
|
826
|
+
return state.apply(state.tr.setSelection(TextSelection.create(state.doc, pos)));
|
|
827
|
+
}
|
|
828
|
+
it('toggles the surrounding table into layout mode and back', () => {
|
|
829
|
+
let state = stateInTable(table);
|
|
830
|
+
getCommand(state, 'toggleLayoutTable')(state, tr => {
|
|
831
|
+
state = state.apply(tr);
|
|
832
|
+
});
|
|
833
|
+
expect(docToHtml(state.doc)).to.include('<table role="presentation" data-layout="true">');
|
|
834
|
+
expect(computeToolbarState(state).tableLayout).to.equal(true);
|
|
835
|
+
getCommand(state, 'toggleLayoutTable')(state, tr => {
|
|
836
|
+
state = state.apply(tr);
|
|
837
|
+
});
|
|
838
|
+
expect(docToHtml(state.doc)).to.not.include('data-layout');
|
|
839
|
+
});
|
|
840
|
+
it('parses role="presentation" tables as layout tables', () => {
|
|
841
|
+
const doc = htmlToDoc(defaultSchema, '<table role="presentation"><tr><td><p>a</p></td></tr></table>');
|
|
842
|
+
expect(docToHtml(doc)).to.include('role="presentation"');
|
|
843
|
+
});
|
|
844
|
+
it('returns false outside a table', () => {
|
|
845
|
+
const state = stateWithAllSelected('<p>hello</p>');
|
|
846
|
+
expect(getCommand(state, 'toggleLayoutTable')(state)).to.equal(false);
|
|
847
|
+
});
|
|
848
|
+
});
|
|
849
|
+
describe('multi-level lists', () => {
|
|
850
|
+
const nested = '<ol data-list-style="multilevel"><li><p>one</p><ol><li><p>deep</p></li></ol></li></ol>';
|
|
851
|
+
it('round-trips the multilevel marker', () => {
|
|
852
|
+
const doc = htmlToDoc(defaultSchema, nested);
|
|
853
|
+
expect(docToHtml(doc)).to.include('data-list-style="multilevel"');
|
|
854
|
+
});
|
|
855
|
+
it('survives the sanitizer', () => {
|
|
856
|
+
expect(sanitizeHtml(nested)).to.include('data-list-style="multilevel"');
|
|
857
|
+
});
|
|
858
|
+
it('applies multilevel to the outermost ordered list from a nested item', () => {
|
|
859
|
+
const html = '<ol><li><p>one</p><ol><li><p>deep</p></li></ol></li></ol>';
|
|
860
|
+
let state = createEditorState({ doc: htmlToDoc(defaultSchema, html) });
|
|
861
|
+
let pos = 0;
|
|
862
|
+
state.doc.descendants((node, p) => {
|
|
863
|
+
if (node.isTextblock && node.textContent === 'deep')
|
|
864
|
+
pos = p + 1;
|
|
865
|
+
return pos === 0;
|
|
866
|
+
});
|
|
867
|
+
state = state.apply(state.tr.setSelection(TextSelection.create(state.doc, pos)));
|
|
868
|
+
getCommand(state, 'setListStyle', { style: 'multilevel' })(state, tr => {
|
|
869
|
+
state = state.apply(tr);
|
|
870
|
+
});
|
|
871
|
+
const out = docToHtml(state.doc);
|
|
872
|
+
// The outer list carries the marker, not the nested one.
|
|
873
|
+
expect(out.startsWith('<ol data-list-style="multilevel">')).to.equal(true);
|
|
874
|
+
expect(out.indexOf('data-list-style')).to.equal(out.lastIndexOf('data-list-style'));
|
|
875
|
+
// The toolbar reports it from the nested cursor, and clearing removes it.
|
|
876
|
+
expect(computeToolbarState(state).listStyle).to.equal('multilevel');
|
|
877
|
+
getCommand(state, 'setListStyle', { style: null })(state, tr => {
|
|
878
|
+
state = state.apply(tr);
|
|
879
|
+
});
|
|
880
|
+
expect(docToHtml(state.doc)).to.not.include('data-list-style');
|
|
881
|
+
});
|
|
882
|
+
});
|
|
883
|
+
//# sourceMappingURL=pm.test.js.map
|