@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.
@@ -38197,7 +38197,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
38197
38197
  static getStoredSuperdocVersion(docx) {
38198
38198
  return SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
38199
38199
  }
38200
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.7.0-next.5") {
38200
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.7.0-next.6") {
38201
38201
  return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
38202
38202
  }
38203
38203
  /**
@@ -55474,8 +55474,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
55474
55474
  arr.splice(i2, 1);
55475
55475
  }
55476
55476
  };
55477
- const hasOwnProperty$e = Object.prototype.hasOwnProperty;
55478
- const hasOwn = (val, key2) => hasOwnProperty$e.call(val, key2);
55477
+ const hasOwnProperty$f = Object.prototype.hasOwnProperty;
55478
+ const hasOwn = (val, key2) => hasOwnProperty$f.call(val, key2);
55479
55479
  const isArray$1 = Array.isArray;
55480
55480
  const isMap = (val) => toTypeString(val) === "[object Map]";
55481
55481
  const isSet = (val) => toTypeString(val) === "[object Set]";
@@ -56450,7 +56450,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
56450
56450
  const builtInSymbols = new Set(
56451
56451
  /* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key2) => key2 !== "arguments" && key2 !== "caller").map((key2) => Symbol[key2]).filter(isSymbol$1)
56452
56452
  );
56453
- function hasOwnProperty$d(key2) {
56453
+ function hasOwnProperty$e(key2) {
56454
56454
  if (!isSymbol$1(key2)) key2 = String(key2);
56455
56455
  const obj = toRaw(this);
56456
56456
  track$1(obj, "has", key2);
@@ -56485,7 +56485,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
56485
56485
  return fn;
56486
56486
  }
56487
56487
  if (key2 === "hasOwnProperty") {
56488
- return hasOwnProperty$d;
56488
+ return hasOwnProperty$e;
56489
56489
  }
56490
56490
  }
56491
56491
  const res = Reflect.get(
@@ -64367,7 +64367,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64367
64367
  return false;
64368
64368
  }
64369
64369
  };
64370
- const summaryVersion = "1.7.0-next.5";
64370
+ const summaryVersion = "1.7.0-next.6";
64371
64371
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
64372
64372
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
64373
64373
  function mapAttributes(attrs) {
@@ -67035,7 +67035,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
67035
67035
  * Process collaboration migrations
67036
67036
  */
67037
67037
  processCollaborationMigrations() {
67038
- console.debug("[checkVersionMigrations] Current editor version", "1.7.0-next.5");
67038
+ console.debug("[checkVersionMigrations] Current editor version", "1.7.0-next.6");
67039
67039
  if (!this.options.ydoc) return;
67040
67040
  const metaMap = this.options.ydoc.getMap("meta");
67041
67041
  let docVersion = metaMap.get("version");
@@ -81637,6 +81637,28 @@ ${o}
81637
81637
  next2.pendingOrientation = null;
81638
81638
  return next2;
81639
81639
  }
