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

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.4") {
38200
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.7.0-next.5") {
38201
38201
  return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
38202
38202
  }
38203
38203
  /**
@@ -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.4";
64370
+ const summaryVersion = "1.7.0-next.5";
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.4");
67038
+ console.debug("[checkVersionMigrations] Current editor version", "1.7.0-next.5");
67039
67039
  if (!this.options.ydoc) return;
67040
67040
  const metaMap = this.options.ydoc.getMap("meta");
67041
67041
  let docVersion = metaMap.get("version");
@@ -81696,7 +81696,7 @@ ${o}
81696
81696
  const asString = (value) => {
81697
81697
  return typeof value === "string" ? value : void 0;
81698
81698
  };
81699
- const asBoolean = (value) => {
81699
+ const asBoolean$1 = (value) => {
81700
81700
  if (value === true || value === 1) return true;
81701
81701
  if (typeof value === "string") {
81702
81702
  const normalized = value.toLowerCase();
@@ -81877,8 +81877,9 @@ ${o}
81877
81877
  const attrs = getParagraphAttrs(block);
81878
81878
  const spacing = attrs?.spacing ?? {};
81879
81879
  const styleId = asString(attrs?.styleId);
81880
- const contextualSpacing = asBoolean(attrs?.contextualSpacing);
81880
+ const contextualSpacing = asBoolean$1(attrs?.contextualSpacing);
81881
81881
  let spacingBefore = Math.max(0, Number(spacing.before ?? spacing.lineSpaceBefore ?? 0));
81882
+ const baseSpacingBefore = spacingBefore;
81882
81883
  const spacingAfter = Math.max(0, Number(spacing.after ?? spacing.lineSpaceAfter ?? 0));
81883
81884
  let appliedSpacingBefore = spacingBefore === 0;
81884
81885
  let lastState = null;
@@ -81973,6 +81974,21 @@ ${o}
81973
81974
  state.trailingSpacing = 0;
81974
81975
  }
81975
81976
  }
81977
+ const keepLines = attrs?.keepLines === true;
81978
+ if (keepLines && fromLine === 0) {
81979
+ const prevTrailing = state.trailingSpacing ?? 0;
81980
+ const neededSpacingBefore = Math.max(spacingBefore - prevTrailing, 0);
81981
+ const pageContentHeight = state.contentBottom - state.topMargin;
81982
+ const fullHeight = lines.reduce((sum, line) => sum + (line.lineHeight || 0), 0);
81983
+ const fitsOnBlankPage = fullHeight + baseSpacingBefore <= pageContentHeight;
81984
+ const remainingHeightAfterSpacing = state.contentBottom - (state.cursorY + neededSpacingBefore);
81985
+ if (fitsOnBlankPage && state.page.fragments.length > 0 && fullHeight > remainingHeightAfterSpacing) {
81986
+ state = advanceColumn(state);
81987
+ spacingBefore = baseSpacingBefore;
81988
+ appliedSpacingBefore = spacingBefore === 0;
81989
+ continue;
81990
+ }
81991
+ }
81976
81992
  if (!appliedSpacingBefore && spacingBefore > 0) {
81977
81993
  while (!appliedSpacingBefore) {
81978
81994
  const prevTrailing = state.trailingSpacing ?? 0;
@@ -83217,6 +83233,14 @@ ${o}
83217
83233
  const DEFAULT_PAGE_SIZE$2 = { w: 612, h: 792 };
83218
83234
  const DEFAULT_MARGINS$2 = { top: 72, right: 72, bottom: 72, left: 72 };
83219
83235
  const COLUMN_EPSILON$1 = 1e-4;
83236
+ const asBoolean = (value) => {
83237
+ if (value === true || value === 1) return true;
83238
+ if (typeof value === "string") {
83239
+ const normalized = value.toLowerCase();
83240
+ return normalized === "true" || normalized === "1" || normalized === "on";
83241
+ }
83242
+ return false;
83243
+ };
83220
83244
  const layoutDebugEnabled$1 = typeof define_process_default$4 !== "undefined" && typeof define_process_default$4.env !== "undefined" && Boolean(define_process_default$4.env.SD_DEBUG_LAYOUT);
83221
83245
  const layoutLog = (...args) => {
83222
83246
  if (!layoutDebugEnabled$1) return;
@@ -84040,11 +84064,23 @@ ${o}
84040
84064
  if (!shouldSkipAnchoredTable) {
84041
84065
  let state = paginator.ensurePage();
84042
84066
  const availableHeight = state.contentBottom - state.cursorY;
84067
+ const spacingBefore = getParagraphSpacingBefore(paraBlock);
84043
84068
  const spacingAfter = getParagraphSpacingAfter$1(paraBlock);
84069
+ const prevTrailing = Number.isFinite(state.trailingSpacing) && state.trailingSpacing > 0 ? state.trailingSpacing : 0;
84070
+ const currentStyleId = typeof paraBlock.attrs?.styleId === "string" ? paraBlock.attrs?.styleId : void 0;
84071
+ const currentContextualSpacing = asBoolean(paraBlock.attrs?.contextualSpacing);
84072
+ const contextualSpacingApplies = currentContextualSpacing && currentStyleId && state.lastParagraphStyleId === currentStyleId;
84073
+ const effectiveSpacingBefore = contextualSpacingApplies ? 0 : Math.max(spacingBefore - prevTrailing, 0);
84044
84074
  const currentHeight = getMeasureHeight(paraBlock, measure);
84045
84075
  const nextHeight = getMeasureHeight(nextBlock, nextMeasure);
84046
84076
  const nextIsParagraph = nextBlock.kind === "paragraph" && nextMeasure.kind === "paragraph";
84047
84077
  const nextSpacingBefore = nextIsParagraph ? getParagraphSpacingBefore(nextBlock) : 0;
84078
+ const nextStyleId = nextIsParagraph && typeof nextBlock.attrs?.styleId === "string" ? nextBlock.attrs?.styleId : void 0;
84079
+ const nextContextualSpacing = nextIsParagraph && asBoolean(nextBlock.attrs?.contextualSpacing);
84080
+ const sameStyleAsNext = currentStyleId && nextStyleId && nextStyleId === currentStyleId;
84081
+ const effectiveSpacingAfter = currentContextualSpacing && sameStyleAsNext ? 0 : spacingAfter;
84082
+ const effectiveNextSpacingBefore = nextContextualSpacing && sameStyleAsNext ? 0 : nextSpacingBefore;
84083
+ const interParagraphSpacing = nextIsParagraph ? Math.max(effectiveSpacingAfter, effectiveNextSpacingBefore) : effectiveSpacingAfter;
84048
84084
  const nextFirstLineHeight = (() => {
84049
84085
  if (!nextIsParagraph) {
84050
84086
  return nextHeight;
@@ -84055,8 +84091,9 @@ ${o}
84055
84091
  }
84056
84092
  return nextHeight;
84057
84093
  })();
84058
- const combinedHeight = nextIsParagraph ? currentHeight + Math.max(spacingAfter, nextSpacingBefore) + nextFirstLineHeight : currentHeight + spacingAfter + nextHeight;
84059
- if (combinedHeight > availableHeight && state.page.fragments.length > 0) {
84094
+ const combinedHeight = nextIsParagraph ? effectiveSpacingBefore + currentHeight + interParagraphSpacing + nextFirstLineHeight : effectiveSpacingBefore + currentHeight + spacingAfter + nextHeight;
84095
+ const effectiveAvailableHeight = contextualSpacingApplies ? availableHeight + prevTrailing : availableHeight;
84096
+ if (combinedHeight > effectiveAvailableHeight && state.page.fragments.length > 0) {
84060
84097
  state = paginator.advanceColumn(state);
84061
84098
  }
84062
84099
  }
@@ -99988,6 +100025,11 @@ ${o}
99988
100025
  totalHeight: metrics.lineHeight
99989
100026
  };
99990
100027
  }
100028
+ const firstTextRunWithSize = block.runs.find(
100029
+ (run2) => "text" in run2 && "fontSize" in run2 && typeof run2.fontSize === "number"
100030
+ );
100031
+ const fallbackFontSize = firstTextRunWithSize?.fontSize ?? 12;
100032
+ const fallbackFontInfo = firstTextRunWithSize ? getFontInfoFromRun(firstTextRunWithSize) : void 0;
99991
100033
  let currentLine = null;
99992
100034
  const getEffectiveWidth = (baseWidth) => {
99993
100035
  if (dropCapMeasure && lines.length < dropCapMeasure.lines && dropCapMeasure.mode === "drop") {
@@ -99995,7 +100037,8 @@ ${o}
99995
100037
  }
99996
100038
  return baseWidth;
99997
100039
  };
99998
- let lastFontSize = 12;
100040
+ let lastFontSize = fallbackFontSize;
100041
+ let hasSeenTextRun = false;
99999
100042
  let tabStopCursor = 0;
100000
100043
  let pendingTabAlignment = null;
100001
100044
  let pendingRunSpacing = 0;
@@ -100120,11 +100163,7 @@ ${o}
100120
100163
  lines.push(completedLine);
100121
100164
  currentLine = null;
100122
100165
  } else {
100123
- const textRunWithSize = block.runs.find(
100124
- (r2) => r2.kind !== "tab" && r2.kind !== "lineBreak" && r2.kind !== "break" && !("src" in r2) && "fontSize" in r2
100125
- );
100126
- const fallbackSize = textRunWithSize?.fontSize ?? 12;
100127
- const metrics = calculateTypographyMetrics(fallbackSize, spacing);
100166
+ const metrics = calculateTypographyMetrics(fallbackFontSize, spacing, fallbackFontInfo);
100128
100167
  const emptyLine = {
100129
100168
  fromRun: runIndex,
100130
100169
  fromChar: 0,
@@ -100144,6 +100183,7 @@ ${o}
100144
100183
  continue;
100145
100184
  }
100146
100185
  if (isLineBreakRun(run2)) {
100186
+ const lineBreakFontInfo = hasSeenTextRun ? void 0 : fallbackFontInfo;
100147
100187
  if (currentLine) {
100148
100188
  const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
100149
100189
  const completedLine = {
@@ -100153,7 +100193,7 @@ ${o}
100153
100193
  addBarTabsToLine(completedLine);
100154
100194
  lines.push(completedLine);
100155
100195
  } else {
100156
- const metrics = calculateTypographyMetrics(lastFontSize, spacing);
100196
+ const metrics = calculateTypographyMetrics(lastFontSize, spacing, lineBreakFontInfo);
100157
100197
  const emptyLine = {
100158
100198
  fromRun: runIndex,
100159
100199
  fromChar: 0,
@@ -100176,6 +100216,7 @@ ${o}
100176
100216
  toChar: 0,
100177
100217
  width: 0,
100178
100218
  maxFontSize: lastFontSize,
100219
+ maxFontInfo: lineBreakFontInfo,
100179
100220
  maxWidth: nextLineMaxWidth,
100180
100221
  segments: [],
100181
100222
  spaceCount: 0
@@ -100469,6 +100510,7 @@ ${o}
100469
100510
  continue;
100470
100511
  }
100471
100512
  lastFontSize = run2.fontSize;
100513
+ hasSeenTextRun = true;
100472
100514
  const { font } = buildFontString(run2);
100473
100515
  const tabSegments = run2.text.split(" ");
100474
100516
  let charPosInRun = 0;
@@ -145465,6 +145507,7 @@ ${style2}
145465
145507
  };
145466
145508
  const getExtensions = () => getStarterExtensions();
145467
145509
  const initEditor = async ({ content: content2, media: media2 = {}, mediaFiles = {}, fonts = {} } = {}) => {
145510
+ if (!editorElem.value) return;
145468
145511
  const { editorCtor, ...editorOptions } = props.options || {};
145469
145512
  const EditorCtor = editorCtor ?? Editor;
145470
145513
  clearSelectedImage();
@@ -145773,7 +145816,7 @@ ${style2}
145773
145816
  };
145774
145817
  }
145775
145818
  });
145776
- const SuperEditor = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["__scopeId", "data-v-f5c4f915"]]);
145819
+ const SuperEditor = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["__scopeId", "data-v-bb7d8a50"]]);
145777
145820
  const _hoisted_1$h = ["innerHTML"];
145778
145821
  const _sfc_main$i = {
145779
145822
  __name: "SuperInput",
@@ -150924,7 +150967,7 @@ ${reason}`);
150924
150967
  this.config.colors = shuffleArray(this.config.colors);
150925
150968
  this.userColorMap = /* @__PURE__ */ new Map();
150926
150969
  this.colorIndex = 0;
150927
- this.version = "1.7.0-next.4";
150970
+ this.version = "1.7.0-next.5";
150928
150971
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
150929
150972
  this.superdocId = config2.superdocId || v4();
150930
150973
  this.colors = this.config.colors;