superdoc 2.25.0-next.5 → 2.25.0-next.7

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.
@@ -8197,6 +8197,15 @@ function createSuperDocUI(options) {
8197
8197
  const fromWorker = values?.[key];
8198
8198
  return fromWorker !== void 0 ? fromWorker : null;
8199
8199
  };
8200
+ const inlineToggleStateIsCurrent = (commandId, selection) => {
8201
+ const mark = getCommandDescriptor(commandId)?.activeMark;
8202
+ if (!mark || !EFFECTIVE_MARK_KEYS.includes(mark)) return true;
8203
+ if (resolveEffectiveMarkValuesFromLayout(selection)[mark] !== void 0) return true;
8204
+ if (!resolveDocOperation(getDoc(), "format.readEffectiveInlineUniformity")) return true;
8205
+ const { status } = readEffectiveInlineUniformityCached(selection);
8206
+ const key = effectiveInlineUniformityCacheKey(selection);
8207
+ return status === "ready" || key != null && asyncReads.get(key)?.failedToken === contentToken();
8208
+ };
8200
8209
  const readEffectiveInlineUniformityNow = async (input) => {
8201
8210
  if (!input) return null;
8202
8211
  const op = resolveDocOperation(getDoc(), "format.readEffectiveInlineUniformity");
@@ -9519,8 +9528,8 @@ function createSuperDocUI(options) {
9519
9528
  if (selection.status === "ready") pruneSelectionScopedAsyncReads(selection);
9520
9529
  reconcilePendingInlineFormat(selection);
9521
9530
  const selectionSignature = selectionInlineValueSignature(selection);
9522
- for (const [commandId, optimistic] of optimisticInlineToggles) if (!selectionSignature || optimistic.selectionSignature !== selectionSignature) optimisticInlineToggles.delete(commandId);
9523
- else if (optimistic.settled && selection.status === "ready") optimisticInlineToggles.delete(commandId);
9531
+ for (const [commandId, optimistic] of optimisticInlineToggles) if (!selectionSignature || optimistic.selectionSignature !== selectionSignature || optimistic.editorSource !== getEditor() || optimistic.documentSource !== getEditor()?.doc || optimistic.documentMode !== documentMode) optimisticInlineToggles.delete(commandId);
9532
+ else if (optimistic.settled && selection.status === "ready" && inlineToggleStateIsCurrent(commandId, selection)) optimisticInlineToggles.delete(commandId);
9524
9533
  const nextState = {
9525
9534
  ready: getEditor() != null,
9526
9535
  documentMode,
@@ -9689,6 +9698,7 @@ function createSuperDocUI(options) {
9689
9698
  return null;
9690
9699
  };
9691
9700
  let trackedChangeNavigationInFlight = 0;
9701
+ let lastPublishedHostReviewTarget;
9692
9702
  const syncTrackedChangeFocusFromHostReviewTarget = (rawTarget, rawSnapshot) => {
9693
9703
  const rejection = (rawSnapshot && typeof rawSnapshot === "object" ? rawSnapshot : null)?.lastInteractionRejection;
9694
9704
  if (rawTarget == null && rejection && typeof rejection === "object" && rejection.code === "review-target-invalidated" && rejection.detail === "not-painted" && explicitActiveChange) return false;
@@ -9716,7 +9726,18 @@ function createSuperDocUI(options) {
9716
9726
  };
9717
9727
  }
9718
9728
  if (rawTarget == null && next == null && explicitActiveChange != null && hasPendingTrackChangeRevealFocus(explicitActiveChange)) return false;
9729
+ const previousPublication = lastPublishedHostReviewTarget;
9730
+ if (previousPublication && (rawTarget === previousPublication.raw || target?.origin === "panel" && previousPublication.origin === "panel" && next && previousPublication.focus && explicitActiveChangesEqual(previousPublication.focus, next))) return false;
9731
+ lastPublishedHostReviewTarget = {
9732
+ raw: rawTarget,
9733
+ focus: next,
9734
+ origin: target?.origin
9735
+ };
9719
9736
  if (explicitActiveChangesEqual(explicitActiveChange, next)) return false;
9737
+ if (target?.origin === "panel" && explicitActiveChange && next && explicitActiveChange.id === next.id && storyLocatorSignature(explicitActiveChange.story) === storyLocatorSignature(next.story) && !explicitActiveChange.paintedEntityId && next.paintedEntityId) {
9738
+ explicitActiveChange.paintedEntityId = next.paintedEntityId;
9739
+ return false;
9740
+ }
9720
9741
  setExplicitActiveChange(next);
9721
9742
  return true;
9722
9743
  };
@@ -9728,6 +9749,7 @@ function createSuperDocUI(options) {
9728
9749
  detachHostReview = null;
9729
9750
  }
9730
9751
  currentHostReviewSource = next;
9752
+ lastPublishedHostReviewTarget = void 0;
9731
9753
  if (!next) {
9732
9754
  syncTrackedChangeFocusFromHostReviewTarget(null);
9733
9755
  return;
@@ -9800,6 +9822,9 @@ function createSuperDocUI(options) {
9800
9822
  const off = next.subscribe((event) => {
9801
9823
  const type = event?.type;
9802
9824
  const isStandaloneDocumentMutation = type === "document:mutated" && event.hasCommitEvent !== true;
9825
+ if (type === "collaboration:document-replaced" || isStandaloneDocumentMutation || type === "mutation:committed" && mutationCommittedEventChangedDocument(event) || type === "collaboration:remote-changed") {
9826
+ for (const [commandId, optimistic] of optimisticInlineToggles) if (optimistic.settled || type === "collaboration:document-replaced") optimisticInlineToggles.delete(commandId);
9827
+ }
9803
9828
  if (isStandaloneDocumentMutation || type === "mutation:committed" && mutationCommittedEventChangedDocument(event) || type === "collaboration:remote-changed" && Array.isArray(event.changedStoryIds) && event.changedStoryIds.length > 0) scheduleActiveSearchRefresh();
9804
9829
  if ((type === "document:mutated" || type === "mutation:committed" && mutationCommittedEventChangedDocument(event)) && host && !dirtyHosts.has(host)) {
9805
9830
  dirtyHosts.add(host);
@@ -9966,6 +9991,7 @@ function createSuperDocUI(options) {
9966
9991
  hostSeededMutationRevision.delete(replacedDirtyHost);
9967
9992
  }
9968
9993
  runDocumentResetHooks();
9994
+ optimisticInlineToggles.clear();
9969
9995
  asyncReads.clear();
9970
9996
  invalidateDocumentContent();
9971
9997
  recompute();
@@ -10459,7 +10485,10 @@ function createSuperDocUI(options) {
10459
10485
  selectionSignature,
10460
10486
  active: input.value === true,
10461
10487
  generation,
10462
- settled: false
10488
+ settled: false,
10489
+ editorSource: getEditor(),
10490
+ documentSource: getEditor()?.doc,
10491
+ documentMode: readDocumentMode()
10463
10492
  });
10464
10493
  recompute();
10465
10494
  return generation;
@@ -8196,6 +8196,15 @@ function createSuperDocUI(options) {
8196
8196
  const fromWorker = values?.[key];
8197
8197
  return fromWorker !== void 0 ? fromWorker : null;
8198
8198
  };
8199
+ const inlineToggleStateIsCurrent = (commandId, selection) => {
8200
+ const mark = getCommandDescriptor(commandId)?.activeMark;
8201
+ if (!mark || !EFFECTIVE_MARK_KEYS.includes(mark)) return true;
8202
+ if (resolveEffectiveMarkValuesFromLayout(selection)[mark] !== void 0) return true;
8203
+ if (!resolveDocOperation(getDoc(), "format.readEffectiveInlineUniformity")) return true;
8204
+ const { status } = readEffectiveInlineUniformityCached(selection);
8205
+ const key = effectiveInlineUniformityCacheKey(selection);
8206
+ return status === "ready" || key != null && asyncReads.get(key)?.failedToken === contentToken();
8207
+ };
8199
8208
  const readEffectiveInlineUniformityNow = async (input) => {
8200
8209
  if (!input) return null;
8201
8210
  const op = resolveDocOperation(getDoc(), "format.readEffectiveInlineUniformity");
@@ -9518,8 +9527,8 @@ function createSuperDocUI(options) {
9518
9527
  if (selection.status === "ready") pruneSelectionScopedAsyncReads(selection);
9519
9528
  reconcilePendingInlineFormat(selection);
9520
9529
  const selectionSignature = selectionInlineValueSignature(selection);
9521
- for (const [commandId, optimistic] of optimisticInlineToggles) if (!selectionSignature || optimistic.selectionSignature !== selectionSignature) optimisticInlineToggles.delete(commandId);
9522
- else if (optimistic.settled && selection.status === "ready") optimisticInlineToggles.delete(commandId);
9530
+ for (const [commandId, optimistic] of optimisticInlineToggles) if (!selectionSignature || optimistic.selectionSignature !== selectionSignature || optimistic.editorSource !== getEditor() || optimistic.documentSource !== getEditor()?.doc || optimistic.documentMode !== documentMode) optimisticInlineToggles.delete(commandId);
9531
+ else if (optimistic.settled && selection.status === "ready" && inlineToggleStateIsCurrent(commandId, selection)) optimisticInlineToggles.delete(commandId);
9523
9532
  const nextState = {
9524
9533
  ready: getEditor() != null,
9525
9534
  documentMode,
@@ -9688,6 +9697,7 @@ function createSuperDocUI(options) {
9688
9697
  return null;
9689
9698
  };
9690
9699
  let trackedChangeNavigationInFlight = 0;
9700
+ let lastPublishedHostReviewTarget;
9691
9701
  const syncTrackedChangeFocusFromHostReviewTarget = (rawTarget, rawSnapshot) => {
9692
9702
  const rejection = (rawSnapshot && typeof rawSnapshot === "object" ? rawSnapshot : null)?.lastInteractionRejection;
9693
9703
  if (rawTarget == null && rejection && typeof rejection === "object" && rejection.code === "review-target-invalidated" && rejection.detail === "not-painted" && explicitActiveChange) return false;
@@ -9715,7 +9725,18 @@ function createSuperDocUI(options) {
9715
9725
  };
9716
9726
  }
9717
9727
  if (rawTarget == null && next == null && explicitActiveChange != null && hasPendingTrackChangeRevealFocus(explicitActiveChange)) return false;
9728
+ const previousPublication = lastPublishedHostReviewTarget;
9729
+ if (previousPublication && (rawTarget === previousPublication.raw || target?.origin === "panel" && previousPublication.origin === "panel" && next && previousPublication.focus && explicitActiveChangesEqual(previousPublication.focus, next))) return false;
9730
+ lastPublishedHostReviewTarget = {
9731
+ raw: rawTarget,
9732
+ focus: next,
9733
+ origin: target?.origin
9734
+ };
9718
9735
  if (explicitActiveChangesEqual(explicitActiveChange, next)) return false;
9736
+ if (target?.origin === "panel" && explicitActiveChange && next && explicitActiveChange.id === next.id && storyLocatorSignature(explicitActiveChange.story) === storyLocatorSignature(next.story) && !explicitActiveChange.paintedEntityId && next.paintedEntityId) {
9737
+ explicitActiveChange.paintedEntityId = next.paintedEntityId;
9738
+ return false;
9739
+ }
9719
9740
  setExplicitActiveChange(next);
9720
9741
  return true;
9721
9742
  };
@@ -9727,6 +9748,7 @@ function createSuperDocUI(options) {
9727
9748
  detachHostReview = null;
9728
9749
  }
9729
9750
  currentHostReviewSource = next;
9751
+ lastPublishedHostReviewTarget = void 0;
9730
9752
  if (!next) {
9731
9753
  syncTrackedChangeFocusFromHostReviewTarget(null);
9732
9754
  return;
@@ -9799,6 +9821,9 @@ function createSuperDocUI(options) {
9799
9821
  const off = next.subscribe((event) => {
9800
9822
  const type = event?.type;
9801
9823
  const isStandaloneDocumentMutation = type === "document:mutated" && event.hasCommitEvent !== true;
9824
+ if (type === "collaboration:document-replaced" || isStandaloneDocumentMutation || type === "mutation:committed" && mutationCommittedEventChangedDocument(event) || type === "collaboration:remote-changed") {
9825
+ for (const [commandId, optimistic] of optimisticInlineToggles) if (optimistic.settled || type === "collaboration:document-replaced") optimisticInlineToggles.delete(commandId);
9826
+ }
9802
9827
  if (isStandaloneDocumentMutation || type === "mutation:committed" && mutationCommittedEventChangedDocument(event) || type === "collaboration:remote-changed" && Array.isArray(event.changedStoryIds) && event.changedStoryIds.length > 0) scheduleActiveSearchRefresh();
9803
9828
  if ((type === "document:mutated" || type === "mutation:committed" && mutationCommittedEventChangedDocument(event)) && host && !dirtyHosts.has(host)) {
9804
9829
  dirtyHosts.add(host);
@@ -9965,6 +9990,7 @@ function createSuperDocUI(options) {
9965
9990
  hostSeededMutationRevision.delete(replacedDirtyHost);
9966
9991
  }
9967
9992
  runDocumentResetHooks();
9993
+ optimisticInlineToggles.clear();
9968
9994
  asyncReads.clear();
9969
9995
  invalidateDocumentContent();
9970
9996
  recompute();
@@ -10458,7 +10484,10 @@ function createSuperDocUI(options) {
10458
10484
  selectionSignature,
10459
10485
  active: input.value === true,
10460
10486
  generation,
10461
- settled: false
10487
+ settled: false,
10488
+ editorSource: getEditor(),
10489
+ documentSource: getEditor()?.doc,
10490
+ documentMode: readDocumentMode()
10462
10491
  });
10463
10492
  recompute();
10464
10493
  return generation;
@@ -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.25.0-next.5",
22
+ superdocVersion: "2.25.0-next.7",
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.25.0-next.5",
21
+ superdocVersion: "2.25.0-next.7",
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
@@ -0,0 +1,17 @@
1
+ import { Fragment, ResolvedPage, ResolvedPaintItem } from '../../../contracts/src/index.js';
2
+ import { PageDecorationPayload } from './renderer.js';
3
+ export type DecorationPageGeometry = Pick<ResolvedPage, 'height' | 'margins' | 'baseMargins' | 'footnoteReserved' | 'index'>;
4
+ export declare function resolveDecorationBandGeometry(data: PageDecorationPayload, kind: 'header' | 'footer'): {
5
+ effectiveHeight: number;
6
+ effectiveOffset: number;
7
+ footerYOffset: number;
8
+ };
9
+ /** Page-local coordinates shared by canonical painting and neutral edit geometry. */
10
+ export declare function resolveDecorationFragmentPosition(page: DecorationPageGeometry, kind: 'header' | 'footer', data: PageDecorationPayload, fragment: Fragment, item: ResolvedPaintItem | undefined, band?: {
11
+ effectiveHeight: number;
12
+ effectiveOffset: number;
13
+ footerYOffset: number;
14
+ }, behindDocument?: boolean): {
15
+ x: number;
16
+ y: number;
17
+ };
@@ -137,3 +137,4 @@ export { resolveRunTypographyStyles, resolveRunDecorationStyles } from './runs/t
137
137
  export { resolveTrackedChangeDecorationFacts, getTrackedChangeLayers, resolveTrackedChangesConfig, } from './runs/tracked-changes.js';
138
138
  export { buildLinkRenderData } from './runs/links.js';
139
139
  export { INLINE_TRACKED_CHANGE_DEFAULTS } from './styles.js';
140
+ export { resolveDecorationFragmentPosition } from './decoration-geometry.js';
@@ -433,26 +433,6 @@ export declare class DomPainter {
433
433
  private resolveSeparatorColumnGeometry;
434
434
  private renderDecorationsForPage;
435
435
  private renderDecorationsForPageWork;
436
- /**
437
- * Check if a fragment is vertically anchored to the page.
438
- * Used to determine special Y positioning for page-relative anchored content
439
- * in header/footer decoration sections.
440
- */
441
- private isPageRelativeAnchoredFragment;
442
- private isPageRelativeParagraphFrame;
443
- private isPageRelativeHorizontalAnchoredFragment;
444
- /**
445
- * Header/footer layout emits normalized anchor Y coordinates:
446
- * - headers: local to the header container origin
447
- * - footers: local to the top of the footer band (pageHeight - bottomMargin)
448
- *
449
- * Footer containers can grow upward when content overflows the reserved footer
450
- * band, so their top edge is not always the same as the footer band origin.
451
- * This helper returns the page-space origin that normalized anchor Y values
452
- * are measured from.
453
- */
454
- private getDecorationAnchorPageOriginY;
455
- private getFooterFragmentAnchorPageOriginY;
456
436
  private renderDecorationSectionWork;
457
437
  private resetState;
458
438
  dispose(): void;
@@ -681,15 +661,4 @@ export declare class DomPainter {
681
661
  private applyFragmentWrapperZIndex;
682
662
  private applyResolvedFragmentFrame;
683
663
  private applyFragmentColumnOwnership;
684
- /**
685
- * Estimates the height of a fragment when explicit height is not available.
686
- *
687
- * This method provides fallback height calculations for footer bottom-alignment
688
- * from resolved layout data, or using the fragment's height property for
689
- * tables, images, and drawings.
690
- *
691
- * @param fragment - The fragment to estimate height for
692
- * @returns Estimated height in pixels, or 0 if height cannot be determined
693
- */
694
- private estimateFragmentHeight;
695
664
  }
@@ -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-B-A8sK47.cjs");
2
+ const require_create_super_doc_ui = require("../chunks/create-super-doc-ui-ABeUNZlq.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-CrH79xw6.es.js";
1
+ import { t as createSuperDocUI } from "../chunks/create-super-doc-ui-CCNvH6mr.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-B-A8sK47.cjs");
2
+ const require_create_super_doc_ui = require("../chunks/create-super-doc-ui-ABeUNZlq.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-CrH79xw6.es.js";
1
+ import { t as createSuperDocUI } from "../chunks/create-super-doc-ui-CCNvH6mr.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-B-A8sK47.cjs");
2
+ const require_create_super_doc_ui = require("../chunks/create-super-doc-ui-ABeUNZlq.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-CrH79xw6.es.js";
1
+ import { a as BUILT_IN_COMMAND_IDS, t as createSuperDocUI, u as shallowEqual } from "../chunks/create-super-doc-ui-CCNvH6mr.es.js";
2
2
  export { BUILT_IN_COMMAND_IDS, createSuperDocUI, shallowEqual };