在光标所在的TinyMCE编辑器中插入文本 [英] Inserting text in TinyMCE Editor where the cursor is

查看:3398
本文介绍了在光标所在的TinyMCE编辑器中插入文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直试图将文本插入TinyMCE编辑器中的焦点段落元素(< p> ),确切地说光标在哪里但没有运气!

I've been trying to insert text into the TinyMCE Editor at the focused paragraph element (<p>) exactly where the cursor is but got no luck!!

var elem = tinyMCE.activeEditor.dom.get('tinymce');
var child = elem.firstChild;
while (child) {
    if (child.focused) {
        $(child).insertAtCaret("some text");
    }
    child = child.nextSibling;
}

如果有人知道如何解决这个问题,我将非常感激。

If anyone has any idea on how to solve this I'll be very thankful.

推荐答案

您应该使用命令 mceInsertContent
请参阅 TinyMCE文档

tinymce.activeEditor.execCommand('mceInsertContent', false, "some text");

这篇关于在光标所在的TinyMCE编辑器中插入文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