@harbour-enterprises/superdoc 0.20.0-next.5 → 0.20.0-next.6

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.
Files changed (90) hide show
  1. package/dist/chunks/{PdfViewer-Blwty0A0.cjs → PdfViewer--YKlzafo.cjs} +1 -1
  2. package/dist/chunks/{PdfViewer-DcPZsBsK.es.js → PdfViewer-CuiUv0d5.es.js} +1 -1
  3. package/dist/chunks/{index-BZzn2Rcn.es.js → index-Cl1u_lKk.es.js} +2 -2
  4. package/dist/chunks/{index-BB5vhzVT.cjs → index-CuHtS7O9.cjs} +2 -2
  5. package/dist/chunks/{super-editor.es-BgBNGRxg.cjs → super-editor.es-BIW7iKAk.cjs} +736 -464
  6. package/dist/chunks/{super-editor.es-BTcVSa_f.es.js → super-editor.es-DN4v75aq.es.js} +736 -464
  7. package/dist/core/SuperDoc.d.ts.map +1 -1
  8. package/dist/super-editor/ai-writer.es.js +2 -2
  9. package/dist/super-editor/chunks/{converter-BPTfSIJf.js → converter-kutpjDQU.js} +687 -470
  10. package/dist/super-editor/chunks/{docx-zipper-ikgI-2vM.js → docx-zipper-BjcI24VU.js} +1 -1
  11. package/dist/super-editor/chunks/{editor-hh7sL4Wv.js → editor-ps-v4FlA.js} +55 -2
  12. package/dist/super-editor/chunks/{toolbar-B-apzt27.js → toolbar-Ch271j8X.js} +2 -2
  13. package/dist/super-editor/converter.es.js +1 -1
  14. package/dist/super-editor/docx-zipper.es.js +2 -2
  15. package/dist/super-editor/editor.es.js +3 -3
  16. package/dist/super-editor/file-zipper.es.js +1 -1
  17. package/dist/super-editor/src/core/super-converter/v2/importer/tableImporter.d.ts +0 -22
  18. package/dist/super-editor/src/core/super-converter/v3/handlers/utils.d.ts +10 -3
  19. package/dist/super-editor/src/core/super-converter/v3/handlers/w/bidiVisual/bidiVisual-translator.d.ts +6 -0
  20. package/dist/super-editor/src/core/super-converter/v3/handlers/w/bidiVisual/index.d.ts +1 -0
  21. package/dist/super-editor/src/core/super-converter/v3/handlers/w/bottom/bottom-translator.d.ts +6 -0
  22. package/dist/super-editor/src/core/super-converter/v3/handlers/w/bottom/index.d.ts +2 -0
  23. package/dist/super-editor/src/core/super-converter/v3/handlers/w/bottom/marginBottom-translator.d.ts +6 -0
  24. package/dist/super-editor/src/core/super-converter/v3/handlers/w/end/end-translator.d.ts +6 -0
  25. package/dist/super-editor/src/core/super-converter/v3/handlers/w/end/index.d.ts +2 -0
  26. package/dist/super-editor/src/core/super-converter/v3/handlers/w/end/marginEnd-translator.d.ts +6 -0
  27. package/dist/super-editor/src/core/super-converter/v3/handlers/w/gridCol/gridCol-translator.d.ts +6 -0
  28. package/dist/super-editor/src/core/super-converter/v3/handlers/w/gridCol/index.d.ts +1 -0
  29. package/dist/super-editor/src/core/super-converter/v3/handlers/w/insideH/index.d.ts +1 -0
  30. package/dist/super-editor/src/core/super-converter/v3/handlers/w/insideH/insideH-translator.d.ts +6 -0
  31. package/dist/super-editor/src/core/super-converter/v3/handlers/w/insideV/index.d.ts +1 -0
  32. package/dist/super-editor/src/core/super-converter/v3/handlers/w/insideV/insideV-translator.d.ts +6 -0
  33. package/dist/super-editor/src/core/super-converter/v3/handlers/w/left/index.d.ts +2 -0
  34. package/dist/super-editor/src/core/super-converter/v3/handlers/w/left/left-translator.d.ts +6 -0
  35. package/dist/super-editor/src/core/super-converter/v3/handlers/w/left/marginLeft-translator.d.ts +6 -0
  36. package/dist/super-editor/src/core/super-converter/v3/handlers/w/right/index.d.ts +2 -0
  37. package/dist/super-editor/src/core/super-converter/v3/handlers/w/right/marginRight-translator.d.ts +6 -0
  38. package/dist/super-editor/src/core/super-converter/v3/handlers/w/right/right-translator.d.ts +6 -0
  39. package/dist/super-editor/src/core/super-converter/v3/handlers/w/shd/index.d.ts +1 -0
  40. package/dist/super-editor/src/core/super-converter/v3/handlers/w/shd/shd-translator.d.ts +6 -0
  41. package/dist/super-editor/src/core/super-converter/v3/handlers/w/start/index.d.ts +2 -0
  42. package/dist/super-editor/src/core/super-converter/v3/handlers/w/start/marginStart-translator.d.ts +6 -0
  43. package/dist/super-editor/src/core/super-converter/v3/handlers/w/start/start-translator.d.ts +6 -0
  44. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tbl/index.d.ts +1 -0
  45. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tbl/tbl-translator.d.ts +28 -0
  46. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblBorders/index.d.ts +1 -0
  47. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblBorders/tblBorders-translator.d.ts +6 -0
  48. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblCaption/index.d.ts +1 -0
  49. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblCaption/tblCaption-translator.d.ts +6 -0
  50. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblCellMar/index.d.ts +1 -0
  51. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblCellMar/tblCellMar-translator.d.ts +2 -0
  52. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblDescription/index.d.ts +1 -0
  53. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblDescription/tblDescription-translator.d.ts +6 -0
  54. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblGrid/index.d.ts +1 -0
  55. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblGrid/tblGrid-translator.d.ts +5 -0
  56. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblInd/index.d.ts +1 -0
  57. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblInd/tblInd-translator.d.ts +6 -0
  58. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblLayout/index.d.ts +1 -0
  59. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblLayout/tblLayout-translator.d.ts +6 -0
  60. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblLook/index.d.ts +1 -0
  61. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblLook/tblLook-translator.d.ts +6 -0
  62. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblOverlap/index.d.ts +1 -0
  63. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblOverlap/tblOverlap-translator.d.ts +6 -0
  64. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblPr/index.d.ts +1 -0
  65. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblPr/tblPr-translator.d.ts +5 -0
  66. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyle/index.d.ts +1 -0
  67. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyle/tblStyle-translator.d.ts +6 -0
  68. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyleColBandSize/index.d.ts +1 -0
  69. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyleColBandSize/tblStyleColBandSize-translator.d.ts +6 -0
  70. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyleRowBandSize/index.d.ts +1 -0
  71. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyleRowBandSize/tblStyleRowBandSize-translator.d.ts +6 -0
  72. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblW/index.d.ts +1 -0
  73. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblW/tblW-translator.d.ts +6 -0
  74. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblpPr/index.d.ts +1 -0
  75. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblpPr/tblpPr-translator.d.ts +6 -0
  76. package/dist/super-editor/src/core/super-converter/v3/handlers/w/tc/helpers/legacy-handle-table-cell-node.d.ts +1 -1
  77. package/dist/super-editor/src/core/super-converter/v3/handlers/w/top/index.d.ts +2 -0
  78. package/dist/super-editor/src/core/super-converter/v3/handlers/w/top/marginTop-translator.d.ts +6 -0
  79. package/dist/super-editor/src/core/super-converter/v3/handlers/w/top/top-translator.d.ts +6 -0
  80. package/dist/super-editor/src/core/super-converter/v3/node-translator/node-translator.d.ts +3 -1
  81. package/dist/super-editor/src/extensions/table/table.d.ts +330 -0
  82. package/dist/super-editor/super-editor.es.js +8 -8
  83. package/dist/super-editor/toolbar.es.js +2 -2
  84. package/dist/super-editor.cjs +1 -1
  85. package/dist/super-editor.es.js +1 -1
  86. package/dist/superdoc.cjs +2 -2
  87. package/dist/superdoc.es.js +2 -2
  88. package/dist/superdoc.umd.js +736 -464
  89. package/dist/superdoc.umd.js.map +1 -1
  90. package/package.json +1 -1
@@ -16394,41 +16394,6 @@ const prepareCommentsXmlFilesForExport = ({ convertedXml, defs, commentsWithPara
16394
16394
  documentXml: updatedXml
16395
16395
  };
16396
16396
  };
16397
- const getColStyleDeclaration = (minWidth, width) => {
16398
- if (width) {
16399
- return ["width", `${Math.max(width, minWidth)}px`];
16400
- }
16401
- return ["min-width", `${minWidth}px`];
16402
- };
16403
- const createColGroup = (node, cellMinWidth, overrideCol, overrideValue) => {
16404
- let totalWidth = 0;
16405
- let fixedWidth = true;
16406
- const cols = [];
16407
- const colsValues = [];
16408
- const row = node.firstChild;
16409
- if (!row) return {};
16410
- for (let i = 0, col = 0; i < row.childCount; i++) {
16411
- const { colspan, colwidth } = row.child(i).attrs;
16412
- for (let j2 = 0; j2 < colspan; j2++, col++) {
16413
- const hasWidth = overrideCol === col ? overrideValue : colwidth && colwidth[j2];
16414
- totalWidth += hasWidth || cellMinWidth;
16415
- if (!hasWidth) fixedWidth = false;
16416
- const [prop, value] = getColStyleDeclaration(cellMinWidth, hasWidth);
16417
- cols.push(["col", { style: `${prop}: ${value}` }]);
16418
- colsValues.push(parseInt(value, 10));
16419
- }
16420
- }
16421
- const tableWidth = fixedWidth ? `${totalWidth}px` : "";
16422
- const tableMinWidth = fixedWidth ? "" : `${totalWidth}px`;
16423
- const colgroup = ["colgroup", {}, ...cols];
16424
- const colgroupValues = [...colsValues];
16425
- return {
16426
- colgroup,
16427
- tableWidth,
16428
- tableMinWidth,
16429
- colgroupValues
16430
- };
16431
- };
16432
16397
  const lower16 = 65535;
16433
16398
  const factor16 = Math.pow(2, 16);
16434
16399
  function makeRecover(index2, offset2) {
@@ -24198,46 +24163,6 @@ const baseNumbering = {
24198
24163
  }
24199
24164
  ]
24200
24165
  };
