Fix/cleanup.

This commit is contained in:
Daniel J. Geiger 2023-01-06 16:55:31 -06:00
parent 333cc53797
commit 6e3b575fa5
3 changed files with 5 additions and 14 deletions

View File

@ -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
| ((

View File

@ -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;

View File

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