@harbour-enterprises/superdoc 1.7.0-next.5 → 1.7.0-next.7

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,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 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 combineIndentProperties, a4 as _getReferencedTableStyles, a5 as decodeRPrFromMarks, a6 as calculateResolvedParagraphProperties, a7 as encodeCSSFromPPr, a8 as encodeCSSFromRPr, a9 as generateOrderedListIndex, aa as docxNumberingHelpers, ab as InputRule, ac as insertNewRelationship, ad as kebabCase$1, ae as getUnderlineCssString } from "./SuperConverter-DU1Tqi67.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 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 combineIndentProperties, a4 as _getReferencedTableStyles, a5 as decodeRPrFromMarks, a6 as calculateResolvedParagraphProperties, a7 as encodeCSSFromPPr, a8 as encodeCSSFromRPr, a9 as generateOrderedListIndex, aa as docxNumberingHelpers, ab as InputRule, ac as insertNewRelationship, ad as kebabCase$1, ae as getUnderlineCssString } from "./SuperConverter-CQtzIJhu.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 h$1, $ 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";
@@ -15771,7 +15771,7 @@ const canUseDOM = () => {
15771
15771
  return false;
15772
15772
  }
15773
15773
  };
15774
- const summaryVersion = "1.7.0-next.5";
15774
+ const summaryVersion = "1.7.0-next.7";
15775
15775
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
15776
15776
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
15777
15777
  function mapAttributes(attrs) {
@@ -18438,7 +18438,7 @@ class Editor extends EventEmitter {
18438
18438
  * Process collaboration migrations
18439
18439
  */
18440
18440
  processCollaborationMigrations() {
18441
- console.debug("[checkVersionMigrations] Current editor version", "1.7.0-next.5");
18441
+ console.debug("[checkVersionMigrations] Current editor version", "1.7.0-next.7");
18442
18442
  if (!this.options.ydoc) return;
18443
18443
  const metaMap = this.options.ydoc.getMap("meta");
18444
18444
  let docVersion = metaMap.get("version");
@@ -33040,6 +33040,28 @@ function applyPendingToActive(state) {
33040
33040
  next.pendingOrientation = null;
33041
33041
  return next;
33042
33042
  }
33043
+ const isTextRun$3 = (run) => {
33044
+ const runWithKind = run;
33045
+ return !runWithKind.kind || runWithKind.kind === "text";
33046
+ };
33047
+ const isEmptyTextParagraph = (block) => {
33048
+ const runs = block.runs;
33049
+ if (!runs || runs.length === 0) return true;
33050
+ if (runs.length !== 1) return false;
33051
+ const run = runs[0];
33052
+ if (!isTextRun$3(run)) return false;
33053
+ return typeof run.text === "string" && run.text.length === 0;
33054
+ };
33055
+ const shouldSuppressSpacingForEmpty = (block, side) => {
33056
+ if (!isEmptyTextParagraph(block)) return false;
33057
+ const attrs = block.attrs;
33058
+ const spacingExplicit = attrs?.spacingExplicit;
33059
+ if (!spacingExplicit) return false;
33060
+ if (side === "before") {
33061
+ return !spacingExplicit.before;
33062
+ }
33063
+ return !spacingExplicit.after;
33064
+ };
33043
33065
  function normalizeLines(measure) {
33044
33066
  if (measure.lines.length > 0) {
33045
33067
  return measure.lines;
@@ -33279,11 +33301,17 @@ function layoutParagraphBlock(ctx2, anchors) {
33279
33301
  let fromLine = 0;
33280
33302
  const attrs = getParagraphAttrs(block);
33281
33303
  const spacing = attrs?.spacing ?? {};
33304
+ const spacingExplicit = attrs?.spacingExplicit;
33282
33305
  const styleId = asString(attrs?.styleId);
33283
33306
  const contextualSpacing = asBoolean$1(attrs?.contextualSpacing);
33284
33307
  let spacingBefore = Math.max(0, Number(spacing.before ?? spacing.lineSpaceBefore ?? 0));
33308
+ let spacingAfter = Math.max(0, Number(spacing.after ?? spacing.lineSpaceAfter ?? 0));
33309
+ const emptyTextParagraph = isEmptyTextParagraph(block);
33310
+ if (emptyTextParagraph && spacingExplicit) {
33311
+ if (!spacingExplicit.before) spacingBefore = 0;
33312
+ if (!spacingExplicit.after) spacingAfter = 0;
33313
+ }
33285
33314
  const baseSpacingBefore = spacingBefore;
33286
- const spacingAfter = Math.max(0, Number(spacing.after ?? spacing.lineSpaceAfter ?? 0));
33287
33315
  let appliedSpacingBefore = spacingBefore === 0;
33288
33316
  let lastState = null;
33289
33317
  const isPositionedFrame = frame?.wrap === "none";
@@ -34605,11 +34633,13 @@ function hasHeight(fragment) {
34605
34633
  function getParagraphSpacingBefore(block) {
34606
34634
  const spacing = block.attrs?.spacing;
34607
34635
  const value = spacing?.before ?? spacing?.lineSpaceBefore;
34636
+ if (shouldSuppressSpacingForEmpty(block, "before")) return 0;
34608
34637
  return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : 0;
34609
34638
  }
34610
34639
  function getParagraphSpacingAfter$1(block) {
34611
34640
  const spacing = block.attrs?.spacing;
34612
34641
  const value = spacing?.after ?? spacing?.lineSpaceAfter;
34642
+ if (shouldSuppressSpacingForEmpty(block, "after")) return 0;
34613
34643
  return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : 0;
34614
34644
  }
34615
34645
  function getMeasureHeight(block, measure) {
@@ -42319,18 +42349,29 @@ function setupInternalFieldAnnotationDragHandlers({
42319
42349
  const fieldId = event.data.fieldId;
42320
42350
  if (fieldId) {
42321
42351
  const targetPos = event.pmPosition;
42352
+ const pmStart = event.data.pmStart;
42322
42353
  let sourceStart = null;
42323
42354
  let sourceEnd = null;
42324
42355
  let sourceNode = null;
42325
- state.doc.descendants((node, pos) => {
42326
- if (node.type.name === "fieldAnnotation" && node.attrs.fieldId === fieldId) {
42327
- sourceStart = pos;
42328
- sourceEnd = pos + node.nodeSize;
42329
- sourceNode = node;
42330
- return false;
42356
+ if (pmStart != null) {
42357
+ const nodeAt = state.doc.nodeAt(pmStart);
42358
+ if (nodeAt?.type?.name === "fieldAnnotation") {
42359
+ sourceStart = pmStart;
42360
+ sourceEnd = pmStart + nodeAt.nodeSize;
42361
+ sourceNode = nodeAt;
42331
42362
  }
42332
- return true;
42333
- });
42363
+ }
42364
+ if (sourceStart == null || sourceEnd == null || !sourceNode) {
42365
+ state.doc.descendants((node, pos) => {
42366
+ if (node.type.name === "fieldAnnotation" && node.attrs.fieldId === fieldId) {
42367
+ sourceStart = pos;
42368
+ sourceEnd = pos + node.nodeSize;
42369
+ sourceNode = node;
42370
+ return false;
42371
+ }
42372
+ return true;
42373
+ });
42374
+ }
42334
42375
  if (sourceStart === null || sourceEnd === null || !sourceNode) {
42335
42376
  return;
42336
42377
  }
@@ -43467,6 +43508,26 @@ function normalizeTextInsets(value) {
43467
43508
  return { top: top2, right: right2, bottom: bottom2, left: left2 };
43468
43509
  }
43469
43510
  const OOXML_Z_INDEX_BASE = 251658240;
43511
+ const asOoxmlElement = (value) => {
43512
+ if (!value || typeof value !== "object") return void 0;
43513
+ const element = value;
43514
+ if (element.name == null && element.attributes == null && element.elements == null) return void 0;
43515
+ return element;
43516
+ };
43517
+ const findOoxmlChild = (parent, name) => {
43518
+ return parent?.elements?.find((child) => child?.name === name);
43519
+ };
43520
+ const getOoxmlAttribute = (element, key2) => {
43521
+ if (!element?.attributes) return void 0;
43522
+ const attrs = element.attributes;
43523
+ return attrs[key2] ?? attrs[key2.startsWith("w:") ? key2.slice(2) : `w:${key2}`];
43524
+ };
43525
+ const parseOoxmlNumber = (value) => {
43526
+ if (value == null) return void 0;
43527
+ const num = typeof value === "number" ? value : Number.parseInt(String(value), 10);
43528
+ return Number.isFinite(num) ? num : void 0;
43529
+ };
43530
+ const hasOwnProperty$d = (obj, key2) => Object.prototype.hasOwnProperty.call(obj, key2);
43470
43531
  function normalizeZIndex(originalAttributes) {
43471
43532
  if (!isPlainObject$2(originalAttributes)) return void 0;
43472
43533
  const relativeHeight = originalAttributes.relativeHeight;
@@ -45467,24 +45528,47 @@ const DEFAULT_DECIMAL_SEPARATOR$2 = ".";
45467
45528
  const isValidNumberingId = (numId) => {
45468
45529
  return numId != null && numId !== 0 && numId !== "0";
45469
45530
  };
45470
- const asOoxmlElement = (value) => {
45471
- if (!value || typeof value !== "object") return void 0;
45472
- const element = value;
45473
- if (element.name == null && element.attributes == null && element.elements == null) return void 0;
45474
- return element;
45475
- };
45476
- const findChild = (parent, name) => {
45477
- return parent?.elements?.find((child) => child?.name === name);
45531
+ const extractSpacingExplicitFromObject = (value) => {
45532
+ if (!value || typeof value !== "object" || Array.isArray(value)) return {};
45533
+ const obj = value;
45534
+ const explicit = {};
45535
+ if (hasOwnProperty$d(obj, "before") || hasOwnProperty$d(obj, "lineSpaceBefore") || hasOwnProperty$d(obj, "beforeAutospacing") || hasOwnProperty$d(obj, "beforeAutoSpacing")) {
45536
+ explicit.before = true;
45537
+ }
45538
+ if (hasOwnProperty$d(obj, "after") || hasOwnProperty$d(obj, "lineSpaceAfter") || hasOwnProperty$d(obj, "afterAutospacing") || hasOwnProperty$d(obj, "afterAutoSpacing")) {
45539
+ explicit.after = true;
45540
+ }
45541
+ if (hasOwnProperty$d(obj, "line") || hasOwnProperty$d(obj, "lineRule")) {
45542
+ explicit.line = true;
45543
+ }
45544
+ return explicit;
45478
45545
  };
45479
- const getAttribute = (element, key2) => {
45480
- if (!element?.attributes) return void 0;
45481
- const attrs = element.attributes;
45482
- return attrs[key2] ?? attrs[key2.startsWith("w:") ? key2.slice(2) : `w:${key2}`];
45546
+ const extractSpacingExplicitFromOoxml = (value) => {
45547
+ const element = asOoxmlElement(value);
45548
+ if (!element) return {};
45549
+ const pPr = element.name === "w:pPr" ? element : findOoxmlChild(element, "w:pPr");
45550
+ const spacingEl = findOoxmlChild(pPr, "w:spacing");
45551
+ if (!spacingEl) return {};
45552
+ const explicit = {};
45553
+ if (getOoxmlAttribute(spacingEl, "w:before") != null || getOoxmlAttribute(spacingEl, "w:beforeAutospacing") != null || getOoxmlAttribute(spacingEl, "w:beforeAutoSpacing") != null) {
45554
+ explicit.before = true;
45555
+ }
45556
+ if (getOoxmlAttribute(spacingEl, "w:after") != null || getOoxmlAttribute(spacingEl, "w:afterAutospacing") != null || getOoxmlAttribute(spacingEl, "w:afterAutoSpacing") != null) {
45557
+ explicit.after = true;
45558
+ }
45559
+ if (getOoxmlAttribute(spacingEl, "w:line") != null || getOoxmlAttribute(spacingEl, "w:lineRule") != null) {
45560
+ explicit.line = true;
45561
+ }
45562
+ return explicit;
45483
45563
  };
45484
- const parseNumberAttr = (value) => {
45485
- if (value == null) return void 0;
45486
- const num = typeof value === "number" ? value : Number.parseInt(String(value), 10);
45487
- return Number.isFinite(num) ? num : void 0;
45564
+ const mergeSpacingExplicit = (...sources) => {
45565
+ const merged = {};
45566
+ for (const source of sources) {
45567
+ if (source.before) merged.before = true;
45568
+ if (source.after) merged.after = true;
45569
+ if (source.line) merged.line = true;
45570
+ }
45571
+ return merged;
45488
45572
  };
45489
45573
  const mergeSpacingSources = (base2, paragraphProps, attrs) => {
45490
45574
  const isObject2 = (v) => v !== null && typeof v === "object";
@@ -45530,13 +45614,13 @@ const normalizeJustification = (value) => {
45530
45614
  return void 0;
45531
45615
  };
45532
45616
  const extractIndentFromLevel = (lvl) => {
45533
- const pPr = findChild(lvl, "w:pPr");
45534
- const ind = findChild(pPr, "w:ind");
45617
+ const pPr = findOoxmlChild(lvl, "w:pPr");
45618
+ const ind = findOoxmlChild(pPr, "w:ind");
45535
45619
  if (!ind) return void 0;
45536
- const left2 = parseNumberAttr(getAttribute(ind, "w:left"));
45537
- const right2 = parseNumberAttr(getAttribute(ind, "w:right"));
45538
- const firstLine = parseNumberAttr(getAttribute(ind, "w:firstLine"));
45539
- const hanging = parseNumberAttr(getAttribute(ind, "w:hanging"));
45620
+ const left2 = parseOoxmlNumber(getOoxmlAttribute(ind, "w:left"));
45621
+ const right2 = parseOoxmlNumber(getOoxmlAttribute(ind, "w:right"));
45622
+ const firstLine = parseOoxmlNumber(getOoxmlAttribute(ind, "w:firstLine"));
45623
+ const hanging = parseOoxmlNumber(getOoxmlAttribute(ind, "w:hanging"));
45540
45624
  const indent = {};
45541
45625
  if (left2 != null) indent.left = left2;
45542
45626
  if (right2 != null) indent.right = right2;
@@ -45552,31 +45636,31 @@ const normalizeColor = (value) => {
45552
45636
  return `#${upper.toUpperCase()}`;
45553
45637
  };
45554
45638
  const extractMarkerRun = (lvl) => {
45555
- const rPr = findChild(lvl, "w:rPr");
45639
+ const rPr = findOoxmlChild(lvl, "w:rPr");
45556
45640
  if (!rPr) return void 0;
45557
45641
  const run = {};
45558
- const rFonts = findChild(rPr, "w:rFonts");
45559
- const font = getAttribute(rFonts, "w:ascii") ?? getAttribute(rFonts, "w:hAnsi") ?? getAttribute(rFonts, "w:eastAsia");
45642
+ const rFonts = findOoxmlChild(rPr, "w:rFonts");
45643
+ const font = getOoxmlAttribute(rFonts, "w:ascii") ?? getOoxmlAttribute(rFonts, "w:hAnsi") ?? getOoxmlAttribute(rFonts, "w:eastAsia");
45560
45644
  if (typeof font === "string" && font.trim()) {
45561
45645
  run.fontFamily = font;
45562
45646
  }
45563
- const sz = parseNumberAttr(getAttribute(findChild(rPr, "w:sz"), "w:val")) ?? parseNumberAttr(getAttribute(findChild(rPr, "w:szCs"), "w:val"));
45647
+ const sz = parseOoxmlNumber(getOoxmlAttribute(findOoxmlChild(rPr, "w:sz"), "w:val")) ?? parseOoxmlNumber(getOoxmlAttribute(findOoxmlChild(rPr, "w:szCs"), "w:val"));
45564
45648
  if (sz != null) {
45565
45649
  run.fontSize = sz / 2;
45566
45650
  }
45567
- const color = normalizeColor(getAttribute(findChild(rPr, "w:color"), "w:val"));
45651
+ const color = normalizeColor(getOoxmlAttribute(findOoxmlChild(rPr, "w:color"), "w:val"));
45568
45652
  if (color) run.color = color;
45569
- const boldEl = findChild(rPr, "w:b");
45653
+ const boldEl = findOoxmlChild(rPr, "w:b");
45570
45654
  if (boldEl) {
45571
- const boldVal = getAttribute(boldEl, "w:val");
45655
+ const boldVal = getOoxmlAttribute(boldEl, "w:val");
45572
45656
  if (boldVal == null || isTruthy(boldVal)) run.bold = true;
45573
45657
  }
45574
- const italicEl = findChild(rPr, "w:i");
45658
+ const italicEl = findOoxmlChild(rPr, "w:i");
45575
45659
  if (italicEl) {
45576
- const italicVal = getAttribute(italicEl, "w:val");
45660
+ const italicVal = getOoxmlAttribute(italicEl, "w:val");
45577
45661
  if (italicVal == null || isTruthy(italicVal)) run.italic = true;
45578
45662
  }
45579
- const spacingTwips = parseNumberAttr(getAttribute(findChild(rPr, "w:spacing"), "w:val"));
45663
+ const spacingTwips = parseOoxmlNumber(getOoxmlAttribute(findOoxmlChild(rPr, "w:spacing"), "w:val"));
45580
45664
  if (spacingTwips != null && Number.isFinite(spacingTwips)) {
45581
45665
  run.letterSpacing = twipsToPx$1(spacingTwips);
45582
45666
  }
@@ -45584,12 +45668,12 @@ const extractMarkerRun = (lvl) => {
45584
45668
  };
45585
45669
  const findNumFmtElement = (lvl) => {
45586
45670
  if (!lvl) return void 0;
45587
- const direct = findChild(lvl, "w:numFmt");
45671
+ const direct = findOoxmlChild(lvl, "w:numFmt");
45588
45672
  if (direct) return direct;
45589
- const alternate = findChild(lvl, "mc:AlternateContent");
45590
- const choice = findChild(alternate, "mc:Choice");
45673
+ const alternate = findOoxmlChild(lvl, "mc:AlternateContent");
45674
+ const choice = findOoxmlChild(alternate, "mc:Choice");
45591
45675
  if (choice) {
45592
- return findChild(choice, "w:numFmt");
45676
+ return findOoxmlChild(choice, "w:numFmt");
45593
45677
  }
45594
45678
  return void 0;
45595
45679
  };
@@ -45603,7 +45687,7 @@ const resolveNumberingFromContext = (numId, ilvl, numbering) => {
45603
45687
  if (!numDef) {
45604
45688
  return void 0;
45605
45689
  }
45606
- const abstractId = getAttribute(findChild(numDef, "w:abstractNumId"), "w:val");
45690
+ const abstractId = getOoxmlAttribute(findOoxmlChild(numDef, "w:abstractNumId"), "w:val");
45607
45691
  if (abstractId == null) {
45608
45692
  return void 0;
45609
45693
  }
@@ -45612,27 +45696,27 @@ const resolveNumberingFromContext = (numId, ilvl, numbering) => {
45612
45696
  return void 0;
45613
45697
  }
45614
45698
  let levelDef = abstract.elements?.find(
45615
- (el) => el?.name === "w:lvl" && parseNumberAttr(el.attributes?.["w:ilvl"]) === ilvl
45699
+ (el) => el?.name === "w:lvl" && parseOoxmlNumber(el.attributes?.["w:ilvl"]) === ilvl
45616
45700
  );
45617
45701
  const override = numDef.elements?.find(
45618
- (el) => el?.name === "w:lvlOverride" && parseNumberAttr(el.attributes?.["w:ilvl"]) === ilvl
45702
+ (el) => el?.name === "w:lvlOverride" && parseOoxmlNumber(el.attributes?.["w:ilvl"]) === ilvl
45619
45703
  );
45620
- const overrideLvl = findChild(override, "w:lvl");
45704
+ const overrideLvl = findOoxmlChild(override, "w:lvl");
45621
45705
  if (overrideLvl) {
45622
45706
  levelDef = overrideLvl;
45623
45707
  }
45624
- const startOverride = parseNumberAttr(getAttribute(findChild(override, "w:startOverride"), "w:val"));
45708
+ const startOverride = parseOoxmlNumber(getOoxmlAttribute(findOoxmlChild(override, "w:startOverride"), "w:val"));
45625
45709
  if (!levelDef) {
45626
45710
  return void 0;
45627
45711
  }
45628
45712
  const numFmtEl = findNumFmtElement(levelDef);
45629
- const lvlText = getAttribute(findChild(levelDef, "w:lvlText"), "w:val");
45630
- const start2 = startOverride ?? parseNumberAttr(getAttribute(findChild(levelDef, "w:start"), "w:val"));
45631
- const suffix2 = normalizeSuffix(getAttribute(findChild(levelDef, "w:suff"), "w:val"));
45632
- const lvlJc = normalizeJustification(getAttribute(findChild(levelDef, "w:lvlJc"), "w:val"));
45713
+ const lvlText = getOoxmlAttribute(findOoxmlChild(levelDef, "w:lvlText"), "w:val");
45714
+ const start2 = startOverride ?? parseOoxmlNumber(getOoxmlAttribute(findOoxmlChild(levelDef, "w:start"), "w:val"));
45715
+ const suffix2 = normalizeSuffix(getOoxmlAttribute(findOoxmlChild(levelDef, "w:suff"), "w:val"));
45716
+ const lvlJc = normalizeJustification(getOoxmlAttribute(findOoxmlChild(levelDef, "w:lvlJc"), "w:val"));
45633
45717
  const indent = extractIndentFromLevel(levelDef);
45634
45718
  const markerRun = extractMarkerRun(levelDef);
45635
- const numFmt = normalizeNumFmt(getAttribute(numFmtEl, "w:val"));
45719
+ const numFmt = normalizeNumFmt(getOoxmlAttribute(numFmtEl, "w:val"));
45636
45720
  return {
45637
45721
  format: numFmt,
45638
45722
  lvlText,
@@ -45725,6 +45809,7 @@ const cloneParagraphAttrs = (attrs) => {
45725
45809
  if (!attrs) return void 0;
45726
45810
  const clone = { ...attrs };
45727
45811
  if (attrs.spacing) clone.spacing = { ...attrs.spacing };
45812
+ if (attrs.spacingExplicit) clone.spacingExplicit = { ...attrs.spacingExplicit };
45728
45813
  if (attrs.indent) clone.indent = { ...attrs.indent };
45729
45814
  if (attrs.borders) {
45730
45815
  const borderClone = {};
@@ -46100,6 +46185,11 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
46100
46185
  const hydrated = hydrationOverride ?? hydrateParagraphStyleAttrs(para, converterContext);
46101
46186
  const mergedSpacing = mergeSpacingSources(hydrated?.spacing, paragraphProps.spacing, attrs.spacing);
46102
46187
  const normalizedSpacing = normalizeParagraphSpacing(mergedSpacing);
46188
+ const spacingExplicit = mergeSpacingExplicit(
46189
+ extractSpacingExplicitFromObject(paragraphProps.spacing),
46190
+ extractSpacingExplicitFromObject(attrs.spacing),
46191
+ extractSpacingExplicitFromOoxml(paragraphProps)
46192
+ );
46103
46193
  const normalizeIndentObject = (value) => {
46104
46194
  if (!value || typeof value !== "object") return;
46105
46195
  return normalizePxIndent(value) ?? convertIndentTwipsToPx(value);
@@ -46234,6 +46324,7 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
46234
46324
  paragraphAttrs.spacing.afterAutospacing = normalizedSpacing.afterAutospacing;
46235
46325
  }
46236
46326
  }
46327
+ paragraphAttrs.spacingExplicit = spacingExplicit;
46237
46328
  const contextualSpacingValue = normalizedSpacing?.contextualSpacing ?? safeGetProperty(paragraphProps, "contextualSpacing") ?? safeGetProperty(attrs, "contextualSpacing") ?? hydrated?.contextualSpacing;
46238
46329
  if (contextualSpacingValue != null) {
46239
46330
  paragraphAttrs.contextualSpacing = isTruthy(contextualSpacingValue);
@@ -47603,7 +47694,10 @@ function fieldAnnotationNodeToRun(node, positions, fieldMetadata) {
47603
47694
  }
47604
47695
  return run;
47605
47696
  }
47606
- const isTextRun = (run) => run.kind !== "tab";
47697
+ const isTextRun = (run) => {
47698
+ const kind = run.kind;
47699
+ return (kind === void 0 || kind === "text") && "text" in run;
47700
+ };
47607
47701
  const dataAttrsCompatible = (a, b2) => {
47608
47702
  const aAttrs = a.dataAttrs;
47609
47703
  const bAttrs = b2.dataAttrs;
@@ -47712,6 +47806,75 @@ const extractFirstTextRunFont = (para) => {
47712
47806
  const font = findFirstTextFont(para.content);
47713
47807
  return font;
47714
47808
  };
47809
+ const resolveRunFontFamily = (fontFamily2, docx) => {
47810
+ if (typeof fontFamily2 === "string" && fontFamily2.trim().length > 0) {
47811
+ return fontFamily2;
47812
+ }
47813
+ if (!fontFamily2 || typeof fontFamily2 !== "object") return void 0;
47814
+ const toCssFontFamily2 = SuperConverter.toCssFontFamily;
47815
+ const resolved = resolveDocxFontFamily(fontFamily2, docx ?? null, toCssFontFamily2);
47816
+ return resolved ?? void 0;
47817
+ };
47818
+ const parseRunFontSizePx = (fontSize2) => {
47819
+ if (typeof fontSize2 === "number" && Number.isFinite(fontSize2)) {
47820
+ return ptToPx(fontSize2 / HALF_POINTS_PER_POINT) ?? void 0;
47821
+ }
47822
+ if (typeof fontSize2 === "string") {
47823
+ const numeric = Number.parseFloat(fontSize2);
47824
+ if (!Number.isFinite(numeric)) return void 0;
47825
+ if (fontSize2.endsWith("pt")) {
47826
+ return ptToPx(numeric);
47827
+ }
47828
+ if (fontSize2.endsWith("px")) {
47829
+ return numeric;
47830
+ }
47831
+ return ptToPx(numeric / HALF_POINTS_PER_POINT) ?? void 0;
47832
+ }
47833
+ return void 0;
47834
+ };
47835
+ const extractParagraphMarkRunProps = (paragraphProps) => {
47836
+ const directRunProps = paragraphProps.runProperties;
47837
+ const directRunPropsElement = asOoxmlElement(directRunProps);
47838
+ if (directRunProps && isPlainObject$2(directRunProps) && !directRunPropsElement) {
47839
+ return directRunProps;
47840
+ }
47841
+ const element = asOoxmlElement(paragraphProps);
47842
+ const pPr = element ? element.name === "w:pPr" ? element : findOoxmlChild(element, "w:pPr") : void 0;
47843
+ const rPr = directRunPropsElement?.name === "w:rPr" ? directRunPropsElement : findOoxmlChild(pPr, "w:rPr");
47844
+ if (!rPr) return void 0;
47845
+ const runProps = {};
47846
+ const sz = parseOoxmlNumber(getOoxmlAttribute(findOoxmlChild(rPr, "w:sz"), "w:val")) ?? parseOoxmlNumber(getOoxmlAttribute(findOoxmlChild(rPr, "w:szCs"), "w:val"));
47847
+ if (sz != null) {
47848
+ runProps.fontSize = sz;
47849
+ }
47850
+ const rFonts = findOoxmlChild(rPr, "w:rFonts");
47851
+ if (rFonts) {
47852
+ const fontFamily2 = {};
47853
+ const keys2 = ["ascii", "hAnsi", "eastAsia", "cs", "val", "asciiTheme", "hAnsiTheme", "eastAsiaTheme", "cstheme"];
47854
+ for (const key2 of keys2) {
47855
+ const value = getOoxmlAttribute(rFonts, `w:${key2}`);
47856
+ if (value != null) {
47857
+ fontFamily2[key2] = value;
47858
+ }
47859
+ }
47860
+ if (Object.keys(fontFamily2).length > 0) {
47861
+ runProps.fontFamily = fontFamily2;
47862
+ }
47863
+ }
47864
+ return Object.keys(runProps).length > 0 ? runProps : void 0;
47865
+ };
47866
+ const applyParagraphMarkRunProps = (run, paragraphProps, converterContext) => {
47867
+ const runProps = extractParagraphMarkRunProps(paragraphProps);
47868
+ if (!runProps) return;
47869
+ const fontSizePx = parseRunFontSizePx(runProps.fontSize);
47870
+ if (fontSizePx != null) {
47871
+ run.fontSize = fontSizePx;
47872
+ }
47873
+ const fontFamily2 = resolveRunFontFamily(runProps.fontFamily, converterContext?.docx);
47874
+ if (fontFamily2) {
47875
+ run.fontFamily = fontFamily2;
47876
+ }
47877
+ };
47715
47878
  const applyBaseRunDefaults = (run, defaults, uiDisplayFallbackFont, fallbackSize) => {
47716
47879
  if (!run) return;
47717
47880
  if (defaults.fontFamily && run.fontFamily === uiDisplayFallbackFont) {
@@ -47861,6 +48024,8 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
47861
48024
  emptyRun.pmStart = paraPos.start + 1;
47862
48025
  emptyRun.pmEnd = paraPos.start + 1;
47863
48026
  }
48027
+ applyBaseRunDefaults(emptyRun, baseRunDefaults, defaultFont, defaultSize);
48028
+ applyParagraphMarkRunProps(emptyRun, paragraphProps, converterContext);
47864
48029
  let emptyParagraphAttrs = cloneParagraphAttrs(paragraphAttrs);
47865
48030
  if (isSectPrMarker) {
47866
48031
  if (emptyParagraphAttrs) {
@@ -51248,7 +51413,6 @@ function measureText(text, font, ctx2, _fontFamily, _letterSpacing) {
51248
51413
  const paintedWidth = (metrics.actualBoundingBoxLeft || 0) + (metrics.actualBoundingBoxRight || 0);
51249
51414
  return Math.max(advanceWidth, paintedWidth);
51250
51415
  }
51251
- const MIN_SINGLE_LINE_PX = 12 * 96 / 72;
51252
51416
  const WORD_SINGLE_LINE_SPACING_MULTIPLIER = 1.15;
51253
51417
  function calculateTypographyMetrics(fontSize2, spacing, fontInfo) {
51254
51418
  let ascent;
@@ -51262,7 +51426,27 @@ function calculateTypographyMetrics(fontSize2, spacing, fontInfo) {
51262
51426
  ascent = roundValue(fontSize2 * 0.8);
51263
51427
  descent = roundValue(fontSize2 * 0.2);
51264
51428
  }
51265
- const baseLineHeight = Math.max(fontSize2 * WORD_SINGLE_LINE_SPACING_MULTIPLIER, ascent + descent, MIN_SINGLE_LINE_PX);
51429
+ const baseLineHeight = Math.max(fontSize2 * WORD_SINGLE_LINE_SPACING_MULTIPLIER, ascent + descent);
51430
+ const lineHeight2 = roundValue(resolveLineHeight(spacing, baseLineHeight));
51431
+ return {
51432
+ ascent,
51433
+ descent,
51434
+ lineHeight: lineHeight2
51435
+ };
51436
+ }
51437
+ function calculateEmptyParagraphMetrics(fontSize2, spacing, fontInfo) {
51438
+ let ascent;
51439
+ let descent;
51440
+ if (fontInfo) {
51441
+ const ctx2 = getCanvasContext();
51442
+ const metrics = getFontMetrics(ctx2, fontInfo);
51443
+ ascent = roundValue(metrics.ascent);
51444
+ descent = roundValue(metrics.descent);
51445
+ } else {
51446
+ ascent = roundValue(fontSize2 * 0.8);
51447
+ descent = roundValue(fontSize2 * 0.2);
51448
+ }
51449
+ const baseLineHeight = Math.max(fontSize2, ascent + descent);
51266
51450
  const lineHeight2 = roundValue(resolveLineHeight(spacing, baseLineHeight));
51267
51451
  return {
51268
51452
  ascent,
@@ -51293,6 +51477,10 @@ function isImageRun(run) {
51293
51477
  function isLineBreakRun(run) {
51294
51478
  return run.kind === "lineBreak";
51295
51479
  }
51480
+ const isEmptyTextRun = (run) => {
51481
+ if (run.kind && run.kind !== "text") return false;
51482
+ return typeof run.text === "string" && run.text.length === 0;
51483
+ };
51296
51484
  function isFieldAnnotationRun(run) {
51297
51485
  return run.kind === "fieldAnnotation";
51298
51486
  }
@@ -51462,8 +51650,28 @@ async function measureParagraphBlock(block, maxWidth) {
51462
51650
  dropCapDescriptor.measuredHeight = dropCapMeasured.height;
51463
51651
  }
51464
51652
  }
51653
+ const emptyParagraphRun = block.runs.length === 1 && isEmptyTextRun(block.runs[0]) ? block.runs[0] : null;
51654
+ if (emptyParagraphRun) {
51655
+ const fontSize2 = emptyParagraphRun.fontSize ?? 12;
51656
+ const metrics = calculateEmptyParagraphMetrics(fontSize2, spacing, getFontInfoFromRun(emptyParagraphRun));
51657
+ const emptyLine = {
51658
+ fromRun: 0,
51659
+ fromChar: 0,
51660
+ toRun: 0,
51661
+ toChar: 0,
51662
+ width: 0,
51663
+ ...metrics
51664
+ };
51665
+ addBarTabsToLine(emptyLine);
51666
+ lines.push(emptyLine);
51667
+ return {
51668
+ kind: "paragraph",
51669
+ lines,
51670
+ totalHeight: metrics.lineHeight
51671
+ };
51672
+ }
51465
51673
  if (block.runs.length === 0) {
51466
- const metrics = calculateTypographyMetrics(12, spacing);
51674
+ const metrics = calculateEmptyParagraphMetrics(12, spacing);
51467
51675
  const emptyLine = {
51468
51676
  fromRun: 0,
51469
51677
  fromChar: 0,
@@ -1,5 +1,5 @@
1
- import { B as BIT8, M as MAX_SAFE_INTEGER, c as create, a as BITS7, u as utf8TextDecoder, b as create$1, s as setIfUndefined, d as create$2, f as from, e as floor$1, g as equalityDeep, w as writeVarUint, h as writeVarString, t as toUint8Array, i as createEncoder, j as createInjectionKey, k as toString, l as throwError, m as useSsrAdapter, n as configProviderInjectionKey, o as cssrAnchorMetaName, p as globalStyle, q as cB, r as c, v as isMounted, x as commonVariables$2, y as cM, z as cNotM, A as cE, C as derived, D as changeColor, E as insideModal, F as insidePopover, G as resolveWrappedSlot, H as on, I as warnOnce, J as useConfig, K as useMergedState, L as useMemo, N as useTheme, O as useRtl, P as createKey, Q as useThemeClass, R as createId, S as call, T as render, U as messageProviderInjectionKey, V as messageApiInjectionKey, W as fromBase64, X as onChange, Y as varStorage, Z as toBase64, _ as createUint8ArrayFromArrayBuffer, $ as offChange, a0 as writeVarUint8Array, a1 as map, a2 as length, a3 as isNode, a4 as min, a5 as pow, a6 as comments_module_events, a7 as getFileObject, a8 as getTrackChanges, a9 as CommentsPluginKey, aa as TrackChangesBasePluginKey, ab as Editor, ac as getRichTextExtensions, ad as ellipsisVerticalSvg, ae as xmarkIconSvg, af as checkIconSvg, ag as caretDownIconSvg, ah as commentIconSvg, ai as _export_sfc, aj as NDropdown, ak as SuperInput, al as vClickOutside, am as PresentationEditor, an as SuperEditor, ao as AIWriter, ap as NConfigProvider, aq as SuperToolbar } from "./index-DYUIpqx9.es.js";
2
- import "./SuperConverter-DU1Tqi67.es.js";
1
+ import { B as BIT8, M as MAX_SAFE_INTEGER, c as create, a as BITS7, u as utf8TextDecoder, b as create$1, s as setIfUndefined, d as create$2, f as from, e as floor$1, g as equalityDeep, w as writeVarUint, h as writeVarString, t as toUint8Array, i as createEncoder, j as createInjectionKey, k as toString, l as throwError, m as useSsrAdapter, n as configProviderInjectionKey, o as cssrAnchorMetaName, p as globalStyle, q as cB, r as c, v as isMounted, x as commonVariables$2, y as cM, z as cNotM, A as cE, C as derived, D as changeColor, E as insideModal, F as insidePopover, G as resolveWrappedSlot, H as on, I as warnOnce, J as useConfig, K as useMergedState, L as useMemo, N as useTheme, O as useRtl, P as createKey, Q as useThemeClass, R as createId, S as call, T as render, U as messageProviderInjectionKey, V as messageApiInjectionKey, W as fromBase64, X as onChange, Y as varStorage, Z as toBase64, _ as createUint8ArrayFromArrayBuffer, $ as offChange, a0 as writeVarUint8Array, a1 as map, a2 as length, a3 as isNode, a4 as min, a5 as pow, a6 as comments_module_events, a7 as getFileObject, a8 as getTrackChanges, a9 as CommentsPluginKey, aa as TrackChangesBasePluginKey, ab as Editor, ac as getRichTextExtensions, ad as ellipsisVerticalSvg, ae as xmarkIconSvg, af as checkIconSvg, ag as caretDownIconSvg, ah as commentIconSvg, ai as _export_sfc, aj as NDropdown, ak as SuperInput, al as vClickOutside, am as PresentationEditor, an as SuperEditor, ao as AIWriter, ap as NConfigProvider, aq as SuperToolbar } from "./index-C16jjGce.es.js";
2
+ import "./SuperConverter-CQtzIJhu.es.js";
3
3
  import { B as BlankDOCX } from "./blank-docx-ABm6XYAA.es.js";
4
4
  import { E as EventEmitter } from "./eventemitter3-CwrdEv8r.es.js";
5
5
  import { HocuspocusProvider, HocuspocusProviderWebsocket } from "@hocuspocus/provider";
@@ -7513,7 +7513,7 @@ const _sfc_main = {
7513
7513
  __name: "SuperDoc",
7514
7514
  emits: ["selection-update"],
7515
7515
  setup(__props, { emit: __emit }) {
7516
- const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-CMz0vPEp.es.js"));
7516
+ const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-DXTnaF8I.es.js"));
7517
7517
  const superdocStore = useSuperdocStore();
7518
7518
  const commentsStore = useCommentsStore();
7519
7519
  const {
@@ -8467,7 +8467,7 @@ class SuperDoc extends EventEmitter {
8467
8467
  this.config.colors = shuffleArray(this.config.colors);
8468
8468
  this.userColorMap = /* @__PURE__ */ new Map();
8469
8469
  this.colorIndex = 0;
8470
- this.version = "1.7.0-next.5";
8470
+ this.version = "1.7.0-next.7";
8471
8471
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
8472
8472
  this.superdocId = config.superdocId || v4();
8473
8473
  this.colors = this.config.colors;