mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Update to latest Action
changes.
This commit is contained in:
parent
45faf7d58f
commit
ace031e992
6 changed files with 51 additions and 72 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue