All Projects → 2amigos → Yii2 Ckeditor Widget

2amigos / Yii2 Ckeditor Widget

Licence: other
CKEditor WYSIWYG widget for Yii2.

Projects that are alternatives of or similar to Yii2 Ckeditor Widget

yii2-selectize-widget
Selectize From Brian Reavis Yii2 Widget
Stars: ✭ 73 (-55.21%)
Mutual labels:  widget, yii
yii2-grid-view-library
Highly enhanced GridView widget and grid components for Yii2
Stars: ✭ 57 (-65.03%)
Mutual labels:  widget, yii
yii2-multi-select-widget
Bootstrap MultiSelect and MultiSelect Listbox widgets for Yii2
Stars: ✭ 45 (-72.39%)
Mutual labels:  widget, yii
yii2-content-tools
ContentTools editor implementation for Yii 2
Stars: ✭ 79 (-51.53%)
Mutual labels:  widget, wysiwyg
yii2-jstree-widget
jsTree tree widget for yii2
Stars: ✭ 16 (-90.18%)
Mutual labels:  widget, yii
yii2-editable-widget
X-Editable Widget for Yii2
Stars: ✭ 56 (-65.64%)
Mutual labels:  widget, yii
Yii2 Quill
Yii 2 implementation of Quill, modern WYSIWYG editor
Stars: ✭ 52 (-68.1%)
Mutual labels:  widget, wysiwyg
Cl Editor
Lightweight text editor built with svelte, typescript
Stars: ✭ 148 (-9.2%)
Mutual labels:  wysiwyg
Vegalite
R ggplot2 "bindings" for Vega-Lite
Stars: ✭ 157 (-3.68%)
Mutual labels:  widget
Timer App
A simple Timer app for Mac
Stars: ✭ 2,047 (+1155.83%)
Mutual labels:  widget
Mac Hanguldesktop Clock
Hangul Desktop Clock for Mac
Stars: ✭ 146 (-10.43%)
Mutual labels:  widget
Summernote Cleaner
Plugin for Summernote that adds a Button and/or Paste functionality for cleaning MS Word Crud from editor text
Stars: ✭ 148 (-9.2%)
Mutual labels:  wysiwyg
Rich Markdown Editor
The open source React and Prosemirror based markdown editor that powers Outline. Want to try it out? Create an account:
Stars: ✭ 2,468 (+1414.11%)
Mutual labels:  wysiwyg
Yii2 Assets Auto Compress
Automatic compilation of js + css + html
Stars: ✭ 147 (-9.82%)
Mutual labels:  yii
Ngx Dynamic Dashboard Framework
This is a JSON driven angular x based dashboard framework that is inspired by JIRA's dashboard implementation and https://github.com/raulgomis/angular-dashboard-framework
Stars: ✭ 160 (-1.84%)
Mutual labels:  widget
Scriptable
Scripts and widgets for the iOS Scriptable App
Stars: ✭ 147 (-9.82%)
Mutual labels:  widget
Balance
Balance accounting (bookkeeping) system based on debit and credit principle
Stars: ✭ 162 (-0.61%)
Mutual labels:  yii
Clendar
Clendar - universal calendar app. Written in SwiftUI. Available on App Store
Stars: ✭ 153 (-6.13%)
Mutual labels:  widget
Yii2 Cms
YiiCMS - 基于 Yii2 的高度可定制化开源 CMS
Stars: ✭ 153 (-6.13%)
Mutual labels:  yii
Graphview
Flutter GraphView is used to display data in graph structures. It can display Tree layout, Directed and Layered graph. Useful for Family Tree, Hierarchy View.
Stars: ✭ 152 (-6.75%)
Mutual labels:  widget

CKEditor Widget for Yii2

Latest Version Software License Build Status Coverage Status Quality Score Total Downloads

Renders a CKEditor WYSIWYG text editor plugin widget.

Installation

The preferred way to install this extension is through composer.

Either run

composer require 2amigos/yii2-ckeditor-widget

or add

"2amigos/yii2-ckeditor-widget" : "~2.1"

to the require section of your application's composer.json file.

Skins & Plugins

This widget works with default's dev-full/stable branch of CKEditor, with a set of plugins and skins. If you wish to configure a different skins or plugins that the one proposed, you will have to download them separately and configure the widget's clientOptions attribute accordingly.

