@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
@@ -33293,7 +33293,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33293
33293
  */
33294
33294
  decode(params2) {
33295
33295
  const decodedAttrs = this.decodeAttributes(params2);
33296
- return this.decodeFn ? this.decodeFn(params2, decodedAttrs) : void 0;
33296
+ return this.decodeFn ? this.decodeFn.call(this, params2, decodedAttrs) : void 0;
33297
33297
  }
33298
33298
  /**
33299
33299
  * Encode the attributes for the node.
@@ -33302,7 +33302,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33302
33302
  */
33303
33303
  encode(params2) {
33304
33304
  const encodedAttrs = this.encodeAttributes(params2);
33305
- return this.encodeFn ? this.encodeFn(params2, encodedAttrs) : void 0;
33305
+ return this.encodeFn ? this.encodeFn.call(this, params2, encodedAttrs) : void 0;
33306
33306
  }
33307
33307
  /**
33308
33308
  * Create a new NodeTranslator instance from a configuration object.
@@ -33336,37 +33336,37 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33336
33336
  };
33337
33337
  __publicField$2(_NodeTranslator, "translatorTypes", TranslatorTypes);
33338
33338
  let NodeTranslator = _NodeTranslator;
33339
- const encode$f = (attributes) => {
33339
+ const encode$g = (attributes) => {
33340
33340
  return attributes["w:type"];
33341
33341
  };
33342
- const decode$f = (attrs) => {
33342
+ const decode$g = (attrs) => {
33343
33343
  const { lineBreakType } = attrs;
33344
33344
  return lineBreakType;
33345
33345
  };
33346
33346
  const attrConfig$b = Object.freeze({
33347
33347
  xmlName: "w:type",
33348
33348
  sdName: "lineBreakType",
33349
- encode: encode$f,
33350
- decode: decode$f
33349
+ encode: encode$g,
33350
+ decode: decode$g
33351
33351
  });
33352
- const encode$e = (attributes) => {
33352
+ const encode$f = (attributes) => {
33353
33353
  const xmlAttrValue = attributes["w:clear"];
33354
33354
  return xmlAttrValue;
33355
33355
  };
33356
- const decode$e = (attrs) => {
33356
+ const decode$f = (attrs) => {
33357
33357
  const { clear } = attrs;
33358
33358
  return clear;
33359
33359
  };
33360
33360
  const attrConfig$a = Object.freeze({
33361
33361
  xmlName: "w:clear",
33362
33362
  sdName: "clear",
33363
- encode: encode$e,
33364
- decode: decode$e
33363
+ encode: encode$f,
33364
+ decode: decode$f
33365
33365
  });
33366
- const validXmlAttributes$3 = [attrConfig$b, attrConfig$a];
33367
- const XML_NODE_NAME$3 = "w:br";
33368
- const SD_NODE_NAME$3 = "lineBreak";
33369
- const encode$d = (_2, encodedAttrs) => {
33366
+ const validXmlAttributes$4 = [attrConfig$b, attrConfig$a];
33367
+ const XML_NODE_NAME$4 = "w:br";
33368
+ const SD_NODE_NAME$4 = "lineBreak";
33369
+ const encode$e = (_2, encodedAttrs) => {
33370
33370
  const isPageBreak = encodedAttrs?.lineBreakType === "page";
33371
33371
  const translated = {
33372
33372
  type: isPageBreak ? "hardBreak" : "lineBreak"
@@ -33376,7 +33376,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33376
33376
  }
33377
33377
  return translated;
33378
33378
  };
33379
- const decode$d = (params2, decodedAttrs) => {
33379
+ const decode$e = (params2, decodedAttrs) => {
33380
33380
  const { node: node2 } = params2;
33381
33381
  if (!node2) return;
33382
33382
  const wBreak = { name: "w:br" };
@@ -33393,63 +33393,63 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33393
33393
  };
33394
33394
  return translated;
33395
33395
  };
33396
- const config$3 = {
33397
- xmlName: XML_NODE_NAME$3,
33398
- sdNodeOrKeyName: SD_NODE_NAME$3,
33396
+ const config$4 = {
33397
+ xmlName: XML_NODE_NAME$4,
33398
+ sdNodeOrKeyName: SD_NODE_NAME$4,
33399
33399
  type: NodeTranslator.translatorTypes.NODE,
33400
- encode: encode$d,
33401
- decode: decode$d,
33402
- attributes: validXmlAttributes$3
33400
+ encode: encode$e,
33401
+ decode: decode$e,
33402
+ attributes: validXmlAttributes$4
33403
33403
  };
33404
- const translator$3 = NodeTranslator.from(config$3);
33405
- const encode$c = (attributes) => {
33404
+ const translator$4 = NodeTranslator.from(config$4);
33405
+ const encode$d = (attributes) => {
33406
33406
  return attributes["w:val"];
33407
33407
  };
33408
- const decode$c = (attrs) => {
33408
+ const decode$d = (attrs) => {
33409
33409
  const { tabSize } = attrs || {};
33410
33410
  return tabSize;
33411
33411
  };
33412
33412
  const attrConfig$9 = Object.freeze({
33413
33413
  xmlName: "w:val",
33414
33414
  sdName: "tabSize",
33415
- encode: encode$c,
33416
- decode: decode$c
33415
+ encode: encode$d,
33416
+ decode: decode$d
33417
33417
  });
33418
- const encode$b = (attributes) => {
33418
+ const encode$c = (attributes) => {
33419
33419
  return attributes["w:leader"];
33420
33420
  };
33421
- const decode$b = (attrs) => {
33421
+ const decode$c = (attrs) => {
33422
33422
  const { leader } = attrs || {};
33423
33423
  return leader;
33424
33424
  };
33425
33425
  const attrConfig$8 = Object.freeze({
33426
33426
  xmlName: "w:leader",
33427
33427
  sdName: "leader",
33428
- encode: encode$b,
33429
- decode: decode$b
33428
+ encode: encode$c,
33429
+ decode: decode$c
33430
33430
  });
33431
- const encode$a = (attributes) => {
33431
+ const encode$b = (attributes) => {
33432
33432
  return attributes["w:pos"];
33433
33433
  };
33434
- const decode$a = (attrs) => {
33434
+ const decode$b = (attrs) => {
33435
33435
  const { pos } = attrs || {};
33436
33436
  return pos;
33437
33437
  };
33438
33438
  const attrConfig$7 = Object.freeze({
33439
33439
  xmlName: "w:pos",
33440
33440
  sdName: "pos",
33441
- encode: encode$a,
33442
- decode: decode$a
33441
+ encode: encode$b,
33442
+ decode: decode$b
33443
33443
  });
33444
- const validXmlAttributes$2 = [attrConfig$9, attrConfig$7, attrConfig$8];
33445
- const XML_NODE_NAME$2 = "w:tab";
33446
- const SD_NODE_NAME$2 = "tab";
33447
- const encode$9 = (_2, encodedAttrs = {}) => {
33444
+ const validXmlAttributes$3 = [attrConfig$9, attrConfig$7, attrConfig$8];
33445
+ const XML_NODE_NAME$3 = "w:tab";
33446
+ const SD_NODE_NAME$3 = "tab";
33447
+ const encode$a = (_2, encodedAttrs = {}) => {
33448
33448
  const translated = { type: "tab" };
33449
33449
  if (encodedAttrs) translated.attrs = { ...encodedAttrs };
33450
33450
  return translated;
33451
33451
  };
33452
- const decode$9 = (params2, decodedAttrs = {}) => {
33452
+ const decode$a = (params2, decodedAttrs = {}) => {
33453
33453
  const { node: node2 } = params2 || {};
33454
33454
  if (!node2) return;
33455
33455
  const wTab = { name: "w:tab" };
@@ -33465,15 +33465,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
33465
33465
  }
33466
33466
  return translated;
33467
33467
  };
33468
- const config$2 = {
33469
- xmlName: XML_NODE_NAME$2,
33470
- sdNodeOrKeyName: SD_NODE_NAME$2,
33468
+ const config$3 = {
33469
+ xmlName: XML_NODE_NAME$3,
33470
+ sdNodeOrKeyName: SD_NODE_NAME$3,
33471
33471
  type: NodeTranslator.translatorTypes.NODE,
33472
- encode: encode$9,
33473
- decode: decode$9,
33474
- attributes: validXmlAttributes$2
33472
+ encode: encode$a,
33473
+ decode: decode$a,
33474
+ attributes: validXmlAttributes$3
33475
33475
  };
33476
- const translator$2 = NodeTranslator.from(config$2);
33476
+ const translator$3 = NodeTranslator.from(config$3);
33477
33477
  const mergeTextNodes = (nodes) => {
33478
33478
  if (!nodes || !Array.isArray(nodes)) {
33479
33479
  return nodes;
@@ -34043,91 +34043,91 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34043
34043
  }
34044
34044
  return schemaNode;
34045
34045
  };
34046
- const encode$8 = (attributes) => {
34046
+ const encode$9 = (attributes) => {
34047
34047
  return attributes["w:rsidDel"];
34048
34048
  };
34049
- const decode$8 = (attrs) => {
34049
+ const decode$9 = (attrs) => {
34050
34050
  return attrs.rsidDel;
34051
34051
  };
34052
34052
  const attrConfig$6 = Object.freeze({
34053
34053
  xmlName: "w:rsidDel",
34054
34054
  sdName: "rsidDel",
34055
- encode: encode$8,
34056
- decode: decode$8
34055
+ encode: encode$9,
34056
+ decode: decode$9
34057
34057
  });
34058
- const encode$7 = (attributes) => {
34058
+ const encode$8 = (attributes) => {
34059
34059
  return attributes["w:rsidP"];
34060
34060
  };
34061
- const decode$7 = (attrs) => {
34061
+ const decode$8 = (attrs) => {
34062
34062
  return attrs.rsidP;
34063
34063
  };
34064
34064
  const attrConfig$5 = Object.freeze({
34065
34065
  xmlName: "w:rsidP",
34066
34066
  sdName: "rsidP",
34067
- encode: encode$7,
34068
- decode: decode$7
34067
+ encode: encode$8,
34068
+ decode: decode$8
34069
34069
  });
34070
- const encode$6 = (attributes) => {
34070
+ const encode$7 = (attributes) => {
34071
34071
  return attributes["w:rsidR"];
34072
34072
  };
34073
- const decode$6 = (attrs) => {
34073
+ const decode$7 = (attrs) => {
34074
34074
  return attrs.rsidR;
34075
34075
  };
34076
34076
  const attrConfig$4 = Object.freeze({
34077
34077
  xmlName: "w:rsidR",
34078
34078
  sdName: "rsidR",
34079
- encode: encode$6,
34080
- decode: decode$6
34079
+ encode: encode$7,
34080
+ decode: decode$7
34081
34081
  });
34082
- const encode$5 = (attributes) => {
34082
+ const encode$6 = (attributes) => {
34083
34083
  return attributes["w:rsidRPr"];
34084
34084
  };
34085
- const decode$5 = (attrs) => {
34085
+ const decode$6 = (attrs) => {
34086
34086
  return attrs.rsidRPr;
34087
34087
  };
34088
34088
  const attrConfig$3 = Object.freeze({
34089
34089
  xmlName: "w:rsidRPr",
34090
34090
  sdName: "rsidRPr",
34091
- encode: encode$5,
34092
- decode: decode$5
34091
+ encode: encode$6,
34092
+ decode: decode$6
34093
34093
  });
34094
- const encode$4 = (attributes) => {
34094
+ const encode$5 = (attributes) => {
34095
34095
  return attributes["w:rsidRDefault"];
34096
34096
  };
34097
- const decode$4 = (attrs) => {
34097
+ const decode$5 = (attrs) => {
34098
34098
  return attrs.rsidRDefault;
34099
34099
  };
34100
34100
  const attrConfig$2 = Object.freeze({
34101
34101
  xmlName: "w:rsidRDefault",
34102
34102
  sdName: "rsidRDefault",
34103
- encode: encode$4,
34104
- decode: decode$4
34103
+ encode: encode$5,
34104
+ decode: decode$5
34105
34105
  });
34106
- const encode$3 = (attributes) => {
34106
+ const encode$4 = (attributes) => {
34107
34107
  return attributes["w14:paraId"];
34108
34108
  };
34109
- const decode$3 = (attrs) => {
34109
+ const decode$4 = (attrs) => {
34110
34110
  return attrs.paraId;
34111
34111
  };
34112
34112
  const attrConfig$1 = Object.freeze({
34113
34113
  xmlName: "w14:paraId",
34114
34114
  sdName: "paraId",
34115
- encode: encode$3,
34116
- decode: decode$3
34115
+ encode: encode$4,
34116
+ decode: decode$4
34117
34117
  });
34118
- const encode$2 = (attributes) => {
34118
+ const encode$3 = (attributes) => {
34119
34119
  return attributes["w14:textId"];
34120
34120
  };
34121
- const decode$2 = (attrs) => {
34121
+ const decode$3 = (attrs) => {
34122
34122
  return attrs.textId;
34123
34123
  };
34124
34124
  const attrConfig = Object.freeze({
34125
34125
  xmlName: "w14:textId",
34126
34126
  sdName: "textId",
34127
- encode: encode$2,
34128
- decode: decode$2
34127
+ encode: encode$3,
34128
+ decode: decode$3
34129
34129
  });
34130
- const validXmlAttributes$1 = [
34130
+ const validXmlAttributes$2 = [
34131
34131
  attrConfig$1,
34132
34132
  attrConfig,
34133
34133
  attrConfig$4,
@@ -34136,9 +34136,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34136
34136
  attrConfig$3,
34137
34137
  attrConfig$6
34138
34138
  ];
34139
- const XML_NODE_NAME$1 = "w:p";
34140
- const SD_NODE_NAME$1 = "paragraph";
34141
- const encode$1 = (params2, encodedAttrs = {}) => {
34139
+ const XML_NODE_NAME$2 = "w:p";
34140
+ const SD_NODE_NAME$2 = "paragraph";
34141
+ const encode$2 = (params2, encodedAttrs = {}) => {
34142
34142
  const node2 = handleParagraphNode$1(params2);
34143
34143
  if (!node2) return void 0;
34144
34144
  if (encodedAttrs && Object.keys(encodedAttrs).length) {
@@ -34146,7 +34146,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34146
34146
  }
34147
34147
  return node2;
34148
34148
  };
34149
- const decode$1 = (params2, decodedAttrs = {}) => {
34149
+ const decode$2 = (params2, decodedAttrs = {}) => {
34150
34150
  const translated = translateParagraphNode(params2);
34151
34151
  if (!translated) return void 0;
34152
34152
  if (decodedAttrs && Object.keys(decodedAttrs).length) {
@@ -34154,15 +34154,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34154
34154
  }
34155
34155
  return translated;
34156
34156
  };
34157
- const config$1 = {
34158
- xmlName: XML_NODE_NAME$1,
34159
- sdNodeOrKeyName: SD_NODE_NAME$1,
34157
+ const config$2 = {
34158
+ xmlName: XML_NODE_NAME$2,
34159
+ sdNodeOrKeyName: SD_NODE_NAME$2,
34160
34160
  type: NodeTranslator.translatorTypes.NODE,
34161
- encode: encode$1,
34162
- decode: decode$1,
34163
- attributes: validXmlAttributes$1
34161
+ encode: encode$2,
34162
+ decode: decode$2,
34163
+ attributes: validXmlAttributes$2
34164
34164
  };
34165
- const translator$1 = NodeTranslator.from(config$1);
34165
+ const translator$2 = NodeTranslator.from(config$2);
34166
34166
  const handleAllTableNodes = (params2) => {
34167
34167
  const { nodes } = params2;
34168
34168
  if (nodes.length === 0) {
@@ -34257,7 +34257,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34257
34257
  columnWidth
34258
34258
  }
34259
34259
  };
34260
- const schemaNode = translator.encode(translatorParams);
34260
+ const schemaNode = translator$1.encode(translatorParams);
34261
34261
  return schemaNode;
34262
34262
  }
34263
34263
  function getReferencedTableStyles(tblStyleTag, docx) {
@@ -34659,10 +34659,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34659
34659
  if (left2 != null) elements.push({ name: "w:left", attributes: { "w:w": pixelsToTwips(left2) } });
34660
34660
  return elements;
34661
34661
  }
34662
- const XML_NODE_NAME = "w:tc";
34663
- const SD_NODE_NAME = "tableCell";
34664
- const validXmlAttributes = [];
34665
- function encode$g(params2, encodedAttrs) {
34662
+ const XML_NODE_NAME$1 = "w:tc";
34663
+ const SD_NODE_NAME$1 = "tableCell";
34664
+ const validXmlAttributes$1 = [];
34665
+ function encode$1(params2, encodedAttrs) {
34666
34666
  const { node: node2, table, row, rowBorders, styleTag, columnIndex, columnWidth } = params2.extraParams;
34667
34667
  const schemaNode = handleTableCellNode({
34668
34668
  params: params2,
@@ -34679,18 +34679,123 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34679
34679
  }
34680
34680
  return schemaNode;
34681
34681
  }
34682
- function decode(params2, decodedAttrs) {
34682
+ function decode$1(params2, decodedAttrs) {
34683
34683
  const translated = translateTableCell(params2);
34684
34684
  if (decodedAttrs && Object.keys(decodedAttrs).length) {
34685
34685
  translated.attributes = { ...translated.attributes || {}, ...decodedAttrs };
34686
34686
  }
34687
34687
  return translated;
34688
34688
  }
34689
+ const config$1 = {
34690
+ xmlName: XML_NODE_NAME$1,
34691
+ sdNodeOrKeyName: SD_NODE_NAME$1,
34692
+ type: NodeTranslator.translatorTypes.NODE,
34693
+ encode: encode$1,
34694
+ decode: decode$1,
34695
+ attributes: validXmlAttributes$1
34696
+ };
34697
+ const translator$1 = NodeTranslator.from(config$1);
34698
+ const XML_NODE_NAME = "w:hyperlink";
34699
+ const SD_NODE_NAME = "link";
34700
+ const _createAttributeHandler = (xmlName, sdName) => ({
34701
+ xmlName,
34702
+ sdName,
34703
+ encode: (attributes) => attributes[xmlName],
34704
+ decode: (attributes) => attributes[sdName]
34705
+ });
34706
+ const validXmlAttributes = [
34707
+ _createAttributeHandler("w:anchor", "anchor"),
34708
+ _createAttributeHandler("w:docLocation", "docLocation"),
34709
+ {
34710
+ xmlName: "w:history",
34711
+ sdName: "history",
34712
+ encode: (attributes) => attributes["w:history"] === "1" || attributes["w:history"] === "true",
34713
+ decode: (attributes) => attributes["history"] ? "1" : "0"
34714
+ },
34715
+ _createAttributeHandler("w:tooltip", "tooltip"),
34716
+ _createAttributeHandler("r:id", "rId"),
34717
+ _createAttributeHandler("w:tgtFrame", "target")
34718
+ ];
34719
+ const encode$h = (params2, encodedAttrs) => {
34720
+ const { nodes, docx, nodeListHandler: nodeListHandler2 } = params2;
34721
+ const node2 = nodes[0];
34722
+ let href = _resolveHref(docx, encodedAttrs);
34723
+ const linkMark = { type: "link", attrs: { ...encodedAttrs, href } };
34724
+ const runNodes = node2.elements.filter((el) => el.name === "w:r");
34725
+ runNodes.forEach((runNode) => {
34726
+ runNode.marks = [...runNode.marks || [], linkMark];
34727
+ });
34728
+ const updatedNode = nodeListHandler2.handler({
34729
+ ...params2,
34730
+ nodes: runNodes,
34731
+ path: [...params2.path || [], node2]
34732
+ });
34733
+ return updatedNode;
34734
+ };
34735
+ const _resolveHref = (docx, encodedAttrs) => {
34736
+ const rels = docx["word/_rels/document.xml.rels"];
34737
+ const relationships = rels.elements.find((el) => el.name === "Relationships");
34738
+ const { elements } = relationships;
34739
+ const { rId, anchor } = encodedAttrs;
34740
+ let href;
34741
+ if (!rId && anchor) {
34742
+ href = `#${anchor}`;
34743
+ } else if (rId) {
34744
+ const rel = elements.find((el) => el.attributes["Id"] === rId) || {};
34745
+ const { attributes: relAttributes = {} } = rel;
34746
+ href = relAttributes["Target"];
34747
+ }
34748
+ return href;
34749
+ };
34750
+ function decode(params2, _2) {
34751
+ const { node: node2 } = params2;
34752
+ const linkMark = node2.marks.find((m2) => m2.type === "link");
34753
+ const linkAttrs = this.decodeAttributes({ ...params2, node: linkMark });
34754
+ let { anchor, href: link } = linkMark.attrs;
34755
+ const isExternalLink = !anchor;
34756
+ if (isExternalLink) {
34757
+ linkAttrs["r:id"] = _addNewLinkRelationship(params2, link, linkAttrs["r:id"]);
34758
+ }
34759
+ node2.marks = node2.marks.filter((m2) => m2.type !== "link");
34760
+ const outputNode = exportSchemaToJson({ ...params2, node: node2 });
34761
+ const newNode = {
34762
+ name: "w:hyperlink",
34763
+ type: "element",
34764
+ attributes: {
34765
+ ...linkAttrs
34766
+ },
34767
+ elements: [outputNode]
34768
+ };
34769
+ return newNode;
34770
+ }
34771
+ function _addNewLinkRelationship(params2, link, rId) {
34772
+ if (!rId) rId = generateDocxRandomId();
34773
+ if (!params2.relationships || !Array.isArray(params2.relationships)) {
34774
+ params2.relationships = [];
34775
+ }
34776
+ const existingRel = params2.relationships.find(
34777
+ (rel) => rel.attributes && rel.attributes.Id === rId && rel.attributes.Target === link
34778
+ );
34779
+ if (existingRel) {
34780
+ return rId;
34781
+ }
34782
+ params2.relationships.push({
34783
+ type: "element",
34784
+ name: "Relationship",
34785
+ attributes: {
34786
+ Id: rId,
34787
+ Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
34788
+ Target: link,
34789
+ TargetMode: "External"
34790
+ }
34791
+ });
34792
+ return rId;
34793
+ }
34689
34794
  const config = {
34690
34795
  xmlName: XML_NODE_NAME,
34691
34796
  sdNodeOrKeyName: SD_NODE_NAME,
34692
34797
  type: NodeTranslator.translatorTypes.NODE,
34693
- encode: encode$g,
34798
+ encode: encode$h,
34694
34799
  decode,
34695
34800
  attributes: validXmlAttributes
34696
34801
  };
@@ -34701,19 +34806,19 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34701
34806
  doc: translateDocumentNode,
34702
34807
  body: translateBodyNode,
34703
34808
  heading: translateHeadingNode,
34704
- paragraph: translator$1,
34809
+ paragraph: translator$2,
34705
34810
  text: translateTextNode,
34706
34811
  bulletList: translateList,
34707
34812
  orderedList: translateList,
34708
- lineBreak: translator$3,
34813
+ lineBreak: translator$4,
34709
34814
  table: translateTable,
34710
34815
  tableRow: translateTableRow,
34711
- tableCell: translator,
34816
+ tableCell: translator$1,
34712
34817
  bookmarkStart: translateBookmarkStart,
34713
34818
  fieldAnnotation: translateFieldAnnotation,
34714
- tab: translator$2,
34819
+ tab: translator$3,
34715
34820
  image: translateImageNode,
34716
- hardBreak: translator$3,
34821
+ hardBreak: translator$4,
34717
34822
  commentRangeStart: () => translateCommentNode(params2, "Start"),
34718
34823
  commentRangeEnd: () => translateCommentNode(params2, "End"),
34719
34824
  commentReference: () => null,
@@ -35045,7 +35150,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35045
35150
  const isTrackedNode = node2.marks?.some((m2) => trackedMarks.includes(m2.type));
35046
35151
  if (isTrackedNode) return translateTrackedNode(params2);
35047
35152
  const isLinkNode = node2.marks?.some((m2) => m2.type === "link");
35048
- if (isLinkNode) return translateLinkNode(params2);
35153
+ if (isLinkNode) return translator.decode(params2);
35049
35154
  const { text, marks = [] } = node2;
35050
35155
  return getTextNodeForExport(text, marks, params2);
35051
35156
  }
@@ -35124,27 +35229,6 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35124
35229
  }
35125
35230
  });
35126
35231
  }
35127
- function translateLinkNode(params2) {
35128
- const { node: node2 } = params2;
35129
- const linkMark = node2.marks.find((m2) => m2.type === "link");
35130
- const link = linkMark.attrs.href;
35131
- let rId = linkMark.attrs.rId;
35132
- if (!rId) {
35133
- rId = addNewLinkRelationship(params2, link);
35134
- }
35135
- node2.marks = node2.marks.filter((m2) => m2.type !== "link");
35136
- const outputNode = exportSchemaToJson({ ...params2, node: node2 });
35137
- const contentNode = processLinkContentNode(outputNode);
35138
- const newNode = {
35139
- name: "w:hyperlink",
35140
- type: "element",
35141
- attributes: {
35142
- "r:id": rId
35143
- },
35144
- elements: [contentNode]
35145
- };
35146
- return newNode;
35147
- }
35148
35232
  function processLinkContentNode(node2) {
35149
35233
  if (!node2) return node2;
35150
35234
  const contentNode = carbonCopy(node2);
@@ -36763,57 +36847,22 @@ Please report this to https://github.com/markedjs/marked.`, e) {
36763
36847
  handlerName: "trackChangeNodeHandler",
36764
36848
  handler: handleTrackChangeNode
36765
36849
  };
36766
- const handleHyperlinkNode = (params2) => {
36767
- const { nodes, docx, nodeListHandler: nodeListHandler2 } = params2;
36768
- if (nodes.length === 0 || nodes[0].name !== "w:hyperlink") {
36769
- return { nodes: [], consumed: 0 };
36770
- }
36771
- const node2 = nodes[0];
36772
- const rels = docx["word/_rels/document.xml.rels"];
36773
- const relationships = rels.elements.find((el) => el.name === "Relationships");
36774
- const { elements } = relationships;
36775
- const { attributes } = node2;
36776
- const rId = attributes["r:id"];
36777
- const anchor = attributes["w:anchor"];
36778
- attributes["w:history"];
36779
- const rel = elements.find((el) => el.attributes["Id"] === rId) || {};
36780
- const { attributes: relAttributes = {} } = rel;
36781
- let href = relAttributes["Target"];
36782
- if (anchor && !href) href = `#${anchor}`;
36783
- const runNodes = node2.elements.filter((el) => el.name === "w:r");
36784
- const linkMark = { type: "link", attrs: { href, rId } };
36785
- for (const runNode of runNodes) {
36786
- if (!runNode.marks) runNode.marks = [];
36787
- runNode.marks.push(linkMark);
36788
- const rPr = runNode.elements.find((el) => el.name === "w:rPr");
36789
- if (rPr) {
36790
- const styleRel = rPr.elements.find((el) => el.name === "w:rStyle");
36791
- if (styleRel) {
36792
- const styles = docx["word/styles.xml"];
36793
- const { elements: elements2 } = styles.elements[0];
36794
- const styleElements = elements2.filter((el) => el.name === "w:style");
36795
- const style2 = styleElements.find((el) => el.attributes["w:styleId"] === "Hyperlink");
36796
- const styleRpr = style2?.elements?.find((el) => el.name === "w:rPr");
36797
- if (styleRpr) {
36798
- styleRpr.elements.forEach((styleEl) => {
36799
- const hasElInRPr = rPr.elements.find((el) => el.name === styleEl.name);
36800
- if (!hasElInRPr) rPr.elements.push(styleEl);
36801
- });
36802
- }
36803
- }
36850
+ const generateV2HandlerEntity = (handlerName, translator2) => ({
36851
+ handlerName,
36852
+ handler: (params2) => {
36853
+ const { nodes } = params2;
36854
+ if (nodes.length === 0 || nodes[0].name !== translator2.xmlName) {
36855
+ return { nodes: [], consumed: 0 };
36804
36856
  }
36857
+ const result = translator2.encode(params2);
36858
+ if (!result) return { nodes: [], consumed: 0 };
36859
+ return {
36860
+ nodes: Array.isArray(result) ? result : [result],
36861
+ consumed: 1
36862
+ };
36805
36863
  }
36806
- const updatedNode = nodeListHandler2.handler({
36807
- ...params2,
36808
- nodes: runNodes,
36809
- path: [...params2.path || [], node2]
36810
- });
36811
- return { nodes: updatedNode, consumed: 1 };
36812
- };
36813
- const hyperlinkNodeHandlerEntity = {
36814
- handlerName: "hyperlinkNodeHandler",
36815
- handler: handleHyperlinkNode
36816
- };
36864
+ });
36865
+ const hyperlinkNodeHandlerEntity = generateV2HandlerEntity("hyperlinkNodeHandler", translator);
36817
36866
  const handleRunNode = (params2) => {
36818
36867
  const { nodes, nodeListHandler: nodeListHandler2, parentStyleId, docx } = params2;
36819
36868
  if (nodes.length === 0 || nodes[0].name !== "w:r") {
@@ -36925,7 +36974,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
36925
36974
  if (nodes.length === 0 || nodes[0].name !== "w:p") {
36926
36975
  return { nodes: [], consumed: 0 };
36927
36976
  }
36928
- const schemaNode = translator$1.encode(params2);
36977
+ const schemaNode = translator$2.encode(params2);
36929
36978
  const newNodes = schemaNode ? [schemaNode] : [];
36930
36979
  return { nodes: newNodes, consumed: 1 };
36931
36980
  };
@@ -37238,7 +37287,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
37238
37287
  if (nodes.length === 0 || nodes[0].name !== "w:br") {
37239
37288
  return { nodes: [], consumed: 0 };
37240
37289
  }
37241
- const result = translator$3.encode(params2);
37290
+ const result = translator$4.encode(params2);
37242
37291
  if (!result) return { nodes: [], consumed: 0 };
37243
37292
  return {
37244
37293
  nodes: [result],
@@ -37907,7 +37956,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
37907
37956
  if (!nodes.length || nodes[0].name !== "w:tab") {
37908
37957
  return { nodes: [], consumed: 0 };
37909
37958
  }
37910
- const node2 = translator$2.encode(params2);
37959
+ const node2 = translator$3.encode(params2);
37911
37960
  return { nodes: [node2], consumed: 1 };
37912
37961
  };
37913
37962
  const tabNodeEntityHandler = {
@@ -38435,7 +38484,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
38435
38484
  return;
38436
38485
  }
38437
38486
  }
38438
- static updateDocumentVersion(docx = this.convertedXml, version2 = "0.19.0-next.0") {
38487
+ static updateDocumentVersion(docx = this.convertedXml, version2 = "0.18.1") {
38439
38488
  const customLocation = "docProps/custom.xml";
38440
38489
  if (!docx[customLocation]) {
38441
38490
  docx[customLocation] = generateCustomXml();
@@ -38917,7 +38966,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
38917
38966
  function generateCustomXml() {
38918
38967
  return DEFAULT_CUSTOM_XML;
38919
38968
  }
38920
- function generateSuperdocVersion(pid = 2, version2 = "0.19.0-next.0") {
38969
+ function generateSuperdocVersion(pid = 2, version2 = "0.18.1") {
38921
38970
  return {
38922
38971
  type: "element",
38923
38972
  name: "property",
@@ -54814,8 +54863,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
54814
54863
  let modified = false;
54815
54864
  const results = [];
54816
54865
  links.forEach(({ mark, from: from2, to }) => {
54817
- const { rId, href } = mark.attrs;
54818
- if (!rId && href) {
54866
+ const { rId, href, anchor } = mark.attrs;
54867
+ if (!rId && href && !anchor) {
54819
54868
  let newId = editor.converter.docxHelpers.findRelationshipIdFromTarget(href, editor);
54820
54869
  if (newId) logger.debug("Reusing existing rId for link:", newId, "from pos:", from2, "to pos:", to);
54821
54870
  if (!newId) {
@@ -56091,7 +56140,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
56091
56140
  * @returns {Object | void} Migration results
56092
56141
  */
