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,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-CGlcEWcs.cjs");
4
+ const superEditor_converter = require("./SuperConverter-ChOaRc8I.cjs");
5
5
  const vue = require("./vue-De9wkgLl.cjs");
6
6
  require("./jszip.min-BPh2MMAa.cjs");
7
7
  const eventemitter3 = require("./eventemitter3-BQuRcMPI.cjs");
@@ -15788,7 +15788,7 @@ const canUseDOM = () => {
15788
15788
  return false;
15789
15789
  }
15790
15790
  };
15791
- const summaryVersion = "1.7.0-next.5";
15791
+ const summaryVersion = "1.7.0-next.7";
15792
15792
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
15793
15793
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
15794
15794
  function mapAttributes(attrs) {
@@ -18455,7 +18455,7 @@ class Editor extends EventEmitter {
18455
18455
  * Process collaboration migrations
18456
18456
  */
18457
18457
  processCollaborationMigrations() {
18458
- console.debug("[checkVersionMigrations] Current editor version", "1.7.0-next.5");
18458
+ console.debug("[checkVersionMigrations] Current editor version", "1.7.0-next.7");
18459
18459
  if (!this.options.ydoc) return;
18460
18460
  const metaMap = this.options.ydoc.getMap("meta");
18461
18461
  let docVersion = metaMap.get("version");
@@ -33057,6 +33057,28 @@ function applyPendingToActive(state) {
33057
33057
  next.pendingOrientation = null;
33058
33058
  return next;
33059
33059
  }
33060
+ const isTextRun$3 = (run) => {
33061
+ const runWithKind = run;
33062
+ return !runWithKind.kind || runWithKind.kind === "text";
33063
+ };
33064
+ const isEmptyTextParagraph = (block) => {
33065
+ const runs = block.runs;
33066
+ if (!runs || runs.length === 0) return true;
33067
+ if (runs.length !== 1) return false;
33068
+ const run = runs[0];
33069
+ if (!isTextRun$3(run)) return false;
33070
+ return typeof run.text === "string" && run.text.length === 0;
33071
+ };
33072
+ const shouldSuppressSpacingForEmpty = (block, side) => {
33073
+ if (!isEmptyTextParagraph(block)) return false;
33074
+ const attrs = block.attrs;
33075
+ const spacingExplicit = attrs?.spacingExplicit;
33076
+ if (!spacingExplicit) return false;
33077
+ if (side === "before") {
33078
+ return !spacingExplicit.before;
33079
+ }
33080
+ return !spacingExplicit.after;
33081
+ };
33060
33082
  function normalizeLines(measure) {
33061
33083
  if (measure.lines.length > 0) {
33062
33084
  return measure.lines;
@@ -33296,11 +33318,17 @@ function layoutParagraphBlock(ctx2, anchors) {
33296
33318
  let fromLine = 0;
33297
33319
  const attrs = getParagraphAttrs(block);
33298
33320
  const spacing = attrs?.spacing ?? {};
33321
+ const spacingExplicit = attrs?.spacingExplicit;
33299
33322
  const styleId = asString(attrs?.styleId);
33300
33323
  const contextualSpacing = asBoolean$1(attrs?.contextualSpacing);
33301
33324
  let spacingBefore = Math.max(0, Number(spacing.before ?? spacing.lineSpaceBefore ?? 0));
33325
+ let spacingAfter = Math.max(0, Number(spacing.after ?? spacing.lineSpaceAfter ?? 0));
33326
+ const emptyTextParagraph = isEmptyTextParagraph(block);
33327
+ if (emptyTextParagraph && spacingExplicit) {
33328
+ if (!spacingExplicit.before) spacingBefore = 0;
33329
+ if (!spacingExplicit.after) spacingAfter = 0;
33330
+ }
33302
33331
  const baseSpacingBefore = spacingBefore;
33303
- const spacingAfter = Math.max(0, Number(spacing.after ?? spacing.lineSpaceAfter ?? 0));
33304
33332
  let appliedSpacingBefore = spacingBefore === 0;
33305
33333
  let lastState = null;
33306
33334
  const isPositionedFrame = frame?.wrap === "none";
@@ -34622,11 +34650,13 @@ function hasHeight(fragment) {
34622
34650
  function getParagraphSpacingBefore(block) {
34623
34651
  const spacing = block.attrs?.spacing;
34624
34652
  const value = spacing?.before ?? spacing?.lineSpaceBefore;
34653
+ if (shouldSuppressSpacingForEmpty(block, "before")) return 0;
34625
34654
  return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : 0;
34626
34655
  }
34627
34656
  function getParagraphSpacingAfter$1(block) {
34628
34657
  const spacing = block.attrs?.spacing;
34629
34658
  const value = spacing?.after ?? spacing?.lineSpaceAfter;
34659
+ if (shouldSuppressSpacingForEmpty(block, "after")) return 0;
34630
34660
  return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : 0;
34631
34661
  }
34632
34662
  function getMeasureHeight(block, measure) {
@@ -42336,18 +42366,29 @@ function setupInternalFieldAnnotationDragHandlers({
42336
42366
  const fieldId = event.data.fieldId;
42337
42367
  if (fieldId) {
42338
42368
  const targetPos = event.pmPosition;
42369
+ const pmStart = event.data.pmStart;
42339
42370
  let sourceStart = null;
42340
42371
  let sourceEnd = null;
42341
42372
  let sourceNode = null;
42342
- state.doc.descendants((node, pos) => {
42343
- if (node.type.name === "fieldAnnotation" && node.attrs.fieldId === fieldId) {
42344
- sourceStart = pos;
42345
- sourceEnd = pos + node.nodeSize;
42346
- sourceNode = node;
42347
- return false;
42373
+ if (pmStart != null) {
42374
+ const nodeAt = state.doc.nodeAt(pmStart);
42375
+ if (nodeAt?.type?.name === "fieldAnnotation") {
42376
+ sourceStart = pmStart;
42377
+ sourceEnd = pmStart + nodeAt.nodeSize;
42378
+ sourceNode = nodeAt;
42348
42379
  }
42349
- return true;
42350
- });
42380
+ }
42381
+ if (sourceStart == null || sourceEnd == null || !sourceNode) {
42382
+ state.doc.descendants((node, pos) => {
42383
+ if (node.type.name === "fieldAnnotation" && node.attrs.fieldId === fieldId) {
42384
+ sourceStart = pos;
42385
+ sourceEnd = pos + node.nodeSize;
42386
+ sourceNode = node;
42387
+ return false;
42388
+ }
42389
+ return true;
42390
+ });
42391
+ }
42351
42392
  if (sourceStart === null || sourceEnd === null || !sourceNode) {
42352
42393
  return;
42353
42394
  }
@@ -43484,6 +43525,26 @@ function normalizeTextInsets(value) {
43484
43525
  return { top: top2, right: right2, bottom: bottom2, left: left2 };
43485
43526
  }
43486
43527
  const OOXML_Z_INDEX_BASE = 251658240;
43528
+ const asOoxmlElement = (value) => {
43529
+ if (!value || typeof value !== "object") return void 0;
43530
+ const element = value;
43531
+ if (element.name == null && element.attributes == null && element.elements == null) return void 0;
43532
+ return element;
43533
+ };
43534
+ const findOoxmlChild = (parent, name) => {
43535
+ return parent?.elements?.find((child) => child?.name === name);
43536
+ };
43537
+ const getOoxmlAttribute = (element, key2) => {
43538
+ if (!element?.attributes) return void 0;
43539
+ const attrs = element.attributes;
43540
+ return attrs[key2] ?? attrs[key2.startsWith("w:") ? key2.slice(2) : `w:${key2}`];
43541
+ };
43542
+ const parseOoxmlNumber = (value) => {
43543
+ if (value == null) return void 0;
43544
+ const num = typeof value === "number" ? value : Number.parseInt(String(value), 10);
43545
+ return Number.isFinite(num) ? num : void 0;
43546
+ };
43547
+ const hasOwnProperty$d = (obj, key2) => Object.prototype.hasOwnProperty.call(obj, key2);
43487
43548
  function normalizeZIndex(originalAttributes) {
43488
43549
  if (!isPlainObject$2(originalAttributes)) return void 0;
43489
43550
  const relativeHeight = originalAttributes.relativeHeight;
@@ -45484,24 +45545,47 @@ const DEFAULT_DECIMAL_SEPARATOR$2 = ".";
45484
45545
  const isValidNumberingId = (numId) => {
45485
45546
  return numId != null && numId !== 0 && numId !== "0";
45486
45547
  };
45487
- const asOoxmlElement = (value) => {
45488
- if (!value || typeof value !== "object") return void 0;
45489
- const element = value;
45490
- if (element.name == null && element.attributes == null && element.elements == null) return void 0;
45491
- return element;
45492
- };
45493
- const findChild = (parent, name) => {
45494
- return parent?.elements?.find((child) => child?.name === name);
45548
+ const extractSpacingExplicitFromObject = (value) => {
45549
+ if (!value || typeof value !== "object" || Array.isArray(value)) return {};
45550
+ const obj = value;
45551
+ const explicit = {};
45552
+ if (hasOwnProperty$d(obj, "before") || hasOwnProperty$d(obj, "lineSpaceBefore") || hasOwnProperty$d(obj, "beforeAutospacing") || hasOwnProperty$d(obj, "beforeAutoSpacing")) {
45553
+ explicit.before = true;
45554
+ }
45555
+ if (hasOwnProperty$d(obj, "after") || hasOwnProperty$d(obj, "lineSpaceAfter") || hasOwnProperty$d(obj, "afterAutospacing") || hasOwnProperty$d(obj, "afterAutoSpacing")) {
45556
+ explicit.after = true;
45557
+ }
45558
+ if (hasOwnProperty$d(obj, "line") || hasOwnProperty$d(obj, "lineRule")) {
45559
+ explicit.line = true;
45560
+ }
45561
+ return explicit;
45495
45562
  };
45496
- const getAttribute = (element, key2) => {
45497
- if (!element?.attributes) return void 0;
45498
- const attrs = element.attributes;
45499
- return attrs[key2] ?? attrs[key2.startsWith("w:") ? key2.slice(2) : `w:${key2}`];
45563
+ const extractSpacingExplicitFromOoxml = (value) => {
45564
+ const element = asOoxmlElement(value);
45565
+ if (!element) return {};
45566
+ const pPr = element.name === "w:pPr" ? element : findOoxmlChild(element, "w:pPr");
45567
+ const spacingEl = findOoxmlChild(pPr, "w:spacing");
45568
+ if (!spacingEl) return {};
45569
+ const explicit = {};
45570
+ if (getOoxmlAttribute(spacingEl, "w:before") != null || getOoxmlAttribute(spacingEl, "w:beforeAutospacing") != null || getOoxmlAttribute(spacingEl, "w:beforeAutoSpacing") != null) {
45571
+ explicit.before = true;
45572
+ }
45573
+ if (getOoxmlAttribute(spacingEl, "w:after") != null || getOoxmlAttribute(spacingEl, "w:afterAutospacing") != null || getOoxmlAttribute(spacingEl, "w:afterAutoSpacing") != null) {
45574
+ explicit.after = true;
45575
+ }
45576
+ if (getOoxmlAttribute(spacingEl, "w:line") != null || getOoxmlAttribute(spacingEl, "w:lineRule") != null) {
45577
+ explicit.line = true;
45578
+ }
45579
+ return explicit;
45500
45580
  };
45501
- const parseNumberAttr = (value) => {
45502
- if (value == null) return void 0;
45503
- const num = typeof value === "number" ? value : Number.parseInt(String(value), 10);
45504
- return Number.isFinite(num) ? num : void 0;
45581
+ const mergeSpacingExplicit = (...sources) => {
45582
+ const merged = {};
45583
+ for (const source of sources) {
45584
+ if (source.before) merged.before = true;
45585
+ if (source.after) merged.after = true;
45586
+ if (source.line) merged.line = true;
45587
+ }
45588
+ return merged;
45505
45589
  };
45506
45590
  const mergeSpacingSources = (base2, paragraphProps, attrs) => {
45507
45591
  const isObject2 = (v) => v !== null && typeof v === "object";
@@ -45547,13 +45631,13 @@ const normalizeJustification = (value) => {
45547
45631
  return void 0;
45548
45632
  };
45549
45633
  const extractIndentFromLevel = (lvl) => {
45550
- const pPr = findChild(lvl, "w:pPr");
45551
- const ind = findChild(pPr, "w:ind");
45634
+ const pPr = findOoxmlChild(lvl, "w:pPr");
45635
+ const ind = findOoxmlChild(pPr, "w:ind");
45552
45636
  if (!ind) return void 0;
45553
- const left2 = parseNumberAttr(getAttribute(ind, "w:left"));
45554
- const right2 = parseNumberAttr(getAttribute(ind, "w:right"));
45555
- const firstLine = parseNumberAttr(getAttribute(ind, "w:firstLine"));
45556
- const hanging = parseNumberAttr(getAttribute(ind, "w:hanging"));
45637
+ const left2 = parseOoxmlNumber(getOoxmlAttribute(ind, "w:left"));
45638
+ const right2 = parseOoxmlNumber(getOoxmlAttribute(ind, "w:right"));
45639
+ const firstLine = parseOoxmlNumber(getOoxmlAttribute(ind, "w:firstLine"));
45640
+ const hanging = parseOoxmlNumber(getOoxmlAttribute(ind, "w:hanging"));
45557
45641
  const indent = {};
45558
45642
  if (left2 != null) indent.left = left2;
45559
45643
  if (right2 != null) indent.right = right2;
@@ -45569,31 +45653,31 @@ const normalizeColor = (value) => {
45569
45653
  return `#${upper.toUpperCase()}`;
45570
45654
  };
45571
45655
  const extractMarkerRun = (lvl) => {
45572
- const rPr = findChild(lvl, "w:rPr");
45656
+ const rPr = findOoxmlChild(lvl, "w:rPr");
45573
45657
  if (!rPr) return void 0;
45574
45658
  const run = {};
45575
- const rFonts = findChild(rPr, "w:rFonts");
45576
- const font = getAttribute(rFonts, "w:ascii") ?? getAttribute(rFonts, "w:hAnsi") ?? getAttribute(rFonts, "w:eastAsia");
45659
+ const rFonts = findOoxmlChild(rPr, "w:rFonts");
45660
+ const font = getOoxmlAttribute(rFonts, "w:ascii") ?? getOoxmlAttribute(rFonts, "w:hAnsi") ?? getOoxmlAttribute(rFonts, "w:eastAsia");
45577
45661
  if (typeof font === "string" && font.trim()) {
45578
45662
  run.fontFamily = font;
45579
45663
  }
45580
- const sz = parseNumberAttr(getAttribute(findChild(rPr, "w:sz"), "w:val")) ?? parseNumberAttr(getAttribute(findChild(rPr, "w:szCs"), "w:val"));
45664
+ const sz = parseOoxmlNumber(getOoxmlAttribute(findOoxmlChild(rPr, "w:sz"), "w:val")) ?? parseOoxmlNumber(getOoxmlAttribute(findOoxmlChild(rPr, "w:szCs"), "w:val"));
45581
45665
  if (sz != null) {
45582
45666
  run.fontSize = sz / 2;
45583
45667
  }
45584
- const color = normalizeColor(getAttribute(findChild(rPr, "w:color"), "w:val"));
45668
+ const color = normalizeColor(getOoxmlAttribute(findOoxmlChild(rPr, "w:color"), "w:val"));
45585
45669
  if (color) run.color = color;
45586
- const boldEl = findChild(rPr, "w:b");
45670
+ const boldEl = findOoxmlChild(rPr, "w:b");
45587
45671
  if (boldEl) {
45588
- const boldVal = getAttribute(boldEl, "w:val");
45672
+ const boldVal = getOoxmlAttribute(boldEl, "w:val");
45589
45673
  if (boldVal == null || isTruthy(boldVal)) run.bold = true;
45590
45674
  }
45591
- const italicEl = findChild(rPr, "w:i");
45675
+ const italicEl = findOoxmlChild(rPr, "w:i");
45592
45676
  if (italicEl) {
45593
- const italicVal = getAttribute(italicEl, "w:val");
45677
+ const italicVal = getOoxmlAttribute(italicEl, "w:val");
45594
45678
  if (italicVal == null || isTruthy(italicVal)) run.italic = true;
45595
45679
  }
45596
- const spacingTwips = parseNumberAttr(getAttribute(findChild(rPr, "w:spacing"), "w:val"));
45680
+ const spacingTwips = parseOoxmlNumber(getOoxmlAttribute(findOoxmlChild(rPr, "w:spacing"), "w:val"));
45597
45681
  if (spacingTwips != null && Number.isFinite(spacingTwips)) {
45598
45682
  run.letterSpacing = twipsToPx$1(spacingTwips);
45599
45683
  }
@@ -45601,12 +45685,12 @@ const extractMarkerRun = (lvl) => {
45601
45685
  };
45602
45686
  const findNumFmtElement = (lvl) => {
45603
45687
  if (!lvl) return void 0;
45604
- const direct = findChild(lvl, "w:numFmt");
45688
+ const direct = findOoxmlChild(lvl, "w:numFmt");
45605
45689
  if (direct) return direct;
45606
- const alternate = findChild(lvl, "mc:AlternateContent");
45607
- const choice = findChild(alternate, "mc:Choice");
45690
+ const alternate = findOoxmlChild(lvl, "mc:AlternateContent");
45691
+ const choice = findOoxmlChild(alternate, "mc:Choice");
45608
45692
  if (choice) {
45609
- return findChild(choice, "w:numFmt");
45693
+ return findOoxmlChild(choice, "w:numFmt");
45610
45694
  }
45611
45695
  return void 0;
45612
45696
  };
@@ -45620,7 +45704,7 @@ const resolveNumberingFromContext = (numId, ilvl, numbering) => {
45620
45704
  if (!numDef) {
45621
45705
  return void 0;
45622
45706
  }
45623
- const abstractId = getAttribute(findChild(numDef, "w:abstractNumId"), "w:val");
45707
+ const abstractId = getOoxmlAttribute(findOoxmlChild(numDef, "w:abstractNumId"), "w:val");
45624
45708
  if (abstractId == null) {
45625
45709
  return void 0;
45626
45710
  }
@@ -45629,27 +45713,27 @@ const resolveNumberingFromContext = (numId, ilvl, numbering) => {
45629
45713
  return void 0;
45630
45714
  }
45631
45715
  let levelDef = abstract.elements?.find(
45632
- (el) => el?.name === "w:lvl" && parseNumberAttr(el.attributes?.["w:ilvl"]) === ilvl
45716
+ (el) => el?.name === "w:lvl" && parseOoxmlNumber(el.attributes?.["w:ilvl"]) === ilvl
45633
45717
  );
45634
45718
  const override = numDef.elements?.find(
45635
- (el) => el?.name === "w:lvlOverride" && parseNumberAttr(el.attributes?.["w:ilvl"]) === ilvl
45719
+ (el) => el?.name === "w:lvlOverride" && parseOoxmlNumber(el.attributes?.["w:ilvl"]) === ilvl
45636
45720
  );
45637
- const overrideLvl = findChild(override, "w:lvl");
45721
+ const overrideLvl = findOoxmlChild(override, "w:lvl");
45638
45722
  if (overrideLvl) {
45639
45723
  levelDef = overrideLvl;
45640
45724
  }
45641
- const startOverride = parseNumberAttr(getAttribute(findChild(override, "w:startOverride"), "w:val"));
45725
+ const startOverride = parseOoxmlNumber(getOoxmlAttribute(findOoxmlChild(override, "w:startOverride"), "w:val"));
45642
45726
  if (!levelDef) {
45643
45727
  return void 0;
45644
45728
  }
45645
45729
  const numFmtEl = findNumFmtElement(levelDef);
45646
- const lvlText = getAttribute(findChild(levelDef, "w:lvlText"), "w:val");
45647
- const start2 = startOverride ?? parseNumberAttr(getAttribute(findChild(levelDef, "w:start"), "w:val"));
45648
- const suffix2 = normalizeSuffix(getAttribute(findChild(levelDef, "w:suff"), "w:val"));
45649
- const lvlJc = normalizeJustification(getAttribute(findChild(levelDef, "w:lvlJc"), "w:val"));
45730
+ const lvlText = getOoxmlAttribute(findOoxmlChild(levelDef, "w:lvlText"), "w:val");
45731
+ const start2 = startOverride ?? parseOoxmlNumber(getOoxmlAttribute(findOoxmlChild(levelDef, "w:start"), "w:val"));
45732
+ const suffix2 = normalizeSuffix(getOoxmlAttribute(findOoxmlChild(levelDef, "w:suff"), "w:val"));
45733
+ const lvlJc = normalizeJustification(getOoxmlAttribute(findOoxmlChild(levelDef, "w:lvlJc"), "w:val"));
45650
45734
  const indent = extractIndentFromLevel(levelDef);
45651
45735
  const markerRun = extractMarkerRun(levelDef);
45652
- const numFmt = normalizeNumFmt(getAttribute(numFmtEl, "w:val"));
45736
+ const numFmt = normalizeNumFmt(getOoxmlAttribute(numFmtEl, "w:val"));
45653
45737
  return {
45654
45738
  format: numFmt,
45655
45739
  lvlText,
@@ -45742,6 +45826,7 @@ const cloneParagraphAttrs = (attrs) => {
45742
45826
  if (!attrs) return void 0;
45743
45827
  const clone = { ...attrs };
45744
45828
  if (attrs.spacing) clone.spacing = { ...attrs.spacing };
45829
+ if (attrs.spacingExplicit) clone.spacingExplicit = { ...attrs.spacingExplicit };
45745
45830
  if (attrs.indent) clone.indent = { ...attrs.indent };
45746
45831
  if (attrs.borders) {
45747
45832
  const borderClone = {};
@@ -46117,6 +46202,11 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
46117
46202
  const hydrated = hydrationOverride ?? hydrateParagraphStyleAttrs(para, converterContext);
46118
46203
  const mergedSpacing = mergeSpacingSources(hydrated?.spacing, paragraphProps.spacing, attrs.spacing);
46119
46204
  const normalizedSpacing = normalizeParagraphSpacing(mergedSpacing);
46205
+ const spacingExplicit = mergeSpacingExplicit(
46206
+ extractSpacingExplicitFromObject(paragraphProps.spacing),
46207
+ extractSpacingExplicitFromObject(attrs.spacing),
46208
+ extractSpacingExplicitFromOoxml(paragraphProps)
46209
+ );
46120
46210
  const normalizeIndentObject = (value) => {
46121
46211
  if (!value || typeof value !== "object") return;
46122
46212
  return normalizePxIndent(value) ?? convertIndentTwipsToPx(value);
@@ -46251,6 +46341,7 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
46251
46341
  paragraphAttrs.spacing.afterAutospacing = normalizedSpacing.afterAutospacing;
46252
46342
  }
46253
46343
  }
46344
+ paragraphAttrs.spacingExplicit = spacingExplicit;
46254
46345
  const contextualSpacingValue = normalizedSpacing?.contextualSpacing ?? safeGetProperty(paragraphProps, "contextualSpacing") ?? safeGetProperty(attrs, "contextualSpacing") ?? hydrated?.contextualSpacing;
46255
46346
  if (contextualSpacingValue != null) {
46256
46347
  paragraphAttrs.contextualSpacing = isTruthy(contextualSpacingValue);
@@ -47620,7 +47711,10 @@ function fieldAnnotationNodeToRun(node, positions, fieldMetadata) {
47620
47711
  }
47621
47712
  return run;
47622
47713
  }
47623
- const isTextRun = (run) => run.kind !== "tab";
47714
+ const isTextRun = (run) => {
47715
+ const kind = run.kind;
47716
+ return (kind === void 0 || kind === "text") && "text" in run;
47717
+ };
47624
47718
  const dataAttrsCompatible = (a, b2) => {
47625
47719
  const aAttrs = a.dataAttrs;
47626
47720
  const bAttrs = b2.dataAttrs;
@@ -47729,6 +47823,75 @@ const extractFirstTextRunFont = (para) => {
47729
47823
  const font = findFirstTextFont(para.content);
47730
47824
  return font;
47731
47825
  };
47826
+ const resolveRunFontFamily = (fontFamily2, docx) => {
47827
+ if (typeof fontFamily2 === "string" && fontFamily2.trim().length > 0) {
47828
+ return fontFamily2;
47829
+ }
47830
+ if (!fontFamily2 || typeof fontFamily2 !== "object") return void 0;
47831
+ const toCssFontFamily2 = superEditor_converter.SuperConverter.toCssFontFamily;
47832
+ const resolved = superEditor_converter.resolveDocxFontFamily(fontFamily2, docx ?? null, toCssFontFamily2);
47833
+ return resolved ?? void 0;
47834
+ };
47835
+ const parseRunFontSizePx = (fontSize2) => {
47836
+ if (typeof fontSize2 === "number" && Number.isFinite(fontSize2)) {
47837
+ return ptToPx(fontSize2 / HALF_POINTS_PER_POINT) ?? void 0;
47838
+ }
47839
+ if (typeof fontSize2 === "string") {
47840
+ const numeric = Number.parseFloat(fontSize2);
47841
+ if (!Number.isFinite(numeric)) return void 0;
47842
+ if (fontSize2.endsWith("pt")) {
47843
+ return ptToPx(numeric);
47844
+ }
47845
+ if (fontSize2.endsWith("px")) {
47846
+ return numeric;
47847
+ }
47848
+ return ptToPx(numeric / HALF_POINTS_PER_POINT) ?? void 0;
47849
+ }
47850
+ return void 0;
47851
+ };
47852
+ const extractParagraphMarkRunProps = (paragraphProps) => {
47853
+ const directRunProps = paragraphProps.runProperties;
47854
+ const directRunPropsElement = asOoxmlElement(directRunProps);
47855
+ if (directRunProps && isPlainObject$2(directRunProps) && !directRunPropsElement) {
47856
+ return directRunProps;
47857
+ }
47858
+ const element = asOoxmlElement(paragraphProps);
47859
+ const pPr = element ? element.name === "w:pPr" ? element : findOoxmlChild(element, "w:pPr") : void 0;
47860
+ const rPr = directRunPropsElement?.name === "w:rPr" ? directRunPropsElement : findOoxmlChild(pPr, "w:rPr");
47861
+ if (!rPr) return void 0;
47862
+ const runProps = {};
47863
+ const sz = parseOoxmlNumber(getOoxmlAttribute(findOoxmlChild(rPr, "w:sz"), "w:val")) ?? parseOoxmlNumber(getOoxmlAttribute(findOoxmlChild(rPr, "w:szCs"), "w:val"));
47864
+ if (sz != null) {
47865
+ runProps.fontSize = sz;
47866
+ }
47867
+ const rFonts = findOoxmlChild(rPr, "w:rFonts");
47868
+ if (rFonts) {
47869
+ const fontFamily2 = {};
47870
+ const keys2 = ["ascii", "hAnsi", "eastAsia", "cs", "val", "asciiTheme", "hAnsiTheme", "eastAsiaTheme", "cstheme"];
47871
+ for (const key2 of keys2) {
47872
+ const value = getOoxmlAttribute(rFonts, `w:${key2}`);
47873
+ if (value != null) {
47874
+ fontFamily2[key2] = value;
47875
+ }
47876
+ }
47877
+ if (Object.keys(fontFamily2).length > 0) {
47878
+ runProps.fontFamily = fontFamily2;
47879
+ }
47880
+ }
47881
+ return Object.keys(runProps).length > 0 ? runProps : void 0;
47882
+ };
47883
+ const applyParagraphMarkRunProps = (run, paragraphProps, converterContext) => {
47884
+ const runProps = extractParagraphMarkRunProps(paragraphProps);
47885
+ if (!runProps) return;
47886
+ const fontSizePx = parseRunFontSizePx(runProps.fontSize);
47887
+ if (fontSizePx != null) {
47888
+ run.fontSize = fontSizePx;
47889
+ }
47890
+ const fontFamily2 = resolveRunFontFamily(runProps.fontFamily, converterContext?.docx);
47891
+ if (fontFamily2) {
47892
+ run.fontFamily = fontFamily2;
47893
+ }
47894
+ };
47732
47895
  const applyBaseRunDefaults = (run, defaults, uiDisplayFallbackFont, fallbackSize) => {
47733
47896
  if (!run) return;
47734
47897
  if (defaults.fontFamily && run.fontFamily === uiDisplayFallbackFont) {
@@ -47878,6 +48041,8 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
47878
48041
  emptyRun.pmStart = paraPos.start + 1;
47879
48042
  emptyRun.pmEnd = paraPos.start + 1;
47880
48043
  }
48044
+ applyBaseRunDefaults(emptyRun, baseRunDefaults, defaultFont, defaultSize);
48045
+ applyParagraphMarkRunProps(emptyRun, paragraphProps, converterContext);
47881
48046
  let emptyParagraphAttrs = cloneParagraphAttrs(paragraphAttrs);
47882
48047
  if (isSectPrMarker) {
47883
48048
  if (emptyParagraphAttrs) {
@@ -51265,7 +51430,6 @@ function measureText(text, font, ctx2, _fontFamily, _letterSpacing) {
51265
51430
  const paintedWidth = (metrics.actualBoundingBoxLeft || 0) + (metrics.actualBoundingBoxRight || 0);
51266
51431
  return Math.max(advanceWidth, paintedWidth);
51267
51432
  }
51268
- const MIN_SINGLE_LINE_PX = 12 * 96 / 72;
51269
51433
  const WORD_SINGLE_LINE_SPACING_MULTIPLIER = 1.15;
51270
51434
  function calculateTypographyMetrics(fontSize2, spacing, fontInfo) {
51271
51435
  let ascent;
@@ -51279,7 +51443,27 @@ function calculateTypographyMetrics(fontSize2, spacing, fontInfo) {
51279
51443
  ascent = roundValue(fontSize2 * 0.8);
51280
51444
  descent = roundValue(fontSize2 * 0.2);
51281
51445
  }
51282
- const baseLineHeight = Math.max(fontSize2 * WORD_SINGLE_LINE_SPACING_MULTIPLIER, ascent + descent, MIN_SINGLE_LINE_PX);
51446
+ const baseLineHeight = Math.max(fontSize2 * WORD_SINGLE_LINE_SPACING_MULTIPLIER, ascent + descent);
51447
+ const lineHeight2 = roundValue(resolveLineHeight(spacing, baseLineHeight));
51448
+ return {
51449
+ ascent,
51450
+ descent,
51451
+ lineHeight: lineHeight2
51452
+ };
51453
+ }
51454
+ function calculateEmptyParagraphMetrics(fontSize2, spacing, fontInfo) {
51455
+ let ascent;
51456
+ let descent;
51457
+ if (fontInfo) {
51458
+ const ctx2 = getCanvasContext();
51459
+ const metrics = getFontMetrics(ctx2, fontInfo);
51460
+ ascent = roundValue(metrics.ascent);
51461
+ descent = roundValue(metrics.descent);
51462
+ } else {
51463
+ ascent = roundValue(fontSize2 * 0.8);
51464
+ descent = roundValue(fontSize2 * 0.2);
51465
+ }
51466
+ const baseLineHeight = Math.max(fontSize2, ascent + descent);
51283
51467
  const lineHeight2 = roundValue(resolveLineHeight(spacing, baseLineHeight));
51284
51468
  return {
51285
51469
  ascent,
@@ -51310,6 +51494,10 @@ function isImageRun(run) {
51310
51494
  function isLineBreakRun(run) {
51311
51495
  return run.kind === "lineBreak";
51312
51496
  }
51497
+ const isEmptyTextRun = (run) => {
51498
+ if (run.kind && run.kind !== "text") return false;
51499
+ return typeof run.text === "string" && run.text.length === 0;
51500
+ };
51313
51501
  function isFieldAnnotationRun(run) {
51314
51502
  return run.kind === "fieldAnnotation";
51315
51503
  }
@@ -51479,8 +51667,28 @@ async function measureParagraphBlock(block, maxWidth) {
51479
51667
  dropCapDescriptor.measuredHeight = dropCapMeasured.height;
51480
51668
  }
51481
51669
  }
51670
+ const emptyParagraphRun = block.runs.length === 1 && isEmptyTextRun(block.runs[0]) ? block.runs[0] : null;
51671
+ if (emptyParagraphRun) {
51672
+ const fontSize2 = emptyParagraphRun.fontSize ?? 12;
51673
+ const metrics = calculateEmptyParagraphMetrics(fontSize2, spacing, getFontInfoFromRun(emptyParagraphRun));
51674
+ const emptyLine = {
51675
+ fromRun: 0,
51676
+ fromChar: 0,
51677
+ toRun: 0,
51678
+ toChar: 0,
51679
+ width: 0,
51680
+ ...metrics
51681
+ };
51682
+ addBarTabsToLine(emptyLine);
51683
+ lines.push(emptyLine);
51684
+ return {
51685
+ kind: "paragraph",
51686
+ lines,
51687
+ totalHeight: metrics.lineHeight
51688
+ };
51689
+ }
51482
51690
  if (block.runs.length === 0) {
51483
- const metrics = calculateTypographyMetrics(12, spacing);
51691
+ const metrics = calculateEmptyParagraphMetrics(12, spacing);
51484
51692
  const emptyLine = {
51485
51693
  fromRun: 0,
51486
51694
  fromChar: 0,
@@ -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-ChOaRc8I.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-CQtzIJhu.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-menqq4VC.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-ChOaRc8I.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-C16jjGce.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-C16jjGce.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-CQtzIJhu.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-menqq4VC.cjs");
4
+ const superdoc = require("./chunks/index-Brw_Mb9u.cjs");
5
+ const superEditor_converter = require("./chunks/SuperConverter-ChOaRc8I.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-C16jjGce.es.js";
2
+ import { D, H, P, S, c } from "./chunks/index-CWf082Tz.es.js";
3
+ import { S as S2, r } from "./chunks/SuperConverter-CQtzIJhu.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";