Giter Site home page Giter Site logo

bpmn-io / diagram-js Goto Github PK

View Code? Open in Web Editor NEW
1.7K 59.0 419.0 7.55 MB

A toolbox for displaying and modifying diagrams on the web.

License: MIT License

CSS 1.03% JavaScript 96.46% TypeScript 2.51%
diagram-js javascript svg hacktoberfest diagram-editor

diagram-js's Introduction

diagram-js

CI

A toolbox for displaying and modifying diagrams on the web.

Built with diagram-js

Some libraries / applications built on top of diagram-js:

Part of bpmn.io

External

Resources

Development

Prepare the project by installing all dependencies:

npm install

Then, depending on your use-case you may run any of the following commands:

# build the library and run all tests
npm run all

# run the development setup
npm run dev

# run tests (single run)
npm test

Expose an environment variable TEST_BROWSERS=(Chrome|Firefox) to execute the tests in a non-headless browser.

Note

We do not generate any build artifacts. Required parts of the library should be bundled by consuming libraries as needed instead.

License

MIT

diagram-js's People

Contributors

adbre avatar barmac avatar chaptergy avatar dependabot[bot] avatar felixlinker avatar gustavjf avatar hawky-4s- avatar iso50 avatar jbarrus avatar jeromew avatar makepanic avatar marstamm avatar maxtru avatar miyuesc avatar nikku avatar oexlkinq avatar oguzeroglu avatar pedesen avatar phalix avatar philippfromme avatar ptyin avatar renovate[bot] avatar ricardomatias avatar romansmirnov avatar sebastianstamm avatar smbea avatar thetric avatar timkraeuter avatar ulasakdeniz avatar yujianghao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

diagram-js's Issues

Better separate modeling/viewing concerns in Canvas

At the moment the canvas relies on the commandStack for drawing shapes and connections. Ideally we would implement low-level renderering operations irreversible, giving the user the choice whether or not to use the commandStack to build a reversible operation on top of it.

Evaluate usage of #marker-end on Firefox

We should check, whether we can get our current mechanism for connection start/end markers to work on firefox. If not, we should switch to another mechanism.

Add context pad infrastructure

A context pad displays visual information for the user contextual for a given shape. We should provide such an infrastructure for diagram-js.

Provide better module structure

We need to provide an easier to understand module structure. It should allows folks to write plug-ins for diagram-js as node modules and let others consume these modules in a sane way.

This includes that we should get rid of the distinction between modules (what is loaded) and components (what is explicitly activated). In fact, each module should declare what is explicitly activated as well as which other modules it depends on.

This means, instead of directly activating modules on load like this

var diagramModule = require('../di').defaultModule;
diagramModule.type('foo', [ 'FOO' ]);

we should default to something like

// foo/Foo.js
module.exports = Foo;
// foo/index.js
module.exports = {
  __depends__: [
    require('../core'),
    require('diagram-js-some-plugin')
  ],
  __init__: [ 'foo' ],
  foo: [ 'type', require('./Foo') ]
};

Connection .djs-hit not updated after layout / crop

The connection .djs-hit element that is added by interaction events and ensures the user can select connections is not properly updated after connection layout / crop.

This makes connections unselectable after connected elements have been moved.

Must be fixed in InteractionEvents, possibly updating on connection.changed.

Refactor: Shape

Make Shape Object plain again.
Currently shape has methods...
Move that methods to Helper.

Is that possible to do annotation?

Hi,

I am using the old js library https://github.com/camunda/camunda-bpmn.js.

After the update of signavio (from 7.2 to 7.8), it seems to be that the new model xml file can not be rendered by the old library.

I would like to replace it with the new one. Does the new library provides the smiliar function like drawing an annotation around a task? If yes, how can I do it using this new library?

thank in advance.

Best,
Huiying

Align names of services / utilities

At the moment we have no clear naming scheme of services and their files.

  • files are usually written capitalized (e.g. src/core/Canvas.js), sometimes not (e.g. src/util/underscore.js)
  • services are exposed as lower cased versions of the file names src/core/Canvas.js -> canvas

I'd like to propose a naming scheme for services / utilities and align the file names we use across diagram-js so that each file name reflects the name of the exposed runtime service.

Proposal

  • Name service constructors uppercase, but the files according to the exposed service instance. Example: The canvas service would be defined in the file src/core/Canvas.js by a constructor called Canvas
  • Name and expose utilities, i.e. services that expose only static utility functions upper case. Example: The snapsvg wrapper would expose the library via snap in the file src/draw/Snap.js.

Implement basic modeling operations

