superdoc 2.22.0-next.17 → 2.22.0-next.19

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.
@@ -3993,6 +3993,65 @@ var INCREMENTAL_DEPENDENCY_CERTIFICATE_CLASSES = Object.freeze([
3993
3993
  ]);
3994
3994
  new Set(INCREMENTAL_DEPENDENCY_CERTIFICATE_CLASSES);
3995
3995
  //#endregion
3996
+ //#region ../document-api/src/types/story.types.ts
3997
+ /** All recognized story types. */
3998
+ var STORY_TYPES = [
3999
+ "body",
4000
+ "headerFooterSlot",
4001
+ "headerFooterPart",
4002
+ "footnote",
4003
+ "endnote",
4004
+ "textbox"
4005
+ ];
4006
+ /** Valid header/footer story kinds. */
4007
+ var STORY_HEADER_FOOTER_KINDS = ["header", "footer"];
4008
+ /** Valid header/footer slot variants. */
4009
+ var STORY_HEADER_FOOTER_VARIANTS = [
4010
+ "default",
4011
+ "first",
4012
+ "even"
4013
+ ];
4014
+ /** Valid header/footer slot resolution modes. */
4015
+ var STORY_HEADER_FOOTER_RESOLUTIONS = ["effective", "explicit"];
4016
+ /** Valid header/footer slot write modes. */
4017
+ var STORY_HEADER_FOOTER_ON_WRITE_VALUES = [
4018
+ "materializeIfInherited",
4019
+ "editResolvedPart",
4020
+ "error"
4021
+ ];
4022
+ /**
4023
+ * Type guard: returns `true` if `value` is a valid {@link StoryLocator}.
4024
+ *
4025
+ * Checks the full discriminated-union shape so malformed partial locators do
4026
+ * not leak through validation and fail later with raw property-access errors.
4027
+ */
4028
+ function isStoryLocator(value) {
4029
+ if (!isObjectRecord(value) || value.kind !== "story" || !isStringEnumMember(value.storyType, STORY_TYPES)) return false;
4030
+ switch (value.storyType) {
4031
+ case "body": return true;
4032
+ case "headerFooterSlot": return isSectionAddress(value.section) && isStringEnumMember(value.headerFooterKind, STORY_HEADER_FOOTER_KINDS) && isStringEnumMember(value.variant, STORY_HEADER_FOOTER_VARIANTS) && isOptionalStringEnumMember(value.resolution, STORY_HEADER_FOOTER_RESOLUTIONS) && isOptionalStringEnumMember(value.onWrite, STORY_HEADER_FOOTER_ON_WRITE_VALUES);
4033
+ case "headerFooterPart": return isNonEmptyString(value.refId);
4034
+ case "footnote":
4035
+ case "endnote": return isNonEmptyString(value.noteId);
4036
+ case "textbox": return isNonEmptyString(value.textboxId);
4037
+ }
4038
+ }
4039
+ function isObjectRecord(value) {
4040
+ return typeof value === "object" && value !== null;
4041
+ }
4042
+ function isNonEmptyString(value) {
4043
+ return typeof value === "string" && value.length > 0;
4044
+ }
4045
+ function isStringEnumMember(value, allowed) {
4046
+ return typeof value === "string" && allowed.includes(value);
4047
+ }
4048
+ function isOptionalStringEnumMember(value, allowed) {
4049
+ return value === void 0 || isStringEnumMember(value, allowed);
4050
+ }
4051
+ function isSectionAddress(value) {
4052
+ return isObjectRecord(value) && value.kind === "section" && typeof value.sectionId === "string" && value.sectionId.length > 0;
4053
+ }
4054
+ //#endregion
3996
4055
  //#region ../document-api/src/format/inline-run-patch.ts
3997
4056
  var schemaBooleanOrNull = () => ({ oneOf: [{ type: "boolean" }, { type: "null" }] });
