[fix] zoom shortcuts (#323)
* Adds overrides for zoom in / out / reset commands * Add reset command, numpad keys * Remove unused shortcuts * Update package.json
This commit is contained in:
parent
8531971896
commit
fe831c325d
3 changed files with 63 additions and 15 deletions
|
@ -51,10 +51,47 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"keybindings": [
|
||||||
|
{
|
||||||
|
"key": "cmd+numpad_add",
|
||||||
|
"title": "Zoom In",
|
||||||
|
"command": "tldraw.tldr.zoomIn",
|
||||||
|
"category": "tldraw",
|
||||||
|
"enablement": "resourceExtname == .tldr"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "cmd+=",
|
||||||
|
"title": "Zoom In",
|
||||||
|
"command": "tldraw.tldr.zoomIn",
|
||||||
|
"category": "tldraw",
|
||||||
|
"enablement": "resourceExtname == .tldr"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "cmd+numpad_subtract",
|
||||||
|
"title": "Zoom Out",
|
||||||
|
"command": "tldraw.tldr.zoomOut",
|
||||||
|
"category": "tldraw",
|
||||||
|
"enablement": "resourceExtname == .tldr"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "cmd+-",
|
||||||
|
"title": "Zoom Out",
|
||||||
|
"command": "tldraw.tldr.zoomOut",
|
||||||
|
"category": "tldraw",
|
||||||
|
"enablement": "resourceExtname == .tldr"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "cmd+numpad0",
|
||||||
|
"title": "Zoom Out",
|
||||||
|
"command": "tldraw.tldr.resetZoom",
|
||||||
|
"category": "tldraw",
|
||||||
|
"enablement": "resourceExtname == .tldr"
|
||||||
|
}
|
||||||
|
],
|
||||||
"commands": [
|
"commands": [
|
||||||
{
|
{
|
||||||
"command": "tldraw.tldr.new",
|
"command": "tldraw.tldr.new",
|
||||||
"title": "New tldraw File",
|
"title": "New File",
|
||||||
"category": "tldraw"
|
"category": "tldraw"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -31,6 +31,18 @@ export class TldrawEditorProvider implements vscode.CustomTextEditorProvider {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
vscode.commands.registerCommand('tldraw.tldr.zoomIn', () => {
|
||||||
|
// Noop
|
||||||
|
})
|
||||||
|
|
||||||
|
vscode.commands.registerCommand('tldraw.tldr.zoomOut', () => {
|
||||||
|
// Noop
|
||||||
|
})
|
||||||
|
|
||||||
|
vscode.commands.registerCommand('tldraw.tldr.resetZoom', () => {
|
||||||
|
// Noop
|
||||||
|
})
|
||||||
|
|
||||||
// Register our editor provider, indicating to VS Code that we can
|
// Register our editor provider, indicating to VS Code that we can
|
||||||
// handle files with the .tldr extension.
|
// handle files with the .tldr extension.
|
||||||
return vscode.window.registerCustomEditorProvider(
|
return vscode.window.registerCustomEditorProvider(
|
||||||
|
|
|
@ -226,10 +226,9 @@ export function useKeyboardShortcuts(ref: React.RefObject<HTMLDivElement>) {
|
||||||
// Camera
|
// Camera
|
||||||
|
|
||||||
useHotkeys(
|
useHotkeys(
|
||||||
'ctrl+=,⌘+=',
|
'ctrl+=,⌘+=,ctrl+num_subtract,⌘+num_subtract',
|
||||||
(e) => {
|
(e) => {
|
||||||
if (!canHandleEvent()) return
|
if (!canHandleEvent()) return
|
||||||
|
|
||||||
app.zoomIn()
|
app.zoomIn()
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
},
|
},
|
||||||
|
@ -238,7 +237,7 @@ export function useKeyboardShortcuts(ref: React.RefObject<HTMLDivElement>) {
|
||||||
)
|
)
|
||||||
|
|
||||||
useHotkeys(
|
useHotkeys(
|
||||||
'ctrl+-,⌘+-',
|
'ctrl+-,⌘+-,ctrl+num_add,⌘+num_add',
|
||||||
(e) => {
|
(e) => {
|
||||||
if (!canHandleEvent()) return
|
if (!canHandleEvent()) return
|
||||||
|
|
||||||
|
@ -249,6 +248,16 @@ export function useKeyboardShortcuts(ref: React.RefObject<HTMLDivElement>) {
|
||||||
[app]
|
[app]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
useHotkeys(
|
||||||
|
'shift+0,ctrl+numpad_0,⌘+numpad_0',
|
||||||
|
() => {
|
||||||
|
if (!canHandleEvent()) return
|
||||||
|
app.resetZoom()
|
||||||
|
},
|
||||||
|
undefined,
|
||||||
|
[app]
|
||||||
|
)
|
||||||
|
|
||||||
useHotkeys(
|
useHotkeys(
|
||||||
'shift+1',
|
'shift+1',
|
||||||
() => {
|
() => {
|
||||||
|
@ -269,16 +278,6 @@ export function useKeyboardShortcuts(ref: React.RefObject<HTMLDivElement>) {
|
||||||
[app]
|
[app]
|
||||||
)
|
)
|
||||||
|
|
||||||
useHotkeys(
|
|
||||||
'shift+0',
|
|
||||||
() => {
|
|
||||||
if (!canHandleEvent()) return
|
|
||||||
app.resetZoom()
|
|
||||||
},
|
|
||||||
undefined,
|
|
||||||
[app]
|
|
||||||
)
|
|
||||||
|
|
||||||
// Duplicate
|
// Duplicate
|
||||||
|
|
||||||
useHotkeys(
|
useHotkeys(
|
||||||
|
|
Loading…
Reference in a new issue