0x6b / copy-selection-as-markdown

Firefox add-on to copy selection as Markdown
https://addons.mozilla.org/en-US/firefox/addon/copy-selection-as-markdown/
MIT License
190 stars 14 forks source link

optionally embedd images as base64 #69

Open alexanderadam opened 4 years ago

alexanderadam commented 4 years ago

It's possible to embed images via data URLs in base64. For example

![Image](data:image/png;base64,SOMEBASE64STRING)

It would be nice if copy-selection-as-markdown would support this functionality as well. This way it would be easier to have a full backup of an article that might be deleted later on, including it's resources.

PS: Thank you for this extension :pray: PPS: There are also browser extensions like img2base64, that allow to copy an image as base64 directly. Maybe it would be possible to take that logic from there?

alexanderadam commented 4 years ago

There's also a tool for backing up Medium articles called medup that's doing this. What I like about the approach in medup is, that the images are only inlined at the end and there are only references to them within the regular text flow.

0x6b commented 4 years ago

@alexanderadam: Thanks a lot for your suggestion! I don't have your use case but interesting enhancement. challenge accepted!

0x6b commented 4 years ago

Will update this issue after release.

0x6b commented 4 years ago

@alexanderadam: Just released v0.20.4 which contains this feature. Grub your update and let me know if you found any issue. Thanks!

0x6b commented 4 years ago

Check Embed imgs (.gif, .jpg, .jpeg, .png, and .webp) as base64 text as possible at Advanced setting to enable the feature. It requires additional permission to access referenced images.

alexanderadam commented 4 years ago

@0x6b, Thank you so much for working on this. :raised_hands: Unfortunately it didn't work properly when I just tested this. I marked your avatar here on this issue page and I got a reference but it wasn't base64 encoded.

It looks like this:

[![@0x6b][img1]](https://github.com/0x6b) [ 0x6b](https://github.com/0x6b)

[img1]: https://avatars0.githubusercontent.com/u/679719?s=40&v=4

EDIT: Maybe it's a permission thing because it's working perfectly on other sites! I accepted the permission to access everything but it's not appearing at the listed permissions (only Input data to the clipboard is listed.):

Permissions of copy-selection-as-markdown

0x6b commented 4 years ago

Maybe I somehow misunderstand the optional permission concept. I also see permission error in the console like:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://github.githubassets.com/images/spinners/octocat-spinner-32.gif. (Reason: CORS header ‘Origin’ cannot be added).

Will work on this again. Thanks for testing!

EDIT: Easiest solution is to add <all_urls> permission request by default, but it's too open for advanced options.

alexanderadam commented 4 years ago

Easiest solution is to add <all_urls> permission request by default, but it's too open for advanced options.

I absolutely agree and I value your concerns in this regards. :+1: More people should focus which permissions their extension or app is using.