@prosekit/extensions 0.11.3 → 0.11.5
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-B8P652g2.js → drop-indicator-D1eHOhSi.js} +6 -5
- package/dist/drop-indicator-D1eHOhSi.js.map +1 -0
- package/dist/enter-rule-RdhEA900.js +2 -1
- package/dist/enter-rule-RdhEA900.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/{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-BCqIZMDu.js} +3 -3
- package/dist/mark-rule-BCqIZMDu.js.map +1 -0
- package/dist/{paste-rule-Cca3n5TA.js → paste-rule-DIEJKIje.js} +5 -15
- package/dist/paste-rule-DIEJKIje.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 +2 -1
- 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 +2 -1
- 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 -1
- package/dist/prosekit-extensions-file.d.ts.map +1 -0
- package/dist/prosekit-extensions-file.js +4 -16
- package/dist/prosekit-extensions-file.js.map +1 -0
- 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 -1
- 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 +2 -1
- package/dist/prosekit-extensions-image.d.ts.map +1 -0
- package/dist/prosekit-extensions-image.js +3 -3
- 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 +6 -7
- 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 -1
- 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 -4
- 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 +56 -114
- package/dist/prosekit-extensions-table.d.ts.map +1 -0
- package/dist/prosekit-extensions-table.js +3 -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.d.ts +1 -1
- 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 +2 -1
- package/dist/shiki-highlighter-chunk-DSPM0T27.d.ts.map +1 -0
- 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-Bi7WsMI3.js +297 -0
- package/dist/table-Bi7WsMI3.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 +10 -9
- 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 +84 -0
- package/src/drop-indicator/drop-indicator-plugin.ts +147 -0
- package/src/drop-indicator/drop-indicator.ts +37 -0
- package/src/drop-indicator/drop-target.ts +168 -0
- package/src/drop-indicator/index.ts +14 -0
- package/src/drop-indicator/types.ts +90 -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 +119 -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 +27 -0
- package/src/image/image-spec.ts +72 -0
- package/src/image/image.ts +25 -0
- package/src/image/index.ts +13 -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/table-C_qAMj5-.js +0 -734
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--prosekit-list-bullet-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='2.5' fill='currentColor'/%3E%3C/svg%3E");
|
|
3
|
+
--prosekit-list-toggle-open-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpolygon points='8,10 12,14 16,10' fill='currentColor'/%3E%3C/svg%3E");
|
|
4
|
+
--prosekit-list-toggle-closed-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpolygon points='10,8 14,12 10,16' fill='currentColor'/%3E%3C/svg%3E");
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.prosemirror-flat-list {
|
|
8
|
+
& {
|
|
9
|
+
position: relative;
|
|
10
|
+
margin: 0;
|
|
11
|
+
padding: 0;
|
|
12
|
+
list-style: none;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
& > .list-marker {
|
|
16
|
+
position: absolute;
|
|
17
|
+
left: 0;
|
|
18
|
+
width: 1.5em;
|
|
19
|
+
width: 1lh;
|
|
20
|
+
height: 1.5em;
|
|
21
|
+
height: 1lh;
|
|
22
|
+
text-align: center;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
& > .list-content {
|
|
26
|
+
margin-left: 1.5em;
|
|
27
|
+
margin-left: 1lh;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&[data-list-kind="bullet"] > .list-marker,
|
|
31
|
+
&[data-list-kind="toggle"] > .list-marker {
|
|
32
|
+
background-color: currentColor;
|
|
33
|
+
mask-position: center;
|
|
34
|
+
mask-repeat: no-repeat;
|
|
35
|
+
mask-size: contain;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
&[data-list-kind="bullet"] {
|
|
39
|
+
& > .list-marker {
|
|
40
|
+
mask-image: var(--prosekit-list-bullet-icon);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
&[data-list-kind="toggle"] {
|
|
45
|
+
& > .list-marker {
|
|
46
|
+
mask-image: var(--prosekit-list-toggle-open-icon);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
&[data-list-collapsable][data-list-collapsed] > .list-marker {
|
|
50
|
+
mask-image: var(--prosekit-list-toggle-closed-icon);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
&[data-list-kind="ordered"] {
|
|
55
|
+
/*
|
|
56
|
+
Ensure that the counters in children don't escape, so that the sub lists
|
|
57
|
+
won't affect the counter of the parent list.
|
|
58
|
+
|
|
59
|
+
See also https://github.com/ocavue/prosemirror-flat-list/issues/23
|
|
60
|
+
*/
|
|
61
|
+
& > * {
|
|
62
|
+
contain: style;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
&::before {
|
|
66
|
+
position: absolute;
|
|
67
|
+
right: calc(100% - 1.5em);
|
|
68
|
+
right: calc(100% - 1lh);
|
|
69
|
+
content: counter(prosemirror-flat-list-counter, decimal) ". ";
|
|
70
|
+
font-variant-numeric: tabular-nums;
|
|
71
|
+
}
|
|
72
|
+
counter-increment: prosemirror-flat-list-counter;
|
|
73
|
+
|
|
74
|
+
/*
|
|
75
|
+
Reset the counter for the first list node in the sequence.
|
|
76
|
+
*/
|
|
77
|
+
&:first-child,
|
|
78
|
+
:not(&) + & {
|
|
79
|
+
counter-reset: prosemirror-flat-list-counter;
|
|
80
|
+
|
|
81
|
+
/*
|
|
82
|
+
If the first list node has a custom order number, set the counter to that value.
|
|
83
|
+
*/
|
|
84
|
+
&[data-list-order] {
|
|
85
|
+
@supports (counter-set: prosemirror-flat-list-counter 1) {
|
|
86
|
+
counter-set: prosemirror-flat-list-counter var(--prosemirror-flat-list-order);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/*
|
|
90
|
+
Safari older than version 17.2 doesn't support `counter-set`
|
|
91
|
+
*/
|
|
92
|
+
@supports not (counter-set: prosemirror-flat-list-counter 1) {
|
|
93
|
+
counter-increment: prosemirror-flat-list-counter var(--prosemirror-flat-list-order);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
&[data-list-kind="task"] {
|
|
100
|
+
& > .list-marker {
|
|
101
|
+
&,
|
|
102
|
+
& * {
|
|
103
|
+
/* Make sure that the checkbox is at the center */
|
|
104
|
+
display: flex;
|
|
105
|
+
align-items: center;
|
|
106
|
+
justify-content: center;
|
|
107
|
+
margin: 0;
|
|
108
|
+
padding: 0;
|
|
109
|
+
cursor: pointer;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
&[data-list-kind="toggle"] {
|
|
115
|
+
&[data-list-collapsable] > .list-marker {
|
|
116
|
+
cursor: pointer;
|
|
117
|
+
}
|
|
118
|
+
&:not([data-list-collapsable]) > .list-marker {
|
|
119
|
+
opacity: 40%;
|
|
120
|
+
pointer-events: none;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/* If collapsed, hide the second and futher children */
|
|
124
|
+
&[data-list-collapsable][data-list-collapsed] > .list-content > *:nth-child(n+2) {
|
|
125
|
+
display: none;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type {
|
|
2
|
+
LoroSyncPluginProps,
|
|
3
|
+
LoroUndoPluginProps,
|
|
4
|
+
} from 'loro-prosemirror'
|
|
5
|
+
export {
|
|
6
|
+
defineLoro,
|
|
7
|
+
type LoroExtension,
|
|
8
|
+
type LoroOptions,
|
|
9
|
+
} from './loro'
|
|
10
|
+
export { defineLoroCommands } from './loro-commands'
|
|
11
|
+
export {
|
|
12
|
+
defineLoroCursorPlugin,
|
|
13
|
+
type LoroCursorOptions,
|
|
14
|
+
} from './loro-cursor-plugin'
|
|
15
|
+
export { defineLoroKeymap } from './loro-keymap'
|
|
16
|
+
export { defineLoroSyncPlugin } from './loro-sync-plugin'
|
|
17
|
+
export { defineLoroUndoPlugin } from './loro-undo-plugin'
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineCommands,
|
|
3
|
+
type Extension,
|
|
4
|
+
} from '@prosekit/core'
|
|
5
|
+
import {
|
|
6
|
+
redo,
|
|
7
|
+
undo,
|
|
8
|
+
} from 'loro-prosemirror'
|
|
9
|
+
|
|
10
|
+
const commands = {
|
|
11
|
+
undo: () => undo,
|
|
12
|
+
redo: () => redo,
|
|
13
|
+
} as const
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export type LoroCommandsExtension = Extension<{
|
|
19
|
+
Commands: {
|
|
20
|
+
undo: []
|
|
21
|
+
redo: []
|
|
22
|
+
}
|
|
23
|
+
}>
|
|
24
|
+
|
|
25
|
+
export function defineLoroCommands(): LoroCommandsExtension {
|
|
26
|
+
return defineCommands(commands)
|
|
27
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {
|
|
2
|
+
definePlugin,
|
|
3
|
+
type PlainExtension,
|
|
4
|
+
} from '@prosekit/core'
|
|
5
|
+
import type {
|
|
6
|
+
EditorState,
|
|
7
|
+
Selection,
|
|
8
|
+
} from '@prosekit/pm/state'
|
|
9
|
+
import type { DecorationAttrs } from '@prosekit/pm/view'
|
|
10
|
+
import type { PeerID } from 'loro-crdt'
|
|
11
|
+
import {
|
|
12
|
+
LoroCursorPlugin,
|
|
13
|
+
type CursorAwareness,
|
|
14
|
+
} from 'loro-prosemirror'
|
|
15
|
+
|
|
16
|
+
export interface LoroCursorOptions {
|
|
17
|
+
awareness: CursorAwareness
|
|
18
|
+
getSelection?: (state: EditorState) => Selection
|
|
19
|
+
createCursor?: (user: PeerID) => Element
|
|
20
|
+
createSelection?: (user: PeerID) => DecorationAttrs
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function defineLoroCursorPlugin(
|
|
24
|
+
options: LoroCursorOptions,
|
|
25
|
+
): PlainExtension {
|
|
26
|
+
const { awareness, ...rest } = options
|
|
27
|
+
return definePlugin(LoroCursorPlugin(awareness, rest))
|
|
28
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineKeymap,
|
|
3
|
+
isApple,
|
|
4
|
+
type Keymap,
|
|
5
|
+
type PlainExtension,
|
|
6
|
+
} from '@prosekit/core'
|
|
7
|
+
import {
|
|
8
|
+
redo,
|
|
9
|
+
undo,
|
|
10
|
+
} from 'loro-prosemirror'
|
|
11
|
+
|
|
12
|
+
const keymap: Keymap = {
|
|
13
|
+
'Mod-z': undo,
|
|
14
|
+
'Shift-Mod-z': redo,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (!isApple) {
|
|
18
|
+
keymap['Mod-y'] = redo
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function defineLoroKeymap(): PlainExtension {
|
|
22
|
+
return defineKeymap(keymap)
|
|
23
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
definePlugin,
|
|
3
|
+
type PlainExtension,
|
|
4
|
+
} from '@prosekit/core'
|
|
5
|
+
import {
|
|
6
|
+
LoroSyncPlugin,
|
|
7
|
+
type LoroSyncPluginProps,
|
|
8
|
+
} from 'loro-prosemirror'
|
|
9
|
+
|
|
10
|
+
export function defineLoroSyncPlugin(
|
|
11
|
+
options: LoroSyncPluginProps,
|
|
12
|
+
): PlainExtension {
|
|
13
|
+
return definePlugin(LoroSyncPlugin(options))
|
|
14
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
definePlugin,
|
|
3
|
+
type PlainExtension,
|
|
4
|
+
} from '@prosekit/core'
|
|
5
|
+
import {
|
|
6
|
+
LoroUndoPlugin,
|
|
7
|
+
type LoroUndoPluginProps,
|
|
8
|
+
} from 'loro-prosemirror'
|
|
9
|
+
|
|
10
|
+
export function defineLoroUndoPlugin(options: LoroUndoPluginProps): PlainExtension {
|
|
11
|
+
return definePlugin(LoroUndoPlugin(options))
|
|
12
|
+
}
|