2020-02-09 09:07:34 -05:00
|
|
|
import React from "react";
|
2020-01-12 02:22:03 +04:00
|
|
|
import {
|
|
|
|
moveOneLeft,
|
|
|
|
moveOneRight,
|
|
|
|
moveAllLeft,
|
2020-01-24 12:04:54 +02:00
|
|
|
moveAllRight,
|
2020-01-12 02:22:03 +04:00
|
|
|
} from "../zindex";
|
2020-12-01 23:36:06 +02:00
|
|
|
import { KEYS, isDarwin, CODES } from "../keys";
|
2020-02-09 09:07:34 -05:00
|
|
|
import { t } from "../i18n";
|
2020-03-09 15:06:35 +02:00
|
|
|
import { getShortcutKey } from "../utils";
|
2020-03-07 10:20:38 -05:00
|
|
|
import { register } from "./register";
|
|
|
|
import {
|
2020-08-13 04:35:31 -07:00
|
|
|
SendBackwardIcon,
|
|
|
|
BringToFrontIcon,
|
|
|
|
SendToBackIcon,
|
|
|
|
BringForwardIcon,
|
2020-03-07 10:20:38 -05:00
|
|
|
} from "../components/icons";
|
2020-02-09 09:07:34 -05:00
|
|
|
|
2020-03-07 10:20:38 -05:00
|
|
|
export const actionSendBackward = register({
|
2020-01-12 02:22:03 +04:00
|
|
|
name: "sendBackward",
|
2022-03-28 14:46:40 +02:00
|
|
|
trackEvent: { category: "element" },
|
2020-01-12 02:22:03 +04:00
|
|
|
perform: (elements, appState) => {
|
|
|
|
return {
|
2020-09-11 17:06:07 +02:00
|
|
|
elements: moveOneLeft(elements, appState),
|
2020-01-24 12:04:54 +02:00
|
|
|
appState,
|
2020-03-19 14:51:05 +01:00
|
|
|
commitToHistory: true,
|
2020-01-12 02:22:03 +04:00
|
|
|
};
|
|
|
|
},
|
2020-01-21 01:14:10 +02:00
|
|
|
contextItemLabel: "labels.sendBackward",
|
2020-01-12 02:22:03 +04:00
|
|
|
keyPriority: 40,
|
2020-03-23 13:05:07 +02:00
|
|
|
keyTest: (event) =>
|
2020-12-01 23:36:06 +02:00
|
|
|
event[KEYS.CTRL_OR_CMD] &&
|
|
|
|
!event.shiftKey &&
|
|
|
|
event.code === CODES.BRACKET_LEFT,
|
2020-08-13 04:35:31 -07:00
|
|
|
PanelComponent: ({ updateData, appState }) => (
|
2020-02-09 09:07:34 -05:00
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
className="zIndexButton"
|
2020-03-07 10:20:38 -05:00
|
|
|
onClick={() => updateData(null)}
|
2020-04-07 14:39:06 +03:00
|
|
|
title={`${t("labels.sendBackward")} — ${getShortcutKey("CtrlOrCmd+[")}`}
|
2020-02-09 09:07:34 -05:00
|
|
|
>
|
2021-03-13 18:58:06 +05:30
|
|
|
<SendBackwardIcon theme={appState.theme} />
|
2020-02-09 09:07:34 -05:00
|
|
|
</button>
|
|
|
|
),
|
2020-03-07 10:20:38 -05:00
|
|
|
});
|
2020-01-12 02:22:03 +04:00
|
|
|
|
2020-03-07 10:20:38 -05:00
|
|
|
export const actionBringForward = register({
|
2020-01-12 02:22:03 +04:00
|
|
|
name: "bringForward",
|
2022-03-28 14:46:40 +02:00
|
|
|
trackEvent: { category: "element" },
|
2020-01-12 02:22:03 +04:00
|
|
|
perform: (elements, appState) => {
|
|
|
|
return {
|
2020-09-11 17:06:07 +02:00
|
|
|
elements: moveOneRight(elements, appState),
|
2020-01-24 12:04:54 +02:00
|
|
|
appState,
|
2020-03-19 14:51:05 +01:00
|
|
|
commitToHistory: true,
|
2020-01-12 02:22:03 +04:00
|
|
|
};
|
|
|
|
},
|
2020-01-21 01:14:10 +02:00
|
|
|
contextItemLabel: "labels.bringForward",
|
2020-01-12 02:22:03 +04:00
|
|
|
keyPriority: 40,
|
2020-03-23 13:05:07 +02:00
|
|
|
keyTest: (event) =>
|
2020-12-01 23:36:06 +02:00
|
|
|
event[KEYS.CTRL_OR_CMD] &&
|
|
|
|
!event.shiftKey &&
|
|
|
|
event.code === CODES.BRACKET_RIGHT,
|
2020-08-13 04:35:31 -07:00
|
|
|
PanelComponent: ({ updateData, appState }) => (
|
2020-02-09 09:07:34 -05:00
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
className="zIndexButton"
|
2020-03-07 10:20:38 -05:00
|
|
|
onClick={() => updateData(null)}
|
2020-04-07 14:39:06 +03:00
|
|
|
title={`${t("labels.bringForward")} — ${getShortcutKey("CtrlOrCmd+]")}`}
|
2020-02-09 09:07:34 -05:00
|
|
|
>
|
2021-03-13 18:58:06 +05:30
|
|
|
<BringForwardIcon theme={appState.theme} />
|
2020-02-09 09:07:34 -05:00
|
|
|
</button>
|
|
|
|
),
|
2020-03-07 10:20:38 -05:00
|
|
|
});
|
2020-01-12 02:22:03 +04:00
|
|
|
|
2020-03-07 10:20:38 -05:00
|
|
|
export const actionSendToBack = register({
|
2020-01-12 02:22:03 +04:00
|
|
|
name: "sendToBack",
|
2022-03-28 14:46:40 +02:00
|
|
|
trackEvent: { category: "element" },
|
2020-01-12 02:22:03 +04:00
|
|
|
perform: (elements, appState) => {
|
|
|
|
return {
|
2020-09-11 17:06:07 +02:00
|
|
|
elements: moveAllLeft(elements, appState),
|
2020-01-24 12:04:54 +02:00
|
|
|
appState,
|
2020-03-19 14:51:05 +01:00
|
|
|
commitToHistory: true,
|
2020-01-12 02:22:03 +04:00
|
|
|
};
|
|
|
|
},
|
2020-01-21 01:14:10 +02:00
|
|
|
contextItemLabel: "labels.sendToBack",
|
2020-12-01 23:36:06 +02:00
|
|
|
keyTest: (event) =>
|
|
|
|
isDarwin
|
|
|
|
? event[KEYS.CTRL_OR_CMD] &&
|
|
|
|
event.altKey &&
|
|
|
|
event.code === CODES.BRACKET_LEFT
|
2020-03-09 15:06:35 +02:00
|
|
|
: event[KEYS.CTRL_OR_CMD] &&
|
2020-12-01 23:36:06 +02:00
|
|
|
event.shiftKey &&
|
|
|
|
event.code === CODES.BRACKET_LEFT,
|
2020-08-13 04:35:31 -07:00
|
|
|
PanelComponent: ({ updateData, appState }) => (
|
2020-02-09 09:07:34 -05:00
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
className="zIndexButton"
|
2020-03-07 10:20:38 -05:00
|
|
|
onClick={() => updateData(null)}
|
2020-04-07 14:39:06 +03:00
|
|
|
title={`${t("labels.sendToBack")} — ${
|
2020-03-09 15:06:35 +02:00
|
|
|
isDarwin
|
|
|
|
? getShortcutKey("CtrlOrCmd+Alt+[")
|
|
|
|
: getShortcutKey("CtrlOrCmd+Shift+[")
|
|
|
|
}`}
|
2020-02-09 09:07:34 -05:00
|
|
|
>
|
2021-03-13 18:58:06 +05:30
|
|
|
<SendToBackIcon theme={appState.theme} />
|
2020-02-09 09:07:34 -05:00
|
|
|
</button>
|
|
|
|
),
|
2020-03-07 10:20:38 -05:00
|
|
|
});
|
2020-01-12 02:22:03 +04:00
|
|
|
|
2020-03-07 10:20:38 -05:00
|
|
|
export const actionBringToFront = register({
|
2020-01-12 02:22:03 +04:00
|
|
|
name: "bringToFront",
|
2022-03-28 14:46:40 +02:00
|
|
|
trackEvent: { category: "element" },
|
|
|
|
|
2020-01-12 02:22:03 +04:00
|
|
|
perform: (elements, appState) => {
|
|
|
|
return {
|
2020-09-11 17:06:07 +02:00
|
|
|
elements: moveAllRight(elements, appState),
|
2020-01-24 12:04:54 +02:00
|
|
|
appState,
|
2020-03-19 14:51:05 +01:00
|
|
|
commitToHistory: true,
|
2020-01-12 02:22:03 +04:00
|
|
|
};
|
|
|
|
},
|
2020-01-21 01:14:10 +02:00
|
|
|
contextItemLabel: "labels.bringToFront",
|
2020-12-01 23:36:06 +02:00
|
|
|
keyTest: (event) =>
|
|
|
|
isDarwin
|
|
|
|
? event[KEYS.CTRL_OR_CMD] &&
|
|
|
|
event.altKey &&
|
|
|
|
event.code === CODES.BRACKET_RIGHT
|
2020-03-09 15:06:35 +02:00
|
|
|
: event[KEYS.CTRL_OR_CMD] &&
|
2020-12-01 23:36:06 +02:00
|
|
|
event.shiftKey &&
|
|
|
|
event.code === CODES.BRACKET_RIGHT,
|
2020-08-13 04:35:31 -07:00
|
|
|
PanelComponent: ({ updateData, appState }) => (
|
2020-02-09 09:07:34 -05:00
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
className="zIndexButton"
|
2020-03-23 13:05:07 +02:00
|
|
|
onClick={(event) => updateData(null)}
|
2020-04-07 14:39:06 +03:00
|
|
|
title={`${t("labels.bringToFront")} — ${
|
2020-03-09 15:06:35 +02:00
|
|
|
isDarwin
|
|
|
|
? getShortcutKey("CtrlOrCmd+Alt+]")
|
|
|
|
: getShortcutKey("CtrlOrCmd+Shift+]")
|
|
|
|
}`}
|
2020-02-09 09:07:34 -05:00
|
|
|
>
|
2021-03-13 18:58:06 +05:30
|
|
|
<BringToFrontIcon theme={appState.theme} />
|
2020-02-09 09:07:34 -05:00
|
|
|
</button>
|
|
|
|
),
|
2020-03-07 10:20:38 -05:00
|
|
|
});
|