@superdoc-dev/cli 0.2.0-next.21 → 0.2.0-next.23

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 +317 -32
  2. package/package.json +8 -8
package/dist/index.js CHANGED
@@ -26618,7 +26618,7 @@ var init_remark_gfm_z_sDF4ss_es = __esm(() => {
26618
26618
  emptyOptions2 = {};
26619
26619
  });
26620
26620
 
26621
- // ../../packages/superdoc/dist/chunks/SuperConverter-BJBbuXuZ.es.js
26621
+ // ../../packages/superdoc/dist/chunks/SuperConverter-Di-Lg_7T.es.js
26622
26622
  function getExtensionConfigField(extension$1, field, context = { name: "" }) {
26623
26623
  const fieldValue = extension$1.config[field];
26624
26624
  if (typeof fieldValue === "function")
@@ -39090,6 +39090,58 @@ function importFootnoteData({ docx, editor, converter, nodeListHandler, numberin
39090
39090
  });
39091
39091
  return results;
39092
39092
  }
39093
+ function toIdentityValue(value) {
39094
+ if (typeof value === "string" && value.length > 0)
39095
+ return value;
39096
+ if (typeof value === "number" && Number.isFinite(value))
39097
+ return String(value);
39098
+ }
39099
+ function resolvePrimaryBlockIdentity(node3) {
39100
+ if (!node3 || typeof node3 !== "object")
39101
+ return;
39102
+ const attrPriority = BLOCK_IDENTITY_ATTRS[node3.type];
39103
+ if (!attrPriority)
39104
+ return;
39105
+ const attrs = typeof node3.attrs === "object" && node3.attrs ? node3.attrs : {};
39106
+ for (const attr of attrPriority) {
39107
+ const value = toIdentityValue(attrs[attr]);
39108
+ if (value)
39109
+ return {
39110
+ id: value,
39111
+ source: attr
39112
+ };
39113
+ }
39114
+ }
39115
+ function nextUniqueDocxId(usedIds) {
39116
+ let id = generateDocxRandomId();
39117
+ while (usedIds.has(id))
39118
+ id = generateDocxRandomId();
39119
+ return id;
39120
+ }
39121
+ function dedupeBlockIdentitiesInNode(node3, usedIds) {
39122
+ if (!node3 || typeof node3 !== "object")
39123
+ return;
39124
+ const identity = resolvePrimaryBlockIdentity(node3);
39125
+ if (identity)
39126
+ if (usedIds.has(identity.id)) {
39127
+ const replacementId = nextUniqueDocxId(usedIds);
39128
+ node3.attrs = {
39129
+ ...node3.attrs,
39130
+ [identity.source]: replacementId
39131
+ };
39132
+ usedIds.add(replacementId);
39133
+ } else
39134
+ usedIds.add(identity.id);
39135
+ if (Array.isArray(node3.content))
39136
+ node3.content.forEach((child) => dedupeBlockIdentitiesInNode(child, usedIds));
39137
+ }
39138
+ function normalizeDuplicateBlockIdentitiesInContent(content$2 = []) {
39139
+ if (!Array.isArray(content$2) || content$2.length === 0)
39140
+ return content$2;
39141
+ const usedIds = /* @__PURE__ */ new Set;
39142
+ content$2.forEach((node3) => dedupeBlockIdentitiesInNode(node3, usedIds));
39143
+ return content$2;
39144
+ }
39093
39145
  function patchNumberingDefinitions(docx) {
39094
39146
  const numberingXml = docx?.["word/numbering.xml"];
39095
39147
  if (!numberingXml)
@@ -52818,7 +52870,7 @@ var isRegExp = (value) => {
52818
52870
  nodes: [translator$3.encode(params)],
52819
52871
  consumed: 1
52820
52872
  };
52821
- }, tabNodeEntityHandler, footnoteReferenceHandlerEntity, tableNodeHandlerEntity, tableOfContentsHandlerEntity, indexHandlerEntity, indexEntryHandlerEntity, commentRangeStartHandlerEntity, commentRangeEndHandlerEntity, permStartHandlerEntity, permEndHandlerEntity, WORD_2012_NAMESPACE = "http://schemas.microsoft.com/office/word/2012/wordml", deepClone = (value) => JSON.parse(JSON.stringify(value)), getNumberingRoot = (numberingXml) => {
52873
+ }, tabNodeEntityHandler, footnoteReferenceHandlerEntity, tableNodeHandlerEntity, tableOfContentsHandlerEntity, indexHandlerEntity, indexEntryHandlerEntity, commentRangeStartHandlerEntity, commentRangeEndHandlerEntity, permStartHandlerEntity, permEndHandlerEntity, PARAGRAPH_IDENTITY_ATTRS, TABLE_IDENTITY_ATTRS, DEFAULT_BLOCK_IDENTITY_ATTRS, BLOCK_IDENTITY_ATTRS, WORD_2012_NAMESPACE = "http://schemas.microsoft.com/office/word/2012/wordml", deepClone = (value) => JSON.parse(JSON.stringify(value)), getNumberingRoot = (numberingXml) => {
52822
52874
  if (!numberingXml?.elements?.length)
52823
52875
  return null;
52824
52876
  return numberingXml.elements.find((el) => el?.name === "w:numbering") || numberingXml.elements[0] || null;
@@ -52912,6 +52964,7 @@ var isRegExp = (value) => {
52912
52964
  parsedContent = filterOutRootInlineNodes(parsedContent);
52913
52965
  parsedContent = normalizeTableBookmarksInContent(parsedContent, editor);
52914
52966
  collapseWhitespaceNextToInlinePassthrough(parsedContent);
52967
+ parsedContent = normalizeDuplicateBlockIdentitiesInContent(parsedContent);
52915
52968
  return {
52916
52969
  pmDoc: {
52917
52970
  type: "doc",
@@ -53093,6 +53146,7 @@ var isRegExp = (value) => {
53093
53146
  path: []
53094
53147
  });
53095
53148
  schema = filterOutRootInlineNodes(schema);
53149
+ schema = normalizeDuplicateBlockIdentitiesInContent(schema);
53096
53150
  if (!converter.headerIds.ids)
53097
53151
  converter.headerIds.ids = [];
53098
53152
  converter.headerIds.ids.push(rId);
@@ -53121,6 +53175,7 @@ var isRegExp = (value) => {
53121
53175
  path: []
53122
53176
  });
53123
53177
  schema = filterOutRootInlineNodes(schema);
53178
+ schema = normalizeDuplicateBlockIdentitiesInContent(schema);
53124
53179
  if (!converter.footerIds.ids)
53125
53180
  converter.footerIds.ids = [];
53126
53181
  converter.footerIds.ids.push(rId);
@@ -53800,7 +53855,7 @@ var isRegExp = (value) => {
53800
53855
  state.kern = kernNode.attributes["w:val"];
53801
53856
  }
53802
53857
  }, SuperConverter;
53803
- var init_SuperConverter_BJBbuXuZ_es = __esm(() => {
53858
+ var init_SuperConverter_Di_Lg_7T_es = __esm(() => {
53804
53859
  init_rolldown_runtime_B2q5OVn9_es();
53805
53860
  init_jszip_ChlR43oI_es();
53806
53861
  init_xml_js_DLE8mr0n_es();
@@ -65764,6 +65819,28 @@ var init_SuperConverter_BJBbuXuZ_es = __esm(() => {
65764
65819
  commentRangeEndHandlerEntity = generateV2HandlerEntity("commentRangeEndHandler", commentRangeEndTranslator);
65765
65820
  permStartHandlerEntity = generateV2HandlerEntity("permStartHandler", translator$13);
65766
65821
  permEndHandlerEntity = generateV2HandlerEntity("permEndHandler", translator$14);
65822
+ PARAGRAPH_IDENTITY_ATTRS = ["sdBlockId", "paraId"];
65823
+ TABLE_IDENTITY_ATTRS = [
65824
+ "sdBlockId",
65825
+ "paraId",
65826
+ "blockId"
65827
+ ];
65828
+ DEFAULT_BLOCK_IDENTITY_ATTRS = [
65829
+ "sdBlockId",
65830
+ "blockId",
65831
+ "paraId"
65832
+ ];
65833
+ BLOCK_IDENTITY_ATTRS = {
65834
+ paragraph: PARAGRAPH_IDENTITY_ATTRS,
65835
+ heading: DEFAULT_BLOCK_IDENTITY_ATTRS,
65836
+ listItem: DEFAULT_BLOCK_IDENTITY_ATTRS,
65837
+ table: TABLE_IDENTITY_ATTRS,
65838
+ tableRow: TABLE_IDENTITY_ATTRS,
65839
+ tableCell: TABLE_IDENTITY_ATTRS,
65840
+ tableHeader: TABLE_IDENTITY_ATTRS,
65841
+ sdt: DEFAULT_BLOCK_IDENTITY_ATTRS,
65842
+ structuredContentBlock: DEFAULT_BLOCK_IDENTITY_ATTRS
65843
+ };
65767
65844
  DEFAULT_SECTION_PROPS = Object.freeze({
65768
65845
  pageSize: Object.freeze({
65769
65846
  width: "12240",
@@ -93077,9 +93154,9 @@ var init_remark_gfm_CQ3Jg4PR_es = __esm(() => {
93077
93154
  init_remark_gfm_z_sDF4ss_es();
93078
93155
  });
93079
93156
 
93080
- // ../../packages/superdoc/dist/chunks/src-DEQEar7E.es.js
93081
- var exports_src_DEQEar7E_es = {};
93082
- __export(exports_src_DEQEar7E_es, {
93157
+ // ../../packages/superdoc/dist/chunks/src-C0U0FLIH.es.js
93158
+ var exports_src_C0U0FLIH_es = {};
93159
+ __export(exports_src_C0U0FLIH_es, {
93083
93160
  zt: () => defineMark,
93084
93161
  z: () => cM,
93085
93162
  yt: () => removeAwarenessStates,
@@ -140201,7 +140278,8 @@ var Node$13 = class Node$14 {
140201
140278
  }, selectAll$1 = () => ({ state, dispatch }) => selectAll(state, dispatch), deleteSelection$1 = () => ({ state, tr, dispatch }) => {
140202
140279
  const { from: from$12, to, empty: empty$2 } = state.selection;
140203
140280
  if (typeof document !== "undefined" && document.getSelection) {
140204
- if (document.getSelection()?.baseNode?.data?.length === 1)
140281
+ const currentDomSelection = document.getSelection();
140282
+ if (empty$2 && currentDomSelection?.baseNode?.data?.length === 1)
140205
140283
  return false;
140206
140284
  }
140207
140285
  if (empty$2)
@@ -140880,6 +140958,17 @@ var Node$13 = class Node$14 {
140880
140958
  if (dispatch)
140881
140959
  dispatch(state.tr.delete(pos - 1, pos).scrollIntoView());
140882
140960
  return true;
140961
+ }, findPreviousTextDeleteRange = (doc$2, cursorPos, minPos) => {
140962
+ for (let pos = cursorPos - 1;pos >= minPos; pos -= 1) {
140963
+ const nodeBefore = doc$2.resolve(pos).nodeBefore;
140964
+ if (!nodeBefore?.isText || !nodeBefore.text?.length)
140965
+ continue;
140966
+ return {
140967
+ from: pos - 1,
140968
+ to: pos
140969
+ };
140970
+ }
140971
+ return null;
140883
140972
  }, backspaceNextToRun = () => ({ state, tr, dispatch }) => {
140884
140973
  const sel = state.selection;
140885
140974
  if (!sel.empty)
@@ -140891,17 +140980,24 @@ var Node$13 = class Node$14 {
140891
140980
  if ($pos.nodeBefore) {
140892
140981
  if ($pos.nodeBefore.content.size === 0)
140893
140982
  return false;
140894
- tr.delete($pos.pos - 2, $pos.pos - 1).setSelection(Selection.near(tr.doc.resolve($pos.pos - 2)));
140895
- if (dispatch)
140896
- dispatch(tr.scrollIntoView());
140897
140983
  } else {
140898
140984
  const prevNode = state.doc.resolve($pos.start() - 1).nodeBefore;
140899
140985
  if (prevNode?.type !== runType || prevNode.content.size === 0)
140900
140986
  return false;
140901
- tr.delete($pos.pos - 3, $pos.pos - 2).setSelection(Selection.near(tr.doc.resolve($pos.pos - 3)));
140902
- if (dispatch)
140903
- dispatch(tr.scrollIntoView());
140904
140987
  }
140988
+ let runContentStart;
140989
+ if ($pos.nodeBefore)
140990
+ runContentStart = $pos.pos - $pos.nodeBefore.nodeSize + 1;
140991
+ else {
140992
+ const prevNode = state.doc.resolve($pos.start() - 1).nodeBefore;
140993
+ runContentStart = $pos.start() - 1 - prevNode.nodeSize + 1;
140994
+ }
140995
+ const deleteRange2 = findPreviousTextDeleteRange(state.doc, $pos.pos, runContentStart);
140996
+ if (!deleteRange2)
140997
+ return false;
140998
+ tr.delete(deleteRange2.from, deleteRange2.to).setSelection(Selection.near(tr.doc.resolve(deleteRange2.from)));
140999
+ if (dispatch)
141000
+ dispatch(tr.scrollIntoView());
140905
141001
  return true;
140906
141002
  }, deleteSkipEmptyRun = () => ({ state, dispatch }) => {
140907
141003
  const sel = state.selection;
@@ -142736,7 +142832,84 @@ var Node$13 = class Node$14 {
142736
142832
  else if (event === "update")
142737
142833
  params$1.event = comments_module_events.UPDATE;
142738
142834
  return params$1;
142835
+ }, findDocPosByTextOffset = ({ doc: doc$2, from: from$12, to, textOffset }) => {
142836
+ let remaining = textOffset;
142837
+ let foundPos = null;
142838
+ doc$2.nodesBetween(from$12, to, (node3, pos) => {
142839
+ if (foundPos !== null)
142840
+ return false;
142841
+ if (!node3.isText || !node3.text)
142842
+ return;
142843
+ const nodeStart = Math.max(from$12, pos);
142844
+ const nodeEnd = Math.min(to, pos + node3.text.length);
142845
+ if (nodeStart >= nodeEnd)
142846
+ return;
142847
+ const nodeLen$1 = nodeEnd - nodeStart;
142848
+ if (remaining < nodeLen$1) {
142849
+ foundPos = nodeStart + remaining;
142850
+ return false;
142851
+ }
142852
+ remaining -= nodeLen$1;
142853
+ });
142854
+ return foundPos;
142855
+ }, normalizeReplaceStepSingleCharDelete = ({ step, doc: doc$2 }) => {
142856
+ if (!(step instanceof ReplaceStep) || step.from === step.to || step.to - step.from <= 1 || step.slice.content.size === 0)
142857
+ return step;
142858
+ const findSingleDeletedCharPos = ({ oldText, newText, from: from$12, to }) => {
142859
+ if (oldText.length - newText.length !== 1)
142860
+ return null;
142861
+ let prefix$2 = 0;
142862
+ while (prefix$2 < newText.length && oldText.charCodeAt(prefix$2) === newText.charCodeAt(prefix$2))
142863
+ prefix$2 += 1;
142864
+ let suffix$1 = 0;
142865
+ while (suffix$1 < newText.length - prefix$2 && oldText.charCodeAt(oldText.length - 1 - suffix$1) === newText.charCodeAt(newText.length - 1 - suffix$1))
142866
+ suffix$1 += 1;
142867
+ if (prefix$2 + suffix$1 !== newText.length)
142868
+ return null;
142869
+ return findDocPosByTextOffset({
142870
+ doc: doc$2,
142871
+ from: from$12,
142872
+ to,
142873
+ textOffset: prefix$2
142874
+ });
142875
+ };
142876
+ let deleteFrom = findSingleDeletedCharPos({
142877
+ oldText: doc$2.textBetween(step.from, step.to),
142878
+ newText: step.slice.content.textBetween(0, step.slice.content.size),
142879
+ from: step.from,
142880
+ to: step.to
142881
+ });
142882
+ if (deleteFrom === null) {
142883
+ const applied = step.apply(doc$2);
142884
+ if (applied.failed || !applied.doc)
142885
+ return step;
142886
+ deleteFrom = findSingleDeletedCharPos({
142887
+ oldText: doc$2.textBetween(0, doc$2.content.size),
142888
+ newText: applied.doc.textBetween(0, applied.doc.content.size),
142889
+ from: 0,
142890
+ to: doc$2.content.size
142891
+ });
142892
+ if (deleteFrom === null || deleteFrom < step.from || deleteFrom >= step.to)
142893
+ return step;
142894
+ }
142895
+ try {
142896
+ const deleteTo = deleteFrom + 1;
142897
+ const candidate = new ReplaceStep(deleteFrom, deleteTo, Slice.empty, step.structure);
142898
+ return candidate.apply(doc$2).failed ? step : candidate;
142899
+ } catch {
142900
+ return step;
142901
+ }
142739
142902
  }, replaceStep2 = ({ state, tr, step, newTr, map: map$22, user, date, originalStep, originalStepIndex }) => {
142903
+ const originalRange = {
142904
+ from: step.from,
142905
+ to: step.to,
142906
+ sliceSize: step.slice.content.size
142907
+ };
142908
+ step = normalizeReplaceStepSingleCharDelete({
142909
+ step,
142910
+ doc: newTr.doc
142911
+ });
142912
+ const stepWasNormalized = step.from !== originalRange.from || step.to !== originalRange.to || step.slice.content.size !== originalRange.sliceSize;
142740
142913
  if (step.from !== step.to && step.slice.content.size === 0) {
142741
142914
  let hasInlineContent = false;
142742
142915
  newTr.doc.nodesBetween(step.from, step.to, (node3) => {
@@ -142809,13 +142982,16 @@ var Node$13 = class Node$14 {
142809
142982
  });
142810
142983
  trackedInsertedSlice = tempTr.doc.slice(insertedFrom, insertedTo);
142811
142984
  }
142985
+ const docBeforeCondensedStep = newTr.doc;
142812
142986
  const condensedStep = new ReplaceStep(positionTo, positionTo, trackedInsertedSlice, false);
142813
142987
  if (newTr.maybeStep(condensedStep).failed) {
142814
142988
  if (!newTr.maybeStep(step).failed)
142815
142989
  map$22.appendMap(step.getMap());
142816
142990
  return;
142817
142991
  }
142818
- const invertStep = originalStep.invert(tr.docs[originalStepIndex]).map(map$22);
142992
+ const invertSourceStep = stepWasNormalized ? step : originalStep;
142993
+ const invertSourceDoc = stepWasNormalized ? docBeforeCondensedStep : tr.docs[originalStepIndex];
142994
+ const invertStep = stepWasNormalized ? invertSourceStep.invert(invertSourceDoc) : invertSourceStep.invert(invertSourceDoc).map(map$22);
142819
142995
  map$22.appendMap(invertStep.getMap());
142820
142996
  const mirrorIndex = map$22.maps.length - 1;
142821
142997
  map$22.appendMap(condensedStep.getMap(), mirrorIndex);
@@ -142842,6 +143018,8 @@ var Node$13 = class Node$14 {
142842
143018
  meta2.deletionMark = deletionMark;
142843
143019
  if (meta2.insertedTo !== undefined)
142844
143020
  meta2.insertedTo = deletionMap.map(meta2.insertedTo, 1);
143021
+ if (stepWasNormalized && !meta2.insertedMark)
143022
+ meta2.selectionPos = deletionMap.map(step.from, -1);
142845
143023
  map$22.appendMapping(deletionMap);
142846
143024
  }
142847
143025
  newTr.setMeta(TrackChangesBasePluginKey, meta2);
@@ -143130,7 +143308,14 @@ var Node$13 = class Node$14 {
143130
143308
  newTr.setMeta("addToHistory", tr.getMeta("addToHistory"));
143131
143309
  const trackMeta = newTr.getMeta(TrackChangesBasePluginKey);
143132
143310
  if (tr.selectionSet)
143133
- if (tr.selection instanceof TextSelection2 && (tr.selection.from < state.selection.from || tr.getMeta("inputType") === "deleteContentBackward")) {
143311
+ if (trackMeta?.selectionPos !== undefined && trackMeta?.selectionPos !== null) {
143312
+ const boundedPos = Math.max(0, Math.min(trackMeta.selectionPos, newTr.doc.content.size));
143313
+ const $pos = newTr.doc.resolve(boundedPos);
143314
+ if ($pos.parent.inlineContent)
143315
+ newTr.setSelection(TextSelection2.create(newTr.doc, boundedPos));
143316
+ else
143317
+ newTr.setSelection(TextSelection2.near($pos, -1));
143318
+ } else if (tr.selection instanceof TextSelection2 && (tr.selection.from < state.selection.from || tr.getMeta("inputType") === "deleteContentBackward")) {
143134
143319
  const caretPos = map$22.map(tr.selection.from, -1);
143135
143320
  newTr.setSelection(new TextSelection2(newTr.doc.resolve(caretPos)));
143136
143321
  } else if (trackMeta?.insertedTo !== undefined) {
@@ -143435,13 +143620,29 @@ var Node$13 = class Node$14 {
143435
143620
  day: "2-digit",
143436
143621
  year: "numeric"
143437
143622
  });
143438
- }, AnnotatorHelpers, updateYdocDocxData = async (editor, ydoc) => {
143623
+ }, AnnotatorHelpers, inFlightUpdates, updateYdocDocxData = (editor, ydoc) => {
143624
+ ydoc = ydoc || editor?.options?.ydoc;
143625
+ if (!ydoc || ydoc.isDestroyed)
143626
+ return Promise.resolve();
143627
+ if (!editor || editor.isDestroyed)
143628
+ return Promise.resolve();
143629
+ let ydocMap = inFlightUpdates.get(editor);
143630
+ if (!ydocMap) {
143631
+ ydocMap = /* @__PURE__ */ new WeakMap;
143632
+ inFlightUpdates.set(editor, ydocMap);
143633
+ }
143634
+ const existing = ydocMap.get(ydoc);
143635
+ if (existing)
143636
+ return existing;
143637
+ const promise = _doUpdateYdocDocxData(editor, ydoc).finally(() => {
143638
+ const map$22 = inFlightUpdates.get(editor);
143639
+ if (map$22 && map$22.get(ydoc) === promise)
143640
+ map$22.delete(ydoc);
143641
+ });
143642
+ ydocMap.set(ydoc, promise);
143643
+ return promise;
143644
+ }, _doUpdateYdocDocxData = async (editor, ydoc) => {
143439
143645
  try {
143440
- ydoc = ydoc || editor?.options?.ydoc;
143441
- if (!ydoc || ydoc.isDestroyed)
143442
- return;
143443
- if (!editor || editor.isDestroyed)
143444
- return;
143445
143646
  const metaMap = ydoc.getMap("meta");
143446
143647
  const docxValue = metaMap.get("docx");
143447
143648
  let docx = [];
@@ -143558,10 +143759,15 @@ var Node$13 = class Node$14 {
143558
143759
  if (value instanceof Set && value.has("docx"))
143559
143760
  return true;
143560
143761
  return false;
143762
+ }, debouncedDocxUpdateByEditor, cancelDebouncedDocxUpdate = (editor) => {
143763
+ const cancel = debouncedDocxUpdateByEditor.get(editor);
143764
+ if (cancel)
143765
+ cancel();
143561
143766
  }, initDocumentListener = ({ ydoc, editor }) => {
143562
143767
  const debouncedUpdate = debounce$2((editor$1) => {
143563
143768
  updateYdocDocxData(editor$1);
143564
143769
  }, 30000, { maxWait: 60000 });
143770
+ debouncedDocxUpdateByEditor.set(editor, () => debouncedUpdate.cancel());
143565
143771
  const afterTransactionHandler = (transaction) => {
143566
143772
  const { local } = transaction;
143567
143773
  if (!checkDocxChanged(transaction) && transaction.changed?.size && local)
@@ -143571,6 +143777,7 @@ var Node$13 = class Node$14 {
143571
143777
  return () => {
143572
143778
  ydoc.off("afterTransaction", afterTransactionHandler);
143573
143779
  debouncedUpdate.cancel();
143780
+ debouncedDocxUpdateByEditor.delete(editor);
143574
143781
  };
143575
143782
  }, debounce$2 = (fn, wait, { maxWait } = {}) => {
143576
143783
  let timeout$1 = null;
@@ -162519,9 +162726,9 @@ var Node$13 = class Node$14 {
162519
162726
  trackedChanges: context.trackedChanges ?? []
162520
162727
  });
162521
162728
  }, _hoisted_1$6, _hoisted_2$1, _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, RESIZE_HANDLE_WIDTH_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, 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;
162522
- var init_src_DEQEar7E_es = __esm(() => {
162729
+ var init_src_C0U0FLIH_es = __esm(() => {
162523
162730
  init_rolldown_runtime_B2q5OVn9_es();
162524
- init_SuperConverter_BJBbuXuZ_es();
162731
+ init_SuperConverter_Di_Lg_7T_es();
162525
162732
  init_jszip_ChlR43oI_es();
162526
162733
  init_uuid_2IzDu5nl_es();
162527
162734
  init_constants_Dw0kAsLd_es();
@@ -170442,6 +170649,7 @@ function print() { __p += __j.call(arguments, '') }
170442
170649
  annotateHeadersAndFooters,
170443
170650
  getAllHeaderFooterEditors
170444
170651
  };
170652
+ inFlightUpdates = /* @__PURE__ */ new WeakMap;
170445
170653
  new PluginKey("collaboration");
170446
170654
  headlessBindingStateByEditor = /* @__PURE__ */ new WeakMap;
170447
170655
  headlessCleanupRegisteredEditors = /* @__PURE__ */ new WeakSet;
@@ -170528,6 +170736,7 @@ function print() { __p += __j.call(arguments, '') }
170528
170736
  } };
170529
170737
  }
170530
170738
  });
170739
+ debouncedDocxUpdateByEditor = /* @__PURE__ */ new WeakMap;
170531
170740
  isHighContrastMode = ref2(false);
170532
170741
  ({ findChildren: findChildren$4 } = helpers_exports);
170533
170742
  ({ findChildren: findChildren$3 } = helpers_exports);
@@ -175518,7 +175727,8 @@ function print() { __p += __j.call(arguments, '') }
175518
175727
  this.#initMedia();
175519
175728
  this.initDefaultStyles();
175520
175729
  if (this.options.ydoc && this.options.collaborationProvider) {
175521
- updateYdocDocxData(this, this.options.ydoc);
175730
+ cancelDebouncedDocxUpdate(this);
175731
+ await updateYdocDocxData(this, this.options.ydoc);
175522
175732
  this.initializeCollaborationData();
175523
175733
  } else
175524
175734
  this.#insertNewFileData();
@@ -196055,8 +196265,8 @@ function print() { __p += __j.call(arguments, '') }
196055
196265
  return isObjectLike_default(value) && hasOwnProperty$8.call(value, "callee") && !propertyIsEnumerable$1.call(value, "callee");
196056
196266
  };
196057
196267
  stubFalse_default = stubFalse;
196058
- freeExports$2 = typeof exports_src_DEQEar7E_es == "object" && exports_src_DEQEar7E_es && !exports_src_DEQEar7E_es.nodeType && exports_src_DEQEar7E_es;
196059
- freeModule$2 = freeExports$2 && typeof module_src_DEQEar7E_es == "object" && module_src_DEQEar7E_es && !module_src_DEQEar7E_es.nodeType && module_src_DEQEar7E_es;
196268
+ freeExports$2 = typeof exports_src_C0U0FLIH_es == "object" && exports_src_C0U0FLIH_es && !exports_src_C0U0FLIH_es.nodeType && exports_src_C0U0FLIH_es;
196269
+ freeModule$2 = freeExports$2 && typeof module_src_C0U0FLIH_es == "object" && module_src_C0U0FLIH_es && !module_src_C0U0FLIH_es.nodeType && module_src_C0U0FLIH_es;
196060
196270
  Buffer$1 = freeModule$2 && freeModule$2.exports === freeExports$2 ? _root_default.Buffer : undefined;
196061
196271
  isBuffer_default = (Buffer$1 ? Buffer$1.isBuffer : undefined) || stubFalse_default;
196062
196272
  typedArrayTags = {};
@@ -196064,8 +196274,8 @@ function print() { __p += __j.call(arguments, '') }
196064
196274
  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;
196065
196275
  _baseIsTypedArray_default = baseIsTypedArray;
196066
196276
  _baseUnary_default = baseUnary;
196067
- freeExports$1 = typeof exports_src_DEQEar7E_es == "object" && exports_src_DEQEar7E_es && !exports_src_DEQEar7E_es.nodeType && exports_src_DEQEar7E_es;
196068
- freeModule$1 = freeExports$1 && typeof module_src_DEQEar7E_es == "object" && module_src_DEQEar7E_es && !module_src_DEQEar7E_es.nodeType && module_src_DEQEar7E_es;
196277
+ freeExports$1 = typeof exports_src_C0U0FLIH_es == "object" && exports_src_C0U0FLIH_es && !exports_src_C0U0FLIH_es.nodeType && exports_src_C0U0FLIH_es;
196278
+ freeModule$1 = freeExports$1 && typeof module_src_C0U0FLIH_es == "object" && module_src_C0U0FLIH_es && !module_src_C0U0FLIH_es.nodeType && module_src_C0U0FLIH_es;
196069
196279
  freeProcess = freeModule$1 && freeModule$1.exports === freeExports$1 && _freeGlobal_default.process;
196070
196280
  _nodeUtil_default = function() {
196071
196281
  try {
@@ -196170,8 +196380,8 @@ function print() { __p += __j.call(arguments, '') }
196170
196380
  Stack.prototype.has = _stackHas_default;
196171
196381
  Stack.prototype.set = _stackSet_default;
196172
196382
  _Stack_default = Stack;
196173
- freeExports = typeof exports_src_DEQEar7E_es == "object" && exports_src_DEQEar7E_es && !exports_src_DEQEar7E_es.nodeType && exports_src_DEQEar7E_es;
196174
- freeModule = freeExports && typeof module_src_DEQEar7E_es == "object" && module_src_DEQEar7E_es && !module_src_DEQEar7E_es.nodeType && module_src_DEQEar7E_es;
196383
+ freeExports = typeof exports_src_C0U0FLIH_es == "object" && exports_src_C0U0FLIH_es && !exports_src_C0U0FLIH_es.nodeType && exports_src_C0U0FLIH_es;
196384
+ freeModule = freeExports && typeof module_src_C0U0FLIH_es == "object" && module_src_C0U0FLIH_es && !module_src_C0U0FLIH_es.nodeType && module_src_C0U0FLIH_es;
196175
196385
  Buffer4 = freeModule && freeModule.exports === freeExports ? _root_default.Buffer : undefined;
196176
196386
  allocUnsafe = Buffer4 ? Buffer4.allocUnsafe : undefined;
196177
196387
  _cloneBuffer_default = cloneBuffer;
@@ -203823,8 +204033,8 @@ var init_zipper_Cnk_HjM2_es = __esm(() => {
203823
204033
 
203824
204034
  // ../../packages/superdoc/dist/super-editor.es.js
203825
204035
  var init_super_editor_es = __esm(() => {
203826
- init_src_DEQEar7E_es();
203827
- init_SuperConverter_BJBbuXuZ_es();
204036
+ init_src_C0U0FLIH_es();
204037
+ init_SuperConverter_Di_Lg_7T_es();
203828
204038
  init_jszip_ChlR43oI_es();
203829
204039
  init_xml_js_DLE8mr0n_es();
203830
204040
  init_constants_Dw0kAsLd_es();
@@ -251726,6 +251936,77 @@ var init_permEndImporter = __esm(() => {
251726
251936
  permEndHandlerEntity2 = generateV2HandlerEntity2("permEndHandler", translator151);
251727
251937
  });
251728
251938
 
251939
+ // ../../packages/super-editor/src/core/super-converter/v2/importer/normalizeDuplicateBlockIdentitiesInContent.js
251940
+ function toIdentityValue2(value) {
251941
+ if (typeof value === "string" && value.length > 0)
251942
+ return value;
251943
+ if (typeof value === "number" && Number.isFinite(value))
251944
+ return String(value);
251945
+ return;
251946
+ }
251947
+ function resolvePrimaryBlockIdentity2(node4) {
251948
+ if (!node4 || typeof node4 !== "object")
251949
+ return;
251950
+ const attrPriority = BLOCK_IDENTITY_ATTRS2[node4.type];
251951
+ if (!attrPriority)
251952
+ return;
251953
+ const attrs = typeof node4.attrs === "object" && node4.attrs ? node4.attrs : {};
251954
+ for (const attr of attrPriority) {
251955
+ const value = toIdentityValue2(attrs[attr]);
251956
+ if (value)
251957
+ return { id: value, source: attr };
251958
+ }
251959
+ return;
251960
+ }
251961
+ function nextUniqueDocxId2(usedIds) {
251962
+ let id2 = generateDocxRandomId2();
251963
+ while (usedIds.has(id2)) {
251964
+ id2 = generateDocxRandomId2();
251965
+ }
251966
+ return id2;
251967
+ }
251968
+ function dedupeBlockIdentitiesInNode2(node4, usedIds) {
251969
+ if (!node4 || typeof node4 !== "object")
251970
+ return;
251971
+ const identity2 = resolvePrimaryBlockIdentity2(node4);
251972
+ if (identity2) {
251973
+ if (usedIds.has(identity2.id)) {
251974
+ const replacementId = nextUniqueDocxId2(usedIds);
251975
+ node4.attrs = { ...node4.attrs, [identity2.source]: replacementId };
251976
+ usedIds.add(replacementId);
251977
+ } else {
251978
+ usedIds.add(identity2.id);
251979
+ }
251980
+ }
251981
+ if (Array.isArray(node4.content)) {
251982
+ node4.content.forEach((child) => dedupeBlockIdentitiesInNode2(child, usedIds));
251983
+ }
251984
+ }
251985
+ function normalizeDuplicateBlockIdentitiesInContent2(content5 = []) {
251986
+ if (!Array.isArray(content5) || content5.length === 0)
251987
+ return content5;
251988
+ const usedIds = new Set;
251989
+ content5.forEach((node4) => dedupeBlockIdentitiesInNode2(node4, usedIds));
251990
+ return content5;
251991
+ }
251992
+ var PARAGRAPH_IDENTITY_ATTRS2, TABLE_IDENTITY_ATTRS2, DEFAULT_BLOCK_IDENTITY_ATTRS2, BLOCK_IDENTITY_ATTRS2;
251993
+ var init_normalizeDuplicateBlockIdentitiesInContent = __esm(() => {
251994
+ PARAGRAPH_IDENTITY_ATTRS2 = ["sdBlockId", "paraId"];
251995
+ TABLE_IDENTITY_ATTRS2 = ["sdBlockId", "paraId", "blockId"];
251996
+ DEFAULT_BLOCK_IDENTITY_ATTRS2 = ["sdBlockId", "blockId", "paraId"];
251997
+ BLOCK_IDENTITY_ATTRS2 = {
251998
+ paragraph: PARAGRAPH_IDENTITY_ATTRS2,
251999
+ heading: DEFAULT_BLOCK_IDENTITY_ATTRS2,
252000
+ listItem: DEFAULT_BLOCK_IDENTITY_ATTRS2,
252001
+ table: TABLE_IDENTITY_ATTRS2,
252002
+ tableRow: TABLE_IDENTITY_ATTRS2,
252003
+ tableCell: TABLE_IDENTITY_ATTRS2,
252004
+ tableHeader: TABLE_IDENTITY_ATTRS2,
252005
+ sdt: DEFAULT_BLOCK_IDENTITY_ATTRS2,
252006
+ structuredContentBlock: DEFAULT_BLOCK_IDENTITY_ATTRS2
252007
+ };
252008
+ });
252009
+
251729
252010
  // ../../packages/super-editor/src/core/super-converter/v3/handlers/w/styles/index.js
251730
252011
  var init_styles2 = __esm(() => {
251731
252012
  init_styles_translator();
@@ -252415,6 +252696,7 @@ var detectDocumentOrigin2 = (docx) => {
252415
252696
  parsedContent = filterOutRootInlineNodes2(parsedContent);
252416
252697
  parsedContent = normalizeTableBookmarksInContent2(parsedContent, editor);
252417
252698
  collapseWhitespaceNextToInlinePassthrough2(parsedContent);
252699
+ parsedContent = normalizeDuplicateBlockIdentitiesInContent2(parsedContent);
252418
252700
  const result = {
252419
252701
  type: "doc",
252420
252702
  content: parsedContent,
@@ -252614,6 +252896,7 @@ var detectDocumentOrigin2 = (docx) => {
252614
252896
  path: []
252615
252897
  });
252616
252898
  schema = filterOutRootInlineNodes2(schema);
252899
+ schema = normalizeDuplicateBlockIdentitiesInContent2(schema);
252617
252900
  if (!converter.headerIds.ids)
252618
252901
  converter.headerIds.ids = [];
252619
252902
  converter.headerIds.ids.push(rId);
@@ -252643,6 +252926,7 @@ var detectDocumentOrigin2 = (docx) => {
252643
252926
  path: []
252644
252927
  });
252645
252928
  schema = filterOutRootInlineNodes2(schema);
252929
+ schema = normalizeDuplicateBlockIdentitiesInContent2(schema);
252646
252930
  if (!converter.footerIds.ids)
252647
252931
  converter.footerIds.ids = [];
252648
252932
  converter.footerIds.ids.push(rId);
@@ -252731,6 +253015,7 @@ var init_docxImporter = __esm(() => {
252731
253015
  init_commentRangeImporter();
252732
253016
  init_permStartImporter();
252733
253017
  init_permEndImporter();
253018
+ init_normalizeDuplicateBlockIdentitiesInContent();
252734
253019
  init_attributes7();
252735
253020
  init_attributes8();
252736
253021
  init_styles2();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/cli",
3
- "version": "0.2.0-next.21",
3
+ "version": "0.2.0-next.23",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "superdoc": "./dist/index.js"
@@ -20,19 +20,19 @@
20
20
  "@types/node": "22.19.2",
21
21
  "typescript": "^5.9.2",
22
22
  "@superdoc/document-api": "0.0.1",
23
- "superdoc": "1.16.0",
24
- "@superdoc/super-editor": "0.0.1"
23
+ "@superdoc/super-editor": "0.0.1",
24
+ "superdoc": "1.16.0"
25
25
  },
26
26
  "module": "src/index.ts",
27
27
  "publishConfig": {
28
28
  "access": "public"
29
29
  },
30
30
  "optionalDependencies": {
31
- "@superdoc-dev/cli-darwin-arm64": "0.2.0-next.21",
32
- "@superdoc-dev/cli-darwin-x64": "0.2.0-next.21",
33
- "@superdoc-dev/cli-linux-x64": "0.2.0-next.21",
34
- "@superdoc-dev/cli-linux-arm64": "0.2.0-next.21",
35
- "@superdoc-dev/cli-windows-x64": "0.2.0-next.21"
31
+ "@superdoc-dev/cli-darwin-arm64": "0.2.0-next.23",
32
+ "@superdoc-dev/cli-darwin-x64": "0.2.0-next.23",
33
+ "@superdoc-dev/cli-linux-x64": "0.2.0-next.23",
34
+ "@superdoc-dev/cli-linux-arm64": "0.2.0-next.23",
35
+ "@superdoc-dev/cli-windows-x64": "0.2.0-next.23"
36
36
  },
37
37
  "scripts": {
38
38
  "dev": "bun run src/index.ts",