@harbour-enterprises/superdoc 0.18.1-next.2 → 0.19.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{PdfViewer-DPqO7muc.cjs → PdfViewer-D-X0_rBI.cjs} +1 -1
- package/dist/chunks/{PdfViewer-BM7Ea3yr.es.js → PdfViewer-D59q6eRC.es.js} +1 -1
- package/dist/chunks/{index-CyUWXfUG.es.js → index-DYxO8sGC.es.js} +2 -2
- package/dist/chunks/{index-CPLP-MPz.cjs → index-Q9QnSj8V.cjs} +2 -2
- package/dist/chunks/{super-editor.es-CzgdqA6a.es.js → super-editor.es-DcrpYhcf.es.js} +565 -183
- package/dist/chunks/{super-editor.es-BSOX4l_Z.cjs → super-editor.es-DfRBE7HT.cjs} +565 -183
- package/dist/core/SuperDoc.d.ts.map +1 -1
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-X9LxTGJB.js → converter-C8B4S-1x.js} +224 -175
- package/dist/super-editor/chunks/{docx-zipper-CAu7OzVm.js → docx-zipper-BOcyXVbk.js} +1 -1
- package/dist/super-editor/chunks/{editor-BZitQIK-.js → editor-DSLtHYXL.js} +343 -10
- package/dist/super-editor/chunks/{toolbar-D1SFDkxX.js → toolbar-bgMTmwZ7.js} +2 -2
- package/dist/super-editor/converter.es.js +1 -1
- package/dist/super-editor/docx-zipper.es.js +2 -2
- package/dist/super-editor/editor.es.js +3 -3
- package/dist/super-editor/file-zipper.es.js +1 -1
- package/dist/super-editor/src/core/super-converter/v2/importer/docxImporter.d.ts +2 -2
- package/dist/super-editor/src/core/super-converter/v2/importer/hyperlinkImporter.d.ts +2 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/utils.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/hyperlink/hyperlink-translator.d.ts +7 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/hyperlink/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/node-translator/node-translator.d.ts +2 -1
- package/dist/super-editor/src/core/super-validator/validators/xml/index.d.ts +2 -0
- package/dist/super-editor/src/core/super-validator/validators/xml/relationships/relationships-validator.d.ts +31 -0
- package/dist/super-editor/src/extensions/link/link.d.ts +4 -0
- package/dist/super-editor/super-editor.es.js +6 -6
- package/dist/super-editor/toolbar.es.js +2 -2
- package/dist/super-editor.cjs +1 -1
- package/dist/super-editor.es.js +1 -1
- package/dist/superdoc.cjs +2 -2
- package/dist/superdoc.es.js +2 -2
- package/dist/superdoc.umd.js +565 -183
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/superdoc.umd.js
CHANGED
|
@@ -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$
|
|
33339
|
+
const encode$g = (attributes) => {
|
|
33340
33340
|
return attributes["w:type"];
|
|
33341
33341
|
};
|
|
33342
|
-
const decode$
|
|
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$
|
|
33350
|
-
decode: decode$
|
|
33349
|
+
encode: encode$g,
|
|
33350
|
+
decode: decode$g
|
|
33351
33351
|
});
|
|
33352
|
-
const encode$
|
|
33352
|
+
const encode$f = (attributes) => {
|
|
33353
33353
|
const xmlAttrValue = attributes["w:clear"];
|
|
33354
33354
|
return xmlAttrValue;
|
|
33355
33355
|
};
|
|
33356
|
-
const decode$
|
|
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$
|
|
33364
|
-
decode: decode$
|
|
33363
|
+
encode: encode$f,
|
|
33364
|
+
decode: decode$f
|
|
33365
33365
|
});
|
|
33366
|
-
const validXmlAttributes$
|
|
33367
|
-
const XML_NODE_NAME$
|
|
33368
|
-
const SD_NODE_NAME$
|
|
33369
|
-
const encode$
|
|
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$
|
|
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$
|
|
33397
|
-
xmlName: XML_NODE_NAME$
|
|
33398
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
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$
|
|
33401
|
-
decode: decode$
|
|
33402
|
-
attributes: validXmlAttributes$
|
|
33400
|
+
encode: encode$e,
|
|
33401
|
+
decode: decode$e,
|
|
33402
|
+
attributes: validXmlAttributes$4
|
|
33403
33403
|
};
|
|
33404
|
-
const translator$
|
|
33405
|
-
const encode$
|
|
33404
|
+
const translator$4 = NodeTranslator.from(config$4);
|
|
33405
|
+
const encode$d = (attributes) => {
|
|
33406
33406
|
return attributes["w:val"];
|
|
33407
33407
|
};
|
|
33408
|
-
const decode$
|
|
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$
|
|
33416
|
-
decode: decode$
|
|
33415
|
+
encode: encode$d,
|
|
33416
|
+
decode: decode$d
|
|
33417
33417
|
});
|
|
33418
|
-
const encode$
|
|
33418
|
+
const encode$c = (attributes) => {
|
|
33419
33419
|
return attributes["w:leader"];
|
|
33420
33420
|
};
|
|
33421
|
-
const decode$
|
|
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$
|
|
33429
|
-
decode: decode$
|
|
33428
|
+
encode: encode$c,
|
|
33429
|
+
decode: decode$c
|
|
33430
33430
|
});
|
|
33431
|
-
const encode$
|
|
33431
|
+
const encode$b = (attributes) => {
|
|
33432
33432
|
return attributes["w:pos"];
|
|
33433
33433
|
};
|
|
33434
|
-
const decode$
|
|
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$
|
|
33442
|
-
decode: decode$
|
|
33441
|
+
encode: encode$b,
|
|
33442
|
+
decode: decode$b
|
|
33443
33443
|
});
|
|
33444
|
-
const validXmlAttributes$
|
|
33445
|
-
const XML_NODE_NAME$
|
|
33446
|
-
const SD_NODE_NAME$
|
|
33447
|
-
const encode$
|
|
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$
|
|
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$
|
|
33469
|
-
xmlName: XML_NODE_NAME$
|
|
33470
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
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$
|
|
33473
|
-
decode: decode$
|
|
33474
|
-
attributes: validXmlAttributes$
|
|
33472
|
+
encode: encode$a,
|
|
33473
|
+
decode: decode$a,
|
|
33474
|
+
attributes: validXmlAttributes$3
|
|
33475
33475
|
};
|
|
33476
|
-
const translator$
|
|
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$
|
|
34046
|
+
const encode$9 = (attributes) => {
|
|
34047
34047
|
return attributes["w:rsidDel"];
|
|
34048
34048
|
};
|
|
34049
|
-
const decode$
|
|
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$
|
|
34056
|
-
decode: decode$
|
|
34055
|
+
encode: encode$9,
|
|
34056
|
+
decode: decode$9
|
|
34057
34057
|
});
|
|
34058
|
-
const encode$
|
|
34058
|
+
const encode$8 = (attributes) => {
|
|
34059
34059
|
return attributes["w:rsidP"];
|
|
34060
34060
|
};
|
|
34061
|
-
const decode$
|
|
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$
|
|
34068
|
-
decode: decode$
|
|
34067
|
+
encode: encode$8,
|
|
34068
|
+
decode: decode$8
|
|
34069
34069
|
});
|
|
34070
|
-
const encode$
|
|
34070
|
+
const encode$7 = (attributes) => {
|
|
34071
34071
|
return attributes["w:rsidR"];
|
|
34072
34072
|
};
|
|
34073
|
-
const decode$
|
|
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$
|
|
34080
|
-
decode: decode$
|
|
34079
|
+
encode: encode$7,
|
|
34080
|
+
decode: decode$7
|
|
34081
34081
|
});
|
|
34082
|
-
const encode$
|
|
34082
|
+
const encode$6 = (attributes) => {
|
|
34083
34083
|
return attributes["w:rsidRPr"];
|
|
34084
34084
|
};
|
|
34085
|
-
const decode$
|
|
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$
|
|
34092
|
-
decode: decode$
|
|
34091
|
+
encode: encode$6,
|
|
34092
|
+
decode: decode$6
|
|
34093
34093
|
});
|
|
34094
|
-
const encode$
|
|
34094
|
+
const encode$5 = (attributes) => {
|
|
34095
34095
|
return attributes["w:rsidRDefault"];
|
|
34096
34096
|
};
|
|
34097
|
-
const decode$
|
|
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$
|
|
34104
|
-
decode: decode$
|
|
34103
|
+
encode: encode$5,
|
|
34104
|
+
decode: decode$5
|
|
34105
34105
|
});
|
|
34106
|
-
const encode$
|
|
34106
|
+
const encode$4 = (attributes) => {
|
|
34107
34107
|
return attributes["w14:paraId"];
|
|
34108
34108
|
};
|
|
34109
|
-
const decode$
|
|
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$
|
|
34116
|
-
decode: decode$
|
|
34115
|
+
encode: encode$4,
|
|
34116
|
+
decode: decode$4
|
|
34117
34117
|
});
|
|
34118
|
-
const encode$
|
|
34118
|
+
const encode$3 = (attributes) => {
|
|
34119
34119
|
return attributes["w14:textId"];
|
|
34120
34120
|
};
|
|
34121
|
-
const decode$
|
|
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$
|
|
34128
|
-
decode: decode$
|
|
34127
|
+
encode: encode$3,
|
|
34128
|
+
decode: decode$3
|
|
34129
34129
|
});
|
|
34130
|
-
const validXmlAttributes$
|
|
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$
|
|
34140
|
-
const SD_NODE_NAME$
|
|
34141
|
-
const encode$
|
|
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$
|
|
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$
|
|
34158
|
-
xmlName: XML_NODE_NAME$
|
|
34159
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
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$
|
|
34162
|
-
decode: decode$
|
|
34163
|
-
attributes: validXmlAttributes$
|
|
34161
|
+
encode: encode$2,
|
|
34162
|
+
decode: decode$2,
|
|
34163
|
+
attributes: validXmlAttributes$2
|
|
34164
34164
|
};
|
|
34165
|
-
const translator$
|
|
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$
|
|
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$
|
|
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$
|
|
34809
|
+
paragraph: translator$2,
|
|
34705
34810
|
text: translateTextNode,
|
|
34706
34811
|
bulletList: translateList,
|
|
34707
34812
|
orderedList: translateList,
|
|
34708
|
-
lineBreak: translator$
|
|
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$
|
|
34819
|
+
tab: translator$3,
|
|
34715
34820
|
image: translateImageNode,
|
|
34716
|
-
hardBreak: translator$
|
|
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
|
|
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
|
|
36767
|
-
|
|
36768
|
-
|
|
36769
|
-
|
|
36770
|
-
|
|
36771
|
-
|
|
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
|
-
|
|
36807
|
-
|
|
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$
|
|
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$
|
|
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$
|
|
37959
|
+
const node2 = translator$3.encode(params2);
|
|
37911
37960
|
return { nodes: [node2], consumed: 1 };
|
|
37912
37961
|
};
|
|
37913
37962
|
const tabNodeEntityHandler = {
|
|
@@ -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) {
|
|
@@ -54901,8 +54950,307 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
54901
54950
|
}
|
|
54902
54951
|
node2.elements = next;
|
|
54903
54952
|
}
|
|
54953
|
+
function createRelationshipsValidator({ editor, logger }) {
|
|
54954
|
+
return () => {
|
|
54955
|
+
const results = [];
|
|
54956
|
+
let modified = false;
|
|
54957
|
+
const convertedXml = editor?.converter?.convertedXml;
|
|
54958
|
+
if (!convertedXml || typeof convertedXml !== "object") {
|
|
54959
|
+
return { results, modified };
|
|
54960
|
+
}
|
|
54961
|
+
const { relsKey, wasNormalized } = findAndNormalizeRelationshipsFile(convertedXml, results);
|
|
54962
|
+
if (!relsKey) {
|
|
54963
|
+
return { results, modified };
|
|
54964
|
+
}
|
|
54965
|
+
if (wasNormalized) modified = true;
|
|
54966
|
+
const { root: root2, wasFixed } = validateRelationshipsRoot(convertedXml[relsKey], relsKey, results);
|
|
54967
|
+
if (!root2) {
|
|
54968
|
+
return { results, modified };
|
|
54969
|
+
}
|
|
54970
|
+
if (wasFixed) modified = true;
|
|
54971
|
+
const wasCleaned = cleanupRootChildren(root2);
|
|
54972
|
+
if (wasCleaned) modified = true;
|
|
54973
|
+
const { filteredIds, binMediaTargets, wasProcessed } = processRelationships(root2, convertedXml, results);
|
|
54974
|
+
if (wasProcessed) modified = true;
|
|
54975
|
+
const wasDocumentFixed = fixMissingDocumentRefs(convertedXml, filteredIds, results, logger);
|
|
54976
|
+
if (wasDocumentFixed) modified = true;
|
|
54977
|
+
const contentTypesKey = "[Content_Types].xml";
|
|
54978
|
+
const contentTypesXml = convertedXml[contentTypesKey];
|
|
54979
|
+
if (binMediaTargets.size > 0 || contentTypesXml) {
|
|
54980
|
+
const wasContentTypesUpdated = updateContentTypes(convertedXml, binMediaTargets, results);
|
|
54981
|
+
if (wasContentTypesUpdated) modified = true;
|
|
54982
|
+
} else {
|
|
54983
|
+
results.push("[Content_Types].xml not found or not parseable. Skipped content types patch.");
|
|
54984
|
+
}
|
|
54985
|
+
return { results, modified };
|
|
54986
|
+
};
|
|
54987
|
+
}
|
|
54988
|
+
function findAndNormalizeRelationshipsFile(convertedXml, results) {
|
|
54989
|
+
const candidateKeys = [
|
|
54990
|
+
"word/_rels/document.xml.rels",
|
|
54991
|
+
"word/document.xml.rels",
|
|
54992
|
+
"_rels/document.xml.rels",
|
|
54993
|
+
"document.xml.rels"
|
|
54994
|
+
];
|
|
54995
|
+
const relsKey = candidateKeys.find((k) => convertedXml?.[k]?.elements);
|
|
54996
|
+
if (!relsKey) return { relsKey: null, wasNormalized: false };
|
|
54997
|
+
const canonicalKey = "word/_rels/document.xml.rels";
|
|
54998
|
+
if (relsKey !== canonicalKey) {
|
|
54999
|
+
convertedXml[canonicalKey] = convertedXml[relsKey];
|
|
55000
|
+
delete convertedXml[relsKey];
|
|
55001
|
+
results.push(`Normalized relationships location to ${canonicalKey} (was ${relsKey})`);
|
|
55002
|
+
return { relsKey: canonicalKey, wasNormalized: true };
|
|
55003
|
+
}
|
|
55004
|
+
return { relsKey, wasNormalized: false };
|
|
55005
|
+
}
|
|
55006
|
+
function validateRelationshipsRoot(relsTree, relsKey, results) {
|
|
55007
|
+
const root2 = relsTree?.elements?.[0];
|
|
55008
|
+
if (!root2 || root2.type !== "element") {
|
|
55009
|
+
results.push(`${relsKey} is not a valid xml`);
|
|
55010
|
+
return { root: null, wasFixed: false };
|
|
55011
|
+
}
|
|
55012
|
+
const RELS_NS = "http://schemas.openxmlformats.org/package/2006/relationships";
|
|
55013
|
+
let wasFixed = false;
|
|
55014
|
+
if (root2.name !== "Relationships") {
|
|
55015
|
+
root2.name = "Relationships";
|
|
55016
|
+
results.push(`Fixed relationships root element name to "Relationships"`);
|
|
55017
|
+
wasFixed = true;
|
|
55018
|
+
}
|
|
55019
|
+
root2.attributes = root2.attributes || {};
|
|
55020
|
+
if (root2.attributes.xmlns !== RELS_NS) {
|
|
55021
|
+
root2.attributes.xmlns = RELS_NS;
|
|
55022
|
+
results.push(`Set relationships xmlns to ${RELS_NS}`);
|
|
55023
|
+
wasFixed = true;
|
|
55024
|
+
}
|
|
55025
|
+
return { root: root2, wasFixed };
|
|
55026
|
+
}
|
|
55027
|
+
function cleanupRootChildren(root2, results) {
|
|
55028
|
+
const validChildren = root2.elements?.filter((child) => child?.type === "element" && child.name === "Relationship") || [];
|
|
55029
|
+
if (root2.elements?.length !== validChildren.length) {
|
|
55030
|
+
root2.elements = validChildren;
|
|
55031
|
+
return true;
|
|
55032
|
+
}
|
|
55033
|
+
return false;
|
|
55034
|
+
}
|
|
55035
|
+
function processRelationships(root2, convertedXml, results) {
|
|
55036
|
+
const binMediaTargets = /* @__PURE__ */ new Set();
|
|
55037
|
+
const filteredIds = /* @__PURE__ */ new Set();
|
|
55038
|
+
let wasProcessed = false;
|
|
55039
|
+
const ridNum = (id) => {
|
|
55040
|
+
const m2 = /^rId(\d+)$/.exec(String(id || ""));
|
|
55041
|
+
return m2 ? parseInt(m2[1], 10) : null;
|
|
55042
|
+
};
|
|
55043
|
+
const isType2 = (type2, tail) => typeof type2 === "string" && new RegExp(`/relationships/${tail}$`, "i").test(type2);
|
|
55044
|
+
const isHyperlinkType = (type2) => isType2(type2, "hyperlink");
|
|
55045
|
+
const isImageType = (type2) => isType2(type2, "image");
|
|
55046
|
+
const looksExternal = (target) => /^https?:\/\//i.test(target || "") || /^mailto:/i.test(target || "");
|
|
55047
|
+
const usedIds = /* @__PURE__ */ new Set();
|
|
55048
|
+
let maxRid = 0;
|
|
55049
|
+
for (const el of root2.elements) {
|
|
55050
|
+
el.attributes = el.attributes || {};
|
|
55051
|
+
const id = el.attributes.Id;
|
|
55052
|
+
const n = ridNum(id);
|
|
55053
|
+
if (Number.isInteger(n)) maxRid = Math.max(maxRid, n);
|
|
55054
|
+
if (typeof id === "string" && id) {
|
|
55055
|
+
usedIds.add(id);
|
|
55056
|
+
}
|
|
55057
|
+
}
|
|
55058
|
+
let ridCounter = maxRid;
|
|
55059
|
+
const allocateId = (preferred) => {
|
|
55060
|
+
let newId;
|
|
55061
|
+
do {
|
|
55062
|
+
ridCounter += 1;
|
|
55063
|
+
newId = `rId${ridCounter}`;
|
|
55064
|
+
} while (usedIds.has(newId));
|
|
55065
|
+
usedIds.add(newId);
|
|
55066
|
+
return newId;
|
|
55067
|
+
};
|
|
55068
|
+
const seenIds = /* @__PURE__ */ new Set();
|
|
55069
|
+
const filtered = [];
|
|
55070
|
+
function extractStringAttr(attrs, key) {
|
|
55071
|
+
return typeof attrs[key] === "string" ? attrs[key].trim() : "";
|
|
55072
|
+
}
|
|
55073
|
+
for (const rel of root2.elements) {
|
|
55074
|
+
rel.attributes = rel.attributes || {};
|
|
55075
|
+
const attrs = rel.attributes;
|
|
55076
|
+
let id = extractStringAttr(attrs, "Id");
|
|
55077
|
+
const type2 = extractStringAttr(attrs, "Type");
|
|
55078
|
+
let target = extractStringAttr(attrs, "Target");
|
|
55079
|
+
let targetMode = extractStringAttr(attrs, "TargetMode");
|
|
55080
|
+
if (!target) {
|
|
55081
|
+
results.push(`Removed relationship "${id}" without Target`);
|
|
55082
|
+
wasProcessed = true;
|
|
55083
|
+
continue;
|
|
55084
|
+
}
|
|
55085
|
+
if (isHyperlinkType(type2) && looksExternal(target) && targetMode.toLowerCase() !== "external") {
|
|
55086
|
+
attrs.TargetMode = "External";
|
|
55087
|
+
targetMode = "External";
|
|
55088
|
+
results.push(`Set TargetMode="External" for hyperlink ${id}`);
|
|
55089
|
+
wasProcessed = true;
|
|
55090
|
+
}
|
|
55091
|
+
if (isImageType(type2)) {
|
|
55092
|
+
const relPath = `word/${target.replace(/^\.?\//, "")}`;
|
|
55093
|
+
if (/^media\/.+\.bin$/i.test(target) && relPath in convertedXml) {
|
|
55094
|
+
binMediaTargets.add(`/${relPath}`);
|
|
55095
|
+
}
|
|
55096
|
+
}
|
|
55097
|
+
if (targetMode.toLowerCase() !== "external" && !looksExternal(target)) {
|
|
55098
|
+
const likelyPath = `word/${target.replace(/^\.?\//, "")}`;
|
|
55099
|
+
if (!(likelyPath in convertedXml)) {
|
|
55100
|
+
if (!isImageType(type2)) {
|
|
55101
|
+
results.push(`Removed relationship ${id} with missing target: ${target}`);
|
|
55102
|
+
wasProcessed = true;
|
|
55103
|
+
continue;
|
|
55104
|
+
} else {
|
|
55105
|
+
results.push(`Warning: image relationship ${id} target not found: ${target}.`);
|
|
55106
|
+
}
|
|
55107
|
+
}
|
|
55108
|
+
}
|
|
55109
|
+
if (!id) {
|
|
55110
|
+
const newId = allocateId();
|
|
55111
|
+
attrs.Id = newId;
|
|
55112
|
+
results.push(`Assigned missing Id "${newId}"`);
|
|
55113
|
+
wasProcessed = true;
|
|
55114
|
+
id = newId;
|
|
55115
|
+
}
|
|
55116
|
+
if (seenIds.has(id)) {
|
|
55117
|
+
results.push(`Removed duplicate relationship with ID "${id}"`);
|
|
55118
|
+
wasProcessed = true;
|
|
55119
|
+
continue;
|
|
55120
|
+
}
|
|
55121
|
+
seenIds.add(id);
|
|
55122
|
+
filtered.push(rel);
|
|
55123
|
+
}
|
|
55124
|
+
if (root2.elements.length !== filtered.length) {
|
|
55125
|
+
root2.elements = filtered;
|
|
55126
|
+
wasProcessed = true;
|
|
55127
|
+
} else {
|
|
55128
|
+
const contentChanged = root2.elements.some((el, i2) => el !== filtered[i2]);
|
|
55129
|
+
if (contentChanged) {
|
|
55130
|
+
root2.elements = filtered;
|
|
55131
|
+
wasProcessed = true;
|
|
55132
|
+
}
|
|
55133
|
+
}
|
|
55134
|
+
for (const rel of root2.elements) {
|
|
55135
|
+
const id = rel.attributes?.Id;
|
|
55136
|
+
if (typeof id === "string" && id) {
|
|
55137
|
+
filteredIds.add(id);
|
|
55138
|
+
}
|
|
55139
|
+
}
|
|
55140
|
+
return { filteredIds, binMediaTargets, wasProcessed };
|
|
55141
|
+
}
|
|
55142
|
+
function fixMissingDocumentRefs(convertedXml, filteredIds, results, logger) {
|
|
55143
|
+
const documentPath = "word/document.xml";
|
|
55144
|
+
const document2 = convertedXml[documentPath];
|
|
55145
|
+
if (document2?.elements?.length) {
|
|
55146
|
+
const documentRoot = document2.elements[0];
|
|
55147
|
+
if (documentRoot?.type === "element") {
|
|
55148
|
+
const missingRefs = [];
|
|
55149
|
+
processDocumentForMissingRefs(documentRoot, filteredIds, missingRefs);
|
|
55150
|
+
if (missingRefs.length) {
|
|
55151
|
+
results.push(`Fixed ${missingRefs.length} missing relationship references`);
|
|
55152
|
+
logger?.debug?.(`Fixed ${missingRefs.length} missing relationship references in document`);
|
|
55153
|
+
return true;
|
|
55154
|
+
}
|
|
55155
|
+
}
|
|
55156
|
+
}
|
|
55157
|
+
return false;
|
|
55158
|
+
}
|
|
55159
|
+
function updateContentTypes(convertedXml, binMediaTargets, results) {
|
|
55160
|
+
const contentTypesKey = "[Content_Types].xml";
|
|
55161
|
+
const contentTypesXml = convertedXml[contentTypesKey];
|
|
55162
|
+
if (typeof contentTypesXml === "string") {
|
|
55163
|
+
return updateContentTypesString(contentTypesXml, binMediaTargets, results, convertedXml, contentTypesKey);
|
|
55164
|
+
} else if (contentTypesXml?.elements?.length) {
|
|
55165
|
+
return updateContentTypesElements(contentTypesXml, binMediaTargets, results);
|
|
55166
|
+
} else {
|
|
55167
|
+
return false;
|
|
55168
|
+
}
|
|
55169
|
+
}
|
|
55170
|
+
function updateContentTypesString(contentTypesXml, binMediaTargets, results, convertedXml, contentTypesKey) {
|
|
55171
|
+
const CONTENT_TYPES_NS = '<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">';
|
|
55172
|
+
const ensureDefault = (xmlString, ext, contentType) => {
|
|
55173
|
+
const defRe = new RegExp(`<Default\\s+Extension="${ext}"\\b`, "i");
|
|
55174
|
+
if (defRe.test(xmlString)) return xmlString;
|
|
55175
|
+
return xmlString.replace(
|
|
55176
|
+
CONTENT_TYPES_NS,
|
|
55177
|
+
`${CONTENT_TYPES_NS}<Default Extension="${ext}" ContentType="${contentType}"/>`
|
|
55178
|
+
);
|
|
55179
|
+
};
|
|
55180
|
+
const ensureOverride = (xmlString, partName, contentType) => {
|
|
55181
|
+
const esc = partName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
55182
|
+
const ovRe = new RegExp(`<Override\\s+PartName="${esc}"\\b`, "i");
|
|
55183
|
+
if (ovRe.test(xmlString)) return xmlString;
|
|
55184
|
+
return xmlString.replace(
|
|
55185
|
+
CONTENT_TYPES_NS,
|
|
55186
|
+
`${CONTENT_TYPES_NS}<Override PartName="${partName}" ContentType="${contentType}" />`
|
|
55187
|
+
);
|
|
55188
|
+
};
|
|
55189
|
+
let updated = contentTypesXml;
|
|
55190
|
+
updated = ensureDefault(updated, "rels", "application/vnd.openxmlformats-package.relationships+xml");
|
|
55191
|
+
updated = ensureDefault(updated, "xml", "application/xml");
|
|
55192
|
+
for (const partName of binMediaTargets) {
|
|
55193
|
+
updated = ensureOverride(updated, partName, "image/png");
|
|
55194
|
+
results.push(`Added Content Types Override for "${partName}" as image/png`);
|
|
55195
|
+
}
|
|
55196
|
+
if (updated !== contentTypesXml) {
|
|
55197
|
+
convertedXml[contentTypesKey] = updated;
|
|
55198
|
+
return true;
|
|
55199
|
+
}
|
|
55200
|
+
return false;
|
|
55201
|
+
}
|
|
55202
|
+
function updateContentTypesElements(contentTypesXml, binMediaTargets, results) {
|
|
55203
|
+
const typesRoot = contentTypesXml.elements.find((el) => el.name === "Types") || contentTypesXml.elements[0];
|
|
55204
|
+
typesRoot.elements = typesRoot.elements || [];
|
|
55205
|
+
const hasDefault = (ext) => typesRoot.elements.some((el) => el.name === "Default" && el.attributes?.Extension === ext);
|
|
55206
|
+
const addDefault = (ext, ct) => {
|
|
55207
|
+
typesRoot.elements.unshift({
|
|
55208
|
+
type: "element",
|
|
55209
|
+
name: "Default",
|
|
55210
|
+
attributes: { Extension: ext, ContentType: ct }
|
|
55211
|
+
});
|
|
55212
|
+
};
|
|
55213
|
+
const hasOverride = (part) => typesRoot.elements.some((el) => el.name === "Override" && el.attributes?.PartName === part);
|
|
55214
|
+
const addOverride = (part, ct) => {
|
|
55215
|
+
typesRoot.elements.unshift({
|
|
55216
|
+
type: "element",
|
|
55217
|
+
name: "Override",
|
|
55218
|
+
attributes: { PartName: part, ContentType: ct }
|
|
55219
|
+
});
|
|
55220
|
+
};
|
|
55221
|
+
let wasUpdated = false;
|
|
55222
|
+
if (!hasDefault("rels")) {
|
|
55223
|
+
addDefault("rels", "application/vnd.openxmlformats-package.relationships+xml");
|
|
55224
|
+
wasUpdated = true;
|
|
55225
|
+
}
|
|
55226
|
+
if (!hasDefault("xml")) {
|
|
55227
|
+
addDefault("xml", "application/xml");
|
|
55228
|
+
wasUpdated = true;
|
|
55229
|
+
}
|
|
55230
|
+
for (const partName of binMediaTargets) {
|
|
55231
|
+
if (!hasOverride(partName)) {
|
|
55232
|
+
addOverride(partName, "image/png");
|
|
55233
|
+
results.push(`Added Content Types Override for "${partName}" as image/png`);
|
|
55234
|
+
wasUpdated = true;
|
|
55235
|
+
}
|
|
55236
|
+
}
|
|
55237
|
+
return wasUpdated;
|
|
55238
|
+
}
|
|
55239
|
+
function processDocumentForMissingRefs(node2, usedIds, fixed) {
|
|
55240
|
+
if (!node2?.elements?.length) return;
|
|
55241
|
+
for (const element of node2.elements) {
|
|
55242
|
+
if (element?.type !== "element") continue;
|
|
55243
|
+
const rIdValue = element.attributes?.["r:id"];
|
|
55244
|
+
if (typeof rIdValue === "string" && !usedIds.has(rIdValue)) {
|
|
55245
|
+
delete element.attributes["r:id"];
|
|
55246
|
+
fixed.push(`Removed invalid r:id="${rIdValue}"`);
|
|
55247
|
+
}
|
|
55248
|
+
processDocumentForMissingRefs(element, usedIds, fixed);
|
|
55249
|
+
}
|
|
55250
|
+
}
|
|
54904
55251
|
const XmlValidators = {
|
|
54905
|
-
numberingValidator: createNumberingValidator
|
|
55252
|
+
numberingValidator: createNumberingValidator,
|
|
55253
|
+
relationshipsValidator: createRelationshipsValidator
|
|
54906
55254
|
};
|
|
54907
55255
|
class SuperValidator {
|
|
54908
55256
|
/**
|
|
@@ -67343,9 +67691,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
67343
67691
|
*/
|
|
67344
67692
|
protocols: ["http", "https"],
|
|
67345
67693
|
htmlAttributes: {
|
|
67346
|
-
target:
|
|
67694
|
+
target: null,
|
|
67347
67695
|
rel: "noopener noreferrer nofollow",
|
|
67348
|
-
class: null
|
|
67696
|
+
class: null,
|
|
67697
|
+
title: null
|
|
67349
67698
|
}
|
|
67350
67699
|
};
|
|
67351
67700
|
},
|
|
@@ -67374,9 +67723,16 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
67374
67723
|
},
|
|
67375
67724
|
/**
|
|
67376
67725
|
* @category Attribute
|
|
67377
|
-
* @param {
|
|
67726
|
+
* @param {TargetFrameOptions} [target='_blank'] - Link target window
|
|
67378
67727
|
*/
|
|
67379
|
-
target: {
|
|
67728
|
+
target: {
|
|
67729
|
+
default: this.options.htmlAttributes.target,
|
|
67730
|
+
renderDOM: ({ target, href }) => {
|
|
67731
|
+
if (target) return { target };
|
|
67732
|
+
else if (href && !href.startsWith("#")) return { target: "_blank" };
|
|
67733
|
+
return {};
|
|
67734
|
+
}
|
|
67735
|
+
},
|
|
67380
67736
|
/**
|
|
67381
67737
|
* @category Attribute
|
|
67382
67738
|
* @param {string} [rel='noopener noreferrer nofollow'] - Relationship attributes
|
|
@@ -67397,7 +67753,33 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
67397
67753
|
* @category Attribute
|
|
67398
67754
|
* @param {string} [name] - Anchor name for internal references
|
|
67399
67755
|
*/
|
|
67400
|
-
name: { default: null }
|
|
67756
|
+
name: { default: null },
|
|
67757
|
+
/**
|
|
67758
|
+
* @category Attribute
|
|
67759
|
+
* @param {boolean} [history] - Specifies whether the target of the hyperlink shall be added to a list of viewed hyperlinks when it is invoked.
|
|
67760
|
+
*/
|
|
67761
|
+
history: { default: true, rendered: false },
|
|
67762
|
+
/**
|
|
67763
|
+
* @category Attribute
|
|
67764
|
+
* @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.
|
|
67765
|
+
*/
|
|
67766
|
+
anchor: { rendered: false },
|
|
67767
|
+
/**
|
|
67768
|
+
* @category Attribute
|
|
67769
|
+
* @param {string|null} [docLocation] - Specifies a location in the target of the hyperlink.
|
|
67770
|
+
*/
|
|
67771
|
+
docLocation: { rendered: false },
|
|
67772
|
+
/**
|
|
67773
|
+
* @category Attribute
|
|
67774
|
+
* @param {string|null} [tooltip] - A tooltip for the link
|
|
67775
|
+
*/
|
|
67776
|
+
tooltip: {
|
|
67777
|
+
default: null,
|
|
67778
|
+
renderDOM: ({ tooltip }) => {
|
|
67779
|
+
if (tooltip) return { title: tooltip };
|
|
67780
|
+
return {};
|
|
67781
|
+
}
|
|
67782
|
+
}
|
|
67401
67783
|
};
|
|
67402
67784
|
},
|
|
67403
67785
|
addCommands() {
|
|
@@ -88703,9 +89085,9 @@ ${style2}
|
|
|
88703
89085
|
};
|
|
88704
89086
|
const SuperInput = /* @__PURE__ */ _export_sfc$1(_sfc_main$i, [["__scopeId", "data-v-4d5cff52"]]);
|
|
88705
89087
|
const registeredHandlers = Object.freeze({
|
|
88706
|
-
"w:br": translator$
|
|
88707
|
-
"w:tab": translator$
|
|
88708
|
-
"w:p": translator$
|
|
89088
|
+
"w:br": translator$4,
|
|
89089
|
+
"w:tab": translator$3,
|
|
89090
|
+
"w:p": translator$2
|
|
88709
89091
|
});
|
|
88710
89092
|
const Extensions = {
|
|
88711
89093
|
Node: Node$1,
|