Если я не нажму в редакторе, прежде чем нажать на свою пользовательскую кнопку, появится HTML CONTENT, но все остальное исчезнет ... Дело в том, что я разрабатываю этот плагин для публичного использования, поэтому я не хочу, чтобылюди стирают их содержимое по ошибке, есть ли способ установить точку вставки?Вот строка, которая вставляет код содержимого:
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); })();
Спасибо за помощь!