Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload inserted images to a backend #60

Open
PaddiM8 opened this issue Aug 31, 2023 · 3 comments
Open

Upload inserted images to a backend #60

PaddiM8 opened this issue Aug 31, 2023 · 3 comments

Comments

@PaddiM8
Copy link
Contributor

PaddiM8 commented Aug 31, 2023

It would be nice to have some way to automatically upload inserted images to a backend and then use the returned URL, if it isn't possible already. Right now it doesn't seem to be possible to paste some types of images as well (when the clipboard data doesn't contain an external url?).

Maybe it could simply be handled by some event with a callback?

@PaddiM8
Copy link
Contributor Author

PaddiM8 commented Aug 31, 2023

Ok, I might have a solution that fixes the problem where some images can't be pasted, while also making it possible to replace the URL of pasted images.

In ImagePlugin, I dispatch an insert event for INSERT_IMAGE_COMMAND, that contains the image's src and an ImageNode. I also added a registerCommand call for PASTE_COMMAND, which converts pasted images to base64 in order to make it possible to paste any kind of copied image, and then the same things are done as for INSERT_IMAGE_COMMAND.

This is probably what I'm going to use for myself at least, but I could also make PR if anything here is relevant for the official svelte-lexical. Will also think a bit more about the structure.

@umaranis
Copy link
Owner

umaranis commented Sep 4, 2023

Hi @PaddiM8 ,

Perhaps this could be added to one of the demos, instead of the svelte-lexical core. Is your code in an open source repo? Can I have a look please?

Thanks.

@PaddiM8
Copy link
Contributor Author

PaddiM8 commented Sep 4, 2023

Hi. I made modifications to the core package in my fork to make this possible. It's available here https://github.com/PaddiM8/svelte-lexical/tree/fix-image-paste

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants