• Version 0.100.0
  • Published
  • 60.2 kB
  • 1 dependency
  • MIT license


npm i slate-history
yarn add slate-history
pnpm add slate-history


An operation-based history implementation for Slate editors.



variable History

const History: { isHistory(value: any): value is History };

    variable HISTORY

    const HISTORY: WeakMap<BaseEditor, History>;
    • Weakmaps for attaching state to the editor.

    variable HistoryEditor

    const HistoryEditor: {
    isHistoryEditor(value: any): value is HistoryEditor;
    isMerging(editor: HistoryEditor): boolean | undefined;
    isSaving(editor: HistoryEditor): boolean | undefined;
    redo(editor: HistoryEditor): void;
    undo(editor: HistoryEditor): void;
    withoutMerging(editor: HistoryEditor, fn: () => void): void;
    withoutSaving(editor: HistoryEditor, fn: () => void): void;

      variable MERGING

      const MERGING: WeakMap<BaseEditor, boolean>;

        variable SAVING

        const SAVING: WeakMap<BaseEditor, boolean>;


          function withHistory

          withHistory: <T extends any>(editor: T) => T & HistoryEditor;
          • The withHistory plugin keeps track of the operation history of a Slate editor as operations are applied to it, using undo and redo stacks.

            If you are using TypeScript, you must extend Slate's CustomTypes to use this plugin.

            See to learn how.


          interface History

          interface History {}
          • History objects hold all of the operations that are applied to a value, so they can be undone or redone as necessary.

          property redos

          redos: Batch[];

            property undos

            undos: Batch[];

              interface HistoryEditor

              interface HistoryEditor extends BaseEditor {}
              • HistoryEditor contains helpers for history-enabled editors.

              property history

              history: History;

                property redo

                redo: () => void;

                  property undo

                  undo: () => void;

                    property writeHistory

                    writeHistory: (stack: 'undos' | 'redos', batch: any) => void;

                      Package Files (4)

                      Dependencies (1)

                      Dev Dependencies (5)

                      Peer Dependencies (1)


                      To add a badge like this badgeto your package's README, use the codes available below.

                      You may also use to create a custom badge linking to

                      • Markdown
                      • HTML
                        <a href=""><img src="" alt=""></a>