@atlaskit/editor-plugin-selection 0.2.1 → 0.2.2
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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-selection
|
|
2
2
|
|
|
3
|
+
## 0.2.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#68572](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/68572) [`15d407fe5143`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/15d407fe5143) - Upgrading @atlaskit/editor-prosemirror dependency
|
|
8
|
+
|
|
3
9
|
## 0.2.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -75,6 +75,37 @@ var findFixedProblematicNodePosition = function findFixedProblematicNodePosition
|
|
|
75
75
|
}
|
|
76
76
|
return null;
|
|
77
77
|
};
|
|
78
|
+
var isSelectionLineShortcutWhenCursorIsInsideInlineNode = function isSelectionLineShortcutWhenCursorIsInsideInlineNode(view, event) {
|
|
79
|
+
var _selection$$cursor$no, _selection$$cursor$no2;
|
|
80
|
+
if (!event.shiftKey || !event.metaKey) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
var selection = view.state.selection;
|
|
84
|
+
if (!(selection instanceof _state.TextSelection)) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
if (!selection.$cursor) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
var isSelectingInlineNodeForward = event.key === 'ArrowRight' && Boolean((_selection$$cursor$no = selection.$cursor.nodeAfter) === null || _selection$$cursor$no === void 0 ? void 0 : _selection$$cursor$no.isInline);
|
|
91
|
+
var isSelectingInlineNodeBackward = event.key === 'ArrowLeft' && Boolean((_selection$$cursor$no2 = selection.$cursor.nodeBefore) === null || _selection$$cursor$no2 === void 0 ? void 0 : _selection$$cursor$no2.isInline);
|
|
92
|
+
return isSelectingInlineNodeForward || isSelectingInlineNodeBackward;
|
|
93
|
+
};
|
|
94
|
+
var isNavigatingVerticallyWhenCursorIsInsideInlineNode = function isNavigatingVerticallyWhenCursorIsInsideInlineNode(view, event) {
|
|
95
|
+
var _view$state, _selection$$cursor$no3, _selection$$cursor$no4;
|
|
96
|
+
if (event.shiftKey || event.metaKey) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
var selection = (_view$state = view.state) === null || _view$state === void 0 ? void 0 : _view$state.selection;
|
|
100
|
+
if (!(selection instanceof _state.TextSelection)) {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
if (!selection.$cursor) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
var isNavigatingInlineNodeDownward = event.key === 'ArrowDown' && Boolean((_selection$$cursor$no3 = selection.$cursor.nodeBefore) === null || _selection$$cursor$no3 === void 0 ? void 0 : _selection$$cursor$no3.isInline) && Boolean((_selection$$cursor$no4 = selection.$cursor.nodeAfter) === null || _selection$$cursor$no4 === void 0 ? void 0 : _selection$$cursor$no4.isInline);
|
|
107
|
+
return isNavigatingInlineNodeDownward;
|
|
108
|
+
};
|
|
78
109
|
var onKeydown = exports.onKeydown = function onKeydown(view, event) {
|
|
79
110
|
/*
|
|
80
111
|
* This workaround is needed for some specific situations.
|
|
@@ -84,17 +115,23 @@ var onKeydown = exports.onKeydown = function onKeydown(view, event) {
|
|
|
84
115
|
if (!(event instanceof KeyboardEvent)) {
|
|
85
116
|
return false;
|
|
86
117
|
}
|
|
118
|
+
if (isSelectionLineShortcutWhenCursorIsInsideInlineNode(view, event)) {
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
if (isNavigatingVerticallyWhenCursorIsInsideInlineNode(view, event)) {
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
87
124
|
if (!event.shiftKey || event.ctrlKey || event.metaKey) {
|
|
88
125
|
return false;
|
|
89
126
|
}
|
|
90
127
|
if (!['ArrowUp', 'ArrowDown', 'ArrowRight', 'ArrowLeft', 'Home', 'End'].includes(event.key)) {
|
|
91
128
|
return false;
|
|
92
129
|
}
|
|
93
|
-
var _view$
|
|
94
|
-
doc = _view$
|
|
95
|
-
_view$
|
|
96
|
-
$head = _view$
|
|
97
|
-
$anchor = _view$
|
|
130
|
+
var _view$state2 = view.state,
|
|
131
|
+
doc = _view$state2.doc,
|
|
132
|
+
_view$state2$selectio = _view$state2.selection,
|
|
133
|
+
$head = _view$state2$selectio.$head,
|
|
134
|
+
$anchor = _view$state2$selectio.$anchor;
|
|
98
135
|
if (event.key === 'ArrowRight' && $head.nodeAfter || event.key === 'ArrowLeft' && $head.nodeBefore) {
|
|
99
136
|
return false;
|
|
100
137
|
}
|
|
@@ -69,6 +69,37 @@ const findFixedProblematicNodePosition = (doc, $head, direction) => {
|
|
|
69
69
|
}
|
|
70
70
|
return null;
|
|
71
71
|
};
|
|
72
|
+
const isSelectionLineShortcutWhenCursorIsInsideInlineNode = (view, event) => {
|
|
73
|
+
var _selection$$cursor$no, _selection$$cursor$no2;
|
|
74
|
+
if (!event.shiftKey || !event.metaKey) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
const selection = view.state.selection;
|
|
78
|
+
if (!(selection instanceof TextSelection)) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
if (!selection.$cursor) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
const isSelectingInlineNodeForward = event.key === 'ArrowRight' && Boolean((_selection$$cursor$no = selection.$cursor.nodeAfter) === null || _selection$$cursor$no === void 0 ? void 0 : _selection$$cursor$no.isInline);
|
|
85
|
+
const isSelectingInlineNodeBackward = event.key === 'ArrowLeft' && Boolean((_selection$$cursor$no2 = selection.$cursor.nodeBefore) === null || _selection$$cursor$no2 === void 0 ? void 0 : _selection$$cursor$no2.isInline);
|
|
86
|
+
return isSelectingInlineNodeForward || isSelectingInlineNodeBackward;
|
|
87
|
+
};
|
|
88
|
+
const isNavigatingVerticallyWhenCursorIsInsideInlineNode = (view, event) => {
|
|
89
|
+
var _view$state, _selection$$cursor$no3, _selection$$cursor$no4;
|
|
90
|
+
if (event.shiftKey || event.metaKey) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
const selection = (_view$state = view.state) === null || _view$state === void 0 ? void 0 : _view$state.selection;
|
|
94
|
+
if (!(selection instanceof TextSelection)) {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
if (!selection.$cursor) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
const isNavigatingInlineNodeDownward = event.key === 'ArrowDown' && Boolean((_selection$$cursor$no3 = selection.$cursor.nodeBefore) === null || _selection$$cursor$no3 === void 0 ? void 0 : _selection$$cursor$no3.isInline) && Boolean((_selection$$cursor$no4 = selection.$cursor.nodeAfter) === null || _selection$$cursor$no4 === void 0 ? void 0 : _selection$$cursor$no4.isInline);
|
|
101
|
+
return isNavigatingInlineNodeDownward;
|
|
102
|
+
};
|
|
72
103
|
export const onKeydown = (view, event) => {
|
|
73
104
|
/*
|
|
74
105
|
* This workaround is needed for some specific situations.
|
|
@@ -78,6 +109,12 @@ export const onKeydown = (view, event) => {
|
|
|
78
109
|
if (!(event instanceof KeyboardEvent)) {
|
|
79
110
|
return false;
|
|
80
111
|
}
|
|
112
|
+
if (isSelectionLineShortcutWhenCursorIsInsideInlineNode(view, event)) {
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
if (isNavigatingVerticallyWhenCursorIsInsideInlineNode(view, event)) {
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
81
118
|
if (!event.shiftKey || event.ctrlKey || event.metaKey) {
|
|
82
119
|
return false;
|
|
83
120
|
}
|
|
@@ -69,6 +69,37 @@ var findFixedProblematicNodePosition = function findFixedProblematicNodePosition
|
|
|
69
69
|
}
|
|
70
70
|
return null;
|
|
71
71
|
};
|
|
72
|
+
var isSelectionLineShortcutWhenCursorIsInsideInlineNode = function isSelectionLineShortcutWhenCursorIsInsideInlineNode(view, event) {
|
|
73
|
+
var _selection$$cursor$no, _selection$$cursor$no2;
|
|
74
|
+
if (!event.shiftKey || !event.metaKey) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
var selection = view.state.selection;
|
|
78
|
+
if (!(selection instanceof TextSelection)) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
if (!selection.$cursor) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
var isSelectingInlineNodeForward = event.key === 'ArrowRight' && Boolean((_selection$$cursor$no = selection.$cursor.nodeAfter) === null || _selection$$cursor$no === void 0 ? void 0 : _selection$$cursor$no.isInline);
|
|
85
|
+
var isSelectingInlineNodeBackward = event.key === 'ArrowLeft' && Boolean((_selection$$cursor$no2 = selection.$cursor.nodeBefore) === null || _selection$$cursor$no2 === void 0 ? void 0 : _selection$$cursor$no2.isInline);
|
|
86
|
+
return isSelectingInlineNodeForward || isSelectingInlineNodeBackward;
|
|
87
|
+
};
|
|
88
|
+
var isNavigatingVerticallyWhenCursorIsInsideInlineNode = function isNavigatingVerticallyWhenCursorIsInsideInlineNode(view, event) {
|
|
89
|
+
var _view$state, _selection$$cursor$no3, _selection$$cursor$no4;
|
|
90
|
+
if (event.shiftKey || event.metaKey) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
var selection = (_view$state = view.state) === null || _view$state === void 0 ? void 0 : _view$state.selection;
|
|
94
|
+
if (!(selection instanceof TextSelection)) {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
if (!selection.$cursor) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
var isNavigatingInlineNodeDownward = event.key === 'ArrowDown' && Boolean((_selection$$cursor$no3 = selection.$cursor.nodeBefore) === null || _selection$$cursor$no3 === void 0 ? void 0 : _selection$$cursor$no3.isInline) && Boolean((_selection$$cursor$no4 = selection.$cursor.nodeAfter) === null || _selection$$cursor$no4 === void 0 ? void 0 : _selection$$cursor$no4.isInline);
|
|
101
|
+
return isNavigatingInlineNodeDownward;
|
|
102
|
+
};
|
|
72
103
|
export var onKeydown = function onKeydown(view, event) {
|
|
73
104
|
/*
|
|
74
105
|
* This workaround is needed for some specific situations.
|
|
@@ -78,17 +109,23 @@ export var onKeydown = function onKeydown(view, event) {
|
|
|
78
109
|
if (!(event instanceof KeyboardEvent)) {
|
|
79
110
|
return false;
|
|
80
111
|
}
|
|
112
|
+
if (isSelectionLineShortcutWhenCursorIsInsideInlineNode(view, event)) {
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
if (isNavigatingVerticallyWhenCursorIsInsideInlineNode(view, event)) {
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
81
118
|
if (!event.shiftKey || event.ctrlKey || event.metaKey) {
|
|
82
119
|
return false;
|
|
83
120
|
}
|
|
84
121
|
if (!['ArrowUp', 'ArrowDown', 'ArrowRight', 'ArrowLeft', 'Home', 'End'].includes(event.key)) {
|
|
85
122
|
return false;
|
|
86
123
|
}
|
|
87
|
-
var _view$
|
|
88
|
-
doc = _view$
|
|
89
|
-
_view$
|
|
90
|
-
$head = _view$
|
|
91
|
-
$anchor = _view$
|
|
124
|
+
var _view$state2 = view.state,
|
|
125
|
+
doc = _view$state2.doc,
|
|
126
|
+
_view$state2$selectio = _view$state2.selection,
|
|
127
|
+
$head = _view$state2$selectio.$head,
|
|
128
|
+
$anchor = _view$state2$selectio.$anchor;
|
|
92
129
|
if (event.key === 'ArrowRight' && $head.nodeAfter || event.key === 'ArrowLeft' && $head.nodeBefore) {
|
|
93
130
|
return false;
|
|
94
131
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-selection",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Selection plugin for @atlaskit/editor-core",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -21,34 +21,18 @@
|
|
|
21
21
|
"runReact18": false
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@atlaskit/editor-common": "^77.
|
|
25
|
-
"@atlaskit/editor-prosemirror": "
|
|
24
|
+
"@atlaskit/editor-common": "^77.3.0",
|
|
25
|
+
"@atlaskit/editor-prosemirror": "3.0.0",
|
|
26
26
|
"@atlaskit/editor-shared-styles": "^2.9.0",
|
|
27
|
-
"@atlaskit/editor-tables": "^2.
|
|
27
|
+
"@atlaskit/editor-tables": "^2.5.0",
|
|
28
28
|
"@babel/runtime": "^7.0.0"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"react": "^16.8.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@af/editor-libra": "*",
|
|
35
|
-
"@af/visual-regression": "*",
|
|
36
|
-
"@atlaskit/editor-plugin-analytics": "^0.4.0",
|
|
37
|
-
"@atlaskit/editor-plugin-feature-flags": "^1.0.0",
|
|
38
|
-
"@atlaskit/editor-plugin-focus": "^0.2.1",
|
|
39
|
-
"@atlaskit/editor-plugin-grid": "^0.3.0",
|
|
40
|
-
"@atlaskit/editor-plugin-guideline": "^0.5.1",
|
|
41
|
-
"@atlaskit/editor-plugin-rule": "^0.1.2",
|
|
42
|
-
"@atlaskit/editor-plugin-width": "^0.2.2",
|
|
43
|
-
"@atlaskit/media-integration-test-helpers": "^3.0.0",
|
|
44
|
-
"@atlaskit/media-test-helpers": "^33.0.0",
|
|
45
|
-
"@atlaskit/ssr": "*",
|
|
46
|
-
"@atlaskit/visual-regression": "*",
|
|
47
34
|
"@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
|
|
48
|
-
"
|
|
49
|
-
"react-dom": "^16.8.0",
|
|
50
|
-
"typescript": "~4.9.5",
|
|
51
|
-
"wait-for-expect": "^1.2.0"
|
|
35
|
+
"typescript": "~4.9.5"
|
|
52
36
|
},
|
|
53
37
|
"techstack": {
|
|
54
38
|
"@atlassian/frontend": {
|
|
@@ -89,5 +73,10 @@
|
|
|
89
73
|
".": "./src/index.ts",
|
|
90
74
|
"./types": "./src/types.ts"
|
|
91
75
|
},
|
|
92
|
-
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0"
|
|
76
|
+
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0",
|
|
77
|
+
"stricter": {
|
|
78
|
+
"no-unused-dependencies": {
|
|
79
|
+
"checkDevDependencies": true
|
|
80
|
+
}
|
|
81
|
+
}
|
|
93
82
|
}
|