Skip to content

Commit 3909604

Browse files
Added zoom to selection command
1 parent 4377eb7 commit 3909604

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ All features can be enabled/disabled in the settings.
6969
## Canvas Commands
7070
- `Advanced Canvas: Create text node`
7171
- Create a new text node
72+
- `Advanced Canvas: Zoom to selection`
73+
- Zoom to the bounding box of the selected nodes
7274
- `Advanced Canvas: Clone node up/down/left/right`
7375
- Clone the selected node in the direction of the arrow keys
7476
- The cloned node will have the same dimensions and color as the original node

src/@types/Canvas.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export interface Canvas {
4545

4646
getViewportBBox(): BBox
4747
zoomToBbox(bbox: BBox): void
48+
zoomToSelection(): void
4849

4950
undo(): void
5051
redo(): void

src/canvas-extensions/commands-canvas-extension.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ export default class CommandsCanvasExtension {
2929
)
3030
})
3131

32+
this.plugin.addCommand({
33+
id: 'zoom-to-selection',
34+
name: 'Zoom to selection',
35+
checkCallback: CanvasHelper.canvasCommand(
36+
this.plugin,
37+
(canvas: Canvas) => canvas.selection.size > 0,
38+
(canvas: Canvas) => canvas.zoomToSelection()
39+
)
40+
})
41+
3242
for (const direction of DRIECTIONS) {
3343
this.plugin.addCommand({
3444
id: `clone-node-${direction}`,

0 commit comments

Comments
 (0)