Browse Source

Add documentation for Input#isInput() method.

Maciej Gołaszewski 6 years ago
parent
commit
fd0020b3ee

+ 9 - 0
packages/ckeditor5-typing/src/input.js

@@ -41,6 +41,15 @@ export default class Input extends Plugin {
 		injectTypingMutationsHandling( editor );
 	}
 
+	/**
+	 * Checks batch if is a result of user input - ie typing.
+	 *
+	 * **Note:** This method checks if the batch was created using {@link module:typing/inputcommand~InputCommand 'input'}
+	 * command as typing changes coming from user input are inserted to the document using that command.
+	 *
+	 * @param {module:engine/model/batch~Batch} batch A batch to check.
+	 * @returns {Boolean}
+	 */
 	isInput( batch ) {
 		const inputCommand = this.editor.commands.get( 'input' );
 

+ 8 - 0
packages/ckeditor5-typing/src/inputcommand.js

@@ -36,6 +36,13 @@ export default class InputCommand extends Command {
 		 */
 		this._buffer = new ChangeBuffer( editor.model, undoStepSize );
 
+		/**
+		 * Stores batches created by the input command. The batches are used to differentiate input batches from other batches using
+		 * {@link module:typing/input~Input#isInput} method.
+		 *
+		 * @type {WeakSet<module:engine/model/batch~Batch>}
+		 * @private
+		 */
 		this._batches = new WeakSet();
 	}
 
@@ -101,6 +108,7 @@ export default class InputCommand extends Command {
 
 			this._buffer.input( textInsertions );
 
+			// Store the batch as an 'input' batch for the Input.isInput( batch ) check.
 			this._batches.add( this._buffer.batch );
 		} );
 	}