fix blocks rendering for code eval tool#11420
Open
srietkerk wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes block rendering in the code-eval tool’s SVG export path by correctly including Blockly’s renderer-injected CSS after the Blockly v11/v13 changes, ensuring text color and font-family rules are preserved in the rendered SVG output.
Changes:
- Update renderer style lookup to use the
style.blockly-renderer-styleclass (instead of a non-existentblockly-renderer-style-pxt-classicid). - Correct the DOM element type used when reading
blockly-common-styleCSS.
Comment on lines
+410
to
+413
| customCss.unshift((document.getElementById(`blockly-common-style`) as HTMLStyleElement)?.innerText || ""); | ||
| // Blockly injects renderer styles with className="blockly-renderer-style", not an id | ||
| const rendererStyle = document.querySelector(`style.blockly-renderer-style`) as HTMLStyleElement; | ||
| customCss.unshift(rendererStyle?.innerText || ""); |
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.
Fixes microsoft/pxt-microbit#6936
Via copilot, because I think it's a nice summary:
The code was looking up the renderer style element using
document.getElementById('blockly-renderer-style-pxt-classic'), but Blockly (since the v11/v13 upgrades) creates this element withclassName="blockly-renderer-style", not an id. So, the lookup returned null, and the critical CSS rules for text fill color and font-family were silently omitted from the rendered SVG.Without these CSS rules:
Text defaults to fill: black (SVG default) instead of white
Font falls back to the browser default instead of the configured monospace font
I also looked at the other blocks-svg scenarios with this change and they all look good!
Upload target: https://makecode.microbit.org/app/e5b98b20f43e1b7a1f340e51bb8818e4f3b613d8-a84451c729--eval