@harbour-enterprises/superdoc 1.12.0-next.13 → 1.12.0-next.14

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,4 +1,4 @@
1
- import { g as generateDocxRandomId, T as TextSelection$1, o as objectIncludes, w as wrapTextsInRuns, D as DOMParser$1, c as createDocFromMarkdown, a as createDocFromHTML, F as Fragment, b as chainableEditorState, d as convertMarkdownToHTML, f as findParentNode, e as findParentNodeClosestToPos, h as generateRandom32BitHex, i as generateRandomSigned32BitIntStrId, P as Plugin, j as PluginKey, M as Mapping, N as NodeSelection, k as Selection, l as Slice, m as DOMSerializer, n as Mark$1, p as dropPoint, A as AllSelection, q as Schema$2, s as canSplit, t as resolveRunProperties, u as encodeMarksFromRPr, v as liftTarget, x as replaceStep$1, y as canJoin, z as joinPoint, 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, O as TrackInsertMarkName, Q as TrackFormatMarkName, U as AddMarkStep, V as RemoveMarkStep, W as CommandService, S as SuperConverter, X as EditorState, Y as unflattenListsInHtml, Z as SelectionRange, _ as Transform, $ as resolveParagraphProperties, a0 as resolveDocxFontFamily, a1 as _getReferencedTableStyles, a2 as resolveTableCellProperties, a3 as decodeRPrFromMarks, a4 as carbonCopy, a5 as calculateResolvedParagraphProperties, a6 as encodeCSSFromPPr, a7 as encodeCSSFromRPr, a8 as generateOrderedListIndex, a9 as docxNumberingHelpers, aa as InputRule, ab as insertNewRelationship, ac as kebabCase$1, ad as getUnderlineCssString, ae as handleClipboardPaste } from "./SuperConverter-Dx95dNlr.es.js";
1
+ import { g as generateDocxRandomId, T as TextSelection$1, o as objectIncludes, w as wrapTextsInRuns, D as DOMParser$1, c as createDocFromMarkdown, a as createDocFromHTML, F as Fragment, b as chainableEditorState, d as convertMarkdownToHTML, f as findParentNode, e as findParentNodeClosestToPos, h as generateRandom32BitHex, i as generateRandomSigned32BitIntStrId, P as Plugin, j as PluginKey, M as Mapping, N as NodeSelection, k as Selection, l as Slice, m as DOMSerializer, n as Mark$1, p as dropPoint, A as AllSelection, q as Schema$2, s as canSplit, t as resolveRunProperties, u as encodeMarksFromRPr, v as liftTarget, x as replaceStep$1, y as canJoin, z as joinPoint, 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, O as TrackInsertMarkName, Q as TrackFormatMarkName, U as AddMarkStep, V as RemoveMarkStep, W as CommandService, S as SuperConverter, X as EditorState, Y as unflattenListsInHtml, Z as SelectionRange, _ as Transform, $ as resolveParagraphProperties, a0 as resolveDocxFontFamily, a1 as _getReferencedTableStyles, a2 as resolveTableCellProperties, a3 as decodeRPrFromMarks, a4 as carbonCopy, a5 as calculateResolvedParagraphProperties, a6 as encodeCSSFromPPr, a7 as encodeCSSFromRPr, a8 as generateOrderedListIndex, a9 as docxNumberingHelpers, aa as InputRule, ab as insertNewRelationship, ac as kebabCase$1, ad as getUnderlineCssString, ae as handleClipboardPaste } from "./SuperConverter-CA4Y375g.es.js";
2
2
  import { j as twipsToInches, m as inchesToTwips, p as ptToTwips, d as linesToTwips, f as twipsToLines, k as pixelsToTwips, z as resolveOpcTargetPath, B as Buffer$3, D as getArrayBufferFromUrl, h as halfPointToPoints, c as twipsToPixels$2, E as convertSizeToCSS, F as inchesToPixels } from "./helpers-BqdwtJE0.es.js";
3
3
  import { p as process$1$2, r as ref, b as computed, c as createElementBlock, F as Fragment$1, U as renderList, O as withModifiers, o as openBlock, Q as normalizeClass, M as toDisplayString, i as createCommentVNode, a as createBaseVNode, V as createApp, e as onMounted, f as onUnmounted, u as unref, S as withDirectives, Y as vModelText, D as nextTick, N as normalizeStyle, B as watch, Z as withKeys, _ as createTextVNode, g as createVNode, h as h$1, $ as readonly, E as getCurrentInstance, l as onBeforeUnmount, s as reactive, m as onBeforeMount, j as inject, a0 as onActivated, a1 as onDeactivated, a2 as Comment, d as defineComponent, k as provide, q as Teleport, t as toRef, a3 as renderSlot, a4 as isVNode, K as shallowRef, w as watchEffect, J as global$2, T as Transition, a5 as mergeProps, a6 as vShow, a7 as cloneVNode, a8 as Text$2, x as markRaw, P as createBlock, L as withCtx, a9 as useCssVars, W as resolveDynamicComponent, aa as normalizeProps, ab as guardReactiveProps } from "./vue-DiPLN5sT.es.js";
