@ckeditor/ckeditor5-font 40.0.0 → 40.2.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.
Files changed (54) hide show
  1. package/CHANGELOG.md +19 -19
  2. package/LICENSE.md +3 -3
  3. package/package.json +2 -2
  4. package/src/augmentation.d.ts +58 -58
  5. package/src/augmentation.js +5 -5
  6. package/src/font.d.ts +33 -33
  7. package/src/font.js +37 -37
  8. package/src/fontbackgroundcolor/fontbackgroundcolorcommand.d.ts +26 -26
  9. package/src/fontbackgroundcolor/fontbackgroundcolorcommand.js +25 -25
  10. package/src/fontbackgroundcolor/fontbackgroundcolorediting.d.ts +26 -26
  11. package/src/fontbackgroundcolor/fontbackgroundcolorediting.js +123 -123
  12. package/src/fontbackgroundcolor/fontbackgroundcolorui.d.ts +22 -22
  13. package/src/fontbackgroundcolor/fontbackgroundcolorui.js +33 -33
  14. package/src/fontbackgroundcolor.d.ts +30 -30
  15. package/src/fontbackgroundcolor.js +34 -34
  16. package/src/fontcolor/fontcolorcommand.d.ts +25 -25
  17. package/src/fontcolor/fontcolorcommand.js +24 -24
  18. package/src/fontcolor/fontcolorediting.d.ts +26 -26
  19. package/src/fontcolor/fontcolorediting.js +134 -134
  20. package/src/fontcolor/fontcolorui.d.ts +22 -22
  21. package/src/fontcolor/fontcolorui.js +33 -33
  22. package/src/fontcolor.d.ts +29 -29
  23. package/src/fontcolor.js +33 -33
  24. package/src/fontcommand.d.ts +48 -48
  25. package/src/fontcommand.js +79 -79
  26. package/src/fontconfig.d.ts +373 -373
  27. package/src/fontconfig.js +5 -5
  28. package/src/fontfamily/fontfamilycommand.d.ts +25 -25
  29. package/src/fontfamily/fontfamilycommand.js +24 -24
  30. package/src/fontfamily/fontfamilyediting.d.ts +39 -39
  31. package/src/fontfamily/fontfamilyediting.js +115 -115
  32. package/src/fontfamily/fontfamilyui.d.ts +30 -30
  33. package/src/fontfamily/fontfamilyui.js +114 -114
  34. package/src/fontfamily/utils.d.ts +15 -15
  35. package/src/fontfamily/utils.js +80 -80
  36. package/src/fontfamily.d.ts +29 -29
  37. package/src/fontfamily.js +33 -33
  38. package/src/fontsize/fontsizecommand.d.ts +25 -25
  39. package/src/fontsize/fontsizecommand.js +24 -24
  40. package/src/fontsize/fontsizeediting.d.ts +44 -44
  41. package/src/fontsize/fontsizeediting.js +165 -165
  42. package/src/fontsize/fontsizeui.d.ts +31 -31
  43. package/src/fontsize/fontsizeui.js +122 -122
  44. package/src/fontsize/utils.d.ts +12 -12
  45. package/src/fontsize/utils.js +166 -166
  46. package/src/fontsize.d.ts +37 -37
  47. package/src/fontsize.js +43 -43
  48. package/src/index.d.ts +27 -27
  49. package/src/index.js +21 -21
  50. package/src/ui/colorui.d.ts +68 -68
  51. package/src/ui/colorui.js +130 -130
  52. package/src/utils.d.ts +80 -80
  53. package/src/utils.js +97 -97
  54. package/build/font.js.map +0 -1
