8
0
Quellcode durchsuchen

Merge branch 'master' into t/61

Kamil Piechaczek vor 8 Jahren
Ursprung
Commit
a4a26e7044

+ 1 - 0
packages/ckeditor5-typing/src/delete.js

@@ -36,6 +36,7 @@ export default class Delete extends Plugin {
 		this.listenTo( editingView, 'delete', ( evt, data ) => {
 			editor.execute( data.direction == 'forward' ? 'forwardDelete' : 'delete', { unit: data.unit, sequence: data.sequence } );
 			data.preventDefault();
+			editingView.scrollToTheSelection();
 		} );
 	}
 }

+ 30 - 0
packages/ckeditor5-typing/src/typing.js

@@ -28,3 +28,33 @@ export default class Typing extends Plugin {
 		return 'Typing';
 	}
 }
+
+/**
+ * The configuration of the typing features. Used by the features from the `@ckeditor/ckeditor5-typing` package.
+ *
+ * Read more in {@link module:typing/typing~TypingConfig}.
+ *
+ * @member {module:typing/typing~TypingConfig} module:core/editor/editorconfig~EditorConfig#typing
+ */
+
+/**
+ * The configuration of the typing features. Used by the typing features in `@ckeditor/ckeditor5-typing` package.
+ *
+ *		ClassicEditor
+ *			.create( {
+ * 				typing: ... // Typing feature options.
+ *			} )
+ *			.then( ... )
+ *			.catch( ... );
+ *
+ * See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
+ *
+ * @interface TypingConfig
+ */
+
+/**
+ * The granularity of undo/redo for typing and deleting. The value `20` means (more or less) that a new undo step
+ * is created every 20 characters are inserted or deleted.
+ *
+ * @member {Number} [module:typing/typing~TypingConfig#undoStep=20]
+ */

+ 13 - 0
packages/ckeditor5-typing/tests/delete.js

@@ -54,6 +54,19 @@ describe( 'Delete feature', () => {
 		expect( spy.calledWithMatch( 'delete', { unit: 'character', sequence: 5 } ) ).to.be.true;
 	} );
 
+	it( 'scrolls the editing document to the selection after executing the command', () => {
+		const scrollSpy = sinon.stub( editingView, 'scrollToTheSelection' );
+		const executeSpy = editor.execute = sinon.spy();
+
+		editingView.fire( 'delete', new DomEventData( editingView, getDomEvent(), {
+			direction: 'backward',
+			unit: 'character'
+		} ) );
+
+		sinon.assert.calledOnce( scrollSpy );
+		sinon.assert.callOrder( executeSpy, scrollSpy );
+	} );
+
 	function getDomEvent() {
 		return {
 			preventDefault: sinon.spy()