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
* @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<CssRule>} 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);

20
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) : '';
},
/**

Loading…
Cancel
Save