|
@@ -11,6 +11,7 @@ import {
|
|
|
} from "../actions/shortcuts";
|
|
|
import { Action } from "../actions/types";
|
|
|
import { ActionManager } from "../actions/manager";
|
|
|
+import { AppState } from "../types";
|
|
|
|
|
|
type ContextMenuOption = "separator" | Action;
|
|
|
|
|
@@ -20,6 +21,7 @@ type ContextMenuProps = {
|
|
|
top: number;
|
|
|
left: number;
|
|
|
actionManager: ActionManager;
|
|
|
+ appState: Readonly<AppState>;
|
|
|
};
|
|
|
|
|
|
const ContextMenu = ({
|
|
@@ -28,11 +30,11 @@ const ContextMenu = ({
|
|
|
top,
|
|
|
left,
|
|
|
actionManager,
|
|
|
+ appState,
|
|
|
}: ContextMenuProps) => {
|
|
|
const isDarkTheme = !!document
|
|
|
.querySelector(".excalidraw")
|
|
|
?.classList.contains("Appearance_dark");
|
|
|
-
|
|
|
return (
|
|
|
<div
|
|
|
className={clsx("excalidraw", {
|
|
@@ -61,9 +63,10 @@ const ContextMenu = ({
|
|
|
return (
|
|
|
<li key={idx} data-testid={actionName} onClick={onCloseRequest}>
|
|
|
<button
|
|
|
- className={`context-menu-option
|
|
|
- ${actionName === "deleteSelectedElements" ? "dangerous" : ""}
|
|
|
- ${option.checked ? "checkmark" : ""}`}
|
|
|
+ className={clsx("context-menu-option", {
|
|
|
+ dangerous: actionName === "deleteSelectedElements",
|
|
|
+ checkmark: option.checked?.(appState),
|
|
|
+ })}
|
|
|
onClick={() => actionManager.executeAction(option)}
|
|
|
>
|
|
|
<div className="context-menu-option__label">{label}</div>
|
|
@@ -97,6 +100,7 @@ type ContextMenuParams = {
|
|
|
top: ContextMenuProps["top"];
|
|
|
left: ContextMenuProps["left"];
|
|
|
actionManager: ContextMenuProps["actionManager"];
|
|
|
+ appState: Readonly<AppState>;
|
|
|
};
|
|
|
|
|
|
const handleClose = () => {
|
|
@@ -119,6 +123,7 @@ export default {
|
|
|
options={options}
|
|
|
onCloseRequest={handleClose}
|
|
|
actionManager={params.actionManager}
|
|
|
+ appState={params.appState}
|
|
|
/>,
|
|
|
getContextMenuNode(),
|
|
|
);
|