Drop image into contenteditable in Chrome to the cursor

If you can get the co-ordinates of the drop location (which I assume must be possible), you can do it as follows (untested). I’m assuming you’ve got the co-ordinates of the drop location relative to the viewport as variables x and y and the dropped image as the variable img: Demo: http://jsfiddle.net/KZqNj/ Code: var range; … Read more

How to disable elements selection and resizing in contenteditable div?

I spent on this a lot of time myself, when trying to completely hide control selections (this is how they are called) in CKEditor’s widgets. Unfortunately I don’t have a good news. Solution 1 First of all, there’s a mscontrolselect event. When I found it (and the fact that its name has an ms prefix) … Read more

trigger an event when contenteditable is changed

Just store the contents to a variable and check if it is different after blur() event. If it is different, store the new contents. var contents = $(‘.changeable’).html(); $(‘.changeable’).blur(function() { if (contents!=$(this).html()){ alert(‘Handler for .change() called.’); contents = $(this).html(); } }); example: http://jsfiddle.net/niklasvh/a4QNB/

Get caret index in contenteditable div including tags

Have you tried this? Get a range’s start and end offset’s relative to its parent container Direct link to the jsfiddle: https://jsfiddle.net/TjXEG/1/ Function code: function getCaretCharacterOffsetWithin(element) { var caretOffset = 0; if (typeof window.getSelection != “undefined”) { var range = window.getSelection().getRangeAt(0); var preCaretRange = range.cloneRange(); preCaretRange.selectNodeContents(element); preCaretRange.setEnd(range.endContainer, range.endOffset); caretOffset = preCaretRange.toString().length; } else if (typeof … Read more

tech