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.
@@ -24496,6 +24496,26 @@
24496
24496
  }
24497
24497
  const fldCharEl = node2.elements?.find((el) => el.name === "w:fldChar");
24498
24498
  const fldType = fldCharEl?.attributes?.["w:fldCharType"];
24499
+ if (node2.name === "w:fldSimple") {
24500
+ const instrAttr = node2.attributes?.["w:instr"] || "";
24501
+ const fieldType = instrAttr.trim().split(/\s+/)[0];
24502
+ if (fieldType === "PAGE" || fieldType === "NUMPAGES") {
24503
+ const preprocessor = fieldType === "PAGE" ? preProcessPageInstruction : preProcessNumPagesInstruction;
24504
+ const contentNodes = node2.elements || [];
24505
+ let fieldRunRPr = null;
24506
+ for (const child of contentNodes) {
24507
+ const rPr = child.elements?.find((el) => el.name === "w:rPr");
24508
+ if (rPr) {
24509
+ fieldRunRPr = rPr;
24510
+ break;
24511
+ }
24512
+ }
24513
+ const processedField = preprocessor(contentNodes, instrAttr.trim(), fieldRunRPr);
24514
+ processedNodes.push(...processedField);
24515
+ i2++;
24516
+ continue;
24517
+ }
24518
+ }
24499
24519
  if (fldType === "begin") {
24500
24520
  const fieldInfo = scanFieldSequence(nodes, i2);
24501
24521
  if (fieldInfo && (fieldInfo.fieldType === "PAGE" || fieldInfo.fieldType === "NUMPAGES")) {
@@ -38197,7 +38217,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
38197
38217
  static getStoredSuperdocVersion(docx) {
38198
38218
  return SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
38199
38219
  }
38200
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.7.0-next.5") {
38220
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.7.0-next.7") {
38201
38221
  return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
38202
38222
  }
38203
38223
  /**
@@ -55474,8 +55494,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
55474
55494
  arr.splice(i2, 1);
55475
55495
  }
55476
55496
  };
55477
- const hasOwnProperty$e = Object.prototype.hasOwnProperty;
55478
- const hasOwn = (val, key2) => hasOwnProperty$e.call(val, key2);
55497
+ const hasOwnProperty$f = Object.prototype.hasOwnProperty;
55498
+ const hasOwn = (val, key2) => hasOwnProperty$f.call(val, key2);
55479
55499
  const isArray$1 = Array.isArray;
55480
55500
  const isMap = (val) => toTypeString(val) === "[object Map]";
55481
55501
  const isSet = (val) => toTypeString(val) === "[object Set]";
@@ -56450,7 +56470,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
56450
56470
  const builtInSymbols = new Set(
56451
56471
  /* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key2) => key2 !== "arguments" && key2 !== "caller").map((key2) => Symbol[key2]).filter(isSymbol$1)
56452
56472
  );
56453
- function hasOwnProperty$d(key2) {
56473
+ function hasOwnProperty$e(key2) {
56454
56474
  if (!isSymbol$1(key2)) key2 = String(key2);
56455
56475
  const obj = toRaw(this);
56456
56476
  track$1(obj, "has", key2);
@@ -56485,7 +56505,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
56485
56505
  return fn;
56486
56506
  }
56487
56507
  if (key2 === "hasOwnProperty") {
56488
- return hasOwnProperty$d;
56508
+ return hasOwnProperty$e;
56489
56509
  }
56490
56510
  }
56491
56511
  const res = Reflect.get(
@@ -64367,7 +64387,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64367
64387
  return false;
64368
64388
  }
64369
64389
  };
64370
- const summaryVersion = "1.7.0-next.5";
64390
+ const summaryVersion = "1.7.0-next.7";
64371
64391
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
64372
64392
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
64373
64393
  function mapAttributes(attrs) {
@@ -67035,7 +67055,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
67035
67055
  * Process collaboration migrations
67036
67056
  */
67037
67057
  processCollaborationMigrations() {
67038
- console.debug("[checkVersionMigrations] Current editor version", "1.7.0-next.5");
67058
+ console.debug("[checkVersionMigrations] Current editor version", "1.7.0-next.7");
67039
67059
  if (!this.options.ydoc) return;
67040
67060
  const metaMap = this.options.ydoc.getMap("meta");
67041
67061
  let docVersion = metaMap.get("version");
@@ -81637,6 +81657,28 @@ ${o}
81637
81657
  next2.pendingOrientation = null;
81638
81658
  return next2;
81639
81659
  }
81660
+ const isTextRun$3 = (run2) => {
81661
+ const runWithKind = run2;
81662
+ return !runWithKind.kind || runWithKind.kind === "text";
81663
+ };
81664
+ const isEmptyTextParagraph = (block) => {
81665
+ const runs2 = block.runs;
81666
+ if (!runs2 || runs2.length === 0) return true;
81667
+ if (runs2.length !== 1) return false;
81668
+ const run2 = runs2[0];
81669
+ if (!isTextRun$3(run2)) return false;
81670
+ return typeof run2.text === "string" && run2.text.length === 0;
81671
+ };
81672
+ const shouldSuppressSpacingForEmpty = (block, side) => {
81673
+ if (!isEmptyTextParagraph(block)) return false;
81674
+ const attrs = block.attrs;
81675
+ const spacingExplicit = attrs?.spacingExplicit;
81676
+ if (!spacingExplicit) return false;
81677
+ if (side === "before") {
81678
+ return !spacingExplicit.before;
81679
+ }
81680
+ return !spacingExplicit.after;
81681
+ };
81640
81682
  function normalizeLines(measure) {
81641
81683
  if (measure.lines.length > 0) {
81642
81684
  return measure.lines;
@@ -81876,11 +81918,17 @@ ${o}
81876
81918
  let fromLine = 0;
81877
81919
  const attrs = getParagraphAttrs(block);
81878
81920
  const spacing = attrs?.spacing ?? {};
81921
+ const spacingExplicit = attrs?.spacingExplicit;
81879
81922
  const styleId = asString(attrs?.styleId);
81880
81923
  const contextualSpacing = asBoolean$1(attrs?.contextualSpacing);
81881
81924
  let spacingBefore = Math.max(0, Number(spacing.before ?? spacing.lineSpaceBefore ?? 0));
81925
+ let spacingAfter = Math.max(0, Number(spacing.after ?? spacing.lineSpaceAfter ?? 0));
81926
+ const emptyTextParagraph = isEmptyTextParagraph(block);
81927
+ if (emptyTextParagraph && spacingExplicit) {
81928
+ if (!spacingExplicit.before) spacingBefore = 0;
81929
+ if (!spacingExplicit.after) spacingAfter = 0;
81930
+ }
81882
81931
  const baseSpacingBefore = spacingBefore;
81883
- const spacingAfter = Math.max(0, Number(spacing.after ?? spacing.lineSpaceAfter ?? 0));
81884
81932
  let appliedSpacingBefore = spacingBefore === 0;
81885
81933
  let lastState = null;
81886
81934
  const isPositionedFrame = frame?.wrap === "none";
@@ -83203,11 +83251,13 @@ ${o}
83203
83251
  function getParagraphSpacingBefore(block) {
83204
83252
  const spacing = block.attrs?.spacing;
83205
83253
  const value = spacing?.before ?? spacing?.lineSpaceBefore;
83254
+ if (shouldSuppressSpacingForEmpty(block, "before")) return 0;
83206
83255
  return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : 0;
83207
83256
  }
83208
83257
  function getParagraphSpacingAfter$1(block) {
83209
83258
  const spacing = block.attrs?.spacing;
83210
83259
  const value = spacing?.after ?? spacing?.lineSpaceAfter;
83260
+ if (shouldSuppressSpacingForEmpty(block, "after")) return 0;
83211
83261
  return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : 0;
83212
83262
  }
83213
83263
  function getMeasureHeight(block, measure) {
@@ -90913,18 +90963,29 @@ ${o}
90913
90963
  const fieldId = event.data.fieldId;
90914
90964
  if (fieldId) {
90915
90965
  const targetPos = event.pmPosition;
90966
+ const pmStart = event.data.pmStart;
90916
90967
  let sourceStart = null;
90917
90968
  let sourceEnd = null;
90918
90969
  let sourceNode = null;
90919
- state.doc.descendants((node2, pos) => {
90920
- if (node2.type.name === "fieldAnnotation" && node2.attrs.fieldId === fieldId) {
90921
- sourceStart = pos;
90922
- sourceEnd = pos + node2.nodeSize;
90923
- sourceNode = node2;
90924
- return false;
90925
- }
90926
- return true;
90927
- });
90970
+ if (pmStart != null) {
90971
+ const nodeAt = state.doc.nodeAt(pmStart);
90972
+ if (nodeAt?.type?.name === "fieldAnnotation") {
90973
+ sourceStart = pmStart;
90974
+ sourceEnd = pmStart + nodeAt.nodeSize;
90975
+ sourceNode = nodeAt;
90976
+ }
90977
+ }
90978
+ if (sourceStart == null || sourceEnd == null || !sourceNode) {
90979
+ state.doc.descendants((node2, pos) => {
90980
+ if (node2.type.name === "fieldAnnotation" && node2.attrs.fieldId === fieldId) {
90981
+ sourceStart = pos;
90982
+ sourceEnd = pos + node2.nodeSize;
90983
+ sourceNode = node2;
90984
+ return false;
90985
+ }
90986
+ return true;
90987
+ });
90988
+ }
90928
90989
  if (sourceStart === null || sourceEnd === null || !sourceNode) {
90929
90990
  return;
90930
90991
  }
@@ -92052,6 +92113,26 @@ ${o}
92052
92113
  return { top: top2, right: right2, bottom: bottom2, left: left2 };
92053
92114
  }
92054
92115
  const OOXML_Z_INDEX_BASE = 251658240;
92116
+ const asOoxmlElement = (value) => {
92117
+ if (!value || typeof value !== "object") return void 0;
92118
+ const element2 = value;
92119
+ if (element2.name == null && element2.attributes == null && element2.elements == null) return void 0;
92120
+ return element2;
92121
+ };
92122
+ const findOoxmlChild = (parent, name) => {
92123
+ return parent?.elements?.find((child) => child?.name === name);
92124
+ };
92125
+ const getOoxmlAttribute = (element2, key2) => {
92126
+ if (!element2?.attributes) return void 0;
92127
+ const attrs = element2.attributes;
92128
+ return attrs[key2] ?? attrs[key2.startsWith("w:") ? key2.slice(2) : `w:${key2}`];
92129
+ };
92130
+ const parseOoxmlNumber = (value) => {
92131
+ if (value == null) return void 0;
92132
+ const num = typeof value === "number" ? value : Number.parseInt(String(value), 10);
92133
+ return Number.isFinite(num) ? num : void 0;
92134
+ };
92135
+ const hasOwnProperty$d = (obj, key2) => Object.prototype.hasOwnProperty.call(obj, key2);
92055
92136
  function normalizeZIndex(originalAttributes) {
92056
92137
  if (!isPlainObject$4(originalAttributes)) return void 0;
92057
92138
  const relativeHeight = originalAttributes.relativeHeight;
@@ -94012,24 +94093,47 @@ ${o}
94012
94093
  const isValidNumberingId = (numId) => {
94013
94094
  return numId != null && numId !== 0 && numId !== "0";
94014
94095
  };
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);
94096
+ const extractSpacingExplicitFromObject = (value) => {
94097
+ if (!value || typeof value !== "object" || Array.isArray(value)) return {};
94098
+ const obj = value;
94099
+ const explicit = {};
94100
+ if (hasOwnProperty$d(obj, "before") || hasOwnProperty$d(obj, "lineSpaceBefore") || hasOwnProperty$d(obj, "beforeAutospacing") || hasOwnProperty$d(obj, "beforeAutoSpacing")) {
94101
+ explicit.before = true;
94102
+ }
94103
+ if (hasOwnProperty$d(obj, "after") || hasOwnProperty$d(obj, "lineSpaceAfter") || hasOwnProperty$d(obj, "afterAutospacing") || hasOwnProperty$d(obj, "afterAutoSpacing")) {
94104
+ explicit.after = true;
94105
+ }
94106
+ if (hasOwnProperty$d(obj, "line") || hasOwnProperty$d(obj, "lineRule")) {
94107
+ explicit.line = true;
94108
+ }
94109
+ return explicit;
94023
94110
  };
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}`];
94111
+ const extractSpacingExplicitFromOoxml = (value) => {
94112
+ const element2 = asOoxmlElement(value);
94113
+ if (!element2) return {};
94114
+ const pPr = element2.name === "w:pPr" ? element2 : findOoxmlChild(element2, "w:pPr");
94115
+ const spacingEl = findOoxmlChild(pPr, "w:spacing");
94116
+ if (!spacingEl) return {};
94117
+ const explicit = {};
94118
+ if (getOoxmlAttribute(spacingEl, "w:before") != null || getOoxmlAttribute(spacingEl, "w:beforeAutospacing") != null || getOoxmlAttribute(spacingEl, "w:beforeAutoSpacing") != null) {
94119
+ explicit.before = true;
94120
+ }
94121
+ if (getOoxmlAttribute(spacingEl, "w:after") != null || getOoxmlAttribute(spacingEl, "w:afterAutospacing") != null || getOoxmlAttribute(spacingEl, "w:afterAutoSpacing") != null) {
94122
+ explicit.after = true;
94123
+ }
94124
+ if (getOoxmlAttribute(spacingEl, "w:line") != null || getOoxmlAttribute(spacingEl, "w:lineRule") != null) {
94125
+ explicit.line = true;
94126
+ }
94127
+ return explicit;
94028
94128
  };
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;
94129
+ const mergeSpacingExplicit = (...sources) => {
94130
+ const merged = {};
94131
+ for (const source of sources) {
94132
+ if (source.before) merged.before = true;
94133
+ if (source.after) merged.after = true;
94134
+ if (source.line) merged.line = true;
94135
+ }
94136
+ return merged;
94033
94137
  };
94034
94138
  const mergeSpacingSources = (base2, paragraphProps, attrs) => {
94035
94139
  const isObject2 = (v2) => v2 !== null && typeof v2 === "object";
@@ -94075,13 +94179,13 @@ ${o}
94075
94179
  return void 0;
94076
94180
  };
94077
94181
  const extractIndentFromLevel = (lvl) => {
94078
- const pPr = findChild(lvl, "w:pPr");
94079
- const ind = findChild(pPr, "w:ind");
94182
+ const pPr = findOoxmlChild(lvl, "w:pPr");
94183
+ const ind = findOoxmlChild(pPr, "w:ind");
94080
94184
  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"));
94185
+ const left2 = parseOoxmlNumber(getOoxmlAttribute(ind, "w:left"));
94186
+ const right2 = parseOoxmlNumber(getOoxmlAttribute(ind, "w:right"));
94187
+ const firstLine = parseOoxmlNumber(getOoxmlAttribute(ind, "w:firstLine"));
94188
+ const hanging = parseOoxmlNumber(getOoxmlAttribute(ind, "w:hanging"));
94085
94189
  const indent2 = {};
94086
94190
  if (left2 != null) indent2.left = left2;
94087
94191
  if (right2 != null) indent2.right = right2;
@@ -94097,31 +94201,31 @@ ${o}
94097
94201
  return `#${upper.toUpperCase()}`;
94098
94202
  };
94099
94203
  const extractMarkerRun = (lvl) => {
94100
- const rPr = findChild(lvl, "w:rPr");
94204
+ const rPr = findOoxmlChild(lvl, "w:rPr");
94101
94205
  if (!rPr) return void 0;
94102
94206
  const run2 = {};
94103
- const rFonts = findChild(rPr, "w:rFonts");
94104
- const font = getAttribute(rFonts, "w:ascii") ?? getAttribute(rFonts, "w:hAnsi") ?? getAttribute(rFonts, "w:eastAsia");
94207
+ const rFonts = findOoxmlChild(rPr, "w:rFonts");
94208
+ const font = getOoxmlAttribute(rFonts, "w:ascii") ?? getOoxmlAttribute(rFonts, "w:hAnsi") ?? getOoxmlAttribute(rFonts, "w:eastAsia");
94105
94209
  if (typeof font === "string" && font.trim()) {
94106
94210
  run2.fontFamily = font;
94107
94211
  }
94108
- const sz = parseNumberAttr(getAttribute(findChild(rPr, "w:sz"), "w:val")) ?? parseNumberAttr(getAttribute(findChild(rPr, "w:szCs"), "w:val"));
94212
+ const sz = parseOoxmlNumber(getOoxmlAttribute(findOoxmlChild(rPr, "w:sz"), "w:val")) ?? parseOoxmlNumber(getOoxmlAttribute(findOoxmlChild(rPr, "w:szCs"), "w:val"));
94109
94213
  if (sz != null) {
94110
94214
  run2.fontSize = sz / 2;
94111
94215
  }
94112
- const color2 = normalizeColor(getAttribute(findChild(rPr, "w:color"), "w:val"));
94216
+ const color2 = normalizeColor(getOoxmlAttribute(findOoxmlChild(rPr, "w:color"), "w:val"));
94113
94217
  if (color2) run2.color = color2;
94114
- const boldEl = findChild(rPr, "w:b");
94218
+ const boldEl = findOoxmlChild(rPr, "w:b");
94115
94219
  if (boldEl) {
94116
- const boldVal = getAttribute(boldEl, "w:val");
94220
+ const boldVal = getOoxmlAttribute(boldEl, "w:val");
94117
94221
  if (boldVal == null || isTruthy(boldVal)) run2.bold = true;
94118
94222
  }
94119
- const italicEl = findChild(rPr, "w:i");
94223
+ const italicEl = findOoxmlChild(rPr, "w:i");
94120
94224
  if (italicEl) {
94121
- const italicVal = getAttribute(italicEl, "w:val");
94225
+ const italicVal = getOoxmlAttribute(italicEl, "w:val");
94122
94226
  if (italicVal == null || isTruthy(italicVal)) run2.italic = true;
94123
94227
  }
94124
- const spacingTwips = parseNumberAttr(getAttribute(findChild(rPr, "w:spacing"), "w:val"));
94228
+ const spacingTwips = parseOoxmlNumber(getOoxmlAttribute(findOoxmlChild(rPr, "w:spacing"), "w:val"));
94125
94229
  if (spacingTwips != null && Number.isFinite(spacingTwips)) {
94126
94230
  run2.letterSpacing = twipsToPx$1(spacingTwips);
94127
94231
  }
@@ -94129,12 +94233,12 @@ ${o}
94129
94233
  };
94130
94234
  const findNumFmtElement = (lvl) => {
94131
94235
  if (!lvl) return void 0;
94132
- const direct = findChild(lvl, "w:numFmt");
94236
+ const direct = findOoxmlChild(lvl, "w:numFmt");
94133
94237
  if (direct) return direct;
94134
- const alternate = findChild(lvl, "mc:AlternateContent");
94135
- const choice = findChild(alternate, "mc:Choice");
94238
+ const alternate = findOoxmlChild(lvl, "mc:AlternateContent");
94239
+ const choice = findOoxmlChild(alternate, "mc:Choice");
94136
94240
  if (choice) {
94137
- return findChild(choice, "w:numFmt");
94241
+ return findOoxmlChild(choice, "w:numFmt");
94138
94242
  }
94139
94243
  return void 0;
94140
94244
  };
@@ -94148,7 +94252,7 @@ ${o}
94148
94252
  if (!numDef) {
94149
94253
  return void 0;
94150
94254
  }
94151
- const abstractId = getAttribute(findChild(numDef, "w:abstractNumId"), "w:val");
94255
+ const abstractId = getOoxmlAttribute(findOoxmlChild(numDef, "w:abstractNumId"), "w:val");
94152
94256
  if (abstractId == null) {
94153
94257
  return void 0;
94154
94258
  }
@@ -94157,27 +94261,27 @@ ${o}
94157
94261
  return void 0;
94158
94262
  }
94159
94263
  let levelDef = abstract.elements?.find(
94160
- (el) => el?.name === "w:lvl" && parseNumberAttr(el.attributes?.["w:ilvl"]) === ilvl
94264
+ (el) => el?.name === "w:lvl" && parseOoxmlNumber(el.attributes?.["w:ilvl"]) === ilvl
94161
94265
  );
94162
94266
  const override = numDef.elements?.find(
94163
- (el) => el?.name === "w:lvlOverride" && parseNumberAttr(el.attributes?.["w:ilvl"]) === ilvl
94267
+ (el) => el?.name === "w:lvlOverride" && parseOoxmlNumber(el.attributes?.["w:ilvl"]) === ilvl
94164
94268
  );
94165
- const overrideLvl = findChild(override, "w:lvl");
94269
+ const overrideLvl = findOoxmlChild(override, "w:lvl");
94166
94270
  if (overrideLvl) {
94167
94271
  levelDef = overrideLvl;
94168
94272
  }
94169
- const startOverride = parseNumberAttr(getAttribute(findChild(override, "w:startOverride"), "w:val"));
94273
+ const startOverride = parseOoxmlNumber(getOoxmlAttribute(findOoxmlChild(override, "w:startOverride"), "w:val"));
94170
94274
  if (!levelDef) {
94171
94275
  return void 0;
94172
94276
  }
94173
94277
  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"));
94278
+ const lvlText = getOoxmlAttribute(findOoxmlChild(levelDef, "w:lvlText"), "w:val");
94279
+ const start2 = startOverride ?? parseOoxmlNumber(getOoxmlAttribute(findOoxmlChild(levelDef, "w:start"), "w:val"));
94280
+ const suffix2 = normalizeSuffix(getOoxmlAttribute(findOoxmlChild(levelDef, "w:suff"), "w:val"));
94281
+ const lvlJc = normalizeJustification(getOoxmlAttribute(findOoxmlChild(levelDef, "w:lvlJc"), "w:val"));
94178
94282
  const indent2 = extractIndentFromLevel(levelDef);
94179
94283
  const markerRun = extractMarkerRun(levelDef);
94180
- const numFmt = normalizeNumFmt(getAttribute(numFmtEl, "w:val"));
94284
+ const numFmt = normalizeNumFmt(getOoxmlAttribute(numFmtEl, "w:val"));
94181
94285
  return {
94182
94286
  format: numFmt,
94183
94287
  lvlText,
@@ -94270,6 +94374,7 @@ ${o}
94270
94374
  if (!attrs) return void 0;
94271
94375
  const clone = { ...attrs };
94272
94376
  if (attrs.spacing) clone.spacing = { ...attrs.spacing };
94377
+ if (attrs.spacingExplicit) clone.spacingExplicit = { ...attrs.spacingExplicit };
94273
94378
  if (attrs.indent) clone.indent = { ...attrs.indent };
94274
94379
  if (attrs.borders) {
94275
94380
  const borderClone = {};
@@ -94645,6 +94750,11 @@ ${o}
94645
94750
  const hydrated = hydrationOverride ?? hydrateParagraphStyleAttrs(para, converterContext);
94646
94751
  const mergedSpacing = mergeSpacingSources(hydrated?.spacing, paragraphProps.spacing, attrs.spacing);
94647
94752
  const normalizedSpacing = normalizeParagraphSpacing(mergedSpacing);
94753
+ const spacingExplicit = mergeSpacingExplicit(
94754
+ extractSpacingExplicitFromObject(paragraphProps.spacing),
94755
+ extractSpacingExplicitFromObject(attrs.spacing),
94756
+ extractSpacingExplicitFromOoxml(paragraphProps)
94757
+ );
94648
94758
  const normalizeIndentObject = (value) => {
94649
94759
  if (!value || typeof value !== "object") return;
94650
94760
  return normalizePxIndent(value) ?? convertIndentTwipsToPx(value);
@@ -94779,6 +94889,7 @@ ${o}
94779
94889
  paragraphAttrs.spacing.afterAutospacing = normalizedSpacing.afterAutospacing;
94780
94890
  }
94781
94891
  }
94892
+ paragraphAttrs.spacingExplicit = spacingExplicit;
94782
94893
  const contextualSpacingValue = normalizedSpacing?.contextualSpacing ?? safeGetProperty(paragraphProps, "contextualSpacing") ?? safeGetProperty(attrs, "contextualSpacing") ?? hydrated?.contextualSpacing;
94783
94894
  if (contextualSpacingValue != null) {
94784
94895
  paragraphAttrs.contextualSpacing = isTruthy(contextualSpacingValue);
@@ -96148,7 +96259,10 @@ ${o}
96148
96259
  }
96149
96260
  return run2;
96150
96261
  }
96151
- const isTextRun = (run2) => run2.kind !== "tab";
96262
+ const isTextRun = (run2) => {
96263
+ const kind = run2.kind;
96264
+ return (kind === void 0 || kind === "text") && "text" in run2;
96265
+ };
96152
96266
  const dataAttrsCompatible = (a2, b2) => {
96153
96267
  const aAttrs = a2.dataAttrs;
96154
96268
  const bAttrs = b2.dataAttrs;
@@ -96257,6 +96371,75 @@ ${o}
96257
96371
  const font = findFirstTextFont(para.content);
96258
96372
  return font;
96259
96373
  };
96374
+ const resolveRunFontFamily = (fontFamily2, docx) => {
96375
+ if (typeof fontFamily2 === "string" && fontFamily2.trim().length > 0) {
96376
+ return fontFamily2;
96377
+ }
96378
+ if (!fontFamily2 || typeof fontFamily2 !== "object") return void 0;
96379
+ const toCssFontFamily2 = SuperConverter.toCssFontFamily;
96380
+ const resolved = resolveDocxFontFamily(fontFamily2, docx ?? null, toCssFontFamily2);
96381
+ return resolved ?? void 0;
96382
+ };
96383
+ const parseRunFontSizePx = (fontSize2) => {
96384
+ if (typeof fontSize2 === "number" && Number.isFinite(fontSize2)) {
96385
+ return ptToPx(fontSize2 / HALF_POINTS_PER_POINT) ?? void 0;
96386
+ }
96387
+ if (typeof fontSize2 === "string") {
96388
+ const numeric = Number.parseFloat(fontSize2);
96389
+ if (!Number.isFinite(numeric)) return void 0;
96390
+ if (fontSize2.endsWith("pt")) {
96391
+ return ptToPx(numeric);
96392
+ }
96393
+ if (fontSize2.endsWith("px")) {
96394
+ return numeric;
96395
+ }
96396
+ return ptToPx(numeric / HALF_POINTS_PER_POINT) ?? void 0;
96397
+ }
96398
+ return void 0;
96399
+ };
96400
+ const extractParagraphMarkRunProps = (paragraphProps) => {
96401
+ const directRunProps = paragraphProps.runProperties;
96402
+ const directRunPropsElement = asOoxmlElement(directRunProps);
96403
+ if (directRunProps && isPlainObject$4(directRunProps) && !directRunPropsElement) {
96404
+ return directRunProps;
96405
+ }
96406
+ const element2 = asOoxmlElement(paragraphProps);
96407
+ const pPr = element2 ? element2.name === "w:pPr" ? element2 : findOoxmlChild(element2, "w:pPr") : void 0;
96408
+ const rPr = directRunPropsElement?.name === "w:rPr" ? directRunPropsElement : findOoxmlChild(pPr, "w:rPr");
96409
+ if (!rPr) return void 0;
96410
+ const runProps = {};
96411
+ const sz = parseOoxmlNumber(getOoxmlAttribute(findOoxmlChild(rPr, "w:sz"), "w:val")) ?? parseOoxmlNumber(getOoxmlAttribute(findOoxmlChild(rPr, "w:szCs"), "w:val"));
96412
+ if (sz != null) {
96413
+ runProps.fontSize = sz;
96414
+ }
96415
+ const rFonts = findOoxmlChild(rPr, "w:rFonts");
96416
+ if (rFonts) {
96417
+ const fontFamily2 = {};
96418
+ const keys2 = ["ascii", "hAnsi", "eastAsia", "cs", "val", "asciiTheme", "hAnsiTheme", "eastAsiaTheme", "cstheme"];
96419
+ for (const key2 of keys2) {
96420
+ const value = getOoxmlAttribute(rFonts, `w:${key2}`);
96421
+ if (value != null) {
96422
+ fontFamily2[key2] = value;
96423
+ }
96424
+ }
96425
+ if (Object.keys(fontFamily2).length > 0) {
96426
+ runProps.fontFamily = fontFamily2;
96427
+ }
96428
+ }
96429
+ return Object.keys(runProps).length > 0 ? runProps : void 0;
96430
+ };
96431
+ const applyParagraphMarkRunProps = (run2, paragraphProps, converterContext) => {
96432
+ const runProps = extractParagraphMarkRunProps(paragraphProps);
96433
+ if (!runProps) return;
96434
+ const fontSizePx = parseRunFontSizePx(runProps.fontSize);
96435
+ if (fontSizePx != null) {
96436
+ run2.fontSize = fontSizePx;
96437
+ }
96438
+ const fontFamily2 = resolveRunFontFamily(runProps.fontFamily, converterContext?.docx);
96439
+ if (fontFamily2) {
96440
+ run2.fontFamily = fontFamily2;
96441
+ }
96442
+ };
96260
96443
  const applyBaseRunDefaults = (run2, defaults2, uiDisplayFallbackFont, fallbackSize) => {
96261
96444
  if (!run2) return;
96262
96445
  if (defaults2.fontFamily && run2.fontFamily === uiDisplayFallbackFont) {
@@ -96406,6 +96589,8 @@ ${o}
96406
96589
  emptyRun.pmStart = paraPos.start + 1;
96407
96590
  emptyRun.pmEnd = paraPos.start + 1;
96408
96591
  }
96592
+ applyBaseRunDefaults(emptyRun, baseRunDefaults, defaultFont, defaultSize);
96593
+ applyParagraphMarkRunProps(emptyRun, paragraphProps, converterContext);
96409
96594
  let emptyParagraphAttrs = cloneParagraphAttrs(paragraphAttrs);
96410
96595
  if (isSectPrMarker) {
96411
96596
  if (emptyParagraphAttrs) {
@@ -99793,7 +99978,6 @@ ${o}
99793
99978
  const paintedWidth = (metrics.actualBoundingBoxLeft || 0) + (metrics.actualBoundingBoxRight || 0);
99794
99979
  return Math.max(advanceWidth, paintedWidth);
99795
99980
  }
99796
- const MIN_SINGLE_LINE_PX = 12 * 96 / 72;
99797
99981
  const WORD_SINGLE_LINE_SPACING_MULTIPLIER = 1.15;
99798
99982
  function calculateTypographyMetrics(fontSize2, spacing, fontInfo) {
99799
99983
  let ascent;
@@ -99807,7 +99991,27 @@ ${o}
99807
99991
  ascent = roundValue(fontSize2 * 0.8);
99808
99992
  descent = roundValue(fontSize2 * 0.2);
99809
99993
  }
99810
- const baseLineHeight = Math.max(fontSize2 * WORD_SINGLE_LINE_SPACING_MULTIPLIER, ascent + descent, MIN_SINGLE_LINE_PX);
99994
+ const baseLineHeight = Math.max(fontSize2 * WORD_SINGLE_LINE_SPACING_MULTIPLIER, ascent + descent);
99995
+ const lineHeight2 = roundValue(resolveLineHeight(spacing, baseLineHeight));
99996
+ return {
99997
+ ascent,
99998
+ descent,
99999
+ lineHeight: lineHeight2
100000
+ };
100001
+ }
100002
+ function calculateEmptyParagraphMetrics(fontSize2, spacing, fontInfo) {
100003
+ let ascent;
100004
+ let descent;
100005
+ if (fontInfo) {
100006
+ const ctx2 = getCanvasContext();
100007
+ const metrics = getFontMetrics(ctx2, fontInfo);
100008
+ ascent = roundValue(metrics.ascent);
100009
+ descent = roundValue(metrics.descent);
100010
+ } else {
100011
+ ascent = roundValue(fontSize2 * 0.8);
100012
+ descent = roundValue(fontSize2 * 0.2);
100013
+ }
100014
+ const baseLineHeight = Math.max(fontSize2, ascent + descent);
99811
100015
  const lineHeight2 = roundValue(resolveLineHeight(spacing, baseLineHeight));
99812
100016
  return {
99813
100017
  ascent,
@@ -99838,6 +100042,10 @@ ${o}
99838
100042
  function isLineBreakRun(run2) {
99839
100043
  return run2.kind === "lineBreak";
99840
100044
  }
100045
+ const isEmptyTextRun = (run2) => {
100046
+ if (run2.kind && run2.kind !== "text") return false;
100047
+ return typeof run2.text === "string" && run2.text.length === 0;
100048
+ };
99841
100049
  function isFieldAnnotationRun(run2) {
99842
100050
  return run2.kind === "fieldAnnotation";
99843
100051
  }
@@ -100007,8 +100215,28 @@ ${o}
100007
100215
  dropCapDescriptor.measuredHeight = dropCapMeasured.height;
100008
100216
  }
100009
100217
  }
100218
+ const emptyParagraphRun = block.runs.length === 1 && isEmptyTextRun(block.runs[0]) ? block.runs[0] : null;
100219
+ if (emptyParagraphRun) {
100220
+ const fontSize2 = emptyParagraphRun.fontSize ?? 12;
100221
+ const metrics = calculateEmptyParagraphMetrics(fontSize2, spacing, getFontInfoFromRun(emptyParagraphRun));
100222
+ const emptyLine = {
100223
+ fromRun: 0,
100224
+ fromChar: 0,
100225
+ toRun: 0,
100226
+ toChar: 0,
100227
+ width: 0,
100228
+ ...metrics
100229
+ };
100230
+ addBarTabsToLine(emptyLine);
100231
+ lines.push(emptyLine);
100232
+ return {
100233
+ kind: "paragraph",
100234
+ lines,
100235
+ totalHeight: metrics.lineHeight
100236
+ };
100237
+ }
100010
100238
  if (block.runs.length === 0) {
100011
- const metrics = calculateTypographyMetrics(12, spacing);
100239
+ const metrics = calculateEmptyParagraphMetrics(12, spacing);
100012
100240
  const emptyLine = {
100013
100241
  fromRun: 0,
100014
100242
  fromChar: 0,
@@ -150967,7 +151195,7 @@ ${reason}`);
150967
151195
  this.config.colors = shuffleArray(this.config.colors);
150968
151196
  this.userColorMap = /* @__PURE__ */ new Map();
150969
151197
  this.colorIndex = 0;
150970
- this.version = "1.7.0-next.5";
151198
+ this.version = "1.7.0-next.7";
150971
151199
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
150972
151200
  this.superdocId = config2.superdocId || v4();
150973
151201
  this.colors = this.config.colors;