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

Commit

Permalink
Merge branch 'master' into t/ckeditor5-core/64
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamil Piechaczek committed Jun 29, 2018
2 parents 0e15df0 + 6a79fcf commit 178a9e6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 68 deletions.
39 changes: 5 additions & 34 deletions src/decouplededitorui.js
Expand Up @@ -7,43 +7,21 @@
* @module editor-decoupled/decouplededitorui
*/

import ComponentFactory from '@ckeditor/ckeditor5-ui/src/componentfactory';
import FocusTracker from '@ckeditor/ckeditor5-utils/src/focustracker';
import EditorUI from '@ckeditor/ckeditor5-core/src/editor/editorui';
import enableToolbarKeyboardFocus from '@ckeditor/ckeditor5-ui/src/toolbar/enabletoolbarkeyboardfocus';
import normalizeToolbarConfig from '@ckeditor/ckeditor5-ui/src/toolbar/normalizetoolbarconfig';

/**
* The decoupled editor UI class.
*
* @implements module:core/editor/editorui~EditorUI
* @extends module:core/editor/editorui~EditorUI
*/
export default class DecoupledEditorUI {
export default class DecoupledEditorUI extends EditorUI {
/**
* Creates an instance of the editor UI class.
*
* @param {module:core/editor/editor~Editor} editor The editor instance.
* @param {module:ui/editorui/editoruiview~EditorUIView} view The view of the UI.
* @inheritDoc
*/
constructor( editor, view ) {
/**
* @inheritDoc
*/
this.editor = editor;

/**
* @inheritDoc
*/
this.view = view;

/**
* @inheritDoc
*/
this.componentFactory = new ComponentFactory( editor );

/**
* @inheritDoc
*/
this.focusTracker = new FocusTracker();
super( editor, view );

/**
* A normalized `config.toolbar` object.
Expand Down Expand Up @@ -80,11 +58,4 @@ export default class DecoupledEditorUI {
toolbar: this.view.toolbar
} );
}

/**
* Destroys the UI.
*/
destroy() {
this.view.destroy();
}
}
9 changes: 4 additions & 5 deletions tests/decouplededitor.js
Expand Up @@ -29,11 +29,6 @@ describe( 'DecoupledEditor', () => {
describe( 'constructor()', () => {
beforeEach( () => {
editor = new DecoupledEditor();
editor.ui.init();
} );

afterEach( () => {
return editor.destroy();
} );

it( 'uses HTMLDataProcessor', () => {
Expand All @@ -54,8 +49,12 @@ describe( 'DecoupledEditor', () => {

describe( 'ui', () => {
it( 'is created', () => {
editor.ui.init();

expect( editor.ui ).to.be.instanceof( DecoupledEditorUI );
expect( editor.ui.view ).to.be.instanceof( DecoupledEditorUIView );

editor.ui.destroy();
} );
} );
} );
Expand Down
32 changes: 3 additions & 29 deletions tests/decouplededitorui.js
Expand Up @@ -5,15 +5,13 @@

/* globals document, Event */

import ComponentFactory from '@ckeditor/ckeditor5-ui/src/componentfactory';
import View from '@ckeditor/ckeditor5-ui/src/view';

import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor';
import DecoupledEditorUI from '../src/decouplededitorui';
import EditorUI from '@ckeditor/ckeditor5-core/src/editor/editorui';
import DecoupledEditorUIView from '../src/decouplededitoruiview';

import FocusTracker from '@ckeditor/ckeditor5-utils/src/focustracker';

import { keyCodes } from '@ckeditor/ckeditor5-utils/src/keyboard';
import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
import utils from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
Expand Down Expand Up @@ -41,20 +39,8 @@ describe( 'DecoupledEditorUI', () => {
} );

describe( 'constructor()', () => {
it( 'sets #editor', () => {
expect( ui.editor ).to.equal( editor );
} );

it( 'sets #view', () => {
expect( ui.view ).to.be.instanceOf( DecoupledEditorUIView );
} );

it( 'creates #componentFactory factory', () => {
expect( ui.componentFactory ).to.be.instanceOf( ComponentFactory );
} );

it( 'creates #focusTracker', () => {
expect( ui.focusTracker ).to.be.instanceOf( FocusTracker );
it( 'extends EditorUI', () => {
expect( ui ).to.instanceof( EditorUI );
} );
} );

Expand Down Expand Up @@ -164,18 +150,6 @@ describe( 'DecoupledEditorUI', () => {
} );
} );
} );

describe( 'destroy()', () => {
it( 'destroys the #view', () => {
const spy = sinon.spy( view, 'destroy' );

return editor.destroy()
.then( () => {
sinon.assert.calledOnce( spy );
sinon.assert.calledWithExactly( spy );
} );
} );
} );
} );

function viewCreator( name ) {
Expand Down

0 comments on commit 178a9e6

Please sign in to comment.