superdoc 2.7.0-next.9 → 2.7.0

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 (37) hide show
  1. package/dist/chunks/{create-super-doc-ui-C44xPZxz.cjs → create-super-doc-ui-B5nhSKqa.cjs} +11 -3
  2. package/dist/chunks/{create-super-doc-ui-BTNVc3UD.es.js → create-super-doc-ui-BJ6D4BfN.es.js} +11 -3
  3. package/dist/collaboration-upgrade-engine.cjs +1 -1
  4. package/dist/collaboration-upgrade-engine.es.js +1 -1
  5. package/dist/document-api/src/capabilities/capabilities.d.ts +3 -0
  6. package/dist/document-api/src/capabilities/html-markdown-support.d.ts +66 -0
  7. package/dist/document-api/src/contract/command-catalog.d.ts +1 -1
  8. package/dist/document-api/src/contract/operation-definitions.d.ts +12 -1
  9. package/dist/document-api/src/contract/operation-registry.d.ts +9 -3
  10. package/dist/document-api/src/diff/diff.types.d.ts +19 -8
  11. package/dist/document-api/src/diff/index.d.ts +1 -1
  12. package/dist/document-api/src/index.d.ts +8 -4
  13. package/dist/document-api/src/insert/insert.d.ts +12 -2
  14. package/dist/document-api/src/replace/replace.d.ts +18 -6
  15. package/dist/document-api/src/types/content-projection.d.ts +4 -1
  16. package/dist/document-api/src/types/mutation-plan.types.d.ts +1 -1
  17. package/dist/document-api/src/types/receipt.d.ts +1 -1
  18. package/dist/document-api/src/types/sd-contract.d.ts +9 -3
  19. package/dist/document-api/src/types/structural-input.d.ts +18 -3
  20. package/dist/document-api/src/write/write.d.ts +8 -3
  21. package/dist/public/ui-react.cjs +1 -1
  22. package/dist/public/ui-react.es.js +1 -1
  23. package/dist/public/ui.cjs +1 -1
  24. package/dist/public/ui.es.js +1 -1
  25. package/dist/style.css +10 -4
  26. package/dist/style.layered.css +10 -4
  27. package/dist/superdoc/src/public/index.d.cts +6 -0
  28. package/dist/superdoc/src/public/index.d.ts +1 -0
  29. package/dist/superdoc/src/public/ui/types.d.ts +1 -1
  30. package/dist/superdoc/src/public/ui.d.cts +4 -0
  31. package/dist/superdoc/src/public/ui.d.ts +1 -1
  32. package/dist/superdoc.cjs +15 -3
  33. package/dist/superdoc.es.js +15 -3
  34. package/dist-cdn/style.layered.css +1 -1
  35. package/dist-cdn/superdoc.min.css +1 -1
  36. package/dist-cdn/superdoc.min.js +17 -17
  37. package/package.json +2 -2
