Browse Source

Update Style manager API

up-style-manager
Artur Arseniev 4 years ago
parent
commit
5b158b7371
  1. 2
      src/commands/view/OpenStyleManager.js
  2. 24
      src/style_manager/index.js
  3. 2
      src/style_manager/model/Sectors.js
  4. 2
      src/style_manager/view/SectorsView.js

2
src/commands/view/OpenStyleManager.js

@ -66,7 +66,7 @@ export default {
const { sender, sm } = this;
if ((sender && sender.get && !sender.get('active')) || !sm) return;
if (sm.getLastSelected()) {
if (sm.getSelected()) {
this.$cn2?.show();
this.$header?.hide();
} else {

24
src/style_manager/index.js

@ -38,7 +38,7 @@
* * [removeProperty](#removeproperty)
* * [select](#select)
* * [getSelected](#getselected)
* * [getLastSelected](#getlastselected)
* * [getSelectedAll](#getselectedall)
* * [getSelectedParents](#getselectedparents)
* * [addStyleTargets](#addstyletargets)
* * [getBuiltIn](#getbuiltin)
@ -136,7 +136,7 @@ export default () => {
model.listenTo(em, evLayerSelect, trgCustom);
// Other listeners
model.on('change:lastTarget', () => em.trigger(evTarget, this.getLastSelected()));
model.on('change:lastTarget', () => em.trigger(evTarget, this.getSelected()));
return this;
},
@ -346,20 +346,20 @@ export default () => {
},
/**
* Get the array of selected targets.
* @returns {Array<[Component]|[CSSRule]>}
* Get the last selected target.
* By default, the Style Manager shows styles of the last selected target.
* @returns {[Component]|[CSSRule]|null}
*/
getSelected() {
return this.model.get('targets');
return this.model.get('lastTarget') || null;
},
/**
* Get the last selected target.
* By default, the Style Manager shows styles of the last selected target.
* @returns {[Component]|[CSSRule]|null}
* Get the array of selected targets.
* @returns {Array<[Component]|[CSSRule]>}
*/
getLastSelected() {
return this.model.get('lastTarget') || null;
getSelectedAll() {
return this.model.get('targets');
},
/**
@ -378,7 +378,7 @@ export default () => {
* styleManager.addStyleTargets({ color: 'red' });
*/
addStyleTargets(style, opts) {
this.getSelected().map(t => t.addStyle(style, opts));
this.getSelectedAll().map(t => t.addStyle(style, opts));
},
/**
@ -624,7 +624,7 @@ export default () => {
},
__upProps(opts) {
const lastTarget = this.getLastSelected();
const lastTarget = this.getSelected();
// if (!lastTarget || !this.getConfig().custom) return;
if (!lastTarget) return;

2
src/style_manager/model/Sectors.js

@ -22,7 +22,7 @@ export default class Sectors extends Collection {
__targetUpdated() {
const component = this.em.getSelected();
const target = this.module.getLastSelected();
const target = this.module.getSelected();
const params = { target, component, sectors: this };
this.forEach(sector => {

2
src/style_manager/view/SectorsView.js

@ -65,7 +65,7 @@ export default Backbone.View.extend({
const cmp = em.getSelected();
const cmps = em.getSelectedAll();
const mdToClear = trg && !!trg.toHTML ? trg : cmp;
const target = sm.getLastSelected();
const target = sm.getSelected();
// Clean components
mdToClear && this.toggleStateCls([mdToClear]);

Loading…
Cancel
Save