How to make my first draw.io plugin

31 views
Skip to first unread message

Spyke

unread,
May 23, 2024, 3:28:40 PMMay 23
to draw.io Q&A
Hi i would like to make a simple draw.io plugin. Something like showing a text message when a triangle object is placed.
I've coded in C# and WinForms but i've not much expirience in web stuff.

My current setup is:
- Ubuntu Virtual Machine
- Node.js and npm installed
https://github.com/jgraph/drawio repository cloned.
Example script:
// Wait for Draw.io to be ready
mxEvent.addListener(window, 'load', function() {
    // Add a listener for the shapeAdded event
    editor.addListener(mxEvent.SHAPE_ADDED, function(sender, evt) {
        // Get the added shape
        var shape = evt.getProperty('cell');
       
        // Check if the shape is a circle
        if (shape && shape.isVertex() && shape.style && shape.style[mxConstants.STYLE_SHAPE] === mxConstants.SHAPE_ELLIPSE) {
            // Show a text message
            alert('A circle has been added');
        }
    });
});
(this following ChatGPT indications)

But now i'm confused and i'm not sure where i have to put the code, how to compile it, how to test it, etc.

Thx for your help.

Reply all
Reply to author
Forward
0 new messages