### Install Assets (Symfony Flex)
Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/installation.rst
Install CKEditor assets into the public directory when using Symfony Flex.
```bash
$ php bin/console assets:install public
```
--------------------------------
### Display CKEditor Install Command Help
Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/usage/ckeditor.rst
View the comprehensive help documentation for the ckeditor:install command to understand all available options and their usage.
```bash
$ php bin/console ckeditor:install --help
```
--------------------------------
### Integrate CKEditor Installation into Composer Scripts
Source: https://context7.com/friendsofsymfony/fosckeditorbundle/llms.txt
Automate CKEditor installation and updates by adding the 'ckeditor:install' command to your Composer scripts.
```json
{
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"ckeditor:install --clear=drop": "symfony-cmd",
"assets:install --symlink --relative %PUBLIC_DIR%": "symfony-cmd"
},
"post-install-cmd": ["@auto-scripts"],
"post-update-cmd": ["@auto-scripts"]
}
}
```
--------------------------------
### Install Assets (Symfony <= 2.8)
Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/installation.rst
Install CKEditor assets into the web directory for Symfony versions 2.8 and below.
```bash
$ php app/console assets:install web
```
--------------------------------
### Install CKEditor using Console Command
Source: https://context7.com/friendsofsymfony/fosckeditorbundle/llms.txt
Use the ckeditor:install command to download and set up the CKEditor 4 library. Various options are available for release types, versions, and custom builds.
```bash
php bin/console ckeditor:install
```
```bash
php bin/console ckeditor:install --release=standard
```
```bash
php bin/console ckeditor:install --tag=4.16.0
```
```bash
php bin/console ckeditor:install /var/www/html/public/ckeditor
```
```bash
php bin/console ckeditor:install --release=custom --custom-build-id=574a82a0d3e9226d94b0e91d10eaa372
```
```bash
php bin/console ckeditor:install --clear=drop # Drop and reinstall
```
```bash
php bin/console ckeditor:install --clear=keep # Keep and override files
```
```bash
php bin/console ckeditor:install --clear=skip # Skip installation
```
```bash
php bin/console ckeditor:install --exclude=samples --exclude=adapters
```
--------------------------------
### Install CKEditor Assets
Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/migration.rst
Use the console command to fetch CKEditor assets after migration.
```bash
bin/console ckeditor:install
```
--------------------------------
### Configure Composer Scripts for CKEditor Installation
Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/usage/ckeditor.rst
Integrate CKEditor installation into your composer routine for automated management. This script clears the cache, installs CKEditor, and then installs assets.
```json
{
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"ckeditor:install --clear=drop": "symfony-cmd",
"assets:install --symlink --relative %PUBLIC_DIR%": "symfony-cmd"
},
"post-install-cmd": [
"@auto-scripts"
],
"post-update-cmd": [
"@auto-scripts"
]
}
}
```
--------------------------------
### Install CKEditor4 as Node Module (Yarn)
Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/installation.rst
Install CKEditor4 as a node module dependency using Yarn.
```bash
# if you are using Yarn as package manager
$ yarn add ckeditor4@^4.13.0
```
--------------------------------
### Install a Specific CKEditor Release Type
Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/usage/ckeditor.rst
Choose between 'full', 'standard', or 'basic' CKEditor releases for download.
```bash
$ php bin/console ckeditor:install --release=basic
```
--------------------------------
### Install CKEditor to a Custom Path
Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/usage/ckeditor.rst
Specify a custom absolute path for CKEditor installation if the default bundle directory is not desired.
```bash
$ php bin/console ckeditor:install /var/www/html/web/ckeditor
```
--------------------------------
### Example JSON construction
Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/usage/json-builder.rst
Demonstrates building JSON with custom encode options and mixed value setting, followed by resetting and building another JSON structure.
```php
use FOS\CKEditorBundle\Builder\JsonBuilder;
$builder = new JsonBuilder();
// {"0":"foo","1":bar}
echo $builder
->setJsonEncodeOptions(JSON_FORCE_OBJECT)
->setValues(['foo'])
->setValue('[1]', 'bar', false)
->build();
// {"foo":["bar"],"baz":bat}
echo $builder
->reset()
->setValues(['foo' => ['bar']])
->setValue('[baz]', 'bat', false)
->build();
```
--------------------------------
### Install Assets (Symfony >= 3.0, no Flex)
Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/installation.rst
Install CKEditor assets into the web directory for Symfony versions 3.0 and above, when not using Symfony Flex.
```bash
$ php bin/console assets:install web
```
--------------------------------
### Install a Custom CKEditor Build
Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/usage/ckeditor.rst
Use a custom build generated from the CKEditor online builder by providing its build ID.
```bash
$ php bin/console ckeditor:install --release=custom --custom-build-id=574a82a0d3e9226d94b0e91d10eaa372
```
--------------------------------
### Install a Specific CKEditor Version
Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/usage/ckeditor.rst
Download a specific version of CKEditor by providing a version tag.
```bash
$ php bin/console ckeditor:install --tag=4.6.0
```
--------------------------------
### Regenerate Symfony Assets
Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/migration.rst
Run the Symfony assets install command to regenerate assets after installing CKEditor.
```bash
bin/console assets:install
```
--------------------------------
### Install CKEditor via Console (Symfony >= 3.0)
Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/installation.rst
Use this command to install CKEditor assets for Symfony versions 3.0 and above.
```bash
$ php bin/console ckeditor:install
```
--------------------------------
### Install CKEditor4 as Node Module (NPM)
Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/installation.rst
Install CKEditor4 as a node module dependency using NPM.
```bash
# if you are using NPM as package manager
$ npm install --save ckeditor4@^4.13.0
```
--------------------------------
### Install CKEditor via Console (Symfony <= 2.8)
Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/installation.rst
Use this command to install CKEditor assets for Symfony versions 2.8 and below.
```bash
$ php app/console ckeditor:install
```
--------------------------------
### Install CKEditor without Progress Bars
Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/usage/ckeditor.rst
Hide the progress bar during the download and installation process.
```bash
$ php bin/console ckeditor:install --no-progress-bar
```
--------------------------------
### Manage Previous CKEditor Installations
Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/usage/ckeditor.rst
Control how the command handles existing CKEditor installations when running in non-interactive mode. Options include 'drop', 'keep', and 'skip'.
```bash
$ php bin/console ckeditor:install --clear=drop
```
```bash
$ php bin/console ckeditor:install --clear=keep
```
```bash
$ php bin/console ckeditor:install --clear=skip
```
--------------------------------
### Install CKEditor via npm
Source: https://context7.com/friendsofsymfony/fosckeditorbundle/llms.txt
Install CKEditor 4 as a project dependency using npm or Yarn. This is the first step for Webpack Encore integration.
```bash
npm install --save ckeditor4@^4.13.0
# or with Yarn
yarn add ckeditor4@^4.13.0
```
--------------------------------
### Instantiate JsonBuilder
Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/usage/json-builder.rst
Create a new instance of the JsonBuilder to start constructing JSON.
```php
use FOS\CKEditorBundle\Builder\JsonBuilder;
$builder = new JsonBuilder();
```
--------------------------------
### Configure Custom CKEditor Skin
Source: https://context7.com/friendsofsymfony/fosckeditorbundle/llms.txt
Apply custom CKEditor skins by installing them in the web directory and referencing their name and path in the configuration.
```yaml
# config/packages/fos_ck_editor.yaml
fos_ck_editor:
default_config: my_config
configs:
my_config:
skin: "moono-lisa,/bundles/mybundle/ckeditor/skins/moono-lisa/"
```
--------------------------------
### Configure HTTP/HTTPS Proxy for CKEditor Installation
Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/usage/ckeditor.rst
Set environment variables for HTTP and HTTPS proxies if you are behind a proxy server. You can also specify if the request URI should be full.
```bash
$ export HTTP_PROXY=http://127.0.0.1:8080
```
```bash
$ export HTTPS_PROXY=http://127.0.0.1:8080
```
```bash
$ export HTTP_PROXY_REQUEST_FULLURI=true
```
```bash
$ export HTTPS_PROXY_REQUEST_FULLURI=true
```
--------------------------------
### Register and Configure CKEditor Plugins Globally
Source: https://context7.com/friendsofsymfony/fosckeditorbundle/llms.txt
Enable and configure CKEditor plugins globally via the bundle's configuration. Ensure plugins are installed in the web directory or a bundle's public resources.
```yaml
# config/packages/fos_ck_editor.yaml
fos_ck_editor:
default_config: my_config
configs:
my_config:
extraPlugins: "wordcount,notification"
plugins:
wordcount:
path: "/bundles/mybundle/ckeditor/plugins/wordcount/"
filename: "plugin.js"
notification:
path: "/bundles/mybundle/ckeditor/plugins/notification/"
filename: "plugin.js"
```
--------------------------------
### Install FOSCKEditorBundle using Composer
Source: https://context7.com/friendsofsymfony/fosckeditorbundle/llms.txt
Use Composer to add the FOSCKEditorBundle to your Symfony project dependencies.
```bash
composer require friendsofsymfony/ckeditor-bundle
```
--------------------------------
### Register Custom CKEditor Path in Configuration
Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/usage/version.rst
Define the base and JavaScript paths for your custom CKEditor installation in the application's configuration file. Ensure paths are relative to the public directory.
```yaml
# app/config/config.yml
fos_ck_editor:
base_path: "ckeditor"
js_path: "ckeditor/ckeditor.js"
```
--------------------------------
### Configure RequireJS Paths and Shims
Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/usage/require-js.rst
Configure RequireJS to locate CKEditor and define its dependencies and export. This setup is necessary for RequireJS to correctly load CKEditor.
```javascript
{
paths: {
'ckeditor': '{{ asset("bundles/fosckeditor/ckeditor") }}'
},
shim: {
'ckeditor': {
deps: ['jQuery'],
exports: 'CKEDITOR'
}
}
}
```
--------------------------------
### Configure Webpack Encore to Copy CKEditor Files
Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/installation.rst
Configure Webpack Encore to copy CKEditor files from node_modules to the build directory. This example excludes the samples directory.
```javascript
// webpack.config.js
var Encore = require('@symfony/webpack-encore');
Encore
// ...
.copyFiles([
{from: './node_modules/ckeditor4/', to: 'ckeditor/[path][name].[ext]', pattern: /\.(js|css)$/, includeSubdirectories: false},
{from: './node_modules/ckeditor4/adapters', to: 'ckeditor/adapters/[path][name].[ext]'},
{from: './node_modules/ckeditor4/lang', to: 'ckeditor/lang/[path][name].[ext]'},
{from: './node_modules/ckeditor4/plugins', to: 'ckeditor/plugins/[path][name].[ext]'},
{from: './node_modules/ckeditor4/skins', to: 'ckeditor/skins/[path][name].[ext]'},
{from: './node_modules/ckeditor4/vendor', to: 'ckeditor/vendor/[path][name].[ext]'}
])
// Uncomment the following line if you are using Webpack Encore <= 0.24
// .addLoader({test: /\.json$/i, include: [require('path').resolve(__dirname, 'node_modules/ckeditor')], loader: 'raw-loader', type: 'javascript/auto'})
;
```
--------------------------------
### Reset the builder
Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/usage/json-builder.rst
Use the reset method to clear the builder's state and start a new JSON construction.
```php
$builder->reset();
```
--------------------------------
### Customize CKEditor Configuration in Symfony Form
Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/index.rst
Example of customizing CKEditor configuration within a Symfony form type. This snippet shows how to set specific UI colors and other CKEditor options.
```php
use FOS\CKEditorBundle\Form\Type\CKEditorType;
$builder->add('field', CKEditorType::class, [
'config' => [
'uiColor' => '#ffffff',
//...
],
]);
```
--------------------------------
### Run Webpack Encore Build (NPM)
Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/installation.rst
Execute the Webpack Encore build command using NPM.
```bash
# if you are using NPM as package manager
$ npm run dev
```
--------------------------------
### Configure Content Templates Globally
Source: https://context7.com/friendsofsymfony/fosckeditorbundle/llms.txt
Set up content templates that users can insert into the editor. This involves defining template paths and structures in the bundle's configuration.
```yaml
# config/packages/fos_ck_editor.yaml
fos_ck_editor:
default_config: my_config
configs:
my_config:
extraPlugins: "templates"
templates: "my_templates"
templates:
my_templates:
imagesPath: "/bundles/mybundle/templates/images"
templates:
- title: "Image with Caption"
image: "template1.jpg"
description: "An image with a text caption"
html: "
Crazy template :)
" ``` -------------------------------- ### Override PHP Template for CKEditor Widget Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/usage/append-javascript.rst Override the default PHP template to append custom JavaScript. This example prevents CKEditor from removing empty spans. ```php extend('FOSCKEditorBundle:Form:ckeditor_widget.html.php') ?> start('ckeditor_widget_extra') ?> CKEDITOR.dtd.$removeEmpty['span'] = false; stop() ?> ``` -------------------------------- ### Override Twig Template for CKEditor Widget Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/usage/append-javascript.rst Override the default Twig template to append custom JavaScript. This example configures CKEditor to not remove empty spans. ```twig {# app/Resources/views/Form/ckeditor_widget.html.twig #} {% extends '@FOSCKEditor/Form/ckeditor_widget.html.twig' %} {% block ckeditor_widget_extra %} CKEDITOR.dtd.$removeEmpty['span'] = false; {% endblock %} ``` -------------------------------- ### Define Custom CKEditor Configurations and Toolbars Source: https://context7.com/friendsofsymfony/fosckeditorbundle/llms.txt Configure custom CKEditor instances with specific toolbars and UI colors in the bundle's configuration file. Toolbars can be defined with specific item groups. ```yaml fos_ck_editor: configs: my_config_1: toolbar: "my_toolbar_1" uiColor: "#000000" my_config_2: toolbar: "my_toolbar_2" uiColor: "#ffffff" toolbars: configs: my_toolbar_1: ["@document", "/", "@link", "/", "@tool"] my_toolbar_2: ["@document", "/", "@tool"] items: document: ["Source", "-", "Save", "Preview", "Print"] link: ["Anchor", "Link", "Unlink"] tool: ["Maximize", "ShowBlocks"] ``` -------------------------------- ### Update Bundle Definition (config/bundles.php) Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/migration.rst Replace the IvoryCKEditorBundle class with FOSCKEditorBundle in the `config/bundles.php` file. ```php ['all' => true], ]; ``` ```php ['all' => true], ]; ``` -------------------------------- ### Register FOSCKEditorBundle in config/bundles.php (Symfony >= 4.0) Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/installation.rst Register the bundle in your bundles.php file if not using Flex or choosing to skip the recipe. ```php return [ // ... FOS\CKEditorBundle\FOSCKEditorBundle::class => ['all' => true], ]; ``` -------------------------------- ### Enable Templates Plugin Globally Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/usage/template.rst Enable the 'templates' plugin by adding it to 'extraPlugins' in your global configuration. ```yaml # app/config/config.yml fos_ck_editor: default_config: my_config configs: my_config: extraPlugins: "templates" ``` -------------------------------- ### Update Configuration (config/packages/ivory_ck_editor.yaml) Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/migration.rst Change the root configuration key from `ivory_ck_editor` to `fos_ck_editor` in the YAML configuration file. ```yaml # config/packages/ivory_ck_editor.yaml ivory_ck_editor: configs: my_config: toolbar: [ ["Source", "-", "Save"], "/", ["Anchor"], "/", ["Maximize"] ] uiColor: "#000000" filebrowserUploadRoute: "my_route" extraPlugins: "wordcount" # ... ``` ```yaml # config/packages/fos_ck_editor.yaml fos_ck_editor: configs: my_config: toolbar: [ ["Source", "-", "Save"], "/", ["Anchor"], "/", ["Maximize"] ] uiColor: "#000000" filebrowserUploadRoute: "my_route" extraPlugins: "wordcount" # ... ``` -------------------------------- ### Configure Static Filebrowser Route Globally Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/usage/file-browse-upload.rst Set static routing options for file browsing globally in the configuration. This defines a fixed route and parameters for file browser requests. ```yaml # app/config/config.yml fos_ck_editor: default_config: my_config configs: my_config: filebrowserBrowseRoute: "my_route" filebrowserBrowseRouteParameters: { slug: "my-slug" } filebrowserBrowseRouteType: 0 ``` -------------------------------- ### Enable RequireJS Support Source: https://context7.com/friendsofsymfony/fosckeditorbundle/llms.txt Enable RequireJS support for applications using AMD module loading, wrapping CKEditor instantiation in a require block. ```yaml # config/packages/fos_ck_editor.yaml fos_ck_editor: require_js: true ``` -------------------------------- ### Configure Default CKEditor Settings Source: https://context7.com/friendsofsymfony/fosckeditorbundle/llms.txt Set the default CKEditor configuration and define custom configurations for file browsing and uploading routes. ```yaml fos_ck_editor: default_config: my_config configs: my_config: filebrowserBrowseRoute: "app_file_browser" filebrowserBrowseRouteParameters: { type: "files" } filebrowserUploadRoute: "app_file_upload" filebrowserUploadRouteParameters: { type: "files" } filebrowserImageBrowseRoute: "app_image_browser" filebrowserImageUploadRoute: "app_image_upload" ``` -------------------------------- ### Implement Dynamic Filebrowser Handler with Closure Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/usage/file-browse-upload.rst Use a closure for the filebrowserHandler option to dynamically generate URLs. This provides flexibility by allowing access to dependencies like the router and entity objects. ```php // A blog post... $post = $manager->find($id); $builder->add('field', 'ckeditor', [ 'config' => [ 'filebrowserBrowseHandler' => function (RouterInterface $router) use ($post) { return $router->generate( 'my_route', ['slug' => $post->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL ); }, ], ]); ``` -------------------------------- ### Configure RequireJS for CKEditor Source: https://context7.com/friendsofsymfony/fosckeditorbundle/llms.txt Configure RequireJS paths and shims to properly load CKEditor and its dependencies. ```javascript // RequireJS configuration require.config({ paths: { 'ckeditor': '/bundles/fosckeditor/ckeditor' }, shim: { 'ckeditor': { deps: ['jquery'], exports: 'CKEDITOR' } } }); ``` -------------------------------- ### Configure Custom Filebrowser Options Globally Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/usage/file-browse-upload.rst Add custom filebrowser options to be recognized by the bundle globally. This is useful for integrating plugins that introduce new file handling capabilities. ```yaml # app/config/config.yml fos_ck_editor: filebrowsers: - VideoBrowse - VideoUpload ``` -------------------------------- ### Update Configuration (app/config/config.yml) Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/migration.rst If not using Symfony Flex, update the root configuration key in `app/config/config.yml` from `ivory_ck_editor` to `fos_ck_editor`. ```yaml # app/config/config.yml ivory_ck_editor: configs: my_config: toolbar: [ ["Source", "-", "Save"], "/", ["Anchor"], "/", ["Maximize"] ] uiColor: "#000000" filebrowserUploadRoute: "my_route" extraPlugins: "wordcount" # ... ``` ```yaml # app/config/config.yml fos_ck_editor: configs: my_config: toolbar: [ ["Source", "-", "Save"], "/", ["Anchor"], "/", ["Maximize"] ] uiColor: "#000000" filebrowserUploadRoute: "my_route" extraPlugins: "wordcount" # ... ``` -------------------------------- ### Register Skin Globally in Configuration Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/usage/skin.rst Register a custom skin globally by specifying its name and path in the FOSCKEditorBundle configuration file. The skin path must be an absolute path relative to the web directory. ```yaml fos_ck_editor: default_config: my_config configs: my_config: skin: "skin_name,/bundles/mybundle/skins/skin_name/" ``` -------------------------------- ### Define Custom Toolbars Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/usage/toolbar.rst Define custom toolbars named 'my_toolbar_1' and 'my_toolbar_2' in the bundle's configuration. Each toolbar is an array of strips, separated by '/'. ```yaml # config/packages/fos_ck_editor.yaml fos_ck_editor: configs: my_config_1: toolbar: "my_toolbar_1" uiColor: "#000000" # ... my_config_2: toolbar: "my_toolbar_2" uiColor: "#ffffff" # ... my_config_2: toolbar: "my_toolbar_1" uiColor: "#cccccc" toolbars: configs: my_toolbar_1: [ [ "Source", "-", "Save" ], "/", [ "Anchor" ], "/", [ "Maximize" ] ] my_toolbar_2: [ [ "Source" ], "/", [ "Anchor" ], "/", [ "Maximize" ] ] ``` -------------------------------- ### Update Bundle Definition (AppKernel.php) Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/migration.rst If not using Symfony Flex, update the bundle registration in `app/AppKernel.php` to use FOSCKEditorBundle. ```php build(); ``` -------------------------------- ### Configure Asynchronous Loading Source: https://context7.com/friendsofsymfony/fosckeditorbundle/llms.txt Configure CKEditor to load asynchronously at the bottom of the page for better performance, using IvoryFormExtraBundle. Set autoload to false and async to true. ```yaml # config/packages/fos_ck_editor.yaml fos_ck_editor: autoload: false async: true ``` -------------------------------- ### Configure Global Toolbar Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/usage/toolbar.rst Set the global toolbar configuration to 'full' in your Symfony application's configuration file. ```yaml # config/packages/fos_ck_editor.yaml fos_ck_editor: configs: my_config: toolbar: full ``` -------------------------------- ### Configure Templates in the Widget Source: https://context7.com/friendsofsymfony/fosckeditorbundle/llms.txt Define content templates directly within the form widget using PHP, specifying template details like title, image, description, and HTML structure. ```php $builder->add('content', CKEditorType::class, [ 'config' => [ 'extraPlugins' => 'templates', 'templates' => 'my_template', ], 'templates' => [ 'my_template' => [ 'imagesPath' => '/bundles/mybundle/templates/images', 'templates' => [ [ 'title' => 'My Template', 'image' => 'template.jpg', 'description' => 'My awesome template', 'html' => 'Template content
Crazy template :)
', ], // ... ], ], ], ]); ``` -------------------------------- ### Override Parts of a Defined CKEditor Configuration Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/usage/config.rst When using a defined configuration ('my_config'), you can selectively override specific options, such as 'uiColor', using the 'config' option. This allows for minor adjustments without redefining the entire configuration. ```php $builder->add('field', 'ckeditor', [ 'config_name' => 'my_config', 'config' => ['uiColor' => '#ffffff'], ]); ``` -------------------------------- ### Configure Widget Toolbar Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/usage/toolbar.rst Set the toolbar configuration for a specific CKEditor widget directly within the form builder. ```php $builder->add('field', 'ckeditor', [ 'config' => ['toolbar' => 'full'], ]); ``` -------------------------------- ### Configure Webpack Encore for CKEditor Assets Source: https://context7.com/friendsofsymfony/fosckeditorbundle/llms.txt Configure Webpack Encore to copy CKEditor 4 files from `node_modules` to the appropriate build directory for asset management. ```javascript var Encore = require('@symfony/webpack-encore'); Encore .copyFiles([ {from: './node_modules/ckeditor4/', to: 'build/ckeditor/[path][name].[ext]', pattern: /\.(js|css)$/, includeSubdirectories: false}, {from: './node_modules/ckeditor4/adapters', to: 'build/ckeditor/adapters/[path][name].[ext]'}, {from: './node_modules/ckeditor4/lang', to: 'build/ckeditor/lang/[path][name].[ext]'}, {from: './node_modules/ckeditor4/plugins', to: 'build/ckeditor/plugins/[path][name].[ext]'}, {from: './node_modules/ckeditor4/skins', to: 'build/ckeditor/skins/[path][name].[ext]'}, {from: './node_modules/ckeditor4/vendor', to: 'build/ckeditor/vendor/[path][name].[ext]'} ]); ``` -------------------------------- ### Enable RequireJS Per Widget Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/usage/require-js.rst Enable RequireJS support for a specific CKEditor widget by passing the 'require_js' option set to true during its creation. ```php $builder->add('field', 'ckeditor', ['require_js' => true]); ``` -------------------------------- ### Enable Global Input Synchronization Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/usage/textarea-sync.rst To synchronize textarea values globally, set 'input_sync' to true in your app/config/config.yml. This ensures all CKEditor instances update their associated textareas. ```yaml # app/config/config.yml fos_ck_editor: input_sync: true ``` -------------------------------- ### Configure Twig Form Themes Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/installation.rst Add the CKEditor Twig form theme to your configuration to enable the widget. This is not required if using Symfony Flex with the recipe. ```yaml # Symfony 2/3: app/config/config.yml # Symfony 4: config/packages/twig.yaml twig: form_themes: - '@FOSCKEditor/Form/ckeditor_widget.html.twig' ``` -------------------------------- ### Configure CKEditor Default Language Source: https://context7.com/friendsofsymfony/fosckeditorbundle/llms.txt Set the default language for CKEditor instances. This configuration is applied globally unless overridden. ```yaml fos_ck_editor: configs: my_config: language: fr ``` -------------------------------- ### Configure CKEditor Skin in Form Widget Source: https://context7.com/friendsofsymfony/fosckeditorbundle/llms.txt Configure the CKEditor skin directly within a form widget, specifying the skin name and its path. ```php $builder->add('content', CKEditorType::class, [ 'config' => [ 'skin' => 'moono-lisa,/bundles/mybundle/ckeditor/skins/moono-lisa/', ], ]); ``` -------------------------------- ### Enable Widget-Specific Input Synchronization Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/usage/textarea-sync.rst Alternatively, enable input synchronization for a specific CKEditor widget by setting 'input_sync' to true during its definition in a form builder. ```php $builder->add('field', 'ckeditor', ['input_sync' => true]); ``` -------------------------------- ### Append a set of values Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/usage/json-builder.rst Use setValues to append multiple values to the builder. Values are appended without escaping control by default. ```php $builder->setValues(['foo' => ['bar']]); ``` ```php $builder->setValues(['bar'], '[foo]'); ``` -------------------------------- ### Use a Defined CKEditor Configuration in a Form Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/usage/config.rst Apply a previously defined reusable configuration ('my_config') to a CKEditor form field using the 'config_name' option. This avoids duplicating configuration settings across multiple form builders. ```php $builder->add('field', 'ckeditor', [ 'config_name' => 'my_config', ]); ``` -------------------------------- ### Define Custom Styles Globally Source: https://context7.com/friendsofsymfony/fosckeditorbundle/llms.txt Define custom styles that will appear in the CKEditor Styles dropdown menu. These are configured in the bundle's YAML settings. ```yaml # config/packages/fos_ck_editor.yaml fos_ck_editor: default_config: my_config configs: my_config: stylesSet: "my_styles" styles: my_styles: - { name: "Blue Title", element: "h2", styles: { color: "Blue" } } - { name: "CSS Style", element: "span", attributes: { class: "my_style" } } - { name: "Widget Style", type: "widget", widget: "my_widget", attributes: { class: "my_widget_style" } } ``` -------------------------------- ### Exclude Paths During CKEditor Extraction Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/usage/ckeditor.rst Prevent specific directories like 'samples' or 'adapters' from being extracted from the downloaded CKEditor ZIP archive. ```bash $ php bin/console ckeditor:install --exclude=samples --exclude=adapters ``` -------------------------------- ### Override Built-in Toolbar Items Source: https://github.com/friendsofsymfony/fosckeditorbundle/blob/2.x/docs/usage/toolbar.rst Override specific items within built-in toolbar configurations, such as 'full.colors' or 'full.document', to customize them without redefining the entire toolbar. ```yaml fos_ck_editor: configs: my_config: toolbar: "full" toolbars: items: full.colors: [ "TextColor", "BGColor" ] full.document: [ "Source", "-", "Preview", "Print" ] ```