@@ -62,26 +62,26 @@ We will use {@link module:ui/labeledfield/labeledfieldview~LabeledFieldView `Lab
6262// abbreviation/abbreviationview.js
6363
6464import {
65- View ,
66- LabeledFieldView , // ADDED
67- createLabeledInputText // ADDED
68- } from ' @ckeditor/ckeditor5-ui' ;
65+ View ,
66+ LabeledFieldView , // ADDED
67+ createLabeledInputText // ADDED
68+ } from ' @ckeditor/ckeditor5-ui' ;
6969
7070export default class FormView extends View {
7171 constructor ( locale ) {
72- // ...
72+ // ...
7373
74- this .abbrInputView = this ._createInput ( t ( ' Add abbreviation' ) );
74+ this .abbrInputView = this ._createInput ( t ( ' Add abbreviation' ) );
7575 this .titleInputView = this ._createInput ( t ( ' Add title' ) );
7676 }
7777
78- _createInput ( label ) {
79- const labeledInput = new LabeledFieldView ( this .locale , createLabeledInputText );
78+ _createInput ( label ) {
79+ const labeledInput = new LabeledFieldView ( this .locale , createLabeledInputText );
8080
81- labeledInput .label = label;
81+ labeledInput .label = label;
8282
83- return labeledInput;
84- }
83+ return labeledInput;
84+ }
8585}
8686```
8787
@@ -99,41 +99,39 @@ Last thing is to delegate `cancelButtonView#execute` to the FormView, so pressin
9999// abbreviation/abbreviationview.js
100100
101101import {
102- View ,
103- LabeledFieldView ,
104- createLabeledInputText ,
105- ButtonView // ADDED
106- } from ' @ckeditor/ckeditor5-ui' ;
107- import {
108- IconCheck ,
109- IconCancel
110- } from ' @ckeditor/ckeditor5-icons' ; // ADDED
102+ IconCheck ,
103+ IconCancel ,
104+ View ,
105+ LabeledFieldView ,
106+ createLabeledInputText ,
107+ ButtonView // ADDED
108+ } from ' ckeditor5' ;
111109
112110export default class FormView extends View {
113111 constructor ( locale ) {
114- // ...
112+ // ...
115113
116- // Create the save and cancel buttons.
117- this .saveButtonView = this ._createButton (
118- t ( ' Save' ), IconCheck, ' ck-button-save'
119- );
114+ // Create the save and cancel buttons.
115+ this .saveButtonView = this ._createButton (
116+ t ( ' Save' ), IconCheck, ' ck-button-save'
117+ );
120118 // Set the type to 'submit', which will trigger
121119 // the submit event on entire form when clicked.
122120 this .saveButtonView .type = ' submit' ;
123121
124122 this .cancelButtonView = this ._createButton (
125- t ( ' Cancel' ), IconCancel, ' ck-button-cancel'
126- );
123+ t ( ' Cancel' ), IconCancel, ' ck-button-cancel'
124+ );
127125 // Delegate ButtonView#execute to FormView#cancel.
128126 this .cancelButtonView .delegate ( ' execute' ).to ( this , ' cancel' );
129127
130128 }
131129
132- _createInput ( label ) {
133- // ...
134- }
130+ _createInput ( label ) {
131+ // ...
132+ }
135133
136- _createButton ( label , icon , className ) {
134+ _createButton ( label , icon , className ) {
137135 const button = new ButtonView ( this .locale );
138136
139137 button .set ( {
@@ -211,20 +209,19 @@ We also need a `focus()` method, which will focus on the first child, so our `ab
211209// abbreviation/abbreviationview.js
212210
213211import {
214- View ,
215- LabeledFieldView ,
216- createLabeledInputText ,
217- ButtonView ,
218- submitHandler // ADDED
219- } from ' @ckeditor/ckeditor5-ui' ;
220- import { icons } from ' @ckeditor/ckeditor5-core' ;
212+ View ,
213+ LabeledFieldView ,
214+ createLabeledInputText ,
215+ ButtonView ,
216+ submitHandler // ADDED
217+ } from ' ckeditor5' ;
221218
222219export default class FormView extends View {
223220 constructor ( locale ) {
224221
225- // ...
222+ // ...
226223
227- this .childViews = this .createCollection ( [
224+ this .childViews = this .createCollection ( [
228225 this .abbrInputView ,
229226 this .titleInputView ,
230227 this .saveButtonView ,
@@ -234,33 +231,33 @@ export default class FormView extends View {
234231 this .setTemplate ( {
235232 tag: ' form' ,
236233 attributes: {
237- // ...
234+ // ...
238235 },
239236 children: this .childViews // ADDED
240237 } );
241238 }
242239
243- render () {
244- super .render ();
240+ render () {
241+ super .render ();
245242
246243 // Submit the form when the user clicked the save button
247244 // or pressed enter in the input.
248- submitHandler ( {
249- view: this
250- } );
251- }
252-
253- focus () {
254- this .childViews .first .focus ();
255- }
256-
257- _createInput ( label ) {
258- // ...
259- }
260-
261- _createButton ( label , icon , className ) {
262- // ...
263- }
245+ submitHandler ( {
246+ view: this
247+ } );
248+ }
249+
250+ focus () {
251+ this .childViews .first .focus ();
252+ }
253+
254+ _createInput ( label ) {
255+ // ...
256+ }
257+
258+ _createButton ( label , icon , className ) {
259+ // ...
260+ }
264261}
265262```
266263
@@ -275,8 +272,7 @@ This is where we ended up with our UI in the first part of the tutorial.
275272``` js
276273// abbreviation/abbreviationui.js
277274
278- import { Plugin } from ' ckeditor5' ;
279- import { ButtonView } from ' @ckeditor/ckeditor5-ui' ;
275+ import { Plugin , ButtonView } from ' ckeditor5' ;
280276
281277class AbbreviationUI extends Plugin {
282278 init () {
@@ -319,25 +315,29 @@ Finally, let's add our balloon and form view to the `init()` method.
319315``` js
320316// abbreviation/abbreviationui.js
321317
322- import { Plugin } from ' ckeditor5' ;
323- import { ButtonView , ContextualBalloon } from ' @ckeditor/ckeditor5-ui' ; // ADDED
324- import FormView from ' ./abbreviationview' ; // ADDED
318+ import {
319+ Plugin ,
320+ ButtonView , // ADDED
321+ ContextualBalloon // ADDED
322+ } from ' ckeditor5' ;
323+
324+ import FormView from ' ./abbreviationview' ; // ADDED
325325
326326class AbbreviationUI extends Plugin {
327327 static get requires () {
328328 return [ ContextualBalloon ];
329329 }
330330
331331 init () {
332- const editor = this .editor ;
332+ const editor = this .editor ;
333333 const { t } = editor .locale ;
334334
335- // Create the balloon and the form view.
335+ // Create the balloon and the form view.
336336 this ._balloon = this .editor .plugins .get ( ContextualBalloon );
337337 this .formView = this ._createFormView ();
338338
339339 editor .ui .componentFactory .add ( ' abbreviation' , locale => {
340- // ...
340+ // ...
341341 } );
342342 }
343343
@@ -353,7 +353,7 @@ class AbbreviationUI extends Plugin {
353353 const viewDocument = view .document ;
354354 let target = null ;
355355
356- // Set a target position by converting view selection range to DOM
356+ // Set a target position by converting view selection range to DOM
357357 target = () => view .domConverter .viewRangeToDom (
358358 viewDocument .selection .getFirstRange ()
359359 );
@@ -419,7 +419,7 @@ class AbbreviationUI extends Plugin {
419419 }
420420
421421 init () {
422- // ...
422+ // ...
423423 }
424424
425425 _createFormView () {
@@ -442,7 +442,7 @@ class AbbreviationUI extends Plugin {
442442 }
443443
444444 _getBalloonPositionData () {
445- // ...
445+ // ...
446446 }
447447
448448 _showUI () {
@@ -467,25 +467,25 @@ Additionally, we will import {@link module:ui/bindings/clickoutsidehandler~click
467467// abbreviation/abbreviationui.js
468468
469469// ...
470- import { ContextualBalloon , clickOutsideHandler } from ' @ckeditor/ ckeditor5-ui ' ; // ADDED
470+ import { ContextualBalloon , clickOutsideHandler } from ' ckeditor5' ; // ADDED
471471
472472class AbbreviationUI extends Plugin {
473473 static get requires () {
474474 return [ ContextualBalloon ];
475475 }
476476
477477 init () {
478- // ...
478+ // ...
479479 }
480480
481481 _createFormView () {
482482 const editor = this .editor ;
483483 const formView = new FormView ( editor .locale );
484484
485- this .listenTo ( formView, ' submit' , () => {
486- // ...
485+ this .listenTo ( formView, ' submit' , () => {
486+ // ...
487487
488- // Hide the form view after submit.
488+ // Hide the form view after submit.
489489 this ._hideUI ();
490490 } );
491491
@@ -494,7 +494,7 @@ class AbbreviationUI extends Plugin {
494494 this ._hideUI ();
495495 } );
496496
497- // Hide the form view when clicking outside the balloon.
497+ // Hide the form view when clicking outside the balloon.
498498 clickOutsideHandler ( {
499499 emitter: formView,
500500 activator : () => this ._balloon .visibleView === formView,
@@ -517,7 +517,7 @@ class AbbreviationUI extends Plugin {
517517 }
518518
519519 _getBalloonPositionData () {
520- // ...
520+ // ...
521521 }
522522
523523 _showUI () {
0 commit comments