8
0
Просмотр исходного кода

Tests: Range as InputCommand parameter.

Krzysztof Krztoń 8 лет назад
Родитель
Сommit
e5e3e3213d

+ 22 - 0
packages/ckeditor5-typing/tests/input.js

@@ -295,6 +295,28 @@ describe( 'Input feature', () => {
 			expect( getViewData( view ) ).to.equal( '<p>Foo house{}</p>' );
 		} );
 
+		it( 'should place non-collapsed selection after changing single character (composition)', () => {
+			// This test case emulates spellchecker correction.
+			editor.setData( '<p>Foo house</p>' );
+
+			const viewSelection = new ViewSelection();
+			viewSelection.collapse( viewRoot.getChild( 0 ).getChild( 0 ), 8 );
+			viewSelection.setFocus( viewRoot.getChild( 0 ).getChild( 0 ), 9 );
+
+			view.fire( 'mutations',
+				[ {
+					type: 'text',
+					oldText: 'Foo house',
+					newText: 'Foo housa',
+					node: viewRoot.getChild( 0 ).getChild( 0 )
+				} ],
+				viewSelection
+			);
+
+			expect( getModelData( model ) ).to.equal( '<paragraph>Foo hous[a]</paragraph>' );
+			expect( getViewData( view ) ).to.equal( '<p>Foo hous{a}</p>' );
+		} );
+
 		it( 'should replace last &nbsp; with space', () => {
 			model.enqueueChanges( () => {
 				model.selection.setRanges( [

+ 3 - 0
packages/ckeditor5-typing/tests/manual/86/1.html

@@ -0,0 +1,3 @@
+<div id="editor">
+	<p>This is an editor instance.</p>
+</div>

+ 28 - 0
packages/ckeditor5-typing/tests/manual/86/1.js

@@ -0,0 +1,28 @@
+/**
+ * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+/* globals console, window, document */
+
+import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classic';
+import Enter from '@ckeditor/ckeditor5-enter/src/enter';
+import Typing from '../../../src/typing';
+import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
+import Undo from '@ckeditor/ckeditor5-undo/src/undo';
+import { getData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
+
+window.setInterval( function() {
+	console.log( getData( window.editor.document ) );
+}, 3000 );
+
+ClassicEditor.create( document.querySelector( '#editor' ), {
+	plugins: [ Enter, Typing, Paragraph, Undo ],
+	toolbar: [ 'undo', 'redo' ]
+} )
+	.then( editor => {
+		window.editor = editor;
+	} )
+	.catch( err => {
+		console.error( err.stack );
+	} );

+ 5 - 0
packages/ckeditor5-typing/tests/manual/86/1.md

@@ -0,0 +1,5 @@
+## Typing - MacOS accent balloon 
+
+It is possible to navigate with arrow keys inside MacOS balloon panel and insert a selected accent
+(long "a" press to activate accent balloon).
+