Listen for Compile/Run complete and access text of rendered HTML #689
Replies: 3 comments
-
I think we could use the useTranspiledCode hook. This API was designed to return the transpiled module from the active file, in which you could parse the content and use it for whatever you need. Let me know if it helps 😄 |
Beta Was this translation helpful? Give feedback.
-
FYI sandpack/sandpack-react/src/components/TranspiledCode/index.tsx Lines 35 to 46 in 8f50bb1 |
Beta Was this translation helpful? Give feedback.
-
I'd like to add some actions when clicking on decorators so I'm also trying to get an access to the rendered HTML in order to bind some event handlers. Can you please share some working example with I need something more complicated that just elements hiding on click so workarounds like: const decorators: Decorators = [];
decorators.push({
elementAttributes: { "onclick": String(`alert('decorator is clicked')`) },
...
}) isn't suitable in my case. UPD: few "dirty" workarounds found so far:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm interested in evaluating if the rendered HTML contains the correct image URL. This would help in assessing if the user is writing and running the code correctly. For example, I have some code that will render an image tag with a URL and I'd like to test if the image URL matches a regular expression. I see the image URL is in the iframe, but I can't access it there, and I don't know exactly when the HTML is rendered. https://poc-cloudinary-react-sandpack.netlify.app/
Beta Was this translation helpful? Give feedback.
All reactions