diff --git a/lib/features/copy-paste/BpmnCopyPaste.js b/lib/features/copy-paste/BpmnCopyPaste.js index e35abdde..cdf9c538 100644 --- a/lib/features/copy-paste/BpmnCopyPaste.js +++ b/lib/features/copy-paste/BpmnCopyPaste.js @@ -38,7 +38,8 @@ function BpmnCopyPaste(bpmnFactory, eventBus, copyPaste, clipboard, moddle, canv var businessObject = getBusinessObject(element), newBusinessObject = bpmnFactory.create(businessObject.$type); - var properties = getProperties(businessObject.$descriptor); + var properties = getProperties(businessObject.$descriptor), + colors = {}; properties = filter(properties, function(property) { return IGNORED_PROPERTIES.indexOf(property.replace(/bpmn:/, '')) === -1; @@ -50,6 +51,10 @@ function BpmnCopyPaste(bpmnFactory, eventBus, copyPaste, clipboard, moddle, canv setProperties(descriptor, businessObject.di, [ 'isExpanded' ]); + setProperties(colors, businessObject.di, [ 'fill', 'stroke' ]); + + descriptor.colors = colors; + if (element.type === 'label') { return descriptor; } diff --git a/test/spec/features/copy-paste/BpmnCopyPasteSpec.js b/test/spec/features/copy-paste/BpmnCopyPasteSpec.js index c7f1217f..6d578f52 100644 --- a/test/spec/features/copy-paste/BpmnCopyPasteSpec.js +++ b/test/spec/features/copy-paste/BpmnCopyPasteSpec.js @@ -177,6 +177,41 @@ describe('features/copy-paste', function() { it('selected elements', inject(integrationTest([ 'SubProcess_1kd6ist' ]))); + it('should retain color properties', + inject(function(modeling, copyPaste, canvas, elementRegistry) { + + // given + var task = elementRegistry.get('Task_1fo63a7'), + rootElement = canvas.getRootElement(), + newTask, + fill = '#BBDEFB', + stroke = '#1E88E5'; + + + // when + modeling.setColor(task, { fill: fill, stroke: stroke }); + + copyPaste.copy([ task ]); + + copyPaste.paste({ + element: rootElement, + point: { + x: 1100, + y: 250 + } + }); + + newTask = elementRegistry.filter(function(element) { + return element.parent === rootElement && element.type === 'bpmn:Task' && element.id !== 'Task_1fo63a7'; + })[0]; + + // then + expect(newTask.type).to.equal('bpmn:Task'); + expect(newTask.businessObject.di.fill).to.equal(fill); + expect(newTask.businessObject.di.stroke).to.equal(stroke); + }) + ); + });