@ckeditor/ckeditor5-paste-from-office 35.4.0 → 36.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,123 +1,93 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
-
6
5
  /**
7
6
  * @module paste-from-office/filters/parse
8
7
  */
9
-
10
8
  /* globals DOMParser */
11
-
12
9
  import { DomConverter, ViewDocument } from 'ckeditor5/src/engine';
13
-
14
10
  import { normalizeSpacing, normalizeSpacerunSpans } from './space';
15
-
16
11
  /**
17
12
  * Parses provided HTML extracting contents of `<body>` and `<style>` tags.
18
13
  *
19
- * @param {String} htmlString HTML string to be parsed.
20
- * @param {module:engine/view/stylesmap~StylesProcessor} stylesProcessor
21
- * @returns {Object} result
22
- * @returns {module:engine/view/documentfragment~DocumentFragment} result.body Parsed body
23
- * content as a traversable structure.
24
- * @returns {String} result.bodyString Entire body content as a string.
25
- * @returns {Array.<CSSStyleSheet>} result.styles Array of native `CSSStyleSheet` objects, each representing
26
- * separate `style` tag from the source HTML.
27
- * @returns {String} result.stylesString All `style` tags contents combined in the order of occurrence into one string.
14
+ * @param htmlString HTML string to be parsed.
28
15
  */
