gpt4 book ai didi

TinyMCE:可能限制为仅允许子弹吗?

转载 作者:行者123 更新时间:2023-12-04 18:54:35 26 4
gpt4 key购买 nike

如果可能,我希望使用TinyMCE(所见即所得编辑器)允许用户创建项目符号列表,并且仅创建项目符号列表。有人知道吗?

谢谢,

保罗

最佳答案

使用高级主题时,TinyMCE有两个选项会有所帮助。第一个是 theme_advanced_buttons<n> ,它确定在编辑器中显示哪些按钮。由于默认情况下,高级主题会在三行中定义按钮,因此您需要重新定义每个按钮。

第二个是 valid_elements ,它允许TinyMCE删除所有未列出的标签。它还可以将一个标签转换为另一个标签。例如,您可能希望将编号列表切换为项目符号列表。但是请注意,这并不是真正的安全性。您仍然需要执行服务器端检查,以阻止来自恶意或欺骗用户的无效输入。

如果您确实要阻止除项目符号列表之外的所有标签,那么您的init调用可能需要以下选项:

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 : ...
});

另一方面,如果您只想防止编号列表,则您的配置可能看起来更像:
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 : ...
});

关于TinyMCE:可能限制为仅允许子弹吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/922871/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com