Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to resize nodes on the canvas #50

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ interface MouseWheelZoomSettings {
initialSize: number;
modifierKey: ModifierKey;
stepSize: number;
resizeInCanvas: boolean;
}

enum ModifierKey {
Expand All @@ -20,7 +21,8 @@ enum ModifierKey {
const DEFAULT_SETTINGS: MouseWheelZoomSettings = {
modifierKey: ModifierKey.ALT,
stepSize: 25,
initialSize: 500
initialSize: 500,
resizeInCanvas: false,
}

export default class MouseWheelZoomPlugin extends Plugin {
Expand Down Expand Up @@ -94,7 +96,7 @@ export default class MouseWheelZoomPlugin extends Plugin {
this.disableScroll(currentWindow);
}

if (targetIsCanvas){
if (targetIsCanvas && this.settings.resizeInCanvas){
// seems we're trying to zoom on some canvas node.
this.handleZoomForCanvas(evt, eventTarget);
}
Expand Down Expand Up @@ -338,6 +340,17 @@ class MouseWheelZoomSettingsTab extends PluginSettingTab {
await this.plugin.saveSettings()
})
})

new Setting(containerEl)
.setName('Resize in canvas')
.setDesc('When enabled, all nodes on the Obsidian canvas can also be resized using the Modifier key')
.addToggle((toggle) => {
toggle.setValue(this.plugin.settings.resizeInCanvas)
.onChange(async (value) => {
this.plugin.settings.resizeInCanvas = value;
await this.plugin.saveSettings();
});
});
}
}

Expand Down