fix(labs): SVG-стрелки уравнений рисовались как сырой текст на canvas
Уравнения реакций содержат inline <svg class=ic> стрелки. На canvas (fillText) разметка показывалась буквально. Добавлен общий хелпер ChemVisuals.cleanIcons (SVG→Unicode →/↑/↓), применён в flask (eq), redox (s.txt) и chemsandbox (ответ квиза — был единственный незакрытый путь мимо _csClean). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -760,8 +760,21 @@ window.ChemVisuals = (() => {
|
||||
return hex;
|
||||
}
|
||||
|
||||
/* Replace inline icon-SVG (reaction arrows) with Unicode for canvas fillText.
|
||||
Canvas draws plain strings — embedded <svg> markup would show as raw text. */
|
||||
function cleanIcons(s) {
|
||||
if (!s || !s.includes('<svg')) return s;
|
||||
return s.replace(/<svg[\s\S]*?<\/svg>/g, m => {
|
||||
if (m.includes('x1="5" y1="12" x2="19"')) return '→'; // right arrow
|
||||
if (m.includes('x1="12" y1="5" x2="12" y2="19"')) return '↓'; // down (precipitate)
|
||||
if (m.includes('x1="12" y1="19" x2="12" y2="5"')) return '↑'; // up (gas)
|
||||
return '';
|
||||
});
|
||||
}
|
||||
|
||||
/* ── Public API ─────────────────────────────────────────────── */
|
||||
return {
|
||||
cleanIcons,
|
||||
drawErlenmeyer,
|
||||
drawBeaker,
|
||||
drawBurette,
|
||||
|
||||
Reference in New Issue
Block a user