diagram-js-code-editor/README.md

68 lines
1.7 KiB
Markdown
Raw Permalink Normal View History

2021-06-03 09:20:57 +00:00
# diagram-js Code Editor
2021-06-03 05:45:51 +00:00
2021-06-03 09:20:57 +00:00
[![Build Status](https://travis-ci.com/bpmn-io/diagram-js-minimap.svg?branch=master)]()
2021-06-03 05:45:51 +00:00
2021-06-03 09:20:57 +00:00
A code editor for diagram-js.
2021-06-03 05:45:51 +00:00
2021-06-03 09:20:57 +00:00
![Code Editor](resources/screenshot.png)
2021-06-03 05:45:51 +00:00
## Features
2021-06-03 09:20:57 +00:00
* [x] Modify script tasks with python formatting
* [ ] Tests scripts in place with feedback
2021-06-04 15:39:33 +00:00
* [x] View externally provided data and functions
2021-06-03 05:45:51 +00:00
## Usage
2021-06-03 09:20:57 +00:00
Extend your diagram-js application with the coding module. We'll use [bpmn-js](https://github.com/bpmn-io/bpmn-js) as an example:
2021-06-03 05:45:51 +00:00
```javascript
import BpmnModeler from 'bpmn-js/lib/Modeler';
2021-06-04 15:39:33 +00:00
import propertiesPanelModule from 'bpmn-js-properties-panel';
import propertiesProviderModule from 'bpmn-js-properties-panel/lib/provider/camunda';
2021-06-03 05:45:51 +00:00
2021-06-03 09:20:57 +00:00
import codingModule from 'diagram-js-code-editor';
2021-06-03 05:45:51 +00:00
2021-06-04 15:39:33 +00:00
2021-06-03 05:45:51 +00:00
var bpmnModeler = new BpmnModeler({
additionalModules: [
2021-06-04 15:39:33 +00:00
propertiesProviderModule,
propertiesPanelModule,
2021-06-03 09:34:26 +00:00
codingModule
2021-06-03 05:45:51 +00:00
]
});
2021-06-04 15:39:33 +00:00
bpmnModeler.get('eventBus').on('editor.validate.request', (request) => {
if (isGoodCode(request.code)){
} else {
}
bpmnModeler.get('eventBus').fire('editor.validate.response', {passing: true, msg: "msg"});
});
bpmnModeler.get('eventBus').on('editor.scripts.request', () => {
2021-06-04 20:19:37 +00:00
let scripts = [{name: "", description: ""}]
bpmnModeler.get('eventBus').fire('editor.scripts.response', {scripts: scripts});
});
bpmnModeler.get('eventBus').on('editor.objects.request', () => {
let data = [{userId: "int", description: "string"}]
bpmnModeler.get('eventBus').fire('editor.scripts.response', {objects: data});
2021-06-04 15:39:33 +00:00
});
2021-06-03 05:45:51 +00:00
```
For proper styling integrate the embedded style sheet:
```html
2021-06-04 15:39:33 +00:00
<link rel="stylesheet" href="diagram-js-code-editor/assets/diagram-js-code-editor.css" />
2021-06-03 05:45:51 +00:00
```
2021-06-03 09:20:57 +00:00
Please see [this example]() for a more detailed instruction.
2021-06-03 05:45:51 +00:00
## License
MIT