From 171aaf5372ea4f79ea2d4aaa71a6a37707c8c136 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Thu, 21 Sep 2023 16:33:55 +0800 Subject: [PATCH] :art: add loading to preview --- app/src/protyle/preview/index.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/protyle/preview/index.ts b/app/src/protyle/preview/index.ts index 9bffe7067..9eb4bcfc9 100644 --- a/app/src/protyle/preview/index.ts +++ b/app/src/protyle/preview/index.ts @@ -155,7 +155,13 @@ export class Preview { if (this.element.style.display === "none") { return; } - + let loadingElement = this.element.querySelector(".fn__loading"); + if (!loadingElement) { + this.element.insertAdjacentHTML("beforeend", `
+ +
`); + loadingElement = this.element.querySelector(".fn__loading"); + } this.mdTimeoutId = window.setTimeout(() => { fetchPost("/api/export/preview", { id: protyle.block.parentID || protyle.options.blockId, @@ -183,6 +189,7 @@ export class Preview { } }); /// #endif + loadingElement.remove(); }); }, protyle.options.preview.delay); }