Procházet zdrojové kódy

Tests: Refactoring and 100% cc.

Krzysztof Krztoń před 7 roky
rodič
revize
e5f89290f6
31 změnil soubory, kde provedl 240 přidání a 60 odebrání
  1. 15 20
      packages/ckeditor5-paste-from-office/src/filters/image.js
  2. 1 1
      packages/ckeditor5-paste-from-office/tests/_data/image/adjacent-groups/input.safari.word2016.html
  3. 1 1
      packages/ckeditor5-paste-from-office/tests/_data/image/adjacent-groups/model.safari.word2016.html
  4. 1 1
      packages/ckeditor5-paste-from-office/tests/_data/image/adjacent-groups/normalized.safari.word2016.html
  5. 1 1
      packages/ckeditor5-paste-from-office/tests/_data/image/alternative-text/input.safari.word2016.html
  6. 1 1
      packages/ckeditor5-paste-from-office/tests/_data/image/alternative-text/model.safari.word2016.html
  7. 1 1
      packages/ckeditor5-paste-from-office/tests/_data/image/alternative-text/normalized.safari.word2016.html
  8. 1 1
      packages/ckeditor5-paste-from-office/tests/_data/image/linked/input.safari.word2016.html
  9. 1 1
      packages/ckeditor5-paste-from-office/tests/_data/image/linked/model.safari.word2016.html
  10. 1 1
      packages/ckeditor5-paste-from-office/tests/_data/image/linked/normalized.safari.word2016.html
  11. 1 1
      packages/ckeditor5-paste-from-office/tests/_data/image/offline/input.safari.word2016.html
  12. 2 2
      packages/ckeditor5-paste-from-office/tests/_data/image/offline/model.safari.word2016.html
  13. 2 2
      packages/ckeditor5-paste-from-office/tests/_data/image/offline/normalized.safari.word2016.html
  14. 1 1
      packages/ckeditor5-paste-from-office/tests/_data/image/online-offline/input.safari.word2016.html
  15. 3 3
      packages/ckeditor5-paste-from-office/tests/_data/image/online-offline/model.safari.word2016.html
  16. 3 3
      packages/ckeditor5-paste-from-office/tests/_data/image/online-offline/normalized.safari.word2016.html
  17. 1 1
      packages/ckeditor5-paste-from-office/tests/_data/image/reflection/input.safari.word2016.html
  18. 1 1
      packages/ckeditor5-paste-from-office/tests/_data/image/reflection/model.safari.word2016.html
  19. 1 1
      packages/ckeditor5-paste-from-office/tests/_data/image/reflection/normalized.safari.word2016.html
  20. 1 1
      packages/ckeditor5-paste-from-office/tests/_data/image/rotated/input.safari.word2016.html
  21. 1 1
      packages/ckeditor5-paste-from-office/tests/_data/image/rotated/model.safari.word2016.html
  22. 1 1
      packages/ckeditor5-paste-from-office/tests/_data/image/rotated/normalized.safari.word2016.html
  23. 1 1
      packages/ckeditor5-paste-from-office/tests/_data/image/shapes-online-offline/input.safari.word2016.html
  24. 4 4
      packages/ckeditor5-paste-from-office/tests/_data/image/shapes-online-offline/model.safari.word2016.html
  25. 4 4
      packages/ckeditor5-paste-from-office/tests/_data/image/shapes-online-offline/normalized.safari.word2016.html
  26. 1 1
      packages/ckeditor5-paste-from-office/tests/_data/image/wrapped/input.safari.word2016.html
  27. 1 1
      packages/ckeditor5-paste-from-office/tests/_data/image/wrapped/model.safari.word2016.html
  28. 1 1
      packages/ckeditor5-paste-from-office/tests/_data/image/wrapped/normalized.safari.word2016.html
  29. 6 0
      packages/ckeditor5-paste-from-office/tests/_utils/utils.js
  30. 179 0
      packages/ckeditor5-paste-from-office/tests/filters/image.js
  31. 1 1
      packages/ckeditor5-paste-from-office/tests/filters/list.js

+ 15 - 20
packages/ckeditor5-paste-from-office/src/filters/image.js

