@atlaskit/editor-plugin-selection 2.1.4 → 2.1.6
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 +19 -0
- package/dist/cjs/pm-plugins/commands.js +22 -65
- package/dist/cjs/pm-plugins/keymap.js +0 -8
- package/dist/cjs/selectionPlugin.js +2 -12
- package/dist/es2019/pm-plugins/commands.js +0 -45
- package/dist/es2019/pm-plugins/keymap.js +2 -10
- package/dist/es2019/selectionPlugin.js +1 -9
- package/dist/esm/pm-plugins/commands.js +0 -43
- package/dist/esm/pm-plugins/keymap.js +2 -10
- package/dist/esm/selectionPlugin.js +2 -12
- package/dist/types/pm-plugins/commands.d.ts +0 -1
- package/dist/types-ts4.5/pm-plugins/commands.d.ts +0 -1
- package/package.json +4 -7
- package/dist/cjs/pm-plugins/selection-analytics.js +0 -74
- package/dist/es2019/pm-plugins/selection-analytics.js +0 -64
- package/dist/esm/pm-plugins/selection-analytics.js +0 -67
- package/dist/types/pm-plugins/selection-analytics.d.ts +0 -10
- package/dist/types-ts4.5/pm-plugins/selection-analytics.d.ts +0 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-selection
|
|
2
2
|
|
|
3
|
+
## 2.1.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#134378](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/134378)
|
|
8
|
+
[`210a48c778086`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/210a48c778086) -
|
|
9
|
+
EDITOR-546 Cleaned up platform_editor_cmd_a_progressively_select_nodes to revert to control
|
|
10
|
+
behaviour.
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
13
|
+
## 2.1.5
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#132699](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/132699)
|
|
18
|
+
[`eee4cd1d4f4d8`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/eee4cd1d4f4d8) -
|
|
19
|
+
remove feature gate
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
|
|
3
22
|
## 2.1.4
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
|
@@ -3,16 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.setSelectionRelativeToNode = exports.setSelectionInsideAtNodeEnd = exports.
|
|
6
|
+
exports.setSelectionRelativeToNode = exports.setSelectionInsideAtNodeEnd = exports.selectNearNode = exports.arrowRight = exports.arrowLeft = void 0;
|
|
7
7
|
var _selection = require("@atlaskit/editor-common/selection");
|
|
8
8
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
9
9
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
10
|
-
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
11
|
-
var _utils3 = require("@atlaskit/editor-tables/utils");
|
|
12
10
|
var _types = require("../types");
|
|
13
11
|
var _actions = require("./actions");
|
|
14
12
|
var _pluginFactory = require("./plugin-factory");
|
|
15
|
-
var
|
|
13
|
+
var _utils2 = require("./utils");
|
|
16
14
|
/* eslint-disable import/no-extraneous-dependencies */
|
|
17
15
|
|
|
18
16
|
var selectNearNode = exports.selectNearNode = function selectNearNode(selectionRelativeToNode, selection) {
|
|
@@ -66,12 +64,12 @@ var arrowRightFromGapCursor = function arrowRightFromGapCursor(selection) {
|
|
|
66
64
|
$to = selection.$to,
|
|
67
65
|
side = selection.side;
|
|
68
66
|
if (side === _selection.Side.LEFT) {
|
|
69
|
-
var selectableNode = (0,
|
|
67
|
+
var selectableNode = (0, _utils2.findSelectableContainerAfter)($to, state.doc);
|
|
70
68
|
if (selectableNode) {
|
|
71
69
|
return setSelectionRelativeToNode(_selection.RelativeSelectionPos.Start, _state.NodeSelection.create(state.doc, selectableNode.pos))(state, dispatch);
|
|
72
70
|
}
|
|
73
|
-
} else if (side === _selection.Side.RIGHT && (0,
|
|
74
|
-
var _selectableNode = (0,
|
|
71
|
+
} else if (side === _selection.Side.RIGHT && (0, _utils2.isSelectionAtEndOfParentNode)($from, selection)) {
|
|
72
|
+
var _selectableNode = (0, _utils2.findSelectableContainerParent)(selection);
|
|
75
73
|
if (_selectableNode) {
|
|
76
74
|
return setSelectionRelativeToNode(_selection.RelativeSelectionPos.End, _state.NodeSelection.create(state.doc, _selectableNode.pos))(state, dispatch);
|
|
77
75
|
}
|
|
@@ -86,15 +84,15 @@ var arrowLeftFromGapCursor = function arrowLeftFromGapCursor(selection) {
|
|
|
86
84
|
var _getPluginState = (0, _pluginFactory.getPluginState)(state),
|
|
87
85
|
selectionRelativeToNode = _getPluginState.selectionRelativeToNode;
|
|
88
86
|
if (side === _selection.Side.RIGHT) {
|
|
89
|
-
var selectableNode = (0,
|
|
87
|
+
var selectableNode = (0, _utils2.findSelectableContainerBefore)($from, state.doc);
|
|
90
88
|
if (selectableNode) {
|
|
91
89
|
return setSelectionRelativeToNode(_selection.RelativeSelectionPos.End, _state.NodeSelection.create(state.doc, selectableNode.pos))(state, dispatch);
|
|
92
90
|
}
|
|
93
|
-
} else if (side === _selection.Side.LEFT && (0,
|
|
91
|
+
} else if (side === _selection.Side.LEFT && (0, _utils2.isSelectionAtStartOfParentNode)($from, selection)) {
|
|
94
92
|
if (selectionRelativeToNode === _selection.RelativeSelectionPos.Before) {
|
|
95
93
|
var $parent = state.doc.resolve(selection.$from.before(selection.$from.depth));
|
|
96
94
|
if ($parent) {
|
|
97
|
-
var _selectableNode2 = (0,
|
|
95
|
+
var _selectableNode2 = (0, _utils2.findSelectableContainerBefore)($parent, state.doc);
|
|
98
96
|
if (_selectableNode2 && (0, _selection.isIgnored)(_selectableNode2.node)) {
|
|
99
97
|
// selection is inside node without gap cursor preceeded by another node without gap cursor - set node selection for previous node
|
|
100
98
|
return setSelectionRelativeToNode(_selection.RelativeSelectionPos.End, _state.NodeSelection.create(state.doc, _selectableNode2.pos))(state, dispatch);
|
|
@@ -104,7 +102,7 @@ var arrowLeftFromGapCursor = function arrowLeftFromGapCursor(selection) {
|
|
|
104
102
|
// from responding to arrow left key
|
|
105
103
|
setSelectionRelativeToNode()(state, dispatch);
|
|
106
104
|
} else {
|
|
107
|
-
var _selectableNode3 = (0,
|
|
105
|
+
var _selectableNode3 = (0, _utils2.findSelectableContainerParent)(selection);
|
|
108
106
|
if (_selectableNode3) {
|
|
109
107
|
return setSelectionRelativeToNode(_selection.RelativeSelectionPos.Start, _state.NodeSelection.create(state.doc, _selectableNode3.pos))(state, dispatch);
|
|
110
108
|
}
|
|
@@ -121,7 +119,7 @@ var arrowRightFromNode = function arrowRightFromNode(selection) {
|
|
|
121
119
|
var _getPluginState2 = (0, _pluginFactory.getPluginState)(state),
|
|
122
120
|
selectionRelativeToNode = _getPluginState2.selectionRelativeToNode;
|
|
123
121
|
if (node.isAtom) {
|
|
124
|
-
if ((0,
|
|
122
|
+
if ((0, _utils2.isSelectionAtEndOfParentNode)($to, selection) && (node.isInline || (0, _selection.isIgnored)(node))) {
|
|
125
123
|
// selection is for inline node or atom node which is ignored by gap-cursor and that is the last child of its parent node - set text selection after it
|
|
126
124
|
return findAndSetTextSelection(_selection.RelativeSelectionPos.End, state.doc.resolve(from + 1), _types.SelectionDirection.After)(state, dispatch);
|
|
127
125
|
}
|
|
@@ -130,7 +128,7 @@ var arrowRightFromNode = function arrowRightFromNode(selection) {
|
|
|
130
128
|
// selection is for container node - set selection inside it at the start
|
|
131
129
|
return setSelectionInsideAtNodeStart(_selection.RelativeSelectionPos.Inside, node, from)(state, dispatch);
|
|
132
130
|
} else if ((0, _selection.isIgnored)(node) && (!selectionRelativeToNode || selectionRelativeToNode === _selection.RelativeSelectionPos.End)) {
|
|
133
|
-
var selectableNode = (0,
|
|
131
|
+
var selectableNode = (0, _utils2.findSelectableContainerAfter)($to, state.doc);
|
|
134
132
|
if (selectableNode && (0, _selection.isIgnored)(selectableNode.node)) {
|
|
135
133
|
// selection is for node without gap cursor followed by another node without gap cursor - set node selection for next node
|
|
136
134
|
return setSelectionRelativeToNode(_selection.RelativeSelectionPos.Start, _state.NodeSelection.create(state.doc, selectableNode.pos))(state, dispatch);
|
|
@@ -148,7 +146,7 @@ var arrowLeftFromNode = function arrowLeftFromNode(selection) {
|
|
|
148
146
|
var _getPluginState3 = (0, _pluginFactory.getPluginState)(state),
|
|
149
147
|
selectionRelativeToNode = _getPluginState3.selectionRelativeToNode;
|
|
150
148
|
if (node.isAtom) {
|
|
151
|
-
if ((0,
|
|
149
|
+
if ((0, _utils2.isSelectionAtStartOfParentNode)($from, selection) && (node.isInline || (0, _selection.isIgnored)(node))) {
|
|
152
150
|
// selection is for inline node or atom node which is ignored by gap-cursor and that is the first child of its parent node - set text selection before it
|
|
153
151
|
return findAndSetTextSelection(_selection.RelativeSelectionPos.Start, state.doc.resolve(from), _types.SelectionDirection.Before)(state, dispatch);
|
|
154
152
|
}
|
|
@@ -162,7 +160,7 @@ var arrowLeftFromNode = function arrowLeftFromNode(selection) {
|
|
|
162
160
|
return setSelectionInsideAtNodeStart(_selection.RelativeSelectionPos.Before, node, from)(state, dispatch);
|
|
163
161
|
} else if ((0, _selection.isIgnored)(node) && selectionRelativeToNode === _selection.RelativeSelectionPos.Start) {
|
|
164
162
|
// selection is for node without gap cursor preceeded by another node without gap cursor - set node selection for previous node
|
|
165
|
-
var selectableNode = (0,
|
|
163
|
+
var selectableNode = (0, _utils2.findSelectableContainerBefore)($from, state.doc);
|
|
166
164
|
if (selectableNode && (0, _selection.isIgnored)(selectableNode.node)) {
|
|
167
165
|
return setSelectionRelativeToNode(_selection.RelativeSelectionPos.End, _state.NodeSelection.create(state.doc, selectableNode.pos))(state, dispatch);
|
|
168
166
|
}
|
|
@@ -172,8 +170,8 @@ var arrowLeftFromNode = function arrowLeftFromNode(selection) {
|
|
|
172
170
|
};
|
|
173
171
|
var arrowRightFromText = function arrowRightFromText(selection) {
|
|
174
172
|
return function (state, dispatch) {
|
|
175
|
-
if ((0,
|
|
176
|
-
var selectableNode = (0,
|
|
173
|
+
if ((0, _utils2.isSelectionAtEndOfParentNode)(selection.$to, selection)) {
|
|
174
|
+
var selectableNode = (0, _utils2.findSelectableContainerParent)(selection);
|
|
177
175
|
if (selectableNode) {
|
|
178
176
|
return setSelectionRelativeToNode(_selection.RelativeSelectionPos.End, _state.NodeSelection.create(state.doc, selectableNode.pos))(state, dispatch);
|
|
179
177
|
}
|
|
@@ -186,7 +184,7 @@ var arrowLeftFromText = function arrowLeftFromText(selection) {
|
|
|
186
184
|
var _getPluginState4 = (0, _pluginFactory.getPluginState)(state),
|
|
187
185
|
selectionRelativeToNode = _getPluginState4.selectionRelativeToNode;
|
|
188
186
|
if (selectionRelativeToNode === _selection.RelativeSelectionPos.Before) {
|
|
189
|
-
var selectableNode = (0,
|
|
187
|
+
var selectableNode = (0, _utils2.findSelectableContainerBefore)(selection.$from, state.doc);
|
|
190
188
|
if (selectableNode && (0, _selection.isIgnored)(selectableNode.node)) {
|
|
191
189
|
// selection is inside node without gap cursor preceeded by another node without gap cursor - set node selection for previous node
|
|
192
190
|
return setSelectionRelativeToNode(_selection.RelativeSelectionPos.End, _state.NodeSelection.create(state.doc, selectableNode.pos))(state, dispatch);
|
|
@@ -194,8 +192,8 @@ var arrowLeftFromText = function arrowLeftFromText(selection) {
|
|
|
194
192
|
// we don't return this as we want to reset the relative pos, but not block other plugins
|
|
195
193
|
// from responding to arrow left key
|
|
196
194
|
setSelectionRelativeToNode(undefined)(state, dispatch);
|
|
197
|
-
} else if ((0,
|
|
198
|
-
var _selectableNode4 = (0,
|
|
195
|
+
} else if ((0, _utils2.isSelectionAtStartOfParentNode)(selection.$from, selection)) {
|
|
196
|
+
var _selectableNode4 = (0, _utils2.findSelectableContainerParent)(selection);
|
|
199
197
|
if (_selectableNode4) {
|
|
200
198
|
return setSelectionRelativeToNode(_selection.RelativeSelectionPos.Start, _state.NodeSelection.create(state.doc, _selectableNode4.pos))(state, dispatch);
|
|
201
199
|
}
|
|
@@ -217,7 +215,7 @@ var setSelectionInsideAtNodeStart = function setSelectionInsideAtNodeStart(selec
|
|
|
217
215
|
if ((0, _utils.isNodeEmpty)(node)) {
|
|
218
216
|
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(pos), _types.SelectionDirection.After)(state, dispatch);
|
|
219
217
|
}
|
|
220
|
-
var selectableNode = (0,
|
|
218
|
+
var selectableNode = (0, _utils2.findFirstChildNodeToSelect)(node);
|
|
221
219
|
if (selectableNode) {
|
|
222
220
|
var childNode = selectableNode.node,
|
|
223
221
|
childPos = selectableNode.pos;
|
|
@@ -229,7 +227,7 @@ var setSelectionInsideAtNodeStart = function setSelectionInsideAtNodeStart(selec
|
|
|
229
227
|
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(selectionPos + 1), _types.SelectionDirection.Before)(state, dispatch);
|
|
230
228
|
} else if (!(0, _selection.isIgnored)(node)) {
|
|
231
229
|
return setSelectionRelativeToNode(selectionRelativeToNode, new _selection.GapCursorSelection(state.doc.resolve(selectionPos), _selection.Side.LEFT))(state, dispatch);
|
|
232
|
-
} else if ((0,
|
|
230
|
+
} else if ((0, _utils2.isSelectableContainerNode)(node)) {
|
|
233
231
|
return setSelectionRelativeToNode(selectionRelativeToNode, _state.NodeSelection.create(state.doc, selectionPos))(state, dispatch);
|
|
234
232
|
}
|
|
235
233
|
}
|
|
@@ -241,7 +239,7 @@ var setSelectionInsideAtNodeEnd = exports.setSelectionInsideAtNodeEnd = function
|
|
|
241
239
|
if ((0, _utils.isNodeEmpty)(node)) {
|
|
242
240
|
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(to), _types.SelectionDirection.Before)(state, dispatch);
|
|
243
241
|
}
|
|
244
|
-
var selectableNode = (0,
|
|
242
|
+
var selectableNode = (0, _utils2.findLastChildNodeToSelect)(node);
|
|
245
243
|
if (selectableNode) {
|
|
246
244
|
var childNode = selectableNode.node,
|
|
247
245
|
childPos = selectableNode.pos;
|
|
@@ -253,51 +251,10 @@ var setSelectionInsideAtNodeEnd = exports.setSelectionInsideAtNodeEnd = function
|
|
|
253
251
|
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(selectionPos), _types.SelectionDirection.After)(state, dispatch);
|
|
254
252
|
} else if (!(0, _selection.isIgnored)(node)) {
|
|
255
253
|
return setSelectionRelativeToNode(selectionRelativeToNode, new _selection.GapCursorSelection(state.doc.resolve(selectionPos + 1), _selection.Side.RIGHT))(state, dispatch);
|
|
256
|
-
} else if ((0,
|
|
254
|
+
} else if ((0, _utils2.isSelectableContainerNode)(node)) {
|
|
257
255
|
return setSelectionRelativeToNode(selectionRelativeToNode, _state.NodeSelection.create(state.doc, selectionPos))(state, dispatch);
|
|
258
256
|
}
|
|
259
257
|
}
|
|
260
258
|
return false;
|
|
261
259
|
};
|
|
262
|
-
};
|
|
263
|
-
var selectNodeWithModA = exports.selectNodeWithModA = function selectNodeWithModA() {
|
|
264
|
-
return function (state, dispatch) {
|
|
265
|
-
var selection = state.selection;
|
|
266
|
-
var $from = selection.$from,
|
|
267
|
-
$to = selection.$to;
|
|
268
|
-
// Check if the selection is at the top level (e.g., in a paragraph)
|
|
269
|
-
var isTopLevelSelection = $from.depth === 1 || $to.depth === 1;
|
|
270
|
-
|
|
271
|
-
// Determine if the selection is within a code block
|
|
272
|
-
var isInCodeBlock = $from.sameParent($to) && $from.parent.type === state.schema.nodes.codeBlock;
|
|
273
|
-
|
|
274
|
-
// If the selection is at the top level and not in a code block, or if a table is selected, do nothing
|
|
275
|
-
if (isTopLevelSelection && !isInCodeBlock) {
|
|
276
|
-
return false;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
// Get the depth of the first common ancestor node
|
|
280
|
-
var commonAncestorDepth = $from.sharedDepth($to.pos);
|
|
281
|
-
|
|
282
|
-
// We need to adjust the common ancestor depth if a table is selected
|
|
283
|
-
// to skip the current table node and select the parent node instead
|
|
284
|
-
if ((0, _utils3.isTableSelected)(state.selection)) {
|
|
285
|
-
var table = (0, _utils2.findParentNodeOfType)(state.schema.nodes.table)(state.selection);
|
|
286
|
-
if (table) {
|
|
287
|
-
commonAncestorDepth = table.depth - 1;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
for (var depth = commonAncestorDepth; depth > 0; depth--) {
|
|
291
|
-
var node = $from.node(depth);
|
|
292
|
-
var isParentBlockQuote = node.type.name === 'blockquote';
|
|
293
|
-
var isSelectable = _state.NodeSelection.isSelectable(node) && !isParentBlockQuote;
|
|
294
|
-
if (isSelectable) {
|
|
295
|
-
if (dispatch) {
|
|
296
|
-
dispatch(state.tr.setSelection(_state.NodeSelection.create(state.doc, $from.before(depth))));
|
|
297
|
-
}
|
|
298
|
-
return true;
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
return false;
|
|
302
|
-
};
|
|
303
260
|
};
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
8
8
|
var _keymap = require("@atlaskit/editor-prosemirror/keymap");
|
|
9
|
-
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
10
9
|
var _commands = require("./commands");
|
|
11
10
|
function keymapPlugin() {
|
|
12
11
|
var list = {};
|
|
@@ -18,13 +17,6 @@ function keymapPlugin() {
|
|
|
18
17
|
// Ignored via go/ees005
|
|
19
18
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
20
19
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.moveLeft.common, _commands.arrowLeft, list);
|
|
21
|
-
if ((0, _experiments.editorExperiment)('platform_editor_cmd_a_progressively_select_nodes', true, {
|
|
22
|
-
exposure: true
|
|
23
|
-
})) {
|
|
24
|
-
// Ignored via go/ees005
|
|
25
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
26
|
-
(0, _keymaps.bindKeymapWithCommand)(_keymaps.selectNode.common, (0, _commands.selectNodeWithModA)(), list);
|
|
27
|
-
}
|
|
28
20
|
return (0, _keymap.keymap)(list);
|
|
29
21
|
}
|
|
30
22
|
var _default = exports.default = keymapPlugin;
|
|
@@ -5,9 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.selectionPlugin = exports.default = void 0;
|
|
8
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
11
9
|
var _autoExpandSelectionRangeOnInlineNodeMain = require("./pm-plugins/auto-expand-selection-range-on-inline-node-main");
|
|
12
10
|
var _commands = require("./pm-plugins/commands");
|
|
13
11
|
var _gapCursorKeymap = _interopRequireDefault(require("./pm-plugins/gap-cursor-keymap"));
|
|
@@ -15,7 +13,6 @@ var _gapCursorMain = _interopRequireDefault(require("./pm-plugins/gap-cursor-mai
|
|
|
15
13
|
var _gapCursorPluginKey = require("./pm-plugins/gap-cursor-plugin-key");
|
|
16
14
|
var _keymap = _interopRequireDefault(require("./pm-plugins/keymap"));
|
|
17
15
|
var _markBoundaryCursorMain = require("./pm-plugins/mark-boundary-cursor-main");
|
|
18
|
-
var _selectionAnalytics = require("./pm-plugins/selection-analytics");
|
|
19
16
|
var _selectionMain = require("./pm-plugins/selection-main");
|
|
20
17
|
var _types = require("./types");
|
|
21
18
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -105,19 +102,12 @@ var selectionPlugin = exports.selectionPlugin = function selectionPlugin(_ref4)
|
|
|
105
102
|
plugin: function plugin() {
|
|
106
103
|
return (0, _markBoundaryCursorMain.createMarkBoundaryCursorPlugin)();
|
|
107
104
|
}
|
|
108
|
-
}
|
|
105
|
+
}, {
|
|
109
106
|
name: 'autoExpandSelectionRangeOnInlineNode',
|
|
110
107
|
plugin: function plugin() {
|
|
111
108
|
return (0, _autoExpandSelectionRangeOnInlineNodeMain.createAutoExpandSelectionRangeOnInlineNodePlugin)();
|
|
112
109
|
}
|
|
113
|
-
}]
|
|
114
|
-
name: 'selectionAnalytics',
|
|
115
|
-
plugin: function plugin(_ref7) {
|
|
116
|
-
var dispatch = _ref7.dispatch,
|
|
117
|
-
dispatchAnalyticsEvent = _ref7.dispatchAnalyticsEvent;
|
|
118
|
-
return (0, _selectionAnalytics.createSelectionAnalyticsPlugin)(dispatchAnalyticsEvent);
|
|
119
|
-
}
|
|
120
|
-
}]);
|
|
110
|
+
}];
|
|
121
111
|
}
|
|
122
112
|
};
|
|
123
113
|
};
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
import { isIgnored as isIgnoredByGapCursor, RelativeSelectionPos, GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
|
|
3
3
|
import { isEmptyParagraph, isNodeEmpty } from '@atlaskit/editor-common/utils';
|
|
4
4
|
import { NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
-
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
6
|
-
import { isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
7
5
|
import { SelectionDirection, selectionPluginKey } from '../types';
|
|
8
6
|
import { SelectionActionTypes } from './actions';
|
|
9
7
|
import { createCommand, getPluginState } from './plugin-factory';
|
|
@@ -251,47 +249,4 @@ export const setSelectionInsideAtNodeEnd = (selectionRelativeToNode, node, from,
|
|
|
251
249
|
}
|
|
252
250
|
}
|
|
253
251
|
return false;
|
|
254
|
-
};
|
|
255
|
-
export const selectNodeWithModA = () => (state, dispatch) => {
|
|
256
|
-
const {
|
|
257
|
-
selection
|
|
258
|
-
} = state;
|
|
259
|
-
const {
|
|
260
|
-
$from,
|
|
261
|
-
$to
|
|
262
|
-
} = selection;
|
|
263
|
-
// Check if the selection is at the top level (e.g., in a paragraph)
|
|
264
|
-
const isTopLevelSelection = $from.depth === 1 || $to.depth === 1;
|
|
265
|
-
|
|
266
|
-
// Determine if the selection is within a code block
|
|
267
|
-
const isInCodeBlock = $from.sameParent($to) && $from.parent.type === state.schema.nodes.codeBlock;
|
|
268
|
-
|
|
269
|
-
// If the selection is at the top level and not in a code block, or if a table is selected, do nothing
|
|
270
|
-
if (isTopLevelSelection && !isInCodeBlock) {
|
|
271
|
-
return false;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
// Get the depth of the first common ancestor node
|
|
275
|
-
let commonAncestorDepth = $from.sharedDepth($to.pos);
|
|
276
|
-
|
|
277
|
-
// We need to adjust the common ancestor depth if a table is selected
|
|
278
|
-
// to skip the current table node and select the parent node instead
|
|
279
|
-
if (isTableSelected(state.selection)) {
|
|
280
|
-
const table = findParentNodeOfType(state.schema.nodes.table)(state.selection);
|
|
281
|
-
if (table) {
|
|
282
|
-
commonAncestorDepth = table.depth - 1;
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
for (let depth = commonAncestorDepth; depth > 0; depth--) {
|
|
286
|
-
const node = $from.node(depth);
|
|
287
|
-
const isParentBlockQuote = node.type.name === 'blockquote';
|
|
288
|
-
const isSelectable = NodeSelection.isSelectable(node) && !isParentBlockQuote;
|
|
289
|
-
if (isSelectable) {
|
|
290
|
-
if (dispatch) {
|
|
291
|
-
dispatch(state.tr.setSelection(NodeSelection.create(state.doc, $from.before(depth))));
|
|
292
|
-
}
|
|
293
|
-
return true;
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
return false;
|
|
297
252
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { bindKeymapWithCommand, moveLeft, moveRight
|
|
1
|
+
import { bindKeymapWithCommand, moveLeft, moveRight } from '@atlaskit/editor-common/keymaps';
|
|
2
2
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
3
|
-
import {
|
|
4
|
-
import { arrowLeft, arrowRight, selectNodeWithModA } from './commands';
|
|
3
|
+
import { arrowLeft, arrowRight } from './commands';
|
|
5
4
|
function keymapPlugin() {
|
|
6
5
|
const list = {};
|
|
7
6
|
|
|
@@ -12,13 +11,6 @@ function keymapPlugin() {
|
|
|
12
11
|
// Ignored via go/ees005
|
|
13
12
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
14
13
|
bindKeymapWithCommand(moveLeft.common, arrowLeft, list);
|
|
15
|
-
if (editorExperiment('platform_editor_cmd_a_progressively_select_nodes', true, {
|
|
16
|
-
exposure: true
|
|
17
|
-
})) {
|
|
18
|
-
// Ignored via go/ees005
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
20
|
-
bindKeymapWithCommand(selectNode.common, selectNodeWithModA(), list);
|
|
21
|
-
}
|
|
22
14
|
return keymap(list);
|
|
23
15
|
}
|
|
24
16
|
export default keymapPlugin;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
1
|
import { createAutoExpandSelectionRangeOnInlineNodePlugin } from './pm-plugins/auto-expand-selection-range-on-inline-node-main';
|
|
3
2
|
import { selectNearNode } from './pm-plugins/commands';
|
|
4
3
|
import gapCursorKeymapPlugin from './pm-plugins/gap-cursor-keymap';
|
|
@@ -6,7 +5,6 @@ import gapCursorPlugin from './pm-plugins/gap-cursor-main';
|
|
|
6
5
|
import { gapCursorPluginKey } from './pm-plugins/gap-cursor-plugin-key';
|
|
7
6
|
import selectionKeymapPlugin from './pm-plugins/keymap';
|
|
8
7
|
import { createMarkBoundaryCursorPlugin } from './pm-plugins/mark-boundary-cursor-main';
|
|
9
|
-
import { createSelectionAnalyticsPlugin } from './pm-plugins/selection-analytics';
|
|
10
8
|
import { createPlugin } from './pm-plugins/selection-main';
|
|
11
9
|
import { selectionPluginKey } from './types';
|
|
12
10
|
const displayGapCursor = toggle => ({
|
|
@@ -85,15 +83,9 @@ export const selectionPlugin = ({
|
|
|
85
83
|
}, {
|
|
86
84
|
name: 'markBoundaryCursor',
|
|
87
85
|
plugin: () => createMarkBoundaryCursorPlugin()
|
|
88
|
-
},
|
|
86
|
+
}, {
|
|
89
87
|
name: 'autoExpandSelectionRangeOnInlineNode',
|
|
90
88
|
plugin: () => createAutoExpandSelectionRangeOnInlineNodePlugin()
|
|
91
|
-
}] : []), {
|
|
92
|
-
name: 'selectionAnalytics',
|
|
93
|
-
plugin: ({
|
|
94
|
-
dispatch,
|
|
95
|
-
dispatchAnalyticsEvent
|
|
96
|
-
}) => createSelectionAnalyticsPlugin(dispatchAnalyticsEvent)
|
|
97
89
|
}];
|
|
98
90
|
}
|
|
99
91
|
});
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
import { isIgnored as isIgnoredByGapCursor, RelativeSelectionPos, GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
|
|
3
3
|
import { isEmptyParagraph, isNodeEmpty } from '@atlaskit/editor-common/utils';
|
|
4
4
|
import { NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
-
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
6
|
-
import { isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
7
5
|
import { SelectionDirection, selectionPluginKey } from '../types';
|
|
8
6
|
import { SelectionActionTypes } from './actions';
|
|
9
7
|
import { createCommand, getPluginState } from './plugin-factory';
|
|
@@ -252,45 +250,4 @@ export var setSelectionInsideAtNodeEnd = function setSelectionInsideAtNodeEnd(se
|
|
|
252
250
|
}
|
|
253
251
|
return false;
|
|
254
252
|
};
|
|
255
|
-
};
|
|
256
|
-
export var selectNodeWithModA = function selectNodeWithModA() {
|
|
257
|
-
return function (state, dispatch) {
|
|
258
|
-
var selection = state.selection;
|
|
259
|
-
var $from = selection.$from,
|
|
260
|
-
$to = selection.$to;
|
|
261
|
-
// Check if the selection is at the top level (e.g., in a paragraph)
|
|
262
|
-
var isTopLevelSelection = $from.depth === 1 || $to.depth === 1;
|
|
263
|
-
|
|
264
|
-
// Determine if the selection is within a code block
|
|
265
|
-
var isInCodeBlock = $from.sameParent($to) && $from.parent.type === state.schema.nodes.codeBlock;
|
|
266
|
-
|
|
267
|
-
// If the selection is at the top level and not in a code block, or if a table is selected, do nothing
|
|
268
|
-
if (isTopLevelSelection && !isInCodeBlock) {
|
|
269
|
-
return false;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
// Get the depth of the first common ancestor node
|
|
273
|
-
var commonAncestorDepth = $from.sharedDepth($to.pos);
|
|
274
|
-
|
|
275
|
-
// We need to adjust the common ancestor depth if a table is selected
|
|
276
|
-
// to skip the current table node and select the parent node instead
|
|
277
|
-
if (isTableSelected(state.selection)) {
|
|
278
|
-
var table = findParentNodeOfType(state.schema.nodes.table)(state.selection);
|
|
279
|
-
if (table) {
|
|
280
|
-
commonAncestorDepth = table.depth - 1;
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
for (var depth = commonAncestorDepth; depth > 0; depth--) {
|
|
284
|
-
var node = $from.node(depth);
|
|
285
|
-
var isParentBlockQuote = node.type.name === 'blockquote';
|
|
286
|
-
var isSelectable = NodeSelection.isSelectable(node) && !isParentBlockQuote;
|
|
287
|
-
if (isSelectable) {
|
|
288
|
-
if (dispatch) {
|
|
289
|
-
dispatch(state.tr.setSelection(NodeSelection.create(state.doc, $from.before(depth))));
|
|
290
|
-
}
|
|
291
|
-
return true;
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
return false;
|
|
295
|
-
};
|
|
296
253
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { bindKeymapWithCommand, moveLeft, moveRight
|
|
1
|
+
import { bindKeymapWithCommand, moveLeft, moveRight } from '@atlaskit/editor-common/keymaps';
|
|
2
2
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
3
|
-
import {
|
|
4
|
-
import { arrowLeft, arrowRight, selectNodeWithModA } from './commands';
|
|
3
|
+
import { arrowLeft, arrowRight } from './commands';
|
|
5
4
|
function keymapPlugin() {
|
|
6
5
|
var list = {};
|
|
7
6
|
|
|
@@ -12,13 +11,6 @@ function keymapPlugin() {
|
|
|
12
11
|
// Ignored via go/ees005
|
|
13
12
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
14
13
|
bindKeymapWithCommand(moveLeft.common, arrowLeft, list);
|
|
15
|
-
if (editorExperiment('platform_editor_cmd_a_progressively_select_nodes', true, {
|
|
16
|
-
exposure: true
|
|
17
|
-
})) {
|
|
18
|
-
// Ignored via go/ees005
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
20
|
-
bindKeymapWithCommand(selectNode.common, selectNodeWithModA(), list);
|
|
21
|
-
}
|
|
22
14
|
return keymap(list);
|
|
23
15
|
}
|
|
24
16
|
export default keymapPlugin;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
4
|
import { createAutoExpandSelectionRangeOnInlineNodePlugin } from './pm-plugins/auto-expand-selection-range-on-inline-node-main';
|
|
7
5
|
import { selectNearNode as _selectNearNode } from './pm-plugins/commands';
|
|
8
6
|
import gapCursorKeymapPlugin from './pm-plugins/gap-cursor-keymap';
|
|
@@ -10,7 +8,6 @@ import gapCursorPlugin from './pm-plugins/gap-cursor-main';
|
|
|
10
8
|
import { gapCursorPluginKey } from './pm-plugins/gap-cursor-plugin-key';
|
|
11
9
|
import selectionKeymapPlugin from './pm-plugins/keymap';
|
|
12
10
|
import { createMarkBoundaryCursorPlugin } from './pm-plugins/mark-boundary-cursor-main';
|
|
13
|
-
import { createSelectionAnalyticsPlugin } from './pm-plugins/selection-analytics';
|
|
14
11
|
import { createPlugin } from './pm-plugins/selection-main';
|
|
15
12
|
import { selectionPluginKey } from './types';
|
|
16
13
|
var displayGapCursor = function displayGapCursor(toggle) {
|
|
@@ -98,19 +95,12 @@ export var selectionPlugin = function selectionPlugin(_ref4) {
|
|
|
98
95
|
plugin: function plugin() {
|
|
99
96
|
return createMarkBoundaryCursorPlugin();
|
|
100
97
|
}
|
|
101
|
-
}
|
|
98
|
+
}, {
|
|
102
99
|
name: 'autoExpandSelectionRangeOnInlineNode',
|
|
103
100
|
plugin: function plugin() {
|
|
104
101
|
return createAutoExpandSelectionRangeOnInlineNodePlugin();
|
|
105
102
|
}
|
|
106
|
-
}]
|
|
107
|
-
name: 'selectionAnalytics',
|
|
108
|
-
plugin: function plugin(_ref7) {
|
|
109
|
-
var dispatch = _ref7.dispatch,
|
|
110
|
-
dispatchAnalyticsEvent = _ref7.dispatchAnalyticsEvent;
|
|
111
|
-
return createSelectionAnalyticsPlugin(dispatchAnalyticsEvent);
|
|
112
|
-
}
|
|
113
|
-
}]);
|
|
103
|
+
}];
|
|
114
104
|
}
|
|
115
105
|
};
|
|
116
106
|
};
|
|
@@ -7,4 +7,3 @@ export declare const setSelectionRelativeToNode: (selectionRelativeToNode?: Rela
|
|
|
7
7
|
export declare const arrowRight: Command;
|
|
8
8
|
export declare const arrowLeft: Command;
|
|
9
9
|
export declare const setSelectionInsideAtNodeEnd: (selectionRelativeToNode: RelativeSelectionPos, node: PmNode, from: number, to: number) => Command;
|
|
10
|
-
export declare const selectNodeWithModA: () => Command;
|
|
@@ -7,4 +7,3 @@ export declare const setSelectionRelativeToNode: (selectionRelativeToNode?: Rela
|
|
|
7
7
|
export declare const arrowRight: Command;
|
|
8
8
|
export declare const arrowLeft: Command;
|
|
9
9
|
export declare const setSelectionInsideAtNodeEnd: (selectionRelativeToNode: RelativeSelectionPos, node: PmNode, from: number, to: number) => Command;
|
|
10
|
-
export declare const selectNodeWithModA: () => Command;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-selection",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.6",
|
|
4
4
|
"description": "Selection plugin for @atlaskit/editor-core",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -20,13 +20,13 @@
|
|
|
20
20
|
"runReact18": true
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@atlaskit/editor-common": "^102.
|
|
23
|
+
"@atlaskit/editor-common": "^102.17.0",
|
|
24
24
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
25
25
|
"@atlaskit/editor-shared-styles": "^3.4.0",
|
|
26
26
|
"@atlaskit/editor-tables": "^2.9.0",
|
|
27
27
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
28
|
-
"@atlaskit/tmp-editor-statsig": "^4.
|
|
29
|
-
"@atlaskit/tokens": "^4.
|
|
28
|
+
"@atlaskit/tmp-editor-statsig": "^4.6.0",
|
|
29
|
+
"@atlaskit/tokens": "^4.6.0",
|
|
30
30
|
"@babel/runtime": "^7.0.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
@@ -87,9 +87,6 @@
|
|
|
87
87
|
"platform_editor_fix_drag_and_drop_lists": {
|
|
88
88
|
"type": "boolean"
|
|
89
89
|
},
|
|
90
|
-
"editor_auto_expand_selection_on_inline_node": {
|
|
91
|
-
"type": "boolean"
|
|
92
|
-
},
|
|
93
90
|
"platform_editor_lcm_inline_node_selection_fix": {
|
|
94
91
|
"type": "boolean"
|
|
95
92
|
},
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.selectionAnalyticsPluginKey = exports.createSelectionAnalyticsPlugin = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
10
|
-
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
11
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
12
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
14
|
-
var selectionAnalyticsPluginKey = exports.selectionAnalyticsPluginKey = new _state.PluginKey('selectionAnalyticsPluginKey');
|
|
15
|
-
var createSelectionAnalyticsPlugin = exports.createSelectionAnalyticsPlugin = function createSelectionAnalyticsPlugin(dispatchAnalyticsEvent) {
|
|
16
|
-
var keyActions = new Map([['c', 'copy'], ['x', 'cut'], ['z', 'undo'], ['Escape', 'escape'], ['Backspace', 'delete']]);
|
|
17
|
-
var isFollowUpKey = function isFollowUpKey(event) {
|
|
18
|
-
return ['c', 'x', 'z'].includes(event.key) && (event.metaKey || event.ctrlKey) || ['Escape', 'Backspace'].includes(event.key);
|
|
19
|
-
};
|
|
20
|
-
var dispatchEvent = function dispatchEvent(fromDepth, followedBy) {
|
|
21
|
-
dispatchAnalyticsEvent({
|
|
22
|
-
action: _analytics.ACTION.SELECT_ALL,
|
|
23
|
-
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
24
|
-
actionSubjectId: _analytics.ACTION_SUBJECT_ID.ALL,
|
|
25
|
-
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
26
|
-
attributes: {
|
|
27
|
-
followedBy: followedBy,
|
|
28
|
-
fromDepth: fromDepth
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
return new _safePlugin.SafePlugin({
|
|
33
|
-
key: selectionAnalyticsPluginKey,
|
|
34
|
-
state: {
|
|
35
|
-
init: function init() {
|
|
36
|
-
return {
|
|
37
|
-
lastCmdAPress: 0,
|
|
38
|
-
trackingCmdA: false
|
|
39
|
-
};
|
|
40
|
-
},
|
|
41
|
-
apply: function apply(tr, state) {
|
|
42
|
-
var meta = tr.getMeta(selectionAnalyticsPluginKey);
|
|
43
|
-
return meta ? _objectSpread(_objectSpread({}, state), meta) : state;
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
props: {
|
|
47
|
-
handleDOMEvents: {
|
|
48
|
-
keydown: function keydown(view, event) {
|
|
49
|
-
var _selectionAnalyticsPl = selectionAnalyticsPluginKey.getState(view.state),
|
|
50
|
-
lastCmdAPress = _selectionAnalyticsPl.lastCmdAPress,
|
|
51
|
-
trackingCmdA = _selectionAnalyticsPl.trackingCmdA;
|
|
52
|
-
var tr = view.state.tr;
|
|
53
|
-
var depth = view.state.selection.$from.depth;
|
|
54
|
-
var metaKey = event.metaKey || event.ctrlKey;
|
|
55
|
-
if (event.key === 'a' && metaKey) {
|
|
56
|
-
tr.setMeta(selectionAnalyticsPluginKey, {
|
|
57
|
-
lastCmdAPress: Date.now(),
|
|
58
|
-
trackingCmdA: true
|
|
59
|
-
});
|
|
60
|
-
dispatchEvent(depth);
|
|
61
|
-
view.dispatch(tr);
|
|
62
|
-
} else if (trackingCmdA && Date.now() - lastCmdAPress < 5000 && isFollowUpKey(event)) {
|
|
63
|
-
tr.setMeta(selectionAnalyticsPluginKey, {
|
|
64
|
-
trackingCmdA: false
|
|
65
|
-
});
|
|
66
|
-
dispatchEvent(depth, keyActions.get(event.key));
|
|
67
|
-
view.dispatch(tr);
|
|
68
|
-
}
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
};
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
2
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
-
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
-
export const selectionAnalyticsPluginKey = new PluginKey('selectionAnalyticsPluginKey');
|
|
5
|
-
export const createSelectionAnalyticsPlugin = dispatchAnalyticsEvent => {
|
|
6
|
-
const keyActions = new Map([['c', 'copy'], ['x', 'cut'], ['z', 'undo'], ['Escape', 'escape'], ['Backspace', 'delete']]);
|
|
7
|
-
const isFollowUpKey = event => ['c', 'x', 'z'].includes(event.key) && (event.metaKey || event.ctrlKey) || ['Escape', 'Backspace'].includes(event.key);
|
|
8
|
-
const dispatchEvent = (fromDepth, followedBy) => {
|
|
9
|
-
dispatchAnalyticsEvent({
|
|
10
|
-
action: ACTION.SELECT_ALL,
|
|
11
|
-
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
12
|
-
actionSubjectId: ACTION_SUBJECT_ID.ALL,
|
|
13
|
-
eventType: EVENT_TYPE.TRACK,
|
|
14
|
-
attributes: {
|
|
15
|
-
followedBy,
|
|
16
|
-
fromDepth
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
return new SafePlugin({
|
|
21
|
-
key: selectionAnalyticsPluginKey,
|
|
22
|
-
state: {
|
|
23
|
-
init: () => ({
|
|
24
|
-
lastCmdAPress: 0,
|
|
25
|
-
trackingCmdA: false
|
|
26
|
-
}),
|
|
27
|
-
apply(tr, state) {
|
|
28
|
-
const meta = tr.getMeta(selectionAnalyticsPluginKey);
|
|
29
|
-
return meta ? {
|
|
30
|
-
...state,
|
|
31
|
-
...meta
|
|
32
|
-
} : state;
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
props: {
|
|
36
|
-
handleDOMEvents: {
|
|
37
|
-
keydown(view, event) {
|
|
38
|
-
const {
|
|
39
|
-
lastCmdAPress,
|
|
40
|
-
trackingCmdA
|
|
41
|
-
} = selectionAnalyticsPluginKey.getState(view.state);
|
|
42
|
-
const tr = view.state.tr;
|
|
43
|
-
const depth = view.state.selection.$from.depth;
|
|
44
|
-
const metaKey = event.metaKey || event.ctrlKey;
|
|
45
|
-
if (event.key === 'a' && metaKey) {
|
|
46
|
-
tr.setMeta(selectionAnalyticsPluginKey, {
|
|
47
|
-
lastCmdAPress: Date.now(),
|
|
48
|
-
trackingCmdA: true
|
|
49
|
-
});
|
|
50
|
-
dispatchEvent(depth);
|
|
51
|
-
view.dispatch(tr);
|
|
52
|
-
} else if (trackingCmdA && Date.now() - lastCmdAPress < 5000 && isFollowUpKey(event)) {
|
|
53
|
-
tr.setMeta(selectionAnalyticsPluginKey, {
|
|
54
|
-
trackingCmdA: false
|
|
55
|
-
});
|
|
56
|
-
dispatchEvent(depth, keyActions.get(event.key));
|
|
57
|
-
view.dispatch(tr);
|
|
58
|
-
}
|
|
59
|
-
return false;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
5
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
6
|
-
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
7
|
-
export var selectionAnalyticsPluginKey = new PluginKey('selectionAnalyticsPluginKey');
|
|
8
|
-
export var createSelectionAnalyticsPlugin = function createSelectionAnalyticsPlugin(dispatchAnalyticsEvent) {
|
|
9
|
-
var keyActions = new Map([['c', 'copy'], ['x', 'cut'], ['z', 'undo'], ['Escape', 'escape'], ['Backspace', 'delete']]);
|
|
10
|
-
var isFollowUpKey = function isFollowUpKey(event) {
|
|
11
|
-
return ['c', 'x', 'z'].includes(event.key) && (event.metaKey || event.ctrlKey) || ['Escape', 'Backspace'].includes(event.key);
|
|
12
|
-
};
|
|
13
|
-
var dispatchEvent = function dispatchEvent(fromDepth, followedBy) {
|
|
14
|
-
dispatchAnalyticsEvent({
|
|
15
|
-
action: ACTION.SELECT_ALL,
|
|
16
|
-
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
17
|
-
actionSubjectId: ACTION_SUBJECT_ID.ALL,
|
|
18
|
-
eventType: EVENT_TYPE.TRACK,
|
|
19
|
-
attributes: {
|
|
20
|
-
followedBy: followedBy,
|
|
21
|
-
fromDepth: fromDepth
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
return new SafePlugin({
|
|
26
|
-
key: selectionAnalyticsPluginKey,
|
|
27
|
-
state: {
|
|
28
|
-
init: function init() {
|
|
29
|
-
return {
|
|
30
|
-
lastCmdAPress: 0,
|
|
31
|
-
trackingCmdA: false
|
|
32
|
-
};
|
|
33
|
-
},
|
|
34
|
-
apply: function apply(tr, state) {
|
|
35
|
-
var meta = tr.getMeta(selectionAnalyticsPluginKey);
|
|
36
|
-
return meta ? _objectSpread(_objectSpread({}, state), meta) : state;
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
props: {
|
|
40
|
-
handleDOMEvents: {
|
|
41
|
-
keydown: function keydown(view, event) {
|
|
42
|
-
var _selectionAnalyticsPl = selectionAnalyticsPluginKey.getState(view.state),
|
|
43
|
-
lastCmdAPress = _selectionAnalyticsPl.lastCmdAPress,
|
|
44
|
-
trackingCmdA = _selectionAnalyticsPl.trackingCmdA;
|
|
45
|
-
var tr = view.state.tr;
|
|
46
|
-
var depth = view.state.selection.$from.depth;
|
|
47
|
-
var metaKey = event.metaKey || event.ctrlKey;
|
|
48
|
-
if (event.key === 'a' && metaKey) {
|
|
49
|
-
tr.setMeta(selectionAnalyticsPluginKey, {
|
|
50
|
-
lastCmdAPress: Date.now(),
|
|
51
|
-
trackingCmdA: true
|
|
52
|
-
});
|
|
53
|
-
dispatchEvent(depth);
|
|
54
|
-
view.dispatch(tr);
|
|
55
|
-
} else if (trackingCmdA && Date.now() - lastCmdAPress < 5000 && isFollowUpKey(event)) {
|
|
56
|
-
tr.setMeta(selectionAnalyticsPluginKey, {
|
|
57
|
-
trackingCmdA: false
|
|
58
|
-
});
|
|
59
|
-
dispatchEvent(depth, keyActions.get(event.key));
|
|
60
|
-
view.dispatch(tr);
|
|
61
|
-
}
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
2
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
-
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
-
export declare const selectionAnalyticsPluginKey: PluginKey<any>;
|
|
5
|
-
interface SelectionAnalyticsState {
|
|
6
|
-
lastCmdAPress: number;
|
|
7
|
-
trackingCmdA: boolean;
|
|
8
|
-
}
|
|
9
|
-
export declare const createSelectionAnalyticsPlugin: (dispatchAnalyticsEvent: DispatchAnalyticsEvent) => SafePlugin<SelectionAnalyticsState>;
|
|
10
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
2
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
-
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
-
export declare const selectionAnalyticsPluginKey: PluginKey<any>;
|
|
5
|
-
interface SelectionAnalyticsState {
|
|
6
|
-
lastCmdAPress: number;
|
|
7
|
-
trackingCmdA: boolean;
|
|
8
|
-
}
|
|
9
|
-
export declare const createSelectionAnalyticsPlugin: (dispatchAnalyticsEvent: DispatchAnalyticsEvent) => SafePlugin<SelectionAnalyticsState>;
|
|
10
|
-
export {};
|