Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions dev/docs/javascript-public-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,27 @@ window.addEventListener('editor-drawio::configure', event => {
});
```

### `editor-drawio::export`

This event is triggered when an export action is initiated in the embedded diagrams.net drawing editor. It allows for dynamic configuration of the export parameters of diagrams.net, offering greater flexibility and control over the export process.
See [this diagrams.net page](https://www.drawio.com/doc/faq/embed-mode) for details on the available options for the configure event.

#### Event Data

- `config` - The configuration object used for the export function in diagrams.net.
- The default settings include format: 'xmlpng', xml: message.xml, and spin: 'Updating drawing'.
- You can modify this object in-place to customize the export parameters as per your requirements.

##### Example

```javascript
// Set export scale parameter to 2
window.addEventListener('editor-drawio::export', event => {
const config = event.detail.config;
config.scale = 2;
});
```

### `editor-tinymce::pre-init`

This event is called before the TinyMCE editor, used as the BookStack WYSIWYG page editor, is initialised.
Expand Down
8 changes: 5 additions & 3 deletions resources/js/services/drawio.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ function drawEventExport(message) {
}

function drawEventSave(message) {
drawPostMessage({
action: 'export', format: 'xmlpng', xml: message.xml, spin: 'Updating drawing',
});
const config = {
format: 'xmlpng', xml: message.xml, spin: 'Updating drawing',
};
window.$events.emitPublic(iFrame, 'editor-drawio::export', {config});
drawPostMessage({action: 'export', ...config});
}

function drawEventInit() {
Expand Down