@harbour-enterprises/superdoc 1.17.0-next.27 → 1.17.0-next.28

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.
@@ -34329,6 +34329,69 @@ const commentRangeStartHandlerEntity = generateV2HandlerEntity("commentRangeStar
34329
34329
  const commentRangeEndHandlerEntity = generateV2HandlerEntity("commentRangeEndHandler", commentRangeEndTranslator);
34330
34330
  const permStartHandlerEntity = generateV2HandlerEntity("permStartHandler", translator$13);
34331
34331
  const permEndHandlerEntity = generateV2HandlerEntity("permEndHandler", translator$14);
34332
+ var PARAGRAPH_IDENTITY_ATTRS = ["sdBlockId", "paraId"];
34333
+ var TABLE_IDENTITY_ATTRS = [
34334
+ "sdBlockId",
34335
+ "paraId",
34336
+ "blockId"
34337
+ ];
34338
+ var DEFAULT_BLOCK_IDENTITY_ATTRS = [
34339
+ "sdBlockId",
34340
+ "blockId",
34341
+ "paraId"
34342
+ ];
34343
+ var BLOCK_IDENTITY_ATTRS = {
34344
+ paragraph: PARAGRAPH_IDENTITY_ATTRS,
34345
+ heading: DEFAULT_BLOCK_IDENTITY_ATTRS,
34346
+ listItem: DEFAULT_BLOCK_IDENTITY_ATTRS,
34347
+ table: TABLE_IDENTITY_ATTRS,
34348
+ tableRow: TABLE_IDENTITY_ATTRS,
34349
+ tableCell: TABLE_IDENTITY_ATTRS,
34350
+ tableHeader: TABLE_IDENTITY_ATTRS,
34351
+ sdt: DEFAULT_BLOCK_IDENTITY_ATTRS,
34352
+ structuredContentBlock: DEFAULT_BLOCK_IDENTITY_ATTRS
34353
+ };
34354
+ function toIdentityValue(value) {
34355
+ if (typeof value === "string" && value.length > 0) return value;
34356
+ if (typeof value === "number" && Number.isFinite(value)) return String(value);
34357
+ }
34358
+ function resolvePrimaryBlockIdentity(node) {
34359
+ if (!node || typeof node !== "object") return void 0;
34360
+ const attrPriority = BLOCK_IDENTITY_ATTRS[node.type];
34361
+ if (!attrPriority) return void 0;
34362
+ const attrs = typeof node.attrs === "object" && node.attrs ? node.attrs : {};
34363
+ for (const attr of attrPriority) {
34364
+ const value = toIdentityValue(attrs[attr]);
34365
+ if (value) return {
34366
+ id: value,
34367
+ source: attr
34368
+ };
34369
+ }
34370
+ }
34371
+ function nextUniqueDocxId(usedIds) {
34372
+ let id = generateDocxRandomId();
34373
+ while (usedIds.has(id)) id = generateDocxRandomId();
34374
+ return id;
34375
+ }
34376
+ function dedupeBlockIdentitiesInNode(node, usedIds) {
34377
+ if (!node || typeof node !== "object") return;
34378
+ const identity = resolvePrimaryBlockIdentity(node);
34379
+ if (identity) if (usedIds.has(identity.id)) {
34380
+ const replacementId = nextUniqueDocxId(usedIds);
34381
+ node.attrs = {
34382
+ ...node.attrs,
34383
+ [identity.source]: replacementId
34384
+ };
34385
+ usedIds.add(replacementId);
34386
+ } else usedIds.add(identity.id);
34387
+ if (Array.isArray(node.content)) node.content.forEach((child) => dedupeBlockIdentitiesInNode(child, usedIds));
34388
+ }
34389
+ function normalizeDuplicateBlockIdentitiesInContent(content$2 = []) {
34390
+ if (!Array.isArray(content$2) || content$2.length === 0) return content$2;
34391
+ const usedIds = /* @__PURE__ */ new Set();
34392
+ content$2.forEach((node) => dedupeBlockIdentitiesInNode(node, usedIds));
34393
+ return content$2;
34394
+ }
34332
34395
  var WORD_2012_NAMESPACE = "http://schemas.microsoft.com/office/word/2012/wordml";
34333
34396
  function patchNumberingDefinitions(docx) {
34334
34397
  const numberingXml = docx?.["word/numbering.xml"];
@@ -34472,6 +34535,7 @@ const createDocumentJson = (docx, converter, editor) => {
34472
34535
  parsedContent = filterOutRootInlineNodes(parsedContent);
34473
34536
  parsedContent = normalizeTableBookmarksInContent(parsedContent, editor);
34474
34537
  collapseWhitespaceNextToInlinePassthrough(parsedContent);
34538
+ parsedContent = normalizeDuplicateBlockIdentitiesInContent(parsedContent);
34475
34539
  return {
34476
34540
  pmDoc: {
34477
34541
  type: "doc",
@@ -34820,6 +34884,7 @@ var importHeadersFooters = (docx, converter, mainEditor, numbering, translatedNu
34820
34884
  path: []
34821
34885
  });
34822
34886
  schema = filterOutRootInlineNodes(schema);
34887
+ schema = normalizeDuplicateBlockIdentitiesInContent(schema);
34823
34888
  if (!converter.headerIds.ids) converter.headerIds.ids = [];
34824
34889
  converter.headerIds.ids.push(rId);
34825
34890
  converter.headers[rId] = {
@@ -34845,6 +34910,7 @@ var importHeadersFooters = (docx, converter, mainEditor, numbering, translatedNu
34845
34910
  path: []
34846
34911
  });
34847
34912
  schema = filterOutRootInlineNodes(schema);
34913
+ schema = normalizeDuplicateBlockIdentitiesInContent(schema);
34848
34914
  if (!converter.footerIds.ids) converter.footerIds.ids = [];
34849
34915
  converter.footerIds.ids.push(rId);
34850
34916
  converter.footers[rId] = {
@@ -37177,7 +37243,7 @@ var SuperConverter = class SuperConverter {
37177
37243
  static getStoredSuperdocVersion(docx) {
37178
37244
  return SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
37179
37245
  }
37180
- static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.17.0-next.27") {
37246
+ static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.17.0-next.28") {
37181
37247
  return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version, false);
37182
37248
  }
37183
37249
  static generateWordTimestamp() {
@@ -34309,6 +34309,69 @@ const commentRangeStartHandlerEntity = generateV2HandlerEntity("commentRangeStar
34309
34309
  const commentRangeEndHandlerEntity = generateV2HandlerEntity("commentRangeEndHandler", commentRangeEndTranslator);
34310
34310
  const permStartHandlerEntity = generateV2HandlerEntity("permStartHandler", translator$13);
34311
34311
  const permEndHandlerEntity = generateV2HandlerEntity("permEndHandler", translator$14);
34312
+ var PARAGRAPH_IDENTITY_ATTRS = ["sdBlockId", "paraId"];
34313
+ var TABLE_IDENTITY_ATTRS = [
34314
+ "sdBlockId",
34315
+ "paraId",
34316
+ "blockId"
34317
+ ];
34318
+ var DEFAULT_BLOCK_IDENTITY_ATTRS = [
34319
+ "sdBlockId",
34320
+ "blockId",
34321
+ "paraId"
34322
+ ];
34323
+ var BLOCK_IDENTITY_ATTRS = {
34324
+ paragraph: PARAGRAPH_IDENTITY_ATTRS,
34325
+ heading: DEFAULT_BLOCK_IDENTITY_ATTRS,
34326
+ listItem: DEFAULT_BLOCK_IDENTITY_ATTRS,
34327
+ table: TABLE_IDENTITY_ATTRS,
34328
+ tableRow: TABLE_IDENTITY_ATTRS,
34329
+ tableCell: TABLE_IDENTITY_ATTRS,
34330
+ tableHeader: TABLE_IDENTITY_ATTRS,
34331
+ sdt: DEFAULT_BLOCK_IDENTITY_ATTRS,
34332
+ structuredContentBlock: DEFAULT_BLOCK_IDENTITY_ATTRS
34333
+ };
34334
+ function toIdentityValue(value) {
34335
+ if (typeof value === "string" && value.length > 0) return value;
34336
+ if (typeof value === "number" && Number.isFinite(value)) return String(value);
34337
+ }
34338
+ function resolvePrimaryBlockIdentity(node) {
34339
+ if (!node || typeof node !== "object") return void 0;
34340
+ const attrPriority = BLOCK_IDENTITY_ATTRS[node.type];
34341
+ if (!attrPriority) return void 0;
34342
+ const attrs = typeof node.attrs === "object" && node.attrs ? node.attrs : {};
34343
+ for (const attr of attrPriority) {
34344
+ const value = toIdentityValue(attrs[attr]);
34345
+ if (value) return {
34346
+ id: value,
34347
+ source: attr
34348
+ };
34349
+ }
34350
+ }
34351
+ function nextUniqueDocxId(usedIds) {
34352
+ let id = generateDocxRandomId();
34353
+ while (usedIds.has(id)) id = generateDocxRandomId();
34354
+ return id;
34355
+ }
34356
+ function dedupeBlockIdentitiesInNode(node, usedIds) {
34357
+ if (!node || typeof node !== "object") return;
34358
+ const identity = resolvePrimaryBlockIdentity(node);
34359
+ if (identity) if (usedIds.has(identity.id)) {
34360
+ const replacementId = nextUniqueDocxId(usedIds);
34361
+ node.attrs = {
34362
+ ...node.attrs,
34363
+ [identity.source]: replacementId
34364
+ };
34365
+ usedIds.add(replacementId);
34366
+ } else usedIds.add(identity.id);
34367
+ if (Array.isArray(node.content)) node.content.forEach((child) => dedupeBlockIdentitiesInNode(child, usedIds));
34368
+ }
34369
+ function normalizeDuplicateBlockIdentitiesInContent(content$2 = []) {
34370
+ if (!Array.isArray(content$2) || content$2.length === 0) return content$2;
34371
+ const usedIds = /* @__PURE__ */ new Set();
34372
+ content$2.forEach((node) => dedupeBlockIdentitiesInNode(node, usedIds));
34373
+ return content$2;
34374
+ }
34312
34375
  var WORD_2012_NAMESPACE = "http://schemas.microsoft.com/office/word/2012/wordml";
34313
34376
  function patchNumberingDefinitions(docx) {
34314
34377
  const numberingXml = docx?.["word/numbering.xml"];
@@ -34452,6 +34515,7 @@ const createDocumentJson = (docx, converter, editor) => {
34452
34515
  parsedContent = filterOutRootInlineNodes(parsedContent);
34453
34516
  parsedContent = normalizeTableBookmarksInContent(parsedContent, editor);
34454
34517
  collapseWhitespaceNextToInlinePassthrough(parsedContent);
34518
+ parsedContent = normalizeDuplicateBlockIdentitiesInContent(parsedContent);
34455
34519
  return {
34456
34520
  pmDoc: {
34457
34521
  type: "doc",
@@ -34800,6 +34864,7 @@ var importHeadersFooters = (docx, converter, mainEditor, numbering, translatedNu
34800
34864
  path: []
34801
34865
  });
34802
34866
  schema = filterOutRootInlineNodes(schema);
34867
+ schema = normalizeDuplicateBlockIdentitiesInContent(schema);
34803
34868
  if (!converter.headerIds.ids) converter.headerIds.ids = [];
34804
34869
  converter.headerIds.ids.push(rId);
34805
34870
  converter.headers[rId] = {
@@ -34825,6 +34890,7 @@ var importHeadersFooters = (docx, converter, mainEditor, numbering, translatedNu
34825
34890
  path: []
34826
34891
  });
34827
34892
  schema = filterOutRootInlineNodes(schema);
34893
+ schema = normalizeDuplicateBlockIdentitiesInContent(schema);
34828
34894
  if (!converter.footerIds.ids) converter.footerIds.ids = [];
34829
34895
  converter.footerIds.ids.push(rId);
34830
34896
  converter.footers[rId] = {
@@ -37157,7 +37223,7 @@ var SuperConverter = class SuperConverter {
37157
37223
  static getStoredSuperdocVersion(docx) {
37158
37224
  return SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
37159
37225
  }
37160
- static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.17.0-next.27") {
37226
+ static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.17.0-next.28") {
37161
37227
  return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version, false);
37162
37228
  }
37163
37229
  static generateWordTimestamp() {
@@ -1,5 +1,5 @@
1
1
  import { a as __toCommonJS, n as __esmMin, r as __export, t as __commonJSMin } from "./rolldown-runtime-B2q5OVn9.es.js";
2
- import { $ as Selection, A as findChildren$1, At as DOMSerializer, B as findParentNode, C as calculateResolvedParagraphProperties, Ct as resolveTableCellProperties, D as CommandService, Dt as TrackInsertMarkName, E as generateOrderedListIndex, Et as TrackFormatMarkName, F as isNodeActive, Ft as minMax, G as cleanSchemaItem, H as defaultBlockAt$1, I as getSchemaTypeNameByName, It as callOrGet, J as AllSelection, K as getSchemaTypeByName, L as isMarkActive, Lt as getExtensionConfigField, M as findMark, Mt as Mark$1, N as getMarksFromSelection, Nt as Schema$1, O as isInTable, Ot as carbonCopy, P as isActive, Pt as Slice, Q as PluginKey, R as getMarkRange, S as isList, St as resolveRunProperties, T as docxNumberingHelpers, Tt as TrackDeleteMarkName, U as getMarkType, V as findParentNodeClosestToPos, W as getNodeType, X as NodeSelection, Y as EditorState, Z as Plugin, _ as inputRulesPlugin, _t as encodeCSSFromPPr, a as translator, at as ReplaceAroundStep$1, b as changeListLevel, bt as resolveDocxFontFamily, c as updateDOMAttributes, ct as canJoin, d as markdownToPmFragment, dt as joinPoint, et as SelectionRange, f as createDocFromHTML, ft as liftTarget, g as htmlHandler, gt as decodeRPrFromMarks, h as handleClipboardPaste, ht as generateRandomSigned32BitIntStrId, it as RemoveMarkStep, j as getActiveFormatting, jt as Fragment$1, k as posToDOMRect, kt as DOMParser$1, l as processContent, lt as canSplit, m as InputRule, mt as generateDocxRandomId, n as kebabCase$1, nt as AddMarkStep, o as _getReferencedTableStyles, ot as ReplaceStep, p as createCellBorders, pt as replaceStep$1, q as createDocument, r as insertNewRelationship, rt as Mapping, s as helpers_exports, st as Transform, t as SuperConverter, tt as TextSelection$1, u as createDocFromMarkdown, ut as dropPoint, v as unflattenListsInHtml, vt as encodeCSSFromRPr, w as getResolvedParagraphProperties, wt as getUnderlineCssString, x as updateNumberingProperties, xt as resolveParagraphProperties, y as ListHelpers, yt as encodeMarksFromRPr, z as isTextSelection } from "./SuperConverter-B_fGJA0T.es.js";
2
+ import { $ as Selection, A as findChildren$1, At as DOMSerializer, B as findParentNode, C as calculateResolvedParagraphProperties, Ct as resolveTableCellProperties, D as CommandService, Dt as TrackInsertMarkName, E as generateOrderedListIndex, Et as TrackFormatMarkName, F as isNodeActive, Ft as minMax, G as cleanSchemaItem, H as defaultBlockAt$1, I as getSchemaTypeNameByName, It as callOrGet, J as AllSelection, K as getSchemaTypeByName, L as isMarkActive, Lt as getExtensionConfigField, M as findMark, Mt as Mark$1, N as getMarksFromSelection, Nt as Schema$1, O as isInTable, Ot as carbonCopy, P as isActive, Pt as Slice, Q as PluginKey, R as getMarkRange, S as isList, St as resolveRunProperties, T as docxNumberingHelpers, Tt as TrackDeleteMarkName, U as getMarkType, V as findParentNodeClosestToPos, W as getNodeType, X as NodeSelection, Y as EditorState, Z as Plugin, _ as inputRulesPlugin, _t as encodeCSSFromPPr, a as translator, at as ReplaceAroundStep$1, b as changeListLevel, bt as resolveDocxFontFamily, c as updateDOMAttributes, ct as canJoin, d as markdownToPmFragment, dt as joinPoint, et as SelectionRange, f as createDocFromHTML, ft as liftTarget, g as htmlHandler, gt as decodeRPrFromMarks, h as handleClipboardPaste, ht as generateRandomSigned32BitIntStrId, it as RemoveMarkStep, j as getActiveFormatting, jt as Fragment$1, k as posToDOMRect, kt as DOMParser$1, l as processContent, lt as canSplit, m as InputRule, mt as generateDocxRandomId, n as kebabCase$1, nt as AddMarkStep, o as _getReferencedTableStyles, ot as ReplaceStep, p as createCellBorders, pt as replaceStep$1, q as createDocument, r as insertNewRelationship, rt as Mapping, s as helpers_exports, st as Transform, t as SuperConverter, tt as TextSelection$1, u as createDocFromMarkdown, ut as dropPoint, v as unflattenListsInHtml, vt as encodeCSSFromRPr, w as getResolvedParagraphProperties, wt as getUnderlineCssString, x as updateNumberingProperties, xt as resolveParagraphProperties, y as ListHelpers, yt as encodeMarksFromRPr, z as isTextSelection } from "./SuperConverter-D1bmhLzc.es.js";
3
3
  import { a as init_dist$2, i as global, n as init_dist, o as Buffer$3, r as process$1, s as init_dist$1 } from "./jszip-ChlR43oI.es.js";
4
4
  import { t as v4_default } from "./uuid-2IzDu5nl.es.js";
5
5
  import { A as ptToTwips, D as pixelsToTwips, F as twipsToInches, I as twipsToLines, L as twipsToPixels, S as linesToTwips, b as inchesToTwips, c as convertSizeToCSS, j as resolveOpcTargetPath, m as getArrayBufferFromUrl, t as COMMENT_FILE_BASENAMES, v as halfPointToPoints, y as inchesToPixels } from "./constants-Dw0kAsLd.es.js";
@@ -260,7 +260,7 @@ var v_click_outside_default = {
260
260
  var DEFAULT_ENDPOINT = "https://ingest.superdoc.dev/v1/collect";
261
261
  function getSuperdocVersion() {
262
262
  try {
263
- return "1.17.0-next.27";
263
+ return "1.17.0-next.28";
264
264
  } catch {
265
265
  return "unknown";
266
266
  }
@@ -10793,7 +10793,8 @@ const selectAll$1 = () => ({ state, dispatch }) => selectAll(state, dispatch);
10793
10793
  const deleteSelection$1 = () => ({ state, tr, dispatch }) => {
10794
10794
  const { from: from$1, to, empty: empty$2 } = state.selection;
10795
10795
  if (typeof document !== "undefined" && document.getSelection) {
10796
- if (document.getSelection()?.baseNode?.data?.length === 1) return false;
10796
+ const currentDomSelection = document.getSelection();
10797
+ if (empty$2 && currentDomSelection?.baseNode?.data?.length === 1) return false;
10797
10798
  }
10798
10799
  if (empty$2) return deleteSelection(state, dispatch);
10799
10800
  let hasListContent = false;
@@ -11646,6 +11647,17 @@ const backspaceSkipEmptyRun = () => ({ state, dispatch }) => {
11646
11647
  if (dispatch) dispatch(state.tr.delete(pos - 1, pos).scrollIntoView());
11647
11648
  return true;
11648
11649
  };
11650
+ var findPreviousTextDeleteRange = (doc$2, cursorPos, minPos) => {
11651
+ for (let pos = cursorPos - 1; pos >= minPos; pos -= 1) {
11652
+ const nodeBefore = doc$2.resolve(pos).nodeBefore;
11653
+ if (!nodeBefore?.isText || !nodeBefore.text?.length) continue;
11654
+ return {
11655
+ from: pos - 1,
11656
+ to: pos
11657
+ };
11658
+ }
11659
+ return null;
11660
+ };
11649
11661
  const backspaceNextToRun = () => ({ state, tr, dispatch }) => {
11650
11662
  const sel = state.selection;
11651
11663
  if (!sel.empty) return false;
@@ -11654,14 +11666,20 @@ const backspaceNextToRun = () => ({ state, tr, dispatch }) => {
11654
11666
  if ($pos.nodeBefore?.type !== runType && $pos.pos !== $pos.start()) return false;
11655
11667
  if ($pos.nodeBefore) {
11656
11668
  if ($pos.nodeBefore.content.size === 0) return false;
11657
- tr.delete($pos.pos - 2, $pos.pos - 1).setSelection(Selection.near(tr.doc.resolve($pos.pos - 2)));
11658
- if (dispatch) dispatch(tr.scrollIntoView());
11659
11669
  } else {
11660
11670
  const prevNode = state.doc.resolve($pos.start() - 1).nodeBefore;
11661
11671
  if (prevNode?.type !== runType || prevNode.content.size === 0) return false;
11662
- tr.delete($pos.pos - 3, $pos.pos - 2).setSelection(Selection.near(tr.doc.resolve($pos.pos - 3)));
11663
- if (dispatch) dispatch(tr.scrollIntoView());
11664
11672
  }
11673
+ let runContentStart;
11674
+ if ($pos.nodeBefore) runContentStart = $pos.pos - $pos.nodeBefore.nodeSize + 1;
11675
+ else {
11676
+ const prevNode = state.doc.resolve($pos.start() - 1).nodeBefore;
11677
+ runContentStart = $pos.start() - 1 - prevNode.nodeSize + 1;
11678
+ }
11679
+ const deleteRange = findPreviousTextDeleteRange(state.doc, $pos.pos, runContentStart);
11680
+ if (!deleteRange) return false;
11681
+ tr.delete(deleteRange.from, deleteRange.to).setSelection(Selection.near(tr.doc.resolve(deleteRange.from)));
11682
+ if (dispatch) dispatch(tr.scrollIntoView());
11665
11683
  return true;
11666
11684
  };
11667
11685
  const deleteSkipEmptyRun = () => ({ state, dispatch }) => {
@@ -14205,7 +14223,76 @@ function findRangeById(doc$2, id) {
14205
14223
  to
14206
14224
  } : null;
14207
14225
  }
14226
+ var findDocPosByTextOffset = ({ doc: doc$2, from: from$1, to, textOffset }) => {
14227
+ let remaining = textOffset;
14228
+ let foundPos = null;
14229
+ doc$2.nodesBetween(from$1, to, (node, pos) => {
14230
+ if (foundPos !== null) return false;
14231
+ if (!node.isText || !node.text) return;
14232
+ const nodeStart = Math.max(from$1, pos);
14233
+ const nodeEnd = Math.min(to, pos + node.text.length);
14234
+ if (nodeStart >= nodeEnd) return;
14235
+ const nodeLen$1 = nodeEnd - nodeStart;
14236
+ if (remaining < nodeLen$1) {
14237
+ foundPos = nodeStart + remaining;
14238
+ return false;
14239
+ }
14240
+ remaining -= nodeLen$1;
14241
+ });
14242
+ return foundPos;
14243
+ };
14244
+ var normalizeReplaceStepSingleCharDelete = ({ step, doc: doc$2 }) => {
14245
+ if (!(step instanceof ReplaceStep) || step.from === step.to || step.to - step.from <= 1 || step.slice.content.size === 0) return step;
14246
+ const findSingleDeletedCharPos = ({ oldText, newText, from: from$1, to }) => {
14247
+ if (oldText.length - newText.length !== 1) return null;
14248
+ let prefix$2 = 0;
14249
+ while (prefix$2 < newText.length && oldText.charCodeAt(prefix$2) === newText.charCodeAt(prefix$2)) prefix$2 += 1;
14250
+ let suffix$1 = 0;
14251
+ while (suffix$1 < newText.length - prefix$2 && oldText.charCodeAt(oldText.length - 1 - suffix$1) === newText.charCodeAt(newText.length - 1 - suffix$1)) suffix$1 += 1;
14252
+ if (prefix$2 + suffix$1 !== newText.length) return null;
14253
+ return findDocPosByTextOffset({
14254
+ doc: doc$2,
14255
+ from: from$1,
14256
+ to,
14257
+ textOffset: prefix$2
14258
+ });
14259
+ };
14260
+ let deleteFrom = findSingleDeletedCharPos({
14261
+ oldText: doc$2.textBetween(step.from, step.to),
14262
+ newText: step.slice.content.textBetween(0, step.slice.content.size),
14263
+ from: step.from,
14264
+ to: step.to
14265
+ });
14266
+ if (deleteFrom === null) {
14267
+ const applied = step.apply(doc$2);
14268
+ if (applied.failed || !applied.doc) return step;
14269
+ deleteFrom = findSingleDeletedCharPos({
14270
+ oldText: doc$2.textBetween(0, doc$2.content.size),
14271
+ newText: applied.doc.textBetween(0, applied.doc.content.size),
14272
+ from: 0,
14273
+ to: doc$2.content.size
14274
+ });
14275
+ if (deleteFrom === null || deleteFrom < step.from || deleteFrom >= step.to) return step;
14276
+ }
14277
+ try {
14278
+ const deleteTo = deleteFrom + 1;
14279
+ const candidate = new ReplaceStep(deleteFrom, deleteTo, Slice.empty, step.structure);
14280
+ return candidate.apply(doc$2).failed ? step : candidate;
14281
+ } catch {
14282
+ return step;
14283
+ }
14284
+ };
14208
14285
  const replaceStep = ({ state, tr, step, newTr, map: map$2, user, date, originalStep, originalStepIndex }) => {
14286
+ const originalRange = {
14287
+ from: step.from,
14288
+ to: step.to,
14289
+ sliceSize: step.slice.content.size
14290
+ };
14291
+ step = normalizeReplaceStepSingleCharDelete({
14292
+ step,
14293
+ doc: newTr.doc
14294
+ });
14295
+ const stepWasNormalized = step.from !== originalRange.from || step.to !== originalRange.to || step.slice.content.size !== originalRange.sliceSize;
14209
14296
  if (step.from !== step.to && step.slice.content.size === 0) {
14210
14297
  let hasInlineContent = false;
14211
14298
  newTr.doc.nodesBetween(step.from, step.to, (node) => {
@@ -14272,12 +14359,15 @@ const replaceStep = ({ state, tr, step, newTr, map: map$2, user, date, originalS
14272
14359
  });
14273
14360
  trackedInsertedSlice = tempTr.doc.slice(insertedFrom, insertedTo);
14274
14361
  }
14362
+ const docBeforeCondensedStep = newTr.doc;
14275
14363
  const condensedStep = new ReplaceStep(positionTo, positionTo, trackedInsertedSlice, false);
14276
14364
  if (newTr.maybeStep(condensedStep).failed) {
14277
14365
  if (!newTr.maybeStep(step).failed) map$2.appendMap(step.getMap());
14278
14366
  return;
14279
14367
  }
14280
- const invertStep = originalStep.invert(tr.docs[originalStepIndex]).map(map$2);
14368
+ const invertSourceStep = stepWasNormalized ? step : originalStep;
14369
+ const invertSourceDoc = stepWasNormalized ? docBeforeCondensedStep : tr.docs[originalStepIndex];
14370
+ const invertStep = stepWasNormalized ? invertSourceStep.invert(invertSourceDoc) : invertSourceStep.invert(invertSourceDoc).map(map$2);
14281
14371
  map$2.appendMap(invertStep.getMap());
14282
14372
  const mirrorIndex = map$2.maps.length - 1;
14283
14373
  map$2.appendMap(condensedStep.getMap(), mirrorIndex);
@@ -14302,6 +14392,7 @@ const replaceStep = ({ state, tr, step, newTr, map: map$2, user, date, originalS
14302
14392
  meta.deletionNodes = deletionNodes;
14303
14393
  meta.deletionMark = deletionMark;
14304
14394
  if (meta.insertedTo !== void 0) meta.insertedTo = deletionMap.map(meta.insertedTo, 1);
14395
+ if (stepWasNormalized && !meta.insertedMark) meta.selectionPos = deletionMap.map(step.from, -1);
14305
14396
  map$2.appendMapping(deletionMap);
14306
14397
  }
14307
14398
  newTr.setMeta(TrackChangesBasePluginKey, meta);
@@ -19149,7 +19240,12 @@ const trackedTransaction = ({ tr, state, user }) => {
19149
19240
  if (tr.getMeta("uiEvent")) newTr.setMeta("uiEvent", tr.getMeta("uiEvent"));
19150
19241
  if (tr.getMeta("addToHistory") !== void 0) newTr.setMeta("addToHistory", tr.getMeta("addToHistory"));
19151
19242
  const trackMeta = newTr.getMeta(TrackChangesBasePluginKey);
19152
- if (tr.selectionSet) if (tr.selection instanceof TextSelection$1 && (tr.selection.from < state.selection.from || tr.getMeta("inputType") === "deleteContentBackward")) {
19243
+ if (tr.selectionSet) if (trackMeta?.selectionPos !== void 0 && trackMeta?.selectionPos !== null) {
19244
+ const boundedPos = Math.max(0, Math.min(trackMeta.selectionPos, newTr.doc.content.size));
19245
+ const $pos = newTr.doc.resolve(boundedPos);
19246
+ if ($pos.parent.inlineContent) newTr.setSelection(TextSelection$1.create(newTr.doc, boundedPos));
19247
+ else newTr.setSelection(TextSelection$1.near($pos, -1));
19248
+ } else if (tr.selection instanceof TextSelection$1 && (tr.selection.from < state.selection.from || tr.getMeta("inputType") === "deleteContentBackward")) {
19153
19249
  const caretPos = map$2.map(tr.selection.from, -1);
19154
19250
  newTr.setSelection(new TextSelection$1(newTr.doc.resolve(caretPos)));
19155
19251
  } else if (trackMeta?.insertedTo !== void 0) {
@@ -20779,7 +20875,7 @@ const canUseDOM = () => {
20779
20875
  return false;
20780
20876
  }
20781
20877
  };
20782
- var summaryVersion = "1.17.0-next.27";
20878
+ var summaryVersion = "1.17.0-next.28";
20783
20879
  var nodeKeys = [
20784
20880
  "group",
20785
20881
  "content",
@@ -35494,7 +35590,7 @@ var Editor = class Editor extends EventEmitter$1 {
35494
35590
  return migrations.length > 0;
35495
35591
  }
35496
35592
  processCollaborationMigrations() {
35497
- console.debug("[checkVersionMigrations] Current editor version", "1.17.0-next.27");
35593
+ console.debug("[checkVersionMigrations] Current editor version", "1.17.0-next.28");
35498
35594
  if (!this.options.ydoc) return;
35499
35595
  let docVersion = this.options.ydoc.getMap("meta").get("version");
35500
35596
  if (!docVersion) docVersion = "initial";
@@ -1,5 +1,5 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-Dp2H1eGw.cjs");
2
- const require_SuperConverter = require("./SuperConverter-EZm4rCaZ.cjs");
2
+ const require_SuperConverter = require("./SuperConverter-5-aFSmDM.cjs");
3
3
  const require_jszip = require("./jszip-DCT9QYaK.cjs");
4
4
  const require_uuid = require("./uuid-CHj_rjgt.cjs");
5
5
  const require_constants = require("./constants-C-hTr4No.cjs");
@@ -261,7 +261,7 @@ var DEFAULT_ENDPOINT = "https://ingest.superdoc.dev/v1/collect";
261
261
  const COMMUNITY_LICENSE_KEY = "community-and-eval-agplv3";
262
262
  function getSuperdocVersion() {
263
263
  try {
264
- return "1.17.0-next.27";
264
+ return "1.17.0-next.28";
265
265
  } catch {
266
266
  return "unknown";
267
267
  }
@@ -10812,7 +10812,8 @@ const selectAll$1 = () => ({ state, dispatch }) => selectAll(state, dispatch);
10812
10812
  const deleteSelection$1 = () => ({ state, tr, dispatch }) => {
10813
10813
  const { from: from$1, to, empty: empty$2 } = state.selection;
10814
10814
  if (typeof document !== "undefined" && document.getSelection) {
10815
- if (document.getSelection()?.baseNode?.data?.length === 1) return false;
10815
+ const currentDomSelection = document.getSelection();
10816
+ if (empty$2 && currentDomSelection?.baseNode?.data?.length === 1) return false;
10816
10817
  }
10817
10818
  if (empty$2) return deleteSelection(state, dispatch);
10818
10819
  let hasListContent = false;
@@ -11665,6 +11666,17 @@ const backspaceSkipEmptyRun = () => ({ state, dispatch }) => {
11665
11666
  if (dispatch) dispatch(state.tr.delete(pos - 1, pos).scrollIntoView());
11666
11667
  return true;
11667
11668
  };
11669
+ var findPreviousTextDeleteRange = (doc$2, cursorPos, minPos) => {
11670
+ for (let pos = cursorPos - 1; pos >= minPos; pos -= 1) {
11671
+ const nodeBefore = doc$2.resolve(pos).nodeBefore;
11672
+ if (!nodeBefore?.isText || !nodeBefore.text?.length) continue;
11673
+ return {
11674
+ from: pos - 1,
11675
+ to: pos
11676
+ };
11677
+ }
11678
+ return null;
11679
+ };
11668
11680
  const backspaceNextToRun = () => ({ state, tr, dispatch }) => {
11669
11681
  const sel = state.selection;
11670
11682
  if (!sel.empty) return false;
@@ -11673,14 +11685,20 @@ const backspaceNextToRun = () => ({ state, tr, dispatch }) => {
11673
11685
  if ($pos.nodeBefore?.type !== runType && $pos.pos !== $pos.start()) return false;
11674
11686
  if ($pos.nodeBefore) {
11675
11687
  if ($pos.nodeBefore.content.size === 0) return false;
11676
- tr.delete($pos.pos - 2, $pos.pos - 1).setSelection(require_SuperConverter.Selection.near(tr.doc.resolve($pos.pos - 2)));
11677
- if (dispatch) dispatch(tr.scrollIntoView());
11678
11688
  } else {
11679
11689
  const prevNode = state.doc.resolve($pos.start() - 1).nodeBefore;
11680
11690
  if (prevNode?.type !== runType || prevNode.content.size === 0) return false;
11681
- tr.delete($pos.pos - 3, $pos.pos - 2).setSelection(require_SuperConverter.Selection.near(tr.doc.resolve($pos.pos - 3)));
11682
- if (dispatch) dispatch(tr.scrollIntoView());
11683
11691
  }
11692
+ let runContentStart;
11693
+ if ($pos.nodeBefore) runContentStart = $pos.pos - $pos.nodeBefore.nodeSize + 1;
11694
+ else {
11695
+ const prevNode = state.doc.resolve($pos.start() - 1).nodeBefore;
11696
+ runContentStart = $pos.start() - 1 - prevNode.nodeSize + 1;
11697
+ }
11698
+ const deleteRange = findPreviousTextDeleteRange(state.doc, $pos.pos, runContentStart);
11699
+ if (!deleteRange) return false;
11700
+ tr.delete(deleteRange.from, deleteRange.to).setSelection(require_SuperConverter.Selection.near(tr.doc.resolve(deleteRange.from)));
11701
+ if (dispatch) dispatch(tr.scrollIntoView());
11684
11702
  return true;
11685
11703
  };
11686
11704
  const deleteSkipEmptyRun = () => ({ state, dispatch }) => {
@@ -14224,7 +14242,76 @@ function findRangeById(doc$2, id) {
14224
14242
  to
14225
14243
  } : null;
14226
14244
  }
14245
+ var findDocPosByTextOffset = ({ doc: doc$2, from: from$1, to, textOffset }) => {
14246
+ let remaining = textOffset;
14247
+ let foundPos = null;
14248
+ doc$2.nodesBetween(from$1, to, (node, pos) => {
14249
+ if (foundPos !== null) return false;
14250
+ if (!node.isText || !node.text) return;
14251
+ const nodeStart = Math.max(from$1, pos);
14252
+ const nodeEnd = Math.min(to, pos + node.text.length);
14253
+ if (nodeStart >= nodeEnd) return;
14254
+ const nodeLen$1 = nodeEnd - nodeStart;
14255
+ if (remaining < nodeLen$1) {
14256
+ foundPos = nodeStart + remaining;
14257
+ return false;
14258
+ }
14259
+ remaining -= nodeLen$1;
14260
+ });
14261
+ return foundPos;
14262
+ };
14263
+ var normalizeReplaceStepSingleCharDelete = ({ step, doc: doc$2 }) => {
14264
+ if (!(step instanceof require_SuperConverter.ReplaceStep) || step.from === step.to || step.to - step.from <= 1 || step.slice.content.size === 0) return step;
14265
+ const findSingleDeletedCharPos = ({ oldText, newText, from: from$1, to }) => {
14266
+ if (oldText.length - newText.length !== 1) return null;
14267
+ let prefix$2 = 0;
14268
+ while (prefix$2 < newText.length && oldText.charCodeAt(prefix$2) === newText.charCodeAt(prefix$2)) prefix$2 += 1;
14269
+ let suffix$1 = 0;
14270
+ while (suffix$1 < newText.length - prefix$2 && oldText.charCodeAt(oldText.length - 1 - suffix$1) === newText.charCodeAt(newText.length - 1 - suffix$1)) suffix$1 += 1;
14271
+ if (prefix$2 + suffix$1 !== newText.length) return null;
14272
+ return findDocPosByTextOffset({
14273
+ doc: doc$2,
14274
+ from: from$1,
14275
+ to,
14276
+ textOffset: prefix$2
14277
+ });
14278
+ };
14279
+ let deleteFrom = findSingleDeletedCharPos({
14280
+ oldText: doc$2.textBetween(step.from, step.to),
14281
+ newText: step.slice.content.textBetween(0, step.slice.content.size),
14282
+ from: step.from,
14283
+ to: step.to
14284
+ });
14285
+ if (deleteFrom === null) {
14286
+ const applied = step.apply(doc$2);
14287
+ if (applied.failed || !applied.doc) return step;
14288
+ deleteFrom = findSingleDeletedCharPos({
14289
+ oldText: doc$2.textBetween(0, doc$2.content.size),
14290
+ newText: applied.doc.textBetween(0, applied.doc.content.size),
14291
+ from: 0,
14292
+ to: doc$2.content.size
14293
+ });
14294
+ if (deleteFrom === null || deleteFrom < step.from || deleteFrom >= step.to) return step;
14295
+ }
14296
+ try {
14297
+ const deleteTo = deleteFrom + 1;
14298
+ const candidate = new require_SuperConverter.ReplaceStep(deleteFrom, deleteTo, require_SuperConverter.Slice.empty, step.structure);
14299
+ return candidate.apply(doc$2).failed ? step : candidate;
14300
+ } catch {
14301
+ return step;
14302
+ }
14303
+ };
14227
14304
  const replaceStep = ({ state, tr, step, newTr, map: map$2, user, date, originalStep, originalStepIndex }) => {
14305
+ const originalRange = {
14306
+ from: step.from,
14307
+ to: step.to,
14308
+ sliceSize: step.slice.content.size
14309
+ };
14310
+ step = normalizeReplaceStepSingleCharDelete({
14311
+ step,
14312
+ doc: newTr.doc
14313
+ });
14314
+ const stepWasNormalized = step.from !== originalRange.from || step.to !== originalRange.to || step.slice.content.size !== originalRange.sliceSize;
14228
14315
  if (step.from !== step.to && step.slice.content.size === 0) {
14229
14316
  let hasInlineContent = false;
14230
14317
  newTr.doc.nodesBetween(step.from, step.to, (node) => {
@@ -14291,12 +14378,15 @@ const replaceStep = ({ state, tr, step, newTr, map: map$2, user, date, originalS
14291
14378
  });
14292
14379
  trackedInsertedSlice = tempTr.doc.slice(insertedFrom, insertedTo);
14293
14380
  }
14381
+ const docBeforeCondensedStep = newTr.doc;
14294
14382
  const condensedStep = new require_SuperConverter.ReplaceStep(positionTo, positionTo, trackedInsertedSlice, false);
14295
14383
  if (newTr.maybeStep(condensedStep).failed) {
14296
14384
  if (!newTr.maybeStep(step).failed) map$2.appendMap(step.getMap());
14297
14385
  return;
14298
14386
  }
14299
- const invertStep = originalStep.invert(tr.docs[originalStepIndex]).map(map$2);
14387
+ const invertSourceStep = stepWasNormalized ? step : originalStep;
14388
+ const invertSourceDoc = stepWasNormalized ? docBeforeCondensedStep : tr.docs[originalStepIndex];
14389
+ const invertStep = stepWasNormalized ? invertSourceStep.invert(invertSourceDoc) : invertSourceStep.invert(invertSourceDoc).map(map$2);
14300
14390
  map$2.appendMap(invertStep.getMap());
14301
14391
  const mirrorIndex = map$2.maps.length - 1;
14302
14392
  map$2.appendMap(condensedStep.getMap(), mirrorIndex);
@@ -14321,6 +14411,7 @@ const replaceStep = ({ state, tr, step, newTr, map: map$2, user, date, originalS
14321
14411
  meta.deletionNodes = deletionNodes;
14322
14412
  meta.deletionMark = deletionMark;
14323
14413
  if (meta.insertedTo !== void 0) meta.insertedTo = deletionMap.map(meta.insertedTo, 1);
14414
+ if (stepWasNormalized && !meta.insertedMark) meta.selectionPos = deletionMap.map(step.from, -1);
14324
14415
  map$2.appendMapping(deletionMap);
14325
14416
  }
14326
14417
  newTr.setMeta(TrackChangesBasePluginKey, meta);
@@ -19168,7 +19259,12 @@ const trackedTransaction = ({ tr, state, user }) => {
19168
19259
  if (tr.getMeta("uiEvent")) newTr.setMeta("uiEvent", tr.getMeta("uiEvent"));
19169
19260
  if (tr.getMeta("addToHistory") !== void 0) newTr.setMeta("addToHistory", tr.getMeta("addToHistory"));
19170
19261
  const trackMeta = newTr.getMeta(TrackChangesBasePluginKey);
19171
- if (tr.selectionSet) if (tr.selection instanceof require_SuperConverter.TextSelection && (tr.selection.from < state.selection.from || tr.getMeta("inputType") === "deleteContentBackward")) {
19262
+ if (tr.selectionSet) if (trackMeta?.selectionPos !== void 0 && trackMeta?.selectionPos !== null) {
19263
+ const boundedPos = Math.max(0, Math.min(trackMeta.selectionPos, newTr.doc.content.size));
19264
+ const $pos = newTr.doc.resolve(boundedPos);
19265
+ if ($pos.parent.inlineContent) newTr.setSelection(require_SuperConverter.TextSelection.create(newTr.doc, boundedPos));
19266
+ else newTr.setSelection(require_SuperConverter.TextSelection.near($pos, -1));
19267
+ } else if (tr.selection instanceof require_SuperConverter.TextSelection && (tr.selection.from < state.selection.from || tr.getMeta("inputType") === "deleteContentBackward")) {
19172
19268
  const caretPos = map$2.map(tr.selection.from, -1);
19173
19269
  newTr.setSelection(new require_SuperConverter.TextSelection(newTr.doc.resolve(caretPos)));
19174
19270
  } else if (trackMeta?.insertedTo !== void 0) {
@@ -20798,7 +20894,7 @@ const canUseDOM = () => {
20798
20894
  return false;
20799
20895
  }
20800
20896
  };
20801
- var summaryVersion = "1.17.0-next.27";
20897
+ var summaryVersion = "1.17.0-next.28";
20802
20898
  var nodeKeys = [
20803
20899
  "group",
20804
20900
  "content",
@@ -36104,7 +36200,7 @@ var Editor = class Editor extends EventEmitter$1 {
36104
36200
  return migrations.length > 0;
36105
36201
  }
36106
36202
  processCollaborationMigrations() {
36107
- console.debug("[checkVersionMigrations] Current editor version", "1.17.0-next.27");
36203
+ console.debug("[checkVersionMigrations] Current editor version", "1.17.0-next.28");
36108
36204
  if (!this.options.ydoc) return;
36109
36205
  let docVersion = this.options.ydoc.getMap("meta").get("version");
36110
36206
  if (!docVersion) docVersion = "initial";
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_rolldown_runtime = require("../chunks/rolldown-runtime-Dp2H1eGw.cjs");
3
- const require_SuperConverter = require("../chunks/SuperConverter-EZm4rCaZ.cjs");
3
+ const require_SuperConverter = require("../chunks/SuperConverter-5-aFSmDM.cjs");
4
4
  require("../chunks/jszip-DCT9QYaK.cjs");
5
5
  require("../chunks/xml-js--DznO7Gk.cjs");
6
6
  require("../chunks/constants-C-hTr4No.cjs");
@@ -1,4 +1,4 @@
1
- import { t as SuperConverter } from "../chunks/SuperConverter-B_fGJA0T.es.js";
1
+ import { t as SuperConverter } from "../chunks/SuperConverter-D1bmhLzc.es.js";
2
2
  import "../chunks/jszip-ChlR43oI.es.js";
3
3
  import "../chunks/xml-js-DLE8mr0n.es.js";
4
4
  import "../chunks/constants-Dw0kAsLd.es.js";
@@ -1 +1 @@
1
- {"version":3,"file":"backspaceNextToRun.d.ts","sourceRoot":"","sources":["../../../../../../super-editor/src/core/commands/backspaceNextToRun.js"],"names":[],"mappings":"AAOO,sCAFM,OAAO,sBAAsB,EAAE,OAAO,CA8BhD"}
1
+ {"version":3,"file":"backspaceNextToRun.d.ts","sourceRoot":"","sources":["../../../../../../super-editor/src/core/commands/backspaceNextToRun.js"],"names":[],"mappings":"AAiBO,sCAFM,OAAO,sBAAsB,EAAE,OAAO,CAqChD"}
@@ -1 +1 @@
1
- {"version":3,"file":"docxImporter.d.ts","sourceRoot":"","sources":["../../../../../../../../super-editor/src/core/super-converter/v2/importer/docxImporter.js"],"names":[],"mappings":"AAmlBA,6DAMC;AASD;;;;;;;;GAQG;AACH,kDAHW,MAAM,GACJ,MAAM,GAAG,IAAI,CAiBzB;AA2ID;;;;;;;;GAQG;AACH,mDAHW,KAAK,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,GAAG,CAAC;IAAC,KAAK,CAAC,EAAE,GAAG,CAAC;IAAC,KAAK,CAAC,EAAE,GAAG,EAAE,CAAA;CAAC,CAAC,SA4E1E;AAED;;;;;;;;;;;;;GAaG;AACH,2DAJW,KAAK,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC;IAAC,KAAK,CAAC,EAAE,GAAG,CAAA;CAAC,CAAC,WACnD,MAAM,SAOhB;AAgND;;;;;;;GAOG;AACH,iFAiBC;AAv+BM;;;;;;;;;;;;;;;;;;;;;;SAgGN;AAEM;;;;;;;;;;;;;;;;;;EAmCN;sBAxMY,OAAO,GAAA,CAAC;yBACR;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,GAAC,CAAC;IAAC,IAAI,EAAE,GAAC,CAAC;IAAC,KAAK,EAAE,GAAC,CAAC;IAAC,KAAK,EAAE,EAAE,CAAC;CAAC;yBACzD;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,EAAE,CAAA;CAAC;gCAEzB,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,iBAAiB,EAAE,OAAO,KAAK,UAAU,EAAE;8BAChF;IAAC,OAAO,EAAE,iBAAiB,CAAC;IAAC,eAAe,EAAE,gBAAgB,EAAE,CAAA;CAAC;0BAEjE,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,eAAe,EAAE,eAAe,EAAE,iBAAiB,EAAE,OAAO,KAAK;IAAC,KAAK,EAAE,UAAU,EAAE,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAC;+BAC7I;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,WAAW,CAAA;CAAC"}
1
+ {"version":3,"file":"docxImporter.d.ts","sourceRoot":"","sources":["../../../../../../../../super-editor/src/core/super-converter/v2/importer/docxImporter.js"],"names":[],"mappings":"AAqlBA,6DAMC;AASD;;;;;;;;GAQG;AACH,kDAHW,MAAM,GACJ,MAAM,GAAG,IAAI,CAiBzB;AA6ID;;;;;;;;GAQG;AACH,mDAHW,KAAK,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,GAAG,CAAC;IAAC,KAAK,CAAC,EAAE,GAAG,CAAC;IAAC,KAAK,CAAC,EAAE,GAAG,EAAE,CAAA;CAAC,CAAC,SA4E1E;AAED;;;;;;;;;;;;;GAaG;AACH,2DAJW,KAAK,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC;IAAC,KAAK,CAAC,EAAE,GAAG,CAAA;CAAC,CAAC,WACnD,MAAM,SAOhB;AAgND;;;;;;;GAOG;AACH,iFAiBC;AA1+BM;;;;;;;;;;;;;;;;;;;;;;SAiGN;AAEM;;;;;;;;;;;;;;;;;;EAmCN;sBAzMY,OAAO,GAAA,CAAC;yBACR;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,GAAC,CAAC;IAAC,IAAI,EAAE,GAAC,CAAC;IAAC,KAAK,EAAE,GAAC,CAAC;IAAC,KAAK,EAAE,EAAE,CAAC;CAAC;yBACzD;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,EAAE,CAAA;CAAC;gCAEzB,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,iBAAiB,EAAE,OAAO,KAAK,UAAU,EAAE;8BAChF;IAAC,OAAO,EAAE,iBAAiB,CAAC;IAAC,eAAe,EAAE,gBAAgB,EAAE,CAAA;CAAC;0BAEjE,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,eAAe,EAAE,eAAe,EAAE,iBAAiB,EAAE,OAAO,KAAK;IAAC,KAAK,EAAE,UAAU,EAAE,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAC;+BAC7I;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,WAAW,CAAA;CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Deduplicate block identities during import so document-api targeting remains stable.
3
+ *
4
+ * Word files can occasionally contain duplicate stable block IDs across blocks.
5
+ * Since stable IDs are used for deterministic targeting in the adapters,
6
+ * duplicates break deterministic targeting and mutations.
7
+ *
8
+ * Only safe block identity attributes are rewritten: sdBlockId, paraId, and blockId.
9
+ *
10
+ * @param {Array<{type?: string, attrs?: Record<string, unknown>, content?: unknown[]}>} content
11
+ * @returns {Array<{type?: string, attrs?: Record<string, unknown>, content?: unknown[]}>}
12
+ */
13
+ export function normalizeDuplicateBlockIdentitiesInContent(content?: Array<{
14
+ type?: string;
15
+ attrs?: Record<string, unknown>;
16
+ content?: unknown[];
17
+ }>): Array<{
18
+ type?: string;
19
+ attrs?: Record<string, unknown>;
20
+ content?: unknown[];
21
+ }>;
22
+ //# sourceMappingURL=normalizeDuplicateBlockIdentitiesInContent.d.ts.map