Merged PR 173: Implements API methods through right click + more (read desc)
- Implements API methods through right click - Refactor events - Refactor usage of setHistory and setHistoryCurrentStep into a single function - Update ContainerOperations documentations - Added AddContainers in order to add multiple containers + refactor AddContainer to use it - Fix regression - Fix AddContainer at index
This commit is contained in:
parent
79c6874240
commit
57e6c9a156
20 changed files with 652 additions and 291 deletions
|
@ -4,11 +4,11 @@ import { MenuItem } from './MenuItem';
|
|||
|
||||
interface IMenuProps {
|
||||
getListener: () => HTMLElement | null
|
||||
actions: Map<string, IAction[]>
|
||||
actions: Map<string, IMenuAction[]>
|
||||
className?: string
|
||||
}
|
||||
|
||||
export interface IAction {
|
||||
export interface IMenuAction {
|
||||
/** displayed */
|
||||
text: string
|
||||
|
||||
|
@ -75,23 +75,24 @@ export function Menu(props: IMenuProps): JSX.Element {
|
|||
setTarget
|
||||
);
|
||||
|
||||
let children;
|
||||
const children: JSX.Element[] = [];
|
||||
|
||||
if (target !== undefined) {
|
||||
let count = 0;
|
||||
for (const className of target.classList) {
|
||||
count++;
|
||||
const actions = props.actions.get(className);
|
||||
if (actions === undefined) {
|
||||
continue;
|
||||
}
|
||||
|
||||
children = actions.map((action, index) =>
|
||||
<MenuItem
|
||||
key={`contextmenu-item-${index}`}
|
||||
actions.forEach((action, index) => {
|
||||
children.push(<MenuItem
|
||||
key={`contextmenu-item-${count}`}
|
||||
className="contextmenu-item"
|
||||
text={action.text}
|
||||
onClick={() => action.action(target)} />
|
||||
);
|
||||
break;
|
||||
onClick={() => action.action(target)} />);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue