Browse Source

Add new methods for builtin props

up-style-manager
Artur Arseniev 5 years ago
parent
commit
27543c924d
  1. 31
      src/style_manager/index.js
  2. 1
      src/style_manager/model/PropertyFactory.js

31
src/style_manager/index.js

@ -577,16 +577,37 @@ export default () => {
/** /**
* Return built-in property definition * Return built-in property definition
* @param {String} prop * @param {String} prop Property name.
* @returns {Object} Property definition * @returns {Object|null} Property definition.
*/ */
getBuiltIn(prop = '') { getBuiltIn(prop) {
return this.builtIn.get(prop); return this.builtIn.get(prop);
}, },
getBuiltInAll() {}, /**
* Get all the available built-in property definitions.
* @returns {Object}
*/
getBuiltInAll() {
return this.builtIn.props;
},
addBuiltIn(prop, def = {}) {}, /**
* Add built-in property definition.
* If the property exists already, it will extend it.
* @param {String} prop Property name.
* @param {Object} definition Property definition.
* @returns {Object} Added property definition.
* @example
* const sector = styleManager.addBuiltIn('new-property', {
* type: 'select',
* default: 'value1',
* options: [{ id: 'value1', label: 'Some label' }, ...],
* })
*/
addBuiltIn(prop, definition) {
return this.builtIn.add(prop, definition);
},
__upProp(prop, style, parentStyles, opts) { __upProp(prop, style, parentStyles, opts) {
const name = prop.getName(); const name = prop.getName();

1
src/style_manager/model/PropertyFactory.js

@ -390,6 +390,7 @@ export default class PropertyFactory {
result.properties = result.properties(); result.properties = result.properties();
} }
this.props[property] = result; this.props[property] = result;
return result;
} }
get(prop) { get(prop) {

Loading…
Cancel
Save