8
0

padding.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /**
  2. * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  4. */
  5. /**
  6. * @module engine/view/styles/padding
  7. */
  8. import { getPositionShorthandNormalizer, getBoxSidesValueReducer } from './utils';
  9. /**
  10. * Adds a margin CSS styles processing rules.
  11. *
  12. * editor.editing.view.document.addStyleProcessorRules( addPaddingRules );
  13. *
  14. * The normalized value is stored as:
  15. *
  16. * const styles = {
  17. * padding: {
  18. * top,
  19. * right,
  20. * bottom,
  21. * left
  22. * }
  23. * };
  24. *
  25. * @param {module:engine/view/stylesmap~StylesProcessor} stylesProcessor
  26. */
  27. export function addPaddingRules( stylesProcessor ) {
  28. stylesProcessor.setNormalizer( 'padding', getPositionShorthandNormalizer( 'padding' ) );
  29. stylesProcessor.setNormalizer( 'padding-top', value => ( { path: 'padding.top', value } ) );
  30. stylesProcessor.setNormalizer( 'padding-right', value => ( { path: 'padding.right', value } ) );
  31. stylesProcessor.setNormalizer( 'padding-bottom', value => ( { path: 'padding.bottom', value } ) );
  32. stylesProcessor.setNormalizer( 'padding-left', value => ( { path: 'padding.left', value } ) );
  33. stylesProcessor.setReducer( 'padding', getBoxSidesValueReducer( 'padding' ) );
  34. stylesProcessor.setStyleRelation( 'padding', [ 'padding-top', 'padding-right', 'padding-bottom', 'padding-left' ] );
  35. }