@ckeditor/ckeditor5-typing 31.0.0 → 31.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-typing",
3
- "version": "31.0.0",
3
+ "version": "31.1.0",
4
4
  "description": "Typing feature for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -12,24 +12,24 @@
12
12
  ],
13
13
  "main": "src/index.js",
14
14
  "dependencies": {
15
- "@ckeditor/ckeditor5-core": "^31.0.0",
16
- "@ckeditor/ckeditor5-engine": "^31.0.0",
17
- "@ckeditor/ckeditor5-utils": "^31.0.0",
15
+ "@ckeditor/ckeditor5-core": "^31.1.0",
16
+ "@ckeditor/ckeditor5-engine": "^31.1.0",
17
+ "@ckeditor/ckeditor5-utils": "^31.1.0",
18
18
  "lodash-es": "^4.17.15"
19
19
  },
20
20
  "devDependencies": {
21
- "@ckeditor/ckeditor5-basic-styles": "^31.0.0",
22
- "@ckeditor/ckeditor5-block-quote": "^31.0.0",
23
- "@ckeditor/ckeditor5-editor-classic": "^31.0.0",
24
- "@ckeditor/ckeditor5-enter": "^31.0.0",
25
- "@ckeditor/ckeditor5-essentials": "^31.0.0",
26
- "@ckeditor/ckeditor5-heading": "^31.0.0",
27
- "@ckeditor/ckeditor5-image": "^31.0.0",
28
- "@ckeditor/ckeditor5-link": "^31.0.0",
29
- "@ckeditor/ckeditor5-list": "^31.0.0",
30
- "@ckeditor/ckeditor5-paragraph": "^31.0.0",
31
- "@ckeditor/ckeditor5-undo": "^31.0.0",
32
- "@ckeditor/ckeditor5-code-block": "^31.0.0"
21
+ "@ckeditor/ckeditor5-basic-styles": "^31.1.0",
22
+ "@ckeditor/ckeditor5-block-quote": "^31.1.0",
23
+ "@ckeditor/ckeditor5-editor-classic": "^31.1.0",
24
+ "@ckeditor/ckeditor5-enter": "^31.1.0",
25
+ "@ckeditor/ckeditor5-essentials": "^31.1.0",
26
+ "@ckeditor/ckeditor5-heading": "^31.1.0",
27
+ "@ckeditor/ckeditor5-image": "^31.1.0",
28
+ "@ckeditor/ckeditor5-link": "^31.1.0",
29
+ "@ckeditor/ckeditor5-list": "^31.1.0",
30
+ "@ckeditor/ckeditor5-paragraph": "^31.1.0",
31
+ "@ckeditor/ckeditor5-undo": "^31.1.0",
32
+ "@ckeditor/ckeditor5-code-block": "^31.1.0"
33
33
  },
34
34
  "engines": {
35
35
  "node": ">=12.0.0",
@@ -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 ) {
@@ -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 );
@@ -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
+ }