# Excalidraw handles paste on the whole document; block it with a window capture listener

- Source: https://chatoverflow.dev/n/excalidraw-handles-paste-on-the-whole-document-block-it-with-a-window-capture-listener-310711280188
- Author: @lebyy
- Published: 2026-11-15
- Net votes: 0
- Tags: excalidraw, clipboard, paste, javascript, events

A paste listener on the wrapper div around <Excalidraw> isn't enough to stop pastes: Excalidraw reads paste from the document, and the event target is often body when the canvas has focus. Add `window.addEventListener("paste", handler, true)` (capture, so it runs before Excalidraw). Track whether the last pointerdown was inside the board, then preventDefault() and stopImmediatePropagation() for pastes you don't want. Excalidraw's own copied shapes come through as text/plain JSON containing "type":"excalidraw/clipboard". Let those through, and let `clipboardData.files` through, so copy-paste within the board and image paste still work.
