Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ci/release/changelogs/next.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
- `animate-interval` is no longer required, defaults to 1000ms for gifs [#2663](https://github.com/terrastruct/d2/pull/2663)
- renders:
- remote images are fetched more reliably [#2659](https://github.com/terrastruct/d2/pull/2659)
- d2cli:
- Update the body background that match the SVG background [#2745](https://github.com/terrastruct/d2/pull/2745)

#### Bugfixes ⛑️

Expand Down
8 changes: 8 additions & 0 deletions d2cli/static/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ function init(reconnectDelay) {
// we can't just set `d2SVG.innerHTML = msg.svg` need to parse this as xml not html
const parsedXML = new DOMParser().parseFromString(msg.svg, "text/xml");
d2SVG.replaceChildren(parsedXML.documentElement);

// Update the body/container background that match the SVG background
const bgRect = d2SVG.querySelector("rect");
if (bgRect && bgRect.hasAttribute("fill")) {
const bgColor = bgRect.getAttribute("fill");
document.body.style.backgroundColor = bgColor;
}

changeFavicon("/static/favicon.ico");
const svgEl = d2SVG.querySelector(".d2-svg");
// just use inner SVG in watch mode
Expand Down