@harbour-enterprises/superdoc 1.3.0-next.1 → 1.3.0-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{PdfViewer-BAoRLNIo.cjs → PdfViewer-D6XxSIuw.cjs} +2 -2
- package/dist/chunks/{PdfViewer-CkOzQzPk.es.js → PdfViewer-ltwzoe73.es.js} +2 -2
- package/dist/chunks/{SuperConverter-BXP6NikG.es.js → SuperConverter-CVOKZex3.es.js} +294 -192
- package/dist/chunks/{SuperConverter-Dy0-KTCc.cjs → SuperConverter-XGlv5pME.cjs} +261 -159
- package/dist/chunks/{index-BNpbdx2a.cjs → index-D0lYfjMI.cjs} +853 -525
- package/dist/chunks/{index-BbvMtiJY.cjs → index-HQW67fDU.cjs} +4 -4
- package/dist/chunks/{index-wwGlJ58Z.es.js → index-M8MvGhiF.es.js} +853 -525
- package/dist/chunks/{index-C31VY_46.es.js → index-e6096-IC.es.js} +4 -4
- package/dist/super-editor/converter.cjs +1 -1
- package/dist/super-editor/converter.es.js +1 -1
- package/dist/super-editor.cjs +2 -2
- package/dist/super-editor.es.js +3 -3
- package/dist/superdoc.cjs +3 -3
- package/dist/superdoc.es.js +3 -3
- package/dist/superdoc.umd.js +1117 -691
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { B as Buffer$2 } from "./jszip-B1fkPkPJ.es.js";
|
|
2
2
|
import { t as twipsToInches, i as inchesToTwips, p as ptToTwips, l as linesToTwips, a as twipsToLines, b as pixelsToTwips, h as halfPointToPoints, c as twipsToPixels$2, d as convertSizeToCSS, e as inchesToPixels } from "./helpers-C8e9wR5l.es.js";
|
|
3
|
-
import { g as generateDocxRandomId, T as TextSelection$1, o as objectIncludes, w as wrapTextsInRuns, D as DOMParser$1, c as createDocFromMarkdown, a as createDocFromHTML, b as chainableEditorState, d as convertMarkdownToHTML, f as findParentNode, e as findParentNodeClosestToPos, h as generateRandom32BitHex, i as generateRandomSigned32BitIntStrId, P as PluginKey, j as Plugin, M as Mapping, N as NodeSelection, k as Selection, l as Slice, m as DOMSerializer, F as Fragment, n as Mark$1, p as dropPoint, A as AllSelection, q as Schema$1, s as canSplit, t as
|
|
3
|
+
import { g as generateDocxRandomId, T as TextSelection$1, o as objectIncludes, w as wrapTextsInRuns, D as DOMParser$1, c as createDocFromMarkdown, a as createDocFromHTML, b as chainableEditorState, d as convertMarkdownToHTML, f as findParentNode, e as findParentNodeClosestToPos, h as generateRandom32BitHex, i as generateRandomSigned32BitIntStrId, P as PluginKey, j as Plugin, M as Mapping, N as NodeSelection, k as Selection, l as Slice, m as DOMSerializer, F as Fragment, n as Mark$1, p as dropPoint, A as AllSelection, q as Schema$1, s as canSplit, t as resolveRunProperties, u as encodeMarksFromRPr, v as liftTarget, x as canJoin, y as joinPoint, z as replaceStep$1, R as ReplaceAroundStep$1, B as htmlHandler, C as ReplaceStep, E as getResolvedParagraphProperties, G as changeListLevel, H as isList$1, I as updateNumberingProperties, L as ListHelpers, J as inputRulesPlugin, K as TrackDeleteMarkName$1, O as TrackInsertMarkName$1, Q as TrackFormatMarkName$1, U as AddMarkStep, V as RemoveMarkStep, W as CommandService, S as SuperConverter, X as EditorState, Y as unflattenListsInHtml, Z as SelectionRange, _ as Transform, $ as createOoxmlResolver, a0 as translator, a1 as translator$1, a2 as resolveDocxFontFamily, a3 as _getReferencedTableStyles, a4 as decodeRPrFromMarks, a5 as calculateResolvedParagraphProperties, a6 as encodeCSSFromPPr, a7 as encodeCSSFromRPr, a8 as generateOrderedListIndex, a9 as docxNumberingHelpers, aa as InputRule, ab as insertNewRelationship, ac as kebabCase$1, ad as getUnderlineCssString } from "./SuperConverter-CVOKZex3.es.js";
|
|
4
4
|
import { p as process$1, r as ref, C as global$1, c as computed, E as createElementBlock, F as Fragment$1, S as renderList, O as withModifiers, G as openBlock, P as normalizeClass, M as createCommentVNode, H as toDisplayString, K as createBaseVNode, U as createApp, f as onMounted, X as onUnmounted, R as withDirectives, v as unref, Y as vModelText, y as nextTick, L as normalizeStyle, u as watch, Z as withKeys, _ as createTextVNode, I as createVNode, h, $ as readonly, s as getCurrentInstance, o as onBeforeUnmount, j as reactive, b as onBeforeMount, i as inject, a0 as onActivated, a1 as onDeactivated, a2 as Comment, d as defineComponent, a as provide, g as Teleport, t as toRef, a3 as renderSlot, a4 as isVNode, D as shallowRef, w as watchEffect, T as Transition, a5 as mergeProps, a6 as vShow, a7 as cloneVNode, a8 as Text$2, m as markRaw, N as createBlock, J as withCtx, a9 as useCssVars, V as resolveDynamicComponent, aa as normalizeProps, ab as guardReactiveProps } from "./vue-BnBKJwCW.es.js";
|
|
5
5
|
import "./jszip.min-DCl8qkFO.es.js";
|
|
6
6
|
import { E as EventEmitter$1 } from "./eventemitter3-CwrdEv8r.es.js";
|
|
@@ -158,6 +158,354 @@ function parseSizeUnit(val = "0") {
|
|
|
158
158
|
function minMax(value = 0, min2 = 0, max2 = 0) {
|
|
159
159
|
return Math.min(Math.max(value, min2), max2);
|
|
160
160
|
}
|
|
161
|
+
const FONT_FAMILY_FALLBACKS = Object.freeze({
|
|
162
|
+
swiss: "Arial, sans-serif",
|
|
163
|
+
roman: "Times New Roman, serif",
|
|
164
|
+
modern: "Courier New, monospace",
|
|
165
|
+
script: "cursive",
|
|
166
|
+
decorative: "fantasy",
|
|
167
|
+
system: "system-ui",
|
|
168
|
+
auto: "sans-serif"
|
|
169
|
+
});
|
|
170
|
+
const DEFAULT_GENERIC_FALLBACK = "sans-serif";
|
|
171
|
+
const normalizeParts = (value) => (value || "").split(",").map((part) => part.trim()).filter(Boolean);
|
|
172
|
+
function mapWordFamilyFallback(wordFamily) {
|
|
173
|
+
if (!wordFamily) return DEFAULT_GENERIC_FALLBACK;
|
|
174
|
+
const mapped = FONT_FAMILY_FALLBACKS[wordFamily.toLowerCase()];
|
|
175
|
+
return mapped || DEFAULT_GENERIC_FALLBACK;
|
|
176
|
+
}
|
|
177
|
+
function toCssFontFamily(fontName, options = {}) {
|
|
178
|
+
if (!fontName || typeof fontName !== "string") return fontName;
|
|
179
|
+
const trimmed = fontName.trim();
|
|
180
|
+
if (!trimmed || trimmed.includes(",")) return trimmed;
|
|
181
|
+
const { fallback, wordFamily } = options;
|
|
182
|
+
const fallbackValue = fallback ?? (wordFamily ? mapWordFamilyFallback(wordFamily) : void 0) ?? DEFAULT_GENERIC_FALLBACK;
|
|
183
|
+
const fallbackParts = normalizeParts(fallbackValue);
|
|
184
|
+
if (fallbackParts.length === 0) {
|
|
185
|
+
return trimmed;
|
|
186
|
+
}
|
|
187
|
+
const normalizedName = trimmed.toLowerCase();
|
|
188
|
+
const includesName = fallbackParts.some((part) => part.toLowerCase() === normalizedName);
|
|
189
|
+
if (includesName) {
|
|
190
|
+
return fallbackParts.join(", ");
|
|
191
|
+
}
|
|
192
|
+
return [trimmed, ...fallbackParts].join(", ");
|
|
193
|
+
}
|
|
194
|
+
const sdtMetadataCache = /* @__PURE__ */ new Map();
|
|
195
|
+
function resolveStyle(node, context, options = {}) {
|
|
196
|
+
let paragraph = createDefaultParagraph();
|
|
197
|
+
let character = createDefaultCharacter(context);
|
|
198
|
+
let numbering;
|
|
199
|
+
const chain = resolveStyleChain(node.styleId, context.styles);
|
|
200
|
+
for (const style2 of chain) {
|
|
201
|
+
paragraph = mergeParagraph(paragraph, style2.paragraph);
|
|
202
|
+
character = mergeCharacter(character, style2.character);
|
|
203
|
+
if (!numbering && style2.numbering) {
|
|
204
|
+
numbering = resolveNumbering(style2.numbering.numId, style2.numbering.level, context);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
paragraph = mergeParagraph(paragraph, node.paragraphProps);
|
|
208
|
+
character = mergeCharacter(character, node.characterProps);
|
|
209
|
+
if (node.numbering) {
|
|
210
|
+
numbering = resolveNumbering(node.numbering.numId, node.numbering.level, context);
|
|
211
|
+
}
|
|
212
|
+
const sdt = options?.sdt ? resolveSdtMetadata(options.sdt) : void 0;
|
|
213
|
+
return {
|
|
214
|
+
paragraph,
|
|
215
|
+
character,
|
|
216
|
+
numbering,
|
|
217
|
+
sdt
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
function resolveNumbering(numId, level, context) {
|
|
221
|
+
const def = context.numbering?.[numId];
|
|
222
|
+
if (!def) return void 0;
|
|
223
|
+
const levelDef = def.levels.find((entry) => entry.level === level) ?? def.levels[level];
|
|
224
|
+
if (!levelDef) return void 0;
|
|
225
|
+
return {
|
|
226
|
+
numId,
|
|
227
|
+
level,
|
|
228
|
+
indent: {
|
|
229
|
+
left: levelDef.indent?.left,
|
|
230
|
+
hanging: levelDef.indent?.hanging
|
|
231
|
+
},
|
|
232
|
+
format: levelDef.format ?? "decimal",
|
|
233
|
+
text: levelDef.text ?? "%1.",
|
|
234
|
+
start: levelDef.start ?? 1
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
function resolveSdtMetadata(input) {
|
|
238
|
+
if (!input) return void 0;
|
|
239
|
+
const { nodeType, attrs, cacheKey: explicitKey } = input;
|
|
240
|
+
if (!nodeType) return void 0;
|
|
241
|
+
const normalizedAttrs = isPlainObject$4(attrs) ? attrs : {};
|
|
242
|
+
const cacheKey = buildSdtCacheKey(nodeType, normalizedAttrs, explicitKey);
|
|
243
|
+
if (cacheKey && sdtMetadataCache.has(cacheKey)) {
|
|
244
|
+
return sdtMetadataCache.get(cacheKey);
|
|
245
|
+
}
|
|
246
|
+
let metadata;
|
|
247
|
+
switch (nodeType) {
|
|
248
|
+
case "fieldAnnotation":
|
|
249
|
+
metadata = normalizeFieldAnnotationMetadata(normalizedAttrs);
|
|
250
|
+
break;
|
|
251
|
+
case "structuredContent":
|
|
252
|
+
case "structuredContentBlock":
|
|
253
|
+
metadata = normalizeStructuredContentMetadata(nodeType, normalizedAttrs);
|
|
254
|
+
break;
|
|
255
|
+
case "documentSection":
|
|
256
|
+
metadata = normalizeDocumentSectionMetadata(normalizedAttrs);
|
|
257
|
+
break;
|
|
258
|
+
case "docPartObject":
|
|
259
|
+
metadata = normalizeDocPartMetadata(normalizedAttrs);
|
|
260
|
+
break;
|
|
261
|
+
}
|
|
262
|
+
if (metadata && cacheKey) {
|
|
263
|
+
sdtMetadataCache.set(cacheKey, metadata);
|
|
264
|
+
}
|
|
265
|
+
return metadata;
|
|
266
|
+
}
|
|
267
|
+
function createDefaultParagraph(_context) {
|
|
268
|
+
return {
|
|
269
|
+
alignment: "left",
|
|
270
|
+
spacing: {
|
|
271
|
+
before: 0,
|
|
272
|
+
after: 0,
|
|
273
|
+
line: 12,
|
|
274
|
+
lineRule: "auto"
|
|
275
|
+
},
|
|
276
|
+
indent: {
|
|
277
|
+
left: 0,
|
|
278
|
+
right: 0,
|
|
279
|
+
firstLine: 0,
|
|
280
|
+
hanging: 0
|
|
281
|
+
},
|
|
282
|
+
tabs: []
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
function createDefaultCharacter(context) {
|
|
286
|
+
const baseFont = context.defaults?.paragraphFont ?? "Calibri";
|
|
287
|
+
const fallback = context.defaults?.paragraphFontFallback;
|
|
288
|
+
const wordFamily = context.defaults?.paragraphFontFamily;
|
|
289
|
+
const resolvedFamily = toCssFontFamily(baseFont, { fallback, wordFamily }) ?? baseFont;
|
|
290
|
+
return {
|
|
291
|
+
font: {
|
|
292
|
+
family: resolvedFamily,
|
|
293
|
+
size: context.defaults?.fontSize ?? 11,
|
|
294
|
+
weight: 400,
|
|
295
|
+
italic: false
|
|
296
|
+
},
|
|
297
|
+
color: "#000000"
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
function resolveStyleChain(styleId, styles) {
|
|
301
|
+
if (!styleId || !styles) return [];
|
|
302
|
+
const result = [];
|
|
303
|
+
const visited = /* @__PURE__ */ new Set();
|
|
304
|
+
let current = styles[styleId];
|
|
305
|
+
while (current && !visited.has(current.id)) {
|
|
306
|
+
result.unshift(current);
|
|
307
|
+
visited.add(current.id);
|
|
308
|
+
current = current.basedOn ? styles[current.basedOn] : void 0;
|
|
309
|
+
}
|
|
310
|
+
return result;
|
|
311
|
+
}
|
|
312
|
+
function mergeParagraph(base2, overrides) {
|
|
313
|
+
if (!overrides) return base2;
|
|
314
|
+
return {
|
|
315
|
+
...base2,
|
|
316
|
+
alignment: overrides.alignment ?? base2.alignment,
|
|
317
|
+
spacing: overrides.spacing ? { ...base2.spacing, ...overrides.spacing } : base2.spacing,
|
|
318
|
+
indent: overrides.indent ? { ...base2.indent, ...overrides.indent } : base2.indent,
|
|
319
|
+
borders: overrides.borders ? { ...base2.borders, ...overrides.borders } : base2.borders,
|
|
320
|
+
shading: overrides.shading ?? base2.shading,
|
|
321
|
+
tabs: overrides.tabs ?? base2.tabs
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
function mergeCharacter(base2, overrides) {
|
|
325
|
+
if (!overrides) return base2;
|
|
326
|
+
return {
|
|
327
|
+
...base2,
|
|
328
|
+
font: overrides.font ? { ...base2.font, ...overrides.font } : base2.font,
|
|
329
|
+
color: overrides.color ?? base2.color,
|
|
330
|
+
underline: overrides.underline ?? base2.underline,
|
|
331
|
+
strike: overrides.strike ?? base2.strike,
|
|
332
|
+
highlight: overrides.highlight ?? base2.highlight,
|
|
333
|
+
letterSpacing: overrides.letterSpacing ?? base2.letterSpacing
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
function normalizeFieldAnnotationMetadata(attrs) {
|
|
337
|
+
const fieldId = toOptionalString(attrs.fieldId) ?? "";
|
|
338
|
+
const formatting = extractFormatting(attrs);
|
|
339
|
+
const size2 = normalizeSize(attrs.size);
|
|
340
|
+
const extras = isPlainObject$4(attrs.extras) ? attrs.extras : null;
|
|
341
|
+
const marks = isPlainObject$4(attrs.marks) ? attrs.marks : void 0;
|
|
342
|
+
return {
|
|
343
|
+
type: "fieldAnnotation",
|
|
344
|
+
fieldId,
|
|
345
|
+
variant: normalizeFieldAnnotationVariant(attrs.type),
|
|
346
|
+
fieldType: toOptionalString(attrs.fieldType),
|
|
347
|
+
displayLabel: toOptionalString(attrs.displayLabel),
|
|
348
|
+
defaultDisplayLabel: toOptionalString(attrs.defaultDisplayLabel),
|
|
349
|
+
alias: toOptionalString(attrs.alias),
|
|
350
|
+
fieldColor: normalizeColorValue(attrs.fieldColor),
|
|
351
|
+
borderColor: normalizeColorValue(attrs.borderColor),
|
|
352
|
+
highlighted: toBoolean$3(attrs.highlighted, true),
|
|
353
|
+
fontFamily: toNullableString(attrs.fontFamily),
|
|
354
|
+
fontSize: normalizeFontSize(attrs.fontSize),
|
|
355
|
+
textColor: normalizeColorValue(attrs.textColor) ?? null,
|
|
356
|
+
textHighlight: normalizeColorValue(attrs.textHighlight) ?? null,
|
|
357
|
+
linkUrl: toNullableString(attrs.linkUrl),
|
|
358
|
+
imageSrc: toNullableString(attrs.imageSrc),
|
|
359
|
+
rawHtml: attrs.rawHtml ?? void 0,
|
|
360
|
+
size: size2 ?? null,
|
|
361
|
+
extras,
|
|
362
|
+
multipleImage: toBoolean$3(attrs.multipleImage, false),
|
|
363
|
+
hash: toOptionalString(attrs.hash) ?? null,
|
|
364
|
+
generatorIndex: toNumber(attrs.generatorIndex),
|
|
365
|
+
sdtId: toOptionalString(attrs.sdtId) ?? null,
|
|
366
|
+
hidden: toBoolean$3(attrs.hidden, false),
|
|
367
|
+
visibility: normalizeVisibility(attrs.visibility),
|
|
368
|
+
isLocked: toBoolean$3(attrs.isLocked, false),
|
|
369
|
+
formatting,
|
|
370
|
+
marks
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
function normalizeStructuredContentMetadata(nodeType, attrs) {
|
|
374
|
+
return {
|
|
375
|
+
type: "structuredContent",
|
|
376
|
+
scope: nodeType === "structuredContentBlock" ? "block" : "inline",
|
|
377
|
+
id: toNullableString(attrs.id),
|
|
378
|
+
tag: toOptionalString(attrs.tag),
|
|
379
|
+
alias: toOptionalString(attrs.alias),
|
|
380
|
+
sdtPr: attrs.sdtPr
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
function normalizeDocumentSectionMetadata(attrs) {
|
|
384
|
+
return {
|
|
385
|
+
type: "documentSection",
|
|
386
|
+
id: toNullableString(attrs.id),
|
|
387
|
+
title: toOptionalString(attrs.title) ?? null,
|
|
388
|
+
description: toOptionalString(attrs.description) ?? null,
|
|
389
|
+
sectionType: toOptionalString(attrs.sectionType) ?? null,
|
|
390
|
+
isLocked: toBoolean$3(attrs.isLocked, false),
|
|
391
|
+
sdBlockId: toNullableString(attrs.sdBlockId)
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
function normalizeDocPartMetadata(attrs) {
|
|
395
|
+
return {
|
|
396
|
+
type: "docPartObject",
|
|
397
|
+
gallery: toOptionalString(attrs.docPartGallery ?? attrs.gallery) ?? null,
|
|
398
|
+
// Source uniqueId from attrs.id (PM adapter uses getDocPartObjectId which extracts attrs.id)
|
|
399
|
+
// Fall back to attrs.uniqueId for compatibility
|
|
400
|
+
uniqueId: toOptionalString(attrs.id ?? attrs.uniqueId) ?? null,
|
|
401
|
+
alias: toOptionalString(attrs.alias) ?? null,
|
|
402
|
+
instruction: toOptionalString(attrs.instruction) ?? null
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
function isPlainObject$4(value) {
|
|
406
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
407
|
+
}
|
|
408
|
+
function toOptionalString(value) {
|
|
409
|
+
if (value == null) return void 0;
|
|
410
|
+
if (typeof value === "string") {
|
|
411
|
+
const trimmed = value.trim();
|
|
412
|
+
return trimmed.length ? trimmed : void 0;
|
|
413
|
+
}
|
|
414
|
+
return String(value);
|
|
415
|
+
}
|
|
416
|
+
function toNullableString(value) {
|
|
417
|
+
const str = toOptionalString(value);
|
|
418
|
+
return str ?? null;
|
|
419
|
+
}
|
|
420
|
+
function toBoolean$3(value, fallback) {
|
|
421
|
+
if (typeof value === "boolean") return value;
|
|
422
|
+
if (typeof value === "string") {
|
|
423
|
+
const lower = value.toLowerCase();
|
|
424
|
+
if (lower === "true") return true;
|
|
425
|
+
if (lower === "false") return false;
|
|
426
|
+
}
|
|
427
|
+
if (value == null) return fallback;
|
|
428
|
+
return Boolean(value);
|
|
429
|
+
}
|
|
430
|
+
function normalizeVisibility(value) {
|
|
431
|
+
if (typeof value !== "string") return void 0;
|
|
432
|
+
const normalized = value.toLowerCase();
|
|
433
|
+
if (normalized === "visible" || normalized === "hidden") {
|
|
434
|
+
return normalized;
|
|
435
|
+
}
|
|
436
|
+
return void 0;
|
|
437
|
+
}
|
|
438
|
+
function normalizeColorValue(value) {
|
|
439
|
+
if (typeof value !== "string") return void 0;
|
|
440
|
+
const trimmed = value.trim();
|
|
441
|
+
if (!trimmed || trimmed.toLowerCase() === "none") return void 0;
|
|
442
|
+
return trimmed;
|
|
443
|
+
}
|
|
444
|
+
function normalizeFontSize(value) {
|
|
445
|
+
if (value == null) return null;
|
|
446
|
+
if (typeof value === "number") {
|
|
447
|
+
return Number.isFinite(value) ? value : null;
|
|
448
|
+
}
|
|
449
|
+
if (typeof value === "string") {
|
|
450
|
+
const trimmed = value.trim();
|
|
451
|
+
return trimmed.length ? trimmed : null;
|
|
452
|
+
}
|
|
453
|
+
return null;
|
|
454
|
+
}
|
|
455
|
+
function toNumber(value) {
|
|
456
|
+
if (typeof value === "number") {
|
|
457
|
+
return Number.isFinite(value) ? value : null;
|
|
458
|
+
}
|
|
459
|
+
if (typeof value === "string") {
|
|
460
|
+
const parsed = parseFloat(value);
|
|
461
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
462
|
+
}
|
|
463
|
+
return null;
|
|
464
|
+
}
|
|
465
|
+
function normalizeSize(value) {
|
|
466
|
+
if (!isPlainObject$4(value)) return null;
|
|
467
|
+
const obj = value;
|
|
468
|
+
const width = toNumber(obj.width);
|
|
469
|
+
const height = toNumber(obj.height);
|
|
470
|
+
if (width == null && height == null) return null;
|
|
471
|
+
const result = {};
|
|
472
|
+
if (width != null) result.width = width;
|
|
473
|
+
if (height != null) result.height = height;
|
|
474
|
+
return result;
|
|
475
|
+
}
|
|
476
|
+
function normalizeFieldAnnotationVariant(value) {
|
|
477
|
+
if (typeof value !== "string") return void 0;
|
|
478
|
+
const normalized = value.toLowerCase();
|
|
479
|
+
if (normalized === "text" || normalized === "image" || normalized === "signature" || normalized === "checkbox" || normalized === "html" || normalized === "link") {
|
|
480
|
+
return normalized;
|
|
481
|
+
}
|
|
482
|
+
return void 0;
|
|
483
|
+
}
|
|
484
|
+
function extractFormatting(attrs) {
|
|
485
|
+
const bold = toBoolean$3(attrs.bold, false);
|
|
486
|
+
const italic = toBoolean$3(attrs.italic, false);
|
|
487
|
+
const underline = toBoolean$3(attrs.underline, false);
|
|
488
|
+
const formatting = {};
|
|
489
|
+
if (bold) formatting.bold = true;
|
|
490
|
+
if (italic) formatting.italic = true;
|
|
491
|
+
if (underline) formatting.underline = true;
|
|
492
|
+
return Object.keys(formatting).length ? formatting : void 0;
|
|
493
|
+
}
|
|
494
|
+
function buildSdtCacheKey(nodeType, attrs, explicitKey) {
|
|
495
|
+
const provided = toOptionalString(explicitKey);
|
|
496
|
+
if (provided) {
|
|
497
|
+
return `${nodeType}:${provided}`;
|
|
498
|
+
}
|
|
499
|
+
const hash2 = toOptionalString(attrs.hash);
|
|
500
|
+
if (hash2) {
|
|
501
|
+
return `${nodeType}:${hash2}`;
|
|
502
|
+
}
|
|
503
|
+
const id = toOptionalString(attrs.id);
|
|
504
|
+
if (id) {
|
|
505
|
+
return `${nodeType}:${id}`;
|
|
506
|
+
}
|
|
507
|
+
return void 0;
|
|
508
|
+
}
|
|
161
509
|
function createDocument(converter, schema, editor, { check = false } = {}) {
|
|
162
510
|
const documentData = converter.getSchema(editor);
|
|
163
511
|
if (documentData) {
|
|
@@ -9091,15 +9439,19 @@ const splitRunToParagraph = () => (props) => {
|
|
|
9091
9439
|
dispatchTransaction = editor.dispatch.bind(editor);
|
|
9092
9440
|
}
|
|
9093
9441
|
if (!dispatchTransaction) return false;
|
|
9094
|
-
const handled = splitBlockPatch(
|
|
9095
|
-
|
|
9096
|
-
|
|
9442
|
+
const handled = splitBlockPatch(
|
|
9443
|
+
state,
|
|
9444
|
+
(transaction) => {
|
|
9445
|
+
dispatchTransaction(transaction);
|
|
9446
|
+
},
|
|
9447
|
+
editor
|
|
9448
|
+
);
|
|
9097
9449
|
if (handled) {
|
|
9098
9450
|
tr.setMeta("preventDispatch", true);
|
|
9099
9451
|
}
|
|
9100
9452
|
return handled;
|
|
9101
9453
|
};
|
|
9102
|
-
function splitBlockPatch(state, dispatch) {
|
|
9454
|
+
function splitBlockPatch(state, dispatch, editor) {
|
|
9103
9455
|
let { $from } = state.selection;
|
|
9104
9456
|
if (state.selection instanceof NodeSelection && state.selection.node.isBlock) {
|
|
9105
9457
|
if (!$from.parentOffset || !canSplit(state.doc, $from.pos)) return false;
|
|
@@ -9108,14 +9460,15 @@ function splitBlockPatch(state, dispatch) {
|
|
|
9108
9460
|
}
|
|
9109
9461
|
if (!$from.depth) return false;
|
|
9110
9462
|
let types = [];
|
|
9111
|
-
let splitDepth, deflt, atEnd = false, atStart = false;
|
|
9463
|
+
let splitDepth, deflt, paragraphAttrs = null, atEnd = false, atStart = false;
|
|
9112
9464
|
for (let d2 = $from.depth; ; d2--) {
|
|
9113
9465
|
let node = $from.node(d2);
|
|
9114
9466
|
if (node.isBlock) {
|
|
9115
9467
|
atEnd = $from.end(d2) == $from.pos + ($from.depth - d2);
|
|
9116
9468
|
atStart = $from.start(d2) == $from.pos - ($from.depth - d2);
|
|
9117
9469
|
deflt = defaultBlockAt$1($from.node(d2 - 1).contentMatchAt($from.indexAfter(d2 - 1)));
|
|
9118
|
-
|
|
9470
|
+
paragraphAttrs = { ...node.attrs };
|
|
9471
|
+
types.unshift({ type: deflt || node.type, attrs: paragraphAttrs });
|
|
9119
9472
|
splitDepth = d2;
|
|
9120
9473
|
break;
|
|
9121
9474
|
} else {
|
|
@@ -9128,7 +9481,7 @@ function splitBlockPatch(state, dispatch) {
|
|
|
9128
9481
|
let splitPos = tr.mapping.map($from.pos);
|
|
9129
9482
|
let can = canSplit(tr.doc, splitPos, types.length, types);
|
|
9130
9483
|
if (!can) {
|
|
9131
|
-
types[0] = deflt ? { type: deflt } : null;
|
|
9484
|
+
types[0] = deflt ? { type: deflt, attrs: paragraphAttrs } : null;
|
|
9132
9485
|
can = canSplit(tr.doc, splitPos, types.length, types);
|
|
9133
9486
|
}
|
|
9134
9487
|
if (!can) return false;
|
|
@@ -9138,9 +9491,37 @@ function splitBlockPatch(state, dispatch) {
|
|
|
9138
9491
|
if (deflt && $from.node(splitDepth - 1).canReplaceWith($first.index(), $first.index() + 1, deflt))
|
|
9139
9492
|
tr.setNodeMarkup(tr.mapping.map($from.before(splitDepth)), deflt);
|
|
9140
9493
|
}
|
|
9494
|
+
applyStyleMarks(state, tr, editor, paragraphAttrs);
|
|
9141
9495
|
if (dispatch) dispatch(tr.scrollIntoView());
|
|
9142
9496
|
return true;
|
|
9143
9497
|
}
|
|
9498
|
+
function applyStyleMarks(state, tr, editor, paragraphAttrs) {
|
|
9499
|
+
const styleId = paragraphAttrs?.paragraphProperties?.styleId;
|
|
9500
|
+
if (!editor?.converter && !styleId) {
|
|
9501
|
+
return;
|
|
9502
|
+
}
|
|
9503
|
+
try {
|
|
9504
|
+
const params2 = { docx: editor?.converter?.convertedXml ?? {}, numbering: editor?.converter?.numbering ?? {} };
|
|
9505
|
+
const resolvedPpr = styleId ? { styleId } : {};
|
|
9506
|
+
const runProperties = styleId ? resolveRunProperties(params2, {}, resolvedPpr, false, false) : {};
|
|
9507
|
+
const markDefsFromStyle = styleId ? (
|
|
9508
|
+
/** @type {Array<{type: string, attrs: Record<string, unknown>}>} */
|
|
9509
|
+
encodeMarksFromRPr(runProperties, editor?.converter?.convertedXml ?? {})
|
|
9510
|
+
) : [];
|
|
9511
|
+
const selectionMarks = state.selection?.$from?.marks ? state.selection.$from.marks() : [];
|
|
9512
|
+
const selectionMarkDefs = selectionMarks.map((mark) => ({ type: mark.type.name, attrs: mark.attrs }));
|
|
9513
|
+
const markDefsToApply = selectionMarks.length ? selectionMarkDefs : markDefsFromStyle;
|
|
9514
|
+
const marksToApply = markDefsToApply.map((def) => {
|
|
9515
|
+
const markType = state.schema.marks[def.type];
|
|
9516
|
+
return markType ? markType.create(def.attrs) : null;
|
|
9517
|
+
}).filter(Boolean);
|
|
9518
|
+
if (marksToApply.length > 0) {
|
|
9519
|
+
tr.ensureMarks(marksToApply);
|
|
9520
|
+
tr.setMeta("sdStyleMarks", markDefsToApply);
|
|
9521
|
+
}
|
|
9522
|
+
} catch {
|
|
9523
|
+
}
|
|
9524
|
+
}
|
|
9144
9525
|
const splitRunAtCursor = () => (props) => {
|
|
9145
9526
|
let { state, dispatch, tr } = props;
|
|
9146
9527
|
const sel = state.selection;
|
|
@@ -10024,7 +10405,7 @@ const updateAttributes = (typeOrName, attrs = {}) => ({ tr, state, dispatch }) =
|
|
|
10024
10405
|
}
|
|
10025
10406
|
return true;
|
|
10026
10407
|
};
|
|
10027
|
-
const isPlainObject$
|
|
10408
|
+
const isPlainObject$3 = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
10028
10409
|
const assignNestedValue = (target, path, value) => {
|
|
10029
10410
|
if (!path.includes(".")) {
|
|
10030
10411
|
target[path] = value;
|
|
@@ -10038,7 +10419,7 @@ const assignNestedValue = (target, path, value) => {
|
|
|
10038
10419
|
if (isLast) {
|
|
10039
10420
|
current[part] = value;
|
|
10040
10421
|
} else {
|
|
10041
|
-
if (!isPlainObject$
|
|
10422
|
+
if (!isPlainObject$3(current[part])) {
|
|
10042
10423
|
current[part] = {};
|
|
10043
10424
|
}
|
|
10044
10425
|
current = current[part];
|
|
@@ -14898,7 +15279,7 @@ const canUseDOM = () => {
|
|
|
14898
15279
|
return false;
|
|
14899
15280
|
}
|
|
14900
15281
|
};
|
|
14901
|
-
const summaryVersion = "1.3.0-next.
|
|
15282
|
+
const summaryVersion = "1.3.0-next.3";
|
|
14902
15283
|
const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
|
|
14903
15284
|
const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
|
|
14904
15285
|
function mapAttributes(attrs) {
|
|
@@ -17531,7 +17912,7 @@ class Editor extends EventEmitter {
|
|
|
17531
17912
|
* Process collaboration migrations
|
|
17532
17913
|
*/
|
|
17533
17914
|
processCollaborationMigrations() {
|
|
17534
|
-
console.debug("[checkVersionMigrations] Current editor version", "1.3.0-next.
|
|
17915
|
+
console.debug("[checkVersionMigrations] Current editor version", "1.3.0-next.3");
|
|
17535
17916
|
if (!this.options.ydoc) return;
|
|
17536
17917
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
17537
17918
|
let docVersion = metaMap.get("version");
|
|
@@ -19951,18 +20332,18 @@ function formatNumber(num, format) {
|
|
|
19951
20332
|
case "decimal":
|
|
19952
20333
|
return num.toString();
|
|
19953
20334
|
case "lowerLetter":
|
|
19954
|
-
return toLetter
|
|
20335
|
+
return toLetter(num, false);
|
|
19955
20336
|
case "upperLetter":
|
|
19956
|
-
return toLetter
|
|
20337
|
+
return toLetter(num, true);
|
|
19957
20338
|
case "lowerRoman":
|
|
19958
|
-
return toRoman$
|
|
20339
|
+
return toRoman$1(num).toLowerCase();
|
|
19959
20340
|
case "upperRoman":
|
|
19960
|
-
return toRoman$
|
|
20341
|
+
return toRoman$1(num);
|
|
19961
20342
|
default:
|
|
19962
20343
|
return num.toString();
|
|
19963
20344
|
}
|
|
19964
20345
|
}
|
|
19965
|
-
function toLetter
|
|
20346
|
+
function toLetter(num, uppercase) {
|
|
19966
20347
|
let result = "";
|
|
19967
20348
|
let n = num;
|
|
19968
20349
|
while (n > 0) {
|
|
@@ -19973,7 +20354,7 @@ function toLetter$1(num, uppercase) {
|
|
|
19973
20354
|
}
|
|
19974
20355
|
return result || (uppercase ? "A" : "a");
|
|
19975
20356
|
}
|
|
19976
|
-
function toRoman$
|
|
20357
|
+
function toRoman$1(num) {
|
|
19977
20358
|
const lookup = [
|
|
19978
20359
|
[1e3, "M"],
|
|
19979
20360
|
[900, "CM"],
|
|
@@ -23106,39 +23487,6 @@ const resolveTableCellBorders = (tableBorders, rowIndex, colIndex, totalRows, to
|
|
|
23106
23487
|
right: borderValueToSpec(isLastCol ? tableBorders?.right : null)
|
|
23107
23488
|
};
|
|
23108
23489
|
};
|
|
23109
|
-
const FONT_FAMILY_FALLBACKS = Object.freeze({
|
|
23110
|
-
swiss: "Arial, sans-serif",
|
|
23111
|
-
roman: "Times New Roman, serif",
|
|
23112
|
-
modern: "Courier New, monospace",
|
|
23113
|
-
script: "cursive",
|
|
23114
|
-
decorative: "fantasy",
|
|
23115
|
-
system: "system-ui",
|
|
23116
|
-
auto: "sans-serif"
|
|
23117
|
-
});
|
|
23118
|
-
const DEFAULT_GENERIC_FALLBACK = "sans-serif";
|
|
23119
|
-
const normalizeParts = (value) => (value || "").split(",").map((part) => part.trim()).filter(Boolean);
|
|
23120
|
-
function mapWordFamilyFallback(wordFamily) {
|
|
23121
|
-
if (!wordFamily) return DEFAULT_GENERIC_FALLBACK;
|
|
23122
|
-
const mapped = FONT_FAMILY_FALLBACKS[wordFamily.toLowerCase()];
|
|
23123
|
-
return mapped || DEFAULT_GENERIC_FALLBACK;
|
|
23124
|
-
}
|
|
23125
|
-
function toCssFontFamily(fontName, options = {}) {
|
|
23126
|
-
if (!fontName || typeof fontName !== "string") return fontName;
|
|
23127
|
-
const trimmed = fontName.trim();
|
|
23128
|
-
if (!trimmed || trimmed.includes(",")) return trimmed;
|
|
23129
|
-
const { fallback, wordFamily } = options;
|
|
23130
|
-
const fallbackValue = fallback ?? (wordFamily ? mapWordFamilyFallback(wordFamily) : void 0) ?? DEFAULT_GENERIC_FALLBACK;
|
|
23131
|
-
const fallbackParts = normalizeParts(fallbackValue);
|
|
23132
|
-
if (fallbackParts.length === 0) {
|
|
23133
|
-
return trimmed;
|
|
23134
|
-
}
|
|
23135
|
-
const normalizedName = trimmed.toLowerCase();
|
|
23136
|
-
const includesName = fallbackParts.some((part) => part.toLowerCase() === normalizedName);
|
|
23137
|
-
if (includesName) {
|
|
23138
|
-
return fallbackParts.join(", ");
|
|
23139
|
-
}
|
|
23140
|
-
return [trimmed, ...fallbackParts].join(", ");
|
|
23141
|
-
}
|
|
23142
23490
|
const LIST_MARKER_GAP$3 = 8;
|
|
23143
23491
|
function renderListMarker(params2) {
|
|
23144
23492
|
const { doc: doc2, lineEl, markerLayout, markerMeasure, indentLeftPx } = params2;
|
|
@@ -25375,7 +25723,14 @@ class DomPainter {
|
|
|
25375
25723
|
fragmentEl.dataset.continuesOnNext = "true";
|
|
25376
25724
|
}
|
|
25377
25725
|
const lines = fragment.lines ?? measure.lines.slice(fragment.fromLine, fragment.toLine);
|
|
25378
|
-
applyParagraphBlockStyles(fragmentEl, block.attrs);
|
|
25726
|
+
applyParagraphBlockStyles(fragmentEl, block.attrs, { includeBorders: false, includeShading: false });
|
|
25727
|
+
const { shadingLayer, borderLayer } = createParagraphDecorationLayers(this.doc, fragment.width, block.attrs);
|
|
25728
|
+
if (shadingLayer) {
|
|
25729
|
+
fragmentEl.appendChild(shadingLayer);
|
|
25730
|
+
}
|
|
25731
|
+
if (borderLayer) {
|
|
25732
|
+
fragmentEl.appendChild(borderLayer);
|
|
25733
|
+
}
|
|
25379
25734
|
if (block.attrs?.styleId) {
|
|
25380
25735
|
fragmentEl.dataset.styleId = block.attrs.styleId;
|
|
25381
25736
|
fragmentEl.setAttribute("styleid", block.attrs.styleId);
|
|
@@ -25759,10 +26114,18 @@ class DomPainter {
|
|
|
25759
26114
|
contentEl.classList.add("superdoc-list-content");
|
|
25760
26115
|
this.applySdtDataset(contentEl, paragraphMetadata);
|
|
25761
26116
|
contentEl.style.display = "inline-block";
|
|
26117
|
+
contentEl.style.position = "relative";
|
|
25762
26118
|
contentEl.style.width = `${fragment.width}px`;
|
|
25763
26119
|
const lines = itemMeasure.paragraph.lines.slice(fragment.fromLine, fragment.toLine);
|
|
25764
26120
|
const contentAttrs = wordLayout ? item.paragraph.attrs : stripListIndent(item.paragraph.attrs);
|
|
25765
|
-
applyParagraphBlockStyles(contentEl, contentAttrs);
|
|
26121
|
+
applyParagraphBlockStyles(contentEl, contentAttrs, { includeBorders: false, includeShading: false });
|
|
26122
|
+
const { shadingLayer, borderLayer } = createParagraphDecorationLayers(this.doc, fragment.width, contentAttrs);
|
|
26123
|
+
if (shadingLayer) {
|
|
26124
|
+
contentEl.appendChild(shadingLayer);
|
|
26125
|
+
}
|
|
26126
|
+
if (borderLayer) {
|
|
26127
|
+
contentEl.appendChild(borderLayer);
|
|
26128
|
+
}
|
|
25766
26129
|
contentEl.style.textAlign = "left";
|
|
25767
26130
|
const paraForList = {
|
|
25768
26131
|
...item.paragraph,
|
|
@@ -27989,7 +28352,7 @@ const applyRunDataAttributes = (element, dataAttrs) => {
|
|
|
27989
28352
|
}
|
|
27990
28353
|
});
|
|
27991
28354
|
};
|
|
27992
|
-
const applyParagraphBlockStyles = (element, attrs) => {
|
|
28355
|
+
const applyParagraphBlockStyles = (element, attrs, options = {}) => {
|
|
27993
28356
|
if (!attrs) return;
|
|
27994
28357
|
if (attrs.styleId) {
|
|
27995
28358
|
element.setAttribute("styleid", attrs.styleId);
|
|
@@ -28016,8 +28379,55 @@ const applyParagraphBlockStyles = (element, attrs) => {
|
|
|
28016
28379
|
}
|
|
28017
28380
|
}
|
|
28018
28381
|
}
|
|
28019
|
-
|
|
28020
|
-
|
|
28382
|
+
if (options.includeBorders ?? true) {
|
|
28383
|
+
applyParagraphBorderStyles(element, attrs.borders);
|
|
28384
|
+
}
|
|
28385
|
+
if (options.includeShading ?? true) {
|
|
28386
|
+
applyParagraphShadingStyles(element, attrs.shading);
|
|
28387
|
+
}
|
|
28388
|
+
};
|
|
28389
|
+
const getParagraphBorderBox = (fragmentWidth, indent) => {
|
|
28390
|
+
const indentLeft = Number.isFinite(indent?.left) ? indent.left : 0;
|
|
28391
|
+
const indentRight = Number.isFinite(indent?.right) ? indent.right : 0;
|
|
28392
|
+
const firstLine = Number.isFinite(indent?.firstLine) ? indent.firstLine : 0;
|
|
28393
|
+
const hanging = Number.isFinite(indent?.hanging) ? indent.hanging : 0;
|
|
28394
|
+
const firstLineOffset = firstLine - hanging;
|
|
28395
|
+
const minLeftInset = Math.min(indentLeft, indentLeft + firstLineOffset);
|
|
28396
|
+
const leftInset = Math.max(0, minLeftInset);
|
|
28397
|
+
const rightInset = Math.max(0, indentRight);
|
|
28398
|
+
return {
|
|
28399
|
+
leftInset,
|
|
28400
|
+
width: Math.max(0, fragmentWidth - leftInset - rightInset)
|
|
28401
|
+
};
|
|
28402
|
+
};
|
|
28403
|
+
const createParagraphDecorationLayers = (doc2, fragmentWidth, attrs) => {
|
|
28404
|
+
if (!attrs?.borders && !attrs?.shading) return {};
|
|
28405
|
+
const borderBox = getParagraphBorderBox(fragmentWidth, attrs.indent);
|
|
28406
|
+
const baseStyles = {
|
|
28407
|
+
position: "absolute",
|
|
28408
|
+
top: "0px",
|
|
28409
|
+
bottom: "0px",
|
|
28410
|
+
left: `${borderBox.leftInset}px`,
|
|
28411
|
+
width: `${borderBox.width}px`,
|
|
28412
|
+
pointerEvents: "none",
|
|
28413
|
+
boxSizing: "border-box"
|
|
28414
|
+
};
|
|
28415
|
+
let shadingLayer;
|
|
28416
|
+
if (attrs.shading) {
|
|
28417
|
+
shadingLayer = doc2.createElement("div");
|
|
28418
|
+
shadingLayer.classList.add("superdoc-paragraph-shading");
|
|
28419
|
+
Object.assign(shadingLayer.style, baseStyles);
|
|
28420
|
+
applyParagraphShadingStyles(shadingLayer, attrs.shading);
|
|
28421
|
+
}
|
|
28422
|
+
let borderLayer;
|
|
28423
|
+
if (attrs.borders) {
|
|
28424
|
+
borderLayer = doc2.createElement("div");
|
|
28425
|
+
borderLayer.classList.add("superdoc-paragraph-border");
|
|
28426
|
+
Object.assign(borderLayer.style, baseStyles);
|
|
28427
|
+
borderLayer.style.zIndex = "1";
|
|
28428
|
+
applyParagraphBorderStyles(borderLayer, attrs.borders);
|
|
28429
|
+
}
|
|
28430
|
+
return { shadingLayer, borderLayer };
|
|
28021
28431
|
};
|
|
28022
28432
|
const BORDER_SIDES = ["top", "right", "bottom", "left"];
|
|
28023
28433
|
const applyParagraphBorderStyles = (element, borders) => {
|
|
@@ -31667,33 +32077,13 @@ function computePartialRow(rowIndex, blockRow, measure, availableHeight, fromLin
|
|
|
31667
32077
|
toLineByCell.push(cutLine);
|
|
31668
32078
|
heightByCell.push(cumulativeHeight);
|
|
31669
32079
|
}
|
|
31670
|
-
const allCellsCompleteInFirstPass = toLineByCell.every((cutLine, idx) => {
|
|
31671
|
-
const totalLines = getCellTotalLines(row.cells[idx]);
|
|
31672
|
-
return cutLine >= totalLines;
|
|
31673
|
-
});
|
|
31674
|
-
const lineAdvancements = toLineByCell.map((cutLine, idx) => cutLine - (startLines[idx] || 0));
|
|
31675
|
-
const positiveAdvancements = lineAdvancements.filter((adv) => adv > 0);
|
|
31676
|
-
const minLineAdvancement = positiveAdvancements.length > 0 ? Math.min(...positiveAdvancements) : 0;
|
|
31677
32080
|
let actualPartialHeight = 0;
|
|
31678
32081
|
let maxPaddingTotal = 0;
|
|
31679
32082
|
for (let cellIdx = 0; cellIdx < cellCount; cellIdx++) {
|
|
31680
|
-
const cell = row.cells[cellIdx];
|
|
31681
|
-
const startLine = startLines[cellIdx] || 0;
|
|
31682
|
-
const lines = getCellLines(cell);
|
|
31683
32083
|
const cellPadding = cellPaddings[cellIdx];
|
|
31684
32084
|
const paddingTotal = cellPadding.top + cellPadding.bottom;
|
|
31685
32085
|
maxPaddingTotal = Math.max(maxPaddingTotal, paddingTotal);
|
|
31686
|
-
|
|
31687
|
-
actualPartialHeight = Math.max(actualPartialHeight, heightByCell[cellIdx] + paddingTotal);
|
|
31688
|
-
} else {
|
|
31689
|
-
const targetLine = Math.min(startLine + minLineAdvancement, lines.length);
|
|
31690
|
-
let cumulativeHeight = 0;
|
|
31691
|
-
for (let i = startLine; i < targetLine; i++) {
|
|
31692
|
-
cumulativeHeight += lines[i].lineHeight || 0;
|
|
31693
|
-
}
|
|
31694
|
-
toLineByCell[cellIdx] = targetLine;
|
|
31695
|
-
actualPartialHeight = Math.max(actualPartialHeight, cumulativeHeight + paddingTotal);
|
|
31696
|
-
}
|
|
32086
|
+
actualPartialHeight = Math.max(actualPartialHeight, heightByCell[cellIdx] + paddingTotal);
|
|
31697
32087
|
}
|
|
31698
32088
|
const madeProgress = toLineByCell.some((cutLine, idx) => cutLine > (startLines[idx] || 0));
|
|
31699
32089
|
const isFirstPart = startLines.every((l) => l === 0);
|
|
@@ -32246,7 +32636,7 @@ function toUpperLetter(num) {
|
|
|
32246
32636
|
function toLowerLetter(num) {
|
|
32247
32637
|
return toUpperLetter(num).toLowerCase();
|
|
32248
32638
|
}
|
|
32249
|
-
function formatPageNumber
|
|
32639
|
+
function formatPageNumber(pageNumber, format) {
|
|
32250
32640
|
const num = Math.max(1, pageNumber);
|
|
32251
32641
|
switch (format) {
|
|
32252
32642
|
case "decimal":
|
|
@@ -32259,6 +32649,8 @@ function formatPageNumber$1(pageNumber, format) {
|
|
|
32259
32649
|
return toUpperLetter(num);
|
|
32260
32650
|
case "lowerLetter":
|
|
32261
32651
|
return toLowerLetter(num);
|
|
32652
|
+
case "numberInDash":
|
|
32653
|
+
return `-${num}-`;
|
|
32262
32654
|
default:
|
|
32263
32655
|
return String(num);
|
|
32264
32656
|
}
|
|
@@ -32287,7 +32679,7 @@ function computeDisplayPageNumber(pages, sections) {
|
|
|
32287
32679
|
const sectionMetadata = sectionMap.get(pageSectionIndex);
|
|
32288
32680
|
const format = sectionMetadata?.numbering?.format ?? "decimal";
|
|
32289
32681
|
const displayNumber = runningCounter;
|
|
32290
|
-
const displayText = formatPageNumber
|
|
32682
|
+
const displayText = formatPageNumber(displayNumber, format);
|
|
32291
32683
|
result.push({
|
|
32292
32684
|
physicalPage: page.number,
|
|
32293
32685
|
displayNumber,
|
|
@@ -32422,59 +32814,6 @@ const layoutLog = (...args) => {
|
|
|
32422
32814
|
if (!layoutDebugEnabled$1) return;
|
|
32423
32815
|
console.log(...args);
|
|
32424
32816
|
};
|
|
32425
|
-
function formatPageNumber(num, format) {
|
|
32426
|
-
switch (format) {
|
|
32427
|
-
case "decimal":
|
|
32428
|
-
return String(num);
|
|
32429
|
-
case "lowerLetter":
|
|
32430
|
-
return toLetter(num, false);
|
|
32431
|
-
case "upperLetter":
|
|
32432
|
-
return toLetter(num, true);
|
|
32433
|
-
case "lowerRoman":
|
|
32434
|
-
return toRoman$1(num).toLowerCase();
|
|
32435
|
-
case "upperRoman":
|
|
32436
|
-
return toRoman$1(num);
|
|
32437
|
-
default:
|
|
32438
|
-
return String(num);
|
|
32439
|
-
}
|
|
32440
|
-
}
|
|
32441
|
-
function toLetter(num, uppercase) {
|
|
32442
|
-
let result = "";
|
|
32443
|
-
let n = Math.max(1, Math.floor(num));
|
|
32444
|
-
while (n > 0) {
|
|
32445
|
-
const remainder = (n - 1) % 26;
|
|
32446
|
-
const char = String.fromCharCode((uppercase ? 65 : 97) + remainder);
|
|
32447
|
-
result = char + result;
|
|
32448
|
-
n = Math.floor((n - 1) / 26);
|
|
32449
|
-
}
|
|
32450
|
-
return result;
|
|
32451
|
-
}
|
|
32452
|
-
function toRoman$1(num) {
|
|
32453
|
-
const lookup = [
|
|
32454
|
-
[1e3, "M"],
|
|
32455
|
-
[900, "CM"],
|
|
32456
|
-
[500, "D"],
|
|
32457
|
-
[400, "CD"],
|
|
32458
|
-
[100, "C"],
|
|
32459
|
-
[90, "XC"],
|
|
32460
|
-
[50, "L"],
|
|
32461
|
-
[40, "XL"],
|
|
32462
|
-
[10, "X"],
|
|
32463
|
-
[9, "IX"],
|
|
32464
|
-
[5, "V"],
|
|
32465
|
-
[4, "IV"],
|
|
32466
|
-
[1, "I"]
|
|
32467
|
-
];
|
|
32468
|
-
let result = "";
|
|
32469
|
-
let n = Math.max(1, Math.floor(num));
|
|
32470
|
-
for (const [value, numeral] of lookup) {
|
|
32471
|
-
while (n >= value) {
|
|
32472
|
-
result += numeral;
|
|
32473
|
-
n -= value;
|
|
32474
|
-
}
|
|
32475
|
-
}
|
|
32476
|
-
return result;
|
|
32477
|
-
}
|
|
32478
32817
|
function layoutDocument(blocks, measures, options = {}) {
|
|
32479
32818
|
if (blocks.length !== measures.length) {
|
|
32480
32819
|
throw new Error(
|
|
@@ -33930,7 +34269,7 @@ class MeasureCache {
|
|
|
33930
34269
|
return `${block.id}@${safeWidth}x${safeHeight}:${hash2}`;
|
|
33931
34270
|
}
|
|
33932
34271
|
}
|
|
33933
|
-
function resolveHeaderFooterTokens(blocks, pageNumber, totalPages) {
|
|
34272
|
+
function resolveHeaderFooterTokens(blocks, pageNumber, totalPages, pageNumberText) {
|
|
33934
34273
|
if (!blocks || blocks.length === 0) {
|
|
33935
34274
|
return;
|
|
33936
34275
|
}
|
|
@@ -33942,7 +34281,7 @@ function resolveHeaderFooterTokens(blocks, pageNumber, totalPages) {
|
|
|
33942
34281
|
console.warn("[resolveHeaderFooterTokens] Invalid totalPages:", totalPages, "- using 1 as fallback");
|
|
33943
34282
|
totalPages = 1;
|
|
33944
34283
|
}
|
|
33945
|
-
const pageNumberStr = String(pageNumber);
|
|
34284
|
+
const pageNumberStr = pageNumberText ?? String(pageNumber);
|
|
33946
34285
|
const totalPagesStr = String(totalPages);
|
|
33947
34286
|
for (const block of blocks) {
|
|
33948
34287
|
if (block.kind !== "paragraph") continue;
|
|
@@ -34365,15 +34704,31 @@ async function layoutHeaderFooterWithCache(sections, constraints, measureBlock2,
|
|
|
34365
34704
|
for (const pageNum of pagesToLayout) {
|
|
34366
34705
|
const clonedBlocks = cloneHeaderFooterBlocks(blocks);
|
|
34367
34706
|
const { displayText, totalPages: totalPagesForPage } = pageResolver(pageNum);
|
|
34368
|
-
|
|
34369
|
-
resolveHeaderFooterTokens(clonedBlocks, resolvedPageNum, totalPagesForPage);
|
|
34707
|
+
resolveHeaderFooterTokens(clonedBlocks, pageNum, totalPagesForPage, displayText);
|
|
34370
34708
|
const measures = await cache2.measureBlocks(clonedBlocks, constraints, measureBlock2);
|
|
34371
34709
|
const pageLayout = layoutHeaderFooter(clonedBlocks, measures, constraints);
|
|
34710
|
+
const measuresById = /* @__PURE__ */ new Map();
|
|
34711
|
+
for (let i = 0; i < clonedBlocks.length; i += 1) {
|
|
34712
|
+
measuresById.set(clonedBlocks[i].id, measures[i]);
|
|
34713
|
+
}
|
|
34714
|
+
const fragmentsWithLines = pageLayout.pages[0]?.fragments.map((fragment) => {
|
|
34715
|
+
if (fragment.kind !== "para") {
|
|
34716
|
+
return fragment;
|
|
34717
|
+
}
|
|
34718
|
+
const measure = measuresById.get(fragment.blockId);
|
|
34719
|
+
if (!measure || measure.kind !== "paragraph") {
|
|
34720
|
+
return fragment;
|
|
34721
|
+
}
|
|
34722
|
+
return {
|
|
34723
|
+
...fragment,
|
|
34724
|
+
lines: measure.lines.slice(fragment.fromLine, fragment.toLine)
|
|
34725
|
+
};
|
|
34726
|
+
}) ?? [];
|
|
34372
34727
|
pages.push({
|
|
34373
34728
|
number: pageNum,
|
|
34374
34729
|
blocks: clonedBlocks,
|
|
34375
34730
|
measures,
|
|
34376
|
-
fragments:
|
|
34731
|
+
fragments: fragmentsWithLines
|
|
34377
34732
|
});
|
|
34378
34733
|
}
|
|
34379
34734
|
const firstPageLayout = pages[0] ? layoutHeaderFooter(pages[0].blocks, pages[0].measures, constraints) : { height: 0 };
|
|
@@ -39260,7 +39615,14 @@ function extractPageNumbering(elements) {
|
|
|
39260
39615
|
const pgNumType = elements.find((el) => el?.name === "w:pgNumType");
|
|
39261
39616
|
if (!pgNumType?.attributes) return void 0;
|
|
39262
39617
|
const fmtRaw = pgNumType.attributes["w:fmt"];
|
|
39263
|
-
const validFormats = [
|
|
39618
|
+
const validFormats = [
|
|
39619
|
+
"decimal",
|
|
39620
|
+
"lowerLetter",
|
|
39621
|
+
"upperLetter",
|
|
39622
|
+
"lowerRoman",
|
|
39623
|
+
"upperRoman",
|
|
39624
|
+
"numberInDash"
|
|
39625
|
+
];
|
|
39264
39626
|
const fmt = validFormats.includes(fmtRaw) ? fmtRaw : void 0;
|
|
39265
39627
|
const startRaw = pgNumType.attributes["w:start"];
|
|
39266
39628
|
const startNum = startRaw != null ? Number(startRaw) : void 0;
|
|
@@ -39689,7 +40051,7 @@ const pxToPt = (px) => {
|
|
|
39689
40051
|
return px / PX_PER_PT;
|
|
39690
40052
|
};
|
|
39691
40053
|
const isFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value);
|
|
39692
|
-
const isPlainObject$
|
|
40054
|
+
const isPlainObject$2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
39693
40055
|
const normalizePrefix = (value) => {
|
|
39694
40056
|
if (!value) return "";
|
|
39695
40057
|
return String(value);
|
|
@@ -39751,7 +40113,7 @@ function coerceBoolean(value) {
|
|
|
39751
40113
|
}
|
|
39752
40114
|
return void 0;
|
|
39753
40115
|
}
|
|
39754
|
-
const toBoolean$
|
|
40116
|
+
const toBoolean$2 = (value) => {
|
|
39755
40117
|
if (typeof value === "boolean") return value;
|
|
39756
40118
|
if (typeof value === "string") {
|
|
39757
40119
|
const v = value.trim().toLowerCase();
|
|
@@ -40042,7 +40404,7 @@ function hydrateImageBlocks(blocks, mediaFiles) {
|
|
|
40042
40404
|
});
|
|
40043
40405
|
}
|
|
40044
40406
|
function isGradientFill(value) {
|
|
40045
|
-
if (!isPlainObject$
|
|
40407
|
+
if (!isPlainObject$2(value)) return false;
|
|
40046
40408
|
if (value.type !== "gradient") return false;
|
|
40047
40409
|
const gradientType = value.gradientType;
|
|
40048
40410
|
if (gradientType !== "linear" && gradientType !== "radial") return false;
|
|
@@ -40053,12 +40415,12 @@ function isGradientFill(value) {
|
|
|
40053
40415
|
}
|
|
40054
40416
|
if (!Array.isArray(value.stops) || value.stops.length === 0) return false;
|
|
40055
40417
|
return value.stops.every((stop) => {
|
|
40056
|
-
if (!isPlainObject$
|
|
40418
|
+
if (!isPlainObject$2(stop)) return false;
|
|
40057
40419
|
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));
|
|
40058
40420
|
});
|
|
40059
40421
|
}
|
|
40060
40422
|
function isSolidFillWithAlpha(value) {
|
|
40061
|
-
return isPlainObject$
|
|
40423
|
+
return isPlainObject$2(value) && value.type === "solidWithAlpha" && typeof value.color === "string" && typeof value.alpha === "number";
|
|
40062
40424
|
}
|
|
40063
40425
|
function normalizeFillColor(value) {
|
|
40064
40426
|
if (value === null) return null;
|
|
@@ -40073,10 +40435,10 @@ function normalizeStrokeColor(value) {
|
|
|
40073
40435
|
return void 0;
|
|
40074
40436
|
}
|
|
40075
40437
|
function normalizeTextContent(value) {
|
|
40076
|
-
if (!isPlainObject$
|
|
40438
|
+
if (!isPlainObject$2(value)) return void 0;
|
|
40077
40439
|
if (!Array.isArray(value.parts)) return void 0;
|
|
40078
40440
|
if (value.parts.length === 0) return void 0;
|
|
40079
|
-
const validParts = value.parts.filter((p) => isPlainObject$
|
|
40441
|
+
const validParts = value.parts.filter((p) => isPlainObject$2(p) && typeof p.text === "string");
|
|
40080
40442
|
if (validParts.length === 0) return void 0;
|
|
40081
40443
|
const result = {
|
|
40082
40444
|
parts: validParts
|
|
@@ -40094,7 +40456,7 @@ function normalizeTextVerticalAlign(value) {
|
|
|
40094
40456
|
return void 0;
|
|
40095
40457
|
}
|
|
40096
40458
|
function normalizeTextInsets(value) {
|
|
40097
|
-
if (!isPlainObject$
|
|
40459
|
+
if (!isPlainObject$2(value)) return void 0;
|
|
40098
40460
|
const top2 = pickNumber(value.top);
|
|
40099
40461
|
const right2 = pickNumber(value.right);
|
|
40100
40462
|
const bottom2 = pickNumber(value.bottom);
|
|
@@ -40106,7 +40468,7 @@ function normalizeTextInsets(value) {
|
|
|
40106
40468
|
}
|
|
40107
40469
|
const OOXML_Z_INDEX_BASE = 251658240;
|
|
40108
40470
|
function normalizeZIndex(originalAttributes) {
|
|
40109
|
-
if (!isPlainObject$
|
|
40471
|
+
if (!isPlainObject$2(originalAttributes)) return void 0;
|
|
40110
40472
|
const relativeHeight = originalAttributes.relativeHeight;
|
|
40111
40473
|
if (typeof relativeHeight !== "number") return void 0;
|
|
40112
40474
|
return Math.max(0, relativeHeight - OOXML_Z_INDEX_BASE);
|
|
@@ -41300,321 +41662,6 @@ const ensureBidiIndentPx = (indent) => {
|
|
|
41300
41662
|
}
|
|
41301
41663
|
return adjusted;
|
|
41302
41664
|
};
|
|
41303
|
-
const sdtMetadataCache = /* @__PURE__ */ new Map();
|
|
41304
|
-
function resolveStyle(node, context, options = {}) {
|
|
41305
|
-
let paragraph = createDefaultParagraph();
|
|
41306
|
-
let character = createDefaultCharacter(context);
|
|
41307
|
-
let numbering;
|
|
41308
|
-
const chain = resolveStyleChain(node.styleId, context.styles);
|
|
41309
|
-
for (const style2 of chain) {
|
|
41310
|
-
paragraph = mergeParagraph(paragraph, style2.paragraph);
|
|
41311
|
-
character = mergeCharacter(character, style2.character);
|
|
41312
|
-
if (!numbering && style2.numbering) {
|
|
41313
|
-
numbering = resolveNumbering(style2.numbering.numId, style2.numbering.level, context);
|
|
41314
|
-
}
|
|
41315
|
-
}
|
|
41316
|
-
paragraph = mergeParagraph(paragraph, node.paragraphProps);
|
|
41317
|
-
character = mergeCharacter(character, node.characterProps);
|
|
41318
|
-
if (node.numbering) {
|
|
41319
|
-
numbering = resolveNumbering(node.numbering.numId, node.numbering.level, context);
|
|
41320
|
-
}
|
|
41321
|
-
const sdt = options?.sdt ? resolveSdtMetadata(options.sdt) : void 0;
|
|
41322
|
-
return {
|
|
41323
|
-
paragraph,
|
|
41324
|
-
character,
|
|
41325
|
-
numbering,
|
|
41326
|
-
sdt
|
|
41327
|
-
};
|
|
41328
|
-
}
|
|
41329
|
-
function resolveNumbering(numId, level, context) {
|
|
41330
|
-
const def = context.numbering?.[numId];
|
|
41331
|
-
if (!def) return void 0;
|
|
41332
|
-
const levelDef = def.levels.find((entry) => entry.level === level) ?? def.levels[level];
|
|
41333
|
-
if (!levelDef) return void 0;
|
|
41334
|
-
return {
|
|
41335
|
-
numId,
|
|
41336
|
-
level,
|
|
41337
|
-
indent: {
|
|
41338
|
-
left: levelDef.indent?.left,
|
|
41339
|
-
hanging: levelDef.indent?.hanging
|
|
41340
|
-
},
|
|
41341
|
-
format: levelDef.format ?? "decimal",
|
|
41342
|
-
text: levelDef.text ?? "%1.",
|
|
41343
|
-
start: levelDef.start ?? 1
|
|
41344
|
-
};
|
|
41345
|
-
}
|
|
41346
|
-
function resolveSdtMetadata(input) {
|
|
41347
|
-
if (!input) return void 0;
|
|
41348
|
-
const { nodeType, attrs, cacheKey: explicitKey } = input;
|
|
41349
|
-
if (!nodeType) return void 0;
|
|
41350
|
-
const normalizedAttrs = isPlainObject$2(attrs) ? attrs : {};
|
|
41351
|
-
const cacheKey = buildSdtCacheKey(nodeType, normalizedAttrs, explicitKey);
|
|
41352
|
-
if (cacheKey && sdtMetadataCache.has(cacheKey)) {
|
|
41353
|
-
return sdtMetadataCache.get(cacheKey);
|
|
41354
|
-
}
|
|
41355
|
-
let metadata;
|
|
41356
|
-
switch (nodeType) {
|
|
41357
|
-
case "fieldAnnotation":
|
|
41358
|
-
metadata = normalizeFieldAnnotationMetadata(normalizedAttrs);
|
|
41359
|
-
break;
|
|
41360
|
-
case "structuredContent":
|
|
41361
|
-
case "structuredContentBlock":
|
|
41362
|
-
metadata = normalizeStructuredContentMetadata(nodeType, normalizedAttrs);
|
|
41363
|
-
break;
|
|
41364
|
-
case "documentSection":
|
|
41365
|
-
metadata = normalizeDocumentSectionMetadata(normalizedAttrs);
|
|
41366
|
-
break;
|
|
41367
|
-
case "docPartObject":
|
|
41368
|
-
metadata = normalizeDocPartMetadata(normalizedAttrs);
|
|
41369
|
-
break;
|
|
41370
|
-
}
|
|
41371
|
-
if (metadata && cacheKey) {
|
|
41372
|
-
sdtMetadataCache.set(cacheKey, metadata);
|
|
41373
|
-
}
|
|
41374
|
-
return metadata;
|
|
41375
|
-
}
|
|
41376
|
-
function createDefaultParagraph(_context) {
|
|
41377
|
-
return {
|
|
41378
|
-
alignment: "left",
|
|
41379
|
-
spacing: {
|
|
41380
|
-
before: 0,
|
|
41381
|
-
after: 0,
|
|
41382
|
-
line: 12,
|
|
41383
|
-
lineRule: "auto"
|
|
41384
|
-
},
|
|
41385
|
-
indent: {
|
|
41386
|
-
left: 0,
|
|
41387
|
-
right: 0,
|
|
41388
|
-
firstLine: 0,
|
|
41389
|
-
hanging: 0
|
|
41390
|
-
},
|
|
41391
|
-
tabs: []
|
|
41392
|
-
};
|
|
41393
|
-
}
|
|
41394
|
-
function createDefaultCharacter(context) {
|
|
41395
|
-
const baseFont = context.defaults?.paragraphFont ?? "Calibri";
|
|
41396
|
-
const fallback = context.defaults?.paragraphFontFallback;
|
|
41397
|
-
const wordFamily = context.defaults?.paragraphFontFamily;
|
|
41398
|
-
const resolvedFamily = toCssFontFamily(baseFont, { fallback, wordFamily }) ?? baseFont;
|
|
41399
|
-
return {
|
|
41400
|
-
font: {
|
|
41401
|
-
family: resolvedFamily,
|
|
41402
|
-
size: context.defaults?.fontSize ?? 11,
|
|
41403
|
-
weight: 400,
|
|
41404
|
-
italic: false
|
|
41405
|
-
},
|
|
41406
|
-
color: "#000000"
|
|
41407
|
-
};
|
|
41408
|
-
}
|
|
41409
|
-
function resolveStyleChain(styleId, styles) {
|
|
41410
|
-
if (!styleId || !styles) return [];
|
|
41411
|
-
const result = [];
|
|
41412
|
-
const visited = /* @__PURE__ */ new Set();
|
|
41413
|
-
let current = styles[styleId];
|
|
41414
|
-
while (current && !visited.has(current.id)) {
|
|
41415
|
-
result.unshift(current);
|
|
41416
|
-
visited.add(current.id);
|
|
41417
|
-
current = current.basedOn ? styles[current.basedOn] : void 0;
|
|
41418
|
-
}
|
|
41419
|
-
return result;
|
|
41420
|
-
}
|
|
41421
|
-
function mergeParagraph(base2, overrides) {
|
|
41422
|
-
if (!overrides) return base2;
|
|
41423
|
-
return {
|
|
41424
|
-
...base2,
|
|
41425
|
-
alignment: overrides.alignment ?? base2.alignment,
|
|
41426
|
-
spacing: overrides.spacing ? { ...base2.spacing, ...overrides.spacing } : base2.spacing,
|
|
41427
|
-
indent: overrides.indent ? { ...base2.indent, ...overrides.indent } : base2.indent,
|
|
41428
|
-
borders: overrides.borders ? { ...base2.borders, ...overrides.borders } : base2.borders,
|
|
41429
|
-
shading: overrides.shading ?? base2.shading,
|
|
41430
|
-
tabs: overrides.tabs ?? base2.tabs
|
|
41431
|
-
};
|
|
41432
|
-
}
|
|
41433
|
-
function mergeCharacter(base2, overrides) {
|
|
41434
|
-
if (!overrides) return base2;
|
|
41435
|
-
return {
|
|
41436
|
-
...base2,
|
|
41437
|
-
font: overrides.font ? { ...base2.font, ...overrides.font } : base2.font,
|
|
41438
|
-
color: overrides.color ?? base2.color,
|
|
41439
|
-
underline: overrides.underline ?? base2.underline,
|
|
41440
|
-
strike: overrides.strike ?? base2.strike,
|
|
41441
|
-
highlight: overrides.highlight ?? base2.highlight,
|
|
41442
|
-
letterSpacing: overrides.letterSpacing ?? base2.letterSpacing
|
|
41443
|
-
};
|
|
41444
|
-
}
|
|
41445
|
-
function normalizeFieldAnnotationMetadata(attrs) {
|
|
41446
|
-
const fieldId = toOptionalString(attrs.fieldId) ?? "";
|
|
41447
|
-
const formatting = extractFormatting(attrs);
|
|
41448
|
-
const size2 = normalizeSize(attrs.size);
|
|
41449
|
-
const extras = isPlainObject$2(attrs.extras) ? attrs.extras : null;
|
|
41450
|
-
const marks = isPlainObject$2(attrs.marks) ? attrs.marks : void 0;
|
|
41451
|
-
return {
|
|
41452
|
-
type: "fieldAnnotation",
|
|
41453
|
-
fieldId,
|
|
41454
|
-
variant: normalizeFieldAnnotationVariant(attrs.type),
|
|
41455
|
-
fieldType: toOptionalString(attrs.fieldType),
|
|
41456
|
-
displayLabel: toOptionalString(attrs.displayLabel),
|
|
41457
|
-
defaultDisplayLabel: toOptionalString(attrs.defaultDisplayLabel),
|
|
41458
|
-
alias: toOptionalString(attrs.alias),
|
|
41459
|
-
fieldColor: normalizeColorValue(attrs.fieldColor),
|
|
41460
|
-
borderColor: normalizeColorValue(attrs.borderColor),
|
|
41461
|
-
highlighted: toBoolean$2(attrs.highlighted, true),
|
|
41462
|
-
fontFamily: toNullableString(attrs.fontFamily),
|
|
41463
|
-
fontSize: normalizeFontSize(attrs.fontSize),
|
|
41464
|
-
textColor: normalizeColorValue(attrs.textColor) ?? null,
|
|
41465
|
-
textHighlight: normalizeColorValue(attrs.textHighlight) ?? null,
|
|
41466
|
-
linkUrl: toNullableString(attrs.linkUrl),
|
|
41467
|
-
imageSrc: toNullableString(attrs.imageSrc),
|
|
41468
|
-
rawHtml: attrs.rawHtml ?? void 0,
|
|
41469
|
-
size: size2 ?? null,
|
|
41470
|
-
extras,
|
|
41471
|
-
multipleImage: toBoolean$2(attrs.multipleImage, false),
|
|
41472
|
-
hash: toOptionalString(attrs.hash) ?? null,
|
|
41473
|
-
generatorIndex: toNumber(attrs.generatorIndex),
|
|
41474
|
-
sdtId: toOptionalString(attrs.sdtId) ?? null,
|
|
41475
|
-
hidden: toBoolean$2(attrs.hidden, false),
|
|
41476
|
-
visibility: normalizeVisibility(attrs.visibility),
|
|
41477
|
-
isLocked: toBoolean$2(attrs.isLocked, false),
|
|
41478
|
-
formatting,
|
|
41479
|
-
marks
|
|
41480
|
-
};
|
|
41481
|
-
}
|
|
41482
|
-
function normalizeStructuredContentMetadata(nodeType, attrs) {
|
|
41483
|
-
return {
|
|
41484
|
-
type: "structuredContent",
|
|
41485
|
-
scope: nodeType === "structuredContentBlock" ? "block" : "inline",
|
|
41486
|
-
id: toNullableString(attrs.id),
|
|
41487
|
-
tag: toOptionalString(attrs.tag),
|
|
41488
|
-
alias: toOptionalString(attrs.alias),
|
|
41489
|
-
sdtPr: attrs.sdtPr
|
|
41490
|
-
};
|
|
41491
|
-
}
|
|
41492
|
-
function normalizeDocumentSectionMetadata(attrs) {
|
|
41493
|
-
return {
|
|
41494
|
-
type: "documentSection",
|
|
41495
|
-
id: toNullableString(attrs.id),
|
|
41496
|
-
title: toOptionalString(attrs.title) ?? null,
|
|
41497
|
-
description: toOptionalString(attrs.description) ?? null,
|
|
41498
|
-
sectionType: toOptionalString(attrs.sectionType) ?? null,
|
|
41499
|
-
isLocked: toBoolean$2(attrs.isLocked, false),
|
|
41500
|
-
sdBlockId: toNullableString(attrs.sdBlockId)
|
|
41501
|
-
};
|
|
41502
|
-
}
|
|
41503
|
-
function normalizeDocPartMetadata(attrs) {
|
|
41504
|
-
return {
|
|
41505
|
-
type: "docPartObject",
|
|
41506
|
-
gallery: toOptionalString(attrs.docPartGallery ?? attrs.gallery) ?? null,
|
|
41507
|
-
// Source uniqueId from attrs.id (PM adapter uses getDocPartObjectId which extracts attrs.id)
|
|
41508
|
-
// Fall back to attrs.uniqueId for compatibility
|
|
41509
|
-
uniqueId: toOptionalString(attrs.id ?? attrs.uniqueId) ?? null,
|
|
41510
|
-
alias: toOptionalString(attrs.alias) ?? null,
|
|
41511
|
-
instruction: toOptionalString(attrs.instruction) ?? null
|
|
41512
|
-
};
|
|
41513
|
-
}
|
|
41514
|
-
function isPlainObject$2(value) {
|
|
41515
|
-
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
41516
|
-
}
|
|
41517
|
-
function toOptionalString(value) {
|
|
41518
|
-
if (value == null) return void 0;
|
|
41519
|
-
if (typeof value === "string") {
|
|
41520
|
-
const trimmed = value.trim();
|
|
41521
|
-
return trimmed.length ? trimmed : void 0;
|
|
41522
|
-
}
|
|
41523
|
-
return String(value);
|
|
41524
|
-
}
|
|
41525
|
-
function toNullableString(value) {
|
|
41526
|
-
const str = toOptionalString(value);
|
|
41527
|
-
return str ?? null;
|
|
41528
|
-
}
|
|
41529
|
-
function toBoolean$2(value, fallback) {
|
|
41530
|
-
if (typeof value === "boolean") return value;
|
|
41531
|
-
if (typeof value === "string") {
|
|
41532
|
-
const lower = value.toLowerCase();
|
|
41533
|
-
if (lower === "true") return true;
|
|
41534
|
-
if (lower === "false") return false;
|
|
41535
|
-
}
|
|
41536
|
-
if (value == null) return fallback;
|
|
41537
|
-
return Boolean(value);
|
|
41538
|
-
}
|
|
41539
|
-
function normalizeVisibility(value) {
|
|
41540
|
-
if (typeof value !== "string") return void 0;
|
|
41541
|
-
const normalized = value.toLowerCase();
|
|
41542
|
-
if (normalized === "visible" || normalized === "hidden") {
|
|
41543
|
-
return normalized;
|
|
41544
|
-
}
|
|
41545
|
-
return void 0;
|
|
41546
|
-
}
|
|
41547
|
-
function normalizeColorValue(value) {
|
|
41548
|
-
if (typeof value !== "string") return void 0;
|
|
41549
|
-
const trimmed = value.trim();
|
|
41550
|
-
if (!trimmed || trimmed.toLowerCase() === "none") return void 0;
|
|
41551
|
-
return trimmed;
|
|
41552
|
-
}
|
|
41553
|
-
function normalizeFontSize(value) {
|
|
41554
|
-
if (value == null) return null;
|
|
41555
|
-
if (typeof value === "number") {
|
|
41556
|
-
return Number.isFinite(value) ? value : null;
|
|
41557
|
-
}
|
|
41558
|
-
if (typeof value === "string") {
|
|
41559
|
-
const trimmed = value.trim();
|
|
41560
|
-
return trimmed.length ? trimmed : null;
|
|
41561
|
-
}
|
|
41562
|
-
return null;
|
|
41563
|
-
}
|
|
41564
|
-
function toNumber(value) {
|
|
41565
|
-
if (typeof value === "number") {
|
|
41566
|
-
return Number.isFinite(value) ? value : null;
|
|
41567
|
-
}
|
|
41568
|
-
if (typeof value === "string") {
|
|
41569
|
-
const parsed = parseFloat(value);
|
|
41570
|
-
return Number.isFinite(parsed) ? parsed : null;
|
|
41571
|
-
}
|
|
41572
|
-
return null;
|
|
41573
|
-
}
|
|
41574
|
-
function normalizeSize(value) {
|
|
41575
|
-
if (!isPlainObject$2(value)) return null;
|
|
41576
|
-
const obj = value;
|
|
41577
|
-
const width = toNumber(obj.width);
|
|
41578
|
-
const height = toNumber(obj.height);
|
|
41579
|
-
if (width == null && height == null) return null;
|
|
41580
|
-
const result = {};
|
|
41581
|
-
if (width != null) result.width = width;
|
|
41582
|
-
if (height != null) result.height = height;
|
|
41583
|
-
return result;
|
|
41584
|
-
}
|
|
41585
|
-
function normalizeFieldAnnotationVariant(value) {
|
|
41586
|
-
if (typeof value !== "string") return void 0;
|
|
41587
|
-
const normalized = value.toLowerCase();
|
|
41588
|
-
if (normalized === "text" || normalized === "image" || normalized === "signature" || normalized === "checkbox" || normalized === "html" || normalized === "link") {
|
|
41589
|
-
return normalized;
|
|
41590
|
-
}
|
|
41591
|
-
return void 0;
|
|
41592
|
-
}
|
|
41593
|
-
function extractFormatting(attrs) {
|
|
41594
|
-
const bold = toBoolean$2(attrs.bold, false);
|
|
41595
|
-
const italic = toBoolean$2(attrs.italic, false);
|
|
41596
|
-
const underline = toBoolean$2(attrs.underline, false);
|
|
41597
|
-
const formatting = {};
|
|
41598
|
-
if (bold) formatting.bold = true;
|
|
41599
|
-
if (italic) formatting.italic = true;
|
|
41600
|
-
if (underline) formatting.underline = true;
|
|
41601
|
-
return Object.keys(formatting).length ? formatting : void 0;
|
|
41602
|
-
}
|
|
41603
|
-
function buildSdtCacheKey(nodeType, attrs, explicitKey) {
|
|
41604
|
-
const provided = toOptionalString(explicitKey);
|
|
41605
|
-
if (provided) {
|
|
41606
|
-
return `${nodeType}:${provided}`;
|
|
41607
|
-
}
|
|
41608
|
-
const hash2 = toOptionalString(attrs.hash);
|
|
41609
|
-
if (hash2) {
|
|
41610
|
-
return `${nodeType}:${hash2}`;
|
|
41611
|
-
}
|
|
41612
|
-
const id = toOptionalString(attrs.id);
|
|
41613
|
-
if (id) {
|
|
41614
|
-
return `${nodeType}:${id}`;
|
|
41615
|
-
}
|
|
41616
|
-
return void 0;
|
|
41617
|
-
}
|
|
41618
41665
|
const DEFAULT_LIST_HANGING_PX = 18;
|
|
41619
41666
|
const LIST_MARKER_GAP = 8;
|
|
41620
41667
|
const DEFAULT_BULLET_GLYPH = "•";
|
|
@@ -42174,6 +42221,7 @@ const EMPTY_NUMBERING_CONTEXT = {
|
|
|
42174
42221
|
definitions: {},
|
|
42175
42222
|
abstracts: {}
|
|
42176
42223
|
};
|
|
42224
|
+
const ooxmlResolver = createOoxmlResolver({ pPr: translator, rPr: translator$1 });
|
|
42177
42225
|
const hydrateParagraphStyleAttrs = (para, context, preResolved) => {
|
|
42178
42226
|
if (!hasParagraphStyleContext(context)) {
|
|
42179
42227
|
return null;
|
|
@@ -42201,7 +42249,7 @@ const hydrateParagraphStyleAttrs = (para, context, preResolved) => {
|
|
|
42201
42249
|
// should still get docDefaults spacing from style resolution
|
|
42202
42250
|
numbering: context.numbering ?? EMPTY_NUMBERING_CONTEXT
|
|
42203
42251
|
};
|
|
42204
|
-
const resolved = resolveParagraphProperties(resolverParams, inlineProps);
|
|
42252
|
+
const resolved = ooxmlResolver.resolveParagraphProperties(resolverParams, inlineProps);
|
|
42205
42253
|
if (!resolved) {
|
|
42206
42254
|
return null;
|
|
42207
42255
|
}
|
|
@@ -42256,6 +42304,138 @@ const cloneIfObject = (value) => {
|
|
|
42256
42304
|
}
|
|
42257
42305
|
return { ...value };
|
|
42258
42306
|
};
|
|
42307
|
+
const buildCharacterStyleHydration = (resolved, docx) => {
|
|
42308
|
+
const fontFamily2 = extractFontFamily(resolved.fontFamily, docx);
|
|
42309
|
+
const fontSize2 = typeof resolved.fontSize === "number" ? resolved.fontSize : 20;
|
|
42310
|
+
const color = extractColorValue(resolved.color);
|
|
42311
|
+
const bold = normalizeBooleanProp(resolved.bold);
|
|
42312
|
+
const italic = normalizeBooleanProp(resolved.italic);
|
|
42313
|
+
const strike = normalizeBooleanProp(resolved.strike);
|
|
42314
|
+
const underline = extractUnderline(resolved.underline);
|
|
42315
|
+
const letterSpacing = typeof resolved.letterSpacing === "number" ? resolved.letterSpacing : void 0;
|
|
42316
|
+
return {
|
|
42317
|
+
fontFamily: fontFamily2,
|
|
42318
|
+
fontSize: fontSize2,
|
|
42319
|
+
color,
|
|
42320
|
+
bold,
|
|
42321
|
+
italic,
|
|
42322
|
+
strike,
|
|
42323
|
+
underline,
|
|
42324
|
+
letterSpacing
|
|
42325
|
+
};
|
|
42326
|
+
};
|
|
42327
|
+
const hydrateCharacterStyleAttrs = (para, context, resolvedPpr) => {
|
|
42328
|
+
if (!hasParagraphStyleContext(context)) {
|
|
42329
|
+
return null;
|
|
42330
|
+
}
|
|
42331
|
+
const attrs = para.attrs ?? {};
|
|
42332
|
+
const paragraphProps = typeof attrs.paragraphProperties === "object" && attrs.paragraphProperties !== null ? attrs.paragraphProperties : {};
|
|
42333
|
+
const styleIdSource = attrs.styleId ?? paragraphProps.styleId;
|
|
42334
|
+
const styleId = typeof styleIdSource === "string" && styleIdSource.trim() ? styleIdSource : null;
|
|
42335
|
+
const inlineRpr = {};
|
|
42336
|
+
const pprForChain = resolvedPpr ?? { styleId };
|
|
42337
|
+
const numberingProps = attrs.numberingProperties ?? paragraphProps.numberingProperties;
|
|
42338
|
+
if (numberingProps != null) {
|
|
42339
|
+
pprForChain.numberingProperties = numberingProps;
|
|
42340
|
+
}
|
|
42341
|
+
const resolverParams = {
|
|
42342
|
+
docx: context.docx,
|
|
42343
|
+
numbering: context.numbering ?? EMPTY_NUMBERING_CONTEXT
|
|
42344
|
+
};
|
|
42345
|
+
let resolved = null;
|
|
42346
|
+
try {
|
|
42347
|
+
resolved = ooxmlResolver.resolveRunProperties(
|
|
42348
|
+
resolverParams,
|
|
42349
|
+
inlineRpr,
|
|
42350
|
+
pprForChain,
|
|
42351
|
+
false,
|
|
42352
|
+
// not list number marker
|
|
42353
|
+
false
|
|
42354
|
+
// not numberingDefinedInline
|
|
42355
|
+
);
|
|
42356
|
+
if (!resolved || typeof resolved !== "object") {
|
|
42357
|
+
return null;
|
|
42358
|
+
}
|
|
42359
|
+
} catch {
|
|
42360
|
+
return null;
|
|
42361
|
+
}
|
|
42362
|
+
return buildCharacterStyleHydration(resolved, context.docx);
|
|
42363
|
+
};
|
|
42364
|
+
const hydrateMarkerStyleAttrs = (para, context, resolvedPpr) => {
|
|
42365
|
+
if (!hasParagraphStyleContext(context)) {
|
|
42366
|
+
return null;
|
|
42367
|
+
}
|
|
42368
|
+
const attrs = para.attrs ?? {};
|
|
42369
|
+
const paragraphProps = typeof attrs.paragraphProperties === "object" && attrs.paragraphProperties !== null ? attrs.paragraphProperties : {};
|
|
42370
|
+
const styleIdSource = attrs.styleId ?? paragraphProps.styleId;
|
|
42371
|
+
const styleId = typeof styleIdSource === "string" && styleIdSource.trim() ? styleIdSource : null;
|
|
42372
|
+
const inlineRpr = {};
|
|
42373
|
+
const numberingProps = attrs.numberingProperties ?? paragraphProps.numberingProperties;
|
|
42374
|
+
const numberingDefinedInline = numberingProps?.numId != null;
|
|
42375
|
+
const pprForChain = resolvedPpr ? { ...resolvedPpr } : { styleId };
|
|
42376
|
+
if (styleId && !pprForChain.styleId) {
|
|
42377
|
+
pprForChain.styleId = styleId;
|
|
42378
|
+
}
|
|
42379
|
+
if (numberingProps != null) {
|
|
42380
|
+
pprForChain.numberingProperties = numberingProps;
|
|
42381
|
+
}
|
|
42382
|
+
const resolverParams = {
|
|
42383
|
+
docx: context.docx,
|
|
42384
|
+
numbering: context.numbering ?? EMPTY_NUMBERING_CONTEXT
|
|
42385
|
+
};
|
|
42386
|
+
let resolved = null;
|
|
42387
|
+
try {
|
|
42388
|
+
resolved = ooxmlResolver.resolveRunProperties(
|
|
42389
|
+
resolverParams,
|
|
42390
|
+
inlineRpr,
|
|
42391
|
+
pprForChain,
|
|
42392
|
+
true,
|
|
42393
|
+
numberingDefinedInline
|
|
42394
|
+
);
|
|
42395
|
+
if (!resolved || typeof resolved !== "object") {
|
|
42396
|
+
return null;
|
|
42397
|
+
}
|
|
42398
|
+
} catch {
|
|
42399
|
+
return null;
|
|
42400
|
+
}
|
|
42401
|
+
return buildCharacterStyleHydration(resolved, context.docx);
|
|
42402
|
+
};
|
|
42403
|
+
function extractFontFamily(fontFamily2, docx) {
|
|
42404
|
+
if (!fontFamily2 || typeof fontFamily2 !== "object") return void 0;
|
|
42405
|
+
const toCssFontFamily2 = SuperConverter.toCssFontFamily;
|
|
42406
|
+
const resolved = resolveDocxFontFamily(fontFamily2, docx ?? null, toCssFontFamily2);
|
|
42407
|
+
return resolved ?? void 0;
|
|
42408
|
+
}
|
|
42409
|
+
function extractColorValue(color) {
|
|
42410
|
+
if (!color || typeof color !== "object") return void 0;
|
|
42411
|
+
const c2 = color;
|
|
42412
|
+
const val = c2.val;
|
|
42413
|
+
if (typeof val !== "string") return void 0;
|
|
42414
|
+
if (!val || val.toLowerCase() === "auto") return void 0;
|
|
42415
|
+
return val;
|
|
42416
|
+
}
|
|
42417
|
+
function normalizeBooleanProp(value) {
|
|
42418
|
+
if (value == null) return void 0;
|
|
42419
|
+
if (typeof value === "boolean") return value;
|
|
42420
|
+
if (typeof value === "number") return value !== 0;
|
|
42421
|
+
if (typeof value === "string") {
|
|
42422
|
+
const lower = value.toLowerCase();
|
|
42423
|
+
if (lower === "0" || lower === "false" || lower === "off") return false;
|
|
42424
|
+
if (lower === "1" || lower === "true" || lower === "on" || lower === "") return true;
|
|
42425
|
+
}
|
|
42426
|
+
return Boolean(value);
|
|
42427
|
+
}
|
|
42428
|
+
function extractUnderline(underline) {
|
|
42429
|
+
if (!underline || typeof underline !== "object") return void 0;
|
|
42430
|
+
const u = underline;
|
|
42431
|
+
const type = u["w:val"] ?? u.type ?? u.val;
|
|
42432
|
+
if (typeof type !== "string" || type === "none") return void 0;
|
|
42433
|
+
const color = u["w:color"] ?? u.color;
|
|
42434
|
+
return {
|
|
42435
|
+
type,
|
|
42436
|
+
color: typeof color === "string" ? color : void 0
|
|
42437
|
+
};
|
|
42438
|
+
}
|
|
42259
42439
|
const { resolveSpacingIndent } = Engines;
|
|
42260
42440
|
const DEFAULT_DECIMAL_SEPARATOR$2 = ".";
|
|
42261
42441
|
const isValidNumberingId = (numId) => {
|
|
@@ -42771,7 +42951,7 @@ const extractDropCapRunFromParagraph = (para) => {
|
|
|
42771
42951
|
}
|
|
42772
42952
|
return dropCapRun;
|
|
42773
42953
|
};
|
|
42774
|
-
const computeWordLayoutForParagraph = (paragraphAttrs, numberingProps, styleContext,
|
|
42954
|
+
const computeWordLayoutForParagraph = (paragraphAttrs, numberingProps, styleContext, paragraphNode, converterContext, resolvedPpr) => {
|
|
42775
42955
|
if (numberingProps === null) {
|
|
42776
42956
|
return null;
|
|
42777
42957
|
}
|
|
@@ -42809,7 +42989,23 @@ const computeWordLayoutForParagraph = (paragraphAttrs, numberingProps, styleCont
|
|
|
42809
42989
|
spacing: {}
|
|
42810
42990
|
}
|
|
42811
42991
|
};
|
|
42812
|
-
let markerRun
|
|
42992
|
+
let markerRun;
|
|
42993
|
+
const markerHydration = paragraphNode && converterContext ? hydrateMarkerStyleAttrs(paragraphNode, converterContext, resolvedPpr) : null;
|
|
42994
|
+
if (markerHydration) {
|
|
42995
|
+
const resolvedColor = markerHydration.color ? `#${markerHydration.color.replace("#", "")}` : void 0;
|
|
42996
|
+
markerRun = {
|
|
42997
|
+
fontFamily: markerHydration.fontFamily ?? "Times New Roman",
|
|
42998
|
+
fontSize: markerHydration.fontSize / 2,
|
|
42999
|
+
// half-points to points
|
|
43000
|
+
bold: markerHydration.bold,
|
|
43001
|
+
italic: markerHydration.italic,
|
|
43002
|
+
color: resolvedColor,
|
|
43003
|
+
letterSpacing: markerHydration.letterSpacing != null ? twipsToPx$1(markerHydration.letterSpacing) : void 0
|
|
43004
|
+
};
|
|
43005
|
+
}
|
|
43006
|
+
if (!markerRun) {
|
|
43007
|
+
markerRun = numberingProps?.resolvedMarkerRpr;
|
|
43008
|
+
}
|
|
42813
43009
|
if (!markerRun) {
|
|
42814
43010
|
const { character: characterStyle } = resolveStyle({ styleId: paragraphAttrs.styleId }, styleContext);
|
|
42815
43011
|
if (characterStyle) {
|
|
@@ -43130,7 +43326,12 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
|
|
|
43130
43326
|
const numId = numberingProps.numId;
|
|
43131
43327
|
const ilvl = Number.isFinite(numberingProps.ilvl) ? Math.max(0, Math.floor(Number(numberingProps.ilvl))) : 0;
|
|
43132
43328
|
const numericNumId = typeof numId === "number" ? numId : void 0;
|
|
43133
|
-
|
|
43329
|
+
let resolvedLevel;
|
|
43330
|
+
try {
|
|
43331
|
+
resolvedLevel = resolveNumberingFromContext(numId, ilvl, converterContext?.numbering);
|
|
43332
|
+
} catch (error) {
|
|
43333
|
+
resolvedLevel = void 0;
|
|
43334
|
+
}
|
|
43134
43335
|
if (resolvedLevel) {
|
|
43135
43336
|
if (resolvedLevel.format && numberingProps.format == null) {
|
|
43136
43337
|
numberingProps.format = resolvedLevel.format;
|
|
@@ -43191,7 +43392,19 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
|
|
|
43191
43392
|
}
|
|
43192
43393
|
}
|
|
43193
43394
|
}
|
|
43194
|
-
let wordLayout =
|
|
43395
|
+
let wordLayout = null;
|
|
43396
|
+
try {
|
|
43397
|
+
wordLayout = computeWordLayoutForParagraph(
|
|
43398
|
+
paragraphAttrs,
|
|
43399
|
+
enrichedNumberingProps,
|
|
43400
|
+
styleContext,
|
|
43401
|
+
para,
|
|
43402
|
+
converterContext,
|
|
43403
|
+
hydrated?.resolved
|
|
43404
|
+
);
|
|
43405
|
+
} catch (error) {
|
|
43406
|
+
wordLayout = null;
|
|
43407
|
+
}
|
|
43195
43408
|
if (!wordLayout && enrichedNumberingProps.resolvedLevelIndent) {
|
|
43196
43409
|
const resolvedIndentPx = convertIndentTwipsToPx(enrichedNumberingProps.resolvedLevelIndent);
|
|
43197
43410
|
const baseIndent = resolvedIndentPx ?? enrichedNumberingProps.resolvedLevelIndent;
|
|
@@ -43736,7 +43949,7 @@ const V_RELATIVE_VALUES$1 = /* @__PURE__ */ new Set(["paragraph", "page", "margi
|
|
|
43736
43949
|
const H_ALIGN_VALUES$1 = /* @__PURE__ */ new Set(["left", "center", "right"]);
|
|
43737
43950
|
const V_ALIGN_VALUES$1 = /* @__PURE__ */ new Set(["top", "center", "bottom"]);
|
|
43738
43951
|
const getAttrs$1 = (node) => {
|
|
43739
|
-
return isPlainObject$
|
|
43952
|
+
return isPlainObject$2(node.attrs) ? node.attrs : {};
|
|
43740
43953
|
};
|
|
43741
43954
|
const normalizeWrapType$1 = (value) => {
|
|
43742
43955
|
if (typeof value !== "string") return void 0;
|
|
@@ -43759,7 +43972,7 @@ const normalizePolygon$1 = (value) => {
|
|
|
43759
43972
|
return polygon.length > 0 ? polygon : void 0;
|
|
43760
43973
|
};
|
|
43761
43974
|
const normalizeWrap$2 = (value) => {
|
|
43762
|
-
if (!isPlainObject$
|
|
43975
|
+
if (!isPlainObject$2(value)) {
|
|
43763
43976
|
return void 0;
|
|
43764
43977
|
}
|
|
43765
43978
|
const type = normalizeWrapType$1(value.type);
|
|
@@ -43767,7 +43980,7 @@ const normalizeWrap$2 = (value) => {
|
|
|
43767
43980
|
return void 0;
|
|
43768
43981
|
}
|
|
43769
43982
|
const wrap = { type };
|
|
43770
|
-
const attrs = isPlainObject$
|
|
43983
|
+
const attrs = isPlainObject$2(value.attrs) ? value.attrs : {};
|
|
43771
43984
|
const wrapText = normalizeWrapText$1(attrs.wrapText);
|
|
43772
43985
|
if (wrapText) {
|
|
43773
43986
|
wrap.wrapText = wrapText;
|
|
@@ -43784,7 +43997,7 @@ const normalizeWrap$2 = (value) => {
|
|
|
43784
43997
|
if (polygon) {
|
|
43785
43998
|
wrap.polygon = polygon;
|
|
43786
43999
|
}
|
|
43787
|
-
const behindDoc = toBoolean$
|
|
44000
|
+
const behindDoc = toBoolean$2(attrs.behindDoc);
|
|
43788
44001
|
if (behindDoc != null) {
|
|
43789
44002
|
wrap.behindDoc = behindDoc;
|
|
43790
44003
|
}
|
|
@@ -43799,10 +44012,10 @@ const normalizeAnchorAlign$1 = (value, allowed) => {
|
|
|
43799
44012
|
return allowed.has(value) ? value : void 0;
|
|
43800
44013
|
};
|
|
43801
44014
|
const normalizeAnchorData$1 = (value, attrs, wrapBehindDoc) => {
|
|
43802
|
-
const raw = isPlainObject$
|
|
43803
|
-
const marginOffset = isPlainObject$
|
|
43804
|
-
const simplePos = isPlainObject$
|
|
43805
|
-
const originalAttrs = isPlainObject$
|
|
44015
|
+
const raw = isPlainObject$2(value) ? value : void 0;
|
|
44016
|
+
const marginOffset = isPlainObject$2(attrs.marginOffset) ? attrs.marginOffset : void 0;
|
|
44017
|
+
const simplePos = isPlainObject$2(attrs.simplePos) ? attrs.simplePos : void 0;
|
|
44018
|
+
const originalAttrs = isPlainObject$2(attrs.originalAttributes) ? attrs.originalAttributes : void 0;
|
|
43806
44019
|
const isAnchored = attrs.isAnchor === true || Boolean(raw);
|
|
43807
44020
|
const anchor = {};
|
|
43808
44021
|
if (isAnchored) {
|
|
@@ -43820,7 +44033,7 @@ const normalizeAnchorData$1 = (value, attrs, wrapBehindDoc) => {
|
|
|
43820
44033
|
if (offsetH != null) anchor.offsetH = offsetH;
|
|
43821
44034
|
const offsetV = pickNumber(marginOffset?.top ?? marginOffset?.vertical ?? raw?.offsetV ?? simplePos?.y);
|
|
43822
44035
|
if (offsetV != null) anchor.offsetV = offsetV;
|
|
43823
|
-
const behindDoc = toBoolean$
|
|
44036
|
+
const behindDoc = toBoolean$2(raw?.behindDoc ?? wrapBehindDoc ?? originalAttrs?.behindDoc);
|
|
43824
44037
|
if (behindDoc != null) anchor.behindDoc = behindDoc;
|
|
43825
44038
|
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;
|
|
43826
44039
|
return hasData ? anchor : void 0;
|
|
@@ -43945,7 +44158,7 @@ function handleShapeTextboxNode(node, context) {
|
|
|
43945
44158
|
}
|
|
43946
44159
|
}
|
|
43947
44160
|
const getAttrs = (node) => {
|
|
43948
|
-
return isPlainObject$
|
|
44161
|
+
return isPlainObject$2(node.attrs) ? { ...node.attrs } : {};
|
|
43949
44162
|
};
|
|
43950
44163
|
const parseFullWidth = (value) => {
|
|
43951
44164
|
if (typeof value === "string") {
|
|
@@ -43964,7 +44177,7 @@ function contentBlockNodeToDrawingBlock(node, nextBlockId, positions) {
|
|
|
43964
44177
|
if (rawAttrs.horizontalRule !== true) {
|
|
43965
44178
|
return null;
|
|
43966
44179
|
}
|
|
43967
|
-
const size2 = isPlainObject$
|
|
44180
|
+
const size2 = isPlainObject$2(rawAttrs.size) ? rawAttrs.size : void 0;
|
|
43968
44181
|
const { width, isFullWidth } = parseFullWidth(size2?.width);
|
|
43969
44182
|
const height = pickNumber(size2?.height);
|
|
43970
44183
|
if (!height || height <= 0) {
|
|
@@ -44166,6 +44379,9 @@ const extractRunStyleId = (runProperties) => {
|
|
|
44166
44379
|
return null;
|
|
44167
44380
|
};
|
|
44168
44381
|
const DEFAULT_IMAGE_DIMENSION_PX = 100;
|
|
44382
|
+
const HALF_POINTS_PER_POINT = 2;
|
|
44383
|
+
const SCREEN_DPI = 96;
|
|
44384
|
+
const POINT_DPI = 72;
|
|
44169
44385
|
function isInlineImage(node) {
|
|
44170
44386
|
const attrs = node.attrs ?? {};
|
|
44171
44387
|
const wrap = attrs.wrap;
|
|
@@ -44193,8 +44409,8 @@ function imageNodeToRun(node, positions, activeSdt) {
|
|
|
44193
44409
|
const size2 = attrs.size ?? {};
|
|
44194
44410
|
const width = typeof size2.width === "number" && Number.isFinite(size2.width) && size2.width > 0 ? size2.width : DEFAULT_IMAGE_DIMENSION_PX;
|
|
44195
44411
|
const height = typeof size2.height === "number" && Number.isFinite(size2.height) && size2.height > 0 ? size2.height : DEFAULT_IMAGE_DIMENSION_PX;
|
|
44196
|
-
const wrap = isPlainObject$
|
|
44197
|
-
const wrapAttrs = isPlainObject$
|
|
44412
|
+
const wrap = isPlainObject$2(attrs.wrap) ? attrs.wrap : {};
|
|
44413
|
+
const wrapAttrs = isPlainObject$2(wrap.attrs) ? wrap.attrs : {};
|
|
44198
44414
|
const run = {
|
|
44199
44415
|
kind: "image",
|
|
44200
44416
|
src,
|
|
@@ -44404,15 +44620,6 @@ const applyBaseRunDefaults = (run, defaults, uiDisplayFallbackFont, fallbackSize
|
|
|
44404
44620
|
if (defaults.letterSpacing != null && run.letterSpacing == null) {
|
|
44405
44621
|
run.letterSpacing = defaults.letterSpacing;
|
|
44406
44622
|
}
|
|
44407
|
-
if (defaults.bold && run.bold === void 0) {
|
|
44408
|
-
run.bold = true;
|
|
44409
|
-
}
|
|
44410
|
-
if (defaults.italic && run.italic === void 0) {
|
|
44411
|
-
run.italic = true;
|
|
44412
|
-
}
|
|
44413
|
-
if (defaults.underline && !run.underline) {
|
|
44414
|
-
run.underline = defaults.underline;
|
|
44415
|
-
}
|
|
44416
44623
|
};
|
|
44417
44624
|
function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defaultSize, styleContext, listCounterContext, trackedChanges, bookmarks, hyperlinkConfig = DEFAULT_HYPERLINK_CONFIG$1, themeColors, converters, converterContext) {
|
|
44418
44625
|
const baseBlockId = nextBlockId("paragraph");
|
|
@@ -44421,28 +44628,45 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
|
|
|
44421
44628
|
const paragraphHydration = converterContext ? hydrateParagraphStyleAttrs(para, converterContext) : null;
|
|
44422
44629
|
let baseRunDefaults = {};
|
|
44423
44630
|
try {
|
|
44424
|
-
const
|
|
44425
|
-
|
|
44426
|
-
|
|
44427
|
-
|
|
44428
|
-
|
|
44429
|
-
|
|
44430
|
-
|
|
44431
|
-
|
|
44432
|
-
|
|
44433
|
-
|
|
44434
|
-
|
|
44435
|
-
|
|
44436
|
-
|
|
44437
|
-
|
|
44438
|
-
|
|
44439
|
-
|
|
44440
|
-
|
|
44441
|
-
|
|
44442
|
-
|
|
44443
|
-
|
|
44444
|
-
|
|
44445
|
-
|
|
44631
|
+
const charHydration = converterContext ? hydrateCharacterStyleAttrs(para, converterContext, paragraphHydration?.resolved) : null;
|
|
44632
|
+
if (charHydration) {
|
|
44633
|
+
const fontSizePx = charHydration.fontSize / HALF_POINTS_PER_POINT * (SCREEN_DPI / POINT_DPI);
|
|
44634
|
+
baseRunDefaults = {
|
|
44635
|
+
fontFamily: charHydration.fontFamily,
|
|
44636
|
+
fontSizePx,
|
|
44637
|
+
color: charHydration.color ? `#${charHydration.color.replace("#", "")}` : void 0,
|
|
44638
|
+
bold: charHydration.bold,
|
|
44639
|
+
italic: charHydration.italic,
|
|
44640
|
+
underline: charHydration.underline ? {
|
|
44641
|
+
style: charHydration.underline.type,
|
|
44642
|
+
color: charHydration.underline.color
|
|
44643
|
+
} : void 0,
|
|
44644
|
+
letterSpacing: charHydration.letterSpacing != null ? twipsToPx$1(charHydration.letterSpacing) : void 0
|
|
44645
|
+
};
|
|
44646
|
+
} else {
|
|
44647
|
+
const spacingSource = para.attrs?.spacing !== void 0 ? para.attrs.spacing : paragraphProps.spacing !== void 0 ? paragraphProps.spacing : paragraphHydration?.spacing;
|
|
44648
|
+
const indentSource = para.attrs?.indent ?? paragraphProps.indent ?? paragraphHydration?.indent;
|
|
44649
|
+
const normalizedSpacing = normalizeParagraphSpacing(spacingSource);
|
|
44650
|
+
const normalizedIndent = normalizePxIndent(indentSource) ?? normalizeParagraphIndent(indentSource ?? para.attrs?.textIndent);
|
|
44651
|
+
const styleNodeAttrs = paragraphHydration?.tabStops && !para.attrs?.tabStops && !para.attrs?.tabs ? { ...para.attrs ?? {}, tabStops: paragraphHydration.tabStops } : para.attrs ?? {};
|
|
44652
|
+
const styleNode = buildStyleNodeFromAttrs(styleNodeAttrs, normalizedSpacing, normalizedIndent);
|
|
44653
|
+
if (styleNodeAttrs.styleId == null && paragraphProps.styleId) {
|
|
44654
|
+
styleNode.styleId = paragraphProps.styleId;
|
|
44655
|
+
}
|
|
44656
|
+
const resolved = resolveStyle(styleNode, styleContext);
|
|
44657
|
+
baseRunDefaults = {
|
|
44658
|
+
fontFamily: resolved.character.font?.family,
|
|
44659
|
+
fontSizePx: ptToPx(resolved.character.font?.size),
|
|
44660
|
+
color: resolved.character.color,
|
|
44661
|
+
bold: resolved.character.font?.weight != null ? resolved.character.font.weight >= 600 : void 0,
|
|
44662
|
+
italic: resolved.character.font?.italic,
|
|
44663
|
+
underline: resolved.character.underline ? {
|
|
44664
|
+
style: resolved.character.underline.style,
|
|
44665
|
+
color: resolved.character.underline.color
|
|
44666
|
+
} : void 0,
|
|
44667
|
+
letterSpacing: ptToPx(resolved.character.letterSpacing)
|
|
44668
|
+
};
|
|
44669
|
+
}
|
|
44446
44670
|
} catch {
|
|
44447
44671
|
baseRunDefaults = {};
|
|
44448
44672
|
}
|
|
@@ -47993,7 +48217,8 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
47993
48217
|
const originX = currentLine.width;
|
|
47994
48218
|
const { target, nextIndex, stop } = getNextTabStopPx(currentLine.width, tabStops, tabStopCursor);
|
|
47995
48219
|
tabStopCursor = nextIndex;
|
|
47996
|
-
const
|
|
48220
|
+
const clampedTarget = Math.min(target, currentLine.maxWidth);
|
|
48221
|
+
const tabAdvance = Math.max(0, clampedTarget - currentLine.width);
|
|
47997
48222
|
currentLine.width = roundValue(currentLine.width + tabAdvance);
|
|
47998
48223
|
run.width = tabAdvance;
|
|
47999
48224
|
currentLine.maxFontSize = Math.max(currentLine.maxFontSize, 12);
|
|
@@ -48001,14 +48226,14 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
48001
48226
|
currentLine.toChar = 1;
|
|
48002
48227
|
if (stop) {
|
|
48003
48228
|
validateTabStopVal(stop);
|
|
48004
|
-
pendingTabAlignment = { target, val: stop.val };
|
|
48229
|
+
pendingTabAlignment = { target: clampedTarget, val: stop.val };
|
|
48005
48230
|
} else {
|
|
48006
48231
|
pendingTabAlignment = null;
|
|
48007
48232
|
}
|
|
48008
48233
|
if (stop && stop.leader && stop.leader !== "none") {
|
|
48009
48234
|
const leaderStyle = stop.leader;
|
|
48010
|
-
const from3 = Math.min(originX,
|
|
48011
|
-
const to = Math.max(originX,
|
|
48235
|
+
const from3 = Math.min(originX, clampedTarget);
|
|
48236
|
+
const to = Math.max(originX, clampedTarget);
|
|
48012
48237
|
if (!currentLine.leaders) currentLine.leaders = [];
|
|
48013
48238
|
currentLine.leaders.push({ from: from3, to, style: leaderStyle });
|
|
48014
48239
|
}
|
|
@@ -48603,7 +48828,8 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
48603
48828
|
const originX = currentLine.width;
|
|
48604
48829
|
const { target, nextIndex, stop } = getNextTabStopPx(currentLine.width, tabStops, tabStopCursor);
|
|
48605
48830
|
tabStopCursor = nextIndex;
|
|
48606
|
-
const
|
|
48831
|
+
const clampedTarget = Math.min(target, currentLine.maxWidth);
|
|
48832
|
+
const tabAdvance = Math.max(0, clampedTarget - currentLine.width);
|
|
48607
48833
|
currentLine.width = roundValue(currentLine.width + tabAdvance);
|
|
48608
48834
|
currentLine.maxFontInfo = updateMaxFontInfo(currentLine.maxFontSize, currentLine.maxFontInfo, run);
|
|
48609
48835
|
currentLine.maxFontSize = Math.max(currentLine.maxFontSize, run.fontSize);
|
|
@@ -48612,14 +48838,14 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
48612
48838
|
charPosInRun += 1;
|
|
48613
48839
|
if (stop) {
|
|
48614
48840
|
validateTabStopVal(stop);
|
|
48615
|
-
pendingTabAlignment = { target, val: stop.val };
|
|
48841
|
+
pendingTabAlignment = { target: clampedTarget, val: stop.val };
|
|
48616
48842
|
} else {
|
|
48617
48843
|
pendingTabAlignment = null;
|
|
48618
48844
|
}
|
|
48619
48845
|
if (stop && stop.leader && stop.leader !== "none" && stop.leader !== "middleDot") {
|
|
48620
48846
|
const leaderStyle = stop.leader;
|
|
48621
|
-
const from3 = Math.min(originX,
|
|
48622
|
-
const to = Math.max(originX,
|
|
48847
|
+
const from3 = Math.min(originX, clampedTarget);
|
|
48848
|
+
const to = Math.max(originX, clampedTarget);
|
|
48623
48849
|
if (!currentLine.leaders) currentLine.leaders = [];
|
|
48624
48850
|
currentLine.leaders.push({ from: from3, to, style: leaderStyle });
|
|
48625
48851
|
}
|
|
@@ -57175,16 +57401,112 @@ const mapRangesThroughTransactions = (ranges, transactions, docSize) => {
|
|
|
57175
57401
|
});
|
|
57176
57402
|
return mergeRanges$2(mapped, docSize);
|
|
57177
57403
|
};
|
|
57178
|
-
const
|
|
57404
|
+
const getParagraphAtPos = (doc2, pos) => {
|
|
57405
|
+
try {
|
|
57406
|
+
const $pos = doc2.resolve(pos);
|
|
57407
|
+
for (let depth = $pos.depth; depth >= 0; depth--) {
|
|
57408
|
+
const node = $pos.node(depth);
|
|
57409
|
+
if (node.type.name === "paragraph") {
|
|
57410
|
+
return node;
|
|
57411
|
+
}
|
|
57412
|
+
}
|
|
57413
|
+
} catch (_e) {
|
|
57414
|
+
}
|
|
57415
|
+
return null;
|
|
57416
|
+
};
|
|
57417
|
+
const resolveRunPropertiesFromParagraphStyle = (paragraphNode, editor) => {
|
|
57418
|
+
if (!paragraphNode || !editor?.converter) return {};
|
|
57419
|
+
const styleId = paragraphNode.attrs?.paragraphProperties?.styleId;
|
|
57420
|
+
if (!styleId) return {};
|
|
57421
|
+
try {
|
|
57422
|
+
const params2 = { docx: editor.converter.convertedXml, numbering: editor.converter.numbering };
|
|
57423
|
+
const resolvedPpr = { styleId };
|
|
57424
|
+
const runProps = resolveRunProperties(params2, {}, resolvedPpr, false, false);
|
|
57425
|
+
const runProperties = {};
|
|
57426
|
+
if (runProps.fontFamily) {
|
|
57427
|
+
const fontValue = runProps.fontFamily.ascii || runProps.fontFamily;
|
|
57428
|
+
if (fontValue) {
|
|
57429
|
+
runProperties.fontFamily = typeof fontValue === "string" ? fontValue : fontValue.ascii;
|
|
57430
|
+
}
|
|
57431
|
+
}
|
|
57432
|
+
if (runProps.fontSize) {
|
|
57433
|
+
runProperties.fontSize = `${runProps.fontSize / 2}pt`;
|
|
57434
|
+
}
|
|
57435
|
+
if (runProps.bold) runProperties.bold = true;
|
|
57436
|
+
if (runProps.italic) runProperties.italic = true;
|
|
57437
|
+
if (runProps.underline) runProperties.underline = runProps.underline;
|
|
57438
|
+
if (runProps.strike) runProperties.strike = true;
|
|
57439
|
+
return runProperties;
|
|
57440
|
+
} catch (_e) {
|
|
57441
|
+
return {};
|
|
57442
|
+
}
|
|
57443
|
+
};
|
|
57444
|
+
const createMarksFromDefs = (schema, markDefs = []) => markDefs.map((def) => {
|
|
57445
|
+
const markType = schema.marks[def.type];
|
|
57446
|
+
return markType ? markType.create(def.attrs) : null;
|
|
57447
|
+
}).filter(Boolean);
|
|
57448
|
+
const createMarkDefsFromStyleRunProps = (styleRunProps) => {
|
|
57449
|
+
const markDefs = [];
|
|
57450
|
+
const textStyleAttrs = {};
|
|
57451
|
+
if (styleRunProps.fontSize) {
|
|
57452
|
+
textStyleAttrs.fontSize = styleRunProps.fontSize;
|
|
57453
|
+
}
|
|
57454
|
+
if (styleRunProps.fontFamily) {
|
|
57455
|
+
textStyleAttrs.fontFamily = styleRunProps.fontFamily;
|
|
57456
|
+
}
|
|
57457
|
+
if (Object.keys(textStyleAttrs).length > 0) {
|
|
57458
|
+
markDefs.push({ type: "textStyle", attrs: textStyleAttrs });
|
|
57459
|
+
}
|
|
57460
|
+
if (styleRunProps.bold) {
|
|
57461
|
+
markDefs.push({ type: "bold", attrs: { value: true } });
|
|
57462
|
+
}
|
|
57463
|
+
if (styleRunProps.italic) {
|
|
57464
|
+
markDefs.push({ type: "italic", attrs: { value: true } });
|
|
57465
|
+
}
|
|
57466
|
+
if (styleRunProps.strike) {
|
|
57467
|
+
markDefs.push({ type: "strike", attrs: { value: true } });
|
|
57468
|
+
}
|
|
57469
|
+
if (styleRunProps.underline) {
|
|
57470
|
+
const underlineType = styleRunProps.underline["w:val"];
|
|
57471
|
+
if (underlineType) {
|
|
57472
|
+
let underlineColor = styleRunProps.underline["w:color"];
|
|
57473
|
+
if (underlineColor && underlineColor.toLowerCase() !== "auto" && !underlineColor.startsWith("#")) {
|
|
57474
|
+
underlineColor = `#${underlineColor}`;
|
|
57475
|
+
}
|
|
57476
|
+
markDefs.push({
|
|
57477
|
+
type: "underline",
|
|
57478
|
+
attrs: { underlineType, underlineColor }
|
|
57479
|
+
});
|
|
57480
|
+
}
|
|
57481
|
+
}
|
|
57482
|
+
return markDefs;
|
|
57483
|
+
};
|
|
57484
|
+
const buildWrapTransaction = (state, ranges, runType, editor, markDefsFromMeta = []) => {
|
|
57179
57485
|
if (!ranges.length) return null;
|
|
57180
57486
|
const replacements = [];
|
|
57487
|
+
const metaStyleMarks = createMarksFromDefs(state.schema, markDefsFromMeta);
|
|
57181
57488
|
ranges.forEach(({ from: from3, to }) => {
|
|
57182
57489
|
state.doc.nodesBetween(from3, to, (node, pos, parent, index2) => {
|
|
57183
57490
|
if (!node.isText || !parent || parent.type === runType) return;
|
|
57184
57491
|
const match = parent.contentMatchAt ? parent.contentMatchAt(index2) : null;
|
|
57185
57492
|
if (match && !match.matchType(runType)) return;
|
|
57186
57493
|
if (!match && !parent.type.contentMatch.matchType(runType)) return;
|
|
57187
|
-
|
|
57494
|
+
let runProperties = decodeRPrFromMarks(node.marks);
|
|
57495
|
+
if ((!node.marks || node.marks.length === 0) && editor?.converter) {
|
|
57496
|
+
const paragraphNode = getParagraphAtPos(state.doc, pos);
|
|
57497
|
+
const styleRunProps = resolveRunPropertiesFromParagraphStyle(paragraphNode, editor);
|
|
57498
|
+
if (Object.keys(styleRunProps).length > 0) {
|
|
57499
|
+
runProperties = styleRunProps;
|
|
57500
|
+
const markDefs = metaStyleMarks.length ? markDefsFromMeta : createMarkDefsFromStyleRunProps(styleRunProps);
|
|
57501
|
+
const styleMarks = metaStyleMarks.length ? metaStyleMarks : createMarksFromDefs(state.schema, markDefs);
|
|
57502
|
+
if (styleMarks.length && typeof state.schema.text === "function") {
|
|
57503
|
+
const textNode = state.schema.text(node.text || "", styleMarks);
|
|
57504
|
+
if (textNode) {
|
|
57505
|
+
node = textNode;
|
|
57506
|
+
}
|
|
57507
|
+
}
|
|
57508
|
+
}
|
|
57509
|
+
}
|
|
57188
57510
|
const runNode = runType.create({ runProperties }, node);
|
|
57189
57511
|
replacements.push({ from: pos, to: pos + node.nodeSize, runNode });
|
|
57190
57512
|
});
|
|
@@ -57194,9 +57516,10 @@ const buildWrapTransaction = (state, ranges, runType) => {
|
|
|
57194
57516
|
replacements.sort((a, b) => b.from - a.from).forEach(({ from: from3, to, runNode }) => tr.replaceWith(from3, to, runNode));
|
|
57195
57517
|
return tr.docChanged ? tr : null;
|
|
57196
57518
|
};
|
|
57197
|
-
const wrapTextInRunsPlugin = () => {
|
|
57519
|
+
const wrapTextInRunsPlugin = (editor) => {
|
|
57198
57520
|
let view = null;
|
|
57199
57521
|
let pendingRanges = [];
|
|
57522
|
+
let lastStyleMarksMeta = [];
|
|
57200
57523
|
const flush = () => {
|
|
57201
57524
|
if (!view) return;
|
|
57202
57525
|
const runType = view.state.schema.nodes.run;
|
|
@@ -57204,7 +57527,7 @@ const wrapTextInRunsPlugin = () => {
|
|
|
57204
57527
|
pendingRanges = [];
|
|
57205
57528
|
return;
|
|
57206
57529
|
}
|
|
57207
|
-
const tr = buildWrapTransaction(view.state, pendingRanges, runType);
|
|
57530
|
+
const tr = buildWrapTransaction(view.state, pendingRanges, runType, editor, lastStyleMarksMeta);
|
|
57208
57531
|
pendingRanges = [];
|
|
57209
57532
|
if (tr) {
|
|
57210
57533
|
view.dispatch(tr);
|
|
@@ -57223,6 +57546,7 @@ const wrapTextInRunsPlugin = () => {
|
|
|
57223
57546
|
editorView.dom.removeEventListener("compositionend", onCompositionEnd);
|
|
57224
57547
|
view = null;
|
|
57225
57548
|
pendingRanges = [];
|
|
57549
|
+
lastStyleMarksMeta = [];
|
|
57226
57550
|
}
|
|
57227
57551
|
};
|
|
57228
57552
|
},
|
|
@@ -57236,7 +57560,11 @@ const wrapTextInRunsPlugin = () => {
|
|
|
57236
57560
|
if (view?.composing) {
|
|
57237
57561
|
return null;
|
|
57238
57562
|
}
|
|
57239
|
-
const
|
|
57563
|
+
const latestStyleMarksMeta = [...transactions].reverse().find((tr2) => tr2.getMeta && tr2.getMeta("sdStyleMarks"))?.getMeta("sdStyleMarks") || lastStyleMarksMeta;
|
|
57564
|
+
if (latestStyleMarksMeta && latestStyleMarksMeta.length) {
|
|
57565
|
+
lastStyleMarksMeta = latestStyleMarksMeta;
|
|
57566
|
+
}
|
|
57567
|
+
const tr = buildWrapTransaction(newState, pendingRanges, runType, editor, latestStyleMarksMeta);
|
|
57240
57568
|
pendingRanges = [];
|
|
57241
57569
|
return tr;
|
|
57242
57570
|
}
|
|
@@ -57499,7 +57827,7 @@ const Run = OxmlNode.create({
|
|
|
57499
57827
|
},
|
|
57500
57828
|
addPmPlugins() {
|
|
57501
57829
|
return [
|
|
57502
|
-
wrapTextInRunsPlugin(),
|
|
57830
|
+
wrapTextInRunsPlugin(this.editor),
|
|
57503
57831
|
splitRunsAfterMarkPlugin,
|
|
57504
57832
|
calculateInlineRunPropertiesPlugin(this.editor),
|
|
57505
57833
|
cleanupEmptyRunsPlugin
|