Overview
The History extension enables to undo and redo code changes, and provides shortcuts for these actions.
Keys | Description |
---|---|
Ctrl+Z | Undo changes |
Ctrl+Shift+Z | Redo changes |
Usage
Register the History component:
import { RyuseiCode, History } from '@ryusei/code'; RyuseiCode.compose( { History } );
or import the file:
<script src="path-to-the-file/history.min.js"></script>
Options
Set an object to history
to update default options,
or false
to deactivate it.
new RyuseiCode( { history: { ... } } ); // or new RyuseiCode( { history: false } );
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.