2023-10-29 19:49:36 +08:00
|
|
|
import {hideElements} from "../ui/hideElements";
|
|
|
|
|
|
2022-05-26 15:18:53 +08:00
|
|
|
export const destroy = (protyle: IProtyle) => {
|
|
|
|
|
if (!protyle) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-10-29 19:49:36 +08:00
|
|
|
hideElements(["util"], protyle);
|
2023-12-12 00:53:15 +08:00
|
|
|
protyle.observer?.disconnect();
|
|
|
|
|
protyle.observerLoad?.disconnect();
|
2022-05-26 15:18:53 +08:00
|
|
|
protyle.element.classList.remove("protyle");
|
|
|
|
|
protyle.element.removeAttribute("style");
|
|
|
|
|
if (protyle.wysiwyg) {
|
|
|
|
|
protyle.wysiwyg.lastHTMLs = {};
|
|
|
|
|
}
|
|
|
|
|
if (protyle.undo) {
|
|
|
|
|
protyle.undo.clear();
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
protyle.ws.send("closews", {});
|
|
|
|
|
} catch (e) {
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
protyle.ws.send("closews", {});
|
|
|
|
|
}, 10240);
|
|
|
|
|
}
|
2023-08-24 12:19:55 +08:00
|
|
|
protyle.app.plugins.forEach(item => {
|
|
|
|
|
item.eventBus.emit("destroy-protyle", {
|
|
|
|
|
protyle,
|
|
|
|
|
});
|
|
|
|
|
});
|
2022-05-26 15:18:53 +08:00
|
|
|
};
|