|
|
|
@ -10,6 +10,7 @@ |
|
|
|
* * [addType](#addtype) |
|
|
|
* * [getType](#gettype) |
|
|
|
* * [getTypes](#gettypes) |
|
|
|
* * [createType](#createtype) |
|
|
|
* * [render](#render) |
|
|
|
* |
|
|
|
* With Style Manager you basically build categories (called sectors) of CSS properties which could |
|
|
|
@ -69,6 +70,7 @@ module.exports = () => { |
|
|
|
*/ |
|
|
|
name: 'StyleManager', |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Get configuration object |
|
|
|
* @return {Object} |
|
|
|
@ -78,6 +80,7 @@ module.exports = () => { |
|
|
|
return c; |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Initialize module. Automatically called with a new instance of the editor |
|
|
|
* @param {Object} config Configurations |
|
|
|
@ -103,6 +106,7 @@ module.exports = () => { |
|
|
|
return this; |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Add new sector to the collection. If the sector with the same id already exists, |
|
|
|
* that one will be returned |
|
|
|
@ -128,6 +132,7 @@ module.exports = () => { |
|
|
|
return result; |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Get sector by id |
|
|
|
* @param {string} id Sector id |
|
|
|
@ -140,6 +145,7 @@ module.exports = () => { |
|
|
|
return res.length ? res[0] : null; |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Get all sectors |
|
|
|
* @return {Sectors} Collection of sectors |
|
|
|
@ -148,6 +154,7 @@ module.exports = () => { |
|
|
|
return sectors; |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Add property to the sector identified by id |
|
|
|
* @param {string} sectorId Sector id |
|
|
|
@ -193,6 +200,7 @@ module.exports = () => { |
|
|
|
return prop; |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Get property by its CSS name and sector id |
|
|
|
* @param {string} sectorId Sector id |
|
|
|
@ -213,6 +221,7 @@ module.exports = () => { |
|
|
|
return prop; |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Get properties of the sector |
|
|
|
* @param {string} sectorId Sector id |
|
|
|
@ -230,6 +239,7 @@ module.exports = () => { |
|
|
|
return props; |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Get what to style inside Style Manager. If you select the component |
|
|
|
* without classes the entity is the Component itself and all changes will |
|
|
|
@ -258,6 +268,7 @@ module.exports = () => { |
|
|
|
return model; |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Add new property type |
|
|
|
* @param {string} id Type ID |
|
|
|
@ -279,6 +290,7 @@ module.exports = () => { |
|
|
|
properties.addType(id, definition); |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Get type |
|
|
|
* @param {string} id Type ID |
|
|
|
@ -288,6 +300,7 @@ module.exports = () => { |
|
|
|
return properties.getType(id); |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Get all types |
|
|
|
* @return {Array} |
|
|
|
@ -296,6 +309,35 @@ module.exports = () => { |
|
|
|
return properties.getTypes(); |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Create new property from type |
|
|
|
* @param {string} id Type ID |
|
|
|
* @param {Object} [options={}] Options |
|
|
|
* @param {Object} [options.model={}] Custom model object |
|
|
|
* @param {Object} [options.view={}] Custom view object |
|
|
|
* @return {PropertyView} |
|
|
|
* @example |
|
|
|
* const propView = styleManager.createType('integer', { |
|
|
|
* model: {units: ['px', 'rem']} |
|
|
|
* }); |
|
|
|
* propView.render(); |
|
|
|
* propView.model.on('change:value', ...); |
|
|
|
* someContainer.appendChild(propView.el); |
|
|
|
*/ |
|
|
|
createType(id, {model = {}, view = {}} = {}) { |
|
|
|
const type = this.getType(id); |
|
|
|
|
|
|
|
if (type) { |
|
|
|
return new type.view({ |
|
|
|
model: new type.model(model), |
|
|
|
config: c, |
|
|
|
...view |
|
|
|
}); |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Render sectors and properties |
|
|
|
* @return {HTMLElement} |
|
|
|
|