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

Merge branch 'master' into t/1002

Piotrek Koszuliński преди 8 години
родител
ревизия
4767eae759

+ 5 - 4
packages/ckeditor5-engine/src/dev-utils/enableenginedebug.js

@@ -274,8 +274,9 @@ function enableLoggingTools() {
 	};
 
 	InsertOperation.prototype.toString = function() {
-		return getClassName( this ) + `( ${ this.baseVersion } ): ` +
-			`[ ${ this.nodes.length } ] -> ${ this.position }`;
+		const nodeString = this.nodes.length > 1 ? `[ ${ this.nodes.length } ]` : this.nodes.getNode( 0 );
+
+		return getClassName( this ) + `( ${ this.baseVersion } ): ${ nodeString } -> ${ this.position }`;
 	};
 
 	MarkerOperation.prototype.toString = function() {
@@ -367,9 +368,9 @@ function enableLoggingTools() {
 
 	InsertDelta.prototype.toString = function() {
 		const op = this._insertOperation;
+		const nodeString = op.nodes.length > 1 ? `[ ${ op.nodes.length } ]` : op.nodes.getNode( 0 );
 
-		return getClassName( this ) + `( ${ this.baseVersion } ): ` +
-			`[ ${ op.nodes.length } ] -> ${ op.position }`;
+		return getClassName( this ) + `( ${ this.baseVersion } ): ${ nodeString } -> ${ op.position }`;
 	};
 
 	MarkerDelta.prototype.toString = function() {

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

@@ -76,7 +76,7 @@ export default class Position {
 		this.root = root;
 
 		/**
-		 * Position of the node it the tree. Path is described through offsets, not indexes.
+		 * Position of the node in the tree. **Path contains offsets, not indexes.**
 		 *
 		 * Position can be placed before, after or in a {@link module:engine/model/node~Node node} if that node has
 		 * {@link module:engine/model/node~Node#offsetSize} greater than `1`. Items in position path are

+ 49 - 5
packages/ckeditor5-engine/tests/dev-utils/enableenginedebug.js

@@ -209,10 +209,29 @@ describe( 'debug tools', () => {
 				expect( log.calledWithExactly( op.toString() ) ).to.be.true;
 			} );
 
-			it( 'InsertOperation', () => {
+			it( 'InsertOperation (text node)', () => {
 				const op = new InsertOperation( ModelPosition.createAt( modelRoot, 3 ), [ new ModelText( 'abc' ) ], 0 );
 
-				expect( op.toString() ).to.equal( 'InsertOperation( 0 ): [ 1 ] -> main [ 3 ]' );
+				expect( op.toString() ).to.equal( 'InsertOperation( 0 ): #abc -> main [ 3 ]' );
+
+				op.log();
+				expect( log.calledWithExactly( op.toString() ) ).to.be.true;
+			} );
+
+			it( 'InsertOperation (element)', () => {
+				const op = new InsertOperation( ModelPosition.createAt( modelRoot, 3 ), [ new ModelElement( 'paragraph' ) ], 0 );
+
+				expect( op.toString() ).to.equal( 'InsertOperation( 0 ): <paragraph> -> main [ 3 ]' );
+
+				op.log();
+				expect( log.calledWithExactly( op.toString() ) ).to.be.true;
+			} );
+
+			it( 'InsertOperation (multiple nodes)', () => {
+				const nodes = [ new ModelText( 'x' ), new ModelElement( 'y' ), new ModelText( 'z' ) ];
+				const op = new InsertOperation( ModelPosition.createAt( modelRoot, 3 ), nodes, 0 );
+
+				expect( op.toString() ).to.equal( 'InsertOperation( 0 ): [ 3 ] -> main [ 3 ]' );
 
 				op.log();
 				expect( log.calledWithExactly( op.toString() ) ).to.be.true;
@@ -301,13 +320,38 @@ describe( 'debug tools', () => {
 				expect( log.calledWithExactly( delta.toString() ) ).to.be.true;
 			} );
 
-			it( 'InsertDelta', () => {
+			it( 'InsertDelta (text node)', () => {
 				const delta = new InsertDelta();
 				const op = new InsertOperation( ModelPosition.createAt( modelRoot, 3 ), [ new ModelText( 'abc' ) ], 0 );
 
 				delta.addOperation( op );
 
-				expect( delta.toString() ).to.equal( 'InsertDelta( 0 ): [ 1 ] -> main [ 3 ]' );
+				expect( delta.toString() ).to.equal( 'InsertDelta( 0 ): #abc -> main [ 3 ]' );
+
+				delta.log();
+				expect( log.calledWithExactly( delta.toString() ) ).to.be.true;
+			} );
+
+			it( 'InsertDelta (element)', () => {
+				const delta = new InsertDelta();
+				const op = new InsertOperation( ModelPosition.createAt( modelRoot, 3 ), [ new ModelElement( 'paragraph' ) ], 0 );
+
+				delta.addOperation( op );
+
+				expect( delta.toString() ).to.equal( 'InsertDelta( 0 ): <paragraph> -> main [ 3 ]' );
+
+				delta.log();
+				expect( log.calledWithExactly( delta.toString() ) ).to.be.true;
+			} );
+
+			it( 'InsertDelta (multiple nodes)', () => {
+				const delta = new InsertDelta();
+				const nodes = [ new ModelText( 'x' ), new ModelElement( 'y' ), new ModelText( 'z' ) ];
+				const op = new InsertOperation( ModelPosition.createAt( modelRoot, 3 ), nodes, 0 );
+
+				delta.addOperation( op );
+
+				expect( delta.toString() ).to.equal( 'InsertDelta( 0 ): [ 3 ] -> main [ 3 ]' );
 
 				delta.log();
 				expect( log.calledWithExactly( delta.toString() ) ).to.be.true;
@@ -453,7 +497,7 @@ describe( 'debug tools', () => {
 
 			modelDoc.applyOperation( op );
 
-			expect( log.calledWithExactly( 'Applying InsertOperation( 0 ): [ 1 ] -> main [ 0 ]' ) ).to.be.true;
+			expect( log.calledWithExactly( 'Applying InsertOperation( 0 ): #foo -> main [ 0 ]' ) ).to.be.true;
 		} );
 	} );
 

+ 29 - 6
packages/ckeditor5-engine/tests/manual/markers.js

@@ -40,12 +40,35 @@ ClassicEditor.create( document.querySelector( '#editor' ), {
 			return new ViewAttributeElement( 'span', { class: 'h-' + color } );
 		} );
 
-	window.document.getElementById( 'add-yellow' ).addEventListener( 'click', () => addHighlight( 'yellow' ) );
-	window.document.getElementById( 'add-red' ).addEventListener( 'click', () => addHighlight( 'red' ) );
-	window.document.getElementById( 'remove-marker' ).addEventListener( 'click', () => removeHighlight() );
-	window.document.getElementById( 'move-to-start' ).addEventListener( 'click', () => moveSelectionToStart() );
-	window.document.getElementById( 'move-left' ).addEventListener( 'click', () => moveSelectionByOffset( -1 ) );
-	window.document.getElementById( 'move-right' ).addEventListener( 'click', () => moveSelectionByOffset( 1 ) );
+	window.document.getElementById( 'add-yellow' ).addEventListener( 'mousedown', e => {
+		e.preventDefault();
+		addHighlight( 'yellow' );
+	} );
+
+	window.document.getElementById( 'add-red' ).addEventListener( 'mousedown', e => {
+		e.preventDefault();
+		addHighlight( 'red' );
+	} );
+
+	window.document.getElementById( 'remove-marker' ).addEventListener( 'mousedown', e => {
+		e.preventDefault();
+		removeHighlight();
+	} );
+
+	window.document.getElementById( 'move-to-start' ).addEventListener( 'mousedown', e => {
+		e.preventDefault();
+		moveSelectionToStart();
+	} );
+
+	window.document.getElementById( 'move-left' ).addEventListener( 'mousedown', e => {
+		e.preventDefault();
+		moveSelectionByOffset( -1 );
+	} );
+
+	window.document.getElementById( 'move-right' ).addEventListener( 'mousedown', e => {
+		e.preventDefault();
+		moveSelectionByOffset( 1 );
+	} );
 
 	model.enqueueChanges( () => {
 		const root = model.getRoot();

+ 1 - 0
packages/ckeditor5-engine/theme/placeholder.scss

@@ -5,4 +5,5 @@
 	content: attr( data-placeholder );
 	cursor: text;
 	color: #c2c2c2;
+	pointer-events: none; // See ckeditor/ckeditor5#469.
 }