mirror of
https://github.com/projectstorm/react-diagrams.git
synced 2026-03-13 09:50:09 +08:00
Merge pull request #543 from ninenone/master
event modifiers for DeleteItemsAction
This commit is contained in:
@@ -4,6 +4,12 @@ import * as _ from 'lodash';
|
||||
|
||||
export interface DeleteItemsActionOptions {
|
||||
keyCodes?: number[];
|
||||
modifiers?: {
|
||||
ctrlKey?: boolean;
|
||||
shiftKey?: boolean;
|
||||
altKey?: boolean;
|
||||
metaKey?: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -11,14 +17,21 @@ export interface DeleteItemsActionOptions {
|
||||
*/
|
||||
export class DeleteItemsAction extends Action {
|
||||
constructor(options: DeleteItemsActionOptions = {}) {
|
||||
options = {
|
||||
keyCodes: [46, 8],
|
||||
...options
|
||||
const keyCodes = options.keyCodes || [46, 8];
|
||||
const modifiers = {
|
||||
ctrlKey: false,
|
||||
shiftKey: false,
|
||||
altKey: false,
|
||||
metaKey: false,
|
||||
...options.modifiers
|
||||
};
|
||||
|
||||
super({
|
||||
type: InputType.KEY_DOWN,
|
||||
fire: (event: ActionEvent<KeyboardEvent>) => {
|
||||
if (options.keyCodes.indexOf(event.event.keyCode) !== -1) {
|
||||
const { keyCode, ctrlKey, shiftKey, altKey, metaKey } = event.event;
|
||||
|
||||
if (keyCodes.indexOf(keyCode) !== -1 && _.isEqual({ ctrlKey, shiftKey, altKey, metaKey }, modifiers)) {
|
||||
_.forEach(this.engine.getModel().getSelectedEntities(), model => {
|
||||
// only delete items which are not locked
|
||||
if (!model.isLocked()) {
|
||||
|
||||
@@ -6669,6 +6669,11 @@ growly@^1.3.0:
|
||||
version "1.3.0"
|
||||
resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081"
|
||||
|
||||
gsap@^3.0.1:
|
||||
version "3.1.1"
|
||||
resolved "https://registry.npmjs.org/gsap/-/gsap-3.1.1.tgz#b3f5f646563d4099aab9681d16703613f5de6a8c"
|
||||
integrity sha512-ISkCKuXMtBbmbchJxWXuZydXnnWVV9SqNqd8vAevvtq0yzyBapMbXLxwambK73S/2kpTIVzYW8eJXlDD7yHhvw==
|
||||
|
||||
gud@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/gud/-/gud-1.0.0.tgz#a489581b17e6a70beca9abe3ae57de7a499852c0"
|
||||
|
||||
Reference in New Issue
Block a user