8000 GitHub - garixi/yii2-redactor: Extension Redactor WYSIWYG for Yii2 framework (fork of yiidoc/yii2-redactor)
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Extension Redactor WYSIWYG for Yii2 framework (fork of yiidoc/yii2-redactor)

License

Notifications You must be signed in to change notification settings

garixi/yii2-redactor

 
 

Repository files navigation

garixi/yii2-redactor

A redactor extension for Yii2 Framework. This version is a fork of yiidoc/yii2-redactor to allow some additional settings and options.

For install, replace "yiidoc/" with "garixi/" along with a repository if this has not been published on packagelist yet...

Changes

English (UK) language added

    'clientOptions' => [
        ...
        'lang' => 'en_gb',
        ...
    ]

.size()

.size() replaced with .length for JQuery compatibility.

removePastedImages (default false)

Additional option to remove images pasted in to content (as base64 data) - less restrictive than pastePlainText.

removePastedImagesMessage (default blank)

Additional option to tell users the correct way to upload images.

        'clientOptions' => [
            ...
            'pastePlainText' => false,
            'removePastedImages' => true,
            'removePastedImagesMessage' => "<h1>Please upload images via filemanager or drag'n'drop</h1>",
            ...
        ]

dir parameter for upload actions in widget

additional querystring parameter dir to choose the target upload directory

        
                    'clientOptions' => [
                        'imageManagerJson' => ['/redactor/upload/image-json'],
                        'imageUpload' => ['/redactor/upload/image', 'dir' => 'contents/about_page/files'],
                        'fileUpload' => ['/redactor/upload/file','dir' => 'contents/about_page/files'],
                        ...
                    ]
        
                    'clientOptions' => [
                        'imageManagerJson' => ['/redactor/upload/image-json'],
                        'imageUpload' => ['/redactor/upload/image', 'dir' => 'contents/contacts_page/files'],
                        'fileUpload' => ['/redactor/upload/file','dir' => 'contents/contacts_page/files'],
                        ...
                    ]

authUserDir config option

Additional config option added - authUserDir (default blank, allowed characters a-zA-Z0-9 only) When set, this hides logged in user id's in file paths and uses a common folder for all logged in users. The guest user file path is still 'guest'.

    'modules' => [
        'redactor' => [
            'class' => 'yii\redactor\RedactorModule',
            'uploadDir' => '@webroot/uploads',
            'uploadUrl' => '@web/uploads',
            'imageAllowExtensions'=>['jpg','jpeg','png','gif','webp'],
            'authUserDir' => 'files'
        ],
    ],

Integrate Redactor-10-clipboardPaste-plugin

Integrated CFDan's clipboardPaste plugin and added clipboard upload action.

Source: https://github.com/CFDan/Redactor-10-clipboardPaste-plugin

        'clientOptions' => [
            ...
            'removePastedImages' => true,
            'removePastedImagesMessage' => "",
            'plugins' => ['fontcolor','imagemanager','filemanager','clipboardPaste'],
            'clipboardUploadUrl' => ['/redactor/upload/image-clip'],
            'clipboardUpload' => true,
            ...
       
7494
 ]

Original yiidoc/yii2-redactor Readme:

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist yiidoc/yii2-redactor "*"

or

 "yiidoc/yii2-redactor": "*"

to the require section of your composer.json.

Configure

Add to config file (config/web.php or common\config\main.php)

    'modules' => [
        'redactor' => 'yii\redactor\RedactorModule',
    ],

or if you want to change the upload directory. to path/to/uploadfolder default value @webroot/uploads

    'modules' => [
        'redactor' => [
            'class' => 'yii\redactor\RedactorModule',
            'uploadDir' => '@webroot/path/to/uploadfolder',
            'uploadUrl' => '@web/path/to/uploadfolder',
            'imageAllowExtensions'=>['jpg','png','gif']
        ],
    ],

note: You need to create uploads folder and chmod and set security for folder upload reference: Protect Your Uploads Folder with .htaccess, How to Setup Secure Media Uploads

Config view/form

<?= $form->field($model, 'body')->widget(\yii\redactor\widgets\Redactor::className()) ?>

or not use ActiveField

<?= \yii\redactor\widgets\Redactor::widget([
    'model' => $model,
    'attribute' => 'body'
]) ?>

or config advanced redactor reference Docs

<?= $form->field($model, 'body')->widget(\yii\redactor\widgets\Redactor::className(), [
    'clientOptions' => [
        'imageManagerJson' => ['/redactor/upload/image-json'],
        'imageUpload' => ['/redactor/upload/image'],
        'fileUpload' => ['/redactor/upload/file'],
        'lang' => 'zh_cn',
        'plugins' => ['clips', 'fontcolor','imagemanager']
    ]
])?>

About

Extension Redactor WYSIWYG for Yii2 framework (fork of yiidoc/yii2-redactor)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 81.8%
  • CSS 7.2%
  • Less 6.6%
  • PHP 4.4%
0