Skip to main content

history

ai-research-agent / editor/modules/history

Functions

history()

function history(editor): object

Parameters

ParameterType

editor

Editor

Returns

object

NameType
clearHistory() => void
commands{ redo: () => void; undo: () => void; }
cutoffHistory() => void
getStack() => UndoStack
hasRedo() => boolean
hasUndo() => boolean
optionsOptions
redo() => void
setStack(value) => void
shortcuts{ mac:Cmd+Shift+Z: string; mac:Cmd+Z: string; win:Ctrl+Y: string; win:Ctrl+Z: string; }
undo() => void
destroy()
getActive()
init()

initHistory()

function initHistory(initOptions): (editor) => object

History is a view module for storing user changes and undoing/redoing those changes.

Stores history for all user-generated changes. Like-changes will be combined until a selection or a delay timeout cuts off the combining. E.g. if a user types "Hello" the 5 changes will be combined into one history entry. If the user moves the cursor somewhere and then back to the end and types " World" the next 6 changes are combined separately from the first 5 because selection changes add a cutoff history entries.

The default options can be overridden by passing alternatives to history. To add a timeout to force a cutoff after so many milliseconds set a delay like this:

const modules = {
history: history({ delay: 4000 })
};

Parameters

ParameterType

initOptions

Partial<Options>

Returns

Function

Parameters
ParameterType

editor

Editor

Returns

object

NameType
clearHistory() => void
commands{ redo: () => void; undo: () => void; }
cutoffHistory() => void
getStack() => UndoStack
hasRedo() => boolean
hasUndo() => boolean
optionsOptions
redo() => void
setStack(value) => void
shortcuts{ mac:Cmd+Shift+Z: string; mac:Cmd+Z: string; win:Ctrl+Y: string; win:Ctrl+Z: string; }
undo() => void
destroy()
getActive()
init()

transformHistoryStack()

function transformHistoryStack(stack, delta): void

Parameters

ParameterType

stack

UndoStack

delta

default | default

Returns

void


undoStack()

function undoStack(): UndoStack

Returns

UndoStack

Interfaces

HistoryModule

Methods

destroy()
destroy(): void
Returns

void

Properties

clearHistory()
clearHistory: () => void;
Returns

void

cutoffHistory()
cutoffHistory: () => void;
Returns

void

getStack()
getStack: () => UndoStack;
Returns

UndoStack

hasRedo()
hasRedo: () => boolean;
Returns

boolean

hasUndo()
hasUndo: () => boolean;
Returns

boolean

options
options: Options;
redo()
redo: () => void;
Returns

void

setStack()
setStack: (value) => void;
Parameters
ParameterType

value

UndoStack

Returns

void

undo()
undo: () => void;
Returns

void


Options

Properties

delay
delay: number;
maxStack
maxStack: number;
unrecordedSources
unrecordedSources: Set<string>;

StackEntry

Properties

redo
redo: default;
undo
undo: default;

UndoStack

Properties

redo
redo: StackEntry[];
undo
undo: StackEntry[];