From 76f7b71361579f6cbc8d9410a0995bbcaca48f22 Mon Sep 17 00:00:00 2001 From: em411 <7682404+em411@users.noreply.github.com> Date: Wed, 18 Aug 2021 13:07:59 +0200 Subject: [PATCH 1/4] Fix ckeditor removing empty tags --- src/Resources/views/Form/ckeditor_widget.html.twig | 5 +++++ tests/Application/config/packages/twig.yaml | 1 + 2 files changed, 6 insertions(+) create mode 100644 src/Resources/views/Form/ckeditor_widget.html.twig diff --git a/src/Resources/views/Form/ckeditor_widget.html.twig b/src/Resources/views/Form/ckeditor_widget.html.twig new file mode 100644 index 000000000..48c9ee6ab --- /dev/null +++ b/src/Resources/views/Form/ckeditor_widget.html.twig @@ -0,0 +1,5 @@ +{% extends 'FOSCKEditorBundle:Form:ckeditor_widget.html.twig' %} + +{% block ckeditor_widget_extra %} + CKEDITOR.dtd.$removeEmpty['i'] = false; +{% endblock %} diff --git a/tests/Application/config/packages/twig.yaml b/tests/Application/config/packages/twig.yaml index 598a8ce1b..0c3e9905c 100644 --- a/tests/Application/config/packages/twig.yaml +++ b/tests/Application/config/packages/twig.yaml @@ -4,6 +4,7 @@ twig: strict_variables: '%kernel.debug%' form_themes: - '@FOSCKEditor/Form/ckeditor_widget.html.twig' + - '@BitBagSyliusCmsPlugin/Form/ckeditor_widget.html.twig' services: _defaults: From 677ed2b41a6a37fe64af8f8b081fdb2afc5acce9 Mon Sep 17 00:00:00 2001 From: em411 <7682404+em411@users.noreply.github.com> Date: Wed, 18 Aug 2021 13:09:18 +0200 Subject: [PATCH 2/4] Update docs with CKEditor configuration --- doc/installation.md | 1 + doc/wysiwyg.md | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/doc/installation.md b/doc/installation.md index 4d9f15925..834098d09 100644 --- a/doc/installation.md +++ b/doc/installation.md @@ -29,6 +29,7 @@ Since FOSCKEditorBundle 2.0, to make Twig render the WYSIWYG editor, you must ad twig: form_themes: - '@FOSCKEditor/Form/ckeditor_widget.html.twig' + - '@BitBagSyliusCmsPlugin/Form/ckeditor_widget.html.twig' ``` Import required config in your `config/packages/_sylius.yaml` file: diff --git a/doc/wysiwyg.md b/doc/wysiwyg.md index 17e325ae4..879500bf4 100644 --- a/doc/wysiwyg.md +++ b/doc/wysiwyg.md @@ -2,7 +2,7 @@ This plugin comes with a default [FOSCKEditorBundle](https://github.com/FriendsOfSymfony/FOSCKEditorBundle) integration. It has also been customized to use image upload feature. Every time you upload an image in the CKEditor, a new image media -is being created. +is being created. ## General usage @@ -12,3 +12,24 @@ Take [the BlockTranslationType](../src/Form/Type/Translation/BlockTranslationTyp **Note:** *In the WYSIWYG fields, you can use Twig function nesting. Read more [here](twig-functions-in-admin.md).* + +## Configuration + +If you want to customize any behavior of the CKEditor, you have to override one of these files: [CKEditor config](../src/Resources/config/fos_ck_editor/fos_ck_editor.yml) or [CKEditor js config](../src/Resources/views/Form/ckeditor_widget.html.twig) + +**Useful links:** +- [CKEditor configuration](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html) +- [CKEditor DTD configuration](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_dtd.html) + + +**Note:** + +Remember to add your js configuration to `config/packages/twig.yaml` file:** +```yaml +# Symfony 2/3: app/config/config.yml +# Symfony 4: config/packages/twig.yaml + +twig: + form_themes: + - 'path to your configuration' +``` From 49c032ed3356906e11eb5bf2d97ba26c69e14952 Mon Sep 17 00:00:00 2001 From: em411 <7682404+em411@users.noreply.github.com> Date: Thu, 19 Aug 2021 09:05:09 +0200 Subject: [PATCH 3/4] Fix typo --- doc/wysiwyg.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/doc/wysiwyg.md b/doc/wysiwyg.md index 879500bf4..c4a47e473 100644 --- a/doc/wysiwyg.md +++ b/doc/wysiwyg.md @@ -10,7 +10,6 @@ You can use a custom [WysiwygType](../src/Form/Type/WysiwygType.php) any place y Take [the BlockTranslationType](../src/Form/Type/Translation/BlockTranslationType.php) as an example. **Note:** - *In the WYSIWYG fields, you can use Twig function nesting. Read more [here](twig-functions-in-admin.md).* ## Configuration @@ -23,7 +22,6 @@ If you want to customize any behavior of the CKEditor, you have to override one **Note:** - Remember to add your js configuration to `config/packages/twig.yaml` file:** ```yaml # Symfony 2/3: app/config/config.yml From 900cfc07e24adf8cbbb49a78e399c037e7bd650b Mon Sep 17 00:00:00 2001 From: em411 <7682404+em411@users.noreply.github.com> Date: Thu, 19 Aug 2021 12:40:36 +0200 Subject: [PATCH 4/4] Fix twig path --- src/Resources/views/Form/ckeditor_widget.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Resources/views/Form/ckeditor_widget.html.twig b/src/Resources/views/Form/ckeditor_widget.html.twig index 48c9ee6ab..8a1b93166 100644 --- a/src/Resources/views/Form/ckeditor_widget.html.twig +++ b/src/Resources/views/Form/ckeditor_widget.html.twig @@ -1,4 +1,4 @@ -{% extends 'FOSCKEditorBundle:Form:ckeditor_widget.html.twig' %} +{% extends "@FOSCKEditor/Form/ckeditor_widget.html.twig" %} {% block ckeditor_widget_extra %} CKEDITOR.dtd.$removeEmpty['i'] = false;