ソースを参照

Add margin output.

Maciej Gołaszewski 6 年 前
コミット
e22c427bb4
1 ファイル変更31 行追加0 行削除
  1. 31 0
      packages/ckeditor5-engine/src/view/styles.js

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

@@ -275,6 +275,37 @@ function toInlineStyle( styleName, styleObjectOrString, strict = false ) {
 		return toInlineBorder( styleObjectOrString );
 	}
 
+	if ( styleName === 'margin' ) {
+		const { top, right, bottom, left } = styleObjectOrString;
+
+		if ( top === left && left === bottom && bottom === right ) {
+			return ( strict ? 'margin' : '' ) + top;
+		} else if ( ![ top, right, left, bottom ].every( value => !!value ) ) {
+			const ret = [];
+
+			// TODO not so nice:
+			if ( top ) {
+				ret.push( 'margin-top:' + top );
+			}
+
+			if ( right ) {
+				ret.push( 'margin-right:' + right );
+			}
+
+			if ( bottom ) {
+				ret.push( 'margin-bottom:' + bottom );
+			}
+
+			if ( left ) {
+				ret.push( 'margin-left:' + left );
+			}
+
+			return ret.join( ';' );
+		} else {
+			return 'margin...';
+		}
+	}
+
 	return ( strict ? '' : styleName + ':' ) + styleObjectOrString;
 }