@ckeditor/ckeditor5-font 0.0.0-internal-20241017.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/CHANGELOG.md +4 -0
- package/LICENSE.md +23 -0
- package/README.md +31 -0
- package/build/font.js +5 -0
- package/build/translations/ar.js +1 -0
- package/build/translations/az.js +1 -0
- package/build/translations/bg.js +1 -0
- package/build/translations/bn.js +1 -0
- package/build/translations/bs.js +1 -0
- package/build/translations/ca.js +1 -0
- package/build/translations/cs.js +1 -0
- package/build/translations/da.js +1 -0
- package/build/translations/de-ch.js +1 -0
- package/build/translations/de.js +1 -0
- package/build/translations/el.js +1 -0
- package/build/translations/en-au.js +1 -0
- package/build/translations/en-gb.js +1 -0
- package/build/translations/es-co.js +1 -0
- package/build/translations/es.js +1 -0
- package/build/translations/et.js +1 -0
- package/build/translations/fa.js +1 -0
- package/build/translations/fi.js +1 -0
- package/build/translations/fr.js +1 -0
- package/build/translations/gl.js +1 -0
- package/build/translations/he.js +1 -0
- package/build/translations/hi.js +1 -0
- package/build/translations/hr.js +1 -0
- package/build/translations/hu.js +1 -0
- package/build/translations/id.js +1 -0
- package/build/translations/it.js +1 -0
- package/build/translations/ja.js +1 -0
- package/build/translations/jv.js +1 -0
- package/build/translations/ko.js +1 -0
- package/build/translations/ku.js +1 -0
- package/build/translations/lt.js +1 -0
- package/build/translations/lv.js +1 -0
- package/build/translations/ms.js +1 -0
- package/build/translations/nb.js +1 -0
- package/build/translations/ne.js +1 -0
- package/build/translations/nl.js +1 -0
- package/build/translations/no.js +1 -0
- package/build/translations/pl.js +1 -0
- package/build/translations/pt-br.js +1 -0
- package/build/translations/pt.js +1 -0
- package/build/translations/ro.js +1 -0
- package/build/translations/ru.js +1 -0
- package/build/translations/sk.js +1 -0
- package/build/translations/sl.js +1 -0
- package/build/translations/sq.js +1 -0
- package/build/translations/sr-latn.js +1 -0
- package/build/translations/sr.js +1 -0
- package/build/translations/sv.js +1 -0
- package/build/translations/th.js +1 -0
- package/build/translations/tk.js +1 -0
- package/build/translations/tr.js +1 -0
- package/build/translations/ug.js +1 -0
- package/build/translations/uk.js +1 -0
- package/build/translations/ur.js +1 -0
- package/build/translations/uz.js +1 -0
- package/build/translations/vi.js +1 -0
- package/build/translations/zh-cn.js +1 -0
- package/build/translations/zh.js +1 -0
- package/ckeditor5-metadata.json +111 -0
- package/dist/augmentation.d.ts +62 -0
- package/dist/font.d.ts +41 -0
- package/dist/fontbackgroundcolor/fontbackgroundcolorcommand.d.ts +30 -0
- package/dist/fontbackgroundcolor/fontbackgroundcolorediting.d.ts +34 -0
- package/dist/fontbackgroundcolor/fontbackgroundcolorui.d.ts +26 -0
- package/dist/fontbackgroundcolor.d.ts +38 -0
- package/dist/fontcolor/fontcolorcommand.d.ts +29 -0
- package/dist/fontcolor/fontcolorediting.d.ts +34 -0
- package/dist/fontcolor/fontcolorui.d.ts +26 -0
- package/dist/fontcolor.d.ts +37 -0
- package/dist/fontcommand.d.ts +52 -0
- package/dist/fontconfig.d.ts +377 -0
- package/dist/fontfamily/fontfamilycommand.d.ts +29 -0
- package/dist/fontfamily/fontfamilyediting.d.ts +47 -0
- package/dist/fontfamily/fontfamilyui.d.ts +38 -0
- package/dist/fontfamily/utils.d.ts +19 -0
- package/dist/fontfamily.d.ts +37 -0
- package/dist/fontsize/fontsizecommand.d.ts +29 -0
- package/dist/fontsize/fontsizeediting.d.ts +52 -0
- package/dist/fontsize/fontsizeui.d.ts +39 -0
- package/dist/fontsize/utils.d.ts +16 -0
- package/dist/fontsize.d.ts +45 -0
- package/dist/index-content.css +16 -0
- package/dist/index-editor.css +4 -0
- package/dist/index.css +27 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +1634 -0
- package/dist/index.js.map +1 -0
- package/dist/translations/ar.d.ts +8 -0
- package/dist/translations/ar.js +5 -0
- package/dist/translations/ar.umd.js +11 -0
- package/dist/translations/az.d.ts +8 -0
- package/dist/translations/az.js +5 -0
- package/dist/translations/az.umd.js +11 -0
- package/dist/translations/bg.d.ts +8 -0
- package/dist/translations/bg.js +5 -0
- package/dist/translations/bg.umd.js +11 -0
- package/dist/translations/bn.d.ts +8 -0
- package/dist/translations/bn.js +5 -0
- package/dist/translations/bn.umd.js +11 -0
- package/dist/translations/bs.d.ts +8 -0
- package/dist/translations/bs.js +5 -0
- package/dist/translations/bs.umd.js +11 -0
- package/dist/translations/ca.d.ts +8 -0
- package/dist/translations/ca.js +5 -0
- package/dist/translations/ca.umd.js +11 -0
- package/dist/translations/cs.d.ts +8 -0
- package/dist/translations/cs.js +5 -0
- package/dist/translations/cs.umd.js +11 -0
- package/dist/translations/da.d.ts +8 -0
- package/dist/translations/da.js +5 -0
- package/dist/translations/da.umd.js +11 -0
- package/dist/translations/de-ch.d.ts +8 -0
- package/dist/translations/de-ch.js +5 -0
- package/dist/translations/de-ch.umd.js +11 -0
- package/dist/translations/de.d.ts +8 -0
- package/dist/translations/de.js +5 -0
- package/dist/translations/de.umd.js +11 -0
- package/dist/translations/el.d.ts +8 -0
- package/dist/translations/el.js +5 -0
- package/dist/translations/el.umd.js +11 -0
- package/dist/translations/en-au.d.ts +8 -0
- package/dist/translations/en-au.js +5 -0
- package/dist/translations/en-au.umd.js +11 -0
- package/dist/translations/en-gb.d.ts +8 -0
- package/dist/translations/en-gb.js +5 -0
- package/dist/translations/en-gb.umd.js +11 -0
- package/dist/translations/en.d.ts +8 -0
- package/dist/translations/en.js +5 -0
- package/dist/translations/en.umd.js +11 -0
- package/dist/translations/es-co.d.ts +8 -0
- package/dist/translations/es-co.js +5 -0
- package/dist/translations/es-co.umd.js +11 -0
- package/dist/translations/es.d.ts +8 -0
- package/dist/translations/es.js +5 -0
- package/dist/translations/es.umd.js +11 -0
- package/dist/translations/et.d.ts +8 -0
- package/dist/translations/et.js +5 -0
- package/dist/translations/et.umd.js +11 -0
- package/dist/translations/fa.d.ts +8 -0
- package/dist/translations/fa.js +5 -0
- package/dist/translations/fa.umd.js +11 -0
- package/dist/translations/fi.d.ts +8 -0
- package/dist/translations/fi.js +5 -0
- package/dist/translations/fi.umd.js +11 -0
- package/dist/translations/fr.d.ts +8 -0
- package/dist/translations/fr.js +5 -0
- package/dist/translations/fr.umd.js +11 -0
- package/dist/translations/gl.d.ts +8 -0
- package/dist/translations/gl.js +5 -0
- package/dist/translations/gl.umd.js +11 -0
- package/dist/translations/he.d.ts +8 -0
- package/dist/translations/he.js +5 -0
- package/dist/translations/he.umd.js +11 -0
- package/dist/translations/hi.d.ts +8 -0
- package/dist/translations/hi.js +5 -0
- package/dist/translations/hi.umd.js +11 -0
- package/dist/translations/hr.d.ts +8 -0
- package/dist/translations/hr.js +5 -0
- package/dist/translations/hr.umd.js +11 -0
- package/dist/translations/hu.d.ts +8 -0
- package/dist/translations/hu.js +5 -0
- package/dist/translations/hu.umd.js +11 -0
- package/dist/translations/id.d.ts +8 -0
- package/dist/translations/id.js +5 -0
- package/dist/translations/id.umd.js +11 -0
- package/dist/translations/it.d.ts +8 -0
- package/dist/translations/it.js +5 -0
- package/dist/translations/it.umd.js +11 -0
- package/dist/translations/ja.d.ts +8 -0
- package/dist/translations/ja.js +5 -0
- package/dist/translations/ja.umd.js +11 -0
- package/dist/translations/jv.d.ts +8 -0
- package/dist/translations/jv.js +5 -0
- package/dist/translations/jv.umd.js +11 -0
- package/dist/translations/ko.d.ts +8 -0
- package/dist/translations/ko.js +5 -0
- package/dist/translations/ko.umd.js +11 -0
- package/dist/translations/ku.d.ts +8 -0
- package/dist/translations/ku.js +5 -0
- package/dist/translations/ku.umd.js +11 -0
- package/dist/translations/lt.d.ts +8 -0
- package/dist/translations/lt.js +5 -0
- package/dist/translations/lt.umd.js +11 -0
- package/dist/translations/lv.d.ts +8 -0
- package/dist/translations/lv.js +5 -0
- package/dist/translations/lv.umd.js +11 -0
- package/dist/translations/ms.d.ts +8 -0
- package/dist/translations/ms.js +5 -0
- package/dist/translations/ms.umd.js +11 -0
- package/dist/translations/nb.d.ts +8 -0
- package/dist/translations/nb.js +5 -0
- package/dist/translations/nb.umd.js +11 -0
- package/dist/translations/ne.d.ts +8 -0
- package/dist/translations/ne.js +5 -0
- package/dist/translations/ne.umd.js +11 -0
- package/dist/translations/nl.d.ts +8 -0
- package/dist/translations/nl.js +5 -0
- package/dist/translations/nl.umd.js +11 -0
- package/dist/translations/no.d.ts +8 -0
- package/dist/translations/no.js +5 -0
- package/dist/translations/no.umd.js +11 -0
- package/dist/translations/pl.d.ts +8 -0
- package/dist/translations/pl.js +5 -0
- package/dist/translations/pl.umd.js +11 -0
- package/dist/translations/pt-br.d.ts +8 -0
- package/dist/translations/pt-br.js +5 -0
- package/dist/translations/pt-br.umd.js +11 -0
- package/dist/translations/pt.d.ts +8 -0
- package/dist/translations/pt.js +5 -0
- package/dist/translations/pt.umd.js +11 -0
- package/dist/translations/ro.d.ts +8 -0
- package/dist/translations/ro.js +5 -0
- package/dist/translations/ro.umd.js +11 -0
- package/dist/translations/ru.d.ts +8 -0
- package/dist/translations/ru.js +5 -0
- package/dist/translations/ru.umd.js +11 -0
- package/dist/translations/sk.d.ts +8 -0
- package/dist/translations/sk.js +5 -0
- package/dist/translations/sk.umd.js +11 -0
- package/dist/translations/sl.d.ts +8 -0
- package/dist/translations/sl.js +5 -0
- package/dist/translations/sl.umd.js +11 -0
- package/dist/translations/sq.d.ts +8 -0
- package/dist/translations/sq.js +5 -0
- package/dist/translations/sq.umd.js +11 -0
- package/dist/translations/sr-latn.d.ts +8 -0
- package/dist/translations/sr-latn.js +5 -0
- package/dist/translations/sr-latn.umd.js +11 -0
- package/dist/translations/sr.d.ts +8 -0
- package/dist/translations/sr.js +5 -0
- package/dist/translations/sr.umd.js +11 -0
- package/dist/translations/sv.d.ts +8 -0
- package/dist/translations/sv.js +5 -0
- package/dist/translations/sv.umd.js +11 -0
- package/dist/translations/th.d.ts +8 -0
- package/dist/translations/th.js +5 -0
- package/dist/translations/th.umd.js +11 -0
- package/dist/translations/tk.d.ts +8 -0
- package/dist/translations/tk.js +5 -0
- package/dist/translations/tk.umd.js +11 -0
- package/dist/translations/tr.d.ts +8 -0
- package/dist/translations/tr.js +5 -0
- package/dist/translations/tr.umd.js +11 -0
- package/dist/translations/ug.d.ts +8 -0
- package/dist/translations/ug.js +5 -0
- package/dist/translations/ug.umd.js +11 -0
- package/dist/translations/uk.d.ts +8 -0
- package/dist/translations/uk.js +5 -0
- package/dist/translations/uk.umd.js +11 -0
- package/dist/translations/ur.d.ts +8 -0
- package/dist/translations/ur.js +5 -0
- package/dist/translations/ur.umd.js +11 -0
- package/dist/translations/uz.d.ts +8 -0
- package/dist/translations/uz.js +5 -0
- package/dist/translations/uz.umd.js +11 -0
- package/dist/translations/vi.d.ts +8 -0
- package/dist/translations/vi.js +5 -0
- package/dist/translations/vi.umd.js +11 -0
- package/dist/translations/zh-cn.d.ts +8 -0
- package/dist/translations/zh-cn.js +5 -0
- package/dist/translations/zh-cn.umd.js +11 -0
- package/dist/translations/zh.d.ts +8 -0
- package/dist/translations/zh.js +5 -0
- package/dist/translations/zh.umd.js +11 -0
- package/dist/ui/colorui.d.ts +67 -0
- package/dist/utils.d.ts +84 -0
- package/lang/contexts.json +12 -0
- package/lang/translations/ar.po +58 -0
- package/lang/translations/az.po +58 -0
- package/lang/translations/bg.po +58 -0
- package/lang/translations/bn.po +58 -0
- package/lang/translations/bs.po +58 -0
- package/lang/translations/ca.po +58 -0
- package/lang/translations/cs.po +58 -0
- package/lang/translations/da.po +58 -0
- package/lang/translations/de-ch.po +58 -0
- package/lang/translations/de.po +58 -0
- package/lang/translations/el.po +58 -0
- package/lang/translations/en-au.po +58 -0
- package/lang/translations/en-gb.po +58 -0
- package/lang/translations/en.po +58 -0
- package/lang/translations/es-co.po +58 -0
- package/lang/translations/es.po +58 -0
- package/lang/translations/et.po +58 -0
- package/lang/translations/fa.po +58 -0
- package/lang/translations/fi.po +58 -0
- package/lang/translations/fr.po +58 -0
- package/lang/translations/gl.po +58 -0
- package/lang/translations/he.po +58 -0
- package/lang/translations/hi.po +58 -0
- package/lang/translations/hr.po +58 -0
- package/lang/translations/hu.po +58 -0
- package/lang/translations/id.po +58 -0
- package/lang/translations/it.po +58 -0
- package/lang/translations/ja.po +58 -0
- package/lang/translations/jv.po +58 -0
- package/lang/translations/ko.po +58 -0
- package/lang/translations/ku.po +58 -0
- package/lang/translations/lt.po +58 -0
- package/lang/translations/lv.po +58 -0
- package/lang/translations/ms.po +58 -0
- package/lang/translations/nb.po +58 -0
- package/lang/translations/ne.po +58 -0
- package/lang/translations/nl.po +58 -0
- package/lang/translations/no.po +58 -0
- package/lang/translations/pl.po +58 -0
- package/lang/translations/pt-br.po +58 -0
- package/lang/translations/pt.po +58 -0
- package/lang/translations/ro.po +58 -0
- package/lang/translations/ru.po +58 -0
- package/lang/translations/sk.po +58 -0
- package/lang/translations/sl.po +58 -0
- package/lang/translations/sq.po +58 -0
- package/lang/translations/sr-latn.po +58 -0
- package/lang/translations/sr.po +58 -0
- package/lang/translations/sv.po +58 -0
- package/lang/translations/th.po +58 -0
- package/lang/translations/tk.po +58 -0
- package/lang/translations/tr.po +58 -0
- package/lang/translations/ug.po +58 -0
- package/lang/translations/uk.po +58 -0
- package/lang/translations/ur.po +58 -0
- package/lang/translations/uz.po +58 -0
- package/lang/translations/vi.po +58 -0
- package/lang/translations/zh-cn.po +58 -0
- package/lang/translations/zh.po +58 -0
- package/package.json +42 -0
- package/src/augmentation.d.ts +58 -0
- package/src/augmentation.js +5 -0
- package/src/font.d.ts +37 -0
- package/src/font.js +43 -0
- package/src/fontbackgroundcolor/fontbackgroundcolorcommand.d.ts +26 -0
- package/src/fontbackgroundcolor/fontbackgroundcolorcommand.js +25 -0
- package/src/fontbackgroundcolor/fontbackgroundcolorediting.d.ts +30 -0
- package/src/fontbackgroundcolor/fontbackgroundcolorediting.js +129 -0
- package/src/fontbackgroundcolor/fontbackgroundcolorui.d.ts +22 -0
- package/src/fontbackgroundcolor/fontbackgroundcolorui.js +33 -0
- package/src/fontbackgroundcolor.d.ts +34 -0
- package/src/fontbackgroundcolor.js +40 -0
- package/src/fontcolor/fontcolorcommand.d.ts +25 -0
- package/src/fontcolor/fontcolorcommand.js +24 -0
- package/src/fontcolor/fontcolorediting.d.ts +30 -0
- package/src/fontcolor/fontcolorediting.js +140 -0
- package/src/fontcolor/fontcolorui.d.ts +22 -0
- package/src/fontcolor/fontcolorui.js +33 -0
- package/src/fontcolor.d.ts +33 -0
- package/src/fontcolor.js +39 -0
- package/src/fontcommand.d.ts +48 -0
- package/src/fontcommand.js +79 -0
- package/src/fontconfig.d.ts +373 -0
- package/src/fontconfig.js +5 -0
- package/src/fontfamily/fontfamilycommand.d.ts +25 -0
- package/src/fontfamily/fontfamilycommand.js +24 -0
- package/src/fontfamily/fontfamilyediting.d.ts +43 -0
- package/src/fontfamily/fontfamilyediting.js +121 -0
- package/src/fontfamily/fontfamilyui.d.ts +34 -0
- package/src/fontfamily/fontfamilyui.js +150 -0
- package/src/fontfamily/utils.d.ts +15 -0
- package/src/fontfamily/utils.js +80 -0
- package/src/fontfamily.d.ts +33 -0
- package/src/fontfamily.js +39 -0
- package/src/fontsize/fontsizecommand.d.ts +25 -0
- package/src/fontsize/fontsizecommand.js +24 -0
- package/src/fontsize/fontsizeediting.d.ts +48 -0
- package/src/fontsize/fontsizeediting.js +171 -0
- package/src/fontsize/fontsizeui.d.ts +35 -0
- package/src/fontsize/fontsizeui.js +158 -0
- package/src/fontsize/utils.d.ts +12 -0
- package/src/fontsize/utils.js +166 -0
- package/src/fontsize.d.ts +41 -0
- package/src/fontsize.js +49 -0
- package/src/index.d.ts +27 -0
- package/src/index.js +21 -0
- package/src/ui/colorui.d.ts +63 -0
- package/src/ui/colorui.js +179 -0
- package/src/utils.d.ts +80 -0
- package/src/utils.js +97 -0
- package/theme/fontsize.css +26 -0
- package/theme/icons/font-background.svg +1 -0
- package/theme/icons/font-color.svg +1 -0
- package/theme/icons/font-family.svg +1 -0
- package/theme/icons/font-size.svg +1 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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/fontsize/fontsizeediting
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
+
import { CKEditorError } from 'ckeditor5/src/utils.js';
|
|
10
|
+
import { isLength, isPercentage } from 'ckeditor5/src/engine.js';
|
|
11
|
+
import FontSizeCommand from './fontsizecommand.js';
|
|
12
|
+
import { normalizeOptions } from './utils.js';
|
|
13
|
+
import { buildDefinition, FONT_SIZE } from '../utils.js';
|
|
14
|
+
// Mapping of `<font size="..">` styling to CSS's `font-size` values.
|
|
15
|
+
const styleFontSize = [
|
|
16
|
+
'x-small',
|
|
17
|
+
'x-small',
|
|
18
|
+
'small',
|
|
19
|
+
'medium',
|
|
20
|
+
'large',
|
|
21
|
+
'x-large',
|
|
22
|
+
'xx-large',
|
|
23
|
+
'xxx-large'
|
|
24
|
+
];
|
|
25
|
+
/**
|
|
26
|
+
* The font size editing feature.
|
|
27
|
+
*
|
|
28
|
+
* It introduces the {@link module:font/fontsize/fontsizecommand~FontSizeCommand command} and the `fontSize`
|
|
29
|
+
* attribute in the {@link module:engine/model/model~Model model} which renders in the {@link module:engine/view/view view}
|
|
30
|
+
* as a `<span>` element with either:
|
|
31
|
+
* * a style attribute (`<span style="font-size:12px">...</span>`),
|
|
32
|
+
* * or a class attribute (`<span class="text-small">...</span>`)
|
|
33
|
+
*
|
|
34
|
+
* depending on the {@link module:font/fontconfig~FontSizeConfig configuration}.
|
|
35
|
+
*/
|
|
36
|
+
export default class FontSizeEditing extends Plugin {
|
|
37
|
+
/**
|
|
38
|
+
* @inheritDoc
|
|
39
|
+
*/
|
|
40
|
+
static get pluginName() {
|
|
41
|
+
return 'FontSizeEditing';
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* @inheritDoc
|
|
45
|
+
*/
|
|
46
|
+
static get isOfficialPlugin() {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* @inheritDoc
|
|
51
|
+
*/
|
|
52
|
+
constructor(editor) {
|
|
53
|
+
super(editor);
|
|
54
|
+
// Define default configuration using named presets.
|
|
55
|
+
editor.config.define(FONT_SIZE, {
|
|
56
|
+
options: [
|
|
57
|
+
'tiny',
|
|
58
|
+
'small',
|
|
59
|
+
'default',
|
|
60
|
+
'big',
|
|
61
|
+
'huge'
|
|
62
|
+
],
|
|
63
|
+
supportAllValues: false
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* @inheritDoc
|
|
68
|
+
*/
|
|
69
|
+
init() {
|
|
70
|
+
const editor = this.editor;
|
|
71
|
+
// Allow fontSize attribute on text nodes.
|
|
72
|
+
editor.model.schema.extend('$text', { allowAttributes: FONT_SIZE });
|
|
73
|
+
editor.model.schema.setAttributeProperties(FONT_SIZE, {
|
|
74
|
+
isFormatting: true,
|
|
75
|
+
copyOnEnter: true
|
|
76
|
+
});
|
|
77
|
+
const supportAllValues = editor.config.get('fontSize.supportAllValues');
|
|
78
|
+
// Define view to model conversion.
|
|
79
|
+
const options = normalizeOptions(this.editor.config.get('fontSize.options'))
|
|
80
|
+
.filter(item => item.model);
|
|
81
|
+
const definition = buildDefinition(FONT_SIZE, options);
|
|
82
|
+
// Set-up the two-way conversion.
|
|
83
|
+
if (supportAllValues) {
|
|
84
|
+
this._prepareAnyValueConverters(definition);
|
|
85
|
+
this._prepareCompatibilityConverter();
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
editor.conversion.attributeToElement(definition);
|
|
89
|
+
}
|
|
90
|
+
// Add FontSize command.
|
|
91
|
+
editor.commands.add(FONT_SIZE, new FontSizeCommand(editor));
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* These converters enable keeping any value found as `style="font-size: *"` as a value of an attribute on a text even
|
|
95
|
+
* if it is not defined in the plugin configuration.
|
|
96
|
+
*
|
|
97
|
+
* @param definition Converter definition out of input data.
|
|
98
|
+
*/
|
|
99
|
+
_prepareAnyValueConverters(definition) {
|
|
100
|
+
const editor = this.editor;
|
|
101
|
+
// If `fontSize.supportAllValues=true`, we do not allow to use named presets in the plugin's configuration.
|
|
102
|
+
const presets = definition.model.values.filter((value) => {
|
|
103
|
+
return !isLength(String(value)) && !isPercentage(String(value));
|
|
104
|
+
});
|
|
105
|
+
if (presets.length) {
|
|
106
|
+
/**
|
|
107
|
+
* If {@link module:font/fontconfig~FontSizeConfig#supportAllValues `config.fontSize.supportAllValues`} is `true`,
|
|
108
|
+
* you need to use numerical values as font size options.
|
|
109
|
+
*
|
|
110
|
+
* See valid examples described in the {@link module:font/fontconfig~FontSizeConfig#options plugin configuration}.
|
|
111
|
+
*
|
|
112
|
+
* @error font-size-invalid-use-of-named-presets
|
|
113
|
+
* @param {Array.<String>} presets Invalid values.
|
|
114
|
+
*/
|
|
115
|
+
throw new CKEditorError('font-size-invalid-use-of-named-presets', null, { presets });
|
|
116
|
+
}
|
|
117
|
+
editor.conversion.for('downcast').attributeToElement({
|
|
118
|
+
model: FONT_SIZE,
|
|
119
|
+
view: (attributeValue, { writer }) => {
|
|
120
|
+
if (!attributeValue) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
return writer.createAttributeElement('span', { style: 'font-size:' + attributeValue }, { priority: 7 });
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
editor.conversion.for('upcast').elementToAttribute({
|
|
127
|
+
model: {
|
|
128
|
+
key: FONT_SIZE,
|
|
129
|
+
value: (viewElement) => viewElement.getStyle('font-size')
|
|
130
|
+
},
|
|
131
|
+
view: {
|
|
132
|
+
name: 'span',
|
|
133
|
+
styles: {
|
|
134
|
+
'font-size': /.*/
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Adds support for legacy `<font size="..">` formatting.
|
|
141
|
+
*/
|
|
142
|
+
_prepareCompatibilityConverter() {
|
|
143
|
+
const editor = this.editor;
|
|
144
|
+
editor.conversion.for('upcast').elementToAttribute({
|
|
145
|
+
view: {
|
|
146
|
+
name: 'font',
|
|
147
|
+
attributes: {
|
|
148
|
+
// Documentation mentions sizes from 1 to 7. To handle old content we support all values
|
|
149
|
+
// up to 999 but clamp it to the valid range. Why 999? It should cover accidental values
|
|
150
|
+
// similar to percentage, e.g. 100%, 200% which could be the usual mistake for font size.
|
|
151
|
+
'size': /^[+-]?\d{1,3}$/
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
model: {
|
|
155
|
+
key: FONT_SIZE,
|
|
156
|
+
value: (viewElement) => {
|
|
157
|
+
const value = viewElement.getAttribute('size');
|
|
158
|
+
const isRelative = value[0] === '-' || value[0] === '+';
|
|
159
|
+
let size = parseInt(value, 10);
|
|
160
|
+
if (isRelative) {
|
|
161
|
+
// Add relative size (which can be negative) to the default size = 3.
|
|
162
|
+
size = 3 + size;
|
|
163
|
+
}
|
|
164
|
+
const maxSize = styleFontSize.length - 1;
|
|
165
|
+
const clampedSize = Math.min(Math.max(size, 0), maxSize);
|
|
166
|
+
return styleFontSize[clampedSize];
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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/fontsize/fontsizeui
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
+
import '../../theme/fontsize.css';
|
|
10
|
+
/**
|
|
11
|
+
* The font size UI plugin. It introduces the `'fontSize'` dropdown.
|
|
12
|
+
*/
|
|
13
|
+
export default class FontSizeUI extends Plugin {
|
|
14
|
+
/**
|
|
15
|
+
* @inheritDoc
|
|
16
|
+
*/
|
|
17
|
+
static get pluginName(): "FontSizeUI";
|
|
18
|
+
/**
|
|
19
|
+
* @inheritDoc
|
|
20
|
+
*/
|
|
21
|
+
static get isOfficialPlugin(): true;
|
|
22
|
+
/**
|
|
23
|
+
* @inheritDoc
|
|
24
|
+
*/
|
|
25
|
+
init(): void;
|
|
26
|
+
/**
|
|
27
|
+
* Returns options as defined in `config.fontSize.options` but processed to account for
|
|
28
|
+
* editor localization, i.e. to display {@link module:font/fontconfig~FontSizeOption}
|
|
29
|
+
* in the correct language.
|
|
30
|
+
*
|
|
31
|
+
* Note: The reason behind this method is that there is no way to use {@link module:utils/locale~Locale#t}
|
|
32
|
+
* when the user configuration is defined because the editor does not exist yet.
|
|
33
|
+
*/
|
|
34
|
+
private _getLocalizedOptions;
|
|
35
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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/fontsize/fontsizeui
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
+
import { ViewModel, createDropdown, addListToDropdown, MenuBarMenuView, MenuBarMenuListView, MenuBarMenuListItemView, MenuBarMenuListItemButtonView } from 'ckeditor5/src/ui.js';
|
|
10
|
+
import { Collection } from 'ckeditor5/src/utils.js';
|
|
11
|
+
import { normalizeOptions } from './utils.js';
|
|
12
|
+
import { FONT_SIZE } from '../utils.js';
|
|
13
|
+
import '../../theme/fontsize.css';
|
|
14
|
+
import fontSizeIcon from '../../theme/icons/font-size.svg';
|
|
15
|
+
/**
|
|
16
|
+
* The font size UI plugin. It introduces the `'fontSize'` dropdown.
|
|
17
|
+
*/
|
|
18
|
+
export default class FontSizeUI extends Plugin {
|
|
19
|
+
/**
|
|
20
|
+
* @inheritDoc
|
|
21
|
+
*/
|
|
22
|
+
static get pluginName() {
|
|
23
|
+
return 'FontSizeUI';
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* @inheritDoc
|
|
27
|
+
*/
|
|
28
|
+
static get isOfficialPlugin() {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* @inheritDoc
|
|
33
|
+
*/
|
|
34
|
+
init() {
|
|
35
|
+
const editor = this.editor;
|
|
36
|
+
const t = editor.t;
|
|
37
|
+
const options = this._getLocalizedOptions();
|
|
38
|
+
const command = editor.commands.get(FONT_SIZE);
|
|
39
|
+
const accessibleLabel = t('Font Size');
|
|
40
|
+
const listOptions = _prepareListOptions(options, command);
|
|
41
|
+
// Register UI component.
|
|
42
|
+
editor.ui.componentFactory.add(FONT_SIZE, locale => {
|
|
43
|
+
const dropdownView = createDropdown(locale);
|
|
44
|
+
addListToDropdown(dropdownView, listOptions, {
|
|
45
|
+
role: 'menu',
|
|
46
|
+
ariaLabel: accessibleLabel
|
|
47
|
+
});
|
|
48
|
+
// Create dropdown model.
|
|
49
|
+
dropdownView.buttonView.set({
|
|
50
|
+
label: accessibleLabel,
|
|
51
|
+
icon: fontSizeIcon,
|
|
52
|
+
tooltip: true
|
|
53
|
+
});
|
|
54
|
+
dropdownView.extendTemplate({
|
|
55
|
+
attributes: {
|
|
56
|
+
class: [
|
|
57
|
+
'ck-font-size-dropdown'
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
dropdownView.bind('isEnabled').to(command);
|
|
62
|
+
// Execute command when an item from the dropdown is selected.
|
|
63
|
+
this.listenTo(dropdownView, 'execute', evt => {
|
|
64
|
+
editor.execute(evt.source.commandName, { value: evt.source.commandParam });
|
|
65
|
+
editor.editing.view.focus();
|
|
66
|
+
});
|
|
67
|
+
return dropdownView;
|
|
68
|
+
});
|
|
69
|
+
editor.ui.componentFactory.add(`menuBar:${FONT_SIZE}`, locale => {
|
|
70
|
+
const menuView = new MenuBarMenuView(locale);
|
|
71
|
+
menuView.buttonView.set({
|
|
72
|
+
label: accessibleLabel,
|
|
73
|
+
icon: fontSizeIcon
|
|
74
|
+
});
|
|
75
|
+
menuView.bind('isEnabled').to(command);
|
|
76
|
+
const listView = new MenuBarMenuListView(locale);
|
|
77
|
+
for (const definition of listOptions) {
|
|
78
|
+
const listItemView = new MenuBarMenuListItemView(locale, menuView);
|
|
79
|
+
const buttonView = new MenuBarMenuListItemButtonView(locale);
|
|
80
|
+
buttonView.set({
|
|
81
|
+
role: 'menuitemradio',
|
|
82
|
+
isToggleable: true
|
|
83
|
+
});
|
|
84
|
+
buttonView.bind(...Object.keys(definition.model)).to(definition.model);
|
|
85
|
+
buttonView.delegate('execute').to(menuView);
|
|
86
|
+
buttonView.on('execute', () => {
|
|
87
|
+
editor.execute(definition.model.commandName, {
|
|
88
|
+
value: definition.model.commandParam
|
|
89
|
+
});
|
|
90
|
+
editor.editing.view.focus();
|
|
91
|
+
});
|
|
92
|
+
listItemView.children.add(buttonView);
|
|
93
|
+
listView.items.add(listItemView);
|
|
94
|
+
}
|
|
95
|
+
menuView.panelView.children.add(listView);
|
|
96
|
+
return menuView;
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Returns options as defined in `config.fontSize.options` but processed to account for
|
|
101
|
+
* editor localization, i.e. to display {@link module:font/fontconfig~FontSizeOption}
|
|
102
|
+
* in the correct language.
|
|
103
|
+
*
|
|
104
|
+
* Note: The reason behind this method is that there is no way to use {@link module:utils/locale~Locale#t}
|
|
105
|
+
* when the user configuration is defined because the editor does not exist yet.
|
|
106
|
+
*/
|
|
107
|
+
_getLocalizedOptions() {
|
|
108
|
+
const editor = this.editor;
|
|
109
|
+
const t = editor.t;
|
|
110
|
+
const localizedTitles = {
|
|
111
|
+
Default: t('Default'),
|
|
112
|
+
Tiny: t('Tiny'),
|
|
113
|
+
Small: t('Small'),
|
|
114
|
+
Big: t('Big'),
|
|
115
|
+
Huge: t('Huge')
|
|
116
|
+
};
|
|
117
|
+
const options = normalizeOptions((editor.config.get(FONT_SIZE)).options);
|
|
118
|
+
return options.map(option => {
|
|
119
|
+
const title = localizedTitles[option.title];
|
|
120
|
+
if (title && title != option.title) {
|
|
121
|
+
// Clone the option to avoid altering the original `namedPresets` from `./utils.js`.
|
|
122
|
+
option = Object.assign({}, option, { title });
|
|
123
|
+
}
|
|
124
|
+
return option;
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Prepares FontSize dropdown items.
|
|
130
|
+
*/
|
|
131
|
+
function _prepareListOptions(options, command) {
|
|
132
|
+
const itemDefinitions = new Collection();
|
|
133
|
+
for (const option of options) {
|
|
134
|
+
const def = {
|
|
135
|
+
type: 'button',
|
|
136
|
+
model: new ViewModel({
|
|
137
|
+
commandName: FONT_SIZE,
|
|
138
|
+
commandParam: option.model,
|
|
139
|
+
label: option.title,
|
|
140
|
+
class: 'ck-fontsize-option',
|
|
141
|
+
role: 'menuitemradio',
|
|
142
|
+
withText: true
|
|
143
|
+
})
|
|
144
|
+
};
|
|
145
|
+
if (option.view && typeof option.view !== 'string') {
|
|
146
|
+
if (option.view.styles) {
|
|
147
|
+
def.model.set('labelStyle', `font-size:${option.view.styles['font-size']}`);
|
|
148
|
+
}
|
|
149
|
+
if (option.view.classes) {
|
|
150
|
+
def.model.set('class', `${def.model.class} ${option.view.classes}`);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
def.model.bind('isOn').to(command, 'value', value => value === option.model);
|
|
154
|
+
// Add the option to the collection.
|
|
155
|
+
itemDefinitions.add(def);
|
|
156
|
+
}
|
|
157
|
+
return itemDefinitions;
|
|
158
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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 { type FontSizeOption } from '../fontconfig.js';
|
|
6
|
+
/**
|
|
7
|
+
* Normalizes and translates the {@link module:font/fontconfig~FontSizeConfig#options configuration options}
|
|
8
|
+
* to the {@link module:font/fontconfig~FontSizeOption} format.
|
|
9
|
+
*
|
|
10
|
+
* @param configuredOptions An array of options taken from the configuration.
|
|
11
|
+
*/
|
|
12
|
+
export declare function normalizeOptions(configuredOptions: Array<string | number | FontSizeOption>): Array<FontSizeOption>;
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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/fontsize/utils
|
|
7
|
+
*/
|
|
8
|
+
import { CKEditorError } from 'ckeditor5/src/utils.js';
|
|
9
|
+
/**
|
|
10
|
+
* Normalizes and translates the {@link module:font/fontconfig~FontSizeConfig#options configuration options}
|
|
11
|
+
* to the {@link module:font/fontconfig~FontSizeOption} format.
|
|
12
|
+
*
|
|
13
|
+
* @param configuredOptions An array of options taken from the configuration.
|
|
14
|
+
*/
|
|
15
|
+
export function normalizeOptions(configuredOptions) {
|
|
16
|
+
// Convert options to objects.
|
|
17
|
+
return configuredOptions
|
|
18
|
+
.map(item => getOptionDefinition(item))
|
|
19
|
+
// Filter out undefined values that `getOptionDefinition` might return.
|
|
20
|
+
.filter((option) => option !== undefined);
|
|
21
|
+
}
|
|
22
|
+
// Default named presets map. Always create a new instance of the preset object in order to avoid modifying references.
|
|
23
|
+
const namedPresets = {
|
|
24
|
+
get tiny() {
|
|
25
|
+
return {
|
|
26
|
+
title: 'Tiny',
|
|
27
|
+
model: 'tiny',
|
|
28
|
+
view: {
|
|
29
|
+
name: 'span',
|
|
30
|
+
classes: 'text-tiny',
|
|
31
|
+
priority: 7
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
get small() {
|
|
36
|
+
return {
|
|
37
|
+
title: 'Small',
|
|
38
|
+
model: 'small',
|
|
39
|
+
view: {
|
|
40
|
+
name: 'span',
|
|
41
|
+
classes: 'text-small',
|
|
42
|
+
priority: 7
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
get big() {
|
|
47
|
+
return {
|
|
48
|
+
title: 'Big',
|
|
49
|
+
model: 'big',
|
|
50
|
+
view: {
|
|
51
|
+
name: 'span',
|
|
52
|
+
classes: 'text-big',
|
|
53
|
+
priority: 7
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
get huge() {
|
|
58
|
+
return {
|
|
59
|
+
title: 'Huge',
|
|
60
|
+
model: 'huge',
|
|
61
|
+
view: {
|
|
62
|
+
name: 'span',
|
|
63
|
+
classes: 'text-huge',
|
|
64
|
+
priority: 7
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Returns an option definition either from preset or creates one from number shortcut.
|
|
71
|
+
* If object is passed then this method will return it without alternating it. Returns undefined for item than cannot be parsed.
|
|
72
|
+
*/
|
|
73
|
+
function getOptionDefinition(option) {
|
|
74
|
+
if (typeof option === 'number') {
|
|
75
|
+
option = String(option);
|
|
76
|
+
}
|
|
77
|
+
// Check whether passed option is a full item definition provided by user in configuration.
|
|
78
|
+
if (typeof option === 'object' && isFullItemDefinition(option)) {
|
|
79
|
+
return attachPriority(option);
|
|
80
|
+
}
|
|
81
|
+
const preset = findPreset(option);
|
|
82
|
+
// Item is a named preset.
|
|
83
|
+
if (preset) {
|
|
84
|
+
return attachPriority(preset);
|
|
85
|
+
}
|
|
86
|
+
// 'Default' font size. It will be used to remove the fontSize attribute.
|
|
87
|
+
if (option === 'default') {
|
|
88
|
+
return {
|
|
89
|
+
model: undefined,
|
|
90
|
+
title: 'Default'
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
// At this stage we probably have numerical value to generate a preset so parse it's value.
|
|
94
|
+
// Discard any faulty values.
|
|
95
|
+
if (isNumericalDefinition(option)) {
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
// Return font size definition from size value.
|
|
99
|
+
return generatePixelPreset(option);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Creates a predefined preset for pixel size.
|
|
103
|
+
* @param definition Font size in pixels.
|
|
104
|
+
* @returns
|
|
105
|
+
*/
|
|
106
|
+
function generatePixelPreset(definition) {
|
|
107
|
+
// Extend a short (numeric value) definition.
|
|
108
|
+
if (typeof definition === 'string') {
|
|
109
|
+
definition = {
|
|
110
|
+
title: definition,
|
|
111
|
+
model: `${parseFloat(definition)}px`
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
definition.view = {
|
|
115
|
+
name: 'span',
|
|
116
|
+
styles: {
|
|
117
|
+
'font-size': definition.model
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
return attachPriority(definition);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Adds the priority to the view element definition if missing. It's required due to ckeditor/ckeditor5#2291
|
|
124
|
+
*/
|
|
125
|
+
function attachPriority(definition) {
|
|
126
|
+
if (definition.view && typeof definition.view !== 'string' && !definition.view.priority) {
|
|
127
|
+
definition.view.priority = 7;
|
|
128
|
+
}
|
|
129
|
+
return definition;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Returns a prepared preset definition. If passed an object, a name of preset should be defined as `model` value.
|
|
133
|
+
*
|
|
134
|
+
* @param definition.model A preset name.
|
|
135
|
+
*/
|
|
136
|
+
function findPreset(definition) {
|
|
137
|
+
return typeof definition === 'string' ? namedPresets[definition] : namedPresets[definition.model];
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* We treat `definition` as completed if it is an object that contains `title`, `model` and `view` values.
|
|
141
|
+
*/
|
|
142
|
+
function isFullItemDefinition(definition) {
|
|
143
|
+
return definition.title && definition.model && definition.view;
|
|
144
|
+
}
|
|
145
|
+
function isNumericalDefinition(definition) {
|
|
146
|
+
let numberValue;
|
|
147
|
+
if (typeof definition === 'object') {
|
|
148
|
+
if (!definition.model) {
|
|
149
|
+
/**
|
|
150
|
+
* Provided value as an option for {@link module:font/fontsize~FontSize} seems to invalid.
|
|
151
|
+
*
|
|
152
|
+
* See valid examples described in the {@link module:font/fontconfig~FontSizeConfig#options plugin configuration}.
|
|
153
|
+
*
|
|
154
|
+
* @error font-size-invalid-definition
|
|
155
|
+
*/
|
|
156
|
+
throw new CKEditorError('font-size-invalid-definition', null, definition);
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
numberValue = parseFloat(definition.model);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
numberValue = parseFloat(definition);
|
|
164
|
+
}
|
|
165
|
+
return isNaN(numberValue);
|
|
166
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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/fontsize
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
+
import FontSizeEditing from './fontsize/fontsizeediting.js';
|
|
10
|
+
import FontSizeUI from './fontsize/fontsizeui.js';
|
|
11
|
+
import type { FontSizeOption } from './fontconfig.js';
|
|
12
|
+
/**
|
|
13
|
+
* The font size plugin.
|
|
14
|
+
*
|
|
15
|
+
* For a detailed overview, check the {@glink features/font font feature} documentation
|
|
16
|
+
* and the {@glink api/font package page}.
|
|
17
|
+
*
|
|
18
|
+
* This is a "glue" plugin which loads the {@link module:font/fontsize/fontsizeediting~FontSizeEditing} and
|
|
19
|
+
* {@link module:font/fontsize/fontsizeui~FontSizeUI} features in the editor.
|
|
20
|
+
*/
|
|
21
|
+
export default class FontSize extends Plugin {
|
|
22
|
+
/**
|
|
23
|
+
* @inheritDoc
|
|
24
|
+
*/
|
|
25
|
+
static get requires(): readonly [typeof FontSizeEditing, typeof FontSizeUI];
|
|
26
|
+
/**
|
|
27
|
+
* @inheritDoc
|
|
28
|
+
*/
|
|
29
|
+
static get pluginName(): "FontSize";
|
|
30
|
+
/**
|
|
31
|
+
* @inheritDoc
|
|
32
|
+
*/
|
|
33
|
+
static get isOfficialPlugin(): true;
|
|
34
|
+
/**
|
|
35
|
+
* Normalizes and translates the {@link module:font/fontconfig~FontSizeConfig#options configuration options}
|
|
36
|
+
* to the {@link module:font/fontconfig~FontSizeOption} format.
|
|
37
|
+
*
|
|
38
|
+
* @param configuredOptions An array of options taken from the configuration.
|
|
39
|
+
*/
|
|
40
|
+
normalizeSizeOptions(options: Array<string | number | FontSizeOption>): Array<FontSizeOption>;
|
|
41
|
+
}
|
package/src/fontsize.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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/fontsize
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
+
import FontSizeEditing from './fontsize/fontsizeediting.js';
|
|
10
|
+
import FontSizeUI from './fontsize/fontsizeui.js';
|
|
11
|
+
import { normalizeOptions } from './fontsize/utils.js';
|
|
12
|
+
/**
|
|
13
|
+
* The font size plugin.
|
|
14
|
+
*
|
|
15
|
+
* For a detailed overview, check the {@glink features/font font feature} documentation
|
|
16
|
+
* and the {@glink api/font package page}.
|
|
17
|
+
*
|
|
18
|
+
* This is a "glue" plugin which loads the {@link module:font/fontsize/fontsizeediting~FontSizeEditing} and
|
|
19
|
+
* {@link module:font/fontsize/fontsizeui~FontSizeUI} features in the editor.
|
|
20
|
+
*/
|
|
21
|
+
export default class FontSize extends Plugin {
|
|
22
|
+
/**
|
|
23
|
+
* @inheritDoc
|
|
24
|
+
*/
|
|
25
|
+
static get requires() {
|
|
26
|
+
return [FontSizeEditing, FontSizeUI];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* @inheritDoc
|
|
30
|
+
*/
|
|
31
|
+
static get pluginName() {
|
|
32
|
+
return 'FontSize';
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* @inheritDoc
|
|
36
|
+
*/
|
|
37
|
+
static get isOfficialPlugin() {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Normalizes and translates the {@link module:font/fontconfig~FontSizeConfig#options configuration options}
|
|
42
|
+
* to the {@link module:font/fontconfig~FontSizeOption} format.
|
|
43
|
+
*
|
|
44
|
+
* @param configuredOptions An array of options taken from the configuration.
|
|
45
|
+
*/
|
|
46
|
+
normalizeSizeOptions(options) {
|
|
47
|
+
return normalizeOptions(options);
|
|
48
|
+
}
|
|
49
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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
|
|
7
|
+
*/
|
|
8
|
+
export { default as Font } from './font.js';
|
|
9
|
+
export { default as FontBackgroundColor } from './fontbackgroundcolor.js';
|
|
10
|
+
export { default as FontColor } from './fontcolor.js';
|
|
11
|
+
export { default as FontFamily } from './fontfamily.js';
|
|
12
|
+
export { default as FontSize } from './fontsize.js';
|
|
13
|
+
export { default as FontBackgroundColorEditing } from './fontbackgroundcolor/fontbackgroundcolorediting.js';
|
|
14
|
+
export { default as FontBackgroundColorUI } from './fontbackgroundcolor/fontbackgroundcolorui.js';
|
|
15
|
+
export { default as FontColorEditing } from './fontcolor/fontcolorediting.js';
|
|
16
|
+
export { default as FontColorUI } from './fontcolor/fontcolorui.js';
|
|
17
|
+
export { default as FontFamilyEditing } from './fontfamily/fontfamilyediting.js';
|
|
18
|
+
export { default as FontFamilyUI } from './fontfamily/fontfamilyui.js';
|
|
19
|
+
export { default as FontSizeEditing } from './fontsize/fontsizeediting.js';
|
|
20
|
+
export { default as FontSizeUI } from './fontsize/fontsizeui.js';
|
|
21
|
+
export type { default as FontBackgroundColorCommand } from './fontbackgroundcolor/fontbackgroundcolorcommand.js';
|
|
22
|
+
export type { default as FontColorCommand } from './fontcolor/fontcolorcommand.js';
|
|
23
|
+
export type { default as FontFamilyCommand } from './fontfamily/fontfamilycommand.js';
|
|
24
|
+
export type { default as FontSizeCommand } from './fontsize/fontsizecommand.js';
|
|
25
|
+
export type { FONT_BACKGROUND_COLOR, FONT_COLOR, FONT_FAMILY, FONT_SIZE } from './utils.js';
|
|
26
|
+
export type { FontColorConfig, FontFamilyConfig, FontSizeConfig } from './fontconfig.js';
|
|
27
|
+
import './augmentation.js';
|
package/src/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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
|
|
7
|
+
*/
|
|
8
|
+
export { default as Font } from './font.js';
|
|
9
|
+
export { default as FontBackgroundColor } from './fontbackgroundcolor.js';
|
|
10
|
+
export { default as FontColor } from './fontcolor.js';
|
|
11
|
+
export { default as FontFamily } from './fontfamily.js';
|
|
12
|
+
export { default as FontSize } from './fontsize.js';
|
|
13
|
+
export { default as FontBackgroundColorEditing } from './fontbackgroundcolor/fontbackgroundcolorediting.js';
|
|
14
|
+
export { default as FontBackgroundColorUI } from './fontbackgroundcolor/fontbackgroundcolorui.js';
|
|
15
|
+
export { default as FontColorEditing } from './fontcolor/fontcolorediting.js';
|
|
16
|
+
export { default as FontColorUI } from './fontcolor/fontcolorui.js';
|
|
17
|
+
export { default as FontFamilyEditing } from './fontfamily/fontfamilyediting.js';
|
|
18
|
+
export { default as FontFamilyUI } from './fontfamily/fontfamilyui.js';
|
|
19
|
+
export { default as FontSizeEditing } from './fontsize/fontsizeediting.js';
|
|
20
|
+
export { default as FontSizeUI } from './fontsize/fontsizeui.js';
|
|
21
|
+
import './augmentation.js';
|