Skip to content

Commit 23f363a

Browse files
committed
Add user notification to install dependency plugin
1 parent adc99fa commit 23f363a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Plugin} from 'obsidian';
1+
import { Plugin, Notice } from 'obsidian';
22

33
declare global {
44
interface Window {
@@ -17,5 +17,9 @@ export function registerAPI(name: string, api: any, plugin: Plugin) {
1717
}
1818

1919
export function pluginApi(name: string) {
20-
return window['PluginApi'][name];
20+
if ('PluginApi' in window && name in window['PluginApi']) {
21+
return window['PluginApi'][name];
22+
} else {
23+
new Notice(`Plugin ${name} not found. Please install ${name} first.`)
24+
}
2125
}

0 commit comments

Comments
 (0)