The return of the AttachFilePlugin - Drop Content Plugin

45 views
Skip to first unread message

james.v...@gmail.com

unread,
Apr 4, 2025, 4:53:04 AMApr 4
to TiddlyWikiClassic
Hi,

I have been looking for a way to get Eric Shulman's AttachFilePlugin to work with modern browser security. To get around the restrictions with the file picker, I ended up rolling my own plugin that uses drag-and-drop. See: https://github.com/fallwest/tiddly-node-saver/blob/james.westfall/drop_content_plugin/tiddlywiki-plugins/drop-content/DropContentMacro.js

This is an initial (working) draft. Try it out. Suggestions for improvement and pull requests welcome.

Best regards,

James Westfall

Yakov

unread,
Apr 10, 2025, 9:56:00 AMApr 10
to TiddlyWikiClassic
Hi James, thanks for sharing!

I'm afraid, it's quite unclear on how to use the plugin. Here's what I've found:
  1. It has no docs, but I can see that there's <<DropContent>> macro;
  2. The macro creates a drop area (note: although it adds "hover" class on dragover, it has no visual effect);
  3. On drop, it silently creates a tiddler named the same as filename, the text is just binary (I haven't checked if it is preserved correctly after saving and reloading); it's also not hidden, and opening such tiddler takes some time (which also complicates deleting/renaming);
  4. I don't know yet how to use the attached file: if I've dropped an image, how can I embed it? Can I do anything with other attachments (like show pdf in an iframe)?
Also, could you add a valid Source to the plugin (so that it's updated properly with EEP once you do some changes)?

Best regards,
Yakov

PS I wonder if we can reuse the code from HTML5DownloadSaveFile or maybe update it so that it's reusable for this case. Any ideas?

пятница, 4 апреля 2025 г. в 11:53:04 UTC+3, james.v...@gmail.com:

Yakov

unread,
Apr 10, 2025, 9:57:44 AMApr 10
to TiddlyWikiClassic
PS "valid Source" – in fact, Source and Version

четверг, 10 апреля 2025 г. в 16:56:00 UTC+3, Yakov:

Yakov

unread,
Apr 12, 2025, 6:31:26 AMApr 12
to TiddlyWikiClassic
Great, thanks for the update! Looks like you've accidentally sent the message to me, privately, here it is:

Hi Yakov,

Thanks for the good feedback! I have updated the documentation and followed your suggestion to reuse the code from HTML5DownloadSaveFile.
The plugin currently only works for text files, as for my own needs I just want to save various text formats (.ics, .xml, .json).
I'll merge the PR and update the source URL accordingly when it is agreed it looks good.

Best,
James

This makes much more sense now. A couple of other quick notes:
  1. I've tested the plugin with a .txt file and got the content wrapped with <script> tag inside the tiddler, I guess that's a bug;
  2. You may want to also check the usage of showOpenFilePicker and showSaveFilePicker in my ContinuousSavingPlugin – they are limited to Chromium-based browsers, but may be helpful to attach by picking (as an alternative option to drag-and-drop).
Best regards,
Yakov

четверг, 10 апреля 2025 г. в 16:57:44 UTC+3, Yakov:

james.v...@gmail.com

unread,
Apr 12, 2025, 8:28:15 AMApr 12
to TiddlyWikiClassic
Thanks for the fast feedabck Yakov!

The script is not a bug. The macro depends on the https://tiddlytools.com/Classic/#InlineJavascriptPlugin. I have added that to the documentation.
Thanks, I'll take a look at your filepicker code.

Best,

James
Reply all
Reply to author
Forward
0 new messages