as-milano/yii2-tinymce 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

as-milano/yii2-tinymce

Composer 安装命令:

composer require as-milano/yii2-tinymce

包简介

Yii2 extension to use TinyMce with Compressor and FileManager

README 文档

README

Yii2 extension to simplify TinyMCE WYSIWYG editor usage in your application.

Provides:

  • widget;
  • compressor action;
  • integration with file managers like elFinder;
  • integration with spelling services like Yandex.

Fork of another extension with some additional features:

  • TinyMCE gone to npm package to always have the latest version;
  • Added integration with great elFinder extension;
  • (TODO) Icon to insert many images at once;
  • Few bugs resolved. It's all working now.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist as-milano/yii2-tinymce "*"

or add

"as-milano/yii2-tinymce": "*"

to the require section of your composer.json file.

Usage

Widget basic usage

$form->field($model, 'content')->widget(\milano\tinymce\TinyMce::className())

Scripts compressor

This can be used to optimize widget loading time.

At fist setup controller map:

'controllerMap' => [
    'tinyMce' => [
        'class' => 'milano\tinymce\TinyMceController',
    ]
],

Next add route to configured action to widget options:

$form->field($model, 'content')->widget(\milano\tinymce\TinyMce::className(), [
    'compressorRoute' => 'tinyMce/tinyMceCompressor'
])

ElFinder file manager

Install mihaildev/yii2-elfinder extension. You can just include

"mihaildev/yii2-elfinder": "*"

to the require section of your composer.json file.

Configure elFinder (more info here).:

'controllerMap' => [
    'elfinder' => [
        'class' => 'mihaildev\elfinder\Controller',
        'access' => ['@'],
        'disabledCommands' => ['netmount'],
        'roots' => [
            [
                'baseUrl'=>'@web',
                'basePath'=>'@webroot',
                'path' => 'files/global',
                'name' => 'Global'
            ],
        ],
        'watermark' => [
                'source'         => __DIR__.'/logo.png',
                 'marginRight'    => 5,
                 'marginBottom'   => 5,
                 'quality'        => 95,
                 'transparency'   => 70,
                 'targetType'     => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP,
                 'targetMinPixel' => 200
        ]
    ]
],

Then select file manager provider in the widget:

$form->field($model, 'content')->widget(\milano\tinymce\TinyMce::className(), [
    'fileManager' => [
        'class' => \milano\tinymce\fm\MihaildevElFinder::className()
    ],
])

You can customize some window (width and height) and manager (language, filter, path and multiple) properties. If you want to use different access, watermark and roots setting just prepare controllers:

'controllerMap' => [
    'elf1' => [
        'class' => 'mihaildev\elfinder\Controller',
        'access' => ['@'],
        'roots' => [
            [
                'baseUrl'=>'@web',
                'basePath'=>'@webroot',
                'path' => 'files/global',
                'name' => 'Global'
            ],
        ],
        'watermark' => [
                'source'         => __DIR__.'/logo.png',
                 'marginRight'    => 5,
                 'marginBottom'   => 5,
                 'quality'        => 95,
                 'transparency'   => 70,
                 'targetType'     => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP,
                 'targetMinPixel' => 200
        ]
    ],
    'elf2' => [
        'class' => 'mihaildev\elfinder\Controller',
        'access' => ['*'],
        'roots' => [
            [
                'path' => 'files/some1',
                'name' => ['category' => 'my','message' => 'Some Name']
            ],
            [
                'path'   => 'files/some2',
                'name'   => ['category' => 'my','message' => 'Some Name'],
                'access' => ['read' => '*', 'write' => 'UserFilesAccess']
            ]
        ]
    ]
],

and then point to required controller in the widget:

$form->field($model, 'content2')->widget(\milano\tinymce\TinyMce::className(), [
    'fileManager' => [
        'class' => \milano\tinymce\fm\MihaildevElFinder::className(),
        'controller' => 'elf2'
    ]
])

Any file manager

You can write your own file manager provider. Just inherit it from \milano\tinymce\fm\FileManager class and realize getFileBrowserCallback and registerAsset functions.

Spellchecker

TinyMce has bundled plugin for spellchecking but it requires backed to work.

You can use Yandex spellchecker service.

$form->field($model, 'content')->widget(\milano\tinymce\TinyMce::className(), [
    'spellcheckerUrl' => 'http://speller.yandex.net/services/tinyspell'
])

More info about it here: http://api.yandex.ru/speller/doc/dg/tasks/how-to-spellcheck-tinymce.xml

Or you can build own spellcheking service using code provided by moxicode: http://www.tinymce.com/download/download.php

Combined features

<?= $form->field($model, 'content')->widget(\milano\tinymce\TinyMce::className(), [
    'compressorRoute' => 'site/tinyMceCompressor',
    'fileManager' => [
        'class' => \milano\tinymce\fm\MihaildevElFinder::className()
    ],
    'spellcheckerUrl'=>'http://speller.yandex.net/services/tinyspell',
    'options' => ['rows' => 6]
]) ?>

统计信息

  • 总下载量: 2.34k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: JavaScript

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2015-06-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固