In several other issues (#216 #279 and #330) the following snippet is supplied as a way "to prevent non-file attachments like pasted images":
document.addEventListener("trix-attachment-add", function(event) {
event.attachment.remove()
});
This does not work. The image still gets pasted in and a js error is generated: "Uncaught TypeError: Cannot read property 'remove' of undefined" which leads me to believe that this isn't supposed to be called on the event object.
My desired outcome here is preventing users from pasting images from desktop word processor documents (e.g. Word, Libreoffice, etc).
I've been unable to reproduce this issue. Here's what I tried:

The image attachment is added in the first paste as expected. Then it gets removed in the second paste after adding an event handler like you have above.
Okay eating my own words here, but maybe there is still a bug of some kind here. I committed a cardinal sin of the bug reporter - I reported a bug with code I wasn't actually running. I was using jQuery's on to bind the handler and not the exact same as the snippet above, which does appear to work. My apologies on that!
My question for you is this: why does window.event have attachment but the event handler argument does not?
$(document).on("trix-attachment-add", function(e) {
e.attachment.remove(); // error
});
$(document).on("trix-attachment-add", function() {
event.attachment.remove(); // fine
});
I appreciate you taking the time to look into this btw, thanks so much @javan !
With jQuery, you need to access the original, native event:
$(document).on("trix-attachment-add", function(event) {
event.originalEvent.attachment.remove();
});
jQuery passes the handler an Event object it can use to analyze and change the status of the event. This object is a normalized subset of data provided by the browser; the browser's unmodified native event object is available in event.originalEvent.
https://api.jquery.com/on/#event-handler
When using jQuery, I usually name that arg $event instead of event as a reminder:
$(document).on("trix-attachment-add", function($event) {
$event.originalEvent.attachment.remove();
});
the originalEvent just return null...
Most helpful comment
With jQuery, you need to access the original, native event: