@superdoc-dev/cli 0.5.0-next.26 → 0.5.0-next.28

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.
Files changed (2) hide show
  1. package/dist/index.js +540 -528
  2. package/package.json +8 -8
package/dist/index.js CHANGED
@@ -172583,7 +172583,7 @@ var init_remark_gfm_CjV8kaUy_es = __esm(() => {
172583
172583
  init_remark_gfm_z_sDF4ss_es();
172584
172584
  });
172585
172585
 
172586
- // ../../packages/superdoc/dist/chunks/src-0P3ZlqDX.es.js
172586
+ // ../../packages/superdoc/dist/chunks/src-CqUAwJtN.es.js
172587
172587
  function deleteProps(obj, propOrProps) {
172588
172588
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
172589
172589
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -186330,7 +186330,7 @@ function sumRowHeights(rows, fromRow, toRow) {
186330
186330
  total += rows[i4].height;
186331
186331
  return total;
186332
186332
  }
186333
- function computeFragmentHeight(measure, fromRow, toRow, repeatHeaderCount, borderCollapse, partialRow) {
186333
+ function computeFragmentHeight$1(measure, fromRow, toRow, repeatHeaderCount, borderCollapse, partialRow) {
186334
186334
  let height = 0;
186335
186335
  let rowCount = 0;
186336
186336
  if (repeatHeaderCount > 0) {
@@ -186591,12 +186591,12 @@ function findSplitPoint(block, measure, startRow, availableHeight, fullPageHeigh
186591
186591
  if (rs > 1)
186592
186592
  maxRowspanEnd = Math.max(maxRowspanEnd, i4 + rs);
186593
186593
  }
186594
- if (computeFragmentHeight(measure, startRow, i4 + 1, 0, borderCollapse) <= availableHeight) {
186594
+ if (computeFragmentHeight$1(measure, startRow, i4 + 1, 0, borderCollapse) <= availableHeight) {
186595
186595
  lastFitRow = i4 + 1;
186596
186596
  if (maxRowspanEnd <= i4 + 1)
186597
186597
  lastCleanFitRow = i4 + 1;
186598
186598
  } else {
186599
- let remainingHeight = availableHeight - computeFragmentHeight(measure, startRow, lastFitRow, 0, borderCollapse);
186599
+ let remainingHeight = availableHeight - computeFragmentHeight$1(measure, startRow, lastFitRow, 0, borderCollapse);
186600
186600
  if (lastFitRow === startRow) {
186601
186601
  const cellSpacingPx = measure.cellSpacingPx ?? 0;
186602
186602
  const topBorderPx = borderCollapse === "separate" && measure.tableBorderWidths ? measure.tableBorderWidths.top : 0;
@@ -186808,7 +186808,7 @@ function layoutTableBlock({ block, measure, columnWidth, ensurePage, advanceColu
186808
186808
  const hadRemainingLinesBefore = fromLineByCell.some((fromLine, idx) => {
186809
186809
  return fromLine < getCellTotalLines(measure.rows[rowIndex].cells[idx]);
186810
186810
  });
186811
- const fragmentHeight$1 = computeFragmentHeight(measure, rowIndex, rowIndex + 1, repeatHeaderCount, borderCollapse, continuationPartialRow);
186811
+ const fragmentHeight$1 = computeFragmentHeight$1(measure, rowIndex, rowIndex + 1, repeatHeaderCount, borderCollapse, continuationPartialRow);
186812
186812
  if (fragmentHeight$1 > 0 && madeProgress) {
186813
186813
  const { x: x$1, width: width$1 } = resolveTableFrame(columnX(state.columnIndex), columnWidth, Math.min(columnWidth, measure.totalWidth || columnWidth), block.attrs);
186814
186814
  const scaledWidths$1 = rescaleColumnWidths(measure.columnWidths, measure.totalWidth, width$1);
@@ -186863,7 +186863,7 @@ function layoutTableBlock({ block, measure, columnWidth, ensurePage, advanceColu
186863
186863
  continue;
186864
186864
  }
186865
186865
  const forcedEndRow = bodyStartRow + 1;
186866
- const fragmentHeight$1 = computeFragmentHeight(measure, bodyStartRow, forcedEndRow, repeatHeaderCount, borderCollapse, forcedPartialRow);
186866
+ const fragmentHeight$1 = computeFragmentHeight$1(measure, bodyStartRow, forcedEndRow, repeatHeaderCount, borderCollapse, forcedPartialRow);
186867
186867
  const { x: x$1, width: width$1 } = resolveTableFrame(columnX(state.columnIndex), columnWidth, Math.min(columnWidth, measure.totalWidth || columnWidth), block.attrs);
186868
186868
  const scaledWidths$1 = rescaleColumnWidths(measure.columnWidths, measure.totalWidth, width$1);
186869
186869
  const fragment$1 = {
@@ -186890,7 +186890,7 @@ function layoutTableBlock({ block, measure, columnWidth, ensurePage, advanceColu
186890
186890
  isTableContinuation = true;
186891
186891
  continue;
186892
186892
  }
186893
- const fragmentHeight = computeFragmentHeight(measure, bodyStartRow, endRow, repeatHeaderCount, borderCollapse, partialRow);
186893
+ const fragmentHeight = computeFragmentHeight$1(measure, bodyStartRow, endRow, repeatHeaderCount, borderCollapse, partialRow);
186894
186894
  const { x, width } = resolveTableFrame(columnX(state.columnIndex), columnWidth, Math.min(columnWidth, measure.totalWidth || columnWidth), block.attrs);
186895
186895
  const scaledWidths = rescaleColumnWidths(measure.columnWidths, measure.totalWidth, width);
186896
186896
  const fragment2 = {
@@ -219614,6 +219614,102 @@ function findSliceAtPosition(slices, pmPos) {
219614
219614
  }
219615
219615
  return null;
219616
219616
  }
219617
+ function buildBlockMap(blocks2, measures) {
219618
+ const map$12 = /* @__PURE__ */ new Map;
219619
+ for (let i4 = 0;i4 < blocks2.length; i4++)
219620
+ map$12.set(blocks2[i4].id, {
219621
+ block: blocks2[i4],
219622
+ measure: measures[i4]
219623
+ });
219624
+ return map$12;
219625
+ }
219626
+ function sumLineHeights$2(lines, from$1, to) {
219627
+ let total = 0;
219628
+ for (let i4 = from$1;i4 < to && i4 < lines.length; i4++)
219629
+ total += lines[i4].lineHeight;
219630
+ return total;
219631
+ }
219632
+ function computeFragmentHeight(fragment2, blockMap) {
219633
+ if (fragment2.kind === "image" || fragment2.kind === "drawing" || fragment2.kind === "table")
219634
+ return fragment2.height;
219635
+ const entry = blockMap.get(fragment2.blockId);
219636
+ if (!entry)
219637
+ return 0;
219638
+ if (fragment2.kind === "para") {
219639
+ if (fragment2.lines)
219640
+ return fragment2.lines.reduce((sum, line) => sum + line.lineHeight, 0);
219641
+ if (entry.measure.kind === "paragraph")
219642
+ return sumLineHeights$2(entry.measure.lines, fragment2.fromLine, fragment2.toLine);
219643
+ return 0;
219644
+ }
219645
+ if (fragment2.kind === "list-item") {
219646
+ const listMeasure = entry.measure;
219647
+ if (listMeasure.kind !== "list")
219648
+ return 0;
219649
+ const item = listMeasure.items.find((it) => it.itemId === fragment2.itemId);
219650
+ if (!item)
219651
+ return 0;
219652
+ return sumLineHeights$2(item.paragraph.lines, fragment2.fromLine, fragment2.toLine);
219653
+ }
219654
+ return 0;
219655
+ }
219656
+ function isAnchoredMediaFragment(fragment2) {
219657
+ return (fragment2.kind === "image" || fragment2.kind === "drawing") && fragment2.isAnchored === true;
219658
+ }
219659
+ function resolveFragmentZIndex(fragment2) {
219660
+ if (!isAnchoredMediaFragment(fragment2))
219661
+ return;
219662
+ return fragment2.zIndex;
219663
+ }
219664
+ function resolveFragmentId(fragment2) {
219665
+ switch (fragment2.kind) {
219666
+ case "para":
219667
+ return `para:${fragment2.blockId}:${fragment2.fromLine}:${fragment2.toLine}`;
219668
+ case "list-item":
219669
+ return `list-item:${fragment2.blockId}:${fragment2.itemId}:${fragment2.fromLine}:${fragment2.toLine}`;
219670
+ case "image":
219671
+ return `image:${fragment2.blockId}:${fragment2.x}:${fragment2.y}`;
219672
+ case "drawing":
219673
+ return `drawing:${fragment2.blockId}:${fragment2.x}:${fragment2.y}`;
219674
+ case "table": {
219675
+ const partialKey = fragment2.partialRow ? `:${fragment2.partialRow.fromLineByCell.join(",")}-${fragment2.partialRow.toLineByCell.join(",")}` : "";
219676
+ return `table:${fragment2.blockId}:${fragment2.fromRow}:${fragment2.toRow}${partialKey}`;
219677
+ }
219678
+ }
219679
+ }
219680
+ function resolveFragmentItem(fragment2, fragmentIndex, pageIndex, blockMap) {
219681
+ return {
219682
+ kind: "fragment",
219683
+ id: resolveFragmentId(fragment2),
219684
+ pageIndex,
219685
+ x: fragment2.x,
219686
+ y: fragment2.y,
219687
+ width: fragment2.width,
219688
+ height: computeFragmentHeight(fragment2, blockMap),
219689
+ zIndex: resolveFragmentZIndex(fragment2),
219690
+ fragmentKind: fragment2.kind,
219691
+ blockId: fragment2.blockId,
219692
+ fragmentIndex
219693
+ };
219694
+ }
219695
+ function resolveLayout(input2) {
219696
+ const { layout, flowMode, blocks: blocks2, measures } = input2;
219697
+ const blockMap = buildBlockMap(blocks2, measures);
219698
+ const pages = layout.pages.map((page, pageIndex) => ({
219699
+ id: `page-${pageIndex}`,
219700
+ index: pageIndex,
219701
+ number: page.number,
219702
+ width: page.size?.w ?? layout.pageSize.w,
219703
+ height: page.size?.h ?? layout.pageSize.h,
219704
+ items: page.fragments.map((fragment2, fragmentIndex) => resolveFragmentItem(fragment2, fragmentIndex, pageIndex, blockMap))
219705
+ }));
219706
+ return {
219707
+ version: 1,
219708
+ flowMode,
219709
+ pageGap: layout.pageGap ?? 0,
219710
+ pages
219711
+ };
219712
+ }
219617
219713
  function getMeasurementContext() {
219618
219714
  if (measurementCtx)
219619
219715
  return measurementCtx;
@@ -219906,457 +220002,6 @@ function findCharacterAtX(block, line, x, pmStart, availableWidthOverride, align
219906
220002
  pmPosition
219907
220003
  };
219908
220004
  }
219909
- function isRtlLine(lineEl) {
219910
- return getComputedStyle(lineEl).direction === "rtl";
219911
- }
219912
- function isVisibleRect(rect) {
219913
- return rect.width > 0 && rect.height > 0;
219914
- }
219915
- function clickToPositionDom$1(domContainer, clientX, clientY) {
219916
- log2("=== clickToPositionDom START ===");
219917
- log2("Input coords:", {
219918
- clientX,
219919
- clientY
219920
- });
219921
- const pageEl = findPageElement$1(domContainer, clientX, clientY);
219922
- if (!pageEl) {
219923
- log2("No page element found");
219924
- return null;
219925
- }
219926
- const pageRect = pageEl.getBoundingClientRect();
219927
- const pageLocalX = clientX - pageRect.left;
219928
- const pageLocalY = clientY - pageRect.top;
219929
- const viewX = pageRect.left + pageLocalX;
219930
- const viewY = pageRect.top + pageLocalY;
219931
- log2("Page found:", {
219932
- pageIndex: pageEl.dataset.pageIndex,
219933
- pageRect: {
219934
- left: pageRect.left,
219935
- top: pageRect.top,
219936
- width: pageRect.width,
219937
- height: pageRect.height
219938
- },
219939
- viewCoords: {
219940
- viewX,
219941
- viewY
219942
- }
219943
- });
219944
- let hitChain = [];
219945
- const doc$12 = document;
219946
- const hasElementsFromPoint = typeof doc$12.elementsFromPoint === "function";
219947
- if (hasElementsFromPoint)
219948
- try {
219949
- hitChain = doc$12.elementsFromPoint(viewX, viewY) ?? [];
219950
- } catch {}
219951
- if (!Array.isArray(hitChain)) {
219952
- log2("elementsFromPoint returned non-array");
219953
- return null;
219954
- }
219955
- const hitChainData = hitChain.map((el) => {
219956
- const rect = el.getBoundingClientRect();
219957
- return {
219958
- tag: el.tagName,
219959
- classes: el.className,
219960
- blockId: el.dataset?.blockId,
219961
- pmStart: el.dataset?.pmStart,
219962
- pmEnd: el.dataset?.pmEnd,
219963
- rect: {
219964
- top: Math.round(rect.top),
219965
- bottom: Math.round(rect.bottom),
219966
- left: Math.round(rect.left),
219967
- right: Math.round(rect.right),
219968
- height: Math.round(rect.height)
219969
- }
219970
- };
219971
- });
219972
- log2("Hit chain elements:", JSON.stringify(hitChainData, null, 2));
219973
- const fragmentData = Array.from(pageEl.querySelectorAll(`.${CLASS_NAMES.fragment}`)).map((el) => {
219974
- const rect = el.getBoundingClientRect();
219975
- return {
219976
- blockId: el.dataset.blockId,
219977
- pmStart: el.dataset.pmStart,
219978
- pmEnd: el.dataset.pmEnd,
219979
- rect: {
219980
- top: Math.round(rect.top),
219981
- bottom: Math.round(rect.bottom),
219982
- left: Math.round(rect.left),
219983
- right: Math.round(rect.right),
219984
- height: Math.round(rect.height)
219985
- }
219986
- };
219987
- });
219988
- log2("All fragments on page:", JSON.stringify(fragmentData, null, 2));
219989
- const fragmentEl = hitChain.find((el) => el.classList?.contains?.(CLASS_NAMES.fragment));
219990
- if (!fragmentEl) {
219991
- if (hasElementsFromPoint) {
219992
- log2("No fragment found in hit chain; returning null to allow geometry mapping");
219993
- return null;
219994
- }
219995
- const fallbackFragment = pageEl.querySelector(`.${CLASS_NAMES.fragment}`);
219996
- if (!fallbackFragment) {
219997
- log2("No fragment found in hit chain or fallback");
219998
- return null;
219999
- }
220000
- log2("Using fallback fragment (no elementsFromPoint):", {
220001
- blockId: fallbackFragment.dataset.blockId,
220002
- pmStart: fallbackFragment.dataset.pmStart,
220003
- pmEnd: fallbackFragment.dataset.pmEnd
220004
- });
220005
- const result$1 = processFragment(fallbackFragment, viewX, viewY);
220006
- log2("=== clickToPositionDom END (fallback) ===", { result: result$1 });
220007
- return result$1;
220008
- }
220009
- log2("Fragment found:", {
220010
- blockId: fragmentEl.dataset.blockId,
220011
- pmStart: fragmentEl.dataset.pmStart,
220012
- pmEnd: fragmentEl.dataset.pmEnd
220013
- });
220014
- const hitChainLine = hitChain.find((el) => el.classList?.contains?.(CLASS_NAMES.line) && el.dataset?.pmStart !== undefined && el.dataset?.pmEnd !== undefined);
220015
- if (hitChainLine) {
220016
- log2("Using hit chain line directly:", {
220017
- pmStart: hitChainLine.dataset.pmStart,
220018
- pmEnd: hitChainLine.dataset.pmEnd
220019
- });
220020
- const result$1 = processLineElement(hitChainLine, viewX);
220021
- log2("=== clickToPositionDom END (hitChainLine) ===", { result: result$1 });
220022
- return result$1;
220023
- }
220024
- if (fragmentEl.classList.contains(CLASS_NAMES.tableFragment)) {
220025
- log2("Table fragment without line in hit chain, deferring to geometry fallback");
220026
- return null;
220027
- }
220028
- const result = processFragment(fragmentEl, viewX, viewY);
220029
- log2("=== clickToPositionDom END ===", { result });
220030
- return result;
220031
- }
220032
- function findPageElement$1(domContainer, clientX, clientY) {
220033
- if (domContainer.classList?.contains?.(CLASS_NAMES.page))
220034
- return domContainer;
220035
- const doc$12 = document;
220036
- if (typeof doc$12.elementsFromPoint === "function")
220037
- try {
220038
- const hitChain = doc$12.elementsFromPoint(clientX, clientY);
220039
- if (Array.isArray(hitChain)) {
220040
- const pageEl = hitChain.find((el) => el.classList?.contains?.(CLASS_NAMES.page));
220041
- if (pageEl)
220042
- return pageEl;
220043
- }
220044
- } catch {}
220045
- const pages = Array.from(domContainer.querySelectorAll(`.${CLASS_NAMES.page}`));
220046
- for (const page of pages) {
220047
- const rect = page.getBoundingClientRect();
220048
- if (clientX >= rect.left && clientX <= rect.right && clientY >= rect.top && clientY <= rect.bottom)
220049
- return page;
220050
- }
220051
- if (pages.length > 0)
220052
- return pages[0];
220053
- return null;
220054
- }
220055
- function processFragment(fragmentEl, viewX, viewY) {
220056
- log2("processFragment:", {
220057
- viewX,
220058
- viewY,
220059
- blockId: fragmentEl.dataset.blockId
220060
- });
220061
- const lineEls = Array.from(fragmentEl.querySelectorAll(`.${CLASS_NAMES.line}`));
220062
- log2("Lines in fragment:", lineEls.map((el, i4) => {
220063
- const rect = el.getBoundingClientRect();
220064
- return {
220065
- index: i4,
220066
- pmStart: el.dataset.pmStart,
220067
- pmEnd: el.dataset.pmEnd,
220068
- rect: {
220069
- top: rect.top,
220070
- bottom: rect.bottom,
220071
- left: rect.left,
220072
- right: rect.right
220073
- }
220074
- };
220075
- }));
220076
- if (lineEls.length === 0) {
220077
- log2("No lines in fragment");
220078
- return null;
220079
- }
220080
- const lineEl = findLineAtY(lineEls, viewY);
220081
- if (!lineEl) {
220082
- log2("No line found at Y:", viewY);
220083
- return null;
220084
- }
220085
- const lineStart = Number(lineEl.dataset.pmStart ?? "NaN");
220086
- const lineEnd = Number(lineEl.dataset.pmEnd ?? "NaN");
220087
- const lineRect = lineEl.getBoundingClientRect();
220088
- log2("Selected line:", {
220089
- pmStart: lineStart,
220090
- pmEnd: lineEnd,
220091
- rect: {
220092
- top: lineRect.top,
220093
- bottom: lineRect.bottom,
220094
- left: lineRect.left,
220095
- right: lineRect.right
220096
- }
220097
- });
220098
- if (!Number.isFinite(lineStart) || !Number.isFinite(lineEnd)) {
220099
- log2("Line has invalid PM positions");
220100
- return null;
220101
- }
220102
- const spanEls = Array.from(lineEl.querySelectorAll("span, a")).filter((el) => el.dataset.pmStart !== undefined && el.dataset.pmEnd !== undefined && !el.classList.contains(DOM_CLASS_NAMES.INLINE_SDT_WRAPPER));
220103
- log2("Spans/anchors in line:", spanEls.map((el, i4) => {
220104
- const rect = el.getBoundingClientRect();
220105
- return {
220106
- index: i4,
220107
- tag: el.tagName,
220108
- pmStart: el.dataset.pmStart,
220109
- pmEnd: el.dataset.pmEnd,
220110
- text: el.textContent?.substring(0, 20) + (el.textContent && el.textContent.length > 20 ? "..." : ""),
220111
- visibility: el.style.visibility,
220112
- rect: {
220113
- left: rect.left,
220114
- right: rect.right,
220115
- width: rect.width
220116
- }
220117
- };
220118
- }));
220119
- return resolveLinePosition(lineEl, lineStart, lineEnd, spanEls, viewX);
220120
- }
220121
- function mapCharIndexToPm(spanStart, spanEnd, textLength, charIndex) {
220122
- if (!Number.isFinite(spanStart) || !Number.isFinite(spanEnd))
220123
- return spanStart;
220124
- if (textLength <= 0)
220125
- return spanStart;
220126
- const pmRange = spanEnd - spanStart;
220127
- if (!Number.isFinite(pmRange) || pmRange <= 0)
220128
- return spanStart;
220129
- if (pmRange === textLength) {
220130
- const mapped = spanStart + charIndex;
220131
- return Math.min(spanEnd, Math.max(spanStart, mapped));
220132
- }
220133
- return charIndex / textLength <= 0.5 ? spanStart : spanEnd;
220134
- }
220135
- function processLineElement(lineEl, viewX) {
220136
- const lineStart = Number(lineEl.dataset.pmStart ?? "NaN");
220137
- const lineEnd = Number(lineEl.dataset.pmEnd ?? "NaN");
220138
- const lineRect = lineEl.getBoundingClientRect();
220139
- log2("processLineElement:", {
220140
- pmStart: lineStart,
220141
- pmEnd: lineEnd,
220142
- rect: {
220143
- top: lineRect.top,
220144
- bottom: lineRect.bottom,
220145
- left: lineRect.left,
220146
- right: lineRect.right
220147
- }
220148
- });
220149
- if (!Number.isFinite(lineStart) || !Number.isFinite(lineEnd)) {
220150
- log2("Line has invalid PM positions");
220151
- return null;
220152
- }
220153
- const spanEls = Array.from(lineEl.querySelectorAll("span, a")).filter((el) => el.dataset.pmStart !== undefined && el.dataset.pmEnd !== undefined && !el.classList.contains(DOM_CLASS_NAMES.INLINE_SDT_WRAPPER));
220154
- log2("Spans/anchors in line:", spanEls.map((el, i4) => {
220155
- const rect = el.getBoundingClientRect();
220156
- return {
220157
- index: i4,
220158
- tag: el.tagName,
220159
- pmStart: el.dataset.pmStart,
220160
- pmEnd: el.dataset.pmEnd,
220161
- text: el.textContent?.substring(0, 20) + (el.textContent && el.textContent.length > 20 ? "..." : ""),
220162
- visibility: el.style.visibility,
220163
- rect: {
220164
- left: rect.left,
220165
- right: rect.right,
220166
- width: rect.width
220167
- }
220168
- };
220169
- }));
220170
- return resolveLinePosition(lineEl, lineStart, lineEnd, spanEls, viewX);
220171
- }
220172
- function resolveLinePosition(lineEl, lineStart, lineEnd, spanEls, viewX) {
220173
- if (spanEls.length === 0) {
220174
- log2("No spans in line, returning lineStart:", lineStart);
220175
- return lineStart;
220176
- }
220177
- const rtl = isRtlLine(lineEl);
220178
- const allRects = spanEls.map((el) => el.getBoundingClientRect());
220179
- const visibleRects = allRects.filter(isVisibleRect);
220180
- const boundsRects = visibleRects.length > 0 ? visibleRects : allRects;
220181
- const visualLeft = Math.min(...boundsRects.map((r$1) => r$1.left));
220182
- const visualRight = Math.max(...boundsRects.map((r$1) => r$1.right));
220183
- if (viewX <= visualLeft) {
220184
- const pos$1 = rtl ? lineEnd : lineStart;
220185
- log2("Click to visual left of all spans, returning:", pos$1);
220186
- return pos$1;
220187
- }
220188
- if (viewX >= visualRight) {
220189
- const pos$1 = rtl ? lineStart : lineEnd;
220190
- log2("Click to visual right of all spans, returning:", pos$1);
220191
- return pos$1;
220192
- }
220193
- const targetEl = findSpanAtX(spanEls, viewX);
220194
- if (!targetEl) {
220195
- log2("No target element found, returning lineStart:", lineStart);
220196
- return lineStart;
220197
- }
220198
- const spanStart = Number(targetEl.dataset.pmStart ?? "NaN");
220199
- const spanEnd = Number(targetEl.dataset.pmEnd ?? "NaN");
220200
- const targetRect = targetEl.getBoundingClientRect();
220201
- log2("Target element:", {
220202
- tag: targetEl.tagName,
220203
- pmStart: spanStart,
220204
- pmEnd: spanEnd,
220205
- text: targetEl.textContent?.substring(0, 30),
220206
- visibility: targetEl.style.visibility,
220207
- rect: {
220208
- left: targetRect.left,
220209
- right: targetRect.right,
220210
- width: targetRect.width
220211
- }
220212
- });
220213
- if (!Number.isFinite(spanStart) || !Number.isFinite(spanEnd)) {
220214
- log2("Element has invalid PM positions");
220215
- return null;
220216
- }
220217
- const firstChild = targetEl.firstChild;
220218
- if (!firstChild || firstChild.nodeType !== Node.TEXT_NODE || !firstChild.textContent) {
220219
- const closerToLeft = Math.abs(viewX - targetRect.left) <= Math.abs(viewX - targetRect.right);
220220
- const snapPos = rtl ? closerToLeft ? spanEnd : spanStart : closerToLeft ? spanStart : spanEnd;
220221
- log2("Empty/non-text element, snapping to:", {
220222
- closerToLeft,
220223
- rtl,
220224
- snapPos
220225
- });
220226
- return snapPos;
220227
- }
220228
- const textNode = firstChild;
220229
- const charIndex = findCharIndexAtX(textNode, viewX, rtl);
220230
- const pos = mapCharIndexToPm(spanStart, spanEnd, textNode.length, charIndex);
220231
- log2("Character position:", {
220232
- charIndex,
220233
- spanStart,
220234
- rtl,
220235
- finalPos: pos
220236
- });
220237
- return pos;
220238
- }
220239
- function findLineAtY(lineEls, viewY) {
220240
- if (lineEls.length === 0)
220241
- return null;
220242
- for (let i4 = 0;i4 < lineEls.length; i4++) {
220243
- const lineEl = lineEls[i4];
220244
- const rect = lineEl.getBoundingClientRect();
220245
- if (viewY >= rect.top && viewY <= rect.bottom) {
220246
- log2("findLineAtY: Found line at index", i4, {
220247
- pmStart: lineEl.dataset.pmStart,
220248
- pmEnd: lineEl.dataset.pmEnd,
220249
- rect: {
220250
- top: rect.top,
220251
- bottom: rect.bottom
220252
- },
220253
- viewY
220254
- });
220255
- return lineEl;
220256
- }
220257
- }
220258
- const lastLine = lineEls[lineEls.length - 1];
220259
- log2("findLineAtY: Y beyond all lines, using last line:", {
220260
- pmStart: lastLine.dataset.pmStart,
220261
- pmEnd: lastLine.dataset.pmEnd,
220262
- viewY
220263
- });
220264
- return lastLine;
220265
- }
220266
- function findSpanAtX(spanEls, viewX) {
220267
- if (spanEls.length === 0)
220268
- return null;
220269
- let targetSpan = spanEls[0];
220270
- let minDist = Infinity;
220271
- for (let i4 = 0;i4 < spanEls.length; i4++) {
220272
- const span = spanEls[i4];
220273
- const rect = span.getBoundingClientRect();
220274
- if (!isVisibleRect(rect))
220275
- continue;
220276
- if (viewX >= rect.left && viewX <= rect.right) {
220277
- log2("findSpanAtX: Found containing element at index", i4, {
220278
- tag: span.tagName,
220279
- pmStart: span.dataset.pmStart,
220280
- pmEnd: span.dataset.pmEnd,
220281
- rect: {
220282
- left: rect.left,
220283
- right: rect.right
220284
- },
220285
- viewX
220286
- });
220287
- return span;
220288
- }
220289
- const dist = Math.min(Math.abs(viewX - rect.left), Math.abs(viewX - rect.right));
220290
- if (dist < minDist) {
220291
- minDist = dist;
220292
- targetSpan = span;
220293
- }
220294
- }
220295
- log2("findSpanAtX: No containing element, using nearest:", {
220296
- tag: targetSpan.tagName,
220297
- pmStart: targetSpan.dataset.pmStart,
220298
- pmEnd: targetSpan.dataset.pmEnd,
220299
- viewX
220300
- });
220301
- return targetSpan;
220302
- }
220303
- function findCharIndexAtX(textNode, targetX, rtl) {
220304
- const text5 = textNode.textContent ?? "";
220305
- if (text5.length === 0)
220306
- return 0;
220307
- const container = textNode.parentElement;
220308
- if (!container)
220309
- return 0;
220310
- const containerRect = container.getBoundingClientRect();
220311
- const caretIndex = caretOffsetFromPoint(targetX, containerRect.top + containerRect.height / 2, textNode);
220312
- if (caretIndex != null) {
220313
- log2("findCharIndexAtX: caret API returned", caretIndex);
220314
- return caretIndex;
220315
- }
220316
- log2("findCharIndexAtX: falling back to range binary search, rtl =", rtl);
220317
- const range = document.createRange();
220318
- const measureX = (i4) => {
220319
- if (i4 <= 0)
220320
- return rtl ? containerRect.right : containerRect.left;
220321
- range.setStart(textNode, 0);
220322
- range.setEnd(textNode, i4);
220323
- const r$1 = range.getBoundingClientRect();
220324
- return rtl ? r$1.left : r$1.right;
220325
- };
220326
- let lo = 0;
220327
- let hi = text5.length;
220328
- while (lo < hi) {
220329
- const mid = Math.floor((lo + hi) / 2);
220330
- const x = measureX(mid);
220331
- if (rtl ? x > targetX : x < targetX)
220332
- lo = mid + 1;
220333
- else
220334
- hi = mid;
220335
- }
220336
- const index2 = Math.max(0, Math.min(text5.length, lo));
220337
- const xAt = measureX(index2);
220338
- const distAt = Math.abs(xAt - targetX);
220339
- if (index2 > 0) {
220340
- const xPrev = measureX(index2 - 1);
220341
- if (Math.abs(xPrev - targetX) < distAt)
220342
- return index2 - 1;
220343
- }
220344
- return index2;
220345
- }
220346
- function caretOffsetFromPoint(x, y$1, expectedNode) {
220347
- const doc$12 = document;
220348
- if (typeof doc$12.caretPositionFromPoint === "function") {
220349
- const cp = doc$12.caretPositionFromPoint(x, y$1);
220350
- if (cp && cp.offsetNode === expectedNode)
220351
- return cp.offset;
220352
- }
220353
- if (typeof doc$12.caretRangeFromPoint === "function") {
220354
- const r$1 = doc$12.caretRangeFromPoint(x, y$1);
220355
- if (r$1 && r$1.startContainer === expectedNode)
220356
- return r$1.startOffset;
220357
- }
220358
- return null;
220359
- }
220360
220005
  function getWordLayoutConfig(block) {
220361
220006
  if (!block || block.kind !== "paragraph")
220362
220007
  return;
@@ -226499,32 +226144,116 @@ function renderRemoteSelection(options) {
226499
226144
  });
226500
226145
  options.renderCaret();
226501
226146
  }
226147
+ function safeElementsFromPoint(doc$12, x, y$1) {
226148
+ if (typeof doc$12.elementsFromPoint !== "function")
226149
+ return [];
226150
+ try {
226151
+ return doc$12.elementsFromPoint(x, y$1) ?? [];
226152
+ } catch {
226153
+ return [];
226154
+ }
226155
+ }
226156
+ function hasElementsFromPoint(doc$12) {
226157
+ return typeof doc$12.elementsFromPoint === "function";
226158
+ }
226159
+ function getContainerDocument(domContainer) {
226160
+ return domContainer.ownerDocument ?? null;
226161
+ }
226162
+ function getNodeDocument(node3) {
226163
+ return node3.ownerDocument ?? null;
226164
+ }
226165
+ function createRangeForNode(node3) {
226166
+ return getNodeDocument(node3)?.createRange() ?? null;
226167
+ }
226168
+ function isVisibleRect(rect) {
226169
+ return rect.width > 0 && rect.height > 0;
226170
+ }
226171
+ function isRtlLine(lineEl) {
226172
+ return getComputedStyle(lineEl).direction === "rtl";
226173
+ }
226174
+ function readPmRange(el) {
226175
+ return {
226176
+ start: Number(el.dataset.pmStart ?? "NaN"),
226177
+ end: Number(el.dataset.pmEnd ?? "NaN")
226178
+ };
226179
+ }
226180
+ function getClickableSpans(lineEl) {
226181
+ return Array.from(lineEl.querySelectorAll("span, a")).filter((el) => el.dataset.pmStart !== undefined && el.dataset.pmEnd !== undefined && !el.classList.contains(CLASS.inlineSdtWrapper));
226182
+ }
226502
226183
  function clickToPositionDom(domContainer, clientX, clientY) {
226503
- return clickToPositionDom$1(domContainer, clientX, clientY);
226184
+ log2("=== clickToPositionDom START ===", {
226185
+ clientX,
226186
+ clientY
226187
+ });
226188
+ const pageEl = findPageElement(domContainer, clientX, clientY);
226189
+ if (!pageEl) {
226190
+ log2("No page element found");
226191
+ return null;
226192
+ }
226193
+ log2("Page found:", { pageIndex: pageEl.dataset.pageIndex });
226194
+ const doc$12 = getContainerDocument(domContainer);
226195
+ if (!doc$12) {
226196
+ log2("No owner document found");
226197
+ return null;
226198
+ }
226199
+ const hitChain = safeElementsFromPoint(doc$12, clientX, clientY);
226200
+ if (!Array.isArray(hitChain)) {
226201
+ log2("elementsFromPoint returned non-array");
226202
+ return null;
226203
+ }
226204
+ logHitChain(hitChain);
226205
+ const fragmentEl = hitChain.find((el) => el.classList?.contains?.(CLASS.fragment));
226206
+ if (!fragmentEl) {
226207
+ if (hasElementsFromPoint(doc$12)) {
226208
+ log2("No fragment in hit chain; deferring to geometry");
226209
+ return null;
226210
+ }
226211
+ const fallback = pageEl.querySelector(`.${CLASS.fragment}`);
226212
+ if (!fallback)
226213
+ return null;
226214
+ log2("Using fallback fragment (no elementsFromPoint)");
226215
+ return resolveFragment(fallback, clientX, clientY);
226216
+ }
226217
+ const hitChainLine = hitChain.find((el) => el.classList?.contains?.(CLASS.line) && el.dataset?.pmStart !== undefined && el.dataset?.pmEnd !== undefined);
226218
+ if (hitChainLine) {
226219
+ log2("Using hit-chain line directly");
226220
+ return resolveLineAtX(hitChainLine, clientX);
226221
+ }
226222
+ if (fragmentEl.classList.contains(CLASS.tableFragment)) {
226223
+ log2("Table fragment without line in hit chain — deferring to geometry");
226224
+ return null;
226225
+ }
226226
+ return resolveFragment(fragmentEl, clientX, clientY);
226504
226227
  }
226505
226228
  function findPageElement(domContainer, clientX, clientY) {
226506
- return findPageElement$1(domContainer, clientX, clientY);
226229
+ if (domContainer.classList?.contains?.(CLASS.page))
226230
+ return domContainer;
226231
+ const doc$12 = getContainerDocument(domContainer);
226232
+ if (!doc$12)
226233
+ return null;
226234
+ const pageFromHit = safeElementsFromPoint(doc$12, clientX, clientY).find((el) => el.classList?.contains?.(CLASS.page));
226235
+ if (pageFromHit)
226236
+ return pageFromHit;
226237
+ const pages = Array.from(domContainer.querySelectorAll(`.${CLASS.page}`));
226238
+ for (const page of pages) {
226239
+ const r$1 = page.getBoundingClientRect();
226240
+ if (clientX >= r$1.left && clientX <= r$1.right && clientY >= r$1.top && clientY <= r$1.bottom)
226241
+ return page;
226242
+ }
226243
+ return pages[0] ?? null;
226507
226244
  }
226508
226245
  function readLayoutEpochFromDom(domContainer, clientX, clientY) {
226509
- const doc$12 = domContainer.ownerDocument ?? (typeof document !== "undefined" ? document : null);
226510
- if (!doc$12 || typeof doc$12.elementsFromPoint !== "function")
226511
- return null;
226512
- let hitChain = [];
226513
- try {
226514
- hitChain = doc$12.elementsFromPoint(clientX, clientY) ?? [];
226515
- } catch {
226246
+ const doc$12 = getContainerDocument(domContainer);
226247
+ if (!doc$12 || !hasElementsFromPoint(doc$12))
226516
226248
  return null;
226517
- }
226249
+ const hitChain = safeElementsFromPoint(doc$12, clientX, clientY);
226518
226250
  let latestEpoch = null;
226519
226251
  for (const el of hitChain) {
226520
226252
  if (!(el instanceof HTMLElement))
226521
226253
  continue;
226522
226254
  if (!domContainer.contains(el))
226523
226255
  continue;
226524
- const raw = el.dataset.layoutEpoch;
226525
- if (raw == null)
226526
- continue;
226527
- const epoch = Number(raw);
226256
+ const epoch = Number(el.dataset.layoutEpoch);
226528
226257
  if (!Number.isFinite(epoch))
226529
226258
  continue;
226530
226259
  if (latestEpoch == null || epoch > latestEpoch)
@@ -226532,6 +226261,153 @@ function readLayoutEpochFromDom(domContainer, clientX, clientY) {
226532
226261
  }
226533
226262
  return latestEpoch;
226534
226263
  }
226264
+ function resolveFragment(fragmentEl, viewX, viewY) {
226265
+ const lineEls = Array.from(fragmentEl.querySelectorAll(`.${CLASS.line}`));
226266
+ if (lineEls.length === 0) {
226267
+ log2("No lines in fragment");
226268
+ return null;
226269
+ }
226270
+ const lineEl = findLineAtY(lineEls, viewY);
226271
+ if (!lineEl)
226272
+ return null;
226273
+ return resolveLineAtX(lineEl, viewX);
226274
+ }
226275
+ function resolveLineAtX(lineEl, viewX) {
226276
+ const { start: lineStart, end: lineEnd } = readPmRange(lineEl);
226277
+ if (!Number.isFinite(lineStart) || !Number.isFinite(lineEnd)) {
226278
+ log2("Line has invalid PM positions");
226279
+ return null;
226280
+ }
226281
+ return resolvePositionInLine(lineEl, lineStart, lineEnd, getClickableSpans(lineEl), viewX);
226282
+ }
226283
+ function resolvePositionInLine(lineEl, lineStart, lineEnd, spanEls, viewX) {
226284
+ if (spanEls.length === 0) {
226285
+ log2("No spans in line, returning lineStart:", lineStart);
226286
+ return lineStart;
226287
+ }
226288
+ const rtl = isRtlLine(lineEl);
226289
+ const allRects = spanEls.map((el) => el.getBoundingClientRect());
226290
+ const visibleRects = allRects.filter(isVisibleRect);
226291
+ const boundsRects = visibleRects.length > 0 ? visibleRects : allRects;
226292
+ const visualLeft = Math.min(...boundsRects.map((r$1) => r$1.left));
226293
+ const visualRight = Math.max(...boundsRects.map((r$1) => r$1.right));
226294
+ if (viewX <= visualLeft)
226295
+ return rtl ? lineEnd : lineStart;
226296
+ if (viewX >= visualRight)
226297
+ return rtl ? lineStart : lineEnd;
226298
+ const targetEl = findSpanAtX(spanEls, viewX);
226299
+ if (!targetEl)
226300
+ return lineStart;
226301
+ const { start: spanStart, end: spanEnd } = readPmRange(targetEl);
226302
+ if (!Number.isFinite(spanStart) || !Number.isFinite(spanEnd))
226303
+ return null;
226304
+ const firstChild = targetEl.firstChild;
226305
+ if (!firstChild || firstChild.nodeType !== Node.TEXT_NODE || !firstChild.textContent) {
226306
+ const targetRect = targetEl.getBoundingClientRect();
226307
+ const closerToLeft = Math.abs(viewX - targetRect.left) <= Math.abs(viewX - targetRect.right);
226308
+ return rtl ? closerToLeft ? spanEnd : spanStart : closerToLeft ? spanStart : spanEnd;
226309
+ }
226310
+ const textNode = firstChild;
226311
+ const charIndex = findCharIndexAtX(textNode, viewX, rtl);
226312
+ return mapCharIndexToPm(spanStart, spanEnd, textNode.length, charIndex);
226313
+ }
226314
+ function findLineAtY(lineEls, viewY) {
226315
+ if (lineEls.length === 0)
226316
+ return null;
226317
+ for (const lineEl of lineEls) {
226318
+ const r$1 = lineEl.getBoundingClientRect();
226319
+ if (viewY >= r$1.top && viewY <= r$1.bottom)
226320
+ return lineEl;
226321
+ }
226322
+ return lineEls[lineEls.length - 1];
226323
+ }
226324
+ function findSpanAtX(spanEls, viewX) {
226325
+ if (spanEls.length === 0)
226326
+ return null;
226327
+ let nearest = spanEls[0];
226328
+ let minDist = Infinity;
226329
+ for (const span of spanEls) {
226330
+ const r$1 = span.getBoundingClientRect();
226331
+ if (!isVisibleRect(r$1))
226332
+ continue;
226333
+ if (viewX >= r$1.left && viewX <= r$1.right)
226334
+ return span;
226335
+ const dist = Math.min(Math.abs(viewX - r$1.left), Math.abs(viewX - r$1.right));
226336
+ if (dist < minDist) {
226337
+ minDist = dist;
226338
+ nearest = span;
226339
+ }
226340
+ }
226341
+ return nearest;
226342
+ }
226343
+ function mapCharIndexToPm(spanStart, spanEnd, textLength, charIndex) {
226344
+ if (!Number.isFinite(spanStart) || !Number.isFinite(spanEnd))
226345
+ return spanStart;
226346
+ if (textLength <= 0)
226347
+ return spanStart;
226348
+ const pmRange = spanEnd - spanStart;
226349
+ if (!Number.isFinite(pmRange) || pmRange <= 0)
226350
+ return spanStart;
226351
+ if (pmRange === textLength)
226352
+ return Math.min(spanEnd, Math.max(spanStart, spanStart + charIndex));
226353
+ return charIndex / textLength <= 0.5 ? spanStart : spanEnd;
226354
+ }
226355
+ function findCharIndexAtX(textNode, targetX, rtl) {
226356
+ const text5 = textNode.textContent ?? "";
226357
+ if (text5.length === 0)
226358
+ return 0;
226359
+ const container = textNode.parentElement;
226360
+ if (!container)
226361
+ return 0;
226362
+ const containerRect = container.getBoundingClientRect();
226363
+ const caretIndex = caretOffsetFromPoint(targetX, containerRect.top + containerRect.height / 2, textNode);
226364
+ if (caretIndex != null)
226365
+ return caretIndex;
226366
+ return binarySearchCharIndex(textNode, text5.length, targetX, rtl, containerRect);
226367
+ }
226368
+ function caretOffsetFromPoint(x, y$1, expectedNode) {
226369
+ const doc$12 = getNodeDocument(expectedNode);
226370
+ if (!doc$12)
226371
+ return null;
226372
+ if (typeof doc$12.caretPositionFromPoint === "function") {
226373
+ const cp = doc$12.caretPositionFromPoint(x, y$1);
226374
+ if (cp && cp.offsetNode === expectedNode)
226375
+ return cp.offset;
226376
+ }
226377
+ if (typeof doc$12.caretRangeFromPoint === "function") {
226378
+ const r$1 = doc$12.caretRangeFromPoint(x, y$1);
226379
+ if (r$1 && r$1.startContainer === expectedNode)
226380
+ return r$1.startOffset;
226381
+ }
226382
+ return null;
226383
+ }
226384
+ function binarySearchCharIndex(textNode, length$12, targetX, rtl, containerRect) {
226385
+ const range = createRangeForNode(textNode);
226386
+ if (!range)
226387
+ return 0;
226388
+ const measureX = (i4) => {
226389
+ if (i4 <= 0)
226390
+ return rtl ? containerRect.right : containerRect.left;
226391
+ range.setStart(textNode, 0);
226392
+ range.setEnd(textNode, i4);
226393
+ const r$1 = range.getBoundingClientRect();
226394
+ return rtl ? r$1.left : r$1.right;
226395
+ };
226396
+ let lo = 0;
226397
+ let hi = length$12;
226398
+ while (lo < hi) {
226399
+ const mid = Math.floor((lo + hi) / 2);
226400
+ if (rtl ? measureX(mid) > targetX : measureX(mid) < targetX)
226401
+ lo = mid + 1;
226402
+ else
226403
+ hi = mid;
226404
+ }
226405
+ const index2 = Math.max(0, Math.min(length$12, lo));
226406
+ if (index2 > 0 && Math.abs(measureX(index2 - 1) - targetX) < Math.abs(measureX(index2) - targetX))
226407
+ return index2 - 1;
226408
+ return index2;
226409
+ }
226410
+ function logHitChain(hitChain) {}
226535
226411
  function resolvePointerPositionHit(options) {
226536
226412
  const { layout, blocks: blocks2, measures, containerPoint, domContainer, clientX, clientY, geometryHelper } = options;
226537
226413
  const layoutEpoch = layout.layoutEpoch ?? 0;
@@ -242913,6 +242789,9 @@ var Node$13 = class Node$14 {
242913
242789
  },
242914
242790
  setScrollContainer(el) {
242915
242791
  painter.setScrollContainer(el);
242792
+ },
242793
+ setResolvedLayout(resolvedLayout) {
242794
+ painter.setResolvedLayout(resolvedLayout);
242916
242795
  }
242917
242796
  };
242918
242797
  }, VerticalNavigationPluginKey, createDefaultState = () => ({ goalX: null }), VerticalNavigation, createPermissionBlockMarkerNode = ({ name, attributes }) => Node$13.create({
@@ -246567,7 +246446,7 @@ var Node$13 = class Node$14 {
246567
246446
  if (maxGaps === 0)
246568
246447
  return 0;
246569
246448
  return Math.min(Math.max(precedingChars, 0), maxGaps) * run2.letterSpacing;
246570
- }, log2 = (...args$1) => {}, CLASS_NAMES, defaultHeaderFooterIdentifier = () => ({
246449
+ }, defaultHeaderFooterIdentifier = () => ({
246571
246450
  headerIds: {
246572
246451
  default: null,
246573
246452
  first: null,
@@ -251621,7 +251500,7 @@ var Node$13 = class Node$14 {
251621
251500
  this.#onCursorsUpdate = null;
251622
251501
  this.#isSetup = false;
251623
251502
  }
251624
- }, SEMANTIC_FOOTNOTES_HEADING_BLOCK_ID = "__sd_semantic_footnotes_heading", SEMANTIC_FOOTNOTE_BLOCK_ID_PREFIX = "__sd_semantic_footnote", MULTI_CLICK_TIME_THRESHOLD_MS = 400, MULTI_CLICK_DISTANCE_THRESHOLD_PX = 5, AUTO_SCROLL_EDGE_PX = 32, AUTO_SCROLL_MAX_SPEED_PX = 24, SCROLL_DETECTION_TOLERANCE_PX = 1, COMMENT_HIGHLIGHT_SELECTOR = ".superdoc-comment-highlight", clamp = (value, min$2, max$2) => Math.max(min$2, Math.min(max$2, value)), EditorInputManager = class {
251503
+ }, log2 = (...args$1) => {}, CLASS, SEMANTIC_FOOTNOTES_HEADING_BLOCK_ID = "__sd_semantic_footnotes_heading", SEMANTIC_FOOTNOTE_BLOCK_ID_PREFIX = "__sd_semantic_footnote", MULTI_CLICK_TIME_THRESHOLD_MS = 400, MULTI_CLICK_DISTANCE_THRESHOLD_PX = 5, AUTO_SCROLL_EDGE_PX = 32, AUTO_SCROLL_MAX_SPEED_PX = 24, SCROLL_DETECTION_TOLERANCE_PX = 1, COMMENT_HIGHLIGHT_SELECTOR = ".superdoc-comment-highlight", clamp = (value, min$2, max$2) => Math.max(min$2, Math.min(max$2, value)), EditorInputManager = class {
251625
251504
  #deps = null;
251626
251505
  #callbacks = {};
251627
251506
  #isDragging = false;
@@ -255092,7 +254971,7 @@ var Node$13 = class Node$14 {
255092
254971
  return;
255093
254972
  console.log(...args$1);
255094
254973
  }, HEADER_FOOTER_INIT_BUDGET_MS = 200, MAX_ZOOM_WARNING_THRESHOLD = 10, MAX_SELECTION_RECTS_PER_USER = 100, SEMANTIC_RESIZE_DEBOUNCE_MS = 120, MIN_SEMANTIC_CONTENT_WIDTH_PX = 1, GLOBAL_PERFORMANCE, PresentationEditor, ICONS, TEXTS, tableActionsOptions;
255095
- var init_src_0P3ZlqDX_es = __esm(() => {
254974
+ var init_src_CqUAwJtN_es = __esm(() => {
255096
254975
  init_rolldown_runtime_B2q5OVn9_es();
255097
254976
  init_SuperConverter_B9oNf3OB_es();
255098
254977
  init_jszip_ChlR43oI_es();
@@ -273688,6 +273567,7 @@ function print() { __p += __j.call(arguments, '') }
273688
273567
  this.activeCommentId = null;
273689
273568
  this.paintSnapshotBuilder = null;
273690
273569
  this.lastPaintSnapshot = null;
273570
+ this.resolvedLayout = null;
273691
273571
  this.options = options;
273692
273572
  this.layoutMode = options.layoutMode ?? "vertical";
273693
273573
  this.isSemanticFlow = (options.flowMode ?? "paginated") === "semantic";
@@ -273749,6 +273629,19 @@ function print() { __p += __j.call(arguments, '') }
273749
273629
  getActiveComment() {
273750
273630
  return this.activeCommentId;
273751
273631
  }
273632
+ setResolvedLayout(resolvedLayout) {
273633
+ this.resolvedLayout = resolvedLayout;
273634
+ }
273635
+ getResolvedPage(pageIndex) {
273636
+ return this.resolvedLayout?.pages[pageIndex] ?? null;
273637
+ }
273638
+ getResolvedFragmentItem(pageIndex, fragmentIndex) {
273639
+ const page = this.getResolvedPage(pageIndex);
273640
+ if (!page)
273641
+ return;
273642
+ const item = page.items[fragmentIndex];
273643
+ return item?.kind === "fragment" ? item : undefined;
273644
+ }
273752
273645
  getPaintSnapshot() {
273753
273646
  return this.lastPaintSnapshot;
273754
273647
  }
@@ -274061,7 +273954,9 @@ function print() { __p += __j.call(arguments, '') }
274061
273954
  if (!this.currentLayout)
274062
273955
  return;
274063
273956
  if (this.currentLayout.pages.length !== this.virtualHeights.length)
274064
- this.virtualHeights = this.currentLayout.pages.map((p$12) => p$12.size?.h ?? this.currentLayout.pageSize.h);
273957
+ this.virtualHeights = this.currentLayout.pages.map((p$12, i4) => {
273958
+ return this.getResolvedPage(i4)?.height ?? p$12.size?.h ?? this.currentLayout.pageSize.h;
273959
+ });
274065
273960
  const offsets = new Array(this.virtualHeights.length + 1);
274066
273961
  offsets[0] = 0;
274067
273962
  for (let i4 = 0;i4 < this.virtualHeights.length; i4 += 1)
@@ -274171,7 +274066,11 @@ function print() { __p += __j.call(arguments, '') }
274171
274066
  }
274172
274067
  for (const i4 of mounted) {
274173
274068
  const page = layout.pages[i4];
274174
- const pageSize = page.size ?? layout.pageSize;
274069
+ const resolved = this.getResolvedPage(i4);
274070
+ const pageSize = resolved ? {
274071
+ w: resolved.width,
274072
+ h: resolved.height
274073
+ } : page.size ?? layout.pageSize;
274175
274074
  const existing = this.pageIndexToState.get(i4);
274176
274075
  if (!existing) {
274177
274076
  const newState = this.createPageState(page, pageSize, i4);
@@ -274248,7 +274147,11 @@ function print() { __p += __j.call(arguments, '') }
274248
274147
  return;
274249
274148
  mount.innerHTML = "";
274250
274149
  layout.pages.forEach((page, pageIndex) => {
274251
- const pageSize = page.size ?? layout.pageSize;
274150
+ const resolved = this.getResolvedPage(pageIndex);
274151
+ const pageSize = resolved ? {
274152
+ w: resolved.width,
274153
+ h: resolved.height
274154
+ } : page.size ?? layout.pageSize;
274252
274155
  const pageEl = this.renderPage(pageSize.w, pageSize.h, page, pageIndex);
274253
274156
  mount.appendChild(pageEl);
274254
274157
  });
@@ -274260,7 +274163,11 @@ function print() { __p += __j.call(arguments, '') }
274260
274163
  const pages = layout.pages;
274261
274164
  if (pages.length === 0)
274262
274165
  return;
274263
- const firstPageSize = pages[0].size ?? layout.pageSize;
274166
+ const firstResolved = this.getResolvedPage(0);
274167
+ const firstPageSize = firstResolved ? {
274168
+ w: firstResolved.width,
274169
+ h: firstResolved.height
274170
+ } : pages[0].size ?? layout.pageSize;
274264
274171
  const firstPageEl = this.renderPage(firstPageSize.w, firstPageSize.h, pages[0], 0);
274265
274172
  mount.appendChild(firstPageEl);
274266
274173
  for (let i4 = 1;i4 < pages.length; i4 += 2) {
@@ -274268,12 +274175,20 @@ function print() { __p += __j.call(arguments, '') }
274268
274175
  spreadEl.classList.add(CLASS_NAMES$1.spread);
274269
274176
  applyStyles(spreadEl, spreadStyles);
274270
274177
  const leftPage = pages[i4];
274271
- const leftPageSize = leftPage.size ?? layout.pageSize;
274178
+ const leftResolved = this.getResolvedPage(i4);
274179
+ const leftPageSize = leftResolved ? {
274180
+ w: leftResolved.width,
274181
+ h: leftResolved.height
274182
+ } : leftPage.size ?? layout.pageSize;
274272
274183
  const leftPageEl = this.renderPage(leftPageSize.w, leftPageSize.h, leftPage, i4);
274273
274184
  spreadEl.appendChild(leftPageEl);
274274
274185
  if (i4 + 1 < pages.length) {
274275
274186
  const rightPage = pages[i4 + 1];
274276
- const rightPageSize = rightPage.size ?? layout.pageSize;
274187
+ const rightResolved = this.getResolvedPage(i4 + 1);
274188
+ const rightPageSize = rightResolved ? {
274189
+ w: rightResolved.width,
274190
+ h: rightResolved.height
274191
+ } : rightPage.size ?? layout.pageSize;
274277
274192
  const rightPageEl = this.renderPage(rightPageSize.w, rightPageSize.h, rightPage, i4 + 1);
274278
274193
  spreadEl.appendChild(rightPageEl);
274279
274194
  }
@@ -274306,7 +274221,8 @@ function print() { __p += __j.call(arguments, '') }
274306
274221
  const betweenBorderFlags = computeBetweenBorderFlags(page.fragments, this.blockLookup);
274307
274222
  page.fragments.forEach((fragment2, index2) => {
274308
274223
  const sdtBoundary = sdtBoundaries.get(index2);
274309
- el.appendChild(this.renderFragment(fragment2, contextBase, sdtBoundary, betweenBorderFlags.get(index2)));
274224
+ const resolvedItem = this.getResolvedFragmentItem(pageIndex, index2);
274225
+ el.appendChild(this.renderFragment(fragment2, contextBase, sdtBoundary, betweenBorderFlags.get(index2), resolvedItem));
274310
274226
  });
274311
274227
  this.renderDecorationsForPage(el, page, pageIndex);
274312
274228
  return el;
@@ -274527,7 +274443,11 @@ function print() { __p += __j.call(arguments, '') }
274527
274443
  this.mount.innerHTML = "";
274528
274444
  this.pageStates = [];
274529
274445
  layout.pages.forEach((page, pageIndex) => {
274530
- const pageSize = page.size ?? layout.pageSize;
274446
+ const resolved = this.getResolvedPage(pageIndex);
274447
+ const pageSize = resolved ? {
274448
+ w: resolved.width,
274449
+ h: resolved.height
274450
+ } : page.size ?? layout.pageSize;
274531
274451
  const pageState = this.createPageState(page, pageSize, pageIndex);
274532
274452
  pageState.element.dataset.pageNumber = String(page.number);
274533
274453
  pageState.element.dataset.pageIndex = String(pageIndex);
@@ -274540,7 +274460,11 @@ function print() { __p += __j.call(arguments, '') }
274540
274460
  return;
274541
274461
  const nextStates = [];
274542
274462
  layout.pages.forEach((page, index2) => {
274543
- const pageSize = page.size ?? layout.pageSize;
274463
+ const resolved = this.getResolvedPage(index2);
274464
+ const pageSize = resolved ? {
274465
+ w: resolved.width,
274466
+ h: resolved.height
274467
+ } : page.size ?? layout.pageSize;
274544
274468
  const prevState = this.pageStates[index2];
274545
274469
  if (!prevState) {
274546
274470
  const newState = this.createPageState(page, pageSize, index2);
@@ -274580,6 +274504,7 @@ function print() { __p += __j.call(arguments, '') }
274580
274504
  const current = existing.get(key$1);
274581
274505
  const sdtBoundary = sdtBoundaries.get(index2);
274582
274506
  const betweenInfo = betweenBorderFlags.get(index2);
274507
+ const resolvedItem = this.getResolvedFragmentItem(pageIndex, index2);
274583
274508
  if (current) {
274584
274509
  existing.delete(key$1);
274585
274510
  const sdtBoundaryMismatch = shouldRebuildForSdtBoundary(current.element, sdtBoundary);
@@ -274587,13 +274512,13 @@ function print() { __p += __j.call(arguments, '') }
274587
274512
  const newPmStart = fragment2.pmStart;
274588
274513
  const mappingUnreliable = this.currentMapping != null && newPmStart != null && current.element.dataset.pmStart != null && this.currentMapping.map(Number(current.element.dataset.pmStart)) !== newPmStart;
274589
274514
  if (this.changedBlocks.has(fragment2.blockId) || current.signature !== fragmentSignature(fragment2, this.blockLookup) || sdtBoundaryMismatch || betweenBorderMismatch || mappingUnreliable) {
274590
- const replacement = this.renderFragment(fragment2, contextBase, sdtBoundary, betweenInfo);
274515
+ const replacement = this.renderFragment(fragment2, contextBase, sdtBoundary, betweenInfo, resolvedItem);
274591
274516
  pageEl.replaceChild(replacement, current.element);
274592
274517
  current.element = replacement;
274593
274518
  current.signature = fragmentSignature(fragment2, this.blockLookup);
274594
274519
  } else if (this.currentMapping)
274595
274520
  this.updatePositionAttributes(current.element, this.currentMapping);
274596
- this.updateFragmentElement(current.element, fragment2, contextBase.section);
274521
+ this.updateFragmentElement(current.element, fragment2, contextBase.section, resolvedItem);
274597
274522
  if (sdtBoundary?.widthOverride != null)
274598
274523
  current.element.style.width = `${sdtBoundary.widthOverride}px`;
274599
274524
  current.fragment = fragment2;
@@ -274602,7 +274527,7 @@ function print() { __p += __j.call(arguments, '') }
274602
274527
  nextFragments.push(current);
274603
274528
  return;
274604
274529
  }
274605
- const fresh = this.renderFragment(fragment2, contextBase, sdtBoundary, betweenInfo);
274530
+ const fresh = this.renderFragment(fragment2, contextBase, sdtBoundary, betweenInfo, resolvedItem);
274606
274531
  pageEl.insertBefore(fresh, pageEl.children[index2] ?? null);
274607
274532
  nextFragments.push({
274608
274533
  key: key$1,
@@ -274669,7 +274594,8 @@ function print() { __p += __j.call(arguments, '') }
274669
274594
  const betweenBorderFlags = computeBetweenBorderFlags(page.fragments, this.blockLookup);
274670
274595
  const fragmentStates = page.fragments.map((fragment2, index2) => {
274671
274596
  const sdtBoundary = sdtBoundaries.get(index2);
274672
- const fragmentEl = this.renderFragment(fragment2, contextBase, sdtBoundary, betweenBorderFlags.get(index2));
274597
+ const resolvedItem = this.getResolvedFragmentItem(pageIndex, index2);
274598
+ const fragmentEl = this.renderFragment(fragment2, contextBase, sdtBoundary, betweenBorderFlags.get(index2), resolvedItem);
274673
274599
  el.appendChild(fragmentEl);
274674
274600
  return {
274675
274601
  key: fragmentKey(fragment2),
@@ -274710,20 +274636,20 @@ function print() { __p += __j.call(arguments, '') }
274710
274636
  };
274711
274637
  return this.options.pageStyles;
274712
274638
  }
274713
- renderFragment(fragment2, context, sdtBoundary, betweenInfo) {
274639
+ renderFragment(fragment2, context, sdtBoundary, betweenInfo, resolvedItem) {
274714
274640
  if (fragment2.kind === "para")
274715
- return this.renderParagraphFragment(fragment2, context, sdtBoundary, betweenInfo);
274641
+ return this.renderParagraphFragment(fragment2, context, sdtBoundary, betweenInfo, resolvedItem);
274716
274642
  if (fragment2.kind === "list-item")
274717
- return this.renderListItemFragment(fragment2, context, sdtBoundary, betweenInfo);
274643
+ return this.renderListItemFragment(fragment2, context, sdtBoundary, betweenInfo, resolvedItem);
274718
274644
  if (fragment2.kind === "image")
274719
- return this.renderImageFragment(fragment2, context);
274645
+ return this.renderImageFragment(fragment2, context, resolvedItem);
274720
274646
  if (fragment2.kind === "drawing")
274721
- return this.renderDrawingFragment(fragment2, context);
274647
+ return this.renderDrawingFragment(fragment2, context, resolvedItem);
274722
274648
  if (fragment2.kind === "table")
274723
- return this.renderTableFragment(fragment2, context, sdtBoundary);
274649
+ return this.renderTableFragment(fragment2, context, sdtBoundary, resolvedItem);
274724
274650
  throw new Error(`DomPainter: unsupported fragment kind ${fragment2.kind}`);
274725
274651
  }
274726
- renderParagraphFragment(fragment2, context, sdtBoundary, betweenInfo) {
274652
+ renderParagraphFragment(fragment2, context, sdtBoundary, betweenInfo, resolvedItem) {
274727
274653
  try {
274728
274654
  const lookup3 = this.blockLookup.get(fragment2.blockId);
274729
274655
  if (!lookup3 || lookup3.block.kind !== "paragraph" || lookup3.measure.kind !== "paragraph")
@@ -274747,7 +274673,10 @@ function print() { __p += __j.call(arguments, '') }
274747
274673
  ...fragmentStyles,
274748
274674
  overflow: "visible"
274749
274675
  } : fragmentStyles);
274750
- this.applyFragmentFrame(fragmentEl, fragment2, context.section);
274676
+ if (resolvedItem)
274677
+ this.applyResolvedFragmentFrame(fragmentEl, resolvedItem, fragment2, context.section);
274678
+ else
274679
+ this.applyFragmentFrame(fragmentEl, fragment2, context.section);
274751
274680
  if (isTocEntry)
274752
274681
  fragmentEl.classList.add("superdoc-toc-entry");
274753
274682
  if (fragment2.continuesFromPrev)
@@ -274976,7 +274905,7 @@ function print() { __p += __j.call(arguments, '') }
274976
274905
  }
274977
274906
  return dropCapEl;
274978
274907
  }
274979
- renderListItemFragment(fragment2, context, sdtBoundary, betweenInfo) {
274908
+ renderListItemFragment(fragment2, context, sdtBoundary, betweenInfo, resolvedItem) {
274980
274909
  try {
274981
274910
  const lookup3 = this.blockLookup.get(fragment2.blockId);
274982
274911
  if (!lookup3 || lookup3.block.kind !== "list" || lookup3.measure.kind !== "list")
@@ -274992,10 +274921,14 @@ function print() { __p += __j.call(arguments, '') }
274992
274921
  const fragmentEl = this.doc.createElement("div");
274993
274922
  fragmentEl.classList.add(CLASS_NAMES$1.fragment, `${CLASS_NAMES$1.fragment}-list-item`);
274994
274923
  applyStyles(fragmentEl, fragmentStyles);
274995
- fragmentEl.style.left = `${fragment2.x - fragment2.markerWidth}px`;
274996
- fragmentEl.style.top = `${fragment2.y}px`;
274997
- fragmentEl.style.width = `${fragment2.markerWidth + fragment2.width}px`;
274998
- fragmentEl.dataset.blockId = fragment2.blockId;
274924
+ if (resolvedItem)
274925
+ this.applyResolvedListItemWrapperFrame(fragmentEl, fragment2, resolvedItem, context.section);
274926
+ else {
274927
+ fragmentEl.style.left = `${fragment2.x - fragment2.markerWidth}px`;
274928
+ fragmentEl.style.top = `${fragment2.y}px`;
274929
+ fragmentEl.style.width = `${fragment2.markerWidth + fragment2.width}px`;
274930
+ fragmentEl.dataset.blockId = fragment2.blockId;
274931
+ }
274999
274932
  fragmentEl.dataset.itemId = fragment2.itemId;
275000
274933
  const paragraphMetadata = item.paragraph.attrs?.sdt;
275001
274934
  this.applySdtDataset(fragmentEl, paragraphMetadata);
@@ -275074,7 +275007,7 @@ function print() { __p += __j.call(arguments, '') }
275074
275007
  return this.createErrorPlaceholder(fragment2.blockId, error3);
275075
275008
  }
275076
275009
  }
275077
- renderImageFragment(fragment2, context) {
275010
+ renderImageFragment(fragment2, context, resolvedItem) {
275078
275011
  try {
275079
275012
  const lookup3 = this.blockLookup.get(fragment2.blockId);
275080
275013
  if (!lookup3 || lookup3.block.kind !== "image" || lookup3.measure.kind !== "image")
@@ -275085,12 +275018,15 @@ function print() { __p += __j.call(arguments, '') }
275085
275018
  const fragmentEl = this.doc.createElement("div");
275086
275019
  fragmentEl.classList.add(CLASS_NAMES$1.fragment, DOM_CLASS_NAMES.IMAGE_FRAGMENT);
275087
275020
  applyStyles(fragmentEl, fragmentStyles);
275088
- this.applyFragmentFrame(fragmentEl, fragment2, context.section);
275089
- fragmentEl.style.height = `${fragment2.height}px`;
275021
+ if (resolvedItem)
275022
+ this.applyResolvedFragmentFrame(fragmentEl, resolvedItem, fragment2, context.section);
275023
+ else {
275024
+ this.applyFragmentFrame(fragmentEl, fragment2, context.section);
275025
+ fragmentEl.style.height = `${fragment2.height}px`;
275026
+ this.applyFragmentWrapperZIndex(fragmentEl, fragment2);
275027
+ }
275090
275028
  this.applySdtDataset(fragmentEl, block.attrs?.sdt);
275091
275029
  this.applyContainerSdtDataset(fragmentEl, block.attrs?.containerSdt);
275092
- if (fragment2.isAnchored && fragment2.zIndex != null)
275093
- fragmentEl.style.zIndex = String(fragment2.zIndex);
275094
275030
  if (block.id)
275095
275031
  fragmentEl.setAttribute("data-sd-block-id", block.id);
275096
275032
  if (fragment2.pmStart != null)
@@ -275143,7 +275079,7 @@ function print() { __p += __j.call(arguments, '') }
275143
275079
  return this.createErrorPlaceholder(fragment2.blockId, error3);
275144
275080
  }
275145
275081
  }
275146
- renderDrawingFragment(fragment2, context) {
275082
+ renderDrawingFragment(fragment2, context, resolvedItem) {
275147
275083
  try {
275148
275084
  const lookup3 = this.blockLookup.get(fragment2.blockId);
275149
275085
  if (!lookup3 || lookup3.block.kind !== "drawing" || lookup3.measure.kind !== "drawing")
@@ -275155,12 +275091,15 @@ function print() { __p += __j.call(arguments, '') }
275155
275091
  const fragmentEl = this.doc.createElement("div");
275156
275092
  fragmentEl.classList.add(CLASS_NAMES$1.fragment, "superdoc-drawing-fragment");
275157
275093
  applyStyles(fragmentEl, fragmentStyles);
275158
- this.applyFragmentFrame(fragmentEl, fragment2, context.section);
275159
- fragmentEl.style.height = `${fragment2.height}px`;
275094
+ if (resolvedItem)
275095
+ this.applyResolvedFragmentFrame(fragmentEl, resolvedItem, fragment2, context.section);
275096
+ else {
275097
+ this.applyFragmentFrame(fragmentEl, fragment2, context.section);
275098
+ fragmentEl.style.height = `${fragment2.height}px`;
275099
+ this.applyFragmentWrapperZIndex(fragmentEl, fragment2);
275100
+ }
275160
275101
  fragmentEl.style.position = "absolute";
275161
275102
  fragmentEl.style.overflow = "hidden";
275162
- if (fragment2.isAnchored && fragment2.zIndex != null)
275163
- fragmentEl.style.zIndex = String(fragment2.zIndex);
275164
275103
  const innerWrapper = this.doc.createElement("div");
275165
275104
  innerWrapper.classList.add("superdoc-drawing-inner");
275166
275105
  innerWrapper.style.position = "absolute";
@@ -275700,11 +275639,11 @@ function print() { __p += __j.call(arguments, '') }
275700
275639
  createChartElement(block) {
275701
275640
  return createChartElement(this.doc, block.chartData, block.geometry);
275702
275641
  }
275703
- renderTableFragment(fragment2, context, sdtBoundary) {
275642
+ renderTableFragment(fragment2, context, sdtBoundary, resolvedItem) {
275704
275643
  if (!this.doc)
275705
275644
  throw new Error("DomPainter: document is not available");
275706
- const applyFragmentFrameWithSection = (el, frag) => {
275707
- this.applyFragmentFrame(el, frag, context.section);
275645
+ const applyFragmentFrameWithSection = (el$1, frag) => {
275646
+ this.applyFragmentFrame(el$1, frag, context.section);
275708
275647
  };
275709
275648
  const renderLineForTableCell = (block, line, ctx$1, lineIndex, isLastLine, resolvedListTextStartPx) => {
275710
275649
  const paragraphEndsWithLineBreak = (block.runs.length > 0 ? block.runs[block.runs.length - 1] : null)?.kind === "lineBreak";
@@ -275722,7 +275661,7 @@ function print() { __p += __j.call(arguments, '') }
275722
275661
  return this.createChartElement(block);
275723
275662
  return this.createDrawingPlaceholder();
275724
275663
  };
275725
- return renderTableFragment({
275664
+ const el = renderTableFragment({
275726
275665
  doc: this.doc,
275727
275666
  fragment: fragment2,
275728
275667
  context,
@@ -275742,6 +275681,9 @@ function print() { __p += __j.call(arguments, '') }
275742
275681
  applyContainerSdtDataset: this.applyContainerSdtDataset.bind(this),
275743
275682
  applyStyles
275744
275683
  });
275684
+ if (resolvedItem)
275685
+ this.applyResolvedFragmentFrame(el, resolvedItem, fragment2, context.section);
275686
+ return el;
275745
275687
  }
275746
275688
  extractLinkData(run2) {
275747
275689
  if (run2.kind === "tab" || run2.kind === "image" || run2.kind === "lineBreak" || run2.kind === "math")
@@ -276829,12 +276771,20 @@ function print() { __p += __j.call(arguments, '') }
276829
276771
  if (this.activeCommentId && meta2.id === this.activeCommentId)
276830
276772
  elem.classList.add(TRACK_CHANGE_FOCUSED_CLASS);
276831
276773
  }
276832
- updateFragmentElement(el, fragment2, section) {
276833
- this.applyFragmentFrame(el, fragment2, section);
276834
- if (fragment2.kind === "image")
276835
- el.style.height = `${fragment2.height}px`;
276836
- if (fragment2.kind === "drawing")
276837
- el.style.height = `${fragment2.height}px`;
276774
+ updateFragmentElement(el, fragment2, section, resolvedItem) {
276775
+ if (fragment2.kind === "list-item" && resolvedItem) {
276776
+ this.applyResolvedListItemWrapperFrame(el, fragment2, resolvedItem, section);
276777
+ return;
276778
+ }
276779
+ if (resolvedItem)
276780
+ this.applyResolvedFragmentFrame(el, resolvedItem, fragment2, section);
276781
+ else {
276782
+ this.applyFragmentFrame(el, fragment2, section);
276783
+ if (fragment2.kind === "image" || fragment2.kind === "drawing") {
276784
+ el.style.height = `${fragment2.height}px`;
276785
+ this.applyFragmentWrapperZIndex(el, fragment2);
276786
+ }
276787
+ }
276838
276788
  }
276839
276789
  applyFragmentFrame(el, fragment2, section) {
276840
276790
  el.style.left = `${fragment2.x}px`;
@@ -276865,6 +276815,58 @@ function print() { __p += __j.call(arguments, '') }
276865
276815
  delete el.dataset.continuesOnNext;
276866
276816
  }
276867
276817
  }
276818
+ applyFragmentPmAttributes(el, fragment2, section) {
276819
+ if (typeof fragment2.blockId === "string" && fragment2.blockId.startsWith("footnote-"))
276820
+ el.setAttribute("contenteditable", "false");
276821
+ if (fragment2.kind === "para") {
276822
+ if (section === "body" || section === undefined)
276823
+ assertFragmentPmPositions(fragment2, "paragraph fragment");
276824
+ if (fragment2.pmStart != null)
276825
+ el.dataset.pmStart = String(fragment2.pmStart);
276826
+ else
276827
+ delete el.dataset.pmStart;
276828
+ if (fragment2.pmEnd != null)
276829
+ el.dataset.pmEnd = String(fragment2.pmEnd);
276830
+ else
276831
+ delete el.dataset.pmEnd;
276832
+ if (fragment2.continuesFromPrev)
276833
+ el.dataset.continuesFromPrev = "true";
276834
+ else
276835
+ delete el.dataset.continuesFromPrev;
276836
+ if (fragment2.continuesOnNext)
276837
+ el.dataset.continuesOnNext = "true";
276838
+ else
276839
+ delete el.dataset.continuesOnNext;
276840
+ }
276841
+ }
276842
+ isAnchoredMediaFragment(fragment2) {
276843
+ return (fragment2.kind === "image" || fragment2.kind === "drawing") && fragment2.isAnchored === true;
276844
+ }
276845
+ resolveFragmentWrapperZIndex(fragment2, resolvedZIndex) {
276846
+ if (!this.isAnchoredMediaFragment(fragment2))
276847
+ return "";
276848
+ const zIndex = resolvedZIndex ?? fragment2.zIndex;
276849
+ return zIndex != null ? String(zIndex) : "";
276850
+ }
276851
+ applyFragmentWrapperZIndex(el, fragment2, resolvedZIndex) {
276852
+ el.style.zIndex = this.resolveFragmentWrapperZIndex(fragment2, resolvedZIndex);
276853
+ }
276854
+ applyResolvedFragmentFrame(el, item, fragment2, section) {
276855
+ el.style.left = `${item.x}px`;
276856
+ el.style.top = `${item.y}px`;
276857
+ el.style.width = `${item.width}px`;
276858
+ el.dataset.blockId = item.blockId;
276859
+ el.dataset.layoutEpoch = String(this.layoutEpoch);
276860
+ this.applyFragmentWrapperZIndex(el, fragment2, item.zIndex);
276861
+ if (item.fragmentKind === "image" || item.fragmentKind === "drawing" || item.fragmentKind === "table")
276862
+ el.style.height = `${item.height}px`;
276863
+ this.applyFragmentPmAttributes(el, fragment2, section);
276864
+ }
276865
+ applyResolvedListItemWrapperFrame(el, fragment2, item, section) {
276866
+ this.applyResolvedFragmentFrame(el, item, fragment2, section);
276867
+ el.style.left = `${item.x - fragment2.markerWidth}px`;
276868
+ el.style.width = `${item.width + fragment2.markerWidth}px`;
276869
+ }
276868
276870
  estimateFragmentHeight(fragment2) {
276869
276871
  const measure = this.blockLookup.get(fragment2.blockId)?.measure;
276870
276872
  if (fragment2.kind === "para" && measure?.kind === "paragraph")
@@ -284363,12 +284365,7 @@ function print() { __p += __j.call(arguments, '') }
284363
284365
  ]);
284364
284366
  init_dist4();
284365
284367
  SPACE_CHARS$1 = SPACE_CHARS;
284366
- CLASS_NAMES = {
284367
- page: DOM_CLASS_NAMES.PAGE,
284368
- fragment: DOM_CLASS_NAMES.FRAGMENT,
284369
- line: DOM_CLASS_NAMES.LINE,
284370
- tableFragment: DOM_CLASS_NAMES.TABLE_FRAGMENT
284371
- };
284368
+ DOM_CLASS_NAMES.PAGE, DOM_CLASS_NAMES.FRAGMENT, DOM_CLASS_NAMES.LINE, DOM_CLASS_NAMES.TABLE_FRAGMENT;
284372
284369
  init_dist4();
284373
284370
  FeatureFlags = {
284374
284371
  NUMBERING_SECTION_AWARE: isEnabled("SD_NUMBERING_SECTION_AWARE", true),
@@ -284722,6 +284719,13 @@ function print() { __p += __j.call(arguments, '') }
284722
284719
  paragraphToFlowBlocks
284723
284720
  };
284724
284721
  DEFAULT_STALE_TIMEOUT_MS = 300 * 1000;
284722
+ CLASS = {
284723
+ page: DOM_CLASS_NAMES.PAGE,
284724
+ fragment: DOM_CLASS_NAMES.FRAGMENT,
284725
+ line: DOM_CLASS_NAMES.LINE,
284726
+ tableFragment: DOM_CLASS_NAMES.TABLE_FRAGMENT,
284727
+ inlineSdtWrapper: DOM_CLASS_NAMES.INLINE_SDT_WRAPPER
284728
+ };
284725
284729
  SelectionSyncCoordinator = class extends EventEmitter2 {
284726
284730
  #docEpoch = 0;
284727
284731
  #layoutEpoch = 0;
@@ -287614,6 +287618,7 @@ function print() { __p += __j.call(arguments, '') }
287614
287618
  const previousMeasures = this.#layoutState.measures;
287615
287619
  let layout;
287616
287620
  let measures;
287621
+ let resolvedLayout;
287617
287622
  let headerLayouts;
287618
287623
  let footerLayouts;
287619
287624
  let extraBlocks;
@@ -287640,6 +287645,12 @@ function print() { __p += __j.call(arguments, '') }
287640
287645
  extraMeasures = Array.isArray(result.extraMeasures) ? result.extraMeasures : undefined;
287641
287646
  layout.pageGap = this.#getEffectivePageGap();
287642
287647
  layout.layoutEpoch = layoutEpoch;
287648
+ resolvedLayout = resolveLayout({
287649
+ layout,
287650
+ flowMode: this.#layoutOptions.flowMode ?? "paginated",
287651
+ blocks: blocksForLayout,
287652
+ measures
287653
+ });
287643
287654
  headerLayouts = result.headers;
287644
287655
  footerLayouts = result.footers;
287645
287656
  } catch (error3) {
@@ -287691,6 +287702,7 @@ function print() { __p += __j.call(arguments, '') }
287691
287702
  this.#updateDecorationProviders(layout);
287692
287703
  }
287693
287704
  const painter = this.#ensurePainter(blocksForLayout, measures);
287705
+ painter.setResolvedLayout?.(resolvedLayout);
287694
287706
  if (!isSemanticFlow && typeof painter.setProviders === "function")
287695
287707
  painter.setProviders(this.#headerFooterSession?.headerDecorationProvider, this.#headerFooterSession?.footerDecorationProvider);
287696
287708
  const headerBlocks = [];
@@ -289304,7 +289316,7 @@ var init_zipper_YmNpPIyc_es = __esm(() => {
289304
289316
 
289305
289317
  // ../../packages/superdoc/dist/super-editor.es.js
289306
289318
  var init_super_editor_es = __esm(() => {
289307
- init_src_0P3ZlqDX_es();
289319
+ init_src_CqUAwJtN_es();
289308
289320
  init_SuperConverter_B9oNf3OB_es();
289309
289321
  init_jszip_ChlR43oI_es();
289310
289322
  init_xml_js_40FWvL78_es();