【问题标题】:CKEditor styles dropdown: add class to the selected elementCKEditor 样式下拉列表:将类添加到所选元素
【发布时间】:2015-12-15 06:04:06
【问题描述】:

我想要在 CKEditor 中做的是添加一些应该应用于多个元素的自定义样式。我的每个元素(从 h2 到 h6 的标题,加上链接 a)必须有 3 个只会改变颜色的项目。

为了避免一一描述每种样式:H2 Red、H2 Blue、H2 Green、H3 Red、H3... 我想像往常一样从 Format 列表中选择元素,然后从样式列表中选择 itemization。我将有 3 种样式:红色、蓝色、绿色,它们可以通过简单地添加一个类而不是通过定义元素来应用于所选元素。

可行吗?

我考虑过使用自定义颜色列表 (http://docs.ckeditor.com/#!/guide/dev_colorbutton),但颜色是通过颜色代码“即时”添加的,因此当您的网站颜色发生变化时,您不能简单地更改 3 类颜色属性,您必须修改你所有编写的文本,我不想要的,老实说不太优雅。

我尝试设置这样的样式,但没有指定元素(我在 Drupal 下,但我们并不关心):

if (typeof(CKEDITOR) !== 'undefined') {
  CKEDITOR.addStylesSet( 'drupal',
  [
    {
      name : 'Blue',
      attributes :
      {
        'class' : 'color-blue'
      }
    },
    {
      name : 'Green',
      attributes :
      {
        'class' : 'color-green'
      }
    },
    {
      name : 'Red',
      attributes :
      {
        'class' : 'color-red'
      }
    },
  ]);
}

但是不行,自动加了一个span。

感谢您的帮助!

【问题讨论】:

    标签: ckeditor ckeditor4.x


    【解决方案1】:

    http://ckeditor.com/forums/CKEditor/Adding-class-to-the-current-text-block-regardless-of-the-elementtag 的副本 一年以来都没有答案,所以它不应该是可行的......

    【讨论】:

      猜你喜欢
      • 2016-02-29
      • 2020-03-06
      • 1970-01-01
      • 1970-01-01
      • 2011-10-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多