@superdoc-dev/cli 0.17.0-next.24 → 0.17.0-next.26

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 +347 -92
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -68327,7 +68327,7 @@ var init_remark_gfm_BhnWr3yf_es = __esm(() => {
68327
68327
  emptyOptions2 = {};
68328
68328
  });
68329
68329
 
68330
- // ../../packages/superdoc/dist/chunks/SuperConverter-CCgGAnXY.es.js
68330
+ // ../../packages/superdoc/dist/chunks/SuperConverter-WQVqM0th.es.js
68331
68331
  function getExtensionConfigField(extension$1, field, context = { name: "" }) {
68332
68332
  const fieldValue = extension$1.config[field];
68333
68333
  if (typeof fieldValue === "function")
@@ -88534,6 +88534,22 @@ function fixTable(state, table, tablePos, tr) {
88534
88534
  }
88535
88535
  return tr.setMeta(fixTablesKey, { fixTables: true });
88536
88536
  }
88537
+ function findTable($pos) {
88538
+ return findParentNode$1((node3) => node3.type.spec.tableRole === "table", $pos);
88539
+ }
88540
+ function findParentNode$1(predicate, $pos) {
88541
+ for (let depth = $pos.depth;depth >= 0; depth -= 1) {
88542
+ const node3 = $pos.node(depth);
88543
+ if (predicate(node3))
88544
+ return {
88545
+ node: node3,
88546
+ pos: depth === 0 ? 0 : $pos.before(depth),
88547
+ start: $pos.start(depth),
88548
+ depth
88549
+ };
88550
+ }
88551
+ return null;
88552
+ }
88537
88553
  function selectedRect(state) {
88538
88554
  const sel = state.selection;
88539
88555
  const $pos = selectionCell(state);
@@ -134913,7 +134929,7 @@ var isRegExp = (value) => {
134913
134929
  state.kern = kernNode.attributes["w:val"];
134914
134930
  }
134915
134931
  }, SuperConverter;
