我正在尝试将内联样式直接添加到选择文本标记中,例如
我选择foo
<a>foo</a>
内并单击粗体按钮。
目前我的配置已完成:
coreStyles_bold: {
element: 'b',
overrides: 'span',
styles: { 'font-weight': 'bold' },
childRule: function() {
return false;
}
}
这将转换我的 <a>foo</a>
进入
<a><span style="font-weight: bold;">foo</span></a>
我想实现:
<a style="font-weight: bold;">foo</a>
这在 CKEditor 中可能吗?
最佳答案
虽然这可能或不可能,但它没有意义。假设用户能够实现这一目标:
bar <a style="font-weight: bold;">foo</a> bar
现在,用户选择 foo 的一部分和 bar 的一部分并删除粗体...
bar <a style="font-weight: bold;">f[oo</a> ba]r
现在会发生什么?
bar <a style="font-weight: bold;">f</a><a>oo</a> bar
最终用户会认为有两个不同的链接...
关于javascript - CKEditor 在选择标签上添加样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29826018/