@atlaskit/editor-plugin-selection 1.6.7 → 1.6.9
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 +12 -0
- package/dist/cjs/pm-plugins/auto-expand-selection-range-on-inline-node-main.js +4 -0
- package/dist/cjs/pm-plugins/commands.js +4 -1
- package/dist/cjs/pm-plugins/events/keydown.js +3 -1
- package/dist/cjs/pm-plugins/gap-cursor/actions.js +17 -3
- package/dist/cjs/pm-plugins/gap-cursor/utils.js +8 -0
- package/dist/cjs/pm-plugins/gap-cursor-keymap.js +24 -5
- package/dist/cjs/pm-plugins/gap-cursor-main.js +4 -0
- package/dist/cjs/pm-plugins/keymap.js +6 -0
- package/dist/es2019/pm-plugins/auto-expand-selection-range-on-inline-node-main.js +4 -0
- package/dist/es2019/pm-plugins/commands.js +4 -1
- package/dist/es2019/pm-plugins/events/keydown.js +4 -1
- package/dist/es2019/pm-plugins/gap-cursor/actions.js +18 -4
- package/dist/es2019/pm-plugins/gap-cursor/utils.js +8 -0
- package/dist/es2019/pm-plugins/gap-cursor-keymap.js +24 -5
- package/dist/es2019/pm-plugins/gap-cursor-main.js +4 -0
- package/dist/es2019/pm-plugins/keymap.js +6 -0
- package/dist/esm/pm-plugins/auto-expand-selection-range-on-inline-node-main.js +4 -0
- package/dist/esm/pm-plugins/commands.js +4 -1
- package/dist/esm/pm-plugins/events/keydown.js +3 -1
- package/dist/esm/pm-plugins/gap-cursor/actions.js +17 -3
- package/dist/esm/pm-plugins/gap-cursor/utils.js +8 -0
- package/dist/esm/pm-plugins/gap-cursor-keymap.js +24 -5
- package/dist/esm/pm-plugins/gap-cursor-main.js +4 -0
- package/dist/esm/pm-plugins/keymap.js +6 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -15,9 +15,13 @@ var createAutoExpandSelectionRangeOnInlineNodePlugin = exports.createAutoExpandS
|
|
|
15
15
|
props: {
|
|
16
16
|
handleDOMEvents: {
|
|
17
17
|
mousedown: function mousedown(_view, event) {
|
|
18
|
+
// Ignored via go/ees005
|
|
19
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
18
20
|
mouseDownElement = event.target;
|
|
19
21
|
},
|
|
20
22
|
mouseup: function mouseup(view, event) {
|
|
23
|
+
// Ignored via go/ees005
|
|
24
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
21
25
|
var mouseUpElement = event.target;
|
|
22
26
|
|
|
23
27
|
// terminate early if mouse down and mouse up elements are the same -> e.g a click event
|
|
@@ -234,7 +234,10 @@ var setSelectionInsideAtNodeStart = function setSelectionInsideAtNodeStart(selec
|
|
|
234
234
|
return false;
|
|
235
235
|
};
|
|
236
236
|
};
|
|
237
|
-
var setSelectionInsideAtNodeEnd = exports.setSelectionInsideAtNodeEnd = function setSelectionInsideAtNodeEnd(selectionRelativeToNode, node, from, to
|
|
237
|
+
var setSelectionInsideAtNodeEnd = exports.setSelectionInsideAtNodeEnd = function setSelectionInsideAtNodeEnd(selectionRelativeToNode, node, from, to
|
|
238
|
+
// Ignored via go/ees005
|
|
239
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
240
|
+
) {
|
|
238
241
|
return function (state, dispatch) {
|
|
239
242
|
if ((0, _utils.isNodeEmpty)(node)) {
|
|
240
243
|
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(to), _types.SelectionDirection.Before)(state, dispatch);
|
|
@@ -55,7 +55,9 @@ var isProblematicNode = function isProblematicNode(node, _ref2) {
|
|
|
55
55
|
__livePage: __livePage
|
|
56
56
|
}) || isBodiedExtension(node) || isTable(node);
|
|
57
57
|
};
|
|
58
|
-
var findFixedProblematicNodePosition = function findFixedProblematicNodePosition(doc, $head, direction, _ref3
|
|
58
|
+
var findFixedProblematicNodePosition = function findFixedProblematicNodePosition(doc, $head, direction, _ref3 // Ignored via go/ees005
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
60
|
+
) {
|
|
59
61
|
var __livePage = _ref3.__livePage;
|
|
60
62
|
if ($head.pos === 0 || $head.depth === 0) {
|
|
61
63
|
return null;
|
|
@@ -121,6 +121,8 @@ var arrow = exports.arrow = function arrow(dir, endOfTextblock) {
|
|
|
121
121
|
}
|
|
122
122
|
if (view) {
|
|
123
123
|
var domAtPos = view.domAtPos.bind(view);
|
|
124
|
+
// Ignored via go/ees005
|
|
125
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
124
126
|
var target = (0, _utils2.findDomRefAtPos)($pos.pos, domAtPos);
|
|
125
127
|
if (target && target.textContent === _whitespace.ZERO_WIDTH_SPACE) {
|
|
126
128
|
return false;
|
|
@@ -173,7 +175,10 @@ var deleteNode = exports.deleteNode = function deleteNode(dir) {
|
|
|
173
175
|
|
|
174
176
|
// This function captures clicks outside of the ProseMirror contentEditable area
|
|
175
177
|
// see also description of "handleClick" in gap-cursor pm-plugin
|
|
176
|
-
var captureCursorCoords = function captureCursorCoords(event, editorRef, posAtCoords, tr
|
|
178
|
+
var captureCursorCoords = function captureCursorCoords(event, editorRef, posAtCoords, tr
|
|
179
|
+
// Ignored via go/ees005
|
|
180
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
181
|
+
) {
|
|
177
182
|
var rect = editorRef.getBoundingClientRect();
|
|
178
183
|
|
|
179
184
|
// capture clicks before the first block element
|
|
@@ -210,11 +215,17 @@ var captureCursorCoords = function captureCursorCoords(event, editorRef, posAtCo
|
|
|
210
215
|
}
|
|
211
216
|
return null;
|
|
212
217
|
};
|
|
213
|
-
var setSelectionTopLevelBlocks = exports.setSelectionTopLevelBlocks = function setSelectionTopLevelBlocks(tr, event, editorRef, posAtCoords, editorFocused
|
|
218
|
+
var setSelectionTopLevelBlocks = exports.setSelectionTopLevelBlocks = function setSelectionTopLevelBlocks(tr, event, editorRef, posAtCoords, editorFocused
|
|
219
|
+
// Ignored via go/ees005
|
|
220
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
221
|
+
) {
|
|
214
222
|
var cursorCoords = captureCursorCoords(event, editorRef, posAtCoords, tr);
|
|
215
223
|
if (!cursorCoords) {
|
|
216
224
|
return;
|
|
217
225
|
}
|
|
226
|
+
|
|
227
|
+
// Ignored via go/ees005
|
|
228
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
218
229
|
var $pos = cursorCoords.position !== undefined ? tr.doc.resolve(cursorCoords.position) : null;
|
|
219
230
|
if ($pos === null) {
|
|
220
231
|
return;
|
|
@@ -237,7 +248,10 @@ var setSelectionTopLevelBlocks = exports.setSelectionTopLevelBlocks = function s
|
|
|
237
248
|
}
|
|
238
249
|
}
|
|
239
250
|
};
|
|
240
|
-
var setCursorForTopLevelBlocks = exports.setCursorForTopLevelBlocks = function setCursorForTopLevelBlocks(event, editorRef, posAtCoords, editorFocused
|
|
251
|
+
var setCursorForTopLevelBlocks = exports.setCursorForTopLevelBlocks = function setCursorForTopLevelBlocks(event, editorRef, posAtCoords, editorFocused
|
|
252
|
+
// Ignored via go/ees005
|
|
253
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
254
|
+
) {
|
|
241
255
|
return function (state, dispatch) {
|
|
242
256
|
var tr = state.tr;
|
|
243
257
|
setSelectionTopLevelBlocks(tr, event, editorRef, posAtCoords, editorFocused);
|
|
@@ -14,6 +14,9 @@ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
|
14
14
|
var isLeftCursor = exports.isLeftCursor = function isLeftCursor(side) {
|
|
15
15
|
return side === _selection.Side.LEFT;
|
|
16
16
|
};
|
|
17
|
+
|
|
18
|
+
// Ignored via go/ees005
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
17
20
|
function getMediaNearPos(doc, $pos, schema) {
|
|
18
21
|
var dir = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : -1;
|
|
19
22
|
var $currentPos = $pos;
|
|
@@ -37,6 +40,9 @@ function getMediaNearPos(doc, $pos, schema) {
|
|
|
37
40
|
} while ($currentPos.depth > 0);
|
|
38
41
|
return null;
|
|
39
42
|
}
|
|
43
|
+
|
|
44
|
+
// Ignored via go/ees005
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
40
46
|
var isTextBlockNearPos = exports.isTextBlockNearPos = function isTextBlockNearPos(doc, schema, $pos, dir) {
|
|
41
47
|
var $currentPos = $pos;
|
|
42
48
|
var currentNode = dir === -1 ? $currentPos.nodeBefore : $currentPos.nodeAfter;
|
|
@@ -107,6 +113,8 @@ var isIgnoredClick = exports.isIgnoredClick = function isIgnoredClick(elem) {
|
|
|
107
113
|
tableWrap = node;
|
|
108
114
|
break;
|
|
109
115
|
}
|
|
116
|
+
// Ignored via go/ees005
|
|
117
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
110
118
|
node = node.parentNode;
|
|
111
119
|
}
|
|
112
120
|
if (tableWrap) {
|
|
@@ -12,7 +12,10 @@ var _actions = require("./gap-cursor/actions");
|
|
|
12
12
|
var _direction = require("./gap-cursor/direction");
|
|
13
13
|
function keymapPlugin() {
|
|
14
14
|
var map = {};
|
|
15
|
-
(0, _keymaps.bindKeymapWithCommand)(
|
|
15
|
+
(0, _keymaps.bindKeymapWithCommand)(
|
|
16
|
+
// Ignored via go/ees005
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
18
|
+
_keymaps.insertNewLine.common, function (state, dispatch, view) {
|
|
16
19
|
var isInGapCursor = state.selection instanceof _selection.GapCursorSelection;
|
|
17
20
|
// Only operate in gap cursor
|
|
18
21
|
if (!isInGapCursor) {
|
|
@@ -20,27 +23,43 @@ function keymapPlugin() {
|
|
|
20
23
|
}
|
|
21
24
|
return (0, _commands.createParagraphNear)(state, dispatch);
|
|
22
25
|
}, map);
|
|
23
|
-
(0, _keymaps.bindKeymapWithCommand)(
|
|
26
|
+
(0, _keymaps.bindKeymapWithCommand)(
|
|
27
|
+
// Ignored via go/ees005
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
29
|
+
_keymaps.moveLeft.common, function (state, dispatch, view) {
|
|
24
30
|
var endOfTextblock = view ? view.endOfTextblock.bind(view) : undefined;
|
|
25
31
|
return (0, _actions.arrow)(_direction.Direction.LEFT, endOfTextblock)(state, dispatch, view);
|
|
26
32
|
}, map);
|
|
27
|
-
(0, _keymaps.bindKeymapWithCommand)(
|
|
33
|
+
(0, _keymaps.bindKeymapWithCommand)(
|
|
34
|
+
// Ignored via go/ees005
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
36
|
+
_keymaps.moveRight.common, function (state, dispatch, view) {
|
|
28
37
|
var endOfTextblock = view ? view.endOfTextblock.bind(view) : undefined;
|
|
29
38
|
return (0, _actions.arrow)(_direction.Direction.RIGHT, endOfTextblock)(state, dispatch);
|
|
30
39
|
}, map);
|
|
31
|
-
(0, _keymaps.bindKeymapWithCommand)(
|
|
40
|
+
(0, _keymaps.bindKeymapWithCommand)(
|
|
41
|
+
// Ignored via go/ees005
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
43
|
+
_keymaps.moveUp.common, function (state, dispatch, view) {
|
|
32
44
|
var endOfTextblock = view ? view.endOfTextblock.bind(view) : undefined;
|
|
33
45
|
return (0, _actions.arrow)(_direction.Direction.UP, endOfTextblock)(state, dispatch);
|
|
34
46
|
}, map);
|
|
35
|
-
(0, _keymaps.bindKeymapWithCommand)(
|
|
47
|
+
(0, _keymaps.bindKeymapWithCommand)(
|
|
48
|
+
// Ignored via go/ees005
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
50
|
+
_keymaps.moveDown.common, function (state, dispatch, view) {
|
|
36
51
|
var endOfTextblock = view ? view.endOfTextblock.bind(view) : undefined;
|
|
37
52
|
return (0, _actions.arrow)(_direction.Direction.DOWN, endOfTextblock)(state, dispatch);
|
|
38
53
|
}, map);
|
|
39
54
|
|
|
40
55
|
// default PM's Backspace doesn't handle removing block nodes when cursor is after it
|
|
56
|
+
// Ignored via go/ees005
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
41
58
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.backspace.common, (0, _actions.deleteNode)(_direction.Direction.BACKWARD), map);
|
|
42
59
|
|
|
43
60
|
// handle Delete key (remove node after the cursor)
|
|
61
|
+
// Ignored via go/ees005
|
|
62
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
44
63
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.deleteKey.common, (0, _actions.deleteNode)(_direction.Direction.FORWARD), map);
|
|
45
64
|
return (0, _keymap.keymap)(map);
|
|
46
65
|
}
|
|
@@ -24,6 +24,8 @@ var plugin = new _safePlugin.SafePlugin({
|
|
|
24
24
|
displayGapCursor: true
|
|
25
25
|
};
|
|
26
26
|
},
|
|
27
|
+
// Ignored via go/ees005
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
27
29
|
apply: function apply(tr, pluginState, _oldState, newState) {
|
|
28
30
|
var _meta$displayGapCurso;
|
|
29
31
|
var meta = tr.getMeta(_gapCursorPluginKey.gapCursorPluginKey);
|
|
@@ -146,6 +148,8 @@ var plugin = new _safePlugin.SafePlugin({
|
|
|
146
148
|
* certain nodes. We can remove these when PM has better composition support.
|
|
147
149
|
* @see https://github.com/ProseMirror/prosemirror/issues/543
|
|
148
150
|
*/
|
|
151
|
+
// Ignored via go/ees005
|
|
152
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
149
153
|
beforeinput: function beforeinput(view, event) {
|
|
150
154
|
if (event.inputType === 'deleteContentBackward' && view.state.selection instanceof _selection.GapCursorSelection) {
|
|
151
155
|
event.preventDefault();
|
|
@@ -9,7 +9,13 @@ var _keymap = require("@atlaskit/editor-prosemirror/keymap");
|
|
|
9
9
|
var _commands = require("./commands");
|
|
10
10
|
function keymapPlugin() {
|
|
11
11
|
var list = {};
|
|
12
|
+
|
|
13
|
+
// Ignored via go/ees005
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
12
15
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.moveRight.common, _commands.arrowRight, list);
|
|
16
|
+
|
|
17
|
+
// Ignored via go/ees005
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
13
19
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.moveLeft.common, _commands.arrowLeft, list);
|
|
14
20
|
return (0, _keymap.keymap)(list);
|
|
15
21
|
}
|
|
@@ -9,9 +9,13 @@ export const createAutoExpandSelectionRangeOnInlineNodePlugin = () => {
|
|
|
9
9
|
props: {
|
|
10
10
|
handleDOMEvents: {
|
|
11
11
|
mousedown: (_view, event) => {
|
|
12
|
+
// Ignored via go/ees005
|
|
13
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
12
14
|
mouseDownElement = event.target;
|
|
13
15
|
},
|
|
14
16
|
mouseup: (view, event) => {
|
|
17
|
+
// Ignored via go/ees005
|
|
18
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
15
19
|
const mouseUpElement = event.target;
|
|
16
20
|
|
|
17
21
|
// terminate early if mouse down and mouse up elements are the same -> e.g a click event
|
|
@@ -226,7 +226,10 @@ const setSelectionInsideAtNodeStart = (selectionRelativeToNode, node, pos) => (s
|
|
|
226
226
|
}
|
|
227
227
|
return false;
|
|
228
228
|
};
|
|
229
|
-
export const setSelectionInsideAtNodeEnd = (selectionRelativeToNode, node, from, to
|
|
229
|
+
export const setSelectionInsideAtNodeEnd = (selectionRelativeToNode, node, from, to
|
|
230
|
+
// Ignored via go/ees005
|
|
231
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
232
|
+
) => (state, dispatch) => {
|
|
230
233
|
if (isNodeEmpty(node)) {
|
|
231
234
|
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(to), SelectionDirection.Before)(state, dispatch);
|
|
232
235
|
}
|
|
@@ -54,7 +54,10 @@ const isProblematicNode = (node, {
|
|
|
54
54
|
};
|
|
55
55
|
const findFixedProblematicNodePosition = (doc, $head, direction, {
|
|
56
56
|
__livePage
|
|
57
|
-
}
|
|
57
|
+
}
|
|
58
|
+
// Ignored via go/ees005
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
60
|
+
) => {
|
|
58
61
|
if ($head.pos === 0 || $head.depth === 0) {
|
|
59
62
|
return null;
|
|
60
63
|
}
|
|
@@ -44,7 +44,7 @@ function handleMediaGapCursor(dir, state) {
|
|
|
44
44
|
selection,
|
|
45
45
|
tr
|
|
46
46
|
} = state;
|
|
47
|
-
|
|
47
|
+
const $pos = isBackward(dir) ? selection.$from : selection.$to;
|
|
48
48
|
if (dir === Direction.UP && selection.$from.nodeBefore && isMediaNode(selection.$from.nodeBefore)) {
|
|
49
49
|
var _tr$doc$nodeAt;
|
|
50
50
|
const nodeBeforePos = findPositionOfNodeBefore(tr.selection);
|
|
@@ -122,6 +122,8 @@ export const arrow = (dir, endOfTextblock) => (state, dispatch, view) => {
|
|
|
122
122
|
}
|
|
123
123
|
if (view) {
|
|
124
124
|
const domAtPos = view.domAtPos.bind(view);
|
|
125
|
+
// Ignored via go/ees005
|
|
126
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
125
127
|
const target = findDomRefAtPos($pos.pos, domAtPos);
|
|
126
128
|
if (target && target.textContent === ZERO_WIDTH_SPACE) {
|
|
127
129
|
return false;
|
|
@@ -174,7 +176,10 @@ export const deleteNode = dir => (state, dispatch) => {
|
|
|
174
176
|
|
|
175
177
|
// This function captures clicks outside of the ProseMirror contentEditable area
|
|
176
178
|
// see also description of "handleClick" in gap-cursor pm-plugin
|
|
177
|
-
const captureCursorCoords = (event, editorRef, posAtCoords, tr
|
|
179
|
+
const captureCursorCoords = (event, editorRef, posAtCoords, tr
|
|
180
|
+
// Ignored via go/ees005
|
|
181
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
182
|
+
) => {
|
|
178
183
|
const rect = editorRef.getBoundingClientRect();
|
|
179
184
|
|
|
180
185
|
// capture clicks before the first block element
|
|
@@ -211,11 +216,17 @@ const captureCursorCoords = (event, editorRef, posAtCoords, tr) => {
|
|
|
211
216
|
}
|
|
212
217
|
return null;
|
|
213
218
|
};
|
|
214
|
-
export const setSelectionTopLevelBlocks = (tr, event, editorRef, posAtCoords, editorFocused
|
|
219
|
+
export const setSelectionTopLevelBlocks = (tr, event, editorRef, posAtCoords, editorFocused
|
|
220
|
+
// Ignored via go/ees005
|
|
221
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
222
|
+
) => {
|
|
215
223
|
const cursorCoords = captureCursorCoords(event, editorRef, posAtCoords, tr);
|
|
216
224
|
if (!cursorCoords) {
|
|
217
225
|
return;
|
|
218
226
|
}
|
|
227
|
+
|
|
228
|
+
// Ignored via go/ees005
|
|
229
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
219
230
|
const $pos = cursorCoords.position !== undefined ? tr.doc.resolve(cursorCoords.position) : null;
|
|
220
231
|
if ($pos === null) {
|
|
221
232
|
return;
|
|
@@ -238,7 +249,10 @@ export const setSelectionTopLevelBlocks = (tr, event, editorRef, posAtCoords, ed
|
|
|
238
249
|
}
|
|
239
250
|
}
|
|
240
251
|
};
|
|
241
|
-
export const setCursorForTopLevelBlocks = (event, editorRef, posAtCoords, editorFocused
|
|
252
|
+
export const setCursorForTopLevelBlocks = (event, editorRef, posAtCoords, editorFocused
|
|
253
|
+
// Ignored via go/ees005
|
|
254
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
255
|
+
) => (state, dispatch) => {
|
|
242
256
|
const {
|
|
243
257
|
tr
|
|
244
258
|
} = state;
|
|
@@ -3,6 +3,9 @@ import { Side } from '@atlaskit/editor-common/selection';
|
|
|
3
3
|
import { TableSharedCssClassName, UnsupportedSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
4
4
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
5
5
|
export const isLeftCursor = side => side === Side.LEFT;
|
|
6
|
+
|
|
7
|
+
// Ignored via go/ees005
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
6
9
|
export function getMediaNearPos(doc, $pos, schema, dir = -1) {
|
|
7
10
|
let $currentPos = $pos;
|
|
8
11
|
let currentNode = null;
|
|
@@ -26,6 +29,9 @@ export function getMediaNearPos(doc, $pos, schema, dir = -1) {
|
|
|
26
29
|
} while ($currentPos.depth > 0);
|
|
27
30
|
return null;
|
|
28
31
|
}
|
|
32
|
+
|
|
33
|
+
// Ignored via go/ees005
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
29
35
|
export const isTextBlockNearPos = (doc, schema, $pos, dir) => {
|
|
30
36
|
let $currentPos = $pos;
|
|
31
37
|
let currentNode = dir === -1 ? $currentPos.nodeBefore : $currentPos.nodeAfter;
|
|
@@ -94,6 +100,8 @@ export const isIgnoredClick = elem => {
|
|
|
94
100
|
tableWrap = node;
|
|
95
101
|
break;
|
|
96
102
|
}
|
|
103
|
+
// Ignored via go/ees005
|
|
104
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
97
105
|
node = node.parentNode;
|
|
98
106
|
}
|
|
99
107
|
if (tableWrap) {
|
|
@@ -6,7 +6,10 @@ import { arrow, deleteNode } from './gap-cursor/actions';
|
|
|
6
6
|
import { Direction } from './gap-cursor/direction';
|
|
7
7
|
export default function keymapPlugin() {
|
|
8
8
|
const map = {};
|
|
9
|
-
bindKeymapWithCommand(
|
|
9
|
+
bindKeymapWithCommand(
|
|
10
|
+
// Ignored via go/ees005
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
12
|
+
insertNewLine.common, (state, dispatch, view) => {
|
|
10
13
|
const isInGapCursor = state.selection instanceof GapCursorSelection;
|
|
11
14
|
// Only operate in gap cursor
|
|
12
15
|
if (!isInGapCursor) {
|
|
@@ -14,27 +17,43 @@ export default function keymapPlugin() {
|
|
|
14
17
|
}
|
|
15
18
|
return createParagraphNear(state, dispatch);
|
|
16
19
|
}, map);
|
|
17
|
-
bindKeymapWithCommand(
|
|
20
|
+
bindKeymapWithCommand(
|
|
21
|
+
// Ignored via go/ees005
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
23
|
+
moveLeft.common, (state, dispatch, view) => {
|
|
18
24
|
const endOfTextblock = view ? view.endOfTextblock.bind(view) : undefined;
|
|
19
25
|
return arrow(Direction.LEFT, endOfTextblock)(state, dispatch, view);
|
|
20
26
|
}, map);
|
|
21
|
-
bindKeymapWithCommand(
|
|
27
|
+
bindKeymapWithCommand(
|
|
28
|
+
// Ignored via go/ees005
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
30
|
+
moveRight.common, (state, dispatch, view) => {
|
|
22
31
|
const endOfTextblock = view ? view.endOfTextblock.bind(view) : undefined;
|
|
23
32
|
return arrow(Direction.RIGHT, endOfTextblock)(state, dispatch);
|
|
24
33
|
}, map);
|
|
25
|
-
bindKeymapWithCommand(
|
|
34
|
+
bindKeymapWithCommand(
|
|
35
|
+
// Ignored via go/ees005
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
37
|
+
moveUp.common, (state, dispatch, view) => {
|
|
26
38
|
const endOfTextblock = view ? view.endOfTextblock.bind(view) : undefined;
|
|
27
39
|
return arrow(Direction.UP, endOfTextblock)(state, dispatch);
|
|
28
40
|
}, map);
|
|
29
|
-
bindKeymapWithCommand(
|
|
41
|
+
bindKeymapWithCommand(
|
|
42
|
+
// Ignored via go/ees005
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
44
|
+
moveDown.common, (state, dispatch, view) => {
|
|
30
45
|
const endOfTextblock = view ? view.endOfTextblock.bind(view) : undefined;
|
|
31
46
|
return arrow(Direction.DOWN, endOfTextblock)(state, dispatch);
|
|
32
47
|
}, map);
|
|
33
48
|
|
|
34
49
|
// default PM's Backspace doesn't handle removing block nodes when cursor is after it
|
|
50
|
+
// Ignored via go/ees005
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
35
52
|
bindKeymapWithCommand(backspace.common, deleteNode(Direction.BACKWARD), map);
|
|
36
53
|
|
|
37
54
|
// handle Delete key (remove node after the cursor)
|
|
55
|
+
// Ignored via go/ees005
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
38
57
|
bindKeymapWithCommand(deleteKey.common, deleteNode(Direction.FORWARD), map);
|
|
39
58
|
return keymap(map);
|
|
40
59
|
}
|
|
@@ -16,6 +16,8 @@ const plugin = new SafePlugin({
|
|
|
16
16
|
selectionIsGapCursor: false,
|
|
17
17
|
displayGapCursor: true
|
|
18
18
|
}),
|
|
19
|
+
// Ignored via go/ees005
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
19
21
|
apply: (tr, pluginState, _oldState, newState) => {
|
|
20
22
|
var _meta$displayGapCurso;
|
|
21
23
|
const meta = tr.getMeta(gapCursorPluginKey);
|
|
@@ -144,6 +146,8 @@ const plugin = new SafePlugin({
|
|
|
144
146
|
* certain nodes. We can remove these when PM has better composition support.
|
|
145
147
|
* @see https://github.com/ProseMirror/prosemirror/issues/543
|
|
146
148
|
*/
|
|
149
|
+
// Ignored via go/ees005
|
|
150
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
147
151
|
beforeinput: (view, event) => {
|
|
148
152
|
if (event.inputType === 'deleteContentBackward' && view.state.selection instanceof GapCursorSelection) {
|
|
149
153
|
event.preventDefault();
|
|
@@ -3,7 +3,13 @@ import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
|
3
3
|
import { arrowLeft, arrowRight } from './commands';
|
|
4
4
|
function keymapPlugin() {
|
|
5
5
|
const list = {};
|
|
6
|
+
|
|
7
|
+
// Ignored via go/ees005
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
6
9
|
bindKeymapWithCommand(moveRight.common, arrowRight, list);
|
|
10
|
+
|
|
11
|
+
// Ignored via go/ees005
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
7
13
|
bindKeymapWithCommand(moveLeft.common, arrowLeft, list);
|
|
8
14
|
return keymap(list);
|
|
9
15
|
}
|
|
@@ -9,9 +9,13 @@ export var createAutoExpandSelectionRangeOnInlineNodePlugin = function createAut
|
|
|
9
9
|
props: {
|
|
10
10
|
handleDOMEvents: {
|
|
11
11
|
mousedown: function mousedown(_view, event) {
|
|
12
|
+
// Ignored via go/ees005
|
|
13
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
12
14
|
mouseDownElement = event.target;
|
|
13
15
|
},
|
|
14
16
|
mouseup: function mouseup(view, event) {
|
|
17
|
+
// Ignored via go/ees005
|
|
18
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
15
19
|
var mouseUpElement = event.target;
|
|
16
20
|
|
|
17
21
|
// terminate early if mouse down and mouse up elements are the same -> e.g a click event
|
|
@@ -227,7 +227,10 @@ var setSelectionInsideAtNodeStart = function setSelectionInsideAtNodeStart(selec
|
|
|
227
227
|
return false;
|
|
228
228
|
};
|
|
229
229
|
};
|
|
230
|
-
export var setSelectionInsideAtNodeEnd = function setSelectionInsideAtNodeEnd(selectionRelativeToNode, node, from, to
|
|
230
|
+
export var setSelectionInsideAtNodeEnd = function setSelectionInsideAtNodeEnd(selectionRelativeToNode, node, from, to
|
|
231
|
+
// Ignored via go/ees005
|
|
232
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
233
|
+
) {
|
|
231
234
|
return function (state, dispatch) {
|
|
232
235
|
if (isNodeEmpty(node)) {
|
|
233
236
|
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(to), SelectionDirection.Before)(state, dispatch);
|
|
@@ -50,7 +50,9 @@ var isProblematicNode = function isProblematicNode(node, _ref2) {
|
|
|
50
50
|
__livePage: __livePage
|
|
51
51
|
}) || isBodiedExtension(node) || isTable(node);
|
|
52
52
|
};
|
|
53
|
-
var findFixedProblematicNodePosition = function findFixedProblematicNodePosition(doc, $head, direction, _ref3
|
|
53
|
+
var findFixedProblematicNodePosition = function findFixedProblematicNodePosition(doc, $head, direction, _ref3 // Ignored via go/ees005
|
|
54
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
55
|
+
) {
|
|
54
56
|
var __livePage = _ref3.__livePage;
|
|
55
57
|
if ($head.pos === 0 || $head.depth === 0) {
|
|
56
58
|
return null;
|
|
@@ -115,6 +115,8 @@ export var arrow = function arrow(dir, endOfTextblock) {
|
|
|
115
115
|
}
|
|
116
116
|
if (view) {
|
|
117
117
|
var domAtPos = view.domAtPos.bind(view);
|
|
118
|
+
// Ignored via go/ees005
|
|
119
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
118
120
|
var target = findDomRefAtPos($pos.pos, domAtPos);
|
|
119
121
|
if (target && target.textContent === ZERO_WIDTH_SPACE) {
|
|
120
122
|
return false;
|
|
@@ -167,7 +169,10 @@ export var deleteNode = function deleteNode(dir) {
|
|
|
167
169
|
|
|
168
170
|
// This function captures clicks outside of the ProseMirror contentEditable area
|
|
169
171
|
// see also description of "handleClick" in gap-cursor pm-plugin
|
|
170
|
-
var captureCursorCoords = function captureCursorCoords(event, editorRef, posAtCoords, tr
|
|
172
|
+
var captureCursorCoords = function captureCursorCoords(event, editorRef, posAtCoords, tr
|
|
173
|
+
// Ignored via go/ees005
|
|
174
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
175
|
+
) {
|
|
171
176
|
var rect = editorRef.getBoundingClientRect();
|
|
172
177
|
|
|
173
178
|
// capture clicks before the first block element
|
|
@@ -204,11 +209,17 @@ var captureCursorCoords = function captureCursorCoords(event, editorRef, posAtCo
|
|
|
204
209
|
}
|
|
205
210
|
return null;
|
|
206
211
|
};
|
|
207
|
-
export var setSelectionTopLevelBlocks = function setSelectionTopLevelBlocks(tr, event, editorRef, posAtCoords, editorFocused
|
|
212
|
+
export var setSelectionTopLevelBlocks = function setSelectionTopLevelBlocks(tr, event, editorRef, posAtCoords, editorFocused
|
|
213
|
+
// Ignored via go/ees005
|
|
214
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
215
|
+
) {
|
|
208
216
|
var cursorCoords = captureCursorCoords(event, editorRef, posAtCoords, tr);
|
|
209
217
|
if (!cursorCoords) {
|
|
210
218
|
return;
|
|
211
219
|
}
|
|
220
|
+
|
|
221
|
+
// Ignored via go/ees005
|
|
222
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
212
223
|
var $pos = cursorCoords.position !== undefined ? tr.doc.resolve(cursorCoords.position) : null;
|
|
213
224
|
if ($pos === null) {
|
|
214
225
|
return;
|
|
@@ -231,7 +242,10 @@ export var setSelectionTopLevelBlocks = function setSelectionTopLevelBlocks(tr,
|
|
|
231
242
|
}
|
|
232
243
|
}
|
|
233
244
|
};
|
|
234
|
-
export var setCursorForTopLevelBlocks = function setCursorForTopLevelBlocks(event, editorRef, posAtCoords, editorFocused
|
|
245
|
+
export var setCursorForTopLevelBlocks = function setCursorForTopLevelBlocks(event, editorRef, posAtCoords, editorFocused
|
|
246
|
+
// Ignored via go/ees005
|
|
247
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
248
|
+
) {
|
|
235
249
|
return function (state, dispatch) {
|
|
236
250
|
var tr = state.tr;
|
|
237
251
|
setSelectionTopLevelBlocks(tr, event, editorRef, posAtCoords, editorFocused);
|
|
@@ -5,6 +5,9 @@ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
|
5
5
|
export var isLeftCursor = function isLeftCursor(side) {
|
|
6
6
|
return side === Side.LEFT;
|
|
7
7
|
};
|
|
8
|
+
|
|
9
|
+
// Ignored via go/ees005
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
8
11
|
export function getMediaNearPos(doc, $pos, schema) {
|
|
9
12
|
var dir = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : -1;
|
|
10
13
|
var $currentPos = $pos;
|
|
@@ -28,6 +31,9 @@ export function getMediaNearPos(doc, $pos, schema) {
|
|
|
28
31
|
} while ($currentPos.depth > 0);
|
|
29
32
|
return null;
|
|
30
33
|
}
|
|
34
|
+
|
|
35
|
+
// Ignored via go/ees005
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
31
37
|
export var isTextBlockNearPos = function isTextBlockNearPos(doc, schema, $pos, dir) {
|
|
32
38
|
var $currentPos = $pos;
|
|
33
39
|
var currentNode = dir === -1 ? $currentPos.nodeBefore : $currentPos.nodeAfter;
|
|
@@ -98,6 +104,8 @@ export var isIgnoredClick = function isIgnoredClick(elem) {
|
|
|
98
104
|
tableWrap = node;
|
|
99
105
|
break;
|
|
100
106
|
}
|
|
107
|
+
// Ignored via go/ees005
|
|
108
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
101
109
|
node = node.parentNode;
|
|
102
110
|
}
|
|
103
111
|
if (tableWrap) {
|
|
@@ -6,7 +6,10 @@ import { arrow, deleteNode } from './gap-cursor/actions';
|
|
|
6
6
|
import { Direction } from './gap-cursor/direction';
|
|
7
7
|
export default function keymapPlugin() {
|
|
8
8
|
var map = {};
|
|
9
|
-
bindKeymapWithCommand(
|
|
9
|
+
bindKeymapWithCommand(
|
|
10
|
+
// Ignored via go/ees005
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
12
|
+
insertNewLine.common, function (state, dispatch, view) {
|
|
10
13
|
var isInGapCursor = state.selection instanceof GapCursorSelection;
|
|
11
14
|
// Only operate in gap cursor
|
|
12
15
|
if (!isInGapCursor) {
|
|
@@ -14,27 +17,43 @@ export default function keymapPlugin() {
|
|
|
14
17
|
}
|
|
15
18
|
return createParagraphNear(state, dispatch);
|
|
16
19
|
}, map);
|
|
17
|
-
bindKeymapWithCommand(
|
|
20
|
+
bindKeymapWithCommand(
|
|
21
|
+
// Ignored via go/ees005
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
23
|
+
moveLeft.common, function (state, dispatch, view) {
|
|
18
24
|
var endOfTextblock = view ? view.endOfTextblock.bind(view) : undefined;
|
|
19
25
|
return arrow(Direction.LEFT, endOfTextblock)(state, dispatch, view);
|
|
20
26
|
}, map);
|
|
21
|
-
bindKeymapWithCommand(
|
|
27
|
+
bindKeymapWithCommand(
|
|
28
|
+
// Ignored via go/ees005
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
30
|
+
moveRight.common, function (state, dispatch, view) {
|
|
22
31
|
var endOfTextblock = view ? view.endOfTextblock.bind(view) : undefined;
|
|
23
32
|
return arrow(Direction.RIGHT, endOfTextblock)(state, dispatch);
|
|
24
33
|
}, map);
|
|
25
|
-
bindKeymapWithCommand(
|
|
34
|
+
bindKeymapWithCommand(
|
|
35
|
+
// Ignored via go/ees005
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
37
|
+
moveUp.common, function (state, dispatch, view) {
|
|
26
38
|
var endOfTextblock = view ? view.endOfTextblock.bind(view) : undefined;
|
|
27
39
|
return arrow(Direction.UP, endOfTextblock)(state, dispatch);
|
|
28
40
|
}, map);
|
|
29
|
-
bindKeymapWithCommand(
|
|
41
|
+
bindKeymapWithCommand(
|
|
42
|
+
// Ignored via go/ees005
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
44
|
+
moveDown.common, function (state, dispatch, view) {
|
|
30
45
|
var endOfTextblock = view ? view.endOfTextblock.bind(view) : undefined;
|
|
31
46
|
return arrow(Direction.DOWN, endOfTextblock)(state, dispatch);
|
|
32
47
|
}, map);
|
|
33
48
|
|
|
34
49
|
// default PM's Backspace doesn't handle removing block nodes when cursor is after it
|
|
50
|
+
// Ignored via go/ees005
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
35
52
|
bindKeymapWithCommand(backspace.common, deleteNode(Direction.BACKWARD), map);
|
|
36
53
|
|
|
37
54
|
// handle Delete key (remove node after the cursor)
|
|
55
|
+
// Ignored via go/ees005
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
38
57
|
bindKeymapWithCommand(deleteKey.common, deleteNode(Direction.FORWARD), map);
|
|
39
58
|
return keymap(map);
|
|
40
59
|
}
|
|
@@ -18,6 +18,8 @@ var plugin = new SafePlugin({
|
|
|
18
18
|
displayGapCursor: true
|
|
19
19
|
};
|
|
20
20
|
},
|
|
21
|
+
// Ignored via go/ees005
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
21
23
|
apply: function apply(tr, pluginState, _oldState, newState) {
|
|
22
24
|
var _meta$displayGapCurso;
|
|
23
25
|
var meta = tr.getMeta(gapCursorPluginKey);
|
|
@@ -140,6 +142,8 @@ var plugin = new SafePlugin({
|
|
|
140
142
|
* certain nodes. We can remove these when PM has better composition support.
|
|
141
143
|
* @see https://github.com/ProseMirror/prosemirror/issues/543
|
|
142
144
|
*/
|
|
145
|
+
// Ignored via go/ees005
|
|
146
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
143
147
|
beforeinput: function beforeinput(view, event) {
|
|
144
148
|
if (event.inputType === 'deleteContentBackward' && view.state.selection instanceof GapCursorSelection) {
|
|
145
149
|
event.preventDefault();
|
|
@@ -3,7 +3,13 @@ import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
|
3
3
|
import { arrowLeft, arrowRight } from './commands';
|
|
4
4
|
function keymapPlugin() {
|
|
5
5
|
var list = {};
|
|
6
|
+
|
|
7
|
+
// Ignored via go/ees005
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
6
9
|
bindKeymapWithCommand(moveRight.common, arrowRight, list);
|
|
10
|
+
|
|
11
|
+
// Ignored via go/ees005
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
7
13
|
bindKeymapWithCommand(moveLeft.common, arrowLeft, list);
|
|
8
14
|
return keymap(list);
|
|
9
15
|
}
|
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.9",
|
|
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": "^97.
|
|
23
|
+
"@atlaskit/editor-common": "^97.3.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.31.0",
|
|
29
29
|
"@atlaskit/tokens": "^2.5.0",
|
|
30
30
|
"@babel/runtime": "^7.0.0"
|
|
31
31
|
},
|