@ckeditor/ckeditor5-typing 29.2.0 → 32.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 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-2021, [CKSource](http://cksource.com) Frederico Knabben. All rights reserved.
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) Frederico Knabben. All other brand and product names are trademarks, registered trademarks or service marks of their respective holders.
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": "29.2.0",
3
+ "version": "32.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": "^29.2.0",
16
- "@ckeditor/ckeditor5-engine": "^29.2.0",
17
- "@ckeditor/ckeditor5-utils": "^29.2.0",
15
+ "@ckeditor/ckeditor5-core": "^32.0.0",
16
+ "@ckeditor/ckeditor5-engine": "^32.0.0",
17
+ "@ckeditor/ckeditor5-utils": "^32.0.0",
18
18
  "lodash-es": "^4.17.15"
19
19
  },
20
20
  "devDependencies": {
21
- "@ckeditor/ckeditor5-basic-styles": "^29.2.0",
22
- "@ckeditor/ckeditor5-block-quote": "^29.2.0",
23
- "@ckeditor/ckeditor5-editor-classic": "^29.2.0",
24
- "@ckeditor/ckeditor5-enter": "^29.2.0",
25
- "@ckeditor/ckeditor5-essentials": "^29.2.0",
26
- "@ckeditor/ckeditor5-heading": "^29.2.0",
27
- "@ckeditor/ckeditor5-image": "^29.2.0",
28
- "@ckeditor/ckeditor5-link": "^29.2.0",
29
- "@ckeditor/ckeditor5-list": "^29.2.0",
30
- "@ckeditor/ckeditor5-paragraph": "^29.2.0",
31
- "@ckeditor/ckeditor5-undo": "^29.2.0",
32
- "@ckeditor/ckeditor5-code-block": "^29.2.0"
21
+ "@ckeditor/ckeditor5-basic-styles": "^32.0.0",
22
+ "@ckeditor/ckeditor5-block-quote": "^32.0.0",
23
+ "@ckeditor/ckeditor5-editor-classic": "^32.0.0",
24
+ "@ckeditor/ckeditor5-enter": "^32.0.0",
25
+ "@ckeditor/ckeditor5-essentials": "^32.0.0",
26
+ "@ckeditor/ckeditor5-heading": "^32.0.0",
27
+ "@ckeditor/ckeditor5-image": "^32.0.0",
28
+ "@ckeditor/ckeditor5-link": "^32.0.0",
29
+ "@ckeditor/ckeditor5-list": "^32.0.0",
30
+ "@ckeditor/ckeditor5-paragraph": "^32.0.0",
31
+ "@ckeditor/ckeditor5-undo": "^32.0.0",
32
+ "@ckeditor/ckeditor5-code-block": "^32.0.0"
33
33
  },
34
34
  "engines": {
35
- "node": ">=12.0.0",
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-2021, CKSource - Frederico Knabben. All rights reserved.
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
 
@@ -18,6 +18,13 @@ import env from '@ckeditor/ckeditor5-utils/src/env';
18
18
  * @extends module:core/plugin~Plugin
19
19
  */
20
20
  export default class Delete extends Plugin {
21
+ /**
22
+ * Whether pressing backspace should trigger undo action
23
+ *
24
+ * @private
25
+ * @member {Boolean} #_undoOnBackspace
26
+ */
27
+
21
28
  /**
22
29
  * @inheritDoc
23
30
  */
@@ -29,9 +36,12 @@ export default class Delete extends Plugin {
29
36
  const editor = this.editor;
30
37
  const view = editor.editing.view;
31
38
  const viewDocument = view.document;
39
+ const modelDocument = editor.model.document;
32
40
 
33
41
  view.addObserver( DeleteObserver );
34
42
 
43
+ this._undoOnBackspace = false;
44
+
35
45
  const deleteForwardCommand = new DeleteCommand( editor, 'forward' );
36
46
 
37
47
  // Register `deleteForward` command and add `forwardDelete` command as an alias for backward compatibility.
@@ -97,5 +107,33 @@ export default class Delete extends Plugin {
97
107
  }
98
108
  } );
99
109
  }
