import type { EditorCommand } from './commands.js';
import type { DocSchema } from './schema/index.js';
/**
* Methods of editor instance.
*/
export interface Editor {
/**
* Dispatches editing command.
* @param fn command function
* @param args arguments of command
*/
command: (fn: EditorCommand, ...args: A) => void;
/**
* A function to make DOM editable.
* @returns A function to stop subscribing DOM changes and restores previous DOM state.
*/
input: (element: HTMLElement) => () => void;
/**
* Changes editor's read-only state.
* @param value `true` to read-only. `false` to editable.
*/
readonly: (value: boolean) => void;
}
/**
* Options of {@link createEditor}.
*/
export interface EditorOptions {
/**
* Initial document state.
*/
doc: T;
/**
* TODO
*/
schema: DocSchema;
/**
* TODO
*/
isBlock?: (node: HTMLElement) => boolean;
/**
* Callback invoked when document state changes.
*/
onChange: (doc: T) => void;
/**
* Callback invoked when `keydown` events are dispatched.
*
* Return `true` if you want to cancel the editor's default behavior.
*/
onKeyDown?: (keyboard: KeyboardPayload) => boolean | void;
}
export type KeyboardPayload = Pick;
/**
* A function to initialize editor.
*/
export declare const createEditor: ({ schema: { single: isSingleline, js: docToJS, doc: jsToDoc, copy, paste }, doc: initialDoc, isBlock, onChange, onKeyDown: onKeyDownCallback, }: EditorOptions) => Editor;