diff --git a/client/components/open/editors/UndoRedo.vue b/client/components/open/editors/UndoRedo.vue
index ac5d8abb..3c42860a 100644
--- a/client/components/open/editors/UndoRedo.vue
+++ b/client/components/open/editors/UndoRedo.vue
@@ -3,20 +3,24 @@
size="sm"
orientation="horizontal"
>
-
-
+
+
+
+
+
+
@@ -26,7 +30,44 @@ const workingFormStore = useWorkingFormStore()
const { undo, redo, clearHistory } = workingFormStore
const { canUndo, canRedo } = storeToRefs(workingFormStore)
+defineShortcuts({
+ meta_z: {
+ whenever: [canUndo],
+ handler: () => {
+ undo()
+ }
+ },
+ meta_shift_z: {
+ whenever: [canRedo],
+ handler: () => {
+ redo()
+ }
+ }
+})
+
+const undoShortcut = computed(() => {
+ return getOS() == 'macOS' ? ['⌘', 'Z'] : ['Ctrl', 'Z']
+})
+
+const redoShortcut = computed(() => {
+ return getOS() == 'macOS' ? ['⌘', 'Shift', 'Z'] : ['Ctrl', 'Shift', 'Z']
+})
+
onMounted(() => {
setTimeout(() => { clearHistory() }, 500)
})
+
+const getOS = ()=> {
+ if (navigator.userAgentData) {
+ // Modern method
+ return navigator.userAgentData.platform;
+ } else {
+ // Fallback for older browsers
+ const userAgent = navigator.userAgent.toLowerCase();
+ if (userAgent.indexOf("mac") > -1) return "macOS";
+ if (userAgent.indexOf("win") > -1) return "Windows";
+ if (userAgent.indexOf("linux") > -1) return "Linux";
+ return "Unknown";
+ }
+}