@harbour-enterprises/superdoc 1.7.0-next.3 → 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.
@@ -1,6 +1,6 @@
1
1
  import { B as Buffer$2 } from "./jszip-B1fkPkPJ.es.js";
2
2
  import { t as twipsToInches, i as inchesToTwips, p as ptToTwips, l as linesToTwips, a as twipsToLines, b as pixelsToTwips, h as halfPointToPoints, c as twipsToPixels$2, d as convertSizeToCSS, e as inchesToPixels } from "./helpers-C8e9wR5l.es.js";
3
- import { g as generateDocxRandomId, T as TextSelection$1, o as objectIncludes, w as wrapTextsInRuns, D as DOMParser$1, c as createDocFromMarkdown, a as createDocFromHTML, b as chainableEditorState, d as convertMarkdownToHTML, f as findParentNode, e as findParentNodeClosestToPos, h as generateRandom32BitHex, i as generateRandomSigned32BitIntStrId, P as PluginKey, j as Plugin, M as Mapping, N as NodeSelection, k as Selection, l as Slice, m as DOMSerializer, F as Fragment, n as Mark$1, p as dropPoint, A as AllSelection, q as Schema$1, s as canSplit, t as resolveRunProperties, u as encodeMarksFromRPr, v as liftTarget, x as canJoin, y as joinPoint, z as replaceStep$1, R as ReplaceAroundStep$1, B as htmlHandler, C as ReplaceStep, E as getResolvedParagraphProperties, G as changeListLevel, H as isList$1, I as updateNumberingProperties, L as ListHelpers, J as inputRulesPlugin, K as TrackDeleteMarkName$1, O as TrackInsertMarkName$1, Q as TrackFormatMarkName$1, U as AddMarkStep, V as RemoveMarkStep, W as CommandService, S as SuperConverter, X as EditorState, Y as unflattenListsInHtml, Z as SelectionRange, _ as Transform, $ as createOoxmlResolver, a0 as translator, a1 as translator$1, a2 as resolveDocxFontFamily, a3 as combineIndentProperties, a4 as _getReferencedTableStyles, a5 as decodeRPrFromMarks, a6 as calculateResolvedParagraphProperties, a7 as encodeCSSFromPPr, a8 as encodeCSSFromRPr, a9 as generateOrderedListIndex, aa as docxNumberingHelpers, ab as InputRule, ac as insertNewRelationship, ad as kebabCase$1, ae as getUnderlineCssString } from "./SuperConverter-C8ixYsv3.es.js";
3
+ import { g as generateDocxRandomId, T as TextSelection$1, o as objectIncludes, w as wrapTextsInRuns, D as DOMParser$1, c as createDocFromMarkdown, a as createDocFromHTML, b as chainableEditorState, d as convertMarkdownToHTML, f as findParentNode, e as findParentNodeClosestToPos, h as generateRandom32BitHex, i as generateRandomSigned32BitIntStrId, P as PluginKey, j as Plugin, M as Mapping, N as NodeSelection, k as Selection, l as Slice, m as DOMSerializer, F as Fragment, n as Mark$1, p as dropPoint, A as AllSelection, q as Schema$1, s as canSplit, t as resolveRunProperties, u as encodeMarksFromRPr, v as liftTarget, x as canJoin, y as joinPoint, z as replaceStep$1, R as ReplaceAroundStep$1, B as htmlHandler, C as ReplaceStep, E as getResolvedParagraphProperties, G as changeListLevel, H as isList$1, I as updateNumberingProperties, L as ListHelpers, J as inputRulesPlugin, K as TrackDeleteMarkName$1, O as TrackInsertMarkName$1, Q as TrackFormatMarkName$1, U as AddMarkStep, V as RemoveMarkStep, W as CommandService, S as SuperConverter, X as EditorState, Y as unflattenListsInHtml, Z as SelectionRange, _ as Transform, $ as createOoxmlResolver, a0 as translator, a1 as translator$1, a2 as resolveDocxFontFamily, a3 as combineIndentProperties, a4 as _getReferencedTableStyles, a5 as decodeRPrFromMarks, a6 as calculateResolvedParagraphProperties, a7 as encodeCSSFromPPr, a8 as encodeCSSFromRPr, a9 as generateOrderedListIndex, aa as docxNumberingHelpers, ab as InputRule, ac as insertNewRelationship, ad as kebabCase$1, ae as getUnderlineCssString } from "./SuperConverter-DU1Tqi67.es.js";
4
4
  import { p as process$1, r as ref, C as global$1, c as computed, E as createElementBlock, F as Fragment$1, S as renderList, O as withModifiers, G as openBlock, P as normalizeClass, M as createCommentVNode, H as toDisplayString, K as createBaseVNode, U as createApp, f as onMounted, X as onUnmounted, R as withDirectives, v as unref, Y as vModelText, y as nextTick, L as normalizeStyle, u as watch, Z as withKeys, _ as createTextVNode, I as createVNode, h as h$1, $ as readonly, s as getCurrentInstance, o as onBeforeUnmount, j as reactive, b as onBeforeMount, i as inject, a0 as onActivated, a1 as onDeactivated, a2 as Comment, d as defineComponent, a as provide, g as Teleport, t as toRef, a3 as renderSlot, a4 as isVNode, D as shallowRef, w as watchEffect, T as Transition, a5 as mergeProps, a6 as vShow, a7 as cloneVNode, a8 as Text$2, m as markRaw, N as createBlock, J as withCtx, a9 as useCssVars, V as resolveDynamicComponent, aa as normalizeProps, ab as guardReactiveProps } from "./vue-BnBKJwCW.es.js";
