UNPKG

2.02 kBTypeScriptView Raw
1import type { EditorState, Transaction } from '../state';
2import type { CommandFunction, EditorSchema, NonChainableCommandFunction, ProsemirrorCommandFunction } from './pm-types';
3/**
4 * Creates a fake state that can be used on ProseMirror library commands to make
5 * them chainable. The provided Transaction `tr` can be a shared one.
6 *
7 * @param tr - the chainable transaction that should be amended.
8 * @param state - the state of the editor (available via `view.state`).
9 *
10 * This should not be used other than for passing to `prosemirror-*` library
11 * commands.
12 */
13export declare function chainableEditorState<Schema extends EditorSchema = EditorSchema>(tr: Transaction<Schema>, state: EditorState<Schema>): EditorState<Schema>;
14/**
15 * Wraps the default [[ProsemirrorCommandFunction]] and makes it compatible with
16 * the default **remirror** [[CommandFunction]] call signature.
17 *
18 * It extracts all the public APIs of the state object and assigns the
19 * chainable transaction to the `state.tr` property to support chaining.
20 */
21export declare function convertCommand<Schema extends EditorSchema = EditorSchema, Extra extends object = object>(commandFunction: ProsemirrorCommandFunction<Schema>): CommandFunction<Schema, Extra>;
22/**
23 * Marks a command function as non chainable. It will throw an error when
24 * chaining is attempted.
25 *
26 * @remarks
27 *
28 * ```ts
29 * const command = nonChainable(({ state, dispatch }) => {...});
30 * ```
31 */
32export declare function nonChainable<Schema extends EditorSchema = EditorSchema, Extra extends object = object>(commandFunction: CommandFunction<Schema, Extra>): NonChainableCommandFunction<Schema, Extra>;
33/**
34 * Similar to the chainCommands from the `prosemirror-commands` library. Allows
35 * multiple commands to be chained together and runs until one of them returns
36 * true.
37 */
38export declare function chainCommands<Schema extends EditorSchema = EditorSchema, Extra extends object = object>(...commands: Array<CommandFunction<Schema, Extra>>): CommandFunction<Schema, Extra>;