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, appState: AppState,
elements: readonly ExcalidrawElement[], elements: readonly ExcalidrawElement[],
) => boolean; ) => boolean;
customPredicate?: (
elements: readonly ExcalidrawElement[],
appState: AppState,
appProps: ExcalidrawProps,
app: AppClassProperties,
data?: Record<string, any>,
) => boolean;
contextItemLabel?: contextItemLabel?:
| string | string
| (( | ((

View File

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

View File

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