@ckeditor/ckeditor5-paste-from-office-enhanced 39.0.1 → 40.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -1
- package/LICENSE.md +4 -4
- package/README.md +7 -7
- package/build/paste-from-office-enhanced.js +1 -1
- package/ckeditor5-metadata.json +1 -1
- package/package.json +3 -7
- package/src/augmentation.d.ts +10 -10
- package/src/index.d.ts +9 -9
- package/src/normalizers/inliner/msofficestylesinliner.d.ts +42 -42
- package/src/normalizers/inliner/msofficestylesinliner.js +1 -1
- package/src/normalizers/inliner/utils.d.ts +128 -128
- package/src/normalizers/inliner/utils.js +1 -1
- package/src/normalizers/propagator/msofficeinlinestylepropagator.d.ts +43 -43
- package/src/normalizers/propagator/msofficeinlinestylepropagator.js +1 -1
- package/src/normalizers/propagator/utils.d.ts +97 -97
- package/src/normalizers/propagator/utils.js +1 -1
- package/src/pastefromofficeenhanced.d.ts +29 -29
- package/src/pastefromofficeenhanced.js +1 -1
- package/src/pastefromofficeenhancedinliner.d.ts +29 -29
- package/src/pastefromofficeenhancedinliner.js +1 -1
- package/src/pastefromofficeenhancedpropagator.d.ts +36 -36
- package/src/pastefromofficeenhancedpropagator.js +1 -1
- package/src/utils.d.ts +11 -11
- package/src/utils.js +1 -1
|
@@ -1,128 +1,128 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module paste-from-office-enhanced/normalizers/msofficestylesinliner/utils
|
|
7
|
-
*/
|
|
8
|
-
import { type ViewElement } from 'ckeditor5/src/engine';
|
|
9
|
-
type StyleSelector = string;
|
|
10
|
-
type CSSStyleDefinitions = Record<string, string>;
|
|
11
|
-
type ExtractedStyles = Record<StyleSelector, CSSStyleDefinitions>;
|
|
12
|
-
type ExpandedStyles = Map<ParsedCSSSelector, CSSStyleDefinitions>;
|
|
13
|
-
type ParsedCSSSelector = {
|
|
14
|
-
tagName?: StyleSelector;
|
|
15
|
-
className?: StyleSelector;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Returns style definitions that match given element.
|
|
19
|
-
*
|
|
20
|
-
* @param element
|
|
21
|
-
* @param expandedStyles
|
|
22
|
-
* @returns
|
|
23
|
-
*/
|
|
24
|
-
export declare function getMatchingStyles(element: ViewElement, expandedStyles: ExpandedStyles): ExpandedStyles;
|
|
25
|
-
/**
|
|
26
|
-
* Converts CSSStyleSheets into a simple object format:
|
|
27
|
-
*
|
|
28
|
-
* ```js
|
|
29
|
-
* {
|
|
30
|
-
* 'p, p.foo': {
|
|
31
|
-
* 'font-family': 'Arial'
|
|
32
|
-
* },
|
|
33
|
-
* 'td': {
|
|
34
|
-
* 'background': 'red'
|
|
35
|
-
* },
|
|
36
|
-
* // ...
|
|
37
|
-
* }
|
|
38
|
-
* ```
|
|
39
|
-
* @param styles
|
|
40
|
-
* @returns
|
|
41
|
-
*/
|
|
42
|
-
export declare function extractStyles(styles: Array<CSSStyleSheet>): ExtractedStyles;
|
|
43
|
-
/**
|
|
44
|
-
* Expands styles object with complex selector into a map of unique parsed selectors and style definitions.
|
|
45
|
-
*
|
|
46
|
-
* ```ts
|
|
47
|
-
* const styles = {
|
|
48
|
-
* 'p, p.foo': {
|
|
49
|
-
* 'font-family': 'Arial'
|
|
50
|
-
* },
|
|
51
|
-
* 'td': {
|
|
52
|
-
* 'background': 'red'
|
|
53
|
-
* },
|
|
54
|
-
* // ...
|
|
55
|
-
* }
|
|
56
|
-
*
|
|
57
|
-
* expandStyles( styles );
|
|
58
|
-
*
|
|
59
|
-
* {
|
|
60
|
-
* { tagName: 'p' }: {
|
|
61
|
-
* 'font-family': 'Arial'
|
|
62
|
-
* },
|
|
63
|
-
* { tagName: 'p', className: 'foo }: {
|
|
64
|
-
* 'font-family': 'Arial'
|
|
65
|
-
* },
|
|
66
|
-
* { tagName: 'td' }: {
|
|
67
|
-
* 'background': 'red'
|
|
68
|
-
* },
|
|
69
|
-
* // ...
|
|
70
|
-
* }
|
|
71
|
-
* ```
|
|
72
|
-
* @param styles
|
|
73
|
-
* @returns
|
|
74
|
-
*/
|
|
75
|
-
export declare function expandStyles(styles: ExtractedStyles): ExpandedStyles;
|
|
76
|
-
/**
|
|
77
|
-
* Converts a native CSSStyleDeclaration into a simple object.
|
|
78
|
-
*
|
|
79
|
-
* ```ts
|
|
80
|
-
* {
|
|
81
|
-
* 'font-family': 'Arial'
|
|
82
|
-
* 'background': 'red',
|
|
83
|
-
* // ...
|
|
84
|
-
* }
|
|
85
|
-
* ```
|
|
86
|
-
* @param declaration
|
|
87
|
-
* @returns
|
|
88
|
-
*/
|
|
89
|
-
export declare function parseCSSStyleDeclaration(declaration: CSSStyleDeclaration): CSSStyleDefinitions;
|
|
90
|
-
/**
|
|
91
|
-
* Parses CSS selector into an array of objects with tagName and className properties.
|
|
92
|
-
*
|
|
93
|
-
* ```ts
|
|
94
|
-
* parseCSSSelector( 'p, p.foo' );
|
|
95
|
-
* ```
|
|
96
|
-
*
|
|
97
|
-
* returns:
|
|
98
|
-
*
|
|
99
|
-
* ```ts
|
|
100
|
-
* [
|
|
101
|
-
* { tagName: 'p' },
|
|
102
|
-
* { tagName: 'p', className: 'foo' }
|
|
103
|
-
* ]
|
|
104
|
-
* ```
|
|
105
|
-
* @param selector
|
|
106
|
-
* @returns
|
|
107
|
-
*/
|
|
108
|
-
export declare function parseCSSSelector(selector: string): Array<ParsedCSSSelector>;
|
|
109
|
-
/**
|
|
110
|
-
* Flattens multiple style definitions considering their order to simulate a CSS cascade.
|
|
111
|
-
*
|
|
112
|
-
* ```ts
|
|
113
|
-
* flattenStyleDefinitions( [
|
|
114
|
-
* { 'font-family': 'Arial', 'margin-top': '1px', 'font-size': '10px' },
|
|
115
|
-
* { 'font-family': 'monospace', 'margin-top': '3px' }
|
|
116
|
-
* ] );
|
|
117
|
-
* ```
|
|
118
|
-
*
|
|
119
|
-
* returns:
|
|
120
|
-
*
|
|
121
|
-
* ```ts
|
|
122
|
-
* { 'font-family': 'monospace', 'margin-top': '3px', 'font-size': '10px' }
|
|
123
|
-
* ```
|
|
124
|
-
* @param definitions
|
|
125
|
-
* @returns
|
|
126
|
-
*/
|
|
127
|
-
export declare function flattenStyleDefinitions(definitions: Array<CSSStyleDefinitions>): CSSStyleDefinitions;
|
|
128
|
-
export {};
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module paste-from-office-enhanced/normalizers/msofficestylesinliner/utils
|
|
7
|
+
*/
|
|
8
|
+
import { type ViewElement } from 'ckeditor5/src/engine';
|
|
9
|
+
type StyleSelector = string;
|
|
10
|
+
type CSSStyleDefinitions = Record<string, string>;
|
|
11
|
+
type ExtractedStyles = Record<StyleSelector, CSSStyleDefinitions>;
|
|
12
|
+
type ExpandedStyles = Map<ParsedCSSSelector, CSSStyleDefinitions>;
|
|
13
|
+
type ParsedCSSSelector = {
|
|
14
|
+
tagName?: StyleSelector;
|
|
15
|
+
className?: StyleSelector;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Returns style definitions that match given element.
|
|
19
|
+
*
|
|
20
|
+
* @param element
|
|
21
|
+
* @param expandedStyles
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
export declare function getMatchingStyles(element: ViewElement, expandedStyles: ExpandedStyles): ExpandedStyles;
|
|
25
|
+
/**
|
|
26
|
+
* Converts CSSStyleSheets into a simple object format:
|
|
27
|
+
*
|
|
28
|
+
* ```js
|
|
29
|
+
* {
|
|
30
|
+
* 'p, p.foo': {
|
|
31
|
+
* 'font-family': 'Arial'
|
|
32
|
+
* },
|
|
33
|
+
* 'td': {
|
|
34
|
+
* 'background': 'red'
|
|
35
|
+
* },
|
|
36
|
+
* // ...
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
* @param styles
|
|
40
|
+
* @returns
|
|
41
|
+
*/
|
|
42
|
+
export declare function extractStyles(styles: Array<CSSStyleSheet>): ExtractedStyles;
|
|
43
|
+
/**
|
|
44
|
+
* Expands styles object with complex selector into a map of unique parsed selectors and style definitions.
|
|
45
|
+
*
|
|
46
|
+
* ```ts
|
|
47
|
+
* const styles = {
|
|
48
|
+
* 'p, p.foo': {
|
|
49
|
+
* 'font-family': 'Arial'
|
|
50
|
+
* },
|
|
51
|
+
* 'td': {
|
|
52
|
+
* 'background': 'red'
|
|
53
|
+
* },
|
|
54
|
+
* // ...
|
|
55
|
+
* }
|
|
56
|
+
*
|
|
57
|
+
* expandStyles( styles );
|
|
58
|
+
*
|
|
59
|
+
* {
|
|
60
|
+
* { tagName: 'p' }: {
|
|
61
|
+
* 'font-family': 'Arial'
|
|
62
|
+
* },
|
|
63
|
+
* { tagName: 'p', className: 'foo }: {
|
|
64
|
+
* 'font-family': 'Arial'
|
|
65
|
+
* },
|
|
66
|
+
* { tagName: 'td' }: {
|
|
67
|
+
* 'background': 'red'
|
|
68
|
+
* },
|
|
69
|
+
* // ...
|
|
70
|
+
* }
|
|
71
|
+
* ```
|
|
72
|
+
* @param styles
|
|
73
|
+
* @returns
|
|
74
|
+
*/
|
|
75
|
+
export declare function expandStyles(styles: ExtractedStyles): ExpandedStyles;
|
|
76
|
+
/**
|
|
77
|
+
* Converts a native CSSStyleDeclaration into a simple object.
|
|
78
|
+
*
|
|
79
|
+
* ```ts
|
|
80
|
+
* {
|
|
81
|
+
* 'font-family': 'Arial'
|
|
82
|
+
* 'background': 'red',
|
|
83
|
+
* // ...
|
|
84
|
+
* }
|
|
85
|
+
* ```
|
|
86
|
+
* @param declaration
|
|
87
|
+
* @returns
|
|
88
|
+
*/
|
|
89
|
+
export declare function parseCSSStyleDeclaration(declaration: CSSStyleDeclaration): CSSStyleDefinitions;
|
|
90
|
+
/**
|
|
91
|
+
* Parses CSS selector into an array of objects with tagName and className properties.
|
|
92
|
+
*
|
|
93
|
+
* ```ts
|
|
94
|
+
* parseCSSSelector( 'p, p.foo' );
|
|
95
|
+
* ```
|
|
96
|
+
*
|
|
97
|
+
* returns:
|
|
98
|
+
*
|
|
99
|
+
* ```ts
|
|
100
|
+
* [
|
|
101
|
+
* { tagName: 'p' },
|
|
102
|
+
* { tagName: 'p', className: 'foo' }
|
|
103
|
+
* ]
|
|
104
|
+
* ```
|
|
105
|
+
* @param selector
|
|
106
|
+
* @returns
|
|
107
|
+
*/
|
|
108
|
+
export declare function parseCSSSelector(selector: string): Array<ParsedCSSSelector>;
|
|
109
|
+
/**
|
|
110
|
+
* Flattens multiple style definitions considering their order to simulate a CSS cascade.
|
|
111
|
+
*
|
|
112
|
+
* ```ts
|
|
113
|
+
* flattenStyleDefinitions( [
|
|
114
|
+
* { 'font-family': 'Arial', 'margin-top': '1px', 'font-size': '10px' },
|
|
115
|
+
* { 'font-family': 'monospace', 'margin-top': '3px' }
|
|
116
|
+
* ] );
|
|
117
|
+
* ```
|
|
118
|
+
*
|
|
119
|
+
* returns:
|
|
120
|
+
*
|
|
121
|
+
* ```ts
|
|
122
|
+
* { 'font-family': 'monospace', 'margin-top': '3px', 'font-size': '10px' }
|
|
123
|
+
* ```
|
|
124
|
+
* @param definitions
|
|
125
|
+
* @returns
|
|
126
|
+
*/
|
|
127
|
+
export declare function flattenStyleDefinitions(definitions: Array<CSSStyleDefinitions>): CSSStyleDefinitions;
|
|
128
|
+
export {};
|
|
@@ -20,4 +20,4 @@
|
|
|
20
20
|
*
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
|
-
const
|
|
23
|
+
const _0x37d6=['tagName','initial','trim','style','hasClass','set','map','selectorText','getPropertyValue','assign','className','cssRules','split','groups'];(function(_0xca0537,_0x37d6d4){const _0x3c9765=function(_0x1b880e){while(--_0x1b880e){_0xca0537['push'](_0xca0537['shift']());}};_0x3c9765(++_0x37d6d4);}(_0x37d6,0x99));const _0x3c97=function(_0xca0537,_0x37d6d4){_0xca0537=_0xca0537-0x0;let _0x3c9765=_0x37d6[_0xca0537];return _0x3c9765;};const S=/^(?<tagName>(?!\.)[\w-]+)?(\.(?<className>[\w-]+))?$/i;export function getMatchingStyles(_0x87f84c,_0x1dc993){const _0x55374e=new Map();for(const [_0x223e81,_0x3cec22]of _0x1dc993){if(!_0x223e81['tagName']&&!_0x223e81[_0x3c97('0xb')])continue;const _0x2c4318=!_0x223e81[_0x3c97('0x1')]||_0x87f84c['name']===_0x223e81[_0x3c97('0x1')],_0x3e6324=!_0x223e81[_0x3c97('0xb')]||_0x87f84c[_0x3c97('0x5')](_0x223e81[_0x3c97('0xb')]);_0x2c4318&&_0x3e6324&&_0x55374e[_0x3c97('0x6')](_0x223e81,_0x3cec22);}return _0x55374e;}export function extractStyles(_0x3d8112){const _0x33b859={};for(const _0xc8af0a of _0x3d8112)for(const _0x54b284 of _0xc8af0a[_0x3c97('0xc')])if(_0x54b284 instanceof CSSStyleRule){const _0x5f5282=parseCSSStyleDeclaration(_0x54b284[_0x3c97('0x4')]);_0x33b859[_0x54b284[_0x3c97('0x8')]]=Object[_0x3c97('0xa')]({},_0x33b859[_0x54b284['selectorText']]||{},_0x5f5282);}return _0x33b859;}export function expandStyles(_0x11fde7){const _0x297e6c=new Map();for(const _0x14d28a in _0x11fde7){const _0x1d811b=parseCSSSelector(_0x14d28a),_0x2995cb=_0x11fde7[_0x14d28a];for(const _0x1bbf69 of _0x1d811b)_0x297e6c[_0x3c97('0x6')](_0x1bbf69,_0x2995cb);}return _0x297e6c;}export function parseCSSStyleDeclaration(_0x4c969f){const _0x5c0d8d={};for(let _0x2bad52=0x0;_0x2bad52<_0x4c969f['length'];_0x2bad52++){const _0x2fa3e4=_0x4c969f[_0x2bad52],_0x49f922=_0x4c969f[_0x3c97('0x9')](_0x2fa3e4);_0x3c97('0x2')!==_0x49f922&&(_0x5c0d8d[_0x2fa3e4]=_0x49f922);}return _0x5c0d8d;}export function parseCSSSelector(_0x3d0ff6){const _0x1486cc=_0x3d0ff6[_0x3c97('0xd')](',')[_0x3c97('0x7')](_0x58e356=>_0x58e356[_0x3c97('0x3')]()),_0x347cce=[];for(const _0x1909bb of _0x1486cc){const _0x1ce066=S['exec'](_0x1909bb);_0x1ce066&&_0x347cce['push'](_0x1ce066[_0x3c97('0x0')]);}return _0x347cce;}export function flattenStyleDefinitions(_0x3bf4d1){const _0x3bbc40={};for(const _0xd04f24 of _0x3bf4d1)Object[_0x3c97('0xa')](_0x3bbc40,_0xd04f24);return _0x3bbc40;}
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
import { type NormalizerData, MSWordNormalizer } from '@ckeditor/ckeditor5-paste-from-office';
|
|
6
|
-
/**
|
|
7
|
-
* A normalizer that propagates inline styles from block element into `span` element with style properties
|
|
8
|
-
* and/or creates an `HTML` structure based on early mentioned block element styles.
|
|
9
|
-
*
|
|
10
|
-
* Normalizers are registered by the {@link module:paste-from-office-enhanced/pastefromofficeenhanced~PasteFromOfficeEnhanced}
|
|
11
|
-
* plugin and run on {@link module:clipboard/clipboardpipeline~ClipboardPipeline#event:inputTransformation inputTransformation event}.
|
|
12
|
-
* They detect environment-specific quirks and transform it into a form compatible with other CKEditor features.
|
|
13
|
-
*
|
|
14
|
-
* This particular normalizer turns a pasted content such as:
|
|
15
|
-
*
|
|
16
|
-
* ```html
|
|
17
|
-
* <p style="color:red;font-size:10px;font-weight:bold;">
|
|
18
|
-
* foo
|
|
19
|
-
* </p>
|
|
20
|
-
* ```
|
|
21
|
-
*
|
|
22
|
-
* into:
|
|
23
|
-
*
|
|
24
|
-
* ```html
|
|
25
|
-
* <p>
|
|
26
|
-
* <span style="color:red;font-size:10px">
|
|
27
|
-
* <strong>
|
|
28
|
-
* foo
|
|
29
|
-
* </strong>
|
|
30
|
-
* </span>
|
|
31
|
-
* </p>
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
|
-
export default class MSOfficeInlineStylePropagator extends MSWordNormalizer {
|
|
35
|
-
/**
|
|
36
|
-
* @inheritDoc
|
|
37
|
-
*/
|
|
38
|
-
execute(data: NormalizerData): void;
|
|
39
|
-
/**
|
|
40
|
-
* @inheritDoc
|
|
41
|
-
*/
|
|
42
|
-
isActive(htmlString: string): boolean;
|
|
43
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
import { type NormalizerData, MSWordNormalizer } from '@ckeditor/ckeditor5-paste-from-office';
|
|
6
|
+
/**
|
|
7
|
+
* A normalizer that propagates inline styles from block element into `span` element with style properties
|
|
8
|
+
* and/or creates an `HTML` structure based on early mentioned block element styles.
|
|
9
|
+
*
|
|
10
|
+
* Normalizers are registered by the {@link module:paste-from-office-enhanced/pastefromofficeenhanced~PasteFromOfficeEnhanced}
|
|
11
|
+
* plugin and run on {@link module:clipboard/clipboardpipeline~ClipboardPipeline#event:inputTransformation inputTransformation event}.
|
|
12
|
+
* They detect environment-specific quirks and transform it into a form compatible with other CKEditor features.
|
|
13
|
+
*
|
|
14
|
+
* This particular normalizer turns a pasted content such as:
|
|
15
|
+
*
|
|
16
|
+
* ```html
|
|
17
|
+
* <p style="color:red;font-size:10px;font-weight:bold;">
|
|
18
|
+
* foo
|
|
19
|
+
* </p>
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* into:
|
|
23
|
+
*
|
|
24
|
+
* ```html
|
|
25
|
+
* <p>
|
|
26
|
+
* <span style="color:red;font-size:10px">
|
|
27
|
+
* <strong>
|
|
28
|
+
* foo
|
|
29
|
+
* </strong>
|
|
30
|
+
* </span>
|
|
31
|
+
* </p>
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export default class MSOfficeInlineStylePropagator extends MSWordNormalizer {
|
|
35
|
+
/**
|
|
36
|
+
* @inheritDoc
|
|
37
|
+
*/
|
|
38
|
+
execute(data: NormalizerData): void;
|
|
39
|
+
/**
|
|
40
|
+
* @inheritDoc
|
|
41
|
+
*/
|
|
42
|
+
isActive(htmlString: string): boolean;
|
|
43
|
+
}
|
|
@@ -20,4 +20,4 @@
|
|
|
20
20
|
*
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
|
-
const
|
|
23
|
+
const _0x48b6=['document','font','execute','blockElements','getItems','element','stylesProcessor','_parsedData','createRangeIn','includes','content'];(function(_0x32440f,_0x48b686){const _0x384ff8=function(_0x57460d){while(--_0x57460d){_0x32440f['push'](_0x32440f['shift']());}};_0x384ff8(++_0x48b686);}(_0x48b6,0x137));const _0x384f=function(_0x32440f,_0x48b686){_0x32440f=_0x32440f-0x0;let _0x384ff8=_0x48b6[_0x32440f];return _0x384ff8;};import{UpcastWriter as _0x4b3ead,DomConverter as _0x4dd6eb,ViewDocument as _0x1bd4be}from'ckeditor5/src/engine';import{MSWordNormalizer as _0x66c48d}from'@ckeditor/ckeditor5-paste-from-office';import{isMSExcelContent as _0x496900}from'../../utils';import{getStylePropertyNamesToPropagate as _0x3be832,propagateStyleProperties as _0x3ae977}from'./utils';export default class l extends _0x66c48d{[_0x384f('0xa')](_0x471005){const {body:_0x4f224c}=_0x471005[_0x384f('0x4')],_0x28fb44=new _0x4b3ead(_0x4f224c[_0x384f('0x8')]),_0x2a812e=_0x28fb44[_0x384f('0x5')](_0x4f224c),_0x36ee2f=new _0x1bd4be(_0x28fb44[_0x384f('0x8')][_0x384f('0x3')]),_0x53924a=[...new _0x4dd6eb(_0x36ee2f)[_0x384f('0x0')],_0x384f('0x9')],_0x36b5d5=_0x2a812e[_0x384f('0x1')]();for(const _0x1ca304 of _0x36b5d5)if(_0x1ca304['is'](_0x384f('0x2'))&&_0x53924a[_0x384f('0x6')](_0x1ca304['name'])){const _0x23b1a5=_0x3be832(_0x1ca304);_0x3ae977(_0x1ca304,_0x28fb44,_0x23b1a5);}_0x471005[_0x384f('0x7')]=_0x4f224c;}['isActive'](_0x23be3e){return super['isActive'](_0x23be3e)||_0x496900(_0x23be3e);}}
|
|
@@ -1,97 +1,97 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module paste-from-office-enhanced/normalizers/msofficeinlinestylepropagator/utils
|
|
7
|
-
*/
|
|
8
|
-
import type { UpcastWriter, ViewElement } from 'ckeditor5/src/engine';
|
|
9
|
-
/**
|
|
10
|
-
* The list of all `CSS` properties that need to be propagated.
|
|
11
|
-
*
|
|
12
|
-
* @protected
|
|
13
|
-
*/
|
|
14
|
-
export declare const CSS_PROPERTIES_TO_PROPAGATE: readonly ["color", "font-family", "font-size", "text-decoration", "text-decoration-line", "font-weight", "font-style", "vertical-align"];
|
|
15
|
-
/**
|
|
16
|
-
* The list of `CSS` properties that needs to be propagated as an inline `<span>` element.
|
|
17
|
-
*
|
|
18
|
-
* It's a subset of `CSS_PROPERTIES_TO_PROPAGATE`.
|
|
19
|
-
*
|
|
20
|
-
* @protected
|
|
21
|
-
*/
|
|
22
|
-
export declare const CSS_PROPERTIES_TO_BE_SPANS: readonly ["color", "font-family", "font-size"];
|
|
23
|
-
export type CSSPropertyValueAssertion = (value: string) => boolean;
|
|
24
|
-
export type CSSPropertyValueToElementNameMap = readonly [string | CSSPropertyValueAssertion, string];
|
|
25
|
-
/**
|
|
26
|
-
* The map of style to element propagate as a HTML elements
|
|
27
|
-
* (e.g. `text-decoration` with the `underline` value is propagated to `<u>`,
|
|
28
|
-
* or `font-weight` with the `bold` value is propagated to `<strong>`).
|
|
29
|
-
*
|
|
30
|
-
* @protected
|
|
31
|
-
*/
|
|
32
|
-
export declare const CSS_PROPERTIES_TO_BE_HTML_ELEMENTS: {
|
|
33
|
-
[key in Exclude<typeof CSS_PROPERTIES_TO_PROPAGATE[number], typeof CSS_PROPERTIES_TO_BE_SPANS[number]>]: ReadonlyArray<CSSPropertyValueToElementNameMap>;
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Checks whether the given property should be propagated at all.
|
|
37
|
-
*
|
|
38
|
-
* @param property
|
|
39
|
-
* @returns
|
|
40
|
-
*/
|
|
41
|
-
export declare function isPropertyToBePropagated(property: string): property is typeof CSS_PROPERTIES_TO_PROPAGATE[number];
|
|
42
|
-
/**
|
|
43
|
-
* Checks whether the given property should be propagated as a span element.
|
|
44
|
-
*
|
|
45
|
-
* @param property
|
|
46
|
-
* @returns
|
|
47
|
-
*/
|
|
48
|
-
export declare function isPropertyToBePropagatedAsSpan(property: string): property is typeof CSS_PROPERTIES_TO_BE_SPANS[number];
|
|
49
|
-
/**
|
|
50
|
-
* Checks whether the given property should be propagated as an HTML element.
|
|
51
|
-
*
|
|
52
|
-
* @param property
|
|
53
|
-
* @returns
|
|
54
|
-
*/
|
|
55
|
-
export declare function isPropertyToBePropagatedAsHTMLElement(property: string): property is keyof typeof CSS_PROPERTIES_TO_BE_HTML_ELEMENTS;
|
|
56
|
-
/**
|
|
57
|
-
* Collects a list of styles to propagate from a block element.
|
|
58
|
-
*
|
|
59
|
-
* @param element The source `ViewElement`.
|
|
60
|
-
* @returns List of valid CSS properties to propagate.
|
|
61
|
-
*/
|
|
62
|
-
export declare function getStylePropertyNamesToPropagate(element: ViewElement): Array<typeof CSS_PROPERTIES_TO_PROPAGATE[number]>;
|
|
63
|
-
/**
|
|
64
|
-
* Executes styles propagation.
|
|
65
|
-
*
|
|
66
|
-
* @param element The source `ViewElement`.
|
|
67
|
-
* @param writer `UpcastWriter` instance.
|
|
68
|
-
* @param propertiesToPropagate List of valid CSS properties to propagate.
|
|
69
|
-
*/
|
|
70
|
-
export declare function propagateStyleProperties(element: ViewElement, writer: UpcastWriter, propertiesToPropagate: Array<string>): void;
|
|
71
|
-
/**
|
|
72
|
-
* Creates an `HTML` structure based on styles propagated from parent block element.
|
|
73
|
-
*
|
|
74
|
-
* @param element The source `ViewElement`.
|
|
75
|
-
* @param writer `UpcastWriter` instance.
|
|
76
|
-
* @param stylesToBeHtmlElements List of styles properties to be propagated as a HTML elements.
|
|
77
|
-
*/
|
|
78
|
-
export declare function propagateStylesAsHTMLElements(element: ViewElement, writer: UpcastWriter, stylesToBeHtmlElements: Partial<typeof CSS_PROPERTIES_TO_BE_HTML_ELEMENTS>): void;
|
|
79
|
-
/**
|
|
80
|
-
* Creates a `span` as a first child of the `element` with styles propagated from parent block element.
|
|
81
|
-
*
|
|
82
|
-
* @param element The source `ViewElement`.
|
|
83
|
-
* @param writer `UpcastWriter` instance.
|
|
84
|
-
* @param spanStyles List of styles properties to propagate.
|
|
85
|
-
*/
|
|
86
|
-
export declare function propagateStylesAsSpan(element: ViewElement, writer: UpcastWriter, spanStyles: Partial<Record<typeof CSS_PROPERTIES_TO_BE_SPANS[number], string>>): void;
|
|
87
|
-
/**
|
|
88
|
-
* Collects and filters element styles into proper objects for further propagation.
|
|
89
|
-
*
|
|
90
|
-
* @param element The source `ViewElement`.
|
|
91
|
-
* @param propertiesToPropagate The array of style properties to propagate.
|
|
92
|
-
* @returns An object with properties to propagate filtered into styles that will be propagated onto `span` and as a HTML elements.
|
|
93
|
-
*/
|
|
94
|
-
export declare function getStylesToPropagate(element: ViewElement, propertiesToPropagate: Array<string>): {
|
|
95
|
-
spanStyles: Partial<Record<typeof CSS_PROPERTIES_TO_BE_SPANS[number], string>>;
|
|
96
|
-
stylesToBeHtmlElements: Partial<typeof CSS_PROPERTIES_TO_BE_HTML_ELEMENTS>;
|
|
97
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module paste-from-office-enhanced/normalizers/msofficeinlinestylepropagator/utils
|
|
7
|
+
*/
|
|
8
|
+
import type { UpcastWriter, ViewElement } from 'ckeditor5/src/engine';
|
|
9
|
+
/**
|
|
10
|
+
* The list of all `CSS` properties that need to be propagated.
|
|
11
|
+
*
|
|
12
|
+
* @protected
|
|
13
|
+
*/
|
|
14
|
+
export declare const CSS_PROPERTIES_TO_PROPAGATE: readonly ["color", "font-family", "font-size", "text-decoration", "text-decoration-line", "font-weight", "font-style", "vertical-align"];
|
|
15
|
+
/**
|
|
16
|
+
* The list of `CSS` properties that needs to be propagated as an inline `<span>` element.
|
|
17
|
+
*
|
|
18
|
+
* It's a subset of `CSS_PROPERTIES_TO_PROPAGATE`.
|
|
19
|
+
*
|
|
20
|
+
* @protected
|
|
21
|
+
*/
|
|
22
|
+
export declare const CSS_PROPERTIES_TO_BE_SPANS: readonly ["color", "font-family", "font-size"];
|
|
23
|
+
export type CSSPropertyValueAssertion = (value: string) => boolean;
|
|
24
|
+
export type CSSPropertyValueToElementNameMap = readonly [string | CSSPropertyValueAssertion, string];
|
|
25
|
+
/**
|
|
26
|
+
* The map of style to element propagate as a HTML elements
|
|
27
|
+
* (e.g. `text-decoration` with the `underline` value is propagated to `<u>`,
|
|
28
|
+
* or `font-weight` with the `bold` value is propagated to `<strong>`).
|
|
29
|
+
*
|
|
30
|
+
* @protected
|
|
31
|
+
*/
|
|
32
|
+
export declare const CSS_PROPERTIES_TO_BE_HTML_ELEMENTS: {
|
|
33
|
+
[key in Exclude<typeof CSS_PROPERTIES_TO_PROPAGATE[number], typeof CSS_PROPERTIES_TO_BE_SPANS[number]>]: ReadonlyArray<CSSPropertyValueToElementNameMap>;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Checks whether the given property should be propagated at all.
|
|
37
|
+
*
|
|
38
|
+
* @param property
|
|
39
|
+
* @returns
|
|
40
|
+
*/
|
|
41
|
+
export declare function isPropertyToBePropagated(property: string): property is typeof CSS_PROPERTIES_TO_PROPAGATE[number];
|
|
42
|
+
/**
|
|
43
|
+
* Checks whether the given property should be propagated as a span element.
|
|
44
|
+
*
|
|
45
|
+
* @param property
|
|
46
|
+
* @returns
|
|
47
|
+
*/
|
|
48
|
+
export declare function isPropertyToBePropagatedAsSpan(property: string): property is typeof CSS_PROPERTIES_TO_BE_SPANS[number];
|
|
49
|
+
/**
|
|
50
|
+
* Checks whether the given property should be propagated as an HTML element.
|
|
51
|
+
*
|
|
52
|
+
* @param property
|
|
53
|
+
* @returns
|
|
54
|
+
*/
|
|
55
|
+
export declare function isPropertyToBePropagatedAsHTMLElement(property: string): property is keyof typeof CSS_PROPERTIES_TO_BE_HTML_ELEMENTS;
|
|
56
|
+
/**
|
|
57
|
+
* Collects a list of styles to propagate from a block element.
|
|
58
|
+
*
|
|
59
|
+
* @param element The source `ViewElement`.
|
|
60
|
+
* @returns List of valid CSS properties to propagate.
|
|
61
|
+
*/
|
|
62
|
+
export declare function getStylePropertyNamesToPropagate(element: ViewElement): Array<typeof CSS_PROPERTIES_TO_PROPAGATE[number]>;
|
|
63
|
+
/**
|
|
64
|
+
* Executes styles propagation.
|
|
65
|
+
*
|
|
66
|
+
* @param element The source `ViewElement`.
|
|
67
|
+
* @param writer `UpcastWriter` instance.
|
|
68
|
+
* @param propertiesToPropagate List of valid CSS properties to propagate.
|
|
69
|
+
*/
|
|
70
|
+
export declare function propagateStyleProperties(element: ViewElement, writer: UpcastWriter, propertiesToPropagate: Array<string>): void;
|
|
71
|
+
/**
|
|
72
|
+
* Creates an `HTML` structure based on styles propagated from parent block element.
|
|
73
|
+
*
|
|
74
|
+
* @param element The source `ViewElement`.
|
|
75
|
+
* @param writer `UpcastWriter` instance.
|
|
76
|
+
* @param stylesToBeHtmlElements List of styles properties to be propagated as a HTML elements.
|
|
77
|
+
*/
|
|
78
|
+
export declare function propagateStylesAsHTMLElements(element: ViewElement, writer: UpcastWriter, stylesToBeHtmlElements: Partial<typeof CSS_PROPERTIES_TO_BE_HTML_ELEMENTS>): void;
|
|
79
|
+
/**
|
|
80
|
+
* Creates a `span` as a first child of the `element` with styles propagated from parent block element.
|
|
81
|
+
*
|
|
82
|
+
* @param element The source `ViewElement`.
|
|
83
|
+
* @param writer `UpcastWriter` instance.
|
|
84
|
+
* @param spanStyles List of styles properties to propagate.
|
|
85
|
+
*/
|
|
86
|
+
export declare function propagateStylesAsSpan(element: ViewElement, writer: UpcastWriter, spanStyles: Partial<Record<typeof CSS_PROPERTIES_TO_BE_SPANS[number], string>>): void;
|
|
87
|
+
/**
|
|
88
|
+
* Collects and filters element styles into proper objects for further propagation.
|
|
89
|
+
*
|
|
90
|
+
* @param element The source `ViewElement`.
|
|
91
|
+
* @param propertiesToPropagate The array of style properties to propagate.
|
|
92
|
+
* @returns An object with properties to propagate filtered into styles that will be propagated onto `span` and as a HTML elements.
|
|
93
|
+
*/
|
|
94
|
+
export declare function getStylesToPropagate(element: ViewElement, propertiesToPropagate: Array<string>): {
|
|
95
|
+
spanStyles: Partial<Record<typeof CSS_PROPERTIES_TO_BE_SPANS[number], string>>;
|
|
96
|
+
stylesToBeHtmlElements: Partial<typeof CSS_PROPERTIES_TO_BE_HTML_ELEMENTS>;
|
|
97
|
+
};
|
|
@@ -20,4 +20,4 @@
|
|
|
20
20
|
*
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
|
-
const
|
|
23
|
+
const _0x2608=['font-family','span','function','strong','bold','underline','sub','text-decoration-line','setStyle','getStyle','color','keys','createElement','forEach','bolder','font-style','line-through','removeStyle','getChildren','sup','vertical-align','font-size','from','insertChild','includes','split','length','italic','filter'];(function(_0x9f67cd,_0x2608fc){const _0x43b7d1=function(_0x5ca5c4){while(--_0x5ca5c4){_0x9f67cd['push'](_0x9f67cd['shift']());}};_0x43b7d1(++_0x2608fc);}(_0x2608,0x8d));const _0x43b7=function(_0x9f67cd,_0x2608fc){_0x9f67cd=_0x9f67cd-0x0;let _0x43b7d1=_0x2608[_0x9f67cd];return _0x43b7d1;};export const CSS_PROPERTIES_TO_PROPAGATE=[_0x43b7('0xe'),_0x43b7('0x4'),'font-size','text-decoration',_0x43b7('0xb'),'font-weight',_0x43b7('0x13'),_0x43b7('0x18')];export const CSS_PROPERTIES_TO_BE_SPANS=[_0x43b7('0xe'),_0x43b7('0x4'),_0x43b7('0x19')];export const CSS_PROPERTIES_TO_BE_HTML_ELEMENTS={'font-style':[[_0x43b7('0x2'),'i']],'font-weight':[['medium',_0x43b7('0x7')],[_0x43b7('0x8'),_0x43b7('0x7')],[_0x43b7('0x12'),_0x43b7('0x7')],[_0x105e64=>Number(_0x105e64)>=0x258,_0x43b7('0x7')]],'text-decoration':[[_0x43b7('0x9'),'u'],[_0x43b7('0x14'),'s']],'text-decoration-line':[[_0x43b7('0x9'),'u'],[_0x43b7('0x14'),'s']],'vertical-align':[[_0x43b7('0xa'),'sub'],['super',_0x43b7('0x17')]]};export function isPropertyToBePropagated(_0x16bbc2){return CSS_PROPERTIES_TO_PROPAGATE[_0x43b7('0x1c')](_0x16bbc2);}export function isPropertyToBePropagatedAsSpan(_0x4280cb){return CSS_PROPERTIES_TO_BE_SPANS[_0x43b7('0x1c')](_0x4280cb);}export function isPropertyToBePropagatedAsHTMLElement(_0x52c35f){return _0x52c35f in CSS_PROPERTIES_TO_BE_HTML_ELEMENTS;}export function getStylePropertyNamesToPropagate(_0x4ac767){return Array[_0x43b7('0x1a')](_0x4ac767['getStyleNames']())[_0x43b7('0x3')](isPropertyToBePropagated);}export function propagateStyleProperties(_0x122841,_0x3e1af2,_0xcdebc3){const {spanStyles:_0x25900c,stylesToBeHtmlElements:_0x420924}=getStylesToPropagate(_0x122841,_0xcdebc3);propagateStylesAsHTMLElements(_0x122841,_0x3e1af2,_0x420924),propagateStylesAsSpan(_0x122841,_0x3e1af2,_0x25900c);}export function propagateStylesAsHTMLElements(_0x1a8881,_0x2c1992,_0x1b2896){for(const _0x503fcc in _0x1b2896){_0x1b2896[_0x503fcc][_0x43b7('0x11')](([,_0x4e4030])=>{const _0x5ce6dd=_0x2c1992[_0x43b7('0x10')](_0x4e4030,[],_0x1a8881['getChildren']());_0x2c1992[_0x43b7('0x1b')](0x0,_0x5ce6dd,_0x1a8881);}),_0x2c1992['removeStyle'](_0x503fcc,_0x1a8881);}}export function propagateStylesAsSpan(_0x234d0a,_0x5bdb7c,_0x32e83d){if(!Object[_0x43b7('0xf')](_0x32e83d)[_0x43b7('0x1')])return;const _0x2ad850=_0x5bdb7c['createElement'](_0x43b7('0x5'),[],_0x234d0a[_0x43b7('0x16')]());_0x5bdb7c[_0x43b7('0xc')](_0x32e83d,_0x2ad850),_0x5bdb7c[_0x43b7('0x1b')](0x0,_0x2ad850,_0x234d0a),_0x5bdb7c[_0x43b7('0x15')](Object['keys'](_0x32e83d),_0x234d0a);}export function getStylesToPropagate(_0x2ccf65,_0x56df31){const _0x2f8565={},_0x272e3b={};return _0x56df31[_0x43b7('0x11')](_0x46dab8=>{const _0x17f0a4=_0x2ccf65[_0x43b7('0xd')](_0x46dab8);if(_0x17f0a4){if(isPropertyToBePropagatedAsSpan(_0x46dab8))_0x2f8565[_0x46dab8]=_0x17f0a4;else{if(isPropertyToBePropagatedAsHTMLElement(_0x46dab8)){const _0x59db20=_0x17f0a4[_0x43b7('0x0')]('\x20');CSS_PROPERTIES_TO_BE_HTML_ELEMENTS[_0x46dab8][_0x43b7('0x11')](([_0x1103be,_0x11b4dc])=>{for(const _0x3d4c9a of _0x59db20){(_0x43b7('0x6')==typeof _0x1103be&&_0x1103be(_0x3d4c9a)||_0x1103be===_0x3d4c9a)&&(_0x272e3b[_0x46dab8]=[..._0x272e3b[_0x46dab8]||[],[_0x1103be,_0x11b4dc]]);}});}}}}),{'spanStyles':_0x2f8565,'stylesToBeHtmlElements':_0x272e3b};}
|