最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to programatically select all text inside a TinyMCE editor - Stack Overflow

programmeradmin3浏览0评论

I'm looking for a way to programatically select all the content inside a TinyMCE editor instance.

The reason I need this is that I'd like it if all the text inside the editor was selected, as soon as someone clicks on it (I'm using TinyMCE in conjunction with JEditable, by the way).

Thanks,
Edan

I'm looking for a way to programatically select all the content inside a TinyMCE editor instance.

The reason I need this is that I'd like it if all the text inside the editor was selected, as soon as someone clicks on it (I'm using TinyMCE in conjunction with JEditable, by the way).

Thanks,
Edan

Share Improve this question asked Apr 27, 2010 at 16:44 Edan MaorEdan Maor 10.1k17 gold badges67 silver badges93 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 13

Assuming you have your TinyMCE editor instance stored in a variable called ed:

ed.selection.select(ed.getBody(), true);

For tinyMCE 4 I'm using the Range Object for selection:

function selectAll(editor) {
    range = editor.dom.createRng();
    range.selectNodeContents(editor.getBody());
    editor.selection.setRng(range);
}

selectAll(tinyMCE.focusedEditor);
发布评论

评论列表(0)

  1. 暂无评论