瀏覽代碼

Merge branch 'master' into ckeditor5/t/1214

Piotrek Koszuliński 7 年之前
父節點
當前提交
e7b085a22b

+ 12 - 0
packages/ckeditor5-list/CHANGELOG.md

@@ -1,6 +1,18 @@
 Changelog
 =========
 
+## [11.0.3](https://github.com/ckeditor/ckeditor5-list/compare/v11.0.2...v11.0.3) (2018-12-05)
+
+### Bug fixes
+
+* Block filler will be inserted into the list item if its last child is a `<br>` element. Closes [ckeditor/ckeditor5#1312](https://github.com/ckeditor/ckeditor5/issues/1312). ([cb6708e](https://github.com/ckeditor/ckeditor5-list/commit/cb6708e))
+* Preserve correct order of block elements inside list items during the view to model conversion. Closes [ckeditor/ckeditor5#1263](https://github.com/ckeditor/ckeditor5/issues/1263). ([abccef4](https://github.com/ckeditor/ckeditor5-list/commit/abccef4))
+
+### Other changes
+
+* Improved SVG icons size. See [ckeditor/ckeditor5-theme-lark#206](https://github.com/ckeditor/ckeditor5-theme-lark/issues/206). ([d424329](https://github.com/ckeditor/ckeditor5-list/commit/d424329))
+
+
 ## [11.0.2](https://github.com/ckeditor/ckeditor5-list/compare/v11.0.1...v11.0.2) (2018-10-08)
 
 ### Other changes

+ 16 - 16
packages/ckeditor5-list/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@ckeditor/ckeditor5-list",
-  "version": "11.0.2",
+  "version": "11.0.3",
   "description": "Ordered and unordered lists feature to CKEditor 5.",
   "keywords": [
     "ckeditor",
@@ -10,24 +10,24 @@
     "ckeditor5-plugin"
   ],
   "dependencies": {
-    "@ckeditor/ckeditor5-core": "^11.0.1",
-    "@ckeditor/ckeditor5-paragraph": "^10.0.3",
-    "@ckeditor/ckeditor5-ui": "^11.1.0",
-    "@ckeditor/ckeditor5-utils": "^11.0.0"
+    "@ckeditor/ckeditor5-core": "^11.1.0",
+    "@ckeditor/ckeditor5-engine": "^12.0.0",
+    "@ckeditor/ckeditor5-paragraph": "^10.0.4",
+    "@ckeditor/ckeditor5-ui": "^11.2.0",
+    "@ckeditor/ckeditor5-utils": "^11.1.0"
   },
   "devDependencies": {
-    "@ckeditor/ckeditor5-basic-styles": "^10.0.3",
-    "@ckeditor/ckeditor5-block-quote": "^10.1.0",
-    "@ckeditor/ckeditor5-clipboard": "^10.0.3",
-    "@ckeditor/ckeditor5-editor-classic": "^11.0.1",
-    "@ckeditor/ckeditor5-engine": "^11.0.0",
-    "@ckeditor/ckeditor5-enter": "^10.1.2",
-    "@ckeditor/ckeditor5-heading": "^10.1.0",
-    "@ckeditor/ckeditor5-link": "^10.0.4",
-    "@ckeditor/ckeditor5-typing": "^11.0.1",
-    "@ckeditor/ckeditor5-undo": "^10.0.3",
+    "@ckeditor/ckeditor5-basic-styles": "^10.1.0",
+    "@ckeditor/ckeditor5-block-quote": "^10.1.1",
+    "@ckeditor/ckeditor5-clipboard": "^10.0.4",
+    "@ckeditor/ckeditor5-editor-classic": "^11.0.2",
+    "@ckeditor/ckeditor5-enter": "^10.1.3",
+    "@ckeditor/ckeditor5-heading": "^10.1.1",
+    "@ckeditor/ckeditor5-link": "^10.1.0",
+    "@ckeditor/ckeditor5-typing": "^11.0.2",
+    "@ckeditor/ckeditor5-undo": "^10.0.4",
     "eslint": "^5.5.0",
-    "eslint-config-ckeditor5": "^1.0.7",
+    "eslint-config-ckeditor5": "^1.0.9",
     "husky": "^0.14.3",
     "lint-staged": "^7.0.0"
   },

+ 7 - 7
packages/ckeditor5-list/src/converters.js

@@ -93,7 +93,7 @@ export function modelViewRemove( model ) {
  * @see module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:attribute
  * @param {module:utils/eventinfo~EventInfo} evt An object containing information about the fired event.
  * @param {Object} data Additional information about the change.
- * @param {Object} conversionApi Conversion interface.
+ * @param {module:engine/conversion/downcastdispatcher~DowncastConversionApi} conversionApi Conversion interface.
  */
 export function modelViewChangeType( evt, data, conversionApi ) {
 	if ( !conversionApi.consumable.consume( data.item, 'attribute:listType' ) ) {
@@ -190,7 +190,7 @@ export function modelViewChangeIndent( model ) {
  * @see module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:insert
  * @param {module:utils/eventinfo~EventInfo} evt An object containing information about the fired event.
  * @param {Object} data Additional information about the change.
- * @param {Object} conversionApi Conversion interface.
+ * @param {module:engine/conversion/downcastdispatcher~DowncastConversionApi} conversionApi Conversion interface.
  */
 export function modelViewSplitOnInsert( evt, data, conversionApi ) {
 	if ( data.item.name != 'listItem' ) {
@@ -311,7 +311,7 @@ export function modelViewSplitOnInsert( evt, data, conversionApi ) {
  * @see module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:remove
  * @param {module:utils/eventinfo~EventInfo} evt An object containing information about the fired event.
  * @param {Object} data Additional information about the change.
- * @param {Object} conversionApi Conversion interface.
+ * @param {module:engine/conversion/downcastdispatcher~DowncastConversionApi} conversionApi Conversion interface.
  */
 export function modelViewMergeAfter( evt, data, conversionApi ) {
 	const viewPosition = conversionApi.mapper.toViewPosition( data.position );
@@ -334,7 +334,7 @@ export function modelViewMergeAfter( evt, data, conversionApi ) {
  * @see module:engine/conversion/upcastdispatcher~UpcastDispatcher#event:element
  * @param {module:utils/eventinfo~EventInfo} evt An object containing information about the fired event.
  * @param {Object} data An object containing conversion input and a placeholder for conversion output and possibly other values.
- * @param {Object} conversionApi Conversion interface to be used by the callback.
+ * @param {module:engine/conversion/upcastdispatcher~UpcastConversionApi} conversionApi Conversion interface to be used by the callback.
  */
 export function viewModelConverter( evt, data, conversionApi ) {
 	if ( conversionApi.consumable.consume( data.viewItem, { name: true } ) ) {
@@ -392,7 +392,7 @@ export function viewModelConverter( evt, data, conversionApi ) {
  * @see module:engine/conversion/upcastdispatcher~UpcastDispatcher#event:element
  * @param {module:utils/eventinfo~EventInfo} evt An object containing information about the fired event.
  * @param {Object} data An object containing conversion input and a placeholder for conversion output and possibly other values.
- * @param {Object} conversionApi Conversion interface to be used by the callback.
+ * @param {module:engine/conversion/upcastdispatcher~UpcastConversionApi} conversionApi Conversion interface to be used by the callback.
  */
 export function cleanList( evt, data, conversionApi ) {
 	if ( conversionApi.consumable.test( data.viewItem, { name: true } ) ) {
@@ -413,7 +413,7 @@ export function cleanList( evt, data, conversionApi ) {
  * @see module:engine/conversion/upcastdispatcher~UpcastDispatcher#event:element
  * @param {module:utils/eventinfo~EventInfo} evt An object containing information about the fired event.
  * @param {Object} data An object containing conversion input and a placeholder for conversion output and possibly other values.
- * @param {Object} conversionApi Conversion interface to be used by the callback.
+ * @param {module:engine/conversion/upcastdispatcher~UpcastConversionApi} conversionApi Conversion interface to be used by the callback.
  */
 export function cleanListItem( evt, data, conversionApi ) {
 	if ( conversionApi.consumable.test( data.viewItem, { name: true } ) ) {
@@ -806,7 +806,7 @@ function generateLiInUl( modelItem, conversionApi ) {
 //
 // @param {module:engine/model/element~Element} listItemModel List item model element to which converted children will be inserted.
 // @param {Iterable.<module:engine/view/node~Node>} viewChildren View elements which will be converted.
-// @param {Object} conversionApi Conversion interface to be used by the callback.
+// @param {module:engine/conversion/upcastdispatcher~UpcastConversionApi} conversionApi Conversion interface to be used by the callback.
 // @returns {module:engine/model/position~Position} Position on which next elements should be inserted after children conversion.
 function viewToModelListItemChildrenConverter( listItemModel, viewChildren, conversionApi ) {
 	const writer = conversionApi.writer;

+ 9 - 3
packages/ckeditor5-list/src/utils.js

@@ -7,6 +7,8 @@
  * @module list/utils
  */
 
+import { getFillerOffset } from '@ckeditor/ckeditor5-engine/src/view/containerelement';
+
 /**
  * Creates list item {@link module:engine/view/containerelement~ContainerElement}.
  *
@@ -15,7 +17,7 @@
  */
 export function createViewListItemElement( writer ) {
 	const viewItem = writer.createContainerElement( 'li' );
-	viewItem.getFillerOffset = getFillerOffset;
+	viewItem.getFillerOffset = getListItemFillerOffset;
 
 	return viewItem;
 }
@@ -23,8 +25,12 @@ export function createViewListItemElement( writer ) {
 // Implementation of getFillerOffset for view list item element.
 //
 // @returns {Number|null} Block filler offset or `null` if block filler is not needed.
-function getFillerOffset() {
+function getListItemFillerOffset() {
 	const hasOnlyLists = !this.isEmpty && ( this.getChild( 0 ).name == 'ul' || this.getChild( 0 ).name == 'ol' );
 
-	return this.isEmpty || hasOnlyLists ? 0 : null;
+	if ( this.isEmpty || hasOnlyLists ) {
+		return 0;
+	}
+
+	return getFillerOffset.call( this );
 }

+ 10 - 9
packages/ckeditor5-list/tests/listediting.js

@@ -17,8 +17,6 @@ import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtest
 import { getData as getModelData, parse as parseModel, setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 import { getData as getViewData, parse as parseView } from '@ckeditor/ckeditor5-engine/src/dev-utils/view';
 
-import { insertElement } from '@ckeditor/ckeditor5-engine/src/conversion/downcast-converters';
-import { upcastElementToElement } from '@ckeditor/ckeditor5-engine/src/conversion/upcast-converters';
 import { getCode } from '@ckeditor/ckeditor5-utils/src/keyboard';
 
 describe( 'ListEditing', () => {
@@ -345,6 +343,10 @@ describe( 'ListEditing', () => {
 				'<p>foo</p><ul><li>xxx</li><li>yyy</li></ul>'
 			);
 
+			// #ckeditor5/1399
+			test( 'single item with `font-weight` style',
+				'<ol><li style="font-weight: bold">foo</li></ol>', '<ol><li><strong>foo</strong></li></ol>' );
+
 			it( 'model test for mixed content', () => {
 				editor.setData( '<ol><li>a</li></ol><p>xxx</p><ul><li>b</li><li>c</li></ul><p>yyy</p><ul><li>d</li></ul>' );
 
@@ -3813,12 +3815,11 @@ describe( 'ListEditing', () => {
 			editor.editing.downcastDispatcher.on( 'insert:listItem', ( evt, data, conversionApi ) => {
 				conversionApi.consumable.consume( data.item, 'attribute:listType' );
 				conversionApi.consumable.consume( data.item, 'attribute:listIndent' );
-
-				const converter = insertElement( ( modelElement, viewWriter ) => viewWriter.createContainerElement( 'p' ) );
-
-				return converter( evt, data, conversionApi );
 			}, { priority: 'highest' } );
 
+			editor.conversion.for( 'downcast' )
+				.elementToElement( { model: 'listItem', view: 'p', converterPriority: 'highest' } );
+
 			// Paragraph is needed, otherwise selection throws.
 			setModelData( model, '<paragraph>x</paragraph><listItem listIndent="0" listType="bulleted">y</listItem>' );
 
@@ -4022,7 +4023,7 @@ describe( 'ListEditing', () => {
 		} );
 
 		it( 'should split parent element when one of modelCursor ancestors allows to insert list - in the middle', () => {
-			editor.conversion.for( 'upcast' ).add( upcastElementToElement( { view: 'div', model: 'div' } ) );
+			editor.conversion.for( 'upcast' ).elementToElement( { view: 'div', model: 'div' } );
 			model.schema.register( 'div', { inheritAllFrom: '$block' } );
 
 			editor.setData(
@@ -4043,7 +4044,7 @@ describe( 'ListEditing', () => {
 		} );
 
 		it( 'should split parent element when one of modelCursor ancestors allows to insert list - at the end', () => {
-			editor.conversion.for( 'upcast' ).add( upcastElementToElement( { view: 'div', model: 'div' } ) );
+			editor.conversion.for( 'upcast' ).elementToElement( { view: 'div', model: 'div' } );
 			model.schema.register( 'div', { inheritAllFrom: '$block' } );
 
 			editor.setData(
@@ -4062,7 +4063,7 @@ describe( 'ListEditing', () => {
 		} );
 
 		it( 'should split parent element when one of modelCursor ancestors allows to insert list - at the beginning', () => {
-			editor.conversion.for( 'upcast' ).add( upcastElementToElement( { view: 'div', model: 'div' } ) );
+			editor.conversion.for( 'upcast' ).elementToElement( { view: 'div', model: 'div' } );
 			model.schema.register( 'div', { inheritAllFrom: '$block' } );
 
 			editor.setData(

+ 62 - 0
packages/ckeditor5-list/tests/utils.js

@@ -69,6 +69,68 @@ describe( 'utils', () => {
 
 				expect( item.getFillerOffset() ).to.be.null;
 			} );
+
+			// Block filler is required after the `<br>` element if the element is the last child in the container.
+			// See: https://github.com/ckeditor/ckeditor5/issues/1312#issuecomment-436669045.
+			describe( 'for <br> elements in container', () => {
+				it( 'returns offset of the last child which is the <br> element (1)', () => {
+					const item = createViewListItemElement( writer );
+
+					writer.insert( writer.createPositionAt( item, 0 ), writer.createEmptyElement( 'br' ) );
+
+					expect( item.getFillerOffset() ).to.equal( 1 );
+				} );
+
+				it( 'returns offset of the last child which is the <br> element (2)', () => {
+					const item = createViewListItemElement( writer );
+
+					writer.insert( writer.createPositionAt( item, 0 ), writer.createEmptyElement( 'br' ) );
+					writer.insert( writer.createPositionAt( item, 1 ), writer.createEmptyElement( 'br' ) );
+
+					expect( item.getFillerOffset() ).to.equal( 2 );
+				} );
+
+				it( 'always returns the last <br> element in the container', () => {
+					const item = createViewListItemElement( writer );
+
+					writer.insert( writer.createPositionAt( item, 0 ), writer.createText( 'foo' ) );
+					writer.insert( writer.createPositionAt( item, 1 ), writer.createEmptyElement( 'br' ) );
+					writer.insert( writer.createPositionAt( item, 2 ), writer.createEmptyElement( 'br' ) );
+
+					expect( item.getFillerOffset() ).to.equal( 3 );
+				} );
+
+				it( 'works fine with non-empty container with multi <br> elements', () => {
+					const item = createViewListItemElement( writer );
+
+					writer.insert( writer.createPositionAt( item, 0 ), writer.createText( 'foo' ) );
+					writer.insert( writer.createPositionAt( item, 1 ), writer.createEmptyElement( 'br' ) );
+					writer.insert( writer.createPositionAt( item, 2 ), writer.createText( 'bar' ) );
+					writer.insert( writer.createPositionAt( item, 3 ), writer.createEmptyElement( 'br' ) );
+
+					expect( item.getFillerOffset() ).to.equal( 4 );
+				} );
+
+				it( 'ignores the ui elements', () => {
+					const item = createViewListItemElement( writer );
+
+					writer.insert( writer.createPositionAt( item, 0 ), writer.createUIElement( 'span' ) );
+					writer.insert( writer.createPositionAt( item, 1 ), writer.createEmptyElement( 'br' ) );
+
+					expect( item.getFillerOffset() ).to.equal( 2 );
+				} );
+
+				it( 'empty element must be the <br> element', () => {
+					const item = createViewListItemElement( writer );
+
+					writer.insert(
+						writer.createPositionAt( item, 0 ),
+						writer.createEmptyElement( 'img' )
+					);
+
+					expect( item.getFillerOffset() ).to.be.null;
+				} );
+			} );
 		} );
 	} );
 } );

+ 1 - 1
packages/ckeditor5-list/theme/icons/bulletedlist.svg

@@ -1 +1 @@
-<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M7 5.75c0 .414.336.75.75.75h9.5a.75.75 0 1 0 0-1.5h-9.5a.75.75 0 0 0-.75.75zm-6 0C1 4.784 1.777 4 2.75 4c.966 0 1.75.777 1.75 1.75 0 .966-.777 1.75-1.75 1.75C1.784 7.5 1 6.723 1 5.75zm6 9c0 .414.336.75.75.75h9.5a.75.75 0 1 0 0-1.5h-9.5a.75.75 0 0 0-.75.75zm-6 0c0-.966.777-1.75 1.75-1.75.966 0 1.75.777 1.75 1.75 0 .966-.777 1.75-1.75 1.75-.966 0-1.75-.777-1.75-1.75z" fill="#454545" fill-rule="evenodd"/></svg>
+<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M7 5.75c0 .414.336.75.75.75h9.5a.75.75 0 1 0 0-1.5h-9.5a.75.75 0 0 0-.75.75zm-6 0C1 4.784 1.777 4 2.75 4c.966 0 1.75.777 1.75 1.75 0 .966-.777 1.75-1.75 1.75C1.784 7.5 1 6.723 1 5.75zm6 9c0 .414.336.75.75.75h9.5a.75.75 0 1 0 0-1.5h-9.5a.75.75 0 0 0-.75.75zm-6 0c0-.966.777-1.75 1.75-1.75.966 0 1.75.777 1.75 1.75 0 .966-.777 1.75-1.75 1.75-.966 0-1.75-.777-1.75-1.75z"/></svg>

+ 1 - 1
packages/ckeditor5-list/theme/icons/numberedlist.svg

@@ -1 +1 @@
-<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M7 5.75c0 .414.336.75.75.75h9.5a.75.75 0 1 0 0-1.5h-9.5a.75.75 0 0 0-.75.75zM3.5 3v5H2V3.7H1v-1h2.5V3zM.343 17.857l2.59-3.257H2.92a.6.6 0 1 0-1.04 0H.302a2 2 0 1 1 3.995 0h-.001c-.048.405-.16.734-.333.988-.175.254-.59.692-1.244 1.312H4.3v1h-4l.043-.043zM7 14.75a.75.75 0 0 1 .75-.75h9.5a.75.75 0 1 1 0 1.5h-9.5a.75.75 0 0 1-.75-.75z" fill="#454545" fill-rule="evenodd"/></svg>
+<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M7 5.75c0 .414.336.75.75.75h9.5a.75.75 0 1 0 0-1.5h-9.5a.75.75 0 0 0-.75.75zM3.5 3v5H2V3.7H1v-1h2.5V3zM.343 17.857l2.59-3.257H2.92a.6.6 0 1 0-1.04 0H.302a2 2 0 1 1 3.995 0h-.001c-.048.405-.16.734-.333.988-.175.254-.59.692-1.244 1.312H4.3v1h-4l.043-.043zM7 14.75a.75.75 0 0 1 .75-.75h9.5a.75.75 0 1 1 0 1.5h-9.5a.75.75 0 0 1-.75-.75z"/></svg>