Extension:DrawioEditor

DrawioEditor is a MediaWiki extension that integrates the draw.io flow chart editor and allows inline editing of charts.

= Warnings = Please read these warnings carefully before use:
 * The default editor functionality is loaded from draw.io (for configuration options see below). This code only provides integration.
 * The actual editor functionality is loaded from draw.io. This code only provides integration.
 * Be aware that draw.io is an online service and while this plugin integrates the editor using an iframe and communicates with it only locally in your browser (javascript postMessage), it cannot guarantee that the code loaded from draw.io will not upload any data to foreign servers. This may be a privacy concern. Read the Privacy section in the documentation on GitHub for more information. When in doubt, don't use draw.io or this module. You have been warned!
 * This plugin is quite new and probably still has bugs, so it may or may not work with your installation.

= Features =
 * draw.io chart creation and editing.
 * SVG and PNG support. The file type can be configured globally and changed on a per-image basis.
 * Inline Editing and javascript uploads on save, you never leave or reload the wiki page.
 * Image files are transparently stored in the standard wiki file store, you don't need to worry about them.
 * Versioning is provided by the file store, revert to an older version of the chart at any time.
 * Draw.io original XML data is stored within the image files, so only one file must be stored per chart.
 * Supports multiple charts per page.
 * Supports relative and fixed chart dimensions.

= Requirements =
 * When you intend to use SVG which is recommended, you might want to install Extension:NativeSvgHandler too. Also you need a browser that supports SVG.
 * While displaying charts may work in older browsers, especially when using PNG (SVG is default and recommended), saving charts requires a fairly recent browser.

= Installation =

= Configuration =

$wgDrawioEditorBackendUrl

To avoid the mentioned privacy concerns, you can change the URL of the editor using this setting in LocalSettings.php (i.e. use the officially provided docker image from jgraph/docker-drawio as server). The URL given here is used to load the draw.io/diagrams.net editor components embedded in an iframe, WARNING: changing this URL is officially not supported, but works, only change this for testing purpose or if know what you are doing! The default value is https://embed.diagrams.net.

= Usage =

Add a chart
 Add the following tag to any wiki page to insert a draw.io chart:

must be unique and will be used as the basename for the backing file. Save the wiki page. Since no chart exists at this point, a placeholder will be shown where you've put the drawio tag. Click on the Edit link at the top right of it. Draw your chart, click Save to save and Exit to leave Edit mode. 

Edit a chart
Each chart will have an Edit lilnk at it's top right. Click it to get back into the editor. Click Save to save and Exit to get out of the editor. If a wiki page has multiple charts, only one can be edited at the same time.

View or revert to old versions
On each save, a new version of the backing file will be added to the wiki file store. You can get there by clicking the chart while you're not editing. There you can look at and revert to old versions like with any file uploaded to the wiki.

Options
Options are appended to the tag separated by. For example:

Chart dimensions
While the defaults are good under most circumstances, it may be necessary to control how your chart is displayed. The following options can be used for that:


 * width: Sets the chart width. Defaults to.
 * max-width: Set the maximum chart width if width is relative. Defaults to.
 * height: Sets the chart height. Defaults to . Usually not used.

These option take any absolute CSS length value as argument, for example:



The keyword  has a special meaning and stands for the actual size of the chart. When the chart is saved, the image dimensions are automatically adjusted. Usually it's preferable to use  instead of a fixed pixel value.

The default behaviour is the let the chart scale ( and  ) until it reaches its actual width stored in the chart.

If you want it to scale further or less, you can adjust max_width manually. Use  to allow infinite scaling.

If you just want a fixed width, set width to  or some fixed CSS value and leave height on. Unless you need a fixed sized image area before the image is actually loaded or really need to scale based on height, there is usually no point in setting height. If you set it you probably should set width to, or when setting both use   so you don't need to update the values manually every time your image changes. Examples


 * Let the chart scale until it reaches its actual width (default):

Same as:


 * Let the chart scale until it's 800 px wide:


 * Let the chart scale infinitely:


 * Fixed width:


 * Fixed width using the actual chart width:


 * Fixed height and width using the actual chart dimensions:

File type

The file type to be used can be set to either png or svg. The default is svg unless you set $wgDrawioEditorImageType to png in LocalSettings.php.

Use an Object Tag
MediaWiki normally embeds images inside  tags and links them to their description page. If you want to use SVG multimedia functions (e.g. links) it has to be embedded as. This can be set using the interactive attribute or generally by enabling  in LocalSettings.php.

= Links =
 * draw.io
 * Anja Ebersbach: draw.io für MediaWiki und BlueSpice – Kollaborativ erstellte Zeichnungen, Hallo Welt! Blog on July 11, 2017. (german)