@@ -8115,11 +8115,19 @@ function createSuperDocUI(options) {
8115
8115
  try {
8116
8116
  if (spec.action === "insert-row-before" || spec.action === "insert-row-after") {
8117
8117
  const host = getHost();
8118
- const insertRow = ((typeof host?.getHandles === "function" ? host.getHandles() : null)?.editing)?.tables;
8119
- if (typeof insertRow?.insertRow !== "function") return false;
8118
+ const tableCommands = ((typeof host?.getHandles === "function" ? host.getHandles() : null)?.editing)?.tables;
8119
+ if (typeof tableCommands?.insertRow !== "function") return false;
8120
8120
  const options = editorMutationOptionsForRoute(descriptor.docRoute);
8121
8121
  if (options && options.success === false) return options;
8122
- return options ? insertRow.insertRow(input, options) : insertRow.insertRow(input);
8122
+ return options ? tableCommands.insertRow(input, options) : tableCommands.insertRow(input);
8123
+ }
8124
+ if (spec.action === "insert-column-before" || spec.action === "insert-column-after") {
8125
+ const host = getHost();
8126
+ const tableCommands = ((typeof host?.getHandles === "function" ? host.getHandles() : null)?.editing)?.tables;
8127
+ if (typeof tableCommands?.insertColumn !== "function") return false;
8128
+ const options = editorMutationOptionsForRoute(descriptor.docRoute);
8129
+ if (options && options.success === false) return options;
8130
+ return options ? tableCommands.insertColumn(input, context.rowIndex, options) : tableCommands.insertColumn(input, context.rowIndex);
8123
8131
  }
8124
8132
  return callEditorMutation(descriptor.docRoute, op, input);
8125
8133
  } catch {
@@ -8115,11 +8115,19 @@ function createSuperDocUI(options) {
8115
8115
  try {
8116
8116
  if (spec.action === "insert-row-before" || spec.action === "insert-row-after") {
8117
8117
  const host = getHost();
8118
- const insertRow = ((typeof host?.getHandles === "function" ? host.getHandles() : null)?.editing)?.tables;
8119
- if (typeof insertRow?.insertRow !== "function") return false;
8118
+ const tableCommands = ((typeof host?.getHandles === "function" ? host.getHandles() : null)?.editing)?.tables;
8119
+ if (typeof tableCommands?.insertRow !== "function") return false;
8120
8120
  const options = editorMutationOptionsForRoute(descriptor.docRoute);
8121
8121
  if (options && options.success === false) return options;
8122
- return options ? insertRow.insertRow(input, options) : insertRow.insertRow(input);
8122
+ return options ? tableCommands.insertRow(input, options) : tableCommands.insertRow(input);
8123
+ }
8124
+ if (spec.action === "insert-column-before" || spec.action === "insert-column-after") {
8125
+ const host = getHost();
8126
+ const tableCommands = ((typeof host?.getHandles === "function" ? host.getHandles() : null)?.editing)?.tables;
8127
+ if (typeof tableCommands?.insertColumn !== "function") return false;
8128
+ const options = editorMutationOptionsForRoute(descriptor.docRoute);
8129
+ if (options && options.success === false) return options;
8130
+ return options ? tableCommands.insertColumn(input, context.rowIndex, options) : tableCommands.insertColumn(input, context.rowIndex);
8123
8131
  }
8124
8132
  return callEditorMutation(descriptor.docRoute, op, input);
8125
8133
  } catch {
@@ -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.7.0-next.9",
22
+ superdocVersion: "2.7.0",
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.7.0-next.9",
21
+ superdocVersion: "2.7.0",
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,6 @@
1
1
  import { OperationId } from '../contract/types.js';
2
2
  import { InlinePropertyStorage, InlinePropertyType, InlineRunPatchKey } from '../format/inline-run-patch.js';
3
+ import { SDHtmlMarkdownSupportCheckInput, SDHtmlMarkdownSupportCheckResult } from './html-markdown-support.js';
3
4
  export declare const CAPABILITY_REASON_CODES: readonly ["COMMAND_UNAVAILABLE", "HELPER_UNAVAILABLE", "OPERATION_UNAVAILABLE", "TRACKED_MODE_UNAVAILABLE", "DRY_RUN_UNAVAILABLE", "NAMESPACE_UNAVAILABLE", "STYLES_PART_MISSING", "COLLABORATION_ACTIVE"];
4
5
  export type CapabilityReasonCode = (typeof CAPABILITY_REASON_CODES)[number];
5
6
  /**
@@ -72,6 +73,7 @@ export interface DocumentApiCapabilities {
72
73
  /** Engine-specific adapter that resolves runtime capabilities for the current editor instance. */
73
74
  export interface CapabilitiesAdapter {
74
75
  get(): DocumentApiCapabilities;
76
+ check?(input: SDHtmlMarkdownSupportCheckInput): Promise<SDHtmlMarkdownSupportCheckResult>;
75
77
  }
76
78
  /**
77
79
  * Delegates to the capabilities adapter to retrieve the current capability snapshot.
@@ -80,3 +82,4 @@ export interface CapabilitiesAdapter {
80
82
  * @returns The resolved capabilities for this editor instance.
81
83
  */
82
84
  export declare function executeCapabilities(adapter: CapabilitiesAdapter): DocumentApiCapabilities;
85
+ export declare function executeCapabilitiesCheck(adapter: CapabilitiesAdapter, input: SDHtmlMarkdownSupportCheckInput): Promise<SDHtmlMarkdownSupportCheckResult>;
@@ -0,0 +1,66 @@
1
+ import { RichContentInsertInput } from '../insert/insert.js';
2
+ import { RichContentReplaceInput } from '../replace/replace.js';
3
+ import { ChangeMode } from '../write/write.js';
4
+ import { ProjectHtmlInput, ProjectMarkdownInput, SDContentProjectionResult, SDProjectionReviewMode, SDResolvedProjectionScope } from '../types/content-projection.js';
5
+ import { SDFragment } from '../types/fragment.js';
6
+ import { SDError, SDHtmlMarkdownOutcome, SDMutationConversionReport, SDMutationReceipt } from '../types/sd-contract.js';
7
+ import { StoryLocator } from '../types/story.types.js';
8
+ export interface SDHtmlMarkdownCheckGuard {
9
+ version: 'sd-html-markdown-check/1';
10
+ operation: 'insert' | 'replace';
11
+ evaluatedRevision: string;
12
+ requestSha256: string;
13
+ analysisSha256: string;
14
+ }
15
+ export type SDHtmlMarkdownSupportCheckInput = {
16
+ operation: 'insert';
17
+ input: RichContentInsertInput;
18
+ options?: {
19
+ changeMode?: ChangeMode;
20
+ };
21
+ } | {
22
+ operation: 'replace';
23
+ input: RichContentReplaceInput;
24
+ options?: {
25
+ changeMode?: ChangeMode;
26
+ };
27
+ } | {
28
+ operation: 'projectHtml';
29
+ input?: ProjectHtmlInput;
30
+ } | {
31
+ operation: 'projectMarkdown';
32
+ input?: ProjectMarkdownInput;
33
+ };
34
+ interface SDHtmlMarkdownCheckCommon {
35
+ operation: SDHtmlMarkdownSupportCheckInput['operation'];
36
+ format: 'html' | 'markdown';
37
+ supported: boolean;
38
+ outcome: SDHtmlMarkdownOutcome;
39
+ evaluatedRevision: string;
40
+ failure?: SDError;
41
+ }
42
+ export interface SDHtmlMarkdownWriteCheckResult extends SDHtmlMarkdownCheckCommon {
43
+ operation: 'insert' | 'replace';
44
+ wouldChange: boolean;
45
+ conversion: SDMutationConversionReport;
46
+ plan?: {
47
+ fragment: SDFragment;
48
+ resolution: NonNullable<SDMutationReceipt['resolution']>;
49
+ changeMode: ChangeMode;
50
+ atomic: true;
51
+ };
52
+ guard?: SDHtmlMarkdownCheckGuard;
53
+ }
54
+ export interface SDHtmlMarkdownProjectionCheckResult extends SDHtmlMarkdownCheckCommon {
55
+ operation: 'projectHtml' | 'projectMarkdown';
56
+ plan?: {
57
+ reviewMode: SDProjectionReviewMode;
58
+ story: StoryLocator;
59
+ scope: SDResolvedProjectionScope;
60
+ includeSourceMap: boolean;
61
+ };
62
+ projection?: SDContentProjectionResult<'html' | 'markdown'>;
63
+ }
64
+ export type SDHtmlMarkdownSupportCheckResult = SDHtmlMarkdownWriteCheckResult | SDHtmlMarkdownProjectionCheckResult;
65
+ export declare function validateSDHtmlMarkdownSupportCheckInput(input: unknown): asserts input is SDHtmlMarkdownSupportCheckInput;
66
+ export {};
@@ -1,7 +1,7 @@
1
1
  import { CommandCatalog, CommandStaticMetadata, OperationId } from './types.js';
2
2
  export declare const COMMAND_CATALOG: CommandCatalog;
3
3
  /** Operation IDs whose catalog entry has `mutates: true`. */
4
- export declare const MUTATING_OPERATION_IDS: ("replace" | "find" | "delete" | "get" | "insert" | "info" | "format.apply" | "blocks.split" | "blocks.merge" | "blocks.move" | "lists.getState" | "lists.apply" | "lists.continue" | "lists.restart" | "lists.remove" | "format.paragraph.setMarkRunProps" | "tables.moveRow" | "format.bold" | "format.strike" | "format.color" | "format.italic" | "format.rtl" | "format.cs" | "format.shading" | "format.fontFamily" | "format.lang" | "format.fontSize" | "format.fontSizeCs" | "format.highlight" | "format.underline" | "format.caps" | "format.smallCaps" | "format.outline" | "format.shadow" | "format.emboss" | "format.imprint" | "format.vanish" | "format.webHidden" | "format.specVanish" | "format.border" | "format.fitText" | "format.dstrike" | "format.vertAlign" | "format.position" | "format.bCs" | "format.iCs" | "format.snapToGrid" | "format.oMath" | "format.letterSpacing" | "format.charScale" | "format.kerning" | "format.rStyle" | "format.rFonts" | "format.eastAsianLayout" | "format.em" | "format.ligatures" | "format.numForm" | "format.numSpacing" | "format.stylisticSets" | "format.contextualAlternates" | "getNode" | "getNodeById" | "getText" | "getMarkdown" | "getHtml" | "projectMarkdown" | "projectHtml" | "markdownToFragment" | "htmlToFragment" | "extract" | "clearContent" | "formatRange" | "blocks.list" | "blocks.delete" | "blocks.deleteRange" | "styles.apply" | "styles.getCatalog" | "templates.apply" | "create.paragraph" | "create.heading" | "create.sectionBreak" | "sections.list" | "sections.get" | "sections.setBreakType" | "sections.setPageMargins" | "sections.setHeaderFooterMargins" | "sections.setPageSetup" | "sections.setColumns" | "sections.setLineNumbering" | "sections.setPageNumbering" | "sections.setTitlePage" | "sections.setOddEvenHeadersFooters" | "sections.setVerticalAlign" | "sections.setSectionDirection" | "sections.setHeaderFooterRef" | "sections.clearHeaderFooterRef" | "sections.setLinkToPrevious" | "sections.setPageBorders" | "sections.clearPageBorders" | "styles.paragraph.setStyle" | "styles.paragraph.setStyleRef" | "styles.paragraph.clearStyle" | "format.paragraph.resetDirectFormatting" | "format.paragraph.setAlignment" | "format.paragraph.clearAlignment" | "format.paragraph.setIndentation" | "format.paragraph.clearIndentation" | "format.paragraph.setSpacing" | "format.paragraph.clearSpacing" | "format.paragraph.setKeepOptions" | "format.paragraph.setOutlineLevel" | "format.paragraph.setFlowOptions" | "format.paragraph.setTabStop" | "format.paragraph.clearTabStop" | "format.paragraph.clearAllTabStops" | "format.paragraph.setBorder" | "format.paragraph.clearBorder" | "format.paragraph.setShading" | "format.paragraph.clearShading" | "format.paragraph.setDirection" | "format.paragraph.clearDirection" | "format.paragraph.setNumbering" | "lists.list" | "lists.get" | "lists.insert" | "lists.create" | "lists.attach" | "lists.detach" | "lists.delete" | "lists.indent" | "lists.outdent" | "lists.join" | "lists.canJoin" | "lists.separate" | "lists.merge" | "lists.split" | "lists.setLevel" | "lists.setValue" | "lists.continuePrevious" | "lists.canContinuePrevious" | "lists.setLevelRestart" | "lists.convertToText" | "lists.applyTemplate" | "lists.applyPreset" | "lists.setType" | "lists.captureTemplate" | "lists.setLevelNumbering" | "lists.setLevelBullet" | "lists.setLevelPictureBullet" | "lists.setLevelAlignment" | "lists.setLevelIndents" | "lists.setLevelTrailingCharacter" | "lists.setLevelMarkerFont" | "lists.clearLevelOverrides" | "lists.getStyle" | "lists.applyStyle" | "lists.restartAt" | "lists.setLevelNumberStyle" | "lists.setLevelText" | "lists.setLevelStart" | "lists.setLevelLayout" | "comments.create" | "comments.patch" | "comments.delete" | "comments.get" | "comments.list" | "trackChanges.list" | "trackChanges.get" | "trackChanges.decide" | "query.match" | "ranges.resolve" | "selection.current" | "mutations.preview" | "mutations.apply" | "plan.execute" | "capabilities.get" | "create.table" | "tables.convertFromText" | "tables.delete" | "tables.clearContents" | "tables.move" | "tables.split" | "tables.convertToText" | "tables.setLayout" | "tables.insertRow" | "tables.deleteRow" | "tables.setRowHeight" | "tables.distributeRows" | "tables.setRowOptions" | "tables.insertColumn" | "tables.deleteColumn" | "tables.setColumnWidth" | "tables.distributeColumns" | "tables.insertCell" | "tables.deleteCell" | "tables.mergeCells" | "tables.unmergeCells" | "tables.splitCell" | "tables.setCellProperties" | "tables.setCellText" | "tables.sort" | "tables.setAltText" | "tables.setStyle" | "tables.clearStyle" | "tables.setStyleOption" | "tables.setBorder" | "tables.clearBorder" | "tables.applyBorderPreset" | "tables.setShading" | "tables.clearShading" | "tables.setTablePadding" | "tables.setCellPadding" | "tables.setCellSpacing" | "tables.clearCellSpacing" | "tables.applyStyle" | "tables.setBorders" | "tables.setTableOptions" | "tables.applyPreset" | "tables.get" | "tables.getCells" | "tables.getProperties" | "tables.getStyles" | "tables.setDefaultStyle" | "tables.clearDefaultStyle" | "create.tableOfContents" | "toc.list" | "toc.get" | "toc.configure" | "toc.update" | "toc.remove" | "toc.markEntry" | "toc.unmarkEntry" | "toc.listEntries" | "toc.getEntry" | "toc.editEntry" | "history.get" | "history.undo" | "history.redo" | "create.image" | "images.list" | "images.get" | "images.delete" | "images.move" | "images.convertToInline" | "images.convertToFloating" | "images.setSize" | "images.setWrapType" | "images.setWrapSide" | "images.setWrapDistances" | "images.setPosition" | "images.setAnchorOptions" | "images.setZOrder" | "images.scale" | "images.setLockAspectRatio" | "images.rotate" | "images.flip" | "images.crop" | "images.resetCrop" | "images.replaceSource" | "images.setAltText" | "images.setDecorative" | "images.setName" | "images.setHyperlink" | "images.insertCaption" | "images.updateCaption" | "images.removeCaption" | "hyperlinks.list" | "hyperlinks.get" | "hyperlinks.wrap" | "hyperlinks.insert" | "hyperlinks.patch" | "hyperlinks.remove" | "headerFooters.list" | "headerFooters.get" | "headerFooters.resolve" | "headerFooters.refs.set" | "headerFooters.refs.clear" | "headerFooters.refs.setLinkedToPrevious" | "headerFooters.parts.list" | "headerFooters.parts.create" | "headerFooters.parts.delete" | "create.contentControl" | "contentControls.list" | "contentControls.get" | "contentControls.listInRange" | "contentControls.selectByTag" | "contentControls.selectByTitle" | "contentControls.listChildren" | "contentControls.getParent" | "contentControls.wrap" | "contentControls.unwrap" | "contentControls.delete" | "contentControls.copy" | "contentControls.move" | "contentControls.patch" | "contentControls.setLockMode" | "contentControls.setType" | "contentControls.getContent" | "contentControls.replaceContent" | "contentControls.clearContent" | "contentControls.appendContent" | "contentControls.prependContent" | "contentControls.insertBefore" | "contentControls.insertAfter" | "contentControls.getBinding" | "contentControls.setBinding" | "contentControls.clearBinding" | "contentControls.getRawProperties" | "contentControls.patchRawProperties" | "contentControls.validateWordCompatibility" | "contentControls.normalizeWordCompatibility" | "contentControls.normalizeTagPayload" | "contentControls.text.setMultiline" | "contentControls.text.setValue" | "contentControls.text.clearValue" | "contentControls.date.setValue" | "contentControls.date.clearValue" | "contentControls.date.setDisplayFormat" | "contentControls.date.setDisplayLocale" | "contentControls.date.setStorageFormat" | "contentControls.date.setCalendar" | "contentControls.checkbox.getState" | "contentControls.checkbox.setState" | "contentControls.checkbox.toggle" | "contentControls.checkbox.setSymbolPair" | "contentControls.choiceList.getItems" | "contentControls.choiceList.setItems" | "contentControls.choiceList.setSelected" | "contentControls.repeatingSection.listItems" | "contentControls.repeatingSection.insertItemBefore" | "contentControls.repeatingSection.insertItemAfter" | "contentControls.repeatingSection.cloneItem" | "contentControls.repeatingSection.deleteItem" | "contentControls.repeatingSection.setAllowInsertDelete" | "contentControls.group.wrap" | "contentControls.group.ungroup" | "bookmarks.list" | "bookmarks.get" | "bookmarks.insert" | "bookmarks.rename" | "bookmarks.remove" | "footnotes.list" | "footnotes.get" | "footnotes.insert" | "footnotes.update" | "footnotes.remove" | "footnotes.configure" | "clipboard.parse" | "clipboard.insert" | "clipboard.serializeSelection" | "crossRefs.list" | "crossRefs.get" | "crossRefs.insert" | "crossRefs.rebuild" | "crossRefs.remove" | "index.list" | "index.get" | "index.insert" | "index.configure" | "index.rebuild" | "index.remove" | "index.entries.list" | "index.entries.get" | "index.entries.insert" | "index.entries.update" | "index.entries.remove" | "captions.list" | "captions.get" | "captions.insert" | "captions.update" | "captions.remove" | "captions.configure" | "fields.list" | "fields.get" | "fields.insert" | "fields.rebuild" | "fields.remove" | "citations.list" | "citations.get" | "citations.insert" | "citations.update" | "citations.remove" | "citations.sources.list" | "citations.sources.get" | "citations.sources.insert" | "citations.sources.update" | "citations.sources.remove" | "citations.bibliography.get" | "citations.bibliography.insert" | "citations.bibliography.rebuild" | "citations.bibliography.configure" | "citations.bibliography.remove" | "authorities.list" | "authorities.get" | "authorities.insert" | "authorities.configure" | "authorities.rebuild" | "authorities.remove" | "authorities.entries.list" | "authorities.entries.get" | "authorities.entries.insert" | "authorities.entries.update" | "authorities.entries.remove" | "diff.capture" | "diff.compare" | "diff.apply" | "export.toDocx" | "protection.get" | "protection.setEditingRestriction" | "protection.clearEditingRestriction" | "permissionRanges.list" | "permissionRanges.get" | "permissionRanges.create" | "permissionRanges.remove" | "permissionRanges.updatePrincipal" | "customXml.parts.list" | "customXml.parts.get" | "customXml.parts.create" | "customXml.parts.patch" | "customXml.parts.remove" | "metadata.attach" | "metadata.list" | "metadata.get" | "metadata.update" | "metadata.remove" | "metadata.resolve")[];
4
+ export declare const MUTATING_OPERATION_IDS: ("replace" | "find" | "delete" | "get" | "insert" | "info" | "projectHtml" | "projectMarkdown" | "capabilities.check" | "format.apply" | "blocks.split" | "blocks.merge" | "blocks.move" | "lists.getState" | "lists.apply" | "lists.continue" | "lists.restart" | "lists.remove" | "format.paragraph.setMarkRunProps" | "tables.moveRow" | "format.bold" | "format.strike" | "format.color" | "format.italic" | "format.rtl" | "format.cs" | "format.shading" | "format.fontFamily" | "format.lang" | "format.fontSize" | "format.fontSizeCs" | "format.highlight" | "format.underline" | "format.caps" | "format.smallCaps" | "format.outline" | "format.shadow" | "format.emboss" | "format.imprint" | "format.vanish" | "format.webHidden" | "format.specVanish" | "format.border" | "format.fitText" | "format.dstrike" | "format.vertAlign" | "format.position" | "format.bCs" | "format.iCs" | "format.snapToGrid" | "format.oMath" | "format.letterSpacing" | "format.charScale" | "format.kerning" | "format.rStyle" | "format.rFonts" | "format.eastAsianLayout" | "format.em" | "format.ligatures" | "format.numForm" | "format.numSpacing" | "format.stylisticSets" | "format.contextualAlternates" | "getNode" | "getNodeById" | "getText" | "getMarkdown" | "getHtml" | "markdownToFragment" | "htmlToFragment" | "extract" | "clearContent" | "formatRange" | "blocks.list" | "blocks.delete" | "blocks.deleteRange" | "styles.apply" | "styles.getCatalog" | "templates.apply" | "create.paragraph" | "create.heading" | "create.sectionBreak" | "sections.list" | "sections.get" | "sections.setBreakType" | "sections.setPageMargins" | "sections.setHeaderFooterMargins" | "sections.setPageSetup" | "sections.setColumns" | "sections.setLineNumbering" | "sections.setPageNumbering" | "sections.setTitlePage" | "sections.setOddEvenHeadersFooters" | "sections.setVerticalAlign" | "sections.setSectionDirection" | "sections.setHeaderFooterRef" | "sections.clearHeaderFooterRef" | "sections.setLinkToPrevious" | "sections.setPageBorders" | "sections.clearPageBorders" | "styles.paragraph.setStyle" | "styles.paragraph.setStyleRef" | "styles.paragraph.clearStyle" | "format.paragraph.resetDirectFormatting" | "format.paragraph.setAlignment" | "format.paragraph.clearAlignment" | "format.paragraph.setIndentation" | "format.paragraph.clearIndentation" | "format.paragraph.setSpacing" | "format.paragraph.clearSpacing" | "format.paragraph.setKeepOptions" | "format.paragraph.setOutlineLevel" | "format.paragraph.setFlowOptions" | "format.paragraph.setTabStop" | "format.paragraph.clearTabStop" | "format.paragraph.clearAllTabStops" | "format.paragraph.setBorder" | "format.paragraph.clearBorder" | "format.paragraph.setShading" | "format.paragraph.clearShading" | "format.paragraph.setDirection" | "format.paragraph.clearDirection" | "format.paragraph.setNumbering" | "lists.list" | "lists.get" | "lists.insert" | "lists.create" | "lists.attach" | "lists.detach" | "lists.delete" | "lists.indent" | "lists.outdent" | "lists.join" | "lists.canJoin" | "lists.separate" | "lists.merge" | "lists.split" | "lists.setLevel" | "lists.setValue" | "lists.continuePrevious" | "lists.canContinuePrevious" | "lists.setLevelRestart" | "lists.convertToText" | "lists.applyTemplate" | "lists.applyPreset" | "lists.setType" | "lists.captureTemplate" | "lists.setLevelNumbering" | "lists.setLevelBullet" | "lists.setLevelPictureBullet" | "lists.setLevelAlignment" | "lists.setLevelIndents" | "lists.setLevelTrailingCharacter" | "lists.setLevelMarkerFont" | "lists.clearLevelOverrides" | "lists.getStyle" | "lists.applyStyle" | "lists.restartAt" | "lists.setLevelNumberStyle" | "lists.setLevelText" | "lists.setLevelStart" | "lists.setLevelLayout" | "comments.create" | "comments.patch" | "comments.delete" | "comments.get" | "comments.list" | "trackChanges.list" | "trackChanges.get" | "trackChanges.decide" | "query.match" | "ranges.resolve" | "selection.current" | "mutations.preview" | "mutations.apply" | "plan.execute" | "capabilities.get" | "create.table" | "tables.convertFromText" | "tables.delete" | "tables.clearContents" | "tables.move" | "tables.split" | "tables.convertToText" | "tables.setLayout" | "tables.insertRow" | "tables.deleteRow" | "tables.setRowHeight" | "tables.distributeRows" | "tables.setRowOptions" | "tables.insertColumn" | "tables.deleteColumn" | "tables.setColumnWidth" | "tables.distributeColumns" | "tables.insertCell" | "tables.deleteCell" | "tables.mergeCells" | "tables.unmergeCells" | "tables.splitCell" | "tables.setCellProperties" | "tables.setCellText" | "tables.sort" | "tables.setAltText" | "tables.setStyle" | "tables.clearStyle" | "tables.setStyleOption" | "tables.setBorder" | "tables.clearBorder" | "tables.applyBorderPreset" | "tables.setShading" | "tables.clearShading" | "tables.setTablePadding" | "tables.setCellPadding" | "tables.setCellSpacing" | "tables.clearCellSpacing" | "tables.applyStyle" | "tables.setBorders" | "tables.setTableOptions" | "tables.applyPreset" | "tables.get" | "tables.getCells" | "tables.getProperties" | "tables.getStyles" | "tables.setDefaultStyle" | "tables.clearDefaultStyle" | "create.tableOfContents" | "toc.list" | "toc.get" | "toc.configure" | "toc.update" | "toc.remove" | "toc.markEntry" | "toc.unmarkEntry" | "toc.listEntries" | "toc.getEntry" | "toc.editEntry" | "history.get" | "history.undo" | "history.redo" | "create.image" | "images.list" | "images.get" | "images.delete" | "images.move" | "images.convertToInline" | "images.convertToFloating" | "images.setSize" | "images.setWrapType" | "images.setWrapSide" | "images.setWrapDistances" | "images.setPosition" | "images.setAnchorOptions" | "images.setZOrder" | "images.scale" | "images.setLockAspectRatio" | "images.rotate" | "images.flip" | "images.crop" | "images.resetCrop" | "images.replaceSource" | "images.setAltText" | "images.setDecorative" | "images.setName" | "images.setHyperlink" | "images.insertCaption" | "images.updateCaption" | "images.removeCaption" | "hyperlinks.list" | "hyperlinks.get" | "hyperlinks.wrap" | "hyperlinks.insert" | "hyperlinks.patch" | "hyperlinks.remove" | "headerFooters.list" | "headerFooters.get" | "headerFooters.resolve" | "headerFooters.refs.set" | "headerFooters.refs.clear" | "headerFooters.refs.setLinkedToPrevious" | "headerFooters.parts.list" | "headerFooters.parts.create" | "headerFooters.parts.delete" | "create.contentControl" | "contentControls.list" | "contentControls.get" | "contentControls.listInRange" | "contentControls.selectByTag" | "contentControls.selectByTitle" | "contentControls.listChildren" | "contentControls.getParent" | "contentControls.wrap" | "contentControls.unwrap" | "contentControls.delete" | "contentControls.copy" | "contentControls.move" | "contentControls.patch" | "contentControls.setLockMode" | "contentControls.setType" | "contentControls.getContent" | "contentControls.replaceContent" | "contentControls.clearContent" | "contentControls.appendContent" | "contentControls.prependContent" | "contentControls.insertBefore" | "contentControls.insertAfter" | "contentControls.getBinding" | "contentControls.setBinding" | "contentControls.clearBinding" | "contentControls.getRawProperties" | "contentControls.patchRawProperties" | "contentControls.validateWordCompatibility" | "contentControls.normalizeWordCompatibility" | "contentControls.normalizeTagPayload" | "contentControls.text.setMultiline" | "contentControls.text.setValue" | "contentControls.text.clearValue" | "contentControls.date.setValue" | "contentControls.date.clearValue" | "contentControls.date.setDisplayFormat" | "contentControls.date.setDisplayLocale" | "contentControls.date.setStorageFormat" | "contentControls.date.setCalendar" | "contentControls.checkbox.getState" | "contentControls.checkbox.setState" | "contentControls.checkbox.toggle" | "contentControls.checkbox.setSymbolPair" | "contentControls.choiceList.getItems" | "contentControls.choiceList.setItems" | "contentControls.choiceList.setSelected" | "contentControls.repeatingSection.listItems" | "contentControls.repeatingSection.insertItemBefore" | "contentControls.repeatingSection.insertItemAfter" | "contentControls.repeatingSection.cloneItem" | "contentControls.repeatingSection.deleteItem" | "contentControls.repeatingSection.setAllowInsertDelete" | "contentControls.group.wrap" | "contentControls.group.ungroup" | "bookmarks.list" | "bookmarks.get" | "bookmarks.insert" | "bookmarks.rename" | "bookmarks.remove" | "footnotes.list" | "footnotes.get" | "footnotes.insert" | "footnotes.update" | "footnotes.remove" | "footnotes.configure" | "clipboard.parse" | "clipboard.insert" | "clipboard.serializeSelection" | "crossRefs.list" | "crossRefs.get" | "crossRefs.insert" | "crossRefs.rebuild" | "crossRefs.remove" | "index.list" | "index.get" | "index.insert" | "index.configure" | "index.rebuild" | "index.remove" | "index.entries.list" | "index.entries.get" | "index.entries.insert" | "index.entries.update" | "index.entries.remove" | "captions.list" | "captions.get" | "captions.insert" | "captions.update" | "captions.remove" | "captions.configure" | "fields.list" | "fields.get" | "fields.insert" | "fields.rebuild" | "fields.remove" | "citations.list" | "citations.get" | "citations.insert" | "citations.update" | "citations.remove" | "citations.sources.list" | "citations.sources.get" | "citations.sources.insert" | "citations.sources.update" | "citations.sources.remove" | "citations.bibliography.get" | "citations.bibliography.insert" | "citations.bibliography.rebuild" | "citations.bibliography.configure" | "citations.bibliography.remove" | "authorities.list" | "authorities.get" | "authorities.insert" | "authorities.configure" | "authorities.rebuild" | "authorities.remove" | "authorities.entries.list" | "authorities.entries.get" | "authorities.entries.insert" | "authorities.entries.update" | "authorities.entries.remove" | "diff.capture" | "diff.compare" | "diff.apply" | "export.toDocx" | "protection.get" | "protection.setEditingRestriction" | "protection.clearEditingRestriction" | "permissionRanges.list" | "permissionRanges.get" | "permissionRanges.create" | "permissionRanges.remove" | "permissionRanges.updatePrincipal" | "customXml.parts.list" | "customXml.parts.get" | "customXml.parts.create" | "customXml.parts.patch" | "customXml.parts.remove" | "metadata.attach" | "metadata.list" | "metadata.get" | "metadata.update" | "metadata.remove" | "metadata.resolve")[];
5
5
  /** Maps each operation to its human-readable description. */
6
6
  export declare const OPERATION_DESCRIPTION_MAP: Record<OperationId, string>;
7
7
  /** Maps each operation to whether it requires an open document to execute. */
@@ -1055,6 +1055,17 @@ export declare const OPERATION_DEFINITIONS: {
1055
1055
  readonly referenceDocPath: "capabilities/get.mdx";
1056
1056
  readonly referenceGroup: "capabilities";
1057
1057
  };
1058
+ readonly 'capabilities.check': {
1059
+ readonly memberPath: "capabilities.check";
1060
+ readonly description: "Check an exact HTML or Markdown insert, replace, or detailed projection against the current document without mutating it.";
1061
+ readonly expectedResult: "Returns a Promise resolving to structured support, fidelity outcome, diagnostics, and a revision-bound guard for supported writes.";
1062
+ readonly requiresDocumentContext: true;
1063
+ readonly metadata: CommandStaticMetadata;
1064
+ readonly referenceDocPath: "capabilities/check.mdx";
1065
+ readonly referenceGroup: "capabilities";
1066
+ readonly intentGroup: "edit";
1067
+ readonly intentAction: "check_support";
1068
+ };
1058
1069
  readonly 'create.table': {
1059
1070
  readonly memberPath: "create.table";
1060
1071
  readonly description: "Create a new table at the target position.";
@@ -3172,7 +3183,7 @@ export declare const OPERATION_DEFINITIONS: {
3172
3183
  readonly 'diff.apply': {
3173
3184
  readonly memberPath: "diff.apply";
3174
3185
  readonly description: string;
3175
- readonly expectedResult: "Returns a DiffApplyResult with applied operation count and diagnostics.";
3186
+ readonly expectedResult: "Returns a DiffApplyResult with per-operation review receipts, applied operation count, and diagnostics.";
3176
3187
  readonly requiresDocumentContext: true;
3177
3188
  readonly metadata: CommandStaticMetadata;
3178
3189
  readonly referenceDocPath: "diff/apply.mdx";
@@ -21,7 +21,7 @@ import { ClearContentInput } from '../clear-content/clear-content.js';
21
21
  import { InsertInput } from '../insert/insert.js';
22
22
  import { ReplaceInput } from '../replace/replace.js';
23
23
  import { DeleteInput } from '../delete/delete.js';
24
- import { MutationOptions, RevisionGuardOptions } from '../write/write.js';
24
+ import { MutationOptions, RevisionGuardOptions, RichContentMutationOptions } from '../write/write.js';
25
25
  import { FormatInlineAliasInput, FormatRangeInput, StyleApplyInput } from '../format/format.js';
26
26
  import { InlineRunPatchKey } from '../format/inline-run-patch.js';
27
27
  import { StylesApplyInput, StylesApplyOptions, StylesApplyReceipt, StylesGetCatalogInput, StylesGetCatalogResult } from '../styles/index.js';
@@ -31,6 +31,7 @@ import { CommentInfo, CommentsListQuery, CommentsListResult } from '../comments/
31
31
  import { TrackChangesListInput, TrackChangesGetInput, ReviewDecideInput } from '../track-changes/track-changes.js';
32
32
  import { TrackChangeInfo, TrackChangesListResult } from '../types/track-changes.types.js';
33
33
  import { DocumentApiCapabilities } from '../capabilities/capabilities.js';
34
+ import { SDHtmlMarkdownSupportCheckInput, SDHtmlMarkdownSupportCheckResult } from '../capabilities/html-markdown-support.js';
34
35
  import { HistoryState, HistoryActionResult } from '../history/history.types.js';
35
36
  import { DiffSnapshot, DiffPayload, DiffApplyResult, DiffCompareInput, DiffApplyInput, DiffApplyOptions } from '../diff/diff.types.js';
36
37
  import { ExportToDocxInput, ExportToDocxResult } from '../export/export.types.js';
@@ -141,12 +142,12 @@ export interface OperationRegistry extends FormatInlineAliasOperationRegistry {
141
142
  };
142
143
  insert: {
143
144
  input: InsertInput;
144
- options: MutationOptions;
145
+ options: RichContentMutationOptions;
145
146
  output: SDMutationReceipt;
146
147
  };
147
148
  replace: {
148
149
  input: ReplaceInput;
149
- options: MutationOptions;
150
+ options: RichContentMutationOptions;
150
151
  output: SDMutationReceipt;
151
152
  };
152
153
  delete: {
@@ -729,6 +730,11 @@ export interface OperationRegistry extends FormatInlineAliasOperationRegistry {
729
730
  options: never;
730
731
  output: DocumentApiCapabilities;
731
732
  };
733
+ 'capabilities.check': {
734
+ input: SDHtmlMarkdownSupportCheckInput;
735
+ options: never;
736
+ output: Promise<SDHtmlMarkdownSupportCheckResult>;
737
+ };
732
738
  'history.get': {
733
739
  input: undefined;
734
740
  options: never;
@@ -1,10 +1,6 @@
1
- /**
2
- * Public types for the snapshot-based document diff contract.
3
- *
4
- * These types are engine-agnostic wrappers around opaque engine payloads.
5
- * The `payload` field in both DiffSnapshot and DiffPayload is engine-owned
6
- * and must not be inspected by consumers.
7
- */
1
+ import { TrackedChangeAddress } from '../types/address.js';
2
+ import { StoryLocator } from '../types/story.types.js';
3
+ import { TrackChangeNavigationTarget } from '../types/track-changes.types.js';
8
4
  /** Identifier for the engine adapter that produced the opaque payload. */
9
5
  export type DiffEngineId = 'superdoc-v2';
10
6
  /** Declares which document components are included in a snapshot or diff. */
@@ -58,9 +54,24 @@ export interface DiffPayload {
58
54
  /** Opaque engine-owned diff data. Do not inspect or modify. */
59
55
  payload: Record<string, unknown>;
60
56
  }
61
- /** Result metadata returned after applying a diff. */
57
+ export interface DiffApplyReviewItem {
58
+ id: string;
59
+ story: StoryLocator;
60
+ address: TrackedChangeAddress;
61
+ navigationTarget?: TrackChangeNavigationTarget;
62
+ }
63
+ export type DiffApplyOperationReceipt = {
64
+ operationId: string;
65
+ disposition: 'review-created';
66
+ reviewItems: [DiffApplyReviewItem, ...DiffApplyReviewItem[]];
67
+ } | {
68
+ operationId: string;
69
+ disposition: 'applied-directly';
70
+ reviewItems: [];
71
+ };
62
72
  export interface DiffApplyResult {
63
73
  appliedOperations: number;
74
+ operationReceipts: DiffApplyOperationReceipt[];
64
75
  baseFingerprint: string;
65
76
  targetFingerprint: string;
66
77
  coverage: DiffCoverage;
@@ -1,3 +1,3 @@
1
1
  export type { DiffAdapter, DiffApi } from './diff.js';
2
2
  export { executeDiffCapture, executeDiffCompare, executeDiffApply } from './diff.js';
3
- export type { DiffSnapshot, DiffPayload, DiffApplyResult, DiffSummary, DiffCoverage, DiffEngineId, DiffCompareInput, DiffApplyInput, DiffApplyOptions, DiffChangeMode, } from './diff.types.js';
3
+ export type { DiffSnapshot, DiffPayload, DiffApplyResult, DiffSummary, DiffCoverage, DiffEngineId, DiffCompareInput, DiffApplyInput, DiffApplyOptions, DiffChangeMode, DiffApplyOperationReceipt, DiffApplyReviewItem, } from './diff.types.js';
@@ -30,9 +30,10 @@ import { CreateAdapter, CreateApi } from './create/create.js';
30
30
  import { BlocksAdapter, BlocksApi } from './blocks/blocks.js';
31
31
  import { TableLocator, TableMutationResult, TablesConvertFromTextInput, TablesMoveInput, TablesSplitInput, TablesConvertToTextInput, TablesSetLayoutInput, TablesInsertRowInput, TablesDeleteRowInput, TablesMoveRowInput, TablesSetRowHeightInput, TablesDistributeRowsInput, TablesSetRowOptionsInput, TablesInsertColumnInput, TablesDeleteColumnInput, TablesSetColumnWidthInput, TablesDistributeColumnsInput, TablesInsertCellInput, TablesDeleteCellInput, TablesMergeCellsInput, TablesUnmergeCellsInput, TablesSplitCellInput, TablesSetCellPropertiesInput, TablesSetCellTextInput, TablesSortInput, TablesSetAltTextInput, TablesSetStyleInput, TablesClearStyleInput, TablesSetStyleOptionInput, TablesSetBorderInput, TablesClearBorderInput, TablesApplyBorderPresetInput, TablesSetShadingInput, TablesClearShadingInput, TablesSetTablePaddingInput, TablesSetCellPaddingInput, TablesSetCellSpacingInput, TablesClearCellSpacingInput, TablesApplyStyleInput, TablesSetBordersInput, TablesSetTableOptionsInput, TablesApplyPresetInput, TablesGetInput, TablesGetOutput, TablesGetCellsInput, TablesGetCellsOutput, TablesGetPropertiesInput, TablesGetPropertiesOutput, TablesGetStylesInput, TablesGetStylesOutput, TablesSetDefaultStyleInput, TablesClearDefaultStyleInput } from './types/table-operations.types.js';
32
32
  import { TrackChangesAdapter, TrackChangesApi } from './track-changes/track-changes.js';
33
- import { MutationOptions, RevisionGuardOptions, WriteAdapter } from './write/write.js';
33
+ import { MutationOptions, RevisionGuardOptions, RichContentMutationOptions, WriteAdapter } from './write/write.js';
34
34
  import { SelectionMutationAdapter } from './selection-mutation.js';
35
35
  import { CapabilitiesAdapter, DocumentApiCapabilities } from './capabilities/capabilities.js';
36
+ import { SDHtmlMarkdownSupportCheckInput, SDHtmlMarkdownSupportCheckResult } from './capabilities/html-markdown-support.js';
36
37
  import { OperationId } from './contract/types.js';
37
38
  import { DynamicInvokeRequest, InvokeRequest, InvokeResult } from './contract/operation-registry.js';
38
39
  import { PlanApi } from './plan/plan.js';
@@ -63,6 +64,7 @@ import { AuthoritiesApi, AuthoritiesAdapter } from './authorities/authorities.js
63
64
  export * from './types/index.js';
64
65
  export * from './contract/index.js';
65
66
  export * from './capabilities/capabilities.js';
67
+ export * from './capabilities/html-markdown-support.js';
66
68
  export * from './inline-semantics/index.js';
67
69
  export type { HistoryAdapter, HistoryApi } from './history/history.js';
68
70
  export { executeHistoryGet, executeHistoryUndo, executeHistoryRedo } from './history/history.js';
@@ -89,6 +91,7 @@ export { executeProjectMarkdown } from './project-markdown/project-markdown.js';
89
91
  export type { HistoryState, HistoryActionResult, HistoryNoopReason, SDHistoryStatus, SDHistoryCollaborationMeta, } from './history/history.types.js';
90
92
  export { executeTrackChangesGet, executeTrackChangesList, executeTrackChangesDecide, } from './track-changes/track-changes.js';
91
93
  export { createPlanApi, type PlanApi, type PlanExecuteInput, type PlanExecuteEntry, type PlanExecuteEntryExpect, type PlanExecuteResult, type PlanEntryReceipt, type PlanEntryReceiptStatus, type PlanExecuteFailure, type PlanCaptureRefMarker, type PlanProjectTextOffsetMarker, } from './plan/plan.js';
94
+ export type { DiffSnapshot, DiffPayload, DiffApplyResult, DiffCompareInput, DiffApplyInput, DiffApplyOptions, DiffApplyOperationReceipt, DiffApplyReviewItem, } from './diff/diff.types.js';
92
95
  export type { GetAdapter } from './get/get.js';
93
96
  export type { FindAdapter, FindOptions } from './find/find.js';
94
97
  export type { GetNodeAdapter, GetNodeByIdInput } from './get-node/get-node.js';
@@ -97,7 +100,7 @@ export type { GetMarkdownAdapter, GetMarkdownInput } from './get-markdown/get-ma
97
100
  export type { GetHtmlAdapter, GetHtmlInput } from './get-html/get-html.js';
98
101
  export type { InfoAdapter, InfoInput } from './info/info.js';
99
102
  export type { ExtractAdapter, ExtractInput } from './extract/extract.js';
100
- export type { WriteAdapter, WriteRequest } from './write/write.js';
103
+ export type { WriteAdapter, WriteRequest, RichContentMutationOptions } from './write/write.js';
101
104
  export type { FormatInlineAliasApi, FormatInlineAliasInput, FormatBoldInput, FormatItalicInput, FormatRangeInput, FormatUnderlineInput, FormatStrikethroughInput, StyleApplyInput, StyleApplyOptions, } from './format/format.js';
102
105
  export type { InlineRunPatch, InlineRunPatchKey, InlinePropertyStorage, InlinePropertyType, InlinePropertyCarrier, InlinePropertyRegistryEntry, UnderlinePatch, ShadingPatch, BorderPatch, FitTextPatch, LangPatch, RFontsPatch, EastAsianLayoutPatch, StylisticSetPatch, } from './format/inline-run-patch.js';
103
106
  export { INLINE_PROPERTY_REGISTRY, INLINE_PROPERTY_KEY_SET, INLINE_PROPERTY_BY_KEY, INLINE_PROPERTY_KEYS_BY_STORAGE, validateInlineRunPatch, buildInlineRunPatchSchema, } from './format/inline-run-patch.js';
@@ -232,6 +235,7 @@ export type TablesAdapter = Omit<TablesApi, 'moveRow'> & {
232
235
  export interface CapabilitiesApi {
233
236
  (): DocumentApiCapabilities;
234
237
  get(): DocumentApiCapabilities;
238
+ check(input: SDHtmlMarkdownSupportCheckInput): Promise<SDHtmlMarkdownSupportCheckResult>;
235
239
  }
236
240
  export interface QueryApi {
237
241
  /** Accepts canonical nested input or a selector shorthand normalized to `{ select: ... }` internally. */
@@ -325,11 +329,11 @@ export interface DocumentApi {
325
329
  * Insert content at a target location.
326
330
  * If target is omitted, inserts at the end of the document.
327
331
  */
328
- insert(input: InsertInput, options?: MutationOptions): SDMutationReceipt;
332
+ insert(input: InsertInput, options?: RichContentMutationOptions): SDMutationReceipt;
329
333
  /**
330
334
  * Replace text at a target range.
331
335
  */
332
- replace(input: ReplaceInput, options?: MutationOptions): SDMutationReceipt;
336
+ replace(input: ReplaceInput, options?: RichContentMutationOptions): SDMutationReceipt;
333
337
  /**
334
338
  * Delete text at a target range.
335
339
  */
@@ -1,4 +1,4 @@
1
- import { MutationOptions, WriteAdapter } from '../write/write.js';
1
+ import { RichContentMutationOptions, WriteAdapter } from '../write/write.js';
2
2
  import { SelectionTarget, TargetLocator, SDMutationReceipt } from '../types/index.js';
3
3
  import { SDInsertInput } from '../types/structural-input.js';
4
4
  import { StoryLocator } from '../types/story.types.js';
@@ -45,8 +45,18 @@ export type LegacyInsertInput = TextInsertInput;
45
45
  * These are mutually exclusive: providing both is an error.
46
46
  */
47
47
  export type InsertInput = TextInsertInput | RichContentInsertInput | SDInsertInput;
48
+ export declare function isRichContentInsertInput(input: InsertInput): input is RichContentInsertInput;
48
49
  /** Returns true when the input uses the structural SDFragment shape. */
49
50
  export declare function isStructuralInsertInput(input: InsertInput): input is SDInsertInput;
51
+ /**
52
+ * Validates InsertInput as either text or structural shape.
53
+ *
54
+ * Validation order:
55
+ * 0. Input shape guard (must be non-null plain object)
56
+ * 1. Union conflict detection (mutually exclusive discriminants)
57
+ * 2. Shape-specific field and type validation
58
+ */
59
+ export declare function validateInsertInput(input: unknown): asserts input is InsertInput;
50
60
  /**
51
61
  * Executes an insert operation, routing to the appropriate adapter path.
52
62
  *
@@ -60,5 +70,5 @@ export declare function isStructuralInsertInput(input: InsertInput): input is SD
60
70
  * @param options - Optional mutation options (changeMode, dryRun, expectedRevision).
61
71
  * @returns Receipt indicating success/failure and mutation metadata.
62
72
  */
63
- export declare function executeInsert(selectionAdapter: SelectionMutationAdapter, writeAdapter: WriteAdapter, input: InsertInput, options?: MutationOptions): SDMutationReceipt;
73
+ export declare function executeInsert(selectionAdapter: SelectionMutationAdapter, writeAdapter: WriteAdapter, input: InsertInput, options?: RichContentMutationOptions): SDMutationReceipt;
64
74
  export {};
@@ -1,19 +1,23 @@
1
- import { MutationOptions } from '../types/mutation-plan.types.js';
1
+ import { RichContentMutationOptions, WriteAdapter } from '../write/write.js';
2
2
  import { SelectionTarget, TargetLocator } from '../types/address.js';
3
3
  import { SDMutationReceipt } from '../types/sd-contract.js';
4
4
  import { SDReplaceInput } from '../types/structural-input.js';
5
- import { StoryLocator } from '../types/story.types.js';
5
+ import { BodyStoryLocator, StoryLocator } from '../types/story.types.js';
6
6
  import { BlockNodeAddress } from '../types/base.js';
7
7
  import { NestingPolicy } from '../types/placement.js';
8
8
  import { SelectionMutationAdapter } from '../selection-mutation.js';
9
- import { WriteAdapter } from '../write/write.js';
10
- /** Text replacement input: uses SelectionTarget / ref. */
11
- export type TextReplaceInput = TargetLocator & {
9
+ /** Text replacement input: uses SelectionTarget / ref, or the complete main body. */
10
+ export type TextReplaceInput = (TargetLocator & {
12
11
  target?: SelectionTarget;
13
12
  ref?: string;
14
13
  text: string;
15
14
  /** Target a specific document story (body, header, footer, footnote, endnote). */
16
15
  in?: StoryLocator;
16
+ }) | {
17
+ target: BodyStoryLocator;
18
+ text: string;
19
+ ref?: never;
20
+ in?: never;
17
21
  };
18
22
  /** HTML or Markdown replacement input for conversion and structured application. */
19
23
  export type RichContentReplaceInput = {
@@ -23,6 +27,13 @@ export type RichContentReplaceInput = {
23
27
  ref?: string;
24
28
  in?: StoryLocator;
25
29
  nestingPolicy?: NestingPolicy;
30
+ } | {
31
+ value: string;
32
+ type: 'html' | 'markdown';
33
+ target: BodyStoryLocator;
34
+ ref?: never;
35
+ in?: never;
36
+ nestingPolicy?: never;
26
37
  };
27
38
  /**
28
39
  * Input payload for the `doc.replace` operation.
@@ -33,4 +44,5 @@ export type ReplaceInput = TextReplaceInput | RichContentReplaceInput | SDReplac
33
44
  /** Returns true when the input uses the structural SDFragment shape. */
34
45
  export declare function isStructuralReplaceInput(input: ReplaceInput): input is SDReplaceInput;
35
46
  export declare function isRichContentReplaceInput(input: ReplaceInput): input is RichContentReplaceInput;
36
- export declare function executeReplace(selectionAdapter: SelectionMutationAdapter, writeAdapter: WriteAdapter, input: ReplaceInput, options?: MutationOptions): SDMutationReceipt;
47
+ export declare function validateReplaceInput(input: unknown): asserts input is ReplaceInput;
48
+ export declare function executeReplace(selectionAdapter: SelectionMutationAdapter, writeAdapter: WriteAdapter, input: ReplaceInput, options?: RichContentMutationOptions): SDMutationReceipt;
@@ -1,7 +1,7 @@
1
1
  import { BlockNodeAddress, BlockNodeType } from './base.js';
2
2
  import { Range, SelectionTarget, TextTarget } from './address.js';
3
3
  import { StoryLocator } from './story.types.js';
4
- import { SDDiagnostic } from './sd-contract.js';
4
+ import { SDDiagnostic, SDHtmlMarkdownOutcome } from './sd-contract.js';
5
5
  export declare const SD_PROJECTION_FORMATS: readonly ["html", "markdown"];
6
6
  export type SDProjectionFormat = (typeof SD_PROJECTION_FORMATS)[number];
7
7
  export declare const SD_PROJECTION_REVIEW_MODES: readonly ["final", "original", "redline"];
@@ -112,6 +112,8 @@ export interface SDContentProjectionResult<TFormat extends SDProjectionFormat =
112
112
  format: TFormat;
113
113
  content: string;
114
114
  status: SDProjectionStatus;
115
+ /** Fidelity outcome derived from the complete projection diagnostics. */
116
+ outcome: SDHtmlMarkdownOutcome;
115
117
  reviewMode: SDProjectionReviewMode;
116
118
  evaluatedRevision: string;
117
119
  story: StoryLocator;
@@ -122,5 +124,6 @@ export interface SDContentProjectionResult<TFormat extends SDProjectionFormat =
122
124
  annotations: SDProjectionAnnotation[];
123
125
  sourceMap?: SDProjectionSourceMap;
124
126
  }
127
+ export declare function deriveSDHtmlMarkdownOutcome(diagnostics: readonly Pick<SDDiagnostic, 'severity' | 'lossy'>[]): SDHtmlMarkdownOutcome;
125
128
  export declare function deriveSDProjectionStatus(diagnostics: readonly Pick<SDProjectionDiagnostic, 'severity' | 'lossy'>[]): SDProjectionStatus;
126
129
  export declare function validateSDProjectionSourceMap(sourceMap: SDProjectionSourceMap, contentLength: number): boolean;
@@ -264,4 +264,4 @@ export type PlanExecutionError = {
264
264
  stepId?: string;
265
265
  details?: unknown;
266
266
  };
267
- export type { RevisionGuardOptions, MutationOptions } from '../write/write.js';
267
+ export type { RevisionGuardOptions, MutationOptions, RichContentMutationOptions } from '../write/write.js';
@@ -9,7 +9,7 @@ export type AffectedRefRemapping = {
9
9
  from: AffectedRef;
10
10
  to: AffectedRef;
11
11
  };
12
- export type ReceiptFailureCode = 'NO_OP' | 'INVALID_TARGET' | 'TARGET_NOT_FOUND' | 'CAPABILITY_UNAVAILABLE' | 'PERMISSION_DENIED' | 'STALE_REVISION' | 'REVISION_MISMATCH' | 'MATCH_NOT_FOUND' | 'AMBIGUOUS_MATCH' | 'STYLE_CONFLICT' | 'PRECONDITION_FAILED' | 'COMMENT_CASCADE_PARTIAL' | 'INVALID_INPUT' | 'CROSS_BLOCK_MATCH' | 'SPAN_FRAGMENTED' | 'TARGET_MOVED' | 'PLAN_CONFLICT_OVERLAP' | 'INVALID_STEP_COMBINATION' | 'REVISION_CHANGED_SINCE_COMPILE' | 'INVALID_INSERTION_CONTEXT' | 'DOCUMENT_IDENTITY_CONFLICT' | 'UNSUPPORTED_ENVIRONMENT' | 'INTERNAL_ERROR' | 'PAGE_NUMBERS_NOT_MATERIALIZED' | 'INCOMPATIBLE_DEFINITIONS' | 'NO_COMPATIBLE_PREVIOUS' | 'ALREADY_CONTINUOUS' | 'NO_PREVIOUS_LIST' | 'NO_ADJACENT_SEQUENCE' | 'ALREADY_SAME_SEQUENCE' | 'LEVEL_OUT_OF_RANGE' | 'LEVEL_NOT_FOUND' | 'INVALID_NESTING' | 'INVALID_PLACEMENT' | 'EMPTY_FRAGMENT' | 'INVALID_FRAGMENT' | 'INVALID_PAYLOAD' | 'CAPABILITY_UNSUPPORTED' | 'ADDRESS_STALE' | 'DUPLICATE_ID' | 'INVALID_CONTEXT' | 'RAW_MODE_REQUIRED' | 'PRESERVE_ONLY_VIOLATION' | 'LOCK_VIOLATION' | 'TYPE_MISMATCH' | 'UNSUPPORTED_SOURCE' | 'INVALID_PACKAGE' | 'UNSUPPORTED_TEMPLATE_CONTENT';
12
+ export type ReceiptFailureCode = 'NO_OP' | 'INVALID_TARGET' | 'TARGET_NOT_FOUND' | 'CAPABILITY_UNAVAILABLE' | 'PERMISSION_DENIED' | 'STALE_REVISION' | 'REVISION_MISMATCH' | 'CHECK_MISMATCH' | 'MATCH_NOT_FOUND' | 'AMBIGUOUS_MATCH' | 'STYLE_CONFLICT' | 'PRECONDITION_FAILED' | 'COMMENT_CASCADE_PARTIAL' | 'INVALID_INPUT' | 'CROSS_BLOCK_MATCH' | 'SPAN_FRAGMENTED' | 'TARGET_MOVED' | 'PLAN_CONFLICT_OVERLAP' | 'INVALID_STEP_COMBINATION' | 'REVISION_CHANGED_SINCE_COMPILE' | 'INVALID_INSERTION_CONTEXT' | 'DOCUMENT_IDENTITY_CONFLICT' | 'UNSUPPORTED_ENVIRONMENT' | 'INTERNAL_ERROR' | 'PAGE_NUMBERS_NOT_MATERIALIZED' | 'INCOMPATIBLE_DEFINITIONS' | 'NO_COMPATIBLE_PREVIOUS' | 'ALREADY_CONTINUOUS' | 'NO_PREVIOUS_LIST' | 'NO_ADJACENT_SEQUENCE' | 'ALREADY_SAME_SEQUENCE' | 'LEVEL_OUT_OF_RANGE' | 'LEVEL_NOT_FOUND' | 'INVALID_NESTING' | 'INVALID_PLACEMENT' | 'EMPTY_FRAGMENT' | 'INVALID_FRAGMENT' | 'INVALID_PAYLOAD' | 'CAPABILITY_UNSUPPORTED' | 'ADDRESS_STALE' | 'DUPLICATE_ID' | 'INVALID_CONTEXT' | 'RAW_MODE_REQUIRED' | 'PRESERVE_ONLY_VIOLATION' | 'LOCK_VIOLATION' | 'TYPE_MISMATCH' | 'UNSUPPORTED_SOURCE' | 'INVALID_PACKAGE' | 'UNSUPPORTED_TEMPLATE_CONTENT';
13
13
  export type ReceiptFailure = {
14
14
  code: ReceiptFailureCode;
15
15
  message: string;
@@ -1,13 +1,16 @@
1
1
  import { BlockNodeAddress } from './base.js';
2
2
  import { SelectionTarget, TextAddress } from './address.js';
3
3
  import { ReceiptEffects, ReceiptSuccess, TextMutationRange } from './receipt.js';
4
- export type SDErrorCode = 'INVALID_PAYLOAD' | 'INVALID_TARGET' | 'TARGET_NOT_FOUND' | 'ADDRESS_STALE' | 'PRECONDITION_FAILED' | 'REVISION_MISMATCH' | 'INVALID_CONTEXT' | 'INVALID_NESTING' | 'INVALID_PLACEMENT' | 'DUPLICATE_ID' | 'CAPABILITY_UNSUPPORTED' | 'RAW_MODE_REQUIRED' | 'PRESERVE_ONLY_VIOLATION' | 'NO_OP' | 'UNSUPPORTED_ENVIRONMENT' | 'INTERNAL_ERROR';
4
+ import { BodyStoryLocator } from './story.types.js';
5
+ export type SDErrorCode = 'INVALID_PAYLOAD' | 'INVALID_TARGET' | 'TARGET_NOT_FOUND' | 'ADDRESS_STALE' | 'PRECONDITION_FAILED' | 'REVISION_MISMATCH' | 'CHECK_MISMATCH' | 'INVALID_CONTEXT' | 'INVALID_NESTING' | 'INVALID_PLACEMENT' | 'DUPLICATE_ID' | 'CAPABILITY_UNSUPPORTED' | 'RAW_MODE_REQUIRED' | 'PRESERVE_ONLY_VIOLATION' | 'NO_OP' | 'UNSUPPORTED_ENVIRONMENT' | 'INTERNAL_ERROR';
6
+ export declare const SD_HTML_MARKDOWN_OUTCOMES: readonly ["preserved", "preserved-with-warnings", "simplified", "rejected", "no-op", "invalid-target", "outdated"];
7
+ export type SDHtmlMarkdownOutcome = (typeof SD_HTML_MARKDOWN_OUTCOMES)[number];
5
8
  export interface SDError {
6
9
  code: SDErrorCode;
7
10
  message: string;
8
11
  path?: Array<string | number>;
9
12
  /** The target that caused the error, when available. */
10
- target?: BlockNodeAddress | TextAddress | SelectionTarget;
13
+ target?: BlockNodeAddress | TextAddress | SelectionTarget | BodyStoryLocator;
11
14
  details?: Record<string, unknown>;
12
15
  }
13
16
  /**
@@ -15,10 +18,13 @@ export interface SDError {
15
18
  *
16
19
  * - `TextAddress` (`kind: 'text'`): text-level insert/replace with block-relative offsets.
17
20
  * - `BlockNodeAddress` (`kind: 'block'`): structural insert/replace targeting a whole block.
21
+ * - `BodyStoryLocator` (`kind: 'story'`): explicit complete-main-body replacement.
18
22
  */
19
- export type MutationResolutionTarget = TextAddress | BlockNodeAddress;
23
+ export type MutationResolutionTarget = TextAddress | BlockNodeAddress | BodyStoryLocator;
20
24
  export interface SDMutationReceipt {
21
25
  success: boolean;
26
+ /** Rich HTML/Markdown fidelity outcome, when this receipt came from a rich write. */
27
+ outcome?: SDHtmlMarkdownOutcome;
22
28
  failure?: SDError;
23
29
  evaluatedRevision?: {
24
30
  before: string;
@@ -2,7 +2,7 @@ import { BlockNodeAddress } from './base.js';
2
2
  import { SelectionTarget } from './address.js';
3
3
  import { SDFragment } from './fragment.js';
4
4
  import { Placement, NestingPolicy } from './placement.js';
5
- import { StoryLocator } from './story.types.js';
5
+ import { BodyStoryLocator, StoryLocator } from './story.types.js';
6
6
  /** Structural shape for the insert operation. */
7
7
  export interface SDInsertInput {
8
8
  /** Optional insertion target. When omitted, inserts at the end of the document. */
@@ -27,14 +27,29 @@ type StructuralReplaceLocator = {
27
27
  ref: string;
28
28
  /** Target to replace. BlockNodeAddress replaces the entire block; SelectionTarget replaces a contiguous selection. */
29
29
  target?: undefined;
30
+ } | {
31
+ /** Replace the complete main body while preserving the destination DOCX package. */
32
+ target: BodyStoryLocator;
33
+ ref?: undefined;
30
34
  };
31
- /** Structural shape for the replace operation. */
32
- export type SDReplaceInput = StructuralReplaceLocator & {
35
+ type StructuralReplaceContent = {
33
36
  /** Structural content to replace with. */
34
37
  content: SDFragment;
38
+ };
39
+ /** Structural shape for the replace operation. */
40
+ export type SDReplaceInput = (Exclude<StructuralReplaceLocator, {
41
+ target: BodyStoryLocator;
42
+ }> & StructuralReplaceContent & {
35
43
  /** Target a specific document story (body, header, footer, footnote, endnote). */
36
44
  in?: StoryLocator;
37
45
  /** Nesting policy. Defaults to { tables: 'forbid' }. */
38
46
  nestingPolicy?: NestingPolicy;
47
+ }) | {
48
+ /** Replace the complete main body while preserving the destination DOCX package. */
49
+ target: BodyStoryLocator;
50
+ content: SDFragment;
51
+ ref?: never;
52
+ in?: never;
53
+ nestingPolicy?: never;
39
54
  };
40
55
  export {};