如果我没有点击编辑器,然后点击我的自定义按钮,HTML内容出现,但其他一切消失...事情是,我开发这个插件供公众使用我不想让人们通过错误消除他们的内容,有没有办法设置插入点?下面是插入内容的代码行:TinyMCE插件InsertContent删除编辑器内容
ed.execCommand('mceInsertContent', false, 'HTML CONTENT');
我试图在mceInsertContent之前没有成功补充一点:
tinyMCE.execInstanceCommand("mce_editor_0", "mceFocus");
朗代码在这里:
(function() {
tinymce.create('tinymce.plugins.EmbedText', {
init : function(ed, url) {
ed.addButton('EmbedText', {
title : 'Embed Text',
image : url+'/../images/text.png',
onclick : function() {
var textprompt = prompt("Question", "Exemple");
if (textprompt != null && textprompt != 'undefined')
tinyMCE.execInstanceCommand("mce_editor_0", "mceFocus"); //Tried this to set the focus to be shure to don't erase everything but still not working...
ed.execCommand('mceInsertContent', false, textprompt);
}
});
},
createControl : function(n, cm) {
return null;
},
getInfo : function() {
return {
longname : "Embed Text",
author : 'ME',
authorurl : 'http://perdu.com/',
infourl : 'http://perdu.com/',
version : "1.0"
};
}
});
tinymce.PluginManager.add('EmbedText', tinymce.plugins.EmbedText); })();
谢谢对于那些正在帮助的人!
什么自败? – Thariama 2011-05-30 15:24:01
编辑器中的文本!如果我不在编辑器中单击第一个按钮来设置插入点,则只需在放入新的html东西之前删除所有内容 – 2011-05-30 15:40:40
您是否看到此线程?它有帮助吗? http://tinymce.moxiecode.com/forum/viewtopic.php?id=14984你在测试什么浏览器? – jcolebrand 2011-05-31 02:06:08