@ckeditor/ckeditor5-font 38.1.1 → 38.2.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/build/font.js +2 -2
- package/build/translations/ar.js +1 -1
- package/build/translations/az.js +1 -1
- package/build/translations/bg.js +1 -1
- package/build/translations/bn.js +1 -1
- package/build/translations/bs.js +1 -1
- package/build/translations/ca.js +1 -1
- package/build/translations/cs.js +1 -1
- package/build/translations/da.js +1 -1
- package/build/translations/de-ch.js +1 -1
- package/build/translations/de.js +1 -1
- package/build/translations/el.js +1 -1
- package/build/translations/en-au.js +1 -1
- package/build/translations/en-gb.js +1 -1
- package/build/translations/es.js +1 -1
- package/build/translations/et.js +1 -1
- package/build/translations/fa.js +1 -1
- package/build/translations/fi.js +1 -1
- package/build/translations/fr.js +1 -1
- package/build/translations/gl.js +1 -1
- package/build/translations/he.js +1 -1
- package/build/translations/hi.js +1 -1
- package/build/translations/hr.js +1 -1
- package/build/translations/hu.js +1 -1
- package/build/translations/id.js +1 -1
- package/build/translations/it.js +1 -1
- package/build/translations/ja.js +1 -1
- package/build/translations/jv.js +1 -1
- package/build/translations/ko.js +1 -1
- package/build/translations/ku.js +1 -1
- package/build/translations/lt.js +1 -1
- package/build/translations/lv.js +1 -1
- package/build/translations/ms.js +1 -1
- package/build/translations/nb.js +1 -1
- package/build/translations/ne.js +1 -1
- package/build/translations/nl.js +1 -1
- package/build/translations/no.js +1 -1
- package/build/translations/pl.js +1 -1
- package/build/translations/pt-br.js +1 -1
- package/build/translations/pt.js +1 -1
- package/build/translations/ro.js +1 -1
- package/build/translations/ru.js +1 -1
- package/build/translations/sk.js +1 -1
- package/build/translations/sl.js +1 -1
- package/build/translations/sq.js +1 -1
- package/build/translations/sr-latn.js +1 -1
- package/build/translations/sr.js +1 -1
- package/build/translations/sv.js +1 -1
- package/build/translations/th.js +1 -1
- package/build/translations/tk.js +1 -1
- package/build/translations/tr.js +1 -1
- package/build/translations/ug.js +1 -1
- package/build/translations/uk.js +1 -1
- package/build/translations/ur.js +1 -1
- package/build/translations/uz.js +1 -1
- package/build/translations/vi.js +1 -1
- package/build/translations/zh-cn.js +1 -1
- package/build/translations/zh.js +1 -1
- package/lang/contexts.json +1 -2
- package/package.json +3 -3
- 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 -67
- package/src/ui/colorui.js +130 -128
- package/src/utils.d.ts +80 -79
- package/src/utils.js +97 -98
- package/build/font.js.map +0 -1
- package/src/documentcolorcollection.d.ts +0 -70
- package/src/documentcolorcollection.js +0 -42
- package/src/ui/colortableview.d.ts +0 -459
- package/src/ui/colortableview.js +0 -645
- package/theme/fontcolor.css +0 -75
package/src/fontconfig.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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
|
-
export {};
|
|
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
|
+
export {};
|
|
@@ -1,25 +1,25 @@
|
|
|
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/fontfamily/fontfamilycommand
|
|
7
|
-
*/
|
|
8
|
-
import type { Editor } from 'ckeditor5/src/core';
|
|
9
|
-
import FontCommand from '../fontcommand';
|
|
10
|
-
/**
|
|
11
|
-
* The font family command. It is used by {@link module:font/fontfamily/fontfamilyediting~FontFamilyEditing}
|
|
12
|
-
* to apply the font family.
|
|
13
|
-
*
|
|
14
|
-
* ```ts
|
|
15
|
-
* editor.execute( 'fontFamily', { value: 'Arial' } );
|
|
16
|
-
* ```
|
|
17
|
-
*
|
|
18
|
-
* **Note**: Executing the command without the value removes the attribute from the model.
|
|
19
|
-
*/
|
|
20
|
-
export default class FontFamilyCommand extends FontCommand {
|
|
21
|
-
/**
|
|
22
|
-
* @inheritDoc
|
|
23
|
-
*/
|
|
24
|
-
constructor(editor: Editor);
|
|
25
|
-
}
|
|
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/fontfamily/fontfamilycommand
|
|
7
|
+
*/
|
|
8
|
+
import type { Editor } from 'ckeditor5/src/core.js';
|
|
9
|
+
import FontCommand from '../fontcommand.js';
|
|
10
|
+
/**
|
|
11
|
+
* The font family command. It is used by {@link module:font/fontfamily/fontfamilyediting~FontFamilyEditing}
|
|
12
|
+
* to apply the font family.
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* editor.execute( 'fontFamily', { value: 'Arial' } );
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* **Note**: Executing the command without the value removes the attribute from the model.
|
|
19
|
+
*/
|
|
20
|
+
export default class FontFamilyCommand extends FontCommand {
|
|
21
|
+
/**
|
|
22
|
+
* @inheritDoc
|
|
23
|
+
*/
|
|
24
|
+
constructor(editor: Editor);
|
|
25
|
+
}
|
|
@@ -1,24 +1,24 @@
|
|
|
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
|
-
import FontCommand from '../fontcommand';
|
|
6
|
-
import { FONT_FAMILY } from '../utils';
|
|
7
|
-
/**
|
|
8
|
-
* The font family command. It is used by {@link module:font/fontfamily/fontfamilyediting~FontFamilyEditing}
|
|
9
|
-
* to apply the font family.
|
|
10
|
-
*
|
|
11
|
-
* ```ts
|
|
12
|
-
* editor.execute( 'fontFamily', { value: 'Arial' } );
|
|
13
|
-
* ```
|
|
14
|
-
*
|
|
15
|
-
* **Note**: Executing the command without the value removes the attribute from the model.
|
|
16
|
-
*/
|
|
17
|
-
export default class FontFamilyCommand extends FontCommand {
|
|
18
|
-
/**
|
|
19
|
-
* @inheritDoc
|
|
20
|
-
*/
|
|
21
|
-
constructor(editor) {
|
|
22
|
-
super(editor, FONT_FAMILY);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
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
|
+
import FontCommand from '../fontcommand.js';
|
|
6
|
+
import { FONT_FAMILY } from '../utils.js';
|
|
7
|
+
/**
|
|
8
|
+
* The font family command. It is used by {@link module:font/fontfamily/fontfamilyediting~FontFamilyEditing}
|
|
9
|
+
* to apply the font family.
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* editor.execute( 'fontFamily', { value: 'Arial' } );
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* **Note**: Executing the command without the value removes the attribute from the model.
|
|
16
|
+
*/
|
|
17
|
+
export default class FontFamilyCommand extends FontCommand {
|
|
18
|
+
/**
|
|
19
|
+
* @inheritDoc
|
|
20
|
+
*/
|
|
21
|
+
constructor(editor) {
|
|
22
|
+
super(editor, FONT_FAMILY);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -1,39 +1,39 @@
|
|
|
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/fontfamily/fontfamilyediting
|
|
7
|
-
*/
|
|
8
|
-
import { type Editor, Plugin } from 'ckeditor5/src/core';
|
|
9
|
-
/**
|
|
10
|
-
* The font family editing feature.
|
|
11
|
-
*
|
|
12
|
-
* It introduces the {@link module:font/fontfamily/fontfamilycommand~FontFamilyCommand command} and
|
|
13
|
-
* the `fontFamily` attribute in the {@link module:engine/model/model~Model model} which renders
|
|
14
|
-
* in the {@link module:engine/view/view view} as an inline `<span>` element (`<span style="font-family: Arial">`),
|
|
15
|
-
* depending on the {@link module:font/fontconfig~FontFamilyConfig configuration}.
|
|
16
|
-
*/
|
|
17
|
-
export default class FontFamilyEditing extends Plugin {
|
|
18
|
-
/**
|
|
19
|
-
* @inheritDoc
|
|
20
|
-
*/
|
|
21
|
-
static get pluginName(): "FontFamilyEditing";
|
|
22
|
-
/**
|
|
23
|
-
* @inheritDoc
|
|
24
|
-
*/
|
|
25
|
-
constructor(editor: Editor);
|
|
26
|
-
/**
|
|
27
|
-
* @inheritDoc
|
|
28
|
-
*/
|
|
29
|
-
init(): void;
|
|
30
|
-
/**
|
|
31
|
-
* These converters enable keeping any value found as `style="font-family: *"` as a value of an attribute on a text even
|
|
32
|
-
* if it is not defined in the plugin configuration.
|
|
33
|
-
*/
|
|
34
|
-
private _prepareAnyValueConverters;
|
|
35
|
-
/**
|
|
36
|
-
* Adds support for legacy `<font face="..">` formatting.
|
|
37
|
-
*/
|
|
38
|
-
private _prepareCompatibilityConverter;
|
|
39
|
-
}
|
|
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/fontfamily/fontfamilyediting
|
|
7
|
+
*/
|
|
8
|
+
import { type Editor, Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
+
/**
|
|
10
|
+
* The font family editing feature.
|
|
11
|
+
*
|
|
12
|
+
* It introduces the {@link module:font/fontfamily/fontfamilycommand~FontFamilyCommand command} and
|
|
13
|
+
* the `fontFamily` attribute in the {@link module:engine/model/model~Model model} which renders
|
|
14
|
+
* in the {@link module:engine/view/view view} as an inline `<span>` element (`<span style="font-family: Arial">`),
|
|
15
|
+
* depending on the {@link module:font/fontconfig~FontFamilyConfig configuration}.
|
|
16
|
+
*/
|
|
17
|
+
export default class FontFamilyEditing extends Plugin {
|
|
18
|
+
/**
|
|
19
|
+
* @inheritDoc
|
|
20
|
+
*/
|
|
21
|
+
static get pluginName(): "FontFamilyEditing";
|
|
22
|
+
/**
|
|
23
|
+
* @inheritDoc
|
|
24
|
+
*/
|
|
25
|
+
constructor(editor: Editor);
|
|
26
|
+
/**
|
|
27
|
+
* @inheritDoc
|
|
28
|
+
*/
|
|
29
|
+
init(): void;
|
|
30
|
+
/**
|
|
31
|
+
* These converters enable keeping any value found as `style="font-family: *"` as a value of an attribute on a text even
|
|
32
|
+
* if it is not defined in the plugin configuration.
|
|
33
|
+
*/
|
|
34
|
+
private _prepareAnyValueConverters;
|
|
35
|
+
/**
|
|
36
|
+
* Adds support for legacy `<font face="..">` formatting.
|
|
37
|
+
*/
|
|
38
|
+
private _prepareCompatibilityConverter;
|
|
39
|
+
}
|
|
@@ -1,115 +1,115 @@
|
|
|
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/fontfamily/fontfamilyediting
|
|
7
|
-
*/
|
|
8
|
-
import { Plugin } from 'ckeditor5/src/core';
|
|
9
|
-
import FontFamilyCommand from './fontfamilycommand';
|
|
10
|
-
import { normalizeOptions } from './utils';
|
|
11
|
-
import { buildDefinition, FONT_FAMILY } from '../utils';
|
|
12
|
-
/**
|
|
13
|
-
* The font family editing feature.
|
|
14
|
-
*
|
|
15
|
-
* It introduces the {@link module:font/fontfamily/fontfamilycommand~FontFamilyCommand command} and
|
|
16
|
-
* the `fontFamily` attribute in the {@link module:engine/model/model~Model model} which renders
|
|
17
|
-
* in the {@link module:engine/view/view view} as an inline `<span>` element (`<span style="font-family: Arial">`),
|
|
18
|
-
* depending on the {@link module:font/fontconfig~FontFamilyConfig configuration}.
|
|
19
|
-
*/
|
|
20
|
-
export default class FontFamilyEditing extends Plugin {
|
|
21
|
-
/**
|
|
22
|
-
* @inheritDoc
|
|
23
|
-
*/
|
|
24
|
-
static get pluginName() {
|
|
25
|
-
return 'FontFamilyEditing';
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* @inheritDoc
|
|
29
|
-
*/
|
|
30
|
-
constructor(editor) {
|
|
31
|
-
super(editor);
|
|
32
|
-
// Define default configuration using font families shortcuts.
|
|
33
|
-
editor.config.define(FONT_FAMILY, {
|
|
34
|
-
options: [
|
|
35
|
-
'default',
|
|
36
|
-
'Arial, Helvetica, sans-serif',
|
|
37
|
-
'Courier New, Courier, monospace',
|
|
38
|
-
'Georgia, serif',
|
|
39
|
-
'Lucida Sans Unicode, Lucida Grande, sans-serif',
|
|
40
|
-
'Tahoma, Geneva, sans-serif',
|
|
41
|
-
'Times New Roman, Times, serif',
|
|
42
|
-
'Trebuchet MS, Helvetica, sans-serif',
|
|
43
|
-
'Verdana, Geneva, sans-serif'
|
|
44
|
-
],
|
|
45
|
-
supportAllValues: false
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* @inheritDoc
|
|
50
|
-
*/
|
|
51
|
-
init() {
|
|
52
|
-
const editor = this.editor;
|
|
53
|
-
// Allow fontFamily attribute on text nodes.
|
|
54
|
-
editor.model.schema.extend('$text', { allowAttributes: FONT_FAMILY });
|
|
55
|
-
editor.model.schema.setAttributeProperties(FONT_FAMILY, {
|
|
56
|
-
isFormatting: true,
|
|
57
|
-
copyOnEnter: true
|
|
58
|
-
});
|
|
59
|
-
// Get configured font family options without "default" option.
|
|
60
|
-
const options = normalizeOptions(editor.config.get('fontFamily.options')).filter(item => item.model);
|
|
61
|
-
const definition = buildDefinition(FONT_FAMILY, options);
|
|
62
|
-
// Set-up the two-way conversion.
|
|
63
|
-
if (editor.config.get('fontFamily.supportAllValues')) {
|
|
64
|
-
this._prepareAnyValueConverters();
|
|
65
|
-
this._prepareCompatibilityConverter();
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
editor.conversion.attributeToElement(definition);
|
|
69
|
-
}
|
|
70
|
-
editor.commands.add(FONT_FAMILY, new FontFamilyCommand(editor));
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* These converters enable keeping any value found as `style="font-family: *"` as a value of an attribute on a text even
|
|
74
|
-
* if it is not defined in the plugin configuration.
|
|
75
|
-
*/
|
|
76
|
-
_prepareAnyValueConverters() {
|
|
77
|
-
const editor = this.editor;
|
|
78
|
-
editor.conversion.for('downcast').attributeToElement({
|
|
79
|
-
model: FONT_FAMILY,
|
|
80
|
-
view: (attributeValue, { writer }) => {
|
|
81
|
-
return writer.createAttributeElement('span', { style: 'font-family:' + attributeValue }, { priority: 7 });
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
editor.conversion.for('upcast').elementToAttribute({
|
|
85
|
-
model: {
|
|
86
|
-
key: FONT_FAMILY,
|
|
87
|
-
value: (viewElement) => viewElement.getStyle('font-family')
|
|
88
|
-
},
|
|
89
|
-
view: {
|
|
90
|
-
name: 'span',
|
|
91
|
-
styles: {
|
|
92
|
-
'font-family': /.*/
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Adds support for legacy `<font face="..">` formatting.
|
|
99
|
-
*/
|
|
100
|
-
_prepareCompatibilityConverter() {
|
|
101
|
-
const editor = this.editor;
|
|
102
|
-
editor.conversion.for('upcast').elementToAttribute({
|
|
103
|
-
view: {
|
|
104
|
-
name: 'font',
|
|
105
|
-
attributes: {
|
|
106
|
-
'face': /.*/
|
|
107
|
-
}
|
|
108
|
-
},
|
|
109
|
-
model: {
|
|
110
|
-
key: FONT_FAMILY,
|
|
111
|
-
value: (viewElement) => viewElement.getAttribute('face')
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
}
|
|
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/fontfamily/fontfamilyediting
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
+
import FontFamilyCommand from './fontfamilycommand.js';
|
|
10
|
+
import { normalizeOptions } from './utils.js';
|
|
11
|
+
import { buildDefinition, FONT_FAMILY } from '../utils.js';
|
|
12
|
+
/**
|
|
13
|
+
* The font family editing feature.
|
|
14
|
+
*
|
|
15
|
+
* It introduces the {@link module:font/fontfamily/fontfamilycommand~FontFamilyCommand command} and
|
|
16
|
+
* the `fontFamily` attribute in the {@link module:engine/model/model~Model model} which renders
|
|
17
|
+
* in the {@link module:engine/view/view view} as an inline `<span>` element (`<span style="font-family: Arial">`),
|
|
18
|
+
* depending on the {@link module:font/fontconfig~FontFamilyConfig configuration}.
|
|
19
|
+
*/
|
|
20
|
+
export default class FontFamilyEditing extends Plugin {
|
|
21
|
+
/**
|
|
22
|
+
* @inheritDoc
|
|
23
|
+
*/
|
|
24
|
+
static get pluginName() {
|
|
25
|
+
return 'FontFamilyEditing';
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* @inheritDoc
|
|
29
|
+
*/
|
|
30
|
+
constructor(editor) {
|
|
31
|
+
super(editor);
|
|
32
|
+
// Define default configuration using font families shortcuts.
|
|
33
|
+
editor.config.define(FONT_FAMILY, {
|
|
34
|
+
options: [
|
|
35
|
+
'default',
|
|
36
|
+
'Arial, Helvetica, sans-serif',
|
|
37
|
+
'Courier New, Courier, monospace',
|
|
38
|
+
'Georgia, serif',
|
|
39
|
+
'Lucida Sans Unicode, Lucida Grande, sans-serif',
|
|
40
|
+
'Tahoma, Geneva, sans-serif',
|
|
41
|
+
'Times New Roman, Times, serif',
|
|
42
|
+
'Trebuchet MS, Helvetica, sans-serif',
|
|
43
|
+
'Verdana, Geneva, sans-serif'
|
|
44
|
+
],
|
|
45
|
+
supportAllValues: false
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* @inheritDoc
|
|
50
|
+
*/
|
|
51
|
+
init() {
|
|
52
|
+
const editor = this.editor;
|
|
53
|
+
// Allow fontFamily attribute on text nodes.
|
|
54
|
+
editor.model.schema.extend('$text', { allowAttributes: FONT_FAMILY });
|
|
55
|
+
editor.model.schema.setAttributeProperties(FONT_FAMILY, {
|
|
56
|
+
isFormatting: true,
|
|
57
|
+
copyOnEnter: true
|
|
58
|
+
});
|
|
59
|
+
// Get configured font family options without "default" option.
|
|
60
|
+
const options = normalizeOptions(editor.config.get('fontFamily.options')).filter(item => item.model);
|
|
61
|
+
const definition = buildDefinition(FONT_FAMILY, options);
|
|
62
|
+
// Set-up the two-way conversion.
|
|
63
|
+
if (editor.config.get('fontFamily.supportAllValues')) {
|
|
64
|
+
this._prepareAnyValueConverters();
|
|
65
|
+
this._prepareCompatibilityConverter();
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
editor.conversion.attributeToElement(definition);
|
|
69
|
+
}
|
|
70
|
+
editor.commands.add(FONT_FAMILY, new FontFamilyCommand(editor));
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* These converters enable keeping any value found as `style="font-family: *"` as a value of an attribute on a text even
|
|
74
|
+
* if it is not defined in the plugin configuration.
|
|
75
|
+
*/
|
|
76
|
+
_prepareAnyValueConverters() {
|
|
77
|
+
const editor = this.editor;
|
|
78
|
+
editor.conversion.for('downcast').attributeToElement({
|
|
79
|
+
model: FONT_FAMILY,
|
|
80
|
+
view: (attributeValue, { writer }) => {
|
|
81
|
+
return writer.createAttributeElement('span', { style: 'font-family:' + attributeValue }, { priority: 7 });
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
editor.conversion.for('upcast').elementToAttribute({
|
|
85
|
+
model: {
|
|
86
|
+
key: FONT_FAMILY,
|
|
87
|
+
value: (viewElement) => viewElement.getStyle('font-family')
|
|
88
|
+
},
|
|
89
|
+
view: {
|
|
90
|
+
name: 'span',
|
|
91
|
+
styles: {
|
|
92
|
+
'font-family': /.*/
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Adds support for legacy `<font face="..">` formatting.
|
|
99
|
+
*/
|
|
100
|
+
_prepareCompatibilityConverter() {
|
|
101
|
+
const editor = this.editor;
|
|
102
|
+
editor.conversion.for('upcast').elementToAttribute({
|
|
103
|
+
view: {
|
|
104
|
+
name: 'font',
|
|
105
|
+
attributes: {
|
|
106
|
+
'face': /.*/
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
model: {
|
|
110
|
+
key: FONT_FAMILY,
|
|
111
|
+
value: (viewElement) => viewElement.getAttribute('face')
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -1,30 +1,30 @@
|
|
|
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/fontfamily/fontfamilyui
|
|
7
|
-
*/
|
|
8
|
-
import { Plugin } from 'ckeditor5/src/core';
|
|
9
|
-
/**
|
|
10
|
-
* The font family UI plugin. It introduces the `'fontFamily'` dropdown.
|
|
11
|
-
*/
|
|
12
|
-
export default class FontFamilyUI extends Plugin {
|
|
13
|
-
/**
|
|
14
|
-
* @inheritDoc
|
|
15
|
-
*/
|
|
16
|
-
static get pluginName(): "FontFamilyUI";
|
|
17
|
-
/**
|
|
18
|
-
* @inheritDoc
|
|
19
|
-
*/
|
|
20
|
-
init(): void;
|
|
21
|
-
/**
|
|
22
|
-
* Returns options as defined in `config.fontFamily.options` but processed to account for
|
|
23
|
-
* editor localization, i.e. to display {@link module:font/fontconfig~FontFamilyOption}
|
|
24
|
-
* in the correct language.
|
|
25
|
-
*
|
|
26
|
-
* Note: The reason behind this method is that there is no way to use {@link module:utils/locale~Locale#t}
|
|
27
|
-
* when the user configuration is defined because the editor does not exist yet.
|
|
28
|
-
*/
|
|
29
|
-
private _getLocalizedOptions;
|
|
30
|
-
}
|
|
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/fontfamily/fontfamilyui
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
+
/**
|
|
10
|
+
* The font family UI plugin. It introduces the `'fontFamily'` dropdown.
|
|
11
|
+
*/
|
|
12
|
+
export default class FontFamilyUI extends Plugin {
|
|
13
|
+
/**
|
|
14
|
+
* @inheritDoc
|
|
15
|
+
*/
|
|
16
|
+
static get pluginName(): "FontFamilyUI";
|
|
17
|
+
/**
|
|
18
|
+
* @inheritDoc
|
|
19
|
+
*/
|
|
20
|
+
init(): void;
|
|
21
|
+
/**
|
|
22
|
+
* Returns options as defined in `config.fontFamily.options` but processed to account for
|
|
23
|
+
* editor localization, i.e. to display {@link module:font/fontconfig~FontFamilyOption}
|
|
24
|
+
* in the correct language.
|
|
25
|
+
*
|
|
26
|
+
* Note: The reason behind this method is that there is no way to use {@link module:utils/locale~Locale#t}
|
|
27
|
+
* when the user configuration is defined because the editor does not exist yet.
|
|
28
|
+
*/
|
|
29
|
+
private _getLocalizedOptions;
|
|
30
|
+
}
|