datocms / plugins

Repository providing samples using the Plugins SDK
MIT License
33 stars 47 forks source link

[Web Previews] Allow to configure the allow attribute of the iframe #89

Closed JanStevens closed 1 year ago

JanStevens commented 1 year ago

Hi,

When using web previews we want to have a bit more control over the iframe that is used to render the preview in the sidebar. Specifically we want to allow some browser features (like clipboard-write).

The easiest solution is to add configuration to specify the allow attribute in the plugin configuration (see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Permissions_Policy).

Additionally we could also work with toggles or features to enable or disable. I can make a PR for both solutions, WDYT?

Regards

stefanoverna commented 1 year ago

seems like a nice addition! go ahead, and thank you! ❤️

souljuse commented 1 year ago

Hi @JanStevens ! We can definitely do that! One question, would you find useful to specify iframe parameters other than allow? In this case, we can add a customizable FieldArray called iframeOptions, instead of just a Field for the allow parameter. Let me know :)

JanStevens commented 1 year ago

Sounds great I'll adapt the PR!

stefanoverna commented 1 year ago

But do you think it can be a good idea @JanStevens? What other attributes could be useful to send? 😕 I mean, other than allow.

JanStevens commented 1 year ago

I don't have a use case for any other attribute right now but using the Field Array makes it more extensible in the future so it seems a more logical way to go.

Full list of possible attributes: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe

JanStevens commented 1 year ago

@stefanoverna can we move on the PR https://github.com/datocms/plugins/pull/88 ? I honestly don't see any usage for any other attribute, it can always be added later if there is a valid use case for it

stefanoverna commented 1 year ago

Released in v1.0.13 of the plugin!