diff --git a/frontend/js/svg-draw.js b/frontend/js/svg-draw.js index a79c810..5e23533 100644 --- a/frontend/js/svg-draw.js +++ b/frontend/js/svg-draw.js @@ -200,8 +200,23 @@ /* ── drawing interaction ──────────────────────────────────────── */ let drawing = false, startP = null, curEl = null, penPts = null, dragMode = null, dragStart = null, selStartXY = null; + /* The host lesson block-card is draggable=true and hijacks mouse-drag on the + canvas — and its dragstart fires on the CARD (not the svg), so it can't be + cancelled here. Fix: disable the nearest draggable ancestor while a pointer + is down on the canvas, restore on release. */ + let _dragAnc = null; + function suppressAncestorDrag() { + const a = svg.closest && svg.closest('[draggable="true"]'); + if (a) { _dragAnc = a; a.setAttribute('draggable', 'false'); } + } + function restoreAncestorDrag() { + if (_dragAnc) { _dragAnc.setAttribute('draggable', 'true'); _dragAnc = null; } + } + document.addEventListener('pointerup', restoreAncestorDrag); + svg.addEventListener('pointerdown', function (evt) { if (evt.button !== 0) return; + suppressAncestorDrag(); const p = svgPoint(evt); if (state.tool === 'select') { @@ -274,6 +289,7 @@ }); function endDraw(evt) { + restoreAncestorDrag(); if (dragMode === 'move') { dragMode = null; commit(); return; } if (!drawing) return; drawing = false; @@ -466,6 +482,7 @@ function destroy() { document.removeEventListener('keydown', onKey); + document.removeEventListener('pointerup', restoreAncestorDrag); if (root.parentNode) root.parentNode.removeChild(root); }