trsteel / ckeditor-bundle
Symfony bundle for easy integration of the CKEditor WYSIWYG
Installs: 575 920
Dependents: 13
Suggesters: 21
Security: 0
Stars: 97
Watchers: 11
Forks: 59
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=8.1
- ezyang/htmlpurifier: ~4.0
- symfony/form: ^6.0 || ^7.0
- symfony/framework-bundle: ^6.0 || ^7.0
- twig/twig: >=1.1,<4.0
Requires (Dev)
- php-cs-fixer/shim: ^3.13
- phpstan/phpstan: ^1.9
- phpstan/phpstan-symfony: ^1.2
- phpunit/phpunit: ^9.0
- rector/rector: ^0.15.10
- symfony/asset: ^6.0 || ^7.0
- symfony/phpunit-bridge: ^6.0 || ^7.0
- symfony/templating: ^6.0 || ^7.0
- symfony/twig-bundle: ^6.0 || ^7.0
- symfony/yaml: ^6.0 || ^7.0
- 1.21.1
- 1.21.0
- 1.20.0
- 1.19.0
- 1.18.0
- v1.17.0
- v1.16.0
- v1.15.4
- v1.15.3
- v1.15.2
- v1.15.0
- v1.14.0
- v1.13.1
- v1.13.0
- v1.12.1
- 1.12.0
- dev-master / 1.11.x-dev
- v1.11.0
- v1.10.5
- v1.10.4
- v1.10.3
- v1.10.2
- v1.10.1
- v1.10.0
- v1.9.0
- v1.8.4
- v1.8.3
- v1.8.2
- v1.8.1
- v1.8.0
- v1.7.0
- v1.6.2
- v1.6.1
- v1.6.0
- v1.5.1
- v1.5.0
- v1.4.6
- v1.4.5
- v1.4.4
- v1.4.3
- v1.4.2
- v1.4.1
- v1.4.0
- v1.3.1
- v1.3.0
- v1.2.1
- v1.2.0
- v1.1
- v1.0
This package is auto-updated.
Last update: 2024-10-09 02:51:46 UTC
README
- Add TrsteelCkeditorBundle to your composer.json
- Enable the bundle
- Install bundle assets
- Configure the bundle (optional)
- Add the editor to a form
- Configure data transformers
Step 1: Add TrsteelCkeditorBundle to your composer.json
php composer.phar require Trsteel/ckeditor-bundle
Step 2: Enable the bundle
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Trsteel\CkeditorBundle\TrsteelCkeditorBundle(), ); }
Step 3: Install bundle assets
$ php ./app/console assets:install web --symlink
--symlink is optional
Step 4: Configure the bundle (optional)
For a full configuration dump use:
$ php ./app/console config:dump-reference TrsteelCkeditorBundle
An example configuration:
trsteel_ckeditor: class: Trsteel\CkeditorBundle\Form\Type\CkeditorType transformers: ['html_purifier'] toolbar: ['document', 'clipboard', 'editing', '/', 'basicstyles', 'paragraph', 'links', '/', 'insert', 'styles', 'tools'] toolbar_groups: document: ['Source','-','Save','-','Templates'] clipboard: ['Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo'] editing: ['Find','Replace','-','SelectAll'] basicstyles: ['Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat'] paragraph: ['NumberedList','BulletedList','-','Outdent','Indent','-','JustifyLeft', 'JustifyCenter','JustifyRight','JustifyBlock'] links: ['Link','Unlink','Anchor'] insert: ['Image','Flash','Table','HorizontalRule'] styles: ['Styles','Format'] tools: ['Maximize', 'ShowBlocks'] ui_color: '#000000' startup_outline_blocks: true width: 800 #Integer or % height: 300 #Integer or % language: 'en-au' filebrowser_upload_url: url: relative-url.php?type=file filebrowser_image_browse_url: route: route_name route_parameters: type: image
Or even overwrite the 'document' toolbar group in your application completely.
trsteel_ckeditor: class: Trsteel\CkeditorBundle\Form\Type\CkeditorType toolbar: ['document', 'clipboard', 'editing', '/', 'basicstyles', 'paragraph', 'links', '/', 'insert', 'styles', 'tools'] toolbar_groups: document: ['Source']
You can create additional toolbar groups. Just create the group and specify the items. As you can see in the above config the 'document' toolbar group has been overwritten and only shows the 'Source' icon.
Step 5: Add the editor to a form
Example form:
<?php $form = $this->createFormBuilder($post) ->add('title', 'text') ->add('content', \Trsteel\CkeditorBundle\Form\Type\CkeditorType::class, array( 'transformers' => array('html_purifier'), 'toolbar' => array('document','basicstyles'), 'toolbar_groups' => array( 'document' => array('Source') ), 'ui_color' => '#fff', 'startup_outline_blocks' => false, 'width' => '100%', 'height' => '320', 'language' => 'en-au', 'filebrowser_image_browse_url' => array( 'url' => 'relative-url.php?type=file', ), 'filebrowser_image_browse_url' => array( 'route' => 'route_name', 'route_parameters' => array( 'type' => 'image', ), ), )) ->getForm() ;
Note: All parameters from config.yml can be overwritten in a form (excluding 'class').
Step 6: Configure data transformers
Data transformers will automatically update the html content when the form is processed.
The bundle comes with a html purifier transformer thanks to https://github.com/ezyang/htmlpurifier
If you do not want any transformers enabled you should disable them by:
- Disable globally in the config:
trsteel_ckeditor: transformers: []
- Disable them on a particular form:
<?php $form = $this->createFormBuilder($post) ->add('title', 'text') ->add('content', \Trsteel\CkeditorBundle\Form\Type\CkeditorType::class, array( 'transformers' => array(), )) ->getForm() ;