@@ -181,21 +181,19 @@ function extractImageDataFromRtf( rtfData ) {
 
 	if ( images ) {
 		for ( const image of images ) {
-			if ( regexPictureHeader.test( image ) ) {
-				let imageType = false;
-
-				if ( image.indexOf( '\\pngblip' ) !== -1 ) {
-					imageType = 'image/png';
-				} else if ( image.indexOf( '\\jpegblip' ) !== -1 ) {
-					imageType = 'image/jpeg';
-				}
-
-				if ( imageType ) {
-					result.push( {
-						hex: imageType ? image.replace( regexPictureHeader, '' ).replace( /[^\da-fA-F]/g, '' ) : null,
-						type: imageType
-					} );
-				}
+			let imageType = false;
+
+			if ( image.indexOf( '\\pngblip' ) !== -1 ) {
+				imageType = 'image/png';
+			} else if ( image.indexOf( '\\jpegblip' ) !== -1 ) {
+				imageType = 'image/jpeg';
+			}
+
+			if ( imageType ) {
+				result.push( {
+					hex: image.replace( regexPictureHeader, '' ).replace( /[^\da-fA-F]/g, '' ),
+					type: imageType
+				} );
 			}
 		}
 	}
@@ -213,11 +211,8 @@ function replaceImagesFileSourceWithInlineRepresentation( imageElements, imagesH
 	// Assume there is an equal amount of image elements and images HEX sources so they can be matched accordingly based on existing order.
 	if ( imageElements.length === imagesHexSources.length ) {
 		for ( let i = 0; i < imageElements.length; i++ ) {
-			// Replace only `file` urls of images (online images are also represented with local `file://` path).
-			if ( imageElements[ i ].getAttribute( 'src' ).indexOf( 'file://' ) === 0 && imagesHexSources[ i ] ) {
-				const newSrc = `data:${ imagesHexSources[ i ].type };base64,${ convertHexToBase64( imagesHexSources[ i ].hex ) }`;
-				writer.setAttribute( 'src', newSrc, imageElements[ i ] );
-			}
+			const newSrc = `data:${ imagesHexSources[ i ].type };base64,${ convertHexToBase64( imagesHexSources[ i ].hex ) }`;
+			writer.setAttribute( 'src', newSrc, imageElements[ i ] );
 		}
 	}
 }

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 1
packages/ckeditor5-paste-from-office/tests/_data/image/adjacent-groups/input.safari.word2016.html


+ 1 - 1
packages/ckeditor5-paste-from-office/tests/_data/image/adjacent-groups/model.safari.word2016.html

@@ -26,4 +26,4 @@
 <paragraph></paragraph>
 <paragraph></paragraph>
 
-<image src="blob:http://localhost:8125/6948ce58-ac20-4424-8356-f3c727f18ee6"></image>
+<image src="blob:http://localhost:9876/6948ce58-ac20-4424-8356-f3c727f18ee6"></image>

+ 1 - 1
packages/ckeditor5-paste-from-office/tests/_data/image/adjacent-groups/normalized.safari.word2016.html

@@ -37,7 +37,7 @@
 
 <p class="MsoNormal" style="margin: 0cm 0cm 8pt; line-height: 15.693333625793457px; font-size: 11pt; font-family: Calibri, sans-serif; caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;">
 	<span lang="EN-US">
-		<img width="153" height="153" src="blob:http://localhost:8125/4fe9e7ab-3fec-4cce-98b8-7773476dbbf0" v:shapes="Obraz_x0020_12">
+		<img width="153" height="153" src="blob:http://localhost:9876/4fe9e7ab-3fec-4cce-98b8-7773476dbbf0" v:shapes="Obraz_x0020_12">
 	</span>
 	<span lang="EN-US"><o:p></o:p></span>
 </p>

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 1
packages/ckeditor5-paste-from-office/tests/_data/image/alternative-text/input.safari.word2016.html


+ 1 - 1
packages/ckeditor5-paste-from-office/tests/_data/image/alternative-text/model.safari.word2016.html

@@ -1 +1 @@
-<image alt="Title: Hello world - Description: Macintosh HD:Users:dev:Desktop:phoca_thumb_l_sample-200x200.png" src="blob:http://localhost:8125/a47f813e-e187-4192-805b-597b7b785d07"></image>
+<image alt="Title: Hello world - Description: Macintosh HD:Users:dev:Desktop:phoca_thumb_l_sample-200x200.png" src="blob:http://localhost:9876/a47f813e-e187-4192-805b-597b7b785d07"></image>

+ 1 - 1
packages/ckeditor5-paste-from-office/tests/_data/image/alternative-text/normalized.safari.word2016.html

@@ -1,6 +1,6 @@
 <p class="MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: medium; font-family: Cambria, serif; caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;">
 	<span lang="EN-US">
-		<img width="201" height="201" src="blob:http://localhost:8125/a47f813e-e187-4192-805b-597b7b785d07" alt="Title: Hello world - Description: Macintosh HD:Users:dev:Desktop:phoca_thumb_l_sample-200x200.png" v:shapes="Picture_x0020_1">
+		<img width="201" height="201" src="blob:http://localhost:9876/a47f813e-e187-4192-805b-597b7b785d07" alt="Title: Hello world - Description: Macintosh HD:Users:dev:Desktop:phoca_thumb_l_sample-200x200.png" v:shapes="Picture_x0020_1">
 	</span>
 	<span lang="EN-US"><o:p></o:p></span>
 </p>

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 1
packages/ckeditor5-paste-from-office/tests/_data/image/linked/input.safari.word2016.html


+ 1 - 1
packages/ckeditor5-paste-from-office/tests/_data/image/linked/model.safari.word2016.html

@@ -1,2 +1,2 @@
-<image src="blob:http://localhost:8125/b3944c30-1268-4dfb-8c7f-f19894f674c0"></image>
+<image src="blob:http://localhost:9876/b3944c30-1268-4dfb-8c7f-f19894f674c0"></image>
 <paragraph></paragraph>

+ 1 - 1
packages/ckeditor5-paste-from-office/tests/_data/image/linked/normalized.safari.word2016.html

@@ -3,7 +3,7 @@
 		<a href="http://example.com/">
 			<span style="text-decoration: none;">
 				<span>
-					<img border="0" width="153" height="153" src="blob:http://localhost:8125/b3944c30-1268-4dfb-8c7f-f19894f674c0" v:shapes="Obraz_x0020_2">
+					<img border="0" width="153" height="153" src="blob:http://localhost:9876/b3944c30-1268-4dfb-8c7f-f19894f674c0" v:shapes="Obraz_x0020_2">
 				</span>
 			</span>
 		</a>

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 1
packages/ckeditor5-paste-from-office/tests/_data/image/offline/input.safari.word2016.html


+ 2 - 2
packages/ckeditor5-paste-from-office/tests/_data/image/offline/model.safari.word2016.html

@@ -1,3 +1,3 @@
 <paragraph>This word contains some pictures:</paragraph>
-<image src="blob:http://localhost:8125/6eee155b-110e-4cc7-a624-06afab80827b"></image>
-<image src="blob:http://localhost:8125/0028aae7-a8e8-4018-bd92-5f384f2877f7"></image>
+<image src="blob:http://localhost:9876/6eee155b-110e-4cc7-a624-06afab80827b"></image>
+<image src="blob:http://localhost:9876/0028aae7-a8e8-4018-bd92-5f384f2877f7"></image>

+ 2 - 2
packages/ckeditor5-paste-from-office/tests/_data/image/offline/normalized.safari.word2016.html

@@ -4,14 +4,14 @@
 
 <p class="MsoNormal" style="margin: 0cm 0cm 8pt; line-height: 15.693333625793457px; font-size: 11pt; font-family: Calibri, sans-serif; caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;">
 	<span lang="EN-US">
-		<img width="48" height="48" src="blob:http://localhost:8125/6eee155b-110e-4cc7-a624-06afab80827b" v:shapes="Obraz_x0020_1">
+		<img width="48" height="48" src="blob:http://localhost:9876/6eee155b-110e-4cc7-a624-06afab80827b" v:shapes="Obraz_x0020_1">
 	</span>
 	<span lang="EN-US"><o:p></o:p></span>
 </p>
 
 <p class="MsoNormal" style="margin: 0cm 0cm 8pt; line-height: 15.693333625793457px; font-size: 11pt; font-family: Calibri, sans-serif; caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;">
 	<span lang="EN-US">
-		<img width="48" height="48" src="blob:http://localhost:8125/0028aae7-a8e8-4018-bd92-5f384f2877f7" v:shapes="Obraz_x0020_2">
+		<img width="48" height="48" src="blob:http://localhost:9876/0028aae7-a8e8-4018-bd92-5f384f2877f7" v:shapes="Obraz_x0020_2">
 	</span>
 	<span lang="EN-US"><o:p></o:p></span>
 </p>

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 1
packages/ckeditor5-paste-from-office/tests/_data/image/online-offline/input.safari.word2016.html


+ 3 - 3
packages/ckeditor5-paste-from-office/tests/_data/image/online-offline/model.safari.word2016.html

@@ -1,8 +1,8 @@
 <paragraph>Kitty from internet: </paragraph>
-<image alt="http://placekitten.com/200/305" src="blob:http://localhost:8125/3d548a2e-3bf9-4ce8-afce-535abb535964"></image>
+<image alt="http://placekitten.com/200/305" src="blob:http://localhost:9876/3d548a2e-3bf9-4ce8-afce-535abb535964"></image>
 
 <paragraph>My drawing: </paragraph>
-<image src="blob:http://localhost:8125/bc7405cb-6456-46d5-b561-f2a70886abe3"></image>
+<image src="blob:http://localhost:9876/bc7405cb-6456-46d5-b561-f2a70886abe3"></image>
 
 <paragraph> hehehehe :D </paragraph>
-<image src="blob:http://localhost:8125/50cbea9b-c8f0-48e5-9c69-1139aaab304f"></image>
+<image src="blob:http://localhost:9876/50cbea9b-c8f0-48e5-9c69-1139aaab304f"></image>

+ 3 - 3
packages/ckeditor5-paste-from-office/tests/_data/image/online-offline/normalized.safari.word2016.html

@@ -1,7 +1,7 @@
 <p class="MsoNormal" style="margin: 0cm 0cm 8pt; line-height: 15.693333625793457px; font-size: 11pt; font-family: Calibri, sans-serif; caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;">
 	<span lang="EN-US">Kitty from internet:&nbsp;</span>
 	<span lang="EN-US">
-		<img width="150" height="229" src="blob:http://localhost:8125/3d548a2e-3bf9-4ce8-afce-535abb535964" alt="http://placekitten.com/200/305" v:shapes="Picture_x0020_2">
+		<img width="150" height="229" src="blob:http://localhost:9876/3d548a2e-3bf9-4ce8-afce-535abb535964" alt="http://placekitten.com/200/305" v:shapes="Picture_x0020_2">
 	</span>
 	<span lang="EN-US"><o:p></o:p></span>
 </p>
@@ -9,11 +9,11 @@
 <p class="MsoNormal" style="margin: 0cm 0cm 8pt; line-height: 15.693333625793457px; font-size: 11pt; font-family: Calibri, sans-serif; caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;">
 	<span lang="EN-US">My drawing: </span>
 	<span lang="EN-US">
-		<img width="24" height="24" src="blob:http://localhost:8125/bc7405cb-6456-46d5-b561-f2a70886abe3" v:shapes="Obraz_x0020_4">
+		<img width="24" height="24" src="blob:http://localhost:9876/bc7405cb-6456-46d5-b561-f2a70886abe3" v:shapes="Obraz_x0020_4">
 	</span>
 	<span lang="EN-US">&nbsp;hehehehe :D&nbsp;</span>
 	<span lang="EN-US">
-		<img width="24" height="24" src="blob:http://localhost:8125/50cbea9b-c8f0-48e5-9c69-1139aaab304f" v:shapes="Obraz_x0020_5">
+		<img width="24" height="24" src="blob:http://localhost:9876/50cbea9b-c8f0-48e5-9c69-1139aaab304f" v:shapes="Obraz_x0020_5">
 	</span>
 	<span lang="EN-US"><o:p></o:p></span>
 </p>

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 1
packages/ckeditor5-paste-from-office/tests/_data/image/reflection/input.safari.word2016.html


+ 1 - 1
packages/ckeditor5-paste-from-office/tests/_data/image/reflection/model.safari.word2016.html

@@ -1,2 +1,2 @@
-<image alt="Macintosh HD:Users:dev:Desktop:phoca_thumb_l_sample-200x200.png" src="blob:http://localhost:8125/3e7ab849-1542-4799-a08b-f5c55b5ce4b4"></image>
+<image alt="Macintosh HD:Users:dev:Desktop:phoca_thumb_l_sample-200x200.png" src="blob:http://localhost:9876/3e7ab849-1542-4799-a08b-f5c55b5ce4b4"></image>
 

+ 1 - 1
packages/ckeditor5-paste-from-office/tests/_data/image/reflection/normalized.safari.word2016.html

@@ -1,6 +1,6 @@
 <p class="MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: medium; font-family: Cambria, serif; caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;">
 	<span lang="EN-US">
-		<img width="203" height="258" src="blob:http://localhost:8125/3e7ab849-1542-4799-a08b-f5c55b5ce4b4" alt="Macintosh HD:Users:dev:Desktop:phoca_thumb_l_sample-200x200.png" v:shapes="Picture_x0020_1">
+		<img width="203" height="258" src="blob:http://localhost:9876/3e7ab849-1542-4799-a08b-f5c55b5ce4b4" alt="Macintosh HD:Users:dev:Desktop:phoca_thumb_l_sample-200x200.png" v:shapes="Picture_x0020_1">
 	</span>
 	<span lang="EN-US"><o:p></o:p></span>
 </p>

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 1
packages/ckeditor5-paste-from-office/tests/_data/image/rotated/input.safari.word2016.html


+ 1 - 1
packages/ckeditor5-paste-from-office/tests/_data/image/rotated/model.safari.word2016.html

@@ -1 +1 @@
-<image alt="Macintosh HD:Users:dev:Desktop:phoca_thumb_l_sample-200x200.png" src="blob:http://localhost:8125/613ccc9a-a701-4025-823c-02000d80e57c"></image>
+<image alt="Macintosh HD:Users:dev:Desktop:phoca_thumb_l_sample-200x200.png" src="blob:http://localhost:9876/613ccc9a-a701-4025-823c-02000d80e57c"></image>

+ 1 - 1
packages/ckeditor5-paste-from-office/tests/_data/image/rotated/normalized.safari.word2016.html

@@ -1,6 +1,6 @@
 <p class="MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: medium; font-family: Cambria, serif; caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;">
 	<span lang="EN-US">
-		<img width="279" height="279" src="blob:http://localhost:8125/613ccc9a-a701-4025-823c-02000d80e57c" alt="Macintosh HD:Users:dev:Desktop:phoca_thumb_l_sample-200x200.png" v:shapes="Picture_x0020_1">
+		<img width="279" height="279" src="blob:http://localhost:9876/613ccc9a-a701-4025-823c-02000d80e57c" alt="Macintosh HD:Users:dev:Desktop:phoca_thumb_l_sample-200x200.png" v:shapes="Picture_x0020_1">
 	</span>
 	<span lang="EN-US"><o:p></o:p></span>
 </p>

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 1
packages/ckeditor5-paste-from-office/tests/_data/image/shapes-online-offline/input.safari.word2016.html


+ 4 - 4
packages/ckeditor5-paste-from-office/tests/_data/image/shapes-online-offline/model.safari.word2016.html

@@ -1,13 +1,13 @@
 <paragraph>Kitty from internet: </paragraph>
-<image alt="http://placekitten.com/200/305" src="blob:http://localhost:8125/13c7acc7-bf65-4d44-95e4-e7abef2f19bd"></image>
+<image alt="http://placekitten.com/200/305" src="blob:http://localhost:9876/13c7acc7-bf65-4d44-95e4-e7abef2f19bd"></image>
 
 <paragraph>My drawing: </paragraph>
-<image src="blob:http://localhost:8125/f4eae12c-af69-4208-9c41-70883f462710"></image>
+<image src="blob:http://localhost:9876/f4eae12c-af69-4208-9c41-70883f462710"></image>
 
 <paragraph> hehehehe :D </paragraph>
-<image src="blob:http://localhost:8125/658953f0-7e4d-49c3-ae39-7dfb47fe7577"></image>
+<image src="blob:http://localhost:9876/658953f0-7e4d-49c3-ae39-7dfb47fe7577"></image>
 
-<image src="blob:http://localhost:8125/bf643552-117b-4b6c-a0d9-f4941411e38c"></image>
+<image src="blob:http://localhost:9876/bf643552-117b-4b6c-a0d9-f4941411e38c"></image>
 <paragraph>Additional shape made within Word is added here:</paragraph>
 
 <paragraph></paragraph>

+ 4 - 4
packages/ckeditor5-paste-from-office/tests/_data/image/shapes-online-offline/normalized.safari.word2016.html

@@ -1,7 +1,7 @@
 <p class="MsoNormal" style="margin: 0cm 0cm 8pt; line-height: 15.693333625793457px; font-size: 11pt; font-family: Calibri, sans-serif; caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;">
 	<span lang="EN-US">Kitty from internet:&nbsp;</span>
 	<span lang="EN-US">
-		<img width="150" height="229" src="blob:http://localhost:8125/13c7acc7-bf65-4d44-95e4-e7abef2f19bd" alt="http://placekitten.com/200/305" v:shapes="Picture_x0020_2">
+		<img width="150" height="229" src="blob:http://localhost:9876/13c7acc7-bf65-4d44-95e4-e7abef2f19bd" alt="http://placekitten.com/200/305" v:shapes="Picture_x0020_2">
 	</span>
 	<span lang="EN-US"><o:p></o:p></span>
 </p>
@@ -9,10 +9,10 @@
 <p class="MsoNormal" style="margin: 0cm 0cm 8pt; line-height: 15.693333625793457px; font-size: 11pt; font-family: Calibri, sans-serif; caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;">
 	<span lang="EN-US">My drawing: </span>
 	<span lang="EN-US">
-		<img width="24" height="24" src="blob:http://localhost:8125/f4eae12c-af69-4208-9c41-70883f462710" v:shapes="Obraz_x0020_4"></span>
+		<img width="24" height="24" src="blob:http://localhost:9876/f4eae12c-af69-4208-9c41-70883f462710" v:shapes="Obraz_x0020_4"></span>
 	<span lang="EN-US">&nbsp;hehehehe :D&nbsp;</span>
 	<span lang="EN-US">
-		<img width="24" height="24" src="blob:http://localhost:8125/658953f0-7e4d-49c3-ae39-7dfb47fe7577" v:shapes="Obraz_x0020_5">
+		<img width="24" height="24" src="blob:http://localhost:9876/658953f0-7e4d-49c3-ae39-7dfb47fe7577" v:shapes="Obraz_x0020_5">
 	</span>
 	<span lang="EN-US"><o:p></o:p></span>
 </p>
@@ -20,7 +20,7 @@
 <p class="MsoNormal" style="margin: 0cm 0cm 8pt; line-height: 15.693333625793457px; font-size: 11pt; font-family: Calibri, sans-serif; caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;">
 	<span style="position: relative; z-index: 251659264;">
 		<span style="position: absolute; left: -6px; top: -79px; width: 126px; height: 126px;">
-			<img width="126" height="126" src="blob:http://localhost:8125/bf643552-117b-4b6c-a0d9-f4941411e38c" v:shapes="Elipsa_x0020_1">
+			<img width="126" height="126" src="blob:http://localhost:9876/bf643552-117b-4b6c-a0d9-f4941411e38c" v:shapes="Elipsa_x0020_1">
 		</span>
 	</span>
 	<span lang="EN-US">Additional shape made within Word is added here:<o:p></o:p></span>

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 1
packages/ckeditor5-paste-from-office/tests/_data/image/wrapped/input.safari.word2016.html


+ 1 - 1
packages/ckeditor5-paste-from-office/tests/_data/image/wrapped/model.safari.word2016.html

@@ -1 +1 @@
-<image src="blob:http://localhost:8125/1e94edaf-a1cf-4d59-bf72-a54b2b7aca15"></image>
+<image src="blob:http://localhost:9876/1e94edaf-a1cf-4d59-bf72-a54b2b7aca15"></image>

+ 1 - 1
packages/ckeditor5-paste-from-office/tests/_data/image/wrapped/normalized.safari.word2016.html

@@ -1,4 +1,4 @@
 <p class="MsoNormal" style="margin: 0cm 0cm 8pt; line-height: 15.693333625793457px; font-size: 11pt; font-family: Calibri, sans-serif; caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;">
-	<img width="48" height="48" src="blob:http://localhost:8125/1e94edaf-a1cf-4d59-bf72-a54b2b7aca15" align="left" hspace="12" v:shapes="Obraz_x0020_2">
+	<img width="48" height="48" src="blob:http://localhost:9876/1e94edaf-a1cf-4d59-bf72-a54b2b7aca15" align="left" hspace="12" v:shapes="Obraz_x0020_2">
 	<span lang="EN-US"><o:p></o:p></span>
 </p>

+ 6 - 0
packages/ckeditor5-paste-from-office/tests/_utils/utils.js

@@ -147,6 +147,12 @@ function generateNormalizationTests( title, fixtures, editorConfig, skip ) {
 				} );
 		} );
 
