Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Drupal 如何在CKEditor中添加自定义段落格式_Drupal_Ckeditor - Fatal编程技术网

Drupal 如何在CKEditor中添加自定义段落格式

Drupal 如何在CKEditor中添加自定义段落格式,drupal,ckeditor,Drupal,Ckeditor,在我的项目中,我需要从下拉列表中删除“地址”和“格式化”等段落格式,并添加一个名为“链接”的新自定义格式,该格式为Arial、14px、粗体和红色。是否可以在CKEditor中添加自定义段落格式?用于指定一些新格式: CKEDITOR.replace( 'editor1', { format_tags: 'p;h2;h3;pre;links', // entries is displayed in "Paragraph format" format_links: {

在我的项目中,我需要从下拉列表中删除“地址”和“格式化”等段落格式,并添加一个名为“链接”的新自定义格式,该格式为Arial、14px、粗体和红色。是否可以在CKEditor中添加自定义段落格式?

用于指定一些新格式:

CKEDITOR.replace( 'editor1', {
    format_tags: 'p;h2;h3;pre;links', // entries is displayed in "Paragraph format"
    format_links: {
        name: 'Links',
        element: 'span',
        styles: {
            color: 'red',
            'font-family': 'arial',
            'font-weight': 'bold'
        }
    }
} );

要了解更多有关样式的信息,请参见如何工作。另外请注意,由于CKEditor 4.1,从“段落格式”中删除样式会对以下内容产生影响。

由于您使用的是Drupal,
CKEditor.styles.js
是您要查找的文件,这将允许您在“样式”菜单中添加/编辑/删除条目

注释掉所有不需要的条目,并使用类似于以下内容添加新的段落格式:

{ name : 'Links', element : 'p', attributes : { 'class' : 'links' } },
这将把CSS类
链接添加到您想要的任何段落中,并且您可以在主题样式表中定义该类。如果看不到在ckeditor实例中应用的更改,请确保在
ckeditor.css
中定义类

或者,也可以直接应用内联样式:

{ name : 'Links', element : 'p', attributes : { 'style' : 'font: bold 14px Arial, sans-serif; color: red;' } },
但第一种方法显然更灵活/干净


如果没有立即显示更改,请确保清除Drupal和/或浏览器缓存。

我应该将代码ckeditor.config.js放在哪里。我只是把它放在自定义JavaScript配置上,但它不起作用。你能指定位置吗?有很多地方可以设置。在
config.js
customConfig
中创建实例时直接执行(如上所述)。查看了解更多信息。建议破解contrib模块的答案真的有5票赞成票吗?斯特鲁斯。