From 6a8759e21e39a05c77514792383c4c3df49e5eff Mon Sep 17 00:00:00 2001 From: Dennis <46405520+demsr@users.noreply.github.com> Date: Wed, 24 Apr 2024 21:02:21 +0200 Subject: [PATCH] fix missing preview button when editing .md gist (#259) Co-authored-by: Dennis Sumser --- public/editor.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/public/editor.ts b/public/editor.ts index 04d2814..07c0940 100644 --- a/public/editor.ts +++ b/public/editor.ts @@ -36,8 +36,17 @@ document.addEventListener("DOMContentLoaded", () => { let mdpreview = dom.querySelector(".md-preview") as HTMLElement; + let formfilename = dom.querySelector(".form-filename"); + + // check if file ends with .md on pageload + if (formfilename!.value.endsWith(".md")) { + mdpreview!.classList.remove("hidden"); + } else { + mdpreview!.classList.add("hidden"); + } + // event if the filename ends with .md; trigger event - dom.querySelector(".form-filename")!.onkeyup = (e) => { + formfilename!.onkeyup = (e) => { let filename = (e.target as HTMLInputElement).value; if (filename.endsWith(".md")) { mdpreview!.classList.remove("hidden");