joplin-plugin-drawio icon indicating copy to clipboard operation
joplin-plugin-drawio copied to clipboard

Feature Request: judge the picture type by the extension name

Open SeptemberHX opened this issue 2 years ago • 6 comments

Currently only the ![drawio](xxx) style is treated as an editable drawio file, which makes it impossible to give it a clear title at the same time.

However, I notice await joplin.data.resourcePath(request.diagramId) can get the file path with extension like /Users/septemberhx/.config/joplin-desktop/resources/dcd0a67dc3fe493b8d36ae87212e7aa7.svg.

So I believe we can mime.lookup(await joplin.data.resourcePath(request.diagramId)) and get image/svg+xml

SeptemberHX avatar May 25 '22 14:05 SeptemberHX

Seems we cannot think all svg files are drawio files.

I also notice the drawio has to check a file before importing it: https://github.com/jgraph/drawio/blob/96f0e69647a1efc5b1b50b55d6f0fde39f8826c3/src/main/webapp/js/diagramly/DrawioFile.js at line 381.

I think it is not worth spending time on this since this plugin works fine now.

SeptemberHX avatar May 26 '22 02:05 SeptemberHX

I decided to force the image title to drawio for performance reason in order to not check every image in the notes. But it is something that could be changed.

marc0l92 avatar May 26 '22 13:05 marc0l92

Can we change the rule to 'drawio-' prefix or '-drawio' suffix ?

'drawio' makes me confused when writing markdown with multiple images.

I also use a plugin that can render the image with the title, and all the drawio images are with drawio image title after rendered.

SeptemberHX avatar May 27 '22 08:05 SeptemberHX

This is something I can do. If for you the title is important, I can change the plugin to look for a shorter suffix.

![my title.io](xxxxx)

marc0l92 avatar May 27 '22 12:05 marc0l92

👍 It looks nice ! But I am concerned about the compatibility to the images created by old versions for other users.

SeptemberHX avatar May 27 '22 13:05 SeptemberHX

Don't worry, I was planning to support both

marc0l92 avatar May 27 '22 15:05 marc0l92