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

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 +306 -77
  2. package/package.json +8 -8
package/dist/index.js CHANGED
@@ -235222,7 +235222,7 @@ var init_remark_gfm_eZN6yzWQ_es = __esm(() => {
235222
235222
  init_remark_gfm_BhnWr3yf_es();
235223
235223
  });
235224
235224
 
235225
- // ../../packages/superdoc/dist/chunks/src-CXtSesLH.es.js
235225
+ // ../../packages/superdoc/dist/chunks/src-BB0n1coY.es.js
235226
235226
  function deleteProps(obj, propOrProps) {
235227
235227
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
235228
235228
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -286308,10 +286308,10 @@ function clickToPositionGeometry(layout, blocks2, measures, containerPoint, opti
286308
286308
  lineIndex
286309
286309
  };
286310
286310
  }
286311
- const firstRun = cellBlock.runs?.[0];
286312
- if (firstRun && firstRun.pmStart != null)
286311
+ const fallbackPos = cellBlock.runs?.[0]?.pmStart ?? blockPmRangeFromAttrs(cellBlock).pmStart;
286312
+ if (fallbackPos != null)
286313
286313
  return {
286314
- pos: firstRun.pmStart,
286314
+ pos: fallbackPos,
286315
286315
  layoutEpoch,
286316
286316
  blockId: tableHit.fragment.blockId,
286317
286317
  pageIndex,
@@ -286372,6 +286372,15 @@ function percentile(sortedValues, p$12) {
286372
286372
  const weight = index2 - lower;
286373
286373
  return sortedValues[lower] * (1 - weight) + sortedValues[upper] * weight;
286374
286374
  }
286375
+ function pushEmptyLineSelectionBand(rects, opts) {
286376
+ rects.push({
286377
+ x: opts.x,
286378
+ y: opts.y,
286379
+ width: Math.max(1, opts.width),
286380
+ height: opts.height,
286381
+ pageIndex: opts.pageIndex
286382
+ });
286383
+ }
286375
286384
  function selectionToRects(layout, blocks2, measures, from$1, to, geometryHelper) {
286376
286385
  if (from$1 === to)
286377
286386
  return [];
@@ -286398,8 +286407,17 @@ function selectionToRects(layout, blocks2, measures, from$1, to, geometryHelper)
286398
286407
  return;
286399
286408
  const sliceFrom = Math.max(range.pmStart, from$1);
286400
286409
  const sliceTo = Math.min(range.pmEnd, to);
286401
- if (sliceFrom >= sliceTo)
286410
+ if (sliceFrom >= sliceTo) {
286411
+ const emptyLineOffset = lineHeightBeforeIndex$1(measure, index2) - lineHeightBeforeIndex$1(measure, fragment2.fromLine);
286412
+ pushEmptyLineSelectionBand(rects, {
286413
+ x: fragment2.x,
286414
+ y: fragment2.y + emptyLineOffset + pageTopY,
286415
+ width: fragment2.width,
286416
+ height: line.lineHeight,
286417
+ pageIndex
286418
+ });
286402
286419
  return;
286420
+ }
286403
286421
  pmPosToCharOffset(block, line, sliceFrom);
286404
286422
  pmPosToCharOffset(block, line, sliceTo);
286405
286423
  const visualCharOffsetFrom = pmPosToVisualCharOffset(block, line, sliceFrom);
@@ -286577,8 +286595,17 @@ function selectionToRects(layout, blocks2, measures, from$1, to, geometryHelper)
286577
286595
  return;
286578
286596
  const sliceFrom = Math.max(range.pmStart, from$1);
286579
286597
  const sliceTo = Math.min(range.pmEnd, to);
286580
- if (sliceFrom >= sliceTo)
286598
+ if (sliceFrom >= sliceTo) {
286599
+ const emptyLineOffset = lineHeightBeforeIndex$1(info.measure, index2) - lineHeightBeforeIndex$1(info.measure, info.startLine);
286600
+ pushEmptyLineSelectionBand(rects, {
286601
+ x: fragment2.x + contentOffsetX + cellX + padding.left,
286602
+ y: fragment2.y + contentOffsetY + rowOffset + blockTopCursor + effectiveSpacingBeforePx + emptyLineOffset + pageTopY,
286603
+ width: cellMeasure.width - padding.left - padding.right,
286604
+ height: line.lineHeight,
286605
+ pageIndex
286606
+ });
286581
286607
  return;
286608
+ }
286582
286609
  pmPosToCharOffset(info.block, line, sliceFrom);
286583
286610
  pmPosToCharOffset(info.block, line, sliceTo);
286584
286611
  const visualCharOffsetFrom = pmPosToVisualCharOffset(info.block, line, sliceFrom);
@@ -286907,6 +286934,57 @@ function calculateExtendedSelection(blocks2, anchor, head, mode) {
286907
286934
  selHead: head
286908
286935
  };
286909
286936
  }
286937
+ function selectionCollapsesAcrossTableCells(doc$12, anchor, head) {
286938
+ if (anchor === head)
286939
+ return false;
286940
+ try {
286941
+ const size$1 = doc$12.content.size;
286942
+ if (anchor < 0 || head < 0 || anchor > size$1 || head > size$1)
286943
+ return false;
286944
+ const $from = doc$12.resolve(Math.min(anchor, head));
286945
+ const $to = doc$12.resolve(Math.max(anchor, head));
286946
+ const cellAncestor = (pos) => {
286947
+ for (let depth = pos.depth;depth > 0; depth--) {
286948
+ const role = pos.node(depth).type.spec.tableRole;
286949
+ if (role === "cell" || role === "header_cell")
286950
+ return pos.node(depth);
286951
+ }
286952
+ return null;
286953
+ };
286954
+ return cellAncestor($from) !== cellAncestor($to) && $to.parentOffset === 0;
286955
+ } catch {
286956
+ return false;
286957
+ }
286958
+ }
286959
+ function stabilizeTextSelectionAcrossTableCells(doc$12, anchor, head) {
286960
+ if (!selectionCollapsesAcrossTableCells(doc$12, anchor, head))
286961
+ return {
286962
+ selAnchor: anchor,
286963
+ selHead: head
286964
+ };
286965
+ try {
286966
+ const anchorIsUpper = anchor > head;
286967
+ const upperPos = anchorIsUpper ? anchor : head;
286968
+ if (upperPos < 0 || upperPos >= doc$12.content.size)
286969
+ return null;
286970
+ const $upper = doc$12.resolve(upperPos);
286971
+ if (!$upper.parent.inlineContent || $upper.parent.content.size !== 0)
286972
+ return null;
286973
+ const stabilizedUpperPos = upperPos + 1;
286974
+ if (stabilizedUpperPos > doc$12.content.size)
286975
+ return null;
286976
+ const selAnchor = anchorIsUpper ? stabilizedUpperPos : anchor;
286977
+ const selHead = anchorIsUpper ? head : stabilizedUpperPos;
286978
+ if (selectionCollapsesAcrossTableCells(doc$12, selAnchor, selHead))
286979
+ return null;
286980
+ return {
286981
+ selAnchor,
286982
+ selHead
286983
+ };
286984
+ } catch {
286985
+ return null;
286986
+ }
286987
+ }
286910
286988
  function registerPointerClick(event, previous3, options) {
286911
286989
  const time = event.timeStamp ?? performance.now();
286912
286990
  const withinTime = time - previous3.lastClickTime <= options.timeThresholdMs;
@@ -287322,14 +287400,16 @@ function computeSelectionRectsFromDom(options, from$1, to) {
287322
287400
  missingEntries.push(entry);
287323
287401
  }
287324
287402
  } catch {}
287325
- if (missingEntries && missingEntries.length > 0) {
287403
+ const spansMultipleLines = countDistinctLines(pageEntries) > 1;
287404
+ if (spansMultipleLines || missingEntries && missingEntries.length > 0) {
287326
287405
  if (isVerbose)
287327
- debugLog("verbose", `DOM selection rects: range missing entries ${JSON.stringify({
287406
+ debugLog("verbose", `DOM selection rects: switching to per-line rects ${JSON.stringify({
287328
287407
  pageIndex,
287329
287408
  sliceFrom,
287330
287409
  sliceTo,
287331
- missingCount: missingEntries.length,
287332
- missingPreview: missingEntries.slice(0, 20).map(entryDebugInfo)
287410
+ spansMultipleLines,
287411
+ missingCount: missingEntries?.length ?? 0,
287412
+ missingPreview: (missingEntries ?? []).slice(0, 20).map(entryDebugInfo)
287333
287413
  })}`);
287334
287414
  rawRects = collectClientRectsByLine(doc$12, pageEntries, sliceFrom, sliceTo);
287335
287415
  if (dumpRects)
@@ -287399,10 +287479,17 @@ function collectClientRectsByLine(doc$12, entries2, sliceFrom, sliceTo) {
287399
287479
  else
287400
287480
  lineMap.set(lineEl, [entry]);
287401
287481
  }
287402
- for (const [, lineEntries] of lineMap) {
287482
+ for (const [lineEl, lineEntries] of lineMap) {
287403
287483
  lineEntries.sort((a2, b$1) => a2.pmStart - b$1.pmStart !== 0 ? a2.pmStart - b$1.pmStart : a2.pmEnd - b$1.pmEnd);
287404
287484
  const linePmStart = lineEntries[0]?.pmStart ?? Infinity;
287405
287485
  const linePmEnd = lineEntries[lineEntries.length - 1]?.pmEnd ?? -Infinity;
287486
+ if (sliceFrom < linePmStart && linePmEnd < sliceTo && lineEl.isConnected) {
287487
+ const boxRect = lineEl.getBoundingClientRect();
287488
+ if (boxRect.width > 0 && boxRect.height > 0) {
287489
+ rects.push(boxRect);
287490
+ continue;
287491
+ }
287492
+ }
287406
287493
  if (!Number.isFinite(linePmStart) || !Number.isFinite(linePmEnd) || linePmEnd <= linePmStart)
287407
287494
  continue;
287408
287495
  const lineFrom = Math.max(sliceFrom, linePmStart);
@@ -287440,6 +287527,18 @@ function collectClientRectsByLine(doc$12, entries2, sliceFrom, sliceTo) {
287440
287527
  }
287441
287528
  return rects;
287442
287529
  }
287530
+ function countDistinctLines(entries2) {
287531
+ const lines = /* @__PURE__ */ new Set;
287532
+ let hasLoose = false;
287533
+ for (const entry of entries2) {
287534
+ const lineEl = entry.el.closest(".superdoc-line");
287535
+ if (lineEl)
287536
+ lines.add(lineEl);
287537
+ else
287538
+ hasLoose = true;
287539
+ }
287540
+ return lines.size + (hasLoose ? 1 : 0);
287541
+ }
287443
287542
  function setDomRangeStart(range, entry, pos) {
287444
287543
  const el = entry.el;
287445
287544
  const pmStart = entry.pmStart;
@@ -288775,6 +288874,94 @@ function resolvePointerPositionHit(options) {
288775
288874
  }
288776
288875
  return clickToPositionGeometry(layout, blocks2, measures, containerPoint, { geometryHelper });
288777
288876
  }
288877
+ function getTableBlocks(blocks2) {
288878
+ return blocks2.filter((block) => block.kind === "table");
288879
+ }
288880
+ function getTopLevelTablePosByIndex(doc$12, targetTableIndex) {
288881
+ if (!Number.isInteger(targetTableIndex) || targetTableIndex < 0)
288882
+ return null;
288883
+ let tablePos = null;
288884
+ let currentTableIndex = 0;
288885
+ doc$12.descendants((node3, pos) => {
288886
+ if (tablePos !== null)
288887
+ return false;
288888
+ if (node3.type.name !== "table")
288889
+ return true;
288890
+ if (currentTableIndex === targetTableIndex)
288891
+ tablePos = pos;
288892
+ currentTableIndex += 1;
288893
+ return false;
288894
+ });
288895
+ return tablePos;
288896
+ }
288897
+ function getTopLevelTableIndexAtPos(doc$12, targetTablePos) {
288898
+ if (!Number.isFinite(targetTablePos) || targetTablePos < 0 || targetTablePos > doc$12.content.size)
288899
+ return null;
288900
+ let tableIndex = null;
288901
+ let currentTableIndex = 0;
288902
+ doc$12.descendants((node3, pos) => {
288903
+ if (tableIndex !== null)
288904
+ return false;
288905
+ if (node3.type.name !== "table")
288906
+ return true;
288907
+ if (pos === targetTablePos)
288908
+ tableIndex = currentTableIndex;
288909
+ currentTableIndex += 1;
288910
+ return false;
288911
+ });
288912
+ return tableIndex;
288913
+ }
288914
+ function getCellCoordinatesFromCellPos(doc$12, tablePos, cellPos) {
288915
+ const tableNode = doc$12.nodeAt(tablePos);
288916
+ if (!tableNode || tableNode.type.name !== "table")
288917
+ return null;
288918
+ let rowPos = tablePos + 1;
288919
+ for (let rowIndex = 0;rowIndex < tableNode.childCount; rowIndex += 1) {
288920
+ const rowNode = tableNode.child(rowIndex);
288921
+ let currentCellPos = rowPos + 1;
288922
+ for (let cellColIndex = 0;cellColIndex < rowNode.childCount; cellColIndex += 1) {
288923
+ if (currentCellPos === cellPos)
288924
+ return {
288925
+ rowIndex,
288926
+ cellColIndex
288927
+ };
288928
+ currentCellPos += rowNode.child(cellColIndex).nodeSize;
288929
+ }
288930
+ rowPos += rowNode.nodeSize;
288931
+ }
288932
+ return null;
288933
+ }
288934
+ function getTopLevelTableBlockAtPos(doc$12, blocks2, tablePos) {
288935
+ if (!doc$12)
288936
+ return null;
288937
+ const tableIndex = getTopLevelTableIndexAtPos(doc$12, tablePos);
288938
+ if (tableIndex === null)
288939
+ return null;
288940
+ return getTableBlocks(blocks2)[tableIndex] ?? null;
288941
+ }
288942
+ function resolveCellAnchorStateFromCellPos(doc$12, blocks2, cellPos) {
288943
+ if (!doc$12 || !Number.isFinite(cellPos) || cellPos < 0 || cellPos > doc$12.content.size)
288944
+ return null;
288945
+ const tableRole = doc$12.nodeAt(cellPos)?.type.spec.tableRole;
288946
+ if (tableRole !== "cell" && tableRole !== "header_cell")
288947
+ return null;
288948
+ const context = resolveCellContext(doc$12, Math.min(cellPos + 1, doc$12.content.size));
288949
+ if (!context || context.cellPos !== cellPos)
288950
+ return null;
288951
+ const tableBlock = getTopLevelTableBlockAtPos(doc$12, blocks2, context.tablePos);
288952
+ if (!tableBlock)
288953
+ return null;
288954
+ const cellCoordinates = getCellCoordinatesFromCellPos(doc$12, context.tablePos, cellPos);
288955
+ if (!cellCoordinates)
288956
+ return null;
288957
+ return {
288958
+ tablePos: context.tablePos,
288959
+ cellPos,
288960
+ tableBlockId: tableBlock.id,
288961
+ cellRowIndex: cellCoordinates.rowIndex,
288962
+ cellColIndex: cellCoordinates.cellColIndex
288963
+ };
288964
+ }
288778
288965
  function getCellPosFromTableHit(tableHit, doc$12, blocks2) {
288779
288966
  if (!tableHit || !tableHit.block || typeof tableHit.block.id !== "string") {
288780
288967
  console.warn("[getCellPosFromTableHit] Invalid tableHit input:", tableHit);
@@ -288789,22 +288976,12 @@ function getCellPosFromTableHit(tableHit, doc$12, blocks2) {
288789
288976
  }
288790
288977
  if (!doc$12)
288791
288978
  return null;
288792
- const targetTableIndex = blocks2.filter((b$1) => b$1.kind === "table").findIndex((b$1) => b$1.id === tableHit.block.id);
288979
+ const targetTableIndex = getTableBlocks(blocks2).findIndex((b$1) => b$1.id === tableHit.block.id);
288793
288980
  if (targetTableIndex === -1)
288794
288981
  return null;
288795
288982
  let tablePos = null;
288796
- let currentTableIndex = 0;
288797
288983
  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
- });
288984
+ tablePos = getTopLevelTablePosByIndex(doc$12, targetTableIndex);
288808
288985
  } catch (error3) {
288809
288986
  console.error("[getCellPosFromTableHit] Error during document traversal:", error3);
288810
288987
  return null;
@@ -288852,22 +289029,51 @@ function getCellPosFromTableHit(tableHit, doc$12, blocks2) {
288852
289029
  function getTablePosFromHit(tableHit, doc$12, blocks2) {
288853
289030
  if (!doc$12)
288854
289031
  return null;
288855
- const targetTableIndex = blocks2.filter((b$1) => b$1.kind === "table").findIndex((b$1) => b$1.id === tableHit.block.id);
289032
+ const targetTableIndex = getTableBlocks(blocks2).findIndex((b$1) => b$1.id === tableHit.block.id);
288856
289033
  if (targetTableIndex === -1)
288857
289034
  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++;
289035
+ return getTopLevelTablePosByIndex(doc$12, targetTableIndex);
289036
+ }
289037
+ function resolveCellContext(doc$12, pos) {
289038
+ if (!doc$12 || !Number.isFinite(pos) || pos < 0 || pos > doc$12.content.size)
289039
+ return null;
289040
+ let $pos;
289041
+ try {
289042
+ $pos = doc$12.resolve(pos);
289043
+ } catch {
289044
+ return null;
289045
+ }
289046
+ let cellDepth = -1;
289047
+ let tableDepth = -1;
289048
+ for (let depth = $pos.depth;depth > 0; depth--) {
289049
+ const role = $pos.node(depth).type.spec.tableRole;
289050
+ if (cellDepth === -1 && (role === "cell" || role === "header_cell"))
289051
+ cellDepth = depth;
289052
+ if (cellDepth !== -1 && role === "table") {
289053
+ tableDepth = depth;
289054
+ break;
288867
289055
  }
288868
- return true;
288869
- });
288870
- return tablePos;
289056
+ }
289057
+ if (cellDepth === -1 || tableDepth === -1)
289058
+ return null;
289059
+ return {
289060
+ cellPos: $pos.before(cellDepth),
289061
+ tablePos: $pos.before(tableDepth)
289062
+ };
289063
+ }
289064
+ function resolveCrossCellSelection(doc$12, anchorPos, headPos) {
289065
+ const anchor = resolveCellContext(doc$12, anchorPos);
289066
+ const head = resolveCellContext(doc$12, headPos);
289067
+ if (!anchor || !head)
289068
+ return null;
289069
+ if (anchor.tablePos !== head.tablePos)
289070
+ return null;
289071
+ if (anchor.cellPos === head.cellPos)
289072
+ return null;
289073
+ return {
289074
+ anchorCellPos: anchor.cellPos,
289075
+ headCellPos: head.cellPos
289076
+ };
288871
289077
  }
288872
289078
  function shouldUseCellSelection(currentTableHit, cellAnchor, cellDragMode) {
288873
289079
  if (!cellAnchor)
@@ -289330,15 +289536,8 @@ function renderCellSelectionOverlay({ selection, layout, localSelectionLayer, bl
289330
289536
  let tableBlock;
289331
289537
  if (cellAnchorTableBlockId)
289332
289538
  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
- }
289539
+ if (!tableBlock)
289540
+ tableBlock = getTopLevelTableBlockAtPos($anchorCell.node(0), blocks2, tableStart) ?? undefined;
289342
289541
  if (!tableBlock)
289343
289542
  return;
289344
289543
  const tableFragments = [];
@@ -328144,18 +328343,45 @@ menclose::after {
328144
328343
  const layoutState = this.#deps?.getLayoutState();
328145
328344
  return getTablePosFromHit(tableHit, editor?.state?.doc ?? null, layoutState?.blocks ?? []);
328146
328345
  }
328346
+ #setCellAnchorState(cellAnchor, mode = "pending") {
328347
+ this.#cellAnchor = cellAnchor;
328348
+ this.#cellDragMode = mode;
328349
+ }
328147
328350
  #setCellAnchor(tableHit, tablePos) {
328148
328351
  const cellPos = this.#getCellPosFromTableHit(tableHit);
328149
328352
  if (cellPos === null)
328150
328353
  return;
328151
- this.#cellAnchor = {
328354
+ this.#setCellAnchorState({
328152
328355
  tablePos,
328153
328356
  cellPos,
328154
328357
  cellRowIndex: tableHit.cellRowIndex,
328155
328358
  cellColIndex: tableHit.cellColIndex,
328156
328359
  tableBlockId: tableHit.block.id
328157
- };
328158
- this.#cellDragMode = "pending";
328360
+ }, "pending");
328361
+ }
328362
+ #setCellAnchorFromCellPos(cellPos, mode = "pending") {
328363
+ const editor = this.#deps?.getEditor();
328364
+ const layoutState = this.#deps?.getLayoutState();
328365
+ const cellAnchor = resolveCellAnchorStateFromCellPos(editor?.state?.doc ?? null, layoutState?.blocks ?? [], cellPos);
328366
+ if (!cellAnchor)
328367
+ return false;
328368
+ this.#setCellAnchorState(cellAnchor, mode);
328369
+ return true;
328370
+ }
328371
+ #dispatchExtendedTextSelection(editor, anchor, head) {
328372
+ const { selAnchor, selHead } = this.#calculateExtendedSelection(anchor, head, this.#dragExtensionMode);
328373
+ const stabilized = stabilizeTextSelectionAcrossTableCells(editor.state.doc, selAnchor, selHead);
328374
+ if (!stabilized)
328375
+ return false;
328376
+ try {
328377
+ const tr = editor.state.tr.setSelection(TextSelection.create(editor.state.doc, stabilized.selAnchor, stabilized.selHead));
328378
+ editor.view?.dispatch(tr);
328379
+ this.#callbacks.scheduleSelectionUpdate?.();
328380
+ return true;
328381
+ } catch (error3) {
328382
+ console.warn("[SELECTION] Failed to extend text selection:", error3);
328383
+ return false;
328384
+ }
328159
328385
  }
328160
328386
  #hitTestTable(x, y$1) {
328161
328387
  return this.#callbacks.hitTestTable?.(x, y$1) ?? null;
@@ -328757,6 +328983,8 @@ menclose::after {
328757
328983
  this.#pendingMarginClick = null;
328758
328984
  const dragAnchor = this.#dragAnchor;
328759
328985
  const dragMode = this.#dragExtensionMode;
328986
+ if ((!pendingMarginClick || pendingMarginClick.pointerId !== event.pointerId) && dragAnchor != null && this.#dragThresholdExceeded)
328987
+ this.#handleDragSelectionAt(event.clientX, event.clientY);
328760
328988
  const dragUsedFallback = this.#dragUsedPageNotMountedFallback;
328761
328989
  const dragPointer = this.#dragLastPointer;
328762
328990
  this.#isDragging = false;
@@ -329239,14 +329467,7 @@ menclose::after {
329239
329467
  if (!editor)
329240
329468
  return;
329241
329469
  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
- }
329470
+ this.#dispatchExtendedTextSelection(editor, anchor, headPos);
329250
329471
  this.#focusEditor();
329251
329472
  }
329252
329473
  #handleDragSelectionAt(clientX, clientY) {
@@ -329307,17 +329528,28 @@ menclose::after {
329307
329528
  }
329308
329529
  const anchor = this.#dragAnchor;
329309
329530
  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);
329531
+ if (!useActiveSurfaceHitTest) {
329532
+ const crossCell = resolveCrossCellSelection(editor.state.doc, anchor, head);
329533
+ if (crossCell)
329534
+ try {
329535
+ const tr = editor.state.tr.setSelection(CellSelection.create(editor.state.doc, crossCell.anchorCellPos, crossCell.headCellPos));
329536
+ editor.view?.dispatch(tr);
329537
+ if (!this.#setCellAnchorFromCellPos(crossCell.anchorCellPos, "active"))
329538
+ console.warn("[CELL-SELECTION] Failed to cache anchor state for cross-cell drag selection.");
329539
+ this.#callbacks.scheduleSelectionUpdate?.();
329540
+ return;
329541
+ } catch (error3) {
329542
+ console.warn("[SELECTION] Failed to create cross-cell CellSelection during drag:", error3);
329543
+ }
329317
329544
  }
329545
+ this.#dispatchExtendedTextSelection(editor, anchor, head);
329318
329546
  }
329319
329547
  #handleCellDragSelection(currentTableHit, hit) {
329320
- const headCellPos = currentTableHit ? this.#getCellPosFromTableHit(currentTableHit) : null;
329548
+ if (!this.#cellAnchor)
329549
+ return;
329550
+ if (!currentTableHit || currentTableHit.block.id !== this.#cellAnchor.tableBlockId)
329551
+ return;
329552
+ const headCellPos = this.#getCellPosFromTableHit(currentTableHit);
329321
329553
  if (headCellPos === null)
329322
329554
  return;
329323
329555
  if (this.#cellDragMode !== "active")
@@ -329337,13 +329569,7 @@ menclose::after {
329337
329569
  } catch (error3) {
329338
329570
  console.warn("[CELL-SELECTION] Failed to create CellSelection, falling back to TextSelection:", error3);
329339
329571
  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 {}
329572
+ this.#dispatchExtendedTextSelection(editor, anchor, hit.pos);
329347
329573
  }
329348
329574
  }
329349
329575
  #handleHover(normalized) {
@@ -333228,7 +333454,7 @@ menclose::after {
333228
333454
  return;
333229
333455
  console.log(...args$1);
333230
333456
  }, 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(() => {
333457
+ var init_src_BB0n1coY_es = __esm(() => {
333232
333458
  init_rolldown_runtime_Bg48TavK_es();
333233
333459
  init_SuperConverter_CCgGAnXY_es();
333234
333460
  init_jszip_C49i9kUs_es();
@@ -367643,14 +367869,17 @@ function print() { __p += __j.call(arguments, '') }
367643
367869
  return;
367644
367870
  }
367645
367871
  const head = Math.max(0, Math.min(mappedHead.pos, doc$12.content.size));
367646
- const { selAnchor, selHead } = this.#calculateExtendedSelection(anchor, head, mode);
367872
+ const extended = this.#calculateExtendedSelection(anchor, head, mode);
367873
+ const stabilized = stabilizeTextSelectionAcrossTableCells(doc$12, extended.selAnchor, extended.selHead);
367874
+ if (!stabilized)
367875
+ return;
367647
367876
  const current = this.#editor.state.selection;
367648
- const desiredFrom = Math.min(selAnchor, selHead);
367649
- const desiredTo = Math.max(selAnchor, selHead);
367877
+ const desiredFrom = Math.min(stabilized.selAnchor, stabilized.selHead);
367878
+ const desiredTo = Math.max(stabilized.selAnchor, stabilized.selHead);
367650
367879
  if (current.from === desiredFrom && current.to === desiredTo)
367651
367880
  return;
367652
367881
  try {
367653
- const tr = this.#editor.state.tr.setSelection(TextSelection.create(this.#editor.state.doc, selAnchor, selHead));
367882
+ const tr = this.#editor.state.tr.setSelection(TextSelection.create(this.#editor.state.doc, stabilized.selAnchor, stabilized.selHead));
367654
367883
  this.#editor.view?.dispatch(tr);
367655
367884
  this.#scheduleSelectionUpdate();
367656
367885
  } catch {}
@@ -369311,7 +369540,7 @@ var init_zipper_yaJVJ4z9_es = __esm(() => {
369311
369540
 
369312
369541
  // ../../packages/superdoc/dist/super-editor.es.js
369313
369542
  var init_super_editor_es = __esm(() => {
369314
- init_src_CXtSesLH_es();
369543
+ init_src_BB0n1coY_es();
369315
369544
  init_SuperConverter_CCgGAnXY_es();
369316
369545
  init_jszip_C49i9kUs_es();
369317
369546
  init_xml_js_CqGKpaft_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.25",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "superdoc": "./dist/index.js"
@@ -25,19 +25,19 @@
25
25
  "@types/ws": "^8.5.13",
26
26
  "typescript": "^5.9.2",
27
27
  "@superdoc/document-api": "0.0.1",
28
- "superdoc": "1.39.0",
29
- "@superdoc/super-editor": "0.0.1"
28
+ "@superdoc/super-editor": "0.0.1",
29
+ "superdoc": "1.39.0"
30
30
  },
31
31
  "module": "src/index.ts",
32
32
  "publishConfig": {
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.25",
37
+ "@superdoc-dev/cli-darwin-x64": "0.17.0-next.25",
38
+ "@superdoc-dev/cli-linux-arm64": "0.17.0-next.25",
39
+ "@superdoc-dev/cli-windows-x64": "0.17.0-next.25",
40
+ "@superdoc-dev/cli-linux-x64": "0.17.0-next.25"
41
41
  },
42
42
  "scripts": {
43
43
  "predev": "node scripts/ensure-superdoc-build.js",