PencilCode / pencilcode

An online IDE for kids: pencilcode.net.
http://dev.pencilcode.net/
MIT License
167 stars 100 forks source link

Cannot preview SVG #186

Open davidbau opened 9 years ago

davidbau commented 9 years ago

It seems that data:image/svg... image URLS are counted as tainted by the browsers (since it may hide url references within the svg), which means we can not screenshot SVG preview.

We should see if it is possible to preview an .svg file in a different way that can be screenshot.

davidbau commented 9 years ago

(Related to recently-closed bug #183)

weihang7 commented 9 years ago

A quick Google search yields https://github.com/gabelerner/canvg. It seems to transfer the rendering to JavaScript to bypass the cross-domain restriction.

davidbau commented 9 years ago

Yes, but here's something simpler: I suspect if we use an inline rather than an , then the browser won't have the cross-domain problem because it will see there is not URL reference in our SVG.

Note that html2canvas already includes svg rendering logic - a different implementation than canvg I believe. But it doesn't know how to get around an svg data-url.

On Wed, Aug 5, 2015 at 9:44 AM, Weihang Fan notifications@github.com wrote:

A quick Google search yields https://github.com/gabelerner/canvg. It seems to transfer the rendering to JavaScript to bypass the cross-domain restriction.

— Reply to this email directly or view it on GitHub https://github.com/PencilCode/pencilcode/issues/186#issuecomment-128000267 .

weihang7 commented 9 years ago

Darn. I misunderstood and thought it was already an inline svg, and was confused as to why the browser rejected it...

xinan commented 9 years ago

I could try to play around the svg version of html2canvas to see how it goes.

davidbau commented 9 years ago

Assigning to @xinan - feel free to bounce it back if you don't have time.