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

Add ability to paste images into editor #222

Conversation

abdullahceylan
Copy link
Contributor

Summary

This PR allows the user to paste images into the editor and automatically convert it to markdown. #216

Preview

2021-10-31 23 53 58

@vercel
Copy link

vercel bot commented Nov 1, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/katherinepeterson/readme-so/3Vq1xAg16NyQk9aKg1ggfqhKRYYL
✅ Preview: https://readme-so-git-fork-abdullahceylan-feat-69093d-katherinepeterson.vercel.app

console.warn('no image here')
return
}
const url = img.src
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this probably won't work if you copy an image from your file system/desktop right?

}

useEffect(() => {
window.addEventListener('paste', handleImagePaste)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we just add the event listener to the editor instead of the window?

// get image from DOM
const img = parsed.querySelector('img')
if (!img) {
console.warn('no image here')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably don't need to warn since it's totally valid to just paste text. we want to make sure we don't lose that ability too

@octokatherine
Copy link
Owner

@abdullahceylan I'm going to close this due to inactivity, but feel free to open again!

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

Successfully merging this pull request may close these issues.

2 participants