Skip to main content

extension-history

package @remirror/extension-history

class HistoryExtension​

This extension provides undo and redo commands and inserts a plugin which handles history related actions.

Builtin Extension

Signature:

export declare class HistoryExtension extends PlainExtension<HistoryOptions> 

Extends: PlainExtension<HistoryOptions>

(Some inherited members may not be shown because they are not represented in the documentation.)

property name​

Signature:

get name(): "history";

method createExternalPlugins​

Bring the prosemirror-history plugin with options set on this extension.

Signature:

createExternalPlugins(): ProsemirrorPlugin[];

Returns:

ProsemirrorPlugin[]

method createKeymap​

Adds the default key mappings for undo and redo.

Signature:

createKeymap(): PrioritizedKeyBindings;

Returns:

PrioritizedKeyBindings

method redo​

Redo an action that was in the undo stack.

actions.redo()

This command is **non-chainable**.

Signature:

redo(): NonChainableCommandFunction;

Returns:

NonChainableCommandFunction

method redoDepth​

Returns the amount of redoable events available from the current state, or provide a custom state.

Signature:

redoDepth(state?: EditorState): Helper<number>;

Parameters:

ParameterTypeDescription
stateEditorState(Optional)

Returns:

Helper<number>

method redoShortcut​

Handle the redo keybinding for the editor.

Signature:

redoShortcut(props: KeyBindingProps): boolean;

Parameters:

ParameterTypeDescription
propsKeyBindingProps

Returns:

boolean

method undo​

Undo the last action that occurred. This can be overridden by setting an "addToHistory" metadata property of false on a transaction to prevent it from being rolled back by undo.

actions.undo()

// To prevent this use
tr.setMeta(pluginKey, { addToHistory: false })

This command is **non-chainable**.

Signature:

undo(): NonChainableCommandFunction;

Returns:

NonChainableCommandFunction

method undoDepth​

Returns the amount of undoable events available from the current state, or provide a custom state.

Signature:

undoDepth(state?: EditorState): Helper<number>;

Parameters:

ParameterTypeDescription
stateEditorState(Optional)

Returns:

Helper<number>

method undoShortcut​

Handle the undo keybinding.

Signature:

undoShortcut(props: KeyBindingProps): boolean;

Parameters:

ParameterTypeDescription
propsKeyBindingProps

Returns:

boolean

interface HistoryOptions​

Signature:

export interface HistoryOptions 

property depth​

The number of history events that are collected before the oldest events are discarded.

Signature:

depth?: Static<number>;

property getDispatch​

Provide a custom dispatch getter function for embedded editors

Signature:

getDispatch?: AcceptUndefined<() => DispatchFunction>;

Remarks:

This is only needed when the extension is part of a child editor, e.g. ImageCaptionEditor. By passing in the getDispatch method history actions can be dispatched into the parent editor allowing them to propagate into the child editor.

property getState​

Provide a custom state getter function.

Signature:

getState?: AcceptUndefined<() => EditorState>;

Remarks:

This is only needed when the extension is part of a child editor, e.g. ImageCaptionEditor. By passing in the getState method history actions can be dispatched into the parent editor allowing them to propagate into the child editor

property newGroupDelay​

The delay (ms) between changes after which a new group should be started. Note that when changes aren't adjacent, a new group is always started.

Signature:

newGroupDelay?: Static<number>;

property onRedo​

A callback to listen to when the user attempts to redo with the keyboard. When it succeeds success is true.

Signature:

onRedo?: Handler<(success: boolean) => void>;

property onUndo​

A callback to listen to when the user attempts to undo with the keyboard. When it succeeds success is true.

Signature:

onUndo?: Handler<(success: boolean) => void>;