From 85cc802e3db460f92181ab1467c3111623e28c1a Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Sat, 11 Nov 2017 22:25:15 +0100 Subject: [PATCH] Move `getCurrentMedia` in Editor --- src/css_composer/index.js | 10 +--------- src/editor/model/Editor.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 9 deletions(-) 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