Skip to content

Commit 97c8eac

Browse files
committed
more comments
1 parent 0278a4c commit 97c8eac

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

exampleVault/Test.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,13 @@ component.registerEvent(unloadCb);
158158
159159
// return the reactive component
160160
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+
```

jsEngine/engine/JsExecution.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,47 @@ export type JsFunc = (...args: unknown[]) => Promise<unknown>;
1717
* Context provided to a {@link JsExecution}.
1818
*/
1919
export interface JsExecutionContext {
20+
/**
21+
* The file that the execution was triggered from.
22+
*/
2023
file: TFile;
24+
/**
25+
* The metadata of the file that the execution was triggered from.
26+
*/
2127
metadata: CachedMetadata | null;
28+
/**
29+
* Currently unused.
30+
*/
2231
line: number;
2332
}
2433

2534
/**
2635
* Global variables provided to a {@link JsExecution}.
2736
*/
2837
export interface JsExecutionGlobals {
38+
/**
39+
* Reference to the obsidian [app](https://docs.obsidian.md/Reference/TypeScript+API/App) (obsidian API).
40+
*/
2941
app: App;
42+
/**
43+
* Reference to this plugins API.
44+
*/
3045
engine: API;
46+
/**
47+
* Obsidian [component](https://docs.obsidian.md/Reference/TypeScript+API/Component) for lifecycle management.
48+
*/
3149
component: Component;
50+
/**
51+
* The context provided. This can be undefined and extended by other properties.
52+
*/
3253
context: (JsExecutionContext | undefined) & Record<string, unknown>;
54+
/**
55+
* The container element that the execution can render to. This can be undefined.
56+
*/
3357
container: HTMLElement | undefined;
58+
/**
59+
* The entire obsidian module, e.g. a notice can be constructed like this: `new obsidian.Notice('Hello World')`.
60+
*/
3461
obsidian: typeof Obsidian;
3562
}
3663

0 commit comments

Comments
 (0)