Kaynağa Gözat

Merge branch 'master' into i/3287

Maciej Gołaszewski 6 yıl önce
ebeveyn
işleme
cfdb03c309

+ 27 - 0
packages/ckeditor5-engine/CHANGELOG.md

@@ -1,6 +1,33 @@
 Changelog
 =========
 
+## [15.0.0](https://github.com/ckeditor/ckeditor5-engine/compare/v14.0.0...v15.0.0) (2019-10-23)
+
+### MAJOR BREAKING CHANGES
+
+* The behavior of block filler detection on DOM to view conversion was changed. Now, it specifically checks the parent of a text node to check whether it is a block. Which means that a list of block element names has to be used. If you use custom elements or use one of the HTML elements which CKEditor 5 does not recognize as a block element, see [#404](https://github.com/ckeditor/ckeditor5-engine/issues/404) and `DomConverter.blockElements` documentation.
+* The `Selection#getTopMostBlocks()` was removed from the public API. Use `Selection#getSelectedBlocks()` instead.
+* The `Selection#getSelectedBlocks()` does not return blocks nested in other blocks now.
+
+### Features
+
+* Added support for creating elements from other XML namespaces. See [ckeditor/ckeditor5#2088](https://github.com/ckeditor/ckeditor5/issues/2088). ([a9190c9](https://github.com/ckeditor/ckeditor5-engine/commit/a9190c9))
+
+### Bug fixes
+
+* Added a proper check for name-only view matcher in attribute upcast converters. Closes [#1786](https://github.com/ckeditor/ckeditor5-engine/issues/1786). ([2210696](https://github.com/ckeditor/ckeditor5-engine/commit/2210696))
+* Improved filtering out disallowed attributes on child elements. [#1789](https://github.com/ckeditor/ckeditor5-engine/issues/1789). ([c5033b6](https://github.com/ckeditor/ckeditor5-engine/commit/c5033b6))
+* Improved performance when working with fake selections. Closes [#1791](https://github.com/ckeditor/ckeditor5-engine/issues/1791). ([f073ad5](https://github.com/ckeditor/ckeditor5-engine/commit/f073ad5))
+* Placeholder should not be visible in the read-only mode. Closes [ckeditor/ckeditor5#1987](https://github.com/ckeditor/ckeditor5/issues/1987). ([730c417](https://github.com/ckeditor/ckeditor5-engine/commit/730c417))
+* Remove only real block fillers on DOM to view conversion. Closes [#404](https://github.com/ckeditor/ckeditor5-engine/issues/404). ([6d2810b](https://github.com/ckeditor/ckeditor5-engine/commit/6d2810b))
+* The renderer should not update DOM selection when document has active composition. Closes [#1782](https://github.com/ckeditor/ckeditor5-engine/issues/1782). Closes [ckeditor/ckeditor5#1333](https://github.com/ckeditor/ckeditor5/issues/1333). ([c698683](https://github.com/ckeditor/ckeditor5-engine/commit/c698683))
+
+### Other changes
+
+* Added error handling to the common code execution paths. Part of [ckeditor/ckeditor5#1304](https://github.com/ckeditor/ckeditor5/issues/1304). ([220b52f](https://github.com/ckeditor/ckeditor5-engine/commit/220b52f))
+* Removed the `Selection#getTopMostBlocks()` method. Closes [ckeditor/ckeditor5-widget#95](https://github.com/ckeditor/ckeditor5-widget/issues/95). Closes [ckeditor/ckeditor5-table#199](https://github.com/ckeditor/ckeditor5-table/issues/199). ([7970f17](https://github.com/ckeditor/ckeditor5-engine/commit/7970f17))
+
+
 ## [14.0.0](https://github.com/ckeditor/ckeditor5-engine/compare/v13.2.1...v14.0.0) (2019-08-26)
 
 ### Features

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

@@ -1,6 +1,6 @@
 {
   "name": "@ckeditor/ckeditor5-engine",
-  "version": "14.0.0",
+  "version": "15.0.0",
   "description": "The editing engine of CKEditor 5 – the best browser-based rich text editor.",
   "keywords": [
     "wysiwyg",
@@ -21,24 +21,24 @@
     "ckeditor 5"
   ],
   "dependencies": {
-    "@ckeditor/ckeditor5-utils": "^14.0.0",
+    "@ckeditor/ckeditor5-utils": "^15.0.0",
     "lodash-es": "^4.17.10"
   },
   "devDependencies": {
-    "@ckeditor/ckeditor5-basic-styles": "^11.1.4",
-    "@ckeditor/ckeditor5-block-quote": "^11.1.3",
-    "@ckeditor/ckeditor5-core": "^12.3.0",
-    "@ckeditor/ckeditor5-editor-classic": "^12.1.4",
-    "@ckeditor/ckeditor5-enter": "^11.1.0",
-    "@ckeditor/ckeditor5-essentials": "^11.0.5",
-    "@ckeditor/ckeditor5-heading": "^11.0.5",
-    "@ckeditor/ckeditor5-link": "^11.1.2",
-    "@ckeditor/ckeditor5-list": "^12.1.0",
-    "@ckeditor/ckeditor5-paragraph": "^11.0.5",
-    "@ckeditor/ckeditor5-theme-lark": "^14.2.0",
-    "@ckeditor/ckeditor5-typing": "^12.2.0",
-    "@ckeditor/ckeditor5-undo": "^11.0.5",
-    "@ckeditor/ckeditor5-widget": "^11.1.0",
+    "@ckeditor/ckeditor5-basic-styles": "^15.0.0",
+    "@ckeditor/ckeditor5-block-quote": "^15.0.0",
+    "@ckeditor/ckeditor5-core": "^15.0.0",
+    "@ckeditor/ckeditor5-editor-classic": "^15.0.0",
+    "@ckeditor/ckeditor5-enter": "^15.0.0",
+    "@ckeditor/ckeditor5-essentials": "^15.0.0",
+    "@ckeditor/ckeditor5-heading": "^15.0.0",
+    "@ckeditor/ckeditor5-link": "^15.0.0",
+    "@ckeditor/ckeditor5-list": "^15.0.0",
+    "@ckeditor/ckeditor5-paragraph": "^15.0.0",
+    "@ckeditor/ckeditor5-theme-lark": "^15.0.0",
+    "@ckeditor/ckeditor5-typing": "^15.0.0",
+    "@ckeditor/ckeditor5-undo": "^15.0.0",
+    "@ckeditor/ckeditor5-widget": "^15.0.0",
     "eslint": "^5.5.0",
     "eslint-config-ckeditor5": "^2.0.0",
     "husky": "^1.3.1",

+ 1 - 1
packages/ckeditor5-engine/src/model/writer.js

@@ -1328,7 +1328,7 @@ export default class Writer {
 	 */
 	_assertWriterUsedCorrectly() {
 		/**
-		 * Trying to use a writer outside a {@link module:engine/model/model~Model#change `change()` or
+		 * Trying to use a writer outside a {@link module:engine/model/model~Model#change `change()`} or
 		 * {@link module:engine/model/model~Model#enqueueChange `enqueueChange()`} blocks.
 		 *
 		 * The writer can only be used inside these blocks which ensures that the model

+ 32 - 24
packages/ckeditor5-engine/src/view/downcastwriter.js

@@ -81,7 +81,7 @@ export default class DowncastWriter {
 	 *		writer.setSelection( position );
 	 *
 	 * 		// Sets collapsed selection at the position of given item and offset.
-	 *		const paragraph = writer.createContainerElement( 'paragraph' );
+	 *		const paragraph = writer.createContainerElement( 'p' );
 	 *		writer.setSelection( paragraph, offset );
 	 *
 	 * Creates a range inside an {@link module:engine/view/element~Element element} which starts before the first child of
@@ -152,13 +152,13 @@ export default class DowncastWriter {
 	 * Creates new {@link module:engine/view/attributeelement~AttributeElement}.
 	 *
 	 *		writer.createAttributeElement( 'strong' );
-	 *		writer.createAttributeElement( 'strong', { alignment: 'center' } );
+	 *		writer.createAttributeElement( 'a', { href: 'foo.bar' } );
 	 *
 	 *		// Make `<a>` element contain other attributes element so the `<a>` element is not broken.
 	 *		writer.createAttributeElement( 'a', { href: 'foo.bar' }, { priority: 5 } );
 	 *
 	 *		// Set `id` of a marker element so it is not joined or merged with "normal" elements.
-	 *		writer.createAttributeElement( 'span', { class: 'myMarker' }, { id: 'marker:my' } );
+	 *		writer.createAttributeElement( 'span', { class: 'my-marker' }, { id: 'marker:my' } );
 	 *
 	 * @param {String} name Name of the element.
 	 * @param {Object} [attributes] Element's attributes.
@@ -184,8 +184,16 @@ export default class DowncastWriter {
 	/**
 	 * Creates new {@link module:engine/view/containerelement~ContainerElement}.
 	 *
-	 *		writer.createContainerElement( 'paragraph' );
-	 *		writer.createContainerElement( 'paragraph', { alignment: 'center' } );
+	 *		writer.createContainerElement( 'p' );
+	 *
+	 *		// Create element with custom attributes.
+	 *		writer.createContainerElement( 'div', { id: 'foo-bar', 'data-baz': '123' } );
+	 *
+	 *		// Create element with custom styles.
+	 *		writer.createContainerElement( 'p', { style: 'font-weight: bold; padding-bottom: 10px' } );
+	 *
+	 *		// Create element with custom classes.
+	 *		writer.createContainerElement( 'p', { class: 'foo bar baz' } );
 	 *
 	 * @param {String} name Name of the element.
 	 * @param {Object} [attributes] Elements attributes.
@@ -199,7 +207,7 @@ export default class DowncastWriter {
 	 * Creates new {@link module:engine/view/editableelement~EditableElement}.
 	 *
 	 *		writer.createEditableElement( 'div' );
-	 *		writer.createEditableElement( 'div', { alignment: 'center' } );
+	 *		writer.createEditableElement( 'div', { id: 'foo-1234' } );
 	 *
 	 * @param {String} name Name of the element.
 	 * @param {Object} [attributes] Elements attributes.
@@ -216,7 +224,7 @@ export default class DowncastWriter {
 	 * Creates new {@link module:engine/view/emptyelement~EmptyElement}.
 	 *
 	 *		writer.createEmptyElement( 'img' );
-	 *		writer.createEmptyElement( 'img', { alignment: 'center' } );
+	 *		writer.createEmptyElement( 'img', { id: 'foo-1234' } );
 	 *
 	 * @param {String} name Name of the element.
 	 * @param {Object} [attributes] Elements attributes.
@@ -230,7 +238,7 @@ export default class DowncastWriter {
 	 * Creates new {@link module:engine/view/uielement~UIElement}.
 	 *
 	 *		writer.createUIElement( 'span' );
-	 *		writer.createUIElement( 'span', { alignment: 'center' } );
+	 *		writer.createUIElement( 'span', { id: 'foo-1234' } );
 	 *
 	 * Custom render function can be provided as third parameter:
 	 *
@@ -370,10 +378,10 @@ export default class DowncastWriter {
 	 *
 	 * In following examples `<p>` is a container, `<b>` and `<u>` are attribute nodes:
 	 *
-	 *        <p>foo<b><u>bar{}</u></b></p> -> <p>foo<b><u>bar</u></b>[]</p>
-	 *        <p>foo<b><u>{}bar</u></b></p> -> <p>foo{}<b><u>bar</u></b></p>
-	 *        <p>foo<b><u>b{}ar</u></b></p> -> <p>foo<b><u>b</u></b>[]<b><u>ar</u></b></p>
-	 *        <p><b>fo{o</b><u>ba}r</u></p> -> <p><b>fo</b><b>o</b><u>ba</u><u>r</u></b></p>
+	 *		<p>foo<b><u>bar{}</u></b></p> -> <p>foo<b><u>bar</u></b>[]</p>
+	 *		<p>foo<b><u>{}bar</u></b></p> -> <p>foo{}<b><u>bar</u></b></p>
+	 *		<p>foo<b><u>b{}ar</u></b></p> -> <p>foo<b><u>b</u></b>[]<b><u>ar</u></b></p>
+	 *		<p><b>fo{o</b><u>ba}r</u></p> -> <p><b>fo</b><b>o</b><u>ba</u><u>r</u></b></p>
 	 *
 	 * **Note:** {@link module:engine/view/documentfragment~DocumentFragment DocumentFragment} is treated like a container.
 	 *
@@ -416,10 +424,10 @@ export default class DowncastWriter {
 	 * has to be directly inside container element and cannot be in root. Does not break if position is at the beginning
 	 * or at the end of it's parent element.
 	 *
-	 *        <p>foo^bar</p> -> <p>foo</p><p>bar</p>
-	 *        <div><p>foo</p>^<p>bar</p></div> -> <div><p>foo</p></div><div><p>bar</p></div>
-	 *        <p>^foobar</p> -> ^<p>foobar</p>
-	 *        <p>foobar^</p> -> <p>foobar</p>^
+	 *		<p>foo^bar</p> -> <p>foo</p><p>bar</p>
+	 *		<div><p>foo</p>^<p>bar</p></div> -> <div><p>foo</p></div><div><p>bar</p></div>
+	 *		<p>^foobar</p> -> ^<p>foobar</p>
+	 *		<p>foobar^</p> -> <p>foobar</p>^
 	 *
 	 * **Note:** Difference between {@link module:engine/view/downcastwriter~DowncastWriter#breakAttributes breakAttributes} and
 	 * {@link module:engine/view/downcastwriter~DowncastWriter#breakContainer breakContainer} is that `breakAttributes` breaks all
@@ -480,14 +488,14 @@ export default class DowncastWriter {
 	 *
 	 * In following examples `<p>` is a container and `<b>` is an attribute element:
 	 *
-	 *        <p>foo[]bar</p> -> <p>foo{}bar</p>
-	 *        <p><b>foo</b>[]<b>bar</b></p> -> <p><b>foo{}bar</b></p>
-	 *        <p><b foo="bar">a</b>[]<b foo="baz">b</b></p> -> <p><b foo="bar">a</b>[]<b foo="baz">b</b></p>
+	 *		<p>foo[]bar</p> -> <p>foo{}bar</p>
+	 *		<p><b>foo</b>[]<b>bar</b></p> -> <p><b>foo{}bar</b></p>
+	 *		<p><b foo="bar">a</b>[]<b foo="baz">b</b></p> -> <p><b foo="bar">a</b>[]<b foo="baz">b</b></p>
 	 *
 	 * It will also take care about empty attributes when merging:
 	 *
-	 *        <p><b>[]</b></p> -> <p>[]</p>
-	 *        <p><b>foo</b><i>[]</i><b>bar</b></p> -> <p><b>foo{}bar</b></p>
+	 *		<p><b>[]</b></p> -> <p>[]</p>
+	 *		<p><b>foo</b><i>[]</i><b>bar</b></p> -> <p><b>foo{}bar</b></p>
 	 *
 	 * **Note:** Difference between {@link module:engine/view/downcastwriter~DowncastWriter#mergeAttributes mergeAttributes} and
 	 * {@link module:engine/view/downcastwriter~DowncastWriter#mergeContainers mergeContainers} is that `mergeAttributes` merges two
@@ -553,8 +561,8 @@ export default class DowncastWriter {
 	 * Merges two {@link module:engine/view/containerelement~ContainerElement container elements} that are before and after given position.
 	 * Precisely, the element after the position is removed and it's contents are moved to element before the position.
 	 *
-	 *        <p>foo</p>^<p>bar</p> -> <p>foo^bar</p>
-	 *        <div>foo</div>^<p>bar</p> -> <div>foo^bar</div>
+	 *		<p>foo</p>^<p>bar</p> -> <p>foo^bar</p>
+	 *		<div>foo</div>^<p>bar</p> -> <div>foo^bar</div>
 	 *
 	 * **Note:** Difference between {@link module:engine/view/downcastwriter~DowncastWriter#mergeAttributes mergeAttributes} and
 	 * {@link module:engine/view/downcastwriter~DowncastWriter#mergeContainers mergeContainers} is that `mergeAttributes` merges two
@@ -1026,7 +1034,7 @@ export default class DowncastWriter {
 	 *		const selection = writer.createSelection( position );
 	 *
 	 *		// Creates collapsed selection at the position of given item and offset.
-	 *		const paragraph = writer.createContainerElement( 'paragraph' );
+	 *		const paragraph = writer.createContainerElement( 'p' );
 	 *		const selection = writer.createSelection( paragraph, offset );
 	 *
 	 *		// Creates a range inside an {@link module:engine/view/element~Element element} which starts before the

+ 0 - 12
packages/ckeditor5-engine/src/view/renderer.js

@@ -101,13 +101,6 @@ export default class Renderer {
 		 */
 		this.isFocused = false;
 
-		/**
-		 * Indicates if the composition is in progress inside the view document view.
-		 *
-		 * @member {Boolean}
-		 */
-		this.isComposing = false;
-
 		/**
 		 * The text node in which the inline filler was rendered.
 		 *
@@ -769,11 +762,6 @@ export default class Renderer {
 	 * @returns {Boolean}
 	 */
 	_domSelectionNeedsUpdate( domSelection ) {
-		// Remain DOM selection untouched while composing. See #1782.
-		if ( this.isComposing ) {
-			return false;
-		}
-
 		if ( !this.domConverter.isDomSelectionCorrect( domSelection ) ) {
 			// Current DOM selection is in incorrect position. We need to update it.
 			return true;

+ 0 - 1
packages/ckeditor5-engine/src/view/view.js

@@ -105,7 +105,6 @@ export default class View {
 		 */
 		this._renderer = new Renderer( this.domConverter, this.document.selection );
 		this._renderer.bind( 'isFocused' ).to( this.document );
-		this._renderer.bind( 'isComposing' ).to( this.document );
 
 		/**
 		 * A DOM root attributes cache. It saves the initial values of DOM root attributes before the DOM element

+ 0 - 42
packages/ckeditor5-engine/tests/view/renderer.js

@@ -3706,48 +3706,6 @@ describe( 'Renderer', () => {
 				return viewData.repeat( repeat );
 			}
 		} );
-
-		// #1782
-		it( 'should leave dom selection untouched while composing', () => {
-			const { view: viewP, selection: newSelection } = parse( '<container:p>[]</container:p>' );
-
-			viewRoot._appendChild( viewP );
-			selection._setTo( newSelection );
-
-			renderer.markToSync( 'children', viewRoot );
-			renderer.render();
-
-			// Mock IME typing in Safari: <p>[c]</p>.
-			renderer.isComposing = true;
-			const domText = document.createTextNode( 'c' );
-			domRoot.firstChild.appendChild( domText );
-			const range = document.createRange();
-			range.setStart( domText, 0 );
-			range.setEnd( domText, 1 );
-			const domSelection = document.getSelection();
-			domSelection.removeAllRanges();
-			domSelection.addRange( range );
-
-			// <container:p>c[]</container:p>
-			viewP._appendChild( new ViewText( 'c' ) );
-			selection._setTo( [
-				new ViewRange( new ViewPosition( viewP.getChild( 0 ), 1 ), new ViewPosition( viewP.getChild( 0 ), 1 ) )
-			] );
-
-			renderer.markToSync( 'children', viewP );
-			renderer.render();
-
-			expect( domRoot.childNodes.length ).to.equal( 1 );
-			expect( domRoot.firstChild.childNodes.length ).to.equal( 1 );
-			expect( domRoot.firstChild.firstChild.data ).to.equal( 'c' );
-
-			const currentRange = domSelection.getRangeAt( 0 );
-			expect( currentRange.collapsed ).to.equal( false );
-			expect( currentRange.startContainer ).to.equal( domRoot.firstChild.firstChild );
-			expect( currentRange.startOffset ).to.equal( 0 );
-			expect( currentRange.endContainer ).to.equal( domRoot.firstChild.firstChild );
-			expect( currentRange.endOffset ).to.equal( 1 );
-		} );
 	} );
 
 	describe( '#922', () => {