I am currently working on a wysiwyg editor and I'm facing an issue where I need to determine if a user has clicked on an image within the selection range. Is there a method to detect this without attaching event handlers directly to the image itself? Currently, I am monitoring keyup and mouseup events by utilizing Tim Down's getselectedtext() function to check for selected text, but I would like to find a way to identify if the selection contains an image tag or similar element by examining el.nodeName.
While I can successfully identify the image when it is fully highlighted using Tim Down's getselectedtext() function, it does not return any results if the image is simply clicked (with four squares on each corner) instead of being highlighted in blue after dragging the mouse across it. Any suggestions or solutions? Preferably looking for a pure JavaScript approach.