8
0
Просмотр исходного кода

Refactor and add docs for styles processing rules.

Maciej Gołaszewski 6 лет назад
Родитель
Сommit
060dd53512

+ 1 - 1
packages/ckeditor5-engine/src/view/element.js

@@ -386,7 +386,7 @@ export default class Element extends Node {
 	 * For an element with style set to: 'margin:1px
 	 *
 	 *		// Enable 'margin' shorthand processing:
-	 *		editor.editing.view.document.addStyleProcessorRules( addMarginStylesProcessor );
+	 *		editor.editing.view.document.addStyleProcessorRules( addMarginRules );
 	 *
 	 *		const element = view.change( writer => {
 	 *			const element = writer.createElement();

+ 10 - 3
packages/ckeditor5-engine/src/view/styles/backgroundstyles.js → packages/ckeditor5-engine/src/view/styles/background.js

@@ -3,13 +3,20 @@
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  */
 
+/**
+ * @module engine/view/styles/background
+ */
+
 import { isAttachment, isColor, isPosition, isRepeat, isURL } from './utils';
 
 /**
- * @module engine/view/styles
+ * Adds a background CSS styles processing rules.
+ *
+ *		editor.editing.view.document.addStyleProcessorRules( addBackgroundRules );
+ *
+ * @param {module:engine/view/stylesmap~StylesProcessor} stylesProcessor
  */
-
-export function addBackgroundStylesProcessor( stylesProcessor ) {
+export function addBackgroundRules( stylesProcessor ) {
 	stylesProcessor.setNormalizer( 'background', normalizeBackground );
 	stylesProcessor.setNormalizer( 'background-color', value => ( { path: 'background.color', value } ) );
 	stylesProcessor.setReducer( 'background', value => {

+ 10 - 3
packages/ckeditor5-engine/src/view/styles/borderstyles.js → packages/ckeditor5-engine/src/view/styles/border.js

@@ -3,13 +3,20 @@
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  */
 
+/**
+ * @module engine/view/styles/border
+ */
+
 import { getShorthandValues, getTopRightBottomLeftValueReducer, getTopRightBottomLeftValues, isLength, isLineStyle } from './utils';
 
 /**
- * @module engine/view/styles/borderstyle
+ * Adds a border CSS styles processing rules.
+ *
+ *		editor.editing.view.document.addStyleProcessorRules( addBorderRules );
+ *
+ * @param {module:engine/view/stylesmap~StylesProcessor} stylesProcessor
  */
-
-export function addBorderStylesProcessor( stylesProcessor ) {
+export function addBorderRules( stylesProcessor ) {
 	stylesProcessor.setNormalizer( 'border', borderNormalizer );
 
 	// Border-position shorthands.

+ 10 - 3
packages/ckeditor5-engine/src/view/styles/marginstyles.js → packages/ckeditor5-engine/src/view/styles/margin.js

@@ -3,13 +3,20 @@
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  */
 
+/**
+ * @module engine/view/styles/margin
+ */
+
 import { getPositionShorthandNormalizer, getTopRightBottomLeftValueReducer } from './utils';
 
 /**
- * @module engine/view/styles
+ * Adds a margin CSS styles processing rules.
+ *
+ *		editor.editing.view.document.addStyleProcessorRules( addMarginRules );
+ *
+ * @param {module:engine/view/stylesmap~StylesProcessor} stylesProcessor
  */
-
-export function addMarginStylesProcessor( stylesProcessor ) {
+export function addMarginRules( stylesProcessor ) {
 	stylesProcessor.setNormalizer( 'margin', getPositionShorthandNormalizer( 'margin' ) );
 
 	stylesProcessor.setNormalizer( 'margin-top', value => ( { path: 'margin.top', value } ) );

+ 10 - 3
packages/ckeditor5-engine/src/view/styles/paddingstyles.js → packages/ckeditor5-engine/src/view/styles/padding.js

@@ -3,13 +3,20 @@
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  */
 
+/**
+ * @module engine/view/styles/padding
+ */
+
 import { getPositionShorthandNormalizer, getTopRightBottomLeftValueReducer } from './utils';
 
 /**
- * @module engine/view/styles
+ * Adds a margin CSS styles processing rules.
+ *
+ *		editor.editing.view.document.addStyleProcessorRules( addPaddingRules );
+ *
+ * @param {module:engine/view/stylesmap~StylesProcessor} stylesProcessor
  */
-
-export function addPaddingStylesProcessor( stylesProcessor ) {
+export function addPaddingRules( stylesProcessor ) {
 	stylesProcessor.setNormalizer( 'padding', getPositionShorthandNormalizer( 'padding' ) );
 	stylesProcessor.setNormalizer( 'padding-top', value => ( { path: 'padding.top', value } ) );
 	stylesProcessor.setNormalizer( 'padding-right', value => ( { path: 'padding.right', value } ) );

+ 6 - 6
packages/ckeditor5-engine/src/view/stylesmap.js

@@ -94,7 +94,7 @@ export default class StylesMap {
 	 * *Note:* This check supports normalized style names.
 	 *
 	 *		// Enable 'margin' shorthand processing:
-	 *		editor.editing.view.document.addStyleProcessorRules( addMarginStylesProcessor );
+	 *		editor.editing.view.document.addStyleProcessorRules( addMarginRules );
 	 *
 	 *		styles.setTo( 'margin:2px;' );
 	 *
@@ -142,7 +142,7 @@ export default class StylesMap {
 	 * *Note:* This method supports normalized styles if defined.
 	 *
 	 *		// Enable 'margin' shorthand processing:
-	 *		editor.editing.view.document.addStyleProcessorRules( addMarginStylesProcessor );
+	 *		editor.editing.view.document.addStyleProcessorRules( addMarginRules );
 	 *
 	 *		styles.set( 'margin', '2px' );
 	 *
@@ -185,7 +185,7 @@ export default class StylesMap {
 	 * *Note:* This method supports normalized styles if defined.
 	 *
 	 *		// Enable 'margin' shorthand processing:
-	 *		editor.editing.view.document.addStyleProcessorRules( addMarginStylesProcessor );
+	 *		editor.editing.view.document.addStyleProcessorRules( addMarginRules );
 	 *
 	 *		styles.setTo( 'margin:1px' );
 	 *
@@ -205,7 +205,7 @@ export default class StylesMap {
 	 * Returns a normalized style object or a single value.
 	 *
 	 *		// Enable 'margin' shorthand processing:
-	 *		editor.editing.view.document.addStyleProcessorRules( addMarginStylesProcessor );
+	 *		editor.editing.view.document.addStyleProcessorRules( addMarginRules );
 	 *
 	 *		const styles = new Styles();
 	 *		styles.setTo( 'margin:1px 2px 3em;' );
@@ -242,7 +242,7 @@ export default class StylesMap {
 	 * *Note:* This method supports normalized styles if defined.
 	 *
 	 *		// Enable 'margin' shorthand processing:
-	 *		editor.editing.view.document.addStyleProcessorRules( addMarginStylesProcessor );
+	 *		editor.editing.view.document.addStyleProcessorRules( addMarginRules );
 	 *
 	 *		styles.set( 'margin' , '1px' );
 	 *		styles.set( 'background', '#f00' );
@@ -269,7 +269,7 @@ export default class StylesMap {
 	 * Returns property as a value string or undefined if property is not set.
 	 *
 	 *		// Enable 'margin' shorthand processing:
-	 *		editor.editing.view.document.addStyleProcessorRules( addMarginStylesProcessor );
+	 *		editor.editing.view.document.addStyleProcessorRules( addMarginRules );
 	 *
 	 *		const styles = new Styles();
 	 *		styles.setTo( 'margin:1px;' );

+ 2 - 2
packages/ckeditor5-engine/tests/view/styles/backgroundstyles.js

@@ -4,7 +4,7 @@
  */
 
 import StylesMap, { StylesProcessor } from '../../../src/view/stylesmap';
-import { addBackgroundStylesProcessor } from '../../../src/view/styles/backgroundstyles';
+import { addBackgroundRules } from '../../../src/view/styles/background';
 
 describe( 'Background styles normalization', () => {
 	let styles;
@@ -12,7 +12,7 @@ describe( 'Background styles normalization', () => {
 	before( () => {
 		const stylesProcessor = new StylesProcessor();
 		StylesMap._setProcessor( stylesProcessor );
-		addBackgroundStylesProcessor( stylesProcessor );
+		addBackgroundRules( stylesProcessor );
 	} );
 
 	beforeEach( () => {

+ 2 - 2
packages/ckeditor5-engine/tests/view/styles/borderstyles.js

@@ -4,7 +4,7 @@
  */
 
 import StylesMap, { StylesProcessor } from '../../../src/view/stylesmap';
-import { addBorderStylesProcessor } from '../../../src/view/styles/borderstyles';
+import { addBorderRules } from '../../../src/view/styles/border';
 
 describe( 'Border styles normalization', () => {
 	let styles;
@@ -12,7 +12,7 @@ describe( 'Border styles normalization', () => {
 	before( () => {
 		const stylesProcessor = new StylesProcessor();
 		StylesMap._setProcessor( stylesProcessor );
-		addBorderStylesProcessor( stylesProcessor );
+		addBorderRules( stylesProcessor );
 	} );
 
 	beforeEach( () => {

+ 2 - 2
packages/ckeditor5-engine/tests/view/styles/marginstyles.js

@@ -4,7 +4,7 @@
  */
 
 import StylesMap, { StylesProcessor } from '../../../src/view/stylesmap';
-import { addMarginStylesProcessor } from '../../../src/view/styles/marginstyles';
+import { addMarginRules } from '../../../src/view/styles/margin';
 
 describe( 'Margin styles normalizer', () => {
 	let styles;
@@ -12,7 +12,7 @@ describe( 'Margin styles normalizer', () => {
 	before( () => {
 		const stylesProcessor = new StylesProcessor();
 		StylesMap._setProcessor( stylesProcessor );
-		addMarginStylesProcessor( stylesProcessor );
+		addMarginRules( stylesProcessor );
 	} );
 
 	beforeEach( () => {

+ 2 - 2
packages/ckeditor5-engine/tests/view/styles/paddingstyles.js

@@ -4,7 +4,7 @@
  */
 
 import StylesMap, { StylesProcessor } from '../../../src/view/stylesmap';
-import { addPaddingStylesProcessor } from '../../../src/view/styles/paddingstyles';
+import { addPaddingRules } from '../../../src/view/styles/padding';
 
 describe( 'Padding styles normalization', () => {
 	let styles;
@@ -12,7 +12,7 @@ describe( 'Padding styles normalization', () => {
 	before( () => {
 		const stylesProcessor = new StylesProcessor();
 		StylesMap._setProcessor( stylesProcessor );
-		addPaddingStylesProcessor( stylesProcessor );
+		addPaddingRules( stylesProcessor );
 	} );
 
 	beforeEach( () => {

+ 2 - 2
packages/ckeditor5-engine/tests/view/stylesmap.js

@@ -5,7 +5,7 @@
 
 import StylesMap, { StylesProcessor } from '../../src/view/stylesmap';
 import encodedImage from './_utils/encodedimage.txt';
-import { addPaddingStylesProcessor } from '../../src/view/styles/paddingstyles';
+import { addPaddingRules } from '../../src/view/styles/padding';
 import { getTopRightBottomLeftValueReducer } from '../../src/view/styles/utils';
 
 describe( 'StylesMap', () => {
@@ -25,7 +25,7 @@ describe( 'StylesMap', () => {
 		} ) );
 		stylesProcessor.setReducer( 'foo', getTopRightBottomLeftValueReducer( 'foo' ) );
 
-		addPaddingStylesProcessor( stylesProcessor );
+		addPaddingRules( stylesProcessor );
 		StylesMap._setProcessor( stylesProcessor );
 		stylesMap = new StylesMap();
 	} );