个人比较喜欢 CKEditor, 所以就给 micolog 整了个 ckeditor 插件:
http://micolog.appspot.com/plugins/view?key=agdtaWNvbG9nchsLEgZQbHVnaW4iD0NLRWRpdG9yIHBsdWdpbgw
其实 tinymce 也还可以啦,只是我做好这个插件之后才发现原来在 /views/admin/entry.html 中把 tinymce 的初始化代码改成这样,它也完全可以接受了:
(主要是它之前总是自作主张的把 URL 改成相对路径 —— 而且还是个错的,还有 html 的预览把 <p> 弄没了,结构一塌糊涂)
<script type="text/javascript">
$('#content').ready(function() {
$('.editor-toolbar').show();
var editor = null;
$('#edButtonPreview').click(function(){if(editor);else initTinymce();});
$('#edButtonHTML').click(function(){if(editor)tinymce.execCommand('mceRemoveControl',false,'content'); editor=null;});
function initTinymce(){
editor = $('#content').tinymce({
script_url : '/tinymce/tiny_mce.js',
theme : "advanced",
plugins : "safari,pagebreak,save,advhr,advimage,advlink, inlinepopups,media,directionality,visualchars,nonbreaking,fullscreen,preview,autoresize",
theme_advanced_buttons1:"bold,italic,underline,strikethrough,|,bullist,numlist,blockquote,|,forecolor,backcolor,|,justifyleft,justifycenter,justifyright,justifyfull,|,link,unlink,image,code,preview,|,fullscreen",
theme_advanced_buttons2:"styleselect,formatselect,fontselect,fontsizeselect,|,pastetext,pasteword,removeformat,|,media,charmap,|,outdent,indent,|,undo,redo",
theme_advanced_buttons3:"",
theme_advanced_buttons4:"",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,
content_css : "/tinymce/wordpress.css",
extended_valid_elements : "textarea[cols|rows|disabled|name|readonly|class],script[src,type],canvas",
file_browser_callback: 'micolog_file',
relative_urls: false
});
}
initTinymce();
});
function micolog_file(field_name, url, type, win){
if (type=='image')
{ext='jpg|png|jpeg|gif|svg';}
else if (type=='mdeia')
{ext='swf|wmv|avi|wma|mp3|mid|asf|rm|rmvb|flv';}
else
{ext="*";}
tinyMCE.activeEditor.windowManager.open({
file : '/admin/uploadex?ext='+ext,
title : '{%trans "Files"%}',
width : 420,
height : 200,
resizable : "no",
inline : "yes",
popup_css: false,
close_previous : "no"
}, {
window : win,
input : field_name
});
return false;
}
</script>