UNPKG

postit-js-core

Version:

[![Netlify Status](https://api.netlify.com/api/v1/badges/72130b1d-f56b-473e-8f3b-50a5af916e64/deploy-status)](https://app.netlify.com/sites/postit-js-demo/deploys) ![Build Status](https://github.com/pinussilvestrus/postit-js/workflows/ci/badge.svg)

41 lines (28 loc) 953 B
import inherits from 'inherits'; import { assign } from 'min-dash'; import { getBusinessObject, is } from '../../../util/ModelUtil'; import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor'; export default function CreateBoardElementBehavior(eventBus) { CommandInterceptor.call(this, eventBus); // ensure properties were set in business object this.execute('shape.create', function(context) { var shape = context.context.shape; if (is(shape, 'postit:Postit')) { const businessObject = getBusinessObject(shape); !businessObject.color && assign(businessObject, { color: shape.color }); } if (is(shape, 'postit:Image')) { const businessObject = getBusinessObject(shape); !businessObject.source && assign(businessObject, { source: shape.source }); } }); } inherits(CreateBoardElementBehavior, CommandInterceptor); CreateBoardElementBehavior.$inject = [ 'eventBus' ];