This commit is contained in:
Vanessa 2023-05-14 12:09:52 +08:00
parent 300a60aa45
commit 18071638cf
3 changed files with 9 additions and 17 deletions

View file

@ -243,16 +243,6 @@ export class Breadcrumb {
hideElements(["toolbar"], protyle);
fetchPost("/api/format/autoSpace", {
id: protyle.block.rootID
}, () => {
/// #if MOBILE
reloadProtyle(protyle, false);
/// #else
getAllModels().editor.forEach(item => {
if (item.editor.protyle.block.rootID === protyle.block.rootID) {
reloadProtyle(item.editor.protyle, item.editor.protyle.element.isSameNode(protyle.element));
}
});
/// #endif
});
}
}).element);

View file

@ -96,7 +96,7 @@ export class Protyle {
break;
case "addLoadding":
if (data.data === this.protyle.block.rootID) {
addLoading(this.protyle);
addLoading(this.protyle, data.msg);
}
break;
case "transactions":

View file

@ -102,21 +102,23 @@ export const initUI = (protyle: IProtyle) => {
}, {passive: false});
};
export const addLoading = (protyle: IProtyle) => {
export const addLoading = (protyle: IProtyle, msg?: string) => {
protyle.element.removeAttribute("data-loading");
setTimeout(() => {
if (protyle.element.getAttribute("data-loading") !== "finished") {
protyle.element.insertAdjacentHTML("beforeend", '<div style="background-color: var(--b3-theme-background)" class="fn__loading wysiwygLoading"><img width="48px" src="/stage/loading-pure.svg"></div>');
protyle.element.insertAdjacentHTML("beforeend", `<div style="background-color: var(--b3-theme-background);flex-direction: column;" class="fn__loading wysiwygLoading">
<img width="48px" src="/stage/loading-pure.svg">
<div style="color: var(--b3-theme-on-surface);margin-top: 8px;">${msg || ""}</div>
</div>`);
}
}, Constants.TIMEOUT_LOAD);
};
export const removeLoading = (protyle: IProtyle) => {
protyle.element.setAttribute("data-loading", "finished");
const loadingElement = protyle.element.querySelector(".wysiwygLoading");
if (loadingElement) {
loadingElement.remove();
}
protyle.element.querySelectorAll(".wysiwygLoading").forEach(item => {
item.remove();
});
};
export const setPadding = (protyle: IProtyle) => {