8
0
Quellcode durchsuchen

Handle the most important case when Blink replaces even single space with nbsps.

Piotrek Koszuliński vor 9 Jahren
Ursprung
Commit
3a5449340d
1 geänderte Dateien mit 9 neuen und 1 gelöschten Zeilen
  1. 9 1
      packages/ckeditor5-clipboard/src/utils/normalizeclipboarddata.js

+ 9 - 1
packages/ckeditor5-clipboard/src/utils/normalizeclipboarddata.js

@@ -11,5 +11,13 @@
  */
  */
 export default function normalizeClipboardData( data ) {
 export default function normalizeClipboardData( data ) {
 	return data
 	return data
-		.replace( /<span class="Apple-converted-space">(\s+)<\/span>/g, '$1' );
+		.replace( /<span class="Apple-converted-space">(\s+)<\/span>/g, ( fullMatch, spaces ) => {
+			// Handle the most popular and problematic case when even a single space becomes an nbsp;.
+			// Decode those to normal spaces. Read more in https://github.com/ckeditor/ckeditor5-clipboard/issues/2.
+			if ( spaces.length == 1 ) {
+				return ' ';
+			}
+
+			return spaces;
+		} );
 }
 }