Include visual component from npm that needs to be created with "new"

Hi @all.

I’d like to include a visual component from npm in our project (d3kit-timeline, can be found on github and UNPKG). The YouTube tutorial on the npm-Plugin only focuses on packages that have some in- and output, rather than displaying it as part of the GUI.

I’ve looked around a bit and found some similar requests already:

Most proper solutions revolve around the solution of creating a custom component that utilizes this package and is then loading into the project. For simple prototyping I’d rather prefer to make use of the NPM-Plugin in WeWeb.

My current assumption is, that is has to do with the instantiation. The above example with wavesurfer.js can be used without the “new” keyword (indicating that there is an instance already somewhere), whereas with d3kit-timeline needs to be created with “new”. I’ve not been able to create an instance (e.g. on a button click) and bind it to a selected div, similar to the example in wavesurfer.js. Alternatively it maybe really is a question of the “instance keyword” for the npm-Plugin, but I’ve not been able to successfully identify it.

Looking forward to any ideas/suggestions, thanks,
Eric

Hi @PRS-WeWeb :wave:

Sorry I missed your question before. Do you still need help with this?

I just imported LeaderLine and it seems to work.
You just need to check out for how you declare the new, so in my case it’s new LeaderLine(...)
so in NPM, i just imported it like this, and it seems to work. I’ll have to try.

Edit: Yup, works

@aurelie, forgive me not using wwLib.getFrontDocument() :d

1 Like

I don’t know if i will ever be able to forgive you :upside_down_face:

2 Likes