Browse Source

Remove _watchersStack since it's no longer necessary and bind watcher's state to the state of the TextTransformation plugin

panr 5 years ago
parent
commit
44e8c2e795
1 changed files with 1 additions and 27 deletions
  1. 1 27
      packages/ckeditor5-typing/src/texttransformation.js

+ 1 - 27
packages/ckeditor5-typing/src/texttransformation.js

@@ -103,18 +103,6 @@ export default class TextTransformation extends Plugin {
 		const model = this.editor.model;
 		const modelSelection = model.document.selection;
 
-		/**
-		 * Holds a set of active {@link module:typing/textwatcher~TextWatcher}
-		 *
-		 * @type {Set.<TextWatcher>}
-		 * @private
-		 */
-		this._watchersStack = new Set();
-
-		this.on( 'change:isEnabled', () => {
-			this.isEnabled ? this._enableTransformationWatchers() : this._disableTransformationWatchers();
-		} );
-
 		modelSelection.on( 'change:range', () => {
 			// Disable plugin when selection is inside a code block.
 			this.isEnabled = !modelSelection.anchor.parent.is( 'codeBlock' );
@@ -175,24 +163,10 @@ export default class TextTransformation extends Plugin {
 				} );
 			};
 
-			this._watchersStack.add( watcher );
-
 			watcher.on( 'matched:data', watcherCallback );
+			watcher.bind( 'isEnabled' ).to( this );
 		}
 	}
-
-	/**
-	 * Disable each running TextWatcher and clear the set of enabled watchers after all.
-	 *
-	 * @private
-	 */
-	_disableTransformationWatchers() {
-		this._watchersStack.forEach( watcher => {
-			watcher.stopListening();
-		} );
-
-		this._watchersStack.clear();
-	}
 }
 
 // Normalizes the configuration `from` parameter value.