UNPKG

2.43 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>;
9export declare const SPLITTING_ONCE: WeakMap<BaseEditor, boolean | undefined>;
10/**
11 * `HistoryEditor` contains helpers for history-enabled editors.
12 */
13export interface HistoryEditor extends BaseEditor {
14 history: History;
15 undo: () => void;
16 redo: () => void;
17 writeHistory: (stack: 'undos' | 'redos', batch: any) => void;
18}
19export declare const HistoryEditor: {
20 /**
21 * Check if a value is a `HistoryEditor` object.
22 */
23 isHistoryEditor(value: any): value is HistoryEditor;
24 /**
25 * Get the merge flag's current value.
26 */
27 isMerging(editor: HistoryEditor): boolean | undefined;
28 /**
29 * Get the splitting once flag's current value.
30 */
31 isSplittingOnce(editor: HistoryEditor): boolean | undefined;
32 setSplittingOnce(editor: HistoryEditor, value: boolean | undefined): void;
33 /**
34 * Get the saving flag's current value.
35 */
36 isSaving(editor: HistoryEditor): boolean | undefined;
37 /**
38 * Redo to the previous saved state.
39 */
40 redo(editor: HistoryEditor): void;
41 /**
42 * Undo to the previous saved state.
43 */
44 undo(editor: HistoryEditor): void;
45 /**
46 * Apply a series of changes inside a synchronous `fn`, These operations will
47 * be merged into the previous history.
48 */
49 withMerging(editor: HistoryEditor, fn: () => void): void;
50 /**
51 * Apply a series of changes inside a synchronous `fn`, ensuring that the first
52 * operation starts a new batch in the history. Subsequent operations will be
53 * merged as usual.
54 */
55 withNewBatch(editor: HistoryEditor, fn: () => void): void;
56 /**
57 * Apply a series of changes inside a synchronous `fn`, without merging any of
58 * the new operations into previous save point in the history.
59 */
60 withoutMerging(editor: HistoryEditor, fn: () => void): void;
61 /**
62 * Apply a series of changes inside a synchronous `fn`, without saving any of
63 * their operations into the history.
64 */
65 withoutSaving(editor: HistoryEditor, fn: () => void): void;
66};
67//# sourceMappingURL=history-editor.d.ts.map
\No newline at end of file