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(puck context):added iframe ref to the puck context #652

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

IMythx
Copy link
Contributor

@IMythx IMythx commented Oct 11, 2024

added iframe ref to the puck context for the sake of accessing the iframe.contentWindow, iframe.contentDocument and listening to events...etc

potential use cases

1-

iframeRef?.current?.contentWindow?.matchMedia(...)?.matches

to give us the ability to create useMediaQuery custom hook inside the iframe which is differnet than doing it on the global window object (personally faced that case)

2-

iframeRef?.current?.addEventListener('load', (e)=>{
//update some elements or do something
})

and of course many other potential cases

Copy link

vercel bot commented Oct 11, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
puck-docs ✅ Ready (Inspect) Visit Preview Oct 11, 2024 11:03pm

Copy link

vercel bot commented Oct 11, 2024

@IMythx is attempting to deploy a commit to the Measured Team on Vercel.

A member of the Team first needs to authorize it.

@IMythx
Copy link
Contributor Author

IMythx commented Oct 11, 2024

Closes #640

Copy link
Member

@chrisvxd chrisvxd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, not sure if we actually need this - the Puck iframe does have a unique ID, so this could easily done by using #preview-frame selector.

@IMythx
Copy link
Contributor Author

IMythx commented Oct 14, 2024

Hmm, not sure if we actually need this - the Puck iframe does have a unique ID, so this could easily done by using #preview-frame selector.

oh i just noticed that unique id!
but what if it got changed in the future?? i mean there is no explicit indicator that someone is using this id

@chrisvxd
Copy link
Member

Yeah, that's a valid concern, and why I haven't closed this.

I think this PR requires a bit more consideration because it adds 2 new APIs (iframe ref in usePuck, and iframe.ref prop to Puck component). Hopefully the selector should help for the time-being.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants