From e5c9756cb255ecbe7ca62b0626a7a967dbba6112 Mon Sep 17 00:00:00 2001 From: PJ Date: Sat, 26 Oct 2024 01:05:11 -0400 Subject: [PATCH] Misc. bug fixes - Certain HH commands not working (#15) - Command Palette instructions not displaying correctly on newer Obsidian versions --- manifest.json | 2 +- src/hotkey-helper.ts | 28 ++++++++++++++++------------ versions.json | 2 +- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/manifest.json b/manifest.json index 6ed622d..3ea8d8b 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "hotkey-helper", "name": "Hotkey Helper", - "version": "0.3.19", + "version": "0.3.20", "minAppVersion": "1.5.8", "description": "Easily see and access any plugin's settings or hotkey assignments (and conflicts) from the Community Plugins tab", "author": "PJ Eby", diff --git a/src/hotkey-helper.ts b/src/hotkey-helper.ts index cc9b5f8..1f913f0 100644 --- a/src/hotkey-helper.ts +++ b/src/hotkey-helper.ts @@ -3,7 +3,7 @@ import { ExtraButtonComponent, Hotkey, Command, SearchComponent } from "obsidian"; import {around, serialize} from "monkey-around"; -import {defer, modalSelect, onElement} from "@ophidian/core"; +import {defer, modalSelect, onElement, use, app} from "@ophidian/core"; import "./obsidian-internals"; import "../styles.css"; @@ -66,6 +66,8 @@ export default class HotkeyHelper extends Plugin { lastTabId: string; currentViewer: Modal; + use = use.plugin(this); + onload() { const workspace = this.app.workspace, plugin = this, events = workspace as Events; this.registerEvent(events.on("plugin-settings:before-display", (settingsTab, tabId) => { @@ -120,14 +122,17 @@ export default class HotkeyHelper extends Plugin { })); const first = cmdPalette.modalEl.find(".prompt-instructions .prompt-instruction"); if (first) { - createDiv("prompt-instruction", d => { - d.createSpan({ - cls: "prompt-instruction-command", text: Keymap.compileModifiers(["Mod"])+"+↵" - }); - d.appendText(" "); - d.createSpan({text: "to configure hotkey(s)"}) - this.register(() => d.detach()); - }).insertAfter(first); + first.parentNode.insertBefore( + createDiv("prompt-instruction", d => { + d.createSpan({ + cls: "prompt-instruction-command", text: Keymap.compileModifiers(["Mod"])+"+↵" + }); + d.appendText(" "); + d.createSpan({text: "to configure hotkey(s)"}) + this.register(() => d.detach()); + }), + null + ) } } @@ -228,8 +233,7 @@ export default class HotkeyHelper extends Plugin { "Select a plugin to open its settings...", ); if (item) { - app.setting.open() - app.setting.openTabById(item.id); + this.showSettings(item.id); } } }); @@ -518,7 +522,7 @@ export default class HotkeyHelper extends Plugin { return; } - this.showSettings("community-plugins"); + if (!this.showSettings("community-plugins")) return; const remove = around(Modal.prototype, { open(old) { return function(...args) { diff --git a/versions.json b/versions.json index 443b97f..5ca3deb 100644 --- a/versions.json +++ b/versions.json @@ -1,5 +1,5 @@ { - "0.3.19": "1.5.8", + "0.3.20": "1.5.8", "0.3.18": "1.2.8", "0.3.17": "1.1.16", "0.3.16": "0.15.9",