Drupal CKeditor 自定义样式下拉菜单

Drupal CKeditor Custom Styles dropdown

我正在使用 Drupal 7.43 和 ckeditor 版本 4。我想更改自定义样式下拉列表,所以我将 ckeditor.styles.js 文件复制到我的主题根目录中。在配置(drupal 模块)中,我 select 使用主题目录中的这个文件,但下拉列表是空的。此文件的自定义路径也不起作用。这是我在 ckeditor.styles.js 文件中所做的更改。使用默认降价,下拉列表仍然是空的。我是否遗漏了任何配置步骤?

if(typeof(CKEDITOR) !== 'undefined') {
CKEDITOR.addStylesSet( 'drupal',
[
         /* Block Styles */

        { name : 'interner Link'        , element : 'a', styles : { 'color' : '#004684' } },
        { name : 'externer Link'        , element : 'a', styles : { 'color' : '#004684' } },
        { name : 'E-Mail'       , element : 'a', styles : { 'color' : '#004684' } },
        { name : 'Download'     , element : 'a', styles : { 'color' : '#004684' } },

        /* Inline Styles */

        /* Object Styles */

        {
                name : 'left Image',
                element : 'img',
                attributes :
                {
                        'style' : 'padding: 5px; margin-right: 5px',
                        'border' : '2',
                        'align' : 'left'
                }
        },

        {
                name : 'right Image',
                element : 'img',
                attributes :
                {
                        'style' : 'padding: 5px; margin-left: 5px',
                        'border' : '2',
                        'align' : 'right'
                }
        }
]);

}

admin/config/content/ckeditor 中进入您要编辑的配置文件。在 CSS 下,您应该找到一个名为 "Predefined styles" 的下拉列表。在此下拉列表下,您应该找到一个显示 "Define path to ckeditor.styles.js" 的选项,然后您可以将文件的路径放在其下方的文本框中。

注意:我不确定这是否是您的意思

"In configuration (drupal module) I select to use this file from theme directory but the dropdown is empty. And custom path to this file doesn't work too."

我将其解释为 admin/config/content/ckeditor/editg。如果不是这种情况,请告诉我,我会将我的答案更改为更有帮助的内容。

realpenx,我也很反对这个。

在您的自定义 styles.js 文件中,即使您使用 config.styleSet = "your_custom_styleset",也需要将样式集命名为 'drupal' 以便 ckeditor 选取它。 =12=]

对于那些可能 运行 遇到类似问题的人,我会详细说明。我的设置如下:Ckeditor 设置为从主题路径加载 ckeditor.config.js。在该文件中,我有以下内容:

CKEDITOR.editorConfig = function(config) { config.styleSet = "my_custom_styleset"; }

我在 CKEDITOR 模块设置中定义了我的 ckeditor 的路径。styles.js 路径,在该文件中我有:

CKEDITOR.stylesSet.add( 'my_custom_styleset', [ 
  // some styles 
]);

我的样式下拉菜单是空的并且是灰色的。我必须将 'my_custom_styleset' 更改为 'drupal' 才能填充它。诡异的。我可能在某处做错了什么,但我是否做错了并不明显。

我终于解决了网站样式不起作用的问题。这不是 drupal 缓存问题,也不是主题问题,而是浏览器缓存问题。 作为背景,我可能在测试设置时在主题目录中实际拥有正确的 ckeditor.styles.js 文件之前将 Predefined styles 设置为 "Use theme ckeditor.styles.js",这也可能弄乱了我的缓存文件——因为它当时无法正确加载编辑器。 我尝试了很多我遇到的想法,清除 drupal 缓存,jquery 更新版本,......切换回 drupal 核心主题突然奏效,这让我想知道我的主题。在干净的浏览器中测试站点后(您也可以尝试隐身模式或隐私模式),样式会显示出来...也许这 answer/report 可以为其他人节省一些时间...