@atlaskit/editor-plugin-selection 1.3.1 → 1.3.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 +8 -0
- package/dist/cjs/commands.js +33 -110
- package/dist/es2019/commands.js +8 -89
- package/dist/esm/commands.js +33 -110
- package/package.json +1 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-selection
|
|
2
2
|
|
|
3
|
+
## 1.3.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#125367](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/125367)
|
|
8
|
+
[`40695df29bb9a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/40695df29bb9a) -
|
|
9
|
+
Removed FF cd platform.editor.change-navigation-for-atom-nodes
|
|
10
|
+
|
|
3
11
|
## 1.3.1
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/dist/cjs/commands.js
CHANGED
|
@@ -7,7 +7,6 @@ exports.setSelectionRelativeToNode = exports.setSelectionInsideAtNodeEnd = expor
|
|
|
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 _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
11
10
|
var _actions = require("./actions");
|
|
12
11
|
var _gapCursorSelection = require("./gap-cursor-selection");
|
|
13
12
|
var _pluginFactory = require("./plugin-factory");
|
|
@@ -120,28 +119,9 @@ var arrowRightFromNode = function arrowRightFromNode(selection) {
|
|
|
120
119
|
$to = selection.$to;
|
|
121
120
|
var _getPluginState2 = (0, _pluginFactory.getPluginState)(state),
|
|
122
121
|
selectionRelativeToNode = _getPluginState2.selectionRelativeToNode;
|
|
123
|
-
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.change-navigation-for-atom-nodes')) {
|
|
124
|
-
if (node.isAtom) {
|
|
125
|
-
if ((0, _utils2.isSelectionAtEndOfParentNode)($to, selection) && (node.isInline || (0, _selection.isIgnored)(node))) {
|
|
126
|
-
// 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
|
|
127
|
-
return findAndSetTextSelection(_types.RelativeSelectionPos.End, state.doc.resolve(from + 1), _types.SelectionDirection.After)(state, dispatch);
|
|
128
|
-
}
|
|
129
|
-
return false;
|
|
130
|
-
} else if (selectionRelativeToNode === _types.RelativeSelectionPos.Start) {
|
|
131
|
-
// selection is for container node - set selection inside it at the start
|
|
132
|
-
return setSelectionInsideAtNodeStart(_types.RelativeSelectionPos.Inside, node, from)(state, dispatch);
|
|
133
|
-
} else if ((0, _selection.isIgnored)(node) && (!selectionRelativeToNode || selectionRelativeToNode === _types.RelativeSelectionPos.End)) {
|
|
134
|
-
var selectableNode = (0, _utils2.findSelectableContainerAfter)($to, state.doc);
|
|
135
|
-
if (selectableNode && (0, _selection.isIgnored)(selectableNode.node)) {
|
|
136
|
-
// selection is for node without gap cursor followed by another node without gap cursor - set node selection for next node
|
|
137
|
-
return setSelectionRelativeToNode(_types.RelativeSelectionPos.Start, _state.NodeSelection.create(state.doc, selectableNode.pos))(state, dispatch);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
return false;
|
|
141
|
-
}
|
|
142
122
|
if (node.isAtom) {
|
|
143
|
-
if ((0, _utils2.isSelectionAtEndOfParentNode)($to, selection)) {
|
|
144
|
-
// selection is for inline node that is the last child of its parent node - set text selection after it
|
|
123
|
+
if ((0, _utils2.isSelectionAtEndOfParentNode)($to, selection) && (node.isInline || (0, _selection.isIgnored)(node))) {
|
|
124
|
+
// 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
|
|
145
125
|
return findAndSetTextSelection(_types.RelativeSelectionPos.End, state.doc.resolve(from + 1), _types.SelectionDirection.After)(state, dispatch);
|
|
146
126
|
}
|
|
147
127
|
return false;
|
|
@@ -149,10 +129,10 @@ var arrowRightFromNode = function arrowRightFromNode(selection) {
|
|
|
149
129
|
// selection is for container node - set selection inside it at the start
|
|
150
130
|
return setSelectionInsideAtNodeStart(_types.RelativeSelectionPos.Inside, node, from)(state, dispatch);
|
|
151
131
|
} else if ((0, _selection.isIgnored)(node) && (!selectionRelativeToNode || selectionRelativeToNode === _types.RelativeSelectionPos.End)) {
|
|
152
|
-
var
|
|
153
|
-
if (
|
|
132
|
+
var selectableNode = (0, _utils2.findSelectableContainerAfter)($to, state.doc);
|
|
133
|
+
if (selectableNode && (0, _selection.isIgnored)(selectableNode.node)) {
|
|
154
134
|
// selection is for node without gap cursor followed by another node without gap cursor - set node selection for next node
|
|
155
|
-
return setSelectionRelativeToNode(_types.RelativeSelectionPos.Start, _state.NodeSelection.create(state.doc,
|
|
135
|
+
return setSelectionRelativeToNode(_types.RelativeSelectionPos.Start, _state.NodeSelection.create(state.doc, selectableNode.pos))(state, dispatch);
|
|
156
136
|
}
|
|
157
137
|
}
|
|
158
138
|
return false;
|
|
@@ -166,32 +146,9 @@ var arrowLeftFromNode = function arrowLeftFromNode(selection) {
|
|
|
166
146
|
$from = selection.$from;
|
|
167
147
|
var _getPluginState3 = (0, _pluginFactory.getPluginState)(state),
|
|
168
148
|
selectionRelativeToNode = _getPluginState3.selectionRelativeToNode;
|
|
169
|
-
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.change-navigation-for-atom-nodes')) {
|
|
170
|
-
if (node.isAtom) {
|
|
171
|
-
if ((0, _utils2.isSelectionAtStartOfParentNode)($from, selection) && (node.isInline || (0, _selection.isIgnored)(node))) {
|
|
172
|
-
// 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
|
|
173
|
-
return findAndSetTextSelection(_types.RelativeSelectionPos.Start, state.doc.resolve(from), _types.SelectionDirection.Before)(state, dispatch);
|
|
174
|
-
}
|
|
175
|
-
return false;
|
|
176
|
-
} else if (selectionRelativeToNode === _types.RelativeSelectionPos.End) {
|
|
177
|
-
// selection is for container node - set selection inside it at the end
|
|
178
|
-
return setSelectionInsideAtNodeEnd(_types.RelativeSelectionPos.Inside, node, from, to)(state, dispatch);
|
|
179
|
-
} else if (!selectionRelativeToNode || selectionRelativeToNode === _types.RelativeSelectionPos.Inside) {
|
|
180
|
-
// selection is for container node - set selection inside it at the start
|
|
181
|
-
// (this is a special case when the user selects by clicking node)
|
|
182
|
-
return setSelectionInsideAtNodeStart(_types.RelativeSelectionPos.Before, node, from)(state, dispatch);
|
|
183
|
-
} else if ((0, _selection.isIgnored)(node) && selectionRelativeToNode === _types.RelativeSelectionPos.Start) {
|
|
184
|
-
// selection is for node without gap cursor preceeded by another node without gap cursor - set node selection for previous node
|
|
185
|
-
var selectableNode = (0, _utils2.findSelectableContainerBefore)($from, state.doc);
|
|
186
|
-
if (selectableNode && (0, _selection.isIgnored)(selectableNode.node)) {
|
|
187
|
-
return setSelectionRelativeToNode(_types.RelativeSelectionPos.End, _state.NodeSelection.create(state.doc, selectableNode.pos))(state, dispatch);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
return false;
|
|
191
|
-
}
|
|
192
149
|
if (node.isAtom) {
|
|
193
|
-
if ((0, _utils2.isSelectionAtStartOfParentNode)($from, selection)) {
|
|
194
|
-
// selection is for inline node that is the first child of its parent node - set text selection before it
|
|
150
|
+
if ((0, _utils2.isSelectionAtStartOfParentNode)($from, selection) && (node.isInline || (0, _selection.isIgnored)(node))) {
|
|
151
|
+
// 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
|
|
195
152
|
return findAndSetTextSelection(_types.RelativeSelectionPos.Start, state.doc.resolve(from), _types.SelectionDirection.Before)(state, dispatch);
|
|
196
153
|
}
|
|
197
154
|
return false;
|
|
@@ -204,9 +161,9 @@ var arrowLeftFromNode = function arrowLeftFromNode(selection) {
|
|
|
204
161
|
return setSelectionInsideAtNodeStart(_types.RelativeSelectionPos.Before, node, from)(state, dispatch);
|
|
205
162
|
} else if ((0, _selection.isIgnored)(node) && selectionRelativeToNode === _types.RelativeSelectionPos.Start) {
|
|
206
163
|
// selection is for node without gap cursor preceeded by another node without gap cursor - set node selection for previous node
|
|
207
|
-
var
|
|
208
|
-
if (
|
|
209
|
-
return setSelectionRelativeToNode(_types.RelativeSelectionPos.End, _state.NodeSelection.create(state.doc,
|
|
164
|
+
var selectableNode = (0, _utils2.findSelectableContainerBefore)($from, state.doc);
|
|
165
|
+
if (selectableNode && (0, _selection.isIgnored)(selectableNode.node)) {
|
|
166
|
+
return setSelectionRelativeToNode(_types.RelativeSelectionPos.End, _state.NodeSelection.create(state.doc, selectableNode.pos))(state, dispatch);
|
|
210
167
|
}
|
|
211
168
|
}
|
|
212
169
|
return false;
|
|
@@ -237,9 +194,9 @@ var arrowLeftFromText = function arrowLeftFromText(selection) {
|
|
|
237
194
|
// from responding to arrow left key
|
|
238
195
|
setSelectionRelativeToNode(undefined)(state, dispatch);
|
|
239
196
|
} else if ((0, _utils2.isSelectionAtStartOfParentNode)(selection.$from, selection)) {
|
|
240
|
-
var
|
|
241
|
-
if (
|
|
242
|
-
return setSelectionRelativeToNode(_types.RelativeSelectionPos.Start, _state.NodeSelection.create(state.doc,
|
|
197
|
+
var _selectableNode4 = (0, _utils2.findSelectableContainerParent)(selection);
|
|
198
|
+
if (_selectableNode4) {
|
|
199
|
+
return setSelectionRelativeToNode(_types.RelativeSelectionPos.Start, _state.NodeSelection.create(state.doc, _selectableNode4.pos))(state, dispatch);
|
|
243
200
|
}
|
|
244
201
|
}
|
|
245
202
|
return false;
|
|
@@ -260,36 +217,19 @@ var setSelectionInsideAtNodeStart = function setSelectionInsideAtNodeStart(selec
|
|
|
260
217
|
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(pos), _types.SelectionDirection.After)(state, dispatch);
|
|
261
218
|
}
|
|
262
219
|
var selectableNode = (0, _utils2.findFirstChildNodeToSelect)(node);
|
|
263
|
-
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.change-navigation-for-atom-nodes')) {
|
|
264
|
-
if (selectableNode) {
|
|
265
|
-
var childNode = selectableNode.node,
|
|
266
|
-
childPos = selectableNode.pos;
|
|
267
|
-
var selectionPos = pos + childPos + 1;
|
|
268
|
-
if (childNode.isText || childNode.isAtom && (0, _selection.isIgnored)(childNode) || childNode.isInline) {
|
|
269
|
-
//selection is for text node, inline node or atom node which is ignored by gap-cursor. set selection before it.
|
|
270
|
-
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(selectionPos), _types.SelectionDirection.Before)(state, dispatch);
|
|
271
|
-
} else if ((0, _utils.isEmptyParagraph)(childNode)) {
|
|
272
|
-
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(selectionPos + 1), _types.SelectionDirection.Before)(state, dispatch);
|
|
273
|
-
} else if (!(0, _selection.isIgnored)(node)) {
|
|
274
|
-
return setSelectionRelativeToNode(selectionRelativeToNode, new _gapCursorSelection.GapCursorSelection(state.doc.resolve(selectionPos), _gapCursorSelection.Side.LEFT))(state, dispatch);
|
|
275
|
-
} else if ((0, _utils2.isSelectableContainerNode)(node)) {
|
|
276
|
-
return setSelectionRelativeToNode(selectionRelativeToNode, _state.NodeSelection.create(state.doc, selectionPos))(state, dispatch);
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
return false;
|
|
280
|
-
}
|
|
281
220
|
if (selectableNode) {
|
|
282
|
-
var
|
|
283
|
-
|
|
284
|
-
var
|
|
285
|
-
if (
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
221
|
+
var childNode = selectableNode.node,
|
|
222
|
+
childPos = selectableNode.pos;
|
|
223
|
+
var selectionPos = pos + childPos + 1;
|
|
224
|
+
if (childNode.isText || childNode.isAtom && (0, _selection.isIgnored)(childNode) || childNode.isInline) {
|
|
225
|
+
//selection is for text node, inline node or atom node which is ignored by gap-cursor. set selection before it.
|
|
226
|
+
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(selectionPos), _types.SelectionDirection.Before)(state, dispatch);
|
|
227
|
+
} else if ((0, _utils.isEmptyParagraph)(childNode)) {
|
|
228
|
+
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(selectionPos + 1), _types.SelectionDirection.Before)(state, dispatch);
|
|
289
229
|
} else if (!(0, _selection.isIgnored)(node)) {
|
|
290
|
-
return setSelectionRelativeToNode(selectionRelativeToNode, new _gapCursorSelection.GapCursorSelection(state.doc.resolve(
|
|
230
|
+
return setSelectionRelativeToNode(selectionRelativeToNode, new _gapCursorSelection.GapCursorSelection(state.doc.resolve(selectionPos), _gapCursorSelection.Side.LEFT))(state, dispatch);
|
|
291
231
|
} else if ((0, _utils2.isSelectableContainerNode)(node)) {
|
|
292
|
-
return setSelectionRelativeToNode(selectionRelativeToNode, _state.NodeSelection.create(state.doc,
|
|
232
|
+
return setSelectionRelativeToNode(selectionRelativeToNode, _state.NodeSelection.create(state.doc, selectionPos))(state, dispatch);
|
|
293
233
|
}
|
|
294
234
|
}
|
|
295
235
|
return false;
|
|
@@ -301,36 +241,19 @@ var setSelectionInsideAtNodeEnd = exports.setSelectionInsideAtNodeEnd = function
|
|
|
301
241
|
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(to), _types.SelectionDirection.Before)(state, dispatch);
|
|
302
242
|
}
|
|
303
243
|
var selectableNode = (0, _utils2.findLastChildNodeToSelect)(node);
|
|
304
|
-
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.change-navigation-for-atom-nodes')) {
|
|
305
|
-
if (selectableNode) {
|
|
306
|
-
var childNode = selectableNode.node,
|
|
307
|
-
childPos = selectableNode.pos;
|
|
308
|
-
var selectionPos = from + childPos + childNode.nodeSize;
|
|
309
|
-
if (childNode.isText || childNode.isAtom && (0, _selection.isIgnored)(childNode) || childNode.isInline) {
|
|
310
|
-
//selection is for text node, inline node or atom node which is ignored by gap-cursor. set selection after it.
|
|
311
|
-
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(selectionPos + 1), _types.SelectionDirection.After)(state, dispatch);
|
|
312
|
-
} else if ((0, _utils.isEmptyParagraph)(childNode)) {
|
|
313
|
-
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(selectionPos), _types.SelectionDirection.After)(state, dispatch);
|
|
314
|
-
} else if (!(0, _selection.isIgnored)(node)) {
|
|
315
|
-
return setSelectionRelativeToNode(selectionRelativeToNode, new _gapCursorSelection.GapCursorSelection(state.doc.resolve(selectionPos + 1), _gapCursorSelection.Side.RIGHT))(state, dispatch);
|
|
316
|
-
} else if ((0, _utils2.isSelectableContainerNode)(node)) {
|
|
317
|
-
return setSelectionRelativeToNode(selectionRelativeToNode, _state.NodeSelection.create(state.doc, selectionPos))(state, dispatch);
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
return false;
|
|
321
|
-
}
|
|
322
244
|
if (selectableNode) {
|
|
323
|
-
var
|
|
324
|
-
|
|
325
|
-
var
|
|
326
|
-
if (
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
245
|
+
var childNode = selectableNode.node,
|
|
246
|
+
childPos = selectableNode.pos;
|
|
247
|
+
var selectionPos = from + childPos + childNode.nodeSize;
|
|
248
|
+
if (childNode.isText || childNode.isAtom && (0, _selection.isIgnored)(childNode) || childNode.isInline) {
|
|
249
|
+
//selection is for text node, inline node or atom node which is ignored by gap-cursor. set selection after it.
|
|
250
|
+
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(selectionPos + 1), _types.SelectionDirection.After)(state, dispatch);
|
|
251
|
+
} else if ((0, _utils.isEmptyParagraph)(childNode)) {
|
|
252
|
+
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(selectionPos), _types.SelectionDirection.After)(state, dispatch);
|
|
330
253
|
} else if (!(0, _selection.isIgnored)(node)) {
|
|
331
|
-
return setSelectionRelativeToNode(selectionRelativeToNode, new _gapCursorSelection.GapCursorSelection(state.doc.resolve(
|
|
254
|
+
return setSelectionRelativeToNode(selectionRelativeToNode, new _gapCursorSelection.GapCursorSelection(state.doc.resolve(selectionPos + 1), _gapCursorSelection.Side.RIGHT))(state, dispatch);
|
|
332
255
|
} else if ((0, _utils2.isSelectableContainerNode)(node)) {
|
|
333
|
-
return setSelectionRelativeToNode(selectionRelativeToNode, _state.NodeSelection.create(state.doc,
|
|
256
|
+
return setSelectionRelativeToNode(selectionRelativeToNode, _state.NodeSelection.create(state.doc, selectionPos))(state, dispatch);
|
|
334
257
|
}
|
|
335
258
|
}
|
|
336
259
|
return false;
|
package/dist/es2019/commands.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import { isIgnored as isIgnoredByGapCursor } 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 { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
6
5
|
import { SelectionActionTypes } from './actions';
|
|
7
6
|
import { GapCursorSelection, Side } from './gap-cursor-selection';
|
|
8
7
|
import { createCommand, getPluginState } from './plugin-factory';
|
|
@@ -117,28 +116,9 @@ const arrowRightFromNode = selection => (state, dispatch) => {
|
|
|
117
116
|
const {
|
|
118
117
|
selectionRelativeToNode
|
|
119
118
|
} = getPluginState(state);
|
|
120
|
-
if (getBooleanFF('platform.editor.change-navigation-for-atom-nodes')) {
|
|
121
|
-
if (node.isAtom) {
|
|
122
|
-
if (isSelectionAtEndOfParentNode($to, selection) && (node.isInline || isIgnoredByGapCursor(node))) {
|
|
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
|
|
124
|
-
return findAndSetTextSelection(RelativeSelectionPos.End, state.doc.resolve(from + 1), SelectionDirection.After)(state, dispatch);
|
|
125
|
-
}
|
|
126
|
-
return false;
|
|
127
|
-
} else if (selectionRelativeToNode === RelativeSelectionPos.Start) {
|
|
128
|
-
// selection is for container node - set selection inside it at the start
|
|
129
|
-
return setSelectionInsideAtNodeStart(RelativeSelectionPos.Inside, node, from)(state, dispatch);
|
|
130
|
-
} else if (isIgnoredByGapCursor(node) && (!selectionRelativeToNode || selectionRelativeToNode === RelativeSelectionPos.End)) {
|
|
131
|
-
const selectableNode = findSelectableContainerAfter($to, state.doc);
|
|
132
|
-
if (selectableNode && isIgnoredByGapCursor(selectableNode.node)) {
|
|
133
|
-
// selection is for node without gap cursor followed by another node without gap cursor - set node selection for next node
|
|
134
|
-
return setSelectionRelativeToNode(RelativeSelectionPos.Start, NodeSelection.create(state.doc, selectableNode.pos))(state, dispatch);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
return false;
|
|
138
|
-
}
|
|
139
119
|
if (node.isAtom) {
|
|
140
|
-
if (isSelectionAtEndOfParentNode($to, selection)) {
|
|
141
|
-
// selection is for inline node that is the last child of its parent node - set text selection after it
|
|
120
|
+
if (isSelectionAtEndOfParentNode($to, selection) && (node.isInline || isIgnoredByGapCursor(node))) {
|
|
121
|
+
// 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
|
|
142
122
|
return findAndSetTextSelection(RelativeSelectionPos.End, state.doc.resolve(from + 1), SelectionDirection.After)(state, dispatch);
|
|
143
123
|
}
|
|
144
124
|
return false;
|
|
@@ -164,32 +144,9 @@ const arrowLeftFromNode = selection => (state, dispatch) => {
|
|
|
164
144
|
const {
|
|
165
145
|
selectionRelativeToNode
|
|
166
146
|
} = getPluginState(state);
|
|
167
|
-
if (getBooleanFF('platform.editor.change-navigation-for-atom-nodes')) {
|
|
168
|
-
if (node.isAtom) {
|
|
169
|
-
if (isSelectionAtStartOfParentNode($from, selection) && (node.isInline || isIgnoredByGapCursor(node))) {
|
|
170
|
-
// 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
|
|
171
|
-
return findAndSetTextSelection(RelativeSelectionPos.Start, state.doc.resolve(from), SelectionDirection.Before)(state, dispatch);
|
|
172
|
-
}
|
|
173
|
-
return false;
|
|
174
|
-
} else if (selectionRelativeToNode === RelativeSelectionPos.End) {
|
|
175
|
-
// selection is for container node - set selection inside it at the end
|
|
176
|
-
return setSelectionInsideAtNodeEnd(RelativeSelectionPos.Inside, node, from, to)(state, dispatch);
|
|
177
|
-
} else if (!selectionRelativeToNode || selectionRelativeToNode === RelativeSelectionPos.Inside) {
|
|
178
|
-
// selection is for container node - set selection inside it at the start
|
|
179
|
-
// (this is a special case when the user selects by clicking node)
|
|
180
|
-
return setSelectionInsideAtNodeStart(RelativeSelectionPos.Before, node, from)(state, dispatch);
|
|
181
|
-
} else if (isIgnoredByGapCursor(node) && selectionRelativeToNode === RelativeSelectionPos.Start) {
|
|
182
|
-
// selection is for node without gap cursor preceeded by another node without gap cursor - set node selection for previous node
|
|
183
|
-
const selectableNode = findSelectableContainerBefore($from, state.doc);
|
|
184
|
-
if (selectableNode && isIgnoredByGapCursor(selectableNode.node)) {
|
|
185
|
-
return setSelectionRelativeToNode(RelativeSelectionPos.End, NodeSelection.create(state.doc, selectableNode.pos))(state, dispatch);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
return false;
|
|
189
|
-
}
|
|
190
147
|
if (node.isAtom) {
|
|
191
|
-
if (isSelectionAtStartOfParentNode($from, selection)) {
|
|
192
|
-
// selection is for inline node that is the first child of its parent node - set text selection before it
|
|
148
|
+
if (isSelectionAtStartOfParentNode($from, selection) && (node.isInline || isIgnoredByGapCursor(node))) {
|
|
149
|
+
// 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
|
|
193
150
|
return findAndSetTextSelection(RelativeSelectionPos.Start, state.doc.resolve(from), SelectionDirection.Before)(state, dispatch);
|
|
194
151
|
}
|
|
195
152
|
return false;
|
|
@@ -251,33 +208,14 @@ const setSelectionInsideAtNodeStart = (selectionRelativeToNode, node, pos) => (s
|
|
|
251
208
|
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(pos), SelectionDirection.After)(state, dispatch);
|
|
252
209
|
}
|
|
253
210
|
const selectableNode = findFirstChildNodeToSelect(node);
|
|
254
|
-
if (getBooleanFF('platform.editor.change-navigation-for-atom-nodes')) {
|
|
255
|
-
if (selectableNode) {
|
|
256
|
-
const {
|
|
257
|
-
node: childNode,
|
|
258
|
-
pos: childPos
|
|
259
|
-
} = selectableNode;
|
|
260
|
-
const selectionPos = pos + childPos + 1;
|
|
261
|
-
if (childNode.isText || childNode.isAtom && isIgnoredByGapCursor(childNode) || childNode.isInline) {
|
|
262
|
-
//selection is for text node, inline node or atom node which is ignored by gap-cursor. set selection before it.
|
|
263
|
-
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(selectionPos), SelectionDirection.Before)(state, dispatch);
|
|
264
|
-
} else if (isEmptyParagraph(childNode)) {
|
|
265
|
-
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(selectionPos + 1), SelectionDirection.Before)(state, dispatch);
|
|
266
|
-
} else if (!isIgnoredByGapCursor(node)) {
|
|
267
|
-
return setSelectionRelativeToNode(selectionRelativeToNode, new GapCursorSelection(state.doc.resolve(selectionPos), Side.LEFT))(state, dispatch);
|
|
268
|
-
} else if (isSelectableContainerNode(node)) {
|
|
269
|
-
return setSelectionRelativeToNode(selectionRelativeToNode, NodeSelection.create(state.doc, selectionPos))(state, dispatch);
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
return false;
|
|
273
|
-
}
|
|
274
211
|
if (selectableNode) {
|
|
275
212
|
const {
|
|
276
213
|
node: childNode,
|
|
277
214
|
pos: childPos
|
|
278
215
|
} = selectableNode;
|
|
279
216
|
const selectionPos = pos + childPos + 1;
|
|
280
|
-
if (childNode.isText || childNode.isAtom) {
|
|
217
|
+
if (childNode.isText || childNode.isAtom && isIgnoredByGapCursor(childNode) || childNode.isInline) {
|
|
218
|
+
//selection is for text node, inline node or atom node which is ignored by gap-cursor. set selection before it.
|
|
281
219
|
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(selectionPos), SelectionDirection.Before)(state, dispatch);
|
|
282
220
|
} else if (isEmptyParagraph(childNode)) {
|
|
283
221
|
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(selectionPos + 1), SelectionDirection.Before)(state, dispatch);
|
|
@@ -294,33 +232,14 @@ export const setSelectionInsideAtNodeEnd = (selectionRelativeToNode, node, from,
|
|
|
294
232
|
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(to), SelectionDirection.Before)(state, dispatch);
|
|
295
233
|
}
|
|
296
234
|
const selectableNode = findLastChildNodeToSelect(node);
|
|
297
|
-
if (getBooleanFF('platform.editor.change-navigation-for-atom-nodes')) {
|
|
298
|
-
if (selectableNode) {
|
|
299
|
-
const {
|
|
300
|
-
node: childNode,
|
|
301
|
-
pos: childPos
|
|
302
|
-
} = selectableNode;
|
|
303
|
-
const selectionPos = from + childPos + childNode.nodeSize;
|
|
304
|
-
if (childNode.isText || childNode.isAtom && isIgnoredByGapCursor(childNode) || childNode.isInline) {
|
|
305
|
-
//selection is for text node, inline node or atom node which is ignored by gap-cursor. set selection after it.
|
|
306
|
-
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(selectionPos + 1), SelectionDirection.After)(state, dispatch);
|
|
307
|
-
} else if (isEmptyParagraph(childNode)) {
|
|
308
|
-
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(selectionPos), SelectionDirection.After)(state, dispatch);
|
|
309
|
-
} else if (!isIgnoredByGapCursor(node)) {
|
|
310
|
-
return setSelectionRelativeToNode(selectionRelativeToNode, new GapCursorSelection(state.doc.resolve(selectionPos + 1), Side.RIGHT))(state, dispatch);
|
|
311
|
-
} else if (isSelectableContainerNode(node)) {
|
|
312
|
-
return setSelectionRelativeToNode(selectionRelativeToNode, NodeSelection.create(state.doc, selectionPos))(state, dispatch);
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
return false;
|
|
316
|
-
}
|
|
317
235
|
if (selectableNode) {
|
|
318
236
|
const {
|
|
319
237
|
node: childNode,
|
|
320
238
|
pos: childPos
|
|
321
239
|
} = selectableNode;
|
|
322
240
|
const selectionPos = from + childPos + childNode.nodeSize;
|
|
323
|
-
if (childNode.isText || childNode.isAtom) {
|
|
241
|
+
if (childNode.isText || childNode.isAtom && isIgnoredByGapCursor(childNode) || childNode.isInline) {
|
|
242
|
+
//selection is for text node, inline node or atom node which is ignored by gap-cursor. set selection after it.
|
|
324
243
|
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(selectionPos + 1), SelectionDirection.After)(state, dispatch);
|
|
325
244
|
} else if (isEmptyParagraph(childNode)) {
|
|
326
245
|
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(selectionPos), SelectionDirection.After)(state, dispatch);
|
package/dist/esm/commands.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import { isIgnored as isIgnoredByGapCursor } 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 { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
6
5
|
import { SelectionActionTypes } from './actions';
|
|
7
6
|
import { GapCursorSelection, Side } from './gap-cursor-selection';
|
|
8
7
|
import { createCommand, getPluginState } from './plugin-factory';
|
|
@@ -113,28 +112,9 @@ var arrowRightFromNode = function arrowRightFromNode(selection) {
|
|
|
113
112
|
$to = selection.$to;
|
|
114
113
|
var _getPluginState2 = getPluginState(state),
|
|
115
114
|
selectionRelativeToNode = _getPluginState2.selectionRelativeToNode;
|
|
116
|
-
if (getBooleanFF('platform.editor.change-navigation-for-atom-nodes')) {
|
|
117
|
-
if (node.isAtom) {
|
|
118
|
-
if (isSelectionAtEndOfParentNode($to, selection) && (node.isInline || isIgnoredByGapCursor(node))) {
|
|
119
|
-
// 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
|
|
120
|
-
return findAndSetTextSelection(RelativeSelectionPos.End, state.doc.resolve(from + 1), SelectionDirection.After)(state, dispatch);
|
|
121
|
-
}
|
|
122
|
-
return false;
|
|
123
|
-
} else if (selectionRelativeToNode === RelativeSelectionPos.Start) {
|
|
124
|
-
// selection is for container node - set selection inside it at the start
|
|
125
|
-
return setSelectionInsideAtNodeStart(RelativeSelectionPos.Inside, node, from)(state, dispatch);
|
|
126
|
-
} else if (isIgnoredByGapCursor(node) && (!selectionRelativeToNode || selectionRelativeToNode === RelativeSelectionPos.End)) {
|
|
127
|
-
var selectableNode = findSelectableContainerAfter($to, state.doc);
|
|
128
|
-
if (selectableNode && isIgnoredByGapCursor(selectableNode.node)) {
|
|
129
|
-
// selection is for node without gap cursor followed by another node without gap cursor - set node selection for next node
|
|
130
|
-
return setSelectionRelativeToNode(RelativeSelectionPos.Start, NodeSelection.create(state.doc, selectableNode.pos))(state, dispatch);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
return false;
|
|
134
|
-
}
|
|
135
115
|
if (node.isAtom) {
|
|
136
|
-
if (isSelectionAtEndOfParentNode($to, selection)) {
|
|
137
|
-
// selection is for inline node that is the last child of its parent node - set text selection after it
|
|
116
|
+
if (isSelectionAtEndOfParentNode($to, selection) && (node.isInline || isIgnoredByGapCursor(node))) {
|
|
117
|
+
// 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
|
|
138
118
|
return findAndSetTextSelection(RelativeSelectionPos.End, state.doc.resolve(from + 1), SelectionDirection.After)(state, dispatch);
|
|
139
119
|
}
|
|
140
120
|
return false;
|
|
@@ -142,10 +122,10 @@ var arrowRightFromNode = function arrowRightFromNode(selection) {
|
|
|
142
122
|
// selection is for container node - set selection inside it at the start
|
|
143
123
|
return setSelectionInsideAtNodeStart(RelativeSelectionPos.Inside, node, from)(state, dispatch);
|
|
144
124
|
} else if (isIgnoredByGapCursor(node) && (!selectionRelativeToNode || selectionRelativeToNode === RelativeSelectionPos.End)) {
|
|
145
|
-
var
|
|
146
|
-
if (
|
|
125
|
+
var selectableNode = findSelectableContainerAfter($to, state.doc);
|
|
126
|
+
if (selectableNode && isIgnoredByGapCursor(selectableNode.node)) {
|
|
147
127
|
// selection is for node without gap cursor followed by another node without gap cursor - set node selection for next node
|
|
148
|
-
return setSelectionRelativeToNode(RelativeSelectionPos.Start, NodeSelection.create(state.doc,
|
|
128
|
+
return setSelectionRelativeToNode(RelativeSelectionPos.Start, NodeSelection.create(state.doc, selectableNode.pos))(state, dispatch);
|
|
149
129
|
}
|
|
150
130
|
}
|
|
151
131
|
return false;
|
|
@@ -159,32 +139,9 @@ var arrowLeftFromNode = function arrowLeftFromNode(selection) {
|
|
|
159
139
|
$from = selection.$from;
|
|
160
140
|
var _getPluginState3 = getPluginState(state),
|
|
161
141
|
selectionRelativeToNode = _getPluginState3.selectionRelativeToNode;
|
|
162
|
-
if (getBooleanFF('platform.editor.change-navigation-for-atom-nodes')) {
|
|
163
|
-
if (node.isAtom) {
|
|
164
|
-
if (isSelectionAtStartOfParentNode($from, selection) && (node.isInline || isIgnoredByGapCursor(node))) {
|
|
165
|
-
// 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
|
|
166
|
-
return findAndSetTextSelection(RelativeSelectionPos.Start, state.doc.resolve(from), SelectionDirection.Before)(state, dispatch);
|
|
167
|
-
}
|
|
168
|
-
return false;
|
|
169
|
-
} else if (selectionRelativeToNode === RelativeSelectionPos.End) {
|
|
170
|
-
// selection is for container node - set selection inside it at the end
|
|
171
|
-
return setSelectionInsideAtNodeEnd(RelativeSelectionPos.Inside, node, from, to)(state, dispatch);
|
|
172
|
-
} else if (!selectionRelativeToNode || selectionRelativeToNode === RelativeSelectionPos.Inside) {
|
|
173
|
-
// selection is for container node - set selection inside it at the start
|
|
174
|
-
// (this is a special case when the user selects by clicking node)
|
|
175
|
-
return setSelectionInsideAtNodeStart(RelativeSelectionPos.Before, node, from)(state, dispatch);
|
|
176
|
-
} else if (isIgnoredByGapCursor(node) && selectionRelativeToNode === RelativeSelectionPos.Start) {
|
|
177
|
-
// selection is for node without gap cursor preceeded by another node without gap cursor - set node selection for previous node
|
|
178
|
-
var selectableNode = findSelectableContainerBefore($from, state.doc);
|
|
179
|
-
if (selectableNode && isIgnoredByGapCursor(selectableNode.node)) {
|
|
180
|
-
return setSelectionRelativeToNode(RelativeSelectionPos.End, NodeSelection.create(state.doc, selectableNode.pos))(state, dispatch);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
return false;
|
|
184
|
-
}
|
|
185
142
|
if (node.isAtom) {
|
|
186
|
-
if (isSelectionAtStartOfParentNode($from, selection)) {
|
|
187
|
-
// selection is for inline node that is the first child of its parent node - set text selection before it
|
|
143
|
+
if (isSelectionAtStartOfParentNode($from, selection) && (node.isInline || isIgnoredByGapCursor(node))) {
|
|
144
|
+
// 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
|
|
188
145
|
return findAndSetTextSelection(RelativeSelectionPos.Start, state.doc.resolve(from), SelectionDirection.Before)(state, dispatch);
|
|
189
146
|
}
|
|
190
147
|
return false;
|
|
@@ -197,9 +154,9 @@ var arrowLeftFromNode = function arrowLeftFromNode(selection) {
|
|
|
197
154
|
return setSelectionInsideAtNodeStart(RelativeSelectionPos.Before, node, from)(state, dispatch);
|
|
198
155
|
} else if (isIgnoredByGapCursor(node) && selectionRelativeToNode === RelativeSelectionPos.Start) {
|
|
199
156
|
// selection is for node without gap cursor preceeded by another node without gap cursor - set node selection for previous node
|
|
200
|
-
var
|
|
201
|
-
if (
|
|
202
|
-
return setSelectionRelativeToNode(RelativeSelectionPos.End, NodeSelection.create(state.doc,
|
|
157
|
+
var selectableNode = findSelectableContainerBefore($from, state.doc);
|
|
158
|
+
if (selectableNode && isIgnoredByGapCursor(selectableNode.node)) {
|
|
159
|
+
return setSelectionRelativeToNode(RelativeSelectionPos.End, NodeSelection.create(state.doc, selectableNode.pos))(state, dispatch);
|
|
203
160
|
}
|
|
204
161
|
}
|
|
205
162
|
return false;
|
|
@@ -230,9 +187,9 @@ var arrowLeftFromText = function arrowLeftFromText(selection) {
|
|
|
230
187
|
// from responding to arrow left key
|
|
231
188
|
setSelectionRelativeToNode(undefined)(state, dispatch);
|
|
232
189
|
} else if (isSelectionAtStartOfParentNode(selection.$from, selection)) {
|
|
233
|
-
var
|
|
234
|
-
if (
|
|
235
|
-
return setSelectionRelativeToNode(RelativeSelectionPos.Start, NodeSelection.create(state.doc,
|
|
190
|
+
var _selectableNode4 = findSelectableContainerParent(selection);
|
|
191
|
+
if (_selectableNode4) {
|
|
192
|
+
return setSelectionRelativeToNode(RelativeSelectionPos.Start, NodeSelection.create(state.doc, _selectableNode4.pos))(state, dispatch);
|
|
236
193
|
}
|
|
237
194
|
}
|
|
238
195
|
return false;
|
|
@@ -253,36 +210,19 @@ var setSelectionInsideAtNodeStart = function setSelectionInsideAtNodeStart(selec
|
|
|
253
210
|
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(pos), SelectionDirection.After)(state, dispatch);
|
|
254
211
|
}
|
|
255
212
|
var selectableNode = findFirstChildNodeToSelect(node);
|
|
256
|
-
if (getBooleanFF('platform.editor.change-navigation-for-atom-nodes')) {
|
|
257
|
-
if (selectableNode) {
|
|
258
|
-
var childNode = selectableNode.node,
|
|
259
|
-
childPos = selectableNode.pos;
|
|
260
|
-
var selectionPos = pos + childPos + 1;
|
|
261
|
-
if (childNode.isText || childNode.isAtom && isIgnoredByGapCursor(childNode) || childNode.isInline) {
|
|
262
|
-
//selection is for text node, inline node or atom node which is ignored by gap-cursor. set selection before it.
|
|
263
|
-
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(selectionPos), SelectionDirection.Before)(state, dispatch);
|
|
264
|
-
} else if (isEmptyParagraph(childNode)) {
|
|
265
|
-
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(selectionPos + 1), SelectionDirection.Before)(state, dispatch);
|
|
266
|
-
} else if (!isIgnoredByGapCursor(node)) {
|
|
267
|
-
return setSelectionRelativeToNode(selectionRelativeToNode, new GapCursorSelection(state.doc.resolve(selectionPos), Side.LEFT))(state, dispatch);
|
|
268
|
-
} else if (isSelectableContainerNode(node)) {
|
|
269
|
-
return setSelectionRelativeToNode(selectionRelativeToNode, NodeSelection.create(state.doc, selectionPos))(state, dispatch);
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
return false;
|
|
273
|
-
}
|
|
274
213
|
if (selectableNode) {
|
|
275
|
-
var
|
|
276
|
-
|
|
277
|
-
var
|
|
278
|
-
if (
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
214
|
+
var childNode = selectableNode.node,
|
|
215
|
+
childPos = selectableNode.pos;
|
|
216
|
+
var selectionPos = pos + childPos + 1;
|
|
217
|
+
if (childNode.isText || childNode.isAtom && isIgnoredByGapCursor(childNode) || childNode.isInline) {
|
|
218
|
+
//selection is for text node, inline node or atom node which is ignored by gap-cursor. set selection before it.
|
|
219
|
+
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(selectionPos), SelectionDirection.Before)(state, dispatch);
|
|
220
|
+
} else if (isEmptyParagraph(childNode)) {
|
|
221
|
+
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(selectionPos + 1), SelectionDirection.Before)(state, dispatch);
|
|
282
222
|
} else if (!isIgnoredByGapCursor(node)) {
|
|
283
|
-
return setSelectionRelativeToNode(selectionRelativeToNode, new GapCursorSelection(state.doc.resolve(
|
|
223
|
+
return setSelectionRelativeToNode(selectionRelativeToNode, new GapCursorSelection(state.doc.resolve(selectionPos), Side.LEFT))(state, dispatch);
|
|
284
224
|
} else if (isSelectableContainerNode(node)) {
|
|
285
|
-
return setSelectionRelativeToNode(selectionRelativeToNode, NodeSelection.create(state.doc,
|
|
225
|
+
return setSelectionRelativeToNode(selectionRelativeToNode, NodeSelection.create(state.doc, selectionPos))(state, dispatch);
|
|
286
226
|
}
|
|
287
227
|
}
|
|
288
228
|
return false;
|
|
@@ -294,36 +234,19 @@ export var setSelectionInsideAtNodeEnd = function setSelectionInsideAtNodeEnd(se
|
|
|
294
234
|
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(to), SelectionDirection.Before)(state, dispatch);
|
|
295
235
|
}
|
|
296
236
|
var selectableNode = findLastChildNodeToSelect(node);
|
|
297
|
-
if (getBooleanFF('platform.editor.change-navigation-for-atom-nodes')) {
|
|
298
|
-
if (selectableNode) {
|
|
299
|
-
var childNode = selectableNode.node,
|
|
300
|
-
childPos = selectableNode.pos;
|
|
301
|
-
var selectionPos = from + childPos + childNode.nodeSize;
|
|
302
|
-
if (childNode.isText || childNode.isAtom && isIgnoredByGapCursor(childNode) || childNode.isInline) {
|
|
303
|
-
//selection is for text node, inline node or atom node which is ignored by gap-cursor. set selection after it.
|
|
304
|
-
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(selectionPos + 1), SelectionDirection.After)(state, dispatch);
|
|
305
|
-
} else if (isEmptyParagraph(childNode)) {
|
|
306
|
-
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(selectionPos), SelectionDirection.After)(state, dispatch);
|
|
307
|
-
} else if (!isIgnoredByGapCursor(node)) {
|
|
308
|
-
return setSelectionRelativeToNode(selectionRelativeToNode, new GapCursorSelection(state.doc.resolve(selectionPos + 1), Side.RIGHT))(state, dispatch);
|
|
309
|
-
} else if (isSelectableContainerNode(node)) {
|
|
310
|
-
return setSelectionRelativeToNode(selectionRelativeToNode, NodeSelection.create(state.doc, selectionPos))(state, dispatch);
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
return false;
|
|
314
|
-
}
|
|
315
237
|
if (selectableNode) {
|
|
316
|
-
var
|
|
317
|
-
|
|
318
|
-
var
|
|
319
|
-
if (
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
238
|
+
var childNode = selectableNode.node,
|
|
239
|
+
childPos = selectableNode.pos;
|
|
240
|
+
var selectionPos = from + childPos + childNode.nodeSize;
|
|
241
|
+
if (childNode.isText || childNode.isAtom && isIgnoredByGapCursor(childNode) || childNode.isInline) {
|
|
242
|
+
//selection is for text node, inline node or atom node which is ignored by gap-cursor. set selection after it.
|
|
243
|
+
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(selectionPos + 1), SelectionDirection.After)(state, dispatch);
|
|
244
|
+
} else if (isEmptyParagraph(childNode)) {
|
|
245
|
+
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(selectionPos), SelectionDirection.After)(state, dispatch);
|
|
323
246
|
} else if (!isIgnoredByGapCursor(node)) {
|
|
324
|
-
return setSelectionRelativeToNode(selectionRelativeToNode, new GapCursorSelection(state.doc.resolve(
|
|
247
|
+
return setSelectionRelativeToNode(selectionRelativeToNode, new GapCursorSelection(state.doc.resolve(selectionPos + 1), Side.RIGHT))(state, dispatch);
|
|
325
248
|
} else if (isSelectableContainerNode(node)) {
|
|
326
|
-
return setSelectionRelativeToNode(selectionRelativeToNode, NodeSelection.create(state.doc,
|
|
249
|
+
return setSelectionRelativeToNode(selectionRelativeToNode, NodeSelection.create(state.doc, selectionPos))(state, dispatch);
|
|
327
250
|
}
|
|
328
251
|
}
|
|
329
252
|
return false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-selection",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "Selection plugin for @atlaskit/editor-core",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -77,9 +77,6 @@
|
|
|
77
77
|
}
|
|
78
78
|
},
|
|
79
79
|
"platform-feature-flags": {
|
|
80
|
-
"platform.editor.change-navigation-for-atom-nodes": {
|
|
81
|
-
"type": "boolean"
|
|
82
|
-
},
|
|
83
80
|
"platform.editor.single-player-expand": {
|
|
84
81
|
"type": "boolean"
|
|
85
82
|
}
|