4
4
  import "./jszip.min-BCZQ7Wq2.es.js";
@@ -976,7 +976,7 @@ const DEFAULT_ENDPOINT = "https://ingest.superdoc.dev/v1/collect";
976
976
  const COMMUNITY_LICENSE_KEY = "community-and-eval-agplv3";
977
977
  function getSuperdocVersion() {
978
978
  try {
979
- return true ? "1.12.0-next.13" : "unknown";
979
+ return true ? "1.12.0-next.14" : "unknown";
980
980
  } catch {
981
981
  return "unknown";
982
982
  }
@@ -17051,7 +17051,7 @@ const canUseDOM = () => {
17051
17051
  return false;
17052
17052
  }
17053
17053
  };
17054
- const summaryVersion = "1.12.0-next.13";
17054
+ const summaryVersion = "1.12.0-next.14";
17055
17055
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
17056
17056
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
17057
17057
  function mapAttributes(attrs) {
@@ -19855,7 +19855,7 @@ class Editor extends EventEmitter {
19855
19855
  * Process collaboration migrations
19856
19856
  */
19857
19857
  processCollaborationMigrations() {
19858
- console.debug("[checkVersionMigrations] Current editor version", "1.12.0-next.13");
19858
+ console.debug("[checkVersionMigrations] Current editor version", "1.12.0-next.14");
19859
19859
  if (!this.options.ydoc) return;
19860
19860
  const metaMap = this.options.ydoc.getMap("meta");
19861
19861
  let docVersion = metaMap.get("version");
@@ -25671,6 +25671,11 @@ const DOM_CLASS_NAMES = {
25671
25671
  * Class name for block-level structured content containers.
25672
25672
  */
25673
25673
  BLOCK_SDT: "superdoc-structured-content-block",
25674
+ /**
25675
+ * Class name for table fragment containers.
25676
+ * Applied to table fragments for resize overlay targeting and click mapping.
25677
+ */
25678
+ TABLE_FRAGMENT: "superdoc-table-fragment",
25674
25679
  /**
25675
25680
  * Class name added to block SDT fragments on hover via event delegation.
25676
25681
  * Applied/removed by SdtGroupedHover to highlight all fragments of the same SDT.
@@ -27366,16 +27371,31 @@ const renderTableFragment = (deps) => {
27366
27371
  container.style.height = `${fragment.height}px`;
27367
27372
  applySdtDataset(container, block.attrs?.sdt);
27368
27373
  applySdtContainerStyling(doc2, container, block.attrs?.sdt, block.attrs?.containerSdt, sdtBoundary);
27369
- container.classList.add("superdoc-table-fragment");
27374
+ container.classList.add(DOM_CLASS_NAMES.TABLE_FRAGMENT);
27370
27375
  if (fragment.metadata?.columnBoundaries) {
27371
27376
  const columnCount = measure.columnWidths.length;
27372
- const rowCount = block.rows.length;
27373
27377
  const boundarySegments = [];
27374
27378
  for (let i = 0; i < columnCount; i++) {
27375
27379
  boundarySegments.push([]);
27376
27380
  }
27381
+ const renderedRows = [];
27382
+ if (fragment.repeatHeaderCount && fragment.repeatHeaderCount > 0) {
27383
+ for (let r2 = 0; r2 < fragment.repeatHeaderCount; r2++) {
27384
+ const rowMeasure = measure.rows[r2];
27385
+ if (!rowMeasure) break;
27386
+ renderedRows.push({ rowIndex: r2, height: rowMeasure.height });
27387
+ }
27388
+ }
27389
+ for (let r2 = fragment.fromRow; r2 < fragment.toRow; r2++) {
27390
+ const rowMeasure = measure.rows[r2];
27391
+ if (!rowMeasure) break;
27392
+ const isPartialRow = fragment.partialRow && fragment.partialRow.rowIndex === r2;
27393
+ const actualHeight = isPartialRow ? fragment.partialRow.partialHeight : rowMeasure.height;
27394
+ renderedRows.push({ rowIndex: r2, height: actualHeight });
27395
+ }
27377
27396
  let rowY = 0;
27378
- for (let rowIndex = 0; rowIndex < rowCount; rowIndex++) {
27397
+ for (let i = 0; i < renderedRows.length; i++) {
27398
+ const { rowIndex, height } = renderedRows[i];
27379
27399
  const rowMeasure = measure.rows[rowIndex];
27380
27400
  if (!rowMeasure) continue;
27381
27401
  const boundariesInRow = /* @__PURE__ */ new Set();
@@ -27393,19 +27413,19 @@ const renderTableFragment = (deps) => {
27393
27413
  for (const boundaryCol of boundariesInRow) {
27394
27414
  const segments = boundarySegments[boundaryCol];
27395
27415
  const lastSegment = segments[segments.length - 1];
27396
- if (lastSegment && lastSegment.toRow === rowIndex) {
27397
- lastSegment.toRow = rowIndex + 1;
27398
- lastSegment.height += rowMeasure.height;
27416
+ if (lastSegment && i > 0 && lastSegment.toRow === i) {
27417
+ lastSegment.toRow = i + 1;
27418
+ lastSegment.height += height;
27399
27419
  } else {
27400
27420
  segments.push({
27401
- fromRow: rowIndex,
27402
- toRow: rowIndex + 1,
27421
+ fromRow: i,
27422
+ toRow: i + 1,
27403
27423
  y: rowY,
27404
- height: rowMeasure.height
27424
+ height
27405
27425
  });
27406
27426
  }
27407
27427
  }
27408
- rowY += rowMeasure.height;
27428
+ rowY += height;
27409
27429
  }
27410
27430
  const metadata = {
27411
27431
  columns: fragment.metadata.columnBoundaries.map((boundary) => ({
@@ -44612,7 +44632,8 @@ const log = (...args) => {
44612
44632
  const CLASS_NAMES = {
44613
44633
  page: DOM_CLASS_NAMES.PAGE,
44614
44634
  fragment: DOM_CLASS_NAMES.FRAGMENT,
44615
- line: DOM_CLASS_NAMES.LINE
44635
+ line: DOM_CLASS_NAMES.LINE,
44636
+ tableFragment: DOM_CLASS_NAMES.TABLE_FRAGMENT
44616
44637
  };
44617
44638
  function clickToPositionDom(domContainer, clientX, clientY) {
44618
44639
  const pageEl = findPageElement(domContainer, clientX, clientY);
@@ -44709,6 +44730,9 @@ function clickToPositionDom(domContainer, clientX, clientY) {
44709
44730
  const result2 = processLineElement(hitChainLine, viewX);
44710
44731
  return result2;
44711
44732
  }
44733
+ if (fragmentEl.classList.contains(CLASS_NAMES.tableFragment)) {
44734
+ return null;
44735
+ }
44712
44736
  const result = processFragment(fragmentEl, viewX, viewY);
44713
44737
  return result;
44714
44738
  }
@@ -52605,6 +52629,53 @@ var Priority = /* @__PURE__ */ ((Priority2) => {
52605
52629
  const isAtomicFragment = (fragment) => {
52606
52630
  return fragment.kind === "drawing" || fragment.kind === "image";
52607
52631
  };
52632
+ function snapToNearestFragment(pageHit, blocks, measures, pageRelativePoint) {
52633
+ const fragments = pageHit.page.fragments.filter(
52634
+ (f) => f != null && typeof f === "object"
52635
+ );
52636
+ let nearestHit = null;
52637
+ let nearestDist = Infinity;
52638
+ for (const frag of fragments) {
52639
+ const isPara = frag.kind === "para";
52640
+ const isAtomic = isAtomicFragment(frag);
52641
+ if (!isPara && !isAtomic) continue;
52642
+ const blockIndex = findBlockIndexByFragmentId(blocks, frag.blockId);
52643
+ if (blockIndex === -1) continue;
52644
+ const block = blocks[blockIndex];
52645
+ const measure = measures[blockIndex];
52646
+ if (!block || !measure) continue;
52647
+ let fragHeight = 0;
52648
+ if (isAtomic) {
52649
+ fragHeight = frag.height;
52650
+ } else if (isPara && block.kind === "paragraph" && measure.kind === "paragraph") {
52651
+ fragHeight = measure.lines.slice(frag.fromLine, frag.toLine).reduce((sum, line) => sum + line.lineHeight, 0);
52652
+ } else {
52653
+ continue;
52654
+ }
52655
+ const top2 = frag.y;
52656
+ const bottom2 = frag.y + fragHeight;
52657
+ let dist;
52658
+ if (pageRelativePoint.y < top2) {
52659
+ dist = top2 - pageRelativePoint.y;
52660
+ } else if (pageRelativePoint.y > bottom2) {
52661
+ dist = pageRelativePoint.y - bottom2;
52662
+ } else {
52663
+ dist = 0;
52664
+ }
52665
+ if (dist < nearestDist) {
52666
+ nearestDist = dist;
52667
+ const pageY = Math.max(0, Math.min(pageRelativePoint.y - top2, fragHeight));
52668
+ nearestHit = {
52669
+ fragment: frag,
52670
+ block,
52671
+ measure,
52672
+ pageIndex: pageHit.pageIndex,
52673
+ pageY
52674
+ };
52675
+ }
52676
+ }
52677
+ return nearestHit;
52678
+ }
52608
52679
  const logClickStage = (_level, _stage, _payload) => {
52609
52680
  };
52610
52681
  const logPositionDebug = (payload) => {
@@ -52909,66 +52980,46 @@ function clickToPosition(layout, blocks, measures, containerPoint, domContainer,
52909
52980
  return { pos: domPos, layoutEpoch: domLayoutEpoch, blockId: "", pageIndex: 0, column: 0, lineIndex: -1 };
52910
52981
  }
52911
52982
  }
52912
- const pageHit = hitTestPage(layout, containerPoint, geometryHelper);
52983
+ let pageHit = null;
52984
+ let isContainerPointPageRelative = false;
52985
+ if (domContainer != null && clientX != null && clientY != null) {
52986
+ const pageEl = findPageElement(domContainer, clientX, clientY);
52987
+ if (pageEl) {
52988
+ const domPageIndex = Number(pageEl.dataset.pageIndex ?? "NaN");
52989
+ if (Number.isFinite(domPageIndex) && domPageIndex >= 0 && domPageIndex < layout.pages.length) {
52990
+ pageHit = { pageIndex: domPageIndex, page: layout.pages[domPageIndex] };
52991
+ isContainerPointPageRelative = true;
52992
+ }
52993
+ }
52994
+ }
52995
+ if (!pageHit) {
52996
+ pageHit = hitTestPage(layout, containerPoint, geometryHelper);
52997
+ }
52913
52998
  if (!pageHit) {
52914
52999
  return null;
52915
53000
  }
52916
- const pageTopY = geometryHelper ? geometryHelper.getPageTop(pageHit.pageIndex) : calculatePageTopFallback(layout, pageHit.pageIndex);
52917
- const pageRelativePoint = {
52918
- x: containerPoint.x,
52919
- y: containerPoint.y - pageTopY
52920
- };
53001
+ let pageRelativePoint;
53002
+ if (isContainerPointPageRelative) {
53003
+ pageRelativePoint = containerPoint;
53004
+ } else {
53005
+ const pageTopY = geometryHelper ? geometryHelper.getPageTop(pageHit.pageIndex) : calculatePageTopFallback(layout, pageHit.pageIndex);
53006
+ pageRelativePoint = {
53007
+ x: containerPoint.x,
53008
+ y: containerPoint.y - pageTopY
53009
+ };
53010
+ }
52921
53011
  logClickStage("log", "page-hit", {
52922
53012
  pageIndex: pageHit.pageIndex
52923
53013
  });
52924
53014
  let fragmentHit = hitTestFragment(layout, pageHit, blocks, measures, pageRelativePoint);
52925
53015
  if (!fragmentHit) {
52926
- const page = pageHit.page;
52927
- const fragments = page.fragments.filter(
52928
- (f) => f != null && typeof f === "object"
52929
- );
52930
- let nearestHit = null;
52931
- let nearestDist = Infinity;
52932
- for (const frag of fragments) {
52933
- const isPara = frag.kind === "para";
52934
- const isAtomic = isAtomicFragment(frag);
52935
- if (!isPara && !isAtomic) continue;
52936
- const blockIndex = findBlockIndexByFragmentId(blocks, frag.blockId);
52937
- if (blockIndex === -1) continue;
52938
- const block = blocks[blockIndex];
52939
- const measure = measures[blockIndex];
52940
- if (!block || !measure) continue;
52941
- let fragHeight = 0;
52942
- if (isAtomic) {
52943
- fragHeight = frag.height;
52944
- } else if (isPara && block.kind === "paragraph" && measure.kind === "paragraph") {
52945
- fragHeight = measure.lines.slice(frag.fromLine, frag.toLine).reduce((sum, line) => sum + line.lineHeight, 0);
52946
- } else {
52947
- continue;
52948
- }
52949
- const top2 = frag.y;
52950
- const bottom2 = frag.y + fragHeight;
52951
- let dist;
52952
- if (pageRelativePoint.y < top2) {
52953
- dist = top2 - pageRelativePoint.y;
52954
- } else if (pageRelativePoint.y > bottom2) {
52955
- dist = pageRelativePoint.y - bottom2;
52956
- } else {
52957
- dist = 0;
52958
- }
52959
- if (dist < nearestDist) {
52960
- nearestDist = dist;
52961
- const pageY = Math.max(0, Math.min(pageRelativePoint.y - top2, fragHeight));
52962
- nearestHit = {
52963
- fragment: frag,
52964
- block,
52965
- measure,
52966
- pageIndex: pageHit.pageIndex,
52967
- pageY
52968
- };
52969
- }
53016
+ const isWithinTableFragment = pageHit.page.fragments.filter((f) => f.kind === "table").some((f) => {
53017
+ const tf = f;
53018
+ return pageRelativePoint.x >= tf.x && pageRelativePoint.x <= tf.x + tf.width && pageRelativePoint.y >= tf.y && pageRelativePoint.y <= tf.y + tf.height;
53019
+ });
53020
+ if (!isWithinTableFragment) {
53021
+ fragmentHit = snapToNearestFragment(pageHit, blocks, measures, pageRelativePoint);
52970
53022
  }
52971
- fragmentHit = nearestHit;
52972
53023
  }
52973
53024
  if (fragmentHit) {
52974
53025
  const { fragment, block, measure, pageIndex, pageY } = fragmentHit;
@@ -53008,7 +53059,8 @@ function clickToPosition(layout, blocks, measures, containerPoint, domContainer,
53008
53059
  const column = determineColumn(layout, fragment.x);
53009
53060
  logPositionDebug({
53010
53061
  blockId: fragment.blockId,
53011
- x: pageRelativePoint.x - fragment.x
53062
+ x: pageRelativePoint.x - fragment.x,
53063
+ y: pageRelativePoint.y
53012
53064
  });
53013
53065
  logClickStage("log", "success", {
53014
53066
  blockId: fragment.blockId
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  require("../chunks/helpers-OFep8CYR.cjs");
4
- const superEditor_converter = require("../chunks/SuperConverter-BMjvGr5r.cjs");
4
+ const superEditor_converter = require("../chunks/SuperConverter-OKWxKamo.cjs");
5
5
  require("../chunks/uuid-R7L08bOx.cjs");
6
6
  exports.SuperConverter = superEditor_converter.SuperConverter;
@@ -1,5 +1,5 @@
1
1
  import "../chunks/helpers-BqdwtJE0.es.js";
2
- import { S } from "../chunks/SuperConverter-Dx95dNlr.es.js";
2
+ import { S } from "../chunks/SuperConverter-CA4Y375g.es.js";
3
3
  import "../chunks/uuid-CjlX8hrF.es.js";
4
4
  export {
5
5
  S as SuperConverter
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("./chunks/index-BF7DfWLs.cjs");
3
+ const index = require("./chunks/index-CiZRgn7j.cjs");
4
4
  const superEditor_docxZipper = require("./super-editor/docx-zipper.cjs");
5
5
  const superEditor_fileZipper = require("./super-editor/file-zipper.cjs");
6
6
  const vue = require("./chunks/vue-BkoOkkmT.cjs");
7
- const superEditor_converter = require("./chunks/SuperConverter-BMjvGr5r.cjs");
7
+ const superEditor_converter = require("./chunks/SuperConverter-OKWxKamo.cjs");
8
8
  function isNodeType(node, name) {
9
9
  return node.type.name === name;
10
10
  }
@@ -1,9 +1,9 @@
1
- import { N as Node, M as Mark } from "./chunks/index-C-t9SDCr.es.js";
2
- import { A, a, C, E, b, P, S, _, c, d, e, T, f, i, g, h, j, k, l, m, n } from "./chunks/index-C-t9SDCr.es.js";
1
+ import { N as Node, M as Mark } from "./chunks/index-DwDTMIHF.es.js";
2
+ import { A, a, C, E, b, P, S, _, c, d, e, T, f, i, g, h, j, k, l, m, n } from "./chunks/index-DwDTMIHF.es.js";
3
3
  import { default as default2 } from "./super-editor/docx-zipper.es.js";
4
4
  import { createZip } from "./super-editor/file-zipper.es.js";
5
5
  import { d as defineComponent, o as openBlock, c as createElementBlock, a as createBaseVNode } from "./chunks/vue-DiPLN5sT.es.js";
6
- import { S as S2, r } from "./chunks/SuperConverter-Dx95dNlr.es.js";
6
+ import { S as S2, r } from "./chunks/SuperConverter-CA4Y375g.es.js";
7
7
  function isNodeType(node, name) {
8
8
  return node.type.name === name;
9
9
  }
package/dist/superdoc.cjs CHANGED
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("./chunks/index-BF7DfWLs.cjs");
4
- const superdoc = require("./chunks/index-DcUDN9u9.cjs");
3
+ const index = require("./chunks/index-CiZRgn7j.cjs");
4
+ const superdoc = require("./chunks/index-DQyH0Ms9.cjs");
5
5
  const blankDocx = require("./chunks/blank-docx-DfW3Eeh2.cjs");
6
- const superEditor_converter = require("./chunks/SuperConverter-BMjvGr5r.cjs");
6
+ const superEditor_converter = require("./chunks/SuperConverter-OKWxKamo.cjs");
7
7
  const superEditor_fileZipper = require("./super-editor/file-zipper.cjs");
8
8
  require("./chunks/helpers-OFep8CYR.cjs");
9
9
  require("./chunks/jszip.min-oAFpNMh5.cjs");
@@ -1,7 +1,7 @@
1
- import { a, E, b, S, i, ay, k, m, n } from "./chunks/index-C-t9SDCr.es.js";
2
- import { D, H, P, S as S2, c, g } from "./chunks/index-BTrpAvox.es.js";
1
+ import { a, E, b, S, i, ay, k, m, n } from "./chunks/index-DwDTMIHF.es.js";
2
+ import { D, H, P, S as S2, c, g } from "./chunks/index-B6-qYQaj.es.js";
3
3
  import { B } from "./chunks/blank-docx-ABm6XYAA.es.js";
4
- import { S as S3, r } from "./chunks/SuperConverter-Dx95dNlr.es.js";
4
+ import { S as S3, r } from "./chunks/SuperConverter-CA4Y375g.es.js";
5
5
  import { createZip } from "./super-editor/file-zipper.es.js";
6
6
  import "./chunks/helpers-BqdwtJE0.es.js";
7
7
  import "./chunks/jszip.min-BCZQ7Wq2.es.js";
@@ -34378,7 +34378,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34378
34378
  const COMMUNITY_LICENSE_KEY = "community-and-eval-agplv3";
34379
34379
  function getSuperdocVersion() {
34380
34380
  try {
34381
- return true ? "1.12.0-next.13" : "unknown";
34381
+ return true ? "1.12.0-next.14" : "unknown";
34382
34382
  } catch {
34383
34383
  return "unknown";
34384
34384
  }
@@ -37650,7 +37650,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
37650
37650
  static getStoredSuperdocVersion(docx) {
37651
37651
  return SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
37652
37652
  }
37653
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.12.0-next.13") {
37653
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.12.0-next.14") {
37654
37654
  return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
37655
37655
  }
37656
37656
  /**
@@ -65127,7 +65127,7 @@ ${err.toString()}`);
65127
65127
  return false;
65128
65128
  }
65129
65129
  };
65130
- const summaryVersion = "1.12.0-next.13";
65130
+ const summaryVersion = "1.12.0-next.14";
65131
65131
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
65132
65132
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
65133
65133
  function mapAttributes(attrs) {
@@ -67932,7 +67932,7 @@ ${err.toString()}`);
67932
67932
  * Process collaboration migrations
67933
67933
  */
67934
67934
  processCollaborationMigrations() {
67935
- console.debug("[checkVersionMigrations] Current editor version", "1.12.0-next.13");
67935
+ console.debug("[checkVersionMigrations] Current editor version", "1.12.0-next.14");
67936
67936
  if (!this.options.ydoc) return;
67937
67937
  const metaMap = this.options.ydoc.getMap("meta");
67938
67938
  let docVersion = metaMap.get("version");
@@ -73748,6 +73748,11 @@ ${o}
73748
73748
  * Class name for block-level structured content containers.
73749
73749
  */
73750
73750
  BLOCK_SDT: "superdoc-structured-content-block",
73751
+ /**
73752
+ * Class name for table fragment containers.
73753
+ * Applied to table fragments for resize overlay targeting and click mapping.
73754
+ */
73755
+ TABLE_FRAGMENT: "superdoc-table-fragment",
73751
73756
  /**
73752
73757
  * Class name added to block SDT fragments on hover via event delegation.
73753
73758
  * Applied/removed by SdtGroupedHover to highlight all fragments of the same SDT.
@@ -75444,16 +75449,31 @@ ${o}
75444
75449
  container.style.height = `${fragment.height}px`;
75445
75450
  applySdtDataset(container, block.attrs?.sdt);
75446
75451
  applySdtContainerStyling(doc2, container, block.attrs?.sdt, block.attrs?.containerSdt, sdtBoundary);
75447
- container.classList.add("superdoc-table-fragment");
75452
+ container.classList.add(DOM_CLASS_NAMES.TABLE_FRAGMENT);
75448
75453
  if (fragment.metadata?.columnBoundaries) {
75449
75454
  const columnCount = measure.columnWidths.length;
75450
- const rowCount = block.rows.length;
75451
75455
  const boundarySegments = [];
75452
75456
  for (let i2 = 0; i2 < columnCount; i2++) {
75453
75457
  boundarySegments.push([]);
75454
75458
  }
75459
+ const renderedRows = [];
75460
+ if (fragment.repeatHeaderCount && fragment.repeatHeaderCount > 0) {
75461
+ for (let r2 = 0; r2 < fragment.repeatHeaderCount; r2++) {
75462
+ const rowMeasure = measure.rows[r2];
75463
+ if (!rowMeasure) break;
75464
+ renderedRows.push({ rowIndex: r2, height: rowMeasure.height });
75465
+ }
75466
+ }
75467
+ for (let r2 = fragment.fromRow; r2 < fragment.toRow; r2++) {
75468
+ const rowMeasure = measure.rows[r2];
75469
+ if (!rowMeasure) break;
75470
+ const isPartialRow = fragment.partialRow && fragment.partialRow.rowIndex === r2;
75471
+ const actualHeight = isPartialRow ? fragment.partialRow.partialHeight : rowMeasure.height;
75472
+ renderedRows.push({ rowIndex: r2, height: actualHeight });
75473
+ }
75455
75474
  let rowY = 0;
75456
- for (let rowIndex = 0; rowIndex < rowCount; rowIndex++) {
75475
+ for (let i2 = 0; i2 < renderedRows.length; i2++) {
75476
+ const { rowIndex, height } = renderedRows[i2];
75457
75477
  const rowMeasure = measure.rows[rowIndex];
75458
75478
  if (!rowMeasure) continue;
75459
75479
  const boundariesInRow = /* @__PURE__ */ new Set();
@@ -75471,19 +75491,19 @@ ${o}
75471
75491
  for (const boundaryCol of boundariesInRow) {
75472
75492
  const segments = boundarySegments[boundaryCol];
75473
75493
  const lastSegment = segments[segments.length - 1];
75474
- if (lastSegment && lastSegment.toRow === rowIndex) {
75475
- lastSegment.toRow = rowIndex + 1;
75476
- lastSegment.height += rowMeasure.height;
75494
+ if (lastSegment && i2 > 0 && lastSegment.toRow === i2) {
75495
+ lastSegment.toRow = i2 + 1;
75496
+ lastSegment.height += height;
75477
75497
  } else {
75478
75498
  segments.push({
75479
- fromRow: rowIndex,
75480
- toRow: rowIndex + 1,
75499
+ fromRow: i2,
75500
+ toRow: i2 + 1,
75481
75501
  y: rowY,
75482
- height: rowMeasure.height
75502
+ height
75483
75503
  });
75484
75504
  }
75485
75505
  }
75486
- rowY += rowMeasure.height;
75506
+ rowY += height;
75487
75507
  }
75488
75508
  const metadata = {
75489
75509
  columns: fragment.metadata.columnBoundaries.map((boundary) => ({
@@ -92643,7 +92663,8 @@ ${o}
92643
92663
  const CLASS_NAMES = {
92644
92664
  page: DOM_CLASS_NAMES.PAGE,
92645
92665
  fragment: DOM_CLASS_NAMES.FRAGMENT,
92646
- line: DOM_CLASS_NAMES.LINE
92666
+ line: DOM_CLASS_NAMES.LINE,
92667
+ tableFragment: DOM_CLASS_NAMES.TABLE_FRAGMENT
92647
92668
  };
92648
92669
  function clickToPositionDom(domContainer, clientX, clientY) {
92649
92670
  const pageEl = findPageElement(domContainer, clientX, clientY);
@@ -92740,6 +92761,9 @@ ${o}
92740
92761
  const result2 = processLineElement(hitChainLine, viewX);
92741
92762
  return result2;
92742
92763
  }
92764
+ if (fragmentEl.classList.contains(CLASS_NAMES.tableFragment)) {
92765
+ return null;
92766
+ }
92743
92767
  const result = processFragment(fragmentEl, viewX, viewY);
92744
92768
  return result;
92745
92769
  }
@@ -100639,6 +100663,53 @@ ${o}
100639
100663
  const isAtomicFragment = (fragment) => {
100640
100664
  return fragment.kind === "drawing" || fragment.kind === "image";
100641
100665
  };
100666
+ function snapToNearestFragment(pageHit, blocks2, measures, pageRelativePoint) {
100667
+ const fragments = pageHit.page.fragments.filter(
100668
+ (f) => f != null && typeof f === "object"
100669
+ );
100670
+ let nearestHit = null;
100671
+ let nearestDist = Infinity;
100672
+ for (const frag of fragments) {
100673
+ const isPara = frag.kind === "para";
100674
+ const isAtomic = isAtomicFragment(frag);
100675
+ if (!isPara && !isAtomic) continue;
100676
+ const blockIndex = findBlockIndexByFragmentId(blocks2, frag.blockId);
100677
+ if (blockIndex === -1) continue;
100678
+ const block = blocks2[blockIndex];
100679
+ const measure = measures[blockIndex];
100680
+ if (!block || !measure) continue;
100681
+ let fragHeight = 0;
100682
+ if (isAtomic) {
100683
+ fragHeight = frag.height;
100684
+ } else if (isPara && block.kind === "paragraph" && measure.kind === "paragraph") {
100685
+ fragHeight = measure.lines.slice(frag.fromLine, frag.toLine).reduce((sum, line) => sum + line.lineHeight, 0);
100686
+ } else {
100687
+ continue;
100688
+ }
100689
+ const top2 = frag.y;
100690
+ const bottom2 = frag.y + fragHeight;
100691
+ let dist;
100692
+ if (pageRelativePoint.y < top2) {
100693
+ dist = top2 - pageRelativePoint.y;
100694
+ } else if (pageRelativePoint.y > bottom2) {
100695
+ dist = pageRelativePoint.y - bottom2;
100696
+ } else {
100697
+ dist = 0;
100698
+ }
100699
+ if (dist < nearestDist) {
100700
+ nearestDist = dist;
100701
+ const pageY = Math.max(0, Math.min(pageRelativePoint.y - top2, fragHeight));
100702
+ nearestHit = {
100703
+ fragment: frag,
100704
+ block,
100705
+ measure,
100706
+ pageIndex: pageHit.pageIndex,
100707
+ pageY
100708
+ };
100709
+ }
100710
+ }
100711
+ return nearestHit;
100712
+ }
100642
100713
  const logClickStage = (_level, _stage, _payload) => {
100643
100714
  };
100644
100715
  const logPositionDebug = (payload) => {
@@ -100943,66 +101014,46 @@ ${o}
100943
101014
  return { pos: domPos, layoutEpoch: domLayoutEpoch, blockId: "", pageIndex: 0, column: 0, lineIndex: -1 };
100944
101015
  }
100945
101016
  }
100946
- const pageHit = hitTestPage(layout, containerPoint, geometryHelper);
101017
+ let pageHit = null;
101018
+ let isContainerPointPageRelative = false;
101019
+ if (domContainer != null && clientX != null && clientY != null) {
101020
+ const pageEl = findPageElement(domContainer, clientX, clientY);
101021
+ if (pageEl) {
101022
+ const domPageIndex = Number(pageEl.dataset.pageIndex ?? "NaN");
101023
+ if (Number.isFinite(domPageIndex) && domPageIndex >= 0 && domPageIndex < layout.pages.length) {
101024
+ pageHit = { pageIndex: domPageIndex, page: layout.pages[domPageIndex] };
101025
+ isContainerPointPageRelative = true;
101026
+ }
101027
+ }
101028
+ }
101029
+ if (!pageHit) {
101030
+ pageHit = hitTestPage(layout, containerPoint, geometryHelper);
101031
+ }
100947
101032
  if (!pageHit) {
100948
101033
  return null;
100949
101034
  }
100950
- const pageTopY = geometryHelper ? geometryHelper.getPageTop(pageHit.pageIndex) : calculatePageTopFallback(layout, pageHit.pageIndex);
100951
- const pageRelativePoint = {
100952
- x: containerPoint.x,
100953
- y: containerPoint.y - pageTopY
100954
- };
101035
+ let pageRelativePoint;
101036
+ if (isContainerPointPageRelative) {
101037
+ pageRelativePoint = containerPoint;
101038
+ } else {
101039
+ const pageTopY = geometryHelper ? geometryHelper.getPageTop(pageHit.pageIndex) : calculatePageTopFallback(layout, pageHit.pageIndex);
101040
+ pageRelativePoint = {
101041
+ x: containerPoint.x,
101042
+ y: containerPoint.y - pageTopY
101043
+ };
101044
+ }
100955
101045
  logClickStage("log", "page-hit", {
100956
101046
  pageIndex: pageHit.pageIndex
100957
101047
  });
100958
101048
  let fragmentHit = hitTestFragment(layout, pageHit, blocks2, measures, pageRelativePoint);
100959
101049
  if (!fragmentHit) {
100960
- const page = pageHit.page;
100961
- const fragments = page.fragments.filter(
100962
- (f) => f != null && typeof f === "object"
100963
- );
100964
- let nearestHit = null;
100965
- let nearestDist = Infinity;
100966
- for (const frag of fragments) {
100967
- const isPara = frag.kind === "para";
100968
- const isAtomic = isAtomicFragment(frag);
100969
- if (!isPara && !isAtomic) continue;
100970
- const blockIndex = findBlockIndexByFragmentId(blocks2, frag.blockId);
100971
- if (blockIndex === -1) continue;
100972
- const block = blocks2[blockIndex];
100973
- const measure = measures[blockIndex];
100974
- if (!block || !measure) continue;
100975
- let fragHeight = 0;
100976
- if (isAtomic) {
100977
- fragHeight = frag.height;
100978
- } else if (isPara && block.kind === "paragraph" && measure.kind === "paragraph") {
100979
- fragHeight = measure.lines.slice(frag.fromLine, frag.toLine).reduce((sum, line) => sum + line.lineHeight, 0);
100980
- } else {
100981
- continue;
100982
- }
100983
- const top2 = frag.y;
100984
- const bottom2 = frag.y + fragHeight;
100985
- let dist;
100986
- if (pageRelativePoint.y < top2) {
100987
- dist = top2 - pageRelativePoint.y;
100988
- } else if (pageRelativePoint.y > bottom2) {
100989
- dist = pageRelativePoint.y - bottom2;
100990
- } else {
100991
- dist = 0;
100992
- }
100993
- if (dist < nearestDist) {
100994
- nearestDist = dist;
100995
- const pageY = Math.max(0, Math.min(pageRelativePoint.y - top2, fragHeight));
100996
- nearestHit = {
100997
- fragment: frag,
100998
- block,
100999
- measure,
101000
- pageIndex: pageHit.pageIndex,
101001
- pageY
101002
- };
101003
- }
101050
+ const isWithinTableFragment = pageHit.page.fragments.filter((f) => f.kind === "table").some((f) => {
101051
+ const tf = f;
101052
+ return pageRelativePoint.x >= tf.x && pageRelativePoint.x <= tf.x + tf.width && pageRelativePoint.y >= tf.y && pageRelativePoint.y <= tf.y + tf.height;
101053
+ });
101054
+ if (!isWithinTableFragment) {
101055
+ fragmentHit = snapToNearestFragment(pageHit, blocks2, measures, pageRelativePoint);
101004
101056
  }
101005
- fragmentHit = nearestHit;
101006
101057
  }
101007
101058
  if (fragmentHit) {
101008
101059
  const { fragment, block, measure, pageIndex, pageY } = fragmentHit;
@@ -101042,7 +101093,8 @@ ${o}
101042
101093
  const column = determineColumn(layout, fragment.x);
101043
101094
  logPositionDebug({
101044
101095
  blockId: fragment.blockId,
101045
- x: pageRelativePoint.x - fragment.x
101096
+ x: pageRelativePoint.x - fragment.x,
101097
+ y: pageRelativePoint.y
101046
101098
  });
101047
101099
  logClickStage("log", "success", {
101048
101100
  blockId: fragment.blockId
@@ -171825,7 +171877,7 @@ js: import "konva/skia-backend";
171825
171877
  this.config.colors = shuffleArray(this.config.colors);
171826
171878
  this.userColorMap = /* @__PURE__ */ new Map();
171827
171879
  this.colorIndex = 0;
171828
- this.version = "1.12.0-next.13";
171880
+ this.version = "1.12.0-next.14";
171829
171881
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
171830
171882
  this.superdocId = config2.superdocId || v4();
171831
171883
  this.colors = this.config.colors;