@ckeditor/ckeditor5-typing 31.0.0 → 33.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/package.json +17 -17
- package/src/delete.js +1 -1
- package/src/deletecommand.js +8 -3
- package/src/deleteobserver.js +11 -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 +11 -2
- package/src/utils/inlinehighlight.js +1 -1
- package/src/utils/utils.js +20 -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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-typing",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "33.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": "^33.0.0",
|
|
16
|
+
"@ckeditor/ckeditor5-engine": "^33.0.0",
|
|
17
|
+
"@ckeditor/ckeditor5-utils": "^33.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": "^33.0.0",
|
|
22
|
+
"@ckeditor/ckeditor5-block-quote": "^33.0.0",
|
|
23
|
+
"@ckeditor/ckeditor5-editor-classic": "^33.0.0",
|
|
24
|
+
"@ckeditor/ckeditor5-enter": "^33.0.0",
|
|
25
|
+
"@ckeditor/ckeditor5-essentials": "^33.0.0",
|
|
26
|
+
"@ckeditor/ckeditor5-heading": "^33.0.0",
|
|
27
|
+
"@ckeditor/ckeditor5-image": "^33.0.0",
|
|
28
|
+
"@ckeditor/ckeditor5-link": "^33.0.0",
|
|
29
|
+
"@ckeditor/ckeditor5-list": "^33.0.0",
|
|
30
|
+
"@ckeditor/ckeditor5-paragraph": "^33.0.0",
|
|
31
|
+
"@ckeditor/ckeditor5-undo": "^33.0.0",
|
|
32
|
+
"@ckeditor/ckeditor5-code-block": "^33.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
|
|
|
@@ -12,6 +12,7 @@ import DomEventData from '@ckeditor/ckeditor5-engine/src/view/observer/domeventd
|
|
|
12
12
|
import BubblingEventInfo from '@ckeditor/ckeditor5-engine/src/view/observer/bubblingeventinfo';
|
|
13
13
|
import { keyCodes } from '@ckeditor/ckeditor5-utils/src/keyboard';
|
|
14
14
|
import env from '@ckeditor/ckeditor5-utils/src/env';
|
|
15
|
+
import { isShiftDeleteOnNonCollapsedSelection } from './utils/utils';
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* Delete observer introduces the {@link module:engine/view/document~Document#event:delete} event.
|
|
@@ -35,6 +36,15 @@ export default class DeleteObserver extends Observer {
|
|
|
35
36
|
} );
|
|
36
37
|
|
|
37
38
|
document.on( 'keydown', ( evt, data ) => {
|
|
39
|
+
// Do not fire the `delete` event, if Shift + Delete key combination was pressed on a non-collapsed selection on Windows.
|
|
40
|
+
//
|
|
41
|
+
// The Shift + Delete key combination should work in the same way as the `cut` event on a non-collapsed selection on Windows.
|
|
42
|
+
// In fact, the native `cut` event is actually emitted in this case, but with lower priority. Therefore, in order to handle the
|
|
43
|
+
// Shift + Delete key combination correctly, it is enough not to emit the `delete` event.
|
|
44
|
+
if ( env.isWindows && isShiftDeleteOnNonCollapsedSelection( data, document ) ) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
38
48
|
const deleteData = {};
|
|
39
49
|
|
|
40
50
|
if ( data.keyCode == keyCodes.delete ) {
|
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
|
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
import { getCode } from '@ckeditor/ckeditor5-utils/src/keyboard';
|
|
11
11
|
import env from '@ckeditor/ckeditor5-utils/src/env';
|
|
12
|
+
import { isShiftDeleteOnNonCollapsedSelection } from './utils';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Handles keystrokes which are unsafe for typing. This handler's logic is explained
|
|
@@ -49,6 +50,15 @@ export default function injectUnsafeKeystrokesHandling( editor ) {
|
|
|
49
50
|
//
|
|
50
51
|
// @param {module:engine/view/observer/keyobserver~KeyEventData} evtData
|
|
51
52
|
function handleUnsafeKeystroke( evtData ) {
|
|
53
|
+
// Do not delete the content, if Shift + Delete key combination was pressed on a non-collapsed selection on Windows.
|
|
54
|
+
//
|
|
55
|
+
// The Shift + Delete key combination should work in the same way as the `cut` event on a non-collapsed selection on Windows.
|
|
56
|
+
// In fact, the native `cut` event is actually emitted in this case, but with lower priority. Therefore, in order to handle the
|
|
57
|
+
// Shift + Delete key combination correctly, it is enough to prevent the content deletion here.
|
|
58
|
+
if ( env.isWindows && isShiftDeleteOnNonCollapsedSelection( evtData, view.document ) ) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
52
62
|
const doc = model.document;
|
|
53
63
|
const isComposing = view.document.isComposing;
|
|
54
64
|
const isSelectionUnchanged = latestCompositionSelection && latestCompositionSelection.isEqual( doc.selection );
|
|
@@ -111,7 +121,6 @@ export default function injectUnsafeKeystrokesHandling( editor ) {
|
|
|
111
121
|
buffer.lock();
|
|
112
122
|
|
|
113
123
|
const batch = buffer.batch;
|
|
114
|
-
inputCommand._batches.add( batch );
|
|
115
124
|
|
|
116
125
|
model.enqueueChange( batch, () => {
|
|
117
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
|
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
import diff from '@ckeditor/ckeditor5-utils/src/diff';
|
|
11
11
|
import diffToChanges from '@ckeditor/ckeditor5-utils/src/difftochanges';
|
|
12
|
+
import { keyCodes } from '@ckeditor/ckeditor5-utils/src/keyboard';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Returns true if container children have mutated or more than a single text node was changed.
|
|
@@ -83,3 +84,21 @@ export function compareChildNodes( oldChild, newChild ) {
|
|
|
83
84
|
return oldChild === newChild;
|
|
84
85
|
}
|
|
85
86
|
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Checks if <kbd>Shift</kbd> + <kbd>Delete</kbd> keystroke was pressed on a non-collapsed selection.
|
|
90
|
+
*
|
|
91
|
+
* This key combination has a special meaning on Windows machines and it should work in the same way as the `cut` event on a non-collapsed
|
|
92
|
+
* selection.
|
|
93
|
+
*
|
|
94
|
+
* @param {module:engine/view/observer/domeventdata~DomEventData} domEventData Event data.
|
|
95
|
+
* @param {module:engine/view/document~Document} document The document instance on which the event has been fired.
|
|
96
|
+
* @returns {Boolean}
|
|
97
|
+
*/
|
|
98
|
+
export function isShiftDeleteOnNonCollapsedSelection( domEventData, document ) {
|
|
99
|
+
const selection = document.selection;
|
|
100
|
+
const isShiftDelete = domEventData.shiftKey && domEventData.keyCode === keyCodes.delete;
|
|
101
|
+
const isNonCollapsedSelection = !selection.isCollapsed;
|
|
102
|
+
|
|
103
|
+
return isShiftDelete && isNonCollapsedSelection;
|
|
104
|
+
}
|