@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
@@ -16392,41 +16392,6 @@ const prepareCommentsXmlFilesForExport = ({ convertedXml, defs, commentsWithPara
16392
16392
  documentXml: updatedXml
16393
16393
  };
16394
16394
  };
16395
- const getColStyleDeclaration = (minWidth, width) => {
16396
- if (width) {
16397
- return ["width", `${Math.max(width, minWidth)}px`];
16398
- }
16399
- return ["min-width", `${minWidth}px`];
16400
- };
16401
- const createColGroup = (node, cellMinWidth, overrideCol, overrideValue) => {
16402
- let totalWidth = 0;
16403
- let fixedWidth = true;
16404
- const cols = [];
16405
- const colsValues = [];
16406
- const row = node.firstChild;
16407
- if (!row) return {};
16408
- for (let i = 0, col = 0; i < row.childCount; i++) {
16409
- const { colspan, colwidth } = row.child(i).attrs;
16410
- for (let j2 = 0; j2 < colspan; j2++, col++) {
16411
- const hasWidth = overrideCol === col ? overrideValue : colwidth && colwidth[j2];
16412
- totalWidth += hasWidth || cellMinWidth;
16413
- if (!hasWidth) fixedWidth = false;
16414
- const [prop, value] = getColStyleDeclaration(cellMinWidth, hasWidth);
16415
- cols.push(["col", { style: `${prop}: ${value}` }]);
16416
- colsValues.push(parseInt(value, 10));
16417
- }
16418
- }
16419
- const tableWidth = fixedWidth ? `${totalWidth}px` : "";
16420
- const tableMinWidth = fixedWidth ? "" : `${totalWidth}px`;
16421
- const colgroup = ["colgroup", {}, ...cols];
16422
- const colgroupValues = [...colsValues];
16423
- return {
16424
- colgroup,
16425
- tableWidth,
16426
- tableMinWidth,
16427
- colgroupValues
16428
- };
16429
- };
16430
16395
  const lower16 = 65535;
16431
16396
  const factor16 = Math.pow(2, 16);
16432
16397
  function makeRecover(index, offset) {
@@ -24196,46 +24161,6 @@ const baseNumbering = {
24196
24161
  }
24197
24162
  ]
24198
24163
  };
