@superdoc-dev/cli 0.17.0-next.26 → 0.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.
Files changed (2) hide show
  1. package/dist/index.js +345 -50
  2. package/package.json +8 -8
package/dist/index.js CHANGED
@@ -68327,7 +68327,7 @@ var init_remark_gfm_BhnWr3yf_es = __esm(() => {
68327
68327
  emptyOptions2 = {};
68328
68328
  });
68329
68329
 
68330
- // ../../packages/superdoc/dist/chunks/SuperConverter-WQVqM0th.es.js
68330
+ // ../../packages/superdoc/dist/chunks/SuperConverter-DK5WIHuy.es.js
68331
68331
  function getExtensionConfigField(extension$1, field, context = { name: "" }) {
68332
68332
  const fieldValue = extension$1.config[field];
68333
68333
  if (typeof fieldValue === "function")
@@ -90614,8 +90614,11 @@ function trackRevisions(editor) {
90614
90614
  return;
90615
90615
  subscribedEditors.add(editor);
90616
90616
  editor.on("transaction", ({ transaction }) => {
90617
- if (transaction.docChanged)
90618
- incrementRevision(editor);
90617
+ if (transaction.getMeta?.("superdoc/block-identity-repair"))
90618
+ return;
90619
+ if (!transaction.docChanged)
90620
+ return;
90621
+ incrementRevision(editor);
90619
90622
  });
90620
90623
  }
90621
90624
  function checkRevision(editor, expectedRevision) {
@@ -100551,19 +100554,22 @@ function toIdentityValue(value) {
100551
100554
  if (typeof value === "number" && Number.isFinite(value))
100552
100555
  return String(value);
100553
100556
  }
100554
- function getBlockIdentityAttrs(node3) {
100555
- if (!node3 || typeof node3 !== "object")
100557
+ function getBlockIdentityAttrsForType(typeName) {
100558
+ if (!typeName)
100556
100559
  return [];
100557
- return BLOCK_IDENTITY_ATTRS[node3.type] ?? [];
100560
+ return BLOCK_IDENTITY_ATTRS[typeName] ?? [];
100558
100561
  }
100559
- function getExplicitIdentityEntries(node3) {
100560
- const attrPriority = getBlockIdentityAttrs(node3);
100562
+ function shouldSynthesizeParaIdForType(typeName) {
100563
+ return Boolean(typeName && SYNTHETIC_PARA_ID_TYPES.has(typeName));
100564
+ }
100565
+ function getExplicitIdentityEntries(attrs, typeName) {
100566
+ const attrPriority = getBlockIdentityAttrsForType(typeName);
100561
100567
  if (attrPriority.length === 0)
100562
100568
  return [];
100563
- const attrs = typeof node3.attrs === "object" && node3.attrs ? node3.attrs : {};
100569
+ const safeAttrs = attrs && typeof attrs === "object" ? attrs : {};
100564
100570
  const identityEntries = [];
100565
100571
  for (const attr of attrPriority) {
100566
- const value = toIdentityValue(attrs[attr]);
100572
+ const value = toIdentityValue(safeAttrs[attr]);
100567
100573
  if (value)
100568
100574
  identityEntries.push({
100569
100575
  attr,
@@ -100587,18 +100593,6 @@ function groupIdentityEntriesByValue(identityEntries) {
100587
100593
  }
100588
100594
  return [...groupsByValue.values()];
100589
100595
  }
100590
- function shouldSynthesizeParaId(node3) {
100591
- return Boolean(node3 && typeof node3 === "object" && SYNTHETIC_PARA_ID_TYPES.has(node3.type));
100592
- }
100593
- function collectExplicitBlockIdentities(node3, reservedIds) {
100594
- if (!node3 || typeof node3 !== "object")
100595
- return;
100596
- const identityEntries = getExplicitIdentityEntries(node3);
100597
- for (const { value } of groupIdentityEntriesByValue(identityEntries))
100598
- reservedIds.add(value);
100599
- if (Array.isArray(node3.content))
100600
- node3.content.forEach((child) => collectExplicitBlockIdentities(child, reservedIds));
100601
- }
100602
100596
  function createDeterministicDocxIdAllocator(reservedIds) {
100603
100597
  let nextValue = 1;
100604
100598
  return () => {
@@ -100613,6 +100607,15 @@ function createDeterministicDocxIdAllocator(reservedIds) {
100613
100607
  throw new Error("Unable to allocate a unique synthetic DOCX block id.");
100614
100608
  };
100615
100609
  }
100610
+ function collectExplicitBlockIdentities(node3, reservedIds) {
100611
+ if (!node3 || typeof node3 !== "object")
100612
+ return;
100613
+ const identityEntries = getExplicitIdentityEntries(node3.attrs, node3?.type);
100614
+ for (const { value } of groupIdentityEntriesByValue(identityEntries))
100615
+ reservedIds.add(value);
100616
+ if (Array.isArray(node3.content))
100617
+ node3.content.forEach((child) => collectExplicitBlockIdentities(child, reservedIds));
100618
+ }
100616
100619
  function setBlockIdentity(node3, attrName, value) {
100617
100620
  node3.attrs = {
100618
100621
  ...node3.attrs ?? {},
@@ -100622,7 +100625,7 @@ function setBlockIdentity(node3, attrName, value) {
100622
100625
  function normalizeBlockIdentitiesInNode(node3, seenIds, allocateDocxId) {
100623
100626
  if (!node3 || typeof node3 !== "object")
100624
100627
  return;
100625
- const groupedIdentities = groupIdentityEntriesByValue(getExplicitIdentityEntries(node3));
100628
+ const groupedIdentities = groupIdentityEntriesByValue(getExplicitIdentityEntries(node3.attrs, node3?.type));
100626
100629
  if (groupedIdentities.length > 0)
100627
100630
  for (const identityGroup of groupedIdentities)
100628
100631
  if (seenIds.has(identityGroup.value)) {
@@ -100632,7 +100635,7 @@ function normalizeBlockIdentitiesInNode(node3, seenIds, allocateDocxId) {
100632
100635
  seenIds.add(replacementId);
100633
100636
  } else
100634
100637
  seenIds.add(identityGroup.value);
100635
- else if (shouldSynthesizeParaId(node3)) {
100638
+ else if (shouldSynthesizeParaIdForType(node3?.type)) {
100636
100639
  const syntheticParaId = allocateDocxId();
100637
100640
  setBlockIdentity(node3, "paraId", syntheticParaId);
100638
100641
  seenIds.add(syntheticParaId);
@@ -108250,6 +108253,7 @@ function buildBlockIndex(editor) {
108250
108253
  const byId = /* @__PURE__ */ new Map;
108251
108254
  const ambiguous = /* @__PURE__ */ new Set;
108252
108255
  const pathByNode = /* @__PURE__ */ new WeakMap;
108256
+ const explicitIdentities = /* @__PURE__ */ new Map;
108253
108257
  pathByNode.set(editor.state.doc, []);
108254
108258
  function registerKey(key, candidate) {
108255
108259
  if (byId.has(key)) {
@@ -108258,11 +108262,44 @@ function buildBlockIndex(editor) {
108258
108262
  } else if (!ambiguous.has(key))
108259
108263
  byId.set(key, candidate);
108260
108264
  }
108265
+ function recordExplicitIdentities(node3, pos) {
108266
+ const attrPriority = getBlockIdentityAttrsForType(node3.type?.name);
108267
+ if (attrPriority.length === 0)
108268
+ return;
108269
+ const attrs = node3.attrs ?? {};
108270
+ let nodeGroups;
108271
+ for (const attr of attrPriority) {
108272
+ const value = toIdentityValue(attrs[attr]);
108273
+ if (!value)
108274
+ continue;
108275
+ if (!nodeGroups)
108276
+ nodeGroups = /* @__PURE__ */ new Map;
108277
+ const existing = nodeGroups.get(value);
108278
+ if (existing)
108279
+ existing.push(attr);
108280
+ else
108281
+ nodeGroups.set(value, [attr]);
108282
+ }
108283
+ if (!nodeGroups)
108284
+ return;
108285
+ for (const [value, attrsForValue] of nodeGroups) {
108286
+ const observations = explicitIdentities.get(value);
108287
+ const observation = {
108288
+ pos,
108289
+ attrs: attrsForValue
108290
+ };
108291
+ if (observations)
108292
+ observations.push(observation);
108293
+ else
108294
+ explicitIdentities.set(value, [observation]);
108295
+ }
108296
+ }
108261
108297
  editor.state.doc.descendants((node3, pos, parent, index2) => {
108262
108298
  const parentPath = parent ? pathByNode.get(parent) ?? [] : [];
108263
108299
  const path2 = typeof index2 === "number" && Number.isInteger(index2) && index2 >= 0 ? [...parentPath, index2] : undefined;
108264
108300
  if (path2)
108265
108301
  pathByNode.set(node3, path2);
108302
+ recordExplicitIdentities(node3, pos);
108266
108303
  const nodeType = mapBlockNodeType(node3);
108267
108304
  if (!nodeType)
108268
108305
  return;
@@ -108285,7 +108322,8 @@ function buildBlockIndex(editor) {
108285
108322
  return {
108286
108323
  candidates,
108287
108324
  byId,
108288
- ambiguous
108325
+ ambiguous,
108326
+ explicitIdentities
108289
108327
  };
108290
108328
  }
108291
108329
  function findBlockById(index2, address2) {
@@ -111870,6 +111908,8 @@ function resolveStoryRuntime(hostEditor, locator, options = {}) {
111870
111908
  if (store && !hasHostStoreSyncListener(runtime.editor, storyKey)) {
111871
111909
  markHostStoreSyncListener(runtime.editor, storyKey);
111872
111910
  runtime.editor.on("transaction", ({ transaction }) => {
111911
+ if (transaction.getMeta?.("superdoc/block-identity-repair"))
111912
+ return;
111873
111913
  if (transaction.docChanged)
111874
111914
  incrementStoryRevision(store, storyKey);
111875
111915
  });
@@ -134929,7 +134969,7 @@ var isRegExp = (value) => {
134929
134969
  state.kern = kernNode.attributes["w:val"];
134930
134970
  }
134931
134971
  }, SuperConverter;
134932
- var init_SuperConverter_WQVqM0th_es = __esm(() => {
134972
+ var init_SuperConverter_DK5WIHuy_es = __esm(() => {
134933
134973
  init_rolldown_runtime_Bg48TavK_es();
134934
134974
  init_jszip_C49i9kUs_es();
134935
134975
  init_xml_js_CqGKpaft_es();
@@ -175673,7 +175713,7 @@ var init_SuperConverter_WQVqM0th_es = __esm(() => {
175673
175713
  };
175674
175714
  });
175675
175715
 
175676
- // ../../packages/superdoc/dist/chunks/create-headless-toolbar-B8OXKxcw.es.js
175716
+ // ../../packages/superdoc/dist/chunks/create-headless-toolbar-BLN1v7eO.es.js
175677
175717
  function parseSizeUnit(val = "0") {
175678
175718
  const length3 = val.toString() || "0";
175679
175719
  const value = Number.parseFloat(length3);
@@ -177156,6 +177196,194 @@ function applySetMarksToResolved(editor, existingMarks, setMarks) {
177156
177196
  }
177157
177197
  return marks;
177158
177198
  }
177199
+ function planRepairs(doc2, identityMap) {
177200
+ if (identityMap)
177201
+ return planRepairsFromIdentityMap(identityMap);
177202
+ return planRepairsByWalk(doc2);
177203
+ }
177204
+ function planRepairsFromIdentityMap(identityMap) {
177205
+ let hasDuplicates = false;
177206
+ for (const observations of identityMap.values())
177207
+ if (observations.length > 1) {
177208
+ hasDuplicates = true;
177209
+ break;
177210
+ }
177211
+ if (!hasDuplicates)
177212
+ return {
177213
+ plans: [],
177214
+ report: {
177215
+ repairedBlockCount: 0,
177216
+ duplicateBlockIds: [],
177217
+ renames: []
177218
+ }
177219
+ };
177220
+ const rewrites = [];
177221
+ for (const [value, observations] of identityMap) {
177222
+ if (observations.length <= 1)
177223
+ continue;
177224
+ for (let i4 = 1;i4 < observations.length; i4 += 1) {
177225
+ const { pos, attrs } = observations[i4];
177226
+ rewrites.push({
177227
+ pos,
177228
+ value,
177229
+ attrs
177230
+ });
177231
+ }
177232
+ }
177233
+ rewrites.sort((a, b) => a.pos - b.pos);
177234
+ const allocateDocxId = createDeterministicDocxIdAllocator(new Set(identityMap.keys()));
177235
+ const plansByPos = /* @__PURE__ */ new Map;
177236
+ const duplicateBlockIds = [];
177237
+ const renames = [];
177238
+ for (const { pos, value, attrs } of rewrites) {
177239
+ const replacementValue = allocateDocxId();
177240
+ let plan = plansByPos.get(pos);
177241
+ if (!plan) {
177242
+ plan = {
177243
+ pos,
177244
+ rewrittenGroups: []
177245
+ };
177246
+ plansByPos.set(pos, plan);
177247
+ }
177248
+ const attrsCopy = [...attrs];
177249
+ plan.rewrittenGroups.push({
177250
+ originalValue: value,
177251
+ replacementValue,
177252
+ attrs: attrsCopy
177253
+ });
177254
+ duplicateBlockIds.push(value);
177255
+ renames.push({
177256
+ originalValue: value,
177257
+ replacementValue,
177258
+ attrs: attrsCopy
177259
+ });
177260
+ }
177261
+ const plans = [...plansByPos.values()].sort((a, b) => a.pos - b.pos);
177262
+ return {
177263
+ plans,
177264
+ report: {
177265
+ repairedBlockCount: plans.length,
177266
+ duplicateBlockIds,
177267
+ renames
177268
+ }
177269
+ };
177270
+ }
177271
+ function planRepairsByWalk(doc2) {
177272
+ const reservedIds = /* @__PURE__ */ new Set;
177273
+ let hasDuplicates = false;
177274
+ doc2.descendants((node3) => {
177275
+ const entries2 = getExplicitIdentityEntries(node3.attrs, node3.type?.name);
177276
+ for (const { value } of groupIdentityEntriesByValue(entries2))
177277
+ if (reservedIds.has(value))
177278
+ hasDuplicates = true;
177279
+ else
177280
+ reservedIds.add(value);
177281
+ });
177282
+ if (!hasDuplicates)
177283
+ return {
177284
+ plans: [],
177285
+ report: {
177286
+ repairedBlockCount: 0,
177287
+ duplicateBlockIds: [],
177288
+ renames: []
177289
+ }
177290
+ };
177291
+ const allocateDocxId = createDeterministicDocxIdAllocator(reservedIds);
177292
+ const seenIds = /* @__PURE__ */ new Set;
177293
+ const plans = [];
177294
+ const duplicateBlockIds = [];
177295
+ const renames = [];
177296
+ doc2.descendants((node3, pos) => {
177297
+ const groups = groupIdentityEntriesByValue(getExplicitIdentityEntries(node3.attrs, node3.type?.name));
177298
+ if (groups.length === 0)
177299
+ return;
177300
+ let plan = null;
177301
+ for (const group of groups)
177302
+ if (seenIds.has(group.value)) {
177303
+ if (!plan)
177304
+ plan = {
177305
+ pos,
177306
+ rewrittenGroups: []
177307
+ };
177308
+ const replacementValue = allocateDocxId();
177309
+ plan.rewrittenGroups.push({
177310
+ originalValue: group.value,
177311
+ replacementValue,
177312
+ attrs: [...group.attrs]
177313
+ });
177314
+ duplicateBlockIds.push(group.value);
177315
+ renames.push({
177316
+ originalValue: group.value,
177317
+ replacementValue,
177318
+ attrs: [...group.attrs]
177319
+ });
177320
+ seenIds.add(replacementValue);
177321
+ } else
177322
+ seenIds.add(group.value);
177323
+ if (plan)
177324
+ plans.push(plan);
177325
+ });
177326
+ return {
177327
+ plans,
177328
+ report: {
177329
+ repairedBlockCount: plans.length,
177330
+ duplicateBlockIds,
177331
+ renames
177332
+ }
177333
+ };
177334
+ }
177335
+ function repairDuplicateBlockIdentities(editor) {
177336
+ const doc2 = editor.state?.doc;
177337
+ if (!doc2 || typeof doc2.descendants !== "function")
177338
+ return null;
177339
+ if (typeof editor.state?.tr !== "object" || editor.state.tr === null)
177340
+ return null;
177341
+ if (typeof editor.dispatch !== "function")
177342
+ return null;
177343
+ let identityMap;
177344
+ try {
177345
+ identityMap = getBlockIndex(editor).explicitIdentities;
177346
+ } catch {
177347
+ identityMap = undefined;
177348
+ }
177349
+ const { plans, report } = planRepairs(doc2, identityMap);
177350
+ if (plans.length === 0)
177351
+ return null;
177352
+ const tr = editor.state.tr;
177353
+ tr.setMeta("addToHistory", false);
177354
+ tr.setMeta("superdoc/block-identity-repair", report);
177355
+ for (const plan of plans)
177356
+ for (const group of plan.rewrittenGroups)
177357
+ for (const attr of group.attrs)
177358
+ tr.setNodeAttribute(plan.pos, attr, group.replacementValue);
177359
+ editor.dispatch(tr);
177360
+ const blockedNodeIds = [];
177361
+ for (const plan of plans) {
177362
+ const node3 = editor.state.doc.nodeAt(plan.pos);
177363
+ if (!node3) {
177364
+ blockedNodeIds.push(`pos:${plan.pos}`);
177365
+ continue;
177366
+ }
177367
+ for (const group of plan.rewrittenGroups)
177368
+ for (const attr of group.attrs)
177369
+ if (node3.attrs?.[attr] !== group.replacementValue) {
177370
+ const observedId = typeof node3.attrs?.id === "string" && node3.attrs.id || typeof node3.attrs?.sdBlockId === "string" && node3.attrs.sdBlockId || `pos:${plan.pos}`;
177371
+ blockedNodeIds.push(observedId);
177372
+ }
177373
+ }
177374
+ if (blockedNodeIds.length > 0) {
177375
+ const unique = [...new Set(blockedNodeIds)];
177376
+ const MAX_ID_PREVIEW_LENGTH = 32;
177377
+ const truncate = (id2) => id2.length > MAX_ID_PREVIEW_LENGTH ? `${id2.slice(0, MAX_ID_PREVIEW_LENGTH - 1)}…` : id2;
177378
+ const preview = unique.slice(0, 4).map(truncate).join(", ");
177379
+ const previewSuffix = unique.length > 4 ? `, +${unique.length - 4} more` : "";
177380
+ throw planError("REPAIR_BLOCKED", `Runtime identity repair was rejected by a transaction filter (${unique.length} node${unique.length === 1 ? "" : "s"}: ${preview}${previewSuffix}). A structured-content lock or permission range likely covers one of the duplicate blocks. Re-import the document via doc.open to assign unique identities.`, undefined, {
177381
+ blockedNodeIds: unique,
177382
+ remediation: "Re-import the document via doc.open to assign unique identities."
177383
+ });
177384
+ }
177385
+ return report;
177386
+ }
177159
177387
  function getCandidateText(editor, candidate, options) {
177160
177388
  if (candidate.node.childCount > 0)
177161
177389
  return textContentInBlock(candidate.node, options);
@@ -178360,12 +178588,15 @@ function assertNoDuplicateBlockIds(index2) {
178360
178588
  if (count2 === 1)
178361
178589
  duplicates.push(candidate.nodeId);
178362
178590
  }
178363
- if (duplicates.length > 0)
178364
- throw planError("DOCUMENT_IDENTITY_CONFLICT", "Document contains blocks with duplicate identities. This must be resolved before mutations can be applied.", undefined, {
178591
+ if (duplicates.length > 0) {
178592
+ const preview = duplicates.slice(0, 4).join(", ");
178593
+ const previewSuffix = duplicates.length > 4 ? `, +${duplicates.length - 4} more` : "";
178594
+ throw planError("DOCUMENT_IDENTITY_CONFLICT", `Document contains ${duplicates.length} block identit${duplicates.length === 1 ? "y" : "ies"} shared by multiple blocks (${preview}${previewSuffix}). Re-import the document via doc.open to assign unique identities.`, undefined, {
178365
178595
  duplicateBlockIds: duplicates,
178366
178596
  blockCount: duplicates.length,
178367
- remediation: "Re-import the document or call document.repair() to assign unique identities."
178597
+ remediation: "Re-import the document via doc.open to assign unique identities."
178368
178598
  });
178599
+ }
178369
178600
  }
178370
178601
  function assertSingleStoryKey(steps) {
178371
178602
  let seenStoryKey;
@@ -178393,11 +178624,71 @@ function assertSingleStoryKey(steps) {
178393
178624
  });
178394
178625
  }
178395
178626
  }
178627
+ function collectReferencedBlockIds(step3) {
178628
+ const where = step3.where;
178629
+ const ids = [];
178630
+ const withinNodeId = where.within?.nodeId;
178631
+ if (withinNodeId)
178632
+ ids.push(withinNodeId);
178633
+ if (isRefWhere(where)) {
178634
+ const ref3 = where.ref;
178635
+ if (ref3.startsWith("text:")) {
178636
+ const decoded = decodeRef(ref3);
178637
+ if (decoded) {
178638
+ for (const seg of decoded.segments ?? [])
178639
+ if (seg?.blockId)
178640
+ ids.push(seg.blockId);
178641
+ const nodeId = decoded.node?.nodeId;
178642
+ if (nodeId)
178643
+ ids.push(nodeId);
178644
+ }
178645
+ } else
178646
+ ids.push(ref3);
178647
+ return ids;
178648
+ }
178649
+ if (isBlockWhere(where)) {
178650
+ ids.push(where.nodeId);
178651
+ return ids;
178652
+ }
178653
+ if (isTargetWhere(where))
178654
+ for (const point3 of [where.target?.start, where.target?.end]) {
178655
+ const blockId = point3?.blockId;
178656
+ if (blockId)
178657
+ ids.push(blockId);
178658
+ const edgeNodeId = point3?.node?.nodeId;
178659
+ if (edgeNodeId)
178660
+ ids.push(edgeNodeId);
178661
+ }
178662
+ return ids;
178663
+ }
178664
+ function assertNoStaleRefsAfterRepair(steps, repairedIds) {
178665
+ if (repairedIds.size === 0)
178666
+ return;
178667
+ for (const step3 of steps)
178668
+ for (const blockId of collectReferencedBlockIds(step3)) {
178669
+ if (!repairedIds.has(blockId))
178670
+ continue;
178671
+ throw planError("STALE_REF", `Step "${step3.id}" references block id "${blockId}", which was duplicated in this document and has just been repaired (the duplicate occurrence was renamed). The reference is ambiguous — it may have pointed at the renamed block. Re-run query.match / doc.find against the repaired document and retry with a fresh ref.`, step3.id, {
178672
+ blockId,
178673
+ repairedBlockIds: [...repairedIds],
178674
+ remediation: "Re-run query.match() or doc.find() to obtain fresh refs, then retry the mutation."
178675
+ });
178676
+ }
178677
+ }
178396
178678
  function compilePlan(editor, steps, options = {}) {
178397
178679
  if (steps.length > 200)
178398
178680
  throw planError("INVALID_INPUT", `plan contains ${steps.length} steps, maximum is 200`);
178681
+ let index2 = getBlockIndex(editor);
178682
+ if (!options.skipIdentityRepair) {
178683
+ const repair = repairDuplicateBlockIdentities(editor);
178684
+ if (repair) {
178685
+ clearIndexCache(editor);
178686
+ index2 = getBlockIndex(editor);
178687
+ console.warn(`[plan-engine] Repaired ${repair.repairedBlockCount} block(s) with duplicate identities before plan compilation. Original ids: ${repair.duplicateBlockIds.slice(0, 4).join(", ")}${repair.duplicateBlockIds.length > 4 ? `, +${repair.duplicateBlockIds.length - 4} more` : ""}.`);
178688
+ assertNoStaleRefsAfterRepair(steps, new Set(repair.duplicateBlockIds));
178689
+ }
178690
+ }
178399
178691
  const compiledRevision = getRevision(editor);
178400
- const index2 = getBlockIndex(editor);
178401
178692
  assertNoDuplicateBlockIds(index2);
178402
178693
  const mutationSteps = [];
178403
178694
  const assertSteps = [];
@@ -180490,6 +180781,7 @@ function executeCompiledPlan(editor, compiled, options = {}) {
180490
180781
  function executePlan(editor, input) {
180491
180782
  if (!input.steps?.length)
180492
180783
  throw planError("INVALID_INPUT", "plan must contain at least one step");
180784
+ checkRevision(editor, input.expectedRevision);
180493
180785
  return executeCompiledPlan(editor, compilePlan(editor, input.steps, { selectTextModel: input.changeMode === "tracked" ? "raw" : "visible" }), {
180494
180786
  changeMode: input.changeMode ?? "direct",
180495
180787
  expectedRevision: input.expectedRevision
@@ -181836,7 +182128,9 @@ function selectionMutationWrapper(editor, request, options) {
181836
182128
  ensureTrackedInlinePropertySupport(inlineKeys);
181837
182129
  }
181838
182130
  const stepId = v4_default();
181839
- const compiled = compilePlan(storyEditor, [buildSelectionStepDef(stepId, request, buildSelectionWhere(request))]);
182131
+ const step3 = buildSelectionStepDef(stepId, request, buildSelectionWhere(request));
182132
+ checkRevision(storyEditor, options?.expectedRevision);
182133
+ const compiled = compilePlan(storyEditor, [step3], options?.dryRun ? { skipIdentityRepair: true } : undefined);
181840
182134
  if (request.kind === "insert" && request.target) {
181841
182135
  if (request.target.start.kind === "nodeEdge" || request.target.end.kind === "nodeEdge")
181842
182136
  throw new DocumentApiAdapterError("INVALID_TARGET", "Text inserts do not support nodeEdge targets. Use a text-offset target inside a textblock.");
@@ -181866,7 +182160,6 @@ function selectionMutationWrapper(editor, request, options) {
181866
182160
  }
181867
182161
  }
181868
182162
  }
181869
- checkRevision(storyEditor, options?.expectedRevision);
181870
182163
  if (options?.dryRun) {
181871
182164
  const resolution$1 = buildSelectionResolutionFromCompiled(compiled, stepId);
181872
182165
  if (request.kind === "insert" && !request.text)
@@ -182084,6 +182377,7 @@ function insertStructuredInner(editor, input, options) {
182084
182377
  }
182085
182378
  };
182086
182379
  } else if (ref3) {
182380
+ checkRevision(editor, options?.expectedRevision);
182087
182381
  const dummyStepId = v4_default();
182088
182382
  const compiled = compilePlan(editor, [{
182089
182383
  id: dummyStepId,
@@ -182096,7 +182390,7 @@ function insertStructuredInner(editor, input, options) {
182096
182390
  position: "before",
182097
182391
  content: { text: "" }
182098
182392
  }
182099
- }]);
182393
+ }], options?.dryRun ? { skipIdentityRepair: true } : undefined);
182100
182394
  const compiledTarget = compiled.mutationSteps.find((s) => s.step.id === dummyStepId)?.targets[0];
182101
182395
  if (!compiledTarget)
182102
182396
  throw new DocumentApiAdapterError("TARGET_NOT_FOUND", "Structured insert ref could not be resolved.", { ref: ref3 });
@@ -186068,8 +186362,8 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, normalizeActorId = (value) => {
186068
186362
  }
186069
186363
  };
186070
186364
  };
186071
- var init_create_headless_toolbar_B8OXKxcw_es = __esm(() => {
186072
- init_SuperConverter_WQVqM0th_es();
186365
+ var init_create_headless_toolbar_BLN1v7eO_es = __esm(() => {
186366
+ init_SuperConverter_DK5WIHuy_es();
186073
186367
  init_uuid_B2wVPhPi_es();
186074
186368
  init_constants_D9qj59G2_es();
186075
186369
  init_dist_B8HfvhaK_es();
@@ -235238,7 +235532,7 @@ var init_remark_gfm_eZN6yzWQ_es = __esm(() => {
235238
235532
  init_remark_gfm_BhnWr3yf_es();
235239
235533
  });
235240
235534
 
235241
- // ../../packages/superdoc/dist/chunks/src-Bvhjxf8i.es.js
235535
+ // ../../packages/superdoc/dist/chunks/src-PJVnllcq.es.js
235242
235536
  function deleteProps(obj, propOrProps) {
235243
235537
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
235244
235538
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -258897,7 +259191,7 @@ function previewPlan(editor, input2) {
258897
259191
  let currentPhase = "compile";
258898
259192
  let evaluatedRevision = getRevision(editor);
258899
259193
  try {
258900
- const compiled = compilePlan(editor, input2.steps);
259194
+ const compiled = compilePlan(editor, input2.steps, { skipIdentityRepair: true });
258901
259195
  evaluatedRevision = compiled.compiledRevision;
258902
259196
  currentPhase = "execute";
258903
259197
  const tr = editor.state.tr;
@@ -307132,7 +307426,8 @@ var Node$13 = class Node$14 {
307132
307426
  const ySyncMeta = tr.getMeta(ySyncPluginKey);
307133
307427
  const pendingDeadKeyPlaceholder = TrackChangesBasePluginKey.getState(state)?.pendingDeadKeyPlaceholder ?? null;
307134
307428
  const hasDisallowedMeta = tr.meta && Object.keys(tr.meta).some((meta2) => !ALLOWED_META_KEYS.has(meta2));
307135
- if (ySyncMeta?.isChangeOrigin || !tr.steps.length || hasDisallowedMeta && !isProgrammaticInput || notAllowedMeta.includes(tr.getMeta("inputType")) || tr.getMeta(CommentsPluginKey)) {
307429
+ const isBlockIdentityRepair = Boolean(tr.getMeta("superdoc/block-identity-repair"));
307430
+ if (ySyncMeta?.isChangeOrigin || !tr.steps.length || isBlockIdentityRepair || hasDisallowedMeta && !isProgrammaticInput || notAllowedMeta.includes(tr.getMeta("inputType")) || tr.getMeta(CommentsPluginKey)) {
307136
307431
  if (pendingDeadKeyPlaceholder && !isCompositionTransaction(tr))
307137
307432
  mergeTrackChangesMeta(tr, { pendingDeadKeyPlaceholder: null });
307138
307433
  return tr;
@@ -333480,13 +333775,13 @@ menclose::after {
333480
333775
  return;
333481
333776
  console.log(...args$1);
333482
333777
  }, HEADER_FOOTER_INIT_BUDGET_MS = 200, MAX_ZOOM_WARNING_THRESHOLD = 10, MAX_SELECTION_RECTS_PER_USER = 100, SEMANTIC_RESIZE_DEBOUNCE_MS = 120, MIN_SEMANTIC_CONTENT_WIDTH_PX = 1, GLOBAL_PERFORMANCE, PresentationEditor, ICONS, TEXTS, tableActionsOptions, TRACKED_MARK_NAMES;
333483
- var init_src_Bvhjxf8i_es = __esm(() => {
333778
+ var init_src_PJVnllcq_es = __esm(() => {
333484
333779
  init_rolldown_runtime_Bg48TavK_es();
333485
- init_SuperConverter_WQVqM0th_es();
333780
+ init_SuperConverter_DK5WIHuy_es();
333486
333781
  init_jszip_C49i9kUs_es();
333487
333782
  init_xml_js_CqGKpaft_es();
333488
333783
  init_uuid_B2wVPhPi_es();
333489
- init_create_headless_toolbar_B8OXKxcw_es();
333784
+ init_create_headless_toolbar_BLN1v7eO_es();
333490
333785
  init_constants_D9qj59G2_es();
333491
333786
  init_dist_B8HfvhaK_es();
333492
333787
  init_unified_Dsuw2be5_es();
@@ -369271,11 +369566,11 @@ function print() { __p += __j.call(arguments, '') }
369271
369566
  ]);
369272
369567
  });
369273
369568
 
369274
- // ../../packages/superdoc/dist/chunks/create-super-doc-ui-CCLA6uFG.es.js
369569
+ // ../../packages/superdoc/dist/chunks/create-super-doc-ui-CrjXK3s_.es.js
369275
369570
  var DEFAULT_TEXT_ALIGN_OPTIONS, DEFAULT_LINE_HEIGHT_OPTIONS, DEFAULT_ZOOM_OPTIONS, DEFAULT_DOCUMENT_MODE_OPTIONS, DEFAULT_FONT_SIZE_OPTIONS, headlessToolbarConstants, MOD_ALIASES, ALT_ALIASES, CTRL_ALIASES, SHIFT_ALIASES, BUILTIN_CONTEXT_MENU_GROUPS, BUILTIN_GROUP_ORDER, RESERVED_PROXY_PROPERTY_NAMES, ALL_TOOLBAR_COMMAND_IDS, EMPTY_ACTIVE_IDS, FONT_SIZE_OPTIONS;
369276
- var init_create_super_doc_ui_CCLA6uFG_es = __esm(() => {
369277
- init_SuperConverter_WQVqM0th_es();
369278
- init_create_headless_toolbar_B8OXKxcw_es();
369571
+ var init_create_super_doc_ui_CrjXK3s__es = __esm(() => {
369572
+ init_SuperConverter_DK5WIHuy_es();
369573
+ init_create_headless_toolbar_BLN1v7eO_es();
369279
369574
  DEFAULT_TEXT_ALIGN_OPTIONS = [
369280
369575
  {
369281
369576
  label: "Left",
@@ -369566,16 +369861,16 @@ var init_zipper_yaJVJ4z9_es = __esm(() => {
369566
369861
 
369567
369862
  // ../../packages/superdoc/dist/super-editor.es.js
369568
369863
  var init_super_editor_es = __esm(() => {
369569
- init_src_Bvhjxf8i_es();
369570
- init_SuperConverter_WQVqM0th_es();
369864
+ init_src_PJVnllcq_es();
369865
+ init_SuperConverter_DK5WIHuy_es();
369571
369866
  init_jszip_C49i9kUs_es();
369572
369867
  init_xml_js_CqGKpaft_es();
369573
- init_create_headless_toolbar_B8OXKxcw_es();
369868
+ init_create_headless_toolbar_BLN1v7eO_es();
369574
369869
  init_constants_D9qj59G2_es();
369575
369870
  init_dist_B8HfvhaK_es();
369576
369871
  init_unified_Dsuw2be5_es();
369577
369872
  init_DocxZipper_FUsfThjV_es();
369578
- init_create_super_doc_ui_CCLA6uFG_es();
369873
+ init_create_super_doc_ui_CrjXK3s__es();
369579
369874
  init_ui_C5PAS9hY_es();
369580
369875
  init_eventemitter3_BnGqBE_Q_es();
369581
369876
  init_errors_CNaD6vcg_es();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/cli",
3
- "version": "0.17.0-next.26",
3
+ "version": "0.17.0-next.28",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "superdoc": "./dist/index.js"
@@ -24,20 +24,20 @@
24
24
  "@types/node": "22.19.2",
25
25
  "@types/ws": "^8.5.13",
26
26
  "typescript": "^5.9.2",
27
- "@superdoc/document-api": "0.0.1",
27
+ "@superdoc/super-editor": "0.0.1",
28
28
  "superdoc": "1.39.0",
29
- "@superdoc/super-editor": "0.0.1"
29
+ "@superdoc/document-api": "0.0.1"
30
30
  },
31
31
  "module": "src/index.ts",
32
32
  "publishConfig": {
33
33
  "access": "public"
34
34
  },
35
35
  "optionalDependencies": {
36
- "@superdoc-dev/cli-darwin-arm64": "0.17.0-next.26",
37
- "@superdoc-dev/cli-darwin-x64": "0.17.0-next.26",
38
- "@superdoc-dev/cli-linux-x64": "0.17.0-next.26",
39
- "@superdoc-dev/cli-linux-arm64": "0.17.0-next.26",
40
- "@superdoc-dev/cli-windows-x64": "0.17.0-next.26"
36
+ "@superdoc-dev/cli-darwin-x64": "0.17.0-next.28",
37
+ "@superdoc-dev/cli-darwin-arm64": "0.17.0-next.28",
38
+ "@superdoc-dev/cli-linux-x64": "0.17.0-next.28",
39
+ "@superdoc-dev/cli-windows-x64": "0.17.0-next.28",
40
+ "@superdoc-dev/cli-linux-arm64": "0.17.0-next.28"
41
41
  },
42
42
  "scripts": {
43
43
  "predev": "node scripts/ensure-superdoc-build.js",