@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.
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  const jszip = require("./jszip-C8_CqJxM.cjs");
3
3
  const helpers$1 = require("./helpers-nOdwpmwb.cjs");
4
- const superEditor_converter = require("./SuperConverter-Dy0-KTCc.cjs");
4
+ const superEditor_converter = require("./SuperConverter-XGlv5pME.cjs");
5
5
  const vue = require("./vue-De9wkgLl.cjs");
6
6
  require("./jszip.min-BPh2MMAa.cjs");
7
7
  const eventemitter3 = require("./eventemitter3-BQuRcMPI.cjs");
@@ -175,6 +175,354 @@ function parseSizeUnit(val = "0") {
175
175
  function minMax(value = 0, min2 = 0, max2 = 0) {
176
176
  return Math.min(Math.max(value, min2), max2);
177
177
  }
178
+ const FONT_FAMILY_FALLBACKS = Object.freeze({
179
+ swiss: "Arial, sans-serif",
180
+ roman: "Times New Roman, serif",
181
+ modern: "Courier New, monospace",
182
+ script: "cursive",
183
+ decorative: "fantasy",
184
+ system: "system-ui",
185
+ auto: "sans-serif"
186
+ });
187
+ const DEFAULT_GENERIC_FALLBACK = "sans-serif";
188
+ const normalizeParts = (value) => (value || "").split(",").map((part) => part.trim()).filter(Boolean);
189
+ function mapWordFamilyFallback(wordFamily) {
190
+ if (!wordFamily) return DEFAULT_GENERIC_FALLBACK;
191
+ const mapped = FONT_FAMILY_FALLBACKS[wordFamily.toLowerCase()];
192
+ return mapped || DEFAULT_GENERIC_FALLBACK;
193
+ }
194
+ function toCssFontFamily(fontName, options = {}) {
195
+ if (!fontName || typeof fontName !== "string") return fontName;
196
+ const trimmed = fontName.trim();
197
+ if (!trimmed || trimmed.includes(",")) return trimmed;
198
+ const { fallback, wordFamily } = options;
199
+ const fallbackValue = fallback ?? (wordFamily ? mapWordFamilyFallback(wordFamily) : void 0) ?? DEFAULT_GENERIC_FALLBACK;
200
+ const fallbackParts = normalizeParts(fallbackValue);
201
+ if (fallbackParts.length === 0) {
202
+ return trimmed;
203
+ }
204
+ const normalizedName = trimmed.toLowerCase();
205
+ const includesName = fallbackParts.some((part) => part.toLowerCase() === normalizedName);
206
+ if (includesName) {
207
+ return fallbackParts.join(", ");
208
+ }
209
+ return [trimmed, ...fallbackParts].join(", ");
210
+ }
211
+ const sdtMetadataCache = /* @__PURE__ */ new Map();
212
+ function resolveStyle(node, context, options = {}) {
213
+ let paragraph = createDefaultParagraph();
214
+ let character = createDefaultCharacter(context);
215
+ let numbering;
216
+ const chain = resolveStyleChain(node.styleId, context.styles);
217
+ for (const style2 of chain) {
218
+ paragraph = mergeParagraph(paragraph, style2.paragraph);
219
+ character = mergeCharacter(character, style2.character);
220
+ if (!numbering && style2.numbering) {
221
+ numbering = resolveNumbering(style2.numbering.numId, style2.numbering.level, context);
222
+ }
223
+ }
224
+ paragraph = mergeParagraph(paragraph, node.paragraphProps);
225
+ character = mergeCharacter(character, node.characterProps);
226
+ if (node.numbering) {
227
+ numbering = resolveNumbering(node.numbering.numId, node.numbering.level, context);
228
+ }
229
+ const sdt = options?.sdt ? resolveSdtMetadata(options.sdt) : void 0;
230
+ return {
231
+ paragraph,
232
+ character,
233
+ numbering,
234
+ sdt
235
+ };
236
+ }
237
+ function resolveNumbering(numId, level, context) {
238
+ const def = context.numbering?.[numId];
239
+ if (!def) return void 0;
240
+ const levelDef = def.levels.find((entry) => entry.level === level) ?? def.levels[level];
241
+ if (!levelDef) return void 0;
242
+ return {
243
+ numId,
244
+ level,
245
+ indent: {
246
+ left: levelDef.indent?.left,
247
+ hanging: levelDef.indent?.hanging
248
+ },
249
+ format: levelDef.format ?? "decimal",
250
+ text: levelDef.text ?? "%1.",
251
+ start: levelDef.start ?? 1
252
+ };
253
+ }
254
+ function resolveSdtMetadata(input) {
255
+ if (!input) return void 0;
256
+ const { nodeType, attrs, cacheKey: explicitKey } = input;
257
+ if (!nodeType) return void 0;
258
+ const normalizedAttrs = isPlainObject$4(attrs) ? attrs : {};
259
+ const cacheKey = buildSdtCacheKey(nodeType, normalizedAttrs, explicitKey);
260
+ if (cacheKey && sdtMetadataCache.has(cacheKey)) {
261
+ return sdtMetadataCache.get(cacheKey);
262
+ }
263
+ let metadata;
264
+ switch (nodeType) {
265
+ case "fieldAnnotation":
266
+ metadata = normalizeFieldAnnotationMetadata(normalizedAttrs);
267
+ break;
268
+ case "structuredContent":
269
+ case "structuredContentBlock":
270
+ metadata = normalizeStructuredContentMetadata(nodeType, normalizedAttrs);
271
+ break;
272
+ case "documentSection":
273
+ metadata = normalizeDocumentSectionMetadata(normalizedAttrs);
274
+ break;
275
+ case "docPartObject":
276
+ metadata = normalizeDocPartMetadata(normalizedAttrs);
277
+ break;
278
+ }
279
+ if (metadata && cacheKey) {
280
+ sdtMetadataCache.set(cacheKey, metadata);
281
+ }
282
+ return metadata;
283
+ }
284
+ function createDefaultParagraph(_context) {
285
+ return {
286
+ alignment: "left",
287
+ spacing: {
288
+ before: 0,
289
+ after: 0,
290
+ line: 12,
291
+ lineRule: "auto"
292
+ },
293
+ indent: {
294
+ left: 0,
295
+ right: 0,
296
+ firstLine: 0,
297
+ hanging: 0
298
+ },
299
+ tabs: []
300
+ };
301
+ }
302
+ function createDefaultCharacter(context) {
303
+ const baseFont = context.defaults?.paragraphFont ?? "Calibri";
304
+ const fallback = context.defaults?.paragraphFontFallback;
305
+ const wordFamily = context.defaults?.paragraphFontFamily;
306
+ const resolvedFamily = toCssFontFamily(baseFont, { fallback, wordFamily }) ?? baseFont;
307
+ return {
308
+ font: {
309
+ family: resolvedFamily,
310
+ size: context.defaults?.fontSize ?? 11,
311
+ weight: 400,
312
+ italic: false
313
+ },
314
+ color: "#000000"
315
+ };
316
+ }
317
+ function resolveStyleChain(styleId, styles) {
318
+ if (!styleId || !styles) return [];
319
+ const result = [];
320
+ const visited = /* @__PURE__ */ new Set();
321
+ let current = styles[styleId];
322
+ while (current && !visited.has(current.id)) {
323
+ result.unshift(current);
324
+ visited.add(current.id);
325
+ current = current.basedOn ? styles[current.basedOn] : void 0;
326
+ }
327
+ return result;
328
+ }
329
+ function mergeParagraph(base2, overrides) {
330
+ if (!overrides) return base2;
331
+ return {
332
+ ...base2,
333
+ alignment: overrides.alignment ?? base2.alignment,
334
+ spacing: overrides.spacing ? { ...base2.spacing, ...overrides.spacing } : base2.spacing,
335
+ indent: overrides.indent ? { ...base2.indent, ...overrides.indent } : base2.indent,
336
+ borders: overrides.borders ? { ...base2.borders, ...overrides.borders } : base2.borders,
337
+ shading: overrides.shading ?? base2.shading,
338
+ tabs: overrides.tabs ?? base2.tabs
339
+ };
340
+ }
341
+ function mergeCharacter(base2, overrides) {
342
+ if (!overrides) return base2;
343
+ return {
344
+ ...base2,
345
+ font: overrides.font ? { ...base2.font, ...overrides.font } : base2.font,
346
+ color: overrides.color ?? base2.color,
347
+ underline: overrides.underline ?? base2.underline,
348
+ strike: overrides.strike ?? base2.strike,
349
+ highlight: overrides.highlight ?? base2.highlight,
350
+ letterSpacing: overrides.letterSpacing ?? base2.letterSpacing
351
+ };
352
+ }
353
+ function normalizeFieldAnnotationMetadata(attrs) {
354
+ const fieldId = toOptionalString(attrs.fieldId) ?? "";
355
+ const formatting = extractFormatting(attrs);
356
+ const size2 = normalizeSize(attrs.size);
357
+ const extras = isPlainObject$4(attrs.extras) ? attrs.extras : null;
358
+ const marks = isPlainObject$4(attrs.marks) ? attrs.marks : void 0;
359
+ return {
360
+ type: "fieldAnnotation",
361
+ fieldId,
362
+ variant: normalizeFieldAnnotationVariant(attrs.type),
363
+ fieldType: toOptionalString(attrs.fieldType),
364
+ displayLabel: toOptionalString(attrs.displayLabel),
365
+ defaultDisplayLabel: toOptionalString(attrs.defaultDisplayLabel),
366
+ alias: toOptionalString(attrs.alias),
367
+ fieldColor: normalizeColorValue(attrs.fieldColor),
368
+ borderColor: normalizeColorValue(attrs.borderColor),
369
+ highlighted: toBoolean$3(attrs.highlighted, true),
370
+ fontFamily: toNullableString(attrs.fontFamily),
371
+ fontSize: normalizeFontSize(attrs.fontSize),
372
+ textColor: normalizeColorValue(attrs.textColor) ?? null,
373
+ textHighlight: normalizeColorValue(attrs.textHighlight) ?? null,
374
+ linkUrl: toNullableString(attrs.linkUrl),
375
+ imageSrc: toNullableString(attrs.imageSrc),
376
+ rawHtml: attrs.rawHtml ?? void 0,
377
+ size: size2 ?? null,
378
+ extras,
379
+ multipleImage: toBoolean$3(attrs.multipleImage, false),
380
+ hash: toOptionalString(attrs.hash) ?? null,
381
+ generatorIndex: toNumber(attrs.generatorIndex),
382
+ sdtId: toOptionalString(attrs.sdtId) ?? null,
383
+ hidden: toBoolean$3(attrs.hidden, false),
384
+ visibility: normalizeVisibility(attrs.visibility),
385
+ isLocked: toBoolean$3(attrs.isLocked, false),
386
+ formatting,
387
+ marks
388
+ };
389
+ }
390
+ function normalizeStructuredContentMetadata(nodeType, attrs) {
391
+ return {
392
+ type: "structuredContent",
393
+ scope: nodeType === "structuredContentBlock" ? "block" : "inline",
394
+ id: toNullableString(attrs.id),
395
+ tag: toOptionalString(attrs.tag),
396
+ alias: toOptionalString(attrs.alias),
397
+ sdtPr: attrs.sdtPr
398
+ };
399
+ }
400
+ function normalizeDocumentSectionMetadata(attrs) {
401
+ return {
402
+ type: "documentSection",
403
+ id: toNullableString(attrs.id),
404
+ title: toOptionalString(attrs.title) ?? null,
405
+ description: toOptionalString(attrs.description) ?? null,
406
+ sectionType: toOptionalString(attrs.sectionType) ?? null,
407
+ isLocked: toBoolean$3(attrs.isLocked, false),
408
+ sdBlockId: toNullableString(attrs.sdBlockId)
409
+ };
410
+ }
411
+ function normalizeDocPartMetadata(attrs) {
412
+ return {
413
+ type: "docPartObject",
414
+ gallery: toOptionalString(attrs.docPartGallery ?? attrs.gallery) ?? null,
415
+ // Source uniqueId from attrs.id (PM adapter uses getDocPartObjectId which extracts attrs.id)
416
+ // Fall back to attrs.uniqueId for compatibility
417
+ uniqueId: toOptionalString(attrs.id ?? attrs.uniqueId) ?? null,
418
+ alias: toOptionalString(attrs.alias) ?? null,
419
+ instruction: toOptionalString(attrs.instruction) ?? null
420
+ };
421
+ }
422
+ function isPlainObject$4(value) {
423
+ return !!value && typeof value === "object" && !Array.isArray(value);
424
+ }
425
+ function toOptionalString(value) {
426
+ if (value == null) return void 0;
427
+ if (typeof value === "string") {
428
+ const trimmed = value.trim();
429
+ return trimmed.length ? trimmed : void 0;
430
+ }
431
+ return String(value);
432
+ }
433
+ function toNullableString(value) {
434
+ const str = toOptionalString(value);
435
+ return str ?? null;
436
+ }
437
+ function toBoolean$3(value, fallback) {
438
+ if (typeof value === "boolean") return value;
439
+ if (typeof value === "string") {
440
+ const lower = value.toLowerCase();
441
+ if (lower === "true") return true;
442
+ if (lower === "false") return false;
443
+ }
444
+ if (value == null) return fallback;
445
+ return Boolean(value);
446
+ }
447
+ function normalizeVisibility(value) {
448
+ if (typeof value !== "string") return void 0;
449
+ const normalized = value.toLowerCase();
450
+ if (normalized === "visible" || normalized === "hidden") {
451
+ return normalized;
452
+ }
453
+ return void 0;
454
+ }
455
+ function normalizeColorValue(value) {
456
+ if (typeof value !== "string") return void 0;
457
+ const trimmed = value.trim();
458
+ if (!trimmed || trimmed.toLowerCase() === "none") return void 0;
459
+ return trimmed;
460
+ }
461
+ function normalizeFontSize(value) {
462
+ if (value == null) return null;
463
+ if (typeof value === "number") {
464
+ return Number.isFinite(value) ? value : null;
465
+ }
466
+ if (typeof value === "string") {
467
+ const trimmed = value.trim();
468
+ return trimmed.length ? trimmed : null;
469
+ }
470
+ return null;
471
+ }
472
+ function toNumber(value) {
473
+ if (typeof value === "number") {
474
+ return Number.isFinite(value) ? value : null;
475
+ }
476
+ if (typeof value === "string") {
477
+ const parsed = parseFloat(value);
478
+ return Number.isFinite(parsed) ? parsed : null;
479
+ }
480
+ return null;
481
+ }
482
+ function normalizeSize(value) {
483
+ if (!isPlainObject$4(value)) return null;
484
+ const obj = value;
485
+ const width = toNumber(obj.width);
486
+ const height = toNumber(obj.height);
487
+ if (width == null && height == null) return null;
488
+ const result = {};
489
+ if (width != null) result.width = width;
490
+ if (height != null) result.height = height;
491
+ return result;
492
+ }
493
+ function normalizeFieldAnnotationVariant(value) {
494
+ if (typeof value !== "string") return void 0;
495
+ const normalized = value.toLowerCase();
496
+ if (normalized === "text" || normalized === "image" || normalized === "signature" || normalized === "checkbox" || normalized === "html" || normalized === "link") {
497
+ return normalized;
498
+ }
499
+ return void 0;
500
+ }
501
+ function extractFormatting(attrs) {
502
+ const bold = toBoolean$3(attrs.bold, false);
503
+ const italic = toBoolean$3(attrs.italic, false);
504
+ const underline = toBoolean$3(attrs.underline, false);
505
+ const formatting = {};
506
+ if (bold) formatting.bold = true;
507
+ if (italic) formatting.italic = true;
508
+ if (underline) formatting.underline = true;
509
+ return Object.keys(formatting).length ? formatting : void 0;
510
+ }
511
+ function buildSdtCacheKey(nodeType, attrs, explicitKey) {
512
+ const provided = toOptionalString(explicitKey);
513
+ if (provided) {
514
+ return `${nodeType}:${provided}`;
515
+ }
516
+ const hash2 = toOptionalString(attrs.hash);
517
+ if (hash2) {
518
+ return `${nodeType}:${hash2}`;
519
+ }
520
+ const id = toOptionalString(attrs.id);
521
+ if (id) {
522
+ return `${nodeType}:${id}`;
523
+ }
524
+ return void 0;
525
+ }
178
526
  function createDocument(converter, schema, editor, { check = false } = {}) {
179
527
  const documentData = converter.getSchema(editor);
180
528
  if (documentData) {
@@ -9108,15 +9456,19 @@ const splitRunToParagraph = () => (props) => {
9108
9456
  dispatchTransaction = editor.dispatch.bind(editor);
9109
9457
  }
9110
9458
  if (!dispatchTransaction) return false;
9111
- const handled = splitBlockPatch(state, (transaction) => {
9112
- dispatchTransaction(transaction);
9113
- });
9459
+ const handled = splitBlockPatch(
9460
+ state,
9461
+ (transaction) => {
9462
+ dispatchTransaction(transaction);
9463
+ },
9464
+ editor
9465
+ );
9114
9466
  if (handled) {
9115
9467
  tr.setMeta("preventDispatch", true);
9116
9468
  }
9117
9469
  return handled;
9118
9470
  };
9119
- function splitBlockPatch(state, dispatch) {
9471
+ function splitBlockPatch(state, dispatch, editor) {
9120
9472
  let { $from } = state.selection;
9121
9473
  if (state.selection instanceof superEditor_converter.NodeSelection && state.selection.node.isBlock) {
9122
9474
  if (!$from.parentOffset || !superEditor_converter.canSplit(state.doc, $from.pos)) return false;
@@ -9125,14 +9477,15 @@ function splitBlockPatch(state, dispatch) {
9125
9477
  }
9126
9478
  if (!$from.depth) return false;
9127
9479
  let types = [];
9128
- let splitDepth, deflt, atEnd = false, atStart = false;
9480
+ let splitDepth, deflt, paragraphAttrs = null, atEnd = false, atStart = false;
9129
9481
  for (let d2 = $from.depth; ; d2--) {
9130
9482
  let node = $from.node(d2);
9131
9483
  if (node.isBlock) {
9132
9484
  atEnd = $from.end(d2) == $from.pos + ($from.depth - d2);
9133
9485
  atStart = $from.start(d2) == $from.pos - ($from.depth - d2);
9134
9486
  deflt = defaultBlockAt$1($from.node(d2 - 1).contentMatchAt($from.indexAfter(d2 - 1)));
9135
- types.unshift(null);
9487
+ paragraphAttrs = { ...node.attrs };
9488
+ types.unshift({ type: deflt || node.type, attrs: paragraphAttrs });
9136
9489
  splitDepth = d2;
9137
9490
  break;
9138
9491
  } else {
@@ -9145,7 +9498,7 @@ function splitBlockPatch(state, dispatch) {
9145
9498
  let splitPos = tr.mapping.map($from.pos);
9146
9499
  let can = superEditor_converter.canSplit(tr.doc, splitPos, types.length, types);
9147
9500
  if (!can) {
9148
- types[0] = deflt ? { type: deflt } : null;
9501
+ types[0] = deflt ? { type: deflt, attrs: paragraphAttrs } : null;
9149
9502
  can = superEditor_converter.canSplit(tr.doc, splitPos, types.length, types);
9150
9503
  }
9151
9504
  if (!can) return false;
@@ -9155,9 +9508,37 @@ function splitBlockPatch(state, dispatch) {
9155
9508
  if (deflt && $from.node(splitDepth - 1).canReplaceWith($first.index(), $first.index() + 1, deflt))
9156
9509
  tr.setNodeMarkup(tr.mapping.map($from.before(splitDepth)), deflt);
9157
9510
  }
9511
+ applyStyleMarks(state, tr, editor, paragraphAttrs);
9158
9512
  if (dispatch) dispatch(tr.scrollIntoView());
9159
9513
  return true;
9160
9514
  }
9515
+ function applyStyleMarks(state, tr, editor, paragraphAttrs) {
9516
+ const styleId = paragraphAttrs?.paragraphProperties?.styleId;
9517
+ if (!editor?.converter && !styleId) {
9518
+ return;
9519
+ }
9520
+ try {
9521
+ const params2 = { docx: editor?.converter?.convertedXml ?? {}, numbering: editor?.converter?.numbering ?? {} };
9522
+ const resolvedPpr = styleId ? { styleId } : {};
9523
+ const runProperties = styleId ? superEditor_converter.resolveRunProperties(params2, {}, resolvedPpr, false, false) : {};
9524
+ const markDefsFromStyle = styleId ? (
9525
+ /** @type {Array<{type: string, attrs: Record<string, unknown>}>} */
9526
+ superEditor_converter.encodeMarksFromRPr(runProperties, editor?.converter?.convertedXml ?? {})
9527
+ ) : [];
9528
+ const selectionMarks = state.selection?.$from?.marks ? state.selection.$from.marks() : [];
9529
+ const selectionMarkDefs = selectionMarks.map((mark) => ({ type: mark.type.name, attrs: mark.attrs }));
9530
+ const markDefsToApply = selectionMarks.length ? selectionMarkDefs : markDefsFromStyle;
9531
+ const marksToApply = markDefsToApply.map((def) => {
9532
+ const markType = state.schema.marks[def.type];
9533
+ return markType ? markType.create(def.attrs) : null;
9534
+ }).filter(Boolean);
9535
+ if (marksToApply.length > 0) {
9536
+ tr.ensureMarks(marksToApply);
9537
+ tr.setMeta("sdStyleMarks", markDefsToApply);
9538
+ }
9539
+ } catch {
9540
+ }
9541
+ }
9161
9542
  const splitRunAtCursor = () => (props) => {
9162
9543
  let { state, dispatch, tr } = props;
9163
9544
  const sel = state.selection;
@@ -10041,7 +10422,7 @@ const updateAttributes = (typeOrName, attrs = {}) => ({ tr, state, dispatch }) =
10041
10422
  }
10042
10423
  return true;
10043
10424
  };
10044
- const isPlainObject$4 = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
10425
+ const isPlainObject$3 = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
10045
10426
  const assignNestedValue = (target, path, value) => {
10046
10427
  if (!path.includes(".")) {
10047
10428
  target[path] = value;
@@ -10055,7 +10436,7 @@ const assignNestedValue = (target, path, value) => {
10055
10436
  if (isLast) {
10056
10437
  current[part] = value;
10057
10438
  } else {
10058
- if (!isPlainObject$4(current[part])) {
10439
+ if (!isPlainObject$3(current[part])) {
10059
10440
  current[part] = {};
10060
10441
  }
10061
10442
  current = current[part];
@@ -14915,7 +15296,7 @@ const canUseDOM = () => {
14915
15296
  return false;
14916
15297
  }
14917
15298
  };
14918
- const summaryVersion = "1.3.0-next.1";
15299
+ const summaryVersion = "1.3.0-next.3";
14919
15300
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
14920
15301
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
14921
15302
  function mapAttributes(attrs) {
@@ -17548,7 +17929,7 @@ class Editor extends EventEmitter {
17548
17929
  * Process collaboration migrations
17549
17930
  */
17550
17931
  processCollaborationMigrations() {
17551
- console.debug("[checkVersionMigrations] Current editor version", "1.3.0-next.1");
17932
+ console.debug("[checkVersionMigrations] Current editor version", "1.3.0-next.3");
17552
17933
  if (!this.options.ydoc) return;
17553
17934
  const metaMap = this.options.ydoc.getMap("meta");
17554
17935
  let docVersion = metaMap.get("version");
@@ -19968,18 +20349,18 @@ function formatNumber(num, format) {
19968
20349
  case "decimal":
19969
20350
  return num.toString();
19970
20351
  case "lowerLetter":
19971
- return toLetter$1(num, false);
20352
+ return toLetter(num, false);
19972
20353
  case "upperLetter":
19973
- return toLetter$1(num, true);
20354
+ return toLetter(num, true);
19974
20355
  case "lowerRoman":
19975
- return toRoman$2(num).toLowerCase();
20356
+ return toRoman$1(num).toLowerCase();
19976
20357
  case "upperRoman":
19977
- return toRoman$2(num);
20358
+ return toRoman$1(num);
19978
20359
  default:
19979
20360
  return num.toString();
19980
20361
  }
19981
20362
  }
19982
- function toLetter$1(num, uppercase) {
20363
+ function toLetter(num, uppercase) {
19983
20364
  let result = "";
19984
20365
  let n = num;
19985
20366
  while (n > 0) {
@@ -19990,7 +20371,7 @@ function toLetter$1(num, uppercase) {
19990
20371
  }
19991
20372
  return result || (uppercase ? "A" : "a");
19992
20373
  }
19993
- function toRoman$2(num) {
20374
+ function toRoman$1(num) {
19994
20375
  const lookup = [
19995
20376
  [1e3, "M"],
19996
20377
  [900, "CM"],
@@ -23123,39 +23504,6 @@ const resolveTableCellBorders = (tableBorders, rowIndex, colIndex, totalRows, to
23123
23504
  right: borderValueToSpec(isLastCol ? tableBorders?.right : null)
23124
23505
  };
23125
23506
  };
23126
- const FONT_FAMILY_FALLBACKS = Object.freeze({
23127
- swiss: "Arial, sans-serif",
23128
- roman: "Times New Roman, serif",
23129
- modern: "Courier New, monospace",
23130
- script: "cursive",
23131
- decorative: "fantasy",
23132
- system: "system-ui",
23133
- auto: "sans-serif"
23134
- });
23135
- const DEFAULT_GENERIC_FALLBACK = "sans-serif";
23136
- const normalizeParts = (value) => (value || "").split(",").map((part) => part.trim()).filter(Boolean);
23137
- function mapWordFamilyFallback(wordFamily) {
23138
- if (!wordFamily) return DEFAULT_GENERIC_FALLBACK;
23139
- const mapped = FONT_FAMILY_FALLBACKS[wordFamily.toLowerCase()];
23140
- return mapped || DEFAULT_GENERIC_FALLBACK;
23141
- }
23142
- function toCssFontFamily(fontName, options = {}) {
23143
- if (!fontName || typeof fontName !== "string") return fontName;
23144
- const trimmed = fontName.trim();
23145
- if (!trimmed || trimmed.includes(",")) return trimmed;
23146
- const { fallback, wordFamily } = options;
23147
- const fallbackValue = fallback ?? (wordFamily ? mapWordFamilyFallback(wordFamily) : void 0) ?? DEFAULT_GENERIC_FALLBACK;
23148
- const fallbackParts = normalizeParts(fallbackValue);
23149
- if (fallbackParts.length === 0) {
23150
- return trimmed;
23151
- }
23152
- const normalizedName = trimmed.toLowerCase();
23153
- const includesName = fallbackParts.some((part) => part.toLowerCase() === normalizedName);
23154
- if (includesName) {
23155
- return fallbackParts.join(", ");
23156
- }
23157
- return [trimmed, ...fallbackParts].join(", ");
23158
- }
23159
23507
  const LIST_MARKER_GAP$3 = 8;
23160
23508
  function renderListMarker(params2) {
23161
23509
  const { doc: doc2, lineEl, markerLayout, markerMeasure, indentLeftPx } = params2;
@@ -25392,7 +25740,14 @@ class DomPainter {
25392
25740
  fragmentEl.dataset.continuesOnNext = "true";
25393
25741
  }
25394
25742
  const lines = fragment.lines ?? measure.lines.slice(fragment.fromLine, fragment.toLine);
25395
- applyParagraphBlockStyles(fragmentEl, block.attrs);
25743
+ applyParagraphBlockStyles(fragmentEl, block.attrs, { includeBorders: false, includeShading: false });
25744
+ const { shadingLayer, borderLayer } = createParagraphDecorationLayers(this.doc, fragment.width, block.attrs);
25745
+ if (shadingLayer) {
25746
+ fragmentEl.appendChild(shadingLayer);
25747
+ }
25748
+ if (borderLayer) {
25749
+ fragmentEl.appendChild(borderLayer);
25750
+ }
25396
25751
  if (block.attrs?.styleId) {
25397
25752
  fragmentEl.dataset.styleId = block.attrs.styleId;
25398
25753
  fragmentEl.setAttribute("styleid", block.attrs.styleId);
@@ -25776,10 +26131,18 @@ class DomPainter {
25776
26131
  contentEl.classList.add("superdoc-list-content");
25777
26132
  this.applySdtDataset(contentEl, paragraphMetadata);
25778
26133
  contentEl.style.display = "inline-block";
26134
+ contentEl.style.position = "relative";
25779
26135
  contentEl.style.width = `${fragment.width}px`;
25780
26136
  const lines = itemMeasure.paragraph.lines.slice(fragment.fromLine, fragment.toLine);
25781
26137
  const contentAttrs = wordLayout ? item.paragraph.attrs : stripListIndent(item.paragraph.attrs);
25782
- applyParagraphBlockStyles(contentEl, contentAttrs);
26138
+ applyParagraphBlockStyles(contentEl, contentAttrs, { includeBorders: false, includeShading: false });
26139
+ const { shadingLayer, borderLayer } = createParagraphDecorationLayers(this.doc, fragment.width, contentAttrs);
26140
+ if (shadingLayer) {
26141
+ contentEl.appendChild(shadingLayer);
26142
+ }
26143
+ if (borderLayer) {
26144
+ contentEl.appendChild(borderLayer);
26145
+ }
25783
26146
  contentEl.style.textAlign = "left";
25784
26147
  const paraForList = {
25785
26148
  ...item.paragraph,
@@ -28006,7 +28369,7 @@ const applyRunDataAttributes = (element, dataAttrs) => {
28006
28369
  }
28007
28370
  });
28008
28371
  };
28009
- const applyParagraphBlockStyles = (element, attrs) => {
28372
+ const applyParagraphBlockStyles = (element, attrs, options = {}) => {
28010
28373
  if (!attrs) return;
28011
28374
  if (attrs.styleId) {
28012
28375
  element.setAttribute("styleid", attrs.styleId);
@@ -28033,8 +28396,55 @@ const applyParagraphBlockStyles = (element, attrs) => {
28033
28396
  }
28034
28397
  }
28035
28398
  }
28036
- applyParagraphBorderStyles(element, attrs.borders);
28037
- applyParagraphShadingStyles(element, attrs.shading);
28399
+ if (options.includeBorders ?? true) {
28400
+ applyParagraphBorderStyles(element, attrs.borders);
28401
+ }
28402
+ if (options.includeShading ?? true) {
28403
+ applyParagraphShadingStyles(element, attrs.shading);
28404
+ }
28405
+ };
28406
+ const getParagraphBorderBox = (fragmentWidth, indent) => {
28407
+ const indentLeft = Number.isFinite(indent?.left) ? indent.left : 0;
28408
+ const indentRight = Number.isFinite(indent?.right) ? indent.right : 0;
28409
+ const firstLine = Number.isFinite(indent?.firstLine) ? indent.firstLine : 0;
28410
+ const hanging = Number.isFinite(indent?.hanging) ? indent.hanging : 0;
28411
+ const firstLineOffset = firstLine - hanging;
28412
+ const minLeftInset = Math.min(indentLeft, indentLeft + firstLineOffset);
28413
+ const leftInset = Math.max(0, minLeftInset);
28414
+ const rightInset = Math.max(0, indentRight);
28415
+ return {
28416
+ leftInset,
28417
+ width: Math.max(0, fragmentWidth - leftInset - rightInset)
28418
+ };
28419
+ };
28420
+ const createParagraphDecorationLayers = (doc2, fragmentWidth, attrs) => {
28421
+ if (!attrs?.borders && !attrs?.shading) return {};
28422
+ const borderBox = getParagraphBorderBox(fragmentWidth, attrs.indent);
28423
+ const baseStyles = {
28424
+ position: "absolute",
28425
+ top: "0px",
28426
+ bottom: "0px",
28427
+ left: `${borderBox.leftInset}px`,
28428
+ width: `${borderBox.width}px`,
28429
+ pointerEvents: "none",
28430
+ boxSizing: "border-box"
28431
+ };
28432
+ let shadingLayer;
28433
+ if (attrs.shading) {
28434
+ shadingLayer = doc2.createElement("div");
28435
+ shadingLayer.classList.add("superdoc-paragraph-shading");
28436
+ Object.assign(shadingLayer.style, baseStyles);
28437
+ applyParagraphShadingStyles(shadingLayer, attrs.shading);
28438
+ }
28439
+ let borderLayer;
28440
+ if (attrs.borders) {
28441
+ borderLayer = doc2.createElement("div");
28442
+ borderLayer.classList.add("superdoc-paragraph-border");
28443
+ Object.assign(borderLayer.style, baseStyles);
28444
+ borderLayer.style.zIndex = "1";
28445
+ applyParagraphBorderStyles(borderLayer, attrs.borders);
28446
+ }
28447
+ return { shadingLayer, borderLayer };
28038
28448
  };
28039
28449
  const BORDER_SIDES = ["top", "right", "bottom", "left"];
28040
28450
  const applyParagraphBorderStyles = (element, borders) => {
@@ -31684,33 +32094,13 @@ function computePartialRow(rowIndex, blockRow, measure, availableHeight, fromLin
31684
32094
  toLineByCell.push(cutLine);
31685
32095
  heightByCell.push(cumulativeHeight);
31686
32096
  }
31687
- const allCellsCompleteInFirstPass = toLineByCell.every((cutLine, idx) => {
31688
- const totalLines = getCellTotalLines(row.cells[idx]);
31689
- return cutLine >= totalLines;
31690
- });
31691
- const lineAdvancements = toLineByCell.map((cutLine, idx) => cutLine - (startLines[idx] || 0));
31692
- const positiveAdvancements = lineAdvancements.filter((adv) => adv > 0);
31693
- const minLineAdvancement = positiveAdvancements.length > 0 ? Math.min(...positiveAdvancements) : 0;
31694
32097
  let actualPartialHeight = 0;
31695
32098
  let maxPaddingTotal = 0;
31696
32099
  for (let cellIdx = 0; cellIdx < cellCount; cellIdx++) {
31697
- const cell = row.cells[cellIdx];
31698
- const startLine = startLines[cellIdx] || 0;
31699
- const lines = getCellLines(cell);
31700
32100
  const cellPadding = cellPaddings[cellIdx];
31701
32101
  const paddingTotal = cellPadding.top + cellPadding.bottom;
31702
32102
  maxPaddingTotal = Math.max(maxPaddingTotal, paddingTotal);
31703
- if (allCellsCompleteInFirstPass) {
31704
- actualPartialHeight = Math.max(actualPartialHeight, heightByCell[cellIdx] + paddingTotal);
31705
- } else {
31706
- const targetLine = Math.min(startLine + minLineAdvancement, lines.length);
31707
- let cumulativeHeight = 0;
31708
- for (let i = startLine; i < targetLine; i++) {
31709
- cumulativeHeight += lines[i].lineHeight || 0;
31710
- }
31711
- toLineByCell[cellIdx] = targetLine;
31712
- actualPartialHeight = Math.max(actualPartialHeight, cumulativeHeight + paddingTotal);
31713
- }
32103
+ actualPartialHeight = Math.max(actualPartialHeight, heightByCell[cellIdx] + paddingTotal);
31714
32104
  }
31715
32105
  const madeProgress = toLineByCell.some((cutLine, idx) => cutLine > (startLines[idx] || 0));
31716
32106
  const isFirstPart = startLines.every((l) => l === 0);
@@ -32263,7 +32653,7 @@ function toUpperLetter(num) {
32263
32653
  function toLowerLetter(num) {
32264
32654
  return toUpperLetter(num).toLowerCase();
32265
32655
  }
32266
- function formatPageNumber$1(pageNumber, format) {
32656
+ function formatPageNumber(pageNumber, format) {
32267
32657
  const num = Math.max(1, pageNumber);
32268
32658
  switch (format) {
32269
32659
  case "decimal":
@@ -32276,6 +32666,8 @@ function formatPageNumber$1(pageNumber, format) {
32276
32666
  return toUpperLetter(num);
32277
32667
  case "lowerLetter":
32278
32668
  return toLowerLetter(num);
32669
+ case "numberInDash":
32670
+ return `-${num}-`;
32279
32671
  default:
32280
32672
  return String(num);
32281
32673
  }
@@ -32304,7 +32696,7 @@ function computeDisplayPageNumber(pages, sections) {
32304
32696
  const sectionMetadata = sectionMap.get(pageSectionIndex);
32305
32697
  const format = sectionMetadata?.numbering?.format ?? "decimal";
32306
32698
  const displayNumber = runningCounter;
32307
- const displayText = formatPageNumber$1(displayNumber, format);
32699
+ const displayText = formatPageNumber(displayNumber, format);
32308
32700
  result.push({
32309
32701
  physicalPage: page.number,
32310
32702
  displayNumber,
@@ -32439,59 +32831,6 @@ const layoutLog = (...args) => {
32439
32831
  if (!layoutDebugEnabled$1) return;
32440
32832
  console.log(...args);
32441
32833
  };
32442
- function formatPageNumber(num, format) {
32443
- switch (format) {
32444
- case "decimal":
32445
- return String(num);
32446
- case "lowerLetter":
32447
- return toLetter(num, false);
32448
- case "upperLetter":
32449
- return toLetter(num, true);
32450
- case "lowerRoman":
32451
- return toRoman$1(num).toLowerCase();
32452
- case "upperRoman":
32453
- return toRoman$1(num);
32454
- default:
32455
- return String(num);
32456
- }
32457
- }
32458
- function toLetter(num, uppercase) {
32459
- let result = "";
32460
- let n = Math.max(1, Math.floor(num));
32461
- while (n > 0) {
32462
- const remainder = (n - 1) % 26;
32463
- const char = String.fromCharCode((uppercase ? 65 : 97) + remainder);
32464
- result = char + result;
32465
- n = Math.floor((n - 1) / 26);
32466
- }
32467
- return result;
32468
- }
32469
- function toRoman$1(num) {
32470
- const lookup = [
32471
- [1e3, "M"],
32472
- [900, "CM"],
32473
- [500, "D"],
32474
- [400, "CD"],
32475
- [100, "C"],
32476
- [90, "XC"],
32477
- [50, "L"],
32478
- [40, "XL"],
32479
- [10, "X"],
32480
- [9, "IX"],
32481
- [5, "V"],
32482
- [4, "IV"],
32483
- [1, "I"]
32484
- ];
32485
- let result = "";
32486
- let n = Math.max(1, Math.floor(num));
32487
- for (const [value, numeral] of lookup) {
32488
- while (n >= value) {
32489
- result += numeral;
32490
- n -= value;
32491
- }
32492
- }
32493
- return result;
32494
- }
32495
32834
  function layoutDocument(blocks, measures, options = {}) {
32496
32835
  if (blocks.length !== measures.length) {
32497
32836
  throw new Error(
@@ -33947,7 +34286,7 @@ class MeasureCache {
33947
34286
  return `${block.id}@${safeWidth}x${safeHeight}:${hash2}`;
33948
34287
  }
33949
34288
  }
33950
- function resolveHeaderFooterTokens(blocks, pageNumber, totalPages) {
34289
+ function resolveHeaderFooterTokens(blocks, pageNumber, totalPages, pageNumberText) {
33951
34290
  if (!blocks || blocks.length === 0) {
33952
34291
  return;
33953
34292
  }
@@ -33959,7 +34298,7 @@ function resolveHeaderFooterTokens(blocks, pageNumber, totalPages) {
33959
34298
  console.warn("[resolveHeaderFooterTokens] Invalid totalPages:", totalPages, "- using 1 as fallback");
33960
34299
  totalPages = 1;
33961
34300
  }
33962
- const pageNumberStr = String(pageNumber);
34301
+ const pageNumberStr = pageNumberText ?? String(pageNumber);
33963
34302
  const totalPagesStr = String(totalPages);
33964
34303
  for (const block of blocks) {
33965
34304
  if (block.kind !== "paragraph") continue;
@@ -34382,15 +34721,31 @@ async function layoutHeaderFooterWithCache(sections, constraints, measureBlock2,
34382
34721
  for (const pageNum of pagesToLayout) {
34383
34722
  const clonedBlocks = cloneHeaderFooterBlocks(blocks);
34384
34723
  const { displayText, totalPages: totalPagesForPage } = pageResolver(pageNum);
34385
- const resolvedPageNum = parseInt(displayText, 10) || pageNum;
34386
- resolveHeaderFooterTokens(clonedBlocks, resolvedPageNum, totalPagesForPage);
34724
+ resolveHeaderFooterTokens(clonedBlocks, pageNum, totalPagesForPage, displayText);
34387
34725
  const measures = await cache2.measureBlocks(clonedBlocks, constraints, measureBlock2);
34388
34726
  const pageLayout = layoutHeaderFooter(clonedBlocks, measures, constraints);
34727
+ const measuresById = /* @__PURE__ */ new Map();
34728
+ for (let i = 0; i < clonedBlocks.length; i += 1) {
34729
+ measuresById.set(clonedBlocks[i].id, measures[i]);
34730
+ }
34731
+ const fragmentsWithLines = pageLayout.pages[0]?.fragments.map((fragment) => {
34732
+ if (fragment.kind !== "para") {
34733
+ return fragment;
34734
+ }
34735
+ const measure = measuresById.get(fragment.blockId);
34736
+ if (!measure || measure.kind !== "paragraph") {
34737
+ return fragment;
34738
+ }
34739
+ return {
34740
+ ...fragment,
34741
+ lines: measure.lines.slice(fragment.fromLine, fragment.toLine)
34742
+ };
34743
+ }) ?? [];
34389
34744
  pages.push({
34390
34745
  number: pageNum,
34391
34746
  blocks: clonedBlocks,
34392
34747
  measures,
34393
- fragments: pageLayout.pages[0]?.fragments ?? []
34748
+ fragments: fragmentsWithLines
34394
34749
  });
34395
34750
  }
34396
34751
  const firstPageLayout = pages[0] ? layoutHeaderFooter(pages[0].blocks, pages[0].measures, constraints) : { height: 0 };
@@ -39277,7 +39632,14 @@ function extractPageNumbering(elements) {
39277
39632
  const pgNumType = elements.find((el) => el?.name === "w:pgNumType");
39278
39633
  if (!pgNumType?.attributes) return void 0;
39279
39634
  const fmtRaw = pgNumType.attributes["w:fmt"];
39280
- const validFormats = ["decimal", "lowerLetter", "upperLetter", "lowerRoman", "upperRoman"];
39635
+ const validFormats = [
39636
+ "decimal",
39637
+ "lowerLetter",
39638
+ "upperLetter",
39639
+ "lowerRoman",
39640
+ "upperRoman",
39641
+ "numberInDash"
39642
+ ];
39281
39643
  const fmt = validFormats.includes(fmtRaw) ? fmtRaw : void 0;
39282
39644
  const startRaw = pgNumType.attributes["w:start"];
39283
39645
  const startNum = startRaw != null ? Number(startRaw) : void 0;
@@ -39706,7 +40068,7 @@ const pxToPt = (px) => {
39706
40068
  return px / PX_PER_PT;
39707
40069
  };
39708
40070
  const isFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value);
39709
- const isPlainObject$3 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
40071
+ const isPlainObject$2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
39710
40072
  const normalizePrefix = (value) => {
39711
40073
  if (!value) return "";
39712
40074
  return String(value);
@@ -39768,7 +40130,7 @@ function coerceBoolean(value) {
39768
40130
  }
39769
40131
  return void 0;
39770
40132
  }
39771
- const toBoolean$3 = (value) => {
40133
+ const toBoolean$2 = (value) => {
39772
40134
  if (typeof value === "boolean") return value;
39773
40135
  if (typeof value === "string") {
39774
40136
  const v = value.trim().toLowerCase();
@@ -40059,7 +40421,7 @@ function hydrateImageBlocks(blocks, mediaFiles) {
40059
40421
  });
40060
40422
  }
40061
40423
  function isGradientFill(value) {
40062
- if (!isPlainObject$3(value)) return false;
40424
+ if (!isPlainObject$2(value)) return false;
40063
40425
  if (value.type !== "gradient") return false;
40064
40426
  const gradientType = value.gradientType;
40065
40427
  if (gradientType !== "linear" && gradientType !== "radial") return false;
@@ -40070,12 +40432,12 @@ function isGradientFill(value) {
40070
40432
  }
40071
40433
  if (!Array.isArray(value.stops) || value.stops.length === 0) return false;
40072
40434
  return value.stops.every((stop) => {
40073
- if (!isPlainObject$3(stop)) return false;
40435
+ if (!isPlainObject$2(stop)) return false;
40074
40436
  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));
40075
40437
  });
40076
40438
  }
40077
40439
  function isSolidFillWithAlpha(value) {
40078
- return isPlainObject$3(value) && value.type === "solidWithAlpha" && typeof value.color === "string" && typeof value.alpha === "number";
40440
+ return isPlainObject$2(value) && value.type === "solidWithAlpha" && typeof value.color === "string" && typeof value.alpha === "number";
40079
40441
  }
40080
40442
  function normalizeFillColor(value) {
40081
40443
  if (value === null) return null;
@@ -40090,10 +40452,10 @@ function normalizeStrokeColor(value) {
40090
40452
  return void 0;
40091
40453
  }
40092
40454
  function normalizeTextContent(value) {
40093
- if (!isPlainObject$3(value)) return void 0;
40455
+ if (!isPlainObject$2(value)) return void 0;
40094
40456
  if (!Array.isArray(value.parts)) return void 0;
40095
40457
  if (value.parts.length === 0) return void 0;
40096
- const validParts = value.parts.filter((p) => isPlainObject$3(p) && typeof p.text === "string");
40458
+ const validParts = value.parts.filter((p) => isPlainObject$2(p) && typeof p.text === "string");
40097
40459
  if (validParts.length === 0) return void 0;
40098
40460
  const result = {
40099
40461
  parts: validParts
@@ -40111,7 +40473,7 @@ function normalizeTextVerticalAlign(value) {
40111
40473
  return void 0;
40112
40474
  }
40113
40475
  function normalizeTextInsets(value) {
40114
- if (!isPlainObject$3(value)) return void 0;
40476
+ if (!isPlainObject$2(value)) return void 0;
40115
40477
  const top2 = pickNumber(value.top);
40116
40478
  const right2 = pickNumber(value.right);
40117
40479
  const bottom2 = pickNumber(value.bottom);
@@ -40123,7 +40485,7 @@ function normalizeTextInsets(value) {
40123
40485
  }
40124
40486
  const OOXML_Z_INDEX_BASE = 251658240;
40125
40487
  function normalizeZIndex(originalAttributes) {
40126
- if (!isPlainObject$3(originalAttributes)) return void 0;
40488
+ if (!isPlainObject$2(originalAttributes)) return void 0;
40127
40489
  const relativeHeight = originalAttributes.relativeHeight;
40128
40490
  if (typeof relativeHeight !== "number") return void 0;
40129
40491
  return Math.max(0, relativeHeight - OOXML_Z_INDEX_BASE);
@@ -41317,321 +41679,6 @@ const ensureBidiIndentPx = (indent) => {
41317
41679
  }
41318
41680
  return adjusted;
41319
41681
  };
41320
- const sdtMetadataCache = /* @__PURE__ */ new Map();
41321
- function resolveStyle(node, context, options = {}) {
41322
- let paragraph = createDefaultParagraph();
41323
- let character = createDefaultCharacter(context);
41324
- let numbering;
41325
- const chain = resolveStyleChain(node.styleId, context.styles);
41326
- for (const style2 of chain) {
41327
- paragraph = mergeParagraph(paragraph, style2.paragraph);
41328
- character = mergeCharacter(character, style2.character);
41329
- if (!numbering && style2.numbering) {
41330
- numbering = resolveNumbering(style2.numbering.numId, style2.numbering.level, context);
41331
- }
41332
- }
41333
- paragraph = mergeParagraph(paragraph, node.paragraphProps);
41334
- character = mergeCharacter(character, node.characterProps);
41335
- if (node.numbering) {
41336
- numbering = resolveNumbering(node.numbering.numId, node.numbering.level, context);
41337
- }
41338
- const sdt = options?.sdt ? resolveSdtMetadata(options.sdt) : void 0;
41339
- return {
41340
- paragraph,
41341
- character,
41342
- numbering,
41343
- sdt
41344
- };
41345
- }
41346
- function resolveNumbering(numId, level, context) {
41347
- const def = context.numbering?.[numId];
41348
- if (!def) return void 0;
41349
- const levelDef = def.levels.find((entry) => entry.level === level) ?? def.levels[level];
41350
- if (!levelDef) return void 0;
41351
- return {
41352
- numId,
41353
- level,
41354
- indent: {
41355
- left: levelDef.indent?.left,
41356
- hanging: levelDef.indent?.hanging
41357
- },
41358
- format: levelDef.format ?? "decimal",
41359
- text: levelDef.text ?? "%1.",
41360
- start: levelDef.start ?? 1
41361
- };
41362
- }
41363
- function resolveSdtMetadata(input) {
41364
- if (!input) return void 0;
41365
- const { nodeType, attrs, cacheKey: explicitKey } = input;
41366
- if (!nodeType) return void 0;
41367
- const normalizedAttrs = isPlainObject$2(attrs) ? attrs : {};
41368
- const cacheKey = buildSdtCacheKey(nodeType, normalizedAttrs, explicitKey);
41369
- if (cacheKey && sdtMetadataCache.has(cacheKey)) {
41370
- return sdtMetadataCache.get(cacheKey);
41371
- }
41372
- let metadata;
41373
- switch (nodeType) {
41374
- case "fieldAnnotation":
41375
- metadata = normalizeFieldAnnotationMetadata(normalizedAttrs);
41376
- break;
41377
- case "structuredContent":
41378
- case "structuredContentBlock":
41379
- metadata = normalizeStructuredContentMetadata(nodeType, normalizedAttrs);
41380
- break;
41381
- case "documentSection":
41382
- metadata = normalizeDocumentSectionMetadata(normalizedAttrs);
41383
- break;
41384
- case "docPartObject":
41385
- metadata = normalizeDocPartMetadata(normalizedAttrs);
41386
- break;
41387
- }
41388
- if (metadata && cacheKey) {
41389
- sdtMetadataCache.set(cacheKey, metadata);
41390
- }
41391
- return metadata;
41392
- }
41393
- function createDefaultParagraph(_context) {
41394
- return {
41395
- alignment: "left",
41396
- spacing: {
41397
- before: 0,
41398
- after: 0,
41399
- line: 12,
41400
- lineRule: "auto"
41401
- },
41402
- indent: {
41403
- left: 0,
41404
- right: 0,
41405
- firstLine: 0,
41406
- hanging: 0
41407
- },
41408
- tabs: []
41409
- };
41410
- }
41411
- function createDefaultCharacter(context) {
41412
- const baseFont = context.defaults?.paragraphFont ?? "Calibri";
41413
- const fallback = context.defaults?.paragraphFontFallback;
41414
- const wordFamily = context.defaults?.paragraphFontFamily;
41415
- const resolvedFamily = toCssFontFamily(baseFont, { fallback, wordFamily }) ?? baseFont;
41416
- return {
41417
- font: {
41418
- family: resolvedFamily,
41419
- size: context.defaults?.fontSize ?? 11,
41420
- weight: 400,
41421
- italic: false
41422
- },
41423
- color: "#000000"
41424
- };
41425
- }
41426
- function resolveStyleChain(styleId, styles) {
41427
- if (!styleId || !styles) return [];
41428
- const result = [];
41429
- const visited = /* @__PURE__ */ new Set();
41430
- let current = styles[styleId];
41431
- while (current && !visited.has(current.id)) {
41432
- result.unshift(current);
41433
- visited.add(current.id);
41434
- current = current.basedOn ? styles[current.basedOn] : void 0;
41435
- }
41436
- return result;
41437
- }
41438
- function mergeParagraph(base2, overrides) {
41439
- if (!overrides) return base2;
41440
- return {
41441
- ...base2,
41442
- alignment: overrides.alignment ?? base2.alignment,
41443
- spacing: overrides.spacing ? { ...base2.spacing, ...overrides.spacing } : base2.spacing,
41444
- indent: overrides.indent ? { ...base2.indent, ...overrides.indent } : base2.indent,
41445
- borders: overrides.borders ? { ...base2.borders, ...overrides.borders } : base2.borders,
41446
- shading: overrides.shading ?? base2.shading,
41447
- tabs: overrides.tabs ?? base2.tabs
41448
- };
41449
- }
41450
- function mergeCharacter(base2, overrides) {
41451
- if (!overrides) return base2;
41452
- return {
41453
- ...base2,
41454
- font: overrides.font ? { ...base2.font, ...overrides.font } : base2.font,
41455
- color: overrides.color ?? base2.color,
41456
- underline: overrides.underline ?? base2.underline,
41457
- strike: overrides.strike ?? base2.strike,
41458
- highlight: overrides.highlight ?? base2.highlight,
41459
- letterSpacing: overrides.letterSpacing ?? base2.letterSpacing
41460
- };
41461
- }
41462
- function normalizeFieldAnnotationMetadata(attrs) {
41463
- const fieldId = toOptionalString(attrs.fieldId) ?? "";
41464
- const formatting = extractFormatting(attrs);
41465
- const size2 = normalizeSize(attrs.size);
41466
- const extras = isPlainObject$2(attrs.extras) ? attrs.extras : null;
41467
- const marks = isPlainObject$2(attrs.marks) ? attrs.marks : void 0;
41468
- return {
41469
- type: "fieldAnnotation",
41470
- fieldId,
41471
- variant: normalizeFieldAnnotationVariant(attrs.type),
41472
- fieldType: toOptionalString(attrs.fieldType),
41473
- displayLabel: toOptionalString(attrs.displayLabel),
41474
- defaultDisplayLabel: toOptionalString(attrs.defaultDisplayLabel),
41475
- alias: toOptionalString(attrs.alias),
41476
- fieldColor: normalizeColorValue(attrs.fieldColor),
41477
- borderColor: normalizeColorValue(attrs.borderColor),
41478
- highlighted: toBoolean$2(attrs.highlighted, true),
41479
- fontFamily: toNullableString(attrs.fontFamily),
41480
- fontSize: normalizeFontSize(attrs.fontSize),
41481
- textColor: normalizeColorValue(attrs.textColor) ?? null,
41482
- textHighlight: normalizeColorValue(attrs.textHighlight) ?? null,
41483
- linkUrl: toNullableString(attrs.linkUrl),
41484
- imageSrc: toNullableString(attrs.imageSrc),
41485
- rawHtml: attrs.rawHtml ?? void 0,
41486
- size: size2 ?? null,
41487
- extras,
41488
- multipleImage: toBoolean$2(attrs.multipleImage, false),
41489
- hash: toOptionalString(attrs.hash) ?? null,
41490
- generatorIndex: toNumber(attrs.generatorIndex),
41491
- sdtId: toOptionalString(attrs.sdtId) ?? null,
41492
- hidden: toBoolean$2(attrs.hidden, false),
41493
- visibility: normalizeVisibility(attrs.visibility),
41494
- isLocked: toBoolean$2(attrs.isLocked, false),
41495
- formatting,
41496
- marks
41497
- };
41498
- }
41499
- function normalizeStructuredContentMetadata(nodeType, attrs) {
41500
- return {
41501
- type: "structuredContent",
41502
- scope: nodeType === "structuredContentBlock" ? "block" : "inline",
41503
- id: toNullableString(attrs.id),
41504
- tag: toOptionalString(attrs.tag),
41505
- alias: toOptionalString(attrs.alias),
41506
- sdtPr: attrs.sdtPr
41507
- };
41508
- }
41509
- function normalizeDocumentSectionMetadata(attrs) {
41510
- return {
41511
- type: "documentSection",
41512
- id: toNullableString(attrs.id),
41513
- title: toOptionalString(attrs.title) ?? null,
41514
- description: toOptionalString(attrs.description) ?? null,
41515
- sectionType: toOptionalString(attrs.sectionType) ?? null,
41516
- isLocked: toBoolean$2(attrs.isLocked, false),
41517
- sdBlockId: toNullableString(attrs.sdBlockId)
41518
- };
41519
- }
41520
- function normalizeDocPartMetadata(attrs) {
41521
- return {
41522
- type: "docPartObject",
41523
- gallery: toOptionalString(attrs.docPartGallery ?? attrs.gallery) ?? null,
41524
- // Source uniqueId from attrs.id (PM adapter uses getDocPartObjectId which extracts attrs.id)
41525
- // Fall back to attrs.uniqueId for compatibility
41526
- uniqueId: toOptionalString(attrs.id ?? attrs.uniqueId) ?? null,
41527
- alias: toOptionalString(attrs.alias) ?? null,
41528
- instruction: toOptionalString(attrs.instruction) ?? null
41529
- };
41530
- }
41531
- function isPlainObject$2(value) {
41532
- return !!value && typeof value === "object" && !Array.isArray(value);
41533
- }
41534
- function toOptionalString(value) {
41535
- if (value == null) return void 0;
41536
- if (typeof value === "string") {
41537
- const trimmed = value.trim();
41538
- return trimmed.length ? trimmed : void 0;
41539
- }
41540
- return String(value);
41541
- }
41542
- function toNullableString(value) {
41543
- const str = toOptionalString(value);
41544
- return str ?? null;
41545
- }
41546
- function toBoolean$2(value, fallback) {
41547
- if (typeof value === "boolean") return value;
41548
- if (typeof value === "string") {
41549
- const lower = value.toLowerCase();
41550
- if (lower === "true") return true;
41551
- if (lower === "false") return false;
41552
- }
41553
- if (value == null) return fallback;
41554
- return Boolean(value);
41555
- }
41556
- function normalizeVisibility(value) {
41557
- if (typeof value !== "string") return void 0;
41558
- const normalized = value.toLowerCase();
41559
- if (normalized === "visible" || normalized === "hidden") {
41560
- return normalized;
41561
- }
41562
- return void 0;
41563
- }
41564
- function normalizeColorValue(value) {
41565
- if (typeof value !== "string") return void 0;
41566
- const trimmed = value.trim();
41567
- if (!trimmed || trimmed.toLowerCase() === "none") return void 0;
41568
- return trimmed;
41569
- }
41570
- function normalizeFontSize(value) {
41571
- if (value == null) return null;
41572
- if (typeof value === "number") {
41573
- return Number.isFinite(value) ? value : null;
41574
- }
41575
- if (typeof value === "string") {
41576
- const trimmed = value.trim();
41577
- return trimmed.length ? trimmed : null;
41578
- }
41579
- return null;
41580
- }
41581
- function toNumber(value) {
41582
- if (typeof value === "number") {
41583
- return Number.isFinite(value) ? value : null;
41584
- }
41585
- if (typeof value === "string") {
41586
- const parsed = parseFloat(value);
41587
- return Number.isFinite(parsed) ? parsed : null;
41588
- }
41589
- return null;
41590
- }
41591
- function normalizeSize(value) {
41592
- if (!isPlainObject$2(value)) return null;
41593
- const obj = value;
41594
- const width = toNumber(obj.width);
41595
- const height = toNumber(obj.height);
41596
- if (width == null && height == null) return null;
41597
- const result = {};
41598
- if (width != null) result.width = width;
41599
- if (height != null) result.height = height;
41600
- return result;
41601
- }
41602
- function normalizeFieldAnnotationVariant(value) {
41603
- if (typeof value !== "string") return void 0;
41604
- const normalized = value.toLowerCase();
41605
- if (normalized === "text" || normalized === "image" || normalized === "signature" || normalized === "checkbox" || normalized === "html" || normalized === "link") {
41606
- return normalized;
41607
- }
41608
- return void 0;
41609
- }
41610
- function extractFormatting(attrs) {
41611
- const bold = toBoolean$2(attrs.bold, false);
41612
- const italic = toBoolean$2(attrs.italic, false);
41613
- const underline = toBoolean$2(attrs.underline, false);
41614
- const formatting = {};
41615
- if (bold) formatting.bold = true;
41616
- if (italic) formatting.italic = true;
41617
- if (underline) formatting.underline = true;
41618
- return Object.keys(formatting).length ? formatting : void 0;
41619
- }
41620
- function buildSdtCacheKey(nodeType, attrs, explicitKey) {
41621
- const provided = toOptionalString(explicitKey);
41622
- if (provided) {
41623
- return `${nodeType}:${provided}`;
41624
- }
41625
- const hash2 = toOptionalString(attrs.hash);
41626
- if (hash2) {
41627
- return `${nodeType}:${hash2}`;
41628
- }
41629
- const id = toOptionalString(attrs.id);
41630
- if (id) {
41631
- return `${nodeType}:${id}`;
41632
- }
41633
- return void 0;
41634
- }
41635
41682
  const DEFAULT_LIST_HANGING_PX = 18;
41636
41683
  const LIST_MARKER_GAP = 8;
41637
41684
  const DEFAULT_BULLET_GLYPH = "•";
@@ -42191,6 +42238,7 @@ const EMPTY_NUMBERING_CONTEXT = {
42191
42238
  definitions: {},
42192
42239
  abstracts: {}
42193
42240
  };
42241
+ const ooxmlResolver = superEditor_converter.createOoxmlResolver({ pPr: superEditor_converter.translator, rPr: superEditor_converter.translator$1 });
42194
42242
  const hydrateParagraphStyleAttrs = (para, context, preResolved) => {
42195
42243
  if (!hasParagraphStyleContext(context)) {
42196
42244
  return null;
@@ -42218,7 +42266,7 @@ const hydrateParagraphStyleAttrs = (para, context, preResolved) => {
42218
42266
  // should still get docDefaults spacing from style resolution
42219
42267
  numbering: context.numbering ?? EMPTY_NUMBERING_CONTEXT
42220
42268
  };
42221
- const resolved = superEditor_converter.resolveParagraphProperties(resolverParams, inlineProps);
42269
+ const resolved = ooxmlResolver.resolveParagraphProperties(resolverParams, inlineProps);
42222
42270
  if (!resolved) {
42223
42271
  return null;
42224
42272
  }
@@ -42273,6 +42321,138 @@ const cloneIfObject = (value) => {
42273
42321
  }
42274
42322
  return { ...value };
42275
42323
  };
42324
+ const buildCharacterStyleHydration = (resolved, docx) => {
42325
+ const fontFamily2 = extractFontFamily(resolved.fontFamily, docx);
42326
+ const fontSize2 = typeof resolved.fontSize === "number" ? resolved.fontSize : 20;
42327
+ const color = extractColorValue(resolved.color);
42328
+ const bold = normalizeBooleanProp(resolved.bold);
42329
+ const italic = normalizeBooleanProp(resolved.italic);
42330
+ const strike = normalizeBooleanProp(resolved.strike);
42331
+ const underline = extractUnderline(resolved.underline);
42332
+ const letterSpacing = typeof resolved.letterSpacing === "number" ? resolved.letterSpacing : void 0;
42333
+ return {
42334
+ fontFamily: fontFamily2,
42335
+ fontSize: fontSize2,
42336
+ color,
42337
+ bold,
42338
+ italic,
42339
+ strike,
42340
+ underline,
42341
+ letterSpacing
42342
+ };
42343
+ };
42344
+ const hydrateCharacterStyleAttrs = (para, context, resolvedPpr) => {
42345
+ if (!hasParagraphStyleContext(context)) {
42346
+ return null;
42347
+ }
42348
+ const attrs = para.attrs ?? {};
42349
+ const paragraphProps = typeof attrs.paragraphProperties === "object" && attrs.paragraphProperties !== null ? attrs.paragraphProperties : {};
42350
+ const styleIdSource = attrs.styleId ?? paragraphProps.styleId;
42351
+ const styleId = typeof styleIdSource === "string" && styleIdSource.trim() ? styleIdSource : null;
42352
+ const inlineRpr = {};
42353
+ const pprForChain = resolvedPpr ?? { styleId };
42354
+ const numberingProps = attrs.numberingProperties ?? paragraphProps.numberingProperties;
42355
+ if (numberingProps != null) {
42356
+ pprForChain.numberingProperties = numberingProps;
42357
+ }
42358
+ const resolverParams = {
42359
+ docx: context.docx,
42360
+ numbering: context.numbering ?? EMPTY_NUMBERING_CONTEXT
42361
+ };
42362
+ let resolved = null;
42363
+ try {
42364
+ resolved = ooxmlResolver.resolveRunProperties(
42365
+ resolverParams,
42366
+ inlineRpr,
42367
+ pprForChain,
42368
+ false,
42369
+ // not list number marker
42370
+ false
42371
+ // not numberingDefinedInline
42372
+ );
42373
+ if (!resolved || typeof resolved !== "object") {
42374
+ return null;
42375
+ }
42376
+ } catch {
42377
+ return null;
42378
+ }
42379
+ return buildCharacterStyleHydration(resolved, context.docx);
42380
+ };
42381
+ const hydrateMarkerStyleAttrs = (para, context, resolvedPpr) => {
42382
+ if (!hasParagraphStyleContext(context)) {
42383
+ return null;
42384
+ }
42385
+ const attrs = para.attrs ?? {};
42386
+ const paragraphProps = typeof attrs.paragraphProperties === "object" && attrs.paragraphProperties !== null ? attrs.paragraphProperties : {};
42387
+ const styleIdSource = attrs.styleId ?? paragraphProps.styleId;
42388
+ const styleId = typeof styleIdSource === "string" && styleIdSource.trim() ? styleIdSource : null;
42389
+ const inlineRpr = {};
42390
+ const numberingProps = attrs.numberingProperties ?? paragraphProps.numberingProperties;
42391
+ const numberingDefinedInline = numberingProps?.numId != null;
42392
+ const pprForChain = resolvedPpr ? { ...resolvedPpr } : { styleId };
42393
+ if (styleId && !pprForChain.styleId) {
42394
+ pprForChain.styleId = styleId;
42395
+ }
42396
+ if (numberingProps != null) {
42397
+ pprForChain.numberingProperties = numberingProps;
42398
+ }
42399
+ const resolverParams = {
42400
+ docx: context.docx,
42401
+ numbering: context.numbering ?? EMPTY_NUMBERING_CONTEXT
42402
+ };
42403
+ let resolved = null;
42404
+ try {
42405
+ resolved = ooxmlResolver.resolveRunProperties(
42406
+ resolverParams,
42407
+ inlineRpr,
42408
+ pprForChain,
42409
+ true,
42410
+ numberingDefinedInline
42411
+ );
42412
+ if (!resolved || typeof resolved !== "object") {
42413
+ return null;
42414
+ }
42415
+ } catch {
42416
+ return null;
42417
+ }
42418
+ return buildCharacterStyleHydration(resolved, context.docx);
42419
+ };
42420
+ function extractFontFamily(fontFamily2, docx) {
42421
+ if (!fontFamily2 || typeof fontFamily2 !== "object") return void 0;
42422
+ const toCssFontFamily2 = superEditor_converter.SuperConverter.toCssFontFamily;
42423
+ const resolved = superEditor_converter.resolveDocxFontFamily(fontFamily2, docx ?? null, toCssFontFamily2);
42424
+ return resolved ?? void 0;
42425
+ }
42426
+ function extractColorValue(color) {
42427
+ if (!color || typeof color !== "object") return void 0;
42428
+ const c2 = color;
42429
+ const val = c2.val;
42430
+ if (typeof val !== "string") return void 0;
42431
+ if (!val || val.toLowerCase() === "auto") return void 0;
42432
+ return val;
42433
+ }
42434
+ function normalizeBooleanProp(value) {
42435
+ if (value == null) return void 0;
42436
+ if (typeof value === "boolean") return value;
42437
+ if (typeof value === "number") return value !== 0;
42438
+ if (typeof value === "string") {
42439
+ const lower = value.toLowerCase();
42440
+ if (lower === "0" || lower === "false" || lower === "off") return false;
42441
+ if (lower === "1" || lower === "true" || lower === "on" || lower === "") return true;
42442
+ }
42443
+ return Boolean(value);
42444
+ }
42445
+ function extractUnderline(underline) {
42446
+ if (!underline || typeof underline !== "object") return void 0;
42447
+ const u = underline;
42448
+ const type = u["w:val"] ?? u.type ?? u.val;
42449
+ if (typeof type !== "string" || type === "none") return void 0;
42450
+ const color = u["w:color"] ?? u.color;
42451
+ return {
42452
+ type,
42453
+ color: typeof color === "string" ? color : void 0
42454
+ };
42455
+ }
42276
42456
  const { resolveSpacingIndent } = Engines;
42277
42457
  const DEFAULT_DECIMAL_SEPARATOR$2 = ".";
42278
42458
  const isValidNumberingId = (numId) => {
@@ -42788,7 +42968,7 @@ const extractDropCapRunFromParagraph = (para) => {
42788
42968
  }
42789
42969
  return dropCapRun;
42790
42970
  };
42791
- const computeWordLayoutForParagraph = (paragraphAttrs, numberingProps, styleContext, _paragraphNode) => {
42971
+ const computeWordLayoutForParagraph = (paragraphAttrs, numberingProps, styleContext, paragraphNode, converterContext, resolvedPpr) => {
42792
42972
  if (numberingProps === null) {
42793
42973
  return null;
42794
42974
  }
@@ -42826,7 +43006,23 @@ const computeWordLayoutForParagraph = (paragraphAttrs, numberingProps, styleCont
42826
43006
  spacing: {}
42827
43007
  }
42828
43008
  };
42829
- let markerRun = numberingProps?.resolvedMarkerRpr;
43009
+ let markerRun;
43010
+ const markerHydration = paragraphNode && converterContext ? hydrateMarkerStyleAttrs(paragraphNode, converterContext, resolvedPpr) : null;
43011
+ if (markerHydration) {
43012
+ const resolvedColor = markerHydration.color ? `#${markerHydration.color.replace("#", "")}` : void 0;
43013
+ markerRun = {
43014
+ fontFamily: markerHydration.fontFamily ?? "Times New Roman",
43015
+ fontSize: markerHydration.fontSize / 2,
43016
+ // half-points to points
43017
+ bold: markerHydration.bold,
43018
+ italic: markerHydration.italic,
43019
+ color: resolvedColor,
43020
+ letterSpacing: markerHydration.letterSpacing != null ? twipsToPx$1(markerHydration.letterSpacing) : void 0
43021
+ };
43022
+ }
43023
+ if (!markerRun) {
43024
+ markerRun = numberingProps?.resolvedMarkerRpr;
43025
+ }
42830
43026
  if (!markerRun) {
42831
43027
  const { character: characterStyle } = resolveStyle({ styleId: paragraphAttrs.styleId }, styleContext);
42832
43028
  if (characterStyle) {
@@ -43147,7 +43343,12 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
43147
43343
  const numId = numberingProps.numId;
43148
43344
  const ilvl = Number.isFinite(numberingProps.ilvl) ? Math.max(0, Math.floor(Number(numberingProps.ilvl))) : 0;
43149
43345
  const numericNumId = typeof numId === "number" ? numId : void 0;
43150
- const resolvedLevel = resolveNumberingFromContext(numId, ilvl, converterContext?.numbering);
43346
+ let resolvedLevel;
43347
+ try {
43348
+ resolvedLevel = resolveNumberingFromContext(numId, ilvl, converterContext?.numbering);
43349
+ } catch (error) {
43350
+ resolvedLevel = void 0;
43351
+ }
43151
43352
  if (resolvedLevel) {
43152
43353
  if (resolvedLevel.format && numberingProps.format == null) {
43153
43354
  numberingProps.format = resolvedLevel.format;
@@ -43208,7 +43409,19 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
43208
43409
  }
43209
43410
  }
43210
43411
  }
43211
- let wordLayout = computeWordLayoutForParagraph(paragraphAttrs, enrichedNumberingProps, styleContext);
43412
+ let wordLayout = null;
43413
+ try {
43414
+ wordLayout = computeWordLayoutForParagraph(
43415
+ paragraphAttrs,
43416
+ enrichedNumberingProps,
43417
+ styleContext,
43418
+ para,
43419
+ converterContext,
43420
+ hydrated?.resolved
43421
+ );
43422
+ } catch (error) {
43423
+ wordLayout = null;
43424
+ }
43212
43425
  if (!wordLayout && enrichedNumberingProps.resolvedLevelIndent) {
43213
43426
  const resolvedIndentPx = convertIndentTwipsToPx(enrichedNumberingProps.resolvedLevelIndent);
43214
43427
  const baseIndent = resolvedIndentPx ?? enrichedNumberingProps.resolvedLevelIndent;
@@ -43753,7 +43966,7 @@ const V_RELATIVE_VALUES$1 = /* @__PURE__ */ new Set(["paragraph", "page", "margi
43753
43966
  const H_ALIGN_VALUES$1 = /* @__PURE__ */ new Set(["left", "center", "right"]);
43754
43967
  const V_ALIGN_VALUES$1 = /* @__PURE__ */ new Set(["top", "center", "bottom"]);
43755
43968
  const getAttrs$1 = (node) => {
43756
- return isPlainObject$3(node.attrs) ? node.attrs : {};
43969
+ return isPlainObject$2(node.attrs) ? node.attrs : {};
43757
43970
  };
43758
43971
  const normalizeWrapType$1 = (value) => {
43759
43972
  if (typeof value !== "string") return void 0;
@@ -43776,7 +43989,7 @@ const normalizePolygon$1 = (value) => {
43776
43989
  return polygon.length > 0 ? polygon : void 0;
43777
43990
  };
43778
43991
  const normalizeWrap$2 = (value) => {
43779
- if (!isPlainObject$3(value)) {
43992
+ if (!isPlainObject$2(value)) {
43780
43993
  return void 0;
43781
43994
  }
43782
43995
  const type = normalizeWrapType$1(value.type);
@@ -43784,7 +43997,7 @@ const normalizeWrap$2 = (value) => {
43784
43997
  return void 0;
43785
43998
  }
43786
43999
  const wrap = { type };
43787
- const attrs = isPlainObject$3(value.attrs) ? value.attrs : {};
44000
+ const attrs = isPlainObject$2(value.attrs) ? value.attrs : {};
43788
44001
  const wrapText = normalizeWrapText$1(attrs.wrapText);
43789
44002
  if (wrapText) {
43790
44003
  wrap.wrapText = wrapText;
@@ -43801,7 +44014,7 @@ const normalizeWrap$2 = (value) => {
43801
44014
  if (polygon) {
43802
44015
  wrap.polygon = polygon;
43803
44016
  }
43804
- const behindDoc = toBoolean$3(attrs.behindDoc);
44017
+ const behindDoc = toBoolean$2(attrs.behindDoc);
43805
44018
  if (behindDoc != null) {
43806
44019
  wrap.behindDoc = behindDoc;
43807
44020
  }
@@ -43816,10 +44029,10 @@ const normalizeAnchorAlign$1 = (value, allowed) => {
43816
44029
  return allowed.has(value) ? value : void 0;
43817
44030
  };
43818
44031
  const normalizeAnchorData$1 = (value, attrs, wrapBehindDoc) => {
43819
- const raw = isPlainObject$3(value) ? value : void 0;
43820
- const marginOffset = isPlainObject$3(attrs.marginOffset) ? attrs.marginOffset : void 0;
43821
- const simplePos = isPlainObject$3(attrs.simplePos) ? attrs.simplePos : void 0;
43822
- const originalAttrs = isPlainObject$3(attrs.originalAttributes) ? attrs.originalAttributes : void 0;
44032
+ const raw = isPlainObject$2(value) ? value : void 0;
44033
+ const marginOffset = isPlainObject$2(attrs.marginOffset) ? attrs.marginOffset : void 0;
44034
+ const simplePos = isPlainObject$2(attrs.simplePos) ? attrs.simplePos : void 0;
44035
+ const originalAttrs = isPlainObject$2(attrs.originalAttributes) ? attrs.originalAttributes : void 0;
43823
44036
  const isAnchored = attrs.isAnchor === true || Boolean(raw);
43824
44037
  const anchor = {};
43825
44038
  if (isAnchored) {
@@ -43837,7 +44050,7 @@ const normalizeAnchorData$1 = (value, attrs, wrapBehindDoc) => {
43837
44050
  if (offsetH != null) anchor.offsetH = offsetH;
43838
44051
  const offsetV = pickNumber(marginOffset?.top ?? marginOffset?.vertical ?? raw?.offsetV ?? simplePos?.y);
43839
44052
  if (offsetV != null) anchor.offsetV = offsetV;
43840
- const behindDoc = toBoolean$3(raw?.behindDoc ?? wrapBehindDoc ?? originalAttrs?.behindDoc);
44053
+ const behindDoc = toBoolean$2(raw?.behindDoc ?? wrapBehindDoc ?? originalAttrs?.behindDoc);
43841
44054
  if (behindDoc != null) anchor.behindDoc = behindDoc;
43842
44055
  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;
43843
44056
  return hasData ? anchor : void 0;
@@ -43962,7 +44175,7 @@ function handleShapeTextboxNode(node, context) {
43962
44175
  }
43963
44176
  }
43964
44177
  const getAttrs = (node) => {
43965
- return isPlainObject$3(node.attrs) ? { ...node.attrs } : {};
44178
+ return isPlainObject$2(node.attrs) ? { ...node.attrs } : {};
43966
44179
  };
43967
44180
  const parseFullWidth = (value) => {
43968
44181
  if (typeof value === "string") {
@@ -43981,7 +44194,7 @@ function contentBlockNodeToDrawingBlock(node, nextBlockId, positions) {
43981
44194
  if (rawAttrs.horizontalRule !== true) {
43982
44195
  return null;
43983
44196
  }
43984
- const size2 = isPlainObject$3(rawAttrs.size) ? rawAttrs.size : void 0;
44197
+ const size2 = isPlainObject$2(rawAttrs.size) ? rawAttrs.size : void 0;
43985
44198
  const { width, isFullWidth } = parseFullWidth(size2?.width);
43986
44199
  const height = pickNumber(size2?.height);
43987
44200
  if (!height || height <= 0) {
@@ -44183,6 +44396,9 @@ const extractRunStyleId = (runProperties) => {
44183
44396
  return null;
44184
44397
  };
44185
44398
  const DEFAULT_IMAGE_DIMENSION_PX = 100;
44399
+ const HALF_POINTS_PER_POINT = 2;
44400
+ const SCREEN_DPI = 96;
44401
+ const POINT_DPI = 72;
44186
44402
  function isInlineImage(node) {
44187
44403
  const attrs = node.attrs ?? {};
44188
44404
  const wrap = attrs.wrap;
@@ -44210,8 +44426,8 @@ function imageNodeToRun(node, positions, activeSdt) {
44210
44426
  const size2 = attrs.size ?? {};
44211
44427
  const width = typeof size2.width === "number" && Number.isFinite(size2.width) && size2.width > 0 ? size2.width : DEFAULT_IMAGE_DIMENSION_PX;
44212
44428
  const height = typeof size2.height === "number" && Number.isFinite(size2.height) && size2.height > 0 ? size2.height : DEFAULT_IMAGE_DIMENSION_PX;
44213
- const wrap = isPlainObject$3(attrs.wrap) ? attrs.wrap : {};
44214
- const wrapAttrs = isPlainObject$3(wrap.attrs) ? wrap.attrs : {};
44429
+ const wrap = isPlainObject$2(attrs.wrap) ? attrs.wrap : {};
44430
+ const wrapAttrs = isPlainObject$2(wrap.attrs) ? wrap.attrs : {};
44215
44431
  const run = {
44216
44432
  kind: "image",
44217
44433
  src,
@@ -44421,15 +44637,6 @@ const applyBaseRunDefaults = (run, defaults, uiDisplayFallbackFont, fallbackSize
44421
44637
  if (defaults.letterSpacing != null && run.letterSpacing == null) {
44422
44638
  run.letterSpacing = defaults.letterSpacing;
44423
44639
  }
44424
- if (defaults.bold && run.bold === void 0) {
44425
- run.bold = true;
44426
- }
44427
- if (defaults.italic && run.italic === void 0) {
44428
- run.italic = true;
44429
- }
44430
- if (defaults.underline && !run.underline) {
44431
- run.underline = defaults.underline;
44432
- }
44433
44640
  };
44434
44641
  function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defaultSize, styleContext, listCounterContext, trackedChanges, bookmarks, hyperlinkConfig = DEFAULT_HYPERLINK_CONFIG$1, themeColors, converters, converterContext) {
44435
44642
  const baseBlockId = nextBlockId("paragraph");
@@ -44438,28 +44645,45 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
44438
44645
  const paragraphHydration = converterContext ? hydrateParagraphStyleAttrs(para, converterContext) : null;
44439
44646
  let baseRunDefaults = {};
44440
44647
  try {
44441
- const spacingSource = para.attrs?.spacing !== void 0 ? para.attrs.spacing : paragraphProps.spacing !== void 0 ? paragraphProps.spacing : paragraphHydration?.spacing;
44442
- const indentSource = para.attrs?.indent ?? paragraphProps.indent ?? paragraphHydration?.indent;
44443
- const normalizedSpacing = normalizeParagraphSpacing(spacingSource);
44444
- const normalizedIndent = normalizePxIndent(indentSource) ?? normalizeParagraphIndent(indentSource ?? para.attrs?.textIndent);
44445
- const styleNodeAttrs = paragraphHydration?.tabStops && !para.attrs?.tabStops && !para.attrs?.tabs ? { ...para.attrs ?? {}, tabStops: paragraphHydration.tabStops } : para.attrs ?? {};
44446
- const styleNode = buildStyleNodeFromAttrs(styleNodeAttrs, normalizedSpacing, normalizedIndent);
44447
- if (styleNodeAttrs.styleId == null && paragraphProps.styleId) {
44448
- styleNode.styleId = paragraphProps.styleId;
44449
- }
44450
- const resolved = resolveStyle(styleNode, styleContext);
44451
- baseRunDefaults = {
44452
- fontFamily: resolved.character.font?.family,
44453
- fontSizePx: ptToPx(resolved.character.font?.size),
44454
- color: resolved.character.color,
44455
- bold: resolved.character.font?.weight != null ? resolved.character.font.weight >= 600 : void 0,
44456
- italic: resolved.character.font?.italic,
44457
- underline: resolved.character.underline ? {
44458
- style: resolved.character.underline.style,
44459
- color: resolved.character.underline.color
44460
- } : void 0,
44461
- letterSpacing: ptToPx(resolved.character.letterSpacing)
44462
- };
44648
+ const charHydration = converterContext ? hydrateCharacterStyleAttrs(para, converterContext, paragraphHydration?.resolved) : null;
44649
+ if (charHydration) {
44650
+ const fontSizePx = charHydration.fontSize / HALF_POINTS_PER_POINT * (SCREEN_DPI / POINT_DPI);
44651
+ baseRunDefaults = {
44652
+ fontFamily: charHydration.fontFamily,
44653
+ fontSizePx,
44654
+ color: charHydration.color ? `#${charHydration.color.replace("#", "")}` : void 0,
44655
+ bold: charHydration.bold,
44656
+ italic: charHydration.italic,
44657
+ underline: charHydration.underline ? {
44658
+ style: charHydration.underline.type,
44659
+ color: charHydration.underline.color
44660
+ } : void 0,
44661
+ letterSpacing: charHydration.letterSpacing != null ? twipsToPx$1(charHydration.letterSpacing) : void 0
44662
+ };
44663
+ } else {
44664
+ const spacingSource = para.attrs?.spacing !== void 0 ? para.attrs.spacing : paragraphProps.spacing !== void 0 ? paragraphProps.spacing : paragraphHydration?.spacing;
44665
+ const indentSource = para.attrs?.indent ?? paragraphProps.indent ?? paragraphHydration?.indent;
44666
+ const normalizedSpacing = normalizeParagraphSpacing(spacingSource);
44667
+ const normalizedIndent = normalizePxIndent(indentSource) ?? normalizeParagraphIndent(indentSource ?? para.attrs?.textIndent);
44668
+ const styleNodeAttrs = paragraphHydration?.tabStops && !para.attrs?.tabStops && !para.attrs?.tabs ? { ...para.attrs ?? {}, tabStops: paragraphHydration.tabStops } : para.attrs ?? {};
44669
+ const styleNode = buildStyleNodeFromAttrs(styleNodeAttrs, normalizedSpacing, normalizedIndent);
44670
+ if (styleNodeAttrs.styleId == null && paragraphProps.styleId) {
44671
+ styleNode.styleId = paragraphProps.styleId;
44672
+ }
44673
+ const resolved = resolveStyle(styleNode, styleContext);
44674
+ baseRunDefaults = {
44675
+ fontFamily: resolved.character.font?.family,
44676
+ fontSizePx: ptToPx(resolved.character.font?.size),
44677
+ color: resolved.character.color,
44678
+ bold: resolved.character.font?.weight != null ? resolved.character.font.weight >= 600 : void 0,
44679
+ italic: resolved.character.font?.italic,
44680
+ underline: resolved.character.underline ? {
44681
+ style: resolved.character.underline.style,
44682
+ color: resolved.character.underline.color
44683
+ } : void 0,
44684
+ letterSpacing: ptToPx(resolved.character.letterSpacing)
44685
+ };
44686
+ }
44463
44687
  } catch {
44464
44688
  baseRunDefaults = {};
44465
44689
  }
@@ -48010,7 +48234,8 @@ async function measureParagraphBlock(block, maxWidth) {
48010
48234
  const originX = currentLine.width;
48011
48235
  const { target, nextIndex, stop } = getNextTabStopPx(currentLine.width, tabStops, tabStopCursor);
48012
48236
  tabStopCursor = nextIndex;
48013
- const tabAdvance = Math.max(0, target - currentLine.width);
48237
+ const clampedTarget = Math.min(target, currentLine.maxWidth);
48238
+ const tabAdvance = Math.max(0, clampedTarget - currentLine.width);
48014
48239
  currentLine.width = roundValue(currentLine.width + tabAdvance);
48015
48240
  run.width = tabAdvance;
48016
48241
  currentLine.maxFontSize = Math.max(currentLine.maxFontSize, 12);
@@ -48018,14 +48243,14 @@ async function measureParagraphBlock(block, maxWidth) {
48018
48243
  currentLine.toChar = 1;
48019
48244
  if (stop) {
48020
48245
  validateTabStopVal(stop);
48021
- pendingTabAlignment = { target, val: stop.val };
48246
+ pendingTabAlignment = { target: clampedTarget, val: stop.val };
48022
48247
  } else {
48023
48248
  pendingTabAlignment = null;
48024
48249
  }
48025
48250
  if (stop && stop.leader && stop.leader !== "none") {
48026
48251
  const leaderStyle = stop.leader;
48027
- const from3 = Math.min(originX, target);
48028
- const to = Math.max(originX, target);
48252
+ const from3 = Math.min(originX, clampedTarget);
48253
+ const to = Math.max(originX, clampedTarget);
48029
48254
  if (!currentLine.leaders) currentLine.leaders = [];
48030
48255
  currentLine.leaders.push({ from: from3, to, style: leaderStyle });
48031
48256
  }
@@ -48620,7 +48845,8 @@ async function measureParagraphBlock(block, maxWidth) {
48620
48845
  const originX = currentLine.width;
48621
48846
  const { target, nextIndex, stop } = getNextTabStopPx(currentLine.width, tabStops, tabStopCursor);
48622
48847
  tabStopCursor = nextIndex;
48623
- const tabAdvance = Math.max(0, target - currentLine.width);
48848
+ const clampedTarget = Math.min(target, currentLine.maxWidth);
48849
+ const tabAdvance = Math.max(0, clampedTarget - currentLine.width);
48624
48850
  currentLine.width = roundValue(currentLine.width + tabAdvance);
48625
48851
  currentLine.maxFontInfo = updateMaxFontInfo(currentLine.maxFontSize, currentLine.maxFontInfo, run);
48626
48852
  currentLine.maxFontSize = Math.max(currentLine.maxFontSize, run.fontSize);
@@ -48629,14 +48855,14 @@ async function measureParagraphBlock(block, maxWidth) {
48629
48855
  charPosInRun += 1;
48630
48856
  if (stop) {
48631
48857
  validateTabStopVal(stop);
48632
- pendingTabAlignment = { target, val: stop.val };
48858
+ pendingTabAlignment = { target: clampedTarget, val: stop.val };
48633
48859
  } else {
48634
48860
  pendingTabAlignment = null;
48635
48861
  }
48636
48862
  if (stop && stop.leader && stop.leader !== "none" && stop.leader !== "middleDot") {
48637
48863
  const leaderStyle = stop.leader;
48638
- const from3 = Math.min(originX, target);
48639
- const to = Math.max(originX, target);
48864
+ const from3 = Math.min(originX, clampedTarget);
48865
+ const to = Math.max(originX, clampedTarget);
48640
48866
  if (!currentLine.leaders) currentLine.leaders = [];
48641
48867
  currentLine.leaders.push({ from: from3, to, style: leaderStyle });
48642
48868
  }
@@ -57192,16 +57418,112 @@ const mapRangesThroughTransactions = (ranges, transactions, docSize) => {
57192
57418
  });
57193
57419
  return mergeRanges$2(mapped, docSize);
57194
57420
  };
57195
- const buildWrapTransaction = (state, ranges, runType) => {
57421
+ const getParagraphAtPos = (doc2, pos) => {
57422
+ try {
57423
+ const $pos = doc2.resolve(pos);
57424
+ for (let depth = $pos.depth; depth >= 0; depth--) {
57425
+ const node = $pos.node(depth);
57426
+ if (node.type.name === "paragraph") {
57427
+ return node;
57428
+ }
57429
+ }
57430
+ } catch (_e) {
57431
+ }
57432
+ return null;
57433
+ };
57434
+ const resolveRunPropertiesFromParagraphStyle = (paragraphNode, editor) => {
57435
+ if (!paragraphNode || !editor?.converter) return {};
57436
+ const styleId = paragraphNode.attrs?.paragraphProperties?.styleId;
57437
+ if (!styleId) return {};
57438
+ try {
57439
+ const params2 = { docx: editor.converter.convertedXml, numbering: editor.converter.numbering };
57440
+ const resolvedPpr = { styleId };
57441
+ const runProps = superEditor_converter.resolveRunProperties(params2, {}, resolvedPpr, false, false);
57442
+ const runProperties = {};
57443
+ if (runProps.fontFamily) {
57444
+ const fontValue = runProps.fontFamily.ascii || runProps.fontFamily;
57445
+ if (fontValue) {
57446
+ runProperties.fontFamily = typeof fontValue === "string" ? fontValue : fontValue.ascii;
57447
+ }
57448
+ }
57449
+ if (runProps.fontSize) {
57450
+ runProperties.fontSize = `${runProps.fontSize / 2}pt`;
57451
+ }
57452
+ if (runProps.bold) runProperties.bold = true;
57453
+ if (runProps.italic) runProperties.italic = true;
57454
+ if (runProps.underline) runProperties.underline = runProps.underline;
57455
+ if (runProps.strike) runProperties.strike = true;
57456
+ return runProperties;
57457
+ } catch (_e) {
57458
+ return {};
57459
+ }
57460
+ };
57461
+ const createMarksFromDefs = (schema, markDefs = []) => markDefs.map((def) => {
57462
+ const markType = schema.marks[def.type];
57463
+ return markType ? markType.create(def.attrs) : null;
57464
+ }).filter(Boolean);
57465
+ const createMarkDefsFromStyleRunProps = (styleRunProps) => {
57466
+ const markDefs = [];
57467
+ const textStyleAttrs = {};
57468
+ if (styleRunProps.fontSize) {
57469
+ textStyleAttrs.fontSize = styleRunProps.fontSize;
57470
+ }
57471
+ if (styleRunProps.fontFamily) {
57472
+ textStyleAttrs.fontFamily = styleRunProps.fontFamily;
57473
+ }
57474
+ if (Object.keys(textStyleAttrs).length > 0) {
57475
+ markDefs.push({ type: "textStyle", attrs: textStyleAttrs });
57476
+ }
57477
+ if (styleRunProps.bold) {
57478
+ markDefs.push({ type: "bold", attrs: { value: true } });
57479
+ }
57480
+ if (styleRunProps.italic) {
57481
+ markDefs.push({ type: "italic", attrs: { value: true } });
57482
+ }
57483
+ if (styleRunProps.strike) {
57484
+ markDefs.push({ type: "strike", attrs: { value: true } });
57485
+ }
57486
+ if (styleRunProps.underline) {
57487
+ const underlineType = styleRunProps.underline["w:val"];
57488
+ if (underlineType) {
57489
+ let underlineColor = styleRunProps.underline["w:color"];
57490
+ if (underlineColor && underlineColor.toLowerCase() !== "auto" && !underlineColor.startsWith("#")) {
57491
+ underlineColor = `#${underlineColor}`;
57492
+ }
57493
+ markDefs.push({
57494
+ type: "underline",
57495
+ attrs: { underlineType, underlineColor }
57496
+ });
57497
+ }
57498
+ }
57499
+ return markDefs;
57500
+ };
57501
+ const buildWrapTransaction = (state, ranges, runType, editor, markDefsFromMeta = []) => {
57196
57502
  if (!ranges.length) return null;
57197
57503
  const replacements = [];
57504
+ const metaStyleMarks = createMarksFromDefs(state.schema, markDefsFromMeta);
57198
57505
  ranges.forEach(({ from: from3, to }) => {
57199
57506
  state.doc.nodesBetween(from3, to, (node, pos, parent, index2) => {
57200
57507
  if (!node.isText || !parent || parent.type === runType) return;
57201
57508
  const match = parent.contentMatchAt ? parent.contentMatchAt(index2) : null;
57202
57509
  if (match && !match.matchType(runType)) return;
57203
57510
  if (!match && !parent.type.contentMatch.matchType(runType)) return;
57204
- const runProperties = superEditor_converter.decodeRPrFromMarks(node.marks);
57511
+ let runProperties = superEditor_converter.decodeRPrFromMarks(node.marks);
57512
+ if ((!node.marks || node.marks.length === 0) && editor?.converter) {
57513
+ const paragraphNode = getParagraphAtPos(state.doc, pos);
57514
+ const styleRunProps = resolveRunPropertiesFromParagraphStyle(paragraphNode, editor);
57515
+ if (Object.keys(styleRunProps).length > 0) {
57516
+ runProperties = styleRunProps;
57517
+ const markDefs = metaStyleMarks.length ? markDefsFromMeta : createMarkDefsFromStyleRunProps(styleRunProps);
57518
+ const styleMarks = metaStyleMarks.length ? metaStyleMarks : createMarksFromDefs(state.schema, markDefs);
57519
+ if (styleMarks.length && typeof state.schema.text === "function") {
57520
+ const textNode = state.schema.text(node.text || "", styleMarks);
57521
+ if (textNode) {
57522
+ node = textNode;
57523
+ }
57524
+ }
57525
+ }
57526
+ }
57205
57527
  const runNode = runType.create({ runProperties }, node);
57206
57528
  replacements.push({ from: pos, to: pos + node.nodeSize, runNode });
57207
57529
  });
@@ -57211,9 +57533,10 @@ const buildWrapTransaction = (state, ranges, runType) => {
57211
57533
  replacements.sort((a, b) => b.from - a.from).forEach(({ from: from3, to, runNode }) => tr.replaceWith(from3, to, runNode));
57212
57534
  return tr.docChanged ? tr : null;
57213
57535
  };
57214
- const wrapTextInRunsPlugin = () => {
57536
+ const wrapTextInRunsPlugin = (editor) => {
57215
57537
  let view = null;
57216
57538
  let pendingRanges = [];
57539
+ let lastStyleMarksMeta = [];
57217
57540
  const flush = () => {
57218
57541
  if (!view) return;
57219
57542
  const runType = view.state.schema.nodes.run;
@@ -57221,7 +57544,7 @@ const wrapTextInRunsPlugin = () => {
57221
57544
  pendingRanges = [];
57222
57545
  return;
57223
57546
  }
57224
- const tr = buildWrapTransaction(view.state, pendingRanges, runType);
57547
+ const tr = buildWrapTransaction(view.state, pendingRanges, runType, editor, lastStyleMarksMeta);
57225
57548
  pendingRanges = [];
57226
57549
  if (tr) {
57227
57550
  view.dispatch(tr);
@@ -57240,6 +57563,7 @@ const wrapTextInRunsPlugin = () => {
57240
57563
  editorView.dom.removeEventListener("compositionend", onCompositionEnd);
57241
57564
  view = null;
57242
57565
  pendingRanges = [];
57566
+ lastStyleMarksMeta = [];
57243
57567
  }
57244
57568
  };
57245
57569
  },
@@ -57253,7 +57577,11 @@ const wrapTextInRunsPlugin = () => {
57253
57577
  if (view?.composing) {
57254
57578
  return null;
57255
57579
  }
57256
- const tr = buildWrapTransaction(newState, pendingRanges, runType);
57580
+ const latestStyleMarksMeta = [...transactions].reverse().find((tr2) => tr2.getMeta && tr2.getMeta("sdStyleMarks"))?.getMeta("sdStyleMarks") || lastStyleMarksMeta;
57581
+ if (latestStyleMarksMeta && latestStyleMarksMeta.length) {
57582
+ lastStyleMarksMeta = latestStyleMarksMeta;
57583
+ }
57584
+ const tr = buildWrapTransaction(newState, pendingRanges, runType, editor, latestStyleMarksMeta);
57257
57585
  pendingRanges = [];
57258
57586
  return tr;
57259
57587
  }
@@ -57516,7 +57844,7 @@ const Run = OxmlNode.create({
57516
57844
  },
57517
57845
  addPmPlugins() {
57518
57846
  return [
57519
- wrapTextInRunsPlugin(),
57847
+ wrapTextInRunsPlugin(this.editor),
57520
57848
  splitRunsAfterMarkPlugin,
57521
57849
  calculateInlineRunPropertiesPlugin(this.editor),
57522
57850
  cleanupEmptyRunsPlugin