@prosekit/extensions 0.7.13 → 0.7.14
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.
@@ -223,87 +223,44 @@ function defineTablePlugins() {
|
|
223
223
|
|
224
224
|
// src/table/table-spec.ts
|
225
225
|
import { defineNodeSpec } from "@prosekit/core";
|
226
|
+
import { tableNodes } from "prosemirror-tables";
|
226
227
|
var cellContent = "block+";
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
}
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
colwidth: widths && widths.length == colspan ? widths : null
|
238
|
-
};
|
239
|
-
}
|
240
|
-
function setCellAttrs(node) {
|
241
|
-
const pmAttrs = node.attrs;
|
242
|
-
const domAttrs = {};
|
243
|
-
if (pmAttrs.colspan !== 1) {
|
244
|
-
domAttrs.colspan = pmAttrs.colspan;
|
245
|
-
}
|
246
|
-
if (pmAttrs.rowspan !== 1) {
|
247
|
-
domAttrs.rowspan = pmAttrs.rowspan;
|
248
|
-
}
|
249
|
-
if (pmAttrs.colwidth) {
|
250
|
-
domAttrs["data-colwidth"] = pmAttrs.colwidth.join(",");
|
251
|
-
}
|
252
|
-
return domAttrs;
|
253
|
-
}
|
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
|
+
});
|
254
238
|
function defineTableSpec() {
|
255
239
|
return defineNodeSpec({
|
256
|
-
|
257
|
-
tableRole: "table",
|
240
|
+
...specs["table"],
|
258
241
|
content: "tableRow+",
|
259
|
-
|
260
|
-
group: "block",
|
261
|
-
parseDOM: [{ tag: "table" }],
|
262
|
-
toDOM() {
|
263
|
-
return ["table", ["tbody", 0]];
|
264
|
-
}
|
242
|
+
name: "table"
|
265
243
|
});
|
266
244
|
}
|
267
245
|
function defineTableRowSpec() {
|
268
246
|
return defineNodeSpec({
|
269
|
-
|
270
|
-
tableRole: "row",
|
247
|
+
...specs["table_row"],
|
271
248
|
content: "(tableCell | tableHeaderCell)*",
|
272
|
-
|
273
|
-
toDOM() {
|
274
|
-
return ["tr", 0];
|
275
|
-
}
|
249
|
+
name: "tableRow"
|
276
250
|
});
|
277
251
|
}
|
278
|
-
var cellAttrs = {
|
279
|
-
colspan: { default: 1 },
|
280
|
-
rowspan: { default: 1 },
|
281
|
-
colwidth: { default: null }
|
282
|
-
};
|
283
252
|
function defineTableCellSpec() {
|
284
253
|
return defineNodeSpec({
|
254
|
+
...specs["table_cell"],
|
285
255
|
name: "tableCell",
|
286
|
-
|
287
|
-
content: cellContent,
|
288
|
-
attrs: cellAttrs,
|
289
|
-
isolating: true,
|
290
|
-
parseDOM: [{ tag: "td", getAttrs: (dom) => getCellAttrs(dom) }],
|
291
|
-
toDOM(node) {
|
292
|
-
return ["td", setCellAttrs(node), 0];
|
293
|
-
}
|
256
|
+
attrs: cellAttrs
|
294
257
|
});
|
295
258
|
}
|
296
259
|
function defineTableHeaderCellSpec() {
|
297
260
|
return defineNodeSpec({
|
261
|
+
...specs["table_header"],
|
298
262
|
name: "tableHeaderCell",
|
299
|
-
|
300
|
-
content: cellContent,
|
301
|
-
attrs: cellAttrs,
|
302
|
-
isolating: true,
|
303
|
-
parseDOM: [{ tag: "th", getAttrs: (dom) => getCellAttrs(dom) }],
|
304
|
-
toDOM(node) {
|
305
|
-
return ["th", setCellAttrs(node), 0];
|
306
|
-
}
|
263
|
+
attrs: cellAttrs
|
307
264
|
});
|
308
265
|
}
|
309
266
|
|
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.14",
|
5
5
|
"private": false,
|
6
6
|
"author": {
|
7
7
|
"name": "ocavue",
|
@@ -210,7 +210,7 @@
|
|
210
210
|
"prosemirror-search": "^1.0.0",
|
211
211
|
"prosemirror-tables": "^1.5.0",
|
212
212
|
"shiki": "^1.14.1",
|
213
|
-
"@prosekit/core": "^0.7.
|
213
|
+
"@prosekit/core": "^0.7.10",
|
214
214
|
"@prosekit/pm": "^0.1.8"
|
215
215
|
},
|
216
216
|
"peerDependencies": {
|
@@ -235,6 +235,7 @@
|
|
235
235
|
},
|
236
236
|
"devDependencies": {
|
237
237
|
"@vitest/browser": "^2.0.5",
|
238
|
+
"just-pick": "^4.2.0",
|
238
239
|
"loro-crdt": "^0.16.7",
|
239
240
|
"loro-prosemirror": "^0.0.7",
|
240
241
|
"tsup": "^8.2.4",
|