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

Commit d92da9f

Browse files
authored
Merge pull request #16 from ckeditor/t/ckeditor5-core/130
Other: Used the `EditorUI` as a parent class for the `DecoupledEditorUI` (see ckeditor/ckeditor5-core#130).
2 parents f43ea30 + 61e89df commit d92da9f

File tree

2 files changed

+8
-63
lines changed

2 files changed

+8
-63
lines changed

src/decouplededitorui.js

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,21 @@
77
* @module editor-decoupled/decouplededitorui
88
*/
99

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

1514
/**
1615
* The decoupled editor UI class.
1716
*
18-
* @implements module:core/editor/editorui~EditorUI
17+
* @extends module:core/editor/editorui~EditorUI
1918
*/
20-
export default class DecoupledEditorUI {
19+
export default class DecoupledEditorUI extends EditorUI {
2120
/**
22-
* Creates an instance of the editor UI class.
23-
*
24-
* @param {module:core/editor/editor~Editor} editor The editor instance.
25-
* @param {module:ui/editorui/editoruiview~EditorUIView} view The view of the UI.
21+
* @inheritDoc
2622
*/
2723
constructor( editor, view ) {
28-
/**
29-
* @inheritDoc
30-
*/
31-
this.editor = editor;
32-
33-
/**
34-
* @inheritDoc
35-
*/
36-
this.view = view;
37-
38-
/**
39-
* @inheritDoc
40-
*/
41-
this.componentFactory = new ComponentFactory( editor );
42-
43-
/**
44-
* @inheritDoc
45-
*/
46-
this.focusTracker = new FocusTracker();
24+
super( editor, view );
4725

4826
/**
4927
* A normalized `config.toolbar` object.
@@ -80,11 +58,4 @@ export default class DecoupledEditorUI {
8058
toolbar: this.view.toolbar
8159
} );
8260
}
83-
84-
/**
85-
* Destroys the UI.
86-
*/
87-
destroy() {
88-
this.view.destroy();
89-
}
9061
}

tests/decouplededitorui.js

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@
55

66
/* globals document, Event */
77

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

1110
import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor';
1211
import DecoupledEditorUI from '../src/decouplededitorui';
12+
import EditorUI from '@ckeditor/ckeditor5-core/src/editor/editorui';
1313
import DecoupledEditorUIView from '../src/decouplededitoruiview';
1414

15-
import FocusTracker from '@ckeditor/ckeditor5-utils/src/focustracker';
16-
1715
import { keyCodes } from '@ckeditor/ckeditor5-utils/src/keyboard';
1816
import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
1917
import utils from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
@@ -41,20 +39,8 @@ describe( 'DecoupledEditorUI', () => {
4139
} );
4240

4341
describe( 'constructor()', () => {
44-
it( 'sets #editor', () => {
45-
expect( ui.editor ).to.equal( editor );
46-
} );
47-
48-
it( 'sets #view', () => {
49-
expect( ui.view ).to.be.instanceOf( DecoupledEditorUIView );
50-
} );
51-
52-
it( 'creates #componentFactory factory', () => {
53-
expect( ui.componentFactory ).to.be.instanceOf( ComponentFactory );
54-
} );
55-
56-
it( 'creates #focusTracker', () => {
57-
expect( ui.focusTracker ).to.be.instanceOf( FocusTracker );
42+
it( 'extends EditorUI', () => {
43+
expect( ui ).to.instanceof( EditorUI );
5844
} );
5945
} );
6046

@@ -164,18 +150,6 @@ describe( 'DecoupledEditorUI', () => {
164150
} );
165151
} );
166152
} );
167-
168-
describe( 'destroy()', () => {
169-
it( 'destroys the #view', () => {
170-
const spy = sinon.spy( view, 'destroy' );
171-
172-
return editor.destroy()
173-
.then( () => {
174-
sinon.assert.calledOnce( spy );
175-
sinon.assert.calledWithExactly( spy );
176-
} );
177-
} );
178-
} );
179153
} );
180154

181155
function viewCreator( name ) {

0 commit comments

Comments
 (0)