@harbour-enterprises/superdoc 0.20.0-next.2 → 0.20.0-next.4
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-_tL5RYr9.es.js → PdfViewer-BjZBgs8x.es.js} +1 -1
- package/dist/chunks/{PdfViewer-B6adMXJl.cjs → PdfViewer-Ne_-LxpG.cjs} +1 -1
- package/dist/chunks/{index-DwXeHvLq.es.js → index-BVjAJUtV.es.js} +2 -2
- package/dist/chunks/{index-mjjKSLDT.cjs → index-OFvCtpf7.cjs} +2 -2
- package/dist/chunks/{super-editor.es-DJHyk0Zs.cjs → super-editor.es-CCU9etUT.cjs} +1101 -715
- package/dist/chunks/{super-editor.es-CPrd1wq8.es.js → super-editor.es-DgTNVbvS.es.js} +1101 -715
- package/dist/core/SuperDoc.d.ts.map +1 -1
- package/dist/style.css +38 -0
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-KHB8spG5.js → converter-BPTfSIJf.js} +919 -813
- package/dist/super-editor/chunks/{docx-zipper-B-vl4ISA.js → docx-zipper-ikgI-2vM.js} +1 -1
- package/dist/super-editor/chunks/{editor-Df2sUgT0.js → editor-C1C_smD4.js} +294 -10
- package/dist/super-editor/chunks/{toolbar-C6JoUIM_.js → toolbar-pP4CmNcz.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/helpers/index.d.ts +1 -0
- package/dist/super-editor/src/core/helpers/updateDOMAttributes.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/exporter.d.ts +7 -1
- package/dist/super-editor/src/core/super-converter/v2/importer/imageImporter.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/index.d.ts +2 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/drawing/drawing-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/drawing/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/anchor/anchor-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/anchor/helpers/handle-anchor-node.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/anchor/helpers/translate-anchor-node.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/anchor/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/helpers/decode-image-node-helpers.d.ts +18 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/helpers/encode-image-node-helpers.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/inline/helpers/handle-inline-node.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/inline/helpers/translate-inline-node.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/inline/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/inline/inline-translator.d.ts +6 -0
- package/dist/super-editor/src/extensions/structured-content/StructuredContentBlockView.d.ts +10 -0
- package/dist/super-editor/src/extensions/structured-content/StructuredContentInlineView.d.ts +10 -0
- package/dist/super-editor/src/extensions/structured-content/StructuredContentViewBase.d.ts +24 -0
- package/dist/super-editor/src/extensions/structured-content/structured-content-block.d.ts +3 -1
- package/dist/super-editor/src/extensions/structured-content/structured-content.d.ts +3 -1
- package/dist/super-editor/style.css +38 -0
- package/dist/super-editor/super-editor.es.js +8 -13
- 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 +1101 -715
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -21371,7 +21371,7 @@ const isInTable = (state2) => {
|
|
|
21371
21371
|
};
|
|
21372
21372
|
function stripHtmlStyles(html) {
|
|
21373
21373
|
if (!html) return "";
|
|
21374
|
-
const parser = new DOMParser();
|
|
21374
|
+
const parser = new window.DOMParser();
|
|
21375
21375
|
const doc2 = parser.parseFromString(html, "text/html");
|
|
21376
21376
|
const SUPPORTED_ATTRS = [
|
|
21377
21377
|
"href",
|
|
@@ -21390,7 +21390,7 @@ function stripHtmlStyles(html) {
|
|
|
21390
21390
|
"styleid"
|
|
21391
21391
|
];
|
|
21392
21392
|
const cleanNode = (node) => {
|
|
21393
|
-
if (node.nodeType !== Node.ELEMENT_NODE) return;
|
|
21393
|
+
if (node.nodeType !== window.Node.ELEMENT_NODE) return;
|
|
21394
21394
|
[...node.attributes].forEach((attr) => {
|
|
21395
21395
|
const name = attr.name.toLowerCase();
|
|
21396
21396
|
const shouldKeep = SUPPORTED_ATTRS.includes(name) || name.startsWith("data-");
|
|
@@ -22533,6 +22533,23 @@ function processContent({ content, type: type2, schema }) {
|
|
|
22533
22533
|
}
|
|
22534
22534
|
return doc2;
|
|
22535
22535
|
}
|
|
22536
|
+
const defaultBooleans = ["required", "readonly", "disabled", "checked", "multiple", "autofocus"];
|
|
22537
|
+
function updateDOMAttributes(dom, attrs = {}, options = {}) {
|
|
22538
|
+
const customBooleans = options.customBooleans || [];
|
|
22539
|
+
const booleans = [...defaultBooleans, ...customBooleans];
|
|
22540
|
+
Object.entries(attrs).forEach(([key, value]) => {
|
|
22541
|
+
if (booleans.includes(key)) {
|
|
22542
|
+
if (!value) dom.removeAttribute(key);
|
|
22543
|
+
else dom.setAttribute(key, "");
|
|
22544
|
+
return;
|
|
22545
|
+
}
|
|
22546
|
+
if (value != null) {
|
|
22547
|
+
dom.setAttribute(key, value);
|
|
22548
|
+
} else {
|
|
22549
|
+
dom.removeAttribute(key);
|
|
22550
|
+
}
|
|
22551
|
+
});
|
|
22552
|
+
}
|
|
22536
22553
|
const helpers = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
22537
22554
|
__proto__: null,
|
|
22538
22555
|
chainableEditorState,
|
|
@@ -22565,7 +22582,8 @@ const helpers = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePrope
|
|
|
22565
22582
|
isNodeActive,
|
|
22566
22583
|
isTextSelection,
|
|
22567
22584
|
posToDOMRect,
|
|
22568
|
-
processContent
|
|
22585
|
+
processContent,
|
|
22586
|
+
updateDOMAttributes
|
|
22569
22587
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
22570
22588
|
const generateNewListDefinition = ({ numId, listType, level, start, text, fmt, editor }) => {
|
|
22571
22589
|
if (typeof listType === "string") listType = editor.schema.nodes[listType];
|
|
@@ -24178,18 +24196,6 @@ const baseNumbering = {
|
|
|
24178
24196
|
}
|
|
24179
24197
|
]
|
|
24180
24198
|
};
|
|
24181
|
-
const sanitizeDocxMediaName = (value, fallback = "image") => {
|
|
24182
|
-
if (!value) return fallback;
|
|
24183
|
-
const sanitized = value.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
24184
|
-
return sanitized || fallback;
|
|
24185
|
-
};
|
|
24186
|
-
const getFallbackImageNameFromDataUri = (src = "", fallback = "image") => {
|
|
24187
|
-
if (!src || typeof src !== "string") return fallback;
|
|
24188
|
-
const [prefix] = src.split(";");
|
|
24189
|
-
const [, maybeType] = prefix.split("/");
|
|
24190
|
-
const extension = maybeType?.toLowerCase();
|
|
24191
|
-
return extension ? `${fallback}.${extension}` : fallback;
|
|
24192
|
-
};
|
|
24193
24199
|
function preProcessVerticalMergeCells(table, { editorSchema }) {
|
|
24194
24200
|
if (!table || !Array.isArray(table.content)) {
|
|
24195
24201
|
return table;
|
|
@@ -24359,37 +24365,37 @@ const _NodeTranslator = class _NodeTranslator {
|
|
|
24359
24365
|
/** @type {typeof TranslatorTypes} */
|
|
24360
24366
|
__publicField(_NodeTranslator, "translatorTypes", TranslatorTypes);
|
|
24361
24367
|
let NodeTranslator = _NodeTranslator;
|
|
24362
|
-
const encode$
|
|
24368
|
+
const encode$m = (attributes) => {
|
|
24363
24369
|
return attributes["w:type"];
|
|
24364
24370
|
};
|
|
24365
|
-
const decode$
|
|
24371
|
+
const decode$m = (attrs) => {
|
|
24366
24372
|
const { lineBreakType } = attrs;
|
|
24367
24373
|
return lineBreakType;
|
|
24368
24374
|
};
|
|
24369
24375
|
const attrConfig$b = Object.freeze({
|
|
24370
24376
|
xmlName: "w:type",
|
|
24371
24377
|
sdName: "lineBreakType",
|
|
24372
|
-
encode: encode$
|
|
24373
|
-
decode: decode$
|
|
24378
|
+
encode: encode$m,
|
|
24379
|
+
decode: decode$m
|
|
24374
24380
|
});
|
|
24375
|
-
const encode$
|
|
24381
|
+
const encode$l = (attributes) => {
|
|
24376
24382
|
const xmlAttrValue = attributes["w:clear"];
|
|
24377
24383
|
return xmlAttrValue;
|
|
24378
24384
|
};
|
|
24379
|
-
const decode$
|
|
24385
|
+
const decode$l = (attrs) => {
|
|
24380
24386
|
const { clear } = attrs;
|
|
24381
24387
|
return clear;
|
|
24382
24388
|
};
|
|
24383
24389
|
const attrConfig$a = Object.freeze({
|
|
24384
24390
|
xmlName: "w:clear",
|
|
24385
24391
|
sdName: "clear",
|
|
24386
|
-
encode: encode$
|
|
24387
|
-
decode: decode$
|
|
24392
|
+
encode: encode$l,
|
|
24393
|
+
decode: decode$l
|
|
24388
24394
|
});
|
|
24389
|
-
const validXmlAttributes$
|
|
24390
|
-
const XML_NODE_NAME$
|
|
24391
|
-
const SD_NODE_NAME$
|
|
24392
|
-
const encode$
|
|
24395
|
+
const validXmlAttributes$9 = [attrConfig$b, attrConfig$a];
|
|
24396
|
+
const XML_NODE_NAME$a = "w:br";
|
|
24397
|
+
const SD_NODE_NAME$9 = "lineBreak";
|
|
24398
|
+
const encode$k = (_2, encodedAttrs) => {
|
|
24393
24399
|
const isPageBreak = encodedAttrs?.lineBreakType === "page";
|
|
24394
24400
|
const translated = {
|
|
24395
24401
|
type: isPageBreak ? "hardBreak" : "lineBreak"
|
|
@@ -24399,7 +24405,7 @@ const encode$h = (_2, encodedAttrs) => {
|
|
|
24399
24405
|
}
|
|
24400
24406
|
return translated;
|
|
24401
24407
|
};
|
|
24402
|
-
const decode$
|
|
24408
|
+
const decode$k = (params, decodedAttrs) => {
|
|
24403
24409
|
const { node } = params;
|
|
24404
24410
|
if (!node) return;
|
|
24405
24411
|
const wBreak = { name: "w:br" };
|
|
@@ -24416,63 +24422,63 @@ const decode$h = (params, decodedAttrs) => {
|
|
|
24416
24422
|
};
|
|
24417
24423
|
return translated;
|
|
24418
24424
|
};
|
|
24419
|
-
const config$
|
|
24420
|
-
xmlName: XML_NODE_NAME$
|
|
24421
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
24425
|
+
const config$a = {
|
|
24426
|
+
xmlName: XML_NODE_NAME$a,
|
|
24427
|
+
sdNodeOrKeyName: SD_NODE_NAME$9,
|
|
24422
24428
|
type: NodeTranslator.translatorTypes.NODE,
|
|
24423
|
-
encode: encode$
|
|
24424
|
-
decode: decode$
|
|
24425
|
-
attributes: validXmlAttributes$
|
|
24429
|
+
encode: encode$k,
|
|
24430
|
+
decode: decode$k,
|
|
24431
|
+
attributes: validXmlAttributes$9
|
|
24426
24432
|
};
|
|
24427
|
-
const translator$
|
|
24428
|
-
const encode$
|
|
24433
|
+
const translator$m = NodeTranslator.from(config$a);
|
|
24434
|
+
const encode$j = (attributes) => {
|
|
24429
24435
|
return attributes["w:val"];
|
|
24430
24436
|
};
|
|
24431
|
-
const decode$
|
|
24437
|
+
const decode$j = (attrs) => {
|
|
24432
24438
|
const { tabSize } = attrs || {};
|
|
24433
24439
|
return tabSize;
|
|
24434
24440
|
};
|
|
24435
24441
|
const attrConfig$9 = Object.freeze({
|
|
24436
24442
|
xmlName: "w:val",
|
|
24437
24443
|
sdName: "tabSize",
|
|
24438
|
-
encode: encode$
|
|
24439
|
-
decode: decode$
|
|
24444
|
+
encode: encode$j,
|
|
24445
|
+
decode: decode$j
|
|
24440
24446
|
});
|
|
24441
|
-
const encode$
|
|
24447
|
+
const encode$i = (attributes) => {
|
|
24442
24448
|
return attributes["w:leader"];
|
|
24443
24449
|
};
|
|
24444
|
-
const decode$
|
|
24450
|
+
const decode$i = (attrs) => {
|
|
24445
24451
|
const { leader } = attrs || {};
|
|
24446
24452
|
return leader;
|
|
24447
24453
|
};
|
|
24448
24454
|
const attrConfig$8 = Object.freeze({
|
|
24449
24455
|
xmlName: "w:leader",
|
|
24450
24456
|
sdName: "leader",
|
|
24451
|
-
encode: encode$
|
|
24452
|
-
decode: decode$
|
|
24457
|
+
encode: encode$i,
|
|
24458
|
+
decode: decode$i
|
|
24453
24459
|
});
|
|
24454
|
-
const encode$
|
|
24460
|
+
const encode$h = (attributes) => {
|
|
24455
24461
|
return attributes["w:pos"];
|
|
24456
24462
|
};
|
|
24457
|
-
const decode$
|
|
24463
|
+
const decode$h = (attrs) => {
|
|
24458
24464
|
const { pos } = attrs || {};
|
|
24459
24465
|
return pos;
|
|
24460
24466
|
};
|
|
24461
24467
|
const attrConfig$7 = Object.freeze({
|
|
24462
24468
|
xmlName: "w:pos",
|
|
24463
24469
|
sdName: "pos",
|
|
24464
|
-
encode: encode$
|
|
24465
|
-
decode: decode$
|
|
24470
|
+
encode: encode$h,
|
|
24471
|
+
decode: decode$h
|
|
24466
24472
|
});
|
|
24467
|
-
const validXmlAttributes$
|
|
24468
|
-
const XML_NODE_NAME$
|
|
24469
|
-
const SD_NODE_NAME$
|
|
24470
|
-
const encode$
|
|
24473
|
+
const validXmlAttributes$8 = [attrConfig$9, attrConfig$7, attrConfig$8];
|
|
24474
|
+
const XML_NODE_NAME$9 = "w:tab";
|
|
24475
|
+
const SD_NODE_NAME$8 = "tab";
|
|
24476
|
+
const encode$g = (_2, encodedAttrs = {}) => {
|
|
24471
24477
|
const translated = { type: "tab" };
|
|
24472
24478
|
if (encodedAttrs) translated.attrs = { ...encodedAttrs };
|
|
24473
24479
|
return translated;
|
|
24474
24480
|
};
|
|
24475
|
-
const decode$
|
|
24481
|
+
const decode$g = (params, decodedAttrs = {}) => {
|
|
24476
24482
|
const { node } = params || {};
|
|
24477
24483
|
if (!node) return;
|
|
24478
24484
|
const wTab = { name: "w:tab" };
|
|
@@ -24488,15 +24494,15 @@ const decode$d = (params, decodedAttrs = {}) => {
|
|
|
24488
24494
|
}
|
|
24489
24495
|
return translated;
|
|
24490
24496
|
};
|
|
24491
|
-
const config$
|
|
24492
|
-
xmlName: XML_NODE_NAME$
|
|
24493
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
24497
|
+
const config$9 = {
|
|
24498
|
+
xmlName: XML_NODE_NAME$9,
|
|
24499
|
+
sdNodeOrKeyName: SD_NODE_NAME$8,
|
|
24494
24500
|
type: NodeTranslator.translatorTypes.NODE,
|
|
24495
|
-
encode: encode$
|
|
24496
|
-
decode: decode$
|
|
24497
|
-
attributes: validXmlAttributes$
|
|
24501
|
+
encode: encode$g,
|
|
24502
|
+
decode: decode$g,
|
|
24503
|
+
attributes: validXmlAttributes$8
|
|
24498
24504
|
};
|
|
24499
|
-
const translator$
|
|
24505
|
+
const translator$l = NodeTranslator.from(config$9);
|
|
24500
24506
|
const mergeTextNodes = (nodes) => {
|
|
24501
24507
|
if (!nodes || !Array.isArray(nodes)) {
|
|
24502
24508
|
return nodes;
|
|
@@ -25066,91 +25072,91 @@ const handleParagraphNode$1 = (params) => {
|
|
|
25066
25072
|
}
|
|
25067
25073
|
return schemaNode;
|
|
25068
25074
|
};
|
|
25069
|
-
const encode$
|
|
25075
|
+
const encode$f = (attributes) => {
|
|
25070
25076
|
return attributes["w:rsidDel"];
|
|
25071
25077
|
};
|
|
25072
|
-
const decode$
|
|
25078
|
+
const decode$f = (attrs) => {
|
|
25073
25079
|
return attrs.rsidDel;
|
|
25074
25080
|
};
|
|
25075
25081
|
const attrConfig$6 = Object.freeze({
|
|
25076
25082
|
xmlName: "w:rsidDel",
|
|
25077
25083
|
sdName: "rsidDel",
|
|
25078
|
-
encode: encode$
|
|
25079
|
-
decode: decode$
|
|
25084
|
+
encode: encode$f,
|
|
25085
|
+
decode: decode$f
|
|
25080
25086
|
});
|
|
25081
|
-
const encode$
|
|
25087
|
+
const encode$e = (attributes) => {
|
|
25082
25088
|
return attributes["w:rsidP"];
|
|
25083
25089
|
};
|
|
25084
|
-
const decode$
|
|
25090
|
+
const decode$e = (attrs) => {
|
|
25085
25091
|
return attrs.rsidP;
|
|
25086
25092
|
};
|
|
25087
25093
|
const attrConfig$5 = Object.freeze({
|
|
25088
25094
|
xmlName: "w:rsidP",
|
|
25089
25095
|
sdName: "rsidP",
|
|
25090
|
-
encode: encode$
|
|
25091
|
-
decode: decode$
|
|
25096
|
+
encode: encode$e,
|
|
25097
|
+
decode: decode$e
|
|
25092
25098
|
});
|
|
25093
|
-
const encode$
|
|
25099
|
+
const encode$d = (attributes) => {
|
|
25094
25100
|
return attributes["w:rsidR"];
|
|
25095
25101
|
};
|
|
25096
|
-
const decode$
|
|
25102
|
+
const decode$d = (attrs) => {
|
|
25097
25103
|
return attrs.rsidR;
|
|
25098
25104
|
};
|
|
25099
25105
|
const attrConfig$4 = Object.freeze({
|
|
25100
25106
|
xmlName: "w:rsidR",
|
|
25101
25107
|
sdName: "rsidR",
|
|
25102
|
-
encode: encode$
|
|
25103
|
-
decode: decode$
|
|
25108
|
+
encode: encode$d,
|
|
25109
|
+
decode: decode$d
|
|
25104
25110
|
});
|
|
25105
|
-
const encode$
|
|
25111
|
+
const encode$c = (attributes) => {
|
|
25106
25112
|
return attributes["w:rsidRPr"];
|
|
25107
25113
|
};
|
|
25108
|
-
const decode$
|
|
25114
|
+
const decode$c = (attrs) => {
|
|
25109
25115
|
return attrs.rsidRPr;
|
|
25110
25116
|
};
|
|
25111
25117
|
const attrConfig$3 = Object.freeze({
|
|
25112
25118
|
xmlName: "w:rsidRPr",
|
|
25113
25119
|
sdName: "rsidRPr",
|
|
25114
|
-
encode: encode$
|
|
25115
|
-
decode: decode$
|
|
25120
|
+
encode: encode$c,
|
|
25121
|
+
decode: decode$c
|
|
25116
25122
|
});
|
|
25117
|
-
const encode$
|
|
25123
|
+
const encode$b = (attributes) => {
|
|
25118
25124
|
return attributes["w:rsidRDefault"];
|
|
25119
25125
|
};
|
|
25120
|
-
const decode$
|
|
25126
|
+
const decode$b = (attrs) => {
|
|
25121
25127
|
return attrs.rsidRDefault;
|
|
25122
25128
|
};
|
|
25123
25129
|
const attrConfig$2 = Object.freeze({
|
|
25124
25130
|
xmlName: "w:rsidRDefault",
|
|
25125
25131
|
sdName: "rsidRDefault",
|
|
25126
|
-
encode: encode$
|
|
25127
|
-
decode: decode$
|
|
25132
|
+
encode: encode$b,
|
|
25133
|
+
decode: decode$b
|
|
25128
25134
|
});
|
|
25129
|
-
const encode$
|
|
25135
|
+
const encode$a = (attributes) => {
|
|
25130
25136
|
return attributes["w14:paraId"];
|
|
25131
25137
|
};
|
|
25132
|
-
const decode$
|
|
25138
|
+
const decode$a = (attrs) => {
|
|
25133
25139
|
return attrs.paraId;
|
|
25134
25140
|
};
|
|
25135
25141
|
const attrConfig$1 = Object.freeze({
|
|
25136
25142
|
xmlName: "w14:paraId",
|
|
25137
25143
|
sdName: "paraId",
|
|
25138
|
-
encode: encode$
|
|
25139
|
-
decode: decode$
|
|
25144
|
+
encode: encode$a,
|
|
25145
|
+
decode: decode$a
|
|
25140
25146
|
});
|
|
25141
|
-
const encode$
|
|
25147
|
+
const encode$9 = (attributes) => {
|
|
25142
25148
|
return attributes["w14:textId"];
|
|
25143
25149
|
};
|
|
25144
|
-
const decode$
|
|
25150
|
+
const decode$9 = (attrs) => {
|
|
25145
25151
|
return attrs.textId;
|
|
25146
25152
|
};
|
|
25147
25153
|
const attrConfig = Object.freeze({
|
|
25148
25154
|
xmlName: "w14:textId",
|
|
25149
25155
|
sdName: "textId",
|
|
25150
|
-
encode: encode$
|
|
25151
|
-
decode: decode$
|
|
25156
|
+
encode: encode$9,
|
|
25157
|
+
decode: decode$9
|
|
25152
25158
|
});
|
|
25153
|
-
const validXmlAttributes$
|
|
25159
|
+
const validXmlAttributes$7 = [
|
|
25154
25160
|
attrConfig$1,
|
|
25155
25161
|
attrConfig,
|
|
25156
25162
|
attrConfig$4,
|
|
@@ -25159,9 +25165,9 @@ const validXmlAttributes$4 = [
|
|
|
25159
25165
|
attrConfig$3,
|
|
25160
25166
|
attrConfig$6
|
|
25161
25167
|
];
|
|
25162
|
-
const XML_NODE_NAME$
|
|
25163
|
-
const SD_NODE_NAME$
|
|
25164
|
-
const encode$
|
|
25168
|
+
const XML_NODE_NAME$8 = "w:p";
|
|
25169
|
+
const SD_NODE_NAME$7 = "paragraph";
|
|
25170
|
+
const encode$8 = (params, encodedAttrs = {}) => {
|
|
25165
25171
|
const node = handleParagraphNode$1(params);
|
|
25166
25172
|
if (!node) return void 0;
|
|
25167
25173
|
if (encodedAttrs && Object.keys(encodedAttrs).length) {
|
|
@@ -25169,7 +25175,7 @@ const encode$5 = (params, encodedAttrs = {}) => {
|
|
|
25169
25175
|
}
|
|
25170
25176
|
return node;
|
|
25171
25177
|
};
|
|
25172
|
-
const decode$
|
|
25178
|
+
const decode$8 = (params, decodedAttrs = {}) => {
|
|
25173
25179
|
const translated = translateParagraphNode(params);
|
|
25174
25180
|
if (!translated) return void 0;
|
|
25175
25181
|
if (decodedAttrs && Object.keys(decodedAttrs).length) {
|
|
@@ -25177,15 +25183,15 @@ const decode$5 = (params, decodedAttrs = {}) => {
|
|
|
25177
25183
|
}
|
|
25178
25184
|
return translated;
|
|
25179
25185
|
};
|
|
25180
|
-
const config$
|
|
25181
|
-
xmlName: XML_NODE_NAME$
|
|
25182
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
25186
|
+
const config$8 = {
|
|
25187
|
+
xmlName: XML_NODE_NAME$8,
|
|
25188
|
+
sdNodeOrKeyName: SD_NODE_NAME$7,
|
|
25183
25189
|
type: NodeTranslator.translatorTypes.NODE,
|
|
25184
|
-
encode: encode$
|
|
25185
|
-
decode: decode$
|
|
25186
|
-
attributes: validXmlAttributes$
|
|
25190
|
+
encode: encode$8,
|
|
25191
|
+
decode: decode$8,
|
|
25192
|
+
attributes: validXmlAttributes$7
|
|
25187
25193
|
};
|
|
25188
|
-
const translator$
|
|
25194
|
+
const translator$k = NodeTranslator.from(config$8);
|
|
25189
25195
|
const generateV2HandlerEntity = (handlerName, translator2) => ({
|
|
25190
25196
|
handlerName,
|
|
25191
25197
|
handler: (params) => {
|
|
@@ -25292,13 +25298,13 @@ const integerToString = (value) => {
|
|
|
25292
25298
|
const intValue = parseInteger(value);
|
|
25293
25299
|
return intValue != void 0 ? String(intValue) : void 0;
|
|
25294
25300
|
};
|
|
25295
|
-
const translator$
|
|
25301
|
+
const translator$j = NodeTranslator.from({
|
|
25296
25302
|
xmlName: "w:cantSplit",
|
|
25297
25303
|
sdNodeOrKeyName: "cantSplit",
|
|
25298
25304
|
encode: ({ nodes }) => ["1", "true"].includes(nodes[0].attributes?.["w:val"] ?? "1"),
|
|
25299
25305
|
decode: ({ node }) => node.attrs?.cantSplit ? {} : void 0
|
|
25300
25306
|
});
|
|
25301
|
-
const translator$
|
|
25307
|
+
const translator$i = NodeTranslator.from({
|
|
25302
25308
|
xmlName: "w:cnfStyle",
|
|
25303
25309
|
sdNodeOrKeyName: "cnfStyle",
|
|
25304
25310
|
attributes: [
|
|
@@ -25331,8 +25337,8 @@ const translator$f = NodeTranslator.from({
|
|
|
25331
25337
|
return Object.keys(cnfStyleAttrs).length > 0 ? cnfStyleAttrs : void 0;
|
|
25332
25338
|
}
|
|
25333
25339
|
});
|
|
25334
|
-
const translator$
|
|
25335
|
-
const translator$
|
|
25340
|
+
const translator$h = NodeTranslator.from(createSingleAttrPropertyHandler("w:divId"));
|
|
25341
|
+
const translator$g = NodeTranslator.from(
|
|
25336
25342
|
createSingleAttrPropertyHandler(
|
|
25337
25343
|
"w:gridAfter",
|
|
25338
25344
|
null,
|
|
@@ -25341,7 +25347,7 @@ const translator$d = NodeTranslator.from(
|
|
|
25341
25347
|
(v2) => integerToString(v2)
|
|
25342
25348
|
)
|
|
25343
25349
|
);
|
|
25344
|
-
const translator$
|
|
25350
|
+
const translator$f = NodeTranslator.from(
|
|
25345
25351
|
createSingleAttrPropertyHandler(
|
|
25346
25352
|
"w:gridBefore",
|
|
25347
25353
|
null,
|
|
@@ -25350,21 +25356,21 @@ const translator$c = NodeTranslator.from(
|
|
|
25350
25356
|
(v2) => integerToString(v2)
|
|
25351
25357
|
)
|
|
25352
25358
|
);
|
|
25353
|
-
const translator$
|
|
25359
|
+
const translator$e = NodeTranslator.from({
|
|
25354
25360
|
xmlName: "w:hidden",
|
|
25355
25361
|
sdNodeOrKeyName: "hidden",
|
|
25356
25362
|
encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
|
|
25357
25363
|
decode: ({ node }) => node.attrs.hidden ? {} : void 0
|
|
25358
25364
|
});
|
|
25359
|
-
const translator$
|
|
25360
|
-
const translator$
|
|
25361
|
-
const translator$
|
|
25365
|
+
const translator$d = NodeTranslator.from(createSingleAttrPropertyHandler("w:jc"));
|
|
25366
|
+
const translator$c = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "cellSpacing"));
|
|
25367
|
+
const translator$b = NodeTranslator.from({
|
|
25362
25368
|
xmlName: "w:tblHeader",
|
|
25363
25369
|
sdNodeOrKeyName: "repeatHeader",
|
|
25364
25370
|
encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
|
|
25365
25371
|
decode: ({ node }) => node.attrs.repeatHeader ? {} : void 0
|
|
25366
25372
|
});
|
|
25367
|
-
const translator$
|
|
25373
|
+
const translator$a = NodeTranslator.from({
|
|
25368
25374
|
xmlName: "w:trHeight",
|
|
25369
25375
|
sdNodeOrKeyName: "rowHeight",
|
|
25370
25376
|
encode: ({ nodes }) => {
|
|
@@ -25391,11 +25397,11 @@ const translator$7 = NodeTranslator.from({
|
|
|
25391
25397
|
return Object.keys(heightAttrs).length > 0 ? heightAttrs : void 0;
|
|
25392
25398
|
}
|
|
25393
25399
|
});
|
|
25394
|
-
const translator$
|
|
25395
|
-
const translator$
|
|
25396
|
-
const XML_NODE_NAME$
|
|
25400
|
+
const translator$9 = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
|
|
25401
|
+
const translator$8 = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
|
|
25402
|
+
const XML_NODE_NAME$7 = "w:trPr";
|
|
25397
25403
|
const SD_ATTR_KEY = "tableRowProperties";
|
|
25398
|
-
const encode$
|
|
25404
|
+
const encode$7 = (params) => {
|
|
25399
25405
|
const { nodes } = params;
|
|
25400
25406
|
const node = nodes[0];
|
|
25401
25407
|
let attributes = {
|
|
@@ -25409,12 +25415,12 @@ const encode$4 = (params) => {
|
|
|
25409
25415
|
};
|
|
25410
25416
|
return {
|
|
25411
25417
|
type: NodeTranslator.translatorTypes.ATTRIBUTE,
|
|
25412
|
-
xmlName: XML_NODE_NAME$
|
|
25418
|
+
xmlName: XML_NODE_NAME$7,
|
|
25413
25419
|
sdNodeOrKeyName: SD_ATTR_KEY,
|
|
25414
25420
|
attributes
|
|
25415
25421
|
};
|
|
25416
25422
|
};
|
|
25417
|
-
const decode$
|
|
25423
|
+
const decode$7 = (params) => {
|
|
25418
25424
|
const { tableRowProperties = {} } = params.node.attrs || {};
|
|
25419
25425
|
const elements = decodeProperties(propertyTranslatorsBySdName, tableRowProperties);
|
|
25420
25426
|
const newNode = {
|
|
@@ -25426,6 +25432,9 @@ const decode$4 = (params) => {
|
|
|
25426
25432
|
return newNode;
|
|
25427
25433
|
};
|
|
25428
25434
|
const propertyTranslators = [
|
|
25435
|
+
translator$j,
|
|
25436
|
+
translator$i,
|
|
25437
|
+
translator$h,
|
|
25429
25438
|
translator$g,
|
|
25430
25439
|
translator$f,
|
|
25431
25440
|
translator$e,
|
|
@@ -25434,10 +25443,7 @@ const propertyTranslators = [
|
|
|
25434
25443
|
translator$b,
|
|
25435
25444
|
translator$a,
|
|
25436
25445
|
translator$9,
|
|
25437
|
-
translator$8
|
|
25438
|
-
translator$7,
|
|
25439
|
-
translator$6,
|
|
25440
|
-
translator$5
|
|
25446
|
+
translator$8
|
|
25441
25447
|
];
|
|
25442
25448
|
const propertyTranslatorsByXmlName = {};
|
|
25443
25449
|
propertyTranslators.forEach((translator2) => {
|
|
@@ -25447,25 +25453,25 @@ const propertyTranslatorsBySdName = {};
|
|
|
25447
25453
|
propertyTranslators.forEach((translator2) => {
|
|
25448
25454
|
propertyTranslatorsBySdName[translator2.sdNodeOrKeyName] = translator2;
|
|
25449
25455
|
});
|
|
25450
|
-
const config$
|
|
25451
|
-
xmlName: XML_NODE_NAME$
|
|
25456
|
+
const config$7 = {
|
|
25457
|
+
xmlName: XML_NODE_NAME$7,
|
|
25452
25458
|
sdNodeOrKeyName: SD_ATTR_KEY,
|
|
25453
25459
|
type: NodeTranslator.translatorTypes.ATTRIBUTE,
|
|
25454
|
-
encode: encode$
|
|
25455
|
-
decode: decode$
|
|
25460
|
+
encode: encode$7,
|
|
25461
|
+
decode: decode$7
|
|
25456
25462
|
};
|
|
25457
|
-
const translator$
|
|
25458
|
-
const XML_NODE_NAME$
|
|
25459
|
-
const SD_NODE_NAME$
|
|
25460
|
-
const validXmlAttributes$
|
|
25463
|
+
const translator$7 = NodeTranslator.from(config$7);
|
|
25464
|
+
const XML_NODE_NAME$6 = "w:tr";
|
|
25465
|
+
const SD_NODE_NAME$6 = "tableRow";
|
|
25466
|
+
const validXmlAttributes$6 = ["w:rsidDel", "w:rsidR", "w:rsidRPr", "w:rsidTr", "w14:paraId", "w14:textId"].map(
|
|
25461
25467
|
(xmlName) => createAttributeHandler(xmlName)
|
|
25462
25468
|
);
|
|
25463
|
-
const encode$
|
|
25469
|
+
const encode$6 = (params, encodedAttrs) => {
|
|
25464
25470
|
const { row, table } = params.extraParams;
|
|
25465
25471
|
let tableRowProperties = {};
|
|
25466
25472
|
const tPr = row.elements.find((el) => el.name === "w:trPr");
|
|
25467
25473
|
if (tPr) {
|
|
25468
|
-
({ attributes: tableRowProperties } = translator$
|
|
25474
|
+
({ attributes: tableRowProperties } = translator$7.encode({
|
|
25469
25475
|
...params,
|
|
25470
25476
|
nodes: [tPr]
|
|
25471
25477
|
}));
|
|
@@ -25478,7 +25484,7 @@ const encode$3 = (params, encodedAttrs) => {
|
|
|
25478
25484
|
let currentColumnIndex = 0;
|
|
25479
25485
|
const content = cellNodes?.map((n) => {
|
|
25480
25486
|
let columnWidth = gridColumnWidths?.[currentColumnIndex] || null;
|
|
25481
|
-
const result = translator$
|
|
25487
|
+
const result = translator$5.encode({
|
|
25482
25488
|
...params,
|
|
25483
25489
|
extraParams: {
|
|
25484
25490
|
...params.extraParams,
|
|
@@ -25509,7 +25515,7 @@ const _getGridColumnWidths = (tableNode) => {
|
|
|
25509
25515
|
}) || [];
|
|
25510
25516
|
return columnWidths;
|
|
25511
25517
|
};
|
|
25512
|
-
const decode$
|
|
25518
|
+
const decode$6 = (params, decodedAttrs) => {
|
|
25513
25519
|
const { node } = params;
|
|
25514
25520
|
const elements = translateChildNodes(params);
|
|
25515
25521
|
if (node.attrs?.tableRowProperties) {
|
|
@@ -25521,7 +25527,7 @@ const decode$3 = (params, decodedAttrs) => {
|
|
|
25521
25527
|
}
|
|
25522
25528
|
}
|
|
25523
25529
|
tableRowProperties["cantSplit"] = node.attrs["cantSplit"];
|
|
25524
|
-
const trPr = translator$
|
|
25530
|
+
const trPr = translator$7.decode({
|
|
25525
25531
|
...params,
|
|
25526
25532
|
node: { ...node, attrs: { ...node.attrs, tableRowProperties } }
|
|
25527
25533
|
});
|
|
@@ -25533,15 +25539,15 @@ const decode$3 = (params, decodedAttrs) => {
|
|
|
25533
25539
|
elements
|
|
25534
25540
|
};
|
|
25535
25541
|
};
|
|
25536
|
-
const config$
|
|
25537
|
-
xmlName: XML_NODE_NAME$
|
|
25538
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
25542
|
+
const config$6 = {
|
|
25543
|
+
xmlName: XML_NODE_NAME$6,
|
|
25544
|
+
sdNodeOrKeyName: SD_NODE_NAME$6,
|
|
25539
25545
|
type: NodeTranslator.translatorTypes.NODE,
|
|
25540
|
-
encode: encode$
|
|
25541
|
-
decode: decode$
|
|
25542
|
-
attributes: validXmlAttributes$
|
|
25546
|
+
encode: encode$6,
|
|
25547
|
+
decode: decode$6,
|
|
25548
|
+
attributes: validXmlAttributes$6
|
|
25543
25549
|
};
|
|
25544
|
-
const translator$
|
|
25550
|
+
const translator$6 = NodeTranslator.from(config$6);
|
|
25545
25551
|
const handleAllTableNodes = (params) => {
|
|
25546
25552
|
const { nodes } = params;
|
|
25547
25553
|
if (nodes.length === 0) {
|
|
@@ -25605,7 +25611,7 @@ function handleTableNode(node, params) {
|
|
|
25605
25611
|
attrs["borders"] = borderData;
|
|
25606
25612
|
const content = [];
|
|
25607
25613
|
rows.forEach((row) => {
|
|
25608
|
-
const result = translator$
|
|
25614
|
+
const result = translator$6.encode({
|
|
25609
25615
|
...params,
|
|
25610
25616
|
nodes: [row],
|
|
25611
25617
|
extraParams: {
|
|
@@ -25986,10 +25992,10 @@ function generateCellMargins(cellMargins) {
|
|
|
25986
25992
|
if (left != null) elements.push({ name: "w:left", attributes: { "w:w": pixelsToTwips(left) } });
|
|
25987
25993
|
return elements;
|
|
25988
25994
|
}
|
|
25989
|
-
const XML_NODE_NAME$
|
|
25990
|
-
const SD_NODE_NAME$
|
|
25991
|
-
const validXmlAttributes$
|
|
25992
|
-
function encode$
|
|
25995
|
+
const XML_NODE_NAME$5 = "w:tc";
|
|
25996
|
+
const SD_NODE_NAME$5 = "tableCell";
|
|
25997
|
+
const validXmlAttributes$5 = [];
|
|
25998
|
+
function encode$5(params, encodedAttrs) {
|
|
25993
25999
|
const { node, table, row, rowBorders, styleTag, columnIndex, columnWidth } = params.extraParams;
|
|
25994
26000
|
const schemaNode = handleTableCellNode({
|
|
25995
26001
|
params,
|
|
@@ -26006,31 +26012,31 @@ function encode$2(params, encodedAttrs) {
|
|
|
26006
26012
|
}
|
|
26007
26013
|
return schemaNode;
|
|
26008
26014
|
}
|
|
26009
|
-
function decode$
|
|
26015
|
+
function decode$5(params, decodedAttrs) {
|
|
26010
26016
|
const translated = translateTableCell(params);
|
|
26011
26017
|
if (decodedAttrs && Object.keys(decodedAttrs).length) {
|
|
26012
26018
|
translated.attributes = { ...translated.attributes || {}, ...decodedAttrs };
|
|
26013
26019
|
}
|
|
26014
26020
|
return translated;
|
|
26015
26021
|
}
|
|
26016
|
-
const config$
|
|
26017
|
-
xmlName: XML_NODE_NAME$
|
|
26018
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
26022
|
+
const config$5 = {
|
|
26023
|
+
xmlName: XML_NODE_NAME$5,
|
|
26024
|
+
sdNodeOrKeyName: SD_NODE_NAME$5,
|
|
26019
26025
|
type: NodeTranslator.translatorTypes.NODE,
|
|
26020
|
-
encode: encode$
|
|
26021
|
-
decode: decode$
|
|
26022
|
-
attributes: validXmlAttributes$
|
|
26026
|
+
encode: encode$5,
|
|
26027
|
+
decode: decode$5,
|
|
26028
|
+
attributes: validXmlAttributes$5
|
|
26023
26029
|
};
|
|
26024
|
-
const translator$
|
|
26025
|
-
const XML_NODE_NAME$
|
|
26026
|
-
const SD_NODE_NAME$
|
|
26030
|
+
const translator$5 = NodeTranslator.from(config$5);
|
|
26031
|
+
const XML_NODE_NAME$4 = "w:hyperlink";
|
|
26032
|
+
const SD_NODE_NAME$4 = "link";
|
|
26027
26033
|
const _createAttributeHandler = (xmlName, sdName) => ({
|
|
26028
26034
|
xmlName,
|
|
26029
26035
|
sdName,
|
|
26030
26036
|
encode: (attributes) => attributes[xmlName],
|
|
26031
26037
|
decode: (attributes) => attributes[sdName]
|
|
26032
26038
|
});
|
|
26033
|
-
const validXmlAttributes$
|
|
26039
|
+
const validXmlAttributes$4 = [
|
|
26034
26040
|
_createAttributeHandler("w:anchor", "anchor"),
|
|
26035
26041
|
_createAttributeHandler("w:docLocation", "docLocation"),
|
|
26036
26042
|
{
|
|
@@ -26043,7 +26049,7 @@ const validXmlAttributes$1 = [
|
|
|
26043
26049
|
_createAttributeHandler("r:id", "rId"),
|
|
26044
26050
|
_createAttributeHandler("w:tgtFrame", "target")
|
|
26045
26051
|
];
|
|
26046
|
-
const encode$
|
|
26052
|
+
const encode$4 = (params, encodedAttrs) => {
|
|
26047
26053
|
const { nodes, docx, nodeListHandler } = params;
|
|
26048
26054
|
const node = nodes[0];
|
|
26049
26055
|
let href = _resolveHref(docx, encodedAttrs);
|
|
@@ -26074,7 +26080,7 @@ const _resolveHref = (docx, encodedAttrs) => {
|
|
|
26074
26080
|
}
|
|
26075
26081
|
return href;
|
|
26076
26082
|
};
|
|
26077
|
-
function decode$
|
|
26083
|
+
function decode$4(params) {
|
|
26078
26084
|
const { node } = params;
|
|
26079
26085
|
const linkMark = node.marks.find((m2) => m2.type === "link");
|
|
26080
26086
|
const linkAttrs = this.decodeAttributes({ ...params, node: linkMark });
|
|
@@ -26118,15 +26124,15 @@ function _addNewLinkRelationship(params, link, rId) {
|
|
|
26118
26124
|
});
|
|
26119
26125
|
return rId;
|
|
26120
26126
|
}
|
|
26121
|
-
const config$
|
|
26122
|
-
xmlName: XML_NODE_NAME$
|
|
26123
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
26127
|
+
const config$4 = {
|
|
26128
|
+
xmlName: XML_NODE_NAME$4,
|
|
26129
|
+
sdNodeOrKeyName: SD_NODE_NAME$4,
|
|
26124
26130
|
type: NodeTranslator.translatorTypes.NODE,
|
|
26125
|
-
encode: encode$
|
|
26126
|
-
decode: decode$
|
|
26127
|
-
attributes: validXmlAttributes$
|
|
26131
|
+
encode: encode$4,
|
|
26132
|
+
decode: decode$4,
|
|
26133
|
+
attributes: validXmlAttributes$4
|
|
26128
26134
|
};
|
|
26129
|
-
const translator$
|
|
26135
|
+
const translator$4 = NodeTranslator.from(config$4);
|
|
26130
26136
|
function parseTagValueJSON(json) {
|
|
26131
26137
|
if (typeof json !== "string") {
|
|
26132
26138
|
return {};
|
|
@@ -26368,59 +26374,676 @@ function sdtNodeTypeStrategy(node) {
|
|
|
26368
26374
|
}
|
|
26369
26375
|
return { type: "unknown", handler: null };
|
|
26370
26376
|
}
|
|
26371
|
-
|
|
26372
|
-
|
|
26373
|
-
|
|
26374
|
-
|
|
26375
|
-
|
|
26376
|
-
|
|
26377
|
-
|
|
26378
|
-
|
|
26379
|
-
|
|
26380
|
-
|
|
26381
|
-
|
|
26382
|
-
|
|
26383
|
-
|
|
26384
|
-
|
|
26385
|
-
|
|
26386
|
-
|
|
26387
|
-
|
|
26388
|
-
|
|
26389
|
-
|
|
26390
|
-
|
|
26391
|
-
* @returns {import("prosemirror-state").EditorState} Editor state
|
|
26392
|
-
*/
|
|
26393
|
-
get state() {
|
|
26394
|
-
return this.editor.state;
|
|
26377
|
+
function handleImageNode(node, params, isAnchor) {
|
|
26378
|
+
const { docx, filename } = params;
|
|
26379
|
+
const { attributes } = node;
|
|
26380
|
+
const padding = {
|
|
26381
|
+
top: emuToPixels(attributes["distT"]),
|
|
26382
|
+
bottom: emuToPixels(attributes["distB"]),
|
|
26383
|
+
left: emuToPixels(attributes["distL"]),
|
|
26384
|
+
right: emuToPixels(attributes["distR"])
|
|
26385
|
+
};
|
|
26386
|
+
const extent = node.elements.find((el) => el.name === "wp:extent");
|
|
26387
|
+
const size = {
|
|
26388
|
+
width: emuToPixels(extent.attributes?.cx),
|
|
26389
|
+
height: emuToPixels(extent.attributes?.cy)
|
|
26390
|
+
};
|
|
26391
|
+
const graphic = node.elements.find((el) => el.name === "a:graphic");
|
|
26392
|
+
const graphicData = graphic.elements.find((el) => el.name === "a:graphicData");
|
|
26393
|
+
const { uri: uri2 } = graphicData?.attributes || {};
|
|
26394
|
+
const shapeURI = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape";
|
|
26395
|
+
if (!!uri2 && uri2 === shapeURI) {
|
|
26396
|
+
return handleShapeDrawing(params, node, graphicData);
|
|
26395
26397
|
}
|
|
26396
|
-
|
|
26397
|
-
|
|
26398
|
-
|
|
26399
|
-
|
|
26400
|
-
|
|
26401
|
-
|
|
26402
|
-
|
|
26403
|
-
|
|
26404
|
-
|
|
26405
|
-
|
|
26406
|
-
|
|
26407
|
-
|
|
26408
|
-
|
|
26409
|
-
|
|
26410
|
-
|
|
26411
|
-
|
|
26412
|
-
|
|
26413
|
-
|
|
26414
|
-
|
|
26415
|
-
|
|
26416
|
-
|
|
26417
|
-
|
|
26418
|
-
|
|
26398
|
+
const picture = graphicData.elements.find((el) => el.name === "pic:pic");
|
|
26399
|
+
if (!picture || !picture.elements) return null;
|
|
26400
|
+
const blipFill = picture.elements.find((el) => el.name === "pic:blipFill");
|
|
26401
|
+
const blip = blipFill.elements.find((el) => el.name === "a:blip");
|
|
26402
|
+
const positionHTag = node.elements.find((el) => el.name === "wp:positionH");
|
|
26403
|
+
const positionH = positionHTag?.elements.find((el) => el.name === "wp:posOffset");
|
|
26404
|
+
const positionHValue = emuToPixels(positionH?.elements[0]?.text);
|
|
26405
|
+
const hRelativeFrom = positionHTag?.attributes.relativeFrom;
|
|
26406
|
+
const alignH = positionHTag?.elements.find((el) => el.name === "wp:align")?.elements[0]?.text;
|
|
26407
|
+
const positionVTag = node.elements.find((el) => el.name === "wp:positionV");
|
|
26408
|
+
const positionV = positionVTag?.elements?.find((el) => el.name === "wp:posOffset");
|
|
26409
|
+
const positionVValue = emuToPixels(positionV?.elements[0]?.text);
|
|
26410
|
+
const vRelativeFrom = positionVTag?.attributes.relativeFrom;
|
|
26411
|
+
const alignV = positionVTag?.elements?.find((el) => el.name === "wp:align")?.elements[0]?.text;
|
|
26412
|
+
const simplePos = node.elements.find((el) => el.name === "wp:simplePos");
|
|
26413
|
+
const wrapSquare = node.elements.find((el) => el.name === "wp:wrapSquare");
|
|
26414
|
+
const wrapTopAndBottom = node.elements.find((el) => el.name === "wp:wrapTopAndBottom");
|
|
26415
|
+
const docPr = node.elements.find((el) => el.name === "wp:docPr");
|
|
26416
|
+
let anchorData = null;
|
|
26417
|
+
if (hRelativeFrom || alignH || vRelativeFrom || alignV) {
|
|
26418
|
+
anchorData = {
|
|
26419
|
+
hRelativeFrom,
|
|
26420
|
+
vRelativeFrom,
|
|
26421
|
+
alignH,
|
|
26422
|
+
alignV
|
|
26423
|
+
};
|
|
26419
26424
|
}
|
|
26420
|
-
|
|
26421
|
-
|
|
26422
|
-
|
|
26423
|
-
|
|
26425
|
+
const marginOffset = {
|
|
26426
|
+
left: positionHValue,
|
|
26427
|
+
top: positionVValue
|
|
26428
|
+
};
|
|
26429
|
+
const { attributes: blipAttributes = {} } = blip;
|
|
26430
|
+
const rEmbed = blipAttributes["r:embed"];
|
|
26431
|
+
if (!rEmbed) return null;
|
|
26432
|
+
const currentFile = filename || "document.xml";
|
|
26433
|
+
let rels = docx[`word/_rels/${currentFile}.rels`];
|
|
26434
|
+
if (!rels) rels = docx[`word/_rels/document.xml.rels`];
|
|
26435
|
+
const relationships = rels.elements.find((el) => el.name === "Relationships");
|
|
26436
|
+
const { elements } = relationships || [];
|
|
26437
|
+
const rel = elements?.find((el) => el.attributes["Id"] === rEmbed);
|
|
26438
|
+
if (!rel) return null;
|
|
26439
|
+
const { attributes: relAttributes } = rel;
|
|
26440
|
+
const targetPath = relAttributes["Target"];
|
|
26441
|
+
let path = `word/${targetPath}`;
|
|
26442
|
+
if (targetPath.startsWith("/word") || targetPath.startsWith("/media")) path = targetPath.substring(1);
|
|
26443
|
+
const extension = targetPath.substring(targetPath.lastIndexOf(".") + 1);
|
|
26444
|
+
return {
|
|
26445
|
+
type: "image",
|
|
26446
|
+
attrs: {
|
|
26447
|
+
src: path,
|
|
26448
|
+
alt: ["emf", "wmf"].includes(extension) ? "Unable to render EMF/WMF image" : docPr?.attributes.name || "Image",
|
|
26449
|
+
extension,
|
|
26450
|
+
id: docPr?.attributes.id || "",
|
|
26451
|
+
title: docPr?.attributes.descr || "Image",
|
|
26452
|
+
inline: true,
|
|
26453
|
+
padding,
|
|
26454
|
+
marginOffset,
|
|
26455
|
+
size,
|
|
26456
|
+
anchorData,
|
|
26457
|
+
isAnchor,
|
|
26458
|
+
...simplePos && {
|
|
26459
|
+
simplePos: {
|
|
26460
|
+
x: simplePos.attributes.x,
|
|
26461
|
+
y: simplePos.attributes.y
|
|
26462
|
+
}
|
|
26463
|
+
},
|
|
26464
|
+
...wrapSquare && {
|
|
26465
|
+
wrapText: wrapSquare.attributes.wrapText
|
|
26466
|
+
},
|
|
26467
|
+
wrapTopAndBottom: !!wrapTopAndBottom,
|
|
26468
|
+
originalPadding: {
|
|
26469
|
+
distT: attributes["distT"],
|
|
26470
|
+
distB: attributes["distB"],
|
|
26471
|
+
distL: attributes["distL"],
|
|
26472
|
+
distR: attributes["distR"]
|
|
26473
|
+
},
|
|
26474
|
+
originalAttributes: node.attributes,
|
|
26475
|
+
rId: relAttributes["Id"]
|
|
26476
|
+
}
|
|
26477
|
+
};
|
|
26478
|
+
}
|
|
26479
|
+
const handleShapeDrawing = (params, node, graphicData) => {
|
|
26480
|
+
const wsp = graphicData.elements.find((el) => el.name === "wps:wsp");
|
|
26481
|
+
const textBox = wsp.elements.find((el) => el.name === "wps:txbx");
|
|
26482
|
+
const textBoxContent = textBox?.elements?.find((el) => el.name === "w:txbxContent");
|
|
26483
|
+
node.elements.find((el) => el.name === "wp:docPr");
|
|
26484
|
+
const spPr = wsp.elements.find((el) => el.name === "wps:spPr");
|
|
26485
|
+
const prstGeom = spPr?.elements.find((el) => el.name === "a:prstGeom");
|
|
26486
|
+
if (!!prstGeom && prstGeom.attributes["prst"] === "rect" && !textBoxContent) {
|
|
26487
|
+
return getRectangleShape(params, spPr);
|
|
26488
|
+
}
|
|
26489
|
+
if (!textBoxContent) {
|
|
26490
|
+
return null;
|
|
26491
|
+
}
|
|
26492
|
+
const { nodeListHandler } = params;
|
|
26493
|
+
const translatedElement = nodeListHandler.handler({
|
|
26494
|
+
...params,
|
|
26495
|
+
node: textBoxContent.elements[0],
|
|
26496
|
+
nodes: textBoxContent.elements,
|
|
26497
|
+
path: [...params.path || [], textBoxContent]
|
|
26498
|
+
});
|
|
26499
|
+
return translatedElement[0];
|
|
26500
|
+
};
|
|
26501
|
+
const getRectangleShape = (params, node) => {
|
|
26502
|
+
const schemaAttrs = {};
|
|
26503
|
+
const [drawingNode] = params.nodes;
|
|
26504
|
+
if (drawingNode?.name === "w:drawing") {
|
|
26505
|
+
schemaAttrs.drawingContent = drawingNode;
|
|
26506
|
+
}
|
|
26507
|
+
const xfrm = node.elements.find((el) => el.name === "a:xfrm");
|
|
26508
|
+
const start = xfrm.elements.find((el) => el.name === "a:off");
|
|
26509
|
+
const size = xfrm.elements.find((el) => el.name === "a:ext");
|
|
26510
|
+
const solidFill = node.elements.find((el) => el.name === "a:solidFill");
|
|
26511
|
+
node.elements.find((el) => el.name === "a:ln");
|
|
26512
|
+
const rectangleSize = {
|
|
26513
|
+
top: emuToPixels(start.attributes["y"]),
|
|
26514
|
+
left: emuToPixels(start.attributes["x"]),
|
|
26515
|
+
width: emuToPixels(size.attributes["cx"]),
|
|
26516
|
+
height: emuToPixels(size.attributes["cy"])
|
|
26517
|
+
};
|
|
26518
|
+
schemaAttrs.size = rectangleSize;
|
|
26519
|
+
const background = solidFill?.elements[0]?.attributes["val"];
|
|
26520
|
+
if (background) {
|
|
26521
|
+
schemaAttrs.background = "#" + background;
|
|
26522
|
+
}
|
|
26523
|
+
return {
|
|
26524
|
+
type: "contentBlock",
|
|
26525
|
+
attrs: schemaAttrs
|
|
26526
|
+
};
|
|
26527
|
+
};
|
|
26528
|
+
function handleAnchorNode(params) {
|
|
26529
|
+
const { node } = params.extraParams;
|
|
26530
|
+
if (node.name !== "wp:anchor") {
|
|
26531
|
+
return null;
|
|
26532
|
+
}
|
|
26533
|
+
return handleImageNode(node, params, true);
|
|
26534
|
+
}
|
|
26535
|
+
const sanitizeDocxMediaName = (value, fallback = "image") => {
|
|
26536
|
+
if (!value) return fallback;
|
|
26537
|
+
const sanitized = value.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
26538
|
+
return sanitized || fallback;
|
|
26539
|
+
};
|
|
26540
|
+
const getFallbackImageNameFromDataUri = (src = "", fallback = "image") => {
|
|
26541
|
+
if (!src || typeof src !== "string") return fallback;
|
|
26542
|
+
const [prefix] = src.split(";");
|
|
26543
|
+
const [, maybeType] = prefix.split("/");
|
|
26544
|
+
const extension = maybeType?.toLowerCase();
|
|
26545
|
+
return extension ? `${fallback}.${extension}` : fallback;
|
|
26546
|
+
};
|
|
26547
|
+
const translateImageNode = (params) => {
|
|
26548
|
+
const {
|
|
26549
|
+
node: { attrs = {} },
|
|
26550
|
+
tableCell,
|
|
26551
|
+
imageSize
|
|
26552
|
+
} = params;
|
|
26553
|
+
let imageId = attrs.rId;
|
|
26554
|
+
const src = attrs.src || attrs.imageSrc;
|
|
26555
|
+
const { originalWidth, originalHeight } = getPngDimensions(src);
|
|
26556
|
+
let imageName;
|
|
26557
|
+
if (params.node.type === "image") {
|
|
26558
|
+
if (src?.startsWith("data:")) {
|
|
26559
|
+
imageName = getFallbackImageNameFromDataUri(src);
|
|
26560
|
+
} else {
|
|
26561
|
+
imageName = src?.split("/").pop();
|
|
26562
|
+
}
|
|
26563
|
+
} else {
|
|
26564
|
+
imageName = attrs.fieldId;
|
|
26565
|
+
}
|
|
26566
|
+
imageName = sanitizeDocxMediaName(imageName);
|
|
26567
|
+
let size = attrs.size ? {
|
|
26568
|
+
w: pixelsToEmu(attrs.size.width),
|
|
26569
|
+
h: pixelsToEmu(attrs.size.height)
|
|
26570
|
+
} : imageSize;
|
|
26571
|
+
if (originalWidth && originalHeight) {
|
|
26572
|
+
const boxWidthPx = emuToPixels(size.w);
|
|
26573
|
+
const boxHeightPx = emuToPixels(size.h);
|
|
26574
|
+
const { scaledWidth, scaledHeight } = getScaledSize(originalWidth, originalHeight, boxWidthPx, boxHeightPx);
|
|
26575
|
+
size = {
|
|
26576
|
+
w: pixelsToEmu(scaledWidth),
|
|
26577
|
+
h: pixelsToEmu(scaledHeight)
|
|
26578
|
+
};
|
|
26579
|
+
}
|
|
26580
|
+
if (tableCell) {
|
|
26581
|
+
const colwidthSum = tableCell.attrs.colwidth.reduce((acc, curr) => acc + curr, 0);
|
|
26582
|
+
const leftMargin = tableCell.attrs.cellMargins?.left || 8;
|
|
26583
|
+
const rightMargin = tableCell.attrs.cellMargins?.right || 8;
|
|
26584
|
+
const maxWidthEmu = pixelsToEmu(colwidthSum - (leftMargin + rightMargin));
|
|
26585
|
+
const { width: w2, height: h2 } = resizeKeepAspectRatio(size.w, size.h, maxWidthEmu);
|
|
26586
|
+
if (w2 && h2) size = { w: w2, h: h2 };
|
|
26587
|
+
}
|
|
26588
|
+
if (params.node.type === "image" && !imageId) {
|
|
26589
|
+
const path = src?.split("word/")[1];
|
|
26590
|
+
imageId = addNewImageRelationship(params, path);
|
|
26591
|
+
} else if (params.node.type === "fieldAnnotation" && !imageId) {
|
|
26592
|
+
const type2 = src?.split(";")[0].split("/")[1];
|
|
26593
|
+
if (!type2) {
|
|
26594
|
+
return prepareTextAnnotation(params);
|
|
26595
|
+
}
|
|
26596
|
+
const sanitizedHash = sanitizeDocxMediaName(attrs.hash, generateDocxRandomId(4));
|
|
26597
|
+
const fileName = `${imageName}_${sanitizedHash}.${type2}`;
|
|
26598
|
+
const relationshipTarget = `media/${fileName}`;
|
|
26599
|
+
const packagePath = `word/${relationshipTarget}`;
|
|
26600
|
+
imageId = addNewImageRelationship(params, relationshipTarget);
|
|
26601
|
+
params.media[packagePath] = src;
|
|
26602
|
+
}
|
|
26603
|
+
const inlineAttrs = attrs.originalPadding || {
|
|
26604
|
+
distT: 0,
|
|
26605
|
+
distB: 0,
|
|
26606
|
+
distL: 0,
|
|
26607
|
+
distR: 0
|
|
26608
|
+
};
|
|
26609
|
+
const drawingXmlns = "http://schemas.openxmlformats.org/drawingml/2006/main";
|
|
26610
|
+
const pictureXmlns = "http://schemas.openxmlformats.org/drawingml/2006/picture";
|
|
26611
|
+
return {
|
|
26612
|
+
attributes: inlineAttrs,
|
|
26613
|
+
elements: [
|
|
26614
|
+
{
|
|
26615
|
+
name: "wp:extent",
|
|
26616
|
+
attributes: {
|
|
26617
|
+
cx: size.w,
|
|
26618
|
+
cy: size.h
|
|
26619
|
+
}
|
|
26620
|
+
},
|
|
26621
|
+
{
|
|
26622
|
+
name: "wp:effectExtent",
|
|
26623
|
+
attributes: {
|
|
26624
|
+
l: 0,
|
|
26625
|
+
t: 0,
|
|
26626
|
+
r: 0,
|
|
26627
|
+
b: 0
|
|
26628
|
+
}
|
|
26629
|
+
},
|
|
26630
|
+
{
|
|
26631
|
+
name: "wp:docPr",
|
|
26632
|
+
attributes: {
|
|
26633
|
+
id: attrs.id || 0,
|
|
26634
|
+
name: attrs.alt || `Picture ${imageName}`
|
|
26635
|
+
}
|
|
26636
|
+
},
|
|
26637
|
+
{
|
|
26638
|
+
name: "wp:cNvGraphicFramePr",
|
|
26639
|
+
elements: [
|
|
26640
|
+
{
|
|
26641
|
+
name: "a:graphicFrameLocks",
|
|
26642
|
+
attributes: {
|
|
26643
|
+
"xmlns:a": drawingXmlns,
|
|
26644
|
+
noChangeAspect: 1
|
|
26645
|
+
}
|
|
26646
|
+
}
|
|
26647
|
+
]
|
|
26648
|
+
},
|
|
26649
|
+
{
|
|
26650
|
+
name: "a:graphic",
|
|
26651
|
+
attributes: { "xmlns:a": drawingXmlns },
|
|
26652
|
+
elements: [
|
|
26653
|
+
{
|
|
26654
|
+
name: "a:graphicData",
|
|
26655
|
+
attributes: { uri: pictureXmlns },
|
|
26656
|
+
elements: [
|
|
26657
|
+
{
|
|
26658
|
+
name: "pic:pic",
|
|
26659
|
+
attributes: { "xmlns:pic": pictureXmlns },
|
|
26660
|
+
elements: [
|
|
26661
|
+
{
|
|
26662
|
+
name: "pic:nvPicPr",
|
|
26663
|
+
elements: [
|
|
26664
|
+
{
|
|
26665
|
+
name: "pic:cNvPr",
|
|
26666
|
+
attributes: {
|
|
26667
|
+
id: attrs.id || 0,
|
|
26668
|
+
name: attrs.title || `Picture ${imageName}`
|
|
26669
|
+
}
|
|
26670
|
+
},
|
|
26671
|
+
{
|
|
26672
|
+
name: "pic:cNvPicPr",
|
|
26673
|
+
elements: [
|
|
26674
|
+
{
|
|
26675
|
+
name: "a:picLocks",
|
|
26676
|
+
attributes: {
|
|
26677
|
+
noChangeAspect: 1,
|
|
26678
|
+
noChangeArrowheads: 1
|
|
26679
|
+
}
|
|
26680
|
+
}
|
|
26681
|
+
]
|
|
26682
|
+
}
|
|
26683
|
+
]
|
|
26684
|
+
},
|
|
26685
|
+
{
|
|
26686
|
+
name: "pic:blipFill",
|
|
26687
|
+
elements: [
|
|
26688
|
+
{
|
|
26689
|
+
name: "a:blip",
|
|
26690
|
+
attributes: {
|
|
26691
|
+
"r:embed": imageId
|
|
26692
|
+
}
|
|
26693
|
+
},
|
|
26694
|
+
{
|
|
26695
|
+
name: "a:stretch",
|
|
26696
|
+
elements: [{ name: "a:fillRect" }]
|
|
26697
|
+
}
|
|
26698
|
+
]
|
|
26699
|
+
},
|
|
26700
|
+
{
|
|
26701
|
+
name: "pic:spPr",
|
|
26702
|
+
attributes: {
|
|
26703
|
+
bwMode: "auto"
|
|
26704
|
+
},
|
|
26705
|
+
elements: [
|
|
26706
|
+
{
|
|
26707
|
+
name: "a:xfrm",
|
|
26708
|
+
elements: [
|
|
26709
|
+
{
|
|
26710
|
+
name: "a:ext",
|
|
26711
|
+
attributes: {
|
|
26712
|
+
cx: size.w,
|
|
26713
|
+
cy: size.h
|
|
26714
|
+
}
|
|
26715
|
+
},
|
|
26716
|
+
{
|
|
26717
|
+
name: "a:off",
|
|
26718
|
+
attributes: {
|
|
26719
|
+
x: 0,
|
|
26720
|
+
y: 0
|
|
26721
|
+
}
|
|
26722
|
+
}
|
|
26723
|
+
]
|
|
26724
|
+
},
|
|
26725
|
+
{
|
|
26726
|
+
name: "a:prstGeom",
|
|
26727
|
+
attributes: { prst: "rect" },
|
|
26728
|
+
elements: [{ name: "a:avLst" }]
|
|
26729
|
+
},
|
|
26730
|
+
{
|
|
26731
|
+
name: "a:noFill"
|
|
26732
|
+
}
|
|
26733
|
+
]
|
|
26734
|
+
}
|
|
26735
|
+
]
|
|
26736
|
+
}
|
|
26737
|
+
]
|
|
26738
|
+
}
|
|
26739
|
+
]
|
|
26740
|
+
}
|
|
26741
|
+
]
|
|
26742
|
+
};
|
|
26743
|
+
};
|
|
26744
|
+
function getPngDimensions(base64) {
|
|
26745
|
+
if (!base64) return {};
|
|
26746
|
+
const type2 = base64.split(";")[0].split("/")[1];
|
|
26747
|
+
if (!base64 || type2 !== "png") {
|
|
26748
|
+
return {
|
|
26749
|
+
originalWidth: void 0,
|
|
26750
|
+
originalHeight: void 0
|
|
26751
|
+
};
|
|
26752
|
+
}
|
|
26753
|
+
let header = base64.split(",")[1].slice(0, 50);
|
|
26754
|
+
let uint8 = Uint8Array.from(atob(header), (c) => c.charCodeAt(0));
|
|
26755
|
+
let dataView = new DataView(uint8.buffer, 0, 28);
|
|
26756
|
+
return {
|
|
26757
|
+
originalWidth: dataView.getInt32(16),
|
|
26758
|
+
originalHeight: dataView.getInt32(20)
|
|
26759
|
+
};
|
|
26760
|
+
}
|
|
26761
|
+
function getScaledSize(originalWidth, originalHeight, maxWidth, maxHeight) {
|
|
26762
|
+
let scaledWidth = originalWidth;
|
|
26763
|
+
let scaledHeight = originalHeight;
|
|
26764
|
+
let ratio = Math.min(maxWidth / originalWidth, maxHeight / originalHeight);
|
|
26765
|
+
scaledWidth = Math.round(scaledWidth * ratio);
|
|
26766
|
+
scaledHeight = Math.round(scaledHeight * ratio);
|
|
26767
|
+
return { scaledWidth, scaledHeight };
|
|
26768
|
+
}
|
|
26769
|
+
function resizeKeepAspectRatio(width, height, maxWidth) {
|
|
26770
|
+
if (width > maxWidth) {
|
|
26771
|
+
let scale = maxWidth / width;
|
|
26772
|
+
let newHeight = Math.round(height * scale);
|
|
26773
|
+
return { width: maxWidth, height: newHeight };
|
|
26774
|
+
}
|
|
26775
|
+
return { width, height };
|
|
26776
|
+
}
|
|
26777
|
+
function addNewImageRelationship(params, imagePath) {
|
|
26778
|
+
const newId = "rId" + generateDocxRandomId();
|
|
26779
|
+
const newRel = {
|
|
26780
|
+
type: "element",
|
|
26781
|
+
name: "Relationship",
|
|
26782
|
+
attributes: {
|
|
26783
|
+
Id: newId,
|
|
26784
|
+
Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
|
|
26785
|
+
Target: imagePath
|
|
26786
|
+
}
|
|
26787
|
+
};
|
|
26788
|
+
params.relationships.push(newRel);
|
|
26789
|
+
return newId;
|
|
26790
|
+
}
|
|
26791
|
+
function translateAnchorNode(params) {
|
|
26792
|
+
const { attrs } = params.node;
|
|
26793
|
+
const anchorElements = [];
|
|
26794
|
+
const wrapElements = [];
|
|
26795
|
+
if (attrs.simplePos) {
|
|
26796
|
+
anchorElements.push({
|
|
26797
|
+
name: "wp:simplePos",
|
|
26798
|
+
attributes: {
|
|
26799
|
+
x: 0,
|
|
26800
|
+
y: 0
|
|
26801
|
+
}
|
|
26802
|
+
});
|
|
26803
|
+
}
|
|
26804
|
+
if (attrs.anchorData) {
|
|
26805
|
+
const hElements = [];
|
|
26806
|
+
if (attrs.marginOffset.left !== void 0) {
|
|
26807
|
+
hElements.push({
|
|
26808
|
+
name: "wp:posOffset",
|
|
26809
|
+
elements: [{ type: "text", text: pixelsToEmu(attrs.marginOffset.left).toString() }]
|
|
26810
|
+
});
|
|
26811
|
+
}
|
|
26812
|
+
if (attrs.anchorData.alignH) {
|
|
26813
|
+
hElements.push({
|
|
26814
|
+
name: "wp:align",
|
|
26815
|
+
elements: [{ type: "text", text: attrs.anchorData.alignH }]
|
|
26816
|
+
});
|
|
26817
|
+
}
|
|
26818
|
+
anchorElements.push({
|
|
26819
|
+
name: "wp:positionH",
|
|
26820
|
+
attributes: { relativeFrom: attrs.anchorData.hRelativeFrom },
|
|
26821
|
+
...hElements.length && { elements: hElements }
|
|
26822
|
+
});
|
|
26823
|
+
const vElements = [];
|
|
26824
|
+
if (attrs.marginOffset.top !== void 0) {
|
|
26825
|
+
vElements.push({
|
|
26826
|
+
name: "wp:posOffset",
|
|
26827
|
+
elements: [{ type: "text", text: pixelsToEmu(attrs.marginOffset.top).toString() }]
|
|
26828
|
+
});
|
|
26829
|
+
}
|
|
26830
|
+
if (attrs.anchorData.alignV) {
|
|
26831
|
+
vElements.push({
|
|
26832
|
+
name: "wp:align",
|
|
26833
|
+
elements: [{ type: "text", text: attrs.anchorData.alignV }]
|
|
26834
|
+
});
|
|
26835
|
+
}
|
|
26836
|
+
anchorElements.push({
|
|
26837
|
+
name: "wp:positionV",
|
|
26838
|
+
attributes: { relativeFrom: attrs.anchorData.vRelativeFrom },
|
|
26839
|
+
...vElements.length && { elements: vElements }
|
|
26840
|
+
});
|
|
26841
|
+
}
|
|
26842
|
+
if (attrs.wrapText) {
|
|
26843
|
+
wrapElements.push({
|
|
26844
|
+
name: "wp:wrapSquare",
|
|
26845
|
+
attributes: {
|
|
26846
|
+
wrapText: attrs.wrapText
|
|
26847
|
+
}
|
|
26848
|
+
});
|
|
26849
|
+
}
|
|
26850
|
+
if (attrs.wrapTopAndBottom) {
|
|
26851
|
+
wrapElements.push({
|
|
26852
|
+
name: "wp:wrapTopAndBottom"
|
|
26853
|
+
});
|
|
26854
|
+
}
|
|
26855
|
+
if (!wrapElements.length) {
|
|
26856
|
+
wrapElements.push({
|
|
26857
|
+
name: "wp:wrapNone"
|
|
26858
|
+
});
|
|
26859
|
+
}
|
|
26860
|
+
const nodeElements = translateImageNode(params);
|
|
26861
|
+
const inlineAttrs = {
|
|
26862
|
+
...nodeElements.attributes,
|
|
26863
|
+
simplePos: attrs.originalAttributes?.simplePos,
|
|
26864
|
+
relativeHeight: 1,
|
|
26865
|
+
behindDoc: attrs.originalAttributes?.behindDoc,
|
|
26866
|
+
locked: attrs.originalAttributes?.locked,
|
|
26867
|
+
layoutInCell: attrs.originalAttributes?.layoutInCell,
|
|
26868
|
+
allowOverlap: attrs.originalAttributes?.allowOverlap
|
|
26869
|
+
};
|
|
26870
|
+
const effectIndex = nodeElements.elements.findIndex((el) => el.name === "wp:effectExtent");
|
|
26871
|
+
const elementsWithWrap = [
|
|
26872
|
+
...nodeElements.elements.slice(0, effectIndex + 1),
|
|
26873
|
+
...wrapElements,
|
|
26874
|
+
...nodeElements.elements.slice(effectIndex + 1)
|
|
26875
|
+
];
|
|
26876
|
+
return {
|
|
26877
|
+
name: "wp:anchor",
|
|
26878
|
+
attributes: inlineAttrs,
|
|
26879
|
+
elements: [...anchorElements, ...elementsWithWrap]
|
|
26880
|
+
};
|
|
26881
|
+
}
|
|
26882
|
+
const XML_NODE_NAME$3 = "wp:anchor";
|
|
26883
|
+
const SD_NODE_NAME$3 = ["image"];
|
|
26884
|
+
const validXmlAttributes$3 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
|
|
26885
|
+
function encode$3(params, encodedAttrs) {
|
|
26886
|
+
const { node } = params.extraParams;
|
|
26887
|
+
if (!node || !node.type) {
|
|
26888
|
+
return null;
|
|
26889
|
+
}
|
|
26890
|
+
return handleAnchorNode(params);
|
|
26891
|
+
}
|
|
26892
|
+
function decode$3(params, decodedAttrs) {
|
|
26893
|
+
const { node } = params;
|
|
26894
|
+
if (!node || !node.type) {
|
|
26895
|
+
return null;
|
|
26896
|
+
}
|
|
26897
|
+
return translateAnchorNode(params);
|
|
26898
|
+
}
|
|
26899
|
+
const config$3 = {
|
|
26900
|
+
xmlName: XML_NODE_NAME$3,
|
|
26901
|
+
sdNodeOrKeyName: SD_NODE_NAME$3,
|
|
26902
|
+
type: NodeTranslator.translatorTypes.NODE,
|
|
26903
|
+
encode: encode$3,
|
|
26904
|
+
decode: decode$3,
|
|
26905
|
+
attributes: validXmlAttributes$3
|
|
26906
|
+
};
|
|
26907
|
+
const translator$3 = NodeTranslator.from(config$3);
|
|
26908
|
+
function handleInlineNode(params) {
|
|
26909
|
+
const { node } = params.extraParams;
|
|
26910
|
+
if (node.name !== "wp:inline") {
|
|
26911
|
+
return null;
|
|
26912
|
+
}
|
|
26913
|
+
return handleImageNode(node, params, false);
|
|
26914
|
+
}
|
|
26915
|
+
function translateInlineNode(params) {
|
|
26916
|
+
const nodeElements = translateImageNode(params);
|
|
26917
|
+
return {
|
|
26918
|
+
name: "wp:inline",
|
|
26919
|
+
attributes: nodeElements.attributes,
|
|
26920
|
+
elements: nodeElements.elements
|
|
26921
|
+
};
|
|
26922
|
+
}
|
|
26923
|
+
const XML_NODE_NAME$2 = "wp:inline";
|
|
26924
|
+
const SD_NODE_NAME$2 = ["image"];
|
|
26925
|
+
const validXmlAttributes$2 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
|
|
26926
|
+
function encode$2(params, encodedAttrs) {
|
|
26927
|
+
const { node } = params.extraParams;
|
|
26928
|
+
if (!node || !node.type) {
|
|
26929
|
+
return null;
|
|
26930
|
+
}
|
|
26931
|
+
return handleInlineNode(params);
|
|
26932
|
+
}
|
|
26933
|
+
function decode$2(params, decodedAttrs) {
|
|
26934
|
+
const { node } = params;
|
|
26935
|
+
if (!node || !node.type) {
|
|
26936
|
+
return null;
|
|
26937
|
+
}
|
|
26938
|
+
return translateInlineNode(params);
|
|
26939
|
+
}
|
|
26940
|
+
const config$2 = {
|
|
26941
|
+
xmlName: XML_NODE_NAME$2,
|
|
26942
|
+
sdNodeOrKeyName: SD_NODE_NAME$2,
|
|
26943
|
+
type: NodeTranslator.translatorTypes.NODE,
|
|
26944
|
+
encode: encode$2,
|
|
26945
|
+
decode: decode$2,
|
|
26946
|
+
attributes: validXmlAttributes$2
|
|
26947
|
+
};
|
|
26948
|
+
const translator$2 = NodeTranslator.from(config$2);
|
|
26949
|
+
const registeredHandlers = Object.freeze({
|
|
26950
|
+
"w:br": translator$m,
|
|
26951
|
+
"w:tab": translator$l,
|
|
26952
|
+
"w:p": translator$k,
|
|
26953
|
+
"wp:anchor": translator$3,
|
|
26954
|
+
"wp:inline": translator$2
|
|
26955
|
+
});
|
|
26956
|
+
const XML_NODE_NAME$1 = "w:drawing";
|
|
26957
|
+
const SD_NODE_NAME$1 = [];
|
|
26958
|
+
const validXmlAttributes$1 = [];
|
|
26959
|
+
function encode$1(params, encodedAttrs) {
|
|
26960
|
+
const nodes = params.nodes;
|
|
26961
|
+
const node = nodes[0];
|
|
26962
|
+
const validChildTranslators = ["wp:anchor", "wp:inline"];
|
|
26963
|
+
return node.elements.reduce((acc, child) => {
|
|
26964
|
+
if (acc) return acc;
|
|
26965
|
+
if (!validChildTranslators.includes(child.name)) return acc;
|
|
26966
|
+
const translator2 = registeredHandlers[child.name];
|
|
26967
|
+
return translator2.encode({ ...params, extraParams: { node: child } }) || acc;
|
|
26968
|
+
}, null);
|
|
26969
|
+
}
|
|
26970
|
+
function decode$1(params, decodedAttrs) {
|
|
26971
|
+
const { node } = params;
|
|
26972
|
+
if (!node || !node.type) {
|
|
26973
|
+
return null;
|
|
26974
|
+
}
|
|
26975
|
+
const handlerName = node.attrs.isAnchor ? "wp:anchor" : "wp:inline";
|
|
26976
|
+
const resultNode = registeredHandlers[handlerName].decode(params);
|
|
26977
|
+
return wrapTextInRun(
|
|
26978
|
+
{
|
|
26979
|
+
name: "w:drawing",
|
|
26980
|
+
elements: [resultNode]
|
|
26981
|
+
},
|
|
26982
|
+
[]
|
|
26983
|
+
);
|
|
26984
|
+
}
|
|
26985
|
+
const config$1 = {
|
|
26986
|
+
xmlName: XML_NODE_NAME$1,
|
|
26987
|
+
sdNodeOrKeyName: SD_NODE_NAME$1,
|
|
26988
|
+
type: NodeTranslator.translatorTypes.NODE,
|
|
26989
|
+
encode: encode$1,
|
|
26990
|
+
decode: decode$1,
|
|
26991
|
+
attributes: validXmlAttributes$1
|
|
26992
|
+
};
|
|
26993
|
+
const translator$1 = NodeTranslator.from(config$1);
|
|
26994
|
+
class CommandService {
|
|
26995
|
+
/**
|
|
26996
|
+
* @param {import('./commands/types/index.js').CommandServiceOptions} props
|
|
26997
|
+
*/
|
|
26998
|
+
constructor(props) {
|
|
26999
|
+
__publicField(this, "editor");
|
|
27000
|
+
__publicField(this, "rawCommands");
|
|
27001
|
+
this.editor = props.editor;
|
|
27002
|
+
this.rawCommands = this.editor.extensionService.commands;
|
|
27003
|
+
}
|
|
27004
|
+
/**
|
|
27005
|
+
* Static method for creating a service.
|
|
27006
|
+
* @param {import('./commands/types/index.js').CommandServiceOptions} params for the constructor.
|
|
27007
|
+
* @returns {CommandService} New instance of CommandService
|
|
27008
|
+
*/
|
|
27009
|
+
static create(params) {
|
|
27010
|
+
return new CommandService(params);
|
|
27011
|
+
}
|
|
27012
|
+
/**
|
|
27013
|
+
* Get editor state.
|
|
27014
|
+
* @returns {import("prosemirror-state").EditorState} Editor state
|
|
27015
|
+
*/
|
|
27016
|
+
get state() {
|
|
27017
|
+
return this.editor.state;
|
|
27018
|
+
}
|
|
27019
|
+
/**
|
|
27020
|
+
* Get all editor commands
|
|
27021
|
+
* @returns {import('./commands/types/index.js').EditorCommands} Commands object
|
|
27022
|
+
*/
|
|
27023
|
+
get commands() {
|
|
27024
|
+
const { editor, state: state2 } = this;
|
|
27025
|
+
const { view } = editor;
|
|
27026
|
+
const { tr } = state2;
|
|
27027
|
+
const props = this.createProps(tr);
|
|
27028
|
+
const entries = Object.entries(this.rawCommands).map(([name, command]) => {
|
|
27029
|
+
const method = (...args) => {
|
|
27030
|
+
const fn = command(...args)(props);
|
|
27031
|
+
if (!tr.getMeta("preventDispatch")) {
|
|
27032
|
+
view.dispatch(tr);
|
|
27033
|
+
}
|
|
27034
|
+
return fn;
|
|
27035
|
+
};
|
|
27036
|
+
return [name, method];
|
|
27037
|
+
});
|
|
27038
|
+
return (
|
|
27039
|
+
/** @type {import('./commands/types/index.js').EditorCommands} */
|
|
27040
|
+
Object.fromEntries(entries)
|
|
27041
|
+
);
|
|
27042
|
+
}
|
|
27043
|
+
/**
|
|
27044
|
+
* Create a chain of commands to call multiple commands at once.
|
|
27045
|
+
* @returns {(startTr?: Transaction, shouldDispatch?: boolean) => ChainableCommandObject} Function that creates a command chain
|
|
27046
|
+
*/
|
|
26424
27047
|
get chain() {
|
|
26425
27048
|
return () => this.createChain();
|
|
26426
27049
|
}
|
|
@@ -27705,7 +28328,10 @@ function prepareTextAnnotation(params) {
|
|
|
27705
28328
|
return getTextNodeForExport(attrs.displayLabel, [...marks, ...marksFromAttrs], params);
|
|
27706
28329
|
}
|
|
27707
28330
|
function prepareImageAnnotation(params, imageSize) {
|
|
27708
|
-
return
|
|
28331
|
+
return translator$1.decode({
|
|
28332
|
+
...params,
|
|
28333
|
+
imageSize
|
|
28334
|
+
});
|
|
27709
28335
|
}
|
|
27710
28336
|
function prepareCheckboxAnnotation(params) {
|
|
27711
28337
|
const {
|
|
@@ -27983,19 +28609,19 @@ function exportSchemaToJson(params) {
|
|
|
27983
28609
|
doc: translateDocumentNode,
|
|
27984
28610
|
body: translateBodyNode,
|
|
27985
28611
|
heading: translateHeadingNode,
|
|
27986
|
-
paragraph: translator$
|
|
28612
|
+
paragraph: translator$k,
|
|
27987
28613
|
text: translateTextNode,
|
|
27988
28614
|
bulletList: translateList,
|
|
27989
28615
|
orderedList: translateList,
|
|
27990
|
-
lineBreak: translator$
|
|
28616
|
+
lineBreak: translator$m,
|
|
27991
28617
|
table: translateTable,
|
|
27992
|
-
tableRow: translator$
|
|
27993
|
-
tableCell: translator$
|
|
28618
|
+
tableRow: translator$6,
|
|
28619
|
+
tableCell: translator$5,
|
|
27994
28620
|
bookmarkStart: translateBookmarkStart,
|
|
27995
28621
|
fieldAnnotation: translator,
|
|
27996
|
-
tab: translator$
|
|
27997
|
-
image:
|
|
27998
|
-
hardBreak: translator$
|
|
28622
|
+
tab: translator$l,
|
|
28623
|
+
image: translator$1,
|
|
28624
|
+
hardBreak: translator$m,
|
|
27999
28625
|
commentRangeStart: () => translateCommentNode(params, "Start"),
|
|
28000
28626
|
commentRangeEnd: () => translateCommentNode(params, "End"),
|
|
28001
28627
|
commentReference: () => null,
|
|
@@ -28327,7 +28953,7 @@ function translateTextNode(params) {
|
|
|
28327
28953
|
const isTrackedNode = node.marks?.some((m2) => trackedMarks.includes(m2.type));
|
|
28328
28954
|
if (isTrackedNode) return translateTrackedNode(params);
|
|
28329
28955
|
const isLinkNode = node.marks?.some((m2) => m2.type === "link");
|
|
28330
|
-
if (isLinkNode) return translator$
|
|
28956
|
+
if (isLinkNode) return translator$4.decode(params);
|
|
28331
28957
|
const { text, marks = [] } = node;
|
|
28332
28958
|
return getTextNodeForExport(text, marks, params);
|
|
28333
28959
|
}
|
|
@@ -28460,20 +29086,6 @@ function addNewLinkRelationship(params, link) {
|
|
|
28460
29086
|
});
|
|
28461
29087
|
return newId;
|
|
28462
29088
|
}
|
|
28463
|
-
function addNewImageRelationship(params, imagePath) {
|
|
28464
|
-
const newId = "rId" + generateDocxRandomId();
|
|
28465
|
-
const newRel = {
|
|
28466
|
-
type: "element",
|
|
28467
|
-
name: "Relationship",
|
|
28468
|
-
attributes: {
|
|
28469
|
-
Id: newId,
|
|
28470
|
-
Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
|
|
28471
|
-
Target: imagePath
|
|
28472
|
-
}
|
|
28473
|
-
};
|
|
28474
|
-
params.relationships.push(newRel);
|
|
28475
|
-
return newId;
|
|
28476
|
-
}
|
|
28477
29089
|
function translateList(params) {
|
|
28478
29090
|
const { node, editor } = params;
|
|
28479
29091
|
const listItem = node.content[0];
|
|
@@ -28781,395 +29393,56 @@ function translateMark(mark) {
|
|
|
28781
29393
|
case "underline":
|
|
28782
29394
|
markElement.type = "element";
|
|
28783
29395
|
markElement.attributes["w:val"] = attrs.underlineType;
|
|
28784
|
-
break;
|
|
28785
|
-
// Text style cases
|
|
28786
|
-
case "fontSize":
|
|
28787
|
-
value = attrs.fontSize;
|
|
28788
|
-
markElement.attributes["w:val"] = value.slice(0, -2) * 2;
|
|
28789
|
-
break;
|
|
28790
|
-
case "fontFamily":
|
|
28791
|
-
value = attrs.fontFamily;
|
|
28792
|
-
["w:ascii", "w:eastAsia", "w:hAnsi", "w:cs"].forEach((attr) => {
|
|
28793
|
-
const parsedValue = value.split(", ");
|
|
28794
|
-
markElement.attributes[attr] = parsedValue[0] ? parsedValue[0] : value;
|
|
28795
|
-
});
|
|
28796
|
-
break;
|
|
28797
|
-
// Add ability to get run styleIds from textStyle marks and inject to run properties in word
|
|
28798
|
-
case "styleId":
|
|
28799
|
-
markElement.name = "w:rStyle";
|
|
28800
|
-
markElement.attributes["w:val"] = attrs.styleId;
|
|
28801
|
-
break;
|
|
28802
|
-
case "color":
|
|
28803
|
-
let processedColor = attrs.color.replace(/^#/, "").replace(/;$/, "");
|
|
28804
|
-
if (processedColor.startsWith("rgb")) {
|
|
28805
|
-
processedColor = rgbToHex(processedColor);
|
|
28806
|
-
}
|
|
28807
|
-
markElement.attributes["w:val"] = processedColor;
|
|
28808
|
-
break;
|
|
28809
|
-
case "textAlign":
|
|
28810
|
-
markElement.attributes["w:val"] = attrs.textAlign;
|
|
28811
|
-
break;
|
|
28812
|
-
case "textIndent":
|
|
28813
|
-
markElement.attributes["w:firstline"] = inchesToTwips(attrs.textIndent);
|
|
28814
|
-
break;
|
|
28815
|
-
case "textTransform":
|
|
28816
|
-
if (attrs?.textTransform === "none") {
|
|
28817
|
-
markElement.attributes["w:val"] = "0";
|
|
28818
|
-
} else {
|
|
28819
|
-
delete markElement.attributes;
|
|
28820
|
-
}
|
|
28821
|
-
markElement.type = "element";
|
|
28822
|
-
break;
|
|
28823
|
-
case "lineHeight":
|
|
28824
|
-
markElement.attributes["w:line"] = linesToTwips(attrs.lineHeight);
|
|
28825
|
-
break;
|
|
28826
|
-
case "highlight":
|
|
28827
|
-
markElement.attributes["w:fill"] = attrs.color?.substring(1);
|
|
28828
|
-
markElement.attributes["w:color"] = "auto";
|
|
28829
|
-
markElement.attributes["w:val"] = "clear";
|
|
28830
|
-
markElement.name = "w:shd";
|
|
28831
|
-
break;
|
|
28832
|
-
}
|
|
28833
|
-
return markElement;
|
|
28834
|
-
}
|
|
28835
|
-
function getPngDimensions(base64) {
|
|
28836
|
-
if (!base64) return {};
|
|
28837
|
-
const type2 = base64.split(";")[0].split("/")[1];
|
|
28838
|
-
if (!base64 || type2 !== "png") {
|
|
28839
|
-
return {
|
|
28840
|
-
originalWidth: void 0,
|
|
28841
|
-
originalHeight: void 0
|
|
28842
|
-
};
|
|
28843
|
-
}
|
|
28844
|
-
let header = base64.split(",")[1].slice(0, 50);
|
|
28845
|
-
let uint8 = Uint8Array.from(atob(header), (c) => c.charCodeAt(0));
|
|
28846
|
-
let dataView = new DataView(uint8.buffer, 0, 28);
|
|
28847
|
-
return {
|
|
28848
|
-
originalWidth: dataView.getInt32(16),
|
|
28849
|
-
originalHeight: dataView.getInt32(20)
|
|
28850
|
-
};
|
|
28851
|
-
}
|
|
28852
|
-
function getScaledSize(originalWidth, originalHeight, maxWidth, maxHeight) {
|
|
28853
|
-
let scaledWidth = originalWidth;
|
|
28854
|
-
let scaledHeight = originalHeight;
|
|
28855
|
-
let ratio = Math.min(maxWidth / originalWidth, maxHeight / originalHeight);
|
|
28856
|
-
scaledWidth = Math.round(scaledWidth * ratio);
|
|
28857
|
-
scaledHeight = Math.round(scaledHeight * ratio);
|
|
28858
|
-
return { scaledWidth, scaledHeight };
|
|
28859
|
-
}
|
|
28860
|
-
function translateImageNode(params, imageSize) {
|
|
28861
|
-
const {
|
|
28862
|
-
node: { attrs = {} },
|
|
28863
|
-
tableCell
|
|
28864
|
-
} = params;
|
|
28865
|
-
let imageId = attrs.rId;
|
|
28866
|
-
const src = attrs.src || attrs.imageSrc;
|
|
28867
|
-
const { originalWidth, originalHeight } = getPngDimensions(src);
|
|
28868
|
-
let imageName;
|
|
28869
|
-
if (params.node.type === "image") {
|
|
28870
|
-
if (src?.startsWith("data:")) {
|
|
28871
|
-
imageName = getFallbackImageNameFromDataUri(src);
|
|
28872
|
-
} else {
|
|
28873
|
-
imageName = src?.split("/").pop();
|
|
28874
|
-
}
|
|
28875
|
-
} else {
|
|
28876
|
-
imageName = attrs.fieldId;
|
|
28877
|
-
}
|
|
28878
|
-
imageName = sanitizeDocxMediaName(imageName);
|
|
28879
|
-
let size = attrs.size ? {
|
|
28880
|
-
w: pixelsToEmu(attrs.size.width),
|
|
28881
|
-
h: pixelsToEmu(attrs.size.height)
|
|
28882
|
-
} : imageSize;
|
|
28883
|
-
if (originalWidth && originalHeight) {
|
|
28884
|
-
const boxWidthPx = emuToPixels(size.w);
|
|
28885
|
-
const boxHeightPx = emuToPixels(size.h);
|
|
28886
|
-
const { scaledWidth, scaledHeight } = getScaledSize(originalWidth, originalHeight, boxWidthPx, boxHeightPx);
|
|
28887
|
-
size = {
|
|
28888
|
-
w: pixelsToEmu(scaledWidth),
|
|
28889
|
-
h: pixelsToEmu(scaledHeight)
|
|
28890
|
-
};
|
|
28891
|
-
}
|
|
28892
|
-
if (tableCell) {
|
|
28893
|
-
const colwidthSum = tableCell.attrs.colwidth.reduce((acc, curr) => acc + curr, 0);
|
|
28894
|
-
const leftMargin = tableCell.attrs.cellMargins?.left || 8;
|
|
28895
|
-
const rightMargin = tableCell.attrs.cellMargins?.right || 8;
|
|
28896
|
-
const maxWidthEmu = pixelsToEmu(colwidthSum - (leftMargin + rightMargin));
|
|
28897
|
-
const { width: w2, height: h2 } = resizeKeepAspectRatio(size.w, size.h, maxWidthEmu);
|
|
28898
|
-
if (w2 && h2) size = { w: w2, h: h2 };
|
|
28899
|
-
}
|
|
28900
|
-
if (params.node.type === "image" && !imageId) {
|
|
28901
|
-
const path = src?.split("word/")[1];
|
|
28902
|
-
imageId = addNewImageRelationship(params, path);
|
|
28903
|
-
} else if (params.node.type === "fieldAnnotation" && !imageId) {
|
|
28904
|
-
const type2 = src?.split(";")[0].split("/")[1];
|
|
28905
|
-
if (!type2) {
|
|
28906
|
-
return prepareTextAnnotation(params);
|
|
28907
|
-
}
|
|
28908
|
-
const sanitizedHash = sanitizeDocxMediaName(attrs.hash, generateDocxRandomId(4));
|
|
28909
|
-
const fileName = `${imageName}_${sanitizedHash}.${type2}`;
|
|
28910
|
-
const relationshipTarget = `media/${fileName}`;
|
|
28911
|
-
const packagePath = `word/${relationshipTarget}`;
|
|
28912
|
-
imageId = addNewImageRelationship(params, relationshipTarget);
|
|
28913
|
-
params.media[packagePath] = src;
|
|
28914
|
-
}
|
|
28915
|
-
let inlineAttrs = attrs.originalPadding || {
|
|
28916
|
-
distT: 0,
|
|
28917
|
-
distB: 0,
|
|
28918
|
-
distL: 0,
|
|
28919
|
-
distR: 0
|
|
28920
|
-
};
|
|
28921
|
-
const anchorElements = [];
|
|
28922
|
-
let wrapProp = [];
|
|
28923
|
-
if (attrs.isAnchor) {
|
|
28924
|
-
inlineAttrs = {
|
|
28925
|
-
...inlineAttrs,
|
|
28926
|
-
simplePos: attrs.originalAttributes?.simplePos,
|
|
28927
|
-
relativeHeight: 1,
|
|
28928
|
-
behindDoc: attrs.originalAttributes?.behindDoc,
|
|
28929
|
-
locked: attrs.originalAttributes?.locked,
|
|
28930
|
-
layoutInCell: attrs.originalAttributes?.layoutInCell,
|
|
28931
|
-
allowOverlap: attrs.originalAttributes?.allowOverlap
|
|
28932
|
-
};
|
|
28933
|
-
if (attrs.simplePos) {
|
|
28934
|
-
anchorElements.push({
|
|
28935
|
-
name: "wp:simplePos",
|
|
28936
|
-
attributes: {
|
|
28937
|
-
x: 0,
|
|
28938
|
-
y: 0
|
|
28939
|
-
}
|
|
28940
|
-
});
|
|
28941
|
-
}
|
|
28942
|
-
if (attrs.anchorData) {
|
|
28943
|
-
anchorElements.push({
|
|
28944
|
-
name: "wp:positionH",
|
|
28945
|
-
attributes: {
|
|
28946
|
-
relativeFrom: attrs.anchorData.hRelativeFrom
|
|
28947
|
-
},
|
|
28948
|
-
...attrs.marginOffset.left !== void 0 && {
|
|
28949
|
-
elements: [
|
|
28950
|
-
{
|
|
28951
|
-
name: "wp:posOffset",
|
|
28952
|
-
elements: [
|
|
28953
|
-
{
|
|
28954
|
-
type: "text",
|
|
28955
|
-
text: pixelsToEmu(attrs.marginOffset.left).toString()
|
|
28956
|
-
}
|
|
28957
|
-
]
|
|
28958
|
-
}
|
|
28959
|
-
]
|
|
28960
|
-
},
|
|
28961
|
-
...attrs.anchorData.alignH && {
|
|
28962
|
-
elements: [
|
|
28963
|
-
{
|
|
28964
|
-
name: "wp:align",
|
|
28965
|
-
elements: [
|
|
28966
|
-
{
|
|
28967
|
-
type: "text",
|
|
28968
|
-
text: attrs.anchorData.alignH
|
|
28969
|
-
}
|
|
28970
|
-
]
|
|
28971
|
-
}
|
|
28972
|
-
]
|
|
28973
|
-
}
|
|
28974
|
-
});
|
|
28975
|
-
anchorElements.push({
|
|
28976
|
-
name: "wp:positionV",
|
|
28977
|
-
attributes: {
|
|
28978
|
-
relativeFrom: attrs.anchorData.vRelativeFrom
|
|
28979
|
-
},
|
|
28980
|
-
...attrs.marginOffset.top !== void 0 && {
|
|
28981
|
-
elements: [
|
|
28982
|
-
{
|
|
28983
|
-
name: "wp:posOffset",
|
|
28984
|
-
elements: [
|
|
28985
|
-
{
|
|
28986
|
-
type: "text",
|
|
28987
|
-
text: pixelsToEmu(attrs.marginOffset.top).toString()
|
|
28988
|
-
}
|
|
28989
|
-
]
|
|
28990
|
-
}
|
|
28991
|
-
]
|
|
28992
|
-
},
|
|
28993
|
-
...attrs.anchorData.alignV && {
|
|
28994
|
-
elements: [
|
|
28995
|
-
{
|
|
28996
|
-
name: "wp:align",
|
|
28997
|
-
elements: [
|
|
28998
|
-
{
|
|
28999
|
-
type: "text",
|
|
29000
|
-
text: attrs.anchorData.alignV
|
|
29001
|
-
}
|
|
29002
|
-
]
|
|
29003
|
-
}
|
|
29004
|
-
]
|
|
29005
|
-
}
|
|
29006
|
-
});
|
|
29007
|
-
}
|
|
29008
|
-
if (attrs.wrapText) {
|
|
29009
|
-
wrapProp.push({
|
|
29010
|
-
name: "wp:wrapSquare",
|
|
29011
|
-
attributes: {
|
|
29012
|
-
wrapText: attrs.wrapText
|
|
29013
|
-
}
|
|
29014
|
-
});
|
|
29015
|
-
}
|
|
29016
|
-
if (attrs.wrapTopAndBottom) {
|
|
29017
|
-
wrapProp.push({
|
|
29018
|
-
name: "wp:wrapTopAndBottom"
|
|
29019
|
-
});
|
|
29020
|
-
}
|
|
29021
|
-
if (attrs.isAnchor && !wrapProp.length) {
|
|
29022
|
-
wrapProp.push({
|
|
29023
|
-
name: "wp:wrapNone"
|
|
29396
|
+
break;
|
|
29397
|
+
// Text style cases
|
|
29398
|
+
case "fontSize":
|
|
29399
|
+
value = attrs.fontSize;
|
|
29400
|
+
markElement.attributes["w:val"] = value.slice(0, -2) * 2;
|
|
29401
|
+
break;
|
|
29402
|
+
case "fontFamily":
|
|
29403
|
+
value = attrs.fontFamily;
|
|
29404
|
+
["w:ascii", "w:eastAsia", "w:hAnsi", "w:cs"].forEach((attr) => {
|
|
29405
|
+
const parsedValue = value.split(", ");
|
|
29406
|
+
markElement.attributes[attr] = parsedValue[0] ? parsedValue[0] : value;
|
|
29024
29407
|
});
|
|
29025
|
-
|
|
29408
|
+
break;
|
|
29409
|
+
// Add ability to get run styleIds from textStyle marks and inject to run properties in word
|
|
29410
|
+
case "styleId":
|
|
29411
|
+
markElement.name = "w:rStyle";
|
|
29412
|
+
markElement.attributes["w:val"] = attrs.styleId;
|
|
29413
|
+
break;
|
|
29414
|
+
case "color":
|
|
29415
|
+
let processedColor = attrs.color.replace(/^#/, "").replace(/;$/, "");
|
|
29416
|
+
if (processedColor.startsWith("rgb")) {
|
|
29417
|
+
processedColor = rgbToHex(processedColor);
|
|
29418
|
+
}
|
|
29419
|
+
markElement.attributes["w:val"] = processedColor;
|
|
29420
|
+
break;
|
|
29421
|
+
case "textAlign":
|
|
29422
|
+
markElement.attributes["w:val"] = attrs.textAlign;
|
|
29423
|
+
break;
|
|
29424
|
+
case "textIndent":
|
|
29425
|
+
markElement.attributes["w:firstline"] = inchesToTwips(attrs.textIndent);
|
|
29426
|
+
break;
|
|
29427
|
+
case "textTransform":
|
|
29428
|
+
if (attrs?.textTransform === "none") {
|
|
29429
|
+
markElement.attributes["w:val"] = "0";
|
|
29430
|
+
} else {
|
|
29431
|
+
delete markElement.attributes;
|
|
29432
|
+
}
|
|
29433
|
+
markElement.type = "element";
|
|
29434
|
+
break;
|
|
29435
|
+
case "lineHeight":
|
|
29436
|
+
markElement.attributes["w:line"] = linesToTwips(attrs.lineHeight);
|
|
29437
|
+
break;
|
|
29438
|
+
case "highlight":
|
|
29439
|
+
markElement.attributes["w:fill"] = attrs.color?.substring(1);
|
|
29440
|
+
markElement.attributes["w:color"] = "auto";
|
|
29441
|
+
markElement.attributes["w:val"] = "clear";
|
|
29442
|
+
markElement.name = "w:shd";
|
|
29443
|
+
break;
|
|
29026
29444
|
}
|
|
29027
|
-
|
|
29028
|
-
const pictureXmlns = "http://schemas.openxmlformats.org/drawingml/2006/picture";
|
|
29029
|
-
const textNode = wrapTextInRun(
|
|
29030
|
-
{
|
|
29031
|
-
name: "w:drawing",
|
|
29032
|
-
elements: [
|
|
29033
|
-
{
|
|
29034
|
-
name: attrs.isAnchor ? "wp:anchor" : "wp:inline",
|
|
29035
|
-
attributes: inlineAttrs,
|
|
29036
|
-
elements: [
|
|
29037
|
-
...anchorElements,
|
|
29038
|
-
{
|
|
29039
|
-
name: "wp:extent",
|
|
29040
|
-
attributes: {
|
|
29041
|
-
cx: size.w,
|
|
29042
|
-
cy: size.h
|
|
29043
|
-
}
|
|
29044
|
-
},
|
|
29045
|
-
{
|
|
29046
|
-
name: "wp:effectExtent",
|
|
29047
|
-
attributes: {
|
|
29048
|
-
l: 0,
|
|
29049
|
-
t: 0,
|
|
29050
|
-
r: 0,
|
|
29051
|
-
b: 0
|
|
29052
|
-
}
|
|
29053
|
-
},
|
|
29054
|
-
...wrapProp,
|
|
29055
|
-
{
|
|
29056
|
-
name: "wp:docPr",
|
|
29057
|
-
attributes: {
|
|
29058
|
-
id: attrs.id || 0,
|
|
29059
|
-
name: attrs.alt || `Picture ${imageName}`
|
|
29060
|
-
}
|
|
29061
|
-
},
|
|
29062
|
-
{
|
|
29063
|
-
name: "wp:cNvGraphicFramePr",
|
|
29064
|
-
elements: [
|
|
29065
|
-
{
|
|
29066
|
-
name: "a:graphicFrameLocks",
|
|
29067
|
-
attributes: {
|
|
29068
|
-
"xmlns:a": drawingXmlns,
|
|
29069
|
-
noChangeAspect: 1
|
|
29070
|
-
}
|
|
29071
|
-
}
|
|
29072
|
-
]
|
|
29073
|
-
},
|
|
29074
|
-
{
|
|
29075
|
-
name: "a:graphic",
|
|
29076
|
-
attributes: { "xmlns:a": drawingXmlns },
|
|
29077
|
-
elements: [
|
|
29078
|
-
{
|
|
29079
|
-
name: "a:graphicData",
|
|
29080
|
-
attributes: { uri: pictureXmlns },
|
|
29081
|
-
elements: [
|
|
29082
|
-
{
|
|
29083
|
-
name: "pic:pic",
|
|
29084
|
-
attributes: { "xmlns:pic": pictureXmlns },
|
|
29085
|
-
elements: [
|
|
29086
|
-
{
|
|
29087
|
-
name: "pic:nvPicPr",
|
|
29088
|
-
elements: [
|
|
29089
|
-
{
|
|
29090
|
-
name: "pic:cNvPr",
|
|
29091
|
-
attributes: {
|
|
29092
|
-
id: attrs.id || 0,
|
|
29093
|
-
name: attrs.title || `Picture ${imageName}`
|
|
29094
|
-
}
|
|
29095
|
-
},
|
|
29096
|
-
{
|
|
29097
|
-
name: "pic:cNvPicPr",
|
|
29098
|
-
elements: [
|
|
29099
|
-
{
|
|
29100
|
-
name: "a:picLocks",
|
|
29101
|
-
attributes: {
|
|
29102
|
-
noChangeAspect: 1,
|
|
29103
|
-
noChangeArrowheads: 1
|
|
29104
|
-
}
|
|
29105
|
-
}
|
|
29106
|
-
]
|
|
29107
|
-
}
|
|
29108
|
-
]
|
|
29109
|
-
},
|
|
29110
|
-
{
|
|
29111
|
-
name: "pic:blipFill",
|
|
29112
|
-
elements: [
|
|
29113
|
-
{
|
|
29114
|
-
name: "a:blip",
|
|
29115
|
-
attributes: {
|
|
29116
|
-
"r:embed": imageId
|
|
29117
|
-
}
|
|
29118
|
-
},
|
|
29119
|
-
{
|
|
29120
|
-
name: "a:stretch",
|
|
29121
|
-
elements: [{ name: "a:fillRect" }]
|
|
29122
|
-
}
|
|
29123
|
-
]
|
|
29124
|
-
},
|
|
29125
|
-
{
|
|
29126
|
-
name: "pic:spPr",
|
|
29127
|
-
attributes: {
|
|
29128
|
-
bwMode: "auto"
|
|
29129
|
-
},
|
|
29130
|
-
elements: [
|
|
29131
|
-
{
|
|
29132
|
-
name: "a:xfrm",
|
|
29133
|
-
elements: [
|
|
29134
|
-
{
|
|
29135
|
-
name: "a:ext",
|
|
29136
|
-
attributes: {
|
|
29137
|
-
cx: size.w,
|
|
29138
|
-
cy: size.h
|
|
29139
|
-
}
|
|
29140
|
-
},
|
|
29141
|
-
{
|
|
29142
|
-
name: "a:off",
|
|
29143
|
-
attributes: {
|
|
29144
|
-
x: 0,
|
|
29145
|
-
y: 0
|
|
29146
|
-
}
|
|
29147
|
-
}
|
|
29148
|
-
]
|
|
29149
|
-
},
|
|
29150
|
-
{
|
|
29151
|
-
name: "a:prstGeom",
|
|
29152
|
-
attributes: { prst: "rect" },
|
|
29153
|
-
elements: [{ name: "a:avLst" }]
|
|
29154
|
-
},
|
|
29155
|
-
{
|
|
29156
|
-
name: "a:noFill"
|
|
29157
|
-
}
|
|
29158
|
-
]
|
|
29159
|
-
}
|
|
29160
|
-
]
|
|
29161
|
-
}
|
|
29162
|
-
]
|
|
29163
|
-
}
|
|
29164
|
-
]
|
|
29165
|
-
}
|
|
29166
|
-
]
|
|
29167
|
-
}
|
|
29168
|
-
]
|
|
29169
|
-
},
|
|
29170
|
-
[]
|
|
29171
|
-
);
|
|
29172
|
-
return textNode;
|
|
29445
|
+
return markElement;
|
|
29173
29446
|
}
|
|
29174
29447
|
function translateShapeContainer(params) {
|
|
29175
29448
|
const { node } = params;
|
|
@@ -29348,14 +29621,6 @@ generateXml_fn = function(node) {
|
|
|
29348
29621
|
if (!selfClosing) tags.push(`</${name}>`);
|
|
29349
29622
|
return tags;
|
|
29350
29623
|
};
|
|
29351
|
-
function resizeKeepAspectRatio(width, height, maxWidth) {
|
|
29352
|
-
if (width > maxWidth) {
|
|
29353
|
-
let scale = maxWidth / width;
|
|
29354
|
-
let newHeight = Math.round(height * scale);
|
|
29355
|
-
return { width: maxWidth, height: newHeight };
|
|
29356
|
-
}
|
|
29357
|
-
return { width, height };
|
|
29358
|
-
}
|
|
29359
29624
|
const translatePageNumberNode = (params) => {
|
|
29360
29625
|
const outputMarks = processOutputMarks(params.node.attrs?.marksAsAttrs || []);
|
|
29361
29626
|
return getAutoPageJson("PAGE", outputMarks);
|
|
@@ -29439,7 +29704,7 @@ const getInitialJSON = (parsedDocx, fallbackXml = defaultInitialXml) => {
|
|
|
29439
29704
|
return parsedDocx["word/document.xml"] || parseXmlToJson(fallbackXml);
|
|
29440
29705
|
};
|
|
29441
29706
|
const handleDrawingNode = (params) => {
|
|
29442
|
-
const { nodes
|
|
29707
|
+
const { nodes } = params;
|
|
29443
29708
|
const validNodes = ["w:drawing", "w:p"];
|
|
29444
29709
|
if (nodes.length === 0 || !validNodes.includes(nodes[0].name)) {
|
|
29445
29710
|
return { nodes: [], consumed: 0 };
|
|
@@ -29449,167 +29714,9 @@ const handleDrawingNode = (params) => {
|
|
|
29449
29714
|
if (mainNode.name === "w:drawing") node = mainNode;
|
|
29450
29715
|
else node = mainNode.elements.find((el) => el.name === "w:drawing");
|
|
29451
29716
|
if (!node) return { nodes: [], consumed: 0 };
|
|
29452
|
-
|
|
29453
|
-
const
|
|
29454
|
-
|
|
29455
|
-
const isAnchor = elements.find((el) => el.name === "wp:anchor");
|
|
29456
|
-
if (isAnchor) {
|
|
29457
|
-
result = handleImageImport(elements[0], currentFileName, params);
|
|
29458
|
-
if (result && result.attrs) result.attrs.isAnchor = isAnchor;
|
|
29459
|
-
}
|
|
29460
|
-
const inlineImage = elements.find((el) => el.name === "wp:inline");
|
|
29461
|
-
if (inlineImage) result = handleImageImport(inlineImage, currentFileName, params);
|
|
29462
|
-
return { nodes: result ? [result] : [], consumed: 1 };
|
|
29463
|
-
};
|
|
29464
|
-
function handleImageImport(node, currentFileName, params) {
|
|
29465
|
-
const { docx } = params;
|
|
29466
|
-
const { attributes } = node;
|
|
29467
|
-
const padding = {
|
|
29468
|
-
top: emuToPixels(attributes["distT"]),
|
|
29469
|
-
bottom: emuToPixels(attributes["distB"]),
|
|
29470
|
-
left: emuToPixels(attributes["distL"]),
|
|
29471
|
-
right: emuToPixels(attributes["distR"])
|
|
29472
|
-
};
|
|
29473
|
-
const extent = node.elements.find((el) => el.name === "wp:extent");
|
|
29474
|
-
const size = {
|
|
29475
|
-
width: emuToPixels(extent.attributes?.cx),
|
|
29476
|
-
height: emuToPixels(extent.attributes?.cy)
|
|
29477
|
-
};
|
|
29478
|
-
const graphic = node.elements.find((el) => el.name === "a:graphic");
|
|
29479
|
-
const graphicData = graphic.elements.find((el) => el.name === "a:graphicData");
|
|
29480
|
-
const { uri: uri2 } = graphicData?.attributes || {};
|
|
29481
|
-
const shapeURI = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape";
|
|
29482
|
-
if (!!uri2 && uri2 === shapeURI) {
|
|
29483
|
-
return handleShapeDrawing(params, node, graphicData);
|
|
29484
|
-
}
|
|
29485
|
-
const picture = graphicData.elements.find((el) => el.name === "pic:pic");
|
|
29486
|
-
if (!picture || !picture.elements) return null;
|
|
29487
|
-
const blipFill = picture.elements.find((el) => el.name === "pic:blipFill");
|
|
29488
|
-
const blip = blipFill.elements.find((el) => el.name === "a:blip");
|
|
29489
|
-
const positionHTag = node.elements.find((el) => el.name === "wp:positionH");
|
|
29490
|
-
const positionH = positionHTag?.elements.find((el) => el.name === "wp:posOffset");
|
|
29491
|
-
const positionHValue = emuToPixels(positionH?.elements[0]?.text);
|
|
29492
|
-
const hRelativeFrom = positionHTag?.attributes.relativeFrom;
|
|
29493
|
-
const alignH = positionHTag?.elements.find((el) => el.name === "wp:align")?.elements[0]?.text;
|
|
29494
|
-
const positionVTag = node.elements.find((el) => el.name === "wp:positionV");
|
|
29495
|
-
const positionV = positionVTag?.elements?.find((el) => el.name === "wp:posOffset");
|
|
29496
|
-
const positionVValue = emuToPixels(positionV?.elements[0]?.text);
|
|
29497
|
-
const vRelativeFrom = positionVTag?.attributes.relativeFrom;
|
|
29498
|
-
const alignV = positionVTag?.elements?.find((el) => el.name === "wp:align")?.elements[0]?.text;
|
|
29499
|
-
const simplePos = node.elements.find((el) => el.name === "wp:simplePos");
|
|
29500
|
-
const wrapSquare = node.elements.find((el) => el.name === "wp:wrapSquare");
|
|
29501
|
-
const wrapTopAndBottom = node.elements.find((el) => el.name === "wp:wrapTopAndBottom");
|
|
29502
|
-
const docPr = node.elements.find((el) => el.name === "wp:docPr");
|
|
29503
|
-
let anchorData = null;
|
|
29504
|
-
if (hRelativeFrom || alignH || vRelativeFrom || alignV) {
|
|
29505
|
-
anchorData = {
|
|
29506
|
-
hRelativeFrom,
|
|
29507
|
-
vRelativeFrom,
|
|
29508
|
-
alignH,
|
|
29509
|
-
alignV
|
|
29510
|
-
};
|
|
29511
|
-
}
|
|
29512
|
-
const marginOffset = {
|
|
29513
|
-
left: positionHValue,
|
|
29514
|
-
top: positionVValue
|
|
29515
|
-
};
|
|
29516
|
-
const { attributes: blipAttributes = {} } = blip;
|
|
29517
|
-
const rEmbed = blipAttributes["r:embed"];
|
|
29518
|
-
if (!rEmbed) return null;
|
|
29519
|
-
const currentFile = currentFileName || "document.xml";
|
|
29520
|
-
let rels = docx[`word/_rels/${currentFile}.rels`];
|
|
29521
|
-
if (!rels) rels = docx[`word/_rels/document.xml.rels`];
|
|
29522
|
-
const relationships = rels.elements.find((el) => el.name === "Relationships");
|
|
29523
|
-
const { elements } = relationships;
|
|
29524
|
-
const rel = elements.find((el) => el.attributes["Id"] === rEmbed);
|
|
29525
|
-
if (!rel) return null;
|
|
29526
|
-
const { attributes: relAttributes } = rel;
|
|
29527
|
-
const targetPath = relAttributes["Target"];
|
|
29528
|
-
let path = `word/${targetPath}`;
|
|
29529
|
-
if (targetPath.startsWith("/word") || targetPath.startsWith("/media")) path = targetPath.substring(1);
|
|
29530
|
-
const extension = targetPath.substring(targetPath.lastIndexOf(".") + 1);
|
|
29531
|
-
return {
|
|
29532
|
-
type: "image",
|
|
29533
|
-
attrs: {
|
|
29534
|
-
src: path,
|
|
29535
|
-
alt: ["emf", "wmf"].includes(extension) ? "Unable to render EMF/WMF image" : docPr?.attributes.name || "Image",
|
|
29536
|
-
extension,
|
|
29537
|
-
id: docPr?.attributes.id || "",
|
|
29538
|
-
title: docPr?.attributes.descr || "Image",
|
|
29539
|
-
inline: true,
|
|
29540
|
-
padding,
|
|
29541
|
-
marginOffset,
|
|
29542
|
-
size,
|
|
29543
|
-
anchorData,
|
|
29544
|
-
...simplePos && {
|
|
29545
|
-
simplePos: {
|
|
29546
|
-
x: simplePos.attributes.x,
|
|
29547
|
-
y: simplePos.attributes.y
|
|
29548
|
-
}
|
|
29549
|
-
},
|
|
29550
|
-
...wrapSquare && {
|
|
29551
|
-
wrapText: wrapSquare.attributes.wrapText
|
|
29552
|
-
},
|
|
29553
|
-
wrapTopAndBottom: !!wrapTopAndBottom,
|
|
29554
|
-
originalPadding: {
|
|
29555
|
-
distT: attributes["distT"],
|
|
29556
|
-
distB: attributes["distB"],
|
|
29557
|
-
distL: attributes["distL"],
|
|
29558
|
-
distR: attributes["distR"]
|
|
29559
|
-
},
|
|
29560
|
-
originalAttributes: node.attributes,
|
|
29561
|
-
rId: relAttributes["Id"]
|
|
29562
|
-
}
|
|
29563
|
-
};
|
|
29564
|
-
}
|
|
29565
|
-
const handleShapeDrawing = (params, node, graphicData) => {
|
|
29566
|
-
const wsp = graphicData.elements.find((el) => el.name === "wps:wsp");
|
|
29567
|
-
const textBox = wsp.elements.find((el) => el.name === "wps:txbx");
|
|
29568
|
-
const textBoxContent = textBox?.elements?.find((el) => el.name === "w:txbxContent");
|
|
29569
|
-
node.elements.find((el) => el.name === "wp:docPr");
|
|
29570
|
-
const spPr = wsp.elements.find((el) => el.name === "wps:spPr");
|
|
29571
|
-
const prstGeom = spPr?.elements.find((el) => el.name === "a:prstGeom");
|
|
29572
|
-
if (!!prstGeom && prstGeom.attributes["prst"] === "rect" && !textBoxContent) {
|
|
29573
|
-
return getRectangleShape(params, spPr);
|
|
29574
|
-
}
|
|
29575
|
-
if (!textBoxContent) {
|
|
29576
|
-
return null;
|
|
29577
|
-
}
|
|
29578
|
-
const { nodeListHandler } = params;
|
|
29579
|
-
const translatedElement = nodeListHandler.handler({
|
|
29580
|
-
...params,
|
|
29581
|
-
node: textBoxContent.elements[0],
|
|
29582
|
-
nodes: textBoxContent.elements,
|
|
29583
|
-
path: [...params.path || [], textBoxContent]
|
|
29584
|
-
});
|
|
29585
|
-
return translatedElement[0];
|
|
29586
|
-
};
|
|
29587
|
-
const getRectangleShape = (params, node) => {
|
|
29588
|
-
const schemaAttrs = {};
|
|
29589
|
-
const [drawingNode] = params.nodes;
|
|
29590
|
-
if (drawingNode?.name === "w:drawing") {
|
|
29591
|
-
schemaAttrs.drawingContent = drawingNode;
|
|
29592
|
-
}
|
|
29593
|
-
const xfrm = node.elements.find((el) => el.name === "a:xfrm");
|
|
29594
|
-
const start = xfrm.elements.find((el) => el.name === "a:off");
|
|
29595
|
-
const size = xfrm.elements.find((el) => el.name === "a:ext");
|
|
29596
|
-
const solidFill = node.elements.find((el) => el.name === "a:solidFill");
|
|
29597
|
-
node.elements.find((el) => el.name === "a:ln");
|
|
29598
|
-
const rectangleSize = {
|
|
29599
|
-
top: emuToPixels(start.attributes["y"]),
|
|
29600
|
-
left: emuToPixels(start.attributes["x"]),
|
|
29601
|
-
width: emuToPixels(size.attributes["cx"]),
|
|
29602
|
-
height: emuToPixels(size.attributes["cy"])
|
|
29603
|
-
};
|
|
29604
|
-
schemaAttrs.size = rectangleSize;
|
|
29605
|
-
const background = solidFill?.elements[0]?.attributes["val"];
|
|
29606
|
-
if (background) {
|
|
29607
|
-
schemaAttrs.background = "#" + background;
|
|
29608
|
-
}
|
|
29609
|
-
return {
|
|
29610
|
-
type: "contentBlock",
|
|
29611
|
-
attrs: schemaAttrs
|
|
29612
|
-
};
|
|
29717
|
+
const schemaNode = translator$1.encode(params);
|
|
29718
|
+
const newNodes = schemaNode ? [schemaNode] : [];
|
|
29719
|
+
return { nodes: newNodes, consumed: 1 };
|
|
29613
29720
|
};
|
|
29614
29721
|
const drawingNodeHandlerEntity = {
|
|
29615
29722
|
handlerName: "drawingNodeHandler",
|
|
@@ -29709,7 +29816,7 @@ const trackChangeNodeHandlerEntity = {
|
|
|
29709
29816
|
handlerName: "trackChangeNodeHandler",
|
|
29710
29817
|
handler: handleTrackChangeNode
|
|
29711
29818
|
};
|
|
29712
|
-
const hyperlinkNodeHandlerEntity = generateV2HandlerEntity("hyperlinkNodeHandler", translator$
|
|
29819
|
+
const hyperlinkNodeHandlerEntity = generateV2HandlerEntity("hyperlinkNodeHandler", translator$4);
|
|
29713
29820
|
const handleRunNode = (params) => {
|
|
29714
29821
|
const { nodes, nodeListHandler, parentStyleId, docx } = params;
|
|
29715
29822
|
if (nodes.length === 0 || nodes[0].name !== "w:r") {
|
|
@@ -29821,7 +29928,7 @@ const handleParagraphNode = (params) => {
|
|
|
29821
29928
|
if (nodes.length === 0 || nodes[0].name !== "w:p") {
|
|
29822
29929
|
return { nodes: [], consumed: 0 };
|
|
29823
29930
|
}
|
|
29824
|
-
const schemaNode = translator$
|
|
29931
|
+
const schemaNode = translator$k.encode(params);
|
|
29825
29932
|
const newNodes = schemaNode ? [schemaNode] : [];
|
|
29826
29933
|
return { nodes: newNodes, consumed: 1 };
|
|
29827
29934
|
};
|
|
@@ -29924,7 +30031,7 @@ const handler = (params) => {
|
|
|
29924
30031
|
if (nodes.length === 0 || nodes[0].name !== "w:br") {
|
|
29925
30032
|
return { nodes: [], consumed: 0 };
|
|
29926
30033
|
}
|
|
29927
|
-
const result = translator$
|
|
30034
|
+
const result = translator$m.encode(params);
|
|
29928
30035
|
if (!result) return { nodes: [], consumed: 0 };
|
|
29929
30036
|
return {
|
|
29930
30037
|
nodes: [result],
|
|
@@ -30620,7 +30727,7 @@ const handleTabNode = (params) => {
|
|
|
30620
30727
|
if (!nodes.length || nodes[0].name !== "w:tab") {
|
|
30621
30728
|
return { nodes: [], consumed: 0 };
|
|
30622
30729
|
}
|
|
30623
|
-
const node = translator$
|
|
30730
|
+
const node = translator$l.encode(params);
|
|
30624
30731
|
return { nodes: [node], consumed: 1 };
|
|
30625
30732
|
};
|
|
30626
30733
|
const tabNodeEntityHandler = {
|
|
@@ -31700,15 +31807,14 @@ export {
|
|
|
31700
31807
|
createDocFromMarkdown as a7,
|
|
31701
31808
|
createDocFromHTML as a8,
|
|
31702
31809
|
EditorState as a9,
|
|
31703
|
-
|
|
31704
|
-
|
|
31705
|
-
|
|
31706
|
-
|
|
31707
|
-
|
|
31708
|
-
|
|
31709
|
-
|
|
31710
|
-
|
|
31711
|
-
_sfc_main as aI,
|
|
31810
|
+
xmljs as aA,
|
|
31811
|
+
vClickOutside as aB,
|
|
31812
|
+
getActiveFormatting as aC,
|
|
31813
|
+
readFromClipboard as aD,
|
|
31814
|
+
handleClipboardPaste as aE,
|
|
31815
|
+
getFileObject as aF,
|
|
31816
|
+
_sfc_main as aG,
|
|
31817
|
+
registeredHandlers as aH,
|
|
31712
31818
|
hasSomeParentWithClass as aa,
|
|
31713
31819
|
isActive as ab,
|
|
31714
31820
|
unflattenListsInHtml as ac,
|
|
@@ -31730,11 +31836,11 @@ export {
|
|
|
31730
31836
|
createColGroup as as,
|
|
31731
31837
|
generateDocxRandomId as at,
|
|
31732
31838
|
insertNewRelationship as au,
|
|
31733
|
-
|
|
31734
|
-
|
|
31735
|
-
|
|
31736
|
-
|
|
31737
|
-
|
|
31839
|
+
updateDOMAttributes as av,
|
|
31840
|
+
htmlHandler as aw,
|
|
31841
|
+
commonjsGlobal as ax,
|
|
31842
|
+
getDefaultExportFromCjs$1 as ay,
|
|
31843
|
+
getContentTypesFromXml as az,
|
|
31738
31844
|
Slice as b,
|
|
31739
31845
|
DOMParser$1 as c,
|
|
31740
31846
|
Mark as d,
|