134916
- var init_SuperConverter_CCgGAnXY_es = __esm(() => {
134932
+ var init_SuperConverter_WQVqM0th_es = __esm(() => {
134917
134933
  init_rolldown_runtime_Bg48TavK_es();
134918
134934
  init_jszip_C49i9kUs_es();
134919
134935
  init_xml_js_CqGKpaft_es();
@@ -175657,7 +175673,7 @@ var init_SuperConverter_CCgGAnXY_es = __esm(() => {
175657
175673
  };
175658
175674
  });
175659
175675
 
175660
- // ../../packages/superdoc/dist/chunks/create-headless-toolbar-BvrKiWf0.es.js
175676
+ // ../../packages/superdoc/dist/chunks/create-headless-toolbar-B8OXKxcw.es.js
175661
175677
  function parseSizeUnit(val = "0") {
175662
175678
  const length3 = val.toString() || "0";
175663
175679
  const value = Number.parseFloat(length3);
@@ -186052,8 +186068,8 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, normalizeActorId = (value) => {
186052
186068
  }
186053
186069
  };
186054
186070
  };
186055
- var init_create_headless_toolbar_BvrKiWf0_es = __esm(() => {
186056
- init_SuperConverter_CCgGAnXY_es();
186071
+ var init_create_headless_toolbar_B8OXKxcw_es = __esm(() => {
186072
+ init_SuperConverter_WQVqM0th_es();
186057
186073
  init_uuid_B2wVPhPi_es();
186058
186074
  init_constants_D9qj59G2_es();
186059
186075
  init_dist_B8HfvhaK_es();
@@ -235222,7 +235238,7 @@ var init_remark_gfm_eZN6yzWQ_es = __esm(() => {
235222
235238
  init_remark_gfm_BhnWr3yf_es();
235223
235239
  });
235224
235240
 
235225
- // ../../packages/superdoc/dist/chunks/src-CXtSesLH.es.js
235241
+ // ../../packages/superdoc/dist/chunks/src-Bvhjxf8i.es.js
235226
235242
  function deleteProps(obj, propOrProps) {
235227
235243
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
235228
235244
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -286308,10 +286324,10 @@ function clickToPositionGeometry(layout, blocks2, measures, containerPoint, opti
286308
286324
  lineIndex
286309
286325
  };
286310
286326
  }
286311
- const firstRun = cellBlock.runs?.[0];
286312
- if (firstRun && firstRun.pmStart != null)
286327
+ const fallbackPos = cellBlock.runs?.[0]?.pmStart ?? blockPmRangeFromAttrs(cellBlock).pmStart;
286328
+ if (fallbackPos != null)
286313
286329
  return {
286314
- pos: firstRun.pmStart,
286330
+ pos: fallbackPos,
286315
286331
  layoutEpoch,
286316
286332
  blockId: tableHit.fragment.blockId,
286317
286333
  pageIndex,
@@ -286372,6 +286388,16 @@ function percentile(sortedValues, p$12) {
286372
286388
  const weight = index2 - lower;
286373
286389
  return sortedValues[lower] * (1 - weight) + sortedValues[upper] * weight;
286374
286390
  }
286391
+ function pushEmptyLineSelectionBand(rects, opts) {
286392
+ const lineOffset = sumLineHeights(opts.measure, opts.startLineIndex, opts.lineIndex);
286393
+ rects.push({
286394
+ x: opts.x,
286395
+ y: opts.yBase + lineOffset,
286396
+ width: Math.max(1, opts.width),
286397
+ height: opts.lineHeight,
286398
+ pageIndex: opts.pageIndex
286399
+ });
286400
+ }
286375
286401
  function selectionToRects(layout, blocks2, measures, from$1, to, geometryHelper) {
286376
286402
  if (from$1 === to)
286377
286403
  return [];
@@ -286398,8 +286424,19 @@ function selectionToRects(layout, blocks2, measures, from$1, to, geometryHelper)
286398
286424
  return;
286399
286425
  const sliceFrom = Math.max(range.pmStart, from$1);
286400
286426
  const sliceTo = Math.min(range.pmEnd, to);
286401
- if (sliceFrom >= sliceTo)
286427
+ if (sliceFrom >= sliceTo) {
286428
+ pushEmptyLineSelectionBand(rects, {
286429
+ x: fragment2.x,
286430
+ yBase: fragment2.y + pageTopY,
286431
+ width: fragment2.width,
286432
+ lineHeight: line.lineHeight,
286433
+ pageIndex,
286434
+ measure,
286435
+ lineIndex: index2,
286436
+ startLineIndex: fragment2.fromLine
286437
+ });
286402
286438
  return;
286439
+ }
286403
286440
  pmPosToCharOffset(block, line, sliceFrom);
286404
286441
  pmPosToCharOffset(block, line, sliceTo);
286405
286442
  const visualCharOffsetFrom = pmPosToVisualCharOffset(block, line, sliceFrom);
@@ -286577,8 +286614,19 @@ function selectionToRects(layout, blocks2, measures, from$1, to, geometryHelper)
286577
286614
  return;
286578
286615
  const sliceFrom = Math.max(range.pmStart, from$1);
286579
286616
  const sliceTo = Math.min(range.pmEnd, to);
286580
- if (sliceFrom >= sliceTo)
286617
+ if (sliceFrom >= sliceTo) {
286618
+ pushEmptyLineSelectionBand(rects, {
286619
+ x: fragment2.x + contentOffsetX + cellX + padding.left,
286620
+ yBase: fragment2.y + contentOffsetY + rowOffset + blockTopCursor + effectiveSpacingBeforePx + pageTopY,
286621
+ width: cellMeasure.width - padding.left - padding.right,
286622
+ lineHeight: line.lineHeight,
286623
+ pageIndex,
286624
+ measure: info.measure,
286625
+ lineIndex: index2,
286626
+ startLineIndex: info.startLine
286627
+ });
286581
286628
  return;
286629
+ }
286582
286630
  pmPosToCharOffset(info.block, line, sliceFrom);
286583
286631
  pmPosToCharOffset(info.block, line, sliceTo);
286584
286632
  const visualCharOffsetFrom = pmPosToVisualCharOffset(info.block, line, sliceFrom);
@@ -286907,6 +286955,49 @@ function calculateExtendedSelection(blocks2, anchor, head, mode) {
286907
286955
  selHead: head
286908
286956
  };
286909
286957
  }
286958
+ function selectionCollapsesAcrossTableCells(doc$12, anchor, head) {
286959
+ if (anchor === head)
286960
+ return false;
286961
+ try {
286962
+ const size$1 = doc$12.content.size;
286963
+ if (anchor < 0 || head < 0 || anchor > size$1 || head > size$1)
286964
+ return false;
286965
+ const $from = doc$12.resolve(Math.min(anchor, head));
286966
+ const $to = doc$12.resolve(Math.max(anchor, head));
286967
+ return cellWrapping2($from) !== cellWrapping2($to) && $to.parentOffset === 0;
286968
+ } catch {
286969
+ return false;
286970
+ }
286971
+ }
286972
+ function stabilizeTextSelectionAcrossTableCells(doc$12, anchor, head) {
286973
+ if (!selectionCollapsesAcrossTableCells(doc$12, anchor, head))
286974
+ return {
286975
+ selAnchor: anchor,
286976
+ selHead: head
286977
+ };
286978
+ try {
286979
+ const anchorIsUpper = anchor > head;
286980
+ const upperPos = anchorIsUpper ? anchor : head;
286981
+ if (upperPos < 0 || upperPos >= doc$12.content.size)
286982
+ return null;
286983
+ const $upper = doc$12.resolve(upperPos);
286984
+ if (!$upper.parent.inlineContent || $upper.parent.content.size !== 0)
286985
+ return null;
286986
+ const stabilizedUpperPos = upperPos + 1;
286987
+ if (stabilizedUpperPos > doc$12.content.size)
286988
+ return null;
286989
+ const selAnchor = anchorIsUpper ? stabilizedUpperPos : anchor;
286990
+ const selHead = anchorIsUpper ? head : stabilizedUpperPos;
286991
+ if (selectionCollapsesAcrossTableCells(doc$12, selAnchor, selHead))
286992
+ return null;
286993
+ return {
286994
+ selAnchor,
286995
+ selHead
286996
+ };
286997
+ } catch {
286998
+ return null;
286999
+ }
287000
+ }
286910
287001
  function registerPointerClick(event, previous3, options) {
286911
287002
  const time = event.timeStamp ?? performance.now();
286912
287003
  const withinTime = time - previous3.lastClickTime <= options.timeThresholdMs;
@@ -287322,14 +287413,16 @@ function computeSelectionRectsFromDom(options, from$1, to) {
287322
287413
  missingEntries.push(entry);
287323
287414
  }
287324
287415
  } catch {}
287325
- if (missingEntries && missingEntries.length > 0) {
287416
+ const spansMultipleLines = countDistinctLines(pageEntries) > 1;
287417
+ if (spansMultipleLines || missingEntries && missingEntries.length > 0) {
287326
287418
  if (isVerbose)
287327
- debugLog("verbose", `DOM selection rects: range missing entries ${JSON.stringify({
287419
+ debugLog("verbose", `DOM selection rects: switching to per-line rects ${JSON.stringify({
287328
287420
  pageIndex,
287329
287421
  sliceFrom,
287330
287422
  sliceTo,
287331
- missingCount: missingEntries.length,
287332
- missingPreview: missingEntries.slice(0, 20).map(entryDebugInfo)
287423
+ spansMultipleLines,
287424
+ missingCount: missingEntries?.length ?? 0,
287425
+ missingPreview: (missingEntries ?? []).slice(0, 20).map(entryDebugInfo)
287333
287426
  })}`);
287334
287427
  rawRects = collectClientRectsByLine(doc$12, pageEntries, sliceFrom, sliceTo);
287335
287428
  if (dumpRects)
@@ -287399,10 +287492,17 @@ function collectClientRectsByLine(doc$12, entries2, sliceFrom, sliceTo) {
287399
287492
  else
287400
287493
  lineMap.set(lineEl, [entry]);
287401
287494
  }
287402
- for (const [, lineEntries] of lineMap) {
287495
+ for (const [lineEl, lineEntries] of lineMap) {
287403
287496
  lineEntries.sort((a2, b$1) => a2.pmStart - b$1.pmStart !== 0 ? a2.pmStart - b$1.pmStart : a2.pmEnd - b$1.pmEnd);
287404
287497
  const linePmStart = lineEntries[0]?.pmStart ?? Infinity;
287405
287498
  const linePmEnd = lineEntries[lineEntries.length - 1]?.pmEnd ?? -Infinity;
287499
+ if (sliceFrom < linePmStart && linePmEnd < sliceTo && lineEl.isConnected) {
287500
+ const boxRect = lineEl.getBoundingClientRect();
287501
+ if (boxRect.width > 0 && boxRect.height > 0) {
287502
+ rects.push(boxRect);
287503
+ continue;
287504
+ }
287505
+ }
287406
287506
  if (!Number.isFinite(linePmStart) || !Number.isFinite(linePmEnd) || linePmEnd <= linePmStart)
287407
287507
  continue;
287408
287508
  const lineFrom = Math.max(sliceFrom, linePmStart);
@@ -287440,6 +287540,18 @@ function collectClientRectsByLine(doc$12, entries2, sliceFrom, sliceTo) {
287440
287540
  }
287441
287541
  return rects;
287442
287542
  }
287543
+ function countDistinctLines(entries2) {
287544
+ const lines = /* @__PURE__ */ new Set;
287545
+ let hasLoose = false;
287546
+ for (const entry of entries2) {
287547
+ const lineEl = entry.el.closest(".superdoc-line");
287548
+ if (lineEl)
287549
+ lines.add(lineEl);
287550
+ else
287551
+ hasLoose = true;
287552
+ }
287553
+ return lines.size + (hasLoose ? 1 : 0);
287554
+ }
287443
287555
  function setDomRangeStart(range, entry, pos) {
287444
287556
  const el = entry.el;
287445
287557
  const pmStart = entry.pmStart;
@@ -288775,6 +288887,107 @@ function resolvePointerPositionHit(options) {
288775
288887
  }
288776
288888
  return clickToPositionGeometry(layout, blocks2, measures, containerPoint, { geometryHelper });
288777
288889
  }
288890
+ function getTableBlocks(blocks2) {
288891
+ return blocks2.filter((block) => block.kind === "table");
288892
+ }
288893
+ function getTopLevelTablePosByIndex(doc$12, targetTableIndex) {
288894
+ if (!Number.isInteger(targetTableIndex) || targetTableIndex < 0)
288895
+ return null;
288896
+ let tablePos = null;
288897
+ let currentTableIndex = 0;
288898
+ doc$12.descendants((node3, pos) => {
288899
+ if (tablePos !== null)
288900
+ return false;
288901
+ if (node3.type.name !== "table")
288902
+ return true;
288903
+ if (currentTableIndex === targetTableIndex)
288904
+ tablePos = pos;
288905
+ currentTableIndex += 1;
288906
+ return false;
288907
+ });
288908
+ return tablePos;
288909
+ }
288910
+ function getTopLevelTableIndexAtPos(doc$12, targetTablePos) {
288911
+ if (!Number.isFinite(targetTablePos) || targetTablePos < 0 || targetTablePos > doc$12.content.size)
288912
+ return null;
288913
+ let tableIndex = null;
288914
+ let currentTableIndex = 0;
288915
+ doc$12.descendants((node3, pos) => {
288916
+ if (tableIndex !== null)
288917
+ return false;
288918
+ if (node3.type.name !== "table")
288919
+ return true;
288920
+ if (pos === targetTablePos)
288921
+ tableIndex = currentTableIndex;
288922
+ currentTableIndex += 1;
288923
+ return false;
288924
+ });
288925
+ return tableIndex;
288926
+ }
288927
+ function getCellCoordinatesFromCellPos(doc$12, tablePos, cellPos) {
288928
+ const tableNode = doc$12.nodeAt(tablePos);
288929
+ if (!tableNode || tableNode.type.name !== "table")
288930
+ return null;
288931
+ let rowPos = tablePos + 1;
288932
+ for (let rowIndex = 0;rowIndex < tableNode.childCount; rowIndex += 1) {
288933
+ const rowNode = tableNode.child(rowIndex);
288934
+ let currentCellPos = rowPos + 1;
288935
+ for (let cellColIndex = 0;cellColIndex < rowNode.childCount; cellColIndex += 1) {
288936
+ if (currentCellPos === cellPos)
288937
+ return {
288938
+ rowIndex,
288939
+ cellColIndex
288940
+ };
288941
+ currentCellPos += rowNode.child(cellColIndex).nodeSize;
288942
+ }
288943
+ rowPos += rowNode.nodeSize;
288944
+ }
288945
+ return null;
288946
+ }
288947
+ function getTopLevelTableBlockAtPos(doc$12, blocks2, tablePos) {
288948
+ if (!doc$12)
288949
+ return null;
288950
+ const tableIndex = getTopLevelTableIndexAtPos(doc$12, tablePos);
288951
+ if (tableIndex === null)
288952
+ return null;
288953
+ return getTableBlocks(blocks2)[tableIndex] ?? null;
288954
+ }
288955
+ function resolveCellContextAtResolvedPos($pos) {
288956
+ const $cell = cellAround($pos);
288957
+ if (!$cell)
288958
+ return null;
288959
+ const table2 = findTable($cell);
288960
+ if (!table2)
288961
+ return null;
288962
+ return {
288963
+ $cell,
288964
+ cellPos: $cell.pos,
288965
+ tablePos: table2.pos
288966
+ };
288967
+ }
288968
+ function resolveCellAnchorStateFromCellPos(doc$12, blocks2, cellPos) {
288969
+ if (!doc$12 || !Number.isFinite(cellPos) || cellPos < 0 || cellPos > doc$12.content.size)
288970
+ return null;
288971
+ const tableRole = doc$12.nodeAt(cellPos)?.type.spec.tableRole;
288972
+ if (tableRole !== "cell" && tableRole !== "header_cell")
288973
+ return null;
288974
+ const context = resolveCellContext(doc$12, Math.min(cellPos + 1, doc$12.content.size));
288975
+ if (!context || context.cellPos !== cellPos)
288976
+ return null;
288977
+ const tableBlock = getTopLevelTableBlockAtPos(doc$12, blocks2, context.tablePos);
288978
+ if (!tableBlock)
288979
+ return null;
288980
+ const cellCoordinates = getCellCoordinatesFromCellPos(doc$12, context.tablePos, cellPos);
288981
+ if (!cellCoordinates)
288982
+ return null;
288983
+ return {
288984
+ tablePos: context.tablePos,
288985
+ cellPos,
288986
+ tableBlockId: tableBlock.id,
288987
+ cellRowIndex: cellCoordinates.rowIndex,
288988
+ cellColIndex: cellCoordinates.cellColIndex
288989
+ };
288990
+ }
288778
288991
  function getCellPosFromTableHit(tableHit, doc$12, blocks2) {
288779
288992
  if (!tableHit || !tableHit.block || typeof tableHit.block.id !== "string") {
288780
288993
  console.warn("[getCellPosFromTableHit] Invalid tableHit input:", tableHit);
@@ -288789,22 +289002,12 @@ function getCellPosFromTableHit(tableHit, doc$12, blocks2) {
288789
289002
  }
288790
289003
  if (!doc$12)
288791
289004
  return null;
288792
- const targetTableIndex = blocks2.filter((b$1) => b$1.kind === "table").findIndex((b$1) => b$1.id === tableHit.block.id);
289005
+ const targetTableIndex = getTableBlocks(blocks2).findIndex((b$1) => b$1.id === tableHit.block.id);
288793
289006
  if (targetTableIndex === -1)
288794
289007
  return null;
288795
289008
  let tablePos = null;
288796
- let currentTableIndex = 0;
288797
289009
  try {
288798
- doc$12.descendants((node3, pos) => {
288799
- if (node3.type.name === "table") {
288800
- if (currentTableIndex === targetTableIndex) {
288801
- tablePos = pos;
288802
- return false;
288803
- }
288804
- currentTableIndex++;
288805
- }
288806
- return true;
288807
- });
289010
+ tablePos = getTopLevelTablePosByIndex(doc$12, targetTableIndex);
288808
289011
  } catch (error3) {
288809
289012
  console.error("[getCellPosFromTableHit] Error during document traversal:", error3);
288810
289013
  return null;
@@ -288852,22 +289055,51 @@ function getCellPosFromTableHit(tableHit, doc$12, blocks2) {
288852
289055
  function getTablePosFromHit(tableHit, doc$12, blocks2) {
288853
289056
  if (!doc$12)
288854
289057
  return null;
288855
- const targetTableIndex = blocks2.filter((b$1) => b$1.kind === "table").findIndex((b$1) => b$1.id === tableHit.block.id);
289058
+ const targetTableIndex = getTableBlocks(blocks2).findIndex((b$1) => b$1.id === tableHit.block.id);
288856
289059
  if (targetTableIndex === -1)
288857
289060
  return null;
288858
- let tablePos = null;
288859
- let currentTableIndex = 0;
288860
- doc$12.descendants((node3, pos) => {
288861
- if (node3.type.name === "table") {
288862
- if (currentTableIndex === targetTableIndex) {
288863
- tablePos = pos;
288864
- return false;
288865
- }
288866
- currentTableIndex++;
288867
- }
288868
- return true;
288869
- });
288870
- return tablePos;
289061
+ return getTopLevelTablePosByIndex(doc$12, targetTableIndex);
289062
+ }
289063
+ function resolveCellContext(doc$12, pos) {
289064
+ if (!doc$12 || !Number.isFinite(pos) || pos < 0 || pos > doc$12.content.size)
289065
+ return null;
289066
+ let $pos;
289067
+ try {
289068
+ $pos = doc$12.resolve(pos);
289069
+ } catch {
289070
+ return null;
289071
+ }
289072
+ const context = resolveCellContextAtResolvedPos($pos);
289073
+ if (!context)
289074
+ return null;
289075
+ return {
289076
+ cellPos: context.cellPos,
289077
+ tablePos: context.tablePos
289078
+ };
289079
+ }
289080
+ function resolveCrossCellSelection(doc$12, anchorPos, headPos) {
289081
+ if (!doc$12)
289082
+ return null;
289083
+ let $anchorPos;
289084
+ let $headPos;
289085
+ try {
289086
+ $anchorPos = doc$12.resolve(anchorPos);
289087
+ $headPos = doc$12.resolve(headPos);
289088
+ } catch {
289089
+ return null;
289090
+ }
289091
+ const anchor = resolveCellContextAtResolvedPos($anchorPos);
289092
+ const head = resolveCellContextAtResolvedPos($headPos);
289093
+ if (!anchor || !head)
289094
+ return null;
289095
+ if (!inSameTable(anchor.$cell, head.$cell))
289096
+ return null;
289097
+ if (anchor.cellPos === head.cellPos)
289098
+ return null;
289099
+ return {
289100
+ anchorCellPos: anchor.cellPos,
289101
+ headCellPos: head.cellPos
289102
+ };
288871
289103
  }
288872
289104
  function shouldUseCellSelection(currentTableHit, cellAnchor, cellDragMode) {
288873
289105
  if (!cellAnchor)
@@ -289330,15 +289562,8 @@ function renderCellSelectionOverlay({ selection, layout, localSelectionLayer, bl
289330
289562
  let tableBlock;
289331
289563
  if (cellAnchorTableBlockId)
289332
289564
  tableBlock = blocks2.find((block) => block.kind === "table" && block.id === cellAnchorTableBlockId);
289333
- if (!tableBlock) {
289334
- const expectedBlockId = `${tableStart}-table`;
289335
- tableBlock = blocks2.find((block) => block.kind === "table" && block.id === expectedBlockId);
289336
- }
289337
- if (!tableBlock) {
289338
- const tableBlocks = blocks2.filter((block) => block.kind === "table");
289339
- if (tableBlocks.length === 1)
289340
- tableBlock = tableBlocks[0];
289341
- }
289565
+ if (!tableBlock)
289566
+ tableBlock = getTopLevelTableBlockAtPos($anchorCell.node(0), blocks2, tableStart) ?? undefined;
289342
289567
  if (!tableBlock)
289343
289568
  return;
289344
289569
  const tableFragments = [];
@@ -328144,18 +328369,45 @@ menclose::after {
328144
328369
  const layoutState = this.#deps?.getLayoutState();
328145
328370
  return getTablePosFromHit(tableHit, editor?.state?.doc ?? null, layoutState?.blocks ?? []);
328146
328371
  }
328372
+ #setCellAnchorState(cellAnchor, mode = "pending") {
328373
+ this.#cellAnchor = cellAnchor;
328374
+ this.#cellDragMode = mode;
328375
+ }
328147
328376
  #setCellAnchor(tableHit, tablePos) {
328148
328377
  const cellPos = this.#getCellPosFromTableHit(tableHit);
328149
328378
  if (cellPos === null)
328150
328379
  return;
328151
- this.#cellAnchor = {
328380
+ this.#setCellAnchorState({
328152
328381
  tablePos,
328153
328382
  cellPos,
328154
328383
  cellRowIndex: tableHit.cellRowIndex,
328155
328384
  cellColIndex: tableHit.cellColIndex,
328156
328385
  tableBlockId: tableHit.block.id
328157
- };
328158
- this.#cellDragMode = "pending";
328386
+ }, "pending");
328387
+ }
328388
+ #setCellAnchorFromCellPos(cellPos, mode = "pending") {
328389
+ const editor = this.#deps?.getEditor();
328390
+ const layoutState = this.#deps?.getLayoutState();
328391
+ const cellAnchor = resolveCellAnchorStateFromCellPos(editor?.state?.doc ?? null, layoutState?.blocks ?? [], cellPos);
328392
+ if (!cellAnchor)
328393
+ return false;
328394
+ this.#setCellAnchorState(cellAnchor, mode);
328395
+ return true;
328396
+ }
328397
+ #dispatchExtendedTextSelection(editor, anchor, head) {
328398
+ const { selAnchor, selHead } = this.#calculateExtendedSelection(anchor, head, this.#dragExtensionMode);
328399
+ const stabilized = stabilizeTextSelectionAcrossTableCells(editor.state.doc, selAnchor, selHead);
328400
+ if (!stabilized)
328401
+ return false;
328402
+ try {
328403
+ const tr = editor.state.tr.setSelection(TextSelection.create(editor.state.doc, stabilized.selAnchor, stabilized.selHead));
328404
+ editor.view?.dispatch(tr);
328405
+ this.#callbacks.scheduleSelectionUpdate?.();
328406
+ return true;
328407
+ } catch (error3) {
328408
+ console.warn("[SELECTION] Failed to extend text selection:", error3);
328409
+ return false;
328410
+ }
328159
328411
  }
328160
328412
  #hitTestTable(x, y$1) {
328161
328413
  return this.#callbacks.hitTestTable?.(x, y$1) ?? null;
@@ -328757,6 +329009,8 @@ menclose::after {
328757
329009
  this.#pendingMarginClick = null;
328758
329010
  const dragAnchor = this.#dragAnchor;
328759
329011
  const dragMode = this.#dragExtensionMode;
329012
+ if ((!pendingMarginClick || pendingMarginClick.pointerId !== event.pointerId) && dragAnchor != null && this.#dragThresholdExceeded)
329013
+ this.#handleDragSelectionAt(event.clientX, event.clientY);
328760
329014
  const dragUsedFallback = this.#dragUsedPageNotMountedFallback;
328761
329015
  const dragPointer = this.#dragLastPointer;
328762
329016
  this.#isDragging = false;
@@ -329239,14 +329493,7 @@ menclose::after {
329239
329493
  if (!editor)
329240
329494
  return;
329241
329495
  const anchor = editor.state.selection.anchor;
329242
- const { selAnchor, selHead } = this.#calculateExtendedSelection(anchor, headPos, this.#dragExtensionMode);
329243
- try {
329244
- const tr = editor.state.tr.setSelection(TextSelection.create(editor.state.doc, selAnchor, selHead));
329245
- editor.view?.dispatch(tr);
329246
- this.#callbacks.scheduleSelectionUpdate?.();
329247
- } catch (error3) {
329248
- console.warn("[SELECTION] Failed to extend selection on shift+click:", error3);
329249
- }
329496
+ this.#dispatchExtendedTextSelection(editor, anchor, headPos);
329250
329497
  this.#focusEditor();
329251
329498
  }
329252
329499
  #handleDragSelectionAt(clientX, clientY) {
@@ -329307,17 +329554,28 @@ menclose::after {
329307
329554
  }
329308
329555
  const anchor = this.#dragAnchor;
329309
329556
  const head = hit.pos;
329310
- const { selAnchor, selHead } = this.#calculateExtendedSelection(anchor, head, this.#dragExtensionMode);
329311
- try {
329312
- const tr = editor.state.tr.setSelection(TextSelection.create(editor.state.doc, selAnchor, selHead));
329313
- editor.view?.dispatch(tr);
329314
- this.#callbacks.scheduleSelectionUpdate?.();
329315
- } catch (error3) {
329316
- console.warn("[SELECTION] Failed to extend selection during drag:", error3);
329557
+ if (!useActiveSurfaceHitTest) {
329558
+ const crossCell = resolveCrossCellSelection(editor.state.doc, anchor, head);
329559
+ if (crossCell)
329560
+ try {
329561
+ const tr = editor.state.tr.setSelection(CellSelection.create(editor.state.doc, crossCell.anchorCellPos, crossCell.headCellPos));
329562
+ editor.view?.dispatch(tr);
329563
+ if (!this.#setCellAnchorFromCellPos(crossCell.anchorCellPos, "active"))
329564
+ console.warn("[CELL-SELECTION] Failed to cache anchor state for cross-cell drag selection.");
329565
+ this.#callbacks.scheduleSelectionUpdate?.();
329566
+ return;
329567
+ } catch (error3) {
329568
+ console.warn("[SELECTION] Failed to create cross-cell CellSelection during drag:", error3);
329569
+ }
329317
329570
  }
329571
+ this.#dispatchExtendedTextSelection(editor, anchor, head);
329318
329572
  }
329319
329573
  #handleCellDragSelection(currentTableHit, hit) {
329320
- const headCellPos = currentTableHit ? this.#getCellPosFromTableHit(currentTableHit) : null;
329574
+ if (!this.#cellAnchor)
329575
+ return;
329576
+ if (!currentTableHit || currentTableHit.block.id !== this.#cellAnchor.tableBlockId)
329577
+ return;
329578
+ const headCellPos = this.#getCellPosFromTableHit(currentTableHit);
329321
329579
  if (headCellPos === null)
329322
329580
  return;
329323
329581
  if (this.#cellDragMode !== "active")
@@ -329337,13 +329595,7 @@ menclose::after {
329337
329595
  } catch (error3) {
329338
329596
  console.warn("[CELL-SELECTION] Failed to create CellSelection, falling back to TextSelection:", error3);
329339
329597
  const anchor = this.#dragAnchor;
329340
- const head = hit.pos;
329341
- const { selAnchor, selHead } = this.#calculateExtendedSelection(anchor, head, this.#dragExtensionMode);
329342
- try {
329343
- const tr = editor.state.tr.setSelection(TextSelection.create(editor.state.doc, selAnchor, selHead));
329344
- editor.view?.dispatch(tr);
329345
- this.#callbacks.scheduleSelectionUpdate?.();
329346
- } catch {}
329598
+ this.#dispatchExtendedTextSelection(editor, anchor, hit.pos);
329347
329599
  }
329348
329600
  }
329349
329601
  #handleHover(normalized) {
@@ -333228,13 +333480,13 @@ menclose::after {
333228
333480
  return;
333229
333481
  console.log(...args$1);
333230
333482
  }, 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, TRACKED_MARK_NAMES;
333231
- var init_src_CXtSesLH_es = __esm(() => {
333483
+ var init_src_Bvhjxf8i_es = __esm(() => {
333232
333484
  init_rolldown_runtime_Bg48TavK_es();
333233
- init_SuperConverter_CCgGAnXY_es();
333485
+ init_SuperConverter_WQVqM0th_es();
333234
333486
  init_jszip_C49i9kUs_es();
333235
333487
  init_xml_js_CqGKpaft_es();
333236
333488
  init_uuid_B2wVPhPi_es();
333237
- init_create_headless_toolbar_BvrKiWf0_es();
333489
+ init_create_headless_toolbar_B8OXKxcw_es();
333238
333490
  init_constants_D9qj59G2_es();
333239
333491
  init_dist_B8HfvhaK_es();
333240
333492
  init_unified_Dsuw2be5_es();
@@ -367643,14 +367895,17 @@ function print() { __p += __j.call(arguments, '') }
367643
367895
  return;
367644
367896
  }
367645
367897
  const head = Math.max(0, Math.min(mappedHead.pos, doc$12.content.size));
367646
- const { selAnchor, selHead } = this.#calculateExtendedSelection(anchor, head, mode);
367898
+ const extended = this.#calculateExtendedSelection(anchor, head, mode);
367899
+ const stabilized = stabilizeTextSelectionAcrossTableCells(doc$12, extended.selAnchor, extended.selHead);
367900
+ if (!stabilized)
367901
+ return;
367647
367902
  const current = this.#editor.state.selection;
367648
- const desiredFrom = Math.min(selAnchor, selHead);
367649
- const desiredTo = Math.max(selAnchor, selHead);
367903
+ const desiredFrom = Math.min(stabilized.selAnchor, stabilized.selHead);
367904
+ const desiredTo = Math.max(stabilized.selAnchor, stabilized.selHead);
367650
367905
  if (current.from === desiredFrom && current.to === desiredTo)
367651
367906
  return;
367652
367907
  try {
367653
- const tr = this.#editor.state.tr.setSelection(TextSelection.create(this.#editor.state.doc, selAnchor, selHead));
367908
+ const tr = this.#editor.state.tr.setSelection(TextSelection.create(this.#editor.state.doc, stabilized.selAnchor, stabilized.selHead));
367654
367909
  this.#editor.view?.dispatch(tr);
367655
367910
  this.#scheduleSelectionUpdate();
367656
367911
  } catch {}
@@ -369016,11 +369271,11 @@ function print() { __p += __j.call(arguments, '') }
369016
369271
  ]);
369017
369272
  });
369018
369273
 
369019
- // ../../packages/superdoc/dist/chunks/create-super-doc-ui-C_J_pCF0.es.js
369274
+ // ../../packages/superdoc/dist/chunks/create-super-doc-ui-CCLA6uFG.es.js
369020
369275
  var DEFAULT_TEXT_ALIGN_OPTIONS, DEFAULT_LINE_HEIGHT_OPTIONS, DEFAULT_ZOOM_OPTIONS, DEFAULT_DOCUMENT_MODE_OPTIONS, DEFAULT_FONT_SIZE_OPTIONS, headlessToolbarConstants, MOD_ALIASES, ALT_ALIASES, CTRL_ALIASES, SHIFT_ALIASES, BUILTIN_CONTEXT_MENU_GROUPS, BUILTIN_GROUP_ORDER, RESERVED_PROXY_PROPERTY_NAMES, ALL_TOOLBAR_COMMAND_IDS, EMPTY_ACTIVE_IDS, FONT_SIZE_OPTIONS;
369021
- var init_create_super_doc_ui_C_J_pCF0_es = __esm(() => {
369022
- init_SuperConverter_CCgGAnXY_es();
369023
- init_create_headless_toolbar_BvrKiWf0_es();
369276
+ var init_create_super_doc_ui_CCLA6uFG_es = __esm(() => {
369277
+ init_SuperConverter_WQVqM0th_es();
369278
+ init_create_headless_toolbar_B8OXKxcw_es();
369024
369279
  DEFAULT_TEXT_ALIGN_OPTIONS = [
369025
369280
  {
369026
369281
  label: "Left",
@@ -369311,16 +369566,16 @@ var init_zipper_yaJVJ4z9_es = __esm(() => {
369311
369566
 
369312
369567
  // ../../packages/superdoc/dist/super-editor.es.js
369313
369568
  var init_super_editor_es = __esm(() => {
369314
- init_src_CXtSesLH_es();
369315
- init_SuperConverter_CCgGAnXY_es();
369569
+ init_src_Bvhjxf8i_es();
369570
+ init_SuperConverter_WQVqM0th_es();
369316
369571
  init_jszip_C49i9kUs_es();
369317
369572
  init_xml_js_CqGKpaft_es();
369318
- init_create_headless_toolbar_BvrKiWf0_es();
369573
+ init_create_headless_toolbar_B8OXKxcw_es();
369319
369574
  init_constants_D9qj59G2_es();
369320
369575
  init_dist_B8HfvhaK_es();
369321
369576
  init_unified_Dsuw2be5_es();
369322
369577
  init_DocxZipper_FUsfThjV_es();
369323
- init_create_super_doc_ui_C_J_pCF0_es();
369578
+ init_create_super_doc_ui_CCLA6uFG_es();
369324
369579
  init_ui_C5PAS9hY_es();
369325
369580
  init_eventemitter3_BnGqBE_Q_es();
369326
369581
  init_errors_CNaD6vcg_es();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/cli",
3
- "version": "0.17.0-next.24",
3
+ "version": "0.17.0-next.26",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "superdoc": "./dist/index.js"
@@ -33,11 +33,11 @@
33
33
  "access": "public"
34
34
  },
35
35
  "optionalDependencies": {
36
- "@superdoc-dev/cli-darwin-arm64": "0.17.0-next.24",
37
- "@superdoc-dev/cli-linux-x64": "0.17.0-next.24",
38
- "@superdoc-dev/cli-darwin-x64": "0.17.0-next.24",
39
- "@superdoc-dev/cli-linux-arm64": "0.17.0-next.24",
40
- "@superdoc-dev/cli-windows-x64": "0.17.0-next.24"
36
+ "@superdoc-dev/cli-darwin-arm64": "0.17.0-next.26",
37
+ "@superdoc-dev/cli-darwin-x64": "0.17.0-next.26",
38
+ "@superdoc-dev/cli-linux-x64": "0.17.0-next.26",
39
+ "@superdoc-dev/cli-linux-arm64": "0.17.0-next.26",
40
+ "@superdoc-dev/cli-windows-x64": "0.17.0-next.26"
41
41
  },
42
42
  "scripts": {
43
43
  "predev": "node scripts/ensure-superdoc-build.js",