Socket
Socket
Sign inDemoInstall

@ckeditor/ckeditor5-typing

Package Overview
Dependencies
Maintainers
1
Versions
620
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ckeditor/ckeditor5-typing - npm Package Compare versions

Comparing version 12.1.1 to 12.2.0

16

CHANGELOG.md
Changelog
=========
## [12.2.0](https://github.com/ckeditor/ckeditor5-typing/compare/v12.1.1...v12.2.0) (2019-08-26)
### Features
* Introduced `Input#isInput()`. Closes [#214](https://github.com/ckeditor/ckeditor5-typing/issues/214). Fixed the `TextTransformation` feature so it willl trigger only for typing changes. Closes [#208](https://github.com/ckeditor/ckeditor5-typing/issues/208). ([0e26850](https://github.com/ckeditor/ckeditor5-typing/commit/0e26850))
### Bug fixes
* Allow dashes on the begging of a line. Closes [#200](https://github.com/ckeditor/ckeditor5-typing/issues/200). ([6ef7d47](https://github.com/ckeditor/ckeditor5-typing/commit/6ef7d47))
* Typing on mobile device will not throw after each typed character. ([056b036](https://github.com/ckeditor/ckeditor5-typing/commit/056b036))
### Other changes
* The issue tracker for this package was moved to https://github.com/ckeditor/ckeditor5/issues. See [ckeditor/ckeditor5#1988](https://github.com/ckeditor/ckeditor5/issues/1988). ([6491e8d](https://github.com/ckeditor/ckeditor5-typing/commit/6491e8d))
## [12.1.1](https://github.com/ckeditor/ckeditor5-typing/compare/v12.1.0...v12.1.1) (2019-07-10)

@@ -5,0 +21,0 @@

32

package.json
{
"name": "@ckeditor/ckeditor5-typing",
"version": "12.1.1",
"version": "12.2.0",
"description": "Typing feature for CKEditor 5.",

@@ -13,19 +13,19 @@ "keywords": [

"dependencies": {
"@ckeditor/ckeditor5-core": "^12.2.1",
"@ckeditor/ckeditor5-engine": "^13.2.1",
"@ckeditor/ckeditor5-utils": "^13.0.1",
"@ckeditor/ckeditor5-core": "^12.3.0",
"@ckeditor/ckeditor5-engine": "^14.0.0",
"@ckeditor/ckeditor5-utils": "^14.0.0",
"lodash-es": "^4.17.10"
},
"devDependencies": {
"@ckeditor/ckeditor5-basic-styles": "^11.1.3",
"@ckeditor/ckeditor5-block-quote": "^11.1.2",
"@ckeditor/ckeditor5-editor-classic": "^12.1.3",
"@ckeditor/ckeditor5-enter": "^11.0.4",
"@ckeditor/ckeditor5-essentials": "^11.0.4",
"@ckeditor/ckeditor5-heading": "^11.0.4",
"@ckeditor/ckeditor5-image": "^13.1.2",
"@ckeditor/ckeditor5-link": "^11.1.1",
"@ckeditor/ckeditor5-list": "^12.0.4",
"@ckeditor/ckeditor5-paragraph": "^11.0.4",
"@ckeditor/ckeditor5-undo": "^11.0.4",
"@ckeditor/ckeditor5-basic-styles": "^11.1.4",
"@ckeditor/ckeditor5-block-quote": "^11.1.3",
"@ckeditor/ckeditor5-editor-classic": "^12.1.4",
"@ckeditor/ckeditor5-enter": "^11.1.0",
"@ckeditor/ckeditor5-essentials": "^11.0.5",
"@ckeditor/ckeditor5-heading": "^11.0.5",
"@ckeditor/ckeditor5-image": "^14.0.0",
"@ckeditor/ckeditor5-link": "^11.1.2",
"@ckeditor/ckeditor5-list": "^12.1.0",
"@ckeditor/ckeditor5-paragraph": "^11.0.5",
"@ckeditor/ckeditor5-undo": "^11.0.5",
"eslint": "^5.5.0",

@@ -43,3 +43,3 @@ "eslint-config-ckeditor5": "^2.0.0",

"homepage": "https://ckeditor.com/ckeditor-5",
"bugs": "https://github.com/ckeditor/ckeditor5-typing/issues",
"bugs": "https://github.com/ckeditor/ckeditor5/issues",
"repository": {

@@ -46,0 +46,0 @@ "type": "git",

@@ -12,3 +12,3 @@ CKEditor 5 typing feature

This package implements support for typing (inputting and deleting text) in CKEditor 5.
This package implements support for typing (inputting and deleting text) in CKEditor 5. It also includes the automatic text transformations (autocorrect) feature that lets you automatically turn predefined snippets into their improved forms.

@@ -15,0 +15,0 @@ ## Documentation

@@ -85,8 +85,10 @@ /**

this.listenTo( viewDocument, 'keyup', ( evt, data ) => {
const domSelection = data.domTarget.ownerDocument.defaultView.getSelection();
if ( domSelectionAfterDeletion ) {
const domSelection = data.domTarget.ownerDocument.defaultView.getSelection();
domSelection.collapse( domSelectionAfterDeletion.anchorNode, domSelectionAfterDeletion.anchorOffset );
domSelection.extend( domSelectionAfterDeletion.focusNode, domSelectionAfterDeletion.focusOffset );
domSelection.collapse( domSelectionAfterDeletion.anchorNode, domSelectionAfterDeletion.anchorOffset );
domSelection.extend( domSelectionAfterDeletion.focusNode, domSelectionAfterDeletion.focusOffset );
domSelectionAfterDeletion = null;
domSelectionAfterDeletion = null;
}
} );

@@ -93,0 +95,0 @@ }

@@ -43,2 +43,25 @@ /**

}
/**
* Checks batch if it is a result of user input - e.g. typing.
*
* const input = editor.plugins.get( 'Input' );
*
* editor.model.document.on( 'change:data', ( evt, batch ) => {
* if ( input.isTyping( batch ) ) {
* console.log( 'The user typed something...' );
* }
* } );
*
* **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' );
return inputCommand._batches.has( batch );
}
}

@@ -38,2 +38,11 @@ /**

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>}
* @protected
*/
this._batches = new WeakSet();
}

@@ -102,4 +111,7 @@

this._buffer.input( textInsertions );
// Store the batch as an 'input' batch for the Input.isInput( batch ) check.
this._batches.add( this._buffer.batch );
} );
}
}

@@ -35,5 +35,4 @@ /**

horizontalEllipsis: { from: '...', to: '…' },
enDash: { from: ' -- ', to: ' – ' },
emDash: { from: ' --- ', to: ' — ' },
enDash: { from: /(^| )(--)( )$/, to: [ null, '–', null ] },
emDash: { from: /(^| )(---)( )$/, to: [ null, '—', null ] },
// Quotations:

@@ -65,3 +64,3 @@ // English, US

// Set of default transformations provided by the feature.
// A set of default transformations provided by the feature.
const DEFAULT_TRANSFORMATIONS = [

@@ -106,2 +105,3 @@ 'symbols',

const model = editor.model;
const input = editor.plugins.get( 'Input' );

@@ -117,2 +117,6 @@ const configuredTransformations = getConfiguredTransformations( editor.config.get( 'typing.transformations' ) );

watcher.on( 'matched:data', ( evt, data ) => {
if ( !input.isInput( data.batch ) ) {
return;
}
const matches = from.exec( data.text );

@@ -151,4 +155,5 @@ const replaces = to( matches.slice( 1 ) );

// Normalizes config `from` parameter value.
// The normalized value for `from` parameter is a RegExp instance. If passed `from` is already a RegExp instance it is returned unchanged.
// Normalizes the configuration `from` parameter value.
// The normalized value for the `from` parameter is a RegExp instance. If the passed `from` is already a RegExp instance,
// it is returned unchanged.
//

@@ -159,3 +164,3 @@ // @param {String|RegExp} from

if ( typeof from == 'string' ) {
return new RegExp( '(' + escapeRegExp( from ) + ')$' );
return new RegExp( `(${ escapeRegExp( from ) })$` );
}

@@ -167,5 +172,5 @@

// Normalizes config `to` parameter value.
// The normalized value for `to` parameter is a function that takes an array and returns an array. See more in configuration description.
// If passed `to` is already a function it is returned unchanged.
// Normalizes the configuration `to` parameter value.
// The normalized value for the `to` parameter is a function that takes an array and returns an array. See more in the
// configuration description. If the passed `to` is already a function, it is returned unchanged.
//

@@ -243,27 +248,27 @@ // @param {String|Array.<null|String>|Function} to

/**
* Text transformation definition object. Describes what should be replaced with what.
* The text transformation definition object. It describes what should be replaced with what.
*
* The input value (`from`) can be passed either as a string or a regexp.
* The input value (`from`) can be passed either as a string or as a regular expression.
*
* * If a string is passed it will be simply checked if the end of the input matches it.
* * If a regexp is passed, its entire length must be covered with capturing groups (e.g. `/(foo)(bar)$/`).
* * If a string is passed, it will be simply checked if the end of the input matches it.
* * If a regular expression is passed, its entire length must be covered with capturing groups (e.g. `/(foo)(bar)$/`).
* Also, since it is compared against the end of the input, it has to end with `$` to be correctly matched.
* See examples below.
*
* The output value (`to`) can be passed either as a string or an array or a function.
* The output value (`to`) can be passed as a string, as an array or as a function.
*
* * If a string is passed, it will be used as a replacement value as-is. Note, that a string output value can be used only if
* the input value is a string too.
* * If an array is passed it has to have the same number of elements as there are capturing groups in the input value regexp.
* Each capture group will be replaced by a corresponding string from the passed array. If given capturing group should not be replaced,
* * If a string is passed, it will be used as a replacement value as-is. Note that a string output value can be used only if
* the input value is a string, too.
* * If an array is passed, it has to have the same number of elements as there are capturing groups in the input value regular expression.
* Each capture group will be replaced with a corresponding string from the passed array. If a given capturing group should not be replaced,
* use `null` instead of passing a string.
* * If a function is used, it should return an array as described above. The function is passed one parameter &mdash; an array with matches
* by the regexp. See the examples below.
* by the regular expression. See the examples below.
*
* Simple string-to-string replacement:
* A simple string-to-string replacement:
*
* { from: '(c)', to: '©' }
*
* Change quotes styles using regular expression. Note how all the parts are in separate capturing groups and the space at the beginning and
* the text inside quotes are not replaced (`null` passed as the first and the third value in `to` parameter):
* Change quote styles using a regular expression. Note how all the parts are in separate capturing groups and the space at the beginning
* and the text inside quotes are not replaced (`null` passed as the first and the third value in the `to` parameter):
*

@@ -283,4 +288,4 @@ * {

* @typedef {Object} module:typing/texttransformation~TextTransformationDescription
* @property {String|RegExp} from The string or RegExp to transform.
* @property {String} to The text to transform compatible with `String.replace()`
* @property {String|RegExp} from The string or regular expression to transform.
* @property {String} to The text to transform compatible with `String.replace()`.
*/

@@ -324,12 +329,12 @@

* * Mathematical (group name: `mathematical`)
* - `oneHalf`: transforms `1/2`, to: `½`
* - `oneThird`: transforms `1/3`, to: `⅓`
* - `twoThirds`: transforms `2/3`, to: `⅔`
* - `oneForth`: transforms `1/4`, to: `¼`
* - `threeQuarters`: transforms `3/4`, to: `¾`
* - `lessThanOrEqual`: transforms `<=`, to: `≤`
* - `greaterThanOrEqual`: transforms `>=`, to: `≥`
* - `notEqual`: transforms `!=`, to: `≠`
* - `arrowLeft`: transforms `<-`, to: `←`
* - `arrowRight`: transforms `->`, to: `→`
* - `oneHalf`: transforms `1/2` to: `½`
* - `oneThird`: transforms `1/3` to: `⅓`
* - `twoThirds`: transforms `2/3` to: `⅔`
* - `oneForth`: transforms `1/4` to: `¼`
* - `threeQuarters`: transforms `3/4` to: `¾`
* - `lessThanOrEqual`: transforms `<=` to: `≤`
* - `greaterThanOrEqual`: transforms `>=` to: `≥`
* - `notEqual`: transforms `!=` to: `≠`
* - `arrowLeft`: transforms `<-` to: `←`
* - `arrowRight`: transforms `->` to: `→`
* * Misc:

@@ -374,6 +379,6 @@ * - `quotesPrimaryEnGb`: transforms `'Foo bar'` to `‘Foo bar’`

* The standard list of text transformations supported by the editor. By default it comes pre-configured with a couple dozen of them
* (see {@link module:typing/texttransformation~TextTransformationConfig} for the full list of them). You can override this list completely
* (see {@link module:typing/texttransformation~TextTransformationConfig} for the full list). You can override this list completely
* by setting this option or use the other two options
* ({@link module:typing/texttransformation~TextTransformationConfig#extra `transformations.extra`},
* {@link module:typing/texttransformation~TextTransformationConfig#remove `transformations.remove`}) to fine tune the default list.
* {@link module:typing/texttransformation~TextTransformationConfig#remove `transformations.remove`}) to fine-tune the default list.
*

@@ -384,3 +389,3 @@ * @member {Array.<module:typing/texttransformation~TextTransformationDescription>} module:typing/texttransformation~TextTransformationConfig#include

/**
* The extra text transformations that are added to the transformations defined in
* Additional text transformations that are added to the transformations defined in
* {@link module:typing/texttransformation~TextTransformationConfig#include `transformations.include`}.

@@ -398,3 +403,3 @@ *

/**
* The text transformations names that are removed from transformations defined in
* The text transformation names that are removed from transformations defined in
* {@link module:typing/texttransformation~TextTransformationConfig#include `transformations.include`} or

@@ -405,4 +410,4 @@ * {@link module:typing/texttransformation~TextTransformationConfig#extra `transformations.extra`}.

* remove: [
* 'ellipsis', // Remove only 'ellipsis' from 'typography' group.
* 'mathematical' // Remove all transformations from 'mathematical' group.
* 'ellipsis', // Remove only 'ellipsis' from the 'typography' group.
* 'mathematical' // Remove all transformations from the 'mathematical' group.
* ]

@@ -409,0 +414,0 @@ * }

@@ -16,3 +16,3 @@ /**

*
* Fires {@link module:typing/textwatcher~TextWatcher#event:matched:data `matched:data`},
* Fires the {@link module:typing/textwatcher~TextWatcher#event:matched:data `matched:data`},
* {@link module:typing/textwatcher~TextWatcher#event:matched:selection `matched:selection`} and

@@ -70,3 +70,3 @@ * {@link module:typing/textwatcher~TextWatcher#event:unmatched `unmatched`} events on typing or selection changes.

this._evaluateTextBeforeSelection( 'data' );
this._evaluateTextBeforeSelection( 'data', { batch } );
} );

@@ -83,5 +83,6 @@ }

* @private
* @param {'data'|'selection'} suffix Suffix used for generating event name.
* @param {'data'|'selection'} suffix A suffix used for generating the event name.
* @param {Object} data Data object for event.
*/
_evaluateTextBeforeSelection( suffix ) {
_evaluateTextBeforeSelection( suffix, data = {} ) {
const text = this._getText();

@@ -103,2 +104,4 @@

if ( textHasMatch ) {
const eventData = Object.assign( data, { text } );
/**

@@ -108,4 +111,6 @@ * Fired whenever the text watcher found a match for data changes.

* @event matched:data
* @param {Object} data Event data.
* @param {String} data.text The full text before selection.
* @param {module:engine/model/batch~Batch} data.batch A batch associated with a change.
*/
/**

@@ -115,4 +120,6 @@ * Fired whenever the text watcher found a match for selection changes.

* @event matched:selection
* @param {Object} data Event data.
* @param {String} data.text The full text before selection.
*/
this.fire( `matched:${ suffix }`, { text } );
this.fire( `matched:${ suffix }`, eventData );
}

@@ -119,0 +126,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc