@prosekit/extensions 0.14.1 → 0.14.2
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-DJq8pF92.js.map +1 -1
- package/dist/file-upload-I9m1EJAM.js.map +1 -1
- package/dist/{mark-paste-rule-n_2Ehmb5.js → mark-paste-rule--F1QPUcU.js} +2 -2
- package/dist/mark-paste-rule--F1QPUcU.js.map +1 -0
- package/dist/{mark-rule-CUnXwBuy.js → mark-rule-Bqdm49Eq.js} +2 -2
- package/dist/mark-rule-Bqdm49Eq.js.map +1 -0
- package/dist/prosekit-extensions-autocomplete.d.ts +1 -1
- package/dist/prosekit-extensions-autocomplete.js +17 -17
- package/dist/prosekit-extensions-autocomplete.js.map +1 -1
- package/dist/prosekit-extensions-background-color.d.ts +1 -1
- package/dist/prosekit-extensions-background-color.js.map +1 -1
- package/dist/prosekit-extensions-blockquote.d.ts +13 -13
- package/dist/prosekit-extensions-blockquote.d.ts.map +1 -1
- package/dist/prosekit-extensions-blockquote.js +5 -4
- package/dist/prosekit-extensions-blockquote.js.map +1 -1
- package/dist/prosekit-extensions-bold.d.ts +12 -12
- package/dist/prosekit-extensions-bold.d.ts.map +1 -1
- package/dist/prosekit-extensions-bold.js.map +1 -1
- package/dist/prosekit-extensions-code-block.d.ts +52 -35
- package/dist/prosekit-extensions-code-block.d.ts.map +1 -1
- package/dist/prosekit-extensions-code-block.js +76 -70
- package/dist/prosekit-extensions-code-block.js.map +1 -1
- package/dist/prosekit-extensions-code.d.ts +12 -12
- package/dist/prosekit-extensions-code.d.ts.map +1 -1
- package/dist/prosekit-extensions-code.js.map +1 -1
- package/dist/prosekit-extensions-commit.d.ts +1 -1
- package/dist/prosekit-extensions-commit.js +1 -1
- package/dist/prosekit-extensions-enter-rule.d.ts +2 -2
- package/dist/prosekit-extensions-enter-rule.d.ts.map +1 -1
- package/dist/prosekit-extensions-enter-rule.js.map +1 -1
- package/dist/prosekit-extensions-hard-break.d.ts +7 -7
- 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 +15 -15
- package/dist/prosekit-extensions-heading.d.ts.map +1 -1
- package/dist/prosekit-extensions-heading.js.map +1 -1
- package/dist/prosekit-extensions-horizontal-rule.d.ts +7 -7
- package/dist/prosekit-extensions-horizontal-rule.d.ts.map +1 -1
- package/dist/prosekit-extensions-horizontal-rule.js +10 -9
- package/dist/prosekit-extensions-horizontal-rule.js.map +1 -1
- package/dist/prosekit-extensions-image.d.ts +11 -11
- package/dist/prosekit-extensions-image.d.ts.map +1 -1
- package/dist/prosekit-extensions-image.js +9 -9
- package/dist/prosekit-extensions-image.js.map +1 -1
- package/dist/prosekit-extensions-italic.d.ts +12 -12
- package/dist/prosekit-extensions-italic.d.ts.map +1 -1
- package/dist/prosekit-extensions-italic.js.map +1 -1
- package/dist/prosekit-extensions-link.js +2 -2
- package/dist/prosekit-extensions-link.js.map +1 -1
- package/dist/prosekit-extensions-list.d.ts +26 -26
- package/dist/prosekit-extensions-list.d.ts.map +1 -1
- package/dist/prosekit-extensions-list.js +25 -25
- package/dist/prosekit-extensions-list.js.map +1 -1
- package/dist/prosekit-extensions-loro.d.ts +16 -16
- package/dist/prosekit-extensions-loro.d.ts.map +1 -1
- package/dist/prosekit-extensions-loro.js.map +1 -1
- package/dist/prosekit-extensions-mark-rule.js +1 -1
- package/dist/prosekit-extensions-math.d.ts +3 -3
- package/dist/prosekit-extensions-math.d.ts.map +1 -1
- package/dist/prosekit-extensions-math.js +4 -0
- package/dist/prosekit-extensions-math.js.map +1 -1
- package/dist/prosekit-extensions-mod-click-prevention.js +1 -1
- package/dist/prosekit-extensions-paragraph.d.ts +7 -7
- 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.js +1 -1
- package/dist/prosekit-extensions-placeholder.d.ts +1 -1
- package/dist/prosekit-extensions-placeholder.js +2 -2
- package/dist/prosekit-extensions-placeholder.js.map +1 -1
- package/dist/prosekit-extensions-readonly.js +1 -1
- package/dist/prosekit-extensions-strike.js.map +1 -1
- package/dist/prosekit-extensions-table.d.ts +47 -47
- 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 +1 -1
- package/dist/prosekit-extensions-text-color.d.ts +1 -1
- package/dist/prosekit-extensions-text-color.js.map +1 -1
- package/dist/prosekit-extensions-virtual-selection.js +1 -1
- package/dist/prosekit-extensions-yjs.d.ts +3 -3
- package/dist/prosekit-extensions-yjs.d.ts.map +1 -1
- package/dist/prosekit-extensions-yjs.js.map +1 -1
- package/dist/{table-UJVYsrB7.js → table-B81i9oH9.js} +28 -28
- package/dist/table-B81i9oH9.js.map +1 -0
- package/package.json +8 -7
- package/src/autocomplete/autocomplete-helpers.ts +1 -1
- package/src/autocomplete/autocomplete-plugin.ts +2 -2
- package/src/autocomplete/autocomplete-rule.ts +1 -1
- package/src/autocomplete/autocomplete.spec.ts +4 -4
- package/src/autocomplete/autocomplete.ts +2 -2
- package/src/autocomplete/index.ts +2 -2
- package/src/background-color/background-color-commands.spec.ts +1 -1
- package/src/background-color/background-color-commands.ts +1 -1
- package/src/background-color/background-color-spec.spec.ts +1 -1
- package/src/background-color/background-color.ts +2 -2
- package/src/background-color/index.ts +3 -3
- package/src/blockquote/blockquote-input-rule.ts +1 -1
- package/src/blockquote/blockquote-keymap.spec.ts +1 -1
- package/src/blockquote/blockquote-keymap.ts +9 -7
- package/src/blockquote/blockquote.ts +4 -4
- package/src/blockquote/index.ts +5 -5
- package/src/bold/bold-input-rule.spec.ts +2 -2
- package/src/bold/bold-input-rule.ts +1 -1
- package/src/bold/bold.ts +4 -4
- package/src/bold/index.ts +5 -5
- package/src/code/code-input-rule.ts +1 -1
- package/src/code/code.ts +4 -4
- package/src/code/index.ts +5 -5
- package/src/code-block/code-block-commands.ts +1 -1
- package/src/code-block/code-block-highlight.ts +11 -1
- package/src/code-block/code-block-input-rule.ts +3 -3
- package/src/code-block/code-block-shiki.ts +13 -5
- package/src/code-block/code-block-spec.spec.ts +2 -2
- package/src/code-block/code-block-spec.ts +1 -1
- package/src/code-block/code-block.ts +4 -4
- package/src/code-block/index.ts +9 -9
- package/src/code-block/shiki-highlighter.ts +2 -2
- package/src/code-block/shiki-parser.ts +2 -2
- package/src/drop-cursor/index.ts +1 -1
- package/src/drop-indicator/drop-indicator.ts +1 -1
- package/src/drop-indicator/index.ts +1 -1
- package/src/enter-rule/index.ts +3 -3
- package/src/file/file-drop-handler.ts +1 -1
- package/src/file/file-paste-handler.spec.ts +3 -3
- package/src/file/file-paste-handler.ts +1 -1
- package/src/file/index.ts +3 -3
- package/src/gap-cursor/index.ts +1 -1
- package/src/hard-break/hard-break-keymap.spec.ts +2 -2
- package/src/hard-break/hard-break-keymap.ts +1 -1
- package/src/hard-break/hard-break.ts +3 -3
- package/src/hard-break/index.ts +4 -4
- package/src/heading/heading-commands.ts +1 -1
- package/src/heading/heading-input-rule.ts +2 -2
- package/src/heading/heading-keymap.spec.ts +1 -1
- package/src/heading/heading-spec.ts +1 -1
- package/src/heading/heading.ts +4 -4
- package/src/heading/index.ts +6 -6
- package/src/horizontal-rule/horizontal-rule-commands.spec.ts +1 -1
- package/src/horizontal-rule/horizontal-rule-commands.ts +13 -11
- package/src/horizontal-rule/horizontal-rule-input-rule.spec.ts +2 -2
- package/src/horizontal-rule/horizontal-rule-input-rule.ts +1 -1
- package/src/horizontal-rule/horizontal-rule.ts +3 -3
- package/src/horizontal-rule/index.ts +4 -4
- package/src/image/image-commands/insert-image.ts +1 -1
- package/src/image/image-commands/upload-image.spec.ts +4 -4
- package/src/image/image-commands/upload-image.ts +2 -2
- package/src/image/image-commands.ts +3 -3
- package/src/image/image-upload-handler.ts +2 -2
- package/src/image/image.ts +2 -2
- package/src/image/index.ts +6 -6
- package/src/italic/index.ts +5 -5
- package/src/italic/italic-commands.spec.ts +4 -4
- package/src/italic/italic-input-rule.spec.ts +2 -2
- package/src/italic/italic-input-rule.ts +1 -1
- package/src/italic/italic.ts +4 -4
- package/src/link/index.spec.ts +2 -2
- package/src/link/index.ts +6 -6
- package/src/link/link-paste-rule.spec.ts +2 -2
- package/src/link/link-paste-rule.ts +3 -3
- package/src/link/link-regex.spec.ts +1 -1
- package/src/list/index.ts +8 -8
- package/src/list/list-drop-indicator.ts +2 -2
- package/src/list/list-input-rules.ts +1 -1
- package/src/list/list-keymap.spec.ts +1 -1
- package/src/list/list-spec.ts +1 -1
- package/src/list/list-types.spec.ts +2 -2
- package/src/list/list.spec.ts +6 -6
- package/src/list/list.ts +7 -7
- package/src/loro/index.ts +6 -6
- package/src/loro/loro.ts +5 -5
- package/src/mark-rule/apply.ts +2 -2
- package/src/mark-rule/index.ts +2 -2
- package/src/mark-rule/mark-rule.spec.ts +4 -4
- package/src/mark-rule/mark-rule.ts +2 -2
- package/src/math/index.ts +4 -4
- package/src/math/math-block.ts +8 -1
- package/src/math/math-inline.ts +1 -1
- package/src/math/math.ts +3 -3
- package/src/paragraph/index.ts +7 -7
- package/src/paragraph/paragraph-keymap.ts +1 -1
- package/src/paragraph/paragraph.ts +3 -3
- package/src/paste-rule/index.ts +2 -2
- package/src/paste-rule/mark-paste-rule.spec.ts +8 -8
- package/src/paste-rule/mark-paste-rule.ts +2 -2
- package/src/paste-rule/paste-rule.spec.ts +2 -2
- package/src/paste-rule/paste-rule.ts +1 -1
- package/src/paste-rule/split-text-by-regex.spec.ts +1 -1
- package/src/placeholder/index.ts +1 -1
- package/src/strike/index.ts +1 -1
- package/src/table/index.ts +14 -14
- package/src/table/table-commands/delete-cell-selection.spec.ts +3 -3
- package/src/table/table-commands/exit-table.spec.ts +2 -2
- package/src/table/table-commands/insert-table.spec.ts +1 -1
- package/src/table/table-commands/move-table-column.spec.ts +2 -2
- package/src/table/table-commands/move-table-row.spec.ts +2 -2
- package/src/table/table-commands/select-table-cell.spec.ts +3 -3
- package/src/table/table-commands/select-table-cell.ts +1 -1
- package/src/table/table-commands/select-table-column.spec.ts +2 -2
- package/src/table/table-commands/select-table-column.ts +1 -1
- package/src/table/table-commands/select-table-row.spec.ts +2 -2
- package/src/table/table-commands/select-table-row.ts +1 -1
- package/src/table/table-commands/select-table.spec.ts +2 -2
- package/src/table/table-commands/select-table.ts +1 -1
- package/src/table/table-commands.ts +9 -9
- package/src/table/table-drop-indicator.ts +2 -2
- package/src/table/table-spec.spec.ts +4 -4
- package/src/table/table.ts +4 -4
- package/src/table/test-utils.ts +1 -1
- package/src/testing/index.ts +24 -24
- package/src/text-color/index.ts +3 -3
- package/src/text-color/text-color-commands.spec.ts +1 -1
- package/src/text-color/text-color-commands.ts +1 -1
- package/src/text-color/text-color-spec.spec.ts +1 -1
- package/src/text-color/text-color.ts +2 -2
- package/src/yjs/index.ts +7 -7
- package/src/yjs/yjs-cursor-plugin.ts +1 -1
- package/src/yjs/yjs-undo-plugin.ts +3 -2
- package/src/yjs/yjs.ts +6 -6
- package/dist/mark-paste-rule-n_2Ehmb5.js.map +0 -1
- package/dist/mark-rule-CUnXwBuy.js.map +0 -1
- package/dist/table-UJVYsrB7.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as defineDropIndicator } from "./drop-indicator-DJq8pF92.js";
|
|
2
|
-
import { defaultBlockAt, defineCommands, defineNodeSpec, definePlugin, getNodeType, insertNode, union } from "@prosekit/core";
|
|
3
2
|
import { TextSelection } from "@prosekit/pm/state";
|
|
3
|
+
import { defaultBlockAt, defineCommands, defineNodeSpec, definePlugin, getNodeType, insertNode, union } from "@prosekit/core";
|
|
4
4
|
import { CellSelection, TableMap, addColumnAfter, addColumnBefore, addRowAfter, addRowBefore, columnResizing, deleteCellSelection, deleteColumn, deleteRow, deleteTable, findCellPos, findCellRange, findTable, mergeCells, moveTableColumn, moveTableRow, splitCell, tableEditing, tableNodes } from "prosemirror-tables";
|
|
5
5
|
|
|
6
6
|
//#region src/table/table-commands/exit-table.ts
|
|
@@ -82,31 +82,6 @@ function isCellSelection(value) {
|
|
|
82
82
|
return value instanceof CellSelection;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
//#endregion
|
|
86
|
-
//#region src/table/table-commands/select-table.ts
|
|
87
|
-
/**
|
|
88
|
-
* @public
|
|
89
|
-
*/
|
|
90
|
-
function selectTable(options) {
|
|
91
|
-
return (state, dispatch) => {
|
|
92
|
-
const table = findTable(options?.pos ? state.doc.resolve(options.pos) : state.selection.$anchor);
|
|
93
|
-
if (!table) return false;
|
|
94
|
-
const map = TableMap.get(table.node);
|
|
95
|
-
if (map.map.length === 0) return false;
|
|
96
|
-
if (dispatch) {
|
|
97
|
-
let tr = state.tr;
|
|
98
|
-
const firstCellPosInTable = map.map[0];
|
|
99
|
-
const lastCellPosInTable = map.map[map.map.length - 1];
|
|
100
|
-
const firstCellPos = table.pos + firstCellPosInTable + 1;
|
|
101
|
-
const lastCellPos = table.pos + lastCellPosInTable + 1;
|
|
102
|
-
const selection = new CellSelection(tr.doc.resolve(firstCellPos), tr.doc.resolve(lastCellPos));
|
|
103
|
-
tr = tr.setSelection(selection);
|
|
104
|
-
dispatch?.(tr);
|
|
105
|
-
}
|
|
106
|
-
return true;
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
|
|
110
85
|
//#endregion
|
|
111
86
|
//#region src/table/table-commands/select-table-cell.ts
|
|
112
87
|
/**
|
|
@@ -160,6 +135,31 @@ function selectTableRow(options) {
|
|
|
160
135
|
};
|
|
161
136
|
}
|
|
162
137
|
|
|
138
|
+
//#endregion
|
|
139
|
+
//#region src/table/table-commands/select-table.ts
|
|
140
|
+
/**
|
|
141
|
+
* @public
|
|
142
|
+
*/
|
|
143
|
+
function selectTable(options) {
|
|
144
|
+
return (state, dispatch) => {
|
|
145
|
+
const table = findTable(options?.pos ? state.doc.resolve(options.pos) : state.selection.$anchor);
|
|
146
|
+
if (!table) return false;
|
|
147
|
+
const map = TableMap.get(table.node);
|
|
148
|
+
if (map.map.length === 0) return false;
|
|
149
|
+
if (dispatch) {
|
|
150
|
+
let tr = state.tr;
|
|
151
|
+
const firstCellPosInTable = map.map[0];
|
|
152
|
+
const lastCellPosInTable = map.map[map.map.length - 1];
|
|
153
|
+
const firstCellPos = table.pos + firstCellPosInTable + 1;
|
|
154
|
+
const lastCellPos = table.pos + lastCellPosInTable + 1;
|
|
155
|
+
const selection = new CellSelection(tr.doc.resolve(firstCellPos), tr.doc.resolve(lastCellPos));
|
|
156
|
+
tr = tr.setSelection(selection);
|
|
157
|
+
dispatch?.(tr);
|
|
158
|
+
}
|
|
159
|
+
return true;
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
163
|
//#endregion
|
|
164
164
|
//#region src/table/table-commands.ts
|
|
165
165
|
/**
|
|
@@ -284,5 +284,5 @@ function defineTable() {
|
|
|
284
284
|
}
|
|
285
285
|
|
|
286
286
|
//#endregion
|
|
287
|
-
export { insertTable as _, defineTableSpec as a, defineTableCommands as c,
|
|
288
|
-
//# sourceMappingURL=table-
|
|
287
|
+
export { insertTable as _, defineTableSpec as a, defineTableCommands as c, selectTableColumn as d, selectTableCell as f, moveTableColumn as g, moveTableRow as h, defineTableRowSpec as i, selectTable as l, isCellSelection as m, defineTableCellSpec as n, defineTablePlugins as o, findTable as p, defineTableHeaderCellSpec as r, defineTableDropIndicator as s, defineTable as t, selectTableRow as u, exitTable as v };
|
|
288
|
+
//# sourceMappingURL=table-B81i9oH9.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-B81i9oH9.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,IA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EACP,CAAC;;;;;AAeJ,SAAgB,sBAA8C;AAC5D,QAAO,eAAe;EACpB,GAAG,MAAM;EACT,MAAM;EACN,OAAO;EACR,CAAC;;AAYJ,SAAgB,4BAA0D;AACxE,QAAO,eAAe;EACpB,GAAG,MAAM;EACT,MAAM;EACN,OAAO;EACR,CAAC;;;;;;;;ACrEJ,SAAgB,cAA8B;AAC5C,QAAO,MACL,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,2BAA2B,EAC3B,oBAAoB,EACpB,qBAAqB,EACrB,0BAA0B,CAC3B"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prosekit/extensions",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.14.
|
|
4
|
+
"version": "0.14.2",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "A collection of common extensions for ProseKit",
|
|
7
7
|
"author": {
|
|
@@ -223,16 +223,16 @@
|
|
|
223
223
|
"prosemirror-changeset": "^2.4.0",
|
|
224
224
|
"prosemirror-drop-indicator": "^0.1.3",
|
|
225
225
|
"prosemirror-dropcursor": "^1.8.2",
|
|
226
|
+
"prosemirror-enter-rules": "^0.1.5",
|
|
226
227
|
"prosemirror-flat-list": "^0.5.8",
|
|
227
228
|
"prosemirror-gapcursor": "^1.4.0",
|
|
228
229
|
"prosemirror-highlight": "^0.15.0",
|
|
230
|
+
"prosemirror-math": "^0.2.2",
|
|
229
231
|
"prosemirror-search": "^1.1.0",
|
|
230
232
|
"prosemirror-tables": "^1.8.5",
|
|
231
233
|
"shiki": "^3.22.0",
|
|
232
234
|
"@prosekit/core": "^0.10.0",
|
|
233
|
-
"@prosekit/pm": "^0.1.15"
|
|
234
|
-
"prosemirror-enter-rules": "^0.1.3",
|
|
235
|
-
"prosemirror-math": "^0.1.0"
|
|
235
|
+
"@prosekit/pm": "^0.1.15"
|
|
236
236
|
},
|
|
237
237
|
"peerDependencies": {
|
|
238
238
|
"loro-crdt": ">= 1.10.0",
|
|
@@ -259,7 +259,7 @@
|
|
|
259
259
|
"just-pick": "^4.2.0",
|
|
260
260
|
"katex": "^0.16.28",
|
|
261
261
|
"loro-crdt": "^1.10.6",
|
|
262
|
-
"loro-prosemirror": "^0.4.
|
|
262
|
+
"loro-prosemirror": "^0.4.3",
|
|
263
263
|
"rehype-parse": "^9.0.1",
|
|
264
264
|
"rehype-remark": "^10.0.1",
|
|
265
265
|
"remark-gfm": "^4.0.1",
|
|
@@ -270,12 +270,13 @@
|
|
|
270
270
|
"type-fest": "^5.4.4",
|
|
271
271
|
"typescript": "~5.9.3",
|
|
272
272
|
"unified": "^11.0.5",
|
|
273
|
-
"vitest": "^4.0.
|
|
273
|
+
"vitest": "^4.1.0-beta.4",
|
|
274
274
|
"vitest-browser-commands": "^0.2.0",
|
|
275
275
|
"y-prosemirror": "^1.3.7",
|
|
276
276
|
"yjs": "^13.6.29",
|
|
277
277
|
"@prosekit/config-tsdown": "0.0.0",
|
|
278
|
-
"@prosekit/config-vitest": "0.0.0"
|
|
278
|
+
"@prosekit/config-vitest": "0.0.0",
|
|
279
|
+
"@prosekit/config-ts": "0.0.0"
|
|
279
280
|
},
|
|
280
281
|
"publishConfig": {
|
|
281
282
|
"dev": {}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ResolvedPos } from '@prosekit/pm/model'
|
|
2
2
|
import { PluginKey, type EditorState, type Transaction } from '@prosekit/pm/state'
|
|
3
3
|
|
|
4
|
-
import type { AutocompleteRule } from './autocomplete-rule'
|
|
4
|
+
import type { AutocompleteRule } from './autocomplete-rule.ts'
|
|
5
5
|
|
|
6
6
|
export function defaultCanMatch({ state }: { state: EditorState }): boolean {
|
|
7
7
|
const $pos = state.selection.$from
|
|
@@ -13,8 +13,8 @@ import {
|
|
|
13
13
|
type PredictionPluginMatching,
|
|
14
14
|
type PredictionPluginState,
|
|
15
15
|
type PredictionTransactionMeta,
|
|
16
|
-
} from './autocomplete-helpers'
|
|
17
|
-
import type { AutocompleteRule } from './autocomplete-rule'
|
|
16
|
+
} from './autocomplete-helpers.ts'
|
|
17
|
+
import type { AutocompleteRule } from './autocomplete-rule.ts'
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Creates a plugin that handles autocomplete functionality.
|
|
@@ -2,11 +2,11 @@ import { canUseRegexLookbehind, union } from '@prosekit/core'
|
|
|
2
2
|
import { describe, expect, it, vi } from 'vitest'
|
|
3
3
|
import { keyboard } from 'vitest-browser-commands/playwright'
|
|
4
4
|
|
|
5
|
-
import { defineTestExtension, setupTestFromExtension } from '../testing'
|
|
6
|
-
import { inputText } from '../testing/keyboard'
|
|
5
|
+
import { defineTestExtension, setupTestFromExtension } from '../testing/index.ts'
|
|
6
|
+
import { inputText } from '../testing/keyboard.ts'
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { AutocompleteRule, type MatchHandler, type MatchHandlerOptions } from './autocomplete-rule.ts'
|
|
9
|
+
import { defineAutocomplete } from './autocomplete.ts'
|
|
10
10
|
|
|
11
11
|
function setupSlashMenu() {
|
|
12
12
|
const regex = canUseRegexLookbehind() ? /(?<!\S)\/(\S.*)?$/u : /\/(\S.*)?$/u
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineFacet, defineFacetPayload, pluginFacet, type Extension, type PluginPayload } from '@prosekit/core'
|
|
2
2
|
|
|
3
|
-
import { createAutocompletePlugin } from './autocomplete-plugin'
|
|
4
|
-
import type { AutocompleteRule } from './autocomplete-rule'
|
|
3
|
+
import { createAutocompletePlugin } from './autocomplete-plugin.ts'
|
|
4
|
+
import type { AutocompleteRule } from './autocomplete-rule.ts'
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Defines an autocomplete extension that executes logic when the text before
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export { defineAutocomplete } from './autocomplete'
|
|
2
1
|
export {
|
|
3
2
|
AutocompleteRule,
|
|
4
3
|
type AutocompleteRuleOptions,
|
|
@@ -6,4 +5,5 @@ export {
|
|
|
6
5
|
type CanMatchPredicate,
|
|
7
6
|
type MatchHandler,
|
|
8
7
|
type MatchHandlerOptions,
|
|
9
|
-
} from './autocomplete-rule'
|
|
8
|
+
} from './autocomplete-rule.ts'
|
|
9
|
+
export { defineAutocomplete } from './autocomplete.ts'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { addMark, defineCommands, removeMark, type Extension } from '@prosekit/core'
|
|
2
2
|
import type { Command } from '@prosekit/pm/state'
|
|
3
3
|
|
|
4
|
-
import type { BackgroundColorAttrs } from './background-color-spec'
|
|
4
|
+
import type { BackgroundColorAttrs } from './background-color-spec.ts'
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @internal
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { formatHTML } from 'diffable-html-snapshot'
|
|
2
2
|
import { describe, expect, it } from 'vitest'
|
|
3
3
|
|
|
4
|
-
import { setupTest } from '../testing'
|
|
4
|
+
import { setupTest } from '../testing/index.ts'
|
|
5
5
|
|
|
6
6
|
describe('defineBackgroundColorSpec', () => {
|
|
7
7
|
it('should render background color as inline span with style attribute', () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { union, type Union } from '@prosekit/core'
|
|
2
2
|
|
|
3
|
-
import { defineBackgroundColorCommands, type BackgroundColorCommandsExtension } from './background-color-commands'
|
|
4
|
-
import { defineBackgroundColorSpec, type BackgroundColorSpecExtension } from './background-color-spec'
|
|
3
|
+
import { defineBackgroundColorCommands, type BackgroundColorCommandsExtension } from './background-color-commands.ts'
|
|
4
|
+
import { defineBackgroundColorSpec, type BackgroundColorSpecExtension } from './background-color-spec.ts'
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @internal
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { defineBackgroundColor, type BackgroundColorExtension } from './background-color'
|
|
2
1
|
export {
|
|
3
2
|
addBackgroundColor,
|
|
4
3
|
defineBackgroundColorCommands,
|
|
5
4
|
removeBackgroundColor,
|
|
6
5
|
type BackgroundColorCommandsExtension,
|
|
7
|
-
} from './background-color-commands'
|
|
8
|
-
export { defineBackgroundColorSpec, type BackgroundColorAttrs, type BackgroundColorSpecExtension } from './background-color-spec'
|
|
6
|
+
} from './background-color-commands.ts'
|
|
7
|
+
export { defineBackgroundColorSpec, type BackgroundColorAttrs, type BackgroundColorSpecExtension } from './background-color-spec.ts'
|
|
8
|
+
export { defineBackgroundColor, type BackgroundColorExtension } from './background-color.ts'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PlainExtension } from '@prosekit/core'
|
|
2
2
|
|
|
3
|
-
import { defineWrappingInputRule } from '../input-rule'
|
|
3
|
+
import { defineWrappingInputRule } from '../input-rule/index.ts'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Wraps the text block in a blockquote when `>` is typed at the start of a new
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest'
|
|
2
2
|
import { keyboard } from 'vitest-browser-commands/playwright'
|
|
3
3
|
|
|
4
|
-
import { setupTest } from '../testing'
|
|
4
|
+
import { setupTest } from '../testing/index.ts'
|
|
5
5
|
|
|
6
6
|
describe('blockquote keymap', () => {
|
|
7
7
|
it('should wrap paragraph into blockquote with shortcut', async () => {
|
|
@@ -6,14 +6,16 @@ function toggleBlockquoteKeybinding(): Command {
|
|
|
6
6
|
return toggleWrap({ type: 'blockquote' })
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return joinBackward(state, dispatch, view)
|
|
14
|
-
}
|
|
15
|
-
return false
|
|
9
|
+
const backspaceUnsetBlockquoteCommand: Command = (state, dispatch, view): boolean => {
|
|
10
|
+
const $pos = isAtBlockStart(state, view)
|
|
11
|
+
if ($pos?.node(-1).type.name === 'blockquote') {
|
|
12
|
+
return joinBackward(state, dispatch, view)
|
|
16
13
|
}
|
|
14
|
+
return false
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function backspaceUnsetBlockquote(): Command {
|
|
18
|
+
return backspaceUnsetBlockquoteCommand
|
|
17
19
|
}
|
|
18
20
|
/**
|
|
19
21
|
* @internal
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { union, type Union } from '@prosekit/core'
|
|
2
2
|
|
|
3
|
-
import { defineBlockquoteCommands, type BlockquoteCommandsExtension } from './blockquote-commands'
|
|
4
|
-
import { defineBlockquoteInputRule } from './blockquote-input-rule'
|
|
5
|
-
import { defineBlockquoteKeymap } from './blockquote-keymap'
|
|
6
|
-
import { defineBlockquoteSpec, type BlockquoteSpecExtension } from './blockquote-spec'
|
|
3
|
+
import { defineBlockquoteCommands, type BlockquoteCommandsExtension } from './blockquote-commands.ts'
|
|
4
|
+
import { defineBlockquoteInputRule } from './blockquote-input-rule.ts'
|
|
5
|
+
import { defineBlockquoteKeymap } from './blockquote-keymap.ts'
|
|
6
|
+
import { defineBlockquoteSpec, type BlockquoteSpecExtension } from './blockquote-spec.ts'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @internal
|
package/src/blockquote/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
1
|
+
export { defineBlockquoteCommands, type BlockquoteCommandsExtension } from './blockquote-commands.ts'
|
|
2
|
+
export { defineBlockquoteInputRule } from './blockquote-input-rule.ts'
|
|
3
|
+
export { defineBlockquoteKeymap } from './blockquote-keymap.ts'
|
|
4
|
+
export { defineBlockquoteSpec, type BlockquoteSpecExtension } from './blockquote-spec.ts'
|
|
5
|
+
export { defineBlockquote, type BlockquoteExtension } from './blockquote.ts'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest'
|
|
2
2
|
|
|
3
|
-
import { setupTest } from '../testing'
|
|
4
|
-
import { inputText } from '../testing/keyboard'
|
|
3
|
+
import { setupTest } from '../testing/index.ts'
|
|
4
|
+
import { inputText } from '../testing/keyboard.ts'
|
|
5
5
|
|
|
6
6
|
describe('defineBoldInputRule', () => {
|
|
7
7
|
const { editor, n, m } = setupTest()
|
package/src/bold/bold.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { union, type Union } from '@prosekit/core'
|
|
2
2
|
|
|
3
|
-
import { defineBoldCommands, type BoldCommandsExtension } from './bold-commands'
|
|
4
|
-
import { defineBoldInputRule } from './bold-input-rule'
|
|
5
|
-
import { defineBoldKeymap } from './bold-keymap'
|
|
6
|
-
import { defineBoldSpec, type BoldSpecExtension } from './bold-spec'
|
|
3
|
+
import { defineBoldCommands, type BoldCommandsExtension } from './bold-commands.ts'
|
|
4
|
+
import { defineBoldInputRule } from './bold-input-rule.ts'
|
|
5
|
+
import { defineBoldKeymap } from './bold-keymap.ts'
|
|
6
|
+
import { defineBoldSpec, type BoldSpecExtension } from './bold-spec.ts'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @internal
|
package/src/bold/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
1
|
+
export { defineBoldCommands, type BoldCommandsExtension } from './bold-commands.ts'
|
|
2
|
+
export { defineBoldInputRule } from './bold-input-rule.ts'
|
|
3
|
+
export { defineBoldKeymap } from './bold-keymap.ts'
|
|
4
|
+
export { defineBoldSpec, type BoldSpecExtension } from './bold-spec.ts'
|
|
5
|
+
export { defineBold, type BoldExtension } from './bold.ts'
|
package/src/code/code.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { union, type Union } from '@prosekit/core'
|
|
2
2
|
|
|
3
|
-
import { defineCodeCommands, type CodeCommandsExtension } from './code-commands'
|
|
4
|
-
import { defineCodeInputRule } from './code-input-rule'
|
|
5
|
-
import { defineCodeKeymap } from './code-keymap'
|
|
6
|
-
import { defineCodeSpec, type CodeSpecExtension } from './code-spec'
|
|
3
|
+
import { defineCodeCommands, type CodeCommandsExtension } from './code-commands.ts'
|
|
4
|
+
import { defineCodeInputRule } from './code-input-rule.ts'
|
|
5
|
+
import { defineCodeKeymap } from './code-keymap.ts'
|
|
6
|
+
import { defineCodeSpec, type CodeSpecExtension } from './code-spec.ts'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @internal
|
package/src/code/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
1
|
+
export { defineCodeCommands, type CodeCommandsExtension } from './code-commands.ts'
|
|
2
|
+
export { defineCodeInputRule } from './code-input-rule.ts'
|
|
3
|
+
export { defineCodeKeymap } from './code-keymap.ts'
|
|
4
|
+
export { defineCodeSpec, type CodeSpecExtension } from './code-spec.ts'
|
|
5
|
+
export { defineCode, type CodeExtension } from './code.ts'
|
|
@@ -12,7 +12,16 @@ export type HighlightParser = Parser
|
|
|
12
12
|
* @public
|
|
13
13
|
*/
|
|
14
14
|
export type CodeBlockHighlightOptions = {
|
|
15
|
+
/**
|
|
16
|
+
* A parser instance from the `prosemirror-highlight` package.
|
|
17
|
+
*/
|
|
15
18
|
parser: HighlightParser
|
|
19
|
+
/**
|
|
20
|
+
* ProseMirror node types to highlight.
|
|
21
|
+
*
|
|
22
|
+
* @default ['codeBlock', 'mathBlock']
|
|
23
|
+
*/
|
|
24
|
+
nodeTypes?: string[]
|
|
16
25
|
}
|
|
17
26
|
|
|
18
27
|
/**
|
|
@@ -27,8 +36,9 @@ export type CodeBlockHighlightOptions = {
|
|
|
27
36
|
*/
|
|
28
37
|
export function defineCodeBlockHighlight({
|
|
29
38
|
parser,
|
|
39
|
+
nodeTypes = ['codeBlock', 'mathBlock'],
|
|
30
40
|
}: CodeBlockHighlightOptions): Extension {
|
|
31
41
|
return definePlugin(
|
|
32
|
-
createHighlightPlugin({ parser }),
|
|
42
|
+
createHighlightPlugin({ parser, nodeTypes }),
|
|
33
43
|
)
|
|
34
44
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { PlainExtension } from '@prosekit/core'
|
|
2
2
|
|
|
3
|
-
import { defineTextBlockEnterRule } from '../enter-rule'
|
|
4
|
-
import { defineTextBlockInputRule } from '../input-rule'
|
|
3
|
+
import { defineTextBlockEnterRule } from '../enter-rule/index.ts'
|
|
4
|
+
import { defineTextBlockInputRule } from '../input-rule/index.ts'
|
|
5
5
|
|
|
6
|
-
import type { CodeBlockAttrs } from './code-block-types'
|
|
6
|
+
import type { CodeBlockAttrs } from './code-block-types.ts'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Adds input rules for `codeBlock` nodes.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { Extension } from '@prosekit/core'
|
|
2
2
|
import type { SpecialLanguage } from 'shiki'
|
|
3
3
|
|
|
4
|
-
import { defineCodeBlockHighlight } from './code-block-highlight'
|
|
5
|
-
import type { ShikiBundledLanguage, ShikiBundledTheme } from './shiki-bundle'
|
|
6
|
-
import type { ShikiHighlighterOptions } from './shiki-highlighter-chunk'
|
|
7
|
-
import { createLazyParser } from './shiki-parser'
|
|
4
|
+
import { defineCodeBlockHighlight } from './code-block-highlight.ts'
|
|
5
|
+
import type { ShikiBundledLanguage, ShikiBundledTheme } from './shiki-bundle.ts'
|
|
6
|
+
import type { ShikiHighlighterOptions } from './shiki-highlighter-chunk.ts'
|
|
7
|
+
import { createLazyParser } from './shiki-parser.ts'
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* The options to configure the Shiki highlighter.
|
|
@@ -12,6 +12,13 @@ import { createLazyParser } from './shiki-parser'
|
|
|
12
12
|
* @public
|
|
13
13
|
*/
|
|
14
14
|
export interface CodeBlockShikiOptions extends Omit<ShikiHighlighterOptions, 'themes' | 'langs' | 'engine'> {
|
|
15
|
+
/**
|
|
16
|
+
* ProseMirror node types to highlight.
|
|
17
|
+
*
|
|
18
|
+
* @default ['codeBlock', 'mathBlock']
|
|
19
|
+
*/
|
|
20
|
+
nodeTypes?: string[]
|
|
21
|
+
|
|
15
22
|
/**
|
|
16
23
|
* A list of Shiki themes to pre-load. The first theme in the list will be
|
|
17
24
|
* used to render the code block.
|
|
@@ -46,10 +53,11 @@ export interface CodeBlockShikiOptions extends Omit<ShikiHighlighterOptions, 'th
|
|
|
46
53
|
* @public
|
|
47
54
|
*/
|
|
48
55
|
export function defineCodeBlockShiki({
|
|
56
|
+
nodeTypes,
|
|
49
57
|
themes = ['one-dark-pro'],
|
|
50
58
|
langs = ['text'],
|
|
51
59
|
...rest
|
|
52
60
|
}: CodeBlockShikiOptions = {}): Extension {
|
|
53
61
|
const parser = createLazyParser({ themes, langs, ...rest })
|
|
54
|
-
return defineCodeBlockHighlight({ parser })
|
|
62
|
+
return defineCodeBlockHighlight({ parser, nodeTypes })
|
|
55
63
|
}
|
|
@@ -2,8 +2,8 @@ import { jsonFromHTML } from '@prosekit/core'
|
|
|
2
2
|
import { formatHTML } from 'diffable-html-snapshot'
|
|
3
3
|
import { describe, expect, it } from 'vitest'
|
|
4
4
|
|
|
5
|
-
import { setupTest } from '../testing'
|
|
6
|
-
import { htmlFromMarkdown, markdownFromHTML } from '../testing/markdown'
|
|
5
|
+
import { setupTest } from '../testing/index.ts'
|
|
6
|
+
import { htmlFromMarkdown, markdownFromHTML } from '../testing/markdown.ts'
|
|
7
7
|
|
|
8
8
|
describe('defineCodeBlockSpec', () => {
|
|
9
9
|
it('can parse and serialize code blocks', () => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { union, type Union } from '@prosekit/core'
|
|
2
2
|
|
|
3
|
-
import { defineCodeBlockCommands, type CodeBlockCommandsExtension } from './code-block-commands'
|
|
4
|
-
import { defineCodeBlockEnterRule, defineCodeBlockInputRule } from './code-block-input-rule'
|
|
5
|
-
import { defineCodeBlockKeymap } from './code-block-keymap'
|
|
6
|
-
import { defineCodeBlockSpec, type CodeBlockSpecExtension } from './code-block-spec'
|
|
3
|
+
import { defineCodeBlockCommands, type CodeBlockCommandsExtension } from './code-block-commands.ts'
|
|
4
|
+
import { defineCodeBlockEnterRule, defineCodeBlockInputRule } from './code-block-input-rule.ts'
|
|
5
|
+
import { defineCodeBlockKeymap } from './code-block-keymap.ts'
|
|
6
|
+
import { defineCodeBlockSpec, type CodeBlockSpecExtension } from './code-block-spec.ts'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @internal
|
package/src/code-block/index.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export type
|
|
1
|
+
export { defineCodeBlockCommands, type CodeBlockCommandsExtension } from './code-block-commands.ts'
|
|
2
|
+
export { defineCodeBlockHighlight, type CodeBlockHighlightOptions, type HighlightParser } from './code-block-highlight.ts'
|
|
3
|
+
export { defineCodeBlockEnterRule, defineCodeBlockInputRule } from './code-block-input-rule.ts'
|
|
4
|
+
export { defineCodeBlockKeymap } from './code-block-keymap.ts'
|
|
5
|
+
export { defineCodeBlockShiki } from './code-block-shiki.ts'
|
|
6
|
+
export { defineCodeBlockSpec, type CodeBlockSpecExtension } from './code-block-spec.ts'
|
|
7
|
+
export type { CodeBlockAttrs } from './code-block-types.ts'
|
|
8
|
+
export { defineCodeBlock, type CodeBlockExtension } from './code-block.ts'
|
|
9
9
|
export {
|
|
10
10
|
shikiBundledLanguagesInfo,
|
|
11
11
|
shikiBundledThemesInfo,
|
|
@@ -13,4 +13,4 @@ export {
|
|
|
13
13
|
type ShikiBundledLanguageInfo,
|
|
14
14
|
type ShikiBundledTheme,
|
|
15
15
|
type ShikiBundledThemeInfo,
|
|
16
|
-
} from './shiki-bundle'
|
|
16
|
+
} from './shiki-bundle.ts'
|