mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
fix: Narrow the type of Action.name
while still allowing custom names
This commit is contained in:
parent
cbb349e34b
commit
00691631d8
7 changed files with 28 additions and 16 deletions
|
@ -2,6 +2,7 @@ import React from "react";
|
|||
import {
|
||||
Action,
|
||||
UpdaterFn,
|
||||
ActionName,
|
||||
ActionResult,
|
||||
PanelComponentProps,
|
||||
ActionSource,
|
||||
|
@ -40,7 +41,7 @@ const trackAction = (
|
|||
};
|
||||
|
||||
export class ActionManager {
|
||||
actions = {} as Record<Action["name"], Action>;
|
||||
actions = {} as Record<ActionName, Action>;
|
||||
actionPredicates = [] as ActionPredicateFn[];
|
||||
|
||||
updater: (actionResult: ActionResult | Promise<ActionResult>) => void;
|
||||
|
@ -92,7 +93,7 @@ export class ActionManager {
|
|||
|
||||
const actions: Action[] = [];
|
||||
for (const key in this.actions) {
|
||||
const action = this.actions[key];
|
||||
const action = this.actions[key as ActionName];
|
||||
if (filter(action, elements, appState, data)) {
|
||||
actions.push(action);
|
||||
}
|
||||
|
@ -167,7 +168,7 @@ export class ActionManager {
|
|||
/**
|
||||
* @param data additional data sent to the PanelComponent
|
||||
*/
|
||||
renderAction = (name: Action["name"], data?: PanelComponentProps["data"]) => {
|
||||
renderAction = (name: ActionName, data?: PanelComponentProps["data"]) => {
|
||||
const canvasActions = this.app.props.UIOptions.canvasActions;
|
||||
|
||||
if (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue