UNPKG

1.66 kBTypeScriptView Raw
1import { BaseEditor } from 'slate';
2import { History } from './history';
3/**
4 * Weakmaps for attaching state to the editor.
5 */
6export declare const HISTORY: WeakMap<BaseEditor, History>;
7export declare const SAVING: WeakMap<BaseEditor, boolean | undefined>;
8export declare const MERGING: WeakMap<BaseEditor, boolean | undefined>;
9/**
10 * `HistoryEditor` contains helpers for history-enabled editors.
11 */
12export interface HistoryEditor extends BaseEditor {
13 history: History;
14 undo: () => void;
15 redo: () => void;
16 writeHistory: (stack: 'undos' | 'redos', batch: any) => void;
17}
18export declare const HistoryEditor: {
19 /**
20 * Check if a value is a `HistoryEditor` object.
21 */
22 isHistoryEditor(value: any): value is HistoryEditor;
23 /**
24 * Get the merge flag's current value.
25 */
26 isMerging(editor: HistoryEditor): boolean | undefined;
27 /**
28 * Get the saving flag's current value.
29 */
30 isSaving(editor: HistoryEditor): boolean | undefined;
31 /**
32 * Redo to the previous saved state.
33 */
34 redo(editor: HistoryEditor): void;
35 /**
36 * Undo to the previous saved state.
37 */
38 undo(editor: HistoryEditor): void;
39 /**
40 * Apply a series of changes inside a synchronous `fn`, without merging any of
41 * the new operations into previous save point in the history.
42 */
43 withoutMerging(editor: HistoryEditor, fn: () => void): void;
44 /**
45 * Apply a series of changes inside a synchronous `fn`, without saving any of
46 * their operations into the history.
47 */
48 withoutSaving(editor: HistoryEditor, fn: () => void): void;
49};
50//# sourceMappingURL=history-editor.d.ts.map
\No newline at end of file