Skip to content

Preserve checkbox inline styles when exporting block PNG/SVG#336

Merged
tracygardner merged 1 commit intomainfrom
codex/update-svg-styling-in-generatesvg-function
Mar 5, 2026
Merged

Preserve checkbox inline styles when exporting block PNG/SVG#336
tracygardner merged 1 commit intomainfrom
codex/update-svg-styling-in-generatesvg-function

Conversation

@tracygardner
Copy link
Contributor

Motivation

  • Export was replacing entire inline style attributes on text nodes which clobbered checkbox-specific display/visibility styles and caused exported images to misrepresent checked/unchecked boxes.
  • The goal is to normalize text appearance for readability while preserving checkbox inline behavior and any pre-existing inline style properties that should not be overwritten.

Description

  • In generateSVG(block) (main/export.js) changed the selector to target text.blocklyText and switched from setAttribute("style", ...) to per-property updates via textElement.style.fill, textElement.style.stroke, and textElement.style.fontWeight.
  • Detect .blocklyCheckbox on text nodes and skip applying readability overrides (stroke and fontWeight) to checkbox text nodes while still enforcing a normalized fill color.
  • Kept existing embedding of fonts and the stylesheet injection intact so exported SVGs still use the project font and field rect background normalization.

Testing

  • Ran a production build with npm run build which completed successfully.
  • Attempted an automated headless validation that exercised the block export and captured the generated SVG via Playwright, but the export callback environment did not expose the needed registry hooks in the headless run so checkbox-visibility confirmation was only partially validated (script ran but could not fully capture the export output).

Codex Task

@tracygardner tracygardner merged commit c55cffa into main Mar 5, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant