import { describe, it } from '@ephox/bedrock-client'; import { Unicode } from '@ephox/katamari'; import { TinyHooks } from '@ephox/wrap-mcagar'; import { assert } from 'chai'; import Editor from 'tinymce/core/api/Editor'; import { isVisuallyEmpty } from 'tinymce/core/content/Placeholder'; describe('browser.tinymce.core.content.PlaceholderVisuallyEmptyTest', () => { const hook = TinyHooks.bddSetupLight({ base_url: '/project/tinymce/js/tinymce' }, []); const assertEmpty = (label: string, editor: Editor, expected: boolean) => { const body = editor.getBody(); assert.equal(isVisuallyEmpty(editor.dom, body, 'p'), expected, label); }; const testEmpty = (editor: Editor, content: string) => { editor.setContent(content, { format: 'raw' }); assertEmpty(`Check "${content}" is empty`, editor, true); }; const testNotEmpty = (editor: Editor, content: string) => { editor.setContent(content, { format: 'raw' }); assertEmpty(`Check "${content}" is not empty`, editor, false); }; it('TINY-3917: Check content is visually empty', () => { const editor = hook.editor(); testEmpty(editor, '

'); testEmpty(editor, '


'); testEmpty(editor, '


'); testEmpty(editor, '

' + Unicode.zeroWidth + '

'); testEmpty(editor, '


'); }); it('TINY-3917: Check content is NOT visually empty', () => { const editor = hook.editor(); testNotEmpty(editor, '

Text

'); testNotEmpty(editor, '

' + Unicode.nbsp + '

'); testNotEmpty(editor, '



'); testNotEmpty(editor, '
'); testNotEmpty(editor, '
'); testNotEmpty(editor, '


'); testNotEmpty(editor, '

Link

'); testNotEmpty(editor, '

Link

'); testNotEmpty(editor, '
'); testNotEmpty(editor, '

'); testNotEmpty(editor, '
'); testNotEmpty(editor, '
test
'); testNotEmpty(editor, '

' + Unicode.nbsp + '

'); }); });