diff --git a/src/css_composer/index.js b/src/css_composer/index.js index 02b4700e9..9ce542156 100644 --- a/src/css_composer/index.js +++ b/src/css_composer/index.js @@ -282,7 +282,7 @@ module.exports = () => { */ setIdStyle(name, style = {}, opts = {}) { const state = opts.state || ''; - const media = opts.mediaText || this._getCurrentMedia(); + const media = opts.mediaText || em.getCurrentMedia(); const sm = em.get('SelectorManager'); const selector = sm.add({ name, type: Selector.TYPE_ID }); const rule = this.add(selector, state, media); @@ -300,13 +300,5 @@ module.exports = () => { return rulesView.render().el; }, - - _getCurrentMedia() { - const config = em.get('Config'); - const device = em.getDeviceModel(); - const condition = config.mediaCondition; - const width = device && device.get('widthMedia'); - return device && width ? `(${condition}: ${width})` : ''; - }, }; }; diff --git a/src/editor/model/Editor.js b/src/editor/model/Editor.js index 7981ebfc4..971423956 100644 --- a/src/editor/model/Editor.js +++ b/src/editor/model/Editor.js @@ -614,6 +614,20 @@ module.exports = Backbone.Model.extend({ w.getSelection().removeAllRanges(); }, + + /** + * Get current media text + * @return {string} + */ + getCurrentMedia() { + const config = this.config; + const device = this.getDeviceModel(); + const condition = config.mediaCondition; + const width = device && device.get('widthMedia'); + return device && width ? `(${condition}: ${width})` : ''; + }, + + /** * Set/get data from the HTMLElement * @param {HTMLElement} el