@ckeditor/ckeditor5-typing
Advanced tools
Comparing version 16.0.0 to 17.0.0
Changelog | ||
========= | ||
## [17.0.0](https://github.com/ckeditor/ckeditor5-typing/compare/v16.0.0...v17.0.0) (2020-02-19) | ||
### Features | ||
* Add `TextWatcher#isEnabled` property to allow toggling text watcher on and off. ([fa79d00](https://github.com/ckeditor/ckeditor5-typing/commit/fa79d00)) | ||
## [16.0.0](https://github.com/ckeditor/ckeditor5-typing/compare/v15.0.0...v16.0.0) (2019-12-04) | ||
@@ -5,0 +12,0 @@ |
@@ -5,3 +5,3 @@ Software License Agreement | ||
**CKEditor 5 Typing Feature** – https://github.com/ckeditor/ckeditor5-typing <br> | ||
Copyright (c) 2003-2019, [CKSource](http://cksource.com) Frederico Knabben. All rights reserved. | ||
Copyright (c) 2003-2020, [CKSource](http://cksource.com) Frederico Knabben. All rights reserved. | ||
@@ -8,0 +8,0 @@ Licensed under the terms of [GNU General Public License Version 2 or later](http://www.gnu.org/licenses/gpl.html). |
{ | ||
"name": "@ckeditor/ckeditor5-typing", | ||
"version": "16.0.0", | ||
"version": "17.0.0", | ||
"description": "Typing feature for CKEditor 5.", | ||
@@ -13,19 +13,20 @@ "keywords": [ | ||
"dependencies": { | ||
"@ckeditor/ckeditor5-core": "^16.0.0", | ||
"@ckeditor/ckeditor5-engine": "^16.0.0", | ||
"@ckeditor/ckeditor5-utils": "^16.0.0", | ||
"@ckeditor/ckeditor5-core": "^17.0.0", | ||
"@ckeditor/ckeditor5-engine": "^17.0.0", | ||
"@ckeditor/ckeditor5-utils": "^17.0.0", | ||
"lodash-es": "^4.17.10" | ||
}, | ||
"devDependencies": { | ||
"@ckeditor/ckeditor5-basic-styles": "^16.0.0", | ||
"@ckeditor/ckeditor5-block-quote": "^16.0.0", | ||
"@ckeditor/ckeditor5-editor-classic": "^16.0.0", | ||
"@ckeditor/ckeditor5-enter": "^16.0.0", | ||
"@ckeditor/ckeditor5-essentials": "^16.0.0", | ||
"@ckeditor/ckeditor5-heading": "^16.0.0", | ||
"@ckeditor/ckeditor5-image": "^16.0.0", | ||
"@ckeditor/ckeditor5-link": "^16.0.0", | ||
"@ckeditor/ckeditor5-list": "^16.0.0", | ||
"@ckeditor/ckeditor5-paragraph": "^16.0.0", | ||
"@ckeditor/ckeditor5-undo": "^16.0.0", | ||
"@ckeditor/ckeditor5-basic-styles": "^17.0.0", | ||
"@ckeditor/ckeditor5-block-quote": "^17.0.0", | ||
"@ckeditor/ckeditor5-editor-classic": "^17.0.0", | ||
"@ckeditor/ckeditor5-enter": "^17.0.0", | ||
"@ckeditor/ckeditor5-essentials": "^17.0.0", | ||
"@ckeditor/ckeditor5-heading": "^17.0.0", | ||
"@ckeditor/ckeditor5-image": "^17.0.0", | ||
"@ckeditor/ckeditor5-link": "^17.0.0", | ||
"@ckeditor/ckeditor5-list": "^17.0.0", | ||
"@ckeditor/ckeditor5-paragraph": "^17.0.0", | ||
"@ckeditor/ckeditor5-undo": "^17.0.0", | ||
"@ckeditor/ckeditor5-code-block": "^17.0.0", | ||
"eslint": "^5.5.0", | ||
@@ -32,0 +33,0 @@ "eslint-config-ckeditor5": "^2.0.0", |
/** | ||
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved. | ||
* @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
@@ -4,0 +4,0 @@ */ |
/** | ||
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved. | ||
* @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
@@ -4,0 +4,0 @@ */ |
/** | ||
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved. | ||
* @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
@@ -4,0 +4,0 @@ */ |
/** | ||
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved. | ||
* @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
@@ -4,0 +4,0 @@ */ |
/** | ||
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved. | ||
* @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
@@ -4,0 +4,0 @@ */ |
/** | ||
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved. | ||
* @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
@@ -95,2 +95,4 @@ */ | ||
} ); | ||
this.editor = editor; | ||
} | ||
@@ -102,2 +104,19 @@ | ||
init() { | ||
const model = this.editor.model; | ||
const modelSelection = model.document.selection; | ||
modelSelection.on( 'change:range', () => { | ||
// Disable plugin when selection is inside a code block. | ||
this.isEnabled = !modelSelection.anchor.parent.is( 'codeBlock' ); | ||
} ); | ||
this._enableTransformationWatchers(); | ||
} | ||
/** | ||
* Create new set of TextWatchers listening to the editor for typing and selection events. | ||
* | ||
* @private | ||
*/ | ||
_enableTransformationWatchers() { | ||
const editor = this.editor; | ||
@@ -115,3 +134,3 @@ const model = editor.model; | ||
watcher.on( 'matched:data', ( evt, data ) => { | ||
const watcherCallback = ( evt, data ) => { | ||
if ( !input.isInput( data.batch ) ) { | ||
@@ -148,3 +167,6 @@ return; | ||
} ); | ||
} ); | ||
}; | ||
watcher.on( 'matched:data', watcherCallback ); | ||
watcher.bind( 'isEnabled' ).to( this ); | ||
} | ||
@@ -151,0 +173,0 @@ } |
/** | ||
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved. | ||
* @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
@@ -11,3 +11,3 @@ */ | ||
import mix from '@ckeditor/ckeditor5-utils/src/mix'; | ||
import EmitterMixin from '@ckeditor/ckeditor5-utils/src/emittermixin'; | ||
import ObservableMixin from '@ckeditor/ckeditor5-utils/src/observablemixin'; | ||
import getLastTextLine from './utils/getlasttextline'; | ||
@@ -23,2 +23,3 @@ | ||
* @private | ||
* @mixes module:utils/observablemixin~ObservableMixin | ||
*/ | ||
@@ -28,2 +29,3 @@ export default class TextWatcher { | ||
* Creates a text watcher instance. | ||
* | ||
* @param {module:engine/model/model~Model} model | ||
@@ -37,2 +39,28 @@ * @param {Function} testCallback The function used to match the text. | ||
/** | ||
* Flag indicating whether the `TextWatcher` instance is enabled or disabled. | ||
* A disabled TextWatcher will not evaluate text. | ||
* | ||
* To disable TextWatcher: | ||
* | ||
* const watcher = new TextWatcher( editor.model, testCallback ); | ||
* | ||
* // After this a testCallback will not be called. | ||
* watcher.isEnabled = false; | ||
* | ||
* @observable | ||
* @member {Boolean} #isEnabled | ||
*/ | ||
this.set( 'isEnabled', true ); | ||
// Toggle text watching on isEnabled state change. | ||
this.on( 'change:isEnabled', () => { | ||
if ( this.isEnabled ) { | ||
this._startListening(); | ||
} else { | ||
this.stopListening( model.document.selection ); | ||
this.stopListening( model.document ); | ||
} | ||
} ); | ||
this._startListening(); | ||
@@ -50,3 +78,3 @@ } | ||
document.selection.on( 'change:range', ( evt, { directChange } ) => { | ||
this.listenTo( document.selection, 'change:range', ( evt, { directChange } ) => { | ||
// Indirect changes (i.e. when the user types or external changes are applied) are handled in the document's change event. | ||
@@ -70,3 +98,3 @@ if ( !directChange ) { | ||
document.on( 'change:data', ( evt, batch ) => { | ||
this.listenTo( document, 'change:data', ( evt, batch ) => { | ||
if ( batch.type == 'transparent' ) { | ||
@@ -136,3 +164,2 @@ return; | ||
mix( TextWatcher, EmitterMixin ); | ||
mix( TextWatcher, ObservableMixin ); |
/** | ||
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved. | ||
* @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
@@ -4,0 +4,0 @@ */ |
/** | ||
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved. | ||
* @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
@@ -4,0 +4,0 @@ */ |
/** | ||
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved. | ||
* @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
@@ -4,0 +4,0 @@ */ |
/** | ||
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved. | ||
* @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
@@ -4,0 +4,0 @@ */ |
/** | ||
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved. | ||
* @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
@@ -4,0 +4,0 @@ */ |
/** | ||
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved. | ||
* @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
@@ -4,0 +4,0 @@ */ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
87166
1760
18
+ Added@ckeditor/ckeditor5-core@17.0.0(transitive)
+ Added@ckeditor/ckeditor5-engine@17.0.0(transitive)
+ Added@ckeditor/ckeditor5-utils@17.0.0(transitive)
- Removed@ckeditor/ckeditor5-core@16.0.0(transitive)
- Removed@ckeditor/ckeditor5-engine@16.0.0(transitive)
- Removed@ckeditor/ckeditor5-utils@16.0.0(transitive)