@harbour-enterprises/superdoc 1.3.0-next.2 → 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-BEZc2jzN.cjs → PdfViewer-D6XxSIuw.cjs} +2 -2
- package/dist/chunks/{PdfViewer-BpbDm_Oh.es.js → PdfViewer-ltwzoe73.es.js} +2 -2
- package/dist/chunks/{SuperConverter-ClzyObj7.es.js → SuperConverter-CVOKZex3.es.js} +294 -192
- package/dist/chunks/{SuperConverter-DOTz2R8L.cjs → SuperConverter-XGlv5pME.cjs} +261 -159
- package/dist/chunks/{index-C2XLSjq0.cjs → index-D0lYfjMI.cjs} +746 -432
- package/dist/chunks/{index-sykfrKvQ.cjs → index-HQW67fDU.cjs} +4 -4
- package/dist/chunks/{index-D5tN0eME.es.js → index-M8MvGhiF.es.js} +746 -432
- package/dist/chunks/{index-CMxyLpsU.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 +1010 -598
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +3 -3
|
@@ -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");
|
|
@@ -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;
|
|
@@ -39703,7 +40051,7 @@ const pxToPt = (px) => {
|
|
|
39703
40051
|
return px / PX_PER_PT;
|
|
39704
40052
|
};
|
|
39705
40053
|
const isFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value);
|
|
39706
|
-
const isPlainObject$
|
|
40054
|
+
const isPlainObject$2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
39707
40055
|
const normalizePrefix = (value) => {
|
|
39708
40056
|
if (!value) return "";
|
|
39709
40057
|
return String(value);
|
|
@@ -39765,7 +40113,7 @@ function coerceBoolean(value) {
|
|
|
39765
40113
|
}
|
|
39766
40114
|
return void 0;
|
|
39767
40115
|
}
|
|
39768
|
-
const toBoolean$
|
|
40116
|
+
const toBoolean$2 = (value) => {
|
|
39769
40117
|
if (typeof value === "boolean") return value;
|
|
39770
40118
|
if (typeof value === "string") {
|
|
39771
40119
|
const v = value.trim().toLowerCase();
|
|
@@ -40056,7 +40404,7 @@ function hydrateImageBlocks(blocks, mediaFiles) {
|
|
|
40056
40404
|
});
|
|
40057
40405
|
}
|
|
40058
40406
|
function isGradientFill(value) {
|
|
40059
|
-
if (!isPlainObject$
|
|
40407
|
+
if (!isPlainObject$2(value)) return false;
|
|
40060
40408
|
if (value.type !== "gradient") return false;
|
|
40061
40409
|
const gradientType = value.gradientType;
|
|
40062
40410
|
if (gradientType !== "linear" && gradientType !== "radial") return false;
|
|
@@ -40067,12 +40415,12 @@ function isGradientFill(value) {
|
|
|
40067
40415
|
}
|
|
40068
40416
|
if (!Array.isArray(value.stops) || value.stops.length === 0) return false;
|
|
40069
40417
|
return value.stops.every((stop) => {
|
|
40070
|
-
if (!isPlainObject$
|
|
40418
|
+
if (!isPlainObject$2(stop)) return false;
|
|
40071
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));
|
|
40072
40420
|
});
|
|
40073
40421
|
}
|
|
40074
40422
|
function isSolidFillWithAlpha(value) {
|
|
40075
|
-
return isPlainObject$
|
|
40423
|
+
return isPlainObject$2(value) && value.type === "solidWithAlpha" && typeof value.color === "string" && typeof value.alpha === "number";
|
|
40076
40424
|
}
|
|
40077
40425
|
function normalizeFillColor(value) {
|
|
40078
40426
|
if (value === null) return null;
|
|
@@ -40087,10 +40435,10 @@ function normalizeStrokeColor(value) {
|
|
|
40087
40435
|
return void 0;
|
|
40088
40436
|
}
|
|
40089
40437
|
function normalizeTextContent(value) {
|
|
40090
|
-
if (!isPlainObject$
|
|
40438
|
+
if (!isPlainObject$2(value)) return void 0;
|
|
40091
40439
|
if (!Array.isArray(value.parts)) return void 0;
|
|
40092
40440
|
if (value.parts.length === 0) return void 0;
|
|
40093
|
-
const validParts = value.parts.filter((p) => isPlainObject$
|
|
40441
|
+
const validParts = value.parts.filter((p) => isPlainObject$2(p) && typeof p.text === "string");
|
|
40094
40442
|
if (validParts.length === 0) return void 0;
|
|
40095
40443
|
const result = {
|
|
40096
40444
|
parts: validParts
|
|
@@ -40108,7 +40456,7 @@ function normalizeTextVerticalAlign(value) {
|
|
|
40108
40456
|
return void 0;
|
|
40109
40457
|
}
|
|
40110
40458
|
function normalizeTextInsets(value) {
|
|
40111
|
-
if (!isPlainObject$
|
|
40459
|
+
if (!isPlainObject$2(value)) return void 0;
|
|
40112
40460
|
const top2 = pickNumber(value.top);
|
|
40113
40461
|
const right2 = pickNumber(value.right);
|
|
40114
40462
|
const bottom2 = pickNumber(value.bottom);
|
|
@@ -40120,7 +40468,7 @@ function normalizeTextInsets(value) {
|
|
|
40120
40468
|
}
|
|
40121
40469
|
const OOXML_Z_INDEX_BASE = 251658240;
|
|
40122
40470
|
function normalizeZIndex(originalAttributes) {
|
|
40123
|
-
if (!isPlainObject$
|
|
40471
|
+
if (!isPlainObject$2(originalAttributes)) return void 0;
|
|
40124
40472
|
const relativeHeight = originalAttributes.relativeHeight;
|
|
40125
40473
|
if (typeof relativeHeight !== "number") return void 0;
|
|
40126
40474
|
return Math.max(0, relativeHeight - OOXML_Z_INDEX_BASE);
|
|
@@ -41314,321 +41662,6 @@ const ensureBidiIndentPx = (indent) => {
|
|
|
41314
41662
|
}
|
|
41315
41663
|
return adjusted;
|
|
41316
41664
|
};
|
|
41317
|
-
const sdtMetadataCache = /* @__PURE__ */ new Map();
|
|
41318
|
-
function resolveStyle(node, context, options = {}) {
|
|
41319
|
-
let paragraph = createDefaultParagraph();
|
|
41320
|
-
let character = createDefaultCharacter(context);
|
|
41321
|
-
let numbering;
|
|
41322
|
-
const chain = resolveStyleChain(node.styleId, context.styles);
|
|
41323
|
-
for (const style2 of chain) {
|
|
41324
|
-
paragraph = mergeParagraph(paragraph, style2.paragraph);
|
|
41325
|
-
character = mergeCharacter(character, style2.character);
|
|
41326
|
-
if (!numbering && style2.numbering) {
|
|
41327
|
-
numbering = resolveNumbering(style2.numbering.numId, style2.numbering.level, context);
|
|
41328
|
-
}
|
|
41329
|
-
}
|
|
41330
|
-
paragraph = mergeParagraph(paragraph, node.paragraphProps);
|
|
41331
|
-
character = mergeCharacter(character, node.characterProps);
|
|
41332
|
-
if (node.numbering) {
|
|
41333
|
-
numbering = resolveNumbering(node.numbering.numId, node.numbering.level, context);
|
|
41334
|
-
}
|
|
41335
|
-
const sdt = options?.sdt ? resolveSdtMetadata(options.sdt) : void 0;
|
|
41336
|
-
return {
|
|
41337
|
-
paragraph,
|
|
41338
|
-
character,
|
|
41339
|
-
numbering,
|
|
41340
|
-
sdt
|
|
41341
|
-
};
|
|
41342
|
-
}
|
|
41343
|
-
function resolveNumbering(numId, level, context) {
|
|
41344
|
-
const def = context.numbering?.[numId];
|
|
41345
|
-
if (!def) return void 0;
|
|
41346
|
-
const levelDef = def.levels.find((entry) => entry.level === level) ?? def.levels[level];
|
|
41347
|
-
if (!levelDef) return void 0;
|
|
41348
|
-
return {
|
|
41349
|
-
numId,
|
|
41350
|
-
level,
|
|
41351
|
-
indent: {
|
|
41352
|
-
left: levelDef.indent?.left,
|
|
41353
|
-
hanging: levelDef.indent?.hanging
|
|
41354
|
-
},
|
|
41355
|
-
format: levelDef.format ?? "decimal",
|
|
41356
|
-
text: levelDef.text ?? "%1.",
|
|
41357
|
-
start: levelDef.start ?? 1
|
|
41358
|
-
};
|
|
41359
|
-
}
|
|
41360
|
-
function resolveSdtMetadata(input) {
|
|
41361
|
-
if (!input) return void 0;
|
|
41362
|
-
const { nodeType, attrs, cacheKey: explicitKey } = input;
|
|
41363
|
-
if (!nodeType) return void 0;
|
|
41364
|
-
const normalizedAttrs = isPlainObject$2(attrs) ? attrs : {};
|
|
41365
|
-
const cacheKey = buildSdtCacheKey(nodeType, normalizedAttrs, explicitKey);
|
|
41366
|
-
if (cacheKey && sdtMetadataCache.has(cacheKey)) {
|
|
41367
|
-
return sdtMetadataCache.get(cacheKey);
|
|
41368
|
-
}
|
|
41369
|
-
let metadata;
|
|
41370
|
-
switch (nodeType) {
|
|
41371
|
-
case "fieldAnnotation":
|
|
41372
|
-
metadata = normalizeFieldAnnotationMetadata(normalizedAttrs);
|
|
41373
|
-
break;
|
|
41374
|
-
case "structuredContent":
|
|
41375
|
-
case "structuredContentBlock":
|
|
41376
|
-
metadata = normalizeStructuredContentMetadata(nodeType, normalizedAttrs);
|
|
41377
|
-
break;
|
|
41378
|
-
case "documentSection":
|
|
41379
|
-
metadata = normalizeDocumentSectionMetadata(normalizedAttrs);
|
|
41380
|
-
break;
|
|
41381
|
-
case "docPartObject":
|
|
41382
|
-
metadata = normalizeDocPartMetadata(normalizedAttrs);
|
|
41383
|
-
break;
|
|
41384
|
-
}
|
|
41385
|
-
if (metadata && cacheKey) {
|
|
41386
|
-
sdtMetadataCache.set(cacheKey, metadata);
|
|
41387
|
-
}
|
|
41388
|
-
return metadata;
|
|
41389
|
-
}
|
|
41390
|
-
function createDefaultParagraph(_context) {
|
|
41391
|
-
return {
|
|
41392
|
-
alignment: "left",
|
|
41393
|
-
spacing: {
|
|
41394
|
-
before: 0,
|
|
41395
|
-
after: 0,
|
|
41396
|
-
line: 12,
|
|
41397
|
-
lineRule: "auto"
|
|
41398
|
-
},
|
|
41399
|
-
indent: {
|
|
41400
|
-
left: 0,
|
|
41401
|
-
right: 0,
|
|
41402
|
-
firstLine: 0,
|
|
41403
|
-
hanging: 0
|
|
41404
|
-
},
|
|
41405
|
-
tabs: []
|
|
41406
|
-
};
|
|
41407
|
-
}
|
|
41408
|
-
function createDefaultCharacter(context) {
|
|
41409
|
-
const baseFont = context.defaults?.paragraphFont ?? "Calibri";
|
|
41410
|
-
const fallback = context.defaults?.paragraphFontFallback;
|
|
41411
|
-
const wordFamily = context.defaults?.paragraphFontFamily;
|
|
41412
|
-
const resolvedFamily = toCssFontFamily(baseFont, { fallback, wordFamily }) ?? baseFont;
|
|
41413
|
-
return {
|
|
41414
|
-
font: {
|
|
41415
|
-
family: resolvedFamily,
|
|
41416
|
-
size: context.defaults?.fontSize ?? 11,
|
|
41417
|
-
weight: 400,
|
|
41418
|
-
italic: false
|
|
41419
|
-
},
|
|
41420
|
-
color: "#000000"
|
|
41421
|
-
};
|
|
41422
|
-
}
|
|
41423
|
-
function resolveStyleChain(styleId, styles) {
|
|
41424
|
-
if (!styleId || !styles) return [];
|
|
41425
|
-
const result = [];
|
|
41426
|
-
const visited = /* @__PURE__ */ new Set();
|
|
41427
|
-
let current = styles[styleId];
|
|
41428
|
-
while (current && !visited.has(current.id)) {
|
|
41429
|
-
result.unshift(current);
|
|
41430
|
-
visited.add(current.id);
|
|
41431
|
-
current = current.basedOn ? styles[current.basedOn] : void 0;
|
|
41432
|
-
}
|
|
41433
|
-
return result;
|
|
41434
|
-
}
|
|
41435
|
-
function mergeParagraph(base2, overrides) {
|
|
41436
|
-
if (!overrides) return base2;
|
|
41437
|
-
return {
|
|
41438
|
-
...base2,
|
|
41439
|
-
alignment: overrides.alignment ?? base2.alignment,
|
|
41440
|
-
spacing: overrides.spacing ? { ...base2.spacing, ...overrides.spacing } : base2.spacing,
|
|
41441
|
-
indent: overrides.indent ? { ...base2.indent, ...overrides.indent } : base2.indent,
|
|
41442
|
-
borders: overrides.borders ? { ...base2.borders, ...overrides.borders } : base2.borders,
|
|
41443
|
-
shading: overrides.shading ?? base2.shading,
|
|
41444
|
-
tabs: overrides.tabs ?? base2.tabs
|
|
41445
|
-
};
|
|
41446
|
-
}
|
|
41447
|
-
function mergeCharacter(base2, overrides) {
|
|
41448
|
-
if (!overrides) return base2;
|
|
41449
|
-
return {
|
|
41450
|
-
...base2,
|
|
41451
|
-
font: overrides.font ? { ...base2.font, ...overrides.font } : base2.font,
|
|
41452
|
-
color: overrides.color ?? base2.color,
|
|
41453
|
-
underline: overrides.underline ?? base2.underline,
|
|
41454
|
-
strike: overrides.strike ?? base2.strike,
|
|
41455
|
-
highlight: overrides.highlight ?? base2.highlight,
|
|
41456
|
-
letterSpacing: overrides.letterSpacing ?? base2.letterSpacing
|
|
41457
|
-
};
|
|
41458
|
-
}
|
|
41459
|
-
function normalizeFieldAnnotationMetadata(attrs) {
|
|
41460
|
-
const fieldId = toOptionalString(attrs.fieldId) ?? "";
|
|
41461
|
-
const formatting = extractFormatting(attrs);
|
|
41462
|
-
const size2 = normalizeSize(attrs.size);
|
|
41463
|
-
const extras = isPlainObject$2(attrs.extras) ? attrs.extras : null;
|
|
41464
|
-
const marks = isPlainObject$2(attrs.marks) ? attrs.marks : void 0;
|
|
41465
|
-
return {
|
|
41466
|
-
type: "fieldAnnotation",
|
|
41467
|
-
fieldId,
|
|
41468
|
-
variant: normalizeFieldAnnotationVariant(attrs.type),
|
|
41469
|
-
fieldType: toOptionalString(attrs.fieldType),
|
|
41470
|
-
displayLabel: toOptionalString(attrs.displayLabel),
|
|
41471
|
-
defaultDisplayLabel: toOptionalString(attrs.defaultDisplayLabel),
|
|
41472
|
-
alias: toOptionalString(attrs.alias),
|
|
41473
|
-
fieldColor: normalizeColorValue(attrs.fieldColor),
|
|
41474
|
-
borderColor: normalizeColorValue(attrs.borderColor),
|
|
41475
|
-
highlighted: toBoolean$2(attrs.highlighted, true),
|
|
41476
|
-
fontFamily: toNullableString(attrs.fontFamily),
|
|
41477
|
-
fontSize: normalizeFontSize(attrs.fontSize),
|
|
41478
|
-
textColor: normalizeColorValue(attrs.textColor) ?? null,
|
|
41479
|
-
textHighlight: normalizeColorValue(attrs.textHighlight) ?? null,
|
|
41480
|
-
linkUrl: toNullableString(attrs.linkUrl),
|
|
41481
|
-
imageSrc: toNullableString(attrs.imageSrc),
|
|
41482
|
-
rawHtml: attrs.rawHtml ?? void 0,
|
|
41483
|
-
size: size2 ?? null,
|
|
41484
|
-
extras,
|
|
41485
|
-
multipleImage: toBoolean$2(attrs.multipleImage, false),
|
|
41486
|
-
hash: toOptionalString(attrs.hash) ?? null,
|
|
41487
|
-
generatorIndex: toNumber(attrs.generatorIndex),
|
|
41488
|
-
sdtId: toOptionalString(attrs.sdtId) ?? null,
|
|
41489
|
-
hidden: toBoolean$2(attrs.hidden, false),
|
|
41490
|
-
visibility: normalizeVisibility(attrs.visibility),
|
|
41491
|
-
isLocked: toBoolean$2(attrs.isLocked, false),
|
|
41492
|
-
formatting,
|
|
41493
|
-
marks
|
|
41494
|
-
};
|
|
41495
|
-
}
|
|
41496
|
-
function normalizeStructuredContentMetadata(nodeType, attrs) {
|
|
41497
|
-
return {
|
|
41498
|
-
type: "structuredContent",
|
|
41499
|
-
scope: nodeType === "structuredContentBlock" ? "block" : "inline",
|
|
41500
|
-
id: toNullableString(attrs.id),
|
|
41501
|
-
tag: toOptionalString(attrs.tag),
|
|
41502
|
-
alias: toOptionalString(attrs.alias),
|
|
41503
|
-
sdtPr: attrs.sdtPr
|
|
41504
|
-
};
|
|
41505
|
-
}
|
|
41506
|
-
function normalizeDocumentSectionMetadata(attrs) {
|
|
41507
|
-
return {
|
|
41508
|
-
type: "documentSection",
|
|
41509
|
-
id: toNullableString(attrs.id),
|
|
41510
|
-
title: toOptionalString(attrs.title) ?? null,
|
|
41511
|
-
description: toOptionalString(attrs.description) ?? null,
|
|
41512
|
-
sectionType: toOptionalString(attrs.sectionType) ?? null,
|
|
41513
|
-
isLocked: toBoolean$2(attrs.isLocked, false),
|
|
41514
|
-
sdBlockId: toNullableString(attrs.sdBlockId)
|
|
41515
|
-
};
|
|
41516
|
-
}
|
|
41517
|
-
function normalizeDocPartMetadata(attrs) {
|
|
41518
|
-
return {
|
|
41519
|
-
type: "docPartObject",
|
|
41520
|
-
gallery: toOptionalString(attrs.docPartGallery ?? attrs.gallery) ?? null,
|
|
41521
|
-
// Source uniqueId from attrs.id (PM adapter uses getDocPartObjectId which extracts attrs.id)
|
|
41522
|
-
// Fall back to attrs.uniqueId for compatibility
|
|
41523
|
-
uniqueId: toOptionalString(attrs.id ?? attrs.uniqueId) ?? null,
|
|
41524
|
-
alias: toOptionalString(attrs.alias) ?? null,
|
|
41525
|
-
instruction: toOptionalString(attrs.instruction) ?? null
|
|
41526
|
-
};
|
|
41527
|
-
}
|
|
41528
|
-
function isPlainObject$2(value) {
|
|
41529
|
-
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
41530
|
-
}
|
|
41531
|
-
function toOptionalString(value) {
|
|
41532
|
-
if (value == null) return void 0;
|
|
41533
|
-
if (typeof value === "string") {
|
|
41534
|
-
const trimmed = value.trim();
|
|
41535
|
-
return trimmed.length ? trimmed : void 0;
|
|
41536
|
-
}
|
|
41537
|
-
return String(value);
|
|
41538
|
-
}
|
|
41539
|
-
function toNullableString(value) {
|
|
41540
|
-
const str = toOptionalString(value);
|
|
41541
|
-
return str ?? null;
|
|
41542
|
-
}
|
|
41543
|
-
function toBoolean$2(value, fallback) {
|
|
41544
|
-
if (typeof value === "boolean") return value;
|
|
41545
|
-
if (typeof value === "string") {
|
|
41546
|
-
const lower = value.toLowerCase();
|
|
41547
|
-
if (lower === "true") return true;
|
|
41548
|
-
if (lower === "false") return false;
|
|
41549
|
-
}
|
|
41550
|
-
if (value == null) return fallback;
|
|
41551
|
-
return Boolean(value);
|
|
41552
|
-
}
|
|
41553
|
-
function normalizeVisibility(value) {
|
|
41554
|
-
if (typeof value !== "string") return void 0;
|
|
41555
|
-
const normalized = value.toLowerCase();
|
|
41556
|
-
if (normalized === "visible" || normalized === "hidden") {
|
|
41557
|
-
return normalized;
|
|
41558
|
-
}
|
|
41559
|
-
return void 0;
|
|
41560
|
-
}
|
|
41561
|
-
function normalizeColorValue(value) {
|
|
41562
|
-
if (typeof value !== "string") return void 0;
|
|
41563
|
-
const trimmed = value.trim();
|
|
41564
|
-
if (!trimmed || trimmed.toLowerCase() === "none") return void 0;
|
|
41565
|
-
return trimmed;
|
|
41566
|
-
}
|
|
41567
|
-
function normalizeFontSize(value) {
|
|
41568
|
-
if (value == null) return null;
|
|
41569
|
-
if (typeof value === "number") {
|
|
41570
|
-
return Number.isFinite(value) ? value : null;
|
|
41571
|
-
}
|
|
41572
|
-
if (typeof value === "string") {
|
|
41573
|
-
const trimmed = value.trim();
|
|
41574
|
-
return trimmed.length ? trimmed : null;
|
|
41575
|
-
}
|
|
41576
|
-
return null;
|
|
41577
|
-
}
|
|
41578
|
-
function toNumber(value) {
|
|
41579
|
-
if (typeof value === "number") {
|
|
41580
|
-
return Number.isFinite(value) ? value : null;
|
|
41581
|
-
}
|
|
41582
|
-
if (typeof value === "string") {
|
|
41583
|
-
const parsed = parseFloat(value);
|
|
41584
|
-
return Number.isFinite(parsed) ? parsed : null;
|
|
41585
|
-
}
|
|
41586
|
-
return null;
|
|
41587
|
-
}
|
|
41588
|
-
function normalizeSize(value) {
|
|
41589
|
-
if (!isPlainObject$2(value)) return null;
|
|
41590
|
-
const obj = value;
|
|
41591
|
-
const width = toNumber(obj.width);
|
|
41592
|
-
const height = toNumber(obj.height);
|
|
41593
|
-
if (width == null && height == null) return null;
|
|
41594
|
-
const result = {};
|
|
41595
|
-
if (width != null) result.width = width;
|
|
41596
|
-
if (height != null) result.height = height;
|
|
41597
|
-
return result;
|
|
41598
|
-
}
|
|
41599
|
-
function normalizeFieldAnnotationVariant(value) {
|
|
41600
|
-
if (typeof value !== "string") return void 0;
|
|
41601
|
-
const normalized = value.toLowerCase();
|
|
41602
|
-
if (normalized === "text" || normalized === "image" || normalized === "signature" || normalized === "checkbox" || normalized === "html" || normalized === "link") {
|
|
41603
|
-
return normalized;
|
|
41604
|
-
}
|
|
41605
|
-
return void 0;
|
|
41606
|
-
}
|
|
41607
|
-
function extractFormatting(attrs) {
|
|
41608
|
-
const bold = toBoolean$2(attrs.bold, false);
|
|
41609
|
-
const italic = toBoolean$2(attrs.italic, false);
|
|
41610
|
-
const underline = toBoolean$2(attrs.underline, false);
|
|
41611
|
-
const formatting = {};
|
|
41612
|
-
if (bold) formatting.bold = true;
|
|
41613
|
-
if (italic) formatting.italic = true;
|
|
41614
|
-
if (underline) formatting.underline = true;
|
|
41615
|
-
return Object.keys(formatting).length ? formatting : void 0;
|
|
41616
|
-
}
|
|
41617
|
-
function buildSdtCacheKey(nodeType, attrs, explicitKey) {
|
|
41618
|
-
const provided = toOptionalString(explicitKey);
|
|
41619
|
-
if (provided) {
|
|
41620
|
-
return `${nodeType}:${provided}`;
|
|
41621
|
-
}
|
|
41622
|
-
const hash2 = toOptionalString(attrs.hash);
|
|
41623
|
-
if (hash2) {
|
|
41624
|
-
return `${nodeType}:${hash2}`;
|
|
41625
|
-
}
|
|
41626
|
-
const id = toOptionalString(attrs.id);
|
|
41627
|
-
if (id) {
|
|
41628
|
-
return `${nodeType}:${id}`;
|
|
41629
|
-
}
|
|
41630
|
-
return void 0;
|
|
41631
|
-
}
|
|
41632
41665
|
const DEFAULT_LIST_HANGING_PX = 18;
|
|
41633
41666
|
const LIST_MARKER_GAP = 8;
|
|
41634
41667
|
const DEFAULT_BULLET_GLYPH = "•";
|
|
@@ -42188,6 +42221,7 @@ const EMPTY_NUMBERING_CONTEXT = {
|
|
|
42188
42221
|
definitions: {},
|
|
42189
42222
|
abstracts: {}
|
|
42190
42223
|
};
|
|
42224
|
+
const ooxmlResolver = createOoxmlResolver({ pPr: translator, rPr: translator$1 });
|
|
42191
42225
|
const hydrateParagraphStyleAttrs = (para, context, preResolved) => {
|
|
42192
42226
|
if (!hasParagraphStyleContext(context)) {
|
|
42193
42227
|
return null;
|
|
@@ -42215,7 +42249,7 @@ const hydrateParagraphStyleAttrs = (para, context, preResolved) => {
|
|
|
42215
42249
|
// should still get docDefaults spacing from style resolution
|
|
42216
42250
|
numbering: context.numbering ?? EMPTY_NUMBERING_CONTEXT
|
|
42217
42251
|
};
|
|
42218
|
-
const resolved = resolveParagraphProperties(resolverParams, inlineProps);
|
|
42252
|
+
const resolved = ooxmlResolver.resolveParagraphProperties(resolverParams, inlineProps);
|
|
42219
42253
|
if (!resolved) {
|
|
42220
42254
|
return null;
|
|
42221
42255
|
}
|
|
@@ -42270,6 +42304,138 @@ const cloneIfObject = (value) => {
|
|
|
42270
42304
|
}
|
|
42271
42305
|
return { ...value };
|
|
42272
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
|
+
}
|
|
42273
42439
|
const { resolveSpacingIndent } = Engines;
|
|
42274
42440
|
const DEFAULT_DECIMAL_SEPARATOR$2 = ".";
|
|
42275
42441
|
const isValidNumberingId = (numId) => {
|
|
@@ -42785,7 +42951,7 @@ const extractDropCapRunFromParagraph = (para) => {
|
|
|
42785
42951
|
}
|
|
42786
42952
|
return dropCapRun;
|
|
42787
42953
|
};
|
|
42788
|
-
const computeWordLayoutForParagraph = (paragraphAttrs, numberingProps, styleContext,
|
|
42954
|
+
const computeWordLayoutForParagraph = (paragraphAttrs, numberingProps, styleContext, paragraphNode, converterContext, resolvedPpr) => {
|
|
42789
42955
|
if (numberingProps === null) {
|
|
42790
42956
|
return null;
|
|
42791
42957
|
}
|
|
@@ -42823,7 +42989,23 @@ const computeWordLayoutForParagraph = (paragraphAttrs, numberingProps, styleCont
|
|
|
42823
42989
|
spacing: {}
|
|
42824
42990
|
}
|
|
42825
42991
|
};
|
|
42826
|
-
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
|
+
}
|
|
42827
43009
|
if (!markerRun) {
|
|
42828
43010
|
const { character: characterStyle } = resolveStyle({ styleId: paragraphAttrs.styleId }, styleContext);
|
|
42829
43011
|
if (characterStyle) {
|
|
@@ -43144,7 +43326,12 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
|
|
|
43144
43326
|
const numId = numberingProps.numId;
|
|
43145
43327
|
const ilvl = Number.isFinite(numberingProps.ilvl) ? Math.max(0, Math.floor(Number(numberingProps.ilvl))) : 0;
|
|
43146
43328
|
const numericNumId = typeof numId === "number" ? numId : void 0;
|
|
43147
|
-
|
|
43329
|
+
let resolvedLevel;
|
|
43330
|
+
try {
|
|
43331
|
+
resolvedLevel = resolveNumberingFromContext(numId, ilvl, converterContext?.numbering);
|
|
43332
|
+
} catch (error) {
|
|
43333
|
+
resolvedLevel = void 0;
|
|
43334
|
+
}
|
|
43148
43335
|
if (resolvedLevel) {
|
|
43149
43336
|
if (resolvedLevel.format && numberingProps.format == null) {
|
|
43150
43337
|
numberingProps.format = resolvedLevel.format;
|
|
@@ -43205,7 +43392,19 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
|
|
|
43205
43392
|
}
|
|
43206
43393
|
}
|
|
43207
43394
|
}
|
|
43208
|
-
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
|
+
}
|
|
43209
43408
|
if (!wordLayout && enrichedNumberingProps.resolvedLevelIndent) {
|
|
43210
43409
|
const resolvedIndentPx = convertIndentTwipsToPx(enrichedNumberingProps.resolvedLevelIndent);
|
|
43211
43410
|
const baseIndent = resolvedIndentPx ?? enrichedNumberingProps.resolvedLevelIndent;
|
|
@@ -43750,7 +43949,7 @@ const V_RELATIVE_VALUES$1 = /* @__PURE__ */ new Set(["paragraph", "page", "margi
|
|
|
43750
43949
|
const H_ALIGN_VALUES$1 = /* @__PURE__ */ new Set(["left", "center", "right"]);
|
|
43751
43950
|
const V_ALIGN_VALUES$1 = /* @__PURE__ */ new Set(["top", "center", "bottom"]);
|
|
43752
43951
|
const getAttrs$1 = (node) => {
|
|
43753
|
-
return isPlainObject$
|
|
43952
|
+
return isPlainObject$2(node.attrs) ? node.attrs : {};
|
|
43754
43953
|
};
|
|
43755
43954
|
const normalizeWrapType$1 = (value) => {
|
|
43756
43955
|
if (typeof value !== "string") return void 0;
|
|
@@ -43773,7 +43972,7 @@ const normalizePolygon$1 = (value) => {
|
|
|
43773
43972
|
return polygon.length > 0 ? polygon : void 0;
|
|
43774
43973
|
};
|
|
43775
43974
|
const normalizeWrap$2 = (value) => {
|
|
43776
|
-
if (!isPlainObject$
|
|
43975
|
+
if (!isPlainObject$2(value)) {
|
|
43777
43976
|
return void 0;
|
|
43778
43977
|
}
|
|
43779
43978
|
const type = normalizeWrapType$1(value.type);
|
|
@@ -43781,7 +43980,7 @@ const normalizeWrap$2 = (value) => {
|
|
|
43781
43980
|
return void 0;
|
|
43782
43981
|
}
|
|
43783
43982
|
const wrap = { type };
|
|
43784
|
-
const attrs = isPlainObject$
|
|
43983
|
+
const attrs = isPlainObject$2(value.attrs) ? value.attrs : {};
|
|
43785
43984
|
const wrapText = normalizeWrapText$1(attrs.wrapText);
|
|
43786
43985
|
if (wrapText) {
|
|
43787
43986
|
wrap.wrapText = wrapText;
|
|
@@ -43798,7 +43997,7 @@ const normalizeWrap$2 = (value) => {
|
|
|
43798
43997
|
if (polygon) {
|
|
43799
43998
|
wrap.polygon = polygon;
|
|
43800
43999
|
}
|
|
43801
|
-
const behindDoc = toBoolean$
|
|
44000
|
+
const behindDoc = toBoolean$2(attrs.behindDoc);
|
|
43802
44001
|
if (behindDoc != null) {
|
|
43803
44002
|
wrap.behindDoc = behindDoc;
|
|
43804
44003
|
}
|
|
@@ -43813,10 +44012,10 @@ const normalizeAnchorAlign$1 = (value, allowed) => {
|
|
|
43813
44012
|
return allowed.has(value) ? value : void 0;
|
|
43814
44013
|
};
|
|
43815
44014
|
const normalizeAnchorData$1 = (value, attrs, wrapBehindDoc) => {
|
|
43816
|
-
const raw = isPlainObject$
|
|
43817
|
-
const marginOffset = isPlainObject$
|
|
43818
|
-
const simplePos = isPlainObject$
|
|
43819
|
-
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;
|
|
43820
44019
|
const isAnchored = attrs.isAnchor === true || Boolean(raw);
|
|
43821
44020
|
const anchor = {};
|
|
43822
44021
|
if (isAnchored) {
|
|
@@ -43834,7 +44033,7 @@ const normalizeAnchorData$1 = (value, attrs, wrapBehindDoc) => {
|
|
|
43834
44033
|
if (offsetH != null) anchor.offsetH = offsetH;
|
|
43835
44034
|
const offsetV = pickNumber(marginOffset?.top ?? marginOffset?.vertical ?? raw?.offsetV ?? simplePos?.y);
|
|
43836
44035
|
if (offsetV != null) anchor.offsetV = offsetV;
|
|
43837
|
-
const behindDoc = toBoolean$
|
|
44036
|
+
const behindDoc = toBoolean$2(raw?.behindDoc ?? wrapBehindDoc ?? originalAttrs?.behindDoc);
|
|
43838
44037
|
if (behindDoc != null) anchor.behindDoc = behindDoc;
|
|
43839
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;
|
|
43840
44039
|
return hasData ? anchor : void 0;
|
|
@@ -43959,7 +44158,7 @@ function handleShapeTextboxNode(node, context) {
|
|
|
43959
44158
|
}
|
|
43960
44159
|
}
|
|
43961
44160
|
const getAttrs = (node) => {
|
|
43962
|
-
return isPlainObject$
|
|
44161
|
+
return isPlainObject$2(node.attrs) ? { ...node.attrs } : {};
|
|
43963
44162
|
};
|
|
43964
44163
|
const parseFullWidth = (value) => {
|
|
43965
44164
|
if (typeof value === "string") {
|
|
@@ -43978,7 +44177,7 @@ function contentBlockNodeToDrawingBlock(node, nextBlockId, positions) {
|
|
|
43978
44177
|
if (rawAttrs.horizontalRule !== true) {
|
|
43979
44178
|
return null;
|
|
43980
44179
|
}
|
|
43981
|
-
const size2 = isPlainObject$
|
|
44180
|
+
const size2 = isPlainObject$2(rawAttrs.size) ? rawAttrs.size : void 0;
|
|
43982
44181
|
const { width, isFullWidth } = parseFullWidth(size2?.width);
|
|
43983
44182
|
const height = pickNumber(size2?.height);
|
|
43984
44183
|
if (!height || height <= 0) {
|
|
@@ -44180,6 +44379,9 @@ const extractRunStyleId = (runProperties) => {
|
|
|
44180
44379
|
return null;
|
|
44181
44380
|
};
|
|
44182
44381
|
const DEFAULT_IMAGE_DIMENSION_PX = 100;
|
|
44382
|
+
const HALF_POINTS_PER_POINT = 2;
|
|
44383
|
+
const SCREEN_DPI = 96;
|
|
44384
|
+
const POINT_DPI = 72;
|
|
44183
44385
|
function isInlineImage(node) {
|
|
44184
44386
|
const attrs = node.attrs ?? {};
|
|
44185
44387
|
const wrap = attrs.wrap;
|
|
@@ -44207,8 +44409,8 @@ function imageNodeToRun(node, positions, activeSdt) {
|
|
|
44207
44409
|
const size2 = attrs.size ?? {};
|
|
44208
44410
|
const width = typeof size2.width === "number" && Number.isFinite(size2.width) && size2.width > 0 ? size2.width : DEFAULT_IMAGE_DIMENSION_PX;
|
|
44209
44411
|
const height = typeof size2.height === "number" && Number.isFinite(size2.height) && size2.height > 0 ? size2.height : DEFAULT_IMAGE_DIMENSION_PX;
|
|
44210
|
-
const wrap = isPlainObject$
|
|
44211
|
-
const wrapAttrs = isPlainObject$
|
|
44412
|
+
const wrap = isPlainObject$2(attrs.wrap) ? attrs.wrap : {};
|
|
44413
|
+
const wrapAttrs = isPlainObject$2(wrap.attrs) ? wrap.attrs : {};
|
|
44212
44414
|
const run = {
|
|
44213
44415
|
kind: "image",
|
|
44214
44416
|
src,
|
|
@@ -44418,15 +44620,6 @@ const applyBaseRunDefaults = (run, defaults, uiDisplayFallbackFont, fallbackSize
|
|
|
44418
44620
|
if (defaults.letterSpacing != null && run.letterSpacing == null) {
|
|
44419
44621
|
run.letterSpacing = defaults.letterSpacing;
|
|
44420
44622
|
}
|
|
44421
|
-
if (defaults.bold && run.bold === void 0) {
|
|
44422
|
-
run.bold = true;
|
|
44423
|
-
}
|
|
44424
|
-
if (defaults.italic && run.italic === void 0) {
|
|
44425
|
-
run.italic = true;
|
|
44426
|
-
}
|
|
44427
|
-
if (defaults.underline && !run.underline) {
|
|
44428
|
-
run.underline = defaults.underline;
|
|
44429
|
-
}
|
|
44430
44623
|
};
|
|
44431
44624
|
function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defaultSize, styleContext, listCounterContext, trackedChanges, bookmarks, hyperlinkConfig = DEFAULT_HYPERLINK_CONFIG$1, themeColors, converters, converterContext) {
|
|
44432
44625
|
const baseBlockId = nextBlockId("paragraph");
|
|
@@ -44435,28 +44628,45 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
|
|
|
44435
44628
|
const paragraphHydration = converterContext ? hydrateParagraphStyleAttrs(para, converterContext) : null;
|
|
44436
44629
|
let baseRunDefaults = {};
|
|
44437
44630
|
try {
|
|
44438
|
-
const
|
|
44439
|
-
|
|
44440
|
-
|
|
44441
|
-
|
|
44442
|
-
|
|
44443
|
-
|
|
44444
|
-
|
|
44445
|
-
|
|
44446
|
-
|
|
44447
|
-
|
|
44448
|
-
|
|
44449
|
-
|
|
44450
|
-
|
|
44451
|
-
|
|
44452
|
-
|
|
44453
|
-
|
|
44454
|
-
|
|
44455
|
-
|
|
44456
|
-
|
|
44457
|
-
|
|
44458
|
-
|
|
44459
|
-
|
|
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
|
+
}
|
|
44460
44670
|
} catch {
|
|
44461
44671
|
baseRunDefaults = {};
|
|
44462
44672
|
}
|
|
@@ -48007,7 +48217,8 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
48007
48217
|
const originX = currentLine.width;
|
|
48008
48218
|
const { target, nextIndex, stop } = getNextTabStopPx(currentLine.width, tabStops, tabStopCursor);
|
|
48009
48219
|
tabStopCursor = nextIndex;
|
|
48010
|
-
const
|
|
48220
|
+
const clampedTarget = Math.min(target, currentLine.maxWidth);
|
|
48221
|
+
const tabAdvance = Math.max(0, clampedTarget - currentLine.width);
|
|
48011
48222
|
currentLine.width = roundValue(currentLine.width + tabAdvance);
|
|
48012
48223
|
run.width = tabAdvance;
|
|
48013
48224
|
currentLine.maxFontSize = Math.max(currentLine.maxFontSize, 12);
|
|
@@ -48015,14 +48226,14 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
48015
48226
|
currentLine.toChar = 1;
|
|
48016
48227
|
if (stop) {
|
|
48017
48228
|
validateTabStopVal(stop);
|
|
48018
|
-
pendingTabAlignment = { target, val: stop.val };
|
|
48229
|
+
pendingTabAlignment = { target: clampedTarget, val: stop.val };
|
|
48019
48230
|
} else {
|
|
48020
48231
|
pendingTabAlignment = null;
|
|
48021
48232
|
}
|
|
48022
48233
|
if (stop && stop.leader && stop.leader !== "none") {
|
|
48023
48234
|
const leaderStyle = stop.leader;
|
|
48024
|
-
const from3 = Math.min(originX,
|
|
48025
|
-
const to = Math.max(originX,
|
|
48235
|
+
const from3 = Math.min(originX, clampedTarget);
|
|
48236
|
+
const to = Math.max(originX, clampedTarget);
|
|
48026
48237
|
if (!currentLine.leaders) currentLine.leaders = [];
|
|
48027
48238
|
currentLine.leaders.push({ from: from3, to, style: leaderStyle });
|
|
48028
48239
|
}
|
|
@@ -48617,7 +48828,8 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
48617
48828
|
const originX = currentLine.width;
|
|
48618
48829
|
const { target, nextIndex, stop } = getNextTabStopPx(currentLine.width, tabStops, tabStopCursor);
|
|
48619
48830
|
tabStopCursor = nextIndex;
|
|
48620
|
-
const
|
|
48831
|
+
const clampedTarget = Math.min(target, currentLine.maxWidth);
|
|
48832
|
+
const tabAdvance = Math.max(0, clampedTarget - currentLine.width);
|
|
48621
48833
|
currentLine.width = roundValue(currentLine.width + tabAdvance);
|
|
48622
48834
|
currentLine.maxFontInfo = updateMaxFontInfo(currentLine.maxFontSize, currentLine.maxFontInfo, run);
|
|
48623
48835
|
currentLine.maxFontSize = Math.max(currentLine.maxFontSize, run.fontSize);
|
|
@@ -48626,14 +48838,14 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
48626
48838
|
charPosInRun += 1;
|
|
48627
48839
|
if (stop) {
|
|
48628
48840
|
validateTabStopVal(stop);
|
|
48629
|
-
pendingTabAlignment = { target, val: stop.val };
|
|
48841
|
+
pendingTabAlignment = { target: clampedTarget, val: stop.val };
|
|
48630
48842
|
} else {
|
|
48631
48843
|
pendingTabAlignment = null;
|
|
48632
48844
|
}
|
|
48633
48845
|
if (stop && stop.leader && stop.leader !== "none" && stop.leader !== "middleDot") {
|
|
48634
48846
|
const leaderStyle = stop.leader;
|
|
48635
|
-
const from3 = Math.min(originX,
|
|
48636
|
-
const to = Math.max(originX,
|
|
48847
|
+
const from3 = Math.min(originX, clampedTarget);
|
|
48848
|
+
const to = Math.max(originX, clampedTarget);
|
|
48637
48849
|
if (!currentLine.leaders) currentLine.leaders = [];
|
|
48638
48850
|
currentLine.leaders.push({ from: from3, to, style: leaderStyle });
|
|
48639
48851
|
}
|
|
@@ -57189,16 +57401,112 @@ const mapRangesThroughTransactions = (ranges, transactions, docSize) => {
|
|
|
57189
57401
|
});
|
|
57190
57402
|
return mergeRanges$2(mapped, docSize);
|
|
57191
57403
|
};
|
|
57192
|
-
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 = []) => {
|
|
57193
57485
|
if (!ranges.length) return null;
|
|
57194
57486
|
const replacements = [];
|
|
57487
|
+
const metaStyleMarks = createMarksFromDefs(state.schema, markDefsFromMeta);
|
|
57195
57488
|
ranges.forEach(({ from: from3, to }) => {
|
|
57196
57489
|
state.doc.nodesBetween(from3, to, (node, pos, parent, index2) => {
|
|
57197
57490
|
if (!node.isText || !parent || parent.type === runType) return;
|
|
57198
57491
|
const match = parent.contentMatchAt ? parent.contentMatchAt(index2) : null;
|
|
57199
57492
|
if (match && !match.matchType(runType)) return;
|
|
57200
57493
|
if (!match && !parent.type.contentMatch.matchType(runType)) return;
|
|
57201
|
-
|
|
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
|
+
}
|
|
57202
57510
|
const runNode = runType.create({ runProperties }, node);
|
|
57203
57511
|
replacements.push({ from: pos, to: pos + node.nodeSize, runNode });
|
|
57204
57512
|
});
|
|
@@ -57208,9 +57516,10 @@ const buildWrapTransaction = (state, ranges, runType) => {
|
|
|
57208
57516
|
replacements.sort((a, b) => b.from - a.from).forEach(({ from: from3, to, runNode }) => tr.replaceWith(from3, to, runNode));
|
|
57209
57517
|
return tr.docChanged ? tr : null;
|
|
57210
57518
|
};
|
|
57211
|
-
const wrapTextInRunsPlugin = () => {
|
|
57519
|
+
const wrapTextInRunsPlugin = (editor) => {
|
|
57212
57520
|
let view = null;
|
|
57213
57521
|
let pendingRanges = [];
|
|
57522
|
+
let lastStyleMarksMeta = [];
|
|
57214
57523
|
const flush = () => {
|
|
57215
57524
|
if (!view) return;
|
|
57216
57525
|
const runType = view.state.schema.nodes.run;
|
|
@@ -57218,7 +57527,7 @@ const wrapTextInRunsPlugin = () => {
|
|
|
57218
57527
|
pendingRanges = [];
|
|
57219
57528
|
return;
|
|
57220
57529
|
}
|
|
57221
|
-
const tr = buildWrapTransaction(view.state, pendingRanges, runType);
|
|
57530
|
+
const tr = buildWrapTransaction(view.state, pendingRanges, runType, editor, lastStyleMarksMeta);
|
|
57222
57531
|
pendingRanges = [];
|
|
57223
57532
|
if (tr) {
|
|
57224
57533
|
view.dispatch(tr);
|
|
@@ -57237,6 +57546,7 @@ const wrapTextInRunsPlugin = () => {
|
|
|
57237
57546
|
editorView.dom.removeEventListener("compositionend", onCompositionEnd);
|
|
57238
57547
|
view = null;
|
|
57239
57548
|
pendingRanges = [];
|
|
57549
|
+
lastStyleMarksMeta = [];
|
|
57240
57550
|
}
|
|
57241
57551
|
};
|
|
57242
57552
|
},
|
|
@@ -57250,7 +57560,11 @@ const wrapTextInRunsPlugin = () => {
|
|
|
57250
57560
|
if (view?.composing) {
|
|
57251
57561
|
return null;
|
|
57252
57562
|
}
|
|
57253
|
-
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);
|
|
57254
57568
|
pendingRanges = [];
|
|
57255
57569
|
return tr;
|
|
57256
57570
|
}
|
|
@@ -57513,7 +57827,7 @@ const Run = OxmlNode.create({
|
|
|
57513
57827
|
},
|
|
57514
57828
|
addPmPlugins() {
|
|
57515
57829
|
return [
|
|
57516
|
-
wrapTextInRunsPlugin(),
|
|
57830
|
+
wrapTextInRunsPlugin(this.editor),
|
|
57517
57831
|
splitRunsAfterMarkPlugin,
|
|
57518
57832
|
calculateInlineRunPropertiesPlugin(this.editor),
|
|
57519
57833
|
cleanupEmptyRunsPlugin
|