tinyMCE在文本框中的光标处插入文本在Google Chrome中不起作用

时间:2013-12-17 16:12:16

标签: javascript google-chrome extjs tinymce

使用tinymce: majorVersion:'3', minorVersion:'4.7',

这个插入函数:

MrScheduler.insertVariableText = function(text){
if(MrScheduler.currentEditor)
{
    //tinyMCE insert text call
    MrScheduler.currentEditor.execCommand("mceInsertContent", false, text);
    MrScheduler.emailVariableWindow.hide();
}
else
{
    //insert the text into the current field.  Only works for IE,
    //the same functionality doesn't exist in other browsers for a regular input field
    MrScheduler.currentSelectedField.focus();
    if (document.selection) {
        var sel = document.selection.createRange();
        sel.text = text;
        MrScheduler.emailVariableWindow.hide();
    }
}
};

tinyMCE不会在我的emailFileNameField(文本字段)中插入文本 tinyMCE不会在我的emailSubjectField(文本字段)中插入文本 tinyMCE会将文本插入我的emailBodyField(编辑字段)

是否有解决办法让tinyMCE在文本框中的光标处插入?

1 个答案:

答案 0 :(得分:0)

我找到了一个适合我的修复程序。原来这不是TinyMCE的问题,因为TinyMCE此时没有被调用,而是一个自定义的“功能??”正在被召唤。我通过更改else语句修复了这个问题,如下所示:

else
{
    //Insert text in selected field in OTHER BROWSERS 
    MrScheduler.currentSelectedField.focus();
    if (window.getSelection()) {      
        var sel = MrScheduler.currentSelectedField;
        var currText = MrScheduler.currentSelectedField.getValue().toString(); //Get any existing text
        sel.setValue(currText.toString() + text); //append to current value
        MrScheduler.emailVariableWindow.hide();
    }
}