Revert
This commit is contained in:
parent
b78362243a
commit
8067b9bb46
14
src/main.js
14
src/main.js
|
|
@ -48,6 +48,7 @@ let maxSmoothAngle = 0.6;
|
|||
|
||||
let undoStack = [];
|
||||
let redoStack = [];
|
||||
let lastSaveIndex = 0;
|
||||
|
||||
let layoutElements = []
|
||||
|
||||
|
|
@ -2177,6 +2178,7 @@ async function _save(path) {
|
|||
const contents = JSON.stringify(fileData);
|
||||
await writeTextFile(path, contents)
|
||||
filePath = path
|
||||
lastSaveIndex = undoStack.length - 1;
|
||||
console.log(`${path} saved successfully!`);
|
||||
} catch (error) {
|
||||
console.error("Error saving text file:", error);
|
||||
|
|
@ -2240,6 +2242,7 @@ async function open() {
|
|||
await actions[action.name].execute(action.action)
|
||||
undoStack.push(action)
|
||||
}
|
||||
lastSaveIndex = undoStack.length - 1;
|
||||
updateUI()
|
||||
} else {
|
||||
await messageDialog(`File ${path} was created in a newer version of Lightningbeam and cannot be opened in this version.`, { title: 'File version mismatch', kind: 'error' });
|
||||
|
|
@ -2258,6 +2261,12 @@ async function open() {
|
|||
}
|
||||
}
|
||||
|
||||
function revert() {
|
||||
for (let _=0; undoStack.length > lastSaveIndex+1; _++) {
|
||||
undo()
|
||||
}
|
||||
}
|
||||
|
||||
async function importImage() {
|
||||
const path = await openFileDialog({
|
||||
multiple: false,
|
||||
|
|
@ -3428,6 +3437,11 @@ async function updateMenu() {
|
|||
enabled: true,
|
||||
action: open,
|
||||
},
|
||||
{
|
||||
text: 'Revert',
|
||||
enabled: undoStack.length > lastSaveIndex,
|
||||
action: revert,
|
||||
},
|
||||
{
|
||||
text: 'Import Image...',
|
||||
enabled: true,
|
||||
|
|
|
|||
Loading…
Reference in New Issue