@harbour-enterprises/superdoc 0.18.1-next.2 → 0.19.0-next.2

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 (34) hide show
  1. package/dist/chunks/{PdfViewer-DPqO7muc.cjs → PdfViewer-D-X0_rBI.cjs} +1 -1
  2. package/dist/chunks/{PdfViewer-BM7Ea3yr.es.js → PdfViewer-D59q6eRC.es.js} +1 -1
  3. package/dist/chunks/{index-CyUWXfUG.es.js → index-DYxO8sGC.es.js} +2 -2
  4. package/dist/chunks/{index-CPLP-MPz.cjs → index-Q9QnSj8V.cjs} +2 -2
  5. package/dist/chunks/{super-editor.es-CzgdqA6a.es.js → super-editor.es-DcrpYhcf.es.js} +565 -183
  6. package/dist/chunks/{super-editor.es-BSOX4l_Z.cjs → super-editor.es-DfRBE7HT.cjs} +565 -183
  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-X9LxTGJB.js → converter-C8B4S-1x.js} +224 -175
  10. package/dist/super-editor/chunks/{docx-zipper-CAu7OzVm.js → docx-zipper-BOcyXVbk.js} +1 -1
  11. package/dist/super-editor/chunks/{editor-BZitQIK-.js → editor-DSLtHYXL.js} +343 -10
  12. package/dist/super-editor/chunks/{toolbar-D1SFDkxX.js → toolbar-bgMTmwZ7.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/docxImporter.d.ts +2 -2
  18. package/dist/super-editor/src/core/super-converter/v2/importer/hyperlinkImporter.d.ts +2 -6
  19. package/dist/super-editor/src/core/super-converter/v3/handlers/utils.d.ts +1 -0
  20. package/dist/super-editor/src/core/super-converter/v3/handlers/w/hyperlink/hyperlink-translator.d.ts +7 -0
  21. package/dist/super-editor/src/core/super-converter/v3/handlers/w/hyperlink/index.d.ts +1 -0
  22. package/dist/super-editor/src/core/super-converter/v3/node-translator/node-translator.d.ts +2 -1
  23. package/dist/super-editor/src/core/super-validator/validators/xml/index.d.ts +2 -0
  24. package/dist/super-editor/src/core/super-validator/validators/xml/relationships/relationships-validator.d.ts +31 -0
  25. package/dist/super-editor/src/extensions/link/link.d.ts +4 -0
  26. package/dist/super-editor/super-editor.es.js +6 -6
  27. package/dist/super-editor/toolbar.es.js +2 -2
  28. package/dist/super-editor.cjs +1 -1
  29. package/dist/super-editor.es.js +1 -1
  30. package/dist/superdoc.cjs +2 -2
  31. package/dist/superdoc.es.js +2 -2
  32. package/dist/superdoc.umd.js +565 -183
  33. package/dist/superdoc.umd.js.map +1 -1
  34. package/package.json +1 -1
@@ -25551,7 +25551,7 @@ const _NodeTranslator = class _NodeTranslator2 {
25551
25551
  */
25552
25552
  decode(params2) {
25553
25553
  const decodedAttrs = this.decodeAttributes(params2);
25554
- return this.decodeFn ? this.decodeFn(params2, decodedAttrs) : void 0;
25554
+ return this.decodeFn ? this.decodeFn.call(this, params2, decodedAttrs) : void 0;
25555
25555
  }
25556
25556
  /**
25557
25557
  * Encode the attributes for the node.
@@ -25560,7 +25560,7 @@ const _NodeTranslator = class _NodeTranslator2 {
25560
25560
  */
25561
25561
  encode(params2) {
25562
25562
  const encodedAttrs = this.encodeAttributes(params2);
25563
- return this.encodeFn ? this.encodeFn(params2, encodedAttrs) : void 0;
25563
+ return this.encodeFn ? this.encodeFn.call(this, params2, encodedAttrs) : void 0;
25564
25564
  }
25565
25565
  /**
25566
25566
  * Create a new NodeTranslator instance from a configuration object.
@@ -25594,37 +25594,37 @@ const _NodeTranslator = class _NodeTranslator2 {
25594
25594
  };
25595
25595
  __publicField$2(_NodeTranslator, "translatorTypes", TranslatorTypes);
25596
25596
  let NodeTranslator = _NodeTranslator;
25597
- const encode$f = (attributes) => {
25597
+ const encode$g = (attributes) => {
25598
25598
  return attributes["w:type"];
25599
25599
  };
25600
- const decode$f = (attrs) => {
25600
+ const decode$g = (attrs) => {
25601
25601
  const { lineBreakType } = attrs;
25602
25602
  return lineBreakType;
25603
25603
  };
25604
25604
  const attrConfig$b = Object.freeze({
25605
25605
  xmlName: "w:type",
25606
25606
  sdName: "lineBreakType",
25607
- encode: encode$f,
25608
- decode: decode$f
25607
+ encode: encode$g,
25608
+ decode: decode$g
25609
25609
  });
25610
- const encode$e = (attributes) => {
25610
+ const encode$f = (attributes) => {
25611
25611
  const xmlAttrValue = attributes["w:clear"];
25612
25612
  return xmlAttrValue;
25613
25613
  };
25614
- const decode$e = (attrs) => {
25614
+ const decode$f = (attrs) => {
25615
25615
  const { clear } = attrs;
25616
25616
  return clear;
25617
25617
  };
25618
25618
  const attrConfig$a = Object.freeze({
25619
25619
  xmlName: "w:clear",
25620
25620
  sdName: "clear",
25621
- encode: encode$e,
25622
- decode: decode$e
25621
+ encode: encode$f,
25622
+ decode: decode$f
25623
25623
  });
25624
- const validXmlAttributes$3 = [attrConfig$b, attrConfig$a];
25625
- const XML_NODE_NAME$3 = "w:br";
25626
- const SD_NODE_NAME$3 = "lineBreak";
25627
- const encode$d = (_2, encodedAttrs) => {
25624
+ const validXmlAttributes$4 = [attrConfig$b, attrConfig$a];
25625
+ const XML_NODE_NAME$4 = "w:br";
25626
+ const SD_NODE_NAME$4 = "lineBreak";
25627
+ const encode$e = (_2, encodedAttrs) => {
25628
25628
  const isPageBreak = encodedAttrs?.lineBreakType === "page";
25629
25629
  const translated = {
25630
25630
  type: isPageBreak ? "hardBreak" : "lineBreak"
@@ -25634,7 +25634,7 @@ const encode$d = (_2, encodedAttrs) => {
25634
25634
  }
25635
25635
  return translated;
25636
25636
  };
25637
- const decode$d = (params2, decodedAttrs) => {
25637
+ const decode$e = (params2, decodedAttrs) => {
25638
25638
  const { node: node2 } = params2;
25639
25639
  if (!node2) return;
25640
25640
  const wBreak = { name: "w:br" };
@@ -25651,63 +25651,63 @@ const decode$d = (params2, decodedAttrs) => {
25651
25651
  };
25652
25652
  return translated;
25653
25653
  };
25654
- const config$3 = {
25655
- xmlName: XML_NODE_NAME$3,
25656
- sdNodeOrKeyName: SD_NODE_NAME$3,
25654
+ const config$4 = {
25655
+ xmlName: XML_NODE_NAME$4,
25656
+ sdNodeOrKeyName: SD_NODE_NAME$4,
25657
25657
  type: NodeTranslator.translatorTypes.NODE,
25658
- encode: encode$d,
25659
- decode: decode$d,
25660
- attributes: validXmlAttributes$3
25658
+ encode: encode$e,
25659
+ decode: decode$e,
25660
+ attributes: validXmlAttributes$4
25661
25661
  };
25662
- const translator$3 = NodeTranslator.from(config$3);
25663
- const encode$c = (attributes) => {
25662
+ const translator$4 = NodeTranslator.from(config$4);
25663
+ const encode$d = (attributes) => {
25664
25664
  return attributes["w:val"];
25665
25665
  };
25666
- const decode$c = (attrs) => {
25666
+ const decode$d = (attrs) => {
25667
25667
  const { tabSize } = attrs || {};
25668
25668
  return tabSize;
25669
25669
  };
25670
25670
  const attrConfig$9 = Object.freeze({
25671
25671
  xmlName: "w:val",
25672
25672
  sdName: "tabSize",
25673
- encode: encode$c,
25674
- decode: decode$c
25673
+ encode: encode$d,
25674
+ decode: decode$d
25675
25675
  });
25676
- const encode$b = (attributes) => {
25676
+ const encode$c = (attributes) => {
25677
25677
  return attributes["w:leader"];
25678
25678
  };
25679
- const decode$b = (attrs) => {
25679
+ const decode$c = (attrs) => {
25680
25680
  const { leader } = attrs || {};
25681
25681
  return leader;
25682
25682
  };
25683
25683
  const attrConfig$8 = Object.freeze({
25684
25684
  xmlName: "w:leader",
25685
25685
  sdName: "leader",
25686
- encode: encode$b,
25687
- decode: decode$b
25686
+ encode: encode$c,
25687
+ decode: decode$c
25688
25688
  });
25689
- const encode$a = (attributes) => {
25689
+ const encode$b = (attributes) => {
25690
25690
  return attributes["w:pos"];
25691
25691
  };
25692
- const decode$a = (attrs) => {
25692
+ const decode$b = (attrs) => {
25693
25693
  const { pos } = attrs || {};
25694
25694
  return pos;
25695
25695
  };
25696
25696
  const attrConfig$7 = Object.freeze({
25697
25697
  xmlName: "w:pos",
25698
25698
  sdName: "pos",
25699
- encode: encode$a,
25700
- decode: decode$a
25699
+ encode: encode$b,
25700
+ decode: decode$b
25701
25701
  });
25702
- const validXmlAttributes$2 = [attrConfig$9, attrConfig$7, attrConfig$8];
25703
- const XML_NODE_NAME$2 = "w:tab";
25704
- const SD_NODE_NAME$2 = "tab";
25705
- const encode$9 = (_2, encodedAttrs = {}) => {
25702
+ const validXmlAttributes$3 = [attrConfig$9, attrConfig$7, attrConfig$8];
25703
+ const XML_NODE_NAME$3 = "w:tab";
25704
+ const SD_NODE_NAME$3 = "tab";
25705
+ const encode$a = (_2, encodedAttrs = {}) => {
25706
25706
  const translated = { type: "tab" };
25707
25707
  if (encodedAttrs) translated.attrs = { ...encodedAttrs };
25708
25708
  return translated;
25709
25709
  };
25710
- const decode$9 = (params2, decodedAttrs = {}) => {
25710
+ const decode$a = (params2, decodedAttrs = {}) => {
25711
25711
  const { node: node2 } = params2 || {};
25712
25712
  if (!node2) return;
25713
25713
  const wTab = { name: "w:tab" };
@@ -25723,15 +25723,15 @@ const decode$9 = (params2, decodedAttrs = {}) => {
25723
25723
  }
25724
25724
  return translated;
25725
25725
  };
25726
- const config$2 = {
25727
- xmlName: XML_NODE_NAME$2,
25728
- sdNodeOrKeyName: SD_NODE_NAME$2,
25726
+ const config$3 = {
25727
+ xmlName: XML_NODE_NAME$3,
25728
+ sdNodeOrKeyName: SD_NODE_NAME$3,
25729
25729
  type: NodeTranslator.translatorTypes.NODE,
25730
- encode: encode$9,
25731
- decode: decode$9,
25732
- attributes: validXmlAttributes$2
25730
+ encode: encode$a,
25731
+ decode: decode$a,
25732
+ attributes: validXmlAttributes$3
25733
25733
  };
25734
- const translator$2 = NodeTranslator.from(config$2);
25734
+ const translator$3 = NodeTranslator.from(config$3);
25735
25735
  const mergeTextNodes = (nodes) => {
25736
25736
  if (!nodes || !Array.isArray(nodes)) {
25737
25737
  return nodes;
@@ -26301,91 +26301,91 @@ const handleParagraphNode$1 = (params2) => {
26301
26301
  }
26302
26302
  return schemaNode;
26303
26303
  };
26304
- const encode$8 = (attributes) => {
26304
+ const encode$9 = (attributes) => {
26305
26305
  return attributes["w:rsidDel"];
26306
26306
  };
26307
- const decode$8 = (attrs) => {
26307
+ const decode$9 = (attrs) => {
26308
26308
  return attrs.rsidDel;
26309
26309
  };
26310
26310
  const attrConfig$6 = Object.freeze({
26311
26311
  xmlName: "w:rsidDel",
26312
26312
  sdName: "rsidDel",
26313
- encode: encode$8,
26314
- decode: decode$8
26313
+ encode: encode$9,
26314
+ decode: decode$9
26315
26315
  });
26316
- const encode$7 = (attributes) => {
26316
+ const encode$8 = (attributes) => {
26317
26317
  return attributes["w:rsidP"];
26318
26318
  };
26319
- const decode$7 = (attrs) => {
26319
+ const decode$8 = (attrs) => {
26320
26320
  return attrs.rsidP;
26321
26321
  };
26322
26322
  const attrConfig$5 = Object.freeze({
26323
26323
  xmlName: "w:rsidP",
26324
26324
  sdName: "rsidP",
26325
- encode: encode$7,
26326
- decode: decode$7
26325
+ encode: encode$8,
26326
+ decode: decode$8
26327
26327
  });
26328
- const encode$6 = (attributes) => {
26328
+ const encode$7 = (attributes) => {
26329
26329
  return attributes["w:rsidR"];
26330
26330
  };
26331
- const decode$6 = (attrs) => {
26331
+ const decode$7 = (attrs) => {
26332
26332
  return attrs.rsidR;
26333
26333
  };
26334
26334
  const attrConfig$4 = Object.freeze({
26335
26335
  xmlName: "w:rsidR",
26336
26336
  sdName: "rsidR",
26337
- encode: encode$6,
26338
- decode: decode$6
26337
+ encode: encode$7,
26338
+ decode: decode$7
26339
26339
  });
26340
- const encode$5 = (attributes) => {
26340
+ const encode$6 = (attributes) => {
26341
26341
  return attributes["w:rsidRPr"];
26342
26342
  };
26343
- const decode$5 = (attrs) => {
26343
+ const decode$6 = (attrs) => {
26344
26344
  return attrs.rsidRPr;
26345
26345
  };
26346
26346
  const attrConfig$3 = Object.freeze({
26347
26347
  xmlName: "w:rsidRPr",
26348
26348
  sdName: "rsidRPr",
26349
- encode: encode$5,
26350
- decode: decode$5
26349
+ encode: encode$6,
26350
+ decode: decode$6
26351
26351
  });
26352
- const encode$4 = (attributes) => {
26352
+ const encode$5 = (attributes) => {
26353
26353
  return attributes["w:rsidRDefault"];
26354
26354
  };
26355
- const decode$4 = (attrs) => {
26355
+ const decode$5 = (attrs) => {
26356
26356
  return attrs.rsidRDefault;
26357
26357
  };
26358
26358
  const attrConfig$2 = Object.freeze({
26359
26359
  xmlName: "w:rsidRDefault",
26360
26360
  sdName: "rsidRDefault",
26361
- encode: encode$4,
26362
- decode: decode$4
26361
+ encode: encode$5,
26362
+ decode: decode$5
26363
26363
  });
26364
- const encode$3 = (attributes) => {
26364
+ const encode$4 = (attributes) => {
26365
26365
  return attributes["w14:paraId"];
26366
26366
  };
26367
- const decode$3 = (attrs) => {
26367
+ const decode$4 = (attrs) => {
26368
26368
  return attrs.paraId;
26369
26369
  };
26370
26370
  const attrConfig$1 = Object.freeze({
26371
26371
  xmlName: "w14:paraId",
26372
26372
  sdName: "paraId",
26373
- encode: encode$3,
26374
- decode: decode$3
26373
+ encode: encode$4,
26374
+ decode: decode$4
26375
26375
  });
26376
- const encode$2 = (attributes) => {
26376
+ const encode$3 = (attributes) => {
26377
26377
  return attributes["w14:textId"];
26378
26378
  };
26379
- const decode$2 = (attrs) => {
26379
+ const decode$3 = (attrs) => {
26380
26380
  return attrs.textId;
26381
26381
  };
26382
26382
  const attrConfig = Object.freeze({
26383
26383
  xmlName: "w14:textId",
26384
26384
  sdName: "textId",
26385
- encode: encode$2,
26386
- decode: decode$2
26385
+ encode: encode$3,
26386
+ decode: decode$3
26387
26387
  });
26388
- const validXmlAttributes$1 = [
26388
+ const validXmlAttributes$2 = [
26389
26389
  attrConfig$1,
26390
26390
  attrConfig,
26391
26391
  attrConfig$4,
@@ -26394,9 +26394,9 @@ const validXmlAttributes$1 = [
26394
26394
  attrConfig$3,
26395
26395
  attrConfig$6
26396
26396
  ];
26397
- const XML_NODE_NAME$1 = "w:p";
26398
- const SD_NODE_NAME$1 = "paragraph";
26399
- const encode$1 = (params2, encodedAttrs = {}) => {
26397
+ const XML_NODE_NAME$2 = "w:p";
26398
+ const SD_NODE_NAME$2 = "paragraph";
26399
+ const encode$2 = (params2, encodedAttrs = {}) => {
26400
26400
  const node2 = handleParagraphNode$1(params2);
26401
26401
  if (!node2) return void 0;
26402
26402
  if (encodedAttrs && Object.keys(encodedAttrs).length) {
@@ -26404,7 +26404,7 @@ const encode$1 = (params2, encodedAttrs = {}) => {
26404
26404
  }
26405
26405
  return node2;
26406
26406
  };
26407
- const decode$1 = (params2, decodedAttrs = {}) => {
26407
+ const decode$2 = (params2, decodedAttrs = {}) => {
26408
26408
  const translated = translateParagraphNode(params2);
26409
26409
  if (!translated) return void 0;
26410
26410
  if (decodedAttrs && Object.keys(decodedAttrs).length) {
@@ -26412,15 +26412,15 @@ const decode$1 = (params2, decodedAttrs = {}) => {
26412
26412
  }
26413
26413
  return translated;
26414
26414
  };
26415
- const config$1 = {
26416
- xmlName: XML_NODE_NAME$1,
26417
- sdNodeOrKeyName: SD_NODE_NAME$1,
26415
+ const config$2 = {
26416
+ xmlName: XML_NODE_NAME$2,
26417
+ sdNodeOrKeyName: SD_NODE_NAME$2,
26418
26418
  type: NodeTranslator.translatorTypes.NODE,
26419
- encode: encode$1,
26420
- decode: decode$1,
26421
- attributes: validXmlAttributes$1
26419
+ encode: encode$2,
26420
+ decode: decode$2,
26421
+ attributes: validXmlAttributes$2
26422
26422
  };
26423
- const translator$1 = NodeTranslator.from(config$1);
26423
+ const translator$2 = NodeTranslator.from(config$2);
26424
26424
  const handleAllTableNodes = (params2) => {
26425
26425
  const { nodes } = params2;
26426
26426
  if (nodes.length === 0) {
@@ -26515,7 +26515,7 @@ function handleTableCellNode$1({
26515
26515
  columnWidth
26516
26516
  }
26517
26517
  };
26518
- const schemaNode = translator.encode(translatorParams);
26518
+ const schemaNode = translator$1.encode(translatorParams);
26519
26519
  return schemaNode;
26520
26520
  }
26521
26521
  function getReferencedTableStyles(tblStyleTag, docx) {
@@ -26917,10 +26917,10 @@ function generateCellMargins(cellMargins) {
26917
26917
  if (left2 != null) elements.push({ name: "w:left", attributes: { "w:w": pixelsToTwips(left2) } });
26918
26918
  return elements;
26919
26919
  }
26920
- const XML_NODE_NAME = "w:tc";
26921
- const SD_NODE_NAME = "tableCell";
26922
- const validXmlAttributes = [];
26923
- function encode$g(params2, encodedAttrs) {
26920
+ const XML_NODE_NAME$1 = "w:tc";
26921
+ const SD_NODE_NAME$1 = "tableCell";
26922
+ const validXmlAttributes$1 = [];
26923
+ function encode$1(params2, encodedAttrs) {
26924
26924
  const { node: node2, table, row, rowBorders, styleTag, columnIndex, columnWidth } = params2.extraParams;
26925
26925
  const schemaNode = handleTableCellNode({
26926
26926
  params: params2,
@@ -26937,18 +26937,123 @@ function encode$g(params2, encodedAttrs) {
26937
26937
  }
26938
26938
  return schemaNode;
26939
26939
  }
26940
- function decode(params2, decodedAttrs) {
26940
+ function decode$1(params2, decodedAttrs) {
26941
26941
  const translated = translateTableCell(params2);
26942
26942
  if (decodedAttrs && Object.keys(decodedAttrs).length) {
26943
26943
  translated.attributes = { ...translated.attributes || {}, ...decodedAttrs };
26944
26944
  }
26945
26945
  return translated;
26946
26946
  }
26947
+ const config$1 = {
26948
+ xmlName: XML_NODE_NAME$1,
26949
+ sdNodeOrKeyName: SD_NODE_NAME$1,
26950
+ type: NodeTranslator.translatorTypes.NODE,
26951
+ encode: encode$1,
26952
+ decode: decode$1,
26953
+ attributes: validXmlAttributes$1
26954
+ };
26955
+ const translator$1 = NodeTranslator.from(config$1);
26956
+ const XML_NODE_NAME = "w:hyperlink";
26957
+ const SD_NODE_NAME = "link";
26958
+ const _createAttributeHandler = (xmlName, sdName) => ({
26959
+ xmlName,
26960
+ sdName,
26961
+ encode: (attributes) => attributes[xmlName],
26962
+ decode: (attributes) => attributes[sdName]
26963
+ });
26964
+ const validXmlAttributes = [
26965
+ _createAttributeHandler("w:anchor", "anchor"),
26966
+ _createAttributeHandler("w:docLocation", "docLocation"),
26967
+ {
26968
+ xmlName: "w:history",
26969
+ sdName: "history",
26970
+ encode: (attributes) => attributes["w:history"] === "1" || attributes["w:history"] === "true",
26971
+ decode: (attributes) => attributes["history"] ? "1" : "0"
26972
+ },
26973
+ _createAttributeHandler("w:tooltip", "tooltip"),
26974
+ _createAttributeHandler("r:id", "rId"),
26975
+ _createAttributeHandler("w:tgtFrame", "target")
26976
+ ];
26977
+ const encode$h = (params2, encodedAttrs) => {
26978
+ const { nodes, docx, nodeListHandler: nodeListHandler2 } = params2;
26979
+ const node2 = nodes[0];
26980
+ let href = _resolveHref(docx, encodedAttrs);
26981
+ const linkMark = { type: "link", attrs: { ...encodedAttrs, href } };
26982
+ const runNodes = node2.elements.filter((el) => el.name === "w:r");
26983
+ runNodes.forEach((runNode) => {
26984
+ runNode.marks = [...runNode.marks || [], linkMark];
26985
+ });
26986
+ const updatedNode = nodeListHandler2.handler({
26987
+ ...params2,
26988
+ nodes: runNodes,
26989
+ path: [...params2.path || [], node2]
26990
+ });
26991
+ return updatedNode;
26992
+ };
26993
+ const _resolveHref = (docx, encodedAttrs) => {
26994
+ const rels = docx["word/_rels/document.xml.rels"];
26995
+ const relationships = rels.elements.find((el) => el.name === "Relationships");
26996
+ const { elements } = relationships;
26997
+ const { rId, anchor } = encodedAttrs;
26998
+ let href;
26999
+ if (!rId && anchor) {
27000
+ href = `#${anchor}`;
27001
+ } else if (rId) {
27002
+ const rel = elements.find((el) => el.attributes["Id"] === rId) || {};
27003
+ const { attributes: relAttributes = {} } = rel;
27004
+ href = relAttributes["Target"];
27005
+ }
27006
+ return href;
27007
+ };
27008
+ function decode(params2, _2) {
27009
+ const { node: node2 } = params2;
27010
+ const linkMark = node2.marks.find((m2) => m2.type === "link");
27011
+ const linkAttrs = this.decodeAttributes({ ...params2, node: linkMark });
27012
+ let { anchor, href: link } = linkMark.attrs;
27013
+ const isExternalLink = !anchor;
27014
+ if (isExternalLink) {
27015
+ linkAttrs["r:id"] = _addNewLinkRelationship(params2, link, linkAttrs["r:id"]);
27016
+ }
27017
+ node2.marks = node2.marks.filter((m2) => m2.type !== "link");
27018
+ const outputNode = exportSchemaToJson({ ...params2, node: node2 });
27019
+ const newNode = {
27020
+ name: "w:hyperlink",
27021
+ type: "element",
27022
+ attributes: {
27023
+ ...linkAttrs
27024
+ },
27025
+ elements: [outputNode]
27026
+ };
27027
+ return newNode;
27028
+ }
27029
+ function _addNewLinkRelationship(params2, link, rId) {
27030
+ if (!rId) rId = generateDocxRandomId();
27031
+ if (!params2.relationships || !Array.isArray(params2.relationships)) {
27032
+ params2.relationships = [];
27033
+ }
27034
+ const existingRel = params2.relationships.find(
27035
+ (rel) => rel.attributes && rel.attributes.Id === rId && rel.attributes.Target === link
27036
+ );
27037
+ if (existingRel) {
27038
+ return rId;
27039
+ }
27040
+ params2.relationships.push({
27041
+ type: "element",
27042
+ name: "Relationship",
27043
+ attributes: {
27044
+ Id: rId,
27045
+ Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
27046
+ Target: link,
27047
+ TargetMode: "External"
27048
+ }
27049
+ });
27050
+ return rId;
27051
+ }
26947
27052
  const config = {
26948
27053
  xmlName: XML_NODE_NAME,
26949
27054
  sdNodeOrKeyName: SD_NODE_NAME,
26950
27055
  type: NodeTranslator.translatorTypes.NODE,
26951
- encode: encode$g,
27056
+ encode: encode$h,
26952
27057
  decode,
26953
27058
  attributes: validXmlAttributes
26954
27059
  };
@@ -26959,19 +27064,19 @@ function exportSchemaToJson(params2) {
26959
27064
  doc: translateDocumentNode,
26960
27065
  body: translateBodyNode,
26961
27066
  heading: translateHeadingNode,
26962
- paragraph: translator$1,
27067
+ paragraph: translator$2,
26963
27068
  text: translateTextNode,
26964
27069
  bulletList: translateList,
26965
27070
  orderedList: translateList,
26966
- lineBreak: translator$3,
27071
+ lineBreak: translator$4,
26967
27072
  table: translateTable,
26968
27073
  tableRow: translateTableRow,
26969
- tableCell: translator,
27074
+ tableCell: translator$1,
26970
27075
  bookmarkStart: translateBookmarkStart,
26971
27076
  fieldAnnotation: translateFieldAnnotation,
26972
- tab: translator$2,
27077
+ tab: translator$3,
26973
27078
  image: translateImageNode,
26974
- hardBreak: translator$3,
27079
+ hardBreak: translator$4,
26975
27080
  commentRangeStart: () => translateCommentNode(params2, "Start"),
26976
27081
  commentRangeEnd: () => translateCommentNode(params2, "End"),
26977
27082
  commentReference: () => null,
@@ -27303,7 +27408,7 @@ function translateTextNode(params2) {
27303
27408
  const isTrackedNode = node2.marks?.some((m2) => trackedMarks.includes(m2.type));
27304
27409
  if (isTrackedNode) return translateTrackedNode(params2);
27305
27410
  const isLinkNode = node2.marks?.some((m2) => m2.type === "link");
27306
- if (isLinkNode) return translateLinkNode(params2);
27411
+ if (isLinkNode) return translator.decode(params2);
27307
27412
  const { text, marks = [] } = node2;
27308
27413
  return getTextNodeForExport(text, marks, params2);
27309
27414
  }
@@ -27382,27 +27487,6 @@ function processOutputMarks(marks = []) {
27382
27487
  }
27383
27488
  });
27384
27489
  }
27385
- function translateLinkNode(params2) {
27386
- const { node: node2 } = params2;
27387
- const linkMark = node2.marks.find((m2) => m2.type === "link");
27388
- const link = linkMark.attrs.href;
27389
- let rId = linkMark.attrs.rId;
27390
- if (!rId) {
27391
- rId = addNewLinkRelationship(params2, link);
27392
- }
27393
- node2.marks = node2.marks.filter((m2) => m2.type !== "link");
27394
- const outputNode = exportSchemaToJson({ ...params2, node: node2 });
27395
- const contentNode = processLinkContentNode(outputNode);
27396
- const newNode = {
27397
- name: "w:hyperlink",
27398
- type: "element",
27399
- attributes: {
27400
- "r:id": rId
27401
- },
27402
- elements: [contentNode]
27403
- };
27404
- return newNode;
27405
- }
27406
27490
  function processLinkContentNode(node2) {
27407
27491
  if (!node2) return node2;
27408
27492
  const contentNode = carbonCopy(node2);
@@ -29021,57 +29105,22 @@ const trackChangeNodeHandlerEntity = {
29021
29105
  handlerName: "trackChangeNodeHandler",
29022
29106
  handler: handleTrackChangeNode
29023
29107
  };
29024
- const handleHyperlinkNode = (params2) => {
29025
- const { nodes, docx, nodeListHandler: nodeListHandler2 } = params2;
29026
- if (nodes.length === 0 || nodes[0].name !== "w:hyperlink") {
29027
- return { nodes: [], consumed: 0 };
29028
- }
29029
- const node2 = nodes[0];
29030
- const rels = docx["word/_rels/document.xml.rels"];
29031
- const relationships = rels.elements.find((el) => el.name === "Relationships");
29032
- const { elements } = relationships;
29033
- const { attributes } = node2;
29034
- const rId = attributes["r:id"];
29035
- const anchor = attributes["w:anchor"];
29036
- attributes["w:history"];
29037
- const rel = elements.find((el) => el.attributes["Id"] === rId) || {};
29038
- const { attributes: relAttributes = {} } = rel;
29039
- let href = relAttributes["Target"];
29040
- if (anchor && !href) href = `#${anchor}`;
29041
- const runNodes = node2.elements.filter((el) => el.name === "w:r");
29042
- const linkMark = { type: "link", attrs: { href, rId } };
29043
- for (const runNode of runNodes) {
29044
- if (!runNode.marks) runNode.marks = [];
29045
- runNode.marks.push(linkMark);
29046
- const rPr = runNode.elements.find((el) => el.name === "w:rPr");
29047
- if (rPr) {
29048
- const styleRel = rPr.elements.find((el) => el.name === "w:rStyle");
29049
- if (styleRel) {
29050
- const styles = docx["word/styles.xml"];
29051
- const { elements: elements2 } = styles.elements[0];
29052
- const styleElements = elements2.filter((el) => el.name === "w:style");
29053
- const style2 = styleElements.find((el) => el.attributes["w:styleId"] === "Hyperlink");
29054
- const styleRpr = style2?.elements?.find((el) => el.name === "w:rPr");
29055
- if (styleRpr) {
29056
- styleRpr.elements.forEach((styleEl) => {
29057
- const hasElInRPr = rPr.elements.find((el) => el.name === styleEl.name);
29058
- if (!hasElInRPr) rPr.elements.push(styleEl);
29059
- });
29060
- }
29061
- }
29108
+ const generateV2HandlerEntity = (handlerName, translator2) => ({
29109
+ handlerName,
29110
+ handler: (params2) => {
29111
+ const { nodes } = params2;
29112
+ if (nodes.length === 0 || nodes[0].name !== translator2.xmlName) {
29113
+ return { nodes: [], consumed: 0 };
29062
29114
  }
29115
+ const result = translator2.encode(params2);
29116
+ if (!result) return { nodes: [], consumed: 0 };
29117
+ return {
29118
+ nodes: Array.isArray(result) ? result : [result],
29119
+ consumed: 1
29120
+ };
29063
29121
  }
29064
- const updatedNode = nodeListHandler2.handler({
29065
- ...params2,
29066
- nodes: runNodes,
29067
- path: [...params2.path || [], node2]
29068
- });
29069
- return { nodes: updatedNode, consumed: 1 };
29070
- };
29071
- const hyperlinkNodeHandlerEntity = {
29072
- handlerName: "hyperlinkNodeHandler",
29073
- handler: handleHyperlinkNode
29074
- };
29122
+ });
29123
+ const hyperlinkNodeHandlerEntity = generateV2HandlerEntity("hyperlinkNodeHandler", translator);
29075
29124
  const handleRunNode = (params2) => {
29076
29125
  const { nodes, nodeListHandler: nodeListHandler2, parentStyleId, docx } = params2;
29077
29126
  if (nodes.length === 0 || nodes[0].name !== "w:r") {
@@ -29183,7 +29232,7 @@ const handleParagraphNode = (params2) => {
29183
29232
  if (nodes.length === 0 || nodes[0].name !== "w:p") {
29184
29233
  return { nodes: [], consumed: 0 };
29185
29234
  }
29186
- const schemaNode = translator$1.encode(params2);
29235
+ const schemaNode = translator$2.encode(params2);
29187
29236
  const newNodes = schemaNode ? [schemaNode] : [];
29188
29237
  return { nodes: newNodes, consumed: 1 };
29189
29238
  };
@@ -29496,7 +29545,7 @@ const handler = (params2) => {
29496
29545
  if (nodes.length === 0 || nodes[0].name !== "w:br") {
29497
29546
  return { nodes: [], consumed: 0 };
29498
29547
  }
29499
- const result = translator$3.encode(params2);
29548
+ const result = translator$4.encode(params2);
29500
29549
  if (!result) return { nodes: [], consumed: 0 };
29501
29550
  return {
29502
29551
  nodes: [result],
@@ -30192,7 +30241,7 @@ const handleTabNode = (params2) => {
30192
30241
  if (!nodes.length || nodes[0].name !== "w:tab") {
30193
30242
  return { nodes: [], consumed: 0 };
30194
30243
  }
30195
- const node2 = translator$2.encode(params2);
30244
+ const node2 = translator$3.encode(params2);
30196
30245
  return { nodes: [node2], consumed: 1 };
30197
30246
  };
30198
30247
  const tabNodeEntityHandler = {
@@ -47099,8 +47148,8 @@ function ensureValidLinkRID(links, editor, tr, logger) {
47099
47148
  let modified = false;
47100
47149
  const results = [];
47101
47150
  links.forEach(({ mark, from: from2, to }) => {
47102
- const { rId, href } = mark.attrs;
47103
- if (!rId && href) {
47151
+ const { rId, href, anchor } = mark.attrs;
47152
+ if (!rId && href && !anchor) {
47104
47153
  let newId = editor.converter.docxHelpers.findRelationshipIdFromTarget(href, editor);
47105
47154
  if (newId) logger.debug("Reusing existing rId for link:", newId, "from pos:", from2, "to pos:", to);
47106
47155
  if (!newId) {
@@ -47186,8 +47235,307 @@ function pruneInvalidNumNodes(node2, removed) {
47186
47235
  }
47187
47236
  node2.elements = next;
47188
47237
  }
47238
+ function createRelationshipsValidator({ editor, logger }) {
47239
+ return () => {
47240
+ const results = [];
47241
+ let modified = false;
47242
+ const convertedXml = editor?.converter?.convertedXml;
47243
+ if (!convertedXml || typeof convertedXml !== "object") {
47244
+ return { results, modified };
47245
+ }
47246
+ const { relsKey, wasNormalized } = findAndNormalizeRelationshipsFile(convertedXml, results);
47247
+ if (!relsKey) {
47248
+ return { results, modified };
47249
+ }
47250
+ if (wasNormalized) modified = true;
47251
+ const { root: root2, wasFixed } = validateRelationshipsRoot(convertedXml[relsKey], relsKey, results);
47252
+ if (!root2) {
47253
+ return { results, modified };
47254
+ }
47255
+ if (wasFixed) modified = true;
47256
+ const wasCleaned = cleanupRootChildren(root2);
47257
+ if (wasCleaned) modified = true;
47258
+ const { filteredIds, binMediaTargets, wasProcessed } = processRelationships(root2, convertedXml, results);
47259
+ if (wasProcessed) modified = true;
47260
+ const wasDocumentFixed = fixMissingDocumentRefs(convertedXml, filteredIds, results, logger);
47261
+ if (wasDocumentFixed) modified = true;
47262
+ const contentTypesKey = "[Content_Types].xml";
47263
+ const contentTypesXml = convertedXml[contentTypesKey];
47264
+ if (binMediaTargets.size > 0 || contentTypesXml) {
47265
+ const wasContentTypesUpdated = updateContentTypes(convertedXml, binMediaTargets, results);
47266
+ if (wasContentTypesUpdated) modified = true;
47267
+ } else {
47268
+ results.push("[Content_Types].xml not found or not parseable. Skipped content types patch.");
47269
+ }
47270
+ return { results, modified };
47271
+ };
47272
+ }
47273
+ function findAndNormalizeRelationshipsFile(convertedXml, results) {
47274
+ const candidateKeys = [
47275
+ "word/_rels/document.xml.rels",
47276
+ "word/document.xml.rels",
47277
+ "_rels/document.xml.rels",
47278
+ "document.xml.rels"
47279
+ ];
47280
+ const relsKey = candidateKeys.find((k) => convertedXml?.[k]?.elements);
47281
+ if (!relsKey) return { relsKey: null, wasNormalized: false };
47282
+ const canonicalKey = "word/_rels/document.xml.rels";
47283
+ if (relsKey !== canonicalKey) {
47284
+ convertedXml[canonicalKey] = convertedXml[relsKey];
47285
+ delete convertedXml[relsKey];
47286
+ results.push(`Normalized relationships location to ${canonicalKey} (was ${relsKey})`);
47287
+ return { relsKey: canonicalKey, wasNormalized: true };
47288
+ }
47289
+ return { relsKey, wasNormalized: false };
47290
+ }
47291
+ function validateRelationshipsRoot(relsTree, relsKey, results) {
47292
+ const root2 = relsTree?.elements?.[0];
47293
+ if (!root2 || root2.type !== "element") {
47294
+ results.push(`${relsKey} is not a valid xml`);
47295
+ return { root: null, wasFixed: false };
47296
+ }
47297
+ const RELS_NS = "http://schemas.openxmlformats.org/package/2006/relationships";
47298
+ let wasFixed = false;
47299
+ if (root2.name !== "Relationships") {
47300
+ root2.name = "Relationships";
47301
+ results.push(`Fixed relationships root element name to "Relationships"`);
47302
+ wasFixed = true;
47303
+ }
47304
+ root2.attributes = root2.attributes || {};
47305
+ if (root2.attributes.xmlns !== RELS_NS) {
47306
+ root2.attributes.xmlns = RELS_NS;
47307
+ results.push(`Set relationships xmlns to ${RELS_NS}`);
47308
+ wasFixed = true;
47309
+ }
47310
+ return { root: root2, wasFixed };
47311
+ }
47312
+ function cleanupRootChildren(root2, results) {
47313
+ const validChildren = root2.elements?.filter((child) => child?.type === "element" && child.name === "Relationship") || [];
47314
+ if (root2.elements?.length !== validChildren.length) {
47315
+ root2.elements = validChildren;
47316
+ return true;
47317
+ }
47318
+ return false;
47319
+ }
47320
+ function processRelationships(root2, convertedXml, results) {
47321
+ const binMediaTargets = /* @__PURE__ */ new Set();
47322
+ const filteredIds = /* @__PURE__ */ new Set();
47323
+ let wasProcessed = false;
47324
+ const ridNum = (id) => {
47325
+ const m2 = /^rId(\d+)$/.exec(String(id || ""));
47326
+ return m2 ? parseInt(m2[1], 10) : null;
47327
+ };
47328
+ const isType2 = (type2, tail) => typeof type2 === "string" && new RegExp(`/relationships/${tail}$`, "i").test(type2);
47329
+ const isHyperlinkType = (type2) => isType2(type2, "hyperlink");
47330
+ const isImageType = (type2) => isType2(type2, "image");
47331
+ const looksExternal = (target) => /^https?:\/\//i.test(target || "") || /^mailto:/i.test(target || "");
47332
+ const usedIds = /* @__PURE__ */ new Set();
47333
+ let maxRid = 0;
47334
+ for (const el of root2.elements) {
47335
+ el.attributes = el.attributes || {};
47336
+ const id = el.attributes.Id;
47337
+ const n = ridNum(id);
47338
+ if (Number.isInteger(n)) maxRid = Math.max(maxRid, n);
47339
+ if (typeof id === "string" && id) {
47340
+ usedIds.add(id);
47341
+ }
47342
+ }
47343
+ let ridCounter = maxRid;
47344
+ const allocateId = (preferred) => {
47345
+ let newId;
47346
+ do {
47347
+ ridCounter += 1;
47348
+ newId = `rId${ridCounter}`;
47349
+ } while (usedIds.has(newId));
47350
+ usedIds.add(newId);
47351
+ return newId;
47352
+ };
47353
+ const seenIds = /* @__PURE__ */ new Set();
47354
+ const filtered = [];
47355
+ function extractStringAttr(attrs, key) {
47356
+ return typeof attrs[key] === "string" ? attrs[key].trim() : "";
47357
+ }
47358
+ for (const rel of root2.elements) {
47359
+ rel.attributes = rel.attributes || {};
47360
+ const attrs = rel.attributes;
47361
+ let id = extractStringAttr(attrs, "Id");
47362
+ const type2 = extractStringAttr(attrs, "Type");
47363
+ let target = extractStringAttr(attrs, "Target");
47364
+ let targetMode = extractStringAttr(attrs, "TargetMode");
47365
+ if (!target) {
47366
+ results.push(`Removed relationship "${id}" without Target`);
47367
+ wasProcessed = true;
47368
+ continue;
47369
+ }
47370
+ if (isHyperlinkType(type2) && looksExternal(target) && targetMode.toLowerCase() !== "external") {
47371
+ attrs.TargetMode = "External";
47372
+ targetMode = "External";
47373
+ results.push(`Set TargetMode="External" for hyperlink ${id}`);
47374
+ wasProcessed = true;
47375
+ }
47376
+ if (isImageType(type2)) {
47377
+ const relPath = `word/${target.replace(/^\.?\//, "")}`;
47378
+ if (/^media\/.+\.bin$/i.test(target) && relPath in convertedXml) {
47379
+ binMediaTargets.add(`/${relPath}`);
47380
+ }
47381
+ }
47382
+ if (targetMode.toLowerCase() !== "external" && !looksExternal(target)) {
47383
+ const likelyPath = `word/${target.replace(/^\.?\//, "")}`;
47384
+ if (!(likelyPath in convertedXml)) {
47385
+ if (!isImageType(type2)) {
47386
+ results.push(`Removed relationship ${id} with missing target: ${target}`);
47387
+ wasProcessed = true;
47388
+ continue;
47389
+ } else {
47390
+ results.push(`Warning: image relationship ${id} target not found: ${target}.`);
47391
+ }
47392
+ }
47393
+ }
47394
+ if (!id) {
47395
+ const newId = allocateId();
47396
+ attrs.Id = newId;
47397
+ results.push(`Assigned missing Id "${newId}"`);
47398
+ wasProcessed = true;
47399
+ id = newId;
47400
+ }
47401
+ if (seenIds.has(id)) {
47402
+ results.push(`Removed duplicate relationship with ID "${id}"`);
47403
+ wasProcessed = true;
47404
+ continue;
47405
+ }
47406
+ seenIds.add(id);
47407
+ filtered.push(rel);
47408
+ }
47409
+ if (root2.elements.length !== filtered.length) {
47410
+ root2.elements = filtered;
47411
+ wasProcessed = true;
47412
+ } else {
47413
+ const contentChanged = root2.elements.some((el, i) => el !== filtered[i]);
47414
+ if (contentChanged) {
47415
+ root2.elements = filtered;
47416
+ wasProcessed = true;
47417
+ }
47418
+ }
47419
+ for (const rel of root2.elements) {
47420
+ const id = rel.attributes?.Id;
47421
+ if (typeof id === "string" && id) {
47422
+ filteredIds.add(id);
47423
+ }
47424
+ }
47425
+ return { filteredIds, binMediaTargets, wasProcessed };
47426
+ }
47427
+ function fixMissingDocumentRefs(convertedXml, filteredIds, results, logger) {
47428
+ const documentPath = "word/document.xml";
47429
+ const document2 = convertedXml[documentPath];
47430
+ if (document2?.elements?.length) {
47431
+ const documentRoot = document2.elements[0];
47432
+ if (documentRoot?.type === "element") {
47433
+ const missingRefs = [];
47434
+ processDocumentForMissingRefs(documentRoot, filteredIds, missingRefs);
47435
+ if (missingRefs.length) {
47436
+ results.push(`Fixed ${missingRefs.length} missing relationship references`);
47437
+ logger?.debug?.(`Fixed ${missingRefs.length} missing relationship references in document`);
47438
+ return true;
47439
+ }
47440
+ }
47441
+ }
47442
+ return false;
47443
+ }
47444
+ function updateContentTypes(convertedXml, binMediaTargets, results) {
47445
+ const contentTypesKey = "[Content_Types].xml";
47446
+ const contentTypesXml = convertedXml[contentTypesKey];
47447
+ if (typeof contentTypesXml === "string") {
47448
+ return updateContentTypesString(contentTypesXml, binMediaTargets, results, convertedXml, contentTypesKey);
47449
+ } else if (contentTypesXml?.elements?.length) {
47450
+ return updateContentTypesElements(contentTypesXml, binMediaTargets, results);
47451
+ } else {
47452
+ return false;
47453
+ }
47454
+ }
47455
+ function updateContentTypesString(contentTypesXml, binMediaTargets, results, convertedXml, contentTypesKey) {
47456
+ const CONTENT_TYPES_NS = '<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">';
47457
+ const ensureDefault = (xmlString, ext, contentType) => {
47458
+ const defRe = new RegExp(`<Default\\s+Extension="${ext}"\\b`, "i");
47459
+ if (defRe.test(xmlString)) return xmlString;
47460
+ return xmlString.replace(
47461
+ CONTENT_TYPES_NS,
47462
+ `${CONTENT_TYPES_NS}<Default Extension="${ext}" ContentType="${contentType}"/>`
47463
+ );
47464
+ };
47465
+ const ensureOverride = (xmlString, partName, contentType) => {
47466
+ const esc = partName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
47467
+ const ovRe = new RegExp(`<Override\\s+PartName="${esc}"\\b`, "i");
47468
+ if (ovRe.test(xmlString)) return xmlString;
47469
+ return xmlString.replace(
47470
+ CONTENT_TYPES_NS,
47471
+ `${CONTENT_TYPES_NS}<Override PartName="${partName}" ContentType="${contentType}" />`
47472
+ );
47473
+ };
47474
+ let updated = contentTypesXml;
47475
+ updated = ensureDefault(updated, "rels", "application/vnd.openxmlformats-package.relationships+xml");
47476
+ updated = ensureDefault(updated, "xml", "application/xml");
47477
+ for (const partName of binMediaTargets) {
47478
+ updated = ensureOverride(updated, partName, "image/png");
47479
+ results.push(`Added Content Types Override for "${partName}" as image/png`);
47480
+ }
47481
+ if (updated !== contentTypesXml) {
47482
+ convertedXml[contentTypesKey] = updated;
47483
+ return true;
47484
+ }
47485
+ return false;
47486
+ }
47487
+ function updateContentTypesElements(contentTypesXml, binMediaTargets, results) {
47488
+ const typesRoot = contentTypesXml.elements.find((el) => el.name === "Types") || contentTypesXml.elements[0];
47489
+ typesRoot.elements = typesRoot.elements || [];
47490
+ const hasDefault = (ext) => typesRoot.elements.some((el) => el.name === "Default" && el.attributes?.Extension === ext);
47491
+ const addDefault = (ext, ct) => {
47492
+ typesRoot.elements.unshift({
47493
+ type: "element",
47494
+ name: "Default",
47495
+ attributes: { Extension: ext, ContentType: ct }
47496
+ });
47497
+ };
47498
+ const hasOverride = (part) => typesRoot.elements.some((el) => el.name === "Override" && el.attributes?.PartName === part);
47499
+ const addOverride = (part, ct) => {
47500
+ typesRoot.elements.unshift({
47501
+ type: "element",
47502
+ name: "Override",
47503
+ attributes: { PartName: part, ContentType: ct }
47504
+ });
47505
+ };
47506
+ let wasUpdated = false;
47507
+ if (!hasDefault("rels")) {
47508
+ addDefault("rels", "application/vnd.openxmlformats-package.relationships+xml");
47509
+ wasUpdated = true;
47510
+ }
47511
+ if (!hasDefault("xml")) {
47512
+ addDefault("xml", "application/xml");
47513
+ wasUpdated = true;
47514
+ }
47515
+ for (const partName of binMediaTargets) {
47516
+ if (!hasOverride(partName)) {
47517
+ addOverride(partName, "image/png");
47518
+ results.push(`Added Content Types Override for "${partName}" as image/png`);
47519
+ wasUpdated = true;
47520
+ }
47521
+ }
47522
+ return wasUpdated;
47523
+ }
47524
+ function processDocumentForMissingRefs(node2, usedIds, fixed) {
47525
+ if (!node2?.elements?.length) return;
47526
+ for (const element of node2.elements) {
47527
+ if (element?.type !== "element") continue;
47528
+ const rIdValue = element.attributes?.["r:id"];
47529
+ if (typeof rIdValue === "string" && !usedIds.has(rIdValue)) {
47530
+ delete element.attributes["r:id"];
47531
+ fixed.push(`Removed invalid r:id="${rIdValue}"`);
47532
+ }
47533
+ processDocumentForMissingRefs(element, usedIds, fixed);
47534
+ }
47535
+ }
47189
47536
  const XmlValidators = {
47190
- numberingValidator: createNumberingValidator
47537
+ numberingValidator: createNumberingValidator,
47538
+ relationshipsValidator: createRelationshipsValidator
47191
47539
  };
47192
47540
  class SuperValidator {
47193
47541
  /**
@@ -59628,9 +59976,10 @@ const Link = Mark2.create({
59628
59976
  */
59629
59977
  protocols: ["http", "https"],
59630
59978
  htmlAttributes: {
59631
- target: "_blank",
59979
+ target: null,
59632
59980
  rel: "noopener noreferrer nofollow",
59633
- class: null
59981
+ class: null,
59982
+ title: null
59634
59983
  }
59635
59984
  };
59636
59985
  },
