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

[FEAT] Export a screenshot of the selected element #145

Open
drfarrell opened this issue Aug 12, 2024 · 4 comments
Open

[FEAT] Export a screenshot of the selected element #145

drfarrell opened this issue Aug 12, 2024 · 4 comments
Assignees
Labels
enhancement New feature or request hacktoberfest Great issues to tackle during hacktoberfest

Comments

@drfarrell
Copy link
Collaborator

Exporting elements in a browser as screenshots opens up a lot of really cool adjacent features such as attaching images to Onlook PRs, asset generation for documentation, and making it so much easier to render realistic images of the product for other creatives.

Filetypes

  • Webp
  • PNG
  • JPG
  • SVG <-- Perhaps the hardest to get right, but would be amazing for designers.

Functionality

  • Export to clipboard (so when a user "pastes" they paste the image)
  • Save as a file
@drfarrell drfarrell added the enhancement New feature or request label Aug 12, 2024
@drfarrell drfarrell added the hacktoberfest Great issues to tackle during hacktoberfest label Oct 16, 2024
@lcrojano
Copy link

I could work on this; this would be my approach

  1. Capturing Screenshots in the Browser:
    use the html2canvas and canvg
  2. Export to Filetypes:
    Convert the canvas to different image formats using the canvas.toDataURL() method.
  3. Export to Clipboard:
    Using the Clipboard API to allow users to copy the image to the clipboard after capturing.

@drfarrell
Copy link
Collaborator Author

drfarrell commented Oct 17, 2024

That was what I was probably going to try out – while you work on that, let me provide some mockups of where I'd expect the user to be able to interact with this...

I'm imagining they can do this from the right-click menu and the bottom part of the properties panel like what Figma has

The right-click menu where I'd imagine a "export as png" button would go (or we could make it a menu item that expands to the right for the filetype)
image

The lower right of our properties panel:
image

What Figma has:
image
image

If you have questions don't hesitate to reach out or feel free to jump in to discord

@Kitenite
Copy link
Contributor

@lcrojano , That sounds reasonable. One thing with html2canvas is that the library would need to be injected into the tag which can be difficult. 2 extra suggestions to consider:

  1. Electron has a screenshot API and we have the dimensions of the element on the page. It could be cut from the screenshot
  2. We get the style from the element so could potentially pull it into the app from the and use html2canvas there.

@drfarrell
Copy link
Collaborator Author

@lcrojano did you happen to give this a try? I'm super excited to see what you come up with!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hacktoberfest Great issues to tackle during hacktoberfest
Projects
None yet
Development

No branches or pull requests

3 participants