This commit is contained in:
Skyler Lehmkuhl 2024-12-07 15:23:13 -05:00
parent b78362243a
commit 8067b9bb46
1 changed files with 14 additions and 0 deletions

View File

@ -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,