@prosekit/extensions 0.11.4 → 0.11.6
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/dist/commit/style.css +2 -0
- package/dist/commit/style.css.map +1 -0
- package/dist/commit/style.js +1 -0
- package/dist/drop-indicator-E7nCfdnR.js +58 -0
- package/dist/drop-indicator-E7nCfdnR.js.map +1 -0
- package/dist/enter-rule-RdhEA900.js +2 -1
- package/dist/enter-rule-RdhEA900.js.map +1 -0
- package/dist/file-DVUhe5KJ.js +134 -0
- package/dist/file-DVUhe5KJ.js.map +1 -0
- package/dist/gap-cursor/style.css +2 -0
- package/dist/gap-cursor/style.css.map +1 -0
- package/dist/gap-cursor/style.js +1 -0
- package/dist/index-DY6lIIYV.d.ts +134 -0
- package/dist/index-DY6lIIYV.d.ts.map +1 -0
- package/dist/{input-rule-Gji4N7Oe.js → input-rule-B17tpW4m.js} +3 -3
- package/dist/input-rule-B17tpW4m.js.map +1 -0
- package/dist/list/style.css +2 -0
- package/dist/list/style.css.map +1 -0
- package/dist/list/style.js +1 -0
- package/dist/loro/style.css +2 -0
- package/dist/loro/style.css.map +1 -0
- package/dist/loro/style.js +1 -0
- package/dist/{mark-rule-D7zaa32n.js → mark-rule-CGmswjQ_.js} +3 -3
- package/dist/mark-rule-CGmswjQ_.js.map +1 -0
- package/dist/{paste-rule-Cca3n5TA.js → paste-rule-BIztzELg.js} +5 -15
- package/dist/paste-rule-BIztzELg.js.map +1 -0
- package/dist/placeholder/style.css +2 -0
- package/dist/placeholder/style.css.map +1 -0
- package/dist/placeholder/style.js +1 -0
- package/dist/prosekit-extensions-autocomplete.d.ts +2 -1
- package/dist/prosekit-extensions-autocomplete.d.ts.map +1 -0
- package/dist/prosekit-extensions-autocomplete.js +2 -9
- package/dist/prosekit-extensions-autocomplete.js.map +1 -0
- package/dist/prosekit-extensions-blockquote.d.ts +2 -1
- package/dist/prosekit-extensions-blockquote.d.ts.map +1 -0
- package/dist/prosekit-extensions-blockquote.js +4 -4
- package/dist/prosekit-extensions-blockquote.js.map +1 -0
- package/dist/prosekit-extensions-bold.d.ts +2 -1
- package/dist/prosekit-extensions-bold.d.ts.map +1 -0
- package/dist/prosekit-extensions-bold.js +3 -2
- package/dist/prosekit-extensions-bold.js.map +1 -0
- package/dist/prosekit-extensions-code-block.d.ts +3 -2
- package/dist/prosekit-extensions-code-block.d.ts.map +1 -0
- package/dist/prosekit-extensions-code-block.js +5 -6
- package/dist/prosekit-extensions-code-block.js.map +1 -0
- package/dist/prosekit-extensions-code.d.ts +2 -1
- package/dist/prosekit-extensions-code.d.ts.map +1 -0
- package/dist/prosekit-extensions-code.js +3 -2
- package/dist/prosekit-extensions-code.js.map +1 -0
- package/dist/prosekit-extensions-commit.d.ts +2 -1
- package/dist/prosekit-extensions-commit.d.ts.map +1 -0
- package/dist/prosekit-extensions-commit.js +11 -13
- package/dist/prosekit-extensions-commit.js.map +1 -0
- package/dist/prosekit-extensions-doc.d.ts +2 -1
- package/dist/prosekit-extensions-doc.d.ts.map +1 -0
- package/dist/prosekit-extensions-doc.js +2 -1
- package/dist/prosekit-extensions-doc.js.map +1 -0
- package/dist/prosekit-extensions-drop-cursor.d.ts +2 -1
- package/dist/prosekit-extensions-drop-cursor.d.ts.map +1 -0
- package/dist/prosekit-extensions-drop-cursor.js +2 -1
- package/dist/prosekit-extensions-drop-cursor.js.map +1 -0
- package/dist/prosekit-extensions-drop-indicator.d.ts +5 -107
- package/dist/prosekit-extensions-drop-indicator.d.ts.map +1 -0
- package/dist/prosekit-extensions-drop-indicator.js +1 -1
- package/dist/prosekit-extensions-enter-rule.d.ts +2 -1
- package/dist/prosekit-extensions-enter-rule.d.ts.map +1 -0
- package/dist/prosekit-extensions-file.d.ts +2 -125
- package/dist/prosekit-extensions-file.js +1 -139
- package/dist/prosekit-extensions-gap-cursor.d.ts +2 -2
- package/dist/prosekit-extensions-gap-cursor.d.ts.map +1 -0
- package/dist/prosekit-extensions-gap-cursor.js +2 -1
- package/dist/prosekit-extensions-gap-cursor.js.map +1 -0
- package/dist/prosekit-extensions-hard-break.d.ts +2 -5
- package/dist/prosekit-extensions-hard-break.d.ts.map +1 -0
- package/dist/prosekit-extensions-hard-break.js +2 -1
- package/dist/prosekit-extensions-hard-break.js.map +1 -0
- package/dist/prosekit-extensions-heading.d.ts +2 -1
- package/dist/prosekit-extensions-heading.d.ts.map +1 -0
- package/dist/prosekit-extensions-heading.js +5 -6
- package/dist/prosekit-extensions-heading.js.map +1 -0
- package/dist/prosekit-extensions-horizontal-rule.d.ts +2 -1
- package/dist/prosekit-extensions-horizontal-rule.d.ts.map +1 -0
- package/dist/prosekit-extensions-horizontal-rule.js +5 -6
- package/dist/prosekit-extensions-horizontal-rule.js.map +1 -0
- package/dist/prosekit-extensions-image.d.ts +80 -3
- package/dist/prosekit-extensions-image.d.ts.map +1 -0
- package/dist/prosekit-extensions-image.js +90 -10
- package/dist/prosekit-extensions-image.js.map +1 -0
- package/dist/prosekit-extensions-input-rule.d.ts +2 -1
- package/dist/prosekit-extensions-input-rule.d.ts.map +1 -0
- package/dist/prosekit-extensions-input-rule.js +1 -1
- package/dist/prosekit-extensions-italic.d.ts +2 -1
- package/dist/prosekit-extensions-italic.d.ts.map +1 -0
- package/dist/prosekit-extensions-italic.js +3 -2
- package/dist/prosekit-extensions-italic.js.map +1 -0
- package/dist/prosekit-extensions-link.d.ts +2 -1
- package/dist/prosekit-extensions-link.d.ts.map +1 -0
- package/dist/prosekit-extensions-link.js +6 -5
- package/dist/prosekit-extensions-link.js.map +1 -0
- package/dist/prosekit-extensions-list.d.ts +22 -21
- package/dist/prosekit-extensions-list.d.ts.map +1 -0
- package/dist/prosekit-extensions-list.js +7 -8
- package/dist/prosekit-extensions-list.js.map +1 -0
- package/dist/prosekit-extensions-loro.d.ts +14 -13
- package/dist/prosekit-extensions-loro.d.ts.map +1 -0
- package/dist/prosekit-extensions-loro.js +2 -1
- package/dist/prosekit-extensions-loro.js.map +1 -0
- package/dist/prosekit-extensions-mark-rule.d.ts +2 -1
- package/dist/prosekit-extensions-mark-rule.d.ts.map +1 -0
- package/dist/prosekit-extensions-mark-rule.js +1 -1
- package/dist/prosekit-extensions-mention.d.ts +2 -1
- package/dist/prosekit-extensions-mention.d.ts.map +1 -0
- package/dist/prosekit-extensions-mention.js +2 -1
- package/dist/prosekit-extensions-mention.js.map +1 -0
- package/dist/prosekit-extensions-mod-click-prevention.d.ts +2 -1
- package/dist/prosekit-extensions-mod-click-prevention.d.ts.map +1 -0
- package/dist/prosekit-extensions-mod-click-prevention.js +2 -1
- package/dist/prosekit-extensions-mod-click-prevention.js.map +1 -0
- package/dist/prosekit-extensions-paragraph.d.ts +2 -5
- package/dist/prosekit-extensions-paragraph.d.ts.map +1 -0
- package/dist/prosekit-extensions-paragraph.js +2 -1
- package/dist/prosekit-extensions-paragraph.js.map +1 -0
- package/dist/prosekit-extensions-paste-rule.d.ts +2 -1
- package/dist/prosekit-extensions-paste-rule.d.ts.map +1 -0
- package/dist/prosekit-extensions-paste-rule.js +1 -1
- package/dist/prosekit-extensions-placeholder.d.ts +2 -1
- package/dist/prosekit-extensions-placeholder.d.ts.map +1 -0
- package/dist/prosekit-extensions-placeholder.js +5 -5
- package/dist/prosekit-extensions-placeholder.js.map +1 -0
- package/dist/prosekit-extensions-readonly.d.ts +2 -1
- package/dist/prosekit-extensions-readonly.d.ts.map +1 -0
- package/dist/prosekit-extensions-readonly.js +2 -1
- package/dist/prosekit-extensions-readonly.js.map +1 -0
- package/dist/prosekit-extensions-search.d.ts +2 -1
- package/dist/prosekit-extensions-search.d.ts.map +1 -0
- package/dist/prosekit-extensions-search.js +3 -3
- package/dist/prosekit-extensions-search.js.map +1 -0
- package/dist/prosekit-extensions-strike.d.ts +2 -1
- package/dist/prosekit-extensions-strike.d.ts.map +1 -0
- package/dist/prosekit-extensions-strike.js +3 -2
- package/dist/prosekit-extensions-strike.js.map +1 -0
- package/dist/prosekit-extensions-table.d.ts +47 -114
- package/dist/prosekit-extensions-table.d.ts.map +1 -0
- package/dist/prosekit-extensions-table.js +2 -2
- package/dist/prosekit-extensions-text-align.d.ts +2 -1
- package/dist/prosekit-extensions-text-align.d.ts.map +1 -0
- package/dist/prosekit-extensions-text-align.js +2 -1
- package/dist/prosekit-extensions-text-align.js.map +1 -0
- package/dist/prosekit-extensions-text.d.ts +2 -1
- package/dist/prosekit-extensions-text.d.ts.map +1 -0
- package/dist/prosekit-extensions-text.js +2 -1
- package/dist/prosekit-extensions-text.js.map +1 -0
- package/dist/prosekit-extensions-underline.d.ts +2 -1
- package/dist/prosekit-extensions-underline.d.ts.map +1 -0
- package/dist/prosekit-extensions-underline.js +2 -1
- package/dist/prosekit-extensions-underline.js.map +1 -0
- package/dist/prosekit-extensions-virtual-selection.d.ts +2 -1
- package/dist/prosekit-extensions-virtual-selection.d.ts.map +1 -0
- package/dist/prosekit-extensions-virtual-selection.js +3 -3
- package/dist/prosekit-extensions-virtual-selection.js.map +1 -0
- package/dist/prosekit-extensions-yjs.d.ts +2 -1
- package/dist/prosekit-extensions-yjs.d.ts.map +1 -0
- package/dist/prosekit-extensions-yjs.js +2 -1
- package/dist/prosekit-extensions-yjs.js.map +1 -0
- package/dist/prosekit-extensions.js +1 -0
- package/dist/search/style.css +2 -0
- package/dist/search/style.css.map +1 -0
- package/dist/search/style.js +1 -0
- package/dist/{shiki-highlighter-chunk-DSPM0T27.d.ts → shiki-highlighter-chunk-Cwu1Jr9o.d.ts} +2 -1
- package/dist/shiki-highlighter-chunk-Cwu1Jr9o.d.ts.map +1 -0
- package/dist/shiki-highlighter-chunk.d.ts +1 -1
- package/dist/shiki-highlighter-chunk.js +3 -5
- package/dist/shiki-highlighter-chunk.js.map +1 -0
- package/dist/table/style.css +2 -0
- package/dist/table/style.css.map +1 -0
- package/dist/table/style.js +1 -0
- package/dist/table-BNwuK7xg.js +297 -0
- package/dist/table-BNwuK7xg.js.map +1 -0
- package/dist/virtual-selection/style.css +2 -0
- package/dist/virtual-selection/style.css.map +1 -0
- package/dist/virtual-selection/style.js +1 -0
- package/dist/yjs/style.css +2 -0
- package/dist/yjs/style.css.map +1 -0
- package/dist/yjs/style.js +1 -0
- package/package.json +12 -10
- package/src/autocomplete/autocomplete-helpers.ts +74 -0
- package/src/autocomplete/autocomplete-plugin.ts +186 -0
- package/src/autocomplete/autocomplete-rule.ts +117 -0
- package/src/autocomplete/autocomplete.spec.ts +132 -0
- package/src/autocomplete/autocomplete.ts +29 -0
- package/src/autocomplete/index.ts +9 -0
- package/src/blockquote/blockquote-commands.ts +32 -0
- package/src/blockquote/blockquote-input-rule.ts +14 -0
- package/src/blockquote/blockquote-keymap.spec.ts +45 -0
- package/src/blockquote/blockquote-keymap.ts +31 -0
- package/src/blockquote/blockquote-spec.ts +24 -0
- package/src/blockquote/blockquote.ts +34 -0
- package/src/blockquote/index.ts +14 -0
- package/src/bold/bold-commands.ts +23 -0
- package/src/bold/bold-input-rule.spec.ts +51 -0
- package/src/bold/bold-input-rule.ts +18 -0
- package/src/bold/bold-keymap.ts +14 -0
- package/src/bold/bold-spec.ts +53 -0
- package/src/bold/bold.ts +32 -0
- package/src/bold/index.ts +14 -0
- package/src/code/code-commands.ts +23 -0
- package/src/code/code-input-rule.ts +18 -0
- package/src/code/code-keymap.ts +14 -0
- package/src/code/code-spec.ts +28 -0
- package/src/code/code.ts +32 -0
- package/src/code/index.ts +14 -0
- package/src/code-block/code-block-commands.ts +44 -0
- package/src/code-block/code-block-highlight.ts +40 -0
- package/src/code-block/code-block-input-rule.ts +36 -0
- package/src/code-block/code-block-keymap.ts +61 -0
- package/src/code-block/code-block-shiki.ts +58 -0
- package/src/code-block/code-block-spec.spec.ts +164 -0
- package/src/code-block/code-block-spec.ts +71 -0
- package/src/code-block/code-block-types.ts +8 -0
- package/src/code-block/code-block.ts +46 -0
- package/src/code-block/index.ts +32 -0
- package/src/code-block/shiki-bundle.ts +8 -0
- package/src/code-block/shiki-highlighter-chunk.ts +84 -0
- package/src/code-block/shiki-highlighter.ts +22 -0
- package/src/code-block/shiki-parser.ts +36 -0
- package/src/commit/index.ts +330 -0
- package/src/commit/style.css +7 -0
- package/src/doc/index.ts +21 -0
- package/src/drop-cursor/drop-cursor.ts +46 -0
- package/src/drop-cursor/index.ts +5 -0
- package/src/drop-indicator/drop-indicator-facet.ts +62 -0
- package/src/drop-indicator/drop-indicator.ts +35 -0
- package/src/drop-indicator/index.ts +14 -0
- package/src/enter-rule/index.ts +241 -0
- package/src/file/file-drop-handler.ts +75 -0
- package/src/file/file-paste-handler.spec.ts +95 -0
- package/src/file/file-paste-handler.ts +59 -0
- package/src/file/file-upload.ts +140 -0
- package/src/file/helpers.ts +39 -0
- package/src/file/index.ts +16 -0
- package/src/gap-cursor/gap-cursor.ts +28 -0
- package/src/gap-cursor/index.ts +4 -0
- package/src/gap-cursor/style.css +25 -0
- package/src/hard-break/hard-break-commands.ts +31 -0
- package/src/hard-break/hard-break-keymap.spec.ts +45 -0
- package/src/hard-break/hard-break-keymap.ts +16 -0
- package/src/hard-break/hard-break-spec.ts +31 -0
- package/src/hard-break/hard-break.ts +32 -0
- package/src/hard-break/index.ts +13 -0
- package/src/heading/heading-commands.ts +37 -0
- package/src/heading/heading-input-rule.ts +22 -0
- package/src/heading/heading-keymap.spec.ts +53 -0
- package/src/heading/heading-keymap.ts +40 -0
- package/src/heading/heading-spec.ts +39 -0
- package/src/heading/heading-types.ts +3 -0
- package/src/heading/heading.ts +34 -0
- package/src/heading/index.ts +15 -0
- package/src/horizontal-rule/horizontal-rule-commands.spec.ts +61 -0
- package/src/horizontal-rule/horizontal-rule-commands.ts +37 -0
- package/src/horizontal-rule/horizontal-rule-input-rule.spec.ts +61 -0
- package/src/horizontal-rule/horizontal-rule-input-rule.ts +26 -0
- package/src/horizontal-rule/horizontal-rule-spec.ts +21 -0
- package/src/horizontal-rule/horizontal-rule.ts +29 -0
- package/src/horizontal-rule/index.ts +14 -0
- package/src/image/image-commands.ts +36 -0
- package/src/image/image-spec.ts +72 -0
- package/src/image/image-upload-handler.ts +156 -0
- package/src/image/image.ts +25 -0
- package/src/image/index.ts +22 -0
- package/src/index.ts +1 -0
- package/src/input-rule/index.ts +237 -0
- package/src/italic/index.ts +14 -0
- package/src/italic/italic-commands.spec.ts +75 -0
- package/src/italic/italic-commands.ts +23 -0
- package/src/italic/italic-input-rule.spec.ts +25 -0
- package/src/italic/italic-input-rule.ts +18 -0
- package/src/italic/italic-keymap.ts +14 -0
- package/src/italic/italic-spec.ts +35 -0
- package/src/italic/italic.ts +34 -0
- package/src/link/index.spec.ts +88 -0
- package/src/link/index.ts +156 -0
- package/src/link/link-paste-rule.spec.ts +194 -0
- package/src/link/link-paste-rule.ts +22 -0
- package/src/link/link-regex.spec.ts +82 -0
- package/src/link/link-regex.ts +79 -0
- package/src/link/link-types.ts +8 -0
- package/src/list/index.ts +25 -0
- package/src/list/list-commands.ts +61 -0
- package/src/list/list-drop-indicator.ts +37 -0
- package/src/list/list-input-rules.ts +14 -0
- package/src/list/list-keymap.spec.ts +39 -0
- package/src/list/list-keymap.ts +48 -0
- package/src/list/list-plugins.ts +35 -0
- package/src/list/list-serializer.ts +38 -0
- package/src/list/list-spec.ts +60 -0
- package/src/list/list-types.spec.ts +10 -0
- package/src/list/list-types.ts +23 -0
- package/src/list/list.spec.ts +134 -0
- package/src/list/list.ts +38 -0
- package/src/list/style.css +128 -0
- package/src/loro/index.ts +17 -0
- package/src/loro/loro-commands.ts +27 -0
- package/src/loro/loro-cursor-plugin.ts +28 -0
- package/src/loro/loro-keymap.ts +23 -0
- package/src/loro/loro-sync-plugin.ts +14 -0
- package/src/loro/loro-undo-plugin.ts +12 -0
- package/src/loro/loro.ts +75 -0
- package/src/loro/style.css +33 -0
- package/src/mark-rule/apply.ts +129 -0
- package/src/mark-rule/index.ts +2 -0
- package/src/mark-rule/mark-rule.spec.ts +123 -0
- package/src/mark-rule/mark-rule.ts +48 -0
- package/src/mark-rule/range.ts +107 -0
- package/src/mark-rule/types.ts +30 -0
- package/src/mention/index.ts +90 -0
- package/src/mod-click-prevention/index.ts +35 -0
- package/src/paragraph/index.ts +7 -0
- package/src/paragraph/paragraph-commands.ts +29 -0
- package/src/paragraph/paragraph-keymap.ts +15 -0
- package/src/paragraph/paragraph-spec.ts +31 -0
- package/src/paragraph/paragraph.ts +37 -0
- package/src/paste-rule/index.ts +10 -0
- package/src/paste-rule/mark-paste-rule.spec.ts +112 -0
- package/src/paste-rule/mark-paste-rule.ts +194 -0
- package/src/paste-rule/paste-rule-plugin.ts +53 -0
- package/src/paste-rule/paste-rule.spec.ts +96 -0
- package/src/paste-rule/paste-rule.ts +60 -0
- package/src/paste-rule/split-text-by-regex.spec.ts +97 -0
- package/src/paste-rule/split-text-by-regex.ts +44 -0
- package/src/placeholder/index.ts +113 -0
- package/src/placeholder/style.css +7 -0
- package/src/readonly/index.ts +22 -0
- package/src/search/index.ts +140 -0
- package/src/search/style.css +13 -0
- package/src/strike/index.ts +101 -0
- package/src/table/index.ts +53 -0
- package/src/table/style.css +42 -0
- package/src/table/table-commands/delete-cell-selection.spec.ts +41 -0
- package/src/table/table-commands/delete-cell-selection.ts +1 -0
- package/src/table/table-commands/exit-table.spec.ts +45 -0
- package/src/table/table-commands/exit-table.ts +49 -0
- package/src/table/table-commands/insert-table.spec.ts +39 -0
- package/src/table/table-commands/insert-table.ts +80 -0
- package/src/table/table-commands/move-table-column.spec.ts +618 -0
- package/src/table/table-commands/move-table-column.ts +4 -0
- package/src/table/table-commands/move-table-row.spec.ts +380 -0
- package/src/table/table-commands/move-table-row.ts +4 -0
- package/src/table/table-commands/select-table-cell.spec.ts +34 -0
- package/src/table/table-commands/select-table-cell.ts +35 -0
- package/src/table/table-commands/select-table-column.spec.ts +33 -0
- package/src/table/table-commands/select-table-column.ts +39 -0
- package/src/table/table-commands/select-table-row.spec.ts +32 -0
- package/src/table/table-commands/select-table-row.ts +39 -0
- package/src/table/table-commands/select-table.spec.ts +36 -0
- package/src/table/table-commands/select-table.ts +50 -0
- package/src/table/table-commands.ts +110 -0
- package/src/table/table-drop-indicator.ts +40 -0
- package/src/table/table-plugins.ts +15 -0
- package/src/table/table-spec.spec.ts +113 -0
- package/src/table/table-spec.ts +109 -0
- package/src/table/table-utils.ts +16 -0
- package/src/table/table.ts +49 -0
- package/src/table/test-utils.ts +28 -0
- package/src/testing/clipboard.ts +58 -0
- package/src/testing/format-html.ts +5 -0
- package/src/testing/index.ts +161 -0
- package/src/testing/keyboard.ts +36 -0
- package/src/testing/markdown.ts +23 -0
- package/src/text/index.ts +24 -0
- package/src/text-align/index.ts +133 -0
- package/src/types/assert-type-equal.ts +8 -0
- package/src/underline/index.ts +83 -0
- package/src/virtual-selection/index.ts +100 -0
- package/src/virtual-selection/style.css +5 -0
- package/src/yjs/index.ts +22 -0
- package/src/yjs/style.css +31 -0
- package/src/yjs/yjs-commands.ts +27 -0
- package/src/yjs/yjs-cursor-plugin.ts +25 -0
- package/src/yjs/yjs-keymap.ts +23 -0
- package/src/yjs/yjs-sync-plugin.ts +23 -0
- package/src/yjs/yjs-undo-plugin.ts +87 -0
- package/src/yjs/yjs.ts +84 -0
- package/dist/drop-indicator-dB9rZn8e.js +0 -267
- package/dist/table-CPI9ZxbK.js +0 -760
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/* eslint-disable unicorn/prefer-string-raw -- Don't use String.raw here for better bundler minification */
|
|
2
|
+
|
|
3
|
+
// All valid alpha TLDs.
|
|
4
|
+
// Data source: https://data.iana.org/TLD/tlds-alpha-by-domain.txt
|
|
5
|
+
const TLD_RE_PATTERN =
|
|
6
|
+
'a(?:a(?:a|rp)|b(?:arth|b(?:ott|vie)?|c|le|ogado|udhabi)|c(?:ademy|c(?:enture|ountants?)|o|tor)?|d(?:s|ult)?|e(?:g|ro|tna)?|f(?:l|rica)?|g(?:akhan|ency)?|i(?:g|r(?:bus|force|tel))?|kdn|l(?:faromeo|i(?:baba|pay)|l(?:finanz|state|y)|s(?:ace|tom))?|m(?:azon|e(?:rican(?:express|family)|x)|fam|ica|sterdam)?|n(?:alytics|droid|quan|z)|ol?|p(?:artments|p(?:le)?)|q(?:uarelle)?|r(?:a(?:b|mco)|chi|my|pa|te?)?|s(?:da|ia|sociates)?|t(?:hleta|torney)?|u(?:ction|di(?:ble|o)?|spost|t(?:hor|os?))?|vianca|ws?|xa?|z(?:ure)?)|b(?:a(?:by|idu|n(?:a(?:mex|narepublic)|d|k)|r(?:c(?:elona|lay(?:card|s))|efoot|gains)?|s(?:eball|ketball)|uhaus|yern)?|b(?:c|t|va)?|c[gn]|d|e(?:a(?:ts|uty)|er|ntley|rlin|st(?:buy)?|t)?|f|g|h(?:arti)?|i(?:ble|d|ke|ngo?|o|z)?|j|l(?:ack(?:friday)?|o(?:ckbuster|g|omberg)|ue)|m[sw]?|n(?:pparibas)?|o(?:ats|ehringer|fa|m|nd|o(?:k(?:ing)?)?|s(?:ch|t(?:ik|on))|t|utique|x)?|r(?:adesco|idgestone|o(?:adway|ker|ther)|ussels)?|s|t|u(?:ild(?:ers)?|siness|y|zz)|v|w|y|zh?)|c(?:a(?:b|fe|l(?:l|vinklein)?|m(?:era|p)?|non|p(?:etown|ital(?:one)?)|r(?:avan|ds|e(?:ers?)?|s)?|s(?:a|e|h|ino)|t(?:ering|holic)?)?|b(?:a|n|re|s)|c|d|e(?:nter|o|rn)|f[ad]?|g|h(?:a(?:n(?:el|nel)|rity|se|t)|eap|intai|r(?:istmas|ome)|urch)?|i(?:priani|rcle|sco|t(?:adel|ic?|y(?:eats)?))?|k|l(?:aims|eaning|i(?:ck|ni(?:c|que))|o(?:thing|ud)|ub(?:med)?)?|m|n|o(?:ach|des|ffee|l(?:lege|ogne)|m(?:cast|m(?:bank|unity)|p(?:a(?:ny|re)|uter)|sec)?|n(?:dos|s(?:truction|ulting)|t(?:act|ractors))|o(?:king(?:channel)?|l|p)|rsica|u(?:ntry|pons?|rses))?|pa|r(?:edit(?:card|union)?|icket|own|s|uises?)?|u(?:isinella)?|v|w|x|y(?:mru|ou)?|z)|d(?:a(?:bur|d|nce|t(?:a|e|ing|sun)|y)|clk|ds|e(?:al(?:er|s)?|gree|l(?:ivery|l|oitte|ta)|mocrat|nt(?:al|ist)|si(?:gn)?|v)?|hl|i(?:amonds|et|gital|rect(?:ory)?|s(?:co(?:unt|ver)|h)|y)|j|k|m|np|o(?:c(?:s|tor)|g|mains|t|wnload)?|rive|tv|u(?:bai|nlop|pont|rban)|v(?:ag|r)|z)|e(?:a(?:rth|t)|co?|d(?:eka|u(?:cation)?)|e|g|m(?:ail|erck)|n(?:ergy|gineer(?:ing)?|terprises)|pson|quipment|r(?:icsson|ni)?|s(?:q|tate)?|t(?:isalat)?|u(?:rovision|s)?|vents|x(?:change|p(?:ert|osed|ress)|traspace))|f(?:a(?:ge|i(?:l|rwinds|th)|mily|ns?|rm(?:ers)?|s(?:hion|t))|e(?:dex|edback|rr(?:ari|ero))|i(?:at|d(?:elity|o)|lm|na(?:l|nc(?:e|ial))|r(?:e(?:stone)?|mdale)|sh(?:ing)?|t(?:ness)?)?|j|k|l(?:i(?:ckr|ghts|r)|o(?:rist|wers)|y)|m|o(?:o(?:d(?:network)?|tball)?|r(?:d|ex|sale|um)|undation|x)?|r(?:e(?:e|senius)|l|o(?:gans|nt(?:door|ier)))?|tr|u(?:jitsu|nd?|rniture|tbol)|yi)|g(?:a(?:l(?:l(?:ery|o|up))?|mes?|p|rden|y)?|b(?:iz)?|dn?|e(?:a|nt(?:ing)?|orge)?|f|g(?:ee)?|h|i(?:fts?|v(?:es|ing))?|l(?:ass|e|ob(?:al|o))?|m(?:ail|bh|o|x)?|n|o(?:daddy|l(?:d(?:point)?|f)|o(?:dyear|g(?:le)?)?|p|t|v)|p|q|r(?:a(?:inger|phics|tis)|een|ipe|o(?:cery|up))?|s|t|u(?:ardian|cci|ge|i(?:de|tars)|ru)?|w|y)|h(?:a(?:ir|mburg|ngout|us)|bo|dfc(?:bank)?|e(?:alth(?:care)?|l(?:p|sinki)|r(?:e|mes))|gtv|i(?:phop|samitsu|tachi|v)|kt?|m|n|o(?:ckey|l(?:dings|iday)|me(?:depot|goods|s(?:ense)?)|nda|rse|s(?:pital|t(?:ing)?)|t(?:el(?:es|s)|mail)?|use|w)|r|sbc|t|u(?:ghes)?|y(?:att|undai))|i(?:bm|c(?:bc|e|u)|d|e(?:ee)?|fm|kano|l|m(?:amat|db|mo(?:bilien)?)?|n(?:c|dustries|f(?:initi|o)|g|k|s(?:titute|ur(?:ance|e))|t(?:ernational|uit)?|vestments)?|o|piranga|q|r(?:ish)?|s(?:maili|t(?:anbul)?)?|t(?:au|v)?)|j(?:a(?:guar|va)|cb|e(?:ep|tzt|welry)?|io|ll|mp?|nj|o(?:b(?:s|urg)|t|y)?|p(?:morgan|rs)?|u(?:egos|niper))|k(?:aufen|ddi|e(?:rry(?:hotels|logistics|properties))?|fh|g|h|i(?:a|ds|m|nd(?:er|le)|tchen|wi)?|m|n|o(?:eln|matsu|sher)|p(?:mg|n)?|r(?:d|ed)?|uokgroup|w|y(?:oto)?|z)|l(?:a(?:caixa|m(?:borghini|er)|n(?:c(?:aster|ia)|d(?:rover)?|xess)|salle|t(?:ino|robe)?|w(?:yer)?)?|b|c|ds|e(?:ase|clerc|frak|g(?:al|o)|xus)|gbt|i(?:dl|fe(?:insurance|style)?|ghting|ke|lly|m(?:ited|o)|n(?:coln|de|k)|psy|v(?:e|ing))?|k|l[cp]|o(?:ans?|c(?:ker|us)|l|ndon|tt[eo]|ve)|pl(?:financial)?|r|s|t(?:da?)?|u(?:ndbeck|x(?:e|ury))?|v|y)|m(?:a(?:cys|drid|i(?:f|son)|keup|n(?:agement|go)?|p|r(?:ket(?:ing|s)?|riott|shalls)|serati|ttel)?|ba|c(?:kinsey)?|d|e(?:d(?:ia)?|et|lbourne|m(?:e|orial)|nu?|rckmsd)?|g|h|i(?:ami|crosoft|l|n[it]|t(?:subishi)?)|k|l[bs]?|ma?|n|o(?:bi(?:le)?|da|e|i|m|n(?:ash|ey|ster)|r(?:mon|tgage)|scow|to(?:rcycles)?|v(?:ie)?)?|p|q|r|sd?|t[nr]?|u(?:s(?:eum|ic)|tual)?|v|w|x|y|z)|n(?:a(?:b|goya|me|tura|vy)?|ba|c|e(?:c|t(?:bank|flix|work)?|ustar|ws?|x(?:t(?:direct)?|us))?|fl?|go?|hk|i(?:co|k(?:e|on)|nja|ssa[ny])?|l|o(?:kia|rt(?:hwesternmutual|on)|w(?:ruz|tv)?)?|p|r[aw]?|tt|u|yc|z)|o(?:b(?:i|server)|ffice|kinawa|l(?:ayan(?:group)?|dnavy|lo)|m(?:ega)?|n(?:e|g|l(?:ine)?)|oo|pen|r(?:a(?:cle|nge)|g(?:anic)?|igins)|saka|t(?:suka|t)|vh)|p(?:a(?:ge|nasonic|r(?:is|s|t(?:ners|s|y))|ssagens|y)?|ccw|et?|f(?:izer)?|g|h(?:armacy|d|ilips|o(?:ne|to(?:graphy|s)?)|ysio)?|i(?:c(?:s|t(?:et|ures))|d|n[gk]?|oneer|zza)|k|l(?:a(?:ce|y(?:station)?)|u(?:mbing|s))?|m|nc?|o(?:hl|ker|litie|rn|st)|r(?:a(?:merica|xi)|ess|ime|o(?:d(?:uctions)?|f|gressive|mo|pert(?:ies|y)|tection)?|u(?:dential)?)?|s|t|ub|wc?|y)|q(?:a|pon|ue(?:bec|st))|r(?:a(?:cing|dio)|e(?:a(?:d|l(?:estate|t(?:or|y)))|cipes|d(?:stone|umbrella)?|hab|i(?:sen?|t)|liance|n(?:t(?:als)?)?|p(?:air|ort|ublican)|st(?:aurant)?|views?|xroth)?|i(?:c(?:h(?:ardli)?|oh)|l|o|p)|o(?:c(?:her|ks)|deo|gers|om)?|s(?:vp)?|u(?:gby|hr|n)?|we?|yukyu)|s(?:a(?:arland|fe(?:ty)?|kura|l(?:e|on)|ms(?:club|ung)|n(?:dvik(?:coromant)?|ofi)|p|rl|s|ve|xo)?|b[is]?|c(?:a|b|h(?:aeffler|midt|o(?:larships|ol)|ule|warz)|ience|ot)?|d|e(?:a(?:rch|t)|cur(?:e|ity)|ek|lect|ner|rvices|ven|w|xy?)?|fr|g|h(?:a(?:ngrila|rp|w)|ell|i(?:a|ksha)|o(?:es|p(?:ping)?|uji|w(?:time)?))?|i(?:lk|n(?:a|gles)|te)?|j|k(?:in?|y(?:pe)?)?|l(?:ing)?|m(?:art|ile)?|n(?:cf)?|o(?:c(?:cer|ial)|ft(?:bank|ware)|hu|l(?:ar|utions)|n[gy]|y)?|p(?:a(?:ce)?|o(?:rt|t))|rl?|s|t(?:a(?:da|ples|r|te(?:bank|farm))|c(?:group)?|o(?:ckholm|r(?:age|e))|ream|ud(?:io|y)|yle)?|u(?:cks|pp(?:l(?:ies|y)|ort)|r(?:f|gery)|zuki)?|v|w(?:atch|iss)|x|y(?:dney|stems)?|z)|t(?:a(?:b|ipei|lk|obao|rget|t(?:a(?:motors|r)|too)|xi?)|ci?|dk?|e(?:am|ch(?:nology)?|l|masek|nnis|va)|f|g|h(?:d|eat(?:er|re))?|i(?:aa|ckets|enda|ffany|ps|r(?:es|ol))|j(?:maxx|x)?|k(?:maxx)?|l|m(?:all)?|n|o(?:day|kyo|ols|p|ray|shiba|tal|urs|wn|y(?:ota|s))?|r(?:a(?:d(?:e|ing)|ining|vel(?:channel|ers(?:insurance)?)?)|ust|v)?|t|u(?:be|i|nes|shu)|vs?|w|z)|u(?:a|b(?:ank|s)|g|k|n(?:i(?:com|versity)|o)|ol|ps|s|y|z)|v(?:a(?:cations|n(?:a|guard))?|c|e(?:gas|ntures|r(?:isign|sicherung)|t)?|g|i(?:ajes|deo|g|king|llas|n|p|rgin|s(?:a|ion)|v[ao])?|laanderen|n|o(?:dka|l(?:kswagen|vo)|t(?:e|ing|o)|yage)|u(?:elos)?)|w(?:a(?:l(?:es|mart|ter)|ng(?:gou)?|tch(?:es)?)|e(?:ather(?:channel)?|b(?:cam|er|site)|d(?:ding)?|i(?:bo|r))|f|hoswho|i(?:en|ki|lliamhill|n(?:dows|e|ners)?)|me|o(?:lterskluwer|odside|r(?:ks?|ld)|w)|s|t[cf])|x(?:box|erox|finity|i(?:huan|n)|xx|yz)|y(?:a(?:chts|hoo|maxun|ndex)|e|o(?:dobashi|ga|kohama|u(?:tube)?)|t|un)|z(?:a(?:ppos|ra)?|ero|ip|m|one|uerich|w)'
|
|
7
|
+
|
|
8
|
+
// Some common punctuations that can be used to stop a link
|
|
9
|
+
const PUNCTUATION_CHAR_PATTERN = '\\.\\,\\;\\!\\?'
|
|
10
|
+
|
|
11
|
+
const STOP_CHAR_PATTERN = '[' + PUNCTUATION_CHAR_PATTERN + ']'
|
|
12
|
+
|
|
13
|
+
const END_CHAR_PATTERN = '[^' + '\\s' + PUNCTUATION_CHAR_PATTERN + ']'
|
|
14
|
+
|
|
15
|
+
// dprint-ignore
|
|
16
|
+
const LINK_RE_BASE_PATTERN = (
|
|
17
|
+
// start of the link group
|
|
18
|
+
'(' +
|
|
19
|
+
'(?:' +
|
|
20
|
+
// protocol identifier (optional)
|
|
21
|
+
// short syntax // is allowed
|
|
22
|
+
'(?:(?:https?:)?\\/\\/)?' +
|
|
23
|
+
|
|
24
|
+
// host & domain names.
|
|
25
|
+
'(?:' +
|
|
26
|
+
'(?:' +
|
|
27
|
+
'[a-z0-9\\u00a1-\\uffff]' +
|
|
28
|
+
'[a-z0-9\\u00a1-\\uffff_-]{0,62}' +
|
|
29
|
+
')?' +
|
|
30
|
+
'[a-z0-9\\u00a1-\\uffff]\\.' +
|
|
31
|
+
')+' +
|
|
32
|
+
|
|
33
|
+
// TLD identifier name, must not end with dot
|
|
34
|
+
'(?:' +
|
|
35
|
+
TLD_RE_PATTERN +
|
|
36
|
+
')' +
|
|
37
|
+
')' +
|
|
38
|
+
|
|
39
|
+
// port number (optional)
|
|
40
|
+
'(?::\\d{2,5})?' +
|
|
41
|
+
|
|
42
|
+
// sub path (optional)
|
|
43
|
+
'(?:/' +
|
|
44
|
+
'(?:' +
|
|
45
|
+
'\\S*' +
|
|
46
|
+
END_CHAR_PATTERN +
|
|
47
|
+
')?' +
|
|
48
|
+
')?' +
|
|
49
|
+
|
|
50
|
+
// query string (optional)
|
|
51
|
+
'(?:\\?' +
|
|
52
|
+
'(?:' +
|
|
53
|
+
'\\S*' +
|
|
54
|
+
END_CHAR_PATTERN +
|
|
55
|
+
')' +
|
|
56
|
+
')?' +
|
|
57
|
+
|
|
58
|
+
// fragment (optional)
|
|
59
|
+
'(?:\\#' +
|
|
60
|
+
'(?:' +
|
|
61
|
+
'\\S*' +
|
|
62
|
+
END_CHAR_PATTERN +
|
|
63
|
+
')?' +
|
|
64
|
+
')?' +
|
|
65
|
+
|
|
66
|
+
// end of the link group
|
|
67
|
+
')'
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
// dprint-ignore
|
|
71
|
+
const LINK_ENTER_PATTERN = LINK_RE_BASE_PATTERN + STOP_CHAR_PATTERN + '?' + '$'
|
|
72
|
+
// dprint-ignore
|
|
73
|
+
const LINK_INPUT_PATTERN = LINK_RE_BASE_PATTERN + STOP_CHAR_PATTERN + '?' + '\\s$'
|
|
74
|
+
// dprint-ignore
|
|
75
|
+
const LINK_MARK_PATTERN = LINK_RE_BASE_PATTERN + '(?=' + STOP_CHAR_PATTERN + '|\\s|$)'
|
|
76
|
+
|
|
77
|
+
export const LINK_ENTER_RE: RegExp = new RegExp(LINK_ENTER_PATTERN, 'gi')
|
|
78
|
+
export const LINK_INPUT_RE: RegExp = new RegExp(LINK_INPUT_PATTERN, 'gi')
|
|
79
|
+
export const LINK_MARK_RE: RegExp = new RegExp(LINK_MARK_PATTERN, 'gi')
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export { ListDOMSerializer } from 'prosemirror-flat-list'
|
|
2
|
+
export type {
|
|
3
|
+
DedentListOptions,
|
|
4
|
+
IndentListOptions,
|
|
5
|
+
ToggleCollapsedOptions,
|
|
6
|
+
UnwrapListOptions,
|
|
7
|
+
WrapInListGetAttrs,
|
|
8
|
+
} from 'prosemirror-flat-list'
|
|
9
|
+
export {
|
|
10
|
+
defineList,
|
|
11
|
+
type ListExtension,
|
|
12
|
+
} from './list'
|
|
13
|
+
export {
|
|
14
|
+
defineListCommands,
|
|
15
|
+
type ListCommandsExtension,
|
|
16
|
+
} from './list-commands'
|
|
17
|
+
export { defineListInputRules } from './list-input-rules'
|
|
18
|
+
export { defineListKeymap } from './list-keymap'
|
|
19
|
+
export { defineListPlugins } from './list-plugins'
|
|
20
|
+
export { defineListSerializer } from './list-serializer'
|
|
21
|
+
export {
|
|
22
|
+
defineListSpec,
|
|
23
|
+
type ListSpecExtension,
|
|
24
|
+
} from './list-spec'
|
|
25
|
+
export type { ListAttrs } from './list-types'
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineCommands,
|
|
3
|
+
insertNode,
|
|
4
|
+
type Extension,
|
|
5
|
+
} from '@prosekit/core'
|
|
6
|
+
import type { Command } from '@prosekit/pm/state'
|
|
7
|
+
import {
|
|
8
|
+
createDedentListCommand as dedentList,
|
|
9
|
+
createIndentListCommand as indentList,
|
|
10
|
+
createMoveListCommand as moveList,
|
|
11
|
+
createSplitListCommand as splitList,
|
|
12
|
+
createToggleCollapsedCommand as toggleCollapsed,
|
|
13
|
+
createToggleListCommand as toggleList,
|
|
14
|
+
createUnwrapListCommand as unwrapList,
|
|
15
|
+
createWrapInListCommand as wrapInList,
|
|
16
|
+
type DedentListOptions,
|
|
17
|
+
type IndentListOptions,
|
|
18
|
+
type ListAttributes,
|
|
19
|
+
type ToggleCollapsedOptions,
|
|
20
|
+
type UnwrapListOptions,
|
|
21
|
+
} from 'prosemirror-flat-list'
|
|
22
|
+
|
|
23
|
+
function insertList(attrs?: ListAttributes): Command {
|
|
24
|
+
return insertNode({ type: 'list', attrs })
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
30
|
+
export type ListCommandsExtension = Extension<{
|
|
31
|
+
Commands: {
|
|
32
|
+
dedentList: [options?: DedentListOptions]
|
|
33
|
+
indentList: [options?: IndentListOptions]
|
|
34
|
+
moveList: [direction: 'up' | 'down']
|
|
35
|
+
splitList: []
|
|
36
|
+
toggleCollapsed: [options?: ToggleCollapsedOptions]
|
|
37
|
+
unwrapList: [options?: UnwrapListOptions]
|
|
38
|
+
toggleList: [attrs?: ListAttributes]
|
|
39
|
+
wrapInList: [attrs?: ListAttributes]
|
|
40
|
+
insertList: [attrs?: ListAttributes]
|
|
41
|
+
}
|
|
42
|
+
}>
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Defines list commands.
|
|
46
|
+
*
|
|
47
|
+
* @internal
|
|
48
|
+
*/
|
|
49
|
+
export function defineListCommands(): ListCommandsExtension {
|
|
50
|
+
return defineCommands({
|
|
51
|
+
dedentList,
|
|
52
|
+
indentList,
|
|
53
|
+
moveList,
|
|
54
|
+
splitList,
|
|
55
|
+
toggleCollapsed,
|
|
56
|
+
unwrapList,
|
|
57
|
+
toggleList,
|
|
58
|
+
wrapInList,
|
|
59
|
+
insertList,
|
|
60
|
+
})
|
|
61
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { PlainExtension } from '@prosekit/core'
|
|
2
|
+
|
|
3
|
+
import type { DragEventHandler } from '../drop-indicator'
|
|
4
|
+
import { defineDropIndicator } from '../drop-indicator'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Configures drop indicator to avoid unexpected drop point.
|
|
8
|
+
*
|
|
9
|
+
* We don't want to drag a list node and drop it as the first
|
|
10
|
+
* child of another list node.
|
|
11
|
+
*
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
export function defineListDropIndicator(): PlainExtension {
|
|
15
|
+
return defineDropIndicator({
|
|
16
|
+
onDrag,
|
|
17
|
+
})
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const onDrag: DragEventHandler = ({ view, pos }): boolean => {
|
|
21
|
+
const slice = view.dragging?.slice
|
|
22
|
+
if (
|
|
23
|
+
slice
|
|
24
|
+
&& slice.openStart === 0
|
|
25
|
+
&& slice.openEnd === 0
|
|
26
|
+
&& slice.content.childCount === 1
|
|
27
|
+
) {
|
|
28
|
+
const node = slice.content.child(0)
|
|
29
|
+
if (node.type.name === 'list') {
|
|
30
|
+
const $pos = view.state.doc.resolve(pos)
|
|
31
|
+
if ($pos.parent.type.name === 'list' && $pos.index() === 0) {
|
|
32
|
+
return false
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return true
|
|
37
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
union,
|
|
3
|
+
type Extension,
|
|
4
|
+
} from '@prosekit/core'
|
|
5
|
+
import { listInputRules } from 'prosemirror-flat-list'
|
|
6
|
+
|
|
7
|
+
import { defineInputRule } from '../input-rule'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export function defineListInputRules(): Extension {
|
|
13
|
+
return union(listInputRules.map(defineInputRule))
|
|
14
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {
|
|
2
|
+
describe,
|
|
3
|
+
expect,
|
|
4
|
+
it,
|
|
5
|
+
} from 'vitest'
|
|
6
|
+
|
|
7
|
+
import { setupTest } from '../testing'
|
|
8
|
+
import { pressKey } from '../testing/keyboard'
|
|
9
|
+
|
|
10
|
+
describe('keymap', () => {
|
|
11
|
+
const { editor, n } = setupTest()
|
|
12
|
+
|
|
13
|
+
it('can update indentation', async () => {
|
|
14
|
+
const doc1 = n.doc(
|
|
15
|
+
//
|
|
16
|
+
n.bullet(n.p('foo')),
|
|
17
|
+
n.bullet(n.p('bar<a>')),
|
|
18
|
+
)
|
|
19
|
+
const doc2 = n.doc(
|
|
20
|
+
//
|
|
21
|
+
n.bullet(
|
|
22
|
+
//
|
|
23
|
+
n.p('foo'),
|
|
24
|
+
n.bullet(n.p('bar<a>')),
|
|
25
|
+
),
|
|
26
|
+
)
|
|
27
|
+
editor.set(doc1)
|
|
28
|
+
|
|
29
|
+
await pressKey('mod-]')
|
|
30
|
+
expect(editor.state.doc.toJSON()).toEqual(doc2.toJSON())
|
|
31
|
+
await pressKey('mod-[')
|
|
32
|
+
expect(editor.state.doc.toJSON()).toEqual(doc1.toJSON())
|
|
33
|
+
|
|
34
|
+
await pressKey('Tab')
|
|
35
|
+
expect(editor.state.doc.toJSON()).toEqual(doc2.toJSON())
|
|
36
|
+
await pressKey('Shift-Tab')
|
|
37
|
+
expect(editor.state.doc.toJSON()).toEqual(doc1.toJSON())
|
|
38
|
+
})
|
|
39
|
+
})
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineKeymap,
|
|
3
|
+
type PlainExtension,
|
|
4
|
+
} from '@prosekit/core'
|
|
5
|
+
import {
|
|
6
|
+
chainCommands,
|
|
7
|
+
deleteSelection,
|
|
8
|
+
} from '@prosekit/pm/commands'
|
|
9
|
+
import {
|
|
10
|
+
createDedentListCommand,
|
|
11
|
+
createIndentListCommand,
|
|
12
|
+
deleteCommand,
|
|
13
|
+
enterCommand,
|
|
14
|
+
joinCollapsedListBackward,
|
|
15
|
+
joinListUp,
|
|
16
|
+
protectCollapsed,
|
|
17
|
+
} from 'prosemirror-flat-list'
|
|
18
|
+
|
|
19
|
+
// This is different from the one exported by prosemirror-flat-list, because
|
|
20
|
+
// some commands are moved to `defineBaseKeymap` in `prosekit/core`.
|
|
21
|
+
const backspaceCommand = chainCommands(
|
|
22
|
+
protectCollapsed,
|
|
23
|
+
deleteSelection,
|
|
24
|
+
joinListUp,
|
|
25
|
+
joinCollapsedListBackward,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
const dedentListCommand = createDedentListCommand()
|
|
29
|
+
const indentListCommand = createIndentListCommand()
|
|
30
|
+
|
|
31
|
+
const listKeymap = {
|
|
32
|
+
'Enter': enterCommand,
|
|
33
|
+
'Backspace': backspaceCommand,
|
|
34
|
+
'Delete': deleteCommand,
|
|
35
|
+
'Mod-]': indentListCommand,
|
|
36
|
+
'Mod-[': dedentListCommand,
|
|
37
|
+
'Tab': indentListCommand,
|
|
38
|
+
'Shift-Tab': dedentListCommand,
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Returns a extension that adds key bindings for list.
|
|
43
|
+
*
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
export function defineListKeymap(): PlainExtension {
|
|
47
|
+
return defineKeymap(listKeymap)
|
|
48
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {
|
|
2
|
+
definePlugin,
|
|
3
|
+
type PlainExtension,
|
|
4
|
+
} from '@prosekit/core'
|
|
5
|
+
import { Plugin } from '@prosekit/pm/state'
|
|
6
|
+
import {
|
|
7
|
+
createListEventPlugin,
|
|
8
|
+
createListRenderingPlugin,
|
|
9
|
+
createSafariInputMethodWorkaroundPlugin,
|
|
10
|
+
unwrapListSlice,
|
|
11
|
+
} from 'prosemirror-flat-list'
|
|
12
|
+
|
|
13
|
+
function createListClipboardPlugin(): Plugin {
|
|
14
|
+
return new Plugin({
|
|
15
|
+
props: {
|
|
16
|
+
transformCopied: unwrapListSlice,
|
|
17
|
+
},
|
|
18
|
+
})
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function createListPlugins(): Plugin[] {
|
|
22
|
+
return [
|
|
23
|
+
createListEventPlugin(),
|
|
24
|
+
createListRenderingPlugin(),
|
|
25
|
+
createListClipboardPlugin(),
|
|
26
|
+
createSafariInputMethodWorkaroundPlugin(),
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
export function defineListPlugins(): PlainExtension {
|
|
34
|
+
return definePlugin(createListPlugins)
|
|
35
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { isElementLike } from '@ocavue/utils'
|
|
2
|
+
import {
|
|
3
|
+
defineClipboardSerializer,
|
|
4
|
+
type PlainExtension,
|
|
5
|
+
} from '@prosekit/core'
|
|
6
|
+
import {
|
|
7
|
+
joinListElements,
|
|
8
|
+
listToDOM,
|
|
9
|
+
} from 'prosemirror-flat-list'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
export function defineListSerializer(): PlainExtension {
|
|
15
|
+
return defineClipboardSerializer({
|
|
16
|
+
serializeFragmentWrapper: (fn) => {
|
|
17
|
+
return (...args) => {
|
|
18
|
+
const dom = fn(...args)
|
|
19
|
+
return joinListElements(dom)
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
serializeNodeWrapper: (fn) => {
|
|
23
|
+
return (...args) => {
|
|
24
|
+
const dom = fn(...args)
|
|
25
|
+
return isElementLike(dom) ? joinListElements(dom) : dom
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
nodesFromSchemaWrapper: (fn) => {
|
|
29
|
+
return (...args) => {
|
|
30
|
+
const nodes = fn(...args)
|
|
31
|
+
return {
|
|
32
|
+
...nodes,
|
|
33
|
+
list: (node) => listToDOM({ node, nativeList: true, getMarkers: () => null }),
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
})
|
|
38
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineNodeSpec,
|
|
3
|
+
type Extension,
|
|
4
|
+
} from '@prosekit/core'
|
|
5
|
+
import type {
|
|
6
|
+
DOMOutputSpec,
|
|
7
|
+
ProseMirrorNode,
|
|
8
|
+
} from '@prosekit/pm/model'
|
|
9
|
+
import {
|
|
10
|
+
createListSpec,
|
|
11
|
+
listToDOM,
|
|
12
|
+
type ListAttributes,
|
|
13
|
+
} from 'prosemirror-flat-list'
|
|
14
|
+
|
|
15
|
+
import type { ListAttrs } from './list-types'
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
export type ListSpecExtension = Extension<{
|
|
21
|
+
Nodes: {
|
|
22
|
+
list: ListAttrs
|
|
23
|
+
}
|
|
24
|
+
}>
|
|
25
|
+
|
|
26
|
+
function getMarkers(node: ProseMirrorNode): DOMOutputSpec[] {
|
|
27
|
+
const attrs = node.attrs as ListAttributes
|
|
28
|
+
switch (attrs.kind) {
|
|
29
|
+
case 'task':
|
|
30
|
+
// Use a `label` element here so that the area around the checkbox is also checkable.
|
|
31
|
+
return [
|
|
32
|
+
[
|
|
33
|
+
'label',
|
|
34
|
+
[
|
|
35
|
+
'input',
|
|
36
|
+
{ type: 'checkbox', checked: attrs.checked ? '' : undefined },
|
|
37
|
+
],
|
|
38
|
+
],
|
|
39
|
+
]
|
|
40
|
+
default:
|
|
41
|
+
// Always return an empty array so that the marker element is rendered. This
|
|
42
|
+
// is required to make the drop indicator locate the correct position.
|
|
43
|
+
return []
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @internal
|
|
49
|
+
*/
|
|
50
|
+
export function defineListSpec(): ListSpecExtension {
|
|
51
|
+
const spec = createListSpec()
|
|
52
|
+
|
|
53
|
+
return defineNodeSpec<'list', ListAttrs>({
|
|
54
|
+
...spec,
|
|
55
|
+
toDOM: (node) => {
|
|
56
|
+
return listToDOM({ node, getMarkers })
|
|
57
|
+
},
|
|
58
|
+
name: 'list',
|
|
59
|
+
})
|
|
60
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ListAttributes } from 'prosemirror-flat-list'
|
|
2
|
+
import { test } from 'vitest'
|
|
3
|
+
|
|
4
|
+
import { assertTypeEqual } from '../types/assert-type-equal'
|
|
5
|
+
|
|
6
|
+
import type { ListAttrs } from './list-types'
|
|
7
|
+
|
|
8
|
+
test('ListAttrs', () => {
|
|
9
|
+
assertTypeEqual<keyof ListAttrs, keyof ListAttributes>(true)
|
|
10
|
+
})
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The attributes of a list node.
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export interface ListAttrs {
|
|
7
|
+
/**
|
|
8
|
+
* The kind of list node.
|
|
9
|
+
*/
|
|
10
|
+
kind?: 'bullet' | 'ordered' | 'task' | 'toggle'
|
|
11
|
+
/**
|
|
12
|
+
* The optional order of the list node.
|
|
13
|
+
*/
|
|
14
|
+
order?: number | null
|
|
15
|
+
/**
|
|
16
|
+
* Whether the list node is checked if its `kind` is `"task"`.
|
|
17
|
+
*/
|
|
18
|
+
checked?: boolean
|
|
19
|
+
/**
|
|
20
|
+
* Whether the list node is collapsed if its `kind` is `"toggle"`.
|
|
21
|
+
*/
|
|
22
|
+
collapsed?: boolean
|
|
23
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createEditor,
|
|
3
|
+
union,
|
|
4
|
+
} from '@prosekit/core'
|
|
5
|
+
import type { ProseMirrorNode } from '@prosekit/pm/model'
|
|
6
|
+
import {
|
|
7
|
+
describe,
|
|
8
|
+
expect,
|
|
9
|
+
it,
|
|
10
|
+
} from 'vitest'
|
|
11
|
+
|
|
12
|
+
import { defineDoc } from '../doc'
|
|
13
|
+
import { defineParagraph } from '../paragraph'
|
|
14
|
+
import { setupTest } from '../testing'
|
|
15
|
+
import { defineText } from '../text'
|
|
16
|
+
|
|
17
|
+
import { defineList } from './index'
|
|
18
|
+
|
|
19
|
+
describe('defineList', () => {
|
|
20
|
+
it('can add list node', () => {
|
|
21
|
+
const extension = union(
|
|
22
|
+
defineList(),
|
|
23
|
+
defineDoc(),
|
|
24
|
+
defineText(),
|
|
25
|
+
defineParagraph(),
|
|
26
|
+
)
|
|
27
|
+
const editor = createEditor({ extension })
|
|
28
|
+
const schema = editor.schema
|
|
29
|
+
const nodes = Object.keys(schema.nodes)
|
|
30
|
+
expect(nodes.includes('list')).toBe(true)
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
it('can copy lists as native HTML <li> elements', async () => {
|
|
34
|
+
const { editor, n, copy } = setupTest()
|
|
35
|
+
|
|
36
|
+
const copyAndGetHTML = async (doc: ProseMirrorNode) => {
|
|
37
|
+
editor.set(doc)
|
|
38
|
+
editor.commands.selectAll()
|
|
39
|
+
const { html } = await copy()
|
|
40
|
+
return html
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
expect(
|
|
44
|
+
await copyAndGetHTML(
|
|
45
|
+
n.doc(
|
|
46
|
+
n.bullet(n.paragraph('Bullet 1')),
|
|
47
|
+
n.bullet(n.paragraph('Bullet 2')),
|
|
48
|
+
),
|
|
49
|
+
),
|
|
50
|
+
).toMatchInlineSnapshot(`
|
|
51
|
+
"
|
|
52
|
+
<ul data-pm-slice="0 0 []">
|
|
53
|
+
<li
|
|
54
|
+
class="prosemirror-flat-list"
|
|
55
|
+
data-list-kind="bullet"
|
|
56
|
+
>
|
|
57
|
+
<p>
|
|
58
|
+
Bullet 1
|
|
59
|
+
</p>
|
|
60
|
+
</li>
|
|
61
|
+
<li
|
|
62
|
+
class="prosemirror-flat-list"
|
|
63
|
+
data-list-kind="bullet"
|
|
64
|
+
>
|
|
65
|
+
<p>
|
|
66
|
+
Bullet 2
|
|
67
|
+
</p>
|
|
68
|
+
</li>
|
|
69
|
+
</ul>
|
|
70
|
+
"
|
|
71
|
+
`)
|
|
72
|
+
|
|
73
|
+
expect(
|
|
74
|
+
await copyAndGetHTML(
|
|
75
|
+
n.doc(
|
|
76
|
+
n.ordered(n.paragraph('Ordered 1')),
|
|
77
|
+
n.ordered(n.paragraph('Ordered 2')),
|
|
78
|
+
),
|
|
79
|
+
),
|
|
80
|
+
).toMatchInlineSnapshot(`
|
|
81
|
+
"
|
|
82
|
+
<ol data-pm-slice="0 0 []">
|
|
83
|
+
<li
|
|
84
|
+
class="prosemirror-flat-list"
|
|
85
|
+
data-list-kind="ordered"
|
|
86
|
+
>
|
|
87
|
+
<p>
|
|
88
|
+
Ordered 1
|
|
89
|
+
</p>
|
|
90
|
+
</li>
|
|
91
|
+
<li
|
|
92
|
+
class="prosemirror-flat-list"
|
|
93
|
+
data-list-kind="ordered"
|
|
94
|
+
>
|
|
95
|
+
<p>
|
|
96
|
+
Ordered 2
|
|
97
|
+
</p>
|
|
98
|
+
</li>
|
|
99
|
+
</ol>
|
|
100
|
+
"
|
|
101
|
+
`)
|
|
102
|
+
|
|
103
|
+
expect(
|
|
104
|
+
await copyAndGetHTML(
|
|
105
|
+
n.doc(
|
|
106
|
+
n.checked(n.paragraph('Checked 1')),
|
|
107
|
+
n.unchecked(n.paragraph('Unchecked 2')),
|
|
108
|
+
),
|
|
109
|
+
),
|
|
110
|
+
).toMatchInlineSnapshot(`
|
|
111
|
+
"
|
|
112
|
+
<ul data-pm-slice="0 0 []">
|
|
113
|
+
<li
|
|
114
|
+
class="prosemirror-flat-list"
|
|
115
|
+
data-list-kind="task"
|
|
116
|
+
data-list-checked
|
|
117
|
+
>
|
|
118
|
+
<p>
|
|
119
|
+
Checked 1
|
|
120
|
+
</p>
|
|
121
|
+
</li>
|
|
122
|
+
<li
|
|
123
|
+
class="prosemirror-flat-list"
|
|
124
|
+
data-list-kind="task"
|
|
125
|
+
>
|
|
126
|
+
<p>
|
|
127
|
+
Unchecked 2
|
|
128
|
+
</p>
|
|
129
|
+
</li>
|
|
130
|
+
</ul>
|
|
131
|
+
"
|
|
132
|
+
`)
|
|
133
|
+
})
|
|
134
|
+
})
|
package/src/list/list.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {
|
|
2
|
+
union,
|
|
3
|
+
type Union,
|
|
4
|
+
} from '@prosekit/core'
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
defineListCommands,
|
|
8
|
+
type ListCommandsExtension,
|
|
9
|
+
} from './list-commands'
|
|
10
|
+
import { defineListDropIndicator } from './list-drop-indicator'
|
|
11
|
+
import { defineListInputRules } from './list-input-rules'
|
|
12
|
+
import { defineListKeymap } from './list-keymap'
|
|
13
|
+
import { defineListPlugins } from './list-plugins'
|
|
14
|
+
import { defineListSerializer } from './list-serializer'
|
|
15
|
+
import {
|
|
16
|
+
defineListSpec,
|
|
17
|
+
type ListSpecExtension,
|
|
18
|
+
} from './list-spec'
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
export type ListExtension = Union<[ListSpecExtension, ListCommandsExtension]>
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
export function defineList(): ListExtension {
|
|
29
|
+
return union(
|
|
30
|
+
defineListSpec(),
|
|
31
|
+
defineListPlugins(),
|
|
32
|
+
defineListKeymap(),
|
|
33
|
+
defineListInputRules(),
|
|
34
|
+
defineListCommands(),
|
|
35
|
+
defineListSerializer(),
|
|
36
|
+
defineListDropIndicator(),
|
|
37
|
+
)
|
|
38
|
+
}
|