@harbour-enterprises/superdoc 1.3.0-next.1 → 1.3.0-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{PdfViewer-BAoRLNIo.cjs → PdfViewer-D6XxSIuw.cjs} +2 -2
- package/dist/chunks/{PdfViewer-CkOzQzPk.es.js → PdfViewer-ltwzoe73.es.js} +2 -2
- package/dist/chunks/{SuperConverter-BXP6NikG.es.js → SuperConverter-CVOKZex3.es.js} +294 -192
- package/dist/chunks/{SuperConverter-Dy0-KTCc.cjs → SuperConverter-XGlv5pME.cjs} +261 -159
- package/dist/chunks/{index-BNpbdx2a.cjs → index-D0lYfjMI.cjs} +853 -525
- package/dist/chunks/{index-BbvMtiJY.cjs → index-HQW67fDU.cjs} +4 -4
- package/dist/chunks/{index-wwGlJ58Z.es.js → index-M8MvGhiF.es.js} +853 -525
- package/dist/chunks/{index-C31VY_46.es.js → index-e6096-IC.es.js} +4 -4
- package/dist/super-editor/converter.cjs +1 -1
- package/dist/super-editor/converter.es.js +1 -1
- package/dist/super-editor.cjs +2 -2
- package/dist/super-editor.es.js +3 -3
- package/dist/superdoc.cjs +3 -3
- package/dist/superdoc.es.js +3 -3
- package/dist/superdoc.umd.js +1117 -691
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +2 -2
package/dist/superdoc.umd.js
CHANGED
|
@@ -12179,134 +12179,200 @@
|
|
|
12179
12179
|
"italic",
|
|
12180
12180
|
"strike",
|
|
12181
12181
|
"underline",
|
|
12182
|
-
"letterSpacing"
|
|
12183
|
-
"vertAlign",
|
|
12184
|
-
"position"
|
|
12182
|
+
"letterSpacing"
|
|
12185
12183
|
];
|
|
12186
12184
|
const DEFAULT_FONT_SIZE_HALF_POINTS = 20;
|
|
12187
|
-
|
|
12188
|
-
|
|
12185
|
+
function isObject$4(item) {
|
|
12186
|
+
return item != null && typeof item === "object" && !Array.isArray(item);
|
|
12187
|
+
}
|
|
12188
|
+
function combineProperties$1(propertiesArray, options = {}) {
|
|
12189
|
+
const { fullOverrideProps = [], specialHandling = {} } = options;
|
|
12190
|
+
if (!propertiesArray || propertiesArray.length === 0) {
|
|
12191
|
+
return {};
|
|
12192
|
+
}
|
|
12193
|
+
const merge2 = (target, source) => {
|
|
12194
|
+
const output = { ...target };
|
|
12195
|
+
if (isObject$4(target) && isObject$4(source)) {
|
|
12196
|
+
for (const key2 in source) {
|
|
12197
|
+
if (Object.prototype.hasOwnProperty.call(source, key2)) {
|
|
12198
|
+
const handler2 = specialHandling[key2];
|
|
12199
|
+
if (handler2 && typeof handler2 === "function") {
|
|
12200
|
+
output[key2] = handler2(output, source);
|
|
12201
|
+
} else if (!fullOverrideProps.includes(key2) && isObject$4(source[key2])) {
|
|
12202
|
+
if (key2 in target && isObject$4(target[key2])) {
|
|
12203
|
+
output[key2] = merge2(target[key2], source[key2]);
|
|
12204
|
+
} else {
|
|
12205
|
+
output[key2] = source[key2];
|
|
12206
|
+
}
|
|
12207
|
+
} else {
|
|
12208
|
+
output[key2] = source[key2];
|
|
12209
|
+
}
|
|
12210
|
+
}
|
|
12211
|
+
}
|
|
12212
|
+
}
|
|
12213
|
+
return output;
|
|
12214
|
+
};
|
|
12215
|
+
return propertiesArray.reduce((acc, current) => merge2(acc, current ?? {}), {});
|
|
12216
|
+
}
|
|
12217
|
+
function combineRunProperties$1(propertiesArray) {
|
|
12218
|
+
return combineProperties$1(propertiesArray, {
|
|
12219
|
+
fullOverrideProps: ["fontFamily", "color"]
|
|
12220
|
+
});
|
|
12221
|
+
}
|
|
12222
|
+
function applyInlineOverrides(finalProps, inlineProps, overrideKeys = INLINE_OVERRIDE_PROPERTIES) {
|
|
12223
|
+
if (!inlineProps) return finalProps;
|
|
12224
|
+
for (const prop of overrideKeys) {
|
|
12225
|
+
if (inlineProps[prop] != null) {
|
|
12226
|
+
finalProps[prop] = inlineProps[prop];
|
|
12227
|
+
}
|
|
12228
|
+
}
|
|
12229
|
+
return finalProps;
|
|
12230
|
+
}
|
|
12231
|
+
function isValidFontSize(value) {
|
|
12232
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0;
|
|
12233
|
+
}
|
|
12234
|
+
function resolveFontSizeWithFallback(value, defaultProps2, normalProps) {
|
|
12235
|
+
if (isValidFontSize(value)) {
|
|
12236
|
+
return value;
|
|
12237
|
+
}
|
|
12238
|
+
if (defaultProps2 && isValidFontSize(defaultProps2.fontSize)) {
|
|
12239
|
+
return defaultProps2.fontSize;
|
|
12240
|
+
}
|
|
12241
|
+
if (normalProps && isValidFontSize(normalProps.fontSize)) {
|
|
12242
|
+
return normalProps.fontSize;
|
|
12243
|
+
}
|
|
12244
|
+
return DEFAULT_FONT_SIZE_HALF_POINTS;
|
|
12245
|
+
}
|
|
12246
|
+
function orderDefaultsAndNormal(defaultProps2, normalProps, isNormalDefault) {
|
|
12247
|
+
if (isNormalDefault) {
|
|
12248
|
+
return [defaultProps2, normalProps];
|
|
12249
|
+
} else {
|
|
12250
|
+
return [normalProps, defaultProps2];
|
|
12251
|
+
}
|
|
12252
|
+
}
|
|
12253
|
+
function createFirstLineIndentHandler() {
|
|
12254
|
+
return (target, source) => {
|
|
12255
|
+
if (target.hanging != null && source.firstLine != null) {
|
|
12256
|
+
delete target.hanging;
|
|
12257
|
+
}
|
|
12258
|
+
return source.firstLine;
|
|
12259
|
+
};
|
|
12260
|
+
}
|
|
12261
|
+
function combineIndentProperties(indentChain) {
|
|
12262
|
+
const indentOnly = indentChain.map((props) => props.indent != null ? { indent: props.indent } : {});
|
|
12263
|
+
return combineProperties$1(indentOnly, {
|
|
12264
|
+
specialHandling: {
|
|
12265
|
+
firstLine: createFirstLineIndentHandler()
|
|
12266
|
+
}
|
|
12267
|
+
});
|
|
12268
|
+
}
|
|
12269
|
+
function createOoxmlResolver(translators) {
|
|
12270
|
+
return {
|
|
12271
|
+
resolveRunProperties: (params2, inlineRpr, resolvedPpr, isListNumber = false, numberingDefinedInline = false) => resolveRunProperties$1(translators, params2, inlineRpr, resolvedPpr, isListNumber, numberingDefinedInline),
|
|
12272
|
+
resolveParagraphProperties: (params2, inlineProps, insideTable = false, overrideInlineStyleId = false, tableStyleId = null) => resolveParagraphProperties$1(translators, params2, inlineProps, insideTable, overrideInlineStyleId, tableStyleId),
|
|
12273
|
+
getDefaultProperties,
|
|
12274
|
+
getStyleProperties,
|
|
12275
|
+
resolveStyleChain: resolveStyleChain$1,
|
|
12276
|
+
getNumberingProperties: (params2, ilvl, numId, translator2, tries = 0) => getNumberingProperties(translators, params2, ilvl, numId, translator2, tries)
|
|
12277
|
+
};
|
|
12278
|
+
}
|
|
12279
|
+
function resolveRunProperties$1(translators, params2, inlineRpr, resolvedPpr, isListNumber = false, numberingDefinedInline = false) {
|
|
12189
12280
|
const paragraphStyleId = resolvedPpr?.styleId;
|
|
12190
|
-
const paragraphStyleProps = resolveStyleChain$1(params2, paragraphStyleId,
|
|
12191
|
-
const defaultProps2 = getDefaultProperties(params2,
|
|
12192
|
-
const { properties: normalProps, isDefault: isNormalDefault } = getStyleProperties(params2, "Normal",
|
|
12281
|
+
const paragraphStyleProps = resolveStyleChain$1(params2, paragraphStyleId, translators.rPr);
|
|
12282
|
+
const defaultProps2 = getDefaultProperties(params2, translators.rPr);
|
|
12283
|
+
const { properties: normalProps, isDefault: isNormalDefault } = getStyleProperties(params2, "Normal", translators.rPr);
|
|
12193
12284
|
let runStyleProps = {};
|
|
12194
12285
|
if (!paragraphStyleId?.startsWith("TOC")) {
|
|
12195
|
-
runStyleProps = inlineRpr
|
|
12286
|
+
runStyleProps = inlineRpr?.styleId ? resolveStyleChain$1(params2, inlineRpr.styleId, translators.rPr) : {};
|
|
12196
12287
|
}
|
|
12288
|
+
const defaultsChain = orderDefaultsAndNormal(defaultProps2, normalProps, isNormalDefault);
|
|
12289
|
+
const inlineRprSafe = inlineRpr ?? {};
|
|
12197
12290
|
let styleChain;
|
|
12198
|
-
|
|
12199
|
-
styleChain = [defaultProps2, normalProps];
|
|
12200
|
-
} else {
|
|
12201
|
-
styleChain = [normalProps, defaultProps2];
|
|
12202
|
-
}
|
|
12291
|
+
let inlineOverrideSource = inlineRprSafe;
|
|
12203
12292
|
if (isListNumber) {
|
|
12204
12293
|
let numberingProps = {};
|
|
12205
|
-
const
|
|
12294
|
+
const numberingProperties = resolvedPpr?.numberingProperties;
|
|
12295
|
+
const numId = numberingProperties?.numId;
|
|
12206
12296
|
if (numId != null && numId !== 0 && numId !== "0") {
|
|
12207
12297
|
numberingProps = getNumberingProperties(
|
|
12298
|
+
translators,
|
|
12208
12299
|
params2,
|
|
12209
|
-
|
|
12300
|
+
numberingProperties?.ilvl ?? 0,
|
|
12210
12301
|
numId,
|
|
12211
|
-
|
|
12302
|
+
translators.rPr
|
|
12212
12303
|
);
|
|
12213
12304
|
}
|
|
12214
|
-
|
|
12215
|
-
|
|
12216
|
-
|
|
12217
|
-
if (inlineRpr?.underline) {
|
|
12218
|
-
delete inlineRpr.underline;
|
|
12305
|
+
const inlineRprForList = numberingDefinedInline ? inlineRprSafe : {};
|
|
12306
|
+
if (inlineRprForList?.underline) {
|
|
12307
|
+
delete inlineRprForList.underline;
|
|
12219
12308
|
}
|
|
12220
|
-
styleChain = [...
|
|
12309
|
+
styleChain = [...defaultsChain, paragraphStyleProps, runStyleProps, inlineRprForList, numberingProps];
|
|
12310
|
+
inlineOverrideSource = inlineRprForList;
|
|
12221
12311
|
} else {
|
|
12222
|
-
styleChain = [...
|
|
12223
|
-
}
|
|
12224
|
-
const finalProps = combineProperties(styleChain, ["fontFamily", "color"]);
|
|
12225
|
-
for (const prop of INLINE_OVERRIDE_PROPERTIES) {
|
|
12226
|
-
if (inlineRpr?.[prop] != null) {
|
|
12227
|
-
finalProps[prop] = inlineRpr[prop];
|
|
12228
|
-
}
|
|
12229
|
-
}
|
|
12230
|
-
if (finalProps.fontSize == null || typeof finalProps.fontSize !== "number" || !Number.isFinite(finalProps.fontSize) || finalProps.fontSize <= 0) {
|
|
12231
|
-
let defaultFontSize = DEFAULT_FONT_SIZE_HALF_POINTS;
|
|
12232
|
-
if (defaultProps2?.fontSize != null && typeof defaultProps2.fontSize === "number" && Number.isFinite(defaultProps2.fontSize) && defaultProps2.fontSize > 0) {
|
|
12233
|
-
defaultFontSize = defaultProps2.fontSize;
|
|
12234
|
-
} else if (normalProps?.fontSize != null && typeof normalProps.fontSize === "number" && Number.isFinite(normalProps.fontSize) && normalProps.fontSize > 0) {
|
|
12235
|
-
defaultFontSize = normalProps.fontSize;
|
|
12236
|
-
}
|
|
12237
|
-
finalProps.fontSize = defaultFontSize;
|
|
12312
|
+
styleChain = [...defaultsChain, paragraphStyleProps, runStyleProps, inlineRprSafe];
|
|
12238
12313
|
}
|
|
12314
|
+
const finalProps = combineRunProperties$1(styleChain);
|
|
12315
|
+
applyInlineOverrides(finalProps, inlineOverrideSource);
|
|
12316
|
+
finalProps.fontSize = resolveFontSizeWithFallback(finalProps.fontSize, defaultProps2, normalProps);
|
|
12239
12317
|
return finalProps;
|
|
12240
|
-
}
|
|
12241
|
-
function resolveParagraphProperties(params2, inlineProps, insideTable = false, overrideInlineStyleId = false, tableStyleId = null) {
|
|
12242
|
-
const defaultProps2 = getDefaultProperties(params2,
|
|
12243
|
-
const { properties: normalProps, isDefault: isNormalDefault } = getStyleProperties(params2, "Normal",
|
|
12244
|
-
|
|
12245
|
-
let
|
|
12318
|
+
}
|
|
12319
|
+
function resolveParagraphProperties$1(translators, params2, inlineProps, insideTable = false, overrideInlineStyleId = false, tableStyleId = null) {
|
|
12320
|
+
const defaultProps2 = getDefaultProperties(params2, translators.pPr);
|
|
12321
|
+
const { properties: normalProps, isDefault: isNormalDefault } = getStyleProperties(params2, "Normal", translators.pPr);
|
|
12322
|
+
const inlinePropsSafe = inlineProps ?? {};
|
|
12323
|
+
let styleId = inlinePropsSafe?.styleId;
|
|
12324
|
+
let styleProps = inlinePropsSafe?.styleId ? resolveStyleChain$1(params2, inlinePropsSafe.styleId, translators.pPr) : {};
|
|
12246
12325
|
let numberingProps = {};
|
|
12247
|
-
|
|
12248
|
-
let numId =
|
|
12249
|
-
let numberingDefinedInline =
|
|
12250
|
-
const
|
|
12326
|
+
const ilvl = inlinePropsSafe?.numberingProperties?.ilvl ?? styleProps?.numberingProperties?.ilvl;
|
|
12327
|
+
let numId = inlinePropsSafe?.numberingProperties?.numId ?? styleProps?.numberingProperties?.numId;
|
|
12328
|
+
let numberingDefinedInline = inlinePropsSafe?.numberingProperties?.numId != null;
|
|
12329
|
+
const inlineNumId = inlinePropsSafe?.numberingProperties?.numId;
|
|
12330
|
+
const inlineNumIdDisablesNumbering = inlineNumId === 0 || inlineNumId === "0";
|
|
12251
12331
|
if (inlineNumIdDisablesNumbering) {
|
|
12252
12332
|
numId = null;
|
|
12253
12333
|
}
|
|
12254
12334
|
const isList2 = numId != null && numId !== 0 && numId !== "0";
|
|
12255
12335
|
if (isList2) {
|
|
12256
|
-
|
|
12257
|
-
numberingProps = getNumberingProperties(params2,
|
|
12336
|
+
const ilvlNum = ilvl != null ? ilvl : 0;
|
|
12337
|
+
numberingProps = getNumberingProperties(translators, params2, ilvlNum, numId, translators.pPr);
|
|
12258
12338
|
if (overrideInlineStyleId && numberingProps.styleId) {
|
|
12259
12339
|
styleId = numberingProps.styleId;
|
|
12260
|
-
styleProps = resolveStyleChain$1(params2, styleId,
|
|
12261
|
-
if (
|
|
12262
|
-
|
|
12263
|
-
|
|
12264
|
-
|
|
12340
|
+
styleProps = resolveStyleChain$1(params2, styleId, translators.pPr);
|
|
12341
|
+
if (inlinePropsSafe) {
|
|
12342
|
+
inlinePropsSafe.styleId = styleId;
|
|
12343
|
+
const inlineNumProps = inlinePropsSafe.numberingProperties;
|
|
12344
|
+
if (styleProps.numberingProperties?.ilvl === inlineNumProps?.ilvl && styleProps.numberingProperties?.numId === inlineNumProps?.numId) {
|
|
12345
|
+
delete inlinePropsSafe.numberingProperties;
|
|
12265
12346
|
numberingDefinedInline = false;
|
|
12266
12347
|
}
|
|
12267
12348
|
}
|
|
12268
12349
|
}
|
|
12269
12350
|
}
|
|
12270
|
-
const tableProps = tableStyleId ? resolveStyleChain$1(params2, tableStyleId,
|
|
12271
|
-
|
|
12272
|
-
|
|
12273
|
-
defaultsChain = [defaultProps2, normalProps];
|
|
12274
|
-
} else {
|
|
12275
|
-
defaultsChain = [normalProps, defaultProps2];
|
|
12276
|
-
}
|
|
12277
|
-
const propsChain = [...defaultsChain, tableProps, numberingProps, styleProps, inlineProps];
|
|
12351
|
+
const tableProps = tableStyleId ? resolveStyleChain$1(params2, tableStyleId, translators.pPr) : {};
|
|
12352
|
+
const defaultsChain = orderDefaultsAndNormal(defaultProps2, normalProps, isNormalDefault);
|
|
12353
|
+
const propsChain = [...defaultsChain, tableProps, numberingProps, styleProps, inlinePropsSafe];
|
|
12278
12354
|
let indentChain;
|
|
12279
12355
|
if (isList2) {
|
|
12280
12356
|
if (numberingDefinedInline) {
|
|
12281
|
-
indentChain = [...defaultsChain, styleProps, numberingProps,
|
|
12357
|
+
indentChain = [...defaultsChain, styleProps, numberingProps, inlinePropsSafe];
|
|
12282
12358
|
} else {
|
|
12283
|
-
styleProps = resolveStyleChain$1(params2, styleId,
|
|
12284
|
-
indentChain = [...defaultsChain, numberingProps, styleProps,
|
|
12359
|
+
styleProps = resolveStyleChain$1(params2, styleId, translators.pPr, false);
|
|
12360
|
+
indentChain = [...defaultsChain, numberingProps, styleProps, inlinePropsSafe];
|
|
12285
12361
|
}
|
|
12286
12362
|
} else {
|
|
12287
|
-
indentChain = [...defaultsChain, numberingProps, styleProps,
|
|
12363
|
+
indentChain = [...defaultsChain, numberingProps, styleProps, inlinePropsSafe];
|
|
12288
12364
|
}
|
|
12289
|
-
|
|
12290
|
-
|
|
12291
|
-
indentChain.map((props) => props.indent != null ? { indent: props.indent } : {}),
|
|
12292
|
-
[],
|
|
12293
|
-
{
|
|
12294
|
-
firstLine: (target, source) => {
|
|
12295
|
-
if (target.hanging != null && source.firstLine != null) {
|
|
12296
|
-
delete target.hanging;
|
|
12297
|
-
}
|
|
12298
|
-
return source.firstLine;
|
|
12299
|
-
}
|
|
12300
|
-
}
|
|
12301
|
-
);
|
|
12365
|
+
const finalProps = combineProperties$1(propsChain);
|
|
12366
|
+
const finalIndent = combineIndentProperties(indentChain);
|
|
12302
12367
|
finalProps.indent = finalIndent.indent;
|
|
12303
|
-
if (insideTable && !
|
|
12368
|
+
if (insideTable && !inlinePropsSafe?.spacing && !styleProps?.spacing) {
|
|
12304
12369
|
finalProps.spacing = void 0;
|
|
12305
12370
|
}
|
|
12306
12371
|
return finalProps;
|
|
12307
12372
|
}
|
|
12308
|
-
|
|
12309
|
-
let styleProps = {}
|
|
12373
|
+
function resolveStyleChain$1(params2, styleId, translator2, followBasedOnChain = true) {
|
|
12374
|
+
let styleProps = {};
|
|
12375
|
+
let basedOn = void 0;
|
|
12310
12376
|
if (styleId && styleId !== "Normal") {
|
|
12311
12377
|
({ properties: styleProps, basedOn } = getStyleProperties(params2, styleId, translator2));
|
|
12312
12378
|
}
|
|
@@ -12318,7 +12384,7 @@
|
|
|
12318
12384
|
break;
|
|
12319
12385
|
}
|
|
12320
12386
|
seenStyles.add(basedOn);
|
|
12321
|
-
const result = getStyleProperties(params2,
|
|
12387
|
+
const result = getStyleProperties(params2, nextBasedOn, translator2);
|
|
12322
12388
|
const basedOnProps = result.properties;
|
|
12323
12389
|
nextBasedOn = result.basedOn;
|
|
12324
12390
|
if (basedOnProps && Object.keys(basedOnProps).length) {
|
|
@@ -12327,120 +12393,499 @@
|
|
|
12327
12393
|
basedOn = nextBasedOn;
|
|
12328
12394
|
}
|
|
12329
12395
|
styleChain = styleChain.reverse();
|
|
12330
|
-
|
|
12331
|
-
|
|
12332
|
-
};
|
|
12396
|
+
return combineProperties$1(styleChain);
|
|
12397
|
+
}
|
|
12333
12398
|
function getDefaultProperties(params2, translator2) {
|
|
12334
|
-
const
|
|
12335
|
-
const styles = docx["word/styles.xml"];
|
|
12399
|
+
const docx = params2?.docx;
|
|
12400
|
+
const styles = docx?.["word/styles.xml"];
|
|
12336
12401
|
const rootElements = styles?.elements?.[0]?.elements;
|
|
12337
12402
|
if (!rootElements?.length) {
|
|
12338
12403
|
return {};
|
|
12339
12404
|
}
|
|
12340
12405
|
const defaults2 = rootElements.find((el) => el.name === "w:docDefaults");
|
|
12341
12406
|
const xmlName = translator2.xmlName;
|
|
12342
|
-
const
|
|
12343
|
-
const
|
|
12407
|
+
const defaultsElements = defaults2?.elements;
|
|
12408
|
+
const elementPrDefault = defaultsElements?.find((el) => el.name === `${xmlName}Default`);
|
|
12409
|
+
const elementPrDefaultElements = elementPrDefault?.elements;
|
|
12410
|
+
const elementPr = elementPrDefaultElements?.find((el) => el.name === xmlName);
|
|
12344
12411
|
if (!elementPr) {
|
|
12345
12412
|
return {};
|
|
12346
12413
|
}
|
|
12347
|
-
|
|
12348
|
-
return result;
|
|
12414
|
+
return translator2.encode({ ...params2, nodes: [elementPr] }) || {};
|
|
12349
12415
|
}
|
|
12350
12416
|
function getStyleProperties(params2, styleId, translator2) {
|
|
12351
|
-
const {
|
|
12352
|
-
const emptyResult = { properties: {}, isDefault: false, basedOn: null };
|
|
12417
|
+
const emptyResult = { properties: {}, isDefault: false, basedOn: void 0 };
|
|
12353
12418
|
if (!styleId) return emptyResult;
|
|
12354
|
-
const
|
|
12419
|
+
const docx = params2?.docx;
|
|
12420
|
+
const styles = docx?.["word/styles.xml"];
|
|
12355
12421
|
const rootElements = styles?.elements?.[0]?.elements;
|
|
12356
12422
|
if (!rootElements?.length) {
|
|
12357
12423
|
return emptyResult;
|
|
12358
12424
|
}
|
|
12359
|
-
const style2 = rootElements.find(
|
|
12360
|
-
|
|
12361
|
-
|
|
12362
|
-
|
|
12363
|
-
|
|
12364
|
-
const
|
|
12425
|
+
const style2 = rootElements.find(
|
|
12426
|
+
(el) => el.name === "w:style" && el.attributes?.["w:styleId"] === styleId
|
|
12427
|
+
);
|
|
12428
|
+
const styleElements = style2?.elements;
|
|
12429
|
+
const basedOnElement = styleElements?.find((el) => el.name === "w:basedOn");
|
|
12430
|
+
const basedOn = basedOnElement?.attributes?.["w:val"];
|
|
12431
|
+
const elementPr = styleElements?.find((el) => el.name === translator2.xmlName);
|
|
12365
12432
|
if (!elementPr) {
|
|
12366
12433
|
return { ...emptyResult, basedOn };
|
|
12367
12434
|
}
|
|
12368
12435
|
const result = translator2.encode({ ...params2, nodes: [elementPr] }) || {};
|
|
12369
|
-
|
|
12436
|
+
const isDefault = style2?.attributes?.["w:default"] === "1";
|
|
12437
|
+
return { properties: result, isDefault, basedOn };
|
|
12370
12438
|
}
|
|
12371
|
-
function getNumberingProperties(params2, ilvl, numId, translator2, tries = 0) {
|
|
12372
|
-
const
|
|
12373
|
-
if (!
|
|
12374
|
-
const { definitions, abstracts } =
|
|
12439
|
+
function getNumberingProperties(translators, params2, ilvl, numId, translator2, tries = 0) {
|
|
12440
|
+
const numbering = params2?.numbering;
|
|
12441
|
+
if (!numbering) return {};
|
|
12442
|
+
const { definitions, abstracts } = numbering;
|
|
12443
|
+
if (!definitions || !abstracts) return {};
|
|
12375
12444
|
const propertiesChain = [];
|
|
12376
12445
|
const numDefinition = definitions[numId];
|
|
12377
12446
|
if (!numDefinition) return {};
|
|
12378
|
-
const
|
|
12379
|
-
|
|
12447
|
+
const numDefElements = numDefinition.elements;
|
|
12448
|
+
const lvlOverride = numDefElements?.find(
|
|
12449
|
+
(element2) => element2.name === "w:lvlOverride" && element2.attributes?.["w:ilvl"] == ilvl
|
|
12380
12450
|
);
|
|
12381
|
-
const
|
|
12451
|
+
const lvlOverrideElements = lvlOverride?.elements;
|
|
12452
|
+
const overridePr = lvlOverrideElements?.find((el) => el.name === translator2.xmlName);
|
|
12382
12453
|
if (overridePr) {
|
|
12383
12454
|
const overrideProps = translator2.encode({ ...params2, nodes: [overridePr] }) || {};
|
|
12384
12455
|
propertiesChain.push(overrideProps);
|
|
12385
12456
|
}
|
|
12386
|
-
const
|
|
12457
|
+
const abstractNumIdElement = numDefElements?.find((item) => item.name === "w:abstractNumId");
|
|
12458
|
+
const abstractNumId = abstractNumIdElement?.attributes?.["w:val"];
|
|
12387
12459
|
const listDefinitionForThisNumId = abstracts[abstractNumId];
|
|
12388
12460
|
if (!listDefinitionForThisNumId) return {};
|
|
12389
|
-
const
|
|
12461
|
+
const listDefElements = listDefinitionForThisNumId.elements;
|
|
12462
|
+
const numStyleLink = listDefElements?.find((item) => item.name === "w:numStyleLink");
|
|
12390
12463
|
const styleId = numStyleLink?.attributes?.["w:val"];
|
|
12391
12464
|
if (styleId && tries < 1) {
|
|
12392
|
-
const { properties: styleProps } = getStyleProperties(params2, styleId,
|
|
12393
|
-
|
|
12394
|
-
|
|
12465
|
+
const { properties: styleProps } = getStyleProperties(params2, styleId, translators.pPr);
|
|
12466
|
+
const numIdFromStyle = styleProps?.numberingProperties?.numId;
|
|
12467
|
+
if (numIdFromStyle) {
|
|
12468
|
+
return getNumberingProperties(
|
|
12469
|
+
translators,
|
|
12470
|
+
params2,
|
|
12471
|
+
ilvl,
|
|
12472
|
+
numIdFromStyle,
|
|
12473
|
+
translator2,
|
|
12474
|
+
tries + 1
|
|
12475
|
+
);
|
|
12395
12476
|
}
|
|
12396
12477
|
}
|
|
12397
|
-
const levelDefinition =
|
|
12398
|
-
(element2) => element2.name === "w:lvl" && element2.attributes["w:ilvl"] == ilvl
|
|
12478
|
+
const levelDefinition = listDefElements?.find(
|
|
12479
|
+
(element2) => element2.name === "w:lvl" && element2.attributes?.["w:ilvl"] == ilvl
|
|
12399
12480
|
);
|
|
12400
12481
|
if (!levelDefinition) return {};
|
|
12401
|
-
const
|
|
12482
|
+
const levelDefElements = levelDefinition.elements;
|
|
12483
|
+
const abstractElementPr = levelDefElements?.find((el) => el.name === translator2.xmlName);
|
|
12402
12484
|
if (!abstractElementPr) return {};
|
|
12403
12485
|
const abstractProps = translator2.encode({ ...params2, nodes: [abstractElementPr] }) || {};
|
|
12404
|
-
const pStyleElement =
|
|
12486
|
+
const pStyleElement = levelDefElements?.find((el) => el.name === "w:pStyle");
|
|
12405
12487
|
if (pStyleElement) {
|
|
12406
|
-
const pStyleId = pStyleElement
|
|
12488
|
+
const pStyleId = pStyleElement.attributes?.["w:val"];
|
|
12407
12489
|
abstractProps.styleId = pStyleId;
|
|
12408
12490
|
}
|
|
12409
12491
|
propertiesChain.push(abstractProps);
|
|
12410
12492
|
propertiesChain.reverse();
|
|
12411
|
-
|
|
12412
|
-
return result;
|
|
12493
|
+
return combineProperties$1(propertiesChain);
|
|
12413
12494
|
}
|
|
12414
|
-
|
|
12415
|
-
if (!
|
|
12416
|
-
|
|
12495
|
+
function resolveDocxFontFamily(attributes, docx, toCssFontFamily2) {
|
|
12496
|
+
if (!attributes || typeof attributes !== "object") return null;
|
|
12497
|
+
const ascii = attributes["w:ascii"] ?? attributes["ascii"];
|
|
12498
|
+
const themeAscii = attributes["w:asciiTheme"] ?? attributes["asciiTheme"];
|
|
12499
|
+
let resolved = ascii;
|
|
12500
|
+
if (docx && themeAscii) {
|
|
12501
|
+
const theme = docx["word/theme/theme1.xml"];
|
|
12502
|
+
const themeElements = theme?.elements;
|
|
12503
|
+
if (themeElements?.length) {
|
|
12504
|
+
const topElement = themeElements[0];
|
|
12505
|
+
const topElementElements = topElement?.elements;
|
|
12506
|
+
const themeElementsNode = topElementElements?.find((el) => el.name === "a:themeElements");
|
|
12507
|
+
const themeElementsElements = themeElementsNode?.elements;
|
|
12508
|
+
const fontScheme = themeElementsElements?.find((el) => el.name === "a:fontScheme");
|
|
12509
|
+
const fontSchemeElements = fontScheme?.elements;
|
|
12510
|
+
const prefix2 = themeAscii.startsWith("minor") ? "minor" : "major";
|
|
12511
|
+
const font = fontSchemeElements?.find((el) => el.name === `a:${prefix2}Font`);
|
|
12512
|
+
const fontElements = font?.elements;
|
|
12513
|
+
const latin = fontElements?.find((el) => el.name === "a:latin");
|
|
12514
|
+
const typeface = latin?.attributes?.typeface;
|
|
12515
|
+
resolved = typeface || resolved;
|
|
12516
|
+
}
|
|
12417
12517
|
}
|
|
12418
|
-
|
|
12419
|
-
|
|
12420
|
-
|
|
12421
|
-
|
|
12422
|
-
|
|
12423
|
-
|
|
12424
|
-
|
|
12425
|
-
|
|
12426
|
-
|
|
12427
|
-
|
|
12428
|
-
|
|
12429
|
-
|
|
12430
|
-
|
|
12431
|
-
|
|
12432
|
-
|
|
12433
|
-
|
|
12434
|
-
|
|
12435
|
-
|
|
12436
|
-
|
|
12437
|
-
|
|
12438
|
-
|
|
12439
|
-
|
|
12518
|
+
if (!resolved) return null;
|
|
12519
|
+
if (toCssFontFamily2) {
|
|
12520
|
+
return toCssFontFamily2(resolved, docx ?? void 0);
|
|
12521
|
+
}
|
|
12522
|
+
return resolved;
|
|
12523
|
+
}
|
|
12524
|
+
const FONT_FAMILY_FALLBACKS$1 = Object.freeze({
|
|
12525
|
+
swiss: "Arial, sans-serif",
|
|
12526
|
+
roman: "Times New Roman, serif",
|
|
12527
|
+
modern: "Courier New, monospace",
|
|
12528
|
+
script: "cursive",
|
|
12529
|
+
decorative: "fantasy",
|
|
12530
|
+
system: "system-ui",
|
|
12531
|
+
auto: "sans-serif"
|
|
12532
|
+
});
|
|
12533
|
+
const DEFAULT_GENERIC_FALLBACK$1 = "sans-serif";
|
|
12534
|
+
const normalizeParts = (value) => (value || "").split(",").map((part) => part.trim()).filter(Boolean);
|
|
12535
|
+
function mapWordFamilyFallback(wordFamily) {
|
|
12536
|
+
if (!wordFamily) return DEFAULT_GENERIC_FALLBACK$1;
|
|
12537
|
+
const mapped = FONT_FAMILY_FALLBACKS$1[wordFamily.toLowerCase()];
|
|
12538
|
+
return mapped || DEFAULT_GENERIC_FALLBACK$1;
|
|
12539
|
+
}
|
|
12540
|
+
function toCssFontFamily(fontName, options = {}) {
|
|
12541
|
+
if (!fontName || typeof fontName !== "string") return fontName;
|
|
12542
|
+
const trimmed = fontName.trim();
|
|
12543
|
+
if (!trimmed || trimmed.includes(",")) return trimmed;
|
|
12544
|
+
const { fallback, wordFamily } = options;
|
|
12545
|
+
const fallbackValue = fallback ?? (wordFamily ? mapWordFamilyFallback(wordFamily) : void 0) ?? DEFAULT_GENERIC_FALLBACK$1;
|
|
12546
|
+
const fallbackParts = normalizeParts(fallbackValue);
|
|
12547
|
+
if (fallbackParts.length === 0) {
|
|
12548
|
+
return trimmed;
|
|
12549
|
+
}
|
|
12550
|
+
const normalizedName = trimmed.toLowerCase();
|
|
12551
|
+
const includesName = fallbackParts.some((part) => part.toLowerCase() === normalizedName);
|
|
12552
|
+
if (includesName) {
|
|
12553
|
+
return fallbackParts.join(", ");
|
|
12554
|
+
}
|
|
12555
|
+
return [trimmed, ...fallbackParts].join(", ");
|
|
12556
|
+
}
|
|
12557
|
+
const sdtMetadataCache = /* @__PURE__ */ new Map();
|
|
12558
|
+
function resolveStyle(node2, context, options = {}) {
|
|
12559
|
+
let paragraph2 = createDefaultParagraph();
|
|
12560
|
+
let character = createDefaultCharacter(context);
|
|
12561
|
+
let numbering;
|
|
12562
|
+
const chain = resolveStyleChain(node2.styleId, context.styles);
|
|
12563
|
+
for (const style2 of chain) {
|
|
12564
|
+
paragraph2 = mergeParagraph(paragraph2, style2.paragraph);
|
|
12565
|
+
character = mergeCharacter(character, style2.character);
|
|
12566
|
+
if (!numbering && style2.numbering) {
|
|
12567
|
+
numbering = resolveNumbering(style2.numbering.numId, style2.numbering.level, context);
|
|
12440
12568
|
}
|
|
12441
|
-
|
|
12569
|
+
}
|
|
12570
|
+
paragraph2 = mergeParagraph(paragraph2, node2.paragraphProps);
|
|
12571
|
+
character = mergeCharacter(character, node2.characterProps);
|
|
12572
|
+
if (node2.numbering) {
|
|
12573
|
+
numbering = resolveNumbering(node2.numbering.numId, node2.numbering.level, context);
|
|
12574
|
+
}
|
|
12575
|
+
const sdt = options?.sdt ? resolveSdtMetadata(options.sdt) : void 0;
|
|
12576
|
+
return {
|
|
12577
|
+
paragraph: paragraph2,
|
|
12578
|
+
character,
|
|
12579
|
+
numbering,
|
|
12580
|
+
sdt
|
|
12581
|
+
};
|
|
12582
|
+
}
|
|
12583
|
+
function resolveNumbering(numId, level, context) {
|
|
12584
|
+
const def2 = context.numbering?.[numId];
|
|
12585
|
+
if (!def2) return void 0;
|
|
12586
|
+
const levelDef = def2.levels.find((entry) => entry.level === level) ?? def2.levels[level];
|
|
12587
|
+
if (!levelDef) return void 0;
|
|
12588
|
+
return {
|
|
12589
|
+
numId,
|
|
12590
|
+
level,
|
|
12591
|
+
indent: {
|
|
12592
|
+
left: levelDef.indent?.left,
|
|
12593
|
+
hanging: levelDef.indent?.hanging
|
|
12594
|
+
},
|
|
12595
|
+
format: levelDef.format ?? "decimal",
|
|
12596
|
+
text: levelDef.text ?? "%1.",
|
|
12597
|
+
start: levelDef.start ?? 1
|
|
12598
|
+
};
|
|
12599
|
+
}
|
|
12600
|
+
function resolveSdtMetadata(input2) {
|
|
12601
|
+
if (!input2) return void 0;
|
|
12602
|
+
const { nodeType, attrs, cacheKey: explicitKey } = input2;
|
|
12603
|
+
if (!nodeType) return void 0;
|
|
12604
|
+
const normalizedAttrs = isPlainObject$7(attrs) ? attrs : {};
|
|
12605
|
+
const cacheKey = buildSdtCacheKey(nodeType, normalizedAttrs, explicitKey);
|
|
12606
|
+
if (cacheKey && sdtMetadataCache.has(cacheKey)) {
|
|
12607
|
+
return sdtMetadataCache.get(cacheKey);
|
|
12608
|
+
}
|
|
12609
|
+
let metadata;
|
|
12610
|
+
switch (nodeType) {
|
|
12611
|
+
case "fieldAnnotation":
|
|
12612
|
+
metadata = normalizeFieldAnnotationMetadata(normalizedAttrs);
|
|
12613
|
+
break;
|
|
12614
|
+
case "structuredContent":
|
|
12615
|
+
case "structuredContentBlock":
|
|
12616
|
+
metadata = normalizeStructuredContentMetadata(nodeType, normalizedAttrs);
|
|
12617
|
+
break;
|
|
12618
|
+
case "documentSection":
|
|
12619
|
+
metadata = normalizeDocumentSectionMetadata(normalizedAttrs);
|
|
12620
|
+
break;
|
|
12621
|
+
case "docPartObject":
|
|
12622
|
+
metadata = normalizeDocPartMetadata(normalizedAttrs);
|
|
12623
|
+
break;
|
|
12624
|
+
}
|
|
12625
|
+
if (metadata && cacheKey) {
|
|
12626
|
+
sdtMetadataCache.set(cacheKey, metadata);
|
|
12627
|
+
}
|
|
12628
|
+
return metadata;
|
|
12629
|
+
}
|
|
12630
|
+
function createDefaultParagraph(_context) {
|
|
12631
|
+
return {
|
|
12632
|
+
alignment: "left",
|
|
12633
|
+
spacing: {
|
|
12634
|
+
before: 0,
|
|
12635
|
+
after: 0,
|
|
12636
|
+
line: 12,
|
|
12637
|
+
lineRule: "auto"
|
|
12638
|
+
},
|
|
12639
|
+
indent: {
|
|
12640
|
+
left: 0,
|
|
12641
|
+
right: 0,
|
|
12642
|
+
firstLine: 0,
|
|
12643
|
+
hanging: 0
|
|
12644
|
+
},
|
|
12645
|
+
tabs: []
|
|
12646
|
+
};
|
|
12647
|
+
}
|
|
12648
|
+
function createDefaultCharacter(context) {
|
|
12649
|
+
const baseFont = context.defaults?.paragraphFont ?? "Calibri";
|
|
12650
|
+
const fallback = context.defaults?.paragraphFontFallback;
|
|
12651
|
+
const wordFamily = context.defaults?.paragraphFontFamily;
|
|
12652
|
+
const resolvedFamily = toCssFontFamily(baseFont, { fallback, wordFamily }) ?? baseFont;
|
|
12653
|
+
return {
|
|
12654
|
+
font: {
|
|
12655
|
+
family: resolvedFamily,
|
|
12656
|
+
size: context.defaults?.fontSize ?? 11,
|
|
12657
|
+
weight: 400,
|
|
12658
|
+
italic: false
|
|
12659
|
+
},
|
|
12660
|
+
color: "#000000"
|
|
12661
|
+
};
|
|
12662
|
+
}
|
|
12663
|
+
function resolveStyleChain(styleId, styles) {
|
|
12664
|
+
if (!styleId || !styles) return [];
|
|
12665
|
+
const result = [];
|
|
12666
|
+
const visited = /* @__PURE__ */ new Set();
|
|
12667
|
+
let current = styles[styleId];
|
|
12668
|
+
while (current && !visited.has(current.id)) {
|
|
12669
|
+
result.unshift(current);
|
|
12670
|
+
visited.add(current.id);
|
|
12671
|
+
current = current.basedOn ? styles[current.basedOn] : void 0;
|
|
12672
|
+
}
|
|
12673
|
+
return result;
|
|
12674
|
+
}
|
|
12675
|
+
function mergeParagraph(base2, overrides) {
|
|
12676
|
+
if (!overrides) return base2;
|
|
12677
|
+
return {
|
|
12678
|
+
...base2,
|
|
12679
|
+
alignment: overrides.alignment ?? base2.alignment,
|
|
12680
|
+
spacing: overrides.spacing ? { ...base2.spacing, ...overrides.spacing } : base2.spacing,
|
|
12681
|
+
indent: overrides.indent ? { ...base2.indent, ...overrides.indent } : base2.indent,
|
|
12682
|
+
borders: overrides.borders ? { ...base2.borders, ...overrides.borders } : base2.borders,
|
|
12683
|
+
shading: overrides.shading ?? base2.shading,
|
|
12684
|
+
tabs: overrides.tabs ?? base2.tabs
|
|
12685
|
+
};
|
|
12686
|
+
}
|
|
12687
|
+
function mergeCharacter(base2, overrides) {
|
|
12688
|
+
if (!overrides) return base2;
|
|
12689
|
+
return {
|
|
12690
|
+
...base2,
|
|
12691
|
+
font: overrides.font ? { ...base2.font, ...overrides.font } : base2.font,
|
|
12692
|
+
color: overrides.color ?? base2.color,
|
|
12693
|
+
underline: overrides.underline ?? base2.underline,
|
|
12694
|
+
strike: overrides.strike ?? base2.strike,
|
|
12695
|
+
highlight: overrides.highlight ?? base2.highlight,
|
|
12696
|
+
letterSpacing: overrides.letterSpacing ?? base2.letterSpacing
|
|
12442
12697
|
};
|
|
12443
|
-
|
|
12698
|
+
}
|
|
12699
|
+
function normalizeFieldAnnotationMetadata(attrs) {
|
|
12700
|
+
const fieldId = toOptionalString(attrs.fieldId) ?? "";
|
|
12701
|
+
const formatting = extractFormatting(attrs);
|
|
12702
|
+
const size2 = normalizeSize(attrs.size);
|
|
12703
|
+
const extras = isPlainObject$7(attrs.extras) ? attrs.extras : null;
|
|
12704
|
+
const marks = isPlainObject$7(attrs.marks) ? attrs.marks : void 0;
|
|
12705
|
+
return {
|
|
12706
|
+
type: "fieldAnnotation",
|
|
12707
|
+
fieldId,
|
|
12708
|
+
variant: normalizeFieldAnnotationVariant(attrs.type),
|
|
12709
|
+
fieldType: toOptionalString(attrs.fieldType),
|
|
12710
|
+
displayLabel: toOptionalString(attrs.displayLabel),
|
|
12711
|
+
defaultDisplayLabel: toOptionalString(attrs.defaultDisplayLabel),
|
|
12712
|
+
alias: toOptionalString(attrs.alias),
|
|
12713
|
+
fieldColor: normalizeColorValue(attrs.fieldColor),
|
|
12714
|
+
borderColor: normalizeColorValue(attrs.borderColor),
|
|
12715
|
+
highlighted: toBoolean$3(attrs.highlighted, true),
|
|
12716
|
+
fontFamily: toNullableString(attrs.fontFamily),
|
|
12717
|
+
fontSize: normalizeFontSize(attrs.fontSize),
|
|
12718
|
+
textColor: normalizeColorValue(attrs.textColor) ?? null,
|
|
12719
|
+
textHighlight: normalizeColorValue(attrs.textHighlight) ?? null,
|
|
12720
|
+
linkUrl: toNullableString(attrs.linkUrl),
|
|
12721
|
+
imageSrc: toNullableString(attrs.imageSrc),
|
|
12722
|
+
rawHtml: attrs.rawHtml ?? void 0,
|
|
12723
|
+
size: size2 ?? null,
|
|
12724
|
+
extras,
|
|
12725
|
+
multipleImage: toBoolean$3(attrs.multipleImage, false),
|
|
12726
|
+
hash: toOptionalString(attrs.hash) ?? null,
|
|
12727
|
+
generatorIndex: toNumber$1(attrs.generatorIndex),
|
|
12728
|
+
sdtId: toOptionalString(attrs.sdtId) ?? null,
|
|
12729
|
+
hidden: toBoolean$3(attrs.hidden, false),
|
|
12730
|
+
visibility: normalizeVisibility(attrs.visibility),
|
|
12731
|
+
isLocked: toBoolean$3(attrs.isLocked, false),
|
|
12732
|
+
formatting,
|
|
12733
|
+
marks
|
|
12734
|
+
};
|
|
12735
|
+
}
|
|
12736
|
+
function normalizeStructuredContentMetadata(nodeType, attrs) {
|
|
12737
|
+
return {
|
|
12738
|
+
type: "structuredContent",
|
|
12739
|
+
scope: nodeType === "structuredContentBlock" ? "block" : "inline",
|
|
12740
|
+
id: toNullableString(attrs.id),
|
|
12741
|
+
tag: toOptionalString(attrs.tag),
|
|
12742
|
+
alias: toOptionalString(attrs.alias),
|
|
12743
|
+
sdtPr: attrs.sdtPr
|
|
12744
|
+
};
|
|
12745
|
+
}
|
|
12746
|
+
function normalizeDocumentSectionMetadata(attrs) {
|
|
12747
|
+
return {
|
|
12748
|
+
type: "documentSection",
|
|
12749
|
+
id: toNullableString(attrs.id),
|
|
12750
|
+
title: toOptionalString(attrs.title) ?? null,
|
|
12751
|
+
description: toOptionalString(attrs.description) ?? null,
|
|
12752
|
+
sectionType: toOptionalString(attrs.sectionType) ?? null,
|
|
12753
|
+
isLocked: toBoolean$3(attrs.isLocked, false),
|
|
12754
|
+
sdBlockId: toNullableString(attrs.sdBlockId)
|
|
12755
|
+
};
|
|
12756
|
+
}
|
|
12757
|
+
function normalizeDocPartMetadata(attrs) {
|
|
12758
|
+
return {
|
|
12759
|
+
type: "docPartObject",
|
|
12760
|
+
gallery: toOptionalString(attrs.docPartGallery ?? attrs.gallery) ?? null,
|
|
12761
|
+
// Source uniqueId from attrs.id (PM adapter uses getDocPartObjectId which extracts attrs.id)
|
|
12762
|
+
// Fall back to attrs.uniqueId for compatibility
|
|
12763
|
+
uniqueId: toOptionalString(attrs.id ?? attrs.uniqueId) ?? null,
|
|
12764
|
+
alias: toOptionalString(attrs.alias) ?? null,
|
|
12765
|
+
instruction: toOptionalString(attrs.instruction) ?? null
|
|
12766
|
+
};
|
|
12767
|
+
}
|
|
12768
|
+
function isPlainObject$7(value) {
|
|
12769
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
12770
|
+
}
|
|
12771
|
+
function toOptionalString(value) {
|
|
12772
|
+
if (value == null) return void 0;
|
|
12773
|
+
if (typeof value === "string") {
|
|
12774
|
+
const trimmed = value.trim();
|
|
12775
|
+
return trimmed.length ? trimmed : void 0;
|
|
12776
|
+
}
|
|
12777
|
+
return String(value);
|
|
12778
|
+
}
|
|
12779
|
+
function toNullableString(value) {
|
|
12780
|
+
const str = toOptionalString(value);
|
|
12781
|
+
return str ?? null;
|
|
12782
|
+
}
|
|
12783
|
+
function toBoolean$3(value, fallback) {
|
|
12784
|
+
if (typeof value === "boolean") return value;
|
|
12785
|
+
if (typeof value === "string") {
|
|
12786
|
+
const lower = value.toLowerCase();
|
|
12787
|
+
if (lower === "true") return true;
|
|
12788
|
+
if (lower === "false") return false;
|
|
12789
|
+
}
|
|
12790
|
+
if (value == null) return fallback;
|
|
12791
|
+
return Boolean(value);
|
|
12792
|
+
}
|
|
12793
|
+
function normalizeVisibility(value) {
|
|
12794
|
+
if (typeof value !== "string") return void 0;
|
|
12795
|
+
const normalized = value.toLowerCase();
|
|
12796
|
+
if (normalized === "visible" || normalized === "hidden") {
|
|
12797
|
+
return normalized;
|
|
12798
|
+
}
|
|
12799
|
+
return void 0;
|
|
12800
|
+
}
|
|
12801
|
+
function normalizeColorValue(value) {
|
|
12802
|
+
if (typeof value !== "string") return void 0;
|
|
12803
|
+
const trimmed = value.trim();
|
|
12804
|
+
if (!trimmed || trimmed.toLowerCase() === "none") return void 0;
|
|
12805
|
+
return trimmed;
|
|
12806
|
+
}
|
|
12807
|
+
function normalizeFontSize(value) {
|
|
12808
|
+
if (value == null) return null;
|
|
12809
|
+
if (typeof value === "number") {
|
|
12810
|
+
return Number.isFinite(value) ? value : null;
|
|
12811
|
+
}
|
|
12812
|
+
if (typeof value === "string") {
|
|
12813
|
+
const trimmed = value.trim();
|
|
12814
|
+
return trimmed.length ? trimmed : null;
|
|
12815
|
+
}
|
|
12816
|
+
return null;
|
|
12817
|
+
}
|
|
12818
|
+
function toNumber$1(value) {
|
|
12819
|
+
if (typeof value === "number") {
|
|
12820
|
+
return Number.isFinite(value) ? value : null;
|
|
12821
|
+
}
|
|
12822
|
+
if (typeof value === "string") {
|
|
12823
|
+
const parsed = parseFloat(value);
|
|
12824
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
12825
|
+
}
|
|
12826
|
+
return null;
|
|
12827
|
+
}
|
|
12828
|
+
function normalizeSize(value) {
|
|
12829
|
+
if (!isPlainObject$7(value)) return null;
|
|
12830
|
+
const obj = value;
|
|
12831
|
+
const width = toNumber$1(obj.width);
|
|
12832
|
+
const height = toNumber$1(obj.height);
|
|
12833
|
+
if (width == null && height == null) return null;
|
|
12834
|
+
const result = {};
|
|
12835
|
+
if (width != null) result.width = width;
|
|
12836
|
+
if (height != null) result.height = height;
|
|
12837
|
+
return result;
|
|
12838
|
+
}
|
|
12839
|
+
function normalizeFieldAnnotationVariant(value) {
|
|
12840
|
+
if (typeof value !== "string") return void 0;
|
|
12841
|
+
const normalized = value.toLowerCase();
|
|
12842
|
+
if (normalized === "text" || normalized === "image" || normalized === "signature" || normalized === "checkbox" || normalized === "html" || normalized === "link") {
|
|
12843
|
+
return normalized;
|
|
12844
|
+
}
|
|
12845
|
+
return void 0;
|
|
12846
|
+
}
|
|
12847
|
+
function extractFormatting(attrs) {
|
|
12848
|
+
const bold = toBoolean$3(attrs.bold, false);
|
|
12849
|
+
const italic = toBoolean$3(attrs.italic, false);
|
|
12850
|
+
const underline = toBoolean$3(attrs.underline, false);
|
|
12851
|
+
const formatting = {};
|
|
12852
|
+
if (bold) formatting.bold = true;
|
|
12853
|
+
if (italic) formatting.italic = true;
|
|
12854
|
+
if (underline) formatting.underline = true;
|
|
12855
|
+
return Object.keys(formatting).length ? formatting : void 0;
|
|
12856
|
+
}
|
|
12857
|
+
function buildSdtCacheKey(nodeType, attrs, explicitKey) {
|
|
12858
|
+
const provided = toOptionalString(explicitKey);
|
|
12859
|
+
if (provided) {
|
|
12860
|
+
return `${nodeType}:${provided}`;
|
|
12861
|
+
}
|
|
12862
|
+
const hash2 = toOptionalString(attrs.hash);
|
|
12863
|
+
if (hash2) {
|
|
12864
|
+
return `${nodeType}:${hash2}`;
|
|
12865
|
+
}
|
|
12866
|
+
const id = toOptionalString(attrs.id);
|
|
12867
|
+
if (id) {
|
|
12868
|
+
return `${nodeType}:${id}`;
|
|
12869
|
+
}
|
|
12870
|
+
return void 0;
|
|
12871
|
+
}
|
|
12872
|
+
const ooxmlResolver$1 = createOoxmlResolver({ pPr: translator$14, rPr: translator$1O });
|
|
12873
|
+
const getToCssFontFamily = () => {
|
|
12874
|
+
return SuperConverter.toCssFontFamily;
|
|
12875
|
+
};
|
|
12876
|
+
const SUBSCRIPT_SUPERSCRIPT_SCALE$1 = 0.65;
|
|
12877
|
+
const resolveRunProperties = (params2, inlineRpr, resolvedPpr, isListNumber = false, numberingDefinedInline = false) => ooxmlResolver$1.resolveRunProperties(params2, inlineRpr, resolvedPpr, isListNumber, numberingDefinedInline);
|
|
12878
|
+
function resolveParagraphProperties(params2, inlineProps, insideTable = false, overrideInlineStyleId = false, tableStyleId = null) {
|
|
12879
|
+
return ooxmlResolver$1.resolveParagraphProperties(
|
|
12880
|
+
params2,
|
|
12881
|
+
inlineProps,
|
|
12882
|
+
insideTable,
|
|
12883
|
+
overrideInlineStyleId,
|
|
12884
|
+
tableStyleId
|
|
12885
|
+
);
|
|
12886
|
+
}
|
|
12887
|
+
const combineProperties = (propertiesArray, fullOverrideProps = [], specialHandling = {}) => {
|
|
12888
|
+
return combineProperties$1(propertiesArray, { fullOverrideProps, specialHandling });
|
|
12444
12889
|
};
|
|
12445
12890
|
const combineRunProperties = (propertiesArray) => {
|
|
12446
12891
|
return combineProperties(propertiesArray, ["fontFamily", "color"]);
|
|
@@ -12499,9 +12944,9 @@
|
|
|
12499
12944
|
textStyleAttrs[key2] = `${spacing}pt`;
|
|
12500
12945
|
break;
|
|
12501
12946
|
case "fontFamily":
|
|
12502
|
-
const fontFamily2 =
|
|
12947
|
+
const fontFamily2 = resolveDocxFontFamily(value, docx, getToCssFontFamily());
|
|
12503
12948
|
textStyleAttrs[key2] = fontFamily2;
|
|
12504
|
-
const eastAsiaFamily = value["eastAsia"];
|
|
12949
|
+
const eastAsiaFamily = typeof value === "object" && value !== null ? value["eastAsia"] : void 0;
|
|
12505
12950
|
if (eastAsiaFamily) {
|
|
12506
12951
|
const eastAsiaCss = getFontFamilyValue$1({ "w:ascii": eastAsiaFamily }, docx);
|
|
12507
12952
|
if (!fontFamily2 || eastAsiaCss !== textStyleAttrs.fontFamily) {
|
|
@@ -12756,11 +13201,11 @@
|
|
|
12756
13201
|
}
|
|
12757
13202
|
case "fontFamily": {
|
|
12758
13203
|
if (!value) break;
|
|
12759
|
-
const fontFamily2 =
|
|
13204
|
+
const fontFamily2 = resolveDocxFontFamily(value, docx, getToCssFontFamily());
|
|
12760
13205
|
if (fontFamily2) {
|
|
12761
13206
|
css["font-family"] = fontFamily2;
|
|
12762
13207
|
}
|
|
12763
|
-
const eastAsiaFamily = value["eastAsia"];
|
|
13208
|
+
const eastAsiaFamily = typeof value === "object" && value !== null ? value["eastAsia"] : void 0;
|
|
12764
13209
|
if (eastAsiaFamily) {
|
|
12765
13210
|
const eastAsiaCss = getFontFamilyValue$1({ "w:ascii": eastAsiaFamily }, docx);
|
|
12766
13211
|
if (eastAsiaCss && (!fontFamily2 || eastAsiaCss !== fontFamily2)) {
|
|
@@ -32519,7 +32964,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
32519
32964
|
text2 = text2.replace(/^[ \t\n\r]+/, "").replace(/[ \t\n\r]+$/, "");
|
|
32520
32965
|
}
|
|
32521
32966
|
text2 = text2.replace(/\[\[sdspace\]\]/g, "");
|
|
32522
|
-
|
|
32967
|
+
const isWhitespaceOnly = /^[ \t\n\r]*$/.test(text2);
|
|
32968
|
+
if (xmlSpace !== "preserve" && isWhitespaceOnly) {
|
|
32523
32969
|
return null;
|
|
32524
32970
|
}
|
|
32525
32971
|
} else if (!elements.length && encodedAttrs.xmlSpace === "preserve") {
|
|
@@ -35473,7 +35919,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
35473
35919
|
const result = additions.length ? [...existingRelationships, ...additions] : existingRelationships;
|
|
35474
35920
|
return result;
|
|
35475
35921
|
};
|
|
35476
|
-
const FONT_FAMILY_FALLBACKS
|
|
35922
|
+
const FONT_FAMILY_FALLBACKS = Object.freeze({
|
|
35477
35923
|
swiss: "Arial, sans-serif",
|
|
35478
35924
|
roman: "Times New Roman, serif",
|
|
35479
35925
|
modern: "Courier New, monospace",
|
|
@@ -35482,7 +35928,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
35482
35928
|
system: "system-ui",
|
|
35483
35929
|
auto: "sans-serif"
|
|
35484
35930
|
});
|
|
35485
|
-
const DEFAULT_GENERIC_FALLBACK
|
|
35931
|
+
const DEFAULT_GENERIC_FALLBACK = "sans-serif";
|
|
35486
35932
|
const DEFAULT_FONT_SIZE_PT = 10;
|
|
35487
35933
|
const collectRunDefaultProperties = (runProps, { allowOverrideTypeface = true, allowOverrideSize = true, themeResolver, state }) => {
|
|
35488
35934
|
if (!runProps?.elements?.length || !state) return;
|
|
@@ -35577,13 +36023,13 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
35577
36023
|
const fontEntry = SuperConverter.getFontTableEntry(docx, fontName);
|
|
35578
36024
|
const family = fontEntry?.elements?.find((child) => child.name === "w:family")?.attributes?.["w:val"];
|
|
35579
36025
|
if (!family) return null;
|
|
35580
|
-
const mapped = FONT_FAMILY_FALLBACKS
|
|
35581
|
-
return mapped || DEFAULT_GENERIC_FALLBACK
|
|
36026
|
+
const mapped = FONT_FAMILY_FALLBACKS[family.toLowerCase()];
|
|
36027
|
+
return mapped || DEFAULT_GENERIC_FALLBACK;
|
|
35582
36028
|
}
|
|
35583
36029
|
static toCssFontFamily(fontName, docx) {
|
|
35584
36030
|
if (!fontName) return fontName;
|
|
35585
36031
|
if (fontName.includes(",")) return fontName;
|
|
35586
|
-
const fallback = SuperConverter.getFallbackFromFontTable(docx, fontName) || DEFAULT_GENERIC_FALLBACK
|
|
36032
|
+
const fallback = SuperConverter.getFallbackFromFontTable(docx, fontName) || DEFAULT_GENERIC_FALLBACK;
|
|
35587
36033
|
const normalizedFallbackParts = fallback.split(",").map((part) => part.trim().toLowerCase()).filter(Boolean);
|
|
35588
36034
|
if (normalizedFallbackParts.includes(fontName.trim().toLowerCase())) {
|
|
35589
36035
|
return fallback;
|
|
@@ -35919,7 +36365,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
35919
36365
|
static getStoredSuperdocVersion(docx) {
|
|
35920
36366
|
return SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
|
|
35921
36367
|
}
|
|
35922
|
-
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.3.0-next.
|
|
36368
|
+
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.3.0-next.3") {
|
|
35923
36369
|
return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
|
|
35924
36370
|
}
|
|
35925
36371
|
/**
|
|
@@ -45269,15 +45715,19 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
45269
45715
|
dispatchTransaction = editor.dispatch.bind(editor);
|
|
45270
45716
|
}
|
|
45271
45717
|
if (!dispatchTransaction) return false;
|
|
45272
|
-
const handled = splitBlockPatch(
|
|
45273
|
-
|
|
45274
|
-
|
|
45718
|
+
const handled = splitBlockPatch(
|
|
45719
|
+
state,
|
|
45720
|
+
(transaction) => {
|
|
45721
|
+
dispatchTransaction(transaction);
|
|
45722
|
+
},
|
|
45723
|
+
editor
|
|
45724
|
+
);
|
|
45275
45725
|
if (handled) {
|
|
45276
45726
|
tr.setMeta("preventDispatch", true);
|
|
45277
45727
|
}
|
|
45278
45728
|
return handled;
|
|
45279
45729
|
};
|
|
45280
|
-
function splitBlockPatch(state, dispatch) {
|
|
45730
|
+
function splitBlockPatch(state, dispatch, editor) {
|
|
45281
45731
|
let { $from } = state.selection;
|
|
45282
45732
|
if (state.selection instanceof NodeSelection && state.selection.node.isBlock) {
|
|
45283
45733
|
if (!$from.parentOffset || !canSplit(state.doc, $from.pos)) return false;
|
|
@@ -45286,14 +45736,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
45286
45736
|
}
|
|
45287
45737
|
if (!$from.depth) return false;
|
|
45288
45738
|
let types2 = [];
|
|
45289
|
-
let splitDepth, deflt, atEnd = false, atStart = false;
|
|
45739
|
+
let splitDepth, deflt, paragraphAttrs = null, atEnd = false, atStart = false;
|
|
45290
45740
|
for (let d2 = $from.depth; ; d2--) {
|
|
45291
45741
|
let node2 = $from.node(d2);
|
|
45292
45742
|
if (node2.isBlock) {
|
|
45293
45743
|
atEnd = $from.end(d2) == $from.pos + ($from.depth - d2);
|
|
45294
45744
|
atStart = $from.start(d2) == $from.pos - ($from.depth - d2);
|
|
45295
45745
|
deflt = defaultBlockAt$1($from.node(d2 - 1).contentMatchAt($from.indexAfter(d2 - 1)));
|
|
45296
|
-
|
|
45746
|
+
paragraphAttrs = { ...node2.attrs };
|
|
45747
|
+
types2.unshift({ type: deflt || node2.type, attrs: paragraphAttrs });
|
|
45297
45748
|
splitDepth = d2;
|
|
45298
45749
|
break;
|
|
45299
45750
|
} else {
|
|
@@ -45306,7 +45757,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
45306
45757
|
let splitPos = tr.mapping.map($from.pos);
|
|
45307
45758
|
let can = canSplit(tr.doc, splitPos, types2.length, types2);
|
|
45308
45759
|
if (!can) {
|
|
45309
|
-
types2[0] = deflt ? { type: deflt } : null;
|
|
45760
|
+
types2[0] = deflt ? { type: deflt, attrs: paragraphAttrs } : null;
|
|
45310
45761
|
can = canSplit(tr.doc, splitPos, types2.length, types2);
|
|
45311
45762
|
}
|
|
45312
45763
|
if (!can) return false;
|
|
@@ -45316,9 +45767,37 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
45316
45767
|
if (deflt && $from.node(splitDepth - 1).canReplaceWith($first.index(), $first.index() + 1, deflt))
|
|
45317
45768
|
tr.setNodeMarkup(tr.mapping.map($from.before(splitDepth)), deflt);
|
|
45318
45769
|
}
|
|
45770
|
+
applyStyleMarks(state, tr, editor, paragraphAttrs);
|
|
45319
45771
|
if (dispatch) dispatch(tr.scrollIntoView());
|
|
45320
45772
|
return true;
|
|
45321
45773
|
}
|
|
45774
|
+
function applyStyleMarks(state, tr, editor, paragraphAttrs) {
|
|
45775
|
+
const styleId = paragraphAttrs?.paragraphProperties?.styleId;
|
|
45776
|
+
if (!editor?.converter && !styleId) {
|
|
45777
|
+
return;
|
|
45778
|
+
}
|
|
45779
|
+
try {
|
|
45780
|
+
const params2 = { docx: editor?.converter?.convertedXml ?? {}, numbering: editor?.converter?.numbering ?? {} };
|
|
45781
|
+
const resolvedPpr = styleId ? { styleId } : {};
|
|
45782
|
+
const runProperties = styleId ? resolveRunProperties(params2, {}, resolvedPpr, false, false) : {};
|
|
45783
|
+
const markDefsFromStyle = styleId ? (
|
|
45784
|
+
/** @type {Array<{type: string, attrs: Record<string, unknown>}>} */
|
|
45785
|
+
encodeMarksFromRPr(runProperties, editor?.converter?.convertedXml ?? {})
|
|
45786
|
+
) : [];
|
|
45787
|
+
const selectionMarks = state.selection?.$from?.marks ? state.selection.$from.marks() : [];
|
|
45788
|
+
const selectionMarkDefs = selectionMarks.map((mark2) => ({ type: mark2.type.name, attrs: mark2.attrs }));
|
|
45789
|
+
const markDefsToApply = selectionMarks.length ? selectionMarkDefs : markDefsFromStyle;
|
|
45790
|
+
const marksToApply = markDefsToApply.map((def2) => {
|
|
45791
|
+
const markType = state.schema.marks[def2.type];
|
|
45792
|
+
return markType ? markType.create(def2.attrs) : null;
|
|
45793
|
+
}).filter(Boolean);
|
|
45794
|
+
if (marksToApply.length > 0) {
|
|
45795
|
+
tr.ensureMarks(marksToApply);
|
|
45796
|
+
tr.setMeta("sdStyleMarks", markDefsToApply);
|
|
45797
|
+
}
|
|
45798
|
+
} catch {
|
|
45799
|
+
}
|
|
45800
|
+
}
|
|
45322
45801
|
const splitRunAtCursor = () => (props) => {
|
|
45323
45802
|
let { state, dispatch, tr } = props;
|
|
45324
45803
|
const sel = state.selection;
|
|
@@ -46202,7 +46681,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
46202
46681
|
}
|
|
46203
46682
|
return true;
|
|
46204
46683
|
};
|
|
46205
|
-
const isPlainObject$
|
|
46684
|
+
const isPlainObject$6 = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
46206
46685
|
const assignNestedValue = (target, path2, value) => {
|
|
46207
46686
|
if (!path2.includes(".")) {
|
|
46208
46687
|
target[path2] = value;
|
|
@@ -46216,7 +46695,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
46216
46695
|
if (isLast) {
|
|
46217
46696
|
current[part] = value;
|
|
46218
46697
|
} else {
|
|
46219
|
-
if (!isPlainObject$
|
|
46698
|
+
if (!isPlainObject$6(current[part])) {
|
|
46220
46699
|
current[part] = {};
|
|
46221
46700
|
}
|
|
46222
46701
|
current = current[part];
|
|
@@ -52665,7 +53144,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
52665
53144
|
const toRawType = (value) => {
|
|
52666
53145
|
return toTypeString(value).slice(8, -1);
|
|
52667
53146
|
};
|
|
52668
|
-
const isPlainObject$
|
|
53147
|
+
const isPlainObject$5 = (val) => toTypeString(val) === "[object Object]";
|
|
52669
53148
|
const isIntegerKey = (key2) => isString(key2) && key2 !== "NaN" && key2[0] !== "-" && "" + parseInt(key2, 10) === key2;
|
|
52670
53149
|
const isReservedProp = /* @__PURE__ */ makeMap(
|
|
52671
53150
|
// the leading comma is intentional so empty string "" is also included
|
|
@@ -52715,7 +53194,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
52715
53194
|
const n = parseFloat(val);
|
|
52716
53195
|
return isNaN(n) ? val : n;
|
|
52717
53196
|
};
|
|
52718
|
-
const toNumber
|
|
53197
|
+
const toNumber = (val) => {
|
|
52719
53198
|
const n = isString(val) ? Number(val) : NaN;
|
|
52720
53199
|
return isNaN(n) ? val : n;
|
|
52721
53200
|
};
|
|
@@ -52814,7 +53293,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
52814
53293
|
};
|
|
52815
53294
|
} else if (isSymbol$1(val)) {
|
|
52816
53295
|
return stringifySymbol(val);
|
|
52817
|
-
} else if (isObject$2(val) && !isArray$1(val) && !isPlainObject$
|
|
53296
|
+
} else if (isObject$2(val) && !isArray$1(val) && !isPlainObject$5(val)) {
|
|
52818
53297
|
return String(val);
|
|
52819
53298
|
}
|
|
52820
53299
|
return val;
|
|
@@ -54431,7 +54910,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
54431
54910
|
value.forEach((v2) => {
|
|
54432
54911
|
traverse(v2, depth, seen);
|
|
54433
54912
|
});
|
|
54434
|
-
} else if (isPlainObject$
|
|
54913
|
+
} else if (isPlainObject$5(value)) {
|
|
54435
54914
|
for (const key2 in value) {
|
|
54436
54915
|
traverse(value[key2], depth, seen);
|
|
54437
54916
|
}
|
|
@@ -59660,7 +60139,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
59660
60139
|
}
|
|
59661
60140
|
}
|
|
59662
60141
|
function NumberOf(val) {
|
|
59663
|
-
const res = toNumber
|
|
60142
|
+
const res = toNumber(val);
|
|
59664
60143
|
return res;
|
|
59665
60144
|
}
|
|
59666
60145
|
function addTransitionClass(el, cls) {
|
|
@@ -61541,7 +62020,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
61541
62020
|
return false;
|
|
61542
62021
|
}
|
|
61543
62022
|
};
|
|
61544
|
-
const summaryVersion = "1.3.0-next.
|
|
62023
|
+
const summaryVersion = "1.3.0-next.3";
|
|
61545
62024
|
const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
|
|
61546
62025
|
const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
|
|
61547
62026
|
function mapAttributes(attrs) {
|
|
@@ -64175,7 +64654,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
64175
64654
|
* Process collaboration migrations
|
|
64176
64655
|
*/
|
|
64177
64656
|
processCollaborationMigrations() {
|
|
64178
|
-
console.debug("[checkVersionMigrations] Current editor version", "1.3.0-next.
|
|
64657
|
+
console.debug("[checkVersionMigrations] Current editor version", "1.3.0-next.3");
|
|
64179
64658
|
if (!this.options.ydoc) return;
|
|
64180
64659
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
64181
64660
|
let docVersion = metaMap.get("version");
|
|
@@ -66595,18 +67074,18 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
66595
67074
|
case "decimal":
|
|
66596
67075
|
return num.toString();
|
|
66597
67076
|
case "lowerLetter":
|
|
66598
|
-
return toLetter
|
|
67077
|
+
return toLetter(num, false);
|
|
66599
67078
|
case "upperLetter":
|
|
66600
|
-
return toLetter
|
|
67079
|
+
return toLetter(num, true);
|
|
66601
67080
|
case "lowerRoman":
|
|
66602
|
-
return toRoman$
|
|
67081
|
+
return toRoman$1(num).toLowerCase();
|
|
66603
67082
|
case "upperRoman":
|
|
66604
|
-
return toRoman$
|
|
67083
|
+
return toRoman$1(num);
|
|
66605
67084
|
default:
|
|
66606
67085
|
return num.toString();
|
|
66607
67086
|
}
|
|
66608
67087
|
}
|
|
66609
|
-
function toLetter
|
|
67088
|
+
function toLetter(num, uppercase) {
|
|
66610
67089
|
let result = "";
|
|
66611
67090
|
let n = num;
|
|
66612
67091
|
while (n > 0) {
|
|
@@ -66617,7 +67096,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
66617
67096
|
}
|
|
66618
67097
|
return result || (uppercase ? "A" : "a");
|
|
66619
67098
|
}
|
|
66620
|
-
function toRoman$
|
|
67099
|
+
function toRoman$1(num) {
|
|
66621
67100
|
const lookup = [
|
|
66622
67101
|
[1e3, "M"],
|
|
66623
67102
|
[900, "CM"],
|
|
@@ -69751,39 +70230,6 @@ ${l}
|
|
|
69751
70230
|
right: borderValueToSpec(isLastCol ? tableBorders?.right : null)
|
|
69752
70231
|
};
|
|
69753
70232
|
};
|
|
69754
|
-
const FONT_FAMILY_FALLBACKS = Object.freeze({
|
|
69755
|
-
swiss: "Arial, sans-serif",
|
|
69756
|
-
roman: "Times New Roman, serif",
|
|
69757
|
-
modern: "Courier New, monospace",
|
|
69758
|
-
script: "cursive",
|
|
69759
|
-
decorative: "fantasy",
|
|
69760
|
-
system: "system-ui",
|
|
69761
|
-
auto: "sans-serif"
|
|
69762
|
-
});
|
|
69763
|
-
const DEFAULT_GENERIC_FALLBACK = "sans-serif";
|
|
69764
|
-
const normalizeParts = (value) => (value || "").split(",").map((part) => part.trim()).filter(Boolean);
|
|
69765
|
-
function mapWordFamilyFallback(wordFamily) {
|
|
69766
|
-
if (!wordFamily) return DEFAULT_GENERIC_FALLBACK;
|
|
69767
|
-
const mapped = FONT_FAMILY_FALLBACKS[wordFamily.toLowerCase()];
|
|
69768
|
-
return mapped || DEFAULT_GENERIC_FALLBACK;
|
|
69769
|
-
}
|
|
69770
|
-
function toCssFontFamily(fontName, options = {}) {
|
|
69771
|
-
if (!fontName || typeof fontName !== "string") return fontName;
|
|
69772
|
-
const trimmed = fontName.trim();
|
|
69773
|
-
if (!trimmed || trimmed.includes(",")) return trimmed;
|
|
69774
|
-
const { fallback, wordFamily } = options;
|
|
69775
|
-
const fallbackValue = fallback ?? (wordFamily ? mapWordFamilyFallback(wordFamily) : void 0) ?? DEFAULT_GENERIC_FALLBACK;
|
|
69776
|
-
const fallbackParts = normalizeParts(fallbackValue);
|
|
69777
|
-
if (fallbackParts.length === 0) {
|
|
69778
|
-
return trimmed;
|
|
69779
|
-
}
|
|
69780
|
-
const normalizedName = trimmed.toLowerCase();
|
|
69781
|
-
const includesName = fallbackParts.some((part) => part.toLowerCase() === normalizedName);
|
|
69782
|
-
if (includesName) {
|
|
69783
|
-
return fallbackParts.join(", ");
|
|
69784
|
-
}
|
|
69785
|
-
return [trimmed, ...fallbackParts].join(", ");
|
|
69786
|
-
}
|
|
69787
70233
|
const LIST_MARKER_GAP$3 = 8;
|
|
69788
70234
|
function renderListMarker(params2) {
|
|
69789
70235
|
const { doc: doc2, lineEl, markerLayout, markerMeasure, indentLeftPx } = params2;
|
|
@@ -72021,7 +72467,14 @@ ${l}
|
|
|
72021
72467
|
fragmentEl.dataset.continuesOnNext = "true";
|
|
72022
72468
|
}
|
|
72023
72469
|
const lines = fragment.lines ?? measure.lines.slice(fragment.fromLine, fragment.toLine);
|
|
72024
|
-
applyParagraphBlockStyles(fragmentEl, block.attrs);
|
|
72470
|
+
applyParagraphBlockStyles(fragmentEl, block.attrs, { includeBorders: false, includeShading: false });
|
|
72471
|
+
const { shadingLayer, borderLayer } = createParagraphDecorationLayers(this.doc, fragment.width, block.attrs);
|
|
72472
|
+
if (shadingLayer) {
|
|
72473
|
+
fragmentEl.appendChild(shadingLayer);
|
|
72474
|
+
}
|
|
72475
|
+
if (borderLayer) {
|
|
72476
|
+
fragmentEl.appendChild(borderLayer);
|
|
72477
|
+
}
|
|
72025
72478
|
if (block.attrs?.styleId) {
|
|
72026
72479
|
fragmentEl.dataset.styleId = block.attrs.styleId;
|
|
72027
72480
|
fragmentEl.setAttribute("styleid", block.attrs.styleId);
|
|
@@ -72405,10 +72858,18 @@ ${l}
|
|
|
72405
72858
|
contentEl.classList.add("superdoc-list-content");
|
|
72406
72859
|
this.applySdtDataset(contentEl, paragraphMetadata);
|
|
72407
72860
|
contentEl.style.display = "inline-block";
|
|
72861
|
+
contentEl.style.position = "relative";
|
|
72408
72862
|
contentEl.style.width = `${fragment.width}px`;
|
|
72409
72863
|
const lines = itemMeasure.paragraph.lines.slice(fragment.fromLine, fragment.toLine);
|
|
72410
72864
|
const contentAttrs = wordLayout ? item.paragraph.attrs : stripListIndent(item.paragraph.attrs);
|
|
72411
|
-
applyParagraphBlockStyles(contentEl, contentAttrs);
|
|
72865
|
+
applyParagraphBlockStyles(contentEl, contentAttrs, { includeBorders: false, includeShading: false });
|
|
72866
|
+
const { shadingLayer, borderLayer } = createParagraphDecorationLayers(this.doc, fragment.width, contentAttrs);
|
|
72867
|
+
if (shadingLayer) {
|
|
72868
|
+
contentEl.appendChild(shadingLayer);
|
|
72869
|
+
}
|
|
72870
|
+
if (borderLayer) {
|
|
72871
|
+
contentEl.appendChild(borderLayer);
|
|
72872
|
+
}
|
|
72412
72873
|
contentEl.style.textAlign = "left";
|
|
72413
72874
|
const paraForList = {
|
|
72414
72875
|
...item.paragraph,
|
|
@@ -74632,7 +75093,7 @@ ${l}
|
|
|
74632
75093
|
}
|
|
74633
75094
|
});
|
|
74634
75095
|
};
|
|
74635
|
-
const applyParagraphBlockStyles = (element2, attrs) => {
|
|
75096
|
+
const applyParagraphBlockStyles = (element2, attrs, options = {}) => {
|
|
74636
75097
|
if (!attrs) return;
|
|
74637
75098
|
if (attrs.styleId) {
|
|
74638
75099
|
element2.setAttribute("styleid", attrs.styleId);
|
|
@@ -74659,8 +75120,55 @@ ${l}
|
|
|
74659
75120
|
}
|
|
74660
75121
|
}
|
|
74661
75122
|
}
|
|
74662
|
-
|
|
74663
|
-
|
|
75123
|
+
if (options.includeBorders ?? true) {
|
|
75124
|
+
applyParagraphBorderStyles(element2, attrs.borders);
|
|
75125
|
+
}
|
|
75126
|
+
if (options.includeShading ?? true) {
|
|
75127
|
+
applyParagraphShadingStyles(element2, attrs.shading);
|
|
75128
|
+
}
|
|
75129
|
+
};
|
|
75130
|
+
const getParagraphBorderBox = (fragmentWidth, indent2) => {
|
|
75131
|
+
const indentLeft = Number.isFinite(indent2?.left) ? indent2.left : 0;
|
|
75132
|
+
const indentRight = Number.isFinite(indent2?.right) ? indent2.right : 0;
|
|
75133
|
+
const firstLine = Number.isFinite(indent2?.firstLine) ? indent2.firstLine : 0;
|
|
75134
|
+
const hanging = Number.isFinite(indent2?.hanging) ? indent2.hanging : 0;
|
|
75135
|
+
const firstLineOffset = firstLine - hanging;
|
|
75136
|
+
const minLeftInset = Math.min(indentLeft, indentLeft + firstLineOffset);
|
|
75137
|
+
const leftInset = Math.max(0, minLeftInset);
|
|
75138
|
+
const rightInset = Math.max(0, indentRight);
|
|
75139
|
+
return {
|
|
75140
|
+
leftInset,
|
|
75141
|
+
width: Math.max(0, fragmentWidth - leftInset - rightInset)
|
|
75142
|
+
};
|
|
75143
|
+
};
|
|
75144
|
+
const createParagraphDecorationLayers = (doc2, fragmentWidth, attrs) => {
|
|
75145
|
+
if (!attrs?.borders && !attrs?.shading) return {};
|
|
75146
|
+
const borderBox = getParagraphBorderBox(fragmentWidth, attrs.indent);
|
|
75147
|
+
const baseStyles = {
|
|
75148
|
+
position: "absolute",
|
|
75149
|
+
top: "0px",
|
|
75150
|
+
bottom: "0px",
|
|
75151
|
+
left: `${borderBox.leftInset}px`,
|
|
75152
|
+
width: `${borderBox.width}px`,
|
|
75153
|
+
pointerEvents: "none",
|
|
75154
|
+
boxSizing: "border-box"
|
|
75155
|
+
};
|
|
75156
|
+
let shadingLayer;
|
|
75157
|
+
if (attrs.shading) {
|
|
75158
|
+
shadingLayer = doc2.createElement("div");
|
|
75159
|
+
shadingLayer.classList.add("superdoc-paragraph-shading");
|
|
75160
|
+
Object.assign(shadingLayer.style, baseStyles);
|
|
75161
|
+
applyParagraphShadingStyles(shadingLayer, attrs.shading);
|
|
75162
|
+
}
|
|
75163
|
+
let borderLayer;
|
|
75164
|
+
if (attrs.borders) {
|
|
75165
|
+
borderLayer = doc2.createElement("div");
|
|
75166
|
+
borderLayer.classList.add("superdoc-paragraph-border");
|
|
75167
|
+
Object.assign(borderLayer.style, baseStyles);
|
|
75168
|
+
borderLayer.style.zIndex = "1";
|
|
75169
|
+
applyParagraphBorderStyles(borderLayer, attrs.borders);
|
|
75170
|
+
}
|
|
75171
|
+
return { shadingLayer, borderLayer };
|
|
74664
75172
|
};
|
|
74665
75173
|
const BORDER_SIDES = ["top", "right", "bottom", "left"];
|
|
74666
75174
|
const applyParagraphBorderStyles = (element2, borders) => {
|
|
@@ -78311,33 +78819,13 @@ ${l}
|
|
|
78311
78819
|
toLineByCell.push(cutLine);
|
|
78312
78820
|
heightByCell.push(cumulativeHeight);
|
|
78313
78821
|
}
|
|
78314
|
-
const allCellsCompleteInFirstPass = toLineByCell.every((cutLine, idx) => {
|
|
78315
|
-
const totalLines = getCellTotalLines(row2.cells[idx]);
|
|
78316
|
-
return cutLine >= totalLines;
|
|
78317
|
-
});
|
|
78318
|
-
const lineAdvancements = toLineByCell.map((cutLine, idx) => cutLine - (startLines[idx] || 0));
|
|
78319
|
-
const positiveAdvancements = lineAdvancements.filter((adv) => adv > 0);
|
|
78320
|
-
const minLineAdvancement = positiveAdvancements.length > 0 ? Math.min(...positiveAdvancements) : 0;
|
|
78321
78822
|
let actualPartialHeight = 0;
|
|
78322
78823
|
let maxPaddingTotal = 0;
|
|
78323
78824
|
for (let cellIdx = 0; cellIdx < cellCount; cellIdx++) {
|
|
78324
|
-
const cell2 = row2.cells[cellIdx];
|
|
78325
|
-
const startLine = startLines[cellIdx] || 0;
|
|
78326
|
-
const lines = getCellLines(cell2);
|
|
78327
78825
|
const cellPadding = cellPaddings[cellIdx];
|
|
78328
78826
|
const paddingTotal = cellPadding.top + cellPadding.bottom;
|
|
78329
78827
|
maxPaddingTotal = Math.max(maxPaddingTotal, paddingTotal);
|
|
78330
|
-
|
|
78331
|
-
actualPartialHeight = Math.max(actualPartialHeight, heightByCell[cellIdx] + paddingTotal);
|
|
78332
|
-
} else {
|
|
78333
|
-
const targetLine = Math.min(startLine + minLineAdvancement, lines.length);
|
|
78334
|
-
let cumulativeHeight = 0;
|
|
78335
|
-
for (let i2 = startLine; i2 < targetLine; i2++) {
|
|
78336
|
-
cumulativeHeight += lines[i2].lineHeight || 0;
|
|
78337
|
-
}
|
|
78338
|
-
toLineByCell[cellIdx] = targetLine;
|
|
78339
|
-
actualPartialHeight = Math.max(actualPartialHeight, cumulativeHeight + paddingTotal);
|
|
78340
|
-
}
|
|
78828
|
+
actualPartialHeight = Math.max(actualPartialHeight, heightByCell[cellIdx] + paddingTotal);
|
|
78341
78829
|
}
|
|
78342
78830
|
const madeProgress = toLineByCell.some((cutLine, idx) => cutLine > (startLines[idx] || 0));
|
|
78343
78831
|
const isFirstPart = startLines.every((l) => l === 0);
|
|
@@ -78890,7 +79378,7 @@ ${l}
|
|
|
78890
79378
|
function toLowerLetter(num) {
|
|
78891
79379
|
return toUpperLetter(num).toLowerCase();
|
|
78892
79380
|
}
|
|
78893
|
-
function formatPageNumber
|
|
79381
|
+
function formatPageNumber(pageNumber, format) {
|
|
78894
79382
|
const num = Math.max(1, pageNumber);
|
|
78895
79383
|
switch (format) {
|
|
78896
79384
|
case "decimal":
|
|
@@ -78903,6 +79391,8 @@ ${l}
|
|
|
78903
79391
|
return toUpperLetter(num);
|
|
78904
79392
|
case "lowerLetter":
|
|
78905
79393
|
return toLowerLetter(num);
|
|
79394
|
+
case "numberInDash":
|
|
79395
|
+
return `-${num}-`;
|
|
78906
79396
|
default:
|
|
78907
79397
|
return String(num);
|
|
78908
79398
|
}
|
|
@@ -78931,7 +79421,7 @@ ${l}
|
|
|
78931
79421
|
const sectionMetadata = sectionMap.get(pageSectionIndex);
|
|
78932
79422
|
const format = sectionMetadata?.numbering?.format ?? "decimal";
|
|
78933
79423
|
const displayNumber = runningCounter;
|
|
78934
|
-
const displayText = formatPageNumber
|
|
79424
|
+
const displayText = formatPageNumber(displayNumber, format);
|
|
78935
79425
|
result.push({
|
|
78936
79426
|
physicalPage: page.number,
|
|
78937
79427
|
displayNumber,
|
|
@@ -79067,59 +79557,6 @@ ${l}
|
|
|
79067
79557
|
if (!layoutDebugEnabled$1) return;
|
|
79068
79558
|
console.log(...args);
|
|
79069
79559
|
};
|
|
79070
|
-
function formatPageNumber(num, format) {
|
|
79071
|
-
switch (format) {
|
|
79072
|
-
case "decimal":
|
|
79073
|
-
return String(num);
|
|
79074
|
-
case "lowerLetter":
|
|
79075
|
-
return toLetter(num, false);
|
|
79076
|
-
case "upperLetter":
|
|
79077
|
-
return toLetter(num, true);
|
|
79078
|
-
case "lowerRoman":
|
|
79079
|
-
return toRoman$1(num).toLowerCase();
|
|
79080
|
-
case "upperRoman":
|
|
79081
|
-
return toRoman$1(num);
|
|
79082
|
-
default:
|
|
79083
|
-
return String(num);
|
|
79084
|
-
}
|
|
79085
|
-
}
|
|
79086
|
-
function toLetter(num, uppercase) {
|
|
79087
|
-
let result = "";
|
|
79088
|
-
let n = Math.max(1, Math.floor(num));
|
|
79089
|
-
while (n > 0) {
|
|
79090
|
-
const remainder = (n - 1) % 26;
|
|
79091
|
-
const char = String.fromCharCode((uppercase ? 65 : 97) + remainder);
|
|
79092
|
-
result = char + result;
|
|
79093
|
-
n = Math.floor((n - 1) / 26);
|
|
79094
|
-
}
|
|
79095
|
-
return result;
|
|
79096
|
-
}
|
|
79097
|
-
function toRoman$1(num) {
|
|
79098
|
-
const lookup = [
|
|
79099
|
-
[1e3, "M"],
|
|
79100
|
-
[900, "CM"],
|
|
79101
|
-
[500, "D"],
|
|
79102
|
-
[400, "CD"],
|
|
79103
|
-
[100, "C"],
|
|
79104
|
-
[90, "XC"],
|
|
79105
|
-
[50, "L"],
|
|
79106
|
-
[40, "XL"],
|
|
79107
|
-
[10, "X"],
|
|
79108
|
-
[9, "IX"],
|
|
79109
|
-
[5, "V"],
|
|
79110
|
-
[4, "IV"],
|
|
79111
|
-
[1, "I"]
|
|
79112
|
-
];
|
|
79113
|
-
let result = "";
|
|
79114
|
-
let n = Math.max(1, Math.floor(num));
|
|
79115
|
-
for (const [value, numeral] of lookup) {
|
|
79116
|
-
while (n >= value) {
|
|
79117
|
-
result += numeral;
|
|
79118
|
-
n -= value;
|
|
79119
|
-
}
|
|
79120
|
-
}
|
|
79121
|
-
return result;
|
|
79122
|
-
}
|
|
79123
79560
|
function layoutDocument(blocks2, measures, options = {}) {
|
|
79124
79561
|
if (blocks2.length !== measures.length) {
|
|
79125
79562
|
throw new Error(
|
|
@@ -80575,7 +81012,7 @@ ${l}
|
|
|
80575
81012
|
return `${block.id}@${safeWidth}x${safeHeight}:${hash2}`;
|
|
80576
81013
|
}
|
|
80577
81014
|
}
|
|
80578
|
-
function resolveHeaderFooterTokens(blocks2, pageNumber, totalPages) {
|
|
81015
|
+
function resolveHeaderFooterTokens(blocks2, pageNumber, totalPages, pageNumberText) {
|
|
80579
81016
|
if (!blocks2 || blocks2.length === 0) {
|
|
80580
81017
|
return;
|
|
80581
81018
|
}
|
|
@@ -80587,7 +81024,7 @@ ${l}
|
|
|
80587
81024
|
console.warn("[resolveHeaderFooterTokens] Invalid totalPages:", totalPages, "- using 1 as fallback");
|
|
80588
81025
|
totalPages = 1;
|
|
80589
81026
|
}
|
|
80590
|
-
const pageNumberStr = String(pageNumber);
|
|
81027
|
+
const pageNumberStr = pageNumberText ?? String(pageNumber);
|
|
80591
81028
|
const totalPagesStr = String(totalPages);
|
|
80592
81029
|
for (const block of blocks2) {
|
|
80593
81030
|
if (block.kind !== "paragraph") continue;
|
|
@@ -81011,15 +81448,31 @@ ${l}
|
|
|
81011
81448
|
for (const pageNum of pagesToLayout) {
|
|
81012
81449
|
const clonedBlocks = cloneHeaderFooterBlocks(blocks2);
|
|
81013
81450
|
const { displayText, totalPages: totalPagesForPage } = pageResolver(pageNum);
|
|
81014
|
-
|
|
81015
|
-
resolveHeaderFooterTokens(clonedBlocks, resolvedPageNum, totalPagesForPage);
|
|
81451
|
+
resolveHeaderFooterTokens(clonedBlocks, pageNum, totalPagesForPage, displayText);
|
|
81016
81452
|
const measures = await cache2.measureBlocks(clonedBlocks, constraints, measureBlock2);
|
|
81017
81453
|
const pageLayout = layoutHeaderFooter(clonedBlocks, measures, constraints);
|
|
81454
|
+
const measuresById = /* @__PURE__ */ new Map();
|
|
81455
|
+
for (let i2 = 0; i2 < clonedBlocks.length; i2 += 1) {
|
|
81456
|
+
measuresById.set(clonedBlocks[i2].id, measures[i2]);
|
|
81457
|
+
}
|
|
81458
|
+
const fragmentsWithLines = pageLayout.pages[0]?.fragments.map((fragment) => {
|
|
81459
|
+
if (fragment.kind !== "para") {
|
|
81460
|
+
return fragment;
|
|
81461
|
+
}
|
|
81462
|
+
const measure = measuresById.get(fragment.blockId);
|
|
81463
|
+
if (!measure || measure.kind !== "paragraph") {
|
|
81464
|
+
return fragment;
|
|
81465
|
+
}
|
|
81466
|
+
return {
|
|
81467
|
+
...fragment,
|
|
81468
|
+
lines: measure.lines.slice(fragment.fromLine, fragment.toLine)
|
|
81469
|
+
};
|
|
81470
|
+
}) ?? [];
|
|
81018
81471
|
pages.push({
|
|
81019
81472
|
number: pageNum,
|
|
81020
81473
|
blocks: clonedBlocks,
|
|
81021
81474
|
measures,
|
|
81022
|
-
fragments:
|
|
81475
|
+
fragments: fragmentsWithLines
|
|
81023
81476
|
});
|
|
81024
81477
|
}
|
|
81025
81478
|
const firstPageLayout = pages[0] ? layoutHeaderFooter(pages[0].blocks, pages[0].measures, constraints) : { height: 0 };
|
|
@@ -85898,7 +86351,14 @@ ${l}
|
|
|
85898
86351
|
const pgNumType = elements.find((el) => el?.name === "w:pgNumType");
|
|
85899
86352
|
if (!pgNumType?.attributes) return void 0;
|
|
85900
86353
|
const fmtRaw = pgNumType.attributes["w:fmt"];
|
|
85901
|
-
const validFormats = [
|
|
86354
|
+
const validFormats = [
|
|
86355
|
+
"decimal",
|
|
86356
|
+
"lowerLetter",
|
|
86357
|
+
"upperLetter",
|
|
86358
|
+
"lowerRoman",
|
|
86359
|
+
"upperRoman",
|
|
86360
|
+
"numberInDash"
|
|
86361
|
+
];
|
|
85902
86362
|
const fmt = validFormats.includes(fmtRaw) ? fmtRaw : void 0;
|
|
85903
86363
|
const startRaw = pgNumType.attributes["w:start"];
|
|
85904
86364
|
const startNum = startRaw != null ? Number(startRaw) : void 0;
|
|
@@ -86321,7 +86781,7 @@ ${l}
|
|
|
86321
86781
|
return px / PX_PER_PT;
|
|
86322
86782
|
};
|
|
86323
86783
|
const isFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value);
|
|
86324
|
-
const isPlainObject$
|
|
86784
|
+
const isPlainObject$4 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
86325
86785
|
const normalizePrefix = (value) => {
|
|
86326
86786
|
if (!value) return "";
|
|
86327
86787
|
return String(value);
|
|
@@ -86383,7 +86843,7 @@ ${l}
|
|
|
86383
86843
|
}
|
|
86384
86844
|
return void 0;
|
|
86385
86845
|
}
|
|
86386
|
-
const toBoolean$
|
|
86846
|
+
const toBoolean$2 = (value) => {
|
|
86387
86847
|
if (typeof value === "boolean") return value;
|
|
86388
86848
|
if (typeof value === "string") {
|
|
86389
86849
|
const v2 = value.trim().toLowerCase();
|
|
@@ -86674,7 +87134,7 @@ ${l}
|
|
|
86674
87134
|
});
|
|
86675
87135
|
}
|
|
86676
87136
|
function isGradientFill(value) {
|
|
86677
|
-
if (!isPlainObject$
|
|
87137
|
+
if (!isPlainObject$4(value)) return false;
|
|
86678
87138
|
if (value.type !== "gradient") return false;
|
|
86679
87139
|
const gradientType = value.gradientType;
|
|
86680
87140
|
if (gradientType !== "linear" && gradientType !== "radial") return false;
|
|
@@ -86685,12 +87145,12 @@ ${l}
|
|
|
86685
87145
|
}
|
|
86686
87146
|
if (!Array.isArray(value.stops) || value.stops.length === 0) return false;
|
|
86687
87147
|
return value.stops.every((stop) => {
|
|
86688
|
-
if (!isPlainObject$
|
|
87148
|
+
if (!isPlainObject$4(stop)) return false;
|
|
86689
87149
|
return typeof stop.position === "number" && Number.isFinite(stop.position) && typeof stop.color === "string" && (stop.alpha === void 0 || typeof stop.alpha === "number" && Number.isFinite(stop.alpha));
|
|
86690
87150
|
});
|
|
86691
87151
|
}
|
|
86692
87152
|
function isSolidFillWithAlpha(value) {
|
|
86693
|
-
return isPlainObject$
|
|
87153
|
+
return isPlainObject$4(value) && value.type === "solidWithAlpha" && typeof value.color === "string" && typeof value.alpha === "number";
|
|
86694
87154
|
}
|
|
86695
87155
|
function normalizeFillColor(value) {
|
|
86696
87156
|
if (value === null) return null;
|
|
@@ -86705,10 +87165,10 @@ ${l}
|
|
|
86705
87165
|
return void 0;
|
|
86706
87166
|
}
|
|
86707
87167
|
function normalizeTextContent(value) {
|
|
86708
|
-
if (!isPlainObject$
|
|
87168
|
+
if (!isPlainObject$4(value)) return void 0;
|
|
86709
87169
|
if (!Array.isArray(value.parts)) return void 0;
|
|
86710
87170
|
if (value.parts.length === 0) return void 0;
|
|
86711
|
-
const validParts = value.parts.filter((p2) => isPlainObject$
|
|
87171
|
+
const validParts = value.parts.filter((p2) => isPlainObject$4(p2) && typeof p2.text === "string");
|
|
86712
87172
|
if (validParts.length === 0) return void 0;
|
|
86713
87173
|
const result = {
|
|
86714
87174
|
parts: validParts
|
|
@@ -86726,7 +87186,7 @@ ${l}
|
|
|
86726
87186
|
return void 0;
|
|
86727
87187
|
}
|
|
86728
87188
|
function normalizeTextInsets(value) {
|
|
86729
|
-
if (!isPlainObject$
|
|
87189
|
+
if (!isPlainObject$4(value)) return void 0;
|
|
86730
87190
|
const top2 = pickNumber(value.top);
|
|
86731
87191
|
const right2 = pickNumber(value.right);
|
|
86732
87192
|
const bottom2 = pickNumber(value.bottom);
|
|
@@ -86738,7 +87198,7 @@ ${l}
|
|
|
86738
87198
|
}
|
|
86739
87199
|
const OOXML_Z_INDEX_BASE = 251658240;
|
|
86740
87200
|
function normalizeZIndex(originalAttributes) {
|
|
86741
|
-
if (!isPlainObject$
|
|
87201
|
+
if (!isPlainObject$4(originalAttributes)) return void 0;
|
|
86742
87202
|
const relativeHeight = originalAttributes.relativeHeight;
|
|
86743
87203
|
if (typeof relativeHeight !== "number") return void 0;
|
|
86744
87204
|
return Math.max(0, relativeHeight - OOXML_Z_INDEX_BASE);
|
|
@@ -87892,321 +88352,6 @@ ${l}
|
|
|
87892
88352
|
}
|
|
87893
88353
|
return adjusted;
|
|
87894
88354
|
};
|
|
87895
|
-
const sdtMetadataCache = /* @__PURE__ */ new Map();
|
|
87896
|
-
function resolveStyle(node2, context, options = {}) {
|
|
87897
|
-
let paragraph2 = createDefaultParagraph();
|
|
87898
|
-
let character = createDefaultCharacter(context);
|
|
87899
|
-
let numbering;
|
|
87900
|
-
const chain = resolveStyleChain(node2.styleId, context.styles);
|
|
87901
|
-
for (const style2 of chain) {
|
|
87902
|
-
paragraph2 = mergeParagraph(paragraph2, style2.paragraph);
|
|
87903
|
-
character = mergeCharacter(character, style2.character);
|
|
87904
|
-
if (!numbering && style2.numbering) {
|
|
87905
|
-
numbering = resolveNumbering(style2.numbering.numId, style2.numbering.level, context);
|
|
87906
|
-
}
|
|
87907
|
-
}
|
|
87908
|
-
paragraph2 = mergeParagraph(paragraph2, node2.paragraphProps);
|
|
87909
|
-
character = mergeCharacter(character, node2.characterProps);
|
|
87910
|
-
if (node2.numbering) {
|
|
87911
|
-
numbering = resolveNumbering(node2.numbering.numId, node2.numbering.level, context);
|
|
87912
|
-
}
|
|
87913
|
-
const sdt = options?.sdt ? resolveSdtMetadata(options.sdt) : void 0;
|
|
87914
|
-
return {
|
|
87915
|
-
paragraph: paragraph2,
|
|
87916
|
-
character,
|
|
87917
|
-
numbering,
|
|
87918
|
-
sdt
|
|
87919
|
-
};
|
|
87920
|
-
}
|
|
87921
|
-
function resolveNumbering(numId, level, context) {
|
|
87922
|
-
const def2 = context.numbering?.[numId];
|
|
87923
|
-
if (!def2) return void 0;
|
|
87924
|
-
const levelDef = def2.levels.find((entry) => entry.level === level) ?? def2.levels[level];
|
|
87925
|
-
if (!levelDef) return void 0;
|
|
87926
|
-
return {
|
|
87927
|
-
numId,
|
|
87928
|
-
level,
|
|
87929
|
-
indent: {
|
|
87930
|
-
left: levelDef.indent?.left,
|
|
87931
|
-
hanging: levelDef.indent?.hanging
|
|
87932
|
-
},
|
|
87933
|
-
format: levelDef.format ?? "decimal",
|
|
87934
|
-
text: levelDef.text ?? "%1.",
|
|
87935
|
-
start: levelDef.start ?? 1
|
|
87936
|
-
};
|
|
87937
|
-
}
|
|
87938
|
-
function resolveSdtMetadata(input2) {
|
|
87939
|
-
if (!input2) return void 0;
|
|
87940
|
-
const { nodeType, attrs, cacheKey: explicitKey } = input2;
|
|
87941
|
-
if (!nodeType) return void 0;
|
|
87942
|
-
const normalizedAttrs = isPlainObject$4(attrs) ? attrs : {};
|
|
87943
|
-
const cacheKey = buildSdtCacheKey(nodeType, normalizedAttrs, explicitKey);
|
|
87944
|
-
if (cacheKey && sdtMetadataCache.has(cacheKey)) {
|
|
87945
|
-
return sdtMetadataCache.get(cacheKey);
|
|
87946
|
-
}
|
|
87947
|
-
let metadata;
|
|
87948
|
-
switch (nodeType) {
|
|
87949
|
-
case "fieldAnnotation":
|
|
87950
|
-
metadata = normalizeFieldAnnotationMetadata(normalizedAttrs);
|
|
87951
|
-
break;
|
|
87952
|
-
case "structuredContent":
|
|
87953
|
-
case "structuredContentBlock":
|
|
87954
|
-
metadata = normalizeStructuredContentMetadata(nodeType, normalizedAttrs);
|
|
87955
|
-
break;
|
|
87956
|
-
case "documentSection":
|
|
87957
|
-
metadata = normalizeDocumentSectionMetadata(normalizedAttrs);
|
|
87958
|
-
break;
|
|
87959
|
-
case "docPartObject":
|
|
87960
|
-
metadata = normalizeDocPartMetadata(normalizedAttrs);
|
|
87961
|
-
break;
|
|
87962
|
-
}
|
|
87963
|
-
if (metadata && cacheKey) {
|
|
87964
|
-
sdtMetadataCache.set(cacheKey, metadata);
|
|
87965
|
-
}
|
|
87966
|
-
return metadata;
|
|
87967
|
-
}
|
|
87968
|
-
function createDefaultParagraph(_context) {
|
|
87969
|
-
return {
|
|
87970
|
-
alignment: "left",
|
|
87971
|
-
spacing: {
|
|
87972
|
-
before: 0,
|
|
87973
|
-
after: 0,
|
|
87974
|
-
line: 12,
|
|
87975
|
-
lineRule: "auto"
|
|
87976
|
-
},
|
|
87977
|
-
indent: {
|
|
87978
|
-
left: 0,
|
|
87979
|
-
right: 0,
|
|
87980
|
-
firstLine: 0,
|
|
87981
|
-
hanging: 0
|
|
87982
|
-
},
|
|
87983
|
-
tabs: []
|
|
87984
|
-
};
|
|
87985
|
-
}
|
|
87986
|
-
function createDefaultCharacter(context) {
|
|
87987
|
-
const baseFont = context.defaults?.paragraphFont ?? "Calibri";
|
|
87988
|
-
const fallback = context.defaults?.paragraphFontFallback;
|
|
87989
|
-
const wordFamily = context.defaults?.paragraphFontFamily;
|
|
87990
|
-
const resolvedFamily = toCssFontFamily(baseFont, { fallback, wordFamily }) ?? baseFont;
|
|
87991
|
-
return {
|
|
87992
|
-
font: {
|
|
87993
|
-
family: resolvedFamily,
|
|
87994
|
-
size: context.defaults?.fontSize ?? 11,
|
|
87995
|
-
weight: 400,
|
|
87996
|
-
italic: false
|
|
87997
|
-
},
|
|
87998
|
-
color: "#000000"
|
|
87999
|
-
};
|
|
88000
|
-
}
|
|
88001
|
-
function resolveStyleChain(styleId, styles) {
|
|
88002
|
-
if (!styleId || !styles) return [];
|
|
88003
|
-
const result = [];
|
|
88004
|
-
const visited = /* @__PURE__ */ new Set();
|
|
88005
|
-
let current = styles[styleId];
|
|
88006
|
-
while (current && !visited.has(current.id)) {
|
|
88007
|
-
result.unshift(current);
|
|
88008
|
-
visited.add(current.id);
|
|
88009
|
-
current = current.basedOn ? styles[current.basedOn] : void 0;
|
|
88010
|
-
}
|
|
88011
|
-
return result;
|
|
88012
|
-
}
|
|
88013
|
-
function mergeParagraph(base2, overrides) {
|
|
88014
|
-
if (!overrides) return base2;
|
|
88015
|
-
return {
|
|
88016
|
-
...base2,
|
|
88017
|
-
alignment: overrides.alignment ?? base2.alignment,
|
|
88018
|
-
spacing: overrides.spacing ? { ...base2.spacing, ...overrides.spacing } : base2.spacing,
|
|
88019
|
-
indent: overrides.indent ? { ...base2.indent, ...overrides.indent } : base2.indent,
|
|
88020
|
-
borders: overrides.borders ? { ...base2.borders, ...overrides.borders } : base2.borders,
|
|
88021
|
-
shading: overrides.shading ?? base2.shading,
|
|
88022
|
-
tabs: overrides.tabs ?? base2.tabs
|
|
88023
|
-
};
|
|
88024
|
-
}
|
|
88025
|
-
function mergeCharacter(base2, overrides) {
|
|
88026
|
-
if (!overrides) return base2;
|
|
88027
|
-
return {
|
|
88028
|
-
...base2,
|
|
88029
|
-
font: overrides.font ? { ...base2.font, ...overrides.font } : base2.font,
|
|
88030
|
-
color: overrides.color ?? base2.color,
|
|
88031
|
-
underline: overrides.underline ?? base2.underline,
|
|
88032
|
-
strike: overrides.strike ?? base2.strike,
|
|
88033
|
-
highlight: overrides.highlight ?? base2.highlight,
|
|
88034
|
-
letterSpacing: overrides.letterSpacing ?? base2.letterSpacing
|
|
88035
|
-
};
|
|
88036
|
-
}
|
|
88037
|
-
function normalizeFieldAnnotationMetadata(attrs) {
|
|
88038
|
-
const fieldId = toOptionalString(attrs.fieldId) ?? "";
|
|
88039
|
-
const formatting = extractFormatting(attrs);
|
|
88040
|
-
const size2 = normalizeSize(attrs.size);
|
|
88041
|
-
const extras = isPlainObject$4(attrs.extras) ? attrs.extras : null;
|
|
88042
|
-
const marks = isPlainObject$4(attrs.marks) ? attrs.marks : void 0;
|
|
88043
|
-
return {
|
|
88044
|
-
type: "fieldAnnotation",
|
|
88045
|
-
fieldId,
|
|
88046
|
-
variant: normalizeFieldAnnotationVariant(attrs.type),
|
|
88047
|
-
fieldType: toOptionalString(attrs.fieldType),
|
|
88048
|
-
displayLabel: toOptionalString(attrs.displayLabel),
|
|
88049
|
-
defaultDisplayLabel: toOptionalString(attrs.defaultDisplayLabel),
|
|
88050
|
-
alias: toOptionalString(attrs.alias),
|
|
88051
|
-
fieldColor: normalizeColorValue(attrs.fieldColor),
|
|
88052
|
-
borderColor: normalizeColorValue(attrs.borderColor),
|
|
88053
|
-
highlighted: toBoolean$2(attrs.highlighted, true),
|
|
88054
|
-
fontFamily: toNullableString(attrs.fontFamily),
|
|
88055
|
-
fontSize: normalizeFontSize(attrs.fontSize),
|
|
88056
|
-
textColor: normalizeColorValue(attrs.textColor) ?? null,
|
|
88057
|
-
textHighlight: normalizeColorValue(attrs.textHighlight) ?? null,
|
|
88058
|
-
linkUrl: toNullableString(attrs.linkUrl),
|
|
88059
|
-
imageSrc: toNullableString(attrs.imageSrc),
|
|
88060
|
-
rawHtml: attrs.rawHtml ?? void 0,
|
|
88061
|
-
size: size2 ?? null,
|
|
88062
|
-
extras,
|
|
88063
|
-
multipleImage: toBoolean$2(attrs.multipleImage, false),
|
|
88064
|
-
hash: toOptionalString(attrs.hash) ?? null,
|
|
88065
|
-
generatorIndex: toNumber(attrs.generatorIndex),
|
|
88066
|
-
sdtId: toOptionalString(attrs.sdtId) ?? null,
|
|
88067
|
-
hidden: toBoolean$2(attrs.hidden, false),
|
|
88068
|
-
visibility: normalizeVisibility(attrs.visibility),
|
|
88069
|
-
isLocked: toBoolean$2(attrs.isLocked, false),
|
|
88070
|
-
formatting,
|
|
88071
|
-
marks
|
|
88072
|
-
};
|
|
88073
|
-
}
|
|
88074
|
-
function normalizeStructuredContentMetadata(nodeType, attrs) {
|
|
88075
|
-
return {
|
|
88076
|
-
type: "structuredContent",
|
|
88077
|
-
scope: nodeType === "structuredContentBlock" ? "block" : "inline",
|
|
88078
|
-
id: toNullableString(attrs.id),
|
|
88079
|
-
tag: toOptionalString(attrs.tag),
|
|
88080
|
-
alias: toOptionalString(attrs.alias),
|
|
88081
|
-
sdtPr: attrs.sdtPr
|
|
88082
|
-
};
|
|
88083
|
-
}
|
|
88084
|
-
function normalizeDocumentSectionMetadata(attrs) {
|
|
88085
|
-
return {
|
|
88086
|
-
type: "documentSection",
|
|
88087
|
-
id: toNullableString(attrs.id),
|
|
88088
|
-
title: toOptionalString(attrs.title) ?? null,
|
|
88089
|
-
description: toOptionalString(attrs.description) ?? null,
|
|
88090
|
-
sectionType: toOptionalString(attrs.sectionType) ?? null,
|
|
88091
|
-
isLocked: toBoolean$2(attrs.isLocked, false),
|
|
88092
|
-
sdBlockId: toNullableString(attrs.sdBlockId)
|
|
88093
|
-
};
|
|
88094
|
-
}
|
|
88095
|
-
function normalizeDocPartMetadata(attrs) {
|
|
88096
|
-
return {
|
|
88097
|
-
type: "docPartObject",
|
|
88098
|
-
gallery: toOptionalString(attrs.docPartGallery ?? attrs.gallery) ?? null,
|
|
88099
|
-
// Source uniqueId from attrs.id (PM adapter uses getDocPartObjectId which extracts attrs.id)
|
|
88100
|
-
// Fall back to attrs.uniqueId for compatibility
|
|
88101
|
-
uniqueId: toOptionalString(attrs.id ?? attrs.uniqueId) ?? null,
|
|
88102
|
-
alias: toOptionalString(attrs.alias) ?? null,
|
|
88103
|
-
instruction: toOptionalString(attrs.instruction) ?? null
|
|
88104
|
-
};
|
|
88105
|
-
}
|
|
88106
|
-
function isPlainObject$4(value) {
|
|
88107
|
-
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
88108
|
-
}
|
|
88109
|
-
function toOptionalString(value) {
|
|
88110
|
-
if (value == null) return void 0;
|
|
88111
|
-
if (typeof value === "string") {
|
|
88112
|
-
const trimmed = value.trim();
|
|
88113
|
-
return trimmed.length ? trimmed : void 0;
|
|
88114
|
-
}
|
|
88115
|
-
return String(value);
|
|
88116
|
-
}
|
|
88117
|
-
function toNullableString(value) {
|
|
88118
|
-
const str = toOptionalString(value);
|
|
88119
|
-
return str ?? null;
|
|
88120
|
-
}
|
|
88121
|
-
function toBoolean$2(value, fallback) {
|
|
88122
|
-
if (typeof value === "boolean") return value;
|
|
88123
|
-
if (typeof value === "string") {
|
|
88124
|
-
const lower = value.toLowerCase();
|
|
88125
|
-
if (lower === "true") return true;
|
|
88126
|
-
if (lower === "false") return false;
|
|
88127
|
-
}
|
|
88128
|
-
if (value == null) return fallback;
|
|
88129
|
-
return Boolean(value);
|
|
88130
|
-
}
|
|
88131
|
-
function normalizeVisibility(value) {
|
|
88132
|
-
if (typeof value !== "string") return void 0;
|
|
88133
|
-
const normalized = value.toLowerCase();
|
|
88134
|
-
if (normalized === "visible" || normalized === "hidden") {
|
|
88135
|
-
return normalized;
|
|
88136
|
-
}
|
|
88137
|
-
return void 0;
|
|
88138
|
-
}
|
|
88139
|
-
function normalizeColorValue(value) {
|
|
88140
|
-
if (typeof value !== "string") return void 0;
|
|
88141
|
-
const trimmed = value.trim();
|
|
88142
|
-
if (!trimmed || trimmed.toLowerCase() === "none") return void 0;
|
|
88143
|
-
return trimmed;
|
|
88144
|
-
}
|
|
88145
|
-
function normalizeFontSize(value) {
|
|
88146
|
-
if (value == null) return null;
|
|
88147
|
-
if (typeof value === "number") {
|
|
88148
|
-
return Number.isFinite(value) ? value : null;
|
|
88149
|
-
}
|
|
88150
|
-
if (typeof value === "string") {
|
|
88151
|
-
const trimmed = value.trim();
|
|
88152
|
-
return trimmed.length ? trimmed : null;
|
|
88153
|
-
}
|
|
88154
|
-
return null;
|
|
88155
|
-
}
|
|
88156
|
-
function toNumber(value) {
|
|
88157
|
-
if (typeof value === "number") {
|
|
88158
|
-
return Number.isFinite(value) ? value : null;
|
|
88159
|
-
}
|
|
88160
|
-
if (typeof value === "string") {
|
|
88161
|
-
const parsed = parseFloat(value);
|
|
88162
|
-
return Number.isFinite(parsed) ? parsed : null;
|
|
88163
|
-
}
|
|
88164
|
-
return null;
|
|
88165
|
-
}
|
|
88166
|
-
function normalizeSize(value) {
|
|
88167
|
-
if (!isPlainObject$4(value)) return null;
|
|
88168
|
-
const obj = value;
|
|
88169
|
-
const width = toNumber(obj.width);
|
|
88170
|
-
const height = toNumber(obj.height);
|
|
88171
|
-
if (width == null && height == null) return null;
|
|
88172
|
-
const result = {};
|
|
88173
|
-
if (width != null) result.width = width;
|
|
88174
|
-
if (height != null) result.height = height;
|
|
88175
|
-
return result;
|
|
88176
|
-
}
|
|
88177
|
-
function normalizeFieldAnnotationVariant(value) {
|
|
88178
|
-
if (typeof value !== "string") return void 0;
|
|
88179
|
-
const normalized = value.toLowerCase();
|
|
88180
|
-
if (normalized === "text" || normalized === "image" || normalized === "signature" || normalized === "checkbox" || normalized === "html" || normalized === "link") {
|
|
88181
|
-
return normalized;
|
|
88182
|
-
}
|
|
88183
|
-
return void 0;
|
|
88184
|
-
}
|
|
88185
|
-
function extractFormatting(attrs) {
|
|
88186
|
-
const bold = toBoolean$2(attrs.bold, false);
|
|
88187
|
-
const italic = toBoolean$2(attrs.italic, false);
|
|
88188
|
-
const underline = toBoolean$2(attrs.underline, false);
|
|
88189
|
-
const formatting = {};
|
|
88190
|
-
if (bold) formatting.bold = true;
|
|
88191
|
-
if (italic) formatting.italic = true;
|
|
88192
|
-
if (underline) formatting.underline = true;
|
|
88193
|
-
return Object.keys(formatting).length ? formatting : void 0;
|
|
88194
|
-
}
|
|
88195
|
-
function buildSdtCacheKey(nodeType, attrs, explicitKey) {
|
|
88196
|
-
const provided = toOptionalString(explicitKey);
|
|
88197
|
-
if (provided) {
|
|
88198
|
-
return `${nodeType}:${provided}`;
|
|
88199
|
-
}
|
|
88200
|
-
const hash2 = toOptionalString(attrs.hash);
|
|
88201
|
-
if (hash2) {
|
|
88202
|
-
return `${nodeType}:${hash2}`;
|
|
88203
|
-
}
|
|
88204
|
-
const id = toOptionalString(attrs.id);
|
|
88205
|
-
if (id) {
|
|
88206
|
-
return `${nodeType}:${id}`;
|
|
88207
|
-
}
|
|
88208
|
-
return void 0;
|
|
88209
|
-
}
|
|
88210
88355
|
const DEFAULT_LIST_HANGING_PX = 18;
|
|
88211
88356
|
const LIST_MARKER_GAP = 8;
|
|
88212
88357
|
const DEFAULT_BULLET_GLYPH = "•";
|
|
@@ -88766,6 +88911,7 @@ ${l}
|
|
|
88766
88911
|
definitions: {},
|
|
88767
88912
|
abstracts: {}
|
|
88768
88913
|
};
|
|
88914
|
+
const ooxmlResolver = createOoxmlResolver({ pPr: translator$14, rPr: translator$1O });
|
|
88769
88915
|
const hydrateParagraphStyleAttrs = (para, context, preResolved) => {
|
|
88770
88916
|
if (!hasParagraphStyleContext(context)) {
|
|
88771
88917
|
return null;
|
|
@@ -88793,7 +88939,7 @@ ${l}
|
|
|
88793
88939
|
// should still get docDefaults spacing from style resolution
|
|
88794
88940
|
numbering: context.numbering ?? EMPTY_NUMBERING_CONTEXT
|
|
88795
88941
|
};
|
|
88796
|
-
const resolved = resolveParagraphProperties(resolverParams, inlineProps);
|
|
88942
|
+
const resolved = ooxmlResolver.resolveParagraphProperties(resolverParams, inlineProps);
|
|
88797
88943
|
if (!resolved) {
|
|
88798
88944
|
return null;
|
|
88799
88945
|
}
|
|
@@ -88848,6 +88994,138 @@ ${l}
|
|
|
88848
88994
|
}
|
|
88849
88995
|
return { ...value };
|
|
88850
88996
|
};
|
|
88997
|
+
const buildCharacterStyleHydration = (resolved, docx) => {
|
|
88998
|
+
const fontFamily2 = extractFontFamily(resolved.fontFamily, docx);
|
|
88999
|
+
const fontSize2 = typeof resolved.fontSize === "number" ? resolved.fontSize : 20;
|
|
89000
|
+
const color2 = extractColorValue(resolved.color);
|
|
89001
|
+
const bold = normalizeBooleanProp(resolved.bold);
|
|
89002
|
+
const italic = normalizeBooleanProp(resolved.italic);
|
|
89003
|
+
const strike = normalizeBooleanProp(resolved.strike);
|
|
89004
|
+
const underline = extractUnderline(resolved.underline);
|
|
89005
|
+
const letterSpacing = typeof resolved.letterSpacing === "number" ? resolved.letterSpacing : void 0;
|
|
89006
|
+
return {
|
|
89007
|
+
fontFamily: fontFamily2,
|
|
89008
|
+
fontSize: fontSize2,
|
|
89009
|
+
color: color2,
|
|
89010
|
+
bold,
|
|
89011
|
+
italic,
|
|
89012
|
+
strike,
|
|
89013
|
+
underline,
|
|
89014
|
+
letterSpacing
|
|
89015
|
+
};
|
|
89016
|
+
};
|
|
89017
|
+
const hydrateCharacterStyleAttrs = (para, context, resolvedPpr) => {
|
|
89018
|
+
if (!hasParagraphStyleContext(context)) {
|
|
89019
|
+
return null;
|
|
89020
|
+
}
|
|
89021
|
+
const attrs = para.attrs ?? {};
|
|
89022
|
+
const paragraphProps = typeof attrs.paragraphProperties === "object" && attrs.paragraphProperties !== null ? attrs.paragraphProperties : {};
|
|
89023
|
+
const styleIdSource = attrs.styleId ?? paragraphProps.styleId;
|
|
89024
|
+
const styleId = typeof styleIdSource === "string" && styleIdSource.trim() ? styleIdSource : null;
|
|
89025
|
+
const inlineRpr = {};
|
|
89026
|
+
const pprForChain = resolvedPpr ?? { styleId };
|
|
89027
|
+
const numberingProps = attrs.numberingProperties ?? paragraphProps.numberingProperties;
|
|
89028
|
+
if (numberingProps != null) {
|
|
89029
|
+
pprForChain.numberingProperties = numberingProps;
|
|
89030
|
+
}
|
|
89031
|
+
const resolverParams = {
|
|
89032
|
+
docx: context.docx,
|
|
89033
|
+
numbering: context.numbering ?? EMPTY_NUMBERING_CONTEXT
|
|
89034
|
+
};
|
|
89035
|
+
let resolved = null;
|
|
89036
|
+
try {
|
|
89037
|
+
resolved = ooxmlResolver.resolveRunProperties(
|
|
89038
|
+
resolverParams,
|
|
89039
|
+
inlineRpr,
|
|
89040
|
+
pprForChain,
|
|
89041
|
+
false,
|
|
89042
|
+
// not list number marker
|
|
89043
|
+
false
|
|
89044
|
+
// not numberingDefinedInline
|
|
89045
|
+
);
|
|
89046
|
+
if (!resolved || typeof resolved !== "object") {
|
|
89047
|
+
return null;
|
|
89048
|
+
}
|
|
89049
|
+
} catch {
|
|
89050
|
+
return null;
|
|
89051
|
+
}
|
|
89052
|
+
return buildCharacterStyleHydration(resolved, context.docx);
|
|
89053
|
+
};
|
|
89054
|
+
const hydrateMarkerStyleAttrs = (para, context, resolvedPpr) => {
|
|
89055
|
+
if (!hasParagraphStyleContext(context)) {
|
|
89056
|
+
return null;
|
|
89057
|
+
}
|
|
89058
|
+
const attrs = para.attrs ?? {};
|
|
89059
|
+
const paragraphProps = typeof attrs.paragraphProperties === "object" && attrs.paragraphProperties !== null ? attrs.paragraphProperties : {};
|
|
89060
|
+
const styleIdSource = attrs.styleId ?? paragraphProps.styleId;
|
|
89061
|
+
const styleId = typeof styleIdSource === "string" && styleIdSource.trim() ? styleIdSource : null;
|
|
89062
|
+
const inlineRpr = {};
|
|
89063
|
+
const numberingProps = attrs.numberingProperties ?? paragraphProps.numberingProperties;
|
|
89064
|
+
const numberingDefinedInline = numberingProps?.numId != null;
|
|
89065
|
+
const pprForChain = resolvedPpr ? { ...resolvedPpr } : { styleId };
|
|
89066
|
+
if (styleId && !pprForChain.styleId) {
|
|
89067
|
+
pprForChain.styleId = styleId;
|
|
89068
|
+
}
|
|
89069
|
+
if (numberingProps != null) {
|
|
89070
|
+
pprForChain.numberingProperties = numberingProps;
|
|
89071
|
+
}
|
|
89072
|
+
const resolverParams = {
|
|
89073
|
+
docx: context.docx,
|
|
89074
|
+
numbering: context.numbering ?? EMPTY_NUMBERING_CONTEXT
|
|
89075
|
+
};
|
|
89076
|
+
let resolved = null;
|
|
89077
|
+
try {
|
|
89078
|
+
resolved = ooxmlResolver.resolveRunProperties(
|
|
89079
|
+
resolverParams,
|
|
89080
|
+
inlineRpr,
|
|
89081
|
+
pprForChain,
|
|
89082
|
+
true,
|
|
89083
|
+
numberingDefinedInline
|
|
89084
|
+
);
|
|
89085
|
+
if (!resolved || typeof resolved !== "object") {
|
|
89086
|
+
return null;
|
|
89087
|
+
}
|
|
89088
|
+
} catch {
|
|
89089
|
+
return null;
|
|
89090
|
+
}
|
|
89091
|
+
return buildCharacterStyleHydration(resolved, context.docx);
|
|
89092
|
+
};
|
|
89093
|
+
function extractFontFamily(fontFamily2, docx) {
|
|
89094
|
+
if (!fontFamily2 || typeof fontFamily2 !== "object") return void 0;
|
|
89095
|
+
const toCssFontFamily2 = SuperConverter.toCssFontFamily;
|
|
89096
|
+
const resolved = resolveDocxFontFamily(fontFamily2, docx ?? null, toCssFontFamily2);
|
|
89097
|
+
return resolved ?? void 0;
|
|
89098
|
+
}
|
|
89099
|
+
function extractColorValue(color2) {
|
|
89100
|
+
if (!color2 || typeof color2 !== "object") return void 0;
|
|
89101
|
+
const c2 = color2;
|
|
89102
|
+
const val = c2.val;
|
|
89103
|
+
if (typeof val !== "string") return void 0;
|
|
89104
|
+
if (!val || val.toLowerCase() === "auto") return void 0;
|
|
89105
|
+
return val;
|
|
89106
|
+
}
|
|
89107
|
+
function normalizeBooleanProp(value) {
|
|
89108
|
+
if (value == null) return void 0;
|
|
89109
|
+
if (typeof value === "boolean") return value;
|
|
89110
|
+
if (typeof value === "number") return value !== 0;
|
|
89111
|
+
if (typeof value === "string") {
|
|
89112
|
+
const lower = value.toLowerCase();
|
|
89113
|
+
if (lower === "0" || lower === "false" || lower === "off") return false;
|
|
89114
|
+
if (lower === "1" || lower === "true" || lower === "on" || lower === "") return true;
|
|
89115
|
+
}
|
|
89116
|
+
return Boolean(value);
|
|
89117
|
+
}
|
|
89118
|
+
function extractUnderline(underline) {
|
|
89119
|
+
if (!underline || typeof underline !== "object") return void 0;
|
|
89120
|
+
const u = underline;
|
|
89121
|
+
const type = u["w:val"] ?? u.type ?? u.val;
|
|
89122
|
+
if (typeof type !== "string" || type === "none") return void 0;
|
|
89123
|
+
const color2 = u["w:color"] ?? u.color;
|
|
89124
|
+
return {
|
|
89125
|
+
type,
|
|
89126
|
+
color: typeof color2 === "string" ? color2 : void 0
|
|
89127
|
+
};
|
|
89128
|
+
}
|
|
88851
89129
|
const { resolveSpacingIndent } = Engines;
|
|
88852
89130
|
const DEFAULT_DECIMAL_SEPARATOR$2 = ".";
|
|
88853
89131
|
const isValidNumberingId = (numId) => {
|
|
@@ -89363,7 +89641,7 @@ ${l}
|
|
|
89363
89641
|
}
|
|
89364
89642
|
return dropCapRun;
|
|
89365
89643
|
};
|
|
89366
|
-
const computeWordLayoutForParagraph = (paragraphAttrs, numberingProps, styleContext,
|
|
89644
|
+
const computeWordLayoutForParagraph = (paragraphAttrs, numberingProps, styleContext, paragraphNode, converterContext, resolvedPpr) => {
|
|
89367
89645
|
if (numberingProps === null) {
|
|
89368
89646
|
return null;
|
|
89369
89647
|
}
|
|
@@ -89401,7 +89679,23 @@ ${l}
|
|
|
89401
89679
|
spacing: {}
|
|
89402
89680
|
}
|
|
89403
89681
|
};
|
|
89404
|
-
let markerRun
|
|
89682
|
+
let markerRun;
|
|
89683
|
+
const markerHydration = paragraphNode && converterContext ? hydrateMarkerStyleAttrs(paragraphNode, converterContext, resolvedPpr) : null;
|
|
89684
|
+
if (markerHydration) {
|
|
89685
|
+
const resolvedColor = markerHydration.color ? `#${markerHydration.color.replace("#", "")}` : void 0;
|
|
89686
|
+
markerRun = {
|
|
89687
|
+
fontFamily: markerHydration.fontFamily ?? "Times New Roman",
|
|
89688
|
+
fontSize: markerHydration.fontSize / 2,
|
|
89689
|
+
// half-points to points
|
|
89690
|
+
bold: markerHydration.bold,
|
|
89691
|
+
italic: markerHydration.italic,
|
|
89692
|
+
color: resolvedColor,
|
|
89693
|
+
letterSpacing: markerHydration.letterSpacing != null ? twipsToPx$1(markerHydration.letterSpacing) : void 0
|
|
89694
|
+
};
|
|
89695
|
+
}
|
|
89696
|
+
if (!markerRun) {
|
|
89697
|
+
markerRun = numberingProps?.resolvedMarkerRpr;
|
|
89698
|
+
}
|
|
89405
89699
|
if (!markerRun) {
|
|
89406
89700
|
const { character: characterStyle } = resolveStyle({ styleId: paragraphAttrs.styleId }, styleContext);
|
|
89407
89701
|
if (characterStyle) {
|
|
@@ -89722,7 +90016,12 @@ ${l}
|
|
|
89722
90016
|
const numId = numberingProps.numId;
|
|
89723
90017
|
const ilvl = Number.isFinite(numberingProps.ilvl) ? Math.max(0, Math.floor(Number(numberingProps.ilvl))) : 0;
|
|
89724
90018
|
const numericNumId = typeof numId === "number" ? numId : void 0;
|
|
89725
|
-
|
|
90019
|
+
let resolvedLevel;
|
|
90020
|
+
try {
|
|
90021
|
+
resolvedLevel = resolveNumberingFromContext(numId, ilvl, converterContext?.numbering);
|
|
90022
|
+
} catch (error) {
|
|
90023
|
+
resolvedLevel = void 0;
|
|
90024
|
+
}
|
|
89726
90025
|
if (resolvedLevel) {
|
|
89727
90026
|
if (resolvedLevel.format && numberingProps.format == null) {
|
|
89728
90027
|
numberingProps.format = resolvedLevel.format;
|
|
@@ -89783,7 +90082,19 @@ ${l}
|
|
|
89783
90082
|
}
|
|
89784
90083
|
}
|
|
89785
90084
|
}
|
|
89786
|
-
let wordLayout =
|
|
90085
|
+
let wordLayout = null;
|
|
90086
|
+
try {
|
|
90087
|
+
wordLayout = computeWordLayoutForParagraph(
|
|
90088
|
+
paragraphAttrs,
|
|
90089
|
+
enrichedNumberingProps,
|
|
90090
|
+
styleContext,
|
|
90091
|
+
para,
|
|
90092
|
+
converterContext,
|
|
90093
|
+
hydrated?.resolved
|
|
90094
|
+
);
|
|
90095
|
+
} catch (error) {
|
|
90096
|
+
wordLayout = null;
|
|
90097
|
+
}
|
|
89787
90098
|
if (!wordLayout && enrichedNumberingProps.resolvedLevelIndent) {
|
|
89788
90099
|
const resolvedIndentPx = convertIndentTwipsToPx(enrichedNumberingProps.resolvedLevelIndent);
|
|
89789
90100
|
const baseIndent = resolvedIndentPx ?? enrichedNumberingProps.resolvedLevelIndent;
|
|
@@ -90328,7 +90639,7 @@ ${l}
|
|
|
90328
90639
|
const H_ALIGN_VALUES$1 = /* @__PURE__ */ new Set(["left", "center", "right"]);
|
|
90329
90640
|
const V_ALIGN_VALUES$1 = /* @__PURE__ */ new Set(["top", "center", "bottom"]);
|
|
90330
90641
|
const getAttrs$1 = (node2) => {
|
|
90331
|
-
return isPlainObject$
|
|
90642
|
+
return isPlainObject$4(node2.attrs) ? node2.attrs : {};
|
|
90332
90643
|
};
|
|
90333
90644
|
const normalizeWrapType$1 = (value) => {
|
|
90334
90645
|
if (typeof value !== "string") return void 0;
|
|
@@ -90351,7 +90662,7 @@ ${l}
|
|
|
90351
90662
|
return polygon.length > 0 ? polygon : void 0;
|
|
90352
90663
|
};
|
|
90353
90664
|
const normalizeWrap$2 = (value) => {
|
|
90354
|
-
if (!isPlainObject$
|
|
90665
|
+
if (!isPlainObject$4(value)) {
|
|
90355
90666
|
return void 0;
|
|
90356
90667
|
}
|
|
90357
90668
|
const type = normalizeWrapType$1(value.type);
|
|
@@ -90359,7 +90670,7 @@ ${l}
|
|
|
90359
90670
|
return void 0;
|
|
90360
90671
|
}
|
|
90361
90672
|
const wrap2 = { type };
|
|
90362
|
-
const attrs = isPlainObject$
|
|
90673
|
+
const attrs = isPlainObject$4(value.attrs) ? value.attrs : {};
|
|
90363
90674
|
const wrapText = normalizeWrapText$1(attrs.wrapText);
|
|
90364
90675
|
if (wrapText) {
|
|
90365
90676
|
wrap2.wrapText = wrapText;
|
|
@@ -90376,7 +90687,7 @@ ${l}
|
|
|
90376
90687
|
if (polygon) {
|
|
90377
90688
|
wrap2.polygon = polygon;
|
|
90378
90689
|
}
|
|
90379
|
-
const behindDoc = toBoolean$
|
|
90690
|
+
const behindDoc = toBoolean$2(attrs.behindDoc);
|
|
90380
90691
|
if (behindDoc != null) {
|
|
90381
90692
|
wrap2.behindDoc = behindDoc;
|
|
90382
90693
|
}
|
|
@@ -90391,10 +90702,10 @@ ${l}
|
|
|
90391
90702
|
return allowed.has(value) ? value : void 0;
|
|
90392
90703
|
};
|
|
90393
90704
|
const normalizeAnchorData$1 = (value, attrs, wrapBehindDoc) => {
|
|
90394
|
-
const raw = isPlainObject$
|
|
90395
|
-
const marginOffset = isPlainObject$
|
|
90396
|
-
const simplePos = isPlainObject$
|
|
90397
|
-
const originalAttrs = isPlainObject$
|
|
90705
|
+
const raw = isPlainObject$4(value) ? value : void 0;
|
|
90706
|
+
const marginOffset = isPlainObject$4(attrs.marginOffset) ? attrs.marginOffset : void 0;
|
|
90707
|
+
const simplePos = isPlainObject$4(attrs.simplePos) ? attrs.simplePos : void 0;
|
|
90708
|
+
const originalAttrs = isPlainObject$4(attrs.originalAttributes) ? attrs.originalAttributes : void 0;
|
|
90398
90709
|
const isAnchored = attrs.isAnchor === true || Boolean(raw);
|
|
90399
90710
|
const anchor = {};
|
|
90400
90711
|
if (isAnchored) {
|
|
@@ -90412,7 +90723,7 @@ ${l}
|
|
|
90412
90723
|
if (offsetH != null) anchor.offsetH = offsetH;
|
|
90413
90724
|
const offsetV = pickNumber(marginOffset?.top ?? marginOffset?.vertical ?? raw?.offsetV ?? simplePos?.y);
|
|
90414
90725
|
if (offsetV != null) anchor.offsetV = offsetV;
|
|
90415
|
-
const behindDoc = toBoolean$
|
|
90726
|
+
const behindDoc = toBoolean$2(raw?.behindDoc ?? wrapBehindDoc ?? originalAttrs?.behindDoc);
|
|
90416
90727
|
if (behindDoc != null) anchor.behindDoc = behindDoc;
|
|
90417
90728
|
const hasData = anchor.isAnchored || anchor.hRelativeFrom != null || anchor.vRelativeFrom != null || anchor.alignH != null || anchor.alignV != null || anchor.offsetH != null || anchor.offsetV != null || anchor.behindDoc != null;
|
|
90418
90729
|
return hasData ? anchor : void 0;
|
|
@@ -90537,7 +90848,7 @@ ${l}
|
|
|
90537
90848
|
}
|
|
90538
90849
|
}
|
|
90539
90850
|
const getAttrs = (node2) => {
|
|
90540
|
-
return isPlainObject$
|
|
90851
|
+
return isPlainObject$4(node2.attrs) ? { ...node2.attrs } : {};
|
|
90541
90852
|
};
|
|
90542
90853
|
const parseFullWidth = (value) => {
|
|
90543
90854
|
if (typeof value === "string") {
|
|
@@ -90556,7 +90867,7 @@ ${l}
|
|
|
90556
90867
|
if (rawAttrs.horizontalRule !== true) {
|
|
90557
90868
|
return null;
|
|
90558
90869
|
}
|
|
90559
|
-
const size2 = isPlainObject$
|
|
90870
|
+
const size2 = isPlainObject$4(rawAttrs.size) ? rawAttrs.size : void 0;
|
|
90560
90871
|
const { width, isFullWidth } = parseFullWidth(size2?.width);
|
|
90561
90872
|
const height = pickNumber(size2?.height);
|
|
90562
90873
|
if (!height || height <= 0) {
|
|
@@ -90758,6 +91069,9 @@ ${l}
|
|
|
90758
91069
|
return null;
|
|
90759
91070
|
};
|
|
90760
91071
|
const DEFAULT_IMAGE_DIMENSION_PX = 100;
|
|
91072
|
+
const HALF_POINTS_PER_POINT = 2;
|
|
91073
|
+
const SCREEN_DPI = 96;
|
|
91074
|
+
const POINT_DPI = 72;
|
|
90761
91075
|
function isInlineImage(node2) {
|
|
90762
91076
|
const attrs = node2.attrs ?? {};
|
|
90763
91077
|
const wrap2 = attrs.wrap;
|
|
@@ -90785,8 +91099,8 @@ ${l}
|
|
|
90785
91099
|
const size2 = attrs.size ?? {};
|
|
90786
91100
|
const width = typeof size2.width === "number" && Number.isFinite(size2.width) && size2.width > 0 ? size2.width : DEFAULT_IMAGE_DIMENSION_PX;
|
|
90787
91101
|
const height = typeof size2.height === "number" && Number.isFinite(size2.height) && size2.height > 0 ? size2.height : DEFAULT_IMAGE_DIMENSION_PX;
|
|
90788
|
-
const wrap2 = isPlainObject$
|
|
90789
|
-
const wrapAttrs = isPlainObject$
|
|
91102
|
+
const wrap2 = isPlainObject$4(attrs.wrap) ? attrs.wrap : {};
|
|
91103
|
+
const wrapAttrs = isPlainObject$4(wrap2.attrs) ? wrap2.attrs : {};
|
|
90790
91104
|
const run2 = {
|
|
90791
91105
|
kind: "image",
|
|
90792
91106
|
src,
|
|
@@ -90996,15 +91310,6 @@ ${l}
|
|
|
90996
91310
|
if (defaults2.letterSpacing != null && run2.letterSpacing == null) {
|
|
90997
91311
|
run2.letterSpacing = defaults2.letterSpacing;
|
|
90998
91312
|
}
|
|
90999
|
-
if (defaults2.bold && run2.bold === void 0) {
|
|
91000
|
-
run2.bold = true;
|
|
91001
|
-
}
|
|
91002
|
-
if (defaults2.italic && run2.italic === void 0) {
|
|
91003
|
-
run2.italic = true;
|
|
91004
|
-
}
|
|
91005
|
-
if (defaults2.underline && !run2.underline) {
|
|
91006
|
-
run2.underline = defaults2.underline;
|
|
91007
|
-
}
|
|
91008
91313
|
};
|
|
91009
91314
|
function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defaultSize, styleContext, listCounterContext, trackedChanges, bookmarks, hyperlinkConfig = DEFAULT_HYPERLINK_CONFIG$1, themeColors, converters, converterContext) {
|
|
91010
91315
|
const baseBlockId = nextBlockId("paragraph");
|
|
@@ -91013,28 +91318,45 @@ ${l}
|
|
|
91013
91318
|
const paragraphHydration = converterContext ? hydrateParagraphStyleAttrs(para, converterContext) : null;
|
|
91014
91319
|
let baseRunDefaults = {};
|
|
91015
91320
|
try {
|
|
91016
|
-
const
|
|
91017
|
-
|
|
91018
|
-
|
|
91019
|
-
|
|
91020
|
-
|
|
91021
|
-
|
|
91022
|
-
|
|
91023
|
-
|
|
91024
|
-
|
|
91025
|
-
|
|
91026
|
-
|
|
91027
|
-
|
|
91028
|
-
|
|
91029
|
-
|
|
91030
|
-
|
|
91031
|
-
|
|
91032
|
-
|
|
91033
|
-
|
|
91034
|
-
|
|
91035
|
-
|
|
91036
|
-
|
|
91037
|
-
|
|
91321
|
+
const charHydration = converterContext ? hydrateCharacterStyleAttrs(para, converterContext, paragraphHydration?.resolved) : null;
|
|
91322
|
+
if (charHydration) {
|
|
91323
|
+
const fontSizePx = charHydration.fontSize / HALF_POINTS_PER_POINT * (SCREEN_DPI / POINT_DPI);
|
|
91324
|
+
baseRunDefaults = {
|
|
91325
|
+
fontFamily: charHydration.fontFamily,
|
|
91326
|
+
fontSizePx,
|
|
91327
|
+
color: charHydration.color ? `#${charHydration.color.replace("#", "")}` : void 0,
|
|
91328
|
+
bold: charHydration.bold,
|
|
91329
|
+
italic: charHydration.italic,
|
|
91330
|
+
underline: charHydration.underline ? {
|
|
91331
|
+
style: charHydration.underline.type,
|
|
91332
|
+
color: charHydration.underline.color
|
|
91333
|
+
} : void 0,
|
|
91334
|
+
letterSpacing: charHydration.letterSpacing != null ? twipsToPx$1(charHydration.letterSpacing) : void 0
|
|
91335
|
+
};
|
|
91336
|
+
} else {
|
|
91337
|
+
const spacingSource = para.attrs?.spacing !== void 0 ? para.attrs.spacing : paragraphProps.spacing !== void 0 ? paragraphProps.spacing : paragraphHydration?.spacing;
|
|
91338
|
+
const indentSource = para.attrs?.indent ?? paragraphProps.indent ?? paragraphHydration?.indent;
|
|
91339
|
+
const normalizedSpacing = normalizeParagraphSpacing(spacingSource);
|
|
91340
|
+
const normalizedIndent = normalizePxIndent(indentSource) ?? normalizeParagraphIndent(indentSource ?? para.attrs?.textIndent);
|
|
91341
|
+
const styleNodeAttrs = paragraphHydration?.tabStops && !para.attrs?.tabStops && !para.attrs?.tabs ? { ...para.attrs ?? {}, tabStops: paragraphHydration.tabStops } : para.attrs ?? {};
|
|
91342
|
+
const styleNode = buildStyleNodeFromAttrs(styleNodeAttrs, normalizedSpacing, normalizedIndent);
|
|
91343
|
+
if (styleNodeAttrs.styleId == null && paragraphProps.styleId) {
|
|
91344
|
+
styleNode.styleId = paragraphProps.styleId;
|
|
91345
|
+
}
|
|
91346
|
+
const resolved = resolveStyle(styleNode, styleContext);
|
|
91347
|
+
baseRunDefaults = {
|
|
91348
|
+
fontFamily: resolved.character.font?.family,
|
|
91349
|
+
fontSizePx: ptToPx(resolved.character.font?.size),
|
|
91350
|
+
color: resolved.character.color,
|
|
91351
|
+
bold: resolved.character.font?.weight != null ? resolved.character.font.weight >= 600 : void 0,
|
|
91352
|
+
italic: resolved.character.font?.italic,
|
|
91353
|
+
underline: resolved.character.underline ? {
|
|
91354
|
+
style: resolved.character.underline.style,
|
|
91355
|
+
color: resolved.character.underline.color
|
|
91356
|
+
} : void 0,
|
|
91357
|
+
letterSpacing: ptToPx(resolved.character.letterSpacing)
|
|
91358
|
+
};
|
|
91359
|
+
}
|
|
91038
91360
|
} catch {
|
|
91039
91361
|
baseRunDefaults = {};
|
|
91040
91362
|
}
|
|
@@ -94585,7 +94907,8 @@ ${l}
|
|
|
94585
94907
|
const originX = currentLine.width;
|
|
94586
94908
|
const { target, nextIndex, stop } = getNextTabStopPx(currentLine.width, tabStops, tabStopCursor);
|
|
94587
94909
|
tabStopCursor = nextIndex;
|
|
94588
|
-
const
|
|
94910
|
+
const clampedTarget = Math.min(target, currentLine.maxWidth);
|
|
94911
|
+
const tabAdvance = Math.max(0, clampedTarget - currentLine.width);
|
|
94589
94912
|
currentLine.width = roundValue(currentLine.width + tabAdvance);
|
|
94590
94913
|
run2.width = tabAdvance;
|
|
94591
94914
|
currentLine.maxFontSize = Math.max(currentLine.maxFontSize, 12);
|
|
@@ -94593,14 +94916,14 @@ ${l}
|
|
|
94593
94916
|
currentLine.toChar = 1;
|
|
94594
94917
|
if (stop) {
|
|
94595
94918
|
validateTabStopVal(stop);
|
|
94596
|
-
pendingTabAlignment = { target, val: stop.val };
|
|
94919
|
+
pendingTabAlignment = { target: clampedTarget, val: stop.val };
|
|
94597
94920
|
} else {
|
|
94598
94921
|
pendingTabAlignment = null;
|
|
94599
94922
|
}
|
|
94600
94923
|
if (stop && stop.leader && stop.leader !== "none") {
|
|
94601
94924
|
const leaderStyle = stop.leader;
|
|
94602
|
-
const from2 = Math.min(originX,
|
|
94603
|
-
const to = Math.max(originX,
|
|
94925
|
+
const from2 = Math.min(originX, clampedTarget);
|
|
94926
|
+
const to = Math.max(originX, clampedTarget);
|
|
94604
94927
|
if (!currentLine.leaders) currentLine.leaders = [];
|
|
94605
94928
|
currentLine.leaders.push({ from: from2, to, style: leaderStyle });
|
|
94606
94929
|
}
|
|
@@ -95195,7 +95518,8 @@ ${l}
|
|
|
95195
95518
|
const originX = currentLine.width;
|
|
95196
95519
|
const { target, nextIndex, stop } = getNextTabStopPx(currentLine.width, tabStops, tabStopCursor);
|
|
95197
95520
|
tabStopCursor = nextIndex;
|
|
95198
|
-
const
|
|
95521
|
+
const clampedTarget = Math.min(target, currentLine.maxWidth);
|
|
95522
|
+
const tabAdvance = Math.max(0, clampedTarget - currentLine.width);
|
|
95199
95523
|
currentLine.width = roundValue(currentLine.width + tabAdvance);
|
|
95200
95524
|
currentLine.maxFontInfo = updateMaxFontInfo(currentLine.maxFontSize, currentLine.maxFontInfo, run2);
|
|
95201
95525
|
currentLine.maxFontSize = Math.max(currentLine.maxFontSize, run2.fontSize);
|
|
@@ -95204,14 +95528,14 @@ ${l}
|
|
|
95204
95528
|
charPosInRun += 1;
|
|
95205
95529
|
if (stop) {
|
|
95206
95530
|
validateTabStopVal(stop);
|
|
95207
|
-
pendingTabAlignment = { target, val: stop.val };
|
|
95531
|
+
pendingTabAlignment = { target: clampedTarget, val: stop.val };
|
|
95208
95532
|
} else {
|
|
95209
95533
|
pendingTabAlignment = null;
|
|
95210
95534
|
}
|
|
95211
95535
|
if (stop && stop.leader && stop.leader !== "none" && stop.leader !== "middleDot") {
|
|
95212
95536
|
const leaderStyle = stop.leader;
|
|
95213
|
-
const from2 = Math.min(originX,
|
|
95214
|
-
const to = Math.max(originX,
|
|
95537
|
+
const from2 = Math.min(originX, clampedTarget);
|
|
95538
|
+
const to = Math.max(originX, clampedTarget);
|
|
95215
95539
|
if (!currentLine.leaders) currentLine.leaders = [];
|
|
95216
95540
|
currentLine.leaders.push({ from: from2, to, style: leaderStyle });
|
|
95217
95541
|
}
|
|
@@ -103720,16 +104044,112 @@ ${l}
|
|
|
103720
104044
|
});
|
|
103721
104045
|
return mergeRanges$2(mapped, docSize);
|
|
103722
104046
|
};
|
|
103723
|
-
const
|
|
104047
|
+
const getParagraphAtPos = (doc2, pos) => {
|
|
104048
|
+
try {
|
|
104049
|
+
const $pos = doc2.resolve(pos);
|
|
104050
|
+
for (let depth = $pos.depth; depth >= 0; depth--) {
|
|
104051
|
+
const node2 = $pos.node(depth);
|
|
104052
|
+
if (node2.type.name === "paragraph") {
|
|
104053
|
+
return node2;
|
|
104054
|
+
}
|
|
104055
|
+
}
|
|
104056
|
+
} catch (_e2) {
|
|
104057
|
+
}
|
|
104058
|
+
return null;
|
|
104059
|
+
};
|
|
104060
|
+
const resolveRunPropertiesFromParagraphStyle = (paragraphNode, editor) => {
|
|
104061
|
+
if (!paragraphNode || !editor?.converter) return {};
|
|
104062
|
+
const styleId = paragraphNode.attrs?.paragraphProperties?.styleId;
|
|
104063
|
+
if (!styleId) return {};
|
|
104064
|
+
try {
|
|
104065
|
+
const params2 = { docx: editor.converter.convertedXml, numbering: editor.converter.numbering };
|
|
104066
|
+
const resolvedPpr = { styleId };
|
|
104067
|
+
const runProps = resolveRunProperties(params2, {}, resolvedPpr, false, false);
|
|
104068
|
+
const runProperties = {};
|
|
104069
|
+
if (runProps.fontFamily) {
|
|
104070
|
+
const fontValue = runProps.fontFamily.ascii || runProps.fontFamily;
|
|
104071
|
+
if (fontValue) {
|
|
104072
|
+
runProperties.fontFamily = typeof fontValue === "string" ? fontValue : fontValue.ascii;
|
|
104073
|
+
}
|
|
104074
|
+
}
|
|
104075
|
+
if (runProps.fontSize) {
|
|
104076
|
+
runProperties.fontSize = `${runProps.fontSize / 2}pt`;
|
|
104077
|
+
}
|
|
104078
|
+
if (runProps.bold) runProperties.bold = true;
|
|
104079
|
+
if (runProps.italic) runProperties.italic = true;
|
|
104080
|
+
if (runProps.underline) runProperties.underline = runProps.underline;
|
|
104081
|
+
if (runProps.strike) runProperties.strike = true;
|
|
104082
|
+
return runProperties;
|
|
104083
|
+
} catch (_e2) {
|
|
104084
|
+
return {};
|
|
104085
|
+
}
|
|
104086
|
+
};
|
|
104087
|
+
const createMarksFromDefs = (schema, markDefs = []) => markDefs.map((def2) => {
|
|
104088
|
+
const markType = schema.marks[def2.type];
|
|
104089
|
+
return markType ? markType.create(def2.attrs) : null;
|
|
104090
|
+
}).filter(Boolean);
|
|
104091
|
+
const createMarkDefsFromStyleRunProps = (styleRunProps) => {
|
|
104092
|
+
const markDefs = [];
|
|
104093
|
+
const textStyleAttrs = {};
|
|
104094
|
+
if (styleRunProps.fontSize) {
|
|
104095
|
+
textStyleAttrs.fontSize = styleRunProps.fontSize;
|
|
104096
|
+
}
|
|
104097
|
+
if (styleRunProps.fontFamily) {
|
|
104098
|
+
textStyleAttrs.fontFamily = styleRunProps.fontFamily;
|
|
104099
|
+
}
|
|
104100
|
+
if (Object.keys(textStyleAttrs).length > 0) {
|
|
104101
|
+
markDefs.push({ type: "textStyle", attrs: textStyleAttrs });
|
|
104102
|
+
}
|
|
104103
|
+
if (styleRunProps.bold) {
|
|
104104
|
+
markDefs.push({ type: "bold", attrs: { value: true } });
|
|
104105
|
+
}
|
|
104106
|
+
if (styleRunProps.italic) {
|
|
104107
|
+
markDefs.push({ type: "italic", attrs: { value: true } });
|
|
104108
|
+
}
|
|
104109
|
+
if (styleRunProps.strike) {
|
|
104110
|
+
markDefs.push({ type: "strike", attrs: { value: true } });
|
|
104111
|
+
}
|
|
104112
|
+
if (styleRunProps.underline) {
|
|
104113
|
+
const underlineType = styleRunProps.underline["w:val"];
|
|
104114
|
+
if (underlineType) {
|
|
104115
|
+
let underlineColor = styleRunProps.underline["w:color"];
|
|
104116
|
+
if (underlineColor && underlineColor.toLowerCase() !== "auto" && !underlineColor.startsWith("#")) {
|
|
104117
|
+
underlineColor = `#${underlineColor}`;
|
|
104118
|
+
}
|
|
104119
|
+
markDefs.push({
|
|
104120
|
+
type: "underline",
|
|
104121
|
+
attrs: { underlineType, underlineColor }
|
|
104122
|
+
});
|
|
104123
|
+
}
|
|
104124
|
+
}
|
|
104125
|
+
return markDefs;
|
|
104126
|
+
};
|
|
104127
|
+
const buildWrapTransaction = (state, ranges, runType, editor, markDefsFromMeta = []) => {
|
|
103724
104128
|
if (!ranges.length) return null;
|
|
103725
104129
|
const replacements = [];
|
|
104130
|
+
const metaStyleMarks = createMarksFromDefs(state.schema, markDefsFromMeta);
|
|
103726
104131
|
ranges.forEach(({ from: from2, to }) => {
|
|
103727
104132
|
state.doc.nodesBetween(from2, to, (node2, pos, parent, index2) => {
|
|
103728
104133
|
if (!node2.isText || !parent || parent.type === runType) return;
|
|
103729
104134
|
const match = parent.contentMatchAt ? parent.contentMatchAt(index2) : null;
|
|
103730
104135
|
if (match && !match.matchType(runType)) return;
|
|
103731
104136
|
if (!match && !parent.type.contentMatch.matchType(runType)) return;
|
|
103732
|
-
|
|
104137
|
+
let runProperties = decodeRPrFromMarks(node2.marks);
|
|
104138
|
+
if ((!node2.marks || node2.marks.length === 0) && editor?.converter) {
|
|
104139
|
+
const paragraphNode = getParagraphAtPos(state.doc, pos);
|
|
104140
|
+
const styleRunProps = resolveRunPropertiesFromParagraphStyle(paragraphNode, editor);
|
|
104141
|
+
if (Object.keys(styleRunProps).length > 0) {
|
|
104142
|
+
runProperties = styleRunProps;
|
|
104143
|
+
const markDefs = metaStyleMarks.length ? markDefsFromMeta : createMarkDefsFromStyleRunProps(styleRunProps);
|
|
104144
|
+
const styleMarks = metaStyleMarks.length ? metaStyleMarks : createMarksFromDefs(state.schema, markDefs);
|
|
104145
|
+
if (styleMarks.length && typeof state.schema.text === "function") {
|
|
104146
|
+
const textNode = state.schema.text(node2.text || "", styleMarks);
|
|
104147
|
+
if (textNode) {
|
|
104148
|
+
node2 = textNode;
|
|
104149
|
+
}
|
|
104150
|
+
}
|
|
104151
|
+
}
|
|
104152
|
+
}
|
|
103733
104153
|
const runNode = runType.create({ runProperties }, node2);
|
|
103734
104154
|
replacements.push({ from: pos, to: pos + node2.nodeSize, runNode });
|
|
103735
104155
|
});
|
|
@@ -103739,9 +104159,10 @@ ${l}
|
|
|
103739
104159
|
replacements.sort((a2, b2) => b2.from - a2.from).forEach(({ from: from2, to, runNode }) => tr.replaceWith(from2, to, runNode));
|
|
103740
104160
|
return tr.docChanged ? tr : null;
|
|
103741
104161
|
};
|
|
103742
|
-
const wrapTextInRunsPlugin = () => {
|
|
104162
|
+
const wrapTextInRunsPlugin = (editor) => {
|
|
103743
104163
|
let view = null;
|
|
103744
104164
|
let pendingRanges = [];
|
|
104165
|
+
let lastStyleMarksMeta = [];
|
|
103745
104166
|
const flush = () => {
|
|
103746
104167
|
if (!view) return;
|
|
103747
104168
|
const runType = view.state.schema.nodes.run;
|
|
@@ -103749,7 +104170,7 @@ ${l}
|
|
|
103749
104170
|
pendingRanges = [];
|
|
103750
104171
|
return;
|
|
103751
104172
|
}
|
|
103752
|
-
const tr = buildWrapTransaction(view.state, pendingRanges, runType);
|
|
104173
|
+
const tr = buildWrapTransaction(view.state, pendingRanges, runType, editor, lastStyleMarksMeta);
|
|
103753
104174
|
pendingRanges = [];
|
|
103754
104175
|
if (tr) {
|
|
103755
104176
|
view.dispatch(tr);
|
|
@@ -103768,6 +104189,7 @@ ${l}
|
|
|
103768
104189
|
editorView.dom.removeEventListener("compositionend", onCompositionEnd2);
|
|
103769
104190
|
view = null;
|
|
103770
104191
|
pendingRanges = [];
|
|
104192
|
+
lastStyleMarksMeta = [];
|
|
103771
104193
|
}
|
|
103772
104194
|
};
|
|
103773
104195
|
},
|
|
@@ -103781,7 +104203,11 @@ ${l}
|
|
|
103781
104203
|
if (view?.composing) {
|
|
103782
104204
|
return null;
|
|
103783
104205
|
}
|
|
103784
|
-
const
|
|
104206
|
+
const latestStyleMarksMeta = [...transactions].reverse().find((tr2) => tr2.getMeta && tr2.getMeta("sdStyleMarks"))?.getMeta("sdStyleMarks") || lastStyleMarksMeta;
|
|
104207
|
+
if (latestStyleMarksMeta && latestStyleMarksMeta.length) {
|
|
104208
|
+
lastStyleMarksMeta = latestStyleMarksMeta;
|
|
104209
|
+
}
|
|
104210
|
+
const tr = buildWrapTransaction(newState, pendingRanges, runType, editor, latestStyleMarksMeta);
|
|
103785
104211
|
pendingRanges = [];
|
|
103786
104212
|
return tr;
|
|
103787
104213
|
}
|
|
@@ -104044,7 +104470,7 @@ ${l}
|
|
|
104044
104470
|
},
|
|
104045
104471
|
addPmPlugins() {
|
|
104046
104472
|
return [
|
|
104047
|
-
wrapTextInRunsPlugin(),
|
|
104473
|
+
wrapTextInRunsPlugin(this.editor),
|
|
104048
104474
|
splitRunsAfterMarkPlugin,
|
|
104049
104475
|
calculateInlineRunPropertiesPlugin(this.editor),
|
|
104050
104476
|
cleanupEmptyRunsPlugin
|
|
@@ -143178,7 +143604,7 @@ ${reason}`);
|
|
|
143178
143604
|
this.config.colors = shuffleArray(this.config.colors);
|
|
143179
143605
|
this.userColorMap = /* @__PURE__ */ new Map();
|
|
143180
143606
|
this.colorIndex = 0;
|
|
143181
|
-
this.version = "1.3.0-next.
|
|
143607
|
+
this.version = "1.3.0-next.3";
|
|
143182
143608
|
this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
|
|
143183
143609
|
this.superdocId = config2.superdocId || v4();
|
|
143184
143610
|
this.colors = this.config.colors;
|