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

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-DpNWJAJU.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.6";
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.6");
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) {
@@ -43467,6 +43497,26 @@ function normalizeTextInsets(value) {
43467
43497
  return { top: top2, right: right2, bottom: bottom2, left: left2 };
43468
43498
  }
43469
43499
  const OOXML_Z_INDEX_BASE = 251658240;
43500
+ const asOoxmlElement = (value) => {
43501
+ if (!value || typeof value !== "object") return void 0;
43502
+ const element = value;
43503
+ if (element.name == null && element.attributes == null && element.elements == null) return void 0;
43504
+ return element;
43505
+ };
43506
+ const findOoxmlChild = (parent, name) => {
43507
+ return parent?.elements?.find((child) => child?.name === name);
43508
+ };
43509
+ const getOoxmlAttribute = (element, key2) => {
43510
+ if (!element?.attributes) return void 0;
43511
+ const attrs = element.attributes;
43512
+ return attrs[key2] ?? attrs[key2.startsWith("w:") ? key2.slice(2) : `w:${key2}`];
43513
+ };
43514
+ const parseOoxmlNumber = (value) => {
43515
+ if (value == null) return void 0;
43516
+ const num = typeof value === "number" ? value : Number.parseInt(String(value), 10);
43517
+ return Number.isFinite(num) ? num : void 0;
43518
+ };
43519
+ const hasOwnProperty$d = (obj, key2) => Object.prototype.hasOwnProperty.call(obj, key2);
43470
43520
  function normalizeZIndex(originalAttributes) {
43471
43521
  if (!isPlainObject$2(originalAttributes)) return void 0;
43472
43522
  const relativeHeight = originalAttributes.relativeHeight;
@@ -45467,24 +45517,47 @@ const DEFAULT_DECIMAL_SEPARATOR$2 = ".";
45467
45517
  const isValidNumberingId = (numId) => {
45468
45518
  return numId != null && numId !== 0 && numId !== "0";
45469
45519
  };
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);
45520
+ const extractSpacingExplicitFromObject = (value) => {
45521
+ if (!value || typeof value !== "object" || Array.isArray(value)) return {};
45522
+ const obj = value;
45523
+ const explicit = {};
45524
+ if (hasOwnProperty$d(obj, "before") || hasOwnProperty$d(obj, "lineSpaceBefore") || hasOwnProperty$d(obj, "beforeAutospacing") || hasOwnProperty$d(obj, "beforeAutoSpacing")) {
45525
+ explicit.before = true;
45526
+ }
45527
+ if (hasOwnProperty$d(obj, "after") || hasOwnProperty$d(obj, "lineSpaceAfter") || hasOwnProperty$d(obj, "afterAutospacing") || hasOwnProperty$d(obj, "afterAutoSpacing")) {
45528
+ explicit.after = true;
45529
+ }
45530
+ if (hasOwnProperty$d(obj, "line") || hasOwnProperty$d(obj, "lineRule")) {
45531
+ explicit.line = true;
45532
+ }
45533
+ return explicit;
45478
45534
  };
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}`];
45535
+ const extractSpacingExplicitFromOoxml = (value) => {
45536
+ const element = asOoxmlElement(value);
45537
+ if (!element) return {};
45538
+ const pPr = element.name === "w:pPr" ? element : findOoxmlChild(element, "w:pPr");
45539
+ const spacingEl = findOoxmlChild(pPr, "w:spacing");
45540
+ if (!spacingEl) return {};
45541
+ const explicit = {};
45542
+ if (getOoxmlAttribute(spacingEl, "w:before") != null || getOoxmlAttribute(spacingEl, "w:beforeAutospacing") != null || getOoxmlAttribute(spacingEl, "w:beforeAutoSpacing") != null) {
45543
+ explicit.before = true;
45544
+ }
45545
+ if (getOoxmlAttribute(spacingEl, "w:after") != null || getOoxmlAttribute(spacingEl, "w:afterAutospacing") != null || getOoxmlAttribute(spacingEl, "w:afterAutoSpacing") != null) {
45546
+ explicit.after = true;
45547
+ }
45548
+ if (getOoxmlAttribute(spacingEl, "w:line") != null || getOoxmlAttribute(spacingEl, "w:lineRule") != null) {
45549
+ explicit.line = true;
45550
+ }
45551
+ return explicit;
45483
45552
  };
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;
45553
+ const mergeSpacingExplicit = (...sources) => {
45554
+ const merged = {};
45555
+ for (const source of sources) {
45556
+ if (source.before) merged.before = true;
45557
+ if (source.after) merged.after = true;
45558
+ if (source.line) merged.line = true;
45559
+ }
45560
+ return merged;
45488
45561
  };
45489
45562
  const mergeSpacingSources = (base2, paragraphProps, attrs) => {
45490
45563
  const isObject2 = (v) => v !== null && typeof v === "object";
@@ -45530,13 +45603,13 @@ const normalizeJustification = (value) => {
45530
45603
  return void 0;
45531
45604
  };
45532
45605
  const extractIndentFromLevel = (lvl) => {
45533
- const pPr = findChild(lvl, "w:pPr");
45534
- const ind = findChild(pPr, "w:ind");
45606
+ const pPr = findOoxmlChild(lvl, "w:pPr");
45607
+ const ind = findOoxmlChild(pPr, "w:ind");
45535
45608
  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"));
45609
+ const left2 = parseOoxmlNumber(getOoxmlAttribute(ind, "w:left"));
45610
+ const right2 = parseOoxmlNumber(getOoxmlAttribute(ind, "w:right"));
45611
+ const firstLine = parseOoxmlNumber(getOoxmlAttribute(ind, "w:firstLine"));
45612
+ const hanging = parseOoxmlNumber(getOoxmlAttribute(ind, "w:hanging"));
45540
45613
  const indent = {};
45541
45614
  if (left2 != null) indent.left = left2;
45542
45615
  if (right2 != null) indent.right = right2;
@@ -45552,31 +45625,31 @@ const normalizeColor = (value) => {
45552
45625
  return `#${upper.toUpperCase()}`;
