File tree Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -158,4 +158,13 @@ component.registerEvent(unloadCb);
158
158
159
159
// return the reactive component
160
160
return reactive;
161
- ```
161
+ ```
162
+
163
+ # Obsidian Module
164
+
165
+ ``` js-engine
166
+ const el = container.createEl("button", {text: "Click me"})
167
+ el.addEventListener("click", () => {
168
+ new obsidian.Notice("Hello")
169
+ });
170
+ ```
Original file line number Diff line number Diff line change @@ -17,20 +17,47 @@ export type JsFunc = (...args: unknown[]) => Promise<unknown>;
17
17
* Context provided to a {@link JsExecution}.
18
18
*/
19
19
export interface JsExecutionContext {
20
+ /**
21
+ * The file that the execution was triggered from.
22
+ */
20
23
file : TFile ;
24
+ /**
25
+ * The metadata of the file that the execution was triggered from.
26
+ */
21
27
metadata : CachedMetadata | null ;
28
+ /**
29
+ * Currently unused.
30
+ */
22
31
line : number ;
23
32
}
24
33
25
34
/**
26
35
* Global variables provided to a {@link JsExecution}.
27
36
*/
28
37
export interface JsExecutionGlobals {
38
+ /**
39
+ * Reference to the obsidian [app](https://docs.obsidian.md/Reference/TypeScript+API/App) (obsidian API).
40
+ */
29
41
app : App ;
42
+ /**
43
+ * Reference to this plugins API.
44
+ */
30
45
engine : API ;
46
+ /**
47
+ * Obsidian [component](https://docs.obsidian.md/Reference/TypeScript+API/Component) for lifecycle management.
48
+ */
31
49
component : Component ;
50
+ /**
51
+ * The context provided. This can be undefined and extended by other properties.
52
+ */
32
53
context : ( JsExecutionContext | undefined ) & Record < string , unknown > ;
54
+ /**
55
+ * The container element that the execution can render to. This can be undefined.
56
+ */
33
57
container : HTMLElement | undefined ;
58
+ /**
59
+ * The entire obsidian module, e.g. a notice can be constructed like this: `new obsidian.Notice('Hello World')`.
60
+ */
34
61
obsidian : typeof Obsidian ;
35
62
}
36
63
You can’t perform that action at this time.
0 commit comments