sadovojav / yii2-ckeditor
此包的最新版本(dev-master)没有可用的许可信息。
Yii2 CKEditor
dev-master
2016-01-07 19:09 UTC
Requires
- php: >=5.4.0
- yiisoft/yii2: *
This package is auto-updated.
Last update: 2024-08-29 04:00:40 UTC
README
这是一个分支 MihailDev/yii2-ckeditor
特性
- 添加自定义插件的能力
- 在事件上初始化编辑器
- 添加了自定义插件
插件
Composer
安装此扩展的首选方式是通过 Composer。
运行 php composer.phar require sadovojav/yii2-ckeditor "dev-master"
或者将 "sadovojav/yii2-ckeditor": "dev-master"
添加到你的 composer.json
文件的 require 部分
使用
- 小部件
use sadovojav\ckeditor\CKEditor; echo CKEditor::widget();
- ActiveForm
use sadovojav\ckeditor\CKEditor; echo $form->field($post, 'text_full')->widget(CKEditor::className());
参数
- array
editorOptions
- CKeditor 选项 - array
containerOptions
- 容器选项 - array
extraPlugins
- 额外插件连接 - string
initOnEvent
=false
- 初始化的事件类型
示例
echo $form->field($post, 'text_full')->widget(CKEditor::className(), [ 'extraPlugins' => [ ['test', '@root/uploads/plugins/test-plugin/', 'plugin.js'] ], 'editorOptions' => [ 'toolbar' => [ ['Source', 'NewPage', 'Preview', 'Viewss'], ['PasteText', '-', 'Undo', 'Redo'], ['Replace', 'SelectAll', 'Scayt'], ['Format', 'FontSize'], ['Bold', 'Italic', 'Underline', 'TextColor', 'StrikeThrough', '-', 'Outdent', 'Indent', 'RemoveFormat', 'Blockquote', 'HorizontalRule'], ['NumberedList', 'BulletedList', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'], ['Image', 'oembed', 'Video', 'Iframe'], ['Link', 'Unlink'], ['Maximize', 'ShowBlocks'], ['test'] ], 'allowedContent' => true, 'forcePasteAsPlainText' => true, 'extraPlugins' => 'test,image2,widget,oembed,video', 'language' => Yii::$app->language, 'height' => 500 ], ]);
在事件上初始化编辑器
'initOnEvent' => 'focus' //dblclick, mouseover, etc.
使用额外插件
- 添加额外插件连接信息
'extraPlugins' => [
['test', '@root/uploads/plugins/test-plugin/', 'plugin.js']
],
test
必需 - 插件名称@root/uploads/plugins/test-plugin/
必需 - 插件路径plugin.js
必需 - 插件脚本文件
- 将额外插件添加到 editorOptions -> extraPlugins
'extraPlugins' => 'test,image2,oembed,widget,video',
逗号后不加空格。
- 如果你的插件使用按钮,请将其添加到面板上
'toolbar' => [
['test'],
],
链接
- 鼠标事件 - https://api.jqueryjs.cn/category/events/mouse-events/
- CKEditor Api - http://docs.ckeditor.com/
- 文件管理器 ElFinder - https://github.com/MihailDev/yii2-elfinder