From aee071be6aa37f5642d41a5f84cc47654e68f66f Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Fri, 25 Nov 2022 13:05:41 +0100 Subject: [PATCH] Fix syntax extensions not loading at b oot --- plugos/syscalls/fulltext.sqlite.ts | 2 +- plugos/syscalls/store.deno.ts | 2 +- plugs/core/plugmanager.ts | 1 + server/syscalls/index.ts | 2 +- web/editor.tsx | 20 +++++++++++--------- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/plugos/syscalls/fulltext.sqlite.ts b/plugos/syscalls/fulltext.sqlite.ts index 4a6346a..fd3fac7 100644 --- a/plugos/syscalls/fulltext.sqlite.ts +++ b/plugos/syscalls/fulltext.sqlite.ts @@ -15,7 +15,7 @@ export async function ensureFTSTable( `CREATE VIRTUAL TABLE ${tableName} USING fts5(key, value);`, ); - console.log(`Created fts5 table ${tableName}`); + // console.log(`Created fts5 table ${tableName}`); } } diff --git a/plugos/syscalls/store.deno.ts b/plugos/syscalls/store.deno.ts index 59170d1..e1b2b90 100644 --- a/plugos/syscalls/store.deno.ts +++ b/plugos/syscalls/store.deno.ts @@ -21,7 +21,7 @@ export async function ensureTable(db: AsyncSQLite, tableName: string) { await db.execute( `CREATE TABLE ${tableName} (key STRING PRIMARY KEY, value TEXT);`, ); - console.log(`Created table ${tableName}`); + // console.log(`Created table ${tableName}`); } } diff --git a/plugs/core/plugmanager.ts b/plugs/core/plugmanager.ts index 9230ecd..e0b12fa 100644 --- a/plugs/core/plugmanager.ts +++ b/plugs/core/plugmanager.ts @@ -49,6 +49,7 @@ export async function addPlugCommand() { await editor.navigate("PLUGS"); await system.invokeFunction("server", "updatePlugs"); await editor.flashNotification("Plug added!"); + system.reloadPlugs(); } export async function updatePlugs() { diff --git a/server/syscalls/index.ts b/server/syscalls/index.ts index 903b66b..b442cf0 100644 --- a/server/syscalls/index.ts +++ b/server/syscalls/index.ts @@ -28,7 +28,7 @@ export async function ensureTable(db: AsyncSQLite): Promise { await db.execute( `CREATE INDEX ${tableName}_idx ON ${tableName}(key);`, ); - console.log(`Created table ${tableName}`); + // console.log(`Created table ${tableName}`); } } diff --git a/web/editor.tsx b/web/editor.tsx index a04805c..2f2f667 100644 --- a/web/editor.tsx +++ b/web/editor.tsx @@ -439,6 +439,7 @@ export class Editor { } // deno-lint-ignore no-this-alias const editor = this; + return EditorState.create({ doc: this.collabState ? this.collabState.ytext.toString() : text, extensions: [ @@ -577,16 +578,17 @@ export class Editor { rebuildEditorState() { const editorView = this.editorView; console.log("Rebuilding editor state"); + + // Load all syntax extensions + this.mdExtensions = loadMarkdownExtensions(this.system); + // And reload the syscalls to use the new syntax extensions + this.system.registerSyscalls( + [], + markdownSyscalls(buildMarkdown(this.mdExtensions)), + ); + if (editorView && this.currentPage) { - console.log("Getting all syntax extensions"); - this.mdExtensions = loadMarkdownExtensions(this.system); - - // And reload the syscalls to use the new syntax extensions - this.system.registerSyscalls( - [], - markdownSyscalls(buildMarkdown(this.mdExtensions)), - ); - + // And update the editor if a page is loaded this.saveState(this.currentPage); editorView.setState(