@prosekit/extensions 0.13.0 → 0.14.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/{drop-indicator-B1QHFb5m.js → drop-indicator-B_oMfeVP.js} +11 -10
- package/dist/drop-indicator-B_oMfeVP.js.map +1 -0
- package/dist/{enter-rule-CzWOZF_Z.js → enter-rule-D-p4ykfv.js} +1 -1
- package/dist/enter-rule-D-p4ykfv.js.map +1 -0
- package/dist/{file-DrfcSid-.js → file-iLVR0eM0.js} +3 -3
- package/dist/file-iLVR0eM0.js.map +1 -0
- package/dist/{index-oIc1a2f2.d.ts → index-cp1u4e0e.d.ts} +1 -1
- package/dist/index-cp1u4e0e.d.ts.map +1 -0
- package/dist/{input-rule-dmsb3j6w.js → input-rule-COGr_GBb.js} +1 -1
- package/dist/input-rule-COGr_GBb.js.map +1 -0
- package/dist/{mark-rule-BcLB4Uv2.js → mark-rule-CYe8zk4q.js} +6 -6
- package/dist/mark-rule-CYe8zk4q.js.map +1 -0
- package/dist/{paste-rule-pVb4sqvJ.js → paste-rule-BaDghcaU.js} +7 -7
- package/dist/paste-rule-BaDghcaU.js.map +1 -0
- package/dist/prosekit-extensions-autocomplete.d.ts.map +1 -1
- package/dist/prosekit-extensions-autocomplete.js.map +1 -1
- package/dist/prosekit-extensions-background-color.d.ts +62 -0
- package/dist/prosekit-extensions-background-color.d.ts.map +1 -0
- package/dist/prosekit-extensions-background-color.js +76 -0
- package/dist/prosekit-extensions-background-color.js.map +1 -0
- package/dist/prosekit-extensions-blockquote.d.ts.map +1 -1
- package/dist/prosekit-extensions-blockquote.js +1 -1
- package/dist/prosekit-extensions-blockquote.js.map +1 -1
- package/dist/prosekit-extensions-bold.d.ts.map +1 -1
- package/dist/prosekit-extensions-bold.js +1 -1
- package/dist/prosekit-extensions-bold.js.map +1 -1
- package/dist/prosekit-extensions-code-block.d.ts +1 -1
- package/dist/prosekit-extensions-code-block.d.ts.map +1 -1
- package/dist/prosekit-extensions-code-block.js +4 -4
- package/dist/prosekit-extensions-code-block.js.map +1 -1
- package/dist/prosekit-extensions-code.d.ts.map +1 -1
- package/dist/prosekit-extensions-code.js +1 -1
- package/dist/prosekit-extensions-code.js.map +1 -1
- package/dist/prosekit-extensions-commit.d.ts +0 -1
- package/dist/prosekit-extensions-commit.d.ts.map +1 -1
- package/dist/prosekit-extensions-commit.js.map +1 -1
- package/dist/prosekit-extensions-doc.d.ts +0 -1
- package/dist/prosekit-extensions-doc.d.ts.map +1 -1
- package/dist/prosekit-extensions-doc.js.map +1 -1
- package/dist/prosekit-extensions-drop-cursor.d.ts.map +1 -1
- package/dist/prosekit-extensions-drop-cursor.js.map +1 -1
- package/dist/prosekit-extensions-drop-indicator.d.ts +0 -1
- package/dist/prosekit-extensions-drop-indicator.d.ts.map +1 -1
- package/dist/prosekit-extensions-drop-indicator.js +1 -1
- package/dist/prosekit-extensions-enter-rule.d.ts +0 -1
- package/dist/prosekit-extensions-enter-rule.d.ts.map +1 -1
- package/dist/prosekit-extensions-enter-rule.js +1 -1
- package/dist/prosekit-extensions-file.d.ts +1 -1
- package/dist/prosekit-extensions-file.js +1 -1
- package/dist/prosekit-extensions-gap-cursor.d.ts +0 -1
- package/dist/prosekit-extensions-gap-cursor.d.ts.map +1 -1
- package/dist/prosekit-extensions-gap-cursor.js.map +1 -1
- package/dist/prosekit-extensions-hard-break.d.ts.map +1 -1
- package/dist/prosekit-extensions-hard-break.js.map +1 -1
- package/dist/prosekit-extensions-heading.d.ts.map +1 -1
- package/dist/prosekit-extensions-heading.js +1 -1
- package/dist/prosekit-extensions-heading.js.map +1 -1
- package/dist/prosekit-extensions-horizontal-rule.d.ts.map +1 -1
- package/dist/prosekit-extensions-horizontal-rule.js +1 -1
- package/dist/prosekit-extensions-horizontal-rule.js.map +1 -1
- package/dist/prosekit-extensions-image.d.ts +9 -2
- package/dist/prosekit-extensions-image.d.ts.map +1 -1
- package/dist/prosekit-extensions-image.js +17 -4
- package/dist/prosekit-extensions-image.js.map +1 -1
- package/dist/prosekit-extensions-input-rule.d.ts +0 -1
- package/dist/prosekit-extensions-input-rule.d.ts.map +1 -1
- package/dist/prosekit-extensions-input-rule.js +1 -1
- package/dist/prosekit-extensions-italic.d.ts.map +1 -1
- package/dist/prosekit-extensions-italic.js +1 -1
- package/dist/prosekit-extensions-italic.js.map +1 -1
- package/dist/prosekit-extensions-link.d.ts +0 -1
- package/dist/prosekit-extensions-link.d.ts.map +1 -1
- package/dist/prosekit-extensions-link.js +4 -4
- package/dist/prosekit-extensions-link.js.map +1 -1
- package/dist/prosekit-extensions-list.d.ts +0 -1
- package/dist/prosekit-extensions-list.d.ts.map +1 -1
- package/dist/prosekit-extensions-list.js +3 -3
- package/dist/prosekit-extensions-list.js.map +1 -1
- package/dist/prosekit-extensions-loro.d.ts.map +1 -1
- package/dist/prosekit-extensions-loro.js +2 -2
- package/dist/prosekit-extensions-loro.js.map +1 -1
- package/dist/prosekit-extensions-mark-rule.d.ts +0 -1
- package/dist/prosekit-extensions-mark-rule.d.ts.map +1 -1
- package/dist/prosekit-extensions-mark-rule.js +1 -1
- package/dist/prosekit-extensions-mention.d.ts.map +1 -1
- package/dist/prosekit-extensions-mention.js.map +1 -1
- package/dist/prosekit-extensions-mod-click-prevention.d.ts +0 -1
- package/dist/prosekit-extensions-mod-click-prevention.d.ts.map +1 -1
- package/dist/prosekit-extensions-mod-click-prevention.js.map +1 -1
- package/dist/prosekit-extensions-paragraph.d.ts.map +1 -1
- package/dist/prosekit-extensions-paragraph.js.map +1 -1
- package/dist/prosekit-extensions-paste-rule.d.ts +0 -1
- package/dist/prosekit-extensions-paste-rule.d.ts.map +1 -1
- package/dist/prosekit-extensions-paste-rule.js +1 -1
- package/dist/prosekit-extensions-placeholder.d.ts.map +1 -1
- package/dist/prosekit-extensions-placeholder.js +1 -1
- package/dist/prosekit-extensions-placeholder.js.map +1 -1
- package/dist/prosekit-extensions-readonly.d.ts +0 -1
- package/dist/prosekit-extensions-readonly.d.ts.map +1 -1
- package/dist/prosekit-extensions-readonly.js.map +1 -1
- package/dist/prosekit-extensions-search.d.ts +0 -1
- package/dist/prosekit-extensions-search.d.ts.map +1 -1
- package/dist/prosekit-extensions-search.js.map +1 -1
- package/dist/prosekit-extensions-strike.d.ts +0 -1
- package/dist/prosekit-extensions-strike.d.ts.map +1 -1
- package/dist/prosekit-extensions-strike.js +1 -1
- package/dist/prosekit-extensions-table.d.ts.map +1 -1
- package/dist/prosekit-extensions-table.js +1 -1
- package/dist/prosekit-extensions-text-align.d.ts +0 -1
- package/dist/prosekit-extensions-text-align.d.ts.map +1 -1
- package/dist/prosekit-extensions-text-align.js +2 -2
- package/dist/prosekit-extensions-text-align.js.map +1 -1
- package/dist/prosekit-extensions-text-color.d.ts +62 -0
- package/dist/prosekit-extensions-text-color.d.ts.map +1 -0
- package/dist/prosekit-extensions-text-color.js +76 -0
- package/dist/prosekit-extensions-text-color.js.map +1 -0
- package/dist/prosekit-extensions-text.d.ts +0 -1
- package/dist/prosekit-extensions-text.d.ts.map +1 -1
- package/dist/prosekit-extensions-text.js.map +1 -1
- package/dist/prosekit-extensions-underline.d.ts +0 -1
- package/dist/prosekit-extensions-underline.d.ts.map +1 -1
- package/dist/prosekit-extensions-virtual-selection.d.ts +0 -1
- package/dist/prosekit-extensions-virtual-selection.d.ts.map +1 -1
- package/dist/prosekit-extensions-virtual-selection.js.map +1 -1
- package/dist/prosekit-extensions-yjs.d.ts +9 -2
- package/dist/prosekit-extensions-yjs.d.ts.map +1 -1
- package/dist/prosekit-extensions-yjs.js.map +1 -1
- package/dist/{shiki-highlighter-chunk-rkzofy4z.d.ts → shiki-highlighter-chunk-DNNm2Vow.d.ts} +1 -1
- package/dist/shiki-highlighter-chunk-DNNm2Vow.d.ts.map +1 -0
- package/dist/shiki-highlighter-chunk.d.ts +1 -1
- package/dist/shiki-highlighter-chunk.js.map +1 -1
- package/dist/{table-BRDh_9mG.js → table-4oHfV-Ql.js} +2 -2
- package/dist/table-4oHfV-Ql.js.map +1 -0
- package/package.json +28 -14
- package/src/autocomplete/autocomplete-helpers.ts +1 -5
- package/src/autocomplete/autocomplete-plugin.ts +3 -13
- package/src/autocomplete/autocomplete.spec.ts +4 -19
- package/src/autocomplete/autocomplete.ts +1 -7
- package/src/background-color/background-color-commands.spec.ts +71 -0
- package/src/background-color/background-color-commands.ts +35 -0
- package/src/background-color/background-color-spec.spec.ts +286 -0
- package/src/background-color/background-color-spec.ts +58 -0
- package/src/background-color/background-color.ts +21 -0
- package/src/background-color/index.ts +8 -0
- package/src/blockquote/blockquote-commands.ts +1 -7
- package/src/blockquote/blockquote-keymap.spec.ts +1 -5
- package/src/blockquote/blockquote-keymap.ts +1 -6
- package/src/blockquote/blockquote-spec.ts +1 -4
- package/src/blockquote/blockquote.ts +3 -12
- package/src/blockquote/index.ts +3 -12
- package/src/bold/bold-commands.ts +1 -5
- package/src/bold/bold-input-rule.spec.ts +1 -5
- package/src/bold/bold-input-rule.ts +1 -4
- package/src/bold/bold-keymap.ts +1 -5
- package/src/bold/bold-spec.ts +1 -4
- package/src/bold/bold.ts +3 -12
- package/src/bold/index.ts +3 -12
- package/src/code/code-commands.ts +1 -5
- package/src/code/code-input-rule.ts +1 -4
- package/src/code/code-keymap.ts +1 -5
- package/src/code/code-spec.ts +1 -4
- package/src/code/code.ts +3 -12
- package/src/code/index.ts +3 -12
- package/src/code-block/code-block-commands.ts +1 -8
- package/src/code-block/code-block-highlight.ts +2 -8
- package/src/code-block/code-block-keymap.ts +2 -9
- package/src/code-block/code-block-shiki.ts +1 -4
- package/src/code-block/code-block-spec.spec.ts +4 -11
- package/src/code-block/code-block-spec.ts +1 -4
- package/src/code-block/code-block.ts +4 -16
- package/src/code-block/index.ts +5 -21
- package/src/code-block/shiki-highlighter-chunk.ts +1 -7
- package/src/code-block/shiki-highlighter.ts +1 -4
- package/src/code-block/shiki-parser.ts +1 -4
- package/src/commit/index.ts +6 -35
- package/src/doc/index.ts +1 -4
- package/src/drop-cursor/drop-cursor.ts +1 -4
- package/src/drop-cursor/index.ts +1 -5
- package/src/drop-indicator/drop-indicator-facet.ts +12 -21
- package/src/drop-indicator/index.ts +1 -5
- package/src/enter-rule/index.ts +2 -11
- package/src/file/file-paste-handler.spec.ts +3 -16
- package/src/file/index.ts +3 -16
- package/src/gap-cursor/gap-cursor.ts +1 -4
- package/src/gap-cursor/index.ts +1 -4
- package/src/hard-break/hard-break-commands.ts +1 -5
- package/src/hard-break/hard-break-keymap.spec.ts +1 -5
- package/src/hard-break/hard-break-keymap.ts +1 -4
- package/src/hard-break/hard-break-spec.ts +1 -4
- package/src/hard-break/hard-break.ts +3 -12
- package/src/hard-break/index.ts +3 -12
- package/src/heading/heading-commands.ts +1 -7
- package/src/heading/heading-keymap.spec.ts +1 -5
- package/src/heading/heading-keymap.ts +1 -8
- package/src/heading/heading-spec.ts +1 -4
- package/src/heading/heading.ts +3 -12
- package/src/heading/index.ts +3 -12
- package/src/horizontal-rule/horizontal-rule-commands.spec.ts +1 -5
- package/src/horizontal-rule/horizontal-rule-commands.ts +2 -9
- package/src/horizontal-rule/horizontal-rule-input-rule.spec.ts +5 -9
- package/src/horizontal-rule/horizontal-rule-input-rule.ts +1 -5
- package/src/horizontal-rule/horizontal-rule-spec.ts +1 -4
- package/src/horizontal-rule/horizontal-rule.ts +3 -12
- package/src/horizontal-rule/index.ts +3 -13
- package/src/image/image-commands/upload-image.spec.ts +245 -0
- package/src/image/image-commands/upload-image.ts +46 -11
- package/src/image/image-commands.ts +2 -8
- package/src/image/image-spec.ts +1 -4
- package/src/image/image-upload-handler.ts +2 -8
- package/src/image/image.ts +3 -12
- package/src/image/index.ts +3 -13
- package/src/input-rule/index.ts +2 -13
- package/src/italic/index.ts +3 -12
- package/src/italic/italic-commands.spec.ts +2 -10
- package/src/italic/italic-commands.ts +1 -5
- package/src/italic/italic-input-rule.spec.ts +1 -5
- package/src/italic/italic-input-rule.ts +1 -4
- package/src/italic/italic-keymap.ts +1 -5
- package/src/italic/italic-spec.ts +1 -4
- package/src/italic/italic.ts +3 -12
- package/src/link/index.spec.ts +1 -5
- package/src/link/index.ts +1 -5
- package/src/link/link-paste-rule.spec.ts +2 -9
- package/src/link/link-regex.spec.ts +1 -5
- package/src/list/index.ts +3 -12
- package/src/list/list-commands.ts +1 -5
- package/src/list/list-input-rules.ts +1 -4
- package/src/list/list-keymap.spec.ts +1 -5
- package/src/list/list-keymap.ts +2 -8
- package/src/list/list-plugins.ts +1 -4
- package/src/list/list-serializer.ts +2 -9
- package/src/list/list-spec.ts +3 -13
- package/src/list/list.spec.ts +10 -21
- package/src/list/list.ts +3 -12
- package/src/loro/index.ts +3 -13
- package/src/loro/loro-commands.ts +2 -8
- package/src/loro/loro-cursor-plugin.ts +3 -13
- package/src/loro/loro-keymap.ts +2 -10
- package/src/loro/loro-sync-plugin.ts +2 -8
- package/src/loro/loro-undo-plugin.ts +2 -8
- package/src/loro/loro.ts +2 -11
- package/src/mark-rule/apply.ts +3 -13
- package/src/mark-rule/mark-rule.spec.ts +2 -13
- package/src/mark-rule/mark-rule.ts +2 -13
- package/src/mark-rule/range.ts +2 -8
- package/src/mark-rule/types.ts +1 -4
- package/src/mention/index.ts +1 -8
- package/src/mod-click-prevention/index.ts +2 -9
- package/src/paragraph/paragraph-commands.ts +1 -5
- package/src/paragraph/paragraph-keymap.ts +1 -4
- package/src/paragraph/paragraph-spec.ts +1 -4
- package/src/paragraph/paragraph.ts +3 -14
- package/src/paste-rule/index.ts +2 -10
- package/src/paste-rule/mark-paste-rule.spec.ts +3 -13
- package/src/paste-rule/mark-paste-rule.ts +4 -14
- package/src/paste-rule/paste-rule-plugin.ts +2 -11
- package/src/paste-rule/paste-rule.spec.ts +4 -19
- package/src/paste-rule/split-text-by-regex.spec.ts +1 -5
- package/src/placeholder/index.ts +3 -16
- package/src/readonly/index.ts +2 -8
- package/src/search/index.ts +1 -6
- package/src/table/index.ts +10 -40
- package/src/table/table-commands/delete-cell-selection.spec.ts +1 -5
- package/src/table/table-commands/exit-table.spec.ts +1 -5
- package/src/table/table-commands/insert-table.spec.ts +1 -5
- package/src/table/table-commands/insert-table.ts +1 -4
- package/src/table/table-commands/move-table-column.spec.ts +1 -5
- package/src/table/table-commands/move-table-column.ts +1 -4
- package/src/table/table-commands/move-table-row.spec.ts +1 -5
- package/src/table/table-commands/move-table-row.ts +1 -4
- package/src/table/table-commands/select-table-cell.spec.ts +1 -5
- package/src/table/table-commands/select-table-column.spec.ts +1 -5
- package/src/table/table-commands/select-table-row.spec.ts +1 -5
- package/src/table/table-commands/select-table.spec.ts +1 -5
- package/src/table/table-commands/select-table.ts +1 -4
- package/src/table/table-commands.ts +8 -32
- package/src/table/table-plugins.ts +2 -8
- package/src/table/table-spec.spec.ts +2 -11
- package/src/table/table-spec.ts +2 -8
- package/src/table/table-utils.ts +2 -6
- package/src/table/table.ts +2 -8
- package/src/table/test-utils.ts +1 -4
- package/src/testing/clipboard.ts +1 -2
- package/src/testing/index.ts +7 -12
- package/src/text/index.ts +1 -4
- package/src/text-align/index.ts +2 -2
- package/src/text-color/index.ts +3 -0
- package/src/text-color/text-color-commands.spec.ts +71 -0
- package/src/text-color/text-color-commands.ts +35 -0
- package/src/text-color/text-color-spec.spec.ts +297 -0
- package/src/text-color/text-color-spec.ts +58 -0
- package/src/text-color/text-color.ts +21 -0
- package/src/virtual-selection/index.ts +3 -14
- package/src/yjs/index.ts +5 -20
- package/src/yjs/yjs-commands.ts +2 -8
- package/src/yjs/yjs-cursor-plugin.ts +3 -5
- package/src/yjs/yjs-keymap.ts +2 -10
- package/src/yjs/yjs-sync-plugin.ts +1 -4
- package/src/yjs/yjs-types.ts +10 -0
- package/src/yjs/yjs-undo-plugin.ts +2 -8
- package/src/yjs/yjs.ts +6 -24
- package/dist/drop-indicator-B1QHFb5m.js.map +0 -1
- package/dist/enter-rule-CzWOZF_Z.js.map +0 -1
- package/dist/file-DrfcSid-.js.map +0 -1
- package/dist/index-oIc1a2f2.d.ts.map +0 -1
- package/dist/input-rule-dmsb3j6w.js.map +0 -1
- package/dist/mark-rule-BcLB4Uv2.js.map +0 -1
- package/dist/paste-rule-pVb4sqvJ.js.map +0 -1
- package/dist/shiki-highlighter-chunk-rkzofy4z.d.ts.map +0 -1
- package/dist/table-BRDh_9mG.js.map +0 -1
- package/src/testing/format-html.ts +0 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-4oHfV-Ql.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.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.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, TableMap } from 'prosemirror-tables'\n\nimport { findTable } from '../table-utils'\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 type { Command } from '@prosekit/pm/state'\nimport { CellSelection } from 'prosemirror-tables'\n\nimport { findCellPos } from '../table-utils'\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'\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'\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 { 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'\nimport { exitTable } from './table-commands/exit-table'\nimport { insertTable, type InsertTableOptions } from './table-commands/insert-table'\nimport { moveTableColumn, type MoveTableColumnOptions } from './table-commands/move-table-column'\nimport { moveTableRow, type MoveTableRowOptions } from './table-commands/move-table-row'\nimport { selectTable, type SelectTableOptions } from './table-commands/select-table'\nimport { selectTableCell, type SelectTableCellOptions } from './table-commands/select-table-cell'\nimport { selectTableColumn, type SelectTableColumnOptions } from './table-commands/select-table-column'\nimport { selectTableRow, type SelectTableRowOptions } from './table-commands/select-table-row'\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'\nimport { defineDropIndicator } from '../drop-indicator'\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'\nimport { defineTableDropIndicator } from './table-drop-indicator'\nimport { defineTablePlugins } from './table-plugins'\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'\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":"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"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prosekit/extensions",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.14.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "A collection of common extensions for ProseKit",
|
|
7
7
|
"author": {
|
|
@@ -34,6 +34,10 @@
|
|
|
34
34
|
"types": "./dist/prosekit-extensions-autocomplete.d.ts",
|
|
35
35
|
"default": "./dist/prosekit-extensions-autocomplete.js"
|
|
36
36
|
},
|
|
37
|
+
"./background-color": {
|
|
38
|
+
"types": "./dist/prosekit-extensions-background-color.d.ts",
|
|
39
|
+
"default": "./dist/prosekit-extensions-background-color.js"
|
|
40
|
+
},
|
|
37
41
|
"./blockquote": {
|
|
38
42
|
"types": "./dist/prosekit-extensions-blockquote.d.ts",
|
|
39
43
|
"default": "./dist/prosekit-extensions-blockquote.js"
|
|
@@ -183,6 +187,10 @@
|
|
|
183
187
|
"types": "./dist/prosekit-extensions-text-align.d.ts",
|
|
184
188
|
"default": "./dist/prosekit-extensions-text-align.js"
|
|
185
189
|
},
|
|
190
|
+
"./text-color": {
|
|
191
|
+
"types": "./dist/prosekit-extensions-text-color.d.ts",
|
|
192
|
+
"default": "./dist/prosekit-extensions-text-color.js"
|
|
193
|
+
},
|
|
186
194
|
"./underline": {
|
|
187
195
|
"types": "./dist/prosekit-extensions-underline.d.ts",
|
|
188
196
|
"default": "./dist/prosekit-extensions-underline.js"
|
|
@@ -207,7 +215,7 @@
|
|
|
207
215
|
"src"
|
|
208
216
|
],
|
|
209
217
|
"dependencies": {
|
|
210
|
-
"@ocavue/utils": "^1.
|
|
218
|
+
"@ocavue/utils": "^1.4.0",
|
|
211
219
|
"prosemirror-changeset": "^2.3.1",
|
|
212
220
|
"prosemirror-drop-indicator": "^0.1.3",
|
|
213
221
|
"prosemirror-dropcursor": "^1.8.2",
|
|
@@ -215,9 +223,9 @@
|
|
|
215
223
|
"prosemirror-gapcursor": "^1.4.0",
|
|
216
224
|
"prosemirror-highlight": "^0.13.0",
|
|
217
225
|
"prosemirror-search": "^1.1.0",
|
|
218
|
-
"prosemirror-tables": "^1.8.
|
|
219
|
-
"shiki": "^3.
|
|
220
|
-
"@prosekit/core": "^0.
|
|
226
|
+
"prosemirror-tables": "^1.8.5",
|
|
227
|
+
"shiki": "^3.22.0",
|
|
228
|
+
"@prosekit/core": "^0.10.0",
|
|
221
229
|
"@prosekit/pm": "^0.1.15"
|
|
222
230
|
},
|
|
223
231
|
"peerDependencies": {
|
|
@@ -241,26 +249,24 @@
|
|
|
241
249
|
}
|
|
242
250
|
},
|
|
243
251
|
"devDependencies": {
|
|
244
|
-
"
|
|
245
|
-
"diffable-html": "^6.0.1",
|
|
252
|
+
"diffable-html-snapshot": "^0.2.0",
|
|
246
253
|
"just-pick": "^4.2.0",
|
|
247
|
-
"loro-crdt": "^1.10.
|
|
248
|
-
"loro-prosemirror": "^0.4.
|
|
254
|
+
"loro-crdt": "^1.10.5",
|
|
255
|
+
"loro-prosemirror": "^0.4.2",
|
|
249
256
|
"rehype-parse": "^9.0.1",
|
|
250
257
|
"rehype-remark": "^10.0.1",
|
|
251
258
|
"remark-gfm": "^4.0.1",
|
|
252
259
|
"remark-html": "^16.0.1",
|
|
253
260
|
"remark-parse": "^11.0.0",
|
|
254
261
|
"remark-stringify": "^11.0.0",
|
|
255
|
-
"tsdown": "^0.
|
|
256
|
-
"type-fest": "^5.3
|
|
262
|
+
"tsdown": "^0.20.1",
|
|
263
|
+
"type-fest": "^5.4.3",
|
|
257
264
|
"typescript": "~5.9.3",
|
|
258
265
|
"unified": "^11.0.5",
|
|
259
|
-
"vitest": "^4.0.
|
|
266
|
+
"vitest": "^4.0.18",
|
|
260
267
|
"vitest-browser-commands": "^0.2.0",
|
|
261
268
|
"y-prosemirror": "^1.3.7",
|
|
262
|
-
"
|
|
263
|
-
"yjs": "^13.6.27",
|
|
269
|
+
"yjs": "^13.6.29",
|
|
264
270
|
"@prosekit/config-tsdown": "0.0.0",
|
|
265
271
|
"@prosekit/config-vitest": "0.0.0"
|
|
266
272
|
},
|
|
@@ -271,6 +277,7 @@
|
|
|
271
277
|
"entry": {
|
|
272
278
|
"prosekit-extensions": "./src/index.ts",
|
|
273
279
|
"prosekit-extensions-autocomplete": "./src/autocomplete/index.ts",
|
|
280
|
+
"prosekit-extensions-background-color": "./src/background-color/index.ts",
|
|
274
281
|
"prosekit-extensions-blockquote": "./src/blockquote/index.ts",
|
|
275
282
|
"prosekit-extensions-bold": "./src/bold/index.ts",
|
|
276
283
|
"prosekit-extensions-code": "./src/code/index.ts",
|
|
@@ -310,6 +317,7 @@
|
|
|
310
317
|
"table/style": "./src/table/style.css",
|
|
311
318
|
"prosekit-extensions-text": "./src/text/index.ts",
|
|
312
319
|
"prosekit-extensions-text-align": "./src/text-align/index.ts",
|
|
320
|
+
"prosekit-extensions-text-color": "./src/text-color/index.ts",
|
|
313
321
|
"prosekit-extensions-underline": "./src/underline/index.ts",
|
|
314
322
|
"prosekit-extensions-virtual-selection": "./src/virtual-selection/index.ts",
|
|
315
323
|
"virtual-selection/style": "./src/virtual-selection/style.css",
|
|
@@ -330,6 +338,9 @@
|
|
|
330
338
|
"autocomplete": [
|
|
331
339
|
"./dist/prosekit-extensions-autocomplete.d.ts"
|
|
332
340
|
],
|
|
341
|
+
"background-color": [
|
|
342
|
+
"./dist/prosekit-extensions-background-color.d.ts"
|
|
343
|
+
],
|
|
333
344
|
"blockquote": [
|
|
334
345
|
"./dist/prosekit-extensions-blockquote.d.ts"
|
|
335
346
|
],
|
|
@@ -426,6 +437,9 @@
|
|
|
426
437
|
"text-align": [
|
|
427
438
|
"./dist/prosekit-extensions-text-align.d.ts"
|
|
428
439
|
],
|
|
440
|
+
"text-color": [
|
|
441
|
+
"./dist/prosekit-extensions-text-color.d.ts"
|
|
442
|
+
],
|
|
429
443
|
"underline": [
|
|
430
444
|
"./dist/prosekit-extensions-underline.d.ts"
|
|
431
445
|
],
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import type { ResolvedPos } from '@prosekit/pm/model'
|
|
2
|
-
import {
|
|
3
|
-
PluginKey,
|
|
4
|
-
type EditorState,
|
|
5
|
-
type Transaction,
|
|
6
|
-
} from '@prosekit/pm/state'
|
|
2
|
+
import { PluginKey, type EditorState, type Transaction } from '@prosekit/pm/state'
|
|
7
3
|
|
|
8
4
|
import type { AutocompleteRule } from './autocomplete-rule'
|
|
9
5
|
|
|
@@ -1,19 +1,9 @@
|
|
|
1
1
|
import { OBJECT_REPLACEMENT_CHARACTER } from '@prosekit/core'
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
ResolvedPos,
|
|
5
|
-
} from '@prosekit/pm/model'
|
|
6
|
-
import {
|
|
7
|
-
Plugin,
|
|
8
|
-
type EditorState,
|
|
9
|
-
type Transaction,
|
|
10
|
-
} from '@prosekit/pm/state'
|
|
2
|
+
import type { ProseMirrorNode, ResolvedPos } from '@prosekit/pm/model'
|
|
3
|
+
import { Plugin, type EditorState, type Transaction } from '@prosekit/pm/state'
|
|
11
4
|
import type { Mapping } from '@prosekit/pm/transform'
|
|
12
5
|
import type { EditorView } from '@prosekit/pm/view'
|
|
13
|
-
import {
|
|
14
|
-
Decoration,
|
|
15
|
-
DecorationSet,
|
|
16
|
-
} from '@prosekit/pm/view'
|
|
6
|
+
import { Decoration, DecorationSet } from '@prosekit/pm/view'
|
|
17
7
|
|
|
18
8
|
import {
|
|
19
9
|
getPluginState,
|
|
@@ -1,27 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
union,
|
|
4
|
-
} from '@prosekit/core'
|
|
5
|
-
import {
|
|
6
|
-
describe,
|
|
7
|
-
expect,
|
|
8
|
-
it,
|
|
9
|
-
vi,
|
|
10
|
-
} from 'vitest'
|
|
1
|
+
import { canUseRegexLookbehind, union } from '@prosekit/core'
|
|
2
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
11
3
|
import { keyboard } from 'vitest-browser-commands/playwright'
|
|
12
4
|
|
|
13
|
-
import {
|
|
14
|
-
defineTestExtension,
|
|
15
|
-
setupTestFromExtension,
|
|
16
|
-
} from '../testing'
|
|
5
|
+
import { defineTestExtension, setupTestFromExtension } from '../testing'
|
|
17
6
|
import { inputText } from '../testing/keyboard'
|
|
18
7
|
|
|
19
8
|
import { defineAutocomplete } from './autocomplete'
|
|
20
|
-
import {
|
|
21
|
-
AutocompleteRule,
|
|
22
|
-
type MatchHandler,
|
|
23
|
-
type MatchHandlerOptions,
|
|
24
|
-
} from './autocomplete-rule'
|
|
9
|
+
import { AutocompleteRule, type MatchHandler, type MatchHandlerOptions } from './autocomplete-rule'
|
|
25
10
|
|
|
26
11
|
function setupSlashMenu() {
|
|
27
12
|
const regex = canUseRegexLookbehind() ? /(?<!\S)\/(\S.*)?$/u : /\/(\S.*)?$/u
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
defineFacet,
|
|
3
|
-
defineFacetPayload,
|
|
4
|
-
pluginFacet,
|
|
5
|
-
type Extension,
|
|
6
|
-
type PluginPayload,
|
|
7
|
-
} from '@prosekit/core'
|
|
1
|
+
import { defineFacet, defineFacetPayload, pluginFacet, type Extension, type PluginPayload } from '@prosekit/core'
|
|
8
2
|
|
|
9
3
|
import { createAutocompletePlugin } from './autocomplete-plugin'
|
|
10
4
|
import type { AutocompleteRule } from './autocomplete-rule'
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
|
|
3
|
+
import { setupTest } from '../testing'
|
|
4
|
+
|
|
5
|
+
describe('addBackgroundColor', () => {
|
|
6
|
+
it('can add background color to text', () => {
|
|
7
|
+
const { editor, n, m } = setupTest()
|
|
8
|
+
|
|
9
|
+
const doc1 = n.doc(
|
|
10
|
+
n.p('Hello <a>world<b>'),
|
|
11
|
+
)
|
|
12
|
+
const doc2 = n.doc(
|
|
13
|
+
n.p('Hello ', m.backgroundColor({ color: 'red' }, 'world')),
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
editor.set(doc1)
|
|
17
|
+
editor.commands.addBackgroundColor({ color: 'red' })
|
|
18
|
+
expect(editor.getDocJSON()).toEqual(doc2.toJSON())
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('can override existing background color', () => {
|
|
22
|
+
const { editor, n, m } = setupTest()
|
|
23
|
+
|
|
24
|
+
const doc1 = n.doc(
|
|
25
|
+
n.p(
|
|
26
|
+
'A',
|
|
27
|
+
m.backgroundColor({ color: 'red' }, 'B<a>C'),
|
|
28
|
+
m.backgroundColor({ color: 'red' }, 'DE'),
|
|
29
|
+
'F<b>G',
|
|
30
|
+
),
|
|
31
|
+
)
|
|
32
|
+
const doc2 = n.doc(
|
|
33
|
+
n.p(
|
|
34
|
+
'A',
|
|
35
|
+
m.backgroundColor({ color: 'red' }, 'B'),
|
|
36
|
+
m.backgroundColor({ color: 'blue' }, 'CDEF'),
|
|
37
|
+
'G',
|
|
38
|
+
),
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
editor.set(doc1)
|
|
42
|
+
editor.commands.addBackgroundColor({ color: 'blue' })
|
|
43
|
+
expect(editor.getDocJSON()).toEqual(doc2.toJSON())
|
|
44
|
+
})
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
describe('removeBackgroundColor', () => {
|
|
48
|
+
it('can remove background color from text', () => {
|
|
49
|
+
const { editor, n, m } = setupTest()
|
|
50
|
+
|
|
51
|
+
const doc1 = n.doc(
|
|
52
|
+
n.p(
|
|
53
|
+
'A',
|
|
54
|
+
m.backgroundColor({ color: 'red' }, 'B<a>C'),
|
|
55
|
+
m.backgroundColor({ color: 'blue' }, 'DE'),
|
|
56
|
+
'F<b>G',
|
|
57
|
+
),
|
|
58
|
+
)
|
|
59
|
+
const doc2 = n.doc(
|
|
60
|
+
n.p(
|
|
61
|
+
'A',
|
|
62
|
+
m.backgroundColor({ color: 'red' }, 'B'),
|
|
63
|
+
'CDEFG',
|
|
64
|
+
),
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
editor.set(doc1)
|
|
68
|
+
editor.commands.removeBackgroundColor()
|
|
69
|
+
expect(editor.getDocJSON()).toEqual(doc2.toJSON())
|
|
70
|
+
})
|
|
71
|
+
})
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { addMark, defineCommands, removeMark, type Extension } from '@prosekit/core'
|
|
2
|
+
import type { Command } from '@prosekit/pm/state'
|
|
3
|
+
|
|
4
|
+
import type { BackgroundColorAttrs } from './background-color-spec'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export function addBackgroundColor(attrs: BackgroundColorAttrs): Command {
|
|
10
|
+
return addMark({ type: 'backgroundColor', attrs })
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export function removeBackgroundColor(): Command {
|
|
17
|
+
return removeMark({ type: 'backgroundColor' })
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
export type BackgroundColorCommandsExtension = Extension<{
|
|
24
|
+
Commands: {
|
|
25
|
+
addBackgroundColor: [attrs: BackgroundColorAttrs]
|
|
26
|
+
removeBackgroundColor: []
|
|
27
|
+
}
|
|
28
|
+
}>
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
export function defineBackgroundColorCommands(): BackgroundColorCommandsExtension {
|
|
34
|
+
return defineCommands({ addBackgroundColor, removeBackgroundColor })
|
|
35
|
+
}
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import { formatHTML } from 'diffable-html-snapshot'
|
|
2
|
+
import { describe, expect, it } from 'vitest'
|
|
3
|
+
|
|
4
|
+
import { setupTest } from '../testing'
|
|
5
|
+
|
|
6
|
+
describe('defineBackgroundColorSpec', () => {
|
|
7
|
+
it('should render background color as inline span with style attribute', () => {
|
|
8
|
+
const { editor, n, m } = setupTest()
|
|
9
|
+
|
|
10
|
+
const doc = n.doc(
|
|
11
|
+
n.p(
|
|
12
|
+
'Default',
|
|
13
|
+
m.backgroundColor({ color: '#0000ff' }, 'hex'),
|
|
14
|
+
m.backgroundColor({ color: 'blue' }, 'named'),
|
|
15
|
+
m.backgroundColor({ color: 'rgb(0, 0, 255)' }, 'rgb'),
|
|
16
|
+
m.backgroundColor({ color: 'rgba(0 0 255 / 0.5)' }, 'rgba'),
|
|
17
|
+
m.backgroundColor({ color: 'hsl(240 100% 50% / 0.5)' }, 'hsl'),
|
|
18
|
+
m.backgroundColor({ color: 'var(--color-variable)' }, 'variable'),
|
|
19
|
+
),
|
|
20
|
+
)
|
|
21
|
+
editor.set(doc)
|
|
22
|
+
expect(formatHTML(editor.view.dom.innerHTML)).toMatchInlineSnapshot(
|
|
23
|
+
`
|
|
24
|
+
"
|
|
25
|
+
<p>
|
|
26
|
+
Default
|
|
27
|
+
<span
|
|
28
|
+
data-background-color="#0000ff"
|
|
29
|
+
style="background-color: rgb(0, 0, 255);"
|
|
30
|
+
>
|
|
31
|
+
hex
|
|
32
|
+
</span>
|
|
33
|
+
<span
|
|
34
|
+
data-background-color="blue"
|
|
35
|
+
style="background-color: blue;"
|
|
36
|
+
>
|
|
37
|
+
named
|
|
38
|
+
</span>
|
|
39
|
+
<span
|
|
40
|
+
data-background-color="rgb(0, 0, 255)"
|
|
41
|
+
style="background-color: rgb(0, 0, 255);"
|
|
42
|
+
>
|
|
43
|
+
rgb
|
|
44
|
+
</span>
|
|
45
|
+
<span
|
|
46
|
+
data-background-color="rgba(0 0 255 / 0.5)"
|
|
47
|
+
style="background-color: rgba(0, 0, 255, 0.5);"
|
|
48
|
+
>
|
|
49
|
+
rgba
|
|
50
|
+
</span>
|
|
51
|
+
<span
|
|
52
|
+
data-background-color="hsl(240 100% 50% / 0.5)"
|
|
53
|
+
style="background-color: rgba(0, 0, 255, 0.5);"
|
|
54
|
+
>
|
|
55
|
+
hsl
|
|
56
|
+
</span>
|
|
57
|
+
<span
|
|
58
|
+
data-background-color="var(--color-variable)"
|
|
59
|
+
style="background-color: var(--color-variable);"
|
|
60
|
+
>
|
|
61
|
+
variable
|
|
62
|
+
</span>
|
|
63
|
+
</p>
|
|
64
|
+
"
|
|
65
|
+
`,
|
|
66
|
+
)
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
it('should parse background color from style attribute', () => {
|
|
70
|
+
const { editor } = setupTest()
|
|
71
|
+
|
|
72
|
+
const html = `<p><span style="background-color: #0000ff;">text</span></p>`
|
|
73
|
+
editor.setContent(html)
|
|
74
|
+
expect(editor.state.doc.firstChild?.firstChild?.toJSON()).toMatchInlineSnapshot(`
|
|
75
|
+
{
|
|
76
|
+
"marks": [
|
|
77
|
+
{
|
|
78
|
+
"attrs": {
|
|
79
|
+
"color": "rgb(0, 0, 255)",
|
|
80
|
+
},
|
|
81
|
+
"type": "backgroundColor",
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
"text": "text",
|
|
85
|
+
"type": "text",
|
|
86
|
+
}
|
|
87
|
+
`)
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
it('should parse background color from data-background-color attribute', () => {
|
|
91
|
+
const { editor } = setupTest()
|
|
92
|
+
|
|
93
|
+
const html = `<p><span data-background-color="rgb(0 0 255 / 0.5)">text</span></p>`
|
|
94
|
+
editor.setContent(html)
|
|
95
|
+
expect(editor.state.doc.firstChild?.firstChild?.toJSON()).toMatchInlineSnapshot(`
|
|
96
|
+
{
|
|
97
|
+
"marks": [
|
|
98
|
+
{
|
|
99
|
+
"attrs": {
|
|
100
|
+
"color": "rgb(0 0 255 / 0.5)",
|
|
101
|
+
},
|
|
102
|
+
"type": "backgroundColor",
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
"text": "text",
|
|
106
|
+
"type": "text",
|
|
107
|
+
}
|
|
108
|
+
`)
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
it('should prioritize data-background-color attribute over style attribute', () => {
|
|
112
|
+
const { editor } = setupTest()
|
|
113
|
+
|
|
114
|
+
const html = `<p><span style="background-color: blue;" data-background-color="red">This should be red</span></p>`
|
|
115
|
+
editor.setContent(html)
|
|
116
|
+
expect(editor.state.doc.firstChild?.firstChild?.toJSON()).toMatchInlineSnapshot(`
|
|
117
|
+
{
|
|
118
|
+
"marks": [
|
|
119
|
+
{
|
|
120
|
+
"attrs": {
|
|
121
|
+
"color": "red",
|
|
122
|
+
},
|
|
123
|
+
"type": "backgroundColor",
|
|
124
|
+
},
|
|
125
|
+
],
|
|
126
|
+
"text": "This should be red",
|
|
127
|
+
"type": "text",
|
|
128
|
+
}
|
|
129
|
+
`)
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
it('should not parse span with background-color: inherit', () => {
|
|
133
|
+
const { editor } = setupTest()
|
|
134
|
+
|
|
135
|
+
const html = '<p><span style="background-color: inherit">text</span></p>'
|
|
136
|
+
editor.setContent(html)
|
|
137
|
+
expect(editor.state.doc.firstChild?.firstChild?.toJSON()).toMatchInlineSnapshot(`
|
|
138
|
+
{
|
|
139
|
+
"text": "text",
|
|
140
|
+
"type": "text",
|
|
141
|
+
}
|
|
142
|
+
`)
|
|
143
|
+
|
|
144
|
+
const html2 = '<p><span data-background-color="inherit">text</span></p>'
|
|
145
|
+
editor.setContent(html2)
|
|
146
|
+
expect(editor.state.doc.firstChild?.firstChild?.toJSON()).toMatchInlineSnapshot(`
|
|
147
|
+
{
|
|
148
|
+
"text": "text",
|
|
149
|
+
"type": "text",
|
|
150
|
+
}
|
|
151
|
+
`)
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
it('should preserve both background-color and text-color marks', () => {
|
|
155
|
+
const { editor, n, m } = setupTest()
|
|
156
|
+
|
|
157
|
+
const doc = n.doc(
|
|
158
|
+
n.p(
|
|
159
|
+
m.backgroundColor(
|
|
160
|
+
{ color: 'yellow' },
|
|
161
|
+
m.textColor({ color: 'red' }, 'colored text'),
|
|
162
|
+
),
|
|
163
|
+
),
|
|
164
|
+
)
|
|
165
|
+
editor.set(doc)
|
|
166
|
+
expect(formatHTML(editor.view.dom.innerHTML)).toMatchInlineSnapshot(
|
|
167
|
+
`
|
|
168
|
+
"
|
|
169
|
+
<p>
|
|
170
|
+
<span
|
|
171
|
+
data-background-color="yellow"
|
|
172
|
+
style="background-color: yellow;"
|
|
173
|
+
>
|
|
174
|
+
<span
|
|
175
|
+
data-text-color="red"
|
|
176
|
+
style="color: red;"
|
|
177
|
+
>
|
|
178
|
+
colored text
|
|
179
|
+
</span>
|
|
180
|
+
</span>
|
|
181
|
+
</p>
|
|
182
|
+
"
|
|
183
|
+
`,
|
|
184
|
+
)
|
|
185
|
+
})
|
|
186
|
+
|
|
187
|
+
it('should preserve background-color mark when parsing HTML with both marks', () => {
|
|
188
|
+
const { editor } = setupTest()
|
|
189
|
+
|
|
190
|
+
const html = '<p>'
|
|
191
|
+
+ '<span style="background-color: yellow;">'
|
|
192
|
+
+ '<span style="color: red;">colored text</span>'
|
|
193
|
+
+ '</span>'
|
|
194
|
+
+ '</p>'
|
|
195
|
+
|
|
196
|
+
editor.setContent(html)
|
|
197
|
+
expect(editor.state.doc.firstChild?.firstChild?.toJSON()).toMatchInlineSnapshot(`
|
|
198
|
+
{
|
|
199
|
+
"marks": [
|
|
200
|
+
{
|
|
201
|
+
"attrs": {
|
|
202
|
+
"color": "yellow",
|
|
203
|
+
},
|
|
204
|
+
"type": "backgroundColor",
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
"attrs": {
|
|
208
|
+
"color": "red",
|
|
209
|
+
},
|
|
210
|
+
"type": "textColor",
|
|
211
|
+
},
|
|
212
|
+
],
|
|
213
|
+
"text": "colored text",
|
|
214
|
+
"type": "text",
|
|
215
|
+
}
|
|
216
|
+
`)
|
|
217
|
+
})
|
|
218
|
+
|
|
219
|
+
it('should handle background color on partial text selection', () => {
|
|
220
|
+
const { editor, n, m } = setupTest()
|
|
221
|
+
|
|
222
|
+
const doc = n.doc(
|
|
223
|
+
n.p(
|
|
224
|
+
'Start ',
|
|
225
|
+
m.backgroundColor({ color: 'yellow' }, 'highlighted'),
|
|
226
|
+
' end',
|
|
227
|
+
),
|
|
228
|
+
)
|
|
229
|
+
editor.set(doc)
|
|
230
|
+
expect(formatHTML(editor.view.dom.innerHTML)).toMatchInlineSnapshot(
|
|
231
|
+
`
|
|
232
|
+
"
|
|
233
|
+
<p>
|
|
234
|
+
Start
|
|
235
|
+
<span
|
|
236
|
+
data-background-color="yellow"
|
|
237
|
+
style="background-color: yellow;"
|
|
238
|
+
>
|
|
239
|
+
highlighted
|
|
240
|
+
</span>
|
|
241
|
+
end
|
|
242
|
+
</p>
|
|
243
|
+
"
|
|
244
|
+
`,
|
|
245
|
+
)
|
|
246
|
+
})
|
|
247
|
+
|
|
248
|
+
it('should handle multiple adjacent background colors', () => {
|
|
249
|
+
const { editor, n, m } = setupTest()
|
|
250
|
+
|
|
251
|
+
const doc = n.doc(
|
|
252
|
+
n.p(
|
|
253
|
+
m.backgroundColor({ color: 'yellow' }, 'yellow'),
|
|
254
|
+
m.backgroundColor({ color: 'green' }, 'green'),
|
|
255
|
+
m.backgroundColor({ color: 'blue' }, 'blue'),
|
|
256
|
+
),
|
|
257
|
+
)
|
|
258
|
+
editor.set(doc)
|
|
259
|
+
expect(formatHTML(editor.view.dom.innerHTML)).toMatchInlineSnapshot(
|
|
260
|
+
`
|
|
261
|
+
"
|
|
262
|
+
<p>
|
|
263
|
+
<span
|
|
264
|
+
data-background-color="yellow"
|
|
265
|
+
style="background-color: yellow;"
|
|
266
|
+
>
|
|
267
|
+
yellow
|
|
268
|
+
</span>
|
|
269
|
+
<span
|
|
270
|
+
data-background-color="green"
|
|
271
|
+
style="background-color: green;"
|
|
272
|
+
>
|
|
273
|
+
green
|
|
274
|
+
</span>
|
|
275
|
+
<span
|
|
276
|
+
data-background-color="blue"
|
|
277
|
+
style="background-color: blue;"
|
|
278
|
+
>
|
|
279
|
+
blue
|
|
280
|
+
</span>
|
|
281
|
+
</p>
|
|
282
|
+
"
|
|
283
|
+
`,
|
|
284
|
+
)
|
|
285
|
+
})
|
|
286
|
+
})
|