浏览代码

Improved documentation of the plugin.

Kamil Piechaczek 5 年之前
父节点
当前提交
324f6793b7

+ 16 - 0
packages/ckeditor5-font/src/fontfamily.js

@@ -112,3 +112,19 @@ export default class FontFamily extends Plugin {
  *
  * @member {Array.<String|module:font/fontfamily~FontFamilyOption>} module:font/fontfamily~FontFamilyConfig#options
  */
+
+/**
+ * By default the plugin removes any `font-family` value that does not match to the plugin's configuration. It means if you paste a content
+ * with font families that the editor does not understand, the font-family attribute will be removed and the content will be displayed
+ * with the font.
+ *
+ * You can preserve pasted font family values by switching the option:
+ *
+ *		const fontSizeConfig = {
+ *			disableValueMatching: true
+ *		};
+ *
+ * Now, the font families, not specified in the editor's configuration, won't be removed when pasting the content.
+ *
+ * @member {Boolean} module:font/fontfamily~FontFamilyConfig#disableValueMatching
+ */

+ 32 - 0
packages/ckeditor5-font/src/fontsize.js

@@ -105,6 +105,22 @@ export default class FontSize extends Plugin {
  * 			options: [ 9, 10, 11, 12, 13, 14, 15 ]
  * 		};
  *
+ * Also, you can define a label in the dropdown for numerical values:
+ *
+ *		const fontSizeConfig = {
+ *			options: [
+ *				{
+ * 				 	title: 'Small',
+ * 				 	model: '8px
+ * 				},
+ * 				'default',
+ * 				{
+ * 				 	title: 'Big',
+ * 				 	model: '14px
+ * 				}
+ *			]
+ *		};
+ *
  * Font size can be applied using the command API. To do that, use the `'fontSize'` command and pass the desired font size as a `value`.
  * For example, the following code will apply the `fontSize` attribute with the **tiny** value to the current selection:
  *
@@ -114,3 +130,19 @@ export default class FontSize extends Plugin {
  *
  * @member {Array.<String|Number|module:font/fontsize~FontSizeOption>} module:font/fontsize~FontSizeConfig#options
  */
+
+/**
+ * By default the plugin removes any `font-size` value that does not match to the plugin's configuration. It means if you paste a content
+ * with font sizes that the editor does not understand, the font-size attribute will be removed and the content will be displayed
+ * with the default size.
+ *
+ * You can preserve pasted font size values by switching the option:
+ *
+ *		const fontSizeConfig = {
+ *			disableValueMatching: true
+ *		};
+ *
+ * Now, the font sizes, not specified in the editor's configuration, won't be removed when pasting the content.
+ *
+ * @member {Boolean} module:font/fontsize~FontSizeConfig#disableValueMatching
+ */

+ 1 - 1
packages/ckeditor5-font/src/fontsize/utils.js

@@ -26,7 +26,7 @@ export function normalizeOptions( configuredOptions, options = {} ) {
 		.filter( option => !!option );
 }
 
-// The values should be synchronized with "/theme/fontsize.css" file.
+// The values should be synchronized with values specified in the "/theme/fontsize.css" file.
 export const FONT_SIZE_PRESET_UNITS = {
 	tiny: '0.7em',
 	small: '0.85em',

+ 1 - 1
packages/ckeditor5-font/theme/fontsize.css

@@ -3,7 +3,7 @@
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  */
 
-/* The values should be synchronized with the "FONT_SIZE_PRESET_UNITS" constant in the "/src/fontsize/utils.js" file. */
+/* The values should be synchronized with the "FONT_SIZE_PRESET_UNITS" object in the "/src/fontsize/utils.js" file. */
 .text-tiny {
 	font-size: .7em;
 }