A privacy-first, self-hosted, fully open source personal knowledge management software, written in typescript and golang. (PERSONAL FORK)
at lambda-fork/main 37 lines 1.0 kB view raw
1import {hideElements} from "../ui/hideElements"; 2import {isSupportCSSHL} from "../render/searchMarkRender"; 3 4export const destroy = (protyle: IProtyle) => { 5 if (!protyle) { 6 return; 7 } 8 hideElements(["util"], protyle); 9 if (isSupportCSSHL()) { 10 protyle.highlight.markHL.clear(); 11 protyle.highlight.mark.clear(); 12 protyle.highlight.ranges = []; 13 protyle.highlight.rangeIndex = 0; 14 } 15 protyle.observer?.disconnect(); 16 protyle.observerLoad?.disconnect(); 17 protyle.element.classList.remove("protyle"); 18 protyle.element.removeAttribute("style"); 19 if (protyle.wysiwyg) { 20 protyle.wysiwyg.lastHTMLs = {}; 21 } 22 if (protyle.undo) { 23 protyle.undo.clear(); 24 } 25 try { 26 protyle.ws.send("closews", {}); 27 } catch (e) { 28 setTimeout(() => { 29 protyle.ws.send("closews", {}); 30 }, 10240); 31 } 32 protyle.app.plugins.forEach(item => { 33 item.eventBus.emit("destroy-protyle", { 34 protyle, 35 }); 36 }); 37};