@ckeditor/ckeditor5-bookmark 0.0.0-nightly-20241216.0 → 0.0.0-nightly-20241218.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -14,38 +14,23 @@ import { FocusTracker, KeystrokeHandler, logWarning } from '@ckeditor/ckeditor5-
14
14
  * See {@link module:bookmark/ui/bookmarkformview~BookmarkFormView}.
15
15
  */ class BookmarkFormView extends View {
16
16
  /**
17
- * Tracks information about DOM focus in the form.
18
- */ focusTracker = new FocusTracker();
19
- /**
20
- * An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
21
- */ keystrokes = new KeystrokeHandler();
22
- /**
23
- * The ID input view.
24
- */ idInputView;
25
- /**
26
- * The Submit button view.
27
- */ buttonView;
28
- /**
29
- * A collection of form child views in the form.
30
- */ children;
31
- /**
32
- * An array of form validators used by {@link #isValid}.
33
- */ _validators;
34
- /**
35
- * A collection of views that can be focused in the form.
36
- */ _focusables = new ViewCollection();
37
- /**
38
- * Helps cycling over {@link #_focusables} in the form.
39
- */ _focusCycler;
40
- /**
41
- * Creates an instance of the {@link module:bookmark/ui/bookmarkformview~BookmarkFormView} class.
42
- *
43
- * Also see {@link #render}.
44
- *
45
- * @param locale The localization services instance.
46
- * @param validators Form validators used by {@link #isValid}.
47
- */ constructor(locale, validators){
17
+ * Creates an instance of the {@link module:bookmark/ui/bookmarkformview~BookmarkFormView} class.
18
+ *
19
+ * Also see {@link #render}.
20
+ *
21
+ * @param locale The localization services instance.
22
+ * @param validators Form validators used by {@link #isValid}.
23
+ */ constructor(locale, validators){
48
24
  super(locale);
25
+ /**
26
+ * Tracks information about DOM focus in the form.
27
+ */ this.focusTracker = new FocusTracker();
28
+ /**
29
+ * An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
30
+ */ this.keystrokes = new KeystrokeHandler();
31
+ /**
32
+ * A collection of views that can be focused in the form.
33
+ */ this._focusables = new ViewCollection();
49
34
  const t = locale.t;
50
35
  this._validators = validators;
51
36
  this.idInputView = this._createIdInput();
@@ -78,8 +63,8 @@ import { FocusTracker, KeystrokeHandler, logWarning } from '@ckeditor/ckeditor5-
78
63
  });
79
64
  }
80
65
  /**
81
- * @inheritDoc
82
- */ render() {
66
+ * @inheritDoc
67
+ */ render() {
83
68
  super.render();
84
69
  submitHandler({
85
70
  view: this
@@ -98,20 +83,20 @@ import { FocusTracker, KeystrokeHandler, logWarning } from '@ckeditor/ckeditor5-
98
83
  this.keystrokes.listenTo(this.element);
99
84
  }
100
85
  /**
101
- * @inheritDoc
102
- */ destroy() {
86
+ * @inheritDoc
87
+ */ destroy() {
103
88
  super.destroy();
104
89
  this.focusTracker.destroy();
105
90
  this.keystrokes.destroy();
106
91
  }
107
92
  /**
108
- * Focuses the fist {@link #_focusables} in the form.
109
- */ focus() {
93
+ * Focuses the fist {@link #_focusables} in the form.
94
+ */ focus() {
110
95
  this._focusCycler.focusFirst();
111
96
  }
112
97
  /**
113
- * Validates the form and returns `false` when some fields are invalid.
114
- */ isValid() {
98
+ * Validates the form and returns `false` when some fields are invalid.
99
+ */ isValid() {
115
100
  this.resetFormStatus();
116
101
  for (const validator of this._validators){
117
102
  const errorText = validator(this);
@@ -125,16 +110,16 @@ import { FocusTracker, KeystrokeHandler, logWarning } from '@ckeditor/ckeditor5-
125
110
  return true;
126
111
  }
127
112
  /**
128
- * Cleans up the supplementary error and information text of the {@link #idInputView}
129
- * bringing them back to the state when the form has been displayed for the first time.
130
- *
131
- * See {@link #isValid}.
132
- */ resetFormStatus() {
113
+ * Cleans up the supplementary error and information text of the {@link #idInputView}
114
+ * bringing them back to the state when the form has been displayed for the first time.
115
+ *
116
+ * See {@link #isValid}.
117
+ */ resetFormStatus() {
133
118
  this.idInputView.errorText = null;
134
119
  }
135
120
  /**
136
- * Creates header and form view.
137
- */ _createViewChildren() {
121
+ * Creates header and form view.
122
+ */ _createViewChildren() {
138
123
  const children = this.createCollection();
139
124
  const t = this.t;
140
125
  children.add(new FormHeaderView(this.locale, {
@@ -144,8 +129,8 @@ import { FocusTracker, KeystrokeHandler, logWarning } from '@ckeditor/ckeditor5-
144
129
  return children;
145
130
  }
146
131
  /**
147
- * Creates form content view with input and button.
148
- */ _createFormContentView() {
132
+ * Creates form content view with input and button.
133
+ */ _createFormContentView() {
149
134
  const view = new View(this.locale);
150
135
  const children = this.createCollection();
151
136
  const classList = [
@@ -165,10 +150,10 @@ import { FocusTracker, KeystrokeHandler, logWarning } from '@ckeditor/ckeditor5-
165
150
  return view;
166
151
  }
167
152
  /**
168
- * Creates a labeled input view.
169
- *
170
- * @returns Labeled field view instance.
171
- */ _createIdInput() {
153
+ * Creates a labeled input view.
154
+ *
155
+ * @returns Labeled field view instance.
156
+ */ _createIdInput() {
172
157
  const t = this.locale.t;
173
158
  const labeledInput = new LabeledFieldView(this.locale, createLabeledInputText);
174
159
  labeledInput.label = t('Bookmark name');
@@ -176,12 +161,12 @@ import { FocusTracker, KeystrokeHandler, logWarning } from '@ckeditor/ckeditor5-
176
161
  return labeledInput;
177
162
  }
178
163
  /**
179
- * Creates a button view.
180
- *
181
- * @param label The button label.
182
- * @param className The additional button CSS class name.
183
- * @returns The button view instance.
184
- */ _createButton(label, className) {
164
+ * Creates a button view.
165
+ *
166
+ * @param label The button label.
167
+ * @param className The additional button CSS class name.
168
+ * @returns The button view instance.
169
+ */ _createButton(label, className) {
185
170
  const button = new ButtonView(this.locale);
186
171
  button.set({
187
172
  label,
@@ -195,11 +180,11 @@ import { FocusTracker, KeystrokeHandler, logWarning } from '@ckeditor/ckeditor5-
195
180
  return button;
196
181
  }
197
182
  /**
198
- * The native DOM `value` of the {@link #idInputView} element.
199
- *
200
- * **Note**: Do not confuse it with the {@link module:ui/inputtext/inputtextview~InputTextView#value}
201
- * which works one way only and may not represent the actual state of the component in the DOM.
202
- */ get id() {
183
+ * The native DOM `value` of the {@link #idInputView} element.
184
+ *
185
+ * **Note**: Do not confuse it with the {@link module:ui/inputtext/inputtextview~InputTextView#value}
186
+ * which works one way only and may not represent the actual state of the component in the DOM.
187
+ */ get id() {
203
188
  const { element } = this.idInputView.fieldView;
204
189
  if (!element) {
205
190
  return null;
@@ -213,30 +198,18 @@ import { FocusTracker, KeystrokeHandler, logWarning } from '@ckeditor/ckeditor5-
213
198
  * removing or editing the bookmark.
214
199
  */ class BookmarkActionsView extends View {
215
200
  /**
216
- * Tracks information about DOM focus in the actions.
217
- */ focusTracker = new FocusTracker();
218
- /**
219
- * An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
220
- */ keystrokes = new KeystrokeHandler();
221
- /**
222
- * The bookmark preview view.
223
- */ bookmarkPreviewView;
224
- /**
225
- * The remove button view.
226
- */ removeButtonView;
227
- /**
228
- * The edit bookmark button view.
229
- */ editButtonView;
230
- /**
231
- * A collection of views that can be focused in the view.
232
- */ _focusables = new ViewCollection();
233
- /**
234
- * Helps cycling over {@link #_focusables} in the view.
235
- */ _focusCycler;
236
- /**
237
- * @inheritDoc
238
- */ constructor(locale){
201
+ * @inheritDoc
202
+ */ constructor(locale){
239
203
  super(locale);
204
+ /**
205
+ * Tracks information about DOM focus in the actions.
206
+ */ this.focusTracker = new FocusTracker();
207
+ /**
208
+ * An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
209
+ */ this.keystrokes = new KeystrokeHandler();
210
+ /**
211
+ * A collection of views that can be focused in the view.
212
+ */ this._focusables = new ViewCollection();
240
213
  const t = locale.t;
241
214
  this.bookmarkPreviewView = this._createBookmarkPreviewView();
242
215
  this.removeButtonView = this._createButton(t('Remove bookmark'), icons.remove, 'remove', this.bookmarkPreviewView);
@@ -272,8 +245,8 @@ import { FocusTracker, KeystrokeHandler, logWarning } from '@ckeditor/ckeditor5-
272
245
  });
273
246
  }
274
247
  /**
275
- * @inheritDoc
276
- */ render() {
248
+ * @inheritDoc
249
+ */ render() {
277
250
  super.render();
278
251
  const childViews = [
279
252
  this.editButtonView,
@@ -289,26 +262,26 @@ import { FocusTracker, KeystrokeHandler, logWarning } from '@ckeditor/ckeditor5-
289
262
  this.keystrokes.listenTo(this.element);
290
263
  }
291
264
  /**
292
- * @inheritDoc
293
- */ destroy() {
265
+ * @inheritDoc
266
+ */ destroy() {
294
267
  super.destroy();
295
268
  this.focusTracker.destroy();
296
269
  this.keystrokes.destroy();
297
270
  }
298
271
  /**
299
- * Focuses the fist {@link #_focusables} in the actions.
300
- */ focus() {
272
+ * Focuses the fist {@link #_focusables} in the actions.
273
+ */ focus() {
301
274
  this._focusCycler.focusFirst();
302
275
  }
303
276
  /**
304
- * Creates a button view.
305
- *
306
- * @param label The button label.
307
- * @param icon The button icon.
308
- * @param eventName An event name that the `ButtonView#execute` event will be delegated to.
309
- * @param additionalLabel An additional label outside the button.
310
- * @returns The button view instance.
311
- */ _createButton(label, icon, eventName, additionalLabel) {
277
+ * Creates a button view.
278
+ *
279
+ * @param label The button label.
280
+ * @param icon The button icon.
281
+ * @param eventName An event name that the `ButtonView#execute` event will be delegated to.
282
+ * @param additionalLabel An additional label outside the button.
283
+ * @returns The button view instance.
284
+ */ _createButton(label, icon, eventName, additionalLabel) {
312
285
  const button = new ButtonView(this.locale);
313
286
  button.set({
314
287
  label,
@@ -327,10 +300,10 @@ import { FocusTracker, KeystrokeHandler, logWarning } from '@ckeditor/ckeditor5-
327
300
  return button;
328
301
  }
329
302
  /**
330
- * Creates a bookmark name preview label.
331
- *
332
- * @returns The label view instance.
333
- */ _createBookmarkPreviewView() {
303
+ * Creates a bookmark name preview label.
304
+ *
305
+ * @returns The label view instance.
306
+ */ _createBookmarkPreviewView() {
334
307
  const label = new LabelView(this.locale);
335
308
  label.extendTemplate({
336
309
  attributes: {
@@ -381,32 +354,32 @@ import { FocusTracker, KeystrokeHandler, logWarning } from '@ckeditor/ckeditor5-
381
354
  * ```
382
355
  */ class InsertBookmarkCommand extends Command {
383
356
  /**
384
- * @inheritDoc
385
- */ refresh() {
357
+ * @inheritDoc
358
+ */ refresh() {
386
359
  const model = this.editor.model;
387
360
  const selection = model.document.selection;
388
361
  const position = this._getPositionToInsertBookmark(selection);
389
362
  this.isEnabled = !!position;
390
363
  }
391
364
  /**
392
- * Executes the command.
393
- *
394
- * @fires execute
395
- * @param options Command options.
396
- * @param options.bookmarkId The value of the `bookmarkId` attribute.
397
- */ execute(options) {
365
+ * Executes the command.
366
+ *
367
+ * @fires execute
368
+ * @param options Command options.
369
+ * @param options.bookmarkId The value of the `bookmarkId` attribute.
370
+ */ execute(options) {
398
371
  if (!options) {
399
372
  return;
400
373
  }
401
374
  const { bookmarkId } = options;
402
375
  if (!isBookmarkIdValid(bookmarkId)) {
403
376
  /**
404
- * Insert bookmark command can be executed only with a valid name.
405
- *
406
- * A valid bookmark name must be a non-empty string and must not contain any spaces.
407
- *
408
- * @error insert-bookmark-command-executed-with-invalid-name
409
- */ logWarning('insert-bookmark-command-executed-with-invalid-name');
377
+ * Insert bookmark command can be executed only with a valid name.
378
+ *
379
+ * A valid bookmark name must be a non-empty string and must not contain any spaces.
380
+ *
381
+ * @error insert-bookmark-command-executed-with-invalid-name
382
+ */ logWarning('insert-bookmark-command-executed-with-invalid-name');
410
383
  return;
411
384
  }
412
385
  const editor = this.editor;
@@ -436,9 +409,9 @@ import { FocusTracker, KeystrokeHandler, logWarning } from '@ckeditor/ckeditor5-
436
409
  });
437
410
  }
438
411
  /**
439
- * Returns the position where the bookmark can be inserted. And if it is not possible to insert a bookmark,
440
- * check if it is possible to insert a paragraph.
441
- */ _getPositionToInsertBookmark(selection) {
412
+ * Returns the position where the bookmark can be inserted. And if it is not possible to insert a bookmark,
413
+ * check if it is possible to insert a paragraph.
414
+ */ _getPositionToInsertBookmark(selection) {
442
415
  const model = this.editor.model;
443
416
  const schema = model.schema;
444
417
  const firstRange = selection.getFirstRange();
@@ -483,8 +456,8 @@ import { FocusTracker, KeystrokeHandler, logWarning } from '@ckeditor/ckeditor5-
483
456
  * ```
484
457
  */ class UpdateBookmarkCommand extends Command {
485
458
  /**
486
- * @inheritDoc
487
- */ refresh() {
459
+ * @inheritDoc
460
+ */ refresh() {
488
461
  const model = this.editor.model;
489
462
  const selection = model.document.selection;
490
463
  const selectedBookmark = getSelectedBookmark(selection);
@@ -492,24 +465,24 @@ import { FocusTracker, KeystrokeHandler, logWarning } from '@ckeditor/ckeditor5-
492
465
  this.value = selectedBookmark ? selectedBookmark.getAttribute('bookmarkId') : undefined;
493
466
  }
494
467
  /**
495
- * Executes the command.
496
- *
497
- * @fires execute
498
- * @param options Command options.
499
- * @param options.bookmarkId The new value of the `bookmarkId` attribute to set.
500
- */ execute(options) {
468
+ * Executes the command.
469
+ *
470
+ * @fires execute
471
+ * @param options Command options.
472
+ * @param options.bookmarkId The new value of the `bookmarkId` attribute to set.
473
+ */ execute(options) {
501
474
  if (!options) {
502
475
  return;
503
476
  }
504
477
  const { bookmarkId } = options;
505
478
  if (!isBookmarkIdValid(bookmarkId)) {
506
479
  /**
507
- * Update bookmark command can be executed only with a valid name.
508
- *
509
- * A valid bookmark name must be a non-empty string and must not contain any spaces.
510
- *
511
- * @error update-bookmark-command-executed-with-invalid-name
512
- */ logWarning('update-bookmark-command-executed-with-invalid-name');
480
+ * Update bookmark command can be executed only with a valid name.
481
+ *
482
+ * A valid bookmark name must be a non-empty string and must not contain any spaces.
483
+ *
484
+ * @error update-bookmark-command-executed-with-invalid-name
485
+ */ logWarning('update-bookmark-command-executed-with-invalid-name');
513
486
  return;
514
487
  }
515
488
  const model = this.editor.model;
@@ -535,22 +508,25 @@ import { FocusTracker, KeystrokeHandler, logWarning } from '@ckeditor/ckeditor5-
535
508
  /**
536
509
  * The bookmark editing plugin.
537
510
  */ class BookmarkEditing extends Plugin {
511
+ constructor(){
512
+ super(...arguments);
513
+ /**
514
+ * A collection of bookmarks elements in the document.
515
+ */ this._bookmarkElements = new Map();
516
+ }
538
517
  /**
539
- * A collection of bookmarks elements in the document.
540
- */ _bookmarkElements = new Map();
541
- /**
542
- * @inheritDoc
543
- */ static get pluginName() {
518
+ * @inheritDoc
519
+ */ static get pluginName() {
544
520
  return 'BookmarkEditing';
545
521
  }
546
522
  /**
547
- * @inheritDoc
548
- */ static get isOfficialPlugin() {
523
+ * @inheritDoc
524
+ */ static get isOfficialPlugin() {
549
525
  return true;
550
526
  }
551
527
  /**
552
- * @inheritDoc
553
- */ init() {
528
+ * @inheritDoc
529
+ */ init() {
554
530
  const { editor } = this;
555
531
  this._defineSchema();
556
532
  this._defineConverters();
@@ -561,8 +537,8 @@ import { FocusTracker, KeystrokeHandler, logWarning } from '@ckeditor/ckeditor5-
561
537
  });
562
538
  }
563
539
  /**
564
- * Returns the model element for the given bookmark ID if it exists.
565
- */ getElementForBookmarkId(bookmarkId) {
540
+ * Returns the model element for the given bookmark ID if it exists.
541
+ */ getElementForBookmarkId(bookmarkId) {
566
542
  for (const [element, id] of this._bookmarkElements){
567
543
  if (id == bookmarkId) {
568
544
  return element;
@@ -571,8 +547,8 @@ import { FocusTracker, KeystrokeHandler, logWarning } from '@ckeditor/ckeditor5-
571
547
  return null;
572
548
  }
573
549
  /**
574
- * Defines the schema for the bookmark feature.
575
- */ _defineSchema() {
550
+ * Defines the schema for the bookmark feature.
551
+ */ _defineSchema() {
576
552
  const schema = this.editor.model.schema;
577
553
  schema.register('bookmark', {
578
554
  inheritAllFrom: '$inlineObject',
@@ -584,8 +560,8 @@ import { FocusTracker, KeystrokeHandler, logWarning } from '@ckeditor/ckeditor5-
584
560
  });
585
561
  }
586
562
  /**
587
- * Defines the converters for the bookmark feature.
588
- */ _defineConverters() {
563
+ * Defines the converters for the bookmark feature.
564
+ */ _defineConverters() {
589
565
  const { editor } = this;
590
566
  const { conversion, t } = editor;
591
567
  editor.data.htmlProcessor.domConverter.registerInlineObjectMatcher((element)=>upcastMatcher(element));
@@ -633,8 +609,8 @@ import { FocusTracker, KeystrokeHandler, logWarning } from '@ckeditor/ckeditor5-
633
609
  conversion.for('upcast').add((dispatcher)=>dispatcher.on('element:a', dataViewModelAnchorInsertion(editor)));
634
610
  }
635
611
  /**
636
- * Creates a UI element for the `bookmark` representation in editing view.
637
- */ _createBookmarkUIElement(writer) {
612
+ * Creates a UI element for the `bookmark` representation in editing view.
613
+ */ _createBookmarkUIElement(writer) {
638
614
  return writer.createUIElement('span', {
639
615
  class: 'ck-bookmark__icon'
640
616
  }, function(domDocument) {
@@ -650,8 +626,8 @@ import { FocusTracker, KeystrokeHandler, logWarning } from '@ckeditor/ckeditor5-
650
626
  });
651
627
  }
652
628
  /**
653
- * Tracking the added or removed bookmark elements.
654
- */ _trackBookmarkElements() {
629
+ * Tracking the added or removed bookmark elements.
630
+ */ _trackBookmarkElements() {
655
631
  this._bookmarkElements.forEach((id, element)=>{
656
632
  if (element.root.rootName === '$graveyard') {
657
633
  this._bookmarkElements.delete(element);
@@ -751,36 +727,36 @@ const VISUAL_SELECTION_MARKER_NAME = 'bookmark-ui';
751
727
  * It registers the `'bookmark'` UI button in the editor's {@link module:ui/componentfactory~ComponentFactory component factory}
752
728
  * which inserts the `bookmark` element upon selection.
753
729
  */ class BookmarkUI extends Plugin {
754
- /**
755
- * The actions view displayed inside of the balloon.
756
- */ actionsView = null;
757
- /**
758
- * The form view displayed inside the balloon.
759
- */ formView = null;
760
- /**
761
- * The contextual balloon plugin instance.
762
- */ _balloon;
763
- /**
764
- * @inheritDoc
765
- */ static get requires() {
730
+ constructor(){
731
+ super(...arguments);
732
+ /**
733
+ * The actions view displayed inside of the balloon.
734
+ */ this.actionsView = null;
735
+ /**
736
+ * The form view displayed inside the balloon.
737
+ */ this.formView = null;
738
+ }
739
+ /**
740
+ * @inheritDoc
741
+ */ static get requires() {
766
742
  return [
767
743
  BookmarkEditing,
768
744
  ContextualBalloon
769
745
  ];
770
746
  }
771
747
  /**
772
- * @inheritDoc
773
- */ static get pluginName() {
748
+ * @inheritDoc
749
+ */ static get pluginName() {
774
750
  return 'BookmarkUI';
775
751
  }
776
752
  /**
777
- * @inheritDoc
778
- */ static get isOfficialPlugin() {
753
+ * @inheritDoc
754
+ */ static get isOfficialPlugin() {
779
755
  return true;
780
756
  }
781
757
  /**
782
- * @inheritDoc
783
- */ init() {
758
+ * @inheritDoc
759
+ */ init() {
784
760
  const editor = this.editor;
785
761
  editor.editing.view.addObserver(ClickObserver);
786
762
  this._balloon = editor.plugins.get(ContextualBalloon);
@@ -813,8 +789,8 @@ const VISUAL_SELECTION_MARKER_NAME = 'bookmark-ui';
813
789
  });
814
790
  }
815
791
  /**
816
- * @inheritDoc
817
- */ destroy() {
792
+ * @inheritDoc
793
+ */ destroy() {
818
794
  super.destroy();
819
795
  // Destroy created UI components as they are not automatically destroyed (see ckeditor5#1341).
820
796
  if (this.formView) {
@@ -825,16 +801,16 @@ const VISUAL_SELECTION_MARKER_NAME = 'bookmark-ui';
825
801
  }
826
802
  }
827
803
  /**
828
- * Creates views.
829
- */ _createViews() {
804
+ * Creates views.
805
+ */ _createViews() {
830
806
  this.actionsView = this._createActionsView();
831
807
  this.formView = this._createFormView();
832
808
  // Attach lifecycle actions to the the balloon.
833
809
  this._enableUserBalloonInteractions();
834
810
  }
835
811
  /**
836
- * Creates the {@link module:bookmark/ui/bookmarkactionsview~BookmarkActionsView} instance.
837
- */ _createActionsView() {
812
+ * Creates the {@link module:bookmark/ui/bookmarkactionsview~BookmarkActionsView} instance.
813
+ */ _createActionsView() {
838
814
  const editor = this.editor;
839
815
  const actionsView = new BookmarkActionsView(editor.locale);
840
816
  const updateBookmarkCommand = editor.commands.get('updateBookmark');
@@ -859,8 +835,8 @@ const VISUAL_SELECTION_MARKER_NAME = 'bookmark-ui';
859
835
  return actionsView;
860
836
  }
861
837
  /**
862
- * Creates the {@link module:bookmark/ui/bookmarkformview~BookmarkFormView} instance.
863
- */ _createFormView() {
838
+ * Creates the {@link module:bookmark/ui/bookmarkformview~BookmarkFormView} instance.
839
+ */ _createFormView() {
864
840
  const editor = this.editor;
865
841
  const locale = editor.locale;
866
842
  const insertBookmarkCommand = editor.commands.get('insertBookmark');
@@ -903,9 +879,9 @@ const VISUAL_SELECTION_MARKER_NAME = 'bookmark-ui';
903
879
  return formView;
904
880
  }
905
881
  /**
906
- * Creates a toolbar Bookmark button. Clicking this button will show
907
- * a {@link #_balloon} attached to the selection.
908
- */ _createToolbarBookmarkButton() {
882
+ * Creates a toolbar Bookmark button. Clicking this button will show
883
+ * a {@link #_balloon} attached to the selection.
884
+ */ _createToolbarBookmarkButton() {
909
885
  const editor = this.editor;
910
886
  editor.ui.componentFactory.add('bookmark', ()=>{
911
887
  const buttonView = this._createButton(ButtonView);
@@ -919,8 +895,8 @@ const VISUAL_SELECTION_MARKER_NAME = 'bookmark-ui';
919
895
  });
920
896
  }
921
897
  /**
922
- * Creates a button for `bookmark` command to use either in toolbar or in menu bar.
923
- */ _createButton(ButtonClass) {
898
+ * Creates a button for `bookmark` command to use either in toolbar or in menu bar.
899
+ */ _createButton(ButtonClass) {
924
900
  const editor = this.editor;
925
901
  const locale = editor.locale;
926
902
  const view = new ButtonClass(locale);
@@ -941,9 +917,9 @@ const VISUAL_SELECTION_MARKER_NAME = 'bookmark-ui';
941
917
  return view;
942
918
  }
943
919
  /**
944
- * Attaches actions that control whether the balloon panel containing the
945
- * {@link #formView} should be displayed.
946
- */ _enableBalloonActivators() {
920
+ * Attaches actions that control whether the balloon panel containing the
921
+ * {@link #formView} should be displayed.
922
+ */ _enableBalloonActivators() {
947
923
  const editor = this.editor;
948
924
  const viewDocument = editor.editing.view.document;
949
925
  // Handle click on view document and show panel when selection is placed inside the bookmark element.
@@ -957,9 +933,9 @@ const VISUAL_SELECTION_MARKER_NAME = 'bookmark-ui';
957
933
  });
958
934
  }
959
935
  /**
960
- * Attaches actions that control whether the balloon panel containing the
961
- * {@link #formView} is visible or not.
962
- */ _enableUserBalloonInteractions() {
936
+ * Attaches actions that control whether the balloon panel containing the
937
+ * {@link #formView} is visible or not.
938
+ */ _enableUserBalloonInteractions() {
963
939
  // Focus the form if the balloon is visible and the Tab key has been pressed.
964
940
  this.editor.keystrokes.set('Tab', (data, cancel)=>{
965
941
  if (this._areActionsVisible && !this.actionsView.focusTracker.isFocused) {
@@ -989,17 +965,17 @@ const VISUAL_SELECTION_MARKER_NAME = 'bookmark-ui';
989
965
  });
990
966
  }
991
967
  /**
992
- * Updates the button label. If bookmark is selected label is set to 'Update' otherwise
993
- * it is 'Insert'.
994
- */ _updateFormButtonLabel(isBookmarkSelected) {
968
+ * Updates the button label. If bookmark is selected label is set to 'Update' otherwise
969
+ * it is 'Insert'.
970
+ */ _updateFormButtonLabel(isBookmarkSelected) {
995
971
  const t = this.editor.locale.t;
996
972
  this.formView.buttonView.label = isBookmarkSelected ? t('Update') : t('Insert');
997
973
  }
998
974
  /**
999
- * Adds the {@link #actionsView} to the {@link #_balloon}.
1000
- *
1001
- * @internal
1002
- */ _addActionsView() {
975
+ * Adds the {@link #actionsView} to the {@link #_balloon}.
976
+ *
977
+ * @internal
978
+ */ _addActionsView() {
1003
979
  if (!this.actionsView) {
1004
980
  this._createViews();
1005
981
  }
@@ -1012,8 +988,8 @@ const VISUAL_SELECTION_MARKER_NAME = 'bookmark-ui';
1012
988
  });
1013
989
  }
1014
990
  /**
1015
- * Adds the {@link #formView} to the {@link #_balloon}.
1016
- */ _addFormView() {
991
+ * Adds the {@link #formView} to the {@link #_balloon}.
992
+ */ _addFormView() {
1017
993
  if (!this.formView) {
1018
994
  this._createViews();
1019
995
  }
@@ -1036,8 +1012,8 @@ const VISUAL_SELECTION_MARKER_NAME = 'bookmark-ui';
1036
1012
  this.formView.enableCssTransitions();
1037
1013
  }
1038
1014
  /**
1039
- * Closes the form view. Decides whether the balloon should be hidden completely.
1040
- */ _closeFormView() {
1015
+ * Closes the form view. Decides whether the balloon should be hidden completely.
1016
+ */ _closeFormView() {
1041
1017
  const updateBookmarkCommand = this.editor.commands.get('updateBookmark');
1042
1018
  if (updateBookmarkCommand.value !== undefined) {
1043
1019
  this._removeFormView();
@@ -1046,8 +1022,8 @@ const VISUAL_SELECTION_MARKER_NAME = 'bookmark-ui';
1046
1022
  }
1047
1023
  }
1048
1024
  /**
1049
- * Removes the {@link #formView} from the {@link #_balloon}.
1050
- */ _removeFormView() {
1025
+ * Removes the {@link #formView} from the {@link #_balloon}.
1026
+ */ _removeFormView() {
1051
1027
  if (this._isFormInPanel) {
1052
1028
  // Blur the input element before removing it from DOM to prevent issues in some browsers.
1053
1029
  // See https://github.com/ckeditor/ckeditor5/issues/1501.
@@ -1062,8 +1038,8 @@ const VISUAL_SELECTION_MARKER_NAME = 'bookmark-ui';
1062
1038
  }
1063
1039
  }
1064
1040
  /**
1065
- * Shows the correct UI type. It is either {@link #formView} or {@link #actionsView}.
1066
- */ _showUI(forceVisible = false) {
1041
+ * Shows the correct UI type. It is either {@link #formView} or {@link #actionsView}.
1042
+ */ _showUI(forceVisible = false) {
1067
1043
  if (!this.formView) {
1068
1044
  this._createViews();
1069
1045
  }
@@ -1093,10 +1069,10 @@ const VISUAL_SELECTION_MARKER_NAME = 'bookmark-ui';
1093
1069
  this._startUpdatingUI();
1094
1070
  }
1095
1071
  /**
1096
- * Removes the {@link #formView} from the {@link #_balloon}.
1097
- *
1098
- * See {@link #_addFormView}, {@link #_addActionsView}.
1099
- */ _hideUI() {
1072
+ * Removes the {@link #formView} from the {@link #_balloon}.
1073
+ *
1074
+ * See {@link #_addFormView}, {@link #_addActionsView}.
1075
+ */ _hideUI() {
1100
1076
  if (!this._isUIInPanel) {
1101
1077
  return;
1102
1078
  }
@@ -1113,11 +1089,11 @@ const VISUAL_SELECTION_MARKER_NAME = 'bookmark-ui';
1113
1089
  this._hideFakeVisualSelection();
1114
1090
  }
1115
1091
  /**
1116
- * Makes the UI react to the {@link module:ui/editorui/editorui~EditorUI#event:update} event to
1117
- * reposition itself when the editor UI should be refreshed.
1118
- *
1119
- * See: {@link #_hideUI} to learn when the UI stops reacting to the `update` event.
1120
- */ _startUpdatingUI() {
1092
+ * Makes the UI react to the {@link module:ui/editorui/editorui~EditorUI#event:update} event to
1093
+ * reposition itself when the editor UI should be refreshed.
1094
+ *
1095
+ * See: {@link #_hideUI} to learn when the UI stops reacting to the `update` event.
1096
+ */ _startUpdatingUI() {
1121
1097
  const editor = this.editor;
1122
1098
  const viewDocument = editor.editing.view.document;
1123
1099
  let prevSelectedBookmark = this._getSelectedBookmarkElement();
@@ -1153,37 +1129,37 @@ const VISUAL_SELECTION_MARKER_NAME = 'bookmark-ui';
1153
1129
  this.listenTo(this._balloon, 'change:visibleView', update);
1154
1130
  }
1155
1131
  /**
1156
- * Returns `true` when {@link #formView} is in the {@link #_balloon}.
1157
- */ get _isFormInPanel() {
1132
+ * Returns `true` when {@link #formView} is in the {@link #_balloon}.
1133
+ */ get _isFormInPanel() {
1158
1134
  return !!this.formView && this._balloon.hasView(this.formView);
1159
1135
  }
1160
1136
  /**
1161
- * Returns `true` when {@link #actionsView} is in the {@link #_balloon}.
1162
- */ get _areActionsInPanel() {
1137
+ * Returns `true` when {@link #actionsView} is in the {@link #_balloon}.
1138
+ */ get _areActionsInPanel() {
1163
1139
  return !!this.actionsView && this._balloon.hasView(this.actionsView);
1164
1140
  }
1165
1141
  /**
1166
- * Returns `true` when {@link #actionsView} is in the {@link #_balloon} and it is
1167
- * currently visible.
1168
- */ get _areActionsVisible() {
1142
+ * Returns `true` when {@link #actionsView} is in the {@link #_balloon} and it is
1143
+ * currently visible.
1144
+ */ get _areActionsVisible() {
1169
1145
  return !!this.actionsView && this._balloon.visibleView === this.actionsView;
1170
1146
  }
1171
1147
  /**
1172
- * Returns `true` when {@link #actionsView} or {@link #formView} is in the {@link #_balloon}.
1173
- */ get _isUIInPanel() {
1148
+ * Returns `true` when {@link #actionsView} or {@link #formView} is in the {@link #_balloon}.
1149
+ */ get _isUIInPanel() {
1174
1150
  return this._isFormInPanel || this._areActionsInPanel;
1175
1151
  }
1176
1152
  /**
1177
- * Returns `true` when {@link #actionsView} or {@link #formView} is in the {@link #_balloon} and it is
1178
- * currently visible.
1179
- */ get _isUIVisible() {
1153
+ * Returns `true` when {@link #actionsView} or {@link #formView} is in the {@link #_balloon} and it is
1154
+ * currently visible.
1155
+ */ get _isUIVisible() {
1180
1156
  const visibleView = this._balloon.visibleView;
1181
1157
  return !!this.formView && visibleView == this.formView || this._areActionsVisible;
1182
1158
  }
1183
1159
  /**
1184
- * Returns positioning options for the {@link #_balloon}. They control the way the balloon is attached
1185
- * to the target element or selection.
1186
- */ _getBalloonPositionData() {
1160
+ * Returns positioning options for the {@link #_balloon}. They control the way the balloon is attached
1161
+ * to the target element or selection.
1162
+ */ _getBalloonPositionData() {
1187
1163
  const view = this.editor.editing.view;
1188
1164
  const model = this.editor.model;
1189
1165
  let target;
@@ -1206,10 +1182,10 @@ const VISUAL_SELECTION_MARKER_NAME = 'bookmark-ui';
1206
1182
  };
1207
1183
  }
1208
1184
  /**
1209
- * Returns the bookmark {@link module:engine/view/attributeelement~AttributeElement} under
1210
- * the {@link module:engine/view/document~Document editing view's} selection or `null`
1211
- * if there is none.
1212
- */ _getSelectedBookmarkElement() {
1185
+ * Returns the bookmark {@link module:engine/view/attributeelement~AttributeElement} under
1186
+ * the {@link module:engine/view/document~Document editing view's} selection or `null`
1187
+ * if there is none.
1188
+ */ _getSelectedBookmarkElement() {
1213
1189
  const selection = this.editor.model.document.selection;
1214
1190
  const element = selection.getSelectedElement();
1215
1191
  if (element && element.is('element', 'bookmark')) {
@@ -1218,10 +1194,10 @@ const VISUAL_SELECTION_MARKER_NAME = 'bookmark-ui';
1218
1194
  return null;
1219
1195
  }
1220
1196
  /**
1221
- * Displays a fake visual selection when the contextual balloon is displayed.
1222
- *
1223
- * This adds a 'bookmark-ui' marker into the document that is rendered as a highlight on selected text fragment.
1224
- */ _showFakeVisualSelection() {
1197
+ * Displays a fake visual selection when the contextual balloon is displayed.
1198
+ *
1199
+ * This adds a 'bookmark-ui' marker into the document that is rendered as a highlight on selected text fragment.
1200
+ */ _showFakeVisualSelection() {
1225
1201
  const model = this.editor.model;
1226
1202
  model.change((writer)=>{
1227
1203
  const range = model.document.selection.getFirstRange();
@@ -1250,8 +1226,8 @@ const VISUAL_SELECTION_MARKER_NAME = 'bookmark-ui';
1250
1226
  });
1251
1227
  }
1252
1228
  /**
1253
- * Hides the fake visual selection created in {@link #_showFakeVisualSelection}.
1254
- */ _hideFakeVisualSelection() {
1229
+ * Hides the fake visual selection created in {@link #_showFakeVisualSelection}.
1230
+ */ _hideFakeVisualSelection() {
1255
1231
  const model = this.editor.model;
1256
1232
  if (model.markers.has(VISUAL_SELECTION_MARKER_NAME)) {
1257
1233
  model.change((writer)=>{
@@ -1296,13 +1272,13 @@ const VISUAL_SELECTION_MARKER_NAME = 'bookmark-ui';
1296
1272
  * For a detailed overview, check the {@glink features/bookmarks Bookmarks} feature guide.
1297
1273
  */ class Bookmark extends Plugin {
1298
1274
  /**
1299
- * @inheritDoc
1300
- */ static get pluginName() {
1275
+ * @inheritDoc
1276
+ */ static get pluginName() {
1301
1277
  return 'Bookmark';
1302
1278
  }
1303
1279
  /**
1304
- * @inheritDoc
1305
- */ static get requires() {
1280
+ * @inheritDoc
1281
+ */ static get requires() {
1306
1282
  return [
1307
1283
  BookmarkEditing,
1308
1284
  BookmarkUI,
@@ -1310,8 +1286,8 @@ const VISUAL_SELECTION_MARKER_NAME = 'bookmark-ui';
1310
1286
  ];
1311
1287
  }
1312
1288
  /**
1313
- * @inheritDoc
1314
- */ static get isOfficialPlugin() {
1289
+ * @inheritDoc
1290
+ */ static get isOfficialPlugin() {
1315
1291
  return true;
1316
1292
  }
1317
1293
  }