5
5
  import "./jszip.min-DCl8qkFO.es.js";
6
6
  import { E as EventEmitter$1 } from "./eventemitter3-CwrdEv8r.es.js";
@@ -15771,7 +15771,7 @@ const canUseDOM = () => {
15771
15771
  return false;
15772
15772
  }
15773
15773
  };
15774
- const summaryVersion = "1.7.0-next.3";
15774
+ const summaryVersion = "1.7.0-next.5";
15775
15775
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
15776
15776
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
15777
15777
  function mapAttributes(attrs) {
@@ -18438,7 +18438,7 @@ class Editor extends EventEmitter {
18438
18438
  * Process collaboration migrations
18439
18439
  */
18440
18440
  processCollaborationMigrations() {
18441
- console.debug("[checkVersionMigrations] Current editor version", "1.7.0-next.3");
18441
+ console.debug("[checkVersionMigrations] Current editor version", "1.7.0-next.5");
18442
18442
  if (!this.options.ydoc) return;
18443
18443
  const metaMap = this.options.ydoc.getMap("meta");
18444
18444
  let docVersion = metaMap.get("version");
@@ -24496,6 +24496,69 @@ const resolveTableCellBorders = (tableBorders, rowIndex, colIndex, totalRows, to
24496
24496
  right: borderValueToSpec(isLastCol ? tableBorders?.right : null)
24497
24497
  };
24498
24498
  };
24499
+ const clampNumber = (value, min2, max2) => Math.min(max2, Math.max(min2, value));
24500
+ const mergeSortedSegments = (segments) => {
24501
+ if (segments.length <= 1) return segments;
24502
+ const merged = [];
24503
+ let current = segments[0];
24504
+ for (let i = 1; i < segments.length; i += 1) {
24505
+ const next = segments[i];
24506
+ if (next.start <= current.end) {
24507
+ current = { start: current.start, end: Math.max(current.end, next.end) };
24508
+ continue;
24509
+ }
24510
+ merged.push(current);
24511
+ current = next;
24512
+ }
24513
+ merged.push(current);
24514
+ return merged;
24515
+ };
24516
+ const applySquareWrapExclusionsToLines = (renderedLines, exclusions, contentWidthPx, alignmentOffsetY) => {
24517
+ if (renderedLines.length === 0 || exclusions.length === 0 || contentWidthPx <= 0) return;
24518
+ renderedLines.forEach((line) => {
24519
+ const paddingLeft = line.el.style.paddingLeft;
24520
+ const paddingRight = line.el.style.paddingRight;
24521
+ if (paddingLeft && paddingLeft !== "0px" || paddingRight && paddingRight !== "0px") {
24522
+ return;
24523
+ }
24524
+ const lineTop = line.top + alignmentOffsetY;
24525
+ const lineBottom = lineTop + line.height;
24526
+ const excludedSegments = [];
24527
+ for (const ex of exclusions) {
24528
+ if (lineBottom <= ex.top || lineTop >= ex.bottom) continue;
24529
+ if (ex.wrapText !== "bothSides") continue;
24530
+ const start2 = clampNumber(ex.left, 0, contentWidthPx);
24531
+ const end2 = clampNumber(ex.right, 0, contentWidthPx);
24532
+ if (end2 <= start2) continue;
24533
+ excludedSegments.push({ start: start2, end: end2 });
24534
+ }
24535
+ if (excludedSegments.length === 0) return;
24536
+ excludedSegments.sort((a, b2) => a.start - b2.start);
24537
+ const merged = mergeSortedSegments(excludedSegments);
24538
+ let bestStart = 0;
24539
+ let bestWidth = 0;
24540
+ let cursor = 0;
24541
+ for (const seg of merged) {
24542
+ const gapWidth = seg.start - cursor;
24543
+ if (gapWidth > bestWidth) {
24544
+ bestStart = cursor;
24545
+ bestWidth = gapWidth;
24546
+ }
24547
+ cursor = Math.max(cursor, seg.end);
24548
+ }
24549
+ const tailWidth = contentWidthPx - cursor;
24550
+ if (tailWidth > bestWidth) {
24551
+ bestStart = cursor;
24552
+ bestWidth = tailWidth;
24553
+ }
24554
+ if (bestWidth <= 0 || bestStart === 0 && bestWidth >= contentWidthPx) return;
24555
+ const marginLeft = bestStart;
24556
+ const marginRight = Math.max(0, contentWidthPx - (bestStart + bestWidth));
24557
+ line.el.style.boxSizing = "border-box";
24558
+ line.el.style.marginLeft = `${marginLeft}px`;
24559
+ line.el.style.marginRight = `${marginRight}px`;
24560
+ });
24561
+ };
24499
24562
  function isStructuredContentMetadata(sdt) {
24500
24563
  return sdt !== null && sdt !== void 0 && typeof sdt === "object" && "type" in sdt && sdt.type === "structuredContent";
24501
24564
  }
@@ -24824,6 +24887,7 @@ const renderTableCell = (deps) => {
24824
24887
  content.style.justifyContent = "flex-start";
24825
24888
  }
24826
24889
  cellEl.appendChild(content);
24890
+ content.style.zIndex = "0";
24827
24891
  const blockLineCounts = [];
24828
24892
  for (let i = 0; i < Math.min(blockMeasures.length, cellBlocks.length); i++) {
24829
24893
  const bm = blockMeasures[i];
@@ -24836,6 +24900,12 @@ const renderTableCell = (deps) => {
24836
24900
  const totalLines = blockLineCounts.reduce((a, b2) => a + b2, 0);
24837
24901
  const globalFromLine = fromLine ?? 0;
24838
24902
  const globalToLine = toLine === -1 || toLine === void 0 ? totalLines : toLine;
24903
+ const contentWidthPx = Math.max(0, cellMeasure.width - paddingLeft - paddingRight);
24904
+ const contentHeightPx = Math.max(0, rowHeight - paddingTop - paddingBottom);
24905
+ const paragraphTopById = /* @__PURE__ */ new Map();
24906
+ let flowCursorY = 0;
24907
+ const anchoredBlocks = [];
24908
+ const renderedLines = [];
24839
24909
  let cumulativeLineCount = 0;
24840
24910
  for (let i = 0; i < Math.min(blockMeasures.length, cellBlocks.length); i++) {
24841
24911
  const blockMeasure = blockMeasures[i];
@@ -24858,9 +24928,14 @@ const renderTableCell = (deps) => {
24858
24928
  });
24859
24929
  tableWrapper.appendChild(tableEl);
24860
24930
  content.appendChild(tableWrapper);
24931
+ flowCursorY += tableMeasure.totalHeight;
24861
24932
  continue;
24862
24933
  }
24863
24934
  if (blockMeasure.kind === "image" && block?.kind === "image") {
24935
+ if (block.anchor?.isAnchored) {
24936
+ anchoredBlocks.push({ block, measure: blockMeasure });
24937
+ continue;
24938
+ }
24864
24939
  const imageWrapper = doc2.createElement("div");
24865
24940
  imageWrapper.style.position = "relative";
24866
24941
  imageWrapper.style.width = `${blockMeasure.width}px`;
@@ -24883,9 +24958,14 @@ const renderTableCell = (deps) => {
24883
24958
  imgEl.style.display = "block";
24884
24959
  imageWrapper.appendChild(imgEl);
24885
24960
  content.appendChild(imageWrapper);
24961
+ flowCursorY += blockMeasure.height;
24886
24962
  continue;
24887
24963
  }
24888
24964
  if (blockMeasure.kind === "drawing" && block?.kind === "drawing") {
24965
+ if (block.anchor?.isAnchored) {
24966
+ anchoredBlocks.push({ block, measure: blockMeasure });
24967
+ continue;
24968
+ }
24889
24969
  const drawingWrapper = doc2.createElement("div");
24890
24970
  drawingWrapper.style.position = "relative";
24891
24971
  drawingWrapper.style.width = `${blockMeasure.width}px`;
@@ -24928,12 +25008,14 @@ const renderTableCell = (deps) => {
24928
25008
  }
24929
25009
  drawingWrapper.appendChild(drawingInner);
24930
25010
  content.appendChild(drawingWrapper);
25011
+ flowCursorY += blockMeasure.height;
24931
25012
  continue;
24932
25013
  }
24933
25014
  if (blockMeasure.kind === "paragraph" && block?.kind === "paragraph") {
24934
25015
  const paragraphMeasure = blockMeasure;
24935
25016
  const lines = paragraphMeasure.lines;
24936
25017
  const blockLineCount = lines?.length || 0;
25018
+ paragraphTopById.set(block.id, flowCursorY);
24937
25019
  const wordLayout = block.attrs?.wordLayout ?? null;
24938
25020
  const markerLayout = wordLayout?.marker;
24939
25021
  const markerMeasure = paragraphMeasure.marker;
@@ -24968,6 +25050,7 @@ const renderTableCell = (deps) => {
24968
25050
  for (let lineIdx = localStartLine; lineIdx < localEndLine && lineIdx < lines.length; lineIdx++) {
24969
25051
  const line = lines[lineIdx];
24970
25052
  const isLastLine = lineIdx === lines.length - 1;
25053
+ const lineTop = flowCursorY + renderedHeight;
24971
25054
  const lineEl = renderLine(
24972
25055
  block,
24973
25056
  line,
@@ -24987,6 +25070,7 @@ const renderTableCell = (deps) => {
24987
25070
  markerMeasure,
24988
25071
  indentLeftPx
24989
25072
  });
25073
+ renderedLines.push({ el: lineContainer, top: lineTop, height: line.lineHeight });
24990
25074
  paraWrapper.appendChild(lineContainer);
24991
25075
  } else {
24992
25076
  applyTableCellLineIndentation({
@@ -24999,6 +25083,7 @@ const renderTableCell = (deps) => {
24999
25083
  localStartLine,
25000
25084
  suppressFirstLineIndent
25001
25085
  });
25086
+ renderedLines.push({ el: lineEl, top: lineTop, height: line.lineHeight });
25002
25087
  paraWrapper.appendChild(lineEl);
25003
25088
  }
25004
25089
  renderedHeight += line.lineHeight;
@@ -25011,15 +25096,124 @@ const renderTableCell = (deps) => {
25011
25096
  if (renderedHeight > 0) {
25012
25097
  paraWrapper.style.height = `${renderedHeight}px`;
25013
25098
  }
25099
+ flowCursorY += renderedHeight;
25014
25100
  if (renderedEntireBlock) {
25015
25101
  const spacingAfter = block.attrs?.spacing?.after;
25016
25102
  if (typeof spacingAfter === "number" && spacingAfter > 0) {
25017
25103
  paraWrapper.style.marginBottom = `${spacingAfter}px`;
25104
+ flowCursorY += spacingAfter;
25018
25105
  }
25019
25106
  }
25020
25107
  cumulativeLineCount += blockLineCount;
25021
25108
  }
25022
25109
  }
25110
+ const verticalAlign = cell?.attrs?.verticalAlign;
25111
+ const remainingSpace = contentHeightPx - flowCursorY;
25112
+ const alignmentOffsetY = verticalAlign === "center" ? Math.max(0, remainingSpace / 2) : verticalAlign === "bottom" ? Math.max(0, remainingSpace) : 0;
25113
+ const wrapExclusions = [];
25114
+ for (const entry of anchoredBlocks) {
25115
+ const anchoredBlock = entry.block;
25116
+ const anchoredMeasure = entry.measure;
25117
+ const anchor = anchoredBlock.anchor;
25118
+ if (!anchor || !anchor.isAnchored) {
25119
+ continue;
25120
+ }
25121
+ const objectWidth = anchoredMeasure.width;
25122
+ const objectHeight = anchoredMeasure.height;
25123
+ const left2 = anchor.offsetH ?? 0;
25124
+ const top2 = anchor.offsetV ?? 0;
25125
+ const behindDoc = anchor.behindDoc === true || anchoredBlock.wrap?.type === "None" && anchoredBlock.wrap?.behindDoc;
25126
+ const zIndex = anchoredBlock.kind === "drawing" && typeof anchoredBlock.zIndex === "number" ? anchoredBlock.zIndex : behindDoc ? -1 : 1;
25127
+ const wrap = anchoredBlock.wrap;
25128
+ if (!behindDoc && wrap?.type === "Square") {
25129
+ const wrapText = wrap.wrapText ?? "bothSides";
25130
+ const distLeft = anchoredBlock.padding?.left ?? 0;
25131
+ const distRight = anchoredBlock.padding?.right ?? 0;
25132
+ const distTop = anchoredBlock.padding?.top ?? 0;
25133
+ const distBottom = anchoredBlock.padding?.bottom ?? 0;
25134
+ wrapExclusions.push({
25135
+ left: left2 - distLeft,
25136
+ right: left2 + objectWidth + distRight,
25137
+ top: top2 - distTop,
25138
+ bottom: top2 + objectHeight + distBottom,
25139
+ wrapText
25140
+ });
25141
+ }
25142
+ if (anchoredBlock.kind === "image") {
25143
+ const imageWrapper = doc2.createElement("div");
25144
+ imageWrapper.style.position = "absolute";
25145
+ imageWrapper.style.left = `${left2}px`;
25146
+ imageWrapper.style.top = `${top2}px`;
25147
+ imageWrapper.style.width = `${objectWidth}px`;
25148
+ imageWrapper.style.height = `${objectHeight}px`;
25149
+ imageWrapper.style.maxWidth = "100%";
25150
+ imageWrapper.style.boxSizing = "border-box";
25151
+ imageWrapper.style.zIndex = String(zIndex);
25152
+ applySdtDataset(imageWrapper, anchoredBlock.attrs?.sdt);
25153
+ const imgEl = doc2.createElement("img");
25154
+ imgEl.classList.add("superdoc-table-image");
25155
+ if (anchoredBlock.src) {
25156
+ imgEl.src = anchoredBlock.src;
25157
+ }
25158
+ imgEl.alt = anchoredBlock.alt ?? "";
25159
+ imgEl.style.width = "100%";
25160
+ imgEl.style.height = "100%";
25161
+ imgEl.style.objectFit = anchoredBlock.objectFit ?? "contain";
25162
+ if (anchoredBlock.objectFit === "cover") {
25163
+ imgEl.style.objectPosition = "left top";
25164
+ }
25165
+ imgEl.style.display = "block";
25166
+ imageWrapper.appendChild(imgEl);
25167
+ content.appendChild(imageWrapper);
25168
+ } else {
25169
+ const drawingWrapper = doc2.createElement("div");
25170
+ drawingWrapper.style.position = "absolute";
25171
+ drawingWrapper.style.left = `${left2}px`;
25172
+ drawingWrapper.style.top = `${top2}px`;
25173
+ drawingWrapper.style.width = `${objectWidth}px`;
25174
+ drawingWrapper.style.height = `${objectHeight}px`;
25175
+ drawingWrapper.style.maxWidth = "100%";
25176
+ drawingWrapper.style.boxSizing = "border-box";
25177
+ drawingWrapper.style.zIndex = String(zIndex);
25178
+ applySdtDataset(drawingWrapper, anchoredBlock.attrs);
25179
+ const drawingInner = doc2.createElement("div");
25180
+ drawingInner.classList.add("superdoc-table-drawing");
25181
+ drawingInner.style.width = "100%";
25182
+ drawingInner.style.height = "100%";
25183
+ drawingInner.style.display = "flex";
25184
+ drawingInner.style.alignItems = "center";
25185
+ drawingInner.style.justifyContent = "center";
25186
+ drawingInner.style.overflow = "hidden";
25187
+ if (anchoredBlock.drawingKind === "image" && "src" in anchoredBlock && anchoredBlock.src) {
25188
+ const img = doc2.createElement("img");
25189
+ img.classList.add("superdoc-drawing-image");
25190
+ img.src = anchoredBlock.src;
25191
+ img.alt = anchoredBlock.alt ?? "";
25192
+ img.style.width = "100%";
25193
+ img.style.height = "100%";
25194
+ img.style.objectFit = anchoredBlock.objectFit ?? "contain";
25195
+ if (anchoredBlock.objectFit === "cover") {
25196
+ img.style.objectPosition = "left top";
25197
+ }
25198
+ drawingInner.appendChild(img);
25199
+ } else if (renderDrawingContent) {
25200
+ const drawingContent = renderDrawingContent(anchoredBlock);
25201
+ drawingContent.style.width = "100%";
25202
+ drawingContent.style.height = "100%";
25203
+ drawingInner.appendChild(drawingContent);
25204
+ } else {
25205
+ const placeholder = doc2.createElement("div");
25206
+ placeholder.style.width = "100%";
25207
+ placeholder.style.height = "100%";
25208
+ placeholder.style.background = "repeating-linear-gradient(45deg, rgba(15,23,42,0.1), rgba(15,23,42,0.1) 6px, rgba(15,23,42,0.2) 6px, rgba(15,23,42,0.2) 12px)";
25209
+ placeholder.style.border = "1px dashed rgba(15, 23, 42, 0.3)";
25210
+ drawingInner.appendChild(placeholder);
25211
+ }
25212
+ drawingWrapper.appendChild(drawingInner);
25213
+ content.appendChild(drawingWrapper);
25214
+ }
25215
+ }
25216
+ applySquareWrapExclusionsToLines(renderedLines, wrapExclusions, contentWidthPx, alignmentOffsetY);
25023
25217
  }
25024
25218
  return { cellElement: cellEl };
25025
25219
  };
@@ -27973,8 +28167,8 @@ class DomPainter {
27973
28167
  groupEl.style.height = "100%";
27974
28168
  const groupTransform = block.groupTransform;
27975
28169
  let contentContainer = groupEl;
27976
- let groupScaleX = 1;
27977
- let groupScaleY = 1;
28170
+ const groupScaleX = 1;
28171
+ const groupScaleY = 1;
27978
28172
  if (groupTransform) {
27979
28173
  const inner = this.doc.createElement("div");
27980
28174
  inner.style.position = "absolute";
@@ -27990,13 +28184,6 @@ class DomPainter {
27990
28184
  if (offsetX || offsetY) {
27991
28185
  transforms.push(`translate(${-offsetX}px, ${-offsetY}px)`);
27992
28186
  }
27993
- const targetWidth = groupTransform.width ?? block.geometry.width ?? childWidth;
27994
- const targetHeight = groupTransform.height ?? block.geometry.height ?? childHeight;
27995
- groupScaleX = childWidth ? targetWidth / childWidth : 1;
27996
- groupScaleY = childHeight ? targetHeight / childHeight : 1;
27997
- if (groupScaleX !== 1 || groupScaleY !== 1) {
27998
- transforms.push(`scale(${groupScaleX}, ${groupScaleY})`);
27999
- }
28000
28187
  if (transforms.length > 0) {
28001
28188
  inner.style.transformOrigin = "top left";
28002
28189
  inner.style.transform = transforms.join(" ");
@@ -32912,7 +33099,7 @@ const getParagraphAttrs = (block) => {
32912
33099
  const asString = (value) => {
32913
33100
  return typeof value === "string" ? value : void 0;
32914
33101
  };
32915
- const asBoolean = (value) => {
33102
+ const asBoolean$1 = (value) => {
32916
33103
  if (value === true || value === 1) return true;
32917
33104
  if (typeof value === "string") {
32918
33105
  const normalized = value.toLowerCase();
@@ -33093,8 +33280,9 @@ function layoutParagraphBlock(ctx2, anchors) {
33093
33280
  const attrs = getParagraphAttrs(block);
33094
33281
  const spacing = attrs?.spacing ?? {};
33095
33282
  const styleId = asString(attrs?.styleId);
33096
- const contextualSpacing = asBoolean(attrs?.contextualSpacing);
33283
+ const contextualSpacing = asBoolean$1(attrs?.contextualSpacing);
33097
33284
  let spacingBefore = Math.max(0, Number(spacing.before ?? spacing.lineSpaceBefore ?? 0));
33285
+ const baseSpacingBefore = spacingBefore;
33098
33286
  const spacingAfter = Math.max(0, Number(spacing.after ?? spacing.lineSpaceAfter ?? 0));
33099
33287
  let appliedSpacingBefore = spacingBefore === 0;
33100
33288
  let lastState = null;
@@ -33189,6 +33377,21 @@ function layoutParagraphBlock(ctx2, anchors) {
33189
33377
  state.trailingSpacing = 0;
33190
33378
  }
33191
33379
  }
33380
+ const keepLines = attrs?.keepLines === true;
33381
+ if (keepLines && fromLine === 0) {
33382
+ const prevTrailing = state.trailingSpacing ?? 0;
33383
+ const neededSpacingBefore = Math.max(spacingBefore - prevTrailing, 0);
33384
+ const pageContentHeight = state.contentBottom - state.topMargin;
33385
+ const fullHeight = lines.reduce((sum, line) => sum + (line.lineHeight || 0), 0);
33386
+ const fitsOnBlankPage = fullHeight + baseSpacingBefore <= pageContentHeight;
33387
+ const remainingHeightAfterSpacing = state.contentBottom - (state.cursorY + neededSpacingBefore);
33388
+ if (fitsOnBlankPage && state.page.fragments.length > 0 && fullHeight > remainingHeightAfterSpacing) {
33389
+ state = advanceColumn(state);
33390
+ spacingBefore = baseSpacingBefore;
33391
+ appliedSpacingBefore = spacingBefore === 0;
33392
+ continue;
33393
+ }
33394
+ }
33192
33395
  if (!appliedSpacingBefore && spacingBefore > 0) {
33193
33396
  while (!appliedSpacingBefore) {
33194
33397
  const prevTrailing = state.trailingSpacing ?? 0;
@@ -34432,6 +34635,14 @@ function getMeasureHeight(block, measure) {
34432
34635
  const DEFAULT_PAGE_SIZE$2 = { w: 612, h: 792 };
34433
34636
  const DEFAULT_MARGINS$2 = { top: 72, right: 72, bottom: 72, left: 72 };
34434
34637
  const COLUMN_EPSILON$1 = 1e-4;
34638
+ const asBoolean = (value) => {
34639
+ if (value === true || value === 1) return true;
34640
+ if (typeof value === "string") {
34641
+ const normalized = value.toLowerCase();
34642
+ return normalized === "true" || normalized === "1" || normalized === "on";
34643
+ }
34644
+ return false;
34645
+ };
34435
34646
  const layoutDebugEnabled$1 = typeof process$1 !== "undefined" && typeof process$1.env !== "undefined" && Boolean(process$1.env.SD_DEBUG_LAYOUT);
34436
34647
  const layoutLog = (...args) => {
34437
34648
  if (!layoutDebugEnabled$1) return;
@@ -34544,7 +34755,7 @@ function layoutDocument(blocks, measures, options = {}) {
34544
34755
  let activeOrientation = null;
34545
34756
  let pendingOrientation = null;
34546
34757
  let activeVAlign = null;
34547
- let pendingVAlign = null;
34758
+ let pendingVAlign = void 0;
34548
34759
  const paginatorMargins = { left: activeLeftMargin, right: activeRightMargin };
34549
34760
  const floatManager = createFloatingObjectManager(
34550
34761
  normalizeColumns(activeColumns, activePageSize.w - (activeLeftMargin + activeRightMargin)),
@@ -34717,6 +34928,10 @@ function layoutDocument(blocks, measures, options = {}) {
34717
34928
  }
34718
34929
  if (activeVAlign && activeVAlign !== "top") {
34719
34930
  page.vAlign = activeVAlign;
34931
+ page.baseMargins = {
34932
+ top: activeSectionBaseTopMargin,
34933
+ bottom: activeSectionBaseBottomMargin
34934
+ };
34720
34935
  }
34721
34936
  return page;
34722
34937
  };
@@ -34751,6 +34966,9 @@ function layoutDocument(blocks, measures, options = {}) {
34751
34966
  ...initialSectionMetadata.footerRefs && { footerRefs: initialSectionMetadata.footerRefs }
34752
34967
  };
34753
34968
  }
34969
+ if (initialSectionMetadata?.vAlign) {
34970
+ activeVAlign = initialSectionMetadata.vAlign;
34971
+ }
34754
34972
  let activeSectionIndex = initialSectionMetadata?.sectionIndex ?? 0;
34755
34973
  let pendingSectionIndex = null;
34756
34974
  const sectionFirstPageNumbers = /* @__PURE__ */ new Map();
@@ -34837,9 +35055,9 @@ function layoutDocument(blocks, measures, options = {}) {
34837
35055
  activeSectionIndex = pendingSectionIndex;
34838
35056
  pendingSectionIndex = null;
34839
35057
  }
34840
- if (pendingVAlign !== null) {
35058
+ if (pendingVAlign !== void 0) {
34841
35059
  activeVAlign = pendingVAlign;
34842
- pendingVAlign = null;
35060
+ pendingVAlign = void 0;
34843
35061
  }
34844
35062
  if (pendingSectionBaseTopMargin !== null) {
34845
35063
  activeSectionBaseTopMargin = pendingSectionBaseTopMargin;
@@ -35123,14 +35341,13 @@ function layoutDocument(blocks, measures, options = {}) {
35123
35341
  pendingSectionBaseBottomMargin = typeof blockBottomMargin === "number" ? blockBottomMargin : margins.bottom;
35124
35342
  }
35125
35343
  }
35126
- if (effectiveBlock.vAlign) {
35127
- const isFirstSection2 = effectiveBlock.attrs?.isFirstSection && states.length === 0;
35128
- if (isFirstSection2) {
35129
- activeVAlign = effectiveBlock.vAlign;
35130
- pendingVAlign = null;
35131
- } else {
35132
- pendingVAlign = effectiveBlock.vAlign;
35133
- }
35344
+ const sectionVAlign = effectiveBlock.vAlign ?? null;
35345
+ const isFirstSectionForVAlign = effectiveBlock.attrs?.isFirstSection && states.length === 0;
35346
+ if (isFirstSectionForVAlign) {
35347
+ activeVAlign = sectionVAlign;
35348
+ pendingVAlign = void 0;
35349
+ } else {
35350
+ pendingVAlign = sectionVAlign;
35134
35351
  }
35135
35352
  if (effectiveBlock.headerRefs || effectiveBlock.footerRefs) {
35136
35353
  const baseSectionRefs = pendingSectionRefs ?? activeSectionRefs;
@@ -35249,11 +35466,23 @@ function layoutDocument(blocks, measures, options = {}) {
35249
35466
  if (!shouldSkipAnchoredTable) {
35250
35467
  let state = paginator.ensurePage();
35251
35468
  const availableHeight = state.contentBottom - state.cursorY;
35469
+ const spacingBefore = getParagraphSpacingBefore(paraBlock);
35252
35470
  const spacingAfter = getParagraphSpacingAfter$1(paraBlock);
35471
+ const prevTrailing = Number.isFinite(state.trailingSpacing) && state.trailingSpacing > 0 ? state.trailingSpacing : 0;
35472
+ const currentStyleId = typeof paraBlock.attrs?.styleId === "string" ? paraBlock.attrs?.styleId : void 0;
35473
+ const currentContextualSpacing = asBoolean(paraBlock.attrs?.contextualSpacing);
35474
+ const contextualSpacingApplies = currentContextualSpacing && currentStyleId && state.lastParagraphStyleId === currentStyleId;
35475
+ const effectiveSpacingBefore = contextualSpacingApplies ? 0 : Math.max(spacingBefore - prevTrailing, 0);
35253
35476
  const currentHeight = getMeasureHeight(paraBlock, measure);
35254
35477
  const nextHeight = getMeasureHeight(nextBlock, nextMeasure);
35255
35478
  const nextIsParagraph = nextBlock.kind === "paragraph" && nextMeasure.kind === "paragraph";
35256
35479
  const nextSpacingBefore = nextIsParagraph ? getParagraphSpacingBefore(nextBlock) : 0;
35480
+ const nextStyleId = nextIsParagraph && typeof nextBlock.attrs?.styleId === "string" ? nextBlock.attrs?.styleId : void 0;
35481
+ const nextContextualSpacing = nextIsParagraph && asBoolean(nextBlock.attrs?.contextualSpacing);
35482
+ const sameStyleAsNext = currentStyleId && nextStyleId && nextStyleId === currentStyleId;
35483
+ const effectiveSpacingAfter = currentContextualSpacing && sameStyleAsNext ? 0 : spacingAfter;
35484
+ const effectiveNextSpacingBefore = nextContextualSpacing && sameStyleAsNext ? 0 : nextSpacingBefore;
35485
+ const interParagraphSpacing = nextIsParagraph ? Math.max(effectiveSpacingAfter, effectiveNextSpacingBefore) : effectiveSpacingAfter;
35257
35486
  const nextFirstLineHeight = (() => {
35258
35487
  if (!nextIsParagraph) {
35259
35488
  return nextHeight;
@@ -35264,8 +35493,9 @@ function layoutDocument(blocks, measures, options = {}) {
35264
35493
  }
35265
35494
  return nextHeight;
35266
35495
  })();
35267
- const combinedHeight = nextIsParagraph ? currentHeight + Math.max(spacingAfter, nextSpacingBefore) + nextFirstLineHeight : currentHeight + spacingAfter + nextHeight;
35268
- if (combinedHeight > availableHeight && state.page.fragments.length > 0) {
35496
+ const combinedHeight = nextIsParagraph ? effectiveSpacingBefore + currentHeight + interParagraphSpacing + nextFirstLineHeight : effectiveSpacingBefore + currentHeight + spacingAfter + nextHeight;
35497
+ const effectiveAvailableHeight = contextualSpacingApplies ? availableHeight + prevTrailing : availableHeight;
35498
+ if (combinedHeight > effectiveAvailableHeight && state.page.fragments.length > 0) {
35269
35499
  state = paginator.advanceColumn(state);
35270
35500
  }
35271
35501
  }
@@ -35411,11 +35641,17 @@ function layoutDocument(blocks, measures, options = {}) {
35411
35641
  pages.pop();
35412
35642
  }
35413
35643
  for (const page of pages) {
35414
- if (!page.vAlign || page.vAlign === "top") continue;
35415
- if (page.fragments.length === 0) continue;
35644
+ if (!page.vAlign || page.vAlign === "top") {
35645
+ continue;
35646
+ }
35647
+ if (page.fragments.length === 0) {
35648
+ continue;
35649
+ }
35416
35650
  const pageSizeForPage = page.size ?? pageSize;
35417
- const contentTop = page.margins?.top ?? margins.top;
35418
- const contentBottom = pageSizeForPage.h - (page.margins?.bottom ?? margins.bottom);
35651
+ const baseTop = page.baseMargins?.top ?? page.margins?.top ?? margins.top;
35652
+ const baseBottom = page.baseMargins?.bottom ?? page.margins?.bottom ?? margins.bottom;
35653
+ const contentTop = baseTop;
35654
+ const contentBottom = pageSizeForPage.h - baseBottom;
35419
35655
  const contentHeight = contentBottom - contentTop;
35420
35656
  let minY = Infinity;
35421
35657
  let maxY = -Infinity;
@@ -42516,7 +42752,9 @@ function buildSectionRangesFromParagraphs(paragraphs, hasBodySectPr) {
42516
42752
  return ranges;
42517
42753
  }
42518
42754
  function publishSectionMetadata(sectionRanges, options) {
42519
- if (!options?.sectionMetadata) return;
42755
+ if (!options?.sectionMetadata) {
42756
+ return;
42757
+ }
42520
42758
  options.sectionMetadata.length = 0;
42521
42759
  sectionRanges.forEach((section) => {
42522
42760
  options.sectionMetadata?.push({
@@ -42524,7 +42762,8 @@ function publishSectionMetadata(sectionRanges, options) {
42524
42762
  headerRefs: section.headerRefs,
42525
42763
  footerRefs: section.footerRefs,
42526
42764
  numbering: section.numbering,
42527
- titlePg: section.titlePg
42765
+ titlePg: section.titlePg,
42766
+ vAlign: section.vAlign
42528
42767
  });
42529
42768
  });
42530
42769
  }
@@ -51241,6 +51480,11 @@ async function measureParagraphBlock(block, maxWidth) {
51241
51480
  totalHeight: metrics.lineHeight
51242
51481
  };
51243
51482
  }
51483
+ const firstTextRunWithSize = block.runs.find(
51484
+ (run) => "text" in run && "fontSize" in run && typeof run.fontSize === "number"
51485
+ );
51486
+ const fallbackFontSize = firstTextRunWithSize?.fontSize ?? 12;
51487
+ const fallbackFontInfo = firstTextRunWithSize ? getFontInfoFromRun(firstTextRunWithSize) : void 0;
51244
51488
  let currentLine = null;
51245
51489
  const getEffectiveWidth = (baseWidth) => {
51246
51490
  if (dropCapMeasure && lines.length < dropCapMeasure.lines && dropCapMeasure.mode === "drop") {
@@ -51248,7 +51492,8 @@ async function measureParagraphBlock(block, maxWidth) {
51248
51492
  }
51249
51493
  return baseWidth;
51250
51494
  };
51251
- let lastFontSize = 12;
51495
+ let lastFontSize = fallbackFontSize;
51496
+ let hasSeenTextRun = false;
51252
51497
  let tabStopCursor = 0;
51253
51498
  let pendingTabAlignment = null;
51254
51499
  let pendingRunSpacing = 0;
@@ -51373,11 +51618,7 @@ async function measureParagraphBlock(block, maxWidth) {
51373
51618
  lines.push(completedLine);
51374
51619
  currentLine = null;
51375
51620
  } else {
51376
- const textRunWithSize = block.runs.find(
51377
- (r2) => r2.kind !== "tab" && r2.kind !== "lineBreak" && r2.kind !== "break" && !("src" in r2) && "fontSize" in r2
51378
- );
51379
- const fallbackSize = textRunWithSize?.fontSize ?? 12;
51380
- const metrics = calculateTypographyMetrics(fallbackSize, spacing);
51621
+ const metrics = calculateTypographyMetrics(fallbackFontSize, spacing, fallbackFontInfo);
51381
51622
  const emptyLine = {
51382
51623
  fromRun: runIndex,
51383
51624
  fromChar: 0,
@@ -51397,6 +51638,7 @@ async function measureParagraphBlock(block, maxWidth) {
51397
51638
  continue;
51398
51639
  }
51399
51640
  if (isLineBreakRun(run)) {
51641
+ const lineBreakFontInfo = hasSeenTextRun ? void 0 : fallbackFontInfo;
51400
51642
  if (currentLine) {
51401
51643
  const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
51402
51644
  const completedLine = {
@@ -51406,7 +51648,7 @@ async function measureParagraphBlock(block, maxWidth) {
51406
51648
  addBarTabsToLine(completedLine);
51407
51649
  lines.push(completedLine);
51408
51650
  } else {
51409
- const metrics = calculateTypographyMetrics(lastFontSize, spacing);
51651
+ const metrics = calculateTypographyMetrics(lastFontSize, spacing, lineBreakFontInfo);
51410
51652
  const emptyLine = {
51411
51653
  fromRun: runIndex,
51412
51654
  fromChar: 0,
@@ -51429,6 +51671,7 @@ async function measureParagraphBlock(block, maxWidth) {
51429
51671
  toChar: 0,
51430
51672
  width: 0,
51431
51673
  maxFontSize: lastFontSize,
51674
+ maxFontInfo: lineBreakFontInfo,
51432
51675
  maxWidth: nextLineMaxWidth,
51433
51676
  segments: [],
51434
51677
  spaceCount: 0
@@ -51722,6 +51965,7 @@ async function measureParagraphBlock(block, maxWidth) {
51722
51965
  continue;
51723
51966
  }
51724
51967
  lastFontSize = run.fontSize;
51968
+ hasSeenTextRun = true;
51725
51969
  const { font } = buildFontString(run);
51726
51970
  const tabSegments = run.text.split(" ");
51727
51971
  let charPosInRun = 0;
@@ -52389,6 +52633,10 @@ async function measureTableBlock(block, constraints) {
52389
52633
  const measure = await measureBlock(block2, { maxWidth: contentWidth, maxHeight: Infinity });
52390
52634
  blockMeasures.push(measure);
52391
52635
  const blockHeight = "totalHeight" in measure ? measure.totalHeight : "height" in measure ? measure.height : 0;
52636
+ const isAnchoredOutOfFlow = (block2.kind === "image" || block2.kind === "drawing") && block2.anchor?.isAnchored === true && (block2.wrap?.type ?? "Inline") !== "Inline";
52637
+ if (isAnchoredOutOfFlow) {
52638
+ continue;
52639
+ }
52392
52640
  contentHeight += blockHeight;
52393
52641
  if (block2.kind === "paragraph") {
52394
52642
  const spacingAfter = block2.attrs?.spacing?.after;
@@ -94682,6 +94930,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
94682
94930
  };
94683
94931
  const getExtensions = () => getStarterExtensions();
94684
94932
  const initEditor = async ({ content, media = {}, mediaFiles = {}, fonts = {} } = {}) => {
94933
+ if (!editorElem.value) return;
94685
94934
  const { editorCtor, ...editorOptions } = props.options || {};
94686
94935
  const EditorCtor = editorCtor ?? Editor;
94687
94936
  clearSelectedImage();
@@ -94990,7 +95239,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
94990
95239
  };
94991
95240
  }
94992
95241
  });
94993
- const SuperEditor = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-f5c4f915"]]);
95242
+ const SuperEditor = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-bb7d8a50"]]);
94994
95243
  const _hoisted_1 = ["innerHTML"];
94995
95244
  const _sfc_main = {
94996
95245
  __name: "SuperInput",