Browse Source

Adjust editor.getCss for json option

pull/3692/head
Artur Arseniev 5 years ago
parent
commit
3fd2afd4ca
  1. 10
      src/editor/index.js
  2. 20
      src/editor/model/Editor.js

10
src/editor/index.js

@ -210,8 +210,8 @@ export default (config = {}) => {
/** /**
* Returns HTML built inside canvas * Returns HTML built inside canvas
* @param {Object} [opts={}] Options * @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 {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 * @returns {string} HTML string
*/ */
getHtml(opts) { getHtml(opts) {
@ -221,8 +221,10 @@ export default (config = {}) => {
/** /**
* Returns CSS built inside canvas * Returns CSS built inside canvas
* @param {Object} [opts={}] Options * @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 * @param {Boolean} [opts.avoidProtected=false] Don't include protected CSS
* @returns {string} CSS string * @returns {String|Array<CssRule>} CSS string or array of CssRules
*/ */
getCss(opts) { getCss(opts) {
return em.getCss(opts); return em.getCss(opts);
@ -231,8 +233,8 @@ export default (config = {}) => {
/** /**
* Returns JS of all components * Returns JS of all components
* @param {Object} [opts={}] Options * @param {Object} [opts={}] Options
* @param {Component} [opts.component] Get the JS of a particular component * @param {Component} [opts.component] Get the JS of a specific component
* @returns {string} JS string * @returns {String} JS string
*/ */
getJs(opts) { getJs(opts) {
return em.getJs(opts); return em.getJs(opts);

20
src/editor/model/Editor.js

@ -561,16 +561,16 @@ export default Backbone.Model.extend({
const cssc = this.get('CssComposer'); const cssc = this.get('CssComposer');
const wrp = opts.component || this.get('DomComponents').getComponent(); const wrp = opts.component || this.get('DomComponents').getComponent();
const protCss = !avoidProt ? config.protectedCss : ''; const protCss = !avoidProt ? config.protectedCss : '';
const css =
return wrp wrp &&
? protCss + this.get('CodeManager').getCode(wrp, 'css', {
this.get('CodeManager').getCode(wrp, 'css', { cssc,
cssc, wrapperIsBody,
wrapperIsBody, keepUnusedStyles,
keepUnusedStyles, ...optsCss,
...optsCss ...opts
}) });
: ''; return wrp ? (opts.json ? css : protCss + css) : '';
}, },
/** /**

Loading…
Cancel
Save