Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TinyMCE 4 insert link form fields disabled

I'm using the tinymce-rails gem which uses TinyMCE 4 and I'm loading the link plugin and all this is initiated after/in a colorbox popup.

TinyMCE editor is working perfectly but the link button brings up a dialog to add/edit a link, but none of the fields except the target are available for editing.

below is the related code:

setup_new_message: ->
  tinyMCE.init
    selector: '.tinymce'
    plugins: "textcolor link"
    menubar: false
    toolbar: "formatselect | fontselect | bold italic underline | forecolor | alignleft aligncenter alignright | bullist numlist | link"
    height: 250

  $(document).on 'focusin', (e) ->
    if $(e.target).closest(".mce-window").length
      e.stopImmediatePropagation()

I found the $(document).on 'focusin' in other stackoverflow question/answers but this is not working for me. It does fire the e.stopImmediatePropagation() but it is not working as everyone said it would.

Any thoughts? Thanks in advance.

like image 815
Sparkmasterflex Avatar asked Nov 29 '25 05:11

Sparkmasterflex


2 Answers

For anyone putting tinymce inside a Material UI mui Dialog, do:

<Dialog disableEnforceFocus={true} ...>
like image 51
JohnFlux Avatar answered Dec 01 '25 19:12

JohnFlux


Depending on the version of TinyMCE, the solution would be:

$(document).on('focusin', function(e) {
    var target = $(e.target);
    if (target.closest(".mce-window").length || target.closest(".tox-dialog").length) {
        e.stopImmediatePropagation();
        target = null;
    }
});

And of course the answer from Sparkmasterflex

like image 23
Ivijan Stefan Stipić Avatar answered Dec 01 '25 17:12

Ivijan Stefan Stipić