@harbour-enterprises/superdoc 1.3.0-next.2 → 1.3.0-next.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{PdfViewer-BpbDm_Oh.es.js → PdfViewer-BT0Whwl-.es.js} +2 -2
- package/dist/chunks/{PdfViewer-BEZc2jzN.cjs → PdfViewer-DkzZlntQ.cjs} +2 -2
- package/dist/chunks/{SuperConverter-ClzyObj7.es.js → SuperConverter-D62X6P1R.es.js} +296 -193
- package/dist/chunks/{SuperConverter-DOTz2R8L.cjs → SuperConverter-qB6m0K1X.cjs} +263 -160
- package/dist/chunks/{index-D5tN0eME.es.js → index-BgcNLeK9.es.js} +840 -436
- package/dist/chunks/{index-C2XLSjq0.cjs → index-Buh63pW6.cjs} +840 -436
- package/dist/chunks/{index-CMxyLpsU.es.js → index-CiR7cacp.es.js} +4 -4
- package/dist/chunks/{index-sykfrKvQ.cjs → index-Dtd_PFUu.cjs} +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 +1106 -603
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +3 -3
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"
|
|
12442
12661
|
};
|
|
12443
|
-
|
|
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
|
|
12697
|
+
};
|
|
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)) {
|
|
@@ -30445,8 +30890,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
30445
30890
|
hash: attrs.hash
|
|
30446
30891
|
};
|
|
30447
30892
|
const annotationAttrsJson = JSON.stringify(annotationAttrs);
|
|
30893
|
+
const sanitizedDisplayLabel = attrs.displayLabel === "undefined" || attrs.displayLabel === void 0 ? "" : attrs.displayLabel;
|
|
30448
30894
|
const sdtPrElements = [
|
|
30449
|
-
{ name: "w:alias", attributes: { "w:val":
|
|
30895
|
+
{ name: "w:alias", attributes: { "w:val": sanitizedDisplayLabel } },
|
|
30450
30896
|
{ name: "w:tag", attributes: { "w:val": annotationAttrsJson } },
|
|
30451
30897
|
{ name: "w:id", attributes: { "w:val": id } }
|
|
30452
30898
|
];
|
|
@@ -32519,7 +32965,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
32519
32965
|
text2 = text2.replace(/^[ \t\n\r]+/, "").replace(/[ \t\n\r]+$/, "");
|
|
32520
32966
|
}
|
|
32521
32967
|
text2 = text2.replace(/\[\[sdspace\]\]/g, "");
|
|
32522
|
-
|
|
32968
|
+
const isWhitespaceOnly = /^[ \t\n\r]*$/.test(text2);
|
|
32969
|
+
if (xmlSpace !== "preserve" && isWhitespaceOnly) {
|
|
32523
32970
|
return null;
|
|
32524
32971
|
}
|
|
32525
32972
|
} else if (!elements.length && encodedAttrs.xmlSpace === "preserve") {
|
|
@@ -35473,7 +35920,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
35473
35920
|
const result = additions.length ? [...existingRelationships, ...additions] : existingRelationships;
|
|
35474
35921
|
return result;
|
|
35475
35922
|
};
|
|
35476
|
-
const FONT_FAMILY_FALLBACKS
|
|
35923
|
+
const FONT_FAMILY_FALLBACKS = Object.freeze({
|
|
35477
35924
|
swiss: "Arial, sans-serif",
|
|
35478
35925
|
roman: "Times New Roman, serif",
|
|
35479
35926
|
modern: "Courier New, monospace",
|
|
@@ -35482,7 +35929,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
35482
35929
|
system: "system-ui",
|
|
35483
35930
|
auto: "sans-serif"
|
|
35484
35931
|
});
|
|
35485
|
-
const DEFAULT_GENERIC_FALLBACK
|
|
35932
|
+
const DEFAULT_GENERIC_FALLBACK = "sans-serif";
|
|
35486
35933
|
const DEFAULT_FONT_SIZE_PT = 10;
|
|
35487
35934
|
const collectRunDefaultProperties = (runProps, { allowOverrideTypeface = true, allowOverrideSize = true, themeResolver, state }) => {
|
|
35488
35935
|
if (!runProps?.elements?.length || !state) return;
|
|
@@ -35577,13 +36024,13 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
35577
36024
|
const fontEntry = SuperConverter.getFontTableEntry(docx, fontName);
|
|
35578
36025
|
const family = fontEntry?.elements?.find((child) => child.name === "w:family")?.attributes?.["w:val"];
|
|
35579
36026
|
if (!family) return null;
|
|
35580
|
-
const mapped = FONT_FAMILY_FALLBACKS
|
|
35581
|
-
return mapped || DEFAULT_GENERIC_FALLBACK
|
|
36027
|
+
const mapped = FONT_FAMILY_FALLBACKS[family.toLowerCase()];
|
|
36028
|
+
return mapped || DEFAULT_GENERIC_FALLBACK;
|
|
35582
36029
|
}
|
|
35583
36030
|
static toCssFontFamily(fontName, docx) {
|
|
35584
36031
|
if (!fontName) return fontName;
|
|
35585
36032
|
if (fontName.includes(",")) return fontName;
|
|
35586
|
-
const fallback = SuperConverter.getFallbackFromFontTable(docx, fontName) || DEFAULT_GENERIC_FALLBACK
|
|
36033
|
+
const fallback = SuperConverter.getFallbackFromFontTable(docx, fontName) || DEFAULT_GENERIC_FALLBACK;
|
|
35587
36034
|
const normalizedFallbackParts = fallback.split(",").map((part) => part.trim().toLowerCase()).filter(Boolean);
|
|
35588
36035
|
if (normalizedFallbackParts.includes(fontName.trim().toLowerCase())) {
|
|
35589
36036
|
return fallback;
|
|
@@ -35919,7 +36366,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
35919
36366
|
static getStoredSuperdocVersion(docx) {
|
|
35920
36367
|
return SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
|
|
35921
36368
|
}
|
|
35922
|
-
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.3.0-next.
|
|
36369
|
+
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.3.0-next.4") {
|
|
35923
36370
|
return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
|
|
35924
36371
|
}
|
|
35925
36372
|
/**
|
|
@@ -45269,15 +45716,19 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
45269
45716
|
dispatchTransaction = editor.dispatch.bind(editor);
|
|
45270
45717
|
}
|
|
45271
45718
|
if (!dispatchTransaction) return false;
|
|
45272
|
-
const handled = splitBlockPatch(
|
|
45273
|
-
|
|
45274
|
-
|
|
45719
|
+
const handled = splitBlockPatch(
|
|
45720
|
+
state,
|
|
45721
|
+
(transaction) => {
|
|
45722
|
+
dispatchTransaction(transaction);
|
|
45723
|
+
},
|
|
45724
|
+
editor
|
|
45725
|
+
);
|
|
45275
45726
|
if (handled) {
|
|
45276
45727
|
tr.setMeta("preventDispatch", true);
|
|
45277
45728
|
}
|
|
45278
45729
|
return handled;
|
|
45279
45730
|
};
|
|
45280
|
-
function splitBlockPatch(state, dispatch) {
|
|
45731
|
+
function splitBlockPatch(state, dispatch, editor) {
|
|
45281
45732
|
let { $from } = state.selection;
|
|
45282
45733
|
if (state.selection instanceof NodeSelection && state.selection.node.isBlock) {
|
|
45283
45734
|
if (!$from.parentOffset || !canSplit(state.doc, $from.pos)) return false;
|
|
@@ -45286,14 +45737,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
45286
45737
|
}
|
|
45287
45738
|
if (!$from.depth) return false;
|
|
45288
45739
|
let types2 = [];
|
|
45289
|
-
let splitDepth, deflt, atEnd = false, atStart = false;
|
|
45740
|
+
let splitDepth, deflt, paragraphAttrs = null, atEnd = false, atStart = false;
|
|
45290
45741
|
for (let d2 = $from.depth; ; d2--) {
|
|
45291
45742
|
let node2 = $from.node(d2);
|
|
45292
45743
|
if (node2.isBlock) {
|
|
45293
45744
|
atEnd = $from.end(d2) == $from.pos + ($from.depth - d2);
|
|
45294
45745
|
atStart = $from.start(d2) == $from.pos - ($from.depth - d2);
|
|
45295
45746
|
deflt = defaultBlockAt$1($from.node(d2 - 1).contentMatchAt($from.indexAfter(d2 - 1)));
|
|
45296
|
-
|
|
45747
|
+
paragraphAttrs = { ...node2.attrs };
|
|
45748
|
+
types2.unshift({ type: deflt || node2.type, attrs: paragraphAttrs });
|
|
45297
45749
|
splitDepth = d2;
|
|
45298
45750
|
break;
|
|
45299
45751
|
} else {
|
|
@@ -45306,7 +45758,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
45306
45758
|
let splitPos = tr.mapping.map($from.pos);
|
|
45307
45759
|
let can = canSplit(tr.doc, splitPos, types2.length, types2);
|
|
45308
45760
|
if (!can) {
|
|
45309
|
-
types2[0] = deflt ? { type: deflt } : null;
|
|
45761
|
+
types2[0] = deflt ? { type: deflt, attrs: paragraphAttrs } : null;
|
|
45310
45762
|
can = canSplit(tr.doc, splitPos, types2.length, types2);
|
|
45311
45763
|
}
|
|
45312
45764
|
if (!can) return false;
|
|
@@ -45316,9 +45768,37 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
45316
45768
|
if (deflt && $from.node(splitDepth - 1).canReplaceWith($first.index(), $first.index() + 1, deflt))
|
|
45317
45769
|
tr.setNodeMarkup(tr.mapping.map($from.before(splitDepth)), deflt);
|
|
45318
45770
|
}
|
|
45771
|
+
applyStyleMarks(state, tr, editor, paragraphAttrs);
|
|
45319
45772
|
if (dispatch) dispatch(tr.scrollIntoView());
|
|
45320
45773
|
return true;
|
|
45321
45774
|
}
|
|
45775
|
+
function applyStyleMarks(state, tr, editor, paragraphAttrs) {
|
|
45776
|
+
const styleId = paragraphAttrs?.paragraphProperties?.styleId;
|
|
45777
|
+
if (!editor?.converter && !styleId) {
|
|
45778
|
+
return;
|
|
45779
|
+
}
|
|
45780
|
+
try {
|
|
45781
|
+
const params2 = { docx: editor?.converter?.convertedXml ?? {}, numbering: editor?.converter?.numbering ?? {} };
|
|
45782
|
+
const resolvedPpr = styleId ? { styleId } : {};
|
|
45783
|
+
const runProperties = styleId ? resolveRunProperties(params2, {}, resolvedPpr, false, false) : {};
|
|
45784
|
+
const markDefsFromStyle = styleId ? (
|
|
45785
|
+
/** @type {Array<{type: string, attrs: Record<string, unknown>}>} */
|
|
45786
|
+
encodeMarksFromRPr(runProperties, editor?.converter?.convertedXml ?? {})
|
|
45787
|
+
) : [];
|
|
45788
|
+
const selectionMarks = state.selection?.$from?.marks ? state.selection.$from.marks() : [];
|
|
45789
|
+
const selectionMarkDefs = selectionMarks.map((mark2) => ({ type: mark2.type.name, attrs: mark2.attrs }));
|
|
45790
|
+
const markDefsToApply = selectionMarks.length ? selectionMarkDefs : markDefsFromStyle;
|
|
45791
|
+
const marksToApply = markDefsToApply.map((def2) => {
|
|
45792
|
+
const markType = state.schema.marks[def2.type];
|
|
45793
|
+
return markType ? markType.create(def2.attrs) : null;
|
|
45794
|
+
}).filter(Boolean);
|
|
45795
|
+
if (marksToApply.length > 0) {
|
|
45796
|
+
tr.ensureMarks(marksToApply);
|
|
45797
|
+
tr.setMeta("sdStyleMarks", markDefsToApply);
|
|
45798
|
+
}
|
|
45799
|
+
} catch {
|
|
45800
|
+
}
|
|
45801
|
+
}
|
|
45322
45802
|
const splitRunAtCursor = () => (props) => {
|
|
45323
45803
|
let { state, dispatch, tr } = props;
|
|
45324
45804
|
const sel = state.selection;
|
|
@@ -46202,7 +46682,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
46202
46682
|
}
|
|
46203
46683
|
return true;
|
|
46204
46684
|
};
|
|
46205
|
-
const isPlainObject$
|
|
46685
|
+
const isPlainObject$6 = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
46206
46686
|
const assignNestedValue = (target, path2, value) => {
|
|
46207
46687
|
if (!path2.includes(".")) {
|
|
46208
46688
|
target[path2] = value;
|
|
@@ -46216,7 +46696,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
46216
46696
|
if (isLast) {
|
|
46217
46697
|
current[part] = value;
|
|
46218
46698
|
} else {
|
|
46219
|
-
if (!isPlainObject$
|
|
46699
|
+
if (!isPlainObject$6(current[part])) {
|
|
46220
46700
|
current[part] = {};
|
|
46221
46701
|
}
|
|
46222
46702
|
current = current[part];
|
|
@@ -49189,8 +49669,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
49189
49669
|
const hasMatchingId = changeMarks.find((mark2) => mark2.attrs.id === id);
|
|
49190
49670
|
if (hasMatchingId) nodesWithMark.push(node3);
|
|
49191
49671
|
});
|
|
49672
|
+
const nodesToProcess = nodesWithMark.length ? nodesWithMark : node2 ? [node2] : [];
|
|
49673
|
+
if (!nodesToProcess.length) {
|
|
49674
|
+
return;
|
|
49675
|
+
}
|
|
49192
49676
|
const { deletionText, trackedChangeText } = getTrackedChangeText({
|
|
49193
|
-
nodes:
|
|
49677
|
+
nodes: nodesToProcess,
|
|
49194
49678
|
mark: trackedMark,
|
|
49195
49679
|
trackedChangeType,
|
|
49196
49680
|
isDeletionInsertion
|
|
@@ -52519,6 +53003,45 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
52519
53003
|
console.warn("[collaboration] Failed to update Ydoc docx data", error);
|
|
52520
53004
|
}
|
|
52521
53005
|
};
|
|
53006
|
+
let isApplyingRemoteChanges = false;
|
|
53007
|
+
const isApplyingRemoteHeaderFooterChanges = () => isApplyingRemoteChanges;
|
|
53008
|
+
const pushHeaderFooterToYjs = (editor, type, sectionId, content2) => {
|
|
53009
|
+
if (isApplyingRemoteChanges) return;
|
|
53010
|
+
const ydoc = editor?.options?.ydoc;
|
|
53011
|
+
if (!ydoc) return;
|
|
53012
|
+
const headerFooterMap = ydoc.getMap("headerFooterJson");
|
|
53013
|
+
const key2 = `${type}:${sectionId}`;
|
|
53014
|
+
const existing = headerFooterMap.get(key2)?.content;
|
|
53015
|
+
if (existing && JSON.stringify(existing) === JSON.stringify(content2)) {
|
|
53016
|
+
return;
|
|
53017
|
+
}
|
|
53018
|
+
ydoc.transact(() => headerFooterMap.set(key2, { type, sectionId, content: content2 }), {
|
|
53019
|
+
event: "header-footer-update",
|
|
53020
|
+
user: editor.options.user
|
|
53021
|
+
});
|
|
53022
|
+
};
|
|
53023
|
+
const applyRemoteHeaderFooterChanges = (editor, key2, data) => {
|
|
53024
|
+
if (!editor || editor.isDestroyed || !editor.converter) return;
|
|
53025
|
+
const { type, sectionId, content: content2 } = data;
|
|
53026
|
+
if (!type || !sectionId || !content2) return;
|
|
53027
|
+
isApplyingRemoteChanges = true;
|
|
53028
|
+
try {
|
|
53029
|
+
const storage = editor.converter[`${type}s`];
|
|
53030
|
+
if (storage) storage[sectionId] = content2;
|
|
53031
|
+
editor.converter.headerFooterModified = true;
|
|
53032
|
+
const editors = editor.converter[`${type}Editors`];
|
|
53033
|
+
editors?.forEach((item) => {
|
|
53034
|
+
if (item.id === sectionId && item.editor) {
|
|
53035
|
+
item.editor.replaceContent(content2);
|
|
53036
|
+
}
|
|
53037
|
+
});
|
|
53038
|
+
editor.emit("remoteHeaderFooterChanged", { type, sectionId, content: content2 });
|
|
53039
|
+
} finally {
|
|
53040
|
+
setTimeout(() => {
|
|
53041
|
+
isApplyingRemoteChanges = false;
|
|
53042
|
+
}, 0);
|
|
53043
|
+
}
|
|
53044
|
+
};
|
|
52522
53045
|
new PluginKey("collaboration");
|
|
52523
53046
|
const Collaboration = Extension.create({
|
|
52524
53047
|
name: "collaboration",
|
|
@@ -52547,6 +53070,18 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
52547
53070
|
}
|
|
52548
53071
|
});
|
|
52549
53072
|
});
|
|
53073
|
+
const headerFooterMap = this.options.ydoc.getMap("headerFooterJson");
|
|
53074
|
+
headerFooterMap.observe((event) => {
|
|
53075
|
+
if (event.transaction.local) return;
|
|
53076
|
+
event.changes.keys.forEach((change, key2) => {
|
|
53077
|
+
if (change.action === "add" || change.action === "update") {
|
|
53078
|
+
const data = headerFooterMap.get(key2);
|
|
53079
|
+
if (data) {
|
|
53080
|
+
applyRemoteHeaderFooterChanges(this.editor, key2, data);
|
|
53081
|
+
}
|
|
53082
|
+
}
|
|
53083
|
+
});
|
|
53084
|
+
});
|
|
52550
53085
|
return [syncPlugin];
|
|
52551
53086
|
},
|
|
52552
53087
|
addCommands() {
|
|
@@ -52665,7 +53200,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
52665
53200
|
const toRawType = (value) => {
|
|
52666
53201
|
return toTypeString(value).slice(8, -1);
|
|
52667
53202
|
};
|
|
52668
|
-
const isPlainObject$
|
|
53203
|
+
const isPlainObject$5 = (val) => toTypeString(val) === "[object Object]";
|
|
52669
53204
|
const isIntegerKey = (key2) => isString(key2) && key2 !== "NaN" && key2[0] !== "-" && "" + parseInt(key2, 10) === key2;
|
|
52670
53205
|
const isReservedProp = /* @__PURE__ */ makeMap(
|
|
52671
53206
|
// the leading comma is intentional so empty string "" is also included
|
|
@@ -52715,7 +53250,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
52715
53250
|
const n = parseFloat(val);
|
|
52716
53251
|
return isNaN(n) ? val : n;
|
|
52717
53252
|
};
|
|
52718
|
-
const toNumber
|
|
53253
|
+
const toNumber = (val) => {
|
|
52719
53254
|
const n = isString(val) ? Number(val) : NaN;
|
|
52720
53255
|
return isNaN(n) ? val : n;
|
|
52721
53256
|
};
|
|
@@ -52814,7 +53349,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
52814
53349
|
};
|
|
52815
53350
|
} else if (isSymbol$1(val)) {
|
|
52816
53351
|
return stringifySymbol(val);
|
|
52817
|
-
} else if (isObject$2(val) && !isArray$1(val) && !isPlainObject$
|
|
53352
|
+
} else if (isObject$2(val) && !isArray$1(val) && !isPlainObject$5(val)) {
|
|
52818
53353
|
return String(val);
|
|
52819
53354
|
}
|
|
52820
53355
|
return val;
|
|
@@ -54431,7 +54966,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
54431
54966
|
value.forEach((v2) => {
|
|
54432
54967
|
traverse(v2, depth, seen);
|
|
54433
54968
|
});
|
|
54434
|
-
} else if (isPlainObject$
|
|
54969
|
+
} else if (isPlainObject$5(value)) {
|
|
54435
54970
|
for (const key2 in value) {
|
|
54436
54971
|
traverse(value[key2], depth, seen);
|
|
54437
54972
|
}
|
|
@@ -59660,7 +60195,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
59660
60195
|
}
|
|
59661
60196
|
}
|
|
59662
60197
|
function NumberOf(val) {
|
|
59663
|
-
const res = toNumber
|
|
60198
|
+
const res = toNumber(val);
|
|
59664
60199
|
return res;
|
|
59665
60200
|
}
|
|
59666
60201
|
function addTransitionClass(el, cls) {
|
|
@@ -61541,7 +62076,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
61541
62076
|
return false;
|
|
61542
62077
|
}
|
|
61543
62078
|
};
|
|
61544
|
-
const summaryVersion = "1.3.0-next.
|
|
62079
|
+
const summaryVersion = "1.3.0-next.4";
|
|
61545
62080
|
const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
|
|
61546
62081
|
const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
|
|
61547
62082
|
function mapAttributes(attrs) {
|
|
@@ -64175,7 +64710,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
64175
64710
|
* Process collaboration migrations
|
|
64176
64711
|
*/
|
|
64177
64712
|
processCollaborationMigrations() {
|
|
64178
|
-
console.debug("[checkVersionMigrations] Current editor version", "1.3.0-next.
|
|
64713
|
+
console.debug("[checkVersionMigrations] Current editor version", "1.3.0-next.4");
|
|
64179
64714
|
if (!this.options.ydoc) return;
|
|
64180
64715
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
64181
64716
|
let docVersion = metaMap.get("version");
|
|
@@ -69751,39 +70286,6 @@ ${l}
|
|
|
69751
70286
|
right: borderValueToSpec(isLastCol ? tableBorders?.right : null)
|
|
69752
70287
|
};
|
|
69753
70288
|
};
|
|
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
70289
|
const LIST_MARKER_GAP$3 = 8;
|
|
69788
70290
|
function renderListMarker(params2) {
|
|
69789
70291
|
const { doc: doc2, lineEl, markerLayout, markerMeasure, indentLeftPx } = params2;
|
|
@@ -73787,7 +74289,12 @@ ${l}
|
|
|
73787
74289
|
const hanging = paraIndent?.hanging ?? 0;
|
|
73788
74290
|
const isFirstLineOfPara = lineIndex === 0 || lineIndex === void 0;
|
|
73789
74291
|
const firstLineOffsetForCumX = isFirstLineOfPara ? firstLine - hanging : 0;
|
|
73790
|
-
const
|
|
74292
|
+
const wordLayoutValue = block.attrs?.wordLayout;
|
|
74293
|
+
const wordLayout = isMinimalWordLayout(wordLayoutValue) ? wordLayoutValue : void 0;
|
|
74294
|
+
const isListParagraph = Boolean(wordLayout?.marker);
|
|
74295
|
+
const rawTextStartPx = typeof wordLayout?.marker?.textStartX === "number" && Number.isFinite(wordLayout.marker.textStartX) ? wordLayout.marker.textStartX : typeof wordLayout?.textStartPx === "number" && Number.isFinite(wordLayout.textStartPx) ? wordLayout.textStartPx : void 0;
|
|
74296
|
+
const listIndentOffset = isFirstLineOfPara ? rawTextStartPx ?? indentLeft : indentLeft;
|
|
74297
|
+
const indentOffset = isListParagraph ? listIndentOffset : indentLeft + firstLineOffsetForCumX;
|
|
73791
74298
|
let cumulativeX = 0;
|
|
73792
74299
|
const segmentsByRun = /* @__PURE__ */ new Map();
|
|
73793
74300
|
line.segments.forEach((segment) => {
|
|
@@ -86334,8 +86841,17 @@ ${l}
|
|
|
86334
86841
|
if (px == null || !Number.isFinite(px)) return void 0;
|
|
86335
86842
|
return px / PX_PER_PT;
|
|
86336
86843
|
};
|
|
86844
|
+
const convertIndentTwipsToPx$1 = (indent2) => {
|
|
86845
|
+
if (!indent2) return void 0;
|
|
86846
|
+
const result = {};
|
|
86847
|
+
if (isFiniteNumber(indent2.left)) result.left = twipsToPx$1(indent2.left);
|
|
86848
|
+
if (isFiniteNumber(indent2.right)) result.right = twipsToPx$1(indent2.right);
|
|
86849
|
+
if (isFiniteNumber(indent2.firstLine)) result.firstLine = twipsToPx$1(indent2.firstLine);
|
|
86850
|
+
if (isFiniteNumber(indent2.hanging)) result.hanging = twipsToPx$1(indent2.hanging);
|
|
86851
|
+
return Object.keys(result).length ? result : void 0;
|
|
86852
|
+
};
|
|
86337
86853
|
const isFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value);
|
|
86338
|
-
const isPlainObject$
|
|
86854
|
+
const isPlainObject$4 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
86339
86855
|
const normalizePrefix = (value) => {
|
|
86340
86856
|
if (!value) return "";
|
|
86341
86857
|
return String(value);
|
|
@@ -86397,7 +86913,7 @@ ${l}
|
|
|
86397
86913
|
}
|
|
86398
86914
|
return void 0;
|
|
86399
86915
|
}
|
|
86400
|
-
const toBoolean$
|
|
86916
|
+
const toBoolean$2 = (value) => {
|
|
86401
86917
|
if (typeof value === "boolean") return value;
|
|
86402
86918
|
if (typeof value === "string") {
|
|
86403
86919
|
const v2 = value.trim().toLowerCase();
|
|
@@ -86688,7 +87204,7 @@ ${l}
|
|
|
86688
87204
|
});
|
|
86689
87205
|
}
|
|
86690
87206
|
function isGradientFill(value) {
|
|
86691
|
-
if (!isPlainObject$
|
|
87207
|
+
if (!isPlainObject$4(value)) return false;
|
|
86692
87208
|
if (value.type !== "gradient") return false;
|
|
86693
87209
|
const gradientType = value.gradientType;
|
|
86694
87210
|
if (gradientType !== "linear" && gradientType !== "radial") return false;
|
|
@@ -86699,12 +87215,12 @@ ${l}
|
|
|
86699
87215
|
}
|
|
86700
87216
|
if (!Array.isArray(value.stops) || value.stops.length === 0) return false;
|
|
86701
87217
|
return value.stops.every((stop) => {
|
|
86702
|
-
if (!isPlainObject$
|
|
87218
|
+
if (!isPlainObject$4(stop)) return false;
|
|
86703
87219
|
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));
|
|
86704
87220
|
});
|
|
86705
87221
|
}
|
|
86706
87222
|
function isSolidFillWithAlpha(value) {
|
|
86707
|
-
return isPlainObject$
|
|
87223
|
+
return isPlainObject$4(value) && value.type === "solidWithAlpha" && typeof value.color === "string" && typeof value.alpha === "number";
|
|
86708
87224
|
}
|
|
86709
87225
|
function normalizeFillColor(value) {
|
|
86710
87226
|
if (value === null) return null;
|
|
@@ -86719,10 +87235,10 @@ ${l}
|
|
|
86719
87235
|
return void 0;
|
|
86720
87236
|
}
|
|
86721
87237
|
function normalizeTextContent(value) {
|
|
86722
|
-
if (!isPlainObject$
|
|
87238
|
+
if (!isPlainObject$4(value)) return void 0;
|
|
86723
87239
|
if (!Array.isArray(value.parts)) return void 0;
|
|
86724
87240
|
if (value.parts.length === 0) return void 0;
|
|
86725
|
-
const validParts = value.parts.filter((p2) => isPlainObject$
|
|
87241
|
+
const validParts = value.parts.filter((p2) => isPlainObject$4(p2) && typeof p2.text === "string");
|
|
86726
87242
|
if (validParts.length === 0) return void 0;
|
|
86727
87243
|
const result = {
|
|
86728
87244
|
parts: validParts
|
|
@@ -86740,7 +87256,7 @@ ${l}
|
|
|
86740
87256
|
return void 0;
|
|
86741
87257
|
}
|
|
86742
87258
|
function normalizeTextInsets(value) {
|
|
86743
|
-
if (!isPlainObject$
|
|
87259
|
+
if (!isPlainObject$4(value)) return void 0;
|
|
86744
87260
|
const top2 = pickNumber(value.top);
|
|
86745
87261
|
const right2 = pickNumber(value.right);
|
|
86746
87262
|
const bottom2 = pickNumber(value.bottom);
|
|
@@ -86752,7 +87268,7 @@ ${l}
|
|
|
86752
87268
|
}
|
|
86753
87269
|
const OOXML_Z_INDEX_BASE = 251658240;
|
|
86754
87270
|
function normalizeZIndex(originalAttributes) {
|
|
86755
|
-
if (!isPlainObject$
|
|
87271
|
+
if (!isPlainObject$4(originalAttributes)) return void 0;
|
|
86756
87272
|
const relativeHeight = originalAttributes.relativeHeight;
|
|
86757
87273
|
if (typeof relativeHeight !== "number") return void 0;
|
|
86758
87274
|
return Math.max(0, relativeHeight - OOXML_Z_INDEX_BASE);
|
|
@@ -87906,321 +88422,6 @@ ${l}
|
|
|
87906
88422
|
}
|
|
87907
88423
|
return adjusted;
|
|
87908
88424
|
};
|
|
87909
|
-
const sdtMetadataCache = /* @__PURE__ */ new Map();
|
|
87910
|
-
function resolveStyle(node2, context, options = {}) {
|
|
87911
|
-
let paragraph2 = createDefaultParagraph();
|
|
87912
|
-
let character = createDefaultCharacter(context);
|
|
87913
|
-
let numbering;
|
|
87914
|
-
const chain = resolveStyleChain(node2.styleId, context.styles);
|
|
87915
|
-
for (const style2 of chain) {
|
|
87916
|
-
paragraph2 = mergeParagraph(paragraph2, style2.paragraph);
|
|
87917
|
-
character = mergeCharacter(character, style2.character);
|
|
87918
|
-
if (!numbering && style2.numbering) {
|
|
87919
|
-
numbering = resolveNumbering(style2.numbering.numId, style2.numbering.level, context);
|
|
87920
|
-
}
|
|
87921
|
-
}
|
|
87922
|
-
paragraph2 = mergeParagraph(paragraph2, node2.paragraphProps);
|
|
87923
|
-
character = mergeCharacter(character, node2.characterProps);
|
|
87924
|
-
if (node2.numbering) {
|
|
87925
|
-
numbering = resolveNumbering(node2.numbering.numId, node2.numbering.level, context);
|
|
87926
|
-
}
|
|
87927
|
-
const sdt = options?.sdt ? resolveSdtMetadata(options.sdt) : void 0;
|
|
87928
|
-
return {
|
|
87929
|
-
paragraph: paragraph2,
|
|
87930
|
-
character,
|
|
87931
|
-
numbering,
|
|
87932
|
-
sdt
|
|
87933
|
-
};
|
|
87934
|
-
}
|
|
87935
|
-
function resolveNumbering(numId, level, context) {
|
|
87936
|
-
const def2 = context.numbering?.[numId];
|
|
87937
|
-
if (!def2) return void 0;
|
|
87938
|
-
const levelDef = def2.levels.find((entry) => entry.level === level) ?? def2.levels[level];
|
|
87939
|
-
if (!levelDef) return void 0;
|
|
87940
|
-
return {
|
|
87941
|
-
numId,
|
|
87942
|
-
level,
|
|
87943
|
-
indent: {
|
|
87944
|
-
left: levelDef.indent?.left,
|
|
87945
|
-
hanging: levelDef.indent?.hanging
|
|
87946
|
-
},
|
|
87947
|
-
format: levelDef.format ?? "decimal",
|
|
87948
|
-
text: levelDef.text ?? "%1.",
|
|
87949
|
-
start: levelDef.start ?? 1
|
|
87950
|
-
};
|
|
87951
|
-
}
|
|
87952
|
-
function resolveSdtMetadata(input2) {
|
|
87953
|
-
if (!input2) return void 0;
|
|
87954
|
-
const { nodeType, attrs, cacheKey: explicitKey } = input2;
|
|
87955
|
-
if (!nodeType) return void 0;
|
|
87956
|
-
const normalizedAttrs = isPlainObject$4(attrs) ? attrs : {};
|
|
87957
|
-
const cacheKey = buildSdtCacheKey(nodeType, normalizedAttrs, explicitKey);
|
|
87958
|
-
if (cacheKey && sdtMetadataCache.has(cacheKey)) {
|
|
87959
|
-
return sdtMetadataCache.get(cacheKey);
|
|
87960
|
-
}
|
|
87961
|
-
let metadata;
|
|
87962
|
-
switch (nodeType) {
|
|
87963
|
-
case "fieldAnnotation":
|
|
87964
|
-
metadata = normalizeFieldAnnotationMetadata(normalizedAttrs);
|
|
87965
|
-
break;
|
|
87966
|
-
case "structuredContent":
|
|
87967
|
-
case "structuredContentBlock":
|
|
87968
|
-
metadata = normalizeStructuredContentMetadata(nodeType, normalizedAttrs);
|
|
87969
|
-
break;
|
|
87970
|
-
case "documentSection":
|
|
87971
|
-
metadata = normalizeDocumentSectionMetadata(normalizedAttrs);
|
|
87972
|
-
break;
|
|
87973
|
-
case "docPartObject":
|
|
87974
|
-
metadata = normalizeDocPartMetadata(normalizedAttrs);
|
|
87975
|
-
break;
|
|
87976
|
-
}
|
|
87977
|
-
if (metadata && cacheKey) {
|
|
87978
|
-
sdtMetadataCache.set(cacheKey, metadata);
|
|
87979
|
-
}
|
|
87980
|
-
return metadata;
|
|
87981
|
-
}
|
|
87982
|
-
function createDefaultParagraph(_context) {
|
|
87983
|
-
return {
|
|
87984
|
-
alignment: "left",
|
|
87985
|
-
spacing: {
|
|
87986
|
-
before: 0,
|
|
87987
|
-
after: 0,
|
|
87988
|
-
line: 12,
|
|
87989
|
-
lineRule: "auto"
|
|
87990
|
-
},
|
|
87991
|
-
indent: {
|
|
87992
|
-
left: 0,
|
|
87993
|
-
right: 0,
|
|
87994
|
-
firstLine: 0,
|
|
87995
|
-
hanging: 0
|
|
87996
|
-
},
|
|
87997
|
-
tabs: []
|
|
87998
|
-
};
|
|
87999
|
-
}
|
|
88000
|
-
function createDefaultCharacter(context) {
|
|
88001
|
-
const baseFont = context.defaults?.paragraphFont ?? "Calibri";
|
|
88002
|
-
const fallback = context.defaults?.paragraphFontFallback;
|
|
88003
|
-
const wordFamily = context.defaults?.paragraphFontFamily;
|
|
88004
|
-
const resolvedFamily = toCssFontFamily(baseFont, { fallback, wordFamily }) ?? baseFont;
|
|
88005
|
-
return {
|
|
88006
|
-
font: {
|
|
88007
|
-
family: resolvedFamily,
|
|
88008
|
-
size: context.defaults?.fontSize ?? 11,
|
|
88009
|
-
weight: 400,
|
|
88010
|
-
italic: false
|
|
88011
|
-
},
|
|
88012
|
-
color: "#000000"
|
|
88013
|
-
};
|
|
88014
|
-
}
|
|
88015
|
-
function resolveStyleChain(styleId, styles) {
|
|
88016
|
-
if (!styleId || !styles) return [];
|
|
88017
|
-
const result = [];
|
|
88018
|
-
const visited = /* @__PURE__ */ new Set();
|
|
88019
|
-
let current = styles[styleId];
|
|
88020
|
-
while (current && !visited.has(current.id)) {
|
|
88021
|
-
result.unshift(current);
|
|
88022
|
-
visited.add(current.id);
|
|
88023
|
-
current = current.basedOn ? styles[current.basedOn] : void 0;
|
|
88024
|
-
}
|
|
88025
|
-
return result;
|
|
88026
|
-
}
|
|
88027
|
-
function mergeParagraph(base2, overrides) {
|
|
88028
|
-
if (!overrides) return base2;
|
|
88029
|
-
return {
|
|
88030
|
-
...base2,
|
|
88031
|
-
alignment: overrides.alignment ?? base2.alignment,
|
|
88032
|
-
spacing: overrides.spacing ? { ...base2.spacing, ...overrides.spacing } : base2.spacing,
|
|
88033
|
-
indent: overrides.indent ? { ...base2.indent, ...overrides.indent } : base2.indent,
|
|
88034
|
-
borders: overrides.borders ? { ...base2.borders, ...overrides.borders } : base2.borders,
|
|
88035
|
-
shading: overrides.shading ?? base2.shading,
|
|
88036
|
-
tabs: overrides.tabs ?? base2.tabs
|
|
88037
|
-
};
|
|
88038
|
-
}
|
|
88039
|
-
function mergeCharacter(base2, overrides) {
|
|
88040
|
-
if (!overrides) return base2;
|
|
88041
|
-
return {
|
|
88042
|
-
...base2,
|
|
88043
|
-
font: overrides.font ? { ...base2.font, ...overrides.font } : base2.font,
|
|
88044
|
-
color: overrides.color ?? base2.color,
|
|
88045
|
-
underline: overrides.underline ?? base2.underline,
|
|
88046
|
-
strike: overrides.strike ?? base2.strike,
|
|
88047
|
-
highlight: overrides.highlight ?? base2.highlight,
|
|
88048
|
-
letterSpacing: overrides.letterSpacing ?? base2.letterSpacing
|
|
88049
|
-
};
|
|
88050
|
-
}
|
|
88051
|
-
function normalizeFieldAnnotationMetadata(attrs) {
|
|
88052
|
-
const fieldId = toOptionalString(attrs.fieldId) ?? "";
|
|
88053
|
-
const formatting = extractFormatting(attrs);
|
|
88054
|
-
const size2 = normalizeSize(attrs.size);
|
|
88055
|
-
const extras = isPlainObject$4(attrs.extras) ? attrs.extras : null;
|
|
88056
|
-
const marks = isPlainObject$4(attrs.marks) ? attrs.marks : void 0;
|
|
88057
|
-
return {
|
|
88058
|
-
type: "fieldAnnotation",
|
|
88059
|
-
fieldId,
|
|
88060
|
-
variant: normalizeFieldAnnotationVariant(attrs.type),
|
|
88061
|
-
fieldType: toOptionalString(attrs.fieldType),
|
|
88062
|
-
displayLabel: toOptionalString(attrs.displayLabel),
|
|
88063
|
-
defaultDisplayLabel: toOptionalString(attrs.defaultDisplayLabel),
|
|
88064
|
-
alias: toOptionalString(attrs.alias),
|
|
88065
|
-
fieldColor: normalizeColorValue(attrs.fieldColor),
|
|
88066
|
-
borderColor: normalizeColorValue(attrs.borderColor),
|
|
88067
|
-
highlighted: toBoolean$2(attrs.highlighted, true),
|
|
88068
|
-
fontFamily: toNullableString(attrs.fontFamily),
|
|
88069
|
-
fontSize: normalizeFontSize(attrs.fontSize),
|
|
88070
|
-
textColor: normalizeColorValue(attrs.textColor) ?? null,
|
|
88071
|
-
textHighlight: normalizeColorValue(attrs.textHighlight) ?? null,
|
|
88072
|
-
linkUrl: toNullableString(attrs.linkUrl),
|
|
88073
|
-
imageSrc: toNullableString(attrs.imageSrc),
|
|
88074
|
-
rawHtml: attrs.rawHtml ?? void 0,
|
|
88075
|
-
size: size2 ?? null,
|
|
88076
|
-
extras,
|
|
88077
|
-
multipleImage: toBoolean$2(attrs.multipleImage, false),
|
|
88078
|
-
hash: toOptionalString(attrs.hash) ?? null,
|
|
88079
|
-
generatorIndex: toNumber(attrs.generatorIndex),
|
|
88080
|
-
sdtId: toOptionalString(attrs.sdtId) ?? null,
|
|
88081
|
-
hidden: toBoolean$2(attrs.hidden, false),
|
|
88082
|
-
visibility: normalizeVisibility(attrs.visibility),
|
|
88083
|
-
isLocked: toBoolean$2(attrs.isLocked, false),
|
|
88084
|
-
formatting,
|
|
88085
|
-
marks
|
|
88086
|
-
};
|
|
88087
|
-
}
|
|
88088
|
-
function normalizeStructuredContentMetadata(nodeType, attrs) {
|
|
88089
|
-
return {
|
|
88090
|
-
type: "structuredContent",
|
|
88091
|
-
scope: nodeType === "structuredContentBlock" ? "block" : "inline",
|
|
88092
|
-
id: toNullableString(attrs.id),
|
|
88093
|
-
tag: toOptionalString(attrs.tag),
|
|
88094
|
-
alias: toOptionalString(attrs.alias),
|
|
88095
|
-
sdtPr: attrs.sdtPr
|
|
88096
|
-
};
|
|
88097
|
-
}
|
|
88098
|
-
function normalizeDocumentSectionMetadata(attrs) {
|
|
88099
|
-
return {
|
|
88100
|
-
type: "documentSection",
|
|
88101
|
-
id: toNullableString(attrs.id),
|
|
88102
|
-
title: toOptionalString(attrs.title) ?? null,
|
|
88103
|
-
description: toOptionalString(attrs.description) ?? null,
|
|
88104
|
-
sectionType: toOptionalString(attrs.sectionType) ?? null,
|
|
88105
|
-
isLocked: toBoolean$2(attrs.isLocked, false),
|
|
88106
|
-
sdBlockId: toNullableString(attrs.sdBlockId)
|
|
88107
|
-
};
|
|
88108
|
-
}
|
|
88109
|
-
function normalizeDocPartMetadata(attrs) {
|
|
88110
|
-
return {
|
|
88111
|
-
type: "docPartObject",
|
|
88112
|
-
gallery: toOptionalString(attrs.docPartGallery ?? attrs.gallery) ?? null,
|
|
88113
|
-
// Source uniqueId from attrs.id (PM adapter uses getDocPartObjectId which extracts attrs.id)
|
|
88114
|
-
// Fall back to attrs.uniqueId for compatibility
|
|
88115
|
-
uniqueId: toOptionalString(attrs.id ?? attrs.uniqueId) ?? null,
|
|
88116
|
-
alias: toOptionalString(attrs.alias) ?? null,
|
|
88117
|
-
instruction: toOptionalString(attrs.instruction) ?? null
|
|
88118
|
-
};
|
|
88119
|
-
}
|
|
88120
|
-
function isPlainObject$4(value) {
|
|
88121
|
-
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
88122
|
-
}
|
|
88123
|
-
function toOptionalString(value) {
|
|
88124
|
-
if (value == null) return void 0;
|
|
88125
|
-
if (typeof value === "string") {
|
|
88126
|
-
const trimmed = value.trim();
|
|
88127
|
-
return trimmed.length ? trimmed : void 0;
|
|
88128
|
-
}
|
|
88129
|
-
return String(value);
|
|
88130
|
-
}
|
|
88131
|
-
function toNullableString(value) {
|
|
88132
|
-
const str = toOptionalString(value);
|
|
88133
|
-
return str ?? null;
|
|
88134
|
-
}
|
|
88135
|
-
function toBoolean$2(value, fallback) {
|
|
88136
|
-
if (typeof value === "boolean") return value;
|
|
88137
|
-
if (typeof value === "string") {
|
|
88138
|
-
const lower = value.toLowerCase();
|
|
88139
|
-
if (lower === "true") return true;
|
|
88140
|
-
if (lower === "false") return false;
|
|
88141
|
-
}
|
|
88142
|
-
if (value == null) return fallback;
|
|
88143
|
-
return Boolean(value);
|
|
88144
|
-
}
|
|
88145
|
-
function normalizeVisibility(value) {
|
|
88146
|
-
if (typeof value !== "string") return void 0;
|
|
88147
|
-
const normalized = value.toLowerCase();
|
|
88148
|
-
if (normalized === "visible" || normalized === "hidden") {
|
|
88149
|
-
return normalized;
|
|
88150
|
-
}
|
|
88151
|
-
return void 0;
|
|
88152
|
-
}
|
|
88153
|
-
function normalizeColorValue(value) {
|
|
88154
|
-
if (typeof value !== "string") return void 0;
|
|
88155
|
-
const trimmed = value.trim();
|
|
88156
|
-
if (!trimmed || trimmed.toLowerCase() === "none") return void 0;
|
|
88157
|
-
return trimmed;
|
|
88158
|
-
}
|
|
88159
|
-
function normalizeFontSize(value) {
|
|
88160
|
-
if (value == null) return null;
|
|
88161
|
-
if (typeof value === "number") {
|
|
88162
|
-
return Number.isFinite(value) ? value : null;
|
|
88163
|
-
}
|
|
88164
|
-
if (typeof value === "string") {
|
|
88165
|
-
const trimmed = value.trim();
|
|
88166
|
-
return trimmed.length ? trimmed : null;
|
|
88167
|
-
}
|
|
88168
|
-
return null;
|
|
88169
|
-
}
|
|
88170
|
-
function toNumber(value) {
|
|
88171
|
-
if (typeof value === "number") {
|
|
88172
|
-
return Number.isFinite(value) ? value : null;
|
|
88173
|
-
}
|
|
88174
|
-
if (typeof value === "string") {
|
|
88175
|
-
const parsed = parseFloat(value);
|
|
88176
|
-
return Number.isFinite(parsed) ? parsed : null;
|
|
88177
|
-
}
|
|
88178
|
-
return null;
|
|
88179
|
-
}
|
|
88180
|
-
function normalizeSize(value) {
|
|
88181
|
-
if (!isPlainObject$4(value)) return null;
|
|
88182
|
-
const obj = value;
|
|
88183
|
-
const width = toNumber(obj.width);
|
|
88184
|
-
const height = toNumber(obj.height);
|
|
88185
|
-
if (width == null && height == null) return null;
|
|
88186
|
-
const result = {};
|
|
88187
|
-
if (width != null) result.width = width;
|
|
88188
|
-
if (height != null) result.height = height;
|
|
88189
|
-
return result;
|
|
88190
|
-
}
|
|
88191
|
-
function normalizeFieldAnnotationVariant(value) {
|
|
88192
|
-
if (typeof value !== "string") return void 0;
|
|
88193
|
-
const normalized = value.toLowerCase();
|
|
88194
|
-
if (normalized === "text" || normalized === "image" || normalized === "signature" || normalized === "checkbox" || normalized === "html" || normalized === "link") {
|
|
88195
|
-
return normalized;
|
|
88196
|
-
}
|
|
88197
|
-
return void 0;
|
|
88198
|
-
}
|
|
88199
|
-
function extractFormatting(attrs) {
|
|
88200
|
-
const bold = toBoolean$2(attrs.bold, false);
|
|
88201
|
-
const italic = toBoolean$2(attrs.italic, false);
|
|
88202
|
-
const underline = toBoolean$2(attrs.underline, false);
|
|
88203
|
-
const formatting = {};
|
|
88204
|
-
if (bold) formatting.bold = true;
|
|
88205
|
-
if (italic) formatting.italic = true;
|
|
88206
|
-
if (underline) formatting.underline = true;
|
|
88207
|
-
return Object.keys(formatting).length ? formatting : void 0;
|
|
88208
|
-
}
|
|
88209
|
-
function buildSdtCacheKey(nodeType, attrs, explicitKey) {
|
|
88210
|
-
const provided = toOptionalString(explicitKey);
|
|
88211
|
-
if (provided) {
|
|
88212
|
-
return `${nodeType}:${provided}`;
|
|
88213
|
-
}
|
|
88214
|
-
const hash2 = toOptionalString(attrs.hash);
|
|
88215
|
-
if (hash2) {
|
|
88216
|
-
return `${nodeType}:${hash2}`;
|
|
88217
|
-
}
|
|
88218
|
-
const id = toOptionalString(attrs.id);
|
|
88219
|
-
if (id) {
|
|
88220
|
-
return `${nodeType}:${id}`;
|
|
88221
|
-
}
|
|
88222
|
-
return void 0;
|
|
88223
|
-
}
|
|
88224
88425
|
const DEFAULT_LIST_HANGING_PX = 18;
|
|
88225
88426
|
const LIST_MARKER_GAP = 8;
|
|
88226
88427
|
const DEFAULT_BULLET_GLYPH = "•";
|
|
@@ -88780,6 +88981,7 @@ ${l}
|
|
|
88780
88981
|
definitions: {},
|
|
88781
88982
|
abstracts: {}
|
|
88782
88983
|
};
|
|
88984
|
+
const ooxmlResolver = createOoxmlResolver({ pPr: translator$14, rPr: translator$1O });
|
|
88783
88985
|
const hydrateParagraphStyleAttrs = (para, context, preResolved) => {
|
|
88784
88986
|
if (!hasParagraphStyleContext(context)) {
|
|
88785
88987
|
return null;
|
|
@@ -88807,7 +89009,7 @@ ${l}
|
|
|
88807
89009
|
// should still get docDefaults spacing from style resolution
|
|
88808
89010
|
numbering: context.numbering ?? EMPTY_NUMBERING_CONTEXT
|
|
88809
89011
|
};
|
|
88810
|
-
const resolved = resolveParagraphProperties(resolverParams, inlineProps);
|
|
89012
|
+
const resolved = ooxmlResolver.resolveParagraphProperties(resolverParams, inlineProps);
|
|
88811
89013
|
if (!resolved) {
|
|
88812
89014
|
return null;
|
|
88813
89015
|
}
|
|
@@ -88862,6 +89064,138 @@ ${l}
|
|
|
88862
89064
|
}
|
|
88863
89065
|
return { ...value };
|
|
88864
89066
|
};
|
|
89067
|
+
const buildCharacterStyleHydration = (resolved, docx) => {
|
|
89068
|
+
const fontFamily2 = extractFontFamily(resolved.fontFamily, docx);
|
|
89069
|
+
const fontSize2 = typeof resolved.fontSize === "number" ? resolved.fontSize : 20;
|
|
89070
|
+
const color2 = extractColorValue(resolved.color);
|
|
89071
|
+
const bold = normalizeBooleanProp(resolved.bold);
|
|
89072
|
+
const italic = normalizeBooleanProp(resolved.italic);
|
|
89073
|
+
const strike = normalizeBooleanProp(resolved.strike);
|
|
89074
|
+
const underline = extractUnderline(resolved.underline);
|
|
89075
|
+
const letterSpacing = typeof resolved.letterSpacing === "number" ? resolved.letterSpacing : void 0;
|
|
89076
|
+
return {
|
|
89077
|
+
fontFamily: fontFamily2,
|
|
89078
|
+
fontSize: fontSize2,
|
|
89079
|
+
color: color2,
|
|
89080
|
+
bold,
|
|
89081
|
+
italic,
|
|
89082
|
+
strike,
|
|
89083
|
+
underline,
|
|
89084
|
+
letterSpacing
|
|
89085
|
+
};
|
|
89086
|
+
};
|
|
89087
|
+
const hydrateCharacterStyleAttrs = (para, context, resolvedPpr) => {
|
|
89088
|
+
if (!hasParagraphStyleContext(context)) {
|
|
89089
|
+
return null;
|
|
89090
|
+
}
|
|
89091
|
+
const attrs = para.attrs ?? {};
|
|
89092
|
+
const paragraphProps = typeof attrs.paragraphProperties === "object" && attrs.paragraphProperties !== null ? attrs.paragraphProperties : {};
|
|
89093
|
+
const styleIdSource = attrs.styleId ?? paragraphProps.styleId;
|
|
89094
|
+
const styleId = typeof styleIdSource === "string" && styleIdSource.trim() ? styleIdSource : null;
|
|
89095
|
+
const inlineRpr = {};
|
|
89096
|
+
const pprForChain = resolvedPpr ?? { styleId };
|
|
89097
|
+
const numberingProps = attrs.numberingProperties ?? paragraphProps.numberingProperties;
|
|
89098
|
+
if (numberingProps != null) {
|
|
89099
|
+
pprForChain.numberingProperties = numberingProps;
|
|
89100
|
+
}
|
|
89101
|
+
const resolverParams = {
|
|
89102
|
+
docx: context.docx,
|
|
89103
|
+
numbering: context.numbering ?? EMPTY_NUMBERING_CONTEXT
|
|
89104
|
+
};
|
|
89105
|
+
let resolved = null;
|
|
89106
|
+
try {
|
|
89107
|
+
resolved = ooxmlResolver.resolveRunProperties(
|
|
89108
|
+
resolverParams,
|
|
89109
|
+
inlineRpr,
|
|
89110
|
+
pprForChain,
|
|
89111
|
+
false,
|
|
89112
|
+
// not list number marker
|
|
89113
|
+
false
|
|
89114
|
+
// not numberingDefinedInline
|
|
89115
|
+
);
|
|
89116
|
+
if (!resolved || typeof resolved !== "object") {
|
|
89117
|
+
return null;
|
|
89118
|
+
}
|
|
89119
|
+
} catch {
|
|
89120
|
+
return null;
|
|
89121
|
+
}
|
|
89122
|
+
return buildCharacterStyleHydration(resolved, context.docx);
|
|
89123
|
+
};
|
|
89124
|
+
const hydrateMarkerStyleAttrs = (para, context, resolvedPpr) => {
|
|
89125
|
+
if (!hasParagraphStyleContext(context)) {
|
|
89126
|
+
return null;
|
|
89127
|
+
}
|
|
89128
|
+
const attrs = para.attrs ?? {};
|
|
89129
|
+
const paragraphProps = typeof attrs.paragraphProperties === "object" && attrs.paragraphProperties !== null ? attrs.paragraphProperties : {};
|
|
89130
|
+
const styleIdSource = attrs.styleId ?? paragraphProps.styleId;
|
|
89131
|
+
const styleId = typeof styleIdSource === "string" && styleIdSource.trim() ? styleIdSource : null;
|
|
89132
|
+
const inlineRpr = {};
|
|
89133
|
+
const numberingProps = attrs.numberingProperties ?? paragraphProps.numberingProperties;
|
|
89134
|
+
const numberingDefinedInline = numberingProps?.numId != null;
|
|
89135
|
+
const pprForChain = resolvedPpr ? { ...resolvedPpr } : { styleId };
|
|
89136
|
+
if (styleId && !pprForChain.styleId) {
|
|
89137
|
+
pprForChain.styleId = styleId;
|
|
89138
|
+
}
|
|
89139
|
+
if (numberingProps != null) {
|
|
89140
|
+
pprForChain.numberingProperties = numberingProps;
|
|
89141
|
+
}
|
|
89142
|
+
const resolverParams = {
|
|
89143
|
+
docx: context.docx,
|
|
89144
|
+
numbering: context.numbering ?? EMPTY_NUMBERING_CONTEXT
|
|
89145
|
+
};
|
|
89146
|
+
let resolved = null;
|
|
89147
|
+
try {
|
|
89148
|
+
resolved = ooxmlResolver.resolveRunProperties(
|
|
89149
|
+
resolverParams,
|
|
89150
|
+
inlineRpr,
|
|
89151
|
+
pprForChain,
|
|
89152
|
+
true,
|
|
89153
|
+
numberingDefinedInline
|
|
89154
|
+
);
|
|
89155
|
+
if (!resolved || typeof resolved !== "object") {
|
|
89156
|
+
return null;
|
|
89157
|
+
}
|
|
89158
|
+
} catch {
|
|
89159
|
+
return null;
|
|
89160
|
+
}
|
|
89161
|
+
return buildCharacterStyleHydration(resolved, context.docx);
|
|
89162
|
+
};
|
|
89163
|
+
function extractFontFamily(fontFamily2, docx) {
|
|
89164
|
+
if (!fontFamily2 || typeof fontFamily2 !== "object") return void 0;
|
|
89165
|
+
const toCssFontFamily2 = SuperConverter.toCssFontFamily;
|
|
89166
|
+
const resolved = resolveDocxFontFamily(fontFamily2, docx ?? null, toCssFontFamily2);
|
|
89167
|
+
return resolved ?? void 0;
|
|
89168
|
+
}
|
|
89169
|
+
function extractColorValue(color2) {
|
|
89170
|
+
if (!color2 || typeof color2 !== "object") return void 0;
|
|
89171
|
+
const c2 = color2;
|
|
89172
|
+
const val = c2.val;
|
|
89173
|
+
if (typeof val !== "string") return void 0;
|
|
89174
|
+
if (!val || val.toLowerCase() === "auto") return void 0;
|
|
89175
|
+
return val;
|
|
89176
|
+
}
|
|
89177
|
+
function normalizeBooleanProp(value) {
|
|
89178
|
+
if (value == null) return void 0;
|
|
89179
|
+
if (typeof value === "boolean") return value;
|
|
89180
|
+
if (typeof value === "number") return value !== 0;
|
|
89181
|
+
if (typeof value === "string") {
|
|
89182
|
+
const lower = value.toLowerCase();
|
|
89183
|
+
if (lower === "0" || lower === "false" || lower === "off") return false;
|
|
89184
|
+
if (lower === "1" || lower === "true" || lower === "on" || lower === "") return true;
|
|
89185
|
+
}
|
|
89186
|
+
return Boolean(value);
|
|
89187
|
+
}
|
|
89188
|
+
function extractUnderline(underline) {
|
|
89189
|
+
if (!underline || typeof underline !== "object") return void 0;
|
|
89190
|
+
const u = underline;
|
|
89191
|
+
const type = u["w:val"] ?? u.type ?? u.val;
|
|
89192
|
+
if (typeof type !== "string" || type === "none") return void 0;
|
|
89193
|
+
const color2 = u["w:color"] ?? u.color;
|
|
89194
|
+
return {
|
|
89195
|
+
type,
|
|
89196
|
+
color: typeof color2 === "string" ? color2 : void 0
|
|
89197
|
+
};
|
|
89198
|
+
}
|
|
88865
89199
|
const { resolveSpacingIndent } = Engines;
|
|
88866
89200
|
const DEFAULT_DECIMAL_SEPARATOR$2 = ".";
|
|
88867
89201
|
const isValidNumberingId = (numId) => {
|
|
@@ -89377,7 +89711,7 @@ ${l}
|
|
|
89377
89711
|
}
|
|
89378
89712
|
return dropCapRun;
|
|
89379
89713
|
};
|
|
89380
|
-
const computeWordLayoutForParagraph = (paragraphAttrs, numberingProps, styleContext,
|
|
89714
|
+
const computeWordLayoutForParagraph = (paragraphAttrs, numberingProps, styleContext, paragraphNode, converterContext, resolvedPpr) => {
|
|
89381
89715
|
if (numberingProps === null) {
|
|
89382
89716
|
return null;
|
|
89383
89717
|
}
|
|
@@ -89415,7 +89749,23 @@ ${l}
|
|
|
89415
89749
|
spacing: {}
|
|
89416
89750
|
}
|
|
89417
89751
|
};
|
|
89418
|
-
let markerRun
|
|
89752
|
+
let markerRun;
|
|
89753
|
+
const markerHydration = paragraphNode && converterContext ? hydrateMarkerStyleAttrs(paragraphNode, converterContext, resolvedPpr) : null;
|
|
89754
|
+
if (markerHydration) {
|
|
89755
|
+
const resolvedColor = markerHydration.color ? `#${markerHydration.color.replace("#", "")}` : void 0;
|
|
89756
|
+
markerRun = {
|
|
89757
|
+
fontFamily: markerHydration.fontFamily ?? "Times New Roman",
|
|
89758
|
+
fontSize: markerHydration.fontSize / 2,
|
|
89759
|
+
// half-points to points
|
|
89760
|
+
bold: markerHydration.bold,
|
|
89761
|
+
italic: markerHydration.italic,
|
|
89762
|
+
color: resolvedColor,
|
|
89763
|
+
letterSpacing: markerHydration.letterSpacing != null ? twipsToPx$1(markerHydration.letterSpacing) : void 0
|
|
89764
|
+
};
|
|
89765
|
+
}
|
|
89766
|
+
if (!markerRun) {
|
|
89767
|
+
markerRun = numberingProps?.resolvedMarkerRpr;
|
|
89768
|
+
}
|
|
89419
89769
|
if (!markerRun) {
|
|
89420
89770
|
const { character: characterStyle } = resolveStyle({ styleId: paragraphAttrs.styleId }, styleContext);
|
|
89421
89771
|
if (characterStyle) {
|
|
@@ -89484,8 +89834,11 @@ ${l}
|
|
|
89484
89834
|
const hydrated = hydrationOverride ?? hydrateParagraphStyleAttrs(para, converterContext);
|
|
89485
89835
|
const mergedSpacing = mergeSpacingSources(hydrated?.spacing, paragraphProps.spacing, attrs.spacing);
|
|
89486
89836
|
const normalizedSpacing = normalizeParagraphSpacing(mergedSpacing);
|
|
89487
|
-
const
|
|
89488
|
-
|
|
89837
|
+
const normalizeIndentObject = (value) => {
|
|
89838
|
+
if (!value || typeof value !== "object") return;
|
|
89839
|
+
return normalizePxIndent(value) ?? convertIndentTwipsToPx(value);
|
|
89840
|
+
};
|
|
89841
|
+
const normalizedIndent = normalizeIndentObject(attrs.indent) ?? convertIndentTwipsToPx(paragraphProps.indent) ?? convertIndentTwipsToPx(hydrated?.indent) ?? normalizeParagraphIndent(attrs.textIndent);
|
|
89489
89842
|
const unwrapTabStops = (tabStops) => {
|
|
89490
89843
|
if (!Array.isArray(tabStops)) {
|
|
89491
89844
|
return void 0;
|
|
@@ -89736,7 +90089,12 @@ ${l}
|
|
|
89736
90089
|
const numId = numberingProps.numId;
|
|
89737
90090
|
const ilvl = Number.isFinite(numberingProps.ilvl) ? Math.max(0, Math.floor(Number(numberingProps.ilvl))) : 0;
|
|
89738
90091
|
const numericNumId = typeof numId === "number" ? numId : void 0;
|
|
89739
|
-
|
|
90092
|
+
let resolvedLevel;
|
|
90093
|
+
try {
|
|
90094
|
+
resolvedLevel = resolveNumberingFromContext(numId, ilvl, converterContext?.numbering);
|
|
90095
|
+
} catch (error) {
|
|
90096
|
+
resolvedLevel = void 0;
|
|
90097
|
+
}
|
|
89740
90098
|
if (resolvedLevel) {
|
|
89741
90099
|
if (resolvedLevel.format && numberingProps.format == null) {
|
|
89742
90100
|
numberingProps.format = resolvedLevel.format;
|
|
@@ -89797,7 +90155,19 @@ ${l}
|
|
|
89797
90155
|
}
|
|
89798
90156
|
}
|
|
89799
90157
|
}
|
|
89800
|
-
let wordLayout =
|
|
90158
|
+
let wordLayout = null;
|
|
90159
|
+
try {
|
|
90160
|
+
wordLayout = computeWordLayoutForParagraph(
|
|
90161
|
+
paragraphAttrs,
|
|
90162
|
+
enrichedNumberingProps,
|
|
90163
|
+
styleContext,
|
|
90164
|
+
para,
|
|
90165
|
+
converterContext,
|
|
90166
|
+
hydrated?.resolved
|
|
90167
|
+
);
|
|
90168
|
+
} catch (error) {
|
|
90169
|
+
wordLayout = null;
|
|
90170
|
+
}
|
|
89801
90171
|
if (!wordLayout && enrichedNumberingProps.resolvedLevelIndent) {
|
|
89802
90172
|
const resolvedIndentPx = convertIndentTwipsToPx(enrichedNumberingProps.resolvedLevelIndent);
|
|
89803
90173
|
const baseIndent = resolvedIndentPx ?? enrichedNumberingProps.resolvedLevelIndent;
|
|
@@ -90342,7 +90712,7 @@ ${l}
|
|
|
90342
90712
|
const H_ALIGN_VALUES$1 = /* @__PURE__ */ new Set(["left", "center", "right"]);
|
|
90343
90713
|
const V_ALIGN_VALUES$1 = /* @__PURE__ */ new Set(["top", "center", "bottom"]);
|
|
90344
90714
|
const getAttrs$1 = (node2) => {
|
|
90345
|
-
return isPlainObject$
|
|
90715
|
+
return isPlainObject$4(node2.attrs) ? node2.attrs : {};
|
|
90346
90716
|
};
|
|
90347
90717
|
const normalizeWrapType$1 = (value) => {
|
|
90348
90718
|
if (typeof value !== "string") return void 0;
|
|
@@ -90365,7 +90735,7 @@ ${l}
|
|
|
90365
90735
|
return polygon.length > 0 ? polygon : void 0;
|
|
90366
90736
|
};
|
|
90367
90737
|
const normalizeWrap$2 = (value) => {
|
|
90368
|
-
if (!isPlainObject$
|
|
90738
|
+
if (!isPlainObject$4(value)) {
|
|
90369
90739
|
return void 0;
|
|
90370
90740
|
}
|
|
90371
90741
|
const type = normalizeWrapType$1(value.type);
|
|
@@ -90373,7 +90743,7 @@ ${l}
|
|
|
90373
90743
|
return void 0;
|
|
90374
90744
|
}
|
|
90375
90745
|
const wrap2 = { type };
|
|
90376
|
-
const attrs = isPlainObject$
|
|
90746
|
+
const attrs = isPlainObject$4(value.attrs) ? value.attrs : {};
|
|
90377
90747
|
const wrapText = normalizeWrapText$1(attrs.wrapText);
|
|
90378
90748
|
if (wrapText) {
|
|
90379
90749
|
wrap2.wrapText = wrapText;
|
|
@@ -90390,7 +90760,7 @@ ${l}
|
|
|
90390
90760
|
if (polygon) {
|
|
90391
90761
|
wrap2.polygon = polygon;
|
|
90392
90762
|
}
|
|
90393
|
-
const behindDoc = toBoolean$
|
|
90763
|
+
const behindDoc = toBoolean$2(attrs.behindDoc);
|
|
90394
90764
|
if (behindDoc != null) {
|
|
90395
90765
|
wrap2.behindDoc = behindDoc;
|
|
90396
90766
|
}
|
|
@@ -90405,10 +90775,10 @@ ${l}
|
|
|
90405
90775
|
return allowed.has(value) ? value : void 0;
|
|
90406
90776
|
};
|
|
90407
90777
|
const normalizeAnchorData$1 = (value, attrs, wrapBehindDoc) => {
|
|
90408
|
-
const raw = isPlainObject$
|
|
90409
|
-
const marginOffset = isPlainObject$
|
|
90410
|
-
const simplePos = isPlainObject$
|
|
90411
|
-
const originalAttrs = isPlainObject$
|
|
90778
|
+
const raw = isPlainObject$4(value) ? value : void 0;
|
|
90779
|
+
const marginOffset = isPlainObject$4(attrs.marginOffset) ? attrs.marginOffset : void 0;
|
|
90780
|
+
const simplePos = isPlainObject$4(attrs.simplePos) ? attrs.simplePos : void 0;
|
|
90781
|
+
const originalAttrs = isPlainObject$4(attrs.originalAttributes) ? attrs.originalAttributes : void 0;
|
|
90412
90782
|
const isAnchored = attrs.isAnchor === true || Boolean(raw);
|
|
90413
90783
|
const anchor = {};
|
|
90414
90784
|
if (isAnchored) {
|
|
@@ -90426,7 +90796,7 @@ ${l}
|
|
|
90426
90796
|
if (offsetH != null) anchor.offsetH = offsetH;
|
|
90427
90797
|
const offsetV = pickNumber(marginOffset?.top ?? marginOffset?.vertical ?? raw?.offsetV ?? simplePos?.y);
|
|
90428
90798
|
if (offsetV != null) anchor.offsetV = offsetV;
|
|
90429
|
-
const behindDoc = toBoolean$
|
|
90799
|
+
const behindDoc = toBoolean$2(raw?.behindDoc ?? wrapBehindDoc ?? originalAttrs?.behindDoc);
|
|
90430
90800
|
if (behindDoc != null) anchor.behindDoc = behindDoc;
|
|
90431
90801
|
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;
|
|
90432
90802
|
return hasData ? anchor : void 0;
|
|
@@ -90551,7 +90921,7 @@ ${l}
|
|
|
90551
90921
|
}
|
|
90552
90922
|
}
|
|
90553
90923
|
const getAttrs = (node2) => {
|
|
90554
|
-
return isPlainObject$
|
|
90924
|
+
return isPlainObject$4(node2.attrs) ? { ...node2.attrs } : {};
|
|
90555
90925
|
};
|
|
90556
90926
|
const parseFullWidth = (value) => {
|
|
90557
90927
|
if (typeof value === "string") {
|
|
@@ -90570,7 +90940,7 @@ ${l}
|
|
|
90570
90940
|
if (rawAttrs.horizontalRule !== true) {
|
|
90571
90941
|
return null;
|
|
90572
90942
|
}
|
|
90573
|
-
const size2 = isPlainObject$
|
|
90943
|
+
const size2 = isPlainObject$4(rawAttrs.size) ? rawAttrs.size : void 0;
|
|
90574
90944
|
const { width, isFullWidth } = parseFullWidth(size2?.width);
|
|
90575
90945
|
const height = pickNumber(size2?.height);
|
|
90576
90946
|
if (!height || height <= 0) {
|
|
@@ -90772,6 +91142,9 @@ ${l}
|
|
|
90772
91142
|
return null;
|
|
90773
91143
|
};
|
|
90774
91144
|
const DEFAULT_IMAGE_DIMENSION_PX = 100;
|
|
91145
|
+
const HALF_POINTS_PER_POINT = 2;
|
|
91146
|
+
const SCREEN_DPI = 96;
|
|
91147
|
+
const POINT_DPI = 72;
|
|
90775
91148
|
function isInlineImage(node2) {
|
|
90776
91149
|
const attrs = node2.attrs ?? {};
|
|
90777
91150
|
const wrap2 = attrs.wrap;
|
|
@@ -90799,8 +91172,8 @@ ${l}
|
|
|
90799
91172
|
const size2 = attrs.size ?? {};
|
|
90800
91173
|
const width = typeof size2.width === "number" && Number.isFinite(size2.width) && size2.width > 0 ? size2.width : DEFAULT_IMAGE_DIMENSION_PX;
|
|
90801
91174
|
const height = typeof size2.height === "number" && Number.isFinite(size2.height) && size2.height > 0 ? size2.height : DEFAULT_IMAGE_DIMENSION_PX;
|
|
90802
|
-
const wrap2 = isPlainObject$
|
|
90803
|
-
const wrapAttrs = isPlainObject$
|
|
91175
|
+
const wrap2 = isPlainObject$4(attrs.wrap) ? attrs.wrap : {};
|
|
91176
|
+
const wrapAttrs = isPlainObject$4(wrap2.attrs) ? wrap2.attrs : {};
|
|
90804
91177
|
const run2 = {
|
|
90805
91178
|
kind: "image",
|
|
90806
91179
|
src,
|
|
@@ -91010,15 +91383,6 @@ ${l}
|
|
|
91010
91383
|
if (defaults2.letterSpacing != null && run2.letterSpacing == null) {
|
|
91011
91384
|
run2.letterSpacing = defaults2.letterSpacing;
|
|
91012
91385
|
}
|
|
91013
|
-
if (defaults2.bold && run2.bold === void 0) {
|
|
91014
|
-
run2.bold = true;
|
|
91015
|
-
}
|
|
91016
|
-
if (defaults2.italic && run2.italic === void 0) {
|
|
91017
|
-
run2.italic = true;
|
|
91018
|
-
}
|
|
91019
|
-
if (defaults2.underline && !run2.underline) {
|
|
91020
|
-
run2.underline = defaults2.underline;
|
|
91021
|
-
}
|
|
91022
91386
|
};
|
|
91023
91387
|
function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defaultSize, styleContext, listCounterContext, trackedChanges, bookmarks, hyperlinkConfig = DEFAULT_HYPERLINK_CONFIG$1, themeColors, converters, converterContext) {
|
|
91024
91388
|
const baseBlockId = nextBlockId("paragraph");
|
|
@@ -91027,28 +91391,48 @@ ${l}
|
|
|
91027
91391
|
const paragraphHydration = converterContext ? hydrateParagraphStyleAttrs(para, converterContext) : null;
|
|
91028
91392
|
let baseRunDefaults = {};
|
|
91029
91393
|
try {
|
|
91030
|
-
const
|
|
91031
|
-
|
|
91032
|
-
|
|
91033
|
-
|
|
91034
|
-
|
|
91035
|
-
|
|
91036
|
-
|
|
91037
|
-
|
|
91038
|
-
|
|
91039
|
-
|
|
91040
|
-
|
|
91041
|
-
|
|
91042
|
-
|
|
91043
|
-
|
|
91044
|
-
|
|
91045
|
-
|
|
91046
|
-
|
|
91047
|
-
|
|
91048
|
-
|
|
91049
|
-
|
|
91050
|
-
|
|
91051
|
-
|
|
91394
|
+
const charHydration = converterContext ? hydrateCharacterStyleAttrs(para, converterContext, paragraphHydration?.resolved) : null;
|
|
91395
|
+
if (charHydration) {
|
|
91396
|
+
const fontSizePx = charHydration.fontSize / HALF_POINTS_PER_POINT * (SCREEN_DPI / POINT_DPI);
|
|
91397
|
+
baseRunDefaults = {
|
|
91398
|
+
fontFamily: charHydration.fontFamily,
|
|
91399
|
+
fontSizePx,
|
|
91400
|
+
color: charHydration.color ? `#${charHydration.color.replace("#", "")}` : void 0,
|
|
91401
|
+
bold: charHydration.bold,
|
|
91402
|
+
italic: charHydration.italic,
|
|
91403
|
+
underline: charHydration.underline ? {
|
|
91404
|
+
style: charHydration.underline.type,
|
|
91405
|
+
color: charHydration.underline.color
|
|
91406
|
+
} : void 0,
|
|
91407
|
+
letterSpacing: charHydration.letterSpacing != null ? twipsToPx$1(charHydration.letterSpacing) : void 0
|
|
91408
|
+
};
|
|
91409
|
+
} else {
|
|
91410
|
+
const spacingSource = para.attrs?.spacing !== void 0 ? para.attrs.spacing : paragraphProps.spacing !== void 0 ? paragraphProps.spacing : paragraphHydration?.spacing;
|
|
91411
|
+
const normalizeIndentObject = (value) => {
|
|
91412
|
+
if (!value || typeof value !== "object") return;
|
|
91413
|
+
return normalizePxIndent(value) ?? convertIndentTwipsToPx$1(value);
|
|
91414
|
+
};
|
|
91415
|
+
const normalizedSpacing = normalizeParagraphSpacing(spacingSource);
|
|
91416
|
+
const normalizedIndent = normalizeIndentObject(para.attrs?.indent) ?? convertIndentTwipsToPx$1(paragraphProps.indent) ?? convertIndentTwipsToPx$1(paragraphHydration?.indent) ?? normalizeParagraphIndent(para.attrs?.textIndent);
|
|
91417
|
+
const styleNodeAttrs = paragraphHydration?.tabStops && !para.attrs?.tabStops && !para.attrs?.tabs ? { ...para.attrs ?? {}, tabStops: paragraphHydration.tabStops } : para.attrs ?? {};
|
|
91418
|
+
const styleNode = buildStyleNodeFromAttrs(styleNodeAttrs, normalizedSpacing, normalizedIndent);
|
|
91419
|
+
if (styleNodeAttrs.styleId == null && paragraphProps.styleId) {
|
|
91420
|
+
styleNode.styleId = paragraphProps.styleId;
|
|
91421
|
+
}
|
|
91422
|
+
const resolved = resolveStyle(styleNode, styleContext);
|
|
91423
|
+
baseRunDefaults = {
|
|
91424
|
+
fontFamily: resolved.character.font?.family,
|
|
91425
|
+
fontSizePx: ptToPx(resolved.character.font?.size),
|
|
91426
|
+
color: resolved.character.color,
|
|
91427
|
+
bold: resolved.character.font?.weight != null ? resolved.character.font.weight >= 600 : void 0,
|
|
91428
|
+
italic: resolved.character.font?.italic,
|
|
91429
|
+
underline: resolved.character.underline ? {
|
|
91430
|
+
style: resolved.character.underline.style,
|
|
91431
|
+
color: resolved.character.underline.color
|
|
91432
|
+
} : void 0,
|
|
91433
|
+
letterSpacing: ptToPx(resolved.character.letterSpacing)
|
|
91434
|
+
};
|
|
91435
|
+
}
|
|
91052
91436
|
} catch {
|
|
91053
91437
|
baseRunDefaults = {};
|
|
91054
91438
|
}
|
|
@@ -92750,6 +93134,9 @@ ${l}
|
|
|
92750
93134
|
};
|
|
92751
93135
|
const onHeaderFooterDataUpdate = async ({ editor, transaction }, mainEditor, sectionId, type) => {
|
|
92752
93136
|
if (!type || !sectionId) return;
|
|
93137
|
+
if (isApplyingRemoteHeaderFooterChanges()) {
|
|
93138
|
+
return;
|
|
93139
|
+
}
|
|
92753
93140
|
const updatedData = editor.getUpdatedJson();
|
|
92754
93141
|
const editorsList = mainEditor.converter[`${type}Editors`];
|
|
92755
93142
|
if (Array.isArray(editorsList)) {
|
|
@@ -92773,6 +93160,7 @@ ${l}
|
|
|
92773
93160
|
if (editor.docChanged && mainEditor.converter) {
|
|
92774
93161
|
mainEditor.converter.headerFooterModified = true;
|
|
92775
93162
|
}
|
|
93163
|
+
pushHeaderFooterToYjs(mainEditor, type, sectionId, updatedData);
|
|
92776
93164
|
await updateYdocDocxData(mainEditor);
|
|
92777
93165
|
};
|
|
92778
93166
|
const setEditorToolbar = ({ editor }, mainEditor) => {
|
|
@@ -94599,7 +94987,8 @@ ${l}
|
|
|
94599
94987
|
const originX = currentLine.width;
|
|
94600
94988
|
const { target, nextIndex, stop } = getNextTabStopPx(currentLine.width, tabStops, tabStopCursor);
|
|
94601
94989
|
tabStopCursor = nextIndex;
|
|
94602
|
-
const
|
|
94990
|
+
const clampedTarget = Math.min(target, currentLine.maxWidth);
|
|
94991
|
+
const tabAdvance = Math.max(0, clampedTarget - currentLine.width);
|
|
94603
94992
|
currentLine.width = roundValue(currentLine.width + tabAdvance);
|
|
94604
94993
|
run2.width = tabAdvance;
|
|
94605
94994
|
currentLine.maxFontSize = Math.max(currentLine.maxFontSize, 12);
|
|
@@ -94607,14 +94996,14 @@ ${l}
|
|
|
94607
94996
|
currentLine.toChar = 1;
|
|
94608
94997
|
if (stop) {
|
|
94609
94998
|
validateTabStopVal(stop);
|
|
94610
|
-
pendingTabAlignment = { target, val: stop.val };
|
|
94999
|
+
pendingTabAlignment = { target: clampedTarget, val: stop.val };
|
|
94611
95000
|
} else {
|
|
94612
95001
|
pendingTabAlignment = null;
|
|
94613
95002
|
}
|
|
94614
95003
|
if (stop && stop.leader && stop.leader !== "none") {
|
|
94615
95004
|
const leaderStyle = stop.leader;
|
|
94616
|
-
const from2 = Math.min(originX,
|
|
94617
|
-
const to = Math.max(originX,
|
|
95005
|
+
const from2 = Math.min(originX, clampedTarget);
|
|
95006
|
+
const to = Math.max(originX, clampedTarget);
|
|
94618
95007
|
if (!currentLine.leaders) currentLine.leaders = [];
|
|
94619
95008
|
currentLine.leaders.push({ from: from2, to, style: leaderStyle });
|
|
94620
95009
|
}
|
|
@@ -95209,7 +95598,8 @@ ${l}
|
|
|
95209
95598
|
const originX = currentLine.width;
|
|
95210
95599
|
const { target, nextIndex, stop } = getNextTabStopPx(currentLine.width, tabStops, tabStopCursor);
|
|
95211
95600
|
tabStopCursor = nextIndex;
|
|
95212
|
-
const
|
|
95601
|
+
const clampedTarget = Math.min(target, currentLine.maxWidth);
|
|
95602
|
+
const tabAdvance = Math.max(0, clampedTarget - currentLine.width);
|
|
95213
95603
|
currentLine.width = roundValue(currentLine.width + tabAdvance);
|
|
95214
95604
|
currentLine.maxFontInfo = updateMaxFontInfo(currentLine.maxFontSize, currentLine.maxFontInfo, run2);
|
|
95215
95605
|
currentLine.maxFontSize = Math.max(currentLine.maxFontSize, run2.fontSize);
|
|
@@ -95218,14 +95608,14 @@ ${l}
|
|
|
95218
95608
|
charPosInRun += 1;
|
|
95219
95609
|
if (stop) {
|
|
95220
95610
|
validateTabStopVal(stop);
|
|
95221
|
-
pendingTabAlignment = { target, val: stop.val };
|
|
95611
|
+
pendingTabAlignment = { target: clampedTarget, val: stop.val };
|
|
95222
95612
|
} else {
|
|
95223
95613
|
pendingTabAlignment = null;
|
|
95224
95614
|
}
|
|
95225
95615
|
if (stop && stop.leader && stop.leader !== "none" && stop.leader !== "middleDot") {
|
|
95226
95616
|
const leaderStyle = stop.leader;
|
|
95227
|
-
const from2 = Math.min(originX,
|
|
95228
|
-
const to = Math.max(originX,
|
|
95617
|
+
const from2 = Math.min(originX, clampedTarget);
|
|
95618
|
+
const to = Math.max(originX, clampedTarget);
|
|
95229
95619
|
if (!currentLine.leaders) currentLine.leaders = [];
|
|
95230
95620
|
currentLine.leaders.push({ from: from2, to, style: leaderStyle });
|
|
95231
95621
|
}
|
|
@@ -97619,6 +98009,17 @@ ${l}
|
|
|
97619
98009
|
event: "collaborationReady",
|
|
97620
98010
|
handler: handleCollaborationReady
|
|
97621
98011
|
});
|
|
98012
|
+
const handleRemoteHeaderFooterChanged = (payload) => {
|
|
98013
|
+
this.#headerFooterAdapter?.invalidate(payload.sectionId);
|
|
98014
|
+
this.#headerFooterManager?.refresh();
|
|
98015
|
+
this.#pendingDocChange = true;
|
|
98016
|
+
this.#scheduleRerender();
|
|
98017
|
+
};
|
|
98018
|
+
this.#editor.on("remoteHeaderFooterChanged", handleRemoteHeaderFooterChanged);
|
|
98019
|
+
this.#editorListeners.push({
|
|
98020
|
+
event: "remoteHeaderFooterChanged",
|
|
98021
|
+
handler: handleRemoteHeaderFooterChanged
|
|
98022
|
+
});
|
|
97622
98023
|
}
|
|
97623
98024
|
/**
|
|
97624
98025
|
* Setup awareness event subscriptions for remote cursor tracking.
|
|
@@ -103734,16 +104135,112 @@ ${l}
|
|
|
103734
104135
|
});
|
|
103735
104136
|
return mergeRanges$2(mapped, docSize);
|
|
103736
104137
|
};
|
|
103737
|
-
const
|
|
104138
|
+
const getParagraphAtPos = (doc2, pos) => {
|
|
104139
|
+
try {
|
|
104140
|
+
const $pos = doc2.resolve(pos);
|
|
104141
|
+
for (let depth = $pos.depth; depth >= 0; depth--) {
|
|
104142
|
+
const node2 = $pos.node(depth);
|
|
104143
|
+
if (node2.type.name === "paragraph") {
|
|
104144
|
+
return node2;
|
|
104145
|
+
}
|
|
104146
|
+
}
|
|
104147
|
+
} catch (_e2) {
|
|
104148
|
+
}
|
|
104149
|
+
return null;
|
|
104150
|
+
};
|
|
104151
|
+
const resolveRunPropertiesFromParagraphStyle = (paragraphNode, editor) => {
|
|
104152
|
+
if (!paragraphNode || !editor?.converter) return {};
|
|
104153
|
+
const styleId = paragraphNode.attrs?.paragraphProperties?.styleId;
|
|
104154
|
+
if (!styleId) return {};
|
|
104155
|
+
try {
|
|
104156
|
+
const params2 = { docx: editor.converter.convertedXml, numbering: editor.converter.numbering };
|
|
104157
|
+
const resolvedPpr = { styleId };
|
|
104158
|
+
const runProps = resolveRunProperties(params2, {}, resolvedPpr, false, false);
|
|
104159
|
+
const runProperties = {};
|
|
104160
|
+
if (runProps.fontFamily) {
|
|
104161
|
+
const fontValue = runProps.fontFamily.ascii || runProps.fontFamily;
|
|
104162
|
+
if (fontValue) {
|
|
104163
|
+
runProperties.fontFamily = typeof fontValue === "string" ? fontValue : fontValue.ascii;
|
|
104164
|
+
}
|
|
104165
|
+
}
|
|
104166
|
+
if (runProps.fontSize) {
|
|
104167
|
+
runProperties.fontSize = `${runProps.fontSize / 2}pt`;
|
|
104168
|
+
}
|
|
104169
|
+
if (runProps.bold) runProperties.bold = true;
|
|
104170
|
+
if (runProps.italic) runProperties.italic = true;
|
|
104171
|
+
if (runProps.underline) runProperties.underline = runProps.underline;
|
|
104172
|
+
if (runProps.strike) runProperties.strike = true;
|
|
104173
|
+
return runProperties;
|
|
104174
|
+
} catch (_e2) {
|
|
104175
|
+
return {};
|
|
104176
|
+
}
|
|
104177
|
+
};
|
|
104178
|
+
const createMarksFromDefs = (schema, markDefs = []) => markDefs.map((def2) => {
|
|
104179
|
+
const markType = schema.marks[def2.type];
|
|
104180
|
+
return markType ? markType.create(def2.attrs) : null;
|
|
104181
|
+
}).filter(Boolean);
|
|
104182
|
+
const createMarkDefsFromStyleRunProps = (styleRunProps) => {
|
|
104183
|
+
const markDefs = [];
|
|
104184
|
+
const textStyleAttrs = {};
|
|
104185
|
+
if (styleRunProps.fontSize) {
|
|
104186
|
+
textStyleAttrs.fontSize = styleRunProps.fontSize;
|
|
104187
|
+
}
|
|
104188
|
+
if (styleRunProps.fontFamily) {
|
|
104189
|
+
textStyleAttrs.fontFamily = styleRunProps.fontFamily;
|
|
104190
|
+
}
|
|
104191
|
+
if (Object.keys(textStyleAttrs).length > 0) {
|
|
104192
|
+
markDefs.push({ type: "textStyle", attrs: textStyleAttrs });
|
|
104193
|
+
}
|
|
104194
|
+
if (styleRunProps.bold) {
|
|
104195
|
+
markDefs.push({ type: "bold", attrs: { value: true } });
|
|
104196
|
+
}
|
|
104197
|
+
if (styleRunProps.italic) {
|
|
104198
|
+
markDefs.push({ type: "italic", attrs: { value: true } });
|
|
104199
|
+
}
|
|
104200
|
+
if (styleRunProps.strike) {
|
|
104201
|
+
markDefs.push({ type: "strike", attrs: { value: true } });
|
|
104202
|
+
}
|
|
104203
|
+
if (styleRunProps.underline) {
|
|
104204
|
+
const underlineType = styleRunProps.underline["w:val"];
|
|
104205
|
+
if (underlineType) {
|
|
104206
|
+
let underlineColor = styleRunProps.underline["w:color"];
|
|
104207
|
+
if (underlineColor && underlineColor.toLowerCase() !== "auto" && !underlineColor.startsWith("#")) {
|
|
104208
|
+
underlineColor = `#${underlineColor}`;
|
|
104209
|
+
}
|
|
104210
|
+
markDefs.push({
|
|
104211
|
+
type: "underline",
|
|
104212
|
+
attrs: { underlineType, underlineColor }
|
|
104213
|
+
});
|
|
104214
|
+
}
|
|
104215
|
+
}
|
|
104216
|
+
return markDefs;
|
|
104217
|
+
};
|
|
104218
|
+
const buildWrapTransaction = (state, ranges, runType, editor, markDefsFromMeta = []) => {
|
|
103738
104219
|
if (!ranges.length) return null;
|
|
103739
104220
|
const replacements = [];
|
|
104221
|
+
const metaStyleMarks = createMarksFromDefs(state.schema, markDefsFromMeta);
|
|
103740
104222
|
ranges.forEach(({ from: from2, to }) => {
|
|
103741
104223
|
state.doc.nodesBetween(from2, to, (node2, pos, parent, index2) => {
|
|
103742
104224
|
if (!node2.isText || !parent || parent.type === runType) return;
|
|
103743
104225
|
const match = parent.contentMatchAt ? parent.contentMatchAt(index2) : null;
|
|
103744
104226
|
if (match && !match.matchType(runType)) return;
|
|
103745
104227
|
if (!match && !parent.type.contentMatch.matchType(runType)) return;
|
|
103746
|
-
|
|
104228
|
+
let runProperties = decodeRPrFromMarks(node2.marks);
|
|
104229
|
+
if ((!node2.marks || node2.marks.length === 0) && editor?.converter) {
|
|
104230
|
+
const paragraphNode = getParagraphAtPos(state.doc, pos);
|
|
104231
|
+
const styleRunProps = resolveRunPropertiesFromParagraphStyle(paragraphNode, editor);
|
|
104232
|
+
if (Object.keys(styleRunProps).length > 0) {
|
|
104233
|
+
runProperties = styleRunProps;
|
|
104234
|
+
const markDefs = metaStyleMarks.length ? markDefsFromMeta : createMarkDefsFromStyleRunProps(styleRunProps);
|
|
104235
|
+
const styleMarks = metaStyleMarks.length ? metaStyleMarks : createMarksFromDefs(state.schema, markDefs);
|
|
104236
|
+
if (styleMarks.length && typeof state.schema.text === "function") {
|
|
104237
|
+
const textNode = state.schema.text(node2.text || "", styleMarks);
|
|
104238
|
+
if (textNode) {
|
|
104239
|
+
node2 = textNode;
|
|
104240
|
+
}
|
|
104241
|
+
}
|
|
104242
|
+
}
|
|
104243
|
+
}
|
|
103747
104244
|
const runNode = runType.create({ runProperties }, node2);
|
|
103748
104245
|
replacements.push({ from: pos, to: pos + node2.nodeSize, runNode });
|
|
103749
104246
|
});
|
|
@@ -103753,9 +104250,10 @@ ${l}
|
|
|
103753
104250
|
replacements.sort((a2, b2) => b2.from - a2.from).forEach(({ from: from2, to, runNode }) => tr.replaceWith(from2, to, runNode));
|
|
103754
104251
|
return tr.docChanged ? tr : null;
|
|
103755
104252
|
};
|
|
103756
|
-
const wrapTextInRunsPlugin = () => {
|
|
104253
|
+
const wrapTextInRunsPlugin = (editor) => {
|
|
103757
104254
|
let view = null;
|
|
103758
104255
|
let pendingRanges = [];
|
|
104256
|
+
let lastStyleMarksMeta = [];
|
|
103759
104257
|
const flush = () => {
|
|
103760
104258
|
if (!view) return;
|
|
103761
104259
|
const runType = view.state.schema.nodes.run;
|
|
@@ -103763,7 +104261,7 @@ ${l}
|
|
|
103763
104261
|
pendingRanges = [];
|
|
103764
104262
|
return;
|
|
103765
104263
|
}
|
|
103766
|
-
const tr = buildWrapTransaction(view.state, pendingRanges, runType);
|
|
104264
|
+
const tr = buildWrapTransaction(view.state, pendingRanges, runType, editor, lastStyleMarksMeta);
|
|
103767
104265
|
pendingRanges = [];
|
|
103768
104266
|
if (tr) {
|
|
103769
104267
|
view.dispatch(tr);
|
|
@@ -103782,6 +104280,7 @@ ${l}
|
|
|
103782
104280
|
editorView.dom.removeEventListener("compositionend", onCompositionEnd2);
|
|
103783
104281
|
view = null;
|
|
103784
104282
|
pendingRanges = [];
|
|
104283
|
+
lastStyleMarksMeta = [];
|
|
103785
104284
|
}
|
|
103786
104285
|
};
|
|
103787
104286
|
},
|
|
@@ -103795,7 +104294,11 @@ ${l}
|
|
|
103795
104294
|
if (view?.composing) {
|
|
103796
104295
|
return null;
|
|
103797
104296
|
}
|
|
103798
|
-
const
|
|
104297
|
+
const latestStyleMarksMeta = [...transactions].reverse().find((tr2) => tr2.getMeta && tr2.getMeta("sdStyleMarks"))?.getMeta("sdStyleMarks") || lastStyleMarksMeta;
|
|
104298
|
+
if (latestStyleMarksMeta && latestStyleMarksMeta.length) {
|
|
104299
|
+
lastStyleMarksMeta = latestStyleMarksMeta;
|
|
104300
|
+
}
|
|
104301
|
+
const tr = buildWrapTransaction(newState, pendingRanges, runType, editor, latestStyleMarksMeta);
|
|
103799
104302
|
pendingRanges = [];
|
|
103800
104303
|
return tr;
|
|
103801
104304
|
}
|
|
@@ -104058,7 +104561,7 @@ ${l}
|
|
|
104058
104561
|
},
|
|
104059
104562
|
addPmPlugins() {
|
|
104060
104563
|
return [
|
|
104061
|
-
wrapTextInRunsPlugin(),
|
|
104564
|
+
wrapTextInRunsPlugin(this.editor),
|
|
104062
104565
|
splitRunsAfterMarkPlugin,
|
|
104063
104566
|
calculateInlineRunPropertiesPlugin(this.editor),
|
|
104064
104567
|
cleanupEmptyRunsPlugin
|
|
@@ -143192,7 +143695,7 @@ ${reason}`);
|
|
|
143192
143695
|
this.config.colors = shuffleArray(this.config.colors);
|
|
143193
143696
|
this.userColorMap = /* @__PURE__ */ new Map();
|
|
143194
143697
|
this.colorIndex = 0;
|
|
143195
|
-
this.version = "1.3.0-next.
|
|
143698
|
+
this.version = "1.3.0-next.4";
|
|
143196
143699
|
this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
|
|
143197
143700
|
this.superdocId = config2.superdocId || v4();
|
|
143198
143701
|
this.colors = this.config.colors;
|