Details
-
Bug
-
Resolution: Fixed
-
High
-
4.4.1
-
None
-
Yes
Description
I have a content with custom tag named "keydata" that doesn't have any attributes and it is not causing any issues in Ibexa 3. Here's the XML part of that custom tag from my database:
<eztemplate name="keydata"> <ezcontent> <eztemplate name="keydata_item"> <ezcontent> <title ezxhtml:level="3">250</title> <para>COLLABORATEURS</para> </ezcontent> </eztemplate> <eztemplate name="keydata_item"> <ezcontent> <title ezxhtml:level="3">3500</title> <para>CLIENTS DANS LA REGION </para> </ezcontent> </eztemplate> <eztemplate name="keydata_item"> <ezcontent> <title ezxhtml:level="3">8</title> <para>BUREAUX DANS LA RÉGION</para> </ezcontent> </eztemplate> </ezcontent> </eztemplate>
After migrating to Ibexa 4 it causes an error and the richtext editor is just empty
I've compared the js files between Ibexa 3 and Ibexa 4 and here's what I found:
In Ibexa 3 there was a loop that checked every child element if it's an ezconfig element (https://github.com/ezsystems/ezplatform-richtext/blob/2.3/src/bundle/Resources/public/js/OnlineEditor/plugins/base/ez-custom-tag-base.js#L441):
getEzConfigElement: function() { let config = [...this.element.getChildren().$].find((child) => child.dataset && child.dataset.ezelement === 'ezconfig'); if (!config) { config = new CKEDITOR.dom.element('span'); config.data('ezelement', 'ezconfig'); this.element.append(config); } else { config = new CKEDITOR.dom.element(config); } return config; },
if there was nothing found, the ezconfig element was created.
In Ibexa 4 I haven't found anything like that, there's just a simple getChild(1) call, so it assumes that the ezconfig element is always present. It doesn't even check if the element that was found is the one that it expected to find. (https://github.com/ibexa/fieldtype-richtext/blob/main/src/bundle/Resources/public/js/CKEditor/custom-tags/block-custom-tag/custom-tag-editing.js#L113-L114)
const configElement = viewElement.getChild(1); const configValuesIterator = configElement.getChildren();
The error happens when getChildren() is called on configElement, because configElement is undefined due to the lack of ezconfig element.
Because of that we can't edit the migrated content that contains custom tags with no attributes.