diff --git a/src/style_manager/config/config.js b/src/style_manager/config/config.js index 85c313b9e..f1cf37e0c 100644 --- a/src/style_manager/config/config.js +++ b/src/style_manager/config/config.js @@ -4,7 +4,7 @@ export default { { name: 'General', open: false, - properties: ['float', 'display', 'position', 'top', 'right', 'left', 'bottom'], + properties: ['display', 'float', 'position', 'top', 'right', 'left', 'bottom'], }, { name: 'Flex', diff --git a/src/style_manager/model/Property.js b/src/style_manager/model/Property.js index 4a4315be9..815ab1fae 100644 --- a/src/style_manager/model/Property.js +++ b/src/style_manager/model/Property.js @@ -126,6 +126,14 @@ export default class Property extends Model { return !isUndefined(val) && val !== '' && !parentValue; } + /** + * Indicates if the current value is coming from a parent target (eg. another CSSRule). + * @returns {Boolean} + */ + hasValueParent() { + return this.hasValue() && !this.hasValue({ noParent: true }); + } + /** * Get the CSS style object of the property. * @param {Object} [opts={}] Options @@ -182,6 +190,23 @@ export default class Property extends Model { this._up(this.__getClearProps(), { ...opts, __clear: true }); } + /** + * Indicates if the current value comes directly from the selected target and so can be cleared. + * @returns {Boolean} + */ + canClear() { + const parent = this.getParent(); + return parent ? parent.__canClearProp(this) : this.hasValue({ noParent: true }); + } + + /** + * If the current property is a sub-property, this will return the parent Property. + * @returns {[Property]|null} + */ + getParent() { + return this.__getParentProp() || null; + } + __parseValue(value, opts) { return this.parseValue(value, opts); } diff --git a/src/style_manager/model/PropertyComposite.js b/src/style_manager/model/PropertyComposite.js index f69eaf8e0..eebcf770b 100644 --- a/src/style_manager/model/PropertyComposite.js +++ b/src/style_manager/model/PropertyComposite.js @@ -43,6 +43,7 @@ export default class PropertyComposite extends Property { join: null, fromStyle: null, toStyle: null, + full: true, }; } @@ -354,6 +355,10 @@ export default class PropertyComposite extends Property { return this.get('properties').getFullValue(); } + + __canClearProp(prop) { + return this.isDetached() && prop.hasValue({ noParent: true }); + } } /** * [Property]: property.html