我想控制 TinyMCE 中的粗体按钮,以便它对标题禁用,但对于其他文本仍然可以正常工作。可能吗?
一个很好的方法类似于如何自定义“清除格式”按钮,您可以在其中指定选择器,但这不适用于“粗体”格式。
tinymce.init({
formats: {
removeformat: [
// Configures `clear formatting` to remove specified elements regardless of its attributes
{ selector: 'b,strong,em,i,font,u,strike', remove: 'all' },
]
}
});
代码示例:https ://codepen.io/andreyprokhorov/pen/zYBbdVy
如果我为“跨度”定义粗体样式,那么我不能禁用标题的粗体(h1-h6)。除此之外,当在编辑器中选择标题时,我希望“粗体”按钮看起来被禁用。
formats: {
bold: { inline: 'span', classes: 'bold' }, //nothing disabled
bold: { selector: 'h1,h2,h3,h4,h5,h6', classes: '' }, //disables everything
bold: [ { inline: 'span', classes: 'bold' }, { selector: 'h1,h2,h3,h4,h5,h6', classes: '' }], //nothing disabled
},
有任何想法吗?