Parcourir la source

Add StylesMap.hasProperty() documentation.

Maciej Gołaszewski il y a 6 ans
Parent
commit
cf57e8fd1d
1 fichiers modifiés avec 22 ajouts et 2 suppressions
  1. 22 2
      packages/ckeditor5-engine/src/view/stylesmap.js

+ 22 - 2
packages/ckeditor5-engine/src/view/stylesmap.js

@@ -72,9 +72,29 @@ export default class StylesMap {
 	}
 
 	/**
-	 * Checks if single style rule is set.
+	 * Checks if a given style is set.
 	 *
-	 * Supports shorthands.
+	 *		styles.setTo( 'margin-left:1px;' );
+	 *
+	 *		styles.hasProperty( 'margin-left' );    // returns true
+	 *		styles.hasProperty( 'padding' );        // returns false
+	 *
+	 * *Note:* This check supports normalized style names.
+	 *
+	 *		// Enable 'margin' shorthand processing:
+	 *		editor.editing.view.document.addStyleProcessorRules( addMarginStylesProcessor );
+	 *
+	 *		styles.setTo( 'margin:2px;' );
+	 *
+	 *		styles.hasProperty( 'margin' );         // returns true
+	 *		styles.hasProperty( 'margin-top' );     // returns true
+	 *		styles.hasProperty( 'margin-left' );    // returns true
+	 *
+	 *		styles.removeProperty( 'margin-top' );
+	 *
+	 *		styles.hasProperty( 'margin' );         // returns false
+	 *		styles.hasProperty( 'margin-top' );     // returns false
+	 *		styles.hasProperty( 'margin-left' );    // returns true
 	 *
 	 * @param {String} propertyName
 	 * @returns {Boolean}