-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
padding.ts
43 lines (38 loc) · 1.38 KB
/
padding.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
/**
* @module engine/view/styles/padding
*/
import type { StylesProcessor } from '../stylesmap.js';
import { getPositionShorthandNormalizer, getBoxSidesValueReducer } from './utils.js';
/**
* Adds a padding CSS styles processing rules.
*
* ```ts
* editor.data.addStyleProcessorRules( addPaddingRules );
* ```
*
* The normalized value is stored as:
*
* ```ts
* const styles = {
* padding: {
* top,
* right,
* bottom,
* left
* }
* };
* ```
*/
export function addPaddingRules( stylesProcessor: StylesProcessor ): void {
stylesProcessor.setNormalizer( 'padding', getPositionShorthandNormalizer( 'padding' ) );
stylesProcessor.setNormalizer( 'padding-top', value => ( { path: 'padding.top', value } ) );
stylesProcessor.setNormalizer( 'padding-right', value => ( { path: 'padding.right', value } ) );
stylesProcessor.setNormalizer( 'padding-bottom', value => ( { path: 'padding.bottom', value } ) );
stylesProcessor.setNormalizer( 'padding-left', value => ( { path: 'padding.left', value } ) );
stylesProcessor.setReducer( 'padding', getBoxSidesValueReducer( 'padding' ) );
stylesProcessor.setStyleRelation( 'padding', [ 'padding-top', 'padding-right', 'padding-bottom', 'padding-left' ] );
}