1 | export declare type EditorSchema = import('../model').Schema;
|
2 | export declare type EditorView = import('../view').EditorView;
|
3 | export declare type Selection = import('../state').Selection;
|
4 | export declare type DecorationSet = import('../view').DecorationSet;
|
5 | export declare type Transaction = import('../state').Transaction;
|
6 | export declare type PluginKey<PluginState = any> = import('../state').PluginKey<PluginState>;
|
7 | export declare type Mark = import('../model').Mark;
|
8 | export declare type ResolvedPos = import('../model').ResolvedPos;
|
9 | export declare type InputRule = import('../inputrules').InputRule;
|
10 | export declare type Fragment = import('../model').Fragment;
|
11 | export declare type NodeView = import('../view').NodeView;
|
12 | export declare type ProsemirrorNode = import('../model').Node;
|
13 | export declare type ProsemirrorPlugin<PluginState = any> = import('../state').Plugin<PluginState>;
|
14 | export declare type MarkType = import('../model').MarkType;
|
15 | export declare type NodeType = import('../model').NodeType;
|
16 | export declare type EditorState = Readonly<import('../state').EditorState>;
|
17 | export declare type Slice = import('../model').Slice;
|
18 | export declare type Decoration = import('../view').Decoration;
|
19 | export declare type Mapping = import('../transform').Mapping;
|
20 | declare const _brand: unique symbol;
|
21 | interface Branding<Type> {
|
22 | readonly [_brand]: Type;
|
23 | }
|
24 | declare type Brand<Type, B> = Type & Branding<B>;
|
25 | /**
|
26 | * Brands a command as non chainable so that it can be excluded from the
|
27 | * inferred chainable commands.
|
28 | */
|
29 | export declare type NonChainableCommandFunction<Extra extends object = object> = Brand<CommandFunction<Extra>, 'non-chainable'>;
|
30 | /**
|
31 | * Used to apply the Prosemirror transaction to the current {@link EditorState}.
|
32 | *
|
33 | * @typeParam Schema - the underlying editor schema.
|
34 | */
|
35 | export declare type DispatchFunction = (tr: Transaction) => void;
|
36 | /**
|
37 | * This is the type signature for commands within the prosemirror editor.
|
38 | *
|
39 | * @remarks
|
40 | *
|
41 | * A command function takes an editor state and optionally a dispatch function
|
42 | * that it can use to dispatch a transaction. It should return a boolean that
|
43 | * indicates whether it could perform any action.
|
44 | *
|
45 | * When no dispatch callback is passed, the command should do a 'dry run',
|
46 | * determining whether it is applicable, but not actually performing any action.
|
47 | *
|
48 | * @typeParam Schema - the underlying editor schema.
|
49 | */
|
50 | export declare type ProsemirrorCommandFunction = (state: EditorState, dispatch: DispatchFunction | undefined, view: EditorView | undefined) => boolean;
|
51 | /**
|
52 | * A command method for running commands in your editor.
|
53 | *
|
54 | * @typeParam Schema - the underlying editor schema.
|
55 | * @typeParam ExtraProps - extra parameters to add to the command function.
|
56 | *
|
57 | * @remarks
|
58 | *
|
59 | * This groups all the prosemirror command arguments into a single parameter.
|
60 | *
|
61 | * tldr; When `dispatch=undefined` make sure the command function is **idempotent**.
|
62 | *
|
63 | * One thing to be aware of is that when creating a command function the
|
64 | * `tr` should only be updated when the `dispatch` method is available. This is
|
65 | * because by convention calling the command function with `dispatch=undefined`
|
66 | * is used to check if the function returns `true`, an indicator that it is
|
67 | * enabled, or returns `false` to indicate it is not enabled.
|
68 | *
|
69 | * If the transaction has been updated outside of the `dispatch=true` condition
|
70 | * then running the command again will result in multiple transaction updates
|
71 | * and unpredictable behavior.
|
72 | *
|
73 | * @see {@link ProsemirrorCommandFunction}
|
74 | */
|
75 | export declare type CommandFunction<ExtraProps extends object = object> = (params: CommandFunctionProps & ExtraProps) => boolean;
|
76 | /**
|
77 | * A parameter builder interface for the remirror `CommandFunction`.
|
78 | *
|
79 | * @typeParam Schema - the underlying editor schema.
|
80 | */
|
81 | export interface CommandFunctionProps {
|
82 | /**
|
83 | * The shared ProseMirror Transaction.
|
84 | */
|
85 | tr: Transaction;
|
86 | /**
|
87 | * A snapshot of the ProseMirror editor state.
|
88 | */
|
89 | state: EditorState;
|
90 | /**
|
91 | * The dispatch function which causes the command to be performed.
|
92 | *
|
93 | * @remarks
|
94 | *
|
95 | * `dispatch` can be `undefined`. When no `dispatch` callback is provided the
|
96 | * command should perform a 'dry run', determining whether the command is
|
97 | * applicable (`return true`), but not actually performing the action.
|
98 | */
|
99 | dispatch?: DispatchFunction;
|
100 | /**
|
101 | * An instance of the ProseMirror editor `view`.
|
102 | */
|
103 | view?: EditorView;
|
104 | }
|
105 | export {};
|