fix missing preview button when editing .md gist (#259)

Co-authored-by: Dennis Sumser <dennis.sumser@schmolck.de>
This commit is contained in:
Dennis 2024-04-24 21:02:21 +02:00 committed by GitHub
parent a3a3d367ea
commit 6a8759e21e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -36,8 +36,17 @@ document.addEventListener("DOMContentLoaded", () => {
let mdpreview = dom.querySelector(".md-preview") as HTMLElement;
let formfilename = dom.querySelector<HTMLInputElement>(".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<HTMLInputElement>(".form-filename")!.onkeyup = (e) => {
formfilename!.onkeyup = (e) => {
let filename = (e.target as HTMLInputElement).value;
if (filename.endsWith(".md")) {
mdpreview!.classList.remove("hidden");