承接 wolfguard/yii2-tinymce-codemirror 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

wolfguard/yii2-tinymce-codemirror

Composer 安装命令:

composer require wolfguard/yii2-tinymce-codemirror

包简介

Yii2 extension to use TinyMce with Compressor, CodeMirror 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.
  • 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.

Fork of another extension with some additional features:

  • CodeMirror plugin integration for source code mode.

CodeMirror plugin was taken from Christiaan Baartse repository

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist wolfguard/yii2-tinymce-codemirror "*"

or add

"wolfguard/yii2-tinymce-codemirror": "*"

to the require section of your composer.json file.

Usage

Widget basic usage

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

Scripts compressor

This can be used to optimize widget loading time.

At fist setup controller map:

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

Next add route to configured action to widget options:

$form->field($model, 'content')->widget(\wolfguard\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(\wolfguard\tinymce\TinyMce::className(), [
    'fileManager' => [
        'class' => \wolfguard\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(\wolfguard\tinymce\TinyMce::className(), [
    'fileManager' => [
        'class' => \wolfguard\tinymce\fm\MihaildevElFinder::className(),
        'controller' => 'elf2'
    ]
])

Any file manager

You can write your own file manager provider. Just inherit it from \wolfguard\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(\wolfguard\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(\wolfguard\tinymce\TinyMce::className(), [
    'compressorRoute' => 'site/tinyMceCompressor',
    'fileManager' => [
        'class' => \wolfguard\tinymce\fm\MihaildevElFinder::className()
    ],
    'spellcheckerUrl'=>'http://speller.yandex.net/services/tinyspell',
    'options' => ['rows' => 6]
]) ?>

CodeMirror configuration

Additional configuration options

You can modify the behaviour of the codemirror plugin, by adding a codemirror object to the TinyMCE configuration.

indentOnInit: boolean (false) CodeMirror automatically indents code. With the indentOnInit option, you tell the Source Code editor to indent all code when the editor opens. This might be slow for large documents.

path: string (codemirror) You might already have CodeMirror hosted elsewhere (outside TinyMCE). In that case, you can reuse that CodeMirror instance, by overriding the default path. For example:

path: 'http://www.mysite.com/tools/codemirror-4.8'

config: Object CodeMirror configuration object, which is passed on to the CodeMirror instance. Check http://codemirror.net/doc/manual.html for available configuration options.

jsFiles: Array Array of CodeMirror Javascript files you want to (additionally) load. For example:

jsFiles: [
   'mode/clike/clike.js',
   'mode/php/php.js'
]

The following Javascript files are always loaded: lib/codemirror.js, addon/edit/matchbrackets.js, mode/xml/xml.js, mode/javascript/javascript.js, mode/css/css.js, mode/htmlmixed/htmlmixed.js, addon/dialog/dialog.js, addon/search/searchcursor.js, addon/search/search.js, addon/selection/active-line.js.

cssFiles: Array Array of CodeMirror CSS files you want to (additionally) load. For example:

cssFiles: [
   'theme/neat.css',
   'theme/elegant.css'
]

The following CSS files are always loaded: lib/codemirror.css, addon/dialog/dialog.css.

Config example

tinymce.init({
  selector: '#html',
  plugins: 'codemirror',
  toolbar: 'undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | code',
  codemirror: {
    indentOnInit: true, // Whether or not to indent code on init.
    path: 'CodeMirror', // Path to CodeMirror distribution
    config: {           // CodeMirror config object
       mode: 'application/x-httpd-php',
       lineNumbers: false
    },
    jsFiles: [          // Additional JS files to load
       'mode/clike/clike.js',
       'mode/php/php.js'
    ]
  }
});

wolfguard/yii2-tinymce-codemirror 适用场景与选型建议

wolfguard/yii2-tinymce-codemirror 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 783 次下载、GitHub Stars 达 1, 最近一次更新时间为 2016 年 03 月 15 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「wysiwyg」 「tinymce」 「extension」 「codemirror」 「yii2」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 wolfguard/yii2-tinymce-codemirror 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 wolfguard/yii2-tinymce-codemirror 我们能提供哪些服务?
定制开发 / 二次开发

基于 wolfguard/yii2-tinymce-codemirror 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 2
  • Forks: 2
  • 开发语言: JavaScript

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2016-03-15