jerosoler / Drawflow

Simple flow library 🖥️🖱️
https://jerosoler.github.io/Drawflow/
MIT License
4.7k stars 728 forks source link

Add support of link labels #687

Open mokaddem opened 1 year ago

mokaddem commented 1 year ago

Hello!

First of all, many thanks for all the effort spent on creating this awesome project!

I had to introduce the support of link labels and I felt like it would benefit the community to have this feature as well. Right now, each labels are created using HTML defined by the app, but we could think of a way to parametrize this part if you think the effort is worth it.

Here is how you could use it


const editor = new Drawflow(el)

// Define some labels in HTML
const label1 = '<span class="label label-info" id="lb-a">Label A</span>'
const label2 = '<span class="label label-warning" id="lb-b">Label B</span>'
const labels = [label1, label2]

// Labels will be automatically added if they exist
editor.addConnection(id_output, id_input, output_class, input_class, labels)

And here's what it looks like image

Let me know if you see issues or if you'd like me to change something. Cheers!

jerosoler commented 1 year ago

Hello! @mokaddem

Thanks for PR.

If labels is one thing missing.

There are alternatives to add the labels: