I am trying to get the text selected event from tinymce, the way i do is as follows
const editor = global["tinymce"].activeEditor;
editor.on("NodeChange", e => {
const selectedText = editor.selection.getContent({ format: "text" });
});
Tinymce is already loaded by wordpress before including this code, the problem i face is the NodeChange event is not triggered on the editor instance. I dont want to create a tinymce plugin for this, is this possible without creating a plugin? The code i have pasted here actually works if i add it via the console, i am missing something when i load it normally