import { context, describe, it } from '@ephox/bedrock-client'; import { TinyAssertions, TinyHooks, TinySelections } from '@ephox/wrap-mcagar'; import { assert } from 'chai'; import Editor from 'tinymce/core/api/Editor'; import { SetContentEvent } from 'tinymce/core/api/EventTypes'; import { EditorEvent } from 'tinymce/core/api/util/EventDispatcher'; import * as InsertContent from 'tinymce/core/content/InsertContent'; describe('browser.tinymce.core.content.InsertContentTest', () => { const hook = TinyHooks.bddSetupLight({ add_unload_trigger: false, disable_nodechange: true, entities: 'raw', indent: false, base_url: '/project/tinymce/js/tinymce', custom_elements: '~foo-bar' }, [], true); it('TBA: insertAtCaret - i inside text, converts to em', () => { const editor = hook.editor(); editor.setContent('

1234

'); TinySelections.setSelection(editor, [ 0, 0 ], 2, [ 0, 0 ], 2); InsertContent.insertAtCaret(editor, 'a'); TinyAssertions.assertContent(editor, '

12a34

'); }); it('TBA: insertAtCaret - ul at beginning of li', () => { const editor = hook.editor(); editor.setContent(''); TinySelections.setSelection(editor, [ 0, 0, 0 ], 0, [ 0, 0, 0 ], 0); InsertContent.insertAtCaret(editor, { content: '', paste: true }); TinyAssertions.assertContent(editor, ''); TinyAssertions.assertSelection(editor, [ 0, 1, 0 ], 0, [ 0, 1, 0 ], 0); }); it('TBA: insertAtCaret - ul with multiple items at beginning of li', () => { const editor = hook.editor(); editor.setContent(''); TinySelections.setSelection(editor, [ 0, 0, 0 ], 0, [ 0, 0, 0 ], 0); InsertContent.insertAtCaret(editor, { content: '', paste: true }); TinyAssertions.assertContent(editor, ''); TinyAssertions.assertSelection(editor, [ 0, 2, 0 ], 0, [ 0, 2, 0 ], 0); }); it('TBA: insertAtCaret - ul at end of li', () => { const editor = hook.editor(); editor.setContent(''); TinySelections.setSelection(editor, [ 0, 0, 0 ], 2, [ 0, 0, 0 ], 2); InsertContent.insertAtCaret(editor, { content: '', paste: true }); TinyAssertions.assertContent(editor, ''); TinyAssertions.assertSelection(editor, [ 0, 1, 0 ], 1, [ 0, 1, 0 ], 1); }); it('TBA: insertAtCaret - ul with multiple items at end of li', () => { const editor = hook.editor(); editor.setContent(''); TinySelections.setSelection(editor, [ 0, 0, 0 ], 2, [ 0, 0, 0 ], 2); InsertContent.insertAtCaret(editor, { content: '', paste: true }); TinyAssertions.assertContent(editor, ''); TinyAssertions.assertSelection(editor, [ 0, 3, 0 ], 1, [ 0, 3, 0 ], 1); }); it('TBA: insertAtCaret - ul with multiple items in middle of li', () => { const editor = hook.editor(); editor.setContent(''); TinySelections.setSelection(editor, [ 0, 0, 0 ], 1, [ 0, 0, 0 ], 1); InsertContent.insertAtCaret(editor, { content: '', paste: true }); TinyAssertions.assertContent(editor, ''); TinyAssertions.assertSelection(editor, [ 0, 2, 0 ], 1, [ 0, 2, 0 ], 1); }); it('TBA: insertAtCaret - ul in middle of li with formatting', () => { const editor = hook.editor(); editor.setContent(''); TinySelections.setSelection(editor, [ 0, 0, 0, 0, 0 ], 1, [ 0, 0, 0, 0, 0 ], 1); InsertContent.insertAtCaret(editor, { content: '', paste: true }); TinyAssertions.assertContent(editor, ''); TinyAssertions.assertSelection(editor, [ 0, 1, 0 ], 1, [ 0, 1, 0 ], 1); }); it('TBA: insertAtCaret - ul with trailing empty block in middle of li', () => { const editor = hook.editor(); editor.setContent(''); TinySelections.setSelection(editor, [ 0, 0, 0 ], 1, [ 0, 0, 0 ], 1); InsertContent.insertAtCaret(editor, { content: '

\u00a0

', paste: true }); TinyAssertions.assertContent(editor, ''); TinyAssertions.assertSelection(editor, [ 0, 2, 0 ], 1, [ 0, 2, 0 ], 1); }); it('TBA: insertAtCaret - ul at beginning of li with empty end li', () => { const editor = hook.editor(); editor.setContent(''); TinySelections.setSelection(editor, [ 0, 0, 0 ], 0, [ 0, 0, 0 ], 0); InsertContent.insertAtCaret(editor, { content: '', paste: true }); TinyAssertions.assertContent(editor, ''); TinyAssertions.assertSelection(editor, [ 0, 1, 0 ], 0, [ 0, 1, 0 ], 0); }); it('TBA: insertAtCaret - merge inline elements', () => { const editor = hook.editor(); editor.setContent('

abc

'); TinySelections.setSelection(editor, [ 0, 0, 0, 0 ], 1, [ 0, 0, 0, 0 ], 1); InsertContent.insertAtCaret(editor, { content: '123', merge: true }); TinyAssertions.assertContent(editor, '

a123bc

'); }); it('TINY-1231: insertAtCaret - list into empty table cell with invalid contents', () => { const editor = hook.editor(); editor.setContent('

', { format: 'raw' }); TinySelections.setSelection(editor, [ 0, 0, 0, 0 ], 0, [ 0, 0, 0, 0 ], 0); InsertContent.insertAtCaret(editor, { content: '', paste: true }); TinyAssertions.assertContent(editor, '
  • a
'); TinyAssertions.assertSelection(editor, [ 0, 0, 0, 0, 0, 0, 0 ], 1, [ 0, 0, 0, 0, 0, 0, 0 ], 1); }); it('TBA: insertAtCaret - content into single table cell with all content selected', () => { const editor = hook.editor(); editor.setContent('
content
', { format: 'raw' }); TinySelections.setSelection(editor, [ 0, 0, 0, 0, 0 ], 0, [ 0, 0, 0, 0, 0 ], 7); InsertContent.insertAtCaret(editor, { content: 'replace', paste: true }); TinyAssertions.assertContent(editor, '
replace
'); }); it('TBA: insertAtCaret - empty paragraph pad the empty element with br on insert and nbsp on save', () => { const editor = hook.editor(); editor.setContent('

ab

'); TinySelections.setSelection(editor, [ 0, 0 ], 1, [ 0, 0 ], 1); InsertContent.insertAtCaret(editor, { content: '

', merge: true }); assert.equal(editor.getContent({ format: 'raw' }), '

a


b

', 'Raw content'); TinyAssertions.assertContent(editor, '

a

\u00a0

b

'); }); it('TBA: insertAtCaret prevent default of beforeSetContent', () => { const editor = hook.editor(); let args: EditorEvent | undefined; const handler = (e: EditorEvent) => { if (e.selection === true) { e.preventDefault(); e.content = '

b

'; editor.getBody().innerHTML = '

c

'; } }; const collector = (e: EditorEvent) => { args = e; }; editor.on('BeforeSetContent', handler); editor.on('SetContent', collector); editor.setContent('

a

'); editor.selection.setCursorLocation(editor.dom.select('p')[0].firstChild as Text, 0); InsertContent.insertAtCaret(editor, { content: '

b

', paste: true }); TinyAssertions.assertContent(editor, '

c

'); assert.equal(args?.content, '

b

'); assert.equal(args?.type, 'setcontent'); assert.isTrue(args?.paste); editor.off('BeforeSetContent', handler); editor.on('BeforeSetContent', collector); }); it('TBA: insertAtCaret - text content at a text node with a trailing nbsp character', () => { const editor = hook.editor(); editor.setContent('

abc 

'); TinySelections.setSelection(editor, [ 0, 0 ], 4, [ 0, 0 ], 4); InsertContent.insertAtCaret(editor, 'd'); TinyAssertions.assertContent(editor, '

abc d

'); }); it('TBA: insertAtCaret - html at a text node with a trailing nbsp character', () => { const editor = hook.editor(); editor.setContent('

abc 

'); TinySelections.setSelection(editor, [ 0, 0 ], 4, [ 0, 0 ], 4); InsertContent.insertAtCaret(editor, 'd'); TinyAssertions.assertContent(editor, '

abc d

'); }); it('TBA: insertAtCaret - text in the middle of a text node with nbsp characters', () => { const editor = hook.editor(); editor.setContent('

a c

'); TinySelections.setSelection(editor, [ 0, 0 ], 2, [ 0, 0 ], 2); InsertContent.insertAtCaret(editor, 'b'); TinyAssertions.assertContent(editor, '

a bc

'); }); it('TBA: insertAtCaret - html in the middle of a text node with nbsp characters', () => { const editor = hook.editor(); editor.setContent('

a c

'); TinySelections.setSelection(editor, [ 0, 0 ], 2, [ 0, 0 ], 2); InsertContent.insertAtCaret(editor, 'b'); TinyAssertions.assertContent(editor, '

a bc

'); }); it('TINY-5966: insertAtCaret - text content at a text node with a leading nbsp character', () => { const editor = hook.editor(); editor.setContent('

 abc

'); TinySelections.setSelection(editor, [ 0, 0 ], 0, [ 0, 0 ], 0); InsertContent.insertAtCaret(editor, 'd'); TinyAssertions.assertContent(editor, '

d abc

'); }); it('TINY-5966: insertAtCaret - html at a text node with a leading nbsp character', () => { const editor = hook.editor(); editor.setContent('

 abc

'); TinySelections.setSelection(editor, [ 0, 0 ], 0, [ 0, 0 ], 0); InsertContent.insertAtCaret(editor, 'd'); TinyAssertions.assertContent(editor, '

d abc

'); }); it('TINY-5966: insertAtCaret - text content at a text node with a only a nbsp character', () => { const editor = hook.editor(); editor.setContent('

 

', { format: 'raw' }); TinySelections.setSelection(editor, [ 0, 0 ], 1, [ 0, 0 ], 1); InsertContent.insertAtCaret(editor, 'a'); TinyAssertions.assertContent(editor, '

\u00a0a

'); editor.setContent('

 

', { format: 'raw' }); TinySelections.setSelection(editor, [ 0, 0 ], 0, [ 0, 0 ], 0); InsertContent.insertAtCaret(editor, 'a'); TinyAssertions.assertContent(editor, '

a\u00a0

'); }); it('TINY-5966: insertAtCaret - html at a text node with a only a nbsp character', () => { const editor = hook.editor(); editor.setContent('

 

', { format: 'raw' }); TinySelections.setSelection(editor, [ 0, 0 ], 1, [ 0, 0 ], 1); InsertContent.insertAtCaret(editor, 'a'); TinyAssertions.assertContent(editor, '

\u00a0a

'); editor.setContent('

 

', { format: 'raw' }); TinySelections.setSelection(editor, [ 0, 0 ], 0, [ 0, 0 ], 0); InsertContent.insertAtCaret(editor, 'a'); TinyAssertions.assertContent(editor, '

a\u00a0

'); }); it('TINY-5966: insertAtCaret - text content at a empty block with leading/trailing spaces', () => { const editor = hook.editor(); editor.setContent('

'); TinySelections.setSelection(editor, [ 0, 0 ], 0, [ 0, 0 ], 0); InsertContent.insertAtCaret(editor, ' a '); TinyAssertions.assertContent(editor, '

\u00a0a\u00a0

'); }); it('TINY-5966: insertAtCaret - text content at a text node between 2 spaces with leading/trailing spaces', () => { const editor = hook.editor(); editor.setContent('

a  c

'); TinySelections.setSelection(editor, [ 0, 0 ], 2, [ 0, 0 ], 2); InsertContent.insertAtCaret(editor, ' b '); TinyAssertions.assertContent(editor, '

a\u00a0 b\u00a0 c

'); }); it('TINY-5966: insertAtCaret - text content at a text node before br', () => { const editor = hook.editor(); editor.setContent('

a
b

'); TinySelections.setSelection(editor, [ 0, 0 ], 1, [ 0, 0 ], 1); InsertContent.insertAtCaret(editor, ' c '); TinyAssertions.assertContent(editor, '

a c\u00a0
b

'); editor.setContent('


 b

'); TinySelections.setSelection(editor, [ 0, 0 ], 2, [ 0, 0 ], 2); InsertContent.insertAtCaret(editor, 'c'); TinyAssertions.assertContent(editor, '

a c
\u00a0b

'); }); it('TINY-5966: insertAtCaret - html content at a text node before br', () => { const editor = hook.editor(); editor.setContent('


 b

'); TinySelections.setSelection(editor, [ 0, 0 ], 2, [ 0, 0 ], 2); InsertContent.insertAtCaret(editor, 'c'); TinyAssertions.assertContent(editor, '

a c
\u00a0b

'); }); it('TINY-5966: insertAtCaret - text content at a text node after br', () => { const editor = hook.editor(); editor.setContent('

a
b

'); TinySelections.setSelection(editor, [ 0, 2 ], 0, [ 0, 2 ], 0); InsertContent.insertAtCaret(editor, ' c '); TinyAssertions.assertContent(editor, '

a
\u00a0c b

'); editor.setContent('


 b

'); TinySelections.setSelection(editor, [ 0, 2 ], 0, [ 0, 2 ], 0); InsertContent.insertAtCaret(editor, 'c'); TinyAssertions.assertContent(editor, '

a\u00a0
c b

'); }); it('TINY-5966: insertAtCaret - html content at a text node after br', () => { const editor = hook.editor(); editor.setContent('


 b

'); TinySelections.setSelection(editor, [ 0, 2 ], 0, [ 0, 2 ], 0); InsertContent.insertAtCaret(editor, 'c'); TinyAssertions.assertContent(editor, '

a\u00a0
c b

'); }); it('TINY-5966: insertAtCaret - text content with spaces in pre', () => { const editor = hook.editor(); editor.setContent('
');
    TinySelections.setSelection(editor, [ 0, 0 ], 0, [ 0, 0 ], 0);
    InsertContent.insertAtCaret(editor, '  a  ');
    TinyAssertions.assertContent(editor, '
  a  
'); editor.setContent('
a b c
'); TinySelections.setSelection(editor, [ 0, 0 ], 2, [ 0, 0 ], 3); InsertContent.insertAtCaret(editor, ' b '); TinyAssertions.assertContent(editor, '
a  b  c
'); }); it('TINY-5966: insertAtCaret - html content with spaces in pre', () => { const editor = hook.editor(); editor.setContent('
');
    TinySelections.setSelection(editor, [ 0, 0 ], 0, [ 0, 0 ], 0);
    InsertContent.insertAtCaret(editor, '  a  ');
    TinyAssertions.assertContent(editor, '
  a  
'); }); it('TINY-8860: insertAtCaret - insert pre block on empty p', () => { const editor = hook.editor(); editor.setContent('

'); TinySelections.setCursor(editor, [ 0 ], 0); InsertContent.insertAtCaret(editor, { content: '
abc
', paste: true }); TinyAssertions.assertContent(editor, '
abc
'); }); it('TINY-8860: insertAtCaret - insert styled pre block', () => { const editor = hook.editor(); editor.setContent('
abc
'); TinySelections.setCursor(editor, [ 0, 0 ], 1); InsertContent.insertAtCaret(editor, { content: '
123
', paste: true }); TinyAssertions.assertContent(editor, '
a123bc
'); }); it('TINY-8860: insertAtCaret - insert plain pre in styled pre block', () => { const editor = hook.editor(); editor.setContent('
123abc
'); TinySelections.setCursor(editor, [ 0, 0, 0 ], 1); InsertContent.insertAtCaret(editor, { content: '
abc
', paste: true }); TinyAssertions.assertContent(editor, '
1abc23abc
'); }); it('TINY-8860: insertAtCaret - insert styled pre in differently styled pre block', () => { const editor = hook.editor(); editor.setContent('
1abc23abc
'); TinySelections.setCursor(editor, [ 0, 0, 0 ], 5); InsertContent.insertAtCaret(editor, { content: '
abc
', paste: true }); TinyAssertions.assertContent(editor, '
1abc2abc3abc
'); }); it('TINY-8860: insertAtCaret - insert cef pre in pre block', () => { const editor = hook.editor(); editor.setContent('
abc
'); TinySelections.setCursor(editor, [ 0, 0 ], 1); InsertContent.insertAtCaret(editor, { content: '
123
', paste: true }); TinyAssertions.assertContent(editor, '
a
123
bc
'); }); it('TINY-8860: insertAtCaret - insert pre over cef pre block', () => { const editor = hook.editor(); editor.setContent('
abc
'); TinySelections.setSelection(editor, [], 1, [], 2); InsertContent.insertAtCaret(editor, { content: '
123
', paste: true }); TinyAssertions.assertContent(editor, '
123
'); }); it('TINY-6263: insertAtCaret - merge font-size spans', () => { const editor = hook.editor(); editor.setContent(''); TinySelections.setCursor(editor, [ 0 ], 0); InsertContent.insertAtCaret(editor, { content: '

' + '' + '' + '' + 'test' + '' + '' + '' + '

', merge: true }); TinyAssertions.assertContent(editor, '

' + '' + '' + 'test' + '' + '' + '

'); }); it('TINY-6263: insertAtCaret - merge spans with similar node in-between', () => { const editor = hook.editor(); editor.setContent(''); TinySelections.setCursor(editor, [ 0 ], 0); InsertContent.insertAtCaret(editor, { content: '

' + '' + '' + 'test' + '' + '' + '

', merge: true }); TinyAssertions.assertContent(editor, '

' + '' + 'test' + '' + '

'); }); it('TINY-6263: insertAtCaret - merge font colors with other surrounding inline elements in-between', () => { const editor = hook.editor(); editor.setContent(''); TinySelections.setCursor(editor, [ 0 ], 0); InsertContent.insertAtCaret(editor, { content: '

' + '' + '' + '' + 'red' + 'yellow' + '' + '' + 'blue' + '' + '' + '' + '' + '' + '

', merge: true }); TinyAssertions.assertContent(editor, '

' + '' + '' + 'red' + 'yellow' + 'blue' + '' + '' + '

'); }); it('TINY-6263: insertAtCaret - spans with non-inheritable styles should not merge', () => { const editor = hook.editor(); editor.setContent(''); TinySelections.setCursor(editor, [ 0 ], 0); InsertContent.insertAtCaret(editor, { content: '

' + '' + '' + 'test' + '' + '' + '

' + '

' + '' + '' + 'test' + '' + '' + '

', merge: true }); TinyAssertions.assertContent(editor, '

' + '' + '' + 'test' + '' + '' + '

' + '

' + '' + '' + 'test' + '' + '' + '

'); }); it('TINY-6263: insertAtCaret - shorthand styles with longhand properties in-between', () => { const editor = hook.editor(); editor.setContent(''); TinySelections.setCursor(editor, [ 0 ], 0); InsertContent.insertAtCaret(editor, { content: '

' + '' + '' + 'test' + '' + '' + '

' + '

' + '' + '' + 'test' + '' + '' + '

', merge: true }); TinyAssertions.assertContent(editor, '

' + '' + 'test' + '' + '

' + '

' + '' + '' + 'test' + '' + '' + '

'); }); it('TINY-6263: insertAtCaret - longhand style spans with shorthand style span in-between', () => { const editor = hook.editor(); editor.setContent(''); TinySelections.setCursor(editor, [ 0 ], 0); InsertContent.insertAtCaret(editor, { content: '

' + '' + '' + 'test' + '' + '' + '' + '' + '

' + '

' + '' + '' + 'test' + '' + '' + '

', merge: true }); TinyAssertions.assertContent(editor, '

' + '' + 'test' + '' + '

' + '

' + '' + '' + 'test' + '' + '' + '

'); }); it('TINY-7756: Content with nested elements that will be invalid if parent is unwrapped', () => { const editor = hook.editor(); editor.setContent(''); TinySelections.setCursor(editor, [ 0 ], 0); InsertContent.insertAtCaret( editor, '' + '' + '
' ); TinyAssertions.assertContent(editor, ''); editor.setContent(''); TinySelections.setCursor(editor, [ 0 ], 0); InsertContent.insertAtCaret( editor, '' + '' + '' + '' + '' + '' + '
' + '' + '' + '' + '' + '' + '
' ); TinyAssertions.assertContent( editor, '' + '' + '' + '' + '' + '' + '
' + '' + '' + '' + '
' ); }); it('TINY-7842: Inserting content into a contenteditable=true block within a contenteditable=false parent', () => { const editor = hook.editor(); editor.setContent( '

some content to stop the fake caret rendering before the CEF element

' + '
' + '

Non editable content

' + '
' + '

Editablecontent

' + '
' + '
' ); TinySelections.setCursor(editor, [ 1, 1, 0, 0 ], 8); InsertContent.insertAtCaret(editor, ' pasted '); TinyAssertions.assertContent( editor, '

some content to stop the fake caret rendering before the CEF element

' + '
' + '

Non editable content

' + '
' + '

Editable pasted content

' + '
' + '
' ); TinyAssertions.assertCursor(editor, [ 1, 1, 0, 0 ], 16); }); it('TINY-8444: Inserting block content runs the node filters', () => { const editor = hook.editor(); editor.setContent('

Content

'); TinySelections.setCursor(editor, [ 0, 0 ], 3); let numNodesFiltered = 0; editor.parser.addNodeFilter('div', (nodes) => { numNodesFiltered += nodes.length; }); editor.insertContent('
inserted content
'); assert.equal(numNodesFiltered, 1, 'Node filters should have run'); TinyAssertions.assertContent(editor, '

Con

inserted content

tent

'); }); it('TINY-4784: An empty custom element should not be removed when inserted', () => { const editor = hook.editor(); editor.setContent('

'); editor.insertContent(''); TinyAssertions.assertContent(editor, '

'); }); it('TINY-9193: it should keep the caret in the same paragraph where insertion occurred', () => { const editor = hook.editor(); editor.setContent('

foo

barbaz

', { format: 'raw' }); TinySelections.setSelection(editor, [ 1 ], 0, [ 1 ], 1); editor.insertContent('X'); TinyAssertions.assertRawContent(editor, '

foo

Xbaz

'); }); context('Transparent blocks', () => { it('TINY-9172: Insert block anchor in regular block', () => { const editor = hook.editor(); editor.setContent('
a
'); TinySelections.setCursor(editor, [ 0, 0 ], 0); editor.insertContent('

b

'); TinyAssertions.assertContent(editor, '

b

a
'); assert.isTrue(editor.dom.select('a[data-mce-block="true"]').length === 1, 'Should have data-mce-block set to true'); }); it('TINY-9172: Insert block anchor in transparent block should split the block', () => { const editor = hook.editor(); editor.setContent('
ac
'); TinySelections.setCursor(editor, [ 0, 0, 0 ], 1); editor.insertContent('

b

'); TinyAssertions.assertContent(editor, '
a

b

c
'); }); it('TINY-9172: Insert inline anchor in anchor block should unwrap the inline anchor', () => { const editor = hook.editor(); editor.setContent('
ac
'); TinySelections.setCursor(editor, [ 0, 0, 0 ], 1); editor.insertContent('b'); TinyAssertions.assertContent(editor, '
abc
'); }); it('TINY-9172: Insert block in anchor should work and annotate the element with data-mce-block', () => { const editor = hook.editor(); editor.setContent('
ac
'); TinySelections.setCursor(editor, [ 0, 0, 0 ], 1); editor.insertContent('

b

'); TinyAssertions.assertContent(editor, '
a

b

c
'); assert.isTrue(editor.dom.select('a[data-mce-block="true"]').length === 1, 'Should have data-mce-block set to true'); }); it('TINY-9172: Insert block in regular anchor should annotate the block with data-mce-block', () => { const editor = hook.editor(); editor.setContent('
ac
'); TinySelections.setCursor(editor, [ 0, 0, 0 ], 1); editor.insertContent('

b

'); TinyAssertions.assertContent(editor, '
a

b

c
'); TinyAssertions.assertContentPresence(editor, { 'a[data-mce-block]': 1 }); }); it('TINY-9172: Insert block mixed with inlines in regular anchor should annotate the block with data-mce-block', () => { const editor = hook.editor(); editor.setContent('
ad
'); TinySelections.setCursor(editor, [ 0, 0, 0 ], 1); editor.insertContent('

b

c'); TinyAssertions.assertContent(editor, '
a

b

cd
'); TinyAssertions.assertContentPresence(editor, { 'a[data-mce-block]': 1 }); }); it('TINY-9232: Insert paragraphs in anchor inside paragraph should split the paragraph and anchor', () => { const editor = hook.editor(); editor.setContent('

ad

'); TinySelections.setCursor(editor, [ 0, 0, 0 ], 1); editor.insertContent('

b

c

'); TinyAssertions.assertContent(editor, '

a

b

c

d

'); }); }); context('Noneditable parents', () => { it('TINY-9462: insertContent in noneditable element should be a noop', () => { const editor = hook.editor(); const content = '
text
'; editor.setContent(content); // Shifted since fake caret is before div TinySelections.setSelection(editor, [ 1, 0 ], 1, [ 1, 0 ], 2); editor.insertContent('hello'); TinyAssertions.assertContent(editor, content); }); it('TINY-9462: insertContent in normal element in noneditable root should be a noop', () => { const editor = hook.editor(); const content = '
text
'; editor.getBody().contentEditable = 'false'; editor.setContent(content); TinySelections.setSelection(editor, [ 0, 0 ], 1, [ 0, 0 ], 2); editor.insertContent('hello'); TinyAssertions.assertContent(editor, content); editor.getBody().contentEditable = 'true'; }); it('TINY-9462: insertContent in editable element in noneditable root should insert content', () => { const editor = hook.editor(); editor.getBody().contentEditable = 'false'; editor.setContent('
text
'); TinySelections.setSelection(editor, [ 0, 0 ], 1, [ 0, 0 ], 2); editor.insertContent('hello'); TinyAssertions.assertContent(editor, '
thelloxt
'); editor.getBody().contentEditable = 'true'; }); }); });