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

Commit c148346

Browse files
authored
Merge pull request #40 from ckeditor/t/ckeditor5-core/130
Other: Used the `EditorUI` as a parent class for the `InlineEditorUI` (see ckeditor/ckeditor5-core#130).
2 parents dceb003 + a549473 commit c148346

File tree

2 files changed

+12
-66
lines changed

2 files changed

+12
-66
lines changed

src/inlineeditorui.js

+6-35
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,21 @@
77
* @module editor-inline/inlineeditorui
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 inline editor UI class.
1716
*
18-
* @implements module:core/editor/editorui~EditorUI
17+
* @extends module:core/editor/editorui~EditorUI
1918
*/
20-
export default class InlineEditorUI {
19+
export default class InlineEditorUI 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.
@@ -71,7 +49,7 @@ export default class InlineEditorUI {
7149
}
7250

7351
// https://github.com/ckeditor/ckeditor5-editor-inline/issues/4
74-
view.listenTo( editor.editing.view, 'render', () => {
52+
view.listenTo( editor.ui, 'update', () => {
7553
// Don't pin if the panel is not already visible. It prevents the panel
7654
// showing up when there's no focus in the UI.
7755
if ( view.panel.isVisible ) {
@@ -103,11 +81,4 @@ export default class InlineEditorUI {
10381
toolbar: view.toolbar
10482
} );
10583
}
106-
107-
/**
108-
* Destroys the UI.
109-
*/
110-
destroy() {
111-
this.view.destroy();
112-
}
11384
}

tests/inlineeditorui.js

+6-31
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 InlineEditorUI from '../src/inlineeditorui';
11+
import EditorUI from '@ckeditor/ckeditor5-core/src/editor/editorui';
1212
import InlineEditorUIView from '../src/inlineeditoruiview';
1313
import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor';
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( 'InlineEditorUI', () => {
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.equal( view );
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

@@ -94,17 +80,17 @@ describe( 'InlineEditorUI', () => {
9480
} );
9581

9682
// https://github.com/ckeditor/ckeditor5-editor-inline/issues/4
97-
it( 'pin() is called on editor.editable.view#render', () => {
83+
it( 'pin() is called on editor.ui#update', () => {
9884
const spy = sinon.stub( view.panel, 'pin' );
9985

10086
view.panel.hide();
10187

102-
editor.editing.view.render();
88+
editor.ui.fire( 'update' );
10389
sinon.assert.notCalled( spy );
10490

10591
view.panel.show();
10692

107-
editor.editing.view.render();
93+
editor.ui.fire( 'update' );
10894
sinon.assert.calledOnce( spy );
10995
sinon.assert.calledWithExactly( spy, {
11096
target: view.editableElement,
@@ -212,17 +198,6 @@ describe( 'InlineEditorUI', () => {
212198
} );
213199
} );
214200
} );
215-
216-
describe( 'destroy()', () => {
217-
it( 'destroys the #view', () => {
218-
const spy = sinon.spy( view, 'destroy' );
219-
220-
return editor.destroy()
221-
.then( () => {
222-
sinon.assert.calledOnce( spy );
223-
} );
224-
} );
225-
} );
226201
} );
227202

228203
function viewCreator( name ) {

0 commit comments

Comments
 (0)