Override default style behavior of TinyMCE on new element

I was trying to search for a way to override default behavior of TinyMCE when it applies same styles to new elements. For example, when we apply some style to a paragraph and hit enter for new paragraph, it inherits same styles. Is it possible to override this behavior?

Related posts

1 comment

  1. Yes, it is.

    You will have to register the keyup event and check for the ENTER key.
    Then you check the actual node the caret is in and you may add/remove classes or whatever. Use the setup tinymce configuration parameter to add the handler:

     setup:function(ed){
          ed.on("keyup", function(e){
               if(e.keyCode == 13){ // ENTER
                    var node = ed.selection.getNode();
    
                    // do your magic here
               }                        
          });
     }
    

Comments are closed.