@superdoc-dev/mcp 0.12.0-next.24 → 0.12.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.
- package/dist/index.js +306 -77
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -224588,7 +224588,7 @@ var init_remark_gfm_eZN6yzWQ_es = __esm(() => {
|
|
|
224588
224588
|
init_remark_gfm_BhnWr3yf_es();
|
|
224589
224589
|
});
|
|
224590
224590
|
|
|
224591
|
-
// ../../packages/superdoc/dist/chunks/src-
|
|
224591
|
+
// ../../packages/superdoc/dist/chunks/src-BB0n1coY.es.js
|
|
224592
224592
|
function deleteProps(obj, propOrProps) {
|
|
224593
224593
|
const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
|
|
224594
224594
|
const removeNested = (target, pathParts, index2 = 0) => {
|
|
@@ -275541,10 +275541,10 @@ function clickToPositionGeometry(layout, blocks2, measures, containerPoint, opti
|
|
|
275541
275541
|
lineIndex
|
|
275542
275542
|
};
|
|
275543
275543
|
}
|
|
275544
|
-
const
|
|
275545
|
-
if (
|
|
275544
|
+
const fallbackPos = cellBlock.runs?.[0]?.pmStart ?? blockPmRangeFromAttrs(cellBlock).pmStart;
|
|
275545
|
+
if (fallbackPos != null)
|
|
275546
275546
|
return {
|
|
275547
|
-
pos:
|
|
275547
|
+
pos: fallbackPos,
|
|
275548
275548
|
layoutEpoch,
|
|
275549
275549
|
blockId: tableHit.fragment.blockId,
|
|
275550
275550
|
pageIndex,
|
|
@@ -275605,6 +275605,15 @@ function percentile(sortedValues, p$12) {
|
|
|
275605
275605
|
const weight = index2 - lower;
|
|
275606
275606
|
return sortedValues[lower] * (1 - weight) + sortedValues[upper] * weight;
|
|
275607
275607
|
}
|
|
275608
|
+
function pushEmptyLineSelectionBand(rects, opts) {
|
|
275609
|
+
rects.push({
|
|
275610
|
+
x: opts.x,
|
|
275611
|
+
y: opts.y,
|
|
275612
|
+
width: Math.max(1, opts.width),
|
|
275613
|
+
height: opts.height,
|
|
275614
|
+
pageIndex: opts.pageIndex
|
|
275615
|
+
});
|
|
275616
|
+
}
|
|
275608
275617
|
function selectionToRects(layout, blocks2, measures, from$1, to, geometryHelper) {
|
|
275609
275618
|
if (from$1 === to)
|
|
275610
275619
|
return [];
|
|
@@ -275631,8 +275640,17 @@ function selectionToRects(layout, blocks2, measures, from$1, to, geometryHelper)
|
|
|
275631
275640
|
return;
|
|
275632
275641
|
const sliceFrom = Math.max(range.pmStart, from$1);
|
|
275633
275642
|
const sliceTo = Math.min(range.pmEnd, to);
|
|
275634
|
-
if (sliceFrom >= sliceTo)
|
|
275643
|
+
if (sliceFrom >= sliceTo) {
|
|
275644
|
+
const emptyLineOffset = lineHeightBeforeIndex$1(measure, index2) - lineHeightBeforeIndex$1(measure, fragment.fromLine);
|
|
275645
|
+
pushEmptyLineSelectionBand(rects, {
|
|
275646
|
+
x: fragment.x,
|
|
275647
|
+
y: fragment.y + emptyLineOffset + pageTopY,
|
|
275648
|
+
width: fragment.width,
|
|
275649
|
+
height: line.lineHeight,
|
|
275650
|
+
pageIndex
|
|
275651
|
+
});
|
|
275635
275652
|
return;
|
|
275653
|
+
}
|
|
275636
275654
|
pmPosToCharOffset(block, line, sliceFrom);
|
|
275637
275655
|
pmPosToCharOffset(block, line, sliceTo);
|
|
275638
275656
|
const visualCharOffsetFrom = pmPosToVisualCharOffset(block, line, sliceFrom);
|
|
@@ -275810,8 +275828,17 @@ function selectionToRects(layout, blocks2, measures, from$1, to, geometryHelper)
|
|
|
275810
275828
|
return;
|
|
275811
275829
|
const sliceFrom = Math.max(range.pmStart, from$1);
|
|
275812
275830
|
const sliceTo = Math.min(range.pmEnd, to);
|
|
275813
|
-
if (sliceFrom >= sliceTo)
|
|
275831
|
+
if (sliceFrom >= sliceTo) {
|
|
275832
|
+
const emptyLineOffset = lineHeightBeforeIndex$1(info.measure, index2) - lineHeightBeforeIndex$1(info.measure, info.startLine);
|
|
275833
|
+
pushEmptyLineSelectionBand(rects, {
|
|
275834
|
+
x: fragment.x + contentOffsetX + cellX + padding.left,
|
|
275835
|
+
y: fragment.y + contentOffsetY + rowOffset + blockTopCursor + effectiveSpacingBeforePx + emptyLineOffset + pageTopY,
|
|
275836
|
+
width: cellMeasure.width - padding.left - padding.right,
|
|
275837
|
+
height: line.lineHeight,
|
|
275838
|
+
pageIndex
|
|
275839
|
+
});
|
|
275814
275840
|
return;
|
|
275841
|
+
}
|
|
275815
275842
|
pmPosToCharOffset(info.block, line, sliceFrom);
|
|
275816
275843
|
pmPosToCharOffset(info.block, line, sliceTo);
|
|
275817
275844
|
const visualCharOffsetFrom = pmPosToVisualCharOffset(info.block, line, sliceFrom);
|
|
@@ -276140,6 +276167,57 @@ function calculateExtendedSelection(blocks2, anchor, head, mode) {
|
|
|
276140
276167
|
selHead: head
|
|
276141
276168
|
};
|
|
276142
276169
|
}
|
|
276170
|
+
function selectionCollapsesAcrossTableCells(doc$12, anchor, head) {
|
|
276171
|
+
if (anchor === head)
|
|
276172
|
+
return false;
|
|
276173
|
+
try {
|
|
276174
|
+
const size$1 = doc$12.content.size;
|
|
276175
|
+
if (anchor < 0 || head < 0 || anchor > size$1 || head > size$1)
|
|
276176
|
+
return false;
|
|
276177
|
+
const $from = doc$12.resolve(Math.min(anchor, head));
|
|
276178
|
+
const $to = doc$12.resolve(Math.max(anchor, head));
|
|
276179
|
+
const cellAncestor = (pos) => {
|
|
276180
|
+
for (let depth = pos.depth;depth > 0; depth--) {
|
|
276181
|
+
const role = pos.node(depth).type.spec.tableRole;
|
|
276182
|
+
if (role === "cell" || role === "header_cell")
|
|
276183
|
+
return pos.node(depth);
|
|
276184
|
+
}
|
|
276185
|
+
return null;
|
|
276186
|
+
};
|
|
276187
|
+
return cellAncestor($from) !== cellAncestor($to) && $to.parentOffset === 0;
|
|
276188
|
+
} catch {
|
|
276189
|
+
return false;
|
|
276190
|
+
}
|
|
276191
|
+
}
|
|
276192
|
+
function stabilizeTextSelectionAcrossTableCells(doc$12, anchor, head) {
|
|
276193
|
+
if (!selectionCollapsesAcrossTableCells(doc$12, anchor, head))
|
|
276194
|
+
return {
|
|
276195
|
+
selAnchor: anchor,
|
|
276196
|
+
selHead: head
|
|
276197
|
+
};
|
|
276198
|
+
try {
|
|
276199
|
+
const anchorIsUpper = anchor > head;
|
|
276200
|
+
const upperPos = anchorIsUpper ? anchor : head;
|
|
276201
|
+
if (upperPos < 0 || upperPos >= doc$12.content.size)
|
|
276202
|
+
return null;
|
|
276203
|
+
const $upper = doc$12.resolve(upperPos);
|
|
276204
|
+
if (!$upper.parent.inlineContent || $upper.parent.content.size !== 0)
|
|
276205
|
+
return null;
|
|
276206
|
+
const stabilizedUpperPos = upperPos + 1;
|
|
276207
|
+
if (stabilizedUpperPos > doc$12.content.size)
|
|
276208
|
+
return null;
|
|
276209
|
+
const selAnchor = anchorIsUpper ? stabilizedUpperPos : anchor;
|
|
276210
|
+
const selHead = anchorIsUpper ? head : stabilizedUpperPos;
|
|
276211
|
+
if (selectionCollapsesAcrossTableCells(doc$12, selAnchor, selHead))
|
|
276212
|
+
return null;
|
|
276213
|
+
return {
|
|
276214
|
+
selAnchor,
|
|
276215
|
+
selHead
|
|
276216
|
+
};
|
|
276217
|
+
} catch {
|
|
276218
|
+
return null;
|
|
276219
|
+
}
|
|
276220
|
+
}
|
|
276143
276221
|
function registerPointerClick(event, previous3, options) {
|
|
276144
276222
|
const time3 = event.timeStamp ?? performance.now();
|
|
276145
276223
|
const withinTime = time3 - previous3.lastClickTime <= options.timeThresholdMs;
|
|
@@ -276555,14 +276633,16 @@ function computeSelectionRectsFromDom(options, from$1, to) {
|
|
|
276555
276633
|
missingEntries.push(entry);
|
|
276556
276634
|
}
|
|
276557
276635
|
} catch {}
|
|
276558
|
-
|
|
276636
|
+
const spansMultipleLines = countDistinctLines(pageEntries) > 1;
|
|
276637
|
+
if (spansMultipleLines || missingEntries && missingEntries.length > 0) {
|
|
276559
276638
|
if (isVerbose)
|
|
276560
|
-
debugLog("verbose", `DOM selection rects:
|
|
276639
|
+
debugLog("verbose", `DOM selection rects: switching to per-line rects ${JSON.stringify({
|
|
276561
276640
|
pageIndex,
|
|
276562
276641
|
sliceFrom,
|
|
276563
276642
|
sliceTo,
|
|
276564
|
-
|
|
276565
|
-
|
|
276643
|
+
spansMultipleLines,
|
|
276644
|
+
missingCount: missingEntries?.length ?? 0,
|
|
276645
|
+
missingPreview: (missingEntries ?? []).slice(0, 20).map(entryDebugInfo)
|
|
276566
276646
|
})}`);
|
|
276567
276647
|
rawRects = collectClientRectsByLine(doc$12, pageEntries, sliceFrom, sliceTo);
|
|
276568
276648
|
if (dumpRects)
|
|
@@ -276632,10 +276712,17 @@ function collectClientRectsByLine(doc$12, entries, sliceFrom, sliceTo) {
|
|
|
276632
276712
|
else
|
|
276633
276713
|
lineMap.set(lineEl, [entry]);
|
|
276634
276714
|
}
|
|
276635
|
-
for (const [, lineEntries] of lineMap) {
|
|
276715
|
+
for (const [lineEl, lineEntries] of lineMap) {
|
|
276636
276716
|
lineEntries.sort((a2, b$1) => a2.pmStart - b$1.pmStart !== 0 ? a2.pmStart - b$1.pmStart : a2.pmEnd - b$1.pmEnd);
|
|
276637
276717
|
const linePmStart = lineEntries[0]?.pmStart ?? Infinity;
|
|
276638
276718
|
const linePmEnd = lineEntries[lineEntries.length - 1]?.pmEnd ?? -Infinity;
|
|
276719
|
+
if (sliceFrom < linePmStart && linePmEnd < sliceTo && lineEl.isConnected) {
|
|
276720
|
+
const boxRect = lineEl.getBoundingClientRect();
|
|
276721
|
+
if (boxRect.width > 0 && boxRect.height > 0) {
|
|
276722
|
+
rects.push(boxRect);
|
|
276723
|
+
continue;
|
|
276724
|
+
}
|
|
276725
|
+
}
|
|
276639
276726
|
if (!Number.isFinite(linePmStart) || !Number.isFinite(linePmEnd) || linePmEnd <= linePmStart)
|
|
276640
276727
|
continue;
|
|
276641
276728
|
const lineFrom = Math.max(sliceFrom, linePmStart);
|
|
@@ -276673,6 +276760,18 @@ function collectClientRectsByLine(doc$12, entries, sliceFrom, sliceTo) {
|
|
|
276673
276760
|
}
|
|
276674
276761
|
return rects;
|
|
276675
276762
|
}
|
|
276763
|
+
function countDistinctLines(entries) {
|
|
276764
|
+
const lines = /* @__PURE__ */ new Set;
|
|
276765
|
+
let hasLoose = false;
|
|
276766
|
+
for (const entry of entries) {
|
|
276767
|
+
const lineEl = entry.el.closest(".superdoc-line");
|
|
276768
|
+
if (lineEl)
|
|
276769
|
+
lines.add(lineEl);
|
|
276770
|
+
else
|
|
276771
|
+
hasLoose = true;
|
|
276772
|
+
}
|
|
276773
|
+
return lines.size + (hasLoose ? 1 : 0);
|
|
276774
|
+
}
|
|
276676
276775
|
function setDomRangeStart(range, entry, pos) {
|
|
276677
276776
|
const el = entry.el;
|
|
276678
276777
|
const pmStart = entry.pmStart;
|
|
@@ -278008,6 +278107,94 @@ function resolvePointerPositionHit(options) {
|
|
|
278008
278107
|
}
|
|
278009
278108
|
return clickToPositionGeometry(layout, blocks2, measures, containerPoint, { geometryHelper });
|
|
278010
278109
|
}
|
|
278110
|
+
function getTableBlocks(blocks2) {
|
|
278111
|
+
return blocks2.filter((block) => block.kind === "table");
|
|
278112
|
+
}
|
|
278113
|
+
function getTopLevelTablePosByIndex(doc$12, targetTableIndex) {
|
|
278114
|
+
if (!Number.isInteger(targetTableIndex) || targetTableIndex < 0)
|
|
278115
|
+
return null;
|
|
278116
|
+
let tablePos = null;
|
|
278117
|
+
let currentTableIndex = 0;
|
|
278118
|
+
doc$12.descendants((node2, pos) => {
|
|
278119
|
+
if (tablePos !== null)
|
|
278120
|
+
return false;
|
|
278121
|
+
if (node2.type.name !== "table")
|
|
278122
|
+
return true;
|
|
278123
|
+
if (currentTableIndex === targetTableIndex)
|
|
278124
|
+
tablePos = pos;
|
|
278125
|
+
currentTableIndex += 1;
|
|
278126
|
+
return false;
|
|
278127
|
+
});
|
|
278128
|
+
return tablePos;
|
|
278129
|
+
}
|
|
278130
|
+
function getTopLevelTableIndexAtPos(doc$12, targetTablePos) {
|
|
278131
|
+
if (!Number.isFinite(targetTablePos) || targetTablePos < 0 || targetTablePos > doc$12.content.size)
|
|
278132
|
+
return null;
|
|
278133
|
+
let tableIndex = null;
|
|
278134
|
+
let currentTableIndex = 0;
|
|
278135
|
+
doc$12.descendants((node2, pos) => {
|
|
278136
|
+
if (tableIndex !== null)
|
|
278137
|
+
return false;
|
|
278138
|
+
if (node2.type.name !== "table")
|
|
278139
|
+
return true;
|
|
278140
|
+
if (pos === targetTablePos)
|
|
278141
|
+
tableIndex = currentTableIndex;
|
|
278142
|
+
currentTableIndex += 1;
|
|
278143
|
+
return false;
|
|
278144
|
+
});
|
|
278145
|
+
return tableIndex;
|
|
278146
|
+
}
|
|
278147
|
+
function getCellCoordinatesFromCellPos(doc$12, tablePos, cellPos) {
|
|
278148
|
+
const tableNode = doc$12.nodeAt(tablePos);
|
|
278149
|
+
if (!tableNode || tableNode.type.name !== "table")
|
|
278150
|
+
return null;
|
|
278151
|
+
let rowPos = tablePos + 1;
|
|
278152
|
+
for (let rowIndex = 0;rowIndex < tableNode.childCount; rowIndex += 1) {
|
|
278153
|
+
const rowNode = tableNode.child(rowIndex);
|
|
278154
|
+
let currentCellPos = rowPos + 1;
|
|
278155
|
+
for (let cellColIndex = 0;cellColIndex < rowNode.childCount; cellColIndex += 1) {
|
|
278156
|
+
if (currentCellPos === cellPos)
|
|
278157
|
+
return {
|
|
278158
|
+
rowIndex,
|
|
278159
|
+
cellColIndex
|
|
278160
|
+
};
|
|
278161
|
+
currentCellPos += rowNode.child(cellColIndex).nodeSize;
|
|
278162
|
+
}
|
|
278163
|
+
rowPos += rowNode.nodeSize;
|
|
278164
|
+
}
|
|
278165
|
+
return null;
|
|
278166
|
+
}
|
|
278167
|
+
function getTopLevelTableBlockAtPos(doc$12, blocks2, tablePos) {
|
|
278168
|
+
if (!doc$12)
|
|
278169
|
+
return null;
|
|
278170
|
+
const tableIndex = getTopLevelTableIndexAtPos(doc$12, tablePos);
|
|
278171
|
+
if (tableIndex === null)
|
|
278172
|
+
return null;
|
|
278173
|
+
return getTableBlocks(blocks2)[tableIndex] ?? null;
|
|
278174
|
+
}
|
|
278175
|
+
function resolveCellAnchorStateFromCellPos(doc$12, blocks2, cellPos) {
|
|
278176
|
+
if (!doc$12 || !Number.isFinite(cellPos) || cellPos < 0 || cellPos > doc$12.content.size)
|
|
278177
|
+
return null;
|
|
278178
|
+
const tableRole = doc$12.nodeAt(cellPos)?.type.spec.tableRole;
|
|
278179
|
+
if (tableRole !== "cell" && tableRole !== "header_cell")
|
|
278180
|
+
return null;
|
|
278181
|
+
const context = resolveCellContext(doc$12, Math.min(cellPos + 1, doc$12.content.size));
|
|
278182
|
+
if (!context || context.cellPos !== cellPos)
|
|
278183
|
+
return null;
|
|
278184
|
+
const tableBlock = getTopLevelTableBlockAtPos(doc$12, blocks2, context.tablePos);
|
|
278185
|
+
if (!tableBlock)
|
|
278186
|
+
return null;
|
|
278187
|
+
const cellCoordinates = getCellCoordinatesFromCellPos(doc$12, context.tablePos, cellPos);
|
|
278188
|
+
if (!cellCoordinates)
|
|
278189
|
+
return null;
|
|
278190
|
+
return {
|
|
278191
|
+
tablePos: context.tablePos,
|
|
278192
|
+
cellPos,
|
|
278193
|
+
tableBlockId: tableBlock.id,
|
|
278194
|
+
cellRowIndex: cellCoordinates.rowIndex,
|
|
278195
|
+
cellColIndex: cellCoordinates.cellColIndex
|
|
278196
|
+
};
|
|
278197
|
+
}
|
|
278011
278198
|
function getCellPosFromTableHit(tableHit, doc$12, blocks2) {
|
|
278012
278199
|
if (!tableHit || !tableHit.block || typeof tableHit.block.id !== "string") {
|
|
278013
278200
|
console.warn("[getCellPosFromTableHit] Invalid tableHit input:", tableHit);
|
|
@@ -278022,22 +278209,12 @@ function getCellPosFromTableHit(tableHit, doc$12, blocks2) {
|
|
|
278022
278209
|
}
|
|
278023
278210
|
if (!doc$12)
|
|
278024
278211
|
return null;
|
|
278025
|
-
const targetTableIndex = blocks2
|
|
278212
|
+
const targetTableIndex = getTableBlocks(blocks2).findIndex((b$1) => b$1.id === tableHit.block.id);
|
|
278026
278213
|
if (targetTableIndex === -1)
|
|
278027
278214
|
return null;
|
|
278028
278215
|
let tablePos = null;
|
|
278029
|
-
let currentTableIndex = 0;
|
|
278030
278216
|
try {
|
|
278031
|
-
doc$12
|
|
278032
|
-
if (node2.type.name === "table") {
|
|
278033
|
-
if (currentTableIndex === targetTableIndex) {
|
|
278034
|
-
tablePos = pos;
|
|
278035
|
-
return false;
|
|
278036
|
-
}
|
|
278037
|
-
currentTableIndex++;
|
|
278038
|
-
}
|
|
278039
|
-
return true;
|
|
278040
|
-
});
|
|
278217
|
+
tablePos = getTopLevelTablePosByIndex(doc$12, targetTableIndex);
|
|
278041
278218
|
} catch (error48) {
|
|
278042
278219
|
console.error("[getCellPosFromTableHit] Error during document traversal:", error48);
|
|
278043
278220
|
return null;
|
|
@@ -278085,22 +278262,51 @@ function getCellPosFromTableHit(tableHit, doc$12, blocks2) {
|
|
|
278085
278262
|
function getTablePosFromHit(tableHit, doc$12, blocks2) {
|
|
278086
278263
|
if (!doc$12)
|
|
278087
278264
|
return null;
|
|
278088
|
-
const targetTableIndex = blocks2
|
|
278265
|
+
const targetTableIndex = getTableBlocks(blocks2).findIndex((b$1) => b$1.id === tableHit.block.id);
|
|
278089
278266
|
if (targetTableIndex === -1)
|
|
278090
278267
|
return null;
|
|
278091
|
-
|
|
278092
|
-
|
|
278093
|
-
|
|
278094
|
-
|
|
278095
|
-
|
|
278096
|
-
|
|
278097
|
-
|
|
278098
|
-
|
|
278099
|
-
|
|
278268
|
+
return getTopLevelTablePosByIndex(doc$12, targetTableIndex);
|
|
278269
|
+
}
|
|
278270
|
+
function resolveCellContext(doc$12, pos) {
|
|
278271
|
+
if (!doc$12 || !Number.isFinite(pos) || pos < 0 || pos > doc$12.content.size)
|
|
278272
|
+
return null;
|
|
278273
|
+
let $pos;
|
|
278274
|
+
try {
|
|
278275
|
+
$pos = doc$12.resolve(pos);
|
|
278276
|
+
} catch {
|
|
278277
|
+
return null;
|
|
278278
|
+
}
|
|
278279
|
+
let cellDepth = -1;
|
|
278280
|
+
let tableDepth = -1;
|
|
278281
|
+
for (let depth = $pos.depth;depth > 0; depth--) {
|
|
278282
|
+
const role = $pos.node(depth).type.spec.tableRole;
|
|
278283
|
+
if (cellDepth === -1 && (role === "cell" || role === "header_cell"))
|
|
278284
|
+
cellDepth = depth;
|
|
278285
|
+
if (cellDepth !== -1 && role === "table") {
|
|
278286
|
+
tableDepth = depth;
|
|
278287
|
+
break;
|
|
278100
278288
|
}
|
|
278101
|
-
|
|
278102
|
-
|
|
278103
|
-
|
|
278289
|
+
}
|
|
278290
|
+
if (cellDepth === -1 || tableDepth === -1)
|
|
278291
|
+
return null;
|
|
278292
|
+
return {
|
|
278293
|
+
cellPos: $pos.before(cellDepth),
|
|
278294
|
+
tablePos: $pos.before(tableDepth)
|
|
278295
|
+
};
|
|
278296
|
+
}
|
|
278297
|
+
function resolveCrossCellSelection(doc$12, anchorPos, headPos) {
|
|
278298
|
+
const anchor = resolveCellContext(doc$12, anchorPos);
|
|
278299
|
+
const head = resolveCellContext(doc$12, headPos);
|
|
278300
|
+
if (!anchor || !head)
|
|
278301
|
+
return null;
|
|
278302
|
+
if (anchor.tablePos !== head.tablePos)
|
|
278303
|
+
return null;
|
|
278304
|
+
if (anchor.cellPos === head.cellPos)
|
|
278305
|
+
return null;
|
|
278306
|
+
return {
|
|
278307
|
+
anchorCellPos: anchor.cellPos,
|
|
278308
|
+
headCellPos: head.cellPos
|
|
278309
|
+
};
|
|
278104
278310
|
}
|
|
278105
278311
|
function shouldUseCellSelection(currentTableHit, cellAnchor, cellDragMode) {
|
|
278106
278312
|
if (!cellAnchor)
|
|
@@ -278563,15 +278769,8 @@ function renderCellSelectionOverlay({ selection, layout, localSelectionLayer, bl
|
|
|
278563
278769
|
let tableBlock;
|
|
278564
278770
|
if (cellAnchorTableBlockId)
|
|
278565
278771
|
tableBlock = blocks2.find((block) => block.kind === "table" && block.id === cellAnchorTableBlockId);
|
|
278566
|
-
if (!tableBlock)
|
|
278567
|
-
|
|
278568
|
-
tableBlock = blocks2.find((block) => block.kind === "table" && block.id === expectedBlockId);
|
|
278569
|
-
}
|
|
278570
|
-
if (!tableBlock) {
|
|
278571
|
-
const tableBlocks = blocks2.filter((block) => block.kind === "table");
|
|
278572
|
-
if (tableBlocks.length === 1)
|
|
278573
|
-
tableBlock = tableBlocks[0];
|
|
278574
|
-
}
|
|
278772
|
+
if (!tableBlock)
|
|
278773
|
+
tableBlock = getTopLevelTableBlockAtPos($anchorCell.node(0), blocks2, tableStart) ?? undefined;
|
|
278575
278774
|
if (!tableBlock)
|
|
278576
278775
|
return;
|
|
278577
278776
|
const tableFragments = [];
|
|
@@ -317377,18 +317576,45 @@ menclose::after {
|
|
|
317377
317576
|
const layoutState = this.#deps?.getLayoutState();
|
|
317378
317577
|
return getTablePosFromHit(tableHit, editor?.state?.doc ?? null, layoutState?.blocks ?? []);
|
|
317379
317578
|
}
|
|
317579
|
+
#setCellAnchorState(cellAnchor, mode = "pending") {
|
|
317580
|
+
this.#cellAnchor = cellAnchor;
|
|
317581
|
+
this.#cellDragMode = mode;
|
|
317582
|
+
}
|
|
317380
317583
|
#setCellAnchor(tableHit, tablePos) {
|
|
317381
317584
|
const cellPos = this.#getCellPosFromTableHit(tableHit);
|
|
317382
317585
|
if (cellPos === null)
|
|
317383
317586
|
return;
|
|
317384
|
-
this.#
|
|
317587
|
+
this.#setCellAnchorState({
|
|
317385
317588
|
tablePos,
|
|
317386
317589
|
cellPos,
|
|
317387
317590
|
cellRowIndex: tableHit.cellRowIndex,
|
|
317388
317591
|
cellColIndex: tableHit.cellColIndex,
|
|
317389
317592
|
tableBlockId: tableHit.block.id
|
|
317390
|
-
};
|
|
317391
|
-
|
|
317593
|
+
}, "pending");
|
|
317594
|
+
}
|
|
317595
|
+
#setCellAnchorFromCellPos(cellPos, mode = "pending") {
|
|
317596
|
+
const editor = this.#deps?.getEditor();
|
|
317597
|
+
const layoutState = this.#deps?.getLayoutState();
|
|
317598
|
+
const cellAnchor = resolveCellAnchorStateFromCellPos(editor?.state?.doc ?? null, layoutState?.blocks ?? [], cellPos);
|
|
317599
|
+
if (!cellAnchor)
|
|
317600
|
+
return false;
|
|
317601
|
+
this.#setCellAnchorState(cellAnchor, mode);
|
|
317602
|
+
return true;
|
|
317603
|
+
}
|
|
317604
|
+
#dispatchExtendedTextSelection(editor, anchor, head) {
|
|
317605
|
+
const { selAnchor, selHead } = this.#calculateExtendedSelection(anchor, head, this.#dragExtensionMode);
|
|
317606
|
+
const stabilized = stabilizeTextSelectionAcrossTableCells(editor.state.doc, selAnchor, selHead);
|
|
317607
|
+
if (!stabilized)
|
|
317608
|
+
return false;
|
|
317609
|
+
try {
|
|
317610
|
+
const tr = editor.state.tr.setSelection(TextSelection.create(editor.state.doc, stabilized.selAnchor, stabilized.selHead));
|
|
317611
|
+
editor.view?.dispatch(tr);
|
|
317612
|
+
this.#callbacks.scheduleSelectionUpdate?.();
|
|
317613
|
+
return true;
|
|
317614
|
+
} catch (error48) {
|
|
317615
|
+
console.warn("[SELECTION] Failed to extend text selection:", error48);
|
|
317616
|
+
return false;
|
|
317617
|
+
}
|
|
317392
317618
|
}
|
|
317393
317619
|
#hitTestTable(x, y$1) {
|
|
317394
317620
|
return this.#callbacks.hitTestTable?.(x, y$1) ?? null;
|
|
@@ -317990,6 +318216,8 @@ menclose::after {
|
|
|
317990
318216
|
this.#pendingMarginClick = null;
|
|
317991
318217
|
const dragAnchor = this.#dragAnchor;
|
|
317992
318218
|
const dragMode = this.#dragExtensionMode;
|
|
318219
|
+
if ((!pendingMarginClick || pendingMarginClick.pointerId !== event.pointerId) && dragAnchor != null && this.#dragThresholdExceeded)
|
|
318220
|
+
this.#handleDragSelectionAt(event.clientX, event.clientY);
|
|
317993
318221
|
const dragUsedFallback = this.#dragUsedPageNotMountedFallback;
|
|
317994
318222
|
const dragPointer = this.#dragLastPointer;
|
|
317995
318223
|
this.#isDragging = false;
|
|
@@ -318472,14 +318700,7 @@ menclose::after {
|
|
|
318472
318700
|
if (!editor)
|
|
318473
318701
|
return;
|
|
318474
318702
|
const anchor = editor.state.selection.anchor;
|
|
318475
|
-
|
|
318476
|
-
try {
|
|
318477
|
-
const tr = editor.state.tr.setSelection(TextSelection.create(editor.state.doc, selAnchor, selHead));
|
|
318478
|
-
editor.view?.dispatch(tr);
|
|
318479
|
-
this.#callbacks.scheduleSelectionUpdate?.();
|
|
318480
|
-
} catch (error48) {
|
|
318481
|
-
console.warn("[SELECTION] Failed to extend selection on shift+click:", error48);
|
|
318482
|
-
}
|
|
318703
|
+
this.#dispatchExtendedTextSelection(editor, anchor, headPos);
|
|
318483
318704
|
this.#focusEditor();
|
|
318484
318705
|
}
|
|
318485
318706
|
#handleDragSelectionAt(clientX, clientY) {
|
|
@@ -318540,17 +318761,28 @@ menclose::after {
|
|
|
318540
318761
|
}
|
|
318541
318762
|
const anchor = this.#dragAnchor;
|
|
318542
318763
|
const head = hit.pos;
|
|
318543
|
-
|
|
318544
|
-
|
|
318545
|
-
|
|
318546
|
-
|
|
318547
|
-
|
|
318548
|
-
|
|
318549
|
-
|
|
318764
|
+
if (!useActiveSurfaceHitTest) {
|
|
318765
|
+
const crossCell = resolveCrossCellSelection(editor.state.doc, anchor, head);
|
|
318766
|
+
if (crossCell)
|
|
318767
|
+
try {
|
|
318768
|
+
const tr = editor.state.tr.setSelection(CellSelection.create(editor.state.doc, crossCell.anchorCellPos, crossCell.headCellPos));
|
|
318769
|
+
editor.view?.dispatch(tr);
|
|
318770
|
+
if (!this.#setCellAnchorFromCellPos(crossCell.anchorCellPos, "active"))
|
|
318771
|
+
console.warn("[CELL-SELECTION] Failed to cache anchor state for cross-cell drag selection.");
|
|
318772
|
+
this.#callbacks.scheduleSelectionUpdate?.();
|
|
318773
|
+
return;
|
|
318774
|
+
} catch (error48) {
|
|
318775
|
+
console.warn("[SELECTION] Failed to create cross-cell CellSelection during drag:", error48);
|
|
318776
|
+
}
|
|
318550
318777
|
}
|
|
318778
|
+
this.#dispatchExtendedTextSelection(editor, anchor, head);
|
|
318551
318779
|
}
|
|
318552
318780
|
#handleCellDragSelection(currentTableHit, hit) {
|
|
318553
|
-
|
|
318781
|
+
if (!this.#cellAnchor)
|
|
318782
|
+
return;
|
|
318783
|
+
if (!currentTableHit || currentTableHit.block.id !== this.#cellAnchor.tableBlockId)
|
|
318784
|
+
return;
|
|
318785
|
+
const headCellPos = this.#getCellPosFromTableHit(currentTableHit);
|
|
318554
318786
|
if (headCellPos === null)
|
|
318555
318787
|
return;
|
|
318556
318788
|
if (this.#cellDragMode !== "active")
|
|
@@ -318570,13 +318802,7 @@ menclose::after {
|
|
|
318570
318802
|
} catch (error48) {
|
|
318571
318803
|
console.warn("[CELL-SELECTION] Failed to create CellSelection, falling back to TextSelection:", error48);
|
|
318572
318804
|
const anchor = this.#dragAnchor;
|
|
318573
|
-
|
|
318574
|
-
const { selAnchor, selHead } = this.#calculateExtendedSelection(anchor, head, this.#dragExtensionMode);
|
|
318575
|
-
try {
|
|
318576
|
-
const tr = editor.state.tr.setSelection(TextSelection.create(editor.state.doc, selAnchor, selHead));
|
|
318577
|
-
editor.view?.dispatch(tr);
|
|
318578
|
-
this.#callbacks.scheduleSelectionUpdate?.();
|
|
318579
|
-
} catch {}
|
|
318805
|
+
this.#dispatchExtendedTextSelection(editor, anchor, hit.pos);
|
|
318580
318806
|
}
|
|
318581
318807
|
}
|
|
318582
318808
|
#handleHover(normalized) {
|
|
@@ -322461,7 +322687,7 @@ menclose::after {
|
|
|
322461
322687
|
return;
|
|
322462
322688
|
console.log(...args$1);
|
|
322463
322689
|
}, 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;
|
|
322464
|
-
var
|
|
322690
|
+
var init_src_BB0n1coY_es = __esm(() => {
|
|
322465
322691
|
init_rolldown_runtime_Bg48TavK_es();
|
|
322466
322692
|
init_SuperConverter_CCgGAnXY_es();
|
|
322467
322693
|
init_jszip_C49i9kUs_es();
|
|
@@ -356876,14 +357102,17 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
356876
357102
|
return;
|
|
356877
357103
|
}
|
|
356878
357104
|
const head = Math.max(0, Math.min(mappedHead.pos, doc$12.content.size));
|
|
356879
|
-
const
|
|
357105
|
+
const extended = this.#calculateExtendedSelection(anchor, head, mode);
|
|
357106
|
+
const stabilized = stabilizeTextSelectionAcrossTableCells(doc$12, extended.selAnchor, extended.selHead);
|
|
357107
|
+
if (!stabilized)
|
|
357108
|
+
return;
|
|
356880
357109
|
const current = this.#editor.state.selection;
|
|
356881
|
-
const desiredFrom = Math.min(selAnchor, selHead);
|
|
356882
|
-
const desiredTo = Math.max(selAnchor, selHead);
|
|
357110
|
+
const desiredFrom = Math.min(stabilized.selAnchor, stabilized.selHead);
|
|
357111
|
+
const desiredTo = Math.max(stabilized.selAnchor, stabilized.selHead);
|
|
356883
357112
|
if (current.from === desiredFrom && current.to === desiredTo)
|
|
356884
357113
|
return;
|
|
356885
357114
|
try {
|
|
356886
|
-
const tr = this.#editor.state.tr.setSelection(TextSelection.create(this.#editor.state.doc, selAnchor, selHead));
|
|
357115
|
+
const tr = this.#editor.state.tr.setSelection(TextSelection.create(this.#editor.state.doc, stabilized.selAnchor, stabilized.selHead));
|
|
356887
357116
|
this.#editor.view?.dispatch(tr);
|
|
356888
357117
|
this.#scheduleSelectionUpdate();
|
|
356889
357118
|
} catch {}
|
|
@@ -358544,7 +358773,7 @@ var init_zipper_yaJVJ4z9_es = __esm(() => {
|
|
|
358544
358773
|
|
|
358545
358774
|
// ../../packages/superdoc/dist/super-editor.es.js
|
|
358546
358775
|
var init_super_editor_es = __esm(() => {
|
|
358547
|
-
|
|
358776
|
+
init_src_BB0n1coY_es();
|
|
358548
358777
|
init_SuperConverter_CCgGAnXY_es();
|
|
358549
358778
|
init_jszip_C49i9kUs_es();
|
|
358550
358779
|
init_xml_js_CqGKpaft_es();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdoc-dev/mcp",
|
|
3
|
-
"version": "0.12.0-next.
|
|
3
|
+
"version": "0.12.0-next.25",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=20"
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"@types/node": "22.19.2",
|
|
21
21
|
"typescript": "^5.9.2",
|
|
22
22
|
"@superdoc/document-api": "0.0.1",
|
|
23
|
-
"superdoc": "
|
|
24
|
-
"
|
|
23
|
+
"@superdoc/super-editor": "0.0.1",
|
|
24
|
+
"superdoc": "1.39.0"
|
|
25
25
|
},
|
|
26
26
|
"publishConfig": {
|
|
27
27
|
"access": "public"
|