@superdoc-dev/cli 0.7.0-next.36 → 0.7.0-next.38

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 +227 -41
  2. package/package.json +7 -7
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-nnj-4GhR.es.js
205833
+ // ../../packages/superdoc/dist/chunks/src-_aJt3Hgw.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) => {
@@ -259379,6 +259483,17 @@ function readPmRange(el) {
259379
259483
  end: Number(el.dataset.pmEnd ?? "NaN")
259380
259484
  };
259381
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
+ }
259382
259497
  function getClickableSpans(lineEl) {
259383
259498
  return Array.from(lineEl.querySelectorAll("span, a")).filter((el) => el.dataset.pmStart !== undefined && el.dataset.pmEnd !== undefined && !el.classList.contains(CLASS.inlineSdtWrapper));
259384
259499
  }
@@ -259494,9 +259609,9 @@ function resolvePositionInLine(lineEl, lineStart, lineEnd, spanEls, viewX) {
259494
259609
  const visualLeft = Math.min(...boundsRects.map((r$1) => r$1.left));
259495
259610
  const visualRight = Math.max(...boundsRects.map((r$1) => r$1.right));
259496
259611
  if (viewX <= visualLeft)
259497
- return rtl ? lineEnd : lineStart;
259612
+ return getInlineSdtWrapperBoundaryPos(rtl ? spanEls[spanEls.length - 1] : spanEls[0], rtl ? "after" : "before") ?? (rtl ? lineEnd : lineStart);
259498
259613
  if (viewX >= visualRight)
259499
- return rtl ? lineStart : lineEnd;
259614
+ return getInlineSdtWrapperBoundaryPos(rtl ? spanEls[0] : spanEls[spanEls.length - 1], rtl ? "before" : "after") ?? (rtl ? lineStart : lineEnd);
259500
259615
  const targetEl = findSpanAtX(spanEls, viewX);
259501
259616
  if (!targetEl)
259502
259617
  return lineStart;
@@ -268768,20 +268883,39 @@ var Node$13 = class Node$14 {
268768
268883
  if (!insertedMark && !deletionMark && !formatMark)
268769
268884
  return;
268770
268885
  const newTrackedChanges = { ...trackedChanges };
268771
- let id2 = insertedMark?.attrs?.id || deletionMark?.attrs?.id || formatMark?.attrs?.id;
268772
- if (!id2)
268886
+ const insertedId = insertedMark?.attrs?.id ?? null;
268887
+ const deletionId = deletionMark?.attrs?.id ?? null;
268888
+ const formatId = formatMark?.attrs?.id ?? null;
268889
+ const primaryId = insertedId || deletionId || formatId;
268890
+ if (!primaryId)
268773
268891
  return trackedChanges;
268774
- let isNewChange = false;
268775
- if (!newTrackedChanges[id2]) {
268776
- newTrackedChanges[id2] = {};
268777
- isNewChange = true;
268778
- }
268779
- if (insertedMark)
268780
- newTrackedChanges[id2].insertion = id2;
268781
- if (deletionMark)
268782
- newTrackedChanges[id2].deletion = deletionMark.attrs?.id;
268783
- if (formatMark)
268784
- newTrackedChanges[id2].format = formatMark.attrs?.id;
268892
+ const registerTrackedChangeId = (changeId, patch3) => {
268893
+ if (!changeId)
268894
+ return false;
268895
+ const existing = newTrackedChanges[changeId];
268896
+ if (existing) {
268897
+ Object.assign(existing, patch3);
268898
+ return false;
268899
+ }
268900
+ newTrackedChanges[changeId] = { ...patch3 };
268901
+ return true;
268902
+ };
268903
+ const buildTrackedChangePayload = ({ event, marks, nodes: nodes$1, deletionNodes: deletionNodes$1 = [] }) => {
268904
+ if (!marks.insertedMark && !marks.deletionMark && !marks.formatMark)
268905
+ return null;
268906
+ const trackedMarkId = marks.insertedMark?.attrs?.id ?? marks.deletionMark?.attrs?.id ?? marks.formatMark?.attrs?.id ?? null;
268907
+ if (!trackedMarkId)
268908
+ return null;
268909
+ return createOrUpdateTrackedChangeComment({
268910
+ documentId: editor.options.documentId,
268911
+ event,
268912
+ marks,
268913
+ deletionNodes: deletionNodes$1,
268914
+ nodes: nodes$1,
268915
+ newEditorState,
268916
+ trackedChangesForId: getTrackChanges(newEditorState, trackedMarkId)
268917
+ });
268918
+ };
268785
268919
  const { step: step3 } = trackedChangeMeta;
268786
268920
  let nodes = step3?.slice?.content?.content || [];
268787
268921
  if (!nodes.length)
@@ -268791,8 +268925,42 @@ var Node$13 = class Node$14 {
268791
268925
  return false;
268792
268926
  }
268793
268927
  });
