import { type Editor, Node } from '@tiptap/core'; import { type Node as ProseMirrorNode } from '@tiptap/pm/model'; /** * The deliberately small content-control surface exposed by Writer. * * Repeating sections use a dedicated block model. Picture controls and other * active form semantics beyond the bounded checkbox, drop-down list, combo * box, date, and passive custom-XML data-binding slices are intentionally not * represented here. A control is an inline, editable container whose metadata * can round-trip to a passive Word `w:sdt`. */ export type WorkDocumentContentControlType = 'text' | 'richText' | 'checkbox' | 'dropDownList' | 'comboBox' | 'date'; export type WorkDocumentContentControlLock = 'unlocked' | 'contentLocked' | 'sdtLocked' | 'sdtContentLocked'; export type WorkDocumentContentControlAppearance = 'boundingBox' | 'hidden' | 'tags'; export type WorkDocumentContentControlDateMapping = 'date' | 'dateTime' | 'text'; export interface WorkDocumentContentControlListItem { displayText: string; value: string; } export interface WorkDocumentContentControlProperties { id: string; nativeId: number | null; type: WorkDocumentContentControlType; alias: string; tag: string; lock: WorkDocumentContentControlLock; multiLine: boolean; appearance: WorkDocumentContentControlAppearance; color: string | null; /** Checked state for `checkbox` controls; ignored otherwise. */ checked: boolean; /** Ordered list items for `dropDownList` and `comboBox` controls. */ options: WorkDocumentContentControlListItem[]; /** * Selected option value for `dropDownList` and `comboBox` controls. * Combo boxes may leave this empty when the visible text is free-form. */ selectedValue: string; /** Last known date for `date` controls (`xsd:dateTime`, UTC). */ fullDate: string; /** Display mask for `date` controls (Word `w:dateFormat`). */ dateFormat: string; /** Language id for `date` controls (Word `w:lid`). */ dateLanguage: string; /** Custom-XML mapping hint for `date` controls (Word `w:storeMappedDataAs`). */ dateMapping: WorkDocumentContentControlDateMapping; /** * Passive `w:dataBinding` store item GUID when present. Empty means unbound. * Live custom-XML sync stays host-owned; Writer only round-trips metadata. */ bindingStoreItemId: string; /** Absolute XPath for `w:dataBinding`; required when a store item id is set. */ bindingXPath: string; /** Optional `w:prefixMappings` for the binding XPath namespaces. */ bindingPrefixMappings: string; } /** Ballot-box glyphs used for bounded checkbox display and DOCX export. */ export declare const DOCUMENT_CONTENT_CONTROL_CHECKBOX_UNCHECKED = "\u2610"; export declare const DOCUMENT_CONTENT_CONTROL_CHECKBOX_CHECKED = "\u2611"; export declare const DOCUMENT_CONTENT_CONTROL_MAX_LIST_ITEMS = 32; export declare const DOCUMENT_CONTENT_CONTROL_DEFAULT_DATE_FORMAT = "yyyy\u5E74M\u6708d\u65E5"; export declare const DOCUMENT_CONTENT_CONTROL_DEFAULT_DATE_LANGUAGE = "zh-CN"; export declare const DOCUMENT_CONTENT_CONTROL_DATE_FORMATS: readonly ["yyyy年M月d日", "yyyy-MM-dd", "MMMM d, yyyy", "dddd, MMMM d, yyyy"]; export interface DocumentContentControlInsertOptions extends Partial { /** Initial plain text for an empty selection. */ text?: string; } export interface DocumentContentControlCommandOptions { restoreFocus?: boolean; /** Explicitly permits deleting a control whose `w:sdt` is locked. */ allowLocked?: boolean; } export interface SelectedDocumentContentControl { node: ProseMirrorNode; position: number; } declare module '@tiptap/core' { interface Commands { documentContentControl: { insertDocumentContentControl: (options?: DocumentContentControlInsertOptions) => ReturnType; setDocumentContentControlProperties: (value: Partial, options?: DocumentContentControlCommandOptions) => ReturnType; deleteDocumentContentControl: (options?: DocumentContentControlCommandOptions) => ReturnType; }; } } export declare const DOCUMENT_CONTENT_CONTROL_DEFAULTS: WorkDocumentContentControlProperties; /** Transaction meta used by the typed commands to cross the lock guard. */ export declare const DOCUMENT_CONTENT_CONTROL_MUTATION_META = "documentContentControlMutation"; export declare const DocumentContentControl: Node; export declare function documentContentControlProperties(editor: Editor): WorkDocumentContentControlProperties; export declare function setDocumentContentControlProperties(editor: Editor, value: Partial, options?: DocumentContentControlCommandOptions): boolean; export declare function selectedDocumentContentControl(stateOrEditor: Editor | Editor['state']): SelectedDocumentContentControl | null; export declare function normalizeDocumentContentControlProperties(value: Partial>): WorkDocumentContentControlProperties; export declare function isListStyleContentControl(type: WorkDocumentContentControlType | unknown): type is 'comboBox' | 'dropDownList'; export declare function isStructuredFormContentControl(type: WorkDocumentContentControlType | unknown): type is 'checkbox' | 'comboBox' | 'date' | 'dropDownList'; export declare function documentContentControlCheckboxGlyph(checked: boolean): string; export declare function documentContentControlDropDownDisplay(properties: Pick): string; export declare function documentContentControlDateDisplay(properties: Pick): string; export declare function contentControlDateInputValue(fullDate: string): string; export declare function contentControlFullDateFromInput(value: string): string; export declare function contentControlLocksContent(value: WorkDocumentContentControlLock | unknown): boolean; export declare function contentControlLocksShell(value: WorkDocumentContentControlLock | unknown): boolean; export declare function contentControlCss(value: Partial>): string; export declare function contentControlDomAttributes(value: Partial>): Record; export declare function documentContentControlPropertiesFromElement(element: Element): WorkDocumentContentControlProperties;