bariew/yii2-imperavi-redactor

Imperavi Redactor WYSIWYG小部件(针对Yii 2的OEM授权)

安装: 340

依赖者: 4

建议者: 0

安全: 0

星标: 0

关注者: 2

分支: 53

开放问题: 0

语言:JavaScript

类型:yii2-extension

1.0.0-alpha 2014-08-13 06:55 UTC

This package is auto-updated.

Last update: 2024-09-16 14:50:17 UTC


README

Tourista 创建

ImperaviRedactorWidget 是一个用于 Imperavi Redactor 的高质量WYSIWYG编辑器的包装器。

请注意,Imperavi Redactor 本身是一个专有商业版权软件,但由于Yii社区购买了OEM许可证,您可以在Yii中免费使用它。

使用模型

yii\imperavi\Widget::widget([
	// You can either use it for model attribute
	'model' => $my_model,
	'attribute' => 'my_field',

	// or just for input field
	'name' => 'my_input_name',

	// Some options, see http://imperavi.com/redactor/docs/
	'options' => [
		'toolbar' => false,
		'css' => 'wym.css',
	],
]);

或者,您可以通过调用将Redactor附加到已存在的DOM元素

yii\imperavi\Widget::widget([
	// Some options, see http://imperavi.com/redactor/docs/
	'options' => [],
]);

通过资源包将插件连接到redactor。

yii\imperavi\Widget::widget([
	'options' => [
		'lang' => 'ru',
	],
	'plugins' => [
		'fullscreen',
		'clips'
	]
]);

使用上传操作

 // 1. Use your controller actions() method, e.g.:
    public function actions()
    {
        $path = "/files/".$this->module->id."/".$this->id."/".Yii::$app->user->id;
        return [
            'file-upload'    => [
                'class'         => 'yii\imperavi\actions\FileUpload',
                'uploadPath'    => Yii::getAlias('@app/web'.$path),
                'uploadUrl'     => $path
            ],
            'image-upload'    => [
                'class'         => 'yii\imperavi\actions\ImageUpload',
                'uploadPath'    => Yii::getAlias('@app/web'.$path),
                'uploadUrl'     => $path
            ],
            'image-list'    => [
                'class'         => 'yii\imperavi\actions\ImageList',
                'uploadPath'    => Yii::getAlias('@app/web'.$path),
                'uploadUrl'     => $path
            ],
        ];
    }
 // 2. Set upload options in your imperavi widget, e.g.:
    [
        'fileUpload'               => Url::toRoute(['file-upload', 'attr' => 'content']),
        'imageUpload'              => Url::toRoute(['image-upload', 'attr' => 'content']),
        'imageGetJson'             => Url::toRoute(['image-list', 'attr' => 'content']),
        'imageUploadErrorCallback' => new \yii\web\JsExpression('function(json) { alert(json.error); }'),
        'fileUploadErrorCallback'  => new \yii\web\JsExpression('function(json) { alert(json.error); }'),
    ]

 * You can also redefine action 'customRules' attribute for file validation.

安装

安装此扩展的首选方法是使用 composer

运行以下命令

php composer.phar require bariew/yii2-imperavi-redactor "*"

或者

"bariew/yii2-imperavi-redactor": "*"

将以下内容添加到您的 composer.json 文件的require部分。