Преглед на файлове

Transform content on 'inputTransformation' event instead of 'clipboardInput'.

Krzysztof Krztoń преди 7 години
родител
ревизия
d817605f4c
променени са 1 файла, в които са добавени 4 реда и са изтрити 8 реда
  1. 4 8
      packages/ckeditor5-paste-from-office/src/pastefromoffice.js

+ 4 - 8
packages/ckeditor5-paste-from-office/src/pastefromoffice.js

@@ -8,6 +8,7 @@
  */
 
 import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
+import Clipboard from '@ckeditor/ckeditor5-clipboard/src/clipboard';
 
 import { parseHtml } from './filters/utils';
 import { paragraphsToLists } from './filters/list';
@@ -31,19 +32,14 @@ export default class PasteFromOffice extends Plugin {
 	 */
 	init() {
 		const editor = this.editor;
-		const document = editor.editing.view.document;
 
-		this.listenTo( document, 'clipboardInput', ( evt, data ) => {
+		this.listenTo( editor.plugins.get( Clipboard ), 'inputTransformation', ( evt, data ) => {
 			const html = data.dataTransfer.getData( 'text/html' );
 
 			if ( isWordInput( html ) ) {
-				evt.stop();
-
-				editor.plugins.get( 'Clipboard' ).fire( 'inputTransformation', {
-					content: this._normalizeWordInput( html )
-				} );
+				data.content = this._normalizeWordInput( html );
 			}
-		} );
+		}, { priority: 'high' } );
 	}
 
 	/**