3998
4057
  var schemaStringOrNull = () => ({ oneOf: [{
@@ -5703,6 +5762,13 @@ function selectionTargetFromTextTarget(target) {
5703
5762
  ...story ? { story } : {}
5704
5763
  };
5705
5764
  }
5765
+ function capturedTableCellTarget(value) {
5766
+ if (!value || typeof value !== "object") return null;
5767
+ const target = value;
5768
+ if (target.kind !== "selection" || target.coordinateSpace !== void 0 && target.coordinateSpace !== "visible" && target.coordinateSpace !== "tracked" || target.story !== void 0 && !isStoryLocator(target.story)) return null;
5769
+ for (const point of [target.start, target.end]) if (!point || point.kind !== "text" || typeof point.blockId !== "string" || point.blockId.length === 0 || !Number.isInteger(point.offset) || point.offset < 0 || point.story !== void 0 && !isStoryLocator(point.story)) return null;
5770
+ return value;
5771
+ }
5706
5772
  function selectionTargetForRestore(capture) {
5707
5773
  if (capture.selectionTarget) return capture.selectionTarget;
5708
5774
  return selectionTargetFromTextTarget(capture.target);
@@ -7042,11 +7108,11 @@ function createSuperDocUI(options) {
7042
7108
  };
7043
7109
  const selectionScopedAsyncReadKeys = (selection) => {
7044
7110
  const signature = selectionSignature(selection);
7045
- const effectiveUniformitySignature = selectionEffectiveUniformitySignature(selection);
7111
+ const effectiveUniformityKey = effectiveInlineUniformityCacheKey(selection);
7046
7112
  return /* @__PURE__ */ new Set([
7047
7113
  `contentControls:inRange:${signature}`,
7048
7114
  `query:${signature}`,
7049
- ...effectiveUniformitySignature ? [`effInline:${effectiveUniformitySignature}`] : []
7115
+ ...effectiveUniformityKey ? [effectiveUniformityKey] : []
7050
7116
  ]);
7051
7117
  };
7052
7118
  const pruneSelectionScopedAsyncReads = (selection) => {
@@ -7940,7 +8006,7 @@ function createSuperDocUI(options) {
7940
8006
  if (!sawWholeRun) return {};
7941
8007
  return collapseMarkSets(wholeSets);
7942
8008
  };
7943
- const completeProjectedInlineValues = (selection, direct) => {
8009
+ const completeProjectedInlineValues = (selection, direct, effectiveInput = effectiveInlineUniformityInput(selection)) => {
7944
8010
  if (direct.fontFamily !== void 0 && direct.fontSize !== void 0 && direct.color !== void 0 && direct.highlight !== void 0) return {
7945
8011
  values: direct,
7946
8012
  effectiveUniformityStatus: "ready"
@@ -7954,7 +8020,7 @@ function createSuperDocUI(options) {
7954
8020
  ...direct
7955
8021
  };
7956
8022
  if (!selection.empty && (combined.fontFamily === void 0 || combined.fontSize === void 0)) {
7957
- const uniformity = resolveEffectiveInlineUniformityValues(selection);
8023
+ const uniformity = resolveEffectiveInlineUniformityValues(selection, effectiveInput);
7958
8024
  if (uniformity.values) {
7959
8025
  if (combined.fontFamily === void 0 && uniformity.values.fontFamily !== void 0) combined.fontFamily = uniformity.values.fontFamily;
7960
8026
  if (combined.fontSize === void 0 && uniformity.values.fontSize !== void 0) combined.fontSize = uniformity.values.fontSize;
@@ -7984,9 +8050,23 @@ function createSuperDocUI(options) {
7984
8050
  "underline",
7985
8051
  "strikethrough"
7986
8052
  ];
7987
- const readEffectiveInlineUniformityCached = (selection) => {
7988
- const target = selection.selectionTarget;
7989
- if (!target) return {
8053
+ function effectiveInlineUniformityInput(selection) {
8054
+ const cellTarget = currentCellSelectionTarget();
8055
+ const target = cellTarget ?? selection.selectionTarget;
8056
+ if (!target) return null;
8057
+ const tableCellSelection = cellTarget ? tableCellSelectionForTarget(cellTarget) : null;
8058
+ return {
8059
+ target,
8060
+ offsetSpace: "selection",
8061
+ ...tableCellSelection ? { tableCellSelection } : {}
8062
+ };
8063
+ }
8064
+ function effectiveInlineUniformityCacheKey(selection, input = effectiveInlineUniformityInput(selection)) {
8065
+ if (!input) return null;
8066
+ return `effInline:${input.tableCellSelection ? `${selectionKey({ selectionTarget: input.target })}|cells:${JSON.stringify(input.tableCellSelection)}` : selectionEffectiveUniformitySignature(selection) ?? selectionSignature(selection)}`;
8067
+ }
8068
+ const readEffectiveInlineUniformityCached = (selection, input = effectiveInlineUniformityInput(selection)) => {
8069
+ if (!input) return {
7990
8070
  value: null,
7991
8071
  status: "ready"
7992
8072
  };
@@ -7995,15 +8075,13 @@ function createSuperDocUI(options) {
7995
8075
  value: null,
7996
8076
  status: "ready"
7997
8077
  };
7998
- const signature = selectionEffectiveUniformitySignature(selection) ?? selectionSignature(selection);
7999
- return readAsync(`effInline:${signature}`, contentToken(), () => op({
8000
- target,
8001
- offsetSpace: "selection",
8078
+ return readAsync(effectiveInlineUniformityCacheKey(selection, input), contentToken(), () => op({
8079
+ ...input,
8002
8080
  keys: EFFECTIVE_INLINE_UNIFORMITY_KEYS
8003
8081
  }), (raw) => raw && typeof raw === "object" ? raw : null);
8004
8082
  };
8005
- const resolveEffectiveInlineUniformityValues = (selection) => {
8006
- const { value, status } = readEffectiveInlineUniformityCached(selection);
8083
+ const resolveEffectiveInlineUniformityValues = (selection, input = effectiveInlineUniformityInput(selection)) => {
8084
+ const { value, status } = readEffectiveInlineUniformityCached(selection, input);
8007
8085
  if (!value || value.success !== true) return {
8008
8086
  values: null,
8009
8087
  status
@@ -8057,16 +8135,12 @@ function createSuperDocUI(options) {
8057
8135
  const fromWorker = values?.[key];
8058
8136
  return fromWorker !== void 0 ? fromWorker : null;
8059
8137
  };
8060
- const readEffectiveInlineUniformityNow = async (selection) => {
8061
- const target = selection.selectionTarget;
8062
- if (!target) return null;
8138
+ const readEffectiveInlineUniformityNow = async (input) => {
8139
+ if (!input) return null;
8063
8140
  const op = resolveDocOperation(getDoc(), "format.readEffectiveInlineUniformity");
8064
8141
  if (!op) return null;
8065
8142
  try {
8066
- const raw = await Promise.resolve(op({
8067
- target,
8068
- offsetSpace: "selection"
8069
- }));
8143
+ const raw = await Promise.resolve(op(input));
8070
8144
  return raw && typeof raw === "object" && raw.success === true ? raw : null;
8071
8145
  } catch {
8072
8146
  return null;
@@ -8081,8 +8155,8 @@ function createSuperDocUI(options) {
8081
8155
  else delete projected[key];
8082
8156
  }
8083
8157
  };
8084
- const projectSelectionInlineValuesWithStatus = (selection) => completeProjectedInlineValues(selection, projectInlineValuesFromQueryItem(resolveSelectionTextQueryItem(selection), selection));
8085
- const projectSelectionInlineValues = (selection) => projectSelectionInlineValuesWithStatus(selection).values;
8158
+ const projectSelectionInlineValuesWithStatus = (selection, effectiveInput = effectiveInlineUniformityInput(selection)) => completeProjectedInlineValues(selection, projectInlineValuesFromQueryItem(resolveSelectionTextQueryItem(selection), selection), effectiveInput);
8159
+ const projectSelectionInlineValues = (selection, effectiveInput = effectiveInlineUniformityInput(selection)) => projectSelectionInlineValuesWithStatus(selection, effectiveInput).values;
8086
8160
  /**
8087
8161
  * Read command-critical inline values for format-painter capture. Reactive
8088
8162
  * command state intentionally serves stale values while its worker read is
@@ -8091,20 +8165,21 @@ function createSuperDocUI(options) {
8091
8165
  * without changing the non-blocking toolbar snapshot policy.
8092
8166
  */
8093
8167
  const readFormatPainterInlineValues = async (selection) => {
8168
+ const effectiveInput = effectiveInlineUniformityInput(selection);
8094
8169
  const query = getDoc()?.query;
8095
8170
  const request = selectionTextQueryRequest(selection);
8096
- if (typeof query?.match !== "function" || !request) return projectSelectionInlineValues(selection);
8171
+ if (typeof query?.match !== "function" || !request) return projectSelectionInlineValues(selection, effectiveInput);
8097
8172
  try {
8098
8173
  const raw = await Promise.resolve(query.match(request));
8099
8174
  const direct = projectInlineValuesFromQueryItem(pickSelectionTextQueryItem(raw && typeof raw === "object" ? raw : null, selection), selection);
8100
- const completed = completeProjectedInlineValues(selection, direct);
8175
+ const completed = completeProjectedInlineValues(selection, direct, effectiveInput);
8101
8176
  if (completed.effectiveUniformityStatus !== "ready" && (direct.fontFamily === void 0 || direct.fontSize === void 0)) {
8102
- const effective = await readEffectiveInlineUniformityNow(selection);
8177
+ const effective = await readEffectiveInlineUniformityNow(effectiveInput);
8103
8178
  if (effective) applyEffectiveInlineUniformity(completed.values, direct, effective);
8104
8179
  }
8105
8180
  return completed.values;
8106
8181
  } catch {
8107
- return projectSelectionInlineValues(selection);
8182
+ return projectSelectionInlineValues(selection, effectiveInput);
8108
8183
  }
8109
8184
  };
8110
8185
  const readBlockNode = async (address) => {
@@ -8347,7 +8422,7 @@ function createSuperDocUI(options) {
8347
8422
  supported: true,
8348
8423
  reason: lockReason
8349
8424
  }, "builtin");
8350
- const enabled = selectionBlockIds(selection).length > 0 || resolveInlineSelectionTarget(selection) != null;
8425
+ const enabled = selectionBlockIds(selection).length > 0 || resolveInlineCommandTarget(selection) != null;
8351
8426
  return normalizeCommandState({
8352
8427
  enabled,
8353
8428
  active: false,
@@ -8401,7 +8476,7 @@ function createSuperDocUI(options) {
8401
8476
  value,
8402
8477
  reason: SUPERDOC_UI_REASONS.documentReadonly
8403
8478
  }, "builtin");
8404
- if (descriptor.inline && !resolveInlineSelectionTarget(selection)) {
8479
+ if (descriptor.inline && !resolveInlineCommandTarget(selection)) {
8405
8480
  const lockReason = contentControlLockReason(lockModesById);
8406
8481
  if (lockReason) return normalizeCommandState({
8407
8482
  enabled: false,
@@ -10356,9 +10431,32 @@ function createSuperDocUI(options) {
10356
10431
  * option is not part of public `MutationOptions`; this is the same cast
10357
10432
  * pattern the delete/replace callers use.
10358
10433
  */
10359
- const callInlineFormatMutation = (route, op, input, selection = state.selection) => {
10434
+ function currentCellSelectionTarget() {
10435
+ const handles = safeCall(() => getHost()?.getHandles?.(), null);
10436
+ if (!(handles?.selection?.getSnapshot?.())?.tableCells) return null;
10437
+ const resolved = handles?.selection?.toSelectionTarget?.();
10438
+ return resolved?.kind === "ok" && resolved.mode === "range" ? capturedTableCellTarget(resolved.target) : null;
10439
+ }
10440
+ function resolveInlineCommandTarget(selection) {
10441
+ return currentCellSelectionTarget() ?? resolveInlineSelectionTarget(selection);
10442
+ }
10443
+ function tableCellSelectionForTarget(target) {
10444
+ const cellTarget = currentCellSelectionTarget();
10445
+ const candidate = target;
10446
+ if (!cellTarget || candidate?.start?.blockId !== cellTarget.start.blockId || candidate?.end?.blockId !== cellTarget.end.blockId || candidate?.start?.offset !== cellTarget.start.offset || candidate?.end?.offset !== cellTarget.end.offset) return null;
10447
+ return {
10448
+ anchorBlockId: cellTarget.start.blockId,
10449
+ focusBlockId: cellTarget.end.blockId
10450
+ };
10451
+ }
10452
+ const callInlineFormatMutation = (route, op, input, selection = state.selection, tableCellSelection = tableCellSelectionForTarget(input?.target)) => {
10360
10453
  const options = editorMutationOptionsForRoute(route);
10361
10454
  if (options && options.success === false) return options;
10455
+ if (tableCellSelection) return op(input, {
10456
+ ...options,
10457
+ offsetSpace: "selection",
10458
+ tableCellSelection
10459
+ });
10362
10460
  if (!selection.selectionTarget) return options ? op(input, options) : op(input);
10363
10461
  return op(input, {
10364
10462
  ...options,
@@ -10464,7 +10562,7 @@ function createSuperDocUI(options) {
10464
10562
  }
10465
10563
  };
10466
10564
  const defaultStyleId = getStyleCatalog().cache?.full.defaults.paragraphStyleId ?? DEFAULT_PARAGRAPH_STYLE_ID;
10467
- const rangeTarget = resolveInlineSelectionTarget(state.selection);
10565
+ const rangeTarget = resolveInlineCommandTarget(state.selection);
10468
10566
  if (rangeTarget) {
10469
10567
  const inlineOp = resolveDocOperation(doc, "format.apply");
10470
10568
  if (inlineOp) try {
@@ -11061,8 +11159,8 @@ function createSuperDocUI(options) {
11061
11159
  if (state.selection.status !== "ready") return false;
11062
11160
  if (trackDecisionCommand(id)?.scope === "id") return true;
11063
11161
  if (!descriptor || descriptor.disposition !== "routed") return true;
11064
- if (descriptor.inline?.kind === "clear") return selectionBlockIds(state.selection).length > 0 || resolveInlineSelectionTarget(state.selection) != null;
11065
- if (descriptor.inline) return resolveInlineSelectionTarget(state.selection) != null || canStorePendingInlineFormat(state.selection);
11162
+ if (descriptor.inline?.kind === "clear") return selectionBlockIds(state.selection).length > 0 || resolveInlineCommandTarget(state.selection) != null;
11163
+ if (descriptor.inline) return resolveInlineCommandTarget(state.selection) != null || canStorePendingInlineFormat(state.selection);
11066
11164
  if (descriptor.blockParagraph || descriptor.list) return selectionBlockIds(state.selection).length > 0;
11067
11165
  if (descriptor.link) return linkPayloadHasExplicitTarget(payload) || selectionTextAddresses(state.selection).length > 0 || collapsedTextAddressFromSelection(state.selection) != null || commandActiveState(descriptor, getDoc(), state.selection);
11068
11166
  return true;
@@ -11126,7 +11224,7 @@ function createSuperDocUI(options) {
11126
11224
  if (descriptor.inline) {
11127
11225
  const { lockModesById } = computeActiveContentControlLockModes(doc?.contentControls, state.selection);
11128
11226
  if (contentControlLockReason(lockModesById)) return false;
11129
- const target = resolveInlineSelectionTarget(state.selection);
11227
+ const target = resolveInlineCommandTarget(state.selection);
11130
11228
  if (!target) {
11131
11229
  if (!canStorePendingInlineFormat(state.selection)) return settleCommandExecution(false);
11132
11230
  return settleCommandExecution(storePendingInlineFormat(descriptor, normalized));
@@ -11134,6 +11232,8 @@ function createSuperDocUI(options) {
11134
11232
  const active = commandActiveState(descriptor, doc, state.selection);
11135
11233
  const input = buildInlineFormatInput(descriptor.inline, target, normalized, active);
11136
11234
  if (!input) return false;
11235
+ const commandSelection = state.selection;
11236
+ const tableCellSelection = tableCellSelectionForTarget(target);
11137
11237
  let releaseScheduledMutation = null;
11138
11238
  try {
11139
11239
  const commandEditor = getEditor();
@@ -11141,7 +11241,7 @@ function createSuperDocUI(options) {
11141
11241
  const commandMode = readDocumentMode();
11142
11242
  const mutate = () => {
11143
11243
  if (getEditor() !== commandEditor || commandEditor?.doc !== commandDocSource || readDocumentMode() !== commandMode) return false;
11144
- return callInlineFormatMutation(route, op, input);
11244
+ return callInlineFormatMutation(route, op, input, commandSelection, tableCellSelection);
11145
11245
  };
11146
11246
  const selectionSignature = selectionInlineValueSignature(state.selection) ?? selectionKey(state.selection);
11147
11247
  const scheduledMutation = descriptor.inline.kind === "toggle" ? scheduleInlineToggleMutation(`${descriptor.id}:${selectionSignature}`, mutate) : null;
@@ -11452,34 +11552,42 @@ function createSuperDocUI(options) {
11452
11552
  if (painter.pointerSelecting || painter.keyboardSelecting) return;
11453
11553
  const selectionApi = getDoc()?.selection;
11454
11554
  const readSelection = async () => {
11555
+ const cellTarget = currentCellSelectionTarget();
11556
+ const tableCellSelection = tableCellSelectionForTarget(cellTarget);
11455
11557
  const rawSelection = typeof selectionApi?.["current"] === "function" ? await Promise.resolve(selectionApi["current"]({ includeText: true })) : readSelectionInfoLive().value;
11456
- return normalizeSelectionInfo(rawSelection);
11558
+ return {
11559
+ selection: normalizeSelectionInfo(rawSelection),
11560
+ cellTarget,
11561
+ tableCellSelection
11562
+ };
11457
11563
  };
11458
11564
  const waitForSelectionSettle = () => new Promise((resolve) => setTimeout(resolve, 16));
11459
11565
  const MAX_SELECTION_ATTEMPTS = 8;
11460
- let sel = null;
11566
+ let selectionRead = null;
11461
11567
  let key = "";
11462
11568
  for (let attempt = 0; attempt < MAX_SELECTION_ATTEMPTS; attempt += 1) {
11463
11569
  if (attempt > 0) await waitForSelectionSettle();
11464
11570
  if (painter.mode === "idle" || painter.pointerSelecting || painter.keyboardSelecting) return;
11465
- sel = await readSelection();
11571
+ selectionRead = await readSelection();
11572
+ const sel = selectionRead.selection;
11466
11573
  if (!sel || sel["empty"]) continue;
11467
11574
  key = selectionKey(sel);
11468
11575
  if (key === painter.sourceSelectionKey) continue;
11469
11576
  break;
11470
11577
  }
11471
- if (sel && !sel["empty"] && key !== painter.sourceSelectionKey) {
11472
- await applyFormatPainter(sel);
11578
+ if (selectionRead?.selection && !selectionRead.selection["empty"] && key !== painter.sourceSelectionKey) {
11579
+ await applyFormatPainter(selectionRead.selection, selectionRead.cellTarget, selectionRead.tableCellSelection);
11473
11580
  return;
11474
11581
  }
11475
11582
  if (painter.snapshot?.paragraph) {
11476
- const caretSel = await readSelection();
11583
+ const caretRead = await readSelection();
11584
+ const caretSel = caretRead.selection;
11477
11585
  if (!caretSel) return;
11478
11586
  if (selectionKey(caretSel) === painter.sourceSelectionKey) return;
11479
- await applyFormatPainter(caretSel);
11587
+ await applyFormatPainter(caretSel, caretRead.cellTarget, caretRead.tableCellSelection);
11480
11588
  }
11481
11589
  };
11482
- const applyFormatPainter = async (selection) => {
11590
+ const applyFormatPainter = async (selection, cellTarget, tableCellSelection) => {
11483
11591
  const snap = painter.snapshot;
11484
11592
  if (!snap) {
11485
11593
  if (painter.mode === "armed") exitFormatPainter();
@@ -11494,14 +11602,14 @@ function createSuperDocUI(options) {
11494
11602
  return;
11495
11603
  }
11496
11604
  const selTarget = selection["target"];
11497
- const selectionTarget = selection["selectionTarget"];
11605
+ const selectionTarget = cellTarget ?? selection.selectionTarget;
11498
11606
  if (!(selection["empty"] === true) && Object.keys(snap.inline).length > 0) {
11499
11607
  const inlineOp = resolveDocOperation(doc, "format.apply");
11500
11608
  if (inlineOp && selectionTarget) try {
11501
11609
  if (!commandResultSucceeded(commandResultFromOperationResult(await Promise.resolve(callInlineFormatMutation("format.apply", inlineOp, {
11502
11610
  target: selectionTarget,
11503
11611
  inline: snap.inline
11504
- }, selection))))) {
11612
+ }, selection, tableCellSelection))))) {
11505
11613
  recompute();
11506
11614
  return;
11507
11615
  }
@@ -11690,10 +11798,13 @@ function createSuperDocUI(options) {
11690
11798
  current: () => readSelectionInfoLive().value,
11691
11799
  capture: () => {
11692
11800
  const snapshot = selectionSub.get();
11693
- if (snapshot.empty || !snapshot.target && !snapshot.selectionTarget) return null;
11801
+ if (snapshot.empty) return null;
11802
+ const cells = currentCellSelectionTarget();
11803
+ if (!snapshot.target && !snapshot.selectionTarget && !cells) return null;
11694
11804
  return {
11695
11805
  ...snapshot,
11696
- capturedAt: Date.now()
11806
+ capturedAt: Date.now(),
11807
+ ...cells ? { _tableCellSelectionTarget: cells } : {}
11697
11808
  };
11698
11809
  },
11699
11810
  restore: (capture) => {
@@ -11712,7 +11823,13 @@ function createSuperDocUI(options) {
11712
11823
  ok: false,
11713
11824
  reason: SUPERDOC_UI_REASONS.notReady
11714
11825
  });
11715
- const target = selectionTargetForRestore(capture);
11826
+ const hasCellTarget = "_tableCellSelectionTarget" in capture;
11827
+ const cellTarget = hasCellTarget ? capturedTableCellTarget(capture._tableCellSelectionTarget) : null;
11828
+ if (hasCellTarget && !cellTarget) return done({
11829
+ ok: false,
11830
+ reason: SUPERDOC_UI_REASONS.targetUnresolved
11831
+ });
11832
+ const target = cellTarget ?? selectionTargetForRestore(capture);
11716
11833
  if (!target) return done({
11717
11834
  ok: false,
11718
11835
  reason: SUPERDOC_UI_REASONS.targetUnresolved
@@ -11723,7 +11840,7 @@ function createSuperDocUI(options) {
11723
11840
  reason: resolved.reason
11724
11841
  });
11725
11842
  try {
11726
- return done(normalizeHostSelectionApplyResult(resolved.helper.apply(target)));
11843
+ return done(normalizeHostSelectionApplyResult(cellTarget ? resolved.helper.apply(target, { tableCells: true }) : resolved.helper.apply(target)));
11727
11844
  } catch {
11728
11845
  return done({
11729
11846
  ok: false,
@@ -19,7 +19,7 @@ var COLLABORATION_UPGRADE_ENGINE_MINIMUM_NODE_MAJOR = 20;
19
19
  var PRIVATE_ENGINE_INFO = (0, _superdoc_docx_engine_collaboration_upgrade_engine.getCollaborationUpgradeEngineInfo)();
20
20
  var ENGINE_INFO = Object.freeze({
21
21
  ...PRIVATE_ENGINE_INFO,
22
- superdocVersion: "2.22.0-next.17",
22
+ superdocVersion: "2.22.0-next.19",
23
23
  roomSchemaVersion: Object.freeze({ ...PRIVATE_ENGINE_INFO.roomSchemaVersion }),
24
24
  supportedBundleVersions: SUPPORTED_COLLABORATION_UPGRADE_BUNDLE_VERSIONS,
25
25
  supportedV1ReaderContractVersions: SUPPORTED_V1_READER_CONTRACT_VERSIONS
@@ -18,7 +18,7 @@ var COLLABORATION_UPGRADE_ENGINE_MINIMUM_NODE_MAJOR = 20;
18
18
  var PRIVATE_ENGINE_INFO = getCollaborationUpgradeEngineInfo$1();
19
19
  var ENGINE_INFO = Object.freeze({
20
20
  ...PRIVATE_ENGINE_INFO,
21
- superdocVersion: "2.22.0-next.17",
21
+ superdocVersion: "2.22.0-next.19",
22
22
  roomSchemaVersion: Object.freeze({ ...PRIVATE_ENGINE_INFO.roomSchemaVersion }),
23
23
  supportedBundleVersions: SUPPORTED_COLLABORATION_UPGRADE_BUNDLE_VERSIONS,
24
24
  supportedV1ReaderContractVersions: SUPPORTED_V1_READER_CONTRACT_VERSIONS
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_create_super_doc_ui = require("../chunks/create-super-doc-ui-DTLJMJIl.cjs");
2
+ const require_create_super_doc_ui = require("../chunks/create-super-doc-ui-MSiU8Kg0.cjs");
3
3
  const require_slice_source = require("../chunks/slice-source-CFaqq0Vo.cjs");
4
4
  let react = require("react");
5
5
  //#region src/public/ui/react.ts
@@ -1,4 +1,4 @@
1
- import { t as createSuperDocUI } from "../chunks/create-super-doc-ui-Dos1KQcL.es.js";
1
+ import { t as createSuperDocUI } from "../chunks/create-super-doc-ui-DmGX1w-i.es.js";
2
2
  import { t as toSliceSource } from "../chunks/slice-source-gfOhG2MW.es.js";
3
3
  import { createContext, createElement, useCallback, useContext, useEffect, useRef, useState } from "react";
4
4
  //#region src/public/ui/react.ts
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_create_super_doc_ui = require("../chunks/create-super-doc-ui-DTLJMJIl.cjs");
2
+ const require_create_super_doc_ui = require("../chunks/create-super-doc-ui-MSiU8Kg0.cjs");
3
3
  const require_slice_source = require("../chunks/slice-source-CFaqq0Vo.cjs");
4
4
  let superdoc_entry_vue = require("vue");
5
5
  //#region src/public/ui/vue.ts
@@ -1,4 +1,4 @@
1
- import { t as createSuperDocUI } from "../chunks/create-super-doc-ui-Dos1KQcL.es.js";
1
+ import { t as createSuperDocUI } from "../chunks/create-super-doc-ui-DmGX1w-i.es.js";
2
2
  import { t as toSliceSource } from "../chunks/slice-source-gfOhG2MW.es.js";
3
3
  import { computed, inject, onScopeDispose, provide, shallowRef, toRaw, toValue, watch } from "vue";
4
4
  //#region src/public/ui/vue.ts
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_create_super_doc_ui = require("../chunks/create-super-doc-ui-DTLJMJIl.cjs");
2
+ const require_create_super_doc_ui = require("../chunks/create-super-doc-ui-MSiU8Kg0.cjs");
3
3
  exports.BUILT_IN_COMMAND_IDS = require_create_super_doc_ui.BUILT_IN_COMMAND_IDS;
4
4
  exports.createSuperDocUI = require_create_super_doc_ui.createSuperDocUI;
5
5
  exports.shallowEqual = require_create_super_doc_ui.shallowEqual;
@@ -1,2 +1,2 @@
1
- import { a as BUILT_IN_COMMAND_IDS, t as createSuperDocUI, u as shallowEqual } from "../chunks/create-super-doc-ui-Dos1KQcL.es.js";
1
+ import { a as BUILT_IN_COMMAND_IDS, t as createSuperDocUI, u as shallowEqual } from "../chunks/create-super-doc-ui-DmGX1w-i.es.js";
2
2
  export { BUILT_IN_COMMAND_IDS, createSuperDocUI, shallowEqual };
package/dist/superdoc.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_rolldown_runtime = require("./chunks/rolldown-runtime-74VwNCz7.cjs");
3
3
  const require_blank_docx = require("./chunks/blank-docx-BuFAbRjs.cjs");
4
- const require_create_super_doc_ui = require("./chunks/create-super-doc-ui-DTLJMJIl.cjs");
4
+ const require_create_super_doc_ui = require("./chunks/create-super-doc-ui-MSiU8Kg0.cjs");
5
5
  const require_eventemitter3 = require("./chunks/eventemitter3-C_TAnXOl.cjs");
6
6
  const require_uuid = require("./chunks/uuid-BhG0ngwk.cjs");
7
7
  const require__plugin_vue_export_helper = require("./chunks/_plugin-vue_export-helper-CYxINHh_.cjs");
@@ -316,7 +316,7 @@ var shuffleArray = (array) => {
316
316
  var DEFAULT_ENDPOINT = "https://ingest.superdoc.dev/v1/collect";
317
317
  function getSuperdocVersion() {
318
318
  try {
319
- return "2.22.0-next.17";
319
+ return "2.22.0-next.19";
320
320
  } catch {
321
321
  return "unknown";
322
322
  }
@@ -46382,7 +46382,7 @@ var SuperDoc = class extends require_eventemitter3.import_eventemitter3.default
46382
46382
  this.config.colors = shuffleArray(this.config.colors);
46383
46383
  this.userColorMap = /* @__PURE__ */ new Map();
46384
46384
  this.colorIndex = 0;
46385
- this.version = "2.22.0-next.17";
46385
+ this.version = "2.22.0-next.19";
46386
46386
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
46387
46387
  this.superdocId = config.superdocId || require_uuid.v4();
46388
46388
  this.colors = this.config.colors ?? [];
@@ -1,6 +1,6 @@
1
1
  import { i as __toESM$2 } from "./chunks/rolldown-runtime-0pSA04fp.es.js";
2
2
  import { t as blank_default } from "./chunks/blank-docx-DzQccOlW.es.js";
3
- import { c as createImageFilePicker, d as DOM_CLASS_NAMES, f as closeInteractionHistory, g as recordInteraction, h as isWorkflowRecordingEnabled, i as registerFirstPartyCommandMutation, l as resolveImageSrc, m as getWorkflowRecording, n as executeFirstPartyCommandAsync, o as applyV2CommentInvalidationFromMutation, p as createInteractionHistory, r as readFirstPartyPageNumbers, s as getV2TrackedChangeMutationImpact, t as createSuperDocUI } from "./chunks/create-super-doc-ui-Dos1KQcL.es.js";
3
+ import { c as createImageFilePicker, d as DOM_CLASS_NAMES, f as closeInteractionHistory, g as recordInteraction, h as isWorkflowRecordingEnabled, i as registerFirstPartyCommandMutation, l as resolveImageSrc, m as getWorkflowRecording, n as executeFirstPartyCommandAsync, o as applyV2CommentInvalidationFromMutation, p as createInteractionHistory, r as readFirstPartyPageNumbers, s as getV2TrackedChangeMutationImpact, t as createSuperDocUI } from "./chunks/create-super-doc-ui-DmGX1w-i.es.js";
4
4
  import { t as import_eventemitter3 } from "./chunks/eventemitter3-DEIiXiH2.es.js";
5
5
  import { t as v4 } from "./chunks/uuid-H0Xcmmhy.es.js";
6
6
  import { $ as watch$1, A as onActivated, B as resolveDirective, C as isRef$1, D as normalizeClass, E as nextTick, F as openBlock, G as toRef, H as shallowRef$1, I as reactive, J as useAttrs, K as toRefs, L as ref, M as onDeactivated, N as onMounted, O as normalizeProps, P as onScopeDispose$1, Q as vModelText, R as renderList, S as isReactive$1, T as mergeProps, U as toDisplayString, V as resolveDynamicComponent, W as toRaw$2, X as vModelCheckbox, Y as useSlots, Z as vModelSelect, _ as getCurrentInstance, a as computed$1, b as hasInjectionContext, c as createCommentVNode, d as createStaticVNode, et as withCtx, f as createTextVNode, g as effectScope, h as defineComponent, i as Transition, j as onBeforeUnmount, k as normalizeStyle, l as createElementBlock, m as defineAsyncComponent, n as Fragment, nt as withKeys, o as createApp, p as createVNode, q as unref, r as Teleport, rt as withModifiers, s as createBlock, t as _plugin_vue_export_helper_default, tt as withDirectives, u as createElementVNode, v as getCurrentScope, w as markRaw, x as inject$1, y as h, z as renderSlot } from "./chunks/_plugin-vue_export-helper-DHiJKCsy.es.js";
@@ -314,7 +314,7 @@ var shuffleArray = (array) => {
314
314
  var DEFAULT_ENDPOINT = "https://ingest.superdoc.dev/v1/collect";
315
315
  function getSuperdocVersion() {
316
316
  try {
317
- return "2.22.0-next.17";
317
+ return "2.22.0-next.19";
318
318
  } catch {
319
319
  return "unknown";
320
320
  }
@@ -46311,7 +46311,7 @@ var SuperDoc = class extends import_eventemitter3.default {
46311
46311
  this.config.colors = shuffleArray(this.config.colors);
46312
46312
  this.userColorMap = /* @__PURE__ */ new Map();
46313
46313
  this.colorIndex = 0;
46314
- this.version = "2.22.0-next.17";
46314
+ this.version = "2.22.0-next.19";
46315
46315
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
46316
46316
  this.superdocId = config.superdocId || v4();
46317
46317
  this.colors = this.config.colors ?? [];