src/provider/element-templates/ReplaceBehavior.js
/**
 * This function catches the <moddleCopy.canCopyProperty> event
 * and only allows the copy of the modelerTemplate property
 * if the element's type or its parent's is in
 * the list of elements the template applies to.
 */
This function catches the  event
and only allows the copy of the modelerTemplate property
if the element's type or its parent's is in
the list of elements the template applies to.
This function catches the event and only allows the copy of the modelerTemplate property if the element ' s type or its parent ' s is in the list of elements the template applies to .
function ReplaceBehavior(elementTemplates, eventBus) {
  eventBus.on('moddleCopy.canCopyProperty', function(context) {
    const {
      parent,
      property,
      propertyName
    } = context;
    if (propertyName !== 'modelerTemplate') {
      return;
    }
    const elementTemplate = elementTemplates.get(property);
    if (!elementTemplate) {
      return false;
    }
    const { appliesTo } = elementTemplate;
    const allowed = appliesTo.reduce((allowed, type) => {
      return allowed || is(parent, type);
    }, false);
    if (!allowed) {
      return false;
    }
  });
}
function ReplaceBehavior ( elementTemplates , eventBus ) { eventBus . on ( 'moddleCopy.canCopyProperty' , function ( context ) { const { parent , property , propertyName } = context ; if ( propertyName !== 'modelerTemplate' ) { return ; } const elementTemplate = elementTemplates . get ( property ) ; if ( ! elementTemplate ) { return false ; } const { appliesTo } = elementTemplate ; const allowed = appliesTo . reduce ( ( allowed , type ) => { return allowed || is ( parent , type ) ; } , false ) ; if ( ! allowed ) { return false ; } } ) ; }
This function catches the <moddleCopy.canCopyProperty> event
 and only allows the copy of the modelerTemplate property
 if the element's type or its parent's is in
 the list of elements the template applies to.
This function catches the <moddleCopy . canCopyProperty > event and only allows the copy of the modelerTemplate property if the element ' s type or its parent ' s is in the list of elements the template applies to .