RichText parser destroys HTML structure and triggers TypeError on Toolbar Actions

Description

When loading standard HTML content containing block-level elements (like <div>) into the DHX RichText editor, the internal parser completely flattens and alters the DOM structure by converting blocks into a chain of inline <span> elements. This structural loss breaks the core editing layout. Furthermore, performing formatting actions (such as applying a blockquote) on these flattened elements triggers a critical JavaScript runtime error.

Data Flow Analysis

1. Input HTML (Loaded via setValue())

<div><b>Casque jet Vespa Modernist</b></div>
<div>
    <ul>
        <li>Casque jet en matériau ABS...</li>
    </ul>
</div>

2. Internal DOM Structure (After DHX Parsing)

The editor removes the original <div> block containers and converts the content into this inline structure:

<span data-id="37" style="font-weight:bold;">Casque jet Vespa Modernist</span><span data-id="38"> </span><ul data-id="39"><li data-id="40"><span data-id="41">Casque jet en matériau ABS...</span></li></ul><span data-id="44"> </span>

3. Output HTML (Retrieved via getValue())

The original block hierarchy is entirely lost. The editor outputs the flattened structure instead of preserving the input layout:

<span data-id="37" style="font-weight:bold;">Casque jet Vespa Modernist</span><span data-id="38"> </span><ul data-id="39"><li data-id="40"><span data-id="41">Casque jet en matériau ABS...</span></li></ul><span data-id="44"> </span>

Steps to Reproduce

  1. Load the provided Input HTML into the DHX RichText editor.

  2. Focus the cursor inside the first parsed line: <span data-id="37" style="font-weight:bold;">Casque jet Vespa Modernist</span>.

  3. Click the “Quote” action button in the toolbar.

Actual Behavior

The editor crashes instantly because it fails to process the inline element where a block element is expected. The browser console throws the following error:
Uncaught (in promise) TypeError: can't access property "type", c is undefined

Expected Behavior

The general block structure (including <div> elements) must be preserved during parsing, in line with industry standards (e.g., CKEditor). Toolbar actions like “Quote” should execute safely without breaking editor functionality or throwing runtime exceptions.

Hello @Czeslaw,

Thank you for the very detailed description of the issue. I already sent it to the dev team, and they will consider the best approach to fix it. I will notify you of any updates.

Here is a complete list of currently supported HTML tags:

Block: p, h1, h2, h3, h4, h5, h6, blockquote, ul, ol, li

Inline / formatting: b, strong, i, em, u, s, strike, a, sub, sup

Content / other: img, hr, br

Warm regards,

1 Like

Hello Czeslaw,

The dev team already fixed the issue with div inside the passed content in the latest release:

You can try it in the following demo:

Warm regards,