Использование редактора TinyMCE

81 views
Skip to first unread message

aleman

unread,
Sep 23, 2008, 4:06:41 AM9/23/08
to Fullajax
Если вы надумали использовать в качестве редактора, замечательный
TinyMCE, (вызывая его через fullajax) вы сможете сразу наткнуться на
проблему "не работает".

Как оказалось проблема в том что "изначально у TinyMCE немного кривой
механизм загрузки", когда загружаеш его аякс методом.

Проблемы его касаются пути и готовности к отрисовке.

Чтобы решить 1 проблему добавте в самое начало:
(например перед <script language="JavaScript" type="text/javascript"
src="/tinymce/editor/tiny_mce.js"></script>)

строчку скрипта:

<script>tinyMCEPreInit = { base : "/tinymce/editor", suffix : ""} </
script>
(/tinymce/editor - смените этот путь на ваш, где лежит tiny_mce.js)


И добавив после <script language="JavaScript" type="text/javascript"
src="/tinymce/editor/tiny_mce.js"></script>

строчку
tinymce.dom.Event._pageInit();

мы решим вторую проблему.

Итого должно получится такое (которое будет возвращаться аяксом:)) ):

<script>tinyMCEPreInit = { base : "/tinymce/editor", suffix : ""} </
script>
<script language="JavaScript" type="text/javascript" src="/tinymce/
editor/tiny_mce.js"></script>
<script>
tinymce.dom.Event._pageInit();
tinyMCE.init({
// General options
mode : "exact",
elements : "test",
theme : "advanced",
plugins :
"safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",

// Theme options
theme_advanced_buttons1 :
"newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,fontsizeselect,|,cut,copy,paste,pastetext,pasteword,|,insertdate,inserttime",
theme_advanced_buttons2 :
"search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,code,|,preview,|,forecolor,backcolor",
theme_advanced_buttons3 :
"tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,charmap,emotions,|,fullscreen",
theme_advanced_buttons4 :
"insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,pagebreak,|,ltr,rtl,|,iespell,media,advhr,|,print",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,

// Example content CSS (should be your site CSS)
content_css : "css/content.css",

// Drop lists for link/image/media/template dialogs
template_external_list_url : "lists/template_list.js",
external_link_list_url : "lists/link_list.js",
external_image_list_url : "lists/image_list.js",
media_external_list_url : "lists/media_list.js",

// Replace values for the template plugin
template_replace_values : {
username : "Some User",
staffid : "991234"
}
});
</script>
<textarea id="test"></textarea>

Ruslan

unread,
Sep 23, 2008, 4:13:03 AM9/23/08
to Fullajax
все сказано выше правильно. вот второй вариант подключения, который я
использую в своих проектах


tinyMCEPreInit = { base : '/scripts/tiny_mce',
suffix : ''}
SRAX.addScript({url:'/scripts/tiny_mce/tiny_mce.js',
callback:function(){
tinymce.dom.Event._pageInit();
HB.Editor.init = function(id, theme){
var editor = new tinymce.Editor(id, {
mode: 'exact',
elements: id,
theme: theme ? theme : 'advanced',
theme_advanced_toolbar_location : 'top',
theme_advanced_toolbar_align : 'left'
})
editor.onPostRender.add(callback);
editor.render();
}
}})
Reply all
Reply to author
Forward
0 new messages