# How can we inject 'lassoTool' or any diagram-js classes (like in custom palette provider using $inject) in a .ts file?

**URL:** <https://forum.camunda.io/t/how-can-we-inject-lassotool-or-any-diagram-js-classes-like-in-custom-palette-provider-using-inject-in-a-ts-file/26440>\
**Category:** Discussion & Questions\
**Created:** [March 29, 2021, 9:15pm UTC](https://forum.camunda.io/t/how-can-we-inject-lassotool-or-any-diagram-js-classes-like-in-custom-palette-provider-using-inject-in-a-ts-file/26440 "2021-03-29T21:15:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![deepu.v87](https://forum.camunda.io/user_avatar/forum.camunda.io/deepu.v87/32/13778_2.png) [@deepu.v87](https://forum.camunda.io/u/deepu.v87)\
**Post date:** [March 29, 2021, 9:15pm UTC](https://forum.camunda.io/t/how-can-we-inject-lassotool-or-any-diagram-js-classes-like-in-custom-palette-provider-using-inject-in-a-ts-file/26440/1 "2021-03-29T21:15:32Z")

</div>

We have a requirement to provide the Tools separately in another panel. I was hoping to create another panel if I could inject the lassoTool, spaceTool etc in a .ts file just like we could do in a custom palette provider js file.

I am new to UI world. Any help would be appreciated.

---

<div class="post-metadata">

**Author:** ![Niklas\_Kiefer](https://forum.camunda.io/user_avatar/forum.camunda.io/niklas_kiefer/32/14794_2.png) [@Niklas\_Kiefer](https://forum.camunda.io/u/Niklas_Kiefer)\
**Post date:** [March 30, 2021, 7:37am UTC](https://forum.camunda.io/t/how-can-we-inject-lassotool-or-any-diagram-js-classes-like-in-custom-palette-provider-using-inject-in-a-ts-file/26440/2 "2021-03-30T07:37:53Z")

</div>

Hi 👋

So do you already have your plugin written in Javascript and it’s working? Can you maybe share it? It should be possible to translate this into a `.ts` sibling.

---

<div class="post-metadata">

**Author:** ![deepu.v87](https://forum.camunda.io/user_avatar/forum.camunda.io/deepu.v87/32/13778_2.png) [@deepu.v87](https://forum.camunda.io/u/deepu.v87)\
**Post date:** [March 30, 2021, 1:04pm UTC](https://forum.camunda.io/t/how-can-we-inject-lassotool-or-any-diagram-js-classes-like-in-custom-palette-provider-using-inject-in-a-ts-file/26440/3 "2021-03-30T13:04:36Z")

</div>

I have a CustomPaletteProvider.js like below where I can inject anything from diagram-js. I just need to add it in constructor and use it in $inject block.

```
import PaletteProvider from 'bpmn-js/lib/features/palette/PaletteProvider';
export default function CustomPaletteProvider(palette, create, elementFactory, spaceTool, lassoTool, handTool, globalConnect, translate, bpmnFactoryObj) {
  var customPaletteProvider = new PaletteProvider(palette, create, elementFactory, spaceTool, lassoTool, handTool, globalConnect, translate);
}

CustomPaletteProvider.$inject = [
  'palette',
  'create',
  'elementFactory',
  'spaceTool',
  'lassoTool',
  'handTool',
  'globalConnect',
  'translate',
  'bpmnFactory'
];
PaletteProvider.prototype.getPaletteEntries = function (element) {
...
}

```

Now I have a .ts file like below where I would like to inject the lassoTool. How can i do it?

```
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
  title = 'bpmn-customize';
  modeler;
  constructor() {
     ...
  }

```

If there is any reference on the upgrade/downgrade components, please let me know. I can try it out. I think I must be missing some key concepts here.

I see ‘didi’ framework is used for DI in diagram-js. How do I make use of these modules injected in a .ts file?

---

<div class="post-metadata">

**Author:** ![deepu.v87](https://forum.camunda.io/user_avatar/forum.camunda.io/deepu.v87/32/13778_2.png) [@deepu.v87](https://forum.camunda.io/u/deepu.v87)\
**Post date:** [March 30, 2021, 9:16pm UTC](https://forum.camunda.io/t/how-can-we-inject-lassotool-or-any-diagram-js-classes-like-in-custom-palette-provider-using-inject-in-a-ts-file/26440/4 "2021-03-30T21:16:47Z")

</div>

I have found a solution that works for me.

Here are my Angular component and html files.  
app.component.ts  
app.component.html

**app.component.ts**  
I have the modeler object created in the ngOnInit() function.

```
ngOnInit(): void {
    var container = $('#js-drop-zone');
    const $modelerContainer = $('#js-canvas');
    this.modeler = new Modeler({
      container: $modelerContainer,
      additionalModules: [
        customControlsModule
      ],
      moddleExtensions: {
        camunda: camundaModdleDescriptor
      }
    });
}

```

I also have a click event function for lassoTool. Here I get the ‘lassoTool’ module from the modeler created in the ngOnInit() function.

```
  lassoToolActivate(event){
    var tool = this.modeler.get('lassoTool');
    tool.activateSelection(event);
  }

```

**app.component.html**  
I have a button outside of the div#js-drop-zone for lassoTool.

```
  <button class="entry bpmn-icon-lasso-tool" (click)="lassoToolActivate($event)">LassoTool</button>

```

Now the click on the lassoTool button activates the lassoTool on the canvas.

---

<div class="post-metadata">

**Author:** ![system](https://forum.camunda.io/uploads/default/original/3X/5/8/58d50142eacca605d35cb1ef9e6b86ae85f49436.png) [@system](https://forum.camunda.io/u/system)\
**Post date:** [January 30, 2024, 12:58pm UTC](https://forum.camunda.io/t/how-can-we-inject-lassotool-or-any-diagram-js-classes-like-in-custom-palette-provider-using-inject-in-a-ts-file/26440/5 "2024-01-30T12:58:50Z")

</div>

Closed on January 30, 2024, 12:58pm UTC


