import { OoxmlContentSource } from '../selection/selection.types.js'; import { RichContentMutationOptions, TextMutationOptions, TrackedRichContentMutationOptions, WriteAdapter } from '../write/write.js'; import { SelectionTarget } from '../types/address.js'; import { SDMutationReceipt } from '../types/sd-contract.js'; import { SDReplaceInput } from '../types/structural-input.js'; import { BodyStoryLocator, StoryLocator } from '../types/story.types.js'; import { BlockNodeAddress } from '../types/base.js'; import { NestingPolicy } from '../types/placement.js'; import { SelectionMutationAdapter } from '../selection-mutation.js'; export declare const TEXT_REPLACEMENT_GRANULARITIES: readonly ["word", "phrase", "range"]; export type TextReplacementGranularity = (typeof TEXT_REPLACEMENT_GRANULARITIES)[number]; export declare function isTextReplacementGranularity(value: unknown): value is TextReplacementGranularity; export declare function isSingleParagraphVisibleTextSelection(target: unknown): target is SelectionTarget; /** Text replacement input: uses SelectionTarget / ref, or the complete main body. */ export type TextReplaceInput = { target: SelectionTarget; ref?: never; text: string; /** Require this exact selected text before replacing a single-paragraph text selection. */ expectedText?: string; replacementGranularity?: TextReplacementGranularity; /** Target a specific document story (body, header, footer, footnote, endnote). */ in?: StoryLocator; } | { ref: string; target?: never; text: string; expectedText?: never; replacementGranularity?: never; in?: StoryLocator; } | { target: BodyStoryLocator; text: string; expectedText?: never; replacementGranularity?: never; ref?: never; in?: never; }; /** HTML or Markdown replacement input for conversion and structured application. */ export type RichContentReplaceInput = { value: string; type: 'html' | 'markdown'; target?: SelectionTarget | BlockNodeAddress; ref?: string; in?: StoryLocator; nestingPolicy?: NestingPolicy; } | { value: string; type: 'html' | 'markdown'; target: BodyStoryLocator; ref?: never; in?: never; nestingPolicy?: never; }; /** * Input payload for the `doc.replace` operation. * * Discrimination: `text`, typed `value`, `content`, portable `capture`, or retained `snapshotId`. */ export type NativeOoxmlReplaceInput = OoxmlContentSource & { target: SelectionTarget | BlockNodeAddress; in?: StoryLocator; nestingPolicy?: NestingPolicy; }; export type SnapshotReplaceInput = { target: BlockNodeAddress; snapshotId: string; in?: never; }; export type ParagraphTextReplaceInput = { target: BlockNodeAddress; text: string; in?: never; }; export interface ReplaceMutationOptions extends RichContentMutationOptions { /** * Replace one paragraph's contents, retaining its identity and exact paragraph properties. * Plain text newlines (LF, CRLF, or CR) become inline line breaks; tabs become inline tabs. */ replaceMode?: 'contents'; /** Compare the addressed paragraph with an unchanged retained snapshot before committing. */ expectedSnapshotId?: string; } export type TrackedReplaceMutationOptions = TrackedRichContentMutationOptions & Pick; type ReplaceExecutionOptions = ReplaceMutationOptions | TrackedReplaceMutationOptions | (TextMutationOptions & { replaceMode?: never; expectedSnapshotId?: never; }); export type ReplaceInput = TextReplaceInput | RichContentReplaceInput | SDReplaceInput | NativeOoxmlReplaceInput | SnapshotReplaceInput | ParagraphTextReplaceInput; /** Returns true when the input uses the structural SDFragment shape. */ export declare function isStructuralReplaceInput(input: ReplaceInput): input is SDReplaceInput; export declare function isRichContentReplaceInput(input: ReplaceInput): input is RichContentReplaceInput; export declare function validateReplaceInput(input: unknown, options?: ReplaceExecutionOptions): asserts input is ReplaceInput; export declare function executeReplace(selectionAdapter: SelectionMutationAdapter, writeAdapter: WriteAdapter, input: ReplaceInput, options?: ReplaceExecutionOptions): SDMutationReceipt; export {};