@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
- function getCellAttrs(dom) {
228
- if (typeof dom === "string") {
229
- return {};
230
- }
231
- const widthAttr = dom.getAttribute("data-colwidth");
232
- const widths = widthAttr && /^\d+(,\d+)*$/.test(widthAttr) ? widthAttr.split(",").map((s) => Number(s)) : null;
233
- const colspan = Number(dom.getAttribute("colspan") || 1);
234
- return {
235
- colspan,
236
- rowspan: Number(dom.getAttribute("rowspan") || 1),
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
- name: "table",
257
- tableRole: "table",
240
+ ...specs["table"],
258
241
  content: "tableRow+",
259
- isolating: true,
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
- name: "tableRow",
270
- tableRole: "row",
247
+ ...specs["table_row"],
271
248
  content: "(tableCell | tableHeaderCell)*",
272
- parseDOM: [{ tag: "tr" }],
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
- tableRole: "cell",
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
- tableRole: "header_cell",
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.13",
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.9",
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",