mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-29 02:52:27 +08:00
24 lines
743 B
TypeScript
24 lines
743 B
TypeScript
import type FNote from "../../../entities/fnote.js";
|
|
import AbstractLauncher from "./abstract_launcher.js";
|
|
|
|
export default class ScriptLauncher extends AbstractLauncher {
|
|
constructor(launcherNote: FNote) {
|
|
super(launcherNote);
|
|
|
|
this.title(() => this.launcherNote.title)
|
|
.icon(() => this.launcherNote.getIcon())
|
|
.onClick(() => this.launch());
|
|
}
|
|
|
|
async launch() {
|
|
if (this.launcherNote.isLabelTruthy("scriptInLauncherContent")) {
|
|
await this.launcherNote.executeScript();
|
|
} else {
|
|
const script = await this.launcherNote.getRelationTarget("script");
|
|
if (script) {
|
|
await script.executeScript();
|
|
}
|
|
}
|
|
}
|
|
}
|