Browse Source

The 'bodyToView' filter return type adjustments.

Krzysztof Krztoń 7 years ago
parent
commit
8e78d8ff95

+ 3 - 2
packages/ckeditor5-paste-from-office/src/filters/common.js

@@ -30,8 +30,9 @@ export function extractBody( data ) {
  * @param {Object} data
  * @param {String} data.body HTML string which should be parsed.
  * @returns {Object} result
- * @returns {module:engine/view/view~View|null} result.view The {@link module:engine/view/view~View} class instance
- * created based on provided HTML string. Return `null` if `data.body` parameter was empty.
+ * @returns {module:engine/view/node~Node|module:engine/view/documentfragment~DocumentFragment|null} result.view
+ * The {@link module:engine/view/view~View} class instance created based on provided HTML string.
+ * Returns `null` if `data.body` parameter was empty.
  */
 export function bodyToView( data ) {
 	data.view = data.body ? htmlDataProcessor.toView( data.body ) : null;

+ 6 - 4
packages/ckeditor5-paste-from-office/src/pastefromword.js

@@ -8,6 +8,7 @@
  */
 
 import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
+import DocumentFragment from '@ckeditor/ckeditor5-engine/src/view/documentfragment';
 
 import { extractBody, bodyToView, extractStyles } from './filters/common';
 import { paragraphsToLists } from './filters/list';
@@ -52,18 +53,19 @@ export default class PasteFromWord extends Plugin {
 	 * @private
 	 * @param {module:core/editor/editor~Editor} editor Editor instance.
 	 * @param {String} input Word input.
-	 * @returns {module:engine/view/view~View} view Normalized input as {module:engine/view/view~View} instance.
+	 * @returns {module:engine/view/node~Node|module:engine/view/documentfragment~DocumentFragment} view Normalized input.
 	 */
 	_normalizeWordInput( input, editor ) {
 		const editorDocument = editor.editing.view.getDomRoot();
 		const ownerDocument = editorDocument ? editorDocument.ownerDocument : null;
 
-		return transformInput( input, ownerDocument,
+		const transofrmedInput = transformInput( input, ownerDocument,
 			extractBody,
 			bodyToView,
 			extractStyles,
-			paragraphsToLists
-		).view;
+			paragraphsToLists );
+
+		return transofrmedInput.view || new DocumentFragment();
 	}
 }