I created a contentEditable div to use as a rich textarea. It has resize handlers around it that I'd like to get rid of. Any idea how I'd do this?
Edit: This appears to be happening because I am absolutely positioning the div, so Firefox adds an infuriating _moz_resize attribute to the element which I cannot turn off.
It looks like I'll be able to work around this by adding a wrapper div and absolutely positioning the wrapper and then making the inner div contentEditable.
Just as a side note, you can disable Firefox's automatic resize handle feature by sending the (somewhat poorly-documented)
enableObjectResizing
command to the document:AFAIK, this can only safely be done once the document has loaded, and there's no way I know of to disable the grabber, which is a separate feature.
In Chrome 39, these handles don't seem to exist, even if you wanted them to.
In Firefox, one can simply use
execCommand
, like ZoogieZork answered.But in Internet Explorer this can't be turned off. It must be worked around.
In WYMeditor development, here's what I've found.
The following results in:
mouseup
mouseup
will result in an image being selected.This is the best I could come up with after hours of very deep breaths. I think it is good enough if you really want to get rid of those handles.
In IE, Setting
oncontrolselect
to returnfalse
on the image, really does prevent those handles from appearing, and you can do it cleverly, by attaching the following handler to themousedown
event:It actually doesn't work completely well. The reason that it didn't work very well is that in order to begin a drag and drop operation on the image, one had to press and hold the mouse, without moving it, for a split second, and only then begin moving it for the drag. If one pressed the mouse and immediately began dragging, the image would remain in its place and not be dragged.
So I didn't do that.
What I did is the following. In all browsers, I used
mouseup
to text select the target image exclusively. In non-IE and IE11, synchronously:In IE 7 through 10, asynchronously:
This made sure that after those handles show up, they disappear ASAP, because the image loses its "control selection" because that selection is replaced with a regular text selection.
In Internet Explorer 7 through 11, I attached a handler to
dragend
that removes all selection:This makes the handles that show up after drag and drop, disappear.
I hope this helps and I hope you can make it even better.
Have you tried adding the style
to the div?
... just the best fix ever
or any html element that wraps your input/img
Works on IE11 like a charm
I just face that problem. I tried
document.execCommand("enableObjectResizing", false, false);
but, the move icon was still appearing. What just fix my problem was juste.preventDefault()
whenonmousedown
event occurs.