8
0
Szymon Cofalik 9 лет назад
Родитель
Сommit
1c3e48df10

+ 3 - 9
packages/ckeditor5-engine/src/model/composer/modifyselection.js

@@ -8,39 +8,33 @@ import TreeWalker from '../treewalker.js';
 import Range from '../range.js';
 import { isInsideSurrogatePair, isInsideCombinedSymbol } from '../../../utils/unicode.js';
 
-/* jshint -W100 */
 /**
  * Modifies the selection. Currently the supported modifications are:
  *
  * * Extending. The selection focus is moved in the specified `options.direction` with a step specified in `options.unit`.
  * Possible values for `unit` are:
  *  * `'character'` (default) - moves selection by one user-perceived character. In most cases this means moving by one
- *  character in {String} sense. However, unicode also defines "combing marks". These are special symbols, that combines
+ *  character in `String` sense. However, unicode also defines "combing marks". These are special symbols, that combines
  *  with a symbol before it ("base character") to create one user-perceived character. For example, `q̣̇` is a normal
  *  letter `q` with two "combining marks": upper dot (`Ux0307`) and lower dot (`Ux0323`). For most actions, i.e. extending
  *  selection by one position, it is correct to include both "base character" and all of it's "combining marks". That is
  *  why `'character'` value is most natural and common method of modifying selection.
  *  * `'codePoint'` - moves selection by one unicode code point. In contrary to, `'character'` unit, this will insert
  *  selection between "base character" and "combining mark", because "combining marks" have their own unicode code points.
- *  However, for technical reasons, unicode code points with values above `UxFFFF` are represented in native {String} by
+ *  However, for technical reasons, unicode code points with values above `UxFFFF` are represented in native `String` by
  *  two characters, called "surrogate pairs". Halves of "surrogate pairs" have a meaning only when placed next to each other.
- *  For example `𨭎` is represented in {String} by `\uD862\uDF4E`. Both `\uD862` and `\uDF4E` do not have any meaning
+ *  For example `𨭎` is represented in `String` by `\uD862\uDF4E`. Both `\uD862` and `\uDF4E` do not have any meaning
  *  outside the pair (are rendered as ? when alone). Position between them would be incorrect. In this case, selection
  *  extension will include whole "surrogate pair".
  *
  * **Note:** if you extend a forward selection in a backward direction you will in fact shrink it.
  *
- * **Note:** you may use `CKEditor5 Graphemes` feature available at https://github.com/ckeditor/ckeditor5-graphemes
- * to enhance `'character'` option to support so-called "graphemes". This feature is not available in
- * `engine` out-of-the-box due to it's big size and niche usage.
- *
  * @method engine.model.composer.modifySelection
  * @param {engine.model.Selection} selection The selection to modify.
  * @param {Object} [options]
  * @param {'forward'|'backward'} [options.direction='forward'] The direction in which the selection should be modified.
  * @param {'character'|'codePoint'} [options.unit='character'] The unit by which selection should be modified.
  */
-/* jshint +W100 */
 export default function modifySelection( selection, options = {} ) {
 	const isForward = options.direction != 'backward';
 	options.unit = options.unit ? options.unit : 'character';

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

@@ -33,7 +33,7 @@ export default class Text extends Node {
 		 *
 		 * @type {String}
 		 */
-		this.data = data ? data.normalize() : '';
+		this.data = data || '';
 	}
 
 	/**

+ 2 - 2
packages/ckeditor5-engine/src/view/text.js

@@ -28,7 +28,7 @@ export default class Text extends Node {
 		 * @private
 		 * @member {String} engine.view.Text#_data
 		 */
-		this._data = data ? data.normalize() : '';
+		this._data = data;
 	}
 
 	/**
@@ -52,7 +52,7 @@ export default class Text extends Node {
 	set data( data ) {
 		this._fireChange( 'text', this );
 
-		this._data = data ? data.normalize() : '';
+		this._data = data;
 	}
 
 	/**

+ 0 - 27
packages/ckeditor5-engine/tests/model/composer/modifyselection.js

@@ -125,19 +125,6 @@ describe( 'Delete utils', () => {
 					{ direction: 'backward' }
 				);
 
-				//test(
-				//	'unicode support - forward',
-				//	'<p>நி<selection>லை</selection>க்கு</p>',
-				//	'<p>நி<selection>லைக்</selection>கு</p>'
-				//);
-				//
-				//test(
-				//	'unicode support - backward',
-				//	'<p>நி<selection backward>லை</selection>க்கு</p>',
-				//	'<p><selection backward>நிலை</selection>க்கு</p>',
-				//	{ direction: 'backward' }
-				//);
-
 				test(
 					'unicode support - combining mark forward',
 					'<p>foo<selection />b̂ar</p>',
@@ -327,20 +314,6 @@ describe( 'Delete utils', () => {
 				{ unit: 'codePoint' }
 			);
 
-			//test(
-			//	'extends one unicode code point forward',
-			//	'<p>நி<selection>லை</selection>க்கு</p>',
-			//	'<p>நி<selection>லைக</selection>்கு</p>',
-			//	{ unit: 'codePoint' }
-			//);
-			//
-			//test(
-			//	'shrinks one unicode code point backward (combining mark case) ',
-			//	'<p>நி<selection>லைக்</selection>கு</p>',
-			//	'<p>நி<selection>லைக</selection>்கு</p>',
-			//	{ unit: 'codePoint', direction: 'backward' }
-			//);
-
 			test(
 				'unicode support - surrogate pairs forward',
 				'<p><selection />\uD83D\uDCA9</p>',

+ 1 - 15
packages/ckeditor5-engine/tests/model/text.js

@@ -66,22 +66,8 @@ describe( 'Text', () => {
 			expect( deserialized.data ).to.equal( 'foo' );
 			expect( Array.from( deserialized.getAttributes() ) ).to.deep.equal( [ [ 'bold', true ] ] );
 		} );
-	} );
-
-	// All characters, code points, combined symbols, etc. can be looked up in browsers console to better understand what is going on.
-	describe( 'unicode support', () => {
-		it( 'should normalize strings kept in data', () => {
-			// This is a letter "n" with so-called combining mark, similar to ~, which code point is \u0303.
-			// Those two characters together combines to "ñ", but that character already has it's code point: \u00F1.
-			let dataCombined = '\u006E\u0303';
-			let textN = new Text( dataCombined );
-
-			expect( textN.data ).to.equal( '\u00F1' ); // "ñ" got normalized to \u00F1.
-			expect( textN.data.length ).to.equal( 1 ); // It is now just one character.
-			expect( textN.offsetSize ).to.equal( 1 ); // And has correct offset size.
-		} );
 
-		it( 'should be properly serialized and de-serialized', () => {
+		it( 'should support unicode', () => {
 			let textQ = new Text( 'நி' );
 			let json = jsonParseStringify( textQ );
 

+ 0 - 11
packages/ckeditor5-engine/tests/view/text.js

@@ -63,15 +63,4 @@ describe( 'Element', () => {
 			expect( text.data ).to.equal( 'bar' );
 		} );
 	} );
-
-	// This is same set of tests as in engine.model.Text tests. Look there for comments on tests.
-	describe( 'unicode support', () => {
-		it( 'should normalize strings kept in data', () => {
-			let dataCombined = '\u006E\u0303';
-			let textN = new Text( dataCombined );
-
-			expect( textN.data ).to.equal( '\u00F1' );
-			expect( textN.data.length ).to.equal( 1 );
-		} );
-	} );
 } );