8
0
فهرست منبع

Fix #7958 by checking for valid `firstChild`.

Tomi Blinnikka 5 سال پیش
والد
کامیت
0ac2ed9322

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

@@ -93,7 +93,7 @@ export function unwrapParagraphInListItem( documentFragment, writer ) {
 			// Google Docs allows on single paragraph inside LI.
 			const firstChild = element.getChild( 0 );
 
-			if ( firstChild.is( 'element', 'p' ) ) {
+			if ( firstChild && firstChild.is( 'element', 'p' ) ) {
 				writer.unwrapElement( firstChild );
 			}
 		}

+ 1 - 0
packages/ckeditor5-paste-from-office/tests/_data/paste-from-google-docs/lists/empty-list-item/input.html

@@ -0,0 +1 @@
+<meta charset='utf-8'><meta charset="utf-8"><b style="font-weight:normal;" id="docs-internal-guid-7f8963f3-7fff-683a-b3de-156ff66d4860"><ul style="margin-top:0;margin-bottom:0;"><li dir="ltr" style="list-style-type:disc;font-size:11pt;font-family:Arial;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;"><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt;" role="presentation"><span style="font-size:11pt;font-family:Arial;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">Item 1</span></p></li><li dir="ltr" style="list-style-type:disc;font-size:11pt;font-family:Arial;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;"><br /></li></ul></b>

+ 1 - 0
packages/ckeditor5-paste-from-office/tests/_data/paste-from-google-docs/lists/empty-list-item/model.html

@@ -0,0 +1 @@
+<listItem listIndent="0" listType="bulleted">Item 1</listItem><listItem listIndent="0" listType="bulleted"></listItem>

+ 7 - 2
packages/ckeditor5-paste-from-office/tests/_data/paste-from-google-docs/lists/index.js

@@ -15,18 +15,23 @@ import repeatedlyNestedListModel from './repeatedly-nested-list/model.html';
 import partiallySelected from './partially-selected/input.html';
 import partiallySelectedModel from './partially-selected/model.html';
 
+import emptyListItem from './empty-list-item/input.html';
+import emptyListItemModel from './empty-list-item/model.html';
+
 export const fixtures = {
 	input: {
 		nestedOrderedList,
 		mixedList,
 		repeatedlyNestedList,
-		partiallySelected
+		partiallySelected,
+		emptyListItem
 	},
 	model: {
 		nestedOrderedList: nestedOrderedListModel,
 		mixedList: mixedListModel,
 		repeatedlyNestedList: repeatedlyNestedListModel,
-		partiallySelected: partiallySelectedModel
+		partiallySelected: partiallySelectedModel,
+		emptyListItem: emptyListItemModel
 	}
 };