export type WorkDocumentFieldKind = 'page' | 'numPages' | 'section' | 'sectionPages' | 'date' | 'time' | 'wordCount' | 'characterCount' | 'pageReference'; export interface WorkDocumentFieldContext { pageNumber: number; totalPages: number; sectionNumber: number; sectionPages: number; /** Number of visible body words, excluding generated field results. */ wordCount?: number; /** Number of visible body characters, including spaces. */ characterCount?: number; /** Page number resolved for a PAGEREF target, when the target is present. */ referencePageNumber?: number | null; /** Page numbers keyed by `id:` or `name:`. */ bookmarkPageNumbers?: ReadonlyMap; now?: Date; } export type WorkDocumentFieldContextResolver = (position: number) => WorkDocumentFieldContext | null; export interface WorkDocumentFieldRefreshOptions { resolveContext?: WorkDocumentFieldContextResolver; now?: Date; addToHistory?: boolean; updateClock?: boolean; } export interface WorkDocumentFieldInsertOptions { /** Bookmark identity used to keep a page reference stable across renames. */ targetId?: string; /** Bookmark name emitted in the native PAGEREF instruction. */ targetName?: string; /** Typed numeric or date/time format selected by the field authoring UI. */ format?: WorkDocumentFieldFormat; /** Preserve the native MERGEFORMAT switch when editing an imported field. */ mergeFormat?: boolean; /** Add the native PAGEREF hyperlink switch. */ hyperlink?: boolean; } export interface WorkDocumentFieldDraft { kind: WorkDocumentFieldKind; format: WorkDocumentFieldFormat; targetId: string; targetName: string; hyperlink: boolean; mergeFormat: boolean; } export type WorkDocumentNumericFieldFormat = 'arabic' | 'roman' | 'romanLower' | 'alphabetic' | 'alphabeticLower' | 'ordinal'; export type WorkDocumentClockFieldFormat = 'yyyy年M月d日' | 'yyyy-MM-dd' | 'MMMM d, yyyy' | 'dddd, MMMM d, yyyy' | 'HH:mm' | 'HH:mm:ss' | 'h:mm AM/PM'; export type WorkDocumentFieldFormat = { kind: 'none'; } | { kind: 'numeric'; value: WorkDocumentNumericFieldFormat; } | { kind: 'clock'; value: WorkDocumentClockFieldFormat; /** A native format outside the bounded picker, retained until changed. */ source?: string; }; export declare function documentFieldKind(value: string | undefined): WorkDocumentFieldKind | null; export declare function docxDocumentFieldKind(instruction: string): WorkDocumentFieldKind | null; export declare function documentFieldInstruction(kind: WorkDocumentFieldKind, options?: WorkDocumentFieldInsertOptions): string; export declare function documentFieldDraftFromAttributes(attributes: { kind?: unknown; instruction?: unknown; targetId?: unknown; targetName?: unknown; }): WorkDocumentFieldDraft | null; export declare function documentFieldOptionsFromDraft(draft: WorkDocumentFieldDraft): WorkDocumentFieldInsertOptions; /** Builds a stable PAGEREF instruction while retaining the supported switches. */ export declare function documentPageReferenceInstruction(targetName: unknown, source?: string, defaultHyperlink?: boolean): string; export declare function documentFieldLabel(kind: WorkDocumentFieldKind): string; /** WPS/Word-style field-code text shown when "切换域代码" is active. */ export declare function documentFieldCodeDisplay(instruction: string): string; export declare function documentFieldDisplay(kind: WorkDocumentFieldKind, context: WorkDocumentFieldContext, instruction?: string, cachedValue?: string): string; export declare function normalizeDocumentFieldsHtml(source: string): string; export declare function resolveDocumentFieldsHtml(source: string, context: WorkDocumentFieldContext): string; /** Returns the bookmark name used by a bounded PAGEREF instruction. */ export declare function docxDocumentFieldTarget(instruction: string): string | null; /** * The editor intentionally accepts only switches whose result can be * represented by one deterministic inline atom. Unknown switches remain * cached text instead of being presented as an editable field with altered * semantics. */ export declare function supportedDocxDocumentFieldInstruction(instruction: string): boolean; /** Returns the supported numeric display switch, preserving its source case. */ export declare function numericFieldFormatSwitch(source: string): string | null; export declare function documentFieldStatisticsFromText(source: string): { wordCount: number; characterCount: number; }; /** Computes bounded body statistics while excluding generated field results. */ export declare function documentFieldStatisticsFromHtml(source: string): { wordCount: number; characterCount: number; };