@harbour-enterprises/superdoc 0.13.0-RC2 → 0.13.0-next.0

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 (95) hide show
  1. package/dist/chunks/{eventemitter3-Dq2TEegt.es.js → eventemitter3-BrspJk8q.es.js} +1 -1
  2. package/dist/chunks/{eventemitter3-DuScojUH.cjs → eventemitter3-DfVviFzP.cjs} +1 -1
  3. package/dist/chunks/{index-CMBtuT02.cjs → index-B4J7wgs6.cjs} +2 -2
  4. package/dist/chunks/{index-B1MhwjTC.cjs → index-Cdsq63Xq.cjs} +4 -4
  5. package/dist/chunks/{index-SKpROzLW.es.js → index-Diu6UKHt.es.js} +4 -4
  6. package/dist/chunks/{index-BrSjd1Id.es.js → index-Hr3Um-Bg.es.js} +2 -2
  7. package/dist/chunks/{jszip-Bwu_om3F.cjs → jszip-BTAcmbVg.cjs} +1 -1
  8. package/dist/chunks/{jszip-BmWWPxfF.es.js → jszip-DckFs3A7.es.js} +1 -1
  9. package/dist/chunks/{super-editor.es-CG_E8Uh1.cjs → super-editor.es-B4lFJKTF.cjs} +3765 -1629
  10. package/dist/chunks/{super-editor.es-B6M3d3ew.es.js → super-editor.es-C-QroPG4.es.js} +3765 -1629
  11. package/dist/chunks/{url-DuggQ5JR.cjs → url-BIzg4y2i.cjs} +2 -2
  12. package/dist/chunks/{url-CAZQTNP3.es.js → url-CHayXMZH.es.js} +2 -2
  13. package/dist/chunks/{vue-IIIZMHTg.es.js → vue-Bi1uWinj.es.js} +17 -11
  14. package/dist/chunks/{vue-DPZkajuO.cjs → vue-HIY1g7dm.cjs} +17 -11
  15. package/dist/chunks/{xml-js-B7Vccv2s.cjs → xml-js-BjqmFOSP.cjs} +2 -2
  16. package/dist/chunks/{xml-js-BV-kCPOA.es.js → xml-js-CfClL-1b.es.js} +2 -2
  17. package/dist/core/SuperDoc.d.ts +0 -6
  18. package/dist/core/SuperDoc.d.ts.map +1 -1
  19. package/dist/core/collaboration/collaboration.d.ts +0 -9
  20. package/dist/core/collaboration/collaboration.d.ts.map +1 -1
  21. package/dist/core/collaboration/helpers.d.ts.map +1 -1
  22. package/dist/style.css +246 -147
  23. package/dist/super-editor/ai-writer.es.js +2 -2
  24. package/dist/super-editor/chunks/{converter-DdMoUfYl.js → converter-Bwa99qcs.js} +571 -336
  25. package/dist/super-editor/chunks/{docx-zipper-CaPhHWh0.js → docx-zipper-CVKlI3mU.js} +1 -1
  26. package/dist/super-editor/chunks/{editor-DfrK7LO9.js → editor-BdaZqkkS.js} +3590 -1911
  27. package/dist/super-editor/chunks/{toolbar-h35AzYvu.js → toolbar-BNg5l9RP.js} +130 -37
  28. package/dist/super-editor/components/pagination-helpers.d.ts.map +1 -1
  29. package/dist/super-editor/converter.es.js +1 -1
  30. package/dist/super-editor/core/Editor.d.ts +1 -8
  31. package/dist/super-editor/core/Editor.d.ts.map +1 -1
  32. package/dist/super-editor/core/InputRule.d.ts +7 -0
  33. package/dist/super-editor/core/InputRule.d.ts.map +1 -1
  34. package/dist/super-editor/core/commands/splitListItem.d.ts +1 -1
  35. package/dist/super-editor/core/commands/splitListItem.d.ts.map +1 -1
  36. package/dist/super-editor/core/helpers/annotator.d.ts +2 -0
  37. package/dist/super-editor/core/helpers/annotator.d.ts.map +1 -1
  38. package/dist/super-editor/core/helpers/findWordBounds.d.ts +5 -0
  39. package/dist/super-editor/core/helpers/findWordBounds.d.ts.map +1 -0
  40. package/dist/super-editor/core/helpers/setWordSelection.d.ts +2 -0
  41. package/dist/super-editor/core/helpers/setWordSelection.d.ts.map +1 -0
  42. package/dist/super-editor/core/inputRules/docx-paste/docx-paste.d.ts.map +1 -1
  43. package/dist/super-editor/core/super-converter/SuperConverter.d.ts +4 -1
  44. package/dist/super-editor/core/super-converter/SuperConverter.d.ts.map +1 -1
  45. package/dist/super-editor/core/super-converter/exporter.d.ts.map +1 -1
  46. package/dist/super-editor/core/super-converter/helpers.d.ts.map +1 -1
  47. package/dist/super-editor/core/super-converter/v2/importer/autoPageNumberImporter.d.ts.map +1 -1
  48. package/dist/super-editor/core/super-converter/v2/importer/listImporter.d.ts +5 -32
  49. package/dist/super-editor/core/super-converter/v2/importer/listImporter.d.ts.map +1 -1
  50. package/dist/super-editor/core/super-converter/v2/importer/paragraphNodeImporter.d.ts.map +1 -1
  51. package/dist/super-editor/docx-zipper.es.js +2 -2
  52. package/dist/super-editor/editor.es.js +3 -3
  53. package/dist/super-editor/extensions/field-annotation/FieldAnnotationView.d.ts.map +1 -1
  54. package/dist/super-editor/extensions/field-annotation/field-annotation.d.ts.map +1 -1
  55. package/dist/super-editor/extensions/image/imageHelpers/imagePositionPlugin.d.ts.map +1 -1
  56. package/dist/super-editor/extensions/image/imageHelpers/index.d.ts +1 -0
  57. package/dist/super-editor/extensions/image/imageHelpers/processUploadedImage.d.ts.map +1 -1
  58. package/dist/super-editor/extensions/image/index.d.ts +1 -0
  59. package/dist/super-editor/extensions/index.d.ts +2 -1
  60. package/dist/super-editor/extensions/index.d.ts.map +1 -1
  61. package/dist/super-editor/extensions/line-height/line-height.d.ts.map +1 -1
  62. package/dist/super-editor/extensions/linked-styles/linked-styles.d.ts.map +1 -1
  63. package/dist/super-editor/extensions/list-item/list-item.d.ts.map +1 -1
  64. package/dist/super-editor/extensions/noderesizer/index.d.ts +2 -0
  65. package/dist/super-editor/extensions/noderesizer/index.d.ts.map +1 -0
  66. package/dist/super-editor/extensions/noderesizer/noderesizer.d.ts +7 -0
  67. package/dist/super-editor/extensions/noderesizer/noderesizer.d.ts.map +1 -0
  68. package/dist/super-editor/extensions/ordered-list/ordered-list.d.ts.map +1 -1
  69. package/dist/super-editor/extensions/page-number/page-number.d.ts +10 -0
  70. package/dist/super-editor/extensions/page-number/page-number.d.ts.map +1 -1
  71. package/dist/super-editor/extensions/pagination/pagination-helpers.d.ts +2 -1
  72. package/dist/super-editor/extensions/pagination/pagination-helpers.d.ts.map +1 -1
  73. package/dist/super-editor/extensions/pagination/pagination.d.ts.map +1 -1
  74. package/dist/super-editor/extensions/paragraph/paragraph.d.ts.map +1 -1
  75. package/dist/super-editor/file-zipper.es.js +1 -1
  76. package/dist/super-editor/style.css +219 -120
  77. package/dist/super-editor/super-editor.es.js +325 -200
  78. package/dist/super-editor/tests/e2e/test-app/vite.config.d.ts +1 -1
  79. package/dist/super-editor/tests/export/export-helpers/export-helpers.d.ts.map +1 -1
  80. package/dist/super-editor/toolbar.es.js +2 -2
  81. package/dist/super-editor.cjs +2 -2
  82. package/dist/super-editor.es.js +2 -2
  83. package/dist/superdoc.cjs +1590 -367
  84. package/dist/superdoc.es.js +1575 -368
  85. package/dist/superdoc.umd.js +5248 -1904
  86. package/dist/superdoc.umd.js.map +1 -1
  87. package/package.json +3 -2
  88. package/dist/super-editor/core/helpers/list-numbering-helpers.d.ts +0 -235
  89. package/dist/super-editor/core/helpers/list-numbering-helpers.d.ts.map +0 -1
  90. package/dist/super-editor/extensions/list-item/ListItemNodeView.d.ts +0 -56
  91. package/dist/super-editor/extensions/list-item/ListItemNodeView.d.ts.map +0 -1
  92. package/dist/super-editor/tests/e2e/test-app/dist/assets/index-BTMvkUyI.d.ts +0 -3
  93. package/dist/super-editor/tests/e2e/test-app/dist/assets/index-BTMvkUyI.d.ts.map +0 -1
  94. package/dist/super-editor/tests/editor/listItemHelpers.test.d.ts +0 -2
  95. package/dist/super-editor/tests/editor/listItemHelpers.test.d.ts.map +0 -1
@@ -12438,7 +12438,7 @@ const OPT_PRESERVE_WS = 1, OPT_PRESERVE_WS_FULL = 2, OPT_OPEN_LEFT = 4;
12438
12438
  function wsOptionsFor(type2, preserveWhitespace, base) {
12439
12439
  if (preserveWhitespace != null)
12440
12440
  return (preserveWhitespace ? OPT_PRESERVE_WS : 0) | (preserveWhitespace === "full" ? OPT_PRESERVE_WS_FULL : 0);
12441
- return type2 && type2.whitespace == "pre" ? OPT_PRESERVE_WS | OPT_PRESERVE_WS_FULL : base & -5;
12441
+ return type2 && type2.whitespace == "pre" ? OPT_PRESERVE_WS | OPT_PRESERVE_WS_FULL : base & ~OPT_OPEN_LEFT;
12442
12442
  }
