A privacy-first, self-hosted, fully open source personal knowledge management software, written in typescript and golang. (PERSONAL FORK)
1import {hideElements} from "../ui/hideElements";
2import {getAllModels} from "../../layout/getAll";
3import {updateOutline} from "../../editor/util";
4import {resize} from "./resize";
5
6export const setEditMode = (protyle: IProtyle, type: TEditorMode) => {
7 if (type === "preview") {
8 if (!protyle.preview.element.classList.contains("fn__none")) {
9 return;
10 }
11 protyle.preview.element.classList.remove("fn__none");
12 protyle.contentElement.classList.add("fn__none");
13 protyle.scroll?.element.classList.add("fn__none");
14 if (protyle.options.render.breadcrumb) {
15 protyle.breadcrumb?.element.classList.add("fn__none");
16 protyle.breadcrumb.toggleExit(true);
17 }
18 protyle.preview.render(protyle);
19 /// #if !MOBILE
20 updateOutline(getAllModels(), protyle, true);
21 /// #endif
22 } else if (type === "wysiwyg") {
23 if (!protyle.contentElement.classList.contains("fn__none")) {
24 return;
25 }
26 protyle.preview.element.classList.add("fn__none");
27 protyle.contentElement.classList.remove("fn__none");
28 if (protyle.options.render.scroll) {
29 protyle.scroll?.element.classList.remove("fn__none");
30 }
31 if (protyle.options.render.breadcrumb) {
32 protyle.breadcrumb?.element.classList.remove("fn__none");
33 protyle.breadcrumb.toggleExit(!protyle.block.showAll);
34 }
35 /// #if !MOBILE
36 updateOutline(getAllModels(), protyle, true);
37 /// #endif
38 resize(protyle);
39 }
40 hideElements(["gutterOnly", "toolbar", "select", "hint", "util"], protyle);
41 protyle.app.plugins.forEach(item => {
42 item.eventBus.emit("switch-protyle-mode", {protyle});
43 });
44};