Selaa lähdekoodia

[fix] zoom shortcuts (#323)

* Adds overrides for zoom in / out / reset commands

* Add reset command, numpad keys

* Remove unused shortcuts

* Update package.json
main
Steve Ruiz 3 vuotta sitten
vanhempi
commit
fe831c325d
No account linked to committer's email address

+ 39
- 2
apps/vscode/extension/package.json Näytä tiedosto

@@ -51,10 +51,47 @@
51 51
 				]
52 52
 			}
53 53
 		],
54
+		"keybindings": [
55
+			{
56
+				"key": "cmd+numpad_add",
57
+				"title": "Zoom In",
58
+				"command": "tldraw.tldr.zoomIn",
59
+				"category": "tldraw",
60
+				"enablement": "resourceExtname == .tldr"
61
+			},
62
+			{
63
+				"key": "cmd+=",
64
+				"title": "Zoom In",
65
+				"command": "tldraw.tldr.zoomIn",
66
+				"category": "tldraw",
67
+				"enablement": "resourceExtname == .tldr"
68
+			},
69
+			{
70
+				"key": "cmd+numpad_subtract",
71
+				"title": "Zoom Out",
72
+				"command": "tldraw.tldr.zoomOut",
73
+				"category": "tldraw",
74
+				"enablement": "resourceExtname == .tldr"
75
+			},
76
+			{
77
+				"key": "cmd+-",
78
+				"title": "Zoom Out",
79
+				"command": "tldraw.tldr.zoomOut",
80
+				"category": "tldraw",
81
+				"enablement": "resourceExtname == .tldr"
82
+			},
83
+			{
84
+				"key": "cmd+numpad0",
85
+				"title": "Zoom Out",
86
+				"command": "tldraw.tldr.resetZoom",
87
+				"category": "tldraw",
88
+				"enablement": "resourceExtname == .tldr"
89
+			}
90
+		],
54 91
 		"commands": [
55 92
 			{
56 93
 				"command": "tldraw.tldr.new",
57
-				"title": "New tldraw File",
94
+				"title": "New File",
58 95
 				"category": "tldraw"
59 96
 			}
60 97
 		]
@@ -82,4 +119,4 @@
82 119
 		"vsce": "^2.2.0"
83 120
 	},
84 121
 	"gitHead": "325008ff82bd27b63d625ad1b760f8871fb71af9"
85
-}
122
+}

+ 12
- 0
apps/vscode/extension/src/TldrawEditorProvider.ts Näytä tiedosto

@@ -31,6 +31,18 @@ export class TldrawEditorProvider implements vscode.CustomTextEditorProvider {
31 31
       )
32 32
     })
33 33
 
34
+    vscode.commands.registerCommand('tldraw.tldr.zoomIn', () => {
35
+      // Noop
36
+    })
37
+
38
+    vscode.commands.registerCommand('tldraw.tldr.zoomOut', () => {
39
+      // Noop
40
+    })
41
+
42
+    vscode.commands.registerCommand('tldraw.tldr.resetZoom', () => {
43
+      // Noop
44
+    })
45
+
34 46
     // Register our editor provider, indicating to VS Code that we can
35 47
     // handle files with the .tldr extension.
36 48
     return vscode.window.registerCustomEditorProvider(

+ 8
- 9
packages/tldraw/src/hooks/useKeyboardShortcuts.tsx Näytä tiedosto

@@ -226,10 +226,9 @@ export function useKeyboardShortcuts(ref: React.RefObject<HTMLDivElement>) {
226 226
   // Camera
227 227
 
228 228
   useHotkeys(
229
-    'ctrl+=,⌘+=',
229
+    'ctrl+=,⌘+=,ctrl+num_subtract,⌘+num_subtract',
230 230
     (e) => {
231 231
       if (!canHandleEvent()) return
232
-
233 232
       app.zoomIn()
234 233
       e.preventDefault()
235 234
     },
@@ -238,7 +237,7 @@ export function useKeyboardShortcuts(ref: React.RefObject<HTMLDivElement>) {
238 237
   )
239 238
 
240 239
   useHotkeys(
241
-    'ctrl+-,⌘+-',
240
+    'ctrl+-,⌘+-,ctrl+num_add,⌘+num_add',
242 241
     (e) => {
243 242
       if (!canHandleEvent()) return
244 243
 
@@ -250,30 +249,30 @@ export function useKeyboardShortcuts(ref: React.RefObject<HTMLDivElement>) {
250 249
   )
251 250
 
252 251
   useHotkeys(
253
-    'shift+1',
252
+    'shift+0,ctrl+numpad_0,⌘+numpad_0',
254 253
     () => {
255 254
       if (!canHandleEvent()) return
256
-      app.zoomToFit()
255
+      app.resetZoom()
257 256
     },
258 257
     undefined,
259 258
     [app]
260 259
   )
261 260
 
262 261
   useHotkeys(
263
-    'shift+2',
262
+    'shift+1',
264 263
     () => {
265 264
       if (!canHandleEvent()) return
266
-      app.zoomToSelection()
265
+      app.zoomToFit()
267 266
     },
268 267
     undefined,
269 268
     [app]
270 269
   )
271 270
 
272 271
   useHotkeys(
273
-    'shift+0',
272
+    'shift+2',
274 273
     () => {
275 274
       if (!canHandleEvent()) return
276
-      app.resetZoom()
275
+      app.zoomToSelection()
277 276
     },
278 277
     undefined,
279 278
     [app]

Loading…
Peruuta
Tallenna