@prosekit/extensions 0.16.0-beta.0 → 0.16.0
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/{prosekit-extensions-autocomplete.d.ts → autocomplete.d.ts} +1 -6
- package/dist/autocomplete.d.ts.map +1 -0
- package/dist/{prosekit-extensions-autocomplete.js → autocomplete.js} +1 -9
- package/dist/autocomplete.js.map +1 -0
- package/dist/{prosekit-extensions-background-color.d.ts → background-color.d.ts} +1 -8
- package/dist/background-color.d.ts.map +1 -0
- package/dist/{prosekit-extensions-background-color.js → background-color.js} +1 -7
- package/dist/background-color.js.map +1 -0
- package/dist/{prosekit-extensions-blockquote.d.ts → blockquote.d.ts} +1 -12
- package/dist/blockquote.d.ts.map +1 -0
- package/dist/{prosekit-extensions-blockquote.js → blockquote.js} +2 -12
- package/dist/blockquote.js.map +1 -0
- package/dist/{prosekit-extensions-bold.d.ts → bold.d.ts} +1 -12
- package/dist/bold.d.ts.map +1 -0
- package/dist/{prosekit-extensions-bold.js → bold.js} +2 -12
- package/dist/bold.js.map +1 -0
- package/dist/{prosekit-extensions-code-block.d.ts → code-block.d.ts} +1 -20
- package/dist/code-block.d.ts.map +1 -0
- package/dist/{prosekit-extensions-code-block.js → code-block.js} +3 -21
- package/dist/code-block.js.map +1 -0
- package/dist/{prosekit-extensions-code.d.ts → code.d.ts} +1 -12
- package/dist/code.d.ts.map +1 -0
- package/dist/{prosekit-extensions-code.js → code.js} +2 -12
- package/dist/code.js.map +1 -0
- package/dist/{prosekit-extensions-commit.d.ts → commit.d.ts} +1 -4
- package/dist/commit.d.ts.map +1 -0
- package/dist/{prosekit-extensions-commit.js → commit.js} +1 -3
- package/dist/commit.js.map +1 -0
- package/dist/{prosekit-extensions-doc.d.ts → doc.d.ts} +1 -4
- package/dist/doc.d.ts.map +1 -0
- package/dist/{prosekit-extensions-doc.js → doc.js} +1 -3
- package/dist/doc.js.map +1 -0
- package/dist/{prosekit-extensions-drop-cursor.d.ts → drop-cursor.d.ts} +1 -4
- package/dist/drop-cursor.d.ts.map +1 -0
- package/dist/{prosekit-extensions-drop-cursor.js → drop-cursor.js} +1 -3
- package/dist/drop-cursor.js.map +1 -0
- package/dist/{prosekit-extensions-drop-indicator.d.ts → drop-indicator.d.ts} +1 -4
- package/dist/drop-indicator.d.ts.map +1 -0
- package/dist/drop-indicator.js +2 -57
- package/dist/drop-indicator2.js +53 -0
- package/dist/drop-indicator2.js.map +1 -0
- package/dist/{prosekit-extensions-enter-rule.d.ts → enter-rule.d.ts} +1 -4
- package/dist/enter-rule.d.ts.map +1 -0
- package/dist/{prosekit-extensions-enter-rule.js → enter-rule.js} +1 -3
- package/dist/enter-rule.js.map +1 -0
- package/dist/file.js +2 -128
- package/dist/file2.js +120 -0
- package/dist/file2.js.map +1 -0
- package/dist/{prosekit-extensions-gap-cursor.d.ts → gap-cursor.d.ts} +1 -4
- package/dist/gap-cursor.d.ts.map +1 -0
- package/dist/{prosekit-extensions-gap-cursor.js → gap-cursor.js} +1 -3
- package/dist/gap-cursor.js.map +1 -0
- package/dist/{prosekit-extensions-hard-break.d.ts → hard-break.d.ts} +1 -10
- package/dist/hard-break.d.ts.map +1 -0
- package/dist/{prosekit-extensions-hard-break.js → hard-break.js} +1 -9
- package/dist/hard-break.js.map +1 -0
- package/dist/{prosekit-extensions-heading.d.ts → heading.d.ts} +1 -14
- package/dist/heading.d.ts.map +1 -0
- package/dist/{prosekit-extensions-heading.js → heading.js} +2 -12
- package/dist/heading.js.map +1 -0
- package/dist/{prosekit-extensions-horizontal-rule.d.ts → horizontal-rule.d.ts} +1 -10
- package/dist/horizontal-rule.d.ts.map +1 -0
- package/dist/{prosekit-extensions-horizontal-rule.js → horizontal-rule.js} +2 -10
- package/dist/horizontal-rule.js.map +1 -0
- package/dist/{prosekit-extensions-image.d.ts → image.d.ts} +1 -14
- package/dist/image.d.ts.map +1 -0
- package/dist/{prosekit-extensions-image.js → image.js} +2 -14
- package/dist/image.js.map +1 -0
- package/dist/index.d.ts +0 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/{prosekit-extensions-input-rule.d.ts → input-rule.d.ts} +1 -4
- package/dist/input-rule.d.ts.map +1 -0
- package/dist/{prosekit-extensions-input-rule.js → input-rule.js} +1 -3
- package/dist/input-rule.js.map +1 -0
- package/dist/{prosekit-extensions-italic.d.ts → italic.d.ts} +1 -12
- package/dist/italic.d.ts.map +1 -0
- package/dist/{prosekit-extensions-italic.js → italic.js} +2 -12
- package/dist/italic.js.map +1 -0
- package/dist/{prosekit-extensions-link.d.ts → link.d.ts} +1 -8
- package/dist/link.d.ts.map +1 -0
- package/dist/{prosekit-extensions-link.js → link.js} +5 -11
- package/dist/link.js.map +1 -0
- package/dist/{prosekit-extensions-list.d.ts → list.d.ts} +1 -18
- package/dist/list.d.ts.map +1 -0
- package/dist/{prosekit-extensions-list.js → list.js} +3 -19
- package/dist/list.js.map +1 -0
- package/dist/{prosekit-extensions-loro.d.ts → loro.d.ts} +1 -14
- package/dist/loro.d.ts.map +1 -0
- package/dist/{prosekit-extensions-loro.js → loro.js} +1 -13
- package/dist/loro.js.map +1 -0
- package/dist/{prosekit-extensions-mark-rule.d.ts → mark-rule.d.ts} +1 -6
- package/dist/mark-rule.d.ts.map +1 -0
- package/dist/mark-rule.js +2 -157
- package/dist/mark-rule2.js +151 -0
- package/dist/mark-rule2.js.map +1 -0
- package/dist/{prosekit-extensions-math.d.ts → math.d.ts} +1 -10
- package/dist/math.d.ts.map +1 -0
- package/dist/{prosekit-extensions-math.js → math.js} +3 -11
- package/dist/math.js.map +1 -0
- package/dist/{prosekit-extensions-mention.d.ts → mention.d.ts} +1 -4
- package/dist/mention.d.ts.map +1 -0
- package/dist/{prosekit-extensions-mention.js → mention.js} +1 -3
- package/dist/mention.js.map +1 -0
- package/dist/{prosekit-extensions-mod-click-prevention.d.ts → mod-click-prevention.d.ts} +1 -4
- package/dist/mod-click-prevention.d.ts.map +1 -0
- package/dist/{prosekit-extensions-mod-click-prevention.js → mod-click-prevention.js} +1 -3
- package/dist/mod-click-prevention.js.map +1 -0
- package/dist/{prosekit-extensions-page.d.ts → page.d.ts} +1 -12
- package/dist/page.d.ts.map +1 -0
- package/dist/{prosekit-extensions-page.js → page.js} +3 -15
- package/dist/page.js.map +1 -0
- package/dist/{prosekit-extensions-paragraph.d.ts → paragraph.d.ts} +1 -10
- package/dist/paragraph.d.ts.map +1 -0
- package/dist/{prosekit-extensions-paragraph.js → paragraph.js} +1 -9
- package/dist/paragraph.js.map +1 -0
- package/dist/{prosekit-extensions-paste-rule.d.ts → paste-rule.d.ts} +1 -6
- package/dist/paste-rule.d.ts.map +1 -0
- package/dist/paste-rule.js +2 -158
- package/dist/paste-rule2.js +150 -0
- package/dist/paste-rule2.js.map +1 -0
- package/dist/{prosekit-extensions-placeholder.d.ts → placeholder.d.ts} +1 -4
- package/dist/placeholder.d.ts.map +1 -0
- package/dist/{prosekit-extensions-placeholder.js → placeholder.js} +2 -4
- package/dist/placeholder.js.map +1 -0
- package/dist/{prosekit-extensions-readonly.d.ts → readonly.d.ts} +1 -4
- package/dist/readonly.d.ts.map +1 -0
- package/dist/{prosekit-extensions-readonly.js → readonly.js} +6 -3
- package/dist/readonly.js.map +1 -0
- package/dist/{prosekit-extensions-search.d.ts → search.d.ts} +1 -4
- package/dist/search.d.ts.map +1 -0
- package/dist/{prosekit-extensions-search.js → search.js} +1 -3
- package/dist/search.js.map +1 -0
- package/dist/shiki-highlighter-chunk.js +0 -2
- package/dist/shiki-highlighter-chunk.js.map +1 -1
- package/dist/{prosekit-extensions-strike.d.ts → strike.d.ts} +1 -4
- package/dist/strike.d.ts.map +1 -0
- package/dist/{prosekit-extensions-strike.js → strike.js} +2 -4
- package/dist/strike.js.map +1 -0
- package/dist/{prosekit-extensions-table.d.ts → table.d.ts} +1 -26
- package/dist/table.d.ts.map +1 -0
- package/dist/table.js +2 -276
- package/dist/table2.js +252 -0
- package/dist/table2.js.map +1 -0
- package/dist/{prosekit-extensions-text-align.d.ts → text-align.d.ts} +1 -4
- package/dist/text-align.d.ts.map +1 -0
- package/dist/{prosekit-extensions-text-align.js → text-align.js} +1 -3
- package/dist/text-align.js.map +1 -0
- package/dist/{prosekit-extensions-text-color.d.ts → text-color.d.ts} +1 -8
- package/dist/text-color.d.ts.map +1 -0
- package/dist/{prosekit-extensions-text-color.js → text-color.js} +1 -7
- package/dist/text-color.js.map +1 -0
- package/dist/{prosekit-extensions-text.d.ts → text.d.ts} +1 -4
- package/dist/text.d.ts.map +1 -0
- package/dist/{prosekit-extensions-text.js → text.js} +1 -3
- package/dist/text.js.map +1 -0
- package/dist/{prosekit-extensions-underline.d.ts → underline.d.ts} +1 -4
- package/dist/underline.d.ts.map +1 -0
- package/dist/{prosekit-extensions-underline.js → underline.js} +1 -3
- package/dist/underline.js.map +1 -0
- package/dist/{prosekit-extensions-virtual-selection.d.ts → virtual-selection.d.ts} +1 -4
- package/dist/virtual-selection.d.ts.map +1 -0
- package/dist/{prosekit-extensions-virtual-selection.js → virtual-selection.js} +1 -3
- package/dist/virtual-selection.js.map +1 -0
- package/dist/{prosekit-extensions-yjs.d.ts → yjs.d.ts} +1 -16
- package/dist/yjs.d.ts.map +1 -0
- package/dist/{prosekit-extensions-yjs.js → yjs.js} +1 -13
- package/dist/yjs.js.map +1 -0
- package/package.json +136 -194
- package/src/page/page-element.ts +2 -2
- package/src/readonly/index.ts +6 -0
- package/dist/drop-indicator.js.map +0 -1
- package/dist/file.js.map +0 -1
- package/dist/mark-rule.js.map +0 -1
- package/dist/paste-rule.js.map +0 -1
- package/dist/prosekit-extensions-autocomplete.d.ts.map +0 -1
- package/dist/prosekit-extensions-autocomplete.js.map +0 -1
- package/dist/prosekit-extensions-background-color.d.ts.map +0 -1
- package/dist/prosekit-extensions-background-color.js.map +0 -1
- package/dist/prosekit-extensions-blockquote.d.ts.map +0 -1
- package/dist/prosekit-extensions-blockquote.js.map +0 -1
- package/dist/prosekit-extensions-bold.d.ts.map +0 -1
- package/dist/prosekit-extensions-bold.js.map +0 -1
- package/dist/prosekit-extensions-code-block.d.ts.map +0 -1
- package/dist/prosekit-extensions-code-block.js.map +0 -1
- package/dist/prosekit-extensions-code.d.ts.map +0 -1
- package/dist/prosekit-extensions-code.js.map +0 -1
- package/dist/prosekit-extensions-commit.d.ts.map +0 -1
- package/dist/prosekit-extensions-commit.js.map +0 -1
- package/dist/prosekit-extensions-doc.d.ts.map +0 -1
- package/dist/prosekit-extensions-doc.js.map +0 -1
- package/dist/prosekit-extensions-drop-cursor.d.ts.map +0 -1
- package/dist/prosekit-extensions-drop-cursor.js.map +0 -1
- package/dist/prosekit-extensions-drop-indicator.d.ts.map +0 -1
- package/dist/prosekit-extensions-drop-indicator.js +0 -2
- package/dist/prosekit-extensions-enter-rule.d.ts.map +0 -1
- package/dist/prosekit-extensions-enter-rule.js.map +0 -1
- package/dist/prosekit-extensions-file.js +0 -2
- package/dist/prosekit-extensions-gap-cursor.d.ts.map +0 -1
- package/dist/prosekit-extensions-gap-cursor.js.map +0 -1
- package/dist/prosekit-extensions-hard-break.d.ts.map +0 -1
- package/dist/prosekit-extensions-hard-break.js.map +0 -1
- package/dist/prosekit-extensions-heading.d.ts.map +0 -1
- package/dist/prosekit-extensions-heading.js.map +0 -1
- package/dist/prosekit-extensions-horizontal-rule.d.ts.map +0 -1
- package/dist/prosekit-extensions-horizontal-rule.js.map +0 -1
- package/dist/prosekit-extensions-image.d.ts.map +0 -1
- package/dist/prosekit-extensions-image.js.map +0 -1
- package/dist/prosekit-extensions-input-rule.d.ts.map +0 -1
- package/dist/prosekit-extensions-input-rule.js.map +0 -1
- package/dist/prosekit-extensions-italic.d.ts.map +0 -1
- package/dist/prosekit-extensions-italic.js.map +0 -1
- package/dist/prosekit-extensions-link.d.ts.map +0 -1
- package/dist/prosekit-extensions-link.js.map +0 -1
- package/dist/prosekit-extensions-list.d.ts.map +0 -1
- package/dist/prosekit-extensions-list.js.map +0 -1
- package/dist/prosekit-extensions-loro.d.ts.map +0 -1
- package/dist/prosekit-extensions-loro.js.map +0 -1
- package/dist/prosekit-extensions-mark-rule.d.ts.map +0 -1
- package/dist/prosekit-extensions-mark-rule.js +0 -2
- package/dist/prosekit-extensions-math.d.ts.map +0 -1
- package/dist/prosekit-extensions-math.js.map +0 -1
- package/dist/prosekit-extensions-mention.d.ts.map +0 -1
- package/dist/prosekit-extensions-mention.js.map +0 -1
- package/dist/prosekit-extensions-mod-click-prevention.d.ts.map +0 -1
- package/dist/prosekit-extensions-mod-click-prevention.js.map +0 -1
- package/dist/prosekit-extensions-page.d.ts.map +0 -1
- package/dist/prosekit-extensions-page.js.map +0 -1
- package/dist/prosekit-extensions-paragraph.d.ts.map +0 -1
- package/dist/prosekit-extensions-paragraph.js.map +0 -1
- package/dist/prosekit-extensions-paste-rule.d.ts.map +0 -1
- package/dist/prosekit-extensions-paste-rule.js +0 -2
- package/dist/prosekit-extensions-placeholder.d.ts.map +0 -1
- package/dist/prosekit-extensions-placeholder.js.map +0 -1
- package/dist/prosekit-extensions-readonly.d.ts.map +0 -1
- package/dist/prosekit-extensions-readonly.js.map +0 -1
- package/dist/prosekit-extensions-search.d.ts.map +0 -1
- package/dist/prosekit-extensions-search.js.map +0 -1
- package/dist/prosekit-extensions-strike.d.ts.map +0 -1
- package/dist/prosekit-extensions-strike.js.map +0 -1
- package/dist/prosekit-extensions-table.d.ts.map +0 -1
- package/dist/prosekit-extensions-table.js +0 -2
- package/dist/prosekit-extensions-text-align.d.ts.map +0 -1
- package/dist/prosekit-extensions-text-align.js.map +0 -1
- package/dist/prosekit-extensions-text-color.d.ts.map +0 -1
- package/dist/prosekit-extensions-text-color.js.map +0 -1
- package/dist/prosekit-extensions-text.d.ts.map +0 -1
- package/dist/prosekit-extensions-text.js.map +0 -1
- package/dist/prosekit-extensions-underline.d.ts.map +0 -1
- package/dist/prosekit-extensions-underline.js.map +0 -1
- package/dist/prosekit-extensions-virtual-selection.d.ts.map +0 -1
- package/dist/prosekit-extensions-virtual-selection.js.map +0 -1
- package/dist/prosekit-extensions-yjs.d.ts.map +0 -1
- package/dist/prosekit-extensions-yjs.js.map +0 -1
- package/dist/table.js.map +0 -1
- /package/dist/{prosekit-extensions-file.d.ts → file.d.ts} +0 -0
- /package/dist/{prosekit-extensions.js → index.js} +0 -0
- /package/dist/{prosekit-extensions.d.ts → index2.d.ts} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-extensions-list.d.ts","names":[],"sources":["../src/list/list-commands.ts","../src/list/list-input-rules.ts","../src/list/list-keymap.ts","../src/list/list-plugins.ts","../src/list/list-serializer.ts","../src/list/list-types.ts","../src/list/list-spec.ts","../src/list/list.ts"],"mappings":";;;;;;AAyBA;KAAY,qBAAA,GAAwB,SAAA;EAClC,QAAA;IACE,UAAA,GAAa,OAAA,GAAU,mBAAA;IACvB,UAAA,GAAa,OAAA,GAAU,mBAAA;IACvB,QAAA,GAAW,SAAA;IACX,SAAA;IACA,eAAA,GAAkB,OAAA,GAAU,wBAAA;IAC5B,UAAA,GAAa,OAAA,GAAU,mBAAA;IACvB,UAAA,GAAa,KAAA,GAAQ,cAAA;IACrB,UAAA,GAAa,KAAA,GAAQ,cAAA;IACrB,UAAA,GAAa,KAAA,GAAQ,cAAA;EAAA;AAAA;;;;;;iBAST,kBAAA,CAAA,GAAsB,qBAAA;;;;;;iBCpCtB,oBAAA,CAAA,GAAwB,SAAA;;;;;;ADiBxC;;iBEcgB,gBAAA,CAAA,GAAoB,cAAA;;;;;;iBCVpB,iBAAA,CAAA,GAAqB,cAAA;;;;;;iBCtBrB,oBAAA,CAAA,GAAwB,cAAA;;;;;;;AJkBxC;UKpBiB,SAAA;;;;EAIf,IAAA;ELuByB;;;EKnBzB,KAAA;ELYkC;;;EKRlC,OAAA;ELSA;;;EKLA,SAAA;AAAA;;;;;ALIF;KMhBY,iBAAA,GAAoB,SAAA;EAC9B,KAAA;IACE,IAAA,EAAM,SAAA;EAAA;AAAA;;;;iBA4BM,cAAA,CAAA,GAAkB,iBAAA;;;;ANdlC;;KOZY,aAAA,GAAgB,KAAA,EAAO,iBAAA,EAAmB,qBAAA;;;;iBAKtC,UAAA,CAAA,GAAc,aAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-extensions-list.js","names":[],"sources":["../src/list/list-commands.ts","../src/list/list-input-rules.ts","../src/list/list-keymap.ts","../src/list/list-plugins.ts","../src/list/list-serializer.ts","../src/list/list-spec.ts","../src/list/list-drop-indicator.ts","../src/list/list.ts"],"sourcesContent":["import { defineCommands, insertNode, type Extension } from '@prosekit/core'\nimport type { Command } from '@prosekit/pm/state'\nimport {\n createDedentListCommand as dedentList,\n createIndentListCommand as indentList,\n createMoveListCommand as moveList,\n createSplitListCommand as splitList,\n createToggleCollapsedCommand as toggleCollapsed,\n createToggleListCommand as toggleList,\n createUnwrapListCommand as unwrapList,\n createWrapInListCommand as wrapInList,\n type DedentListOptions,\n type IndentListOptions,\n type ListAttributes,\n type ToggleCollapsedOptions,\n type UnwrapListOptions,\n} from 'prosemirror-flat-list'\n\nfunction insertList(attrs?: ListAttributes): Command {\n return insertNode({ type: 'list', attrs })\n}\n\n/**\n * @internal\n */\nexport type ListCommandsExtension = Extension<{\n Commands: {\n dedentList: [options?: DedentListOptions]\n indentList: [options?: IndentListOptions]\n moveList: [direction: 'up' | 'down']\n splitList: []\n toggleCollapsed: [options?: ToggleCollapsedOptions]\n unwrapList: [options?: UnwrapListOptions]\n toggleList: [attrs?: ListAttributes]\n wrapInList: [attrs?: ListAttributes]\n insertList: [attrs?: ListAttributes]\n }\n}>\n\n/**\n * Defines list commands.\n *\n * @internal\n */\nexport function defineListCommands(): ListCommandsExtension {\n return defineCommands({\n dedentList,\n indentList,\n moveList,\n splitList,\n toggleCollapsed,\n unwrapList,\n toggleList,\n wrapInList,\n insertList,\n })\n}\n","import { union, type Extension } from '@prosekit/core'\nimport { listInputRules } from 'prosemirror-flat-list'\n\nimport { defineInputRule } from '../input-rule/index.ts'\n\n/**\n * @internal\n */\nexport function defineListInputRules(): Extension {\n return union(listInputRules.map(defineInputRule))\n}\n","import { defineKeymap, type PlainExtension } from '@prosekit/core'\nimport { chainCommands, deleteSelection } from '@prosekit/pm/commands'\nimport {\n createDedentListCommand,\n createIndentListCommand,\n deleteCommand,\n enterCommand,\n joinCollapsedListBackward,\n joinListUp,\n protectCollapsed,\n} from 'prosemirror-flat-list'\n\n// This is different from the one exported by prosemirror-flat-list, because\n// some commands are moved to `defineBaseKeymap` in `prosekit/core`.\nconst backspaceCommand = chainCommands(\n protectCollapsed,\n deleteSelection,\n joinListUp,\n joinCollapsedListBackward,\n)\n\nconst dedentListCommand = createDedentListCommand()\nconst indentListCommand = createIndentListCommand()\n\nconst listKeymap = {\n 'Enter': enterCommand,\n 'Backspace': backspaceCommand,\n 'Delete': deleteCommand,\n 'Mod-]': indentListCommand,\n 'Mod-[': dedentListCommand,\n 'Tab': indentListCommand,\n 'Shift-Tab': dedentListCommand,\n}\n\n/**\n * Returns a extension that adds key bindings for list.\n *\n * @internal\n */\nexport function defineListKeymap(): PlainExtension {\n return defineKeymap(listKeymap)\n}\n","import { definePlugin, type PlainExtension } from '@prosekit/core'\nimport { Plugin } from '@prosekit/pm/state'\nimport {\n createListEventPlugin,\n createListRenderingPlugin,\n createSafariInputMethodWorkaroundPlugin,\n unwrapListSlice,\n} from 'prosemirror-flat-list'\n\nfunction createListClipboardPlugin(): Plugin {\n return new Plugin({\n props: {\n transformCopied: unwrapListSlice,\n },\n })\n}\n\nfunction createListPlugins(): Plugin[] {\n return [\n createListEventPlugin(),\n createListRenderingPlugin(),\n createListClipboardPlugin(),\n createSafariInputMethodWorkaroundPlugin(),\n ]\n}\n\n/**\n * @internal\n */\nexport function defineListPlugins(): PlainExtension {\n return definePlugin(createListPlugins)\n}\n","import { isElementLike } from '@ocavue/utils'\nimport { defineClipboardSerializer, type PlainExtension } from '@prosekit/core'\nimport { findCheckboxInListItem, joinListElements, listToDOM } from 'prosemirror-flat-list'\n\n/**\n * @internal\n */\nexport function defineListSerializer(): PlainExtension {\n return defineClipboardSerializer({\n serializeFragmentWrapper: (fn) => {\n return (...args) => {\n const dom = fn(...args)\n return normalizeElementTree(joinListElements(dom))\n }\n },\n serializeNodeWrapper: (fn) => {\n return (...args) => {\n const dom = fn(...args)\n return isElementLike(dom)\n ? normalizeElementTree(joinListElements(dom))\n : dom\n }\n },\n nodesFromSchemaWrapper: (fn) => {\n return (...args) => {\n const nodes = fn(...args)\n return {\n ...nodes,\n list: (node) => listToDOM({ node, nativeList: true }),\n }\n }\n },\n })\n}\n\nfunction normalizeElementTree<T extends Element | DocumentFragment>(\n node: T,\n): T {\n if (isElementLike(node)) {\n normalizeTaskList(node)\n }\n\n for (const child of node.children) {\n normalizeElementTree(child)\n }\n\n return node\n}\n\n/**\n * Modifies the DOM tree for task lists to ensure that the output HTML can be\n * parsed by rehype-remark.\n */\nfunction normalizeTaskList(node: Element): void {\n if (\n !node.classList.contains('prosemirror-flat-list')\n || node.getAttribute('data-list-kind') !== 'task'\n || node.children.length !== 2\n ) {\n return\n }\n\n const marker = node.children.item(0)\n if (!marker || !marker.classList.contains('list-marker')) {\n return\n }\n\n const checkbox = findCheckboxInListItem(marker)\n if (!checkbox) {\n return\n }\n\n const content = node.children.item(1)\n if (!content || !content.classList.contains('list-content')) {\n return\n }\n\n const textBlock = content.children.item(0)\n if (!textBlock || !['P', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6'].includes(textBlock.tagName)) {\n return\n }\n\n node.replaceChildren(...content.children)\n textBlock.prepend(checkbox)\n}\n","import { defineNodeSpec, type Extension } from '@prosekit/core'\nimport type { DOMOutputSpec, ProseMirrorNode } from '@prosekit/pm/model'\nimport { createListSpec, listToDOM, type ListAttributes } from 'prosemirror-flat-list'\n\nimport type { ListAttrs } from './list-types.ts'\n\n/**\n * @internal\n */\nexport type ListSpecExtension = Extension<{\n Nodes: {\n list: ListAttrs\n }\n}>\n\nfunction getMarkers(node: ProseMirrorNode): DOMOutputSpec[] {\n const attrs = node.attrs as ListAttributes\n switch (attrs.kind) {\n case 'task':\n // Use a `label` element here so that the area around the checkbox is also checkable.\n return [\n [\n 'label',\n [\n 'input',\n { type: 'checkbox', checked: attrs.checked ? '' : undefined },\n ],\n ],\n ]\n default:\n // Always return an empty array so that the marker element is rendered. This\n // is required to make the drop indicator locate the correct position.\n return []\n }\n}\n\n/**\n * @internal\n */\nexport function defineListSpec(): ListSpecExtension {\n const spec = createListSpec()\n\n return defineNodeSpec<'list', ListAttrs>({\n ...spec,\n toDOM: (node) => {\n return listToDOM({ node, getMarkers })\n },\n name: 'list',\n })\n}\n","import type { PlainExtension } from '@prosekit/core'\n\nimport type { DragEventHandler } from '../drop-indicator/index.ts'\nimport { defineDropIndicator } from '../drop-indicator/index.ts'\n\n/**\n * Configures drop indicator to avoid unexpected drop point.\n *\n * We don't want to drag a list node and drop it as the first\n * child of another list node.\n *\n * @internal\n */\nexport function defineListDropIndicator(): PlainExtension {\n return defineDropIndicator({\n onDrag,\n })\n}\n\nconst onDrag: DragEventHandler = ({ view, pos }): boolean => {\n const slice = view.dragging?.slice\n if (\n slice\n && slice.openStart === 0\n && slice.openEnd === 0\n && slice.content.childCount === 1\n ) {\n const node = slice.content.child(0)\n if (node.type.name === 'list') {\n const $pos = view.state.doc.resolve(pos)\n if ($pos.parent.type.name === 'list' && $pos.index() === 0) {\n return false\n }\n }\n }\n return true\n}\n","import { union, type Union } from '@prosekit/core'\n\nimport { defineListCommands, type ListCommandsExtension } from './list-commands.ts'\nimport { defineListDropIndicator } from './list-drop-indicator.ts'\nimport { defineListInputRules } from './list-input-rules.ts'\nimport { defineListKeymap } from './list-keymap.ts'\nimport { defineListPlugins } from './list-plugins.ts'\nimport { defineListSerializer } from './list-serializer.ts'\nimport { defineListSpec, type ListSpecExtension } from './list-spec.ts'\n\n/**\n * @internal\n */\nexport type ListExtension = Union<[ListSpecExtension, ListCommandsExtension]>\n\n/**\n * @public\n */\nexport function defineList(): ListExtension {\n return union(\n defineListSpec(),\n defineListPlugins(),\n defineListKeymap(),\n defineListInputRules(),\n defineListCommands(),\n defineListSerializer(),\n defineListDropIndicator(),\n )\n}\n"],"mappings":";;;;;;;;AAkBA,SAAS,WAAW,OAAiC;AACnD,QAAO,WAAW;EAAE,MAAM;EAAQ;EAAO,CAAC;;;;;;;AAyB5C,SAAgB,qBAA4C;AAC1D,QAAO,eAAe;EACpB,YAAA;EACA,YAAA;EACA,UAAA;EACA,WAAA;EACA,iBAAA;EACA,YAAA;EACA,YAAA;EACA,YAAA;EACA;EACD,CAAC;;;;;;;AC/CJ,SAAgB,uBAAkC;AAChD,QAAO,MAAM,eAAe,IAAI,gBAAgB,CAAC;;;;ACKnD,MAAM,mBAAmB,cACvB,kBACA,iBACA,YACA,0BACD;AAED,MAAM,oBAAoB,yBAAyB;AACnD,MAAM,oBAAoB,yBAAyB;AAEnD,MAAM,aAAa;CACjB,SAAS;CACT,aAAa;CACb,UAAU;CACV,SAAS;CACT,SAAS;CACT,OAAO;CACP,aAAa;CACd;;;;;;AAOD,SAAgB,mBAAmC;AACjD,QAAO,aAAa,WAAW;;;;AC/BjC,SAAS,4BAAoC;AAC3C,QAAO,IAAI,OAAO,EAChB,OAAO,EACL,iBAAiB,iBAClB,EACF,CAAC;;AAGJ,SAAS,oBAA8B;AACrC,QAAO;EACL,uBAAuB;EACvB,2BAA2B;EAC3B,2BAA2B;EAC3B,yCAAyC;EAC1C;;;;;AAMH,SAAgB,oBAAoC;AAClD,QAAO,aAAa,kBAAkB;;;;;;;ACvBxC,SAAgB,uBAAuC;AACrD,QAAO,0BAA0B;EAC/B,2BAA2B,OAAO;AAChC,WAAQ,GAAG,SAAS;AAElB,WAAO,qBAAqB,iBADhB,GAAG,GAAG,KAAK,CAC0B,CAAC;;;EAGtD,uBAAuB,OAAO;AAC5B,WAAQ,GAAG,SAAS;IAClB,MAAM,MAAM,GAAG,GAAG,KAAK;AACvB,WAAO,cAAc,IAAI,GACrB,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EACvC,GAHW,gBAAgB;EAI3B,QAAQ,SAAS;AACf,UAAO,UAAU;IAAE;IAAM;IAAY,CAAC;;EAExC,MAAM;EACP,CAAC;;;;;;;;;;;;ACnCJ,SAAgB,0BAA0C;AACxD,QAAO,oBAAoB,EACzB,QACD,CAAC;;AAGJ,MAAM,UAA4B,EAAE,MAAM,UAAmB;CAC3D,MAAM,QAAQ,KAAK,UAAU;AAC7B,KACE,SACG,MAAM,cAAc,KACpB,MAAM,YAAY,KAClB,MAAM,QAAQ,eAAe;MAEnB,MAAM,QAAQ,MAAM,EAAE,CAC1B,KAAK,SAAS,QAAQ;GAC7B,MAAM,OAAO,KAAK,MAAM,IAAI,QAAQ,IAAI;AACxC,OAAI,KAAK,OAAO,KAAK,SAAS,UAAU,KAAK,OAAO,KAAK,EACvD,QAAO;;;AAIb,QAAO;;;;;;;ACjBT,SAAgB,aAA4B;AAC1C,QAAO,MACL,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,EACpB,sBAAsB,EACtB,yBAAyB,CAC1B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-extensions-loro.d.ts","names":[],"sources":["../src/loro/loro-commands.ts","../src/loro/loro-cursor-plugin.ts","../src/loro/loro-keymap.ts","../src/loro/loro-sync-plugin.ts","../src/loro/loro-undo-plugin.ts","../src/loro/loro.ts"],"mappings":";;;;;;;KAWY,qBAAA,GAAwB,SAAA;EAClC,QAAA;IACE,IAAA;IACA,IAAA;EAAA;AAAA;AAAA,iBAIY,kBAAA,CAAA,GAAsB,qBAAA;;;UCbrB,iBAAA,SAA0B,mBAAA;EACzC,SAAA,GAAY,eAAA;EACZ,QAAA,GAAW,oBAAA;AAAA;AAAA,iBAGG,sBAAA,CACd,OAAA,EAAS,iBAAA,GACR,cAAA;;;iBCAa,gBAAA,CAAA,GAAoB,cAAA;;;iBCTpB,oBAAA,CACd,OAAA,EAAS,qBAAA,GACR,cAAA;;;iBCFa,oBAAA,CAAqB,OAAA,EAAS,qBAAA,GAAsB,cAAA;;;UCcnD,WAAA;ELNL;;;EKUV,GAAA,EAAK,WAAA;ELV6B;;;EKelC,SAAA,GAAY,eAAA;ELZN;;AAIR;EKaE,QAAA,GAAW,oBAAA;;;;EAKX,IAAA,GAAO,IAAA,CAAK,qBAAA;;;AJ/Bd;EIoCE,IAAA,GAAO,IAAA,CAAK,qBAAA;;;;EAKZ,MAAA,GAAS,mBAAA;AAAA;;;;KAMC,aAAA,GAAgB,KAAA,EAAO,qBAAA,EAAuB,cAAA;;;;iBAK1C,UAAA,CAAW,OAAA,EAAS,WAAA,GAAc,aAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-extensions-loro.js","names":[],"sources":["../src/loro/loro-commands.ts","../src/loro/loro-cursor-plugin.ts","../src/loro/loro-keymap.ts","../src/loro/loro-sync-plugin.ts","../src/loro/loro-undo-plugin.ts","../src/loro/loro.ts"],"sourcesContent":["import { defineCommands, type Extension } from '@prosekit/core'\nimport { redo, undo } from 'loro-prosemirror'\n\nconst commands = {\n undo: () => undo,\n redo: () => redo,\n} as const\n\n/**\n * @internal\n */\nexport type LoroCommandsExtension = Extension<{\n Commands: {\n undo: []\n redo: []\n }\n}>\n\nexport function defineLoroCommands(): LoroCommandsExtension {\n return defineCommands(commands)\n}\n","import { definePlugin, type PlainExtension } from '@prosekit/core'\nimport type { Plugin } from '@prosekit/pm/state'\nimport type { CursorAwareness, CursorEphemeralStore, CursorPluginOptions } from 'loro-prosemirror'\nimport { LoroCursorPlugin, LoroEphemeralCursorPlugin } from 'loro-prosemirror'\n\nexport interface LoroCursorOptions extends CursorPluginOptions {\n awareness?: CursorAwareness\n presence?: CursorEphemeralStore\n}\n\nexport function defineLoroCursorPlugin(\n options: LoroCursorOptions,\n): PlainExtension {\n return definePlugin(createLoroCursorPlugin(options))\n}\n\nfunction createLoroCursorPlugin(options: LoroCursorOptions): Plugin {\n const { awareness, presence, ...rest } = options\n if (awareness && presence) {\n throw new Error('Only one of awareness and presence can be provided')\n } else if (awareness) {\n return LoroCursorPlugin(awareness, rest)\n } else if (presence) {\n return LoroEphemeralCursorPlugin(presence, rest)\n } else {\n throw new Error('Either awareness or presence must be provided')\n }\n}\n","import { defineKeymap, isApple, type Keymap, type PlainExtension } from '@prosekit/core'\nimport { redo, undo } from 'loro-prosemirror'\n\nconst keymap: Keymap = {\n 'Mod-z': undo,\n 'Mod-Z': redo,\n}\n\nif (!isApple) {\n keymap['Mod-y'] = redo\n}\n\nexport function defineLoroKeymap(): PlainExtension {\n return defineKeymap(keymap)\n}\n","import { definePlugin, type PlainExtension } from '@prosekit/core'\nimport { LoroSyncPlugin, type LoroSyncPluginProps } from 'loro-prosemirror'\n\nexport function defineLoroSyncPlugin(\n options: LoroSyncPluginProps,\n): PlainExtension {\n return definePlugin(LoroSyncPlugin(options))\n}\n","import { definePlugin, type PlainExtension } from '@prosekit/core'\nimport { LoroUndoPlugin, type LoroUndoPluginProps } from 'loro-prosemirror'\n\nexport function defineLoroUndoPlugin(options: LoroUndoPluginProps): PlainExtension {\n return definePlugin(LoroUndoPlugin(options))\n}\n","import type { Priority } from '@prosekit/core'\nimport { union, withPriority, type PlainExtension, type Union } from '@prosekit/core'\nimport type {\n CursorAwareness,\n CursorEphemeralStore,\n CursorPluginOptions,\n LoroDocType,\n LoroSyncPluginProps,\n LoroUndoPluginProps,\n} from 'loro-prosemirror'\n\nimport { defineLoroCommands, type LoroCommandsExtension } from './loro-commands.ts'\nimport { defineLoroCursorPlugin } from './loro-cursor-plugin.ts'\nimport { defineLoroKeymap } from './loro-keymap.ts'\nimport { defineLoroSyncPlugin } from './loro-sync-plugin.ts'\nimport { defineLoroUndoPlugin } from './loro-undo-plugin.ts'\n\nexport interface LoroOptions {\n /**\n * The Loro instance handles the state of shared data.\n */\n doc: LoroDocType\n\n /**\n * The (legacy) Awareness instance. One of `awareness` or `presence` must be provided.\n */\n awareness?: CursorAwareness\n\n /**\n * The CursorEphemeralStore instance. One of `awareness` or `presence` must be provided.\n */\n presence?: CursorEphemeralStore\n\n /**\n * Extra options for `LoroSyncPlugin`.\n */\n sync?: Omit<LoroSyncPluginProps, 'doc'>\n\n /**\n * Extra options for the `LoroUndoPlugin`.\n */\n undo?: Omit<LoroUndoPluginProps, 'doc'>\n\n /**\n * Extra options for `LoroCursorPlugin` or `LoroEphemeralCursorPlugin`.\n */\n cursor?: CursorPluginOptions\n}\n\n/**\n * @internal\n */\nexport type LoroExtension = Union<[LoroCommandsExtension, PlainExtension]>\n\n/**\n * @public\n */\nexport function defineLoro(options: LoroOptions): LoroExtension {\n const { doc, awareness, presence, sync, undo, cursor } = options\n\n return withPriority(\n union([\n defineLoroKeymap(),\n defineLoroCommands(),\n defineLoroCursorPlugin({ ...cursor, awareness, presence }),\n defineLoroUndoPlugin({ ...undo, doc }),\n defineLoroSyncPlugin({ ...sync, doc }),\n ]),\n 3 satisfies typeof Priority.high,\n )\n}\n"],"mappings":";;;AAGA,MAAM,WAAW;CACf,YAAY;CACZ,YAAY;CACb;AAYD,SAAgB,qBAA4C;AAC1D,QAAO,eAAe,SAAS;;;;ACTjC,SAAgB,uBACd,SACgB;AAChB,QAAO,aAAa,uBAAuB,QAAQ,CAAC;;AAGtD,SAAS,uBAAuB,SAAoC;CAClE,MAAM,EAAE,WAAW,UAAU,GAAG,SAAS;AACzC,KAAI,aAAa,SACf,OAAM,IAAI,MAAM,qDAAqD;UAC5D,UACT,QAAO,iBAAiB,WAAW,KAAK;UAC/B,SACT,QAAO,0BAA0B,UAAU,KAAK;KAEhD,OAAM,IAAI,MAAM,gDAAgD;;;;ACtBpE,MAAM,SAAiB;CACrB,SAAS;CACT,SAAS;CACV;AAED,IAAI,CAAC,QACH,QAAO,WAAW;AAGpB,SAAgB,mBAAmC;AACjD,QAAO,aAAa,OAAO;;;;ACV7B,SAAgB,qBACd,SACgB;AAChB,QAAO,aAAa,eAAe,QAAQ,CAAC;;;;ACH9C,SAAgB,qBAAqB,SAA8C;AACjF,QAAO,aAAa,eAAe,QAAQ,CAAC;;;;;;;ACqD9C,SAAgB,WAAW,SAAqC;CAC9D,MAAM,EAAE,KAAK,WAAW,UAAU,MAAM,MAAM,WAAW;AAEzD,QAAO,aACL,MAAM;EACJ,kBAAkB;EAClB,oBAAoB;EACpB,uBAAuB;GAAE,GAAG;GAAQ;GAAW;GAAU,CAAC;EAC1D,qBAAqB;GAAE,GAAG;GAAM;GAAK,CAAC;EACtC,qBAAqB;GAAE,GAAG;GAAM;GAAK,CAAC;EACvC,CAAC,EACF,EACD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-extensions-mark-rule.d.ts","names":[],"sources":["../src/mark-rule/types.ts","../src/mark-rule/mark-rule.ts"],"mappings":";;;;;;;AAOA;;UAAiB,eAAA;EAKR;;;;EAAP,KAAA,EAAO,MAAA;EAamD;;;EAR1D,IAAA,WAAe,QAAA;EAAf;;;;;;EAQA,KAAA,GAAQ,KAAA,YAAiB,KAAA,EAAO,gBAAA,KAAqB,KAAA;AAAA;;;;;AAlBvD;;iBCGgB,cAAA,CAAe,OAAA,EAAS,eAAA,GAAkB,cAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-extensions-math.d.ts","names":[],"sources":["../src/math/math-block.ts","../src/math/math-inline.ts","../src/math/math-plugin.ts","../src/math/math.ts"],"mappings":";;;;;;;AASA;KAAY,sBAAA,GAAyB,SAAA;EACnC,KAAA;IACE,SAAA,EAAW,KAAA;EAAA;AAAA;;;;iBAOC,mBAAA,CAAA,GAAuB,sBAAA;AAAvC;;;;;AAAA,UAmBiB,oBAAA;EAAoB;;;EAInC,MAAA,EAAQ,eAAA;AAAA;;;;;;;iBASM,mBAAA,CAAA;EAAsB;AAAA,GAAU,oBAAA,GAAuB,SAAA;;;;iBAYvD,wBAAA,CAAA,GAA4B,cAAA;;;AAA5C;;;UASiB,gBAAA;EATyC;AAS1D;;EAIE,MAAA,EAAQ,eAAA;AAAA;;AAMV;;KAAY,kBAAA,GAAqB,KAAA,EAAO,sBAAA;;;AAQxC;;;;iBAAgB,eAAA,CAAgB,OAAA,EAAS,gBAAA,GAAmB,kBAAA;;;;;AAhF5D;KCAY,uBAAA,GAA0B,SAAA;EACpC,KAAA;IACE,UAAA,EAAY,KAAA;EAAA;AAAA;;;;iBAOA,oBAAA,CAAA,GAAwB,uBAAA;ADAxC;;;;;AAAA,UCYiB,qBAAA;EDOoB;;;ECHnC,MAAA,EAAQ,gBAAA;AAAA;;;;;;;iBASM,oBAAA,CAAA;EAAuB;AAAA,GAAU,qBAAA,GAAwB,SAAA;;;;iBAYzD,yBAAA,CAAA,GAA6B,cAAA;;;ADO7C;;;UCEiB,iBAAA;EDFyC;AAS1D;;ECHE,MAAA,EAAQ,gBAAA;AAAA;;ADaV;;KCPY,mBAAA,GAAsB,KAAA,EAAO,uBAAA;;;ADezC;;;;iBCPgB,gBAAA,CAAiB,OAAA,EAAS,iBAAA,GAAoB,mBAAA;;;iBC/E9C,gBAAA,CAAA,GAAoB,cAAA;;;;AFMpC;;KGCY,aAAA,GAAgB,KAAA,EAAO,mBAAA,EAAqB,kBAAA;;;;;;UAOvC,WAAA;EHNG;AAOpB;;EGGE,eAAA,EAAiB,eAAA;EHHoB;;AAmBvC;EGXE,gBAAA,EAAkB,gBAAA;AAAA;;;AHwBpB;iBGlBgB,UAAA,CAAW,OAAA,EAAS,WAAA,GAAc,aAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-extensions-math.js","names":[],"sources":["../src/math/math-block.ts","../src/math/math-inline.ts","../src/math/math-plugin.ts","../src/math/math.ts"],"sourcesContent":["import { defineNodeSpec, defineNodeView, union, type Extension, type PlainExtension, type Union } from '@prosekit/core'\nimport type { Attrs } from '@prosekit/pm/model'\nimport { createMathBlockView, mathBlockEnterRule, mathBlockSpec, type RenderMathBlock } from 'prosemirror-math'\n\nimport { defineEnterRule } from '../enter-rule/index.ts'\n\n/**\n * @internal\n */\nexport type MathBlockSpecExtension = Extension<{\n Nodes: {\n mathBlock: Attrs\n }\n}>\n\n/**\n * @internal\n */\nexport function defineMathBlockSpec(): MathBlockSpecExtension {\n return defineNodeSpec<'mathBlock', Attrs>({\n ...mathBlockSpec,\n attrs: {\n // The language in the `mathBlock` node, useful for syntax highlighting.\n // This library doesn't focus on using the TeX language in a `mathBlock` node,\n // but this is the most common language used for math blocks in rich text\n // editors, so 'tex' is set as the default value.\n language: { default: 'tex', validate: 'string' },\n },\n name: 'mathBlock',\n })\n}\n\n/**\n * Options for {@link defineMathBlockView}.\n *\n * @internal\n */\nexport interface MathBlockViewOptions {\n /**\n * The function to render the math block.\n */\n render: RenderMathBlock\n}\n\n/**\n * Defines an extension that renders a math block using a custom node view.\n *\n * @param options\n * @internal\n */\nexport function defineMathBlockView({ render }: MathBlockViewOptions): Extension {\n return defineNodeView({\n name: 'mathBlock',\n constructor: (node, view, getPos, decorations) => {\n return createMathBlockView(render, node, decorations)\n },\n })\n}\n\n/**\n * @internal\n */\nexport function defineMathBlockEnterRule(): PlainExtension {\n return defineEnterRule(mathBlockEnterRule)\n}\n\n/**\n * Options for {@link defineMathBlock}.\n *\n * @internal\n */\nexport interface MathBlockOptions {\n /**\n * The function to render the math block.\n */\n render: RenderMathBlock\n}\n\n/**\n * @internal\n */\nexport type MathBlockExtension = Union<[MathBlockSpecExtension]>\n\n/**\n * Defines node `mathBlock` and related functionalities.\n *\n * @param options\n * @public\n */\nexport function defineMathBlock(options: MathBlockOptions): MathBlockExtension {\n return union(\n defineMathBlockSpec(),\n defineMathBlockView(options),\n defineMathBlockEnterRule(),\n )\n}\n","import { defineNodeSpec, defineNodeView, union, type Extension, type PlainExtension, type Union } from '@prosekit/core'\nimport type { Attrs } from '@prosekit/pm/model'\nimport { createMathInlineInputRule, createMathInlineView, mathInlineSpec, type RenderMathInline } from 'prosemirror-math'\n\nimport { defineInputRule } from '../input-rule/index.ts'\n\n/**\n * @internal\n */\nexport type MathInlineSpecExtension = Extension<{\n Nodes: {\n mathInline: Attrs\n }\n}>\n\n/**\n * @internal\n */\nexport function defineMathInlineSpec(): MathInlineSpecExtension {\n return defineNodeSpec<'mathInline', Attrs>({\n ...mathInlineSpec,\n name: 'mathInline',\n })\n}\n\n/**\n * Options for {@link defineMathInlineView}.\n *\n * @internal\n */\nexport interface MathInlineViewOptions {\n /**\n * The function to render the math inline.\n */\n render: RenderMathInline\n}\n\n/**\n * Defines an extension that renders a math inline using a custom node view.\n *\n * @param options\n * @internal\n */\nexport function defineMathInlineView({ render }: MathInlineViewOptions): Extension {\n return defineNodeView({\n name: 'mathInline',\n constructor: (node, view, getPos, decorations) => {\n return createMathInlineView(render, node, decorations)\n },\n })\n}\n\n/**\n * @internal\n */\nexport function defineMathInlineInputRule(): PlainExtension {\n return defineInputRule(createMathInlineInputRule('mathInline'))\n}\n\n/**\n * Options for {@link defineMathInline}.\n *\n * @internal\n */\nexport interface MathInlineOptions {\n /**\n * The function to render the math inline.\n */\n render: RenderMathInline\n}\n\n/**\n * @internal\n */\nexport type MathInlineExtension = Union<[MathInlineSpecExtension]>\n\n/**\n * Defines node `mathInline` and related functionalities.\n *\n * @param options\n * @public\n */\nexport function defineMathInline(options: MathInlineOptions): MathInlineExtension {\n return union(\n defineMathInlineSpec(),\n defineMathInlineView(options),\n defineMathInlineInputRule(),\n )\n}\n","import { definePlugin, type PlainExtension } from '@prosekit/core'\nimport { createCursorInsidePlugin } from 'prosemirror-math'\n\nexport function defineMathPlugin(): PlainExtension {\n return definePlugin(\n createCursorInsidePlugin(),\n )\n}\n","import { union, type Union } from '@prosekit/core'\nimport type { RenderMathBlock, RenderMathInline } from 'prosemirror-math'\n\nimport { defineMathBlock, type MathBlockExtension } from './math-block.ts'\nimport { defineMathInline, type MathInlineExtension } from './math-inline.ts'\nimport { defineMathPlugin } from './math-plugin.ts'\n\n/**\n * @public\n */\nexport type MathExtension = Union<[MathInlineExtension, MathBlockExtension]>\n\n/**\n * Options for {@link defineMath}.\n *\n * @public\n */\nexport interface MathOptions {\n /**\n * The function to render the math block.\n */\n renderMathBlock: RenderMathBlock\n\n /**\n * The function to render the math inline.\n */\n renderMathInline: RenderMathInline\n}\n\n/**\n * @public\n */\nexport function defineMath(options: MathOptions): MathExtension {\n return union(\n defineMathBlock({ render: options.renderMathBlock }),\n defineMathInline({ render: options.renderMathInline }),\n defineMathPlugin(),\n )\n}\n"],"mappings":";;;;;;;;AAkBA,SAAgB,sBAA8C;AAC5D,QAAO,eAAmC;EACxC,GAAG;EACH,OAAO,EAKL,UAAU;GAAE,SAAS;GAAO,UAAU;GAAU,EACjD;EACD,MAAM;EACP,CAAC;;;;;;;;AAqBJ,SAAgB,oBAAoB,EAAE,UAA2C;AAC/E,QAAO,eAAe;EACpB,MAAM;EACN,cAAc,MAAM,MAAM,QAAQ,gBAAgB;AAChD,UAAO,oBAAoB,QAAQ,MAAM,YAAY;;EAExD,CAAC;;;;;AAMJ,SAAgB,2BAA2C;AACzD,QAAO,gBAAgB,mBAAmB;;;;;;;;AA0B5C,SAAgB,gBAAgB,SAA+C;AAC7E,QAAO,MACL,qBAAqB,EACrB,oBAAoB,QAAQ,EAC5B,0BAA0B,CAC3B;;;;;;;AC5EH,SAAgB,uBAAgD;AAC9D,QAAO,eAAoC;EACzC,GAAG;EACH,MAAM;EACP,CAAC;;;;;;;;AAqBJ,SAAgB,qBAAqB,EAAE,UAA4C;AACjF,QAAO,eAAe;EACpB,MAAM;EACN,cAAc,MAAM,MAAM,QAAQ,gBAAgB;AAChD,UAAO,qBAAqB,QAAQ,MAAM,YAAY;;EAEzD,CAAC;;;;;AAMJ,SAAgB,4BAA4C;AAC1D,QAAO,gBAAgB,0BAA0B,aAAa,CAAC;;;;;;;;AA0BjE,SAAgB,iBAAiB,SAAiD;AAChF,QAAO,MACL,sBAAsB,EACtB,qBAAqB,QAAQ,EAC7B,2BAA2B,CAC5B;;;;ACpFH,SAAgB,mBAAmC;AACjD,QAAO,aACL,0BAA0B,CAC3B;;;;;;;AC0BH,SAAgB,WAAW,SAAqC;AAC9D,QAAO,MACL,gBAAgB,EAAE,QAAQ,QAAQ,iBAAiB,CAAC,EACpD,iBAAiB,EAAE,QAAQ,QAAQ,kBAAkB,CAAC,EACtD,kBAAkB,CACnB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-extensions-mention.d.ts","names":[],"sources":["../src/mention/index.ts"],"mappings":";;;UAEiB,YAAA;EACf,EAAA;EACA,KAAA;EACA,IAAA;AAAA;;;;KAMU,oBAAA,GAAuB,SAAA;EACjC,KAAA;IACE,OAAA,EAAS,YAAA;EAAA;AAAA;;;;iBAOG,iBAAA,CAAA,GAAqB,oBAAA;;;;KAsCzB,wBAAA,GAA2B,SAAA;EACrC,QAAA;IACE,aAAA,GAAgB,KAAA,EAAO,YAAA;EAAA;AAAA;AAAA,iBAIX,qBAAA,CAAA,GAAyB,wBAAA;AANzC;;;AAAA,KAiBY,gBAAA,GAAmB,KAAA,EAAO,oBAAA,EAAsB,wBAAA;;;;iBAK5C,aAAA,CAAA,GAAiB,gBAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-extensions-mention.js","names":[],"sources":["../src/mention/index.ts"],"sourcesContent":["import { defineCommands, defineNodeSpec, insertNode, union, type Extension, type Union } from '@prosekit/core'\n\nexport interface MentionAttrs {\n id: string\n value: string\n kind: string\n}\n\n/**\n * @internal\n */\nexport type MentionSpecExtension = Extension<{\n Nodes: {\n mention: MentionAttrs\n }\n}>\n\n/**\n * @public\n */\nexport function defineMentionSpec(): MentionSpecExtension {\n return defineNodeSpec<'mention', MentionAttrs>({\n name: 'mention',\n atom: true,\n group: 'inline',\n attrs: {\n id: { validate: 'string' },\n value: { validate: 'string' },\n kind: { default: '', validate: 'string' },\n },\n inline: true,\n leafText: (node) => (node.attrs as MentionAttrs).value.toString(),\n parseDOM: [\n {\n tag: `span[data-mention]`,\n getAttrs: (dom: HTMLElement): MentionAttrs => ({\n id: dom.getAttribute('data-id') || '',\n kind: dom.getAttribute('data-mention') || '',\n value: dom.textContent || '',\n }),\n },\n ],\n toDOM(node) {\n return [\n 'span',\n {\n 'data-id': (node.attrs as MentionAttrs).id.toString(),\n 'data-mention': (node.attrs as MentionAttrs).kind.toString(),\n },\n (node.attrs as MentionAttrs).value.toString(),\n ]\n },\n })\n}\n\n/**\n * @internal\n */\nexport type MentionCommandsExtension = Extension<{\n Commands: {\n insertMention: [attrs: MentionAttrs]\n }\n}>\n\nexport function defineMentionCommands(): MentionCommandsExtension {\n return defineCommands({\n insertMention: (attrs: MentionAttrs) => {\n return insertNode({ type: 'mention', attrs })\n },\n })\n}\n\n/**\n * @internal\n */\nexport type MentionExtension = Union<[MentionSpecExtension, MentionCommandsExtension]>\n\n/**\n * @public\n */\nexport function defineMention(): MentionExtension {\n return union(defineMentionSpec(), defineMentionCommands())\n}\n"],"mappings":";;;;;AAoBA,SAAgB,oBAA0C;AACxD,QAAO,eAAwC;EAC7C,MAAM;EACN,MAAM;EACN,OAAO;EACP,OAAO;GACL,IAAI,EAAE,UAAU,UAAU;GAC1B,OAAO,EAAE,UAAU,UAAU;GAC7B,MAAM;IAAE,SAAS;IAAI,UAAU;IAAU;GAC1C;EACD,QAAQ;EACR,WAAW,SAAU,KAAK,MAAuB,MAAM,UAAU;EACjE,UAAU,CACR;GACE,KAAK;GACL,WAAW,SAAoC;IAC7C,IAAI,IAAI,aAAa,UAAU,IAAI;IACnC,MAAM,IAAI,aAAa,eAAe,IAAI;IAC1C,OAAO,IAAI,eAAe;IAC3B;GACF,CACF;EACD,MAAM,MAAM;AACV,UAAO;IACL;IACA;KACE,WAAY,KAAK,MAAuB,GAAG,UAAU;KACrD,gBAAiB,KAAK,MAAuB,KAAK,UAAU;KAC7D;IACA,KAAK,MAAuB,MAAM,UAAU;IAC9C;;EAEJ,CAAC;;AAYJ,SAAgB,wBAAkD;AAChE,QAAO,eAAe,EACpB,gBAAgB,UAAwB;AACtC,SAAO,WAAW;GAAE,MAAM;GAAW;GAAO,CAAC;IAEhD,CAAC;;;;;AAWJ,SAAgB,gBAAkC;AAChD,QAAO,MAAM,mBAAmB,EAAE,uBAAuB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-extensions-mod-click-prevention.d.ts","names":[],"sources":["../src/mod-click-prevention/index.ts"],"mappings":";;;;;AAOA;KAAY,2BAAA,GAA8B,cAAA;;;;AAQ1C;;;iBAAgB,wBAAA,CAAA,GAA4B,2BAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-extensions-mod-click-prevention.js","names":[],"sources":["../src/mod-click-prevention/index.ts"],"sourcesContent":["import { definePlugin, isApple, type PlainExtension } from '@prosekit/core'\nimport { Plugin, PluginKey } from '@prosekit/pm/state'\nimport type { EditorView } from '@prosekit/pm/view'\n\n/**\n * @internal\n */\nexport type ModClickPreventionExtension = PlainExtension\n\n/**\n * By default, clicking a node while holding the mod key will select the node. This\n * extension disables that behavior.\n *\n * @public\n */\nexport function defineModClickPrevention(): ModClickPreventionExtension {\n return definePlugin(new Plugin({ key, props: { handleClick } }))\n}\n\nconst key = new PluginKey('prosekit-mod-click-prevention')\n\nfunction handleClick(_view: EditorView, _pos: number, event: MouseEvent) {\n return !!event[selectNodeModifier]\n}\n\nconst selectNodeModifier: 'metaKey' | 'ctrlKey' = isApple\n ? 'metaKey'\n : 'ctrlKey'\n"],"mappings":";;;;;;;;;AAeA,SAAgB,2BAAwD;AACtE,QAAO,aAAa,IAAI,OAAO;EAAE;EAAK,OAAO,EAAE,aAAa;EAAE,CAAC,CAAC;;AAGlE,MAAM,MAAM,IAAI,UAAU,gCAAgC;AAE1D,SAAS,YAAY,OAAmB,MAAc,OAAmB;AACvE,QAAO,CAAC,CAAC,MAAM;;AAGjB,MAAM,qBAA4C,UAC9C,YACA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-extensions-page.d.ts","names":[],"sources":["../src/page/page-break-commands.ts","../src/page/page-break-keymap.ts","../src/page/page-break-spec.ts","../src/page/page-break.ts","../src/page/page-rendering.ts"],"mappings":";;;;;;;;KAOY,0BAAA,GAA6B,SAAA;EACvC,QAAA;IACE,eAAA;EAAA;AAAA;;;;iBAoBY,eAAA,CAAA,GAAmB,OAAA;AAAnC;;;AAAA,iBAOgB,uBAAA,CAAA,GAA2B,0BAAA;;;;;;KC7B/B,wBAAA,GAA2B,cAAA;ADAvC;;;AAAA,iBCKgB,qBAAA,CAAA,GAAyB,wBAAA;;;;;;KCN7B,sBAAA,GAAyB,SAAA;EACnC,KAAA;IACE,SAAA,EAAW,KAAA;EAAA;AAAA;;;;iBAOC,mBAAA,CAAA,GAAuB,sBAAA;AAAA;EAAA,UAc3B,QAAA;IACR,SAAA;EAAA;AAAA;;;;AFvBJ;;KGEY,kBAAA,GAAqB,KAAA,EAC9B,sBAAA,EAAwB,0BAAA,EAA4B,wBAAA;;;AHmBvD;iBGbgB,eAAA,CAAA,GAAmB,kBAAA;;;;;;UCLlB,oBAAA;EJJL;;;;;EIUV,SAAA;EJRE;;;AAoBJ;;EILE,UAAA;EJKiC;;AAOnC;;;EILE,SAAA;EJKmE;;;;AC7BrE;EG+BE,WAAA;;;;AH1BF;;EGiCE,YAAA;EHjCuC;;;;;EGwCvC,UAAA;AAAA;;;;iBAMc,mBAAA,CAAoB,OAAA,GAAS,oBAAA,GAA4B,sBAAA;;;;KAS7D,sBAAA,GAAyB,SAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-extensions-page.js","names":["#parseDataAttributes","#isLeader","#isHeadPending","#render","#contentBoxHeight","#paddingTop","#paddingBottom","#requestUpdate","#group","#forceNextBreak","#pageHeight","#parseFloatAttribute","#pageMarginTop","#pageMarginBottom","#size","#paddingTopPending","#paddingBottomPending","#isHead","#isTail","#isTailPending","#updateRequested","#updateAll"],"sources":["../src/page/page-break-commands.ts","../src/page/page-break-keymap.ts","../src/page/page-break-spec.ts","../src/page/page-break.ts","../src/page/page-element.ts","../src/page/page-rendering.ts"],"sourcesContent":["import { defineCommands, getNodeType, type Extension } from '@prosekit/core'\nimport { Fragment, Slice } from '@prosekit/pm/model'\nimport type { Command } from '@prosekit/pm/state'\n\n/**\n * @internal\n */\nexport type PageBreakCommandsExtension = Extension<{\n Commands: {\n insertPageBreak: []\n }\n}>\n\nconst insertPageBreakCommand: Command = (state, dispatch): boolean => {\n if (!dispatch) return true\n\n const { schema, tr } = state\n const type = getNodeType(schema, 'pageBreak')\n const node = type.createChecked()\n const pos = tr.selection.anchor\n const slice = new Slice(Fragment.from(node), 0, 0)\n tr.replaceRange(pos, pos, slice).scrollIntoView()\n dispatch(tr)\n return true\n}\n\n/**\n * @internal\n */\nexport function insertPageBreak(): Command {\n return insertPageBreakCommand\n}\n\n/**\n * @internal\n */\nexport function definePageBreakCommands(): PageBreakCommandsExtension {\n return defineCommands({\n insertPageBreak: insertPageBreak,\n })\n}\n","import { defineKeymap, type PlainExtension } from '@prosekit/core'\n\nimport { insertPageBreak } from './page-break-commands.ts'\n\n/**\n * @internal\n */\nexport type PageBreakKeymapExtension = PlainExtension\n\n/**\n * @internal\n */\nexport function definePageBreakKeymap(): PageBreakKeymapExtension {\n return defineKeymap({\n 'Mod-Enter': insertPageBreak(),\n })\n}\n","import { defineNodeSpec, type Extension } from '@prosekit/core'\nimport type { Attrs } from '@prosekit/pm/model'\n\n/**\n * @internal\n */\nexport type PageBreakSpecExtension = Extension<{\n Nodes: {\n pageBreak: Attrs\n }\n}>\n\n/**\n * @internal\n */\nexport function definePageBreakSpec(): PageBreakSpecExtension {\n return defineNodeSpec({\n name: 'pageBreak',\n group: 'block',\n selectable: true,\n parseDOM: [{ tag: 'div.prosekit-page-break' }],\n toDOM() {\n return ['div', { class: 'prosekit-horizontal-rule prosekit-page-break' }, ['hr']]\n },\n pageBreak: true,\n })\n}\n\ndeclare module '@prosekit/pm/model' {\n interface NodeSpec {\n pageBreak?: boolean | undefined\n }\n}\n","import { union, type Union } from '@prosekit/core'\n\nimport { definePageBreakCommands, type PageBreakCommandsExtension } from './page-break-commands.ts'\nimport { definePageBreakKeymap, type PageBreakKeymapExtension } from './page-break-keymap.ts'\nimport { definePageBreakSpec, type PageBreakSpecExtension } from './page-break-spec.ts'\n\n/**\n * @internal\n */\nexport type PageBreakExtension = Union<\n [PageBreakSpecExtension, PageBreakCommandsExtension, PageBreakKeymapExtension]\n>\n\n/**\n * @public\n */\nexport function definePageBreak(): PageBreakExtension {\n return union(\n definePageBreakSpec(),\n definePageBreakCommands(),\n definePageBreakKeymap(),\n )\n}\n","import { once } from '@ocavue/utils'\nimport { customElements, HTMLElement } from 'server-dom-shim'\n\n/**\n * @internal\n */\nexport const PAGE_CHUNK_TAG_NAME = 'pm-page-chunk'\n\n/**\n * @internal\n */\nexport const registerPageChunkElement: VoidFunction = /* @__PURE__ */ once(() => {\n if (typeof window === 'undefined' || customElements.get(PAGE_CHUNK_TAG_NAME)) return\n customElements.define(PAGE_CHUNK_TAG_NAME, PageChunkElement)\n})\n\nclass PageChunkElement extends HTMLElement {\n static observedAttributes = [\n 'data-group',\n 'data-break',\n 'data-h',\n 'data-mt',\n 'data-mb',\n\n // Only the first chunk of the whole document has this attribute.\n 'data-size',\n ]\n\n // Data attributes set by external code\n #group: string = ''\n #forceNextBreak: boolean = false\n #pageHeight: number = 0\n #pageMarginTop: number = 0\n #pageMarginBottom: number = 0\n #size: number | undefined = undefined\n\n // Internal states\n #updateRequested: boolean = false\n #contentBoxHeight: number = 0\n\n // Rendering states\n #isHead: boolean = false\n #isTail: boolean = false\n #paddingTop: number = 0\n #paddingBottom: number = 0\n\n // Pending rendering states\n #isHeadPending: boolean = false\n #isTailPending: boolean = false\n #paddingTopPending: number = 0\n #paddingBottomPending: number = 0\n\n connectedCallback() {\n this.#parseDataAttributes()\n\n if (this.#isLeader()) {\n this.#isHeadPending = true\n }\n\n this.#render()\n\n // Get the initial content box height when the resize observer is not started yet. Notice that\n // `this.clientHeight` is an integer while the content box height can be a float, so this is not\n // accurate but should be good enough for the first render.\n this.#contentBoxHeight = this.clientHeight - this.#paddingTop - this.#paddingBottom\n\n observeElement(this)\n\n this.#requestUpdate()\n }\n\n disconnectedCallback() {\n unobserveElement(this)\n }\n\n attributeChangedCallback(_: string, oldValue: string | null, newValue: string | null) {\n if (oldValue === newValue) return\n this.#parseDataAttributes()\n this.#requestUpdate()\n }\n\n #parseDataAttributes() {\n this.#group = this.getAttribute('data-group') || ''\n this.#forceNextBreak = this.hasAttribute('data-break')\n this.#pageHeight = this.#parseFloatAttribute('data-h')\n this.#pageMarginTop = this.#parseFloatAttribute('data-mt')\n this.#pageMarginBottom = this.#parseFloatAttribute('data-mb')\n\n const sizeAttr = this.getAttribute('data-size')\n this.#size = sizeAttr ? Number.parseInt(sizeAttr, 10) : undefined\n }\n\n #parseFloatAttribute(name: string): number {\n const value = this.getAttribute(name)\n return value != null ? Number.parseFloat(value) : 0\n }\n\n #isLeader() {\n return this.#size != null\n }\n\n #render() {\n if (this.#paddingTop !== this.#paddingTopPending || this.#paddingBottom !== this.#paddingBottomPending) {\n Object.assign(this.style, {\n paddingTop: `${this.#paddingTop = this.#paddingTopPending}px`,\n paddingBottom: `${this.#paddingBottom = this.#paddingBottomPending}px`,\n })\n }\n if (this.#isHead !== this.#isHeadPending) {\n this.toggleAttribute('data-page-head', this.#isHead = this.#isHeadPending)\n }\n if (this.#isTail !== this.#isTailPending) {\n this.toggleAttribute('data-page-tail', this.#isTail = this.#isTailPending)\n }\n }\n\n setHeight(height: number) {\n // Avoid potential float number precision issues\n if (Math.abs(this.#contentBoxHeight - height) < 0.1) {\n return\n }\n this.#contentBoxHeight = height\n this.#requestUpdate()\n }\n\n /**\n * Schedules a batched page layout recalculation.\n *\n * Any chunk can call this method, but the actual layout work (#updateAll)\n * always runs on the leader chunk, because it needs to iterate over every\n * chunk in order to compute page breaks.\n *\n * Two nested microtasks are used to batch updates:\n *\n * Microtask 1 – Delegation: non-leader chunks forward the request to the\n * leader chunk, so multiple chunks changing in the same tick only trigger\n * one layout pass.\n *\n * Microtask 2 – Execution: the leader chunk defers #updateAll to a second\n * microtask so that any other attribute / resize changes that were queued\n * in the same tick (and forwarded during microtask 1) are already reflected\n * before the layout is recalculated.\n *\n * The #updateRequested flag acts as a deduplication guard so that rapid\n * successive calls (e.g. multiple attributes changing at once) result in at\n * most one scheduled pass per chunk.\n */\n #requestUpdate() {\n if (this.#updateRequested) {\n return\n }\n\n this.#updateRequested = true\n queueMicrotask(() => {\n if (!this.#isLeader()) {\n this.#updateRequested = false\n const leader = findLeaderChunk(this, this.#group)\n if (!leader) return\n leader.#requestUpdate()\n return\n }\n queueMicrotask(() => {\n this.#updateRequested = false\n this.#updateAll()\n })\n })\n }\n\n #updateAll() {\n if (!this.isConnected) {\n return\n }\n\n const elements = findAllChunks(this, this.#group)\n const count = elements.length\n if (count === 0) return\n\n const pageHeight = this.#pageHeight\n const pageMarginTop = this.#pageMarginTop\n const maxContentHeight = pageHeight - pageMarginTop - this.#pageMarginBottom\n\n let currentContentHeight = 0\n let forceNextBreak = false\n\n for (let i = 0; i < count; i++) {\n const element = elements[i]\n const h = element.#contentBoxHeight\n const isHead = forceNextBreak || i === 0 || (currentContentHeight + h > maxContentHeight)\n\n forceNextBreak = element.#forceNextBreak\n\n if (isHead && i > 0) {\n const prev = elements[i - 1]\n prev.#paddingBottomPending = Math.max(0, pageHeight - pageMarginTop - currentContentHeight)\n prev.#isTailPending = true\n currentContentHeight = h\n } else {\n currentContentHeight += h\n }\n\n element.#paddingTopPending = isHead ? pageMarginTop : 0\n element.#paddingBottomPending = 0\n element.#isTailPending = false\n element.#isHeadPending = isHead\n }\n\n const last = elements[count - 1]\n last.#paddingBottomPending = Math.max(0, pageHeight - pageMarginTop - currentContentHeight)\n last.#isTailPending = true\n\n for (const element of elements) {\n element.#render()\n }\n }\n}\n\nfunction handleResize(entries: ResizeObserverEntry[]) {\n for (const entry of entries) {\n const contentBoxHeight = entry.contentBoxSize?.[0]?.blockSize ?? entry.contentRect.height\n const element = entry.target as PageChunkElement\n element.setHeight(contentBoxHeight)\n }\n}\n\nconst getResizeObserver = /* @__PURE__ */ once(() => {\n return new ResizeObserver(handleResize)\n})\n\nfunction observeElement(element: PageChunkElement) {\n getResizeObserver().observe(element)\n}\n\nfunction unobserveElement(element: PageChunkElement) {\n getResizeObserver().unobserve(element)\n}\n\nfunction findLeaderChunk(element: HTMLElement, group: string): PageChunkElement | null | undefined {\n const root = element.closest('.ProseMirror')\n return root?.querySelector<PageChunkElement>(`${PAGE_CHUNK_TAG_NAME}[data-group=\"${group}\"][data-size]`)\n}\n\nfunction findAllChunks(element: HTMLElement, group: string): PageChunkElement[] {\n const root = element.closest('.ProseMirror')\n const elements = root?.querySelectorAll<PageChunkElement>(`${PAGE_CHUNK_TAG_NAME}[data-group=\"${group}\"]`)\n return Array.from(elements || [])\n}\n","import { getId } from '@ocavue/utils'\nimport { definePlugin, type Extension } from '@prosekit/core'\nimport type { Node } from '@prosekit/pm/model'\nimport { Plugin, PluginKey } from '@prosekit/pm/state'\nimport { Decoration, DecorationSet } from '@prosekit/pm/view'\n\nimport { PAGE_CHUNK_TAG_NAME, registerPageChunkElement } from './page-element.ts'\n\n/**\n * @public\n */\nexport interface PageRenderingOptions {\n /**\n * The width of the page in px.\n *\n * @default 794 (Portrait A4 paper size in 96 DPI)\n */\n pageWidth?: number\n\n /**\n * The height of the page in px.\n *\n * @default 1123 (Portrait A4 paper size in 96 DPI)\n */\n pageHeight?: number\n\n /**\n * The top margin of the page in px.\n *\n * @default 70\n */\n marginTop?: number\n\n /**\n * The right margin of the page in px.\n *\n * @default 70\n */\n marginRight?: number\n\n /**\n * The bottom margin of the page in px.\n *\n * @default 70\n */\n marginBottom?: number\n\n /**\n * The left margin of the page in px.\n *\n * @default 70\n */\n marginLeft?: number\n}\n\n/**\n * @public\n */\nexport function definePageRendering(options: PageRenderingOptions = {}): PageRenderingExtension {\n return definePlugin(\n createPageRenderingPlugin(options),\n )\n}\n\n/**\n * @internal\n */\nexport type PageRenderingExtension = Extension\n\nfunction createPageRenderingPlugin(options: PageRenderingOptions): Plugin {\n const {\n pageWidth = 794,\n pageHeight = 1123,\n marginTop = 70,\n marginRight = 70,\n marginBottom = 70,\n marginLeft = 70,\n } = options\n\n type PluginState = [group: string, decoration: DecorationSet]\n\n const key = new PluginKey<PluginState>('prosekit-page-render')\n\n function createDecorationSet(doc: Node, group: string): DecorationSet {\n const decorations: Decoration[] = []\n const totalCount = doc.childCount\n\n doc.forEach((node, pos, index) => {\n const isPageBreak: boolean | undefined = node.type.spec.pageBreak\n\n decorations.push(Decoration.node(pos, pos + node.nodeSize, {\n 'nodeName': PAGE_CHUNK_TAG_NAME,\n 'data-group': group,\n 'data-break': isPageBreak ? 'true' : undefined,\n 'data-h': String(pageHeight),\n 'data-mt': String(marginTop),\n 'data-mb': String(marginBottom),\n 'data-size': index === 0 ? String(totalCount) : undefined,\n }))\n })\n\n return DecorationSet.create(doc, decorations)\n }\n\n return new Plugin<PluginState>({\n key,\n view: () => {\n registerPageChunkElement()\n return {}\n },\n state: {\n init: (_config, state): PluginState => {\n const group = `page-group-${getId()}`\n const decoration = createDecorationSet(state.doc, group)\n return [group, decoration]\n },\n apply: (tr, value, oldState, newState): PluginState => {\n if (!tr.docChanged) return value\n\n const [group, decoration] = value\n\n let needRecreate = oldState.doc.childCount !== newState.doc.childCount\n\n if (!needRecreate) {\n const count = oldState.doc.childCount\n for (let i = 0; i < count; i++) {\n const oldNode = oldState.doc.child(i)\n const newNode = newState.doc.child(i)\n if (oldNode.type !== newNode.type) {\n needRecreate = true\n break\n }\n }\n }\n\n if (!needRecreate) {\n const mapped = decoration.map(tr.mapping, tr.doc, {\n onRemove: () => {\n needRecreate = true\n },\n })\n if (!needRecreate) {\n return [group, mapped]\n }\n }\n\n return [group, createDecorationSet(newState.doc, group)]\n },\n },\n props: {\n decorations: (state) => {\n return key.getState(state)?.[1]\n },\n attributes: {\n style: [\n `--page-margin-right:${marginRight}px;`,\n `--page-margin-left:${marginLeft}px;`,\n `--page-width:${pageWidth}px;`,\n `--page-height:${pageHeight}px;`,\n ].join(''),\n },\n },\n })\n}\n"],"mappings":";;;;;;;AAaA,MAAM,0BAAmC,OAAO,aAAsB;AACpE,KAAI,CAAC,SAAU,QAAO;CAEtB,MAAM,EAAE,QAAQ,OAAO;CAEvB,MAAM,OADO,YAAY,QAAQ,YAAY,CAC3B,eAAe;CACjC,MAAM,MAAM,GAAG,UAAU;CACzB,MAAM,QAAQ,IAAI,MAAM,SAAS,KAAK,KAAK,EAAE,GAAG,EAAE;AAClD,IAAG,aAAa,KAAK,KAAK,MAAM,CAAC,gBAAgB;AACjD,UAAS,GAAG;AACZ,QAAO;;;;;AAMT,SAAgB,kBAA2B;AACzC,QAAO;;;;;AAMT,SAAgB,0BAAsD;AACpE,QAAO,eAAe,EACH,iBAClB,CAAC;;;;;;;AC3BJ,SAAgB,wBAAkD;AAChE,QAAO,aAAa,EAClB,aAAa,iBAAiB,EAC/B,CAAC;;;;;;;ACAJ,SAAgB,sBAA8C;AAC5D,QAAO,eAAe;EACpB,MAAM;EACN,OAAO;EACP,YAAY;EACZ,UAAU,CAAC,EAAE,KAAK,2BAA2B,CAAC;EAC9C,QAAQ;AACN,UAAO;IAAC;IAAO,EAAE,OAAO,gDAAgD;IAAE,CAAC,KAAK;IAAC;;EAEnF,WAAW;EACZ,CAAC;;;;;;;ACTJ,SAAgB,kBAAsC;AACpD,QAAO,MACL,qBAAqB,EACrB,yBAAyB,EACzB,uBAAuB,CACxB;;;;;;;ACfH,MAAa,sBAAsB;;;;AAKnC,MAAa,2BAAyD,2BAAW;AAC/E,KAAI,OAAO,WAAW,eAAe,eAAe,IAAA,gBAAwB,CAAE;AAC9E,gBAAe,OAAO,qBAAqB,iBAAiB;EAC5D;AAEF,IAAM,mBAAN,cAA+B,YAAY;;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AM,CAAC;;GAE3D;EACD,OAAO;GACL,cAAc,UAAU;AACtB,WAAO,IAAI,SAAS,MAAM,GAAG;;GAE/B,YAAY,EACV,OAAO;IACL,uBAAuB,YAAY;IACnC,sBAAsB,WAAW;IACjC,gBAAgB,UAAU;IAC1B,iBAAiB,WAAW;IAC7B,CAAC,KAAK,GAAG,EACX;GACF;EACF,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-extensions-paragraph.d.ts","names":[],"sources":["../src/paragraph/paragraph-commands.ts","../src/paragraph/paragraph-keymap.ts","../src/paragraph/paragraph-spec.ts","../src/paragraph/paragraph.ts"],"mappings":";;;;;;;;KAMY,0BAAA,GAA6B,SAAA;EACvC,QAAA;IACE,YAAA;EAAA;AAAA;AAcJ;;;AAAA,iBAAgB,uBAAA,CAAA,GAA2B,0BAAA;;;;;;iBCf3B,qBAAA,CAAA,GAAyB,cAAA;;;;;;KCD7B,sBAAA,GAAyB,SAAA;EACnC,KAAA;IACE,SAAA,EAAW,KAAA;EAAA;AAAA;;;;;AFcf;iBELgB,mBAAA,CAAA,GAAuB,sBAAA;;;;;AFXvC;KGIY,kBAAA,GAAqB,KAAA,EAAO,sBAAA,EAAwB,0BAAA;;;;;;;;AHYhE;iBGFgB,eAAA,CAAA,GAAmB,kBAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-extensions-paragraph.js","names":[],"sources":["../src/paragraph/paragraph-commands.ts","../src/paragraph/paragraph-keymap.ts","../src/paragraph/paragraph-spec.ts","../src/paragraph/paragraph.ts"],"sourcesContent":["import { defineCommands, setBlockType, type Extension } from '@prosekit/core'\nimport type { Command } from '@prosekit/pm/state'\n\n/**\n * @internal\n */\nexport type ParagraphCommandsExtension = Extension<{\n Commands: {\n setParagraph: []\n }\n}>\n\n/**\n * @internal\n */\nexport function setParagraph(): Command {\n return setBlockType({ type: 'paragraph' })\n}\n\n/**\n * @internal\n */\nexport function defineParagraphCommands(): ParagraphCommandsExtension {\n return defineCommands({ setParagraph })\n}\n","import { defineKeymap, type PlainExtension } from '@prosekit/core'\n\nimport { setParagraph } from './paragraph-commands.ts'\n\n/**\n * @internal\n */\nexport function defineParagraphKeymap(): PlainExtension {\n return defineKeymap({\n 'Mod-Alt-0': setParagraph(),\n })\n}\n","import { defineNodeSpec, type Extension } from '@prosekit/core'\nimport type { Attrs } from '@prosekit/pm/model'\n\n/**\n * @internal\n */\nexport type ParagraphSpecExtension = Extension<{\n Nodes: {\n paragraph: Attrs\n }\n}>\n\n/**\n * @internal\n *\n * Defines a paragraph node spec.\n */\nexport function defineParagraphSpec(): ParagraphSpecExtension {\n return defineNodeSpec({\n name: 'paragraph',\n content: 'inline*',\n group: 'block',\n parseDOM: [{ tag: 'p' }],\n toDOM() {\n return ['p', 0]\n },\n })\n}\n","import type { Priority } from '@prosekit/core'\nimport { union, withPriority, type Union } from '@prosekit/core'\n\nimport { defineParagraphCommands, type ParagraphCommandsExtension } from './paragraph-commands.ts'\nimport { defineParagraphKeymap } from './paragraph-keymap.ts'\nimport { defineParagraphSpec, type ParagraphSpecExtension } from './paragraph-spec.ts'\n\n/**\n * @internal\n */\nexport type ParagraphExtension = Union<[ParagraphSpecExtension, ParagraphCommandsExtension]>\n\n/**\n * @public\n *\n * Defines a paragraph node.\n *\n * The paragraph node spec has the highest priority, because it should be the\n * default block node for most cases.\n */\nexport function defineParagraph(): ParagraphExtension {\n return union(\n withPriority(defineParagraphSpec(), 4 satisfies typeof Priority.highest),\n defineParagraphCommands(),\n defineParagraphKeymap(),\n )\n}\n"],"mappings":";;;;;AAeA,SAAgB,eAAwB;AACtC,QAAO,aAAa,EAAE,MAAM,aAAa,CAAC;;;;;AAM5C,SAAgB,0BAAsD;AACpE,QAAO,eAAe,EAAE,cAAc,CAAC;;;;;;;AChBzC,SAAgB,wBAAwC;AACtD,QAAO,aAAa,EAClB,aAAa,cAAc,EAC5B,CAAC;;;;;;;;;ACOJ,SAAgB,sBAA8C;AAC5D,QAAO,eAAe;EACpB,MAAM;EACN,SAAS;EACT,OAAO;EACP,UAAU,CAAC,EAAE,KAAK,KAAK,CAAC;EACxB,QAAQ;AACN,UAAO,CAAC,KAAK,EAAE;;EAElB,CAAC;;;;;;;;;;;;ACNJ,SAAgB,kBAAsC;AACpD,QAAO,MACL,aAAa,qBAAqB,EAAE,EAAoC,EACxE,yBAAyB,EACzB,uBAAuB,CACxB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-extensions-paste-rule.d.ts","names":[],"sources":["../src/paste-rule/mark-paste-rule.ts","../src/paste-rule/paste-rule.ts"],"mappings":";;;;;;;;AAYA;;UAAiB,oBAAA;EAKR;;;;EAAP,KAAA,EAAO,MAAA;EAmB4B;;;EAdnC,IAAA,WAAe,QAAA;EAAf;;;;;;EAQA,QAAA,IAAY,KAAA,EAAO,eAAA,KAAoB,KAAA;EAMnB;;;;EAApB,UAAA,IAAc,IAAA,EAAM,eAAA;AAAA;;;;;;iBAQN,mBAAA,CAAoB,OAAA,EAAS,oBAAA,GAAuB,cAAA;;;;;AAhCpE;;;UCDiB,uBAAA;EDWA;;;ECPf,KAAA,EAAO,KAAA;EDqB4B;;;EChBnC,IAAA,EAAM,UAAA;EDEN;;;;ECIA,KAAA;AAAA;;;;;;ADkBF;KCTY,gBAAA,IAAoB,OAAA,EAAS,uBAAA,KAA4B,KAAA;;;;;;UAOpD,gBAAA;EDEiE;;;ECEhF,OAAA,EAAS,gBAAA;AAAA;;;;;;;;;iBAWK,eAAA,CAAA;EAAkB;AAAA,GAAW,gBAAA,GAAmB,cAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-extensions-placeholder.d.ts","names":[],"sources":["../src/placeholder/index.ts"],"mappings":";;;;UAOiB,kBAAA;;AAAjB;;;EAKE,WAAA,aAAwB,KAAA,EAAO,WAAA;EAA/B;;;;;;;;AAuBF;;;;;;EAPE,QAAA,uBAA+B,KAAA,EAAO,WAAA;AAAA;;;;;iBAOxB,iBAAA,CAAkB,OAAA,EAAS,kBAAA,GAAqB,cAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-extensions-placeholder.js","names":[],"sources":["../src/placeholder/index.ts"],"sourcesContent":["import { definePlugin, isInCodeBlock, isTextSelection, maybeRun, type PlainExtension } from '@prosekit/core'\nimport type { ProseMirrorNode } from '@prosekit/pm/model'\nimport { Plugin, PluginKey, type EditorState } from '@prosekit/pm/state'\nimport { Decoration, DecorationSet } from '@prosekit/pm/view'\n\nimport { findTable } from '../table/index.ts'\n\nexport interface PlaceholderOptions {\n /**\n * The placeholder to use. It can be a static string or a function that\n * receives the current editor state and returns a string.\n */\n placeholder: string | ((state: EditorState) => string)\n\n /**\n * By default, the placeholder text will be shown whenever the current text\n * cursor is in an empty text node and it's not inside a code block or a\n * table node.\n *\n * If you only want to show the placeholder when the whole doc is empty, you\n * can set this option to 'doc'.\n *\n * You can also pass a function that receives the current editor state and\n * returns a boolean value to determine whether the placeholder should be\n * shown.\n *\n * @default 'block'\n */\n strategy?: 'doc' | 'block' | ((state: EditorState) => boolean)\n}\n\n/**\n * Add a placeholder text to the editor when the current block or document is\n * empty.\n */\nexport function definePlaceholder(options: PlaceholderOptions): PlainExtension {\n return definePlugin(createPlaceholderPlugin(options))\n}\n\nfunction createPlaceholderPlugin({\n placeholder,\n strategy = 'block',\n}: PlaceholderOptions): Plugin {\n return new Plugin({\n key: new PluginKey('prosekit-placeholder'),\n props: {\n decorations: (state) => {\n const strategyFn = typeof strategy === 'function'\n ? strategy\n : strategy === 'doc'\n ? docStrategy\n : defaultStrategy\n\n if (!strategyFn(state)) {\n return null\n }\n\n const placeholderText: string = maybeRun(placeholder, state)\n const deco = createPlaceholderDecoration(state, placeholderText)\n if (!deco) {\n return null\n }\n\n return DecorationSet.create(state.doc, [deco])\n },\n },\n })\n}\n\nfunction defaultStrategy(state: EditorState): boolean {\n return !isInCodeBlock(state.selection) && !findTable(state.selection.$from)\n}\n\nfunction docStrategy(state: EditorState): boolean {\n return isDocEmpty(state.doc) && defaultStrategy(state)\n}\n\nfunction isDocEmpty(doc: ProseMirrorNode) {\n return doc.childCount <= 1 && !doc.firstChild?.content.size\n}\n\nfunction createPlaceholderDecoration(\n state: EditorState,\n placeholderText: string,\n): Decoration | null {\n if (!placeholderText) return null\n\n const { selection } = state\n if (!selection.empty || !isTextSelection(selection)) return null\n\n const $pos = selection.$anchor\n const node = $pos.parent\n if (node.content.size > 0) return null\n\n const before = $pos.before()\n\n return Decoration.node(before, before + node.nodeSize, {\n 'class': 'prosekit-placeholder',\n 'data-placeholder': placeholderText,\n })\n}\n"],"mappings":";;;;;;;;;AAmCA,SAAgB,kBAAkB,SAA6C;AAC7E,QAAO,aAAa,wBAAwB,QAAQ,CAAC;;AAGvD,SAAS,wBAAwB,EAC/B,aACA,WAAW,WACkB;AAC7B,QAAO,IAAI,OAAO;EAChB,KAAK,IAAI,UAAU,uBAAuB;EAC1C,OAAO,EACL,cAAc,UAAU;AAOtB,OAAI,EANe,OAAO,aAAa,aACnC,WACA,aAAa,QACb,cACA,iBAEY,MAAM,CACpB,QAAO;GAIT,MAAM,OAAO,4BAA4B,OADT,SAAS,aAAa,MAAM,CACI;AAChE,OAAI,CAAC,KACH,QAAO;AAGT,UAAO,cAAc,OAAO,MAAM,KAAK,CAAC,KAAK,CAAC;KAEjD;EACF,CAAC;;AAGJ,SAAS,gBAAgB,OAA6B;AACpD,QAAO,CAAC,cAAc,MAAM,UAAU,IAAI,CAAC,UAAU,MAAM,UAAU,MAAM;;AAG7E,SAAS,YAAY,OAA6B;AAChD,QAAO,WAAW,MAAM,IAAI,IAAI,gBAAgB,MAAM;;AAGxD,SAAS,WAAW,KAAsB;AACxC,QAAO,IAAI,cAAc,KAAK,CAAC,IAAI,YAAY,QAAQ;;AAGzD,SAAS,4BACP,OACA,iBACmB;AACnB,KAAI,CAAC,gBAAiB,QAAO;CAE7B,MAAM,EAAE,cAAc;AACtB,KAAI,CAAC,UAAU,SAAS,CAAC,gBAAgB,UAAU,CAAE,QAAO;CAE5D,MAAM,OAAO,UAAU;CACvB,MAAM,OAAO,KAAK;AAClB,KAAI,KAAK,QAAQ,OAAO,EAAG,QAAO;CAElC,MAAM,SAAS,KAAK,QAAQ;AAE5B,QAAO,WAAW,KAAK,QAAQ,SAAS,KAAK,UAAU;EACrD,SAAS;EACT,oBAAoB;EACrB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-extensions-readonly.d.ts","names":[],"sources":["../src/readonly/index.ts"],"mappings":";;;;;AAMA;iBAAgB,cAAA,CAAA,GAAkB,cAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-extensions-readonly.js","names":[],"sources":["../src/readonly/index.ts"],"sourcesContent":["import { definePlugin, type PlainExtension } from '@prosekit/core'\nimport { PluginKey, ProseMirrorPlugin } from '@prosekit/pm/state'\n\n/**\n * Make the editor read-only.\n */\nexport function defineReadonly(): PlainExtension {\n return definePlugin(plugin)\n}\n\nconst plugin = new ProseMirrorPlugin({\n key: new PluginKey('prosekey-readonly'),\n props: {\n editable: () => false,\n },\n})\n"],"mappings":";;;;;;AAMA,SAAgB,iBAAiC;AAC/C,QAAO,aAAa,OAAO;;AAG7B,MAAM,SAAS,IAAI,kBAAkB;CACnC,KAAK,IAAI,UAAU,oBAAoB;CACvC,OAAO,EACL,gBAAgB,OACjB;CACF,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-extensions-search.d.ts","names":[],"sources":["../src/search/index.ts"],"mappings":";;;;;AAqBA;;;UAAiB,kBAAA;EAIf;;;EAAA,MAAA;EA4BA;;;EAvBA,OAAA;EAsCc;;;;;EA/Bd,aAAA;EA+B8D;;;AAqChE;;;;EA3DE,OAAA;EA4DA;;;;;EArDA,MAAA;EA2DE;;;;;EApDF,SAAA;AAAA;;;;;;iBAQc,iBAAA,CAAkB,OAAA,EAAS,kBAAA,GAAqB,cAAA;;;;KAqCpD,uBAAA,GAA0B,SAAA;EACpC,QAAA;IACE,QAAA;IACA,QAAA;IACA,cAAA;IACA,cAAA;IACA,WAAA;IACA,iBAAA;IACA,cAAA;IACA,UAAA;EAAA;AAAA;;;;;;iBASY,oBAAA,CAAA,GAAwB,uBAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-extensions-search.js","names":[],"sources":["../src/search/index.ts"],"sourcesContent":["import { defineCommands, definePlugin, type Extension, type PlainExtension } from '@prosekit/core'\nimport type { Command } from '@prosekit/pm/state'\nimport type { EditorView } from '@prosekit/pm/view'\nimport {\n findNext,\n findNextNoWrap,\n findPrev,\n findPrevNoWrap,\n replaceAll,\n replaceCurrent,\n replaceNext,\n replaceNextNoWrap,\n search,\n SearchQuery,\n} from 'prosemirror-search'\n\n/**\n * Options for {@link defineSearchQuery}\n *\n * @public\n */\nexport interface SearchQueryOptions {\n /**\n * The search string (or regular expression).\n */\n search: string\n\n /**\n * The replace text.\n */\n replace?: string\n\n /**\n * Indicates whether the search is case-sensitive\n *\n * @default false\n */\n caseSensitive?: boolean\n\n /**\n * By default, string search will replace `\\n`, `\\r`, and `\\t` in the query\n * with newline, return, and tab characters. When this is set to true, that\n * behavior is disabled.\n *\n * @default false\n */\n literal?: boolean\n\n /**\n * When true, the search string is interpreted as a regular expression.\n *\n * @default false\n */\n regexp?: boolean\n\n /**\n * Enable whole-word matching.\n *\n * @default false\n */\n wholeWord?: boolean\n}\n\n/**\n * Defines an extension that stores a current search query and replace string.\n *\n * @public\n */\nexport function defineSearchQuery(options: SearchQueryOptions): PlainExtension {\n const query = new SearchQuery(options)\n return definePlugin(search({ initialQuery: query }))\n}\n\n/**\n * Scrolls the active search match into view.\n */\nfunction scrollActiveIntoView(view: EditorView) {\n if (view.isDestroyed) return\n const active = view.dom.querySelector('.ProseMirror-active-search-match')\n active?.scrollIntoView({\n block: 'nearest',\n inline: 'nearest',\n behavior: 'smooth',\n })\n}\n\n/**\n * Wraps a command and scrolls the active search match into view when the command\n * is applied.\n */\nfunction withScrollActiveIntoView(command: Command): Command {\n return (state, dispatch, view) => {\n const result = command(state, dispatch, view)\n if (result && dispatch && view) {\n // Add a small delay because the command itself will handle scrolling if\n // the view is focused.\n setTimeout(() => scrollActiveIntoView(view), 50)\n }\n return result\n }\n}\n\n/**\n * @internal\n */\nexport type SearchCommandsExtension = Extension<{\n Commands: {\n findNext: []\n findPrev: []\n findNextNoWrap: []\n findPrevNoWrap: []\n replaceNext: []\n replaceNextNoWrap: []\n replaceCurrent: []\n replaceAll: []\n }\n}>\n\n/**\n * Defines commands for search and replace.\n *\n * @public\n */\nexport function defineSearchCommands(): SearchCommandsExtension {\n return defineCommands({\n findNext: () => withScrollActiveIntoView(findNext),\n findPrev: () => withScrollActiveIntoView(findPrev),\n findNextNoWrap: () => withScrollActiveIntoView(findNextNoWrap),\n findPrevNoWrap: () => withScrollActiveIntoView(findPrevNoWrap),\n replaceNext: () => withScrollActiveIntoView(replaceNext),\n replaceNextNoWrap: () => withScrollActiveIntoView(replaceNextNoWrap),\n replaceCurrent: () => withScrollActiveIntoView(replaceCurrent),\n replaceAll: () => withScrollActiveIntoView(replaceAll),\n })\n}\n"],"mappings":";;;;;;;;AAoEA,SAAgB,kBAAkB,SAA6C;AAE7E,QAAO,aAAa,OAAO,EAAE,cADf,IAAI,YAAY,QAAQ,EACY,CAAC,CAAC;;;;;AAMtD,SAAS,qBAAqB,MAAkB;AAC9C,KAAI,KAAK,YAAa;AACP,MAAK,IAAI,cAAc,mCAAmC,EACjE,eAAe;EACrB,OAAO;EACP,QAAQ;EACR,UAAU;EACX,CAAC;;;;;;AAOJ,SAAS,yBAAyB,SAA2B;AAC3D,SAAQ,OAAO,UAAU,SAAS;EAChC,MAAM,SAAS,QAAQ,OAAO,UAAU,KAAK;AAC7C,MAAI,UAAU,YAAY,KAGxB,kBAAiB,qBAAqB,KAAK,EAAE,GAAG;AAElD,SAAO;;;;;;;;AAyBX,SAAgB,uBAAgD;AAC9D,QAAO,eAAe;EACpB,gBAAgB,yBAAyB,SAAS;EAClD,gBAAgB,yBAAyB,SAAS;EAClD,sBAAsB,yBAAyB,eAAe;EAC9D,sBAAsB,yBAAyB,eAAe;EAC9D,mBAAmB,yBAAyB,YAAY;EACxD,yBAAyB,yBAAyB,kBAAkB;EACpE,sBAAsB,yBAAyB,eAAe;EAC9D,kBAAkB,yBAAyB,WAAW;EACvD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-extensions-strike.d.ts","names":[],"sources":["../src/strike/index.ts"],"mappings":";;;;;;AAkBA;KAAY,mBAAA,GAAsB,SAAA;EAChC,KAAA;IACE,MAAA,EAAQ,KAAA;EAAA;AAAA;;;;iBAOI,gBAAA,CAAA,GAAoB,mBAAA;AAApC;;;AAAA,KAmBY,uBAAA,GAA0B,SAAA;EACpC,QAAA;IACE,YAAA;EAAA;AAAA;;;;iBAOY,oBAAA,CAAA,GAAwB,uBAAA;;;AAAxC;iBASgB,kBAAA,CAAA,GAAsB,cAAA;;;;iBAUtB,qBAAA,CAAA,GAAyB,cAAA;;;;KAY7B,eAAA,GAAkB,KAAA,EAC3B,mBAAA,EAAqB,uBAAA;;;AADxB;iBAOgB,YAAA,CAAA,GAAgB,eAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-extensions-strike.js","names":[],"sources":["../src/strike/index.ts"],"sourcesContent":["import {\n canUseRegexLookbehind,\n defineCommands,\n defineKeymap,\n defineMarkSpec,\n toggleMark,\n union,\n type Extension,\n type PlainExtension,\n type Union,\n} from '@prosekit/core'\nimport type { Attrs } from '@prosekit/pm/model'\n\nimport { defineMarkInputRule } from '../input-rule/index.ts'\n\n/**\n * @internal\n */\nexport type StrikeSpecExtension = Extension<{\n Marks: {\n strike: Attrs\n }\n}>\n\n/**\n * @internal\n */\nexport function defineStrikeSpec(): StrikeSpecExtension {\n return defineMarkSpec({\n name: 'strike',\n parseDOM: [\n { tag: 's' },\n { tag: 'strike' },\n { tag: 'del' },\n { style: 'text-decoration=line-through' },\n { style: 'text-decoration-line=line-through' },\n ],\n toDOM() {\n return ['s', 0]\n },\n })\n}\n\n/**\n * @internal\n */\nexport type StrikeCommandsExtension = Extension<{\n Commands: {\n toggleStrike: []\n }\n}>\n\n/**\n * @internal\n */\nexport function defineStrikeCommands(): StrikeCommandsExtension {\n return defineCommands({\n toggleStrike: () => toggleMark({ type: 'strike' }),\n })\n}\n\n/**\n * @internal\n */\nexport function defineStrikeKeymap(): PlainExtension {\n return defineKeymap({\n 'Mod-S': toggleMark({ type: 'strike' }),\n 'Mod-X': toggleMark({ type: 'strike' }),\n })\n}\n\n/**\n * @internal\n */\nexport function defineStrikeInputRule(): PlainExtension {\n return defineMarkInputRule({\n regex: canUseRegexLookbehind()\n ? /(?<=\\s|^)~~([^\\s~]|[^\\s~][^~]*[^\\s~])~~$/\n : /~~([^\\s~]|[^\\s~][^~]*[^\\s~])~~$/,\n type: 'strike',\n })\n}\n\n/**\n * @internal\n */\nexport type StrikeExtension = Union<\n [StrikeSpecExtension, StrikeCommandsExtension]\n>\n\n/**\n * @public\n */\nexport function defineStrike(): StrikeExtension {\n return union(\n defineStrikeSpec(),\n defineStrikeCommands(),\n defineStrikeKeymap(),\n defineStrikeInputRule(),\n )\n}\n"],"mappings":";;;;;;AA2BA,SAAgB,mBAAwC;AACtD,QAAO,eAAe;EACpB,MAAM;EACN,UAAU;GACR,EAAE,KAAK,KAAK;GACZ,EAAE,KAAK,UAAU;GACjB,EAAE,KAAK,OAAO;GACd,EAAE,OAAO,gCAAgC;GACzC,EAAE,OAAO,qCAAqC;GAC/C;EACD,QAAQ;AACN,UAAO,CAAC,KAAK,EAAE;;EAElB,CAAC;;;;;AAeJ,SAAgB,uBAAgD;AAC9D,QAAO,eAAe,EACpB,oBAAoB,WAAW,EAAE,MAAM,UAAU,CAAC,EACnD,CAAC;;;;;AAMJ,SAAgB,qBAAqC;AACnD,QAAO,aAAa;EAClB,SAAS,WAAW,EAAE,MAAM,UAAU,CAAC;EACvC,SAAS,WAAW,EAAE,MAAM,UAAU,CAAC;EACxC,CAAC;;;;;AAMJ,SAAgB,wBAAwC;AACtD,QAAO,oBAAoB;EACzB,OAAO,uBAAuB,GAC1B,6CACA;EACJ,MAAM;EACP,CAAC;;;;;AAaJ,SAAgB,eAAgC;AAC9C,QAAO,MACL,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,EACpB,uBAAuB,CACxB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-extensions-table.d.ts","names":[],"sources":["../src/table/table-commands/insert-table.ts","../src/table/table-commands/select-table-cell.ts","../src/table/table-commands/select-table-column.ts","../src/table/table-commands/select-table-row.ts","../src/table/table-commands/select-table.ts","../src/table/table-commands.ts","../src/table/table-commands/exit-table.ts","../src/table/table-drop-indicator.ts","../src/table/table-plugins.ts","../src/table/table-spec.ts","../src/table/table-utils.ts","../src/table/table.ts"],"mappings":";;;;;;;;;UA2CiB,kBAAA;;AAAjB;;EAIE,GAAA;EAJiC;;;EASjC,GAAA;EAOM;;AAWR;;;EAXE,MAAA;AAAA;;;;;;;;ACnDF;iBD8DgB,WAAA,CAAY,OAAA,EAAS,kBAAA,GAAqB,OAAA;;;;;;UC9DzC,sBAAA;;ADmCjB;;;EC9BE,GAAA;AAAA;;;;iBAMc,eAAA,CAAgB,OAAA,GAAU,sBAAA,GAAyB,OAAA;;;;;;UCXlD,wBAAA;;AFmCjB;;;EE9BE,MAAA;EFkCA;;;;EE5BA,IAAA;AAAA;;;;iBAMc,iBAAA,CAAkB,OAAA,GAAU,wBAAA,GAA2B,OAAA;;;;;;UCjBtD,qBAAA;;AHmCjB;;;EG9BE,MAAA;EHkCA;;;;EG5BA,IAAA;AAAA;;;;iBAMc,cAAA,CAAe,OAAA,GAAU,qBAAA,GA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AiB,SAAA;EAAA;AAAA;AAAA,iBAIL,yBAAA,CAAA,GAA6B,4BAAA;;;;;;;ATrD7C;iBUlCgB,eAAA,CAAgB,KAAA,YAAiB,KAAA,IAAS,aAAA;;;;;;KCU9C,cAAA,GAAiB,KAAA,EAEzB,kBAAA,EACA,qBAAA,EACA,sBAAA,EACA,4BAAA,EACA,sBAAA;;;AX6CJ;iBWtCgB,WAAA,CAAA,GAAe,cAAA"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { _ as insertTable, a as defineTableSpec, c as defineTableCommands, d as selectTableColumn, f as selectTableCell, g as moveTableColumn, h as moveTableRow, i as defineTableRowSpec, l as selectTable, m as isCellSelection, n as defineTableCellSpec, o as defineTablePlugins, p as findTable, r as defineTableHeaderCellSpec, s as defineTableDropIndicator, t as defineTable, u as selectTableRow, v as exitTable } from "./table.js";
|
|
2
|
-
export { defineTable, defineTableCellSpec, defineTableCommands, defineTableDropIndicator, defineTableHeaderCellSpec, defineTablePlugins, defineTableRowSpec, defineTableSpec, exitTable, findTable, insertTable, isCellSelection, moveTableColumn, moveTableRow, selectTable, selectTableCell, selectTableColumn, selectTableRow };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-extensions-text-align.d.ts","names":[],"sources":["../src/text-align/index.ts"],"mappings":";;;;;;AAeA;UAAiB,gBAAA;EAAgB;;;;;;;EAQ/B,KAAA,EAAO,QAAA;EA6BG;;;;;EAtBV,OAAA;AAAA;;;;KAsBU,uBAAA,4BAAmD,SAAA;EAC7D,KAAA,UAAe,QAAA;IAAa,SAAA;EAAA;AAAA;;;;iBAgBd,YAAA,CAAA;EACd,KAAA;EACA;AAAA;EAEA,KAAA;EACA,KAAA;AAAA,IACE,OAAA;;;;KAOQ,0BAAA,GAA6B,SAAA;EACvC,QAAA;IACE,YAAA,GAAe,KAAA;EAAA;AAAA;;;;iBAOH,uBAAA,CACd,KAAA,aACC,0BAAA;;;;iBASa,qBAAA,CAAsB,KAAA,aAAkB,cAAA;;;;KAY5C,kBAAA,4BAA8C,KAAA,EACvD,uBAAA,CAAwB,QAAA,GAAW,0BAAA;;;AADtC;;;;iBAUgB,eAAA,kCAAA,CACd,OAAA,EAAS,gBAAA,CAAiB,QAAA,IACzB,kBAAA,CAAmB,QAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-extensions-text-align.js","names":[],"sources":["../src/text-align/index.ts"],"sourcesContent":["import {\n defineCommands,\n defineKeymap,\n defineNodeAttr,\n setNodeAttrsBetween,\n union,\n type Extension,\n type PlainExtension,\n type Union,\n} from '@prosekit/core'\nimport type { Command } from '@prosekit/pm/state'\n\n/**\n * @public\n */\nexport interface TextAlignOptions<NodeName extends string = string> {\n /**\n * The names of node to add the attribute to.\n *\n * @example\n *\n * [\"paragraph\", \"heading\"]\n */\n types: NodeName[]\n\n /**\n * The default value for the attribute.\n *\n * @default \"left\"\n */\n default?: string\n}\n\nfunction defineTextAlignAttr<NodeName extends string>(\n type: NodeName,\n defaultValue: string | null,\n) {\n return defineNodeAttr<NodeName, 'textAlign', string | null>({\n type,\n attr: 'textAlign',\n default: defaultValue,\n splittable: true,\n toDOM: (value: any) => (value ? ['style', `text-align:${value};`] : null),\n parseDOM: (node: HTMLElement) => {\n return node.style.getPropertyValue('text-align') || null\n },\n })\n}\n\n/**\n * @internal\n */\nexport type TextAlignAttrsExtension<NodeName extends string> = Extension<{\n Nodes: { [K in NodeName]: { textAlign: string | null } }\n}>\n\n/**\n * @internal\n */\nfunction defineTextAlignAttrs<NodeName extends string>(\n types: NodeName[],\n defaultValue: string | null,\n): TextAlignAttrsExtension<NodeName> {\n return union(types.map((type) => defineTextAlignAttr(type, defaultValue)))\n}\n\n/**\n * @internal\n */\nexport function setTextAlign({\n types,\n value,\n}: {\n types: string[]\n value: string | null\n}): Command {\n return setNodeAttrsBetween({ type: types, attrs: { textAlign: value } })\n}\n\n/**\n * @internal\n */\nexport type TextAlignCommandsExtension = Extension<{\n Commands: {\n setTextAlign: [value: string | null]\n }\n}>\n\n/**\n * @internal\n */\nexport function defineTextAlignCommands(\n types: string[],\n): TextAlignCommandsExtension {\n return defineCommands({\n setTextAlign: (value: string | null) => setTextAlign({ types, value }),\n })\n}\n\n/**\n * @internal\n */\nexport function defineTextAlignKeymap(types: string[]): PlainExtension {\n return defineKeymap({\n 'Mod-L': setTextAlign({ types, value: 'left' }),\n 'Mod-E': setTextAlign({ types, value: 'center' }),\n 'Mod-R': setTextAlign({ types, value: 'right' }),\n 'Mod-J': setTextAlign({ types, value: 'justify' }),\n })\n}\n\n/**\n * @internal\n */\nexport type TextAlignExtension<NodeName extends string> = Union<\n [TextAlignAttrsExtension<NodeName>, TextAlignCommandsExtension]\n>\n\n/**\n * Adds a `textAlign` attribute to the specified nodes. This will be rendered as\n * a CSS `text-align` style.\n *\n * @public\n */\nexport function defineTextAlign<NodeName extends string = string>(\n options: TextAlignOptions<NodeName>,\n): TextAlignExtension<NodeName> {\n return union(\n defineTextAlignAttrs<NodeName>(options.types, options.default || 'left'),\n defineTextAlignKeymap(options.types),\n defineTextAlignCommands(options.types),\n )\n}\n"],"mappings":";;AAiCA,SAAS,oBACP,MACA,cACA;AACA,QAAO,eAAqD;EAC1D;EACA,MAAM;EACN,SAAS;EACT,YAAY;EACZ,QAAQ,UAAgB,QAAQ,CAAC,SAAS,cAAc,MAAM,GAAG,GAAG;EACpE,WAAW,SAAsB;AAC/B,UAAO,KAAK,MAAM,iBAAiB,aAAa,IAAI;;EAEvD,CAAC;;;;;AAaJ,SAAS,qBACP,OACA,cACmC;AACnC,QAAO,MAAM,MAAM,KAAK,SAAS,oBAAoB,MAAM,aAAa,CAAC,CAAC;;;;;AAM5E,SAAgB,aAAa,EAC3B,OACA,SAIU;AACV,QAAO,oBAAoB;EAAE,MAAM;EAAO,OAAO,EAAE,WAAW,OAAO;EAAE,CAAC;;;;;AAe1E,SAAgB,wBACd,OAC4B;AAC5B,QAAO,eAAe,EACpB,eAAe,UAAyB,aAAa;EAAE;EAAO;EAAO,CAAC,EACvE,CAAC;;;;;AAMJ,SAAgB,sBAAsB,OAAiC;AACrE,QAAO,aAAa;EAClB,SAAS,aAAa;GAAE;GAAO,OAAO;GAAQ,CAAC;EAC/C,SAAS,aAAa;GAAE;GAAO,OAAO;GAAU,CAAC;EACjD,SAAS,aAAa;GAAE;GAAO,OAAO;GAAS,CAAC;EAChD,SAAS,aAAa;GAAE;GAAO,OAAO;GAAW,CAAC;EACnD,CAAC;;;;;;;;AAgBJ,SAAgB,gBACd,SAC8B;AAC9B,QAAO,MACL,qBAA+B,QAAQ,OAAO,QAAQ,WAAW,OAAO,EACxE,sBAAsB,QAAQ,MAAM,EACpC,wBAAwB,QAAQ,MAAM,CACvC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-extensions-text-color.d.ts","names":[],"sources":["../src/text-color/text-color-spec.ts","../src/text-color/text-color-commands.ts","../src/text-color/text-color.ts"],"mappings":";;;;;;;AAOA;;UAAiB,cAAA;EACf,KAAA;AAAA;AAMF;;;AAAA,KAAY,sBAAA,GAAyB,SAAA;EACnC,KAAA;IACE,SAAA,EAAW,cAAA;EAAA;AAAA;;;AAOf;iBAAgB,mBAAA,CAAA,GAAuB,sBAAA;;;;AAhBvC;;iBCCgB,YAAA,CAAa,KAAA,EAAO,cAAA,GAAiB,OAAA;;;ADMrD;iBCCgB,eAAA,CAAA,GAAmB,OAAA;;;;KAOvB,0BAAA,GAA6B,SAAA;EACvC,QAAA;IACE,YAAA,GAAe,KAAA,EAAO,cAAA;IACtB,eAAA;EAAA;AAAA;;;;iBAOY,uBAAA,CAAA,GAA2B,0BAAA;;;;ADzB3C;;KECY,kBAAA,GAAqB,KAAA,EAAO,sBAAA,EAAwB,0BAAA;;;AFMhE;;;iBECgB,eAAA,CAAA,GAAmB,kBAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-extensions-text-color.js","names":[],"sources":["../src/text-color/text-color-commands.ts","../src/text-color/text-color-spec.ts","../src/text-color/text-color.ts"],"sourcesContent":["import { addMark, defineCommands, removeMark, type Extension } from '@prosekit/core'\nimport type { Command } from '@prosekit/pm/state'\n\nimport type { TextColorAttrs } from './text-color-spec.ts'\n\n/**\n * @internal\n */\nexport function addTextColor(attrs: TextColorAttrs): Command {\n return addMark({ type: 'textColor', attrs })\n}\n\n/**\n * @internal\n */\nexport function removeTextColor(): Command {\n return removeMark({ type: 'textColor' })\n}\n\n/**\n * @internal\n */\nexport type TextColorCommandsExtension = Extension<{\n Commands: {\n addTextColor: [attrs: TextColorAttrs]\n removeTextColor: []\n }\n}>\n\n/**\n * @internal\n */\nexport function defineTextColorCommands(): TextColorCommandsExtension {\n return defineCommands({ addTextColor, removeTextColor })\n}\n","import { defineMarkSpec, type Extension } from '@prosekit/core'\n\n/**\n * Attributes for the `textColor` mark.\n *\n * @public\n */\nexport interface TextColorAttrs {\n color: string\n}\n\n/**\n * @internal\n */\nexport type TextColorSpecExtension = Extension<{\n Marks: {\n textColor: TextColorAttrs\n }\n}>\n\n/**\n * @internal\n */\nexport function defineTextColorSpec(): TextColorSpecExtension {\n return defineMarkSpec<'textColor', TextColorAttrs>({\n name: 'textColor',\n attrs: {\n color: {\n validate: 'string',\n },\n },\n parseDOM: [\n {\n tag: ':where([style*=\"color:\"], [data-text-color])',\n getAttrs: (node): TextColorAttrs | false => {\n // When both `data-text-color` and `style=\"color\"` are present, we\n // prioritize the `data-text-color` attribute. This avoids the\n // browser's default behavior of changing hex colors to rgba in style\n // attribute.\n const value = node.getAttribute('data-text-color')\n if (value && value !== 'inherit') {\n return { color: value }\n }\n const color = node.style.color\n if (color && color !== 'inherit') {\n return { color }\n }\n return false\n },\n consuming: false,\n },\n ],\n toDOM(mark) {\n const color = (mark.attrs as TextColorAttrs).color\n return ['span', { 'style': `color: ${color};`, 'data-text-color': color }, 0]\n },\n })\n}\n","import { union, type Union } from '@prosekit/core'\n\nimport { defineTextColorCommands, type TextColorCommandsExtension } from './text-color-commands.ts'\nimport { defineTextColorSpec, type TextColorSpecExtension } from './text-color-spec.ts'\n\n/**\n * @internal\n */\nexport type TextColorExtension = Union<[TextColorSpecExtension, TextColorCommandsExtension]>\n\n/**\n * Defines the `textColor` mark and some commands for it.\n *\n * @public\n */\nexport function defineTextColor(): TextColorExtension {\n return union(\n defineTextColorSpec(),\n defineTextColorCommands(),\n )\n}\n"],"mappings":";;;;;AAQA,SAAgB,aAAa,OAAgC;AAC3D,QAAO,QAAQ;EAAE,MAAM;EAAa;EAAO,CAAC;;;;;AAM9C,SAAgB,kBAA2B;AACzC,QAAO,WAAW,EAAE,MAAM,aAAa,CAAC;;;;;AAgB1C,SAAgB,0BAAsD;AACpE,QAAO,eAAe;EAAE;EAAc;EAAiB,CAAC;;;;;;;ACV1D,SAAgB,sBAA8C;AAC5D,QAAO,eAA4C;EACjD,MAAM;EACN,OAAO,EACL,OAAO,EACL,UAAU,UACX,EACF;EACD,UAAU,CACR;GACE,KAAK;GACL,WAAW,SAAiC;IAK1C,MAAM,QAAQ,KAAK,aAAa,kBAAkB;AAClD,QAAI,SAAS,UAAU,UACrB,QAAO,EAAE,OAAO,OAAO;IAEzB,MAAM,QAAQ,KAAK,MAAM;AACzB,QAAI,SAAS,UAAU,UACrB,QAAO,EAAE,OAAO;AAElB,WAAO;;GAET,WAAW;GACZ,CACF;EACD,MAAM,MAAM;GACV,MAAM,QAAS,KAAK,MAAyB;AAC7C,UAAO;IAAC;IAAQ;KAAE,SAAS,UAAU,MAAM;KAAI,mBAAmB;KAAO;IAAE;IAAE;;EAEhF,CAAC;;;;;;;;;ACzCJ,SAAgB,kBAAsC;AACpD,QAAO,MACL,qBAAqB,EACrB,yBAAyB,CAC1B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-extensions-text.d.ts","names":[],"sources":["../src/text/index.ts"],"mappings":";;;;;;AAMA;KAAY,aAAA,GAAgB,SAAA;EAC1B,KAAA;IACE,IAAA,EAAM,KAAA;EAAA;AAAA;;;;iBAOM,UAAA,CAAA,GAAc,aAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-extensions-text.js","names":[],"sources":["../src/text/index.ts"],"sourcesContent":["import { defineNodeSpec, type Extension } from '@prosekit/core'\nimport type { Attrs } from '@prosekit/pm/model'\n\n/**\n * @internal\n */\nexport type TextExtension = Extension<{\n Nodes: {\n text: Attrs\n }\n}>\n\n/**\n * @public\n */\nexport function defineText(): TextExtension {\n return defineNodeSpec({\n name: 'text',\n group: 'inline',\n })\n}\n"],"mappings":";;;;;AAeA,SAAgB,aAA4B;AAC1C,QAAO,eAAe;EACpB,MAAM;EACN,OAAO;EACR,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-extensions-underline.d.ts","names":[],"sources":["../src/underline/index.ts"],"mappings":";;;;;;AAeA;KAAY,sBAAA,GAAyB,SAAA;EACnC,KAAA;IACE,SAAA,EAAW,KAAA;EAAA;AAAA;;;;iBAOC,mBAAA,CAAA,GAAuB,sBAAA;AAAvC;;;AAAA,KAkBY,0BAAA,GAA6B,SAAA;EACvC,QAAA;IACE,eAAA;EAAA;AAAA;;;;iBAOY,uBAAA,CAAA,GAA2B,0BAAA;;;AAA3C;iBASgB,qBAAA,CAAA,GAAyB,cAAA;;;;KAS7B,kBAAA,GAAqB,KAAA,EAC9B,sBAAA,EAAwB,0BAAA;;AAD3B;;iBAOgB,eAAA,CAAA,GAAmB,kBAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-extensions-underline.js","names":[],"sources":["../src/underline/index.ts"],"sourcesContent":["import {\n defineCommands,\n defineKeymap,\n defineMarkSpec,\n toggleMark,\n union,\n type Extension,\n type PlainExtension,\n type Union,\n} from '@prosekit/core'\nimport type { Attrs } from '@prosekit/pm/model'\n\n/**\n * @internal\n */\nexport type UnderlineSpecExtension = Extension<{\n Marks: {\n underline: Attrs\n }\n}>\n\n/**\n * @internal\n */\nexport function defineUnderlineSpec(): UnderlineSpecExtension {\n return defineMarkSpec({\n name: 'underline',\n parseDOM: [\n { tag: 'u' },\n { tag: 'underline' },\n { style: 'text-decoration=underline' },\n { style: 'text-decoration-line=underline' },\n ],\n toDOM() {\n return ['u', 0]\n },\n })\n}\n\n/**\n * @internal\n */\nexport type UnderlineCommandsExtension = Extension<{\n Commands: {\n toggleUnderline: []\n }\n}>\n\n/**\n * @internal\n */\nexport function defineUnderlineCommands(): UnderlineCommandsExtension {\n return defineCommands({\n toggleUnderline: () => toggleMark({ type: 'underline' }),\n })\n}\n\n/**\n * @internal\n */\nexport function defineUnderlineKeymap(): PlainExtension {\n return defineKeymap({\n 'Mod-u': toggleMark({ type: 'underline' }),\n })\n}\n\n/**\n * @internal\n */\nexport type UnderlineExtension = Union<\n [UnderlineSpecExtension, UnderlineCommandsExtension]\n>\n\n/**\n * @public\n */\nexport function defineUnderline(): UnderlineExtension {\n return union(\n defineUnderlineSpec(),\n defineUnderlineCommands(),\n defineUnderlineKeymap(),\n )\n}\n"],"mappings":";;;;;AAwBA,SAAgB,sBAA8C;AAC5D,QAAO,eAAe;EACpB,MAAM;EACN,UAAU;GACR,EAAE,KAAK,KAAK;GACZ,EAAE,KAAK,aAAa;GACpB,EAAE,OAAO,6BAA6B;GACtC,EAAE,OAAO,kCAAkC;GAC5C;EACD,QAAQ;AACN,UAAO,CAAC,KAAK,EAAE;;EAElB,CAAC;;;;;AAeJ,SAAgB,0BAAsD;AACpE,QAAO,eAAe,EACpB,uBAAuB,WAAW,EAAE,MAAM,aAAa,CAAC,EACzD,CAAC;;;;;AAMJ,SAAgB,wBAAwC;AACtD,QAAO,aAAa,EAClB,SAAS,WAAW,EAAE,MAAM,aAAa,CAAC,EAC3C,CAAC;;;;;AAaJ,SAAgB,kBAAsC;AACpD,QAAO,MACL,qBAAqB,EACrB,yBAAyB,EACzB,uBAAuB,CACxB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-extensions-virtual-selection.d.ts","names":[],"sources":["../src/virtual-selection/index.ts"],"mappings":";;;;;AAOA;KAAY,yBAAA,GAA4B,cAAA;;;;AAYxC;;;;;;;iBAAgB,sBAAA,CAAA,GAA0B,yBAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-extensions-virtual-selection.js","names":[],"sources":["../src/virtual-selection/index.ts"],"sourcesContent":["import { definePlugin, type PlainExtension } from '@prosekit/core'\nimport { PluginKey, ProseMirrorPlugin, type EditorState, type Transaction } from '@prosekit/pm/state'\nimport { Decoration, DecorationSet } from '@prosekit/pm/view'\n\n/**\n * @internal\n */\nexport type VirtualSelectionExtension = PlainExtension\n\n/**\n * Shows a virtual selection when the editor is not focused. When the editor is\n * not focused, the selected inline content will be wrapped in a `<span>`\n * element with the class `prosekit-virtual-selection`.\n *\n * This is useful when you want to move the focus to an element outside the\n * editor, but still want to show the selection.\n *\n * @public\n */\nexport function defineVirtualSelection(): VirtualSelectionExtension {\n return definePlugin(virtualSelectionPlugin)\n}\n\n// Show the decoration when this is true.\ntype PluginState = boolean\n\nconst key = new PluginKey<PluginState>('prosekit-virtual-selection')\n\nfunction getFocusMeta(tr: Transaction): PluginState | undefined {\n return tr.getMeta(key) as PluginState | undefined\n}\n\nfunction setFocusMeta(tr: Transaction, value: PluginState) {\n return tr.setMeta(key, value)\n}\n\nfunction getFocusState(state: EditorState): PluginState | undefined {\n return key.getState(state)\n}\n\nconst virtualSelectionPlugin = new ProseMirrorPlugin<PluginState>({\n key,\n state: {\n init: () => false,\n apply: (tr, value) => {\n return getFocusMeta(tr) ?? value\n },\n },\n props: {\n handleDOMEvents: {\n focus: (view) => {\n view.dispatch(setFocusMeta(view.state.tr, false))\n },\n\n blur: (view) => {\n const { dom, root } = view\n const activeElement = root.activeElement\n\n // Don't show the decoration if the dom is blurred because the focus\n // moved outside the browser window.\n if (activeElement === dom) return\n\n view.dispatch(setFocusMeta(view.state.tr, true))\n },\n },\n decorations: (state) => {\n const { selection, doc } = state\n\n if (\n selection.empty\n || !getFocusState(state)\n // When `selection.visible` is false, it indicates that the selection is\n // rendered by the editor and it's not a native browser selection. An\n // example of this is `NodeSelection`. In this situation, since the\n // editor already shows the selection, we don't need to display a\n // virtual selection.\n || !selection.visible\n ) {\n return null\n }\n\n return DecorationSet.create(doc, [\n Decoration.inline(selection.from, selection.to, {\n class: 'prosekit-virtual-selection',\n }),\n ])\n },\n },\n})\n"],"mappings":";;;;;;;;;;;;;;AAmBA,SAAgB,yBAAoD;AAClE,QAAO,aAAa,uBAAuB;;AAM7C,MAAM,MAAM,IAAI,UAAuB,6BAA6B;AAEpE,SAAS,aAAa,IAA0C;AAC9D,QAAO,GAAG,QAAQ,IAAI;;AAGxB,SAAS,aAAa,IAAiB,OAAoB;AACzD,QAAO,GAAG,QAAQ,KAAK,MAAM;;AAG/B,SAAS,cAAc,OAA6C;AAClE,QAAO,IAAI,SAAS,MAAM;;AAG5B,MAAM,yBAAyB,IAAI,kBAA+B;CAChE;CACA,OAAO;EACL,YAAY;EACZ,QAAQ,IAAI,UAAU;AACpB,UAAO,aAAa,GAAG,IAAI;;EAE9B;CACD,OAAO;EACL,iBAAiB;GACf,QAAQ,SAAS;AACf,SAAK,SAAS,aAAa,KAAK,MAAM,IAAI,MAAM,CAAC;;GAGnD,OAAO,SAAS;IACd,MAAM,EAAE,KAAK,SAAS;AAKtB,QAJsB,KAAK,kBAIL,IAAK;AAE3B,SAAK,SAAS,aAAa,KAAK,MAAM,IAAI,KAAK,CAAC;;GAEnD;EACD,cAAc,UAAU;GACtB,MAAM,EAAE,WAAW,QAAQ;AAE3B,OACE,UAAU,SACP,CAAC,cAAc,MAAM,IAMrB,CAAC,UAAU,QAEd,QAAO;AAGT,UAAO,cAAc,OAAO,KAAK,CAC/B,WAAW,OAAO,UAAU,MAAM,UAAU,IAAI,EAC9C,OAAO,8BACR,CAAC,CACH,CAAC;;EAEL;CACF,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-extensions-yjs.d.ts","names":[],"sources":["../src/yjs/yjs-commands.ts","../src/yjs/yjs-types.ts","../src/yjs/yjs-cursor-plugin.ts","../src/yjs/yjs-keymap.ts","../src/yjs/yjs-sync-plugin.ts","../src/yjs/yjs-undo-plugin.ts","../src/yjs/yjs.ts"],"mappings":";;;;;;;;KAWY,oBAAA,GAAuB,SAAA;EACjC,QAAA;IACE,IAAA;IACA,IAAA;EAAA;AAAA;AAAA,iBAIY,iBAAA,CAAA,GAAqB,oBAAA;;;;;;;AAPrC;KCJY,SAAA,GAAY,UAAA,QAAkB,aAAA;;;;;ADI1C;KEFY,sBAAA,GAAyB,WAAA,CACnC,UAAA,QAAkB,aAAA;AAAA,UAGH,gBAAA,SAAyB,sBAAA;EACxC,SAAA,EAAW,SAAA;AAAA;AAAA,iBAGG,qBAAA,CACd,OAAA,EAAS,gBAAA,GACR,cAAA;;;iBCPa,eAAA,CAAA,GAAmB,cAAA;;;;;AHDnC;KIHY,oBAAA,GAAuB,WAAA,CACjC,UAAA,QAAkB,WAAA;AAAA,UAGH,cAAA,SAAuB,oBAAA;EACtC,QAAA,EAAU,CAAA,CAAE,WAAA;AAAA;AAAA,iBAGE,mBAAA,CAAoB,OAAA,EAAS,cAAA,GAAiB,cAAA;;;;;;KC6ClD,oBAAA,GAAuB,WAAA,CACjC,UAAA,QAAkB,WAAA;AAAA,UAGH,cAAA,SAAuB,oBAAA;;;;iBAcxB,mBAAA,CAAoB,OAAA,EAAS,cAAA,GAAiB,cAAA;;;UCpE7C,UAAA;ENA2B;;;EMI1C,GAAA,EAAK,CAAA,CAAE,GAAA;ENDL;;;EMMF,SAAA,EAAW,SAAA;ENFoB;;;;EMQ/B,QAAA,GAAW,CAAA,CAAE,WAAA;;;ALnBf;EKwBE,IAAA,GAAO,oBAAA;;;;EAKP,IAAA,GAAO,oBAAA;;;AJ3BT;EIgCE,MAAA,GAAS,sBAAA;AAAA;;;;KAMC,YAAA,GAAe,KAAA,EAAO,oBAAA,EAAsB,cAAA;;;;iBAKxC,SAAA,CAAU,OAAA,EAAS,UAAA,GAAa,YAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-extensions-yjs.js","names":["yUndoPlugin","originalYUndoPlugin"],"sources":["../src/yjs/yjs-commands.ts","../src/yjs/yjs-cursor-plugin.ts","../src/yjs/yjs-keymap.ts","../src/yjs/yjs-sync-plugin.ts","../src/yjs/yjs-undo-plugin.ts","../src/yjs/yjs.ts"],"sourcesContent":["import { defineCommands, type Extension } from '@prosekit/core'\nimport { redoCommand, undoCommand } from 'y-prosemirror'\n\nconst commands = {\n undo: () => undoCommand,\n redo: () => redoCommand,\n} as const\n\n/**\n * @internal\n */\nexport type YjsCommandsExtension = Extension<{\n Commands: {\n undo: []\n redo: []\n }\n}>\n\nexport function defineYjsCommands(): YjsCommandsExtension {\n return defineCommands(commands)\n}\n","import { definePlugin, type PlainExtension } from '@prosekit/core'\nimport type { Plugin } from '@prosekit/pm/state'\nimport { yCursorPlugin } from 'y-prosemirror'\n\nimport type { Awareness } from './yjs-types.ts'\n\n/**\n * Options for `y-prosemirror`'s `yCursorPlugin`.\n */\nexport type YjsCursorPluginOptions = NonNullable<\n Parameters<typeof yCursorPlugin>[1]\n>\n\nexport interface YjsCursorOptions extends YjsCursorPluginOptions {\n awareness: Awareness\n}\n\nexport function defineYjsCursorPlugin(\n options: YjsCursorOptions,\n): PlainExtension {\n const { awareness, ...rest } = options\n return definePlugin(yCursorPlugin(awareness, rest) as Plugin)\n}\n","import { defineKeymap, isApple, type Keymap, type PlainExtension } from '@prosekit/core'\nimport { redoCommand, undoCommand } from 'y-prosemirror'\n\nconst keymap: Keymap = {\n 'Mod-z': undoCommand,\n 'Mod-Z': redoCommand,\n}\n\nif (!isApple) {\n keymap['Mod-y'] = redoCommand\n}\n\nexport function defineYjsKeymap(): PlainExtension {\n return defineKeymap(keymap)\n}\n","import { definePlugin, type PlainExtension } from '@prosekit/core'\nimport type { Plugin } from '@prosekit/pm/state'\nimport { ySyncPlugin } from 'y-prosemirror'\nimport type * as Y from 'yjs'\n\n/**\n * Options for `y-prosemirror`'s `ySyncPlugin`.\n */\nexport type YjsSyncPluginOptions = NonNullable<\n Parameters<typeof ySyncPlugin>[1]\n>\n\nexport interface YjsSyncOptions extends YjsSyncPluginOptions {\n fragment: Y.XmlFragment\n}\n\nexport function defineYjsSyncPlugin(options: YjsSyncOptions): PlainExtension {\n const { fragment, ...rest } = options\n return definePlugin(ySyncPlugin(fragment, rest) as Plugin)\n}\n","import { definePlugin, type PlainExtension } from '@prosekit/core'\nimport type { ProseMirrorPlugin } from '@prosekit/pm/state'\nimport type { EditorView } from '@prosekit/pm/view'\nimport { yUndoPlugin as originalYUndoPlugin, yUndoPluginKey, type UndoPluginState } from 'y-prosemirror'\nimport type { UndoManager as YjsUndoManager } from 'yjs'\n\ntype UndoManager = YjsUndoManager & { restore: () => void }\n\n/**\n * @see https://github.com/yjs/y-prosemirror/issues/114 and https://github.com/yjs/y-prosemirror/issues/102\n */\nfunction fixYUndoPlugin(yUndoPluginInstance: ProseMirrorPlugin) {\n const originalUndoPluginView = yUndoPluginInstance.spec.view\n yUndoPluginInstance.spec.view = (view: EditorView) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- The type definition in y-prosemirror is not correct. An explicit file extension should be added to this line: https://npmx.dev/package-code/y-prosemirror/v/1.3.7/dist%2Fsrc%2Fplugins%2Fkeys.d.ts#L13\n const pluginState: UndoPluginState | undefined = yUndoPluginKey.getState(view.state)\n if (!pluginState) {\n return {}\n }\n\n const undoManager = pluginState.undoManager as UndoManager\n\n if (undoManager.restore) {\n undoManager.restore()\n undoManager.restore = () => {}\n }\n\n const viewRet = originalUndoPluginView\n ? originalUndoPluginView(view)\n : undefined\n\n return {\n destroy: () => {\n const hasUndoManSelf = undoManager.trackedOrigins.has(undoManager)\n\n const observers = undoManager._observers\n\n undoManager.restore = () => {\n if (hasUndoManSelf) {\n undoManager.trackedOrigins.add(undoManager)\n }\n\n undoManager.doc.on(\n 'afterTransaction',\n undoManager.afterTransactionHandler,\n )\n\n undoManager._observers = observers\n }\n\n if (viewRet?.destroy) {\n viewRet.destroy()\n }\n },\n }\n }\n}\n\n/**\n * Options for the `y-prosemirror`'s `yUndoPlugin`.\n */\nexport type YjsUndoPluginOptions = NonNullable<\n Parameters<typeof originalYUndoPlugin>[0]\n>\n\nexport interface YjsUndoOptions extends YjsUndoPluginOptions {}\n\n/**\n * @internal\n */\nfunction yUndoPlugin(options?: YjsUndoOptions) {\n const yUndoPluginInstance = originalYUndoPlugin(options)\n fixYUndoPlugin(yUndoPluginInstance)\n return yUndoPluginInstance\n}\n\n/**\n * @internal\n */\nexport function defineYjsUndoPlugin(options: YjsUndoOptions): PlainExtension {\n return definePlugin(yUndoPlugin(options))\n}\n","import type { Priority } from '@prosekit/core'\nimport { union, withPriority, type PlainExtension, type Union } from '@prosekit/core'\nimport type * as Y from 'yjs'\n\nimport { defineYjsCommands, type YjsCommandsExtension } from './yjs-commands.ts'\nimport { defineYjsCursorPlugin, type YjsCursorPluginOptions } from './yjs-cursor-plugin.ts'\nimport { defineYjsKeymap } from './yjs-keymap.ts'\nimport { defineYjsSyncPlugin, type YjsSyncPluginOptions } from './yjs-sync-plugin.ts'\nimport type { Awareness } from './yjs-types.ts'\nimport { defineYjsUndoPlugin, type YjsUndoPluginOptions } from './yjs-undo-plugin.ts'\n\nexport interface YjsOptions {\n /**\n * The Yjs instance handles the state of shared data.\n */\n doc: Y.Doc\n\n /**\n * The Awareness instance.\n */\n awareness: Awareness\n\n /**\n * The Yjs XmlFragment to use. If not provided,\n * `doc.getXmlFragment('prosemirror')` will be used.\n */\n fragment?: Y.XmlFragment\n\n /**\n * Options for `y-prosemirror`'s `ySyncPlugin`.\n */\n sync?: YjsSyncPluginOptions\n\n /**\n * Options for the `y-prosemirror`'s `yUndoPlugin`.\n */\n undo?: YjsUndoPluginOptions\n\n /**\n * Options for `y-prosemirror`'s `yCursorPlugin`.\n */\n cursor?: YjsCursorPluginOptions\n}\n\n/**\n * @internal\n */\nexport type YjsExtension = Union<[YjsCommandsExtension, PlainExtension]>\n\n/**\n * @public\n */\nexport function defineYjs(options: YjsOptions): YjsExtension {\n const { doc, awareness, sync, undo, cursor } = options\n const fragment = options.fragment ?? doc.getXmlFragment('prosemirror')\n\n return withPriority(\n union([\n defineYjsKeymap(),\n defineYjsCommands(),\n defineYjsCursorPlugin({ ...cursor, awareness }),\n defineYjsUndoPlugin({ ...undo }),\n defineYjsSyncPlugin({ ...sync, fragment }),\n ]),\n 3 satisfies typeof Priority.high,\n )\n}\n"],"mappings":";;;AAGA,MAAM,WAAW;CACf,YAAY;CACZ,YAAY;CACb;AAYD,SAAgB,oBAA0C;AACxD,QAAO,eAAe,SAAS;;;;ACFjC,SAAgB,sBACd,SACgB;CAChB,MAAM,EAAE,WAAW,GAAG,SAAS;AAC/B,QAAO,aAAa,cAAc,WAAW,KAAK,CAAW;;;;AClB/D,MAAM,SAAiB;CACrB,SAAS;CACT,SAAS;CACV;AAED,IAAI,CAAC,QACH,QAAO,WAAW;AAGpB,SAAgB,kBAAkC;AAChD,QAAO,aAAa,OAAO;;;;ACG7B,SAAgB,oBAAoB,SAAyC;CAC3E,MAAM,EAAE,UAAU,GAAG,SAAS;AAC9B,QAAO,aAAa,YAAY,UAAU,KAAK,CAAW;;;;;;;ACP5D,SAAS,eAAe,qBAAwC;CAC9D,MAAM,yBAAyB,oBAAoB,KAAK;AACxD,qBAAoB,KAAK,QAAQ,SAAqB;EAEpD,MAAM,cAA2C,eAAe,SAAS,KAAK,MAAM;AACpF,MAAI,CAAC,YACH,QAAO,EAAE;EAGX,MAAM,cAAc,YAAY;AAEhC,MAAI,YAAY,SAAS;AACvB,eAAY,SAAS;AACrB,eAAY,gBAAgB;;EAG9B,MAAM,UAAU,yBACZ,uBAAuB,KAAK,GAC5B,KAAA;AAEJ,SAAO,EACL,eAAe;GACb,MAAM,iBAAiB,YAAY,eAAe,IAAI,YAAY;GAElE,MAAM,YAAY,YAAY;AAE9B,eAAY,gBAAgB;AAC1B,QAAI,eACF,aAAY,eAAe,IAAI,YAAY;AAG7C,gBAAY,IAAI,GACd,oBACA,YAAY,wBACb;AAED,gBAAY,aAAa;;AAG3B,OAAI,SAAS,QACX,SAAQ,SAAS;KAGtB;;;;;;AAgBL,SAASA,cAAY,SAA0B;CAC7C,MAAM,sBAAsBC,YAAoB,QAAQ;AACxD,gBAAe,oBAAoB;AACnC,QAAO;;;;;AAMT,SAAgB,oBAAoB,SAAyC;AAC3E,QAAO,aAAaD,cAAY,QAAQ,CAAC;;;;;;;AC5B3C,SAAgB,UAAU,SAAmC;CAC3D,MAAM,EAAE,KAAK,WAAW,MAAM,MAAM,WAAW;CAC/C,MAAM,WAAW,QAAQ,YAAY,IAAI,eAAe,cAAc;AAEtE,QAAO,aACL,MAAM;EACJ,iBAAiB;EACjB,mBAAmB;EACnB,sBAAsB;GAAE,GAAG;GAAQ;GAAW,CAAC;EAC/C,oBAAoB,EAAE,GAAG,MAAM,CAAC;EAChC,oBAAoB;GAAE,GAAG;GAAM;GAAU,CAAC;EAC3C,CAAC,EACF,EACD"}
|
package/dist/table.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"table.js","names":[],"sources":["../src/table/table-commands/exit-table.ts","../src/table/table-commands/insert-table.ts","../src/table/table-utils.ts","../src/table/table-commands/select-table-cell.ts","../src/table/table-commands/select-table-column.ts","../src/table/table-commands/select-table-row.ts","../src/table/table-commands/select-table.ts","../src/table/table-commands.ts","../src/table/table-drop-indicator.ts","../src/table/table-plugins.ts","../src/table/table-spec.ts","../src/table/table.ts"],"sourcesContent":["import { defaultBlockAt } from '@prosekit/core'\nimport { TextSelection } from '@prosekit/pm/state'\nimport type { Command } from '@prosekit/pm/state'\nimport type { TableRole } from 'prosemirror-tables'\n\n/**\n * When the selection is in a table node, create a default block after the table\n * table, and move the cursor there.\n *\n * @public\n */\nexport const exitTable: Command = (state, dispatch) => {\n const { $head, $anchor } = state.selection\n\n if (!$head.sameParent($anchor)) {\n return false\n }\n\n let tableStart = -1\n let tableDepth = -1\n for (let depth = $head.depth; depth >= 0; depth--) {\n const node = $head.node(depth)\n if ((node.type.spec.tableRole as TableRole) === 'table') {\n tableStart = $head.before(depth)\n tableDepth = depth\n }\n }\n\n if (tableStart < 0 || tableDepth <= 0) {\n return false\n }\n\n const above = $head.node(tableDepth - 1)\n const after = $head.indexAfter(tableDepth - 1)\n const type = defaultBlockAt(above.contentMatchAt(after))\n const node = type?.createAndFill()\n\n if (!type || !node || !above.canReplaceWith(after, after, type)) {\n return false\n }\n\n if (dispatch) {\n const pos = $head.after(tableDepth)\n const tr = state.tr.replaceWith(pos, pos, node)\n tr.setSelection(TextSelection.near(tr.doc.resolve(pos), 1))\n dispatch(tr.scrollIntoView())\n }\n return true\n}\n","import { getNodeType, insertNode } from '@prosekit/core'\nimport type { Schema } from '@prosekit/pm/model'\nimport type { Command } from '@prosekit/pm/state'\n\nfunction createEmptyTable(\n schema: Schema,\n row: number,\n col: number,\n header: boolean,\n) {\n const tableType = getNodeType(schema, 'table')\n const tableRowType = getNodeType(schema, 'tableRow')\n const tableCellType = getNodeType(schema, 'tableCell')\n const tableHeaderCellType = getNodeType(schema, 'tableHeaderCell')\n\n if (header) {\n const headerCell = tableHeaderCellType.createAndFill()!\n const headerCells = repeat(headerCell, col)\n const headerRow = tableRowType.createAndFill(null, headerCells)!\n\n const bodyCell = tableCellType.createAndFill()!\n const bodyCells = repeat(bodyCell, col)\n const bodyRow = tableRowType.createAndFill(null, bodyCells)!\n const bodyRows = repeat(bodyRow, row - 1)\n\n return tableType.createAndFill(null, [headerRow, ...bodyRows])!\n } else {\n const bodyCell = tableCellType.createAndFill()!\n const bodyCells = repeat(bodyCell, col)\n const bodyRow = tableRowType.createAndFill(null, bodyCells)!\n const bodyRows = repeat(bodyRow, row)\n\n return tableType.createAndFill(null, bodyRows)!\n }\n}\n\nfunction repeat<T>(node: T, length: number): T[] {\n return Array<T>(length).fill(node)\n}\n\n/**\n * @public\n */\nexport interface InsertTableOptions {\n /**\n * The number of rows in the table.\n */\n row: number\n\n /**\n * The number of columns in the table.\n */\n col: number\n\n /**\n * Whether the table has a header row.\n *\n * @default false\n */\n header?: boolean\n}\n\n/**\n * Insert a table node with the given number of rows and columns, and optionally\n * a header row.\n *\n * @param options\n *\n * @public\n */\nexport function insertTable(options: InsertTableOptions): Command {\n return (state, dispatch, view) => {\n const { row, col, header = false } = options\n const table = createEmptyTable(state.schema, row, col, header)\n return insertNode({ node: table })(state, dispatch, view)\n }\n}\n","import { CellSelection, findCellPos, findCellRange, findTable } from 'prosemirror-tables'\n\nexport { findCellPos, findCellRange, findTable }\n\n/**\n * Checks if the given object is a `CellSelection` instance.\n *\n * @public\n */\nexport function isCellSelection(value: unknown): value is CellSelection {\n return value instanceof CellSelection\n}\n","import type { Command } from '@prosekit/pm/state'\nimport { CellSelection } from 'prosemirror-tables'\n\nimport { findCellPos } from '../table-utils.ts'\n\n/**\n * @public\n */\nexport interface SelectTableCellOptions {\n /**\n * A hit position of the table cell to select from. By default, the selection\n * anchor will be used.\n */\n pos?: number\n}\n\n/**\n * @public\n */\nexport function selectTableCell(options?: SelectTableCellOptions): Command {\n return (state, dispatch) => {\n const $cellPos = findCellPos(\n state.doc,\n options?.pos ?? state.selection.anchor,\n )\n if (!$cellPos) {\n return false\n }\n if (dispatch) {\n const selection = new CellSelection($cellPos)\n dispatch(state.tr.setSelection(selection))\n }\n return true\n }\n}\n","import type { Command } from '@prosekit/pm/state'\nimport { CellSelection } from 'prosemirror-tables'\n\nimport { findCellRange } from '../table-utils.ts'\n\n/**\n * @public\n */\nexport interface SelectTableColumnOptions {\n /**\n * A hit position of the table cell to select from. By default, the selection\n * anchor will be used.\n */\n anchor?: number\n\n /**\n * A hit position of the table cell to select to. By default, the selection\n * head will be used.\n */\n head?: number\n}\n\n/**\n * @public\n */\nexport function selectTableColumn(options?: SelectTableColumnOptions): Command {\n return (state, dispatch) => {\n const range = findCellRange(state.selection, options?.anchor, options?.head)\n if (!range) {\n return false\n }\n if (dispatch) {\n const [$anchorCell, $headCell] = range\n const selection = CellSelection.colSelection($anchorCell, $headCell)\n dispatch(state.tr.setSelection(selection))\n }\n return true\n }\n}\n","import type { Command } from '@prosekit/pm/state'\nimport { CellSelection } from 'prosemirror-tables'\n\nimport { findCellRange } from '../table-utils.ts'\n\n/**\n * @public\n */\nexport interface SelectTableRowOptions {\n /**\n * A hit position of the table cell to select from. By default, the selection\n * anchor will be used.\n */\n anchor?: number\n\n /**\n * A hit position of the table cell to select to. By default, the selection\n * head will be used.\n */\n head?: number\n}\n\n/**\n * @public\n */\nexport function selectTableRow(options?: SelectTableRowOptions): Command {\n return (state, dispatch) => {\n const range = findCellRange(state.selection, options?.anchor, options?.head)\n if (!range) {\n return false\n }\n if (dispatch) {\n const [$anchorCell, $headCell] = range\n const selection = CellSelection.rowSelection($anchorCell, $headCell)\n dispatch(state.tr.setSelection(selection))\n }\n return true\n }\n}\n","import type { Command } from '@prosekit/pm/state'\nimport { CellSelection, TableMap } from 'prosemirror-tables'\n\nimport { findTable } from '../table-utils.ts'\n\n/**\n * @public\n */\nexport interface SelectTableOptions {\n /**\n * A hit position of the table to select from. By default, the selection\n * anchor will be used.\n */\n pos?: number\n}\n\n/**\n * @public\n */\nexport function selectTable(options?: SelectTableOptions): Command {\n return (state, dispatch) => {\n const $pos = options?.pos\n ? state.doc.resolve(options.pos)\n : state.selection.$anchor\n const table = findTable($pos)\n if (!table) {\n return false\n }\n const map = TableMap.get(table.node)\n if (map.map.length === 0) {\n return false\n }\n if (dispatch) {\n let tr = state.tr\n const firstCellPosInTable = map.map[0]\n const lastCellPosInTable = map.map[map.map.length - 1]\n const firstCellPos = table.pos + firstCellPosInTable + 1\n const lastCellPos = table.pos + lastCellPosInTable + 1\n const $firstCellPos = tr.doc.resolve(firstCellPos)\n const $lastCellPos = tr.doc.resolve(lastCellPos)\n const selection = new CellSelection($firstCellPos, $lastCellPos)\n tr = tr.setSelection(selection)\n dispatch?.(tr)\n }\n return true\n }\n}\n","import { defineCommands, type Extension } from '@prosekit/core'\nimport {\n addColumnAfter,\n addColumnBefore,\n addRowAfter,\n addRowBefore,\n deleteColumn,\n deleteRow,\n deleteTable,\n mergeCells,\n splitCell,\n} from 'prosemirror-tables'\n\nimport { deleteCellSelection } from './table-commands/delete-cell-selection.ts'\nimport { exitTable } from './table-commands/exit-table.ts'\nimport { insertTable, type InsertTableOptions } from './table-commands/insert-table.ts'\nimport { moveTableColumn, type MoveTableColumnOptions } from './table-commands/move-table-column.ts'\nimport { moveTableRow, type MoveTableRowOptions } from './table-commands/move-table-row.ts'\nimport { selectTableCell, type SelectTableCellOptions } from './table-commands/select-table-cell.ts'\nimport { selectTableColumn, type SelectTableColumnOptions } from './table-commands/select-table-column.ts'\nimport { selectTableRow, type SelectTableRowOptions } from './table-commands/select-table-row.ts'\nimport { selectTable, type SelectTableOptions } from './table-commands/select-table.ts'\n\n/**\n * @internal\n */\nexport type TableCommandsExtension = Extension<{\n Commands: {\n insertTable: [options: InsertTableOptions]\n exitTable: []\n\n selectTable: [options?: SelectTableOptions]\n selectTableCell: [options?: SelectTableCellOptions]\n selectTableColumn: [options?: SelectTableColumnOptions]\n selectTableRow: [options?: SelectTableRowOptions]\n\n addTableColumnBefore: []\n addTableColumnAfter: []\n addTableRowAbove: []\n addTableRowBelow: []\n\n deleteTable: []\n deleteTableColumn: []\n deleteTableRow: []\n deleteCellSelection: []\n\n mergeTableCells: []\n splitTableCell: []\n\n moveTableRow: [options: MoveTableRowOptions]\n moveTableColumn: [options: MoveTableColumnOptions]\n }\n}>\n\n/**\n * Adds commands for working with `table` nodes.\n *\n * @public\n */\nexport function defineTableCommands(): TableCommandsExtension {\n return defineCommands({\n insertTable,\n exitTable: () => exitTable,\n\n selectTable,\n selectTableCell,\n selectTableColumn,\n selectTableRow,\n\n addTableColumnBefore: () => addColumnBefore,\n addTableColumnAfter: () => addColumnAfter,\n addTableRowAbove: () => addRowBefore,\n addTableRowBelow: () => addRowAfter,\n\n deleteTable: () => deleteTable,\n deleteTableColumn: () => deleteColumn,\n deleteTableRow: () => deleteRow,\n deleteCellSelection: () => deleteCellSelection,\n\n mergeTableCells: () => mergeCells,\n splitTableCell: () => splitCell,\n\n moveTableRow,\n moveTableColumn,\n })\n}\n","import type { PlainExtension } from '@prosekit/core'\n\nimport type { DragEventHandler } from '../drop-indicator/index.ts'\nimport { defineDropIndicator } from '../drop-indicator/index.ts'\n\n/**\n * Hides the drop indicator when dragging a table column or row by using the\n * table handle.\n *\n * @internal\n */\nexport function defineTableDropIndicator(): PlainExtension {\n return defineDropIndicator({\n onDrag,\n })\n}\n\nconst matchMap = new WeakMap<DataTransfer, boolean>()\n\nconst onDrag: DragEventHandler = ({ event }): boolean => {\n const dataTransfer = event.dataTransfer\n if (!dataTransfer) return true\n\n let match: boolean\n\n if (matchMap.has(dataTransfer)) {\n match = matchMap.get(dataTransfer)!\n } else {\n // On Safari, accessing `dataTransfer.types` is more than 10x slower than in\n // Chrome. This becomes a bottleneck when `onDrag` is called frequently, so\n // we cache the result in a WeakMap.\n const types = dataTransfer.types\n match = types.includes('application/x-prosekit-table-handle-drag')\n matchMap.set(dataTransfer, match)\n }\n\n // Don't show the drop indicator when the drag event has\n // \"application/x-prosekit-table-handle-drag\" type.\n return !match\n}\n","import { definePlugin, type PlainExtension } from '@prosekit/core'\nimport { columnResizing, tableEditing } from 'prosemirror-tables'\n\n/**\n * @public\n */\nexport function defineTablePlugins(): PlainExtension {\n return definePlugin([tableEditing(), columnResizing()])\n}\n","import { defineNodeSpec, type Extension } from '@prosekit/core'\nimport type { AttributeSpec, Attrs } from '@prosekit/pm/model'\nimport { tableNodes } from 'prosemirror-tables'\n\nconst cellContent = 'block+'\n\n/**\n * @public\n */\nexport interface CellAttrs {\n colspan?: number\n rowspan?: number\n colwidth?: number[] | null\n}\n\nconst cellAttrs = {\n colspan: { default: 1 },\n rowspan: { default: 1 },\n colwidth: { default: null },\n} satisfies Record<string, AttributeSpec>\n\n/**\n * @internal\n */\nexport type TableSpecExtension = Extension<{\n Nodes: {\n table: Attrs\n }\n}>\n\nconst specs = tableNodes({\n tableGroup: 'block',\n cellContent,\n cellAttributes: {},\n})\n\n/**\n * @internal\n */\nexport function defineTableSpec(): TableSpecExtension {\n return defineNodeSpec({\n ...specs['table'],\n content: 'tableRow+',\n name: 'table',\n })\n}\n\n/**\n * @internal\n */\nexport type TableRowSpecExtension = Extension<{\n Nodes: {\n tableRow: Attrs\n }\n}>\n\n/**\n * @internal\n */\nexport function defineTableRowSpec(): TableRowSpecExtension {\n return defineNodeSpec({\n ...specs['table_row'],\n content: '(tableCell | tableHeaderCell)*',\n name: 'tableRow',\n })\n}\n\n/**\n * @internal\n */\nexport type TableCellSpecExtension = Extension<{\n Nodes: {\n tableCell: CellAttrs\n }\n}>\n\n/**\n * @internal\n */\nexport function defineTableCellSpec(): TableCellSpecExtension {\n return defineNodeSpec({\n ...specs['table_cell'],\n name: 'tableCell',\n attrs: cellAttrs,\n })\n}\n\n/**\n * @internal\n */\nexport type TableHeaderCellSpecExtension = Extension<{\n Nodes: {\n tableHeaderCell: CellAttrs\n }\n}>\n\nexport function defineTableHeaderCellSpec(): TableHeaderCellSpecExtension {\n return defineNodeSpec({\n ...specs['table_header'],\n name: 'tableHeaderCell',\n attrs: cellAttrs,\n })\n}\n","import { union, type Union } from '@prosekit/core'\n\nimport { defineTableCommands, type TableCommandsExtension } from './table-commands.ts'\nimport { defineTableDropIndicator } from './table-drop-indicator.ts'\nimport { defineTablePlugins } from './table-plugins.ts'\nimport {\n defineTableCellSpec,\n defineTableHeaderCellSpec,\n defineTableRowSpec,\n defineTableSpec,\n type TableCellSpecExtension,\n type TableHeaderCellSpecExtension,\n type TableRowSpecExtension,\n type TableSpecExtension,\n} from './table-spec.ts'\n\n/**\n * @internal\n */\nexport type TableExtension = Union<\n [\n TableSpecExtension,\n TableRowSpecExtension,\n TableCellSpecExtension,\n TableHeaderCellSpecExtension,\n TableCommandsExtension,\n ]\n>\n\n/**\n * @public\n */\nexport function defineTable(): TableExtension {\n return union(\n defineTableSpec(),\n defineTableRowSpec(),\n defineTableCellSpec(),\n defineTableHeaderCellSpec(),\n defineTablePlugins(),\n defineTableCommands(),\n defineTableDropIndicator(),\n )\n}\n"],"mappings":";;;;;;;;;;;AAWA,MAAa,aAAsB,OAAO,aAAa;CACrD,MAAM,EAAE,OAAO,YAAY,MAAM;AAEjC,KAAI,CAAC,MAAM,WAAW,QAAQ,CAC5B,QAAO;CAGT,IAAI,aAAa;CACjB,IAAI,aAAa;AACjB,MAAK,IAAI,QAAQ,MAAM,OAAO,SAAS,GAAG,QAExC,KADa,MAAM,KAAK,MAAM,CACpB,KAAK,KAAK,cAA4B,SAAS;AACvD,eAAa,MAAM,OAAO,MAAM;AAChC,eAAa;;AAIjB,KAAI,aAAa,KAAK,cAAc,EAClC,QAAO;CAGT,MAAM,QAAQ,MAAM,KAAK,aAAa,EAAE;CACxC,MAAM,QAAQ,MAAM,WAAW,aAAa,EAAE;CAC9C,MAAM,OAAO,eAAe,MAAM,eAAe,MAAM,CAAC;CACxD,MAAM,OAAO,MAAM,eAAe;AAElC,KAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,eAAe,OAAO,OAAO,KAAK,CAC7D,QAAO;AAGT,KAAI,UAAU;EACZ,MAAM,MAAM,MAAM,MAAM,WAAW;EACnC,MAAM,KAAK,MAAM,GAAG,YAAY,KAAK,KAAK,KAAK;AAC/C,KAAG,aAAa,cAAc,KAAK,GAAG,IAAI,QAAQ,IAAI,EAAE,EAAE,CAAC;AAC3D,WAAS,GAAG,gBAAgB,CAAC;;AAE/B,QAAO;;;;AC3CT,SAAS,iBACP,QACA,KACA,KACA,QACA;CACA,MAAM,YAAY,YAAY,QAAQ,QAAQ;CA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