268794
- const emitParams = nodes.length > 0 || Boolean(deletionNodes?.length) ? createOrUpdateTrackedChangeComment({
268795
- documentId: editor.options.documentId,
268928
+ const hasCandidateNodes = nodes.length > 0 || Boolean(deletionNodes?.length);
268929
+ if (Boolean(insertedMark && deletionMark) && Boolean(insertedId) && Boolean(deletionId) && insertedId !== deletionId) {
268930
+ const isNewInsertion = registerTrackedChangeId(insertedId, { insertion: insertedId });
268931
+ const isNewDeletion = registerTrackedChangeId(deletionId, { deletion: deletionId });
268932
+ const insertionPayload = hasCandidateNodes ? buildTrackedChangePayload({
268933
+ event: isNewInsertion ? "add" : "update",
268934
+ marks: {
268935
+ insertedMark,
268936
+ deletionMark: null,
268937
+ formatMark: null
268938
+ },
268939
+ deletionNodes: [],
268940
+ nodes
268941
+ }) : null;
268942
+ const deletionPayload = deletionMark && (hasCandidateNodes || getTrackChanges(newEditorState, deletionId).length > 0) ? buildTrackedChangePayload({
268943
+ event: isNewDeletion ? "add" : "update",
268944
+ marks: {
268945
+ insertedMark: null,
268946
+ deletionMark,
268947
+ formatMark: null
268948
+ },
268949
+ deletionNodes,
268950
+ nodes: []
268951
+ }) : null;
268952
+ if (emitCommentEvent && insertionPayload)
268953
+ editor.emit("commentsUpdate", insertionPayload);
268954
+ if (emitCommentEvent && deletionPayload)
268955
+ editor.emit("commentsUpdate", deletionPayload);
268956
+ return newTrackedChanges;
268957
+ }
268958
+ const isNewChange = registerTrackedChangeId(primaryId, {
268959
+ ...insertedMark ? { insertion: primaryId } : {},
268960
+ ...deletionMark ? { deletion: deletionId } : {},
268961
+ ...formatMark ? { format: formatId } : {}
268962
+ });
268963
+ const emitParams = hasCandidateNodes ? buildTrackedChangePayload({
268796
268964
  event: isNewChange ? "add" : "update",
268797
268965
  marks: {
268798
268966
  insertedMark,
@@ -268800,8 +268968,7 @@ var Node$13 = class Node$14 {
268800
268968
  formatMark
268801
268969
  },
268802
268970
  deletionNodes,
268803
- nodes,
268804
- newEditorState
268971
+ nodes
268805
268972
  }) : null;
268806
268973
  if (emitParams && emitCommentEvent)
268807
268974
  editor.emit("commentsUpdate", emitParams);
@@ -268899,7 +269066,9 @@ var Node$13 = class Node$14 {
268899
269066
  const { name: trackedChangeType } = type;
268900
269067
  const { author, authorEmail, authorImage, date, importedAuthor } = attrs;
268901
269068
  const id2 = attrs.id;
268902
- let isReplacement = !!(marks.insertedMark && marks.deletionMark);
269069
+ const insertedMarkId = marks.insertedMark?.attrs?.id ?? null;
269070
+ const deletionMarkId = marks.deletionMark?.attrs?.id ?? null;
269071
+ let isReplacement = Boolean(insertedMarkId && deletionMarkId && insertedMarkId === deletionMarkId);
268903
269072
  if (!isReplacement) {
268904
269073
  const hasInsertMark = trackedChangesWithId.some(({ mark: mark2 }) => mark2.type.name === TrackInsertMarkName);
268905
269074
  const hasDeleteMark = trackedChangesWithId.some(({ mark: mark2 }) => mark2.type.name === TrackDeleteMarkName);
@@ -287248,15 +287417,32 @@ menclose::after {
287248
287417
  try {
287249
287418
  const sdtBlock = clickDepth === 1 ? this.#findStructuredContentBlockAtPos(doc$12, hit.pos) : null;
287250
287419
  let nextSelection;
287420
+ let inlineSdtBoundaryPos = null;
287421
+ let inlineSdtBoundaryDirection = null;
287251
287422
  const insideTableInSdt = !!sdtBlock && this.#isInsideTableWithinStructuredContentBlock(doc$12, hit.pos, sdtBlock.pos);
287252
287423
  if (sdtBlock && !insideTableInSdt)
287253
287424
  nextSelection = NodeSelection.create(doc$12, sdtBlock.pos);
287254
287425
  else {
287255
- nextSelection = TextSelection.create(doc$12, hit.pos);
287426
+ const inlineSdt = clickDepth === 1 ? this.#findStructuredContentInlineAtPos(doc$12, hit.pos) : null;
287427
+ if (inlineSdt && hit.pos >= inlineSdt.end) {
287428
+ const afterInlineSdt = inlineSdt.pos + inlineSdt.node.nodeSize;
287429
+ inlineSdtBoundaryPos = afterInlineSdt;
287430
+ inlineSdtBoundaryDirection = "after";
287431
+ nextSelection = TextSelection.create(doc$12, afterInlineSdt);
287432
+ } else if (inlineSdt && hit.pos <= inlineSdt.start) {
287433
+ inlineSdtBoundaryPos = inlineSdt.pos;
287434
+ inlineSdtBoundaryDirection = "before";
287435
+ nextSelection = TextSelection.create(doc$12, inlineSdt.pos);
287436
+ } else
287437
+ nextSelection = TextSelection.create(doc$12, hit.pos);
287256
287438
  if (!nextSelection.$from.parent.inlineContent)
287257
287439
  nextSelection = Selection.near(doc$12.resolve(hit.pos), 1);
287258
287440
  }
287259
- const tr = editor.state.tr.setSelection(nextSelection);
287441
+ let tr = editor.state.tr.setSelection(nextSelection);
287442
+ if (inlineSdtBoundaryPos != null && inlineSdtBoundaryDirection) {
287443
+ tr = applyEditableSlotAtInlineBoundary(tr, inlineSdtBoundaryPos, inlineSdtBoundaryDirection);
287444
+ nextSelection = tr.selection;
287445
+ }
287260
287446
  if (nextSelection instanceof TextSelection && nextSelection.empty && editor.state.storedMarks)
287261
287447
  tr.setStoredMarks(editor.state.storedMarks);
287262
287448
  editor.view?.dispatch(tr);
@@ -290353,7 +290539,7 @@ menclose::after {
290353
290539
  return;
290354
290540
  console.log(...args$1);
290355
290541
  }, 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;
290356
- var init_src_nnj_4GhR_es = __esm(() => {
290542
+ var init_src__aJt3Hgw_es = __esm(() => {
290357
290543
  init_rolldown_runtime_Bg48TavK_es();
290358
290544
  init_SuperConverter_D8HLuwGQ_es();
290359
290545
  init_jszip_C49i9kUs_es();
@@ -325227,7 +325413,7 @@ var init_zipper_DbkgrypV_es = __esm(() => {
325227
325413
 
325228
325414
  // ../../packages/superdoc/dist/super-editor.es.js
325229
325415
  var init_super_editor_es = __esm(() => {
325230
- init_src_nnj_4GhR_es();
325416
+ init_src__aJt3Hgw_es();
325231
325417
  init_SuperConverter_D8HLuwGQ_es();
325232
325418
  init_jszip_C49i9kUs_es();
325233
325419
  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.36",
3
+ "version": "0.7.0-next.38",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "superdoc": "./dist/index.js"
@@ -25,8 +25,8 @@
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",
29
+ "@superdoc/pm-adapter": "0.0.0",
30
30
  "superdoc": "1.26.0"
31
31
  },
32
32
  "module": "src/index.ts",
@@ -34,11 +34,11 @@
34
34
  "access": "public"
35
35
  },
36
36
  "optionalDependencies": {
37
- "@superdoc-dev/cli-darwin-arm64": "0.7.0-next.36",
38
- "@superdoc-dev/cli-darwin-x64": "0.7.0-next.36",
39
- "@superdoc-dev/cli-windows-x64": "0.7.0-next.36",
40
- "@superdoc-dev/cli-linux-arm64": "0.7.0-next.36",
41
- "@superdoc-dev/cli-linux-x64": "0.7.0-next.36"
37
+ "@superdoc-dev/cli-darwin-arm64": "0.7.0-next.38",
38
+ "@superdoc-dev/cli-darwin-x64": "0.7.0-next.38",
39
+ "@superdoc-dev/cli-windows-x64": "0.7.0-next.38",
40
+ "@superdoc-dev/cli-linux-x64": "0.7.0-next.38",
41
+ "@superdoc-dev/cli-linux-arm64": "0.7.0-next.38"
42
42
  },
43
43
  "scripts": {
44
44
  "predev": "node scripts/ensure-superdoc-build.js",