weison-tech / yii2-imperavi-widget
Yii 2 框架的 imperavi redactor 小部件。
1.2.11
2016-05-18 03:22 UTC
Requires
- yiisoft/yii2: *
Requires (Dev)
- mikey179/vfsstream: ~1
- phpunit/phpunit: 4.*
- scrutinizer/ocular: ~1.1
README
Imperavi Redactor Widget
是一个用于 Imperavi Redactor 的高质量 WYSIWYG 编辑器的包装器。
注意,Imperavi Redactor 本身是一个专有商业版权软件,但由于 Yii 社区购买了 OEM 许可证,您可以在 Yii 中免费使用它。
安装
安装此扩展的首选方式是通过 composer。
运行
$ php composer.phar require --prefer-dist weison-tech/yii2-imperavi-widget "*"
或添加
"weison-tech/yii2-imperavi-widget": "*"
到您的 composer.json
文件的 require 部分。
用法
扩展安装完成后,只需在您的代码中使用它
像小部件一样
echo \vova07\imperavi\Widget::widget([ 'name' => 'redactor', 'settings' => [ 'lang' => 'ru', 'minHeight' => 200, 'plugins' => [ 'clips', 'fullscreen' ] ] ]);
像 ActiveForm 小部件一样
use vova07\imperavi\Widget; echo $form->field($model, 'content')->widget(Widget::className(), [ 'settings' => [ 'lang' => 'ru', 'minHeight' => 200, 'plugins' => [ 'clips', 'fullscreen' ] ] ]);
像预定义 textarea 的小部件一样
echo \vova07\imperavi\Widget::widget([ 'selector' => '#my-textarea-id', 'settings' => [ 'lang' => 'ru', 'minHeight' => 200, 'plugins' => [ 'clips', 'fullscreen' ] ] ]);
添加已上传的图片
// DefaultController.php public function actions() { return [ 'images-get' => [ 'class' => 'vova07\imperavi\actions\GetAction', 'url' => 'http://my-site.com/images/', // Directory URL address, where files are stored. 'path' => '@alias/to/my/path', // Or absolute path to directory where files are stored. 'type' => GetAction::TYPE_IMAGES, ] ]; } // View.php echo \vova07\imperavi\Widget::widget([ 'selector' => '#my-textarea-id', 'settings' => [ 'lang' => 'ru', 'minHeight' => 200, 'imageManagerJson' => Url::to(['/default/images-get']), 'plugins' => [ 'imagemanager' ] ] ]);
添加已上传的文件
// DefaultController.php public function actions() { return [ 'files-get' => [ 'class' => 'vova07\imperavi\actions\GetAction', 'url' => 'http://my-site.com/files/', // Directory URL address, where files are stored. 'path' => '@alias/to/my/path', // Or absolute path to directory where files are stored. 'type' => GetAction::TYPE_FILES, ] ]; } // View.php echo \vova07\imperavi\Widget::widget([ 'selector' => '#my-textarea-id', 'settings' => [ 'lang' => 'ru', 'minHeight' => 200, 'fileManagerJson' => Url::to(['/default/files-get']), 'plugins' => [ 'filemanager' ] ] ]);
上传图片
// DefaultController.php public function actions() { return [ 'image-upload' => [ 'class' => 'vova07\imperavi\actions\UploadAction', 'url' => 'http://my-site.com/images/', // Directory URL address, where files are stored. 'path' => '@alias/to/my/path' // Or absolute path to directory where files are stored. ], ]; } // View.php echo \vova07\imperavi\Widget::widget([ 'selector' => '#my-textarea-id', 'settings' => [ 'lang' => 'ru', 'minHeight' => 200, 'imageUpload' => Url::to(['/default/image-upload']) ] ]);
上传文件
// DefaultController.php public function actions() { return [ 'file-upload' => [ 'class' => 'vova07\imperavi\actions\UploadAction', 'url' => 'http://my-site.com/files/', // Directory URL address, where files are stored. 'path' => '@alias/to/my/path', // Or absolute path to directory where files are stored. 'uploadOnlyImage' => false, // For not image-only uploading. ], ]; } // View.php echo \vova07\imperavi\Widget::widget([ 'selector' => '#my-textarea-id', 'settings' => [ 'lang' => 'ru', 'minHeight' => 200, 'fileUpload' => Url::to(['/default/file-upload']) ] ]);
添加自定义插件
echo \vova07\imperavi\Widget::widget([ 'selector' => '#my-textarea-id', 'settings' => [ 'lang' => 'ru', 'minHeight' => 200, 'plugins' => [ 'clips', 'fullscreen' ] ], 'plugins' => [ 'my-custom-plugin' => 'app\assets\MyPluginBundle' ] ]);
测试
$ phpunit
更多信息
请参阅 Imperavi Redactor 文档以获取有关其配置选项的更多信息。
贡献
请参阅 CONTRIBUTING 以获取详细信息。
鸣谢
许可
BSD 许可证 (BSD)。请参阅 许可文件 以获取更多信息。