浏览代码

fix: undo-redo activated inside input element

Ahmad Kholid 2 年之前
父节点
当前提交
9e76dc7513
共有 3 个文件被更改,包括 11 次插入5 次删除
  1. 1 1
      package.json
  2. 2 2
      src/composable/shortcut.js
  3. 8 2
      src/newtab/pages/workflows/[id].vue

+ 1 - 1
package.json

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

+ 2 - 2
src/composable/shortcut.js

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

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

@@ -905,12 +905,18 @@ async function fetchConnectedTable() {
 
 
   connectedTable.value = table;
   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([
 const shortcut = useShortcut([
   getShortcut('editor:toggle-sidebar', toggleSidebar),
   getShortcut('editor:toggle-sidebar', toggleSidebar),
   getShortcut('editor:duplicate-block', duplicateElements),
   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(
 watch(