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

Change setting TextTransformation#isEnabled on selection change:range

panr 6 лет назад
Родитель
Сommit
4179eb4b4c
1 измененных файлов с 5 добавлено и 6 удалено
  1. 5 6
      packages/ckeditor5-typing/src/texttransformation.js

+ 5 - 6
packages/ckeditor5-typing/src/texttransformation.js

@@ -101,8 +101,7 @@ export default class TextTransformation extends Plugin {
 	 */
 	init() {
 		const model = this.editor.model;
-		const modelDocument = model.document;
-		const modelSelection = modelDocument.selection;
+		const modelSelection = model.document.selection;
 
 		/**
 		 * Holds a set of active {@link module:typing/textwatcher~TextWatcher}
@@ -116,12 +115,12 @@ export default class TextTransformation extends Plugin {
 			this.isEnabled ? this._enableTransformationWatchers() : this._disableTransformationWatchers();
 		} );
 
-		this._enableTransformationWatchers();
-
-		this.listenTo( modelDocument, 'change:data', () => {
-			// Disable plugin when typing in code block.
+		modelSelection.on( 'change:range', () => {
+			// Disable plugin when selection is inside a code block.
 			this.isEnabled = !modelSelection.anchor.parent.is( 'codeBlock' );
 		} );
+
+		this._enableTransformationWatchers();
 	}
 
 	/**