@atlaskit/editor-core 187.46.1 → 187.47.0

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.
Files changed (89) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/cjs/index.js +3 -3
  3. package/dist/cjs/plugins/caption/pm-plugins/keymap.js +1 -1
  4. package/dist/cjs/plugins/code-block/pm-plugins/main.js +7 -7
  5. package/dist/cjs/plugins/expand/commands.js +2 -2
  6. package/dist/cjs/plugins/expand/index.js +6 -2
  7. package/dist/cjs/plugins/expand/nodeviews/index.js +26 -23
  8. package/dist/cjs/plugins/expand/pm-plugins/keymap.js +10 -12
  9. package/dist/cjs/plugins/expand/pm-plugins/main.js +9 -6
  10. package/dist/cjs/plugins/extension/pm-plugins/main.js +8 -9
  11. package/dist/cjs/plugins/layout/pm-plugins/main.js +2 -2
  12. package/dist/cjs/plugins/media/toolbar/commands.js +1 -1
  13. package/dist/cjs/plugins/panel/pm-plugins/main.js +2 -2
  14. package/dist/cjs/plugins/paste/handlers.js +3 -3
  15. package/dist/cjs/plugins/selection/commands.js +27 -14
  16. package/dist/cjs/plugins/selection/gap-cursor/utils/place-gap-cursor.js +1 -1
  17. package/dist/cjs/plugins/selection/index.js +13 -1
  18. package/dist/cjs/plugins/selection/utils.js +11 -25
  19. package/dist/cjs/plugins/tasks-and-decisions/commands.js +2 -2
  20. package/dist/cjs/plugins/tasks-and-decisions/pm-plugins/main.js +2 -3
  21. package/dist/cjs/test-utils.js +1 -1
  22. package/dist/cjs/version-wrapper.js +1 -1
  23. package/dist/es2019/index.js +1 -1
  24. package/dist/es2019/plugins/caption/pm-plugins/keymap.js +1 -1
  25. package/dist/es2019/plugins/code-block/pm-plugins/main.js +1 -1
  26. package/dist/es2019/plugins/expand/commands.js +1 -1
  27. package/dist/es2019/plugins/expand/index.js +4 -2
  28. package/dist/es2019/plugins/expand/nodeviews/index.js +24 -19
  29. package/dist/es2019/plugins/expand/pm-plugins/keymap.js +6 -6
  30. package/dist/es2019/plugins/expand/pm-plugins/main.js +6 -4
  31. package/dist/es2019/plugins/extension/pm-plugins/main.js +1 -2
  32. package/dist/es2019/plugins/layout/pm-plugins/main.js +1 -1
  33. package/dist/es2019/plugins/media/toolbar/commands.js +1 -1
  34. package/dist/es2019/plugins/panel/pm-plugins/main.js +1 -1
  35. package/dist/es2019/plugins/paste/handlers.js +1 -1
  36. package/dist/es2019/plugins/selection/commands.js +17 -6
  37. package/dist/es2019/plugins/selection/gap-cursor/utils/place-gap-cursor.js +1 -1
  38. package/dist/es2019/plugins/selection/index.js +13 -1
  39. package/dist/es2019/plugins/selection/utils.js +2 -21
  40. package/dist/es2019/plugins/tasks-and-decisions/commands.js +1 -1
  41. package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/main.js +1 -1
  42. package/dist/es2019/test-utils.js +1 -1
  43. package/dist/es2019/version-wrapper.js +1 -1
  44. package/dist/esm/index.js +1 -1
  45. package/dist/esm/plugins/caption/pm-plugins/keymap.js +1 -1
  46. package/dist/esm/plugins/code-block/pm-plugins/main.js +1 -1
  47. package/dist/esm/plugins/expand/commands.js +1 -1
  48. package/dist/esm/plugins/expand/index.js +6 -2
  49. package/dist/esm/plugins/expand/nodeviews/index.js +24 -21
  50. package/dist/esm/plugins/expand/pm-plugins/keymap.js +6 -8
  51. package/dist/esm/plugins/expand/pm-plugins/main.js +6 -3
  52. package/dist/esm/plugins/extension/pm-plugins/main.js +1 -2
  53. package/dist/esm/plugins/layout/pm-plugins/main.js +1 -1
  54. package/dist/esm/plugins/media/toolbar/commands.js +1 -1
  55. package/dist/esm/plugins/panel/pm-plugins/main.js +1 -1
  56. package/dist/esm/plugins/paste/handlers.js +1 -1
  57. package/dist/esm/plugins/selection/commands.js +18 -6
  58. package/dist/esm/plugins/selection/gap-cursor/utils/place-gap-cursor.js +1 -1
  59. package/dist/esm/plugins/selection/index.js +13 -1
  60. package/dist/esm/plugins/selection/utils.js +2 -21
  61. package/dist/esm/plugins/tasks-and-decisions/commands.js +1 -1
  62. package/dist/esm/plugins/tasks-and-decisions/pm-plugins/main.js +1 -1
  63. package/dist/esm/test-utils.js +1 -1
  64. package/dist/esm/version-wrapper.js +1 -1
  65. package/dist/types/index.d.ts +1 -1
  66. package/dist/types/labs/next/presets/default.d.ts +9 -5
  67. package/dist/types/plugins/expand/index.d.ts +6 -1
  68. package/dist/types/plugins/expand/nodeviews/index.d.ts +7 -3
  69. package/dist/types/plugins/expand/pm-plugins/keymap.d.ts +3 -1
  70. package/dist/types/plugins/expand/pm-plugins/main.d.ts +3 -2
  71. package/dist/types/plugins/panel/pm-plugins/main.d.ts +3 -3
  72. package/dist/types/plugins/selection/commands.d.ts +4 -2
  73. package/dist/types/plugins/selection/index.d.ts +5 -2
  74. package/dist/types/plugins/selection/utils.d.ts +2 -7
  75. package/dist/types/test-utils.d.ts +1 -1
  76. package/dist/types-ts4.5/index.d.ts +1 -1
  77. package/dist/types-ts4.5/labs/next/presets/default.d.ts +9 -5
  78. package/dist/types-ts4.5/plugins/expand/index.d.ts +3 -1
  79. package/dist/types-ts4.5/plugins/expand/nodeviews/index.d.ts +7 -3
  80. package/dist/types-ts4.5/plugins/expand/pm-plugins/keymap.d.ts +3 -1
  81. package/dist/types-ts4.5/plugins/expand/pm-plugins/main.d.ts +3 -2
  82. package/dist/types-ts4.5/plugins/panel/pm-plugins/main.d.ts +3 -3
  83. package/dist/types-ts4.5/plugins/selection/commands.d.ts +4 -2
  84. package/dist/types-ts4.5/plugins/selection/index.d.ts +5 -2
  85. package/dist/types-ts4.5/plugins/selection/utils.d.ts +2 -7
  86. package/dist/types-ts4.5/test-utils.d.ts +1 -1
  87. package/package.json +2 -2
  88. package/report.api.md +1 -3
  89. package/tmp/api-report-tmp.d.ts +1 -4
