Add event listener to TinyMCE

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
totza2010
User
Posts: 109

Add event listener to TinyMCE

Post by totza2010 »

Edit html code in tinymce not editable.
i find solution fix this problem work, By

document.addEventListener('focusin', (e) => {
  if (e.target.closest(".tox-tinymce-aux, .moxman-window, .tam-assetmanager-root") !== null) {
    e.stopImmediatePropagation();
  }
});

use this code, but i try pase this code in client script and startup script not work,
i try pase this code in file ewediter.js worked.


arbei
User
Posts: 9384

Post by arbei »

You cannot put it in Client/Startup Script directly because the editors are not created yet. You may wait until the form is initiated, e.g. in Startup Script

currentForm.on("initiated", () => { ... your code ... }); // This example assume normal pages such as the Add/Edit page of a table

totza2010
User
Posts: 109

Post by totza2010 »

currentForm.on("initiated", (e) => { 
    document.addEventListener('focusin', (e) => {
        if (e.target.closest(".tox-tinymce-aux, .moxman-window, .tam-assetmanager-root") !== null) {
            e.stopImmediatePropagation();
        }
    });
});

i use this code in global startup script, it worked. thx.


Post Reply