2020-03-01 14:39:03 -05:00
|
|
|
import React from "react";
|
|
|
|
import { menu, palette } from "../components/icons";
|
|
|
|
import { ToolButton } from "../components/ToolButton";
|
|
|
|
import { t } from "../i18n";
|
|
|
|
import { showSelectedShapeActions } from "../element";
|
2020-03-07 10:20:38 -05:00
|
|
|
import { register } from "./register";
|
2020-04-06 03:17:13 +05:30
|
|
|
import { allowFullScreen, exitFullScreen, isFullScreen } from "../utils";
|
|
|
|
import { KEYS } from "../keys";
|
2020-04-07 16:12:10 +05:30
|
|
|
import { HelpIcon } from "../components/HelpIcon";
|
2020-03-01 14:39:03 -05:00
|
|
|
|
2020-03-07 10:20:38 -05:00
|
|
|
export const actionToggleCanvasMenu = register({
|
2020-03-01 14:39:03 -05:00
|
|
|
name: "toggleCanvasMenu",
|
|
|
|
perform: (_, appState) => ({
|
|
|
|
appState: {
|
|
|
|
...appState,
|
|
|
|
openMenu: appState.openMenu === "canvas" ? null : "canvas",
|
|
|
|
},
|
2020-03-19 14:51:05 +01:00
|
|
|
commitToHistory: false,
|
2020-03-01 14:39:03 -05:00
|
|
|
}),
|
|
|
|
PanelComponent: ({ appState, updateData }) => (
|
|
|
|
<ToolButton
|
|
|
|
type="button"
|
|
|
|
icon={menu}
|
|
|
|
aria-label={t("buttons.menu")}
|
|
|
|
onClick={updateData}
|
|
|
|
selected={appState.openMenu === "canvas"}
|
|
|
|
/>
|
|
|
|
),
|
2020-03-07 10:20:38 -05:00
|
|
|
});
|
2020-03-01 14:39:03 -05:00
|
|
|
|
2020-03-07 10:20:38 -05:00
|
|
|
export const actionToggleEditMenu = register({
|
2020-03-01 14:39:03 -05:00
|
|
|
name: "toggleEditMenu",
|
|
|
|
perform: (_elements, appState) => ({
|
|
|
|
appState: {
|
|
|
|
...appState,
|
|
|
|
openMenu: appState.openMenu === "shape" ? null : "shape",
|
|
|
|
},
|
2020-03-19 14:51:05 +01:00
|
|
|
commitToHistory: false,
|
2020-03-01 14:39:03 -05:00
|
|
|
}),
|
|
|
|
PanelComponent: ({ elements, appState, updateData }) => (
|
|
|
|
<ToolButton
|
|
|
|
visible={showSelectedShapeActions(appState, elements)}
|
|
|
|
type="button"
|
|
|
|
icon={palette}
|
|
|
|
aria-label={t("buttons.edit")}
|
|
|
|
onClick={updateData}
|
|
|
|
selected={appState.openMenu === "shape"}
|
|
|
|
/>
|
|
|
|
),
|
2020-03-07 10:20:38 -05:00
|
|
|
});
|
2020-04-06 03:17:13 +05:30
|
|
|
|
|
|
|
export const actionFullScreen = register({
|
|
|
|
name: "toggleFullScreen",
|
|
|
|
perform: () => {
|
|
|
|
if (!isFullScreen()) {
|
|
|
|
allowFullScreen();
|
|
|
|
}
|
|
|
|
if (isFullScreen()) {
|
|
|
|
exitFullScreen();
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
commitToHistory: false,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
keyTest: (event) => event.keyCode === KEYS.F_KEY_CODE,
|
|
|
|
});
|
2020-04-07 16:12:10 +05:30
|
|
|
|
|
|
|
export const actionShortcuts = register({
|
|
|
|
name: "toggleShortcuts",
|
|
|
|
perform: (_elements, appState) => {
|
|
|
|
return {
|
|
|
|
appState: {
|
|
|
|
...appState,
|
|
|
|
showShortcutsDialog: true,
|
|
|
|
},
|
|
|
|
commitToHistory: false,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
PanelComponent: ({ updateData }) => (
|
2020-04-07 16:40:37 +03:00
|
|
|
<HelpIcon title={t("shortcutsDialog.title")} onClick={updateData} />
|
2020-04-07 16:12:10 +05:30
|
|
|
),
|
|
|
|
keyTest: (event) => event.key === KEYS.QUESTION_MARK,
|
|
|
|
});
|