import * as platejs0 from "platejs"; import { Editor, EditorPropOptions, NodeEntry, NodeProps, OmitFirst, Path, PluginConfig, SetNodesOptions, SlateEditor, TElement, TIdElement, TRange, TText, UnknownObject } from "platejs"; import * as platejs_react0 from "platejs/react"; import { EditableSiblingComponent, PlateEditor } from "platejs/react"; import React, { CSSProperties } from "react"; //#region src/react/BlockMenuPlugin.d.ts declare const BLOCK_CONTEXT_MENU_ID = "context"; type BlockMenuConfig = PluginConfig<'blockMenu', { openId: OpenId | null; position: { x: number; y: number; }; }, { blockMenu: { hide: () => void; show: (id: OpenId, position?: { x: number; y: number; }) => void; showContextMenu: (blockId: string, position: { x: number; y: number; }) => void; }; }>; type OpenId = (string & {}) | typeof BLOCK_CONTEXT_MENU_ID; declare const BlockMenuPlugin: platejs_react0.PlatePlugin void; show: (id: OpenId, position?: { x: number; y: number; }) => void; showContextMenu: (blockId: string, position: { x: number; y: number; }) => void; }; } & Record<"blockMenu", Partial<{ hide: () => void; show: (id: OpenId, position?: { x: number; y: number; }) => void; showContextMenu: (blockId: string, position: { x: number; y: number; }) => void; }>>, {}, {}>>; //#endregion //#region src/internal/utils/intersects.d.ts type Intersection = 'center' | 'cover' | 'touch'; //#endregion //#region src/internal/types.d.ts type Behaviour = { intersect: Intersection; overlap: OverlapMode; scrolling: Scrolling; startThreshold: Coordinates | number; triggers: Trigger[]; }; type Coordinates = { x: number; y: number; }; type DeepPartial = T extends unknown[] ? T : T extends HTMLElement ? T : { [P in keyof T]?: DeepPartial }; type Features = { range: boolean; singleTap: SingleTap; touch: boolean; }; type Modifier = 'alt' | 'ctrl' | 'shift'; type MouseButton = 0 | 1 | 2 | 3 | 4; type MouseButtonWithModifiers = { button: MouseButton; modifiers: Modifier[]; }; type OverlapMode = 'drop' | 'invert' | 'keep'; type PartialSelectionOptions = { document?: Document; } & DeepPartial>; type Quantify = T | T[]; type Scrolling = { manualSpeed: number; speedDivider: number; startScrollMargins: { x: number; y: number; }; }; type SelectionOptions = { behaviour: Behaviour; boundaries: Quantify; container: Quantify; document: Document; features: Features; selectables: Quantify; selectionAreaClass: string; startAreas: Quantify; }; type SingleTap = { allow: boolean; intersect: TapMode; }; type TapMode = 'native' | 'touch'; type Trigger = MouseButton | MouseButtonWithModifiers; //#endregion //#region src/react/hooks/useBlockSelectable.d.ts /** Add block selection when right click on a block. */ declare const addOnContextMenu: (editor: PlateEditor, { disabledWhenFocused, element, event }: { element: TElement; event: React.MouseEvent; disabledWhenFocused?: boolean; }) => void; declare const useBlockSelectable: () => { props: { className: string; onContextMenu: (event: React.MouseEvent) => void; } | { className?: undefined; onContextMenu?: undefined; }; }; //#endregion //#region src/react/internal/api/setSelectedIds.d.ts declare const setSelectedIds: (editor: SlateEditor, { added, ids, removed }: Partial<{ added: Element[]; removed: Element[]; }> & { ids?: string[]; }) => void; //#endregion //#region src/react/BlockSelectionPlugin.d.ts type BlockSelectionConfig = PluginConfig<'blockSelection', { anchorId?: string | null; areaOptions?: PartialSelectionOptions; editorPaddingRight?: CSSProperties['width']; enableContextMenu?: boolean; /** * Disable the plugin's custom selectAll (Cmd+A) behavior. * When true, uses the editor's default selectAll behavior. */ disableSelectAll?: boolean; isSelecting?: boolean; isSelectionAreaVisible?: boolean; rightSelectionAreaClassName?: string; selectedIds?: Set; shadowInputRef?: React.RefObject; /** Check if a block is selectable */ isSelectable?: (element: TElement, path: Path) => boolean; onKeyDownSelecting?: (editor: SlateEditor, e: KeyboardEvent) => void; }, { blockSelection: { /** Add block selection when right click on a block. */ addOnContextMenu: OmitFirst; /** Set selected block ids */ setSelectedIds: OmitFirst; /** Add a block to the selection. */ add: (id: string[] | string) => void; /** * Select a block by id, with optional delay and clear options. * * @deprecated Use `add` or `set` instead. */ addSelectedRow: (id: string, options?: { clear?: boolean; delay?: number; }) => void; /** Clear block selection */ clear: () => void; /** Delete a block from the selection. */ delete: (id: string[] | string) => void; /** Deselect all blocks */ deselect: () => void; /** Get the first selected block */ first: () => NodeEntry | null; /** Focus block selection – that differs from the editor focus */ focus: () => void; /** * Get selected blocks * * @param options.sort - Sort the nodes by path * @param options.collapseTableRows - If all table rows are selected, * return the table node with all selected rows instead, do not return * the table rows anymore. */ getNodes: (options?: { collapseTableRows?: boolean; /** * If no nodes are selected by blockSelection, use the editor's original * selection to get blocks */ selectionFallback?: boolean; sort?: boolean; }) => NodeEntry[]; /** Check if a block is selected. */ has: (id: string[] | string) => boolean; /** Check if a block is selectable. */ isSelectable: (element: TElement, path: Path) => boolean; /** Arrow-based move selection */ moveSelection: (direction: 'down' | 'up') => void; /** Reset selected block ids. @deprecated Use `clear` instead. */ resetSelectedIds: () => void; /** Select all selectable blocks */ selectAll: () => void; /** Set a block to be selected. */ set: (id: string[] | string) => void; /** Shift-based expand/shrink selection */ shiftSelection: (direction: 'down' | 'up') => void; /** Deselect all blocks. @deprecated Use `deselect` instead. */ unselect: () => void; }; }, {}, { /** Check if a block is selected by id */ isSelected?: (id?: string) => boolean; /** Check if any blocks are selected */ isSelectingSome?: () => boolean; }>; declare const BlockSelectionPlugin: platejs_react0.PlatePlugin; shadowInputRef?: React.RefObject; /** Check if a block is selectable */ isSelectable?: (element: TElement, path: Path) => boolean; onKeyDownSelecting?: (editor: SlateEditor, e: KeyboardEvent) => void; }, { blockSelection: { /** Add block selection when right click on a block. */ addOnContextMenu: OmitFirst; /** Set selected block ids */ setSelectedIds: OmitFirst; /** Add a block to the selection. */ add: (id: string[] | string) => void; /** * Select a block by id, with optional delay and clear options. * * @deprecated Use `add` or `set` instead. */ addSelectedRow: (id: string, options?: { clear?: boolean; delay?: number; }) => void; /** Clear block selection */ clear: () => void; /** Delete a block from the selection. */ delete: (id: string[] | string) => void; /** Deselect all blocks */ deselect: () => void; /** Get the first selected block */ first: () => NodeEntry | null; /** Focus block selection – that differs from the editor focus */ focus: () => void; /** * Get selected blocks * * @param options.sort - Sort the nodes by path * @param options.collapseTableRows - If all table rows are selected, * return the table node with all selected rows instead, do not return * the table rows anymore. */ getNodes: (options?: { collapseTableRows?: boolean; /** * If no nodes are selected by blockSelection, use the editor's original * selection to get blocks */ selectionFallback?: boolean; sort?: boolean; }) => NodeEntry[]; /** Check if a block is selected. */ has: (id: string[] | string) => boolean; /** Check if a block is selectable. */ isSelectable: (element: TElement, path: Path) => boolean; /** Arrow-based move selection */ moveSelection: (direction: "down" | "up") => void; /** Reset selected block ids. @deprecated Use `clear` instead. */ resetSelectedIds: () => void; /** Select all selectable blocks */ selectAll: () => void; /** Set a block to be selected. */ set: (id: string[] | string) => void; /** Shift-based expand/shrink selection */ shiftSelection: (direction: "down" | "up") => void; /** Deselect all blocks. @deprecated Use `deselect` instead. */ unselect: () => void; }; } & Record<"blockSelection", Partial<{ /** Add block selection when right click on a block. */ addOnContextMenu: OmitFirst; /** Set selected block ids */ setSelectedIds: OmitFirst; /** Add a block to the selection. */ add: (id: string[] | string) => void; /** * Select a block by id, with optional delay and clear options. * * @deprecated Use `add` or `set` instead. */ addSelectedRow: (id: string, options?: { clear?: boolean; delay?: number; }) => void; /** Clear block selection */ clear: () => void; /** Delete a block from the selection. */ delete: (id: string[] | string) => void; /** Deselect all blocks */ deselect: () => void; /** Get the first selected block */ first: () => NodeEntry | null; /** Focus block selection – that differs from the editor focus */ focus: () => void; /** * Get selected blocks * * @param options.sort - Sort the nodes by path * @param options.collapseTableRows - If all table rows are selected, * return the table node with all selected rows instead, do not return * the table rows anymore. */ getNodes: (options?: { collapseTableRows?: boolean; /** * If no nodes are selected by blockSelection, use the editor's original * selection to get blocks */ selectionFallback?: boolean; sort?: boolean; }) => NodeEntry[]; /** Check if a block is selected. */ has: (id: string[] | string) => boolean; /** Check if a block is selectable. */ isSelectable: (element: TElement, path: Path) => boolean; /** Arrow-based move selection */ moveSelection: (direction: "down" | "up") => void; /** Reset selected block ids. @deprecated Use `clear` instead. */ resetSelectedIds: () => void; /** Select all selectable blocks */ selectAll: () => void; /** Set a block to be selected. */ set: (id: string[] | string) => void; /** Shift-based expand/shrink selection */ shiftSelection: (direction: "down" | "up") => void; /** Deselect all blocks. @deprecated Use `deselect` instead. */ unselect: () => void; }>>, Record<"blockSelection", { /** Duplicate selected blocks */ duplicate: () => void; /** Insert blocks and select */ insertBlocksAndSelect: (nodes: TElement[], args_1: { at: Path; insertedCallback?: () => void; }) => void; /** Remove selected blocks */ removeNodes: () => void; /** Set selection based on block selection */ select: () => void; /** * Selects blocks in the editor based on the provided block ID. * * Uses block selection if any blocks are selected, otherwise falls back to * editor selection. If the provided block ID is already in the current * selection, maintains the existing selection. Otherwise, clears the * current selection and selects only the specified block. */ selectBlocks: (at: Path | platejs0.TNode) => void; /** Set block indent */ setIndent: (indent: number, options?: platejs0.SetNodesOptions | undefined) => void; /** Set nodes on selected blocks */ setNodes: (props: Partial>, options?: platejs0.SetNodesOptions | undefined) => void; /** Set texts on selected blocks */ setTexts: (props: Partial>, options?: Omit | undefined) => void; }>, { /** Check if a block is selected by id */ isSelected?: (id?: string) => boolean; /** Check if any blocks are selected */ isSelectingSome?: () => boolean; }>>; //#endregion //#region src/react/types.d.ts type CaretPosition = { height: number; left: number; top: number; }; type CursorData = { selectionStyle?: React.CSSProperties; style?: React.CSSProperties; }; interface CursorOverlayState> extends CursorState { caretPosition: CaretPosition | null; selectionRects: SelectionRect[]; } type CursorState = { id: any; selection: TRange | null; data?: TCursorData; }; type SelectionRect = { height: number; left: number; top: number; width: number; }; //#endregion //#region src/react/CursorOverlayPlugin.d.ts type CursorOverlayConfig = PluginConfig<'cursorOverlay', { cursors: Record>; }, { cursorOverlay: { addCursor: (id: string, cursor: Omit, 'id'>) => void; removeCursor: (id: (string & {}) | 'drag' | 'selection') => void; }; }>; declare const CursorOverlayPlugin: platejs_react0.PlatePlugin>; }, { cursorOverlay: { addCursor: (id: string, cursor: Omit, "id">) => void; removeCursor: (id: (string & {}) | "drag" | "selection") => void; }; } & Record<"cursorOverlay", { addCursor: (id: string, cursor: Omit, "id">) => void; removeCursor: (id: (string & {}) | "drag" | "selection") => void; }>, {}, {}>>; //#endregion //#region src/react/components/BlockSelectionAfterEditable.d.ts declare const BlockSelectionAfterEditable: EditableSiblingComponent; //#endregion //#region src/react/hooks/useBlockSelected.d.ts declare const useBlockSelected: (_id?: string) => any; //#endregion //#region src/react/hooks/useBlockSelectionNodes.d.ts declare function useBlockSelectionNodes(): platejs0.NodeEntry[]; declare function useBlockSelectionFragment(): TElement[]; declare function useBlockSelectionFragmentProp(options?: Omit): string | undefined; //#endregion //#region src/react/hooks/useCursorOverlay.d.ts type UseCursorOverlayOptions = { /** * Minimum width of a selection rect. * * @default 1 */ minSelectionWidth?: number; /** * Whether to refresh the cursor overlay positions on container resize. * * @default true */ refreshOnResize?: boolean; }; declare const FROZEN_EMPTY_ARRAY: SelectionRect[]; declare const useCursorOverlay: ({ minSelectionWidth, refreshOnResize }?: UseCursorOverlayOptions) => { cursors: CursorOverlayState[]; refresh: () => void; }; //#endregion //#region src/react/hooks/useIsSelecting.d.ts declare const isSelectingOrFocused: (editor: PlateEditor) => any; declare const useIsSelecting: () => any; //#endregion //#region src/react/hooks/useRefreshOnResize.d.ts type UseRefreshOnResizeOptions = { selectionRectCache: React.MutableRefObject>; containerRef?: React.RefObject; refreshOnResize?: boolean; }; declare const useRefreshOnResize: ({ containerRef, refreshOnResize, selectionRectCache }: UseRefreshOnResizeOptions) => { refresh: (sync?: boolean) => void; }; //#endregion //#region src/react/hooks/useRequestReRender.d.ts declare const useRequestReRender: () => (immediate?: boolean) => void; //#endregion //#region src/react/hooks/useSelectionArea.d.ts declare const useSelectionArea: () => void; //#endregion //#region src/react/queries/getCaretPosition.d.ts /** Get the caret position of a range from selectionRects. */ declare const getCaretPosition: (selectionRects: SelectionRect[], range: TRange) => CaretPosition | null; //#endregion //#region src/react/queries/getCursorOverlayState.d.ts /** Get cursor overlay state from selection rects. */ declare const getCursorOverlayState: ({ cursors: cursorStates, selectionRects }: { cursors: Record>; selectionRects: Record; }) => CursorOverlayState[]; //#endregion //#region src/react/queries/getSelectionRects.d.ts declare const getSelectionRects: (editor: Editor, { range, xOffset, yOffset }: { range: TRange; xOffset: number; yOffset: number; }) => SelectionRect[]; //#endregion //#region src/react/transforms/duplicateBlockSelectionNodes.d.ts declare const duplicateBlockSelectionNodes: (editor: PlateEditor) => void; //#endregion //#region src/react/transforms/insertBlocksAndSelect.d.ts declare const insertBlocksAndSelect: (editor: PlateEditor, nodes: TElement[], { at, insertedCallback }: { at: Path; insertedCallback?: () => void; }) => void; //#endregion //#region src/react/transforms/removeBlockSelectionNodes.d.ts declare const removeBlockSelectionNodes: (editor: SlateEditor) => void; //#endregion //#region src/react/transforms/selectBlockSelectionNodes.d.ts declare const selectBlockSelectionNodes: (editor: SlateEditor) => void; //#endregion //#region src/react/transforms/setBlockSelectionNodes.d.ts declare const setBlockSelectionNodes: (editor: PlateEditor, props: Partial>, options?: SetNodesOptions) => void; declare const setBlockSelectionIndent: (editor: PlateEditor, indent: number, options?: SetNodesOptions) => void; declare const setBlockSelectionTexts: (editor: PlateEditor, props: Partial>, options?: Omit) => void; //#endregion //#region src/react/utils/copySelectedBlocks.d.ts declare const copySelectedBlocks: (editor: SlateEditor, dataTransfer?: DataTransfer) => boolean; //#endregion //#region src/react/utils/pasteSelectedBlocks.d.ts declare const pasteSelectedBlocks: (editor: SlateEditor, e: ClipboardEvent) => void; //#endregion //#region src/react/utils/selectInsertedBlocks.d.ts /** Select inserted blocks from the last operations. */ declare const selectInsertedBlocks: (editor: SlateEditor) => void; //#endregion export { BLOCK_CONTEXT_MENU_ID, BlockMenuConfig, BlockMenuPlugin, BlockSelectionAfterEditable, BlockSelectionConfig, BlockSelectionPlugin, CaretPosition, CursorData, CursorOverlayConfig, CursorOverlayPlugin, CursorOverlayState, CursorState, FROZEN_EMPTY_ARRAY, SelectionRect, UseCursorOverlayOptions, UseRefreshOnResizeOptions, addOnContextMenu, copySelectedBlocks, duplicateBlockSelectionNodes, getCaretPosition, getCursorOverlayState, getSelectionRects, insertBlocksAndSelect, isSelectingOrFocused, pasteSelectedBlocks, removeBlockSelectionNodes, selectBlockSelectionNodes, selectInsertedBlocks, setBlockSelectionIndent, setBlockSelectionNodes, setBlockSelectionTexts, useBlockSelectable, useBlockSelected, useBlockSelectionFragment, useBlockSelectionFragmentProp, useBlockSelectionNodes, useCursorOverlay, useIsSelecting, useRefreshOnResize, useRequestReRender, useSelectionArea };