使用JQuery操作Tinymce Document DOM

sin*_*inθ 3 html javascript jquery tinymce tinymce-4

我有一个像这样的span标签的tinymce textarea : <span data-range-id="4oYnl5fH0">...</span>.

单击文本范围时,我想在文本旁边显示一个弹出窗口.

问题是文本隐藏在iframe中,因此JQuery无法访问它.

有没有办法用JQuery更改iframe中的内容,特别是使用tinymce?我不能只是复制内容,然后将其粘贴回来,因为我需要获取文本在屏幕上的位置的坐标为此,我会使用这个:

position = $(this).offset();
Run Code Online (Sandbox Code Playgroud)

thisspan标记在哪里

Tha*_*ama 5

是的,这是可能的,也很容易.

var editor = tinymce.editors[0]; // or tinymce.get('your_editor_id') or tinymce.activeEditor

var $ed_body = $(editor.getBody());

// do whatever you want with the editor content located inside the body
Run Code Online (Sandbox Code Playgroud)