@harbour-enterprises/superdoc 0.20.2 → 0.21.0-RC1
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-BhwyCIho.cjs → PdfViewer-BdrjIRpr.cjs} +1 -1
- package/dist/chunks/{PdfViewer-BceCsygM.es.js → PdfViewer-DK1etjvu.es.js} +1 -1
- package/dist/chunks/{index-B6tAKGVb.cjs → index-C_zTr1ZR.cjs} +14 -33
- package/dist/chunks/{index-C0kV6dM8.es.js → index-ucP9WQ5I.es.js} +14 -33
- package/dist/chunks/{super-editor.es-BollA_Sr.es.js → super-editor.es-KKA9G1l1.es.js} +1851 -434
- package/dist/chunks/{super-editor.es-Dzt_HBkR.cjs → super-editor.es-XC168Mlw.cjs} +1851 -434
- package/dist/core/SuperDoc.d.ts.map +1 -1
- package/dist/stores/comments-store.d.ts.map +1 -1
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-DyzbfydS.js → converter-B61ZUb-V.js} +1405 -339
- package/dist/super-editor/chunks/{docx-zipper-Bk9SAmal.js → docx-zipper-B8nhsVFW.js} +2 -2
- package/dist/super-editor/chunks/{editor-BWE7oMgS.js → editor-CQ0o4v54.js} +420 -65
- package/dist/super-editor/chunks/{toolbar-BmHEsvA1.js → toolbar-DWzoslZk.js} +11 -21
- 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/commands/index.d.ts +1 -0
- package/dist/super-editor/src/core/commands/toggleMarkCascade.d.ts +41 -0
- package/dist/super-editor/src/core/super-converter/SuperConverter.d.ts +5 -0
- package/dist/super-editor/src/core/super-converter/helpers.d.ts +2 -0
- package/dist/super-editor/src/core/super-converter/v2/importer/markImporter.d.ts +12 -0
- package/dist/super-editor/src/core/super-converter/v2/importer/runNodeImporter.d.ts +6 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/index.d.ts +20 -4
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/b/attributes/index.d.ts +3 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/b/attributes/w-val.d.ts +4 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/b/b-translator.d.ts +7 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/b/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/color/attributes/index.d.ts +2 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/color/attributes/w-theme-color.d.ts +4 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/color/attributes/w-theme-shade.d.ts +4 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/color/attributes/w-theme-tint.d.ts +4 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/color/attributes/w-val.d.ts +4 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/color/color-translator.d.ts +7 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/highlight/attributes/index.d.ts +2 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/highlight/attributes/w-val.d.ts +4 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/highlight/highlight-translator.d.ts +4 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/i/attributes/index.d.ts +2 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/i/attributes/w-val.d.ts +4 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/i/i-translator.d.ts +7 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/r/attributes/index.d.ts +2 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/r/attributes/w-rsid-del.d.ts +4 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/r/attributes/w-rsid-r-pr.d.ts +4 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/r/attributes/w-rsid-r.d.ts +4 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/r/helpers/helpers.d.ts +40 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/r/helpers/index.d.ts +2 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/r/helpers/split-run-properties.d.ts +9 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/r/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/r/r-translator.d.ts +4 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/rFonts/attributes/index.d.ts +2 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/rFonts/attributes/w-ascii.d.ts +4 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/rFonts/attributes/w-cs.d.ts +4 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/rFonts/attributes/w-east-asia.d.ts +4 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/rFonts/attributes/w-hansi.d.ts +4 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/rFonts/attributes/w-val.d.ts +4 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/rFonts/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/rFonts/rFonts-translator.d.ts +5 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/rStyle/attributes/index.d.ts +2 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/rStyle/attributes/w-val.d.ts +4 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/rStyle/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/rStyle/rstyle-translator.d.ts +7 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/rpr/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/rpr/rpr-translator.d.ts +5 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/rpr/run-property-translators.d.ts +11 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/strike/attributes/index.d.ts +2 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/strike/attributes/w-val.d.ts +4 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/strike/strike-translator.d.ts +7 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/sz/attributes/index.d.ts +2 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/sz/attributes/w-val.d.ts +4 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/sz/sz-translator.d.ts +4 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/szcs/attributes/index.d.ts +2 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/szcs/attributes/w-val.d.ts +4 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/szcs/szcs-translator.d.ts +4 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/u/attributes/index.d.ts +2 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/u/attributes/w-color.d.ts +4 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/u/attributes/w-theme-color.d.ts +4 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/u/attributes/w-theme-shade.d.ts +4 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/u/attributes/w-theme-tint.d.ts +4 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/u/attributes/w-val.d.ts +4 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/u/u-translator.d.ts +7 -0
- package/dist/super-editor/src/extensions/index.d.ts +2 -2
- package/dist/super-editor/src/extensions/linked-styles/index.d.ts +1 -0
- package/dist/super-editor/src/extensions/linked-styles/underline-css.d.ts +17 -0
- package/dist/super-editor/src/extensions/run/index.d.ts +1 -0
- package/dist/super-editor/src/extensions/run/run.d.ts +6 -0
- package/dist/super-editor/src/extensions/shared/cascade-toggle.d.ts +8 -0
- package/dist/super-editor/super-editor.es.js +49 -23
- 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 +1865 -467
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
- package/dist/super-editor/src/core/super-converter/helpers/mediaHelpers.d.ts +0 -2
|
@@ -14877,25 +14877,47 @@ const getContentTypesFromXml = (contentTypesXml) => {
|
|
|
14877
14877
|
const defaults = xmlDoc.querySelectorAll("Default");
|
|
14878
14878
|
return Array.from(defaults).map((item) => item.getAttribute("Extension"));
|
|
14879
14879
|
};
|
|
14880
|
+
const DOCX_HIGHLIGHT_KEYWORD_MAP = /* @__PURE__ */ new Map([
|
|
14881
|
+
["yellow", "FFFF00"],
|
|
14882
|
+
["green", "00FF00"],
|
|
14883
|
+
["blue", "0000FF"],
|
|
14884
|
+
["cyan", "00FFFF"],
|
|
14885
|
+
["magenta", "FF00FF"],
|
|
14886
|
+
["red", "FF0000"],
|
|
14887
|
+
["darkYellow", "808000"],
|
|
14888
|
+
["darkGreen", "008000"],
|
|
14889
|
+
["darkBlue", "000080"],
|
|
14890
|
+
["darkCyan", "008080"],
|
|
14891
|
+
["darkMagenta", "800080"],
|
|
14892
|
+
["darkGray", "808080"],
|
|
14893
|
+
["darkRed", "800000"],
|
|
14894
|
+
["lightGray", "C0C0C0"],
|
|
14895
|
+
["black", "000000"],
|
|
14896
|
+
["white", "FFFFFF"]
|
|
14897
|
+
]);
|
|
14898
|
+
const normalizeHexColor = (hex2) => {
|
|
14899
|
+
if (!hex2) return null;
|
|
14900
|
+
let value = hex2.replace("#", "").trim();
|
|
14901
|
+
if (!value) return null;
|
|
14902
|
+
value = value.toUpperCase();
|
|
14903
|
+
if (value.length === 3)
|
|
14904
|
+
value = value.split("").map((c2) => c2 + c2).join("");
|
|
14905
|
+
if (value.length === 8) value = value.slice(0, 6);
|
|
14906
|
+
return value;
|
|
14907
|
+
};
|
|
14880
14908
|
const getHexColorFromDocxSystem = (docxColor) => {
|
|
14881
|
-
const
|
|
14882
|
-
|
|
14883
|
-
|
|
14884
|
-
|
|
14885
|
-
|
|
14886
|
-
|
|
14887
|
-
|
|
14888
|
-
|
|
14889
|
-
|
|
14890
|
-
|
|
14891
|
-
|
|
14892
|
-
|
|
14893
|
-
["darkGray", "#808080FF"],
|
|
14894
|
-
["darkRed", "#800000FF"],
|
|
14895
|
-
["lightGray", "#C0C0C0FF"],
|
|
14896
|
-
["black", "#000"]
|
|
14897
|
-
]);
|
|
14898
|
-
return colorMap.get(docxColor) || null;
|
|
14909
|
+
const hex2 = DOCX_HIGHLIGHT_KEYWORD_MAP.get(docxColor);
|
|
14910
|
+
return hex2 ? `#${hex2}` : null;
|
|
14911
|
+
};
|
|
14912
|
+
const getDocxHighlightKeywordFromHex = (hexColor) => {
|
|
14913
|
+
if (!hexColor) return null;
|
|
14914
|
+
if (DOCX_HIGHLIGHT_KEYWORD_MAP.has(hexColor)) return hexColor;
|
|
14915
|
+
const normalized = normalizeHexColor(hexColor);
|
|
14916
|
+
if (!normalized) return null;
|
|
14917
|
+
for (const [keyword, hex2] of DOCX_HIGHLIGHT_KEYWORD_MAP.entries()) {
|
|
14918
|
+
if (hex2 === normalized) return keyword;
|
|
14919
|
+
}
|
|
14920
|
+
return null;
|
|
14899
14921
|
};
|
|
14900
14922
|
function isValidHexColor(color) {
|
|
14901
14923
|
if (!color || typeof color !== "string") return false;
|
|
@@ -24176,18 +24198,6 @@ const baseNumbering = {
|
|
|
24176
24198
|
}
|
|
24177
24199
|
]
|
|
24178
24200
|
};
|
|
24179
|
-
const sanitizeDocxMediaName = (value, fallback = "image") => {
|
|
24180
|
-
if (!value) return fallback;
|
|
24181
|
-
const sanitized = value.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
24182
|
-
return sanitized || fallback;
|
|
24183
|
-
};
|
|
24184
|
-
const getFallbackImageNameFromDataUri = (src = "", fallback = "image") => {
|
|
24185
|
-
if (!src || typeof src !== "string") return fallback;
|
|
24186
|
-
const [prefix2] = src.split(";");
|
|
24187
|
-
const [, maybeType] = prefix2.split("/");
|
|
24188
|
-
const extension = maybeType?.toLowerCase();
|
|
24189
|
-
return extension ? `${fallback}.${extension}` : fallback;
|
|
24190
|
-
};
|
|
24191
24201
|
const TranslatorTypes = Object.freeze({
|
|
24192
24202
|
NODE: "node",
|
|
24193
24203
|
ATTRIBUTE: "attribute"
|
|
@@ -24308,37 +24318,37 @@ const _NodeTranslator = class _NodeTranslator2 {
|
|
|
24308
24318
|
};
|
|
24309
24319
|
__publicField$2(_NodeTranslator, "translatorTypes", TranslatorTypes);
|
|
24310
24320
|
let NodeTranslator = _NodeTranslator;
|
|
24311
|
-
const encode$
|
|
24321
|
+
const encode$T = (attributes) => {
|
|
24312
24322
|
return attributes["w:type"];
|
|
24313
24323
|
};
|
|
24314
|
-
const decode$
|
|
24324
|
+
const decode$K = (attrs) => {
|
|
24315
24325
|
const { lineBreakType } = attrs;
|
|
24316
24326
|
return lineBreakType;
|
|
24317
24327
|
};
|
|
24318
|
-
const attrConfig$
|
|
24328
|
+
const attrConfig$z = Object.freeze({
|
|
24319
24329
|
xmlName: "w:type",
|
|
24320
24330
|
sdName: "lineBreakType",
|
|
24321
|
-
encode: encode$
|
|
24322
|
-
decode: decode$
|
|
24331
|
+
encode: encode$T,
|
|
24332
|
+
decode: decode$K
|
|
24323
24333
|
});
|
|
24324
|
-
const encode$
|
|
24334
|
+
const encode$S = (attributes) => {
|
|
24325
24335
|
const xmlAttrValue = attributes["w:clear"];
|
|
24326
24336
|
return xmlAttrValue;
|
|
24327
24337
|
};
|
|
24328
|
-
const decode$
|
|
24338
|
+
const decode$J = (attrs) => {
|
|
24329
24339
|
const { clear } = attrs;
|
|
24330
24340
|
return clear;
|
|
24331
24341
|
};
|
|
24332
|
-
const attrConfig$
|
|
24342
|
+
const attrConfig$y = Object.freeze({
|
|
24333
24343
|
xmlName: "w:clear",
|
|
24334
24344
|
sdName: "clear",
|
|
24335
|
-
encode: encode$
|
|
24336
|
-
decode: decode$
|
|
24345
|
+
encode: encode$S,
|
|
24346
|
+
decode: decode$J
|
|
24337
24347
|
});
|
|
24338
|
-
const validXmlAttributes$
|
|
24339
|
-
const XML_NODE_NAME$
|
|
24348
|
+
const validXmlAttributes$h = [attrConfig$z, attrConfig$y];
|
|
24349
|
+
const XML_NODE_NAME$j = "w:br";
|
|
24340
24350
|
const SD_NODE_NAME$6 = "lineBreak";
|
|
24341
|
-
const encode$
|
|
24351
|
+
const encode$R = (_2, encodedAttrs) => {
|
|
24342
24352
|
const isPageBreak = encodedAttrs?.lineBreakType === "page";
|
|
24343
24353
|
const translated = {
|
|
24344
24354
|
type: isPageBreak ? "hardBreak" : "lineBreak"
|
|
@@ -24348,7 +24358,7 @@ const encode$h = (_2, encodedAttrs) => {
|
|
|
24348
24358
|
}
|
|
24349
24359
|
return translated;
|
|
24350
24360
|
};
|
|
24351
|
-
const decode$
|
|
24361
|
+
const decode$I = (params2, decodedAttrs) => {
|
|
24352
24362
|
const { node } = params2;
|
|
24353
24363
|
if (!node) return;
|
|
24354
24364
|
const wBreak = { name: "w:br" };
|
|
@@ -24365,63 +24375,120 @@ const decode$h = (params2, decodedAttrs) => {
|
|
|
24365
24375
|
};
|
|
24366
24376
|
return translated;
|
|
24367
24377
|
};
|
|
24368
|
-
const config$
|
|
24369
|
-
xmlName: XML_NODE_NAME$
|
|
24378
|
+
const config$j = {
|
|
24379
|
+
xmlName: XML_NODE_NAME$j,
|
|
24370
24380
|
sdNodeOrKeyName: SD_NODE_NAME$6,
|
|
24371
24381
|
type: NodeTranslator.translatorTypes.NODE,
|
|
24372
|
-
encode: encode$
|
|
24373
|
-
decode: decode$
|
|
24374
|
-
attributes: validXmlAttributes$
|
|
24382
|
+
encode: encode$R,
|
|
24383
|
+
decode: decode$I,
|
|
24384
|
+
attributes: validXmlAttributes$h
|
|
24385
|
+
};
|
|
24386
|
+
const translator$v = NodeTranslator.from(config$j);
|
|
24387
|
+
const encode$Q = (attributes) => attributes?.["w:val"];
|
|
24388
|
+
const decode$H = (attrs) => attrs?.highlight;
|
|
24389
|
+
const attrConfig$x = Object.freeze({
|
|
24390
|
+
xmlName: "w:val",
|
|
24391
|
+
sdName: "highlight",
|
|
24392
|
+
encode: encode$Q,
|
|
24393
|
+
decode: decode$H
|
|
24394
|
+
});
|
|
24395
|
+
const validXmlAttributes$g = [attrConfig$x];
|
|
24396
|
+
const XML_NODE_NAME$i = "w:highlight";
|
|
24397
|
+
const SD_ATTR_KEY$b = "highlight";
|
|
24398
|
+
const encode$P = (params2, encodedAttrs = {}) => {
|
|
24399
|
+
const { nodes } = params2;
|
|
24400
|
+
const node = nodes?.[0];
|
|
24401
|
+
const value = encodedAttrs.highlight ?? node?.attributes?.["w:val"];
|
|
24402
|
+
return {
|
|
24403
|
+
type: "attr",
|
|
24404
|
+
xmlName: XML_NODE_NAME$i,
|
|
24405
|
+
sdNodeOrKeyName: SD_ATTR_KEY$b,
|
|
24406
|
+
attributes: { "w:val": value ?? null }
|
|
24407
|
+
};
|
|
24408
|
+
};
|
|
24409
|
+
const decode$G = (params2) => {
|
|
24410
|
+
const attrs = params2?.node?.attrs || {};
|
|
24411
|
+
const highlightValue = attrs.highlight ?? attrs.color ?? null;
|
|
24412
|
+
if (!highlightValue) return void 0;
|
|
24413
|
+
const normalizedValue = String(highlightValue).trim().toLowerCase();
|
|
24414
|
+
if (!normalizedValue || normalizedValue === "transparent" || normalizedValue === "none") {
|
|
24415
|
+
return void 0;
|
|
24416
|
+
}
|
|
24417
|
+
const keyword = getDocxHighlightKeywordFromHex(highlightValue);
|
|
24418
|
+
if (keyword) {
|
|
24419
|
+
return {
|
|
24420
|
+
name: XML_NODE_NAME$i,
|
|
24421
|
+
attributes: { "w:val": keyword }
|
|
24422
|
+
};
|
|
24423
|
+
}
|
|
24424
|
+
const fill = normalizeHexColor(highlightValue);
|
|
24425
|
+
if (!fill) return void 0;
|
|
24426
|
+
return {
|
|
24427
|
+
name: "w:shd",
|
|
24428
|
+
attributes: {
|
|
24429
|
+
"w:color": "auto",
|
|
24430
|
+
"w:val": "clear",
|
|
24431
|
+
"w:fill": fill
|
|
24432
|
+
}
|
|
24433
|
+
};
|
|
24434
|
+
};
|
|
24435
|
+
const config$i = {
|
|
24436
|
+
xmlName: XML_NODE_NAME$i,
|
|
24437
|
+
sdNodeOrKeyName: SD_ATTR_KEY$b,
|
|
24438
|
+
type: NodeTranslator.translatorTypes.ATTRIBUTE,
|
|
24439
|
+
encode: encode$P,
|
|
24440
|
+
decode: decode$G,
|
|
24441
|
+
attributes: validXmlAttributes$g
|
|
24375
24442
|
};
|
|
24376
|
-
const translator$
|
|
24377
|
-
const encode$
|
|
24443
|
+
const translator$u = NodeTranslator.from(config$i);
|
|
24444
|
+
const encode$O = (attributes) => {
|
|
24378
24445
|
return attributes["w:val"];
|
|
24379
24446
|
};
|
|
24380
|
-
const decode$
|
|
24447
|
+
const decode$F = (attrs) => {
|
|
24381
24448
|
const { tabSize } = attrs || {};
|
|
24382
24449
|
return tabSize;
|
|
24383
24450
|
};
|
|
24384
|
-
const attrConfig$
|
|
24451
|
+
const attrConfig$w = Object.freeze({
|
|
24385
24452
|
xmlName: "w:val",
|
|
24386
24453
|
sdName: "tabSize",
|
|
24387
|
-
encode: encode$
|
|
24388
|
-
decode: decode$
|
|
24454
|
+
encode: encode$O,
|
|
24455
|
+
decode: decode$F
|
|
24389
24456
|
});
|
|
24390
|
-
const encode$
|
|
24457
|
+
const encode$N = (attributes) => {
|
|
24391
24458
|
return attributes["w:leader"];
|
|
24392
24459
|
};
|
|
24393
|
-
const decode$
|
|
24460
|
+
const decode$E = (attrs) => {
|
|
24394
24461
|
const { leader } = attrs || {};
|
|
24395
24462
|
return leader;
|
|
24396
24463
|
};
|
|
24397
|
-
const attrConfig$
|
|
24464
|
+
const attrConfig$v = Object.freeze({
|
|
24398
24465
|
xmlName: "w:leader",
|
|
24399
24466
|
sdName: "leader",
|
|
24400
|
-
encode: encode$
|
|
24401
|
-
decode: decode$
|
|
24467
|
+
encode: encode$N,
|
|
24468
|
+
decode: decode$E
|
|
24402
24469
|
});
|
|
24403
|
-
const encode$
|
|
24470
|
+
const encode$M = (attributes) => {
|
|
24404
24471
|
return attributes["w:pos"];
|
|
24405
24472
|
};
|
|
24406
|
-
const decode$
|
|
24473
|
+
const decode$D = (attrs) => {
|
|
24407
24474
|
const { pos } = attrs || {};
|
|
24408
24475
|
return pos;
|
|
24409
24476
|
};
|
|
24410
|
-
const attrConfig$
|
|
24477
|
+
const attrConfig$u = Object.freeze({
|
|
24411
24478
|
xmlName: "w:pos",
|
|
24412
24479
|
sdName: "pos",
|
|
24413
|
-
encode: encode$
|
|
24414
|
-
decode: decode$
|
|
24480
|
+
encode: encode$M,
|
|
24481
|
+
decode: decode$D
|
|
24415
24482
|
});
|
|
24416
|
-
const validXmlAttributes$
|
|
24417
|
-
const XML_NODE_NAME$
|
|
24483
|
+
const validXmlAttributes$f = [attrConfig$w, attrConfig$u, attrConfig$v];
|
|
24484
|
+
const XML_NODE_NAME$h = "w:tab";
|
|
24418
24485
|
const SD_NODE_NAME$5 = "tab";
|
|
24419
|
-
const encode$
|
|
24486
|
+
const encode$L = (_2, encodedAttrs = {}) => {
|
|
24420
24487
|
const translated = { type: "tab" };
|
|
24421
24488
|
if (encodedAttrs) translated.attrs = { ...encodedAttrs };
|
|
24422
24489
|
return translated;
|
|
24423
24490
|
};
|
|
24424
|
-
const decode$
|
|
24491
|
+
const decode$C = (params2, decodedAttrs = {}) => {
|
|
24425
24492
|
const { node } = params2 || {};
|
|
24426
24493
|
if (!node) return;
|
|
24427
24494
|
const wTab = { name: "w:tab" };
|
|
@@ -24437,15 +24504,15 @@ const decode$d = (params2, decodedAttrs = {}) => {
|
|
|
24437
24504
|
}
|
|
24438
24505
|
return translated;
|
|
24439
24506
|
};
|
|
24440
|
-
const config$
|
|
24441
|
-
xmlName: XML_NODE_NAME$
|
|
24507
|
+
const config$h = {
|
|
24508
|
+
xmlName: XML_NODE_NAME$h,
|
|
24442
24509
|
sdNodeOrKeyName: SD_NODE_NAME$5,
|
|
24443
24510
|
type: NodeTranslator.translatorTypes.NODE,
|
|
24444
|
-
encode: encode$
|
|
24445
|
-
decode: decode$
|
|
24446
|
-
attributes: validXmlAttributes$
|
|
24511
|
+
encode: encode$L,
|
|
24512
|
+
decode: decode$C,
|
|
24513
|
+
attributes: validXmlAttributes$f
|
|
24447
24514
|
};
|
|
24448
|
-
const translator$
|
|
24515
|
+
const translator$t = NodeTranslator.from(config$h);
|
|
24449
24516
|
const mergeTextNodes = (nodes) => {
|
|
24450
24517
|
if (!nodes || !Array.isArray(nodes)) {
|
|
24451
24518
|
return nodes;
|
|
@@ -24620,17 +24687,21 @@ function getMarkValue(markType, attributes, docx) {
|
|
|
24620
24687
|
function getFontFamilyValue(attributes, docx) {
|
|
24621
24688
|
const ascii = attributes["w:ascii"];
|
|
24622
24689
|
const themeAscii = attributes["w:asciiTheme"];
|
|
24623
|
-
|
|
24624
|
-
|
|
24625
|
-
|
|
24626
|
-
|
|
24627
|
-
|
|
24628
|
-
|
|
24629
|
-
|
|
24630
|
-
|
|
24631
|
-
|
|
24632
|
-
|
|
24633
|
-
|
|
24690
|
+
let resolved = ascii;
|
|
24691
|
+
if (docx && themeAscii) {
|
|
24692
|
+
const theme = docx["word/theme/theme1.xml"];
|
|
24693
|
+
if (theme?.elements?.length) {
|
|
24694
|
+
const { elements: topElements } = theme;
|
|
24695
|
+
const { elements } = topElements[0] || {};
|
|
24696
|
+
const themeElements = elements?.find((el) => el.name === "a:themeElements");
|
|
24697
|
+
const fontScheme = themeElements?.elements?.find((el) => el.name === "a:fontScheme");
|
|
24698
|
+
const majorFont = fontScheme?.elements?.find((el) => el.name === "a:majorFont");
|
|
24699
|
+
const latin = majorFont?.elements?.find((el) => el.name === "a:latin");
|
|
24700
|
+
resolved = latin?.attributes?.typeface || resolved;
|
|
24701
|
+
}
|
|
24702
|
+
}
|
|
24703
|
+
if (!resolved) return null;
|
|
24704
|
+
return SuperConverter.toCssFontFamily(resolved, docx);
|
|
24634
24705
|
}
|
|
24635
24706
|
function getIndentValue(attributes) {
|
|
24636
24707
|
let value = attributes["w:left"];
|
|
@@ -24651,7 +24722,11 @@ function getHighLightValue(attributes) {
|
|
|
24651
24722
|
return getHexColorFromDocxSystem(attributes?.["w:val"]) || null;
|
|
24652
24723
|
}
|
|
24653
24724
|
function getStrikeValue(attributes) {
|
|
24654
|
-
|
|
24725
|
+
const raw = attributes?.["w:val"];
|
|
24726
|
+
if (raw === void 0 || raw === null) return "1";
|
|
24727
|
+
const value = String(raw).trim().toLowerCase();
|
|
24728
|
+
if (value === "1" || value === "true" || value === "on") return "1";
|
|
24729
|
+
return null;
|
|
24655
24730
|
}
|
|
24656
24731
|
const parseParagraphBorders = (pBdr) => {
|
|
24657
24732
|
if (!pBdr || !pBdr.elements) return {};
|
|
@@ -25015,102 +25090,102 @@ const handleParagraphNode$1 = (params2) => {
|
|
|
25015
25090
|
}
|
|
25016
25091
|
return schemaNode;
|
|
25017
25092
|
};
|
|
25018
|
-
const encode$
|
|
25093
|
+
const encode$K = (attributes) => {
|
|
25019
25094
|
return attributes["w:rsidDel"];
|
|
25020
25095
|
};
|
|
25021
|
-
const decode$
|
|
25096
|
+
const decode$B = (attrs) => {
|
|
25022
25097
|
return attrs.rsidDel;
|
|
25023
25098
|
};
|
|
25024
|
-
const attrConfig$
|
|
25099
|
+
const attrConfig$t = Object.freeze({
|
|
25025
25100
|
xmlName: "w:rsidDel",
|
|
25026
25101
|
sdName: "rsidDel",
|
|
25027
|
-
encode: encode$
|
|
25028
|
-
decode: decode$
|
|
25102
|
+
encode: encode$K,
|
|
25103
|
+
decode: decode$B
|
|
25029
25104
|
});
|
|
25030
|
-
const encode$
|
|
25105
|
+
const encode$J = (attributes) => {
|
|
25031
25106
|
return attributes["w:rsidP"];
|
|
25032
25107
|
};
|
|
25033
|
-
const decode$
|
|
25108
|
+
const decode$A = (attrs) => {
|
|
25034
25109
|
return attrs.rsidP;
|
|
25035
25110
|
};
|
|
25036
|
-
const attrConfig$
|
|
25111
|
+
const attrConfig$s = Object.freeze({
|
|
25037
25112
|
xmlName: "w:rsidP",
|
|
25038
25113
|
sdName: "rsidP",
|
|
25039
|
-
encode: encode$
|
|
25040
|
-
decode: decode$
|
|
25114
|
+
encode: encode$J,
|
|
25115
|
+
decode: decode$A
|
|
25041
25116
|
});
|
|
25042
|
-
const encode$
|
|
25117
|
+
const encode$I = (attributes) => {
|
|
25043
25118
|
return attributes["w:rsidR"];
|
|
25044
25119
|
};
|
|
25045
|
-
const decode$
|
|
25120
|
+
const decode$z = (attrs) => {
|
|
25046
25121
|
return attrs.rsidR;
|
|
25047
25122
|
};
|
|
25048
|
-
const attrConfig$
|
|
25123
|
+
const attrConfig$r = Object.freeze({
|
|
25049
25124
|
xmlName: "w:rsidR",
|
|
25050
25125
|
sdName: "rsidR",
|
|
25051
|
-
encode: encode$
|
|
25052
|
-
decode: decode$
|
|
25126
|
+
encode: encode$I,
|
|
25127
|
+
decode: decode$z
|
|
25053
25128
|
});
|
|
25054
|
-
const encode$
|
|
25129
|
+
const encode$H = (attributes) => {
|
|
25055
25130
|
return attributes["w:rsidRPr"];
|
|
25056
25131
|
};
|
|
25057
|
-
const decode$
|
|
25132
|
+
const decode$y = (attrs) => {
|
|
25058
25133
|
return attrs.rsidRPr;
|
|
25059
25134
|
};
|
|
25060
|
-
const attrConfig$
|
|
25135
|
+
const attrConfig$q = Object.freeze({
|
|
25061
25136
|
xmlName: "w:rsidRPr",
|
|
25062
25137
|
sdName: "rsidRPr",
|
|
25063
|
-
encode: encode$
|
|
25064
|
-
decode: decode$
|
|
25138
|
+
encode: encode$H,
|
|
25139
|
+
decode: decode$y
|
|
25065
25140
|
});
|
|
25066
|
-
const encode$
|
|
25141
|
+
const encode$G = (attributes) => {
|
|
25067
25142
|
return attributes["w:rsidRDefault"];
|
|
25068
25143
|
};
|
|
25069
|
-
const decode$
|
|
25144
|
+
const decode$x = (attrs) => {
|
|
25070
25145
|
return attrs.rsidRDefault;
|
|
25071
25146
|
};
|
|
25072
|
-
const attrConfig$
|
|
25147
|
+
const attrConfig$p = Object.freeze({
|
|
25073
25148
|
xmlName: "w:rsidRDefault",
|
|
25074
25149
|
sdName: "rsidRDefault",
|
|
25075
|
-
encode: encode$
|
|
25076
|
-
decode: decode$
|
|
25150
|
+
encode: encode$G,
|
|
25151
|
+
decode: decode$x
|
|
25077
25152
|
});
|
|
25078
|
-
const encode$
|
|
25153
|
+
const encode$F = (attributes) => {
|
|
25079
25154
|
return attributes["w14:paraId"];
|
|
25080
25155
|
};
|
|
25081
|
-
const decode$
|
|
25156
|
+
const decode$w = (attrs) => {
|
|
25082
25157
|
return attrs.paraId;
|
|
25083
25158
|
};
|
|
25084
|
-
const attrConfig$
|
|
25159
|
+
const attrConfig$o = Object.freeze({
|
|
25085
25160
|
xmlName: "w14:paraId",
|
|
25086
25161
|
sdName: "paraId",
|
|
25087
|
-
encode: encode$
|
|
25088
|
-
decode: decode$
|
|
25162
|
+
encode: encode$F,
|
|
25163
|
+
decode: decode$w
|
|
25089
25164
|
});
|
|
25090
|
-
const encode$
|
|
25165
|
+
const encode$E = (attributes) => {
|
|
25091
25166
|
return attributes["w14:textId"];
|
|
25092
25167
|
};
|
|
25093
|
-
const decode$
|
|
25168
|
+
const decode$v = (attrs) => {
|
|
25094
25169
|
return attrs.textId;
|
|
25095
25170
|
};
|
|
25096
|
-
const attrConfig = Object.freeze({
|
|
25171
|
+
const attrConfig$n = Object.freeze({
|
|
25097
25172
|
xmlName: "w14:textId",
|
|
25098
25173
|
sdName: "textId",
|
|
25099
|
-
encode: encode$
|
|
25100
|
-
decode: decode$
|
|
25174
|
+
encode: encode$E,
|
|
25175
|
+
decode: decode$v
|
|
25101
25176
|
});
|
|
25102
|
-
const validXmlAttributes$
|
|
25103
|
-
attrConfig$
|
|
25104
|
-
attrConfig,
|
|
25105
|
-
attrConfig$
|
|
25106
|
-
attrConfig$
|
|
25107
|
-
attrConfig$
|
|
25108
|
-
attrConfig$
|
|
25109
|
-
attrConfig$
|
|
25177
|
+
const validXmlAttributes$e = [
|
|
25178
|
+
attrConfig$o,
|
|
25179
|
+
attrConfig$n,
|
|
25180
|
+
attrConfig$r,
|
|
25181
|
+
attrConfig$p,
|
|
25182
|
+
attrConfig$s,
|
|
25183
|
+
attrConfig$q,
|
|
25184
|
+
attrConfig$t
|
|
25110
25185
|
];
|
|
25111
|
-
const XML_NODE_NAME$
|
|
25186
|
+
const XML_NODE_NAME$g = "w:p";
|
|
25112
25187
|
const SD_NODE_NAME$4 = "paragraph";
|
|
25113
|
-
const encode$
|
|
25188
|
+
const encode$D = (params2, encodedAttrs = {}) => {
|
|
25114
25189
|
const node = handleParagraphNode$1(params2);
|
|
25115
25190
|
if (!node) return void 0;
|
|
25116
25191
|
if (encodedAttrs && Object.keys(encodedAttrs).length) {
|
|
@@ -25118,7 +25193,7 @@ const encode$5 = (params2, encodedAttrs = {}) => {
|
|
|
25118
25193
|
}
|
|
25119
25194
|
return node;
|
|
25120
25195
|
};
|
|
25121
|
-
const decode$
|
|
25196
|
+
const decode$u = (params2, decodedAttrs = {}) => {
|
|
25122
25197
|
const translated = translateParagraphNode(params2);
|
|
25123
25198
|
if (!translated) return void 0;
|
|
25124
25199
|
if (decodedAttrs && Object.keys(decodedAttrs).length) {
|
|
@@ -25126,15 +25201,15 @@ const decode$5 = (params2, decodedAttrs = {}) => {
|
|
|
25126
25201
|
}
|
|
25127
25202
|
return translated;
|
|
25128
25203
|
};
|
|
25129
|
-
const config$
|
|
25130
|
-
xmlName: XML_NODE_NAME$
|
|
25204
|
+
const config$g = {
|
|
25205
|
+
xmlName: XML_NODE_NAME$g,
|
|
25131
25206
|
sdNodeOrKeyName: SD_NODE_NAME$4,
|
|
25132
25207
|
type: NodeTranslator.translatorTypes.NODE,
|
|
25133
|
-
encode: encode$
|
|
25134
|
-
decode: decode$
|
|
25135
|
-
attributes: validXmlAttributes$
|
|
25208
|
+
encode: encode$D,
|
|
25209
|
+
decode: decode$u,
|
|
25210
|
+
attributes: validXmlAttributes$e
|
|
25136
25211
|
};
|
|
25137
|
-
const translator$
|
|
25212
|
+
const translator$s = NodeTranslator.from(config$g);
|
|
25138
25213
|
const generateV2HandlerEntity = (handlerName, translator2) => ({
|
|
25139
25214
|
handlerName,
|
|
25140
25215
|
handler: (params2) => {
|
|
@@ -25241,13 +25316,13 @@ const integerToString = (value) => {
|
|
|
25241
25316
|
const intValue = parseInteger(value);
|
|
25242
25317
|
return intValue != void 0 ? String(intValue) : void 0;
|
|
25243
25318
|
};
|
|
25244
|
-
const translator$
|
|
25319
|
+
const translator$r = NodeTranslator.from({
|
|
25245
25320
|
xmlName: "w:cantSplit",
|
|
25246
25321
|
sdNodeOrKeyName: "cantSplit",
|
|
25247
25322
|
encode: ({ nodes }) => ["1", "true"].includes(nodes[0].attributes?.["w:val"] ?? "1"),
|
|
25248
25323
|
decode: ({ node }) => node.attrs?.cantSplit ? {} : void 0
|
|
25249
25324
|
});
|
|
25250
|
-
const translator$
|
|
25325
|
+
const translator$q = NodeTranslator.from({
|
|
25251
25326
|
xmlName: "w:cnfStyle",
|
|
25252
25327
|
sdNodeOrKeyName: "cnfStyle",
|
|
25253
25328
|
attributes: [
|
|
@@ -25280,8 +25355,8 @@ const translator$f = NodeTranslator.from({
|
|
|
25280
25355
|
return Object.keys(cnfStyleAttrs).length > 0 ? cnfStyleAttrs : void 0;
|
|
25281
25356
|
}
|
|
25282
25357
|
});
|
|
25283
|
-
const translator$
|
|
25284
|
-
const translator$
|
|
25358
|
+
const translator$p = NodeTranslator.from(createSingleAttrPropertyHandler("w:divId"));
|
|
25359
|
+
const translator$o = NodeTranslator.from(
|
|
25285
25360
|
createSingleAttrPropertyHandler(
|
|
25286
25361
|
"w:gridAfter",
|
|
25287
25362
|
null,
|
|
@@ -25290,7 +25365,7 @@ const translator$d = NodeTranslator.from(
|
|
|
25290
25365
|
(v2) => integerToString(v2)
|
|
25291
25366
|
)
|
|
25292
25367
|
);
|
|
25293
|
-
const translator$
|
|
25368
|
+
const translator$n = NodeTranslator.from(
|
|
25294
25369
|
createSingleAttrPropertyHandler(
|
|
25295
25370
|
"w:gridBefore",
|
|
25296
25371
|
null,
|
|
@@ -25299,21 +25374,21 @@ const translator$c = NodeTranslator.from(
|
|
|
25299
25374
|
(v2) => integerToString(v2)
|
|
25300
25375
|
)
|
|
25301
25376
|
);
|
|
25302
|
-
const translator$
|
|
25377
|
+
const translator$m = NodeTranslator.from({
|
|
25303
25378
|
xmlName: "w:hidden",
|
|
25304
25379
|
sdNodeOrKeyName: "hidden",
|
|
25305
25380
|
encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
|
|
25306
25381
|
decode: ({ node }) => node.attrs.hidden ? {} : void 0
|
|
25307
25382
|
});
|
|
25308
|
-
const translator$
|
|
25309
|
-
const translator$
|
|
25310
|
-
const translator$
|
|
25383
|
+
const translator$l = NodeTranslator.from(createSingleAttrPropertyHandler("w:jc"));
|
|
25384
|
+
const translator$k = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "cellSpacing"));
|
|
25385
|
+
const translator$j = NodeTranslator.from({
|
|
25311
25386
|
xmlName: "w:tblHeader",
|
|
25312
25387
|
sdNodeOrKeyName: "repeatHeader",
|
|
25313
25388
|
encode: ({ nodes }) => parseBoolean(nodes[0].attributes?.["w:val"] ?? "1"),
|
|
25314
25389
|
decode: ({ node }) => node.attrs.repeatHeader ? {} : void 0
|
|
25315
25390
|
});
|
|
25316
|
-
const translator$
|
|
25391
|
+
const translator$i = NodeTranslator.from({
|
|
25317
25392
|
xmlName: "w:trHeight",
|
|
25318
25393
|
sdNodeOrKeyName: "rowHeight",
|
|
25319
25394
|
encode: ({ nodes }) => {
|
|
@@ -25340,11 +25415,11 @@ const translator$7 = NodeTranslator.from({
|
|
|
25340
25415
|
return Object.keys(heightAttrs).length > 0 ? heightAttrs : void 0;
|
|
25341
25416
|
}
|
|
25342
25417
|
});
|
|
25343
|
-
const translator$
|
|
25344
|
-
const translator$
|
|
25345
|
-
const XML_NODE_NAME$
|
|
25346
|
-
const SD_ATTR_KEY = "tableRowProperties";
|
|
25347
|
-
const encode$
|
|
25418
|
+
const translator$h = NodeTranslator.from(createMeasurementPropertyHandler("w:wAfter"));
|
|
25419
|
+
const translator$g = NodeTranslator.from(createMeasurementPropertyHandler("w:wBefore"));
|
|
25420
|
+
const XML_NODE_NAME$f = "w:trPr";
|
|
25421
|
+
const SD_ATTR_KEY$a = "tableRowProperties";
|
|
25422
|
+
const encode$C = (params2) => {
|
|
25348
25423
|
const { nodes } = params2;
|
|
25349
25424
|
const node = nodes[0];
|
|
25350
25425
|
let attributes = {
|
|
@@ -25358,12 +25433,12 @@ const encode$4 = (params2) => {
|
|
|
25358
25433
|
};
|
|
25359
25434
|
return {
|
|
25360
25435
|
type: NodeTranslator.translatorTypes.ATTRIBUTE,
|
|
25361
|
-
xmlName: XML_NODE_NAME$
|
|
25362
|
-
sdNodeOrKeyName: SD_ATTR_KEY,
|
|
25436
|
+
xmlName: XML_NODE_NAME$f,
|
|
25437
|
+
sdNodeOrKeyName: SD_ATTR_KEY$a,
|
|
25363
25438
|
attributes
|
|
25364
25439
|
};
|
|
25365
25440
|
};
|
|
25366
|
-
const decode$
|
|
25441
|
+
const decode$t = (params2) => {
|
|
25367
25442
|
const { tableRowProperties = {} } = params2.node.attrs || {};
|
|
25368
25443
|
const elements = decodeProperties(propertyTranslatorsBySdName, tableRowProperties);
|
|
25369
25444
|
const newNode = {
|
|
@@ -25375,18 +25450,18 @@ const decode$4 = (params2) => {
|
|
|
25375
25450
|
return newNode;
|
|
25376
25451
|
};
|
|
25377
25452
|
const propertyTranslators = [
|
|
25378
|
-
translator$
|
|
25379
|
-
translator$
|
|
25380
|
-
translator$
|
|
25381
|
-
translator$
|
|
25382
|
-
translator$
|
|
25383
|
-
translator$
|
|
25384
|
-
translator$
|
|
25385
|
-
translator$
|
|
25386
|
-
translator$
|
|
25387
|
-
translator$
|
|
25388
|
-
translator$
|
|
25389
|
-
translator$
|
|
25453
|
+
translator$r,
|
|
25454
|
+
translator$q,
|
|
25455
|
+
translator$p,
|
|
25456
|
+
translator$o,
|
|
25457
|
+
translator$n,
|
|
25458
|
+
translator$m,
|
|
25459
|
+
translator$l,
|
|
25460
|
+
translator$k,
|
|
25461
|
+
translator$j,
|
|
25462
|
+
translator$i,
|
|
25463
|
+
translator$h,
|
|
25464
|
+
translator$g
|
|
25390
25465
|
];
|
|
25391
25466
|
const propertyTranslatorsByXmlName = {};
|
|
25392
25467
|
propertyTranslators.forEach((translator2) => {
|
|
@@ -25396,25 +25471,25 @@ const propertyTranslatorsBySdName = {};
|
|
|
25396
25471
|
propertyTranslators.forEach((translator2) => {
|
|
25397
25472
|
propertyTranslatorsBySdName[translator2.sdNodeOrKeyName] = translator2;
|
|
25398
25473
|
});
|
|
25399
|
-
const config$
|
|
25400
|
-
xmlName: XML_NODE_NAME$
|
|
25401
|
-
sdNodeOrKeyName: SD_ATTR_KEY,
|
|
25474
|
+
const config$f = {
|
|
25475
|
+
xmlName: XML_NODE_NAME$f,
|
|
25476
|
+
sdNodeOrKeyName: SD_ATTR_KEY$a,
|
|
25402
25477
|
type: NodeTranslator.translatorTypes.ATTRIBUTE,
|
|
25403
|
-
encode: encode$
|
|
25404
|
-
decode: decode$
|
|
25478
|
+
encode: encode$C,
|
|
25479
|
+
decode: decode$t
|
|
25405
25480
|
};
|
|
25406
|
-
const translator$
|
|
25407
|
-
const XML_NODE_NAME$
|
|
25481
|
+
const translator$f = NodeTranslator.from(config$f);
|
|
25482
|
+
const XML_NODE_NAME$e = "w:tr";
|
|
25408
25483
|
const SD_NODE_NAME$3 = "tableRow";
|
|
25409
|
-
const validXmlAttributes$
|
|
25484
|
+
const validXmlAttributes$d = ["w:rsidDel", "w:rsidR", "w:rsidRPr", "w:rsidTr", "w14:paraId", "w14:textId"].map(
|
|
25410
25485
|
(xmlName) => createAttributeHandler(xmlName)
|
|
25411
25486
|
);
|
|
25412
|
-
const encode$
|
|
25487
|
+
const encode$B = (params2, encodedAttrs) => {
|
|
25413
25488
|
const { row, table } = params2.extraParams;
|
|
25414
25489
|
let tableRowProperties = {};
|
|
25415
25490
|
const tPr = row.elements.find((el) => el.name === "w:trPr");
|
|
25416
25491
|
if (tPr) {
|
|
25417
|
-
({ attributes: tableRowProperties } = translator$
|
|
25492
|
+
({ attributes: tableRowProperties } = translator$f.encode({
|
|
25418
25493
|
...params2,
|
|
25419
25494
|
nodes: [tPr]
|
|
25420
25495
|
}));
|
|
@@ -25427,7 +25502,7 @@ const encode$3 = (params2, encodedAttrs) => {
|
|
|
25427
25502
|
let currentColumnIndex = 0;
|
|
25428
25503
|
const content = cellNodes?.map((n) => {
|
|
25429
25504
|
let columnWidth = gridColumnWidths?.[currentColumnIndex] || null;
|
|
25430
|
-
const result = translator$
|
|
25505
|
+
const result = translator$d.encode({
|
|
25431
25506
|
...params2,
|
|
25432
25507
|
extraParams: {
|
|
25433
25508
|
...params2.extraParams,
|
|
@@ -25458,7 +25533,7 @@ const _getGridColumnWidths = (tableNode) => {
|
|
|
25458
25533
|
}) || [];
|
|
25459
25534
|
return columnWidths;
|
|
25460
25535
|
};
|
|
25461
|
-
const decode$
|
|
25536
|
+
const decode$s = (params2, decodedAttrs) => {
|
|
25462
25537
|
const { node } = params2;
|
|
25463
25538
|
const elements = translateChildNodes(params2);
|
|
25464
25539
|
if (node.attrs?.tableRowProperties) {
|
|
@@ -25470,7 +25545,7 @@ const decode$3 = (params2, decodedAttrs) => {
|
|
|
25470
25545
|
}
|
|
25471
25546
|
}
|
|
25472
25547
|
tableRowProperties["cantSplit"] = node.attrs["cantSplit"];
|
|
25473
|
-
const trPr = translator$
|
|
25548
|
+
const trPr = translator$f.decode({
|
|
25474
25549
|
...params2,
|
|
25475
25550
|
node: { ...node, attrs: { ...node.attrs, tableRowProperties } }
|
|
25476
25551
|
});
|
|
@@ -25482,15 +25557,15 @@ const decode$3 = (params2, decodedAttrs) => {
|
|
|
25482
25557
|
elements
|
|
25483
25558
|
};
|
|
25484
25559
|
};
|
|
25485
|
-
const config$
|
|
25486
|
-
xmlName: XML_NODE_NAME$
|
|
25560
|
+
const config$e = {
|
|
25561
|
+
xmlName: XML_NODE_NAME$e,
|
|
25487
25562
|
sdNodeOrKeyName: SD_NODE_NAME$3,
|
|
25488
25563
|
type: NodeTranslator.translatorTypes.NODE,
|
|
25489
|
-
encode: encode$
|
|
25490
|
-
decode: decode$
|
|
25491
|
-
attributes: validXmlAttributes$
|
|
25564
|
+
encode: encode$B,
|
|
25565
|
+
decode: decode$s,
|
|
25566
|
+
attributes: validXmlAttributes$d
|
|
25492
25567
|
};
|
|
25493
|
-
const translator$
|
|
25568
|
+
const translator$e = NodeTranslator.from(config$e);
|
|
25494
25569
|
const handleAllTableNodes = (params2) => {
|
|
25495
25570
|
const { nodes } = params2;
|
|
25496
25571
|
if (nodes.length === 0) {
|
|
@@ -25554,7 +25629,7 @@ function handleTableNode(node, params2) {
|
|
|
25554
25629
|
attrs["borders"] = borderData;
|
|
25555
25630
|
const content = [];
|
|
25556
25631
|
rows.forEach((row) => {
|
|
25557
|
-
const result = translator$
|
|
25632
|
+
const result = translator$e.encode({
|
|
25558
25633
|
...params2,
|
|
25559
25634
|
nodes: [row],
|
|
25560
25635
|
extraParams: {
|
|
@@ -25935,10 +26010,10 @@ function generateCellMargins(cellMargins) {
|
|
|
25935
26010
|
if (left2 != null) elements.push({ name: "w:left", attributes: { "w:w": pixelsToTwips(left2) } });
|
|
25936
26011
|
return elements;
|
|
25937
26012
|
}
|
|
25938
|
-
const XML_NODE_NAME$
|
|
26013
|
+
const XML_NODE_NAME$d = "w:tc";
|
|
25939
26014
|
const SD_NODE_NAME$2 = "tableCell";
|
|
25940
|
-
const validXmlAttributes$
|
|
25941
|
-
function encode$
|
|
26015
|
+
const validXmlAttributes$c = [];
|
|
26016
|
+
function encode$A(params2, encodedAttrs) {
|
|
25942
26017
|
const { node, table, row, rowBorders, styleTag, columnIndex, columnWidth } = params2.extraParams;
|
|
25943
26018
|
const schemaNode = handleTableCellNode({
|
|
25944
26019
|
params: params2,
|
|
@@ -25955,23 +26030,23 @@ function encode$2(params2, encodedAttrs) {
|
|
|
25955
26030
|
}
|
|
25956
26031
|
return schemaNode;
|
|
25957
26032
|
}
|
|
25958
|
-
function decode$
|
|
26033
|
+
function decode$r(params2, decodedAttrs) {
|
|
25959
26034
|
const translated = translateTableCell(params2);
|
|
25960
26035
|
if (decodedAttrs && Object.keys(decodedAttrs).length) {
|
|
25961
26036
|
translated.attributes = { ...translated.attributes || {}, ...decodedAttrs };
|
|
25962
26037
|
}
|
|
25963
26038
|
return translated;
|
|
25964
26039
|
}
|
|
25965
|
-
const config$
|
|
25966
|
-
xmlName: XML_NODE_NAME$
|
|
26040
|
+
const config$d = {
|
|
26041
|
+
xmlName: XML_NODE_NAME$d,
|
|
25967
26042
|
sdNodeOrKeyName: SD_NODE_NAME$2,
|
|
25968
26043
|
type: NodeTranslator.translatorTypes.NODE,
|
|
25969
|
-
encode: encode$
|
|
25970
|
-
decode: decode$
|
|
25971
|
-
attributes: validXmlAttributes$
|
|
26044
|
+
encode: encode$A,
|
|
26045
|
+
decode: decode$r,
|
|
26046
|
+
attributes: validXmlAttributes$c
|
|
25972
26047
|
};
|
|
25973
|
-
const translator$
|
|
25974
|
-
const XML_NODE_NAME$
|
|
26048
|
+
const translator$d = NodeTranslator.from(config$d);
|
|
26049
|
+
const XML_NODE_NAME$c = "w:hyperlink";
|
|
25975
26050
|
const SD_NODE_NAME$1 = "link";
|
|
25976
26051
|
const _createAttributeHandler = (xmlName, sdName) => ({
|
|
25977
26052
|
xmlName,
|
|
@@ -25979,7 +26054,7 @@ const _createAttributeHandler = (xmlName, sdName) => ({
|
|
|
25979
26054
|
encode: (attributes) => attributes[xmlName],
|
|
25980
26055
|
decode: (attributes) => attributes[sdName]
|
|
25981
26056
|
});
|
|
25982
|
-
const validXmlAttributes$
|
|
26057
|
+
const validXmlAttributes$b = [
|
|
25983
26058
|
_createAttributeHandler("w:anchor", "anchor"),
|
|
25984
26059
|
_createAttributeHandler("w:docLocation", "docLocation"),
|
|
25985
26060
|
{
|
|
@@ -25992,7 +26067,7 @@ const validXmlAttributes$1 = [
|
|
|
25992
26067
|
_createAttributeHandler("r:id", "rId"),
|
|
25993
26068
|
_createAttributeHandler("w:tgtFrame", "target")
|
|
25994
26069
|
];
|
|
25995
|
-
const encode$
|
|
26070
|
+
const encode$z = (params2, encodedAttrs) => {
|
|
25996
26071
|
const { nodes, docx, nodeListHandler } = params2;
|
|
25997
26072
|
const node = nodes[0];
|
|
25998
26073
|
let href = _resolveHref(docx, encodedAttrs);
|
|
@@ -26006,7 +26081,16 @@ const encode$1 = (params2, encodedAttrs) => {
|
|
|
26006
26081
|
nodes: runNodes,
|
|
26007
26082
|
path: [...params2.path || [], node]
|
|
26008
26083
|
});
|
|
26009
|
-
|
|
26084
|
+
const ensureLinkMark = (child) => {
|
|
26085
|
+
if (!child || typeof child !== "object") return child;
|
|
26086
|
+
const existingMarks = Array.isArray(child.marks) ? child.marks : [];
|
|
26087
|
+
const hasLink = existingMarks.some((mark) => mark?.type === "link");
|
|
26088
|
+
if (hasLink) return child;
|
|
26089
|
+
const linkClone = { type: "link", attrs: { ...linkMark.attrs } };
|
|
26090
|
+
return { ...child, marks: [...existingMarks, linkClone] };
|
|
26091
|
+
};
|
|
26092
|
+
if (!Array.isArray(updatedNode)) return updatedNode;
|
|
26093
|
+
return updatedNode.map((child) => ensureLinkMark(child));
|
|
26010
26094
|
};
|
|
26011
26095
|
const _resolveHref = (docx, encodedAttrs) => {
|
|
26012
26096
|
const rels = docx["word/_rels/document.xml.rels"];
|
|
@@ -26023,7 +26107,7 @@ const _resolveHref = (docx, encodedAttrs) => {
|
|
|
26023
26107
|
}
|
|
26024
26108
|
return href;
|
|
26025
26109
|
};
|
|
26026
|
-
function decode$
|
|
26110
|
+
function decode$q(params2) {
|
|
26027
26111
|
const { node } = params2;
|
|
26028
26112
|
const linkMark = node.marks.find((m2) => m2.type === "link");
|
|
26029
26113
|
const linkAttrs = this.decodeAttributes({ ...params2, node: linkMark });
|
|
@@ -26067,15 +26151,15 @@ function _addNewLinkRelationship(params2, link, rId) {
|
|
|
26067
26151
|
});
|
|
26068
26152
|
return rId;
|
|
26069
26153
|
}
|
|
26070
|
-
const config$
|
|
26071
|
-
xmlName: XML_NODE_NAME$
|
|
26154
|
+
const config$c = {
|
|
26155
|
+
xmlName: XML_NODE_NAME$c,
|
|
26072
26156
|
sdNodeOrKeyName: SD_NODE_NAME$1,
|
|
26073
26157
|
type: NodeTranslator.translatorTypes.NODE,
|
|
26074
|
-
encode: encode$
|
|
26075
|
-
decode: decode$
|
|
26076
|
-
attributes: validXmlAttributes$
|
|
26158
|
+
encode: encode$z,
|
|
26159
|
+
decode: decode$q,
|
|
26160
|
+
attributes: validXmlAttributes$b
|
|
26077
26161
|
};
|
|
26078
|
-
const translator$
|
|
26162
|
+
const translator$c = NodeTranslator.from(config$c);
|
|
26079
26163
|
function parseTagValueJSON(json) {
|
|
26080
26164
|
if (typeof json !== "string") {
|
|
26081
26165
|
return {};
|
|
@@ -26086,7 +26170,7 @@ function parseTagValueJSON(json) {
|
|
|
26086
26170
|
}
|
|
26087
26171
|
try {
|
|
26088
26172
|
return JSON.parse(trimmed);
|
|
26089
|
-
} catch
|
|
26173
|
+
} catch {
|
|
26090
26174
|
return {};
|
|
26091
26175
|
}
|
|
26092
26176
|
}
|
|
@@ -27888,10 +27972,10 @@ function translateStructuredContent(params2) {
|
|
|
27888
27972
|
};
|
|
27889
27973
|
return result;
|
|
27890
27974
|
}
|
|
27891
|
-
const XML_NODE_NAME = "w:sdt";
|
|
27975
|
+
const XML_NODE_NAME$b = "w:sdt";
|
|
27892
27976
|
const SD_NODE_NAME = ["fieldAnnotation", "structuredContent", "structuredContentBlock", "documentSection"];
|
|
27893
|
-
const validXmlAttributes = [];
|
|
27894
|
-
function encode$
|
|
27977
|
+
const validXmlAttributes$a = [];
|
|
27978
|
+
function encode$y(params2) {
|
|
27895
27979
|
const nodes = params2.nodes;
|
|
27896
27980
|
const node = nodes[0];
|
|
27897
27981
|
const { type: sdtType, handler: handler2 } = sdtNodeTypeStrategy(node);
|
|
@@ -27901,7 +27985,7 @@ function encode$k(params2, encodedAttrs) {
|
|
|
27901
27985
|
const result = handler2(params2);
|
|
27902
27986
|
return result;
|
|
27903
27987
|
}
|
|
27904
|
-
function decode(params2
|
|
27988
|
+
function decode$p(params2) {
|
|
27905
27989
|
const { node } = params2;
|
|
27906
27990
|
if (!node || !node.type) {
|
|
27907
27991
|
return null;
|
|
@@ -27917,43 +28001,138 @@ function decode(params2, decodedAttrs) {
|
|
|
27917
28001
|
const result = decoder();
|
|
27918
28002
|
return result;
|
|
27919
28003
|
}
|
|
27920
|
-
const config = {
|
|
27921
|
-
xmlName: XML_NODE_NAME,
|
|
28004
|
+
const config$b = {
|
|
28005
|
+
xmlName: XML_NODE_NAME$b,
|
|
27922
28006
|
sdNodeOrKeyName: SD_NODE_NAME,
|
|
27923
28007
|
type: NodeTranslator.translatorTypes.NODE,
|
|
27924
|
-
encode: encode$
|
|
27925
|
-
decode,
|
|
27926
|
-
attributes: validXmlAttributes
|
|
28008
|
+
encode: encode$y,
|
|
28009
|
+
decode: decode$p,
|
|
28010
|
+
attributes: validXmlAttributes$a
|
|
28011
|
+
};
|
|
28012
|
+
const translator$b = NodeTranslator.from(config$b);
|
|
28013
|
+
const encode$x = (attributes) => attributes?.["w:val"];
|
|
28014
|
+
const decode$o = (attrs) => attrs?.underline;
|
|
28015
|
+
const attrConfig$m = Object.freeze({
|
|
28016
|
+
xmlName: "w:val",
|
|
28017
|
+
sdName: "underline",
|
|
28018
|
+
encode: encode$x,
|
|
28019
|
+
decode: decode$o
|
|
28020
|
+
});
|
|
28021
|
+
const encode$w = (attributes) => attributes?.["w:color"];
|
|
28022
|
+
const decode$n = (attrs) => attrs?.color;
|
|
28023
|
+
const attrConfig$l = Object.freeze({
|
|
28024
|
+
xmlName: "w:color",
|
|
28025
|
+
sdName: "color",
|
|
28026
|
+
encode: encode$w,
|
|
28027
|
+
decode: decode$n
|
|
28028
|
+
});
|
|
28029
|
+
const encode$v = (attributes) => attributes?.["w:themeColor"];
|
|
28030
|
+
const decode$m = (attrs) => attrs?.themeColor;
|
|
28031
|
+
const attrConfig$k = Object.freeze({
|
|
28032
|
+
xmlName: "w:themeColor",
|
|
28033
|
+
sdName: "themeColor",
|
|
28034
|
+
encode: encode$v,
|
|
28035
|
+
decode: decode$m
|
|
28036
|
+
});
|
|
28037
|
+
const encode$u = (attributes) => attributes?.["w:themeTint"];
|
|
28038
|
+
const decode$l = (attrs) => attrs?.themeTint;
|
|
28039
|
+
const attrConfig$j = Object.freeze({
|
|
28040
|
+
xmlName: "w:themeTint",
|
|
28041
|
+
sdName: "themeTint",
|
|
28042
|
+
encode: encode$u,
|
|
28043
|
+
decode: decode$l
|
|
28044
|
+
});
|
|
28045
|
+
const encode$t = (attributes) => attributes?.["w:themeShade"];
|
|
28046
|
+
const decode$k = (attrs) => attrs?.themeShade;
|
|
28047
|
+
const attrConfig$i = Object.freeze({
|
|
28048
|
+
xmlName: "w:themeShade",
|
|
28049
|
+
sdName: "themeShade",
|
|
28050
|
+
encode: encode$t,
|
|
28051
|
+
decode: decode$k
|
|
28052
|
+
});
|
|
28053
|
+
const validXmlAttributes$9 = [attrConfig$m, attrConfig$l, attrConfig$k, attrConfig$j, attrConfig$i];
|
|
28054
|
+
const XML_NODE_NAME$a = "w:u";
|
|
28055
|
+
const SD_ATTR_KEY$9 = "underline";
|
|
28056
|
+
const encode$s = (params2, encodedAttrs = {}) => {
|
|
28057
|
+
const { nodes } = params2;
|
|
28058
|
+
const node = nodes?.[0];
|
|
28059
|
+
const sourceAttrs = node?.attributes || {};
|
|
28060
|
+
const underlineType = encodedAttrs.underline ?? sourceAttrs["w:val"];
|
|
28061
|
+
const color = encodedAttrs.color ?? sourceAttrs["w:color"];
|
|
28062
|
+
const themeColor = encodedAttrs.themeColor ?? sourceAttrs["w:themeColor"];
|
|
28063
|
+
const themeTint = encodedAttrs.themeTint ?? sourceAttrs["w:themeTint"];
|
|
28064
|
+
const themeShade = encodedAttrs.themeShade ?? sourceAttrs["w:themeShade"];
|
|
28065
|
+
const attributes = { "w:val": underlineType ?? null };
|
|
28066
|
+
if (color !== void 0 && color !== null) attributes["w:color"] = color;
|
|
28067
|
+
if (themeColor !== void 0 && themeColor !== null) attributes["w:themeColor"] = themeColor;
|
|
28068
|
+
if (themeTint !== void 0 && themeTint !== null) attributes["w:themeTint"] = themeTint;
|
|
28069
|
+
if (themeShade !== void 0 && themeShade !== null) attributes["w:themeShade"] = themeShade;
|
|
28070
|
+
return {
|
|
28071
|
+
type: "attr",
|
|
28072
|
+
xmlName: XML_NODE_NAME$a,
|
|
28073
|
+
sdNodeOrKeyName: SD_ATTR_KEY$9,
|
|
28074
|
+
attributes
|
|
28075
|
+
};
|
|
27927
28076
|
};
|
|
27928
|
-
const
|
|
28077
|
+
const decode$j = (params2) => {
|
|
28078
|
+
const attrs = params2?.node?.attrs || {};
|
|
28079
|
+
const underlineType = attrs.underlineType ?? attrs.underline ?? null;
|
|
28080
|
+
const color = attrs.underlineColor ?? attrs.color ?? null;
|
|
28081
|
+
const themeColor = attrs.underlineThemeColor ?? attrs.themeColor ?? null;
|
|
28082
|
+
const themeTint = attrs.underlineThemeTint ?? attrs.themeTint ?? null;
|
|
28083
|
+
const themeShade = attrs.underlineThemeShade ?? attrs.themeShade ?? null;
|
|
28084
|
+
if (!underlineType && !color && !themeColor && !themeTint && !themeShade) return void 0;
|
|
28085
|
+
const attributes = {};
|
|
28086
|
+
if (underlineType) attributes["w:val"] = underlineType;
|
|
28087
|
+
if (color) {
|
|
28088
|
+
const normalized = normalizeHexColor(color);
|
|
28089
|
+
if (normalized) attributes["w:color"] = normalized;
|
|
28090
|
+
}
|
|
28091
|
+
if (themeColor) attributes["w:themeColor"] = themeColor;
|
|
28092
|
+
if (themeTint) attributes["w:themeTint"] = themeTint;
|
|
28093
|
+
if (themeShade) attributes["w:themeShade"] = themeShade;
|
|
28094
|
+
return {
|
|
28095
|
+
name: XML_NODE_NAME$a,
|
|
28096
|
+
attributes
|
|
28097
|
+
};
|
|
28098
|
+
};
|
|
28099
|
+
const config$a = {
|
|
28100
|
+
xmlName: XML_NODE_NAME$a,
|
|
28101
|
+
sdNodeOrKeyName: SD_ATTR_KEY$9,
|
|
28102
|
+
type: NodeTranslator.translatorTypes.ATTRIBUTE,
|
|
28103
|
+
encode: encode$s,
|
|
28104
|
+
decode: decode$j,
|
|
28105
|
+
attributes: validXmlAttributes$9
|
|
28106
|
+
};
|
|
28107
|
+
const translator$a = NodeTranslator.from(config$a);
|
|
27929
28108
|
function exportSchemaToJson(params2) {
|
|
27930
28109
|
const { type: type2 } = params2.node || {};
|
|
27931
28110
|
const router = {
|
|
27932
28111
|
doc: translateDocumentNode,
|
|
27933
28112
|
body: translateBodyNode,
|
|
27934
28113
|
heading: translateHeadingNode,
|
|
27935
|
-
paragraph: translator$
|
|
28114
|
+
paragraph: translator$s,
|
|
27936
28115
|
text: translateTextNode,
|
|
27937
28116
|
bulletList: translateList,
|
|
27938
28117
|
orderedList: translateList,
|
|
27939
|
-
lineBreak: translator$
|
|
28118
|
+
lineBreak: translator$v,
|
|
27940
28119
|
table: translateTable,
|
|
27941
|
-
tableRow: translator$
|
|
27942
|
-
tableCell: translator$
|
|
28120
|
+
tableRow: translator$e,
|
|
28121
|
+
tableCell: translator$d,
|
|
27943
28122
|
bookmarkStart: translateBookmarkStart,
|
|
27944
|
-
fieldAnnotation: translator,
|
|
27945
|
-
tab: translator$
|
|
28123
|
+
fieldAnnotation: translator$b,
|
|
28124
|
+
tab: translator$t,
|
|
27946
28125
|
image: translateImageNode,
|
|
27947
|
-
hardBreak: translator$
|
|
28126
|
+
hardBreak: translator$v,
|
|
27948
28127
|
commentRangeStart: () => translateCommentNode(params2, "Start"),
|
|
27949
28128
|
commentRangeEnd: () => translateCommentNode(params2, "End"),
|
|
27950
28129
|
commentReference: () => null,
|
|
27951
28130
|
shapeContainer: translateShapeContainer,
|
|
27952
28131
|
shapeTextbox: translateShapeTextbox,
|
|
27953
28132
|
contentBlock: translateContentBlock,
|
|
27954
|
-
structuredContent: translator,
|
|
27955
|
-
structuredContentBlock: translator,
|
|
27956
|
-
documentSection: translator,
|
|
28133
|
+
structuredContent: translator$b,
|
|
28134
|
+
structuredContentBlock: translator$b,
|
|
28135
|
+
documentSection: translator$b,
|
|
27957
28136
|
"page-number": translatePageNumberNode,
|
|
27958
28137
|
"total-page-number": translateTotalPageNumberNode
|
|
27959
28138
|
};
|
|
@@ -28276,7 +28455,7 @@ function translateTextNode(params2) {
|
|
|
28276
28455
|
const isTrackedNode = node.marks?.some((m2) => trackedMarks.includes(m2.type));
|
|
28277
28456
|
if (isTrackedNode) return translateTrackedNode(params2);
|
|
28278
28457
|
const isLinkNode = node.marks?.some((m2) => m2.type === "link");
|
|
28279
|
-
if (isLinkNode) return translator$
|
|
28458
|
+
if (isLinkNode) return translator$c.decode(params2);
|
|
28280
28459
|
const { text, marks = [] } = node;
|
|
28281
28460
|
return getTextNodeForExport(text, marks, params2);
|
|
28282
28461
|
}
|
|
@@ -28761,10 +28940,20 @@ function translateMark(mark) {
|
|
|
28761
28940
|
delete markElement.attributes;
|
|
28762
28941
|
markElement.type = "element";
|
|
28763
28942
|
break;
|
|
28764
|
-
case "underline":
|
|
28765
|
-
|
|
28766
|
-
|
|
28767
|
-
|
|
28943
|
+
case "underline": {
|
|
28944
|
+
const translated = translator$a.decode({
|
|
28945
|
+
node: {
|
|
28946
|
+
attrs: {
|
|
28947
|
+
underlineType: attrs.underlineType ?? attrs.underline ?? null,
|
|
28948
|
+
underlineColor: attrs.underlineColor ?? attrs.color ?? null,
|
|
28949
|
+
underlineThemeColor: attrs.underlineThemeColor ?? attrs.themeColor ?? null,
|
|
28950
|
+
underlineThemeTint: attrs.underlineThemeTint ?? attrs.themeTint ?? null,
|
|
28951
|
+
underlineThemeShade: attrs.underlineThemeShade ?? attrs.themeShade ?? null
|
|
28952
|
+
}
|
|
28953
|
+
}
|
|
28954
|
+
});
|
|
28955
|
+
return translated || {};
|
|
28956
|
+
}
|
|
28768
28957
|
// Text style cases
|
|
28769
28958
|
case "fontSize":
|
|
28770
28959
|
value = attrs.fontSize;
|
|
@@ -28806,12 +28995,11 @@ function translateMark(mark) {
|
|
|
28806
28995
|
case "lineHeight":
|
|
28807
28996
|
markElement.attributes["w:line"] = linesToTwips(attrs.lineHeight);
|
|
28808
28997
|
break;
|
|
28809
|
-
case "highlight":
|
|
28810
|
-
|
|
28811
|
-
|
|
28812
|
-
|
|
28813
|
-
|
|
28814
|
-
break;
|
|
28998
|
+
case "highlight": {
|
|
28999
|
+
const highlightValue = attrs.color ?? attrs.highlight ?? null;
|
|
29000
|
+
const translated = translator$u.decode({ node: { attrs: { highlight: highlightValue } } });
|
|
29001
|
+
return translated || {};
|
|
29002
|
+
}
|
|
28815
29003
|
}
|
|
28816
29004
|
return markElement;
|
|
28817
29005
|
}
|
|
@@ -28848,17 +29036,7 @@ function translateImageNode(params2, imageSize) {
|
|
|
28848
29036
|
let imageId = attrs.rId;
|
|
28849
29037
|
const src = attrs.src || attrs.imageSrc;
|
|
28850
29038
|
const { originalWidth, originalHeight } = getPngDimensions(src);
|
|
28851
|
-
|
|
28852
|
-
if (params2.node.type === "image") {
|
|
28853
|
-
if (src?.startsWith("data:")) {
|
|
28854
|
-
imageName = getFallbackImageNameFromDataUri(src);
|
|
28855
|
-
} else {
|
|
28856
|
-
imageName = src?.split("/").pop();
|
|
28857
|
-
}
|
|
28858
|
-
} else {
|
|
28859
|
-
imageName = attrs.fieldId;
|
|
28860
|
-
}
|
|
28861
|
-
imageName = sanitizeDocxMediaName(imageName);
|
|
29039
|
+
const imageName = params2.node.type === "image" ? src.split("/").pop() : attrs.fieldId?.replace("-", "_");
|
|
28862
29040
|
let size2 = attrs.size ? {
|
|
28863
29041
|
w: pixelsToEmu(attrs.size.width),
|
|
28864
29042
|
h: pixelsToEmu(attrs.size.height)
|
|
@@ -28888,12 +29066,9 @@ function translateImageNode(params2, imageSize) {
|
|
|
28888
29066
|
if (!type2) {
|
|
28889
29067
|
return prepareTextAnnotation(params2);
|
|
28890
29068
|
}
|
|
28891
|
-
const
|
|
28892
|
-
|
|
28893
|
-
|
|
28894
|
-
const packagePath = `word/${relationshipTarget}`;
|
|
28895
|
-
imageId = addNewImageRelationship(params2, relationshipTarget);
|
|
28896
|
-
params2.media[packagePath] = src;
|
|
29069
|
+
const imageUrl = `media/${imageName}_${attrs.hash}.${type2}`;
|
|
29070
|
+
imageId = addNewImageRelationship(params2, imageUrl);
|
|
29071
|
+
params2.media[`${imageName}_${attrs.hash}.${type2}`] = src;
|
|
28897
29072
|
}
|
|
28898
29073
|
let inlineAttrs = attrs.originalPadding || {
|
|
28899
29074
|
distT: 0,
|
|
@@ -29692,82 +29867,912 @@ const trackChangeNodeHandlerEntity = {
|
|
|
29692
29867
|
handlerName: "trackChangeNodeHandler",
|
|
29693
29868
|
handler: handleTrackChangeNode
|
|
29694
29869
|
};
|
|
29695
|
-
const hyperlinkNodeHandlerEntity = generateV2HandlerEntity("hyperlinkNodeHandler", translator$
|
|
29696
|
-
const
|
|
29697
|
-
const
|
|
29698
|
-
if (
|
|
29699
|
-
|
|
29700
|
-
|
|
29870
|
+
const hyperlinkNodeHandlerEntity = generateV2HandlerEntity("hyperlinkNodeHandler", translator$c);
|
|
29871
|
+
const encode$r = (attributes) => {
|
|
29872
|
+
const raw = attributes?.["w:val"];
|
|
29873
|
+
if (raw === void 0 || raw === null) return void 0;
|
|
29874
|
+
if (typeof raw === "boolean") return raw;
|
|
29875
|
+
if (typeof raw === "number") return raw !== 0;
|
|
29876
|
+
const val = String(raw).trim().toLowerCase();
|
|
29877
|
+
if (val === "0" || val === "false" || val === "off") return false;
|
|
29878
|
+
if (val === "1" || val === "true" || val === "on") return true;
|
|
29879
|
+
return void 0;
|
|
29880
|
+
};
|
|
29881
|
+
const decode$i = (runProps) => {
|
|
29882
|
+
if (runProps?.bold === false) return "0";
|
|
29883
|
+
return void 0;
|
|
29884
|
+
};
|
|
29885
|
+
const attrConfig$h = Object.freeze({
|
|
29886
|
+
xmlName: "w:val",
|
|
29887
|
+
sdName: "bold",
|
|
29888
|
+
encode: encode$r,
|
|
29889
|
+
decode: decode$i
|
|
29890
|
+
});
|
|
29891
|
+
const validXmlAttributes$8 = [attrConfig$h];
|
|
29892
|
+
const XML_NODE_NAME$9 = "w:b";
|
|
29893
|
+
const SD_ATTR_KEY$8 = "bold";
|
|
29894
|
+
const encode$q = (params2, encodedAttrs = {}) => {
|
|
29895
|
+
const { nodes } = params2;
|
|
29701
29896
|
const node = nodes[0];
|
|
29702
|
-
|
|
29703
|
-
|
|
29704
|
-
|
|
29705
|
-
|
|
29706
|
-
if (
|
|
29707
|
-
|
|
29708
|
-
|
|
29709
|
-
|
|
29710
|
-
|
|
29711
|
-
|
|
29712
|
-
|
|
29713
|
-
|
|
29714
|
-
|
|
29715
|
-
|
|
29716
|
-
|
|
29717
|
-
|
|
29718
|
-
|
|
29719
|
-
|
|
29720
|
-
|
|
29721
|
-
|
|
29722
|
-
|
|
29723
|
-
|
|
29724
|
-
|
|
29725
|
-
|
|
29726
|
-
|
|
29727
|
-
|
|
29728
|
-
|
|
29729
|
-
|
|
29730
|
-
|
|
29731
|
-
|
|
29732
|
-
|
|
29733
|
-
|
|
29897
|
+
if (!node) return void 0;
|
|
29898
|
+
const val = encodedAttrs?.[SD_ATTR_KEY$8];
|
|
29899
|
+
let attributes;
|
|
29900
|
+
if (val === false) attributes = { "w:val": "0" };
|
|
29901
|
+
else if (val === true)
|
|
29902
|
+
attributes = {};
|
|
29903
|
+
else attributes = node.attributes || {};
|
|
29904
|
+
return {
|
|
29905
|
+
type: "attr",
|
|
29906
|
+
xmlName: XML_NODE_NAME$9,
|
|
29907
|
+
sdNodeOrKeyName: SD_ATTR_KEY$8,
|
|
29908
|
+
attributes
|
|
29909
|
+
};
|
|
29910
|
+
};
|
|
29911
|
+
const config$9 = {
|
|
29912
|
+
xmlName: XML_NODE_NAME$9,
|
|
29913
|
+
sdNodeOrKeyName: SD_ATTR_KEY$8,
|
|
29914
|
+
type: NodeTranslator.translatorTypes.ATTRIBUTE,
|
|
29915
|
+
encode: encode$q,
|
|
29916
|
+
attributes: validXmlAttributes$8
|
|
29917
|
+
};
|
|
29918
|
+
const translator$9 = NodeTranslator.from(config$9);
|
|
29919
|
+
const encode$p = (attributes) => {
|
|
29920
|
+
const raw = attributes?.["w:val"];
|
|
29921
|
+
if (raw === void 0 || raw === null) return void 0;
|
|
29922
|
+
if (typeof raw === "boolean") return raw;
|
|
29923
|
+
if (typeof raw === "number") return raw !== 0;
|
|
29924
|
+
const val = String(raw).trim().toLowerCase();
|
|
29925
|
+
if (val === "0" || val === "false" || val === "off") return false;
|
|
29926
|
+
if (val === "1" || val === "true" || val === "on") return true;
|
|
29927
|
+
return void 0;
|
|
29928
|
+
};
|
|
29929
|
+
const decode$h = (attrs) => {
|
|
29930
|
+
if (attrs?.italic === false) return "0";
|
|
29931
|
+
return void 0;
|
|
29932
|
+
};
|
|
29933
|
+
const attrConfig$g = Object.freeze({
|
|
29934
|
+
xmlName: "w:val",
|
|
29935
|
+
sdName: "italic",
|
|
29936
|
+
encode: encode$p,
|
|
29937
|
+
decode: decode$h
|
|
29938
|
+
});
|
|
29939
|
+
const validXmlAttributes$7 = [attrConfig$g];
|
|
29940
|
+
const XML_NODE_NAME$8 = "w:i";
|
|
29941
|
+
const SD_ATTR_KEY$7 = "italic";
|
|
29942
|
+
const encode$o = (params2, encodedAttrs = {}) => {
|
|
29943
|
+
const { nodes } = params2;
|
|
29944
|
+
const node = nodes?.[0];
|
|
29945
|
+
if (!node) return void 0;
|
|
29946
|
+
const val = encodedAttrs?.[SD_ATTR_KEY$7];
|
|
29947
|
+
let attributes;
|
|
29948
|
+
if (val === false) attributes = { "w:val": "0" };
|
|
29949
|
+
else if (val === true) attributes = {};
|
|
29950
|
+
else attributes = { ...node.attributes || {} };
|
|
29951
|
+
if (attributes["w:val"] === void 0 && val !== true) attributes["w:val"] = null;
|
|
29952
|
+
else if (val === true && attributes["w:val"] === void 0) delete attributes["w:val"];
|
|
29953
|
+
return {
|
|
29954
|
+
type: "attr",
|
|
29955
|
+
xmlName: XML_NODE_NAME$8,
|
|
29956
|
+
sdNodeOrKeyName: SD_ATTR_KEY$7,
|
|
29957
|
+
attributes
|
|
29958
|
+
};
|
|
29959
|
+
};
|
|
29960
|
+
const config$8 = {
|
|
29961
|
+
xmlName: XML_NODE_NAME$8,
|
|
29962
|
+
sdNodeOrKeyName: SD_ATTR_KEY$7,
|
|
29963
|
+
type: NodeTranslator.translatorTypes.ATTRIBUTE,
|
|
29964
|
+
encode: encode$o,
|
|
29965
|
+
attributes: validXmlAttributes$7
|
|
29966
|
+
};
|
|
29967
|
+
const translator$8 = NodeTranslator.from(config$8);
|
|
29968
|
+
const encode$n = (attributes) => {
|
|
29969
|
+
const raw = attributes?.["w:val"];
|
|
29970
|
+
if (raw === void 0 || raw === null) return void 0;
|
|
29971
|
+
if (typeof raw === "boolean") return raw;
|
|
29972
|
+
if (typeof raw === "number") return raw !== 0;
|
|
29973
|
+
const val = String(raw).trim().toLowerCase();
|
|
29974
|
+
if (val === "0" || val === "false" || val === "off") return false;
|
|
29975
|
+
if (val === "1" || val === "true" || val === "on") return true;
|
|
29976
|
+
return void 0;
|
|
29977
|
+
};
|
|
29978
|
+
const decode$g = (attrs) => {
|
|
29979
|
+
if (attrs?.strike === false) return "0";
|
|
29980
|
+
return void 0;
|
|
29981
|
+
};
|
|
29982
|
+
const attrConfig$f = Object.freeze({
|
|
29983
|
+
xmlName: "w:val",
|
|
29984
|
+
sdName: "strike",
|
|
29985
|
+
encode: encode$n,
|
|
29986
|
+
decode: decode$g
|
|
29987
|
+
});
|
|
29988
|
+
const validXmlAttributes$6 = [attrConfig$f];
|
|
29989
|
+
const XML_NODE_NAME$7 = "w:strike";
|
|
29990
|
+
const SD_ATTR_KEY$6 = "strike";
|
|
29991
|
+
const encode$m = (params2, encodedAttrs = {}) => {
|
|
29992
|
+
const { nodes } = params2;
|
|
29993
|
+
const node = nodes?.[0];
|
|
29994
|
+
if (!node) return void 0;
|
|
29995
|
+
const val = encodedAttrs?.[SD_ATTR_KEY$6];
|
|
29996
|
+
let attributes;
|
|
29997
|
+
if (val === false) attributes = { "w:val": "0" };
|
|
29998
|
+
else if (val === true) attributes = {};
|
|
29999
|
+
else attributes = { ...node.attributes || {} };
|
|
30000
|
+
if (attributes["w:val"] === void 0 && val !== true) attributes["w:val"] = null;
|
|
30001
|
+
else if (val === true && attributes["w:val"] === void 0) delete attributes["w:val"];
|
|
30002
|
+
return {
|
|
30003
|
+
type: "attr",
|
|
30004
|
+
xmlName: XML_NODE_NAME$7,
|
|
30005
|
+
sdNodeOrKeyName: SD_ATTR_KEY$6,
|
|
30006
|
+
attributes
|
|
30007
|
+
};
|
|
30008
|
+
};
|
|
30009
|
+
const config$7 = {
|
|
30010
|
+
xmlName: XML_NODE_NAME$7,
|
|
30011
|
+
sdNodeOrKeyName: SD_ATTR_KEY$6,
|
|
30012
|
+
type: NodeTranslator.translatorTypes.ATTRIBUTE,
|
|
30013
|
+
encode: encode$m,
|
|
30014
|
+
attributes: validXmlAttributes$6
|
|
30015
|
+
};
|
|
30016
|
+
const translator$7 = NodeTranslator.from(config$7);
|
|
30017
|
+
const encode$l = (attributes) => attributes?.["w:val"];
|
|
30018
|
+
const decode$f = (attrs) => attrs?.color;
|
|
30019
|
+
const attrConfig$e = Object.freeze({
|
|
30020
|
+
xmlName: "w:val",
|
|
30021
|
+
sdName: "color",
|
|
30022
|
+
encode: encode$l,
|
|
30023
|
+
decode: decode$f
|
|
30024
|
+
});
|
|
30025
|
+
const encode$k = (attributes) => attributes?.["w:themeColor"];
|
|
30026
|
+
const decode$e = (attrs) => attrs?.themeColor;
|
|
30027
|
+
const attrConfig$d = Object.freeze({
|
|
30028
|
+
xmlName: "w:themeColor",
|
|
30029
|
+
sdName: "themeColor",
|
|
30030
|
+
encode: encode$k,
|
|
30031
|
+
decode: decode$e
|
|
30032
|
+
});
|
|
30033
|
+
const encode$j = (attributes) => attributes?.["w:themeTint"];
|
|
30034
|
+
const decode$d = (attrs) => attrs?.themeTint;
|
|
30035
|
+
const attrConfig$c = Object.freeze({
|
|
30036
|
+
xmlName: "w:themeTint",
|
|
30037
|
+
sdName: "themeTint",
|
|
30038
|
+
encode: encode$j,
|
|
30039
|
+
decode: decode$d
|
|
30040
|
+
});
|
|
30041
|
+
const encode$i = (attributes) => attributes?.["w:themeShade"];
|
|
30042
|
+
const decode$c = (attrs) => attrs?.themeShade;
|
|
30043
|
+
const attrConfig$b = Object.freeze({
|
|
30044
|
+
xmlName: "w:themeShade",
|
|
30045
|
+
sdName: "themeShade",
|
|
30046
|
+
encode: encode$i,
|
|
30047
|
+
decode: decode$c
|
|
30048
|
+
});
|
|
30049
|
+
const validXmlAttributes$5 = [attrConfig$e, attrConfig$d, attrConfig$c, attrConfig$b];
|
|
30050
|
+
const XML_NODE_NAME$6 = "w:color";
|
|
30051
|
+
const SD_ATTR_KEY$5 = "color";
|
|
30052
|
+
const encode$h = (params2, encodedAttrs = {}) => {
|
|
30053
|
+
const { nodes } = params2;
|
|
30054
|
+
const node = nodes?.[0];
|
|
30055
|
+
const sourceAttrs = node?.attributes || {};
|
|
30056
|
+
const value = encodedAttrs.color ?? sourceAttrs["w:val"];
|
|
30057
|
+
const themeColor = encodedAttrs.themeColor ?? sourceAttrs["w:themeColor"];
|
|
30058
|
+
const themeTint = encodedAttrs.themeTint ?? sourceAttrs["w:themeTint"];
|
|
30059
|
+
const themeShade = encodedAttrs.themeShade ?? sourceAttrs["w:themeShade"];
|
|
30060
|
+
const attributes = {};
|
|
30061
|
+
attributes["w:val"] = value ?? null;
|
|
30062
|
+
if (themeColor !== void 0 && themeColor !== null) attributes["w:themeColor"] = themeColor;
|
|
30063
|
+
if (themeTint !== void 0 && themeTint !== null) attributes["w:themeTint"] = themeTint;
|
|
30064
|
+
if (themeShade !== void 0 && themeShade !== null) attributes["w:themeShade"] = themeShade;
|
|
30065
|
+
return {
|
|
30066
|
+
type: "attr",
|
|
30067
|
+
xmlName: XML_NODE_NAME$6,
|
|
30068
|
+
sdNodeOrKeyName: SD_ATTR_KEY$5,
|
|
30069
|
+
attributes
|
|
30070
|
+
};
|
|
30071
|
+
};
|
|
30072
|
+
const config$6 = {
|
|
30073
|
+
xmlName: XML_NODE_NAME$6,
|
|
30074
|
+
sdNodeOrKeyName: SD_ATTR_KEY$5,
|
|
30075
|
+
type: NodeTranslator.translatorTypes.ATTRIBUTE,
|
|
30076
|
+
encode: encode$h,
|
|
30077
|
+
attributes: validXmlAttributes$5
|
|
30078
|
+
};
|
|
30079
|
+
const translator$6 = NodeTranslator.from(config$6);
|
|
30080
|
+
const encode$g = (attributes) => attributes?.["w:eastAsia"];
|
|
30081
|
+
const decode$b = (attrs) => attrs?.eastAsia;
|
|
30082
|
+
const attrConfig$a = Object.freeze({
|
|
30083
|
+
xmlName: "w:eastAsia",
|
|
30084
|
+
sdName: "eastAsia",
|
|
30085
|
+
encode: encode$g,
|
|
30086
|
+
decode: decode$b
|
|
30087
|
+
});
|
|
30088
|
+
const encode$f = (attributes) => attributes?.["w:ascii"];
|
|
30089
|
+
const decode$a = (attrs) => attrs?.ascii;
|
|
30090
|
+
const attrConfig$9 = Object.freeze({
|
|
30091
|
+
xmlName: "w:ascii",
|
|
30092
|
+
sdName: "ascii",
|
|
30093
|
+
encode: encode$f,
|
|
30094
|
+
decode: decode$a
|
|
30095
|
+
});
|
|
30096
|
+
const encode$e = (attributes) => attributes?.["w:hAnsi"];
|
|
30097
|
+
const decode$9 = (attrs) => attrs?.hAnsi;
|
|
30098
|
+
const attrConfig$8 = Object.freeze({
|
|
30099
|
+
xmlName: "w:hAnsi",
|
|
30100
|
+
sdName: "hAnsi",
|
|
30101
|
+
encode: encode$e,
|
|
30102
|
+
decode: decode$9
|
|
30103
|
+
});
|
|
30104
|
+
const encode$d = (attributes) => attributes?.["w:cs"];
|
|
30105
|
+
const decode$8 = (attrs) => attrs?.cs;
|
|
30106
|
+
const attrConfig$7 = Object.freeze({
|
|
30107
|
+
xmlName: "w:cs",
|
|
30108
|
+
sdName: "cs",
|
|
30109
|
+
encode: encode$d,
|
|
30110
|
+
decode: decode$8
|
|
30111
|
+
});
|
|
30112
|
+
const encode$c = (attributes) => attributes?.["w:val"];
|
|
30113
|
+
const decode$7 = (attrs) => attrs?.value;
|
|
30114
|
+
const attrConfig$6 = Object.freeze({
|
|
30115
|
+
xmlName: "w:val",
|
|
30116
|
+
sdName: "value",
|
|
30117
|
+
encode: encode$c,
|
|
30118
|
+
decode: decode$7
|
|
30119
|
+
});
|
|
30120
|
+
const validXmlAttributes$4 = [attrConfig$a, attrConfig$9, attrConfig$8, attrConfig$7, attrConfig$6];
|
|
30121
|
+
const XML_NODE_NAME$5 = "w:rFonts";
|
|
30122
|
+
const SD_ATTR_KEY$4 = "fontFamily";
|
|
30123
|
+
const encode$b = (params2, encodedAttrs = {}) => {
|
|
30124
|
+
const { nodes } = params2;
|
|
30125
|
+
const node = nodes?.[0];
|
|
30126
|
+
const sourceAttrs = node?.attributes || {};
|
|
30127
|
+
const attributes = {};
|
|
30128
|
+
const setAttr = (xmlName, sdName) => {
|
|
30129
|
+
if (encodedAttrs[sdName] !== void 0 && encodedAttrs[sdName] !== null) {
|
|
30130
|
+
attributes[xmlName] = encodedAttrs[sdName];
|
|
30131
|
+
} else if (sourceAttrs[xmlName] !== void 0) {
|
|
30132
|
+
attributes[xmlName] = sourceAttrs[xmlName];
|
|
30133
|
+
}
|
|
30134
|
+
};
|
|
30135
|
+
setAttr("w:eastAsia", "eastAsia");
|
|
30136
|
+
setAttr("w:ascii", "ascii");
|
|
30137
|
+
setAttr("w:hAnsi", "hAnsi");
|
|
30138
|
+
setAttr("w:cs", "cs");
|
|
30139
|
+
setAttr("w:val", "value");
|
|
30140
|
+
Object.keys(sourceAttrs).forEach((key) => {
|
|
30141
|
+
if (attributes[key] === void 0) attributes[key] = sourceAttrs[key];
|
|
30142
|
+
});
|
|
30143
|
+
if (attributes["w:val"] === void 0 && attributes["w:eastAsia"]) {
|
|
30144
|
+
attributes["w:val"] = attributes["w:eastAsia"];
|
|
30145
|
+
}
|
|
30146
|
+
if (attributes["w:val"] === void 0) delete attributes["w:val"];
|
|
30147
|
+
return {
|
|
30148
|
+
type: "attr",
|
|
30149
|
+
xmlName: XML_NODE_NAME$5,
|
|
30150
|
+
sdNodeOrKeyName: SD_ATTR_KEY$4,
|
|
30151
|
+
attributes
|
|
30152
|
+
};
|
|
30153
|
+
};
|
|
30154
|
+
const config$5 = {
|
|
30155
|
+
xmlName: XML_NODE_NAME$5,
|
|
30156
|
+
sdNodeOrKeyName: SD_ATTR_KEY$4,
|
|
30157
|
+
type: NodeTranslator.translatorTypes.ATTRIBUTE,
|
|
30158
|
+
encode: encode$b,
|
|
30159
|
+
attributes: validXmlAttributes$4
|
|
30160
|
+
};
|
|
30161
|
+
const translator$5 = NodeTranslator.from(config$5);
|
|
30162
|
+
const encode$a = (attributes) => attributes?.["w:val"];
|
|
30163
|
+
const decode$6 = (attrs) => attrs?.styleId;
|
|
30164
|
+
const attrConfig$5 = Object.freeze({
|
|
30165
|
+
xmlName: "w:val",
|
|
30166
|
+
sdName: "styleId",
|
|
30167
|
+
encode: encode$a,
|
|
30168
|
+
decode: decode$6
|
|
30169
|
+
});
|
|
30170
|
+
const validXmlAttributes$3 = [attrConfig$5];
|
|
30171
|
+
const XML_NODE_NAME$4 = "w:rStyle";
|
|
30172
|
+
const SD_ATTR_KEY$3 = "styleId";
|
|
30173
|
+
const encode$9 = (params2, encodedAttrs = {}) => {
|
|
30174
|
+
const { nodes } = params2;
|
|
30175
|
+
const node = nodes?.[0];
|
|
30176
|
+
const value = encodedAttrs.styleId ?? node?.attributes?.["w:val"];
|
|
30177
|
+
return {
|
|
30178
|
+
type: "attr",
|
|
30179
|
+
xmlName: XML_NODE_NAME$4,
|
|
30180
|
+
sdNodeOrKeyName: SD_ATTR_KEY$3,
|
|
30181
|
+
attributes: { "w:val": value ?? null }
|
|
30182
|
+
};
|
|
30183
|
+
};
|
|
30184
|
+
const config$4 = {
|
|
30185
|
+
xmlName: XML_NODE_NAME$4,
|
|
30186
|
+
sdNodeOrKeyName: SD_ATTR_KEY$3,
|
|
30187
|
+
type: NodeTranslator.translatorTypes.ATTRIBUTE,
|
|
30188
|
+
encode: encode$9,
|
|
30189
|
+
attributes: validXmlAttributes$3
|
|
30190
|
+
};
|
|
30191
|
+
const translator$4 = NodeTranslator.from(config$4);
|
|
30192
|
+
const encode$8 = (attributes) => attributes?.["w:val"];
|
|
30193
|
+
const decode$5 = (attrs) => attrs?.fontSize;
|
|
30194
|
+
const attrConfig$4 = Object.freeze({
|
|
30195
|
+
xmlName: "w:val",
|
|
30196
|
+
sdName: "fontSize",
|
|
30197
|
+
encode: encode$8,
|
|
30198
|
+
decode: decode$5
|
|
30199
|
+
});
|
|
30200
|
+
const validXmlAttributes$2 = [attrConfig$4];
|
|
30201
|
+
const XML_NODE_NAME$3 = "w:sz";
|
|
30202
|
+
const SD_ATTR_KEY$2 = "fontSize";
|
|
30203
|
+
const encode$7 = (params2, encodedAttrs = {}) => {
|
|
30204
|
+
const { nodes } = params2;
|
|
30205
|
+
const node = nodes?.[0];
|
|
30206
|
+
const value = encodedAttrs.fontSize ?? node?.attributes?.["w:val"];
|
|
30207
|
+
return {
|
|
30208
|
+
type: "attr",
|
|
30209
|
+
xmlName: XML_NODE_NAME$3,
|
|
30210
|
+
sdNodeOrKeyName: SD_ATTR_KEY$2,
|
|
30211
|
+
attributes: { "w:val": value ?? null }
|
|
30212
|
+
};
|
|
30213
|
+
};
|
|
30214
|
+
const config$3 = {
|
|
30215
|
+
xmlName: XML_NODE_NAME$3,
|
|
30216
|
+
sdNodeOrKeyName: SD_ATTR_KEY$2,
|
|
30217
|
+
type: NodeTranslator.translatorTypes.ATTRIBUTE,
|
|
30218
|
+
encode: encode$7,
|
|
30219
|
+
attributes: validXmlAttributes$2
|
|
30220
|
+
};
|
|
30221
|
+
const translator$3 = NodeTranslator.from(config$3);
|
|
30222
|
+
const encode$6 = (attributes) => attributes?.["w:val"];
|
|
30223
|
+
const decode$4 = (attrs) => attrs?.fontSizeCs;
|
|
30224
|
+
const attrConfig$3 = Object.freeze({
|
|
30225
|
+
xmlName: "w:val",
|
|
30226
|
+
sdName: "fontSizeCs",
|
|
30227
|
+
encode: encode$6,
|
|
30228
|
+
decode: decode$4
|
|
30229
|
+
});
|
|
30230
|
+
const validXmlAttributes$1 = [attrConfig$3];
|
|
30231
|
+
const XML_NODE_NAME$2 = "w:szCs";
|
|
30232
|
+
const SD_ATTR_KEY$1 = "fontSizeCs";
|
|
30233
|
+
const encode$5 = (params2, encodedAttrs = {}) => {
|
|
30234
|
+
const { nodes } = params2;
|
|
30235
|
+
const node = nodes?.[0];
|
|
30236
|
+
const value = encodedAttrs.fontSizeCs ?? node?.attributes?.["w:val"];
|
|
30237
|
+
return {
|
|
30238
|
+
type: "attr",
|
|
30239
|
+
xmlName: XML_NODE_NAME$2,
|
|
30240
|
+
sdNodeOrKeyName: SD_ATTR_KEY$1,
|
|
30241
|
+
attributes: { "w:val": value ?? null }
|
|
30242
|
+
};
|
|
30243
|
+
};
|
|
30244
|
+
const config$2 = {
|
|
30245
|
+
xmlName: XML_NODE_NAME$2,
|
|
30246
|
+
sdNodeOrKeyName: SD_ATTR_KEY$1,
|
|
30247
|
+
type: NodeTranslator.translatorTypes.ATTRIBUTE,
|
|
30248
|
+
encode: encode$5,
|
|
30249
|
+
attributes: validXmlAttributes$1
|
|
30250
|
+
};
|
|
30251
|
+
const translator$2 = NodeTranslator.from(config$2);
|
|
30252
|
+
const runPropertyTranslators = Object.freeze({
|
|
30253
|
+
"w:b": translator$9,
|
|
30254
|
+
"w:i": translator$8,
|
|
30255
|
+
"w:u": translator$a,
|
|
30256
|
+
"w:strike": translator$7,
|
|
30257
|
+
"w:color": translator$6,
|
|
30258
|
+
"w:highlight": translator$u,
|
|
30259
|
+
"w:rFonts": translator$5,
|
|
30260
|
+
"w:rStyle": translator$4,
|
|
30261
|
+
"w:sz": translator$3,
|
|
30262
|
+
"w:szCs": translator$2
|
|
30263
|
+
});
|
|
30264
|
+
const rawRunPropertyXmlNames = Object.freeze(["w:lang", "w:shd"]);
|
|
30265
|
+
const RAW_CHILD_NAME_SET = new Set(rawRunPropertyXmlNames);
|
|
30266
|
+
const KNOWN_CHILD_XML_NAMES = /* @__PURE__ */ new Set([...Object.keys(runPropertyTranslators), ...RAW_CHILD_NAME_SET]);
|
|
30267
|
+
const toRunPropertyEntry = (candidate) => {
|
|
30268
|
+
if (!candidate || candidate.type !== "attr") return null;
|
|
30269
|
+
const xmlName = candidate.xmlName || candidate.name;
|
|
30270
|
+
if (!xmlName) return null;
|
|
30271
|
+
return {
|
|
30272
|
+
xmlName,
|
|
30273
|
+
attributes: { ...candidate.attributes || {} }
|
|
30274
|
+
};
|
|
30275
|
+
};
|
|
30276
|
+
const XML_NODE_NAME$1 = "w:rPr";
|
|
30277
|
+
const SD_ATTR_KEY = "runProperties";
|
|
30278
|
+
const encode$4 = (params2) => {
|
|
30279
|
+
const { nodes } = params2;
|
|
30280
|
+
const node = nodes?.[0] || {};
|
|
30281
|
+
const contents = Array.isArray(node.elements) ? node.elements : [];
|
|
30282
|
+
const runPropsArray = contents.reduce(
|
|
30283
|
+
(acc, child) => {
|
|
30284
|
+
if (!child || typeof child !== "object") return acc;
|
|
30285
|
+
const xmlName = child.name;
|
|
30286
|
+
if (!KNOWN_CHILD_XML_NAMES.has(xmlName)) return acc;
|
|
30287
|
+
const translator2 = runPropertyTranslators[xmlName];
|
|
30288
|
+
let entry = null;
|
|
30289
|
+
if (translator2) {
|
|
30290
|
+
const encoded = translator2.encode({ ...params2, nodes: [child] }) || null;
|
|
30291
|
+
entry = toRunPropertyEntry(encoded);
|
|
30292
|
+
} else if (RAW_CHILD_NAME_SET.has(xmlName)) {
|
|
30293
|
+
entry = toRunPropertyEntry({
|
|
30294
|
+
type: "attr",
|
|
30295
|
+
xmlName,
|
|
30296
|
+
attributes: { ...child.attributes || {} }
|
|
30297
|
+
});
|
|
29734
30298
|
}
|
|
30299
|
+
if (entry) acc.push(entry);
|
|
30300
|
+
return acc;
|
|
30301
|
+
},
|
|
30302
|
+
/** @type {{ xmlName: string, attributes: Record<string, any> }[]} */
|
|
30303
|
+
[]
|
|
30304
|
+
);
|
|
30305
|
+
return {
|
|
30306
|
+
type: "attr",
|
|
30307
|
+
xmlName: "w:rPr",
|
|
30308
|
+
sdNodeOrKeyName: "runProperties",
|
|
30309
|
+
attributes: runPropsArray
|
|
30310
|
+
};
|
|
30311
|
+
};
|
|
30312
|
+
const config$1 = {
|
|
30313
|
+
xmlName: XML_NODE_NAME$1,
|
|
30314
|
+
sdNodeOrKeyName: SD_ATTR_KEY,
|
|
30315
|
+
type: NodeTranslator.translatorTypes.ATTRIBUTE,
|
|
30316
|
+
encode: encode$4
|
|
30317
|
+
};
|
|
30318
|
+
const translator$1 = NodeTranslator.from(config$1);
|
|
30319
|
+
const collectRunProperties = (params2, rPrNode, translator2 = translator$1) => {
|
|
30320
|
+
if (!rPrNode) return { entries: [], hadRPr: false, styleChangeMarks: [] };
|
|
30321
|
+
const result = translator2.encode({ ...params2, nodes: [rPrNode] }) || {};
|
|
30322
|
+
let entries = [];
|
|
30323
|
+
if (Array.isArray(result.attributes) && result.attributes.length) {
|
|
30324
|
+
entries = result.attributes.map((attr) => ({
|
|
30325
|
+
xmlName: attr?.xmlName,
|
|
30326
|
+
attributes: { ...attr?.attributes || {} }
|
|
30327
|
+
}));
|
|
30328
|
+
} else if (Array.isArray(rPrNode.elements) && rPrNode.elements.length) {
|
|
30329
|
+
entries = rPrNode.elements.filter((el) => el && typeof el === "object").map((el) => ({
|
|
30330
|
+
xmlName: el.name,
|
|
30331
|
+
attributes: { ...el.attributes || {} }
|
|
30332
|
+
}));
|
|
30333
|
+
}
|
|
30334
|
+
const legacyMarks = parseMarks(rPrNode, [], params2?.docx) || [];
|
|
30335
|
+
const styleChangeMarks = handleStyleChangeMarks(rPrNode, legacyMarks) || [];
|
|
30336
|
+
return { entries, hadRPr: true, styleChangeMarks };
|
|
30337
|
+
};
|
|
30338
|
+
const buildRunAttrs = (encodedAttrs = {}, hadRPr, runProps) => {
|
|
30339
|
+
const base2 = { ...encodedAttrs || {} };
|
|
30340
|
+
if (hadRPr) {
|
|
30341
|
+
base2.runProperties = runProps.length ? runProps : null;
|
|
30342
|
+
}
|
|
30343
|
+
return base2;
|
|
30344
|
+
};
|
|
30345
|
+
const ensureRunMark = (marks, runAttrs) => {
|
|
30346
|
+
if (!runAttrs) return;
|
|
30347
|
+
const runMark = createRunMark(runAttrs);
|
|
30348
|
+
const runMarkIndex = marks.findIndex((mark) => mark?.type === "run");
|
|
30349
|
+
if (runMarkIndex >= 0) {
|
|
30350
|
+
const existing = marks[runMarkIndex];
|
|
30351
|
+
if (runMark.attrs) {
|
|
30352
|
+
marks[runMarkIndex] = { ...existing, attrs: mergeRunAttrs(existing?.attrs, runMark.attrs) };
|
|
30353
|
+
}
|
|
30354
|
+
return;
|
|
30355
|
+
}
|
|
30356
|
+
marks.push(runMark);
|
|
30357
|
+
};
|
|
30358
|
+
const ensureInlineMarks = (marks, inlineMarks = []) => {
|
|
30359
|
+
inlineMarks.forEach(({ type: type2, attrs }) => {
|
|
30360
|
+
if (!type2) return;
|
|
30361
|
+
if (marks.some((mark) => mark?.type === type2)) return;
|
|
30362
|
+
marks.push(attrs ? { type: type2, attrs: { ...attrs } } : { type: type2 });
|
|
30363
|
+
});
|
|
30364
|
+
};
|
|
30365
|
+
const ensureTextStyleMark = (marks, textStyleAttrs) => {
|
|
30366
|
+
if (!textStyleAttrs) return;
|
|
30367
|
+
const existingTextStyle = marks.find((mark) => mark?.type === "textStyle");
|
|
30368
|
+
if (existingTextStyle) {
|
|
30369
|
+
existingTextStyle.attrs = { ...existingTextStyle.attrs || {}, ...textStyleAttrs };
|
|
30370
|
+
return;
|
|
30371
|
+
}
|
|
30372
|
+
marks.push({ type: "textStyle", attrs: { ...textStyleAttrs } });
|
|
30373
|
+
};
|
|
30374
|
+
const applyRunMarks = (node, runAttrs, inlineMarks, textStyleAttrs) => {
|
|
30375
|
+
if (!node || typeof node !== "object") return node;
|
|
30376
|
+
const baseMarks = Array.isArray(node.marks) ? node.marks : [];
|
|
30377
|
+
const marks = baseMarks.map((mark) => cloneMark(mark));
|
|
30378
|
+
ensureRunMark(marks, runAttrs);
|
|
30379
|
+
ensureInlineMarks(marks, inlineMarks);
|
|
30380
|
+
if (node.type === "text") {
|
|
30381
|
+
ensureTextStyleMark(marks, textStyleAttrs);
|
|
30382
|
+
}
|
|
30383
|
+
return { ...node, marks };
|
|
30384
|
+
};
|
|
30385
|
+
const createRunMark = (attrs = {}) => {
|
|
30386
|
+
const hasAttrs = attrs && Object.keys(attrs).length > 0;
|
|
30387
|
+
return hasAttrs ? { type: "run", attrs: cloneRunAttrs(attrs) } : { type: "run" };
|
|
30388
|
+
};
|
|
30389
|
+
const deriveStyleMarks = ({ docx, paragraphStyleId, runStyleId }) => {
|
|
30390
|
+
const paragraphStyleMarks = collectStyleMarks(paragraphStyleId, docx);
|
|
30391
|
+
const runStyleMarks = collectStyleMarks(runStyleId, docx);
|
|
30392
|
+
const inlineMarks = mergeInlineMarkSets(paragraphStyleMarks.inlineMarks, runStyleMarks.inlineMarks);
|
|
30393
|
+
const textStyleAttrs = mergeTextStyleAttrs(paragraphStyleMarks.textStyleAttrs, runStyleMarks.textStyleAttrs);
|
|
30394
|
+
return { inlineMarks, textStyleAttrs };
|
|
30395
|
+
};
|
|
30396
|
+
const collectStyleMarks = (styleId, docx, seen = /* @__PURE__ */ new Set()) => {
|
|
30397
|
+
if (!styleId || !docx || seen.has(styleId)) return { inlineMarks: [], textStyleAttrs: null };
|
|
30398
|
+
seen.add(styleId);
|
|
30399
|
+
const chain = collectStyleChain(styleId, docx, seen);
|
|
30400
|
+
if (!chain.length) return { inlineMarks: [], textStyleAttrs: null };
|
|
30401
|
+
const inlineMap = /* @__PURE__ */ new Map();
|
|
30402
|
+
let textStyleAttrs = {};
|
|
30403
|
+
chain.forEach((styleTag) => {
|
|
30404
|
+
const marks = extractMarksFromStyle(styleTag, docx);
|
|
30405
|
+
marks.inlineMarks.forEach((mark) => {
|
|
30406
|
+
inlineMap.set(mark.type, mark.attrs ? { type: mark.type, attrs: { ...mark.attrs } } : { type: mark.type });
|
|
29735
30407
|
});
|
|
30408
|
+
if (marks.textStyleAttrs) textStyleAttrs = { ...textStyleAttrs, ...marks.textStyleAttrs };
|
|
30409
|
+
});
|
|
30410
|
+
return {
|
|
30411
|
+
inlineMarks: Array.from(inlineMap.values()),
|
|
30412
|
+
textStyleAttrs: Object.keys(textStyleAttrs).length ? textStyleAttrs : null
|
|
30413
|
+
};
|
|
30414
|
+
};
|
|
30415
|
+
const collectStyleChain = (styleId, docx, seen) => {
|
|
30416
|
+
if (!styleId || !docx) return [];
|
|
30417
|
+
const styleTag = findStyleTag(docx, styleId);
|
|
30418
|
+
if (!styleTag || !styleTag.elements) return [];
|
|
30419
|
+
const basedOn = styleTag.elements?.find((el) => el.name === "w:basedOn")?.attributes?.["w:val"];
|
|
30420
|
+
let chain = [];
|
|
30421
|
+
if (basedOn && !seen.has(basedOn)) {
|
|
30422
|
+
seen.add(basedOn);
|
|
30423
|
+
chain = collectStyleChain(basedOn, docx, seen);
|
|
30424
|
+
}
|
|
30425
|
+
chain.push(styleTag);
|
|
30426
|
+
return chain;
|
|
30427
|
+
};
|
|
30428
|
+
const findStyleTag = (docx, styleId) => {
|
|
30429
|
+
const stylesFile = docx?.["word/styles.xml"];
|
|
30430
|
+
if (!stylesFile?.elements?.length) return null;
|
|
30431
|
+
const candidates = [];
|
|
30432
|
+
stylesFile.elements.forEach((el) => {
|
|
30433
|
+
if (!el) return;
|
|
30434
|
+
if (el.name === "w:styles" && Array.isArray(el.elements)) {
|
|
30435
|
+
el.elements.forEach((child) => {
|
|
30436
|
+
if (child?.name === "w:style") candidates.push(child);
|
|
30437
|
+
});
|
|
30438
|
+
return;
|
|
30439
|
+
}
|
|
30440
|
+
if (el.name === "w:style") {
|
|
30441
|
+
candidates.push(el);
|
|
30442
|
+
return;
|
|
30443
|
+
}
|
|
30444
|
+
if (Array.isArray(el.elements)) {
|
|
30445
|
+
el.elements.forEach((child) => {
|
|
30446
|
+
if (child?.name === "w:style") candidates.push(child);
|
|
30447
|
+
});
|
|
30448
|
+
}
|
|
30449
|
+
});
|
|
30450
|
+
return candidates.find((tag) => tag?.attributes?.["w:styleId"] === styleId) || null;
|
|
30451
|
+
};
|
|
30452
|
+
const extractMarksFromStyle = (styleTag, docx) => {
|
|
30453
|
+
const rPr = styleTag?.elements?.find((el) => el.name === "w:rPr");
|
|
30454
|
+
if (!rPr) return { inlineMarks: [], textStyleAttrs: null };
|
|
30455
|
+
const marks = parseMarks(rPr, [], docx) || [];
|
|
30456
|
+
const inlineMarks = [];
|
|
30457
|
+
let textStyleAttrs = {};
|
|
30458
|
+
marks.forEach((mark) => {
|
|
30459
|
+
if (!mark) return;
|
|
30460
|
+
if (mark.type === "textStyle") {
|
|
30461
|
+
const attrs = mark.attrs || {};
|
|
30462
|
+
if (Object.keys(attrs).length) textStyleAttrs = { ...textStyleAttrs, ...attrs };
|
|
30463
|
+
return;
|
|
30464
|
+
}
|
|
30465
|
+
if (mark.type) inlineMarks.push(mark.attrs ? { type: mark.type, attrs: { ...mark.attrs } } : { type: mark.type });
|
|
30466
|
+
});
|
|
30467
|
+
return {
|
|
30468
|
+
inlineMarks,
|
|
30469
|
+
textStyleAttrs: Object.keys(textStyleAttrs).length ? textStyleAttrs : null
|
|
30470
|
+
};
|
|
30471
|
+
};
|
|
30472
|
+
const mergeInlineMarkSets = (...markSets) => {
|
|
30473
|
+
const map3 = /* @__PURE__ */ new Map();
|
|
30474
|
+
markSets.filter(Boolean).forEach((marks) => {
|
|
29736
30475
|
marks.forEach((mark) => {
|
|
29737
|
-
|
|
29738
|
-
|
|
29739
|
-
);
|
|
29740
|
-
if (!exists2) {
|
|
29741
|
-
combinedMarks.push(mark);
|
|
29742
|
-
}
|
|
30476
|
+
if (!mark || !mark.type) return;
|
|
30477
|
+
map3.set(mark.type, mark.attrs ? { type: mark.type, attrs: { ...mark.attrs } } : { type: mark.type });
|
|
29743
30478
|
});
|
|
29744
|
-
|
|
29745
|
-
|
|
29746
|
-
|
|
29747
|
-
|
|
29748
|
-
|
|
29749
|
-
|
|
29750
|
-
|
|
29751
|
-
|
|
29752
|
-
|
|
30479
|
+
});
|
|
30480
|
+
return Array.from(map3.values());
|
|
30481
|
+
};
|
|
30482
|
+
const mergeTextStyleAttrs = (...attrsList) => {
|
|
30483
|
+
const merged = attrsList.filter((attrs) => attrs && Object.keys(attrs).length).reduce((acc, attrs) => ({ ...acc, ...attrs }), {});
|
|
30484
|
+
return Object.keys(merged).length ? merged : null;
|
|
30485
|
+
};
|
|
30486
|
+
const cloneRunAttrs = (attrs) => {
|
|
30487
|
+
const clone = { ...attrs };
|
|
30488
|
+
if (Array.isArray(attrs?.runProperties)) {
|
|
30489
|
+
clone.runProperties = attrs.runProperties.map((entry) => ({
|
|
30490
|
+
xmlName: entry?.xmlName,
|
|
30491
|
+
attributes: { ...entry?.attributes || {} }
|
|
30492
|
+
}));
|
|
30493
|
+
}
|
|
30494
|
+
return clone;
|
|
30495
|
+
};
|
|
30496
|
+
const cloneMark = (mark) => {
|
|
30497
|
+
if (!mark || typeof mark !== "object") return mark;
|
|
30498
|
+
const cloned = { ...mark };
|
|
30499
|
+
if (mark.attrs && typeof mark.attrs === "object") {
|
|
30500
|
+
cloned.attrs = { ...mark.attrs };
|
|
30501
|
+
if (Array.isArray(mark.attrs.runProperties)) {
|
|
30502
|
+
cloned.attrs.runProperties = mark.attrs.runProperties.map((entry) => ({
|
|
30503
|
+
xmlName: entry?.xmlName,
|
|
30504
|
+
attributes: { ...entry?.attributes || {} }
|
|
30505
|
+
}));
|
|
30506
|
+
}
|
|
30507
|
+
}
|
|
30508
|
+
return cloned;
|
|
30509
|
+
};
|
|
30510
|
+
const mergeRunAttrs = (existing = {}, incoming = {}) => {
|
|
30511
|
+
const merged = { ...existing, ...cloneRunAttrs(incoming) };
|
|
30512
|
+
if (Array.isArray(existing?.runProperties) && Array.isArray(incoming?.runProperties)) {
|
|
30513
|
+
const seen = /* @__PURE__ */ new Set();
|
|
30514
|
+
const combined = [...existing.runProperties, ...incoming.runProperties];
|
|
30515
|
+
merged.runProperties = combined.filter((entry) => {
|
|
30516
|
+
const key = entry?.xmlName;
|
|
30517
|
+
if (!key || seen.has(key)) return false;
|
|
30518
|
+
seen.add(key);
|
|
30519
|
+
return true;
|
|
29753
30520
|
});
|
|
29754
30521
|
}
|
|
29755
|
-
return
|
|
30522
|
+
return merged;
|
|
29756
30523
|
};
|
|
29757
|
-
const
|
|
29758
|
-
|
|
29759
|
-
if (
|
|
29760
|
-
|
|
30524
|
+
const normalizeBool = (value) => {
|
|
30525
|
+
if (value === void 0 || value === null) return true;
|
|
30526
|
+
if (typeof value === "boolean") return value;
|
|
30527
|
+
if (typeof value === "number") return value !== 0;
|
|
30528
|
+
const normalized = String(value).trim().toLowerCase();
|
|
30529
|
+
if (normalized === "0" || normalized === "false" || normalized === "off") return false;
|
|
30530
|
+
if (normalized === "1" || normalized === "true" || normalized === "on") return true;
|
|
30531
|
+
return true;
|
|
30532
|
+
};
|
|
30533
|
+
const resolveRunElement = (node) => {
|
|
30534
|
+
if (!node) return null;
|
|
30535
|
+
if (node.name === "w:r") return node;
|
|
30536
|
+
return (node.elements || []).find((el) => el.name === "w:r") || null;
|
|
30537
|
+
};
|
|
30538
|
+
const ensureRunPropertiesContainer = (runElement) => {
|
|
30539
|
+
if (!Array.isArray(runElement.elements)) runElement.elements = [];
|
|
30540
|
+
let rPr = runElement.elements.find((el) => el.name === "w:rPr");
|
|
30541
|
+
if (!rPr) {
|
|
30542
|
+
rPr = { name: "w:rPr", elements: [] };
|
|
30543
|
+
runElement.elements.unshift(rPr);
|
|
30544
|
+
}
|
|
30545
|
+
if (!Array.isArray(rPr.elements)) rPr.elements = [];
|
|
30546
|
+
return rPr;
|
|
30547
|
+
};
|
|
30548
|
+
const splitRunProperties = (entries = [], docx = null) => {
|
|
30549
|
+
const remainingProps = [];
|
|
30550
|
+
const inlineMarks = [];
|
|
30551
|
+
const textStyleAttrs = {};
|
|
30552
|
+
let hasTextStyle = false;
|
|
30553
|
+
let highlightColor = null;
|
|
30554
|
+
let runStyleId = null;
|
|
30555
|
+
entries.forEach((entry) => {
|
|
30556
|
+
if (!entry || !entry.xmlName) return;
|
|
30557
|
+
const attributes = entry.attributes || {};
|
|
30558
|
+
switch (entry.xmlName) {
|
|
30559
|
+
case "w:b": {
|
|
30560
|
+
const val = normalizeBool(attributes["w:val"]);
|
|
30561
|
+
inlineMarks.push(val ? { type: "bold" } : { type: "bold", attrs: { value: "0" } });
|
|
30562
|
+
break;
|
|
30563
|
+
}
|
|
30564
|
+
case "w:i": {
|
|
30565
|
+
const val = normalizeBool(attributes["w:val"]);
|
|
30566
|
+
inlineMarks.push(val ? { type: "italic" } : { type: "italic", attrs: { value: "0" } });
|
|
30567
|
+
break;
|
|
30568
|
+
}
|
|
30569
|
+
case "w:u": {
|
|
30570
|
+
const rawVal = attributes["w:val"];
|
|
30571
|
+
const underlineType = rawVal == null || rawVal === "" ? "single" : String(rawVal);
|
|
30572
|
+
const attrs = {};
|
|
30573
|
+
if (underlineType.toLowerCase() === "none" || underlineType === "0") {
|
|
30574
|
+
attrs.underlineType = "none";
|
|
30575
|
+
} else {
|
|
30576
|
+
attrs.underlineType = underlineType;
|
|
30577
|
+
const colorRaw = attributes["w:color"];
|
|
30578
|
+
if (typeof colorRaw === "string" && colorRaw.toLowerCase() !== "auto") {
|
|
30579
|
+
const normalizedColor = normalizeHexColor(colorRaw);
|
|
30580
|
+
if (normalizedColor) attrs.underlineColor = `#${normalizedColor}`;
|
|
30581
|
+
}
|
|
30582
|
+
}
|
|
30583
|
+
if (attributes["w:themeColor"]) attrs.underlineThemeColor = attributes["w:themeColor"];
|
|
30584
|
+
if (attributes["w:themeTint"]) attrs.underlineThemeTint = attributes["w:themeTint"];
|
|
30585
|
+
if (attributes["w:themeShade"]) attrs.underlineThemeShade = attributes["w:themeShade"];
|
|
30586
|
+
inlineMarks.push({ type: "underline", attrs });
|
|
30587
|
+
break;
|
|
30588
|
+
}
|
|
30589
|
+
case "w:color": {
|
|
30590
|
+
const raw = attributes["w:val"];
|
|
30591
|
+
if (typeof raw === "string" && raw) {
|
|
30592
|
+
hasTextStyle = true;
|
|
30593
|
+
textStyleAttrs.color = `#${raw.replace("#", "").toUpperCase()}`;
|
|
30594
|
+
}
|
|
30595
|
+
break;
|
|
30596
|
+
}
|
|
30597
|
+
case "w:rFonts": {
|
|
30598
|
+
const family = attributes["w:ascii"] || attributes["w:eastAsia"] || attributes["w:hAnsi"] || attributes["w:val"];
|
|
30599
|
+
if (family) {
|
|
30600
|
+
hasTextStyle = true;
|
|
30601
|
+
textStyleAttrs.fontFamily = SuperConverter.toCssFontFamily(family, docx);
|
|
30602
|
+
}
|
|
30603
|
+
break;
|
|
30604
|
+
}
|
|
30605
|
+
case "w:sz":
|
|
30606
|
+
case "w:szCs": {
|
|
30607
|
+
const rawSize = Number(attributes["w:val"]);
|
|
30608
|
+
if (Number.isFinite(rawSize) && rawSize > 0) {
|
|
30609
|
+
hasTextStyle = true;
|
|
30610
|
+
textStyleAttrs.fontSize = `${rawSize / 2}pt`;
|
|
30611
|
+
}
|
|
30612
|
+
break;
|
|
30613
|
+
}
|
|
30614
|
+
case "w:strike": {
|
|
30615
|
+
const val = normalizeBool(attributes["w:val"]);
|
|
30616
|
+
inlineMarks.push(val ? { type: "strike" } : { type: "strike", attrs: { value: "0" } });
|
|
30617
|
+
break;
|
|
30618
|
+
}
|
|
30619
|
+
case "w:highlight": {
|
|
30620
|
+
const color = attributes["w:val"];
|
|
30621
|
+
if (typeof color === "string" && color) {
|
|
30622
|
+
highlightColor = color.toLowerCase() === "none" ? "transparent" : color;
|
|
30623
|
+
}
|
|
30624
|
+
break;
|
|
30625
|
+
}
|
|
30626
|
+
case "w:shd": {
|
|
30627
|
+
const fill = attributes["w:fill"];
|
|
30628
|
+
const shdVal = attributes["w:val"];
|
|
30629
|
+
if (fill && String(fill).toLowerCase() !== "auto") {
|
|
30630
|
+
highlightColor = `#${String(fill).replace("#", "")}`;
|
|
30631
|
+
} else if (typeof shdVal === "string") {
|
|
30632
|
+
const normalized = shdVal.toLowerCase();
|
|
30633
|
+
if (normalized === "clear" || normalized === "nil" || normalized === "none") {
|
|
30634
|
+
highlightColor = "transparent";
|
|
30635
|
+
}
|
|
30636
|
+
}
|
|
30637
|
+
break;
|
|
30638
|
+
}
|
|
30639
|
+
case "w:rStyle": {
|
|
30640
|
+
if (typeof attributes["w:val"] === "string") runStyleId = attributes["w:val"];
|
|
30641
|
+
remainingProps.push({ xmlName: entry.xmlName, attributes: { ...attributes } });
|
|
30642
|
+
break;
|
|
30643
|
+
}
|
|
30644
|
+
default: {
|
|
30645
|
+
remainingProps.push({ xmlName: entry.xmlName, attributes: { ...attributes } });
|
|
30646
|
+
}
|
|
30647
|
+
}
|
|
30648
|
+
});
|
|
30649
|
+
if (highlightColor) inlineMarks.push({ type: "highlight", attrs: { color: highlightColor } });
|
|
30650
|
+
return {
|
|
30651
|
+
remainingProps,
|
|
30652
|
+
inlineMarks,
|
|
30653
|
+
textStyleAttrs: hasTextStyle ? textStyleAttrs : null,
|
|
30654
|
+
runStyleId
|
|
30655
|
+
};
|
|
30656
|
+
};
|
|
30657
|
+
const encode$3 = (attributes) => {
|
|
30658
|
+
return attributes["w:rsidR"];
|
|
30659
|
+
};
|
|
30660
|
+
const decode$3 = (attrs) => {
|
|
30661
|
+
return attrs.rsidR;
|
|
30662
|
+
};
|
|
30663
|
+
const attrConfig$2 = Object.freeze({
|
|
30664
|
+
xmlName: "w:rsidR",
|
|
30665
|
+
sdName: "rsidR",
|
|
30666
|
+
encode: encode$3,
|
|
30667
|
+
decode: decode$3
|
|
30668
|
+
});
|
|
30669
|
+
const encode$2 = (attributes) => {
|
|
30670
|
+
return attributes["w:rsidRPr"];
|
|
30671
|
+
};
|
|
30672
|
+
const decode$2 = (attrs) => {
|
|
30673
|
+
return attrs.rsidRPr;
|
|
30674
|
+
};
|
|
30675
|
+
const attrConfig$1 = Object.freeze({
|
|
30676
|
+
xmlName: "w:rsidRPr",
|
|
30677
|
+
sdName: "rsidRPr",
|
|
30678
|
+
encode: encode$2,
|
|
30679
|
+
decode: decode$2
|
|
30680
|
+
});
|
|
30681
|
+
const encode$1 = (attributes) => {
|
|
30682
|
+
return attributes["w:rsidDel"];
|
|
30683
|
+
};
|
|
30684
|
+
const decode$1 = (attrs) => {
|
|
30685
|
+
return attrs.rsidDel;
|
|
30686
|
+
};
|
|
30687
|
+
const attrConfig = Object.freeze({
|
|
30688
|
+
xmlName: "w:rsidDel",
|
|
30689
|
+
sdName: "rsidDel",
|
|
30690
|
+
encode: encode$1,
|
|
30691
|
+
decode: decode$1
|
|
30692
|
+
});
|
|
30693
|
+
const validXmlAttributes = [attrConfig$2, attrConfig$1, attrConfig];
|
|
30694
|
+
const XML_NODE_NAME = "w:r";
|
|
30695
|
+
const SD_KEY_NAME = "run";
|
|
30696
|
+
const encode$U = (params2, encodedAttrs = {}) => {
|
|
30697
|
+
const { nodes = [], nodeListHandler } = params2 || {};
|
|
30698
|
+
const runNode = nodes[0];
|
|
30699
|
+
if (!runNode) return void 0;
|
|
30700
|
+
const elements = Array.isArray(runNode.elements) ? runNode.elements : [];
|
|
30701
|
+
const rPrNode = elements.find((child) => child?.name === "w:rPr");
|
|
30702
|
+
const contentElements = rPrNode ? elements.filter((el) => el !== rPrNode) : elements;
|
|
30703
|
+
const { entries: runPropEntries, hadRPr, styleChangeMarks } = collectRunProperties(params2, rPrNode);
|
|
30704
|
+
const { remainingProps, inlineMarks, textStyleAttrs, runStyleId } = splitRunProperties(runPropEntries, params2?.docx);
|
|
30705
|
+
const styleMarks = deriveStyleMarks({
|
|
30706
|
+
docx: params2?.docx,
|
|
30707
|
+
paragraphStyleId: params2?.parentStyleId,
|
|
30708
|
+
runStyleId
|
|
30709
|
+
});
|
|
30710
|
+
const mergedInlineMarks = mergeInlineMarkSets(styleMarks.inlineMarks, inlineMarks);
|
|
30711
|
+
let mergedTextStyleAttrs = mergeTextStyleAttrs(styleMarks.textStyleAttrs, textStyleAttrs);
|
|
30712
|
+
if (runStyleId) {
|
|
30713
|
+
mergedTextStyleAttrs = mergedTextStyleAttrs ? { ...mergedTextStyleAttrs, styleId: runStyleId } : { styleId: runStyleId };
|
|
30714
|
+
}
|
|
30715
|
+
const runAttrs = buildRunAttrs(encodedAttrs, hadRPr, remainingProps);
|
|
30716
|
+
let runLevelMarks = Array.isArray(runNode.marks) ? runNode.marks.map((mark) => cloneMark(mark)) : [];
|
|
30717
|
+
if (styleChangeMarks?.length) {
|
|
30718
|
+
runLevelMarks = [...runLevelMarks, ...styleChangeMarks.map((mark) => cloneMark(mark))];
|
|
30719
|
+
}
|
|
30720
|
+
const childParams = { ...params2, nodes: contentElements };
|
|
30721
|
+
const content = nodeListHandler?.handler(childParams) || [];
|
|
30722
|
+
const contentWithRunMarks = content.map((child) => {
|
|
30723
|
+
if (!child || typeof child !== "object") return child;
|
|
30724
|
+
const baseMarks = Array.isArray(child.marks) ? child.marks.map((mark) => cloneMark(mark)) : [];
|
|
30725
|
+
if (!runLevelMarks.length) return child;
|
|
30726
|
+
return { ...child, marks: [...baseMarks, ...runLevelMarks.map((mark) => cloneMark(mark))] };
|
|
30727
|
+
});
|
|
30728
|
+
const marked = contentWithRunMarks.map(
|
|
30729
|
+
(child) => applyRunMarks(child, runAttrs, mergedInlineMarks, mergedTextStyleAttrs)
|
|
30730
|
+
);
|
|
30731
|
+
const filtered = marked.filter(Boolean);
|
|
30732
|
+
if (!filtered.length) return [];
|
|
30733
|
+
if (filtered.length === 1) return filtered[0];
|
|
30734
|
+
return filtered;
|
|
30735
|
+
};
|
|
30736
|
+
const decode = (params2, decodedAttrs = {}) => {
|
|
30737
|
+
const { node } = params2 || {};
|
|
30738
|
+
if (!node) return void 0;
|
|
30739
|
+
const marks = Array.isArray(node.marks) ? node.marks : [];
|
|
30740
|
+
const runMarkIndex = marks.findIndex((mark) => mark?.type === SD_KEY_NAME);
|
|
30741
|
+
const runMark = runMarkIndex >= 0 ? marks[runMarkIndex] : void 0;
|
|
30742
|
+
const strippedMarks = marks.filter((_2, idx) => idx !== runMarkIndex);
|
|
30743
|
+
const exportNode = { ...node, marks: strippedMarks };
|
|
30744
|
+
const exportParams = { ...params2, node: exportNode };
|
|
30745
|
+
if (!exportParams.editor) {
|
|
30746
|
+
exportParams.editor = { extensionService: { extensions: [] } };
|
|
30747
|
+
}
|
|
30748
|
+
const translated = exportSchemaToJson(exportParams);
|
|
30749
|
+
if (!translated) return void 0;
|
|
30750
|
+
const runElement = resolveRunElement(translated);
|
|
30751
|
+
if (!runElement) return translated;
|
|
30752
|
+
runElement.attributes = { ...runElement.attributes || {}, ...decodedAttrs };
|
|
30753
|
+
const runProperties = Array.isArray(runMark?.attrs?.runProperties) ? runMark.attrs.runProperties : null;
|
|
30754
|
+
if (runProperties && runProperties.length) {
|
|
30755
|
+
const rPr = ensureRunPropertiesContainer(runElement);
|
|
30756
|
+
const existingNames = new Set((rPr.elements || []).map((el) => el.name));
|
|
30757
|
+
runProperties.forEach((entry) => {
|
|
30758
|
+
if (!entry || !entry.xmlName || entry.xmlName === "w:b") return;
|
|
30759
|
+
if (existingNames.has(entry.xmlName)) return;
|
|
30760
|
+
rPr.elements.push({ name: entry.xmlName, attributes: { ...entry.attributes || {} } });
|
|
30761
|
+
existingNames.add(entry.xmlName);
|
|
30762
|
+
});
|
|
29761
30763
|
}
|
|
29762
|
-
|
|
29763
|
-
const style2 = styleTags.find((tag) => tag.attributes["w:styleId"] === styleId) || {};
|
|
29764
|
-
if (!style2) return {};
|
|
29765
|
-
return parseProperties(style2);
|
|
30764
|
+
return translated;
|
|
29766
30765
|
};
|
|
29767
|
-
const
|
|
29768
|
-
|
|
29769
|
-
|
|
30766
|
+
const config = {
|
|
30767
|
+
xmlName: XML_NODE_NAME,
|
|
30768
|
+
sdNodeOrKeyName: SD_KEY_NAME,
|
|
30769
|
+
type: NodeTranslator.translatorTypes.NODE,
|
|
30770
|
+
encode: encode$U,
|
|
30771
|
+
decode,
|
|
30772
|
+
attributes: validXmlAttributes
|
|
29770
30773
|
};
|
|
30774
|
+
const translator = NodeTranslator.from(config);
|
|
30775
|
+
const runNodeHandlerEntity = generateV2HandlerEntity("runNodeHandler", translator);
|
|
29771
30776
|
const handleTextNode = (params2) => {
|
|
29772
30777
|
const { nodes, insideTrackChange } = params2;
|
|
29773
30778
|
if (nodes.length === 0 || !(nodes[0].name === "w:t" || insideTrackChange && nodes[0].name === "w:delText")) {
|
|
@@ -29804,7 +30809,7 @@ const handleParagraphNode = (params2) => {
|
|
|
29804
30809
|
if (nodes.length === 0 || nodes[0].name !== "w:p") {
|
|
29805
30810
|
return { nodes: [], consumed: 0 };
|
|
29806
30811
|
}
|
|
29807
|
-
const schemaNode = translator$
|
|
30812
|
+
const schemaNode = translator$s.encode(params2);
|
|
29808
30813
|
const newNodes = schemaNode ? [schemaNode] : [];
|
|
29809
30814
|
return { nodes: newNodes, consumed: 1 };
|
|
29810
30815
|
};
|
|
@@ -29817,7 +30822,7 @@ const handleSdtNode = (params2) => {
|
|
|
29817
30822
|
if (nodes.length === 0 || nodes[0].name !== "w:sdt") {
|
|
29818
30823
|
return { nodes: [], consumed: 0 };
|
|
29819
30824
|
}
|
|
29820
|
-
const result = translator.encode(params2);
|
|
30825
|
+
const result = translator$b.encode(params2);
|
|
29821
30826
|
if (!result) {
|
|
29822
30827
|
return { nodes: [], consumed: 0 };
|
|
29823
30828
|
}
|
|
@@ -29907,7 +30912,7 @@ const handler = (params2) => {
|
|
|
29907
30912
|
if (nodes.length === 0 || nodes[0].name !== "w:br") {
|
|
29908
30913
|
return { nodes: [], consumed: 0 };
|
|
29909
30914
|
}
|
|
29910
|
-
const result = translator$
|
|
30915
|
+
const result = translator$v.encode(params2);
|
|
29911
30916
|
if (!result) return { nodes: [], consumed: 0 };
|
|
29912
30917
|
return {
|
|
29913
30918
|
nodes: [result],
|
|
@@ -30603,7 +31608,7 @@ const handleTabNode = (params2) => {
|
|
|
30603
31608
|
if (!nodes.length || nodes[0].name !== "w:tab") {
|
|
30604
31609
|
return { nodes: [], consumed: 0 };
|
|
30605
31610
|
}
|
|
30606
|
-
const node = translator$
|
|
31611
|
+
const node = translator$t.encode(params2);
|
|
30607
31612
|
return { nodes: [node], consumed: 1 };
|
|
30608
31613
|
};
|
|
30609
31614
|
const tabNodeEntityHandler = {
|
|
@@ -31050,6 +32055,16 @@ const isAlternatingHeadersOddEven = (docx) => {
|
|
|
31050
32055
|
};
|
|
31051
32056
|
const HYPERLINK_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink";
|
|
31052
32057
|
const HEADER_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header";
|
|
32058
|
+
const FONT_FAMILY_FALLBACKS = Object.freeze({
|
|
32059
|
+
swiss: "Arial, sans-serif",
|
|
32060
|
+
roman: "Times New Roman, serif",
|
|
32061
|
+
modern: "Courier New, monospace",
|
|
32062
|
+
script: "cursive",
|
|
32063
|
+
decorative: "fantasy",
|
|
32064
|
+
system: "system-ui",
|
|
32065
|
+
auto: "sans-serif"
|
|
32066
|
+
});
|
|
32067
|
+
const DEFAULT_GENERIC_FALLBACK = "sans-serif";
|
|
31053
32068
|
const _SuperConverter = class _SuperConverter2 {
|
|
31054
32069
|
constructor(params2 = null) {
|
|
31055
32070
|
__privateAdd$2(this, _SuperConverter_instances);
|
|
@@ -31085,6 +32100,31 @@ const _SuperConverter = class _SuperConverter2 {
|
|
|
31085
32100
|
this.documentId = params2?.documentId || null;
|
|
31086
32101
|
if (this.docx.length || this.xml) this.parseFromXml();
|
|
31087
32102
|
}
|
|
32103
|
+
static getFontTableEntry(docx, fontName) {
|
|
32104
|
+
if (!docx || !fontName) return null;
|
|
32105
|
+
const fontTable = docx["word/fontTable.xml"];
|
|
32106
|
+
if (!fontTable?.elements?.length) return null;
|
|
32107
|
+
const fontsNode = fontTable.elements.find((el) => el.name === "w:fonts");
|
|
32108
|
+
if (!fontsNode?.elements?.length) return null;
|
|
32109
|
+
return fontsNode.elements.find((el) => el?.attributes?.["w:name"] === fontName) || null;
|
|
32110
|
+
}
|
|
32111
|
+
static getFallbackFromFontTable(docx, fontName) {
|
|
32112
|
+
const fontEntry = _SuperConverter2.getFontTableEntry(docx, fontName);
|
|
32113
|
+
const family = fontEntry?.elements?.find((child) => child.name === "w:family")?.attributes?.["w:val"];
|
|
32114
|
+
if (!family) return null;
|
|
32115
|
+
const mapped = FONT_FAMILY_FALLBACKS[family.toLowerCase()];
|
|
32116
|
+
return mapped || DEFAULT_GENERIC_FALLBACK;
|
|
32117
|
+
}
|
|
32118
|
+
static toCssFontFamily(fontName, docx) {
|
|
32119
|
+
if (!fontName) return fontName;
|
|
32120
|
+
if (fontName.includes(",")) return fontName;
|
|
32121
|
+
const fallback = _SuperConverter2.getFallbackFromFontTable(docx, fontName) || DEFAULT_GENERIC_FALLBACK;
|
|
32122
|
+
const normalizedFallbackParts = fallback.split(",").map((part) => part.trim().toLowerCase()).filter(Boolean);
|
|
32123
|
+
if (normalizedFallbackParts.includes(fontName.trim().toLowerCase())) {
|
|
32124
|
+
return fallback;
|
|
32125
|
+
}
|
|
32126
|
+
return `${fontName}, ${fallback}`;
|
|
32127
|
+
}
|
|
31088
32128
|
/**
|
|
31089
32129
|
* Get the DocxHelpers object that contains utility functions for working with docx files.
|
|
31090
32130
|
* @returns {import('./docx-helpers/docx-helpers.js').DocxHelpers} The DocxHelpers object.
|
|
@@ -31130,7 +32170,7 @@ const _SuperConverter = class _SuperConverter2 {
|
|
|
31130
32170
|
return;
|
|
31131
32171
|
}
|
|
31132
32172
|
}
|
|
31133
|
-
static updateDocumentVersion(docx = this.convertedXml, version2 = "0.
|
|
32173
|
+
static updateDocumentVersion(docx = this.convertedXml, version2 = "0.21.0-RC1") {
|
|
31134
32174
|
const customLocation = "docProps/custom.xml";
|
|
31135
32175
|
if (!docx[customLocation]) {
|
|
31136
32176
|
docx[customLocation] = generateCustomXml();
|
|
@@ -31181,13 +32221,19 @@ const _SuperConverter = class _SuperConverter2 {
|
|
|
31181
32221
|
if (rPrDefaults) {
|
|
31182
32222
|
const rPr = rPrDefaults.elements?.find((el) => el.name === "w:rPr");
|
|
31183
32223
|
const fonts = rPr?.elements?.find((el) => el.name === "w:rFonts");
|
|
31184
|
-
|
|
31185
|
-
|
|
31186
|
-
|
|
32224
|
+
if (fonts?.attributes?.["w:ascii"]) {
|
|
32225
|
+
typeface = fonts.attributes["w:ascii"];
|
|
32226
|
+
}
|
|
32227
|
+
const fontSizeRaw = rPr?.elements?.find((el) => el.name === "w:sz")?.attributes?.["w:val"];
|
|
32228
|
+
if (!fontSizeNormal && fontSizeRaw) {
|
|
32229
|
+
fontSizeNormal = Number(fontSizeRaw) / 2;
|
|
32230
|
+
}
|
|
31187
32231
|
}
|
|
31188
|
-
const
|
|
32232
|
+
const fallbackSz = Number(rElements.find((el) => el.name === "w:sz")?.attributes?.["w:val"]);
|
|
32233
|
+
const fontSizePt = fontSizeNormal ?? (Number.isFinite(fallbackSz) ? fallbackSz / 2 : void 0) ?? 10;
|
|
31189
32234
|
const kern = rElements.find((el) => el.name === "w:kern")?.attributes["w:val"];
|
|
31190
|
-
|
|
32235
|
+
const fontFamilyCss = _SuperConverter2.toCssFontFamily(typeface, this.convertedXml);
|
|
32236
|
+
return { fontSizePt, kern, typeface, panose, fontFamilyCss };
|
|
31191
32237
|
}
|
|
31192
32238
|
}
|
|
31193
32239
|
getDocumentFonts() {
|
|
@@ -31617,7 +32663,7 @@ function storeSuperdocVersion(docx) {
|
|
|
31617
32663
|
function generateCustomXml() {
|
|
31618
32664
|
return DEFAULT_CUSTOM_XML;
|
|
31619
32665
|
}
|
|
31620
|
-
function generateSuperdocVersion(pid = 2, version2 = "0.
|
|
32666
|
+
function generateSuperdocVersion(pid = 2, version2 = "0.21.0-RC1") {
|
|
31621
32667
|
return {
|
|
31622
32668
|
type: "element",
|
|
31623
32669
|
name: "property",
|
|
@@ -34026,7 +35072,7 @@ class DocxZipper {
|
|
|
34026
35072
|
const u8 = await zipEntry.async("uint8array");
|
|
34027
35073
|
const content = ensureXmlString(u8);
|
|
34028
35074
|
this.files.push({ name, content });
|
|
34029
|
-
} else if (name.startsWith("word/media") && name !== "word/media/" ||
|
|
35075
|
+
} else if (name.startsWith("word/media") && name !== "word/media/" || name.startsWith("media") && name !== "media/") {
|
|
34030
35076
|
if (isNode2) {
|
|
34031
35077
|
const buffer2 = await zipEntry.async("nodebuffer");
|
|
34032
35078
|
const fileBase64 = buffer2.toString("base64");
|
|
@@ -43031,6 +44077,95 @@ const toggleMark = (typeOrName, attrs = {}, options = {}) => ({ state: state2, c
|
|
|
43031
44077
|
if (isActive2) return commands2.unsetMark(type2, { extendEmptyMarkRange });
|
|
43032
44078
|
return commands2.setMark(type2, attrs);
|
|
43033
44079
|
};
|
|
44080
|
+
const toggleMarkCascade = (markName, options = {}) => ({ state: state2, chain, editor }) => {
|
|
44081
|
+
const {
|
|
44082
|
+
negationAttrs = { value: "0" },
|
|
44083
|
+
isNegation = (attrs) => attrs?.value === "0",
|
|
44084
|
+
styleDetector = defaultStyleDetector,
|
|
44085
|
+
extendEmptyMarkRange = true
|
|
44086
|
+
} = options;
|
|
44087
|
+
const selectionMarks = getMarksFromSelection(state2) || [];
|
|
44088
|
+
const inlineMarks = selectionMarks.filter((m2) => m2.type?.name === markName);
|
|
44089
|
+
const hasNegation = inlineMarks.some((m2) => isNegation(m2.attrs || {}));
|
|
44090
|
+
const hasInline = inlineMarks.some((m2) => !isNegation(m2.attrs || {}));
|
|
44091
|
+
const styleOn = styleDetector({ state: state2, selectionMarks, markName, editor });
|
|
44092
|
+
const cmdChain = chain();
|
|
44093
|
+
if (hasNegation) return cmdChain.unsetMark(markName, { extendEmptyMarkRange }).run();
|
|
44094
|
+
if (hasInline && styleOn) {
|
|
44095
|
+
return cmdChain.unsetMark(markName, { extendEmptyMarkRange }).setMark(markName, negationAttrs, { extendEmptyMarkRange }).run();
|
|
44096
|
+
}
|
|
44097
|
+
if (hasInline) return cmdChain.unsetMark(markName, { extendEmptyMarkRange }).run();
|
|
44098
|
+
if (styleOn) return cmdChain.setMark(markName, negationAttrs, { extendEmptyMarkRange }).run();
|
|
44099
|
+
return cmdChain.setMark(markName, {}, { extendEmptyMarkRange }).run();
|
|
44100
|
+
};
|
|
44101
|
+
function defaultStyleDetector({ state: state2, selectionMarks, markName, editor }) {
|
|
44102
|
+
try {
|
|
44103
|
+
const styleId = getEffectiveStyleId(state2, selectionMarks);
|
|
44104
|
+
if (!styleId || !editor?.converter?.linkedStyles) return false;
|
|
44105
|
+
const styles = editor.converter.linkedStyles;
|
|
44106
|
+
const seen = /* @__PURE__ */ new Set();
|
|
44107
|
+
let current = styleId;
|
|
44108
|
+
const key = mapMarkToStyleKey(markName);
|
|
44109
|
+
while (current && !seen.has(current)) {
|
|
44110
|
+
seen.add(current);
|
|
44111
|
+
const style2 = styles.find((s) => s.id === current);
|
|
44112
|
+
const def = style2?.definition?.styles || {};
|
|
44113
|
+
if (key in def) {
|
|
44114
|
+
const raw = def[key];
|
|
44115
|
+
if (raw === void 0) return true;
|
|
44116
|
+
const val = raw?.value ?? raw;
|
|
44117
|
+
if (val === "0" || val === false) return false;
|
|
44118
|
+
return !!val;
|
|
44119
|
+
}
|
|
44120
|
+
current = style2?.definition?.attrs?.basedOn || null;
|
|
44121
|
+
}
|
|
44122
|
+
return false;
|
|
44123
|
+
} catch {
|
|
44124
|
+
return false;
|
|
44125
|
+
}
|
|
44126
|
+
}
|
|
44127
|
+
function getEffectiveStyleId(state2, selectionMarks) {
|
|
44128
|
+
const sidFromMarks = getStyleIdFromMarks(selectionMarks);
|
|
44129
|
+
if (sidFromMarks) return sidFromMarks;
|
|
44130
|
+
const $from = state2.selection.$from;
|
|
44131
|
+
const before = $from.nodeBefore;
|
|
44132
|
+
const after = $from.nodeAfter;
|
|
44133
|
+
if (before && before.marks) {
|
|
44134
|
+
const sid = getStyleIdFromMarks(before.marks);
|
|
44135
|
+
if (sid) return sid;
|
|
44136
|
+
}
|
|
44137
|
+
if (after && after.marks) {
|
|
44138
|
+
const sid = getStyleIdFromMarks(after.marks);
|
|
44139
|
+
if (sid) return sid;
|
|
44140
|
+
}
|
|
44141
|
+
const ts = selectionMarks.find((m2) => m2.type?.name === "textStyle" && m2.attrs?.styleId);
|
|
44142
|
+
if (ts) return ts.attrs.styleId;
|
|
44143
|
+
const pos = state2.selection.$from.pos;
|
|
44144
|
+
const $pos = state2.doc.resolve(pos);
|
|
44145
|
+
for (let d2 = $pos.depth; d2 >= 0; d2--) {
|
|
44146
|
+
const n = $pos.node(d2);
|
|
44147
|
+
if (n?.type?.name === "paragraph") return n.attrs?.styleId || null;
|
|
44148
|
+
}
|
|
44149
|
+
return null;
|
|
44150
|
+
}
|
|
44151
|
+
function getStyleIdFromMarks(marks) {
|
|
44152
|
+
const run2 = marks.find((m2) => m2.type?.name === "run");
|
|
44153
|
+
const runProperties = run2?.attrs?.runProperties;
|
|
44154
|
+
if (!runProperties) return null;
|
|
44155
|
+
if (runProperties && typeof runProperties === "object" && !Array.isArray(runProperties) && runProperties.styleId) {
|
|
44156
|
+
return runProperties.styleId;
|
|
44157
|
+
}
|
|
44158
|
+
if (Array.isArray(runProperties)) {
|
|
44159
|
+
const rStyleEntry = runProperties.find((e) => e?.xmlName === "w:rStyle");
|
|
44160
|
+
const sid = rStyleEntry?.attributes?.["w:val"];
|
|
44161
|
+
if (sid) return sid;
|
|
44162
|
+
}
|
|
44163
|
+
return null;
|
|
44164
|
+
}
|
|
44165
|
+
function mapMarkToStyleKey(markName) {
|
|
44166
|
+
if (markName === "textStyle" || markName === "color") return "color";
|
|
44167
|
+
return markName;
|
|
44168
|
+
}
|
|
43034
44169
|
const clearNodes = () => ({ state: state2, tr, dispatch }) => {
|
|
43035
44170
|
const { selection } = tr;
|
|
43036
44171
|
const { ranges } = selection;
|
|
@@ -44376,11 +45511,14 @@ const commands$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
|
|
|
44376
45511
|
command,
|
|
44377
45512
|
createParagraphNear,
|
|
44378
45513
|
decreaseListIndent,
|
|
45514
|
+
defaultStyleDetector,
|
|
44379
45515
|
deleteListItem,
|
|
44380
45516
|
deleteSelection,
|
|
44381
45517
|
exitCode,
|
|
44382
45518
|
first,
|
|
45519
|
+
getEffectiveStyleId,
|
|
44383
45520
|
getParaCtx,
|
|
45521
|
+
getStyleIdFromMarks,
|
|
44384
45522
|
handleBackspaceNextToList,
|
|
44385
45523
|
handleDeleteNextToList,
|
|
44386
45524
|
increaseListIndent,
|
|
@@ -44395,6 +45533,7 @@ const commands$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
|
|
|
44395
45533
|
joinUp,
|
|
44396
45534
|
liftEmptyBlock,
|
|
44397
45535
|
liftListItem,
|
|
45536
|
+
mapMarkToStyleKey,
|
|
44398
45537
|
nearestListAt,
|
|
44399
45538
|
newlineInCode,
|
|
44400
45539
|
rebuildListNodeWithNewNum,
|
|
@@ -44414,6 +45553,7 @@ const commands$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
|
|
|
44414
45553
|
splitListItem,
|
|
44415
45554
|
toggleList,
|
|
44416
45555
|
toggleMark,
|
|
45556
|
+
toggleMarkCascade,
|
|
44417
45557
|
toggleNode,
|
|
44418
45558
|
undoInputRule,
|
|
44419
45559
|
unsetAllMarks,
|
|
@@ -45617,7 +46757,7 @@ const createHeaderFooterEditor = ({
|
|
|
45617
46757
|
currentPageNumber
|
|
45618
46758
|
}) => {
|
|
45619
46759
|
const parentStyles = editor.converter.getDocumentDefaultStyles();
|
|
45620
|
-
const { fontSizePt, typeface } = parentStyles;
|
|
46760
|
+
const { fontSizePt, typeface, fontFamilyCss } = parentStyles;
|
|
45621
46761
|
const fontSizeInPixles = fontSizePt * 1.3333;
|
|
45622
46762
|
const lineHeight2 = fontSizeInPixles * 1.2;
|
|
45623
46763
|
Object.assign(editorContainer.style, {
|
|
@@ -45630,7 +46770,7 @@ const createHeaderFooterEditor = ({
|
|
|
45630
46770
|
left: "0",
|
|
45631
46771
|
width: "auto",
|
|
45632
46772
|
maxWidth: "none",
|
|
45633
|
-
fontFamily: typeface,
|
|
46773
|
+
fontFamily: fontFamilyCss || typeface,
|
|
45634
46774
|
fontSize: `${fontSizeInPixles}px`,
|
|
45635
46775
|
lineHeight: `${lineHeight2}px`
|
|
45636
46776
|
});
|
|
@@ -46460,7 +47600,6 @@ const trackedTransaction = ({ tr, state: state2, user }) => {
|
|
|
46460
47600
|
originalStep,
|
|
46461
47601
|
originalStepIndex
|
|
46462
47602
|
});
|
|
46463
|
-
console.debug("[track-changes]: replaceStep");
|
|
46464
47603
|
} else if (step instanceof AddMarkStep) {
|
|
46465
47604
|
addMarkStep({
|
|
46466
47605
|
state: state2,
|
|
@@ -46470,7 +47609,6 @@ const trackedTransaction = ({ tr, state: state2, user }) => {
|
|
|
46470
47609
|
user,
|
|
46471
47610
|
date
|
|
46472
47611
|
});
|
|
46473
|
-
console.debug("[track-changes]: addMarkStep");
|
|
46474
47612
|
} else if (step instanceof RemoveMarkStep) {
|
|
46475
47613
|
removeMarkStep({
|
|
46476
47614
|
state: state2,
|
|
@@ -46480,10 +47618,8 @@ const trackedTransaction = ({ tr, state: state2, user }) => {
|
|
|
46480
47618
|
user,
|
|
46481
47619
|
date
|
|
46482
47620
|
});
|
|
46483
|
-
console.debug("[track-changes]: removeMarkStep");
|
|
46484
47621
|
} else {
|
|
46485
47622
|
newTr.step(step);
|
|
46486
|
-
console.log("[track-changes]: otherStep");
|
|
46487
47623
|
}
|
|
46488
47624
|
});
|
|
46489
47625
|
if (tr.getMeta("inputType")) {
|
|
@@ -48553,9 +49689,10 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
48553
49689
|
element.style.isolation = "isolate";
|
|
48554
49690
|
proseMirror.style.outline = "none";
|
|
48555
49691
|
proseMirror.style.border = "none";
|
|
48556
|
-
const { typeface, fontSizePt } = this.converter.getDocumentDefaultStyles() ?? {};
|
|
48557
|
-
|
|
48558
|
-
|
|
49692
|
+
const { typeface, fontSizePt, fontFamilyCss } = this.converter.getDocumentDefaultStyles() ?? {};
|
|
49693
|
+
const resolvedFontFamily = fontFamilyCss || typeface;
|
|
49694
|
+
if (resolvedFontFamily) {
|
|
49695
|
+
element.style.fontFamily = resolvedFontFamily;
|
|
48559
49696
|
}
|
|
48560
49697
|
if (fontSizePt) {
|
|
48561
49698
|
element.style.fontSize = `${fontSizePt}pt`;
|
|
@@ -48869,7 +50006,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
48869
50006
|
* @returns {Object | void} Migration results
|
|
48870
50007
|
*/
|
|
48871
50008
|
processCollaborationMigrations() {
|
|
48872
|
-
console.debug("[checkVersionMigrations] Current editor version", "0.
|
|
50009
|
+
console.debug("[checkVersionMigrations] Current editor version", "0.21.0-RC1");
|
|
48873
50010
|
if (!this.options.ydoc) return;
|
|
48874
50011
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
48875
50012
|
let docVersion = metaMap.get("version");
|
|
@@ -49978,6 +51115,7 @@ const FormatCommands = Extension.create({
|
|
|
49978
51115
|
},
|
|
49979
51116
|
addCommands() {
|
|
49980
51117
|
return {
|
|
51118
|
+
toggleMarkCascade,
|
|
49981
51119
|
/**
|
|
49982
51120
|
* Clear all formatting (nodes and marks)
|
|
49983
51121
|
* @category Command
|
|
@@ -50962,24 +52100,32 @@ const Text = Node$1.create({
|
|
|
50962
52100
|
group: "inline",
|
|
50963
52101
|
inline: true
|
|
50964
52102
|
});
|
|
50965
|
-
const
|
|
52103
|
+
const Run = Mark2.create({
|
|
50966
52104
|
name: "run",
|
|
50967
|
-
|
|
50968
|
-
|
|
50969
|
-
|
|
50970
|
-
|
|
50971
|
-
|
|
50972
|
-
},
|
|
50973
|
-
renderDOM() {
|
|
50974
|
-
return ["run", 0];
|
|
52105
|
+
inclusive: false,
|
|
52106
|
+
addOptions() {
|
|
52107
|
+
return {
|
|
52108
|
+
htmlAttributes: {}
|
|
52109
|
+
};
|
|
50975
52110
|
},
|
|
50976
52111
|
addAttributes() {
|
|
50977
52112
|
return {
|
|
50978
|
-
|
|
50979
|
-
|
|
50980
|
-
|
|
52113
|
+
runProperties: {
|
|
52114
|
+
default: null,
|
|
52115
|
+
rendered: false
|
|
50981
52116
|
}
|
|
50982
52117
|
};
|
|
52118
|
+
},
|
|
52119
|
+
parseDOM() {
|
|
52120
|
+
return [
|
|
52121
|
+
{
|
|
52122
|
+
tag: "span[data-run]"
|
|
52123
|
+
}
|
|
52124
|
+
];
|
|
52125
|
+
},
|
|
52126
|
+
renderDOM({ htmlAttributes }) {
|
|
52127
|
+
const base2 = Attribute2.mergeAttributes({ "data-run": "1" }, this.options.htmlAttributes, htmlAttributes);
|
|
52128
|
+
return ["span", base2, 0];
|
|
50983
52129
|
}
|
|
50984
52130
|
});
|
|
50985
52131
|
const inputRegex$1 = /^\s*([-+*])\s$/;
|
|
@@ -51543,6 +52689,7 @@ const getMarksStyle = (attrs) => {
|
|
|
51543
52689
|
case "textStyle":
|
|
51544
52690
|
const { fontFamily: fontFamily2, fontSize: fontSize2 } = attr.attrs;
|
|
51545
52691
|
styles += `${fontFamily2 ? `font-family: ${fontFamily2};` : ""} ${fontSize2 ? `font-size: ${fontSize2};` : ""}`;
|
|
52692
|
+
break;
|
|
51546
52693
|
}
|
|
51547
52694
|
}
|
|
51548
52695
|
return styles.trim();
|
|
@@ -51561,12 +52708,22 @@ const generateLinkedStyleString = (linkedStyle, basedOnStyle, node, parent, incl
|
|
|
51561
52708
|
const linkedDefinitionStyles = { ...linkedStyle.definition.styles };
|
|
51562
52709
|
const basedOnDefinitionStyles = { ...basedOnStyle?.definition?.styles };
|
|
51563
52710
|
const resultStyles = { ...linkedDefinitionStyles };
|
|
51564
|
-
|
|
51565
|
-
|
|
51566
|
-
|
|
51567
|
-
|
|
51568
|
-
|
|
51569
|
-
|
|
52711
|
+
const inheritKeys = [
|
|
52712
|
+
"font-size",
|
|
52713
|
+
"font-family",
|
|
52714
|
+
"text-transform",
|
|
52715
|
+
"bold",
|
|
52716
|
+
"italic",
|
|
52717
|
+
"underline",
|
|
52718
|
+
"strike",
|
|
52719
|
+
"color",
|
|
52720
|
+
"highlight"
|
|
52721
|
+
];
|
|
52722
|
+
inheritKeys.forEach((k) => {
|
|
52723
|
+
if (!linkedDefinitionStyles[k] && basedOnDefinitionStyles[k]) {
|
|
52724
|
+
resultStyles[k] = basedOnDefinitionStyles[k];
|
|
52725
|
+
}
|
|
52726
|
+
});
|
|
51570
52727
|
Object.entries(resultStyles).forEach(([k, value]) => {
|
|
51571
52728
|
const key = kebabCase$1(k);
|
|
51572
52729
|
const flattenedMarks = [];
|
|
@@ -51581,6 +52738,10 @@ const generateLinkedStyleString = (linkedStyle, basedOnStyle, node, parent, incl
|
|
|
51581
52738
|
}
|
|
51582
52739
|
flattenedMarks.push({ key: n.type.name, value: n.attrs[key] });
|
|
51583
52740
|
});
|
|
52741
|
+
const underlineNone = node?.marks?.some((m2) => m2.type?.name === "underline" && m2.attrs?.underlineType === "none");
|
|
52742
|
+
if (underlineNone) {
|
|
52743
|
+
markValue["text-decoration"] = "none";
|
|
52744
|
+
}
|
|
51584
52745
|
const mark = flattenedMarks.find((n) => n.key === key);
|
|
51585
52746
|
const hasParentIndent = Object.keys(parent?.attrs?.indent || {});
|
|
51586
52747
|
const hasParentSpacing = Object.keys(parent?.attrs?.spacing || {});
|
|
@@ -51597,10 +52758,28 @@ const generateLinkedStyleString = (linkedStyle, basedOnStyle, node, parent, incl
|
|
|
51597
52758
|
if (rightIndent) markValue["margin-right"] = rightIndent + "px";
|
|
51598
52759
|
if (firstLine) markValue["text-indent"] = firstLine + "px";
|
|
51599
52760
|
} else if (key === "bold" && node) {
|
|
51600
|
-
const
|
|
51601
|
-
|
|
52761
|
+
const boldValue = typeof value === "object" && value !== null ? value.value : value;
|
|
52762
|
+
const hasInlineBoldOff = node.marks?.some((m2) => m2.type?.name === "bold" && m2.attrs?.value === "0");
|
|
52763
|
+
const hasInlineBoldOn = node.marks?.some((m2) => m2.type?.name === "bold" && m2.attrs?.value !== "0");
|
|
52764
|
+
if (!listTypes.includes(node.type.name) && !hasInlineBoldOff && !hasInlineBoldOn && boldValue !== "0" && boldValue !== false) {
|
|
51602
52765
|
markValue["font-weight"] = "bold";
|
|
51603
52766
|
}
|
|
52767
|
+
} else if (key === "italic" && node) {
|
|
52768
|
+
const italicValue = typeof value === "object" && value !== null ? value.value : value;
|
|
52769
|
+
const hasInlineItalicOff = node.marks?.some((m2) => m2.type?.name === "italic" && m2.attrs?.value === "0");
|
|
52770
|
+
const hasInlineItalicOn = node.marks?.some((m2) => m2.type?.name === "italic" && m2.attrs?.value !== "0");
|
|
52771
|
+
if (!listTypes.includes(node.type.name) && !hasInlineItalicOff && !hasInlineItalicOn && italicValue !== "0" && italicValue !== false) {
|
|
52772
|
+
markValue["font-style"] = "italic";
|
|
52773
|
+
}
|
|
52774
|
+
} else if (key === "strike" && node) {
|
|
52775
|
+
const strikeValue = typeof value === "object" && value !== null ? value.value : value;
|
|
52776
|
+
const hasInlineStrikeOff = node.marks?.some((m2) => m2.type?.name === "strike" && m2.attrs?.value === "0");
|
|
52777
|
+
const hasInlineStrikeOn = node.marks?.some(
|
|
52778
|
+
(m2) => m2.type?.name === "strike" && (m2.attrs?.value === void 0 || m2.attrs?.value !== "0")
|
|
52779
|
+
);
|
|
52780
|
+
if (!listTypes.includes(node.type.name) && !hasInlineStrikeOff && !hasInlineStrikeOn && strikeValue !== "0" && strikeValue !== false) {
|
|
52781
|
+
markValue["text-decoration"] = "line-through";
|
|
52782
|
+
}
|
|
51604
52783
|
} else if (key === "text-transform" && node) {
|
|
51605
52784
|
if (!listTypes.includes(node.type.name)) {
|
|
51606
52785
|
markValue[key] = value;
|
|
@@ -51609,10 +52788,44 @@ const generateLinkedStyleString = (linkedStyle, basedOnStyle, node, parent, incl
|
|
|
51609
52788
|
if (!listTypes.includes(node.type.name)) {
|
|
51610
52789
|
markValue[key] = value;
|
|
51611
52790
|
}
|
|
52791
|
+
} else if (key === "font-family" && node) {
|
|
52792
|
+
if (!listTypes.includes(node.type.name)) {
|
|
52793
|
+
markValue[key] = value;
|
|
52794
|
+
}
|
|
51612
52795
|
} else if (key === "color" && node) {
|
|
51613
52796
|
if (!listTypes.includes(node.type.name)) {
|
|
51614
52797
|
markValue[key] = value;
|
|
51615
52798
|
}
|
|
52799
|
+
} else if (key === "highlight" && node) {
|
|
52800
|
+
const hasInlineHighlight = node.marks?.some((m2) => m2.type?.name === "highlight");
|
|
52801
|
+
if (!listTypes.includes(node.type.name) && !hasInlineHighlight) {
|
|
52802
|
+
const color = typeof value === "string" ? value : value?.color;
|
|
52803
|
+
if (color) markValue["background-color"] = color;
|
|
52804
|
+
}
|
|
52805
|
+
} else if (key === "underline" && node) {
|
|
52806
|
+
const styleValRaw = value?.value ?? value ?? "";
|
|
52807
|
+
const styleVal = styleValRaw.toString().toLowerCase();
|
|
52808
|
+
const hasInlineUnderlineOff = node.marks?.some(
|
|
52809
|
+
(m2) => m2.type?.name === "underline" && m2.attrs?.underlineType === "none"
|
|
52810
|
+
);
|
|
52811
|
+
const hasInlineUnderlineOn = node.marks?.some(
|
|
52812
|
+
(m2) => m2.type?.name === "underline" && m2.attrs?.underlineType && m2.attrs.underlineType !== "none"
|
|
52813
|
+
);
|
|
52814
|
+
if (!listTypes.includes(node.type.name) && !hasInlineUnderlineOff && !hasInlineUnderlineOn) {
|
|
52815
|
+
if (styleVal && styleVal !== "none" && styleVal !== "0") {
|
|
52816
|
+
const colorVal = value && typeof value === "object" ? value.color || value.underlineColor || null : null;
|
|
52817
|
+
const css = getUnderlineCssString({ type: styleVal, color: colorVal });
|
|
52818
|
+
css.split(";").forEach((decl) => {
|
|
52819
|
+
const d2 = decl.trim();
|
|
52820
|
+
if (!d2) return;
|
|
52821
|
+
const idx = d2.indexOf(":");
|
|
52822
|
+
if (idx === -1) return;
|
|
52823
|
+
const k2 = d2.slice(0, idx).trim();
|
|
52824
|
+
const v2 = d2.slice(idx + 1).trim();
|
|
52825
|
+
markValue[k2] = v2;
|
|
52826
|
+
});
|
|
52827
|
+
}
|
|
52828
|
+
}
|
|
51616
52829
|
} else if (typeof value === "string") {
|
|
51617
52830
|
markValue[key] = value;
|
|
51618
52831
|
}
|
|
@@ -51745,23 +52958,51 @@ const createLinkedStylesPlugin = (editor) => {
|
|
|
51745
52958
|
};
|
|
51746
52959
|
const generateDecorations = (state2, styles) => {
|
|
51747
52960
|
const decorations = [];
|
|
51748
|
-
let lastStyleId = null;
|
|
51749
52961
|
const doc2 = state2?.doc;
|
|
52962
|
+
const getParagraphStyleId = (pos) => {
|
|
52963
|
+
const $pos = state2.doc.resolve(pos);
|
|
52964
|
+
for (let d2 = $pos.depth; d2 >= 0; d2--) {
|
|
52965
|
+
const n = $pos.node(d2);
|
|
52966
|
+
if (n?.type?.name === "paragraph") return n.attrs?.styleId || null;
|
|
52967
|
+
}
|
|
52968
|
+
return null;
|
|
52969
|
+
};
|
|
51750
52970
|
doc2.descendants((node, pos) => {
|
|
51751
52971
|
const { name } = node.type;
|
|
51752
|
-
if (
|
|
51753
|
-
|
|
51754
|
-
|
|
52972
|
+
if (name !== "text") return;
|
|
52973
|
+
const paragraphStyleId = getParagraphStyleId(pos);
|
|
52974
|
+
let runStyleId = null;
|
|
52975
|
+
let inlineTextStyleId = null;
|
|
51755
52976
|
for (const mark of node.marks) {
|
|
51756
|
-
if (mark.type.name === "
|
|
51757
|
-
|
|
51758
|
-
|
|
51759
|
-
|
|
51760
|
-
|
|
51761
|
-
|
|
52977
|
+
if (mark.type.name === "run") {
|
|
52978
|
+
const rp = mark.attrs?.runProperties;
|
|
52979
|
+
if (rp && typeof rp === "object" && !Array.isArray(rp) && rp.styleId) runStyleId = rp.styleId;
|
|
52980
|
+
else if (Array.isArray(rp)) {
|
|
52981
|
+
const ent = rp.find((e) => e?.xmlName === "w:rStyle");
|
|
52982
|
+
const sid = ent?.attributes?.["w:val"];
|
|
52983
|
+
if (sid) runStyleId = sid;
|
|
52984
|
+
}
|
|
52985
|
+
} else if (mark.type.name === "textStyle" && mark.attrs?.styleId) {
|
|
52986
|
+
inlineTextStyleId = mark.attrs.styleId;
|
|
52987
|
+
}
|
|
52988
|
+
}
|
|
52989
|
+
const buildStyleMap = (sid) => {
|
|
52990
|
+
if (!sid) return {};
|
|
52991
|
+
const { linkedStyle, basedOnStyle: basedOnStyle2 } = getLinkedStyle(sid, styles);
|
|
52992
|
+
if (!linkedStyle) return {};
|
|
52993
|
+
const base2 = { ...basedOnStyle2?.definition?.styles || {} };
|
|
52994
|
+
return { ...base2, ...linkedStyle.definition?.styles || {} };
|
|
52995
|
+
};
|
|
52996
|
+
const pMap = buildStyleMap(paragraphStyleId);
|
|
52997
|
+
const tMap = buildStyleMap(inlineTextStyleId);
|
|
52998
|
+
const rMap = buildStyleMap(runStyleId);
|
|
52999
|
+
const finalStyles = { ...pMap, ...tMap, ...rMap };
|
|
53000
|
+
if (Object.keys(finalStyles).length === 0) return;
|
|
53001
|
+
const mergedLinkedStyle = { definition: { styles: finalStyles, attrs: {} } };
|
|
53002
|
+
const basedOnStyle = null;
|
|
51762
53003
|
const $pos = state2.doc.resolve(pos);
|
|
51763
53004
|
const parent = $pos.parent;
|
|
51764
|
-
const styleString = generateLinkedStyleString(
|
|
53005
|
+
const styleString = generateLinkedStyleString(mergedLinkedStyle, basedOnStyle, node, parent);
|
|
51765
53006
|
if (!styleString) return;
|
|
51766
53007
|
const decoration = Decoration.inline(pos, pos + node.nodeSize, { style: styleString });
|
|
51767
53008
|
decorations.push(decoration);
|
|
@@ -51896,6 +53137,70 @@ const LinkedStyles = Extension.create({
|
|
|
51896
53137
|
};
|
|
51897
53138
|
}
|
|
51898
53139
|
});
|
|
53140
|
+
function getUnderlineCssString({ type: type2 = "single", color = null, thickness = null, approximate = true } = {}) {
|
|
53141
|
+
const parts = [];
|
|
53142
|
+
const add = (k, v2) => {
|
|
53143
|
+
if (!v2) return;
|
|
53144
|
+
parts.push(`${k}: ${v2}`);
|
|
53145
|
+
};
|
|
53146
|
+
const lower = String(type2 || "single").toLowerCase();
|
|
53147
|
+
if (lower === "none" || lower === "0") {
|
|
53148
|
+
add("text-decoration", "none");
|
|
53149
|
+
return parts.join("; ");
|
|
53150
|
+
}
|
|
53151
|
+
add("text-decoration-line", "underline");
|
|
53152
|
+
const HEAVY = thickness || "0.2em";
|
|
53153
|
+
const THICK = thickness || "0.15em";
|
|
53154
|
+
switch (lower) {
|
|
53155
|
+
case "single":
|
|
53156
|
+
break;
|
|
53157
|
+
case "double":
|
|
53158
|
+
add("text-decoration-style", "double");
|
|
53159
|
+
break;
|
|
53160
|
+
case "thick":
|
|
53161
|
+
add("text-decoration-thickness", THICK);
|
|
53162
|
+
break;
|
|
53163
|
+
case "dotted":
|
|
53164
|
+
add("text-decoration-style", "dotted");
|
|
53165
|
+
break;
|
|
53166
|
+
case "dash":
|
|
53167
|
+
case "dashed":
|
|
53168
|
+
add("text-decoration-style", "dashed");
|
|
53169
|
+
break;
|
|
53170
|
+
case "dotdash":
|
|
53171
|
+
case "dotdotdash":
|
|
53172
|
+
case "dashlong":
|
|
53173
|
+
case "dashlongheavy":
|
|
53174
|
+
if (approximate) {
|
|
53175
|
+
add("text-decoration-style", "dashed");
|
|
53176
|
+
if (lower.includes("heavy")) add("text-decoration-thickness", HEAVY);
|
|
53177
|
+
}
|
|
53178
|
+
break;
|
|
53179
|
+
case "dottedheavy":
|
|
53180
|
+
add("text-decoration-style", "dotted");
|
|
53181
|
+
add("text-decoration-thickness", HEAVY);
|
|
53182
|
+
break;
|
|
53183
|
+
case "dashedheavy":
|
|
53184
|
+
add("text-decoration-style", "dashed");
|
|
53185
|
+
add("text-decoration-thickness", HEAVY);
|
|
53186
|
+
break;
|
|
53187
|
+
case "wavy":
|
|
53188
|
+
add("text-decoration-style", "wavy");
|
|
53189
|
+
break;
|
|
53190
|
+
case "wavyheavy":
|
|
53191
|
+
add("text-decoration-style", "wavy");
|
|
53192
|
+
add("text-decoration-thickness", HEAVY);
|
|
53193
|
+
break;
|
|
53194
|
+
case "wavydouble":
|
|
53195
|
+
if (approximate) {
|
|
53196
|
+
add("text-decoration-style", "wavy");
|
|
53197
|
+
add("text-decoration-thickness", HEAVY);
|
|
53198
|
+
}
|
|
53199
|
+
break;
|
|
53200
|
+
}
|
|
53201
|
+
if (color) add("text-decoration-color", color);
|
|
53202
|
+
return parts.join("; ");
|
|
53203
|
+
}
|
|
51899
53204
|
const generateOrderedListIndex = ({ listLevel, lvlText, listNumberingType, customFormat }) => {
|
|
51900
53205
|
const handler2 = listIndexMap[listNumberingType];
|
|
51901
53206
|
return handler2 ? handler2(listLevel, lvlText, customFormat) : null;
|
|
@@ -60181,6 +61486,30 @@ const TextStyle = Mark2.create({
|
|
|
60181
61486
|
};
|
|
60182
61487
|
}
|
|
60183
61488
|
});
|
|
61489
|
+
function createCascadeToggleCommands({
|
|
61490
|
+
markName,
|
|
61491
|
+
setCommand,
|
|
61492
|
+
unsetCommand,
|
|
61493
|
+
toggleCommand,
|
|
61494
|
+
negationAttrs,
|
|
61495
|
+
isNegation,
|
|
61496
|
+
extendEmptyMarkRange
|
|
61497
|
+
} = {}) {
|
|
61498
|
+
if (!markName) throw new Error("createCascadeToggleCommands requires a markName");
|
|
61499
|
+
const capitalized = markName.charAt(0).toUpperCase() + markName.slice(1);
|
|
61500
|
+
const setName = setCommand ?? `set${capitalized}`;
|
|
61501
|
+
const unsetName = unsetCommand ?? `unset${capitalized}`;
|
|
61502
|
+
const toggleName = toggleCommand ?? `toggle${capitalized}`;
|
|
61503
|
+
const cascadeOptions = {};
|
|
61504
|
+
if (negationAttrs) cascadeOptions.negationAttrs = negationAttrs;
|
|
61505
|
+
if (typeof isNegation === "function") cascadeOptions.isNegation = isNegation;
|
|
61506
|
+
if (extendEmptyMarkRange !== void 0) cascadeOptions.extendEmptyMarkRange = extendEmptyMarkRange;
|
|
61507
|
+
return {
|
|
61508
|
+
[setName]: () => ({ commands: commands2 }) => commands2.setMark(markName),
|
|
61509
|
+
[unsetName]: () => ({ commands: commands2 }) => commands2.unsetMark(markName),
|
|
61510
|
+
[toggleName]: () => ({ commands: commands2 }) => commands2.toggleMarkCascade(markName, cascadeOptions)
|
|
61511
|
+
};
|
|
61512
|
+
}
|
|
60184
61513
|
const Bold = Mark2.create({
|
|
60185
61514
|
name: "bold",
|
|
60186
61515
|
addOptions() {
|
|
@@ -60215,9 +61544,18 @@ const Bold = Mark2.create({
|
|
|
60215
61544
|
];
|
|
60216
61545
|
},
|
|
60217
61546
|
renderDOM({ htmlAttributes }) {
|
|
60218
|
-
|
|
61547
|
+
const merged = Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes);
|
|
61548
|
+
const { value, ...rest } = merged || {};
|
|
61549
|
+
if (value === "0") {
|
|
61550
|
+
return ["span", rest, 0];
|
|
61551
|
+
}
|
|
61552
|
+
return ["strong", rest, 0];
|
|
60219
61553
|
},
|
|
60220
61554
|
addCommands() {
|
|
61555
|
+
const { setBold, unsetBold, toggleBold } = createCascadeToggleCommands({
|
|
61556
|
+
markName: this.name,
|
|
61557
|
+
negationAttrs: { value: "0" }
|
|
61558
|
+
});
|
|
60221
61559
|
return {
|
|
60222
61560
|
/**
|
|
60223
61561
|
* Apply bold formatting
|
|
@@ -60227,7 +61565,7 @@ const Bold = Mark2.create({
|
|
|
60227
61565
|
* setBold()
|
|
60228
61566
|
* @note '0' renders as normal weight
|
|
60229
61567
|
*/
|
|
60230
|
-
setBold
|
|
61568
|
+
setBold,
|
|
60231
61569
|
/**
|
|
60232
61570
|
* Remove bold formatting
|
|
60233
61571
|
* @category Command
|
|
@@ -60235,7 +61573,7 @@ const Bold = Mark2.create({
|
|
|
60235
61573
|
* @example
|
|
60236
61574
|
* unsetBold()
|
|
60237
61575
|
*/
|
|
60238
|
-
unsetBold
|
|
61576
|
+
unsetBold,
|
|
60239
61577
|
/**
|
|
60240
61578
|
* Toggle bold formatting
|
|
60241
61579
|
* @category Command
|
|
@@ -60243,7 +61581,7 @@ const Bold = Mark2.create({
|
|
|
60243
61581
|
* @example
|
|
60244
61582
|
* toggleBold()
|
|
60245
61583
|
*/
|
|
60246
|
-
toggleBold
|
|
61584
|
+
toggleBold
|
|
60247
61585
|
};
|
|
60248
61586
|
},
|
|
60249
61587
|
addShortcuts() {
|
|
@@ -60260,6 +61598,22 @@ const Italic = Mark2.create({
|
|
|
60260
61598
|
htmlAttributes: {}
|
|
60261
61599
|
};
|
|
60262
61600
|
},
|
|
61601
|
+
addAttributes() {
|
|
61602
|
+
return {
|
|
61603
|
+
/**
|
|
61604
|
+
* @category Attribute
|
|
61605
|
+
* @param {string} [value] - Italic toggle value ('0' renders as normal)
|
|
61606
|
+
*/
|
|
61607
|
+
value: {
|
|
61608
|
+
default: null,
|
|
61609
|
+
renderDOM: (attrs) => {
|
|
61610
|
+
if (!attrs.value) return {};
|
|
61611
|
+
if (attrs.value === "0") return { style: "font-style: normal" };
|
|
61612
|
+
return {};
|
|
61613
|
+
}
|
|
61614
|
+
}
|
|
61615
|
+
};
|
|
61616
|
+
},
|
|
60263
61617
|
parseDOM() {
|
|
60264
61618
|
return [
|
|
60265
61619
|
{ tag: "i" },
|
|
@@ -60269,9 +61623,18 @@ const Italic = Mark2.create({
|
|
|
60269
61623
|
];
|
|
60270
61624
|
},
|
|
60271
61625
|
renderDOM({ htmlAttributes }) {
|
|
60272
|
-
|
|
61626
|
+
const merged = Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes);
|
|
61627
|
+
const { value, ...rest } = merged || {};
|
|
61628
|
+
if (value === "0") {
|
|
61629
|
+
return ["span", rest, 0];
|
|
61630
|
+
}
|
|
61631
|
+
return ["em", rest, 0];
|
|
60273
61632
|
},
|
|
60274
61633
|
addCommands() {
|
|
61634
|
+
const { setItalic, unsetItalic, toggleItalic } = createCascadeToggleCommands({
|
|
61635
|
+
markName: this.name,
|
|
61636
|
+
negationAttrs: { value: "0" }
|
|
61637
|
+
});
|
|
60275
61638
|
return {
|
|
60276
61639
|
/**
|
|
60277
61640
|
* Apply italic formatting
|
|
@@ -60280,7 +61643,7 @@ const Italic = Mark2.create({
|
|
|
60280
61643
|
* @example
|
|
60281
61644
|
* setItalic()
|
|
60282
61645
|
*/
|
|
60283
|
-
setItalic
|
|
61646
|
+
setItalic,
|
|
60284
61647
|
/**
|
|
60285
61648
|
* Remove italic formatting
|
|
60286
61649
|
* @category Command
|
|
@@ -60288,7 +61651,7 @@ const Italic = Mark2.create({
|
|
|
60288
61651
|
* @example
|
|
60289
61652
|
* unsetItalic()
|
|
60290
61653
|
*/
|
|
60291
|
-
unsetItalic
|
|
61654
|
+
unsetItalic,
|
|
60292
61655
|
/**
|
|
60293
61656
|
* Toggle italic formatting
|
|
60294
61657
|
* @category Command
|
|
@@ -60296,7 +61659,7 @@ const Italic = Mark2.create({
|
|
|
60296
61659
|
* @example
|
|
60297
61660
|
* toggleItalic()
|
|
60298
61661
|
*/
|
|
60299
|
-
toggleItalic
|
|
61662
|
+
toggleItalic
|
|
60300
61663
|
};
|
|
60301
61664
|
},
|
|
60302
61665
|
addShortcuts() {
|
|
@@ -60321,7 +61684,16 @@ const Underline = Mark2.create({
|
|
|
60321
61684
|
];
|
|
60322
61685
|
},
|
|
60323
61686
|
renderDOM({ htmlAttributes }) {
|
|
60324
|
-
|
|
61687
|
+
const merged = Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes);
|
|
61688
|
+
const type2 = merged?.underlineType;
|
|
61689
|
+
const color = merged?.underlineColor;
|
|
61690
|
+
const css = getUnderlineCssString({ type: type2, color });
|
|
61691
|
+
const { style: style2, ...rest } = merged || {};
|
|
61692
|
+
const styleString = [style2, css].filter(Boolean).join("; ");
|
|
61693
|
+
if (type2 === "none") {
|
|
61694
|
+
return ["span", { ...rest, ...styleString ? { style: styleString } : {} }, 0];
|
|
61695
|
+
}
|
|
61696
|
+
return ["u", { ...rest, ...styleString ? { style: styleString } : {} }, 0];
|
|
60325
61697
|
},
|
|
60326
61698
|
addAttributes() {
|
|
60327
61699
|
return {
|
|
@@ -60331,10 +61703,18 @@ const Underline = Mark2.create({
|
|
|
60331
61703
|
*/
|
|
60332
61704
|
underlineType: {
|
|
60333
61705
|
default: "single"
|
|
61706
|
+
},
|
|
61707
|
+
underlineColor: {
|
|
61708
|
+
default: null
|
|
60334
61709
|
}
|
|
60335
61710
|
};
|
|
60336
61711
|
},
|
|
60337
61712
|
addCommands() {
|
|
61713
|
+
const { setUnderline, unsetUnderline, toggleUnderline } = createCascadeToggleCommands({
|
|
61714
|
+
markName: this.name,
|
|
61715
|
+
negationAttrs: { underlineType: "none" },
|
|
61716
|
+
isNegation: (attrs) => attrs?.underlineType === "none"
|
|
61717
|
+
});
|
|
60338
61718
|
return {
|
|
60339
61719
|
/**
|
|
60340
61720
|
* Apply underline formatting
|
|
@@ -60343,7 +61723,7 @@ const Underline = Mark2.create({
|
|
|
60343
61723
|
* @example
|
|
60344
61724
|
* setUnderline()
|
|
60345
61725
|
*/
|
|
60346
|
-
setUnderline
|
|
61726
|
+
setUnderline,
|
|
60347
61727
|
/**
|
|
60348
61728
|
* Remove underline formatting
|
|
60349
61729
|
* @category Command
|
|
@@ -60351,7 +61731,7 @@ const Underline = Mark2.create({
|
|
|
60351
61731
|
* @example
|
|
60352
61732
|
* unsetUnderline()
|
|
60353
61733
|
*/
|
|
60354
|
-
unsetUnderline
|
|
61734
|
+
unsetUnderline,
|
|
60355
61735
|
/**
|
|
60356
61736
|
* Toggle underline formatting
|
|
60357
61737
|
* @category Command
|
|
@@ -60359,7 +61739,7 @@ const Underline = Mark2.create({
|
|
|
60359
61739
|
* @example
|
|
60360
61740
|
* toggleUnderline()
|
|
60361
61741
|
*/
|
|
60362
|
-
toggleUnderline
|
|
61742
|
+
toggleUnderline
|
|
60363
61743
|
};
|
|
60364
61744
|
},
|
|
60365
61745
|
addShortcuts() {
|
|
@@ -60454,9 +61834,18 @@ const Strike = Mark2.create({
|
|
|
60454
61834
|
];
|
|
60455
61835
|
},
|
|
60456
61836
|
renderDOM({ htmlAttributes }) {
|
|
60457
|
-
|
|
61837
|
+
const merged = Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes);
|
|
61838
|
+
const { value, ...rest } = merged || {};
|
|
61839
|
+
if (value === "0") {
|
|
61840
|
+
return ["span", rest, 0];
|
|
61841
|
+
}
|
|
61842
|
+
return ["s", rest, 0];
|
|
60458
61843
|
},
|
|
60459
61844
|
addCommands() {
|
|
61845
|
+
const { setStrike, unsetStrike, toggleStrike } = createCascadeToggleCommands({
|
|
61846
|
+
markName: this.name,
|
|
61847
|
+
negationAttrs: { value: "0" }
|
|
61848
|
+
});
|
|
60460
61849
|
return {
|
|
60461
61850
|
/**
|
|
60462
61851
|
* Apply strikethrough formatting
|
|
@@ -60465,9 +61854,7 @@ const Strike = Mark2.create({
|
|
|
60465
61854
|
* @example
|
|
60466
61855
|
* setStrike()
|
|
60467
61856
|
*/
|
|
60468
|
-
setStrike
|
|
60469
|
-
return commands2.setMark(this.name);
|
|
60470
|
-
},
|
|
61857
|
+
setStrike,
|
|
60471
61858
|
/**
|
|
60472
61859
|
* Remove strikethrough formatting
|
|
60473
61860
|
* @category Command
|
|
@@ -60475,9 +61862,7 @@ const Strike = Mark2.create({
|
|
|
60475
61862
|
* @example
|
|
60476
61863
|
* unsetStrike()
|
|
60477
61864
|
*/
|
|
60478
|
-
unsetStrike
|
|
60479
|
-
return commands2.unsetMark(this.name);
|
|
60480
|
-
},
|
|
61865
|
+
unsetStrike,
|
|
60481
61866
|
/**
|
|
60482
61867
|
* Toggle strikethrough formatting
|
|
60483
61868
|
* @category Command
|
|
@@ -60485,8 +61870,24 @@ const Strike = Mark2.create({
|
|
|
60485
61870
|
* @example
|
|
60486
61871
|
* toggleStrike()
|
|
60487
61872
|
*/
|
|
60488
|
-
toggleStrike
|
|
60489
|
-
|
|
61873
|
+
toggleStrike
|
|
61874
|
+
};
|
|
61875
|
+
},
|
|
61876
|
+
addAttributes() {
|
|
61877
|
+
return {
|
|
61878
|
+
/**
|
|
61879
|
+
* @category Attribute
|
|
61880
|
+
* @param {string} [value] - Strike toggle value ('0' renders as normal)
|
|
61881
|
+
*/
|
|
61882
|
+
value: {
|
|
61883
|
+
default: null,
|
|
61884
|
+
renderDOM: (attrs) => {
|
|
61885
|
+
if (!attrs.value) return {};
|
|
61886
|
+
if (attrs.value === "0") {
|
|
61887
|
+
return { style: "text-decoration: none" };
|
|
61888
|
+
}
|
|
61889
|
+
return {};
|
|
61890
|
+
}
|
|
60490
61891
|
}
|
|
60491
61892
|
};
|
|
60492
61893
|
},
|
|
@@ -66641,7 +68042,7 @@ const getStarterExtensions = () => {
|
|
|
66641
68042
|
Paragraph,
|
|
66642
68043
|
LineBreak,
|
|
66643
68044
|
HardBreak,
|
|
66644
|
-
|
|
68045
|
+
Run,
|
|
66645
68046
|
SlashMenu,
|
|
66646
68047
|
Strike,
|
|
66647
68048
|
TabNode,
|
|
@@ -69172,7 +70573,7 @@ function resolveTo(selector) {
|
|
|
69172
70573
|
if (typeof selector === "string") {
|
|
69173
70574
|
return document.querySelector(selector);
|
|
69174
70575
|
}
|
|
69175
|
-
return selector()
|
|
70576
|
+
return selector();
|
|
69176
70577
|
}
|
|
69177
70578
|
const LazyTeleport = defineComponent({
|
|
69178
70579
|
name: "LazyTeleport",
|
|
@@ -69260,11 +70661,8 @@ const oppositeAlignCssPositionProps = {
|
|
|
69260
70661
|
};
|
|
69261
70662
|
const keepOffsetDirection = {
|
|
69262
70663
|
top: true,
|
|
69263
|
-
// top++
|
|
69264
70664
|
bottom: false,
|
|
69265
|
-
// top--
|
|
69266
70665
|
left: true,
|
|
69267
|
-
// left++
|
|
69268
70666
|
right: false
|
|
69269
70667
|
// left--
|
|
69270
70668
|
};
|
|
@@ -70381,6 +71779,7 @@ function isFocusable(element) {
|
|
|
70381
71779
|
return !!element.href && element.rel !== "ignore";
|
|
70382
71780
|
case "INPUT":
|
|
70383
71781
|
return element.type !== "hidden" && element.type !== "file";
|
|
71782
|
+
case "BUTTON":
|
|
70384
71783
|
case "SELECT":
|
|
70385
71784
|
case "TEXTAREA":
|
|
70386
71785
|
return true;
|
|
@@ -70399,8 +71798,8 @@ const FocusTrap = defineComponent({
|
|
|
70399
71798
|
default: true
|
|
70400
71799
|
},
|
|
70401
71800
|
onEsc: Function,
|
|
70402
|
-
initialFocusTo:
|
|
70403
|
-
finalFocusTo:
|
|
71801
|
+
initialFocusTo: String,
|
|
71802
|
+
finalFocusTo: String,
|
|
70404
71803
|
returnFocusOnDeactivated: {
|
|
70405
71804
|
type: Boolean,
|
|
70406
71805
|
default: true
|
|
@@ -72498,7 +73897,6 @@ function self$6(vars) {
|
|
|
72498
73897
|
});
|
|
72499
73898
|
}
|
|
72500
73899
|
const scrollbarLight = {
|
|
72501
|
-
name: "Scrollbar",
|
|
72502
73900
|
common: derived,
|
|
72503
73901
|
self: self$6
|
|
72504
73902
|
};
|
|
@@ -74014,14 +75412,11 @@ function self$5(vars) {
|
|
|
74014
75412
|
boxShadow: boxShadow2
|
|
74015
75413
|
});
|
|
74016
75414
|
}
|
|
74017
|
-
const popoverLight =
|
|
75415
|
+
const popoverLight = {
|
|
74018
75416
|
name: "Popover",
|
|
74019
75417
|
common: derived,
|
|
74020
|
-
peers: {
|
|
74021
|
-
Scrollbar: scrollbarLight
|
|
74022
|
-
},
|
|
74023
75418
|
self: self$5
|
|
74024
|
-
}
|
|
75419
|
+
};
|
|
74025
75420
|
const oppositePlacement = {
|
|
74026
75421
|
top: "bottom",
|
|
74027
75422
|
bottom: "top",
|
|
@@ -74241,11 +75636,9 @@ const NPopoverBody = defineComponent({
|
|
|
74241
75636
|
const {
|
|
74242
75637
|
namespaceRef,
|
|
74243
75638
|
mergedClsPrefixRef,
|
|
74244
|
-
inlineThemeDisabled
|
|
74245
|
-
mergedRtlRef
|
|
75639
|
+
inlineThemeDisabled
|
|
74246
75640
|
} = useConfig(props);
|
|
74247
75641
|
const themeRef = useTheme("Popover", "-popover", style$3, popoverLight, props, mergedClsPrefixRef);
|
|
74248
|
-
const rtlEnabledRef = useRtl("Popover", mergedRtlRef, mergedClsPrefixRef);
|
|
74249
75642
|
const followerRef = ref$1(null);
|
|
74250
75643
|
const NPopover2 = inject("NPopover");
|
|
74251
75644
|
const bodyRef = ref$1(null);
|
|
@@ -74443,8 +75836,6 @@ const NPopoverBody = defineComponent({
|
|
|
74443
75836
|
style: props.contentStyle
|
|
74444
75837
|
}, slots);
|
|
74445
75838
|
const maybeScrollableBody = props.scrollable ? h$1(XScrollbar, {
|
|
74446
|
-
themeOverrides: themeRef.value.peerOverrides.Scrollbar,
|
|
74447
|
-
theme: themeRef.value.peers.Scrollbar,
|
|
74448
75839
|
contentClass: hasHeaderOrFooter ? void 0 : `${mergedClsPrefix}-popover__content ${(_b = props.contentClass) !== null && _b !== void 0 ? _b : ""}`,
|
|
74449
75840
|
contentStyle: hasHeaderOrFooter ? void 0 : props.contentStyle
|
|
74450
75841
|
}, {
|
|
@@ -74460,7 +75851,7 @@ const NPopoverBody = defineComponent({
|
|
|
74460
75851
|
return [maybeScrollableBody, arrow2];
|
|
74461
75852
|
};
|
|
74462
75853
|
contentNode = h$1("div", mergeProps({
|
|
74463
|
-
class: [`${mergedClsPrefix}-popover`, `${mergedClsPrefix}-popover-shared`,
|
|
75854
|
+
class: [`${mergedClsPrefix}-popover`, `${mergedClsPrefix}-popover-shared`, themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass.value, extraClass.map((v2) => `${mergedClsPrefix}-${v2}`), {
|
|
74464
75855
|
[`${mergedClsPrefix}-popover--scrollable`]: props.scrollable,
|
|
74465
75856
|
[`${mergedClsPrefix}-popover--show-header-or-footer`]: hasHeaderOrFooter,
|
|
74466
75857
|
[`${mergedClsPrefix}-popover--raw`]: props.raw,
|
|
@@ -74484,7 +75875,7 @@ const NPopoverBody = defineComponent({
|
|
|
74484
75875
|
// The popover class and overlap class must exists, they will be used
|
|
74485
75876
|
// to place the body & transition animation.
|
|
74486
75877
|
// Shadow class exists for reuse box-shadow.
|
|
74487
|
-
[`${mergedClsPrefix}-popover-shared`,
|
|
75878
|
+
[`${mergedClsPrefix}-popover-shared`, themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass.value, props.overlap && `${mergedClsPrefix}-popover-shared--overlap`, props.showArrow && `${mergedClsPrefix}-popover-shared--show-arrow`, props.arrowPointToCenter && `${mergedClsPrefix}-popover-shared--center-arrow`],
|
|
74488
75879
|
bodyRef,
|
|
74489
75880
|
styleRef.value,
|
|
74490
75881
|
handleMouseEnter,
|
|
@@ -79961,10 +81352,14 @@ class SuperToolbar extends EventEmitter2 {
|
|
|
79961
81352
|
* @param {string} params.argument - The color to set
|
|
79962
81353
|
* @returns {void}
|
|
79963
81354
|
*/
|
|
79964
|
-
setColor: ({
|
|
79965
|
-
|
|
79966
|
-
|
|
79967
|
-
|
|
81355
|
+
setColor: ({ argument }) => {
|
|
81356
|
+
if (!argument || !this.activeEditor) return;
|
|
81357
|
+
const isNone = argument === "none";
|
|
81358
|
+
const value = isNone ? "inherit" : argument;
|
|
81359
|
+
if (this.activeEditor?.commands?.setColor) this.activeEditor.commands.setColor(value);
|
|
81360
|
+
const argValue = isNone ? null : argument;
|
|
81361
|
+
this.activeEditor?.commands.setFieldAnnotationsTextColor(argValue, true);
|
|
81362
|
+
this.updateToolbarState();
|
|
79968
81363
|
},
|
|
79969
81364
|
/**
|
|
79970
81365
|
* Sets the highlight color for text
|
|
@@ -79973,12 +81368,14 @@ class SuperToolbar extends EventEmitter2 {
|
|
|
79973
81368
|
* @param {string} params.argument - The highlight color to set
|
|
79974
81369
|
* @returns {void}
|
|
79975
81370
|
*/
|
|
79976
|
-
setHighlight: ({
|
|
79977
|
-
|
|
79978
|
-
|
|
79979
|
-
|
|
79980
|
-
|
|
79981
|
-
|
|
81371
|
+
setHighlight: ({ argument }) => {
|
|
81372
|
+
if (!argument || !this.activeEditor) return;
|
|
81373
|
+
const inlineColor = argument !== "none" ? argument : "transparent";
|
|
81374
|
+
if (this.activeEditor?.commands?.setHighlight) this.activeEditor.commands.setHighlight(inlineColor);
|
|
81375
|
+
const argValue = argument !== "none" ? argument : null;
|
|
81376
|
+
this.activeEditor?.commands.setFieldAnnotationsTextHighlight(argValue, true);
|
|
81377
|
+
this.activeEditor?.commands.setCellBackground(argValue);
|
|
81378
|
+
this.updateToolbarState();
|
|
79982
81379
|
},
|
|
79983
81380
|
/**
|
|
79984
81381
|
* Toggles the ruler visibility
|
|
@@ -80345,7 +81742,6 @@ class SuperToolbar extends EventEmitter2 {
|
|
|
80345
81742
|
if (!command2) {
|
|
80346
81743
|
return;
|
|
80347
81744
|
}
|
|
80348
|
-
this.log("(emmitCommand) Command:", command2, "\n item:", item, "\n argument:", argument, "\n option:", option);
|
|
80349
81745
|
if (command2 in __privateGet(this, _interceptedCommands)) {
|
|
80350
81746
|
return __privateGet(this, _interceptedCommands)[command2]({ item, argument });
|
|
80351
81747
|
}
|
|
@@ -81908,11 +83304,32 @@ const _sfc_main = {
|
|
|
81908
83304
|
}
|
|
81909
83305
|
};
|
|
81910
83306
|
const SuperInput = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-4d5cff52"]]);
|
|
81911
|
-
const
|
|
81912
|
-
|
|
81913
|
-
"w:
|
|
81914
|
-
"w:
|
|
81915
|
-
|
|
83307
|
+
const baseHandlers = {
|
|
83308
|
+
...runPropertyTranslators,
|
|
83309
|
+
"w:br": translator$v,
|
|
83310
|
+
"w:cantSplit": translator$r,
|
|
83311
|
+
"w:cnfStyle": translator$q,
|
|
83312
|
+
"w:divId": translator$p,
|
|
83313
|
+
"w:gridAfter": translator$o,
|
|
83314
|
+
"w:gridBefore": translator$n,
|
|
83315
|
+
"w:hidden": translator$m,
|
|
83316
|
+
"w:hyperlink": translator$c,
|
|
83317
|
+
"w:jc": translator$l,
|
|
83318
|
+
"w:p": translator$s,
|
|
83319
|
+
"w:r": translator,
|
|
83320
|
+
"w:rPr": translator$1,
|
|
83321
|
+
"w:sdt": translator$b,
|
|
83322
|
+
"w:tab": translator$t,
|
|
83323
|
+
"w:tblCellSpacing": translator$k,
|
|
83324
|
+
"w:tblHeader": translator$j,
|
|
83325
|
+
"w:tc": translator$d,
|
|
83326
|
+
"w:tr": translator$e,
|
|
83327
|
+
"w:trHeight": translator$i,
|
|
83328
|
+
"w:trPr": translator$f,
|
|
83329
|
+
"w:wAfter": translator$h,
|
|
83330
|
+
"w:wBefore": translator$g
|
|
83331
|
+
};
|
|
83332
|
+
const registeredHandlers = Object.freeze(baseHandlers);
|
|
81916
83333
|
const Extensions = {
|
|
81917
83334
|
Node: Node$1,
|
|
81918
83335
|
Attribute: Attribute2,
|