浏览代码

Move filebrowser shortcuts to settings (#10466)

* Move filebrowser shortcuts to settings
Fixes #10465

* Remove unused `Selectors`
Frédéric Collonval 3 年之前
父节点
当前提交
29aa9147ca
共有 2 个文件被更改,包括 30 次插入46 次删除
  1. 30 0
      packages/filebrowser-extension/schema/browser.json
  2. 0 46
      packages/filebrowser-extension/src/index.ts

+ 30 - 0
packages/filebrowser-extension/schema/browser.json

@@ -148,6 +148,36 @@
       "command": "filebrowser:go-up",
       "keys": ["Backspace"],
       "selector": ".jp-DirListing-content .jp-DirListing-itemText"
+    },
+    {
+      "command": "filebrowser:delete",
+      "keys": ["Delete"],
+      "selector": ".jp-DirListing-content .jp-DirListing-itemText"
+    },
+    {
+      "command": "filebrowser:cut",
+      "keys": ["Accel X"],
+      "selector": ".jp-DirListing-content .jp-DirListing-itemText"
+    },
+    {
+      "command": "filebrowser:copy",
+      "keys": ["Accel C"],
+      "selector": ".jp-DirListing-content .jp-DirListing-itemText"
+    },
+    {
+      "command": "filebrowser:paste",
+      "keys": ["Accel V"],
+      "selector": ".jp-DirListing-content .jp-DirListing-itemText"
+    },
+    {
+      "command": "filebrowser:rename",
+      "keys": ["F2"],
+      "selector": ".jp-DirListing-content .jp-DirListing-itemText"
+    },
+    {
+      "command": "filebrowser:duplicate",
+      "keys": ["Accel D"],
+      "selector": ".jp-DirListing-content .jp-DirListing-itemText"
     }
   ],
   "properties": {

+ 0 - 46
packages/filebrowser-extension/src/index.ts

@@ -120,21 +120,6 @@ namespace CommandIDs {
   export const search = 'filebrowser:search';
 }
 
-namespace Selectors {
-  // matches the text in the filebrowser; relies on an implementation detail
-  // being the text of the listing element being substituted with input
-  // area to deactivate shortcuts when the file name is being edited.
-  export const selectorBrowser =
-    '.jp-DirListing-content .jp-DirListing-itemText';
-  // matches anywhere on filebrowser
-  export const selectorContent = '.jp-DirListing-content';
-  // matches all filebrowser items
-  export const selectorItem = '.jp-DirListing-item[data-isdir]';
-  // matches only non-directory items
-  export const selectorNotDir = '.jp-DirListing-item[data-isdir="false"]';
-  export const selectorHeader = '.jp-DirListing-header';
-}
-
 /**
  * The file browser namespace token.
  */
@@ -1047,37 +1032,6 @@ function addCommands(
       category: trans.__('File Operations')
     });
   }
-
-  app.commands.addKeyBinding({
-    command: CommandIDs.del,
-    selector: Selectors.selectorBrowser,
-    keys: ['Delete']
-  });
-  app.commands.addKeyBinding({
-    command: CommandIDs.cut,
-    selector: Selectors.selectorBrowser,
-    keys: ['Ctrl X']
-  });
-  app.commands.addKeyBinding({
-    command: CommandIDs.copy,
-    selector: Selectors.selectorBrowser,
-    keys: ['Ctrl C']
-  });
-  app.commands.addKeyBinding({
-    command: CommandIDs.paste,
-    selector: Selectors.selectorBrowser,
-    keys: ['Ctrl V']
-  });
-  app.commands.addKeyBinding({
-    command: CommandIDs.rename,
-    selector: Selectors.selectorBrowser,
-    keys: ['F2']
-  });
-  app.commands.addKeyBinding({
-    command: CommandIDs.duplicate,
-    selector: Selectors.selectorBrowser,
-    keys: ['Ctrl D']
-  });
 }
 
 /**