@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,96 @@
|
|
|
1
|
+
import { expect } from '@open-wc/testing';
|
|
2
|
+
import { toInlineStyledHtml, buildWordDocument, buildPrintDocument } from './export';
|
|
3
|
+
/** Renders HTML into a live, attached, styled element and returns its root. */
|
|
4
|
+
function styledRoot(inner, css = '') {
|
|
5
|
+
const host = document.createElement('div');
|
|
6
|
+
if (css) {
|
|
7
|
+
const style = document.createElement('style');
|
|
8
|
+
style.textContent = css;
|
|
9
|
+
host.appendChild(style);
|
|
10
|
+
}
|
|
11
|
+
const root = document.createElement('div');
|
|
12
|
+
root.innerHTML = inner;
|
|
13
|
+
host.appendChild(root);
|
|
14
|
+
document.body.appendChild(host);
|
|
15
|
+
return root;
|
|
16
|
+
}
|
|
17
|
+
describe('export', () => {
|
|
18
|
+
describe('toInlineStyledHtml', () => {
|
|
19
|
+
it('folds computed colour into an inline style attribute', () => {
|
|
20
|
+
const root = styledRoot('<p class="c">hi</p>', '.c { color: rgb(255, 0, 0); }');
|
|
21
|
+
const out = toInlineStyledHtml(root);
|
|
22
|
+
root.parentElement.remove();
|
|
23
|
+
expect(out).to.match(/<p[^>]*style="[^"]*color: rgb\(255, 0, 0\)/);
|
|
24
|
+
});
|
|
25
|
+
it('strips classes and editor-only attributes', () => {
|
|
26
|
+
const root = styledRoot('<p class="foo" contenteditable="true" data-x="1">t</p>');
|
|
27
|
+
const out = toInlineStyledHtml(root);
|
|
28
|
+
root.parentElement.remove();
|
|
29
|
+
expect(out).to.not.include('class=');
|
|
30
|
+
expect(out).to.not.include('contenteditable');
|
|
31
|
+
expect(out).to.not.include('data-x');
|
|
32
|
+
});
|
|
33
|
+
it('keeps structural attributes like href and src', () => {
|
|
34
|
+
const root = styledRoot('<p><a href="https://a.b">x</a></p>');
|
|
35
|
+
const out = toInlineStyledHtml(root);
|
|
36
|
+
root.parentElement.remove();
|
|
37
|
+
expect(out).to.include('href="https://a.b"');
|
|
38
|
+
});
|
|
39
|
+
it('does not repeat inherited values already set on the parent', () => {
|
|
40
|
+
const root = styledRoot('<div class="wrap"><p>child</p></div>', '.wrap { color: rgb(0, 128, 0); }');
|
|
41
|
+
const out = toInlineStyledHtml(root);
|
|
42
|
+
root.parentElement.remove();
|
|
43
|
+
// The wrapper carries the colour; the inheriting <p> should not repeat it.
|
|
44
|
+
const pMatch = /<p([^>]*)>/.exec(out);
|
|
45
|
+
expect(pMatch[1]).to.not.include('color: rgb(0, 128, 0)');
|
|
46
|
+
});
|
|
47
|
+
it('caps images at 100% width', () => {
|
|
48
|
+
const root = styledRoot('<p><img src="data:image/png;base64,AA" alt="x"></p>');
|
|
49
|
+
const out = toInlineStyledHtml(root);
|
|
50
|
+
root.parentElement.remove();
|
|
51
|
+
expect(out).to.match(/<img[^>]*max-width: 100%/);
|
|
52
|
+
});
|
|
53
|
+
it('emits borders on table cells', () => {
|
|
54
|
+
const root = styledRoot('<table><tbody><tr><td class="cell">a</td></tr></tbody></table>', '.cell { border: 2px solid rgb(0, 0, 0); }');
|
|
55
|
+
const out = toInlineStyledHtml(root);
|
|
56
|
+
root.parentElement.remove();
|
|
57
|
+
// Four equal sides serialize to the border-width/style/color shorthand.
|
|
58
|
+
expect(out).to.match(/<td[^>]*border-width: 2px/);
|
|
59
|
+
expect(out).to.match(/<td[^>]*border-style: solid/);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
describe('buildWordDocument', () => {
|
|
63
|
+
it('wraps body in a Word-openable document with office namespaces', () => {
|
|
64
|
+
const doc = buildWordDocument('<p>hi</p>', 'My File');
|
|
65
|
+
expect(doc).to.include('xmlns:w="urn:schemas-microsoft-com:office:word"');
|
|
66
|
+
expect(doc).to.include('<w:WordDocument>');
|
|
67
|
+
expect(doc).to.include('<title>My File</title>');
|
|
68
|
+
expect(doc).to.include('<p>hi</p>');
|
|
69
|
+
});
|
|
70
|
+
it('escapes the title', () => {
|
|
71
|
+
const doc = buildWordDocument('<p>x</p>', '<evil>');
|
|
72
|
+
expect(doc).to.include('<title><evil></title>');
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
describe('buildPrintDocument', () => {
|
|
76
|
+
it('includes page CSS and the body', () => {
|
|
77
|
+
const doc = buildPrintDocument('<p>hi</p>', { title: 'Doc' });
|
|
78
|
+
expect(doc).to.include('@page');
|
|
79
|
+
expect(doc).to.include('<p>hi</p>');
|
|
80
|
+
expect(doc).to.include('page-break-before: always');
|
|
81
|
+
});
|
|
82
|
+
it('renders a running header and footer when provided', () => {
|
|
83
|
+
const doc = buildPrintDocument('<p>x</p>', { header: 'Top', footer: 'Bottom' });
|
|
84
|
+
expect(doc).to.include('nw-print-header');
|
|
85
|
+
expect(doc).to.include('Top');
|
|
86
|
+
expect(doc).to.include('nw-print-footer');
|
|
87
|
+
expect(doc).to.include('Bottom');
|
|
88
|
+
});
|
|
89
|
+
it('omits header/footer bands when not provided', () => {
|
|
90
|
+
const doc = buildPrintDocument('<p>x</p>', { title: 'Doc' });
|
|
91
|
+
expect(doc).to.not.include('nw-print-header');
|
|
92
|
+
expect(doc).to.not.include('nw-print-footer');
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
//# sourceMappingURL=export.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export.test.js","sourceRoot":"","sources":["../../../../src/nile-wysiwyg-editor/engine/export.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAErF,+EAA+E;AAC/E,SAAS,UAAU,CAAC,KAAa,EAAE,GAAG,GAAG,EAAE;IACzC,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC3C,IAAI,GAAG,EAAE,CAAC;QACR,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAC9C,KAAK,CAAC,WAAW,GAAG,GAAG,CAAC;QACxB,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;IACD,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC3C,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IACvB,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAChC,OAAO,IAAI,CAAC;AACd,CAAC;AAED,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;IACtB,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;QAClC,EAAE,CAAC,sDAAsD,EAAE,GAAG,EAAE;YAC9D,MAAM,IAAI,GAAG,UAAU,CAAC,qBAAqB,EAAE,+BAA+B,CAAC,CAAC;YAChF,MAAM,GAAG,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC;YACrC,IAAI,CA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G,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;YAC1C,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,6CAA6C,EAAE,GAAG,EAAE;YACrD,MAAM,GAAG,GAAG,kBAAkB,CAAC,UAAU,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;YAC7D,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;YAC9C,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;QAChD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect } from '@open-wc/testing';\nimport { toInlineStyledHtml, buildWordDocument, buildPrintDocument } from './export';\n\n/** Renders HTML into a live, attached, styled element and returns its root. */\nfunction styledRoot(inner: string, css = ''): HTMLElement {\n const host = document.createElement('div');\n if (css) {\n const style = document.createElement('style');\n style.textContent = css;\n host.appendChild(style);\n }\n const root = document.createElement('div');\n root.innerHTML = inner;\n host.appendChild(root);\n document.body.appendChild(host);\n return root;\n}\n\ndescribe('export', () => {\n describe('toInlineStyledHtml', () => {\n it('folds computed colour into an inline style attribute', () => {\n const root = styledRoot('<p class=\"c\">hi</p>', '.c { color: rgb(255, 0, 0); }');\n const out = toInlineStyledHtml(root);\n root.parentElement!.remove();\n expect(out).to.match(/<p[^>]*style=\"[^\"]*color: rgb\\(255, 0, 0\\)/);\n });\n\n it('strips classes and editor-only attributes', () => {\n const root = styledRoot('<p class=\"foo\" contenteditable=\"true\" data-x=\"1\">t</p>');\n const out = toInlineStyledHtml(root);\n root.parentElement!.remove();\n expect(out).to.not.include('class=');\n expect(out).to.not.include('contenteditable');\n expect(out).to.not.include('data-x');\n });\n\n it('keeps structural attributes like href and src', () => {\n const root = styledRoot('<p><a href=\"https://a.b\">x</a></p>');\n const out = toInlineStyledHtml(root);\n root.parentElement!.remove();\n expect(out).to.include('href=\"https://a.b\"');\n });\n\n it('does not repeat inherited values already set on the parent', () => {\n const root = styledRoot(\n '<div class=\"wrap\"><p>child</p></div>',\n '.wrap { color: rgb(0, 128, 0); }'\n );\n const out = toInlineStyledHtml(root);\n root.parentElement!.remove();\n // The wrapper carries the colour; the inheriting <p> should not repeat it.\n const pMatch = /<p([^>]*)>/.exec(out);\n expect(pMatch![1]).to.not.include('color: rgb(0, 128, 0)');\n });\n\n it('caps images at 100% width', () => {\n const root = styledRoot('<p><img src=\"data:image/png;base64,AA\" alt=\"x\"></p>');\n const out = toInlineStyledHtml(root);\n root.parentElement!.remove();\n expect(out).to.match(/<img[^>]*max-width: 100%/);\n });\n\n it('emits borders on table cells', () => {\n const root = styledRoot(\n '<table><tbody><tr><td class=\"cell\">a</td></tr></tbody></table>',\n '.cell { border: 2px solid rgb(0, 0, 0); }'\n );\n const out = toInlineStyledHtml(root);\n root.parentElement!.remove();\n // Four equal sides serialize to the border-width/style/color shorthand.\n expect(out).to.match(/<td[^>]*border-width: 2px/);\n expect(out).to.match(/<td[^>]*border-style: solid/);\n });\n });\n\n describe('buildWordDocument', () => {\n it('wraps body in a Word-openable document with office namespaces', () => {\n const doc = buildWordDocument('<p>hi</p>', 'My File');\n expect(doc).to.include('xmlns:w=\"urn:schemas-microsoft-com:office:word\"');\n expect(doc).to.include('<w:WordDocument>');\n expect(doc).to.include('<title>My File</title>');\n expect(doc).to.include('<p>hi</p>');\n });\n\n it('escapes the title', () => {\n const doc = buildWordDocument('<p>x</p>', '<evil>');\n expect(doc).to.include('<title><evil></title>');\n });\n });\n\n describe('buildPrintDocument', () => {\n it('includes page CSS and the body', () => {\n const doc = buildPrintDocument('<p>hi</p>', { title: 'Doc' });\n expect(doc).to.include('@page');\n expect(doc).to.include('<p>hi</p>');\n expect(doc).to.include('page-break-before: always');\n });\n\n it('renders a running header and footer when provided', () => {\n const doc = buildPrintDocument('<p>x</p>', { header: 'Top', footer: 'Bottom' });\n expect(doc).to.include('nw-print-header');\n expect(doc).to.include('Top');\n expect(doc).to.include('nw-print-footer');\n expect(doc).to.include('Bottom');\n });\n\n it('omits header/footer bands when not provided', () => {\n const doc = buildPrintDocument('<p>x</p>', { title: 'Doc' });\n expect(doc).to.not.include('nw-print-header');\n expect(doc).to.not.include('nw-print-footer');\n });\n });\n});\n"]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export { createSchema, defaultSchema } from './schema';
|
|
2
|
+
export type { Alignment } from './schema';
|
|
3
|
+
export { sanitizeHtml, isSafeUrl } from './sanitize';
|
|
4
|
+
export { htmlToDoc, htmlToSlice, docToHtml, docToText, docToJson, jsonToDoc, isDocEmpty, } from './serializer';
|
|
5
|
+
export { getCommand, getMarkRange } from './commands';
|
|
6
|
+
export type { CommandName, CommandAttrs } from './commands';
|
|
7
|
+
export { docToMarkdown } from './markdown';
|
|
8
|
+
export { markdownToHtml, looksLikeMarkdown } from './markdown-parse';
|
|
9
|
+
export { isOfficeHtml, isExcelHtml, cleanOfficeHtml } from './office-paste';
|
|
10
|
+
export { toInlineStyledHtml, buildWordDocument, buildPrintDocument, } from './export';
|
|
11
|
+
export type { PrintOptions } from './export';
|
|
12
|
+
export { selectedImageInfo } from './commands';
|
|
13
|
+
export { ImageView, FigureView } from './plugins/image-view';
|
|
14
|
+
export { EmbedView } from './plugins/embed-view';
|
|
15
|
+
export { MathView } from './plugins/math-view';
|
|
16
|
+
export type { MathRenderer } from './plugins/math-view';
|
|
17
|
+
export { INDENT_STEP_PX, MAX_INDENT, BULLET_STYLES, ORDERED_STYLES } from './schema';
|
|
18
|
+
export { computeToolbarState } from './selection-state';
|
|
19
|
+
export type { ToolbarState } from './selection-state';
|
|
20
|
+
export { createEditorState, mentionSuggestKey, slashSuggestKey, emojiSuggestKey, } from './create-state';
|
|
21
|
+
export { maxLengthPlugin } from './plugins/max-length';
|
|
22
|
+
export { TaskItemView } from './plugins/task-list';
|
|
23
|
+
export { codeHighlightPlugin, CODE_LANGUAGES } from './plugins/code-highlight';
|
|
24
|
+
export { toEmbedUrl, isAllowedEmbedSrc, embedPastePlugin } from './plugins/embeds';
|
|
25
|
+
export type { EmbedTarget } from './plugins/embeds';
|
|
26
|
+
export type { CreateStateOptions } from './create-state';
|
|
27
|
+
export { countWords } from './serializer';
|
|
28
|
+
export type { SuggestionMatch, SuggestionOptions } from './plugins/suggestions';
|
|
29
|
+
export { findReplaceKey, getFindState, searchTr, findStepTr, clearFindTr, replaceActiveTr, replaceAllTr, } from './plugins/find-replace';
|
|
30
|
+
export type { FindState, FindMatch } from './plugins/find-replace';
|
|
31
|
+
export { placeholderPlugin } from './plugins/placeholder';
|
|
32
|
+
export { formatPainterPlugin, formatPainterKey, isFormatPainterArmed, armFormatPainter, disarmFormatPainter, applyFormatPainter, } from './plugins/format-painter';
|
|
33
|
+
export { linkPlugin } from './plugins/link';
|
|
34
|
+
export { singleLinePlugin, flattenToSingleParagraph } from './plugins/single-line';
|
|
35
|
+
export { tablePlugins } from './plugins/tables';
|
|
36
|
+
export { imagePlugin, imageUploadKey, findUploadPos } from './plugins/image';
|
|
37
|
+
export { pastePlugin, plainTextSlice, stripSliceFormatting } from './plugins/paste';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export { createSchema, defaultSchema } from './schema';
|
|
2
|
+
export { sanitizeHtml, isSafeUrl } from './sanitize';
|
|
3
|
+
export { htmlToDoc, htmlToSlice, docToHtml, docToText, docToJson, jsonToDoc, isDocEmpty, } from './serializer';
|
|
4
|
+
export { getCommand, getMarkRange } from './commands';
|
|
5
|
+
export { docToMarkdown } from './markdown';
|
|
6
|
+
export { markdownToHtml, looksLikeMarkdown } from './markdown-parse';
|
|
7
|
+
export { isOfficeHtml, isExcelHtml, cleanOfficeHtml } from './office-paste';
|
|
8
|
+
export { toInlineStyledHtml, buildWordDocument, buildPrintDocument, } from './export';
|
|
9
|
+
export { selectedImageInfo } from './commands';
|
|
10
|
+
export { ImageView, FigureView } from './plugins/image-view';
|
|
11
|
+
export { EmbedView } from './plugins/embed-view';
|
|
12
|
+
export { MathView } from './plugins/math-view';
|
|
13
|
+
export { INDENT_STEP_PX, MAX_INDENT, BULLET_STYLES, ORDERED_STYLES } from './schema';
|
|
14
|
+
export { computeToolbarState } from './selection-state';
|
|
15
|
+
export { createEditorState, mentionSuggestKey, slashSuggestKey, emojiSuggestKey, } from './create-state';
|
|
16
|
+
export { maxLengthPlugin } from './plugins/max-length';
|
|
17
|
+
export { TaskItemView } from './plugins/task-list';
|
|
18
|
+
export { codeHighlightPlugin, CODE_LANGUAGES } from './plugins/code-highlight';
|
|
19
|
+
export { toEmbedUrl, isAllowedEmbedSrc, embedPastePlugin } from './plugins/embeds';
|
|
20
|
+
export { countWords } from './serializer';
|
|
21
|
+
export { findReplaceKey, getFindState, searchTr, findStepTr, clearFindTr, replaceActiveTr, replaceAllTr, } from './plugins/find-replace';
|
|
22
|
+
export { placeholderPlugin } from './plugins/placeholder';
|
|
23
|
+
export { formatPainterPlugin, formatPainterKey, isFormatPainterArmed, armFormatPainter, disarmFormatPainter, applyFormatPainter, } from './plugins/format-painter';
|
|
24
|
+
export { linkPlugin } from './plugins/link';
|
|
25
|
+
export { singleLinePlugin, flattenToSingleParagraph } from './plugins/single-line';
|
|
26
|
+
export { tablePlugins } from './plugins/tables';
|
|
27
|
+
export { imagePlugin, imageUploadKey, findUploadPos } from './plugins/image';
|
|
28
|
+
export { pastePlugin, plainTextSlice, stripSliceFormatting } from './plugins/paste';
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/nile-wysiwyg-editor/engine/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CA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M,cAAc,CAAC;AAE1C,OAAO,EACL,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,WAAW,EACX,eAAe,EACf,YAAY,GACb,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACnF,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC","sourcesContent":["export { createSchema, defaultSchema } from './schema';\nexport type { Alignment } from './schema';\nexport { sanitizeHtml, isSafeUrl } from './sanitize';\nexport {\n htmlToDoc,\n htmlToSlice,\n docToHtml,\n docToText,\n docToJson,\n jsonToDoc,\n isDocEmpty,\n} from './serializer';\nexport { getCommand, getMarkRange } from './commands';\nexport type { CommandName, CommandAttrs } from './commands';\nexport { docToMarkdown } from './markdown';\nexport { markdownToHtml, looksLikeMarkdown } from './markdown-parse';\nexport { isOfficeHtml, isExcelHtml, cleanOfficeHtml } from './office-paste';\nexport {\n toInlineStyledHtml,\n buildWordDocument,\n buildPrintDocument,\n} from './export';\nexport type { PrintOptions } from './export';\nexport { selectedImageInfo } from './commands';\nexport { ImageView, FigureView } from './plugins/image-view';\nexport { EmbedView } from './plugins/embed-view';\nexport { MathView } from './plugins/math-view';\nexport type { MathRenderer } from './plugins/math-view';\nexport { INDENT_STEP_PX, MAX_INDENT, BULLET_STYLES, ORDERED_STYLES } from './schema';\nexport { computeToolbarState } from './selection-state';\nexport type { ToolbarState } from './selection-state';\nexport {\n createEditorState,\n mentionSuggestKey,\n slashSuggestKey,\n emojiSuggestKey,\n} from './create-state';\nexport { maxLengthPlugin } from './plugins/max-length';\nexport { TaskItemView } from './plugins/task-list';\nexport { codeHighlightPlugin, CODE_LANGUAGES } from './plugins/code-highlight';\nexport { toEmbedUrl, isAllowedEmbedSrc, embedPastePlugin } from './plugins/embeds';\nexport type { EmbedTarget } from './plugins/embeds';\nexport type { CreateStateOptions } from './create-state';\nexport { countWords } from './serializer';\nexport type { SuggestionMatch, SuggestionOptions } from './plugins/suggestions';\nexport {\n findReplaceKey,\n getFindState,\n searchTr,\n findStepTr,\n clearFindTr,\n replaceActiveTr,\n replaceAllTr,\n} from './plugins/find-replace';\nexport type { FindState, FindMatch } from './plugins/find-replace';\nexport { placeholderPlugin } from './plugins/placeholder';\nexport {\n formatPainterPlugin,\n formatPainterKey,\n isFormatPainterArmed,\n armFormatPainter,\n disarmFormatPainter,\n applyFormatPainter,\n} from './plugins/format-painter';\nexport { linkPlugin } from './plugins/link';\nexport { singleLinePlugin, flattenToSingleParagraph } from './plugins/single-line';\nexport { tablePlugins } from './plugins/tables';\nexport { imagePlugin, imageUploadKey, findUploadPos } from './plugins/image';\nexport { pastePlugin, plainTextSlice, stripSliceFormatting } from './plugins/paste';\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Schema } from 'prosemirror-model';
|
|
2
|
+
import { Plugin } from 'prosemirror-state';
|
|
3
|
+
export interface InputRulesOptions {
|
|
4
|
+
/** Include the autocorrect/typography rules. Defaults to true. */
|
|
5
|
+
textTransform?: boolean;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Markdown-style typing shortcuts: block rules plus inline mark rules
|
|
9
|
+
* (**bold**, *italic*, `code`, ~~strike~~), and (unless disabled) the
|
|
10
|
+
* typography autocorrect rules.
|
|
11
|
+
*/
|
|
12
|
+
export declare function buildInputRules(schema: Schema, options?: InputRulesOptions): Plugin;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { inputRules, wrappingInputRule, textblockTypeInputRule, InputRule, } from 'prosemirror-inputrules';
|
|
2
|
+
function escapeRegex(text) {
|
|
3
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
4
|
+
}
|
|
5
|
+
/** True when the cursor sits in code (block or mark) — no autocorrect there. */
|
|
6
|
+
function isInCodeContext(state) {
|
|
7
|
+
const { $from } = state.selection;
|
|
8
|
+
if ($from.parent.type.spec.code)
|
|
9
|
+
return true;
|
|
10
|
+
const code = state.schema.marks.code;
|
|
11
|
+
return !!(code && code.isInSet(state.storedMarks || $from.marks()));
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* String-replacement rule (the library stringHandler plus a code-context
|
|
15
|
+
* guard): when the regex has a capture group, only the group is replaced and
|
|
16
|
+
* the surrounding matched text is preserved.
|
|
17
|
+
*/
|
|
18
|
+
function replaceRule(regexp, replacement) {
|
|
19
|
+
return new InputRule(regexp, (state, match, start, end) => {
|
|
20
|
+
if (isInCodeContext(state))
|
|
21
|
+
return null;
|
|
22
|
+
let insert = replacement;
|
|
23
|
+
let from = start;
|
|
24
|
+
if (match.length > 1 && match[1] !== undefined) {
|
|
25
|
+
const offset = match[0].lastIndexOf(match[1]);
|
|
26
|
+
insert += match[0].slice(offset + match[1].length);
|
|
27
|
+
from += offset;
|
|
28
|
+
const cutOff = from - end;
|
|
29
|
+
if (cutOff > 0) {
|
|
30
|
+
insert = match[0].slice(offset - cutOff, offset) + insert;
|
|
31
|
+
from = end;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return state.tr.insertText(insert, from, end);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* CKEditor-style text transformations: symbols, fractions, dashes, ellipsis
|
|
39
|
+
* and smart quotes. All skipped inside code and revertable with Backspace.
|
|
40
|
+
*/
|
|
41
|
+
function textTransformRules() {
|
|
42
|
+
return [
|
|
43
|
+
// Symbols.
|
|
44
|
+
replaceRule(/\(c\)$/i, '©'),
|
|
45
|
+
replaceRule(/\(r\)$/i, '®'),
|
|
46
|
+
replaceRule(/\(tm\)$/i, '™'),
|
|
47
|
+
// Fractions (word-bounded, completed by a space).
|
|
48
|
+
replaceRule(/(?:^|\s)(1\/2)\s$/, '½'),
|
|
49
|
+
replaceRule(/(?:^|\s)(1\/4)\s$/, '¼'),
|
|
50
|
+
replaceRule(/(?:^|\s)(3\/4)\s$/, '¾'),
|
|
51
|
+
// Dashes: " --- " → em, " -- " → en. The em rule can't be shadowed by
|
|
52
|
+
// the en rule because the en rule requires whitespace before "--".
|
|
53
|
+
replaceRule(/\s(---)\s$/, '—'),
|
|
54
|
+
replaceRule(/\s(--)\s$/, '–'),
|
|
55
|
+
// Ellipsis.
|
|
56
|
+
replaceRule(/\.\.\.$/, '…'),
|
|
57
|
+
// Smart quotes: opening after start/space/bracket, closing elsewhere.
|
|
58
|
+
replaceRule(/(?:^|[\s{[(<'"‘“])(")$/, '“'),
|
|
59
|
+
replaceRule(/"$/, '”'),
|
|
60
|
+
replaceRule(/(?:^|[\s{[(<'"‘“])(')$/, '‘'),
|
|
61
|
+
replaceRule(/'$/, '’'),
|
|
62
|
+
];
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Markdown mark shortcut: typing `<delim>text<delim>` applies the mark and
|
|
66
|
+
* strips the delimiters. The matched range (delimiters and all) is replaced
|
|
67
|
+
* with the marked content, so the final typed delimiter never lands.
|
|
68
|
+
*/
|
|
69
|
+
function markInputRule(delim, markType) {
|
|
70
|
+
const escaped = escapeRegex(delim);
|
|
71
|
+
const inner = escapeRegex(delim[0]);
|
|
72
|
+
const regexp = new RegExp(`(?:^|\\s)${escaped}([^${inner}\\s](?:[^${inner}]*[^${inner}\\s])?)${escaped}$`);
|
|
73
|
+
return new InputRule(regexp, (state, match, start, end) => {
|
|
74
|
+
const content = match[1];
|
|
75
|
+
const delimStart = start + match[0].indexOf(delim);
|
|
76
|
+
const tr = state.tr;
|
|
77
|
+
tr.delete(delimStart, end);
|
|
78
|
+
tr.insertText(content, delimStart);
|
|
79
|
+
tr.addMark(delimStart, delimStart + content.length, markType.create());
|
|
80
|
+
tr.removeStoredMark(markType);
|
|
81
|
+
return tr;
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Autolink: typing a space after a bare URL (`https://…`, `http://…` or
|
|
86
|
+
* `www.…`) converts it into a link. Trailing punctuation stays outside the
|
|
87
|
+
* link, code spans and existing links are left alone, and Backspace
|
|
88
|
+
* (undoInputRule) reverts the conversion like any other input rule.
|
|
89
|
+
*/
|
|
90
|
+
function linkifyRule(schema) {
|
|
91
|
+
const linkType = schema.marks.link;
|
|
92
|
+
const regexp = /(?:^|\s)((?:https?:\/\/|www\.)[^\s]*[^\s.,:;!?'")\]}])\s$/i;
|
|
93
|
+
return new InputRule(regexp, (state, match, start, end) => {
|
|
94
|
+
const url = match[1];
|
|
95
|
+
const urlStart = start + match[0].indexOf(url);
|
|
96
|
+
const urlEnd = urlStart + url.length;
|
|
97
|
+
if (state.doc.rangeHasMark(urlStart, urlEnd, linkType))
|
|
98
|
+
return null;
|
|
99
|
+
if (state.doc.rangeHasMark(urlStart, urlEnd, schema.marks.code))
|
|
100
|
+
return null;
|
|
101
|
+
const href = /^www\./i.test(url) ? `https://${url}` : url;
|
|
102
|
+
const tr = state.tr;
|
|
103
|
+
tr.addMark(urlStart, urlEnd, linkType.create({ href }));
|
|
104
|
+
tr.removeStoredMark(linkType);
|
|
105
|
+
tr.insertText(' ', end);
|
|
106
|
+
return tr;
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Markdown-style typing shortcuts: block rules plus inline mark rules
|
|
111
|
+
* (**bold**, *italic*, `code`, ~~strike~~), and (unless disabled) the
|
|
112
|
+
* typography autocorrect rules.
|
|
113
|
+
*/
|
|
114
|
+
export function buildInputRules(schema, options = {}) {
|
|
115
|
+
const transforms = options.textTransform === false ? [] : textTransformRules();
|
|
116
|
+
return inputRules({
|
|
117
|
+
rules: [
|
|
118
|
+
...transforms,
|
|
119
|
+
// "# " … "###### " → heading
|
|
120
|
+
textblockTypeInputRule(new RegExp('^(#{1,6})\\s$'), schema.nodes.heading, match => ({ level: match[1].length })),
|
|
121
|
+
// "> " → blockquote
|
|
122
|
+
wrappingInputRule(/^\s*>\s$/, schema.nodes.blockquote),
|
|
123
|
+
// "- " or "* " → bullet list
|
|
124
|
+
wrappingInputRule(/^\s*([-*])\s$/, schema.nodes.bullet_list),
|
|
125
|
+
// "1. " → ordered list
|
|
126
|
+
wrappingInputRule(/^(\d+)\.\s$/, schema.nodes.ordered_list, match => ({ order: +match[1] }), (match, node) => node.childCount + node.attrs.order === +match[1]),
|
|
127
|
+
// "```" → code block
|
|
128
|
+
textblockTypeInputRule(/^```$/, schema.nodes.code_block),
|
|
129
|
+
// "[] " or "[ ] " → checklist
|
|
130
|
+
wrappingInputRule(/^\s*\[[ ]?\]\s$/, schema.nodes.task_list),
|
|
131
|
+
// Inline marks. Bold before italic so '**' is never read as italic;
|
|
132
|
+
// strike (~~) before subscript (~) so a double tilde is never a single.
|
|
133
|
+
markInputRule('**', schema.marks.bold),
|
|
134
|
+
markInputRule('*', schema.marks.italic),
|
|
135
|
+
markInputRule('~~', schema.marks.strike),
|
|
136
|
+
markInputRule('~', schema.marks.subscript),
|
|
137
|
+
markInputRule('^', schema.marks.superscript),
|
|
138
|
+
markInputRule('`', schema.marks.code),
|
|
139
|
+
// Bare URL + space → link.
|
|
140
|
+
linkifyRule(schema),
|
|
141
|
+
],
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=inputrules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inputrules.js","sourceRoot":"","sources":["../../../../src/nile-wysiwyg-editor/engine/inputrules.ts"],"names":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InputRule,\n} from 'prosemirror-inputrules';\nimport { MarkType, Schema } from 'prosemirror-model';\nimport { Plugin } from 'prosemirror-state';\n\nfunction escapeRegex(text: string): string {\n return text.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\n/** True when the cursor sits in code (block or mark) — no autocorrect there. */\nfunction isInCodeContext(state: import('prosemirror-state').EditorState): boolean {\n const { $from } = state.selection;\n if ($from.parent.type.spec.code) return true;\n const code = state.schema.marks.code;\n return !!(code && code.isInSet(state.storedMarks || $from.marks()));\n}\n\n/**\n * String-replacement rule (the library stringHandler plus a code-context\n * guard): when the regex has a capture group, only the group is replaced and\n * the surrounding matched text is preserved.\n */\nfunction replaceRule(regexp: RegExp, replacement: string): InputRule {\n return new InputRule(regexp, (state, match, start, end) => {\n if (isInCodeContext(state)) return null;\n let insert = replacement;\n let from = start;\n if (match.length > 1 && match[1] !== undefined) {\n const offset = match[0].lastIndexOf(match[1]);\n insert += match[0].slice(offset + match[1].length);\n from += offset;\n const cutOff = from - end;\n if (cutOff > 0) {\n insert = match[0].slice(offset - cutOff, offset) + insert;\n from = end;\n }\n }\n return state.tr.insertText(insert, from, end);\n });\n}\n\n/**\n * CKEditor-style text transformations: symbols, fractions, dashes, ellipsis\n * and smart quotes. All skipped inside code and revertable with Backspace.\n */\nfunction textTransformRules(): InputRule[] {\n return [\n // Symbols.\n replaceRule(/\\(c\\)$/i, '©'),\n replaceRule(/\\(r\\)$/i, '®'),\n replaceRule(/\\(tm\\)$/i, '™'),\n // Fractions (word-bounded, completed by a space).\n replaceRule(/(?:^|\\s)(1\\/2)\\s$/, '½'),\n replaceRule(/(?:^|\\s)(1\\/4)\\s$/, '¼'),\n replaceRule(/(?:^|\\s)(3\\/4)\\s$/, '¾'),\n // Dashes: \" --- \" → em, \" -- \" → en. The em rule can't be shadowed by\n // the en rule because the en rule requires whitespace before \"--\".\n replaceRule(/\\s(---)\\s$/, '—'),\n replaceRule(/\\s(--)\\s$/, '–'),\n // Ellipsis.\n replaceRule(/\\.\\.\\.$/, '…'),\n // Smart quotes: opening after start/space/bracket, closing elsewhere.\n replaceRule(/(?:^|[\\s{[(<'\"‘“])(\")$/, '“'),\n replaceRule(/\"$/, '”'),\n replaceRule(/(?:^|[\\s{[(<'\"‘“])(')$/, '‘'),\n replaceRule(/'$/, '’'),\n ];\n}\n\nexport interface InputRulesOptions {\n /** Include the autocorrect/typography rules. Defaults to true. */\n textTransform?: boolean;\n}\n\n/**\n * Markdown mark shortcut: typing `<delim>text<delim>` applies the mark and\n * strips the delimiters. The matched range (delimiters and all) is replaced\n * with the marked content, so the final typed delimiter never lands.\n */\nfunction markInputRule(delim: string, markType: MarkType): InputRule {\n const escaped = escapeRegex(delim);\n const inner = escapeRegex(delim[0]);\n const regexp = new RegExp(\n `(?:^|\\\\s)${escaped}([^${inner}\\\\s](?:[^${inner}]*[^${inner}\\\\s])?)${escaped}$`\n );\n return new InputRule(regexp, (state, match, start, end) => {\n const content = match[1];\n const delimStart = start + match[0].indexOf(delim);\n const tr = state.tr;\n tr.delete(delimStart, end);\n tr.insertText(content, delimStart);\n tr.addMark(delimStart, delimStart + content.length, markType.create());\n tr.removeStoredMark(markType);\n return tr;\n });\n}\n\n/**\n * Autolink: typing a space after a bare URL (`https://…`, `http://…` or\n * `www.…`) converts it into a link. Trailing punctuation stays outside the\n * link, code spans and existing links are left alone, and Backspace\n * (undoInputRule) reverts the conversion like any other input rule.\n */\nfunction linkifyRule(schema: Schema): InputRule {\n const linkType = schema.marks.link;\n const regexp = /(?:^|\\s)((?:https?:\\/\\/|www\\.)[^\\s]*[^\\s.,:;!?'\")\\]}])\\s$/i;\n return new InputRule(regexp, (state, match, start, end) => {\n const url = match[1];\n const urlStart = start + match[0].indexOf(url);\n const urlEnd = urlStart + url.length;\n if (state.doc.rangeHasMark(urlStart, urlEnd, linkType)) return null;\n if (state.doc.rangeHasMark(urlStart, urlEnd, schema.marks.code)) return null;\n const href = /^www\\./i.test(url) ? `https://${url}` : url;\n const tr = state.tr;\n tr.addMark(urlStart, urlEnd, linkType.create({ href }));\n tr.removeStoredMark(linkType);\n tr.insertText(' ', end);\n return tr;\n });\n}\n\n/**\n * Markdown-style typing shortcuts: block rules plus inline mark rules\n * (**bold**, *italic*, `code`, ~~strike~~), and (unless disabled) the\n * typography autocorrect rules.\n */\nexport function buildInputRules(schema: Schema, options: InputRulesOptions = {}): Plugin {\n const transforms = options.textTransform === false ? [] : textTransformRules();\n return inputRules({\n rules: [\n ...transforms,\n // \"# \" … \"###### \" → heading\n textblockTypeInputRule(\n new RegExp('^(#{1,6})\\\\s$'),\n schema.nodes.heading,\n match => ({ level: match[1].length })\n ),\n // \"> \" → blockquote\n wrappingInputRule(/^\\s*>\\s$/, schema.nodes.blockquote),\n // \"- \" or \"* \" → bullet list\n wrappingInputRule(/^\\s*([-*])\\s$/, schema.nodes.bullet_list),\n // \"1. \" → ordered list\n wrappingInputRule(\n /^(\\d+)\\.\\s$/,\n schema.nodes.ordered_list,\n match => ({ order: +match[1] }),\n (match, node) => node.childCount + node.attrs.order === +match[1]\n ),\n // \"```\" → code block\n textblockTypeInputRule(/^```$/, schema.nodes.code_block),\n // \"[] \" or \"[ ] \" → checklist\n wrappingInputRule(/^\\s*\\[[ ]?\\]\\s$/, schema.nodes.task_list),\n // Inline marks. Bold before italic so '**' is never read as italic;\n // strike (~~) before subscript (~) so a double tilde is never a single.\n markInputRule('**', schema.marks.bold),\n markInputRule('*', schema.marks.italic),\n markInputRule('~~', schema.marks.strike),\n markInputRule('~', schema.marks.subscript),\n markInputRule('^', schema.marks.superscript),\n markInputRule('`', schema.marks.code),\n // Bare URL + space → link.\n linkifyRule(schema),\n ],\n });\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Plugin } from 'prosemirror-state';
|
|
2
|
+
import { Schema } from 'prosemirror-model';
|
|
3
|
+
export interface KeymapOptions {
|
|
4
|
+
/** Invoked on Mod-k so the host can open its link editor UI. */
|
|
5
|
+
onLinkShortcut?: () => void;
|
|
6
|
+
/** Invoked on Mod-f so the host can open its find & replace bar. */
|
|
7
|
+
onFindShortcut?: () => void;
|
|
8
|
+
/** Invoked on Mod-/ so the host can open its shortcut help dialog. */
|
|
9
|
+
onShortcutHelp?: () => void;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Editor keymap. Returned as two plugins: feature bindings first, then the
|
|
13
|
+
* ProseMirror base keymap as fallback.
|
|
14
|
+
*/
|
|
15
|
+
export declare function buildKeymapPlugins(schema: Schema, options?: KeymapOptions): Plugin[];
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { keymap } from 'prosemirror-keymap';
|
|
2
|
+
import { baseKeymap, chainCommands, exitCode } from 'prosemirror-commands';
|
|
3
|
+
import { undo, redo } from 'prosemirror-history';
|
|
4
|
+
import { undoInputRule } from 'prosemirror-inputrules';
|
|
5
|
+
import { splitListItem, liftListItem, sinkListItem, } from 'prosemirror-schema-list';
|
|
6
|
+
import { getCommand } from './commands';
|
|
7
|
+
import { plainTextSlice } from './plugins/paste';
|
|
8
|
+
const isMac = typeof navigator !== 'undefined' && /Mac|iP(hone|[oa]d)/.test(navigator.platform);
|
|
9
|
+
/**
|
|
10
|
+
* Editor keymap. Returned as two plugins: feature bindings first, then the
|
|
11
|
+
* ProseMirror base keymap as fallback.
|
|
12
|
+
*/
|
|
13
|
+
export function buildKeymapPlugins(schema, options = {}) {
|
|
14
|
+
const keys = {};
|
|
15
|
+
keys['Mod-z'] = undo;
|
|
16
|
+
keys['Shift-Mod-z'] = redo;
|
|
17
|
+
if (!isMac)
|
|
18
|
+
keys['Mod-y'] = redo;
|
|
19
|
+
keys['Backspace'] = undoInputRule;
|
|
20
|
+
keys['Mod-b'] = (state, dispatch, view) => getCommand(state, 'bold')(state, dispatch, view);
|
|
21
|
+
keys['Mod-i'] = (state, dispatch, view) => getCommand(state, 'italic')(state, dispatch, view);
|
|
22
|
+
keys['Mod-u'] = (state, dispatch, view) => getCommand(state, 'underline')(state, dispatch, view);
|
|
23
|
+
keys['Shift-Mod-x'] = (state, dispatch, view) => getCommand(state, 'strike')(state, dispatch, view);
|
|
24
|
+
// Google Docs convention: Ctrl+, subscript, Ctrl+. superscript.
|
|
25
|
+
keys['Mod-,'] = (state, dispatch, view) => getCommand(state, 'subscript')(state, dispatch, view);
|
|
26
|
+
keys['Mod-.'] = (state, dispatch, view) => getCommand(state, 'superscript')(state, dispatch, view);
|
|
27
|
+
// Paste without formatting. Reads the clipboard directly so the result is
|
|
28
|
+
// plain text regardless of the persistent toggle; falls back to the
|
|
29
|
+
// browser default when the async Clipboard API is unavailable.
|
|
30
|
+
keys['Shift-Mod-v'] = (_state, _dispatch, view) => {
|
|
31
|
+
if (!view || typeof navigator === 'undefined' || !navigator.clipboard?.readText) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
navigator.clipboard
|
|
35
|
+
.readText()
|
|
36
|
+
.then(text => {
|
|
37
|
+
if (!text || !view)
|
|
38
|
+
return;
|
|
39
|
+
const slice = plainTextSlice(view.state.schema, text);
|
|
40
|
+
view.dispatch(view.state.tr.replaceSelection(slice).scrollIntoView());
|
|
41
|
+
})
|
|
42
|
+
.catch(() => {
|
|
43
|
+
/* clipboard denied — silently no-op */
|
|
44
|
+
});
|
|
45
|
+
return true;
|
|
46
|
+
};
|
|
47
|
+
keys['Shift-Ctrl-0'] = (state, dispatch, view) => getCommand(state, 'paragraph')(state, dispatch, view);
|
|
48
|
+
for (let level = 1; level <= 6; level += 1) {
|
|
49
|
+
keys[`Shift-Ctrl-${level}`] = (state, dispatch, view) => getCommand(state, 'heading', { level })(state, dispatch, view);
|
|
50
|
+
}
|
|
51
|
+
keys['Shift-Mod-7'] = (state, dispatch, view) => getCommand(state, 'orderedList')(state, dispatch, view);
|
|
52
|
+
keys['Shift-Mod-8'] = (state, dispatch, view) => getCommand(state, 'bulletList')(state, dispatch, view);
|
|
53
|
+
keys['Shift-Mod-9'] = (state, dispatch, view) => getCommand(state, 'blockquote')(state, dispatch, view);
|
|
54
|
+
keys['Mod-Alt-c'] = (state, dispatch, view) => getCommand(state, 'codeBlock')(state, dispatch, view);
|
|
55
|
+
// Google Docs convention: Mod-] / Mod-[ indent and outdent.
|
|
56
|
+
keys['Mod-]'] = (state, dispatch, view) => getCommand(state, 'indent')(state, dispatch, view);
|
|
57
|
+
keys['Mod-['] = (state, dispatch, view) => getCommand(state, 'outdent')(state, dispatch, view);
|
|
58
|
+
// New task items always start unchecked.
|
|
59
|
+
keys['Enter'] = chainCommands(splitListItem(schema.nodes.task_item, { checked: false }), splitListItem(schema.nodes.list_item));
|
|
60
|
+
keys['Tab'] = chainCommands(sinkListItem(schema.nodes.task_item), sinkListItem(schema.nodes.list_item));
|
|
61
|
+
keys['Shift-Tab'] = chainCommands(liftListItem(schema.nodes.task_item), liftListItem(schema.nodes.list_item));
|
|
62
|
+
// Hard break; exitCode first so breaks escape code marks cleanly.
|
|
63
|
+
const br = chainCommands(exitCode, (state, dispatch) => {
|
|
64
|
+
if (dispatch) {
|
|
65
|
+
dispatch(state.tr.replaceSelectionWith(schema.nodes.hard_break.create()).scrollIntoView());
|
|
66
|
+
}
|
|
67
|
+
return true;
|
|
68
|
+
});
|
|
69
|
+
keys['Shift-Enter'] = br;
|
|
70
|
+
keys['Mod-Enter'] = br;
|
|
71
|
+
if (options.onLinkShortcut) {
|
|
72
|
+
const open = options.onLinkShortcut;
|
|
73
|
+
keys['Mod-k'] = () => {
|
|
74
|
+
open();
|
|
75
|
+
return true;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
if (options.onFindShortcut) {
|
|
79
|
+
const openFind = options.onFindShortcut;
|
|
80
|
+
keys['Mod-f'] = () => {
|
|
81
|
+
openFind();
|
|
82
|
+
return true;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
if (options.onShortcutHelp) {
|
|
86
|
+
const openHelp = options.onShortcutHelp;
|
|
87
|
+
keys['Mod-/'] = () => {
|
|
88
|
+
openHelp();
|
|
89
|
+
return true;
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
return [keymap(keys), keymap(baseKeymap)];
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=keymap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keymap.js","sourceRoot":"","sources":["../../../../src/nile-wysiwyg-editor/engine/keymap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EACL,aAAa,EACb,YAAY,EACZ,YAAY,GACb,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,MAAM,KAAK,GACT,OAAO,SAAS,KAAK,WAAW,IAAI,oBAAoB,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;AAWpF;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAc,EAAE,UAAyB,EAAE;IAC5E,MAAM,IAAI,GAA4B,EAAE,CAAC;IAEzC,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;IACrB,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC;IAC3B,IAAI,CAAC,KAAK;QAAE,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;IACjC,IAAI,CAAC,WAAW,CAAC,GAAG,aAAa,CAAC;IAElC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,CACxC,UAAU,CAAC,KAAK,EAAE,MAAM,CAAE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,IAAI,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["import { keymap } from 'prosemirror-keymap';\nimport { baseKeymap, chainCommands, exitCode } from 'prosemirror-commands';\nimport { undo, redo } from 'prosemirror-history';\nimport { undoInputRule } from 'prosemirror-inputrules';\nimport {\n splitListItem,\n liftListItem,\n sinkListItem,\n} from 'prosemirror-schema-list';\nimport { Command, Plugin } from 'prosemirror-state';\nimport { Schema } from 'prosemirror-model';\nimport { getCommand } from './commands';\nimport { plainTextSlice } from './plugins/paste';\n\nconst isMac =\n typeof navigator !== 'undefined' && /Mac|iP(hone|[oa]d)/.test(navigator.platform);\n\nexport interface KeymapOptions {\n /** Invoked on Mod-k so the host can open its link editor UI. */\n onLinkShortcut?: () => void;\n /** Invoked on Mod-f so the host can open its find & replace bar. */\n onFindShortcut?: () => void;\n /** Invoked on Mod-/ so the host can open its shortcut help dialog. */\n onShortcutHelp?: () => void;\n}\n\n/**\n * Editor keymap. Returned as two plugins: feature bindings first, then the\n * ProseMirror base keymap as fallback.\n */\nexport function buildKeymapPlugins(schema: Schema, options: KeymapOptions = {}): Plugin[] {\n const keys: Record<string, Command> = {};\n\n keys['Mod-z'] = undo;\n keys['Shift-Mod-z'] = redo;\n if (!isMac) keys['Mod-y'] = redo;\n keys['Backspace'] = undoInputRule;\n\n keys['Mod-b'] = (state, dispatch, view) =>\n getCommand(state, 'bold')!(state, dispatch, view);\n keys['Mod-i'] = (state, dispatch, view) =>\n getCommand(state, 'italic')!(state, dispatch, view);\n keys['Mod-u'] = (state, dispatch, view) =>\n getCommand(state, 'underline')!(state, dispatch, view);\n keys['Shift-Mod-x'] = (state, dispatch, view) =>\n getCommand(state, 'strike')!(state, dispatch, view);\n // Google Docs convention: Ctrl+, subscript, Ctrl+. superscript.\n keys['Mod-,'] = (state, dispatch, view) =>\n getCommand(state, 'subscript')!(state, dispatch, view);\n keys['Mod-.'] = (state, dispatch, view) =>\n getCommand(state, 'superscript')!(state, dispatch, view);\n\n // Paste without formatting. Reads the clipboard directly so the result is\n // plain text regardless of the persistent toggle; falls back to the\n // browser default when the async Clipboard API is unavailable.\n keys['Shift-Mod-v'] = (_state, _dispatch, view) => {\n if (!view || typeof navigator === 'undefined' || !navigator.clipboard?.readText) {\n return false;\n }\n navigator.clipboard\n .readText()\n .then(text => {\n if (!text || !view) return;\n const slice = plainTextSlice(view.state.schema, text);\n view.dispatch(view.state.tr.replaceSelection(slice).scrollIntoView());\n })\n .catch(() => {\n /* clipboard denied — silently no-op */\n });\n return true;\n };\n\n keys['Shift-Ctrl-0'] = (state, dispatch, view) =>\n getCommand(state, 'paragraph')!(state, dispatch, view);\n for (let level = 1; level <= 6; level += 1) {\n keys[`Shift-Ctrl-${level}`] = (state, dispatch, view) =>\n getCommand(state, 'heading', { level })!(state, dispatch, view);\n }\n\n keys['Shift-Mod-7'] = (state, dispatch, view) =>\n getCommand(state, 'orderedList')!(state, dispatch, view);\n keys['Shift-Mod-8'] = (state, dispatch, view) =>\n getCommand(state, 'bulletList')!(state, dispatch, view);\n keys['Shift-Mod-9'] = (state, dispatch, view) =>\n getCommand(state, 'blockquote')!(state, dispatch, view);\n keys['Mod-Alt-c'] = (state, dispatch, view) =>\n getCommand(state, 'codeBlock')!(state, dispatch, view);\n\n // Google Docs convention: Mod-] / Mod-[ indent and outdent.\n keys['Mod-]'] = (state, dispatch, view) =>\n getCommand(state, 'indent')!(state, dispatch, view);\n keys['Mod-['] = (state, dispatch, view) =>\n getCommand(state, 'outdent')!(state, dispatch, view);\n\n // New task items always start unchecked.\n keys['Enter'] = chainCommands(\n splitListItem(schema.nodes.task_item, { checked: false }),\n splitListItem(schema.nodes.list_item)\n );\n keys['Tab'] = chainCommands(\n sinkListItem(schema.nodes.task_item),\n sinkListItem(schema.nodes.list_item)\n );\n keys['Shift-Tab'] = chainCommands(\n liftListItem(schema.nodes.task_item),\n liftListItem(schema.nodes.list_item)\n );\n\n // Hard break; exitCode first so breaks escape code marks cleanly.\n const br: Command = chainCommands(exitCode, (state, dispatch) => {\n if (dispatch) {\n dispatch(\n state.tr.replaceSelectionWith(schema.nodes.hard_break.create()).scrollIntoView()\n );\n }\n return true;\n });\n keys['Shift-Enter'] = br;\n keys['Mod-Enter'] = br;\n\n if (options.onLinkShortcut) {\n const open = options.onLinkShortcut;\n keys['Mod-k'] = () => {\n open();\n return true;\n };\n }\n\n if (options.onFindShortcut) {\n const openFind = options.onFindShortcut;\n keys['Mod-f'] = () => {\n openFind();\n return true;\n };\n }\n\n if (options.onShortcutHelp) {\n const openHelp = options.onShortcutHelp;\n keys['Mod-/'] = () => {\n openHelp();\n return true;\n };\n }\n\n return [keymap(keys), keymap(baseKeymap)];\n}\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Markdown → HTML conversion, the import counterpart of ./markdown
|
|
3
|
+
* (docToMarkdown). Dependency-free and scoped to the same structural subset
|
|
4
|
+
* the serializer emits: headings, blockquotes, bullet/ordered/task lists
|
|
5
|
+
* (nested), fenced code blocks, GFM tables, horizontal rules, and the inline
|
|
6
|
+
* marks (**bold**, *italic*, ~~strike~~, `code`, [links](…), images).
|
|
7
|
+
*
|
|
8
|
+
* The output is intentionally plain HTML that the schema's parseDOM rules
|
|
9
|
+
* understand (e.g. <pre data-language>, <ul data-task-list>), and every
|
|
10
|
+
* consumer feeds it through htmlToDoc/htmlToSlice — so the schema and the
|
|
11
|
+
* sanitizer stay the single source of truth for what lands in the document.
|
|
12
|
+
*/
|
|
13
|
+
/** Inline Markdown → HTML. Code spans are lifted out first to stay literal. */
|
|
14
|
+
export declare function inlineToHtml(source: string): string;
|
|
15
|
+
/** Parses a Markdown string into schema-compatible HTML. */
|
|
16
|
+
export declare function markdownToHtml(markdown: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Conservative sniff for "this plain text is probably Markdown": one block
|
|
19
|
+
* construct or one unambiguous inline construct is required. HTML-looking
|
|
20
|
+
* text is never treated as Markdown.
|
|
21
|
+
*/
|
|
22
|
+
export declare function looksLikeMarkdown(text: string): boolean;
|