2021-02-02 02:26:42 +05:30
|
|
|
import { CODES, KEYS } from "../keys";
|
|
|
|
import { register } from "./register";
|
|
|
|
|
|
|
|
export const actionToggleViewMode = register({
|
|
|
|
name: "viewMode",
|
2022-12-11 22:57:03 +01:00
|
|
|
viewMode: true,
|
2022-03-28 14:46:40 +02:00
|
|
|
trackEvent: {
|
|
|
|
category: "canvas",
|
|
|
|
predicate: (appState) => !appState.viewModeEnabled,
|
|
|
|
},
|
2021-02-02 02:26:42 +05:30
|
|
|
perform(elements, appState) {
|
|
|
|
return {
|
|
|
|
appState: {
|
|
|
|
...appState,
|
|
|
|
viewModeEnabled: !this.checked!(appState),
|
|
|
|
},
|
|
|
|
commitToHistory: false,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
checked: (appState) => appState.viewModeEnabled,
|
|
|
|
contextItemLabel: "labels.viewMode",
|
|
|
|
keyTest: (event) =>
|
|
|
|
!event[KEYS.CTRL_OR_CMD] && event.altKey && event.code === CODES.R,
|
|
|
|
});
|