@@ -59659,9 +60008,16 @@ const Link = Mark2.create({
59659
60008
  },
59660
60009
  /**
59661
60010
  * @category Attribute
59662
- * @param {string} [target='_blank'] - Link target window
60011
+ * @param {TargetFrameOptions} [target='_blank'] - Link target window
59663
60012
  */
59664
- target: { default: this.options.htmlAttributes.target },
60013
+ target: {
60014
+ default: this.options.htmlAttributes.target,
60015
+ renderDOM: ({ target, href }) => {
60016
+ if (target) return { target };
60017
+ else if (href && !href.startsWith("#")) return { target: "_blank" };
60018
+ return {};
60019
+ }
60020
+ },
59665
60021
  /**
59666
60022
  * @category Attribute
59667
60023
  * @param {string} [rel='noopener noreferrer nofollow'] - Relationship attributes
@@ -59682,7 +60038,33 @@ const Link = Mark2.create({
59682
60038
  * @category Attribute
59683
60039
  * @param {string} [name] - Anchor name for internal references
59684
60040
  */
59685
- name: { default: null }
60041
+ name: { default: null },
60042
+ /**
60043
+ * @category Attribute
60044
+ * @param {boolean} [history] - Specifies whether the target of the hyperlink shall be added to a list of viewed hyperlinks when it is invoked.
60045
+ */
60046
+ history: { default: true, rendered: false },
60047
+ /**
60048
+ * @category Attribute
60049
+ * @param {string|null} [anchor] - Specifies the name of a bookmark that is the target of this link. If the rId and href attributes are specified, then this attribute is ignored.
60050
+ */
60051
+ anchor: { rendered: false },
60052
+ /**
60053
+ * @category Attribute
60054
+ * @param {string|null} [docLocation] - Specifies a location in the target of the hyperlink.
60055
+ */
60056
+ docLocation: { rendered: false },
60057
+ /**
60058
+ * @category Attribute
60059
+ * @param {string|null} [tooltip] - A tooltip for the link
60060
+ */
60061
+ tooltip: {
60062
+ default: null,
60063
+ renderDOM: ({ tooltip }) => {
60064
+ if (tooltip) return { title: tooltip };
60065
+ return {};
60066
+ }
60067
+ }
59686
60068
  };
59687
60069
  },
59688
60070
  addCommands() {
@@ -80988,9 +81370,9 @@ const _sfc_main = {
80988
81370
  };
80989
81371
  const SuperInput = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-4d5cff52"]]);
80990
81372
  const registeredHandlers = Object.freeze({
80991
- "w:br": translator$3,
80992
- "w:tab": translator$2,
80993
- "w:p": translator$1
81373
+ "w:br": translator$4,
81374
+ "w:tab": translator$3,
81375
+ "w:p": translator$2
80994
81376
  });
80995
81377
  const Extensions = {
80996
81378
  Node: Node$1,