UNPKG

@lobehub/editor

Version:

A powerful and extensible rich text editor built on Meta's Lexical framework, providing a modern editing experience with React integration.

69 lines (68 loc) 2.32 kB
import { IEditor } from "../../../types"; /** * Editor state and toolbar methods return type */ export interface EditorState { /** Current block type (e.g., 'paragraph', 'h1', 'h2', 'bullet', 'number', 'code') */ blockType: string | null; /** Format selection as blockquote */ blockquote: () => void; /** Toggle bold formatting */ bold: () => void; /** Toggle bullet list */ bulletList: () => void; /** Whether redo operation is available */ canRedo: boolean; /** Whether undo operation is available */ canUndo: boolean; /** Toggle check list */ checkList: () => void; /** Toggle code formatting */ code: () => void; /** Format selection as code block */ codeblock: () => void; /** Current code block language */ codeblockLang: string | null | undefined; /** Insert or toggle link */ insertLink: () => void; /** Insert math (inline or block based on context) */ insertMath: () => void; /** Whether cursor is inside a blockquote */ isBlockquote: boolean; /** Whether selection has bold formatting */ isBold: boolean; /** Whether selection has code formatting */ isCode: boolean; /** Whether cursor is inside a code block */ isCodeblock: boolean; /** Whether editor content is empty */ isEmpty: boolean; /** Whether selection has italic formatting */ isItalic: boolean; /** Whether editor has selection */ isSelected: boolean; /** Whether selection has strikethrough formatting */ isStrikethrough: boolean; /** Whether selection has underline formatting */ isUnderline: boolean; /** Toggle italic formatting */ italic: () => void; /** Toggle numbered list */ numberList: () => void; /** Redo last operation */ redo: () => void; /** Toggle strikethrough formatting */ strikethrough: () => void; /** Toggle underline formatting */ underline: () => void; /** Undo last operation */ undo: () => void; /** Update code block language */ updateCodeblockLang: (lang: string) => void; } /** * Provide toolbar state and toolbar methods * @param editor - Editor instance * @returns Editor state and methods for toolbar functionality */ export declare function useEditorState(editor?: IEditor): EditorState;