import { SelectionTarget } from '../types/address.js'; import { StoryLocator } from '../types/story.types.js'; import { InlineRunPatch, InlineRunPatchKey } from './inline-run-patch.js'; /** `effective` resolves the style cascade; `direct` reads only run-level `w:rPr`. */ export type InlineReadView = 'effective' | 'direct'; /** Per-slot state for object-valued keys (`rFonts`, `lang`, `underline`, ...). */ export type InlineReadSlotState = { state: 'uniform'; value: unknown; } | { state: 'mixed'; } | { state: 'unset'; } | { state: 'unresolvable'; reason: string; }; /** Read state for one inline key across the selection. */ export type InlineReadState = { state: 'uniform'; value: InlineRunPatch[K]; } /** `slots` is present only for object-valued keys whose slots disagree. */ | { state: 'mixed'; slots?: Record; } /** Direct view only: no selected run sets the key directly. */ | { state: 'unset'; } | { state: 'unresolvable'; reason: string; }; /** * Input payload for `format.readSelection`. * * Provide exactly one locator: `target`, `ref`, or `selection: 'current'` (the * live editor selection, including pending caret formatting). */ export interface FormatReadSelectionInput { target?: SelectionTarget; ref?: string; selection?: 'current'; /** Keys to read; defaults to every `format.apply` key. */ keys?: readonly InlineRunPatchKey[]; /** Defaults to `effective`. */ view?: InlineReadView; in?: StoryLocator; } /** Normalized adapter request: exactly one locator, explicit keys and view. */ export type FormatReadSelectionRequest = ({ target: SelectionTarget; } | { ref: string; } | { selection: 'current'; }) & { keys: InlineRunPatchKey[]; view: InlineReadView; in?: StoryLocator; }; export interface FormatReadSelectionResult { /** True when the selection is a caret. */ collapsed: boolean; /** True when pending caret formatting (toggled, not yet typed) was included. */ pendingApplied?: boolean; /** Exactly the requested keys. */ properties: { [K in InlineRunPatchKey]?: InlineReadState; }; } export interface FormatReadSelectionAdapter { readSelection(request: FormatReadSelectionRequest): Promise; } /** * Executes `format.readSelection`. Validation failures reject before the * adapter is called. */ export declare function executeFormatReadSelection(adapter: Partial | undefined, input: FormatReadSelectionInput): Promise;