1
0
Эх сурвалжийг харах

fix: undo-redo activated inside input element

Ahmad Kholid 2 жил өмнө
parent
commit
9e76dc7513

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "automa",
-  "version": "1.15.1",
+  "version": "1.15.2",
   "description": "An extension for automating your browser by connecting blocks",
   "license": "MIT",
   "repository": {

+ 2 - 2
src/composable/shortcut.js

@@ -122,9 +122,9 @@ export function useShortcut(shortcuts, handler) {
     if (shortcutId) event.preventDefault();
 
     if (typeof params.data === 'function') {
-      params.data(params);
+      params.data(params, event);
     } else if (handler) {
-      handler(params);
+      handler(params, event);
     }
   };
   const addShortcutData = ({ combo, id, readable, ...rest }) => {

+ 8 - 2
src/newtab/pages/workflows/[id].vue

@@ -905,12 +905,18 @@ async function fetchConnectedTable() {
 
   connectedTable.value = table;
 }
+function undoRedoCommand(type, { target }) {
+  const els = ['INPUT', 'SELECT', 'TEXTAREA'];
+  if (els.includes(target.tagName) || target.isContentEditable) return;
+
+  executeCommand(type);
+}
 
 const shortcut = useShortcut([
   getShortcut('editor:toggle-sidebar', toggleSidebar),
   getShortcut('editor:duplicate-block', duplicateElements),
-  getShortcut('action:undo', () => executeCommand('undo')),
-  getShortcut('action:redo', () => executeCommand('redo')),
+  getShortcut('action:undo', (_, event) => undoRedoCommand('undo', event)),
+  getShortcut('action:redo', (_, event) => undoRedoCommand('redo', event)),
 ]);
 
 watch(