Browse Source

Pass editor in custom CSS parser

pull/1446/head
Artur Arseniev 8 years ago
parent
commit
6bcb55baf2
  1. 2
      src/editor/index.js
  2. 5
      src/parser/model/ParserCss.js

2
src/editor/index.js

@ -599,7 +599,7 @@ module.exports = config => {
/**
* Trigger event log message
* @param {String} msg String to log
* @param {*} msg Message to log
* @param {Object} [opts={}] Custom options
* @param {String} [opts.ns=''] Namespace of the log (eg. to use in plugins)
* @param {String} [opts.level='debug'] Level of the log, `debug`, `info`, `warning`, `error`

5
src/parser/model/ParserCss.js

@ -12,8 +12,9 @@ module.exports = (config = {}) => ({
*/
parse(str) {
let result = [];
const customParser = config.parserCss;
const nodes = customParser ? customParser(str) : BrowserCssParser(str);
const { parserCss, em = {} } = config;
const editor = em && em.get('Editor');
const nodes = parserCss ? parserCss(str, editor) : BrowserCssParser(str);
nodes.forEach(node => (result = result.concat(this.checkNode(node))));
return result;

Loading…
Cancel
Save