@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
@@ -1,19 +1,30 @@
1
1
  import { NodeSelection, TextSelection, Selection } from '@atlaskit/editor-prosemirror/state';
2
2
  import { GapCursorSelection, Side } from './gap-cursor-selection';
3
- import { isIgnored as isIgnoredByGapCursor } from '../selection/gap-cursor/utils/is-ignored';
3
+ import { isIgnored as isIgnoredByGapCursor } from '@atlaskit/editor-common/selection';
4
4
  import { isNodeEmpty, isEmptyParagraph } from '@atlaskit/editor-common/utils';
5
5
  import { SelectionActionTypes } from './actions';
6
6
  import { createCommand, getPluginState } from './plugin-factory';
7
7
  import { isSelectableContainerNode, isSelectionAtEndOfParentNode, findSelectableContainerParent, isSelectionAtStartOfParentNode, findSelectableContainerBefore, findSelectableContainerAfter, findFirstChildNodeToSelect, findLastChildNodeToSelect } from './utils';
8
- import { RelativeSelectionPos, SelectionDirection } from './types';
9
- export const setSelectionRelativeToNode = (selectionRelativeToNode, selection) => createCommand({
10
- type: SelectionActionTypes.SET_RELATIVE_SELECTION,
11
- selectionRelativeToNode
12
- }, tr => {
8
+ import { RelativeSelectionPos, SelectionDirection, selectionPluginKey } from './types';
9
+ export const selectNearNode = (selectionRelativeToNode, selection) => ({
10
+ tr
11
+ }) => {
12
+ tr.setMeta(selectionPluginKey, {
13
+ type: SelectionActionTypes.SET_RELATIVE_SELECTION,
14
+ selectionRelativeToNode
15
+ });
13
16
  if (selection) {
14
17
  return tr.setSelection(selection);
15
18
  }
16
19
  return tr;
20
+ };
21
+ export const setSelectionRelativeToNode = (selectionRelativeToNode, selection) => createCommand({
22
+ type: SelectionActionTypes.SET_RELATIVE_SELECTION,
23
+ selectionRelativeToNode
24
+ }, tr => {
25
+ return selectNearNode(selectionRelativeToNode, selection)({
26
+ tr
27
+ }) || tr;
17
28
  });
18
29
  export const arrowRight = (state, dispatch) => {
19
30
  const {
@@ -1,5 +1,5 @@
1
1
  import { getLayoutModeFromTargetNode, isLeftCursor, getComputedStyleForLayoutMode } from '../utils';
2
- import { Side } from '../selection';
2
+ import { Side } from '@atlaskit/editor-common/selection';
3
3
 
4
4
  /**
5
5
  * We have a couple of nodes that require us to compute style
@@ -1,8 +1,10 @@
1
1
  import { createPlugin } from './pm-plugins/selection-main';
2
+ import { selectionPluginKey } from './types';
2
3
  import selectionKeymapPlugin from './pm-plugins/keymap';
3
4
  import gapCursorPlugin from './pm-plugins/gap-cursor-main';
4
5
  import { gapCursorPluginKey } from './pm-plugins/gap-cursor-plugin-key';
5
6
  import gapCursorKeymapPlugin from './pm-plugins/gap-cursor-keymap';
7
+ import { selectNearNode } from './commands';
6
8
  const displayGapCursor = toggle => ({
7
9
  tr
8
10
  }) => {
@@ -15,7 +17,17 @@ export const selectionPlugin = ({
15
17
  }) => ({
16
18
  name: 'selection',
17
19
  commands: {
18
- displayGapCursor
20
+ displayGapCursor,
21
+ selectNearNode
22
+ },
23
+ getSharedState(editorState) {
24
+ if (!editorState) {
25
+ return undefined;
26
+ }
27
+ const pluginState = selectionPluginKey.getState(editorState);
28
+ return {
29
+ selectionRelativeToNode: pluginState === null || pluginState === void 0 ? void 0 : pluginState.selectionRelativeToNode
30
+ };
19
31
  },
20
32
  pmPlugins() {
21
33
  return [{
@@ -2,28 +2,9 @@ import { NodeSelection, TextSelection, Selection, AllSelection } from '@atlaskit
2
2
  import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
3
3
  import { flatten, findParentNode } from '@atlaskit/editor-prosemirror/utils';
4
4
  import { akEditorSelectedNodeClassName } from '@atlaskit/editor-shared-styles';
5
- import { isSelectionAtStartOfNode, isSelectionAtEndOfNode, getNodeSelectionAnalyticsPayload, getAllSelectionAnalyticsPayload, getRangeSelectionAnalyticsPayload, getCellSelectionAnalyticsPayload, selectNode } from '@atlaskit/editor-common/selection';
5
+ import { isSelectionAtStartOfNode, isSelectionAtEndOfNode, getNodeSelectionAnalyticsPayload, getAllSelectionAnalyticsPayload, getRangeSelectionAnalyticsPayload, getCellSelectionAnalyticsPayload, createSelectionClickHandler, isIgnored as isIgnoredByGapCursor } from '@atlaskit/editor-common/selection';
6
6
  import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
7
- import { isIgnored as isIgnoredByGapCursor } from '../selection/gap-cursor/utils/is-ignored';
8
7
  import { selectionPluginKey } from './types';
9
- export function createSelectionClickHandler(nodes, isValidTarget, options) {
10
- return function handleClickOn(view, pos, node, nodePos, event, direct) {
11
- if (options.useLongPressSelection) {
12
- return false;
13
- }
14
- if (direct && nodes.indexOf(node.type.name) !== -1) {
15
- if (event.target) {
16
- const target = event.target;
17
- if (isValidTarget(target)) {
18
- const selectionPos = options.getNodeSelectionPos ? options.getNodeSelectionPos(view.state, nodePos) : nodePos;
19
- selectNode(selectionPos)(view.state, view.dispatch);
20
- return true;
21
- }
22
- }
23
- }
24
- return false;
25
- };
26
- }
27
8
  export const getDecorations = tr => {
28
9
  if (tr.selection instanceof NodeSelection) {
29
10
  return DecorationSet.create(tr.doc, [Decoration.node(tr.selection.from, tr.selection.to, {
@@ -249,4 +230,4 @@ export const findLastChildNodeToSelect = parent => {
249
230
  };
250
231
  export const isSelectionAtStartOfParentNode = ($pos, selection) => isSelectionAtStartOfNode($pos, findSelectableContainerParent(selection));
251
232
  export const isSelectionAtEndOfParentNode = ($pos, selection) => isSelectionAtEndOfNode($pos, findSelectableContainerParent(selection));
252
- export { getNodeSelectionAnalyticsPayload, getAllSelectionAnalyticsPayload, getRangeSelectionAnalyticsPayload, getCellSelectionAnalyticsPayload };
233
+ export { getNodeSelectionAnalyticsPayload, getAllSelectionAnalyticsPayload, getRangeSelectionAnalyticsPayload, getCellSelectionAnalyticsPayload, createSelectionClickHandler };
@@ -4,7 +4,7 @@ import { findParentNodeOfType, hasParentNodeOfType, replaceParentNodeOfType, saf
4
4
  import { liftTarget } from '@atlaskit/editor-prosemirror/transform';
5
5
  import { uuid } from '@atlaskit/adf-schema';
6
6
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, addAnalytics, EVENT_TYPE, INPUT_METHOD, USER_CONTEXT } from '../analytics';
7
- import { GapCursorSelection } from '../selection/gap-cursor-selection';
7
+ import { GapCursorSelection } from '@atlaskit/editor-common/selection';
8
8
  import { stateKey as taskDecisionStateKey } from './pm-plugins/plugin-key';
9
9
  import { autoJoinTr } from '@atlaskit/editor-common/utils';
10
10
  const getContextData = (contextProvider = {}) => {
@@ -2,7 +2,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
2
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
3
3
  import { uuid } from '@atlaskit/adf-schema';
4
4
  import { nodesBetweenChanged, SetAttrsStep } from '../../../utils';
5
- import { createSelectionClickHandler } from '../../selection/utils';
5
+ import { createSelectionClickHandler } from '@atlaskit/editor-common/selection';
6
6
  import { decisionItemNodeView } from '../nodeviews/decisionItem';
7
7
  import { taskItemNodeViewFactory } from '../nodeviews/taskItem';
8
8
  import { stateKey } from './plugin-key';
@@ -79,7 +79,7 @@ export const createPMSchemaAndPlugins = (inputPreset = new EditorPresetBuilder()
79
79
  };
80
80
  };
81
81
  export { EventDispatcher } from './event-dispatcher';
82
- export { GapCursorSelection, Side as GapCursorSide } from './plugins/selection/gap-cursor/selection';
82
+ export { GapCursorSelection, Side as GapCursorSide } from '@atlaskit/editor-common/selection';
83
83
  export function setTextSelection(view, anchor, head) {
84
84
  const {
85
85
  state
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "187.46.1";
2
+ export const version = "187.47.0";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
package/dist/esm/index.js CHANGED
@@ -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
  var list = {};
9
9
  bindKeymapWithCommand(moveDown.common, createNewParagraphBelowCaption, list);
@@ -5,7 +5,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
5
5
  import { browser } from '@atlaskit/editor-common/utils';
6
6
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
7
7
  import { codeBlockNodeView } from '../nodeviews/code-block';
8
- import { createSelectionClickHandler } from '../../selection/utils';
8
+ import { createSelectionClickHandler } from '@atlaskit/editor-common/selection';
9
9
  import { pluginKey } from '../plugin-key';
10
10
  import { ACTIONS } from './actions';
11
11
  import { ignoreFollowingMutations, resetShouldIgnoreFollowingMutations } from '../actions';
@@ -4,7 +4,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
4
4
  import { Selection } from '@atlaskit/editor-prosemirror/state';
5
5
  import { findTable } from '@atlaskit/editor-tables/utils';
6
6
  import { addAnalytics, ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, INPUT_METHOD, EVENT_TYPE, PLATFORMS, MODE } from '../analytics';
7
- import { GapCursorSelection, Side } from '../selection/gap-cursor-selection';
7
+ import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
8
8
  import { findExpand } from './utils';
9
9
  import { createCommand } from './pm-plugins/plugin-factory';
10
10
  import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
@@ -9,6 +9,8 @@ import { getToolbarConfig } from './toolbar';
9
9
  import { createExpandNode } from './commands';
10
10
  import { messages } from '../insert-block/ui/ToolbarInsertBlock/messages';
11
11
  import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
12
+ // TO-DO: replace with editor-plugin-selection
13
+
12
14
  var expandPlugin = function expandPlugin(_ref) {
13
15
  var _api$featureFlags;
14
16
  var _ref$config = _ref.config,
@@ -32,11 +34,13 @@ var expandPlugin = function expandPlugin(_ref) {
32
34
  plugin: function plugin(_ref2) {
33
35
  var dispatch = _ref2.dispatch,
34
36
  getIntl = _ref2.getIntl;
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: function plugin() {
42
+ return expandKeymap(api);
43
+ }
40
44
  }];
41
45
  },
42
46
  pluginsOptions: {
@@ -11,11 +11,8 @@ import { expandMessages } from '@atlaskit/editor-common/ui';
11
11
  import { isEmptyNode } from '../../../utils';
12
12
  import { updateExpandTitle, toggleExpandExpanded, deleteExpandAtPos, setSelectionInsideExpand } from '../commands';
13
13
  import { expandClassNames } from '../ui/class-names';
14
- import { GapCursorSelection, Side } from '../../../plugins/selection/gap-cursor-selection';
14
+ import { GapCursorSelection, Side, RelativeSelectionPos } from '@atlaskit/editor-common/selection';
15
15
  import { closestElement } from '../../../utils/dom';
16
- import { RelativeSelectionPos } from '../../selection/types';
17
- import { setSelectionRelativeToNode } from '../../selection/commands';
18
- import { getPluginState as getSelectionPluginState } from '../../selection/plugin-factory';
19
16
  function buildExpandClassName(type, expanded) {
20
17
  return "".concat(expandClassNames.prefix, " ").concat(expandClassNames.type(type), " ").concat(expanded ? expandClassNames.expanded : '');
21
18
  }
@@ -53,7 +50,7 @@ var toDOM = function toDOM(node, intl) {
53
50
  }, 0]];
54
51
  };
55
52
  export var ExpandNodeView = /*#__PURE__*/function () {
56
- function ExpandNodeView(node, view, getPos, getIntl, isMobile, featureFlags) {
53
+ function ExpandNodeView(node, view, getPos, getIntl, isMobile, featureFlags, selectNearNode, api) {
57
54
  var _this = this;
58
55
  _classCallCheck(this, ExpandNodeView);
59
56
  _defineProperty(this, "allowInteractiveExpand", true);
@@ -63,7 +60,10 @@ export var ExpandNodeView = /*#__PURE__*/function () {
63
60
  var _this$view = _this.view,
64
61
  state = _this$view.state,
65
62
  dispatch = _this$view.dispatch;
66
- setSelectionRelativeToNode(RelativeSelectionPos.Start)(state, dispatch);
63
+ if (_this.selectNearNode) {
64
+ var _this$api;
65
+ (_this$api = _this.api) === null || _this$api === void 0 ? void 0 : _this$api.core.actions.execute(_this.selectNearNode(RelativeSelectionPos.Start));
66
+ }
67
67
  var pos = _this.getPos();
68
68
  if (typeof pos === 'number') {
69
69
  setSelectionInsideExpand(pos)(state, dispatch, _this.view);
@@ -260,7 +260,7 @@ export var ExpandNodeView = /*#__PURE__*/function () {
260
260
  }
261
261
  });
262
262
  _defineProperty(this, "handleArrowRightFromTitle", function (event) {
263
- if (!_this.input) {
263
+ if (!_this.input || !_this.selectNearNode) {
264
264
  return;
265
265
  }
266
266
  var pos = _this.getPos();
@@ -272,16 +272,15 @@ export var ExpandNodeView = /*#__PURE__*/function () {
272
272
  selectionStart = _this$input4.selectionStart,
273
273
  selectionEnd = _this$input4.selectionEnd;
274
274
  if (selectionStart === selectionEnd && selectionStart === value.length) {
275
+ var _this$api2;
275
276
  event.preventDefault();
276
- var _this$view8 = _this.view,
277
- state = _this$view8.state,
278
- dispatch = _this$view8.dispatch;
277
+ var state = _this.view.state;
279
278
  _this.view.focus();
280
- setSelectionRelativeToNode(RelativeSelectionPos.End, NodeSelection.create(state.doc, pos))(state, dispatch);
279
+ (_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)));
281
280
  }
282
281
  });
283
282
  _defineProperty(this, "handleArrowLeftFromTitle", function (event) {
284
- if (!_this.input) {
283
+ if (!_this.input || !_this.selectNearNode) {
285
284
  return;
286
285
  }
287
286
  var pos = _this.getPos();
@@ -292,21 +291,23 @@ export var ExpandNodeView = /*#__PURE__*/function () {
292
291
  selectionStart = _this$input5.selectionStart,
293
292
  selectionEnd = _this$input5.selectionEnd;
294
293
  if (selectionStart === selectionEnd && selectionStart === 0) {
294
+ var _this$api3;
295
295
  event.preventDefault();
296
- var _this$view9 = _this.view,
297
- state = _this$view9.state,
298
- dispatch = _this$view9.dispatch;
296
+ var state = _this.view.state;
299
297
  _this.view.focus();
300
-
298
+ var selectionSharedState = ((_this$api3 = _this.api) === null || _this$api3 === void 0 ? void 0 : _this$api3.selection.sharedState.currentState()) || {};
301
299
  // selectionRelativeToNode is undefined when user clicked to select node, then hit left to get focus in title
302
300
  // This is a special case where we want to bypass node selection and jump straight to gap cursor
303
- if (getSelectionPluginState(state).selectionRelativeToNode === undefined) {
304
- setSelectionRelativeToNode(undefined, new GapCursorSelection(state.doc.resolve(pos), Side.LEFT))(state, dispatch);
301
+ if ((selectionSharedState === null || selectionSharedState === void 0 ? void 0 : selectionSharedState.selectionRelativeToNode) === undefined) {
302
+ var _this$api4;
303
+ (_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)));
305
304
  } else {
306
- setSelectionRelativeToNode(RelativeSelectionPos.Start, NodeSelection.create(state.doc, pos))(state, dispatch);
305
+ var _this$api5;
306
+ (_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)));
307
307
  }
308
308
  }
309
309
  });
310
+ this.selectNearNode = selectNearNode;
310
311
  this.intl = getIntl();
311
312
  var _DOMSerializer$render = DOMSerializer.renderSpec(document, toDOM(node, this.intl)),
312
313
  dom = _DOMSerializer$render.dom,
@@ -318,6 +319,7 @@ export var ExpandNodeView = /*#__PURE__*/function () {
318
319
  this.contentDOM = contentDOM;
319
320
  this.isMobile = isMobile;
320
321
  this.featureFlags = featureFlags;
322
+ this.api = api;
321
323
  this.icon = this.dom.querySelector(".".concat(expandClassNames.icon));
322
324
  this.input = this.dom.querySelector(".".concat(expandClassNames.titleInput));
323
325
  this.titleContainer = this.dom.querySelector(".".concat(expandClassNames.titleContainer));
@@ -440,8 +442,9 @@ export var ExpandNodeView = /*#__PURE__*/function () {
440
442
  export default function (_ref2) {
441
443
  var getIntl = _ref2.getIntl,
442
444
  isMobile = _ref2.isMobile,
443
- featureFlags = _ref2.featureFlags;
445
+ featureFlags = _ref2.featureFlags,
446
+ api = _ref2.api;
444
447
  return function (node, view, getPos) {
445
- return new ExpandNodeView(node, view, getPos, getIntl, isMobile, featureFlags);
448
+ return new ExpandNodeView(node, view, getPos, getIntl, isMobile, featureFlags, api === null || api === void 0 ? void 0 : api.selection.commands.selectNearNode, api);
446
449
  };
447
450
  }
@@ -1,13 +1,11 @@
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
  var isExpandNode = function 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';
@@ -15,15 +13,15 @@ var isExpandNode = function isExpandNode(node) {
15
13
  var isExpandSelected = function isExpandSelected(selection) {
16
14
  return selection instanceof NodeSelection && isExpandNode(selection.node);
17
15
  };
18
- export function expandKeymap() {
16
+ export function expandKeymap(api) {
19
17
  var list = {};
20
18
  bindKeymapWithCommand(moveRight.common, function (state, dispatch, editorView) {
21
19
  if (!editorView) {
22
20
  return false;
23
21
  }
24
22
  var selection = state.selection;
25
- var _getSelectionPluginSt = getSelectionPluginState(state),
26
- selectionRelativeToNode = _getSelectionPluginSt.selectionRelativeToNode;
23
+ var selectionSharedState = (api === null || api === void 0 ? void 0 : api.selection.sharedState.currentState()) || {};
24
+ var selectionRelativeToNode = selectionSharedState.selectionRelativeToNode;
27
25
  if (isExpandSelected(selection) && selectionRelativeToNode === RelativeSelectionPos.Start) {
28
26
  return focusTitle(selection.from + 1)(state, dispatch, editorView);
29
27
  }
@@ -34,8 +32,8 @@ export function expandKeymap() {
34
32
  return false;
35
33
  }
36
34
  var selection = state.selection;
37
- var _getSelectionPluginSt2 = getSelectionPluginState(state),
38
- selectionRelativeToNode = _getSelectionPluginSt2.selectionRelativeToNode;
35
+ var selectionSharedState = (api === null || api === void 0 ? void 0 : api.selection.sharedState.currentState()) || {};
36
+ var selectionRelativeToNode = selectionSharedState.selectionRelativeToNode;
39
37
  if (isExpandSelected(selection) && (selectionRelativeToNode === undefined || selectionRelativeToNode === RelativeSelectionPos.End)) {
40
38
  return focusTitle(selection.from + 1)(state, dispatch, editorView);
41
39
  }
@@ -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';
@@ -14,6 +14,7 @@ export var createPlugin = function createPlugin(dispatch, getIntl) {
14
14
  var appearance = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'full-page';
15
15
  var useLongPressSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
16
16
  var featureFlags = arguments.length > 4 ? arguments[4] : undefined;
17
+ var api = arguments.length > 5 ? arguments[5] : undefined;
17
18
  var state = createPluginState(dispatch, {});
18
19
  var isMobile = appearance === 'mobile';
19
20
  return new SafePlugin({
@@ -24,12 +25,14 @@ export var createPlugin = function createPlugin(dispatch, getIntl) {
24
25
  expand: ExpandNodeView({
25
26
  getIntl: getIntl,
26
27
  isMobile: isMobile,
27
- featureFlags: featureFlags
28
+ featureFlags: featureFlags,
29
+ api: api
28
30
  }),
29
31
  nestedExpand: ExpandNodeView({
30
32
  getIntl: getIntl,
31
33
  isMobile: isMobile,
32
- featureFlags: featureFlags
34
+ featureFlags: featureFlags,
35
+ api: api
33
36
  })
34
37
  },
35
38
  handleKeyDown: function handleKeyDown(_view, event) {
@@ -4,8 +4,7 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
4
4
  import { TextSelection, NodeSelection } from '@atlaskit/editor-prosemirror/state';
5
5
  import { findParentNodeOfTypeClosestToPos, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
6
6
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
7
- import { isSelectionAtStartOfNode, isSelectionAtEndOfNode } from '@atlaskit/editor-common/selection';
8
- import { createSelectionClickHandler } from '../../selection/utils';
7
+ import { isSelectionAtStartOfNode, isSelectionAtEndOfNode, createSelectionClickHandler } from '@atlaskit/editor-common/selection';
9
8
  import ExtensionNodeView from '../nodeviews/extension';
10
9
  import { updateState, clearEditingContext } from '../commands';
11
10
  import { getSelectedExtension, getSelectedDomElement } from '../utils';
@@ -7,7 +7,7 @@ import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
7
7
  import { keydownHandler } from '@atlaskit/editor-prosemirror/keymap';
8
8
  import { findParentNodeOfType, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
9
9
  import { filterCommand as filter } from '@atlaskit/editor-common/utils';
10
- import { createSelectionClickHandler } from '../../selection/utils';
10
+ import { createSelectionClickHandler } from '@atlaskit/editor-common/selection';
11
11
  import { fixColumnSizes, fixColumnStructure, getSelectedLayout } from '../actions';
12
12
  import { pluginKey } from './plugin-key';
13
13
  export var DEFAULT_LAYOUT = 'two_equal';
@@ -70,7 +70,7 @@ export var changeMediaCardToInline = function changeMediaCardToInline(editorAnal
70
70
  var node = paragraph.createChecked({}, content);
71
71
  var nodePos = state.tr.doc.resolve(state.selection.from).start() - 1;
72
72
  var tr = removeMediaGroupNode(state);
73
- tr = safeInsert(node, nodePos, true)(tr);
73
+ tr = safeInsert(node, nodePos, false)(tr);
74
74
  if (dispatch) {
75
75
  editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
76
76
  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 var createPlugin = function createPlugin(dispatch, providerFactory, pluginOptions) {
7
7
  var _pluginOptions$useLon = pluginOptions.useLongPressSelection,
8
8
  useLongPressSelection = _pluginOptions$useLon === void 0 ? false : _pluginOptions$useLon;
@@ -15,7 +15,7 @@ import { replaceSelectedTable } from '@atlaskit/editor-tables/utils';
15
15
  import { compose, insideTable, isParagraph, isText, isLinkMark, insideTableCell, isInListItem } from '../../utils';
16
16
  import { mapSlice } from '../../utils/slice';
17
17
  import { INPUT_METHOD } from '../analytics';
18
- import { GapCursorSelection, Side } from '../selection/gap-cursor-selection';
18
+ import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
19
19
  import { runMacroAutoConvert } from '../macro';
20
20
  import { insertMediaAsMediaSingle } from '../media/utils/media-single';
21
21
  import { addReplaceSelectedTableAnalytics, applyTextMarksToSlice, hasOnlyNodesOfType } from './util';
@@ -1,20 +1,32 @@
1
1
  import { NodeSelection, TextSelection, Selection } from '@atlaskit/editor-prosemirror/state';
2
2
  import { GapCursorSelection, Side } from './gap-cursor-selection';
3
- import { isIgnored as isIgnoredByGapCursor } from '../selection/gap-cursor/utils/is-ignored';
3
+ import { isIgnored as isIgnoredByGapCursor } from '@atlaskit/editor-common/selection';
4
4
  import { isNodeEmpty, isEmptyParagraph } from '@atlaskit/editor-common/utils';
5
5
  import { SelectionActionTypes } from './actions';
6
6
  import { createCommand, getPluginState } from './plugin-factory';
7
7
  import { isSelectableContainerNode, isSelectionAtEndOfParentNode, findSelectableContainerParent, isSelectionAtStartOfParentNode, findSelectableContainerBefore, findSelectableContainerAfter, findFirstChildNodeToSelect, findLastChildNodeToSelect } from './utils';
8
- import { RelativeSelectionPos, SelectionDirection } from './types';
8
+ import { RelativeSelectionPos, SelectionDirection, selectionPluginKey } from './types';
9
+ export var selectNearNode = function selectNearNode(selectionRelativeToNode, selection) {
10
+ return function (_ref) {
11
+ var tr = _ref.tr;
12
+ tr.setMeta(selectionPluginKey, {
13
+ type: SelectionActionTypes.SET_RELATIVE_SELECTION,
14
+ selectionRelativeToNode: selectionRelativeToNode
15
+ });
16
+ if (selection) {
17
+ return tr.setSelection(selection);
18
+ }
19
+ return tr;
20
+ };
21
+ };
9
22
  export var setSelectionRelativeToNode = function setSelectionRelativeToNode(selectionRelativeToNode, selection) {
10
23
  return createCommand({
11
24
  type: SelectionActionTypes.SET_RELATIVE_SELECTION,
12
25
  selectionRelativeToNode: selectionRelativeToNode
13
26
  }, function (tr) {
14
- if (selection) {
15
- return tr.setSelection(selection);
16
- }
17
- return tr;
27
+ return selectNearNode(selectionRelativeToNode, selection)({
28
+ tr: tr
29
+ }) || tr;
18
30
  });
19
31
  };
20
32
  export var arrowRight = function arrowRight(state, dispatch) {
@@ -1,6 +1,6 @@
1
1
  import _toArray from "@babel/runtime/helpers/toArray";
2
2
  import { getLayoutModeFromTargetNode, isLeftCursor, getComputedStyleForLayoutMode } from '../utils';
3
- import { Side } from '../selection';
3
+ import { Side } from '@atlaskit/editor-common/selection';
4
4
 
5
5
  /**
6
6
  * We have a couple of nodes that require us to compute style
@@ -1,8 +1,10 @@
1
1
  import { createPlugin } from './pm-plugins/selection-main';
2
+ import { selectionPluginKey } from './types';
2
3
  import selectionKeymapPlugin from './pm-plugins/keymap';
3
4
  import gapCursorPlugin from './pm-plugins/gap-cursor-main';
4
5
  import { gapCursorPluginKey } from './pm-plugins/gap-cursor-plugin-key';
5
6
  import gapCursorKeymapPlugin from './pm-plugins/gap-cursor-keymap';
7
+ import { selectNearNode } from './commands';
6
8
  var displayGapCursor = function displayGapCursor(toggle) {
7
9
  return function (_ref) {
8
10
  var tr = _ref.tr;
@@ -16,7 +18,17 @@ export var selectionPlugin = function selectionPlugin(_ref2) {
16
18
  return {
17
19
  name: 'selection',
18
20
  commands: {
19
- displayGapCursor: displayGapCursor
21
+ displayGapCursor: displayGapCursor,
22
+ selectNearNode: selectNearNode
23
+ },
24
+ getSharedState: function getSharedState(editorState) {
25
+ if (!editorState) {
26
+ return undefined;
27
+ }
28
+ var pluginState = selectionPluginKey.getState(editorState);
29
+ return {
30
+ selectionRelativeToNode: pluginState === null || pluginState === void 0 ? void 0 : pluginState.selectionRelativeToNode
31
+ };
20
32
  },
21
33
  pmPlugins: function pmPlugins() {
22
34
  return [{
@@ -2,28 +2,9 @@ import { NodeSelection, TextSelection, Selection, AllSelection } from '@atlaskit
2
2
  import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
3
3
  import { flatten, findParentNode } from '@atlaskit/editor-prosemirror/utils';
4
4
  import { akEditorSelectedNodeClassName } from '@atlaskit/editor-shared-styles';
5
- import { isSelectionAtStartOfNode, isSelectionAtEndOfNode, getNodeSelectionAnalyticsPayload, getAllSelectionAnalyticsPayload, getRangeSelectionAnalyticsPayload, getCellSelectionAnalyticsPayload, selectNode } from '@atlaskit/editor-common/selection';
5
+ import { isSelectionAtStartOfNode, isSelectionAtEndOfNode, getNodeSelectionAnalyticsPayload, getAllSelectionAnalyticsPayload, getRangeSelectionAnalyticsPayload, getCellSelectionAnalyticsPayload, createSelectionClickHandler, isIgnored as isIgnoredByGapCursor } from '@atlaskit/editor-common/selection';
6
6
  import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
7
- import { isIgnored as isIgnoredByGapCursor } from '../selection/gap-cursor/utils/is-ignored';
8
7
  import { selectionPluginKey } from './types';
9
- export function createSelectionClickHandler(nodes, isValidTarget, options) {
10
- return function handleClickOn(view, pos, node, nodePos, event, direct) {
11
- if (options.useLongPressSelection) {
12
- return false;
13
- }
14
- if (direct && nodes.indexOf(node.type.name) !== -1) {
15
- if (event.target) {
16
- var _target = event.target;
17
- if (isValidTarget(_target)) {
18
- var selectionPos = options.getNodeSelectionPos ? options.getNodeSelectionPos(view.state, nodePos) : nodePos;
19
- selectNode(selectionPos)(view.state, view.dispatch);
20
- return true;
21
- }
22
- }
23
- }
24
- return false;
25
- };
26
- }
27
8
  export var getDecorations = function getDecorations(tr) {
28
9
  if (tr.selection instanceof NodeSelection) {
29
10
  return DecorationSet.create(tr.doc, [Decoration.node(tr.selection.from, tr.selection.to, {
@@ -257,4 +238,4 @@ export var isSelectionAtStartOfParentNode = function isSelectionAtStartOfParentN
257
238
  export var isSelectionAtEndOfParentNode = function isSelectionAtEndOfParentNode($pos, selection) {
258
239
  return isSelectionAtEndOfNode($pos, findSelectableContainerParent(selection));
259
240
  };
260
- export { getNodeSelectionAnalyticsPayload, getAllSelectionAnalyticsPayload, getRangeSelectionAnalyticsPayload, getCellSelectionAnalyticsPayload };
241
+ export { getNodeSelectionAnalyticsPayload, getAllSelectionAnalyticsPayload, getRangeSelectionAnalyticsPayload, getCellSelectionAnalyticsPayload, createSelectionClickHandler };
@@ -7,7 +7,7 @@ import { findParentNodeOfType, hasParentNodeOfType, replaceParentNodeOfType, saf
7
7
  import { liftTarget } from '@atlaskit/editor-prosemirror/transform';
8
8
  import { uuid } from '@atlaskit/adf-schema';
9
9
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, addAnalytics, EVENT_TYPE, INPUT_METHOD, USER_CONTEXT } from '../analytics';
10
- import { GapCursorSelection } from '../selection/gap-cursor-selection';
10
+ import { GapCursorSelection } from '@atlaskit/editor-common/selection';
11
11
  import { stateKey as taskDecisionStateKey } from './pm-plugins/plugin-key';
12
12
  import { autoJoinTr } from '@atlaskit/editor-common/utils';
13
13
  var getContextData = function getContextData() {
@@ -7,7 +7,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
7
7
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
8
8
  import { uuid } from '@atlaskit/adf-schema';
9
9
  import { nodesBetweenChanged, SetAttrsStep } from '../../../utils';
10
- import { createSelectionClickHandler } from '../../selection/utils';
10
+ import { createSelectionClickHandler } from '@atlaskit/editor-common/selection';
11
11
  import { decisionItemNodeView } from '../nodeviews/decisionItem';
12
12
  import { taskItemNodeViewFactory } from '../nodeviews/taskItem';
13
13
  import { stateKey } from './plugin-key';
@@ -91,7 +91,7 @@ export var createPMSchemaAndPlugins = function createPMSchemaAndPlugins() {
91
91
  };
92
92
  };
93
93
  export { EventDispatcher } from './event-dispatcher';
94
- export { GapCursorSelection, Side as GapCursorSide } from './plugins/selection/gap-cursor/selection';
94
+ export { GapCursorSelection, Side as GapCursorSide } from '@atlaskit/editor-common/selection';
95
95
  export function setTextSelection(view, anchor, head) {
96
96
  var state = view.state;
97
97
  var tr = state.tr.setSelection(TextSelection.create(state.doc, anchor, head));
@@ -1,5 +1,5 @@
1
1
  export var name = "@atlaskit/editor-core";
2
- export var version = "187.46.1";
2
+ export var version = "187.47.0";
3
3
  export var nextMajorVersion = function nextMajorVersion() {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };