CKEditor 在选择标签上添加样式

CKEditor add style on selection tag

我正在尝试将内联样式直接添加到选择文本标签中,例如 我在 <a>foo</a> 中选择 foo 并单击粗体按钮。 目前我已经完成了我的配置:

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

最终用户会认为有两个不同的链接...