@atlaskit/editor-plugin-selection 1.6.4 → 1.6.5
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 +6 -0
- package/dist/cjs/pm-plugins/commands.js +30 -31
- package/dist/cjs/pm-plugins/gap-cursor/actions.js +21 -23
- package/dist/cjs/pm-plugins/gap-cursor/utils.js +1 -1
- package/dist/cjs/pm-plugins/gap-cursor-keymap.js +1 -1
- package/dist/cjs/pm-plugins/utils.js +0 -6
- package/dist/cjs/types/index.js +3 -0
- package/dist/es2019/pm-plugins/commands.js +2 -3
- package/dist/es2019/pm-plugins/gap-cursor/actions.js +1 -3
- package/dist/es2019/pm-plugins/gap-cursor/utils.js +1 -1
- package/dist/es2019/pm-plugins/gap-cursor-keymap.js +1 -1
- package/dist/es2019/pm-plugins/utils.js +2 -3
- package/dist/es2019/types/index.js +3 -0
- package/dist/esm/pm-plugins/commands.js +2 -3
- package/dist/esm/pm-plugins/gap-cursor/actions.js +1 -3
- package/dist/esm/pm-plugins/gap-cursor/utils.js +1 -1
- package/dist/esm/pm-plugins/gap-cursor-keymap.js +1 -1
- package/dist/esm/pm-plugins/utils.js +2 -3
- package/dist/esm/types/index.js +3 -0
- package/dist/types/pm-plugins/actions.d.ts +1 -1
- package/dist/types/pm-plugins/commands.d.ts +1 -1
- package/dist/types/pm-plugins/gap-cursor/utils.d.ts +1 -1
- package/dist/types/pm-plugins/plugin-factory.d.ts +1 -1
- package/dist/types/pm-plugins/reducer.d.ts +1 -1
- package/dist/types/pm-plugins/selection-main.d.ts +2 -1
- package/dist/types/pm-plugins/utils.d.ts +0 -2
- package/dist/types-ts4.5/pm-plugins/actions.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/commands.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/gap-cursor/utils.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/plugin-factory.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/reducer.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/selection-main.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/utils.d.ts +0 -2
- package/package.json +3 -3
- package/dist/cjs/pm-plugins/gap-cursor/selection.js +0 -30
- package/dist/cjs/pm-plugins/gap-cursor/utils/is-ignored.js +0 -12
- package/dist/cjs/pm-plugins/gap-cursor/utils/is-valid-target-node.js +0 -12
- package/dist/cjs/pm-plugins/gap-cursor-selection.js +0 -37
- package/dist/es2019/pm-plugins/gap-cursor/selection.js +0 -1
- package/dist/es2019/pm-plugins/gap-cursor/utils/is-ignored.js +0 -1
- package/dist/es2019/pm-plugins/gap-cursor/utils/is-valid-target-node.js +0 -1
- package/dist/es2019/pm-plugins/gap-cursor-selection.js +0 -2
- package/dist/esm/pm-plugins/gap-cursor/selection.js +0 -1
- package/dist/esm/pm-plugins/gap-cursor/utils/is-ignored.js +0 -1
- package/dist/esm/pm-plugins/gap-cursor/utils/is-valid-target-node.js +0 -1
- package/dist/esm/pm-plugins/gap-cursor-selection.js +0 -2
- package/dist/types/pm-plugins/gap-cursor/selection.d.ts +0 -1
- package/dist/types/pm-plugins/gap-cursor/utils/is-ignored.d.ts +0 -1
- package/dist/types/pm-plugins/gap-cursor/utils/is-valid-target-node.d.ts +0 -1
- package/dist/types/pm-plugins/gap-cursor-selection.d.ts +0 -2
- package/dist/types-ts4.5/pm-plugins/gap-cursor/selection.d.ts +0 -1
- package/dist/types-ts4.5/pm-plugins/gap-cursor/utils/is-ignored.d.ts +0 -1
- package/dist/types-ts4.5/pm-plugins/gap-cursor/utils/is-valid-target-node.d.ts +0 -1
- package/dist/types-ts4.5/pm-plugins/gap-cursor-selection.d.ts +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -9,7 +9,6 @@ var _utils = require("@atlaskit/editor-common/utils");
|
|
|
9
9
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
10
10
|
var _types = require("../types");
|
|
11
11
|
var _actions = require("./actions");
|
|
12
|
-
var _gapCursorSelection = require("./gap-cursor-selection");
|
|
13
12
|
var _pluginFactory = require("./plugin-factory");
|
|
14
13
|
var _utils2 = require("./utils");
|
|
15
14
|
/* eslint-disable import/no-extraneous-dependencies */
|
|
@@ -39,7 +38,7 @@ var setSelectionRelativeToNode = exports.setSelectionRelativeToNode = function s
|
|
|
39
38
|
};
|
|
40
39
|
var arrowRight = exports.arrowRight = function arrowRight(state, dispatch) {
|
|
41
40
|
var selection = state.selection;
|
|
42
|
-
if (selection instanceof
|
|
41
|
+
if (selection instanceof _selection.GapCursorSelection) {
|
|
43
42
|
return arrowRightFromGapCursor(selection)(state, dispatch);
|
|
44
43
|
} else if (selection instanceof _state.NodeSelection) {
|
|
45
44
|
return arrowRightFromNode(selection)(state, dispatch);
|
|
@@ -50,7 +49,7 @@ var arrowRight = exports.arrowRight = function arrowRight(state, dispatch) {
|
|
|
50
49
|
};
|
|
51
50
|
var arrowLeft = exports.arrowLeft = function arrowLeft(state, dispatch) {
|
|
52
51
|
var selection = state.selection;
|
|
53
|
-
if (selection instanceof
|
|
52
|
+
if (selection instanceof _selection.GapCursorSelection) {
|
|
54
53
|
return arrowLeftFromGapCursor(selection)(state, dispatch);
|
|
55
54
|
} else if (selection instanceof _state.NodeSelection) {
|
|
56
55
|
return arrowLeftFromNode(selection)(state, dispatch);
|
|
@@ -64,15 +63,15 @@ var arrowRightFromGapCursor = function arrowRightFromGapCursor(selection) {
|
|
|
64
63
|
var $from = selection.$from,
|
|
65
64
|
$to = selection.$to,
|
|
66
65
|
side = selection.side;
|
|
67
|
-
if (side ===
|
|
66
|
+
if (side === _selection.Side.LEFT) {
|
|
68
67
|
var selectableNode = (0, _utils2.findSelectableContainerAfter)($to, state.doc);
|
|
69
68
|
if (selectableNode) {
|
|
70
|
-
return setSelectionRelativeToNode(
|
|
69
|
+
return setSelectionRelativeToNode(_selection.RelativeSelectionPos.Start, _state.NodeSelection.create(state.doc, selectableNode.pos))(state, dispatch);
|
|
71
70
|
}
|
|
72
|
-
} else if (side ===
|
|
71
|
+
} else if (side === _selection.Side.RIGHT && (0, _utils2.isSelectionAtEndOfParentNode)($from, selection)) {
|
|
73
72
|
var _selectableNode = (0, _utils2.findSelectableContainerParent)(selection);
|
|
74
73
|
if (_selectableNode) {
|
|
75
|
-
return setSelectionRelativeToNode(
|
|
74
|
+
return setSelectionRelativeToNode(_selection.RelativeSelectionPos.End, _state.NodeSelection.create(state.doc, _selectableNode.pos))(state, dispatch);
|
|
76
75
|
}
|
|
77
76
|
}
|
|
78
77
|
return false;
|
|
@@ -84,19 +83,19 @@ var arrowLeftFromGapCursor = function arrowLeftFromGapCursor(selection) {
|
|
|
84
83
|
side = selection.side;
|
|
85
84
|
var _getPluginState = (0, _pluginFactory.getPluginState)(state),
|
|
86
85
|
selectionRelativeToNode = _getPluginState.selectionRelativeToNode;
|
|
87
|
-
if (side ===
|
|
86
|
+
if (side === _selection.Side.RIGHT) {
|
|
88
87
|
var selectableNode = (0, _utils2.findSelectableContainerBefore)($from, state.doc);
|
|
89
88
|
if (selectableNode) {
|
|
90
|
-
return setSelectionRelativeToNode(
|
|
89
|
+
return setSelectionRelativeToNode(_selection.RelativeSelectionPos.End, _state.NodeSelection.create(state.doc, selectableNode.pos))(state, dispatch);
|
|
91
90
|
}
|
|
92
|
-
} else if (side ===
|
|
93
|
-
if (selectionRelativeToNode ===
|
|
91
|
+
} else if (side === _selection.Side.LEFT && (0, _utils2.isSelectionAtStartOfParentNode)($from, selection)) {
|
|
92
|
+
if (selectionRelativeToNode === _selection.RelativeSelectionPos.Before) {
|
|
94
93
|
var $parent = state.doc.resolve(selection.$from.before(selection.$from.depth));
|
|
95
94
|
if ($parent) {
|
|
96
95
|
var _selectableNode2 = (0, _utils2.findSelectableContainerBefore)($parent, state.doc);
|
|
97
96
|
if (_selectableNode2 && (0, _selection.isIgnored)(_selectableNode2.node)) {
|
|
98
97
|
// selection is inside node without gap cursor preceeded by another node without gap cursor - set node selection for previous node
|
|
99
|
-
return setSelectionRelativeToNode(
|
|
98
|
+
return setSelectionRelativeToNode(_selection.RelativeSelectionPos.End, _state.NodeSelection.create(state.doc, _selectableNode2.pos))(state, dispatch);
|
|
100
99
|
}
|
|
101
100
|
}
|
|
102
101
|
// we don't return this as we want to reset the relative pos, but not block other plugins
|
|
@@ -105,7 +104,7 @@ var arrowLeftFromGapCursor = function arrowLeftFromGapCursor(selection) {
|
|
|
105
104
|
} else {
|
|
106
105
|
var _selectableNode3 = (0, _utils2.findSelectableContainerParent)(selection);
|
|
107
106
|
if (_selectableNode3) {
|
|
108
|
-
return setSelectionRelativeToNode(
|
|
107
|
+
return setSelectionRelativeToNode(_selection.RelativeSelectionPos.Start, _state.NodeSelection.create(state.doc, _selectableNode3.pos))(state, dispatch);
|
|
109
108
|
}
|
|
110
109
|
}
|
|
111
110
|
}
|
|
@@ -122,17 +121,17 @@ var arrowRightFromNode = function arrowRightFromNode(selection) {
|
|
|
122
121
|
if (node.isAtom) {
|
|
123
122
|
if ((0, _utils2.isSelectionAtEndOfParentNode)($to, selection) && (node.isInline || (0, _selection.isIgnored)(node))) {
|
|
124
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
|
|
125
|
-
return findAndSetTextSelection(
|
|
124
|
+
return findAndSetTextSelection(_selection.RelativeSelectionPos.End, state.doc.resolve(from + 1), _types.SelectionDirection.After)(state, dispatch);
|
|
126
125
|
}
|
|
127
126
|
return false;
|
|
128
|
-
} else if (selectionRelativeToNode ===
|
|
127
|
+
} else if (selectionRelativeToNode === _selection.RelativeSelectionPos.Start) {
|
|
129
128
|
// selection is for container node - set selection inside it at the start
|
|
130
|
-
return setSelectionInsideAtNodeStart(
|
|
131
|
-
} else if ((0, _selection.isIgnored)(node) && (!selectionRelativeToNode || selectionRelativeToNode ===
|
|
129
|
+
return setSelectionInsideAtNodeStart(_selection.RelativeSelectionPos.Inside, node, from)(state, dispatch);
|
|
130
|
+
} else if ((0, _selection.isIgnored)(node) && (!selectionRelativeToNode || selectionRelativeToNode === _selection.RelativeSelectionPos.End)) {
|
|
132
131
|
var selectableNode = (0, _utils2.findSelectableContainerAfter)($to, state.doc);
|
|
133
132
|
if (selectableNode && (0, _selection.isIgnored)(selectableNode.node)) {
|
|
134
133
|
// selection is for node without gap cursor followed by another node without gap cursor - set node selection for next node
|
|
135
|
-
return setSelectionRelativeToNode(
|
|
134
|
+
return setSelectionRelativeToNode(_selection.RelativeSelectionPos.Start, _state.NodeSelection.create(state.doc, selectableNode.pos))(state, dispatch);
|
|
136
135
|
}
|
|
137
136
|
}
|
|
138
137
|
return false;
|
|
@@ -149,21 +148,21 @@ var arrowLeftFromNode = function arrowLeftFromNode(selection) {
|
|
|
149
148
|
if (node.isAtom) {
|
|
150
149
|
if ((0, _utils2.isSelectionAtStartOfParentNode)($from, selection) && (node.isInline || (0, _selection.isIgnored)(node))) {
|
|
151
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
|
|
152
|
-
return findAndSetTextSelection(
|
|
151
|
+
return findAndSetTextSelection(_selection.RelativeSelectionPos.Start, state.doc.resolve(from), _types.SelectionDirection.Before)(state, dispatch);
|
|
153
152
|
}
|
|
154
153
|
return false;
|
|
155
|
-
} else if (selectionRelativeToNode ===
|
|
154
|
+
} else if (selectionRelativeToNode === _selection.RelativeSelectionPos.End) {
|
|
156
155
|
// selection is for container node - set selection inside it at the end
|
|
157
|
-
return setSelectionInsideAtNodeEnd(
|
|
158
|
-
} else if (!selectionRelativeToNode || selectionRelativeToNode ===
|
|
156
|
+
return setSelectionInsideAtNodeEnd(_selection.RelativeSelectionPos.Inside, node, from, to)(state, dispatch);
|
|
157
|
+
} else if (!selectionRelativeToNode || selectionRelativeToNode === _selection.RelativeSelectionPos.Inside) {
|
|
159
158
|
// selection is for container node - set selection inside it at the start
|
|
160
159
|
// (this is a special case when the user selects by clicking node)
|
|
161
|
-
return setSelectionInsideAtNodeStart(
|
|
162
|
-
} else if ((0, _selection.isIgnored)(node) && selectionRelativeToNode ===
|
|
160
|
+
return setSelectionInsideAtNodeStart(_selection.RelativeSelectionPos.Before, node, from)(state, dispatch);
|
|
161
|
+
} else if ((0, _selection.isIgnored)(node) && selectionRelativeToNode === _selection.RelativeSelectionPos.Start) {
|
|
163
162
|
// selection is for node without gap cursor preceeded by another node without gap cursor - set node selection for previous node
|
|
164
163
|
var selectableNode = (0, _utils2.findSelectableContainerBefore)($from, state.doc);
|
|
165
164
|
if (selectableNode && (0, _selection.isIgnored)(selectableNode.node)) {
|
|
166
|
-
return setSelectionRelativeToNode(
|
|
165
|
+
return setSelectionRelativeToNode(_selection.RelativeSelectionPos.End, _state.NodeSelection.create(state.doc, selectableNode.pos))(state, dispatch);
|
|
167
166
|
}
|
|
168
167
|
}
|
|
169
168
|
return false;
|
|
@@ -174,7 +173,7 @@ var arrowRightFromText = function arrowRightFromText(selection) {
|
|
|
174
173
|
if ((0, _utils2.isSelectionAtEndOfParentNode)(selection.$to, selection)) {
|
|
175
174
|
var selectableNode = (0, _utils2.findSelectableContainerParent)(selection);
|
|
176
175
|
if (selectableNode) {
|
|
177
|
-
return setSelectionRelativeToNode(
|
|
176
|
+
return setSelectionRelativeToNode(_selection.RelativeSelectionPos.End, _state.NodeSelection.create(state.doc, selectableNode.pos))(state, dispatch);
|
|
178
177
|
}
|
|
179
178
|
}
|
|
180
179
|
return false;
|
|
@@ -184,11 +183,11 @@ var arrowLeftFromText = function arrowLeftFromText(selection) {
|
|
|
184
183
|
return function (state, dispatch) {
|
|
185
184
|
var _getPluginState4 = (0, _pluginFactory.getPluginState)(state),
|
|
186
185
|
selectionRelativeToNode = _getPluginState4.selectionRelativeToNode;
|
|
187
|
-
if (selectionRelativeToNode ===
|
|
186
|
+
if (selectionRelativeToNode === _selection.RelativeSelectionPos.Before) {
|
|
188
187
|
var selectableNode = (0, _utils2.findSelectableContainerBefore)(selection.$from, state.doc);
|
|
189
188
|
if (selectableNode && (0, _selection.isIgnored)(selectableNode.node)) {
|
|
190
189
|
// selection is inside node without gap cursor preceeded by another node without gap cursor - set node selection for previous node
|
|
191
|
-
return setSelectionRelativeToNode(
|
|
190
|
+
return setSelectionRelativeToNode(_selection.RelativeSelectionPos.End, _state.NodeSelection.create(state.doc, selectableNode.pos))(state, dispatch);
|
|
192
191
|
}
|
|
193
192
|
// we don't return this as we want to reset the relative pos, but not block other plugins
|
|
194
193
|
// from responding to arrow left key
|
|
@@ -196,7 +195,7 @@ var arrowLeftFromText = function arrowLeftFromText(selection) {
|
|
|
196
195
|
} else if ((0, _utils2.isSelectionAtStartOfParentNode)(selection.$from, selection)) {
|
|
197
196
|
var _selectableNode4 = (0, _utils2.findSelectableContainerParent)(selection);
|
|
198
197
|
if (_selectableNode4) {
|
|
199
|
-
return setSelectionRelativeToNode(
|
|
198
|
+
return setSelectionRelativeToNode(_selection.RelativeSelectionPos.Start, _state.NodeSelection.create(state.doc, _selectableNode4.pos))(state, dispatch);
|
|
200
199
|
}
|
|
201
200
|
}
|
|
202
201
|
return false;
|
|
@@ -227,7 +226,7 @@ var setSelectionInsideAtNodeStart = function setSelectionInsideAtNodeStart(selec
|
|
|
227
226
|
} else if ((0, _utils.isEmptyParagraph)(childNode)) {
|
|
228
227
|
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(selectionPos + 1), _types.SelectionDirection.Before)(state, dispatch);
|
|
229
228
|
} else if (!(0, _selection.isIgnored)(node)) {
|
|
230
|
-
return setSelectionRelativeToNode(selectionRelativeToNode, new
|
|
229
|
+
return setSelectionRelativeToNode(selectionRelativeToNode, new _selection.GapCursorSelection(state.doc.resolve(selectionPos), _selection.Side.LEFT))(state, dispatch);
|
|
231
230
|
} else if ((0, _utils2.isSelectableContainerNode)(node)) {
|
|
232
231
|
return setSelectionRelativeToNode(selectionRelativeToNode, _state.NodeSelection.create(state.doc, selectionPos))(state, dispatch);
|
|
233
232
|
}
|
|
@@ -251,7 +250,7 @@ var setSelectionInsideAtNodeEnd = exports.setSelectionInsideAtNodeEnd = function
|
|
|
251
250
|
} else if ((0, _utils.isEmptyParagraph)(childNode)) {
|
|
252
251
|
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(selectionPos), _types.SelectionDirection.After)(state, dispatch);
|
|
253
252
|
} else if (!(0, _selection.isIgnored)(node)) {
|
|
254
|
-
return setSelectionRelativeToNode(selectionRelativeToNode, new
|
|
253
|
+
return setSelectionRelativeToNode(selectionRelativeToNode, new _selection.GapCursorSelection(state.doc.resolve(selectionPos + 1), _selection.Side.RIGHT))(state, dispatch);
|
|
255
254
|
} else if ((0, _utils2.isSelectableContainerNode)(node)) {
|
|
256
255
|
return setSelectionRelativeToNode(selectionRelativeToNode, _state.NodeSelection.create(state.doc, selectionPos))(state, dispatch);
|
|
257
256
|
}
|
|
@@ -11,9 +11,7 @@ var _state = require("@atlaskit/editor-prosemirror/state");
|
|
|
11
11
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
12
12
|
var _gapCursorPluginKey = require("../gap-cursor-plugin-key");
|
|
13
13
|
var _direction = require("./direction");
|
|
14
|
-
var _selection2 = require("./selection");
|
|
15
14
|
var _utils3 = require("./utils");
|
|
16
|
-
var _isValidTargetNode = require("./utils/is-valid-target-node");
|
|
17
15
|
var shouldSkipGapCursor = exports.shouldSkipGapCursor = function shouldSkipGapCursor(direction, state, $pos) {
|
|
18
16
|
var _$pos$nodeBefore;
|
|
19
17
|
var doc = state.doc,
|
|
@@ -36,8 +34,8 @@ var shouldSkipGapCursor = exports.shouldSkipGapCursor = function shouldSkipGapCu
|
|
|
36
34
|
function shouldHandleMediaGapCursor(dir, state) {
|
|
37
35
|
var _selection$$from$node;
|
|
38
36
|
var selection = state.selection;
|
|
39
|
-
var upArrowFromGapCursorIntoMedia = selection instanceof
|
|
40
|
-
var downArrowFromGapCursorIntoMediaGroup = selection instanceof
|
|
37
|
+
var upArrowFromGapCursorIntoMedia = selection instanceof _selection.GapCursorSelection && dir === _direction.Direction.UP && selection.$from.nodeBefore && (0, _utils.isMediaNode)(selection.$from.nodeBefore);
|
|
38
|
+
var downArrowFromGapCursorIntoMediaGroup = selection instanceof _selection.GapCursorSelection && dir === _direction.Direction.DOWN && ((_selection$$from$node = selection.$from.nodeAfter) === null || _selection$$from$node === void 0 ? void 0 : _selection$$from$node.type.name) === 'mediaGroup';
|
|
41
39
|
return upArrowFromGapCursorIntoMedia || downArrowFromGapCursorIntoMediaGroup;
|
|
42
40
|
}
|
|
43
41
|
|
|
@@ -53,13 +51,13 @@ function handleMediaGapCursor(dir, state) {
|
|
|
53
51
|
if (nodeBeforePos && selection.side === 'right' && ((_tr$doc$nodeAt = tr.doc.nodeAt(nodeBeforePos)) === null || _tr$doc$nodeAt === void 0 ? void 0 : _tr$doc$nodeAt.type.name) === 'mediaSingle') {
|
|
54
52
|
tr.setSelection(new _state.NodeSelection(tr.doc.resolve(nodeBeforePos))).scrollIntoView();
|
|
55
53
|
} else if (nodeBeforePos || nodeBeforePos === 0) {
|
|
56
|
-
tr.setSelection(new
|
|
54
|
+
tr.setSelection(new _selection.GapCursorSelection(tr.doc.resolve(nodeBeforePos), _selection.Side.LEFT)).scrollIntoView();
|
|
57
55
|
}
|
|
58
56
|
}
|
|
59
57
|
if (dir === _direction.Direction.DOWN && selection.$from.nodeAfter) {
|
|
60
58
|
var nodeAfterPos = selection.side === 'right' ? $pos.pos : $pos.pos + selection.$from.nodeAfter.nodeSize;
|
|
61
59
|
if (nodeAfterPos) {
|
|
62
|
-
tr.setSelection(new
|
|
60
|
+
tr.setSelection(new _selection.GapCursorSelection(tr.doc.resolve(nodeAfterPos), _selection.Side.LEFT)).scrollIntoView();
|
|
63
61
|
}
|
|
64
62
|
}
|
|
65
63
|
return tr;
|
|
@@ -110,14 +108,14 @@ var arrow = exports.arrow = function arrow(dir, endOfTextblock) {
|
|
|
110
108
|
}
|
|
111
109
|
|
|
112
110
|
// when jumping between block nodes at the same depth, we need to reverse cursor without changing ProseMirror position
|
|
113
|
-
if (selection instanceof
|
|
111
|
+
if (selection instanceof _selection.GapCursorSelection &&
|
|
114
112
|
// next node allow gap cursor position
|
|
115
|
-
(0,
|
|
113
|
+
(0, _selection.isValidTargetNode)((0, _direction.isBackward)(dir) ? $pos.nodeBefore : $pos.nodeAfter) && (
|
|
116
114
|
// gap cursor changes block node
|
|
117
|
-
(0, _direction.isBackward)(dir) && selection.side ===
|
|
115
|
+
(0, _direction.isBackward)(dir) && selection.side === _selection.Side.LEFT || (0, _direction.isForward)(dir) && selection.side === _selection.Side.RIGHT)) {
|
|
118
116
|
// reverse cursor position
|
|
119
117
|
if (dispatch) {
|
|
120
|
-
dispatch(tr.setSelection(new
|
|
118
|
+
dispatch(tr.setSelection(new _selection.GapCursorSelection($pos, selection.side === _selection.Side.RIGHT ? _selection.Side.LEFT : _selection.Side.RIGHT)).scrollIntoView());
|
|
121
119
|
}
|
|
122
120
|
return true;
|
|
123
121
|
}
|
|
@@ -128,14 +126,14 @@ var arrow = exports.arrow = function arrow(dir, endOfTextblock) {
|
|
|
128
126
|
return false;
|
|
129
127
|
}
|
|
130
128
|
}
|
|
131
|
-
var nextSelection =
|
|
129
|
+
var nextSelection = _selection.GapCursorSelection.findFrom($pos, (0, _direction.isBackward)(dir) ? -1 : 1, mustMove);
|
|
132
130
|
if (!nextSelection) {
|
|
133
131
|
return false;
|
|
134
132
|
}
|
|
135
|
-
if (!(0,
|
|
133
|
+
if (!(0, _selection.isValidTargetNode)((0, _direction.isForward)(dir) ? nextSelection.$from.nodeBefore : nextSelection.$from.nodeAfter)) {
|
|
136
134
|
// reverse cursor position
|
|
137
135
|
if (dispatch) {
|
|
138
|
-
dispatch(tr.setSelection(new
|
|
136
|
+
dispatch(tr.setSelection(new _selection.GapCursorSelection(nextSelection.$from, (0, _direction.isForward)(dir) ? _selection.Side.LEFT : _selection.Side.RIGHT)).scrollIntoView());
|
|
139
137
|
}
|
|
140
138
|
return true;
|
|
141
139
|
}
|
|
@@ -147,14 +145,14 @@ var arrow = exports.arrow = function arrow(dir, endOfTextblock) {
|
|
|
147
145
|
};
|
|
148
146
|
var deleteNode = exports.deleteNode = function deleteNode(dir) {
|
|
149
147
|
return function (state, dispatch) {
|
|
150
|
-
if (state.selection instanceof
|
|
148
|
+
if (state.selection instanceof _selection.GapCursorSelection) {
|
|
151
149
|
var _state$selection = state.selection,
|
|
152
150
|
$from = _state$selection.$from,
|
|
153
151
|
$anchor = _state$selection.$anchor;
|
|
154
152
|
var tr = state.tr;
|
|
155
153
|
if ((0, _direction.isBackward)(dir)) {
|
|
156
154
|
if (state.selection.side === 'left') {
|
|
157
|
-
tr.setSelection(new
|
|
155
|
+
tr.setSelection(new _selection.GapCursorSelection($anchor, _selection.Side.RIGHT));
|
|
158
156
|
if (dispatch) {
|
|
159
157
|
dispatch(tr);
|
|
160
158
|
}
|
|
@@ -182,7 +180,7 @@ var captureCursorCoords = function captureCursorCoords(event, editorRef, posAtCo
|
|
|
182
180
|
if (event.clientY < rect.top) {
|
|
183
181
|
return {
|
|
184
182
|
position: 0,
|
|
185
|
-
side:
|
|
183
|
+
side: _selection.Side.LEFT
|
|
186
184
|
};
|
|
187
185
|
}
|
|
188
186
|
if (rect.left > 0) {
|
|
@@ -194,9 +192,9 @@ var captureCursorCoords = function captureCursorCoords(event, editorRef, posAtCo
|
|
|
194
192
|
if (coords && coords.inside > -1) {
|
|
195
193
|
var $from = tr.doc.resolve(coords.inside);
|
|
196
194
|
var start = $from.before(1);
|
|
197
|
-
var side = event.clientX < rect.left ?
|
|
195
|
+
var side = event.clientX < rect.left ? _selection.Side.LEFT : _selection.Side.RIGHT;
|
|
198
196
|
var position;
|
|
199
|
-
if (side ===
|
|
197
|
+
if (side === _selection.Side.LEFT) {
|
|
200
198
|
position = start;
|
|
201
199
|
} else {
|
|
202
200
|
var node = tr.doc.nodeAt(start);
|
|
@@ -221,19 +219,19 @@ var setSelectionTopLevelBlocks = exports.setSelectionTopLevelBlocks = function s
|
|
|
221
219
|
if ($pos === null) {
|
|
222
220
|
return;
|
|
223
221
|
}
|
|
224
|
-
var isGapCursorAllowed = cursorCoords.side ===
|
|
225
|
-
if (isGapCursorAllowed &&
|
|
222
|
+
var isGapCursorAllowed = cursorCoords.side === _selection.Side.LEFT ? (0, _selection.isValidTargetNode)($pos.nodeAfter) : (0, _selection.isValidTargetNode)($pos.nodeBefore);
|
|
223
|
+
if (isGapCursorAllowed && _selection.GapCursorSelection.valid($pos)) {
|
|
226
224
|
// this forces PM to re-render the decoration node if we change the side of the gap cursor, it doesn't do it by default
|
|
227
|
-
if (tr.selection instanceof
|
|
225
|
+
if (tr.selection instanceof _selection.GapCursorSelection) {
|
|
228
226
|
tr.setSelection(_state.Selection.near($pos));
|
|
229
227
|
} else {
|
|
230
|
-
tr.setSelection(new
|
|
228
|
+
tr.setSelection(new _selection.GapCursorSelection($pos, cursorCoords.side));
|
|
231
229
|
}
|
|
232
230
|
}
|
|
233
231
|
// try to set text selection if the editor isnt focused
|
|
234
232
|
// if the editor is focused, we are most likely dragging a selection outside.
|
|
235
233
|
else if (editorFocused === false) {
|
|
236
|
-
var selectionTemp = _state.Selection.findFrom($pos, cursorCoords.side ===
|
|
234
|
+
var selectionTemp = _state.Selection.findFrom($pos, cursorCoords.side === _selection.Side.LEFT ? 1 : -1, true);
|
|
237
235
|
if (selectionTemp) {
|
|
238
236
|
tr.setSelection(selectionTemp);
|
|
239
237
|
}
|
|
@@ -8,9 +8,9 @@ exports.getLayoutModeFromTargetNode = getLayoutModeFromTargetNode;
|
|
|
8
8
|
exports.getMediaNearPos = getMediaNearPos;
|
|
9
9
|
exports.isTextBlockNearPos = exports.isLeftCursor = exports.isIgnoredClick = void 0;
|
|
10
10
|
var _mediaSingle = require("@atlaskit/editor-common/media-single");
|
|
11
|
+
var _selection = require("@atlaskit/editor-common/selection");
|
|
11
12
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
12
13
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
13
|
-
var _selection = require("./selection");
|
|
14
14
|
var isLeftCursor = exports.isLeftCursor = function isLeftCursor(side) {
|
|
15
15
|
return side === _selection.Side.LEFT;
|
|
16
16
|
};
|
|
@@ -5,11 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = keymapPlugin;
|
|
7
7
|
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
8
|
+
var _selection = require("@atlaskit/editor-common/selection");
|
|
8
9
|
var _commands = require("@atlaskit/editor-prosemirror/commands");
|
|
9
10
|
var _keymap = require("@atlaskit/editor-prosemirror/keymap");
|
|
10
11
|
var _actions = require("./gap-cursor/actions");
|
|
11
12
|
var _direction = require("./gap-cursor/direction");
|
|
12
|
-
var _selection = require("./gap-cursor/selection");
|
|
13
13
|
function keymapPlugin() {
|
|
14
14
|
var map = {};
|
|
15
15
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.insertNewLine.common, function (state, dispatch, view) {
|
|
@@ -3,12 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
Object.defineProperty(exports, "createSelectionClickHandler", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _selection.createSelectionClickHandler;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
6
|
exports.isSelectionAtStartOfParentNode = exports.isSelectionAtEndOfParentNode = exports.isSelectableContainerNode = exports.isSelectableChildNode = exports.getNodesToDecorateFromSelection = exports.getDecorations = exports.findSelectableContainerParent = exports.findSelectableContainerBefore = exports.findSelectableContainerAfter = exports.findLastChildNodeToSelect = exports.findFirstChildNodeToSelect = void 0;
|
|
13
7
|
exports.shouldRecalcDecorations = shouldRecalcDecorations;
|
|
14
8
|
var _selection = require("@atlaskit/editor-common/selection");
|
package/dist/cjs/types/index.js
CHANGED
|
@@ -12,6 +12,9 @@ Object.defineProperty(exports, "RelativeSelectionPos", {
|
|
|
12
12
|
exports.selectionPluginKey = exports.SelectionDirection = void 0;
|
|
13
13
|
var _selection = require("@atlaskit/editor-common/selection");
|
|
14
14
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
15
|
+
/* eslint-disable @atlaskit/editor/no-re-export */
|
|
16
|
+
// Entry file in package.json
|
|
17
|
+
|
|
15
18
|
var selectionPluginKey = exports.selectionPluginKey = new _state.PluginKey('selection');
|
|
16
19
|
var SelectionDirection = exports.SelectionDirection = /*#__PURE__*/function (SelectionDirection) {
|
|
17
20
|
SelectionDirection[SelectionDirection["Before"] = -1] = "Before";
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/* eslint-disable import/no-extraneous-dependencies */
|
|
2
|
-
import { isIgnored as isIgnoredByGapCursor } from '@atlaskit/editor-common/selection';
|
|
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 {
|
|
5
|
+
import { SelectionDirection, selectionPluginKey } from '../types';
|
|
6
6
|
import { SelectionActionTypes } from './actions';
|
|
7
|
-
import { GapCursorSelection, Side } from './gap-cursor-selection';
|
|
8
7
|
import { createCommand, getPluginState } from './plugin-factory';
|
|
9
8
|
import { findFirstChildNodeToSelect, findLastChildNodeToSelect, findSelectableContainerAfter, findSelectableContainerBefore, findSelectableContainerParent, isSelectableContainerNode, isSelectionAtEndOfParentNode, isSelectionAtStartOfParentNode } from './utils';
|
|
10
9
|
export const selectNearNode = (selectionRelativeToNode, selection) => ({
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { atTheBeginningOfDoc, atTheEndOfDoc } from '@atlaskit/editor-common/selection';
|
|
1
|
+
import { atTheBeginningOfDoc, atTheEndOfDoc, GapCursorSelection, Side, isValidTargetNode } from '@atlaskit/editor-common/selection';
|
|
2
2
|
import { isMediaNode, isNodeBeforeMediaNode, isPositionNearTableRow } from '@atlaskit/editor-common/utils';
|
|
3
3
|
import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/whitespace';
|
|
4
4
|
import { NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
5
5
|
import { findDomRefAtPos, findPositionOfNodeBefore, removeNodeBefore } from '@atlaskit/editor-prosemirror/utils';
|
|
6
6
|
import { gapCursorPluginKey } from '../gap-cursor-plugin-key';
|
|
7
7
|
import { Direction, isBackward, isForward } from './direction';
|
|
8
|
-
import { GapCursorSelection, Side } from './selection';
|
|
9
8
|
import { isTextBlockNearPos } from './utils';
|
|
10
|
-
import { isValidTargetNode } from './utils/is-valid-target-node';
|
|
11
9
|
export const shouldSkipGapCursor = (direction, state, $pos) => {
|
|
12
10
|
var _$pos$nodeBefore;
|
|
13
11
|
const {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CAPTION_PLACEHOLDER_ID } from '@atlaskit/editor-common/media-single';
|
|
2
|
+
import { Side } from '@atlaskit/editor-common/selection';
|
|
2
3
|
import { TableSharedCssClassName, UnsupportedSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
3
4
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
4
|
-
import { Side } from './selection';
|
|
5
5
|
export const isLeftCursor = side => side === Side.LEFT;
|
|
6
6
|
export function getMediaNearPos(doc, $pos, schema, dir = -1) {
|
|
7
7
|
let $currentPos = $pos;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { backspace, bindKeymapWithCommand, deleteKey, insertNewLine, moveDown, moveLeft, moveRight, moveUp } from '@atlaskit/editor-common/keymaps';
|
|
2
|
+
import { GapCursorSelection } from '@atlaskit/editor-common/selection';
|
|
2
3
|
import { createParagraphNear } from '@atlaskit/editor-prosemirror/commands';
|
|
3
4
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
4
5
|
import { arrow, deleteNode } from './gap-cursor/actions';
|
|
5
6
|
import { Direction } from './gap-cursor/direction';
|
|
6
|
-
import { GapCursorSelection } from './gap-cursor/selection';
|
|
7
7
|
export default function keymapPlugin() {
|
|
8
8
|
const map = {};
|
|
9
9
|
bindKeymapWithCommand(insertNewLine.common, (state, dispatch, view) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isIgnored as isIgnoredByGapCursor, isSelectionAtStartOfNode } from '@atlaskit/editor-common/selection';
|
|
2
2
|
import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
3
3
|
import { AllSelection, NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
import { findParentNode, flatten } from '@atlaskit/editor-prosemirror/utils';
|
|
@@ -239,5 +239,4 @@ export const isSelectionAtEndOfParentNode = ($pos, selection) => {
|
|
|
239
239
|
}
|
|
240
240
|
const $after = $pos.doc.resolve($pos.after());
|
|
241
241
|
return $after.parent.content.size === $after.parentOffset;
|
|
242
|
-
};
|
|
243
|
-
export { createSelectionClickHandler };
|
|
242
|
+
};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/* eslint-disable @atlaskit/editor/no-re-export */
|
|
2
|
+
// Entry file in package.json
|
|
3
|
+
|
|
1
4
|
import { RelativeSelectionPos } from '@atlaskit/editor-common/selection';
|
|
2
5
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
6
|
export const selectionPluginKey = new PluginKey('selection');
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/* eslint-disable import/no-extraneous-dependencies */
|
|
2
|
-
import { isIgnored as isIgnoredByGapCursor } from '@atlaskit/editor-common/selection';
|
|
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 {
|
|
5
|
+
import { SelectionDirection, selectionPluginKey } from '../types';
|
|
6
6
|
import { SelectionActionTypes } from './actions';
|
|
7
|
-
import { GapCursorSelection, Side } from './gap-cursor-selection';
|
|
8
7
|
import { createCommand, getPluginState } from './plugin-factory';
|
|
9
8
|
import { findFirstChildNodeToSelect, findLastChildNodeToSelect, findSelectableContainerAfter, findSelectableContainerBefore, findSelectableContainerParent, isSelectableContainerNode, isSelectionAtEndOfParentNode, isSelectionAtStartOfParentNode } from './utils';
|
|
10
9
|
export var selectNearNode = function selectNearNode(selectionRelativeToNode, selection) {
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { atTheBeginningOfDoc, atTheEndOfDoc } from '@atlaskit/editor-common/selection';
|
|
1
|
+
import { atTheBeginningOfDoc, atTheEndOfDoc, GapCursorSelection, Side, isValidTargetNode } from '@atlaskit/editor-common/selection';
|
|
2
2
|
import { isMediaNode, isNodeBeforeMediaNode, isPositionNearTableRow } from '@atlaskit/editor-common/utils';
|
|
3
3
|
import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/whitespace';
|
|
4
4
|
import { NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
5
5
|
import { findDomRefAtPos, findPositionOfNodeBefore, removeNodeBefore } from '@atlaskit/editor-prosemirror/utils';
|
|
6
6
|
import { gapCursorPluginKey } from '../gap-cursor-plugin-key';
|
|
7
7
|
import { Direction, isBackward, isForward } from './direction';
|
|
8
|
-
import { GapCursorSelection, Side } from './selection';
|
|
9
8
|
import { isTextBlockNearPos } from './utils';
|
|
10
|
-
import { isValidTargetNode } from './utils/is-valid-target-node';
|
|
11
9
|
export var shouldSkipGapCursor = function shouldSkipGapCursor(direction, state, $pos) {
|
|
12
10
|
var _$pos$nodeBefore;
|
|
13
11
|
var doc = state.doc,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CAPTION_PLACEHOLDER_ID } from '@atlaskit/editor-common/media-single';
|
|
2
|
+
import { Side } from '@atlaskit/editor-common/selection';
|
|
2
3
|
import { TableSharedCssClassName, UnsupportedSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
3
4
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
4
|
-
import { Side } from './selection';
|
|
5
5
|
export var isLeftCursor = function isLeftCursor(side) {
|
|
6
6
|
return side === Side.LEFT;
|
|
7
7
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { backspace, bindKeymapWithCommand, deleteKey, insertNewLine, moveDown, moveLeft, moveRight, moveUp } from '@atlaskit/editor-common/keymaps';
|
|
2
|
+
import { GapCursorSelection } from '@atlaskit/editor-common/selection';
|
|
2
3
|
import { createParagraphNear } from '@atlaskit/editor-prosemirror/commands';
|
|
3
4
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
4
5
|
import { arrow, deleteNode } from './gap-cursor/actions';
|
|
5
6
|
import { Direction } from './gap-cursor/direction';
|
|
6
|
-
import { GapCursorSelection } from './gap-cursor/selection';
|
|
7
7
|
export default function keymapPlugin() {
|
|
8
8
|
var map = {};
|
|
9
9
|
bindKeymapWithCommand(insertNewLine.common, function (state, dispatch, view) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isIgnored as isIgnoredByGapCursor, isSelectionAtStartOfNode } from '@atlaskit/editor-common/selection';
|
|
2
2
|
import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
3
3
|
import { AllSelection, NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
import { findParentNode, flatten } from '@atlaskit/editor-prosemirror/utils';
|
|
@@ -245,5 +245,4 @@ export var isSelectionAtEndOfParentNode = function isSelectionAtEndOfParentNode(
|
|
|
245
245
|
}
|
|
246
246
|
var $after = $pos.doc.resolve($pos.after());
|
|
247
247
|
return $after.parent.content.size === $after.parentOffset;
|
|
248
|
-
};
|
|
249
|
-
export { createSelectionClickHandler };
|
|
248
|
+
};
|
package/dist/esm/types/index.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/* eslint-disable @atlaskit/editor/no-re-export */
|
|
2
|
+
// Entry file in package.json
|
|
3
|
+
|
|
1
4
|
import { RelativeSelectionPos } from '@atlaskit/editor-common/selection';
|
|
2
5
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
6
|
export var selectionPluginKey = new PluginKey('selection');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type { RelativeSelectionPos } from '@atlaskit/editor-common/selection';
|
|
1
2
|
import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
2
3
|
import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
-
import type { RelativeSelectionPos } from '../types';
|
|
4
4
|
export declare enum SelectionActionTypes {
|
|
5
5
|
SET_DECORATIONS = "SET_DECORATIONS",
|
|
6
6
|
SET_RELATIVE_SELECTION = "SET_RELATIVE_SELECTION"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { RelativeSelectionPos } from '@atlaskit/editor-common/selection';
|
|
1
2
|
import type { Command, EditorCommandWithMetadata } from '@atlaskit/editor-common/types';
|
|
2
3
|
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
4
|
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
-
import { RelativeSelectionPos } from '../types';
|
|
5
5
|
export declare const selectNearNode: EditorCommandWithMetadata;
|
|
6
6
|
export declare const setSelectionRelativeToNode: (selectionRelativeToNode?: RelativeSelectionPos, selection?: Selection | null) => Command;
|
|
7
7
|
export declare const arrowRight: Command;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { Side } from '@atlaskit/editor-common/selection';
|
|
1
2
|
import type { Node as PMNode, ResolvedPos, Schema } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
-
import { Side } from './selection';
|
|
3
3
|
export declare const isLeftCursor: (side: Side) => side is Side.LEFT;
|
|
4
4
|
export declare function getMediaNearPos(doc: PMNode, $pos: ResolvedPos, schema: Schema, dir?: number): PMNode | null;
|
|
5
5
|
export declare const isTextBlockNearPos: (doc: PMNode, schema: Schema, $pos: ResolvedPos, dir: number) => boolean;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { SelectionPluginState } from '
|
|
1
|
+
import type { SelectionPluginState } from '@atlaskit/editor-common/selection';
|
|
2
2
|
export declare const createCommand: <A = import("./actions").SelectionAction>(action: A | ((state: Readonly<import("prosemirror-state").EditorState>) => false | A), transform?: ((tr: import("prosemirror-state").Transaction, state: import("prosemirror-state").EditorState) => import("prosemirror-state").Transaction) | undefined) => import("@atlaskit/editor-common/types").Command, getPluginState: (state: import("prosemirror-state").EditorState) => SelectionPluginState, createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch, initialState: SelectionPluginState | ((state: import("prosemirror-state").EditorState) => SelectionPluginState)) => import("prosemirror-state").SafeStateField<SelectionPluginState>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { SelectionPluginState } from '
|
|
1
|
+
import type { SelectionPluginState } from '@atlaskit/editor-common/selection';
|
|
2
2
|
import type { SelectionAction } from './actions';
|
|
3
3
|
export declare function reducer(pluginState: SelectionPluginState, action: SelectionAction): SelectionPluginState;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
3
3
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
|
+
import type { SelectionPluginState } from '@atlaskit/editor-common/selection';
|
|
4
5
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
-
import type { SelectionPluginOptions
|
|
6
|
+
import type { SelectionPluginOptions } from '../types';
|
|
6
7
|
export declare const getInitialState: (state: EditorState) => SelectionPluginState;
|
|
7
8
|
export declare const createPlugin: (dispatch: Dispatch, dispatchAnalyticsEvent: DispatchAnalyticsEvent, options?: SelectionPluginOptions) => SafePlugin<SelectionPluginState>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { createSelectionClickHandler } from '@atlaskit/editor-common/selection';
|
|
2
1
|
import type { Node as PmNode, ResolvedPos } from '@atlaskit/editor-prosemirror/model';
|
|
3
2
|
import type { EditorState, ReadonlyTransaction, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
4
3
|
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
@@ -55,4 +54,3 @@ export declare const findFirstChildNodeToSelect: (parent: PmNode) => NodeWithPos
|
|
|
55
54
|
export declare const findLastChildNodeToSelect: (parent: PmNode) => NodeWithPos | undefined;
|
|
56
55
|
export declare const isSelectionAtStartOfParentNode: ($pos: ResolvedPos, selection: Selection) => boolean;
|
|
57
56
|
export declare const isSelectionAtEndOfParentNode: ($pos: ResolvedPos, selection: Selection) => boolean;
|
|
58
|
-
export { createSelectionClickHandler };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type { RelativeSelectionPos } from '@atlaskit/editor-common/selection';
|
|
1
2
|
import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
2
3
|
import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
-
import type { RelativeSelectionPos } from '../types';
|
|
4
4
|
export declare enum SelectionActionTypes {
|
|
5
5
|
SET_DECORATIONS = "SET_DECORATIONS",
|
|
6
6
|
SET_RELATIVE_SELECTION = "SET_RELATIVE_SELECTION"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { RelativeSelectionPos } from '@atlaskit/editor-common/selection';
|
|
1
2
|
import type { Command, EditorCommandWithMetadata } from '@atlaskit/editor-common/types';
|
|
2
3
|
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
4
|
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
-
import { RelativeSelectionPos } from '../types';
|
|
5
5
|
export declare const selectNearNode: EditorCommandWithMetadata;
|
|
6
6
|
export declare const setSelectionRelativeToNode: (selectionRelativeToNode?: RelativeSelectionPos, selection?: Selection | null) => Command;
|
|
7
7
|
export declare const arrowRight: Command;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { Side } from '@atlaskit/editor-common/selection';
|
|
1
2
|
import type { Node as PMNode, ResolvedPos, Schema } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
-
import { Side } from './selection';
|
|
3
3
|
export declare const isLeftCursor: (side: Side) => side is Side.LEFT;
|
|
4
4
|
export declare function getMediaNearPos(doc: PMNode, $pos: ResolvedPos, schema: Schema, dir?: number): PMNode | null;
|
|
5
5
|
export declare const isTextBlockNearPos: (doc: PMNode, schema: Schema, $pos: ResolvedPos, dir: number) => boolean;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { SelectionPluginState } from '
|
|
1
|
+
import type { SelectionPluginState } from '@atlaskit/editor-common/selection';
|
|
2
2
|
export declare const createCommand: <A = import("./actions").SelectionAction>(action: A | ((state: Readonly<import("prosemirror-state").EditorState>) => false | A), transform?: ((tr: import("prosemirror-state").Transaction, state: import("prosemirror-state").EditorState) => import("prosemirror-state").Transaction) | undefined) => import("@atlaskit/editor-common/types").Command, getPluginState: (state: import("prosemirror-state").EditorState) => SelectionPluginState, createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch, initialState: SelectionPluginState | ((state: import("prosemirror-state").EditorState) => SelectionPluginState)) => import("prosemirror-state").SafeStateField<SelectionPluginState>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { SelectionPluginState } from '
|
|
1
|
+
import type { SelectionPluginState } from '@atlaskit/editor-common/selection';
|
|
2
2
|
import type { SelectionAction } from './actions';
|
|
3
3
|
export declare function reducer(pluginState: SelectionPluginState, action: SelectionAction): SelectionPluginState;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
3
3
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
|
+
import type { SelectionPluginState } from '@atlaskit/editor-common/selection';
|
|
4
5
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
-
import type { SelectionPluginOptions
|
|
6
|
+
import type { SelectionPluginOptions } from '../types';
|
|
6
7
|
export declare const getInitialState: (state: EditorState) => SelectionPluginState;
|
|
7
8
|
export declare const createPlugin: (dispatch: Dispatch, dispatchAnalyticsEvent: DispatchAnalyticsEvent, options?: SelectionPluginOptions) => SafePlugin<SelectionPluginState>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { createSelectionClickHandler } from '@atlaskit/editor-common/selection';
|
|
2
1
|
import type { Node as PmNode, ResolvedPos } from '@atlaskit/editor-prosemirror/model';
|
|
3
2
|
import type { EditorState, ReadonlyTransaction, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
4
3
|
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
@@ -55,4 +54,3 @@ export declare const findFirstChildNodeToSelect: (parent: PmNode) => NodeWithPos
|
|
|
55
54
|
export declare const findLastChildNodeToSelect: (parent: PmNode) => NodeWithPos | undefined;
|
|
56
55
|
export declare const isSelectionAtStartOfParentNode: ($pos: ResolvedPos, selection: Selection) => boolean;
|
|
57
56
|
export declare const isSelectionAtEndOfParentNode: ($pos: ResolvedPos, selection: Selection) => boolean;
|
|
58
|
-
export { createSelectionClickHandler };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-selection",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.5",
|
|
4
4
|
"description": "Selection plugin for @atlaskit/editor-core",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
"runReact18": true
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@atlaskit/editor-common": "^96.
|
|
23
|
+
"@atlaskit/editor-common": "^96.6.0",
|
|
24
24
|
"@atlaskit/editor-prosemirror": "6.2.1",
|
|
25
25
|
"@atlaskit/editor-shared-styles": "^3.2.0",
|
|
26
26
|
"@atlaskit/editor-tables": "^2.8.0",
|
|
27
27
|
"@atlaskit/platform-feature-flags": "^0.3.0",
|
|
28
|
-
"@atlaskit/tmp-editor-statsig": "2.
|
|
28
|
+
"@atlaskit/tmp-editor-statsig": "2.28.0",
|
|
29
29
|
"@atlaskit/tokens": "^2.5.0",
|
|
30
30
|
"@babel/runtime": "^7.0.0"
|
|
31
31
|
},
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "GapBookmark", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _selection.GapBookmark;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "GapCursorSelection", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function get() {
|
|
15
|
-
return _selection.GapCursorSelection;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "JSON_ID", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function get() {
|
|
21
|
-
return _selection.JSON_ID;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(exports, "Side", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function get() {
|
|
27
|
-
return _selection.Side;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
var _selection = require("@atlaskit/editor-common/selection");
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "isIgnored", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _selection.isIgnored;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
var _selection = require("@atlaskit/editor-common/selection");
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "isValidTargetNode", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _selection.isValidTargetNode;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
var _selection = require("@atlaskit/editor-common/selection");
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "GapCursorSelection", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _selection.GapCursorSelection;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "Side", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function get() {
|
|
15
|
-
return _selection.Side;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "hasGapCursorPlugin", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function get() {
|
|
21
|
-
return _actions.hasGapCursorPlugin;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(exports, "setCursorForTopLevelBlocks", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function get() {
|
|
27
|
-
return _actions.setCursorForTopLevelBlocks;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(exports, "setSelectionTopLevelBlocks", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function get() {
|
|
33
|
-
return _actions.setSelectionTopLevelBlocks;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
var _selection = require("@atlaskit/editor-common/selection");
|
|
37
|
-
var _actions = require("./gap-cursor/actions");
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { GapCursorSelection, JSON_ID, Side, GapBookmark } from '@atlaskit/editor-common/selection';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { isIgnored } from '@atlaskit/editor-common/selection';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { isValidTargetNode } from '@atlaskit/editor-common/selection';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { GapCursorSelection, JSON_ID, Side, GapBookmark } from '@atlaskit/editor-common/selection';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { isIgnored } from '@atlaskit/editor-common/selection';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { isValidTargetNode } from '@atlaskit/editor-common/selection';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { GapCursorSelection, JSON_ID, Side, GapBookmark } from '@atlaskit/editor-common/selection';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { isIgnored } from '@atlaskit/editor-common/selection';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { isValidTargetNode } from '@atlaskit/editor-common/selection';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { GapCursorSelection, JSON_ID, Side, GapBookmark } from '@atlaskit/editor-common/selection';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { isIgnored } from '@atlaskit/editor-common/selection';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { isValidTargetNode } from '@atlaskit/editor-common/selection';
|