Update to latest Action changes.
This commit is contained in:
+22
-3
@@ -75,7 +75,7 @@ export class ActionManager {
|
||||
this.app = app;
|
||||
}
|
||||
|
||||
public registerActionGuards() {
|
||||
registerActionGuards() {
|
||||
const disablers = getActionDisablers();
|
||||
for (const d in disablers) {
|
||||
const dName = d as ActionName;
|
||||
@@ -90,7 +90,7 @@ export class ActionManager {
|
||||
}
|
||||
}
|
||||
|
||||
private registerDisableFn(name: ActionName, disabler: DisableFn) {
|
||||
registerDisableFn(name: ActionName, disabler: DisableFn) {
|
||||
if (!(name in this.disablers)) {
|
||||
this.disablers[name] = [] as DisableFn[];
|
||||
}
|
||||
@@ -99,7 +99,7 @@ export class ActionManager {
|
||||
}
|
||||
}
|
||||
|
||||
private registerEnableFn(name: Action["name"], enabler: EnableFn) {
|
||||
registerEnableFn(name: Action["name"], enabler: EnableFn) {
|
||||
if (!(name in this.enablers)) {
|
||||
this.enablers[name] = [] as EnableFn[];
|
||||
}
|
||||
@@ -108,6 +108,25 @@ export class ActionManager {
|
||||
}
|
||||
}
|
||||
|
||||
getCustomActions(opts?: {
|
||||
elements?: readonly ExcalidrawElement[];
|
||||
data?: Record<string, any>;
|
||||
guardsOnly?: boolean;
|
||||
}): Action[] {
|
||||
// For testing
|
||||
if (this === undefined) {
|
||||
return [];
|
||||
}
|
||||
const customActions: Action[] = [];
|
||||
for (const key in this.actions) {
|
||||
const action = this.actions[key];
|
||||
if (!isActionName(action.name) && this.isActionEnabled(action, opts)) {
|
||||
customActions.push(action);
|
||||
}
|
||||
}
|
||||
return customActions;
|
||||
}
|
||||
|
||||
registerAction(action: Action) {
|
||||
this.actions[action.name] = action;
|
||||
}
|
||||
|
||||
@@ -147,10 +147,6 @@ export type PanelComponentProps = {
|
||||
export interface Action {
|
||||
name: string;
|
||||
PanelComponent?: React.FC<PanelComponentProps>;
|
||||
panelComponentPredicate?: (
|
||||
elements: readonly ExcalidrawElement[],
|
||||
appState: AppState,
|
||||
) => boolean;
|
||||
perform: ActionFn;
|
||||
keyPriority?: number;
|
||||
keyTest?: (
|
||||
@@ -158,11 +154,6 @@ export interface Action {
|
||||
appState: AppState,
|
||||
elements: readonly ExcalidrawElement[],
|
||||
) => boolean;
|
||||
shapeConfigPredicate?: (
|
||||
elements: readonly ExcalidrawElement[],
|
||||
appState: AppState,
|
||||
data?: Record<string, any>,
|
||||
) => boolean;
|
||||
contextItemLabel?:
|
||||
| string
|
||||
| ((
|
||||
|
||||
Reference in New Issue
Block a user