Overview

The History extension enables to undo and redo code changes, and provides shortcuts for these actions.

KeysDescription
Ctrl+ZUndo changes
Ctrl+Shift+ZRedo changes

Usage

Register the History component:

import { RyuseiCode, History } from '@ryusei/code';
RyuseiCode.compose( { History } );
JavaScript

or import the file:

<script src="path-to-the-file/history.min.js"></script>
HTML

Options

Set an object to history to update default options, or false to deactivate it.

new RyuseiCode( { history: { ... } } );
// or
new RyuseiCode( { history: false } );
JavaScript

limit

Limits the number of undo/redo history size.

type: number default: 100


debounce

The debounce duration in milliseconds for recording a history. If a new change comes within this duration, the recording will be postponed (debounced).

type: number default: 300

Properties

lines

get

Returns the latest Lines instance. This is an alias of Code#Lines.


i18n

get

Returns the i18n collection. This is an alias of this.options.i18n.


length

get

Returns the current history length.

Methods

undo()

undo(): void

Performs undo.


redo()

redo(): void

Performs redo only if previously undo() is operated.