user3189644
user3189644

Reputation: 177

Enable resize for div inside contenteditable div

I have a div with contenteditable set to true. Now I want to enable resize for div inside contenteditable div.

In my example html insert works fine but how to make inserted html div to be resizable?

Code:

function inserthtml() {
    var sel = document.selection;
    if (sel) {
        var textRange = sel.createRange();
        document.execCommand('inserthtml', false, "<div><img src='https://www.google.com/images/srpr/logo11w.png'  height='42' width='42'></div>");
        textRange.collapse(false);
        textRange.select();
    } else {
        document.execCommand('inserthtml', false, "<div><img src='https://www.google.com/images/srpr/logo11w.png'  height='42' width='42'></div>");
    }
}

fiddle: http://jsfiddle.net/q6q05f1b/

Upvotes: 7

Views: 4017

Answers (1)

Pranay Nailwal
Pranay Nailwal

Reputation: 542

#editme {
  resize: vertical;
  overflow: auto;
}
<div id="editme" contenteditable="true">Click somewhere in here and press the 'insert html' button</div>

Upvotes: 9

Related Questions