@ckeditor/ckeditor5-typing 31.1.0 → 34.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +2 -2
- package/README.md +2 -1
- package/package.json +17 -17
- package/src/delete.js +1 -1
- package/src/deletecommand.js +8 -3
- package/src/deleteobserver.js +1 -1
- package/src/index.js +1 -1
- package/src/input.js +1 -24
- package/src/inputcommand.js +1 -13
- package/src/texttransformation.js +4 -4
- package/src/textwatcher.js +2 -2
- package/src/twostepcaretmovement.js +1 -1
- package/src/typing.js +1 -1
- package/src/utils/changebuffer.js +4 -4
- package/src/utils/findattributerange.js +1 -1
- package/src/utils/getlasttextline.js +1 -1
- package/src/utils/injecttypingmutationshandling.js +1 -1
- package/src/utils/injectunsafekeystrokeshandling.js +1 -2
- package/src/utils/inlinehighlight.js +1 -1
- package/src/utils/utils.js +1 -1
package/LICENSE.md
CHANGED
|
@@ -2,7 +2,7 @@ Software License Agreement
|
|
|
2
2
|
==========================
|
|
3
3
|
|
|
4
4
|
**CKEditor 5 typing feature** – https://github.com/ckeditor/ckeditor5-typing <br>
|
|
5
|
-
Copyright (c) 2003-
|
|
5
|
+
Copyright (c) 2003-2022, [CKSource](http://cksource.com) Holding sp. z o.o. All rights reserved.
|
|
6
6
|
|
|
7
7
|
Licensed under the terms of [GNU General Public License Version 2 or later](http://www.gnu.org/licenses/gpl.html).
|
|
8
8
|
|
|
@@ -14,4 +14,4 @@ Where not otherwise indicated, all CKEditor content is authored by CKSource engi
|
|
|
14
14
|
Trademarks
|
|
15
15
|
----------
|
|
16
16
|
|
|
17
|
-
**CKEditor** is a trademark of [CKSource](http://cksource.com)
|
|
17
|
+
**CKEditor** is a trademark of [CKSource](http://cksource.com) Holding sp. z o.o. All other brand and product names are trademarks, registered trademarks or service marks of their respective holders.
|
package/README.md
CHANGED
|
@@ -3,7 +3,8 @@ CKEditor 5 typing feature
|
|
|
3
3
|
|
|
4
4
|
[](https://www.npmjs.com/package/@ckeditor/ckeditor5-typing)
|
|
5
5
|
[](https://coveralls.io/github/ckeditor/ckeditor5?branch=master)
|
|
6
|
-
[](https://travis-ci.com/ckeditor/ckeditor5)
|
|
6
|
+
[](https://app.travis-ci.com/github/ckeditor/ckeditor5)
|
|
7
|
+

|
|
7
8
|
|
|
8
9
|
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.
|
|
9
10
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-typing",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "34.0.0",
|
|
4
4
|
"description": "Typing feature for CKEditor 5.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ckeditor",
|
|
@@ -12,27 +12,27 @@
|
|
|
12
12
|
],
|
|
13
13
|
"main": "src/index.js",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@ckeditor/ckeditor5-core": "^
|
|
16
|
-
"@ckeditor/ckeditor5-engine": "^
|
|
17
|
-
"@ckeditor/ckeditor5-utils": "^
|
|
15
|
+
"@ckeditor/ckeditor5-core": "^34.0.0",
|
|
16
|
+
"@ckeditor/ckeditor5-engine": "^34.0.0",
|
|
17
|
+
"@ckeditor/ckeditor5-utils": "^34.0.0",
|
|
18
18
|
"lodash-es": "^4.17.15"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@ckeditor/ckeditor5-basic-styles": "^
|
|
22
|
-
"@ckeditor/ckeditor5-block-quote": "^
|
|
23
|
-
"@ckeditor/ckeditor5-editor-classic": "^
|
|
24
|
-
"@ckeditor/ckeditor5-enter": "^
|
|
25
|
-
"@ckeditor/ckeditor5-essentials": "^
|
|
26
|
-
"@ckeditor/ckeditor5-heading": "^
|
|
27
|
-
"@ckeditor/ckeditor5-image": "^
|
|
28
|
-
"@ckeditor/ckeditor5-link": "^
|
|
29
|
-
"@ckeditor/ckeditor5-list": "^
|
|
30
|
-
"@ckeditor/ckeditor5-paragraph": "^
|
|
31
|
-
"@ckeditor/ckeditor5-undo": "^
|
|
32
|
-
"@ckeditor/ckeditor5-code-block": "^
|
|
21
|
+
"@ckeditor/ckeditor5-basic-styles": "^34.0.0",
|
|
22
|
+
"@ckeditor/ckeditor5-block-quote": "^34.0.0",
|
|
23
|
+
"@ckeditor/ckeditor5-editor-classic": "^34.0.0",
|
|
24
|
+
"@ckeditor/ckeditor5-enter": "^34.0.0",
|
|
25
|
+
"@ckeditor/ckeditor5-essentials": "^34.0.0",
|
|
26
|
+
"@ckeditor/ckeditor5-heading": "^34.0.0",
|
|
27
|
+
"@ckeditor/ckeditor5-image": "^34.0.0",
|
|
28
|
+
"@ckeditor/ckeditor5-link": "^34.0.0",
|
|
29
|
+
"@ckeditor/ckeditor5-list": "^34.0.0",
|
|
30
|
+
"@ckeditor/ckeditor5-paragraph": "^34.0.0",
|
|
31
|
+
"@ckeditor/ckeditor5-undo": "^34.0.0",
|
|
32
|
+
"@ckeditor/ckeditor5-code-block": "^34.0.0"
|
|
33
33
|
},
|
|
34
34
|
"engines": {
|
|
35
|
-
"node": ">=
|
|
35
|
+
"node": ">=14.0.0",
|
|
36
36
|
"npm": ">=5.7.1"
|
|
37
37
|
},
|
|
38
38
|
"author": "CKSource (http://cksource.com/)",
|
package/src/delete.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
|
package/src/deletecommand.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -63,7 +63,8 @@ export default class DeleteCommand extends Command {
|
|
|
63
63
|
*
|
|
64
64
|
* @fires execute
|
|
65
65
|
* @param {Object} [options] The command options.
|
|
66
|
-
* @param {'character'} [options.unit='character']
|
|
66
|
+
* @param {'character'|'codePoint'|'word'} [options.unit='character']
|
|
67
|
+
* See {@link module:engine/model/utils/modifyselection~modifySelection}'s options.
|
|
67
68
|
* @param {Number} [options.sequence=1] A number describing which subsequent delete event it is without the key being released.
|
|
68
69
|
* See the {@link module:engine/view/document~Document#event:delete} event data.
|
|
69
70
|
* @param {module:engine/model/selection~Selection} [options.selection] Selection to remove. If not set, current model selection
|
|
@@ -88,7 +89,11 @@ export default class DeleteCommand extends Command {
|
|
|
88
89
|
|
|
89
90
|
// Try to extend the selection in the specified direction.
|
|
90
91
|
if ( selection.isCollapsed ) {
|
|
91
|
-
model.modifySelection( selection, {
|
|
92
|
+
model.modifySelection( selection, {
|
|
93
|
+
direction: this.direction,
|
|
94
|
+
unit: options.unit,
|
|
95
|
+
treatEmojiAsSingleUnit: true
|
|
96
|
+
} );
|
|
92
97
|
}
|
|
93
98
|
|
|
94
99
|
// Check if deleting in an empty editor. See #61.
|
package/src/deleteobserver.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
|
package/src/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
|
package/src/input.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -40,27 +40,4 @@ export default class Input extends Plugin {
|
|
|
40
40
|
injectUnsafeKeystrokesHandling( editor );
|
|
41
41
|
injectTypingMutationsHandling( editor );
|
|
42
42
|
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Checks batch if it is a result of user input - e.g. typing.
|
|
46
|
-
*
|
|
47
|
-
* const input = editor.plugins.get( 'Input' );
|
|
48
|
-
*
|
|
49
|
-
* editor.model.document.on( 'change:data', ( evt, batch ) => {
|
|
50
|
-
* if ( input.isInput( batch ) ) {
|
|
51
|
-
* console.log( 'The user typed something...' );
|
|
52
|
-
* }
|
|
53
|
-
* } );
|
|
54
|
-
*
|
|
55
|
-
* **Note:** This method checks if the batch was created using {@link module:typing/inputcommand~InputCommand 'input'}
|
|
56
|
-
* command as typing changes coming from user input are inserted to the document using that command.
|
|
57
|
-
*
|
|
58
|
-
* @param {module:engine/model/batch~Batch} batch A batch to check.
|
|
59
|
-
* @returns {Boolean}
|
|
60
|
-
*/
|
|
61
|
-
isInput( batch ) {
|
|
62
|
-
const inputCommand = this.editor.commands.get( 'input' );
|
|
63
|
-
|
|
64
|
-
return inputCommand._batches.has( batch );
|
|
65
|
-
}
|
|
66
43
|
}
|
package/src/inputcommand.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -35,15 +35,6 @@ export default class InputCommand extends Command {
|
|
|
35
35
|
* @member {module:typing/utils/changebuffer~ChangeBuffer} #_buffer
|
|
36
36
|
*/
|
|
37
37
|
this._buffer = new ChangeBuffer( editor.model, undoStepSize );
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Stores batches created by the input command. The batches are used to differentiate input batches from other batches using
|
|
41
|
-
* {@link module:typing/input~Input#isInput} method.
|
|
42
|
-
*
|
|
43
|
-
* @type {WeakSet<module:engine/model/batch~Batch>}
|
|
44
|
-
* @protected
|
|
45
|
-
*/
|
|
46
|
-
this._batches = new WeakSet();
|
|
47
38
|
}
|
|
48
39
|
|
|
49
40
|
/**
|
|
@@ -89,9 +80,6 @@ export default class InputCommand extends Command {
|
|
|
89
80
|
model.enqueueChange( this._buffer.batch, writer => {
|
|
90
81
|
this._buffer.lock();
|
|
91
82
|
|
|
92
|
-
// Store the batch as an 'input' batch for the Input.isInput( batch ) check.
|
|
93
|
-
this._batches.add( this._buffer.batch );
|
|
94
|
-
|
|
95
83
|
model.deleteContent( selection );
|
|
96
84
|
|
|
97
85
|
if ( text ) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -124,7 +124,6 @@ export default class TextTransformation extends Plugin {
|
|
|
124
124
|
_enableTransformationWatchers() {
|
|
125
125
|
const editor = this.editor;
|
|
126
126
|
const model = editor.model;
|
|
127
|
-
const inputPlugin = editor.plugins.get( 'Input' );
|
|
128
127
|
const deletePlugin = editor.plugins.get( 'Delete' );
|
|
129
128
|
const normalizedTransformations = normalizeTransformations( editor.config.get( 'typing.transformations' ) );
|
|
130
129
|
|
|
@@ -140,7 +139,7 @@ export default class TextTransformation extends Plugin {
|
|
|
140
139
|
};
|
|
141
140
|
|
|
142
141
|
const watcherCallback = ( evt, data ) => {
|
|
143
|
-
if ( !
|
|
142
|
+
if ( !data.batch.isTyping ) {
|
|
144
143
|
return;
|
|
145
144
|
}
|
|
146
145
|
|
|
@@ -249,8 +248,9 @@ function normalizeTransformations( config ) {
|
|
|
249
248
|
const configured = config.include.concat( extra ).filter( isNotRemoved );
|
|
250
249
|
|
|
251
250
|
return expandGroupsAndRemoveDuplicates( configured )
|
|
252
|
-
.filter( isNotRemoved ) // Filter out 'remove' transformations as they might be set in group
|
|
251
|
+
.filter( isNotRemoved ) // Filter out 'remove' transformations as they might be set in group.
|
|
253
252
|
.map( transformation => TRANSFORMATIONS[ transformation ] || transformation )
|
|
253
|
+
.filter( transformation => typeof transformation === 'object' ) // Filter out transformations set as string that has not been found.
|
|
254
254
|
.map( transformation => ( {
|
|
255
255
|
from: normalizeFrom( transformation.from ),
|
|
256
256
|
to: normalizeTo( transformation.to )
|
package/src/textwatcher.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -117,7 +117,7 @@ export default class TextWatcher {
|
|
|
117
117
|
} );
|
|
118
118
|
|
|
119
119
|
this.listenTo( document, 'change:data', ( evt, batch ) => {
|
|
120
|
-
if ( batch.
|
|
120
|
+
if ( batch.isUndo || !batch.isLocal ) {
|
|
121
121
|
return;
|
|
122
122
|
}
|
|
123
123
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
|
package/src/typing.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -70,10 +70,10 @@ export default class ChangeBuffer {
|
|
|
70
70
|
// The callback will check whether it is a new batch and in that case the buffer will be flushed.
|
|
71
71
|
//
|
|
72
72
|
// The reason why the buffer needs to be flushed whenever a new batch appears is that the changes added afterwards
|
|
73
|
-
// should be added to a new batch. For instance, when the
|
|
73
|
+
// should be added to a new batch. For instance, when the user types, then inserts an image, and then types again,
|
|
74
74
|
// the characters typed after inserting the image should be added to a different batch than the characters typed before.
|
|
75
75
|
this._changeCallback = ( evt, batch ) => {
|
|
76
|
-
if ( batch.
|
|
76
|
+
if ( batch.isLocal && batch.isUndoable && batch !== this._batch ) {
|
|
77
77
|
this._reset( true );
|
|
78
78
|
}
|
|
79
79
|
};
|
|
@@ -117,7 +117,7 @@ export default class ChangeBuffer {
|
|
|
117
117
|
*/
|
|
118
118
|
get batch() {
|
|
119
119
|
if ( !this._batch ) {
|
|
120
|
-
this._batch = this.model.createBatch();
|
|
120
|
+
this._batch = this.model.createBatch( { isTyping: true } );
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
return this._batch;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -121,7 +121,6 @@ export default function injectUnsafeKeystrokesHandling( editor ) {
|
|
|
121
121
|
buffer.lock();
|
|
122
122
|
|
|
123
123
|
const batch = buffer.batch;
|
|
124
|
-
inputCommand._batches.add( batch );
|
|
125
124
|
|
|
126
125
|
model.enqueueChange( batch, () => {
|
|
127
126
|
model.deleteContent( model.document.selection );
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
|
package/src/utils/utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
|