mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Encapsulate clearing redo stack within History
This commit is contained in:
parent
9eeb4b10af
commit
1c96a4169d
2 changed files with 5 additions and 2 deletions
|
@ -34,6 +34,10 @@ class SceneHistory {
|
||||||
this.skipRecording();
|
this.skipRecording();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearRedoStack() {
|
||||||
|
this.redoStack.splice(0, this.redoStack.length);
|
||||||
|
}
|
||||||
|
|
||||||
redoOnce(elements: ExcalidrawElement[]) {
|
redoOnce(elements: ExcalidrawElement[]) {
|
||||||
const currentEntry = this.generateCurrentEntry(elements);
|
const currentEntry = this.generateCurrentEntry(elements);
|
||||||
const entryToRestore = this.redoStack.pop();
|
const entryToRestore = this.redoStack.pop();
|
||||||
|
|
|
@ -203,7 +203,6 @@ class App extends React.Component<{}, AppState> {
|
||||||
} else if (shapesShortcutKeys.includes(event.key.toLowerCase())) {
|
} else if (shapesShortcutKeys.includes(event.key.toLowerCase())) {
|
||||||
this.setState({ elementType: findShapeByKey(event.key) });
|
this.setState({ elementType: findShapeByKey(event.key) });
|
||||||
} else if (event.metaKey && event.code === "KeyZ") {
|
} else if (event.metaKey && event.code === "KeyZ") {
|
||||||
const currentEntry = history.generateCurrentEntry(elements);
|
|
||||||
if (event.shiftKey) {
|
if (event.shiftKey) {
|
||||||
// Redo action
|
// Redo action
|
||||||
history.redoOnce(elements);
|
history.redoOnce(elements);
|
||||||
|
@ -914,7 +913,7 @@ class App extends React.Component<{}, AppState> {
|
||||||
saveToLocalStorage(elements, this.state);
|
saveToLocalStorage(elements, this.state);
|
||||||
if (history.isRecording()) {
|
if (history.isRecording()) {
|
||||||
history.pushEntry(history.generateCurrentEntry(elements));
|
history.pushEntry(history.generateCurrentEntry(elements));
|
||||||
history.redoStack.splice(0, history.redoStack.length);
|
history.clearRedoStack();
|
||||||
}
|
}
|
||||||
history.resumeRecording();
|
history.resumeRecording();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue