diff --git a/src/app.js b/src/app.js index fbca2fd..be63658 100644 --- a/src/app.js +++ b/src/app.js @@ -283,7 +283,8 @@ document.addEventListener('keydown', e => { btnToggleToc.click() } // 다이어그램 확대 보기가 열려 있으면 줌 숏컷은 다이어그램에 적용 - if ((e.ctrlKey || e.metaKey) && e.key === '+') { + // '='는 Shift 없이 +키를 누른 경우 — 브라우저 관례대로 확대로 처리 + if ((e.ctrlKey || e.metaKey) && (e.key === '+' || e.key === '=')) { e.preventDefault() diagramViewerOpen() ? diagramZoomIn() : doZoomIn() } @@ -291,7 +292,7 @@ document.addEventListener('keydown', e => { e.preventDefault() diagramViewerOpen() ? diagramZoomOut() : doZoomOut() } - if ((e.ctrlKey || e.metaKey) && (e.key === '0' || e.key === '=')) { + if ((e.ctrlKey || e.metaKey) && e.key === '0') { e.preventDefault() diagramViewerOpen() ? diagramZoomReset() : doZoomReset() } @@ -1124,10 +1125,6 @@ function attachDiagramZoomButtons(block) { b.className = `mermaid-zoom-btn ${pos}` b.title = '다이어그램 크게 보기' b.innerHTML = DIAGRAM_EXPAND_ICON - b.addEventListener('click', e => { - e.stopPropagation() - openDiagramViewer(block) - }) return b } block.appendChild(mk('top')) @@ -1135,6 +1132,15 @@ function attachDiagramZoomButtons(block) { if (block.offsetHeight > 240) block.appendChild(mk('bottom')) } +// 클릭은 위임으로 처리 — 탭 캐시 복원(innerHTML 재주입) 시 버튼 노드가 +// 재생성되면서 개별 리스너가 사라지므로, preview에 리스너를 1회만 등록한다 +preview.addEventListener('click', e => { + const btn = e.target.closest('.mermaid-zoom-btn') + if (!btn) return + const block = btn.closest('.mermaid') + if (block) openDiagramViewer(block) +}) + function diagramNaturalWidth(svg) { const vb = svg.viewBox && svg.viewBox.baseVal if (vb && vb.width) return vb.width diff --git a/src/index.html b/src/index.html index a848944..71dd710 100644 --- a/src/index.html +++ b/src/index.html @@ -45,7 +45,7 @@