@harbour-enterprises/superdoc 0.19.0-next.1 → 0.19.0-next.3

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 (32) hide show
  1. package/dist/chunks/{PdfViewer-C2T9YTtR.cjs → PdfViewer-BXpR6HYz.cjs} +1 -1
  2. package/dist/chunks/{PdfViewer-DXueyp6G.es.js → PdfViewer-e5Sqf3uK.es.js} +1 -1
  3. package/dist/chunks/{index-DYPEIENP.es.js → index-Bgbca9Qo.es.js} +3 -3
  4. package/dist/chunks/{index-Do3Yz9zO.cjs → index-Dg8DEGbE.cjs} +3 -3
  5. package/dist/chunks/{super-editor.es-ehqZe3p-.cjs → super-editor.es-BbN2QJLe.cjs} +269 -190
  6. package/dist/chunks/{super-editor.es-BY32iqnX.es.js → super-editor.es-Dga1v3zZ.es.js} +269 -190
  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-CMajoq-M.js} +226 -177
  10. package/dist/super-editor/chunks/{docx-zipper-CAu7OzVm.js → docx-zipper-C5rg6GNf.js} +1 -1
  11. package/dist/super-editor/chunks/{editor-DJIu60o8.js → editor-CH3sE8Fq.js} +45 -15
  12. package/dist/super-editor/chunks/{toolbar-DYCZq9kV.js → toolbar-BHnLBr61.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/extensions/link/link.d.ts +4 -0
  24. package/dist/super-editor/super-editor.es.js +6 -6
  25. package/dist/super-editor/toolbar.es.js +2 -2
  26. package/dist/super-editor.cjs +1 -1
  27. package/dist/super-editor.es.js +1 -1
  28. package/dist/superdoc.cjs +2 -2
  29. package/dist/superdoc.es.js +2 -2
  30. package/dist/superdoc.umd.js +270 -191
  31. package/dist/superdoc.umd.js.map +1 -1
  32. package/package.json +2 -2
@@ -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 = {
@@ -30720,7 +30769,7 @@ const _SuperConverter = class _SuperConverter2 {
30720
30769
  return;
30721
30770
  }
30722
30771
  }
30723
- static updateDocumentVersion(docx = this.convertedXml, version2 = "0.19.0-next.0") {
30772
+ static updateDocumentVersion(docx = this.convertedXml, version2 = "0.18.1") {
30724
30773
  const customLocation = "docProps/custom.xml";
30725
30774
  if (!docx[customLocation]) {
30726
30775
  docx[customLocation] = generateCustomXml();
@@ -31202,7 +31251,7 @@ function storeSuperdocVersion(docx) {
31202
31251
  function generateCustomXml() {
31203
31252
  return DEFAULT_CUSTOM_XML;
31204
31253
  }
31205
- function generateSuperdocVersion(pid = 2, version2 = "0.19.0-next.0") {
31254
+ function generateSuperdocVersion(pid = 2, version2 = "0.18.1") {
31206
31255
  return {
31207
31256
  type: "element",
31208
31257
  name: "property",
@@ -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) {
@@ -48376,7 +48425,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
48376
48425
  * @returns {Object | void} Migration results
48377
48426
  */
48378
48427
  processCollaborationMigrations() {
48379
- console.debug("[checkVersionMigrations] Current editor version", "0.19.0-next.0");
48428
+ console.debug("[checkVersionMigrations] Current editor version", "0.18.1");
48380
48429
  if (!this.options.ydoc) return;
48381
48430
  const metaMap = this.options.ydoc.getMap("meta");
48382
48431
  let docVersion = metaMap.get("version");
@@ -58822,11 +58871,7 @@ const ContentBlock = Node$1.create({
58822
58871
  ];
58823
58872
  },
58824
58873
  renderDOM({ htmlAttributes }) {
58825
- return [
58826
- "div",
58827
- Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes, { "data-type": this.name }),
58828
- 0
58829
- ];
58874
+ return ["div", Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes, { "data-type": this.name })];
58830
58875
  },
58831
58876
  addCommands() {
58832
58877
  return {
@@ -59927,9 +59972,10 @@ const Link = Mark2.create({
59927
59972
  */
59928
59973
  protocols: ["http", "https"],
59929
59974
  htmlAttributes: {
59930
- target: "_blank",
59975
+ target: null,
59931
59976
  rel: "noopener noreferrer nofollow",
59932
- class: null
59977
+ class: null,
59978
+ title: null
59933
59979
  }
59934
59980
  };
59935
59981
  },
@@ -59958,9 +60004,16 @@ const Link = Mark2.create({
59958
60004
  },
59959
60005
  /**
59960
60006
  * @category Attribute
59961
- * @param {string} [target='_blank'] - Link target window
60007
+ * @param {TargetFrameOptions} [target='_blank'] - Link target window
59962
60008
  */
59963
- target: { default: this.options.htmlAttributes.target },
60009
+ target: {
60010
+ default: this.options.htmlAttributes.target,
60011
+ renderDOM: ({ target, href }) => {
60012
+ if (target) return { target };
60013
+ else if (href && !href.startsWith("#")) return { target: "_blank" };
60014
+ return {};
60015
+ }
60016
+ },
59964
60017
  /**
59965
60018
  * @category Attribute
59966
60019
  * @param {string} [rel='noopener noreferrer nofollow'] - Relationship attributes
@@ -59981,7 +60034,33 @@ const Link = Mark2.create({
59981
60034
  * @category Attribute
59982
60035
  * @param {string} [name] - Anchor name for internal references
59983
60036
  */
59984
- name: { default: null }
60037
+ name: { default: null },
60038
+ /**
60039
+ * @category Attribute
60040
+ * @param {boolean} [history] - Specifies whether the target of the hyperlink shall be added to a list of viewed hyperlinks when it is invoked.
60041
+ */
60042
+ history: { default: true, rendered: false },
60043
+ /**
60044
+ * @category Attribute
60045
+ * @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.
60046
+ */
60047
+ anchor: { rendered: false },
60048
+ /**
60049
+ * @category Attribute
60050
+ * @param {string|null} [docLocation] - Specifies a location in the target of the hyperlink.
60051
+ */
60052
+ docLocation: { rendered: false },
60053
+ /**
60054
+ * @category Attribute
60055
+ * @param {string|null} [tooltip] - A tooltip for the link
60056
+ */
60057
+ tooltip: {
60058
+ default: null,
60059
+ renderDOM: ({ tooltip }) => {
60060
+ if (tooltip) return { title: tooltip };
60061
+ return {};
60062
+ }
60063
+ }
59985
60064
  };
59986
60065
  },
59987
60066
  addCommands() {
@@ -81287,9 +81366,9 @@ const _sfc_main = {
81287
81366
  };
81288
81367
  const SuperInput = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-4d5cff52"]]);
81289
81368
  const registeredHandlers = Object.freeze({
81290
- "w:br": translator$3,
81291
- "w:tab": translator$2,
81292
- "w:p": translator$1
81369
+ "w:br": translator$4,
81370
+ "w:tab": translator$3,
81371
+ "w:p": translator$2
81293
81372
  });
81294
81373
  const Extensions = {
81295
81374
  Node: Node$1,