TinyMCE a deux options qui vous aideront, lorsque vous utilisez le thème avancé. Le premier est theme_advanced_buttons<n>
, qui détermine quels boutons sont affichés avec l'éditeur. Comme le thème avancé définit par défaut les boutons sur trois lignes, vous devez les redéfinir chacun.
La seconde est valid_elements
, ce qui permet à TinyMCE de supprimer toutes les balises non répertoriées. Il peut également transformer un tag en un autre; Par exemple, vous pouvez souhaiter passer des listes numérotées dans des listes à puces. Notez, cependant, que ce n'est pas vraiment la sécurité; vous devez toujours effectuer des contrôles côté serveur pour bloquer les entrées non valides des utilisateurs malveillants ou sournois.
Si vous voulez vraiment bloquer tous les tags sauf listes à puces, votre appel init pourrait vouloir les options suivantes:
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 : ...
});
Si, d'autre part, vous ne souhaitez que pour éviter les listes numérotées, votre configuration peut ressembler plus à:
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 : ...
});