Ckeditor 4 - 如何更改 link 的颜色,包括下划线?

Ckeditor 4 - how can I change the color of the link including underline?

当我尝试更改 link 的颜色时(如您 can do on demo page),文本的颜色已更改但下划线仍为蓝色。

有什么办法可以让Ckeditor也改变下划线的颜色吗?我想让 Ckeditor 在默认情况下也可以更改下划线的颜色,而无需用户进行任何操作。

如果您双击 link,将打开一个小弹出窗口 window,您会在其中找到“高级”选项(最后一个选项卡)

在 Advance 选项里面有一个字段叫做 style,你可以在那里提到 color:redtext-decoration:none

这将解决您的问题。

有一个 属性 叫做 text-decoration-color:

示例:

p {
    text-decoration: underline;
    -moz-text-decoration-color: red; /* Code for Firefox */
    text-decoration-color: red;
}

但是!当前浏览器不支持https://developer.mozilla.org/en-US/docs/Web/CSS/text-decoration-color

我找到了解决方案。这是我的代码:

  editor = CKEDITOR.inline(editable_text_element)

  # This event called when text is updated in current editor.
  editor.on 'change', ->
    links = iframe().find('a')
    links.each () ->
      current_link = $(this)
      links_children = current_link.children()

    # Our case is when <a> has only 1 child and this is <span>
    if links_children.size() is 1
      child = links_children.first()
      child_color = child.css('color')
      current_link_color = current_link.css('color')

      current_link.css('color': child_color) if current_link_color isnt child_color

这并不理想,但确实有效。当文本更改时,我通过样式设置颜色。