jgraph / drawio-desktop

Official electron build of draw.io
https://www.diagrams.net
Apache License 2.0
48.13k stars 4.83k forks source link

How to use a plugin in Desktop version of draw.io? #7

Closed Zaijo closed 6 years ago

Zaijo commented 6 years ago

Creating a diagram online (with a plugin) works well, also opening it works well, but when trying to create elements using a plugin, it doesn't offer the Extras -> Plugins menu.

How do I use a plugin locally?

tad-lispy commented 6 years ago

Hey! Just wanted to say thank you for Draw.io and that having plugins in the Electron app would be very cool.

We are using Draw.io for diagramming database schema (using SQL plugin) and keep diagrams in Git repository (as SVG+XML). GitHub integration works, but only for GitHub, is a little bit cumbersome and requires extensive permissions. Working with a desktop app and local filesystem would be preferable for us.

I understand that this may be technically challenging and not at the top of your priority list. If there is any workaround (maybe building from sources with a plugin code somewhere in the tree?) I would greatly appreciate hints.

alderg commented 6 years ago

We'll add plugins in the next release of the desktop version.

nickball-granta commented 6 years ago

Would be great if this could also work from a local URI (for true offline mode, eg on a plane), but I can't seem to make that work.

tobiashochguertel commented 6 years ago

@nickball-granta I use a local webserver on my laptop to serve the plugin. Quick and Easy via MAMP Pro.

image

image

image

image

NickABoen commented 5 years ago

Apologies for bumping this as it's a bit old, but thought I'd chime in as I just dealt with this with what I think is a simpler work around that was convenient for me.

A potentially more generic solution to this is to spin up a simple HTTP server with python. This can be done by navigating to whatever folder has the plugin files you want to host. Instructions are in the link but to summarize

With python 2 this is:

python -m SimpleHTTPServer

With python 3 this is:

python -m http.server

Which should spin up a local server on port 8000 by default (can be configured of course) with it's root pointing to the directory it ran from. Then to add the plugin you simply add it with the link

http://localhost:8000/<path from server root to file>

Like

http//localhost:8000/plugins/test_plugin.js

And that's it. Provided that python is already installed (which it will be on unix/linux systems but easy to install on Windows) it's a quick one-liner with no special configuration.

I'm not sure how robust this is for larger plugin libraries, but it worked for my single file case on Windows at least for both desktop and browser versions.