56093
56142
  processCollaborationMigrations() {
56094
- console.debug("[checkVersionMigrations] Current editor version", "0.19.0-next.0");
56143
+ console.debug("[checkVersionMigrations] Current editor version", "0.18.1");
56095
56144
  if (!this.options.ydoc) return;
56096
56145
  const metaMap = this.options.ydoc.getMap("meta");
56097
56146
  let docVersion = metaMap.get("version");
@@ -66537,11 +66586,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
66537
66586
  ];
66538
66587
  },
66539
66588
  renderDOM({ htmlAttributes }) {
66540
- return [
66541
- "div",
66542
- Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes, { "data-type": this.name }),
66543
- 0
66544
- ];
66589
+ return ["div", Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes, { "data-type": this.name })];
66545
66590
  },
66546
66591
  addCommands() {
66547
66592
  return {
@@ -67642,9 +67687,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
67642
67687
  */
67643
67688
  protocols: ["http", "https"],
67644
67689
  htmlAttributes: {
67645
- target: "_blank",
67690
+ target: null,
67646
67691
  rel: "noopener noreferrer nofollow",
67647
- class: null
67692
+ class: null,
67693
+ title: null
67648
67694
  }
67649
67695
  };
67650
67696
  },
@@ -67673,9 +67719,16 @@ Please report this to https://github.com/markedjs/marked.`, e) {
67673
67719
  },
