mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Merge remote-tracking branch 'origin/master' into feat-custom-actions
This commit is contained in:
commit
333cc53797
81 changed files with 733 additions and 635 deletions
|
@ -312,9 +312,9 @@ const ExcalidrawSetAppStateContext = React.createContext<
|
|||
>(() => {});
|
||||
ExcalidrawSetAppStateContext.displayName = "ExcalidrawSetAppStateContext";
|
||||
|
||||
const ExcalidrawActionManagerContext = React.createContext<
|
||||
ActionManager | { renderAction: ActionManager["renderAction"] }
|
||||
>({ renderAction: () => null });
|
||||
const ExcalidrawActionManagerContext = React.createContext<ActionManager>(
|
||||
null!,
|
||||
);
|
||||
ExcalidrawActionManagerContext.displayName = "ExcalidrawActionManagerContext";
|
||||
|
||||
export const useExcalidrawElements = () =>
|
||||
|
@ -6168,25 +6168,9 @@ class App extends React.Component<AppProps, AppState> {
|
|||
source?: string,
|
||||
): ContextMenuItems => {
|
||||
const options: ContextMenuItems = [];
|
||||
const allElements = this.actionManager.getElementsIncludingDeleted();
|
||||
const appState = this.actionManager.getAppState();
|
||||
let addedCustom = false;
|
||||
this.actionManager.getCustomActions().forEach((action) => {
|
||||
const predicate =
|
||||
type === "custom"
|
||||
? action.customPredicate
|
||||
: action.contextItemPredicate;
|
||||
if (
|
||||
predicate &&
|
||||
predicate(
|
||||
allElements,
|
||||
appState,
|
||||
this.actionManager.app.props,
|
||||
this.actionManager.app,
|
||||
type === "custom" ? { source } : undefined,
|
||||
) &&
|
||||
this.actionManager.isActionEnabled(allElements, appState, action.name)
|
||||
) {
|
||||
if (this.actionManager.isActionEnabled(action, { data: { source } })) {
|
||||
addedCustom = true;
|
||||
options.push(action);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue