Browse Source

Add documentation about normalized styles values.

Maciej Gołaszewski 6 years ago
parent
commit
610c8d848b

+ 15 - 0
packages/ckeditor5-engine/src/view/styles/background.js

@@ -14,6 +14,21 @@ import { isAttachment, isColor, isPosition, isRepeat, isURL } from './utils';
  *
  *		editor.editing.view.document.addStyleProcessorRules( addBackgroundRules );
  *
+ * The normalized value is stored as:
+ *
+ *		const styles = {
+ *			background: {
+ *				color,
+ *				repeat,
+ *				position,
+ *				attachment,
+ *				image
+ *			}
+ *		};
+ *
+ * *Note*: Currently only `'background-color'` longhand value is parsed besides `'background'` shorthand. The reducer also supports only
+ * `'background-color'` value.
+ *
  * @param {module:engine/view/stylesmap~StylesProcessor} stylesProcessor
  */
 export function addBackgroundRules( stylesProcessor ) {

+ 28 - 0
packages/ckeditor5-engine/src/view/styles/border.js

@@ -14,6 +14,34 @@ import { getShorthandValues, getTopRightBottomLeftValueReducer, getTopRightBotto
  *
  *		editor.editing.view.document.addStyleProcessorRules( addBorderRules );
  *
+ * This rules merges all [border](https://developer.mozilla.org/en-US/docs/Web/CSS/border) styles notation shorthands:
+ *
+ * - border
+ * - border-top
+ * - border-right
+ * - border-bottom
+ * - border-left
+ * - border-color
+ * - border-style
+ * - border-width
+ *
+ * and all corresponding longhand forms (like `border-top-color`, `border-top-style`, etc).
+ *
+ * It does not handle other shorthands (like `border-radius` or `border-image`).
+ *
+ * The normalized model stores border values as:
+ *
+ *		const styles = {
+ *			border: {
+ *				color: { top, right, bottom, left },
+ *				style: { top, right, bottom, left },
+ *				width: { top, right, bottom, left },
+ *			}
+ *		};
+ *
+ * The `border` value is reduced to a 4 values for each box edge (even if they could be further reduces to a single
+ * `border:<width> <style> <color>` style.
+ *
  * @param {module:engine/view/stylesmap~StylesProcessor} stylesProcessor
  */
 export function addBorderRules( stylesProcessor ) {

+ 11 - 0
packages/ckeditor5-engine/src/view/styles/margin.js

@@ -14,6 +14,17 @@ import { getPositionShorthandNormalizer, getTopRightBottomLeftValueReducer } fro
  *
  *		editor.editing.view.document.addStyleProcessorRules( addMarginRules );
  *
+ * The normalized value is stored as:
+ *
+ *		const styles = {
+ *			margin: {
+ *				top,
+ *				right,
+ *				bottom,
+ *				left
+ *			}
+ *		};
+ *
  * @param {module:engine/view/stylesmap~StylesProcessor} stylesProcessor
  */
 export function addMarginRules( stylesProcessor ) {

+ 11 - 0
packages/ckeditor5-engine/src/view/styles/padding.js

@@ -14,6 +14,17 @@ import { getPositionShorthandNormalizer, getTopRightBottomLeftValueReducer } fro
  *
  *		editor.editing.view.document.addStyleProcessorRules( addPaddingRules );
  *
+ * The normalized value is stored as:
+ *
+ *		const styles = {
+ *			padding: {
+ *				top,
+ *				right,
+ *				bottom,
+ *				left
+ *			}
+ *		};
+ *
  * @param {module:engine/view/stylesmap~StylesProcessor} stylesProcessor
  */
 export function addPaddingRules( stylesProcessor ) {