prismicio / prismic-toolbar

An embeddable UI for Prismic content and previews directly on your website.
12 stars 19 forks source link

mh - feat(fallback image if html2canvas fails) #78

Closed mikemjharris closed 3 years ago

mikemjharris commented 3 years ago

Issue

On some pages of our website, when we try to create a prismic preview link, the html2canvas code errors. We haven't been able to find out why the error happens. When this errors no request gets sent off to get a preview link.

This blocks us from sharing previews from some pages on our site. While we can debug on our side that issue (I guess some way of how we build our page) it feels like we could handle errors in that step more gracefully. It looks like an image is required when creating the preview link when posting off to the server.

The solution we have implemented is to catch any errors, attach a blank canvas to the page and use that to create a blank sreenshot. This results in us getting a working preview link although without a preview image.

I haven't been able to create a sandboxed example of this so I've uploaded a video taking you through a broken example on our live site and the code in this pull request running locally that fixes it.

The toolbar is fantastic and we use the preview a lot - thanks for all your work on it. Fixing this edge case would be super helpful for us - let me know if you have any thoughts or suggestions on either improving or tackling this issue in another way.

https://user-images.githubusercontent.com/1722189/106042355-d9e61580-60d4-11eb-9c66-e2bebbce95a3.mp4