我创建了一些自定义样式格式,将类添加到 block 级元素。问题是,当我应用一种样式时,它会保留旧类并添加新类。
切换到其他格式时如何删除旧类?
mce_options_article = {
// ...
formats: {
p_grey: { selector: 'p', classes: 'grey' },
p_red: { selector: 'p', classes: 'red' }
},
style_formats: [
{title: 'Paragraph Color', items: [
{title: 'Grey ', format:'p_grey'},
{title: 'Red ', format:'p_red'},
]},
]
// ...
}
最佳答案
使用属性而不是类。
这就是我所做的:
mce_options_article = {
// ...
formats: {
p_grey: { selector: 'p', attributes: {'class':'grey'} }, // use attributes
p_red: { selector: 'p', attributes: {'class':'red'} } // use attributes
},
style_formats: [
{title: 'Paragraph Color', items: [
{title: 'Grey ', format:'p_grey'},
{title: 'Red ', format:'p_red'},
]},
]
// ...
}
关于javascript - 更改/更新格式时如何删除旧的 tinymce style_format 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56224416/