history
ai-research-agent / editor/modules/history
Functions
history()
function history(editor): object
Parameters
Parameter | Type |
---|---|
|
Returns
object
Name | Type |
---|---|
clearHistory | () => void |
commands | { redo : () => void ; undo : () => void ; } |
cutoffHistory | () => void |
getStack | () => UndoStack |
hasRedo | () => boolean |
hasUndo | () => boolean |
options | Options |
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
Parameter | Type |
---|---|
|
|
Returns
Function
Parameters
Parameter | Type |
---|---|
|
Returns
object
Name | Type |
---|---|
clearHistory | () => void |
commands | { redo : () => void ; undo : () => void ; } |
cutoffHistory | () => void |
getStack | () => UndoStack |
hasRedo | () => boolean |
hasUndo | () => boolean |
options | Options |
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
Parameter | Type |
---|---|
| |
|
Returns
void
undoStack()
function undoStack(): UndoStack
Returns
Interfaces
HistoryModule
Methods
destroy()
destroy(): void
Returns
void
Properties
clearHistory()
clearHistory: () => void;
Returns
void
cutoffHistory()
cutoffHistory: () => void;
Returns
void
getStack()
getStack: () => UndoStack;
Returns
hasRedo()
hasRedo: () => boolean;
Returns
boolean
hasUndo()
hasUndo: () => boolean;
Returns
boolean
options
options: Options;
redo()
redo: () => void;
Returns
void
setStack()
setStack: (value) => void;
Parameters
Parameter | Type |
---|---|
|
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[];