81640
+ const isTextRun$3 = (run2) => {
81641
+ const runWithKind = run2;
81642
+ return !runWithKind.kind || runWithKind.kind === "text";
81643
+ };
81644
+ const isEmptyTextParagraph = (block) => {
81645
+ const runs2 = block.runs;
81646
+ if (!runs2 || runs2.length === 0) return true;
81647
+ if (runs2.length !== 1) return false;
81648
+ const run2 = runs2[0];
81649
+ if (!isTextRun$3(run2)) return false;
81650
+ return typeof run2.text === "string" && run2.text.length === 0;
81651
+ };
81652
+ const shouldSuppressSpacingForEmpty = (block, side) => {
81653
+ if (!isEmptyTextParagraph(block)) return false;
81654
+ const attrs = block.attrs;
81655
+ const spacingExplicit = attrs?.spacingExplicit;
81656
+ if (!spacingExplicit) return false;
81657
+ if (side === "before") {
81658
+ return !spacingExplicit.before;
81659
+ }
81660
+ return !spacingExplicit.after;
81661
+ };
81640
81662
  function normalizeLines(measure) {
81641
81663
  if (measure.lines.length > 0) {
81642
81664
  return measure.lines;
@@ -81876,11 +81898,17 @@ ${o}
81876
81898
  let fromLine = 0;
81877
81899
  const attrs = getParagraphAttrs(block);
81878
81900
  const spacing = attrs?.spacing ?? {};
81901
+ const spacingExplicit = attrs?.spacingExplicit;
81879
81902
  const styleId = asString(attrs?.styleId);
81880
81903
  const contextualSpacing = asBoolean$1(attrs?.contextualSpacing);
81881
81904
  let spacingBefore = Math.max(0, Number(spacing.before ?? spacing.lineSpaceBefore ?? 0));
81905
+ let spacingAfter = Math.max(0, Number(spacing.after ?? spacing.lineSpaceAfter ?? 0));
81906
+ const emptyTextParagraph = isEmptyTextParagraph(block);
81907
+ if (emptyTextParagraph && spacingExplicit) {
81908
+ if (!spacingExplicit.before) spacingBefore = 0;
81909
+ if (!spacingExplicit.after) spacingAfter = 0;
81910
+ }
81882
81911
  const baseSpacingBefore = spacingBefore;
81883
- const spacingAfter = Math.max(0, Number(spacing.after ?? spacing.lineSpaceAfter ?? 0));
81884
81912
  let appliedSpacingBefore = spacingBefore === 0;
81885
81913
  let lastState = null;
81886
81914
  const isPositionedFrame = frame?.wrap === "none";
@@ -83203,11 +83231,13 @@ ${o}
83203
83231
  function getParagraphSpacingBefore(block) {
83204
83232
  const spacing = block.attrs?.spacing;
83205
83233
  const value = spacing?.before ?? spacing?.lineSpaceBefore;
83234
+ if (shouldSuppressSpacingForEmpty(block, "before")) return 0;
83206
83235
  return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : 0;
83207
83236
  }
83208
83237
  function getParagraphSpacingAfter$1(block) {
83209
83238
  const spacing = block.attrs?.spacing;
83210
83239
  const value = spacing?.after ?? spacing?.lineSpaceAfter;
83240
+ if (shouldSuppressSpacingForEmpty(block, "after")) return 0;
83211
83241
  return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : 0;
83212
83242
  }
83213
83243
  function getMeasureHeight(block, measure) {
@@ -92052,6 +92082,26 @@ ${o}
92052
92082
  return { top: top2, right: right2, bottom: bottom2, left: left2 };
92053
92083
  }
92054
92084
  const OOXML_Z_INDEX_BASE = 251658240;
92085
+ const asOoxmlElement = (value) => {
92086
+ if (!value || typeof value !== "object") return void 0;
92087
+ const element2 = value;
92088
+ if (element2.name == null && element2.attributes == null && element2.elements == null) return void 0;
92089
+ return element2;
92090
+ };
92091
+ const findOoxmlChild = (parent, name) => {
92092
+ return parent?.elements?.find((child) => child?.name === name);
92093
+ };
92094
+ const getOoxmlAttribute = (element2, key2) => {
92095
+ if (!element2?.attributes) return void 0;
92096
+ const attrs = element2.attributes;
92097
+ return attrs[key2] ?? attrs[key2.startsWith("w:") ? key2.slice(2) : `w:${key2}`];
92098
+ };
92099
+ const parseOoxmlNumber = (value) => {
92100
+ if (value == null) return void 0;
92101
+ const num = typeof value === "number" ? value : Number.parseInt(String(value), 10);
92102
+ return Number.isFinite(num) ? num : void 0;
92103
+ };
92104
+ const hasOwnProperty$d = (obj, key2) => Object.prototype.hasOwnProperty.call(obj, key2);
92055
92105
  function normalizeZIndex(originalAttributes) {
92056
92106
  if (!isPlainObject$4(originalAttributes)) return void 0;
92057
92107
  const relativeHeight = originalAttributes.relativeHeight;
@@ -94012,24 +94062,47 @@ ${o}
94012
94062
  const isValidNumberingId = (numId) => {
94013
94063
  return numId != null && numId !== 0 && numId !== "0";
94014
94064
  };
94015
- const asOoxmlElement = (value) => {
94016
- if (!value || typeof value !== "object") return void 0;
94017
- const element2 = value;
94018
- if (element2.name == null && element2.attributes == null && element2.elements == null) return void 0;
94019
- return element2;
94020
- };
94021
- const findChild = (parent, name) => {
94022
- return parent?.elements?.find((child) => child?.name === name);
94065
+ const extractSpacingExplicitFromObject = (value) => {
94066
+ if (!value || typeof value !== "object" || Array.isArray(value)) return {};
94067
+ const obj = value;
94068
+ const explicit = {};
94069
+ if (hasOwnProperty$d(obj, "before") || hasOwnProperty$d(obj, "lineSpaceBefore") || hasOwnProperty$d(obj, "beforeAutospacing") || hasOwnProperty$d(obj, "beforeAutoSpacing")) {
94070
+ explicit.before = true;
94071
+ }
94072
+ if (hasOwnProperty$d(obj, "after") || hasOwnProperty$d(obj, "lineSpaceAfter") || hasOwnProperty$d(obj, "afterAutospacing") || hasOwnProperty$d(obj, "afterAutoSpacing")) {
94073
+ explicit.after = true;
94074
+ }
94075
+ if (hasOwnProperty$d(obj, "line") || hasOwnProperty$d(obj, "lineRule")) {
94076
+ explicit.line = true;
94077
+ }
94078
+ return explicit;
94023
94079
  };
94024
- const getAttribute = (element2, key2) => {
94025
- if (!element2?.attributes) return void 0;
94026
- const attrs = element2.attributes;
94027
- return attrs[key2] ?? attrs[key2.startsWith("w:") ? key2.slice(2) : `w:${key2}`];
94080
+ const extractSpacingExplicitFromOoxml = (value) => {
94081
+ const element2 = asOoxmlElement(value);
94082
+ if (!element2) return {};
94083
+ const pPr = element2.name === "w:pPr" ? element2 : findOoxmlChild(element2, "w:pPr");
94084
+ const spacingEl = findOoxmlChild(pPr, "w:spacing");
94085
+ if (!spacingEl) return {};
94086
+ const explicit = {};
94087
+ if (getOoxmlAttribute(spacingEl, "w:before") != null || getOoxmlAttribute(spacingEl, "w:beforeAutospacing") != null || getOoxmlAttribute(spacingEl, "w:beforeAutoSpacing") != null) {
94088
+ explicit.before = true;
94089
+ }
94090
+ if (getOoxmlAttribute(spacingEl, "w:after") != null || getOoxmlAttribute(spacingEl, "w:afterAutospacing") != null || getOoxmlAttribute(spacingEl, "w:afterAutoSpacing") != null) {
94091
+ explicit.after = true;
94092
+ }
94093
+ if (getOoxmlAttribute(spacingEl, "w:line") != null || getOoxmlAttribute(spacingEl, "w:lineRule") != null) {
94094
+ explicit.line = true;
94095
+ }
94096
+ return explicit;
94028
94097
  };
94029
- const parseNumberAttr = (value) => {
94030
- if (value == null) return void 0;
94031
- const num = typeof value === "number" ? value : Number.parseInt(String(value), 10);
94032
- return Number.isFinite(num) ? num : void 0;
94098
+ const mergeSpacingExplicit = (...sources) => {
94099
+ const merged = {};
94100
+ for (const source of sources) {
94101
+ if (source.before) merged.before = true;
94102
+ if (source.after) merged.after = true;
94103
+ if (source.line) merged.line = true;
94104
+ }
94105
+ return merged;
94033
94106
  };
94034
94107
  const mergeSpacingSources = (base2, paragraphProps, attrs) => {
94035
94108
  const isObject2 = (v2) => v2 !== null && typeof v2 === "object";
@@ -94075,13 +94148,13 @@ ${o}
94075
94148
  return void 0;
94076
94149
  };
94077
94150
  const extractIndentFromLevel = (lvl) => {
94078
- const pPr = findChild(lvl, "w:pPr");
94079
- const ind = findChild(pPr, "w:ind");
94151
+ const pPr = findOoxmlChild(lvl, "w:pPr");
94152
+ const ind = findOoxmlChild(pPr, "w:ind");
94080
94153
  if (!ind) return void 0;
94081
- const left2 = parseNumberAttr(getAttribute(ind, "w:left"));
94082
- const right2 = parseNumberAttr(getAttribute(ind, "w:right"));
94083
- const firstLine = parseNumberAttr(getAttribute(ind, "w:firstLine"));
94084
- const hanging = parseNumberAttr(getAttribute(ind, "w:hanging"));
94154
+ const left2 = parseOoxmlNumber(getOoxmlAttribute(ind, "w:left"));
94155
+ const right2 = parseOoxmlNumber(getOoxmlAttribute(ind, "w:right"));
94156
+ const firstLine = parseOoxmlNumber(getOoxmlAttribute(ind, "w:firstLine"));
94157
+ const hanging = parseOoxmlNumber(getOoxmlAttribute(ind, "w:hanging"));
94085
94158
  const indent2 = {};
94086
94159
  if (left2 != null) indent2.left = left2;
94087
94160
  if (right2 != null) indent2.right = right2;
@@ -94097,31 +94170,31 @@ ${o}
94097
94170
  return `#${upper.toUpperCase()}`;
94098
94171
  };
94099
94172
  const extractMarkerRun = (lvl) => {
94100
- const rPr = findChild(lvl, "w:rPr");
94173
+ const rPr = findOoxmlChild(lvl, "w:rPr");
94101
94174
  if (!rPr) return void 0;
94102
94175
  const run2 = {};
94103
- const rFonts = findChild(rPr, "w:rFonts");
94104
- const font = getAttribute(rFonts, "w:ascii") ?? getAttribute(rFonts, "w:hAnsi") ?? getAttribute(rFonts, "w:eastAsia");
94176
+ const rFonts = findOoxmlChild(rPr, "w:rFonts");
94177
+ const font = getOoxmlAttribute(rFonts, "w:ascii") ?? getOoxmlAttribute(rFonts, "w:hAnsi") ?? getOoxmlAttribute(rFonts, "w:eastAsia");
94105
94178
  if (typeof font === "string" && font.trim()) {
94106
94179
  run2.fontFamily = font;
94107
94180
  }
94108
- const sz = parseNumberAttr(getAttribute(findChild(rPr, "w:sz"), "w:val")) ?? parseNumberAttr(getAttribute(findChild(rPr, "w:szCs"), "w:val"));
94181
+ const sz = parseOoxmlNumber(getOoxmlAttribute(findOoxmlChild(rPr, "w:sz"), "w:val")) ?? parseOoxmlNumber(getOoxmlAttribute(findOoxmlChild(rPr, "w:szCs"), "w:val"));
94109
94182
  if (sz != null) {
94110
94183
  run2.fontSize = sz / 2;
94111
94184
  }
94112
- const color2 = normalizeColor(getAttribute(findChild(rPr, "w:color"), "w:val"));
94185
+ const color2 = normalizeColor(getOoxmlAttribute(findOoxmlChild(rPr, "w:color"), "w:val"));
94113
94186
  if (color2) run2.color = color2;
94114
- const boldEl = findChild(rPr, "w:b");
94187
+ const boldEl = findOoxmlChild(rPr, "w:b");
94115
94188
  if (boldEl) {
94116
- const boldVal = getAttribute(boldEl, "w:val");
94189
+ const boldVal = getOoxmlAttribute(boldEl, "w:val");
94117
94190
  if (boldVal == null || isTruthy(boldVal)) run2.bold = true;
94118
94191
  }
94119
- const italicEl = findChild(rPr, "w:i");
94192
+ const italicEl = findOoxmlChild(rPr, "w:i");
94120
94193
  if (italicEl) {
94121
- const italicVal = getAttribute(italicEl, "w:val");
94194
+ const italicVal = getOoxmlAttribute(italicEl, "w:val");
94122
94195
  if (italicVal == null || isTruthy(italicVal)) run2.italic = true;
94123
94196
  }
94124
- const spacingTwips = parseNumberAttr(getAttribute(findChild(rPr, "w:spacing"), "w:val"));
94197
+ const spacingTwips = parseOoxmlNumber(getOoxmlAttribute(findOoxmlChild(rPr, "w:spacing"), "w:val"));
94125
94198
  if (spacingTwips != null && Number.isFinite(spacingTwips)) {
94126
94199
  run2.letterSpacing = twipsToPx$1(spacingTwips);
94127
94200
  }
@@ -94129,12 +94202,12 @@ ${o}
94129
94202
  };
94130
94203
  const findNumFmtElement = (lvl) => {
94131
94204
  if (!lvl) return void 0;
94132
- const direct = findChild(lvl, "w:numFmt");
94205
+ const direct = findOoxmlChild(lvl, "w:numFmt");
94133
94206
  if (direct) return direct;
94134
- const alternate = findChild(lvl, "mc:AlternateContent");
94135
- const choice = findChild(alternate, "mc:Choice");
94207
+ const alternate = findOoxmlChild(lvl, "mc:AlternateContent");
94208
+ const choice = findOoxmlChild(alternate, "mc:Choice");
94136
94209
  if (choice) {
94137
- return findChild(choice, "w:numFmt");
94210
+ return findOoxmlChild(choice, "w:numFmt");
94138
94211
  }
94139
94212
  return void 0;
94140
94213
  };
@@ -94148,7 +94221,7 @@ ${o}
94148
94221
  if (!numDef) {
94149
94222
  return void 0;
94150
94223
  }
94151
- const abstractId = getAttribute(findChild(numDef, "w:abstractNumId"), "w:val");
94224
+ const abstractId = getOoxmlAttribute(findOoxmlChild(numDef, "w:abstractNumId"), "w:val");
94152
94225
  if (abstractId == null) {
94153
94226
  return void 0;
94154
94227
  }
@@ -94157,27 +94230,27 @@ ${o}
94157
94230
  return void 0;
94158
94231
  }
94159
94232
  let levelDef = abstract.elements?.find(
94160
- (el) => el?.name === "w:lvl" && parseNumberAttr(el.attributes?.["w:ilvl"]) === ilvl
94233
+ (el) => el?.name === "w:lvl" && parseOoxmlNumber(el.attributes?.["w:ilvl"]) === ilvl
94161
94234
  );
94162
94235
  const override = numDef.elements?.find(
94163
- (el) => el?.name === "w:lvlOverride" && parseNumberAttr(el.attributes?.["w:ilvl"]) === ilvl
94236
+ (el) => el?.name === "w:lvlOverride" && parseOoxmlNumber(el.attributes?.["w:ilvl"]) === ilvl
94164
94237
  );
94165
- const overrideLvl = findChild(override, "w:lvl");
94238
+ const overrideLvl = findOoxmlChild(override, "w:lvl");
94166
94239
  if (overrideLvl) {
94167
94240
  levelDef = overrideLvl;
94168
94241
  }
94169
- const startOverride = parseNumberAttr(getAttribute(findChild(override, "w:startOverride"), "w:val"));
94242
+ const startOverride = parseOoxmlNumber(getOoxmlAttribute(findOoxmlChild(override, "w:startOverride"), "w:val"));
94170
94243
  if (!levelDef) {
94171
94244
  return void 0;
94172
94245
  }
94173
94246
  const numFmtEl = findNumFmtElement(levelDef);
94174
- const lvlText = getAttribute(findChild(levelDef, "w:lvlText"), "w:val");
94175
- const start2 = startOverride ?? parseNumberAttr(getAttribute(findChild(levelDef, "w:start"), "w:val"));
94176
- const suffix2 = normalizeSuffix(getAttribute(findChild(levelDef, "w:suff"), "w:val"));
94177
- const lvlJc = normalizeJustification(getAttribute(findChild(levelDef, "w:lvlJc"), "w:val"));
94247
+ const lvlText = getOoxmlAttribute(findOoxmlChild(levelDef, "w:lvlText"), "w:val");
94248
+ const start2 = startOverride ?? parseOoxmlNumber(getOoxmlAttribute(findOoxmlChild(levelDef, "w:start"), "w:val"));
94249
+ const suffix2 = normalizeSuffix(getOoxmlAttribute(findOoxmlChild(levelDef, "w:suff"), "w:val"));
94250
+ const lvlJc = normalizeJustification(getOoxmlAttribute(findOoxmlChild(levelDef, "w:lvlJc"), "w:val"));
94178
94251
  const indent2 = extractIndentFromLevel(levelDef);
94179
94252
  const markerRun = extractMarkerRun(levelDef);
94180
- const numFmt = normalizeNumFmt(getAttribute(numFmtEl, "w:val"));
94253
+ const numFmt = normalizeNumFmt(getOoxmlAttribute(numFmtEl, "w:val"));
94181
94254
  return {
94182
94255
  format: numFmt,
94183
94256
  lvlText,
@@ -94270,6 +94343,7 @@ ${o}
94270
94343
  if (!attrs) return void 0;
94271
94344
  const clone = { ...attrs };
94272
94345
  if (attrs.spacing) clone.spacing = { ...attrs.spacing };
94346
+ if (attrs.spacingExplicit) clone.spacingExplicit = { ...attrs.spacingExplicit };
94273
94347
  if (attrs.indent) clone.indent = { ...attrs.indent };
94274
94348
  if (attrs.borders) {
94275
94349
  const borderClone = {};
@@ -94645,6 +94719,11 @@ ${o}
94645
94719
  const hydrated = hydrationOverride ?? hydrateParagraphStyleAttrs(para, converterContext);
94646
94720
  const mergedSpacing = mergeSpacingSources(hydrated?.spacing, paragraphProps.spacing, attrs.spacing);
94647
94721
  const normalizedSpacing = normalizeParagraphSpacing(mergedSpacing);
94722
+ const spacingExplicit = mergeSpacingExplicit(
94723
+ extractSpacingExplicitFromObject(paragraphProps.spacing),
94724
+ extractSpacingExplicitFromObject(attrs.spacing),
94725
+ extractSpacingExplicitFromOoxml(paragraphProps)
94726
+ );
94648
94727
  const normalizeIndentObject = (value) => {
94649
94728
  if (!value || typeof value !== "object") return;
94650
94729
  return normalizePxIndent(value) ?? convertIndentTwipsToPx(value);
@@ -94779,6 +94858,7 @@ ${o}
94779
94858
  paragraphAttrs.spacing.afterAutospacing = normalizedSpacing.afterAutospacing;
94780
94859
  }
94781
94860
  }
94861
+ paragraphAttrs.spacingExplicit = spacingExplicit;
94782
94862
  const contextualSpacingValue = normalizedSpacing?.contextualSpacing ?? safeGetProperty(paragraphProps, "contextualSpacing") ?? safeGetProperty(attrs, "contextualSpacing") ?? hydrated?.contextualSpacing;
94783
94863
  if (contextualSpacingValue != null) {
94784
94864
  paragraphAttrs.contextualSpacing = isTruthy(contextualSpacingValue);
@@ -96257,6 +96337,75 @@ ${o}
96257
96337
  const font = findFirstTextFont(para.content);
96258
96338
  return font;
96259
96339
  };
96340
+ const resolveRunFontFamily = (fontFamily2, docx) => {
96341
+ if (typeof fontFamily2 === "string" && fontFamily2.trim().length > 0) {
96342
+ return fontFamily2;
96343
+ }
96344
+ if (!fontFamily2 || typeof fontFamily2 !== "object") return void 0;
96345
+ const toCssFontFamily2 = SuperConverter.toCssFontFamily;
96346
+ const resolved = resolveDocxFontFamily(fontFamily2, docx ?? null, toCssFontFamily2);
96347
+ return resolved ?? void 0;
96348
+ };
96349
+ const parseRunFontSizePx = (fontSize2) => {
96350
+ if (typeof fontSize2 === "number" && Number.isFinite(fontSize2)) {
96351
+ return ptToPx(fontSize2 / HALF_POINTS_PER_POINT) ?? void 0;
96352
+ }
96353
+ if (typeof fontSize2 === "string") {
96354
+ const numeric = Number.parseFloat(fontSize2);
96355
+ if (!Number.isFinite(numeric)) return void 0;
96356
+ if (fontSize2.endsWith("pt")) {
96357
+ return ptToPx(numeric);
96358
+ }
96359
+ if (fontSize2.endsWith("px")) {
96360
+ return numeric;
96361
+ }
96362
+ return ptToPx(numeric / HALF_POINTS_PER_POINT) ?? void 0;
96363
+ }
96364
+ return void 0;
96365
+ };
96366
+ const extractParagraphMarkRunProps = (paragraphProps) => {
96367
+ const directRunProps = paragraphProps.runProperties;
96368
+ const directRunPropsElement = asOoxmlElement(directRunProps);
96369
+ if (directRunProps && isPlainObject$4(directRunProps) && !directRunPropsElement) {
96370
+ return directRunProps;
96371
+ }
96372
+ const element2 = asOoxmlElement(paragraphProps);
96373
+ const pPr = element2 ? element2.name === "w:pPr" ? element2 : findOoxmlChild(element2, "w:pPr") : void 0;
96374
+ const rPr = directRunPropsElement?.name === "w:rPr" ? directRunPropsElement : findOoxmlChild(pPr, "w:rPr");
96375
+ if (!rPr) return void 0;
96376
+ const runProps = {};
96377
+ const sz = parseOoxmlNumber(getOoxmlAttribute(findOoxmlChild(rPr, "w:sz"), "w:val")) ?? parseOoxmlNumber(getOoxmlAttribute(findOoxmlChild(rPr, "w:szCs"), "w:val"));
96378
+ if (sz != null) {
96379
+ runProps.fontSize = sz;
96380
+ }
96381
+ const rFonts = findOoxmlChild(rPr, "w:rFonts");
96382
+ if (rFonts) {
96383
+ const fontFamily2 = {};
96384
+ const keys2 = ["ascii", "hAnsi", "eastAsia", "cs", "val", "asciiTheme", "hAnsiTheme", "eastAsiaTheme", "cstheme"];
96385
+ for (const key2 of keys2) {
96386
+ const value = getOoxmlAttribute(rFonts, `w:${key2}`);
96387
+ if (value != null) {
96388
+ fontFamily2[key2] = value;
96389
+ }
96390
+ }
96391
+ if (Object.keys(fontFamily2).length > 0) {
96392
+ runProps.fontFamily = fontFamily2;
96393
+ }
96394
+ }
96395
+ return Object.keys(runProps).length > 0 ? runProps : void 0;
96396
+ };
96397
+ const applyParagraphMarkRunProps = (run2, paragraphProps, converterContext) => {
96398
+ const runProps = extractParagraphMarkRunProps(paragraphProps);
96399
+ if (!runProps) return;
96400
+ const fontSizePx = parseRunFontSizePx(runProps.fontSize);
96401
+ if (fontSizePx != null) {
96402
+ run2.fontSize = fontSizePx;
96403
+ }
96404
+ const fontFamily2 = resolveRunFontFamily(runProps.fontFamily, converterContext?.docx);
96405
+ if (fontFamily2) {
96406
+ run2.fontFamily = fontFamily2;
96407
+ }
96408
+ };
96260
96409
  const applyBaseRunDefaults = (run2, defaults2, uiDisplayFallbackFont, fallbackSize) => {
96261
96410
  if (!run2) return;
96262
96411
  if (defaults2.fontFamily && run2.fontFamily === uiDisplayFallbackFont) {
@@ -96406,6 +96555,8 @@ ${o}
96406
96555
  emptyRun.pmStart = paraPos.start + 1;
96407
96556
  emptyRun.pmEnd = paraPos.start + 1;
96408
96557
  }
96558
+ applyBaseRunDefaults(emptyRun, baseRunDefaults, defaultFont, defaultSize);
96559
+ applyParagraphMarkRunProps(emptyRun, paragraphProps, converterContext);
96409
96560
  let emptyParagraphAttrs = cloneParagraphAttrs(paragraphAttrs);
96410
96561
  if (isSectPrMarker) {
96411
96562
  if (emptyParagraphAttrs) {
@@ -99793,7 +99944,6 @@ ${o}
99793
99944
  const paintedWidth = (metrics.actualBoundingBoxLeft || 0) + (metrics.actualBoundingBoxRight || 0);
99794
99945
  return Math.max(advanceWidth, paintedWidth);
99795
99946
  }
99796
- const MIN_SINGLE_LINE_PX = 12 * 96 / 72;
99797
99947
  const WORD_SINGLE_LINE_SPACING_MULTIPLIER = 1.15;
99798
99948
  function calculateTypographyMetrics(fontSize2, spacing, fontInfo) {
99799
99949
  let ascent;
@@ -99807,7 +99957,27 @@ ${o}
99807
99957
  ascent = roundValue(fontSize2 * 0.8);
99808
99958
  descent = roundValue(fontSize2 * 0.2);
99809
99959
  }
99810
- const baseLineHeight = Math.max(fontSize2 * WORD_SINGLE_LINE_SPACING_MULTIPLIER, ascent + descent, MIN_SINGLE_LINE_PX);
99960
+ const baseLineHeight = Math.max(fontSize2 * WORD_SINGLE_LINE_SPACING_MULTIPLIER, ascent + descent);
99961
+ const lineHeight2 = roundValue(resolveLineHeight(spacing, baseLineHeight));
99962
+ return {
99963
+ ascent,
99964
+ descent,
99965
+ lineHeight: lineHeight2
99966
+ };
99967
+ }
99968
+ function calculateEmptyParagraphMetrics(fontSize2, spacing, fontInfo) {
99969
+ let ascent;
99970
+ let descent;
99971
+ if (fontInfo) {
99972
+ const ctx2 = getCanvasContext();
99973
+ const metrics = getFontMetrics(ctx2, fontInfo);
99974
+ ascent = roundValue(metrics.ascent);
99975
+ descent = roundValue(metrics.descent);
99976
+ } else {
99977
+ ascent = roundValue(fontSize2 * 0.8);
99978
+ descent = roundValue(fontSize2 * 0.2);
99979
+ }
99980
+ const baseLineHeight = Math.max(fontSize2, ascent + descent);
99811
99981
  const lineHeight2 = roundValue(resolveLineHeight(spacing, baseLineHeight));
99812
99982
  return {
99813
99983
  ascent,
@@ -99838,6 +100008,10 @@ ${o}
99838
100008
  function isLineBreakRun(run2) {
99839
100009
  return run2.kind === "lineBreak";
99840
100010
  }
100011
+ const isEmptyTextRun = (run2) => {
100012
+ if (run2.kind && run2.kind !== "text") return false;
100013
+ return typeof run2.text === "string" && run2.text.length === 0;
100014
+ };
99841
100015
  function isFieldAnnotationRun(run2) {
99842
100016
  return run2.kind === "fieldAnnotation";
99843
100017
  }
@@ -100007,8 +100181,28 @@ ${o}
100007
100181
  dropCapDescriptor.measuredHeight = dropCapMeasured.height;
100008
100182
  }
100009
100183
  }
100184
+ const emptyParagraphRun = block.runs.length === 1 && isEmptyTextRun(block.runs[0]) ? block.runs[0] : null;
100185
+ if (emptyParagraphRun) {
100186
+ const fontSize2 = emptyParagraphRun.fontSize ?? 12;
100187
+ const metrics = calculateEmptyParagraphMetrics(fontSize2, spacing, getFontInfoFromRun(emptyParagraphRun));
100188
+ const emptyLine = {
100189
+ fromRun: 0,
100190
+ fromChar: 0,
100191
+ toRun: 0,
100192
+ toChar: 0,
100193
+ width: 0,
100194
+ ...metrics
100195
+ };
100196
+ addBarTabsToLine(emptyLine);
100197
+ lines.push(emptyLine);
100198
+ return {
100199
+ kind: "paragraph",
100200
+ lines,
100201
+ totalHeight: metrics.lineHeight
100202
+ };
100203
+ }
100010
100204
  if (block.runs.length === 0) {
100011
- const metrics = calculateTypographyMetrics(12, spacing);
100205
+ const metrics = calculateEmptyParagraphMetrics(12, spacing);
100012
100206
  const emptyLine = {
100013
100207
  fromRun: 0,
100014
100208
  fromChar: 0,
@@ -150967,7 +151161,7 @@ ${reason}`);
150967
151161
  this.config.colors = shuffleArray(this.config.colors);
150968
151162
  this.userColorMap = /* @__PURE__ */ new Map();
150969
151163
  this.colorIndex = 0;
150970
- this.version = "1.7.0-next.5";
151164
+ this.version = "1.7.0-next.6";
150971
151165
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
150972
151166
  this.superdocId = config2.superdocId || v4();
150973
151167
  this.colors = this.config.colors;