Auto reindexing on version upgrades
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
import type { ParseTree } from "@silverbulletmd/common/tree";
|
||||
|
||||
export type AppEvent = "page:click" | "page:complete" | "page:load";
|
||||
export type AppEvent =
|
||||
| "page:click"
|
||||
| "page:complete"
|
||||
| "page:load"
|
||||
| "editor:init"
|
||||
| "plugs:loaded";
|
||||
|
||||
export type ClickEvent = {
|
||||
page: string;
|
||||
|
||||
+13
-1
@@ -234,6 +234,8 @@ export class Editor {
|
||||
await this.pageNavigator.navigate("index");
|
||||
}
|
||||
await this.reloadPlugs();
|
||||
|
||||
await this.dispatchAppEvent("editor:init");
|
||||
}
|
||||
|
||||
async save(immediate: boolean = false): Promise<void> {
|
||||
@@ -459,11 +461,12 @@ export class Editor {
|
||||
await this.system.unloadAll();
|
||||
console.log("(Re)loading plugs");
|
||||
for (let pageInfo of this.space.listPlugs()) {
|
||||
console.log("Loading plug", pageInfo.name);
|
||||
// console.log("Loading plug", pageInfo.name);
|
||||
let { text } = await this.space.readPage(pageInfo.name);
|
||||
await this.system.load(JSON.parse(text), createIFrameSandbox);
|
||||
}
|
||||
this.rebuildEditorState();
|
||||
await this.dispatchAppEvent("plugs:loaded");
|
||||
}
|
||||
|
||||
rebuildEditorState() {
|
||||
@@ -725,6 +728,15 @@ export class Editor {
|
||||
);
|
||||
}
|
||||
|
||||
async runCommandByName(name: string) {
|
||||
const cmd = this.viewState.commands.get(name);
|
||||
if (cmd) {
|
||||
await cmd.run();
|
||||
} else {
|
||||
throw new Error(`Command ${name} not found`);
|
||||
}
|
||||
}
|
||||
|
||||
render(container: ReactDOM.Container) {
|
||||
const ViewComponent = this.ViewComponent.bind(this);
|
||||
ReactDOM.render(<ViewComponent />, container);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { SysCallMapping } from "@plugos/plugos/system";
|
||||
import type { Editor } from "../editor";
|
||||
import { version } from "../package.json";
|
||||
|
||||
export function systemSyscalls(editor: Editor): SysCallMapping {
|
||||
return {
|
||||
@@ -19,6 +20,12 @@ export function systemSyscalls(editor: Editor): SysCallMapping {
|
||||
|
||||
return editor.space.invokeFunction(ctx.plug, env, name, args);
|
||||
},
|
||||
"system.invokeCommand": async (ctx, name: string) => {
|
||||
return editor.runCommandByName(name);
|
||||
},
|
||||
"system.getVersion": async () => {
|
||||
return version;
|
||||
},
|
||||
"system.reloadPlugs": async () => {
|
||||
return editor.reloadPlugs();
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user