@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.
@@ -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 _0x3e55=['split','tagName','set','selectorText','className','map','push','length','groups','style','exec','trim','initial','name','getPropertyValue','hasClass','cssRules','assign'];(function(_0x3ab9fe,_0x3e55fe){const _0x16e569=function(_0x46bdc6){while(--_0x46bdc6){_0x3ab9fe['push'](_0x3ab9fe['shift']());}};_0x16e569(++_0x3e55fe);}(_0x3e55,0x15a));const _0x16e5=function(_0x3ab9fe,_0x3e55fe){_0x3ab9fe=_0x3ab9fe-0x0;let _0x16e569=_0x3e55[_0x3ab9fe];return _0x16e569;};const S=/^(?<tagName>(?!\.)[\w-]+)?(\.(?<className>[\w-]+))?$/i;export function getMatchingStyles(_0x469f88,_0x7d5fd4){const _0x116d41=new Map();for(const [_0x58b5da,_0x2d1408]of _0x7d5fd4){if(!_0x58b5da[_0x16e5('0xf')]&&!_0x58b5da[_0x16e5('0x0')])continue;const _0x5c26a0=!_0x58b5da[_0x16e5('0xf')]||_0x469f88[_0x16e5('0x9')]===_0x58b5da['tagName'],_0x1451c8=!_0x58b5da[_0x16e5('0x0')]||_0x469f88[_0x16e5('0xb')](_0x58b5da[_0x16e5('0x0')]);_0x5c26a0&&_0x1451c8&&_0x116d41[_0x16e5('0x10')](_0x58b5da,_0x2d1408);}return _0x116d41;}export function extractStyles(_0x5575c4){const _0x6351a3={};for(const _0x2334c3 of _0x5575c4)for(const _0xc66f88 of _0x2334c3[_0x16e5('0xc')])if(_0xc66f88 instanceof CSSStyleRule){const _0x42e5e5=parseCSSStyleDeclaration(_0xc66f88[_0x16e5('0x5')]);_0x6351a3[_0xc66f88[_0x16e5('0x11')]]=Object[_0x16e5('0xd')]({},_0x6351a3[_0xc66f88[_0x16e5('0x11')]]||{},_0x42e5e5);}return _0x6351a3;}export function expandStyles(_0x19af8a){const _0xd38e8d=new Map();for(const _0x598c8a in _0x19af8a){const _0x5bab2e=parseCSSSelector(_0x598c8a),_0xd14967=_0x19af8a[_0x598c8a];for(const _0x18bfdd of _0x5bab2e)_0xd38e8d[_0x16e5('0x10')](_0x18bfdd,_0xd14967);}return _0xd38e8d;}export function parseCSSStyleDeclaration(_0x2316ec){const _0x237293={};for(let _0x35335d=0x0;_0x35335d<_0x2316ec[_0x16e5('0x3')];_0x35335d++){const _0x4313d2=_0x2316ec[_0x35335d],_0x715ec0=_0x2316ec[_0x16e5('0xa')](_0x4313d2);_0x16e5('0x8')!==_0x715ec0&&(_0x237293[_0x4313d2]=_0x715ec0);}return _0x237293;}export function parseCSSSelector(_0x591fc3){const _0x2311ed=_0x591fc3[_0x16e5('0xe')](',')[_0x16e5('0x1')](_0x46cc7e=>_0x46cc7e[_0x16e5('0x7')]()),_0x27ac50=[];for(const _0x34edeb of _0x2311ed){const _0x2eef14=S[_0x16e5('0x6')](_0x34edeb);_0x2eef14&&_0x27ac50[_0x16e5('0x2')](_0x2eef14[_0x16e5('0x4')]);}return _0x27ac50;}export function flattenStyleDefinitions(_0x455431){const _0x5e60bc={};for(const _0x37623f of _0x455431)Object[_0x16e5('0xd')](_0x5e60bc,_0x37623f);return _0x5e60bc;}
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 _0xbcbf=['name','content','blockElements','execute','includes','font','isActive','getItems','document','stylesProcessor','_parsedData'];(function(_0x3665e6,_0xbcbf1f){const _0x1ce6ea=function(_0x3a9210){while(--_0x3a9210){_0x3665e6['push'](_0x3665e6['shift']());}};_0x1ce6ea(++_0xbcbf1f);}(_0xbcbf,0x148));const _0x1ce6=function(_0x3665e6,_0xbcbf1f){_0x3665e6=_0x3665e6-0x0;let _0x1ce6ea=_0xbcbf[_0x3665e6];return _0x1ce6ea;};import{UpcastWriter as _0x1b5008,DomConverter as _0x462609,ViewDocument as _0x18055d}from'ckeditor5/src/engine';import{MSWordNormalizer as _0x47d1bb}from'@ckeditor/ckeditor5-paste-from-office';import{isMSExcelContent as _0x596c62}from'../../utils';import{getStylePropertyNamesToPropagate as _0x139375,propagateStyleProperties as _0x34d405}from'./utils';export default class l extends _0x47d1bb{[_0x1ce6('0x5')](_0x4b09fa){const {body:_0x151533}=_0x4b09fa[_0x1ce6('0x1')],_0x13a48f=new _0x1b5008(_0x151533['document']),_0x274eab=_0x13a48f['createRangeIn'](_0x151533),_0x5c3134=new _0x18055d(_0x13a48f[_0x1ce6('0xa')][_0x1ce6('0x0')]),_0x2a4ca7=[...new _0x462609(_0x5c3134)[_0x1ce6('0x4')],_0x1ce6('0x7')],_0x44f64b=_0x274eab[_0x1ce6('0x9')]();for(const _0x244d46 of _0x44f64b)if(_0x244d46['is']('element')&&_0x2a4ca7[_0x1ce6('0x6')](_0x244d46[_0x1ce6('0x2')])){const _0x3a846a=_0x139375(_0x244d46);_0x34d405(_0x244d46,_0x13a48f,_0x3a846a);}_0x4b09fa[_0x1ce6('0x3')]=_0x151533;}[_0x1ce6('0x8')](_0x474b1a){return super[_0x1ce6('0x8')](_0x474b1a)||_0x596c62(_0x474b1a);}}
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 _0x22f2=['underline','font-weight','forEach','italic','line-through','font-size','text-decoration','vertical-align','color','removeStyle','getStyleNames','getStyle','text-decoration-line','span','font-family','createElement','split','strong','filter','setStyle','sub','font-style','includes','keys','from','bolder','function'];(function(_0x128ed9,_0x22f2e2){const _0x2069d5=function(_0x42fcaf){while(--_0x42fcaf){_0x128ed9['push'](_0x128ed9['shift']());}};_0x2069d5(++_0x22f2e2);}(_0x22f2,0x68));const _0x2069=function(_0x128ed9,_0x22f2e2){_0x128ed9=_0x128ed9-0x0;let _0x2069d5=_0x22f2[_0x128ed9];return _0x2069d5;};export const CSS_PROPERTIES_TO_PROPAGATE=[_0x2069('0xc'),'font-family',_0x2069('0x9'),_0x2069('0xa'),_0x2069('0x10'),_0x2069('0x5'),_0x2069('0x19'),_0x2069('0xb')];export const CSS_PROPERTIES_TO_BE_SPANS=[_0x2069('0xc'),_0x2069('0x12'),'font-size'];export const CSS_PROPERTIES_TO_BE_HTML_ELEMENTS={'font-style':[[_0x2069('0x7'),'i']],'font-weight':[['medium','strong'],['bold',_0x2069('0x15')],[_0x2069('0x2'),_0x2069('0x15')],[_0x18a28d=>Number(_0x18a28d)>=0x258,_0x2069('0x15')]],'text-decoration':[['underline','u'],[_0x2069('0x8'),'s']],'text-decoration-line':[[_0x2069('0x4'),'u'],['line-through','s']],'vertical-align':[[_0x2069('0x18'),_0x2069('0x18')],['super','sup']]};export function isPropertyToBePropagated(_0x1243a3){return CSS_PROPERTIES_TO_PROPAGATE[_0x2069('0x1a')](_0x1243a3);}export function isPropertyToBePropagatedAsSpan(_0x30b724){return CSS_PROPERTIES_TO_BE_SPANS[_0x2069('0x1a')](_0x30b724);}export function isPropertyToBePropagatedAsHTMLElement(_0x183dfd){return _0x183dfd in CSS_PROPERTIES_TO_BE_HTML_ELEMENTS;}export function getStylePropertyNamesToPropagate(_0x4a6d09){return Array[_0x2069('0x1')](_0x4a6d09[_0x2069('0xe')]())[_0x2069('0x16')](isPropertyToBePropagated);}export function propagateStyleProperties(_0xd4589b,_0x4bf873,_0x8ed994){const {spanStyles:_0x3c7a74,stylesToBeHtmlElements:_0x9b4f96}=getStylesToPropagate(_0xd4589b,_0x8ed994);propagateStylesAsHTMLElements(_0xd4589b,_0x4bf873,_0x9b4f96),propagateStylesAsSpan(_0xd4589b,_0x4bf873,_0x3c7a74);}export function propagateStylesAsHTMLElements(_0x5a9279,_0x59b076,_0x3c8403){for(const _0x1c4a52 in _0x3c8403){_0x3c8403[_0x1c4a52]['forEach'](([,_0xd0f8a])=>{const _0x1bb1bb=_0x59b076[_0x2069('0x13')](_0xd0f8a,[],_0x5a9279['getChildren']());_0x59b076['insertChild'](0x0,_0x1bb1bb,_0x5a9279);}),_0x59b076['removeStyle'](_0x1c4a52,_0x5a9279);}}export function propagateStylesAsSpan(_0x96bfb5,_0x40d3fd,_0x38fe45){if(!Object[_0x2069('0x0')](_0x38fe45)['length'])return;const _0x1d6528=_0x40d3fd[_0x2069('0x13')](_0x2069('0x11'),[],_0x96bfb5['getChildren']());_0x40d3fd[_0x2069('0x17')](_0x38fe45,_0x1d6528),_0x40d3fd['insertChild'](0x0,_0x1d6528,_0x96bfb5),_0x40d3fd[_0x2069('0xd')](Object[_0x2069('0x0')](_0x38fe45),_0x96bfb5);}export function getStylesToPropagate(_0x53c8cd,_0x530b15){const _0x5800f8={},_0xa620db={};return _0x530b15['forEach'](_0x27680c=>{const _0x4bfbf0=_0x53c8cd[_0x2069('0xf')](_0x27680c);if(_0x4bfbf0){if(isPropertyToBePropagatedAsSpan(_0x27680c))_0x5800f8[_0x27680c]=_0x4bfbf0;else{if(isPropertyToBePropagatedAsHTMLElement(_0x27680c)){const _0x20d796=_0x4bfbf0[_0x2069('0x14')]('\x20');CSS_PROPERTIES_TO_BE_HTML_ELEMENTS[_0x27680c][_0x2069('0x6')](([_0x2e7545,_0x5e7975])=>{for(const _0x4dddea of _0x20d796){(_0x2069('0x3')==typeof _0x2e7545&&_0x2e7545(_0x4dddea)||_0x2e7545===_0x4dddea)&&(_0xa620db[_0x27680c]=[..._0xa620db[_0x27680c]||[],[_0x2e7545,_0x5e7975]]);}});}}}}),{'spanStyles':_0x5800f8,'stylesToBeHtmlElements':_0xa620db};}
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};}