@@ -3,24 +3,37 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.setSelectionRelativeToNode = exports.setSelectionInsideAtNodeEnd = exports.arrowRight = exports.arrowLeft = void 0;
6
+ exports.setSelectionRelativeToNode = exports.setSelectionInsideAtNodeEnd = exports.selectNearNode = exports.arrowRight = exports.arrowLeft = void 0;
7
7
  var _state = require("@atlaskit/editor-prosemirror/state");
8
8
  var _gapCursorSelection = require("./gap-cursor-selection");
9
- var _isIgnored = require("../selection/gap-cursor/utils/is-ignored");
9
+ var _selection = require("@atlaskit/editor-common/selection");
10
10
  var _utils = require("@atlaskit/editor-common/utils");
11
11
  var _actions = require("./actions");
12
12
  var _pluginFactory = require("./plugin-factory");
13
13
  var _utils2 = require("./utils");
14
14
  var _types = require("./types");
15
+ var selectNearNode = function selectNearNode(selectionRelativeToNode, selection) {
16
+ return function (_ref) {
17
+ var tr = _ref.tr;
18
+ tr.setMeta(_types.selectionPluginKey, {
19
+ type: _actions.SelectionActionTypes.SET_RELATIVE_SELECTION,
20
+ selectionRelativeToNode: selectionRelativeToNode
21
+ });
22
+ if (selection) {
23
+ return tr.setSelection(selection);
24
+ }
25
+ return tr;
26
+ };
27
+ };
28
+ exports.selectNearNode = selectNearNode;
15
29
  var setSelectionRelativeToNode = function setSelectionRelativeToNode(selectionRelativeToNode, selection) {
16
30
  return (0, _pluginFactory.createCommand)({
17
31
  type: _actions.SelectionActionTypes.SET_RELATIVE_SELECTION,
18
32
  selectionRelativeToNode: selectionRelativeToNode
19
33
  }, function (tr) {
20
- if (selection) {
21
- return tr.setSelection(selection);
22
- }
23
- return tr;
34
+ return selectNearNode(selectionRelativeToNode, selection)({
35
+ tr: tr
36
+ }) || tr;
24
37
  });
25
38
  };
26
39
  exports.setSelectionRelativeToNode = setSelectionRelativeToNode;
