Edited bindings

This commit is contained in:
NWalker4483 2021-06-03 06:56:40 -04:00
parent 81a38dfeed
commit 239cbcedec
1 changed files with 23 additions and 4 deletions

View File

@ -54,6 +54,7 @@ export default function Editor(
if (context.newSelection[0].type == "bpmn:ScriptTask") { if (context.newSelection[0].type == "bpmn:ScriptTask") {
domClasses(self._parent).add('enabled'); domClasses(self._parent).add('enabled');
self._state.isEnabled = true; self._state.isEnabled = true;
if(self.isOpen()){self.close(); self.open();} // close old window to reopen
return; return;
} }
} }
@ -75,11 +76,18 @@ Editor.$inject = [
]; ];
Editor.prototype._init = function () { Editor.prototype._init = function () {
var canvas = this._canvas, var canvas = this._canvas,
container = canvas.getContainer(); container = canvas.getContainer();
// create parent div // create parent div
var parent = this._parent = document.createElement('div'); var parent = this._parent = document.createElement('div');
// prevent drag propagation
domEvent.bind(parent, 'mousemove', function(event) {
event.stopPropagation();
});
domClasses(parent).add('djs-editor'); domClasses(parent).add('djs-editor');
@ -92,7 +100,12 @@ Editor.prototype._init = function () {
parent.appendChild(toggle); parent.appendChild(toggle);
// ? I'm pretty sure I can just create a template string that will hold all these definitions but I'll have to get into that
var main_window = document.createElement('div');
var toolbar = document.createElement('div');
// create ide textarea // create ide textarea
var ide_window = document.createElement('div'); var ide_window = document.createElement('div');
@ -102,7 +115,6 @@ Editor.prototype._init = function () {
parent.appendChild(ide_window); parent.appendChild(ide_window);
}; };
Editor.prototype.validate = function () { Editor.prototype.validate = function () {
// ! This parts gonna be hard // ! This parts gonna be hard
} }
@ -115,7 +127,7 @@ Editor.prototype.open = function () {
var translate = this._injector.get('translate', false) || function (s) { return s; }; var translate = this._injector.get('translate', false) || function (s) { return s; };
domAttr(this._toggle, 'title', translate('Close Editor')); domAttr(this._toggle, 'title', translate('Close Editor'));
if (this._state.isEnabled) {
this._ide = ace.edit("editor"); this._ide = ace.edit("editor");
//this._ide.setTheme("ace/theme/monokai"); //this._ide.setTheme("ace/theme/monokai");
this._ide.session.setMode("ace/mode/python"); this._ide.session.setMode("ace/mode/python");
@ -127,16 +139,23 @@ Editor.prototype.open = function () {
codestore.addEventListener("input", (event) => { codestore.addEventListener("input", (event) => {
this._ide.session.setValue(codestore.value); this._ide.session.setValue(codestore.value);
}); });
this._ide.addEventListener("input", (event) => { this._ide.addEventListener("input", (event) => {
codestore.value = this._ide.getValue(); codestore.value = this._ide.getValue();
}); });
}
this._eventBus.fire('editor.toggle', { open: true }); this._eventBus.fire('editor.toggle', { open: true });
}; };
Editor.prototype.close = function () { Editor.prototype.close = function () {
// if (this.isOpen()){
// this._codestore.focus();
// const e = new Event("change");
// this._codestore.dispatchEvent(e);
// }
assign(this._state, { isOpen: false }); assign(this._state, { isOpen: false });
domClasses(this._parent).remove('open'); domClasses(this._parent).remove('open');