mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
"Select All" only appears when clicking outside of a shape via actionFilter (#329)
Co-authored-by: Christopher Chedeau <vjeuxx@gmail.com>
This commit is contained in:
parent
88a9cee8bb
commit
abf2aaa102
3 changed files with 25 additions and 6 deletions
|
@ -1,5 +1,10 @@
|
|||
import React from "react";
|
||||
import { Action, ActionsManagerInterface, UpdaterFn } from "./types";
|
||||
import {
|
||||
Action,
|
||||
ActionsManagerInterface,
|
||||
UpdaterFn,
|
||||
ActionFilterFn
|
||||
} from "./types";
|
||||
import { ExcalidrawElement } from "../element/types";
|
||||
import { AppState } from "../types";
|
||||
|
||||
|
@ -40,9 +45,11 @@ export class ActionManager implements ActionsManagerInterface {
|
|||
getContextMenuItems(
|
||||
elements: readonly ExcalidrawElement[],
|
||||
appState: AppState,
|
||||
updater: UpdaterFn
|
||||
updater: UpdaterFn,
|
||||
actionFilter: ActionFilterFn = action => action
|
||||
) {
|
||||
return Object.values(this.actions)
|
||||
.filter(actionFilter)
|
||||
.filter(action => "contextItemLabel" in action)
|
||||
.sort(
|
||||
(a, b) =>
|
||||
|
|
|
@ -14,6 +14,7 @@ type ActionFn = (
|
|||
) => ActionResult;
|
||||
|
||||
export type UpdaterFn = (res: ActionResult) => void;
|
||||
export type ActionFilterFn = (action: Action) => void;
|
||||
|
||||
export interface Action {
|
||||
name: string;
|
||||
|
@ -46,7 +47,8 @@ export interface ActionsManagerInterface {
|
|||
getContextMenuItems: (
|
||||
elements: readonly ExcalidrawElement[],
|
||||
appState: AppState,
|
||||
updater: UpdaterFn
|
||||
updater: UpdaterFn,
|
||||
actionFilter: ActionFilterFn
|
||||
) => { label: string; action: () => void }[];
|
||||
renderAction: (
|
||||
name: string,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue