@superdoc-dev/cli 0.2.0-next.76 → 0.2.0-next.77

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 +276 -135
  2. package/package.json +7 -7
package/dist/index.js CHANGED
@@ -107315,9 +107315,9 @@ var init_remark_gfm_CjV8kaUy_es = __esm(() => {
107315
107315
  init_remark_gfm_z_sDF4ss_es();
107316
107316
  });
107317
107317
 
107318
- // ../../packages/superdoc/dist/chunks/src-C0LpayfV.es.js
107319
- var exports_src_C0LpayfV_es = {};
107320
- __export(exports_src_C0LpayfV_es, {
107318
+ // ../../packages/superdoc/dist/chunks/src-BdKG1LCw.es.js
107319
+ var exports_src_BdKG1LCw_es = {};
107320
+ __export(exports_src_BdKG1LCw_es, {
107321
107321
  zt: () => defineMark,
107322
107322
  z: () => cM,
107323
107323
  yt: () => removeAwarenessStates,
@@ -153718,8 +153718,7 @@ async function getEditorContext(editor, event) {
153718
153718
  const state = editor.state;
153719
153719
  if (!state)
153720
153720
  return null;
153721
- const { from: from$12, to, empty: empty$2 } = state.selection;
153722
- const selectedText = !empty$2 ? state.doc.textBetween(from$12, to) : "";
153721
+ const { from: from$12 } = state.selection;
153723
153722
  let pos = null;
153724
153723
  let node3 = null;
153725
153724
  if (event && typeof event.clientX === "number" && typeof event.clientY === "number") {
@@ -153737,6 +153736,14 @@ async function getEditorContext(editor, event) {
153737
153736
  pos = from$12;
153738
153737
  node3 = state.doc.nodeAt(pos);
153739
153738
  }
153739
+ const selection = getContextSelection({
153740
+ editor,
153741
+ state,
153742
+ pos,
153743
+ event
153744
+ });
153745
+ const hasSelection$1 = hasExpandedSelection(selection);
153746
+ const selectedText = hasSelection$1 ? state.doc.textBetween(selection.from, selection.to) : "";
153740
153747
  const clipboardContent = {
153741
153748
  html: null,
153742
153749
  text: null,
@@ -153772,14 +153779,18 @@ async function getEditorContext(editor, event) {
153772
153779
  state.selection.$head.marks().forEach((mark2) => activeMarks.push(mark2.type.name));
153773
153780
  }
153774
153781
  const isTrackedChange = activeMarks.includes("trackInsert") || activeMarks.includes("trackDelete") || activeMarks.includes("trackFormat");
153775
- const trackedChanges = event && pos !== null ? collectTrackedChangesForContext({
153782
+ const trackedChanges = (event && pos !== null ? hasExpandedSelection(selection) && selectionContainsPos(selection, pos) : hasSelection$1) ? collectTrackedChanges({
153783
+ state,
153784
+ from: selection.from,
153785
+ to: selection.to
153786
+ }) : event && pos !== null ? collectTrackedChangesForContext({
153776
153787
  state,
153777
153788
  pos,
153778
153789
  trackedChangeId
153779
153790
  }) : collectTrackedChanges({
153780
153791
  state,
153781
- from: from$12,
153782
- to
153792
+ from: selection.from,
153793
+ to: selection.to
153783
153794
  });
153784
153795
  const cursorCoords = pos !== null ? editor.coordsAtPos?.(pos) : null;
153785
153796
  const cursorPosition = cursorCoords ? {
@@ -153791,9 +153802,9 @@ async function getEditorContext(editor, event) {
153791
153802
  } : null;
153792
153803
  return {
153793
153804
  selectedText,
153794
- hasSelection: !empty$2,
153795
- selectionStart: from$12,
153796
- selectionEnd: to,
153805
+ hasSelection: hasSelection$1,
153806
+ selectionStart: selection.from,
153807
+ selectionEnd: selection.to,
153797
153808
  isInTable: isInTable$2,
153798
153809
  isInList,
153799
153810
  isInSectionNode,
@@ -153817,6 +153828,20 @@ async function getEditorContext(editor, event) {
153817
153828
  trackedChanges
153818
153829
  };
153819
153830
  }
153831
+ function selectionContainsPos(selection, pos) {
153832
+ return hasExpandedSelection(selection) && Number.isFinite(pos) && pos >= selection.from && pos <= selection.to;
153833
+ }
153834
+ function getContextSelection({ editor, state, pos, event }) {
153835
+ const currentSelection = state.selection;
153836
+ const preservedSelection = editor?.options?.preservedSelection ?? editor?.options?.lastSelection;
153837
+ if (hasExpandedSelection(currentSelection))
153838
+ return currentSelection;
153839
+ if (!hasExpandedSelection(preservedSelection))
153840
+ return currentSelection;
153841
+ if (event)
153842
+ return selectionContainsPos(preservedSelection, pos) ? preservedSelection : currentSelection;
153843
+ return preservedSelection;
153844
+ }
153820
153845
  function computeCanUndo(editor, state) {
153821
153846
  if (typeof editor?.can === "function")
153822
153847
  try {
@@ -153992,10 +154017,11 @@ function getItems(context, customItems = [], includeDefaultItems = true) {
153992
154017
  label: TEXTS.trackChangesAccept,
153993
154018
  isDefault: true,
153994
154019
  action: (editor$1, context$1) => {
153995
- if (context$1?.trackedChangeId)
153996
- editor$1.commands.acceptTrackedChangeById(context$1.trackedChangeId);
153997
- else
153998
- editor$1.commands.acceptTrackedChangeBySelection();
154020
+ editor$1.commands.acceptTrackedChangeFromContextMenu({
154021
+ from: context$1?.selectionStart,
154022
+ to: context$1?.selectionEnd,
154023
+ trackedChangeId: context$1?.trackedChangeId
154024
+ });
153999
154025
  },
154000
154026
  showWhen: (context$1) => {
154001
154027
  const { trigger: trigger$1, isTrackedChange } = context$1;
@@ -154007,10 +154033,11 @@ function getItems(context, customItems = [], includeDefaultItems = true) {
154007
154033
  icon: ICONS.trackChangesReject,
154008
154034
  isDefault: true,
154009
154035
  action: (editor$1, context$1) => {
154010
- if (context$1?.trackedChangeId)
154011
- editor$1.commands.rejectTrackedChangeById(context$1.trackedChangeId);
154012
- else
154013
- editor$1.commands.rejectTrackedChangeOnSelection();
154036
+ editor$1.commands.rejectTrackedChangeFromContextMenu({
154037
+ from: context$1?.selectionStart,
154038
+ to: context$1?.selectionEnd,
154039
+ trackedChangeId: context$1?.trackedChangeId
154040
+ });
154014
154041
  },
154015
154042
  showWhen: (context$1) => {
154016
154043
  const { trigger: trigger$1, isTrackedChange } = context$1;
@@ -179803,27 +179830,102 @@ var Node$13 = class Node$14 {
179803
179830
  if (!trackedChangeId)
179804
179831
  return changes;
179805
179832
  return changes.filter((change) => change.id === trackedChangeId);
179806
- }, TrackChanges, dedupeTrackedChangeRanges = (changes = []) => {
179807
- const byKey = /* @__PURE__ */ new Map;
179808
- changes.forEach((change) => {
179809
- if (!change || typeof change.from !== "number" || typeof change.to !== "number")
179833
+ }, hasExpandedSelection = (selection) => {
179834
+ return Number.isFinite(selection?.from) && Number.isFinite(selection?.to) && selection.from !== selection.to;
179835
+ }, TrackChanges, TRACKED_CHANGE_MARKS, getTrackedMark = (node3) => node3?.marks?.find((mark2) => TRACKED_CHANGE_MARKS.includes(mark2.type.name)) ?? null, getTrackedChangeActionSelection = ({ state, editor }) => {
179836
+ const currentSelection = state?.selection;
179837
+ if (hasExpandedSelection(currentSelection))
179838
+ return currentSelection;
179839
+ const preservedSelection = editor?.options?.preservedSelection ?? editor?.options?.lastSelection;
179840
+ if (hasExpandedSelection(preservedSelection))
179841
+ return preservedSelection;
179842
+ return currentSelection;
179843
+ }, getTrackedChangeResolutionContext = ({ state, trackedChangeId = null }) => {
179844
+ const commentsPluginState = CommentsPluginKey.getState(state);
179845
+ const resolvedTrackedChangeId = trackedChangeId ?? commentsPluginState?.activeThreadId ?? null;
179846
+ const hasTrackedChangeInCache = Boolean(resolvedTrackedChangeId && commentsPluginState?.trackedChanges?.[resolvedTrackedChangeId]);
179847
+ const hasTrackedChangeInDocument = Boolean(resolvedTrackedChangeId && getChangesByIdToResolve(state, resolvedTrackedChangeId)?.length);
179848
+ return {
179849
+ trackedChangeId: resolvedTrackedChangeId,
179850
+ hasKnownTrackedChangeId: hasTrackedChangeInCache || hasTrackedChangeInDocument
179851
+ };
179852
+ }, selectionTouchesTrackedChange = ({ state, trackedChangeId, selection = state?.selection }) => {
179853
+ if (!selection)
179854
+ return false;
179855
+ if (!trackedChangeId)
179856
+ return collectTrackedChanges({
179857
+ state,
179858
+ from: selection.from,
179859
+ to: selection.to
179860
+ }).length > 0;
179861
+ return collectTrackedChanges({
179862
+ state,
179863
+ from: selection.from,
179864
+ to: selection.to
179865
+ }).some((change) => change.id === trackedChangeId);
179866
+ }, resolveTrackedChangeAction = ({ action, state, commands: commands$1, editor, trackedChangeId = null, hasKnownTrackedChangeId = false, selection = null }) => {
179867
+ const targetSelection = selection ?? getTrackedChangeActionSelection({
179868
+ state,
179869
+ editor
179870
+ });
179871
+ const betweenCommand = action === "accept" ? commands$1.acceptTrackedChangesBetween : commands$1.rejectTrackedChangesBetween;
179872
+ const byIdCommand = action === "accept" ? commands$1.acceptTrackedChangeById : commands$1.rejectTrackedChangeById;
179873
+ const selectionCommand = action === "accept" ? commands$1.acceptTrackedChangeBySelection : commands$1.rejectTrackedChangeOnSelection;
179874
+ if (hasExpandedSelection(targetSelection) && selectionTouchesTrackedChange({
179875
+ state,
179876
+ trackedChangeId,
179877
+ selection: targetSelection
179878
+ }))
179879
+ return betweenCommand(targetSelection.from, targetSelection.to);
179880
+ if (trackedChangeId && hasKnownTrackedChangeId)
179881
+ return byIdCommand(trackedChangeId);
179882
+ return hasExpandedSelection(targetSelection) ? betweenCommand(targetSelection.from, targetSelection.to) : selectionCommand();
179883
+ }, collectRemainingMarksByType = (trackedChanges = []) => ({
179884
+ insertedMark: trackedChanges.find(({ mark: mark2 }) => mark2.type.name === "trackInsert")?.mark ?? null,
179885
+ deletionMark: trackedChanges.find(({ mark: mark2 }) => mark2.type.name === "trackDelete")?.mark ?? null,
179886
+ formatMark: trackedChanges.find(({ mark: mark2 }) => mark2.type.name === "trackFormat")?.mark ?? null
179887
+ }), emitTrackedChangeCommentLifecycle = ({ editor, nextState, touchedChangeIds }) => {
179888
+ if (!editor?.emit || !touchedChangeIds?.size)
179889
+ return;
179890
+ const resolvedByEmail = editor.options?.user?.email;
179891
+ const resolvedByName = editor.options?.user?.name;
179892
+ touchedChangeIds.forEach((changeId) => {
179893
+ const remainingTrackedChanges = getTrackChanges(nextState, changeId);
179894
+ if (!remainingTrackedChanges.length) {
179895
+ editor.emit("commentsUpdate", {
179896
+ type: "trackedChange",
179897
+ event: "resolve",
179898
+ changeId,
179899
+ resolvedByEmail,
179900
+ resolvedByName
179901
+ });
179810
179902
  return;
179811
- const type = change.mark?.type?.name || "";
179812
- const id2 = change.mark?.attrs?.id || "";
179813
- const key$1 = `${change.from}:${change.to}:${type}:${id2}`;
179814
- if (!byKey.has(key$1))
179815
- byKey.set(key$1, change);
179816
- });
179817
- return Array.from(byKey.values()).sort((left$1, right$1) => {
179818
- if (left$1.from !== right$1.from)
179819
- return left$1.from - right$1.from;
179820
- return left$1.to - right$1.to;
179821
- });
179822
- }, getTrackedChangesByTouchedIds = (state, trackedChanges = []) => {
179823
- const touchedIds = new Set(trackedChanges.map(({ mark: mark2 }) => mark2?.attrs?.id).filter(Boolean));
179824
- if (!touchedIds.size)
179825
- return trackedChanges;
179826
- return Array.from(touchedIds).flatMap((id2) => getChangesByIdToResolve(state, id2) || []);
179903
+ }
179904
+ const updatePayload = createOrUpdateTrackedChangeComment({
179905
+ event: "update",
179906
+ marks: collectRemainingMarksByType(remainingTrackedChanges),
179907
+ deletionNodes: [],
179908
+ nodes: [],
179909
+ newEditorState: nextState,
179910
+ documentId: editor.options?.documentId,
179911
+ trackedChangesForId: remainingTrackedChanges
179912
+ });
179913
+ if (updatePayload)
179914
+ editor.emit("commentsUpdate", updatePayload);
179915
+ });
179916
+ }, dispatchTrackedChangeResolution = ({ state, tr, dispatch, editor, touchedChangeIds }) => {
179917
+ if (!tr.steps.length)
179918
+ return true;
179919
+ const nextState = state.apply(tr);
179920
+ if (dispatch)
179921
+ dispatch(tr);
179922
+ if (dispatch && touchedChangeIds?.size)
179923
+ emitTrackedChangeCommentLifecycle({
179924
+ editor,
179925
+ nextState,
179926
+ touchedChangeIds
179927
+ });
179928
+ return true;
179827
179929
  }, getChangesByIdToResolve = (state, id2) => {
179828
179930
  const trackedChanges = getTrackChanges(state);
179829
179931
  const changeIndex = trackedChanges.findIndex(({ mark: mark2 }) => mark2.attrs.id === id2);
@@ -181991,7 +182093,7 @@ var Node$13 = class Node$14 {
181991
182093
  trackedChanges: context.trackedChanges ?? []
181992
182094
  });
181993
182095
  }, _hoisted_1$6, _hoisted_2$2, _hoisted_3, _hoisted_4, ContextMenu_default, _hoisted_1$5, BasicUpload_default, _hoisted_1$4, MIN_WIDTH = 200, PPI = 96, alignment = "flex-end", Ruler_default, GenericPopover_default, _hoisted_1$3, _hoisted_2$1, RESIZE_HANDLE_WIDTH_PX = 9, RESIZE_HANDLE_HEIGHT_PX = 9, RESIZE_HANDLE_OFFSET_PX = 4, DRAG_OVERLAY_EXTENSION_PX = 1000, MIN_DRAG_OVERLAY_WIDTH_PX = 2000, THROTTLE_INTERVAL_MS = 16, MIN_RESIZE_DELTA_PX = 1, TableResizeOverlay_default, _hoisted_1$2, OVERLAY_EXPANSION_PX = 2000, RESIZE_HANDLE_SIZE_PX = 12, MOUSE_MOVE_THROTTLE_MS = 16, DIMENSION_CHANGE_THRESHOLD_PX = 1, Z_INDEX_OVERLAY = 10, Z_INDEX_HANDLE = 15, Z_INDEX_GUIDELINE = 20, ImageResizeOverlay_default, LINK_CLICK_DEBOUNCE_MS = 300, CURSOR_UPDATE_TIMEOUT_MS = 10, POPOVER_VERTICAL_OFFSET_PX = 15, LinkClickHandler_default, _hoisted_1$1, _hoisted_2, DOCX2 = "application/vnd.openxmlformats-officedocument.wordprocessingml.document", TABLE_RESIZE_HOVER_THRESHOLD = 8, TABLE_RESIZE_THROTTLE_MS = 16, SuperEditor_default, _hoisted_1, SuperInput_default, SlashMenu, Extensions;
181994
- var init_src_C0LpayfV_es = __esm(() => {
182096
+ var init_src_BdKG1LCw_es = __esm(() => {
181995
182097
  init_rolldown_runtime_B2q5OVn9_es();
181996
182098
  init_SuperConverter_CoCZX_fP_es();
181997
182099
  init_jszip_ChlR43oI_es();
@@ -209829,98 +209931,92 @@ function print() { __p += __j.call(arguments, '') }
209829
209931
  return false;
209830
209932
  let { tr, doc: doc$2 } = state;
209831
209933
  tr.setMeta("inputType", "acceptReject");
209934
+ const touchedChangeIds = /* @__PURE__ */ new Set;
209832
209935
  const map$22 = new Mapping;
209833
209936
  doc$2.nodesBetween(from$12, to, (node3, pos) => {
209834
- if (node3.marks && node3.marks.find((mark2) => mark2.type.name === "trackDelete")) {
209835
- const deletionStep = new ReplaceStep(map$22.map(Math.max(pos, from$12)), map$22.map(Math.min(pos + node3.nodeSize, to)), Slice.empty);
209937
+ const trackedMark = getTrackedMark(node3);
209938
+ if (!trackedMark)
209939
+ return;
209940
+ const mappedFrom = map$22.map(Math.max(pos, from$12));
209941
+ const mappedTo = map$22.map(Math.min(pos + node3.nodeSize, to));
209942
+ if (mappedFrom >= mappedTo)
209943
+ return;
209944
+ if (trackedMark.attrs?.id)
209945
+ touchedChangeIds.add(trackedMark.attrs.id);
209946
+ if (trackedMark.type.name === "trackDelete") {
209947
+ const deletionStep = new ReplaceStep(mappedFrom, mappedTo, Slice.empty);
209836
209948
  tr.step(deletionStep);
209837
209949
  map$22.appendMap(deletionStep.getMap());
209838
- } else if (node3.marks && node3.marks.find((mark2) => mark2.type.name === "trackInsert")) {
209839
- const insertionMark = node3.marks.find((mark2) => mark2.type.name === TrackInsertMarkName);
209840
- tr.step(new RemoveMarkStep(map$22.map(Math.max(pos, from$12)), map$22.map(Math.min(pos + node3.nodeSize, to)), insertionMark));
209841
- } else if (node3.marks && node3.marks.find((mark2) => mark2.type.name === "trackFormat")) {
209842
- const formatChangeMark = node3.marks.find((mark2) => mark2.type.name === TrackFormatMarkName);
209843
- tr.step(new RemoveMarkStep(map$22.map(Math.max(pos, from$12)), map$22.map(Math.min(pos + node3.nodeSize, to)), formatChangeMark));
209950
+ return;
209844
209951
  }
209952
+ tr.step(new RemoveMarkStep(mappedFrom, mappedTo, trackedMark));
209845
209953
  });
209846
- if (tr.steps.length)
209847
- dispatch(tr);
209848
- return true;
209849
- },
209850
- rejectTrackedChangesBetween: (from$12, to) => ({ state, dispatch, editor }) => {
209851
- const trackedChangesInSelection = collectTrackedChanges({
209954
+ return dispatchTrackedChangeResolution({
209852
209955
  state,
209853
- from: from$12,
209854
- to
209956
+ tr,
209957
+ dispatch,
209958
+ editor,
209959
+ touchedChangeIds
209855
209960
  });
209856
- const trackedChangesById = getTrackedChangesByTouchedIds(state, trackedChangesInSelection);
209857
- const trackedChangesWithoutId = trackedChangesInSelection.filter(({ mark: mark2 }) => !mark2?.attrs?.id);
209858
- const trackedChanges = dedupeTrackedChangeRanges([...trackedChangesById, ...trackedChangesWithoutId]);
209961
+ },
209962
+ rejectTrackedChangesBetween: (from$12, to) => ({ state, dispatch, editor }) => {
209859
209963
  if (!isTrackedChangeActionAllowed({
209860
209964
  editor,
209861
209965
  action: "reject",
209862
- trackedChanges
209966
+ trackedChanges: collectTrackedChanges({
209967
+ state,
209968
+ from: from$12,
209969
+ to
209970
+ })
209863
209971
  }))
209864
209972
  return false;
209865
209973
  const { tr, doc: doc$2 } = state;
209866
- const rejectedChangeIds = /* @__PURE__ */ new Set;
209974
+ const touchedChangeIds = /* @__PURE__ */ new Set;
209867
209975
  tr.setMeta("inputType", "acceptReject");
209868
209976
  const map$22 = new Mapping;
209869
- trackedChanges.forEach(({ from: rangeFrom, to: rangeTo }) => {
209870
- doc$2.nodesBetween(rangeFrom, rangeTo, (node3, pos) => {
209871
- if (node3.marks && node3.marks.find((mark2) => mark2.type.name === "trackDelete")) {
209872
- const deletionMark = node3.marks.find((mark2) => mark2.type.name === TrackDeleteMarkName);
209873
- if (deletionMark?.attrs?.id)
209874
- rejectedChangeIds.add(deletionMark.attrs.id);
209875
- tr.step(new RemoveMarkStep(map$22.map(Math.max(pos, rangeFrom)), map$22.map(Math.min(pos + node3.nodeSize, rangeTo)), deletionMark));
209876
- } else if (node3.marks && node3.marks.find((mark2) => mark2.type.name === "trackInsert")) {
209877
- const insertionMark = node3.marks.find((mark2) => mark2.type.name === TrackInsertMarkName);
209878
- if (insertionMark?.attrs?.id)
209879
- rejectedChangeIds.add(insertionMark.attrs.id);
209880
- const deletionStep = new ReplaceStep(map$22.map(Math.max(pos, rangeFrom)), map$22.map(Math.min(pos + node3.nodeSize, rangeTo)), Slice.empty);
209881
- tr.step(deletionStep);
209882
- map$22.appendMap(deletionStep.getMap());
209883
- } else if (node3.marks && node3.marks.find((mark2) => mark2.type.name === "trackFormat")) {
209884
- const formatChangeMark = node3.marks.find((mark2) => mark2.type.name === TrackFormatMarkName);
209885
- if (formatChangeMark?.attrs?.id)
209886
- rejectedChangeIds.add(formatChangeMark.attrs.id);
209887
- formatChangeMark.attrs.before.forEach((oldMark) => {
209888
- tr.step(new AddMarkStep(map$22.map(Math.max(pos, rangeFrom)), map$22.map(Math.min(pos + node3.nodeSize, rangeTo)), state.schema.marks[oldMark.type].create(oldMark.attrs)));
209889
- });
209890
- formatChangeMark.attrs.after.forEach((newMark) => {
209891
- const mappedFrom = map$22.map(Math.max(pos, rangeFrom));
209892
- const mappedTo = map$22.map(Math.min(pos + node3.nodeSize, rangeTo));
209893
- const liveMark = findMarkInRangeBySnapshot({
209894
- doc: tr.doc,
209895
- from: mappedFrom,
209896
- to: mappedTo,
209897
- snapshot: newMark
209898
- });
209899
- if (!liveMark)
209900
- return;
209901
- tr.step(new RemoveMarkStep(mappedFrom, mappedTo, liveMark));
209902
- });
209903
- tr.step(new RemoveMarkStep(map$22.map(Math.max(pos, rangeFrom)), map$22.map(Math.min(pos + node3.nodeSize, rangeTo)), formatChangeMark));
209904
- }
209977
+ doc$2.nodesBetween(from$12, to, (node3, pos) => {
209978
+ const trackedMark = getTrackedMark(node3);
209979
+ if (!trackedMark)
209980
+ return;
209981
+ const mappedFrom = map$22.map(Math.max(pos, from$12));
209982
+ const mappedTo = map$22.map(Math.min(pos + node3.nodeSize, to));
209983
+ if (mappedFrom >= mappedTo)
209984
+ return;
209985
+ if (trackedMark.attrs?.id)
209986
+ touchedChangeIds.add(trackedMark.attrs.id);
209987
+ if (trackedMark.type.name === "trackDelete") {
209988
+ tr.step(new RemoveMarkStep(mappedFrom, mappedTo, trackedMark));
209989
+ return;
209990
+ }
209991
+ if (trackedMark.type.name === "trackInsert") {
209992
+ const deletionStep = new ReplaceStep(mappedFrom, mappedTo, Slice.empty);
209993
+ tr.step(deletionStep);
209994
+ map$22.appendMap(deletionStep.getMap());
209995
+ return;
209996
+ }
209997
+ trackedMark.attrs.before.forEach((oldMark) => {
209998
+ tr.step(new AddMarkStep(mappedFrom, mappedTo, state.schema.marks[oldMark.type].create(oldMark.attrs)));
209905
209999
  });
209906
- });
209907
- if (tr.steps.length) {
209908
- dispatch(tr);
209909
- if (editor?.emit && rejectedChangeIds.size) {
209910
- const resolvedByEmail = editor.options?.user?.email;
209911
- const resolvedByName = editor.options?.user?.name;
209912
- rejectedChangeIds.forEach((changeId) => {
209913
- editor.emit("commentsUpdate", {
209914
- type: "trackedChange",
209915
- event: "resolve",
209916
- changeId,
209917
- resolvedByEmail,
209918
- resolvedByName
209919
- });
210000
+ trackedMark.attrs.after.forEach((newMark) => {
210001
+ const liveMark = findMarkInRangeBySnapshot({
210002
+ doc: tr.doc,
210003
+ from: mappedFrom,
210004
+ to: mappedTo,
210005
+ snapshot: newMark
209920
210006
  });
209921
- }
209922
- }
209923
- return true;
210007
+ if (!liveMark)
210008
+ return;
210009
+ tr.step(new RemoveMarkStep(mappedFrom, mappedTo, liveMark));
210010
+ });
210011
+ tr.step(new RemoveMarkStep(mappedFrom, mappedTo, trackedMark));
210012
+ });
210013
+ return dispatchTrackedChangeResolution({
210014
+ state,
210015
+ tr,
210016
+ dispatch,
210017
+ editor,
210018
+ touchedChangeIds
210019
+ });
209924
210020
  },
209925
210021
  acceptTrackedChange: ({ trackedChange }) => ({ commands: commands$1 }) => {
209926
210022
  const { start: from$12, end: to } = trackedChange;
@@ -209930,13 +210026,33 @@ function print() { __p += __j.call(arguments, '') }
209930
210026
  const { from: from$12, to } = state.selection;
209931
210027
  return commands$1.acceptTrackedChangesBetween(from$12, to);
209932
210028
  },
209933
- acceptTrackedChangeFromToolbar: () => ({ state, commands: commands$1 }) => {
209934
- const commentsPluginState = CommentsPluginKey.getState(state);
209935
- const activeThreadId = commentsPluginState?.activeThreadId;
209936
- if (activeThreadId && commentsPluginState?.trackedChanges?.[activeThreadId])
209937
- return commands$1.acceptTrackedChangeById(activeThreadId);
209938
- else
209939
- return commands$1.acceptTrackedChangeBySelection();
210029
+ acceptTrackedChangeFromToolbar: () => ({ state, commands: commands$1, editor }) => {
210030
+ return resolveTrackedChangeAction({
210031
+ action: "accept",
210032
+ state,
210033
+ commands: commands$1,
210034
+ editor,
210035
+ ...getTrackedChangeResolutionContext({
210036
+ state,
210037
+ trackedChangeId: CommentsPluginKey.getState(state)?.activeThreadId
210038
+ })
210039
+ });
210040
+ },
210041
+ acceptTrackedChangeFromContextMenu: ({ from: from$12, to, trackedChangeId = null } = {}) => ({ state, commands: commands$1, editor }) => {
210042
+ return resolveTrackedChangeAction({
210043
+ action: "accept",
210044
+ state,
210045
+ commands: commands$1,
210046
+ editor,
210047
+ selection: Number.isFinite(from$12) && Number.isFinite(to) ? {
210048
+ from: from$12,
210049
+ to
210050
+ } : null,
210051
+ ...getTrackedChangeResolutionContext({
210052
+ state,
210053
+ trackedChangeId
210054
+ })
210055
+ });
209940
210056
  },
209941
210057
  acceptTrackedChangeById: (id2) => ({ state, tr, commands: commands$1 }) => {
209942
210058
  return (getChangesByIdToResolve(state, id2) || []).map(({ from: from$12, to }) => {
@@ -209964,13 +210080,33 @@ function print() { __p += __j.call(arguments, '') }
209964
210080
  const { from: from$12, to } = state.selection;
209965
210081
  return commands$1.rejectTrackedChangesBetween(from$12, to);
209966
210082
  },
209967
- rejectTrackedChangeFromToolbar: () => ({ state, commands: commands$1 }) => {
209968
- const commentsPluginState = CommentsPluginKey.getState(state);
209969
- const activeThreadId = commentsPluginState?.activeThreadId;
209970
- if (activeThreadId && commentsPluginState?.trackedChanges?.[activeThreadId])
209971
- return commands$1.rejectTrackedChangeById(activeThreadId);
209972
- else
209973
- return commands$1.rejectTrackedChangeOnSelection();
210083
+ rejectTrackedChangeFromToolbar: () => ({ state, commands: commands$1, editor }) => {
210084
+ return resolveTrackedChangeAction({
210085
+ action: "reject",
210086
+ state,
210087
+ commands: commands$1,
210088
+ editor,
210089
+ ...getTrackedChangeResolutionContext({
210090
+ state,
210091
+ trackedChangeId: CommentsPluginKey.getState(state)?.activeThreadId
210092
+ })
210093
+ });
210094
+ },
210095
+ rejectTrackedChangeFromContextMenu: ({ from: from$12, to, trackedChangeId = null } = {}) => ({ state, commands: commands$1, editor }) => {
210096
+ return resolveTrackedChangeAction({
210097
+ action: "reject",
210098
+ state,
210099
+ commands: commands$1,
210100
+ editor,
210101
+ selection: Number.isFinite(from$12) && Number.isFinite(to) ? {
210102
+ from: from$12,
210103
+ to
210104
+ } : null,
210105
+ ...getTrackedChangeResolutionContext({
210106
+ state,
210107
+ trackedChangeId
210108
+ })
210109
+ });
209974
210110
  },
209975
210111
  rejectAllTrackedChanges: () => ({ state, commands: commands$1 }) => {
209976
210112
  const from$12 = 0, to = state.doc.content.size;
@@ -210127,6 +210263,11 @@ function print() { __p += __j.call(arguments, '') }
210127
210263
  return [TrackChangesBasePlugin()];
210128
210264
  }
210129
210265
  });
210266
+ TRACKED_CHANGE_MARKS = [
210267
+ TrackDeleteMarkName,
210268
+ TrackInsertMarkName,
210269
+ TrackFormatMarkName
210270
+ ];
210130
210271
  TextTransform = Extension.create({
210131
210272
  name: "textTransform",
210132
210273
  addOptions() {
@@ -213482,8 +213623,8 @@ function print() { __p += __j.call(arguments, '') }
213482
213623
  return isObjectLike_default(value) && hasOwnProperty$8.call(value, "callee") && !propertyIsEnumerable$1.call(value, "callee");
213483
213624
  };
213484
213625
  stubFalse_default = stubFalse;
213485
- freeExports$2 = typeof exports_src_C0LpayfV_es == "object" && exports_src_C0LpayfV_es && !exports_src_C0LpayfV_es.nodeType && exports_src_C0LpayfV_es;
213486
- freeModule$2 = freeExports$2 && typeof module_src_C0LpayfV_es == "object" && module_src_C0LpayfV_es && !module_src_C0LpayfV_es.nodeType && module_src_C0LpayfV_es;
213626
+ freeExports$2 = typeof exports_src_BdKG1LCw_es == "object" && exports_src_BdKG1LCw_es && !exports_src_BdKG1LCw_es.nodeType && exports_src_BdKG1LCw_es;
213627
+ freeModule$2 = freeExports$2 && typeof module_src_BdKG1LCw_es == "object" && module_src_BdKG1LCw_es && !module_src_BdKG1LCw_es.nodeType && module_src_BdKG1LCw_es;
213487
213628
  Buffer$1 = freeModule$2 && freeModule$2.exports === freeExports$2 ? _root_default.Buffer : undefined;
213488
213629
  isBuffer_default = (Buffer$1 ? Buffer$1.isBuffer : undefined) || stubFalse_default;
213489
213630
  typedArrayTags = {};
@@ -213491,8 +213632,8 @@ function print() { __p += __j.call(arguments, '') }
213491
213632
  typedArrayTags[argsTag$1] = typedArrayTags[arrayTag$1] = typedArrayTags[arrayBufferTag$1] = typedArrayTags[boolTag$1] = typedArrayTags[dataViewTag$2] = typedArrayTags[dateTag$1] = typedArrayTags[errorTag$1] = typedArrayTags[funcTag] = typedArrayTags[mapTag$2] = typedArrayTags[numberTag$1] = typedArrayTags[objectTag$3] = typedArrayTags[regexpTag$1] = typedArrayTags[setTag$2] = typedArrayTags[stringTag$1] = typedArrayTags[weakMapTag$1] = false;
213492
213633
  _baseIsTypedArray_default = baseIsTypedArray;
213493
213634
  _baseUnary_default = baseUnary;
213494
- freeExports$1 = typeof exports_src_C0LpayfV_es == "object" && exports_src_C0LpayfV_es && !exports_src_C0LpayfV_es.nodeType && exports_src_C0LpayfV_es;
213495
- freeModule$1 = freeExports$1 && typeof module_src_C0LpayfV_es == "object" && module_src_C0LpayfV_es && !module_src_C0LpayfV_es.nodeType && module_src_C0LpayfV_es;
213635
+ freeExports$1 = typeof exports_src_BdKG1LCw_es == "object" && exports_src_BdKG1LCw_es && !exports_src_BdKG1LCw_es.nodeType && exports_src_BdKG1LCw_es;
213636
+ freeModule$1 = freeExports$1 && typeof module_src_BdKG1LCw_es == "object" && module_src_BdKG1LCw_es && !module_src_BdKG1LCw_es.nodeType && module_src_BdKG1LCw_es;
213496
213637
  freeProcess = freeModule$1 && freeModule$1.exports === freeExports$1 && _freeGlobal_default.process;
213497
213638
  _nodeUtil_default = function() {
213498
213639
  try {
@@ -213597,8 +213738,8 @@ function print() { __p += __j.call(arguments, '') }
213597
213738
  Stack.prototype.has = _stackHas_default;
213598
213739
  Stack.prototype.set = _stackSet_default;
213599
213740
  _Stack_default = Stack;
213600
- freeExports = typeof exports_src_C0LpayfV_es == "object" && exports_src_C0LpayfV_es && !exports_src_C0LpayfV_es.nodeType && exports_src_C0LpayfV_es;
213601
- freeModule = freeExports && typeof module_src_C0LpayfV_es == "object" && module_src_C0LpayfV_es && !module_src_C0LpayfV_es.nodeType && module_src_C0LpayfV_es;
213741
+ freeExports = typeof exports_src_BdKG1LCw_es == "object" && exports_src_BdKG1LCw_es && !exports_src_BdKG1LCw_es.nodeType && exports_src_BdKG1LCw_es;
213742
+ freeModule = freeExports && typeof module_src_BdKG1LCw_es == "object" && module_src_BdKG1LCw_es && !module_src_BdKG1LCw_es.nodeType && module_src_BdKG1LCw_es;
213602
213743
  Buffer4 = freeModule && freeModule.exports === freeExports ? _root_default.Buffer : undefined;
213603
213744
  allocUnsafe = Buffer4 ? Buffer4.allocUnsafe : undefined;
213604
213745
  _cloneBuffer_default = cloneBuffer;
@@ -221678,7 +221819,7 @@ var init_zipper_DqXT7uTa_es = __esm(() => {
221678
221819
 
221679
221820
  // ../../packages/superdoc/dist/super-editor.es.js
221680
221821
  var init_super_editor_es = __esm(() => {
221681
- init_src_C0LpayfV_es();
221822
+ init_src_BdKG1LCw_es();
221682
221823
  init_SuperConverter_CoCZX_fP_es();
221683
221824
  init_jszip_ChlR43oI_es();
221684
221825
  init_xml_js_DLE8mr0n_es();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/cli",
3
- "version": "0.2.0-next.76",
3
+ "version": "0.2.0-next.77",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "superdoc": "./dist/index.js"
@@ -21,8 +21,8 @@
21
21
  "@types/node": "22.19.2",
22
22
  "typescript": "^5.9.2",
23
23
  "@superdoc/document-api": "0.0.1",
24
- "@superdoc/super-editor": "0.0.1",
25
24
  "@superdoc/pm-adapter": "0.0.0",
25
+ "@superdoc/super-editor": "0.0.1",
26
26
  "superdoc": "1.17.0"
27
27
  },
28
28
  "module": "src/index.ts",
@@ -30,11 +30,11 @@
30
30
  "access": "public"
31
31
  },
32
32
  "optionalDependencies": {
33
- "@superdoc-dev/cli-darwin-arm64": "0.2.0-next.76",
34
- "@superdoc-dev/cli-darwin-x64": "0.2.0-next.76",
35
- "@superdoc-dev/cli-linux-x64": "0.2.0-next.76",
36
- "@superdoc-dev/cli-linux-arm64": "0.2.0-next.76",
37
- "@superdoc-dev/cli-windows-x64": "0.2.0-next.76"
33
+ "@superdoc-dev/cli-darwin-arm64": "0.2.0-next.77",
34
+ "@superdoc-dev/cli-darwin-x64": "0.2.0-next.77",
35
+ "@superdoc-dev/cli-linux-x64": "0.2.0-next.77",
36
+ "@superdoc-dev/cli-windows-x64": "0.2.0-next.77",
37
+ "@superdoc-dev/cli-linux-arm64": "0.2.0-next.77"
38
38
  },
39
39
  "scripts": {
40
40
  "dev": "bun run src/index.ts",