superdoc 2.28.0-next.13 → 2.28.0-next.15

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.
@@ -5774,6 +5774,43 @@ function mutationCommittedEventChangedDocument(event) {
5774
5774
  if (receipt && typeof receipt === "object" && receipt.status === "NO_OP") return false;
5775
5775
  return true;
5776
5776
  }
5777
+ function readTxId(value) {
5778
+ return typeof value === "string" && value.length > 0 ? value : null;
5779
+ }
5780
+ function documentChangeScope(stories) {
5781
+ return Array.isArray(stories) && stories.length > 0 ? {
5782
+ kind: "known",
5783
+ stories
5784
+ } : { kind: "unknown" };
5785
+ }
5786
+ function documentChangeFromHostEvent(event) {
5787
+ if (event.type === "collaboration:remote-changed") return {
5788
+ cause: "remote",
5789
+ changeTag: null,
5790
+ txId: null,
5791
+ scope: { kind: "unknown" }
5792
+ };
5793
+ if (event.type !== "mutation:committed") return null;
5794
+ if (event.origin === "history") {
5795
+ const result = isPlainObject(event.result) ? event.result : null;
5796
+ if (!result || result.noop === true) return null;
5797
+ const history = isPlainObject(result.history) ? result.history : null;
5798
+ return {
5799
+ cause: event.direction === "redo" ? "redo" : "undo",
5800
+ changeTag: null,
5801
+ txId: readTxId(history?.txId),
5802
+ scope: documentChangeScope(result.affectedStories)
5803
+ };
5804
+ }
5805
+ if (!mutationCommittedEventChangedDocument(event)) return null;
5806
+ const receipt = isPlainObject(event.receipt) ? event.receipt : {};
5807
+ return {
5808
+ cause: event.cause === "user" ? "user" : "api",
5809
+ changeTag: typeof receipt.changeTag === "string" ? receipt.changeTag : null,
5810
+ txId: readTxId(receipt.txId),
5811
+ scope: documentChangeScope(receipt.affectedStories)
5812
+ };
5813
+ }
5777
5814
  function commandResultSucceeded(result) {
5778
5815
  if (result === false) return false;
5779
5816
  if (result && typeof result === "object" && result.success === false) return false;
@@ -10195,6 +10232,25 @@ function createSuperDocUI(options) {
10195
10232
  state = computeState("initial");
10196
10233
  lastOptimisticInlineSelectionSignature = selectionInlineValueSignature(state.selection);
10197
10234
  let scheduleActiveSearchRefresh = () => {};
10235
+ const documentChangeListeners = /* @__PURE__ */ new Set();
10236
+ let documentChangeEpoch = 0;
10237
+ let documentChangeSeq = 0;
10238
+ const startDocumentChangeEpoch = () => {
10239
+ documentChangeEpoch += 1;
10240
+ documentChangeSeq = 0;
10241
+ };
10242
+ const publishDocumentChange = (event) => {
10243
+ if (documentChangeListeners.size === 0) return;
10244
+ const facts = documentChangeFromHostEvent(event);
10245
+ if (!facts) return;
10246
+ documentChangeSeq += 1;
10247
+ const change = {
10248
+ documentEpoch: `document-${documentChangeEpoch}`,
10249
+ seq: documentChangeSeq,
10250
+ ...facts
10251
+ };
10252
+ for (const listener of Array.from(documentChangeListeners)) safeCall(() => listener(change), void 0);
10253
+ };
10198
10254
  const syncHostEventsSubscription = () => {
10199
10255
  const host = getEditor()?.host;
10200
10256
  const events = host?.events;
@@ -10213,6 +10269,8 @@ function createSuperDocUI(options) {
10213
10269
  try {
10214
10270
  const off = hostMethod(next, "subscribe")?.((event) => {
10215
10271
  const type = event?.type;
10272
+ if (type === "collaboration:document-replaced") startDocumentChangeEpoch();
10273
+ publishDocumentChange(event);
10216
10274
  const isStandaloneDocumentMutation = type === "document:mutated" && event.hasCommitEvent !== true;
10217
10275
  if (type === "collaboration:document-replaced" || isStandaloneDocumentMutation || type === "mutation:committed" && mutationCommittedEventChangedDocument(event) || type === "collaboration:remote-changed") {
10218
10276
  for (const [commandId, optimistic] of optimisticInlineToggles) if (optimistic.settled || type === "collaboration:document-replaced") optimisticInlineToggles.delete(commandId);
@@ -13764,8 +13822,14 @@ function createSuperDocUI(options) {
13764
13822
  } catch {
13765
13823
  return;
13766
13824
  }
13825
+ },
13826
+ onChange: (listener) => {
13827
+ if (disposed) return () => {};
13828
+ documentChangeListeners.add(listener);
13829
+ return () => documentChangeListeners.delete(listener);
13767
13830
  }
13768
13831
  };
13832
+ documentResetHooks.push(startDocumentChangeEpoch);
13769
13833
  const resolveVisibleHost = () => {
13770
13834
  if (typeof HTMLElement === "undefined") return null;
13771
13835
  const mountContainer = (getEditor()?.mount)?.container;
@@ -15246,6 +15310,11 @@ function createSuperDocUI(options) {
15246
15310
  const scopeUnsubs = [];
15247
15311
  return {
15248
15312
  decorations: createDecorationsHandle((handle) => scopeUnsubs.push(() => handle.dispose())),
15313
+ document: { onChange: (listener) => {
15314
+ const unsub = documentHandle.onChange(listener);
15315
+ scopeUnsubs.push(unsub);
15316
+ return unsub;
15317
+ } },
15249
15318
  select: (selector, equality) => {
15250
15319
  const sub = select(selector, equality);
15251
15320
  return {
@@ -15332,6 +15401,7 @@ function createSuperDocUI(options) {
15332
15401
  painterCaptureEpoch += 1;
15333
15402
  painterCommandDoc = null;
15334
15403
  painterModeListeners.clear();
15404
+ documentChangeListeners.clear();
15335
15405
  searchRequestGeneration += 1;
15336
15406
  customCommands.clear();
15337
15407
  };
@@ -5775,6 +5775,43 @@ function mutationCommittedEventChangedDocument(event) {
5775
5775
  if (receipt && typeof receipt === "object" && receipt.status === "NO_OP") return false;
5776
5776
  return true;
5777
5777
  }
5778
+ function readTxId(value) {
5779
+ return typeof value === "string" && value.length > 0 ? value : null;
5780
+ }
5781
+ function documentChangeScope(stories) {
5782
+ return Array.isArray(stories) && stories.length > 0 ? {
5783
+ kind: "known",
5784
+ stories
5785
+ } : { kind: "unknown" };
5786
+ }
5787
+ function documentChangeFromHostEvent(event) {
5788
+ if (event.type === "collaboration:remote-changed") return {
5789
+ cause: "remote",
5790
+ changeTag: null,
5791
+ txId: null,
5792
+ scope: { kind: "unknown" }
5793
+ };
5794
+ if (event.type !== "mutation:committed") return null;
5795
+ if (event.origin === "history") {
5796
+ const result = isPlainObject(event.result) ? event.result : null;
5797
+ if (!result || result.noop === true) return null;
5798
+ const history = isPlainObject(result.history) ? result.history : null;
5799
+ return {
5800
+ cause: event.direction === "redo" ? "redo" : "undo",
5801
+ changeTag: null,
5802
+ txId: readTxId(history?.txId),
5803
+ scope: documentChangeScope(result.affectedStories)
5804
+ };
5805
+ }
5806
+ if (!mutationCommittedEventChangedDocument(event)) return null;
5807
+ const receipt = isPlainObject(event.receipt) ? event.receipt : {};
5808
+ return {
5809
+ cause: event.cause === "user" ? "user" : "api",
5810
+ changeTag: typeof receipt.changeTag === "string" ? receipt.changeTag : null,
5811
+ txId: readTxId(receipt.txId),
5812
+ scope: documentChangeScope(receipt.affectedStories)
5813
+ };
5814
+ }
5778
5815
  function commandResultSucceeded(result) {
5779
5816
  if (result === false) return false;
5780
5817
  if (result && typeof result === "object" && result.success === false) return false;
@@ -10196,6 +10233,25 @@ function createSuperDocUI(options) {
10196
10233
  state = computeState("initial");
10197
10234
  lastOptimisticInlineSelectionSignature = selectionInlineValueSignature(state.selection);
10198
10235
  let scheduleActiveSearchRefresh = () => {};
10236
+ const documentChangeListeners = /* @__PURE__ */ new Set();
10237
+ let documentChangeEpoch = 0;
10238
+ let documentChangeSeq = 0;
10239
+ const startDocumentChangeEpoch = () => {
10240
+ documentChangeEpoch += 1;
10241
+ documentChangeSeq = 0;
10242
+ };
10243
+ const publishDocumentChange = (event) => {
10244
+ if (documentChangeListeners.size === 0) return;
10245
+ const facts = documentChangeFromHostEvent(event);
10246
+ if (!facts) return;
10247
+ documentChangeSeq += 1;
10248
+ const change = {
10249
+ documentEpoch: `document-${documentChangeEpoch}`,
10250
+ seq: documentChangeSeq,
10251
+ ...facts
10252
+ };
10253
+ for (const listener of Array.from(documentChangeListeners)) safeCall(() => listener(change), void 0);
10254
+ };
10199
10255
  const syncHostEventsSubscription = () => {
10200
10256
  const host = getEditor()?.host;
10201
10257
  const events = host?.events;
@@ -10214,6 +10270,8 @@ function createSuperDocUI(options) {
10214
10270
  try {
10215
10271
  const off = hostMethod(next, "subscribe")?.((event) => {
10216
10272
  const type = event?.type;
10273
+ if (type === "collaboration:document-replaced") startDocumentChangeEpoch();
10274
+ publishDocumentChange(event);
10217
10275
  const isStandaloneDocumentMutation = type === "document:mutated" && event.hasCommitEvent !== true;
10218
10276
  if (type === "collaboration:document-replaced" || isStandaloneDocumentMutation || type === "mutation:committed" && mutationCommittedEventChangedDocument(event) || type === "collaboration:remote-changed") {
10219
10277
  for (const [commandId, optimistic] of optimisticInlineToggles) if (optimistic.settled || type === "collaboration:document-replaced") optimisticInlineToggles.delete(commandId);
@@ -13765,8 +13823,14 @@ function createSuperDocUI(options) {
13765
13823
  } catch {
13766
13824
  return;
13767
13825
  }
13826
+ },
13827
+ onChange: (listener) => {
13828
+ if (disposed) return () => {};
13829
+ documentChangeListeners.add(listener);
13830
+ return () => documentChangeListeners.delete(listener);
13768
13831
  }
13769
13832
  };
13833
+ documentResetHooks.push(startDocumentChangeEpoch);
13770
13834
  const resolveVisibleHost = () => {
13771
13835
  if (typeof HTMLElement === "undefined") return null;
13772
13836
  const mountContainer = (getEditor()?.mount)?.container;
@@ -15247,6 +15311,11 @@ function createSuperDocUI(options) {
15247
15311
  const scopeUnsubs = [];
15248
15312
  return {
15249
15313
  decorations: createDecorationsHandle((handle) => scopeUnsubs.push(() => handle.dispose())),
15314
+ document: { onChange: (listener) => {
15315
+ const unsub = documentHandle.onChange(listener);
15316
+ scopeUnsubs.push(unsub);
15317
+ return unsub;
15318
+ } },
15250
15319
  select: (selector, equality) => {
15251
15320
  const sub = select(selector, equality);
15252
15321
  return {
@@ -15333,6 +15402,7 @@ function createSuperDocUI(options) {
15333
15402
  painterCaptureEpoch += 1;
15334
15403
  painterCommandDoc = null;
15335
15404
  painterModeListeners.clear();
15405
+ documentChangeListeners.clear();
15336
15406
  searchRequestGeneration += 1;
15337
15407
  customCommands.clear();
15338
15408
  };
@@ -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.28.0-next.13",
22
+ superdocVersion: "2.28.0-next.15",
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.28.0-next.13",
21
+ superdocVersion: "2.28.0-next.15",
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
@@ -138,7 +138,11 @@ export interface SDPasteBlockSdt {
138
138
  lockMode?: 'unlocked' | 'sdtLocked' | 'contentLocked' | 'sdtContentLocked';
139
139
  multiline?: boolean;
140
140
  }
141
- export type SDPasteInline = SDPasteLeafInline | SDPasteSdtInline | {
141
+ export type SDPasteInline = {
142
+ kind: 'math';
143
+ omml: string;
144
+ sourcePath?: readonly (string | number)[];
145
+ } | SDPasteLeafInline | SDPasteSdtInline | {
142
146
  kind: 'hyperlink';
143
147
  target: {
144
148
  kind: 'external';
@@ -1525,6 +1525,7 @@ export type SectionPageBorderSide = {
1525
1525
  };
1526
1526
  export type SectionPageBorders = {
1527
1527
  offsetFrom: 'page';
1528
+ display?: 'allPages' | 'firstPage';
1528
1529
  top?: SectionPageBorderSide;
1529
1530
  right?: SectionPageBorderSide;
1530
1531
  bottom?: SectionPageBorderSide;
@@ -2971,7 +2972,7 @@ export declare const extractHeaderFooterSpace: (margins?: PageMargins | null) =>
2971
2972
  };
2972
2973
  export type { ResolvedLayout, ResolvedPage, ResolvedPaintItem, ResolvedGroupItem, ResolvedFragmentItem, ResolvedParagraphContent, ResolvedTextLineItem, ResolvedDropCapItem, ResolvedListMarkerItem, ResolvedTableItem, ResolvedImageItem, ResolvedDrawingItem, ResolvedHeaderFooterPage, ResolvedHeaderFooterLayout, } from './resolved-layout.js';
2973
2974
  export { isResolvedTableItem, isResolvedImageItem, isResolvedDrawingItem } from './resolved-layout.js';
2974
- export { PAGE_BREAK_DELETION_ANCHOR_ATTR, DELETED_PAGE_BREAK_LABEL, isPageBreakDeletionAnchorRun, expandRunsForInlineNewlines, isBodyNoteReferenceRun, isZeroWidthMarkerRun, hasZeroWidthMarkerSpan, isNoteLabelRun, isNumberedNoteMarkerRun, isEmptyInlineSdtPlaceholderRun, isEmptySdtPlaceholderRun, NOTE_LABEL_MARKER_ATTR, NOTE_REFERENCE_MARKER_ATTR, sliceRunsForLine, usesPositionedTextGeometry, } from './run-helpers.js';
2975
+ export { PAGE_BREAK_DELETION_ANCHOR_ATTR, DELETED_PAGE_BREAK_LABEL, isPageBreakDeletionAnchorRun, expandRunsForInlineNewlines, isBodyNoteReferenceRun, isZeroWidthMarkerRun, isGeneratedFieldResultRun, hasZeroWidthMarkerSpan, isNoteLabelRun, isNumberedNoteMarkerRun, isEmptyInlineSdtPlaceholderRun, isEmptySdtPlaceholderRun, NOTE_LABEL_MARKER_ATTR, NOTE_REFERENCE_MARKER_ATTR, sliceRunsForLine, usesPositionedTextGeometry, } from './run-helpers.js';
2975
2976
  export { INLINE_OBJECT_REPLACEMENT_CHARACTER, flattenParagraphVisibleText, mapVisibleRangeToRunSlices, type ParagraphVisibleRunSlice, } from './paragraph-visible-text.js';
2976
2977
  export { inlineBoxStyleSignature, isFiniteNonNegativeInteger, normalizeInlineBoxLogicalSides, type InlineBoxLogicalSides, type ResolvedInlineBoxLogicalSides, } from './inline-box.js';
2977
2978
  export { INCREMENTAL_DEPENDENCY_CERTIFICATE_CLASSES, PAGE_CHECKPOINT_DEPENDENCY_CLASSES, areValidPageCheckpointDependencyClasses, isValidIncrementalDependencyOwnerVersion, isValidNonFlowingPageRelativeAnchorDependencyProof, isValidPageCheckpointDependencyCertificate, type IncrementalDependencyCertificateClass, type IncrementalDependencyOwnerVersion, type NonFlowingPageRelativeAnchorDependencyProof, type PageCheckpointDependencyCertificate, type PageCheckpointDependencyClass, } from './incremental-dependency.js';
@@ -12,6 +12,7 @@ export declare const NOTE_LABEL_MARKER_ATTR = "data-v2-note-label";
12
12
  export declare function isBodyNoteReferenceRun(run: Run): boolean;
13
13
  export declare function isZeroWidthMarkerRun(run: Run): boolean;
14
14
  export declare function hasZeroWidthMarkerSpan(run: Run): boolean;
15
+ export declare function isGeneratedFieldResultRun(run: Run): boolean;
15
16
  /** Synthetic note-band or appended-endnote label keyed to its source note. */
16
17
  export declare function isNoteLabelRun(run: Run): boolean;
17
18
  /** Numbered marker text whose measurement identity can use digit capabilities. */
@@ -0,0 +1,2 @@
1
+ import { WordLayoutMarker } from '../../contracts/src/index.js';
2
+ export declare const markerRunMeasureKey: (run: WordLayoutMarker["run"] | undefined) => string;
@@ -99,6 +99,7 @@ export type PaginatorOptions = {
99
99
  }): Page;
100
100
  onNewPage?: (state: PageState | undefined, options?: {
101
101
  applyPendingSection: boolean;
102
+ replaceCurrentPage: boolean;
102
103
  }) => void;
103
104
  shouldStopBeforeNewPage?: (input: {
104
105
  completedPageIndex: number;
@@ -46,7 +46,7 @@ export interface TableInfo {
46
46
  * Word applies these flags when a table has no explicit w:tblLook element.
47
47
  */
48
48
  export declare const DEFAULT_TBL_LOOK: TableLookProperties;
49
- export declare function resolveRunProperties(params: OoxmlResolverParams, inlineRpr: RunProperties | null | undefined, resolvedPpr: ParagraphProperties | null | undefined, tableInfo?: TableInfo | null | undefined, isListNumber?: boolean, numberingDefinedInline?: boolean): RunProperties;
49
+ export declare function resolveRunProperties(params: OoxmlResolverParams, inlineRpr: RunProperties | null | undefined, resolvedPpr: ParagraphProperties | null | undefined, tableInfo?: TableInfo | null | undefined, isListNumber?: boolean): RunProperties;
50
50
  export declare function resolveParagraphProperties(params: OoxmlResolverParams, inlineProps: ParagraphProperties | null | undefined, tableInfo: TableInfo | null | undefined): ParagraphProperties;
51
51
  export declare function resolveStyleChain<T extends PropertyObject>(propertyType: 'paragraphProperties' | 'runProperties' | 'tableProperties', params: OoxmlResolverParams, styleId: string | undefined, followBasedOnChain?: boolean): T;
52
52
  export declare function getNumberingProperties<T extends ParagraphProperties | RunProperties>(propertyType: 'paragraphProperties' | 'runProperties', params: OoxmlResolverParams, ilvl: number, numId: number, tries?: number): T;
@@ -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-8dttPeGi.cjs");
2
+ const require_create_super_doc_ui = require("../chunks/create-super-doc-ui-CFlvn2wr.cjs");
3
3
  const require_slice_source = require("../chunks/slice-source-CFaqq0Vo.cjs");
4
4
  let react = require("react");
5
5
  let use_sync_external_store_shim = require("use-sync-external-store/shim");
@@ -1,4 +1,4 @@
1
- import { t as createSuperDocUI } from "../chunks/create-super-doc-ui-B6Va_J_0.es.js";
1
+ import { t as createSuperDocUI } from "../chunks/create-super-doc-ui-BRahDsch.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
  import { useSyncExternalStore } from "use-sync-external-store/shim";
@@ -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-8dttPeGi.cjs");
2
+ const require_create_super_doc_ui = require("../chunks/create-super-doc-ui-CFlvn2wr.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-B6Va_J_0.es.js";
1
+ import { t as createSuperDocUI } from "../chunks/create-super-doc-ui-BRahDsch.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-8dttPeGi.cjs");
2
+ const require_create_super_doc_ui = require("../chunks/create-super-doc-ui-CFlvn2wr.cjs");
3
3
  //#region ../document-api/src/types/receipt.ts
4
4
  /** Read a known failure.details.reason without assuming every failure has one. */
5
5
  function getDocumentApiRejectionReason(details) {
@@ -1,4 +1,4 @@
1
- import { p as shallowEqual, s as BUILT_IN_COMMAND_IDS, t as createSuperDocUI } from "../chunks/create-super-doc-ui-B6Va_J_0.es.js";
1
+ import { p as shallowEqual, s as BUILT_IN_COMMAND_IDS, t as createSuperDocUI } from "../chunks/create-super-doc-ui-BRahDsch.es.js";
2
2
  //#region ../document-api/src/types/receipt.ts
3
3
  /** Read a known failure.details.reason without assuming every failure has one. */
4
4
  function getDocumentApiRejectionReason(details) {