Usage

The library comes with two widgets: CKEditor and CKEditorInline. One is for classic edition and the other for inline editing respectively.

Using a model with a basic preset:


use dosamigos\ckeditor\CKEditor;


<?= $form->field($model, 'text')->widget(CKEditor::className(), [
        'options' => ['rows' => 6],
        'preset' => 'basic'
    ]) ?>

Using inline edition with basic preset:


use dosamigos\ckeditor\CKEditorInline;

<?php CKEditorInline::begin(['preset' => 'basic']);?>
    This text can be edited now :)
<?php CKEditorInline::end();?>

How to add custom plugins

This is the way to add custom plugins to the editor. Since version 2.0 we are working with the packagist version of the CKEditor library, therefore we are required to use its configuration API in order to add external plugins.

Lets add the popular Code Editor Plugin for example. This plugin would allow us to add a button to our editor's toolbar so we can add code to the content we are editing.

Assuming you have downloaded the plugin and added to the root directory of your Yii2 site. I have it this way:

+ frontend 
+ -- web 
    + -- pbckcode 

We can now add it to our CKEditor widget. For this example I am using CKEditorInline widget. One thing you notice on this example is that we do not use the preset attribute; this is highly important as we want to add a customized toolbar to our widget. No more talking, here is the code:

<?php
 
use dosamigos\ckeditor\CKEditorInline;

// First we need to tell CKEDITOR variable where is our external plugin
$this->registerJs("CKEDITOR.plugins.addExternal('pbckcode', '/pbckcode/plugin.js', '');");

// ... 
// Using the plugin
<?php CKEditorInline::begin(['preset' => 'custom', 'clientOptions' => [
    'extraPlugins' => 'pbckcode',
    'toolbarGroups' => [
        ['name' => 'undo'],
        ['name' => 'basicstyles', 'groups' => ['basicstyles', 'cleanup']],
        ['name' => 'colors'],
        ['name' => 'links', 'groups' => ['links', 'insert']],
        ['name' => 'others', 'groups' => ['others', 'about']],
        
        ['name' => 'pbckcode'] // <--- OUR NEW PLUGIN YAY!
    ]
]]) ?>

<p>
    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
    dolore magna aliqua. 
</p>
<?php CKEditorInline::end() ?>

Browse & Upload

To browse and upload files, the KCFinder plugin is used, which is disabled by default.

To enable it, just use 'kcfinder'=>true.

See this simple example code:

<?php
use dosamigos\ckeditor\CKEditor;

echo $form->field($model, 'text')->widget(CKEditor::className(), [
    'kcfinder' => true,
]);

The upload folder name is upload in the root web directory by default.

You can set options for the kcfOptions parameter, and can find all KCFinder's options in this link: https://kcfinder.sunhater.com/install

For change upload directory or change some options you can see this advanced example code:

<?php
use dosamigos\ckeditor\CKEditor;

echo $form->field($model, 'text')->widget(CKEditor::className(), [
    'kcfinder' => true,
    'kcfOptions' => [
        'uploadURL' => '@web/upload',
        'uploadDir' => '@webroot/upload',
        'access' => [  // @link http://kcfinder.sunhater.com/install#_access
            'files' => [
                'upload' => true,
                'delete' => true,
                'copy' => true,
                'move' => true,
                'rename' => true,
            ],
            'dirs' => [
                'create' => true,
                'delete' => true,
                'rename' => true,
            ],
        ],
        'types' => [  // @link http://kcfinder.sunhater.com/install#_types
            'files' => [
                'type' => '',
            ],
        ],
    ],
]);

About extra assets

You maybe wonder why there is file dosamigos-ckeditor.widget.js. The reason is that due to the way Yii2 works with forms and Cross-Site Request Forgery (csrf). CKEditor does not trigger the on change event nor collects the CSRF token when using file uploads.

The asset tackles both issues.

Testing

To test the extension, is better to clone this repository on your computer. After, go to the extensions folder and do the following (assuming you have composer installed on your computer):

$ composer install --no-interaction --prefer-source --dev

Once all required libraries are installed then do:

$ vendor/bin/phpunit

Further Information

Please, check the CKEditor plugin site documentation for further information about its configuration options.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The BSD License (BSD). Please see License File for more information.

2amigOS!
Web development has never been so fun!
www.2amigos.us

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].