67674
67720
  /**
67675
67721
  * @category Attribute
67676
- * @param {string} [target='_blank'] - Link target window
67722
+ * @param {TargetFrameOptions} [target='_blank'] - Link target window
67677
67723
  */
67678
- target: { default: this.options.htmlAttributes.target },
67724
+ target: {
67725
+ default: this.options.htmlAttributes.target,
67726
+ renderDOM: ({ target, href }) => {
67727
+ if (target) return { target };
67728
+ else if (href && !href.startsWith("#")) return { target: "_blank" };
67729
+ return {};
67730
+ }
67731
+ },
67679
67732
  /**
67680
67733
  * @category Attribute
67681
67734
  * @param {string} [rel='noopener noreferrer nofollow'] - Relationship attributes
@@ -67696,7 +67749,33 @@ Please report this to https://github.com/markedjs/marked.`, e) {
67696
67749
  * @category Attribute
67697
67750
  * @param {string} [name] - Anchor name for internal references
67698
67751
  */
67699
- name: { default: null }
67752
+ name: { default: null },
67753
+ /**
67754
+ * @category Attribute
67755
+ * @param {boolean} [history] - Specifies whether the target of the hyperlink shall be added to a list of viewed hyperlinks when it is invoked.
67756
+ */
67757
+ history: { default: true, rendered: false },
67758
+ /**
67759
+ * @category Attribute
67760
+ * @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.
67761
+ */
67762
+ anchor: { rendered: false },
67763
+ /**
67764
+ * @category Attribute
67765
+ * @param {string|null} [docLocation] - Specifies a location in the target of the hyperlink.
67766
+ */
67767
+ docLocation: { rendered: false },
67768
+ /**
67769
+ * @category Attribute
67770
+ * @param {string|null} [tooltip] - A tooltip for the link
67771
+ */
67772
+ tooltip: {
67773
+ default: null,
67774
+ renderDOM: ({ tooltip }) => {
67775
+ if (tooltip) return { title: tooltip };
67776
+ return {};
67777
+ }
67778
+ }
67700
67779
  };
67701
67780
  },
67702
67781
  addCommands() {
@@ -89002,9 +89081,9 @@ ${style2}
89002
89081
  };
89003
89082
  const SuperInput = /* @__PURE__ */ _export_sfc$1(_sfc_main$i, [["__scopeId", "data-v-4d5cff52"]]);
89004
89083
  const registeredHandlers = Object.freeze({
89005
- "w:br": translator$3,
89006
- "w:tab": translator$2,
89007
- "w:p": translator$1
89084
+ "w:br": translator$4,
89085
+ "w:tab": translator$3,
89086
+ "w:p": translator$2
89008
89087
  });
89009
89088
  const Extensions = {
89010
89089
  Node: Node$1,
@@ -106176,7 +106255,7 @@ ${style2}
106176
106255
  this.config.colors = shuffleArray(this.config.colors);
106177
106256
  this.userColorMap = /* @__PURE__ */ new Map();
106178
106257
  this.colorIndex = 0;
106179
- this.version = "0.19.0-next.0";
106258
+ this.version = "0.18.1";
106180
106259
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
106181
106260
  this.superdocId = config2.superdocId || v4();
106182
106261
  this.colors = this.config.colors;