Skip to content

Commit

Permalink
Load documentation from fragment links
Browse files Browse the repository at this point in the history
  • Loading branch information
amiika committed Dec 18, 2023
1 parent 0ba7ed2 commit 62ed707
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
9 changes: 6 additions & 3 deletions src/Documentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 5 additions & 7 deletions src/InterfaceLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
Expand Down

0 comments on commit 62ed707

Please sign in to comment.