@prosekit/extensions 0.7.21 → 0.7.23
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/_tsup-dts-rollup.d.ts +18 -4
- package/dist/{chunk-4WHSS2ZE.js → chunk-6UYLCVBX.js} +2 -2
- package/dist/chunk-KNFGQ3MV.js +308 -0
- package/dist/prosekit-extensions-autocomplete.js +7 -2
- package/dist/prosekit-extensions-blockquote.js +12 -4
- package/dist/prosekit-extensions-bold.js +14 -4
- package/dist/prosekit-extensions-code-block.js +21 -8
- package/dist/prosekit-extensions-code.js +14 -4
- package/dist/prosekit-extensions-commit.js +8 -5
- package/dist/prosekit-extensions-drop-cursor.d.ts +2 -2
- package/dist/prosekit-extensions-drop-cursor.js +3 -1
- package/dist/prosekit-extensions-enter-rule.js +1 -1
- package/dist/prosekit-extensions-file.d.ts +5 -5
- package/dist/prosekit-extensions-file.js +23 -23
- package/dist/prosekit-extensions-gap-cursor.js +3 -1
- package/dist/prosekit-extensions-heading.js +7 -3
- package/dist/prosekit-extensions-horizontal-rule.js +18 -5
- package/dist/prosekit-extensions-image.js +10 -3
- package/dist/prosekit-extensions-italic.js +14 -4
- package/dist/prosekit-extensions-link.js +2 -2
- package/dist/prosekit-extensions-list.js +21 -9
- package/dist/prosekit-extensions-loro.d.ts +4 -4
- package/dist/prosekit-extensions-loro.js +33 -13
- package/dist/prosekit-extensions-mark-rule.js +1 -1
- package/dist/prosekit-extensions-mod-click-prevention.js +8 -2
- package/dist/prosekit-extensions-placeholder.js +27 -8
- package/dist/prosekit-extensions-readonly.js +4 -1
- package/dist/prosekit-extensions-search.js +6 -3
- package/dist/prosekit-extensions-strike.js +2 -2
- package/dist/prosekit-extensions-table.d.ts +1 -0
- package/dist/prosekit-extensions-table.js +17 -276
- package/dist/prosekit-extensions-virtual-selection.js +7 -2
- package/dist/prosekit-extensions-yjs.js +12 -6
- package/package.json +13 -13
- package/dist/{chunk-RE23OQPF.js → chunk-TWEOBBYZ.js} +1 -1
@@ -1,280 +1,20 @@
|
|
1
|
-
// src/table/table.ts
|
2
|
-
import { union } from "@prosekit/core";
|
3
|
-
|
4
|
-
// src/table/table-commands.ts
|
5
1
|
import {
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
mergeCells,
|
23
|
-
splitCell,
|
24
|
-
TableMap
|
25
|
-
} from "prosemirror-tables";
|
26
|
-
|
27
|
-
// src/table/table-utils.ts
|
28
|
-
import { findParentNode } from "@prosekit/core";
|
29
|
-
import {
|
30
|
-
cellAround,
|
31
|
-
cellNear,
|
32
|
-
CellSelection,
|
33
|
-
inSameTable
|
34
|
-
} from "prosemirror-tables";
|
35
|
-
function isCellSelection(value) {
|
36
|
-
return value instanceof CellSelection;
|
37
|
-
}
|
38
|
-
function findTable($pos) {
|
39
|
-
return findParentNode((node) => node.type.spec.tableRole === "table", $pos);
|
40
|
-
}
|
41
|
-
function findCellRange(selection, anchorHit, headHit) {
|
42
|
-
var _a, _b;
|
43
|
-
if (anchorHit == null && headHit == null && isCellSelection(selection)) {
|
44
|
-
return [selection.$anchorCell, selection.$headCell];
|
45
|
-
}
|
46
|
-
const anchor = (_a = anchorHit != null ? anchorHit : headHit) != null ? _a : selection.anchor;
|
47
|
-
const head = (_b = headHit != null ? headHit : anchorHit) != null ? _b : selection.head;
|
48
|
-
const doc = selection.$head.doc;
|
49
|
-
const $anchorCell = findCellPos(doc, anchor);
|
50
|
-
const $headCell = findCellPos(doc, head);
|
51
|
-
if ($anchorCell && $headCell && inSameTable($anchorCell, $headCell)) {
|
52
|
-
return [$anchorCell, $headCell];
|
53
|
-
}
|
54
|
-
}
|
55
|
-
function findCellPos(doc, pos) {
|
56
|
-
const $pos = doc.resolve(pos);
|
57
|
-
return cellAround($pos) || cellNear($pos);
|
58
|
-
}
|
59
|
-
|
60
|
-
// src/table/table-commands.ts
|
61
|
-
function createEmptyTable(schema, row, col, header) {
|
62
|
-
const tableType = getNodeType(schema, "table");
|
63
|
-
const tableRowType = getNodeType(schema, "tableRow");
|
64
|
-
const tableCellType = getNodeType(schema, "tableCell");
|
65
|
-
const tableHeaderCellType = getNodeType(schema, "tableHeaderCell");
|
66
|
-
if (header) {
|
67
|
-
const headerCell = tableHeaderCellType.createAndFill();
|
68
|
-
const headerCells = repeat(headerCell, col);
|
69
|
-
const headerRow = tableRowType.createAndFill(null, headerCells);
|
70
|
-
const bodyCell = tableCellType.createAndFill();
|
71
|
-
const bodyCells = repeat(bodyCell, col);
|
72
|
-
const bodyRow = tableRowType.createAndFill(null, bodyCells);
|
73
|
-
const bodyRows = repeat(bodyRow, row - 1);
|
74
|
-
return tableType.createAndFill(null, [headerRow, ...bodyRows]);
|
75
|
-
} else {
|
76
|
-
const bodyCell = tableCellType.createAndFill();
|
77
|
-
const bodyCells = repeat(bodyCell, col);
|
78
|
-
const bodyRow = tableRowType.createAndFill(null, bodyCells);
|
79
|
-
const bodyRows = repeat(bodyRow, row);
|
80
|
-
return tableType.createAndFill(null, bodyRows);
|
81
|
-
}
|
82
|
-
}
|
83
|
-
function repeat(node, length) {
|
84
|
-
return Array(length).fill(node);
|
85
|
-
}
|
86
|
-
function insertTable(options) {
|
87
|
-
return (state, dispatch, view) => {
|
88
|
-
const { row, col, header } = options;
|
89
|
-
const table = createEmptyTable(state.schema, row, col, header);
|
90
|
-
return insertNode({ node: table })(state, dispatch, view);
|
91
|
-
};
|
92
|
-
}
|
93
|
-
var exitTable = (state, dispatch) => {
|
94
|
-
const { $head, $anchor } = state.selection;
|
95
|
-
if (!$head.sameParent($anchor)) {
|
96
|
-
return false;
|
97
|
-
}
|
98
|
-
let tableStart = -1;
|
99
|
-
let tableDepth = -1;
|
100
|
-
for (let depth = $head.depth; depth >= 0; depth--) {
|
101
|
-
const node2 = $head.node(depth);
|
102
|
-
if (node2.type.spec.tableRole === "table") {
|
103
|
-
tableStart = $head.before(depth);
|
104
|
-
tableDepth = depth;
|
105
|
-
}
|
106
|
-
}
|
107
|
-
if (tableStart < 0 || tableDepth <= 0) {
|
108
|
-
return false;
|
109
|
-
}
|
110
|
-
const above = $head.node(tableDepth - 1);
|
111
|
-
const after = $head.indexAfter(tableDepth - 1);
|
112
|
-
const type = defaultBlockAt(above.contentMatchAt(after));
|
113
|
-
const node = type == null ? void 0 : type.createAndFill();
|
114
|
-
if (!type || !node || !above.canReplaceWith(after, after, type)) {
|
115
|
-
return false;
|
116
|
-
}
|
117
|
-
if (dispatch) {
|
118
|
-
const pos = $head.after(tableDepth);
|
119
|
-
const tr = state.tr.replaceWith(pos, pos, node);
|
120
|
-
tr.setSelection(TextSelection.near(tr.doc.resolve(pos), 1));
|
121
|
-
dispatch(tr.scrollIntoView());
|
122
|
-
}
|
123
|
-
return true;
|
124
|
-
};
|
125
|
-
function selectTableColumn(options) {
|
126
|
-
return (state, dispatch) => {
|
127
|
-
const range = findCellRange(state.selection, options == null ? void 0 : options.anchor, options == null ? void 0 : options.head);
|
128
|
-
if (!range) {
|
129
|
-
return false;
|
130
|
-
}
|
131
|
-
if (dispatch) {
|
132
|
-
const [$anchorCell, $headCell] = range;
|
133
|
-
const selection = CellSelection2.colSelection($anchorCell, $headCell);
|
134
|
-
dispatch(state.tr.setSelection(selection));
|
135
|
-
}
|
136
|
-
return true;
|
137
|
-
};
|
138
|
-
}
|
139
|
-
function selectTableRow(options) {
|
140
|
-
return (state, dispatch) => {
|
141
|
-
const range = findCellRange(state.selection, options == null ? void 0 : options.anchor, options == null ? void 0 : options.head);
|
142
|
-
if (!range) {
|
143
|
-
return false;
|
144
|
-
}
|
145
|
-
if (dispatch) {
|
146
|
-
const [$anchorCell, $headCell] = range;
|
147
|
-
const selection = CellSelection2.rowSelection($anchorCell, $headCell);
|
148
|
-
dispatch(state.tr.setSelection(selection));
|
149
|
-
}
|
150
|
-
return true;
|
151
|
-
};
|
152
|
-
}
|
153
|
-
function selectTableCell(options) {
|
154
|
-
return (state, dispatch) => {
|
155
|
-
var _a;
|
156
|
-
const $cellPos = findCellPos(
|
157
|
-
state.doc,
|
158
|
-
(_a = options == null ? void 0 : options.pos) != null ? _a : state.selection.anchor
|
159
|
-
);
|
160
|
-
if (!$cellPos) {
|
161
|
-
return false;
|
162
|
-
}
|
163
|
-
if (dispatch) {
|
164
|
-
const selection = new CellSelection2($cellPos);
|
165
|
-
dispatch(state.tr.setSelection(selection));
|
166
|
-
}
|
167
|
-
return true;
|
168
|
-
};
|
169
|
-
}
|
170
|
-
function selectTable(options) {
|
171
|
-
return (state, dispatch) => {
|
172
|
-
const $pos = (options == null ? void 0 : options.pos) ? state.doc.resolve(options.pos) : state.selection.$anchor;
|
173
|
-
const table = findTable($pos);
|
174
|
-
if (!table) {
|
175
|
-
return false;
|
176
|
-
}
|
177
|
-
const map = TableMap.get(table.node);
|
178
|
-
if (map.map.length === 0) {
|
179
|
-
return false;
|
180
|
-
}
|
181
|
-
if (dispatch) {
|
182
|
-
let tr = state.tr;
|
183
|
-
const firstCellPosInTable = map.map[0];
|
184
|
-
const lastCellPosInTable = map.map[map.map.length - 1];
|
185
|
-
const firstCellPos = table.pos + firstCellPosInTable + 1;
|
186
|
-
const lastCellPos = table.pos + lastCellPosInTable + 1;
|
187
|
-
const $firstCellPos = tr.doc.resolve(firstCellPos);
|
188
|
-
const $lastCellPos = tr.doc.resolve(lastCellPos);
|
189
|
-
const selection = new CellSelection2($firstCellPos, $lastCellPos);
|
190
|
-
tr = tr.setSelection(selection);
|
191
|
-
dispatch == null ? void 0 : dispatch(tr);
|
192
|
-
}
|
193
|
-
return true;
|
194
|
-
};
|
195
|
-
}
|
196
|
-
function defineTableCommands() {
|
197
|
-
return defineCommands({
|
198
|
-
insertTable,
|
199
|
-
exitTable: () => exitTable,
|
200
|
-
selectTable,
|
201
|
-
selectTableCell,
|
202
|
-
selectTableColumn,
|
203
|
-
selectTableRow,
|
204
|
-
addTableColumnBefore: () => addColumnBefore,
|
205
|
-
addTableColumnAfter: () => addColumnAfter,
|
206
|
-
addTableRowAbove: () => addRowBefore,
|
207
|
-
addTableRowBelow: () => addRowAfter,
|
208
|
-
deleteTable: () => deleteTable,
|
209
|
-
deleteTableColumn: () => deleteColumn,
|
210
|
-
deleteTableRow: () => deleteRow,
|
211
|
-
deleteCellSelection: () => deleteCellSelection,
|
212
|
-
mergeTableCells: () => mergeCells,
|
213
|
-
splitTableCell: () => splitCell
|
214
|
-
});
|
215
|
-
}
|
216
|
-
|
217
|
-
// src/table/table-plugins.ts
|
218
|
-
import { definePlugin } from "@prosekit/core";
|
219
|
-
import { tableEditing, columnResizing } from "prosemirror-tables";
|
220
|
-
function defineTablePlugins() {
|
221
|
-
return definePlugin([tableEditing(), columnResizing()]);
|
222
|
-
}
|
223
|
-
|
224
|
-
// src/table/table-spec.ts
|
225
|
-
import { defineNodeSpec } from "@prosekit/core";
|
226
|
-
import { tableNodes } from "prosemirror-tables";
|
227
|
-
var cellContent = "block+";
|
228
|
-
var cellAttrs = {
|
229
|
-
colspan: { default: 1 },
|
230
|
-
rowspan: { default: 1 },
|
231
|
-
colwidth: { default: null }
|
232
|
-
};
|
233
|
-
var specs = tableNodes({
|
234
|
-
tableGroup: "block",
|
235
|
-
cellContent,
|
236
|
-
cellAttributes: {}
|
237
|
-
});
|
238
|
-
function defineTableSpec() {
|
239
|
-
return defineNodeSpec({
|
240
|
-
...specs["table"],
|
241
|
-
content: "tableRow+",
|
242
|
-
name: "table"
|
243
|
-
});
|
244
|
-
}
|
245
|
-
function defineTableRowSpec() {
|
246
|
-
return defineNodeSpec({
|
247
|
-
...specs["table_row"],
|
248
|
-
content: "(tableCell | tableHeaderCell)*",
|
249
|
-
name: "tableRow"
|
250
|
-
});
|
251
|
-
}
|
252
|
-
function defineTableCellSpec() {
|
253
|
-
return defineNodeSpec({
|
254
|
-
...specs["table_cell"],
|
255
|
-
name: "tableCell",
|
256
|
-
attrs: cellAttrs
|
257
|
-
});
|
258
|
-
}
|
259
|
-
function defineTableHeaderCellSpec() {
|
260
|
-
return defineNodeSpec({
|
261
|
-
...specs["table_header"],
|
262
|
-
name: "tableHeaderCell",
|
263
|
-
attrs: cellAttrs
|
264
|
-
});
|
265
|
-
}
|
266
|
-
|
267
|
-
// src/table/table.ts
|
268
|
-
function defineTable() {
|
269
|
-
return union(
|
270
|
-
defineTableSpec(),
|
271
|
-
defineTableRowSpec(),
|
272
|
-
defineTableCellSpec(),
|
273
|
-
defineTableHeaderCellSpec(),
|
274
|
-
defineTablePlugins(),
|
275
|
-
defineTableCommands()
|
276
|
-
);
|
277
|
-
}
|
2
|
+
defineTable,
|
3
|
+
defineTableCellSpec,
|
4
|
+
defineTableCommands,
|
5
|
+
defineTableHeaderCellSpec,
|
6
|
+
defineTablePlugins,
|
7
|
+
defineTableRowSpec,
|
8
|
+
defineTableSpec,
|
9
|
+
exitTable,
|
10
|
+
findTable,
|
11
|
+
insertTable,
|
12
|
+
isCellSelection,
|
13
|
+
selectTable,
|
14
|
+
selectTableCell,
|
15
|
+
selectTableColumn,
|
16
|
+
selectTableRow
|
17
|
+
} from "./chunk-KNFGQ3MV.js";
|
278
18
|
export {
|
279
19
|
defineTable,
|
280
20
|
defineTableCellSpec,
|
@@ -284,6 +24,7 @@ export {
|
|
284
24
|
defineTableRowSpec,
|
285
25
|
defineTableSpec,
|
286
26
|
exitTable,
|
27
|
+
findTable,
|
287
28
|
insertTable,
|
288
29
|
isCellSelection,
|
289
30
|
selectTable,
|
@@ -1,10 +1,15 @@
|
|
1
1
|
// src/virtual-selection/index.ts
|
2
|
-
import {
|
2
|
+
import {
|
3
|
+
definePlugin
|
4
|
+
} from "@prosekit/core";
|
3
5
|
import {
|
4
6
|
PluginKey,
|
5
7
|
ProseMirrorPlugin
|
6
8
|
} from "@prosekit/pm/state";
|
7
|
-
import {
|
9
|
+
import {
|
10
|
+
Decoration,
|
11
|
+
DecorationSet
|
12
|
+
} from "@prosekit/pm/view";
|
8
13
|
function defineVirtualSelection() {
|
9
14
|
return definePlugin(virtualSelectionPlugin);
|
10
15
|
}
|
@@ -6,15 +6,17 @@ import {
|
|
6
6
|
} from "@prosekit/core";
|
7
7
|
|
8
8
|
// src/yjs/yjs-commands.ts
|
9
|
-
import {
|
9
|
+
import {
|
10
|
+
defineCommands
|
11
|
+
} from "@prosekit/core";
|
10
12
|
|
11
13
|
// src/yjs/yjs-undo-plugin.ts
|
12
14
|
import { definePlugin } from "@prosekit/core";
|
13
15
|
import {
|
14
|
-
|
15
|
-
yUndoPlugin as originalYUndoPlugin,
|
16
|
+
redo as yRedo,
|
16
17
|
undo as yUndo,
|
17
|
-
|
18
|
+
yUndoPlugin as originalYUndoPlugin,
|
19
|
+
yUndoPluginKey
|
18
20
|
} from "y-prosemirror";
|
19
21
|
function fixYUndoPlugin(yUndoPluginInstance) {
|
20
22
|
const originalUndoPluginView = yUndoPluginInstance.spec.view;
|
@@ -86,7 +88,9 @@ function defineYjsCommands() {
|
|
86
88
|
}
|
87
89
|
|
88
90
|
// src/yjs/yjs-cursor-plugin.ts
|
89
|
-
import {
|
91
|
+
import {
|
92
|
+
definePlugin as definePlugin2
|
93
|
+
} from "@prosekit/core";
|
90
94
|
import { yCursorPlugin } from "y-prosemirror";
|
91
95
|
function defineYjsCursorPlugin(options) {
|
92
96
|
const { awareness, ...rest } = options;
|
@@ -110,7 +114,9 @@ function defineYjsKeymap() {
|
|
110
114
|
}
|
111
115
|
|
112
116
|
// src/yjs/yjs-sync-plugin.ts
|
113
|
-
import {
|
117
|
+
import {
|
118
|
+
definePlugin as definePlugin3
|
119
|
+
} from "@prosekit/core";
|
114
120
|
import { ySyncPlugin } from "y-prosemirror";
|
115
121
|
function defineYjsSyncPlugin(options) {
|
116
122
|
const { fragment, ...rest } = options;
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@prosekit/extensions",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.7.
|
4
|
+
"version": "0.7.23",
|
5
5
|
"private": false,
|
6
6
|
"author": {
|
7
7
|
"name": "ocavue",
|
@@ -216,12 +216,12 @@
|
|
216
216
|
"prosemirror-dropcursor": "^1.8.1",
|
217
217
|
"prosemirror-flat-list": "^0.5.4",
|
218
218
|
"prosemirror-gapcursor": "^1.3.2",
|
219
|
-
"prosemirror-highlight": "^0.
|
219
|
+
"prosemirror-highlight": "^0.11.0",
|
220
220
|
"prosemirror-search": "^1.0.0",
|
221
|
-
"prosemirror-tables": "^1.6.
|
222
|
-
"shiki": "^1.
|
223
|
-
"@prosekit/core": "^0.7.
|
224
|
-
"@prosekit/pm": "^0.1.
|
221
|
+
"prosemirror-tables": "^1.6.1",
|
222
|
+
"shiki": "^1.24.2",
|
223
|
+
"@prosekit/core": "^0.7.14",
|
224
|
+
"@prosekit/pm": "^0.1.9"
|
225
225
|
},
|
226
226
|
"peerDependencies": {
|
227
227
|
"loro-crdt": ">= 0.16.7",
|
@@ -244,15 +244,15 @@
|
|
244
244
|
}
|
245
245
|
},
|
246
246
|
"devDependencies": {
|
247
|
-
"@vitest/browser": "^2.1.
|
247
|
+
"@vitest/browser": "^2.1.8",
|
248
248
|
"just-pick": "^4.2.0",
|
249
|
-
"loro-crdt": "^1.
|
250
|
-
"loro-prosemirror": "^0.
|
249
|
+
"loro-crdt": "^1.2.2",
|
250
|
+
"loro-prosemirror": "^0.2.0",
|
251
251
|
"tsup": "^8.3.5",
|
252
|
-
"type-fest": "^4.
|
253
|
-
"typescript": "
|
254
|
-
"vitest": "^2.1.
|
255
|
-
"y-prosemirror": "^1.2.
|
252
|
+
"type-fest": "^4.30.2",
|
253
|
+
"typescript": "~5.6.3",
|
254
|
+
"vitest": "^2.1.8",
|
255
|
+
"y-prosemirror": "^1.2.15",
|
256
256
|
"y-protocols": "^1.0.6",
|
257
257
|
"yjs": "^13.6.20",
|
258
258
|
"@prosekit/dev": "0.0.0"
|
@@ -1,11 +1,11 @@
|
|
1
1
|
// src/enter-rule/index.ts
|
2
2
|
import {
|
3
|
-
OBJECT_REPLACEMENT_CHARACTER,
|
4
3
|
defineFacet,
|
5
4
|
defineFacetPayload,
|
6
5
|
getNodeType,
|
7
6
|
isTextSelection,
|
8
7
|
maybeRun,
|
8
|
+
OBJECT_REPLACEMENT_CHARACTER,
|
9
9
|
pluginFacet
|
10
10
|
} from "@prosekit/core";
|
11
11
|
import { keydownHandler } from "@prosekit/pm/keymap";
|