瀏覽代碼

Insert text only if its length is > 0.

Krzysztof Krztoń 8 年之前
父節點
當前提交
de8371550f
共有 1 個文件被更改,包括 4 次插入3 次删除
  1. 4 3
      packages/ckeditor5-typing/src/inputcommand.js

+ 4 - 3
packages/ckeditor5-typing/src/inputcommand.js

@@ -20,7 +20,8 @@ export default class InputCommand extends Command {
 	 * Creates an instance of the command.
 	 *
 	 * @param {module:core/editor/editor~Editor} editor
-	 * @param {Number} undoStep The maximum number of atomic changes which can be contained in one batch.
+	 * @param {Number} undoStep The maximum number of atomic changes
+	 * which can be contained in one batch in the command buffer.
 	 */
 	constructor( editor, undoStep ) {
 		super( editor );
@@ -60,7 +61,7 @@ export default class InputCommand extends Command {
 	 * on the beginning of the range (which after removal is a collapsed range).
 	 *
 	 * @param {Object} [options] The command options.
-	 * @param {String} [options.text=''] Text to be inserted.
+	 * @param {String} [options.text] Text to be inserted.
 	 * @param {module:engine/model/range~Range} [options.range] Range in which the text is inserted. Defaults
 	 * to the first range in the current selection.
 	 * @param {module:engine/model/position~Position} [options.resultPosition] Position which will be used
@@ -82,7 +83,7 @@ export default class InputCommand extends Command {
 					this._buffer.batch.remove( range );
 				}
 
-				if ( text ) {
+				if ( text && text.length ) {
 					textInsertions = text.length;
 					this._buffer.batch.weakInsert( range.start, text );
 				}