@superdoc-dev/mcp 0.12.0-next.24 → 0.12.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.
- package/dist/index.js +347 -92
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -52172,7 +52172,7 @@ var init_remark_gfm_BhnWr3yf_es = __esm(() => {
|
|
|
52172
52172
|
emptyOptions2 = {};
|
|
52173
52173
|
});
|
|
52174
52174
|
|
|
52175
|
-
// ../../packages/superdoc/dist/chunks/SuperConverter-
|
|
52175
|
+
// ../../packages/superdoc/dist/chunks/SuperConverter-WQVqM0th.es.js
|
|
52176
52176
|
function getExtensionConfigField(extension$1, field, context = { name: "" }) {
|
|
52177
52177
|
const fieldValue = extension$1.config[field];
|
|
52178
52178
|
if (typeof fieldValue === "function")
|
|
@@ -72379,6 +72379,22 @@ function fixTable(state, table, tablePos, tr) {
|
|
|
72379
72379
|
}
|
|
72380
72380
|
return tr.setMeta(fixTablesKey, { fixTables: true });
|
|
72381
72381
|
}
|
|
72382
|
+
function findTable($pos) {
|
|
72383
|
+
return findParentNode$1((node2) => node2.type.spec.tableRole === "table", $pos);
|
|
72384
|
+
}
|
|
72385
|
+
function findParentNode$1(predicate, $pos) {
|
|
72386
|
+
for (let depth = $pos.depth;depth >= 0; depth -= 1) {
|
|
72387
|
+
const node2 = $pos.node(depth);
|
|
72388
|
+
if (predicate(node2))
|
|
72389
|
+
return {
|
|
72390
|
+
node: node2,
|
|
72391
|
+
pos: depth === 0 ? 0 : $pos.before(depth),
|
|
72392
|
+
start: $pos.start(depth),
|
|
72393
|
+
depth
|
|
72394
|
+
};
|
|
72395
|
+
}
|
|
72396
|
+
return null;
|
|
72397
|
+
}
|
|
72382
72398
|
function selectedRect(state) {
|
|
72383
72399
|
const sel = state.selection;
|
|
72384
72400
|
const $pos = selectionCell(state);
|
|
@@ -118758,7 +118774,7 @@ var isRegExp = (value) => {
|
|
|
118758
118774
|
state.kern = kernNode.attributes["w:val"];
|
|
118759
118775
|
}
|
|
118760
118776
|
}, SuperConverter;
|
|
118761
|
-
var
|
|
118777
|
+
var init_SuperConverter_WQVqM0th_es = __esm(() => {
|
|
118762
118778
|
init_rolldown_runtime_Bg48TavK_es();
|
|
118763
118779
|
init_jszip_C49i9kUs_es();
|
|
118764
118780
|
init_xml_js_CqGKpaft_es();
|
|
@@ -159502,7 +159518,7 @@ var init_SuperConverter_CCgGAnXY_es = __esm(() => {
|
|
|
159502
159518
|
};
|
|
159503
159519
|
});
|
|
159504
159520
|
|
|
159505
|
-
// ../../packages/superdoc/dist/chunks/create-headless-toolbar-
|
|
159521
|
+
// ../../packages/superdoc/dist/chunks/create-headless-toolbar-B8OXKxcw.es.js
|
|
159506
159522
|
function parseSizeUnit(val = "0") {
|
|
159507
159523
|
const length = val.toString() || "0";
|
|
159508
159524
|
const value = Number.parseFloat(length);
|
|
@@ -169897,8 +169913,8 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, normalizeActorId = (value) => {
|
|
|
169897
169913
|
}
|
|
169898
169914
|
};
|
|
169899
169915
|
};
|
|
169900
|
-
var
|
|
169901
|
-
|
|
169916
|
+
var init_create_headless_toolbar_B8OXKxcw_es = __esm(() => {
|
|
169917
|
+
init_SuperConverter_WQVqM0th_es();
|
|
169902
169918
|
init_uuid_B2wVPhPi_es();
|
|
169903
169919
|
init_constants_D9qj59G2_es();
|
|
169904
169920
|
init_dist_B8HfvhaK_es();
|
|
@@ -224588,7 +224604,7 @@ var init_remark_gfm_eZN6yzWQ_es = __esm(() => {
|
|
|
224588
224604
|
init_remark_gfm_BhnWr3yf_es();
|
|
224589
224605
|
});
|
|
224590
224606
|
|
|
224591
|
-
// ../../packages/superdoc/dist/chunks/src-
|
|
224607
|
+
// ../../packages/superdoc/dist/chunks/src-Bvhjxf8i.es.js
|
|
224592
224608
|
function deleteProps(obj, propOrProps) {
|
|
224593
224609
|
const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
|
|
224594
224610
|
const removeNested = (target, pathParts, index2 = 0) => {
|
|
@@ -275541,10 +275557,10 @@ function clickToPositionGeometry(layout, blocks2, measures, containerPoint, opti
|
|
|
275541
275557
|
lineIndex
|
|
275542
275558
|
};
|
|
275543
275559
|
}
|
|
275544
|
-
const
|
|
275545
|
-
if (
|
|
275560
|
+
const fallbackPos = cellBlock.runs?.[0]?.pmStart ?? blockPmRangeFromAttrs(cellBlock).pmStart;
|
|
275561
|
+
if (fallbackPos != null)
|
|
275546
275562
|
return {
|
|
275547
|
-
pos:
|
|
275563
|
+
pos: fallbackPos,
|
|
275548
275564
|
layoutEpoch,
|
|
275549
275565
|
blockId: tableHit.fragment.blockId,
|
|
275550
275566
|
pageIndex,
|
|
@@ -275605,6 +275621,16 @@ function percentile(sortedValues, p$12) {
|
|
|
275605
275621
|
const weight = index2 - lower;
|
|
275606
275622
|
return sortedValues[lower] * (1 - weight) + sortedValues[upper] * weight;
|
|
275607
275623
|
}
|
|
275624
|
+
function pushEmptyLineSelectionBand(rects, opts) {
|
|
275625
|
+
const lineOffset = sumLineHeights(opts.measure, opts.startLineIndex, opts.lineIndex);
|
|
275626
|
+
rects.push({
|
|
275627
|
+
x: opts.x,
|
|
275628
|
+
y: opts.yBase + lineOffset,
|
|
275629
|
+
width: Math.max(1, opts.width),
|
|
275630
|
+
height: opts.lineHeight,
|
|
275631
|
+
pageIndex: opts.pageIndex
|
|
275632
|
+
});
|
|
275633
|
+
}
|
|
275608
275634
|
function selectionToRects(layout, blocks2, measures, from$1, to, geometryHelper) {
|
|
275609
275635
|
if (from$1 === to)
|
|
275610
275636
|
return [];
|
|
@@ -275631,8 +275657,19 @@ function selectionToRects(layout, blocks2, measures, from$1, to, geometryHelper)
|
|
|
275631
275657
|
return;
|
|
275632
275658
|
const sliceFrom = Math.max(range.pmStart, from$1);
|
|
275633
275659
|
const sliceTo = Math.min(range.pmEnd, to);
|
|
275634
|
-
if (sliceFrom >= sliceTo)
|
|
275660
|
+
if (sliceFrom >= sliceTo) {
|
|
275661
|
+
pushEmptyLineSelectionBand(rects, {
|
|
275662
|
+
x: fragment.x,
|
|
275663
|
+
yBase: fragment.y + pageTopY,
|
|
275664
|
+
width: fragment.width,
|
|
275665
|
+
lineHeight: line.lineHeight,
|
|
275666
|
+
pageIndex,
|
|
275667
|
+
measure,
|
|
275668
|
+
lineIndex: index2,
|
|
275669
|
+
startLineIndex: fragment.fromLine
|
|
275670
|
+
});
|
|
275635
275671
|
return;
|
|
275672
|
+
}
|
|
275636
275673
|
pmPosToCharOffset(block, line, sliceFrom);
|
|
275637
275674
|
pmPosToCharOffset(block, line, sliceTo);
|
|
275638
275675
|
const visualCharOffsetFrom = pmPosToVisualCharOffset(block, line, sliceFrom);
|
|
@@ -275810,8 +275847,19 @@ function selectionToRects(layout, blocks2, measures, from$1, to, geometryHelper)
|
|
|
275810
275847
|
return;
|
|
275811
275848
|
const sliceFrom = Math.max(range.pmStart, from$1);
|
|
275812
275849
|
const sliceTo = Math.min(range.pmEnd, to);
|
|
275813
|
-
if (sliceFrom >= sliceTo)
|
|
275850
|
+
if (sliceFrom >= sliceTo) {
|
|
275851
|
+
pushEmptyLineSelectionBand(rects, {
|
|
275852
|
+
x: fragment.x + contentOffsetX + cellX + padding.left,
|
|
275853
|
+
yBase: fragment.y + contentOffsetY + rowOffset + blockTopCursor + effectiveSpacingBeforePx + pageTopY,
|
|
275854
|
+
width: cellMeasure.width - padding.left - padding.right,
|
|
275855
|
+
lineHeight: line.lineHeight,
|
|
275856
|
+
pageIndex,
|
|
275857
|
+
measure: info.measure,
|
|
275858
|
+
lineIndex: index2,
|
|
275859
|
+
startLineIndex: info.startLine
|
|
275860
|
+
});
|
|
275814
275861
|
return;
|
|
275862
|
+
}
|
|
275815
275863
|
pmPosToCharOffset(info.block, line, sliceFrom);
|
|
275816
275864
|
pmPosToCharOffset(info.block, line, sliceTo);
|
|
275817
275865
|
const visualCharOffsetFrom = pmPosToVisualCharOffset(info.block, line, sliceFrom);
|
|
@@ -276140,6 +276188,49 @@ function calculateExtendedSelection(blocks2, anchor, head, mode) {
|
|
|
276140
276188
|
selHead: head
|
|
276141
276189
|
};
|
|
276142
276190
|
}
|
|
276191
|
+
function selectionCollapsesAcrossTableCells(doc$12, anchor, head) {
|
|
276192
|
+
if (anchor === head)
|
|
276193
|
+
return false;
|
|
276194
|
+
try {
|
|
276195
|
+
const size$1 = doc$12.content.size;
|
|
276196
|
+
if (anchor < 0 || head < 0 || anchor > size$1 || head > size$1)
|
|
276197
|
+
return false;
|
|
276198
|
+
const $from = doc$12.resolve(Math.min(anchor, head));
|
|
276199
|
+
const $to = doc$12.resolve(Math.max(anchor, head));
|
|
276200
|
+
return cellWrapping2($from) !== cellWrapping2($to) && $to.parentOffset === 0;
|
|
276201
|
+
} catch {
|
|
276202
|
+
return false;
|
|
276203
|
+
}
|
|
276204
|
+
}
|
|
276205
|
+
function stabilizeTextSelectionAcrossTableCells(doc$12, anchor, head) {
|
|
276206
|
+
if (!selectionCollapsesAcrossTableCells(doc$12, anchor, head))
|
|
276207
|
+
return {
|
|
276208
|
+
selAnchor: anchor,
|
|
276209
|
+
selHead: head
|
|
276210
|
+
};
|
|
276211
|
+
try {
|
|
276212
|
+
const anchorIsUpper = anchor > head;
|
|
276213
|
+
const upperPos = anchorIsUpper ? anchor : head;
|
|
276214
|
+
if (upperPos < 0 || upperPos >= doc$12.content.size)
|
|
276215
|
+
return null;
|
|
276216
|
+
const $upper = doc$12.resolve(upperPos);
|
|
276217
|
+
if (!$upper.parent.inlineContent || $upper.parent.content.size !== 0)
|
|
276218
|
+
return null;
|
|
276219
|
+
const stabilizedUpperPos = upperPos + 1;
|
|
276220
|
+
if (stabilizedUpperPos > doc$12.content.size)
|
|
276221
|
+
return null;
|
|
276222
|
+
const selAnchor = anchorIsUpper ? stabilizedUpperPos : anchor;
|
|
276223
|
+
const selHead = anchorIsUpper ? head : stabilizedUpperPos;
|
|
276224
|
+
if (selectionCollapsesAcrossTableCells(doc$12, selAnchor, selHead))
|
|
276225
|
+
return null;
|
|
276226
|
+
return {
|
|
276227
|
+
selAnchor,
|
|
276228
|
+
selHead
|
|
276229
|
+
};
|
|
276230
|
+
} catch {
|
|
276231
|
+
return null;
|
|
276232
|
+
}
|
|
276233
|
+
}
|
|
276143
276234
|
function registerPointerClick(event, previous3, options) {
|
|
276144
276235
|
const time3 = event.timeStamp ?? performance.now();
|
|
276145
276236
|
const withinTime = time3 - previous3.lastClickTime <= options.timeThresholdMs;
|
|
@@ -276555,14 +276646,16 @@ function computeSelectionRectsFromDom(options, from$1, to) {
|
|
|
276555
276646
|
missingEntries.push(entry);
|
|
276556
276647
|
}
|
|
276557
276648
|
} catch {}
|
|
276558
|
-
|
|
276649
|
+
const spansMultipleLines = countDistinctLines(pageEntries) > 1;
|
|
276650
|
+
if (spansMultipleLines || missingEntries && missingEntries.length > 0) {
|
|
276559
276651
|
if (isVerbose)
|
|
276560
|
-
debugLog("verbose", `DOM selection rects:
|
|
276652
|
+
debugLog("verbose", `DOM selection rects: switching to per-line rects ${JSON.stringify({
|
|
276561
276653
|
pageIndex,
|
|
276562
276654
|
sliceFrom,
|
|
276563
276655
|
sliceTo,
|
|
276564
|
-
|
|
276565
|
-
|
|
276656
|
+
spansMultipleLines,
|
|
276657
|
+
missingCount: missingEntries?.length ?? 0,
|
|
276658
|
+
missingPreview: (missingEntries ?? []).slice(0, 20).map(entryDebugInfo)
|
|
276566
276659
|
})}`);
|
|
276567
276660
|
rawRects = collectClientRectsByLine(doc$12, pageEntries, sliceFrom, sliceTo);
|
|
276568
276661
|
if (dumpRects)
|
|
@@ -276632,10 +276725,17 @@ function collectClientRectsByLine(doc$12, entries, sliceFrom, sliceTo) {
|
|
|
276632
276725
|
else
|
|
276633
276726
|
lineMap.set(lineEl, [entry]);
|
|
276634
276727
|
}
|
|
276635
|
-
for (const [, lineEntries] of lineMap) {
|
|
276728
|
+
for (const [lineEl, lineEntries] of lineMap) {
|
|
276636
276729
|
lineEntries.sort((a2, b$1) => a2.pmStart - b$1.pmStart !== 0 ? a2.pmStart - b$1.pmStart : a2.pmEnd - b$1.pmEnd);
|
|
276637
276730
|
const linePmStart = lineEntries[0]?.pmStart ?? Infinity;
|
|
276638
276731
|
const linePmEnd = lineEntries[lineEntries.length - 1]?.pmEnd ?? -Infinity;
|
|
276732
|
+
if (sliceFrom < linePmStart && linePmEnd < sliceTo && lineEl.isConnected) {
|
|
276733
|
+
const boxRect = lineEl.getBoundingClientRect();
|
|
276734
|
+
if (boxRect.width > 0 && boxRect.height > 0) {
|
|
276735
|
+
rects.push(boxRect);
|
|
276736
|
+
continue;
|
|
276737
|
+
}
|
|
276738
|
+
}
|
|
276639
276739
|
if (!Number.isFinite(linePmStart) || !Number.isFinite(linePmEnd) || linePmEnd <= linePmStart)
|
|
276640
276740
|
continue;
|
|
276641
276741
|
const lineFrom = Math.max(sliceFrom, linePmStart);
|
|
@@ -276673,6 +276773,18 @@ function collectClientRectsByLine(doc$12, entries, sliceFrom, sliceTo) {
|
|
|
276673
276773
|
}
|
|
276674
276774
|
return rects;
|
|
276675
276775
|
}
|
|
276776
|
+
function countDistinctLines(entries) {
|
|
276777
|
+
const lines = /* @__PURE__ */ new Set;
|
|
276778
|
+
let hasLoose = false;
|
|
276779
|
+
for (const entry of entries) {
|
|
276780
|
+
const lineEl = entry.el.closest(".superdoc-line");
|
|
276781
|
+
if (lineEl)
|
|
276782
|
+
lines.add(lineEl);
|
|
276783
|
+
else
|
|
276784
|
+
hasLoose = true;
|
|
276785
|
+
}
|
|
276786
|
+
return lines.size + (hasLoose ? 1 : 0);
|
|
276787
|
+
}
|
|
276676
276788
|
function setDomRangeStart(range, entry, pos) {
|
|
276677
276789
|
const el = entry.el;
|
|
276678
276790
|
const pmStart = entry.pmStart;
|
|
@@ -278008,6 +278120,107 @@ function resolvePointerPositionHit(options) {
|
|
|
278008
278120
|
}
|
|
278009
278121
|
return clickToPositionGeometry(layout, blocks2, measures, containerPoint, { geometryHelper });
|
|
278010
278122
|
}
|
|
278123
|
+
function getTableBlocks(blocks2) {
|
|
278124
|
+
return blocks2.filter((block) => block.kind === "table");
|
|
278125
|
+
}
|
|
278126
|
+
function getTopLevelTablePosByIndex(doc$12, targetTableIndex) {
|
|
278127
|
+
if (!Number.isInteger(targetTableIndex) || targetTableIndex < 0)
|
|
278128
|
+
return null;
|
|
278129
|
+
let tablePos = null;
|
|
278130
|
+
let currentTableIndex = 0;
|
|
278131
|
+
doc$12.descendants((node2, pos) => {
|
|
278132
|
+
if (tablePos !== null)
|
|
278133
|
+
return false;
|
|
278134
|
+
if (node2.type.name !== "table")
|
|
278135
|
+
return true;
|
|
278136
|
+
if (currentTableIndex === targetTableIndex)
|
|
278137
|
+
tablePos = pos;
|
|
278138
|
+
currentTableIndex += 1;
|
|
278139
|
+
return false;
|
|
278140
|
+
});
|
|
278141
|
+
return tablePos;
|
|
278142
|
+
}
|
|
278143
|
+
function getTopLevelTableIndexAtPos(doc$12, targetTablePos) {
|
|
278144
|
+
if (!Number.isFinite(targetTablePos) || targetTablePos < 0 || targetTablePos > doc$12.content.size)
|
|
278145
|
+
return null;
|
|
278146
|
+
let tableIndex = null;
|
|
278147
|
+
let currentTableIndex = 0;
|
|
278148
|
+
doc$12.descendants((node2, pos) => {
|
|
278149
|
+
if (tableIndex !== null)
|
|
278150
|
+
return false;
|
|
278151
|
+
if (node2.type.name !== "table")
|
|
278152
|
+
return true;
|
|
278153
|
+
if (pos === targetTablePos)
|
|
278154
|
+
tableIndex = currentTableIndex;
|
|
278155
|
+
currentTableIndex += 1;
|
|
278156
|
+
return false;
|
|
278157
|
+
});
|
|
278158
|
+
return tableIndex;
|
|
278159
|
+
}
|
|
278160
|
+
function getCellCoordinatesFromCellPos(doc$12, tablePos, cellPos) {
|
|
278161
|
+
const tableNode = doc$12.nodeAt(tablePos);
|
|
278162
|
+
if (!tableNode || tableNode.type.name !== "table")
|
|
278163
|
+
return null;
|
|
278164
|
+
let rowPos = tablePos + 1;
|
|
278165
|
+
for (let rowIndex = 0;rowIndex < tableNode.childCount; rowIndex += 1) {
|
|
278166
|
+
const rowNode = tableNode.child(rowIndex);
|
|
278167
|
+
let currentCellPos = rowPos + 1;
|
|
278168
|
+
for (let cellColIndex = 0;cellColIndex < rowNode.childCount; cellColIndex += 1) {
|
|
278169
|
+
if (currentCellPos === cellPos)
|
|
278170
|
+
return {
|
|
278171
|
+
rowIndex,
|
|
278172
|
+
cellColIndex
|
|
278173
|
+
};
|
|
278174
|
+
currentCellPos += rowNode.child(cellColIndex).nodeSize;
|
|
278175
|
+
}
|
|
278176
|
+
rowPos += rowNode.nodeSize;
|
|
278177
|
+
}
|
|
278178
|
+
return null;
|
|
278179
|
+
}
|
|
278180
|
+
function getTopLevelTableBlockAtPos(doc$12, blocks2, tablePos) {
|
|
278181
|
+
if (!doc$12)
|
|
278182
|
+
return null;
|
|
278183
|
+
const tableIndex = getTopLevelTableIndexAtPos(doc$12, tablePos);
|
|
278184
|
+
if (tableIndex === null)
|
|
278185
|
+
return null;
|
|
278186
|
+
return getTableBlocks(blocks2)[tableIndex] ?? null;
|
|
278187
|
+
}
|
|
278188
|
+
function resolveCellContextAtResolvedPos($pos) {
|
|
278189
|
+
const $cell = cellAround($pos);
|
|
278190
|
+
if (!$cell)
|
|
278191
|
+
return null;
|
|
278192
|
+
const table2 = findTable($cell);
|
|
278193
|
+
if (!table2)
|
|
278194
|
+
return null;
|
|
278195
|
+
return {
|
|
278196
|
+
$cell,
|
|
278197
|
+
cellPos: $cell.pos,
|
|
278198
|
+
tablePos: table2.pos
|
|
278199
|
+
};
|
|
278200
|
+
}
|
|
278201
|
+
function resolveCellAnchorStateFromCellPos(doc$12, blocks2, cellPos) {
|
|
278202
|
+
if (!doc$12 || !Number.isFinite(cellPos) || cellPos < 0 || cellPos > doc$12.content.size)
|
|
278203
|
+
return null;
|
|
278204
|
+
const tableRole = doc$12.nodeAt(cellPos)?.type.spec.tableRole;
|
|
278205
|
+
if (tableRole !== "cell" && tableRole !== "header_cell")
|
|
278206
|
+
return null;
|
|
278207
|
+
const context = resolveCellContext(doc$12, Math.min(cellPos + 1, doc$12.content.size));
|
|
278208
|
+
if (!context || context.cellPos !== cellPos)
|
|
278209
|
+
return null;
|
|
278210
|
+
const tableBlock = getTopLevelTableBlockAtPos(doc$12, blocks2, context.tablePos);
|
|
278211
|
+
if (!tableBlock)
|
|
278212
|
+
return null;
|
|
278213
|
+
const cellCoordinates = getCellCoordinatesFromCellPos(doc$12, context.tablePos, cellPos);
|
|
278214
|
+
if (!cellCoordinates)
|
|
278215
|
+
return null;
|
|
278216
|
+
return {
|
|
278217
|
+
tablePos: context.tablePos,
|
|
278218
|
+
cellPos,
|
|
278219
|
+
tableBlockId: tableBlock.id,
|
|
278220
|
+
cellRowIndex: cellCoordinates.rowIndex,
|
|
278221
|
+
cellColIndex: cellCoordinates.cellColIndex
|
|
278222
|
+
};
|
|
278223
|
+
}
|
|
278011
278224
|
function getCellPosFromTableHit(tableHit, doc$12, blocks2) {
|
|
278012
278225
|
if (!tableHit || !tableHit.block || typeof tableHit.block.id !== "string") {
|
|
278013
278226
|
console.warn("[getCellPosFromTableHit] Invalid tableHit input:", tableHit);
|
|
@@ -278022,22 +278235,12 @@ function getCellPosFromTableHit(tableHit, doc$12, blocks2) {
|
|
|
278022
278235
|
}
|
|
278023
278236
|
if (!doc$12)
|
|
278024
278237
|
return null;
|
|
278025
|
-
const targetTableIndex = blocks2
|
|
278238
|
+
const targetTableIndex = getTableBlocks(blocks2).findIndex((b$1) => b$1.id === tableHit.block.id);
|
|
278026
278239
|
if (targetTableIndex === -1)
|
|
278027
278240
|
return null;
|
|
278028
278241
|
let tablePos = null;
|
|
278029
|
-
let currentTableIndex = 0;
|
|
278030
278242
|
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
|
-
});
|
|
278243
|
+
tablePos = getTopLevelTablePosByIndex(doc$12, targetTableIndex);
|
|
278041
278244
|
} catch (error48) {
|
|
278042
278245
|
console.error("[getCellPosFromTableHit] Error during document traversal:", error48);
|
|
278043
278246
|
return null;
|
|
@@ -278085,22 +278288,51 @@ function getCellPosFromTableHit(tableHit, doc$12, blocks2) {
|
|
|
278085
278288
|
function getTablePosFromHit(tableHit, doc$12, blocks2) {
|
|
278086
278289
|
if (!doc$12)
|
|
278087
278290
|
return null;
|
|
278088
|
-
const targetTableIndex = blocks2
|
|
278291
|
+
const targetTableIndex = getTableBlocks(blocks2).findIndex((b$1) => b$1.id === tableHit.block.id);
|
|
278089
278292
|
if (targetTableIndex === -1)
|
|
278090
278293
|
return null;
|
|
278091
|
-
|
|
278092
|
-
|
|
278093
|
-
|
|
278094
|
-
|
|
278095
|
-
|
|
278096
|
-
|
|
278097
|
-
|
|
278098
|
-
|
|
278099
|
-
|
|
278100
|
-
|
|
278101
|
-
|
|
278102
|
-
|
|
278103
|
-
|
|
278294
|
+
return getTopLevelTablePosByIndex(doc$12, targetTableIndex);
|
|
278295
|
+
}
|
|
278296
|
+
function resolveCellContext(doc$12, pos) {
|
|
278297
|
+
if (!doc$12 || !Number.isFinite(pos) || pos < 0 || pos > doc$12.content.size)
|
|
278298
|
+
return null;
|
|
278299
|
+
let $pos;
|
|
278300
|
+
try {
|
|
278301
|
+
$pos = doc$12.resolve(pos);
|
|
278302
|
+
} catch {
|
|
278303
|
+
return null;
|
|
278304
|
+
}
|
|
278305
|
+
const context = resolveCellContextAtResolvedPos($pos);
|
|
278306
|
+
if (!context)
|
|
278307
|
+
return null;
|
|
278308
|
+
return {
|
|
278309
|
+
cellPos: context.cellPos,
|
|
278310
|
+
tablePos: context.tablePos
|
|
278311
|
+
};
|
|
278312
|
+
}
|
|
278313
|
+
function resolveCrossCellSelection(doc$12, anchorPos, headPos) {
|
|
278314
|
+
if (!doc$12)
|
|
278315
|
+
return null;
|
|
278316
|
+
let $anchorPos;
|
|
278317
|
+
let $headPos;
|
|
278318
|
+
try {
|
|
278319
|
+
$anchorPos = doc$12.resolve(anchorPos);
|
|
278320
|
+
$headPos = doc$12.resolve(headPos);
|
|
278321
|
+
} catch {
|
|
278322
|
+
return null;
|
|
278323
|
+
}
|
|
278324
|
+
const anchor = resolveCellContextAtResolvedPos($anchorPos);
|
|
278325
|
+
const head = resolveCellContextAtResolvedPos($headPos);
|
|
278326
|
+
if (!anchor || !head)
|
|
278327
|
+
return null;
|
|
278328
|
+
if (!inSameTable(anchor.$cell, head.$cell))
|
|
278329
|
+
return null;
|
|
278330
|
+
if (anchor.cellPos === head.cellPos)
|
|
278331
|
+
return null;
|
|
278332
|
+
return {
|
|
278333
|
+
anchorCellPos: anchor.cellPos,
|
|
278334
|
+
headCellPos: head.cellPos
|
|
278335
|
+
};
|
|
278104
278336
|
}
|
|
278105
278337
|
function shouldUseCellSelection(currentTableHit, cellAnchor, cellDragMode) {
|
|
278106
278338
|
if (!cellAnchor)
|
|
@@ -278563,15 +278795,8 @@ function renderCellSelectionOverlay({ selection, layout, localSelectionLayer, bl
|
|
|
278563
278795
|
let tableBlock;
|
|
278564
278796
|
if (cellAnchorTableBlockId)
|
|
278565
278797
|
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
|
-
}
|
|
278798
|
+
if (!tableBlock)
|
|
278799
|
+
tableBlock = getTopLevelTableBlockAtPos($anchorCell.node(0), blocks2, tableStart) ?? undefined;
|
|
278575
278800
|
if (!tableBlock)
|
|
278576
278801
|
return;
|
|
278577
278802
|
const tableFragments = [];
|
|
@@ -317377,18 +317602,45 @@ menclose::after {
|
|
|
317377
317602
|
const layoutState = this.#deps?.getLayoutState();
|
|
317378
317603
|
return getTablePosFromHit(tableHit, editor?.state?.doc ?? null, layoutState?.blocks ?? []);
|
|
317379
317604
|
}
|
|
317605
|
+
#setCellAnchorState(cellAnchor, mode = "pending") {
|
|
317606
|
+
this.#cellAnchor = cellAnchor;
|
|
317607
|
+
this.#cellDragMode = mode;
|
|
317608
|
+
}
|
|
317380
317609
|
#setCellAnchor(tableHit, tablePos) {
|
|
317381
317610
|
const cellPos = this.#getCellPosFromTableHit(tableHit);
|
|
317382
317611
|
if (cellPos === null)
|
|
317383
317612
|
return;
|
|
317384
|
-
this.#
|
|
317613
|
+
this.#setCellAnchorState({
|
|
317385
317614
|
tablePos,
|
|
317386
317615
|
cellPos,
|
|
317387
317616
|
cellRowIndex: tableHit.cellRowIndex,
|
|
317388
317617
|
cellColIndex: tableHit.cellColIndex,
|
|
317389
317618
|
tableBlockId: tableHit.block.id
|
|
317390
|
-
};
|
|
317391
|
-
|
|
317619
|
+
}, "pending");
|
|
317620
|
+
}
|
|
317621
|
+
#setCellAnchorFromCellPos(cellPos, mode = "pending") {
|
|
317622
|
+
const editor = this.#deps?.getEditor();
|
|
317623
|
+
const layoutState = this.#deps?.getLayoutState();
|
|
317624
|
+
const cellAnchor = resolveCellAnchorStateFromCellPos(editor?.state?.doc ?? null, layoutState?.blocks ?? [], cellPos);
|
|
317625
|
+
if (!cellAnchor)
|
|
317626
|
+
return false;
|
|
317627
|
+
this.#setCellAnchorState(cellAnchor, mode);
|
|
317628
|
+
return true;
|
|
317629
|
+
}
|
|
317630
|
+
#dispatchExtendedTextSelection(editor, anchor, head) {
|
|
317631
|
+
const { selAnchor, selHead } = this.#calculateExtendedSelection(anchor, head, this.#dragExtensionMode);
|
|
317632
|
+
const stabilized = stabilizeTextSelectionAcrossTableCells(editor.state.doc, selAnchor, selHead);
|
|
317633
|
+
if (!stabilized)
|
|
317634
|
+
return false;
|
|
317635
|
+
try {
|
|
317636
|
+
const tr = editor.state.tr.setSelection(TextSelection.create(editor.state.doc, stabilized.selAnchor, stabilized.selHead));
|
|
317637
|
+
editor.view?.dispatch(tr);
|
|
317638
|
+
this.#callbacks.scheduleSelectionUpdate?.();
|
|
317639
|
+
return true;
|
|
317640
|
+
} catch (error48) {
|
|
317641
|
+
console.warn("[SELECTION] Failed to extend text selection:", error48);
|
|
317642
|
+
return false;
|
|
317643
|
+
}
|
|
317392
317644
|
}
|
|
317393
317645
|
#hitTestTable(x, y$1) {
|
|
317394
317646
|
return this.#callbacks.hitTestTable?.(x, y$1) ?? null;
|
|
@@ -317990,6 +318242,8 @@ menclose::after {
|
|
|
317990
318242
|
this.#pendingMarginClick = null;
|
|
317991
318243
|
const dragAnchor = this.#dragAnchor;
|
|
317992
318244
|
const dragMode = this.#dragExtensionMode;
|
|
318245
|
+
if ((!pendingMarginClick || pendingMarginClick.pointerId !== event.pointerId) && dragAnchor != null && this.#dragThresholdExceeded)
|
|
318246
|
+
this.#handleDragSelectionAt(event.clientX, event.clientY);
|
|
317993
318247
|
const dragUsedFallback = this.#dragUsedPageNotMountedFallback;
|
|
317994
318248
|
const dragPointer = this.#dragLastPointer;
|
|
317995
318249
|
this.#isDragging = false;
|
|
@@ -318472,14 +318726,7 @@ menclose::after {
|
|
|
318472
318726
|
if (!editor)
|
|
318473
318727
|
return;
|
|
318474
318728
|
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
|
-
}
|
|
318729
|
+
this.#dispatchExtendedTextSelection(editor, anchor, headPos);
|
|
318483
318730
|
this.#focusEditor();
|
|
318484
318731
|
}
|
|
318485
318732
|
#handleDragSelectionAt(clientX, clientY) {
|
|
@@ -318540,17 +318787,28 @@ menclose::after {
|
|
|
318540
318787
|
}
|
|
318541
318788
|
const anchor = this.#dragAnchor;
|
|
318542
318789
|
const head = hit.pos;
|
|
318543
|
-
|
|
318544
|
-
|
|
318545
|
-
|
|
318546
|
-
|
|
318547
|
-
|
|
318548
|
-
|
|
318549
|
-
|
|
318790
|
+
if (!useActiveSurfaceHitTest) {
|
|
318791
|
+
const crossCell = resolveCrossCellSelection(editor.state.doc, anchor, head);
|
|
318792
|
+
if (crossCell)
|
|
318793
|
+
try {
|
|
318794
|
+
const tr = editor.state.tr.setSelection(CellSelection.create(editor.state.doc, crossCell.anchorCellPos, crossCell.headCellPos));
|
|
318795
|
+
editor.view?.dispatch(tr);
|
|
318796
|
+
if (!this.#setCellAnchorFromCellPos(crossCell.anchorCellPos, "active"))
|
|
318797
|
+
console.warn("[CELL-SELECTION] Failed to cache anchor state for cross-cell drag selection.");
|
|
318798
|
+
this.#callbacks.scheduleSelectionUpdate?.();
|
|
318799
|
+
return;
|
|
318800
|
+
} catch (error48) {
|
|
318801
|
+
console.warn("[SELECTION] Failed to create cross-cell CellSelection during drag:", error48);
|
|
318802
|
+
}
|
|
318550
318803
|
}
|
|
318804
|
+
this.#dispatchExtendedTextSelection(editor, anchor, head);
|
|
318551
318805
|
}
|
|
318552
318806
|
#handleCellDragSelection(currentTableHit, hit) {
|
|
318553
|
-
|
|
318807
|
+
if (!this.#cellAnchor)
|
|
318808
|
+
return;
|
|
318809
|
+
if (!currentTableHit || currentTableHit.block.id !== this.#cellAnchor.tableBlockId)
|
|
318810
|
+
return;
|
|
318811
|
+
const headCellPos = this.#getCellPosFromTableHit(currentTableHit);
|
|
318554
318812
|
if (headCellPos === null)
|
|
318555
318813
|
return;
|
|
318556
318814
|
if (this.#cellDragMode !== "active")
|
|
@@ -318570,13 +318828,7 @@ menclose::after {
|
|
|
318570
318828
|
} catch (error48) {
|
|
318571
318829
|
console.warn("[CELL-SELECTION] Failed to create CellSelection, falling back to TextSelection:", error48);
|
|
318572
318830
|
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 {}
|
|
318831
|
+
this.#dispatchExtendedTextSelection(editor, anchor, hit.pos);
|
|
318580
318832
|
}
|
|
318581
318833
|
}
|
|
318582
318834
|
#handleHover(normalized) {
|
|
@@ -322461,13 +322713,13 @@ menclose::after {
|
|
|
322461
322713
|
return;
|
|
322462
322714
|
console.log(...args$1);
|
|
322463
322715
|
}, 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
|
|
322716
|
+
var init_src_Bvhjxf8i_es = __esm(() => {
|
|
322465
322717
|
init_rolldown_runtime_Bg48TavK_es();
|
|
322466
|
-
|
|
322718
|
+
init_SuperConverter_WQVqM0th_es();
|
|
322467
322719
|
init_jszip_C49i9kUs_es();
|
|
322468
322720
|
init_xml_js_CqGKpaft_es();
|
|
322469
322721
|
init_uuid_B2wVPhPi_es();
|
|
322470
|
-
|
|
322722
|
+
init_create_headless_toolbar_B8OXKxcw_es();
|
|
322471
322723
|
init_constants_D9qj59G2_es();
|
|
322472
322724
|
init_dist_B8HfvhaK_es();
|
|
322473
322725
|
init_unified_Dsuw2be5_es();
|
|
@@ -356876,14 +357128,17 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
356876
357128
|
return;
|
|
356877
357129
|
}
|
|
356878
357130
|
const head = Math.max(0, Math.min(mappedHead.pos, doc$12.content.size));
|
|
356879
|
-
const
|
|
357131
|
+
const extended = this.#calculateExtendedSelection(anchor, head, mode);
|
|
357132
|
+
const stabilized = stabilizeTextSelectionAcrossTableCells(doc$12, extended.selAnchor, extended.selHead);
|
|
357133
|
+
if (!stabilized)
|
|
357134
|
+
return;
|
|
356880
357135
|
const current = this.#editor.state.selection;
|
|
356881
|
-
const desiredFrom = Math.min(selAnchor, selHead);
|
|
356882
|
-
const desiredTo = Math.max(selAnchor, selHead);
|
|
357136
|
+
const desiredFrom = Math.min(stabilized.selAnchor, stabilized.selHead);
|
|
357137
|
+
const desiredTo = Math.max(stabilized.selAnchor, stabilized.selHead);
|
|
356883
357138
|
if (current.from === desiredFrom && current.to === desiredTo)
|
|
356884
357139
|
return;
|
|
356885
357140
|
try {
|
|
356886
|
-
const tr = this.#editor.state.tr.setSelection(TextSelection.create(this.#editor.state.doc, selAnchor, selHead));
|
|
357141
|
+
const tr = this.#editor.state.tr.setSelection(TextSelection.create(this.#editor.state.doc, stabilized.selAnchor, stabilized.selHead));
|
|
356887
357142
|
this.#editor.view?.dispatch(tr);
|
|
356888
357143
|
this.#scheduleSelectionUpdate();
|
|
356889
357144
|
} catch {}
|
|
@@ -358249,11 +358504,11 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
358249
358504
|
]);
|
|
358250
358505
|
});
|
|
358251
358506
|
|
|
358252
|
-
// ../../packages/superdoc/dist/chunks/create-super-doc-ui-
|
|
358507
|
+
// ../../packages/superdoc/dist/chunks/create-super-doc-ui-CCLA6uFG.es.js
|
|
358253
358508
|
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;
|
|
358254
|
-
var
|
|
358255
|
-
|
|
358256
|
-
|
|
358509
|
+
var init_create_super_doc_ui_CCLA6uFG_es = __esm(() => {
|
|
358510
|
+
init_SuperConverter_WQVqM0th_es();
|
|
358511
|
+
init_create_headless_toolbar_B8OXKxcw_es();
|
|
358257
358512
|
DEFAULT_TEXT_ALIGN_OPTIONS = [
|
|
358258
358513
|
{
|
|
358259
358514
|
label: "Left",
|
|
@@ -358544,16 +358799,16 @@ var init_zipper_yaJVJ4z9_es = __esm(() => {
|
|
|
358544
358799
|
|
|
358545
358800
|
// ../../packages/superdoc/dist/super-editor.es.js
|
|
358546
358801
|
var init_super_editor_es = __esm(() => {
|
|
358547
|
-
|
|
358548
|
-
|
|
358802
|
+
init_src_Bvhjxf8i_es();
|
|
358803
|
+
init_SuperConverter_WQVqM0th_es();
|
|
358549
358804
|
init_jszip_C49i9kUs_es();
|
|
358550
358805
|
init_xml_js_CqGKpaft_es();
|
|
358551
|
-
|
|
358806
|
+
init_create_headless_toolbar_B8OXKxcw_es();
|
|
358552
358807
|
init_constants_D9qj59G2_es();
|
|
358553
358808
|
init_dist_B8HfvhaK_es();
|
|
358554
358809
|
init_unified_Dsuw2be5_es();
|
|
358555
358810
|
init_DocxZipper_FUsfThjV_es();
|
|
358556
|
-
|
|
358811
|
+
init_create_super_doc_ui_CCLA6uFG_es();
|
|
358557
358812
|
init_ui_C5PAS9hY_es();
|
|
358558
358813
|
init_eventemitter3_BnGqBE_Q_es();
|
|
358559
358814
|
init_errors_CNaD6vcg_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.26",
|
|
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"
|