We should implement the basic modeling operations here and make sure we have the chance to re-use them for different editors (bpmn-js, ...).

Implement an internal diagram-js data-model

We need to document and extend the internal model used by diagram-js.

Our model looks as follows

Base

  • optional label
  • optional parent

A Shape

  • width
  • height
  • x
  • y
  • list children
  • list outgoing
  • list incoming

Connection

  • source
  • target
  • waypoints

Remove snapsvg

Performance studies (bpmn-io/bpmn-js#126) have shown that snapsvg is really slow. Replacing it will result in improved rendering performance and better code structure.

Things to replace

  • DOM manipulation (attribute handling, node creation, insertion, remove)
  • intersection algorithm

Path

Build utility methods to interact with SVG to better separate SVG concerns from diagram-js:

snapsvg: explicit, SVG hiding syntax
var paper = Snap.create();
var group = paper.group();

group.attr({ transform: ' .... ' });
own implementation: native SVG + utility methods
var svg = tsvg.create('svg');
var group = tsvg.append(tsvg.create('g'), svg);

tsvg.attr(group, { transform: ' .... ' });

Add Shape from Palette

A shape can be added by dragging from palette.

  • A visual indication shows, where the shape will be added
  • The add operation completes once the user drops the shape
  • Add is handled through the command stack
  • Escape key and mouse up outside of the canvas cancels the operation

Add method to destroy a created diagram.

Via Diagram#destroy() the diagram should be removed from the DOM.
Additionally, registered components should be notified that they are about to be destroyed via a diagram.destroy event.

Implement command history service

  • Implement service to support undo / redo
  • module should register their commands on the service.
    • multiple modules can register on the same command id

Add the ability to execute behavior before and after a command

This allows us to decorate a command by executing other commands and thus build more complex command chains.

Examples

The following list shows basic commands and how they may be built on each other:

label.create
connection.create > label.create
shape.create > label.create
shape.appendShape > label.create + connection.create

Spike: Add comment box as HTML overlay

We implement a comment field via a HTML overlay.

Comment Field

Goals

  • implemented via overlay API
  • only shown up to a certain zoom level
  • clickable (i.e. the user can interact with it)
  • other HTML overlays may be added, too

Hints

  • absolute positionioning above the element, carried out by overlay api
  • Canvas#getAbsoluteBBox()

Drag & Drop

The following should be contained:

  • Elements may be dragged based on customizable rules
  • The user gets visual feedback on whether it is allowed
  • Drag / Drop is performed if allowed

BPMN Import/Export

Add the ability to import / export BPMN 2.0 xml. This depends on a few things.

Spike

  • Investigate usage of BPMN 2.0 meta model
  • Investigate on DI (e.g. Signavio exports subprocesses as a separate DI, which is allowed according to spec)

API

  • Import XML -> JS
  • Export JS -> XML

Constraints

  • Usable API for working with JS representation
  • Allow validation of imported files (long term)
  • Extensible with custom elements / types (long term)

Hide diagram elements

It should be possible to hide elements, rendering them but making them invisible for the user.

Childs and undo issue

  • Remove with undo a child of a parent container
  • Try to drag and drop the container
  • --> Error message in console

Refactor Canvas.commandStack.register()

Canvas will not be the right place to have all commandStack.register() calls ....

  • Need to a general understanding where we want to have this definitions
  • Refactor existing code base.

Provide infrastructure for layering of visual elements

We should be able to organize diagram elements in layers.

This gives us a quick and simple solution for the following problems:

  • control visibility of certain diagram components
    (e.g. display labels always on top)
  • display and/or toggle overlays
  • control the visibility of diagram components during printing

Implementation Notes

  • Layers may be logically (i.e. in term of precedence rules such as overlay always directly on top of annotated element)
  • Absolute layering may be easily implemented using groups

Model new connections (connect elements)

It should be possible to connect a connection end to a shape

  • shapes should have a few 'docking points' for connections
  • during connection a visual indication is shown
  • connect command is fired and performs the actual connection

Same behavior for creating a new connection.

The svg group 'viewport' is displaced and doesn't scale accurately

While the main svg tag gets correctly placed, the g.viewport tag is slightly misplaced to the right and the bottom as you can see here
diagram_1

Furthermore while working on #51 I also realized that the scale calculations are sometime off by a few pixel as you can see here
diagram_2

In both pictures the black border marks a 800px wide and 500px tall div which is the canvas container. The used .bpmn file is the pizza-collaboration.bpmn which is also used in the bpmn.io demo.

Both issues can be seen in Firefox 33.0 and Chrome 37.0.

Centering of diagram

It would be good to have a method to center the rendered diagram on the canvas.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.