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) =>