@@ -83,7 +96,7 @@ var arrowLeftFromGapCursor = function arrowLeftFromGapCursor(selection) {
83
96
  var $parent = state.doc.resolve(selection.$from.before(selection.$from.depth));
84
97
  if ($parent) {
85
98
  var _selectableNode2 = (0, _utils2.findSelectableContainerBefore)($parent, state.doc);
86
- if (_selectableNode2 && (0, _isIgnored.isIgnored)(_selectableNode2.node)) {
99
+ if (_selectableNode2 && (0, _selection.isIgnored)(_selectableNode2.node)) {
87
100
  // selection is inside node without gap cursor preceeded by another node without gap cursor - set node selection for previous node
88
101
  return setSelectionRelativeToNode(_types.RelativeSelectionPos.End, _state.NodeSelection.create(state.doc, _selectableNode2.pos))(state, dispatch);
89
102
  }
@@ -117,9 +130,9 @@ var arrowRightFromNode = function arrowRightFromNode(selection) {
117
130
  } else if (selectionRelativeToNode === _types.RelativeSelectionPos.Start) {
118
131
  // selection is for container node - set selection inside it at the start
119
132
  return setSelectionInsideAtNodeStart(_types.RelativeSelectionPos.Inside, node, from)(state, dispatch);
120
- } else if ((0, _isIgnored.isIgnored)(node) && (!selectionRelativeToNode || selectionRelativeToNode === _types.RelativeSelectionPos.End)) {
133
+ } else if ((0, _selection.isIgnored)(node) && (!selectionRelativeToNode || selectionRelativeToNode === _types.RelativeSelectionPos.End)) {
121
134
  var selectableNode = (0, _utils2.findSelectableContainerAfter)($to, state.doc);
122
- if (selectableNode && (0, _isIgnored.isIgnored)(selectableNode.node)) {
135
+ if (selectableNode && (0, _selection.isIgnored)(selectableNode.node)) {
123
136
  // selection is for node without gap cursor followed by another node without gap cursor - set node selection for next node
124
137
  return setSelectionRelativeToNode(_types.RelativeSelectionPos.Start, _state.NodeSelection.create(state.doc, selectableNode.pos))(state, dispatch);
125
138
  }
@@ -148,10 +161,10 @@ var arrowLeftFromNode = function arrowLeftFromNode(selection) {
148
161
  // selection is for container node - set selection inside it at the start
149
162
  // (this is a special case when the user selects by clicking node)
150
163
  return setSelectionInsideAtNodeStart(_types.RelativeSelectionPos.Before, node, from)(state, dispatch);
151
- } else if ((0, _isIgnored.isIgnored)(node) && selectionRelativeToNode === _types.RelativeSelectionPos.Start) {
164
+ } else if ((0, _selection.isIgnored)(node) && selectionRelativeToNode === _types.RelativeSelectionPos.Start) {
152
165
  // selection is for node without gap cursor preceeded by another node without gap cursor - set node selection for previous node
153
166
  var selectableNode = (0, _utils2.findSelectableContainerBefore)($from, state.doc);
154
- if (selectableNode && (0, _isIgnored.isIgnored)(selectableNode.node)) {
167
+ if (selectableNode && (0, _selection.isIgnored)(selectableNode.node)) {
155
168
  return setSelectionRelativeToNode(_types.RelativeSelectionPos.End, _state.NodeSelection.create(state.doc, selectableNode.pos))(state, dispatch);
156
169
  }
157
170
  }
@@ -175,7 +188,7 @@ var arrowLeftFromText = function arrowLeftFromText(selection) {
175
188
  selectionRelativeToNode = _getPluginState4.selectionRelativeToNode;
176
189
  if (selectionRelativeToNode === _types.RelativeSelectionPos.Before) {
177
190
  var selectableNode = (0, _utils2.findSelectableContainerBefore)(selection.$from, state.doc);
178
- if (selectableNode && (0, _isIgnored.isIgnored)(selectableNode.node)) {
191
+ if (selectableNode && (0, _selection.isIgnored)(selectableNode.node)) {
179
192
  // selection is inside node without gap cursor preceeded by another node without gap cursor - set node selection for previous node
180
193
  return setSelectionRelativeToNode(_types.RelativeSelectionPos.End, _state.NodeSelection.create(state.doc, selectableNode.pos))(state, dispatch);
181
194
  }
@@ -214,7 +227,7 @@ var setSelectionInsideAtNodeStart = function setSelectionInsideAtNodeStart(selec
214
227
  return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(selectionPos), _types.SelectionDirection.Before)(state, dispatch);
215
228
  } else if ((0, _utils.isEmptyParagraph)(childNode)) {
216
229
  return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(selectionPos + 1), _types.SelectionDirection.Before)(state, dispatch);
217
- } else if (!(0, _isIgnored.isIgnored)(node)) {
230
+ } else if (!(0, _selection.isIgnored)(node)) {
218
231
  return setSelectionRelativeToNode(selectionRelativeToNode, new _gapCursorSelection.GapCursorSelection(state.doc.resolve(selectionPos), _gapCursorSelection.Side.LEFT))(state, dispatch);
219
232
  } else if ((0, _utils2.isSelectableContainerNode)(node)) {
220
233
  return setSelectionRelativeToNode(selectionRelativeToNode, _state.NodeSelection.create(state.doc, selectionPos))(state, dispatch);
@@ -237,7 +250,7 @@ var setSelectionInsideAtNodeEnd = function setSelectionInsideAtNodeEnd(selection
237
250
  return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(selectionPos + 1), _types.SelectionDirection.After)(state, dispatch);
238
251
  } else if ((0, _utils.isEmptyParagraph)(childNode)) {
239
252
  return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(selectionPos), _types.SelectionDirection.After)(state, dispatch);
240
- } else if (!(0, _isIgnored.isIgnored)(node)) {
253
+ } else if (!(0, _selection.isIgnored)(node)) {
241
254
  return setSelectionRelativeToNode(selectionRelativeToNode, new _gapCursorSelection.GapCursorSelection(state.doc.resolve(selectionPos + 1), _gapCursorSelection.Side.RIGHT))(state, dispatch);
242
255
  } else if ((0, _utils2.isSelectableContainerNode)(node)) {
243
256
  return setSelectionRelativeToNode(selectionRelativeToNode, _state.NodeSelection.create(state.doc, selectionPos))(state, dispatch);
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.toDOM = void 0;
8
8
  var _toArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toArray"));
9
9
  var _utils = require("../utils");
10
- var _selection = require("../selection");
10
+ var _selection = require("@atlaskit/editor-common/selection");
11
11
  /**
12
12
  * We have a couple of nodes that require us to compute style
13
13
  * on different elements, ideally all nodes should be able to
@@ -6,10 +6,12 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.selectionPlugin = exports.default = void 0;
8
8
  var _selectionMain = require("./pm-plugins/selection-main");
9
+ var _types = require("./types");
9
10
  var _keymap = _interopRequireDefault(require("./pm-plugins/keymap"));
10
11
  var _gapCursorMain = _interopRequireDefault(require("./pm-plugins/gap-cursor-main"));
11
12
  var _gapCursorPluginKey = require("./pm-plugins/gap-cursor-plugin-key");
12
13
  var _gapCursorKeymap = _interopRequireDefault(require("./pm-plugins/gap-cursor-keymap"));
14
+ var _commands = require("./commands");
13
15
  var displayGapCursor = function displayGapCursor(toggle) {
14
16
  return function (_ref) {
15
17
  var tr = _ref.tr;
@@ -23,7 +25,17 @@ var selectionPlugin = function selectionPlugin(_ref2) {
23
25
  return {
24
26
  name: 'selection',
25
27
  commands: {
26
- displayGapCursor: displayGapCursor
28
+ displayGapCursor: displayGapCursor,
29
+ selectNearNode: _commands.selectNearNode
30
+ },
31
+ getSharedState: function getSharedState(editorState) {
32
+ if (!editorState) {
33
+ return undefined;
34
+ }
35
+ var pluginState = _types.selectionPluginKey.getState(editorState);
36
+ return {
37
+ selectionRelativeToNode: pluginState === null || pluginState === void 0 ? void 0 : pluginState.selectionRelativeToNode
38
+ };
27
39
  },
28
40
  pmPlugins: function pmPlugins() {
29
41
  return [{
@@ -3,7 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.createSelectionClickHandler = createSelectionClickHandler;
6
+ Object.defineProperty(exports, "createSelectionClickHandler", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _selection.createSelectionClickHandler;
10
+ }
11
+ });
7
12
  exports.findSelectableContainerParent = exports.findSelectableContainerBefore = exports.findSelectableContainerAfter = exports.findLastChildNodeToSelect = exports.findFirstChildNodeToSelect = void 0;
8
13
  Object.defineProperty(exports, "getAllSelectionAnalyticsPayload", {
9
14
  enumerable: true,
@@ -39,26 +44,7 @@ var _utils = require("@atlaskit/editor-prosemirror/utils");
39
44
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
40
45
  var _selection = require("@atlaskit/editor-common/selection");
41
46
  var _utils2 = require("@atlaskit/editor-common/utils");
42
- var _isIgnored = require("../selection/gap-cursor/utils/is-ignored");
43
47
  var _types = require("./types");
44
- function createSelectionClickHandler(nodes, isValidTarget, options) {
45
- return function handleClickOn(view, pos, node, nodePos, event, direct) {
46
- if (options.useLongPressSelection) {
47
- return false;
48
- }
49
- if (direct && nodes.indexOf(node.type.name) !== -1) {
50
- if (event.target) {
51
- var _target = event.target;
52
- if (isValidTarget(_target)) {
53
- var selectionPos = options.getNodeSelectionPos ? options.getNodeSelectionPos(view.state, nodePos) : nodePos;
54
- (0, _selection.selectNode)(selectionPos)(view.state, view.dispatch);
55
- return true;
56
- }
57
- }
58
- }
59
- return false;
60
- };
61
- }
62
48
  var getDecorations = function getDecorations(tr) {
63
49
  if (tr.selection instanceof _state.NodeSelection) {
64
50
  return _view.DecorationSet.create(tr.doc, [_view.Decoration.node(tr.selection.from, tr.selection.to, {
@@ -184,7 +170,7 @@ var findSelectableContainerParent = function findSelectableContainerParent(selec
184
170
  var foundNodeThatSupportsGapCursor = false;
185
171
  var selectableNode = (0, _utils.findParentNode)(function (node) {
186
172
  var isSelectable = isSelectableContainerNode(node);
187
- if (!isSelectable && !(0, _isIgnored.isIgnored)(node)) {
173
+ if (!isSelectable && !(0, _selection.isIgnored)(node)) {
188
174
  foundNodeThatSupportsGapCursor = true;
189
175
  }
190
176
  return isSelectable;
@@ -219,7 +205,7 @@ var findSelectableContainerBefore = function findSelectableContainerBefore($pos,
219
205
  pos: $selectionBefore.start(i) - 1
220
206
  };
221
207
  }
222
- if (i > $pos.depth + 1 && !(0, _isIgnored.isIgnored)(node)) {
208
+ if (i > $pos.depth + 1 && !(0, _selection.isIgnored)(node)) {
223
209
  return;
224
210
  }
225
211
  }
@@ -256,7 +242,7 @@ var findSelectableContainerAfter = function findSelectableContainerAfter($pos, d
256
242
  pos: $selectionAfter.start(i) - 1
257
243
  };
258
244
  }
259
- if (i > $pos.depth + 1 && !(0, _isIgnored.isIgnored)(node)) {
245
+ if (i > $pos.depth + 1 && !(0, _selection.isIgnored)(node)) {
260
246
  return;
261
247
  }
262
248
  }
@@ -270,7 +256,7 @@ var findSelectableContainerAfter = function findSelectableContainerAfter($pos, d
270
256
  exports.findSelectableContainerAfter = findSelectableContainerAfter;
271
257
  var findFirstChildNodeToSelect = function findFirstChildNodeToSelect(parent) {
272
258
  return (0, _utils.flatten)(parent).find(function (child) {
273
- return isSelectableChildNode(child.node) || !(0, _isIgnored.isIgnored)(child.node);
259
+ return isSelectableChildNode(child.node) || !(0, _selection.isIgnored)(child.node);
274
260
  });
275
261
  };
276
262
 
@@ -282,7 +268,7 @@ exports.findFirstChildNodeToSelect = findFirstChildNodeToSelect;
282
268
  var findLastChildNodeToSelect = function findLastChildNodeToSelect(parent) {
283
269
  var child;
284
270
  parent.descendants(function (node, pos) {
285
- if (isSelectableChildNode(node) || !(0, _isIgnored.isIgnored)(node)) {
271
+ if (isSelectableChildNode(node) || !(0, _selection.isIgnored)(node)) {
286
272
  child = {
287
273
  node: node,
288
274
  pos: pos
@@ -12,7 +12,7 @@ var _utils = require("@atlaskit/editor-prosemirror/utils");
12
12
  var _transform = require("@atlaskit/editor-prosemirror/transform");
13
13
  var _adfSchema = require("@atlaskit/adf-schema");
14
14
  var _analytics = require("../analytics");
15
- var _gapCursorSelection = require("../selection/gap-cursor-selection");
15
+ var _selection = require("@atlaskit/editor-common/selection");
16
16
  var _pluginKey = require("./pm-plugins/plugin-key");
17
17
  var _utils2 = require("@atlaskit/editor-common/utils");
18
18
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
@@ -212,7 +212,7 @@ var createListAtSelection = function createListAtSelection(tr, list, item, schem
212
212
  }, itemAttrs))]);
213
213
 
214
214
  // we don't take the content of a block node next to the gap cursor and always create an empty task
215
- if (selection instanceof _gapCursorSelection.GapCursorSelection) {
215
+ if (selection instanceof _selection.GapCursorSelection) {
216
216
  return (0, _utils.safeInsert)(emptyList)(tr);
217
217
  }
218
218
 
@@ -11,12 +11,11 @@ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
11
11
  var _state = require("@atlaskit/editor-prosemirror/state");
12
12
  var _adfSchema = require("@atlaskit/adf-schema");
13
13
  var _utils = require("../../../utils");
14
- var _utils2 = require("../../selection/utils");
14
+ var _selection = require("@atlaskit/editor-common/selection");
15
15
  var _decisionItem = require("../nodeviews/decisionItem");
16
16
  var _taskItem = require("../nodeviews/taskItem");
17
17
  var _pluginKey = require("./plugin-key");
18
18
  var _helpers = require("./helpers");
19
- var _selection = require("@atlaskit/editor-common/selection");
20
19
  var _types = require("./types");
21
20
  var _excluded = ["localId"];
22
21
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
@@ -62,7 +61,7 @@ function createPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispa
62
61
  }
63
62
  return false;
64
63
  },
65
- handleClickOn: (0, _utils2.createSelectionClickHandler)(['decisionItem'], function (target) {
64
+ handleClickOn: (0, _selection.createSelectionClickHandler)(['decisionItem'], function (target) {
66
65
  return target.hasAttribute('data-decision-wrapper') || target.getAttribute('aria-label') === 'Decision';
67
66
  }, {
68
67
  useLongPressSelection: useLongPressSelection
@@ -42,7 +42,7 @@ var _pluginKey = require("./plugins/analytics/plugin-key");
42
42
  var _base = require("./plugins/base");
43
43
  var _api = require("./plugins/type-ahead/api");
44
44
  var _eventDispatcher = require("./event-dispatcher");
45
- var _selection = require("./plugins/selection/gap-cursor/selection");
45
+ var _selection = require("@atlaskit/editor-common/selection");
46
46
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
47
47
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
48
48
  function getFireAnalytics(editorView) {
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.version = exports.nextMajorVersion = exports.name = void 0;
7
7
  var name = "@atlaskit/editor-core";
8
8
  exports.name = name;
9
- var version = "187.46.1";
9
+ var version = "187.47.0";
10
10
  exports.version = version;
11
11
  var nextMajorVersion = function nextMajorVersion() {
12
12
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
@@ -57,7 +57,7 @@ export { default as EditorActions } from './actions';
57
57
  // Re-export from provider factory to not cause a breaking change
58
58
 
59
59
  export { PortalProvider, PortalProviderAPI, PortalRenderer } from '@atlaskit/editor-common/portal-provider';
60
- export { GapCursorSelection, Side as GapCursorSide } from './plugins/selection/gap-cursor-selection';
60
+ export { GapCursorSelection, Side as GapCursorSide } from '@atlaskit/editor-common/selection';
61
61
  export { selectionPluginKey } from './plugins/mobile-selection';
62
62
  export { insertExpand } from './plugins/expand/commands';
63
63
  export { default as WithPluginState } from './ui/WithPluginState';
@@ -3,7 +3,7 @@ import { Selection } from '@atlaskit/editor-prosemirror/state';
3
3
  import { bindKeymapWithCommand, moveDown, enter, moveUp, shiftTab, tab, moveLeft } from '@atlaskit/editor-common/keymaps';
4
4
  import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
5
5
  import { createNewParagraphBelow } from '@atlaskit/editor-common/utils';
6
- import { GapCursorSelection } from '../../selection/gap-cursor/selection';
6
+ import { GapCursorSelection } from '@atlaskit/editor-common/selection';
7
7
  export function captionKeymap() {
8
8
  const list = {};
9
9
  bindKeymapWithCommand(moveDown.common, createNewParagraphBelowCaption, list);
@@ -2,7 +2,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
2
  import { browser } from '@atlaskit/editor-common/utils';
3
3
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
4
4
  import { codeBlockNodeView } from '../nodeviews/code-block';
5
- import { createSelectionClickHandler } from '../../selection/utils';
5
+ import { createSelectionClickHandler } from '@atlaskit/editor-common/selection';
6
6
  import { pluginKey } from '../plugin-key';
7
7
  import { ACTIONS } from './actions';
8
8
  import { ignoreFollowingMutations, resetShouldIgnoreFollowingMutations } from '../actions';
@@ -1,7 +1,7 @@
1
1
  import { Selection } from '@atlaskit/editor-prosemirror/state';
2
2
  import { findTable } from '@atlaskit/editor-tables/utils';
3
3
  import { addAnalytics, ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, INPUT_METHOD, EVENT_TYPE, PLATFORMS, MODE } from '../analytics';
4
- import { GapCursorSelection, Side } from '../selection/gap-cursor-selection';
4
+ import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
5
5
  import { findExpand } from './utils';
6
6
  import { createCommand } from './pm-plugins/plugin-factory';
7
7
  import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
@@ -8,6 +8,8 @@ import { getToolbarConfig } from './toolbar';
8
8
  import { createExpandNode } from './commands';
9
9
  import { messages } from '../insert-block/ui/ToolbarInsertBlock/messages';
10
10
  import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
11
+ // TO-DO: replace with editor-plugin-selection
12
+
11
13
  const expandPlugin = ({
12
14
  config: options = {},
13
15
  api
@@ -32,11 +34,11 @@ const expandPlugin = ({
32
34
  dispatch,
33
35
  getIntl
34
36
  }) => {
35
- return createPlugin(dispatch, getIntl, options.appearance, options.useLongPressSelection, featureFlags);
37
+ return createPlugin(dispatch, getIntl, options.appearance, options.useLongPressSelection, featureFlags, api);
36
38
  }
37
39
  }, {
38
40
  name: 'expandKeymap',
39
- plugin: expandKeymap
41
+ plugin: () => expandKeymap(api)
40
42
  }];
41
43
  },
42
44
  pluginsOptions: {
@@ -9,11 +9,8 @@ import { expandMessages } from '@atlaskit/editor-common/ui';
9
9
  import { isEmptyNode } from '../../../utils';
10
10
  import { updateExpandTitle, toggleExpandExpanded, deleteExpandAtPos, setSelectionInsideExpand } from '../commands';
11
11
  import { expandClassNames } from '../ui/class-names';
12
- import { GapCursorSelection, Side } from '../../../plugins/selection/gap-cursor-selection';
12
+ import { GapCursorSelection, Side, RelativeSelectionPos } from '@atlaskit/editor-common/selection';
13
13
  import { closestElement } from '../../../utils/dom';
14
- import { RelativeSelectionPos } from '../../selection/types';
15
- import { setSelectionRelativeToNode } from '../../selection/commands';
16
- import { getPluginState as getSelectionPluginState } from '../../selection/plugin-factory';
17
14
  function buildExpandClassName(type, expanded) {
18
15
  return `${expandClassNames.prefix} ${expandClassNames.type(type)} ${expanded ? expandClassNames.expanded : ''}`;
19
16
  }
@@ -49,7 +46,7 @@ const toDOM = (node, intl) => ['div', {
49
46
  'class': expandClassNames.content
50
47
  }, 0]];
51
48
  export class ExpandNodeView {
52
- constructor(node, view, getPos, getIntl, isMobile, featureFlags) {
49
+ constructor(node, view, getPos, getIntl, isMobile, featureFlags, selectNearNode, api) {
53
50
  _defineProperty(this, "allowInteractiveExpand", true);
54
51
  _defineProperty(this, "isMobile", false);
55
52
  _defineProperty(this, "focusTitle", () => {
@@ -58,7 +55,10 @@ export class ExpandNodeView {
58
55
  state,
59
56
  dispatch
60
57
  } = this.view;
61
- setSelectionRelativeToNode(RelativeSelectionPos.Start)(state, dispatch);
58
+ if (this.selectNearNode) {
59
+ var _this$api;
60
+ (_this$api = this.api) === null || _this$api === void 0 ? void 0 : _this$api.core.actions.execute(this.selectNearNode(RelativeSelectionPos.Start));
61
+ }
62
62
  const pos = this.getPos();
63
63
  if (typeof pos === 'number') {
64
64
  setSelectionInsideExpand(pos)(state, dispatch, this.view);
@@ -266,7 +266,7 @@ export class ExpandNodeView {
266
266
  }
267
267
  });
268
268
  _defineProperty(this, "handleArrowRightFromTitle", event => {
269
- if (!this.input) {
269
+ if (!this.input || !this.selectNearNode) {
270
270
  return;
271
271
  }
272
272
  const pos = this.getPos();
@@ -279,17 +279,17 @@ export class ExpandNodeView {
279
279
  selectionEnd
280
280
  } = this.input;
281
281
  if (selectionStart === selectionEnd && selectionStart === value.length) {
282
+ var _this$api2;
282
283
  event.preventDefault();
283
284
  const {
284
- state,
285
- dispatch
285
+ state
286
286
  } = this.view;
287
287
  this.view.focus();
288
- setSelectionRelativeToNode(RelativeSelectionPos.End, NodeSelection.create(state.doc, pos))(state, dispatch);
288
+ (_this$api2 = this.api) === null || _this$api2 === void 0 ? void 0 : _this$api2.core.actions.execute(this.selectNearNode(RelativeSelectionPos.End, NodeSelection.create(state.doc, pos)));
289
289
  }
290
290
  });
291
291
  _defineProperty(this, "handleArrowLeftFromTitle", event => {
292
- if (!this.input) {
292
+ if (!this.input || !this.selectNearNode) {
293
293
  return;
294
294
  }
295
295
  const pos = this.getPos();
@@ -301,22 +301,25 @@ export class ExpandNodeView {
301
301
  selectionEnd
302
302
  } = this.input;
303
303
  if (selectionStart === selectionEnd && selectionStart === 0) {
304
+ var _this$api3;
304
305
  event.preventDefault();
305
306
  const {
306
- state,
307
- dispatch
307
+ state
308
308
  } = this.view;
309
309
  this.view.focus();
310
-
310
+ const selectionSharedState = ((_this$api3 = this.api) === null || _this$api3 === void 0 ? void 0 : _this$api3.selection.sharedState.currentState()) || {};
311
311
  // selectionRelativeToNode is undefined when user clicked to select node, then hit left to get focus in title
312
312
  // This is a special case where we want to bypass node selection and jump straight to gap cursor
313
- if (getSelectionPluginState(state).selectionRelativeToNode === undefined) {
314
- setSelectionRelativeToNode(undefined, new GapCursorSelection(state.doc.resolve(pos), Side.LEFT))(state, dispatch);
313
+ if ((selectionSharedState === null || selectionSharedState === void 0 ? void 0 : selectionSharedState.selectionRelativeToNode) === undefined) {
314
+ var _this$api4;
315
+ (_this$api4 = this.api) === null || _this$api4 === void 0 ? void 0 : _this$api4.core.actions.execute(this.selectNearNode(undefined, new GapCursorSelection(state.doc.resolve(pos), Side.LEFT)));
315
316
  } else {
316
- setSelectionRelativeToNode(RelativeSelectionPos.Start, NodeSelection.create(state.doc, pos))(state, dispatch);
317
+ var _this$api5;
318
+ (_this$api5 = this.api) === null || _this$api5 === void 0 ? void 0 : _this$api5.core.actions.execute(this.selectNearNode(RelativeSelectionPos.Start, NodeSelection.create(state.doc, pos)));
317
319
  }
318
320
  }
319
321
  });
322
+ this.selectNearNode = selectNearNode;
320
323
  this.intl = getIntl();
321
324
  const {
322
325
  dom,
@@ -329,6 +332,7 @@ export class ExpandNodeView {
329
332
  this.contentDOM = contentDOM;
330
333
  this.isMobile = isMobile;
331
334
  this.featureFlags = featureFlags;
335
+ this.api = api;
332
336
  this.icon = this.dom.querySelector(`.${expandClassNames.icon}`);
333
337
  this.input = this.dom.querySelector(`.${expandClassNames.titleInput}`);
334
338
  this.titleContainer = this.dom.querySelector(`.${expandClassNames.titleContainer}`);
@@ -437,7 +441,8 @@ export class ExpandNodeView {
437
441
  export default function ({
438
442
  getIntl,
439
443
  isMobile,
440
- featureFlags
444
+ featureFlags,
445
+ api
441
446
  }) {
442
- return (node, view, getPos) => new ExpandNodeView(node, view, getPos, getIntl, isMobile, featureFlags);
447
+ return (node, view, getPos) => new ExpandNodeView(node, view, getPos, getIntl, isMobile, featureFlags, api === null || api === void 0 ? void 0 : api.selection.commands.selectNearNode, api);
443
448
  }
@@ -1,19 +1,17 @@
1
1
  import { keymap } from '@atlaskit/editor-prosemirror/keymap';
2
2
  import { Selection, TextSelection, NodeSelection } from '@atlaskit/editor-prosemirror/state';
3
3
  import { bindKeymapWithCommand, moveRight, moveLeft, moveUp, moveDown, tab, backspace } from '@atlaskit/editor-common/keymaps';
4
- import { GapCursorSelection, Side } from '../../selection/gap-cursor-selection';
4
+ import { GapCursorSelection, Side, RelativeSelectionPos } from '@atlaskit/editor-common/selection';
5
5
  import { findExpand } from '../utils';
6
6
  import { isEmptyNode } from '../../../utils';
7
7
  import { expandClassNames } from '../ui/class-names';
8
8
  import { deleteExpand, focusTitle } from '../commands';
9
- import { getPluginState as getSelectionPluginState } from '../../selection/plugin-factory';
10
- import { RelativeSelectionPos } from '../../selection/types';
11
9
  import { isPositionNearTableRow } from '@atlaskit/editor-common/utils';
12
10
  const isExpandNode = node => {
13
11
  return (node === null || node === void 0 ? void 0 : node.type.name) === 'expand' || (node === null || node === void 0 ? void 0 : node.type.name) === 'nestedExpand';
14
12
  };
15
13
  const isExpandSelected = selection => selection instanceof NodeSelection && isExpandNode(selection.node);
16
- export function expandKeymap() {
14
+ export function expandKeymap(api) {
17
15
  const list = {};
18
16
  bindKeymapWithCommand(moveRight.common, (state, dispatch, editorView) => {
19
17
  if (!editorView) {
@@ -22,9 +20,10 @@ export function expandKeymap() {
22
20
  const {
23
21
  selection
24
22
  } = state;
23
+ const selectionSharedState = (api === null || api === void 0 ? void 0 : api.selection.sharedState.currentState()) || {};
25
24
  const {
26
25
  selectionRelativeToNode
27
- } = getSelectionPluginState(state);
26
+ } = selectionSharedState;
28
27
  if (isExpandSelected(selection) && selectionRelativeToNode === RelativeSelectionPos.Start) {
29
28
  return focusTitle(selection.from + 1)(state, dispatch, editorView);
30
29
  }
@@ -37,9 +36,10 @@ export function expandKeymap() {
37
36
  const {
38
37
  selection
39
38
  } = state;
39
+ const selectionSharedState = (api === null || api === void 0 ? void 0 : api.selection.sharedState.currentState()) || {};
40
40
  const {
41
41
  selectionRelativeToNode
42
- } = getSelectionPluginState(state);
42
+ } = selectionSharedState;
43
43
  if (isExpandSelected(selection) && (selectionRelativeToNode === undefined || selectionRelativeToNode === RelativeSelectionPos.End)) {
44
44
  return focusTitle(selection.from + 1)(state, dispatch, editorView);
45
45
  }
@@ -1,6 +1,6 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
2
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
3
- import { createSelectionClickHandler } from '../../selection/utils';
3
+ import { createSelectionClickHandler } from '@atlaskit/editor-common/selection';
4
4
  import ExpandNodeView from '../nodeviews';
5
5
  import { setExpandRef } from '../commands';
6
6
  import { findExpand } from '../utils';
@@ -10,7 +10,7 @@ export function containsClass(element, className) {
10
10
  var _element$classList;
11
11
  return Boolean(element === null || element === void 0 ? void 0 : (_element$classList = element.classList) === null || _element$classList === void 0 ? void 0 : _element$classList.contains(className));
12
12
  }
13
- export const createPlugin = (dispatch, getIntl, appearance = 'full-page', useLongPressSelection = false, featureFlags) => {
13
+ export const createPlugin = (dispatch, getIntl, appearance = 'full-page', useLongPressSelection = false, featureFlags, api) => {
14
14
  const state = createPluginState(dispatch, {});
15
15
  const isMobile = appearance === 'mobile';
16
16
  return new SafePlugin({
@@ -21,12 +21,14 @@ export const createPlugin = (dispatch, getIntl, appearance = 'full-page', useLon
21
21
  expand: ExpandNodeView({
22
22
  getIntl,
23
23
  isMobile,
24
- featureFlags
24
+ featureFlags,
25
+ api
25
26
  }),
26
27
  nestedExpand: ExpandNodeView({
27
28
  getIntl,
28
29
  isMobile,
29
- featureFlags
30
+ featureFlags,
31
+ api
30
32
  })
31
33
  },
32
34
  handleKeyDown(_view, event) {
@@ -1,8 +1,7 @@
1
1
  import { TextSelection, NodeSelection } from '@atlaskit/editor-prosemirror/state';
2
2
  import { findParentNodeOfTypeClosestToPos, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
3
3
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
4
- import { isSelectionAtStartOfNode, isSelectionAtEndOfNode } from '@atlaskit/editor-common/selection';
5
- import { createSelectionClickHandler } from '../../selection/utils';
4
+ import { isSelectionAtStartOfNode, isSelectionAtEndOfNode, createSelectionClickHandler } from '@atlaskit/editor-common/selection';
6
5
  import ExtensionNodeView from '../nodeviews/extension';
7
6
  import { updateState, clearEditingContext } from '../commands';
8
7
  import { getSelectedExtension, getSelectedDomElement } from '../utils';
@@ -4,7 +4,7 @@ import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
4
4
  import { keydownHandler } from '@atlaskit/editor-prosemirror/keymap';
5
5
  import { findParentNodeOfType, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
6
6
  import { filterCommand as filter } from '@atlaskit/editor-common/utils';
7
- import { createSelectionClickHandler } from '../../selection/utils';
7
+ import { createSelectionClickHandler } from '@atlaskit/editor-common/selection';
8
8
  import { fixColumnSizes, fixColumnStructure, getSelectedLayout } from '../actions';
9
9
  import { pluginKey } from './plugin-key';
10
10
  export const DEFAULT_LAYOUT = 'two_equal';
@@ -67,7 +67,7 @@ export const changeMediaCardToInline = editorAnalyticsAPI => (state, dispatch) =
67
67
  const node = paragraph.createChecked({}, content);
68
68
  const nodePos = state.tr.doc.resolve(state.selection.from).start() - 1;
69
69
  let tr = removeMediaGroupNode(state);
70
- tr = safeInsert(node, nodePos, true)(tr);
70
+ tr = safeInsert(node, nodePos, false)(tr);
71
71
  if (dispatch) {
72
72
  editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
73
73
  action: ACTION.CHANGED_TYPE,
@@ -2,7 +2,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
2
  import { PanelSharedCssClassName } from '@atlaskit/editor-common/panel';
3
3
  import { getPanelNodeView } from '../nodeviews/panel';
4
4
  import { pluginKey } from '../types';
5
- import { createSelectionClickHandler } from '../../selection/utils';
5
+ import { createSelectionClickHandler } from '@atlaskit/editor-common/selection';
6
6
  export const createPlugin = (dispatch, providerFactory, pluginOptions) => {
7
7
  const {
8
8
  useLongPressSelection = false
@@ -7,7 +7,7 @@ import { replaceSelectedTable } from '@atlaskit/editor-tables/utils';
7
7
  import { compose, insideTable, isParagraph, isText, isLinkMark, insideTableCell, isInListItem } from '../../utils';
8
8
  import { mapSlice } from '../../utils/slice';
9
9
  import { INPUT_METHOD } from '../analytics';
10
- import { GapCursorSelection, Side } from '../selection/gap-cursor-selection';
10
+ import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
11
11
  import { runMacroAutoConvert } from '../macro';
12
12
  import { insertMediaAsMediaSingle } from '../media/utils/media-single';
13
13
  import { addReplaceSelectedTableAnalytics, applyTextMarksToSlice, hasOnlyNodesOfType } from './util';