import { Value } from 'platejs'; import { WordCountResult, OutlineItem, EditorMode, TocPosition } from '../types/editor-types'; /** * 历史记录状态 */ interface HistoryState { canUndo: boolean; canRedo: boolean; historyLength: number; } /** * 工具栏状态 */ interface ToolbarState { visible: boolean; sticky: boolean; fullWidth: boolean; } /** * 选中状态 */ interface SelectionState { hasSelection: boolean; isCollapsed: boolean; selectedText: string; } /** * 保存状态 */ interface SaveState { isSaving: boolean; lastSavedAt: number | null; hasUnsavedChanges: boolean; } /** * 编辑器全局状态 */ interface EditorState { content: Value | null; setContent: (content: Value) => void; isModified: boolean; setIsModified: (isModified: boolean) => void; mode: EditorMode; setMode: (mode: EditorMode) => void; isFullscreen: boolean; setIsFullscreen: (isFullscreen: boolean) => void; isFocused: boolean; setIsFocused: (focused: boolean) => void; isReadOnly: boolean; setIsReadOnly: (readOnly: boolean) => void; toolbar: ToolbarState; setToolbarVisible: (visible: boolean) => void; setToolbarSticky: (sticky: boolean) => void; setToolbarFullWidth: (fullWidth: boolean) => void; selection: SelectionState; setSelection: (selection: Partial) => void; saveState: SaveState; setSaving: (isSaving: boolean) => void; setLastSavedAt: (timestamp: number | null) => void; setHasUnsavedChanges: (hasChanges: boolean) => void; history: HistoryState; setHistory: (history: Partial) => void; wordCount: WordCountResult | null; setWordCount: (wordCount: WordCountResult | null) => void; outline: OutlineItem[]; setOutline: (outline: OutlineItem[]) => void; tocVisible: boolean; setTocVisible: (visible: boolean) => void; tocPosition: TocPosition; setTocPosition: (pos: TocPosition) => void; tocWidth: string; setTocWidth: (w: string) => void; reset: () => void; batchUpdate: (updates: Partial>) => void; } export declare const useEditorStore: import('zustand').UseBoundStore, "subscribe"> & { subscribe: { (listener: (selectedState: EditorState, previousSelectedState: EditorState) => void): () => void; (selector: (state: EditorState) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: { equalityFn?: ((a: U, b: U) => boolean) | undefined; fireImmediately?: boolean; } | undefined): () => void; }; }, "setState" | "persist"> & { setState(partial: EditorState | Partial | ((state: EditorState) => EditorState | Partial), replace?: false | undefined): unknown; setState(state: EditorState | ((state: EditorState) => EditorState), replace: true): unknown; persist: { setOptions: (options: Partial>) => void; clearStorage: () => void; rehydrate: () => Promise | void; hasHydrated: () => boolean; onHydrate: (fn: (state: EditorState) => void) => () => void; onFinishHydration: (fn: (state: EditorState) => void) => () => void; getOptions: () => Partial>; }; }>; /** * 选择器:获取编辑器是否可编辑 */ export declare const selectIsEditable: (state: EditorState) => boolean; /** * 选择器:获取保存状态摘要 */ export declare const selectSaveStatus: (state: EditorState) => "saving" | "unsaved" | "saved" | "idle"; /** * 选择器:获取文档统计信息 */ export declare const selectDocumentStats: (state: EditorState) => { wordCount: WordCountResult | null; outline: OutlineItem[]; isModified: boolean; }; /** * 选择器:获取工具栏配置 */ export declare const selectToolbarConfig: (state: EditorState) => { visible: boolean; sticky: boolean; fullWidth: boolean; }; /** * 选择器:获取目录配置 */ export declare const selectTocConfig: (state: EditorState) => { visible: boolean; position: TocPosition; width: string; }; /** * 选择器:获取编辑器 UI 状态 */ export declare const selectUIState: (state: EditorState) => { isFullscreen: boolean; isFocused: boolean; isReadOnly: boolean; mode: EditorMode; }; /** * 选择器:获取选中状态 */ export declare const selectSelectionState: (state: EditorState) => SelectionState; /** * 选择器:获取历史记录状态 */ export declare const selectHistoryState: (state: EditorState) => HistoryState; /** * 选择器:检查是否有内容 */ export declare const selectHasContent: (state: EditorState) => boolean; /** * 选择器:获取大纲标题数量 */ export declare const selectOutlineCount: (state: EditorState) => number; /** * 选择器:获取保存时间的格式化字符串 */ export declare const selectLastSavedAtFormatted: (state: EditorState) => string | null; /** * 选择器:获取字数(简化) */ export declare const selectWordCountSimple: (state: EditorState) => number; /** * Hook: 使用编辑器可编辑状态 */ export declare function useIsEditable(): boolean; /** * Hook: 使用保存状态 */ export declare function useSaveStatus(): 'saving' | 'unsaved' | 'saved' | 'idle'; /** * Hook: 使用文档统计 */ export declare function useDocumentStats(): { wordCount: WordCountResult | null; outline: OutlineItem[]; isModified: boolean; }; /** * Hook: 使用工具栏配置 */ export declare function useToolbarConfig(): { visible: boolean; sticky: boolean; fullWidth: boolean; }; /** * Hook: 使用目录配置 */ export declare function useTocConfig(): { visible: boolean; position: TocPosition; width: string; }; /** * Hook: 使用 UI 状态 */ export declare function useUIState(): { isFullscreen: boolean; isFocused: boolean; isReadOnly: boolean; mode: EditorMode; }; /** * 创建独立的 store 实例(用于多编辑器场景) */ export declare function createEditorStore(): import('zustand').UseBoundStore, "subscribe"> & { subscribe: { (listener: (selectedState: EditorState, previousSelectedState: EditorState) => void): () => void; (selector: (state: EditorState) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: { equalityFn?: ((a: U, b: U) => boolean) | undefined; fireImmediately?: boolean; } | undefined): () => void; }; }>; export {};