|
|
@ -34,7 +34,9 @@ export const useUndoRedo = createSharedComposable(() => { |
|
|
|
|
|
|
|
|
|
|
|
const redoQueue: Ref<UndoRedoAction[]> = ref([]) |
|
|
|
const redoQueue: Ref<UndoRedoAction[]> = ref([]) |
|
|
|
|
|
|
|
|
|
|
|
const addUndo = (action: UndoRedoAction) => { |
|
|
|
const addUndo = (action: UndoRedoAction, fromRedo = false) => { |
|
|
|
|
|
|
|
// remove all redo actions that are in the same scope
|
|
|
|
|
|
|
|
if (!fromRedo) redoQueue.value = redoQueue.value.filter((a) => a.scope !== action.scope) |
|
|
|
undoQueue.value.push(action) |
|
|
|
undoQueue.value.push(action) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -93,7 +95,7 @@ export const useUndoRedo = createSharedComposable(() => { |
|
|
|
if (action) { |
|
|
|
if (action) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
await action.redo.fn.apply(action, action.redo.args) |
|
|
|
await action.redo.fn.apply(action, action.redo.args) |
|
|
|
addUndo(action) |
|
|
|
addUndo(action, true) |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
message.warn('Error while redoing action, it is skipped.') |
|
|
|
message.warn('Error while redoing action, it is skipped.') |
|
|
|
} |
|
|
|
} |
|
|
|