+		afterEach( () => {
+			editor.destroy();
+
+			pasteFromOfficePlugin = null;
+		} );
+
 		for ( const name of Object.keys( fixtures.input ) ) {
 			( skip.indexOf( name ) !== -1 ? it.skip : it )( name, () => {
 				const dataTransfer = createDataTransfer( {

+ 179 - 0
packages/ckeditor5-paste-from-office/tests/filters/image.js

@@ -0,0 +1,179 @@
+/**
+ * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+/* globals document, setTimeout */
+
+import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor';
+import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
+import Clipboard from '@ckeditor/ckeditor5-clipboard/src/clipboard';
+import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
+import Image from '@ckeditor/ckeditor5-image/src/image';
+
+import normalizeHtml from '@ckeditor/ckeditor5-utils/tests/_utils/normalizehtml';
+import { setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
+import { stringify as stringifyView } from '@ckeditor/ckeditor5-engine/src/dev-utils/view';
+import { stringify as stringifyModel } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
+
+import PasteFromOffice from '../../src/pastefromoffice';
+import { parseHtml } from '../../src/filters/utils';
+import { replaceImagesSourceWithBase64 } from '../../src/filters/image';
+import { browserFixtures } from '../_data/image/index';
+
+describe( 'Filters', () => {
+	describe( 'image', () => {
+		let editor;
+
+		describe( 'replaceImagesSourceWithBase64', () => {
+			describe( 'with RTF', () => {
+				beforeEach( () => {
+					return VirtualTestEditor
+						.create( {} )
+						.then( editorInstance => {
+							editor = editorInstance;
+						} );
+				} );
+
+				afterEach( () => {
+					editor.destroy();
+				} );
+
+				it( 'should handle correctly empty RTF data', () => {
+					const input = '<p>Foo <img src="file://test.jpg" /></p>';
+					const rtfString = '';
+					const { body } = parseHtml( input );
+
+					replaceImagesSourceWithBase64( body, rtfString, editor.editing.model );
+
+					expect( stringifyView( body ) ).to.equal( normalizeHtml( input ) );
+				} );
+
+				it( 'should not change image with "http://" source', () => {
+					const input = '<p>Foo <img src="http://ckeditor.com/logo.jpg" /></p>';
+					const rtfString = browserFixtures.chrome.inputRtf.onlineOffline;
+					const { body } = parseHtml( input );
+
+					replaceImagesSourceWithBase64( body, rtfString, editor.editing.model );
+
+					expect( stringifyView( body ) ).to.equal( normalizeHtml( input ) );
+				} );
+
+				it( 'should not change image with "file://" source if not images in RTF data', () => {
+					const input = '<p>Foo <img src="file://test.jpg" /></p>';
+					const rtfString = '{\\rtf1\\adeflang1025\\ansi\\ansicpg1252\\uc1\\adeff31507}';
+					const { body } = parseHtml( input );
+
+					replaceImagesSourceWithBase64( body, rtfString, editor.editing.model );
+
+					expect( stringifyView( body ) ).to.equal( normalizeHtml( input ) );
+				} );
+			} );
+
+			describe( 'with Blob', () => {
+				let xhr, requests, element;
+
+				before( () => {
+					element = document.createElement( 'div' );
+
+					document.body.appendChild( element );
+
+					return ClassicTestEditor
+						.create( element, {
+							plugins: [ Clipboard, Paragraph, Image, PasteFromOffice ]
+						} )
+						.then( editorInstance => {
+							editor = editorInstance;
+						} );
+				} );
+
+				beforeEach( () => {
+					setData( editor.model, '<paragraph>[]</paragraph>' );
+
+					xhr = sinon.useFakeXMLHttpRequest();
+					requests = [];
+
+					xhr.onCreate = function( xhrInstance ) {
+						requests.push( xhrInstance );
+					};
+				} );
+
+				afterEach( () => {
+					xhr.restore();
+				} );
+
+				after( () => {
+					editor.destroy();
+
+					element.remove();
+				} );
+
+				it( 'should replace image source when blob successfully fetched', done => {
+					const model = editor.editing.model;
+					const modelData = '<paragraph>Foo</paragraph><image src="blob://http://local/test.jpg"></image>';
+					const input = '<p>Foo<img src="blob://http://local/test.jpg" /></p>';
+					const { body } = parseHtml( input );
+
+					setData( model, modelData );
+
+					replaceImagesSourceWithBase64( body, '', model );
+
+					editor.editing.model.document.on( 'change', () => {
+						const expectedModel = '<paragraph>Foo</paragraph><image src="data:image/jpeg;base64,Rm9vQmFy"></image>';
+
+						try {
+							expect( stringifyModel( model.document.getRoot() ) ).to.equal( expectedModel );
+							done();
+						} catch ( err ) {
+							done( err );
+						}
+					} );
+
+					requests[ 0 ].respond( 200, { 'Content-type': 'image/jpeg' }, 'FooBar' );
+				} );
+
+				it( 'should not replace image source if blob fetching errored', done => {
+					const model = editor.editing.model;
+					const modelData = '<paragraph>Foo</paragraph><image src="blob://http://local/test.jpg"></image>';
+					const input = '<p>Foo<img src="blob://http://local/test.jpg" /></p>';
+					const { body } = parseHtml( input );
+
+					setData( model, modelData );
+
+					replaceImagesSourceWithBase64( body, '', model );
+
+					requests[ 0 ].addEventListener( 'error', () => {
+						// Wait 50ms to validate model.
+						setTimeout( () => {
+							expect( stringifyModel( model.document.getRoot() ) ).to.equal( modelData );
+							done();
+						}, 50 );
+					} );
+
+					requests[ 0 ].error();
+				} );
+
+				it( 'should not replace image source if blob fetching aborted', done => {
+					const model = editor.editing.model;
+					const modelData = '<paragraph>Foo</paragraph><image src="blob://http://local/test.jpg"></image>';
+					const input = '<p>Foo<img src="blob://http://local/test.jpg" /></p>';
+					const { body } = parseHtml( input );
+
+					setData( model, modelData );
+
+					replaceImagesSourceWithBase64( body, '', model );
+
+					requests[ 0 ].addEventListener( 'abort', () => {
+						// Wait 50ms to validate model.
+						setTimeout( () => {
+							expect( stringifyModel( model.document.getRoot() ) ).to.equal( modelData );
+							done();
+						}, 50 );
+					} );
+
+					requests[ 0 ].abort();
+				} );
+			} );
+		} );
+	} );
+} );

+ 1 - 1
packages/ckeditor5-paste-from-office/tests/filters/list.js

@@ -10,7 +10,7 @@ import View from '@ckeditor/ckeditor5-engine/src/view/view';
 import { transformListItemLikeElementsIntoLists } from '../../src/filters/list';
 
 describe( 'Filters', () => {
-	describe( 'List', () => {
+	describe( 'list', () => {
 		const htmlDataProcessor = new HtmlDataProcessor();
 
 		describe( 'transformListItemLikeElementsIntoLists', () => {