Issue with TinyMCE Automatically Formatting Rich Text

Issue with TinyMCE Automatically Formatting Rich Text

Description

I am using TinyMCE Rich Text Editor (tinymcerte-2.1.0-pl) in MODX 3.1.1. When editing a custom template variable (TV) with TinyMCE, I noticed that it automatically wraps <li> tags inside <ul>, even when I intend to use standalone <li> elements. This unexpected formatting causes display issues on my webpage.

What I Tried

  1. Setting valid_children in TinyMCE Configuration

    • I created a system setting:
      • Key: tinymcerte.valid_children
      • Value: +body[li]
    • However, this did not prevent TinyMCE from wrapping <li> inside <ul>.
  2. Checking tinymcerte.toolbar1 and tinymcerte.valid_elements

    • I tried adding li to valid_elements, but it did not change the behavior.
  3. Modifying tinymcerte.content_css

    • I checked if content styles influenced this behavior but found no effect.

Expected Behavior

I would like to enter raw HTML content in the TinyMCE editor and have it remain unchanged, particularly for <li> tags.

Question

  • How can I configure TinyMCE in MODX to allow standalone <li> elements without automatically wrapping them inside <ul>?
  • Are there other settings I need to adjust to prevent TinyMCE from altering my HTML structure?

Any help would be greatly appreciated!

1 Like

tinymcerte.valid_children is not supported by the system settings of TinyMCE RTE. If you want to add other TinyMCE settings than the supported system settings, you have to add these settings in an external configuration file. You have to fill the system setting tinymcerte.external_config with i.e. {core_path}config/tinymcerte/tinymcerte.config.json and create that file with additional settings for TinyMCE RTE.

In your case with:

{
  "valid_children": "+body[li]"
}

The settings in that file are merged into the TinyMCERTE.editorConfig that is visible in the html source code of the manager page. Please check, wether they are occurring there. Otherwise there is some syntax error in the external config file.

1 Like