monsieurbiz / SyliusRichEditorPlugin

This plugin add a rich editor on fields to be able to drag and drop elements and edit it.
MIT License
65 stars 36 forks source link

Replacing Pell with CKEditor editor #150

Closed gseric closed 2 years ago

gseric commented 2 years ago

Hello,

could you please help with this replacement, I need CKEditor because of general file upload and storage support (mostly PDFs)?

The easy part was extending TextType form type and replacing WysiwygType (Pell) with FOSCKEditorBundle's CKEditorType.

But unfortunately CKEditor doesn't load at all. I debugged it a bit and found that UI element forms are loaded using innerHTML which doesn't execute script tags. CKEditor, on the other hand, consists of a textarea and 3 script tags: some inline JS code, external JS file loading, and some inline JS code again which relies on external JS file from second script tag.

My first attempt was to dynamically re-insert script tags using appendChild but didn't managed to ensure execution order - third script tag (inline code) is executed before the external JS file is loaded.

This could be fixed but I stopped at that point because this solution seems dirty and I wonder if there is any better approach...

gseric commented 2 years ago

Never mind, I managed to do it by discarding FOSCKEditorBundle's generated markup and initializing CKEditor manually.