24201
- function preProcessVerticalMergeCells(table, { editorSchema }) {
24202
- if (!table || !Array.isArray(table.content)) {
24203
- return table;
24204
- }
24205
- const rows = table.content;
24206
- for (let rowIndex = 0; rowIndex < rows.length; rowIndex++) {
24207
- const row = rows[rowIndex];
24208
- if (!row) continue;
24209
- if (!Array.isArray(row.content)) {
24210
- row.content = [];
24211
- }
24212
- for (let cellIndex = 0; cellIndex < row.content.length; cellIndex++) {
24213
- const cell = row.content[cellIndex];
24214
- if (!cell) continue;
24215
- const attrs = cell.attrs || {};
24216
- if (!attrs.rowspan || attrs.rowspan <= 1) continue;
24217
- const maxRowspan = Math.min(attrs.rowspan, rows.length - rowIndex);
24218
- for (let offset2 = 1; offset2 < maxRowspan; offset2++) {
24219
- const rowToChange = rows[rowIndex + offset2];
24220
- if (!rowToChange) continue;
24221
- if (!Array.isArray(rowToChange.content)) {
24222
- rowToChange.content = [];
24223
- }
24224
- const existingCell = rowToChange.content[cellIndex];
24225
- if (existingCell?.attrs?.continueMerge) continue;
24226
- const mergedCell = {
24227
- type: cell.type,
24228
- content: [editorSchema.nodes.paragraph.createAndFill().toJSON()],
24229
- attrs: {
24230
- ...cell.attrs,
24231
- rowspan: null,
24232
- continueMerge: true
24233
- }
24234
- };
24235
- rowToChange.content.splice(cellIndex, 0, mergedCell);
24236
- }
24237
- }
24238
- }
24239
- return table;
24240
- }
24241
24166
  const TranslatorTypes = Object.freeze({
24242
24167
  NODE: "node",
24243
24168
  ATTRIBUTE: "attribute"
@@ -24358,37 +24283,37 @@ const _NodeTranslator = class _NodeTranslator2 {
24358
24283
  };
24359
24284
  __publicField$2(_NodeTranslator, "translatorTypes", TranslatorTypes);
24360
24285
  let NodeTranslator = _NodeTranslator;
24361
- const encode$m = (attributes) => {
24286
+ const encode$r = (attributes) => {
24362
24287
  return attributes["w:type"];
24363
24288
  };
24364
- const decode$m = (attrs) => {
24289
+ const decode$r = (attrs) => {
24365
24290
  const { lineBreakType } = attrs;
24366
24291
  return lineBreakType;
24367
24292
  };
24368
24293
  const attrConfig$b = Object.freeze({
24369
24294
  xmlName: "w:type",
24370
24295
  sdName: "lineBreakType",
24371
- encode: encode$m,
24372
- decode: decode$m
24296
+ encode: encode$r,
24297
+ decode: decode$r
24373
24298
  });
24374
- const encode$l = (attributes) => {
24299
+ const encode$q = (attributes) => {
24375
24300
  const xmlAttrValue = attributes["w:clear"];
24376
24301
  return xmlAttrValue;
24377
24302
  };
24378
- const decode$l = (attrs) => {
24303
+ const decode$q = (attrs) => {
24379
24304
  const { clear } = attrs;
24380
24305
  return clear;
24381
24306
  };
24382
24307
  const attrConfig$a = Object.freeze({
24383
24308
  xmlName: "w:clear",
24384
24309
  sdName: "clear",
24385
- encode: encode$l,
24386
- decode: decode$l
24310
+ encode: encode$q,
24311
+ decode: decode$q
24387
24312
  });
24388
24313
  const validXmlAttributes$9 = [attrConfig$b, attrConfig$a];
24389
- const XML_NODE_NAME$a = "w:br";
24390
- const SD_NODE_NAME$9 = "lineBreak";
24391
- const encode$k = (_2, encodedAttrs) => {
24314
+ const XML_NODE_NAME$f = "w:br";
24315
+ const SD_NODE_NAME$a = "lineBreak";
24316
+ const encode$p = (_2, encodedAttrs) => {
24392
24317
  const isPageBreak = encodedAttrs?.lineBreakType === "page";
24393
24318
  const translated = {
24394
24319
  type: isPageBreak ? "hardBreak" : "lineBreak"
@@ -24398,7 +24323,7 @@ const encode$k = (_2, encodedAttrs) => {
24398
24323
  }
24399
24324
  return translated;
24400
24325
  };
24401
- const decode$k = (params2, decodedAttrs) => {
24326
+ const decode$p = (params2, decodedAttrs) => {
24402
24327
  const { node } = params2;
24403
24328
  if (!node) return;
24404
24329
  const wBreak = { name: "w:br" };
@@ -24415,63 +24340,63 @@ const decode$k = (params2, decodedAttrs) => {
24415
24340
  };
24416
24341
  return translated;
24417
24342
  };
24418
- const config$a = {
24419
- xmlName: XML_NODE_NAME$a,
24420
- sdNodeOrKeyName: SD_NODE_NAME$9,
24343
+ const config$d = {
24344
+ xmlName: XML_NODE_NAME$f,
24345
+ sdNodeOrKeyName: SD_NODE_NAME$a,
24421
24346
  type: NodeTranslator.translatorTypes.NODE,
24422
- encode: encode$k,
24423
- decode: decode$k,
24347
+ encode: encode$p,
24348
+ decode: decode$p,
24424
24349
  attributes: validXmlAttributes$9
24425
24350
  };
24426
- const translator$m = NodeTranslator.from(config$a);
24427
- const encode$j = (attributes) => {
24351
+ const translator$T = NodeTranslator.from(config$d);
24352
+ const encode$o = (attributes) => {
24428
24353
  return attributes["w:val"];
24429
24354
  };
24430
- const decode$j = (attrs) => {
24355
+ const decode$o = (attrs) => {
24431
24356
  const { tabSize } = attrs || {};
24432
24357
  return tabSize;
24433
24358
  };
24434
24359
  const attrConfig$9 = Object.freeze({
24435
24360
  xmlName: "w:val",
24436
24361
  sdName: "tabSize",
24437
- encode: encode$j,
24438
- decode: decode$j
24362
+ encode: encode$o,
24363
+ decode: decode$o
24439
24364
  });
24440
- const encode$i = (attributes) => {
24365
+ const encode$n = (attributes) => {
24441
24366
  return attributes["w:leader"];
24442
24367
  };
24443
- const decode$i = (attrs) => {
24368
+ const decode$n = (attrs) => {
24444
24369
  const { leader } = attrs || {};
24445
24370
  return leader;
24446
24371
  };
24447
24372
  const attrConfig$8 = Object.freeze({
24448
24373
  xmlName: "w:leader",
24449
24374
  sdName: "leader",
24450
- encode: encode$i,
24451
- decode: decode$i
24375
+ encode: encode$n,
24376
+ decode: decode$n
24452
24377
  });
24453
- const encode$h = (attributes) => {
24378
+ const encode$m = (attributes) => {
24454
24379
  return attributes["w:pos"];
24455
24380
  };
24456
- const decode$h = (attrs) => {
24381
+ const decode$m = (attrs) => {
24457
24382
  const { pos } = attrs || {};
24458
24383
  return pos;
24459
24384
  };
24460
24385
  const attrConfig$7 = Object.freeze({
24461
24386
  xmlName: "w:pos",
24462
24387
  sdName: "pos",
24463
- encode: encode$h,
24464
- decode: decode$h
24388
+ encode: encode$m,
24389
+ decode: decode$m
24465
24390
  });
24466
24391
  const validXmlAttributes$8 = [attrConfig$9, attrConfig$7, attrConfig$8];
24467
- const XML_NODE_NAME$9 = "w:tab";
24468
- const SD_NODE_NAME$8 = "tab";
24469
- const encode$g = (_2, encodedAttrs = {}) => {
24392
+ const XML_NODE_NAME$e = "w:tab";
24393
+ const SD_NODE_NAME$9 = "tab";
24394
+ const encode$l = (_2, encodedAttrs = {}) => {
24470
24395
  const translated = { type: "tab" };
24471
24396
  if (encodedAttrs) translated.attrs = { ...encodedAttrs };
24472
24397
  return translated;
24473
24398
  };
24474
- const decode$g = (params2, decodedAttrs = {}) => {
24399
+ const decode$l = (params2, decodedAttrs = {}) => {
24475
24400
  const { node } = params2 || {};
24476
24401
  if (!node) return;
24477
24402
  const wTab = { name: "w:tab" };
@@ -24487,15 +24412,15 @@ const decode$g = (params2, decodedAttrs = {}) => {
24487
24412
  }
24488
24413
  return translated;
24489
24414
  };
24490
- const config$9 = {
24491
- xmlName: XML_NODE_NAME$9,
24492
- sdNodeOrKeyName: SD_NODE_NAME$8,
24415
+ const config$c = {
24416
+ xmlName: XML_NODE_NAME$e,
24417
+ sdNodeOrKeyName: SD_NODE_NAME$9,
24493
24418
  type: NodeTranslator.translatorTypes.NODE,
24494
- encode: encode$g,
24495
- decode: decode$g,
24419
+ encode: encode$l,
24420
+ decode: decode$l,
24496
24421
  attributes: validXmlAttributes$8
24497
24422
  };
24498
- const translator$l = NodeTranslator.from(config$9);
24423
+ const translator$S = NodeTranslator.from(config$c);
24499
24424
  const mergeTextNodes = (nodes) => {
24500
24425
  if (!nodes || !Array.isArray(nodes)) {
24501
24426
  return nodes;
@@ -25065,89 +24990,89 @@ const handleParagraphNode$1 = (params2) => {
25065
24990
  }
25066
24991
  return schemaNode;
25067
24992
  };
25068
- const encode$f = (attributes) => {
24993
+ const encode$k = (attributes) => {
25069
24994
  return attributes["w:rsidDel"];
25070
24995
  };
25071
- const decode$f = (attrs) => {
24996
+ const decode$k = (attrs) => {
25072
24997
  return attrs.rsidDel;
25073
24998
  };
25074
24999
  const attrConfig$6 = Object.freeze({
25075
25000
  xmlName: "w:rsidDel",
25076
25001
  sdName: "rsidDel",
25077
- encode: encode$f,
25078
- decode: decode$f
25002
+ encode: encode$k,
25003
+ decode: decode$k
25079
25004
  });
25080
- const encode$e = (attributes) => {
25005
+ const encode$j = (attributes) => {
25081
25006
  return attributes["w:rsidP"];
25082
25007
  };
25083
- const decode$e = (attrs) => {
25008
+ const decode$j = (attrs) => {
25084
25009
  return attrs.rsidP;
25085
25010
  };
25086
25011
  const attrConfig$5 = Object.freeze({
25087
25012
  xmlName: "w:rsidP",
25088
25013
  sdName: "rsidP",
25089
- encode: encode$e,
25090
- decode: decode$e
25014
+ encode: encode$j,
25015
+ decode: decode$j
25091
25016
  });
25092
- const encode$d = (attributes) => {
25017
+ const encode$i = (attributes) => {
25093
25018
  return attributes["w:rsidR"];
25094
25019
  };
25095
- const decode$d = (attrs) => {
25020
+ const decode$i = (attrs) => {
25096
25021
  return attrs.rsidR;
25097
25022
  };
25098
25023
  const attrConfig$4 = Object.freeze({
25099
25024
  xmlName: "w:rsidR",
25100
25025
  sdName: "rsidR",
25101
- encode: encode$d,
25102
- decode: decode$d
25026
+ encode: encode$i,
25027
+ decode: decode$i
25103
25028
  });
25104
- const encode$c = (attributes) => {
25029
+ const encode$h = (attributes) => {
25105
25030
  return attributes["w:rsidRPr"];
25106
25031
  };
25107
- const decode$c = (attrs) => {
25032
+ const decode$h = (attrs) => {
25108
25033
  return attrs.rsidRPr;
25109
25034
  };
25110
25035
  const attrConfig$3 = Object.freeze({
25111
25036
  xmlName: "w:rsidRPr",
25112
25037
  sdName: "rsidRPr",
25113
- encode: encode$c,
25114
- decode: decode$c
25038
+ encode: encode$h,
25039
+ decode: decode$h
25115
25040
  });
25116
- const encode$b = (attributes) => {
25041
+ const encode$g = (attributes) => {
25117
25042
  return attributes["w:rsidRDefault"];
25118
25043
  };
25119
- const decode$b = (attrs) => {
25044
+ const decode$g = (attrs) => {
25120
25045
  return attrs.rsidRDefault;
25121
25046
  };
25122
25047
  const attrConfig$2 = Object.freeze({
25123
25048
  xmlName: "w:rsidRDefault",
25124
25049
  sdName: "rsidRDefault",
25125
- encode: encode$b,
25126
- decode: decode$b
25050
+ encode: encode$g,
25051
+ decode: decode$g
25127
25052
  });
25128
- const encode$a = (attributes) => {
25053
+ const encode$f = (attributes) => {
25129
25054
  return attributes["w14:paraId"];
25130
25055
  };
25131
- const decode$a = (attrs) => {
25056
+ const decode$f = (attrs) => {
25132
25057
  return attrs.paraId;
25133
25058
  };
25134
25059
  const attrConfig$1 = Object.freeze({
25135
25060
  xmlName: "w14:paraId",
25136
25061
  sdName: "paraId",
25137
- encode: encode$a,
25138
- decode: decode$a
25062
+ encode: encode$f,
25063
+ decode: decode$f
25139
25064
  });
25140
- const encode$9 = (attributes) => {
25065
+ const encode$e = (attributes) => {
25141
25066
  return attributes["w14:textId"];
25142
25067
  };
25143
- const decode$9 = (attrs) => {
25068
+ const decode$e = (attrs) => {
25144
25069
  return attrs.textId;
25145
25070
  };
25146
25071
  const attrConfig = Object.freeze({
25147
25072
  xmlName: "w14:textId",
25148
25073
  sdName: "textId",
25149
- encode: encode$9,
25150
- decode: decode$9
25074
+ encode: encode$e,
25075
+ decode: decode$e
25151
25076
  });
25152
25077
  const validXmlAttributes$7 = [
25153
25078
  attrConfig$1,
@@ -25158,9 +25083,9 @@ const validXmlAttributes$7 = [
25158
25083
  attrConfig$3,
25159
25084
  attrConfig$6
25160
25085
  ];
25161
- const XML_NODE_NAME$8 = "w:p";
25162
- const SD_NODE_NAME$7 = "paragraph";
25163
- const encode$8 = (params2, encodedAttrs = {}) => {
25086
+ const XML_NODE_NAME$d = "w:p";
25087
+ const SD_NODE_NAME$8 = "paragraph";
25088
+ const encode$d = (params2, encodedAttrs = {}) => {
25164
25089
  const node = handleParagraphNode$1(params2);
25165
25090
  if (!node) return void 0;
25166
25091
  if (encodedAttrs && Object.keys(encodedAttrs).length) {
@@ -25168,7 +25093,7 @@ const encode$8 = (params2, encodedAttrs = {}) => {
25168
25093
  }
25169
25094
  return node;
25170
25095
  };
25171
- const decode$8 = (params2, decodedAttrs = {}) => {
25096
+ const decode$d = (params2, decodedAttrs = {}) => {
25172
25097
  const translated = translateParagraphNode(params2);
25173
25098
  if (!translated) return void 0;
25174
25099
  if (decodedAttrs && Object.keys(decodedAttrs).length) {
@@ -25176,15 +25101,15 @@ const decode$8 = (params2, decodedAttrs = {}) => {
25176
25101
  }
25177
25102
  return translated;
25178
25103
  };
25179
- const config$8 = {
25180
- xmlName: XML_NODE_NAME$8,
25181
- sdNodeOrKeyName: SD_NODE_NAME$7,
25104
+ const config$b = {
25105
+ xmlName: XML_NODE_NAME$d,
25106
+ sdNodeOrKeyName: SD_NODE_NAME$8,
25182
25107
  type: NodeTranslator.translatorTypes.NODE,
25183
- encode: encode$8,
25184
- decode: decode$8,
25108
+ encode: encode$d,
25109
+ decode: decode$d,
25185
25110
  attributes: validXmlAttributes$7
25186
25111
  };
25187
- const translator$k = NodeTranslator.from(config$8);
25112
+ const translator$R = NodeTranslator.from(config$b);
25188
25113
  const generateV2HandlerEntity = (handlerName, translator2) => ({
25189
25114
  handlerName,
25190
25115
  handler: (params2) => {
@@ -25212,7 +25137,7 @@ function createSingleAttrPropertyHandler(xmlName, sdName = null, attrName = "w:v
25212
25137
  },
25213
25138
  decode: ({ node }) => {
25214
25139
  const value = node.attrs?.[sdName] != null ? transformDecode(node.attrs[sdName]) : void 0;
25215
- return value != null ? { [attrName]: value } : void 0;
25140
+ return value != null ? { name: xmlName, attributes: { [attrName]: value } } : void 0;
25216
25141
  }
25217
25142
  };
25218
25143
  }
@@ -25230,7 +25155,32 @@ function createMeasurementPropertyHandler(xmlName, sdName = null) {
25230
25155
  },
25231
25156
  decode: function({ node }) {
25232
25157
  const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs[sdName] || {} } });
25233
- return decodedAttrs["w:w"] != null ? decodedAttrs : void 0;
25158
+ return decodedAttrs["w:w"] != null ? { attributes: decodedAttrs } : void 0;
25159
+ }
25160
+ };
25161
+ }
25162
+ function createBorderPropertyHandler(xmlName, sdName = null) {
25163
+ if (!sdName) sdName = xmlName.split(":")[1];
25164
+ return {
25165
+ xmlName,
25166
+ sdNodeOrKeyName: sdName,
25167
+ attributes: [
25168
+ createAttributeHandler("w:val"),
25169
+ createAttributeHandler("w:color"),
25170
+ createAttributeHandler("w:themeColor"),
25171
+ createAttributeHandler("w:themeTint"),
25172
+ createAttributeHandler("w:themeShade"),
25173
+ createAttributeHandler("w:sz", "size", parseInteger, integerToString),
25174
+ createAttributeHandler("w:space", null, parseInteger, integerToString),
25175
+ createAttributeHandler("w:shadow", null, parseBoolean, booleanToString),
25176
+ createAttributeHandler("w:frame", null, parseBoolean, booleanToString)
25177
+ ],
25178
+ encode: (_2, encodedAttrs) => {
25179
+ return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
25180
+ },
25181
+ decode: function({ node }, _2) {
25182
+ const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs[sdName] || {} } });
25183
+ return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
25234
25184
  }
25235
25185
  };
25236
25186
  }
@@ -25273,15 +25223,17 @@ function decodeProperties(translatorsBySdName, properties) {
25273
25223
  Object.keys(properties).forEach((key2) => {
25274
25224
  const translator2 = translatorsBySdName[key2];
25275
25225
  if (translator2) {
25276
- const attributes = translator2.decode({ node: { attrs: { [key2]: properties[key2] } } });
25277
- if (attributes != null) {
25278
- elements.push({ name: translator2.xmlName, attributes });
25226
+ const result = translator2.decode({ node: { attrs: { [key2]: properties[key2] } } });
25227
+ if (result != null) {
25228
+ result.name = translator2.xmlName;
25229
+ elements.push(result);
25279
25230
  }
25280
25231
  }
25281
25232
  });
25282
25233
  return elements;
25283
25234
  }
25284
- const parseBoolean = (value) => ["1", "true"].includes(value);
25235
+ const parseBoolean = (value) => value != null ? ["1", "true"].includes(value) : void 0;
25236
+ const booleanToString = (value) => value != null ? value ? "1" : "0" : void 0;
25285
25237
  const parseInteger = (value) => {
25286
25238
  if (value == null) return void 0;
25287
25239
  const intValue = parseInt(value, 10);
@@ -25291,13 +25243,53 @@ const integerToString = (value) => {
25291
25243
  const intValue = parseInteger(value);
25292
25244
  return intValue != void 0 ? String(intValue) : void 0;
25293
25245
  };
25294
- const translator$j = NodeTranslator.from({
25246
+ function preProcessVerticalMergeCells(table, { editorSchema }) {
25247
+ if (!table || !Array.isArray(table.content)) {
25248
+ return table;
25249
+ }
25250
+ const rows = table.content;
25251
+ for (let rowIndex = 0; rowIndex < rows.length; rowIndex++) {
25252
+ const row = rows[rowIndex];
25253
+ if (!row) continue;
25254
+ if (!Array.isArray(row.content)) {
25255
+ row.content = [];
25256
+ }
25257
+ for (let cellIndex = 0; cellIndex < row.content.length; cellIndex++) {
25258
+ const cell = row.content[cellIndex];
25259
+ if (!cell) continue;
25260
+ const attrs = cell.attrs || {};
25261
+ if (!attrs.rowspan || attrs.rowspan <= 1) continue;
25262
+ const maxRowspan = Math.min(attrs.rowspan, rows.length - rowIndex);
25263
+ for (let offset2 = 1; offset2 < maxRowspan; offset2++) {
25264
+ const rowToChange = rows[rowIndex + offset2];
25265
+ if (!rowToChange) continue;
25266
+ if (!Array.isArray(rowToChange.content)) {
25267
+ rowToChange.content = [];
25268
+ }
25269
+ const existingCell = rowToChange.content[cellIndex];
25270
+ if (existingCell?.attrs?.continueMerge) continue;
25271
+ const mergedCell = {
25272
+ type: cell.type,
25273
+ content: [editorSchema.nodes.paragraph.createAndFill().toJSON()],
25274
+ attrs: {
25275
+ ...cell.attrs,
25276
+ rowspan: null,
25277
+ continueMerge: true
25278
+ }
25279
+ };
25280
+ rowToChange.content.splice(cellIndex, 0, mergedCell);
25281
+ }
25282
+ }
25283
+ }
25284
+ return table;
25285
+ }
25286
+ const translator$Q = NodeTranslator.from({
25295
25287
  xmlName: "w:cantSplit",
25296
25288
  sdNodeOrKeyName: "cantSplit",
25297
25289
  encode: ({ nodes }) => ["1", "true"].includes(nodes[0].attributes?.["w:val"] ?? "1"),
25298
- decode: ({ node }) => node.attrs?.cantSplit ? {} : void 0
25290
+ decode: ({ node }) => node.attrs?.cantSplit ? { attributes: {} } : void 0
25299
25291
  });
25300
- const translator$i = NodeTranslator.from({
25292
+ const translator$P = NodeTranslator.from({
25301
25293
  xmlName: "w:cnfStyle",
25302
25294
  sdNodeOrKeyName: "cnfStyle",
25303
25295
  attributes: [
@@ -25312,26 +25304,19 @@ const translator$i = NodeTranslator.from({
25312
25304
  "w:lastRowFirstColumn",
25313
25305
  "w:lastRowLastColumn",
25314
25306
  "w:oddHBand",
25315
- "w:oddVBand",
25316
- "w:val"
25317
- ].map((attr) => createAttributeHandler(attr)),
25307
+ "w:oddVBand"
25308
+ ].map((attr) => createAttributeHandler(attr, null, parseBoolean, booleanToString)).concat([createAttributeHandler("w:val")]),
25318
25309
  encode: (_2, encodedAttrs) => {
25319
- Object.keys(encodedAttrs).forEach((key2) => {
25320
- encodedAttrs[key2] = ["1", "true"].includes(encodedAttrs[key2]);
25321
- });
25322
25310
  return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
25323
25311
  },
25324
- decode: ({ node }) => {
25312
+ decode: function({ node }) {
25325
25313
  if (!node.attrs?.cnfStyle) return;
25326
- const cnfStyleAttrs = {};
25327
- Object.entries(node.attrs.cnfStyle).forEach(([key2, value]) => {
25328
- cnfStyleAttrs[`w:${key2}`] = value ? "1" : "0";
25329
- });
25330
- return Object.keys(cnfStyleAttrs).length > 0 ? cnfStyleAttrs : void 0;
25314
+ const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs.cnfStyle || {} } });
25315
+ return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
25331
25316
  }
25332
25317
  });
25333
- const translator$h = NodeTranslator.from(createSingleAttrPropertyHandler("w:divId"));
25334
- const translator$g = NodeTranslator.from(
25318
+ const translator$O = NodeTranslator.from(createSingleAttrPropertyHandler("w:divId"));
25319
+ const translator$N = NodeTranslator.from(
25335
25320
  createSingleAttrPropertyHandler(
25336
25321
  "w:gridAfter",
25337
25322
  null,
@@ -25340,7 +25325,7 @@ const translator$g = NodeTranslator.from(
25340
25325
  (v2) => integerToString(v2)
25341
25326
  )
25342
25327
  );
25343
- const translator$f = NodeTranslator.from(
25328
+ const translator$M = NodeTranslator.from(
25344
25329
  createSingleAttrPropertyHandler(
25345
25330
  "w:gridBefore",
25346
25331
  null,
@@ -25349,21 +25334,21 @@ const translator$f = NodeTranslator.from(
25349
25334
  (v2) => integerToString(v2)
25350
25335
  )
25351
25336
  );
25352
- const translator$e = NodeTranslator.from({
25337
+ const translator$L = NodeTranslator.from({
25353
25338
  xmlName: "w:hidden",
25354
25339
  sdNodeOrKeyName: "hidden",
25355
25340
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
25356
- decode: ({ node }) => node.attrs.hidden ? {} : void 0
25341
+ decode: ({ node }) => node.attrs.hidden ? { attributes: {} } : void 0
25357
25342
  });
25358
- const translator$d = NodeTranslator.from(createSingleAttrPropertyHandler("w:jc"));
25359
- const translator$c = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "cellSpacing"));
25360
- const translator$b = NodeTranslator.from({
25343
+ const translator$K = NodeTranslator.from(createSingleAttrPropertyHandler("w:jc", "justification"));
25344
+ const translator$J = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "tableCellSpacing"));
25345
+ const translator$I = NodeTranslator.from({
25361
25346
  xmlName: "w:tblHeader",
25362
25347
  sdNodeOrKeyName: "repeatHeader",
25363
25348
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
25364
- decode: ({ node }) => node.attrs.repeatHeader ? {} : void 0
25349
+ decode: ({ node }) => node.attrs.repeatHeader ? { attributes: {} } : void 0
25365
25350
  });
25366
- const translator$a = NodeTranslator.from({
25351
+ const translator$H = NodeTranslator.from({
25367
25352
  xmlName: "w:trHeight",
25368
25353
  sdNodeOrKeyName: "rowHeight",
25369
25354
  encode: ({ nodes }) => {
@@ -25387,14 +25372,14 @@ const translator$a = NodeTranslator.from({
25387
25372
  if (node.attrs.rowHeight.rule) {
25388
25373
  heightAttrs["w:hRule"] = node.attrs.rowHeight.rule;
25389
25374
  }
25390
- return Object.keys(heightAttrs).length > 0 ? heightAttrs : void 0;
25375
+ return Object.keys(heightAttrs).length > 0 ? { attributes: heightAttrs } : void 0;
25391
25376
  }
25392
25377
  });
25393
- const translator$9 = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
25394
- const translator$8 = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
25395
- const XML_NODE_NAME$7 = "w:trPr";
25396
- const SD_ATTR_KEY = "tableRowProperties";
25397
- const encode$7 = (params2) => {
25378
+ const translator$G = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
25379
+ const translator$F = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
25380
+ const XML_NODE_NAME$c = "w:trPr";
25381
+ const SD_ATTR_KEY$4 = "tableRowProperties";
25382
+ const encode$c = (params2) => {
25398
25383
  const { nodes } = params2;
25399
25384
  const node = nodes[0];
25400
25385
  let attributes = {
@@ -25404,18 +25389,18 @@ const encode$7 = (params2) => {
25404
25389
  };
25405
25390
  attributes = {
25406
25391
  ...attributes,
25407
- ...encodeProperties(node, propertyTranslatorsByXmlName)
25392
+ ...encodeProperties(node, propertyTranslatorsByXmlName$2)
25408
25393
  };
25409
25394
  return {
25410
25395
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25411
- xmlName: XML_NODE_NAME$7,
25412
- sdNodeOrKeyName: SD_ATTR_KEY,
25396
+ xmlName: XML_NODE_NAME$c,
25397
+ sdNodeOrKeyName: SD_ATTR_KEY$4,
25413
25398
  attributes
25414
25399
  };
25415
25400
  };
25416
- const decode$7 = (params2) => {
25401
+ const decode$c = (params2) => {
25417
25402
  const { tableRowProperties = {} } = params2.node.attrs || {};
25418
- const elements = decodeProperties(propertyTranslatorsBySdName, tableRowProperties);
25403
+ const elements = decodeProperties(propertyTranslatorsBySdName$2, tableRowProperties);
25419
25404
  const newNode = {
25420
25405
  name: "w:trPr",
25421
25406
  type: "element",
@@ -25424,47 +25409,47 @@ const decode$7 = (params2) => {
25424
25409
  };
25425
25410
  return newNode;
25426
25411
  };
25427
- const propertyTranslators = [
25428
- translator$j,
25429
- translator$i,
25430
- translator$h,
25431
- translator$g,
25432
- translator$f,
25433
- translator$e,
25434
- translator$d,
25435
- translator$c,
25436
- translator$b,
25437
- translator$a,
25438
- translator$9,
25439
- translator$8
25412
+ const propertyTranslators$3 = [
25413
+ translator$Q,
25414
+ translator$P,
25415
+ translator$O,
25416
+ translator$N,
25417
+ translator$M,
25418
+ translator$L,
25419
+ translator$K,
25420
+ translator$J,
25421
+ translator$I,
25422
+ translator$H,
25423
+ translator$G,
25424
+ translator$F
25440
25425
  ];
25441
- const propertyTranslatorsByXmlName = {};
25442
- propertyTranslators.forEach((translator2) => {
25443
- propertyTranslatorsByXmlName[translator2.xmlName] = translator2;
25426
+ const propertyTranslatorsByXmlName$2 = {};
25427
+ propertyTranslators$3.forEach((translator2) => {
25428
+ propertyTranslatorsByXmlName$2[translator2.xmlName] = translator2;
25444
25429
  });
25445
- const propertyTranslatorsBySdName = {};
25446
- propertyTranslators.forEach((translator2) => {
25447
- propertyTranslatorsBySdName[translator2.sdNodeOrKeyName] = translator2;
25430
+ const propertyTranslatorsBySdName$2 = {};
25431
+ propertyTranslators$3.forEach((translator2) => {
25432
+ propertyTranslatorsBySdName$2[translator2.sdNodeOrKeyName] = translator2;
25448
25433
  });
25449
- const config$7 = {
25450
- xmlName: XML_NODE_NAME$7,
25451
- sdNodeOrKeyName: SD_ATTR_KEY,
25434
+ const config$a = {
25435
+ xmlName: XML_NODE_NAME$c,
25436
+ sdNodeOrKeyName: SD_ATTR_KEY$4,
25452
25437
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25453
- encode: encode$7,
25454
- decode: decode$7
25438
+ encode: encode$c,
25439
+ decode: decode$c
25455
25440
  };
25456
- const translator$7 = NodeTranslator.from(config$7);
25457
- const XML_NODE_NAME$6 = "w:tr";
25458
- const SD_NODE_NAME$6 = "tableRow";
25441
+ const translator$E = NodeTranslator.from(config$a);
25442
+ const XML_NODE_NAME$b = "w:tr";
25443
+ const SD_NODE_NAME$7 = "tableRow";
25459
25444
  const validXmlAttributes$6 = ["w:rsidDel", "w:rsidR", "w:rsidRPr", "w:rsidTr", "w14:paraId", "w14:textId"].map(
25460
25445
  (xmlName) => createAttributeHandler(xmlName)
25461
25446
  );
25462
- const encode$6 = (params2, encodedAttrs) => {
25463
- const { row, table } = params2.extraParams;
25447
+ const encode$b = (params2, encodedAttrs) => {
25448
+ const { row } = params2.extraParams;
25464
25449
  let tableRowProperties = {};
25465
25450
  const tPr = row.elements.find((el) => el.name === "w:trPr");
25466
25451
  if (tPr) {
25467
- ({ attributes: tableRowProperties } = translator$7.encode({
25452
+ ({ attributes: tableRowProperties } = translator$E.encode({
25468
25453
  ...params2,
25469
25454
  nodes: [tPr]
25470
25455
  }));
@@ -25472,7 +25457,7 @@ const encode$6 = (params2, encodedAttrs) => {
25472
25457
  encodedAttrs["tableRowProperties"] = Object.freeze(tableRowProperties);
25473
25458
  encodedAttrs["rowHeight"] = twipsToPixels(tableRowProperties["rowHeight"]?.value);
25474
25459
  encodedAttrs["cantSplit"] = tableRowProperties["cantSplit"];
25475
- const gridColumnWidths = _getGridColumnWidths(table);
25460
+ const { columnWidths: gridColumnWidths } = params2.extraParams;
25476
25461
  const cellNodes = row.elements.filter((el) => el.name === "w:tc");
25477
25462
  let currentColumnIndex = 0;
25478
25463
  const content = cellNodes?.map((n) => {
@@ -25499,16 +25484,7 @@ const encode$6 = (params2, encodedAttrs) => {
25499
25484
  };
25500
25485
  return newNode;
25501
25486
  };
25502
- const _getGridColumnWidths = (tableNode) => {
25503
- const tblGrid = tableNode.elements.find((el) => el.name === "w:tblGrid");
25504
- if (!tblGrid) return [];
25505
- const columnWidths = tblGrid?.elements?.flatMap((el) => {
25506
- if (el.name !== "w:gridCol") return [];
25507
- return twipsToPixels(el.attributes["w:w"]);
25508
- }) || [];
25509
- return columnWidths;
25510
- };
25511
- const decode$6 = (params2, decodedAttrs) => {
25487
+ const decode$b = (params2, decodedAttrs) => {
25512
25488
  const { node } = params2;
25513
25489
  const elements = translateChildNodes(params2);
25514
25490
  if (node.attrs?.tableRowProperties) {
@@ -25520,7 +25496,7 @@ const decode$6 = (params2, decodedAttrs) => {
25520
25496
  }
25521
25497
  }
25522
25498
  tableRowProperties["cantSplit"] = node.attrs["cantSplit"];
25523
- const trPr = translator$7.decode({
25499
+ const trPr = translator$E.decode({
25524
25500
  ...params2,
25525
25501
  node: { ...node, attrs: { ...node.attrs, tableRowProperties } }
25526
25502
  });
@@ -25532,86 +25508,348 @@ const decode$6 = (params2, decodedAttrs) => {
25532
25508
  elements
25533
25509
  };
25534
25510
  };
25535
- const config$6 = {
25536
- xmlName: XML_NODE_NAME$6,
25537
- sdNodeOrKeyName: SD_NODE_NAME$6,
25511
+ const config$9 = {
25512
+ xmlName: XML_NODE_NAME$b,
25513
+ sdNodeOrKeyName: SD_NODE_NAME$7,
25538
25514
  type: NodeTranslator.translatorTypes.NODE,
25539
- encode: encode$6,
25540
- decode: decode$6,
25515
+ encode: encode$b,
25516
+ decode: decode$b,
25541
25517
  attributes: validXmlAttributes$6
25542
25518
  };
25543
- const translator$6 = NodeTranslator.from(config$6);
25544
- const handleAllTableNodes = (params2) => {
25545
- const { nodes } = params2;
25546
- if (nodes.length === 0) {
25547
- return { nodes: [], consumed: 0 };
25519
+ const translator$D = NodeTranslator.from(config$9);
25520
+ const translator$C = NodeTranslator.from({
25521
+ xmlName: "w:bidiVisual",
25522
+ sdNodeOrKeyName: "rightToLeft",
25523
+ encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
25524
+ decode: ({ node }) => node.attrs.rightToLeft ? { attributes: {} } : void 0
25525
+ });
25526
+ const translator$B = NodeTranslator.from({
25527
+ xmlName: "w:shd",
25528
+ sdNodeOrKeyName: "shading",
25529
+ attributes: [
25530
+ "w:color",
25531
+ "w:fill",
25532
+ "w:themeColor",
25533
+ "w:themeFill",
25534
+ "w:themeFillShade",
25535
+ "w:themeFillTint",
25536
+ "w:themeShade",
25537
+ "w:themeTint",
25538
+ "w:val"
25539
+ ].map((attr) => createAttributeHandler(attr)),
25540
+ encode: (_2, encodedAttrs) => {
25541
+ return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
25542
+ },
25543
+ decode: function({ node }, _2) {
25544
+ const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs.shading || {} } });
25545
+ return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
25548
25546
  }
25547
+ });
25548
+ const translator$A = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblCaption", "caption"));
25549
+ const translator$z = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblDescription", "description"));
25550
+ const translator$y = NodeTranslator.from(createMeasurementPropertyHandler("w:tblInd", "tableIndent"));
25551
+ const translator$x = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblLayout", "tableLayout", "w:type"));
25552
+ const translator$w = NodeTranslator.from({
25553
+ xmlName: "w:tblLook",
25554
+ sdNodeOrKeyName: "tblLook",
25555
+ attributes: ["w:firstColumn", "w:firstRow", "w:lastColumn", "w:lastRow", "w:noHBand", "w:noVBand"].map((attr) => createAttributeHandler(attr, null, parseBoolean, booleanToString)).concat([createAttributeHandler("w:val")]),
25556
+ encode: (_2, encodedAttrs) => {
25557
+ return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
25558
+ },
25559
+ decode: function({ node }, _2) {
25560
+ const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs.tblLook || {} } });
25561
+ return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
25562
+ }
25563
+ });
25564
+ const translator$v = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblOverlap", "overlap"));
25565
+ const translator$u = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblStyle", "tableStyleId"));
25566
+ const translator$t = NodeTranslator.from(
25567
+ createSingleAttrPropertyHandler("w:tblStyleColBandSize", "tableStyleColBandSize")
25568
+ );
25569
+ const translator$s = NodeTranslator.from(
25570
+ createSingleAttrPropertyHandler("w:tblStyleRowBandSize", "tableStyleRowBandSize")
25571
+ );
25572
+ const translator$r = NodeTranslator.from(createMeasurementPropertyHandler("w:tblW", "tableWidth"));
25573
+ const translator$q = NodeTranslator.from({
25574
+ xmlName: "w:tblpPr",
25575
+ sdNodeOrKeyName: "floatingTableProperties",
25576
+ attributes: ["w:leftFromText", "w:rightFromText", "w:topFromText", "w:bottomFromText", "w:tblpX", "w:tblpY"].map((attr) => createAttributeHandler(attr, null, parseInteger, integerToString)).concat(["w:horzAnchor", "w:vertAnchor", "w:tblpXSpec", "w:tblpYSpec"].map((attr) => createAttributeHandler(attr))),
25577
+ encode: (_2, encodedAttrs) => {
25578
+ return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
25579
+ },
25580
+ decode: function({ node }, _2) {
25581
+ const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs.floatingTableProperties || {} } });
25582
+ return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
25583
+ }
25584
+ });
25585
+ const translator$p = NodeTranslator.from(createBorderPropertyHandler("w:bottom"));
25586
+ const translator$o = NodeTranslator.from(createMeasurementPropertyHandler("w:bottom", "marginBottom"));
25587
+ const translator$n = NodeTranslator.from(createBorderPropertyHandler("w:end"));
25588
+ const translator$m = NodeTranslator.from(createMeasurementPropertyHandler("w:end", "marginEnd"));
25589
+ const translator$l = NodeTranslator.from(createBorderPropertyHandler("w:insideH"));
25590
+ const translator$k = NodeTranslator.from(createBorderPropertyHandler("w:insideV"));
25591
+ const translator$j = NodeTranslator.from(createBorderPropertyHandler("w:left"));
25592
+ const translator$i = NodeTranslator.from(createMeasurementPropertyHandler("w:left", "marginLeft"));
25593
+ const translator$h = NodeTranslator.from(createBorderPropertyHandler("w:right"));
25594
+ const translator$g = NodeTranslator.from(createMeasurementPropertyHandler("w:right", "marginRight"));
25595
+ const translator$f = NodeTranslator.from(createBorderPropertyHandler("w:start"));
25596
+ const translator$e = NodeTranslator.from(createMeasurementPropertyHandler("w:start", "marginStart"));
25597
+ const translator$d = NodeTranslator.from(createBorderPropertyHandler("w:top"));
25598
+ const translator$c = NodeTranslator.from(createMeasurementPropertyHandler("w:top", "marginTop"));
25599
+ const XML_NODE_NAME$a = "w:tblBorders";
25600
+ const SD_ATTR_KEY$3 = "borders";
25601
+ const encode$a = (params2, _2) => {
25602
+ const { nodes } = params2;
25549
25603
  const node = nodes[0];
25550
- switch (node.name) {
25551
- case "w:tbl":
25552
- return { nodes: [handleTableNode(node, params2)], consumed: 1 };
25604
+ const attributes = encodeProperties(node, tblBordersTranslatorsByXmlName);
25605
+ return Object.keys(attributes).length > 0 ? attributes : void 0;
25606
+ };
25607
+ const decode$a = (params2, _2) => {
25608
+ const { borders = {} } = params2.node.attrs || {};
25609
+ const elements = decodeProperties(tblBordersTranslatorsBySdName, borders);
25610
+ const newNode = {
25611
+ name: "w:tblBorders",
25612
+ type: "element",
25613
+ attributes: {},
25614
+ elements
25615
+ };
25616
+ return newNode;
25617
+ };
25618
+ const propertyTranslators$2 = [
25619
+ translator$p,
25620
+ translator$n,
25621
+ translator$l,
25622
+ translator$k,
25623
+ translator$j,
25624
+ translator$h,
25625
+ translator$f,
25626
+ translator$d
25627
+ ];
25628
+ const tblBordersTranslatorsByXmlName = {};
25629
+ const tblBordersTranslatorsBySdName = {};
25630
+ propertyTranslators$2.forEach((translator2) => {
25631
+ tblBordersTranslatorsByXmlName[translator2.xmlName] = translator2;
25632
+ tblBordersTranslatorsBySdName[translator2.sdNodeOrKeyName] = translator2;
25633
+ });
25634
+ const translator$b = NodeTranslator.from({
25635
+ xmlName: XML_NODE_NAME$a,
25636
+ sdNodeOrKeyName: SD_ATTR_KEY$3,
25637
+ type: NodeTranslator.translatorTypes.NODE,
25638
+ attributes: [],
25639
+ encode: encode$a,
25640
+ decode: decode$a
25641
+ });
25642
+ const XML_NODE_NAME$9 = "w:tblCellMar";
25643
+ const SD_ATTR_KEY$2 = "cellMargins";
25644
+ const encode$9 = (params2, _2) => {
25645
+ const { nodes } = params2;
25646
+ const node = nodes[0];
25647
+ const attributes = encodeProperties(node, propertyTranslatorsByXmlName$1);
25648
+ return Object.keys(attributes).length > 0 ? attributes : void 0;
25649
+ };
25650
+ const decode$9 = (params2, _2) => {
25651
+ const { cellMargins = {} } = params2.node.attrs || {};
25652
+ const elements = decodeProperties(propertyTranslatorsBySdName$1, cellMargins);
25653
+ const newNode = {
25654
+ name: XML_NODE_NAME$9,
25655
+ type: "element",
25656
+ attributes: {},
25657
+ elements
25658
+ };
25659
+ return newNode;
25660
+ };
25661
+ const propertyTranslators$1 = [
25662
+ translator$o,
25663
+ translator$m,
25664
+ translator$i,
25665
+ translator$g,
25666
+ translator$e,
25667
+ translator$c
25668
+ ];
25669
+ const propertyTranslatorsByXmlName$1 = {};
25670
+ const propertyTranslatorsBySdName$1 = {};
25671
+ propertyTranslators$1.forEach((translator2) => {
25672
+ propertyTranslatorsByXmlName$1[translator2.xmlName] = translator2;
25673
+ propertyTranslatorsBySdName$1[translator2.sdNodeOrKeyName] = translator2;
25674
+ });
25675
+ const translator$a = NodeTranslator.from({
25676
+ xmlName: XML_NODE_NAME$9,
25677
+ sdNodeOrKeyName: SD_ATTR_KEY$2,
25678
+ type: NodeTranslator.translatorTypes.NODE,
25679
+ attributes: [],
25680
+ encode: encode$9,
25681
+ decode: decode$9
25682
+ });
25683
+ const XML_NODE_NAME$8 = "w:tblPr";
25684
+ const SD_ATTR_KEY$1 = "tableProperties";
25685
+ const encode$8 = (params2) => {
25686
+ const { nodes } = params2;
25687
+ const node = nodes[0];
25688
+ const attributes = encodeProperties(node, propertyTranslatorsByXmlName);
25689
+ return {
25690
+ xmlName: XML_NODE_NAME$8,
25691
+ sdNodeOrKeyName: SD_ATTR_KEY$1,
25692
+ attributes
25693
+ };
25694
+ };
25695
+ const decode$8 = (params2) => {
25696
+ const { tableProperties = {} } = params2.node.attrs || {};
25697
+ const elements = decodeProperties(propertyTranslatorsBySdName, tableProperties);
25698
+ const newNode = {
25699
+ name: "w:tblPr",
25700
+ type: "element",
25701
+ attributes: {},
25702
+ elements
25703
+ };
25704
+ return newNode;
25705
+ };
25706
+ const propertyTranslators = [
25707
+ translator$C,
25708
+ translator$K,
25709
+ translator$B,
25710
+ translator$A,
25711
+ translator$J,
25712
+ translator$z,
25713
+ translator$y,
25714
+ translator$x,
25715
+ translator$w,
25716
+ translator$v,
25717
+ translator$u,
25718
+ translator$t,
25719
+ translator$s,
25720
+ translator$r,
25721
+ translator$q,
25722
+ translator$b,
25723
+ translator$a
25724
+ ];
25725
+ const propertyTranslatorsByXmlName = {};
25726
+ const propertyTranslatorsBySdName = {};
25727
+ propertyTranslators.forEach((translator2) => {
25728
+ propertyTranslatorsByXmlName[translator2.xmlName] = translator2;
25729
+ propertyTranslatorsBySdName[translator2.sdNodeOrKeyName] = translator2;
25730
+ });
25731
+ const config$8 = {
25732
+ xmlName: XML_NODE_NAME$8,
25733
+ sdNodeOrKeyName: SD_ATTR_KEY$1,
25734
+ encode: encode$8,
25735
+ decode: decode$8
25736
+ };
25737
+ const translator$9 = NodeTranslator.from(config$8);
25738
+ const translator$8 = NodeTranslator.from(
25739
+ createSingleAttrPropertyHandler("w:gridCol", "col", "w:w", parseInteger, integerToString)
25740
+ );
25741
+ const XML_NODE_NAME$7 = "w:tblGrid";
25742
+ const SD_ATTR_KEY = "grid";
25743
+ const cellMinWidth = pixelsToTwips(10);
25744
+ const encode$7 = (params2) => {
25745
+ const { nodes } = params2;
25746
+ const node = nodes[0];
25747
+ const attributes = encodeProperties(node, { [translator$8.xmlName]: translator$8 }, true);
25748
+ return {
25749
+ xmlName: XML_NODE_NAME$7,
25750
+ sdNodeOrKeyName: SD_ATTR_KEY,
25751
+ attributes
25752
+ };
25753
+ };
25754
+ const decode$7 = (params2) => {
25755
+ const { grid = [] } = params2.node.attrs || {};
25756
+ const { firstRow = {} } = params2.extraParams || {};
25757
+ const cellNodes = firstRow.content?.filter((n) => n.type === "tableCell") ?? [];
25758
+ const numberOfColumns = cellNodes.length || grid.length;
25759
+ const elements = [];
25760
+ for (let cellIdx = 0; cellIdx < numberOfColumns; cellIdx++) {
25761
+ const cell = cellNodes[cellIdx];
25762
+ const { colspan = 1, colwidth } = cell?.attrs || {};
25763
+ for (let mergedCellIdx = 0; mergedCellIdx < colspan; mergedCellIdx++) {
25764
+ const cellWidthPixels = colwidth && colwidth[mergedCellIdx];
25765
+ const colGridAttrs = grid?.[mergedCellIdx] || {};
25766
+ const gridWidthTwips = colGridAttrs.col;
25767
+ const gridWidthPixels = twipsToPixels(gridWidthTwips);
25768
+ let cellWidthTwips;
25769
+ if (gridWidthPixels === cellWidthPixels) {
25770
+ cellWidthTwips = gridWidthTwips;
25771
+ } else if (cellWidthPixels) {
25772
+ cellWidthTwips = pixelsToTwips(cellWidthPixels);
25773
+ }
25774
+ const widthTwips = Math.max(cellWidthTwips, cellMinWidth);
25775
+ elements.push(
25776
+ translator$8.decode({
25777
+ node: { type: (
25778
+ /** @type {string} */
25779
+ translator$8.sdNodeOrKeyName
25780
+ ), attrs: { col: widthTwips } }
25781
+ })
25782
+ );
25783
+ }
25553
25784
  }
25554
- return { nodes: [], consumed: 0 };
25785
+ const newNode = {
25786
+ name: XML_NODE_NAME$7,
25787
+ attributes: {},
25788
+ elements
25789
+ };
25790
+ return newNode;
25555
25791
  };
25556
- const tableNodeHandlerEntity = {
25557
- handlerName: "tableNodeHandler",
25558
- handler: handleAllTableNodes
25792
+ const config$7 = {
25793
+ xmlName: XML_NODE_NAME$7,
25794
+ sdNodeOrKeyName: SD_ATTR_KEY,
25795
+ encode: encode$7,
25796
+ decode: decode$7
25559
25797
  };
25560
- function handleTableNode(node, params2) {
25561
- const { docx, nodeListHandler } = params2;
25798
+ const translator$7 = NodeTranslator.from(config$7);
25799
+ const XML_NODE_NAME$6 = "w:tbl";
25800
+ const SD_NODE_NAME$6 = "table";
25801
+ const encode$6 = (params2, encodedAttrs) => {
25802
+ const { nodes } = params2;
25803
+ const node = nodes[0];
25562
25804
  const tblPr = node.elements.find((el) => el.name === "w:tblPr");
25563
- const tableBordersElement = tblPr.elements.find((el) => el.name === "w:tblBorders");
25564
- const tableBorders = tableBordersElement?.elements || [];
25565
- const { borders, rowBorders } = processTableBorders(tableBorders);
25566
- const tblStyleTag = tblPr.elements.find((el) => el.name === "w:tblStyle");
25567
- const tableStyleId = tblStyleTag?.attributes["w:val"];
25568
- const attrs = { tableStyleId };
25569
- const tableIndent = tblPr?.elements.find((el) => el.name === "w:tblInd");
25570
- if (tableIndent) {
25571
- const { "w:w": width, "w:type": type2 } = tableIndent.attributes;
25572
- attrs["tableIndent"] = { width: twipsToPixels(width), type: type2 };
25573
- }
25574
- const tableLayout = tblPr?.elements.find((el) => el.name === "w:tblLayout");
25575
- if (tableLayout) {
25576
- const { "w:type": type2 } = tableLayout.attributes;
25577
- attrs["tableLayout"] = type2;
25578
- }
25579
- const referencedStyles = getReferencedTableStyles(tblStyleTag, docx);
25580
- const tblW = tblPr.elements.find((el) => el.name === "w:tblW");
25581
- if (tblW) {
25582
- attrs["tableWidth"] = {
25583
- width: twipsToPixels(tblW.attributes["w:w"]),
25584
- type: tblW.attributes["w:type"]
25585
- };
25586
- }
25587
- const tblCellSpacing = tblPr.elements.find((el) => el.name === "w:tblCellSpacing");
25588
- if (tblCellSpacing) {
25589
- attrs["tableCellSpacing"] = {
25590
- w: tblCellSpacing.attributes["w:w"],
25591
- type: tblCellSpacing.attributes["w:type"]
25592
- };
25593
- attrs["borderCollapse"] = "separate";
25594
- }
25595
- const tblJustification = tblPr.elements.find((el) => el.name === "w:jc");
25596
- if (tblJustification?.attributes) {
25597
- attrs["justification"] = tblJustification.attributes["w:val"];
25805
+ if (tblPr) {
25806
+ encodedAttrs["tableProperties"] = translator$9.encode({ ...params2, nodes: [tblPr] }).attributes;
25807
+ }
25808
+ const tblGrid = node.elements.find((el) => el.name === "w:tblGrid");
25809
+ if (tblGrid) {
25810
+ encodedAttrs["grid"] = translator$7.encode({ ...params2, nodes: [tblGrid] }).attributes;
25598
25811
  }
25812
+ [
25813
+ "tableStyleId",
25814
+ "justification",
25815
+ "tableLayout",
25816
+ ["tableIndent", ({ value, type: type2 }) => ({ width: twipsToPixels(value), type: type2 })],
25817
+ ["tableWidth", ({ value, type: type2 }) => ({ width: twipsToPixels(value), type: type2 })],
25818
+ ["tableCellSpacing", ({ value, type: type2 }) => ({ w: String(value), type: type2 })]
25819
+ ].forEach((prop) => {
25820
+ let key2;
25821
+ let transform;
25822
+ if (Array.isArray(prop)) {
25823
+ [key2, transform] = prop;
25824
+ } else {
25825
+ key2 = prop;
25826
+ transform = (v2) => v2;
25827
+ }
25828
+ if (encodedAttrs.tableProperties?.[key2]) {
25829
+ encodedAttrs[key2] = transform(encodedAttrs.tableProperties[key2]);
25830
+ }
25831
+ });
25832
+ if (encodedAttrs.tableCellSpacing) {
25833
+ encodedAttrs["borderCollapse"] = "separate";
25834
+ }
25835
+ const { borders, rowBorders } = _processTableBorders(encodedAttrs.tableProperties?.borders || {});
25836
+ const referencedStyles = _getReferencedTableStyles(encodedAttrs.tableStyleId, params2);
25599
25837
  const rows = node.elements.filter((el) => el.name === "w:tr");
25600
- const refStylesBorders = referencedStyles?.borders || {};
25601
- const refStylesRowBorders = referencedStyles?.rowBorders || {};
25602
- const borderData = Object.keys(borders)?.length ? Object.assign(refStylesBorders, borders) : refStylesBorders;
25603
- const borderRowData = Object.keys(rowBorders)?.length ? Object.assign(refStylesRowBorders, rowBorders) : refStylesRowBorders;
25604
- attrs["borders"] = borderData;
25838
+ const borderData = Object.assign({}, referencedStyles?.borders || {}, borders || {});
25839
+ const borderRowData = Object.assign({}, referencedStyles?.rowBorders || {}, rowBorders || {});
25840
+ encodedAttrs["borders"] = borderData;
25841
+ const tblStyleTag = tblPr.elements.find((el) => el.name === "w:tblStyle");
25842
+ const columnWidths = (encodedAttrs["grid"] ?? []).map((item) => twipsToPixels(item.col));
25605
25843
  const content = [];
25606
25844
  rows.forEach((row) => {
25607
- const result = translator$6.encode({
25845
+ const result = translator$D.encode({
25608
25846
  ...params2,
25609
25847
  nodes: [row],
25610
25848
  extraParams: {
25611
25849
  row,
25612
- table: node,
25613
25850
  rowBorders: borderRowData,
25614
- styleTag: tblStyleTag
25851
+ styleTag: tblStyleTag,
25852
+ columnWidths
25615
25853
  }
25616
25854
  });
25617
25855
  if (result.content?.length) content.push(result);
@@ -25619,9 +25857,113 @@ function handleTableNode(node, params2) {
25619
25857
  return {
25620
25858
  type: "table",
25621
25859
  content,
25622
- attrs
25860
+ attrs: encodedAttrs
25861
+ };
25862
+ };
25863
+ const decode$6 = (params2, decodedAttrs) => {
25864
+ params2.node = preProcessVerticalMergeCells(params2.node, params2);
25865
+ const { node } = params2;
25866
+ const elements = translateChildNodes(params2);
25867
+ const firstRow = node.content?.find((n) => n.type === "tableRow");
25868
+ const properties = node.attrs.grid;
25869
+ const element = translator$7.decode({
25870
+ ...params2,
25871
+ node: { ...node, attrs: { ...node.attrs, grid: properties } },
25872
+ extraParams: {
25873
+ firstRow
25874
+ }
25875
+ });
25876
+ if (element) elements.unshift(element);
25877
+ if (node.attrs?.tableProperties) {
25878
+ const properties2 = { ...node.attrs.tableProperties };
25879
+ const element2 = translator$9.decode({
25880
+ ...params2,
25881
+ node: { ...node, attrs: { ...node.attrs, tableProperties: properties2 } }
25882
+ });
25883
+ if (element2) elements.unshift(element2);
25884
+ }
25885
+ return {
25886
+ name: "w:tbl",
25887
+ attributes: decodedAttrs || {},
25888
+ elements
25889
+ };
25890
+ };
25891
+ function _processTableBorders(rawBorders) {
25892
+ const borders = {};
25893
+ const rowBorders = {};
25894
+ Object.entries(rawBorders).forEach(([name, attributes]) => {
25895
+ const attrs = {};
25896
+ const color = attributes.color;
25897
+ const size2 = attributes.size;
25898
+ if (color && color !== "auto") attrs["color"] = color.startsWith("#") ? color : `#${color}`;
25899
+ if (size2 && size2 !== "auto") attrs["size"] = eigthPointsToPixels(size2);
25900
+ const rowBorderNames = ["insideH", "insideV"];
25901
+ if (rowBorderNames.includes(name)) rowBorders[name] = attrs;
25902
+ borders[name] = attrs;
25903
+ });
25904
+ return {
25905
+ borders,
25906
+ rowBorders
25623
25907
  };
25624
25908
  }
25909
+ function _getReferencedTableStyles(tableStyleReference, params2) {
25910
+ if (!tableStyleReference) return null;
25911
+ const stylesToReturn = {};
25912
+ const { docx } = params2;
25913
+ const styles = docx["word/styles.xml"];
25914
+ const { elements } = styles.elements[0];
25915
+ const styleElements = elements.filter((el) => el.name === "w:style");
25916
+ const styleTag = styleElements.find((el) => el.attributes["w:styleId"] === tableStyleReference);
25917
+ if (!styleTag) return null;
25918
+ stylesToReturn.name = styleTag.elements.find((el) => el.name === "w:name");
25919
+ const basedOn = styleTag.elements.find((el) => el.name === "w:basedOn");
25920
+ let baseTblPr;
25921
+ if (basedOn?.attributes) {
25922
+ const baseStyles = styleElements.find((el) => el.attributes["w:styleId"] === basedOn.attributes["w:val"]);
25923
+ baseTblPr = baseStyles ? baseStyles.elements.find((el) => el.name === "w:tblPr") : {};
25924
+ }
25925
+ const pPr = styleTag.elements.find((el) => el.name === "w:pPr");
25926
+ if (pPr) {
25927
+ const justification = pPr.elements.find((el) => el.name === "w:jc");
25928
+ if (justification?.attributes) stylesToReturn.justification = justification.attributes["w:val"];
25929
+ }
25930
+ const rPr = styleTag?.elements.find((el) => el.name === "w:rPr");
25931
+ if (rPr) {
25932
+ const fonts = rPr.elements.find((el) => el.name === "w:rFonts");
25933
+ if (fonts) {
25934
+ const { "w:ascii": ascii, "w:hAnsi": hAnsi, "w:cs": cs } = fonts.attributes;
25935
+ stylesToReturn.fonts = { ascii, hAnsi, cs };
25936
+ }
25937
+ const fontSize2 = rPr.elements.find((el) => el.name === "w:sz");
25938
+ if (fontSize2?.attributes) stylesToReturn.fontSize = halfPointToPoints(fontSize2.attributes["w:val"]) + "pt";
25939
+ }
25940
+ const tblPr = styleTag.elements.find((el) => el.name === "w:tblPr");
25941
+ if (tblPr && tblPr.elements) {
25942
+ if (baseTblPr && baseTblPr.elements) {
25943
+ tblPr.elements.push(...baseTblPr.elements);
25944
+ }
25945
+ const tableProperties = translator$9.encode({ ...params2, nodes: [tblPr] }).attributes;
25946
+ const { borders, rowBorders } = _processTableBorders(tableProperties.borders || {});
25947
+ if (borders) stylesToReturn.borders = borders;
25948
+ if (rowBorders) stylesToReturn.rowBorders = rowBorders;
25949
+ const cellMargins = {};
25950
+ Object.entries(tableProperties.cellMargins || {}).forEach(([key2, attrs]) => {
25951
+ if (attrs?.value) cellMargins[key2] = String(attrs.value);
25952
+ });
25953
+ if (Object.keys(cellMargins).length) stylesToReturn.cellMargins = cellMargins;
25954
+ }
25955
+ return stylesToReturn;
25956
+ }
25957
+ const config$6 = {
25958
+ xmlName: XML_NODE_NAME$6,
25959
+ sdNodeOrKeyName: SD_NODE_NAME$6,
25960
+ type: NodeTranslator.translatorTypes.NODE,
25961
+ encode: encode$6,
25962
+ decode: decode$6,
25963
+ attributes: []
25964
+ };
25965
+ const translator$6 = NodeTranslator.from(config$6);
25966
+ const tableNodeHandlerEntity = generateV2HandlerEntity("tableNodeHandler", translator$6);
25625
25967
  function getReferencedTableStyles(tblStyleTag, docx) {
25626
25968
  if (!tblStyleTag) return null;
25627
25969
  const stylesToReturn = {};
@@ -25702,15 +26044,6 @@ function processTableBorders(borderElements) {
25702
26044
  rowBorders
25703
26045
  };
25704
26046
  }
25705
- const getGridColumnWidths = (tableNode) => {
25706
- const tblGrid = tableNode.elements.find((el) => el.name === "w:tblGrid");
25707
- if (!tblGrid) return [];
25708
- const columnWidths = tblGrid?.elements?.flatMap((el) => {
25709
- if (el.name !== "w:gridCol") return [];
25710
- return twipsToPixels(el.attributes["w:w"]);
25711
- }) || [];
25712
- return columnWidths;
25713
- };
25714
26047
  function handleTableCellNode({
25715
26048
  params: params2,
25716
26049
  node,
@@ -25719,7 +26052,8 @@ function handleTableCellNode({
25719
26052
  rowBorders,
25720
26053
  styleTag,
25721
26054
  columnIndex,
25722
- columnWidth = null
26055
+ columnWidth = null,
26056
+ allColumnWidths = []
25723
26057
  }) {
25724
26058
  const { docx, nodeListHandler } = params2;
25725
26059
  const tcPr = node.elements.find((el) => el.name === "w:tcPr");
@@ -25733,7 +26067,7 @@ function handleTableCellNode({
25733
26067
  delete rowBorders?.insideV;
25734
26068
  }
25735
26069
  const inlineBorders = processInlineCellBorders(borders, rowBorders);
25736
- const gridColumnWidths = getGridColumnWidths(table);
26070
+ const gridColumnWidths = allColumnWidths;
25737
26071
  const tcWidth = tcPr?.elements?.find((el) => el.name === "w:tcW");
25738
26072
  let width = tcWidth ? twipsToPixels(tcWidth.attributes["w:w"]) : null;
25739
26073
  const widthType = tcWidth?.attributes["w:type"];
@@ -25989,7 +26323,16 @@ const XML_NODE_NAME$5 = "w:tc";
25989
26323
  const SD_NODE_NAME$5 = "tableCell";
25990
26324
  const validXmlAttributes$5 = [];
25991
26325
  function encode$5(params2, encodedAttrs) {
25992
- const { node, table, row, rowBorders, styleTag, columnIndex, columnWidth } = params2.extraParams;
26326
+ const {
26327
+ node,
26328
+ table,
26329
+ row,
26330
+ rowBorders,
26331
+ styleTag,
26332
+ columnIndex,
26333
+ columnWidth,
26334
+ columnWidths: allColumnWidths
26335
+ } = params2.extraParams;
25993
26336
  const schemaNode = handleTableCellNode({
25994
26337
  params: params2,
25995
26338
  node,
@@ -25998,7 +26341,8 @@ function encode$5(params2, encodedAttrs) {
25998
26341
  rowBorders,
25999
26342
  styleTag,
26000
26343
  columnIndex,
26001
- columnWidth
26344
+ columnWidth,
26345
+ allColumnWidths
26002
26346
  });
26003
26347
  if (encodedAttrs && Object.keys(encodedAttrs).length) {
26004
26348
  schemaNode.attrs = { ...schemaNode.attrs, ...encodedAttrs };
@@ -26940,9 +27284,9 @@ const config$2 = {
26940
27284
  };
26941
27285
  const translator$2 = NodeTranslator.from(config$2);
26942
27286
  const registeredHandlers = Object.freeze({
26943
- "w:br": translator$m,
26944
- "w:tab": translator$l,
26945
- "w:p": translator$k,
27287
+ "w:br": translator$T,
27288
+ "w:tab": translator$S,
27289
+ "w:p": translator$R,
26946
27290
  "wp:anchor": translator$3,
26947
27291
  "wp:inline": translator$2
26948
27292
  });
@@ -28561,7 +28905,7 @@ function translateStructuredContent(params2) {
28561
28905
  const XML_NODE_NAME = "w:sdt";
28562
28906
  const SD_NODE_NAME = ["fieldAnnotation", "structuredContent", "structuredContentBlock", "documentSection"];
28563
28907
  const validXmlAttributes = [];
28564
- function encode$n(params2, encodedAttrs) {
28908
+ function encode$s(params2, encodedAttrs) {
28565
28909
  const nodes = params2.nodes;
28566
28910
  const node = nodes[0];
28567
28911
  const { type: sdtType, handler: handler2 } = sdtNodeTypeStrategy(node);
@@ -28591,7 +28935,7 @@ const config = {
28591
28935
  xmlName: XML_NODE_NAME,
28592
28936
  sdNodeOrKeyName: SD_NODE_NAME,
28593
28937
  type: NodeTranslator.translatorTypes.NODE,
28594
- encode: encode$n,
28938
+ encode: encode$s,
28595
28939
  decode,
28596
28940
  attributes: validXmlAttributes
28597
28941
  };
@@ -28602,19 +28946,19 @@ function exportSchemaToJson(params2) {
28602
28946
  doc: translateDocumentNode,
28603
28947
  body: translateBodyNode,
28604
28948
  heading: translateHeadingNode,
28605
- paragraph: translator$k,
28949
+ paragraph: translator$R,
28606
28950
  text: translateTextNode,
28607
28951
  bulletList: translateList,
28608
28952
  orderedList: translateList,
28609
- lineBreak: translator$m,
28610
- table: translateTable,
28611
- tableRow: translator$6,
28953
+ lineBreak: translator$T,
28954
+ table: translator$6,
28955
+ tableRow: translator$D,
28612
28956
  tableCell: translator$5,
28613
28957
  bookmarkStart: translateBookmarkStart,
28614
28958
  fieldAnnotation: translator,
28615
- tab: translator$l,
28959
+ tab: translator$S,
28616
28960
  image: translator$1,
28617
- hardBreak: translator$m,
28961
+ hardBreak: translator$T,
28618
28962
  commentRangeStart: () => translateCommentNode(params2, "Start"),
28619
28963
  commentRangeEnd: () => translateCommentNode(params2, "End"),
28620
28964
  commentReference: () => null,
@@ -29221,131 +29565,6 @@ const generateNumPrTag = (numId, level) => {
29221
29565
  ]
29222
29566
  };
29223
29567
  };
29224
- function translateTable(params2) {
29225
- params2.node = preProcessVerticalMergeCells(params2.node, params2);
29226
- const elements = translateChildNodes(params2);
29227
- const tableProperties = generateTableProperties(params2.node);
29228
- const gridProperties = generateTableGrid(params2.node, params2);
29229
- elements.unshift(tableProperties);
29230
- elements.unshift(gridProperties);
29231
- return {
29232
- name: "w:tbl",
29233
- elements
29234
- };
29235
- }
29236
- function generateTableProperties(node) {
29237
- const elements = [];
29238
- const { attrs } = node;
29239
- const { tableWidth, tableStyleId, borders, tableIndent, tableLayout, tableCellSpacing, justification } = attrs;
29240
- if (tableStyleId) {
29241
- const tableStyleElement = {
29242
- name: "w:tblStyle",
29243
- attributes: { "w:val": tableStyleId }
29244
- };
29245
- elements.push(tableStyleElement);
29246
- }
29247
- if (borders) {
29248
- const borderElement = generateTableBorders(node);
29249
- elements.push(borderElement);
29250
- }
29251
- if (tableIndent) {
29252
- const { width, type: type2 } = tableIndent;
29253
- const tableIndentElement = {
29254
- name: "w:tblInd",
29255
- attributes: { "w:w": pixelsToTwips(width), "w:type": type2 }
29256
- };
29257
- elements.push(tableIndentElement);
29258
- }
29259
- if (tableLayout) {
29260
- const tableLayoutElement = {
29261
- name: "w:tblLayout",
29262
- attributes: { "w:type": tableLayout }
29263
- };
29264
- elements.push(tableLayoutElement);
29265
- }
29266
- if (tableWidth && tableWidth.width) {
29267
- const tableWidthElement = {
29268
- name: "w:tblW",
29269
- attributes: { "w:w": pixelsToTwips(tableWidth.width), "w:type": tableWidth.type }
29270
- };
29271
- elements.push(tableWidthElement);
29272
- }
29273
- if (tableCellSpacing) {
29274
- elements.push({
29275
- name: "w:tblCellSpacing",
29276
- attributes: {
29277
- "w:w": tableCellSpacing.w,
29278
- "w:type": tableCellSpacing.type
29279
- }
29280
- });
29281
- }
29282
- if (justification) {
29283
- const justificationElement = {
29284
- name: "w:jc",
29285
- attributes: { "w:val": justification }
29286
- };
29287
- elements.push(justificationElement);
29288
- }
29289
- return {
29290
- name: "w:tblPr",
29291
- elements
29292
- };
29293
- }
29294
- function generateTableBorders(node) {
29295
- const { borders } = node.attrs;
29296
- const elements = [];
29297
- if (!borders) return;
29298
- const borderTypes = ["top", "bottom", "left", "right", "insideH", "insideV"];
29299
- borderTypes.forEach((type2) => {
29300
- const border = borders[type2];
29301
- if (!border) return;
29302
- let attributes = {};
29303
- if (!Object.keys(border).length || !border.size) {
29304
- attributes = {
29305
- "w:val": "nil"
29306
- };
29307
- } else {
29308
- attributes = {
29309
- "w:val": "single",
29310
- "w:sz": pixelsToEightPoints(border.size),
29311
- "w:space": border.space || 0,
29312
- "w:color": border?.color?.substring(1) || "000000"
29313
- };
29314
- }
29315
- const borderElement = {
29316
- name: `w:${type2}`,
29317
- attributes
29318
- };
29319
- elements.push(borderElement);
29320
- });
29321
- return {
29322
- name: "w:tblBorders",
29323
- elements
29324
- };
29325
- }
29326
- function generateTableGrid(node, params2) {
29327
- const { editorSchema } = params2;
29328
- let colgroup = [];
29329
- try {
29330
- const pmNode = editorSchema.nodeFromJSON(node);
29331
- const cellMinWidth = 10;
29332
- const { colgroupValues } = createColGroup(pmNode, cellMinWidth);
29333
- colgroup = colgroupValues;
29334
- } catch {
29335
- colgroup = [];
29336
- }
29337
- const elements = [];
29338
- colgroup?.forEach((width) => {
29339
- elements.push({
29340
- name: "w:gridCol",
29341
- attributes: { "w:w": pixelsToTwips(width) }
29342
- });
29343
- });
29344
- return {
29345
- name: "w:tblGrid",
29346
- elements
29347
- };
29348
- }
29349
29568
  function translateBookmarkStart(params2) {
29350
29569
  const bookmarkStartNode = {
29351
29570
  name: "w:bookmarkStart",
@@ -29921,7 +30140,7 @@ const handleParagraphNode = (params2) => {
29921
30140
  if (nodes.length === 0 || nodes[0].name !== "w:p") {
29922
30141
  return { nodes: [], consumed: 0 };
29923
30142
  }
29924
- const schemaNode = translator$k.encode(params2);
30143
+ const schemaNode = translator$R.encode(params2);
29925
30144
  const newNodes = schemaNode ? [schemaNode] : [];
29926
30145
  return { nodes: newNodes, consumed: 1 };
29927
30146
  };
@@ -30024,7 +30243,7 @@ const handler = (params2) => {
30024
30243
  if (nodes.length === 0 || nodes[0].name !== "w:br") {
30025
30244
  return { nodes: [], consumed: 0 };
30026
30245
  }
30027
- const result = translator$m.encode(params2);
30246
+ const result = translator$T.encode(params2);
30028
30247
  if (!result) return { nodes: [], consumed: 0 };
30029
30248
  return {
30030
30249
  nodes: [result],
@@ -30720,7 +30939,7 @@ const handleTabNode = (params2) => {
30720
30939
  if (!nodes.length || nodes[0].name !== "w:tab") {
30721
30940
  return { nodes: [], consumed: 0 };
30722
30941
  }
30723
- const node = translator$l.encode(params2);
30942
+ const node = translator$S.encode(params2);
30724
30943
  return { nodes: [node], consumed: 1 };
30725
30944
  };
30726
30945
  const tabNodeEntityHandler = {
@@ -53470,9 +53689,15 @@ const HardBreak = Node$1.create({
53470
53689
  };
53471
53690
  }
53472
53691
  });
53692
+ const getColStyleDeclaration = (minWidth, width) => {
53693
+ if (width) {
53694
+ return ["width", `${Math.max(width, minWidth)}px`];
53695
+ }
53696
+ return ["min-width", `${minWidth}px`];
53697
+ };
53473
53698
  const createTableView = ({ editor }) => {
53474
53699
  return class TableView {
53475
- constructor(node, cellMinWidth) {
53700
+ constructor(node, cellMinWidth2) {
53476
53701
  __publicField$1(this, "editor");
53477
53702
  __publicField$1(this, "node");
53478
53703
  __publicField$1(this, "dom");
@@ -53482,13 +53707,13 @@ const createTableView = ({ editor }) => {
53482
53707
  __publicField$1(this, "cellMinWidth");
53483
53708
  this.editor = editor;
53484
53709
  this.node = node;
53485
- this.cellMinWidth = cellMinWidth;
53710
+ this.cellMinWidth = cellMinWidth2;
53486
53711
  this.dom = document.createElement("div");
53487
53712
  this.dom.className = "tableWrapper";
53488
53713
  this.table = this.dom.appendChild(document.createElement("table"));
53489
53714
  this.colgroup = this.table.appendChild(document.createElement("colgroup"));
53490
53715
  updateTable(this.editor, this.node, this.table);
53491
- updateColumns(node, this.colgroup, this.table, cellMinWidth);
53716
+ updateColumns(node, this.colgroup, this.table, cellMinWidth2);
53492
53717
  this.contentDOM = this.table.appendChild(document.createElement("tbody"));
53493
53718
  setTimeout(() => {
53494
53719
  updateTableWrapper(this.dom, this.table);
@@ -53513,7 +53738,7 @@ const createTableView = ({ editor }) => {
53513
53738
  }
53514
53739
  };
53515
53740
  };
53516
- function updateColumns(node, colgroup, table, cellMinWidth, overrideCol, overrideValue) {
53741
+ function updateColumns(node, colgroup, table, cellMinWidth2, overrideCol, overrideValue) {
53517
53742
  let totalWidth = 0;
53518
53743
  let fixedWidth = true;
53519
53744
  let nextDOM = colgroup.firstChild;
@@ -53524,16 +53749,16 @@ function updateColumns(node, colgroup, table, cellMinWidth, overrideCol, overrid
53524
53749
  for (let j2 = 0; j2 < colspan; j2++, col++) {
53525
53750
  const hasWidth = overrideCol === col ? overrideValue : colwidth && colwidth[j2];
53526
53751
  const cssWidth = hasWidth ? `${hasWidth}px` : "";
53527
- totalWidth += hasWidth || cellMinWidth;
53752
+ totalWidth += hasWidth || cellMinWidth2;
53528
53753
  if (!hasWidth) fixedWidth = false;
53529
53754
  if (!nextDOM) {
53530
53755
  const col2 = document.createElement("col");
53531
- const [propKey, propVal] = getColStyleDeclaration(cellMinWidth, hasWidth);
53756
+ const [propKey, propVal] = getColStyleDeclaration(cellMinWidth2, hasWidth);
53532
53757
  col2.style.setProperty(propKey, propVal);
53533
53758
  colgroup.appendChild(col2);
53534
53759
  } else {
53535
53760
  if (nextDOM.style.width !== cssWidth) {
53536
- const [propKey, propVal] = getColStyleDeclaration(cellMinWidth, hasWidth);
53761
+ const [propKey, propVal] = getColStyleDeclaration(cellMinWidth2, hasWidth);
53537
53762
  nextDOM.style.setProperty(propKey, propVal);
53538
53763
  }
53539
53764
  nextDOM = nextDOM.nextSibling;
@@ -53630,6 +53855,35 @@ const createTable = (schema, rowsCount, colsCount, withHeaderRow, cellContent =
53630
53855
  const tableBorders = createTableBorders();
53631
53856
  return types2.table.createChecked({ borders: tableBorders }, rows);
53632
53857
  };
53858
+ const createColGroup = (node, cellMinWidth2, overrideCol, overrideValue) => {
53859
+ let totalWidth = 0;
53860
+ let fixedWidth = true;
53861
+ const cols = [];
53862
+ const colsValues = [];
53863
+ const row = node.firstChild;
53864
+ if (!row) return {};
53865
+ for (let i = 0, col = 0; i < row.childCount; i++) {
53866
+ const { colspan, colwidth } = row.child(i).attrs;
53867
+ for (let j2 = 0; j2 < colspan; j2++, col++) {
53868
+ const hasWidth = overrideCol === col ? overrideValue : colwidth && colwidth[j2];
53869
+ totalWidth += hasWidth || cellMinWidth2;
53870
+ if (!hasWidth) fixedWidth = false;
53871
+ const [prop, value] = getColStyleDeclaration(cellMinWidth2, hasWidth);
53872
+ cols.push(["col", { style: `${prop}: ${value}` }]);
53873
+ colsValues.push(parseInt(value, 10));
53874
+ }
53875
+ }
53876
+ const tableWidth = fixedWidth ? `${totalWidth}px` : "";
53877
+ const tableMinWidth = fixedWidth ? "" : `${totalWidth}px`;
53878
+ const colgroup = ["colgroup", {}, ...cols];
53879
+ const colgroupValues = [...colsValues];
53880
+ return {
53881
+ colgroup,
53882
+ tableWidth,
53883
+ tableMinWidth,
53884
+ colgroupValues
53885
+ };
53886
+ };
53633
53887
  var readFromCache;
53634
53888
  var addToCache;
53635
53889
  if (typeof WeakMap != "undefined") {
@@ -55447,7 +55701,7 @@ var columnResizingPluginKey = new PluginKey(
55447
55701
  );
55448
55702
  function columnResizing({
55449
55703
  handleWidth = 5,
55450
- cellMinWidth = 25,
55704
+ cellMinWidth: cellMinWidth2 = 25,
55451
55705
  defaultCellMinWidth = 100,
55452
55706
  View = TableView,
55453
55707
  lastColumnResizable = true
@@ -55483,7 +55737,7 @@ function columnResizing({
55483
55737
  handleMouseLeave(view);
55484
55738
  },
55485
55739
  mousedown: (view, event) => {
55486
- handleMouseDown2(view, event, cellMinWidth, defaultCellMinWidth);
55740
+ handleMouseDown2(view, event, cellMinWidth2, defaultCellMinWidth);
55487
55741
  }
55488
55742
  },
55489
55743
  decorations: (state2) => {
@@ -55554,7 +55808,7 @@ function handleMouseLeave(view) {
55554
55808
  if (pluginState && pluginState.activeHandle > -1 && !pluginState.dragging)
55555
55809
  updateHandle(view, -1);
55556
55810
  }
55557
- function handleMouseDown2(view, event, cellMinWidth, defaultCellMinWidth) {
55811
+ function handleMouseDown2(view, event, cellMinWidth2, defaultCellMinWidth) {
55558
55812
  var _a2;
55559
55813
  if (!view.editable) return false;
55560
55814
  const win = (_a2 = view.dom.ownerDocument.defaultView) != null ? _a2 : window;
@@ -55576,7 +55830,7 @@ function handleMouseDown2(view, event, cellMinWidth, defaultCellMinWidth) {
55576
55830
  updateColumnWidth(
55577
55831
  view,
55578
55832
  pluginState2.activeHandle,
55579
- draggedWidth(pluginState2.dragging, event2, cellMinWidth)
55833
+ draggedWidth(pluginState2.dragging, event2, cellMinWidth2)
55580
55834
  );
55581
55835
  view.dispatch(
55582
55836
  view.state.tr.setMeta(columnResizingPluginKey, { setDragging: null })
@@ -55588,7 +55842,7 @@ function handleMouseDown2(view, event, cellMinWidth, defaultCellMinWidth) {
55588
55842
  const pluginState2 = columnResizingPluginKey.getState(view.state);
55589
55843
  if (!pluginState2) return;
55590
55844
  if (pluginState2.dragging) {
55591
- const dragged = draggedWidth(pluginState2.dragging, event2, cellMinWidth);
55845
+ const dragged = draggedWidth(pluginState2.dragging, event2, cellMinWidth2);
55592
55846
  displayColumnWidth(
55593
55847
  view,
55594
55848
  pluginState2.activeHandle,
@@ -55943,6 +56197,24 @@ const Table = Node$1.create({
55943
56197
  tableCellSpacing: {
55944
56198
  default: null,
55945
56199
  rendered: false
56200
+ },
56201
+ /**
56202
+ * @category Attribute
56203
+ * @param {TableProperties} [tableProperties] - Properties for the table.
56204
+ * @see {@link https://ecma-international.org/publications-and-standards/standards/ecma-376/} "Fundamentals And Markup Language Reference", page 371-483
56205
+ */
56206
+ tableProperties: {
56207
+ default: null,
56208
+ rendered: false
56209
+ },
56210
+ /**
56211
+ * @category Attribute
56212
+ * @param {TableGrid} [grid] - Grid definition for the table
56213
+ * @see {@link https://ecma-international.org/publications-and-standards/standards/ecma-376/} "Fundamentals And Markup Language Reference", page 432
56214
+ */
56215
+ grid: {
56216
+ default: null,
56217
+ rendered: false
55946
56218
  }
55947
56219
  };
55948
56220
  },