From 3394bc36d840836bdd4d72e7b1333c04a1f45eb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kali=C5=84ski?= Date: Wed, 21 Aug 2024 12:09:08 +0200 Subject: [PATCH 1/2] OP-437 - CKEditor correctly displaying --- .../js/bitbag/bitbag-content-configuration.js | 31 ++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/src/Resources/assets/admin/js/bitbag/bitbag-content-configuration.js b/src/Resources/assets/admin/js/bitbag/bitbag-content-configuration.js index b221f2ca..c953eff4 100644 --- a/src/Resources/assets/admin/js/bitbag/bitbag-content-configuration.js +++ b/src/Resources/assets/admin/js/bitbag/bitbag-content-configuration.js @@ -11,9 +11,10 @@ $(document).ready(function() { let pageElements = '#bitbag_sylius_cms_plugin_page_contentElements'; let blockElements = '#bitbag_sylius_cms_plugin_block_contentElements'; - let collectionHolder = $(pageElements).length ? pageElements : blockElements; + let itemElement = document.querySelector(`${collectionHolder} [data-form-collection="item"]`); + if (!$(collectionHolder).length) { return; } @@ -69,6 +70,28 @@ $(document).ready(function() { $(newConfig).find('.bitbag-media-autocomplete').autoComplete(); $(newConfig).find('.sylius-autocomplete').autoComplete(); }); + + if (this.value === 'textarea') { + CKEDITOR.replace("configuration_textarea", { + "toolbar":[ + ["Cut","Copy","Paste","PasteText","PasteFromWord","-","Undo","Redo"], + ["Scayt"],["Link","Unlink","Anchor"], + ["Image","MediaVideo","MediaImage","Table","HorizontalRule","SpecialChar"], + ["Maximize"],["Source"],"\/",["Bold","Italic","Strike","-","RemoveFormat"], + ["NumberedList","BulletedList","-","Outdent","Indent","-","Blockquote"], + ["Styles","Format","About"]], + "enterMode":3, + "forcePasteAsPlainText":"allow-word", + "allowedContent":true, + "extraPlugins":[ + "mediaVideo","mediaImage" + ], + "removePlugins":[ + "exportpdf" + ], + "filebrowserUploadUrl":"\/admin\/editor\/upload-image","bodyId":"bitbag-ckeditor","language":"en-us" + }); + } } } }); @@ -77,7 +100,7 @@ $(document).ready(function() { $(document).loadContentConfiguration(element); }); - $(document).loadContentConfiguration( - document.querySelector(`${collectionHolder} [data-form-collection="item"]`) - ); + if (itemElement) { + $(document).loadContentConfiguration(itemElement); + } }); From cd46957626c25f3a8eff472d94a2e209cbf0867e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kali=C5=84ski?= Date: Thu, 22 Aug 2024 11:12:28 +0200 Subject: [PATCH 2/2] OP-437 - CKEditor correction of an error for more than one textarea --- .../js/bitbag/bitbag-content-configuration.js | 50 +++++++++++-------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/src/Resources/assets/admin/js/bitbag/bitbag-content-configuration.js b/src/Resources/assets/admin/js/bitbag/bitbag-content-configuration.js index c953eff4..4e573901 100644 --- a/src/Resources/assets/admin/js/bitbag/bitbag-content-configuration.js +++ b/src/Resources/assets/admin/js/bitbag/bitbag-content-configuration.js @@ -9,6 +9,26 @@ $(document).ready(function() { $(element).autoComplete(); }); + const ckeditorConfig = { + toolbar: [ + ["Cut", "Copy", "Paste", "PasteText", "PasteFromWord", "-", "Undo", "Redo"], + ["Scayt"], ["Link", "Unlink", "Anchor"], + ["Image", "MediaVideo", "MediaImage", "Table", "HorizontalRule", "SpecialChar"], + ["Maximize"], ["Source"], "/", + ["Bold", "Italic", "Strike", "-", "RemoveFormat"], + ["NumberedList", "BulletedList", "-", "Outdent", "Indent", "-", "Blockquote"], + ["Styles", "Format", "About"] + ], + enterMode: 3, + forcePasteAsPlainText: "allow-word", + allowedContent: true, + extraPlugins: ["mediaVideo", "mediaImage"], + removePlugins: ["exportpdf"], + filebrowserUploadUrl: "/admin/editor/upload-image", + bodyId: "bitbag-ckeditor", + language: "en-us" + }; + let pageElements = '#bitbag_sylius_cms_plugin_page_contentElements'; let blockElements = '#bitbag_sylius_cms_plugin_block_contentElements'; let collectionHolder = $(pageElements).length ? pageElements : blockElements; @@ -69,29 +89,15 @@ $(document).ready(function() { $(element).attr('name', newConfigInputName); $(newConfig).find('.bitbag-media-autocomplete').autoComplete(); $(newConfig).find('.sylius-autocomplete').autoComplete(); - }); - if (this.value === 'textarea') { - CKEDITOR.replace("configuration_textarea", { - "toolbar":[ - ["Cut","Copy","Paste","PasteText","PasteFromWord","-","Undo","Redo"], - ["Scayt"],["Link","Unlink","Anchor"], - ["Image","MediaVideo","MediaImage","Table","HorizontalRule","SpecialChar"], - ["Maximize"],["Source"],"\/",["Bold","Italic","Strike","-","RemoveFormat"], - ["NumberedList","BulletedList","-","Outdent","Indent","-","Blockquote"], - ["Styles","Format","About"]], - "enterMode":3, - "forcePasteAsPlainText":"allow-word", - "allowedContent":true, - "extraPlugins":[ - "mediaVideo","mediaImage" - ], - "removePlugins":[ - "exportpdf" - ], - "filebrowserUploadUrl":"\/admin\/editor\/upload-image","bodyId":"bitbag-ckeditor","language":"en-us" - }); - } + if (this.value === 'textarea') { + const index = target.getAttribute('data-form-collection-index'); + const textareaId = `${collectionHolder}_${index}_configuration_textarea`; + + element.id = textareaId; + CKEDITOR.replace(textareaId, ckeditorConfig); + } + }); } } });