12443
12443
  class NodeContext {
12444
12444
  constructor(type2, attrs, marks, solid, match, options2) {
@@ -15409,7 +15409,7 @@ class Transaction extends Transform {
15409
15409
  throw new RangeError("Selection passed to setSelection must point at the current document");
15410
15410
  this.curSelection = selection;
15411
15411
  this.curSelectionFor = this.steps.length;
15412
- this.updated = (this.updated | UPDATED_SEL) & -3;
15412
+ this.updated = (this.updated | UPDATED_SEL) & ~UPDATED_MARKS;
15413
15413
  this.storedMarks = null;
15414
15414
  return this;
15415
15415
  }
@@ -15460,7 +15460,7 @@ class Transaction extends Transform {
15460
15460
  */
15461
15461
  addStep(step, doc2) {
15462
15462
  super.addStep(step, doc2);
15463
- this.updated = this.updated & -3;
15463
+ this.updated = this.updated & ~UPDATED_MARKS;
15464
15464
  this.storedMarks = null;
15465
15465
  }
15466
15466
  /**
@@ -16076,7 +16076,6 @@ const getLineHeightValueString = (lineHeight, defaultUnit, lineRule = "", isObje
16076
16076
  if (Number.isNaN(value) || value === 0) return {};
16077
16077
  if (lineRule === "atLeast" && value < 1) return {};
16078
16078
  unit = unit ? unit : defaultUnit;
16079
- value += unit ? 4 : 0.2;
16080
16079
  return isObject ? { ["line-height"]: `${value}${unit}` } : `line-height: ${value}${unit}`;
16081
16080
  };
16082
16081
  const deobfuscateFont = (arrayBuffer, guidHex) => {
@@ -17341,6 +17340,16 @@ const carbonCopy = (obj) => {
17341
17340
  return void 0;
17342
17341
  }
17343
17342
  };
17343
+ const baseOrderedListDef = {
17344
+ "attributes": {
17345
+ "w:abstractNumId": "1"
17346
+ }
17347
+ };
17348
+ const baseBulletList = {
17349
+ "attributes": {
17350
+ "w:abstractNumId": "0"
17351
+ }
17352
+ };
17344
17353
  const baseNumbering = {
17345
17354
  "declaration": {
17346
17355
  "attributes": {
@@ -18855,7 +18864,9 @@ function exportSchemaToJson(params) {
18855
18864
  shapeContainer: translateShapeContainer,
18856
18865
  shapeTextbox: translateShapeTextbox,
18857
18866
  contentBlock: translateContentBlock,
18858
- structuredContent: translateStructuredContent
18867
+ structuredContent: translateStructuredContent,
18868
+ "page-number": translatePageNumberNode,
18869
+ "total-page-number": translateTotalPageNumberNode
18859
18870
  };
18860
18871
  if (!router[type2]) {
18861
18872
  console.error("No translation function found for node type:", type2);
@@ -18959,7 +18970,7 @@ function generateParagraphProperties(node2) {
18959
18970
  };
18960
18971
  pPrElements.push(spacingElement);
18961
18972
  }
18962
- if (indent && Object.values(indent).some((v) => v !== 0)) {
18973
+ if (indent) {
18963
18974
  const { left, right, firstLine, hanging } = indent;
18964
18975
  const attributes = {};
18965
18976
  if (left || left === 0) attributes["w:left"] = pixelsToTwips(left);
@@ -18974,7 +18985,7 @@ function generateParagraphProperties(node2) {
18974
18985
  attributes
18975
18986
  };
18976
18987
  pPrElements.push(indentElement);
18977
- } else if (textIndent && textIndent !== "0in") {
18988
+ } else if (textIndent) {
18978
18989
  const indentElement = {
18979
18990
  name: "w:ind",
18980
18991
  attributes: {
@@ -19023,9 +19034,6 @@ function generateParagraphProperties(node2) {
19023
19034
  if (sectPr) {
19024
19035
  pPrElements.push(sectPr);
19025
19036
  }
19026
- const numPr = node2.attrs?.paragraphProperties?.elements?.find((n) => n.name === "w:numPr");
19027
- const hasNumPr = pPrElements.some((n) => n.name === "w:numPr");
19028
- if (numPr && !hasNumPr) pPrElements.push(numPr);
19029
19037
  if (!pPrElements.length) return null;
19030
19038
  return {
19031
19039
  name: "w:pPr",
@@ -19274,68 +19282,160 @@ function addNewImageRelationship(params, imagePath) {
19274
19282
  return newId;
19275
19283
  }
19276
19284
  function translateList(params) {
19277
- const { node: node2 } = params;
19278
- const { attrs = {} } = node2;
19279
- if (node2.content.length > 1) {
19280
- flattenContent(params);
19281
- throw new Error("Multi list not supported yet");
19282
- }
19283
- const listItem = node2.content[0];
19284
- const { numId, level } = listItem.attrs;
19285
- let numPrTag;
19286
- if (numId) {
19287
- numPrTag = generateNumPrTag(numId, level);
19288
- }
19289
- const paragraphNode = node2.content[0]?.content[0];
19290
- const outputNode = exportSchemaToJson({ ...params, node: paragraphNode });
19291
- const pPr = outputNode.elements.find((n) => n.name === "w:pPr");
19292
- if (pPr && pPr.elements) pPr.elements.unshift(numPrTag);
19293
- const indentTag = restoreIndent(listItem.attrs.indent);
19294
- indentTag && pPr?.elements?.push(indentTag);
19295
- const runNode = outputNode.elements?.find((n) => n.name === "w:r");
19296
- const rPr = runNode?.elements?.find((n) => n.name === "w:rPr");
19297
- if (rPr) pPr.elements.push(rPr);
19298
- if (listItem.attrs.numPrType !== "inline") {
19299
- const numPrIndex = pPr?.elements?.findIndex((e) => e.name === "w:numPr");
19300
- if (numPrIndex !== -1) {
19301
- pPr?.elements?.splice(numPrIndex, 1);
19302
- }
19303
- }
19304
- return [outputNode];
19305
- }
19306
- const restoreIndent = (indent) => {
19307
- const attributes = {};
19308
- if (!indent) indent = {};
19309
- if (indent.left || indent.left === 0) attributes["w:left"] = pixelsToTwips(indent.left);
19310
- if (indent.right || indent.right === 0) attributes["w:right"] = pixelsToTwips(indent.right);
19311
- if (indent.firstLine || indent.firstLine === 0) attributes["w:firstLine"] = pixelsToTwips(indent.firstLine);
19312
- if (indent.hanging || indent.hanging === 0) attributes["w:hanging"] = pixelsToTwips(indent.hanging);
19313
- if (indent.leftChars || indent.leftChars === 0) attributes["w:leftChars"] = pixelsToTwips(indent.leftChars);
19314
- if (!Object.keys(attributes).length) return;
19315
- return {
19316
- name: "w:ind",
19285
+ const { type: type2 } = params.node;
19286
+ const flatContent = flattenContent(params);
19287
+ const listNodes = [];
19288
+ flatContent.forEach((listNode) => {
19289
+ const { level, listType, pPrs: additionalPprs, content, attrs = {} } = listNode;
19290
+ const attrsNumId = listNode.attrs.numId;
19291
+ const actualNumId = attrsNumId || listNode.listId;
19292
+ const listId = actualNumId ?? generateNewListDefinition(params, listType);
19293
+ const pPr = getListParagraphProperties(level, listId, additionalPprs);
19294
+ content.forEach((contentNode, index) => {
19295
+ const paragraphNode = Object.assign({}, contentNode);
19296
+ paragraphNode.attrs = {
19297
+ ...paragraphNode.attrs,
19298
+ ...listNode.attrs
19299
+ };
19300
+ const outputNode = exportSchemaToJson({ ...params, node: paragraphNode });
19301
+ if (!outputNode.elements) {
19302
+ outputNode.elements = [];
19303
+ }
19304
+ if (Array.isArray(outputNode)) {
19305
+ const mapped = [];
19306
+ outputNode.forEach((el, index2) => {
19307
+ el.elements.forEach((element) => {
19308
+ if (element.name === "w:pPr") return;
19309
+ mapped.push(element);
19310
+ });
19311
+ if (index2 < outputNode.length - 1) mapped.push({ name: "w:br", type: "element" });
19312
+ });
19313
+ mapped.unshift(carbonCopy(pPr));
19314
+ return listNodes.push({ name: "w:p", elements: mapped });
19315
+ }
19316
+ const propsElementIndex = outputNode.elements.findIndex((e) => e.name === "w:pPr");
19317
+ const content2 = outputNode.elements.filter((e) => e.name !== "w:pPr");
19318
+ if (!content2.length && !Array.isArray(outputNode)) {
19319
+ const elements = contentNode.attrs.paragraphProperties ? [contentNode.attrs.paragraphProperties] : [];
19320
+ const spacer = {
19321
+ name: "w:p",
19322
+ type: "element",
19323
+ elements
19324
+ };
19325
+ return listNodes.push(spacer);
19326
+ }
19327
+ outputNode.elements = outputNode.elements.map((el, index2) => {
19328
+ if (el.name === "w:sdt") {
19329
+ const contentIndex = el.elements.findIndex((e) => e.name === "w:sdtContent");
19330
+ const content3 = el.elements[contentIndex];
19331
+ const innerContent = content3.elements[0];
19332
+ if (innerContent.name === "w:p") {
19333
+ content3.elements = innerContent.elements;
19334
+ }
19335
+ return {
19336
+ name: "w:r",
19337
+ type: "element",
19338
+ elements: [el]
19339
+ };
19340
+ } else {
19341
+ return el;
19342
+ }
19343
+ });
19344
+ const { attributes: generalAttributes } = attrs;
19345
+ const { originalInlineRunProps } = generalAttributes || {};
19346
+ if (originalInlineRunProps) pPr.elements.push(originalInlineRunProps);
19347
+ if (propsElementIndex === -1) {
19348
+ outputNode.elements.unshift(carbonCopy(pPr));
19349
+ } else {
19350
+ const resultProps = carbonCopy(pPr).elements.map((item) => {
19351
+ const isChanged = outputNode.elements[propsElementIndex].elements.find((e) => e.name === item.name);
19352
+ return isChanged ? isChanged : item;
19353
+ });
19354
+ outputNode.elements[propsElementIndex].elements = resultProps;
19355
+ }
19356
+ let importedFontSize;
19357
+ if (listNode.attrs?.importedFontSize) {
19358
+ const fontNoUnit = parseInt(listNode.attrs.importedFontSize.split("pt")[0]);
19359
+ importedFontSize = {
19360
+ name: "w:sz",
19361
+ attributes: { "w:val": fontNoUnit * 2 }
19362
+ };
19363
+ }
19364
+ let importedFontFamily;
19365
+ if (listNode.attrs?.importedFontFamily) {
19366
+ importedFontFamily = {
19367
+ name: "w:rFonts",
19368
+ attributes: { "w:ascii": listNode.attrs?.importedFontFamily, "w:hAnsi": listNode.attrs?.importedFontFamily }
19369
+ };
19370
+ }
19371
+ const rPrElement = outputNode.elements.find((e) => e.name === "w:rPr");
19372
+ if (rPrElement) {
19373
+ rPrElement.elements.push(fontSize);
19374
+ } else if (importedFontSize || importedFontFamily) {
19375
+ const elements = [];
19376
+ if (importedFontSize) elements.push(importedFontSize);
19377
+ if (importedFontFamily) elements.push(importedFontFamily);
19378
+ outputNode.elements.unshift({ name: "w:rPr", elements });
19379
+ }
19380
+ if (index !== 0) {
19381
+ const currentpPr = outputNode.elements.find((e) => e.name === "w:pPr");
19382
+ const numPrIndex = currentpPr.elements.findIndex((e) => e.name === "w:numPr");
19383
+ if (numPrIndex !== -1) currentpPr.elements.splice(numPrIndex, 1);
19384
+ }
19385
+ listNodes.push(outputNode);
19386
+ });
19387
+ });
19388
+ return listNodes;
19389
+ }
19390
+ function generateNewListDefinition(params, listType) {
19391
+ const nextNumbering = getLargestListDefinitionIndex(params.converter?.numbering?.definitions);
19392
+ const definition = listType === "bullet" ? baseBulletList : baseOrderedListDef;
19393
+ const listId = nextNumbering;
19394
+ const abstractId = definition.attributes["w:abstractNumId"];
19395
+ const newNumDef = {
19317
19396
  type: "element",
19318
- attributes
19397
+ name: "w:num",
19398
+ attributes: {
19399
+ "w:numId": String(listId),
19400
+ "w16cid:durableId": "485517411"
19401
+ },
19402
+ elements: [
19403
+ { name: "w:abstractNumId", attributes: { "w:val": String(abstractId) } }
19404
+ ]
19319
19405
  };
19406
+ params.converter.numbering.definitions[listId] = newNumDef;
19407
+ return listId;
19408
+ }
19409
+ const getLargestListDefinitionIndex = (definitions) => {
19410
+ if (!definitions || !Object.keys(definitions).length) return 0;
19411
+ const maxKey = Math.max(...Object.keys(definitions).map((key) => parseInt(key, 10)));
19412
+ return maxKey + 1;
19320
19413
  };
19321
- const generateNumPrTag = (numId, level) => {
19414
+ function getListParagraphProperties(level, numId, additionalPprs = []) {
19322
19415
  return {
19323
- name: "w:numPr",
19416
+ name: "w:pPr",
19324
19417
  type: "element",
19325
19418
  elements: [
19326
19419
  {
19327
- name: "w:numId",
19420
+ name: "w:numPr",
19328
19421
  type: "element",
19329
- attributes: { "w:val": numId }
19422
+ elements: [
19423
+ {
19424
+ name: "w:ilvl",
19425
+ type: "element",
19426
+ attributes: { "w:val": level }
19427
+ },
19428
+ {
19429
+ name: "w:numId",
19430
+ type: "element",
19431
+ attributes: { "w:val": numId }
19432
+ }
19433
+ ]
19330
19434
  },
19331
- {
19332
- name: "w:ilvl",
19333
- type: "element",
19334
- attributes: { "w:val": level }
19335
- }
19435
+ ...additionalPprs
19336
19436
  ]
19337
19437
  };
19338
- };
19438
+ }
19339
19439
  function flattenContent({ node: node2 }) {
19340
19440
  const { content, attrs = {} } = node2;
19341
19441
  const { listId, syncId } = node2.attrs || {};
@@ -19406,7 +19506,10 @@ function preProcessVerticalMergeCells(table, { editorSchema }) {
19406
19506
  if (!row.content) continue;
19407
19507
  for (let cellIndex = 0; cellIndex < row.content?.length; cellIndex++) {
19408
19508
  const cell = row.content[cellIndex];
19409
- if (!cell) continue;
19509
+ if (!cell) {
19510
+ console.log("no cell");
19511
+ continue;
19512
+ }
19410
19513
  const { attrs } = cell;
19411
19514
  if (attrs.rowspan > 1) {
19412
19515
  const rowsToChange = content.slice(rowIndex + 1, rowIndex + attrs.rowspan);
@@ -20141,7 +20244,7 @@ function getTranslationByAnnotationType(annotationType) {
20141
20244
  const translateFieldAttrsToMarks = (attrs = {}) => {
20142
20245
  const {
20143
20246
  fontFamily,
20144
- fontSize,
20247
+ fontSize: fontSize2,
20145
20248
  bold,
20146
20249
  underline,
20147
20250
  italic,
@@ -20150,7 +20253,7 @@ const translateFieldAttrsToMarks = (attrs = {}) => {
20150
20253
  } = attrs;
20151
20254
  const marks = [];
20152
20255
  if (fontFamily) marks.push({ type: "fontFamily", attrs: { fontFamily } });
20153
- if (fontSize) marks.push({ type: "fontSize", attrs: { fontSize } });
20256
+ if (fontSize2) marks.push({ type: "fontSize", attrs: { fontSize: fontSize2 } });
20154
20257
  if (bold) marks.push({ type: "bold", attrs: {} });
20155
20258
  if (underline) marks.push({ type: "underline", attrs: {} });
20156
20259
  if (italic) marks.push({ type: "italic", attrs: {} });
@@ -20371,24 +20474,26 @@ generateXml_fn = function(node2, debug = false) {
20371
20474
  if (!name && node2.type === "text") {
20372
20475
  return node2.text;
20373
20476
  }
20374
- if (name === "w:instrText") {
20375
- tags.push(elements[0].text);
20376
- } else if (name === "w:t" || name === "w:delText" || name === "wp:posOffset") {
20377
- const text = __privateMethod(this, _DocxExporter_instances, replaceSpecialCharacters_fn).call(this, elements[0].text);
20378
- tags.push(text);
20379
- } else {
20380
- if (elements) {
20381
- for (let child of elements) {
20382
- const newElements = __privateMethod(this, _DocxExporter_instances, generateXml_fn).call(this, child);
20383
- if (!newElements) continue;
20384
- if (typeof newElements === "string") {
20385
- tags.push(newElements);
20386
- continue;
20477
+ if (elements) {
20478
+ if (name === "w:instrText") {
20479
+ tags.push(elements[0].text);
20480
+ } else if (name === "w:t" || name === "w:delText" || name === "wp:posOffset") {
20481
+ const text = __privateMethod(this, _DocxExporter_instances, replaceSpecialCharacters_fn).call(this, elements[0].text);
20482
+ tags.push(text);
20483
+ } else {
20484
+ if (elements) {
20485
+ for (let child of elements) {
20486
+ const newElements = __privateMethod(this, _DocxExporter_instances, generateXml_fn).call(this, child);
20487
+ if (!newElements) continue;
20488
+ if (typeof newElements === "string") {
20489
+ tags.push(newElements);
20490
+ continue;
20491
+ }
20492
+ const removeUndefined = newElements.filter((el) => {
20493
+ return el !== "<undefined>" && el !== "</undefined>";
20494
+ });
20495
+ tags.push(...removeUndefined);
20387
20496
  }
20388
- const removeUndefined = newElements.filter((el) => {
20389
- return el !== "<undefined>" && el !== "</undefined>";
20390
- });
20391
- tags.push(...removeUndefined);
20392
20497
  }
20393
20498
  }
20394
20499
  }
@@ -20410,7 +20515,7 @@ function applyMarksToHtmlAnnotation(state2, marks) {
20410
20515
  return state2;
20411
20516
  }
20412
20517
  const fontFamily = marks.find((m) => m.type === "fontFamily");
20413
- const fontSize = marks.find((m) => m.type === "fontSize");
20518
+ const fontSize2 = marks.find((m) => m.type === "fontSize");
20414
20519
  const highlight = marks.find((m) => m.type === "highlight");
20415
20520
  const textStyleType = schema.marks.textStyle;
20416
20521
  const highlightType = schema.marks.highlight;
@@ -20421,17 +20526,17 @@ function applyMarksToHtmlAnnotation(state2, marks) {
20421
20526
  if (!foundTextStyle) {
20422
20527
  tr.addMark(pos, pos + node2.nodeSize, textStyleType.create({
20423
20528
  ...fontFamily?.attrs,
20424
- ...fontSize?.attrs
20529
+ ...fontSize2?.attrs
20425
20530
  }));
20426
20531
  } else if (!foundTextStyle?.attrs.fontFamily && fontFamily) {
20427
20532
  tr.addMark(pos, pos + node2.nodeSize, textStyleType.create({
20428
20533
  ...foundTextStyle?.attrs,
20429
20534
  ...fontFamily.attrs
20430
20535
  }));
20431
- } else if (!foundTextStyle?.attrs.fontSize && fontSize) {
20536
+ } else if (!foundTextStyle?.attrs.fontSize && fontSize2) {
20432
20537
  tr.addMark(pos, pos + node2.nodeSize, textStyleType.create({
20433
20538
  ...foundTextStyle?.attrs,
20434
- ...fontSize.attrs
20539
+ ...fontSize2.attrs
20435
20540
  }));
20436
20541
  }
20437
20542
  if (!foundHighlight) {
@@ -20458,6 +20563,81 @@ function translateStructuredContent(params) {
20458
20563
  elements: nodeElements
20459
20564
  };
20460
20565
  }
20566
+ const translatePageNumberNode = (params) => {
20567
+ const outputMarks = processOutputMarks(params.node.attrs?.marksAsAttrs || []);
20568
+ return getAutoPageJson("PAGE", outputMarks);
20569
+ };
20570
+ const translateTotalPageNumberNode = (params) => {
20571
+ const outputMarks = processOutputMarks(params.node.attrs?.marksAsAttrs || []);
20572
+ return getAutoPageJson("NUMPAGES", outputMarks);
20573
+ };
20574
+ const getAutoPageJson = (type2, outputMarks = []) => {
20575
+ return [
20576
+ {
20577
+ "name": "w:r",
20578
+ "elements": [
20579
+ {
20580
+ "name": "w:rPr",
20581
+ "elements": outputMarks
20582
+ },
20583
+ {
20584
+ "name": "w:fldChar",
20585
+ "attributes": {
20586
+ "w:fldCharType": "begin"
20587
+ }
20588
+ }
20589
+ ]
20590
+ },
20591
+ {
20592
+ "name": "w:r",
20593
+ "elements": [
20594
+ {
20595
+ "name": "w:rPr",
20596
+ "elements": outputMarks
20597
+ },
20598
+ {
20599
+ "name": "w:instrText",
20600
+ "elements": [
20601
+ {
20602
+ "type": "text",
20603
+ "text": ` ${type2}`
20604
+ }
20605
+ ]
20606
+ }
20607
+ ]
20608
+ },
20609
+ {
20610
+ "name": "w:r",
20611
+ "elements": [
20612
+ {
20613
+ "name": "w:rPr",
20614
+ "elements": outputMarks
20615
+ },
20616
+ {
20617
+ "name": "w:fldChar",
20618
+ "attributes": {
20619
+ "w:fldCharType": "separate"
20620
+ }
20621
+ }
20622
+ ]
20623
+ },
20624
+ {
20625
+ "name": "w:r",
20626
+ "elements": [
20627
+ {
20628
+ "name": "w:rPr",
20629
+ "elements": outputMarks
20630
+ },
20631
+ {
20632
+ "name": "w:fldChar",
20633
+ "attributes": {
20634
+ "w:fldCharType": "end"
20635
+ }
20636
+ }
20637
+ ]
20638
+ }
20639
+ ];
20640
+ };
20461
20641
  const defaultInitialXml = `<w:document xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" xmlns:cx="http://schemas.microsoft.com/office/drawing/2014/chartex" xmlns:cx1="http://schemas.microsoft.com/office/drawing/2015/9/8/chartex" xmlns:cx2="http://schemas.microsoft.com/office/drawing/2015/10/21/chartex" xmlns:cx3="http://schemas.microsoft.com/office/drawing/2016/5/9/chartex" xmlns:cx4="http://schemas.microsoft.com/office/drawing/2016/5/10/chartex" xmlns:cx5="http://schemas.microsoft.com/office/drawing/2016/5/11/chartex" xmlns:cx6="http://schemas.microsoft.com/office/drawing/2016/5/12/chartex" xmlns:cx7="http://schemas.microsoft.com/office/drawing/2016/5/13/chartex" xmlns:cx8="http://schemas.microsoft.com/office/drawing/2016/5/14/chartex" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:aink="http://schemas.microsoft.com/office/drawing/2016/ink" xmlns:am3d="http://schemas.microsoft.com/office/drawing/2017/model3d" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:oel="http://schemas.microsoft.com/office/2019/extlst" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml" xmlns:w16cex="http://schemas.microsoft.com/office/word/2018/wordml/cex" xmlns:w16cid="http://schemas.microsoft.com/office/word/2016/wordml/cid" xmlns:w16="http://schemas.microsoft.com/office/word/2018/wordml" xmlns:w16sdtdh="http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash" xmlns:w16se="http://schemas.microsoft.com/office/word/2015/wordml/symex" xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" mc:Ignorable="w14 w15 w16se w16cid w16 w16cex w16sdtdh wp14"><w:body></w:body></w:document>`;
20462
20642
  const parseXmlToJson = (xml) => {
20463
20643
  return JSON.parse(xmljs.xml2json(xml, null, 2));
@@ -20555,7 +20735,7 @@ function handleTableCellNode(node2, row, table, rowBorders, columnWidth = null,
20555
20735
  const attributes = {};
20556
20736
  const referencedStyles = getReferencedTableStyles(styleTag, docx) || {};
20557
20737
  attributes.cellMargins = getTableCellMargins(marginTag, referencedStyles);
20558
- const { fontSize, fonts = {} } = referencedStyles;
20738
+ const { fontSize: fontSize2, fonts = {} } = referencedStyles;
20559
20739
  const fontFamily = fonts["ascii"];
20560
20740
  if (width) {
20561
20741
  attributes["colwidth"] = [width];
@@ -20583,7 +20763,7 @@ function handleTableCellNode(node2, row, table, rowBorders, columnWidth = null,
20583
20763
  if (colspan) attributes["colspan"] = parseInt(colspan, 10);
20584
20764
  if (background) attributes["background"] = background;
20585
20765
  attributes["verticalAlign"] = verticalAlign;
20586
- if (fontSize) attributes["fontSize"] = fontSize;
20766
+ if (fontSize2) attributes["fontSize"] = fontSize2;
20587
20767
  if (fontFamily) attributes["fontFamily"] = fontFamily["ascii"];
20588
20768
  if (rowBorders) attributes["borders"] = { ...rowBorders };
20589
20769
  if (inlineBorders) attributes["borders"] = Object.assign(attributes["borders"] || {}, inlineBorders);
@@ -20681,8 +20861,8 @@ function getReferencedTableStyles(tblStyleTag, docx, nodeListHandler2) {
20681
20861
  const { "w:ascii": ascii, "w:hAnsi": hAnsi, "w:cs": cs } = fonts.attributes;
20682
20862
  stylesToReturn.fonts = { ascii, hAnsi, cs };
20683
20863
  }
20684
- const fontSize = rPr.elements.find((el) => el.name === "w:sz");
20685
- if (fontSize?.attributes) stylesToReturn.fontSize = halfPointToPoints(fontSize.attributes["w:val"]) + "pt";
20864
+ const fontSize2 = rPr.elements.find((el) => el.name === "w:sz");
20865
+ if (fontSize2?.attributes) stylesToReturn.fontSize = halfPointToPoints(fontSize2.attributes["w:val"]) + "pt";
20686
20866
  }
20687
20867
  const tblPr = styleTag.elements.find((el) => el.name === "w:tblPr");
20688
20868
  if (tblPr && tblPr.elements) {
@@ -21135,6 +21315,11 @@ function getElementName(element) {
21135
21315
  const isPropertiesElement = (element) => {
21136
21316
  return !!SuperConverter.propertyTypes[element.name || element.type];
21137
21317
  };
21318
+ function hasTextNode(elements) {
21319
+ const runs = elements.filter((el) => el.name === "w:r");
21320
+ const runsHaveText = runs.some((run) => run.elements.some((el) => el.name === "w:t"));
21321
+ return runsHaveText;
21322
+ }
21138
21323
  const handleTrackChangeNode = (params) => {
21139
21324
  const { nodes, nodeListHandler: nodeListHandler2 } = params;
21140
21325
  if (nodes.length === 0 || !(nodes[0].name === "w:del" || nodes[0].name === "w:ins" || nodes[0].name === "w:sdt")) {
@@ -21336,118 +21521,221 @@ const areAttrsEqual = (attrsA = {}, attrsB = {}) => {
21336
21521
  };
21337
21522
  const handleListNode = (params) => {
21338
21523
  const { nodes, lists, docx } = params;
21339
- if (nodes.length === 0 || nodes[0].name !== "w:p" || nodes[0].isList) {
21524
+ if (nodes.length === 0 || nodes[0].name !== "w:p") {
21340
21525
  return { nodes: [], consumed: 0 };
21341
21526
  }
21342
21527
  const node2 = carbonCopy(nodes[0]);
21343
- const isList = testForList(node2, docx);
21344
- if (isList) {
21345
- node2.isList = true;
21346
- const result = handleListNodes(params, node2);
21528
+ const processedElements = preProcessNodesForFldChar(node2.elements);
21529
+ node2.elements = processedElements;
21530
+ const originalPpr = node2.elements.find((el) => el.name === "w:pPr");
21531
+ if (testForList(node2, docx)) {
21532
+ const siblings = carbonCopy(nodes);
21533
+ const listItems = [];
21534
+ let possibleList = siblings.shift();
21535
+ while (possibleList && testForList(possibleList, docx)) {
21536
+ listItems.push(possibleList);
21537
+ possibleList = siblings.shift();
21538
+ if (possibleList?.elements && !hasTextNode(possibleList.elements)) {
21539
+ const { name } = possibleList;
21540
+ if (name === "w:tbl") continue;
21541
+ listItems.push(possibleList);
21542
+ possibleList = siblings.shift();
21543
+ }
21544
+ }
21545
+ const listNodes = handleListNodes({ listItems, params, originalPpr });
21347
21546
  return {
21348
- nodes: [result],
21349
- consumed: 1
21547
+ nodes: [listNodes],
21548
+ consumed: listItems.filter((i) => i.seen).length,
21549
+ lists
21350
21550
  };
21351
21551
  } else {
21352
- return { nodes: [], consumed: 0 };
21552
+ return { nodes: [], consumed: 0, lists };
21353
21553
  }
21354
21554
  };
21355
21555
  const listHandlerEntity = {
21356
21556
  handlerName: "listHandler",
21357
21557
  handler: handleListNode
21358
21558
  };
21359
- function handleListNodes(params, node2) {
21559
+ function handleListNodes({
21560
+ listItems,
21561
+ originalPpr,
21562
+ params,
21563
+ listLevel = 0,
21564
+ actualListLevel = 0,
21565
+ currentListNumId = null,
21566
+ path = "",
21567
+ isNested = false
21568
+ }) {
21360
21569
  const { docx, nodeListHandler: nodeListHandler2, lists } = params;
21361
- const initialpPr = node2.elements.find((el) => el.name === "w:pPr");
21570
+ const parsedListItems = [];
21571
+ let overallListType;
21572
+ let listStyleType;
21573
+ const handleStandardNode2 = nodeListHandler2.handlerEntities.find(
21574
+ (e) => e.handlerName === "standardNodeHandler"
21575
+ )?.handler;
21576
+ if (!handleStandardNode2) {
21577
+ console.error("Standard node handler not found");
21578
+ return { nodes: [], consumed: 0 };
21579
+ }
21580
+ const initialpPr = listItems[0].elements.find((el) => el.name === "w:pPr");
21362
21581
  const styleTag = initialpPr?.elements?.find((el) => el.name === "w:pStyle");
21363
21582
  const styleId = styleTag?.attributes["w:val"];
21364
- const { numPr: numPrTag, type: numPrType } = getNumPrRecursive({ node: node2, styleId, docx });
21365
- const currentListNumId = getNumIdFromTag(numPrTag);
21366
- const iLvlTag = numPrTag?.elements?.find((el) => el.name === "w:ilvl");
21367
- let iLvl = Number(iLvlTag?.attributes["w:val"]);
21368
- if (!iLvl && iLvl !== 0) iLvl = getOutlineLevelFromStyleTag(styleId, docx);
21369
- const {
21370
- listType,
21371
- listOrderingType,
21372
- listrPrs,
21373
- listpPrs,
21374
- start,
21375
- lvlText,
21376
- lvlJc
21377
- } = getNodeNumberingDefinition(node2, iLvl, docx);
21378
- if (!listType) {
21379
- const pPrIndex = node2.elements.findIndex((el) => el.name === "w:pPr");
21380
- const pPr = node2.elements[pPrIndex];
21381
- const numPrIndex2 = pPr?.elements?.findIndex((el) => el.name === "w:numPr");
21382
- if (numPrIndex2 >= 0) {
21383
- pPr?.elements?.splice(numPrIndex2, 1);
21384
- node2.elements[pPrIndex] = pPr;
21385
- }
21386
- const styleIdIndex = pPr?.elements?.findIndex((el) => el.name === "w:pStyle");
21387
- if (styleIdIndex >= 0) pPr?.elements?.splice(styleIdIndex, 1);
21388
- const fallBack = nodeListHandler2.handler({ ...params, nodes: [node2] })?.filter((n) => n);
21389
- return fallBack[0];
21390
- }
21391
- if (!lists[currentListNumId]) lists[currentListNumId] = { levels: {} };
21392
- const currentListByNumId = lists[currentListNumId];
21393
- if (!currentListByNumId.levels[iLvl]) currentListByNumId.levels[iLvl] = Number(start) || 1;
21394
- else currentListByNumId.levels[iLvl]++;
21395
- Object.keys(currentListByNumId.levels).forEach((key) => {
21396
- const level = Number(key);
21397
- if (level > iLvl) {
21398
- delete currentListByNumId.levels[level];
21399
- }
21400
- });
21401
- const path = [];
21402
- if (iLvl > 0) {
21403
- for (let i = iLvl; i >= 0; i--) {
21404
- const { start: lvlStart } = getNodeNumberingDefinition(node2, i, docx);
21405
- if (!currentListByNumId.levels[i]) {
21406
- currentListByNumId.levels[i] = Number(lvlStart);
21583
+ const numPrTag = getNumPrRecursive({ node: listItems[0], styleId, docx });
21584
+ currentListNumId = getNumIdFromTag(numPrTag);
21585
+ actualListLevel = parseInt(numPrTag?.elements?.find((el) => el.name === "w:ilvl")?.attributes["w:val"]) || 0;
21586
+ if (actualListLevel === void 0) actualListLevel = getOutlineLevelFromStyleTag(styleId, docx);
21587
+ let lastNestedListLevel = 0;
21588
+ for (let [index, item] of listItems.entries()) {
21589
+ if (item.seen) continue;
21590
+ const { attributes, elements, marks = [] } = parseProperties(item);
21591
+ const matchedStyle = getStyleTagFromStyleId(styleId, docx) || {};
21592
+ const { marks: styleIdMarks } = parseProperties(matchedStyle);
21593
+ const textStyle = marks.find((mark) => mark.type === "textStyle");
21594
+ const textStyleFromStyles = styleIdMarks?.find((mark) => mark.type === "textStyle");
21595
+ const {
21596
+ listType,
21597
+ listOrderingType,
21598
+ ilvl,
21599
+ listrPrs,
21600
+ listpPrs,
21601
+ start,
21602
+ lvlText,
21603
+ lvlJc,
21604
+ numId
21605
+ } = getNodeNumberingDefinition(item, listLevel, docx);
21606
+ listStyleType = listOrderingType;
21607
+ const intLevel = parseInt(ilvl);
21608
+ const isRoot = actualListLevel === intLevel && numId === currentListNumId;
21609
+ const isSameListLevelDef = isSameListLevelDefsExceptStart({
21610
+ firstListId: numId,
21611
+ secondListId: currentListNumId,
21612
+ level: intLevel,
21613
+ pStyleId: null,
21614
+ docx
21615
+ });
21616
+ const isDifferentList = numId !== currentListNumId && !isSameListLevelDef;
21617
+ const isNested2 = listLevel < intLevel || listLevel === intLevel && isDifferentList && lastNestedListLevel === listLevel;
21618
+ if (!lists[currentListNumId]) lists[currentListNumId] = {};
21619
+ if (!lists[currentListNumId][listLevel]) {
21620
+ lists[currentListNumId][listLevel] = Number(start);
21621
+ }
21622
+ const nodeAttributes = {};
21623
+ if (isRoot && !isNested2) {
21624
+ overallListType = listType;
21625
+ item.seen = true;
21626
+ const schemaElements = [];
21627
+ const nodeContents = nodeListHandler2.handler({ ...params, nodes: [attributes.paragraphProperties, ...elements] })?.filter((n) => n) || [];
21628
+ let parNode = {
21629
+ type: "paragraph",
21630
+ content: nodeContents
21631
+ };
21632
+ if (parNode.content) {
21633
+ parNode = {
21634
+ ...parNode,
21635
+ attrs: {
21636
+ textAlign: textStyle?.attrs.textAlign || textStyleFromStyles?.attrs.textAlign || null,
21637
+ rsidRDefault: attributes?.["w:rsidRDefault"] || null,
21638
+ styleId
21639
+ },
21640
+ content: mergeTextNodes(parNode.content)
21641
+ };
21642
+ }
21643
+ schemaElements.push(parNode);
21644
+ lastNestedListLevel = listLevel;
21645
+ let thisItemPath = [];
21646
+ if (listStyleType !== "bullet") {
21647
+ thisItemPath = [...path, lists[currentListNumId][listLevel]];
21648
+ lists[currentListNumId][actualListLevel]++;
21649
+ }
21650
+ if (!path.length && actualListLevel > 0) {
21651
+ const currentDef = lists[currentListNumId];
21652
+ if (currentDef) {
21653
+ const newPath = [];
21654
+ Object.keys(currentDef).forEach((key) => {
21655
+ newPath.push(currentDef[key]);
21656
+ });
21657
+ thisItemPath = newPath;
21658
+ }
21659
+ }
21660
+ const pPr = item.elements.find((el) => el.name === "w:pPr");
21661
+ let indent = pPr?.elements.find((el) => el.name === "w:ind");
21662
+ const pPrFromStyles = matchedStyle?.elements?.find((style) => style.name === "w:pPr");
21663
+ const stylesIndent = pPrFromStyles?.elements?.find((el) => el.name === "w:ind");
21664
+ if (!indent) indent = stylesIndent;
21665
+ if (indent) {
21666
+ const indentAttrs = {};
21667
+ if (!indent.attributes) indent.attributes = {};
21668
+ if (indent.attributes["w:left"] !== void 0) indentAttrs.left = twipsToPixels(indent.attributes["w:left"]);
21669
+ if (indent.attributes["w:right"] !== void 0) indentAttrs.right = twipsToPixels(indent.attributes["w:right"]);
21670
+ if (indent.attributes["w:firstLine"] !== void 0) indentAttrs.firstLine = twipsToPixels(indent.attributes["w:firstLine"]);
21671
+ if (indent.attributes["w:hanging"] !== void 0) indentAttrs.hanging = twipsToPixels(indent.attributes["w:hanging"]);
21672
+ nodeAttributes["indent"] = indentAttrs;
21673
+ }
21674
+ if (listpPrs) nodeAttributes["listParagraphProperties"] = listpPrs;
21675
+ if (listrPrs) nodeAttributes["listRunProperties"] = listrPrs;
21676
+ nodeAttributes["textStyle"] = textStyle;
21677
+ nodeAttributes["order"] = start;
21678
+ nodeAttributes["lvlText"] = lvlText;
21679
+ nodeAttributes["lvlJc"] = textStyle?.attrs.textAlign;
21680
+ nodeAttributes["listLevel"] = thisItemPath;
21681
+ nodeAttributes["listNumberingType"] = listOrderingType;
21682
+ nodeAttributes["attributes"] = {
21683
+ parentAttributes: item?.attributes || null
21684
+ };
21685
+ const originalRunProps = originalPpr?.elements?.find((el) => el.name === "w:rPr");
21686
+ if (originalRunProps) {
21687
+ nodeAttributes.attributes["originalInlineRunProps"] = originalRunProps;
21688
+ }
21689
+ nodeAttributes["numId"] = numId;
21690
+ if (docx) {
21691
+ nodeAttributes["spacing"] = getParagraphSpacing(item, docx, styleId);
21692
+ }
21693
+ const newListItem = createListItem(schemaElements, nodeAttributes, []);
21694
+ parsedListItems.push(newListItem);
21695
+ } else if (isNested2) {
21696
+ const newPath = [...path, lists[currentListNumId][listLevel]];
21697
+ const sublist = handleListNodes({
21698
+ listItems: listItems.slice(index),
21699
+ originalPpr,
21700
+ params,
21701
+ listLevel: listLevel + 1,
21702
+ actualListLevel: listLevel,
21703
+ currentListNumId: numId,
21704
+ path: newPath,
21705
+ isNested: true
21706
+ });
21707
+ lastNestedListLevel = sublist.lastNestedListLevel;
21708
+ delete sublist.lastNestedListLevel;
21709
+ const lastItem = parsedListItems[parsedListItems.length - 1];
21710
+ if (!lastItem) {
21711
+ parsedListItems.push(createListItem([sublist], nodeAttributes, []));
21712
+ } else {
21713
+ lastItem.content.push(sublist);
21407
21714
  }
21408
- path.unshift(currentListByNumId.levels[i]);
21715
+ } else if (!numId) {
21716
+ item.seen = true;
21717
+ const n = handleStandardNode2({ ...params, nodes: [item] }).nodes[0];
21718
+ parsedListItems[parsedListItems.length - 1]?.content.push(n);
21719
+ } else {
21720
+ lastNestedListLevel = listLevel;
21721
+ if (listLevel > 0 && item.elements[0].elements.find((el) => el.name === "w:numPr")) {
21722
+ lists[currentListNumId][listLevel] = 0;
21723
+ }
21724
+ break;
21409
21725
  }
21410
21726
  }
21411
- if (!path.length) path.push(currentListByNumId.levels[iLvl]);
21412
- const attrs = {};
21413
- attrs.lvlText = lvlText;
21414
- attrs.listLevel = path;
21415
- attrs.listNumberingType = listOrderingType;
21416
- attrs.numId = currentListNumId;
21417
- attrs.level = iLvl;
21418
- attrs.numPrType = numPrType;
21419
- attrs.styleId = styleId;
21420
- node2.isList = true;
21421
- const nodePpr = node2.attrs?.paragraphProperties?.elements?.find((el) => el.name === "w:pPr");
21422
- const numPrIndex = node2.attrs?.paragraphProperties?.elements?.findIndex((el) => el.name === "w:numPr");
21423
- nodePpr?.elements?.splice(numPrIndex, 1);
21424
- const listContents = nodeListHandler2.handler({ ...params, nodes: [node2] });
21425
- const innerParagraph = listContents.find((el) => el.type === "paragraph");
21426
- const firstElement = innerParagraph.content[0];
21427
- firstElement?.marks?.find((mark) => mark.type === "textStyle");
21428
- attrs.indent = listpPrs?.indent;
21429
- const processedContents = listContents.map((el, index) => {
21430
- const { attrs: elementAttrs } = el;
21431
- const { indent, textIndent, paragraphProperties, ...rest } = elementAttrs;
21432
- if (index === 0 && !attrs.indent) attrs.indent = indent;
21433
- return {
21434
- ...el,
21435
- attrs: rest
21436
- };
21437
- });
21438
- const listItem = {
21439
- type: "listItem",
21440
- content: processedContents || [],
21441
- attrs
21442
- };
21443
21727
  const resultingList = {
21444
- type: listType,
21445
- content: [listItem],
21728
+ type: overallListType || "bulletList",
21729
+ content: parsedListItems,
21446
21730
  attrs: {
21447
- "list-style-type": listOrderingType,
21448
- listId: currentListNumId
21731
+ "list-style-type": listStyleType,
21732
+ listId: currentListNumId,
21733
+ attributes: {
21734
+ parentAttributes: listItems[0]?.attributes || null
21735
+ }
21449
21736
  }
21450
21737
  };
21738
+ if (isNested) resultingList.lastNestedListLevel = lastNestedListLevel;
21451
21739
  return resultingList;
21452
21740
  }
21453
21741
  const getOutlineLevelFromStyleTag = (styleTag, docx) => {
@@ -21466,27 +21754,11 @@ function testForList(node2, docx) {
21466
21754
  const paragraphStyle = pPr.elements?.find((el) => el.name === "w:pStyle");
21467
21755
  let numPr = pPr.elements?.find((el) => el.name === "w:numPr");
21468
21756
  let numId = getNumIdFromTag(numPr);
21469
- const ilvlTag = numPr?.elements?.find((el) => el.name === "w:ilvl");
21470
- let ilvl = ilvlTag?.attributes["w:val"];
21471
- let outlinelvl;
21472
21757
  const styleId = paragraphStyle?.attributes["w:val"];
21473
- const styleTag = getStyleTagFromStyleId(styleId, docx);
21474
- if (styleTag && !numId) {
21475
- const { numPr: numPrRecursve, type: type2 } = getNumPrRecursive({ node: node2, styleId, docx });
21476
- numPr = numPrRecursve;
21758
+ if (styleId && !numId) {
21759
+ numPr = getNumPrRecursive({ node: node2, styleId, docx });
21477
21760
  numId = getNumIdFromTag(numPr);
21478
- const stylePpr = styleTag?.elements?.find((el) => el.name === "w:pPr");
21479
- stylePpr?.elements?.find((el) => el.name === "w:numPr");
21480
- ilvl = stylePpr?.elements?.find((el) => el.name === "w:ilvl")?.attributes["w:val"];
21481
- outlinelvl = stylePpr?.elements?.find((el) => el.name === "w:outlineLvl")?.attributes["w:val"];
21482
- ilvl = outlinelvl || ilvl;
21483
- }
21484
- const numbering = docx["word/numbering.xml"] || {};
21485
- const numDefinition = numbering?.elements?.[0].elements?.find((el) => el.attributes?.["w:numId"] == numId);
21486
- const abstractNumId = numDefinition?.elements?.find((el) => el.name === "w:abstractNumId")?.attributes["w:val"];
21487
- const abstractNumDefinition = numbering?.elements?.[0].elements?.find((el) => el.attributes?.["w:abstractNumId"] == abstractNumId);
21488
- const levelDefinition = abstractNumDefinition?.elements?.find((el) => el.name === "w:lvl" && el.attributes?.["w:ilvl"] == ilvl);
21489
- if (!levelDefinition) return false;
21761
+ }
21490
21762
  return !!numId;
21491
21763
  }
21492
21764
  const getNumIdFromTag = (tag) => {
@@ -21494,19 +21766,20 @@ const getNumIdFromTag = (tag) => {
21494
21766
  };
21495
21767
  function getStyleTagFromStyleId(styleId, docx) {
21496
21768
  const styles = docx["word/styles.xml"];
21497
- if (!styles) return {};
21769
+ if (!styles) {
21770
+ return {};
21771
+ }
21498
21772
  const styleEls = styles.elements;
21499
21773
  const wStyles = styleEls.find((el) => el.name === "w:styles");
21500
21774
  const styleTags = wStyles.elements.filter((style) => style.name === "w:style");
21501
- const styleDef = styleTags.find((tag) => tag.attributes["w:styleId"] === styleId);
21502
- return styleDef;
21775
+ return styleTags.find((tag) => tag.attributes["w:styleId"] === styleId);
21503
21776
  }
21504
21777
  function getNumPrRecursive({ node: node2, styleId, docx, seenStyleIds = /* @__PURE__ */ new Set() }) {
21505
21778
  const initialPpr = node2?.elements?.find((el) => el.name === "w:pPr");
21506
21779
  const initialNumPr = initialPpr?.elements?.find((el) => el.name === "w:numPr");
21507
21780
  let numPr = initialNumPr;
21508
21781
  let numId = getNumIdFromTag(numPr);
21509
- if (numId) return { numPr, type: "inline" };
21782
+ if (numId) return numPr;
21510
21783
  const matchedStyle = getStyleTagFromStyleId(styleId, docx);
21511
21784
  const pPr = matchedStyle?.elements?.find((style) => style.name === "w:pPr");
21512
21785
  numPr = pPr?.elements?.find((style) => style.name === "w:numPr");
@@ -21515,10 +21788,18 @@ function getNumPrRecursive({ node: node2, styleId, docx, seenStyleIds = /* @__PU
21515
21788
  if (!numId && !seenStyleIds.has(styleId)) {
21516
21789
  const basedOnStyleId = basedOn?.attributes["w:val"];
21517
21790
  seenStyleIds.add(styleId);
21518
- if (!basedOnStyleId) return {};
21791
+ if (!basedOnStyleId) return null;
21519
21792
  return getNumPrRecursive({ styleId: basedOnStyleId, docx, seenStyleIds });
21520
21793
  }
21521
- return { numPr, type: "numbering" };
21794
+ return numPr;
21795
+ }
21796
+ function createListItem(content, attrs, marks) {
21797
+ return {
21798
+ type: "listItem",
21799
+ content,
21800
+ attrs,
21801
+ marks
21802
+ };
21522
21803
  }
21523
21804
  const orderedListTypes = [
21524
21805
  "decimal",
@@ -21556,6 +21837,18 @@ const unorderedListTypes = [
21556
21837
  "disc"
21557
21838
  // Disc bullets (●)
21558
21839
  ];
21840
+ const isSameListLevelDefsExceptStart = ({ firstListId, secondListId, level, pStyleId, docx }) => {
21841
+ const { numFmt, lvlText, lvlJc } = getListLevelDefinitionTag(firstListId, level, pStyleId, docx);
21842
+ const {
21843
+ numFmt: numFmt2,
21844
+ lvlText: lvlText2,
21845
+ lvlJc: lvlJc2
21846
+ } = getListLevelDefinitionTag(secondListId, level, pStyleId, docx);
21847
+ const sameNumFmt = numFmt === numFmt2;
21848
+ const sameLvlText = lvlText === lvlText2;
21849
+ const sameLvlJc = lvlJc === lvlJc2;
21850
+ return sameNumFmt && sameLvlText && sameLvlJc;
21851
+ };
21559
21852
  const getListNumIdFromStyleRef = (styleId, docx) => {
21560
21853
  const styles = docx["word/styles.xml"];
21561
21854
  if (!styles) return null;
@@ -21587,28 +21880,24 @@ const getListNumIdFromStyleRef = (styleId, docx) => {
21587
21880
  }
21588
21881
  return { numId, ilvl };
21589
21882
  };
21590
- const getAbstractDefinition = (numId, docx) => {
21883
+ const getListLevelDefinitionTag = (numId, level, pStyleId, docx) => {
21591
21884
  const def = docx["word/numbering.xml"];
21592
21885
  if (!def) return {};
21593
21886
  const { elements } = def;
21594
21887
  const listData = elements[0];
21888
+ if (pStyleId) {
21889
+ const { numId: numIdFromStyles, ilvl: iLvlFromStyles } = getListNumIdFromStyleRef(pStyleId, docx) || {};
21890
+ if (!numId && numIdFromStyles) numId = numIdFromStyles;
21891
+ if (!level && iLvlFromStyles) level = iLvlFromStyles ? parseInt(iLvlFromStyles) : null;
21892
+ }
21595
21893
  const numberingElements = listData.elements;
21596
21894
  const abstractDefinitions = numberingElements.filter((style) => style.name === "w:abstractNum");
21597
21895
  const numDefinitions = numberingElements.filter((style) => style.name === "w:num");
21598
- const numDefinition = numDefinitions.find((style) => style.attributes["w:numId"] == numId);
21896
+ const numDefinition = numDefinitions.find((style) => style.attributes["w:numId"] === numId);
21599
21897
  const abstractNumId = numDefinition?.elements[0].attributes["w:val"];
21600
21898
  const listDefinitionForThisNumId = abstractDefinitions?.find(
21601
21899
  (style) => style.attributes["w:abstractNumId"] === abstractNumId
21602
21900
  );
21603
- return listDefinitionForThisNumId;
21604
- };
21605
- const getListLevelDefinitionTag = (numId, level, pStyleId, docx) => {
21606
- if (pStyleId) {
21607
- const { numId: numIdFromStyles, ilvl: iLvlFromStyles } = getListNumIdFromStyleRef(pStyleId, docx) || {};
21608
- if (!numId && numIdFromStyles) numId = numIdFromStyles;
21609
- if (!level && iLvlFromStyles) level = iLvlFromStyles ? parseInt(iLvlFromStyles) : null;
21610
- }
21611
- const listDefinitionForThisNumId = getAbstractDefinition(numId, docx);
21612
21901
  const currentLevel = getDefinitionForLevel(listDefinitionForThisNumId, level);
21613
21902
  const numStyleLink = listDefinitionForThisNumId?.elements?.find((style) => style.name === "w:numStyleLink");
21614
21903
  const numStyleLinkId = numStyleLink?.attributes["w:val"];
@@ -21617,15 +21906,7 @@ const getListLevelDefinitionTag = (numId, level, pStyleId, docx) => {
21617
21906
  return getListLevelDefinitionTag(current.numId, level, null, docx);
21618
21907
  }
21619
21908
  const start = currentLevel?.elements?.find((style) => style.name === "w:start")?.attributes["w:val"];
21620
- let numFmt = currentLevel?.elements?.find((style) => style.name === "w:numFmt")?.attributes["w:val"];
21621
- if (!numFmt) {
21622
- const altChoice = currentLevel?.elements.find((style) => style.name === "mc:AlternateContent");
21623
- const choice = altChoice?.elements.find((style) => style.name === "mc:Choice");
21624
- const choiceNumFmt = choice?.elements.find((style) => style.name === "w:numFmt")?.attributes["w:val"];
21625
- if (choiceNumFmt) {
21626
- numFmt = choiceNumFmt;
21627
- }
21628
- }
21909
+ const numFmt = currentLevel?.elements?.find((style) => style.name === "w:numFmt")?.attributes["w:val"];
21629
21910
  const lvlText = currentLevel?.elements?.find((style) => style.name === "w:lvlText").attributes["w:val"];
21630
21911
  const lvlJc = currentLevel?.elements?.find((style) => style.name === "w:lvlJc").attributes["w:val"];
21631
21912
  const pPr = currentLevel?.elements?.find((style) => style.name === "w:pPr");
@@ -21640,10 +21921,12 @@ function getNodeNumberingDefinition(item, level, docx) {
21640
21921
  const initialPpr = item.elements.find((el) => el.name === "w:pPr");
21641
21922
  const styleTag = initialPpr?.elements?.find((el) => el.name === "w:pStyle");
21642
21923
  const styleId = styleTag?.attributes["w:val"];
21643
- const { numPr: numPrTag, type: type2 } = getNumPrRecursive({ node: item, styleId, docx });
21924
+ const numPrTag = getNumPrRecursive({ node: item, styleId, docx });
21644
21925
  if (!numPrTag) return {};
21645
21926
  const numIdTag = numPrTag?.elements.find((style) => style.name === "w:numId");
21646
21927
  const numId = numIdTag?.attributes["w:val"];
21928
+ const ilvlTag = numPrTag?.elements.find((style) => style.name === "w:ilvl");
21929
+ const ilvl = ilvlTag?.attributes["w:val"] || getOutlineLevelFromStyleTag(styleId, docx);
21647
21930
  const pStyle = listStyles.find((style) => style.name === "w:pStyle");
21648
21931
  const pStyleId = pStyle?.attributes["w:val"];
21649
21932
  const {
@@ -21655,84 +21938,29 @@ function getNodeNumberingDefinition(item, level, docx) {
21655
21938
  rPr
21656
21939
  } = getListLevelDefinitionTag(numId, level, pStyleId, docx);
21657
21940
  let listpPrs, listrPrs;
21658
- if (pPr) listpPrs = _processListParagraphProperties(pPr, initialPpr);
21941
+ if (pPr) listpPrs = _processListParagraphProperties(pPr);
21659
21942
  if (rPr) listrPrs = _processListRunProperties(rPr);
21660
21943
  let listType;
21661
21944
  if (unorderedListTypes.includes(listTypeDef?.toLowerCase())) listType = "bulletList";
21662
21945
  else if (orderedListTypes.includes(listTypeDef)) listType = "orderedList";
21663
- else if (listTypeDef === "custom") {
21664
- listType = "orderedList";
21665
- } else {
21666
- return {};
21667
- }
21668
- return { listType, listOrderingType: listTypeDef, listrPrs, listpPrs, start, lvlText, lvlJc };
21946
+ else return {};
21947
+ return { listType, listOrderingType: listTypeDef, ilvl, numId, listrPrs, listpPrs, start, lvlText, lvlJc };
21669
21948
  }
21670
21949
  function getDefinitionForLevel(data, level) {
21671
21950
  return data?.elements?.find((item) => Number(item.attributes["w:ilvl"]) === level);
21672
21951
  }
21673
- function parseIndentElement(indElem) {
21674
- if (!indElem || !indElem.attributes) return {};
21675
- const out = {};
21676
- if (indElem.attributes["w:left"] != null) out.left = twipsToPixels(indElem.attributes["w:left"]);
21677
- if (indElem.attributes["w:right"] != null) out.right = twipsToPixels(indElem.attributes["w:right"]);
21678
- if (indElem.attributes["w:firstLine"] != null) out.firstLine = twipsToPixels(indElem.attributes["w:firstLine"]);
21679
- if (indElem.attributes["w:hanging"] != null) out.hanging = twipsToPixels(indElem.attributes["w:hanging"]);
21680
- if (indElem.attributes["w:leftChars"] != null) out.leftChars = twipsToPixels(indElem.attributes["w:leftChars"]);
21681
- return out;
21682
- }
21683
- function combineIndents(ind1, ind2) {
21684
- ind1 = ind1 && typeof ind1 === "object" ? ind1 : {};
21685
- ind2 = ind2 && typeof ind2 === "object" ? ind2 : {};
21686
- const indent = {};
21687
- ["left", "right", "firstLine", "hanging"].forEach((prop) => {
21688
- const v1 = ind1[prop] !== void 0 ? Number(ind1[prop]) : null;
21689
- const v2 = ind2[prop] !== void 0 ? Number(ind2[prop]) : null;
21690
- if (v1 != null && v2 != null) {
21691
- indent[prop] = prop === "left" || prop === "hanging" ? Math.max(v1, v2) : v1;
21692
- } else if (v1 != null) {
21693
- indent[prop] = v1;
21694
- } else if (v2 != null) {
21695
- indent[prop] = v2;
21696
- }
21697
- });
21698
- return indent;
21699
- }
21700
- function _processListParagraphProperties(data, inlinePpr) {
21952
+ function _processListParagraphProperties(data) {
21701
21953
  const { elements } = data;
21702
21954
  const expectedTypes = ["w:ind", "w:jc", "w:tabs"];
21703
21955
  const paragraphProperties = {};
21704
21956
  if (!elements) return paragraphProperties;
21705
21957
  elements.forEach((item) => {
21706
- if (!expectedTypes.includes(item.name)) {
21707
- console.warn(`[numbering.xml] Unexpected list paragraph prop found: ${item.name}`);
21708
- }
21709
- });
21710
- const inlineIndent = inlinePpr?.elements?.find((item) => item.name === "w:ind");
21711
- const parsedInlineIndent = parseIndentElement(inlineIndent);
21712
- const styleIndent = elements.find((item) => item.name === "w:ind");
21713
- parseIndentElement(styleIndent);
21714
- paragraphProperties.indent = parsedInlineIndent;
21715
- const justify = elements.find((item) => item.name === "w:jc");
21716
- if (justify) {
21717
- const justifyAttrs = {};
21718
- if (!justify.attributes) justify.attributes = {};
21719
- if (justify.attributes["w:val"] !== void 0) justifyAttrs.val = justify.attributes["w:val"];
21720
- paragraphProperties.justify = justifyAttrs;
21721
- }
21722
- const tabs = elements.find((item) => item.name === "w:tabs");
21723
- if (tabs) {
21724
- const tabElements = tabs.elements.filter((item) => item.name === "w:tab");
21725
- const tabStops = [];
21726
- tabElements.forEach((tab) => {
21727
- const tabStop = {};
21728
- if (!tab.attributes) tab.attributes = {};
21729
- if (tab.attributes["w:val"] !== void 0) tabStop.val = tab.attributes["w:val"];
21730
- if (tab.attributes["w:leader"] !== void 0) tabStop.leader = tab.attributes["w:leader"];
21731
- if (tab.attributes["w:pos"] !== void 0) tabStop.pos = twipsToPixels(tab.attributes["w:pos"]);
21732
- tabStops.push(tabStop);
21958
+ if (!expectedTypes.includes(item.name)) ;
21959
+ const { attributes = {} } = item;
21960
+ Object.keys(attributes).forEach((key) => {
21961
+ paragraphProperties[key] = attributes[key];
21733
21962
  });
21734
- paragraphProperties.tabStops = tabStops;
21735
- }
21963
+ });
21736
21964
  return paragraphProperties;
21737
21965
  }
21738
21966
  function _processListRunProperties(data) {
@@ -21779,6 +22007,9 @@ const handleParagraphNode = (params) => {
21779
22007
  let schemaNode;
21780
22008
  let processedElements = preProcessNodesForFldChar(node2.elements);
21781
22009
  node2.elements = processedElements;
22010
+ if (testForList(node2, docx)) {
22011
+ return { nodes: [], consumed: 0 };
22012
+ }
21782
22013
  const handleStandardNode2 = nodeListHandler2.handlerEntities.find(
21783
22014
  (e) => e.handlerName === "standardNodeHandler"
21784
22015
  )?.handler;
@@ -21848,14 +22079,6 @@ const handleParagraphNode = (params) => {
21848
22079
  schemaNode.attrs["spacing"] = getParagraphSpacing(node2, docx, styleId, schemaNode.attrs.marksAttrs);
21849
22080
  schemaNode.attrs["rsidRDefault"] = defaultStyleId;
21850
22081
  }
21851
- if (docx) {
21852
- const { justify: justify2 } = getDefaultParagraphStyle(docx, styleId);
21853
- if (justify2) {
21854
- schemaNode.attrs.justify = {
21855
- val: justify2["w:val"]
21856
- };
21857
- }
21858
- }
21859
22082
  if (framePr && framePr.attributes["w:dropCap"]) {
21860
22083
  schemaNode.attrs.dropcap = {
21861
22084
  type: framePr.attributes["w:dropCap"],
@@ -21878,7 +22101,6 @@ const handleParagraphNode = (params) => {
21878
22101
  schemaNode.attrs.paragraphProperties.sectPr = sectPr;
21879
22102
  schemaNode.attrs.pageBreakSource = "sectPr";
21880
22103
  }
21881
- console.debug("paragraphNodeHandler", schemaNode);
21882
22104
  return { nodes: schemaNode ? [schemaNode] : [], consumed: 1 };
21883
22105
  };
21884
22106
  const getParagraphIndent = (node2, docx, styleId = "") => {
@@ -21928,7 +22150,7 @@ const getParagraphSpacing = (node2, docx, styleId = "", marks = []) => {
21928
22150
  const inLineSpacingTag = pPr?.elements?.find((el) => el.name === "w:spacing");
21929
22151
  const inLineSpacing = inLineSpacingTag?.attributes || {};
21930
22152
  const textStyleMark = marks.find((el) => el.type === "textStyle");
21931
- const fontSize = textStyleMark?.attrs?.fontSize;
22153
+ const fontSize2 = textStyleMark?.attrs?.fontSize;
21932
22154
  const lineSpacing = inLineSpacing?.["w:line"] || line || pDefaultSpacing?.["w:line"];
21933
22155
  if (lineSpacing) spacing.line = twipsToLines(lineSpacing);
21934
22156
  const lineRule = inLineSpacing?.["w:lineRule"] || lineRuleStyle || pDefaultSpacing?.["w:lineRule"];
@@ -21939,14 +22161,14 @@ const getParagraphSpacing = (node2, docx, styleId = "", marks = []) => {
21939
22161
  const beforeSpacing = inLineSpacing?.["w:before"] || lineSpaceBefore || pDefaultSpacing?.["w:before"];
21940
22162
  if (beforeSpacing) spacing.lineSpaceBefore = twipsToPixels(beforeSpacing);
21941
22163
  const beforeAutospacing = inLineSpacing?.["w:beforeAutospacing"];
21942
- if (beforeAutospacing === "1" && fontSize) {
21943
- spacing.lineSpaceBefore += Math.round(parseInt(fontSize) * 0.5 * 96 / 72);
22164
+ if (beforeAutospacing === "1" && fontSize2) {
22165
+ spacing.lineSpaceBefore += Math.round(parseInt(fontSize2) * 0.5 * 96 / 72);
21944
22166
  }
21945
22167
  const afterSpacing = inLineSpacing?.["w:after"] || lineSpaceAfter || pDefaultSpacing?.["w:after"];
21946
22168
  if (afterSpacing) spacing.lineSpaceAfter = twipsToPixels(afterSpacing);
21947
22169
  const afterAutospacing = inLineSpacing?.["w:afterAutospacing"];
21948
- if (afterAutospacing === "1" && fontSize) {
21949
- spacing.lineSpaceAfter += Math.round(parseInt(fontSize) * 0.5 * 96 / 72);
22170
+ if (afterAutospacing === "1" && fontSize2) {
22171
+ spacing.lineSpaceAfter += Math.round(parseInt(fontSize2) * 0.5 * 96 / 72);
21950
22172
  }
21951
22173
  return spacing;
21952
22174
  };
@@ -22126,15 +22348,25 @@ const processCombinedNodesForFldChar = (nodesToCombine = []) => {
22126
22348
  if (!isNumPages) isNumPages = instrText?.trim().startsWith("NUMPAGES");
22127
22349
  const urlMatch = instrText?.match(/HYPERLINK\s+"([^"]+)"/);
22128
22350
  if (hasPageMarker) {
22129
- processedNodes.push({
22351
+ const pageNumNode = {
22130
22352
  name: "sd:autoPageNumber",
22131
22353
  type: "element"
22354
+ };
22355
+ nodesToCombine.forEach((n) => {
22356
+ const rPrNode = n.elements.find((el) => el.name === "w:rPr");
22357
+ if (rPrNode) pageNumNode.elements = [rPrNode];
22132
22358
  });
22359
+ processedNodes.push(pageNumNode);
22133
22360
  } else if (isNumPages) {
22134
- processedNodes.push({
22361
+ const totalPageNumNode = {
22135
22362
  name: "sd:totalPageNumber",
22136
22363
  type: "element"
22364
+ };
22365
+ nodesToCombine.forEach((n) => {
22366
+ const rPrNode = n.elements.find((el) => el.name === "w:rPr");
22367
+ if (rPrNode) totalPageNumNode.elements = [rPrNode];
22137
22368
  });
22369
+ processedNodes.push(totalPageNumNode);
22138
22370
  } else if (urlMatch && urlMatch?.length >= 2) {
22139
22371
  const url = urlMatch[1];
22140
22372
  const textMarks = [];
@@ -22206,7 +22438,7 @@ const handleAnnotationNode = (params) => {
22206
22438
  const fieldColor = sdtPr?.elements.find((el) => el.name === "w:fieldColor")?.attributes["w:val"];
22207
22439
  const isMultipleImage = sdtPr?.elements.find((el) => el.name === "w:fieldMultipleImage")?.attributes["w:val"];
22208
22440
  const fontFamily = sdtPr?.elements.find((el) => el.name === "w:fieldFontFamily")?.attributes["w:val"];
22209
- const fontSize = sdtPr?.elements.find((el) => el.name === "w:fieldFontSize")?.attributes["w:val"];
22441
+ const fontSize2 = sdtPr?.elements.find((el) => el.name === "w:fieldFontSize")?.attributes["w:val"];
22210
22442
  const textColor = sdtPr?.elements.find((el) => el.name === "w:fieldTextColor")?.attributes["w:val"];
22211
22443
  const textHighlight = sdtPr?.elements.find((el) => el.name === "w:fieldTextHighlight")?.attributes["w:val"];
22212
22444
  const attrs = {
@@ -22217,7 +22449,7 @@ const handleAnnotationNode = (params) => {
22217
22449
  fieldColor,
22218
22450
  multipleImage: isMultipleImage === "true",
22219
22451
  fontFamily: fontFamily !== "null" ? fontFamily : null,
22220
- fontSize: fontSize !== "null" ? fontSize : null,
22452
+ fontSize: fontSize2 !== "null" ? fontSize2 : null,
22221
22453
  textColor: textColor !== "null" ? textColor : null,
22222
22454
  textHighlight: textHighlight !== "null" ? textHighlight : null
22223
22455
  };
@@ -22470,8 +22702,13 @@ const handleAutoPageNumber = (params) => {
22470
22702
  if (nodes.length === 0 || nodes[0].name !== "sd:autoPageNumber") {
22471
22703
  return { nodes: [], consumed: 0 };
22472
22704
  }
22705
+ const rPr = nodes[0].elements?.find((el) => el.name === "w:rPr");
22706
+ const marks = parseMarks(rPr || { elements: [] });
22473
22707
  const processedNode = {
22474
- type: "page-number"
22708
+ type: "page-number",
22709
+ attrs: {
22710
+ marksAsAttrs: marks
22711
+ }
22475
22712
  };
22476
22713
  return { nodes: [processedNode], consumed: 1 };
22477
22714
  };
@@ -22484,8 +22721,13 @@ const handleAutoTotalPageNumber = (params) => {
22484
22721
  if (nodes.length === 0 || nodes[0].name !== "sd:totalPageNumber") {
22485
22722
  return { nodes: [], consumed: 0 };
22486
22723
  }
22724
+ const rPr = nodes[0].elements?.find((el) => el.name === "w:rPr");
22725
+ const marks = parseMarks(rPr || { elements: [] });
22487
22726
  const processedNode = {
22488
- type: "total-page-number"
22727
+ type: "total-page-number",
22728
+ attrs: {
22729
+ marksAsAttrs: marks
22730
+ }
22489
22731
  };
22490
22732
  return { nodes: [processedNode], consumed: 1 };
22491
22733
  };
@@ -22783,8 +23025,8 @@ const defaultNodeListHandler = () => {
22783
23025
  alternateChoiceHandler,
22784
23026
  runNodeHandlerEntity,
22785
23027
  pictNodeHandlerEntity,
22786
- listHandlerEntity,
22787
23028
  paragraphNodeHandlerEntity,
23029
+ listHandlerEntity,
22788
23030
  textNodeHandlerEntity,
22789
23031
  lineBreakNodeHandlerEntity,
22790
23032
  annotationNodeHandlerEntity,
@@ -22798,7 +23040,7 @@ const defaultNodeListHandler = () => {
22798
23040
  autoPageHandlerEntity,
22799
23041
  autoTotalPageCountEntity,
22800
23042
  standardNodeHandlerEntity
22801
- // This is the last one as it can handle everything
23043
+ //this should be the last one, bcs this parses everything!!!
22802
23044
  ];
22803
23045
  const handler = createNodeListHandler(entities);
22804
23046
  return {
@@ -23030,8 +23272,6 @@ const importHeadersFooters = (docx, converter, editor) => {
23030
23272
  converter.headers[rId] = { type: "doc", content: [...schema] };
23031
23273
  sectionType && (converter.headerIds[sectionType] = rId);
23032
23274
  });
23033
- const titlePg = allSectPrElements?.find((el) => el.name === "w:titlePg");
23034
- if (titlePg) converter.headerIds.titlePg = true;
23035
23275
  footers.forEach((footer) => {
23036
23276
  const { rId, referenceFile, currentFileName } = getHeaderFooterSectionData(footer, docx);
23037
23277
  const sectPrFooter = allSectPrElements.find((el) => el.name === "w:footerReference" && el.attributes["r:id"] === rId);
@@ -23172,7 +23412,7 @@ const _SuperConverter = class _SuperConverter {
23172
23412
  return;
23173
23413
  }
23174
23414
  }
23175
- static updateDocumentVersion(docx = this.convertedXml, version = "0.13.0-RC2") {
23415
+ static updateDocumentVersion(docx = this.convertedXml, version = "0.13.0-next.0") {
23176
23416
  const customLocation = "docProps/custom.xml";
23177
23417
  if (!docx[customLocation]) {
23178
23418
  docx[customLocation] = generateCustomXml();
@@ -23299,6 +23539,7 @@ const _SuperConverter = class _SuperConverter {
23299
23539
  getThemeInfo(themeName) {
23300
23540
  themeName = themeName.toLowerCase();
23301
23541
  const theme1 = this.convertedXml["word/theme/theme1.xml"];
23542
+ if (!theme1) return {};
23302
23543
  const themeData = theme1.elements.find((el) => el.name === "a:theme");
23303
23544
  const themeElements = themeData.elements.find((el) => el.name === "a:themeElements");
23304
23545
  const fontScheme = themeElements.elements.find((el) => el.name === "a:fontScheme");
@@ -23329,7 +23570,7 @@ const _SuperConverter = class _SuperConverter {
23329
23570
  const exporter = new DocxExporter(this);
23330
23571
  return exporter.schemaToXml(data, debug);
23331
23572
  }
23332
- async exportToDocx(jsonData, editorSchema, documentMedia, isFinalDoc = false, commentsExportType, comments = [], editor, exportJsonOnly = false) {
23573
+ async exportToDocx(jsonData, editorSchema, documentMedia, isFinalDoc = false, commentsExportType, comments = [], editor) {
23333
23574
  const commentsWithParaIds = comments.map((c) => prepareCommentParaIds(c));
23334
23575
  const commentDefinitions = commentsWithParaIds.map((c, index) => getCommentDefinition(c, index, commentsWithParaIds, editor));
23335
23576
  const { result, params } = this.exportToXmlJson({
@@ -23341,7 +23582,6 @@ const _SuperConverter = class _SuperConverter {
23341
23582
  isFinalDoc,
23342
23583
  editor
23343
23584
  });
23344
- if (exportJsonOnly) return result;
23345
23585
  const exporter = new DocxExporter(this);
23346
23586
  const xml = exporter.schemaToXml(result);
23347
23587
  await __privateMethod(this, _SuperConverter_instances, exportProcessMediaFiles_fn).call(this, {
@@ -23642,7 +23882,7 @@ function storeSuperdocVersion(docx) {
23642
23882
  function generateCustomXml() {
23643
23883
  return DEFAULT_CUSTOM_XML;
23644
23884
  }
23645
- function generateSuperdocVersion(pid = 2, version = "0.13.0-RC2") {
23885
+ function generateSuperdocVersion(pid = 2, version = "0.13.0-next.0") {
23646
23886
  return {
23647
23887
  type: "element",
23648
23888
  name: "property",
@@ -23666,7 +23906,7 @@ function generateSuperdocVersion(pid = 2, version = "0.13.0-RC2") {
23666
23906
  };
23667
23907
  }
23668
23908
  export {
23669
- getDefinitionForLevel as $,
23909
+ Transform as $,
23670
23910
  AllSelection as A,
23671
23911
  Buffer2 as B,
23672
23912
  TrackInsertMarkName as C,
@@ -23692,20 +23932,15 @@ export {
23692
23932
  getLineHeightValueString as W,
23693
23933
  toKebabCase as X,
23694
23934
  kebabCase as Y,
23695
- getStyleTagFromStyleId as Z,
23696
- getAbstractDefinition as _,
23935
+ getColStyleDeclaration as Z,
23936
+ SelectionRange as _,
23697
23937
  Plugin as a,
23698
- parseIndentElement as a0,
23699
- combineIndents as a1,
23700
- getColStyleDeclaration as a2,
23701
- SelectionRange as a3,
23702
- Transform as a4,
23703
- createColGroup as a5,
23704
- commonjsGlobal as a6,
23705
- getDefaultExportFromCjs$1 as a7,
23706
- getContentTypesFromXml as a8,
23707
- xmljs as a9,
23708
- vClickOutside as aa,
23938
+ createColGroup as a0,
23939
+ commonjsGlobal as a1,
23940
+ getDefaultExportFromCjs$1 as a2,
23941
+ getContentTypesFromXml as a3,
23942
+ xmljs as a4,
23943
+ vClickOutside as a5,
23709
23944
  canSplit as b,
23710
23945
  callOrGet as c,
23711
23946
  canJoin as d,
@@ -23718,13 +23953,13 @@ export {
23718
23953
  NodeRange as k,
23719
23954
  liftTarget as l,
23720
23955
  findWrapping as m,
23721
- generateDocxRandomId as n,
23956
+ isMacOS as n,
23722
23957
  objectIncludes as o,
23723
- minMax as p,
23724
- generateRandom32BitHex as q,
23958
+ isIOS as p,
23959
+ generateDocxRandomId as q,
23725
23960
  replaceStep as r,
23726
- isMacOS as s,
23727
- isIOS as t,
23961
+ minMax as s,
23962
+ generateRandom32BitHex as t,
23728
23963
  DOMSerializer as u,
23729
23964
  Mark as v,
23730
23965
  dropPoint as w,