');
equal(editor.selection.getRng(true).startContainer.parentNode.nodeName, 'H1');
});
test('Enter before text after EM', function() {
editor.setContent('
');
var rng = editor.selection.getRng(true);
equal(rng.startContainer.nodeName, 'P');
equal(rng.startContainer.childNodes[rng.startOffset].nodeName, 'IMG');
});
test('Enter before last IMG in P with IMG sibling', function() {
editor.setContent('');
editor.selection.setCursorLocation(editor.getBody().firstChild, 1);
Utils.pressEnter();
equal(editor.getContent(), '');
var rng = editor.selection.getRng(true);
equal(rng.startContainer.nodeName, 'P');
equal(rng.startContainer.childNodes[rng.startOffset].nodeName, 'IMG');
});
test('Enter after last IMG in P', function() {
editor.setContent('
');
var rng = editor.selection.getRng(true);
equal(rng.startContainer.nodeName, 'P');
equal(rng.startContainer.childNodes[rng.startOffset].nodeName, 'INPUT');
});
test('Enter before last INPUT in P with IMG sibling', function() {
editor.setContent('');
editor.selection.setCursorLocation(editor.getBody().firstChild, 1);
Utils.pressEnter();
equal(editor.getContent(), '');
var rng = editor.selection.getRng(true);
equal(rng.startContainer.nodeName, 'P');
equal(rng.startContainer.childNodes[rng.startOffset].nodeName, 'INPUT');
});
test('Enter after last INPUT in P', function() {
editor.setContent('
');
equal(editor.selection.getRng(true).startContainer.nodeValue, 'abc');
});
test('Enter at end of STRONG in EM inside P', function() {
editor.setContent('
');
equal(editor.selection.getRng(true).startContainer.nodeName, 'STRONG');
});
test('Enter at middle of STRONG in EM inside P', function() {
editor.setContent('
');
equal(editor.selection.getRng(true).startContainer.parentNode.nodeName, 'STRONG');
});
test('Enter at beginning STRONG in EM inside P', function() {
editor.setContent('
');
equal(editor.selection.getRng(true).startContainer.nodeValue, 'abc');
});
test('Enter at middle of P with style, id and class attributes', function() {
editor.setContent('
');
equal(editor.selection.getRng(true).startContainer.parentNode.nodeName, 'P');
});
test('Enter at a range between H1 and P', function() {
editor.setContent('
');
equal(editor.selection.getNode().nodeName, 'STRONG');
});
test('Enter inside middle of text node in body', function() {
editor.getBody().innerHTML = 'abcd';
Utils.setSelection('body', 2);
Utils.pressEnter();
equal(editor.getContent(), '
ab
cd
');
equal(editor.selection.getNode().nodeName, 'P');
});
test('Enter inside at beginning of text node in body', function() {
editor.getBody().innerHTML = 'abcd';
Utils.setSelection('body', 0);
Utils.pressEnter();
equal(editor.getContent(), '
\u00a0
abcd
');
equal(editor.selection.getNode().nodeName, 'P');
});
test('Enter inside at end of text node in body', function() {
editor.getBody().innerHTML = 'abcd';
Utils.setSelection('body', 4);
Utils.pressEnter();
equal(editor.getContent(), '
');
equal(editor.selection.getNode().nodeName, 'P');
});
test('Enter inside empty li at the end of ol', function() {
editor.getBody().innerHTML = (tinymce.isIE && tinymce.Env.ie < 11) ? '
');
equal(editor.selection.getNode().nodeName, 'P');
});
test('Shift+Enter inside empty li at the end of ol', function() {
editor.getBody().innerHTML = (tinymce.isIE && tinymce.Env.ie < 11) ? '
');
equal(editor.selection.getNode().nodeName, 'P');
});
test('Enter inside empty li in the middle of ol with forced_root_block: false', function() {
editor.settings.forced_root_block = false;
editor.getBody().innerHTML = (tinymce.isIE && tinymce.Env.ie < 11) ? '
');
equal(editor.selection.getNode().nodeName, 'BODY');
});
test('Enter inside empty li at the end of ol with forced_root_block: false', function() {
editor.settings.forced_root_block = false;
editor.getBody().innerHTML = (tinymce.isIE && tinymce.Env.ie < 11) ? '
');
equal(editor.selection.getNode().nodeName, 'P');
});
// Nested lists in LI elements
test('Enter inside empty LI in beginning of OL in LI', function() {
editor.getBody().innerHTML = Utils.trimBrsOnIE(
'' +
'
' +
''
);
equal(editor.selection.getNode().nodeName, 'LI');
});
test('Enter inside empty LI in middle of OL in LI', function() {
editor.getBody().innerHTML = Utils.trimBrsOnIE(
'' +
'
' +
''
);
// Ignore on IE 7, 8 this is a known bug not worth fixing
if (!tinymce.Env.ie || tinymce.Env.ie > 8) {
equal(editor.selection.getNode().nodeName, 'LI');
}
});
test('Enter inside empty LI in end of OL in LI', function() {
editor.getBody().innerHTML = Utils.trimBrsOnIE(
'' +
'
' +
'' +
''
);
equal(editor.selection.getNode().nodeName, 'LI');
});
// Nested lists in OL elements
// Ignore on IE 7, 8 this is a known bug not worth fixing
if (!tinymce.Env.ie || tinymce.Env.ie > 8) {
test('Enter before nested list', function() {
editor.getBody().innerHTML = Utils.trimBrsOnIE(
'' +
'
' +
'' +
''
);
equal(editor.selection.getNode().nodeName, 'LI');
});
test('Enter inside empty LI in end of OL in OL', function() {
editor.getBody().innerHTML = Utils.trimBrsOnIE(
'' +
'
');
// Ignore on IE 7, 8 this is a known bug not worth fixing
if (!tinymce.Env.ie || tinymce.Env.ie > 8) {
equal(editor.selection.getNode().nodeName, 'P');
}
});
test('Enter at end of P inside LI', function() {
editor.getBody().innerHTML = '
');
equal(editor.selection.getNode().nodeName, 'P');
});
test('Enter in the middle of text in P with forced_root_block set to false', function() {
editor.settings.forced_root_block = false;
editor.getBody().innerHTML = '
');
});
test('Enter at the end of text in P with forced_root_block set to false', function() {
editor.settings.forced_root_block = false;
editor.getBody().innerHTML = '
');
});
test('Enter at the middle of text in BODY with forced_root_block set to false', function() {
editor.settings.forced_root_block = false;
editor.getBody().innerHTML = 'abcd';
Utils.setSelection('body', 2);
editor.focus();
Utils.pressEnter();
equal(Utils.cleanHtml(editor.getBody().innerHTML), 'ab cd');
});
test('Enter at the beginning of text in BODY with forced_root_block set to false', function() {
editor.settings.forced_root_block = false;
editor.getBody().innerHTML = 'abcd';
Utils.setSelection('body', 0);
editor.focus();
Utils.pressEnter();
equal(Utils.cleanHtml(editor.getBody().innerHTML), ' abcd');
});
test('Enter at the end of text in BODY with forced_root_block set to false', function() {
editor.settings.forced_root_block = false;
editor.getBody().innerHTML = 'abcd';
Utils.setSelection('body', 4);
editor.focus();
Utils.pressEnter();
equal(Utils.cleanHtml(editor.getBody().innerHTML), (tinymce.isIE && tinymce.Env.ie < 11) ? 'abcd ' : 'abcd
');
});
test('Enter in empty P at the end of a blockquote and end_container_on_empty_block: true', function() {
editor.settings.end_container_on_empty_block = true;
editor.getBody().innerHTML = (tinymce.isIE && tinymce.Env.ie < 11) ? '
');
});
test('Enter in empty P at the beginning of a blockquote and end_container_on_empty_block: true', function() {
editor.settings.end_container_on_empty_block = true;
editor.getBody().innerHTML = (tinymce.isIE && tinymce.Env.ie < 11) ? '
');
});
test('Enter in empty P at in the middle of a blockquote and end_container_on_empty_block: true', function() {
editor.settings.end_container_on_empty_block = true;
editor.getBody().innerHTML = (tinymce.isIE && tinymce.Env.ie < 11) ? '
');
});
test('Enter inside empty P with empty P siblings', function() {
// Tests that a workaround for an IE bug is working correctly
editor.getBody().innerHTML = '
');
});
test('Enter at end of H1 with forced_root_block_attrs', function() {
editor.settings.forced_root_block_attrs = {"class": "class1"};
editor.getBody().innerHTML = '
');
});
test('Shift+Enter in beginning of P with forced_root_block set to false', function() {
editor.settings.forced_root_block = false;
editor.getBody().innerHTML = '
');
});
test('Shift+Enter in middle of P with forced_root_block set to false', function() {
editor.settings.forced_root_block = false;
editor.getBody().innerHTML = '
');
});
test('Shift+Enter at the end of P with forced_root_block set to false', function() {
editor.settings.forced_root_block = false;
editor.getBody().innerHTML = '
');
});
test('Enter at end of text in a span inside a P and keep_styles: false', function() {
editor.settings.keep_styles = false;
editor.getBody().innerHTML = '
');
var rng = editor.selection.getRng(true);
equal(rng.startContainer.nodeName, 'P');
equal(rng.startContainer.childNodes[rng.startOffset].nodeName, 'BR');
});
// Ignore on IE 7, 8 this is a known bug not worth fixing
if (!tinymce.Env.ie || tinymce.Env.ie > 8) {
test('Enter before BR between DIVs', function() {
editor.getBody().innerHTML = '
');
});
}
// Only test these on modern browsers
if (window.getSelection) {
test('Enter behind table element', function() {
var rng = editor.dom.createRng();
editor.getBody().innerHTML = '