voodoo-mobile / yii2-imperavi-widget
该包已被废弃,不再维护。未建议替代包。
Yii 2 框架的 imperavi redactor 小部件。
1.3.3
2016-07-18 09:56 UTC
Requires
- yiisoft/yii2: *
Requires (Dev)
- mikey179/vfsstream: ~1
- phpunit/phpunit: 4.*
- scrutinizer/ocular: ~1.1
README
Imperavi Redactor 小部件
是一个用于 Imperavi Redactor(一个高质量的 WYSIWYG 编辑器)的包装器。
请注意,Imperavi Redactor 本身是一个专有商业版权软件,但由于 Yii 社区购买了 OEM 许可,您可以在 Yii 中免费使用它。
安装
安装此扩展的首选方式是通过 composer。
运行以下命令之一:
$ php composer.phar require --prefer-dist vova07/yii2-imperavi-widget "*"
或者将以下内容添加到您的 composer.json
文件的 require 部分。
"vova07/yii2-imperavi-widget": "*"
使用
使用
一旦安装了该扩展,您就可以在代码中简单使用它
使用小部件
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 许可证。请参阅 许可证文件 以获取更多信息。