import { ApproxStructure } from '@ephox/agar'; import { after, before, context, describe, it } from '@ephox/bedrock-client'; import { TinyAssertions, TinyHooks, TinySelections } from '@ephox/wrap-mcagar'; import Editor from 'tinymce/core/api/Editor'; import { EditorEvent } from 'tinymce/core/api/util/EventDispatcher'; import * as InsertNewLine from 'tinymce/core/newline/InsertNewLine'; describe('browser.tinymce.core.newline.InsertNewLineTest', () => { const hook = TinyHooks.bddSetupLight({ indent: false, base_url: '/project/tinymce/js/tinymce' }, [], true); const bookmarkSpan = ''; const insertNewline = (editor: Editor, args: Partial>) => { InsertNewLine.insert(editor, args as EditorEvent); }; context('Enter in paragraph', () => { it('Insert block before', () => { const editor = hook.editor(); editor.setContent('

ab

'); TinySelections.setCursor(editor, [ 0, 0 ], 0); insertNewline(editor, { }); TinyAssertions.assertContent(editor, '

 

ab

'); TinyAssertions.assertSelection(editor, [ 1, 0 ], 0, [ 1, 0 ], 0); }); it('Split block in the middle', () => { const editor = hook.editor(); editor.setContent('

ab

'); TinySelections.setCursor(editor, [ 0, 0 ], 1); insertNewline(editor, { }); TinyAssertions.assertContent(editor, '

a

b

'); TinyAssertions.assertSelection(editor, [ 1, 0 ], 0, [ 1, 0 ], 0); }); it('Insert block after', () => { const editor = hook.editor(); editor.setContent('

ab

'); TinySelections.setCursor(editor, [ 0, 0 ], 2); insertNewline(editor, { }); TinyAssertions.assertContent(editor, '

ab

 

'); TinyAssertions.assertSelection(editor, [ 1 ], 0, [ 1 ], 0); }); it('Insert block after bookmark', () => { const editor = hook.editor(); editor.setContent(`

${bookmarkSpan}

`, { format: 'raw' }); TinySelections.setCursor(editor, [ 0 ], 1); insertNewline(editor, { }); TinyAssertions.assertContentStructure(editor, ApproxStructure.build((s, str) => s.element('body', { children: [ s.element('p', { children: [ ApproxStructure.fromHtml(bookmarkSpan), s.element('br', { attrs: { 'data-mce-bogus': str.is('1') } }) ] }), s.element('p', { children: [ s.element('br', { attrs: { 'data-mce-bogus': str.is('1') } }) ] }) ] })) ); TinyAssertions.assertSelection(editor, [ 1 ], 0, [ 1 ], 0); }); }); context('CEF', () => { it('TINY-9098: insert newline on inline CEF element should do nothing', () => { const editor = hook.editor(); editor.setContent('

beforexafter

'); TinySelections.select(editor, 'span', []); insertNewline(editor, { }); editor.nodeChanged(); TinyAssertions.assertContent(editor, '

beforexafter

'); }); it('TINY-9194: restore selection from the bookmark and insert newline after inline CEF element', () => { const editor = hook.editor(); editor.setContent('

a

'); // actual content

a

TinySelections.setCursor(editor, [ 0 ], 2); // actual content

a

TinyAssertions.assertCursor(editor, [ 0, 1 ], 1); const bookmark = editor.selection.getBookmark(); editor.selection.moveToBookmark(bookmark); // actual content

a

TinyAssertions.assertCursor(editor, [ 0, 1 ], 1); insertNewline(editor, { }); TinyAssertions.assertContent(editor, '

a

 

'); TinyAssertions.assertCursor(editor, [ 1 ], 0); }); it('TINY-9461: should not split editing host in noneditable root', () => { const editor = hook.editor(); const initialContent = '

ab

'; editor.getBody().contentEditable = 'false'; editor.setContent(initialContent); TinySelections.setCursor(editor, [ 0, 0 ], 1); insertNewline(editor, { }); TinyAssertions.assertContent(editor, initialContent); editor.getBody().contentEditable = 'true'; }); it('TINY-9461: should wrap div contents in paragraph and split inner paragraph in a div editing host inside a noneditable root', () => { const editor = hook.editor(); editor.getBody().contentEditable = 'false'; editor.setContent('
ab
'); TinySelections.setCursor(editor, [ 0, 0 ], 1); insertNewline(editor, { }); TinyAssertions.assertContent(editor, '

a

b

'); editor.getBody().contentEditable = 'true'; }); it('TINY-9461: should not split editing host', () => { const editor = hook.editor(); const initialContent = '

ab

'; editor.setContent(initialContent); TinySelections.setCursor(editor, [ 1, 0, 0 ], 1); insertNewline(editor, { }); TinyAssertions.assertContent(editor, initialContent); }); it('TINY-9461: should wrap div contents in paragraph and split inner paragraph in a div editing host', () => { const editor = hook.editor(); editor.getBody().contentEditable = 'false'; editor.setContent('
ab
'); TinySelections.setCursor(editor, [ 0, 0, 0 ], 1); insertNewline(editor, { }); TinyAssertions.assertContent(editor, '

a

b

'); editor.getBody().contentEditable = 'true'; }); }); context('br_newline_selector', () => { before(() => { hook.editor().options.set('br_newline_selector', 'p,div.test'); }); after(() => { hook.editor().options.unset('br_newline_selector'); }); it('Insert newline where br is forced (paragraph)', () => { const editor = hook.editor(); editor.setContent('

ab

'); TinySelections.setCursor(editor, [ 0, 0 ], 1); insertNewline(editor, { }); editor.nodeChanged(); TinyAssertions.assertContent(editor, '

a
b

'); }); it('Insert newline where br is forced (div)', () => { const editor = hook.editor(); editor.setContent('
ab
'); TinySelections.setCursor(editor, [ 0, 0 ], 1); insertNewline(editor, { }); editor.nodeChanged(); TinyAssertions.assertContent(editor, '
a
b
'); }); it('Insert newline where br is not forced', () => { const editor = hook.editor(); editor.setContent('
ab
'); TinySelections.setCursor(editor, [ 0, 0 ], 1); insertNewline(editor, { }); editor.nodeChanged(); TinyAssertions.assertContent(editor, '
a
b
'); }); }); context('no_newline_selector', () => { before(() => { hook.editor().options.set('no_newline_selector', 'p,div.test'); }); after(() => { hook.editor().options.unset('no_newline_selector'); }); it('Insert newline where newline is blocked (paragraph)', () => { const editor = hook.editor(); editor.setContent('

ab

'); TinySelections.setCursor(editor, [ 0, 0 ], 1); insertNewline(editor, { }); editor.nodeChanged(); TinyAssertions.assertContent(editor, '

ab

'); }); it('Insert newline where newline is blocked (div)', () => { const editor = hook.editor(); editor.setContent('
ab
'); TinySelections.setCursor(editor, [ 0, 0 ], 1); insertNewline(editor, { }); editor.nodeChanged(); TinyAssertions.assertContent(editor, '
ab
'); }); it('Insert newline where newline is not blocked', () => { const editor = hook.editor(); editor.setContent('
ab
'); TinySelections.setCursor(editor, [ 0, 0 ], 1); insertNewline(editor, { }); editor.nodeChanged(); TinyAssertions.assertContent(editor, '
a
b
'); }); }); it('Insert newline before image in link', () => { const editor = hook.editor(); editor.setContent('

a

'); TinySelections.setCursor(editor, [ 0, 0 ], 1); insertNewline(editor, { }); TinyAssertions.assertContent(editor, '

a

'); TinyAssertions.assertSelection(editor, [ 1, 0 ], 0, [ 1, 0 ], 0); }); context('end_container_on_empty_block', () => { context('With the default value', () => { it('TINY-6559: Press Enter in blockquote', () => { const editor = hook.editor(); editor.setContent('

Line 1

Line 2

'); TinySelections.setCursor(editor, [ 0, 1 ], 1); insertNewline(editor, { }); TinyAssertions.assertContent(editor, '

Line 1

Line 2

 

'); TinyAssertions.assertSelection(editor, [ 0, 2 ], 0, [ 0, 2 ], 0); }); it('TINY-6559: Press Shift+Enter in blockquote', () => { const editor = hook.editor(); editor.setContent('

Line 1

Line 2

'); TinySelections.setCursor(editor, [ 0, 1 ], 1); insertNewline(editor, { shiftKey: true }); TinyAssertions.assertContent(editor, '

Line 1

Line 2

'); TinyAssertions.assertSelection(editor, [ 0, 1 ], 2, [ 0, 1 ], 2); }); it('TINY-6559: Press Enter twice in blockquote', () => { const editor = hook.editor(); editor.setContent('

Line 1

Line 2

'); TinySelections.setCursor(editor, [ 0, 1 ], 1); insertNewline(editor, { }); insertNewline(editor, { }); TinyAssertions.assertContent(editor, '

Line 1

Line 2

 

'); TinyAssertions.assertSelection(editor, [ 1 ], 0, [ 1 ], 0); }); it('TINY-6559: Press Enter twice in blockquote while between two lines', () => { const editor = hook.editor(); editor.setContent('

Line 1

Line 2

'); TinySelections.setCursor(editor, [ 0, 0 ], 1); insertNewline(editor, { }); insertNewline(editor, { }); TinyAssertions.assertContent(editor, '

Line 1

 

Line 2

'); TinyAssertions.assertSelection(editor, [ 1 ], 0, [ 1 ], 0); }); it('TINY-6559: Press Enter twice in a div', () => { const editor = hook.editor(); editor.setContent('

Line 1

Line 2

'); TinySelections.setCursor(editor, [ 0, 1 ], 1); insertNewline(editor, { }); insertNewline(editor, { }); TinyAssertions.assertContent(editor, '

Line 1

Line 2

 

 

'); TinyAssertions.assertSelection(editor, [ 0, 3 ], 0, [ 0, 3 ], 0); }); it('TINY-6559: Press Enter twice in a section', () => { const editor = hook.editor(); editor.setContent('

Line 1

Line 2

'); TinySelections.setCursor(editor, [ 0, 1 ], 1); insertNewline(editor, { }); insertNewline(editor, { }); TinyAssertions.assertContent(editor, '

Line 1

Line 2

 

 

'); TinyAssertions.assertSelection(editor, [ 0, 3 ], 0, [ 0, 3 ], 0); }); }); context('Is set to "div"', () => { it('TINY-6559: Press Enter in blockquote', () => { const editor = hook.editor(); editor.options.set('end_container_on_empty_block', 'div'); editor.setContent('

Line 1

Line 2

'); TinySelections.setCursor(editor, [ 0, 1 ], 1); insertNewline(editor, { }); TinyAssertions.assertContent(editor, '

Line 1

Line 2

 

'); TinyAssertions.assertSelection(editor, [ 0, 2 ], 0, [ 0, 2 ], 0); }); it('TINY-6559: Press Shift+Enter in blockquote', () => { const editor = hook.editor(); editor.options.set('end_container_on_empty_block', 'div'); editor.setContent('

Line 1

Line 2

'); TinySelections.setCursor(editor, [ 0, 1 ], 1); insertNewline(editor, { shiftKey: true }); TinyAssertions.assertContent(editor, '

Line 1

Line 2

'); TinyAssertions.assertSelection(editor, [ 0, 1 ], 2, [ 0, 1 ], 2); }); it('TINY-6559: Press Enter twice in blockquote', () => { const editor = hook.editor(); editor.options.set('end_container_on_empty_block', 'div'); editor.setContent('

Line 1

Line 2

'); TinySelections.setCursor(editor, [ 0, 1 ], 1); insertNewline(editor, { }); insertNewline(editor, { }); TinyAssertions.assertContent(editor, '

Line 1

Line 2

 

 

'); TinyAssertions.assertSelection(editor, [ 0, 3 ], 0, [ 0, 3 ], 0); }); it('TINY-6559: Press Enter twice in blockquote while between two lines', () => { const editor = hook.editor(); editor.options.set('end_container_on_empty_block', 'div'); editor.setContent('

Line 1

Line 2

'); TinySelections.setCursor(editor, [ 0, 0 ], 1); insertNewline(editor, { }); insertNewline(editor, { }); TinyAssertions.assertContent(editor, '

Line 1

 

 

Line 2

'); TinyAssertions.assertSelection(editor, [ 0, 2 ], 0, [ 0, 2 ], 0); }); it('TINY-6559: Press Enter twice in a div', () => { const editor = hook.editor(); editor.options.set('end_container_on_empty_block', 'div'); editor.setContent('

Line 1

Line 2

'); TinySelections.setCursor(editor, [ 0, 1 ], 1); insertNewline(editor, { }); insertNewline(editor, { }); TinyAssertions.assertContent(editor, '

Line 1

Line 2

 

'); TinyAssertions.assertSelection(editor, [ 1 ], 0, [ 1 ], 0); }); it('TINY-6559: Press Enter twice in a section', () => { const editor = hook.editor(); editor.setContent('

Line 1

Line 2

'); TinySelections.setCursor(editor, [ 0, 1 ], 1); insertNewline(editor, { }); insertNewline(editor, { }); TinyAssertions.assertContent(editor, '

Line 1

Line 2

 

 

'); TinyAssertions.assertSelection(editor, [ 0, 3 ], 0, [ 0, 3 ], 0); }); }); context('Is set to "div,blockquote"', () => { it('TINY-6559: Press Enter in blockquote', () => { const editor = hook.editor(); editor.options.set('end_container_on_empty_block', 'div,blockquote'); editor.setContent('

Line 1

Line 2

'); TinySelections.setCursor(editor, [ 0, 1 ], 1); insertNewline(editor, { }); TinyAssertions.assertContent(editor, '

Line 1

Line 2

 

'); TinyAssertions.assertSelection(editor, [ 0, 2 ], 0, [ 0, 2 ], 0); }); it('TINY-6559: Press Shift+Enter in blockquote', () => { const editor = hook.editor(); editor.options.set('end_container_on_empty_block', 'div,blockquote'); editor.setContent('

Line 1

Line 2

'); TinySelections.setCursor(editor, [ 0, 1 ], 1); insertNewline(editor, { shiftKey: true }); TinyAssertions.assertContent(editor, '

Line 1

Line 2

'); TinyAssertions.assertSelection(editor, [ 0, 1 ], 2, [ 0, 1 ], 2); }); it('TINY-6559: Press Enter twice in blockquote', () => { const editor = hook.editor(); editor.options.set('end_container_on_empty_block', 'div,blockquote'); editor.setContent('

Line 1

Line 2

'); TinySelections.setCursor(editor, [ 0, 1 ], 1); insertNewline(editor, { }); insertNewline(editor, { }); TinyAssertions.assertContent(editor, '

Line 1

Line 2

 

'); TinyAssertions.assertSelection(editor, [ 1 ], 0, [ 1 ], 0); }); it('TINY-6559: Press Enter twice in blockquote while between two lines', () => { const editor = hook.editor(); editor.options.set('end_container_on_empty_block', 'div,blockquote'); editor.setContent('

Line 1

Line 2

'); TinySelections.setCursor(editor, [ 0, 0 ], 1); insertNewline(editor, { }); insertNewline(editor, { }); TinyAssertions.assertContent(editor, '

Line 1

 

Line 2

'); TinyAssertions.assertSelection(editor, [ 1 ], 0, [ 1 ], 0); }); it('TINY-6559: Press Enter twice in a div', () => { const editor = hook.editor(); editor.options.set('end_container_on_empty_block', 'div,blockquote'); editor.setContent('

Line 1

Line 2

'); TinySelections.setCursor(editor, [ 0, 1 ], 1); insertNewline(editor, { }); insertNewline(editor, { }); TinyAssertions.assertContent(editor, '

Line 1

Line 2

 

'); TinyAssertions.assertSelection(editor, [ 1 ], 0, [ 1 ], 0); }); it('TINY-6559: Press Enter twice in a section', () => { const editor = hook.editor(); editor.setContent('

Line 1

Line 2

'); TinySelections.setCursor(editor, [ 0, 1 ], 1); insertNewline(editor, { }); insertNewline(editor, { }); TinyAssertions.assertContent(editor, '

Line 1

Line 2

 

 

'); TinyAssertions.assertSelection(editor, [ 0, 3 ], 0, [ 0, 3 ], 0); }); }); context('Is set to true', () => { it('TINY-6559: Press Enter in blockquote', () => { const editor = hook.editor(); editor.options.set('end_container_on_empty_block', true); editor.setContent('

Line 1

Line 2

'); TinySelections.setCursor(editor, [ 0, 1 ], 1); insertNewline(editor, { }); TinyAssertions.assertContent(editor, '

Line 1

Line 2

 

'); TinyAssertions.assertSelection(editor, [ 0, 2 ], 0, [ 0, 2 ], 0); }); it('TINY-6559: Press Shift+Enter in blockquote', () => { const editor = hook.editor(); editor.options.set('end_container_on_empty_block', true); editor.setContent('

Line 1

Line 2

'); TinySelections.setCursor(editor, [ 0, 1 ], 1); insertNewline(editor, { shiftKey: true }); TinyAssertions.assertContent(editor, '

Line 1

Line 2

'); TinyAssertions.assertSelection(editor, [ 0, 1 ], 2, [ 0, 1 ], 2); }); it('TINY-6559: Press Enter twice in blockquote', () => { const editor = hook.editor(); editor.options.set('end_container_on_empty_block', true); editor.setContent('

Line 1

Line 2

'); TinySelections.setCursor(editor, [ 0, 1 ], 1); insertNewline(editor, { }); insertNewline(editor, { }); TinyAssertions.assertContent(editor, '

Line 1

Line 2

 

'); TinyAssertions.assertSelection(editor, [ 1 ], 0, [ 1 ], 0); }); it('TINY-6559: Press Enter twice in blockquote while between two lines', () => { const editor = hook.editor(); editor.options.set('end_container_on_empty_block', true); editor.setContent('

Line 1

Line 2

'); TinySelections.setCursor(editor, [ 0, 0 ], 1); insertNewline(editor, { }); insertNewline(editor, { }); TinyAssertions.assertContent(editor, '

Line 1

 

Line 2

'); TinyAssertions.assertSelection(editor, [ 1 ], 0, [ 1 ], 0); }); it('TINY-6559: Press Enter twice in a div', () => { const editor = hook.editor(); editor.options.set('end_container_on_empty_block', true); editor.setContent('

Line 1

Line 2

'); TinySelections.setCursor(editor, [ 0, 1 ], 1); insertNewline(editor, { }); insertNewline(editor, { }); TinyAssertions.assertContent(editor, '

Line 1

Line 2

 

'); TinyAssertions.assertSelection(editor, [ 1 ], 0, [ 1 ], 0); }); it('TINY-6559: Press Enter twice in a section', () => { const editor = hook.editor(); editor.setContent('

Line 1

Line 2

'); TinySelections.setCursor(editor, [ 0, 1 ], 1); insertNewline(editor, { }); insertNewline(editor, { }); TinyAssertions.assertContent(editor, '

Line 1

Line 2

 

'); TinyAssertions.assertSelection(editor, [ 1 ], 0, [ 1 ], 0); }); }); context('Is set to false', () => { it('TINY-6559: Press Enter in blockquote', () => { const editor = hook.editor(); editor.options.set('end_container_on_empty_block', false); editor.setContent('

Line 1

Line 2

'); TinySelections.setCursor(editor, [ 0, 1 ], 1); insertNewline(editor, { }); TinyAssertions.assertContent(editor, '

Line 1

Line 2

 

'); TinyAssertions.assertSelection(editor, [ 0, 2 ], 0, [ 0, 2 ], 0); }); it('TINY-6559: Press Shift+Enter in blockquote', () => { const editor = hook.editor(); editor.options.set('end_container_on_empty_block', false); editor.setContent('

Line 1

Line 2

'); TinySelections.setCursor(editor, [ 0, 1 ], 1); insertNewline(editor, { shiftKey: true }); TinyAssertions.assertContent(editor, '

Line 1

Line 2

'); TinyAssertions.assertSelection(editor, [ 0, 1 ], 2, [ 0, 1 ], 2); }); it('TINY-6559: Press Enter twice in blockquote', () => { const editor = hook.editor(); editor.options.set('end_container_on_empty_block', false); editor.setContent('

Line 1

Line 2

'); TinySelections.setCursor(editor, [ 0, 1 ], 1); insertNewline(editor, { }); insertNewline(editor, { }); TinyAssertions.assertContent(editor, '

Line 1

Line 2

 

 

'); TinyAssertions.assertSelection(editor, [ 0, 3 ], 0, [ 0, 3 ], 0); }); it('TINY-6559: Press Enter twice in blockquote while between two lines', () => { const editor = hook.editor(); editor.options.set('end_container_on_empty_block', false); editor.setContent('

Line 1

Line 2

'); TinySelections.setCursor(editor, [ 0, 0 ], 1); insertNewline(editor, { }); insertNewline(editor, { }); TinyAssertions.assertContent(editor, '

Line 1

 

 

Line 2

'); TinyAssertions.assertSelection(editor, [ 0, 2 ], 0, [ 0, 2 ], 0); }); it('TINY-6559: Press Enter twice in a div', () => { const editor = hook.editor(); editor.options.set('end_container_on_empty_block', false); editor.setContent('

Line 1

Line 2

'); TinySelections.setCursor(editor, [ 0, 1 ], 1); insertNewline(editor, { }); insertNewline(editor, { }); TinyAssertions.assertContent(editor, '

Line 1

Line 2

 

 

'); TinyAssertions.assertSelection(editor, [ 0, 3 ], 0, [ 0, 3 ], 0); }); it('TINY-6559: Press Enter twice in a section', () => { const editor = hook.editor(); editor.setContent('

Line 1

Line 2

'); TinySelections.setCursor(editor, [ 0, 1 ], 1); insertNewline(editor, { }); insertNewline(editor, { }); TinyAssertions.assertContent(editor, '

Line 1

Line 2

 

 

'); TinyAssertions.assertSelection(editor, [ 0, 3 ], 0, [ 0, 3 ], 0); }); }); }); context('TINY-8458: newline_behavior "block"', () => { before(() => { hook.editor().options.set('newline_behavior', 'block'); }); after(() => { hook.editor().options.unset('newline_behavior'); }); it('Split block in the middle', () => { const editor = hook.editor(); editor.setContent('

ab

'); TinySelections.setCursor(editor, [ 0, 0 ], 1); insertNewline(editor, { }); TinyAssertions.assertContent(editor, '

a

b

'); TinyAssertions.assertSelection(editor, [ 1, 0 ], 0, [ 1, 0 ], 0); }); it('Split block in the middle with shift+enter', () => { const editor = hook.editor(); editor.setContent('

ab

'); TinySelections.setCursor(editor, [ 0, 0 ], 1); insertNewline(editor, { shiftKey: true }); TinyAssertions.assertContent(editor, '

a

b

'); TinyAssertions.assertSelection(editor, [ 1, 0 ], 0, [ 1, 0 ], 0); }); context('ignores br_newline_selector', () => { before(() => { hook.editor().options.set('br_newline_selector', 'p'); }); after(() => { hook.editor().options.unset('br_newline_selector'); }); it('Insert newline where br is forced', () => { const editor = hook.editor(); editor.setContent('

ab

'); TinySelections.setCursor(editor, [ 0, 0 ], 1); insertNewline(editor, { }); editor.nodeChanged(); TinyAssertions.assertContent(editor, '

a

b

'); }); }); context('does not ignore no_newline_selector', () => { before(() => { hook.editor().options.set('no_newline_selector', 'p'); }); after(() => { hook.editor().options.unset('no_newline_selector'); }); it('Insert newline where newline is blocked', () => { const editor = hook.editor(); editor.setContent('

ab

'); TinySelections.setCursor(editor, [ 0, 0 ], 1); insertNewline(editor, { }); editor.nodeChanged(); TinyAssertions.assertContent(editor, '

ab

'); }); }); }); context('TINY-8458: newline_behavior "linebreak"', () => { before(() => { hook.editor().options.set('newline_behavior', 'linebreak'); }); after(() => { hook.editor().options.unset('newline_behavior'); }); it('Split block in the middle', () => { const editor = hook.editor(); editor.setContent('

ab

'); TinySelections.setCursor(editor, [ 0, 0 ], 1); insertNewline(editor, { }); TinyAssertions.assertContent(editor, '

a
b

'); TinyAssertions.assertSelection(editor, [ 0 ], 2, [ 0 ], 2); }); it('Split block in the middle with shift+enter', () => { const editor = hook.editor(); editor.setContent('

ab

'); TinySelections.setCursor(editor, [ 0, 0 ], 1); insertNewline(editor, { shiftKey: true }); TinyAssertions.assertContent(editor, '

a
b

'); TinyAssertions.assertSelection(editor, [ 0 ], 2, [ 0 ], 2); }); context('ignores br_newline_selector', () => { before(() => { hook.editor().options.set('br_newline_selector', 'p'); }); after(() => { hook.editor().options.unset('br_newline_selector'); }); it('Insert newline where br is not forced', () => { const editor = hook.editor(); editor.setContent('
ab
'); TinySelections.setCursor(editor, [ 0, 0 ], 1); insertNewline(editor, { }); editor.nodeChanged(); TinyAssertions.assertContent(editor, '
a
b
'); }); }); context('does not ignore no_newline_selector', () => { before(() => { hook.editor().options.set('no_newline_selector', 'p'); }); after(() => { hook.editor().options.unset('no_newline_selector'); }); it('Insert newline where newline is blocked', () => { const editor = hook.editor(); editor.setContent('

ab

'); TinySelections.setCursor(editor, [ 0, 0 ], 1); insertNewline(editor, { }); editor.nodeChanged(); TinyAssertions.assertContent(editor, '

ab

'); }); }); }); context('TINY-8458: newline_behavior "invert"', () => { before(() => { hook.editor().options.set('newline_behavior', 'invert'); }); after(() => { hook.editor().options.unset('newline_behavior'); }); it('Split block in the middle', () => { const editor = hook.editor(); editor.setContent('

ab

'); TinySelections.setCursor(editor, [ 0, 0 ], 1); insertNewline(editor, { }); TinyAssertions.assertContent(editor, '

a
b

'); TinyAssertions.assertSelection(editor, [ 0 ], 2, [ 0 ], 2); }); it('Split block in the middle with shift+enter', () => { const editor = hook.editor(); editor.setContent('

ab

'); TinySelections.setCursor(editor, [ 0, 0 ], 1); insertNewline(editor, { shiftKey: true }); TinyAssertions.assertContent(editor, '

a

b

'); TinyAssertions.assertSelection(editor, [ 1, 0 ], 0, [ 1, 0 ], 0); }); context('inverts br_newline_selector', () => { before(() => { hook.editor().options.set('br_newline_selector', 'p'); }); after(() => { hook.editor().options.unset('br_newline_selector'); }); it('Insert newline where br is forced', () => { const editor = hook.editor(); editor.setContent('

ab

'); TinySelections.setCursor(editor, [ 0, 0 ], 1); insertNewline(editor, { }); editor.nodeChanged(); TinyAssertions.assertContent(editor, '

a

b

'); }); it('Insert newline where br is not forced', () => { const editor = hook.editor(); editor.setContent('
ab
'); TinySelections.setCursor(editor, [ 0, 0 ], 1); insertNewline(editor, { }); editor.nodeChanged(); TinyAssertions.assertContent(editor, '
a
b
'); }); }); context('does not ignore no_newline_selector', () => { before(() => { hook.editor().options.set('no_newline_selector', 'p'); }); after(() => { hook.editor().options.unset('no_newline_selector'); }); it('Insert newline where newline is blocked', () => { const editor = hook.editor(); editor.setContent('

ab

'); TinySelections.setCursor(editor, [ 0, 0 ], 1); insertNewline(editor, { }); editor.nodeChanged(); TinyAssertions.assertContent(editor, '

ab

'); }); }); }); });