24199
- function preProcessVerticalMergeCells(table, { editorSchema }) {
24200
- if (!table || !Array.isArray(table.content)) {
24201
- return table;
24202
- }
24203
- const rows = table.content;
24204
- for (let rowIndex = 0; rowIndex < rows.length; rowIndex++) {
24205
- const row = rows[rowIndex];
24206
- if (!row) continue;
24207
- if (!Array.isArray(row.content)) {
24208
- row.content = [];
24209
- }
24210
- for (let cellIndex = 0; cellIndex < row.content.length; cellIndex++) {
24211
- const cell = row.content[cellIndex];
24212
- if (!cell) continue;
24213
- const attrs = cell.attrs || {};
24214
- if (!attrs.rowspan || attrs.rowspan <= 1) continue;
24215
- const maxRowspan = Math.min(attrs.rowspan, rows.length - rowIndex);
24216
- for (let offset = 1; offset < maxRowspan; offset++) {
24217
- const rowToChange = rows[rowIndex + offset];
24218
- if (!rowToChange) continue;
24219
- if (!Array.isArray(rowToChange.content)) {
24220
- rowToChange.content = [];
24221
- }
24222
- const existingCell = rowToChange.content[cellIndex];
24223
- if (existingCell?.attrs?.continueMerge) continue;
24224
- const mergedCell = {
24225
- type: cell.type,
24226
- content: [editorSchema.nodes.paragraph.createAndFill().toJSON()],
24227
- attrs: {
24228
- ...cell.attrs,
24229
- rowspan: null,
24230
- continueMerge: true
24231
- }
24232
- };
24233
- rowToChange.content.splice(cellIndex, 0, mergedCell);
24234
- }
24235
- }
24236
- }
24237
- return table;
24238
- }
24239
24164
  const TranslatorTypes = Object.freeze({
24240
24165
  NODE: "node",
24241
24166
  ATTRIBUTE: "attribute"
@@ -24365,37 +24290,37 @@ const _NodeTranslator = class _NodeTranslator {
24365
24290
  /** @type {typeof TranslatorTypes} */
24366
24291
  __publicField(_NodeTranslator, "translatorTypes", TranslatorTypes);
24367
24292
  let NodeTranslator = _NodeTranslator;
24368
- const encode$m = (attributes) => {
24293
+ const encode$r = (attributes) => {
24369
24294
  return attributes["w:type"];
24370
24295
  };
24371
- const decode$m = (attrs) => {
24296
+ const decode$r = (attrs) => {
24372
24297
  const { lineBreakType } = attrs;
24373
24298
  return lineBreakType;
24374
24299
  };
24375
24300
  const attrConfig$b = Object.freeze({
24376
24301
  xmlName: "w:type",
24377
24302
  sdName: "lineBreakType",
24378
- encode: encode$m,
24379
- decode: decode$m
24303
+ encode: encode$r,
24304
+ decode: decode$r
24380
24305
  });
24381
- const encode$l = (attributes) => {
24306
+ const encode$q = (attributes) => {
24382
24307
  const xmlAttrValue = attributes["w:clear"];
24383
24308
  return xmlAttrValue;
24384
24309
  };
24385
- const decode$l = (attrs) => {
24310
+ const decode$q = (attrs) => {
24386
24311
  const { clear } = attrs;
24387
24312
  return clear;
24388
24313
  };
24389
24314
  const attrConfig$a = Object.freeze({
24390
24315
  xmlName: "w:clear",
24391
24316
  sdName: "clear",
24392
- encode: encode$l,
24393
- decode: decode$l
24317
+ encode: encode$q,
24318
+ decode: decode$q
24394
24319
  });
24395
24320
  const validXmlAttributes$9 = [attrConfig$b, attrConfig$a];
24396
- const XML_NODE_NAME$a = "w:br";
24397
- const SD_NODE_NAME$9 = "lineBreak";
24398
- const encode$k = (_2, encodedAttrs) => {
24321
+ const XML_NODE_NAME$f = "w:br";
24322
+ const SD_NODE_NAME$a = "lineBreak";
24323
+ const encode$p = (_2, encodedAttrs) => {
24399
24324
  const isPageBreak = encodedAttrs?.lineBreakType === "page";
24400
24325
  const translated = {
24401
24326
  type: isPageBreak ? "hardBreak" : "lineBreak"
@@ -24405,7 +24330,7 @@ const encode$k = (_2, encodedAttrs) => {
24405
24330
  }
24406
24331
  return translated;
24407
24332
  };
24408
- const decode$k = (params, decodedAttrs) => {
24333
+ const decode$p = (params, decodedAttrs) => {
24409
24334
  const { node } = params;
24410
24335
  if (!node) return;
24411
24336
  const wBreak = { name: "w:br" };
@@ -24422,63 +24347,63 @@ const decode$k = (params, decodedAttrs) => {
24422
24347
  };
24423
24348
  return translated;
24424
24349
  };
24425
- const config$a = {
24426
- xmlName: XML_NODE_NAME$a,
24427
- sdNodeOrKeyName: SD_NODE_NAME$9,
24350
+ const config$d = {
24351
+ xmlName: XML_NODE_NAME$f,
24352
+ sdNodeOrKeyName: SD_NODE_NAME$a,
24428
24353
  type: NodeTranslator.translatorTypes.NODE,
24429
- encode: encode$k,
24430
- decode: decode$k,
24354
+ encode: encode$p,
24355
+ decode: decode$p,
24431
24356
  attributes: validXmlAttributes$9
24432
24357
  };
24433
- const translator$m = NodeTranslator.from(config$a);
24434
- const encode$j = (attributes) => {
24358
+ const translator$T = NodeTranslator.from(config$d);
24359
+ const encode$o = (attributes) => {
24435
24360
  return attributes["w:val"];
24436
24361
  };
24437
- const decode$j = (attrs) => {
24362
+ const decode$o = (attrs) => {
24438
24363
  const { tabSize } = attrs || {};
24439
24364
  return tabSize;
24440
24365
  };
24441
24366
  const attrConfig$9 = Object.freeze({
24442
24367
  xmlName: "w:val",
24443
24368
  sdName: "tabSize",
24444
- encode: encode$j,
24445
- decode: decode$j
24369
+ encode: encode$o,
24370
+ decode: decode$o
24446
24371
  });
24447
- const encode$i = (attributes) => {
24372
+ const encode$n = (attributes) => {
24448
24373
  return attributes["w:leader"];
24449
24374
  };
24450
- const decode$i = (attrs) => {
24375
+ const decode$n = (attrs) => {
24451
24376
  const { leader } = attrs || {};
24452
24377
  return leader;
24453
24378
  };
24454
24379
  const attrConfig$8 = Object.freeze({
24455
24380
  xmlName: "w:leader",
24456
24381
  sdName: "leader",
24457
- encode: encode$i,
24458
- decode: decode$i
24382
+ encode: encode$n,
24383
+ decode: decode$n
24459
24384
  });
24460
- const encode$h = (attributes) => {
24385
+ const encode$m = (attributes) => {
24461
24386
  return attributes["w:pos"];
24462
24387
  };
24463
- const decode$h = (attrs) => {
24388
+ const decode$m = (attrs) => {
24464
24389
  const { pos } = attrs || {};
24465
24390
  return pos;
24466
24391
  };
24467
24392
  const attrConfig$7 = Object.freeze({
24468
24393
  xmlName: "w:pos",
24469
24394
  sdName: "pos",
24470
- encode: encode$h,
24471
- decode: decode$h
24395
+ encode: encode$m,
24396
+ decode: decode$m
24472
24397
  });
24473
24398
  const validXmlAttributes$8 = [attrConfig$9, attrConfig$7, attrConfig$8];
24474
- const XML_NODE_NAME$9 = "w:tab";
24475
- const SD_NODE_NAME$8 = "tab";
24476
- const encode$g = (_2, encodedAttrs = {}) => {
24399
+ const XML_NODE_NAME$e = "w:tab";
24400
+ const SD_NODE_NAME$9 = "tab";
24401
+ const encode$l = (_2, encodedAttrs = {}) => {
24477
24402
  const translated = { type: "tab" };
24478
24403
  if (encodedAttrs) translated.attrs = { ...encodedAttrs };
24479
24404
  return translated;
24480
24405
  };
24481
- const decode$g = (params, decodedAttrs = {}) => {
24406
+ const decode$l = (params, decodedAttrs = {}) => {
24482
24407
  const { node } = params || {};
24483
24408
  if (!node) return;
24484
24409
  const wTab = { name: "w:tab" };
@@ -24494,15 +24419,15 @@ const decode$g = (params, decodedAttrs = {}) => {
24494
24419
  }
24495
24420
  return translated;
24496
24421
  };
24497
- const config$9 = {
24498
- xmlName: XML_NODE_NAME$9,
24499
- sdNodeOrKeyName: SD_NODE_NAME$8,
24422
+ const config$c = {
24423
+ xmlName: XML_NODE_NAME$e,
24424
+ sdNodeOrKeyName: SD_NODE_NAME$9,
24500
24425
  type: NodeTranslator.translatorTypes.NODE,
24501
- encode: encode$g,
24502
- decode: decode$g,
24426
+ encode: encode$l,
24427
+ decode: decode$l,
24503
24428
  attributes: validXmlAttributes$8
24504
24429
  };
24505
- const translator$l = NodeTranslator.from(config$9);
24430
+ const translator$S = NodeTranslator.from(config$c);
24506
24431
  const mergeTextNodes = (nodes) => {
24507
24432
  if (!nodes || !Array.isArray(nodes)) {
24508
24433
  return nodes;
@@ -25072,89 +24997,89 @@ const handleParagraphNode$1 = (params) => {
25072
24997
  }
25073
24998
  return schemaNode;
25074
24999
  };
25075
- const encode$f = (attributes) => {
25000
+ const encode$k = (attributes) => {
25076
25001
  return attributes["w:rsidDel"];
25077
25002
  };
25078
- const decode$f = (attrs) => {
25003
+ const decode$k = (attrs) => {
25079
25004
  return attrs.rsidDel;
25080
25005
  };
25081
25006
  const attrConfig$6 = Object.freeze({
25082
25007
  xmlName: "w:rsidDel",
25083
25008
  sdName: "rsidDel",
25084
- encode: encode$f,
25085
- decode: decode$f
25009
+ encode: encode$k,
25010
+ decode: decode$k
25086
25011
  });
25087
- const encode$e = (attributes) => {
25012
+ const encode$j = (attributes) => {
25088
25013
  return attributes["w:rsidP"];
25089
25014
  };
25090
- const decode$e = (attrs) => {
25015
+ const decode$j = (attrs) => {
25091
25016
  return attrs.rsidP;
25092
25017
  };
25093
25018
  const attrConfig$5 = Object.freeze({
25094
25019
  xmlName: "w:rsidP",
25095
25020
  sdName: "rsidP",
25096
- encode: encode$e,
25097
- decode: decode$e
25021
+ encode: encode$j,
25022
+ decode: decode$j
25098
25023
  });
25099
- const encode$d = (attributes) => {
25024
+ const encode$i = (attributes) => {
25100
25025
  return attributes["w:rsidR"];
25101
25026
  };
25102
- const decode$d = (attrs) => {
25027
+ const decode$i = (attrs) => {
25103
25028
  return attrs.rsidR;
25104
25029
  };
25105
25030
  const attrConfig$4 = Object.freeze({
25106
25031
  xmlName: "w:rsidR",
25107
25032
  sdName: "rsidR",
25108
- encode: encode$d,
25109
- decode: decode$d
25033
+ encode: encode$i,
25034
+ decode: decode$i
25110
25035
  });
25111
- const encode$c = (attributes) => {
25036
+ const encode$h = (attributes) => {
25112
25037
  return attributes["w:rsidRPr"];
25113
25038
  };
25114
- const decode$c = (attrs) => {
25039
+ const decode$h = (attrs) => {
25115
25040
  return attrs.rsidRPr;
25116
25041
  };
25117
25042
  const attrConfig$3 = Object.freeze({
25118
25043
  xmlName: "w:rsidRPr",
25119
25044
  sdName: "rsidRPr",
25120
- encode: encode$c,
25121
- decode: decode$c
25045
+ encode: encode$h,
25046
+ decode: decode$h
25122
25047
  });
25123
- const encode$b = (attributes) => {
25048
+ const encode$g = (attributes) => {
25124
25049
  return attributes["w:rsidRDefault"];
25125
25050
  };
25126
- const decode$b = (attrs) => {
25051
+ const decode$g = (attrs) => {
25127
25052
  return attrs.rsidRDefault;
25128
25053
  };
25129
25054
  const attrConfig$2 = Object.freeze({
25130
25055
  xmlName: "w:rsidRDefault",
25131
25056
  sdName: "rsidRDefault",
25132
- encode: encode$b,
25133
- decode: decode$b
25057
+ encode: encode$g,
25058
+ decode: decode$g
25134
25059
  });
25135
- const encode$a = (attributes) => {
25060
+ const encode$f = (attributes) => {
25136
25061
  return attributes["w14:paraId"];
25137
25062
  };
25138
- const decode$a = (attrs) => {
25063
+ const decode$f = (attrs) => {
25139
25064
  return attrs.paraId;
25140
25065
  };
25141
25066
  const attrConfig$1 = Object.freeze({
25142
25067
  xmlName: "w14:paraId",
25143
25068
  sdName: "paraId",
25144
- encode: encode$a,
25145
- decode: decode$a
25069
+ encode: encode$f,
25070
+ decode: decode$f
25146
25071
  });
25147
- const encode$9 = (attributes) => {
25072
+ const encode$e = (attributes) => {
25148
25073
  return attributes["w14:textId"];
25149
25074
  };
25150
- const decode$9 = (attrs) => {
25075
+ const decode$e = (attrs) => {
25151
25076
  return attrs.textId;
25152
25077
  };
25153
25078
  const attrConfig = Object.freeze({
25154
25079
  xmlName: "w14:textId",
25155
25080
  sdName: "textId",
25156
- encode: encode$9,
25157
- decode: decode$9
25081
+ encode: encode$e,
25082
+ decode: decode$e
25158
25083
  });
25159
25084
  const validXmlAttributes$7 = [
25160
25085
  attrConfig$1,
@@ -25165,9 +25090,9 @@ const validXmlAttributes$7 = [
25165
25090
  attrConfig$3,
25166
25091
  attrConfig$6
25167
25092
  ];
25168
- const XML_NODE_NAME$8 = "w:p";
25169
- const SD_NODE_NAME$7 = "paragraph";
25170
- const encode$8 = (params, encodedAttrs = {}) => {
25093
+ const XML_NODE_NAME$d = "w:p";
25094
+ const SD_NODE_NAME$8 = "paragraph";
25095
+ const encode$d = (params, encodedAttrs = {}) => {
25171
25096
  const node = handleParagraphNode$1(params);
25172
25097
  if (!node) return void 0;
25173
25098
  if (encodedAttrs && Object.keys(encodedAttrs).length) {
@@ -25175,7 +25100,7 @@ const encode$8 = (params, encodedAttrs = {}) => {
25175
25100
  }
25176
25101
  return node;
25177
25102
  };
25178
- const decode$8 = (params, decodedAttrs = {}) => {
25103
+ const decode$d = (params, decodedAttrs = {}) => {
25179
25104
  const translated = translateParagraphNode(params);
25180
25105
  if (!translated) return void 0;
25181
25106
  if (decodedAttrs && Object.keys(decodedAttrs).length) {
@@ -25183,15 +25108,15 @@ const decode$8 = (params, decodedAttrs = {}) => {
25183
25108
  }
25184
25109
  return translated;
25185
25110
  };
25186
- const config$8 = {
25187
- xmlName: XML_NODE_NAME$8,
25188
- sdNodeOrKeyName: SD_NODE_NAME$7,
25111
+ const config$b = {
25112
+ xmlName: XML_NODE_NAME$d,
25113
+ sdNodeOrKeyName: SD_NODE_NAME$8,
25189
25114
  type: NodeTranslator.translatorTypes.NODE,
25190
- encode: encode$8,
25191
- decode: decode$8,
25115
+ encode: encode$d,
25116
+ decode: decode$d,
25192
25117
  attributes: validXmlAttributes$7
25193
25118
  };
25194
- const translator$k = NodeTranslator.from(config$8);
25119
+ const translator$R = NodeTranslator.from(config$b);
25195
25120
  const generateV2HandlerEntity = (handlerName, translator2) => ({
25196
25121
  handlerName,
25197
25122
  handler: (params) => {
@@ -25219,7 +25144,7 @@ function createSingleAttrPropertyHandler(xmlName, sdName = null, attrName = "w:v
25219
25144
  },
25220
25145
  decode: ({ node }) => {
25221
25146
  const value = node.attrs?.[sdName] != null ? transformDecode(node.attrs[sdName]) : void 0;
25222
- return value != null ? { [attrName]: value } : void 0;
25147
+ return value != null ? { name: xmlName, attributes: { [attrName]: value } } : void 0;
25223
25148
  }
25224
25149
  };
25225
25150
  }
@@ -25237,7 +25162,32 @@ function createMeasurementPropertyHandler(xmlName, sdName = null) {
25237
25162
  },
25238
25163
  decode: function({ node }) {
25239
25164
  const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs[sdName] || {} } });
25240
- return decodedAttrs["w:w"] != null ? decodedAttrs : void 0;
25165
+ return decodedAttrs["w:w"] != null ? { attributes: decodedAttrs } : void 0;
25166
+ }
25167
+ };
25168
+ }
25169
+ function createBorderPropertyHandler(xmlName, sdName = null) {
25170
+ if (!sdName) sdName = xmlName.split(":")[1];
25171
+ return {
25172
+ xmlName,
25173
+ sdNodeOrKeyName: sdName,
25174
+ attributes: [
25175
+ createAttributeHandler("w:val"),
25176
+ createAttributeHandler("w:color"),
25177
+ createAttributeHandler("w:themeColor"),
25178
+ createAttributeHandler("w:themeTint"),
25179
+ createAttributeHandler("w:themeShade"),
25180
+ createAttributeHandler("w:sz", "size", parseInteger, integerToString),
25181
+ createAttributeHandler("w:space", null, parseInteger, integerToString),
25182
+ createAttributeHandler("w:shadow", null, parseBoolean, booleanToString),
25183
+ createAttributeHandler("w:frame", null, parseBoolean, booleanToString)
25184
+ ],
25185
+ encode: (_2, encodedAttrs) => {
25186
+ return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
25187
+ },
25188
+ decode: function({ node }, _2) {
25189
+ const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs[sdName] || {} } });
25190
+ return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
25241
25191
  }
25242
25192
  };
25243
25193
  }
@@ -25280,15 +25230,17 @@ function decodeProperties(translatorsBySdName, properties) {
25280
25230
  Object.keys(properties).forEach((key) => {
25281
25231
  const translator2 = translatorsBySdName[key];
25282
25232
  if (translator2) {
25283
- const attributes = translator2.decode({ node: { attrs: { [key]: properties[key] } } });
25284
- if (attributes != null) {
25285
- elements.push({ name: translator2.xmlName, attributes });
25233
+ const result = translator2.decode({ node: { attrs: { [key]: properties[key] } } });
25234
+ if (result != null) {
25235
+ result.name = translator2.xmlName;
25236
+ elements.push(result);
25286
25237
  }
25287
25238
  }
25288
25239
  });
25289
25240
  return elements;
25290
25241
  }
25291
- const parseBoolean = (value) => ["1", "true"].includes(value);
25242
+ const parseBoolean = (value) => value != null ? ["1", "true"].includes(value) : void 0;
25243
+ const booleanToString = (value) => value != null ? value ? "1" : "0" : void 0;
25292
25244
  const parseInteger = (value) => {
25293
25245
  if (value == null) return void 0;
25294
25246
  const intValue = parseInt(value, 10);
@@ -25298,13 +25250,53 @@ const integerToString = (value) => {
25298
25250
  const intValue = parseInteger(value);
25299
25251
  return intValue != void 0 ? String(intValue) : void 0;
25300
25252
  };
25301
- const translator$j = NodeTranslator.from({
25253
+ function preProcessVerticalMergeCells(table, { editorSchema }) {
25254
+ if (!table || !Array.isArray(table.content)) {
25255
+ return table;
25256
+ }
25257
+ const rows = table.content;
25258
+ for (let rowIndex = 0; rowIndex < rows.length; rowIndex++) {
25259
+ const row = rows[rowIndex];
25260
+ if (!row) continue;
25261
+ if (!Array.isArray(row.content)) {
25262
+ row.content = [];
25263
+ }
25264
+ for (let cellIndex = 0; cellIndex < row.content.length; cellIndex++) {
25265
+ const cell = row.content[cellIndex];
25266
+ if (!cell) continue;
25267
+ const attrs = cell.attrs || {};
25268
+ if (!attrs.rowspan || attrs.rowspan <= 1) continue;
25269
+ const maxRowspan = Math.min(attrs.rowspan, rows.length - rowIndex);
25270
+ for (let offset = 1; offset < maxRowspan; offset++) {
25271
+ const rowToChange = rows[rowIndex + offset];
25272
+ if (!rowToChange) continue;
25273
+ if (!Array.isArray(rowToChange.content)) {
25274
+ rowToChange.content = [];
25275
+ }
25276
+ const existingCell = rowToChange.content[cellIndex];
25277
+ if (existingCell?.attrs?.continueMerge) continue;
25278
+ const mergedCell = {
25279
+ type: cell.type,
25280
+ content: [editorSchema.nodes.paragraph.createAndFill().toJSON()],
25281
+ attrs: {
25282
+ ...cell.attrs,
25283
+ rowspan: null,
25284
+ continueMerge: true
25285
+ }
25286
+ };
25287
+ rowToChange.content.splice(cellIndex, 0, mergedCell);
25288
+ }
25289
+ }
25290
+ }
25291
+ return table;
25292
+ }
25293
+ const translator$Q = NodeTranslator.from({
25302
25294
  xmlName: "w:cantSplit",
25303
25295
  sdNodeOrKeyName: "cantSplit",
25304
25296
  encode: ({ nodes }) => ["1", "true"].includes(nodes[0].attributes?.["w:val"] ?? "1"),
25305
- decode: ({ node }) => node.attrs?.cantSplit ? {} : void 0
25297
+ decode: ({ node }) => node.attrs?.cantSplit ? { attributes: {} } : void 0
25306
25298
  });
25307
- const translator$i = NodeTranslator.from({
25299
+ const translator$P = NodeTranslator.from({
25308
25300
  xmlName: "w:cnfStyle",
25309
25301
  sdNodeOrKeyName: "cnfStyle",
25310
25302
  attributes: [
@@ -25319,26 +25311,19 @@ const translator$i = NodeTranslator.from({
25319
25311
  "w:lastRowFirstColumn",
25320
25312
  "w:lastRowLastColumn",
25321
25313
  "w:oddHBand",
25322
- "w:oddVBand",
25323
- "w:val"
25324
- ].map((attr) => createAttributeHandler(attr)),
25314
+ "w:oddVBand"
25315
+ ].map((attr) => createAttributeHandler(attr, null, parseBoolean, booleanToString)).concat([createAttributeHandler("w:val")]),
25325
25316
  encode: (_2, encodedAttrs) => {
25326
- Object.keys(encodedAttrs).forEach((key) => {
25327
- encodedAttrs[key] = ["1", "true"].includes(encodedAttrs[key]);
25328
- });
25329
25317
  return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
25330
25318
  },
25331
- decode: ({ node }) => {
25319
+ decode: function({ node }) {
25332
25320
  if (!node.attrs?.cnfStyle) return;
25333
- const cnfStyleAttrs = {};
25334
- Object.entries(node.attrs.cnfStyle).forEach(([key, value]) => {
25335
- cnfStyleAttrs[`w:${key}`] = value ? "1" : "0";
25336
- });
25337
- return Object.keys(cnfStyleAttrs).length > 0 ? cnfStyleAttrs : void 0;
25321
+ const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs.cnfStyle || {} } });
25322
+ return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
25338
25323
  }
25339
25324
  });
25340
- const translator$h = NodeTranslator.from(createSingleAttrPropertyHandler("w:divId"));
25341
- const translator$g = NodeTranslator.from(
25325
+ const translator$O = NodeTranslator.from(createSingleAttrPropertyHandler("w:divId"));
25326
+ const translator$N = NodeTranslator.from(
25342
25327
  createSingleAttrPropertyHandler(
25343
25328
  "w:gridAfter",
25344
25329
  null,
@@ -25347,7 +25332,7 @@ const translator$g = NodeTranslator.from(
25347
25332
  (v2) => integerToString(v2)
25348
25333
  )
25349
25334
  );
25350
- const translator$f = NodeTranslator.from(
25335
+ const translator$M = NodeTranslator.from(
25351
25336
  createSingleAttrPropertyHandler(
25352
25337
  "w:gridBefore",
25353
25338
  null,
@@ -25356,21 +25341,21 @@ const translator$f = NodeTranslator.from(
25356
25341
  (v2) => integerToString(v2)
25357
25342
  )
25358
25343
  );
25359
- const translator$e = NodeTranslator.from({
25344
+ const translator$L = NodeTranslator.from({
25360
25345
  xmlName: "w:hidden",
25361
25346
  sdNodeOrKeyName: "hidden",
25362
25347
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
25363
- decode: ({ node }) => node.attrs.hidden ? {} : void 0
25348
+ decode: ({ node }) => node.attrs.hidden ? { attributes: {} } : void 0
25364
25349
  });
25365
- const translator$d = NodeTranslator.from(createSingleAttrPropertyHandler("w:jc"));
25366
- const translator$c = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "cellSpacing"));
25367
- const translator$b = NodeTranslator.from({
25350
+ const translator$K = NodeTranslator.from(createSingleAttrPropertyHandler("w:jc", "justification"));
25351
+ const translator$J = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "tableCellSpacing"));
25352
+ const translator$I = NodeTranslator.from({
25368
25353
  xmlName: "w:tblHeader",
25369
25354
  sdNodeOrKeyName: "repeatHeader",
25370
25355
  encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
25371
- decode: ({ node }) => node.attrs.repeatHeader ? {} : void 0
25356
+ decode: ({ node }) => node.attrs.repeatHeader ? { attributes: {} } : void 0
25372
25357
  });
25373
- const translator$a = NodeTranslator.from({
25358
+ const translator$H = NodeTranslator.from({
25374
25359
  xmlName: "w:trHeight",
25375
25360
  sdNodeOrKeyName: "rowHeight",
25376
25361
  encode: ({ nodes }) => {
@@ -25394,14 +25379,14 @@ const translator$a = NodeTranslator.from({
25394
25379
  if (node.attrs.rowHeight.rule) {
25395
25380
  heightAttrs["w:hRule"] = node.attrs.rowHeight.rule;
25396
25381
  }
25397
- return Object.keys(heightAttrs).length > 0 ? heightAttrs : void 0;
25382
+ return Object.keys(heightAttrs).length > 0 ? { attributes: heightAttrs } : void 0;
25398
25383
  }
25399
25384
  });
25400
- const translator$9 = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
25401
- const translator$8 = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
25402
- const XML_NODE_NAME$7 = "w:trPr";
25403
- const SD_ATTR_KEY = "tableRowProperties";
25404
- const encode$7 = (params) => {
25385
+ const translator$G = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
25386
+ const translator$F = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
25387
+ const XML_NODE_NAME$c = "w:trPr";
25388
+ const SD_ATTR_KEY$4 = "tableRowProperties";
25389
+ const encode$c = (params) => {
25405
25390
  const { nodes } = params;
25406
25391
  const node = nodes[0];
25407
25392
  let attributes = {
@@ -25411,18 +25396,18 @@ const encode$7 = (params) => {
25411
25396
  };
25412
25397
  attributes = {
25413
25398
  ...attributes,
25414
- ...encodeProperties(node, propertyTranslatorsByXmlName)
25399
+ ...encodeProperties(node, propertyTranslatorsByXmlName$2)
25415
25400
  };
25416
25401
  return {
25417
25402
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25418
- xmlName: XML_NODE_NAME$7,
25419
- sdNodeOrKeyName: SD_ATTR_KEY,
25403
+ xmlName: XML_NODE_NAME$c,
25404
+ sdNodeOrKeyName: SD_ATTR_KEY$4,
25420
25405
  attributes
25421
25406
  };
25422
25407
  };
25423
- const decode$7 = (params) => {
25408
+ const decode$c = (params) => {
25424
25409
  const { tableRowProperties = {} } = params.node.attrs || {};
25425
- const elements = decodeProperties(propertyTranslatorsBySdName, tableRowProperties);
25410
+ const elements = decodeProperties(propertyTranslatorsBySdName$2, tableRowProperties);
25426
25411
  const newNode = {
25427
25412
  name: "w:trPr",
25428
25413
  type: "element",
@@ -25431,47 +25416,47 @@ const decode$7 = (params) => {
25431
25416
  };
25432
25417
  return newNode;
25433
25418
  };
25434
- const propertyTranslators = [
25435
- translator$j,
25436
- translator$i,
25437
- translator$h,
25438
- translator$g,
25439
- translator$f,
25440
- translator$e,
25441
- translator$d,
25442
- translator$c,
25443
- translator$b,
25444
- translator$a,
25445
- translator$9,
25446
- translator$8
25419
+ const propertyTranslators$3 = [
25420
+ translator$Q,
25421
+ translator$P,
25422
+ translator$O,
25423
+ translator$N,
25424
+ translator$M,
25425
+ translator$L,
25426
+ translator$K,
25427
+ translator$J,
25428
+ translator$I,
25429
+ translator$H,
25430
+ translator$G,
25431
+ translator$F
25447
25432
  ];
25448
- const propertyTranslatorsByXmlName = {};
25449
- propertyTranslators.forEach((translator2) => {
25450
- propertyTranslatorsByXmlName[translator2.xmlName] = translator2;
25433
+ const propertyTranslatorsByXmlName$2 = {};
25434
+ propertyTranslators$3.forEach((translator2) => {
25435
+ propertyTranslatorsByXmlName$2[translator2.xmlName] = translator2;
25451
25436
  });
25452
- const propertyTranslatorsBySdName = {};
25453
- propertyTranslators.forEach((translator2) => {
25454
- propertyTranslatorsBySdName[translator2.sdNodeOrKeyName] = translator2;
25437
+ const propertyTranslatorsBySdName$2 = {};
25438
+ propertyTranslators$3.forEach((translator2) => {
25439
+ propertyTranslatorsBySdName$2[translator2.sdNodeOrKeyName] = translator2;
25455
25440
  });
25456
- const config$7 = {
25457
- xmlName: XML_NODE_NAME$7,
25458
- sdNodeOrKeyName: SD_ATTR_KEY,
25441
+ const config$a = {
25442
+ xmlName: XML_NODE_NAME$c,
25443
+ sdNodeOrKeyName: SD_ATTR_KEY$4,
25459
25444
  type: NodeTranslator.translatorTypes.ATTRIBUTE,
25460
- encode: encode$7,
25461
- decode: decode$7
25445
+ encode: encode$c,
25446
+ decode: decode$c
25462
25447
  };
25463
- const translator$7 = NodeTranslator.from(config$7);
25464
- const XML_NODE_NAME$6 = "w:tr";
25465
- const SD_NODE_NAME$6 = "tableRow";
25448
+ const translator$E = NodeTranslator.from(config$a);
25449
+ const XML_NODE_NAME$b = "w:tr";
25450
+ const SD_NODE_NAME$7 = "tableRow";
25466
25451
  const validXmlAttributes$6 = ["w:rsidDel", "w:rsidR", "w:rsidRPr", "w:rsidTr", "w14:paraId", "w14:textId"].map(
25467
25452
  (xmlName) => createAttributeHandler(xmlName)
25468
25453
  );
25469
- const encode$6 = (params, encodedAttrs) => {
25470
- const { row, table } = params.extraParams;
25454
+ const encode$b = (params, encodedAttrs) => {
25455
+ const { row } = params.extraParams;
25471
25456
  let tableRowProperties = {};
25472
25457
  const tPr = row.elements.find((el) => el.name === "w:trPr");
25473
25458
  if (tPr) {
25474
- ({ attributes: tableRowProperties } = translator$7.encode({
25459
+ ({ attributes: tableRowProperties } = translator$E.encode({
25475
25460
  ...params,
25476
25461
  nodes: [tPr]
25477
25462
  }));
@@ -25479,7 +25464,7 @@ const encode$6 = (params, encodedAttrs) => {
25479
25464
  encodedAttrs["tableRowProperties"] = Object.freeze(tableRowProperties);
25480
25465
  encodedAttrs["rowHeight"] = twipsToPixels(tableRowProperties["rowHeight"]?.value);
25481
25466
  encodedAttrs["cantSplit"] = tableRowProperties["cantSplit"];
25482
- const gridColumnWidths = _getGridColumnWidths(table);
25467
+ const { columnWidths: gridColumnWidths } = params.extraParams;
25483
25468
  const cellNodes = row.elements.filter((el) => el.name === "w:tc");
25484
25469
  let currentColumnIndex = 0;
25485
25470
  const content = cellNodes?.map((n) => {
@@ -25506,16 +25491,7 @@ const encode$6 = (params, encodedAttrs) => {
25506
25491
  };
25507
25492
  return newNode;
25508
25493
  };
25509
- const _getGridColumnWidths = (tableNode) => {
25510
- const tblGrid = tableNode.elements.find((el) => el.name === "w:tblGrid");
25511
- if (!tblGrid) return [];
25512
- const columnWidths = tblGrid?.elements?.flatMap((el) => {
25513
- if (el.name !== "w:gridCol") return [];
25514
- return twipsToPixels(el.attributes["w:w"]);
25515
- }) || [];
25516
- return columnWidths;
25517
- };
25518
- const decode$6 = (params, decodedAttrs) => {
25494
+ const decode$b = (params, decodedAttrs) => {
25519
25495
  const { node } = params;
25520
25496
  const elements = translateChildNodes(params);
25521
25497
  if (node.attrs?.tableRowProperties) {
@@ -25527,7 +25503,7 @@ const decode$6 = (params, decodedAttrs) => {
25527
25503
  }
25528
25504
  }
25529
25505
  tableRowProperties["cantSplit"] = node.attrs["cantSplit"];
25530
- const trPr = translator$7.decode({
25506
+ const trPr = translator$E.decode({
25531
25507
  ...params,
25532
25508
  node: { ...node, attrs: { ...node.attrs, tableRowProperties } }
25533
25509
  });
@@ -25539,86 +25515,348 @@ const decode$6 = (params, decodedAttrs) => {
25539
25515
  elements
25540
25516
  };
25541
25517
  };
25542
- const config$6 = {
25543
- xmlName: XML_NODE_NAME$6,
25544
- sdNodeOrKeyName: SD_NODE_NAME$6,
25518
+ const config$9 = {
25519
+ xmlName: XML_NODE_NAME$b,
25520
+ sdNodeOrKeyName: SD_NODE_NAME$7,
25545
25521
  type: NodeTranslator.translatorTypes.NODE,
25546
- encode: encode$6,
25547
- decode: decode$6,
25522
+ encode: encode$b,
25523
+ decode: decode$b,
25548
25524
  attributes: validXmlAttributes$6
25549
25525
  };
25550
- const translator$6 = NodeTranslator.from(config$6);
25551
- const handleAllTableNodes = (params) => {
25552
- const { nodes } = params;
25553
- if (nodes.length === 0) {
25554
- return { nodes: [], consumed: 0 };
25526
+ const translator$D = NodeTranslator.from(config$9);
25527
+ const translator$C = NodeTranslator.from({
25528
+ xmlName: "w:bidiVisual",
25529
+ sdNodeOrKeyName: "rightToLeft",
25530
+ encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
25531
+ decode: ({ node }) => node.attrs.rightToLeft ? { attributes: {} } : void 0
25532
+ });
25533
+ const translator$B = NodeTranslator.from({
25534
+ xmlName: "w:shd",
25535
+ sdNodeOrKeyName: "shading",
25536
+ attributes: [
25537
+ "w:color",
25538
+ "w:fill",
25539
+ "w:themeColor",
25540
+ "w:themeFill",
25541
+ "w:themeFillShade",
25542
+ "w:themeFillTint",
25543
+ "w:themeShade",
25544
+ "w:themeTint",
25545
+ "w:val"
25546
+ ].map((attr) => createAttributeHandler(attr)),
25547
+ encode: (_2, encodedAttrs) => {
25548
+ return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
25549
+ },
25550
+ decode: function({ node }, _2) {
25551
+ const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs.shading || {} } });
25552
+ return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
25553
+ }
25554
+ });
25555
+ const translator$A = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblCaption", "caption"));
25556
+ const translator$z = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblDescription", "description"));
25557
+ const translator$y = NodeTranslator.from(createMeasurementPropertyHandler("w:tblInd", "tableIndent"));
25558
+ const translator$x = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblLayout", "tableLayout", "w:type"));
25559
+ const translator$w = NodeTranslator.from({
25560
+ xmlName: "w:tblLook",
25561
+ sdNodeOrKeyName: "tblLook",
25562
+ attributes: ["w:firstColumn", "w:firstRow", "w:lastColumn", "w:lastRow", "w:noHBand", "w:noVBand"].map((attr) => createAttributeHandler(attr, null, parseBoolean, booleanToString)).concat([createAttributeHandler("w:val")]),
25563
+ encode: (_2, encodedAttrs) => {
25564
+ return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
25565
+ },
25566
+ decode: function({ node }, _2) {
25567
+ const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs.tblLook || {} } });
25568
+ return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
25555
25569
  }
25570
+ });
25571
+ const translator$v = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblOverlap", "overlap"));
25572
+ const translator$u = NodeTranslator.from(createSingleAttrPropertyHandler("w:tblStyle", "tableStyleId"));
25573
+ const translator$t = NodeTranslator.from(
25574
+ createSingleAttrPropertyHandler("w:tblStyleColBandSize", "tableStyleColBandSize")
25575
+ );
25576
+ const translator$s = NodeTranslator.from(
25577
+ createSingleAttrPropertyHandler("w:tblStyleRowBandSize", "tableStyleRowBandSize")
25578
+ );
25579
+ const translator$r = NodeTranslator.from(createMeasurementPropertyHandler("w:tblW", "tableWidth"));
25580
+ const translator$q = NodeTranslator.from({
25581
+ xmlName: "w:tblpPr",
25582
+ sdNodeOrKeyName: "floatingTableProperties",
25583
+ 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))),
25584
+ encode: (_2, encodedAttrs) => {
25585
+ return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
25586
+ },
25587
+ decode: function({ node }, _2) {
25588
+ const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs.floatingTableProperties || {} } });
25589
+ return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
25590
+ }
25591
+ });
25592
+ const translator$p = NodeTranslator.from(createBorderPropertyHandler("w:bottom"));
25593
+ const translator$o = NodeTranslator.from(createMeasurementPropertyHandler("w:bottom", "marginBottom"));
25594
+ const translator$n = NodeTranslator.from(createBorderPropertyHandler("w:end"));
25595
+ const translator$m = NodeTranslator.from(createMeasurementPropertyHandler("w:end", "marginEnd"));
25596
+ const translator$l = NodeTranslator.from(createBorderPropertyHandler("w:insideH"));
25597
+ const translator$k = NodeTranslator.from(createBorderPropertyHandler("w:insideV"));
25598
+ const translator$j = NodeTranslator.from(createBorderPropertyHandler("w:left"));
25599
+ const translator$i = NodeTranslator.from(createMeasurementPropertyHandler("w:left", "marginLeft"));
25600
+ const translator$h = NodeTranslator.from(createBorderPropertyHandler("w:right"));
25601
+ const translator$g = NodeTranslator.from(createMeasurementPropertyHandler("w:right", "marginRight"));
25602
+ const translator$f = NodeTranslator.from(createBorderPropertyHandler("w:start"));
25603
+ const translator$e = NodeTranslator.from(createMeasurementPropertyHandler("w:start", "marginStart"));
25604
+ const translator$d = NodeTranslator.from(createBorderPropertyHandler("w:top"));
25605
+ const translator$c = NodeTranslator.from(createMeasurementPropertyHandler("w:top", "marginTop"));
25606
+ const XML_NODE_NAME$a = "w:tblBorders";
25607
+ const SD_ATTR_KEY$3 = "borders";
25608
+ const encode$a = (params, _2) => {
25609
+ const { nodes } = params;
25610
+ const node = nodes[0];
25611
+ const attributes = encodeProperties(node, tblBordersTranslatorsByXmlName);
25612
+ return Object.keys(attributes).length > 0 ? attributes : void 0;
25613
+ };
25614
+ const decode$a = (params, _2) => {
25615
+ const { borders = {} } = params.node.attrs || {};
25616
+ const elements = decodeProperties(tblBordersTranslatorsBySdName, borders);
25617
+ const newNode = {
25618
+ name: "w:tblBorders",
25619
+ type: "element",
25620
+ attributes: {},
25621
+ elements
25622
+ };
25623
+ return newNode;
25624
+ };
25625
+ const propertyTranslators$2 = [
25626
+ translator$p,
25627
+ translator$n,
25628
+ translator$l,
25629
+ translator$k,
25630
+ translator$j,
25631
+ translator$h,
25632
+ translator$f,
25633
+ translator$d
25634
+ ];
25635
+ const tblBordersTranslatorsByXmlName = {};
25636
+ const tblBordersTranslatorsBySdName = {};
25637
+ propertyTranslators$2.forEach((translator2) => {
25638
+ tblBordersTranslatorsByXmlName[translator2.xmlName] = translator2;
25639
+ tblBordersTranslatorsBySdName[translator2.sdNodeOrKeyName] = translator2;
25640
+ });
25641
+ const translator$b = NodeTranslator.from({
25642
+ xmlName: XML_NODE_NAME$a,
25643
+ sdNodeOrKeyName: SD_ATTR_KEY$3,
25644
+ type: NodeTranslator.translatorTypes.NODE,
25645
+ attributes: [],
25646
+ encode: encode$a,
25647
+ decode: decode$a
25648
+ });
25649
+ const XML_NODE_NAME$9 = "w:tblCellMar";
25650
+ const SD_ATTR_KEY$2 = "cellMargins";
25651
+ const encode$9 = (params, _2) => {
25652
+ const { nodes } = params;
25653
+ const node = nodes[0];
25654
+ const attributes = encodeProperties(node, propertyTranslatorsByXmlName$1);
25655
+ return Object.keys(attributes).length > 0 ? attributes : void 0;
25656
+ };
25657
+ const decode$9 = (params, _2) => {
25658
+ const { cellMargins = {} } = params.node.attrs || {};
25659
+ const elements = decodeProperties(propertyTranslatorsBySdName$1, cellMargins);
25660
+ const newNode = {
25661
+ name: XML_NODE_NAME$9,
25662
+ type: "element",
25663
+ attributes: {},
25664
+ elements
25665
+ };
25666
+ return newNode;
25667
+ };
25668
+ const propertyTranslators$1 = [
25669
+ translator$o,
25670
+ translator$m,
25671
+ translator$i,
25672
+ translator$g,
25673
+ translator$e,
25674
+ translator$c
25675
+ ];
25676
+ const propertyTranslatorsByXmlName$1 = {};
25677
+ const propertyTranslatorsBySdName$1 = {};
25678
+ propertyTranslators$1.forEach((translator2) => {
25679
+ propertyTranslatorsByXmlName$1[translator2.xmlName] = translator2;
25680
+ propertyTranslatorsBySdName$1[translator2.sdNodeOrKeyName] = translator2;
25681
+ });
25682
+ const translator$a = NodeTranslator.from({
25683
+ xmlName: XML_NODE_NAME$9,
25684
+ sdNodeOrKeyName: SD_ATTR_KEY$2,
25685
+ type: NodeTranslator.translatorTypes.NODE,
25686
+ attributes: [],
25687
+ encode: encode$9,
25688
+ decode: decode$9
25689
+ });
25690
+ const XML_NODE_NAME$8 = "w:tblPr";
25691
+ const SD_ATTR_KEY$1 = "tableProperties";
25692
+ const encode$8 = (params) => {
25693
+ const { nodes } = params;
25694
+ const node = nodes[0];
25695
+ const attributes = encodeProperties(node, propertyTranslatorsByXmlName);
25696
+ return {
25697
+ xmlName: XML_NODE_NAME$8,
25698
+ sdNodeOrKeyName: SD_ATTR_KEY$1,
25699
+ attributes
25700
+ };
25701
+ };
25702
+ const decode$8 = (params) => {
25703
+ const { tableProperties = {} } = params.node.attrs || {};
25704
+ const elements = decodeProperties(propertyTranslatorsBySdName, tableProperties);
25705
+ const newNode = {
25706
+ name: "w:tblPr",
25707
+ type: "element",
25708
+ attributes: {},
25709
+ elements
25710
+ };
25711
+ return newNode;
25712
+ };
25713
+ const propertyTranslators = [
25714
+ translator$C,
25715
+ translator$K,
25716
+ translator$B,
25717
+ translator$A,
25718
+ translator$J,
25719
+ translator$z,
25720
+ translator$y,
25721
+ translator$x,
25722
+ translator$w,
25723
+ translator$v,
25724
+ translator$u,
25725
+ translator$t,
25726
+ translator$s,
25727
+ translator$r,
25728
+ translator$q,
25729
+ translator$b,
25730
+ translator$a
25731
+ ];
25732
+ const propertyTranslatorsByXmlName = {};
25733
+ const propertyTranslatorsBySdName = {};
25734
+ propertyTranslators.forEach((translator2) => {
25735
+ propertyTranslatorsByXmlName[translator2.xmlName] = translator2;
25736
+ propertyTranslatorsBySdName[translator2.sdNodeOrKeyName] = translator2;
25737
+ });
25738
+ const config$8 = {
25739
+ xmlName: XML_NODE_NAME$8,
25740
+ sdNodeOrKeyName: SD_ATTR_KEY$1,
25741
+ encode: encode$8,
25742
+ decode: decode$8
25743
+ };
25744
+ const translator$9 = NodeTranslator.from(config$8);
25745
+ const translator$8 = NodeTranslator.from(
25746
+ createSingleAttrPropertyHandler("w:gridCol", "col", "w:w", parseInteger, integerToString)
25747
+ );
25748
+ const XML_NODE_NAME$7 = "w:tblGrid";
25749
+ const SD_ATTR_KEY = "grid";
25750
+ const cellMinWidth = pixelsToTwips(10);
25751
+ const encode$7 = (params) => {
25752
+ const { nodes } = params;
25556
25753
  const node = nodes[0];
25557
- switch (node.name) {
25558
- case "w:tbl":
25559
- return { nodes: [handleTableNode(node, params)], consumed: 1 };
25754
+ const attributes = encodeProperties(node, { [translator$8.xmlName]: translator$8 }, true);
25755
+ return {
25756
+ xmlName: XML_NODE_NAME$7,
25757
+ sdNodeOrKeyName: SD_ATTR_KEY,
25758
+ attributes
25759
+ };
25760
+ };
25761
+ const decode$7 = (params) => {
25762
+ const { grid = [] } = params.node.attrs || {};
25763
+ const { firstRow = {} } = params.extraParams || {};
25764
+ const cellNodes = firstRow.content?.filter((n) => n.type === "tableCell") ?? [];
25765
+ const numberOfColumns = cellNodes.length || grid.length;
25766
+ const elements = [];
25767
+ for (let cellIdx = 0; cellIdx < numberOfColumns; cellIdx++) {
25768
+ const cell = cellNodes[cellIdx];
25769
+ const { colspan = 1, colwidth } = cell?.attrs || {};
25770
+ for (let mergedCellIdx = 0; mergedCellIdx < colspan; mergedCellIdx++) {
25771
+ const cellWidthPixels = colwidth && colwidth[mergedCellIdx];
25772
+ const colGridAttrs = grid?.[mergedCellIdx] || {};
25773
+ const gridWidthTwips = colGridAttrs.col;
25774
+ const gridWidthPixels = twipsToPixels(gridWidthTwips);
25775
+ let cellWidthTwips;
25776
+ if (gridWidthPixels === cellWidthPixels) {
25777
+ cellWidthTwips = gridWidthTwips;
25778
+ } else if (cellWidthPixels) {
25779
+ cellWidthTwips = pixelsToTwips(cellWidthPixels);
25780
+ }
25781
+ const widthTwips = Math.max(cellWidthTwips, cellMinWidth);
25782
+ elements.push(
25783
+ translator$8.decode({
25784
+ node: { type: (
25785
+ /** @type {string} */
25786
+ translator$8.sdNodeOrKeyName
25787
+ ), attrs: { col: widthTwips } }
25788
+ })
25789
+ );
25790
+ }
25560
25791
  }
25561
- return { nodes: [], consumed: 0 };
25792
+ const newNode = {
25793
+ name: XML_NODE_NAME$7,
25794
+ attributes: {},
25795
+ elements
25796
+ };
25797
+ return newNode;
25562
25798
  };
25563
- const tableNodeHandlerEntity = {
25564
- handlerName: "tableNodeHandler",
25565
- handler: handleAllTableNodes
25799
+ const config$7 = {
25800
+ xmlName: XML_NODE_NAME$7,
25801
+ sdNodeOrKeyName: SD_ATTR_KEY,
25802
+ encode: encode$7,
25803
+ decode: decode$7
25566
25804
  };
25567
- function handleTableNode(node, params) {
25568
- const { docx, nodeListHandler } = params;
25805
+ const translator$7 = NodeTranslator.from(config$7);
25806
+ const XML_NODE_NAME$6 = "w:tbl";
25807
+ const SD_NODE_NAME$6 = "table";
25808
+ const encode$6 = (params, encodedAttrs) => {
25809
+ const { nodes } = params;
25810
+ const node = nodes[0];
25569
25811
  const tblPr = node.elements.find((el) => el.name === "w:tblPr");
25570
- const tableBordersElement = tblPr.elements.find((el) => el.name === "w:tblBorders");
25571
- const tableBorders = tableBordersElement?.elements || [];
25572
- const { borders, rowBorders } = processTableBorders(tableBorders);
25573
- const tblStyleTag = tblPr.elements.find((el) => el.name === "w:tblStyle");
25574
- const tableStyleId = tblStyleTag?.attributes["w:val"];
25575
- const attrs = { tableStyleId };
25576
- const tableIndent = tblPr?.elements.find((el) => el.name === "w:tblInd");
25577
- if (tableIndent) {
25578
- const { "w:w": width, "w:type": type2 } = tableIndent.attributes;
25579
- attrs["tableIndent"] = { width: twipsToPixels(width), type: type2 };
25580
- }
25581
- const tableLayout = tblPr?.elements.find((el) => el.name === "w:tblLayout");
25582
- if (tableLayout) {
25583
- const { "w:type": type2 } = tableLayout.attributes;
25584
- attrs["tableLayout"] = type2;
25585
- }
25586
- const referencedStyles = getReferencedTableStyles(tblStyleTag, docx);
25587
- const tblW = tblPr.elements.find((el) => el.name === "w:tblW");
25588
- if (tblW) {
25589
- attrs["tableWidth"] = {
25590
- width: twipsToPixels(tblW.attributes["w:w"]),
25591
- type: tblW.attributes["w:type"]
25592
- };
25593
- }
25594
- const tblCellSpacing = tblPr.elements.find((el) => el.name === "w:tblCellSpacing");
25595
- if (tblCellSpacing) {
25596
- attrs["tableCellSpacing"] = {
25597
- w: tblCellSpacing.attributes["w:w"],
25598
- type: tblCellSpacing.attributes["w:type"]
25599
- };
25600
- attrs["borderCollapse"] = "separate";
25601
- }
25602
- const tblJustification = tblPr.elements.find((el) => el.name === "w:jc");
25603
- if (tblJustification?.attributes) {
25604
- attrs["justification"] = tblJustification.attributes["w:val"];
25812
+ if (tblPr) {
25813
+ encodedAttrs["tableProperties"] = translator$9.encode({ ...params, nodes: [tblPr] }).attributes;
25814
+ }
25815
+ const tblGrid = node.elements.find((el) => el.name === "w:tblGrid");
25816
+ if (tblGrid) {
25817
+ encodedAttrs["grid"] = translator$7.encode({ ...params, nodes: [tblGrid] }).attributes;
25818
+ }
25819
+ [
25820
+ "tableStyleId",
25821
+ "justification",
25822
+ "tableLayout",
25823
+ ["tableIndent", ({ value, type: type2 }) => ({ width: twipsToPixels(value), type: type2 })],
25824
+ ["tableWidth", ({ value, type: type2 }) => ({ width: twipsToPixels(value), type: type2 })],
25825
+ ["tableCellSpacing", ({ value, type: type2 }) => ({ w: String(value), type: type2 })]
25826
+ ].forEach((prop) => {
25827
+ let key;
25828
+ let transform;
25829
+ if (Array.isArray(prop)) {
25830
+ [key, transform] = prop;
25831
+ } else {
25832
+ key = prop;
25833
+ transform = (v2) => v2;
25834
+ }
25835
+ if (encodedAttrs.tableProperties?.[key]) {
25836
+ encodedAttrs[key] = transform(encodedAttrs.tableProperties[key]);
25837
+ }
25838
+ });
25839
+ if (encodedAttrs.tableCellSpacing) {
25840
+ encodedAttrs["borderCollapse"] = "separate";
25605
25841
  }
25842
+ const { borders, rowBorders } = _processTableBorders(encodedAttrs.tableProperties?.borders || {});
25843
+ const referencedStyles = _getReferencedTableStyles(encodedAttrs.tableStyleId, params);
25606
25844
  const rows = node.elements.filter((el) => el.name === "w:tr");
25607
- const refStylesBorders = referencedStyles?.borders || {};
25608
- const refStylesRowBorders = referencedStyles?.rowBorders || {};
25609
- const borderData = Object.keys(borders)?.length ? Object.assign(refStylesBorders, borders) : refStylesBorders;
25610
- const borderRowData = Object.keys(rowBorders)?.length ? Object.assign(refStylesRowBorders, rowBorders) : refStylesRowBorders;
25611
- attrs["borders"] = borderData;
25845
+ const borderData = Object.assign({}, referencedStyles?.borders || {}, borders || {});
25846
+ const borderRowData = Object.assign({}, referencedStyles?.rowBorders || {}, rowBorders || {});
25847
+ encodedAttrs["borders"] = borderData;
25848
+ const tblStyleTag = tblPr.elements.find((el) => el.name === "w:tblStyle");
25849
+ const columnWidths = (encodedAttrs["grid"] ?? []).map((item) => twipsToPixels(item.col));
25612
25850
  const content = [];
25613
25851
  rows.forEach((row) => {
25614
- const result = translator$6.encode({
25852
+ const result = translator$D.encode({
25615
25853
  ...params,
25616
25854
  nodes: [row],
25617
25855
  extraParams: {
25618
25856
  row,
25619
- table: node,
25620
25857
  rowBorders: borderRowData,
25621
- styleTag: tblStyleTag
25858
+ styleTag: tblStyleTag,
25859
+ columnWidths
25622
25860
  }
25623
25861
  });
25624
25862
  if (result.content?.length) content.push(result);
@@ -25626,9 +25864,113 @@ function handleTableNode(node, params) {
25626
25864
  return {
25627
25865
  type: "table",
25628
25866
  content,
25629
- attrs
25867
+ attrs: encodedAttrs
25630
25868
  };
25869
+ };
25870
+ const decode$6 = (params, decodedAttrs) => {
25871
+ params.node = preProcessVerticalMergeCells(params.node, params);
25872
+ const { node } = params;
25873
+ const elements = translateChildNodes(params);
25874
+ const firstRow = node.content?.find((n) => n.type === "tableRow");
25875
+ const properties = node.attrs.grid;
25876
+ const element = translator$7.decode({
25877
+ ...params,
25878
+ node: { ...node, attrs: { ...node.attrs, grid: properties } },
25879
+ extraParams: {
25880
+ firstRow
25881
+ }
25882
+ });
25883
+ if (element) elements.unshift(element);
25884
+ if (node.attrs?.tableProperties) {
25885
+ const properties2 = { ...node.attrs.tableProperties };
25886
+ const element2 = translator$9.decode({
25887
+ ...params,
25888
+ node: { ...node, attrs: { ...node.attrs, tableProperties: properties2 } }
25889
+ });
25890
+ if (element2) elements.unshift(element2);
25891
+ }
25892
+ return {
25893
+ name: "w:tbl",
25894
+ attributes: decodedAttrs || {},
25895
+ elements
25896
+ };
25897
+ };
25898
+ function _processTableBorders(rawBorders) {
25899
+ const borders = {};
25900
+ const rowBorders = {};
25901
+ Object.entries(rawBorders).forEach(([name, attributes]) => {
25902
+ const attrs = {};
25903
+ const color = attributes.color;
25904
+ const size = attributes.size;
25905
+ if (color && color !== "auto") attrs["color"] = color.startsWith("#") ? color : `#${color}`;
25906
+ if (size && size !== "auto") attrs["size"] = eigthPointsToPixels(size);
25907
+ const rowBorderNames = ["insideH", "insideV"];
25908
+ if (rowBorderNames.includes(name)) rowBorders[name] = attrs;
25909
+ borders[name] = attrs;
25910
+ });
25911
+ return {
25912
+ borders,
25913
+ rowBorders
25914
+ };
25915
+ }
25916
+ function _getReferencedTableStyles(tableStyleReference, params) {
25917
+ if (!tableStyleReference) return null;
25918
+ const stylesToReturn = {};
25919
+ const { docx } = params;
25920
+ const styles = docx["word/styles.xml"];
25921
+ const { elements } = styles.elements[0];
25922
+ const styleElements = elements.filter((el) => el.name === "w:style");
25923
+ const styleTag = styleElements.find((el) => el.attributes["w:styleId"] === tableStyleReference);
25924
+ if (!styleTag) return null;
25925
+ stylesToReturn.name = styleTag.elements.find((el) => el.name === "w:name");
25926
+ const basedOn = styleTag.elements.find((el) => el.name === "w:basedOn");
25927
+ let baseTblPr;
25928
+ if (basedOn?.attributes) {
25929
+ const baseStyles = styleElements.find((el) => el.attributes["w:styleId"] === basedOn.attributes["w:val"]);
25930
+ baseTblPr = baseStyles ? baseStyles.elements.find((el) => el.name === "w:tblPr") : {};
25931
+ }
25932
+ const pPr = styleTag.elements.find((el) => el.name === "w:pPr");
25933
+ if (pPr) {
25934
+ const justification = pPr.elements.find((el) => el.name === "w:jc");
25935
+ if (justification?.attributes) stylesToReturn.justification = justification.attributes["w:val"];
25936
+ }
25937
+ const rPr = styleTag?.elements.find((el) => el.name === "w:rPr");
25938
+ if (rPr) {
25939
+ const fonts = rPr.elements.find((el) => el.name === "w:rFonts");
25940
+ if (fonts) {
25941
+ const { "w:ascii": ascii, "w:hAnsi": hAnsi, "w:cs": cs } = fonts.attributes;
25942
+ stylesToReturn.fonts = { ascii, hAnsi, cs };
25943
+ }
25944
+ const fontSize = rPr.elements.find((el) => el.name === "w:sz");
25945
+ if (fontSize?.attributes) stylesToReturn.fontSize = halfPointToPoints(fontSize.attributes["w:val"]) + "pt";
25946
+ }
25947
+ const tblPr = styleTag.elements.find((el) => el.name === "w:tblPr");
25948
+ if (tblPr && tblPr.elements) {
25949
+ if (baseTblPr && baseTblPr.elements) {
25950
+ tblPr.elements.push(...baseTblPr.elements);
25951
+ }
25952
+ const tableProperties = translator$9.encode({ ...params, nodes: [tblPr] }).attributes;
25953
+ const { borders, rowBorders } = _processTableBorders(tableProperties.borders || {});
25954
+ if (borders) stylesToReturn.borders = borders;
25955
+ if (rowBorders) stylesToReturn.rowBorders = rowBorders;
25956
+ const cellMargins = {};
25957
+ Object.entries(tableProperties.cellMargins || {}).forEach(([key, attrs]) => {
25958
+ if (attrs?.value) cellMargins[key] = String(attrs.value);
25959
+ });
25960
+ if (Object.keys(cellMargins).length) stylesToReturn.cellMargins = cellMargins;
25961
+ }
25962
+ return stylesToReturn;
25631
25963
  }
25964
+ const config$6 = {
25965
+ xmlName: XML_NODE_NAME$6,
25966
+ sdNodeOrKeyName: SD_NODE_NAME$6,
25967
+ type: NodeTranslator.translatorTypes.NODE,
25968
+ encode: encode$6,
25969
+ decode: decode$6,
25970
+ attributes: []
25971
+ };
25972
+ const translator$6 = NodeTranslator.from(config$6);
25973
+ const tableNodeHandlerEntity = generateV2HandlerEntity("tableNodeHandler", translator$6);
25632
25974
  function getReferencedTableStyles(tblStyleTag, docx) {
25633
25975
  if (!tblStyleTag) return null;
25634
25976
  const stylesToReturn = {};
@@ -25709,15 +26051,6 @@ function processTableBorders(borderElements) {
25709
26051
  rowBorders
25710
26052
  };
25711
26053
  }
25712
- const getGridColumnWidths = (tableNode) => {
25713
- const tblGrid = tableNode.elements.find((el) => el.name === "w:tblGrid");
25714
- if (!tblGrid) return [];
25715
- const columnWidths = tblGrid?.elements?.flatMap((el) => {
25716
- if (el.name !== "w:gridCol") return [];
25717
- return twipsToPixels(el.attributes["w:w"]);
25718
- }) || [];
25719
- return columnWidths;
25720
- };
25721
26054
  function handleTableCellNode({
25722
26055
  params,
25723
26056
  node,
@@ -25726,7 +26059,8 @@ function handleTableCellNode({
25726
26059
  rowBorders,
25727
26060
  styleTag,
25728
26061
  columnIndex,
25729
- columnWidth = null
26062
+ columnWidth = null,
26063
+ allColumnWidths = []
25730
26064
  }) {
25731
26065
  const { docx, nodeListHandler } = params;
25732
26066
  const tcPr = node.elements.find((el) => el.name === "w:tcPr");
@@ -25740,7 +26074,7 @@ function handleTableCellNode({
25740
26074
  delete rowBorders?.insideV;
25741
26075
  }
25742
26076
  const inlineBorders = processInlineCellBorders(borders, rowBorders);
25743
- const gridColumnWidths = getGridColumnWidths(table);
26077
+ const gridColumnWidths = allColumnWidths;
25744
26078
  const tcWidth = tcPr?.elements?.find((el) => el.name === "w:tcW");
25745
26079
  let width = tcWidth ? twipsToPixels(tcWidth.attributes["w:w"]) : null;
25746
26080
  const widthType = tcWidth?.attributes["w:type"];
@@ -25996,7 +26330,16 @@ const XML_NODE_NAME$5 = "w:tc";
25996
26330
  const SD_NODE_NAME$5 = "tableCell";
25997
26331
  const validXmlAttributes$5 = [];
25998
26332
  function encode$5(params, encodedAttrs) {
25999
- const { node, table, row, rowBorders, styleTag, columnIndex, columnWidth } = params.extraParams;
26333
+ const {
26334
+ node,
26335
+ table,
26336
+ row,
26337
+ rowBorders,
26338
+ styleTag,
26339
+ columnIndex,
26340
+ columnWidth,
26341
+ columnWidths: allColumnWidths
26342
+ } = params.extraParams;
26000
26343
  const schemaNode = handleTableCellNode({
26001
26344
  params,
26002
26345
  node,
@@ -26005,7 +26348,8 @@ function encode$5(params, encodedAttrs) {
26005
26348
  rowBorders,
26006
26349
  styleTag,
26007
26350
  columnIndex,
26008
- columnWidth
26351
+ columnWidth,
26352
+ allColumnWidths
26009
26353
  });
26010
26354
  if (encodedAttrs && Object.keys(encodedAttrs).length) {
26011
26355
  schemaNode.attrs = { ...schemaNode.attrs, ...encodedAttrs };
@@ -26947,9 +27291,9 @@ const config$2 = {
26947
27291
  };
26948
27292
  const translator$2 = NodeTranslator.from(config$2);
26949
27293
  const registeredHandlers = Object.freeze({
26950
- "w:br": translator$m,
26951
- "w:tab": translator$l,
26952
- "w:p": translator$k,
27294
+ "w:br": translator$T,
27295
+ "w:tab": translator$S,
27296
+ "w:p": translator$R,
26953
27297
  "wp:anchor": translator$3,
26954
27298
  "wp:inline": translator$2
26955
27299
  });
@@ -28609,19 +28953,19 @@ function exportSchemaToJson(params) {
28609
28953
  doc: translateDocumentNode,
28610
28954
  body: translateBodyNode,
28611
28955
  heading: translateHeadingNode,
28612
- paragraph: translator$k,
28956
+ paragraph: translator$R,
28613
28957
  text: translateTextNode,
28614
28958
  bulletList: translateList,
28615
28959
  orderedList: translateList,
28616
- lineBreak: translator$m,
28617
- table: translateTable,
28618
- tableRow: translator$6,
28960
+ lineBreak: translator$T,
28961
+ table: translator$6,
28962
+ tableRow: translator$D,
28619
28963
  tableCell: translator$5,
28620
28964
  bookmarkStart: translateBookmarkStart,
28621
28965
  fieldAnnotation: translator,
28622
- tab: translator$l,
28966
+ tab: translator$S,
28623
28967
  image: translator$1,
28624
- hardBreak: translator$m,
28968
+ hardBreak: translator$T,
28625
28969
  commentRangeStart: () => translateCommentNode(params, "Start"),
28626
28970
  commentRangeEnd: () => translateCommentNode(params, "End"),
28627
28971
  commentReference: () => null,
@@ -29228,131 +29572,6 @@ const generateNumPrTag = (numId, level) => {
29228
29572
  ]
29229
29573
  };
29230
29574
  };
29231
- function translateTable(params) {
29232
- params.node = preProcessVerticalMergeCells(params.node, params);
29233
- const elements = translateChildNodes(params);
29234
- const tableProperties = generateTableProperties(params.node);
29235
- const gridProperties = generateTableGrid(params.node, params);
29236
- elements.unshift(tableProperties);
29237
- elements.unshift(gridProperties);
29238
- return {
29239
- name: "w:tbl",
29240
- elements
29241
- };
29242
- }
29243
- function generateTableProperties(node) {
29244
- const elements = [];
29245
- const { attrs } = node;
29246
- const { tableWidth, tableStyleId, borders, tableIndent, tableLayout, tableCellSpacing, justification } = attrs;
29247
- if (tableStyleId) {
29248
- const tableStyleElement = {
29249
- name: "w:tblStyle",
29250
- attributes: { "w:val": tableStyleId }
29251
- };
29252
- elements.push(tableStyleElement);
29253
- }
29254
- if (borders) {
29255
- const borderElement = generateTableBorders(node);
29256
- elements.push(borderElement);
29257
- }
29258
- if (tableIndent) {
29259
- const { width, type: type2 } = tableIndent;
29260
- const tableIndentElement = {
29261
- name: "w:tblInd",
29262
- attributes: { "w:w": pixelsToTwips(width), "w:type": type2 }
29263
- };
29264
- elements.push(tableIndentElement);
29265
- }
29266
- if (tableLayout) {
29267
- const tableLayoutElement = {
29268
- name: "w:tblLayout",
29269
- attributes: { "w:type": tableLayout }
29270
- };
29271
- elements.push(tableLayoutElement);
29272
- }
29273
- if (tableWidth && tableWidth.width) {
29274
- const tableWidthElement = {
29275
- name: "w:tblW",
29276
- attributes: { "w:w": pixelsToTwips(tableWidth.width), "w:type": tableWidth.type }
29277
- };
29278
- elements.push(tableWidthElement);
29279
- }
29280
- if (tableCellSpacing) {
29281
- elements.push({
29282
- name: "w:tblCellSpacing",
29283
- attributes: {
29284
- "w:w": tableCellSpacing.w,
29285
- "w:type": tableCellSpacing.type
29286
- }
29287
- });
29288
- }
29289
- if (justification) {
29290
- const justificationElement = {
29291
- name: "w:jc",
29292
- attributes: { "w:val": justification }
29293
- };
29294
- elements.push(justificationElement);
29295
- }
29296
- return {
29297
- name: "w:tblPr",
29298
- elements
29299
- };
29300
- }
29301
- function generateTableBorders(node) {
29302
- const { borders } = node.attrs;
29303
- const elements = [];
29304
- if (!borders) return;
29305
- const borderTypes = ["top", "bottom", "left", "right", "insideH", "insideV"];
29306
- borderTypes.forEach((type2) => {
29307
- const border = borders[type2];
29308
- if (!border) return;
29309
- let attributes = {};
29310
- if (!Object.keys(border).length || !border.size) {
29311
- attributes = {
29312
- "w:val": "nil"
29313
- };
29314
- } else {
29315
- attributes = {
29316
- "w:val": "single",
29317
- "w:sz": pixelsToEightPoints(border.size),
29318
- "w:space": border.space || 0,
29319
- "w:color": border?.color?.substring(1) || "000000"
29320
- };
29321
- }
29322
- const borderElement = {
29323
- name: `w:${type2}`,
29324
- attributes
29325
- };
29326
- elements.push(borderElement);
29327
- });
29328
- return {
29329
- name: "w:tblBorders",
29330
- elements
29331
- };
29332
- }
29333
- function generateTableGrid(node, params) {
29334
- const { editorSchema } = params;
29335
- let colgroup = [];
29336
- try {
29337
- const pmNode = editorSchema.nodeFromJSON(node);
29338
- const cellMinWidth = 10;
29339
- const { colgroupValues } = createColGroup(pmNode, cellMinWidth);
29340
- colgroup = colgroupValues;
29341
- } catch {
29342
- colgroup = [];
29343
- }
29344
- const elements = [];
29345
- colgroup?.forEach((width) => {
29346
- elements.push({
29347
- name: "w:gridCol",
29348
- attributes: { "w:w": pixelsToTwips(width) }
29349
- });
29350
- });
29351
- return {
29352
- name: "w:tblGrid",
29353
- elements
29354
- };
29355
- }
29356
29575
  function translateBookmarkStart(params) {
29357
29576
  const bookmarkStartNode = {
29358
29577
  name: "w:bookmarkStart",
@@ -29928,7 +30147,7 @@ const handleParagraphNode = (params) => {
29928
30147
  if (nodes.length === 0 || nodes[0].name !== "w:p") {
29929
30148
  return { nodes: [], consumed: 0 };
29930
30149
  }
29931
- const schemaNode = translator$k.encode(params);
30150
+ const schemaNode = translator$R.encode(params);
29932
30151
  const newNodes = schemaNode ? [schemaNode] : [];
29933
30152
  return { nodes: newNodes, consumed: 1 };
29934
30153
  };
@@ -30031,7 +30250,7 @@ const handler = (params) => {
30031
30250
  if (nodes.length === 0 || nodes[0].name !== "w:br") {
30032
30251
  return { nodes: [], consumed: 0 };
30033
30252
  }
30034
- const result = translator$m.encode(params);
30253
+ const result = translator$T.encode(params);
30035
30254
  if (!result) return { nodes: [], consumed: 0 };
30036
30255
  return {
30037
30256
  nodes: [result],
@@ -30727,7 +30946,7 @@ const handleTabNode = (params) => {
30727
30946
  if (!nodes.length || nodes[0].name !== "w:tab") {
30728
30947
  return { nodes: [], consumed: 0 };
30729
30948
  }
30730
- const node = translator$l.encode(params);
30949
+ const node = translator$S.encode(params);
30731
30950
  return { nodes: [node], consumed: 1 };
30732
30951
  };
30733
30952
  const tabNodeEntityHandler = {
@@ -31807,14 +32026,12 @@ export {
31807
32026
  createDocFromMarkdown as a7,
31808
32027
  createDocFromHTML as a8,
31809
32028
  EditorState as a9,
31810
- xmljs as aA,
31811
- vClickOutside as aB,
31812
- getActiveFormatting as aC,
31813
- readFromClipboard as aD,
31814
- handleClipboardPaste as aE,
31815
- getFileObject as aF,
31816
- _sfc_main as aG,
31817
- registeredHandlers as aH,
32029
+ getActiveFormatting as aA,
32030
+ readFromClipboard as aB,
32031
+ handleClipboardPaste as aC,
32032
+ getFileObject as aD,
32033
+ _sfc_main as aE,
32034
+ registeredHandlers as aF,
31818
32035
  hasSomeParentWithClass as aa,
31819
32036
  isActive as ab,
31820
32037
  unflattenListsInHtml as ac,
@@ -31829,18 +32046,18 @@ export {
31829
32046
  parseIndentElement as al,
31830
32047
  combineIndents as am,
31831
32048
  StepMap as an,
31832
- getColStyleDeclaration as ao,
31833
- SelectionRange as ap,
31834
- Transform as aq,
31835
- isInTable as ar,
31836
- createColGroup as as,
31837
- generateDocxRandomId as at,
31838
- insertNewRelationship as au,
31839
- updateDOMAttributes as av,
31840
- htmlHandler as aw,
31841
- commonjsGlobal as ax,
31842
- getDefaultExportFromCjs$1 as ay,
31843
- getContentTypesFromXml as az,
32049
+ SelectionRange as ao,
32050
+ Transform as ap,
32051
+ isInTable as aq,
32052
+ generateDocxRandomId as ar,
32053
+ insertNewRelationship as as,
32054
+ updateDOMAttributes as at,
32055
+ htmlHandler as au,
32056
+ commonjsGlobal as av,
32057
+ getDefaultExportFromCjs$1 as aw,
32058
+ getContentTypesFromXml as ax,
32059
+ xmljs as ay,
32060
+ vClickOutside as az,
31844
32061
  Slice as b,
31845
32062
  DOMParser$1 as c,
31846
32063
  Mark as d,