Closed motleydev closed 5 years ago
The issue is that the sandbox values are getting rendered as a comma separated list.
Hm, your link above seems to work for me (redirects to https://codesandbox.io/embed/oq040xjn6y?hidenavigation=1&view=editor). Are you still experiencing problems? Maybe CodeSandbox fixed this?
The issue is that the sandbox values are getting rendered as a comma separated list.
Ah I see what you mean now, the sandbox
attribute on the iframe is not being set correctly:
<iframe ... sandbox="allow-modals,allow-forms,allow-popups,allow-scripts,allow-same-origin">
Very interesting - just playing around with this a bit and it seems like it converts spaces to commas (but only on the sandbox
attribute!). Not sure where this is coming from... Remark or Gatsby themselves?
One way to get around it for now is to remove the sandbox
attribute altogether, although that doesn't seem like a good solution for security in the long run...
Hm, not sure how you're using the plugin @motleydev, but for me, I'm using gatsby-plugin-mdx
with the gatsbyRemarkPlugins
configuration option, and it seems like the MDX code that's generated in utils/gen-mdx.js
at the location below is returning an array instead of a string. See how sandbox
is returned as an array but sandbox-2
is a string...
I'm not sure if this is a bug in gatsby-plugin-mdx
or one of its dependencies, but getting closer...
cc @ChristopherBiscardi
Seems like it's actually a bit similar to the description in mdx-js/mdx#146 and mdx-js/mdx#158 too..
Hm, looks like a bug in MDX. If I call .join(' ')
on the .sandbox
property if it's an array, it fixes the issue.
Opened a PR at the MDX repo for this: https://github.com/mdx-js/mdx/pull/715/
@elboman @motleydev PR has been merged! This issue is fixed with @mdx-js/mdx@1.1.6
.
This issue can now be closed.
@elboman This can be closed now, whenever you get a chance.
Thanks!
No problem, glad to help :)
I'm using this with gatsby-mdx plugins and the embed is a black box.
My plugin usage:
Here's the link that get's generated:
https://codesandbox.io/api/v1/sandboxes/define?embed=1¶meters=N4IgZglgNgpgziAXKCA7AJjAHgOgFYLIgDGA9qgC4yVIjYAOpAThQASZgCGArlGwBQBKVgF4AfKwA6IABIwoUUqwDqzKOmkBuEAF8ANCHqdiAa04BzGPjjkkoMpWoU7IALac0tNJlwFdOgKA&query=hidenavigation%3D1%26view%3Deditor