@ckeditor/ckeditor5-font 41.4.2 → 42.0.0-alpha.1

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
@@ -7,23 +7,37 @@ import { ColorSelectorView, createDropdown, addListToDropdown, MenuBarMenuView,
7
7
  import { Collection, CKEditorError } from '@ckeditor/ckeditor5-utils/dist/index.js';
8
8
  import { isLength, isPercentage, addBackgroundRules } from '@ckeditor/ckeditor5-engine/dist/index.js';
9
9
 
10
- class FontCommand extends Command {
10
+ /**
11
+ * The base font command.
12
+ */ class FontCommand extends Command {
13
+ /**
14
+ * A model attribute on which this command operates.
15
+ */ attributeKey;
16
+ /**
17
+ * Creates an instance of the command.
18
+ *
19
+ * @param editor Editor instance.
20
+ * @param attributeKey The name of a model attribute on which this command operates.
21
+ */ constructor(editor, attributeKey){
22
+ super(editor);
23
+ this.attributeKey = attributeKey;
24
+ }
11
25
  /**
12
- * @inheritDoc
13
- */ refresh() {
26
+ * @inheritDoc
27
+ */ refresh() {
14
28
  const model = this.editor.model;
15
29
  const doc = model.document;
16
30
  this.value = doc.selection.getAttribute(this.attributeKey);
17
31
  this.isEnabled = model.schema.checkAttributeInSelection(doc.selection, this.attributeKey);
18
32
  }
19
33
  /**
20
- * Executes the command. Applies the `value` of the {@link #attributeKey} to the selection.
21
- * If no `value` is passed, it removes the attribute from the selection.
22
- *
23
- * @param options Options for the executed command.
24
- * @param options.value The value to apply.
25
- * @fires execute
26
- */ execute(options = {}) {
34
+ * Executes the command. Applies the `value` of the {@link #attributeKey} to the selection.
35
+ * If no `value` is passed, it removes the attribute from the selection.
36
+ *
37
+ * @param options Options for the executed command.
38
+ * @param options.value The value to apply.
39
+ * @fires execute
40
+ */ execute(options = {}) {
27
41
  const model = this.editor.model;
28
42
  const document = model.document;
29
43
  const selection = document.selection;
@@ -58,15 +72,6 @@ class FontCommand extends Command {
58
72
  });
59
73
  }
60
74
  }
61
- /**
62
- * Creates an instance of the command.
63
- *
64
- * @param editor Editor instance.
65
- * @param attributeKey The name of a model attribute on which this command operates.
66
- */ constructor(editor, attributeKey){
67
- super(editor);
68
- this.attributeKey = attributeKey;
69
- }
70
75
  }
71
76
 
72
77
  /**
@@ -155,10 +160,19 @@ class FontCommand extends Command {
155
160
  return value.replace(/\s/g, '');
156
161
  }
157
162
 
158
- class FontFamilyCommand extends FontCommand {
163
+ /**
164
+ * The font family command. It is used by {@link module:font/fontfamily/fontfamilyediting~FontFamilyEditing}
165
+ * to apply the font family.
166
+ *
167
+ * ```ts
168
+ * editor.execute( 'fontFamily', { value: 'Arial' } );
169
+ * ```
170
+ *
171
+ * **Note**: Executing the command without the value removes the attribute from the model.
172
+ */ class FontFamilyCommand extends FontCommand {
159
173
  /**
160
- * @inheritDoc
161
- */ constructor(editor){
174
+ * @inheritDoc
175
+ */ constructor(editor){
162
176
  super(editor, FONT_FAMILY);
163
177
  }
164
178
  }
@@ -236,15 +250,42 @@ class FontFamilyCommand extends FontCommand {
236
250
  return fontName;
237
251
  }
238
252
 
239
- class FontFamilyEditing extends Plugin {
253
+ /**
254
+ * The font family editing feature.
255
+ *
256
+ * It introduces the {@link module:font/fontfamily/fontfamilycommand~FontFamilyCommand command} and
257
+ * the `fontFamily` attribute in the {@link module:engine/model/model~Model model} which renders
258
+ * in the {@link module:engine/view/view view} as an inline `<span>` element (`<span style="font-family: Arial">`),
259
+ * depending on the {@link module:font/fontconfig~FontFamilyConfig configuration}.
260
+ */ class FontFamilyEditing extends Plugin {
240
261
  /**
241
- * @inheritDoc
242
- */ static get pluginName() {
262
+ * @inheritDoc
263
+ */ static get pluginName() {
243
264
  return 'FontFamilyEditing';
244
265
  }
245
266
  /**
246
- * @inheritDoc
247
- */ init() {
267
+ * @inheritDoc
268
+ */ constructor(editor){
269
+ super(editor);
270
+ // Define default configuration using font families shortcuts.
271
+ editor.config.define(FONT_FAMILY, {
272
+ options: [
273
+ 'default',
274
+ 'Arial, Helvetica, sans-serif',
275
+ 'Courier New, Courier, monospace',
276
+ 'Georgia, serif',
277
+ 'Lucida Sans Unicode, Lucida Grande, sans-serif',
278
+ 'Tahoma, Geneva, sans-serif',
279
+ 'Times New Roman, Times, serif',
280
+ 'Trebuchet MS, Helvetica, sans-serif',
281
+ 'Verdana, Geneva, sans-serif'
282
+ ],
283
+ supportAllValues: false
284
+ });
285
+ }
286
+ /**
287
+ * @inheritDoc
288
+ */ init() {
248
289
  const editor = this.editor;
249
290
  // Allow fontFamily attribute on text nodes.
250
291
  editor.model.schema.extend('$text', {
@@ -267,9 +308,9 @@ class FontFamilyEditing extends Plugin {
267
308
  editor.commands.add(FONT_FAMILY, new FontFamilyCommand(editor));
268
309
  }
269
310
  /**
270
- * These converters enable keeping any value found as `style="font-family: *"` as a value of an attribute on a text even
271
- * if it is not defined in the plugin configuration.
272
- */ _prepareAnyValueConverters() {
311
+ * These converters enable keeping any value found as `style="font-family: *"` as a value of an attribute on a text even
312
+ * if it is not defined in the plugin configuration.
313
+ */ _prepareAnyValueConverters() {
273
314
  const editor = this.editor;
274
315
  editor.conversion.for('downcast').attributeToElement({
275
316
  model: FONT_FAMILY,
@@ -295,8 +336,8 @@ class FontFamilyEditing extends Plugin {
295
336
  });
296
337
  }
297
338
  /**
298
- * Adds support for legacy `<font face="..">` formatting.
299
- */ _prepareCompatibilityConverter() {
339
+ * Adds support for legacy `<font face="..">` formatting.
340
+ */ _prepareCompatibilityConverter() {
300
341
  const editor = this.editor;
301
342
  editor.conversion.for('upcast').elementToAttribute({
302
343
  view: {
@@ -311,39 +352,21 @@ class FontFamilyEditing extends Plugin {
311
352
  }
312
353
  });
313
354
  }
314
- /**
315
- * @inheritDoc
316
- */ constructor(editor){
317
- super(editor);
318
- // Define default configuration using font families shortcuts.
319
- editor.config.define(FONT_FAMILY, {
320
- options: [
321
- 'default',
322
- 'Arial, Helvetica, sans-serif',
323
- 'Courier New, Courier, monospace',
324
- 'Georgia, serif',
325
- 'Lucida Sans Unicode, Lucida Grande, sans-serif',
326
- 'Tahoma, Geneva, sans-serif',
327
- 'Times New Roman, Times, serif',
328
- 'Trebuchet MS, Helvetica, sans-serif',
329
- 'Verdana, Geneva, sans-serif'
330
- ],
331
- supportAllValues: false
332
- });
333
- }
334
355
  }
335
356
 
336
357
  var fontFamilyIcon = "<svg viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M11.03 3h6.149a.75.75 0 1 1 0 1.5h-5.514L11.03 3zm1.27 3h4.879a.75.75 0 1 1 0 1.5h-4.244L12.3 6zm1.27 3h3.609a.75.75 0 1 1 0 1.5h-2.973L13.57 9zm-2.754 2.5L8.038 4.785 5.261 11.5h5.555zm.62 1.5H4.641l-1.666 4.028H1.312l5.789-14h1.875l5.789 14h-1.663L11.436 13z\"/></svg>";
337
358
 
338
- class FontFamilyUI extends Plugin {
359
+ /**
360
+ * The font family UI plugin. It introduces the `'fontFamily'` dropdown.
361
+ */ class FontFamilyUI extends Plugin {
339
362
  /**
340
- * @inheritDoc
341
- */ static get pluginName() {
363
+ * @inheritDoc
364
+ */ static get pluginName() {
342
365
  return 'FontFamilyUI';
343
366
  }
344
367
  /**
345
- * @inheritDoc
346
- */ init() {
368
+ * @inheritDoc
369
+ */ init() {
347
370
  const editor = this.editor;
348
371
  const t = editor.t;
349
372
  const options = this._getLocalizedOptions();
@@ -405,13 +428,13 @@ class FontFamilyUI extends Plugin {
405
428
  });
406
429
  }
407
430
  /**
408
- * Returns options as defined in `config.fontFamily.options` but processed to account for
409
- * editor localization, i.e. to display {@link module:font/fontconfig~FontFamilyOption}
410
- * in the correct language.
411
- *
412
- * Note: The reason behind this method is that there is no way to use {@link module:utils/locale~Locale#t}
413
- * when the user configuration is defined because the editor does not exist yet.
414
- */ _getLocalizedOptions() {
431
+ * Returns options as defined in `config.fontFamily.options` but processed to account for
432
+ * editor localization, i.e. to display {@link module:font/fontconfig~FontFamilyOption}
433
+ * in the correct language.
434
+ *
435
+ * Note: The reason behind this method is that there is no way to use {@link module:utils/locale~Locale#t}
436
+ * when the user configuration is defined because the editor does not exist yet.
437
+ */ _getLocalizedOptions() {
415
438
  const editor = this.editor;
416
439
  const t = editor.t;
417
440
  const options = normalizeOptions$1(editor.config.get(FONT_FAMILY).options);
@@ -459,26 +482,43 @@ class FontFamilyUI extends Plugin {
459
482
  return itemDefinitions;
460
483
  }
461
484
 
462
- class FontFamily extends Plugin {
485
+ /**
486
+ * The font family plugin.
487
+ *
488
+ * For a detailed overview, check the {@glink features/font font feature} documentatiom
489
+ * and the {@glink api/font package page}.
490
+ *
491
+ * This is a "glue" plugin which loads the {@link module:font/fontfamily/fontfamilyediting~FontFamilyEditing} and
492
+ * {@link module:font/fontfamily/fontfamilyui~FontFamilyUI} features in the editor.
493
+ */ class FontFamily extends Plugin {
463
494
  /**
464
- * @inheritDoc
465
- */ static get requires() {
495
+ * @inheritDoc
496
+ */ static get requires() {
466
497
  return [
467
498
  FontFamilyEditing,
468
499
  FontFamilyUI
469
500
  ];
470
501
  }
471
502
  /**
472
- * @inheritDoc
473
- */ static get pluginName() {
503
+ * @inheritDoc
504
+ */ static get pluginName() {
474
505
  return 'FontFamily';
475
506
  }
476
507
  }
477
508
 
478
- class FontSizeCommand extends FontCommand {
509
+ /**
510
+ * The font size command. It is used by {@link module:font/fontsize/fontsizeediting~FontSizeEditing}
511
+ * to apply the font size.
512
+ *
513
+ * ```ts
514
+ * editor.execute( 'fontSize', { value: 'small' } );
515
+ * ```
516
+ *
517
+ * **Note**: Executing the command without the value removes the attribute from the model.
518
+ */ class FontSizeCommand extends FontCommand {
479
519
  /**
480
- * @inheritDoc
481
- */ constructor(editor){
520
+ * @inheritDoc
521
+ */ constructor(editor){
482
522
  super(editor, FONT_SIZE);
483
523
  }
484
524
  }
@@ -616,12 +656,12 @@ function isNumericalDefinition(definition) {
616
656
  if (typeof definition === 'object') {
617
657
  if (!definition.model) {
618
658
  /**
619
- * Provided value as an option for {@link module:font/fontsize~FontSize} seems to invalid.
620
- *
621
- * See valid examples described in the {@link module:font/fontconfig~FontSizeConfig#options plugin configuration}.
622
- *
623
- * @error font-size-invalid-definition
624
- */ throw new CKEditorError('font-size-invalid-definition', null, definition);
659
+ * Provided value as an option for {@link module:font/fontsize~FontSize} seems to invalid.
660
+ *
661
+ * See valid examples described in the {@link module:font/fontconfig~FontSizeConfig#options plugin configuration}.
662
+ *
663
+ * @error font-size-invalid-definition
664
+ */ throw new CKEditorError('font-size-invalid-definition', null, definition);
625
665
  } else {
626
666
  numberValue = parseFloat(definition.model);
627
667
  }
@@ -642,15 +682,41 @@ const styleFontSize = [
642
682
  'xx-large',
643
683
  'xxx-large'
644
684
  ];
645
- class FontSizeEditing extends Plugin {
685
+ /**
686
+ * The font size editing feature.
687
+ *
688
+ * It introduces the {@link module:font/fontsize/fontsizecommand~FontSizeCommand command} and the `fontSize`
689
+ * attribute in the {@link module:engine/model/model~Model model} which renders in the {@link module:engine/view/view view}
690
+ * as a `<span>` element with either:
691
+ * * a style attribute (`<span style="font-size:12px">...</span>`),
692
+ * * or a class attribute (`<span class="text-small">...</span>`)
693
+ *
694
+ * depending on the {@link module:font/fontconfig~FontSizeConfig configuration}.
695
+ */ class FontSizeEditing extends Plugin {
646
696
  /**
647
- * @inheritDoc
648
- */ static get pluginName() {
697
+ * @inheritDoc
698
+ */ static get pluginName() {
649
699
  return 'FontSizeEditing';
650
700
  }
651
701
  /**
652
- * @inheritDoc
653
- */ init() {
702
+ * @inheritDoc
703
+ */ constructor(editor){
704
+ super(editor);
705
+ // Define default configuration using named presets.
706
+ editor.config.define(FONT_SIZE, {
707
+ options: [
708
+ 'tiny',
709
+ 'small',
710
+ 'default',
711
+ 'big',
712
+ 'huge'
713
+ ],
714
+ supportAllValues: false
715
+ });
716
+ }
717
+ /**
718
+ * @inheritDoc
719
+ */ init() {
654
720
  const editor = this.editor;
655
721
  // Allow fontSize attribute on text nodes.
656
722
  editor.model.schema.extend('$text', {
@@ -675,11 +741,11 @@ class FontSizeEditing extends Plugin {
675
741
  editor.commands.add(FONT_SIZE, new FontSizeCommand(editor));
676
742
  }
677
743
  /**
678
- * These converters enable keeping any value found as `style="font-size: *"` as a value of an attribute on a text even
679
- * if it is not defined in the plugin configuration.
680
- *
681
- * @param definition Converter definition out of input data.
682
- */ _prepareAnyValueConverters(definition) {
744
+ * These converters enable keeping any value found as `style="font-size: *"` as a value of an attribute on a text even
745
+ * if it is not defined in the plugin configuration.
746
+ *
747
+ * @param definition Converter definition out of input data.
748
+ */ _prepareAnyValueConverters(definition) {
683
749
  const editor = this.editor;
684
750
  // If `fontSize.supportAllValues=true`, we do not allow to use named presets in the plugin's configuration.
685
751
  const presets = definition.model.values.filter((value)=>{
@@ -687,14 +753,14 @@ class FontSizeEditing extends Plugin {
687
753
  });
688
754
  if (presets.length) {
689
755
  /**
690
- * If {@link module:font/fontconfig~FontSizeConfig#supportAllValues `config.fontSize.supportAllValues`} is `true`,
691
- * you need to use numerical values as font size options.
692
- *
693
- * See valid examples described in the {@link module:font/fontconfig~FontSizeConfig#options plugin configuration}.
694
- *
695
- * @error font-size-invalid-use-of-named-presets
696
- * @param {Array.<String>} presets Invalid values.
697
- */ throw new CKEditorError('font-size-invalid-use-of-named-presets', null, {
756
+ * If {@link module:font/fontconfig~FontSizeConfig#supportAllValues `config.fontSize.supportAllValues`} is `true`,
757
+ * you need to use numerical values as font size options.
758
+ *
759
+ * See valid examples described in the {@link module:font/fontconfig~FontSizeConfig#options plugin configuration}.
760
+ *
761
+ * @error font-size-invalid-use-of-named-presets
762
+ * @param {Array.<String>} presets Invalid values.
763
+ */ throw new CKEditorError('font-size-invalid-use-of-named-presets', null, {
698
764
  presets
699
765
  });
700
766
  }
@@ -725,8 +791,8 @@ class FontSizeEditing extends Plugin {
725
791
  });
726
792
  }
727
793
  /**
728
- * Adds support for legacy `<font size="..">` formatting.
729
- */ _prepareCompatibilityConverter() {
794
+ * Adds support for legacy `<font size="..">` formatting.
795
+ */ _prepareCompatibilityConverter() {
730
796
  const editor = this.editor;
731
797
  editor.conversion.for('upcast').elementToAttribute({
732
798
  view: {
@@ -755,35 +821,21 @@ class FontSizeEditing extends Plugin {
755
821
  }
756
822
  });
757
823
  }
758
- /**
759
- * @inheritDoc
760
- */ constructor(editor){
761
- super(editor);
762
- // Define default configuration using named presets.
763
- editor.config.define(FONT_SIZE, {
764
- options: [
765
- 'tiny',
766
- 'small',
767
- 'default',
768
- 'big',
769
- 'huge'
770
- ],
771
- supportAllValues: false
772
- });
773
- }
774
824
  }
775
825
 
776
826
  var fontSizeIcon = "<svg viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M9.816 11.5 7.038 4.785 4.261 11.5h5.555zm.62 1.5H3.641l-1.666 4.028H.312l5.789-14h1.875l5.789 14h-1.663L10.436 13zm7.55 2.279.779-.779.707.707-2.265 2.265-2.193-2.265.707-.707.765.765V4.825c0-.042 0-.083.002-.123l-.77.77-.707-.707L17.207 2.5l2.265 2.265-.707.707-.782-.782c.002.043.003.089.003.135v10.454z\"/></svg>";
777
827
 
778
- class FontSizeUI extends Plugin {
828
+ /**
829
+ * The font size UI plugin. It introduces the `'fontSize'` dropdown.
830
+ */ class FontSizeUI extends Plugin {
779
831
  /**
780
- * @inheritDoc
781
- */ static get pluginName() {
832
+ * @inheritDoc
833
+ */ static get pluginName() {
782
834
  return 'FontSizeUI';
783
835
  }
784
836
  /**
785
- * @inheritDoc
786
- */ init() {
837
+ * @inheritDoc
838
+ */ init() {
787
839
  const editor = this.editor;
788
840
  const t = editor.t;
789
841
  const options = this._getLocalizedOptions();
@@ -848,13 +900,13 @@ class FontSizeUI extends Plugin {
848
900
  });
849
901
  }
850
902
  /**
851
- * Returns options as defined in `config.fontSize.options` but processed to account for
852
- * editor localization, i.e. to display {@link module:font/fontconfig~FontSizeOption}
853
- * in the correct language.
854
- *
855
- * Note: The reason behind this method is that there is no way to use {@link module:utils/locale~Locale#t}
856
- * when the user configuration is defined because the editor does not exist yet.
857
- */ _getLocalizedOptions() {
903
+ * Returns options as defined in `config.fontSize.options` but processed to account for
904
+ * editor localization, i.e. to display {@link module:font/fontconfig~FontSizeOption}
905
+ * in the correct language.
906
+ *
907
+ * Note: The reason behind this method is that there is no way to use {@link module:utils/locale~Locale#t}
908
+ * when the user configuration is defined because the editor does not exist yet.
909
+ */ _getLocalizedOptions() {
858
910
  const editor = this.editor;
859
911
  const t = editor.t;
860
912
  const localizedTitles = {
@@ -908,47 +960,71 @@ class FontSizeUI extends Plugin {
908
960
  return itemDefinitions;
909
961
  }
910
962
 
911
- class FontSize extends Plugin {
963
+ /**
964
+ * The font size plugin.
965
+ *
966
+ * For a detailed overview, check the {@glink features/font font feature} documentation
967
+ * and the {@glink api/font package page}.
968
+ *
969
+ * This is a "glue" plugin which loads the {@link module:font/fontsize/fontsizeediting~FontSizeEditing} and
970
+ * {@link module:font/fontsize/fontsizeui~FontSizeUI} features in the editor.
971
+ */ class FontSize extends Plugin {
912
972
  /**
913
- * @inheritDoc
914
- */ static get requires() {
973
+ * @inheritDoc
974
+ */ static get requires() {
915
975
  return [
916
976
  FontSizeEditing,
917
977
  FontSizeUI
918
978
  ];
919
979
  }
920
980
  /**
921
- * @inheritDoc
922
- */ static get pluginName() {
981
+ * @inheritDoc
982
+ */ static get pluginName() {
923
983
  return 'FontSize';
924
984
  }
925
985
  /**
926
- * Normalizes and translates the {@link module:font/fontconfig~FontSizeConfig#options configuration options}
927
- * to the {@link module:font/fontconfig~FontSizeOption} format.
928
- *
929
- * @param configuredOptions An array of options taken from the configuration.
930
- */ normalizeSizeOptions(options) {
986
+ * Normalizes and translates the {@link module:font/fontconfig~FontSizeConfig#options configuration options}
987
+ * to the {@link module:font/fontconfig~FontSizeOption} format.
988
+ *
989
+ * @param configuredOptions An array of options taken from the configuration.
990
+ */ normalizeSizeOptions(options) {
931
991
  return normalizeOptions(options);
932
992
  }
933
993
  }
934
994
 
935
- class FontColorCommand extends FontCommand {
995
+ /**
996
+ * The font color command. It is used by {@link module:font/fontcolor/fontcolorediting~FontColorEditing}
997
+ * to apply the font color.
998
+ *
999
+ * ```ts
1000
+ * editor.execute( 'fontColor', { value: 'rgb(250, 20, 20)' } );
1001
+ * ```
1002
+ *
1003
+ * **Note**: Executing the command with the `null` value removes the attribute from the model.
1004
+ */ class FontColorCommand extends FontCommand {
936
1005
  /**
937
- * @inheritDoc
938
- */ constructor(editor){
1006
+ * @inheritDoc
1007
+ */ constructor(editor){
939
1008
  super(editor, FONT_COLOR);
940
1009
  }
941
1010
  }
942
1011
 
943
- class FontColorEditing extends Plugin {
1012
+ /**
1013
+ * The font color editing feature.
1014
+ *
1015
+ * It introduces the {@link module:font/fontcolor/fontcolorcommand~FontColorCommand command} and
1016
+ * the `fontColor` attribute in the {@link module:engine/model/model~Model model} which renders
1017
+ * in the {@link module:engine/view/view view} as a `<span>` element (`<span style="color: ...">`),
1018
+ * depending on the {@link module:font/fontconfig~FontColorConfig configuration}.
1019
+ */ class FontColorEditing extends Plugin {
944
1020
  /**
945
- * @inheritDoc
946
- */ static get pluginName() {
1021
+ * @inheritDoc
1022
+ */ static get pluginName() {
947
1023
  return 'FontColorEditing';
948
1024
  }
949
1025
  /**
950
- * @inheritDoc
951
- */ constructor(editor){
1026
+ * @inheritDoc
1027
+ */ constructor(editor){
952
1028
  super(editor);
953
1029
  editor.config.define(FONT_COLOR, {
954
1030
  colors: [
@@ -1057,10 +1133,49 @@ class FontColorEditing extends Plugin {
1057
1133
  }
1058
1134
  }
1059
1135
 
1060
- class ColorUI extends Plugin {
1136
+ /**
1137
+ * The color UI plugin which isolates the common logic responsible for displaying dropdowns with color grids.
1138
+ *
1139
+ * It is used to create the `'fontBackgroundColor'` and `'fontColor'` dropdowns, each hosting
1140
+ * a {@link module:ui/colorselector/colorselectorview~ColorSelectorView}.
1141
+ */ class ColorUI extends Plugin {
1142
+ /**
1143
+ * The name of the command which will be executed when a color tile is clicked.
1144
+ */ commandName;
1145
+ /**
1146
+ * The name of this component in the {@link module:ui/componentfactory~ComponentFactory}.
1147
+ * Also the configuration scope name in `editor.config`.
1148
+ */ componentName;
1149
+ /**
1150
+ * The SVG icon used by the dropdown.
1151
+ */ icon;
1152
+ /**
1153
+ * The label used by the dropdown.
1154
+ */ dropdownLabel;
1155
+ /**
1156
+ * The number of columns in the color grid.
1157
+ */ columns;
1158
+ /**
1159
+ * Creates a plugin which introduces a dropdown with a pre–configured
1160
+ * {@link module:ui/colorselector/colorselectorview~ColorSelectorView}.
1161
+ *
1162
+ * @param config The configuration object.
1163
+ * @param config.commandName The name of the command which will be executed when a color tile is clicked.
1164
+ * @param config.componentName The name of the dropdown in the {@link module:ui/componentfactory~ComponentFactory}
1165
+ * and the configuration scope name in `editor.config`.
1166
+ * @param config.icon The SVG icon used by the dropdown.
1167
+ * @param config.dropdownLabel The label used by the dropdown.
1168
+ */ constructor(editor, { commandName, componentName, icon, dropdownLabel }){
1169
+ super(editor);
1170
+ this.commandName = commandName;
1171
+ this.componentName = componentName;
1172
+ this.icon = icon;
1173
+ this.dropdownLabel = dropdownLabel;
1174
+ this.columns = editor.config.get(`${this.componentName}.columns`);
1175
+ }
1061
1176
  /**
1062
- * @inheritDoc
1063
- */ init() {
1177
+ * @inheritDoc
1178
+ */ init() {
1064
1179
  const editor = this.editor;
1065
1180
  const locale = editor.locale;
1066
1181
  const t = locale.t;
@@ -1199,37 +1314,16 @@ class ColorUI extends Plugin {
1199
1314
  return menuView;
1200
1315
  });
1201
1316
  }
1202
- /**
1203
- * Creates a plugin which introduces a dropdown with a pre–configured
1204
- * {@link module:ui/colorselector/colorselectorview~ColorSelectorView}.
1205
- *
1206
- * @param config The configuration object.
1207
- * @param config.commandName The name of the command which will be executed when a color tile is clicked.
1208
- * @param config.componentName The name of the dropdown in the {@link module:ui/componentfactory~ComponentFactory}
1209
- * and the configuration scope name in `editor.config`.
1210
- * @param config.icon The SVG icon used by the dropdown.
1211
- * @param config.dropdownLabel The label used by the dropdown.
1212
- */ constructor(editor, { commandName, componentName, icon, dropdownLabel }){
1213
- super(editor);
1214
- this.commandName = commandName;
1215
- this.componentName = componentName;
1216
- this.icon = icon;
1217
- this.dropdownLabel = dropdownLabel;
1218
- this.columns = editor.config.get(`${this.componentName}.columns`);
1219
- }
1220
1317
  }
1221
1318
 
1222
1319
  var fontColorIcon = "<svg viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M12.4 10.3 10 4.5l-2.4 5.8h4.8zm.5 1.2H7.1L5.7 15H4.2l5-12h1.6l5 12h-1.5L13 11.5zm3.1 7H4a1 1 0 0 1 0-2h12a1 1 0 0 1 0 2z\"/></svg>";
1223
1320
 
1224
- class FontColorUI extends ColorUI {
1225
- /**
1226
- * @inheritDoc
1227
- */ static get pluginName() {
1228
- return 'FontColorUI';
1229
- }
1321
+ /**
1322
+ * The font color UI plugin. It introduces the `'fontColor'` dropdown.
1323
+ */ class FontColorUI extends ColorUI {
1230
1324
  /**
1231
- * @inheritDoc
1232
- */ constructor(editor){
1325
+ * @inheritDoc
1326
+ */ constructor(editor){
1233
1327
  const t = editor.locale.t;
1234
1328
  super(editor, {
1235
1329
  commandName: FONT_COLOR,
@@ -1238,41 +1332,71 @@ class FontColorUI extends ColorUI {
1238
1332
  dropdownLabel: t('Font Color')
1239
1333
  });
1240
1334
  }
1335
+ /**
1336
+ * @inheritDoc
1337
+ */ static get pluginName() {
1338
+ return 'FontColorUI';
1339
+ }
1241
1340
  }
1242
1341
 
1243
- class FontColor extends Plugin {
1342
+ /**
1343
+ * The font color plugin.
1344
+ *
1345
+ * For a detailed overview, check the {@glink features/font font feature} documentation
1346
+ * and the {@glink api/font package page}.
1347
+ *
1348
+ * This is a "glue" plugin which loads the {@link module:font/fontcolor/fontcolorediting~FontColorEditing} and
1349
+ * {@link module:font/fontcolor/fontcolorui~FontColorUI} features in the editor.
1350
+ */ class FontColor extends Plugin {
1244
1351
  /**
1245
- * @inheritDoc
1246
- */ static get requires() {
1352
+ * @inheritDoc
1353
+ */ static get requires() {
1247
1354
  return [
1248
1355
  FontColorEditing,
1249
1356
  FontColorUI
1250
1357
  ];
1251
1358
  }
1252
1359
  /**
1253
- * @inheritDoc
1254
- */ static get pluginName() {
1360
+ * @inheritDoc
1361
+ */ static get pluginName() {
1255
1362
  return 'FontColor';
1256
1363
  }
1257
1364
  }
1258
1365
 
1259
- class FontBackgroundColorCommand extends FontCommand {
1366
+ /**
1367
+ * The font background color command. It is used by
1368
+ * {@link module:font/fontbackgroundcolor/fontbackgroundcolorediting~FontBackgroundColorEditing}
1369
+ * to apply the font background color.
1370
+ *
1371
+ * ```ts
1372
+ * editor.execute( 'fontBackgroundColor', { value: 'rgb(250, 20, 20)' } );
1373
+ * ```
1374
+ *
1375
+ * **Note**: Executing the command with the `null` value removes the attribute from the model.
1376
+ */ class FontBackgroundColorCommand extends FontCommand {
1260
1377
  /**
1261
- * @inheritDoc
1262
- */ constructor(editor){
1378
+ * @inheritDoc
1379
+ */ constructor(editor){
1263
1380
  super(editor, FONT_BACKGROUND_COLOR);
1264
1381
  }
1265
1382
  }
1266
1383
 
1267
- class FontBackgroundColorEditing extends Plugin {
1384
+ /**
1385
+ * The font background color editing feature.
1386
+ *
1387
+ * It introduces the {@link module:font/fontbackgroundcolor/fontbackgroundcolorcommand~FontBackgroundColorCommand command} and
1388
+ * the `fontBackgroundColor` attribute in the {@link module:engine/model/model~Model model} which renders
1389
+ * in the {@link module:engine/view/view view} as a `<span>` element (`<span style="background-color: ...">`),
1390
+ * depending on the {@link module:font/fontconfig~FontColorConfig configuration}.
1391
+ */ class FontBackgroundColorEditing extends Plugin {
1268
1392
  /**
1269
- * @inheritDoc
1270
- */ static get pluginName() {
1393
+ * @inheritDoc
1394
+ */ static get pluginName() {
1271
1395
  return 'FontBackgroundColorEditing';
1272
1396
  }
1273
1397
  /**
1274
- * @inheritDoc
1275
- */ constructor(editor){
1398
+ * @inheritDoc
1399
+ */ constructor(editor){
1276
1400
  super(editor);
1277
1401
  editor.config.define(FONT_BACKGROUND_COLOR, {
1278
1402
  colors: [
@@ -1371,15 +1495,12 @@ class FontBackgroundColorEditing extends Plugin {
1371
1495
 
1372
1496
  var fontBackgroundColorIcon = "<svg viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M4 2h12a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2zm8.38 9.262H7.62L10 5.506l2.38 5.756zm.532 1.285L14.34 16h1.426L10.804 4H9.196L4.234 16H5.66l1.428-3.453h5.824z\"/></svg>";
1373
1497
 
1374
- class FontBackgroundColorUI extends ColorUI {
1375
- /**
1376
- * @inheritDoc
1377
- */ static get pluginName() {
1378
- return 'FontBackgroundColorUI';
1379
- }
1498
+ /**
1499
+ * The font background color UI plugin. It introduces the `'fontBackgroundColor'` dropdown.
1500
+ */ class FontBackgroundColorUI extends ColorUI {
1380
1501
  /**
1381
- * @inheritDoc
1382
- */ constructor(editor){
1502
+ * @inheritDoc
1503
+ */ constructor(editor){
1383
1504
  const t = editor.locale.t;
1384
1505
  super(editor, {
1385
1506
  commandName: FONT_BACKGROUND_COLOR,
@@ -1388,28 +1509,52 @@ class FontBackgroundColorUI extends ColorUI {
1388
1509
  dropdownLabel: t('Font Background Color')
1389
1510
  });
1390
1511
  }
1512
+ /**
1513
+ * @inheritDoc
1514
+ */ static get pluginName() {
1515
+ return 'FontBackgroundColorUI';
1516
+ }
1391
1517
  }
1392
1518
 
1393
- class FontBackgroundColor extends Plugin {
1519
+ /**
1520
+ * The font background color plugin.
1521
+ *
1522
+ * For a detailed overview, check the {@glink features/font font feature} documentation
1523
+ * and the {@glink api/font package page}.
1524
+ *
1525
+ * This is a "glue" plugin which loads
1526
+ * the {@link module:font/fontbackgroundcolor/fontbackgroundcolorediting~FontBackgroundColorEditing} and
1527
+ * {@link module:font/fontbackgroundcolor/fontbackgroundcolorui~FontBackgroundColorUI} features in the editor.
1528
+ */ class FontBackgroundColor extends Plugin {
1394
1529
  /**
1395
- * @inheritDoc
1396
- */ static get requires() {
1530
+ * @inheritDoc
1531
+ */ static get requires() {
1397
1532
  return [
1398
1533
  FontBackgroundColorEditing,
1399
1534
  FontBackgroundColorUI
1400
1535
  ];
1401
1536
  }
1402
1537
  /**
1403
- * @inheritDoc
1404
- */ static get pluginName() {
1538
+ * @inheritDoc
1539
+ */ static get pluginName() {
1405
1540
  return 'FontBackgroundColor';
1406
1541
  }
1407
1542
  }
1408
1543
 
1409
- class Font extends Plugin {
1544
+ /**
1545
+ * A plugin that enables a set of text styling features:
1546
+ *
1547
+ * * {@link module:font/fontsize~FontSize},
1548
+ * * {@link module:font/fontfamily~FontFamily}.
1549
+ * * {@link module:font/fontcolor~FontColor},
1550
+ * * {@link module:font/fontbackgroundcolor~FontBackgroundColor}.
1551
+ *
1552
+ * For a detailed overview, check the {@glink features/font Font feature} documentation
1553
+ * and the {@glink api/font package page}.
1554
+ */ class Font extends Plugin {
1410
1555
  /**
1411
- * @inheritDoc
1412
- */ static get requires() {
1556
+ * @inheritDoc
1557
+ */ static get requires() {
1413
1558
  return [
1414
1559
  FontFamily,
1415
1560
  FontSize,
@@ -1418,8 +1563,8 @@ class Font extends Plugin {
1418
1563
  ];
1419
1564
  }
1420
1565
  /**
1421
- * @inheritDoc
1422
- */ static get pluginName() {
1566
+ * @inheritDoc
1567
+ */ static get pluginName() {
1423
1568
  return 'Font';
1424
1569
  }
1425
1570
  }