@superdoc-dev/cli 0.7.0-next.35 → 0.7.0-next.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +209 -31
  2. package/package.json +8 -8
package/dist/index.js CHANGED
@@ -205830,7 +205830,7 @@ var init_remark_gfm_eZN6yzWQ_es = __esm(() => {
205830
205830
  init_remark_gfm_BhnWr3yf_es();
205831
205831
  });
205832
205832
 
205833
- // ../../packages/superdoc/dist/chunks/src-CKSsojHL.es.js
205833
+ // ../../packages/superdoc/dist/chunks/src-j2qoSUF1.es.js
205834
205834
  function deleteProps(obj, propOrProps) {
205835
205835
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
205836
205836
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -207576,33 +207576,137 @@ function createStructuredContentLockPlugin() {
207576
207576
  }
207577
207577
  });
207578
207578
  }
207579
+ function needsEditableSlot(node3, side) {
207580
+ if (!node3)
207581
+ return true;
207582
+ const name = node3.type.name;
207583
+ if (name === "hardBreak" || name === "lineBreak" || name === "structuredContent")
207584
+ return true;
207585
+ if (name === "run")
207586
+ return !(side === "before" ? node3.lastChild?.isText : node3.firstChild?.isText);
207587
+ return false;
207588
+ }
207589
+ function applyEditableSlotAtInlineBoundary(tr, pos, direction) {
207590
+ const clampedPos = Math.max(0, Math.min(pos, tr.doc.content.size));
207591
+ if (direction === "before") {
207592
+ if (!needsEditableSlot(tr.doc.resolve(clampedPos).nodeBefore, "before"))
207593
+ return tr.setSelection(TextSelection.create(tr.doc, clampedPos));
207594
+ tr.insertText("​", clampedPos);
207595
+ return tr.setSelection(TextSelection.create(tr.doc, clampedPos + 1));
207596
+ }
207597
+ if (!needsEditableSlot(tr.doc.nodeAt(clampedPos), "after"))
207598
+ return tr.setSelection(TextSelection.create(tr.doc, clampedPos));
207599
+ tr.insertText("​", clampedPos);
207600
+ return tr.setSelection(TextSelection.create(tr.doc, clampedPos + 1));
207601
+ }
207579
207602
  function createStructuredContentSelectPlugin(editor) {
207580
- return new Plugin({ appendTransaction(transactions, oldState, newState) {
207581
- if (editor?.options?.documentMode === "viewing")
207582
- return null;
207583
- const { selection } = newState;
207584
- if (!selection.empty)
207585
- return null;
207586
- if (oldState.selection.eq(newState.selection))
207587
- return null;
207588
- if (transactions.some((tr) => tr.docChanged))
207589
- return null;
207590
- const $pos = selection.$from;
207591
- for (let d = $pos.depth;d > 0; d--)
207592
- if ($pos.node(d).type.name === "structuredContent") {
207603
+ return new Plugin({
207604
+ props: { handleKeyDown(view, event) {
207605
+ if (editor?.options?.documentMode === "viewing")
207606
+ return false;
207607
+ if (event.key !== "ArrowRight" && event.key !== "ArrowLeft")
207608
+ return false;
207609
+ if (event.shiftKey || event.altKey || event.ctrlKey || event.metaKey)
207610
+ return false;
207611
+ const { state } = view;
207612
+ const { selection } = state;
207613
+ const resolveBoundaryExit = ($pos) => {
207614
+ for (let depth = $pos.depth;depth > 0; depth -= 1) {
207615
+ const node3 = $pos.node(depth);
207616
+ if (node3.type.name !== "structuredContent")
207617
+ continue;
207618
+ const contentFrom = $pos.start(depth);
207619
+ const contentTo = $pos.end(depth);
207620
+ const nodePos = $pos.before(depth);
207621
+ const beforePos = nodePos;
207622
+ const afterPos = nodePos + node3.nodeSize;
207623
+ if (selection.empty) {
207624
+ if (event.key === "ArrowRight" && selection.from >= contentTo - 1)
207625
+ return afterPos;
207626
+ if (event.key === "ArrowLeft" && selection.from <= contentFrom + 1)
207627
+ return beforePos;
207628
+ return null;
207629
+ }
207630
+ if (!(selection.from === contentFrom && selection.to === contentTo))
207631
+ return null;
207632
+ if (event.key === "ArrowRight")
207633
+ return afterPos;
207634
+ if (event.key === "ArrowLeft")
207635
+ return beforePos;
207636
+ return null;
207637
+ }
207638
+ return null;
207639
+ };
207640
+ const nextPos = resolveBoundaryExit(selection.$from);
207641
+ if (nextPos == null)
207642
+ return false;
207643
+ try {
207644
+ const direction = event.key === "ArrowLeft" ? "before" : "after";
207645
+ const tr = applyEditableSlotAtInlineBoundary(state.tr, nextPos, direction);
207646
+ view.dispatch(tr);
207647
+ event.preventDefault();
207648
+ return true;
207649
+ } catch {
207650
+ return false;
207651
+ }
207652
+ } },
207653
+ appendTransaction(transactions, oldState, newState) {
207654
+ if (editor?.options?.documentMode === "viewing")
207655
+ return null;
207656
+ const { selection } = newState;
207657
+ if (oldState.selection.eq(newState.selection))
207658
+ return null;
207659
+ if (transactions.some((tr) => tr.docChanged))
207660
+ return null;
207661
+ if (!selection.empty) {
207662
+ let selectedSdt = null;
207663
+ newState.doc.descendants((node3, pos) => {
207664
+ if (node3.type.name !== "structuredContent")
207665
+ return true;
207666
+ const contentFrom = pos + 1;
207667
+ const contentTo = pos + node3.nodeSize - 1;
207668
+ if (!(selection.from <= contentFrom && selection.to >= contentTo))
207669
+ return true;
207670
+ selectedSdt = {
207671
+ node: node3,
207672
+ pos,
207673
+ contentFrom,
207674
+ contentTo
207675
+ };
207676
+ return false;
207677
+ });
207678
+ if (selectedSdt) {
207679
+ const oldAtTrailingBoundary = oldState.selection.empty && oldState.selection.from >= selectedSdt.pos + selectedSdt.node.nodeSize;
207680
+ const oldAtLeadingBoundary = oldState.selection.empty && oldState.selection.from <= selectedSdt.pos;
207681
+ if (oldAtTrailingBoundary)
207682
+ return applyEditableSlotAtInlineBoundary(newState.tr, selectedSdt.pos + selectedSdt.node.nodeSize, "after");
207683
+ if (oldAtLeadingBoundary)
207684
+ return applyEditableSlotAtInlineBoundary(newState.tr, selectedSdt.pos, "before");
207685
+ }
207686
+ return null;
207687
+ }
207688
+ if (!selection.empty)
207689
+ return null;
207690
+ const $pos = selection.$from;
207691
+ const old$pos = oldState.selection.$from;
207692
+ for (let d = $pos.depth;d > 0; d--) {
207693
+ if ($pos.node(d).type.name !== "structuredContent")
207694
+ continue;
207593
207695
  const sdtStart = $pos.before(d);
207594
207696
  const contentFrom = $pos.start(d);
207595
207697
  const contentTo = $pos.end(d);
207698
+ if (selection.from <= contentFrom || selection.from >= contentTo)
207699
+ return null;
207596
207700
  if (contentFrom === contentTo)
207597
207701
  return null;
207598
- const old$pos = oldState.selection.$from;
207599
207702
  for (let od = old$pos.depth;od > 0; od--)
207600
207703
  if (old$pos.node(od).type.name === "structuredContent" && old$pos.before(od) === sdtStart)
207601
207704
  return null;
207602
207705
  return newState.tr.setSelection(TextSelection.create(newState.doc, contentFrom, contentTo));
207603
207706
  }
207604
- return null;
207605
- } });
207707
+ return null;
207708
+ }
207709
+ });
207606
207710
  }
207607
207711
  function getStructuredContentTagsById(idOrIds, state) {
207608
207712
  return findChildren$1(state.doc, (node3) => {
@@ -253786,6 +253890,25 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
253786
253890
  const maxReserve = computeMaxFootnoteReserve(layoutForPages, pageIndex, baseReserve);
253787
253891
  const columns = pageColumns$1.get(pageIndex);
253788
253892
  const columnCount = Math.max(1, Math.floor(columns?.count ?? 1));
253893
+ let demand = 0;
253894
+ for (let columnIndex = 0;columnIndex < columnCount; columnIndex += 1) {
253895
+ const ids = idsByColumn$1.get(pageIndex)?.get(columnIndex) ?? [];
253896
+ let columnDemand = 0;
253897
+ ids.forEach((id2, idx) => {
253898
+ const ranges = rangesByFootnoteId.get(id2) ?? [];
253899
+ let rangesHeight = 0;
253900
+ ranges.forEach((range) => {
253901
+ const spacingAfter = "spacingAfter" in range ? range.spacingAfter ?? 0 : 0;
253902
+ rangesHeight += range.height + spacingAfter;
253903
+ });
253904
+ columnDemand += rangesHeight + (idx > 0 ? safeGap : 0);
253905
+ });
253906
+ if (columnDemand > 0)
253907
+ columnDemand += safeSeparatorSpacingBefore + safeDividerHeight + safeTopPadding;
253908
+ if (columnDemand > demand)
253909
+ demand = columnDemand;
253910
+ }
253911
+ const placementCeiling = demand > 0 ? Math.min(Math.ceil(demand), maxReserve) : maxReserve;
253789
253912
  const pendingForPage = /* @__PURE__ */ new Map;
253790
253913
  pendingByColumn.forEach((entries2, columnIndex) => {
253791
253914
  const targetIndex = columnIndex < columnCount ? columnIndex : Math.max(0, columnCount - 1);
@@ -253811,7 +253934,7 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
253811
253934
  const isFirstSlice = columnSlices.length === 0;
253812
253935
  const overhead = isFirstSlice ? (isFirstSlice ? safeSeparatorSpacingBefore : 0) + (isFirstSlice ? isContinuation ? continuationDividerHeight : safeDividerHeight : 0) + safeTopPadding : 0;
253813
253936
  const gapBefore = !isFirstSlice ? safeGap : 0;
253814
- const { slice: slice2, remainingRanges } = fitFootnoteContent(id2, ranges, Math.max(0, maxReserve - usedHeight - overhead - gapBefore), pageIndex, columnIndex, isContinuation, measuresById$1, isFirstSlice && maxReserve > 0);
253937
+ const { slice: slice2, remainingRanges } = fitFootnoteContent(id2, ranges, Math.max(0, placementCeiling - usedHeight - overhead - gapBefore), pageIndex, columnIndex, isContinuation, measuresById$1, isFirstSlice && placementCeiling > 0);
253815
253938
  if (slice2.ranges.length === 0)
253816
253939
  return {
253817
253940
  placed: false,
@@ -254162,7 +254285,7 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
254162
254285
  let reserves = plan.reserves;
254163
254286
  if (reserves.some((h$2) => h$2 > 0)) {
254164
254287
  let reservesStabilized = false;
254165
- const seenReserveKeys = new Set([reserves.join(",")]);
254288
+ const seenReserveVectors = [reserves.slice()];
254166
254289
  for (let pass = 0;pass < MAX_FOOTNOTE_LAYOUT_PASSES; pass += 1) {
254167
254290
  layout = relayout(reserves);
254168
254291
  ({ columns: pageColumns, idsByColumn } = resolveFootnoteAssignments(layout));
@@ -254175,9 +254298,22 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
254175
254298
  break;
254176
254299
  }
254177
254300
  const nextKey = nextReserves.join(",");
254178
- if (seenReserveKeys.has(nextKey))
254301
+ if (seenReserveVectors.some((v) => v.join(",") === nextKey)) {
254302
+ const allVectors = [...seenReserveVectors, nextReserves];
254303
+ const mergedLength = Math.max(...allVectors.map((v) => v.length));
254304
+ const merged = new Array(mergedLength).fill(0);
254305
+ for (const vec of allVectors)
254306
+ for (let i4 = 0;i4 < mergedLength; i4 += 1)
254307
+ if ((vec[i4] ?? 0) > merged[i4])
254308
+ merged[i4] = vec[i4];
254309
+ reserves = merged;
254310
+ layout = relayout(reserves);
254311
+ ({ columns: pageColumns, idsByColumn } = resolveFootnoteAssignments(layout));
254312
+ ({ measuresById } = await measureFootnoteBlocks(collectFootnoteIdsByColumn(idsByColumn)));
254313
+ plan = computeFootnoteLayoutPlan(layout, idsByColumn, measuresById, reserves, pageColumns);
254179
254314
  break;
254180
- seenReserveKeys.add(nextKey);
254315
+ }
254316
+ seenReserveVectors.push(nextReserves.slice());
254181
254317
  if (pass < MAX_FOOTNOTE_LAYOUT_PASSES - 1)
254182
254318
  reserves = nextReserves;
254183
254319
  }
@@ -254186,11 +254322,25 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
254186
254322
  let { columns: finalPageColumns, idsByColumn: finalIdsByColumn } = resolveFootnoteAssignments(layout);
254187
254323
  let { blocks: finalBlocks, measuresById: finalMeasuresById } = await measureFootnoteBlocks(collectFootnoteIdsByColumn(finalIdsByColumn));
254188
254324
  let finalPlan = computeFootnoteLayoutPlan(layout, finalIdsByColumn, finalMeasuresById, reserves, finalPageColumns);
254189
- const finalReserves = finalPlan.reserves;
254190
254325
  let reservesAppliedToLayout = reserves;
254191
- if (finalReserves.length !== reserves.length || finalReserves.some((h$2, i4) => (reserves[i4] ?? 0) !== h$2) || reserves.some((h$2, i4) => (finalReserves[i4] ?? 0) !== h$2)) {
254192
- layout = relayout(finalReserves);
254193
- reservesAppliedToLayout = finalReserves;
254326
+ const MAX_POST_PASSES = 3;
254327
+ for (let postPass = 0;postPass < MAX_POST_PASSES; postPass += 1) {
254328
+ const target = reservesAppliedToLayout.slice();
254329
+ const planReserves = finalPlan.reserves;
254330
+ const len3 = Math.max(target.length, planReserves.length);
254331
+ let needsRelayout = false;
254332
+ for (let i4 = 0;i4 < len3; i4 += 1) {
254333
+ const applied = target[i4] ?? 0;
254334
+ const needed = planReserves[i4] ?? 0;
254335
+ if (needed > applied) {
254336
+ target[i4] = needed;
254337
+ needsRelayout = true;
254338
+ }
254339
+ }
254340
+ if (!needsRelayout)
254341
+ break;
254342
+ layout = relayout(target);
254343
+ reservesAppliedToLayout = target;
254194
254344
  ({ columns: finalPageColumns, idsByColumn: finalIdsByColumn } = resolveFootnoteAssignments(layout));
254195
254345
  ({ blocks: finalBlocks, measuresById: finalMeasuresById } = await measureFootnoteBlocks(collectFootnoteIdsByColumn(finalIdsByColumn)));
254196
254346
  finalPlan = computeFootnoteLayoutPlan(layout, finalIdsByColumn, finalMeasuresById, reservesAppliedToLayout, finalPageColumns);
@@ -259333,6 +259483,17 @@ function readPmRange(el) {
259333
259483
  end: Number(el.dataset.pmEnd ?? "NaN")
259334
259484
  };
259335
259485
  }
259486
+ function getInlineSdtWrapperBoundaryPos(spanEl, side) {
259487
+ if (!(spanEl instanceof HTMLElement))
259488
+ return null;
259489
+ const wrapper = spanEl.closest(`.${CLASS.inlineSdtWrapper}`);
259490
+ if (!wrapper)
259491
+ return null;
259492
+ const { start: start$1, end: end$1 } = readPmRange(wrapper);
259493
+ if (!Number.isFinite(start$1) || !Number.isFinite(end$1))
259494
+ return null;
259495
+ return side === "before" ? start$1 - 1 : end$1 + 1;
259496
+ }
259336
259497
  function getClickableSpans(lineEl) {
259337
259498
  return Array.from(lineEl.querySelectorAll("span, a")).filter((el) => el.dataset.pmStart !== undefined && el.dataset.pmEnd !== undefined && !el.classList.contains(CLASS.inlineSdtWrapper));
259338
259499
  }
@@ -259448,9 +259609,9 @@ function resolvePositionInLine(lineEl, lineStart, lineEnd, spanEls, viewX) {
259448
259609
  const visualLeft = Math.min(...boundsRects.map((r$1) => r$1.left));
259449
259610
  const visualRight = Math.max(...boundsRects.map((r$1) => r$1.right));
259450
259611
  if (viewX <= visualLeft)
259451
- return rtl ? lineEnd : lineStart;
259612
+ return getInlineSdtWrapperBoundaryPos(rtl ? spanEls[spanEls.length - 1] : spanEls[0], rtl ? "after" : "before") ?? (rtl ? lineEnd : lineStart);
259452
259613
  if (viewX >= visualRight)
259453
- return rtl ? lineStart : lineEnd;
259614
+ return getInlineSdtWrapperBoundaryPos(rtl ? spanEls[0] : spanEls[spanEls.length - 1], rtl ? "before" : "after") ?? (rtl ? lineStart : lineEnd);
259454
259615
  const targetEl = findSpanAtX(spanEls, viewX);
259455
259616
  if (!targetEl)
259456
259617
  return lineStart;
@@ -287202,15 +287363,32 @@ menclose::after {
287202
287363
  try {
287203
287364
  const sdtBlock = clickDepth === 1 ? this.#findStructuredContentBlockAtPos(doc$12, hit.pos) : null;
287204
287365
  let nextSelection;
287366
+ let inlineSdtBoundaryPos = null;
287367
+ let inlineSdtBoundaryDirection = null;
287205
287368
  const insideTableInSdt = !!sdtBlock && this.#isInsideTableWithinStructuredContentBlock(doc$12, hit.pos, sdtBlock.pos);
287206
287369
  if (sdtBlock && !insideTableInSdt)
287207
287370
  nextSelection = NodeSelection.create(doc$12, sdtBlock.pos);
287208
287371
  else {
287209
- nextSelection = TextSelection.create(doc$12, hit.pos);
287372
+ const inlineSdt = clickDepth === 1 ? this.#findStructuredContentInlineAtPos(doc$12, hit.pos) : null;
287373
+ if (inlineSdt && hit.pos >= inlineSdt.end) {
287374
+ const afterInlineSdt = inlineSdt.pos + inlineSdt.node.nodeSize;
287375
+ inlineSdtBoundaryPos = afterInlineSdt;
287376
+ inlineSdtBoundaryDirection = "after";
287377
+ nextSelection = TextSelection.create(doc$12, afterInlineSdt);
287378
+ } else if (inlineSdt && hit.pos <= inlineSdt.start) {
287379
+ inlineSdtBoundaryPos = inlineSdt.pos;
287380
+ inlineSdtBoundaryDirection = "before";
287381
+ nextSelection = TextSelection.create(doc$12, inlineSdt.pos);
287382
+ } else
287383
+ nextSelection = TextSelection.create(doc$12, hit.pos);
287210
287384
  if (!nextSelection.$from.parent.inlineContent)
287211
287385
  nextSelection = Selection.near(doc$12.resolve(hit.pos), 1);
287212
287386
  }
287213
- const tr = editor.state.tr.setSelection(nextSelection);
287387
+ let tr = editor.state.tr.setSelection(nextSelection);
287388
+ if (inlineSdtBoundaryPos != null && inlineSdtBoundaryDirection) {
287389
+ tr = applyEditableSlotAtInlineBoundary(tr, inlineSdtBoundaryPos, inlineSdtBoundaryDirection);
287390
+ nextSelection = tr.selection;
287391
+ }
287214
287392
  if (nextSelection instanceof TextSelection && nextSelection.empty && editor.state.storedMarks)
287215
287393
  tr.setStoredMarks(editor.state.storedMarks);
287216
287394
  editor.view?.dispatch(tr);
@@ -290307,7 +290485,7 @@ menclose::after {
290307
290485
  return;
290308
290486
  console.log(...args$1);
290309
290487
  }, 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;
290310
- var init_src_CKSsojHL_es = __esm(() => {
290488
+ var init_src_j2qoSUF1_es = __esm(() => {
290311
290489
  init_rolldown_runtime_Bg48TavK_es();
290312
290490
  init_SuperConverter_D8HLuwGQ_es();
290313
290491
  init_jszip_C49i9kUs_es();
@@ -325181,7 +325359,7 @@ var init_zipper_DbkgrypV_es = __esm(() => {
325181
325359
 
325182
325360
  // ../../packages/superdoc/dist/super-editor.es.js
325183
325361
  var init_super_editor_es = __esm(() => {
325184
- init_src_CKSsojHL_es();
325362
+ init_src_j2qoSUF1_es();
325185
325363
  init_SuperConverter_D8HLuwGQ_es();
325186
325364
  init_jszip_C49i9kUs_es();
325187
325365
  init_xml_js_CqGKpaft_es();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/cli",
3
- "version": "0.7.0-next.35",
3
+ "version": "0.7.0-next.37",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "superdoc": "./dist/index.js"
@@ -25,20 +25,20 @@
25
25
  "@types/ws": "^8.5.13",
26
26
  "typescript": "^5.9.2",
27
27
  "@superdoc/document-api": "0.0.1",
28
- "@superdoc/pm-adapter": "0.0.0",
29
28
  "@superdoc/super-editor": "0.0.1",
30
- "superdoc": "1.26.0"
29
+ "superdoc": "1.26.0",
30
+ "@superdoc/pm-adapter": "0.0.0"
31
31
  },
32
32
  "module": "src/index.ts",
33
33
  "publishConfig": {
34
34
  "access": "public"
35
35
  },
36
36
  "optionalDependencies": {
37
- "@superdoc-dev/cli-darwin-arm64": "0.7.0-next.35",
38
- "@superdoc-dev/cli-darwin-x64": "0.7.0-next.35",
39
- "@superdoc-dev/cli-linux-x64": "0.7.0-next.35",
40
- "@superdoc-dev/cli-linux-arm64": "0.7.0-next.35",
41
- "@superdoc-dev/cli-windows-x64": "0.7.0-next.35"
37
+ "@superdoc-dev/cli-darwin-arm64": "0.7.0-next.37",
38
+ "@superdoc-dev/cli-darwin-x64": "0.7.0-next.37",
39
+ "@superdoc-dev/cli-linux-x64": "0.7.0-next.37",
40
+ "@superdoc-dev/cli-linux-arm64": "0.7.0-next.37",
41
+ "@superdoc-dev/cli-windows-x64": "0.7.0-next.37"
42
42
  },
43
43
  "scripts": {
44
44
  "predev": "node scripts/ensure-superdoc-build.js",