add: cleaner ui, prior view check, audio element, rendering fixes
This commit is contained in:
parent
f215d038b3
commit
cacd992f53
7 changed files with 320 additions and 57 deletions
|
@ -147,6 +147,19 @@ globalThis.tab_editor = () => {
|
|||
}
|
||||
};
|
||||
|
||||
globalThis.get_preview = async () => {
|
||||
return await (
|
||||
await fetch("/api/v1/render", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
content: globalThis.editor.getValue(),
|
||||
metadata: globalThis.metadata_editor.getValue(),
|
||||
}),
|
||||
})
|
||||
).text();
|
||||
};
|
||||
|
||||
globalThis.tab_preview = async () => {
|
||||
if (
|
||||
!document
|
||||
|
@ -157,16 +170,7 @@ globalThis.tab_preview = async () => {
|
|||
}
|
||||
|
||||
// render
|
||||
const res = await (
|
||||
await fetch("/api/v1/render", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
content: globalThis.editor.getValue(),
|
||||
metadata: globalThis.metadata_editor.getValue(),
|
||||
}),
|
||||
})
|
||||
).text();
|
||||
const res = await get_preview();
|
||||
|
||||
document.getElementById("preview_tab").innerHTML = res;
|
||||
hljs.highlightAll();
|
||||
|
@ -366,3 +370,24 @@ setTimeout(() => {
|
|||
// run initial hash check
|
||||
hash_check(window.location.hash);
|
||||
}, 150);
|
||||
|
||||
globalThis.submitter_load = (submitter) => {
|
||||
return {
|
||||
load() {
|
||||
submitter.querySelector("[ui_ident=text]").classList.add("hidden");
|
||||
submitter
|
||||
.querySelector("[ui_ident=loader]")
|
||||
.classList.remove("hidden");
|
||||
submitter.setAttribute("disabled", "true");
|
||||
},
|
||||
failed() {
|
||||
submitter
|
||||
.querySelector("[ui_ident=text]")
|
||||
.classList.remove("hidden");
|
||||
submitter
|
||||
.querySelector("[ui_ident=loader]")
|
||||
.classList.add("hidden");
|
||||
submitter.removeAttribute("disabled");
|
||||
},
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue