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

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-Cjkauq08.cjs} +1 -1
  2. package/dist/chunks/{PdfViewer-BM7Ea3yr.es.js → PdfViewer-DhPox0cw.es.js} +1 -1
  3. package/dist/chunks/{index-CyUWXfUG.es.js → index-CFhFJ_ud.es.js} +3 -3
  4. package/dist/chunks/{index-CPLP-MPz.cjs → index-Cejmh9Gr.cjs} +3 -3
  5. package/dist/chunks/{super-editor.es-CzgdqA6a.es.js → super-editor.es-BdzquZlo.es.js} +568 -186
  6. package/dist/chunks/{super-editor.es-BSOX4l_Z.cjs → super-editor.es-CZMzTdMy.cjs} +568 -186
  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-Dxe9WVzD.js} +226 -177
  10. package/dist/super-editor/chunks/{docx-zipper-CAu7OzVm.js → docx-zipper-DCWGGMK3.js} +1 -1
  11. package/dist/super-editor/chunks/{editor-BZitQIK-.js → editor-hZAeDOwp.js} +344 -11
  12. package/dist/super-editor/chunks/{toolbar-D1SFDkxX.js → toolbar-BuVS5V_M.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 +569 -187
  33. package/dist/superdoc.umd.js.map +1 -1
  34. package/package.json +2 -2
@@ -25557,7 +25557,7 @@ const _NodeTranslator = class _NodeTranslator {
25557
25557
  */
25558
25558
  decode(params) {
25559
25559
  const decodedAttrs = this.decodeAttributes(params);
25560
- return this.decodeFn ? this.decodeFn(params, decodedAttrs) : void 0;
25560
+ return this.decodeFn ? this.decodeFn.call(this, params, decodedAttrs) : void 0;
25561
25561
  }
25562
25562
  /**
25563
25563
  * Encode the attributes for the node.
@@ -25566,7 +25566,7 @@ const _NodeTranslator = class _NodeTranslator {
25566
25566
  */
25567
25567
  encode(params) {
25568
25568
  const encodedAttrs = this.encodeAttributes(params);
25569
- return this.encodeFn ? this.encodeFn(params, encodedAttrs) : void 0;
25569
+ return this.encodeFn ? this.encodeFn.call(this, params, encodedAttrs) : void 0;
25570
25570
  }
25571
25571
  /**
25572
25572
  * Create a new NodeTranslator instance from a configuration object.
@@ -25601,37 +25601,37 @@ const _NodeTranslator = class _NodeTranslator {
25601
25601
  /** @type {typeof TranslatorTypes} */
25602
25602
  __publicField(_NodeTranslator, "translatorTypes", TranslatorTypes);
25603
25603
  let NodeTranslator = _NodeTranslator;
25604
- const encode$f = (attributes) => {
25604
+ const encode$g = (attributes) => {
25605
25605
  return attributes["w:type"];
25606
25606
  };
25607
- const decode$f = (attrs) => {
25607
+ const decode$g = (attrs) => {
25608
25608
  const { lineBreakType } = attrs;
25609
25609
  return lineBreakType;
25610
25610
  };
25611
25611
  const attrConfig$b = Object.freeze({
25612
25612
  xmlName: "w:type",
25613
25613
  sdName: "lineBreakType",
25614
- encode: encode$f,
25615
- decode: decode$f
25614
+ encode: encode$g,
25615
+ decode: decode$g
25616
25616
  });
25617
- const encode$e = (attributes) => {
25617
+ const encode$f = (attributes) => {
25618
25618
  const xmlAttrValue = attributes["w:clear"];
25619
25619
  return xmlAttrValue;
25620
25620
  };
25621
- const decode$e = (attrs) => {
25621
+ const decode$f = (attrs) => {
25622
25622
  const { clear } = attrs;
25623
25623
  return clear;
25624
25624
  };
25625
25625
  const attrConfig$a = Object.freeze({
25626
25626
  xmlName: "w:clear",
25627
25627
  sdName: "clear",
25628
- encode: encode$e,
25629
- decode: decode$e
25628
+ encode: encode$f,
25629
+ decode: decode$f
25630
25630
  });
25631
- const validXmlAttributes$3 = [attrConfig$b, attrConfig$a];
25632
- const XML_NODE_NAME$3 = "w:br";
25633
- const SD_NODE_NAME$3 = "lineBreak";
25634
- const encode$d = (_2, encodedAttrs) => {
25631
+ const validXmlAttributes$4 = [attrConfig$b, attrConfig$a];
25632
+ const XML_NODE_NAME$4 = "w:br";
25633
+ const SD_NODE_NAME$4 = "lineBreak";
25634
+ const encode$e = (_2, encodedAttrs) => {
25635
25635
  const isPageBreak = encodedAttrs?.lineBreakType === "page";
25636
25636
  const translated = {
25637
25637
  type: isPageBreak ? "hardBreak" : "lineBreak"
@@ -25641,7 +25641,7 @@ const encode$d = (_2, encodedAttrs) => {
25641
25641
  }
25642
25642
  return translated;
25643
25643
  };
25644
- const decode$d = (params, decodedAttrs) => {
25644
+ const decode$e = (params, decodedAttrs) => {
25645
25645
  const { node: node2 } = params;
25646
25646
  if (!node2) return;
25647
25647
  const wBreak = { name: "w:br" };
@@ -25658,63 +25658,63 @@ const decode$d = (params, decodedAttrs) => {
25658
25658
  };
25659
25659
  return translated;
25660
25660
  };
25661
- const config$3 = {
25662
- xmlName: XML_NODE_NAME$3,
25663
- sdNodeOrKeyName: SD_NODE_NAME$3,
25661
+ const config$4 = {
25662
+ xmlName: XML_NODE_NAME$4,
25663
+ sdNodeOrKeyName: SD_NODE_NAME$4,
25664
25664
  type: NodeTranslator.translatorTypes.NODE,
25665
- encode: encode$d,
25666
- decode: decode$d,
25667
- attributes: validXmlAttributes$3
25665
+ encode: encode$e,
25666
+ decode: decode$e,
25667
+ attributes: validXmlAttributes$4
25668
25668
  };
25669
- const translator$3 = NodeTranslator.from(config$3);
25670
- const encode$c = (attributes) => {
25669
+ const translator$4 = NodeTranslator.from(config$4);
25670
+ const encode$d = (attributes) => {
25671
25671
  return attributes["w:val"];
25672
25672
  };
25673
- const decode$c = (attrs) => {
25673
+ const decode$d = (attrs) => {
25674
25674
  const { tabSize } = attrs || {};
25675
25675
  return tabSize;
25676
25676
  };
25677
25677
  const attrConfig$9 = Object.freeze({
25678
25678
  xmlName: "w:val",
25679
25679
  sdName: "tabSize",
25680
- encode: encode$c,
25681
- decode: decode$c
25680
+ encode: encode$d,
25681
+ decode: decode$d
25682
25682
  });
25683
- const encode$b = (attributes) => {
25683
+ const encode$c = (attributes) => {
25684
25684
  return attributes["w:leader"];
25685
25685
  };
25686
- const decode$b = (attrs) => {
25686
+ const decode$c = (attrs) => {
25687
25687
  const { leader } = attrs || {};
25688
25688
  return leader;
25689
25689
  };
25690
25690
  const attrConfig$8 = Object.freeze({
25691
25691
  xmlName: "w:leader",
25692
25692
  sdName: "leader",
25693
- encode: encode$b,
25694
- decode: decode$b
25693
+ encode: encode$c,
25694
+ decode: decode$c
25695
25695
  });
25696
- const encode$a = (attributes) => {
25696
+ const encode$b = (attributes) => {
25697
25697
  return attributes["w:pos"];
25698
25698
  };
25699
- const decode$a = (attrs) => {
25699
+ const decode$b = (attrs) => {
25700
25700
  const { pos } = attrs || {};
25701
25701
  return pos;
25702
25702
  };
25703
25703
  const attrConfig$7 = Object.freeze({
25704
25704
  xmlName: "w:pos",
25705
25705
  sdName: "pos",
25706
- encode: encode$a,
25707
- decode: decode$a
25706
+ encode: encode$b,
25707
+ decode: decode$b
25708
25708
  });
25709
- const validXmlAttributes$2 = [attrConfig$9, attrConfig$7, attrConfig$8];
25710
- const XML_NODE_NAME$2 = "w:tab";
25711
- const SD_NODE_NAME$2 = "tab";
25712
- const encode$9 = (_2, encodedAttrs = {}) => {
25709
+ const validXmlAttributes$3 = [attrConfig$9, attrConfig$7, attrConfig$8];
25710
+ const XML_NODE_NAME$3 = "w:tab";
25711
+ const SD_NODE_NAME$3 = "tab";
25712
+ const encode$a = (_2, encodedAttrs = {}) => {
25713
25713
  const translated = { type: "tab" };
25714
25714
  if (encodedAttrs) translated.attrs = { ...encodedAttrs };
25715
25715
  return translated;
25716
25716
  };
25717
- const decode$9 = (params, decodedAttrs = {}) => {
25717
+ const decode$a = (params, decodedAttrs = {}) => {
25718
25718
  const { node: node2 } = params || {};
25719
25719
  if (!node2) return;
25720
25720
  const wTab = { name: "w:tab" };
@@ -25730,15 +25730,15 @@ const decode$9 = (params, decodedAttrs = {}) => {
25730
25730
  }
25731
25731
  return translated;
25732
25732
  };
25733
- const config$2 = {
25734
- xmlName: XML_NODE_NAME$2,
25735
- sdNodeOrKeyName: SD_NODE_NAME$2,
25733
+ const config$3 = {
25734
+ xmlName: XML_NODE_NAME$3,
25735
+ sdNodeOrKeyName: SD_NODE_NAME$3,
25736
25736
  type: NodeTranslator.translatorTypes.NODE,
25737
- encode: encode$9,
25738
- decode: decode$9,
25739
- attributes: validXmlAttributes$2
25737
+ encode: encode$a,
25738
+ decode: decode$a,
25739
+ attributes: validXmlAttributes$3
25740
25740
  };
25741
- const translator$2 = NodeTranslator.from(config$2);
25741
+ const translator$3 = NodeTranslator.from(config$3);
25742
25742
  const mergeTextNodes = (nodes) => {
25743
25743
  if (!nodes || !Array.isArray(nodes)) {
25744
25744
  return nodes;
@@ -26308,91 +26308,91 @@ const handleParagraphNode$1 = (params) => {
26308
26308
  }
26309
26309
  return schemaNode;
26310
26310
  };
26311
- const encode$8 = (attributes) => {
26311
+ const encode$9 = (attributes) => {
26312
26312
  return attributes["w:rsidDel"];
26313
26313
  };
26314
- const decode$8 = (attrs) => {
26314
+ const decode$9 = (attrs) => {
26315
26315
  return attrs.rsidDel;
26316
26316
  };
26317
26317
  const attrConfig$6 = Object.freeze({
26318
26318
  xmlName: "w:rsidDel",
26319
26319
  sdName: "rsidDel",
26320
- encode: encode$8,
26321
- decode: decode$8
26320
+ encode: encode$9,
26321
+ decode: decode$9
26322
26322
  });
26323
- const encode$7 = (attributes) => {
26323
+ const encode$8 = (attributes) => {
26324
26324
  return attributes["w:rsidP"];
26325
26325
  };
26326
- const decode$7 = (attrs) => {
26326
+ const decode$8 = (attrs) => {
26327
26327
  return attrs.rsidP;
26328
26328
  };
26329
26329
  const attrConfig$5 = Object.freeze({
26330
26330
  xmlName: "w:rsidP",
26331
26331
  sdName: "rsidP",
26332
- encode: encode$7,
26333
- decode: decode$7
26332
+ encode: encode$8,
26333
+ decode: decode$8
26334
26334
  });
26335
- const encode$6 = (attributes) => {
26335
+ const encode$7 = (attributes) => {
26336
26336
  return attributes["w:rsidR"];
26337
26337
  };
26338
- const decode$6 = (attrs) => {
26338
+ const decode$7 = (attrs) => {
26339
26339
  return attrs.rsidR;
26340
26340
  };
26341
26341
  const attrConfig$4 = Object.freeze({
26342
26342
  xmlName: "w:rsidR",
26343
26343
  sdName: "rsidR",
26344
- encode: encode$6,
26345
- decode: decode$6
26344
+ encode: encode$7,
26345
+ decode: decode$7
26346
26346
  });
26347
- const encode$5 = (attributes) => {
26347
+ const encode$6 = (attributes) => {
26348
26348
  return attributes["w:rsidRPr"];
26349
26349
  };
26350
- const decode$5 = (attrs) => {
26350
+ const decode$6 = (attrs) => {
26351
26351
  return attrs.rsidRPr;
26352
26352
  };
26353
26353
  const attrConfig$3 = Object.freeze({
26354
26354
  xmlName: "w:rsidRPr",
26355
26355
  sdName: "rsidRPr",
26356
- encode: encode$5,
26357
- decode: decode$5
26356
+ encode: encode$6,
26357
+ decode: decode$6
26358
26358
  });
26359
- const encode$4 = (attributes) => {
26359
+ const encode$5 = (attributes) => {
26360
26360
  return attributes["w:rsidRDefault"];
26361
26361
  };
26362
- const decode$4 = (attrs) => {
26362
+ const decode$5 = (attrs) => {
26363
26363
  return attrs.rsidRDefault;
26364
26364
  };
26365
26365
  const attrConfig$2 = Object.freeze({
26366
26366
  xmlName: "w:rsidRDefault",
26367
26367
  sdName: "rsidRDefault",
26368
- encode: encode$4,
26369
- decode: decode$4
26368
+ encode: encode$5,
26369
+ decode: decode$5
26370
26370
  });
26371
- const encode$3 = (attributes) => {
26371
+ const encode$4 = (attributes) => {
26372
26372
  return attributes["w14:paraId"];
26373
26373
  };
26374
- const decode$3 = (attrs) => {
26374
+ const decode$4 = (attrs) => {
26375
26375
  return attrs.paraId;
26376
26376
  };
26377
26377
  const attrConfig$1 = Object.freeze({
26378
26378
  xmlName: "w14:paraId",
26379
26379
  sdName: "paraId",
26380
- encode: encode$3,
26381
- decode: decode$3
26380
+ encode: encode$4,
26381
+ decode: decode$4
26382
26382
  });
26383
- const encode$2 = (attributes) => {
26383
+ const encode$3 = (attributes) => {
26384
26384
  return attributes["w14:textId"];
26385
26385
  };
26386
- const decode$2 = (attrs) => {
26386
+ const decode$3 = (attrs) => {
26387
26387
  return attrs.textId;
26388
26388
  };
26389
26389
  const attrConfig = Object.freeze({
26390
26390
  xmlName: "w14:textId",
26391
26391
  sdName: "textId",
26392
- encode: encode$2,
26393
- decode: decode$2
26392
+ encode: encode$3,
26393
+ decode: decode$3
26394
26394
  });
26395
- const validXmlAttributes$1 = [
26395
+ const validXmlAttributes$2 = [
26396
26396
  attrConfig$1,
26397
26397
  attrConfig,
26398
26398
  attrConfig$4,
@@ -26401,9 +26401,9 @@ const validXmlAttributes$1 = [
26401
26401
  attrConfig$3,
26402
26402
  attrConfig$6
26403
26403
  ];
26404
- const XML_NODE_NAME$1 = "w:p";
26405
- const SD_NODE_NAME$1 = "paragraph";
26406
- const encode$1 = (params, encodedAttrs = {}) => {
26404
+ const XML_NODE_NAME$2 = "w:p";
26405
+ const SD_NODE_NAME$2 = "paragraph";
26406
+ const encode$2 = (params, encodedAttrs = {}) => {
26407
26407
  const node2 = handleParagraphNode$1(params);
26408
26408
  if (!node2) return void 0;
26409
26409
  if (encodedAttrs && Object.keys(encodedAttrs).length) {
@@ -26411,7 +26411,7 @@ const encode$1 = (params, encodedAttrs = {}) => {
26411
26411
  }
26412
26412
  return node2;
26413
26413
  };
26414
- const decode$1 = (params, decodedAttrs = {}) => {
26414
+ const decode$2 = (params, decodedAttrs = {}) => {
26415
26415
  const translated = translateParagraphNode(params);
26416
26416
  if (!translated) return void 0;
26417
26417
  if (decodedAttrs && Object.keys(decodedAttrs).length) {
@@ -26419,15 +26419,15 @@ const decode$1 = (params, decodedAttrs = {}) => {
26419
26419
  }
26420
26420
  return translated;
26421
26421
  };
26422
- const config$1 = {
26423
- xmlName: XML_NODE_NAME$1,
26424
- sdNodeOrKeyName: SD_NODE_NAME$1,
26422
+ const config$2 = {
26423
+ xmlName: XML_NODE_NAME$2,
26424
+ sdNodeOrKeyName: SD_NODE_NAME$2,
26425
26425
  type: NodeTranslator.translatorTypes.NODE,
26426
- encode: encode$1,
26427
- decode: decode$1,
26428
- attributes: validXmlAttributes$1
26426
+ encode: encode$2,
26427
+ decode: decode$2,
26428
+ attributes: validXmlAttributes$2
26429
26429
  };
26430
- const translator$1 = NodeTranslator.from(config$1);
26430
+ const translator$2 = NodeTranslator.from(config$2);
26431
26431
  const handleAllTableNodes = (params) => {
26432
26432
  const { nodes } = params;
26433
26433
  if (nodes.length === 0) {
@@ -26522,7 +26522,7 @@ function handleTableCellNode$1({
26522
26522
  columnWidth
26523
26523
  }
26524
26524
  };
26525
- const schemaNode = translator.encode(translatorParams);
26525
+ const schemaNode = translator$1.encode(translatorParams);
26526
26526
  return schemaNode;
26527
26527
  }
26528
26528
  function getReferencedTableStyles(tblStyleTag, docx) {
@@ -26924,10 +26924,10 @@ function generateCellMargins(cellMargins) {
26924
26924
  if (left != null) elements.push({ name: "w:left", attributes: { "w:w": pixelsToTwips(left) } });
26925
26925
  return elements;
26926
26926
  }
26927
- const XML_NODE_NAME = "w:tc";
26928
- const SD_NODE_NAME = "tableCell";
26929
- const validXmlAttributes = [];
26930
- function encode(params, encodedAttrs) {
26927
+ const XML_NODE_NAME$1 = "w:tc";
26928
+ const SD_NODE_NAME$1 = "tableCell";
26929
+ const validXmlAttributes$1 = [];
26930
+ function encode$1(params, encodedAttrs) {
26931
26931
  const { node: node2, table, row, rowBorders, styleTag, columnIndex, columnWidth } = params.extraParams;
26932
26932
  const schemaNode = handleTableCellNode({
26933
26933
  params,
@@ -26944,13 +26944,118 @@ function encode(params, encodedAttrs) {
26944
26944
  }
26945
26945
  return schemaNode;
26946
26946
  }
26947
- function decode(params, decodedAttrs) {
26947
+ function decode$1(params, decodedAttrs) {
26948
26948
  const translated = translateTableCell(params);
26949
26949
  if (decodedAttrs && Object.keys(decodedAttrs).length) {
26950
26950
  translated.attributes = { ...translated.attributes || {}, ...decodedAttrs };
26951
26951
  }
26952
26952
  return translated;
26953
26953
  }
26954
+ const config$1 = {
26955
+ xmlName: XML_NODE_NAME$1,
26956
+ sdNodeOrKeyName: SD_NODE_NAME$1,
26957
+ type: NodeTranslator.translatorTypes.NODE,
26958
+ encode: encode$1,
26959
+ decode: decode$1,
26960
+ attributes: validXmlAttributes$1
26961
+ };
26962
+ const translator$1 = NodeTranslator.from(config$1);
26963
+ const XML_NODE_NAME = "w:hyperlink";
26964
+ const SD_NODE_NAME = "link";
26965
+ const _createAttributeHandler = (xmlName, sdName) => ({
26966
+ xmlName,
26967
+ sdName,
26968
+ encode: (attributes) => attributes[xmlName],
26969
+ decode: (attributes) => attributes[sdName]
26970
+ });
26971
+ const validXmlAttributes = [
26972
+ _createAttributeHandler("w:anchor", "anchor"),
26973
+ _createAttributeHandler("w:docLocation", "docLocation"),
26974
+ {
26975
+ xmlName: "w:history",
26976
+ sdName: "history",
26977
+ encode: (attributes) => attributes["w:history"] === "1" || attributes["w:history"] === "true",
26978
+ decode: (attributes) => attributes["history"] ? "1" : "0"
26979
+ },
26980
+ _createAttributeHandler("w:tooltip", "tooltip"),
26981
+ _createAttributeHandler("r:id", "rId"),
26982
+ _createAttributeHandler("w:tgtFrame", "target")
26983
+ ];
26984
+ const encode = (params, encodedAttrs) => {
26985
+ const { nodes, docx, nodeListHandler: nodeListHandler2 } = params;
26986
+ const node2 = nodes[0];
26987
+ let href = _resolveHref(docx, encodedAttrs);
26988
+ const linkMark = { type: "link", attrs: { ...encodedAttrs, href } };
26989
+ const runNodes = node2.elements.filter((el) => el.name === "w:r");
26990
+ runNodes.forEach((runNode) => {
26991
+ runNode.marks = [...runNode.marks || [], linkMark];
26992
+ });
26993
+ const updatedNode = nodeListHandler2.handler({
26994
+ ...params,
26995
+ nodes: runNodes,
26996
+ path: [...params.path || [], node2]
26997
+ });
26998
+ return updatedNode;
26999
+ };
27000
+ const _resolveHref = (docx, encodedAttrs) => {
27001
+ const rels = docx["word/_rels/document.xml.rels"];
27002
+ const relationships = rels.elements.find((el) => el.name === "Relationships");
27003
+ const { elements } = relationships;
27004
+ const { rId, anchor } = encodedAttrs;
27005
+ let href;
27006
+ if (!rId && anchor) {
27007
+ href = `#${anchor}`;
27008
+ } else if (rId) {
27009
+ const rel = elements.find((el) => el.attributes["Id"] === rId) || {};
27010
+ const { attributes: relAttributes = {} } = rel;
27011
+ href = relAttributes["Target"];
27012
+ }
27013
+ return href;
27014
+ };
27015
+ function decode(params, _2) {
27016
+ const { node: node2 } = params;
27017
+ const linkMark = node2.marks.find((m2) => m2.type === "link");
27018
+ const linkAttrs = this.decodeAttributes({ ...params, node: linkMark });
27019
+ let { anchor, href: link } = linkMark.attrs;
27020
+ const isExternalLink = !anchor;
27021
+ if (isExternalLink) {
27022
+ linkAttrs["r:id"] = _addNewLinkRelationship(params, link, linkAttrs["r:id"]);
27023
+ }
27024
+ node2.marks = node2.marks.filter((m2) => m2.type !== "link");
27025
+ const outputNode = exportSchemaToJson({ ...params, node: node2 });
27026
+ const newNode = {
27027
+ name: "w:hyperlink",
27028
+ type: "element",
27029
+ attributes: {
27030
+ ...linkAttrs
27031
+ },
27032
+ elements: [outputNode]
27033
+ };
27034
+ return newNode;
27035
+ }
27036
+ function _addNewLinkRelationship(params, link, rId) {
27037
+ if (!rId) rId = generateDocxRandomId();
27038
+ if (!params.relationships || !Array.isArray(params.relationships)) {
27039
+ params.relationships = [];
27040
+ }
27041
+ const existingRel = params.relationships.find(
27042
+ (rel) => rel.attributes && rel.attributes.Id === rId && rel.attributes.Target === link
27043
+ );
27044
+ if (existingRel) {
27045
+ return rId;
27046
+ }
27047
+ params.relationships.push({
27048
+ type: "element",
27049
+ name: "Relationship",
27050
+ attributes: {
27051
+ Id: rId,
27052
+ Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
27053
+ Target: link,
27054
+ TargetMode: "External"
27055
+ }
27056
+ });
27057
+ return rId;
27058
+ }
26954
27059
  const config = {
26955
27060
  xmlName: XML_NODE_NAME,
26956
27061
  sdNodeOrKeyName: SD_NODE_NAME,
@@ -26966,19 +27071,19 @@ function exportSchemaToJson(params) {
26966
27071
  doc: translateDocumentNode,
26967
27072
  body: translateBodyNode,
26968
27073
  heading: translateHeadingNode,
26969
- paragraph: translator$1,
27074
+ paragraph: translator$2,
26970
27075
  text: translateTextNode,
26971
27076
  bulletList: translateList,
26972
27077
  orderedList: translateList,
26973
- lineBreak: translator$3,
27078
+ lineBreak: translator$4,
26974
27079
  table: translateTable,
26975
27080
  tableRow: translateTableRow,
26976
- tableCell: translator,
27081
+ tableCell: translator$1,
26977
27082
  bookmarkStart: translateBookmarkStart,
26978
27083
  fieldAnnotation: translateFieldAnnotation,
26979
- tab: translator$2,
27084
+ tab: translator$3,
26980
27085
  image: translateImageNode,
26981
- hardBreak: translator$3,
27086
+ hardBreak: translator$4,
26982
27087
  commentRangeStart: () => translateCommentNode(params, "Start"),
26983
27088
  commentRangeEnd: () => translateCommentNode(params, "End"),
26984
27089
  commentReference: () => null,
@@ -27310,7 +27415,7 @@ function translateTextNode(params) {
27310
27415
  const isTrackedNode = node2.marks?.some((m2) => trackedMarks.includes(m2.type));
27311
27416
  if (isTrackedNode) return translateTrackedNode(params);
27312
27417
  const isLinkNode = node2.marks?.some((m2) => m2.type === "link");
27313
- if (isLinkNode) return translateLinkNode(params);
27418
+ if (isLinkNode) return translator.decode(params);
27314
27419
  const { text, marks = [] } = node2;
27315
27420
  return getTextNodeForExport(text, marks, params);
27316
27421
  }
@@ -27389,27 +27494,6 @@ function processOutputMarks(marks = []) {
27389
27494
  }
27390
27495
  });
27391
27496
  }
27392
- function translateLinkNode(params) {
27393
- const { node: node2 } = params;
27394
- const linkMark = node2.marks.find((m2) => m2.type === "link");
27395
- const link = linkMark.attrs.href;
27396
- let rId = linkMark.attrs.rId;
27397
- if (!rId) {
27398
- rId = addNewLinkRelationship(params, link);
27399
- }
27400
- node2.marks = node2.marks.filter((m2) => m2.type !== "link");
27401
- const outputNode = exportSchemaToJson({ ...params, node: node2 });
27402
- const contentNode = processLinkContentNode(outputNode);
27403
- const newNode = {
27404
- name: "w:hyperlink",
27405
- type: "element",
27406
- attributes: {
27407
- "r:id": rId
27408
- },
27409
- elements: [contentNode]
27410
- };
27411
- return newNode;
27412
- }
27413
27497
  function processLinkContentNode(node2) {
27414
27498
  if (!node2) return node2;
27415
27499
  const contentNode = carbonCopy(node2);
@@ -29028,57 +29112,22 @@ const trackChangeNodeHandlerEntity = {
29028
29112
  handlerName: "trackChangeNodeHandler",
29029
29113
  handler: handleTrackChangeNode
29030
29114
  };
29031
- const handleHyperlinkNode = (params) => {
29032
- const { nodes, docx, nodeListHandler: nodeListHandler2 } = params;
29033
- if (nodes.length === 0 || nodes[0].name !== "w:hyperlink") {
29034
- return { nodes: [], consumed: 0 };
29035
- }
29036
- const node2 = nodes[0];
29037
- const rels = docx["word/_rels/document.xml.rels"];
29038
- const relationships = rels.elements.find((el) => el.name === "Relationships");
29039
- const { elements } = relationships;
29040
- const { attributes } = node2;
29041
- const rId = attributes["r:id"];
29042
- const anchor = attributes["w:anchor"];
29043
- attributes["w:history"];
29044
- const rel = elements.find((el) => el.attributes["Id"] === rId) || {};
29045
- const { attributes: relAttributes = {} } = rel;
29046
- let href = relAttributes["Target"];
29047
- if (anchor && !href) href = `#${anchor}`;
29048
- const runNodes = node2.elements.filter((el) => el.name === "w:r");
29049
- const linkMark = { type: "link", attrs: { href, rId } };
29050
- for (const runNode of runNodes) {
29051
- if (!runNode.marks) runNode.marks = [];
29052
- runNode.marks.push(linkMark);
29053
- const rPr = runNode.elements.find((el) => el.name === "w:rPr");
29054
- if (rPr) {
29055
- const styleRel = rPr.elements.find((el) => el.name === "w:rStyle");
29056
- if (styleRel) {
29057
- const styles = docx["word/styles.xml"];
29058
- const { elements: elements2 } = styles.elements[0];
29059
- const styleElements = elements2.filter((el) => el.name === "w:style");
29060
- const style = styleElements.find((el) => el.attributes["w:styleId"] === "Hyperlink");
29061
- const styleRpr = style?.elements?.find((el) => el.name === "w:rPr");
29062
- if (styleRpr) {
29063
- styleRpr.elements.forEach((styleEl) => {
29064
- const hasElInRPr = rPr.elements.find((el) => el.name === styleEl.name);
29065
- if (!hasElInRPr) rPr.elements.push(styleEl);
29066
- });
29067
- }
29068
- }
29069
- }
29115
+ const generateV2HandlerEntity = (handlerName, translator2) => ({
29116
+ handlerName,
29117
+ handler: (params) => {
29118
+ const { nodes } = params;
29119
+ if (nodes.length === 0 || nodes[0].name !== translator2.xmlName) {
29120
+ return { nodes: [], consumed: 0 };
29121
+ }
29122
+ const result = translator2.encode(params);
29123
+ if (!result) return { nodes: [], consumed: 0 };
29124
+ return {
29125
+ nodes: Array.isArray(result) ? result : [result],
29126
+ consumed: 1
29127
+ };
29070
29128
  }
29071
- const updatedNode = nodeListHandler2.handler({
29072
- ...params,
29073
- nodes: runNodes,
29074
- path: [...params.path || [], node2]
29075
- });
29076
- return { nodes: updatedNode, consumed: 1 };
29077
- };
29078
- const hyperlinkNodeHandlerEntity = {
29079
- handlerName: "hyperlinkNodeHandler",
29080
- handler: handleHyperlinkNode
29081
- };
29129
+ });
29130
+ const hyperlinkNodeHandlerEntity = generateV2HandlerEntity("hyperlinkNodeHandler", translator);
29082
29131
  const handleRunNode = (params) => {
29083
29132
  const { nodes, nodeListHandler: nodeListHandler2, parentStyleId, docx } = params;
29084
29133
  if (nodes.length === 0 || nodes[0].name !== "w:r") {
@@ -29190,7 +29239,7 @@ const handleParagraphNode = (params) => {
29190
29239
  if (nodes.length === 0 || nodes[0].name !== "w:p") {
29191
29240
  return { nodes: [], consumed: 0 };
29192
29241
  }
29193
- const schemaNode = translator$1.encode(params);
29242
+ const schemaNode = translator$2.encode(params);
29194
29243
  const newNodes = schemaNode ? [schemaNode] : [];
29195
29244
  return { nodes: newNodes, consumed: 1 };
29196
29245
  };
@@ -29503,7 +29552,7 @@ const handler = (params) => {
29503
29552
  if (nodes.length === 0 || nodes[0].name !== "w:br") {
29504
29553
  return { nodes: [], consumed: 0 };
29505
29554
  }
29506
- const result = translator$3.encode(params);
29555
+ const result = translator$4.encode(params);
29507
29556
  if (!result) return { nodes: [], consumed: 0 };
29508
29557
  return {
29509
29558
  nodes: [result],
@@ -30199,7 +30248,7 @@ const handleTabNode = (params) => {
30199
30248
  if (!nodes.length || nodes[0].name !== "w:tab") {
30200
30249
  return { nodes: [], consumed: 0 };
30201
30250
  }
30202
- const node2 = translator$2.encode(params);
30251
+ const node2 = translator$3.encode(params);
30203
30252
  return { nodes: [node2], consumed: 1 };
30204
30253
  };
30205
30254
  const tabNodeEntityHandler = {
@@ -30727,7 +30776,7 @@ const _SuperConverter = class _SuperConverter {
30727
30776
  return;
30728
30777
  }
30729
30778
  }
30730
- static updateDocumentVersion(docx = this.convertedXml, version = "0.19.0-next.0") {
30779
+ static updateDocumentVersion(docx = this.convertedXml, version = "0.19.0-next.0-alpha") {
30731
30780
  const customLocation = "docProps/custom.xml";
30732
30781
  if (!docx[customLocation]) {
30733
30782
  docx[customLocation] = generateCustomXml();
@@ -31212,7 +31261,7 @@ function storeSuperdocVersion(docx) {
31212
31261
  function generateCustomXml() {
31213
31262
  return DEFAULT_CUSTOM_XML;
31214
31263
  }
31215
- function generateSuperdocVersion(pid = 2, version = "0.19.0-next.0") {
31264
+ function generateSuperdocVersion(pid = 2, version = "0.19.0-next.0-alpha") {
31216
31265
  return {
31217
31266
  type: "element",
31218
31267
  name: "property",
@@ -31280,9 +31329,9 @@ export {
31280
31329
  readFromClipboard as aC,
31281
31330
  handleClipboardPaste as aD,
31282
31331
  getFileObject as aE,
31283
- translator$1 as aF,
31284
- translator$2 as aG,
31285
- translator$3 as aH,
31332
+ translator$2 as aF,
31333
+ translator$3 as aG,
31334
+ translator$4 as aH,
31286
31335
  _sfc_main as aI,
31287
31336
  hasSomeParentWithClass as aa,
31288
31337
  isActive as ab,