Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Removed deprecated code.
Browse files Browse the repository at this point in the history
  • Loading branch information
f1ames committed Jan 22, 2019
1 parent 5dd2aa1 commit d9025cc
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 41 deletions.
11 changes: 0 additions & 11 deletions src/decouplededitor.js
Expand Up @@ -15,7 +15,6 @@ import DecoupledEditorUIView from './decouplededitoruiview';
import getDataFromElement from '@ckeditor/ckeditor5-utils/src/dom/getdatafromelement';
import setDataInElement from '@ckeditor/ckeditor5-utils/src/dom/setdatainelement';
import mix from '@ckeditor/ckeditor5-utils/src/mix';
import log from '@ckeditor/ckeditor5-utils/src/log';
import { isElement } from 'lodash-es';

/**
Expand Down Expand Up @@ -77,16 +76,6 @@ export default class DecoupledEditor extends Editor {
this.ui = new DecoupledEditorUI( this, new DecoupledEditorUIView( this.locale, this.sourceElement ) );
}

/**
* @inheritDoc
*/
get element() {
log.warn( 'deprecated-editor-element: The editor#element is deprecated.' );
// This editor has no single "main UI element". Its editable and toolbar are exposed separately and need
// to be added to the DOM manually by the consumer.
return null;
}

/**
* Destroys the editor instance, releasing all resources used by it.
*
Expand Down
11 changes: 10 additions & 1 deletion src/decouplededitorui.js
Expand Up @@ -71,7 +71,7 @@ export default class DecoupledEditorUI extends EditorUI {

this._editableElements.set( view.editable.name, view.editable.element );

this.focusTracker.add( this.view.editable.element );
this.focusTracker.add( view.editable.element );

this.view.toolbar.fillFromConfig( this._toolbarConfig.items, this.componentFactory );

Expand All @@ -84,4 +84,13 @@ export default class DecoupledEditorUI extends EditorUI {

this.fire( 'ready' );
}

/**
* @inheritDoc
*/
destroy() {
this._view.destroy();

super.destroy();
}
}
29 changes: 1 addition & 28 deletions tests/decouplededitor.js
Expand Up @@ -44,10 +44,6 @@ describe( 'DecoupledEditor', () => {
expect( testUtils.isMixed( DecoupledEditor, DataApiMixin ) ).to.be.true;
} );

it( 'implements the EditorWithUI interface', () => {
expect( editor.element ).to.be.null;
} );

it( 'creates main root element', () => {
expect( editor.model.document.getRoot( 'main' ) ).to.instanceof( RootElement );
} );
Expand Down Expand Up @@ -195,7 +191,6 @@ describe( 'DecoupledEditor', () => {
init() {
this.editor.on( 'pluginsReady', spy );
this.editor.ui.on( 'ready', spy );
this.editor.on( 'uiReady', spy );
this.editor.on( 'dataReady', spy );
this.editor.on( 'ready', spy );
}
Expand All @@ -206,7 +201,7 @@ describe( 'DecoupledEditor', () => {
plugins: [ EventWatcher ]
} )
.then( newEditor => {
expect( fired ).to.deep.equal( [ 'pluginsReady', 'ready', 'uiReady', 'dataReady', 'ready' ] );
expect( fired ).to.deep.equal( [ 'pluginsReady', 'ready', 'dataReady', 'ready' ] );

return newEditor.destroy();
} );
Expand Down Expand Up @@ -234,28 +229,6 @@ describe( 'DecoupledEditor', () => {
} );
} );

it( 'fires uiReady once UI is rendered', () => {
let isReady;

class EventWatcher extends Plugin {
init() {
this.editor.on( 'uiReady', () => {
isReady = this.editor.ui.view.isRendered;
} );
}
}

return DecoupledEditor
.create( getElementOrData(), {
plugins: [ EventWatcher ]
} )
.then( newEditor => {
expect( isReady ).to.be.true;

return newEditor.destroy();
} );
} );

it( 'fires ready once UI is rendered', () => {
let isReady;

Expand Down
9 changes: 8 additions & 1 deletion tests/decouplededitorui.js
Expand Up @@ -17,7 +17,7 @@ import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
import utils from '@ckeditor/ckeditor5-utils/tests/_utils/utils';

describe( 'DecoupledEditorUI', () => {
let editor, view, ui;
let editor, view, ui, viewElement;

testUtils.createSinonSandbox();

Expand All @@ -31,6 +31,7 @@ describe( 'DecoupledEditorUI', () => {

ui = editor.ui;
view = ui.view;
viewElement = view.element;
} );
} );

Expand Down Expand Up @@ -151,6 +152,12 @@ describe( 'DecoupledEditorUI', () => {
} );
} );

describe( 'element()', () => {
it( 'returns correct element instance', () => {
expect( ui.element ).to.equal( viewElement );
} );
} );

describe( 'getEditableElement()', () => {
it( 'returns editable element (default)', () => {
expect( ui.getEditableElement() ).to.equal( view.editable.element );
Expand Down

0 comments on commit d9025cc

Please sign in to comment.