Skip to content

Commit

Permalink
Add Setting to Change Modifier Key (as well as insitu tester)
Browse files Browse the repository at this point in the history
Fixes #4
  • Loading branch information
itsonlyjames committed Oct 11, 2024
1 parent 55c29d4 commit 0870ff0
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 5 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "quick-open",
"name": "Quick Select",
"version": "1.1.3",
"version": "1.1.4",
"minAppVersion": "0.15.0",
"description": "Quickly select items in any modal using keyboard shortcuts. Supercharge your workflow with fast, efficient item selection in Obsidian modals.",
"author": "James Alexandre",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-quick-select",
"version": "1.1.3",
"version": "1.1.4",
"description": "Allows the use of meta key plus number to quickly select and execute that item in any Obsidian modal",
"main": "main.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ export default class QuickOpen extends Plugin {
handleKeyPress(event: KeyboardEvent) {
if (
this.activeModal &&
(event.metaKey || event.ctrlKey) &&
event[this.settings.modifierKey] &&
event.key >= "1" &&
event.key <= "9"
) {
Expand Down
37 changes: 36 additions & 1 deletion src/settings.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { App, PluginSettingTab, Setting } from "obsidian";
import QuickOpen from "./main";

type modOptions = "metaKey" | "ctrlKey" | "altKey";
export interface QuickOpenSettings {
stackTabsInPopout: boolean;
modifierKey: modOptions;
}

export const DEFAULT_SETTINGS: QuickOpenSettings = {
stackTabsInPopout: true,
modifierKey: "metaKey",
};

export class QuickOpenSettingTab extends PluginSettingTab {
Expand All @@ -21,7 +24,39 @@ export class QuickOpenSettingTab extends PluginSettingTab {
const { containerEl } = this;
containerEl.empty();

containerEl.createEl("h2", { text: "Quick Select Settings" });
containerEl.createEl("h1", { text: "Quick Select Settings" });

const keyDisplay = containerEl.createSpan();
keyDisplay.setText(" (press key)");

document.addEventListener("keydown", (event) => {
if (event.metaKey || event.ctrlKey || event.altKey)
keyDisplay.setText(event.key);
});

new Setting(containerEl)
.setName("Modifier key")
.setDesc(
createFragment((frag) => {
frag.appendText("Choose the key that activates Quick Select: ");
frag.append(keyDisplay);
}),
)
.addDropdown((dropdown) =>
dropdown
.addOptions({
metaKey: "Meta",
ctrlKey: "Control",
altKey: "Alt",
})
.setValue(this.plugin.settings.modifierKey)
.onChange(async (value: modOptions) => {
this.plugin.settings.modifierKey = value;
await this.plugin.saveSettings();
}),
);

containerEl.createEl("h2", { text: "Miscellaneous" });

new Setting(containerEl)
.setName("Stack Tabs in Popout Windows")
Expand Down
3 changes: 2 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"1.1.0": "0.15.0",
"1.1.1": "0.15.0",
"1.1.2": "0.15.0",
"1.1.3": "0.15.0"
"1.1.3": "0.15.0",
"1.1.4": "0.15.0"
}

0 comments on commit 0870ff0

Please sign in to comment.