list-content-styles.js 854 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/usr/bin/env node
  2. /**
  3. * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
  4. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  5. */
  6. /* eslint-env node */
  7. const postcss = require( 'postcss' );
  8. module.exports = postcss.plugin( 'list-content-styles', function( options ) {
  9. const selectorStyles = options.contentRules.selector;
  10. const variables = options.contentRules.variables;
  11. return root => {
  12. root.walkRules( rule => {
  13. rule.selectors.forEach( selector => {
  14. if ( selector.match( ':root' ) ) {
  15. variables.push( {
  16. file: root.source.input.file,
  17. css: rule.toString()
  18. } );
  19. }
  20. if ( selector.match( '.ck-content' ) ) {
  21. selectorStyles.push( {
  22. file: root.source.input.file,
  23. css: rule.toString()
  24. } );
  25. }
  26. } );
  27. } );
  28. };
  29. } );