@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
|
@@ -102,4 +102,5 @@ declare class AutocompleteRule {
|
|
|
102
102
|
//#region src/autocomplete/autocomplete.d.ts
|
|
103
103
|
declare function defineAutocomplete(rule: AutocompleteRule): Extension;
|
|
104
104
|
//#endregion
|
|
105
|
-
export { AutocompleteRule, type AutocompleteRuleOptions, type CanMatchOptions, type CanMatchPredicate, type MatchHandler, type MatchHandlerOptions, defineAutocomplete };
|
|
105
|
+
export { AutocompleteRule, type AutocompleteRuleOptions, type CanMatchOptions, type CanMatchPredicate, type MatchHandler, type MatchHandlerOptions, defineAutocomplete };
|
|
106
|
+
//# sourceMappingURL=prosekit-extensions-autocomplete.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prosekit-extensions-autocomplete.d.ts","names":[],"sources":["../src/autocomplete/autocomplete-rule.ts","../src/autocomplete/autocomplete.ts"],"sourcesContent":[],"mappings":";;;;;;;AAOiB,UAAA,mBAAA,CAAmB;EAAA;;;EASZ,KAAA,EALf,WAKe;EA8BZ;AAKZ;AAUA;EAKiB,KAAA,EAlDR,eAkDQ;EAAuB;;;MAmB5B,EAAA,MAAA;;;AAeZ;EAA6B,EAAA,EAAA,MAAA;;;;;aAUN,EAAA,GAAA,GAAA,IAAA;EAAuB;;;;ACnG9C;EAAkC,WAAA,EAAA,GAAA,GAAA,IAAA;;;;;;KDmCtB,YAAA,aAAyB;;;;UAKpB,eAAA;;;;SAIR;;;;;KAMG,iBAAA,aAA8B;;;;UAKzB,uBAAA;;;;;;;;SAQR;;;;;WAME;;;;YAKC;;;;;;aAOC;;;;;;;cAQA,gBAAA;;kBAEK;;oBAEE;;qBAEC;;;WAEmB;;uBAEjB;;;;iBCnGP,kBAAA,OAAyB,mBAAmB"}
|
|
@@ -136,14 +136,6 @@ const autocompleteFacet = defineFacet({
|
|
|
136
136
|
* @public
|
|
137
137
|
*/
|
|
138
138
|
var AutocompleteRule = class {
|
|
139
|
-
/** @internal */
|
|
140
|
-
regex;
|
|
141
|
-
/** @internal */
|
|
142
|
-
onMatch;
|
|
143
|
-
/** @internal */
|
|
144
|
-
onLeave;
|
|
145
|
-
/** @internal */
|
|
146
|
-
canMatch;
|
|
147
139
|
constructor(options) {
|
|
148
140
|
this.regex = options.regex;
|
|
149
141
|
this.onMatch = options.onEnter;
|
|
@@ -153,4 +145,5 @@ var AutocompleteRule = class {
|
|
|
153
145
|
};
|
|
154
146
|
|
|
155
147
|
//#endregion
|
|
156
|
-
export { AutocompleteRule, defineAutocomplete };
|
|
148
|
+
export { AutocompleteRule, defineAutocomplete };
|
|
149
|
+
//# sourceMappingURL=prosekit-extensions-autocomplete.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prosekit-extensions-autocomplete.js","names":["pluginKey: PluginKey<PredictionPluginState>","parentOffset: number","textBefore: string","rules: AutocompleteRule[]"],"sources":["../src/autocomplete/autocomplete-helpers.ts","../src/autocomplete/autocomplete-plugin.ts","../src/autocomplete/autocomplete.ts","../src/autocomplete/autocomplete-rule.ts"],"sourcesContent":["import type { ResolvedPos } from '@prosekit/pm/model'\nimport {\n PluginKey,\n type EditorState,\n type Transaction,\n} from '@prosekit/pm/state'\n\nimport type { AutocompleteRule } from './autocomplete-rule'\n\nexport function defaultCanMatch({ state }: { state: EditorState }): boolean {\n return state.selection.empty && !isInsideCode(state.selection.$from)\n}\n\nfunction isInsideCode($pos: ResolvedPos): boolean {\n for (let d = $pos.depth; d > 0; d--) {\n if ($pos.node(d).type.spec.code) {\n return true\n }\n }\n\n return $pos.marks().some((mark) => mark.type.name === 'code')\n}\n\n/**\n * @internal\n */\nexport interface PredictionPluginMatching {\n rule: AutocompleteRule\n from: number\n to: number\n match: RegExpExecArray\n}\n\n/**\n * @internal\n */\nexport interface PredictionPluginState {\n /**\n * The matching positions that should be ignored.\n */\n ignores: number[]\n\n /**\n * The current active matching.\n */\n matching: PredictionPluginMatching | null\n}\n\n/**\n * @internal\n */\ninterface PredictionTransactionMeta {\n /**\n * The from position that should be ignored.\n */\n ignore: number\n}\n\nexport function getPluginState(state: EditorState): PredictionPluginState | undefined {\n return pluginKey.getState(state)\n}\n\nexport function getTrMeta(tr: Transaction): PredictionTransactionMeta | undefined {\n return tr.getMeta(pluginKey) as PredictionTransactionMeta | undefined\n}\n\nexport function setTrMeta(\n tr: Transaction,\n meta: PredictionTransactionMeta,\n): Transaction {\n return tr.setMeta(pluginKey, meta)\n}\n\nexport const pluginKey: PluginKey<PredictionPluginState> = new PluginKey<PredictionPluginState>('prosekit-autocomplete')\n","import { OBJECT_REPLACEMENT_CHARACTER } from '@prosekit/core'\nimport {\n Plugin,\n type EditorState,\n type Transaction,\n} from '@prosekit/pm/state'\nimport {\n Decoration,\n DecorationSet,\n} from '@prosekit/pm/view'\n\nimport {\n getPluginState,\n getTrMeta,\n pluginKey,\n setTrMeta,\n type PredictionPluginMatching,\n type PredictionPluginState,\n} from './autocomplete-helpers'\nimport type { AutocompleteRule } from './autocomplete-rule'\n\nexport function createAutocompletePlugin({\n getRules,\n}: {\n getRules: () => AutocompleteRule[]\n}): Plugin {\n return new Plugin<PredictionPluginState>({\n key: pluginKey,\n\n state: {\n init: (): PredictionPluginState => {\n return { ignores: [], matching: null }\n },\n apply: (\n tr: Transaction,\n prevValue: PredictionPluginState,\n oldState: EditorState,\n newState: EditorState,\n ): PredictionPluginState => {\n const meta = getTrMeta(tr)\n\n // No changes\n if (\n !tr.docChanged\n && oldState.selection.eq(newState.selection)\n && !meta\n ) {\n return prevValue\n }\n\n // Receiving a meta means that we are ignoring a match\n if (meta) {\n let ignores = prevValue.ignores\n if (!ignores.includes(meta.ignore)) {\n ignores = [...ignores, meta.ignore]\n }\n return { matching: null, ignores }\n }\n\n // Calculate the new ignores\n const ignoreSet = new Set(prevValue.ignores.map(pos => tr.mapping.map(pos)))\n\n // Calculate the new matching\n let matching = calcPluginStateMatching(newState, getRules())\n\n // Check if the matching should be ignored\n if (matching && ignoreSet.has(matching.from)) {\n matching = null\n }\n\n // Return the new matching and ignores\n return { matching, ignores: Array.from(ignoreSet) }\n },\n },\n\n view: () => ({\n update: (view, prevState) => {\n const prevValue = getPluginState(prevState)\n const currValue = getPluginState(view.state)\n\n if (\n prevValue?.matching\n && prevValue.matching.rule !== currValue?.matching?.rule\n ) {\n // Deactivate the previous rule\n prevValue.matching.rule.onLeave?.()\n }\n\n if (\n currValue?.matching\n && !currValue.ignores.includes(currValue.matching.from)\n ) {\n // Activate the current rule\n\n const { from, to, match, rule } = currValue.matching\n\n const textContent = view.state.doc.textBetween(\n from,\n to,\n null,\n OBJECT_REPLACEMENT_CHARACTER,\n )\n\n const deleteMatch = () => {\n if (\n view.state.doc.textBetween(\n from,\n to,\n null,\n OBJECT_REPLACEMENT_CHARACTER,\n ) === textContent\n ) {\n view.dispatch(view.state.tr.delete(from, to))\n }\n }\n\n const ignoreMatch = () => {\n view.dispatch(\n setTrMeta(view.state.tr, { ignore: from }),\n )\n }\n\n rule.onMatch({\n state: view.state,\n match,\n from,\n to,\n deleteMatch,\n ignoreMatch,\n })\n }\n },\n }),\n\n props: {\n decorations: (state: EditorState) => {\n const pluginState = getPluginState(state)\n if (pluginState?.matching) {\n const { from, to } = pluginState.matching\n const deco = Decoration.inline(from, to, {\n class: 'prosemirror-prediction-match',\n })\n return DecorationSet.create(state.doc, [deco])\n }\n return null\n },\n },\n })\n}\n\nconst MAX_MATCH = 200\n\nfunction calcPluginStateMatching(\n state: EditorState,\n rules: AutocompleteRule[],\n): PredictionPluginMatching | null {\n const $pos = state.selection.$from\n\n const parentOffset: number = $pos.parentOffset\n\n const textBefore: string = $pos.parent.textBetween(\n Math.max(0, parentOffset - MAX_MATCH),\n parentOffset,\n null,\n OBJECT_REPLACEMENT_CHARACTER,\n )\n\n for (const rule of rules) {\n if (!rule.canMatch({ state })) {\n continue\n }\n\n rule.regex.lastIndex = 0\n const match = rule.regex.exec(textBefore)\n if (!match) {\n continue\n }\n\n const to = $pos.pos\n const from = to - textBefore.length + match.index\n\n return { rule, match, from, to }\n }\n\n return null\n}\n","import {\n defineFacet,\n defineFacetPayload,\n pluginFacet,\n type Extension,\n type PluginPayload,\n} from '@prosekit/core'\n\nimport { createAutocompletePlugin } from './autocomplete-plugin'\nimport type { AutocompleteRule } from './autocomplete-rule'\n\nexport function defineAutocomplete(rule: AutocompleteRule): Extension {\n return defineFacetPayload(autocompleteFacet, [rule])\n}\n\nconst autocompleteFacet = defineFacet<AutocompleteRule, PluginPayload>({\n reduce: () => {\n let rules: AutocompleteRule[] = []\n const getRules = () => rules\n const plugin = createAutocompletePlugin({ getRules })\n\n return function reducer(inputs) {\n rules = inputs\n return plugin\n }\n },\n parent: pluginFacet,\n singleton: true,\n})\n","import type { EditorState } from '@prosekit/pm/state'\n\nimport { defaultCanMatch } from './autocomplete-helpers'\n\n/**\n * Options for the {@link MatchHandler} callback.\n */\nexport interface MatchHandlerOptions {\n /**\n * The editor state.\n */\n state: EditorState\n\n /**\n * The result of `RegExp.exec`.\n */\n match: RegExpExecArray\n\n /**\n * The start position of the matched text.\n */\n from: number\n\n /**\n * The end position of the matched text.\n */\n to: number\n\n /**\n * Call this function to ignore the match. You probably want to call this\n * function when the user presses the `Escape` key.\n */\n ignoreMatch: () => void\n\n /**\n * Call this function to delete the matched text. For example, in a slash\n * menu, you might want to delete the matched text first then do something\n * else when the user presses the `Enter` key.\n */\n deleteMatch: () => void\n}\n\n/**\n * A callback that is called when the rule starts to match, and also on\n * subsequent updates while the rule continues to match.\n */\nexport type MatchHandler = (options: MatchHandlerOptions) => void\n\n/**\n * Options for the {@link CanMatchPredicate} callback.\n */\nexport interface CanMatchOptions {\n /**\n * The editor state.\n */\n state: EditorState\n}\n\n/**\n * A predicate to determine if the rule can be applied in the current editor state.\n */\nexport type CanMatchPredicate = (options: CanMatchOptions) => boolean\n\n/**\n * Options for creating an {@link AutocompleteRule}\n */\nexport interface AutocompleteRuleOptions {\n /**\n * The regular expression to match against the text before the cursor. The\n * last match before the cursor is used.\n *\n * For a slash menu, you might use `/(?<!\\S)\\/(|\\S.*)$/u`.\n * For a mention, you might use `/@\\w*$/`\n */\n regex: RegExp\n\n /**\n * A callback that is called when the rule starts to match, and also on\n * subsequent updates while the rule continues to match.\n */\n onEnter: MatchHandler\n\n /**\n * A callback that is called when the rule stops matching.\n */\n onLeave?: VoidFunction\n\n /**\n * A predicate to determine if the rule can be applied in the current editor\n * state. If not provided, it defaults to only allowing matches in empty\n * selections that are not inside a code block or code mark.\n */\n canMatch?: CanMatchPredicate\n}\n\n/**\n * An autocomplete rule that can be used to create an autocomplete extension.\n *\n * @public\n */\nexport class AutocompleteRule {\n /** @internal */\n readonly regex: RegExp\n /** @internal */\n readonly onMatch: MatchHandler\n /** @internal */\n readonly onLeave?: VoidFunction\n /** @internal */\n readonly canMatch: (options: { state: EditorState }) => boolean\n\n constructor(options: AutocompleteRuleOptions) {\n this.regex = options.regex\n this.onMatch = options.onEnter\n this.onLeave = options.onLeave\n this.canMatch = options.canMatch ?? defaultCanMatch\n }\n}\n"],"mappings":"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"}
|
|
@@ -45,4 +45,5 @@ declare function defineBlockquoteInputRule(): PlainExtension;
|
|
|
45
45
|
*/
|
|
46
46
|
declare function defineBlockquoteKeymap(): PlainExtension;
|
|
47
47
|
//#endregion
|
|
48
|
-
export { type BlockquoteCommandsExtension, type BlockquoteExtension, type BlockquoteSpecExtension, defineBlockquote, defineBlockquoteCommands, defineBlockquoteInputRule, defineBlockquoteKeymap, defineBlockquoteSpec };
|
|
48
|
+
export { type BlockquoteCommandsExtension, type BlockquoteExtension, type BlockquoteSpecExtension, defineBlockquote, defineBlockquoteCommands, defineBlockquoteInputRule, defineBlockquoteKeymap, defineBlockquoteSpec };
|
|
49
|
+
//# sourceMappingURL=prosekit-extensions-blockquote.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prosekit-extensions-blockquote.d.ts","names":[],"sources":["../src/blockquote/blockquote-commands.ts","../src/blockquote/blockquote-spec.ts","../src/blockquote/blockquote.ts","../src/blockquote/blockquote-input-rule.ts","../src/blockquote/blockquote-keymap.ts"],"sourcesContent":[],"mappings":";;;;KAQY,2BAAA,GAA8B;;;IAA9B,gBAAA,EAAA,EAAA;IAWI,gBAAA,EAAA,EAAA;;;;ACbhB;;AAEgB,iBDWA,wBAAA,CAAA,CCXA,EDW4B,2BCX5B;;;KAFJ,uBAAA,GAA0B;;IDE1B,UAAA,ECAI,KDAJ;EAWI,CAAA;;iBCPA,oBAAA,CAAA,GAAwB;;;;ADJxC;AAWA;KEAY,mBAAA,GAAsB,OAC/B,yBAAyB,4BDd5B,CAAA;;;;AAA+C,iBCoB/B,gBAAA,CAAA,CDpB+B,ECoBX,mBDpBW;;;;;;ADE/C;AAWgB,iBGXA,yBAAA,CAAA,CHW4B,EGXC,cHWD;;;;;;AAXhC,iBIiBI,sBAAA,CAAA,CJjB0B,EIiBA,cJjBS"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineWrappingInputRule } from "./input-rule-
|
|
1
|
+
import { defineWrappingInputRule } from "./input-rule-B17tpW4m.js";
|
|
2
2
|
import { defineCommands, defineKeymap, defineNodeSpec, insertNode, isAtBlockStart, toggleWrap, union, wrap } from "@prosekit/core";
|
|
3
3
|
import { joinBackward } from "@prosekit/pm/commands";
|
|
4
4
|
|
|
@@ -40,8 +40,7 @@ function toggleBlockquoteKeybinding() {
|
|
|
40
40
|
}
|
|
41
41
|
function backspaceUnsetBlockquote() {
|
|
42
42
|
return (state, dispatch, view) => {
|
|
43
|
-
|
|
44
|
-
if ($pos?.node(-1).type.name === "blockquote") return joinBackward(state, dispatch, view);
|
|
43
|
+
if (isAtBlockStart(state, view)?.node(-1).type.name === "blockquote") return joinBackward(state, dispatch, view);
|
|
45
44
|
return false;
|
|
46
45
|
};
|
|
47
46
|
}
|
|
@@ -80,4 +79,5 @@ function defineBlockquote() {
|
|
|
80
79
|
}
|
|
81
80
|
|
|
82
81
|
//#endregion
|
|
83
|
-
export { defineBlockquote, defineBlockquoteCommands, defineBlockquoteInputRule, defineBlockquoteKeymap, defineBlockquoteSpec };
|
|
82
|
+
export { defineBlockquote, defineBlockquoteCommands, defineBlockquoteInputRule, defineBlockquoteKeymap, defineBlockquoteSpec };
|
|
83
|
+
//# sourceMappingURL=prosekit-extensions-blockquote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prosekit-extensions-blockquote.js","names":[],"sources":["../src/blockquote/blockquote-commands.ts","../src/blockquote/blockquote-input-rule.ts","../src/blockquote/blockquote-keymap.ts","../src/blockquote/blockquote-spec.ts","../src/blockquote/blockquote.ts"],"sourcesContent":["import {\n defineCommands,\n insertNode,\n toggleWrap,\n wrap,\n type Extension,\n} from '@prosekit/core'\n\nexport type BlockquoteCommandsExtension = Extension<{\n Commands: {\n setBlockquote: []\n insertBlockquote: []\n toggleBlockquote: []\n }\n}>\n\n/**\n * @internal\n */\nexport function defineBlockquoteCommands(): BlockquoteCommandsExtension {\n return defineCommands({\n setBlockquote: () => {\n return wrap({ type: 'blockquote' })\n },\n insertBlockquote: () => {\n return insertNode({ type: 'blockquote' })\n },\n toggleBlockquote: () => {\n return toggleWrap({ type: 'blockquote' })\n },\n })\n}\n","import type { PlainExtension } from '@prosekit/core'\n\nimport { defineWrappingInputRule } from '../input-rule'\n\n/**\n * Wraps the text block in a blockquote when `>` is typed at the start of a new\n * line followed by a space.\n */\nexport function defineBlockquoteInputRule(): PlainExtension {\n return defineWrappingInputRule({\n regex: /^>\\s/,\n type: 'blockquote',\n })\n}\n","import {\n defineKeymap,\n isAtBlockStart,\n toggleWrap,\n type PlainExtension,\n} from '@prosekit/core'\nimport { joinBackward } from '@prosekit/pm/commands'\nimport type { Command } from '@prosekit/pm/state'\n\nfunction toggleBlockquoteKeybinding(): Command {\n return toggleWrap({ type: 'blockquote' })\n}\n\nfunction backspaceUnsetBlockquote(): Command {\n return (state, dispatch, view) => {\n const $pos = isAtBlockStart(state, view)\n if ($pos?.node(-1).type.name === 'blockquote') {\n return joinBackward(state, dispatch, view)\n }\n return false\n }\n}\n/**\n * @internal\n */\nexport function defineBlockquoteKeymap(): PlainExtension {\n return defineKeymap({\n 'mod-shift-b': toggleBlockquoteKeybinding(),\n 'Backspace': backspaceUnsetBlockquote(),\n })\n}\n","import {\n defineNodeSpec,\n type Extension,\n} from '@prosekit/core'\nimport type { Attrs } from '@prosekit/pm/model'\n\nexport type BlockquoteSpecExtension = Extension<{\n Nodes: {\n blockquote: Attrs\n }\n}>\n\nexport function defineBlockquoteSpec(): BlockquoteSpecExtension {\n return defineNodeSpec({\n name: 'blockquote',\n content: 'block+',\n group: 'block',\n defining: true,\n parseDOM: [{ tag: 'blockquote' }],\n toDOM() {\n return ['blockquote', 0]\n },\n })\n}\n","import {\n union,\n type Union,\n} from '@prosekit/core'\n\nimport {\n defineBlockquoteCommands,\n type BlockquoteCommandsExtension,\n} from './blockquote-commands'\nimport { defineBlockquoteInputRule } from './blockquote-input-rule'\nimport { defineBlockquoteKeymap } from './blockquote-keymap'\nimport {\n defineBlockquoteSpec,\n type BlockquoteSpecExtension,\n} from './blockquote-spec'\n\n/**\n * @internal\n */\nexport type BlockquoteExtension = Union<\n [BlockquoteSpecExtension, BlockquoteCommandsExtension]\n>\n\n/**\n * @public\n */\nexport function defineBlockquote(): BlockquoteExtension {\n return union(\n defineBlockquoteSpec(),\n defineBlockquoteInputRule(),\n defineBlockquoteCommands(),\n defineBlockquoteKeymap(),\n )\n}\n"],"mappings":";;;;;;;;AAmBA,SAAgB,2BAAwD;AACtE,QAAO,eAAe;EACpB,qBAAqB;AACnB,UAAO,KAAK,EAAE,MAAM,cAAc,CAAC;;EAErC,wBAAwB;AACtB,UAAO,WAAW,EAAE,MAAM,cAAc,CAAC;;EAE3C,wBAAwB;AACtB,UAAO,WAAW,EAAE,MAAM,cAAc,CAAC;;EAE5C,CAAC;;;;;;;;;ACtBJ,SAAgB,4BAA4C;AAC1D,QAAO,wBAAwB;EAC7B,OAAO;EACP,MAAM;EACP,CAAC;;;;;ACHJ,SAAS,6BAAsC;AAC7C,QAAO,WAAW,EAAE,MAAM,cAAc,CAAC;;AAG3C,SAAS,2BAAoC;AAC3C,SAAQ,OAAO,UAAU,SAAS;AAEhC,MADa,eAAe,OAAO,KAAK,EAC9B,KAAK,GAAG,CAAC,KAAK,SAAS,aAC/B,QAAO,aAAa,OAAO,UAAU,KAAK;AAE5C,SAAO;;;;;;AAMX,SAAgB,yBAAyC;AACvD,QAAO,aAAa;EAClB,eAAe,4BAA4B;EAC3C,aAAa,0BAA0B;EACxC,CAAC;;;;;ACjBJ,SAAgB,uBAAgD;AAC9D,QAAO,eAAe;EACpB,MAAM;EACN,SAAS;EACT,OAAO;EACP,UAAU;EACV,UAAU,CAAC,EAAE,KAAK,cAAc,CAAC;EACjC,QAAQ;AACN,UAAO,CAAC,cAAc,EAAE;;EAE3B,CAAC;;;;;;;;ACIJ,SAAgB,mBAAwC;AACtD,QAAO,MACL,sBAAsB,EACtB,2BAA2B,EAC3B,0BAA0B,EAC1B,wBAAwB,CACzB"}
|
|
@@ -51,4 +51,5 @@ declare function defineBoldInputRule(): PlainExtension;
|
|
|
51
51
|
*/
|
|
52
52
|
declare function defineBoldKeymap(): PlainExtension;
|
|
53
53
|
//#endregion
|
|
54
|
-
export { type BoldCommandsExtension, type BoldExtension, type BoldSpecExtension, defineBold, defineBoldCommands, defineBoldInputRule, defineBoldKeymap, defineBoldSpec };
|
|
54
|
+
export { type BoldCommandsExtension, type BoldExtension, type BoldSpecExtension, defineBold, defineBoldCommands, defineBoldInputRule, defineBoldKeymap, defineBoldSpec };
|
|
55
|
+
//# sourceMappingURL=prosekit-extensions-bold.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prosekit-extensions-bold.d.ts","names":[],"sources":["../src/bold/bold-commands.ts","../src/bold/bold-spec.ts","../src/bold/bold.ts","../src/bold/bold-input-rule.ts","../src/bold/bold-keymap.ts"],"sourcesContent":[],"mappings":";;;;;;;AASY,KAAA,qBAAA,GAAwB,SAAA,CAAA;EASpB,QAAA,EAAA;;;;ACThB;;;AAAgC,iBDShB,kBAAA,CAAA,CCTgB,EDSM,qBCTN;;;;;ADAhC;AASgB,KCTJ,iBAAA,GAAoB,SDSM,CAAA;;UCP5B;;AAFV,CAAA,CAAA;;;;AAAyC,iBASzB,cAAA,CAAA,CATyB,EASP,iBATO;;;;ADAzC;AASA;KECY,aAAA,GAAgB,OAAO,mBAAmB;;;ADVtD;AAA6B,iBCeb,UAAA,CAAA,CDfa,ECeC,aDfD;;;;;;ADAjB,iBGCI,mBAAA,CAAA,CHDoB,EGCG,cHDM;;;;;;AAAjC,iBIAI,gBAAA,CAAA,CJAoB,EIAA,cJAS"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineMarkInputRule } from "./input-rule-
|
|
1
|
+
import { defineMarkInputRule } from "./input-rule-B17tpW4m.js";
|
|
2
2
|
import { canUseRegexLookbehind, defineCommands, defineKeymap, defineMarkSpec, toggleMark, union } from "@prosekit/core";
|
|
3
3
|
|
|
4
4
|
//#region src/bold/bold-commands.ts
|
|
@@ -73,4 +73,5 @@ function defineBold() {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
//#endregion
|
|
76
|
-
export { defineBold, defineBoldCommands, defineBoldInputRule, defineBoldKeymap, defineBoldSpec };
|
|
76
|
+
export { defineBold, defineBoldCommands, defineBoldInputRule, defineBoldKeymap, defineBoldSpec };
|
|
77
|
+
//# sourceMappingURL=prosekit-extensions-bold.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prosekit-extensions-bold.js","names":[],"sources":["../src/bold/bold-commands.ts","../src/bold/bold-input-rule.ts","../src/bold/bold-keymap.ts","../src/bold/bold-spec.ts","../src/bold/bold.ts"],"sourcesContent":["import {\n defineCommands,\n toggleMark,\n type Extension,\n} from '@prosekit/core'\n\n/**\n * @internal\n */\nexport type BoldCommandsExtension = Extension<{\n Commands: {\n toggleBold: []\n }\n}>\n\n/**\n * @internal\n */\nexport function defineBoldCommands(): BoldCommandsExtension {\n return defineCommands({\n toggleBold: () => toggleMark({ type: 'bold' }),\n })\n}\n","import {\n canUseRegexLookbehind,\n type PlainExtension,\n} from '@prosekit/core'\n\nimport { defineMarkInputRule } from '../input-rule'\n\n/**\n * @internal\n */\nexport function defineBoldInputRule(): PlainExtension {\n return defineMarkInputRule({\n regex: canUseRegexLookbehind()\n ? /(?<=\\s|^)\\*\\*([^\\s*]|[^\\s*][^*]*[^\\s*])\\*\\*$/\n : /\\*\\*([^\\s*]|[^\\s*][^*]*[^\\s*])\\*\\*$/,\n type: 'bold',\n })\n}\n","import {\n defineKeymap,\n toggleMark,\n type PlainExtension,\n} from '@prosekit/core'\n\n/**\n * @internal\n */\nexport function defineBoldKeymap(): PlainExtension {\n return defineKeymap({\n 'Mod-b': toggleMark({ type: 'bold' }),\n })\n}\n","import {\n defineMarkSpec,\n type Extension,\n} from '@prosekit/core'\nimport type { Attrs } from '@prosekit/pm/model'\n\n/**\n * @internal\n */\nexport type BoldSpecExtension = Extension<{\n Marks: {\n bold: Attrs\n }\n}>\n\n/**\n * @internal\n */\nexport function defineBoldSpec(): BoldSpecExtension {\n return defineMarkSpec({\n name: 'bold',\n parseDOM: [\n { tag: 'strong' },\n // This works around a Google Docs misbehavior where\n // pasted content will be inexplicably wrapped in `<b>`\n // tags with a font-weight normal.\n {\n tag: 'b',\n getAttrs: (node: string | HTMLElement): null | false => {\n return (\n typeof node !== 'string'\n && node.style.fontWeight !== 'normal'\n && null\n )\n },\n },\n { style: 'font-weight=400', clearMark: (m) => m.type.name == 'strong' },\n {\n style: 'font-weight',\n getAttrs: (value: string | HTMLElement): null | false => {\n return (\n typeof value === 'string'\n && /^(bold(er)?|[5-9]\\d{2,})$/.test(value)\n && null\n )\n },\n },\n ],\n toDOM() {\n return ['strong', 0]\n },\n })\n}\n","import {\n union,\n type Union,\n} from '@prosekit/core'\n\nimport {\n defineBoldCommands,\n type BoldCommandsExtension,\n} from './bold-commands'\nimport { defineBoldInputRule } from './bold-input-rule'\nimport { defineBoldKeymap } from './bold-keymap'\nimport {\n defineBoldSpec,\n type BoldSpecExtension,\n} from './bold-spec'\n\n/**\n * @internal\n */\nexport type BoldExtension = Union<[BoldSpecExtension, BoldCommandsExtension]>\n\n/**\n * @public\n */\nexport function defineBold(): BoldExtension {\n return union(\n defineBoldSpec(),\n defineBoldCommands(),\n defineBoldKeymap(),\n defineBoldInputRule(),\n )\n}\n"],"mappings":";;;;;;;AAkBA,SAAgB,qBAA4C;AAC1D,QAAO,eAAe,EACpB,kBAAkB,WAAW,EAAE,MAAM,QAAQ,CAAC,EAC/C,CAAC;;;;;;;;ACXJ,SAAgB,sBAAsC;AACpD,QAAO,oBAAoB;EACzB,OAAO,uBAAuB,GAC1B,iDACA;EACJ,MAAM;EACP,CAAC;;;;;;;;ACPJ,SAAgB,mBAAmC;AACjD,QAAO,aAAa,EAClB,SAAS,WAAW,EAAE,MAAM,QAAQ,CAAC,EACtC,CAAC;;;;;;;;ACMJ,SAAgB,iBAAoC;AAClD,QAAO,eAAe;EACpB,MAAM;EACN,UAAU;GACR,EAAE,KAAK,UAAU;GAIjB;IACE,KAAK;IACL,WAAW,SAA6C;AACtD,YACE,OAAO,SAAS,YACb,KAAK,MAAM,eAAe,YAC1B;;IAGR;GACD;IAAE,OAAO;IAAmB,YAAY,MAAM,EAAE,KAAK,QAAQ;IAAU;GACvE;IACE,OAAO;IACP,WAAW,UAA8C;AACvD,YACE,OAAO,UAAU,YACd,4BAA4B,KAAK,MAAM,IACvC;;IAGR;GACF;EACD,QAAQ;AACN,UAAO,CAAC,UAAU,EAAE;;EAEvB,CAAC;;;;;;;;AC3BJ,SAAgB,aAA4B;AAC1C,QAAO,MACL,gBAAgB,EAChB,oBAAoB,EACpB,kBAAkB,EAClB,qBAAqB,CACtB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ShikiHighlighterOptions } from "./shiki-highlighter-chunk-
|
|
1
|
+
import { ShikiHighlighterOptions } from "./shiki-highlighter-chunk-Cwu1Jr9o.js";
|
|
2
2
|
import { Extension, PlainExtension, Union } from "@prosekit/core";
|
|
3
3
|
import { Parser } from "prosemirror-highlight";
|
|
4
4
|
import { BundledLanguage as ShikiBundledLanguage, BundledLanguageInfo as ShikiBundledLanguageInfo, BundledTheme as ShikiBundledTheme, BundledThemeInfo as ShikiBundledThemeInfo, SpecialLanguage, bundledLanguagesInfo as shikiBundledLanguagesInfo, bundledThemesInfo as shikiBundledThemesInfo } from "shiki";
|
|
@@ -156,4 +156,5 @@ declare function defineCodeBlockShiki({
|
|
|
156
156
|
...rest
|
|
157
157
|
}?: CodeBlockShikiOptions): Extension;
|
|
158
158
|
//#endregion
|
|
159
|
-
export { type CodeBlockAttrs, type CodeBlockCommandsExtension, type CodeBlockExtension, type CodeBlockHighlightOptions, type CodeBlockSpecExtension, type HighlightParser, type ShikiBundledLanguage, type ShikiBundledLanguageInfo, type ShikiBundledTheme, type ShikiBundledThemeInfo, defineCodeBlock, defineCodeBlockCommands, defineCodeBlockEnterRule, defineCodeBlockHighlight, defineCodeBlockInputRule, defineCodeBlockKeymap, defineCodeBlockShiki, defineCodeBlockSpec, shikiBundledLanguagesInfo, shikiBundledThemesInfo };
|
|
159
|
+
export { type CodeBlockAttrs, type CodeBlockCommandsExtension, type CodeBlockExtension, type CodeBlockHighlightOptions, type CodeBlockSpecExtension, type HighlightParser, type ShikiBundledLanguage, type ShikiBundledLanguageInfo, type ShikiBundledTheme, type ShikiBundledThemeInfo, defineCodeBlock, defineCodeBlockCommands, defineCodeBlockEnterRule, defineCodeBlockHighlight, defineCodeBlockInputRule, defineCodeBlockKeymap, defineCodeBlockShiki, defineCodeBlockSpec, shikiBundledLanguagesInfo, shikiBundledThemesInfo };
|
|
160
|
+
//# sourceMappingURL=prosekit-extensions-code-block.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prosekit-extensions-code-block.d.ts","names":[],"sources":["../src/code-block/code-block-types.ts","../src/code-block/code-block-commands.ts","../src/code-block/code-block-spec.ts","../src/code-block/code-block.ts","../src/code-block/code-block-highlight.ts","../src/code-block/code-block-input-rule.ts","../src/code-block/code-block-keymap.ts","../src/code-block/code-block-shiki.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;UAKiB,cAAA;EAAA,QAAA,EAAA,MAAA;;;;;;;KCSL,0BAAA,GAA6B;EDTxB,QAAA,EAAA;2BCWU;8BACG;8BACA;IAJlB,iBAAA,EAAA,CAAA,KAA0B,EAKP,cALO,CAAA;EAAA,CAAA;;;;;;;AActB,iBAAA,uBAAA,CAAA,CAA2B,EAAA,0BAA0B;;;;;;KClBzD,sBAAA,GAAyB;EFLpB,KAAA,EAAA;eEOF;;;ADEf;;;;;AAK+B,iBCEf,mBAAA,CAAA,CDFe,ECEQ,sBDFR;;;;;;ADdd,KGiBL,kBAAA,GAAqB,KHjBF,CAAA,CGkB5B,wBAAwB;AFT3B;;;;;;;;AAcA;;;iBESgB,eAAA,CAAA,GAAmB;;;;;;;AHhCnC;KISY,eAAA,GAAkB;;;AHA9B;AAAsC,KGK1B,yBAAA,GHL0B;QAEX,EGIjB,eHJiB;;;;;;AAY3B;;;;AClBA;;AAEe,iBEqBC,wBAAA,CFrBD;EAAA;AAAA,CAAA,EEuBZ,yBFvBY,CAAA,EEuBgB,SFvBhB;;;;;;;;AFPE,iBKOD,wBAAA,CAAA,CLPe,EKOa,cLPb;;;;ACS/B;;AAE2B,iBISX,wBAAA,CAAA,CJTW,EISiB,cJTjB;;;;;;iBKHX,qBAAA,CAAA,GAAyB;;;;;ANRzC;;;UOWiB,qBAAA,SAA8B,KAAK;ENFxC;;;;;;QAA6B,CAAA,EMS9B,iBNT8B,EAAA;EAAS;AAclD;;;;EClBY,KAAA,CAAA,EAAA,CKoBD,oBLpBuB,GKoBA,eLpBA,CAAA,EAAA;EAAA;;;EAAY,MAAA,CAAA,EKyBnC,uBLzBmC,CAAA,QAAA,CAAA;AAW9C;;;;ACCA;;;;;;AAeA;;;iBIagB,oBAAA;;;;IAIb,wBAA6B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineTextBlockInputRule } from "./input-rule-
|
|
1
|
+
import { defineTextBlockInputRule } from "./input-rule-B17tpW4m.js";
|
|
2
2
|
import { defineTextBlockEnterRule } from "./enter-rule-RdhEA900.js";
|
|
3
3
|
import { defaultBlockAt, defineCommands, defineKeymap, defineNodeSpec, definePlugin, insertNode, setBlockType, setNodeAttrs, toggleNode, union } from "@prosekit/core";
|
|
4
4
|
import { TextSelection } from "@prosekit/pm/state";
|
|
@@ -131,8 +131,7 @@ function defineCodeBlockSpec() {
|
|
|
131
131
|
tag: "pre",
|
|
132
132
|
preserveWhitespace: "full",
|
|
133
133
|
getAttrs: (node) => {
|
|
134
|
-
|
|
135
|
-
return { language };
|
|
134
|
+
return { language: extractLanguageFromElement(node) || extractLanguageFromElement(node.querySelector("code")) };
|
|
136
135
|
}
|
|
137
136
|
}],
|
|
138
137
|
toDOM(node) {
|
|
@@ -153,8 +152,7 @@ function extractLanguageFromElement(element) {
|
|
|
153
152
|
if (!element) return "";
|
|
154
153
|
const attr = element.getAttribute("data-language");
|
|
155
154
|
if (attr) return attr;
|
|
156
|
-
const
|
|
157
|
-
const match = className.match(/language-(\w+)/);
|
|
155
|
+
const match = element.className.match(/language-(\w+)/);
|
|
158
156
|
if (match) return match[1];
|
|
159
157
|
return "";
|
|
160
158
|
}
|
|
@@ -247,4 +245,5 @@ function defineCodeBlockShiki({ themes = ["one-dark-pro"], langs = ["text"],...r
|
|
|
247
245
|
}
|
|
248
246
|
|
|
249
247
|
//#endregion
|
|
250
|
-
export { defineCodeBlock, defineCodeBlockCommands, defineCodeBlockEnterRule, defineCodeBlockHighlight, defineCodeBlockInputRule, defineCodeBlockKeymap, defineCodeBlockShiki, defineCodeBlockSpec, shikiBundledLanguagesInfo, shikiBundledThemesInfo };
|
|
248
|
+
export { defineCodeBlock, defineCodeBlockCommands, defineCodeBlockEnterRule, defineCodeBlockHighlight, defineCodeBlockInputRule, defineCodeBlockKeymap, defineCodeBlockShiki, defineCodeBlockSpec, shikiBundledLanguagesInfo, shikiBundledThemesInfo };
|
|
249
|
+
//# sourceMappingURL=prosekit-extensions-code-block.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prosekit-extensions-code-block.js","names":["existCodeBlock: Command","loaded: ((options: HighlighterOptions) => HighlighterResult) | undefined","createOrGetHighlighter","parser: Parser | undefined"],"sources":["../src/code-block/code-block-commands.ts","../src/code-block/code-block-input-rule.ts","../src/code-block/code-block-keymap.ts","../src/code-block/code-block-spec.ts","../src/code-block/code-block.ts","../src/code-block/code-block-highlight.ts","../src/code-block/shiki-highlighter.ts","../src/code-block/shiki-parser.ts","../src/code-block/code-block-shiki.ts"],"sourcesContent":["import {\n defineCommands,\n insertNode,\n setBlockType,\n setNodeAttrs,\n toggleNode,\n type Extension,\n} from '@prosekit/core'\n\nimport type { CodeBlockAttrs } from './code-block-types'\n\n/**\n * @internal\n */\nexport type CodeBlockCommandsExtension = Extension<{\n Commands: {\n setCodeBlock: [attrs?: CodeBlockAttrs]\n insertCodeBlock: [attrs?: CodeBlockAttrs]\n toggleCodeBlock: [attrs?: CodeBlockAttrs]\n setCodeBlockAttrs: [attrs: CodeBlockAttrs]\n }\n}>\n\n/**\n * Adds commands for working with `codeBlock` nodes.\n *\n * @public\n */\nexport function defineCodeBlockCommands(): CodeBlockCommandsExtension {\n return defineCommands({\n setCodeBlock: (attrs?: CodeBlockAttrs) => {\n return setBlockType({ type: 'codeBlock', attrs })\n },\n insertCodeBlock: (attrs?: CodeBlockAttrs) => {\n return insertNode({ type: 'codeBlock', attrs })\n },\n toggleCodeBlock: (attrs?: CodeBlockAttrs) => {\n return toggleNode({ type: 'codeBlock', attrs })\n },\n setCodeBlockAttrs: (attrs: CodeBlockAttrs) => {\n return setNodeAttrs({ type: 'codeBlock', attrs })\n },\n })\n}\n","import type { PlainExtension } from '@prosekit/core'\n\nimport { defineTextBlockEnterRule } from '../enter-rule'\nimport { defineTextBlockInputRule } from '../input-rule'\n\nimport type { CodeBlockAttrs } from './code-block-types'\n\n/**\n * Adds input rules for `codeBlock` nodes.\n *\n * @public\n */\nexport function defineCodeBlockInputRule(): PlainExtension {\n return defineTextBlockInputRule({\n regex: /^```(\\S*)\\s$/,\n type: 'codeBlock',\n attrs: getAttrs,\n })\n}\n\n/**\n * Adds enter rules for `codeBlock` nodes.\n *\n * @public\n */\nexport function defineCodeBlockEnterRule(): PlainExtension {\n return defineTextBlockEnterRule({\n regex: /^```(\\S*)$/,\n type: 'codeBlock',\n attrs: getAttrs,\n })\n}\n\nfunction getAttrs(match: RegExpMatchArray): CodeBlockAttrs {\n return { language: match[1] || '' }\n}\n","import {\n defaultBlockAt,\n defineKeymap,\n type PlainExtension,\n} from '@prosekit/core'\nimport {\n TextSelection,\n type Command,\n} from '@prosekit/pm/state'\n\n/**\n * Defines the keymap for code blocks.\n */\nexport function defineCodeBlockKeymap(): PlainExtension {\n return defineKeymap({\n Enter: existCodeBlock,\n })\n}\n\n/**\n * Exit a code block and insert a default block below if the cursor is at the\n * end of the code block and the code block is ended with two new lines.\n */\nconst existCodeBlock: Command = (state, dispatch) => {\n if (!state.selection.empty) {\n return false\n }\n\n const { $head } = state.selection\n const parent = $head.parent\n if (\n parent.isTextblock\n && parent.type.spec.code\n && $head.parentOffset === parent.content.size\n && parent.textContent.endsWith('\\n\\n')\n ) {\n const grandParent = $head.node(-1)\n const insertIndex = $head.indexAfter(-1)\n const type = defaultBlockAt(grandParent.contentMatchAt(insertIndex))\n\n if (!type || !grandParent.canReplaceWith(insertIndex, insertIndex, type)) {\n return false\n }\n\n if (dispatch) {\n const { tr } = state\n tr.delete($head.pos - 2, $head.pos)\n const pos = tr.selection.$head.after()\n const node = type.createAndFill()\n if (node) {\n tr.replaceWith(pos, pos, node)\n tr.setSelection(TextSelection.near(tr.doc.resolve(pos), 1))\n dispatch(tr.scrollIntoView())\n }\n }\n\n return true\n }\n\n return false\n}\n","import {\n defineNodeSpec,\n type Extension,\n} from '@prosekit/core'\n\nimport type { CodeBlockAttrs } from './code-block-types'\n\n/**\n * @internal\n */\nexport type CodeBlockSpecExtension = Extension<{\n Nodes: {\n codeBlock: CodeBlockAttrs\n }\n}>\n\n/**\n * Defines the `codeBlock` node spec.\n *\n * @public\n */\nexport function defineCodeBlockSpec(): CodeBlockSpecExtension {\n return defineNodeSpec({\n name: 'codeBlock',\n content: 'text*',\n group: 'block',\n code: true,\n defining: true,\n marks: '',\n attrs: { language: { default: '', validate: 'string' } },\n parseDOM: [\n {\n tag: 'pre',\n preserveWhitespace: 'full',\n getAttrs: (node): CodeBlockAttrs => {\n const language = extractLanguageFromElement(node)\n || extractLanguageFromElement(node.querySelector('code'))\n return { language }\n },\n },\n ],\n toDOM(node) {\n const { language } = node.attrs as CodeBlockAttrs\n return [\n 'pre',\n { 'data-language': language || undefined },\n // `class: language-${language}` is used by remark-rehype to highlight the code block\n ['code', { class: language ? `language-${language}` : undefined }, 0],\n ]\n },\n })\n}\n\nfunction extractLanguageFromElement(element: HTMLElement | null | undefined): string {\n if (!element) {\n return ''\n }\n\n const attr = element.getAttribute('data-language')\n if (attr) {\n return attr\n }\n\n const className = element.className\n const match = className.match(/language-(\\w+)/)\n if (match) {\n return match[1]\n }\n\n return ''\n}\n","import {\n union,\n type Union,\n} from '@prosekit/core'\n\nimport {\n defineCodeBlockCommands,\n type CodeBlockCommandsExtension,\n} from './code-block-commands'\nimport {\n defineCodeBlockEnterRule,\n defineCodeBlockInputRule,\n} from './code-block-input-rule'\nimport { defineCodeBlockKeymap } from './code-block-keymap'\nimport {\n defineCodeBlockSpec,\n type CodeBlockSpecExtension,\n} from './code-block-spec'\n\n/**\n * @internal\n */\nexport type CodeBlockExtension = Union<\n [CodeBlockSpecExtension, CodeBlockCommandsExtension]\n>\n\n/**\n * Adds `codeBlock` nodes to the editor. This includes the following extensions:\n *\n * - {@link defineCodeBlockSpec}\n * - {@link defineCodeBlockInputRule}\n * - {@link defineCodeBlockEnterRule}\n * - {@link defineCodeBlockKeymap}\n * - {@link defineCodeBlockCommands}.\n *\n * @public\n */\nexport function defineCodeBlock(): CodeBlockExtension {\n return union(\n defineCodeBlockSpec(),\n defineCodeBlockInputRule(),\n defineCodeBlockEnterRule(),\n defineCodeBlockKeymap(),\n defineCodeBlockCommands(),\n )\n}\n","import {\n definePlugin,\n type Extension,\n} from '@prosekit/core'\nimport {\n createHighlightPlugin,\n type Parser,\n} from 'prosemirror-highlight'\n\n/**\n * @public\n *\n * An alias for the `Parser` type from the `prosemirror-highlight` package.\n */\nexport type HighlightParser = Parser\n\n/**\n * @public\n */\nexport type CodeBlockHighlightOptions = {\n parser: HighlightParser\n}\n\n/**\n * Adds syntax highlighting to code blocks. This function requires a `Parser`\n * instance from the `prosemirror-highlight` package. See the\n * [documentation](https://github.com/ocavue/prosemirror-highlight) for more\n * information.\n *\n * @param options\n *\n * @public\n */\nexport function defineCodeBlockHighlight({\n parser,\n}: CodeBlockHighlightOptions): Extension {\n return definePlugin(\n createHighlightPlugin({ parser }),\n )\n}\n","import type {\n HighlighterOptions,\n HighlighterResult,\n} from './shiki-highlighter-chunk'\n\nlet loaded: ((options: HighlighterOptions) => HighlighterResult) | undefined\n\nasync function load() {\n const { createOrGetHighlighter } = await import('./shiki-highlighter-chunk')\n loaded = createOrGetHighlighter\n}\n\nexport function createOrGetHighlighter(\n options: HighlighterOptions,\n): HighlighterResult {\n if (!loaded) {\n return { promise: load() }\n }\n return loaded(options)\n}\n\nexport type { HighlighterOptions }\n","import type { Parser } from 'prosemirror-highlight'\nimport { createParser } from 'prosemirror-highlight/shiki'\n\nimport type { ShikiBundledLanguage } from './shiki-bundle'\nimport {\n createOrGetHighlighter,\n type HighlighterOptions,\n} from './shiki-highlighter'\n\n/**\n * @internal\n */\nexport function createLazyParser(\n highlighterOptions: HighlighterOptions,\n): Parser {\n let parser: Parser | undefined\n\n return function lazyParser(options) {\n const language = (options.language || '') as ShikiBundledLanguage\n const { highlighter, promise } = createOrGetHighlighter({\n ...highlighterOptions,\n langs: [language],\n })\n\n if (!highlighter) {\n return promise\n }\n\n if (!parser) {\n parser = createParser(highlighter, {\n theme: highlighterOptions.themes[0],\n })\n }\n return parser(options)\n }\n}\n","import type { Extension } from '@prosekit/core'\nimport type { SpecialLanguage } from 'shiki'\n\nimport { defineCodeBlockHighlight } from './code-block-highlight'\nimport type {\n ShikiBundledLanguage,\n ShikiBundledTheme,\n} from './shiki-bundle'\nimport type { ShikiHighlighterOptions } from './shiki-highlighter-chunk'\nimport { createLazyParser } from './shiki-parser'\n\n/**\n * The options to configure the Shiki highlighter.\n *\n * @public\n */\nexport interface CodeBlockShikiOptions extends Omit<ShikiHighlighterOptions, 'themes' | 'langs' | 'engine'> {\n /**\n * A list of Shiki themes to pre-load. The first theme in the list will be\n * used to render the code block.\n *\n * @default ['one-dark-pro']\n */\n themes?: ShikiBundledTheme[]\n\n /**\n * A list of Shiki languages to pre-load.\n *\n * @default ['text']\n */\n langs?: (ShikiBundledLanguage | SpecialLanguage)[]\n\n /**\n * The RegExp engine to use. By default, the JavaScript engine is used.\n */\n engine?: ShikiHighlighterOptions['engine']\n}\n\n/**\n * Adds syntax highlighting to code blocks using the [Shiki](https://github.com/shikijs/shiki) package.\n *\n * It will set two CSS variables on the code block elements:\n *\n * - `--prosemirror-highlight`: sets text color\n * - `--prosemirror-highlight-bg`: sets background color\n *\n * @param options - The options to configure the Shiki highlighter.\n *\n * @public\n */\nexport function defineCodeBlockShiki({\n themes = ['one-dark-pro'],\n langs = ['text'],\n ...rest\n}: CodeBlockShikiOptions = {}): Extension {\n const parser = createLazyParser({ themes, langs, ...rest })\n return defineCodeBlockHighlight({ parser })\n}\n"],"mappings":"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"}
|
|
@@ -51,4 +51,5 @@ declare function defineCodeInputRule(): PlainExtension;
|
|
|
51
51
|
*/
|
|
52
52
|
declare function defineCodeKeymap(): PlainExtension;
|
|
53
53
|
//#endregion
|
|
54
|
-
export { type CodeCommandsExtension, type CodeExtension, type CodeSpecExtension, defineCode, defineCodeCommands, defineCodeInputRule, defineCodeKeymap, defineCodeSpec };
|
|
54
|
+
export { type CodeCommandsExtension, type CodeExtension, type CodeSpecExtension, defineCode, defineCodeCommands, defineCodeInputRule, defineCodeKeymap, defineCodeSpec };
|
|
55
|
+
//# sourceMappingURL=prosekit-extensions-code.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prosekit-extensions-code.d.ts","names":[],"sources":["../src/code/code-commands.ts","../src/code/code-spec.ts","../src/code/code.ts","../src/code/code-input-rule.ts","../src/code/code-keymap.ts"],"sourcesContent":[],"mappings":";;;;;;;AASY,KAAA,qBAAA,GAAwB,SAAA,CAAA;EASpB,QAAA,EAAA;;;;ACThB;;;AAAgC,iBDShB,kBAAA,CAAA,CCTgB,EDSM,qBCTN;;;;;ADAhC;AASgB,KCTJ,iBAAA,GAAoB,SDSM,CAAA;;UCP5B;;AAFV,CAAA,CAAA;;;;AAAyC,iBASzB,cAAA,CAAA,CATyB,EASP,iBATO;;;;ADAzC;AASA;KECY,aAAA,GAAgB,OAAO,mBAAmB;;;ADVtD;AAA6B,iBCeb,UAAA,CAAA,CDfa,ECeC,aDfD;;;;;;ADAjB,iBGCI,mBAAA,CAAA,CHDoB,EGCG,cHDM;;;;;;AAAjC,iBIAI,gBAAA,CAAA,CJAoB,EIAA,cJAS"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineMarkInputRule } from "./input-rule-
|
|
1
|
+
import { defineMarkInputRule } from "./input-rule-B17tpW4m.js";
|
|
2
2
|
import { canUseRegexLookbehind, defineCommands, defineKeymap, defineMarkSpec, toggleMark, union } from "@prosekit/core";
|
|
3
3
|
|
|
4
4
|
//#region src/code/code-commands.ts
|
|
@@ -56,4 +56,5 @@ function defineCode() {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
//#endregion
|
|
59
|
-
export { defineCode, defineCodeCommands, defineCodeInputRule, defineCodeKeymap, defineCodeSpec };
|
|
59
|
+
export { defineCode, defineCodeCommands, defineCodeInputRule, defineCodeKeymap, defineCodeSpec };
|
|
60
|
+
//# sourceMappingURL=prosekit-extensions-code.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prosekit-extensions-code.js","names":[],"sources":["../src/code/code-commands.ts","../src/code/code-input-rule.ts","../src/code/code-keymap.ts","../src/code/code-spec.ts","../src/code/code.ts"],"sourcesContent":["import {\n defineCommands,\n toggleMark,\n type Extension,\n} from '@prosekit/core'\n\n/**\n * @internal\n */\nexport type CodeCommandsExtension = Extension<{\n Commands: {\n toggleCode: []\n }\n}>\n\n/**\n * @internal\n */\nexport function defineCodeCommands(): CodeCommandsExtension {\n return defineCommands({\n toggleCode: () => toggleMark({ type: 'code' }),\n })\n}\n","import {\n canUseRegexLookbehind,\n type PlainExtension,\n} from '@prosekit/core'\n\nimport { defineMarkInputRule } from '../input-rule'\n\n/**\n * @internal\n */\nexport function defineCodeInputRule(): PlainExtension {\n return defineMarkInputRule({\n regex: canUseRegexLookbehind()\n ? /(?<=\\s|^)`([^\\s`]|[^\\s`][^`]*[^\\s`])`$/\n : /`([^\\s`]|[^\\s`][^`]*[^\\s`])`$/,\n type: 'code',\n })\n}\n","import {\n defineKeymap,\n toggleMark,\n type PlainExtension,\n} from '@prosekit/core'\n\n/**\n * @internal\n */\nexport function defineCodeKeymap(): PlainExtension {\n return defineKeymap({\n 'Mod-e': toggleMark({ type: 'code' }),\n })\n}\n","import {\n defineMarkSpec,\n type Extension,\n} from '@prosekit/core'\nimport type { Attrs } from '@prosekit/pm/model'\n\n/**\n * @internal\n */\nexport type CodeSpecExtension = Extension<{\n Marks: {\n code: Attrs\n }\n}>\n\n/**\n * @internal\n */\nexport function defineCodeSpec(): CodeSpecExtension {\n return defineMarkSpec({\n name: 'code',\n parseDOM: [{ tag: 'code' }],\n code: true,\n toDOM() {\n return ['code', 0]\n },\n })\n}\n","import {\n union,\n type Union,\n} from '@prosekit/core'\n\nimport {\n defineCodeCommands,\n type CodeCommandsExtension,\n} from './code-commands'\nimport { defineCodeInputRule } from './code-input-rule'\nimport { defineCodeKeymap } from './code-keymap'\nimport {\n defineCodeSpec,\n type CodeSpecExtension,\n} from './code-spec'\n\n/**\n * @internal\n */\nexport type CodeExtension = Union<[CodeSpecExtension, CodeCommandsExtension]>\n\n/**\n * @public\n */\nexport function defineCode(): CodeExtension {\n return union(\n defineCodeSpec(),\n defineCodeCommands(),\n defineCodeKeymap(),\n defineCodeInputRule(),\n )\n}\n"],"mappings":";;;;;;;AAkBA,SAAgB,qBAA4C;AAC1D,QAAO,eAAe,EACpB,kBAAkB,WAAW,EAAE,MAAM,QAAQ,CAAC,EAC/C,CAAC;;;;;;;;ACXJ,SAAgB,sBAAsC;AACpD,QAAO,oBAAoB;EACzB,OAAO,uBAAuB,GAC1B,2CACA;EACJ,MAAM;EACP,CAAC;;;;;;;;ACPJ,SAAgB,mBAAmC;AACjD,QAAO,aAAa,EAClB,SAAS,WAAW,EAAE,MAAM,QAAQ,CAAC,EACtC,CAAC;;;;;;;;ACMJ,SAAgB,iBAAoC;AAClD,QAAO,eAAe;EACpB,MAAM;EACN,UAAU,CAAC,EAAE,KAAK,QAAQ,CAAC;EAC3B,MAAM;EACN,QAAQ;AACN,UAAO,CAAC,QAAQ,EAAE;;EAErB,CAAC;;;;;;;;ACFJ,SAAgB,aAA4B;AAC1C,QAAO,MACL,gBAAgB,EAChB,oBAAoB,EACpB,kBAAkB,EAClB,qBAAqB,CACtB"}
|
|
@@ -49,4 +49,5 @@ declare class CommitRecorder {
|
|
|
49
49
|
*/
|
|
50
50
|
declare function defineCommitRecorder(commitRecorder: CommitRecorder): PlainExtension;
|
|
51
51
|
//#endregion
|
|
52
|
-
export { type Commit, CommitRecorder, defineCommitRecorder, defineCommitViewer };
|
|
52
|
+
export { type Commit, CommitRecorder, defineCommitRecorder, defineCommitViewer };
|
|
53
|
+
//# sourceMappingURL=prosekit-extensions-commit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prosekit-extensions-commit.d.ts","names":[],"sources":["../src/commit/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAmB2B;UAejB,MAAA,CAAM;;;;EAaC,GAAA,EATV,QASU;EA2MR;;;QAAoC,EAhNnC,QAgNmC;EAAc;AAAA;;;OAsC/C,EAjPH,QAiPG,EAAA;;;AASW;;iBA/Cd,kBAAA,CAwDqC,MAAA,EAxDV,MAwDU,CAAA,EAxDD,cAwDC;cAjDxC,cAAA,CAiDyD;EAAc,QAAA,MAAA;;;;;;;YAxCjE;;;;YAsBA;;;;YASA;;;;;iBASH,oBAAA,iBAAqC,iBAAiB"}
|
|
@@ -7,13 +7,10 @@ import { ChangeSet } from "prosemirror-changeset";
|
|
|
7
7
|
|
|
8
8
|
//#region src/commit/index.ts
|
|
9
9
|
function getChanges(doc, parent, steps) {
|
|
10
|
-
|
|
11
|
-
const currSet = initSet.addSteps(doc, steps.map((step) => step.getMap()), null);
|
|
12
|
-
return currSet.changes;
|
|
10
|
+
return ChangeSet.create(parent).addSteps(doc, steps.map((step) => step.getMap()), null).changes;
|
|
13
11
|
}
|
|
14
12
|
function renderDivWeight(view) {
|
|
15
|
-
|
|
16
|
-
return document.createElement("div");
|
|
13
|
+
return view.dom.ownerDocument.createElement("div");
|
|
17
14
|
}
|
|
18
15
|
function decorateDeletionSlice(slice) {
|
|
19
16
|
let { openStart, openEnd, content } = slice;
|
|
@@ -49,8 +46,7 @@ function decorateDeletionSlice(slice) {
|
|
|
49
46
|
const render = (view) => {
|
|
50
47
|
const document = view.dom.ownerDocument;
|
|
51
48
|
const element = document.createElement(isInline ? "span" : "div");
|
|
52
|
-
|
|
53
|
-
serializer.serializeFragment(content, { document }, element);
|
|
49
|
+
DOMSerializer.fromSchema(schema).serializeFragment(content, { document }, element);
|
|
54
50
|
element.classList.add("prosekit-commit-deletion");
|
|
55
51
|
return element;
|
|
56
52
|
};
|
|
@@ -76,8 +72,7 @@ function decorateChange(prev, change) {
|
|
|
76
72
|
return decorations;
|
|
77
73
|
}
|
|
78
74
|
function decorateCommit(doc, parent, steps) {
|
|
79
|
-
const
|
|
80
|
-
const decorations = changes.flatMap((change) => decorateChange(parent, change));
|
|
75
|
+
const decorations = getChanges(doc, parent, steps).flatMap((change) => decorateChange(parent, change));
|
|
81
76
|
return DecorationSet.create(doc, decorations);
|
|
82
77
|
}
|
|
83
78
|
function defineCommitDecoration(commit) {
|
|
@@ -108,9 +103,11 @@ function defineCommitViewer(commit) {
|
|
|
108
103
|
return union(defineDefaultState({ defaultDoc: commit.doc }), defineCommitDecoration(commit));
|
|
109
104
|
}
|
|
110
105
|
var CommitRecorder = class {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
106
|
+
constructor() {
|
|
107
|
+
this.parent = null;
|
|
108
|
+
this.doc = null;
|
|
109
|
+
this.steps = [];
|
|
110
|
+
}
|
|
114
111
|
/**
|
|
115
112
|
* Return a commit object including all changes since the last commit. `null`
|
|
116
113
|
* will be returned if there is no change.
|
|
@@ -160,4 +157,5 @@ function defineCommitRecorder(commitRecorder) {
|
|
|
160
157
|
}
|
|
161
158
|
|
|
162
159
|
//#endregion
|
|
163
|
-
export { CommitRecorder, defineCommitRecorder, defineCommitViewer };
|
|
160
|
+
export { CommitRecorder, defineCommitRecorder, defineCommitViewer };
|
|
161
|
+
//# sourceMappingURL=prosekit-extensions-commit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prosekit-extensions-commit.js","names":["decorations: Decoration[]","commit: Commit"],"sources":["../src/commit/index.ts"],"sourcesContent":["import {\n defineDefaultState,\n definePlugin,\n jsonFromNode,\n union,\n type NodeJSON,\n type PlainExtension,\n type StepJSON,\n} from '@prosekit/core'\nimport {\n DOMSerializer,\n Fragment,\n Slice,\n type ProseMirrorNode,\n} from '@prosekit/pm/model'\nimport {\n PluginKey,\n ProseMirrorPlugin,\n type Transaction,\n} from '@prosekit/pm/state'\nimport { Step } from '@prosekit/pm/transform'\nimport {\n Decoration,\n DecorationSet,\n type EditorView,\n} from '@prosekit/pm/view'\nimport {\n ChangeSet,\n type Change,\n} from 'prosemirror-changeset'\n\n/**\n * A JSON representation of a commit.\n */\ninterface Commit {\n /**\n * The current doc node in the JSON format\n */\n doc: NodeJSON\n /**\n * The parent node in the JSON format\n */\n parent: NodeJSON\n /**\n * An array of steps in the JSON format that transform the parent node to the\n * current doc node.\n */\n steps: StepJSON[]\n}\n\nfunction getChanges(\n doc: ProseMirrorNode,\n parent: ProseMirrorNode,\n steps: Step[],\n): readonly Change[] {\n const initSet = ChangeSet.create(parent)\n const currSet = initSet.addSteps(\n doc,\n steps.map((step) => step.getMap()),\n null,\n )\n return currSet.changes\n}\n\nfunction renderDivWeight(view: EditorView): HTMLElement {\n const document = view.dom.ownerDocument\n return document.createElement('div')\n}\n\nfunction decorateDeletionSlice(\n slice: Slice,\n): Array<(view: EditorView) => HTMLElement> {\n // Get the fragment of the deleted content\n let { openStart, openEnd, content } = slice\n\n while (openStart > 0 && openEnd > 0 && content.childCount === 1) {\n openStart--\n openEnd--\n content = content.child(0).content\n }\n\n // Nothing to render\n if (content.childCount === 0) {\n return []\n }\n\n // For example, if the slice is\n // {\n // openStart: 1,\n // openEnd: 1,\n // content: <p>Hello</p><p>World</p>\n // }\n // We should render the following decorations:\n // <span>Hello</span>\n // <div></div>\n // <span>World</span>\n if (openStart > 0 && openEnd > 0 && content.childCount === 2) {\n const head = Fragment.from([content.child(0)])\n const tail = Fragment.from([content.child(1)])\n return [\n ...decorateDeletionSlice(new Slice(head, openStart, openStart)),\n renderDivWeight,\n ...decorateDeletionSlice(new Slice(tail, openEnd, openEnd)),\n ]\n }\n\n // For example, if the slice is\n // {\n // openStart: 1,\n // openEnd: 0,\n // content: <p>Hello</p><p>World</p>\n // }\n // We should render the following decorations:\n // <span>Hello</span>\n // <div><p>World</p></div>\n if (openStart > 0 && content.childCount >= 2) {\n const nodes = content.content\n const head = Fragment.from(nodes.slice(0, 1))\n const body = Fragment.from(nodes.slice(1))\n\n return [\n ...decorateDeletionSlice(new Slice(head, openStart, openStart)),\n ...decorateDeletionSlice(new Slice(body, 0, openEnd)),\n ]\n }\n\n // For example, if the slice is\n // {\n // openStart: 0,\n // openEnd: 1,\n // content: <p>Hello</p><p>World</p>\n // }\n // We should render the following decorations:\n // <div><p>Hello</p></div>\n // <span>World</span>\n if (openEnd > 0 && content.childCount >= 2) {\n const nodes = content.content\n const body = Fragment.from(nodes.slice(0, -1))\n const tail = Fragment.from(nodes.slice(-1))\n return [\n ...decorateDeletionSlice(new Slice(body, openStart, 0)),\n ...decorateDeletionSlice(new Slice(tail, openEnd, openEnd)),\n ]\n }\n\n const schema = content.child(0).type.schema\n const isInline = content.child(0).isInline\n\n const render = (view: EditorView): HTMLElement => {\n const document = view.dom.ownerDocument\n\n // Render the fragment to HTML\n const element = document.createElement(isInline ? 'span' : 'div')\n const serializer = DOMSerializer.fromSchema(schema)\n serializer.serializeFragment(content, { document }, element)\n\n // Add the class to the element\n element.classList.add('prosekit-commit-deletion')\n return element\n }\n\n return [render]\n}\n\nfunction decorateDeletion(\n /** The doc node before the deletion */\n doc: ProseMirrorNode,\n /** The start position of the deleted text in the doc node */\n from: number,\n /** The end position of the deleted text in the doc node */\n to: number,\n /** The insert position of the decoration in the doc node after the change */\n pos: number,\n): Decoration[] {\n const slice = doc.slice(from, to)\n\n const renders = decorateDeletionSlice(slice)\n const count = renders.length\n\n return renders.map((render, index) =>\n Decoration.widget(pos, render, {\n side: -20 - count + index,\n // Ensure the text in the decoration is able to be selected.\n ignoreSelection: true,\n })\n )\n}\n\nfunction decorateAddition(\n /** The start position of the inserted text in the doc node */\n from: number,\n /** The end position of the inserted text in the doc node */\n to: number,\n): Decoration {\n return Decoration.inline(from, to, { class: 'prosekit-commit-addition' })\n}\n\nfunction decorateChange(prev: ProseMirrorNode, change: Change): Decoration[] {\n const { fromA, toA, fromB, toB } = change\n const decorations: Decoration[] = []\n\n if (fromA < toA) {\n decorations.push(...decorateDeletion(prev, fromA, toA, fromB))\n }\n if (fromB < toB) {\n decorations.push(decorateAddition(fromB, toB))\n }\n\n return decorations\n}\n\nfunction decorateCommit(\n doc: ProseMirrorNode,\n parent: ProseMirrorNode,\n steps: Step[],\n): DecorationSet {\n const changes = getChanges(doc, parent, steps)\n const decorations = changes.flatMap((change) => decorateChange(parent, change))\n return DecorationSet.create(doc, decorations)\n}\n\nfunction defineCommitDecoration(commit: Commit): PlainExtension {\n const key = new PluginKey<DecorationSet>('prosekit-commit-decoration')\n\n return definePlugin(({ schema }): ProseMirrorPlugin => {\n const parent = schema.nodeFromJSON(commit.parent)\n const steps = commit.steps.map((step) => Step.fromJSON(schema, step))\n\n return new ProseMirrorPlugin({\n key,\n state: {\n init: (_, instance): DecorationSet => {\n return decorateCommit(instance.doc, parent, steps)\n },\n apply: (tr, deco: DecorationSet): DecorationSet => {\n return deco.map(tr.mapping, tr.doc)\n },\n },\n props: {\n decorations: (state): DecorationSet | undefined => {\n return key.getState(state)\n },\n },\n })\n })\n}\n\n/**\n * Define an extension to display the changes from the given commit in the editor.\n */\nfunction defineCommitViewer(commit: Commit): PlainExtension {\n return union(\n defineDefaultState({ defaultDoc: commit.doc }),\n defineCommitDecoration(commit),\n )\n}\n\nclass CommitRecorder {\n private parent: ProseMirrorNode | null = null\n private doc: ProseMirrorNode | null = null\n private steps: Step[] = []\n\n /**\n * Return a commit object including all changes since the last commit. `null`\n * will be returned if there is no change.\n */\n commit(): Commit | null {\n if (\n !this.parent\n || !this.doc\n || this.steps.length === 0\n || this.parent.eq(this.doc)\n ) {\n return null\n }\n\n const commit: Commit = {\n doc: jsonFromNode(this.doc),\n parent: jsonFromNode(this.parent),\n steps: this.steps.map((step) => step.toJSON() as StepJSON),\n }\n this.init(this.doc)\n return commit\n }\n\n /**\n * @internal\n */\n init(doc: ProseMirrorNode): void {\n this.doc = doc\n this.parent = doc\n this.steps = []\n }\n\n /**\n * @internal\n */\n apply(tr: Transaction): void {\n this.steps.push(...tr.steps)\n this.doc = tr.doc\n }\n}\n\n/**\n * Define an extension that can record the changes in the editor.\n */\nfunction defineCommitRecorder(commitRecorder: CommitRecorder): PlainExtension {\n const key = new PluginKey<DecorationSet>('prosekit-commit-recorder')\n\n return definePlugin(\n new ProseMirrorPlugin({\n key,\n state: {\n init: (_, state): void => {\n commitRecorder.init(state.doc)\n },\n apply: (tr): void => {\n commitRecorder.apply(tr)\n },\n },\n }),\n )\n}\n\nexport {\n CommitRecorder,\n defineCommitRecorder,\n defineCommitViewer,\n type Commit,\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prosekit-extensions-doc.d.ts","names":[],"sources":["../src/doc/index.ts"],"sourcesContent":[],"mappings":";;;;;;;AASA;AAAwB,KAAZ,YAAA,GAAe,SAAH,CAAA;OAA6B,EAAA;IAA1B,GAAA,EAA0B,KAA1B;EAAS,CAAA;AAKpC,CAAA,CAAA;;;;iBAAgB,SAAA,CAAA,GAAa"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prosekit-extensions-doc.js","names":[],"sources":["../src/doc/index.ts"],"sourcesContent":["import {\n defineNodeSpec,\n type Extension,\n} from '@prosekit/core'\nimport type { Attrs } from '@prosekit/pm/model'\n\n/**\n * @internal\n */\nexport type DocExtension = Extension<{ Nodes: { doc: Attrs } }>\n\n/**\n * @public\n */\nexport function defineDoc(): DocExtension {\n return defineNodeSpec({\n name: 'doc',\n content: 'block+',\n topNode: true,\n })\n}\n"],"mappings":";;;;;;AAcA,SAAgB,YAA0B;AACxC,QAAO,eAAe;EACpB,MAAM;EACN,SAAS;EACT,SAAS;EACV,CAAC"}
|
|
@@ -34,4 +34,5 @@ type DropCursorExtension = PlainExtension;
|
|
|
34
34
|
*/
|
|
35
35
|
declare function defineDropCursor(options?: DropCursorOptions): DropCursorExtension;
|
|
36
36
|
//#endregion
|
|
37
|
-
export { type DropCursorExtension, type DropCursorOptions, defineDropCursor };
|
|
37
|
+
export { type DropCursorExtension, type DropCursorOptions, defineDropCursor };
|
|
38
|
+
//# sourceMappingURL=prosekit-extensions-drop-cursor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prosekit-extensions-drop-cursor.d.ts","names":[],"sources":["../src/drop-cursor/drop-cursor.ts"],"sourcesContent":[],"mappings":";;;UAMiB,iBAAA;;AAAjB;AAwBA;AAWA;;OACY,CAAA,EAAA,MAAA,GAAA,KAAA;;;;;;;;;;;;;;;KAZA,mBAAA,GAAsB;;;;;;;;;;iBAWlB,gBAAA,WACJ,oBACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prosekit-extensions-drop-cursor.js","names":[],"sources":["../src/drop-cursor/drop-cursor.ts"],"sourcesContent":["import {\n definePlugin,\n type PlainExtension,\n} from '@prosekit/core'\nimport { dropCursor } from 'prosemirror-dropcursor'\n\nexport interface DropCursorOptions {\n /**\n * The color of the cursor. Use `false` to apply no color and rely only on class.\n *\n * @default 'black'\n */\n color?: string | false\n\n /**\n * The precise width of the cursor in pixels.\n *\n * @default 1\n */\n width?: number\n\n /**\n * A CSS class name to add to the cursor element.\n */\n class?: string\n}\n\n/**\n * @internal\n */\nexport type DropCursorExtension = PlainExtension\n\n/**\n * Show up a decoration at the drop position when something is dragged over the editor.\n *\n * See [prosemirror-dropcursor](https://github.com/ProseMirror/prosemirror-dropcursor) for more information.\n *\n * You probably want to use `<DropIndicator />` component instead of this extension.\n *\n * @public\n */\nexport function defineDropCursor(\n options?: DropCursorOptions,\n): DropCursorExtension {\n return definePlugin(() => dropCursor(options))\n}\n"],"mappings":";;;;;;;;;;;;;AAyCA,SAAgB,iBACd,SACqB;AACrB,QAAO,mBAAmB,WAAW,QAAQ,CAAC"}
|
|
@@ -1,111 +1,8 @@
|
|
|
1
1
|
import { PlainExtension } from "@prosekit/core";
|
|
2
|
-
import {
|
|
3
|
-
import { EditorView } from "@prosekit/pm/view";
|
|
4
|
-
import { Slice } from "@prosekit/pm/model";
|
|
2
|
+
import { DragEventHandler, DragEventHandlerOptions, DropIndicatorPluginOptions, Line, Point, ShowHandler, ShowHandlerOptions, ViewDragging } from "prosemirror-drop-indicator";
|
|
5
3
|
|
|
6
|
-
//#region src/drop-indicator/types.d.ts
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* A function that will be called when the `dragover` event is fired. You can
|
|
10
|
-
* return `false` to disable the current drop point and thus hide the drop
|
|
11
|
-
* indicator.
|
|
12
|
-
*
|
|
13
|
-
* @public
|
|
14
|
-
*/
|
|
15
|
-
type DragEventHandler = (options: DragEventHandlerOptions) => boolean;
|
|
16
|
-
/**
|
|
17
|
-
* Options for {@link DragEventHandler}.
|
|
18
|
-
*
|
|
19
|
-
* @public
|
|
20
|
-
*/
|
|
21
|
-
interface DragEventHandlerOptions {
|
|
22
|
-
/**
|
|
23
|
-
* The editor's view.
|
|
24
|
-
*/
|
|
25
|
-
view: EditorView;
|
|
26
|
-
/**
|
|
27
|
-
* The drop position in current document.
|
|
28
|
-
*/
|
|
29
|
-
pos: number;
|
|
30
|
-
/**
|
|
31
|
-
* The `dragover` event.
|
|
32
|
-
*/
|
|
33
|
-
event: DragEvent;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* A function that will be called when the drop indicator should be shown.
|
|
37
|
-
*
|
|
38
|
-
* @public
|
|
39
|
-
*/
|
|
40
|
-
type ShowHandler = (options: ShowHandlerOptions) => void;
|
|
41
|
-
/**
|
|
42
|
-
* Options for {@link ShowHandler}.
|
|
43
|
-
*
|
|
44
|
-
* @public
|
|
45
|
-
*/
|
|
46
|
-
interface ShowHandlerOptions {
|
|
47
|
-
/**
|
|
48
|
-
* The editor's view.
|
|
49
|
-
*/
|
|
50
|
-
view: EditorView;
|
|
51
|
-
/**
|
|
52
|
-
* The ProseMirror position that the drop indicator should be shown at.
|
|
53
|
-
*/
|
|
54
|
-
pos: number;
|
|
55
|
-
/**
|
|
56
|
-
* The line that the drop indicator should be shown at.
|
|
57
|
-
*/
|
|
58
|
-
line: Line;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* @internal
|
|
62
|
-
*/
|
|
63
|
-
interface Point {
|
|
64
|
-
readonly x: number;
|
|
65
|
-
readonly y: number;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* @internal
|
|
69
|
-
*/
|
|
70
|
-
interface Line {
|
|
71
|
-
readonly p1: Point;
|
|
72
|
-
readonly p2: Point;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* An interface matching the internal ProseMirror implementation.
|
|
76
|
-
*
|
|
77
|
-
* See https://github.com/ProseMirror/prosemirror-view/blob/1.38.1/src/input.ts#L657
|
|
78
|
-
*
|
|
79
|
-
* @internal
|
|
80
|
-
*/
|
|
81
|
-
interface ViewDragging {
|
|
82
|
-
readonly slice: Slice;
|
|
83
|
-
readonly move: boolean;
|
|
84
|
-
readonly node?: NodeSelection;
|
|
85
|
-
}
|
|
86
|
-
//#endregion
|
|
87
|
-
//#region src/drop-indicator/drop-indicator-facet.d.ts
|
|
88
|
-
/**
|
|
89
|
-
* @internal
|
|
90
|
-
*/
|
|
91
|
-
interface DropIndicatorPayload {
|
|
92
|
-
/**
|
|
93
|
-
* A callback that is called when the drop indicator should be shown.
|
|
94
|
-
*/
|
|
95
|
-
onShow?: ShowHandler;
|
|
96
|
-
/**
|
|
97
|
-
* A callback that is called when the drop indicator should be hidden.
|
|
98
|
-
*/
|
|
99
|
-
onHide?: VoidFunction;
|
|
100
|
-
/**
|
|
101
|
-
* A callback that is called when the `dragover` event is fired. You can
|
|
102
|
-
* return `false` to disable the current drop point and thus hide the drop
|
|
103
|
-
* indicator.
|
|
104
|
-
*/
|
|
105
|
-
onDrag?: DragEventHandler;
|
|
106
|
-
}
|
|
107
|
-
//#endregion
|
|
108
4
|
//#region src/drop-indicator/drop-indicator.d.ts
|
|
5
|
+
|
|
109
6
|
/**
|
|
110
7
|
* @internal
|
|
111
8
|
*/
|
|
@@ -129,6 +26,7 @@ declare function defineDropIndicator(options?: DropIndicatorOptions): DropIndica
|
|
|
129
26
|
*
|
|
130
27
|
* @public
|
|
131
28
|
*/
|
|
132
|
-
interface DropIndicatorOptions extends
|
|
29
|
+
interface DropIndicatorOptions extends DropIndicatorPluginOptions {}
|
|
133
30
|
//#endregion
|
|
134
|
-
export { type DragEventHandler, type DragEventHandlerOptions, type DropIndicatorExtension, type DropIndicatorOptions, type Line, type Point, type ShowHandler, type ShowHandlerOptions, type ViewDragging, defineDropIndicator };
|
|
31
|
+
export { type DragEventHandler, type DragEventHandlerOptions, type DropIndicatorExtension, type DropIndicatorOptions, type Line, type Point, type ShowHandler, type ShowHandlerOptions, type ViewDragging, defineDropIndicator };
|
|
32
|
+
//# sourceMappingURL=prosekit-extensions-drop-indicator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prosekit-extensions-drop-indicator.d.ts","names":[],"sources":["../src/drop-indicator/drop-indicator.ts"],"sourcesContent":[],"mappings":";;;;;;;AAQA;AAegB,KAfJ,sBAAA,GAAyB,cAeF;;;;;AAWnC;;;;;;;;;iBAXgB,mBAAA,WACJ,uBACT;;;;;;UASc,oBAAA,SAA6B"}
|
|
@@ -108,4 +108,5 @@ declare function defineTextBlockEnterRule({
|
|
|
108
108
|
stop
|
|
109
109
|
}: TextBlockEnterRuleOptions): PlainExtension;
|
|
110
110
|
//#endregion
|
|
111
|
-
export { EnterRuleHandler, EnterRuleHandlerOptions, EnterRuleOptions, TextBlockEnterRuleOptions, defineEnterRule, defineTextBlockEnterRule };
|
|
111
|
+
export { EnterRuleHandler, EnterRuleHandlerOptions, EnterRuleOptions, TextBlockEnterRuleOptions, defineEnterRule, defineTextBlockEnterRule };
|
|
112
|
+
//# sourceMappingURL=prosekit-extensions-enter-rule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prosekit-extensions-enter-rule.d.ts","names":[],"sources":["../src/enter-rule/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA8BA;;;AAmBS,UAnBQ,uBAAA,CAmBR;EAAe;AAMxB;;OAAyC,EArBhC,WAqBgC;;;AAOzC;EAA4B,IAAA,EAAA,MAAA;;;;EAwBX,EAAA,EAAA,MAAA;EAAyB;;;OAehC,EApDD,eAoDC;;;;AAmBV;AAA+B,KAjEnB,gBAAA,GAiEmB,CAAA,OAAA,EAjEU,uBAiEV,EAAA,GAjEsC,WAiEtC,GAAA,IAAA;;;;;;AAIK,KA9DxB,gBAAA,GA8DwB;EAcpB;;;OAEd,EA1EO,MA0EP;;;;SAG6B,EAxEpB,gBAwEoB;EAAc;;;;;;;;;;;;UAzD5B,yBAAA;;;;SAIR;;;;iBAKQ;;;;;UAMP,wBAAwB,qBAAqB;;;;;;;;;;;;;;;;;iBAmBvC,eAAA;;;;GAIb,mBAAmB;;;;;;;;;;iBAcN,wBAAA;;;;;GAKb,4BAA4B"}
|