alyssaxuu / flowy

The minimal javascript library to create flowcharts ✨

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Plugin system proposal

mateojovani opened this issue · comments

I want to introduce a very minimalistic plugin interface in order to extend the library but not modify the core engine itself.
This way it is easier for developers to extend the library as it is easier for the maintainer to not worry about the different complex use cases.

My proposal is simple.

flowy.load = function() {
...
   flowy.registerPlugins = function(plugins = []) {
        plugins.forEach(plugin => plugin(canvas_div, blocks, drag))
    }
}

This way you expose a context to the developers who wish to extend the library, such as:

var DeleteBlockPlugin = function (canvas, blocks, drag) {
    var deleteBlock = function () { ... }

    document.getElementById("delete-block").addEventListener("click", deleteBlock);
 }

flowy.registerPlugins([DeleteBlockPlugin,  ..., AddBlockPlugin])

Let me know what you think and if you are happy with this, I will proceed implementing it.
Thanks

Hello,

Is plug-in system available? or did u implemented the code changes?

Thanks.