2017 © Pedro PelΓ‘ez
 

neos-plugin mxgraph

Integrate MXGraph / Draw.io into Neos as Node Type for creating interactive diagrams and flowcharts

image

sandstorm/mxgraph

Integrate MXGraph / Draw.io into Neos as Node Type for creating interactive diagrams and flowcharts

  • Tuesday, December 26, 2017
  • by sandstormmedia
  • Repository
  • 3 Watchers
  • 6 Stars
  • 429 Installations
  • HTML
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 13 % Grown

The README.md

Diagrams.net / Draw.io

(formerly known as MXGraph, that explains the name of this package)., (*1)

Integrates diagrams.net / Draw.io into Neos as Node Type for creating interactive diagrams and flowcharts, (*2)

Thanks to the awesome people from diagrams.net / Draw.io - without them this project would not be possible., (*3)

Demo

graphdemo, (*4)

Features

  • provides a Node Type "Diagram" which contains the rendered representation for the diagram and the internal xml code
  • you can click an inspector button opening the graph editor
  • when you save, the graph data is directly stored inside the Node
  • when you save the graph, Neos refreshes automatically
  • (new since 3.x) all diagrams.net features supported
  • (new since 3.x) customization of diagrams.net editor possible
  • (new since 3.x, optional) auto-updates can be enabled by using embed.diagrams.net
  • (new since 3.x) renders diagram as embedded SVG; so you can f.e. click links
  • (new since 3.x) Import .drawio, .svg, .png files

How to install

  • Neos 8.x: composer install sandstorm/mxgraph - Version 3.x

then, enjoy :-), (*5)

Upgrading from Sandstorm.MxGraph 2.x to 3.x

In Sandstorm.MxGraph >= 3.0, we do not render the diagram as SVG image embedded via the <img>-Tag, but instead directly embed the SVG at that location. This has the benefit that f.e. links inside the diagram) will work as expected., (*6)

If you update from 2.x to 3.x, this change might break your styling. To get the old behavior back, set the following fusion configuration:, (*7)

prototype(Sandstorm.MxGraph:Diagram) {
    // BACKWARDS COMPATIBILITY: to get the old (2.x) behavior back, set to false.
    renderAsInlineSvg = false
}

You need to open and save diagrams created with version <= 2.X to render them as inline SVGs, because the internal storage format of the Node changed to enable this functionality (and this is only re-written on save)., (*8)

Custom Draw.io Configuration

Diagrams.net / Draw.io is very customizable (custom fonts, colors, presets, ...) - lots of configuration options documented here. These config options can be set via Settings.yaml at Sandstorm.MxGraph.drawioConfiguration, for example, the following sets up draw.io with colors and fonts for Neos.io:, (*9)

Sandstorm:
  MxGraph:
    # You can configure the diagram editor as explained here: https://www.diagrams.net/doc/faq/configure-diagram-editor
    # !! lots of options possible - see docs for details.
    drawioConfiguration:
      customFonts:
        - fontFamily: Work Sans
          fontUrl: https://fonts.googleapis.com/css?family=Work+Sans
      # Colour codes to be added before presetColors (no leading # for the colour codes, null for a blank entry)
      customPresetColors:
        - '26224C'
        - '00ADEE'
      # colorNames: Names for colors, eg. {β€˜FFFFFF’: β€˜White’, β€˜000000’: β€˜Black’} that are used as tooltips (uppercase, no leading # for the colour codes).
      colorNames:
        26224C: Neos Dark Blue
        00ADEE: Neos Light Blue

      # Available colour schemes in the style section at the top of the format panel (use leading # for the colour codes).
      # Possible colour keys are fill, stroke, gradient and font (font is ignored for connectors). An optional title can
      # be added to be used as a tooltip. An optional border can be added to define the CSS for the border width and type,
      # eg. β€˜2px solid’ or β€˜3px dashed’ (only setting the border width is not valid, the border type must be included).
      customColorSchemes:
        # !! the 1st array level is the **page**, then come the entries.
        -
          - title: Neos Light Blue solid
            fill: '#00ADEE'
            stroke: white
            border: 1px solid
            font: white
          - title: Neos Dark Blue solid
            fill: '#26224C'
            stroke: white
            border: 1px solid
            font: white
          - title: Neos Light Blue border
            fill: '#ffffff'
            stroke: '#00ADEE'
            border: 2px solid
            font: '#00ADEE'

