slate-history

  • Version 0.110.3
  • Published
  • 70.3 kB
  • 1 dependency
  • MIT license

Install

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

Overview

An operation-based history implementation for Slate editors.

Index

Variables

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;
    isSplittingOnce(editor: HistoryEditor): boolean | undefined;
    setSplittingOnce(editor: HistoryEditor, value: boolean | undefined): void;
    isSaving(editor: HistoryEditor): boolean | undefined;
    redo(editor: HistoryEditor): void;
    undo(editor: HistoryEditor): void;
    withMerging(editor: HistoryEditor, fn: () => void): void;
    withNewBatch(editor: HistoryEditor, fn: () => void): 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>;

          variable SPLITTING_ONCE

          const SPLITTING_ONCE: WeakMap<BaseEditor, boolean>;

            Functions

            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 https://docs.slatejs.org/concepts/11-typescript to learn how.

            Interfaces

            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)

                        Badge

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

                        You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/slate-history.

                        • Markdown
                          [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/slate-history)
                        • HTML
                          <a href="https://www.jsdocs.io/package/slate-history"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>