From 6e3b575fa59f158ca90233596bf99d907f8f128d Mon Sep 17 00:00:00 2001 From: "Daniel J. Geiger" <1852529+DanielJGeiger@users.noreply.github.com> Date: Fri, 6 Jan 2023 16:55:31 -0600 Subject: [PATCH] Fix/cleanup. --- src/actions/types.ts | 7 ------- src/components/App.tsx | 8 +++----- src/packages/excalidraw/example/App.tsx | 4 ++-- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/src/actions/types.ts b/src/actions/types.ts index 76ece6e5c..6d097cd72 100644 --- a/src/actions/types.ts +++ b/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, - ) => boolean; contextItemLabel?: | string | (( diff --git a/src/components/App.tsx b/src/components/App.tsx index 90b557e7f..92a9fc550 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -6169,11 +6169,9 @@ class App extends React.Component { ): 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; diff --git a/src/packages/excalidraw/example/App.tsx b/src/packages/excalidraw/example/App.tsx index 3c4ec93cd..588656c1b 100644 --- a/src/packages/excalidraw/example/App.tsx +++ b/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) =>