textarea Wicket的样式文本

时间:2012-01-09 10:45:01

标签: java css textarea wicket

我有一个由文本行组成的字符串。我想将这些行输入到具有一些CSS样式的textarea中(例如,更改某些行的颜色)。怎么办呢?

2 个答案:

答案 0 :(得分:1)

使用tinymce编辑器。 http://www.tinymce.com/
或者您可以使用任何类型的Javascript WYSIWYG编辑器

添加tinymce到页面,

<script type="text/javascript" src="<your installation path>/tiny_mce/tiny_mce.js"></script>

<script type="text/javascript">
tinyMCE.init({
    // General options
    mode : "textareas",
    theme : "advanced",
    plugins : "autolink,lists,spellchecker,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 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
    theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
    theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
    theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage",
    theme_advanced_toolbar_location : "top",
    theme_advanced_toolbar_align : "left",
    theme_advanced_statusbar_location : "bottom",
    theme_advanced_resizing : true,

    // Skin options
    skin : "o2k7",
    skin_variant : "silver",

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

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

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

答案 1 :(得分:1)

TinyMCE确实在编辑器中渲染CSS和其他标记方面做得相当不错。

要轻松地将此包含在Wicket中,我建议使用org.wicketstuff.tinymce-parent包。开发/源代码位于GitHub中,实际版本位于公共maven存储库中。

然后,您可以使用标准的Wicket TextArea组件并向其添加TinyMCE行为,而不是直接使用javascript。

一个缺点是,虽然TinyMCE非常成熟,但它也有一些模糊的错误。如果可能的话,最好保持简单。