function Editor(
    config, injector, eventBus,
    canvas, elementRegistry) {
  const self = this;

  this._canvas = canvas;
  this._elementRegistry = elementRegistry;
  this._eventBus = eventBus;
  this._injector = injector;

  this._state = {
    isOpen: undefined,
  };

  this.init();

  this.toggle((config && config.open) || false);

  domEvent.bind(this.toggle_btn, 'click', function(event) {
    event.preventDefault();
    event.stopPropagation();

    self.toggle();
  });

  domEvent.bind(this.run_btn, 'click', function(event) {
    event.preventDefault();
    event.stopPropagation();

    self.validate();
  });

  domEvent.bind(this._parent, 'wheel', function(event) {
    // stop propagation and handle scroll differently
    event.preventDefault();
    event.stopPropagation();
    console.log("wheel");
  });

  // Check that the currently selected bpmn task is a script task and enable or disable coding window appropriately
  eventBus.on('selection.changed', function(context) {
    if (self.isOpen()) {
      self.close();
    }
    domClasses(self._parent).remove('enabled');
    if (context.newSelection.length > 0) {
      console.log(context.newSelection);
      if (context.newSelection[0].type == 'bpmn:ScriptTask' && true) { // TODO: Check if opened task is 'inline script'
        domClasses(self._parent).add('enabled');
      }
    }
  });

  // Returns
  eventBus.on('editor.validation.response', function(response) {
    self.set_valid_state(response.state);
    if (self.marker_id){
      self._ide.session.removeMarker(self.marker_id);
    }
    if (response.line_number) {
      self.marker_id = self._ide.session.addMarker(new Range(response.line_number - 1, 0, response.line_number - 1, 1), "errorMarker", "fullLine");
    }
  });

  // Return a list of objects containing both the script name and description in plain text
  eventBus.on('editor.scripts.response', function(response) {
    if (response.scripts && response.scripts.length > 0) {
      self.scripts = response.scripts;
    } else {
      self.scripts = [{
        name: 'No Scripts Available',
        description: 'Contact your system administrator if this is abnormal',
      }];
    }

    self.scripts_menu.innerHTML = '';
    self.scripts.forEach((element) =>
      self.scripts_menu.innerHTML += `<li><a class="dropdown-item">${element.name}</a><div class="description">${element.description}</div></li>`);// <ul><li>${element.description}</ul></li>`); // <div class="description">${element.description}</div>
  });

  // Return a single object containing all data available to the open task
  eventBus.on('editor.objects.response', function(response) {
    self.objects = response.objects;

    function recurseObject(data) {
      let html = '';
      for (const [key, value] of Object.entries(data)) {
        if (typeof value == 'object' && value != undefined) {
          html += `<li><a class="dropdown-item">${key} &raquo;</a><ul class="submenu dropdown-menu">` + recurseObject(value) + '</ul></li>';
        } else {
          let type = typeof value;
          if (value == undefined) {
            type = 'undefined';
          }
          html += `<li><a class="dropdown-item">${key}<div class="data-type ${type}">${type}</div></a></li>`;
        }
      }
      return html;
    }

    self.objects_menu.innerHTML = recurseObject(self.objects);
  });
}
/**
 * A code editor that allows you to add syntax highlighting and testing to bpmn properties panel
 */
