2011-05-27 36 views
1

我正在为我的论坛网站寻找所见即所得的编辑器。其中内置的语法高亮像我们在www.stackoverflow.comwww.asp.netWYSIWYG编辑器为网站提供内置语法高亮显示

这样我就可以将[用户输入的]整个文本保存到数据库中,并且可以使用语法高亮显示在页面上。

请帮忙。

不要误解我的意思,但我已经在谷歌和Stackoverflow上搜索了这个,我无法获得所需的答案。

如果是开源的,我将不胜感激。 :-)

回答

2

我喜欢和使用tinymce编辑器,它的示例代码如下所示。

<script src="/javascripts/tiny_mce/tiny_mce.js" type="text/javascript"></script> 
<script language="javascript" type="text/javascript"> 

tinyMCE.init({ 

     mode : "textareas", 
     theme : "advanced", 
     plugins : "safari", 
     convert_urls : false, 
     width : "560", 
     height : "15", 
     // 'code' in 'theme_advanced_buttons1' is used for the HTML content 
     theme_advanced_buttons1 : "fontselect,fontsizeselect, separator, bold,italic,underline,separator,forecolor,backcolor,code, justifyleft,justifycenter,justifyright,justifyfull", 

     theme_advanced_buttons2 : "", 

     theme_advanced_buttons3 : "", 

     theme_advanced_toolbar_location : "top", 

     theme_advanced_toolbar_align : "left", extended_valid_elements : "a[name|href|target|title|onclick],img[class|src| border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name], hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]" }); 

</script> 

<textarea cols="40" id="template_content" name="template[content]" rows="20"></textarea>