|
|
@@ -3,7 +3,7 @@
|
|
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
|
*/
|
|
|
|
|
|
-/* globals document */
|
|
|
+/* globals document, console */
|
|
|
|
|
|
import InlineEditorUI from '../src/inlineeditorui';
|
|
|
import InlineEditorUIView from '../src/inlineeditoruiview';
|
|
|
@@ -19,7 +19,6 @@ import ElementApiMixin from '@ckeditor/ckeditor5-core/src/editor/utils/elementap
|
|
|
import RootElement from '@ckeditor/ckeditor5-engine/src/model/rootelement';
|
|
|
|
|
|
import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
|
|
|
-import log from '@ckeditor/ckeditor5-utils/src/log';
|
|
|
|
|
|
import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset';
|
|
|
import { describeMemoryUsage, testMemoryUsage } from '@ckeditor/ckeditor5-core/tests/_utils/memory';
|
|
|
@@ -36,7 +35,7 @@ describe( 'InlineEditor', () => {
|
|
|
|
|
|
document.body.appendChild( editorElement );
|
|
|
|
|
|
- testUtils.sinon.stub( log, 'warn' ).callsFake( () => {} );
|
|
|
+ testUtils.sinon.stub( console, 'warn' ).callsFake( () => {} );
|
|
|
} );
|
|
|
|
|
|
afterEach( () => {
|
|
|
@@ -84,6 +83,23 @@ describe( 'InlineEditor', () => {
|
|
|
expect( editor.editing.view.getDomRoot() ).to.equal( editor.ui.element );
|
|
|
} );
|
|
|
} );
|
|
|
+
|
|
|
+ // See: https://github.com/ckeditor/ckeditor5/issues/746
|
|
|
+ it( 'should throw when trying to create the editor using the same source element more than once', done => {
|
|
|
+ InlineEditor.create( editorElement )
|
|
|
+ .then(
|
|
|
+ () => {
|
|
|
+ expect.fail( 'Inline editor should not initialize on an element already used by other instance.' );
|
|
|
+ },
|
|
|
+ err => {
|
|
|
+ assertCKEditorError( err,
|
|
|
+ /^editor-source-element-already-used/
|
|
|
+ );
|
|
|
+ }
|
|
|
+ )
|
|
|
+ .then( done )
|
|
|
+ .catch( done );
|
|
|
+ } );
|
|
|
} );
|
|
|
|
|
|
describe( 'create()', () => {
|
|
|
@@ -118,6 +134,9 @@ describe( 'InlineEditor', () => {
|
|
|
} );
|
|
|
|
|
|
it( 'should not require config object', () => {
|
|
|
+ const editorElement = document.createElement( 'div' );
|
|
|
+ editorElement.innerHTML = '<p><strong>foo</strong> bar</p>';
|
|
|
+
|
|
|
// Just being safe with `builtinPlugins` static property.
|
|
|
class CustomInlineEditor extends InlineEditor {}
|
|
|
CustomInlineEditor.builtinPlugins = [ Paragraph, Bold ];
|
|
|
@@ -127,6 +146,9 @@ describe( 'InlineEditor', () => {
|
|
|
expect( newEditor.getData() ).to.equal( '<p><strong>foo</strong> bar</p>' );
|
|
|
|
|
|
return newEditor.destroy();
|
|
|
+ } )
|
|
|
+ .then( () => {
|
|
|
+ editorElement.remove();
|
|
|
} );
|
|
|
} );
|
|
|
|
|
|
@@ -141,13 +163,18 @@ describe( 'InlineEditor', () => {
|
|
|
} );
|
|
|
|
|
|
it( 'initializes with config.initialData', () => {
|
|
|
+ const editorElement = document.createElement( 'div' );
|
|
|
+ editorElement.innerHTML = '<p>Hello world!</p>';
|
|
|
+
|
|
|
return InlineEditor.create( editorElement, {
|
|
|
initialData: '<p>Hello world!</p>',
|
|
|
plugins: [ Paragraph ]
|
|
|
} ).then( editor => {
|
|
|
expect( editor.getData() ).to.equal( '<p>Hello world!</p>' );
|
|
|
|
|
|
- editor.destroy();
|
|
|
+ return editor.destroy();
|
|
|
+ } ).then( () => {
|
|
|
+ editorElement.remove();
|
|
|
} );
|
|
|
} );
|
|
|
|