Importing files

In the inspector, there is a button to import a drawio file. This works for:, (*10)

  • .drawio files
  • .drawio.png files (PNG files where the diagram is embedded)
  • .drawio.svg files (SVG files where the diagram is embedded)

Further Customization of embed mode via URL parameters

Until version <= 2.x, we've used a repository https://github.com/jgraph/mxgraph as basis. This has been discontinued at 9.11.2020; and the code has been merged into https://github.com/jgraph/drawio/tree/dev/src/main/webapp., (*11)

For version 3, the implementation has been completely re-done; and it looks like this:, (*12)

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                                        β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚   β”‚       embed.diagrams.net       β”‚   β”‚
β”‚   β”‚       - Diagram Editor -       β”‚   β”‚
β”‚   β”‚                                β”‚   β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚               outer shell              β”‚
β”‚ (communicates with diagrams.net in     β”‚
β”‚  iFrame, and with Neos)                β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

We follow the documentation of the embed mode. The outer shell embeds diagrams.net in an iFrame, and communicates initially via URL parameters, and then via postMessage API., (*13)

We use the following URL parameters: - embed=1: enables embed mode, required - configure=1: allows to inject draw.io configuration from the outside, required. - proto=json: modern, json-based postMessage API, required., (*14)

On top, the following optional URL parameters are set by default, but could be disabled / overridden via Settings.yaml at key Sandstorm.MxGraph.drawioEmbedParameters:, (*15)

  • ui=simple: Use the modern UI theme. the other themes are listed here
  • lockdown=1: Ensure no data is transmitted to external services. see this explanation
  • stealth=1: Disables all features that require external web services (such as PDF export).
  • test=1: if enabled, debug logs are printed to the console.
  • math=0: disables MathML support. (MathML is disabled for fully-disconnected mode; because it would grow the Neos package considerably).

Fully-Disconnected Mode

By using embed.diagrams.net in the iFrame, you get the following properties:, (*16)

Pros:, (*17)

  • Auto-updated to new versions of diagrams.net, so you can use the latest features
  • Integration path is officially supported by the diagrams.net team
  • All cloud features (like PDF export) can be enabled if you want.
  • All features can be used.

Cons: - While the diagram data is not leaving your local computer (for almost all use cases), the IP address of your editors is still sent to embed.diagrams.net. We believe this constitutes personal data under the GPDR; so you need to ask for consent from your editors., (*18)

That's why we additionally have implemented a fully-disconnected mode:, (*19)

There, the full draw.io application has been bundled inside this Neos package, with no external calls being made. We cannot be 100% sure that all Draw.io functionality will work, but we did not find any problems so far., (*20)

That's why the fully disconnected mode is enabled by default, by setting Sandstorm.MyGraph.drawioEmbedUrl=LOCAL, (*21)

License

GPL v3, (*22)

Created with ❀ by sandstorm|media 2016-2023., (*23)

The Versions

26/12 2017

dev-master

9999999-dev

Integrate MXGraph / Draw.io into Neos as Node Type for creating interactive diagrams and flowcharts

  Sources   Download

The Requires

 

26/12 2017

2.0.0

2.0.0.0

Integrate MXGraph / Draw.io into Neos as Node Type for creating interactive diagrams and flowcharts

  Sources   Download

The Requires

 

16/12 2016

1.0.x-dev

1.0.9999999.9999999-dev

Integrate MXGraph / Draw.io into Neos as Node Type for creating interactive diagrams and flowcharts

  Sources   Download

The Requires

 

16/12 2016

1.0.1

1.0.1.0

Integrate MXGraph / Draw.io into Neos as Node Type for creating interactive diagrams and flowcharts

  Sources   Download

The Requires

 

02/12 2016

1.0.0

1.0.0.0

Integrate MXGraph / Draw.io into Neos as Node Type for creating interactive diagrams and flowcharts

  Sources   Download

The Requires