TiddlyWiki / TiddlyDesktop

A custom desktop browser for TiddlyWiki 5 and TiddlyWiki Classic, based on nw.js
1.69k stars 123 forks source link

_canonical_uri issue with Drag and Drop external files on Windows 10 #182

Open msalty opened 4 years ago

msalty commented 4 years ago

When I drag and drop an image file into a fresh Tiddlywiki (v5.1.21) in TiddlyDesktop on Windows 10 the auto-generated _canonical_uri is incorrect. If I open the tiddler containing the imported image, I received the 'broken-image-link' thumbnail. If I delete a single period from the front of the auto-generated _canonical_uri, the image shortcut is fixed.

Example Directory Structure: Tiddlywiki.html | | -- images\ example.jpg

If I drag and drop "example.jpg" into Tiddlywiki.html in TiddlyDesktop, the auto generated _canonical_uri is currently "../images/example.jpg" (note the leading double periods) and the image is not displayed properly in the resulting tiddler. If I remove a single leading period (to indicate current directory), the image link is corrected and the image is displayed properly. I have tested this on a couple machines and the behavior is the same on both. The auto-generated _canonical_uri is always one directory higher than the actual path of the file is.

victorpreuss commented 4 years ago

I also have this issue using TiddlyDesktop-linux64-v0.0.14. Everytime I drag and drop an external attachment, I need to fix the _canonical_uri to remove and additional leading period

A temporary fix for me was to edit https://github.com/Jermolene/TiddlyWiki5/blob/41a7d98e17470d23164420c0235b10f717a7a009/plugins/tiddlywiki/external-attachments/startup.js#L97 reducing in one iteration the loop (rootParts.length-1)