TinyMCE remove / disable resizing

tinyMCE adds those move and resize handles to some of my elements (and not just images).

I would like to get rid of them all together , but I was not successful.

it didn't work for me

 tinyMCE.init({ object_resizing : false }); 

It seems like it should be very easy.

OK, so it looks like it adds js size to any element that is absolutely positioned. if it helps anyone who has an answer.

I just tried to remove it, but I need to put it in order to do what I need.

+6
source share
2 answers

Your editor’s body tag has a contenteditable="true" attribute. this is what adds these annoying resizing elements.

if you set this attribute to false , you cannot edit anything.

what you need to do is set up the onMouseDown listener. if the user clicks on the items in question ... set it to contenteditable="false" . if any other item, set it to contenteditable="true" .

try it...

 (function() { tinymce.create('tinymce.plugins.yourplugin', { init : function(ed, url) { ed.onMouseDown.add(function(ed, e) { var body = ed.getBody(); if(jQuery(e.target).hasClass('target-in-question')) { jQuery(body).attr({'contenteditable': false}) // and whatever else you want to do when clicking on that element }else { jQuery(body).attr({'contenteditable': true}) } }); }, createControl : function(n, cm) { return null; }, }); tinymce.PluginManager.add('yourplugin', tinymce.plugins.yourpluginl); })(); 
+3
source

Removing jQuery and creating cheez la weez to work in TinyMCE version 4. Use this in the plugin, in the initialization code, or simply on your page after creating the editor instance

 // var editor = your tinyMCE editor instance (eg tinymce.activeEditor) editor.on('mousedown', function(e) { var element = e.target, body = editor.dom.doc.body; if (editor.dom.hasClass( element, 'your-class')) { editor.dom.setAttrib(body,'contenteditable',false); } else { editor.dom.setAttrib(body,'contenteditable',true); } }); 

The only bad bit is that your user will have to go back to the editor to resume editing (the arrow keys will not work)

+4
source

All Articles