A code editor that allows you to add syntax highlighting and testing to bpmn properties panel
A code editor that allows you to add syntax highlighting and testing to bpmn properties panel
function Editor(
    config, injector, eventBus,
    canvas, elementRegistry) {
  const self = this;
  this._canvas = canvas;
  this._elementRegistry = elementRegistry;
  this._eventBus = eventBus;
  this._injector = injector;
  this._state = {
    isOpen: undefined,
  };
  this.init();
  this.toggle((config && config.open) || false);
  domEvent.bind(this.toggle_btn, 'click', function(event) {
    event.preventDefault();
    event.stopPropagation();
    self.toggle();
  });
  domEvent.bind(this.run_btn, 'click', function(event) {
    event.preventDefault();
    event.stopPropagation();
    self.validate();
  });
  domEvent.bind(this._parent, 'wheel', function(event) {
    event.preventDefault();
    event.stopPropagation();
    console.log("wheel");
  });
  eventBus.on('selection.changed', function(context) {
    if (self.isOpen()) {
      self.close();
    }
    domClasses(self._parent).remove('enabled');
    if (context.newSelection.length > 0) {
      console.log(context.newSelection);
      if (context.newSelection[0].type == 'bpmn:ScriptTask' && true) { 
        domClasses(self._parent).add('enabled');
      }
    }
  });
  eventBus.on('editor.validation.response', function(response) {
    self.set_valid_state(response.state);
    if (self.marker_id){
      self._ide.session.removeMarker(self.marker_id);
    }
    if (response.line_number) {
      self.marker_id = self._ide.session.addMarker(new Range(response.line_number - 1, 0, response.line_number - 1, 1), "errorMarker", "fullLine");
    }
  });
  eventBus.on('editor.scripts.response', function(response) {
    if (response.scripts && response.scripts.length > 0) {
      self.scripts = response.scripts;
    } else {
      self.scripts = [{
        name: 'No Scripts Available',
        description: 'Contact your system administrator if this is abnormal',
      }];
    }
    self.scripts_menu.innerHTML = '';
    self.scripts.forEach((element) =>
      self.scripts_menu.innerHTML += `<li><a class="dropdown-item">${element.name}</a><div class="description">${element.description}</div></li>`);
  });
  eventBus.on('editor.objects.response', function(response) {
    self.objects = response.objects;
    function recurseObject(data) {
      let html = '';
      for (const [key, value] of Object.entries(data)) {
        if (typeof value == 'object' && value != undefined) {
          html += `<li><a class="dropdown-item">${key} &raquo;</a><ul class="submenu dropdown-menu">` + recurseObject(value) + '</ul></li>';
        } else {
          let type = typeof value;
          if (value == undefined) {
            type = 'undefined';
          }
          html += `<li><a class="dropdown-item">${key}<div class="data-type ${type}">${type}</div></a></li>`;
        }
      }
      return html;
    }
    self.objects_menu.innerHTML = recurseObject(self.objects);
  });
}
function Editor ( config , injector , eventBus , canvas , elementRegistry ) { const self = this ; this . _canvas = canvas ; this . _elementRegistry = elementRegistry ; this . _eventBus = eventBus ; this . _injector = injector ; this . _state = { isOpen : undefined , } ; this . init ( ) ; this . toggle ( ( config && config . open ) || false ) ; domEvent . bind ( this . toggle_btn , 'click' , function ( event ) { event . preventDefault ( ) ; event . stopPropagation ( ) ; self . toggle ( ) ; } ) ; domEvent . bind ( this . run_btn , 'click' , function ( event ) { event . preventDefault ( ) ; event . stopPropagation ( ) ; self . validate ( ) ; } ) ; domEvent . bind ( this . _parent , 'wheel' , function ( event ) { event . preventDefault ( ) ; event . stopPropagation ( ) ; console . log ( "wheel" ) ; } ) ; eventBus . on ( 'selection.changed' , function ( context ) { if ( self . isOpen ( ) ) { self . close ( ) ; } domClasses ( self . _parent ) . remove ( 'enabled' ) ; if ( context . newSelection . length > 0 ) { console . log ( context . newSelection ) ; if ( context . newSelection [ 0 ] . type == 'bpmn:ScriptTask' && true ) { domClasses ( self . _parent ) . add ( 'enabled' ) ; } } } ) ; eventBus . on ( 'editor.validation.response' , function ( response ) { self . set_valid_state ( response . state ) ; if ( self . marker_id ) { self . _ide . session . removeMarker ( self . marker_id ) ; } if ( response . line_number ) { self . marker_id = self . _ide . session . addMarker ( new Range ( response . line_number - 1 , 0 , response . line_number - 1 , 1 ) , "errorMarker" , "fullLine" ) ; } } ) ; eventBus . on ( 'editor.scripts.response' , function ( response ) { if ( response . scripts && response . scripts . length > 0 ) { self . scripts = response . scripts ; } else { self . scripts = [ { name : 'No Scripts Available' , description : 'Contact your system administrator if this is abnormal' , } ] ; } self . scripts_menu . innerHTML = '' ; self . scripts . forEach ( ( element ) => self . scripts_menu . innerHTML += ` ${ element . name } ${ element . description } ` ) ; } ) ; eventBus . on ( 'editor.objects.response' , function ( response ) { self . objects = response . objects ; function recurseObject ( data ) { let html = '' ; for ( const [ key , value ] of Object . entries ( data ) ) { if ( typeof value == 'object' && value != undefined ) { html += ` ${ key } ` + recurseObject ( value ) + '</ul></li>' ; } else { let type = typeof value ; if ( value == undefined ) { type = 'undefined' ; } html += ` ${ key } ${ type } ${ type } ` ; } } return html ; } self . objects_menu . innerHTML = recurseObject ( self . objects ) ; } ) ; }
A code editor that allows you to add syntax highlighting and testing to bpmn properties panel
A code editor that allows you to add syntax highlighting and testing to bpmn properties panel
// stop propagation and handle scroll differently // Check that the currently selected bpmn task is a script task and enable or disable coding window appropriately // TODO: Check if opened task is 'inline script' // Returns // Return a list of objects containing both the script name and description in plain text // <ul><li>${element.description}</ul></li>`); // <div class="description">${element.description}</div> // Return a single object containing all data available to the open task