c99e81678b
* hide zen mode when formFactor = phone * tool bar fixes: icon and width * view mode * fix lint * add exit-view-mode button --------- Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
37 lines
973 B
TypeScript
37 lines
973 B
TypeScript
import { CODES, KEYS } from "@excalidraw/common";
|
|
|
|
import { CaptureUpdateAction } from "@excalidraw/element";
|
|
|
|
import { coffeeIcon } from "../components/icons";
|
|
|
|
import { register } from "./register";
|
|
|
|
export const actionToggleZenMode = register({
|
|
name: "zenMode",
|
|
label: "buttons.zenMode",
|
|
icon: coffeeIcon,
|
|
viewMode: true,
|
|
trackEvent: {
|
|
category: "canvas",
|
|
predicate: (appState) => !appState.zenModeEnabled,
|
|
},
|
|
perform(elements, appState) {
|
|
return {
|
|
appState: {
|
|
...appState,
|
|
zenModeEnabled: !this.checked!(appState),
|
|
},
|
|
captureUpdate: CaptureUpdateAction.EVENTUALLY,
|
|
};
|
|
},
|
|
checked: (appState) => appState.zenModeEnabled,
|
|
predicate: (elements, appState, appProps, app) => {
|
|
return (
|
|
app.editorInterface.formFactor !== "phone" &&
|
|
typeof appProps.zenModeEnabled === "undefined"
|
|
);
|
|
},
|
|
keyTest: (event) =>
|
|
!event[KEYS.CTRL_OR_CMD] && event.altKey && event.code === CODES.Z,
|
|
});
|