@harbour-enterprises/superdoc 0.20.0-next.3 → 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-DbuZR81Q.es.js → PdfViewer-BjZBgs8x.es.js} +1 -1
- package/dist/chunks/{PdfViewer-B9b7_8E2.cjs → PdfViewer-Ne_-LxpG.cjs} +1 -1
- package/dist/chunks/{index-CEAEymUl.es.js → index-BVjAJUtV.es.js} +2 -2
- package/dist/chunks/{index-CLepjsej.cjs → index-OFvCtpf7.cjs} +2 -2
- package/dist/chunks/{super-editor.es-TdXXCNpJ.cjs → super-editor.es-CCU9etUT.cjs} +1099 -713
- package/dist/chunks/{super-editor.es-C7rC3O3K.es.js → super-editor.es-DgTNVbvS.es.js} +1099 -713
- 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-BZ638uQi.js → converter-BPTfSIJf.js} +919 -813
- package/dist/super-editor/chunks/{docx-zipper-B-DSvrA8.js → docx-zipper-ikgI-2vM.js} +1 -1
- package/dist/super-editor/chunks/{editor-JXnNPHDg.js → editor-C1C_smD4.js} +294 -10
- package/dist/super-editor/chunks/{toolbar-CGu2Zc7R.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 +1099 -713
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/superdoc.umd.js
CHANGED
|
@@ -30277,6 +30277,23 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
30277
30277
|
}
|
|
30278
30278
|
return doc2;
|
|
30279
30279
|
}
|
|
30280
|
+
const defaultBooleans = ["required", "readonly", "disabled", "checked", "multiple", "autofocus"];
|
|
30281
|
+
function updateDOMAttributes(dom, attrs = {}, options = {}) {
|
|
30282
|
+
const customBooleans = options.customBooleans || [];
|
|
30283
|
+
const booleans = [...defaultBooleans, ...customBooleans];
|
|
30284
|
+
Object.entries(attrs).forEach(([key, value]) => {
|
|
30285
|
+
if (booleans.includes(key)) {
|
|
30286
|
+
if (!value) dom.removeAttribute(key);
|
|
30287
|
+
else dom.setAttribute(key, "");
|
|
30288
|
+
return;
|
|
30289
|
+
}
|
|
30290
|
+
if (value != null) {
|
|
30291
|
+
dom.setAttribute(key, value);
|
|
30292
|
+
} else {
|
|
30293
|
+
dom.removeAttribute(key);
|
|
30294
|
+
}
|
|
30295
|
+
});
|
|
30296
|
+
}
|
|
30280
30297
|
const helpers = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
30281
30298
|
__proto__: null,
|
|
30282
30299
|
chainableEditorState,
|
|
@@ -30309,7 +30326,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
30309
30326
|
isNodeActive,
|
|
30310
30327
|
isTextSelection,
|
|
30311
30328
|
posToDOMRect,
|
|
30312
|
-
processContent
|
|
30329
|
+
processContent,
|
|
30330
|
+
updateDOMAttributes
|
|
30313
30331
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
30314
30332
|
const generateNewListDefinition = ({ numId, listType, level, start: start2, text, fmt, editor }) => {
|
|
30315
30333
|
if (typeof listType === "string") listType = editor.schema.nodes[listType];
|
|
@@ -31922,18 +31940,6 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
31922
31940
|
}
|
|
31923
31941
|
]
|
|
31924
31942
|
};
|
|
31925
|
-
const sanitizeDocxMediaName = (value, fallback = "image") => {
|
|
31926
|
-
if (!value) return fallback;
|
|
31927
|
-
const sanitized = value.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
31928
|
-
return sanitized || fallback;
|
|
31929
|
-
};
|
|
31930
|
-
const getFallbackImageNameFromDataUri = (src = "", fallback = "image") => {
|
|
31931
|
-
if (!src || typeof src !== "string") return fallback;
|
|
31932
|
-
const [prefix2] = src.split(";");
|
|
31933
|
-
const [, maybeType] = prefix2.split("/");
|
|
31934
|
-
const extension = maybeType?.toLowerCase();
|
|
31935
|
-
return extension ? `${fallback}.${extension}` : fallback;
|
|
31936
|
-
};
|
|
31937
31943
|
function preProcessVerticalMergeCells(table, { editorSchema }) {
|
|
31938
31944
|
if (!table || !Array.isArray(table.content)) {
|
|
31939
31945
|
return table;
|
|
@@ -32094,37 +32100,37 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
32094
32100
|
};
|
|
32095
32101
|
__publicField$2(_NodeTranslator, "translatorTypes", TranslatorTypes);
|
|
32096
32102
|
let NodeTranslator = _NodeTranslator;
|
|
32097
|
-
const encode$
|
|
32103
|
+
const encode$m = (attributes) => {
|
|
32098
32104
|
return attributes["w:type"];
|
|
32099
32105
|
};
|
|
32100
|
-
const decode$
|
|
32106
|
+
const decode$m = (attrs) => {
|
|
32101
32107
|
const { lineBreakType } = attrs;
|
|
32102
32108
|
return lineBreakType;
|
|
32103
32109
|
};
|
|
32104
32110
|
const attrConfig$b = Object.freeze({
|
|
32105
32111
|
xmlName: "w:type",
|
|
32106
32112
|
sdName: "lineBreakType",
|
|
32107
|
-
encode: encode$
|
|
32108
|
-
decode: decode$
|
|
32113
|
+
encode: encode$m,
|
|
32114
|
+
decode: decode$m
|
|
32109
32115
|
});
|
|
32110
|
-
const encode$
|
|
32116
|
+
const encode$l = (attributes) => {
|
|
32111
32117
|
const xmlAttrValue = attributes["w:clear"];
|
|
32112
32118
|
return xmlAttrValue;
|
|
32113
32119
|
};
|
|
32114
|
-
const decode$
|
|
32120
|
+
const decode$l = (attrs) => {
|
|
32115
32121
|
const { clear } = attrs;
|
|
32116
32122
|
return clear;
|
|
32117
32123
|
};
|
|
32118
32124
|
const attrConfig$a = Object.freeze({
|
|
32119
32125
|
xmlName: "w:clear",
|
|
32120
32126
|
sdName: "clear",
|
|
32121
|
-
encode: encode$
|
|
32122
|
-
decode: decode$
|
|
32127
|
+
encode: encode$l,
|
|
32128
|
+
decode: decode$l
|
|
32123
32129
|
});
|
|
32124
|
-
const validXmlAttributes$
|
|
32125
|
-
const XML_NODE_NAME$
|
|
32126
|
-
const SD_NODE_NAME$
|
|
32127
|
-
const encode$
|
|
32130
|
+
const validXmlAttributes$9 = [attrConfig$b, attrConfig$a];
|
|
32131
|
+
const XML_NODE_NAME$a = "w:br";
|
|
32132
|
+
const SD_NODE_NAME$9 = "lineBreak";
|
|
32133
|
+
const encode$k = (_2, encodedAttrs) => {
|
|
32128
32134
|
const isPageBreak = encodedAttrs?.lineBreakType === "page";
|
|
32129
32135
|
const translated = {
|
|
32130
32136
|
type: isPageBreak ? "hardBreak" : "lineBreak"
|
|
@@ -32134,7 +32140,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
32134
32140
|
}
|
|
32135
32141
|
return translated;
|
|
32136
32142
|
};
|
|
32137
|
-
const decode$
|
|
32143
|
+
const decode$k = (params2, decodedAttrs) => {
|
|
32138
32144
|
const { node } = params2;
|
|
32139
32145
|
if (!node) return;
|
|
32140
32146
|
const wBreak = { name: "w:br" };
|
|
@@ -32151,63 +32157,63 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
32151
32157
|
};
|
|
32152
32158
|
return translated;
|
|
32153
32159
|
};
|
|
32154
|
-
const config$
|
|
32155
|
-
xmlName: XML_NODE_NAME$
|
|
32156
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
32160
|
+
const config$a = {
|
|
32161
|
+
xmlName: XML_NODE_NAME$a,
|
|
32162
|
+
sdNodeOrKeyName: SD_NODE_NAME$9,
|
|
32157
32163
|
type: NodeTranslator.translatorTypes.NODE,
|
|
32158
|
-
encode: encode$
|
|
32159
|
-
decode: decode$
|
|
32160
|
-
attributes: validXmlAttributes$
|
|
32164
|
+
encode: encode$k,
|
|
32165
|
+
decode: decode$k,
|
|
32166
|
+
attributes: validXmlAttributes$9
|
|
32161
32167
|
};
|
|
32162
|
-
const translator$
|
|
32163
|
-
const encode$
|
|
32168
|
+
const translator$m = NodeTranslator.from(config$a);
|
|
32169
|
+
const encode$j = (attributes) => {
|
|
32164
32170
|
return attributes["w:val"];
|
|
32165
32171
|
};
|
|
32166
|
-
const decode$
|
|
32172
|
+
const decode$j = (attrs) => {
|
|
32167
32173
|
const { tabSize } = attrs || {};
|
|
32168
32174
|
return tabSize;
|
|
32169
32175
|
};
|
|
32170
32176
|
const attrConfig$9 = Object.freeze({
|
|
32171
32177
|
xmlName: "w:val",
|
|
32172
32178
|
sdName: "tabSize",
|
|
32173
|
-
encode: encode$
|
|
32174
|
-
decode: decode$
|
|
32179
|
+
encode: encode$j,
|
|
32180
|
+
decode: decode$j
|
|
32175
32181
|
});
|
|
32176
|
-
const encode$
|
|
32182
|
+
const encode$i = (attributes) => {
|
|
32177
32183
|
return attributes["w:leader"];
|
|
32178
32184
|
};
|
|
32179
|
-
const decode$
|
|
32185
|
+
const decode$i = (attrs) => {
|
|
32180
32186
|
const { leader } = attrs || {};
|
|
32181
32187
|
return leader;
|
|
32182
32188
|
};
|
|
32183
32189
|
const attrConfig$8 = Object.freeze({
|
|
32184
32190
|
xmlName: "w:leader",
|
|
32185
32191
|
sdName: "leader",
|
|
32186
|
-
encode: encode$
|
|
32187
|
-
decode: decode$
|
|
32192
|
+
encode: encode$i,
|
|
32193
|
+
decode: decode$i
|
|
32188
32194
|
});
|
|
32189
|
-
const encode$
|
|
32195
|
+
const encode$h = (attributes) => {
|
|
32190
32196
|
return attributes["w:pos"];
|
|
32191
32197
|
};
|
|
32192
|
-
const decode$
|
|
32198
|
+
const decode$h = (attrs) => {
|
|
32193
32199
|
const { pos } = attrs || {};
|
|
32194
32200
|
return pos;
|
|
32195
32201
|
};
|
|
32196
32202
|
const attrConfig$7 = Object.freeze({
|
|
32197
32203
|
xmlName: "w:pos",
|
|
32198
32204
|
sdName: "pos",
|
|
32199
|
-
encode: encode$
|
|
32200
|
-
decode: decode$
|
|
32205
|
+
encode: encode$h,
|
|
32206
|
+
decode: decode$h
|
|
32201
32207
|
});
|
|
32202
|
-
const validXmlAttributes$
|
|
32203
|
-
const XML_NODE_NAME$
|
|
32204
|
-
const SD_NODE_NAME$
|
|
32205
|
-
const encode$
|
|
32208
|
+
const validXmlAttributes$8 = [attrConfig$9, attrConfig$7, attrConfig$8];
|
|
32209
|
+
const XML_NODE_NAME$9 = "w:tab";
|
|
32210
|
+
const SD_NODE_NAME$8 = "tab";
|
|
32211
|
+
const encode$g = (_2, encodedAttrs = {}) => {
|
|
32206
32212
|
const translated = { type: "tab" };
|
|
32207
32213
|
if (encodedAttrs) translated.attrs = { ...encodedAttrs };
|
|
32208
32214
|
return translated;
|
|
32209
32215
|
};
|
|
32210
|
-
const decode$
|
|
32216
|
+
const decode$g = (params2, decodedAttrs = {}) => {
|
|
32211
32217
|
const { node } = params2 || {};
|
|
32212
32218
|
if (!node) return;
|
|
32213
32219
|
const wTab = { name: "w:tab" };
|
|
@@ -32223,15 +32229,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
32223
32229
|
}
|
|
32224
32230
|
return translated;
|
|
32225
32231
|
};
|
|
32226
|
-
const config$
|
|
32227
|
-
xmlName: XML_NODE_NAME$
|
|
32228
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
32232
|
+
const config$9 = {
|
|
32233
|
+
xmlName: XML_NODE_NAME$9,
|
|
32234
|
+
sdNodeOrKeyName: SD_NODE_NAME$8,
|
|
32229
32235
|
type: NodeTranslator.translatorTypes.NODE,
|
|
32230
|
-
encode: encode$
|
|
32231
|
-
decode: decode$
|
|
32232
|
-
attributes: validXmlAttributes$
|
|
32236
|
+
encode: encode$g,
|
|
32237
|
+
decode: decode$g,
|
|
32238
|
+
attributes: validXmlAttributes$8
|
|
32233
32239
|
};
|
|
32234
|
-
const translator$
|
|
32240
|
+
const translator$l = NodeTranslator.from(config$9);
|
|
32235
32241
|
const mergeTextNodes = (nodes) => {
|
|
32236
32242
|
if (!nodes || !Array.isArray(nodes)) {
|
|
32237
32243
|
return nodes;
|
|
@@ -32801,91 +32807,91 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
32801
32807
|
}
|
|
32802
32808
|
return schemaNode;
|
|
32803
32809
|
};
|
|
32804
|
-
const encode$
|
|
32810
|
+
const encode$f = (attributes) => {
|
|
32805
32811
|
return attributes["w:rsidDel"];
|
|
32806
32812
|
};
|
|
32807
|
-
const decode$
|
|
32813
|
+
const decode$f = (attrs) => {
|
|
32808
32814
|
return attrs.rsidDel;
|
|
32809
32815
|
};
|
|
32810
32816
|
const attrConfig$6 = Object.freeze({
|
|
32811
32817
|
xmlName: "w:rsidDel",
|
|
32812
32818
|
sdName: "rsidDel",
|
|
32813
|
-
encode: encode$
|
|
32814
|
-
decode: decode$
|
|
32819
|
+
encode: encode$f,
|
|
32820
|
+
decode: decode$f
|
|
32815
32821
|
});
|
|
32816
|
-
const encode$
|
|
32822
|
+
const encode$e = (attributes) => {
|
|
32817
32823
|
return attributes["w:rsidP"];
|
|
32818
32824
|
};
|
|
32819
|
-
const decode$
|
|
32825
|
+
const decode$e = (attrs) => {
|
|
32820
32826
|
return attrs.rsidP;
|
|
32821
32827
|
};
|
|
32822
32828
|
const attrConfig$5 = Object.freeze({
|
|
32823
32829
|
xmlName: "w:rsidP",
|
|
32824
32830
|
sdName: "rsidP",
|
|
32825
|
-
encode: encode$
|
|
32826
|
-
decode: decode$
|
|
32831
|
+
encode: encode$e,
|
|
32832
|
+
decode: decode$e
|
|
32827
32833
|
});
|
|
32828
|
-
const encode$
|
|
32834
|
+
const encode$d = (attributes) => {
|
|
32829
32835
|
return attributes["w:rsidR"];
|
|
32830
32836
|
};
|
|
32831
|
-
const decode$
|
|
32837
|
+
const decode$d = (attrs) => {
|
|
32832
32838
|
return attrs.rsidR;
|
|
32833
32839
|
};
|
|
32834
32840
|
const attrConfig$4 = Object.freeze({
|
|
32835
32841
|
xmlName: "w:rsidR",
|
|
32836
32842
|
sdName: "rsidR",
|
|
32837
|
-
encode: encode$
|
|
32838
|
-
decode: decode$
|
|
32843
|
+
encode: encode$d,
|
|
32844
|
+
decode: decode$d
|
|
32839
32845
|
});
|
|
32840
|
-
const encode$
|
|
32846
|
+
const encode$c = (attributes) => {
|
|
32841
32847
|
return attributes["w:rsidRPr"];
|
|
32842
32848
|
};
|
|
32843
|
-
const decode$
|
|
32849
|
+
const decode$c = (attrs) => {
|
|
32844
32850
|
return attrs.rsidRPr;
|
|
32845
32851
|
};
|
|
32846
32852
|
const attrConfig$3 = Object.freeze({
|
|
32847
32853
|
xmlName: "w:rsidRPr",
|
|
32848
32854
|
sdName: "rsidRPr",
|
|
32849
|
-
encode: encode$
|
|
32850
|
-
decode: decode$
|
|
32855
|
+
encode: encode$c,
|
|
32856
|
+
decode: decode$c
|
|
32851
32857
|
});
|
|
32852
|
-
const encode$
|
|
32858
|
+
const encode$b = (attributes) => {
|
|
32853
32859
|
return attributes["w:rsidRDefault"];
|
|
32854
32860
|
};
|
|
32855
|
-
const decode$
|
|
32861
|
+
const decode$b = (attrs) => {
|
|
32856
32862
|
return attrs.rsidRDefault;
|
|
32857
32863
|
};
|
|
32858
32864
|
const attrConfig$2 = Object.freeze({
|
|
32859
32865
|
xmlName: "w:rsidRDefault",
|
|
32860
32866
|
sdName: "rsidRDefault",
|
|
32861
|
-
encode: encode$
|
|
32862
|
-
decode: decode$
|
|
32867
|
+
encode: encode$b,
|
|
32868
|
+
decode: decode$b
|
|
32863
32869
|
});
|
|
32864
|
-
const encode$
|
|
32870
|
+
const encode$a = (attributes) => {
|
|
32865
32871
|
return attributes["w14:paraId"];
|
|
32866
32872
|
};
|
|
32867
|
-
const decode$
|
|
32873
|
+
const decode$a = (attrs) => {
|
|
32868
32874
|
return attrs.paraId;
|
|
32869
32875
|
};
|
|
32870
32876
|
const attrConfig$1 = Object.freeze({
|
|
32871
32877
|
xmlName: "w14:paraId",
|
|
32872
32878
|
sdName: "paraId",
|
|
32873
|
-
encode: encode$
|
|
32874
|
-
decode: decode$
|
|
32879
|
+
encode: encode$a,
|
|
32880
|
+
decode: decode$a
|
|
32875
32881
|
});
|
|
32876
|
-
const encode$
|
|
32882
|
+
const encode$9 = (attributes) => {
|
|
32877
32883
|
return attributes["w14:textId"];
|
|
32878
32884
|
};
|
|
32879
|
-
const decode$
|
|
32885
|
+
const decode$9 = (attrs) => {
|
|
32880
32886
|
return attrs.textId;
|
|
32881
32887
|
};
|
|
32882
32888
|
const attrConfig = Object.freeze({
|
|
32883
32889
|
xmlName: "w14:textId",
|
|
32884
32890
|
sdName: "textId",
|
|
32885
|
-
encode: encode$
|
|
32886
|
-
decode: decode$
|
|
32891
|
+
encode: encode$9,
|
|
32892
|
+
decode: decode$9
|
|
32887
32893
|
});
|
|
32888
|
-
const validXmlAttributes$
|
|
32894
|
+
const validXmlAttributes$7 = [
|
|
32889
32895
|
attrConfig$1,
|
|
32890
32896
|
attrConfig,
|
|
32891
32897
|
attrConfig$4,
|
|
@@ -32894,9 +32900,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
32894
32900
|
attrConfig$3,
|
|
32895
32901
|
attrConfig$6
|
|
32896
32902
|
];
|
|
32897
|
-
const XML_NODE_NAME$
|
|
32898
|
-
const SD_NODE_NAME$
|
|
32899
|
-
const encode$
|
|
32903
|
+
const XML_NODE_NAME$8 = "w:p";
|
|
32904
|
+
const SD_NODE_NAME$7 = "paragraph";
|
|
32905
|
+
const encode$8 = (params2, encodedAttrs = {}) => {
|
|
32900
32906
|
const node = handleParagraphNode$1(params2);
|
|
32901
32907
|
if (!node) return void 0;
|
|
32902
32908
|
if (encodedAttrs && Object.keys(encodedAttrs).length) {
|
|
@@ -32904,7 +32910,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
32904
32910
|
}
|
|
32905
32911
|
return node;
|
|
32906
32912
|
};
|
|
32907
|
-
const decode$
|
|
32913
|
+
const decode$8 = (params2, decodedAttrs = {}) => {
|
|
32908
32914
|
const translated = translateParagraphNode(params2);
|
|
32909
32915
|
if (!translated) return void 0;
|
|
32910
32916
|
if (decodedAttrs && Object.keys(decodedAttrs).length) {
|
|
@@ -32912,15 +32918,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
32912
32918
|
}
|
|
32913
32919
|
return translated;
|
|
32914
32920
|
};
|
|
32915
|
-
const config$
|
|
32916
|
-
xmlName: XML_NODE_NAME$
|
|
32917
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
32921
|
+
const config$8 = {
|
|
32922
|
+
xmlName: XML_NODE_NAME$8,
|
|
32923
|
+
sdNodeOrKeyName: SD_NODE_NAME$7,
|
|
32918
32924
|
type: NodeTranslator.translatorTypes.NODE,
|
|
32919
|
-
encode: encode$
|
|
32920
|
-
decode: decode$
|
|
32921
|
-
attributes: validXmlAttributes$
|
|
32925
|
+
encode: encode$8,
|
|
32926
|
+
decode: decode$8,
|
|
32927
|
+
attributes: validXmlAttributes$7
|
|
32922
32928
|
};
|
|
32923
|
-
const translator$
|
|
32929
|
+
const translator$k = NodeTranslator.from(config$8);
|
|
32924
32930
|
const generateV2HandlerEntity = (handlerName, translator2) => ({
|
|
32925
32931
|
handlerName,
|
|
32926
32932
|
handler: (params2) => {
|
|
@@ -33027,13 +33033,13 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
33027
33033
|
const intValue = parseInteger(value);
|
|
33028
33034
|
return intValue != void 0 ? String(intValue) : void 0;
|
|
33029
33035
|
};
|
|
33030
|
-
const translator$
|
|
33036
|
+
const translator$j = NodeTranslator.from({
|
|
33031
33037
|
xmlName: "w:cantSplit",
|
|
33032
33038
|
sdNodeOrKeyName: "cantSplit",
|
|
33033
33039
|
encode: ({ nodes }) => ["1", "true"].includes(nodes[0].attributes?.["w:val"] ?? "1"),
|
|
33034
33040
|
decode: ({ node }) => node.attrs?.cantSplit ? {} : void 0
|
|
33035
33041
|
});
|
|
33036
|
-
const translator$
|
|
33042
|
+
const translator$i = NodeTranslator.from({
|
|
33037
33043
|
xmlName: "w:cnfStyle",
|
|
33038
33044
|
sdNodeOrKeyName: "cnfStyle",
|
|
33039
33045
|
attributes: [
|
|
@@ -33066,8 +33072,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
33066
33072
|
return Object.keys(cnfStyleAttrs).length > 0 ? cnfStyleAttrs : void 0;
|
|
33067
33073
|
}
|
|
33068
33074
|
});
|
|
33069
|
-
const translator$
|
|
33070
|
-
const translator$
|
|
33075
|
+
const translator$h = NodeTranslator.from(createSingleAttrPropertyHandler("w:divId"));
|
|
33076
|
+
const translator$g = NodeTranslator.from(
|
|
33071
33077
|
createSingleAttrPropertyHandler(
|
|
33072
33078
|
"w:gridAfter",
|
|
33073
33079
|
null,
|
|
@@ -33076,7 +33082,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
33076
33082
|
(v2) => integerToString(v2)
|
|
33077
33083
|
)
|
|
33078
33084
|
);
|
|
33079
|
-
const translator$
|
|
33085
|
+
const translator$f = NodeTranslator.from(
|
|
33080
33086
|
createSingleAttrPropertyHandler(
|
|
33081
33087
|
"w:gridBefore",
|
|
33082
33088
|
null,
|
|
@@ -33085,21 +33091,21 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
33085
33091
|
(v2) => integerToString(v2)
|
|
33086
33092
|
)
|
|
33087
33093
|
);
|
|
33088
|
-
const translator$
|
|
33094
|
+
const translator$e = NodeTranslator.from({
|
|
33089
33095
|
xmlName: "w:hidden",
|
|
33090
33096
|
sdNodeOrKeyName: "hidden",
|
|
33091
33097
|
encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
|
|
33092
33098
|
decode: ({ node }) => node.attrs.hidden ? {} : void 0
|
|
33093
33099
|
});
|
|
33094
|
-
const translator$
|
|
33095
|
-
const translator$
|
|
33096
|
-
const translator$
|
|
33100
|
+
const translator$d = NodeTranslator.from(createSingleAttrPropertyHandler("w:jc"));
|
|
33101
|
+
const translator$c = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "cellSpacing"));
|
|
33102
|
+
const translator$b = NodeTranslator.from({
|
|
33097
33103
|
xmlName: "w:tblHeader",
|
|
33098
33104
|
sdNodeOrKeyName: "repeatHeader",
|
|
33099
33105
|
encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
|
|
33100
33106
|
decode: ({ node }) => node.attrs.repeatHeader ? {} : void 0
|
|
33101
33107
|
});
|
|
33102
|
-
const translator$
|
|
33108
|
+
const translator$a = NodeTranslator.from({
|
|
33103
33109
|
xmlName: "w:trHeight",
|
|
33104
33110
|
sdNodeOrKeyName: "rowHeight",
|
|
33105
33111
|
encode: ({ nodes }) => {
|
|
@@ -33126,11 +33132,11 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
33126
33132
|
return Object.keys(heightAttrs).length > 0 ? heightAttrs : void 0;
|
|
33127
33133
|
}
|
|
33128
33134
|
});
|
|
33129
|
-
const translator$
|
|
33130
|
-
const translator$
|
|
33131
|
-
const XML_NODE_NAME$
|
|
33135
|
+
const translator$9 = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
|
|
33136
|
+
const translator$8 = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
|
|
33137
|
+
const XML_NODE_NAME$7 = "w:trPr";
|
|
33132
33138
|
const SD_ATTR_KEY = "tableRowProperties";
|
|
33133
|
-
const encode$
|
|
33139
|
+
const encode$7 = (params2) => {
|
|
33134
33140
|
const { nodes } = params2;
|
|
33135
33141
|
const node = nodes[0];
|
|
33136
33142
|
let attributes = {
|
|
@@ -33144,12 +33150,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
33144
33150
|
};
|
|
33145
33151
|
return {
|
|
33146
33152
|
type: NodeTranslator.translatorTypes.ATTRIBUTE,
|
|
33147
|
-
xmlName: XML_NODE_NAME$
|
|
33153
|
+
xmlName: XML_NODE_NAME$7,
|
|
33148
33154
|
sdNodeOrKeyName: SD_ATTR_KEY,
|
|
33149
33155
|
attributes
|
|
33150
33156
|
};
|
|
33151
33157
|
};
|
|
33152
|
-
const decode$
|
|
33158
|
+
const decode$7 = (params2) => {
|
|
33153
33159
|
const { tableRowProperties = {} } = params2.node.attrs || {};
|
|
33154
33160
|
const elements = decodeProperties(propertyTranslatorsBySdName, tableRowProperties);
|
|
33155
33161
|
const newNode = {
|
|
@@ -33161,6 +33167,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
33161
33167
|
return newNode;
|
|
33162
33168
|
};
|
|
33163
33169
|
const propertyTranslators = [
|
|
33170
|
+
translator$j,
|
|
33171
|
+
translator$i,
|
|
33172
|
+
translator$h,
|
|
33164
33173
|
translator$g,
|
|
33165
33174
|
translator$f,
|
|
33166
33175
|
translator$e,
|
|
@@ -33169,10 +33178,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
33169
33178
|
translator$b,
|
|
33170
33179
|
translator$a,
|
|
33171
33180
|
translator$9,
|
|
33172
|
-
translator$8
|
|
33173
|
-
translator$7,
|
|
33174
|
-
translator$6,
|
|
33175
|
-
translator$5
|
|
33181
|
+
translator$8
|
|
33176
33182
|
];
|
|
33177
33183
|
const propertyTranslatorsByXmlName = {};
|
|
33178
33184
|
propertyTranslators.forEach((translator2) => {
|
|
@@ -33182,25 +33188,25 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
33182
33188
|
propertyTranslators.forEach((translator2) => {
|
|
33183
33189
|
propertyTranslatorsBySdName[translator2.sdNodeOrKeyName] = translator2;
|
|
33184
33190
|
});
|
|
33185
|
-
const config$
|
|
33186
|
-
xmlName: XML_NODE_NAME$
|
|
33191
|
+
const config$7 = {
|
|
33192
|
+
xmlName: XML_NODE_NAME$7,
|
|
33187
33193
|
sdNodeOrKeyName: SD_ATTR_KEY,
|
|
33188
33194
|
type: NodeTranslator.translatorTypes.ATTRIBUTE,
|
|
33189
|
-
encode: encode$
|
|
33190
|
-
decode: decode$
|
|
33195
|
+
encode: encode$7,
|
|
33196
|
+
decode: decode$7
|
|
33191
33197
|
};
|
|
33192
|
-
const translator$
|
|
33193
|
-
const XML_NODE_NAME$
|
|
33194
|
-
const SD_NODE_NAME$
|
|
33195
|
-
const validXmlAttributes$
|
|
33198
|
+
const translator$7 = NodeTranslator.from(config$7);
|
|
33199
|
+
const XML_NODE_NAME$6 = "w:tr";
|
|
33200
|
+
const SD_NODE_NAME$6 = "tableRow";
|
|
33201
|
+
const validXmlAttributes$6 = ["w:rsidDel", "w:rsidR", "w:rsidRPr", "w:rsidTr", "w14:paraId", "w14:textId"].map(
|
|
33196
33202
|
(xmlName) => createAttributeHandler(xmlName)
|
|
33197
33203
|
);
|
|
33198
|
-
const encode$
|
|
33204
|
+
const encode$6 = (params2, encodedAttrs) => {
|
|
33199
33205
|
const { row, table } = params2.extraParams;
|
|
33200
33206
|
let tableRowProperties = {};
|
|
33201
33207
|
const tPr = row.elements.find((el) => el.name === "w:trPr");
|
|
33202
33208
|
if (tPr) {
|
|
33203
|
-
({ attributes: tableRowProperties } = translator$
|
|
33209
|
+
({ attributes: tableRowProperties } = translator$7.encode({
|
|
33204
33210
|
...params2,
|
|
33205
33211
|
nodes: [tPr]
|
|
33206
33212
|
}));
|
|
@@ -33213,7 +33219,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
33213
33219
|
let currentColumnIndex = 0;
|
|
33214
33220
|
const content = cellNodes?.map((n) => {
|
|
33215
33221
|
let columnWidth = gridColumnWidths?.[currentColumnIndex] || null;
|
|
33216
|
-
const result = translator$
|
|
33222
|
+
const result = translator$5.encode({
|
|
33217
33223
|
...params2,
|
|
33218
33224
|
extraParams: {
|
|
33219
33225
|
...params2.extraParams,
|
|
@@ -33244,7 +33250,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
33244
33250
|
}) || [];
|
|
33245
33251
|
return columnWidths;
|
|
33246
33252
|
};
|
|
33247
|
-
const decode$
|
|
33253
|
+
const decode$6 = (params2, decodedAttrs) => {
|
|
33248
33254
|
const { node } = params2;
|
|
33249
33255
|
const elements = translateChildNodes(params2);
|
|
33250
33256
|
if (node.attrs?.tableRowProperties) {
|
|
@@ -33256,7 +33262,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
33256
33262
|
}
|
|
33257
33263
|
}
|
|
33258
33264
|
tableRowProperties["cantSplit"] = node.attrs["cantSplit"];
|
|
33259
|
-
const trPr = translator$
|
|
33265
|
+
const trPr = translator$7.decode({
|
|
33260
33266
|
...params2,
|
|
33261
33267
|
node: { ...node, attrs: { ...node.attrs, tableRowProperties } }
|
|
33262
33268
|
});
|
|
@@ -33268,15 +33274,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
33268
33274
|
elements
|
|
33269
33275
|
};
|
|
33270
33276
|
};
|
|
33271
|
-
const config$
|
|
33272
|
-
xmlName: XML_NODE_NAME$
|
|
33273
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
33277
|
+
const config$6 = {
|
|
33278
|
+
xmlName: XML_NODE_NAME$6,
|
|
33279
|
+
sdNodeOrKeyName: SD_NODE_NAME$6,
|
|
33274
33280
|
type: NodeTranslator.translatorTypes.NODE,
|
|
33275
|
-
encode: encode$
|
|
33276
|
-
decode: decode$
|
|
33277
|
-
attributes: validXmlAttributes$
|
|
33281
|
+
encode: encode$6,
|
|
33282
|
+
decode: decode$6,
|
|
33283
|
+
attributes: validXmlAttributes$6
|
|
33278
33284
|
};
|
|
33279
|
-
const translator$
|
|
33285
|
+
const translator$6 = NodeTranslator.from(config$6);
|
|
33280
33286
|
const handleAllTableNodes = (params2) => {
|
|
33281
33287
|
const { nodes } = params2;
|
|
33282
33288
|
if (nodes.length === 0) {
|
|
@@ -33340,7 +33346,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
33340
33346
|
attrs["borders"] = borderData;
|
|
33341
33347
|
const content = [];
|
|
33342
33348
|
rows.forEach((row) => {
|
|
33343
|
-
const result = translator$
|
|
33349
|
+
const result = translator$6.encode({
|
|
33344
33350
|
...params2,
|
|
33345
33351
|
nodes: [row],
|
|
33346
33352
|
extraParams: {
|
|
@@ -33721,10 +33727,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
33721
33727
|
if (left2 != null) elements.push({ name: "w:left", attributes: { "w:w": pixelsToTwips(left2) } });
|
|
33722
33728
|
return elements;
|
|
33723
33729
|
}
|
|
33724
|
-
const XML_NODE_NAME$
|
|
33725
|
-
const SD_NODE_NAME$
|
|
33726
|
-
const validXmlAttributes$
|
|
33727
|
-
function encode$
|
|
33730
|
+
const XML_NODE_NAME$5 = "w:tc";
|
|
33731
|
+
const SD_NODE_NAME$5 = "tableCell";
|
|
33732
|
+
const validXmlAttributes$5 = [];
|
|
33733
|
+
function encode$5(params2, encodedAttrs) {
|
|
33728
33734
|
const { node, table, row, rowBorders, styleTag, columnIndex, columnWidth } = params2.extraParams;
|
|
33729
33735
|
const schemaNode = handleTableCellNode({
|
|
33730
33736
|
params: params2,
|
|
@@ -33741,31 +33747,31 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
33741
33747
|
}
|
|
33742
33748
|
return schemaNode;
|
|
33743
33749
|
}
|
|
33744
|
-
function decode$
|
|
33750
|
+
function decode$5(params2, decodedAttrs) {
|
|
33745
33751
|
const translated = translateTableCell(params2);
|
|
33746
33752
|
if (decodedAttrs && Object.keys(decodedAttrs).length) {
|
|
33747
33753
|
translated.attributes = { ...translated.attributes || {}, ...decodedAttrs };
|
|
33748
33754
|
}
|
|
33749
33755
|
return translated;
|
|
33750
33756
|
}
|
|
33751
|
-
const config$
|
|
33752
|
-
xmlName: XML_NODE_NAME$
|
|
33753
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
33757
|
+
const config$5 = {
|
|
33758
|
+
xmlName: XML_NODE_NAME$5,
|
|
33759
|
+
sdNodeOrKeyName: SD_NODE_NAME$5,
|
|
33754
33760
|
type: NodeTranslator.translatorTypes.NODE,
|
|
33755
|
-
encode: encode$
|
|
33756
|
-
decode: decode$
|
|
33757
|
-
attributes: validXmlAttributes$
|
|
33761
|
+
encode: encode$5,
|
|
33762
|
+
decode: decode$5,
|
|
33763
|
+
attributes: validXmlAttributes$5
|
|
33758
33764
|
};
|
|
33759
|
-
const translator$
|
|
33760
|
-
const XML_NODE_NAME$
|
|
33761
|
-
const SD_NODE_NAME$
|
|
33765
|
+
const translator$5 = NodeTranslator.from(config$5);
|
|
33766
|
+
const XML_NODE_NAME$4 = "w:hyperlink";
|
|
33767
|
+
const SD_NODE_NAME$4 = "link";
|
|
33762
33768
|
const _createAttributeHandler = (xmlName, sdName) => ({
|
|
33763
33769
|
xmlName,
|
|
33764
33770
|
sdName,
|
|
33765
33771
|
encode: (attributes) => attributes[xmlName],
|
|
33766
33772
|
decode: (attributes) => attributes[sdName]
|
|
33767
33773
|
});
|
|
33768
|
-
const validXmlAttributes$
|
|
33774
|
+
const validXmlAttributes$4 = [
|
|
33769
33775
|
_createAttributeHandler("w:anchor", "anchor"),
|
|
33770
33776
|
_createAttributeHandler("w:docLocation", "docLocation"),
|
|
33771
33777
|
{
|
|
@@ -33778,7 +33784,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
33778
33784
|
_createAttributeHandler("r:id", "rId"),
|
|
33779
33785
|
_createAttributeHandler("w:tgtFrame", "target")
|
|
33780
33786
|
];
|
|
33781
|
-
const encode$
|
|
33787
|
+
const encode$4 = (params2, encodedAttrs) => {
|
|
33782
33788
|
const { nodes, docx, nodeListHandler } = params2;
|
|
33783
33789
|
const node = nodes[0];
|
|
33784
33790
|
let href = _resolveHref(docx, encodedAttrs);
|
|
@@ -33809,7 +33815,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
33809
33815
|
}
|
|
33810
33816
|
return href;
|
|
33811
33817
|
};
|
|
33812
|
-
function decode$
|
|
33818
|
+
function decode$4(params2) {
|
|
33813
33819
|
const { node } = params2;
|
|
33814
33820
|
const linkMark = node.marks.find((m2) => m2.type === "link");
|
|
33815
33821
|
const linkAttrs = this.decodeAttributes({ ...params2, node: linkMark });
|
|
@@ -33853,15 +33859,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
33853
33859
|
});
|
|
33854
33860
|
return rId;
|
|
33855
33861
|
}
|
|
33856
|
-
const config$
|
|
33857
|
-
xmlName: XML_NODE_NAME$
|
|
33858
|
-
sdNodeOrKeyName: SD_NODE_NAME$
|
|
33862
|
+
const config$4 = {
|
|
33863
|
+
xmlName: XML_NODE_NAME$4,
|
|
33864
|
+
sdNodeOrKeyName: SD_NODE_NAME$4,
|
|
33859
33865
|
type: NodeTranslator.translatorTypes.NODE,
|
|
33860
|
-
encode: encode$
|
|
33861
|
-
decode: decode$
|
|
33862
|
-
attributes: validXmlAttributes$
|
|
33866
|
+
encode: encode$4,
|
|
33867
|
+
decode: decode$4,
|
|
33868
|
+
attributes: validXmlAttributes$4
|
|
33863
33869
|
};
|
|
33864
|
-
const translator$
|
|
33870
|
+
const translator$4 = NodeTranslator.from(config$4);
|
|
33865
33871
|
function parseTagValueJSON(json) {
|
|
33866
33872
|
if (typeof json !== "string") {
|
|
33867
33873
|
return {};
|
|
@@ -34103,6 +34109,623 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
34103
34109
|
}
|
|
34104
34110
|
return { type: "unknown", handler: null };
|
|
34105
34111
|
}
|
|
34112
|
+
function handleImageNode(node, params2, isAnchor) {
|
|
34113
|
+
const { docx, filename } = params2;
|
|
34114
|
+
const { attributes } = node;
|
|
34115
|
+
const padding = {
|
|
34116
|
+
top: emuToPixels(attributes["distT"]),
|
|
34117
|
+
bottom: emuToPixels(attributes["distB"]),
|
|
34118
|
+
left: emuToPixels(attributes["distL"]),
|
|
34119
|
+
right: emuToPixels(attributes["distR"])
|
|
34120
|
+
};
|
|
34121
|
+
const extent = node.elements.find((el) => el.name === "wp:extent");
|
|
34122
|
+
const size2 = {
|
|
34123
|
+
width: emuToPixels(extent.attributes?.cx),
|
|
34124
|
+
height: emuToPixels(extent.attributes?.cy)
|
|
34125
|
+
};
|
|
34126
|
+
const graphic = node.elements.find((el) => el.name === "a:graphic");
|
|
34127
|
+
const graphicData = graphic.elements.find((el) => el.name === "a:graphicData");
|
|
34128
|
+
const { uri: uri2 } = graphicData?.attributes || {};
|
|
34129
|
+
const shapeURI = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape";
|
|
34130
|
+
if (!!uri2 && uri2 === shapeURI) {
|
|
34131
|
+
return handleShapeDrawing(params2, node, graphicData);
|
|
34132
|
+
}
|
|
34133
|
+
const picture = graphicData.elements.find((el) => el.name === "pic:pic");
|
|
34134
|
+
if (!picture || !picture.elements) return null;
|
|
34135
|
+
const blipFill = picture.elements.find((el) => el.name === "pic:blipFill");
|
|
34136
|
+
const blip = blipFill.elements.find((el) => el.name === "a:blip");
|
|
34137
|
+
const positionHTag = node.elements.find((el) => el.name === "wp:positionH");
|
|
34138
|
+
const positionH = positionHTag?.elements.find((el) => el.name === "wp:posOffset");
|
|
34139
|
+
const positionHValue = emuToPixels(positionH?.elements[0]?.text);
|
|
34140
|
+
const hRelativeFrom = positionHTag?.attributes.relativeFrom;
|
|
34141
|
+
const alignH = positionHTag?.elements.find((el) => el.name === "wp:align")?.elements[0]?.text;
|
|
34142
|
+
const positionVTag = node.elements.find((el) => el.name === "wp:positionV");
|
|
34143
|
+
const positionV = positionVTag?.elements?.find((el) => el.name === "wp:posOffset");
|
|
34144
|
+
const positionVValue = emuToPixels(positionV?.elements[0]?.text);
|
|
34145
|
+
const vRelativeFrom = positionVTag?.attributes.relativeFrom;
|
|
34146
|
+
const alignV = positionVTag?.elements?.find((el) => el.name === "wp:align")?.elements[0]?.text;
|
|
34147
|
+
const simplePos = node.elements.find((el) => el.name === "wp:simplePos");
|
|
34148
|
+
const wrapSquare = node.elements.find((el) => el.name === "wp:wrapSquare");
|
|
34149
|
+
const wrapTopAndBottom = node.elements.find((el) => el.name === "wp:wrapTopAndBottom");
|
|
34150
|
+
const docPr = node.elements.find((el) => el.name === "wp:docPr");
|
|
34151
|
+
let anchorData = null;
|
|
34152
|
+
if (hRelativeFrom || alignH || vRelativeFrom || alignV) {
|
|
34153
|
+
anchorData = {
|
|
34154
|
+
hRelativeFrom,
|
|
34155
|
+
vRelativeFrom,
|
|
34156
|
+
alignH,
|
|
34157
|
+
alignV
|
|
34158
|
+
};
|
|
34159
|
+
}
|
|
34160
|
+
const marginOffset = {
|
|
34161
|
+
left: positionHValue,
|
|
34162
|
+
top: positionVValue
|
|
34163
|
+
};
|
|
34164
|
+
const { attributes: blipAttributes = {} } = blip;
|
|
34165
|
+
const rEmbed = blipAttributes["r:embed"];
|
|
34166
|
+
if (!rEmbed) return null;
|
|
34167
|
+
const currentFile = filename || "document.xml";
|
|
34168
|
+
let rels = docx[`word/_rels/${currentFile}.rels`];
|
|
34169
|
+
if (!rels) rels = docx[`word/_rels/document.xml.rels`];
|
|
34170
|
+
const relationships = rels.elements.find((el) => el.name === "Relationships");
|
|
34171
|
+
const { elements } = relationships || [];
|
|
34172
|
+
const rel = elements?.find((el) => el.attributes["Id"] === rEmbed);
|
|
34173
|
+
if (!rel) return null;
|
|
34174
|
+
const { attributes: relAttributes } = rel;
|
|
34175
|
+
const targetPath = relAttributes["Target"];
|
|
34176
|
+
let path = `word/${targetPath}`;
|
|
34177
|
+
if (targetPath.startsWith("/word") || targetPath.startsWith("/media")) path = targetPath.substring(1);
|
|
34178
|
+
const extension = targetPath.substring(targetPath.lastIndexOf(".") + 1);
|
|
34179
|
+
return {
|
|
34180
|
+
type: "image",
|
|
34181
|
+
attrs: {
|
|
34182
|
+
src: path,
|
|
34183
|
+
alt: ["emf", "wmf"].includes(extension) ? "Unable to render EMF/WMF image" : docPr?.attributes.name || "Image",
|
|
34184
|
+
extension,
|
|
34185
|
+
id: docPr?.attributes.id || "",
|
|
34186
|
+
title: docPr?.attributes.descr || "Image",
|
|
34187
|
+
inline: true,
|
|
34188
|
+
padding,
|
|
34189
|
+
marginOffset,
|
|
34190
|
+
size: size2,
|
|
34191
|
+
anchorData,
|
|
34192
|
+
isAnchor,
|
|
34193
|
+
...simplePos && {
|
|
34194
|
+
simplePos: {
|
|
34195
|
+
x: simplePos.attributes.x,
|
|
34196
|
+
y: simplePos.attributes.y
|
|
34197
|
+
}
|
|
34198
|
+
},
|
|
34199
|
+
...wrapSquare && {
|
|
34200
|
+
wrapText: wrapSquare.attributes.wrapText
|
|
34201
|
+
},
|
|
34202
|
+
wrapTopAndBottom: !!wrapTopAndBottom,
|
|
34203
|
+
originalPadding: {
|
|
34204
|
+
distT: attributes["distT"],
|
|
34205
|
+
distB: attributes["distB"],
|
|
34206
|
+
distL: attributes["distL"],
|
|
34207
|
+
distR: attributes["distR"]
|
|
34208
|
+
},
|
|
34209
|
+
originalAttributes: node.attributes,
|
|
34210
|
+
rId: relAttributes["Id"]
|
|
34211
|
+
}
|
|
34212
|
+
};
|
|
34213
|
+
}
|
|
34214
|
+
const handleShapeDrawing = (params2, node, graphicData) => {
|
|
34215
|
+
const wsp = graphicData.elements.find((el) => el.name === "wps:wsp");
|
|
34216
|
+
const textBox = wsp.elements.find((el) => el.name === "wps:txbx");
|
|
34217
|
+
const textBoxContent = textBox?.elements?.find((el) => el.name === "w:txbxContent");
|
|
34218
|
+
node.elements.find((el) => el.name === "wp:docPr");
|
|
34219
|
+
const spPr = wsp.elements.find((el) => el.name === "wps:spPr");
|
|
34220
|
+
const prstGeom = spPr?.elements.find((el) => el.name === "a:prstGeom");
|
|
34221
|
+
if (!!prstGeom && prstGeom.attributes["prst"] === "rect" && !textBoxContent) {
|
|
34222
|
+
return getRectangleShape(params2, spPr);
|
|
34223
|
+
}
|
|
34224
|
+
if (!textBoxContent) {
|
|
34225
|
+
return null;
|
|
34226
|
+
}
|
|
34227
|
+
const { nodeListHandler } = params2;
|
|
34228
|
+
const translatedElement = nodeListHandler.handler({
|
|
34229
|
+
...params2,
|
|
34230
|
+
node: textBoxContent.elements[0],
|
|
34231
|
+
nodes: textBoxContent.elements,
|
|
34232
|
+
path: [...params2.path || [], textBoxContent]
|
|
34233
|
+
});
|
|
34234
|
+
return translatedElement[0];
|
|
34235
|
+
};
|
|
34236
|
+
const getRectangleShape = (params2, node) => {
|
|
34237
|
+
const schemaAttrs = {};
|
|
34238
|
+
const [drawingNode] = params2.nodes;
|
|
34239
|
+
if (drawingNode?.name === "w:drawing") {
|
|
34240
|
+
schemaAttrs.drawingContent = drawingNode;
|
|
34241
|
+
}
|
|
34242
|
+
const xfrm = node.elements.find((el) => el.name === "a:xfrm");
|
|
34243
|
+
const start2 = xfrm.elements.find((el) => el.name === "a:off");
|
|
34244
|
+
const size2 = xfrm.elements.find((el) => el.name === "a:ext");
|
|
34245
|
+
const solidFill = node.elements.find((el) => el.name === "a:solidFill");
|
|
34246
|
+
node.elements.find((el) => el.name === "a:ln");
|
|
34247
|
+
const rectangleSize = {
|
|
34248
|
+
top: emuToPixels(start2.attributes["y"]),
|
|
34249
|
+
left: emuToPixels(start2.attributes["x"]),
|
|
34250
|
+
width: emuToPixels(size2.attributes["cx"]),
|
|
34251
|
+
height: emuToPixels(size2.attributes["cy"])
|
|
34252
|
+
};
|
|
34253
|
+
schemaAttrs.size = rectangleSize;
|
|
34254
|
+
const background = solidFill?.elements[0]?.attributes["val"];
|
|
34255
|
+
if (background) {
|
|
34256
|
+
schemaAttrs.background = "#" + background;
|
|
34257
|
+
}
|
|
34258
|
+
return {
|
|
34259
|
+
type: "contentBlock",
|
|
34260
|
+
attrs: schemaAttrs
|
|
34261
|
+
};
|
|
34262
|
+
};
|
|
34263
|
+
function handleAnchorNode(params2) {
|
|
34264
|
+
const { node } = params2.extraParams;
|
|
34265
|
+
if (node.name !== "wp:anchor") {
|
|
34266
|
+
return null;
|
|
34267
|
+
}
|
|
34268
|
+
return handleImageNode(node, params2, true);
|
|
34269
|
+
}
|
|
34270
|
+
const sanitizeDocxMediaName = (value, fallback = "image") => {
|
|
34271
|
+
if (!value) return fallback;
|
|
34272
|
+
const sanitized = value.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
34273
|
+
return sanitized || fallback;
|
|
34274
|
+
};
|
|
34275
|
+
const getFallbackImageNameFromDataUri = (src = "", fallback = "image") => {
|
|
34276
|
+
if (!src || typeof src !== "string") return fallback;
|
|
34277
|
+
const [prefix2] = src.split(";");
|
|
34278
|
+
const [, maybeType] = prefix2.split("/");
|
|
34279
|
+
const extension = maybeType?.toLowerCase();
|
|
34280
|
+
return extension ? `${fallback}.${extension}` : fallback;
|
|
34281
|
+
};
|
|
34282
|
+
const translateImageNode = (params2) => {
|
|
34283
|
+
const {
|
|
34284
|
+
node: { attrs = {} },
|
|
34285
|
+
tableCell,
|
|
34286
|
+
imageSize
|
|
34287
|
+
} = params2;
|
|
34288
|
+
let imageId = attrs.rId;
|
|
34289
|
+
const src = attrs.src || attrs.imageSrc;
|
|
34290
|
+
const { originalWidth, originalHeight } = getPngDimensions(src);
|
|
34291
|
+
let imageName;
|
|
34292
|
+
if (params2.node.type === "image") {
|
|
34293
|
+
if (src?.startsWith("data:")) {
|
|
34294
|
+
imageName = getFallbackImageNameFromDataUri(src);
|
|
34295
|
+
} else {
|
|
34296
|
+
imageName = src?.split("/").pop();
|
|
34297
|
+
}
|
|
34298
|
+
} else {
|
|
34299
|
+
imageName = attrs.fieldId;
|
|
34300
|
+
}
|
|
34301
|
+
imageName = sanitizeDocxMediaName(imageName);
|
|
34302
|
+
let size2 = attrs.size ? {
|
|
34303
|
+
w: pixelsToEmu(attrs.size.width),
|
|
34304
|
+
h: pixelsToEmu(attrs.size.height)
|
|
34305
|
+
} : imageSize;
|
|
34306
|
+
if (originalWidth && originalHeight) {
|
|
34307
|
+
const boxWidthPx = emuToPixels(size2.w);
|
|
34308
|
+
const boxHeightPx = emuToPixels(size2.h);
|
|
34309
|
+
const { scaledWidth, scaledHeight } = getScaledSize(originalWidth, originalHeight, boxWidthPx, boxHeightPx);
|
|
34310
|
+
size2 = {
|
|
34311
|
+
w: pixelsToEmu(scaledWidth),
|
|
34312
|
+
h: pixelsToEmu(scaledHeight)
|
|
34313
|
+
};
|
|
34314
|
+
}
|
|
34315
|
+
if (tableCell) {
|
|
34316
|
+
const colwidthSum = tableCell.attrs.colwidth.reduce((acc, curr) => acc + curr, 0);
|
|
34317
|
+
const leftMargin = tableCell.attrs.cellMargins?.left || 8;
|
|
34318
|
+
const rightMargin = tableCell.attrs.cellMargins?.right || 8;
|
|
34319
|
+
const maxWidthEmu = pixelsToEmu(colwidthSum - (leftMargin + rightMargin));
|
|
34320
|
+
const { width: w2, height: h2 } = resizeKeepAspectRatio(size2.w, size2.h, maxWidthEmu);
|
|
34321
|
+
if (w2 && h2) size2 = { w: w2, h: h2 };
|
|
34322
|
+
}
|
|
34323
|
+
if (params2.node.type === "image" && !imageId) {
|
|
34324
|
+
const path = src?.split("word/")[1];
|
|
34325
|
+
imageId = addNewImageRelationship(params2, path);
|
|
34326
|
+
} else if (params2.node.type === "fieldAnnotation" && !imageId) {
|
|
34327
|
+
const type2 = src?.split(";")[0].split("/")[1];
|
|
34328
|
+
if (!type2) {
|
|
34329
|
+
return prepareTextAnnotation(params2);
|
|
34330
|
+
}
|
|
34331
|
+
const sanitizedHash = sanitizeDocxMediaName(attrs.hash, generateDocxRandomId(4));
|
|
34332
|
+
const fileName = `${imageName}_${sanitizedHash}.${type2}`;
|
|
34333
|
+
const relationshipTarget = `media/${fileName}`;
|
|
34334
|
+
const packagePath = `word/${relationshipTarget}`;
|
|
34335
|
+
imageId = addNewImageRelationship(params2, relationshipTarget);
|
|
34336
|
+
params2.media[packagePath] = src;
|
|
34337
|
+
}
|
|
34338
|
+
const inlineAttrs = attrs.originalPadding || {
|
|
34339
|
+
distT: 0,
|
|
34340
|
+
distB: 0,
|
|
34341
|
+
distL: 0,
|
|
34342
|
+
distR: 0
|
|
34343
|
+
};
|
|
34344
|
+
const drawingXmlns = "http://schemas.openxmlformats.org/drawingml/2006/main";
|
|
34345
|
+
const pictureXmlns = "http://schemas.openxmlformats.org/drawingml/2006/picture";
|
|
34346
|
+
return {
|
|
34347
|
+
attributes: inlineAttrs,
|
|
34348
|
+
elements: [
|
|
34349
|
+
{
|
|
34350
|
+
name: "wp:extent",
|
|
34351
|
+
attributes: {
|
|
34352
|
+
cx: size2.w,
|
|
34353
|
+
cy: size2.h
|
|
34354
|
+
}
|
|
34355
|
+
},
|
|
34356
|
+
{
|
|
34357
|
+
name: "wp:effectExtent",
|
|
34358
|
+
attributes: {
|
|
34359
|
+
l: 0,
|
|
34360
|
+
t: 0,
|
|
34361
|
+
r: 0,
|
|
34362
|
+
b: 0
|
|
34363
|
+
}
|
|
34364
|
+
},
|
|
34365
|
+
{
|
|
34366
|
+
name: "wp:docPr",
|
|
34367
|
+
attributes: {
|
|
34368
|
+
id: attrs.id || 0,
|
|
34369
|
+
name: attrs.alt || `Picture ${imageName}`
|
|
34370
|
+
}
|
|
34371
|
+
},
|
|
34372
|
+
{
|
|
34373
|
+
name: "wp:cNvGraphicFramePr",
|
|
34374
|
+
elements: [
|
|
34375
|
+
{
|
|
34376
|
+
name: "a:graphicFrameLocks",
|
|
34377
|
+
attributes: {
|
|
34378
|
+
"xmlns:a": drawingXmlns,
|
|
34379
|
+
noChangeAspect: 1
|
|
34380
|
+
}
|
|
34381
|
+
}
|
|
34382
|
+
]
|
|
34383
|
+
},
|
|
34384
|
+
{
|
|
34385
|
+
name: "a:graphic",
|
|
34386
|
+
attributes: { "xmlns:a": drawingXmlns },
|
|
34387
|
+
elements: [
|
|
34388
|
+
{
|
|
34389
|
+
name: "a:graphicData",
|
|
34390
|
+
attributes: { uri: pictureXmlns },
|
|
34391
|
+
elements: [
|
|
34392
|
+
{
|
|
34393
|
+
name: "pic:pic",
|
|
34394
|
+
attributes: { "xmlns:pic": pictureXmlns },
|
|
34395
|
+
elements: [
|
|
34396
|
+
{
|
|
34397
|
+
name: "pic:nvPicPr",
|
|
34398
|
+
elements: [
|
|
34399
|
+
{
|
|
34400
|
+
name: "pic:cNvPr",
|
|
34401
|
+
attributes: {
|
|
34402
|
+
id: attrs.id || 0,
|
|
34403
|
+
name: attrs.title || `Picture ${imageName}`
|
|
34404
|
+
}
|
|
34405
|
+
},
|
|
34406
|
+
{
|
|
34407
|
+
name: "pic:cNvPicPr",
|
|
34408
|
+
elements: [
|
|
34409
|
+
{
|
|
34410
|
+
name: "a:picLocks",
|
|
34411
|
+
attributes: {
|
|
34412
|
+
noChangeAspect: 1,
|
|
34413
|
+
noChangeArrowheads: 1
|
|
34414
|
+
}
|
|
34415
|
+
}
|
|
34416
|
+
]
|
|
34417
|
+
}
|
|
34418
|
+
]
|
|
34419
|
+
},
|
|
34420
|
+
{
|
|
34421
|
+
name: "pic:blipFill",
|
|
34422
|
+
elements: [
|
|
34423
|
+
{
|
|
34424
|
+
name: "a:blip",
|
|
34425
|
+
attributes: {
|
|
34426
|
+
"r:embed": imageId
|
|
34427
|
+
}
|
|
34428
|
+
},
|
|
34429
|
+
{
|
|
34430
|
+
name: "a:stretch",
|
|
34431
|
+
elements: [{ name: "a:fillRect" }]
|
|
34432
|
+
}
|
|
34433
|
+
]
|
|
34434
|
+
},
|
|
34435
|
+
{
|
|
34436
|
+
name: "pic:spPr",
|
|
34437
|
+
attributes: {
|
|
34438
|
+
bwMode: "auto"
|
|
34439
|
+
},
|
|
34440
|
+
elements: [
|
|
34441
|
+
{
|
|
34442
|
+
name: "a:xfrm",
|
|
34443
|
+
elements: [
|
|
34444
|
+
{
|
|
34445
|
+
name: "a:ext",
|
|
34446
|
+
attributes: {
|
|
34447
|
+
cx: size2.w,
|
|
34448
|
+
cy: size2.h
|
|
34449
|
+
}
|
|
34450
|
+
},
|
|
34451
|
+
{
|
|
34452
|
+
name: "a:off",
|
|
34453
|
+
attributes: {
|
|
34454
|
+
x: 0,
|
|
34455
|
+
y: 0
|
|
34456
|
+
}
|
|
34457
|
+
}
|
|
34458
|
+
]
|
|
34459
|
+
},
|
|
34460
|
+
{
|
|
34461
|
+
name: "a:prstGeom",
|
|
34462
|
+
attributes: { prst: "rect" },
|
|
34463
|
+
elements: [{ name: "a:avLst" }]
|
|
34464
|
+
},
|
|
34465
|
+
{
|
|
34466
|
+
name: "a:noFill"
|
|
34467
|
+
}
|
|
34468
|
+
]
|
|
34469
|
+
}
|
|
34470
|
+
]
|
|
34471
|
+
}
|
|
34472
|
+
]
|
|
34473
|
+
}
|
|
34474
|
+
]
|
|
34475
|
+
}
|
|
34476
|
+
]
|
|
34477
|
+
};
|
|
34478
|
+
};
|
|
34479
|
+
function getPngDimensions(base64) {
|
|
34480
|
+
if (!base64) return {};
|
|
34481
|
+
const type2 = base64.split(";")[0].split("/")[1];
|
|
34482
|
+
if (!base64 || type2 !== "png") {
|
|
34483
|
+
return {
|
|
34484
|
+
originalWidth: void 0,
|
|
34485
|
+
originalHeight: void 0
|
|
34486
|
+
};
|
|
34487
|
+
}
|
|
34488
|
+
let header = base64.split(",")[1].slice(0, 50);
|
|
34489
|
+
let uint8 = Uint8Array.from(atob(header), (c2) => c2.charCodeAt(0));
|
|
34490
|
+
let dataView = new DataView(uint8.buffer, 0, 28);
|
|
34491
|
+
return {
|
|
34492
|
+
originalWidth: dataView.getInt32(16),
|
|
34493
|
+
originalHeight: dataView.getInt32(20)
|
|
34494
|
+
};
|
|
34495
|
+
}
|
|
34496
|
+
function getScaledSize(originalWidth, originalHeight, maxWidth, maxHeight) {
|
|
34497
|
+
let scaledWidth = originalWidth;
|
|
34498
|
+
let scaledHeight = originalHeight;
|
|
34499
|
+
let ratio = Math.min(maxWidth / originalWidth, maxHeight / originalHeight);
|
|
34500
|
+
scaledWidth = Math.round(scaledWidth * ratio);
|
|
34501
|
+
scaledHeight = Math.round(scaledHeight * ratio);
|
|
34502
|
+
return { scaledWidth, scaledHeight };
|
|
34503
|
+
}
|
|
34504
|
+
function resizeKeepAspectRatio(width, height, maxWidth) {
|
|
34505
|
+
if (width > maxWidth) {
|
|
34506
|
+
let scale = maxWidth / width;
|
|
34507
|
+
let newHeight = Math.round(height * scale);
|
|
34508
|
+
return { width: maxWidth, height: newHeight };
|
|
34509
|
+
}
|
|
34510
|
+
return { width, height };
|
|
34511
|
+
}
|
|
34512
|
+
function addNewImageRelationship(params2, imagePath) {
|
|
34513
|
+
const newId = "rId" + generateDocxRandomId();
|
|
34514
|
+
const newRel = {
|
|
34515
|
+
type: "element",
|
|
34516
|
+
name: "Relationship",
|
|
34517
|
+
attributes: {
|
|
34518
|
+
Id: newId,
|
|
34519
|
+
Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
|
|
34520
|
+
Target: imagePath
|
|
34521
|
+
}
|
|
34522
|
+
};
|
|
34523
|
+
params2.relationships.push(newRel);
|
|
34524
|
+
return newId;
|
|
34525
|
+
}
|
|
34526
|
+
function translateAnchorNode(params2) {
|
|
34527
|
+
const { attrs } = params2.node;
|
|
34528
|
+
const anchorElements = [];
|
|
34529
|
+
const wrapElements = [];
|
|
34530
|
+
if (attrs.simplePos) {
|
|
34531
|
+
anchorElements.push({
|
|
34532
|
+
name: "wp:simplePos",
|
|
34533
|
+
attributes: {
|
|
34534
|
+
x: 0,
|
|
34535
|
+
y: 0
|
|
34536
|
+
}
|
|
34537
|
+
});
|
|
34538
|
+
}
|
|
34539
|
+
if (attrs.anchorData) {
|
|
34540
|
+
const hElements = [];
|
|
34541
|
+
if (attrs.marginOffset.left !== void 0) {
|
|
34542
|
+
hElements.push({
|
|
34543
|
+
name: "wp:posOffset",
|
|
34544
|
+
elements: [{ type: "text", text: pixelsToEmu(attrs.marginOffset.left).toString() }]
|
|
34545
|
+
});
|
|
34546
|
+
}
|
|
34547
|
+
if (attrs.anchorData.alignH) {
|
|
34548
|
+
hElements.push({
|
|
34549
|
+
name: "wp:align",
|
|
34550
|
+
elements: [{ type: "text", text: attrs.anchorData.alignH }]
|
|
34551
|
+
});
|
|
34552
|
+
}
|
|
34553
|
+
anchorElements.push({
|
|
34554
|
+
name: "wp:positionH",
|
|
34555
|
+
attributes: { relativeFrom: attrs.anchorData.hRelativeFrom },
|
|
34556
|
+
...hElements.length && { elements: hElements }
|
|
34557
|
+
});
|
|
34558
|
+
const vElements = [];
|
|
34559
|
+
if (attrs.marginOffset.top !== void 0) {
|
|
34560
|
+
vElements.push({
|
|
34561
|
+
name: "wp:posOffset",
|
|
34562
|
+
elements: [{ type: "text", text: pixelsToEmu(attrs.marginOffset.top).toString() }]
|
|
34563
|
+
});
|
|
34564
|
+
}
|
|
34565
|
+
if (attrs.anchorData.alignV) {
|
|
34566
|
+
vElements.push({
|
|
34567
|
+
name: "wp:align",
|
|
34568
|
+
elements: [{ type: "text", text: attrs.anchorData.alignV }]
|
|
34569
|
+
});
|
|
34570
|
+
}
|
|
34571
|
+
anchorElements.push({
|
|
34572
|
+
name: "wp:positionV",
|
|
34573
|
+
attributes: { relativeFrom: attrs.anchorData.vRelativeFrom },
|
|
34574
|
+
...vElements.length && { elements: vElements }
|
|
34575
|
+
});
|
|
34576
|
+
}
|
|
34577
|
+
if (attrs.wrapText) {
|
|
34578
|
+
wrapElements.push({
|
|
34579
|
+
name: "wp:wrapSquare",
|
|
34580
|
+
attributes: {
|
|
34581
|
+
wrapText: attrs.wrapText
|
|
34582
|
+
}
|
|
34583
|
+
});
|
|
34584
|
+
}
|
|
34585
|
+
if (attrs.wrapTopAndBottom) {
|
|
34586
|
+
wrapElements.push({
|
|
34587
|
+
name: "wp:wrapTopAndBottom"
|
|
34588
|
+
});
|
|
34589
|
+
}
|
|
34590
|
+
if (!wrapElements.length) {
|
|
34591
|
+
wrapElements.push({
|
|
34592
|
+
name: "wp:wrapNone"
|
|
34593
|
+
});
|
|
34594
|
+
}
|
|
34595
|
+
const nodeElements = translateImageNode(params2);
|
|
34596
|
+
const inlineAttrs = {
|
|
34597
|
+
...nodeElements.attributes,
|
|
34598
|
+
simplePos: attrs.originalAttributes?.simplePos,
|
|
34599
|
+
relativeHeight: 1,
|
|
34600
|
+
behindDoc: attrs.originalAttributes?.behindDoc,
|
|
34601
|
+
locked: attrs.originalAttributes?.locked,
|
|
34602
|
+
layoutInCell: attrs.originalAttributes?.layoutInCell,
|
|
34603
|
+
allowOverlap: attrs.originalAttributes?.allowOverlap
|
|
34604
|
+
};
|
|
34605
|
+
const effectIndex = nodeElements.elements.findIndex((el) => el.name === "wp:effectExtent");
|
|
34606
|
+
const elementsWithWrap = [
|
|
34607
|
+
...nodeElements.elements.slice(0, effectIndex + 1),
|
|
34608
|
+
...wrapElements,
|
|
34609
|
+
...nodeElements.elements.slice(effectIndex + 1)
|
|
34610
|
+
];
|
|
34611
|
+
return {
|
|
34612
|
+
name: "wp:anchor",
|
|
34613
|
+
attributes: inlineAttrs,
|
|
34614
|
+
elements: [...anchorElements, ...elementsWithWrap]
|
|
34615
|
+
};
|
|
34616
|
+
}
|
|
34617
|
+
const XML_NODE_NAME$3 = "wp:anchor";
|
|
34618
|
+
const SD_NODE_NAME$3 = ["image"];
|
|
34619
|
+
const validXmlAttributes$3 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
|
|
34620
|
+
function encode$3(params2, encodedAttrs) {
|
|
34621
|
+
const { node } = params2.extraParams;
|
|
34622
|
+
if (!node || !node.type) {
|
|
34623
|
+
return null;
|
|
34624
|
+
}
|
|
34625
|
+
return handleAnchorNode(params2);
|
|
34626
|
+
}
|
|
34627
|
+
function decode$3(params2, decodedAttrs) {
|
|
34628
|
+
const { node } = params2;
|
|
34629
|
+
if (!node || !node.type) {
|
|
34630
|
+
return null;
|
|
34631
|
+
}
|
|
34632
|
+
return translateAnchorNode(params2);
|
|
34633
|
+
}
|
|
34634
|
+
const config$3 = {
|
|
34635
|
+
xmlName: XML_NODE_NAME$3,
|
|
34636
|
+
sdNodeOrKeyName: SD_NODE_NAME$3,
|
|
34637
|
+
type: NodeTranslator.translatorTypes.NODE,
|
|
34638
|
+
encode: encode$3,
|
|
34639
|
+
decode: decode$3,
|
|
34640
|
+
attributes: validXmlAttributes$3
|
|
34641
|
+
};
|
|
34642
|
+
const translator$3 = NodeTranslator.from(config$3);
|
|
34643
|
+
function handleInlineNode(params2) {
|
|
34644
|
+
const { node } = params2.extraParams;
|
|
34645
|
+
if (node.name !== "wp:inline") {
|
|
34646
|
+
return null;
|
|
34647
|
+
}
|
|
34648
|
+
return handleImageNode(node, params2, false);
|
|
34649
|
+
}
|
|
34650
|
+
function translateInlineNode(params2) {
|
|
34651
|
+
const nodeElements = translateImageNode(params2);
|
|
34652
|
+
return {
|
|
34653
|
+
name: "wp:inline",
|
|
34654
|
+
attributes: nodeElements.attributes,
|
|
34655
|
+
elements: nodeElements.elements
|
|
34656
|
+
};
|
|
34657
|
+
}
|
|
34658
|
+
const XML_NODE_NAME$2 = "wp:inline";
|
|
34659
|
+
const SD_NODE_NAME$2 = ["image"];
|
|
34660
|
+
const validXmlAttributes$2 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
|
|
34661
|
+
function encode$2(params2, encodedAttrs) {
|
|
34662
|
+
const { node } = params2.extraParams;
|
|
34663
|
+
if (!node || !node.type) {
|
|
34664
|
+
return null;
|
|
34665
|
+
}
|
|
34666
|
+
return handleInlineNode(params2);
|
|
34667
|
+
}
|
|
34668
|
+
function decode$2(params2, decodedAttrs) {
|
|
34669
|
+
const { node } = params2;
|
|
34670
|
+
if (!node || !node.type) {
|
|
34671
|
+
return null;
|
|
34672
|
+
}
|
|
34673
|
+
return translateInlineNode(params2);
|
|
34674
|
+
}
|
|
34675
|
+
const config$2 = {
|
|
34676
|
+
xmlName: XML_NODE_NAME$2,
|
|
34677
|
+
sdNodeOrKeyName: SD_NODE_NAME$2,
|
|
34678
|
+
type: NodeTranslator.translatorTypes.NODE,
|
|
34679
|
+
encode: encode$2,
|
|
34680
|
+
decode: decode$2,
|
|
34681
|
+
attributes: validXmlAttributes$2
|
|
34682
|
+
};
|
|
34683
|
+
const translator$2 = NodeTranslator.from(config$2);
|
|
34684
|
+
const registeredHandlers = Object.freeze({
|
|
34685
|
+
"w:br": translator$m,
|
|
34686
|
+
"w:tab": translator$l,
|
|
34687
|
+
"w:p": translator$k,
|
|
34688
|
+
"wp:anchor": translator$3,
|
|
34689
|
+
"wp:inline": translator$2
|
|
34690
|
+
});
|
|
34691
|
+
const XML_NODE_NAME$1 = "w:drawing";
|
|
34692
|
+
const SD_NODE_NAME$1 = [];
|
|
34693
|
+
const validXmlAttributes$1 = [];
|
|
34694
|
+
function encode$1(params2, encodedAttrs) {
|
|
34695
|
+
const nodes = params2.nodes;
|
|
34696
|
+
const node = nodes[0];
|
|
34697
|
+
const validChildTranslators = ["wp:anchor", "wp:inline"];
|
|
34698
|
+
return node.elements.reduce((acc, child) => {
|
|
34699
|
+
if (acc) return acc;
|
|
34700
|
+
if (!validChildTranslators.includes(child.name)) return acc;
|
|
34701
|
+
const translator2 = registeredHandlers[child.name];
|
|
34702
|
+
return translator2.encode({ ...params2, extraParams: { node: child } }) || acc;
|
|
34703
|
+
}, null);
|
|
34704
|
+
}
|
|
34705
|
+
function decode$1(params2, decodedAttrs) {
|
|
34706
|
+
const { node } = params2;
|
|
34707
|
+
if (!node || !node.type) {
|
|
34708
|
+
return null;
|
|
34709
|
+
}
|
|
34710
|
+
const handlerName = node.attrs.isAnchor ? "wp:anchor" : "wp:inline";
|
|
34711
|
+
const resultNode = registeredHandlers[handlerName].decode(params2);
|
|
34712
|
+
return wrapTextInRun(
|
|
34713
|
+
{
|
|
34714
|
+
name: "w:drawing",
|
|
34715
|
+
elements: [resultNode]
|
|
34716
|
+
},
|
|
34717
|
+
[]
|
|
34718
|
+
);
|
|
34719
|
+
}
|
|
34720
|
+
const config$1 = {
|
|
34721
|
+
xmlName: XML_NODE_NAME$1,
|
|
34722
|
+
sdNodeOrKeyName: SD_NODE_NAME$1,
|
|
34723
|
+
type: NodeTranslator.translatorTypes.NODE,
|
|
34724
|
+
encode: encode$1,
|
|
34725
|
+
decode: decode$1,
|
|
34726
|
+
attributes: validXmlAttributes$1
|
|
34727
|
+
};
|
|
34728
|
+
const translator$1 = NodeTranslator.from(config$1);
|
|
34106
34729
|
class CommandService {
|
|
34107
34730
|
/**
|
|
34108
34731
|
* @param {import('./commands/types/index.js').CommandServiceOptions} props
|
|
@@ -35440,7 +36063,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
35440
36063
|
return getTextNodeForExport(attrs.displayLabel, [...marks, ...marksFromAttrs], params2);
|
|
35441
36064
|
}
|
|
35442
36065
|
function prepareImageAnnotation(params2, imageSize) {
|
|
35443
|
-
return
|
|
36066
|
+
return translator$1.decode({
|
|
36067
|
+
...params2,
|
|
36068
|
+
imageSize
|
|
36069
|
+
});
|
|
35444
36070
|
}
|
|
35445
36071
|
function prepareCheckboxAnnotation(params2) {
|
|
35446
36072
|
const {
|
|
@@ -35677,7 +36303,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
35677
36303
|
const XML_NODE_NAME = "w:sdt";
|
|
35678
36304
|
const SD_NODE_NAME = ["fieldAnnotation", "structuredContent", "structuredContentBlock", "documentSection"];
|
|
35679
36305
|
const validXmlAttributes = [];
|
|
35680
|
-
function encode$
|
|
36306
|
+
function encode$n(params2, encodedAttrs) {
|
|
35681
36307
|
const nodes = params2.nodes;
|
|
35682
36308
|
const node = nodes[0];
|
|
35683
36309
|
const { type: sdtType, handler: handler2 } = sdtNodeTypeStrategy(node);
|
|
@@ -35707,7 +36333,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
35707
36333
|
xmlName: XML_NODE_NAME,
|
|
35708
36334
|
sdNodeOrKeyName: SD_NODE_NAME,
|
|
35709
36335
|
type: NodeTranslator.translatorTypes.NODE,
|
|
35710
|
-
encode: encode$
|
|
36336
|
+
encode: encode$n,
|
|
35711
36337
|
decode,
|
|
35712
36338
|
attributes: validXmlAttributes
|
|
35713
36339
|
};
|
|
@@ -35718,19 +36344,19 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
35718
36344
|
doc: translateDocumentNode,
|
|
35719
36345
|
body: translateBodyNode,
|
|
35720
36346
|
heading: translateHeadingNode,
|
|
35721
|
-
paragraph: translator$
|
|
36347
|
+
paragraph: translator$k,
|
|
35722
36348
|
text: translateTextNode,
|
|
35723
36349
|
bulletList: translateList,
|
|
35724
36350
|
orderedList: translateList,
|
|
35725
|
-
lineBreak: translator$
|
|
36351
|
+
lineBreak: translator$m,
|
|
35726
36352
|
table: translateTable,
|
|
35727
|
-
tableRow: translator$
|
|
35728
|
-
tableCell: translator$
|
|
36353
|
+
tableRow: translator$6,
|
|
36354
|
+
tableCell: translator$5,
|
|
35729
36355
|
bookmarkStart: translateBookmarkStart,
|
|
35730
36356
|
fieldAnnotation: translator,
|
|
35731
|
-
tab: translator$
|
|
35732
|
-
image:
|
|
35733
|
-
hardBreak: translator$
|
|
36357
|
+
tab: translator$l,
|
|
36358
|
+
image: translator$1,
|
|
36359
|
+
hardBreak: translator$m,
|
|
35734
36360
|
commentRangeStart: () => translateCommentNode(params2, "Start"),
|
|
35735
36361
|
commentRangeEnd: () => translateCommentNode(params2, "End"),
|
|
35736
36362
|
commentReference: () => null,
|
|
@@ -36062,7 +36688,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
36062
36688
|
const isTrackedNode = node.marks?.some((m2) => trackedMarks.includes(m2.type));
|
|
36063
36689
|
if (isTrackedNode) return translateTrackedNode(params2);
|
|
36064
36690
|
const isLinkNode = node.marks?.some((m2) => m2.type === "link");
|
|
36065
|
-
if (isLinkNode) return translator$
|
|
36691
|
+
if (isLinkNode) return translator$4.decode(params2);
|
|
36066
36692
|
const { text, marks = [] } = node;
|
|
36067
36693
|
return getTextNodeForExport(text, marks, params2);
|
|
36068
36694
|
}
|
|
@@ -36195,20 +36821,6 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
36195
36821
|
});
|
|
36196
36822
|
return newId;
|
|
36197
36823
|
}
|
|
36198
|
-
function addNewImageRelationship(params2, imagePath) {
|
|
36199
|
-
const newId = "rId" + generateDocxRandomId();
|
|
36200
|
-
const newRel = {
|
|
36201
|
-
type: "element",
|
|
36202
|
-
name: "Relationship",
|
|
36203
|
-
attributes: {
|
|
36204
|
-
Id: newId,
|
|
36205
|
-
Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
|
|
36206
|
-
Target: imagePath
|
|
36207
|
-
}
|
|
36208
|
-
};
|
|
36209
|
-
params2.relationships.push(newRel);
|
|
36210
|
-
return newId;
|
|
36211
|
-
}
|
|
36212
36824
|
function translateList(params2) {
|
|
36213
36825
|
const { node, editor } = params2;
|
|
36214
36826
|
const listItem = node.content[0];
|
|
@@ -36567,345 +37179,6 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
36567
37179
|
}
|
|
36568
37180
|
return markElement;
|
|
36569
37181
|
}
|
|
36570
|
-
function getPngDimensions(base64) {
|
|
36571
|
-
if (!base64) return {};
|
|
36572
|
-
const type2 = base64.split(";")[0].split("/")[1];
|
|
36573
|
-
if (!base64 || type2 !== "png") {
|
|
36574
|
-
return {
|
|
36575
|
-
originalWidth: void 0,
|
|
36576
|
-
originalHeight: void 0
|
|
36577
|
-
};
|
|
36578
|
-
}
|
|
36579
|
-
let header = base64.split(",")[1].slice(0, 50);
|
|
36580
|
-
let uint8 = Uint8Array.from(atob(header), (c2) => c2.charCodeAt(0));
|
|
36581
|
-
let dataView = new DataView(uint8.buffer, 0, 28);
|
|
36582
|
-
return {
|
|
36583
|
-
originalWidth: dataView.getInt32(16),
|
|
36584
|
-
originalHeight: dataView.getInt32(20)
|
|
36585
|
-
};
|
|
36586
|
-
}
|
|
36587
|
-
function getScaledSize(originalWidth, originalHeight, maxWidth, maxHeight) {
|
|
36588
|
-
let scaledWidth = originalWidth;
|
|
36589
|
-
let scaledHeight = originalHeight;
|
|
36590
|
-
let ratio = Math.min(maxWidth / originalWidth, maxHeight / originalHeight);
|
|
36591
|
-
scaledWidth = Math.round(scaledWidth * ratio);
|
|
36592
|
-
scaledHeight = Math.round(scaledHeight * ratio);
|
|
36593
|
-
return { scaledWidth, scaledHeight };
|
|
36594
|
-
}
|
|
36595
|
-
function translateImageNode(params2, imageSize) {
|
|
36596
|
-
const {
|
|
36597
|
-
node: { attrs = {} },
|
|
36598
|
-
tableCell
|
|
36599
|
-
} = params2;
|
|
36600
|
-
let imageId = attrs.rId;
|
|
36601
|
-
const src = attrs.src || attrs.imageSrc;
|
|
36602
|
-
const { originalWidth, originalHeight } = getPngDimensions(src);
|
|
36603
|
-
let imageName;
|
|
36604
|
-
if (params2.node.type === "image") {
|
|
36605
|
-
if (src?.startsWith("data:")) {
|
|
36606
|
-
imageName = getFallbackImageNameFromDataUri(src);
|
|
36607
|
-
} else {
|
|
36608
|
-
imageName = src?.split("/").pop();
|
|
36609
|
-
}
|
|
36610
|
-
} else {
|
|
36611
|
-
imageName = attrs.fieldId;
|
|
36612
|
-
}
|
|
36613
|
-
imageName = sanitizeDocxMediaName(imageName);
|
|
36614
|
-
let size2 = attrs.size ? {
|
|
36615
|
-
w: pixelsToEmu(attrs.size.width),
|
|
36616
|
-
h: pixelsToEmu(attrs.size.height)
|
|
36617
|
-
} : imageSize;
|
|
36618
|
-
if (originalWidth && originalHeight) {
|
|
36619
|
-
const boxWidthPx = emuToPixels(size2.w);
|
|
36620
|
-
const boxHeightPx = emuToPixels(size2.h);
|
|
36621
|
-
const { scaledWidth, scaledHeight } = getScaledSize(originalWidth, originalHeight, boxWidthPx, boxHeightPx);
|
|
36622
|
-
size2 = {
|
|
36623
|
-
w: pixelsToEmu(scaledWidth),
|
|
36624
|
-
h: pixelsToEmu(scaledHeight)
|
|
36625
|
-
};
|
|
36626
|
-
}
|
|
36627
|
-
if (tableCell) {
|
|
36628
|
-
const colwidthSum = tableCell.attrs.colwidth.reduce((acc, curr) => acc + curr, 0);
|
|
36629
|
-
const leftMargin = tableCell.attrs.cellMargins?.left || 8;
|
|
36630
|
-
const rightMargin = tableCell.attrs.cellMargins?.right || 8;
|
|
36631
|
-
const maxWidthEmu = pixelsToEmu(colwidthSum - (leftMargin + rightMargin));
|
|
36632
|
-
const { width: w2, height: h2 } = resizeKeepAspectRatio(size2.w, size2.h, maxWidthEmu);
|
|
36633
|
-
if (w2 && h2) size2 = { w: w2, h: h2 };
|
|
36634
|
-
}
|
|
36635
|
-
if (params2.node.type === "image" && !imageId) {
|
|
36636
|
-
const path = src?.split("word/")[1];
|
|
36637
|
-
imageId = addNewImageRelationship(params2, path);
|
|
36638
|
-
} else if (params2.node.type === "fieldAnnotation" && !imageId) {
|
|
36639
|
-
const type2 = src?.split(";")[0].split("/")[1];
|
|
36640
|
-
if (!type2) {
|
|
36641
|
-
return prepareTextAnnotation(params2);
|
|
36642
|
-
}
|
|
36643
|
-
const sanitizedHash = sanitizeDocxMediaName(attrs.hash, generateDocxRandomId(4));
|
|
36644
|
-
const fileName = `${imageName}_${sanitizedHash}.${type2}`;
|
|
36645
|
-
const relationshipTarget = `media/${fileName}`;
|
|
36646
|
-
const packagePath = `word/${relationshipTarget}`;
|
|
36647
|
-
imageId = addNewImageRelationship(params2, relationshipTarget);
|
|
36648
|
-
params2.media[packagePath] = src;
|
|
36649
|
-
}
|
|
36650
|
-
let inlineAttrs = attrs.originalPadding || {
|
|
36651
|
-
distT: 0,
|
|
36652
|
-
distB: 0,
|
|
36653
|
-
distL: 0,
|
|
36654
|
-
distR: 0
|
|
36655
|
-
};
|
|
36656
|
-
const anchorElements = [];
|
|
36657
|
-
let wrapProp = [];
|
|
36658
|
-
if (attrs.isAnchor) {
|
|
36659
|
-
inlineAttrs = {
|
|
36660
|
-
...inlineAttrs,
|
|
36661
|
-
simplePos: attrs.originalAttributes?.simplePos,
|
|
36662
|
-
relativeHeight: 1,
|
|
36663
|
-
behindDoc: attrs.originalAttributes?.behindDoc,
|
|
36664
|
-
locked: attrs.originalAttributes?.locked,
|
|
36665
|
-
layoutInCell: attrs.originalAttributes?.layoutInCell,
|
|
36666
|
-
allowOverlap: attrs.originalAttributes?.allowOverlap
|
|
36667
|
-
};
|
|
36668
|
-
if (attrs.simplePos) {
|
|
36669
|
-
anchorElements.push({
|
|
36670
|
-
name: "wp:simplePos",
|
|
36671
|
-
attributes: {
|
|
36672
|
-
x: 0,
|
|
36673
|
-
y: 0
|
|
36674
|
-
}
|
|
36675
|
-
});
|
|
36676
|
-
}
|
|
36677
|
-
if (attrs.anchorData) {
|
|
36678
|
-
anchorElements.push({
|
|
36679
|
-
name: "wp:positionH",
|
|
36680
|
-
attributes: {
|
|
36681
|
-
relativeFrom: attrs.anchorData.hRelativeFrom
|
|
36682
|
-
},
|
|
36683
|
-
...attrs.marginOffset.left !== void 0 && {
|
|
36684
|
-
elements: [
|
|
36685
|
-
{
|
|
36686
|
-
name: "wp:posOffset",
|
|
36687
|
-
elements: [
|
|
36688
|
-
{
|
|
36689
|
-
type: "text",
|
|
36690
|
-
text: pixelsToEmu(attrs.marginOffset.left).toString()
|
|
36691
|
-
}
|
|
36692
|
-
]
|
|
36693
|
-
}
|
|
36694
|
-
]
|
|
36695
|
-
},
|
|
36696
|
-
...attrs.anchorData.alignH && {
|
|
36697
|
-
elements: [
|
|
36698
|
-
{
|
|
36699
|
-
name: "wp:align",
|
|
36700
|
-
elements: [
|
|
36701
|
-
{
|
|
36702
|
-
type: "text",
|
|
36703
|
-
text: attrs.anchorData.alignH
|
|
36704
|
-
}
|
|
36705
|
-
]
|
|
36706
|
-
}
|
|
36707
|
-
]
|
|
36708
|
-
}
|
|
36709
|
-
});
|
|
36710
|
-
anchorElements.push({
|
|
36711
|
-
name: "wp:positionV",
|
|
36712
|
-
attributes: {
|
|
36713
|
-
relativeFrom: attrs.anchorData.vRelativeFrom
|
|
36714
|
-
},
|
|
36715
|
-
...attrs.marginOffset.top !== void 0 && {
|
|
36716
|
-
elements: [
|
|
36717
|
-
{
|
|
36718
|
-
name: "wp:posOffset",
|
|
36719
|
-
elements: [
|
|
36720
|
-
{
|
|
36721
|
-
type: "text",
|
|
36722
|
-
text: pixelsToEmu(attrs.marginOffset.top).toString()
|
|
36723
|
-
}
|
|
36724
|
-
]
|
|
36725
|
-
}
|
|
36726
|
-
]
|
|
36727
|
-
},
|
|
36728
|
-
...attrs.anchorData.alignV && {
|
|
36729
|
-
elements: [
|
|
36730
|
-
{
|
|
36731
|
-
name: "wp:align",
|
|
36732
|
-
elements: [
|
|
36733
|
-
{
|
|
36734
|
-
type: "text",
|
|
36735
|
-
text: attrs.anchorData.alignV
|
|
36736
|
-
}
|
|
36737
|
-
]
|
|
36738
|
-
}
|
|
36739
|
-
]
|
|
36740
|
-
}
|
|
36741
|
-
});
|
|
36742
|
-
}
|
|
36743
|
-
if (attrs.wrapText) {
|
|
36744
|
-
wrapProp.push({
|
|
36745
|
-
name: "wp:wrapSquare",
|
|
36746
|
-
attributes: {
|
|
36747
|
-
wrapText: attrs.wrapText
|
|
36748
|
-
}
|
|
36749
|
-
});
|
|
36750
|
-
}
|
|
36751
|
-
if (attrs.wrapTopAndBottom) {
|
|
36752
|
-
wrapProp.push({
|
|
36753
|
-
name: "wp:wrapTopAndBottom"
|
|
36754
|
-
});
|
|
36755
|
-
}
|
|
36756
|
-
if (attrs.isAnchor && !wrapProp.length) {
|
|
36757
|
-
wrapProp.push({
|
|
36758
|
-
name: "wp:wrapNone"
|
|
36759
|
-
});
|
|
36760
|
-
}
|
|
36761
|
-
}
|
|
36762
|
-
const drawingXmlns = "http://schemas.openxmlformats.org/drawingml/2006/main";
|
|
36763
|
-
const pictureXmlns = "http://schemas.openxmlformats.org/drawingml/2006/picture";
|
|
36764
|
-
const textNode = wrapTextInRun(
|
|
36765
|
-
{
|
|
36766
|
-
name: "w:drawing",
|
|
36767
|
-
elements: [
|
|
36768
|
-
{
|
|
36769
|
-
name: attrs.isAnchor ? "wp:anchor" : "wp:inline",
|
|
36770
|
-
attributes: inlineAttrs,
|
|
36771
|
-
elements: [
|
|
36772
|
-
...anchorElements,
|
|
36773
|
-
{
|
|
36774
|
-
name: "wp:extent",
|
|
36775
|
-
attributes: {
|
|
36776
|
-
cx: size2.w,
|
|
36777
|
-
cy: size2.h
|
|
36778
|
-
}
|
|
36779
|
-
},
|
|
36780
|
-
{
|
|
36781
|
-
name: "wp:effectExtent",
|
|
36782
|
-
attributes: {
|
|
36783
|
-
l: 0,
|
|
36784
|
-
t: 0,
|
|
36785
|
-
r: 0,
|
|
36786
|
-
b: 0
|
|
36787
|
-
}
|
|
36788
|
-
},
|
|
36789
|
-
...wrapProp,
|
|
36790
|
-
{
|
|
36791
|
-
name: "wp:docPr",
|
|
36792
|
-
attributes: {
|
|
36793
|
-
id: attrs.id || 0,
|
|
36794
|
-
name: attrs.alt || `Picture ${imageName}`
|
|
36795
|
-
}
|
|
36796
|
-
},
|
|
36797
|
-
{
|
|
36798
|
-
name: "wp:cNvGraphicFramePr",
|
|
36799
|
-
elements: [
|
|
36800
|
-
{
|
|
36801
|
-
name: "a:graphicFrameLocks",
|
|
36802
|
-
attributes: {
|
|
36803
|
-
"xmlns:a": drawingXmlns,
|
|
36804
|
-
noChangeAspect: 1
|
|
36805
|
-
}
|
|
36806
|
-
}
|
|
36807
|
-
]
|
|
36808
|
-
},
|
|
36809
|
-
{
|
|
36810
|
-
name: "a:graphic",
|
|
36811
|
-
attributes: { "xmlns:a": drawingXmlns },
|
|
36812
|
-
elements: [
|
|
36813
|
-
{
|
|
36814
|
-
name: "a:graphicData",
|
|
36815
|
-
attributes: { uri: pictureXmlns },
|
|
36816
|
-
elements: [
|
|
36817
|
-
{
|
|
36818
|
-
name: "pic:pic",
|
|
36819
|
-
attributes: { "xmlns:pic": pictureXmlns },
|
|
36820
|
-
elements: [
|
|
36821
|
-
{
|
|
36822
|
-
name: "pic:nvPicPr",
|
|
36823
|
-
elements: [
|
|
36824
|
-
{
|
|
36825
|
-
name: "pic:cNvPr",
|
|
36826
|
-
attributes: {
|
|
36827
|
-
id: attrs.id || 0,
|
|
36828
|
-
name: attrs.title || `Picture ${imageName}`
|
|
36829
|
-
}
|
|
36830
|
-
},
|
|
36831
|
-
{
|
|
36832
|
-
name: "pic:cNvPicPr",
|
|
36833
|
-
elements: [
|
|
36834
|
-
{
|
|
36835
|
-
name: "a:picLocks",
|
|
36836
|
-
attributes: {
|
|
36837
|
-
noChangeAspect: 1,
|
|
36838
|
-
noChangeArrowheads: 1
|
|
36839
|
-
}
|
|
36840
|
-
}
|
|
36841
|
-
]
|
|
36842
|
-
}
|
|
36843
|
-
]
|
|
36844
|
-
},
|
|
36845
|
-
{
|
|
36846
|
-
name: "pic:blipFill",
|
|
36847
|
-
elements: [
|
|
36848
|
-
{
|
|
36849
|
-
name: "a:blip",
|
|
36850
|
-
attributes: {
|
|
36851
|
-
"r:embed": imageId
|
|
36852
|
-
}
|
|
36853
|
-
},
|
|
36854
|
-
{
|
|
36855
|
-
name: "a:stretch",
|
|
36856
|
-
elements: [{ name: "a:fillRect" }]
|
|
36857
|
-
}
|
|
36858
|
-
]
|
|
36859
|
-
},
|
|
36860
|
-
{
|
|
36861
|
-
name: "pic:spPr",
|
|
36862
|
-
attributes: {
|
|
36863
|
-
bwMode: "auto"
|
|
36864
|
-
},
|
|
36865
|
-
elements: [
|
|
36866
|
-
{
|
|
36867
|
-
name: "a:xfrm",
|
|
36868
|
-
elements: [
|
|
36869
|
-
{
|
|
36870
|
-
name: "a:ext",
|
|
36871
|
-
attributes: {
|
|
36872
|
-
cx: size2.w,
|
|
36873
|
-
cy: size2.h
|
|
36874
|
-
}
|
|
36875
|
-
},
|
|
36876
|
-
{
|
|
36877
|
-
name: "a:off",
|
|
36878
|
-
attributes: {
|
|
36879
|
-
x: 0,
|
|
36880
|
-
y: 0
|
|
36881
|
-
}
|
|
36882
|
-
}
|
|
36883
|
-
]
|
|
36884
|
-
},
|
|
36885
|
-
{
|
|
36886
|
-
name: "a:prstGeom",
|
|
36887
|
-
attributes: { prst: "rect" },
|
|
36888
|
-
elements: [{ name: "a:avLst" }]
|
|
36889
|
-
},
|
|
36890
|
-
{
|
|
36891
|
-
name: "a:noFill"
|
|
36892
|
-
}
|
|
36893
|
-
]
|
|
36894
|
-
}
|
|
36895
|
-
]
|
|
36896
|
-
}
|
|
36897
|
-
]
|
|
36898
|
-
}
|
|
36899
|
-
]
|
|
36900
|
-
}
|
|
36901
|
-
]
|
|
36902
|
-
}
|
|
36903
|
-
]
|
|
36904
|
-
},
|
|
36905
|
-
[]
|
|
36906
|
-
);
|
|
36907
|
-
return textNode;
|
|
36908
|
-
}
|
|
36909
37182
|
function translateShapeContainer(params2) {
|
|
36910
37183
|
const { node } = params2;
|
|
36911
37184
|
const elements = translateChildNodes(params2);
|
|
@@ -37083,14 +37356,6 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
37083
37356
|
if (!selfClosing) tags.push(`</${name}>`);
|
|
37084
37357
|
return tags;
|
|
37085
37358
|
};
|
|
37086
|
-
function resizeKeepAspectRatio(width, height, maxWidth) {
|
|
37087
|
-
if (width > maxWidth) {
|
|
37088
|
-
let scale = maxWidth / width;
|
|
37089
|
-
let newHeight = Math.round(height * scale);
|
|
37090
|
-
return { width: maxWidth, height: newHeight };
|
|
37091
|
-
}
|
|
37092
|
-
return { width, height };
|
|
37093
|
-
}
|
|
37094
37359
|
const translatePageNumberNode = (params2) => {
|
|
37095
37360
|
const outputMarks = processOutputMarks(params2.node.attrs?.marksAsAttrs || []);
|
|
37096
37361
|
return getAutoPageJson("PAGE", outputMarks);
|
|
@@ -37174,7 +37439,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
37174
37439
|
return parsedDocx["word/document.xml"] || parseXmlToJson(fallbackXml);
|
|
37175
37440
|
};
|
|
37176
37441
|
const handleDrawingNode = (params2) => {
|
|
37177
|
-
const { nodes
|
|
37442
|
+
const { nodes } = params2;
|
|
37178
37443
|
const validNodes = ["w:drawing", "w:p"];
|
|
37179
37444
|
if (nodes.length === 0 || !validNodes.includes(nodes[0].name)) {
|
|
37180
37445
|
return { nodes: [], consumed: 0 };
|
|
@@ -37184,167 +37449,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
37184
37449
|
if (mainNode.name === "w:drawing") node = mainNode;
|
|
37185
37450
|
else node = mainNode.elements.find((el) => el.name === "w:drawing");
|
|
37186
37451
|
if (!node) return { nodes: [], consumed: 0 };
|
|
37187
|
-
|
|
37188
|
-
const
|
|
37189
|
-
|
|
37190
|
-
const isAnchor = elements.find((el) => el.name === "wp:anchor");
|
|
37191
|
-
if (isAnchor) {
|
|
37192
|
-
result = handleImageImport(elements[0], currentFileName, params2);
|
|
37193
|
-
if (result && result.attrs) result.attrs.isAnchor = isAnchor;
|
|
37194
|
-
}
|
|
37195
|
-
const inlineImage = elements.find((el) => el.name === "wp:inline");
|
|
37196
|
-
if (inlineImage) result = handleImageImport(inlineImage, currentFileName, params2);
|
|
37197
|
-
return { nodes: result ? [result] : [], consumed: 1 };
|
|
37198
|
-
};
|
|
37199
|
-
function handleImageImport(node, currentFileName, params2) {
|
|
37200
|
-
const { docx } = params2;
|
|
37201
|
-
const { attributes } = node;
|
|
37202
|
-
const padding = {
|
|
37203
|
-
top: emuToPixels(attributes["distT"]),
|
|
37204
|
-
bottom: emuToPixels(attributes["distB"]),
|
|
37205
|
-
left: emuToPixels(attributes["distL"]),
|
|
37206
|
-
right: emuToPixels(attributes["distR"])
|
|
37207
|
-
};
|
|
37208
|
-
const extent = node.elements.find((el) => el.name === "wp:extent");
|
|
37209
|
-
const size2 = {
|
|
37210
|
-
width: emuToPixels(extent.attributes?.cx),
|
|
37211
|
-
height: emuToPixels(extent.attributes?.cy)
|
|
37212
|
-
};
|
|
37213
|
-
const graphic = node.elements.find((el) => el.name === "a:graphic");
|
|
37214
|
-
const graphicData = graphic.elements.find((el) => el.name === "a:graphicData");
|
|
37215
|
-
const { uri: uri2 } = graphicData?.attributes || {};
|
|
37216
|
-
const shapeURI = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape";
|
|
37217
|
-
if (!!uri2 && uri2 === shapeURI) {
|
|
37218
|
-
return handleShapeDrawing(params2, node, graphicData);
|
|
37219
|
-
}
|
|
37220
|
-
const picture = graphicData.elements.find((el) => el.name === "pic:pic");
|
|
37221
|
-
if (!picture || !picture.elements) return null;
|
|
37222
|
-
const blipFill = picture.elements.find((el) => el.name === "pic:blipFill");
|
|
37223
|
-
const blip = blipFill.elements.find((el) => el.name === "a:blip");
|
|
37224
|
-
const positionHTag = node.elements.find((el) => el.name === "wp:positionH");
|
|
37225
|
-
const positionH = positionHTag?.elements.find((el) => el.name === "wp:posOffset");
|
|
37226
|
-
const positionHValue = emuToPixels(positionH?.elements[0]?.text);
|
|
37227
|
-
const hRelativeFrom = positionHTag?.attributes.relativeFrom;
|
|
37228
|
-
const alignH = positionHTag?.elements.find((el) => el.name === "wp:align")?.elements[0]?.text;
|
|
37229
|
-
const positionVTag = node.elements.find((el) => el.name === "wp:positionV");
|
|
37230
|
-
const positionV = positionVTag?.elements?.find((el) => el.name === "wp:posOffset");
|
|
37231
|
-
const positionVValue = emuToPixels(positionV?.elements[0]?.text);
|
|
37232
|
-
const vRelativeFrom = positionVTag?.attributes.relativeFrom;
|
|
37233
|
-
const alignV = positionVTag?.elements?.find((el) => el.name === "wp:align")?.elements[0]?.text;
|
|
37234
|
-
const simplePos = node.elements.find((el) => el.name === "wp:simplePos");
|
|
37235
|
-
const wrapSquare = node.elements.find((el) => el.name === "wp:wrapSquare");
|
|
37236
|
-
const wrapTopAndBottom = node.elements.find((el) => el.name === "wp:wrapTopAndBottom");
|
|
37237
|
-
const docPr = node.elements.find((el) => el.name === "wp:docPr");
|
|
37238
|
-
let anchorData = null;
|
|
37239
|
-
if (hRelativeFrom || alignH || vRelativeFrom || alignV) {
|
|
37240
|
-
anchorData = {
|
|
37241
|
-
hRelativeFrom,
|
|
37242
|
-
vRelativeFrom,
|
|
37243
|
-
alignH,
|
|
37244
|
-
alignV
|
|
37245
|
-
};
|
|
37246
|
-
}
|
|
37247
|
-
const marginOffset = {
|
|
37248
|
-
left: positionHValue,
|
|
37249
|
-
top: positionVValue
|
|
37250
|
-
};
|
|
37251
|
-
const { attributes: blipAttributes = {} } = blip;
|
|
37252
|
-
const rEmbed = blipAttributes["r:embed"];
|
|
37253
|
-
if (!rEmbed) return null;
|
|
37254
|
-
const currentFile = currentFileName || "document.xml";
|
|
37255
|
-
let rels = docx[`word/_rels/${currentFile}.rels`];
|
|
37256
|
-
if (!rels) rels = docx[`word/_rels/document.xml.rels`];
|
|
37257
|
-
const relationships = rels.elements.find((el) => el.name === "Relationships");
|
|
37258
|
-
const { elements } = relationships;
|
|
37259
|
-
const rel = elements.find((el) => el.attributes["Id"] === rEmbed);
|
|
37260
|
-
if (!rel) return null;
|
|
37261
|
-
const { attributes: relAttributes } = rel;
|
|
37262
|
-
const targetPath = relAttributes["Target"];
|
|
37263
|
-
let path = `word/${targetPath}`;
|
|
37264
|
-
if (targetPath.startsWith("/word") || targetPath.startsWith("/media")) path = targetPath.substring(1);
|
|
37265
|
-
const extension = targetPath.substring(targetPath.lastIndexOf(".") + 1);
|
|
37266
|
-
return {
|
|
37267
|
-
type: "image",
|
|
37268
|
-
attrs: {
|
|
37269
|
-
src: path,
|
|
37270
|
-
alt: ["emf", "wmf"].includes(extension) ? "Unable to render EMF/WMF image" : docPr?.attributes.name || "Image",
|
|
37271
|
-
extension,
|
|
37272
|
-
id: docPr?.attributes.id || "",
|
|
37273
|
-
title: docPr?.attributes.descr || "Image",
|
|
37274
|
-
inline: true,
|
|
37275
|
-
padding,
|
|
37276
|
-
marginOffset,
|
|
37277
|
-
size: size2,
|
|
37278
|
-
anchorData,
|
|
37279
|
-
...simplePos && {
|
|
37280
|
-
simplePos: {
|
|
37281
|
-
x: simplePos.attributes.x,
|
|
37282
|
-
y: simplePos.attributes.y
|
|
37283
|
-
}
|
|
37284
|
-
},
|
|
37285
|
-
...wrapSquare && {
|
|
37286
|
-
wrapText: wrapSquare.attributes.wrapText
|
|
37287
|
-
},
|
|
37288
|
-
wrapTopAndBottom: !!wrapTopAndBottom,
|
|
37289
|
-
originalPadding: {
|
|
37290
|
-
distT: attributes["distT"],
|
|
37291
|
-
distB: attributes["distB"],
|
|
37292
|
-
distL: attributes["distL"],
|
|
37293
|
-
distR: attributes["distR"]
|
|
37294
|
-
},
|
|
37295
|
-
originalAttributes: node.attributes,
|
|
37296
|
-
rId: relAttributes["Id"]
|
|
37297
|
-
}
|
|
37298
|
-
};
|
|
37299
|
-
}
|
|
37300
|
-
const handleShapeDrawing = (params2, node, graphicData) => {
|
|
37301
|
-
const wsp = graphicData.elements.find((el) => el.name === "wps:wsp");
|
|
37302
|
-
const textBox = wsp.elements.find((el) => el.name === "wps:txbx");
|
|
37303
|
-
const textBoxContent = textBox?.elements?.find((el) => el.name === "w:txbxContent");
|
|
37304
|
-
node.elements.find((el) => el.name === "wp:docPr");
|
|
37305
|
-
const spPr = wsp.elements.find((el) => el.name === "wps:spPr");
|
|
37306
|
-
const prstGeom = spPr?.elements.find((el) => el.name === "a:prstGeom");
|
|
37307
|
-
if (!!prstGeom && prstGeom.attributes["prst"] === "rect" && !textBoxContent) {
|
|
37308
|
-
return getRectangleShape(params2, spPr);
|
|
37309
|
-
}
|
|
37310
|
-
if (!textBoxContent) {
|
|
37311
|
-
return null;
|
|
37312
|
-
}
|
|
37313
|
-
const { nodeListHandler } = params2;
|
|
37314
|
-
const translatedElement = nodeListHandler.handler({
|
|
37315
|
-
...params2,
|
|
37316
|
-
node: textBoxContent.elements[0],
|
|
37317
|
-
nodes: textBoxContent.elements,
|
|
37318
|
-
path: [...params2.path || [], textBoxContent]
|
|
37319
|
-
});
|
|
37320
|
-
return translatedElement[0];
|
|
37321
|
-
};
|
|
37322
|
-
const getRectangleShape = (params2, node) => {
|
|
37323
|
-
const schemaAttrs = {};
|
|
37324
|
-
const [drawingNode] = params2.nodes;
|
|
37325
|
-
if (drawingNode?.name === "w:drawing") {
|
|
37326
|
-
schemaAttrs.drawingContent = drawingNode;
|
|
37327
|
-
}
|
|
37328
|
-
const xfrm = node.elements.find((el) => el.name === "a:xfrm");
|
|
37329
|
-
const start2 = xfrm.elements.find((el) => el.name === "a:off");
|
|
37330
|
-
const size2 = xfrm.elements.find((el) => el.name === "a:ext");
|
|
37331
|
-
const solidFill = node.elements.find((el) => el.name === "a:solidFill");
|
|
37332
|
-
node.elements.find((el) => el.name === "a:ln");
|
|
37333
|
-
const rectangleSize = {
|
|
37334
|
-
top: emuToPixels(start2.attributes["y"]),
|
|
37335
|
-
left: emuToPixels(start2.attributes["x"]),
|
|
37336
|
-
width: emuToPixels(size2.attributes["cx"]),
|
|
37337
|
-
height: emuToPixels(size2.attributes["cy"])
|
|
37338
|
-
};
|
|
37339
|
-
schemaAttrs.size = rectangleSize;
|
|
37340
|
-
const background = solidFill?.elements[0]?.attributes["val"];
|
|
37341
|
-
if (background) {
|
|
37342
|
-
schemaAttrs.background = "#" + background;
|
|
37343
|
-
}
|
|
37344
|
-
return {
|
|
37345
|
-
type: "contentBlock",
|
|
37346
|
-
attrs: schemaAttrs
|
|
37347
|
-
};
|
|
37452
|
+
const schemaNode = translator$1.encode(params2);
|
|
37453
|
+
const newNodes = schemaNode ? [schemaNode] : [];
|
|
37454
|
+
return { nodes: newNodes, consumed: 1 };
|
|
37348
37455
|
};
|
|
37349
37456
|
const drawingNodeHandlerEntity = {
|
|
37350
37457
|
handlerName: "drawingNodeHandler",
|
|
@@ -37444,7 +37551,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
37444
37551
|
handlerName: "trackChangeNodeHandler",
|
|
37445
37552
|
handler: handleTrackChangeNode
|
|
37446
37553
|
};
|
|
37447
|
-
const hyperlinkNodeHandlerEntity = generateV2HandlerEntity("hyperlinkNodeHandler", translator$
|
|
37554
|
+
const hyperlinkNodeHandlerEntity = generateV2HandlerEntity("hyperlinkNodeHandler", translator$4);
|
|
37448
37555
|
const handleRunNode = (params2) => {
|
|
37449
37556
|
const { nodes, nodeListHandler, parentStyleId, docx } = params2;
|
|
37450
37557
|
if (nodes.length === 0 || nodes[0].name !== "w:r") {
|
|
@@ -37556,7 +37663,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
37556
37663
|
if (nodes.length === 0 || nodes[0].name !== "w:p") {
|
|
37557
37664
|
return { nodes: [], consumed: 0 };
|
|
37558
37665
|
}
|
|
37559
|
-
const schemaNode = translator$
|
|
37666
|
+
const schemaNode = translator$k.encode(params2);
|
|
37560
37667
|
const newNodes = schemaNode ? [schemaNode] : [];
|
|
37561
37668
|
return { nodes: newNodes, consumed: 1 };
|
|
37562
37669
|
};
|
|
@@ -37659,7 +37766,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
37659
37766
|
if (nodes.length === 0 || nodes[0].name !== "w:br") {
|
|
37660
37767
|
return { nodes: [], consumed: 0 };
|
|
37661
37768
|
}
|
|
37662
|
-
const result = translator$
|
|
37769
|
+
const result = translator$m.encode(params2);
|
|
37663
37770
|
if (!result) return { nodes: [], consumed: 0 };
|
|
37664
37771
|
return {
|
|
37665
37772
|
nodes: [result],
|
|
@@ -38328,7 +38435,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
38328
38435
|
if (!nodes.length || nodes[0].name !== "w:tab") {
|
|
38329
38436
|
return { nodes: [], consumed: 0 };
|
|
38330
38437
|
}
|
|
38331
|
-
const node = translator$
|
|
38438
|
+
const node = translator$l.encode(params2);
|
|
38332
38439
|
return { nodes: [node], consumed: 1 };
|
|
38333
38440
|
};
|
|
38334
38441
|
const tabNodeEntityHandler = {
|
|
@@ -67170,69 +67277,353 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
67170
67277
|
};
|
|
67171
67278
|
}
|
|
67172
67279
|
});
|
|
67280
|
+
class StructuredContentViewBase {
|
|
67281
|
+
constructor(props) {
|
|
67282
|
+
__publicField$1(this, "node");
|
|
67283
|
+
__publicField$1(this, "view");
|
|
67284
|
+
__publicField$1(this, "getPos");
|
|
67285
|
+
__publicField$1(this, "decorations");
|
|
67286
|
+
__publicField$1(this, "innerDecorations");
|
|
67287
|
+
__publicField$1(this, "editor");
|
|
67288
|
+
__publicField$1(this, "extension");
|
|
67289
|
+
__publicField$1(this, "htmlAttributes");
|
|
67290
|
+
__publicField$1(this, "root");
|
|
67291
|
+
__publicField$1(this, "isDragging", false);
|
|
67292
|
+
this.node = props.node;
|
|
67293
|
+
this.view = props.editor.view;
|
|
67294
|
+
this.getPos = props.getPos;
|
|
67295
|
+
this.decorations = props.decorations;
|
|
67296
|
+
this.innerDecorations = props.innerDecorations;
|
|
67297
|
+
this.editor = props.editor;
|
|
67298
|
+
this.extension = props.extension;
|
|
67299
|
+
this.htmlAttributes = props.htmlAttributes;
|
|
67300
|
+
this.mount(props);
|
|
67301
|
+
}
|
|
67302
|
+
mount(props) {
|
|
67303
|
+
return;
|
|
67304
|
+
}
|
|
67305
|
+
get dom() {
|
|
67306
|
+
return this.root;
|
|
67307
|
+
}
|
|
67308
|
+
get contentDOM() {
|
|
67309
|
+
return null;
|
|
67310
|
+
}
|
|
67311
|
+
update(node, decorations, innerDecorations) {
|
|
67312
|
+
if (node.type !== this.node.type) {
|
|
67313
|
+
return false;
|
|
67314
|
+
}
|
|
67315
|
+
this.node = node;
|
|
67316
|
+
this.decorations = decorations;
|
|
67317
|
+
this.innerDecorations = innerDecorations;
|
|
67318
|
+
this.updateHTMLAttributes();
|
|
67319
|
+
return true;
|
|
67320
|
+
}
|
|
67321
|
+
stopEvent(event) {
|
|
67322
|
+
if (!this.dom) return false;
|
|
67323
|
+
const target = event.target;
|
|
67324
|
+
const isInElement = this.dom.contains(target) && !this.contentDOM?.contains(target);
|
|
67325
|
+
if (!isInElement) return false;
|
|
67326
|
+
const isDragEvent = event.type.startsWith("drag");
|
|
67327
|
+
const isDropEvent = event.type === "drop";
|
|
67328
|
+
const isInput = ["INPUT", "BUTTON", "SELECT", "TEXTAREA"].includes(target.tagName) || target.isContentEditable;
|
|
67329
|
+
if (isInput && !isDropEvent && !isDragEvent) return true;
|
|
67330
|
+
const { isEditable } = this.editor;
|
|
67331
|
+
const { isDragging } = this;
|
|
67332
|
+
const isDraggable = !!this.node.type.spec.draggable;
|
|
67333
|
+
const isSelectable = NodeSelection.isSelectable(this.node);
|
|
67334
|
+
const isCopyEvent = event.type === "copy";
|
|
67335
|
+
const isPasteEvent = event.type === "paste";
|
|
67336
|
+
const isCutEvent = event.type === "cut";
|
|
67337
|
+
const isClickEvent = event.type === "mousedown";
|
|
67338
|
+
if (!isDraggable && isSelectable && isDragEvent && event.target === this.dom) {
|
|
67339
|
+
event.preventDefault();
|
|
67340
|
+
}
|
|
67341
|
+
if (isDraggable && isDragEvent && !isDragging && event.target === this.dom) {
|
|
67342
|
+
event.preventDefault();
|
|
67343
|
+
return false;
|
|
67344
|
+
}
|
|
67345
|
+
if (isDraggable && isEditable && !isDragging && isClickEvent) {
|
|
67346
|
+
const dragHandle = target.closest("[data-drag-handle]");
|
|
67347
|
+
const isValidDragHandle = dragHandle && (this.dom === dragHandle || this.dom.contains(dragHandle));
|
|
67348
|
+
if (isValidDragHandle) {
|
|
67349
|
+
this.isDragging = true;
|
|
67350
|
+
document.addEventListener(
|
|
67351
|
+
"dragend",
|
|
67352
|
+
() => {
|
|
67353
|
+
this.isDragging = false;
|
|
67354
|
+
},
|
|
67355
|
+
{ once: true }
|
|
67356
|
+
);
|
|
67357
|
+
document.addEventListener(
|
|
67358
|
+
"drop",
|
|
67359
|
+
() => {
|
|
67360
|
+
this.isDragging = false;
|
|
67361
|
+
},
|
|
67362
|
+
{ once: true }
|
|
67363
|
+
);
|
|
67364
|
+
document.addEventListener(
|
|
67365
|
+
"mouseup",
|
|
67366
|
+
() => {
|
|
67367
|
+
this.isDragging = false;
|
|
67368
|
+
},
|
|
67369
|
+
{ once: true }
|
|
67370
|
+
);
|
|
67371
|
+
}
|
|
67372
|
+
}
|
|
67373
|
+
if (isDragging || isDropEvent || isCopyEvent || isPasteEvent || isCutEvent || isClickEvent && isSelectable) {
|
|
67374
|
+
return false;
|
|
67375
|
+
}
|
|
67376
|
+
return true;
|
|
67377
|
+
}
|
|
67378
|
+
ignoreMutation(mutation) {
|
|
67379
|
+
if (!this.dom || !this.contentDOM) return true;
|
|
67380
|
+
if (this.node.isLeaf || this.node.isAtom) return true;
|
|
67381
|
+
if (mutation.type === "selection") return false;
|
|
67382
|
+
if (this.contentDOM === mutation.target && mutation.type === "attributes") return true;
|
|
67383
|
+
if (this.contentDOM.contains(mutation.target)) return false;
|
|
67384
|
+
return true;
|
|
67385
|
+
}
|
|
67386
|
+
destroy() {
|
|
67387
|
+
this.dom.remove();
|
|
67388
|
+
this.contentDOM?.remove();
|
|
67389
|
+
}
|
|
67390
|
+
updateAttributes(attrs) {
|
|
67391
|
+
const pos = this.getPos();
|
|
67392
|
+
if (typeof pos !== "number") {
|
|
67393
|
+
return;
|
|
67394
|
+
}
|
|
67395
|
+
return this.view.dispatch(
|
|
67396
|
+
this.view.state.tr.setNodeMarkup(pos, void 0, {
|
|
67397
|
+
...this.node.attrs,
|
|
67398
|
+
...attrs
|
|
67399
|
+
})
|
|
67400
|
+
);
|
|
67401
|
+
}
|
|
67402
|
+
updateHTMLAttributes() {
|
|
67403
|
+
const { extensionService } = this.editor;
|
|
67404
|
+
const { attributes } = extensionService;
|
|
67405
|
+
const extensionAttrs = attributes.filter((i2) => i2.type === this.node.type.name);
|
|
67406
|
+
this.htmlAttributes = Attribute.getAttributesToRender(this.node, extensionAttrs);
|
|
67407
|
+
}
|
|
67408
|
+
createDragHandle() {
|
|
67409
|
+
const dragHandle = document.createElement("span");
|
|
67410
|
+
dragHandle.classList.add("sd-structured-content-draggable");
|
|
67411
|
+
dragHandle.draggable = true;
|
|
67412
|
+
dragHandle.contentEditable = "false";
|
|
67413
|
+
dragHandle.dataset.dragHandle = "";
|
|
67414
|
+
const textElement = document.createElement("span");
|
|
67415
|
+
textElement.textContent = "Structured content";
|
|
67416
|
+
dragHandle.append(textElement);
|
|
67417
|
+
return dragHandle;
|
|
67418
|
+
}
|
|
67419
|
+
onDragStart(event) {
|
|
67420
|
+
const { view } = this.editor;
|
|
67421
|
+
const target = event.target;
|
|
67422
|
+
const dragHandle = target.nodeType === 3 ? target.parentElement?.closest("[data-drag-handle]") : target.closest("[data-drag-handle]");
|
|
67423
|
+
if (!this.dom || this.contentDOM?.contains(target) || !dragHandle) {
|
|
67424
|
+
return;
|
|
67425
|
+
}
|
|
67426
|
+
let x = 0;
|
|
67427
|
+
let y2 = 0;
|
|
67428
|
+
if (this.dom !== dragHandle) {
|
|
67429
|
+
const domBox = this.dom.getBoundingClientRect();
|
|
67430
|
+
const handleBox = dragHandle.getBoundingClientRect();
|
|
67431
|
+
const offsetX = event.offsetX ?? event.nativeEvent?.offsetX;
|
|
67432
|
+
const offsetY = event.offsetY ?? event.nativeEvent?.offsetY;
|
|
67433
|
+
x = handleBox.x - domBox.x + offsetX;
|
|
67434
|
+
y2 = handleBox.y - domBox.y + offsetY;
|
|
67435
|
+
}
|
|
67436
|
+
event.dataTransfer?.setDragImage(this.dom, x, y2);
|
|
67437
|
+
const pos = this.getPos();
|
|
67438
|
+
if (typeof pos !== "number") {
|
|
67439
|
+
return;
|
|
67440
|
+
}
|
|
67441
|
+
const selection = NodeSelection.create(view.state.doc, pos);
|
|
67442
|
+
const transaction = view.state.tr.setSelection(selection);
|
|
67443
|
+
view.dispatch(transaction);
|
|
67444
|
+
}
|
|
67445
|
+
}
|
|
67446
|
+
class StructuredContentInlineView extends StructuredContentViewBase {
|
|
67447
|
+
constructor(props) {
|
|
67448
|
+
super(props);
|
|
67449
|
+
}
|
|
67450
|
+
mount() {
|
|
67451
|
+
this.buildView();
|
|
67452
|
+
}
|
|
67453
|
+
get contentDOM() {
|
|
67454
|
+
const contentElement = this.dom?.querySelector(`.${structuredContentInnerClass$1}`);
|
|
67455
|
+
return contentElement || null;
|
|
67456
|
+
}
|
|
67457
|
+
createElement() {
|
|
67458
|
+
const element = document.createElement("span");
|
|
67459
|
+
element.classList.add(structuredContentClass$1);
|
|
67460
|
+
element.setAttribute("data-structured-content", "");
|
|
67461
|
+
const contentElement = document.createElement("span");
|
|
67462
|
+
contentElement.classList.add(structuredContentInnerClass$1);
|
|
67463
|
+
element.append(contentElement);
|
|
67464
|
+
const domAttrs = Attribute.mergeAttributes(this.htmlAttributes);
|
|
67465
|
+
updateDOMAttributes(element, { ...domAttrs });
|
|
67466
|
+
return { element, contentElement };
|
|
67467
|
+
}
|
|
67468
|
+
buildView() {
|
|
67469
|
+
const { element } = this.createElement();
|
|
67470
|
+
const dragHandle = this.createDragHandle();
|
|
67471
|
+
element.prepend(dragHandle);
|
|
67472
|
+
element.addEventListener("dragstart", (e) => this.onDragStart(e));
|
|
67473
|
+
this.root = element;
|
|
67474
|
+
}
|
|
67475
|
+
updateView() {
|
|
67476
|
+
const domAttrs = Attribute.mergeAttributes(this.htmlAttributes);
|
|
67477
|
+
updateDOMAttributes(this.dom, { ...domAttrs });
|
|
67478
|
+
}
|
|
67479
|
+
update(node, decorations, innerDecorations) {
|
|
67480
|
+
const result = super.update(node, decorations, innerDecorations);
|
|
67481
|
+
if (!result) return false;
|
|
67482
|
+
this.updateView();
|
|
67483
|
+
return true;
|
|
67484
|
+
}
|
|
67485
|
+
}
|
|
67486
|
+
const structuredContentClass$1 = "sd-structured-content";
|
|
67487
|
+
const structuredContentInnerClass$1 = "sd-structured-content__content";
|
|
67173
67488
|
const StructuredContent = Node$1.create({
|
|
67174
67489
|
name: "structuredContent",
|
|
67175
|
-
group: "inline",
|
|
67490
|
+
group: "inline structuredContent",
|
|
67176
67491
|
inline: true,
|
|
67177
67492
|
content: "inline*",
|
|
67493
|
+
isolating: true,
|
|
67494
|
+
atom: false,
|
|
67495
|
+
// false - has editable content.
|
|
67496
|
+
draggable: true,
|
|
67178
67497
|
addOptions() {
|
|
67179
67498
|
return {
|
|
67180
|
-
structuredContentClass: "sd-structured-content-tag",
|
|
67181
67499
|
htmlAttributes: {
|
|
67500
|
+
class: structuredContentClass$1,
|
|
67182
67501
|
"aria-label": "Structured content node"
|
|
67183
67502
|
}
|
|
67184
67503
|
};
|
|
67185
67504
|
},
|
|
67186
67505
|
addAttributes() {
|
|
67187
67506
|
return {
|
|
67507
|
+
id: {
|
|
67508
|
+
default: null,
|
|
67509
|
+
parseDOM: (elem) => elem.getAttribute("data-id"),
|
|
67510
|
+
renderDOM: (attrs) => {
|
|
67511
|
+
if (!attrs.id) return {};
|
|
67512
|
+
return { "data-id": attrs.id };
|
|
67513
|
+
}
|
|
67514
|
+
},
|
|
67188
67515
|
sdtPr: {
|
|
67189
67516
|
rendered: false
|
|
67190
67517
|
}
|
|
67191
67518
|
};
|
|
67192
67519
|
},
|
|
67193
67520
|
parseDOM() {
|
|
67194
|
-
return [{ tag:
|
|
67521
|
+
return [{ tag: "span[data-structured-content]" }];
|
|
67195
67522
|
},
|
|
67196
67523
|
renderDOM({ htmlAttributes }) {
|
|
67197
67524
|
return [
|
|
67198
67525
|
"span",
|
|
67199
67526
|
Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes, {
|
|
67200
|
-
|
|
67527
|
+
"data-structured-content": ""
|
|
67201
67528
|
}),
|
|
67202
67529
|
0
|
|
67203
67530
|
];
|
|
67531
|
+
},
|
|
67532
|
+
addNodeView() {
|
|
67533
|
+
return (props) => {
|
|
67534
|
+
return new StructuredContentInlineView({ ...props });
|
|
67535
|
+
};
|
|
67204
67536
|
}
|
|
67205
67537
|
});
|
|
67538
|
+
class StructuredContentBlockView extends StructuredContentViewBase {
|
|
67539
|
+
constructor(props) {
|
|
67540
|
+
super(props);
|
|
67541
|
+
}
|
|
67542
|
+
mount() {
|
|
67543
|
+
this.buildView();
|
|
67544
|
+
}
|
|
67545
|
+
get contentDOM() {
|
|
67546
|
+
const contentElement = this.dom?.querySelector(`.${structuredContentInnerClass}`);
|
|
67547
|
+
return contentElement || null;
|
|
67548
|
+
}
|
|
67549
|
+
createElement() {
|
|
67550
|
+
const element = document.createElement("div");
|
|
67551
|
+
element.classList.add(structuredContentClass);
|
|
67552
|
+
element.setAttribute("data-structured-content-block", "");
|
|
67553
|
+
const contentElement = document.createElement("div");
|
|
67554
|
+
contentElement.classList.add(structuredContentInnerClass);
|
|
67555
|
+
element.append(contentElement);
|
|
67556
|
+
const domAttrs = Attribute.mergeAttributes(this.htmlAttributes);
|
|
67557
|
+
updateDOMAttributes(element, { ...domAttrs });
|
|
67558
|
+
return { element, contentElement };
|
|
67559
|
+
}
|
|
67560
|
+
buildView() {
|
|
67561
|
+
const { element } = this.createElement();
|
|
67562
|
+
const dragHandle = this.createDragHandle();
|
|
67563
|
+
element.prepend(dragHandle);
|
|
67564
|
+
element.addEventListener("dragstart", (e) => this.onDragStart(e));
|
|
67565
|
+
this.root = element;
|
|
67566
|
+
}
|
|
67567
|
+
updateView() {
|
|
67568
|
+
const domAttrs = Attribute.mergeAttributes(this.htmlAttributes);
|
|
67569
|
+
updateDOMAttributes(this.dom, { ...domAttrs });
|
|
67570
|
+
}
|
|
67571
|
+
update(node, decorations, innerDecorations) {
|
|
67572
|
+
const result = super.update(node, decorations, innerDecorations);
|
|
67573
|
+
if (!result) return false;
|
|
67574
|
+
this.updateView();
|
|
67575
|
+
return true;
|
|
67576
|
+
}
|
|
67577
|
+
}
|
|
67578
|
+
const structuredContentClass = "sd-structured-content-block";
|
|
67579
|
+
const structuredContentInnerClass = "sd-structured-content-block__content";
|
|
67206
67580
|
const StructuredContentBlock = Node$1.create({
|
|
67207
67581
|
name: "structuredContentBlock",
|
|
67208
|
-
group: "block",
|
|
67582
|
+
group: "block structuredContent",
|
|
67209
67583
|
content: "block*",
|
|
67584
|
+
isolating: true,
|
|
67585
|
+
atom: false,
|
|
67586
|
+
// false - has editable content.
|
|
67587
|
+
draggable: true,
|
|
67210
67588
|
addOptions() {
|
|
67211
67589
|
return {
|
|
67212
|
-
structuredContentClass: "sd-structured-content-block-tag",
|
|
67213
67590
|
htmlAttributes: {
|
|
67591
|
+
class: structuredContentClass,
|
|
67214
67592
|
"aria-label": "Structured content block node"
|
|
67215
67593
|
}
|
|
67216
67594
|
};
|
|
67217
67595
|
},
|
|
67218
67596
|
addAttributes() {
|
|
67219
67597
|
return {
|
|
67598
|
+
id: {
|
|
67599
|
+
default: null,
|
|
67600
|
+
parseDOM: (elem) => elem.getAttribute("data-id"),
|
|
67601
|
+
renderDOM: (attrs) => {
|
|
67602
|
+
if (!attrs.id) return {};
|
|
67603
|
+
return { "data-id": attrs.id };
|
|
67604
|
+
}
|
|
67605
|
+
},
|
|
67220
67606
|
sdtPr: {
|
|
67221
67607
|
rendered: false
|
|
67222
67608
|
}
|
|
67223
67609
|
};
|
|
67224
67610
|
},
|
|
67225
67611
|
parseDOM() {
|
|
67226
|
-
return [{ tag:
|
|
67612
|
+
return [{ tag: "div[data-structured-content-block]" }];
|
|
67227
67613
|
},
|
|
67228
67614
|
renderDOM({ htmlAttributes }) {
|
|
67229
67615
|
return [
|
|
67230
67616
|
"div",
|
|
67231
67617
|
Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes, {
|
|
67232
|
-
|
|
67618
|
+
"data-structured-content-block": ""
|
|
67233
67619
|
}),
|
|
67234
67620
|
0
|
|
67235
67621
|
];
|
|
67622
|
+
},
|
|
67623
|
+
addNodeView() {
|
|
67624
|
+
return (props) => {
|
|
67625
|
+
return new StructuredContentBlockView({ ...props });
|
|
67626
|
+
};
|
|
67236
67627
|
}
|
|
67237
67628
|
});
|
|
67238
67629
|
class DocumentSectionView {
|
|
@@ -89634,11 +90025,6 @@ ${style2}
|
|
|
89634
90025
|
}
|
|
89635
90026
|
};
|
|
89636
90027
|
const SuperInput = /* @__PURE__ */ _export_sfc$1(_sfc_main$i, [["__scopeId", "data-v-4d5cff52"]]);
|
|
89637
|
-
const registeredHandlers = Object.freeze({
|
|
89638
|
-
"w:br": translator$j,
|
|
89639
|
-
"w:tab": translator$i,
|
|
89640
|
-
"w:p": translator$h
|
|
89641
|
-
});
|
|
89642
90028
|
const Extensions = {
|
|
89643
90029
|
Node: Node$1,
|
|
89644
90030
|
Attribute,
|