CreateBehavior.js 792 B

12345678910111213141516171819202122232425262728293031323334
  1. import inherits from 'inherits-browser';
  2. import { is } from '../../../util/ModelUtil';
  3. import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
  4. import { getParent } from '../util/ModelingUtil';
  5. /**
  6. * @typedef {import('didi').Injector} Injector
  7. */
  8. /**
  9. * @param {Injector} injector
  10. */
  11. export default function CreateBehavior(injector) {
  12. injector.invoke(CommandInterceptor, this);
  13. this.preExecute('shape.create', 1500, function(event) {
  14. var context = event.context,
  15. parent = context.parent,
  16. shape = context.shape;
  17. if (is(parent, 'bpmn:Lane') && !is(shape, 'bpmn:Lane')) {
  18. context.parent = getParent(parent, 'bpmn:Participant');
  19. }
  20. });
  21. }
  22. CreateBehavior.$inject = [ 'injector' ];
  23. inherits(CreateBehavior, CommandInterceptor);