How to use diagram-js - 10 common examples

To help you get started, we’ve selected a few diagram-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bpmn-io / bpmn-js-properties-panel / test / spec / provider / bpmn / ElementNameSpec.js View on Github external
'use strict';

var TestHelper = require('../../../TestHelper');

var TestContainer = require('mocha-test-container-support');

/* global bootstrapModeler, inject */

var propertiesPanelModule = require('lib'),
    domQuery = require('min-dom').query,
    coreModule = require('bpmn-js/lib/core').default,
    selectionModule = require('diagram-js/lib/features/selection').default,
    modelingModule = require('bpmn-js/lib/features/modeling').default,
    propertiesProviderModule = require('lib/provider/bpmn'),
    getBusinessObject = require('bpmn-js/lib/util/ModelUtil').getBusinessObject;

function getEntry(container, entryId) {
  return domQuery('div[data-entry="' + entryId + '"]', container);
}

function getNameField(container) {
  var selector = 'div[name=name]';
  return domQuery(selector, getEntry(container, 'name'));
}

function getTextBoxRows(field) {
  var innerText = field.innerText || '';
  var lines = innerText.split(/\r?\n/g);
github bpmn-io / bpmn-js / test / spec / features / modeling / behavior / CreateParticipantBehaviorSpec.js View on Github external
it('should constrain ' + JSON.stringify(position), inject(function(dragging) {

            // when
            dragging.move(canvasEvent(position));

            dragging.end();

            // then
            expectBoundsWithin(
              asTRBL(getBBox(participant.children)),
              asTRBL(getBBox(participant)),
              padding
            );
          }));
github bpmn-io / bpmn-js / test / spec / features / snapping / BpmnCreateMoveSnappingSpec.js View on Github external
it('should snap to bottom-left', inject(function(dragging) {

          // when
          dragging.move(canvasEvent({ x: 90, y: 190 }));

          dragging.end();

          // then
          var boundaryEvent = getBoundaryEvent(task);

          expect(mid(boundaryEvent)).to.eql({
            x: 100, // 90 snapped to 100
            y: 180 // 190 snapped to 180
          });
        }));
github bpmn-io / bpmn-js / test / spec / features / editor-actions / BpmnEditorActionsSpec.js View on Github external
it('should move to origin', inject(function(editorActions) {

          // given
          var elements = editorActions.trigger('selectElements'),
              boundingBox;

          // when
          editorActions.trigger('moveToOrigin');

          boundingBox = getBBox(elements);

          // then
          expect(pick(boundingBox, [ 'x', 'y' ])).to.eql({ x: 0, y: 0 });
        }));
github bpmn-io / bpmn-js / test / spec / features / modeling / behavior / CreateParticipantBehaviorSpec.js View on Github external
it('should constrain ' + JSON.stringify(position), inject(function(dragging) {

            // when
            dragging.move(canvasEvent(position));

            dragging.end();

            // then
            expectBoundsWithin(
              asTRBL(getBBox(participant.children)),
              asTRBL(getBBox(participant)),
              padding
            );
          }));
github bpmn-io / bpmn-js / test / spec / features / auto-place / AutoPlaceSpec.js View on Github external
expect(event.source).to.equal(source);

          return {
            x: 0,
            y: 0
          };
        });

        eventBus.on('autoPlace', listener);

        // when
        autoPlace.append(source, element);

        expect(listener).to.have.been.called;

        expect(getMid(element)).to.eql({
          x: 0,
          y: 0
        });
      }
    ));
github bpmn-io / bpmn-js-properties-panel / test / spec / provider / camunda / ServiceTaskDelegateSpec.js View on Github external
'use strict';

var TestHelper = require('../../../TestHelper');

var TestContainer = require('mocha-test-container-support');

/* global bootstrapModeler, inject */

var propertiesPanelModule = require('lib'),
    domQuery = require('min-dom').query,
    domQueryAll = require('min-dom').queryAll,
    coreModule = require('bpmn-js/lib/core').default,
    selectionModule = require('diagram-js/lib/features/selection').default,
    modelingModule = require('bpmn-js/lib/features/modeling').default,
    propertiesProviderModule = require('lib/provider/camunda'),
    camundaModdlePackage = require('camunda-bpmn-moddle/resources/camunda'),
    getBusinessObject = require('bpmn-js/lib/util/ModelUtil').getBusinessObject;

describe('service-task-delegate-properties', function() {

  var diagramXML = require('./ServiceTaskDelegate.bpmn');

  var testModules = [
    coreModule, selectionModule, modelingModule,
    propertiesPanelModule,
    propertiesProviderModule
  ];

  var container;
github bpmn-io / bpmn-js-properties-panel / test / spec / provider / camunda / JobPrioritySpec.js View on Github external
'use strict';

var TestHelper = require('../../../TestHelper');

var TestContainer = require('mocha-test-container-support');

/* global bootstrapModeler, inject */

var propertiesPanelModule = require('lib'),
    domQuery = require('min-dom').query,
    coreModule = require('bpmn-js/lib/core').default,
    selectionModule = require('diagram-js/lib/features/selection').default,
    modelingModule = require('bpmn-js/lib/features/modeling').default,
    propertiesProviderModule = require('lib/provider/camunda'),
    camundaModdlePackage = require('camunda-bpmn-moddle/resources/camunda'),
    getBusinessObject = require('bpmn-js/lib/util/ModelUtil').getBusinessObject;

describe('jobPriority', function() {
  var diagramXML = require('./JobPriority.bpmn');

  var testModules = [
    coreModule, selectionModule, modelingModule,
    propertiesPanelModule,
    propertiesProviderModule
  ];

  var container;
github bpmn-io / bpmn-js-properties-panel / test / spec / provider / camunda / FormFieldTypeSpec.js View on Github external
'use strict';

var TestHelper = require('../../../TestHelper');

var TestContainer = require('mocha-test-container-support');

/* global bootstrapModeler, inject */

var propertiesPanelModule = require('lib'),
    propertiesProviderModule = require('lib/provider/camunda'),
    selectionModule = require('diagram-js/lib/features/selection').default,
    modelingModule = require('bpmn-js/lib/features/modeling').default,
    coreModule = require('bpmn-js/lib/core').default;

var getBusinessObject = require('bpmn-js/lib/util/ModelUtil').getBusinessObject;

var camundaModdlePackage = require('camunda-bpmn-moddle/resources/camunda');

var domQuery = require('min-dom').query,
    domClasses = require('min-dom').classes;


function getFormFieldType(element) {
  var bo = getBusinessObject(element);

  return bo.extensionElements.values[0].fields[0].type;
}
github bpmn-io / bpmn-js-properties-panel / test / spec / provider / camunda / VersionTagSpec.js View on Github external
'use strict';

var TestHelper = require('../../../TestHelper');

var TestContainer = require('mocha-test-container-support');

/* global bootstrapModeler, inject */

var propertiesPanelModule = require('lib'),
    domQuery = require('min-dom').query,
    coreModule = require('bpmn-js/lib/core').default,
    selectionModule = require('diagram-js/lib/features/selection').default,
    modelingModule = require('bpmn-js/lib/features/modeling').default,
    propertiesProviderModule = require('lib/provider/camunda'),
    camundaModdlePackage = require('camunda-bpmn-moddle/resources/camunda'),
    getBusinessObject = require('bpmn-js/lib/util/ModelUtil').getBusinessObject;


describe('Version-Tag', function() {

  var diagramXML = require('./VersionTag.bpmn');

  var testModules = [
    coreModule, selectionModule, modelingModule,
    propertiesPanelModule,
    propertiesProviderModule
  ];