2022-05-26 15:18:53 +08:00
|
|
|
import {hideElements} from "../ui/hideElements";
|
2023-06-18 00:36:51 +08:00
|
|
|
import {getAllModels} from "../../layout/getAll";
|
|
|
|
|
import {updateOutline} from "../../editor/util";
|
2023-09-13 12:05:57 +08:00
|
|
|
import {resize} from "./resize";
|
2022-05-26 15:18:53 +08:00
|
|
|
|
|
|
|
|
export const setEditMode = (protyle: IProtyle, type: TEditorMode) => {
|
|
|
|
|
if (type === "preview") {
|
|
|
|
|
if (!protyle.preview.element.classList.contains("fn__none")) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
protyle.preview.element.classList.remove("fn__none");
|
|
|
|
|
protyle.contentElement.classList.add("fn__none");
|
|
|
|
|
protyle.scroll?.element.classList.add("fn__none");
|
2022-08-31 01:14:45 +08:00
|
|
|
if (protyle.options.render.breadcrumb) {
|
|
|
|
|
protyle.breadcrumb?.element.classList.add("fn__none");
|
2023-05-17 19:14:21 +08:00
|
|
|
protyle.breadcrumb.toggleExit(true);
|
2022-08-31 01:14:45 +08:00
|
|
|
}
|
2022-05-26 15:18:53 +08:00
|
|
|
protyle.preview.render(protyle);
|
2024-09-18 12:16:58 +08:00
|
|
|
/// #if !MOBILE
|
|
|
|
|
updateOutline(getAllModels(), protyle, true);
|
|
|
|
|
/// #endif
|
2022-05-26 15:18:53 +08:00
|
|
|
} else if (type === "wysiwyg") {
|
|
|
|
|
if (!protyle.contentElement.classList.contains("fn__none")) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
protyle.preview.element.classList.add("fn__none");
|
|
|
|
|
protyle.contentElement.classList.remove("fn__none");
|
2022-06-10 14:47:57 +08:00
|
|
|
if (protyle.options.render.scroll) {
|
|
|
|
|
protyle.scroll?.element.classList.remove("fn__none");
|
|
|
|
|
}
|
2022-08-31 01:14:45 +08:00
|
|
|
if (protyle.options.render.breadcrumb) {
|
|
|
|
|
protyle.breadcrumb?.element.classList.remove("fn__none");
|
2023-05-17 19:14:21 +08:00
|
|
|
protyle.breadcrumb.toggleExit(!protyle.block.showAll);
|
2022-08-31 01:14:45 +08:00
|
|
|
}
|
2023-06-18 21:18:14 +08:00
|
|
|
/// #if !MOBILE
|
2023-06-18 00:36:51 +08:00
|
|
|
updateOutline(getAllModels(), protyle, true);
|
2023-06-18 21:18:14 +08:00
|
|
|
/// #endif
|
2023-09-13 12:05:57 +08:00
|
|
|
resize(protyle);
|
2022-05-26 15:18:53 +08:00
|
|
|
}
|
2024-01-25 13:12:12 +08:00
|
|
|
hideElements(["gutterOnly", "toolbar", "select", "hint", "util"], protyle);
|
2022-05-26 15:18:53 +08:00
|
|
|
};
|