@@ -1,79 +1,79 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @module font/fontcommand
7
- */
8
- import { Command } from 'ckeditor5/src/core';
9
- /**
10
- * The base font command.
11
- */
12
- export default class FontCommand extends Command {
13
- /**
14
- * Creates an instance of the command.
15
- *
16
- * @param editor Editor instance.
17
- * @param attributeKey The name of a model attribute on which this command operates.
18
- */
19
- constructor(editor, attributeKey) {
20
- super(editor);
21
- this.attributeKey = attributeKey;
22
- }
23
- /**
24
- * @inheritDoc
25
- */
26
- refresh() {
27
- const model = this.editor.model;
28
- const doc = model.document;
29
- this.value = doc.selection.getAttribute(this.attributeKey);
30
- this.isEnabled = model.schema.checkAttributeInSelection(doc.selection, this.attributeKey);
31
- }
32
- /**
33
- * Executes the command. Applies the `value` of the {@link #attributeKey} to the selection.
34
- * If no `value` is passed, it removes the attribute from the selection.
35
- *
36
- * @param options Options for the executed command.
37
- * @param options.value The value to apply.
38
- * @fires execute
39
- */
40
- execute(options = {}) {
41
- const model = this.editor.model;
42
- const document = model.document;
43
- const selection = document.selection;
44
- const value = options.value;
45
- const batch = options.batch;
46
- const updateAttribute = (writer) => {
47
- if (selection.isCollapsed) {
48
- if (value) {
49
- writer.setSelectionAttribute(this.attributeKey, value);
50
- }
51
- else {
52
- writer.removeSelectionAttribute(this.attributeKey);
53
- }
54
- }
55
- else {
56
- const ranges = model.schema.getValidRanges(selection.getRanges(), this.attributeKey);
57
- for (const range of ranges) {
58
- if (value) {
59
- writer.setAttribute(this.attributeKey, value, range);
60
- }
61
- else {
62
- writer.removeAttribute(this.attributeKey, range);
63
- }
64
- }
65
- }
66
- };
67
- // In some scenarios, you may want to use a single undo step for multiple changes (e.g. in color picker).
68
- if (batch) {
69
- model.enqueueChange(batch, writer => {
70
- updateAttribute(writer);
71
- });
72
- }
73
- else {
74
- model.change(writer => {
75
- updateAttribute(writer);
76
- });
77
- }
78
- }
79
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module font/fontcommand
7
+ */
8
+ import { Command } from 'ckeditor5/src/core';
9
+ /**
10
+ * The base font command.
11
+ */
12
+ export default class FontCommand extends Command {
13
+ /**
14
+ * Creates an instance of the command.
15
+ *
16
+ * @param editor Editor instance.
17
+ * @param attributeKey The name of a model attribute on which this command operates.
18
+ */
19
+ constructor(editor, attributeKey) {
20
+ super(editor);
21
+ this.attributeKey = attributeKey;
22
+ }
23
+ /**
24
+ * @inheritDoc
25
+ */
26
+ refresh() {
27
+ const model = this.editor.model;
28
+ const doc = model.document;
29
+ this.value = doc.selection.getAttribute(this.attributeKey);
30
+ this.isEnabled = model.schema.checkAttributeInSelection(doc.selection, this.attributeKey);
31
+ }
32
+ /**
33
+ * Executes the command. Applies the `value` of the {@link #attributeKey} to the selection.
34
+ * If no `value` is passed, it removes the attribute from the selection.
35
+ *
36
+ * @param options Options for the executed command.
37
+ * @param options.value The value to apply.
38
+ * @fires execute
39
+ */
40
+ execute(options = {}) {
41
+ const model = this.editor.model;
42
+ const document = model.document;
43
+ const selection = document.selection;
44
+ const value = options.value;
45
+ const batch = options.batch;
46
+ const updateAttribute = (writer) => {
47
+ if (selection.isCollapsed) {
48
+ if (value) {
49
+ writer.setSelectionAttribute(this.attributeKey, value);
50
+ }
51
+ else {
52
+ writer.removeSelectionAttribute(this.attributeKey);
53
+ }
54
+ }
55
+ else {
56
+ const ranges = model.schema.getValidRanges(selection.getRanges(), this.attributeKey);
57
+ for (const range of ranges) {
58
+ if (value) {
59
+ writer.setAttribute(this.attributeKey, value, range);
60
+ }
61
+ else {
62
+ writer.removeAttribute(this.attributeKey, range);
63
+ }
64
+ }
65
+ }
66
+ };
67
+ // In some scenarios, you may want to use a single undo step for multiple changes (e.g. in color picker).
68
+ if (batch) {
69
+ model.enqueueChange(batch, writer => {
70
+ updateAttribute(writer);
71
+ });
72
+ }
73
+ else {
74
+ model.change(writer => {
75
+ updateAttribute(writer);
76
+ });
77
+ }
78
+ }
79
+ }