gfrodriguez / yii2-ckeditor
该软件包最新版本(1.0.0)没有提供许可证信息。
Yii2 CKEditor
1.0.0
2018-10-04 04:20 UTC
Requires
- php: >=5.4.0
- yiisoft/yii2: *
This package is not auto-updated.
Last update: 2024-09-28 09:20:03 UTC
README
这是从 MihailDev/yii2-ckeditor 和 sadovojav/yii2-ckeditor 分支出来的。
功能
- 添加自定义插件的能力
- 在事件上初始化编辑器
- 添加了自定义插件
插件
Composer
通过 Composer 安装此扩展是首选方式。
运行 php composer.phar require gfrodriguez/yii2-ckeditor "dev-master"
或将 "gfrodriguez/yii2-ckeditor": "dev-master"
添加到您的 composer.json
文件的 require 部分
使用方法
- 小部件
use gfrodriguez\ckeditor\CKEditor; echo CKEditor::widget();
- ActiveForm
use gfrodriguez\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' => [ ['Preview', 'Viewss'], ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo'], ['Find', 'Replace', '-', 'SelectAll', '-', 'Scayt'], ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', 'TextColor', 'BGColor', '-', 'RemoveFormat'], ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'], ['Image', 'Table', 'SpecialChar', 'Mathjax'],// 'Footnotes'], ['Styles', 'Format'], ['Maximize', 'ShowBlocks'], ['About'], ], 'allowedContent' => true, 'forcePasteAsPlainText' => true, 'extraPlugins' => 'test,image2,widget,oembed,video', 'language' => Yii::$app->language, 'height' => 500, 'mathJaxLib' => '//cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS_HTML', 'disableNativeSpellChecker' => false, 'scayt_sLang' => Yii::$app->language, 'removePlugins' => 'scayt,wsc', 'disableNativeSpellChecker' => false, 'qtRows' => 8, // Count of rows in the quicktable (default: 8) 'qtColumns' => 10, // Count of columns in the quicktable (default: 10) 'qtBorder' => '1', // Border of the inserted table (default: '1') 'qtWidth' => '90%', // Width of the inserted table (default: '500px') 'qtCellPadding' => '0', // Cell padding of the inserted table (default: '1') 'qtCellSpacing' => '0', // Cell spacing of the inserted table (default: '1') 'qtPreviewSize' => '14px', // Cell size of the preview table (default: '14px') 'qtPreviewBackground' => '#c8def4' // Cell background of the preview table on hover (default: '#e5e5e5') ], ]);
在事件上初始化编辑器
'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' => 'dialog,lineutils,wordcount,notification,image2,widget,oembed,quicktable,tableresize,filetools,notificationaggregator,mathjax',
逗号后不加空格。
- 如果您的插件使用按钮,请在面板上添加它
'toolbar' => [
['test'],
],
链接
- 鼠标事件 - https://api.jqueryjs.cn/category/events/mouse-events/
- CKEditor Api - http://docs.ckeditor.com/
- 文件管理器 ElFinder - https://github.com/MihailDev/yii2-elfinder