Inserting linebreak using "
" in contentEditable does not work: document.execCommand('insertHTML', false, '
')

Confirmed Issue #6274486 • Assigned to Grisha L.

Details

Created
Jan 22, 2016
Privacy
This issue is public.
Reports
Reported by 0 people

Sign in to watch or report this issue.

Steps to reproduce

URL:

Repro Steps:

Type in the div, press enter once or more times, type again.

TEST https://jsfiddle.net/0gkfo2to/][https://jsfiddle.net/0gkfo2to/]

function handleKeydown(e) {
var ENTER_KEY = 13;
console.log(e);
if (e.keyCode === ENTER_KEY) {
e.preventDefault();
document.execCommand('insertHTML’, false, ‘
’);
}
}

<div class="editable-content" contenteditable="true" onkeydown="handleKeydown(event)">
some content
</div>

.editable-content {
white-space: pre-wrap;
}

Expected Results:

The content should display line-breaks, similar to a textarea, when pressing the ENTER key.

Actual Results:

Dev Channel specific:

No

Attachments

0 attachments

    Comments and activity

    • Microsoft Edge Team

      Changed Assigned To to “Mara P.”

      Changed Assigned To to “Amit J.”

      Changed Status to “Confirmed”

      Changed Assigned To to “Amit J.”

      Changed Assigned To from “Amit J.” to “Grisha L.”

    You need to sign in to your Microsoft account to add a comment.

    Sign in