29
- export function parseHtml( htmlString, stylesProcessor ) {
30
- const domParser = new DOMParser();
31
-
32
- // Remove Word specific "if comments" so content inside is not omitted by the parser.
33
- htmlString = htmlString.replace( /<!--\[if gte vml 1]>/g, '' );
34
-
35
- const normalizedHtml = normalizeSpacing( cleanContentAfterBody( htmlString ) );
36
-
37
- // Parse htmlString as native Document object.
38
- const htmlDocument = domParser.parseFromString( normalizedHtml, 'text/html' );
39
-
40
- normalizeSpacerunSpans( htmlDocument );
41
-
42
- // Get `innerHTML` first as transforming to View modifies the source document.
43
- const bodyString = htmlDocument.body.innerHTML;
44
-
45
- // Transform document.body to View.
46
- const bodyView = documentToView( htmlDocument, stylesProcessor );
47
-
48
- // Extract stylesheets.
49
- const stylesObject = extractStyles( htmlDocument );
50
-
51
- return {
52
- body: bodyView,
53
- bodyString,
54
- styles: stylesObject.styles,
55
- stylesString: stylesObject.stylesString
56
- };
16
+ export function parseHtml(htmlString, stylesProcessor) {
17
+ const domParser = new DOMParser();
18
+ // Remove Word specific "if comments" so content inside is not omitted by the parser.
19
+ htmlString = htmlString.replace(/<!--\[if gte vml 1]>/g, '');
20
+ const normalizedHtml = normalizeSpacing(cleanContentAfterBody(htmlString));
21
+ // Parse htmlString as native Document object.
22
+ const htmlDocument = domParser.parseFromString(normalizedHtml, 'text/html');
23
+ normalizeSpacerunSpans(htmlDocument);
24
+ // Get `innerHTML` first as transforming to View modifies the source document.
25
+ const bodyString = htmlDocument.body.innerHTML;
26
+ // Transform document.body to View.
27
+ const bodyView = documentToView(htmlDocument, stylesProcessor);
28
+ // Extract stylesheets.
29
+ const stylesObject = extractStyles(htmlDocument);
30
+ return {
31
+ body: bodyView,
32
+ bodyString,
33
+ styles: stylesObject.styles,
34
+ stylesString: stylesObject.stylesString
35
+ };
57
36
  }
58
-
59
- // Transforms native `Document` object into {@link module:engine/view/documentfragment~DocumentFragment}. Comments are skipped.
60
- //
61
- // @param {Document} htmlDocument Native `Document` object to be transformed.
62
- // @param {module:engine/view/stylesmap~StylesProcessor} stylesProcessor
63
- // @returns {module:engine/view/documentfragment~DocumentFragment}
64
- function documentToView( htmlDocument, stylesProcessor ) {
65
- const viewDocument = new ViewDocument( stylesProcessor );
66
- const domConverter = new DomConverter( viewDocument, { renderingMode: 'data' } );
67
- const fragment = htmlDocument.createDocumentFragment();
68
- const nodes = htmlDocument.body.childNodes;
69
-
70
- while ( nodes.length > 0 ) {
71
- fragment.appendChild( nodes[ 0 ] );
72
- }
73
-
74
- return domConverter.domToView( fragment, { skipComments: true } );
37
+ /**
38
+ * Transforms native `Document` object into {@link module:engine/view/documentfragment~DocumentFragment}. Comments are skipped.
39
+ *
40
+ * @param htmlDocument Native `Document` object to be transformed.
41
+ */
42
+ function documentToView(htmlDocument, stylesProcessor) {
43
+ const viewDocument = new ViewDocument(stylesProcessor);
44
+ const domConverter = new DomConverter(viewDocument, { renderingMode: 'data' });
45
+ const fragment = htmlDocument.createDocumentFragment();
46
+ const nodes = htmlDocument.body.childNodes;
47
+ while (nodes.length > 0) {
48
+ fragment.appendChild(nodes[0]);
49
+ }
50
+ return domConverter.domToView(fragment, { skipComments: true });
75
51
  }
76
-
77
- // Extracts both `CSSStyleSheet` and string representation from all `style` elements available in a provided `htmlDocument`.
78
- //
79
- // @param {Document} htmlDocument Native `Document` object from which styles will be extracted.
80
- // @returns {Object} result
81
- // @returns {Array.<CSSStyleSheet>} result.styles Array of native `CSSStyleSheet` object, each representing
82
- // separate `style` tag from the source object.
83
- // @returns {String} result.stylesString All `style` tags contents combined in the order of occurrence as one string.
84
- function extractStyles( htmlDocument ) {
85
- const styles = [];
86
- const stylesString = [];
87
- const styleTags = Array.from( htmlDocument.getElementsByTagName( 'style' ) );
88
-
89
- for ( const style of styleTags ) {
90
- if ( style.sheet && style.sheet.cssRules && style.sheet.cssRules.length ) {
91
- styles.push( style.sheet );
92
- stylesString.push( style.innerHTML );
93
- }
94
- }
95
-
96
- return {
97
- styles,
98
- stylesString: stylesString.join( ' ' )
99
- };
52
+ /**
53
+ * Extracts both `CSSStyleSheet` and string representation from all `style` elements available in a provided `htmlDocument`.
54
+ *
55
+ * @param htmlDocument Native `Document` object from which styles will be extracted.
56
+ */
57
+ function extractStyles(htmlDocument) {
58
+ const styles = [];
59
+ const stylesString = [];
60
+ const styleTags = Array.from(htmlDocument.getElementsByTagName('style'));
61
+ for (const style of styleTags) {
62
+ if (style.sheet && style.sheet.cssRules && style.sheet.cssRules.length) {
63
+ styles.push(style.sheet);
64
+ stylesString.push(style.innerHTML);
65
+ }
66
+ }
67
+ return {
68
+ styles,
69
+ stylesString: stylesString.join(' ')
70
+ };
100
71
  }
101
-
102
- // Removes leftover content from between closing </body> and closing </html> tag:
103
- //
104
- // <html><body><p>Foo Bar</p></body><span>Fo</span></html> -> <html><body><p>Foo Bar</p></body></html>
105
- //
106
- // This function is used as specific browsers (Edge) add some random content after `body` tag when pasting from Word.
107
- // @param {String} htmlString The HTML string to be cleaned.
108
- // @returns {String} The HTML string with leftover content removed.
109
- function cleanContentAfterBody( htmlString ) {
110
- const bodyCloseTag = '</body>';
111
- const htmlCloseTag = '</html>';
112
-
113
- const bodyCloseIndex = htmlString.indexOf( bodyCloseTag );
114
-
115
- if ( bodyCloseIndex < 0 ) {
116
- return htmlString;
117
- }
118
-
119
- const htmlCloseIndex = htmlString.indexOf( htmlCloseTag, bodyCloseIndex + bodyCloseTag.length );
120
-
121
- return htmlString.substring( 0, bodyCloseIndex + bodyCloseTag.length ) +
122
- ( htmlCloseIndex >= 0 ? htmlString.substring( htmlCloseIndex ) : '' );
72
+ /**
73
+ * Removes leftover content from between closing </body> and closing </html> tag:
74
+ *
75
+ * ```html
76
+ * <html><body><p>Foo Bar</p></body><span>Fo</span></html> -> <html><body><p>Foo Bar</p></body></html>
77
+ * ```
78
+ *
79
+ * This function is used as specific browsers (Edge) add some random content after `body` tag when pasting from Word.
80
+ * @param htmlString The HTML string to be cleaned.
81
+ * @returns The HTML string with leftover content removed.
82
+ */
83
+ function cleanContentAfterBody(htmlString) {
84
+ const bodyCloseTag = '</body>';
85
+ const htmlCloseTag = '</html>';
86
+ const bodyCloseIndex = htmlString.indexOf(bodyCloseTag);
87
+ if (bodyCloseIndex < 0) {
88
+ return htmlString;
89
+ }
90
+ const htmlCloseIndex = htmlString.indexOf(htmlCloseTag, bodyCloseIndex + bodyCloseTag.length);
91
+ return htmlString.substring(0, bodyCloseIndex + bodyCloseTag.length) +
92
+ (htmlCloseIndex >= 0 ? htmlString.substring(htmlCloseIndex) : '');
123
93
  }
@@ -1,25 +1,18 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
-
6
- /**
7
- * @module paste-from-office/filters/removeboldwrapper
8
- */
9
-
10
5
  /**
11
6
  * Removes `<b>` tag wrapper added by Google Docs to a copied content.
12
7
  *
13
- * @param {module:engine/view/documentfragment~DocumentFragment} documentFragment element `data.content` obtained from clipboard
14
- * @param {module:engine/view/upcastwriter~UpcastWriter} writer
8
+ * @param documentFragment element `data.content` obtained from clipboard
15
9
  */
16
- export default function removeBoldWrapper( documentFragment, writer ) {
17
- for ( const child of documentFragment.getChildren() ) {
18
- if ( child.is( 'element', 'b' ) && child.getStyle( 'font-weight' ) === 'normal' ) {
19
- const childIndex = documentFragment.getChildIndex( child );
20
-
21
- writer.remove( child );
22
- writer.insertChild( childIndex, child.getChildren(), documentFragment );
23
- }
24
- }
10
+ export default function removeBoldWrapper(documentFragment, writer) {
11
+ for (const child of documentFragment.getChildren()) {
12
+ if (child.is('element', 'b') && child.getStyle('font-weight') === 'normal') {
13
+ const childIndex = documentFragment.getChildIndex(child);
14
+ writer.remove(child);
15
+ writer.insertChild(childIndex, child.getChildren(), documentFragment);
16
+ }
17
+ }
25
18
  }
@@ -1,61 +1,59 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
-
6
5
  /**
7
6
  * @module paste-from-office/filters/space
8
7
  */
9
-
10
8
  /**
11
9
  * Replaces last space preceding elements closing tag with `&nbsp;`. Such operation prevents spaces from being removed
12
10
  * during further DOM/View processing (see especially {@link module:engine/view/domconverter~DomConverter#_processDataFromDomText}).
13
11
  * This method also takes into account Word specific `<o:p></o:p>` empty tags.
14
12
  * Additionally multiline sequences of spaces and new lines between tags are removed (see #39 and #40).
15
13
  *
16
- * @param {String} htmlString HTML string in which spacing should be normalized.
17
- * @returns {String} Input HTML with spaces normalized.
14
+ * @param htmlString HTML string in which spacing should be normalized.
15
+ * @returns Input HTML with spaces normalized.
18
16
  */
19
- export function normalizeSpacing( htmlString ) {
20
- // Run normalizeSafariSpaceSpans() two times to cover nested spans.
21
- return normalizeSafariSpaceSpans( normalizeSafariSpaceSpans( htmlString ) )
22
- // Remove all \r\n from "spacerun spans" so the last replace line doesn't strip all whitespaces.
23
- .replace( /(<span\s+style=['"]mso-spacerun:yes['"]>[^\S\r\n]*?)[\r\n]+([^\S\r\n]*<\/span>)/g, '$1$2' )
24
- .replace( /<span\s+style=['"]mso-spacerun:yes['"]><\/span>/g, '' )
25
- .replace( / <\//g, '\u00A0</' )
26
- .replace( / <o:p><\/o:p>/g, '\u00A0<o:p></o:p>' )
27
- // Remove <o:p> block filler from empty paragraph. Safari uses \u00A0 instead of &nbsp;.
28
- .replace( /<o:p>(&nbsp;|\u00A0)<\/o:p>/g, '' )
29
- // Remove all whitespaces when they contain any \r or \n.
30
- .replace( />([^\S\r\n]*[\r\n]\s*)</g, '><' );
17
+ export function normalizeSpacing(htmlString) {
18
+ // Run normalizeSafariSpaceSpans() two times to cover nested spans.
19
+ return normalizeSafariSpaceSpans(normalizeSafariSpaceSpans(htmlString))
20
+ // Remove all \r\n from "spacerun spans" so the last replace line doesn't strip all whitespaces.
21
+ .replace(/(<span\s+style=['"]mso-spacerun:yes['"]>[^\S\r\n]*?)[\r\n]+([^\S\r\n]*<\/span>)/g, '$1$2')
22
+ .replace(/<span\s+style=['"]mso-spacerun:yes['"]><\/span>/g, '')
23
+ .replace(/ <\//g, '\u00A0</')
24
+ .replace(/ <o:p><\/o:p>/g, '\u00A0<o:p></o:p>')
25
+ // Remove <o:p> block filler from empty paragraph. Safari uses \u00A0 instead of &nbsp;.
26
+ .replace(/<o:p>(&nbsp;|\u00A0)<\/o:p>/g, '')
27
+ // Remove all whitespaces when they contain any \r or \n.
28
+ .replace(/>([^\S\r\n]*[\r\n]\s*)</g, '><');
31
29
  }
32
-
33
30
  /**
34
31
  * Normalizes spacing in special Word `spacerun spans` (`<span style='mso-spacerun:yes'>\s+</span>`) by replacing
35
32
  * all spaces with `&nbsp; ` pairs. This prevents spaces from being removed during further DOM/View processing
36
33
  * (see especially {@link module:engine/view/domconverter~DomConverter#_processDataFromDomText}).
37
34
  *
38
- * @param {Document} htmlDocument Native `Document` object in which spacing should be normalized.
35
+ * @param htmlDocument Native `Document` object in which spacing should be normalized.
39
36
  */
40
- export function normalizeSpacerunSpans( htmlDocument ) {
41
- htmlDocument.querySelectorAll( 'span[style*=spacerun]' ).forEach( el => {
42
- const innerTextLength = el.innerText.length || 0;
43
-
44
- el.innerText = Array( innerTextLength + 1 ).join( '\u00A0 ' ).substr( 0, innerTextLength );
45
- } );
37
+ export function normalizeSpacerunSpans(htmlDocument) {
38
+ htmlDocument.querySelectorAll('span[style*=spacerun]').forEach(el => {
39
+ const htmlElement = el;
40
+ const innerTextLength = htmlElement.innerText.length || 0;
41
+ htmlElement.innerText = Array(innerTextLength + 1).join('\u00A0 ').substr(0, innerTextLength);
42
+ });
46
43
  }
47
-
48
- // Normalizes specific spacing generated by Safari when content pasted from Word (`<span class="Apple-converted-space"> </span>`)
49
- // by replacing all spaces sequences longer than 1 space with `&nbsp; ` pairs. This prevents spaces from being removed during
50
- // further DOM/View processing (see especially {@link module:engine/view/domconverter~DomConverter#_processDataFromDomText}).
51
- //
52
- // This function is similar to {@link module:clipboard/utils/normalizeclipboarddata normalizeClipboardData util} but uses
53
- // regular spaces / &nbsp; sequence for replacement.
54
- //
55
- // @param {String} htmlString HTML string in which spacing should be normalized
56
- // @returns {String} Input HTML with spaces normalized.
57
- function normalizeSafariSpaceSpans( htmlString ) {
58
- return htmlString.replace( /<span(?: class="Apple-converted-space"|)>(\s+)<\/span>/g, ( fullMatch, spaces ) => {
59
- return spaces.length === 1 ? ' ' : Array( spaces.length + 1 ).join( '\u00A0 ' ).substr( 0, spaces.length );
60
- } );
44
+ /**
45
+ * Normalizes specific spacing generated by Safari when content pasted from Word (`<span class="Apple-converted-space"> </span>`)
46
+ * by replacing all spaces sequences longer than 1 space with `&nbsp; ` pairs. This prevents spaces from being removed during
47
+ * further DOM/View processing (see especially {@link module:engine/view/domconverter~DomConverter#_processDataFromDomText}).
48
+ *
49
+ * This function is similar to {@link module:clipboard/utils/normalizeclipboarddata normalizeClipboardData util} but uses
50
+ * regular spaces / &nbsp; sequence for replacement.
51
+ *
52
+ * @param htmlString HTML string in which spacing should be normalized
53
+ * @returns Input HTML with spaces normalized.
54
+ */
55
+ function normalizeSafariSpaceSpans(htmlString) {
56
+ return htmlString.replace(/<span(?: class="Apple-converted-space"|)>(\s+)<\/span>/g, (fullMatch, spaces) => {
57
+ return spaces.length === 1 ? ' ' : Array(spaces.length + 1).join('\u00A0 ').substr(0, spaces.length);
58
+ });
61
59
  }
package/src/index.js CHANGED
@@ -1,10 +1,8 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
-
6
5
  /**
7
6
  * @module paste-from-office
8
7
  */
9
-
10
8
  export { default as PasteFromOffice } from './pastefromoffice';
@@ -0,0 +1,5 @@
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
+ export {};
@@ -1,57 +1,42 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
-
6
5
  /**
7
6
  * @module paste-from-office/normalizers/googledocsnormalizer
8
7
  */
9
-
10
8
  import { UpcastWriter } from 'ckeditor5/src/engine';
11
-
12
9
  import removeBoldWrapper from '../filters/removeboldwrapper';
13
10
  import transformBlockBrsToParagraphs from '../filters/br';
14
11
  import { unwrapParagraphInListItem } from '../filters/list';
15
-
16
12
  const googleDocsMatch = /id=("|')docs-internal-guid-[-0-9a-f]+("|')/i;
17
-
18
13
  /**
19
14
  * Normalizer for the content pasted from Google Docs.
20
- *
21
- * @implements module:paste-from-office/normalizer~Normalizer
22
15
  */
23
16
  export default class GoogleDocsNormalizer {
24
- /**
25
- * Creates a new `GoogleDocsNormalizer` instance.
26
- *
27
- * @param {module:engine/view/document~Document} document View document.
28
- */
29
- constructor( document ) {
30
- /**
31
- * @readonly
32
- * @type {module:engine/view/document~Document}
33
- */
34
- this.document = document;
35
- }
36
-
37
- /**
38
- * @inheritDoc
39
- */
40
- isActive( htmlString ) {
41
- return googleDocsMatch.test( htmlString );
42
- }
43
-
44
- /**
45
- * @inheritDoc
46
- */
47
- execute( data ) {
48
- const writer = new UpcastWriter( this.document );
49
- const { body: documentFragment } = data._parsedData;
50
-
51
- removeBoldWrapper( documentFragment, writer );
52
- unwrapParagraphInListItem( documentFragment, writer );
53
- transformBlockBrsToParagraphs( documentFragment, writer );
54
-
55
- data.content = documentFragment;
56
- }
17
+ /**
18
+ * Creates a new `GoogleDocsNormalizer` instance.
19
+ *
20
+ * @param document View document.
21
+ */
22
+ constructor(document) {
23
+ this.document = document;
24
+ }
25
+ /**
26
+ * @inheritDoc
27
+ */
28
+ isActive(htmlString) {
29
+ return googleDocsMatch.test(htmlString);
30
+ }
31
+ /**
32
+ * @inheritDoc
33
+ */
34
+ execute(data) {
35
+ const writer = new UpcastWriter(this.document);
36
+ const { body: documentFragment } = data._parsedData;
37
+ removeBoldWrapper(documentFragment, writer);
38
+ unwrapParagraphInListItem(documentFragment, writer);
39
+ transformBlockBrsToParagraphs(documentFragment, writer);
40
+ data.content = documentFragment;
41
+ }
57
42
  }
@@ -1,53 +1,39 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
-
6
5
  /**
7
6
  * @module paste-from-office/normalizers/mswordnormalizer
8
7
  */
9
-
10
8
  import { transformListItemLikeElementsIntoLists } from '../filters/list';
11
9
  import { replaceImagesSourceWithBase64 } from '../filters/image';
12
-
13
10
  const msWordMatch1 = /<meta\s*name="?generator"?\s*content="?microsoft\s*word\s*\d+"?\/?>/i;
14
11
  const msWordMatch2 = /xmlns:o="urn:schemas-microsoft-com/i;
15
-
16
12
  /**
17
13
  * Normalizer for the content pasted from Microsoft Word.
18
- *
19
- * @implements module:paste-from-office/normalizer~Normalizer
20
14
  */
21
15
  export default class MSWordNormalizer {
22
- /**
23
- * Creates a new `MSWordNormalizer` instance.
24
- *
25
- * @param {module:engine/view/document~Document} document View document.
26
- */
27
- constructor( document ) {
28
- /**
29
- * @readonly
30
- * @type {module:engine/view/document~Document}
31
- */
32
- this.document = document;
33
- }
34
-
35
- /**
36
- * @inheritDoc
37
- */
38
- isActive( htmlString ) {
39
- return msWordMatch1.test( htmlString ) || msWordMatch2.test( htmlString );
40
- }
41
-
42
- /**
43
- * @inheritDoc
44
- */
45
- execute( data ) {
46
- const { body: documentFragment, stylesString } = data._parsedData;
47
-
48
- transformListItemLikeElementsIntoLists( documentFragment, stylesString );
49
- replaceImagesSourceWithBase64( documentFragment, data.dataTransfer.getData( 'text/rtf' ) );
50
-
51
- data.content = documentFragment;
52
- }
16
+ /**
17
+ * Creates a new `MSWordNormalizer` instance.
18
+ *
19
+ * @param document View document.
20
+ */
21
+ constructor(document) {
22
+ this.document = document;
23
+ }
24
+ /**
25
+ * @inheritDoc
26
+ */
27
+ isActive(htmlString) {
28
+ return msWordMatch1.test(htmlString) || msWordMatch2.test(htmlString);
29
+ }
30
+ /**
31
+ * @inheritDoc
32
+ */
33
+ execute(data) {
34
+ const { body: documentFragment, stylesString } = data._parsedData;
35
+ transformListItemLikeElementsIntoLists(documentFragment, stylesString);
36
+ replaceImagesSourceWithBase64(documentFragment, data.dataTransfer.getData('text/rtf'));
37
+ data.content = documentFragment;
38
+ }
53
39
  }