diff --git a/src/manager/commands/leftRibbonManager.ts b/src/manager/commands/leftRibbonManager.ts index 26e1990..8de4122 100644 --- a/src/manager/commands/leftRibbonManager.ts +++ b/src/manager/commands/leftRibbonManager.ts @@ -39,7 +39,7 @@ export default class LeftRibbonManager extends CommandManagerBase { // @ts-expect-error const nativeAction = this.plugin.app.workspace.leftRibbon.items.find( // @ts-expect-error - (i) => i.icon === pair.icon && i.name === i.name + (i) => i.icon === pair.icon && i.name === pair.name ); if (nativeAction) { nativeAction.buttonEl.style.color = @@ -62,13 +62,13 @@ export default class LeftRibbonManager extends CommandManagerBase { // @ts-expect-error const nativeAction = this.plugin.app.workspace.leftRibbon.items.find( // @ts-expect-error - (i) => i.icon === pair.icon && i.name === i.name + (i) => i.icon === pair.icon && i.name === pair.name ); if (nativeAction) { nativeAction.buttonEl.remove(); } // @ts-expect-error - app.workspace.leftRibbon.items.remove(nativeAction); + this.plugin.app.workspace.leftRibbon.items.remove(nativeAction); } public reorder(): void { diff --git a/src/manager/commands/menuManager.ts b/src/manager/commands/menuManager.ts index 690ad23..0178abd 100644 --- a/src/manager/commands/menuManager.ts +++ b/src/manager/commands/menuManager.ts @@ -163,8 +163,7 @@ abstract class Base extends CommandManagerBase { commandList.push(pair); await plugin.saveSettings(); } catch (error) { - //Do some proper handling here - console.log(error); + // User cancelled command/icon selection, nothing to do } }); }); diff --git a/src/types.ts b/src/types.ts index 2130ff5..703ed7b 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,4 +1,5 @@ import { h } from "preact"; +import { Command, PluginManifest } from "obsidian"; export enum Action { COMMAND, diff --git a/src/ui/components/commandComponent.tsx b/src/ui/components/commandComponent.tsx index 39a11d5..3b2c1f0 100644 --- a/src/ui/components/commandComponent.tsx +++ b/src/ui/components/commandComponent.tsx @@ -100,8 +100,8 @@ export default function CommandComponent({ const owningPlugin = plugin.app.plugins.manifests[owningPluginID!]; const isInternal = !owningPlugin; const isChecked = - cmd.hasOwnProperty("checkCallback") || - cmd.hasOwnProperty("editorCheckCallback"); + Object.prototype.hasOwnProperty.call(cmd, "checkCallback") || + Object.prototype.hasOwnProperty.call(cmd, "editorCheckCallback"); const modeIcon = getModeIcon(pair.mode); const modeName = pair.mode.match(/desktop|mobile|any/) diff --git a/src/ui/components/hidingViewer.tsx b/src/ui/components/hidingViewer.tsx index 783e04b..c4d552c 100644 --- a/src/ui/components/hidingViewer.tsx +++ b/src/ui/components/hidingViewer.tsx @@ -19,7 +19,7 @@ export function LeftRibbonHider({ useEffect(() => { setRibbonCommands( // @ts-expect-error - app.workspace.leftRibbon.items.map((item) => ({ + plugin.app.workspace.leftRibbon.items.map((item) => ({ name: item.title, icon: item.icon, })) diff --git a/src/util.tsx b/src/util.tsx index 95ea385..3b410e7 100644 --- a/src/util.tsx +++ b/src/util.tsx @@ -24,7 +24,7 @@ export async function chooseNewCommand( const command = await new AddCommandModal(plugin).awaitSelection(); let icon; - if (!command.hasOwnProperty("icon")) { + if (!Object.prototype.hasOwnProperty.call(command, "icon")) { icon = await new ChooseIconModal(plugin).awaitSelection(); }