@ckeditor/ckeditor5-font 39.0.2 → 40.0.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/build/font.js.map +1 -0
- package/package.json +2 -2
- package/src/augmentation.d.ts +58 -58
- package/src/augmentation.js +5 -5
- package/src/font.d.ts +33 -33
- package/src/font.js +37 -37
- package/src/fontbackgroundcolor/fontbackgroundcolorcommand.d.ts +26 -26
- package/src/fontbackgroundcolor/fontbackgroundcolorcommand.js +25 -25
- package/src/fontbackgroundcolor/fontbackgroundcolorediting.d.ts +26 -26
- package/src/fontbackgroundcolor/fontbackgroundcolorediting.js +123 -123
- package/src/fontbackgroundcolor/fontbackgroundcolorui.d.ts +22 -22
- package/src/fontbackgroundcolor/fontbackgroundcolorui.js +33 -33
- package/src/fontbackgroundcolor.d.ts +30 -30
- package/src/fontbackgroundcolor.js +34 -34
- package/src/fontcolor/fontcolorcommand.d.ts +25 -25
- package/src/fontcolor/fontcolorcommand.js +24 -24
- package/src/fontcolor/fontcolorediting.d.ts +26 -26
- package/src/fontcolor/fontcolorediting.js +134 -134
- package/src/fontcolor/fontcolorui.d.ts +22 -22
- package/src/fontcolor/fontcolorui.js +33 -33
- package/src/fontcolor.d.ts +29 -29
- package/src/fontcolor.js +33 -33
- package/src/fontcommand.d.ts +48 -48
- package/src/fontcommand.js +79 -79
- package/src/fontconfig.d.ts +373 -373
- package/src/fontconfig.js +5 -5
- package/src/fontfamily/fontfamilycommand.d.ts +25 -25
- package/src/fontfamily/fontfamilycommand.js +24 -24
- package/src/fontfamily/fontfamilyediting.d.ts +39 -39
- package/src/fontfamily/fontfamilyediting.js +115 -115
- package/src/fontfamily/fontfamilyui.d.ts +30 -30
- package/src/fontfamily/fontfamilyui.js +114 -114
- package/src/fontfamily/utils.d.ts +15 -15
- package/src/fontfamily/utils.js +80 -80
- package/src/fontfamily.d.ts +29 -29
- package/src/fontfamily.js +33 -33
- package/src/fontsize/fontsizecommand.d.ts +25 -25
- package/src/fontsize/fontsizecommand.js +24 -24
- package/src/fontsize/fontsizeediting.d.ts +44 -44
- package/src/fontsize/fontsizeediting.js +165 -165
- package/src/fontsize/fontsizeui.d.ts +31 -31
- package/src/fontsize/fontsizeui.js +122 -122
- package/src/fontsize/utils.d.ts +12 -12
- package/src/fontsize/utils.js +166 -166
- package/src/fontsize.d.ts +37 -37
- package/src/fontsize.js +43 -43
- package/src/index.d.ts +27 -27
- package/src/index.js +21 -21
- package/src/ui/colorui.d.ts +68 -68
- package/src/ui/colorui.js +130 -130
- package/src/utils.d.ts +80 -80
- package/src/utils.js +97 -97
package/src/fontcolor.js
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
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/fontcolor
|
|
7
|
-
*/
|
|
8
|
-
import { Plugin } from 'ckeditor5/src/core';
|
|
9
|
-
import FontColorEditing from './fontcolor/fontcolorediting';
|
|
10
|
-
import FontColorUI from './fontcolor/fontcolorui';
|
|
11
|
-
/**
|
|
12
|
-
* The font color plugin.
|
|
13
|
-
*
|
|
14
|
-
* For a detailed overview, check the {@glink features/font font feature} documentation
|
|
15
|
-
* and the {@glink api/font package page}.
|
|
16
|
-
*
|
|
17
|
-
* This is a "glue" plugin which loads the {@link module:font/fontcolor/fontcolorediting~FontColorEditing} and
|
|
18
|
-
* {@link module:font/fontcolor/fontcolorui~FontColorUI} features in the editor.
|
|
19
|
-
*/
|
|
20
|
-
export default class FontColor extends Plugin {
|
|
21
|
-
/**
|
|
22
|
-
* @inheritDoc
|
|
23
|
-
*/
|
|
24
|
-
static get requires() {
|
|
25
|
-
return [FontColorEditing, FontColorUI];
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* @inheritDoc
|
|
29
|
-
*/
|
|
30
|
-
static get pluginName() {
|
|
31
|
-
return 'FontColor';
|
|
32
|
-
}
|
|
33
|
-
}
|
|
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/fontcolor
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core';
|
|
9
|
+
import FontColorEditing from './fontcolor/fontcolorediting';
|
|
10
|
+
import FontColorUI from './fontcolor/fontcolorui';
|
|
11
|
+
/**
|
|
12
|
+
* The font color plugin.
|
|
13
|
+
*
|
|
14
|
+
* For a detailed overview, check the {@glink features/font font feature} documentation
|
|
15
|
+
* and the {@glink api/font package page}.
|
|
16
|
+
*
|
|
17
|
+
* This is a "glue" plugin which loads the {@link module:font/fontcolor/fontcolorediting~FontColorEditing} and
|
|
18
|
+
* {@link module:font/fontcolor/fontcolorui~FontColorUI} features in the editor.
|
|
19
|
+
*/
|
|
20
|
+
export default class FontColor extends Plugin {
|
|
21
|
+
/**
|
|
22
|
+
* @inheritDoc
|
|
23
|
+
*/
|
|
24
|
+
static get requires() {
|
|
25
|
+
return [FontColorEditing, FontColorUI];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* @inheritDoc
|
|
29
|
+
*/
|
|
30
|
+
static get pluginName() {
|
|
31
|
+
return 'FontColor';
|
|
32
|
+
}
|
|
33
|
+
}
|
package/src/fontcommand.d.ts
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
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, type Editor } from 'ckeditor5/src/core';
|
|
9
|
-
import { type Batch } from 'ckeditor5/src/engine';
|
|
10
|
-
/**
|
|
11
|
-
* The base font command.
|
|
12
|
-
*/
|
|
13
|
-
export default abstract class FontCommand extends Command {
|
|
14
|
-
/**
|
|
15
|
-
* When set, it reflects the {@link #attributeKey} value of the selection.
|
|
16
|
-
*
|
|
17
|
-
* @observable
|
|
18
|
-
* @readonly
|
|
19
|
-
*/
|
|
20
|
-
value: string;
|
|
21
|
-
/**
|
|
22
|
-
* A model attribute on which this command operates.
|
|
23
|
-
*/
|
|
24
|
-
readonly attributeKey: string;
|
|
25
|
-
/**
|
|
26
|
-
* Creates an instance of the command.
|
|
27
|
-
*
|
|
28
|
-
* @param editor Editor instance.
|
|
29
|
-
* @param attributeKey The name of a model attribute on which this command operates.
|
|
30
|
-
*/
|
|
31
|
-
constructor(editor: Editor, attributeKey: string);
|
|
32
|
-
/**
|
|
33
|
-
* @inheritDoc
|
|
34
|
-
*/
|
|
35
|
-
refresh(): void;
|
|
36
|
-
/**
|
|
37
|
-
* Executes the command. Applies the `value` of the {@link #attributeKey} to the selection.
|
|
38
|
-
* If no `value` is passed, it removes the attribute from the selection.
|
|
39
|
-
*
|
|
40
|
-
* @param options Options for the executed command.
|
|
41
|
-
* @param options.value The value to apply.
|
|
42
|
-
* @fires execute
|
|
43
|
-
*/
|
|
44
|
-
execute(options?: {
|
|
45
|
-
value?: string;
|
|
46
|
-
batch?: Batch;
|
|
47
|
-
}): void;
|
|
48
|
-
}
|
|
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, type Editor } from 'ckeditor5/src/core';
|
|
9
|
+
import { type Batch } from 'ckeditor5/src/engine';
|
|
10
|
+
/**
|
|
11
|
+
* The base font command.
|
|
12
|
+
*/
|
|
13
|
+
export default abstract class FontCommand extends Command {
|
|
14
|
+
/**
|
|
15
|
+
* When set, it reflects the {@link #attributeKey} value of the selection.
|
|
16
|
+
*
|
|
17
|
+
* @observable
|
|
18
|
+
* @readonly
|
|
19
|
+
*/
|
|
20
|
+
value: string;
|
|
21
|
+
/**
|
|
22
|
+
* A model attribute on which this command operates.
|
|
23
|
+
*/
|
|
24
|
+
readonly attributeKey: string;
|
|
25
|
+
/**
|
|
26
|
+
* Creates an instance of the command.
|
|
27
|
+
*
|
|
28
|
+
* @param editor Editor instance.
|
|
29
|
+
* @param attributeKey The name of a model attribute on which this command operates.
|
|
30
|
+
*/
|
|
31
|
+
constructor(editor: Editor, attributeKey: string);
|
|
32
|
+
/**
|
|
33
|
+
* @inheritDoc
|
|
34
|
+
*/
|
|
35
|
+
refresh(): void;
|
|
36
|
+
/**
|
|
37
|
+
* Executes the command. Applies the `value` of the {@link #attributeKey} to the selection.
|
|
38
|
+
* If no `value` is passed, it removes the attribute from the selection.
|
|
39
|
+
*
|
|
40
|
+
* @param options Options for the executed command.
|
|
41
|
+
* @param options.value The value to apply.
|
|
42
|
+
* @fires execute
|
|
43
|
+
*/
|
|
44
|
+
execute(options?: {
|
|
45
|
+
value?: string;
|
|
46
|
+
batch?: Batch;
|
|
47
|
+
}): void;
|
|
48
|
+
}
|
package/src/fontcommand.js
CHANGED
|
@@ -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
|
+
}
|