Detecting whenever a user types – in the Gutenberg editor, and checking if there is a preceding or succeeding – then converting both to an em dash
I managed to find an answer to this. Instead of adding an event listener to the editor, I hooked some additional functionality onto Gutenberg’s Autocompleter instead: I wrote a post here detailing how I did this, if anyone is looking to do the same thing: https://blog.terresquall.com/2023/06/how-i-made-double-dashes-automatically-convert-to-em-dashes-in-wordpress-gutenberg-editor/