From 62ed707c5971d352b7de1edd90440ae7f7ddeade Mon Sep 17 00:00:00 2001 From: Miika Alonen Date: Mon, 18 Dec 2023 17:59:28 +0200 Subject: [PATCH] Load documentation from fragment links --- src/Documentation.ts | 9 ++++++--- src/InterfaceLogic.ts | 12 +++++------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/Documentation.ts b/src/Documentation.ts index 2253066..8c83cec 100644 --- a/src/Documentation.ts +++ b/src/Documentation.ts @@ -222,13 +222,16 @@ export const updateDocumentationContent = (app: Editor, bindings: any) => { auto_detection: false }), ...bindings], }); - console.log(app.currentDocumentationPane); + + if(Object.keys(app.docs).length === 0) { + app.docs = documentation_factory(app); + } - function _update_and_assign(callback: Function) { + function _update_and_assign(callback: Function) { const converted_markdown = converter.makeHtml( app.docs[app.currentDocumentationPane], ); - callback(converted_markdown) + callback(converted_markdown) } _update_and_assign((e: string)=> { let display_content = e === undefined ? loading_message : e; diff --git a/src/InterfaceLogic.ts b/src/InterfaceLogic.ts index a252077..7b5dec8 100644 --- a/src/InterfaceLogic.ts +++ b/src/InterfaceLogic.ts @@ -537,18 +537,16 @@ export const installInterfaceLogic = (app: Editor) => { let element = document.getElementById(name); if (element) { element.addEventListener("click", async () => { + // Clear query params & set id as hash paremeter for uri + window.history.replaceState({}, "", window.location.pathname); + window.location.hash = e; + app.docs = documentation_factory(app); + app.currentDocumentationPane = e; if (name !== "docs_sample_list") { - app.currentDocumentationPane = e; - // Clear query params - window.history.replaceState({}, "", window.location.pathname); - // Set id as hash paremeter for uri - window.location.hash = e; updateDocumentationContent(app, app.bindings); } else { console.log("Loading samples!"); await loadSamples().then(() => { - app.docs = documentation_factory(app); - app.currentDocumentationPane = e; updateDocumentationContent(app, app.bindings); }); }