Sterc / Formalicious

Other
6 stars 11 forks source link

MODx.loadRTE is undefined / not initialising editor correctly #29

Open Mark-H opened 1 year ago

Mark-H commented 1 year ago

This comes from an issue using Redactor. There was a small change in Redactor 3.1.5 where it only defines MODx.loadRTE if Redactor is specifically requested/initialised. The purpose of that change was to allow the use of a different editor (like TinyMCE) globally, while using Redactor's ability to be enabled on other specific elements (like specific ContentBlocks fields).

This surfaced one/two issues with the way Formalicious initialises editors.

  1. Formalicious does not check if MODX.loadRTE is defined before calling it for the email content field. This means the Formalicious component breaks when the editor isn't loaded for whatever reason

Error trace:

Scherm­afbeelding 2023-08-14 om 18 53 26

Suggestion:

            if (MODx.config.which_editor === 'TinyMCE RTE') {
                config.skin = MODx.config['tinymcerte.skin'];

                new TinyMCERTE.Tiny({
                    allowDrop : true
                }, config);
-            } else {
-                MODx.loadRTE(id, config);
-            }
+            } else if (MODx.loadRTE) {
+                MODx.loadRTE(id, config);
+            }
  1. Formalicious doesn't seem to run the OnRichTextEditorInit event to initialise editors in a universal way. While Redactor loads itself globally, it only sets MODx.loadRTE if OnRichTextEditorInit is called.

(For more details on this, see https://docs.modmore.com/en/Redactor/v3.x/Usage/Third_Party_Extras.html)