1 | import type { AttributesProps, CommandFunction, CommandFunctionProps, FromToProps, MarkType, MarkTypeProps, PrimitiveSelection, ProsemirrorAttributes } from '@remirror/core-types';
|
2 |
|
3 |
|
4 |
|
5 | interface DelayedCommandProps<Value> {
|
6 | |
7 |
|
8 |
|
9 |
|
10 |
|
11 | immediate?: CommandFunction;
|
12 | |
13 |
|
14 |
|
15 |
|
16 | promise: DelayedValue<Value>;
|
17 | |
18 |
|
19 |
|
20 | onDone: CommandFunction<{
|
21 | value: Value;
|
22 | }>;
|
23 | |
24 |
|
25 |
|
26 |
|
27 | onFail?: CommandFunction;
|
28 | }
|
29 | export type DelayedValue<Type> = Promise<Type> | (() => Promise<Type>);
|
30 | /**
|
31 | * Returns `true` when the provided value is a delayed value.
|
32 | */
|
33 | export declare function isDelayedValue<Type>(value: unknown): value is DelayedValue<Type>;
|
34 | /**
|
35 | * Add tentative support for delayed commands in the editor.
|
36 | *
|
37 | * Delayed commands are commands that run an immediate action, like adding a
|
38 | * tracker to a position in the document. Once the promise that is provided is
|
39 | * returned the `onDone` parameter is run with the document in the current
|
40 | * state. The tracker that was added can now be used to insert content, delete
|
41 | * content or replace content.
|
42 | *
|
43 | * @experimental This is still being worked on and the API is subject to changes
|
44 | * in structure going forward.
|
45 | *
|
46 | * @deprecated use [[`DelayedCommand`]] instead.
|
47 | *
|
48 | */
|
49 | export declare function delayedCommand<Value>({ immediate, promise, onDone, onFail, }: DelayedCommandProps<Value>): CommandFunction;
|
50 | export type DelayedPromiseCreator<Value> = (props: CommandFunctionProps) => Promise<Value>;
|
51 | export declare class DelayedCommand<Value> {
|
52 | private readonly promiseCreator;
|
53 | private readonly failureHandlers;
|
54 | private readonly successHandlers;
|
55 | private readonly validateHandlers;
|
56 | constructor(promiseCreator: DelayedPromiseCreator<Value>);
|
57 | /**
|
58 | * The commands that will immediately be run and used to evaluate whether to
|
59 | * proceed.
|
60 | */
|
61 | validate(handler: CommandFunction, method?: 'push' | 'unshift'): this;
|
62 | /**
|
63 | * Add a success callback to the handler.
|
64 | */
|
65 | success(handler: CommandFunction<{
|
66 | value: Value;
|
67 | }>, method?: 'push' | 'unshift'): this;
|
68 | /**
|
69 | * Add a failure callback to the handler.
|
70 | */
|
71 | failure(handler: CommandFunction<{
|
72 | error: any;
|
73 | }>, method?: 'push' | 'unshift'): this;
|
74 | private runHandlers;
|
75 | /**
|
76 | * Generate the `remirror` command.
|
77 | */
|
78 | readonly generateCommand: () => CommandFunction;
|
79 | }
|
80 | export interface ToggleMarkProps extends MarkTypeProps, Partial<AttributesProps> {
|
81 | |
82 |
|
83 |
|
84 | range?: FromToProps;
|
85 | |
86 |
|
87 |
|
88 | selection?: PrimitiveSelection;
|
89 | }
|
90 |
|
91 |
|
92 |
|
93 |
|
94 |
|
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 | export declare function toggleMark(props: ToggleMarkProps): CommandFunction;
|
107 |
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 | export declare function applyMark(type: string | MarkType, attrs?: ProsemirrorAttributes, selectionPoint?: PrimitiveSelection): CommandFunction;
|
116 | export interface InsertTextOptions extends Partial<FromToProps> {
|
117 | |
118 |
|
119 |
|
120 | marks?: Record<string, ProsemirrorAttributes>;
|
121 | }
|
122 |
|
123 |
|
124 |
|
125 |
|
126 |
|
127 | export declare function insertText(text: string, options?: InsertTextOptions): CommandFunction;
|
128 | export {};
|