From f689e23b14c9fb8a953b081928fb4f487050d550 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Wr=C3=B3bel?= Date: Tue, 26 Jun 2018 09:46:28 +0200 Subject: [PATCH 1/2] Used EditorUI as a ClassicEditorUI parent class. --- src/classiceditorui.js | 39 +++++---------------------------------- tests/classiceditorui.js | 24 +++++------------------- 2 files changed, 10 insertions(+), 53 deletions(-) diff --git a/src/classiceditorui.js b/src/classiceditorui.js index ec4294b..94de4e9 100644 --- a/src/classiceditorui.js +++ b/src/classiceditorui.js @@ -7,43 +7,21 @@ * @module editor-classic/classiceditorui */ -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 classic editor UI class. * - * @implements module:core/editor/editorui~EditorUI + * @extends module:core/editor/editorui~EditorUI */ -export default class ClassicEditorUI { +export default class ClassicEditorUI 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. @@ -88,11 +66,4 @@ export default class ClassicEditorUI { toolbar: this.view.toolbar } ); } - - /** - * Destroys the UI. - */ - destroy() { - this.view.destroy(); - } } diff --git a/tests/classiceditorui.js b/tests/classiceditorui.js index 1147460..7faa253 100644 --- a/tests/classiceditorui.js +++ b/tests/classiceditorui.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 ClassicEditorUI from '../src/classiceditorui'; +import EditorUI from '@ckeditor/ckeditor5-core/src/editor/editorui'; import ClassicEditorUIView from '../src/classiceditoruiview'; -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( 'ClassicEditorUI', () => { } ); describe( 'constructor()', () => { - it( 'sets #editor', () => { - expect( ui.editor ).to.equal( editor ); - } ); - - it( 'sets #view', () => { - expect( ui.view ).to.be.instanceOf( ClassicEditorUIView ); - } ); - - 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 ); } ); } ); @@ -194,8 +180,8 @@ describe( 'ClassicEditorUI', () => { } ); 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( () => { From e53f808230cb50df4234f63e3f3f4ac895975aa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Wr=C3=B3bel?= Date: Wed, 27 Jun 2018 16:27:11 +0200 Subject: [PATCH 2/2] Removed unnecessary test case. --- tests/classiceditorui.js | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/tests/classiceditorui.js b/tests/classiceditorui.js index 7faa253..dcfffbf 100644 --- a/tests/classiceditorui.js +++ b/tests/classiceditorui.js @@ -178,17 +178,6 @@ describe( 'ClassicEditorUI', () => { } ); } ); } ); - - 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 ) {