@harbour-enterprises/superdoc 1.7.0-next.4 → 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,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-CqGLfodX.cjs");
4
+ const superEditor_converter = require("./SuperConverter-iUnNfL5l.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.4";
15791
+ const summaryVersion = "1.7.0-next.6";
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.4");
18458
+ console.debug("[checkVersionMigrations] Current editor version", "1.7.0-next.6");
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;
@@ -33116,7 +33138,7 @@ const getParagraphAttrs = (block) => {
33116
33138
  const asString = (value) => {
33117
33139
  return typeof value === "string" ? value : void 0;
33118
33140
  };
33119
- const asBoolean = (value) => {
33141
+ const asBoolean$1 = (value) => {
33120
33142
  if (value === true || value === 1) return true;
33121
33143
  if (typeof value === "string") {
33122
33144
  const normalized = value.toLowerCase();
@@ -33296,10 +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
- const contextualSpacing = asBoolean(attrs?.contextualSpacing);
33323
+ const contextualSpacing = asBoolean$1(attrs?.contextualSpacing);
33301
33324
  let spacingBefore = Math.max(0, Number(spacing.before ?? spacing.lineSpaceBefore ?? 0));
33302
- const spacingAfter = Math.max(0, Number(spacing.after ?? spacing.lineSpaceAfter ?? 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
+ }
33331
+ const baseSpacingBefore = spacingBefore;
33303
33332
  let appliedSpacingBefore = spacingBefore === 0;
33304
33333
  let lastState = null;
33305
33334
  const isPositionedFrame = frame?.wrap === "none";
@@ -33393,6 +33422,21 @@ function layoutParagraphBlock(ctx2, anchors) {
33393
33422
  state.trailingSpacing = 0;
33394
33423
  }
33395
33424
  }
33425
+ const keepLines = attrs?.keepLines === true;
33426
+ if (keepLines && fromLine === 0) {
33427
+ const prevTrailing = state.trailingSpacing ?? 0;
33428
+ const neededSpacingBefore = Math.max(spacingBefore - prevTrailing, 0);
33429
+ const pageContentHeight = state.contentBottom - state.topMargin;
33430
+ const fullHeight = lines.reduce((sum, line) => sum + (line.lineHeight || 0), 0);
33431
+ const fitsOnBlankPage = fullHeight + baseSpacingBefore <= pageContentHeight;
33432
+ const remainingHeightAfterSpacing = state.contentBottom - (state.cursorY + neededSpacingBefore);
33433
+ if (fitsOnBlankPage && state.page.fragments.length > 0 && fullHeight > remainingHeightAfterSpacing) {
33434
+ state = advanceColumn(state);
33435
+ spacingBefore = baseSpacingBefore;
33436
+ appliedSpacingBefore = spacingBefore === 0;
33437
+ continue;
33438
+ }
33439
+ }
33396
33440
  if (!appliedSpacingBefore && spacingBefore > 0) {
33397
33441
  while (!appliedSpacingBefore) {
33398
33442
  const prevTrailing = state.trailingSpacing ?? 0;
@@ -34606,11 +34650,13 @@ function hasHeight(fragment) {
34606
34650
  function getParagraphSpacingBefore(block) {
34607
34651
  const spacing = block.attrs?.spacing;
34608
34652
  const value = spacing?.before ?? spacing?.lineSpaceBefore;
34653
+ if (shouldSuppressSpacingForEmpty(block, "before")) return 0;
34609
34654
  return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : 0;
34610
34655
  }
34611
34656
  function getParagraphSpacingAfter$1(block) {
34612
34657
  const spacing = block.attrs?.spacing;
34613
34658
  const value = spacing?.after ?? spacing?.lineSpaceAfter;
34659
+ if (shouldSuppressSpacingForEmpty(block, "after")) return 0;
34614
34660
  return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : 0;
34615
34661
  }
34616
34662
  function getMeasureHeight(block, measure) {
@@ -34636,6 +34682,14 @@ function getMeasureHeight(block, measure) {
34636
34682
  const DEFAULT_PAGE_SIZE$2 = { w: 612, h: 792 };
34637
34683
  const DEFAULT_MARGINS$2 = { top: 72, right: 72, bottom: 72, left: 72 };
34638
34684
  const COLUMN_EPSILON$1 = 1e-4;
34685
+ const asBoolean = (value) => {
34686
+ if (value === true || value === 1) return true;
34687
+ if (typeof value === "string") {
34688
+ const normalized = value.toLowerCase();
34689
+ return normalized === "true" || normalized === "1" || normalized === "on";
34690
+ }
34691
+ return false;
34692
+ };
34639
34693
  const layoutDebugEnabled$1 = typeof vue.process$1 !== "undefined" && typeof vue.process$1.env !== "undefined" && Boolean(vue.process$1.env.SD_DEBUG_LAYOUT);
34640
34694
  const layoutLog = (...args) => {
34641
34695
  if (!layoutDebugEnabled$1) return;
@@ -35459,11 +35513,23 @@ function layoutDocument(blocks, measures, options = {}) {
35459
35513
  if (!shouldSkipAnchoredTable) {
35460
35514
  let state = paginator.ensurePage();
35461
35515
  const availableHeight = state.contentBottom - state.cursorY;
35516
+ const spacingBefore = getParagraphSpacingBefore(paraBlock);
35462
35517
  const spacingAfter = getParagraphSpacingAfter$1(paraBlock);
35518
+ const prevTrailing = Number.isFinite(state.trailingSpacing) && state.trailingSpacing > 0 ? state.trailingSpacing : 0;
35519
+ const currentStyleId = typeof paraBlock.attrs?.styleId === "string" ? paraBlock.attrs?.styleId : void 0;
35520
+ const currentContextualSpacing = asBoolean(paraBlock.attrs?.contextualSpacing);
35521
+ const contextualSpacingApplies = currentContextualSpacing && currentStyleId && state.lastParagraphStyleId === currentStyleId;
35522
+ const effectiveSpacingBefore = contextualSpacingApplies ? 0 : Math.max(spacingBefore - prevTrailing, 0);
35463
35523
  const currentHeight = getMeasureHeight(paraBlock, measure);
35464
35524
  const nextHeight = getMeasureHeight(nextBlock, nextMeasure);
35465
35525
  const nextIsParagraph = nextBlock.kind === "paragraph" && nextMeasure.kind === "paragraph";
35466
35526
  const nextSpacingBefore = nextIsParagraph ? getParagraphSpacingBefore(nextBlock) : 0;
35527
+ const nextStyleId = nextIsParagraph && typeof nextBlock.attrs?.styleId === "string" ? nextBlock.attrs?.styleId : void 0;
35528
+ const nextContextualSpacing = nextIsParagraph && asBoolean(nextBlock.attrs?.contextualSpacing);
35529
+ const sameStyleAsNext = currentStyleId && nextStyleId && nextStyleId === currentStyleId;
35530
+ const effectiveSpacingAfter = currentContextualSpacing && sameStyleAsNext ? 0 : spacingAfter;
35531
+ const effectiveNextSpacingBefore = nextContextualSpacing && sameStyleAsNext ? 0 : nextSpacingBefore;
35532
+ const interParagraphSpacing = nextIsParagraph ? Math.max(effectiveSpacingAfter, effectiveNextSpacingBefore) : effectiveSpacingAfter;
35467
35533
  const nextFirstLineHeight = (() => {
35468
35534
  if (!nextIsParagraph) {
35469
35535
  return nextHeight;
@@ -35474,8 +35540,9 @@ function layoutDocument(blocks, measures, options = {}) {
35474
35540
  }
35475
35541
  return nextHeight;
35476
35542
  })();
35477
- const combinedHeight = nextIsParagraph ? currentHeight + Math.max(spacingAfter, nextSpacingBefore) + nextFirstLineHeight : currentHeight + spacingAfter + nextHeight;
35478
- if (combinedHeight > availableHeight && state.page.fragments.length > 0) {
35543
+ const combinedHeight = nextIsParagraph ? effectiveSpacingBefore + currentHeight + interParagraphSpacing + nextFirstLineHeight : effectiveSpacingBefore + currentHeight + spacingAfter + nextHeight;
35544
+ const effectiveAvailableHeight = contextualSpacingApplies ? availableHeight + prevTrailing : availableHeight;
35545
+ if (combinedHeight > effectiveAvailableHeight && state.page.fragments.length > 0) {
35479
35546
  state = paginator.advanceColumn(state);
35480
35547
  }
35481
35548
  }
@@ -43447,6 +43514,26 @@ function normalizeTextInsets(value) {
43447
43514
  return { top: top2, right: right2, bottom: bottom2, left: left2 };
43448
43515
  }
43449
43516
  const OOXML_Z_INDEX_BASE = 251658240;
43517
+ const asOoxmlElement = (value) => {
43518
+ if (!value || typeof value !== "object") return void 0;
43519
+ const element = value;
43520
+ if (element.name == null && element.attributes == null && element.elements == null) return void 0;
43521
+ return element;
43522
+ };
43523
+ const findOoxmlChild = (parent, name) => {
43524
+ return parent?.elements?.find((child) => child?.name === name);
43525
+ };
43526
+ const getOoxmlAttribute = (element, key2) => {
43527
+ if (!element?.attributes) return void 0;
43528
+ const attrs = element.attributes;
43529
+ return attrs[key2] ?? attrs[key2.startsWith("w:") ? key2.slice(2) : `w:${key2}`];
43530
+ };
43531
+ const parseOoxmlNumber = (value) => {
43532
+ if (value == null) return void 0;
43533
+ const num = typeof value === "number" ? value : Number.parseInt(String(value), 10);
43534
+ return Number.isFinite(num) ? num : void 0;
43535
+ };
43536
+ const hasOwnProperty$d = (obj, key2) => Object.prototype.hasOwnProperty.call(obj, key2);
43450
43537
  function normalizeZIndex(originalAttributes) {
43451
43538
  if (!isPlainObject$2(originalAttributes)) return void 0;
43452
43539
  const relativeHeight = originalAttributes.relativeHeight;
@@ -45447,24 +45534,47 @@ const DEFAULT_DECIMAL_SEPARATOR$2 = ".";
45447
45534
  const isValidNumberingId = (numId) => {
45448
45535
  return numId != null && numId !== 0 && numId !== "0";
45449
45536
  };
45450
- const asOoxmlElement = (value) => {
45451
- if (!value || typeof value !== "object") return void 0;
45452
- const element = value;
45453
- if (element.name == null && element.attributes == null && element.elements == null) return void 0;
45454
- return element;
45455
- };
45456
- const findChild = (parent, name) => {
45457
- return parent?.elements?.find((child) => child?.name === name);
45537
+ const extractSpacingExplicitFromObject = (value) => {
45538
+ if (!value || typeof value !== "object" || Array.isArray(value)) return {};
45539
+ const obj = value;
45540
+ const explicit = {};
45541
+ if (hasOwnProperty$d(obj, "before") || hasOwnProperty$d(obj, "lineSpaceBefore") || hasOwnProperty$d(obj, "beforeAutospacing") || hasOwnProperty$d(obj, "beforeAutoSpacing")) {
45542
+ explicit.before = true;
45543
+ }
45544
+ if (hasOwnProperty$d(obj, "after") || hasOwnProperty$d(obj, "lineSpaceAfter") || hasOwnProperty$d(obj, "afterAutospacing") || hasOwnProperty$d(obj, "afterAutoSpacing")) {
45545
+ explicit.after = true;
45546
+ }
45547
+ if (hasOwnProperty$d(obj, "line") || hasOwnProperty$d(obj, "lineRule")) {
45548
+ explicit.line = true;
45549
+ }
45550
+ return explicit;
45458
45551
  };
45459
- const getAttribute = (element, key2) => {
45460
- if (!element?.attributes) return void 0;
45461
- const attrs = element.attributes;
45462
- return attrs[key2] ?? attrs[key2.startsWith("w:") ? key2.slice(2) : `w:${key2}`];
45552
+ const extractSpacingExplicitFromOoxml = (value) => {
45553
+ const element = asOoxmlElement(value);
45554
+ if (!element) return {};
45555
+ const pPr = element.name === "w:pPr" ? element : findOoxmlChild(element, "w:pPr");
45556
+ const spacingEl = findOoxmlChild(pPr, "w:spacing");
45557
+ if (!spacingEl) return {};
45558
+ const explicit = {};
45559
+ if (getOoxmlAttribute(spacingEl, "w:before") != null || getOoxmlAttribute(spacingEl, "w:beforeAutospacing") != null || getOoxmlAttribute(spacingEl, "w:beforeAutoSpacing") != null) {
45560
+ explicit.before = true;
45561
+ }
45562
+ if (getOoxmlAttribute(spacingEl, "w:after") != null || getOoxmlAttribute(spacingEl, "w:afterAutospacing") != null || getOoxmlAttribute(spacingEl, "w:afterAutoSpacing") != null) {
45563
+ explicit.after = true;
45564
+ }
45565
+ if (getOoxmlAttribute(spacingEl, "w:line") != null || getOoxmlAttribute(spacingEl, "w:lineRule") != null) {
45566
+ explicit.line = true;
45567
+ }
45568
+ return explicit;
45463
45569
  };
45464
- const parseNumberAttr = (value) => {
45465
- if (value == null) return void 0;
45466
- const num = typeof value === "number" ? value : Number.parseInt(String(value), 10);
45467
- return Number.isFinite(num) ? num : void 0;
45570
+ const mergeSpacingExplicit = (...sources) => {
45571
+ const merged = {};
45572
+ for (const source of sources) {
45573
+ if (source.before) merged.before = true;
45574
+ if (source.after) merged.after = true;
45575
+ if (source.line) merged.line = true;
45576
+ }
45577
+ return merged;
45468
45578
  };
45469
45579
  const mergeSpacingSources = (base2, paragraphProps, attrs) => {
45470
45580
  const isObject2 = (v) => v !== null && typeof v === "object";
@@ -45510,13 +45620,13 @@ const normalizeJustification = (value) => {
45510
45620
  return void 0;
45511
45621
  };
45512
45622
  const extractIndentFromLevel = (lvl) => {
45513
- const pPr = findChild(lvl, "w:pPr");
45514
- const ind = findChild(pPr, "w:ind");
45623
+ const pPr = findOoxmlChild(lvl, "w:pPr");
45624
+ const ind = findOoxmlChild(pPr, "w:ind");
45515
45625
  if (!ind) return void 0;
45516
- const left2 = parseNumberAttr(getAttribute(ind, "w:left"));
45517
- const right2 = parseNumberAttr(getAttribute(ind, "w:right"));
45518
- const firstLine = parseNumberAttr(getAttribute(ind, "w:firstLine"));
45519
- const hanging = parseNumberAttr(getAttribute(ind, "w:hanging"));
45626
+ const left2 = parseOoxmlNumber(getOoxmlAttribute(ind, "w:left"));
45627
+ const right2 = parseOoxmlNumber(getOoxmlAttribute(ind, "w:right"));
45628
+ const firstLine = parseOoxmlNumber(getOoxmlAttribute(ind, "w:firstLine"));
45629
+ const hanging = parseOoxmlNumber(getOoxmlAttribute(ind, "w:hanging"));
45520
45630
  const indent = {};
45521
45631
  if (left2 != null) indent.left = left2;
45522
45632
  if (right2 != null) indent.right = right2;
@@ -45532,31 +45642,31 @@ const normalizeColor = (value) => {
45532
45642
  return `#${upper.toUpperCase()}`;
45533
45643
  };
45534
45644
  const extractMarkerRun = (lvl) => {
45535
- const rPr = findChild(lvl, "w:rPr");
45645
+ const rPr = findOoxmlChild(lvl, "w:rPr");
45536
45646
  if (!rPr) return void 0;
45537
45647
  const run = {};
45538
- const rFonts = findChild(rPr, "w:rFonts");
45539
- const font = getAttribute(rFonts, "w:ascii") ?? getAttribute(rFonts, "w:hAnsi") ?? getAttribute(rFonts, "w:eastAsia");
45648
+ const rFonts = findOoxmlChild(rPr, "w:rFonts");
45649
+ const font = getOoxmlAttribute(rFonts, "w:ascii") ?? getOoxmlAttribute(rFonts, "w:hAnsi") ?? getOoxmlAttribute(rFonts, "w:eastAsia");
45540
45650
  if (typeof font === "string" && font.trim()) {
45541
45651
  run.fontFamily = font;
45542
45652
  }
45543
- const sz = parseNumberAttr(getAttribute(findChild(rPr, "w:sz"), "w:val")) ?? parseNumberAttr(getAttribute(findChild(rPr, "w:szCs"), "w:val"));
45653
+ const sz = parseOoxmlNumber(getOoxmlAttribute(findOoxmlChild(rPr, "w:sz"), "w:val")) ?? parseOoxmlNumber(getOoxmlAttribute(findOoxmlChild(rPr, "w:szCs"), "w:val"));
45544
45654
  if (sz != null) {
45545
45655
  run.fontSize = sz / 2;
45546
45656
  }
45547
- const color = normalizeColor(getAttribute(findChild(rPr, "w:color"), "w:val"));
45657
+ const color = normalizeColor(getOoxmlAttribute(findOoxmlChild(rPr, "w:color"), "w:val"));
45548
45658
  if (color) run.color = color;
45549
- const boldEl = findChild(rPr, "w:b");
45659
+ const boldEl = findOoxmlChild(rPr, "w:b");
45550
45660
  if (boldEl) {
45551
- const boldVal = getAttribute(boldEl, "w:val");
45661
+ const boldVal = getOoxmlAttribute(boldEl, "w:val");
45552
45662
  if (boldVal == null || isTruthy(boldVal)) run.bold = true;
45553
45663
  }
45554
- const italicEl = findChild(rPr, "w:i");
45664
+ const italicEl = findOoxmlChild(rPr, "w:i");
45555
45665
  if (italicEl) {
45556
- const italicVal = getAttribute(italicEl, "w:val");
45666
+ const italicVal = getOoxmlAttribute(italicEl, "w:val");
45557
45667
  if (italicVal == null || isTruthy(italicVal)) run.italic = true;
45558
45668
  }
45559
- const spacingTwips = parseNumberAttr(getAttribute(findChild(rPr, "w:spacing"), "w:val"));
45669
+ const spacingTwips = parseOoxmlNumber(getOoxmlAttribute(findOoxmlChild(rPr, "w:spacing"), "w:val"));
45560
45670
  if (spacingTwips != null && Number.isFinite(spacingTwips)) {
45561
45671
  run.letterSpacing = twipsToPx$1(spacingTwips);
45562
45672
  }
@@ -45564,12 +45674,12 @@ const extractMarkerRun = (lvl) => {
45564
45674
  };
45565
45675
  const findNumFmtElement = (lvl) => {
45566
45676
  if (!lvl) return void 0;
45567
- const direct = findChild(lvl, "w:numFmt");
45677
+ const direct = findOoxmlChild(lvl, "w:numFmt");
45568
45678
  if (direct) return direct;
45569
- const alternate = findChild(lvl, "mc:AlternateContent");
45570
- const choice = findChild(alternate, "mc:Choice");
45679
+ const alternate = findOoxmlChild(lvl, "mc:AlternateContent");
45680
+ const choice = findOoxmlChild(alternate, "mc:Choice");
45571
45681
  if (choice) {
45572
- return findChild(choice, "w:numFmt");
45682
+ return findOoxmlChild(choice, "w:numFmt");
45573
45683
  }
45574
45684
  return void 0;
45575
45685
  };
@@ -45583,7 +45693,7 @@ const resolveNumberingFromContext = (numId, ilvl, numbering) => {
45583
45693
  if (!numDef) {
45584
45694
  return void 0;
45585
45695
  }
45586
- const abstractId = getAttribute(findChild(numDef, "w:abstractNumId"), "w:val");
45696
+ const abstractId = getOoxmlAttribute(findOoxmlChild(numDef, "w:abstractNumId"), "w:val");
45587
45697
  if (abstractId == null) {
45588
45698
  return void 0;
45589
45699
  }
@@ -45592,27 +45702,27 @@ const resolveNumberingFromContext = (numId, ilvl, numbering) => {
45592
45702
  return void 0;
45593
45703
  }
45594
45704
  let levelDef = abstract.elements?.find(
45595
- (el) => el?.name === "w:lvl" && parseNumberAttr(el.attributes?.["w:ilvl"]) === ilvl
45705
+ (el) => el?.name === "w:lvl" && parseOoxmlNumber(el.attributes?.["w:ilvl"]) === ilvl
45596
45706
  );
45597
45707
  const override = numDef.elements?.find(
45598
- (el) => el?.name === "w:lvlOverride" && parseNumberAttr(el.attributes?.["w:ilvl"]) === ilvl
45708
+ (el) => el?.name === "w:lvlOverride" && parseOoxmlNumber(el.attributes?.["w:ilvl"]) === ilvl
45599
45709
  );
45600
- const overrideLvl = findChild(override, "w:lvl");
45710
+ const overrideLvl = findOoxmlChild(override, "w:lvl");
45601
45711
  if (overrideLvl) {
45602
45712
  levelDef = overrideLvl;
45603
45713
  }
45604
- const startOverride = parseNumberAttr(getAttribute(findChild(override, "w:startOverride"), "w:val"));
45714
+ const startOverride = parseOoxmlNumber(getOoxmlAttribute(findOoxmlChild(override, "w:startOverride"), "w:val"));
45605
45715
  if (!levelDef) {
45606
45716
  return void 0;
45607
45717
  }
45608
45718
  const numFmtEl = findNumFmtElement(levelDef);
45609
- const lvlText = getAttribute(findChild(levelDef, "w:lvlText"), "w:val");
45610
- const start2 = startOverride ?? parseNumberAttr(getAttribute(findChild(levelDef, "w:start"), "w:val"));
45611
- const suffix2 = normalizeSuffix(getAttribute(findChild(levelDef, "w:suff"), "w:val"));
45612
- const lvlJc = normalizeJustification(getAttribute(findChild(levelDef, "w:lvlJc"), "w:val"));
45719
+ const lvlText = getOoxmlAttribute(findOoxmlChild(levelDef, "w:lvlText"), "w:val");
45720
+ const start2 = startOverride ?? parseOoxmlNumber(getOoxmlAttribute(findOoxmlChild(levelDef, "w:start"), "w:val"));
45721
+ const suffix2 = normalizeSuffix(getOoxmlAttribute(findOoxmlChild(levelDef, "w:suff"), "w:val"));
45722
+ const lvlJc = normalizeJustification(getOoxmlAttribute(findOoxmlChild(levelDef, "w:lvlJc"), "w:val"));
45613
45723
  const indent = extractIndentFromLevel(levelDef);
45614
45724
  const markerRun = extractMarkerRun(levelDef);
45615
- const numFmt = normalizeNumFmt(getAttribute(numFmtEl, "w:val"));
45725
+ const numFmt = normalizeNumFmt(getOoxmlAttribute(numFmtEl, "w:val"));
45616
45726
  return {
45617
45727
  format: numFmt,
45618
45728
  lvlText,
@@ -45705,6 +45815,7 @@ const cloneParagraphAttrs = (attrs) => {
45705
45815
  if (!attrs) return void 0;
45706
45816
  const clone = { ...attrs };
45707
45817
  if (attrs.spacing) clone.spacing = { ...attrs.spacing };
45818
+ if (attrs.spacingExplicit) clone.spacingExplicit = { ...attrs.spacingExplicit };
45708
45819
  if (attrs.indent) clone.indent = { ...attrs.indent };
45709
45820
  if (attrs.borders) {
45710
45821
  const borderClone = {};
@@ -46080,6 +46191,11 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
46080
46191
  const hydrated = hydrationOverride ?? hydrateParagraphStyleAttrs(para, converterContext);
46081
46192
  const mergedSpacing = mergeSpacingSources(hydrated?.spacing, paragraphProps.spacing, attrs.spacing);
46082
46193
  const normalizedSpacing = normalizeParagraphSpacing(mergedSpacing);
46194
+ const spacingExplicit = mergeSpacingExplicit(
46195
+ extractSpacingExplicitFromObject(paragraphProps.spacing),
46196
+ extractSpacingExplicitFromObject(attrs.spacing),
46197
+ extractSpacingExplicitFromOoxml(paragraphProps)
46198
+ );
46083
46199
  const normalizeIndentObject = (value) => {
46084
46200
  if (!value || typeof value !== "object") return;
46085
46201
  return normalizePxIndent(value) ?? convertIndentTwipsToPx(value);
@@ -46214,6 +46330,7 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
46214
46330
  paragraphAttrs.spacing.afterAutospacing = normalizedSpacing.afterAutospacing;
46215
46331
  }
46216
46332
  }
46333
+ paragraphAttrs.spacingExplicit = spacingExplicit;
46217
46334
  const contextualSpacingValue = normalizedSpacing?.contextualSpacing ?? safeGetProperty(paragraphProps, "contextualSpacing") ?? safeGetProperty(attrs, "contextualSpacing") ?? hydrated?.contextualSpacing;
46218
46335
  if (contextualSpacingValue != null) {
46219
46336
  paragraphAttrs.contextualSpacing = isTruthy(contextualSpacingValue);
@@ -47692,6 +47809,75 @@ const extractFirstTextRunFont = (para) => {
47692
47809
  const font = findFirstTextFont(para.content);
47693
47810
  return font;
47694
47811
  };
47812
+ const resolveRunFontFamily = (fontFamily2, docx) => {
47813
+ if (typeof fontFamily2 === "string" && fontFamily2.trim().length > 0) {
47814
+ return fontFamily2;
47815
+ }
47816
+ if (!fontFamily2 || typeof fontFamily2 !== "object") return void 0;
47817
+ const toCssFontFamily2 = superEditor_converter.SuperConverter.toCssFontFamily;
47818
+ const resolved = superEditor_converter.resolveDocxFontFamily(fontFamily2, docx ?? null, toCssFontFamily2);
47819
+ return resolved ?? void 0;
47820
+ };
47821
+ const parseRunFontSizePx = (fontSize2) => {
47822
+ if (typeof fontSize2 === "number" && Number.isFinite(fontSize2)) {
47823
+ return ptToPx(fontSize2 / HALF_POINTS_PER_POINT) ?? void 0;
47824
+ }
47825
+ if (typeof fontSize2 === "string") {
47826
+ const numeric = Number.parseFloat(fontSize2);
47827
+ if (!Number.isFinite(numeric)) return void 0;
47828
+ if (fontSize2.endsWith("pt")) {
47829
+ return ptToPx(numeric);
47830
+ }
47831
+ if (fontSize2.endsWith("px")) {
47832
+ return numeric;
47833
+ }
47834
+ return ptToPx(numeric / HALF_POINTS_PER_POINT) ?? void 0;
47835
+ }
47836
+ return void 0;
47837
+ };
47838
+ const extractParagraphMarkRunProps = (paragraphProps) => {
47839
+ const directRunProps = paragraphProps.runProperties;
47840
+ const directRunPropsElement = asOoxmlElement(directRunProps);
47841
+ if (directRunProps && isPlainObject$2(directRunProps) && !directRunPropsElement) {
47842
+ return directRunProps;
47843
+ }
47844
+ const element = asOoxmlElement(paragraphProps);
47845
+ const pPr = element ? element.name === "w:pPr" ? element : findOoxmlChild(element, "w:pPr") : void 0;
47846
+ const rPr = directRunPropsElement?.name === "w:rPr" ? directRunPropsElement : findOoxmlChild(pPr, "w:rPr");
47847
+ if (!rPr) return void 0;
47848
+ const runProps = {};
47849
+ const sz = parseOoxmlNumber(getOoxmlAttribute(findOoxmlChild(rPr, "w:sz"), "w:val")) ?? parseOoxmlNumber(getOoxmlAttribute(findOoxmlChild(rPr, "w:szCs"), "w:val"));
47850
+ if (sz != null) {
47851
+ runProps.fontSize = sz;
47852
+ }
47853
+ const rFonts = findOoxmlChild(rPr, "w:rFonts");
47854
+ if (rFonts) {
47855
+ const fontFamily2 = {};
47856
+ const keys2 = ["ascii", "hAnsi", "eastAsia", "cs", "val", "asciiTheme", "hAnsiTheme", "eastAsiaTheme", "cstheme"];
47857
+ for (const key2 of keys2) {
47858
+ const value = getOoxmlAttribute(rFonts, `w:${key2}`);
47859
+ if (value != null) {
47860
+ fontFamily2[key2] = value;
47861
+ }
47862
+ }
47863
+ if (Object.keys(fontFamily2).length > 0) {
47864
+ runProps.fontFamily = fontFamily2;
47865
+ }
47866
+ }
47867
+ return Object.keys(runProps).length > 0 ? runProps : void 0;
47868
+ };
47869
+ const applyParagraphMarkRunProps = (run, paragraphProps, converterContext) => {
47870
+ const runProps = extractParagraphMarkRunProps(paragraphProps);
47871
+ if (!runProps) return;
47872
+ const fontSizePx = parseRunFontSizePx(runProps.fontSize);
47873
+ if (fontSizePx != null) {
47874
+ run.fontSize = fontSizePx;
47875
+ }
47876
+ const fontFamily2 = resolveRunFontFamily(runProps.fontFamily, converterContext?.docx);
47877
+ if (fontFamily2) {
47878
+ run.fontFamily = fontFamily2;
47879
+ }
47880
+ };
47695
47881
  const applyBaseRunDefaults = (run, defaults, uiDisplayFallbackFont, fallbackSize) => {
47696
47882
  if (!run) return;
47697
47883
  if (defaults.fontFamily && run.fontFamily === uiDisplayFallbackFont) {
@@ -47841,6 +48027,8 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
47841
48027
  emptyRun.pmStart = paraPos.start + 1;
47842
48028
  emptyRun.pmEnd = paraPos.start + 1;
47843
48029
  }
48030
+ applyBaseRunDefaults(emptyRun, baseRunDefaults, defaultFont, defaultSize);
48031
+ applyParagraphMarkRunProps(emptyRun, paragraphProps, converterContext);
47844
48032
  let emptyParagraphAttrs = cloneParagraphAttrs(paragraphAttrs);
47845
48033
  if (isSectPrMarker) {
47846
48034
  if (emptyParagraphAttrs) {
@@ -51228,7 +51416,6 @@ function measureText(text, font, ctx2, _fontFamily, _letterSpacing) {
51228
51416
  const paintedWidth = (metrics.actualBoundingBoxLeft || 0) + (metrics.actualBoundingBoxRight || 0);
51229
51417
  return Math.max(advanceWidth, paintedWidth);
51230
51418
  }
51231
- const MIN_SINGLE_LINE_PX = 12 * 96 / 72;
51232
51419
  const WORD_SINGLE_LINE_SPACING_MULTIPLIER = 1.15;
51233
51420
  function calculateTypographyMetrics(fontSize2, spacing, fontInfo) {
51234
51421
  let ascent;
@@ -51242,7 +51429,27 @@ function calculateTypographyMetrics(fontSize2, spacing, fontInfo) {
51242
51429
  ascent = roundValue(fontSize2 * 0.8);
51243
51430
  descent = roundValue(fontSize2 * 0.2);
51244
51431
  }
51245
- const baseLineHeight = Math.max(fontSize2 * WORD_SINGLE_LINE_SPACING_MULTIPLIER, ascent + descent, MIN_SINGLE_LINE_PX);
51432
+ const baseLineHeight = Math.max(fontSize2 * WORD_SINGLE_LINE_SPACING_MULTIPLIER, ascent + descent);
51433
+ const lineHeight2 = roundValue(resolveLineHeight(spacing, baseLineHeight));
51434
+ return {
51435
+ ascent,
51436
+ descent,
51437
+ lineHeight: lineHeight2
51438
+ };
51439
+ }
51440
+ function calculateEmptyParagraphMetrics(fontSize2, spacing, fontInfo) {
51441
+ let ascent;
51442
+ let descent;
51443
+ if (fontInfo) {
51444
+ const ctx2 = getCanvasContext();
51445
+ const metrics = getFontMetrics(ctx2, fontInfo);
51446
+ ascent = roundValue(metrics.ascent);
51447
+ descent = roundValue(metrics.descent);
51448
+ } else {
51449
+ ascent = roundValue(fontSize2 * 0.8);
51450
+ descent = roundValue(fontSize2 * 0.2);
51451
+ }
51452
+ const baseLineHeight = Math.max(fontSize2, ascent + descent);
51246
51453
  const lineHeight2 = roundValue(resolveLineHeight(spacing, baseLineHeight));
51247
51454
  return {
51248
51455
  ascent,
@@ -51273,6 +51480,10 @@ function isImageRun(run) {
51273
51480
  function isLineBreakRun(run) {
51274
51481
  return run.kind === "lineBreak";
51275
51482
  }
51483
+ const isEmptyTextRun = (run) => {
51484
+ if (run.kind && run.kind !== "text") return false;
51485
+ return typeof run.text === "string" && run.text.length === 0;
51486
+ };
51276
51487
  function isFieldAnnotationRun(run) {
51277
51488
  return run.kind === "fieldAnnotation";
51278
51489
  }
@@ -51442,8 +51653,28 @@ async function measureParagraphBlock(block, maxWidth) {
51442
51653
  dropCapDescriptor.measuredHeight = dropCapMeasured.height;
51443
51654
  }
51444
51655
  }
51656
+ const emptyParagraphRun = block.runs.length === 1 && isEmptyTextRun(block.runs[0]) ? block.runs[0] : null;
51657
+ if (emptyParagraphRun) {
51658
+ const fontSize2 = emptyParagraphRun.fontSize ?? 12;
51659
+ const metrics = calculateEmptyParagraphMetrics(fontSize2, spacing, getFontInfoFromRun(emptyParagraphRun));
51660
+ const emptyLine = {
51661
+ fromRun: 0,
51662
+ fromChar: 0,
51663
+ toRun: 0,
51664
+ toChar: 0,
51665
+ width: 0,
51666
+ ...metrics
51667
+ };
51668
+ addBarTabsToLine(emptyLine);
51669
+ lines.push(emptyLine);
51670
+ return {
51671
+ kind: "paragraph",
51672
+ lines,
51673
+ totalHeight: metrics.lineHeight
51674
+ };
51675
+ }
51445
51676
  if (block.runs.length === 0) {
51446
- const metrics = calculateTypographyMetrics(12, spacing);
51677
+ const metrics = calculateEmptyParagraphMetrics(12, spacing);
51447
51678
  const emptyLine = {
51448
51679
  fromRun: 0,
51449
51680
  fromChar: 0,
@@ -51460,6 +51691,11 @@ async function measureParagraphBlock(block, maxWidth) {
51460
51691
  totalHeight: metrics.lineHeight
51461
51692
  };
51462
51693
  }
51694
+ const firstTextRunWithSize = block.runs.find(
51695
+ (run) => "text" in run && "fontSize" in run && typeof run.fontSize === "number"
51696
+ );
51697
+ const fallbackFontSize = firstTextRunWithSize?.fontSize ?? 12;
51698
+ const fallbackFontInfo = firstTextRunWithSize ? getFontInfoFromRun(firstTextRunWithSize) : void 0;
51463
51699
  let currentLine = null;
51464
51700
  const getEffectiveWidth = (baseWidth) => {
51465
51701
  if (dropCapMeasure && lines.length < dropCapMeasure.lines && dropCapMeasure.mode === "drop") {
@@ -51467,7 +51703,8 @@ async function measureParagraphBlock(block, maxWidth) {
51467
51703
  }
51468
51704
  return baseWidth;
51469
51705
  };
51470
- let lastFontSize = 12;
51706
+ let lastFontSize = fallbackFontSize;
51707
+ let hasSeenTextRun = false;
51471
51708
  let tabStopCursor = 0;
51472
51709
  let pendingTabAlignment = null;
51473
51710
  let pendingRunSpacing = 0;
@@ -51592,11 +51829,7 @@ async function measureParagraphBlock(block, maxWidth) {
51592
51829
  lines.push(completedLine);
51593
51830
  currentLine = null;
51594
51831
  } else {
51595
- const textRunWithSize = block.runs.find(
51596
- (r2) => r2.kind !== "tab" && r2.kind !== "lineBreak" && r2.kind !== "break" && !("src" in r2) && "fontSize" in r2
51597
- );
51598
- const fallbackSize = textRunWithSize?.fontSize ?? 12;
51599
- const metrics = calculateTypographyMetrics(fallbackSize, spacing);
51832
+ const metrics = calculateTypographyMetrics(fallbackFontSize, spacing, fallbackFontInfo);
51600
51833
  const emptyLine = {
51601
51834
  fromRun: runIndex,
51602
51835
  fromChar: 0,
@@ -51616,6 +51849,7 @@ async function measureParagraphBlock(block, maxWidth) {
51616
51849
  continue;
51617
51850
  }
51618
51851
  if (isLineBreakRun(run)) {
51852
+ const lineBreakFontInfo = hasSeenTextRun ? void 0 : fallbackFontInfo;
51619
51853
  if (currentLine) {
51620
51854
  const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
51621
51855
  const completedLine = {
@@ -51625,7 +51859,7 @@ async function measureParagraphBlock(block, maxWidth) {
51625
51859
  addBarTabsToLine(completedLine);
51626
51860
  lines.push(completedLine);
51627
51861
  } else {
51628
- const metrics = calculateTypographyMetrics(lastFontSize, spacing);
51862
+ const metrics = calculateTypographyMetrics(lastFontSize, spacing, lineBreakFontInfo);
51629
51863
  const emptyLine = {
51630
51864
  fromRun: runIndex,
51631
51865
  fromChar: 0,
@@ -51648,6 +51882,7 @@ async function measureParagraphBlock(block, maxWidth) {
51648
51882
  toChar: 0,
51649
51883
  width: 0,
51650
51884
  maxFontSize: lastFontSize,
51885
+ maxFontInfo: lineBreakFontInfo,
51651
51886
  maxWidth: nextLineMaxWidth,
51652
51887
  segments: [],
51653
51888
  spaceCount: 0
@@ -51941,6 +52176,7 @@ async function measureParagraphBlock(block, maxWidth) {
51941
52176
  continue;
51942
52177
  }
51943
52178
  lastFontSize = run.fontSize;
52179
+ hasSeenTextRun = true;
51944
52180
  const { font } = buildFontString(run);
51945
52181
  const tabSegments = run.text.split(" ");
51946
52182
  let charPosInRun = 0;
@@ -94905,6 +95141,7 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
94905
95141
  };
94906
95142
  const getExtensions = () => getStarterExtensions();
94907
95143
  const initEditor = async ({ content, media = {}, mediaFiles = {}, fonts = {} } = {}) => {
95144
+ if (!editorElem.value) return;
94908
95145
  const { editorCtor, ...editorOptions } = props.options || {};
94909
95146
  const EditorCtor = editorCtor ?? Editor;
94910
95147
  clearSelectedImage();
@@ -95213,7 +95450,7 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
95213
95450
  };
95214
95451
  }
95215
95452
  });
95216
- const SuperEditor = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-f5c4f915"]]);
95453
+ const SuperEditor = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-bb7d8a50"]]);
95217
95454
  const _hoisted_1 = ["innerHTML"];
95218
95455
  const _sfc_main = {
95219
95456
  __name: "SuperInput",