From bf4bc725d1106345fa93d763254d0526c12e6693 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Wr=C3=B3bel?= Date: Tue, 26 Jun 2018 10:15:23 +0200 Subject: [PATCH 1/2] Used EditorUI as a DecoupledEditorUI parent class. --- src/decouplededitorui.js | 39 +++++--------------------------------- tests/decouplededitorui.js | 25 +++++------------------- 2 files changed, 10 insertions(+), 54 deletions(-) diff --git a/src/decouplededitorui.js b/src/decouplededitorui.js index c36a581..b23df4a 100644 --- a/src/decouplededitorui.js +++ b/src/decouplededitorui.js @@ -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. @@ -80,11 +58,4 @@ export default class DecoupledEditorUI { toolbar: this.view.toolbar } ); } - - /** - * Destroys the UI. - */ - destroy() { - this.view.destroy(); - } } diff --git a/tests/decouplededitorui.js b/tests/decouplededitorui.js index 943477b..8dc473e 100644 --- a/tests/decouplededitorui.js +++ b/tests/decouplededitorui.js @@ -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'; @@ -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 ); } ); } ); @@ -166,13 +152,12 @@ describe( 'DecoupledEditorUI', () => { } ); describe( 'destroy()', () => { - it( 'destroys the #view', () => { - const spy = sinon.spy( view, 'destroy' ); + it( 'calls EditorUI#destroy', () => { + const spy = testUtils.sinon.spy( EditorUI.prototype, 'destroy' ); return editor.destroy() .then( () => { sinon.assert.calledOnce( spy ); - sinon.assert.calledWithExactly( spy ); } ); } ); } ); From 61e89df51db5bf7ab6defb626487ec442e3648b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Wr=C3=B3bel?= Date: Wed, 27 Jun 2018 16:31:03 +0200 Subject: [PATCH 2/2] Removed unnecessary test case. --- tests/decouplededitorui.js | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/tests/decouplededitorui.js b/tests/decouplededitorui.js index 8dc473e..59d2ebe 100644 --- a/tests/decouplededitorui.js +++ b/tests/decouplededitorui.js @@ -150,17 +150,6 @@ describe( 'DecoupledEditorUI', () => { } ); } ); } ); - - describe( 'destroy()', () => { - it( 'calls EditorUI#destroy', () => { - const spy = testUtils.sinon.spy( EditorUI.prototype, 'destroy' ); - - return editor.destroy() - .then( () => { - sinon.assert.calledOnce( spy ); - } ); - } ); - } ); } ); function viewCreator( name ) {