/** * Slate.js utility functions for PureRichText */ import { Editor, Descendant } from 'slate'; import { TextAlign, MarkType } from '../types'; /** * True when content overflows its in-widget scroll container. Gates the click-to-end-of- * content caret jump: harmless when everything fits, disorienting when scrollable. */ export declare function editorContentOverflows(editableEl: HTMLElement | null): boolean; /** * Scroll the caret into view within the editor's own scroll container only. Replaces * slate-react's default, which walks ancestors to the page and scrolls the whole dashboard * on programmatic selection changes; bounding it stops the "page jumps around" behavior. */ export declare function scrollCaretWithinEditor(editor: Editor, domRange: globalThis.Range): void; /** * Select the end of the document, silently catching errors from empty/invalid content. */ export declare function safeSelectEnd(editor: Editor): void; /** * Focus the framework's select-outline so Escape/Cmd+A keyboard nav keeps a target, * suppressing the native focus ring (a doubled border over the framework's outline). */ export declare function focusSelectOutline(fromEl: HTMLElement | null | undefined): void; /** * Deselect the editor, silently catching errors from stale selection state. */ export declare function safeDeselect(editor: Editor): void; export declare function isMarkActive(editor: Editor, format: MarkType): boolean; export declare function toggleMark(editor: Editor, format: MarkType): void; export declare function getBlockAlignment(editor: Editor): TextAlign; /** * Toggle alignment for current block * For lists, apply alignment to list items rather than the list container */ export declare function toggleAlignment(editor: Editor, align: TextAlign): void; export declare function getBlockLineHeight(editor: Editor): string; /** * Set line height for current block(s) * Applies to all paragraphs that contain any part of the selection */ export declare function setBlockLineHeight(editor: Editor, lineHeight: string): void; /** * Check if currently in a list */ export declare function isListActive(editor: Editor, listType: 'bulleted-list' | 'numbered-list'): boolean; export declare function toggleList(editor: Editor, listType: 'bulleted-list' | 'numbered-list'): void; export declare function getListType(editor: Editor): 'unordered' | 'ordered' | null; export declare function isLinkActive(editor: Editor): boolean; export declare function getSelectedText(editor: Editor): string; export declare function getActiveLink(editor: Editor): { url: string; text: string; } | null; /** * Extract plain text from a Slate node tree. Used for screenreader content. */ export declare function slateToPlainText(nodes: Descendant[]): string; /** * Replace `$token$` patterns in a link URL with resolved values. The token pipeline only * rewrites text nodes, not `url` attributes, so an href stays literally `$token$`; resolve * it here or the browser treats `$url$` as a relative path. */ export declare function resolveUrlTokens(url: string, nameToValue?: Map): string; /** * Resolve a link URL to a browser href: resolve $token$ then normalize. Schemed values * are kept; a bare domain gets https:// so it doesn't open relative to the current page. */ export declare function resolveLinkHref(url: string, nameToValue?: Map): string; export declare function isOpenableUrl(value: string): boolean; export declare function normalizeUrl(url: string): string; /** * Insert or update a link */ export declare function insertLink(editor: Editor, url: string, text?: string): void; /** * Remove link */ export declare function unwrapLink(editor: Editor): void; /** * Get current text styles at cursor/selection */ export declare function getCurrentStyles(editor: Editor): { bold: boolean; italic: boolean; underline: boolean; strikethrough: boolean; color: string | null; backgroundColor: string | null; fontSize: string | null; fontFamily: string | null; textAlign: TextAlign; lineHeight: string | null; listType: 'unordered' | 'ordered' | null; isMixed?: { color?: boolean; backgroundColor?: boolean; fontSize?: boolean; fontFamily?: boolean; lineHeight?: boolean; }; }; /** * Convert Slate value to HTML */ export declare function slateToHtml(value: Descendant[]): string; /** * Convert HTML to Slate value * * Note: This is a simplified parser. Complex HTML from other approaches may not * render exactly the same due to Slate's block/inline model differences. */ export declare function htmlToSlate(html: string): Descendant[]; /** * Normalize color to hex format */ export declare function normalizeColor(color: string | null | undefined): string | null; /** * Parse padding value to array format [top, right, bottom, left] */ export declare function parsePadding(padding: number | [number, number] | [number, number, number, number] | undefined): [number, number, number, number]; //# sourceMappingURL=slateUtils.d.ts.map