@superdoc-dev/cli 0.3.0-next.54 → 0.3.0-next.55
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 +436 -75
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -152177,7 +152177,7 @@ var init_remark_gfm_CjV8kaUy_es = __esm(() => {
|
|
|
152177
152177
|
init_remark_gfm_z_sDF4ss_es();
|
|
152178
152178
|
});
|
|
152179
152179
|
|
|
152180
|
-
// ../../packages/superdoc/dist/chunks/src-
|
|
152180
|
+
// ../../packages/superdoc/dist/chunks/src-D389XrYP.es.js
|
|
152181
152181
|
function deleteProps(obj, propOrProps) {
|
|
152182
152182
|
const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
|
|
152183
152183
|
const removeNested = (target, pathParts, index2 = 0) => {
|
|
@@ -156292,6 +156292,249 @@ function cellWrapping2($pos) {
|
|
|
156292
156292
|
}
|
|
156293
156293
|
return null;
|
|
156294
156294
|
}
|
|
156295
|
+
function findAncestorDepth($pos, predicate) {
|
|
156296
|
+
for (let depth = $pos.depth;depth > 0; depth -= 1)
|
|
156297
|
+
if (predicate($pos.node(depth)))
|
|
156298
|
+
return depth;
|
|
156299
|
+
return -1;
|
|
156300
|
+
}
|
|
156301
|
+
function findRunDepthWithinParagraph($pos, paragraphDepth) {
|
|
156302
|
+
for (let depth = $pos.depth;depth > paragraphDepth; depth -= 1)
|
|
156303
|
+
if ($pos.node(depth).type.name === "run")
|
|
156304
|
+
return depth;
|
|
156305
|
+
return -1;
|
|
156306
|
+
}
|
|
156307
|
+
function findParagraphDepth($pos) {
|
|
156308
|
+
return findAncestorDepth($pos, (node3) => node3.type.name === "paragraph");
|
|
156309
|
+
}
|
|
156310
|
+
function allInlineMarkersBetween(paragraph2, fromIndex, toIndex) {
|
|
156311
|
+
for (let i4 = fromIndex;i4 < toIndex; i4 += 1) {
|
|
156312
|
+
const child = paragraph2.child(i4);
|
|
156313
|
+
if (child.type.name === "run")
|
|
156314
|
+
return false;
|
|
156315
|
+
if (!child.isInline)
|
|
156316
|
+
return false;
|
|
156317
|
+
if (child.textContent !== "")
|
|
156318
|
+
return false;
|
|
156319
|
+
}
|
|
156320
|
+
return true;
|
|
156321
|
+
}
|
|
156322
|
+
function isAtEffectiveParagraphEnd($head) {
|
|
156323
|
+
const paragraphDepth = findParagraphDepth($head);
|
|
156324
|
+
if (paragraphDepth < 0)
|
|
156325
|
+
return false;
|
|
156326
|
+
const paragraph2 = $head.node(paragraphDepth);
|
|
156327
|
+
if (paragraph2.content.size === 0)
|
|
156328
|
+
return true;
|
|
156329
|
+
if ($head.pos === $head.end(paragraphDepth))
|
|
156330
|
+
return true;
|
|
156331
|
+
const runDepth = findRunDepthWithinParagraph($head, paragraphDepth);
|
|
156332
|
+
if (runDepth < 0)
|
|
156333
|
+
return false;
|
|
156334
|
+
if ($head.pos !== $head.end(runDepth))
|
|
156335
|
+
return false;
|
|
156336
|
+
return allInlineMarkersBetween(paragraph2, $head.index(paragraphDepth) + 1, paragraph2.childCount);
|
|
156337
|
+
}
|
|
156338
|
+
function isAtEffectiveParagraphStart($head) {
|
|
156339
|
+
const paragraphDepth = findParagraphDepth($head);
|
|
156340
|
+
if (paragraphDepth < 0)
|
|
156341
|
+
return false;
|
|
156342
|
+
const paragraph2 = $head.node(paragraphDepth);
|
|
156343
|
+
if (paragraph2.content.size === 0)
|
|
156344
|
+
return true;
|
|
156345
|
+
if ($head.pos === $head.start(paragraphDepth))
|
|
156346
|
+
return true;
|
|
156347
|
+
const runDepth = findRunDepthWithinParagraph($head, paragraphDepth);
|
|
156348
|
+
if (runDepth < 0)
|
|
156349
|
+
return false;
|
|
156350
|
+
if ($head.pos !== $head.start(runDepth))
|
|
156351
|
+
return false;
|
|
156352
|
+
return allInlineMarkersBetween(paragraph2, 0, $head.index(paragraphDepth));
|
|
156353
|
+
}
|
|
156354
|
+
function isInLastParagraphOfCell($head, cellDepth) {
|
|
156355
|
+
return $head.index(cellDepth) === $head.node(cellDepth).childCount - 1;
|
|
156356
|
+
}
|
|
156357
|
+
function isInFirstParagraphOfCell($head, cellDepth) {
|
|
156358
|
+
return $head.index(cellDepth) === 0;
|
|
156359
|
+
}
|
|
156360
|
+
function getTableContext($head) {
|
|
156361
|
+
const cellDepth = findAncestorDepth($head, (node3) => TABLE_CELL_ROLES.has(node3.type.spec.tableRole));
|
|
156362
|
+
if (cellDepth < 0)
|
|
156363
|
+
return null;
|
|
156364
|
+
const tableDepth = findAncestorDepth($head, (node3) => node3.type.spec.tableRole === "table");
|
|
156365
|
+
if (tableDepth < 0)
|
|
156366
|
+
return null;
|
|
156367
|
+
const table2 = $head.node(tableDepth);
|
|
156368
|
+
return {
|
|
156369
|
+
cellDepth,
|
|
156370
|
+
cellStart: $head.before(cellDepth),
|
|
156371
|
+
tableStart: $head.start(tableDepth),
|
|
156372
|
+
tablePos: $head.before(tableDepth),
|
|
156373
|
+
table: table2
|
|
156374
|
+
};
|
|
156375
|
+
}
|
|
156376
|
+
function getCellRect(context) {
|
|
156377
|
+
const map$12 = TableMap.get(context.table);
|
|
156378
|
+
return {
|
|
156379
|
+
map: map$12,
|
|
156380
|
+
rect: map$12.findCell(context.cellStart - context.tableStart)
|
|
156381
|
+
};
|
|
156382
|
+
}
|
|
156383
|
+
function isLastCellInTable(context) {
|
|
156384
|
+
if (!context)
|
|
156385
|
+
return false;
|
|
156386
|
+
const { map: map$12, rect } = getCellRect(context);
|
|
156387
|
+
return rect.right === map$12.width && rect.bottom === map$12.height;
|
|
156388
|
+
}
|
|
156389
|
+
function isFirstCellInTable(context) {
|
|
156390
|
+
if (!context)
|
|
156391
|
+
return false;
|
|
156392
|
+
const { rect } = getCellRect(context);
|
|
156393
|
+
return rect.left === 0 && rect.top === 0;
|
|
156394
|
+
}
|
|
156395
|
+
function findFirstTextPosInNode(node3, nodePos) {
|
|
156396
|
+
if (node3.isText)
|
|
156397
|
+
return nodePos;
|
|
156398
|
+
for (let index2 = 0, offset$1 = 0;index2 < node3.childCount; index2 += 1) {
|
|
156399
|
+
const child = node3.child(index2);
|
|
156400
|
+
const found2 = findFirstTextPosInNode(child, nodePos + 1 + offset$1);
|
|
156401
|
+
if (found2 != null)
|
|
156402
|
+
return found2;
|
|
156403
|
+
offset$1 += child.nodeSize;
|
|
156404
|
+
}
|
|
156405
|
+
return null;
|
|
156406
|
+
}
|
|
156407
|
+
function findLastTextPosInNode(node3, nodePos) {
|
|
156408
|
+
if (node3.isText)
|
|
156409
|
+
return nodePos + (node3.text?.length ?? 0);
|
|
156410
|
+
for (let index2 = node3.childCount - 1, offset$1 = node3.content.size;index2 >= 0; index2 -= 1) {
|
|
156411
|
+
const child = node3.child(index2);
|
|
156412
|
+
offset$1 -= child.nodeSize;
|
|
156413
|
+
const found2 = findLastTextPosInNode(child, nodePos + 1 + offset$1);
|
|
156414
|
+
if (found2 != null)
|
|
156415
|
+
return found2;
|
|
156416
|
+
}
|
|
156417
|
+
return null;
|
|
156418
|
+
}
|
|
156419
|
+
function findFirstTextPosAfterBoundary(state, boundaryPos) {
|
|
156420
|
+
const nextNode = state.doc.resolve(boundaryPos).nodeAfter;
|
|
156421
|
+
if (!nextNode)
|
|
156422
|
+
return null;
|
|
156423
|
+
return findFirstTextPosInNode(nextNode, boundaryPos);
|
|
156424
|
+
}
|
|
156425
|
+
function findLastTextPosBeforeBoundary(state, boundaryPos) {
|
|
156426
|
+
const prevNode = state.doc.resolve(boundaryPos).nodeBefore;
|
|
156427
|
+
if (!prevNode)
|
|
156428
|
+
return null;
|
|
156429
|
+
return findLastTextPosInNode(prevNode, boundaryPos - prevNode.nodeSize);
|
|
156430
|
+
}
|
|
156431
|
+
function findSelectionNearBoundary(state, boundaryPos, dir) {
|
|
156432
|
+
return Selection.findFrom(state.doc.resolve(boundaryPos), dir, true) ?? Selection.near(state.doc.resolve(boundaryPos), dir);
|
|
156433
|
+
}
|
|
156434
|
+
function getDirectionHelpers(dir) {
|
|
156435
|
+
if (dir > 0)
|
|
156436
|
+
return {
|
|
156437
|
+
isAtParagraphBoundary: isAtEffectiveParagraphEnd,
|
|
156438
|
+
isEdgeParagraphInCell: isInLastParagraphOfCell,
|
|
156439
|
+
isEdgeCellInTable: isLastCellInTable,
|
|
156440
|
+
findTextPosAcrossBoundary: findFirstTextPosAfterBoundary,
|
|
156441
|
+
getTableBoundaryPos: (context) => context.tablePos + context.table.nodeSize
|
|
156442
|
+
};
|
|
156443
|
+
return {
|
|
156444
|
+
isAtParagraphBoundary: isAtEffectiveParagraphStart,
|
|
156445
|
+
isEdgeParagraphInCell: isInFirstParagraphOfCell,
|
|
156446
|
+
isEdgeCellInTable: isFirstCellInTable,
|
|
156447
|
+
findTextPosAcrossBoundary: findLastTextPosBeforeBoundary,
|
|
156448
|
+
getTableBoundaryPos: (context) => context.tablePos
|
|
156449
|
+
};
|
|
156450
|
+
}
|
|
156451
|
+
function isInProtectedTrailingTableParagraph(state) {
|
|
156452
|
+
const selection = state.selection;
|
|
156453
|
+
if (!selection.empty)
|
|
156454
|
+
return false;
|
|
156455
|
+
const $head = selection.$head;
|
|
156456
|
+
const paragraphDepth = findParagraphDepth($head);
|
|
156457
|
+
if (paragraphDepth !== 1)
|
|
156458
|
+
return false;
|
|
156459
|
+
const paragraph2 = $head.node(paragraphDepth);
|
|
156460
|
+
if (paragraph2.type.name !== "paragraph" || paragraph2.textContent !== "")
|
|
156461
|
+
return false;
|
|
156462
|
+
const paragraphIndex = $head.index(0);
|
|
156463
|
+
if (paragraphIndex !== state.doc.childCount - 1 || paragraphIndex === 0)
|
|
156464
|
+
return false;
|
|
156465
|
+
return state.doc.child(paragraphIndex - 1)?.type.name === "table";
|
|
156466
|
+
}
|
|
156467
|
+
function getTableBoundaryExitSelection(state, dir) {
|
|
156468
|
+
const selection = state.selection;
|
|
156469
|
+
if (!selection.empty)
|
|
156470
|
+
return null;
|
|
156471
|
+
const context = getTableContext(selection.$head);
|
|
156472
|
+
if (!context)
|
|
156473
|
+
return null;
|
|
156474
|
+
const helpers = getDirectionHelpers(dir);
|
|
156475
|
+
if (!helpers.isEdgeParagraphInCell(selection.$head, context.cellDepth))
|
|
156476
|
+
return null;
|
|
156477
|
+
if (!helpers.isAtParagraphBoundary(selection.$head))
|
|
156478
|
+
return null;
|
|
156479
|
+
if (!helpers.isEdgeCellInTable(context))
|
|
156480
|
+
return null;
|
|
156481
|
+
const boundaryPos = helpers.getTableBoundaryPos(context);
|
|
156482
|
+
const targetPos = helpers.findTextPosAcrossBoundary(state, boundaryPos);
|
|
156483
|
+
if (targetPos != null)
|
|
156484
|
+
return TextSelection2.create(state.doc, targetPos);
|
|
156485
|
+
return findSelectionNearBoundary(state, boundaryPos, dir);
|
|
156486
|
+
}
|
|
156487
|
+
function getAdjacentTableEntrySelection(state, dir) {
|
|
156488
|
+
const selection = state.selection;
|
|
156489
|
+
if (!selection.empty)
|
|
156490
|
+
return null;
|
|
156491
|
+
const $head = selection.$head;
|
|
156492
|
+
const paragraphDepth = findParagraphDepth($head);
|
|
156493
|
+
if (paragraphDepth < 0)
|
|
156494
|
+
return null;
|
|
156495
|
+
if (!getDirectionHelpers(dir).isAtParagraphBoundary($head))
|
|
156496
|
+
return null;
|
|
156497
|
+
const boundaryPos = dir > 0 ? $head.end(paragraphDepth) + 1 : $head.start(paragraphDepth) - 1;
|
|
156498
|
+
const $boundary = state.doc.resolve(boundaryPos);
|
|
156499
|
+
const adjacentNode = dir > 0 ? $boundary.nodeAfter : $boundary.nodeBefore;
|
|
156500
|
+
if (!adjacentNode || adjacentNode.type.spec.tableRole !== "table")
|
|
156501
|
+
return null;
|
|
156502
|
+
if (dir > 0) {
|
|
156503
|
+
const targetPos$1 = findFirstTextPosInNode(adjacentNode, boundaryPos);
|
|
156504
|
+
if (targetPos$1 != null)
|
|
156505
|
+
return TextSelection2.create(state.doc, targetPos$1);
|
|
156506
|
+
return findSelectionNearBoundary(state, boundaryPos, 1);
|
|
156507
|
+
}
|
|
156508
|
+
const tablePos = boundaryPos - adjacentNode.nodeSize;
|
|
156509
|
+
const targetPos = findLastTextPosInNode(adjacentNode, tablePos);
|
|
156510
|
+
if (targetPos != null)
|
|
156511
|
+
return TextSelection2.create(state.doc, targetPos);
|
|
156512
|
+
return findSelectionNearBoundary(state, tablePos + adjacentNode.nodeSize, -1);
|
|
156513
|
+
}
|
|
156514
|
+
function createTableBoundaryNavigationPlugin() {
|
|
156515
|
+
return new Plugin({
|
|
156516
|
+
key: TableBoundaryNavigationPluginKey,
|
|
156517
|
+
props: { handleKeyDown(view, event) {
|
|
156518
|
+
if (event.defaultPrevented)
|
|
156519
|
+
return false;
|
|
156520
|
+
if (event.shiftKey || event.altKey || event.ctrlKey || event.metaKey)
|
|
156521
|
+
return false;
|
|
156522
|
+
if ((event.key === "Backspace" || event.key === "Delete") && isInProtectedTrailingTableParagraph(view.state)) {
|
|
156523
|
+
event.preventDefault();
|
|
156524
|
+
return true;
|
|
156525
|
+
}
|
|
156526
|
+
const dir = event.key === "ArrowRight" ? 1 : event.key === "ArrowLeft" ? -1 : 0;
|
|
156527
|
+
if (!dir)
|
|
156528
|
+
return false;
|
|
156529
|
+
const nextSelection = getTableBoundaryExitSelection(view.state, dir) ?? getAdjacentTableEntrySelection(view.state, dir);
|
|
156530
|
+
if (!nextSelection)
|
|
156531
|
+
return false;
|
|
156532
|
+
view.dispatch(view.state.tr.setSelection(nextSelection).scrollIntoView());
|
|
156533
|
+
event.preventDefault();
|
|
156534
|
+
return true;
|
|
156535
|
+
} }
|
|
156536
|
+
});
|
|
156537
|
+
}
|
|
156295
156538
|
function toggleHeaderRow(state, dispatch) {
|
|
156296
156539
|
const target = resolveTarget2(state);
|
|
156297
156540
|
if (!target)
|
|
@@ -156614,20 +156857,61 @@ function insertRowAtIndex({ tr, tablePos, tableNode, sourceRowIndex, insertIndex
|
|
|
156614
156857
|
}
|
|
156615
156858
|
return true;
|
|
156616
156859
|
}
|
|
156617
|
-
function tableSeparatorNeeds(doc$12, pos) {
|
|
156618
|
-
const
|
|
156619
|
-
|
|
156860
|
+
function tableSeparatorNeeds(doc$12, pos, replaceRange2 = {}) {
|
|
156861
|
+
const boundaryBefore = replaceRange2.from ?? pos;
|
|
156862
|
+
const boundaryAfter = replaceRange2.to ?? pos;
|
|
156863
|
+
const $before = doc$12.resolve(boundaryBefore);
|
|
156864
|
+
const $after = doc$12.resolve(boundaryAfter);
|
|
156865
|
+
if ($before.depth !== 0 || $after.depth !== 0)
|
|
156620
156866
|
return {
|
|
156621
156867
|
before: false,
|
|
156622
156868
|
after: false
|
|
156623
156869
|
};
|
|
156624
|
-
const
|
|
156625
|
-
const
|
|
156870
|
+
const beforeIndex = $before.index(0);
|
|
156871
|
+
const afterIndex = $after.index(0);
|
|
156872
|
+
const nodeBefore = beforeIndex > 0 ? doc$12.child(beforeIndex - 1) : null;
|
|
156873
|
+
const nodeAfter = afterIndex < doc$12.childCount ? doc$12.child(afterIndex) : null;
|
|
156626
156874
|
return {
|
|
156627
|
-
before:
|
|
156875
|
+
before: nodeBefore?.type.name === "table",
|
|
156628
156876
|
after: !nodeAfter || nodeAfter.type.name === "table"
|
|
156629
156877
|
};
|
|
156630
156878
|
}
|
|
156879
|
+
function createTableSeparatorParagraph(schema) {
|
|
156880
|
+
const attrs = {
|
|
156881
|
+
sdBlockId: v4_default(),
|
|
156882
|
+
paraId: generateDocxHexId()
|
|
156883
|
+
};
|
|
156884
|
+
return schema.nodes.paragraph.createAndFill(attrs);
|
|
156885
|
+
}
|
|
156886
|
+
function insertTopLevelTableWithSeparators(tr, doc$12, pos, tableNode, replaceRange2 = {}) {
|
|
156887
|
+
const replaceFrom = replaceRange2.from ?? pos;
|
|
156888
|
+
const replaceTo = replaceRange2.to ?? pos;
|
|
156889
|
+
const sep = tableSeparatorNeeds(doc$12, pos, replaceRange2);
|
|
156890
|
+
if (!sep.before && !sep.after) {
|
|
156891
|
+
tr.replaceWith(replaceFrom, replaceTo, tableNode);
|
|
156892
|
+
return { inserted: true };
|
|
156893
|
+
}
|
|
156894
|
+
const nodes = [];
|
|
156895
|
+
if (sep.before) {
|
|
156896
|
+
const before = createTableSeparatorParagraph(doc$12.type.schema);
|
|
156897
|
+
if (!before)
|
|
156898
|
+
return { inserted: false };
|
|
156899
|
+
nodes.push(before);
|
|
156900
|
+
}
|
|
156901
|
+
nodes.push(tableNode);
|
|
156902
|
+
if (sep.after) {
|
|
156903
|
+
const after = createTableSeparatorParagraph(doc$12.type.schema);
|
|
156904
|
+
if (!after)
|
|
156905
|
+
return { inserted: false };
|
|
156906
|
+
nodes.push(after);
|
|
156907
|
+
}
|
|
156908
|
+
tr.replaceWith(replaceFrom, replaceTo, Fragment.from(nodes));
|
|
156909
|
+
return { inserted: true };
|
|
156910
|
+
}
|
|
156911
|
+
function getFirstTableCellTextPos(tablePos, tableNode) {
|
|
156912
|
+
const map$12 = TableMap.get(tableNode);
|
|
156913
|
+
return tablePos + 1 + map$12.map[0] + 2;
|
|
156914
|
+
}
|
|
156631
156915
|
function getCellType({ node: node3, state }) {
|
|
156632
156916
|
return tableNodeTypes(state.schema)[node3.type.spec.tableRole];
|
|
156633
156917
|
}
|
|
@@ -168708,7 +168992,7 @@ function getAdjacentLineClientTarget(editor, coords, direction) {
|
|
|
168708
168992
|
const currentLine = findLineElementAtPoint(doc$12, caretX, coords.clientY + coords.height / 2);
|
|
168709
168993
|
if (!currentLine)
|
|
168710
168994
|
return null;
|
|
168711
|
-
const adjacentLine = findAdjacentLineElement(currentLine, direction);
|
|
168995
|
+
const adjacentLine = findAdjacentLineElement(currentLine, direction, caretX);
|
|
168712
168996
|
if (!adjacentLine)
|
|
168713
168997
|
return null;
|
|
168714
168998
|
const pageEl = adjacentLine.closest?.(`.${DOM_CLASS_NAMES.PAGE}`);
|
|
@@ -168753,33 +169037,17 @@ function findLineElementAtPoint(doc$12, x, y$1) {
|
|
|
168753
169037
|
return el;
|
|
168754
169038
|
return null;
|
|
168755
169039
|
}
|
|
168756
|
-
function findAdjacentLineElement(currentLine, direction) {
|
|
168757
|
-
const lineClass = DOM_CLASS_NAMES.LINE;
|
|
168758
|
-
const fragmentClass = DOM_CLASS_NAMES.FRAGMENT;
|
|
169040
|
+
function findAdjacentLineElement(currentLine, direction, caretX) {
|
|
168759
169041
|
const pageClass = DOM_CLASS_NAMES.PAGE;
|
|
168760
|
-
const headerClass = "superdoc-page-header";
|
|
168761
|
-
const footerClass = "superdoc-page-footer";
|
|
168762
|
-
const fragment2 = currentLine.closest?.(`.${fragmentClass}`);
|
|
168763
169042
|
const page = currentLine.closest?.(`.${pageClass}`);
|
|
168764
|
-
if (!
|
|
169043
|
+
if (!page)
|
|
168765
169044
|
return null;
|
|
168766
|
-
const
|
|
168767
|
-
|
|
168768
|
-
|
|
168769
|
-
|
|
168770
|
-
|
|
168771
|
-
|
|
168772
|
-
}
|
|
168773
|
-
const fragments = Array.from(page.querySelectorAll(`.${fragmentClass}`)).filter((frag) => {
|
|
168774
|
-
return !frag.closest?.(`.${headerClass}, .${footerClass}`);
|
|
168775
|
-
});
|
|
168776
|
-
const fragmentIndex = fragments.indexOf(fragment2);
|
|
168777
|
-
if (fragmentIndex !== -1) {
|
|
168778
|
-
const nextFragment = fragments[fragmentIndex + direction];
|
|
168779
|
-
const fallbackLine = getEdgeLineFromFragment(nextFragment, direction);
|
|
168780
|
-
if (fallbackLine)
|
|
168781
|
-
return fallbackLine;
|
|
168782
|
-
}
|
|
169045
|
+
const currentLineMetrics = getLineMetrics(currentLine);
|
|
169046
|
+
if (!currentLineMetrics)
|
|
169047
|
+
return null;
|
|
169048
|
+
const adjacentOnCurrentPage = findClosestLineInDirection(getPageLineElements(page), currentLine, currentLineMetrics, direction, caretX);
|
|
169049
|
+
if (adjacentOnCurrentPage)
|
|
169050
|
+
return adjacentOnCurrentPage;
|
|
168783
169051
|
const pages = Array.from(page.parentElement?.querySelectorAll?.(`.${pageClass}`) ?? []);
|
|
168784
169052
|
const pageIndex = pages.indexOf(page);
|
|
168785
169053
|
if (pageIndex === -1)
|
|
@@ -168787,12 +169055,7 @@ function findAdjacentLineElement(currentLine, direction) {
|
|
|
168787
169055
|
const nextPage = pages[pageIndex + direction];
|
|
168788
169056
|
if (!nextPage)
|
|
168789
169057
|
return null;
|
|
168790
|
-
|
|
168791
|
-
return !frag.closest?.(`.${headerClass}, .${footerClass}`);
|
|
168792
|
-
});
|
|
168793
|
-
if (direction > 0)
|
|
168794
|
-
return getEdgeLineFromFragment(pageFragments[0], direction);
|
|
168795
|
-
return getEdgeLineFromFragment(pageFragments[pageFragments.length - 1], direction);
|
|
169058
|
+
return findEdgeLineForPage(getPageLineElements(nextPage), direction, caretX);
|
|
168796
169059
|
}
|
|
168797
169060
|
function resolvePositionAtGoalX(editor, pmStart, pmEnd, goalX) {
|
|
168798
169061
|
const presentationEditor = editor.presentationEditor;
|
|
@@ -168821,13 +169084,105 @@ function resolvePositionAtGoalX(editor, pmStart, pmEnd, goalX) {
|
|
|
168821
169084
|
}
|
|
168822
169085
|
return { pos: bestPos };
|
|
168823
169086
|
}
|
|
168824
|
-
function
|
|
168825
|
-
|
|
169087
|
+
function getPageLineElements(page) {
|
|
169088
|
+
const fragmentClass = DOM_CLASS_NAMES.FRAGMENT;
|
|
169089
|
+
const lineClass = DOM_CLASS_NAMES.LINE;
|
|
169090
|
+
const headerClass = "superdoc-page-header";
|
|
169091
|
+
const footerClass = "superdoc-page-footer";
|
|
169092
|
+
return Array.from(page.querySelectorAll(`.${fragmentClass}`)).filter((fragment2) => !fragment2.closest?.(`.${headerClass}, .${footerClass}`)).flatMap((fragment2) => Array.from(fragment2.querySelectorAll(`.${lineClass}`)));
|
|
169093
|
+
}
|
|
169094
|
+
function findClosestLineInDirection(lineEls, currentLine, currentMetrics, direction, caretX) {
|
|
169095
|
+
const directionalCandidates = lineEls.filter((line) => line !== currentLine).map((line) => ({
|
|
169096
|
+
line,
|
|
169097
|
+
metrics: getLineMetrics(line)
|
|
169098
|
+
})).filter(({ metrics }) => metrics && isLineInDirection(metrics.centerY, currentMetrics.centerY, direction));
|
|
169099
|
+
if (directionalCandidates.length === 0)
|
|
168826
169100
|
return null;
|
|
168827
|
-
const
|
|
168828
|
-
|
|
169101
|
+
const nearestVerticalDistance = directionalCandidates.reduce((minDistance, { metrics }) => {
|
|
169102
|
+
const distance = Math.abs(metrics.centerY - currentMetrics.centerY);
|
|
169103
|
+
return Math.min(minDistance, distance);
|
|
169104
|
+
}, Infinity);
|
|
169105
|
+
const targetRowCenterY = directionalCandidates.filter(({ metrics }) => isWithinTolerance(Math.abs(metrics.centerY - currentMetrics.centerY), nearestVerticalDistance, 1)).reduce((bestCenterY, { metrics }) => {
|
|
169106
|
+
if (bestCenterY == null)
|
|
169107
|
+
return metrics.centerY;
|
|
169108
|
+
return direction > 0 ? Math.min(bestCenterY, metrics.centerY) : Math.max(bestCenterY, metrics.centerY);
|
|
169109
|
+
}, null);
|
|
169110
|
+
if (!Number.isFinite(targetRowCenterY))
|
|
169111
|
+
return null;
|
|
169112
|
+
return chooseLineClosestToX(directionalCandidates.filter(({ metrics }) => isWithinTolerance(metrics.centerY, targetRowCenterY, getRowTolerance(currentMetrics, metrics))), caretX);
|
|
169113
|
+
}
|
|
169114
|
+
function findEdgeLineForPage(lineEls, direction, caretX) {
|
|
169115
|
+
const candidates = lineEls.map((line) => ({
|
|
169116
|
+
line,
|
|
169117
|
+
metrics: getLineMetrics(line)
|
|
169118
|
+
})).filter(({ metrics }) => metrics);
|
|
169119
|
+
if (candidates.length === 0)
|
|
169120
|
+
return null;
|
|
169121
|
+
const targetRowCenterY = candidates.reduce((edgeCenterY, { metrics }) => {
|
|
169122
|
+
if (edgeCenterY == null)
|
|
169123
|
+
return metrics.centerY;
|
|
169124
|
+
return direction > 0 ? Math.min(edgeCenterY, metrics.centerY) : Math.max(edgeCenterY, metrics.centerY);
|
|
169125
|
+
}, null);
|
|
169126
|
+
if (!Number.isFinite(targetRowCenterY))
|
|
168829
169127
|
return null;
|
|
168830
|
-
return
|
|
169128
|
+
return chooseLineClosestToX(candidates.filter(({ metrics }) => isWithinTolerance(metrics.centerY, targetRowCenterY, Math.max(metrics.height / 2, 1))), caretX);
|
|
169129
|
+
}
|
|
169130
|
+
function chooseLineClosestToX(candidates, caretX) {
|
|
169131
|
+
if (candidates.length === 0)
|
|
169132
|
+
return null;
|
|
169133
|
+
let best = null;
|
|
169134
|
+
for (const candidate of candidates) {
|
|
169135
|
+
const horizontalDistance = getHorizontalDistanceToLine(candidate.metrics, caretX);
|
|
169136
|
+
const centerDistance = Math.abs(candidate.metrics.centerX - caretX);
|
|
169137
|
+
if (!best || horizontalDistance < best.horizontalDistance || horizontalDistance === best.horizontalDistance && centerDistance < best.centerDistance)
|
|
169138
|
+
best = {
|
|
169139
|
+
line: candidate.line,
|
|
169140
|
+
horizontalDistance,
|
|
169141
|
+
centerDistance
|
|
169142
|
+
};
|
|
169143
|
+
}
|
|
169144
|
+
return best?.line ?? null;
|
|
169145
|
+
}
|
|
169146
|
+
function getLineMetrics(line) {
|
|
169147
|
+
const rect = line?.getBoundingClientRect?.();
|
|
169148
|
+
if (!rect)
|
|
169149
|
+
return null;
|
|
169150
|
+
const { top: top$1, bottom: bottom$1, left: left$1, right: right$1, height, width } = rect;
|
|
169151
|
+
if (![
|
|
169152
|
+
top$1,
|
|
169153
|
+
bottom$1,
|
|
169154
|
+
left$1,
|
|
169155
|
+
right$1,
|
|
169156
|
+
height,
|
|
169157
|
+
width
|
|
169158
|
+
].every(Number.isFinite))
|
|
169159
|
+
return null;
|
|
169160
|
+
return {
|
|
169161
|
+
top: top$1,
|
|
169162
|
+
bottom: bottom$1,
|
|
169163
|
+
left: left$1,
|
|
169164
|
+
right: right$1,
|
|
169165
|
+
height,
|
|
169166
|
+
centerX: left$1 + width / 2,
|
|
169167
|
+
centerY: top$1 + height / 2
|
|
169168
|
+
};
|
|
169169
|
+
}
|
|
169170
|
+
function isLineInDirection(lineCenterY, currentCenterY, direction) {
|
|
169171
|
+
const epsilon = 1;
|
|
169172
|
+
return direction > 0 ? lineCenterY > currentCenterY + epsilon : lineCenterY < currentCenterY - epsilon;
|
|
169173
|
+
}
|
|
169174
|
+
function isWithinTolerance(value, expected, tolerance) {
|
|
169175
|
+
return Math.abs(value - expected) <= tolerance;
|
|
169176
|
+
}
|
|
169177
|
+
function getRowTolerance(currentMetrics, candidateMetrics) {
|
|
169178
|
+
return Math.max(Math.min(currentMetrics.height, candidateMetrics.height) / 2, 1);
|
|
169179
|
+
}
|
|
169180
|
+
function getHorizontalDistanceToLine(metrics, caretX) {
|
|
169181
|
+
if (caretX < metrics.left)
|
|
169182
|
+
return metrics.left - caretX;
|
|
169183
|
+
if (caretX > metrics.right)
|
|
169184
|
+
return caretX - metrics.right;
|
|
169185
|
+
return 0;
|
|
168831
169186
|
}
|
|
168832
169187
|
function getAttributesDiff(objectA = {}, objectB = {}, ignoreKeys = []) {
|
|
168833
169188
|
const diff = {
|
|
@@ -210878,7 +211233,7 @@ var Node$13 = class Node$14 {
|
|
|
210878
211233
|
insideH: borderSpec,
|
|
210879
211234
|
insideV: borderSpec
|
|
210880
211235
|
};
|
|
210881
|
-
}, ZERO_WIDTH_SPACE = "", ROW_START_TO_TEXT_OFFSET = 3, CELL_TO_TEXT_OFFSET = 2, normalizeHeaderAttrsForBodyCell = (attrs) => {
|
|
211236
|
+
}, TABLE_CELL_ROLES, TableBoundaryNavigationPluginKey, ZERO_WIDTH_SPACE = "", ROW_START_TO_TEXT_OFFSET = 3, CELL_TO_TEXT_OFFSET = 2, normalizeHeaderAttrsForBodyCell = (attrs) => {
|
|
210882
211237
|
if (attrs?.borders !== null)
|
|
210883
211238
|
return attrs;
|
|
210884
211239
|
const nextAttrs = { ...attrs };
|
|
@@ -231035,7 +231390,7 @@ var Node$13 = class Node$14 {
|
|
|
231035
231390
|
return;
|
|
231036
231391
|
console.log(...args$1);
|
|
231037
231392
|
}, 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;
|
|
231038
|
-
var
|
|
231393
|
+
var init_src_D389XrYP_es = __esm(() => {
|
|
231039
231394
|
init_rolldown_runtime_B2q5OVn9_es();
|
|
231040
231395
|
init_SuperConverter_Cukh7tk8_es();
|
|
231041
231396
|
init_jszip_ChlR43oI_es();
|
|
@@ -234943,6 +235298,8 @@ ${err.toString()}`);
|
|
|
234943
235298
|
} };
|
|
234944
235299
|
}
|
|
234945
235300
|
});
|
|
235301
|
+
TABLE_CELL_ROLES = new Set(["cell", "header_cell"]);
|
|
235302
|
+
TableBoundaryNavigationPluginKey = new PluginKey("tableBoundaryNavigation");
|
|
234946
235303
|
Table = Node$13.create({
|
|
234947
235304
|
name: "table",
|
|
234948
235305
|
content: "tableRow+",
|
|
@@ -235119,7 +235476,7 @@ ${err.toString()}`);
|
|
|
235119
235476
|
return true;
|
|
235120
235477
|
}).run();
|
|
235121
235478
|
},
|
|
235122
|
-
insertTable: ({ rows = 3, cols = 3, withHeaderRow = false, columnWidths = null } = {}) => ({ tr, dispatch, editor }) => {
|
|
235479
|
+
insertTable: ({ rows = 3, cols = 3, withHeaderRow = false, columnWidths = null } = {}) => ({ tr, dispatch, editor, state }) => {
|
|
235123
235480
|
const widths = columnWidths ?? computeColumnWidths(editor, cols);
|
|
235124
235481
|
const resolved = normalizeNewTableAttrs(editor);
|
|
235125
235482
|
const tableAttrs = {
|
|
@@ -235129,10 +235486,34 @@ ${err.toString()}`);
|
|
|
235129
235486
|
};
|
|
235130
235487
|
const node3 = createTable(editor.schema, rows, cols, withHeaderRow, null, widths, tableAttrs);
|
|
235131
235488
|
if (dispatch) {
|
|
235132
|
-
let offset$1
|
|
235133
|
-
|
|
235134
|
-
|
|
235135
|
-
|
|
235489
|
+
let offset$1;
|
|
235490
|
+
let replaceRange2 = undefined;
|
|
235491
|
+
if (tr.selection.$from.depth === 0) {
|
|
235492
|
+
offset$1 = tr.selection.from;
|
|
235493
|
+
replaceRange2 = {
|
|
235494
|
+
from: tr.selection.from,
|
|
235495
|
+
to: tr.selection.to
|
|
235496
|
+
};
|
|
235497
|
+
} else {
|
|
235498
|
+
offset$1 = tr.selection.$from.end() + 1;
|
|
235499
|
+
const paragraphDepth = tr.selection.$from.parent?.type?.name === "run" ? tr.selection.$from.depth - 1 : tr.selection.$from.depth;
|
|
235500
|
+
const paragraph2 = tr.selection.$from.node(paragraphDepth);
|
|
235501
|
+
const isTopLevelParagraph = paragraphDepth === 1;
|
|
235502
|
+
const isEmptyParagraph = paragraph2.type.name === "paragraph" && paragraph2.textContent === "";
|
|
235503
|
+
if (isTopLevelParagraph && isEmptyParagraph) {
|
|
235504
|
+
offset$1 = tr.selection.$from.before(paragraphDepth);
|
|
235505
|
+
replaceRange2 = {
|
|
235506
|
+
from: tr.selection.$from.before(paragraphDepth),
|
|
235507
|
+
to: tr.selection.$from.after(paragraphDepth)
|
|
235508
|
+
};
|
|
235509
|
+
} else if (tr.selection.$from.parent?.type?.name === "run")
|
|
235510
|
+
offset$1 = tr.selection.$from.after(paragraphDepth);
|
|
235511
|
+
}
|
|
235512
|
+
const { inserted } = insertTopLevelTableWithSeparators(tr, state.doc, offset$1, node3, replaceRange2);
|
|
235513
|
+
if (!inserted)
|
|
235514
|
+
return false;
|
|
235515
|
+
const selectionPos = getFirstTableCellTextPos(offset$1, node3);
|
|
235516
|
+
tr.scrollIntoView().setSelection(TextSelection2.near(tr.doc.resolve(selectionPos)));
|
|
235136
235517
|
}
|
|
235137
235518
|
return true;
|
|
235138
235519
|
},
|
|
@@ -235172,30 +235553,9 @@ ${err.toString()}`);
|
|
|
235172
235553
|
};
|
|
235173
235554
|
const tableNode = tableType.createChecked(tableAttrs, rowNodes);
|
|
235174
235555
|
if (dispatch) {
|
|
235175
|
-
const
|
|
235176
|
-
|
|
235177
|
-
|
|
235178
|
-
sdBlockId: v4_default(),
|
|
235179
|
-
paraId: generateDocxHexId()
|
|
235180
|
-
};
|
|
235181
|
-
return state.schema.nodes.paragraph.createAndFill(attrs);
|
|
235182
|
-
};
|
|
235183
|
-
if (sep.before || sep.after) {
|
|
235184
|
-
const nodes = [];
|
|
235185
|
-
if (sep.before) {
|
|
235186
|
-
const s2 = makeSep();
|
|
235187
|
-
if (s2)
|
|
235188
|
-
nodes.push(s2);
|
|
235189
|
-
}
|
|
235190
|
-
nodes.push(tableNode);
|
|
235191
|
-
if (sep.after) {
|
|
235192
|
-
const s2 = makeSep();
|
|
235193
|
-
if (s2)
|
|
235194
|
-
nodes.push(s2);
|
|
235195
|
-
}
|
|
235196
|
-
tr.insert(pos, Fragment.from(nodes));
|
|
235197
|
-
} else
|
|
235198
|
-
tr.insert(pos, tableNode);
|
|
235556
|
+
const { inserted } = insertTopLevelTableWithSeparators(tr, state.doc, pos, tableNode);
|
|
235557
|
+
if (!inserted)
|
|
235558
|
+
return false;
|
|
235199
235559
|
tr.setMeta("inputType", "programmatic");
|
|
235200
235560
|
if (tracked === true)
|
|
235201
235561
|
tr.setMeta("forceTrackChanges", true);
|
|
@@ -235524,6 +235884,7 @@ ${err.toString()}`);
|
|
|
235524
235884
|
View: createTableView({ editor: this.editor })
|
|
235525
235885
|
})] : [],
|
|
235526
235886
|
tableEditing({ allowTableNodeSelection: this.options.allowTableNodeSelection }),
|
|
235887
|
+
createTableBoundaryNavigationPlugin(),
|
|
235527
235888
|
(() => {
|
|
235528
235889
|
let initialScanDone = false;
|
|
235529
235890
|
return new Plugin({
|
|
@@ -264336,7 +264697,7 @@ var init_zipper_DqXT7uTa_es = __esm(() => {
|
|
|
264336
264697
|
|
|
264337
264698
|
// ../../packages/superdoc/dist/super-editor.es.js
|
|
264338
264699
|
var init_super_editor_es = __esm(() => {
|
|
264339
|
-
|
|
264700
|
+
init_src_D389XrYP_es();
|
|
264340
264701
|
init_SuperConverter_Cukh7tk8_es();
|
|
264341
264702
|
init_jszip_ChlR43oI_es();
|
|
264342
264703
|
init_xml_js_BtmJ6bNs_es();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdoc-dev/cli",
|
|
3
|
-
"version": "0.3.0-next.
|
|
3
|
+
"version": "0.3.0-next.55",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"superdoc": "./dist/index.js"
|
|
@@ -22,19 +22,19 @@
|
|
|
22
22
|
"typescript": "^5.9.2",
|
|
23
23
|
"@superdoc/document-api": "0.0.1",
|
|
24
24
|
"@superdoc/super-editor": "0.0.1",
|
|
25
|
-
"
|
|
26
|
-
"superdoc": "
|
|
25
|
+
"superdoc": "1.20.0",
|
|
26
|
+
"@superdoc/pm-adapter": "0.0.0"
|
|
27
27
|
},
|
|
28
28
|
"module": "src/index.ts",
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"access": "public"
|
|
31
31
|
},
|
|
32
32
|
"optionalDependencies": {
|
|
33
|
-
"@superdoc-dev/cli-darwin-arm64": "0.3.0-next.
|
|
34
|
-
"@superdoc-dev/cli-darwin-x64": "0.3.0-next.
|
|
35
|
-
"@superdoc-dev/cli-linux-
|
|
36
|
-
"@superdoc-dev/cli-linux-
|
|
37
|
-
"@superdoc-dev/cli-windows-x64": "0.3.0-next.
|
|
33
|
+
"@superdoc-dev/cli-darwin-arm64": "0.3.0-next.55",
|
|
34
|
+
"@superdoc-dev/cli-darwin-x64": "0.3.0-next.55",
|
|
35
|
+
"@superdoc-dev/cli-linux-x64": "0.3.0-next.55",
|
|
36
|
+
"@superdoc-dev/cli-linux-arm64": "0.3.0-next.55",
|
|
37
|
+
"@superdoc-dev/cli-windows-x64": "0.3.0-next.55"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
40
|
"predev": "node scripts/ensure-superdoc-build.js",
|