插件支持
此扩展包让您可以管理额外的插件。为了理解它是如何工作的,您将为我们的 CKEditor 小部件启用 Wordcount 插件。
安装插件
首先,您需要下载并将其解压到 web 目录中。为此,您有两种可能性
- 直接将插件放在 web 目录中(例如
/web/ckeditor/plugins/
)。 - 将插件放在任何扩展包的
/Resources/public/
目录中。
注册插件
为了加载它,您需要指定其位置。为此,您可以全局地在您的配置中进行设置
1 2 3 4 5 6 7 8 9 10
# app/config/config.yml
fos_ck_editor:
default_config: my_config
configs:
my_config:
extraPlugins: "wordcount"
plugins:
wordcount:
path: "/bundles/mybundle/wordcount/" # with trailing slash
filename: "plugin.js"
或者您可以在您的小部件中进行设置
1 2 3 4 5 6 7 8 9 10 11
$builder->add('field', 'ckeditor', [
'config' => [
'extraPlugins' => 'wordcount',
],
'plugins' => [
'wordcount' => [
'path' => '/bundles/mybundle/wordcount/', // with trailing slash
'filename' => 'plugin.js',
],
],
]);
插件依赖
一旦您的插件安装并注册,您还需要安装和注册这些依赖项。幸运的是,wordcount
没有额外的依赖项,但其他插件可能需要额外的依赖项。因此,如果是这种情况,您需要为它们重复此过程,依此类推。
本作品,包括代码示例,根据 Creative Commons BY-SA 3.0 许可协议获得许可。