UNPKG

@yoopta/editor

Version:

<h2 align="center">Yoopta-Editor v1 🎉</h2> <p align="center">Yoopta-Editor - is an open source notion-like editor 💥</p> <div align="center"> <img width="574" alt="Screen Shot 2023-01-25 at 16 04 29" src="https://user-images.githubusercontent.com/2909311

33 lines • 1.15 kB
import type { Range as SlateRange } from 'slate'; import type { YooEditor } from '../types'; export type ToDOMRangeOptions = { /** Block ID containing the Slate selection */ blockId: string; /** Slate Range to convert to a DOM Range */ slateRange: SlateRange; }; /** * Convert a Slate Range within a specific block to a native DOM Range. * * This method uses Slate's internal WeakMaps (via ReactEditor.toDOMRange) * which are only available inside @yoopta/editor where the Slate editors * are rendered. * * @param editor - YooEditor instance * @param options - Block ID and Slate range * @returns Native DOM Range or null if the range can't be resolved * * @example * ```typescript * const domRange = Selection.toDOMRange(editor, { * blockId: 'block-1', * slateRange: { anchor: { path: [0, 0], offset: 0 }, focus: { path: [0, 0], offset: 5 } }, * }); * * if (domRange) { * const rect = domRange.getBoundingClientRect(); * } * ``` */ export declare function toDOMRange(editor: YooEditor, options: ToDOMRangeOptions): Range | null; //# sourceMappingURL=toDOMRange.d.ts.map