Browse Source

Fix/cleanup.

Daniel J. Geiger 2 years ago
parent
commit
6e3b575fa5
3 changed files with 5 additions and 14 deletions
  1. 0 7
      src/actions/types.ts
  2. 3 5
      src/components/App.tsx
  3. 2 2
      src/packages/excalidraw/example/App.tsx

+ 0 - 7
src/actions/types.ts

@@ -154,13 +154,6 @@ export interface Action {
     appState: AppState,
     elements: readonly ExcalidrawElement[],
   ) => boolean;
-  customPredicate?: (
-    elements: readonly ExcalidrawElement[],
-    appState: AppState,
-    appProps: ExcalidrawProps,
-    app: AppClassProperties,
-    data?: Record<string, any>,
-  ) => boolean;
   contextItemLabel?:
     | string
     | ((

+ 3 - 5
src/components/App.tsx

@@ -6169,11 +6169,9 @@ class App extends React.Component<AppProps, AppState> {
   ): ContextMenuItems => {
     const options: ContextMenuItems = [];
     let addedCustom = false;
-    this.actionManager.getCustomActions().forEach((action) => {
-      if (this.actionManager.isActionEnabled(action, { data: { source } })) {
-        addedCustom = true;
-        options.push(action);
-      }
+    this.actionManager.getCustomActions({ data: { source } }).forEach((action) => {
+      addedCustom = true;
+      options.push(action);
     });
     if (type === "custom") {
       return options;

+ 2 - 2
src/packages/excalidraw/example/App.tsx

@@ -38,8 +38,8 @@ const exampleAction: Action = {
   perform: (elements, appState) => {
     return { elements, appState, commitToHistory: false };
   },
-  customPredicate: (elements, appState, appProps, app, data) =>
-    data !== undefined && data.source === "editor-current-shape",
+  predicate: (elements, appState, appProps, app, data) =>
+    data === undefined || data.source === "editor-current-shape",
   contextItemLabel: "labels.untitled",
 };
 const exampleEnableFn: EnableFn = (elements, appState, actionName) =>