diff --git a/src/editor/index.js b/src/editor/index.js index 91c9270d2..9b246eb3e 100644 --- a/src/editor/index.js +++ b/src/editor/index.js @@ -210,8 +210,8 @@ export default (config = {}) => { /** * Returns HTML built inside canvas * @param {Object} [opts={}] Options - * @param {Boolean} [opts.cleanId=false] Remove unnecessary IDs (eg. those created automatically) * @param {Component} [opts.component] Return the HTML of a specific Component + * @param {Boolean} [opts.cleanId=false] Remove unnecessary IDs (eg. those created automatically) * @returns {string} HTML string */ getHtml(opts) { @@ -221,8 +221,10 @@ export default (config = {}) => { /** * Returns CSS built inside canvas * @param {Object} [opts={}] Options + * @param {Component} [opts.component] Return the CSS of a specific Component + * @param {Boolean} [opts.json=false] Return an array of CssRules instead of the CSS string * @param {Boolean} [opts.avoidProtected=false] Don't include protected CSS - * @returns {string} CSS string + * @returns {String|Array} CSS string or array of CssRules */ getCss(opts) { return em.getCss(opts); @@ -231,8 +233,8 @@ export default (config = {}) => { /** * Returns JS of all components * @param {Object} [opts={}] Options - * @param {Component} [opts.component] Get the JS of a particular component - * @returns {string} JS string + * @param {Component} [opts.component] Get the JS of a specific component + * @returns {String} JS string */ getJs(opts) { return em.getJs(opts); diff --git a/src/editor/model/Editor.js b/src/editor/model/Editor.js index b67d66003..4b15385e6 100644 --- a/src/editor/model/Editor.js +++ b/src/editor/model/Editor.js @@ -561,16 +561,16 @@ export default Backbone.Model.extend({ const cssc = this.get('CssComposer'); const wrp = opts.component || this.get('DomComponents').getComponent(); const protCss = !avoidProt ? config.protectedCss : ''; - - return wrp - ? protCss + - this.get('CodeManager').getCode(wrp, 'css', { - cssc, - wrapperIsBody, - keepUnusedStyles, - ...optsCss - }) - : ''; + const css = + wrp && + this.get('CodeManager').getCode(wrp, 'css', { + cssc, + wrapperIsBody, + keepUnusedStyles, + ...optsCss, + ...opts + }); + return wrp ? (opts.json ? css : protCss + css) : ''; }, /**