为什么 CKEditor 的嵌套小部件在我的 Drupal 构建中不起作用?
Why does CKEditor's nesting widgets not work in my Drupal build?
得知 CKE 4.4+ 现在可以嵌套小部件,我感到非常兴奋。我通读了 并尝试了一下 - 太棒了。奇怪的是,它不适用于我使用 CKEditor 模块的 Drupal 站点。
所以,我得到的是:
模块使用CDN,交付CKE 4.5.1 (//cdn.ckeditor.com/4.5.1/full-all).
我设置了一个模块来提供 simplebox 插件(取自工作开发 repo 示例):
function mymodule_ckeditor_plugin() {
$plugins = array();
$plugins['simplebox'] = array(
'name' => 'simplebox',
'desc' => t('simplebox Plugin'),
'path' => drupal_get_path('module', 'mymodule') . '/plugins/simplebox/',
'buttons' => array(
'Simplebox' => array('label' => 'Simplebox', 'icon' => 'icons/simplebox.png'),
)
);
return $plugins;
}
它为我提供了要激活的插件:
我的工具栏上有插件按钮:
点击它,标记被创建。但奇怪的是,添加另一个嵌套在里面是不可能的:
知道我做错了什么吗?
我不太确定你从哪里得到 Simplebox 插件。我假设您是从官方 "Creating a Simple CKEditor Widget (Part 2)" 指南下载的。
如果是这样,我得告诉你,指南附带的插件与 ckeditor-dev 存储库中 plugins/widget/dev/assets/simplebox/plugin.js
中的插件之间存在细微差别。
后者是最新的并且在 content
嵌套可编辑中启用任何类型的 HTML:
editor.widgets.add( 'simplebox', {
...
editables: {
...
content: {
selector: '.simplebox-content'
}
}
} );
而旧的非常严格:
editor.widgets.add( 'simplebox', {
...
editables: {
...
content: {
selector: '.simplebox-content',
allowedContent: 'p br ul ol li strong em'
}
}
} );
参见 CKEditor 中的 API docs to know more about the definition of nested editables. The introduction to Advanced Content Filter 应该也会有所帮助。
解决方案:从 GitHub 存储库复制 simplebox plugin 并使用嵌套小部件,拖放等。或者只是删除 allowedContent
来自 content
嵌套可编辑的限制。
对于给您带来的不便,我们深表歉意,我们正在尽最大努力使我们的文档保持最新,但这是一项艰巨的任务,有时我们无法赶上 ;)
得知 CKE 4.4+ 现在可以嵌套小部件,我感到非常兴奋。我通读了
所以,我得到的是:
模块使用CDN,交付CKE 4.5.1 (//cdn.ckeditor.com/4.5.1/full-all).
我设置了一个模块来提供 simplebox 插件(取自工作开发 repo 示例):
function mymodule_ckeditor_plugin() {
$plugins = array();
$plugins['simplebox'] = array(
'name' => 'simplebox',
'desc' => t('simplebox Plugin'),
'path' => drupal_get_path('module', 'mymodule') . '/plugins/simplebox/',
'buttons' => array(
'Simplebox' => array('label' => 'Simplebox', 'icon' => 'icons/simplebox.png'),
)
);
return $plugins;
}
它为我提供了要激活的插件:
我的工具栏上有插件按钮:
点击它,标记被创建。但奇怪的是,添加另一个嵌套在里面是不可能的:
知道我做错了什么吗?
我不太确定你从哪里得到 Simplebox 插件。我假设您是从官方 "Creating a Simple CKEditor Widget (Part 2)" 指南下载的。
如果是这样,我得告诉你,指南附带的插件与 ckeditor-dev 存储库中 plugins/widget/dev/assets/simplebox/plugin.js
中的插件之间存在细微差别。
后者是最新的并且在 content
嵌套可编辑中启用任何类型的 HTML:
editor.widgets.add( 'simplebox', {
...
editables: {
...
content: {
selector: '.simplebox-content'
}
}
} );
而旧的非常严格:
editor.widgets.add( 'simplebox', {
...
editables: {
...
content: {
selector: '.simplebox-content',
allowedContent: 'p br ul ol li strong em'
}
}
} );
参见 CKEditor 中的 API docs to know more about the definition of nested editables. The introduction to Advanced Content Filter 应该也会有所帮助。
解决方案:从 GitHub 存储库复制 simplebox plugin 并使用嵌套小部件,拖放等。或者只是删除 allowedContent
来自 content
嵌套可编辑的限制。
对于给您带来的不便,我们深表歉意,我们正在尽最大努力使我们的文档保持最新,但这是一项艰巨的任务,有时我们无法赶上 ;)