110
+
111
+ if ( this.editor.plugins.has( 'UndoEditing' ) ) {
112
+ this.listenTo( viewDocument, 'delete', ( evt, data ) => {
113
+ if ( this._undoOnBackspace && data.direction == 'backward' && data.sequence == 1 && data.unit == 'codePoint' ) {
114
+ this._undoOnBackspace = false;
115
+
116
+ editor.execute( 'undo' );
117
+
118
+ data.preventDefault();
119
+ evt.stop();
120
+ }
121
+ }, { context: '$capture' } );
122
+
123
+ this.listenTo( modelDocument, 'change', () => {
124
+ this._undoOnBackspace = false;
125
+ } );
126
+ }
127
+ }
128
+
129
+ /**
130
+ * If the next user action after calling this method is pressing backspace, it would undo the last change.
131
+ *
132
+ * Requires {@link module:undo/undoediting~UndoEditing} plugin. If not loaded, does nothing.
133
+ */
134
+ requestUndoOnBackspace() {
135
+ if ( this.editor.plugins.has( 'UndoEditing' ) ) {
136
+ this._undoOnBackspace = true;
137
+ }
100
138
  }
101
139
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
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-2021, CKSource - Frederico Knabben. All rights reserved.
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 ) {
@@ -111,7 +121,7 @@ export default class DeleteObserver extends Observer {
111
121
  * @event module:engine/view/document~Document#event:delete
112
122
  * @param {module:engine/view/observer/domeventdata~DomEventData} data
113
123
  * @param {'forward'|'delete'} data.direction The direction in which the deletion should happen.
114
- * @param {'character'|'word'} data.unit The "amount" of content that should be deleted.
124
+ * @param {'character'|'codePoint'|'word'} data.unit The "amount" of content that should be deleted.
115
125
  * @param {Number} data.sequence A number describing which subsequent delete event it is without the key being released.
116
126
  * If it's 2 or more it means that the key was pressed and hold.
117
127
  * @param {module:engine/view/selection~Selection} [data.selectionToRemove] View selection which content should be removed. If not set,
package/src/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
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-2021, CKSource - Frederico Knabben. All rights reserved.
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
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
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-2021, CKSource - Frederico Knabben. All rights reserved.
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
 
@@ -19,11 +19,11 @@ const TRANSFORMATIONS = {
19
19
  trademark: { from: '(tm)', to: '™' },
20
20
 
21
21
  // Mathematical:
22
- oneHalf: { from: '1/2', to: '½' },
23
- oneThird: { from: '1/3', to: '⅓' },
24
- twoThirds: { from: '2/3', to: '⅔' },
25
- oneForth: { from: '1/4', to: '¼' },
26
- threeQuarters: { from: '3/4', to: '¾' },
22
+ oneHalf: { from: /(^|[^/a-z0-9])(1\/2)([^/a-z0-9])$/i, to: [ null, '½', null ] },
23
+ oneThird: { from: /(^|[^/a-z0-9])(1\/3)([^/a-z0-9])$/i, to: [ null, '⅓', null ] },
24
+ twoThirds: { from: /(^|[^/a-z0-9])(2\/3)([^/a-z0-9])$/i, to: [ null, '⅔', null ] },
25
+ oneForth: { from: /(^|[^/a-z0-9])(1\/4)([^/a-z0-9])$/i, to: [ null, '¼', null ] },
26
+ threeQuarters: { from: /(^|[^/a-z0-9])(3\/4)([^/a-z0-9])$/i, to: [ null, '¾', null ] },
27
27
  lessThanOrEqual: { from: '<=', to: '≤' },
28
28
  greaterThanOrEqual: { from: '>=', to: '≥' },
29
29
  notEqual: { from: '!=', to: '≠' },
@@ -74,6 +74,13 @@ const DEFAULT_TRANSFORMATIONS = [
74
74
  * @extends module:core/plugin~Plugin
75
75
  */
76
76
  export default class TextTransformation extends Plugin {
77
+ /**
78
+ * @inheritDoc
79
+ */
80
+ static get requires() {
81
+ return [ 'Delete', 'Input' ];
82
+ }
83
+
77
84
  /**
78
85
  * @inheritDoc
79
86
  */
@@ -117,7 +124,7 @@ export default class TextTransformation extends Plugin {
117
124
  _enableTransformationWatchers() {
118
125
  const editor = this.editor;
119
126
  const model = editor.model;
120
- const input = editor.plugins.get( 'Input' );
127
+ const deletePlugin = editor.plugins.get( 'Delete' );
121
128
  const normalizedTransformations = normalizeTransformations( editor.config.get( 'typing.transformations' ) );
122
129
 
123
130
  const testCallback = text => {
@@ -132,7 +139,7 @@ export default class TextTransformation extends Plugin {
132
139
  };
133
140
 
134
141
  const watcherCallback = ( evt, data ) => {
135
- if ( !input.isInput( data.batch ) ) {
142
+ if ( !data.batch.isTyping ) {
136
143
  return;
137
144
  }
138
145
 
@@ -164,6 +171,10 @@ export default class TextTransformation extends Plugin {
164
171
 
165
172
  changeIndex += replaceWith.length;
166
173
  }
174
+
175
+ model.enqueueChange( () => {
176
+ deletePlugin.requestUndoOnBackspace();
177
+ } );
167
178
  } );
168
179
  };
169
180
 
@@ -237,8 +248,9 @@ function normalizeTransformations( config ) {
237
248
  const configured = config.include.concat( extra ).filter( isNotRemoved );
238
249
 
239
250
  return expandGroupsAndRemoveDuplicates( configured )
240
- .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.
241
252
  .map( transformation => TRANSFORMATIONS[ transformation ] || transformation )
253
+ .filter( transformation => typeof transformation === 'object' ) // Filter out transformations set as string that has not been found.
242
254
  .map( transformation => ( {
243
255
  from: normalizeFrom( transformation.from ),
244
256
  to: normalizeTo( transformation.to )
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
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.type == 'transparent' ) {
120
+ if ( batch.isUndo || !batch.isLocal ) {
121
121
  return;
122
122
  }
123
123
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
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-2021, CKSource - Frederico Knabben. All rights reserved.
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-2021, CKSource - Frederico Knabben. All rights reserved.
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 user types, then inserts an image, and then types again,
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.type != 'transparent' && batch !== this._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-2021, CKSource - Frederico Knabben. All rights reserved.
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-2021, CKSource - Frederico Knabben. All rights reserved.
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-2021, CKSource - Frederico Knabben. All rights reserved.
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-2021, CKSource - Frederico Knabben. All rights reserved.
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-2021, CKSource - Frederico Knabben. All rights reserved.
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-2021, CKSource - Frederico Knabben. All rights reserved.
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
+ }
package/CHANGELOG.md DELETED
@@ -1,236 +0,0 @@
1
- Changelog
2
- =========
3
-
4
- All changes in the package are documented in the main repository. See: https://github.com/ckeditor/ckeditor5/blob/master/CHANGELOG.md.
5
-
6
- Changes for the past releases are available below.
7
-
8
- ## [19.0.0](https://github.com/ckeditor/ckeditor5-typing/compare/v18.0.0...v19.0.0) (2020-04-29)
9
-
10
- Internal changes only (updated dependencies, documentation, etc.).
11
-
12
-
13
- ## [18.0.0](https://github.com/ckeditor/ckeditor5-typing/compare/v17.0.0...v18.0.0) (2020-03-19)
14
-
15
- ### Other changes
16
-
17
- * `DeleteCommand` should pass its direction to `Model#deleteContent()`. Closes [ckeditor/ckeditor5#6355](https://github.com/ckeditor/ckeditor5/issues/6355). See [ckeditor/ckeditor5#6356](https://github.com/ckeditor/ckeditor5/issues/6356). ([cb75e45](https://github.com/ckeditor/ckeditor5-typing/commit/cb75e45))
18
- * Introduced support for multi-range selections. See [ckeditor/ckeditor5#6116](https://github.com/ckeditor/ckeditor5/issues/6116). ([64daf31](https://github.com/ckeditor/ckeditor5-typing/commit/64daf31))
19
- * Run only one instance of the `TextWatcher` for all text transformations. Closes [ckeditor/ckeditor5#6020](https://github.com/ckeditor/ckeditor5/issues/6020). ([550426d](https://github.com/ckeditor/ckeditor5-typing/commit/550426d))
20
-
21
-
22
- ## [17.0.0](https://github.com/ckeditor/ckeditor5-typing/compare/v16.0.0...v17.0.0) (2020-02-19)
23
-
24
- ### Features
25
-
26
- * Add `TextWatcher#isEnabled` property to allow toggling text watcher on and off. ([fa79d00](https://github.com/ckeditor/ckeditor5-typing/commit/fa79d00))
27
-
28
-
29
- ## [16.0.0](https://github.com/ckeditor/ckeditor5-typing/compare/v15.0.0...v16.0.0) (2019-12-04)
30
-
31
- Internal changes only (updated dependencies, documentation, etc.).
32
-
33
-
34
- ## [15.0.0](https://github.com/ckeditor/ckeditor5-typing/compare/v12.2.0...v15.0.0) (2019-10-23)
35
-
36
- ### Bug fixes
37
-
38
- * Autoformat transformations in blocks containing inline elements. See [ckeditor/ckeditor5#1955](https://github.com/ckeditor/ckeditor5/issues/1955). ([58abd23](https://github.com/ckeditor/ckeditor5-typing/commit/58abd23))
39
-
40
-
41
- ## [12.2.0](https://github.com/ckeditor/ckeditor5-typing/compare/v12.1.1...v12.2.0) (2019-08-26)
42
-
43
- ### Features
44
-
45
- * 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))
46
-
47
- ### Bug fixes
48
-
49
- * 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))
50
- * Typing on mobile device will not throw after each typed character. ([056b036](https://github.com/ckeditor/ckeditor5-typing/commit/056b036))
51
-
52
- ### Other changes
53
-
54
- * 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))
55
-
56
-
57
- ## [12.1.1](https://github.com/ckeditor/ckeditor5-typing/compare/v12.1.0...v12.1.1) (2019-07-10)
58
-
59
- ### Bug fixes
60
-
61
- * Text transformations will not remove existing formatting. Closes [#203](https://github.com/ckeditor/ckeditor5-typing/issues/203). Closes [#196](https://github.com/ckeditor/ckeditor5-typing/issues/196). ([2279eee](https://github.com/ckeditor/ckeditor5-typing/commit/2279eee))
62
-
63
-
64
- ## [12.1.0](https://github.com/ckeditor/ckeditor5-typing/compare/v12.0.2...v12.1.0) (2019-07-04)
65
-
66
- ### Features
67
-
68
- * Introduced the text transformation feature. Additionally, the `TextWatcher` util was moved to this package from `@ckeditor/ckeditor5-mention`. Closes [ckeditor/ckeditor5#1490](https://github.com/ckeditor/ckeditor5/issues/1490). ([dafd16e](https://github.com/ckeditor/ckeditor5-typing/commit/dafd16e))
69
-
70
- ### Bug fixes
71
-
72
- * Improved typing on Android devices by handling `beforeinput` event instead of mutations. Introduced `options.selection` in the `DeleteCommand#execute()` params. Introduced `selectionToRemove` parameter in the `view.Document#event:delete` data. Closes [#167](https://github.com/ckeditor/ckeditor5-typing/issues/167). ([92ab3ff](https://github.com/ckeditor/ckeditor5-typing/commit/92ab3ff))
73
-
74
-
75
- ## [12.0.2](https://github.com/ckeditor/ckeditor5-typing/compare/v12.0.1...v12.0.2) (2019-06-05)
76
-
77
- ### Other changes
78
-
79
- * Use `Model#insertContent()` instead of `model.Writer#insertText()`. Closes [#191](https://github.com/ckeditor/ckeditor5-typing/issues/191). ([0aeb384](https://github.com/ckeditor/ckeditor5-typing/commit/0aeb384))
80
-
81
-
82
- ## [12.0.1](https://github.com/ckeditor/ckeditor5-typing/compare/v12.0.0...v12.0.1) (2019-04-10)
83
-
84
- ### Bug fixes
85
-
86
- * The `delete` event will now stop the `keydown` event if it was set with the highest priority. Closes [#186](https://github.com/ckeditor/ckeditor5-typing/issues/186). ([07cca83](https://github.com/ckeditor/ckeditor5-typing/commit/07cca83))
87
-
88
-
89
- ## [12.0.0](https://github.com/ckeditor/ckeditor5-typing/compare/v11.0.2...v12.0.0) (2019-02-28)
90
-
91
- ### Bug fixes
92
-
93
- * Fixed mutation handling which crashed when the old text was the same as the new text. Closes [#181](https://github.com/ckeditor/ckeditor5-typing/issues/181). ([7175b6c](https://github.com/ckeditor/ckeditor5-typing/commit/7175b6c))
94
-
95
- ### Other changes
96
-
97
- * Exposed `DeleteCommand#buffer`. `InputCommand` uses `Model#deleteContent()` instead of `model.Writer#remove()`. ([5ab39fc](https://github.com/ckeditor/ckeditor5-typing/commit/5ab39fc))
98
-
99
- ### BREAKING CHANGES
100
-
101
- * Upgraded minimal versions of Node to `8.0.0` and npm to `5.7.1`. See: [ckeditor/ckeditor5#1507](https://github.com/ckeditor/ckeditor5/issues/1507). ([612ea3c](https://github.com/ckeditor/ckeditor5-cloud-services/commit/612ea3c))
102
-
103
-
104
- ## [11.0.2](https://github.com/ckeditor/ckeditor5-typing/compare/v11.0.1...v11.0.2) (2018-12-05)
105
-
106
- ### Bug fixes
107
-
108
- * Non-printable keys like volume up or the win key will not remove the content anymore. Closes [#136](https://github.com/ckeditor/ckeditor5-typing/issues/136). ([0ea9fbd](https://github.com/ckeditor/ckeditor5-typing/commit/0ea9fbd))
109
-
110
-
111
- ## [11.0.1](https://github.com/ckeditor/ckeditor5-typing/compare/v11.0.0...v11.0.1) (2018-10-08)
112
-
113
- ### Bug fixes
114
-
115
- * `&nbsp;` is now correctly handled in mutations. Closes [#170](https://github.com/ckeditor/ckeditor5-typing/issues/170). ([9badb20](https://github.com/ckeditor/ckeditor5-typing/commit/9badb20))
116
-
117
-
118
- ## [11.0.0](https://github.com/ckeditor/ckeditor5-typing/compare/v10.0.1...v11.0.0) (2018-07-18)
119
-
120
- ### Bug fixes
121
-
122
- * Handle <kbd>Backspace</kbd> on Android. Closes ckeditor/ckeditor5/issues/1106. Closes https://github.com/ckeditor/ckeditor5/issues/1130. ([9161275](https://github.com/ckeditor/ckeditor5-typing/commit/9161275))
123
- * Remove selection contents on `keydown` before the composition starts. Closes [#83](https://github.com/ckeditor/ckeditor5-typing/issues/83). Closes [#150](https://github.com/ckeditor/ckeditor5-typing/issues/150). ([ab1b46d](https://github.com/ckeditor/ckeditor5-typing/commit/ab1b46d))
124
-
125
- ### BREAKING CHANGES
126
-
127
- * `@ckeditor/ckeditor5-typing/src/changebuffer.js` was moved to `@ckeditor/ckeditor5-typing/src/utils/changebuffer.js`.
128
-
129
-
130
- ## [10.0.1](https://github.com/ckeditor/ckeditor5-typing/compare/v10.0.0...v10.0.1) (2018-06-21)
131
-
132
- ### Bug fixes
133
-
134
- * Bogus `<br />` element inserted by a browser at the end of an element is now correctly handled. Closes [ckeditor/ckeditor5#1083](https://github.com/ckeditor/ckeditor5/issues/1083). ([22abdff](https://github.com/ckeditor/ckeditor5-typing/commit/22abdff))
135
-
136
-
137
- ## [10.0.0](https://github.com/ckeditor/ckeditor5-typing/compare/v1.0.0-beta.4...v10.0.0) (2018-04-25)
138
-
139
- ### Other changes
140
-
141
- * Changed the license to GPL2+ only. See [ckeditor/ckeditor5#991](https://github.com/ckeditor/ckeditor5/issues/991). ([d24abd5](https://github.com/ckeditor/ckeditor5-typing/commit/d24abd5))
142
-
143
- ### BREAKING CHANGES
144
-
145
- * The license under which CKEditor 5 is released has been changed from a triple GPL, LGPL and MPL license to a GPL2+ only. See [ckeditor/ckeditor5#991](https://github.com/ckeditor/ckeditor5/issues/991) for more information.
146
-
147
-
148
- ## [1.0.0-beta.4](https://github.com/ckeditor/ckeditor5-typing/compare/v1.0.0-beta.2...v1.0.0-beta.4) (2018-04-19)
149
-
150
- Internal changes only (updated dependencies, documentation, etc.).
151
-
152
-
153
- ## [1.0.0-beta.2](https://github.com/ckeditor/ckeditor5-typing/compare/v1.0.0-beta.1...v1.0.0-beta.2) (2018-04-10)
154
-
155
- Internal changes only (updated dependencies, documentation, etc.).
156
-
157
-
158
- ## [1.0.0-beta.1](https://github.com/ckeditor/ckeditor5-typing/compare/v1.0.0-alpha.2...v1.0.0-beta.1) (2018-03-15)
159
-
160
- ### Bug fixes
161
-
162
- * `DeleteObserver` will stop the `keydown` event when the `delete` event is stopped. Closes: https://github.com/ckeditor/ckeditor5/issues/753. ([479d043](https://github.com/ckeditor/ckeditor5-typing/commit/479d043))
163
- * Editor should not crash in scenarios when mutations' common ancestor could not be mapped to the model. Closes [ckeditor/ckeditor5#718](https://github.com/ckeditor/ckeditor5/issues/718). ([db0fe8f](https://github.com/ckeditor/ckeditor5-typing/commit/db0fe8f))
164
- * Properly discover delete-word keyboard modifier on mac and non-mac computers. Closes [#92](https://github.com/ckeditor/ckeditor5-typing/issues/92). ([81f5b76](https://github.com/ckeditor/ckeditor5-typing/commit/81f5b76))
165
-
166
- ### Other changes
167
-
168
- * Aligned feature class naming to the new scheme. ([9c2cb9d](https://github.com/ckeditor/ckeditor5-typing/commit/9c2cb9d))
169
-
170
-
171
- ## [1.0.0-alpha.2](https://github.com/ckeditor/ckeditor5-typing/compare/v1.0.0-alpha.1...v1.0.0-alpha.2) (2017-11-14)
172
-
173
- Internal changes only (updated dependencies, documentation, etc.).
174
-
175
- ## [1.0.0-alpha.1](https://github.com/ckeditor/ckeditor5-typing/compare/v0.10.0...v1.0.0-alpha.1) (2017-10-03)
176
-
177
- ### Bug fixes
178
-
179
- * Fixed a bug where using spellchecker sometimes caused creating incorrect deltas, which caused bugs in undo. Closes [#123](https://github.com/ckeditor/ckeditor5-typing/issues/123). Closes [ckeditor/ckeditor5-engine#1152](https://github.com/ckeditor/ckeditor5-engine/issues/1152). ([9a5e22b](https://github.com/ckeditor/ckeditor5-typing/commit/9a5e22b))
180
- * Fixed an error where using spellchecker on a word with a style applied sometimes resulted in that word being removed. Closes [#117](https://github.com/ckeditor/ckeditor5-typing/issues/117). ([1e8d02b](https://github.com/ckeditor/ckeditor5-typing/commit/1e8d02b))
181
-
182
-
183
- ## [0.10.0](https://github.com/ckeditor/ckeditor5-typing/compare/v0.9.1...v0.10.0) (2017-09-03)
184
-
185
- ### Bug fixes
186
-
187
- * Fixed a range of issues when typing or using a spellchecker on styled words leads to errors. Closes [#100](https://github.com/ckeditor/ckeditor5-typing/issues/100). Closes ckeditor/ckeditor5[#491](https://github.com/ckeditor/ckeditor5-typing/issues/491). ([c30dbf8](https://github.com/ckeditor/ckeditor5-typing/commit/c30dbf8))
188
- * Prevent from modifying document by `Input` feature when `InputCommand` is disabled. Closes [#107](https://github.com/ckeditor/ckeditor5-typing/issues/107). ([f935d66](https://github.com/ckeditor/ckeditor5-typing/commit/f935d66))
189
-
190
- ### Features
191
-
192
- * Pressing <kbd>Backspace</kbd> or <kbd>Delete</kbd> in an empty content will reset the current block to a paragraph. Closes [#61](https://github.com/ckeditor/ckeditor5-typing/issues/61). ([bb07bc6](https://github.com/ckeditor/ckeditor5-typing/commit/bb07bc6))
193
- * The viewport will be scrolled to the selection upon user input. See ckeditor/ckeditor5-engine#660. ([2cdf02f](https://github.com/ckeditor/ckeditor5-typing/commit/2cdf02f))
194
-
195
- ### Other changes
196
-
197
- * Aligned the implementation to the new Command API (see https://github.com/ckeditor/ckeditor5-core/issues/88). ([b241ac6](https://github.com/ckeditor/ckeditor5-typing/commit/b241ac6))
198
-
199
- ### BREAKING CHANGES
200
-
201
- * The command API has been changed.
202
-
203
-
204
- ## [0.9.1](https://github.com/ckeditor/ckeditor5-typing/compare/v0.9.0...v0.9.1) (2017-05-07)
205
-
206
- Internal changes only (updated dependencies, documentation, etc.).
207
-
208
- ## [0.9.0](https://github.com/ckeditor/ckeditor5-typing/compare/v0.8.0...v0.9.0) (2017-04-05)
209
-
210
- ### Bug fixes
211
-
212
- * [Safari] Fixed an issue when inserting a Spanish accent character on a non-collapsed selection wouldn't work. Closes [#82](https://github.com/ckeditor/ckeditor5-typing/issues/82). ([49cfe9c](https://github.com/ckeditor/ckeditor5-typing/commit/49cfe9c))
213
- * `InputCommand` now accepts `Range` instead of `Position` as a parameter. Closes [#86](https://github.com/ckeditor/ckeditor5-typing/issues/86). Closes [#54](https://github.com/ckeditor/ckeditor5-typing/issues/54). ([0766407](https://github.com/ckeditor/ckeditor5-typing/commit/0766407))
214
- * New undo step should be created on selection change or applying an attribute. Closes [#20](https://github.com/ckeditor/ckeditor5-typing/issues/20). Closes [#21](https://github.com/ckeditor/ckeditor5-typing/issues/21). ([011452b](https://github.com/ckeditor/ckeditor5-typing/commit/011452b))
215
- * Use `typing.undoStep` in both `InputCommand` and `DeleteCommand`. Closes [#79](https://github.com/ckeditor/ckeditor5-typing/issues/79). ([c597467](https://github.com/ckeditor/ckeditor5-typing/commit/c597467))
216
-
217
- ### Features
218
-
219
- * Named existing plugin(s). ([2a2fcae](https://github.com/ckeditor/ckeditor5-typing/commit/2a2fcae))
220
-
221
- ### BREAKING CHANGES
222
-
223
- * `InputCommand` `options.resultPosition` was replaced with `options.resultRange`.
224
- * The `undo.step` configuration option was replaced by `typing.undoStep` in `DeleteCommand`. See [#79](https://github.com/ckeditor/ckeditor5-typing/issues/79).
225
-
226
-
227
- ## [0.8.0](https://github.com/ckeditor/ckeditor5-typing/compare/v0.7.0...v0.8.0) (2017-03-06)
228
-
229
- ### Bug fixes
230
-
231
- * Replace all `&nbsp;` with spaces in text inserted via mutations. Closes [#68](https://github.com/ckeditor/ckeditor5/issues/68). ([c0fce25](https://github.com/ckeditor/ckeditor5-typing/commit/c0fce25))
232
- * Tab key should not delete selected text. Closes: [#69](https://github.com/ckeditor/ckeditor5/issues/69). ([8447f51](https://github.com/ckeditor/ckeditor5-typing/commit/8447f51))
233
-
234
- ### Features
235
-
236
- * Introduced `InputCommand` which can be used to simulate typing. Closes [#48](https://github.com/ckeditor/ckeditor5/issues/48). ([cdb7fdf](https://github.com/ckeditor/ckeditor5-typing/commit/cdb7fdf))