import { type ReactNode } from 'react'; import type { Editor } from '@tiptap/core'; import type { Node as ProseMirrorNode } from '@tiptap/pm/model'; import { type HandleBlock } from './BlockHandle'; /** A row of the block menu's Turn into: what the block becomes. */ export interface BlockTurnInto { label: string; /** * Turns the block. The handle puts the caret in a block of text first, so a * row for one can act at the caret; `pos` is where the block starts, for a * list or a quote, whose row acts on the whole block. */ run: (editor: Editor, pos: number) => void; /** Whether the block already is this — drawn as the selected row. */ active?: (node: ProseMirrorNode) => boolean; } export interface EditorBlockHandleProps { /** The editor. Not editable, or not there yet, and the handle reads: the caller's rows only. */ editor: Editor | null; /** * Turn into's rows for a block. By default `turnIntoRows`, the same in every * app: a block of text, a list and a quote each get theirs. A list of rows * instead is offered for a block of text only; `[]` offers none. */ turnInto?: readonly BlockTurnInto[] | ((node: ProseMirrorNode, editor: Editor) => readonly BlockTurnInto[]); /** The caller's own rows, after the editing ones. */ actions?: (block: HandleBlock) => ReactNode; /** The `EditorContent`. */ children: ReactNode; className?: string; } /** A copy of the block straight after it, the caret in the copy. `BlockId` gives the copy a fresh id; the original keeps its own. */ export declare function duplicateBlock(editor: Editor, pos: number): boolean; /** Removes the block, the caret where it was. The last block of a document becomes an empty paragraph, since a document holds at least one. */ export declare function deleteBlock(editor: Editor, pos: number): boolean; /** * Moves the block at `from` to `to` (a position between top-level blocks), the * caret in it: what a drop in the gutter does, where the editor has no drop of * its own. The node moves whole, attributes and all, so it keeps its id, as * ProseMirror's drop keeps it. */ export declare function moveBlock(editor: Editor, from: number, to: number): boolean; /** * Starts the browser's own drag of the block, as ProseMirror starts one of a * selected node: the block selected, its slice on `view.dragging` with `move`, * and its HTML on the transfer. ProseMirror's drop then deletes the selection * and inserts the slice with its attributes — so the block arrives with the * id it left with, and every comment anchored to it still finds it. */ export declare function startBlockDrag(editor: Editor, pos: number, event: Pick, image?: Element): void; /** * The drop line a dragged block shows, in the package's accent instead of the * editor's default (the text's colour). Give it to the editor's StarterKit: * `StarterKit.configure({ dropcursor: blockDropCursor })`. */ export declare const blockDropCursor: { readonly color: false; readonly class: "bg-accent-primary"; }; /** * `BlockHandle` in an editor: drag the handle to move the block, and the menu * gains Turn into, Duplicate and Delete before the caller's rows. */ export declare function EditorBlockHandle({ editor, turnInto, actions, children, className }: EditorBlockHandleProps): import("react").JSX.Element; export type ListKind = 'bulletList' | 'orderedList' | 'checklist' | 'text'; /** * Turns the whole list at `pos`, every item, the nested ones too. * * - **Bulleted, Numbered:** the list's own type changes and its attributes * stay, so it keeps its id; every item's tick goes. Not Tiptap's * `toggleList`, which makes the list anew — a fresh id, detaching every * comment anchored to it — and then joins it into a list of that type next * to it. * - **Checklist:** every item a checklist item, the list's type as it was; an * item already one keeps its tick. * * The kind it already is changes nothing — no edit, no undo step. * - **Text:** each item becomes a paragraph that takes the item's id, as * lifting an item out does (MAN-12). The list's own id goes with the list. * * `false` when there is no list at `pos`. */ export declare function turnListInto(editor: Editor, pos: number, kind: ListKind): boolean; export type QuoteKind = 'quote' | 'note' | 'warning' | 'text'; /** * Turns the quote at `pos`: a plain quote, a Note or Warning callout (the * tone changes, the id stays), or its text, whose first paragraph takes the * quote's id, as lifting it out does (MAN-12). `false` when there is no quote * at `pos`. */ export declare function turnQuoteInto(editor: Editor, pos: number, kind: QuoteKind): boolean; /** * The block menu's Turn into for one block, the same in every app (Miky, * LEAF-11's kickoff, 15 October): * * - **A block of text** — a paragraph, a heading, code: the `/` menu's Format * rows, code as a block, and Checklist, Note and Warning where the editor * has `Checklist` and `Callout`. * - **A list:** Bulleted list, Numbered list, Checklist (with `Checklist`), Text. * - **A quote:** Quote, Note, Warning (with `Callout`), Text. * * Anything else — a table, an attachment — none. Each keeps the block's text * and its id, and so the comments anchored to it. */ export declare function turnIntoRows(node: ProseMirrorNode, editor: Editor): readonly BlockTurnInto[]; //# sourceMappingURL=EditorBlockHandle.d.ts.map