Repository navigation
Render the AI builder preview in the sandboxed frame - #1427
Open
vytisbulkevicius wants to merge 2 commits into
Open
vytisbulkevicius wants to merge 2 commits into
vytisbulkevicius wants to merge 2 commits into
Conversation
The builder preview and its code check now use the same sandboxed frame as the front end and the block editor. Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
Contributor
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The AI Chart Builder drew its preview directly in the admin page, while the front end and the block editor draw D3 charts in a sandboxed frame. The builder now uses the same frame for the preview and for its code check.
What changed
Builder preview — chart code runs in the sandboxed D3 frame (
sandbox="allow-scripts"), not in the admin page. The builder no longer bundles its own copy of D3 and TopoJSON.Code check — the check that runs before a chart is shown or saved uses a hidden sandboxed frame and waits for its result. A chart that gives no result in 10 seconds counts as failed.
D3 frame — after each render it reports the result to its parent as
{ type: 'render-result', error }.Note
Tracked in Codeinwp/visualizer-pro#658.
QA
Go to
WP Admin → Visualizer → Chart Library. Click Add New Chart, select the AI builder, add data and generate a chart.Expect: the preview shows the chart, and the chart saves.
In the library, click the edit control of that chart.
Expect: the builder opens and the preview shows the saved chart.
In the builder, ask for a change to the chart (for example, another colour).
Expect: the preview updates, and a chart with broken code shows an error message, not an empty preview.
🤖 Generated with Claude Code