45553
45626
  };
45554
45627
  const extractMarkerRun = (lvl) => {
45555
- const rPr = findChild(lvl, "w:rPr");
45628
+ const rPr = findOoxmlChild(lvl, "w:rPr");
45556
45629
  if (!rPr) return void 0;
45557
45630
  const run = {};
45558
- const rFonts = findChild(rPr, "w:rFonts");
45559
- const font = getAttribute(rFonts, "w:ascii") ?? getAttribute(rFonts, "w:hAnsi") ?? getAttribute(rFonts, "w:eastAsia");
45631
+ const rFonts = findOoxmlChild(rPr, "w:rFonts");
45632
+ const font = getOoxmlAttribute(rFonts, "w:ascii") ?? getOoxmlAttribute(rFonts, "w:hAnsi") ?? getOoxmlAttribute(rFonts, "w:eastAsia");
45560
45633
  if (typeof font === "string" && font.trim()) {
45561
45634
  run.fontFamily = font;
45562
45635
  }
45563
- const sz = parseNumberAttr(getAttribute(findChild(rPr, "w:sz"), "w:val")) ?? parseNumberAttr(getAttribute(findChild(rPr, "w:szCs"), "w:val"));
45636
+ const sz = parseOoxmlNumber(getOoxmlAttribute(findOoxmlChild(rPr, "w:sz"), "w:val")) ?? parseOoxmlNumber(getOoxmlAttribute(findOoxmlChild(rPr, "w:szCs"), "w:val"));
45564
45637
  if (sz != null) {
45565
45638
  run.fontSize = sz / 2;
45566
45639
  }
45567
- const color = normalizeColor(getAttribute(findChild(rPr, "w:color"), "w:val"));
45640
+ const color = normalizeColor(getOoxmlAttribute(findOoxmlChild(rPr, "w:color"), "w:val"));
45568
45641
  if (color) run.color = color;
45569
- const boldEl = findChild(rPr, "w:b");
45642
+ const boldEl = findOoxmlChild(rPr, "w:b");
45570
45643
  if (boldEl) {
45571
- const boldVal = getAttribute(boldEl, "w:val");
45644
+ const boldVal = getOoxmlAttribute(boldEl, "w:val");
45572
45645
  if (boldVal == null || isTruthy(boldVal)) run.bold = true;
45573
45646
  }
45574
- const italicEl = findChild(rPr, "w:i");
45647
+ const italicEl = findOoxmlChild(rPr, "w:i");
45575
45648
  if (italicEl) {
45576
- const italicVal = getAttribute(italicEl, "w:val");
45649
+ const italicVal = getOoxmlAttribute(italicEl, "w:val");
45577
45650
  if (italicVal == null || isTruthy(italicVal)) run.italic = true;
45578
45651
  }
45579
- const spacingTwips = parseNumberAttr(getAttribute(findChild(rPr, "w:spacing"), "w:val"));
45652
+ const spacingTwips = parseOoxmlNumber(getOoxmlAttribute(findOoxmlChild(rPr, "w:spacing"), "w:val"));
45580
45653
  if (spacingTwips != null && Number.isFinite(spacingTwips)) {
45581
45654
  run.letterSpacing = twipsToPx$1(spacingTwips);
45582
45655
  }
@@ -45584,12 +45657,12 @@ const extractMarkerRun = (lvl) => {
45584
45657
  };
45585
45658
  const findNumFmtElement = (lvl) => {
45586
45659
  if (!lvl) return void 0;
45587
- const direct = findChild(lvl, "w:numFmt");
45660
+ const direct = findOoxmlChild(lvl, "w:numFmt");
45588
45661
  if (direct) return direct;
45589
- const alternate = findChild(lvl, "mc:AlternateContent");
45590
- const choice = findChild(alternate, "mc:Choice");
45662
+ const alternate = findOoxmlChild(lvl, "mc:AlternateContent");
45663
+ const choice = findOoxmlChild(alternate, "mc:Choice");
45591
45664
  if (choice) {
45592
- return findChild(choice, "w:numFmt");
45665
+ return findOoxmlChild(choice, "w:numFmt");
45593
45666
  }
45594
45667
  return void 0;
45595
45668
  };
@@ -45603,7 +45676,7 @@ const resolveNumberingFromContext = (numId, ilvl, numbering) => {
45603
45676
  if (!numDef) {
45604
45677
  return void 0;
45605
45678
  }
45606
- const abstractId = getAttribute(findChild(numDef, "w:abstractNumId"), "w:val");
45679
+ const abstractId = getOoxmlAttribute(findOoxmlChild(numDef, "w:abstractNumId"), "w:val");
45607
45680
  if (abstractId == null) {
45608
45681
  return void 0;
45609
45682
  }
@@ -45612,27 +45685,27 @@ const resolveNumberingFromContext = (numId, ilvl, numbering) => {
45612
45685
  return void 0;
45613
45686
  }
45614
45687
  let levelDef = abstract.elements?.find(
45615
- (el) => el?.name === "w:lvl" && parseNumberAttr(el.attributes?.["w:ilvl"]) === ilvl
45688
+ (el) => el?.name === "w:lvl" && parseOoxmlNumber(el.attributes?.["w:ilvl"]) === ilvl
45616
45689
  );
45617
45690
  const override = numDef.elements?.find(
45618
- (el) => el?.name === "w:lvlOverride" && parseNumberAttr(el.attributes?.["w:ilvl"]) === ilvl
45691
+ (el) => el?.name === "w:lvlOverride" && parseOoxmlNumber(el.attributes?.["w:ilvl"]) === ilvl
45619
45692
  );
45620
- const overrideLvl = findChild(override, "w:lvl");
45693
+ const overrideLvl = findOoxmlChild(override, "w:lvl");
45621
45694
  if (overrideLvl) {
45622
45695
  levelDef = overrideLvl;
45623
45696
  }
45624
- const startOverride = parseNumberAttr(getAttribute(findChild(override, "w:startOverride"), "w:val"));
45697
+ const startOverride = parseOoxmlNumber(getOoxmlAttribute(findOoxmlChild(override, "w:startOverride"), "w:val"));
45625
45698
  if (!levelDef) {
45626
45699
  return void 0;
45627
45700
  }
45628
45701
  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"));
45702
+ const lvlText = getOoxmlAttribute(findOoxmlChild(levelDef, "w:lvlText"), "w:val");
45703
+ const start2 = startOverride ?? parseOoxmlNumber(getOoxmlAttribute(findOoxmlChild(levelDef, "w:start"), "w:val"));
45704
+ const suffix2 = normalizeSuffix(getOoxmlAttribute(findOoxmlChild(levelDef, "w:suff"), "w:val"));
45705
+ const lvlJc = normalizeJustification(getOoxmlAttribute(findOoxmlChild(levelDef, "w:lvlJc"), "w:val"));
45633
45706
  const indent = extractIndentFromLevel(levelDef);
45634
45707
  const markerRun = extractMarkerRun(levelDef);
45635
- const numFmt = normalizeNumFmt(getAttribute(numFmtEl, "w:val"));
45708
+ const numFmt = normalizeNumFmt(getOoxmlAttribute(numFmtEl, "w:val"));
45636
45709
  return {
45637
45710
  format: numFmt,
45638
45711
  lvlText,
@@ -45725,6 +45798,7 @@ const cloneParagraphAttrs = (attrs) => {
45725
45798
  if (!attrs) return void 0;
45726
45799
  const clone = { ...attrs };
45727
45800
  if (attrs.spacing) clone.spacing = { ...attrs.spacing };
45801
+ if (attrs.spacingExplicit) clone.spacingExplicit = { ...attrs.spacingExplicit };
45728
45802
  if (attrs.indent) clone.indent = { ...attrs.indent };
45729
45803
  if (attrs.borders) {
45730
45804
  const borderClone = {};
@@ -46100,6 +46174,11 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
46100
46174
  const hydrated = hydrationOverride ?? hydrateParagraphStyleAttrs(para, converterContext);
46101
46175
  const mergedSpacing = mergeSpacingSources(hydrated?.spacing, paragraphProps.spacing, attrs.spacing);
46102
46176
  const normalizedSpacing = normalizeParagraphSpacing(mergedSpacing);
46177
+ const spacingExplicit = mergeSpacingExplicit(
46178
+ extractSpacingExplicitFromObject(paragraphProps.spacing),
46179
+ extractSpacingExplicitFromObject(attrs.spacing),
46180
+ extractSpacingExplicitFromOoxml(paragraphProps)
46181
+ );
46103
46182
  const normalizeIndentObject = (value) => {
46104
46183
  if (!value || typeof value !== "object") return;
46105
46184
  return normalizePxIndent(value) ?? convertIndentTwipsToPx(value);
@@ -46234,6 +46313,7 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
46234
46313
  paragraphAttrs.spacing.afterAutospacing = normalizedSpacing.afterAutospacing;
46235
46314
  }
46236
46315
  }
46316
+ paragraphAttrs.spacingExplicit = spacingExplicit;
46237
46317
  const contextualSpacingValue = normalizedSpacing?.contextualSpacing ?? safeGetProperty(paragraphProps, "contextualSpacing") ?? safeGetProperty(attrs, "contextualSpacing") ?? hydrated?.contextualSpacing;
46238
46318
  if (contextualSpacingValue != null) {
46239
46319
  paragraphAttrs.contextualSpacing = isTruthy(contextualSpacingValue);
@@ -47712,6 +47792,75 @@ const extractFirstTextRunFont = (para) => {
47712
47792
  const font = findFirstTextFont(para.content);
47713
47793
  return font;
47714
47794
  };
47795
+ const resolveRunFontFamily = (fontFamily2, docx) => {
47796
+ if (typeof fontFamily2 === "string" && fontFamily2.trim().length > 0) {
47797
+ return fontFamily2;
47798
+ }
47799
+ if (!fontFamily2 || typeof fontFamily2 !== "object") return void 0;
47800
+ const toCssFontFamily2 = SuperConverter.toCssFontFamily;
47801
+ const resolved = resolveDocxFontFamily(fontFamily2, docx ?? null, toCssFontFamily2);
47802
+ return resolved ?? void 0;
47803
+ };
47804
+ const parseRunFontSizePx = (fontSize2) => {
47805
+ if (typeof fontSize2 === "number" && Number.isFinite(fontSize2)) {
47806
+ return ptToPx(fontSize2 / HALF_POINTS_PER_POINT) ?? void 0;
47807
+ }
47808
+ if (typeof fontSize2 === "string") {
47809
+ const numeric = Number.parseFloat(fontSize2);
47810
+ if (!Number.isFinite(numeric)) return void 0;
47811
+ if (fontSize2.endsWith("pt")) {
47812
+ return ptToPx(numeric);
47813
+ }
47814
+ if (fontSize2.endsWith("px")) {
47815
+ return numeric;
47816
+ }
47817
+ return ptToPx(numeric / HALF_POINTS_PER_POINT) ?? void 0;
47818
+ }
47819
+ return void 0;
47820
+ };
47821
+ const extractParagraphMarkRunProps = (paragraphProps) => {
47822
+ const directRunProps = paragraphProps.runProperties;
47823
+ const directRunPropsElement = asOoxmlElement(directRunProps);
47824
+ if (directRunProps && isPlainObject$2(directRunProps) && !directRunPropsElement) {
47825
+ return directRunProps;
47826
+ }
47827
+ const element = asOoxmlElement(paragraphProps);
47828
+ const pPr = element ? element.name === "w:pPr" ? element : findOoxmlChild(element, "w:pPr") : void 0;
47829
+ const rPr = directRunPropsElement?.name === "w:rPr" ? directRunPropsElement : findOoxmlChild(pPr, "w:rPr");
47830
+ if (!rPr) return void 0;
47831
+ const runProps = {};
47832
+ const sz = parseOoxmlNumber(getOoxmlAttribute(findOoxmlChild(rPr, "w:sz"), "w:val")) ?? parseOoxmlNumber(getOoxmlAttribute(findOoxmlChild(rPr, "w:szCs"), "w:val"));
47833
+ if (sz != null) {
47834
+ runProps.fontSize = sz;
47835
+ }
47836
+ const rFonts = findOoxmlChild(rPr, "w:rFonts");
47837
+ if (rFonts) {
47838
+ const fontFamily2 = {};
47839
+ const keys2 = ["ascii", "hAnsi", "eastAsia", "cs", "val", "asciiTheme", "hAnsiTheme", "eastAsiaTheme", "cstheme"];
47840
+ for (const key2 of keys2) {
47841
+ const value = getOoxmlAttribute(rFonts, `w:${key2}`);
47842
+ if (value != null) {
47843
+ fontFamily2[key2] = value;
47844
+ }
47845
+ }
47846
+ if (Object.keys(fontFamily2).length > 0) {
47847
+ runProps.fontFamily = fontFamily2;
47848
+ }
47849
+ }
47850
+ return Object.keys(runProps).length > 0 ? runProps : void 0;
47851
+ };
47852
+ const applyParagraphMarkRunProps = (run, paragraphProps, converterContext) => {
47853
+ const runProps = extractParagraphMarkRunProps(paragraphProps);
47854
+ if (!runProps) return;
47855
+ const fontSizePx = parseRunFontSizePx(runProps.fontSize);
47856
+ if (fontSizePx != null) {
47857
+ run.fontSize = fontSizePx;
47858
+ }
47859
+ const fontFamily2 = resolveRunFontFamily(runProps.fontFamily, converterContext?.docx);
47860
+ if (fontFamily2) {
47861
+ run.fontFamily = fontFamily2;
47862
+ }
47863
+ };
47715
47864
  const applyBaseRunDefaults = (run, defaults, uiDisplayFallbackFont, fallbackSize) => {
47716
47865
  if (!run) return;
47717
47866
  if (defaults.fontFamily && run.fontFamily === uiDisplayFallbackFont) {
@@ -47861,6 +48010,8 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
47861
48010
  emptyRun.pmStart = paraPos.start + 1;
47862
48011
  emptyRun.pmEnd = paraPos.start + 1;
47863
48012
  }
48013
+ applyBaseRunDefaults(emptyRun, baseRunDefaults, defaultFont, defaultSize);
48014
+ applyParagraphMarkRunProps(emptyRun, paragraphProps, converterContext);
47864
48015
  let emptyParagraphAttrs = cloneParagraphAttrs(paragraphAttrs);
47865
48016
  if (isSectPrMarker) {
47866
48017
  if (emptyParagraphAttrs) {
@@ -51248,7 +51399,6 @@ function measureText(text, font, ctx2, _fontFamily, _letterSpacing) {
51248
51399
  const paintedWidth = (metrics.actualBoundingBoxLeft || 0) + (metrics.actualBoundingBoxRight || 0);
51249
51400
  return Math.max(advanceWidth, paintedWidth);
51250
51401
  }
51251
- const MIN_SINGLE_LINE_PX = 12 * 96 / 72;
51252
51402
  const WORD_SINGLE_LINE_SPACING_MULTIPLIER = 1.15;
51253
51403
  function calculateTypographyMetrics(fontSize2, spacing, fontInfo) {
51254
51404
  let ascent;
@@ -51262,7 +51412,27 @@ function calculateTypographyMetrics(fontSize2, spacing, fontInfo) {
51262
51412
  ascent = roundValue(fontSize2 * 0.8);
51263
51413
  descent = roundValue(fontSize2 * 0.2);
51264
51414
  }
51265
- const baseLineHeight = Math.max(fontSize2 * WORD_SINGLE_LINE_SPACING_MULTIPLIER, ascent + descent, MIN_SINGLE_LINE_PX);
51415
+ const baseLineHeight = Math.max(fontSize2 * WORD_SINGLE_LINE_SPACING_MULTIPLIER, ascent + descent);
51416
+ const lineHeight2 = roundValue(resolveLineHeight(spacing, baseLineHeight));
51417
+ return {
51418
+ ascent,
51419
+ descent,
51420
+ lineHeight: lineHeight2
51421
+ };
51422
+ }
51423
+ function calculateEmptyParagraphMetrics(fontSize2, spacing, fontInfo) {
51424
+ let ascent;
51425
+ let descent;
51426
+ if (fontInfo) {
51427
+ const ctx2 = getCanvasContext();
51428
+ const metrics = getFontMetrics(ctx2, fontInfo);
51429
+ ascent = roundValue(metrics.ascent);
51430
+ descent = roundValue(metrics.descent);
51431
+ } else {
51432
+ ascent = roundValue(fontSize2 * 0.8);
51433
+ descent = roundValue(fontSize2 * 0.2);
51434
+ }
51435
+ const baseLineHeight = Math.max(fontSize2, ascent + descent);
51266
51436
  const lineHeight2 = roundValue(resolveLineHeight(spacing, baseLineHeight));
51267
51437
  return {
51268
51438
  ascent,
@@ -51293,6 +51463,10 @@ function isImageRun(run) {
51293
51463
  function isLineBreakRun(run) {
51294
51464
  return run.kind === "lineBreak";
51295
51465
  }
51466
+ const isEmptyTextRun = (run) => {
51467
+ if (run.kind && run.kind !== "text") return false;
51468
+ return typeof run.text === "string" && run.text.length === 0;
51469
+ };
51296
51470
  function isFieldAnnotationRun(run) {
51297
51471
  return run.kind === "fieldAnnotation";
51298
51472
  }
@@ -51462,8 +51636,28 @@ async function measureParagraphBlock(block, maxWidth) {
51462
51636
  dropCapDescriptor.measuredHeight = dropCapMeasured.height;
51463
51637
  }
51464
51638
  }
51639
+ const emptyParagraphRun = block.runs.length === 1 && isEmptyTextRun(block.runs[0]) ? block.runs[0] : null;
51640
+ if (emptyParagraphRun) {
51641
+ const fontSize2 = emptyParagraphRun.fontSize ?? 12;
51642
+ const metrics = calculateEmptyParagraphMetrics(fontSize2, spacing, getFontInfoFromRun(emptyParagraphRun));
51643
+ const emptyLine = {
51644
+ fromRun: 0,
51645
+ fromChar: 0,
51646
+ toRun: 0,
51647
+ toChar: 0,
51648
+ width: 0,
51649
+ ...metrics
51650
+ };
51651
+ addBarTabsToLine(emptyLine);
51652
+ lines.push(emptyLine);
51653
+ return {
51654
+ kind: "paragraph",
51655
+ lines,
51656
+ totalHeight: metrics.lineHeight
51657
+ };
51658
+ }
51465
51659
  if (block.runs.length === 0) {
51466
- const metrics = calculateTypographyMetrics(12, spacing);
51660
+ const metrics = calculateEmptyParagraphMetrics(12, spacing);
51467
51661
  const emptyLine = {
51468
51662
  fromRun: 0,
51469
51663
  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-DnpYZRby.es.js";
2
+ import "./SuperConverter-DpNWJAJU.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-CVwE4WYW.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.6";
8471
8471
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
8472
8472
  this.superdocId = config.superdocId || v4();
8473
8473
  this.colors = this.config.colors;
@@ -2,6 +2,6 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  require("../chunks/jszip-C8_CqJxM.cjs");
4
4
  require("../chunks/helpers-nOdwpmwb.cjs");
5
- const superEditor_converter = require("../chunks/SuperConverter-CGlcEWcs.cjs");
5
+ const superEditor_converter = require("../chunks/SuperConverter-iUnNfL5l.cjs");
6
6
  require("../chunks/uuid-R7L08bOx.cjs");
7
7
  exports.SuperConverter = superEditor_converter.SuperConverter;
@@ -1,6 +1,6 @@
1
1
  import "../chunks/jszip-B1fkPkPJ.es.js";
2
2
  import "../chunks/helpers-C8e9wR5l.es.js";
3
- import { S } from "../chunks/SuperConverter-DU1Tqi67.es.js";
3
+ import { S } from "../chunks/SuperConverter-DpNWJAJU.es.js";
4
4
  import "../chunks/uuid-CjlX8hrF.es.js";
5
5
  export {
6
6
  S as SuperConverter
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("./chunks/index-i_RngoBn.cjs");
3
+ const index = require("./chunks/index-ChXg2ff-.cjs");
4
4
  const superEditor_docxZipper = require("./super-editor/docx-zipper.cjs");
5
5
  const superEditor_fileZipper = require("./super-editor/file-zipper.cjs");
6
6
  const vue = require("./chunks/vue-De9wkgLl.cjs");
7
- const superEditor_converter = require("./chunks/SuperConverter-CGlcEWcs.cjs");
7
+ const superEditor_converter = require("./chunks/SuperConverter-iUnNfL5l.cjs");
8
8
  function isNodeType(node, name) {
9
9
  return node.type.name === name;
10
10
  }
@@ -1,9 +1,9 @@
1
- import { ax as Node, ay as Mark } from "./chunks/index-DYUIpqx9.es.js";
2
- import { ao, au, a9, ab, aw, am, av, aA, an, ak, aq, az, aa, as, aC, aE, aB, ac, aD, ar, at } from "./chunks/index-DYUIpqx9.es.js";
1
+ import { ax as Node, ay as Mark } from "./chunks/index-DnpYZRby.es.js";
2
+ import { ao, au, a9, ab, aw, am, av, aA, an, ak, aq, az, aa, as, aC, aE, aB, ac, aD, ar, at } from "./chunks/index-DnpYZRby.es.js";
3
3
  import { default as default2 } from "./super-editor/docx-zipper.es.js";
4
4
  import { createZip } from "./super-editor/file-zipper.es.js";
5
5
  import { d as defineComponent, E as createElementBlock, G as openBlock, K as createBaseVNode } from "./chunks/vue-BnBKJwCW.es.js";
6
- import { S, r } from "./chunks/SuperConverter-DU1Tqi67.es.js";
6
+ import { S, r } from "./chunks/SuperConverter-DpNWJAJU.es.js";
7
7
  function isNodeType(node, name) {
8
8
  return node.type.name === name;
9
9
  }
package/dist/superdoc.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("./chunks/index-i_RngoBn.cjs");
4
- const superdoc = require("./chunks/index-Clk0gT7d.cjs");
5
- const superEditor_converter = require("./chunks/SuperConverter-CGlcEWcs.cjs");
3
+ const index = require("./chunks/index-ChXg2ff-.cjs");
4
+ const superdoc = require("./chunks/index-DfBvgXLe.cjs");
5
+ const superEditor_converter = require("./chunks/SuperConverter-iUnNfL5l.cjs");
6
6
  const blankDocx = require("./chunks/blank-docx-DfW3Eeh2.cjs");
7
7
  require("./chunks/jszip-C8_CqJxM.cjs");
8
8
  require("./chunks/helpers-nOdwpmwb.cjs");
@@ -1,6 +1,6 @@
1
- import { au, ab, aw, av, as, a7, ac, ar, at } from "./chunks/index-DYUIpqx9.es.js";
2
- import { D, H, P, S, c } from "./chunks/index-BQo9zrNo.es.js";
3
- import { S as S2, r } from "./chunks/SuperConverter-DU1Tqi67.es.js";
1
+ import { au, ab, aw, av, as, a7, ac, ar, at } from "./chunks/index-DnpYZRby.es.js";
2
+ import { D, H, P, S, c } from "./chunks/index-HKM0YiEI.es.js";
3
+ import { S as S2, r } from "./chunks/SuperConverter-DpNWJAJU.es.js";
4
4
  import { B } from "./chunks/blank-docx-ABm6XYAA.es.js";
5
5
  import "./chunks/jszip-B1fkPkPJ.es.js";
6
6
  import "./chunks/helpers-C8e9wR5l.es.js";