Skip to content

Turn any idea, plan, or codebase into a beautiful interactive diagram. An agent skill for Claude Code, Codex, and more.

v2.3: fix blurry raster exports, drop scale selector

tt-a1i6c6b75f291af
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f059693d..0bb719b7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,20 @@
All notable changes are documented here. Format loosely follows [Keep a Changelog](https://keepachangelog.com/).
+## [2.3.0] — 2026-04-15
+
+### Fixed
+- **Raster exports are now genuinely sharp.** Previously the browser rasterized the serialized SVG at its natural `viewBox` dimensions (e.g., 1000×680), and then `ctx.drawImage(img, 0, 0, width*scale, height*scale)` bitmap-upsampled that raster onto the canvas — which just blew up the pixels and produced a soft image. The new flow sets the serialized SVG's `width`/`height` to `4 × viewBox` so the browser rasterizes the vectors at target resolution natively; the canvas then draws at the image's natural size with no scaling. Result: text edges, arrow heads, and stroke details that are actually crisp at 4×.
+
+### Removed
+- **Scale selector (1× / 2× / 4×).** The selector introduced in 2.1 encouraged picking a low scale to "save file size", which (combined with the upsampling bug above) always produced the softest output. Replaced with a single hardcoded 4× render on every raster export. PNG file sizes grow ~3–4× but the output is visibly sharper. A typical diagram exports to 4000×2720 (~300–700 KB PNG).
+- `Left` / `Right` arrow key binding (used by the selector) removed from the menu keyboard nav. Up/Down/Home/End/Esc/Tab all preserved.
+- `archify-export-scale` localStorage key is no longer read or written (old values are harmless leftovers).
+
+### Changed
+- Toast no longer includes the scale suffix — now just "Copied PNG to clipboard" since the scale is always 4×.
+- JPEG/WebP quality bumped from 0.92 to 0.95 (file-size delta is tiny at 4× but the encoded edges look cleaner).
+
## [2.2.1] — 2026-04-15
### Fixed
diff --git a/README.md b/README.md
index 8ab09cf8..763bace0 100644
--- a/README.md
+++ b/README.md
@@ -1,19 +1,19 @@
# Archify
-**Generate beautiful architecture diagrams in chat. Switch dark / light. Copy to clipboard or export PNG / JPEG / WebP / SVG at 1× / 2× / 4×.**
+**Generate beautiful architecture diagrams in chat. Switch dark / light. Copy to clipboard or export crisp 4× PNG / JPEG / WebP / SVG.**
-Archify is a [Claude Skill](https://support.claude.com/en/articles/12512180-using-skills-in-claude) that turns a plain-English description of your system into a polished, self-contained architecture diagram — a single HTML file you can open, toggle themes on, copy to the clipboard, and export to any common image format.
+Archify is a [Claude Skill](https://support.claude.com/en/articles/12512180-using-skills-in-claude) that turns a plain-English description of your system into a polished, self-contained architecture diagram — a single HTML file you can open, toggle themes on, copy to the clipboard, and export at maximum resolution.
- **No design skills needed** — describe your architecture in English, get a diagram
- **Built-in theme toggle** — one click between dark and light, persists across sessions
- **Copy PNG to clipboard** — one click, paste straight into Slack / Notion / GitHub
-- **Export to image** — PNG, JPEG, WebP, or SVG at user-selected 1× / 2× / 4× scale
+- **Ultra-crisp image export** — PNG / JPEG / WebP rendered natively at 4× source resolution (no upsampling blur), or SVG for true vector
- **Self-contained HTML** — zero dependencies, share by sending the file
- **Iterate by chat** — "add Redis", "move auth to the left", "use emerald for the API"
![License](https://img.shields.io/badge/license-MIT-22c55e?style=flat-square)
![Claude](https://img.shields.io/badge/Claude-Skill-7C3AED?style=flat-square)
-![Version](https://img.shields.io/badge/version-2.2.1-0891b2?style=flat-square)
+![Version](https://img.shields.io/badge/version-2.3.0-0891b2?style=flat-square)
## Preview
@@ -23,7 +23,7 @@ Same diagram, two themes, one click to switch:
|---|---|
| ![Dark theme](examples/images/archify-dark.png) | ![Light theme](examples/images/archify-light.png) |
-The Export menu with the 1× / 2× / 4× scale selector and Copy-to-clipboard:
+The Export menu — Copy PNG to clipboard plus 4 download formats (all raster exports at 4× source resolution):
![Export menu](examples/images/archify-menu.png)
@@ -37,18 +37,17 @@ Live example: [`examples/web-app.html`](examples/web-app.html) — open in a bro
Archify is based on [Cocoon-AI/architecture-diagram-generator](https://github.com/Cocoon-AI/architecture-diagram-generator) v1.0 (dark-only, HTML output). 2.0 rewrote the template around a themeable CSS-variable system and added a client-side export pipeline; 2.1 extends that with copy-to-clipboard and selectable export scale:
-| Feature | v1.0 | Archify 2.0 | Archify 2.1 |
-|---|---|---|---|
-| Dark theme | Yes | Yes | Yes |
-| Light theme | — | Yes (toggle) | Yes (toggle) |
-| Theme persistence | — | `localStorage` + `prefers-color-scheme` | + URL param `?theme=` |
-| PNG download | manual screenshot | 2× retina | **1× / 2× / 4× user-selectable** |
-| JPEG / WebP download | — | 2× retina | **1× / 2× / 4×** |
-| SVG download | — | Vector, styles inlined | Same |
-| Copy PNG to clipboard | — | — | **Yes** (via `ClipboardItem`) |
-| Keyboard shortcuts | — | — | **<kbd>T</kbd> / <kbd>E</kbd> + full menu nav** |
-| Accessibility | — | — | **ARIA semantics + focus-visible** |
-| Styling model | Inline `fill` / `stroke` | CSS custom properties + semantic classes | Same |
+| Feature | v1.0 | 2.0 | 2.1 | 2.3 |
+|---|---|---|---|---|
+| Dark theme | Yes | Yes | Yes | Yes |
+| Light theme | — | Toggle | Toggle | Toggle + <kbd>T</kbd> shortcut |
+| PNG / JPEG / WebP download | manual screenshot | 2× upsampled | 1× / 2× / 4× selector | **4× natively rendered, no blur** |
+| SVG download | — | Vector, styles inlined | Same | Same |
+| Copy PNG to clipboard | — | — | Yes | Yes (always 4×) |
+| Keyboard shortcuts | — | — | <kbd>T</kbd> / <kbd>E</kbd> + menu nav | Same |
+| Accessibility | — | — | ARIA + focus-visible | Same |
+| Print stylesheet | — | — | — | Yes (from 2.2) |
+| Styling model | Inline `fill` / `stroke` | CSS custom properties + semantic classes | Same | Same |
## Quick start
@@ -117,18 +116,18 @@ Open the generated HTML in any browser. Top-right you'll see two buttons:
### Export menu
-| Control | What it does |
+| Action | What it does |
|---|---|
-| **1× / 2× / 4×** scale selector | Sets the raster output scale; remembered per-browser. 1× = compact, 2× = retina (default), 4× = print / slides. |
-| **Copy PNG** | Puts a PNG of the current diagram straight on your clipboard at the selected scale. Paste into Slack, Notion, GitHub, Figma. |
-| **Download PNG / JPEG / WebP** | Saves a raster image at the selected scale. JPEG/WebP are painted over the current theme's background (no alpha); PNG keeps transparency. |
-| **Download SVG** | Vector export with all styles inlined. Edit in Figma / Illustrator. Scale selector doesn't apply — SVG is resolution-independent. |
+| **Copy PNG** | Puts a PNG of the current diagram straight on your clipboard. Paste into Slack, Notion, GitHub, Figma. |
+| **Download PNG / JPEG / WebP** | Saves a raster image. JPEG/WebP are painted over the current theme's background (no alpha); PNG keeps transparency. |
+| **Download SVG** | Vector export with all styles inlined. Edit in Figma / Illustrator. Scales losslessly. |
+
+Every raster export (Copy PNG, Download PNG/JPEG/WebP) is rendered natively by the browser at **4× the diagram's intrinsic resolution** — the serialized SVG is given a `width`/`height` of `4 × viewBox`, rasterized by the browser at that resolution, and drawn to the canvas at natural size (no upsampling). This produces genuinely crisp output for retina displays, slides, and print. There is no scale dial — maximum sharpness is the default and the only option.
### Keyboard
- <kbd>T</kbd> anywhere — toggle theme
- <kbd>E</kbd> anywhere — open the Export menu
-- <kbd>←</kbd> <kbd>→</kbd> on the scale selector — switch scale
- <kbd>↑</kbd> <kbd>↓</kbd> inside the menu — navigate actions
- <kbd>Home</kbd> / <kbd>End</kbd> — jump to first / last action
- <kbd>Enter</kbd> / <kbd>Space</kbd> — activate
diff --git a/archify.zip b/archify.zip
index 06dd6241..c40b10dc 100644
Binary files a/archify.zip and b/archify.zip differ
diff --git a/archify/assets/template.html b/archify/assets/template.html
index 5334b55f..3ed89951 100644
--- a/archify/assets/template.html
+++ b/archify/assets/template.html
@@ -288,31 +288,6 @@
color: var(--text-dim);
font-size: 0.625rem;
}
- .toolbar .export-menu .export-scale {
- display: flex;
- gap: 0.25rem;
- padding: 0.125rem;
- }
- .toolbar .export-menu .export-scale button {
- flex: 1;
- width: auto;
- justify-content: center;
- padding: 0.3125rem 0.375rem;
- font-size: 0.7rem;
- border: 1px solid transparent;
- border-radius: 0.25rem;
- }
- .toolbar .export-menu .export-scale button[aria-checked="true"] {
- background: var(--toolbar-hover);
- border-color: var(--frontend-stroke);
- color: var(--frontend-stroke);
- }
- .toolbar .export-menu .export-sep {
- height: 1px;
- background: var(--toolbar-border);
- margin: 0.25rem 0.375rem;
- opacity: 0.6;
- }
/* Toast — brief feedback for actions like "copied" */
.archify-toast {
@@ -402,12 +377,6 @@
Export <span aria-hidden="true">&#9662;</span>
</button>
<div class="export-menu" id="export-menu" role="menu" aria-label="Export">
- <div class="export-scale" role="radiogroup" aria-label="Raster scale">
- <button data-scale="1" type="button" role="radio" aria-checked="false" title="1x (compact)">1&times;</button>
- <button data-scale="2" type="button" role="radio" aria-checked="true" title="2x (retina, default)">2&times;</button>
- <button data-scale="4" type="button" role="radio" aria-checked="false" title="4x (print / slides)">4&times;</button>
- </div>
- <div class="export-sep" aria-hidden="true"></div>
<button data-action="copy" type="button" role="menuitem" tabindex="-1">Copy PNG <span class="hint">clipboard</span></button>
<button data-format="png" type="button" role="menuitem" tabindex="-1">Download PNG</button>
<button data-format="jpeg" type="button" role="menuitem" tabindex="-1">Download JPEG</button>
@@ -670,12 +639,18 @@
/* ============================================================
Export — PNG / JPEG / WebP / SVG (download) and Copy PNG (clipboard)
- Raster scale is user-selectable (1x / 2x / 4x) and persists in
- localStorage. JPEG/WebP paint the current theme's background
- explicitly since those formats have no alpha.
+
+ Raster exports are always rendered at 4x source resolution for
+ maximum sharpness. The trick: we set the serialized SVG's
+ `width`/`height` to viewBox * 4 so the browser rasterizes the
+ vectors at that resolution natively. drawImage then draws at
+ the image's natural size (no upscaling = no blur).
+
+ JPEG/WebP paint the current theme's background explicitly since
+ those formats have no alpha channel.
============================================================ */
(function () {
- var SCALE_KEY = 'archify-export-scale';
+ var RASTER_SCALE = 4;
function diagramFilename() {
var title = (document.title || 'diagram').replace(/\s+Architecture(\s+Diagram)?$/i, '').trim();
@@ -695,13 +670,21 @@
* rasterized via an Image -> canvas pipeline (canvas does not read the
* host document's CSS).
*/
- function serializeSvg() {
+ function serializeSvg(scale) {
+ // scale: integer multiplier for intrinsic SVG pixel dimensions used by
+ // the raster path. Defaults to 1 (natural size) for SVG download.
+ scale = scale || 1;
+
var svg = document.querySelector('.diagram-container svg');
var clone = svg.cloneNode(true);
var vb = svg.viewBox.baseVal;
- clone.setAttribute('width', vb.width);
- clone.setAttribute('height', vb.height);
+ // Scale width/height so the browser rasterizes the vectors at target
+ // resolution directly. viewBox stays unchanged so coordinates don't
+ // shift. This is the key to sharp rasters — do NOT scale later via
+ // canvas upscaling.
+ clone.setAttribute('width', vb.width * scale);
+ clone.setAttribute('height', vb.height * scale);
clone.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
var theme = document.documentElement.getAttribute('data-theme') || 'dark';
@@ -756,8 +739,8 @@
return {
svgString: new XMLSerializer().serializeToString(clone),
- width: vb.width,
- height: vb.height
+ width: vb.width * scale,
+ height: vb.height * scale
};
}
@@ -773,27 +756,30 @@
}
function rasterize(format) {
- var data = serializeSvg();
+ // Serialize at RASTER_SCALE — the SVG itself will be rasterized by
+ // the browser at the target resolution. drawImage then draws at
+ // natural size, so no upsampling blur.
+ var data = serializeSvg(RASTER_SCALE);
var svgBlob = new Blob([data.svgString], { type: 'image/svg+xml;charset=utf-8' });
var svgUrl = URL.createObjectURL(svgBlob);
- var scale = getScale();
return new Promise(function (resolve, reject) {
var img = new Image();
img.onload = function () {
var canvas = document.createElement('canvas');
- canvas.width = data.width * scale;
- canvas.height = data.height * scale;
+ canvas.width = data.width;
+ canvas.height = data.height;
var ctx = canvas.getContext('2d');
if (format === 'jpeg') {
ctx.fillStyle = currentBg();
ctx.fillRect(0, 0, canvas.width, canvas.height);
}
- ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
+ // Draw at natural size — SVG was already rasterized at target res.
+ ctx.drawImage(img, 0, 0);
URL.revokeObjectURL(svgUrl);
var mime = format === 'jpeg' ? 'image/jpeg' :
format === 'webp' ? 'image/webp' : 'image/png';
- var quality = format === 'png' ? undefined : 0.92;
+ var quality = format === 'png' ? undefined : 0.95;
canvas.toBlob(function (blob) {
if (!blob) reject(new Error('toBlob returned null for ' + format));
else resolve(blob);
@@ -812,26 +798,6 @@
var items = function () {
return Array.prototype.slice.call(menu.querySelectorAll('button[role="menuitem"]'));
};
- var scaleButtons = function () {
- return Array.prototype.slice.call(menu.querySelectorAll('.export-scale button[data-scale]'));
- };
-
- // ---- Raster scale (1x / 2x / 4x) -------------------------------------
- function getScale() {
- var checked = menu.querySelector('.export-scale button[aria-checked="true"]');
- return checked ? parseInt(checked.dataset.scale, 10) : 2;
- }
- function setScale(scale) {
- var s = String(scale);
- scaleButtons().forEach(function (b) {
- b.setAttribute('aria-checked', b.dataset.scale === s ? 'true' : 'false');
- });
- try { localStorage.setItem(SCALE_KEY, s); } catch (_) {}
- }
- (function restoreScale() {
- var saved = parseInt(localStorage.getItem(SCALE_KEY), 10);
- if (saved === 1 || saved === 2 || saved === 4) setScale(saved);
- })();
// ---- Clipboard support ----------------------------------------------
function canCopyImage() {
@@ -903,28 +869,12 @@
});
// Keyboard navigation inside the menu.
- // Scale radio group: Left/Right moves + selects (roving tabindex).
// Menu items: Up/Down, Home/End.
// Esc closes + returns focus to trigger; Tab closes.
menu.addEventListener('keydown', function (e) {
if (e.key === 'Escape') { e.preventDefault(); close(true); return; }
if (e.key === 'Tab') { close(false); return; }
- var onScale = e.target.closest('.export-scale button');
- if (onScale) {
- var sb = scaleButtons();
- var idx = sb.indexOf(onScale);
- if (e.key === 'ArrowLeft' || e.key === 'ArrowRight') {
- e.preventDefault();
- var next = e.key === 'ArrowRight'
- ? sb[(idx + 1) % sb.length]
- : sb[(idx - 1 + sb.length) % sb.length];
- setScale(next.dataset.scale);
- next.focus();
- }
- return;
- }
-
var available = items().filter(function (i) { return !i.disabled; });
var current = available.indexOf(document.activeElement);
switch (e.key) {
@@ -972,7 +922,7 @@
return rasterize('png').then(function (blob) {
return navigator.clipboard.write([new ClipboardItem({ 'image/png': blob })]);
}).then(function () {
- toast('Copied PNG to clipboard (' + getScale() + 'x)');
+ toast('Copied PNG to clipboard');
}).catch(function (err) {
console.error(err);
alert('Copy failed: ' + (err && err.message ? err.message : 'unknown'));
@@ -980,9 +930,6 @@
}
menu.addEventListener('click', function (e) {
- var scaleBtn = e.target.closest('.export-scale button[data-scale]');
- if (scaleBtn) { setScale(scaleBtn.dataset.scale); return; }
-
var copyBtn = e.target.closest('button[data-action="copy"]');
if (copyBtn && !copyBtn.disabled) { runCopy(); return; }
diff --git a/examples/images/archify-light.png b/examples/images/archify-light.png
index 203dfa9c..dd71eacf 100644
Binary files a/examples/images/archify-light.png and b/examples/images/archify-light.png differ
diff --git a/examples/images/archify-menu.png b/examples/images/archify-menu.png
index 2f6f6dd5..b7d99bfe 100644
Binary files a/examples/images/archify-menu.png and b/examples/images/archify-menu.png differ
diff --git a/examples/web-app.html b/examples/web-app.html
index 82f7984d..d5bddead 100644
--- a/examples/web-app.html
+++ b/examples/web-app.html
@@ -288,31 +288,6 @@
color: var(--text-dim);
font-size: 0.625rem;
}
- .toolbar .export-menu .export-scale {
- display: flex;
- gap: 0.25rem;
- padding: 0.125rem;
- }
- .toolbar .export-menu .export-scale button {
- flex: 1;
- width: auto;
- justify-content: center;
- padding: 0.3125rem 0.375rem;
- font-size: 0.7rem;
- border: 1px solid transparent;
- border-radius: 0.25rem;
- }
- .toolbar .export-menu .export-scale button[aria-checked="true"] {
- background: var(--toolbar-hover);
- border-color: var(--frontend-stroke);
- color: var(--frontend-stroke);
- }
- .toolbar .export-menu .export-sep {
- height: 1px;
- background: var(--toolbar-border);
- margin: 0.25rem 0.375rem;
- opacity: 0.6;
- }
/* Toast — brief feedback for actions like "copied" */
.archify-toast {
@@ -402,12 +377,6 @@
Export <span aria-hidden="true">&#9662;</span>
</button>
<div class="export-menu" id="export-menu" role="menu" aria-label="Export">
- <div class="export-scale" role="radiogroup" aria-label="Raster scale">
- <button data-scale="1" type="button" role="radio" aria-checked="false" title="1x (compact)">1&times;</button>
- <button data-scale="2" type="button" role="radio" aria-checked="true" title="2x (retina, default)">2&times;</button>
- <button data-scale="4" type="button" role="radio" aria-checked="false" title="4x (print / slides)">4&times;</button>
- </div>
- <div class="export-sep" aria-hidden="true"></div>
<button data-action="copy" type="button" role="menuitem" tabindex="-1">Copy PNG <span class="hint">clipboard</span></button>
<button data-format="png" type="button" role="menuitem" tabindex="-1">Download PNG</button>
<button data-format="jpeg" type="button" role="menuitem" tabindex="-1">Download JPEG</button>
@@ -621,7 +590,7 @@
<!-- Footer -->
<p class="footer">
- Try <kbd>T</kbd> to toggle theme &middot; <kbd>E</kbd> for Export &middot; pick 1&times; / 2&times; / 4&times; scale &middot; PNG / JPEG / WebP / SVG or copy to clipboard &middot; <kbd>Cmd</kbd>+<kbd>P</kbd> for a clean printable page
+ Try <kbd>T</kbd> to toggle theme &middot; <kbd>E</kbd> for Export &middot; raster output is always 4&times; native resolution for maximum sharpness
</p>
</div>
@@ -670,12 +639,18 @@
/* ============================================================
Export — PNG / JPEG / WebP / SVG (download) and Copy PNG (clipboard)
- Raster scale is user-selectable (1x / 2x / 4x) and persists in
- localStorage. JPEG/WebP paint the current theme's background
- explicitly since those formats have no alpha.
+
+ Raster exports are always rendered at 4x source resolution for
+ maximum sharpness. The trick: we set the serialized SVG's
+ `width`/`height` to viewBox * 4 so the browser rasterizes the
+ vectors at that resolution natively. drawImage then draws at
+ the image's natural size (no upscaling = no blur).
+
+ JPEG/WebP paint the current theme's background explicitly since
+ those formats have no alpha channel.
============================================================ */
(function () {
- var SCALE_KEY = 'archify-export-scale';
+ var RASTER_SCALE = 4;
function diagramFilename() {
var title = (document.title || 'diagram').replace(/\s+Architecture(\s+Diagram)?$/i, '').trim();
@@ -695,13 +670,21 @@
* rasterized via an Image -> canvas pipeline (canvas does not read the
* host document's CSS).
*/
- function serializeSvg() {
+ function serializeSvg(scale) {
+ // scale: integer multiplier for intrinsic SVG pixel dimensions used by
+ // the raster path. Defaults to 1 (natural size) for SVG download.
+ scale = scale || 1;
+
var svg = document.querySelector('.diagram-container svg');
var clone = svg.cloneNode(true);
var vb = svg.viewBox.baseVal;
- clone.setAttribute('width', vb.width);
- clone.setAttribute('height', vb.height);
+ // Scale width/height so the browser rasterizes the vectors at target
+ // resolution directly. viewBox stays unchanged so coordinates don't
+ // shift. This is the key to sharp rasters — do NOT scale later via
+ // canvas upscaling.
+ clone.setAttribute('width', vb.width * scale);
+ clone.setAttribute('height', vb.height * scale);
clone.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
var theme = document.documentElement.getAttribute('data-theme') || 'dark';
@@ -756,8 +739,8 @@
return {
svgString: new XMLSerializer().serializeToString(clone),
- width: vb.width,
- height: vb.height
+ width: vb.width * scale,
+ height: vb.height * scale
};
}
@@ -773,27 +756,30 @@
}
function rasterize(format) {
- var data = serializeSvg();
+ // Serialize at RASTER_SCALE — the SVG itself will be rasterized by
+ // the browser at the target resolution. drawImage then draws at
+ // natural size, so no upsampling blur.
+ var data = serializeSvg(RASTER_SCALE);
var svgBlob = new Blob([data.svgString], { type: 'image/svg+xml;charset=utf-8' });
var svgUrl = URL.createObjectURL(svgBlob);
- var scale = getScale();
return new Promise(function (resolve, reject) {
var img = new Image();
img.onload = function () {
var canvas = document.createElement('canvas');
- canvas.width = data.width * scale;
- canvas.height = data.height * scale;
+ canvas.width = data.width;
+ canvas.height = data.height;
var ctx = canvas.getContext('2d');
if (format === 'jpeg') {
ctx.fillStyle = currentBg();
ctx.fillRect(0, 0, canvas.width, canvas.height);
}
- ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
+ // Draw at natural size — SVG was already rasterized at target res.
+ ctx.drawImage(img, 0, 0);
URL.revokeObjectURL(svgUrl);
var mime = format === 'jpeg' ? 'image/jpeg' :
format === 'webp' ? 'image/webp' : 'image/png';
- var quality = format === 'png' ? undefined : 0.92;
+ var quality = format === 'png' ? undefined : 0.95;
canvas.toBlob(function (blob) {
if (!blob) reject(new Error('toBlob returned null for ' + format));
else resolve(blob);
@@ -812,26 +798,6 @@
var items = function () {
return Array.prototype.slice.call(menu.querySelectorAll('button[role="menuitem"]'));
};
- var scaleButtons = function () {
- return Array.prototype.slice.call(menu.querySelectorAll('.export-scale button[data-scale]'));
- };
-
- // ---- Raster scale (1x / 2x / 4x) -------------------------------------
- function getScale() {
- var checked = menu.querySelector('.export-scale button[aria-checked="true"]');
- return checked ? parseInt(checked.dataset.scale, 10) : 2;
- }
- function setScale(scale) {
- var s = String(scale);
- scaleButtons().forEach(function (b) {
- b.setAttribute('aria-checked', b.dataset.scale === s ? 'true' : 'false');
- });
- try { localStorage.setItem(SCALE_KEY, s); } catch (_) {}
- }
- (function restoreScale() {
- var saved = parseInt(localStorage.getItem(SCALE_KEY), 10);
- if (saved === 1 || saved === 2 || saved === 4) setScale(saved);
- })();
// ---- Clipboard support ----------------------------------------------
function canCopyImage() {
@@ -903,28 +869,12 @@
});
// Keyboard navigation inside the menu.
- // Scale radio group: Left/Right moves + selects (roving tabindex).
// Menu items: Up/Down, Home/End.
// Esc closes + returns focus to trigger; Tab closes.
menu.addEventListener('keydown', function (e) {
if (e.key === 'Escape') { e.preventDefault(); close(true); return; }
if (e.key === 'Tab') { close(false); return; }
- var onScale = e.target.closest('.export-scale button');
- if (onScale) {
- var sb = scaleButtons();
- var idx = sb.indexOf(onScale);
- if (e.key === 'ArrowLeft' || e.key === 'ArrowRight') {
- e.preventDefault();
- var next = e.key === 'ArrowRight'
- ? sb[(idx + 1) % sb.length]
- : sb[(idx - 1 + sb.length) % sb.length];
- setScale(next.dataset.scale);
- next.focus();
- }
- return;
- }
-
var available = items().filter(function (i) { return !i.disabled; });
var current = available.indexOf(document.activeElement);
switch (e.key) {
@@ -972,7 +922,7 @@
return rasterize('png').then(function (blob) {
return navigator.clipboard.write([new ClipboardItem({ 'image/png': blob })]);
}).then(function () {
- toast('Copied PNG to clipboard (' + getScale() + 'x)');
+ toast('Copied PNG to clipboard');
}).catch(function (err) {
console.error(err);
alert('Copy failed: ' + (err && err.message ? err.message : 'unknown'));
@@ -980,9 +930,6 @@
}
menu.addEventListener('click', function (e) {
- var scaleBtn = e.target.closest('.export-scale button[data-scale]');
- if (scaleBtn) { setScale(scaleBtn.dataset.scale); return; }
-
var copyBtn = e.target.closest('button[data-action="copy"]');
if (copyBtn && !copyBtn.disabled) { runCopy(); return; }