import { Node as ProsemirrorNode, Slice } from 'prosemirror-model'; import { EditorState, Transaction } from 'prosemirror-state'; import { EditorView } from 'prosemirror-view'; import { SylApi } from '../api'; import { Types } from '../libs'; import { IMatcherConfig, TextMatcherHandler } from './matchers'; interface IToolbar { className?: string; tooltip?: string | ((node: any) => any); type?: string; icon?: any | ((editor: SylApi, attrs: Types.StringMap, extra: any) => any); handler?(editor: SylApi, ...args: any[]): void; showName?: string | boolean; getRef?(ref: HTMLElement | null): void; [x: string]: any; } interface IControllerCommand { [key: string]: (editor: SylApi, ...args: any[]) => any; } interface IEventHandler { handleKeyDown?: (editor: SylApi, view: EditorView, event: KeyboardEvent) => boolean; handleKeyPress?: (editor: SylApi, view: EditorView, event: KeyboardEvent) => boolean; handleTextInput?: (editor: SylApi, view: EditorView, from: number, to: number, text: string) => boolean; handleClickOn?: (editor: SylApi, view: EditorView, pos: number, node: ProsemirrorNode, nodePos: number, event: MouseEvent, direct: boolean) => boolean; handleClick?: (editor: SylApi, view: EditorView, pos: number, event: MouseEvent) => boolean; handleDoubleClickOn?: (editor: SylApi, view: EditorView, pos: number, node: ProsemirrorNode, nodePos: number, event: MouseEvent, direct: boolean) => boolean; handleDoubleClick?: (editor: SylApi, view: EditorView, pos: number, event: MouseEvent) => boolean; handleTripleClickOn?: (editor: SylApi, view: EditorView, pos: number, node: ProsemirrorNode, nodePos: number, event: MouseEvent, direct: boolean) => boolean; handleTripleClick?: (editor: SylApi, view: EditorView, pos: number, event: MouseEvent) => boolean; handlePaste?: (editor: SylApi, view: EditorView, event: Event, slice: Slice) => boolean; handleDrop?: (editor: SylApi, view: EditorView, event: Event, slice: Slice, moved: boolean) => boolean; handleScrollToSelection?: (editor: SylApi, view: EditorView) => boolean; transformPastedHTML?: (editor: SylApi, html: string) => string; transformPastedText?: (editor: SylApi, text: string) => string; transformPasted?: (editor: SylApi, p: Slice) => Slice; clipboardTextSerializer?: (editor: SylApi, p: Slice) => string; handleDOMEvents?: Partial boolean>>; } declare type TKeymapHandler = (editor: SylApi, state: EditorState, dispatch: EditorView['dispatch'], view: EditorView) => boolean; declare class SylController = any> { name: string; editor: SylApi; toolbar: IToolbar; textMatcher?: Array>; props: Partial; command?: IControllerCommand; disable?(editor: SylApi): boolean; active?(editor: SylApi): boolean; eventHandler?: IEventHandler; keymap?: Types.StringMap; transformGetHTML?(html: string): string; appendTransaction?(tr: Transaction, oldState: EditorState, newState: EditorState): void | Transaction; filterTransaction?(tr: Transaction, state: EditorState): boolean; constructor(editor: SylApi, props: Partial); editorWillUnmount(): void; } export { IControllerCommand, IEventHandler, IToolbar, SylController, TKeymapHandler };