Hi,
I'd like, if possible, to use TinyMCE (WYSIWYG Editor) to allow users to created bulleted lists and only bulleted lists. Anyone know of a way?
Thanks,
Paul
Hi,
I'd like, if possible, to use TinyMCE (WYSIWYG Editor) to allow users to created bulleted lists and only bulleted lists. Anyone know of a way?
Thanks,
Paul
In your tinyMCE.init set the theme-advanced-buttons1 to just have "bullist". You'll also need to set theme-advanced-buttons2, 3, and 4 to nothing. Here's a full example:
<html>
<head>
<title>Application Name</title>
<script type="text/javascript" src="tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({
// General options
mode : "exact",
elements: "description_edit_box",
theme : "advanced",
plugins : "safari,pagebreak,inlinepopups,paste,searchreplace",
// Theme options
theme_advanced_buttons1 : "bullist",
theme_advanced_buttons2 : "",
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,
// Drop lists for link/image/media/template dialogs
external_link_list_url : "lists/link_list.js"
});
</script>
</head>
<body>
<textarea id="description_edit_box" rows="5" ></textarea>
</body>
</html>
TinyMCE has two options that will help, when using the advanced theme. The first is theme_advanced_buttons<n>
, which determines which buttons are shown with the editor. Since the advanced theme by default defines buttons in three rows, you'll need to redefine each one.
The second is valid_elements
, which lets TinyMCE remove any unlisted tags. It can also transform one tag into another; for example, you might wish to switch numbered lists into bulleted lists. Note, however, that this isn't really security; you still need to perform server-side checks to block invalid input from malicious or devious users.
If you really want to block all tags except bulleted lists, your init call might want the following options:
tinyMCE.init({
// Select the advanced theme
theme : "advanced",
// Choose which buttons to show
theme_advanced_buttons1 : "bullist",
theme_advanced_buttons2 : "",
theme_advanced_buttons3 : "",
// Which html tags to allow
valid_elements : "-ul/-ol,-li",
// Other options, including what to make editable
mode : ...
});
If, on the other hand, you only want to prevent numbered lists, your configuration might look more like:
tinyMCE.init({
// Select the advanced theme
theme : "advanced",
// Choose which buttons to show
theme_advanced_buttons1 : "separator,insertdate,inserttime,preview,zoom,separator,forecolor,backcolor",
theme_advanced_buttons2 : "bullist,separator,outdent,indent,separator,undo,redo,separator",
theme_advanced_buttons3 : "hr,removeformat,visualaid,separator,sub,sup,separator,charmap",
// Which html tags to allow
valid_elements : "@[id|class|style|title|dir<ltr?rtl|lang|xml::lang|onclick|ondblclick|" +
"onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|" +
"onkeydown|onkeyup],a[rel|rev|charset|hreflang|tabindex|accesskey|type|" +
"name|href|target|title|class|onfocus|onblur],strong/b,em/i,strike,u," +
"#p[align],-ul[type|compact]/-ol[type|compact],-li,br,img[longdesc|usemap|" +
"src|border|alt=|title|hspace|vspace|width|height|align],-sub,-sup," +
"-blockquote,-table[border=0|cellspacing|cellpadding|width|frame|rules|" +
"height|align|summary|bgcolor|background|bordercolor],-tr[rowspan|width|" +
"height|align|valign|bgcolor|background|bordercolor],tbody,thead,tfoot," +
"#td[colspan|rowspan|width|height|align|valign|bgcolor|background|bordercolor" +
"|scope],#th[colspan|rowspan|width|height|align|valign|scope],caption,-div," +
"-span,-code,-pre,address,-h1,-h2,-h3,-h4,-h5,-h6,hr[size|noshade],-font[face" +
"|size|color],dd,dl,dt,cite,abbr,acronym,del[datetime|cite],ins[datetime|cite]," +
"object[classid|width|height|codebase|*],param[name|value|_value],embed[type|width" +
"|height|src|*],script[src|type],map[name],area[shape|coords|href|alt|target],bdo," +
"button,col[align|char|charoff|span|valign|width],colgroup[align|char|charoff|span|" +
"valign|width],dfn,fieldset,form[action|accept|accept-charset|enctype|method]," +
"input[accept|alt|checked|disabled|maxlength|name|readonly|size|src|type|value]," +
"kbd,label[for],legend,noscript,optgroup[label|disabled],option[disabled|label|selected|value]," +
"q[cite],samp,select[disabled|multiple|name|size],small," +
"textarea[cols|rows|disabled|name|readonly],tt,var,big",
// Other options, including what to make editable
mode : ...
});