Closed bastien70 closed 1 year ago
Hi there!
Here's my first guess at the problem :) - look at the bottom of this section - https://symfony.com/bundles/ux-live-component/current/index.html#working-with-the-component-in-javascript
Basically, when you type into CKEditor, behind the scenes, it probably sets the value on the real (hidden) textarea behind the scenes (and then when your form submits, everything is happy!). But, when CKEditor does this, my guess is that it simply does yourField.value = thenewValue
. This, unfortunately, does not fire the input
JS event like normally typing into a box would. And so, you need to do extra work so that LiveComponents is aware of this change. You'll likely need to write a little extra JS for this.
Let me know if that helps :)
Cheers!
Hello !
Okay thank you, we will see that! :)
Please let me know if this solves the problem :)
Hello @weaverryan , currently, we updated our assets/app.js file by adding this :
CKEDITOR.on('instanceReady', function (ev) {
ev.editor.on('blur', function (ev) {
console.log('blur event fired');
const el = ev.editor.element;
const textarea = document.getElementById(el.$.id);
textarea.innerHTML = ev.editor.getData();
textarea.dispatchEvent(new Event('change', { bubbles: true }));
ev.editor.updateElement();
});
});
It works ! :D
Yup! That's really annoying to need that, but that's the idea! Having a UX component for CKEditor, where we do something like this FOR you, would be awesome. Thanks for reporting back!
Hello,
In a project, we have a step form, with several tabs.
On one of the tabs we have a wysiwyg field. We opted for CKEditor 4.
We are using LiveComponent, so if we go to a field, modify its value, then leave that field, the ajax request should start.
It works fine with all other fields except wysiwyg.
Here is a very minimalist small reproducer of the code set up :
The FormType :
The LiveComponent :
And our template for the step :
And here is a demonstration video. In this one there are more fields than I put in the example above, it was to avoid putting useless info.
But if you watch the video carefully, if I update my URL type fields, the AJAX request is launched. If I update the CKEditor field, no Ajax request.
If I change tabs and come back to the one I was on, my URL type field has been updated, not CKEditor's.
Obviously I'm talking about CKEditor here, but it's exactly the same with the basic wysiwyg provided by EasyAdmin
https://user-images.githubusercontent.com/53140475/207026317-bee58dd6-b491-47c8-abd9-a6b1826383fe.mp4