@atlaskit/editor-plugin-selection 1.7.0 → 1.8.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @atlaskit/editor-plugin-selection
2
2
 
3
+ ## 1.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#111465](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/111465)
8
+ [`dd20af1fdd46f`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/dd20af1fdd46f) -
9
+ Add commands for manually setting/clearing selection decoration range
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
15
+ ## 1.7.1
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies
20
+
3
21
  ## 1.7.0
4
22
 
5
23
  ### Minor Changes
@@ -1,17 +1,22 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.getInitialState = exports.createPlugin = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
7
9
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
8
10
  var _state = require("@atlaskit/editor-prosemirror/state");
11
+ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
9
12
  var _types = require("../types");
10
13
  var _actions = require("./actions");
11
14
  var _createSelectionBetween = require("./events/create-selection-between");
12
15
  var _keydown = require("./events/keydown");
13
16
  var _pluginFactory = require("./plugin-factory");
14
17
  var _utils = require("./utils");
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; }
19
+ 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; }
15
20
  var getInitialState = exports.getInitialState = function getInitialState(state) {
16
21
  return {
17
22
  decorationSet: (0, _utils.getDecorations)(state.tr),
@@ -23,18 +28,27 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, dispat
23
28
  return new _safePlugin.SafePlugin({
24
29
  key: _types.selectionPluginKey,
25
30
  state: (0, _pluginFactory.createPluginState)(dispatch, getInitialState),
26
- appendTransaction: function appendTransaction(_transactions, oldEditorState, newEditorState) {
31
+ appendTransaction: function appendTransaction(transactions, oldEditorState, newEditorState) {
32
+ var _combinedMeta, _combinedMeta2;
33
+ var tr = newEditorState.tr;
34
+ var combinedMeta = {};
35
+ if ((0, _experiments.editorExperiment)('platform_editor_element_drag_and_drop_multiselect', true)) {
36
+ combinedMeta = transactions.map(function (value) {
37
+ return value.getMeta(_types.selectionPluginKey);
38
+ }).reduce(function (prev, curr) {
39
+ return _objectSpread(_objectSpread({}, prev), curr);
40
+ });
41
+ }
27
42
  if (!(0, _utils.shouldRecalcDecorations)({
28
43
  oldEditorState: oldEditorState,
29
44
  newEditorState: newEditorState
30
- })) {
45
+ }) && ((_combinedMeta = combinedMeta) === null || _combinedMeta === void 0 ? void 0 : _combinedMeta.manualSelection) === undefined) {
31
46
  return;
32
47
  }
33
- var tr = newEditorState.tr;
34
48
  tr.setMeta(_types.selectionPluginKey, {
35
49
  type: _actions.SelectionActionTypes.SET_DECORATIONS,
36
50
  selection: tr.selection,
37
- decorationSet: (0, _utils.getDecorations)(tr)
51
+ decorationSet: (0, _utils.getDecorations)(tr, (_combinedMeta2 = combinedMeta) === null || _combinedMeta2 === void 0 ? void 0 : _combinedMeta2.manualSelection)
38
52
  });
39
53
  return tr;
40
54
  },
@@ -12,14 +12,18 @@ var _utils2 = require("@atlaskit/editor-prosemirror/utils");
12
12
  var _view = require("@atlaskit/editor-prosemirror/view");
13
13
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
14
14
  var _types = require("../types");
15
- var getDecorations = exports.getDecorations = function getDecorations(tr) {
16
- if (tr.selection instanceof _state.NodeSelection) {
17
- return _view.DecorationSet.create(tr.doc, [_view.Decoration.node(tr.selection.from, tr.selection.to, {
15
+ var getDecorations = exports.getDecorations = function getDecorations(tr, manualSelection) {
16
+ var selection = tr.selection;
17
+ if (selection instanceof _state.NodeSelection) {
18
+ return _view.DecorationSet.create(tr.doc, [_view.Decoration.node(selection.from, selection.to, {
18
19
  class: _editorSharedStyles.akEditorSelectedNodeClassName
19
20
  })]);
20
21
  }
21
- if (tr.selection instanceof _state.TextSelection || tr.selection instanceof _state.AllSelection) {
22
- var decorations = getNodesToDecorateFromSelection(tr.selection, tr.doc).map(function (_ref) {
22
+ if (selection instanceof _state.TextSelection || selection instanceof _state.AllSelection) {
23
+ if (manualSelection && manualSelection.anchor >= 0 && manualSelection.head >= 0 && manualSelection.anchor <= tr.doc.nodeSize && manualSelection.head <= tr.doc.nodeSize) {
24
+ selection = _state.TextSelection.create(tr.doc, manualSelection.anchor, manualSelection.head);
25
+ }
26
+ var decorations = getNodesToDecorateFromSelection(selection, tr.doc).map(function (_ref) {
23
27
  var node = _ref.node,
24
28
  pos = _ref.pos;
25
29
  return _view.Decoration.node(pos, pos + node.nodeSize, {
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.selectionPlugin = exports.default = void 0;
8
8
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
10
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
10
11
  var _autoExpandSelectionRangeOnInlineNodeMain = require("./pm-plugins/auto-expand-selection-range-on-inline-node-main");
11
12
  var _commands = require("./pm-plugins/commands");
@@ -16,6 +17,8 @@ var _keymap = _interopRequireDefault(require("./pm-plugins/keymap"));
16
17
  var _markBoundaryCursorMain = require("./pm-plugins/mark-boundary-cursor-main");
17
18
  var _selectionMain = require("./pm-plugins/selection-main");
18
19
  var _types = require("./types");
20
+ 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; }
21
+ 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; }
19
22
  var displayGapCursor = function displayGapCursor(toggle) {
20
23
  return function (_ref) {
21
24
  var tr = _ref.tr;
@@ -24,17 +27,40 @@ var displayGapCursor = function displayGapCursor(toggle) {
24
27
  });
25
28
  };
26
29
  };
27
- var selectionPlugin = exports.selectionPlugin = function selectionPlugin(_ref2) {
28
- var options = _ref2.config;
30
+ var clearManualSelection = function clearManualSelection() {
31
+ return function (_ref2) {
32
+ var tr = _ref2.tr;
33
+ var currMeta = tr.getMeta(_types.selectionPluginKey);
34
+ return tr.setMeta(_types.selectionPluginKey, _objectSpread(_objectSpread({}, currMeta), {}, {
35
+ manualSelection: {}
36
+ }));
37
+ };
38
+ };
39
+ var setManualSelection = function setManualSelection(anchor, head) {
40
+ return function (_ref3) {
41
+ var tr = _ref3.tr;
42
+ var currMeta = tr.getMeta(_types.selectionPluginKey);
43
+ return tr.setMeta(_types.selectionPluginKey, _objectSpread(_objectSpread({}, currMeta), {}, {
44
+ manualSelection: {
45
+ anchor: anchor,
46
+ head: head
47
+ }
48
+ }));
49
+ };
50
+ };
51
+ var selectionPlugin = exports.selectionPlugin = function selectionPlugin(_ref4) {
52
+ var options = _ref4.config;
29
53
  return {
30
54
  name: 'selection',
31
55
  commands: {
32
- displayGapCursor: displayGapCursor
56
+ displayGapCursor: displayGapCursor,
57
+ clearManualSelection: clearManualSelection,
58
+ setManualSelection: setManualSelection
33
59
  },
34
60
  actions: {
35
- selectNearNode: function selectNearNode(_ref3) {
36
- var selectionRelativeToNode = _ref3.selectionRelativeToNode,
37
- selection = _ref3.selection;
61
+ selectNearNode: function selectNearNode(_ref5) {
62
+ var selectionRelativeToNode = _ref5.selectionRelativeToNode,
63
+ selection = _ref5.selection;
38
64
  return function (state) {
39
65
  return (0, _commands.selectNearNode)(selectionRelativeToNode, selection)({
40
66
  tr: state.tr
@@ -55,9 +81,9 @@ var selectionPlugin = exports.selectionPlugin = function selectionPlugin(_ref2)
55
81
  pmPlugins: function pmPlugins() {
56
82
  return [{
57
83
  name: 'selection',
58
- plugin: function plugin(_ref4) {
59
- var dispatch = _ref4.dispatch,
60
- dispatchAnalyticsEvent = _ref4.dispatchAnalyticsEvent;
84
+ plugin: function plugin(_ref6) {
85
+ var dispatch = _ref6.dispatch,
86
+ dispatchAnalyticsEvent = _ref6.dispatchAnalyticsEvent;
61
87
  return (0, _selectionMain.createPlugin)(dispatch, dispatchAnalyticsEvent, options);
62
88
  }
63
89
  }, {
@@ -1,5 +1,6 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
2
  import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
3
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
3
4
  import { selectionPluginKey } from '../types';
4
5
  import { SelectionActionTypes } from './actions';
5
6
  import { onCreateSelectionBetween } from './events/create-selection-between';
@@ -14,20 +15,30 @@ export const createPlugin = (dispatch, dispatchAnalyticsEvent, options = {}) =>
14
15
  return new SafePlugin({
15
16
  key: selectionPluginKey,
16
17
  state: createPluginState(dispatch, getInitialState),
17
- appendTransaction(_transactions, oldEditorState, newEditorState) {
18
+ appendTransaction(transactions, oldEditorState, newEditorState) {
19
+ var _combinedMeta, _combinedMeta2;
20
+ const {
21
+ tr
22
+ } = newEditorState;
23
+ let combinedMeta = {};
24
+ if (editorExperiment('platform_editor_element_drag_and_drop_multiselect', true)) {
25
+ combinedMeta = transactions.map(value => value.getMeta(selectionPluginKey)).reduce((prev, curr) => {
26
+ return {
27
+ ...prev,
28
+ ...curr
29
+ };
30
+ });
31
+ }
18
32
  if (!shouldRecalcDecorations({
19
33
  oldEditorState,
20
34
  newEditorState
21
- })) {
35
+ }) && ((_combinedMeta = combinedMeta) === null || _combinedMeta === void 0 ? void 0 : _combinedMeta.manualSelection) === undefined) {
22
36
  return;
23
37
  }
24
- const {
25
- tr
26
- } = newEditorState;
27
38
  tr.setMeta(selectionPluginKey, {
28
39
  type: SelectionActionTypes.SET_DECORATIONS,
29
40
  selection: tr.selection,
30
- decorationSet: getDecorations(tr)
41
+ decorationSet: getDecorations(tr, (_combinedMeta2 = combinedMeta) === null || _combinedMeta2 === void 0 ? void 0 : _combinedMeta2.manualSelection)
31
42
  });
32
43
  return tr;
33
44
  },
@@ -5,14 +5,18 @@ import { findParentNode, flatten } from '@atlaskit/editor-prosemirror/utils';
5
5
  import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
6
6
  import { akEditorSelectedNodeClassName } from '@atlaskit/editor-shared-styles';
7
7
  import { selectionPluginKey } from '../types';
8
- export const getDecorations = tr => {
9
- if (tr.selection instanceof NodeSelection) {
10
- return DecorationSet.create(tr.doc, [Decoration.node(tr.selection.from, tr.selection.to, {
8
+ export const getDecorations = (tr, manualSelection) => {
9
+ let selection = tr.selection;
10
+ if (selection instanceof NodeSelection) {
11
+ return DecorationSet.create(tr.doc, [Decoration.node(selection.from, selection.to, {
11
12
  class: akEditorSelectedNodeClassName
12
13
  })]);
13
14
  }
14
- if (tr.selection instanceof TextSelection || tr.selection instanceof AllSelection) {
15
- const decorations = getNodesToDecorateFromSelection(tr.selection, tr.doc).map(({
15
+ if (selection instanceof TextSelection || selection instanceof AllSelection) {
16
+ if (manualSelection && manualSelection.anchor >= 0 && manualSelection.head >= 0 && manualSelection.anchor <= tr.doc.nodeSize && manualSelection.head <= tr.doc.nodeSize) {
17
+ selection = TextSelection.create(tr.doc, manualSelection.anchor, manualSelection.head);
18
+ }
19
+ const decorations = getNodesToDecorateFromSelection(selection, tr.doc).map(({
16
20
  node,
17
21
  pos
18
22
  }) => {
@@ -15,12 +15,35 @@ const displayGapCursor = toggle => ({
15
15
  displayGapCursor: toggle
16
16
  });
17
17
  };
18
+ const clearManualSelection = () => ({
19
+ tr
20
+ }) => {
21
+ const currMeta = tr.getMeta(selectionPluginKey);
22
+ return tr.setMeta(selectionPluginKey, {
23
+ ...currMeta,
24
+ manualSelection: {}
25
+ });
26
+ };
27
+ const setManualSelection = (anchor, head) => ({
28
+ tr
29
+ }) => {
30
+ const currMeta = tr.getMeta(selectionPluginKey);
31
+ return tr.setMeta(selectionPluginKey, {
32
+ ...currMeta,
33
+ manualSelection: {
34
+ anchor,
35
+ head
36
+ }
37
+ });
38
+ };
18
39
  export const selectionPlugin = ({
19
40
  config: options
20
41
  }) => ({
21
42
  name: 'selection',
22
43
  commands: {
23
- displayGapCursor
44
+ displayGapCursor,
45
+ clearManualSelection,
46
+ setManualSelection
24
47
  },
25
48
  actions: {
26
49
  selectNearNode: ({
@@ -1,5 +1,9 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ 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; }
3
+ 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) { _defineProperty(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; }
1
4
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
5
  import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
6
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
3
7
  import { selectionPluginKey } from '../types';
4
8
  import { SelectionActionTypes } from './actions';
5
9
  import { onCreateSelectionBetween } from './events/create-selection-between';
@@ -17,18 +21,27 @@ export var createPlugin = function createPlugin(dispatch, dispatchAnalyticsEvent
17
21
  return new SafePlugin({
18
22
  key: selectionPluginKey,
19
23
  state: createPluginState(dispatch, getInitialState),
20
- appendTransaction: function appendTransaction(_transactions, oldEditorState, newEditorState) {
24
+ appendTransaction: function appendTransaction(transactions, oldEditorState, newEditorState) {
25
+ var _combinedMeta, _combinedMeta2;
26
+ var tr = newEditorState.tr;
27
+ var combinedMeta = {};
28
+ if (editorExperiment('platform_editor_element_drag_and_drop_multiselect', true)) {
29
+ combinedMeta = transactions.map(function (value) {
30
+ return value.getMeta(selectionPluginKey);
31
+ }).reduce(function (prev, curr) {
32
+ return _objectSpread(_objectSpread({}, prev), curr);
33
+ });
34
+ }
21
35
  if (!shouldRecalcDecorations({
22
36
  oldEditorState: oldEditorState,
23
37
  newEditorState: newEditorState
24
- })) {
38
+ }) && ((_combinedMeta = combinedMeta) === null || _combinedMeta === void 0 ? void 0 : _combinedMeta.manualSelection) === undefined) {
25
39
  return;
26
40
  }
27
- var tr = newEditorState.tr;
28
41
  tr.setMeta(selectionPluginKey, {
29
42
  type: SelectionActionTypes.SET_DECORATIONS,
30
43
  selection: tr.selection,
31
- decorationSet: getDecorations(tr)
44
+ decorationSet: getDecorations(tr, (_combinedMeta2 = combinedMeta) === null || _combinedMeta2 === void 0 ? void 0 : _combinedMeta2.manualSelection)
32
45
  });
33
46
  return tr;
34
47
  },
@@ -5,14 +5,18 @@ import { findParentNode, flatten } from '@atlaskit/editor-prosemirror/utils';
5
5
  import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
6
6
  import { akEditorSelectedNodeClassName } from '@atlaskit/editor-shared-styles';
7
7
  import { selectionPluginKey } from '../types';
8
- export var getDecorations = function getDecorations(tr) {
9
- if (tr.selection instanceof NodeSelection) {
10
- return DecorationSet.create(tr.doc, [Decoration.node(tr.selection.from, tr.selection.to, {
8
+ export var getDecorations = function getDecorations(tr, manualSelection) {
9
+ var selection = tr.selection;
10
+ if (selection instanceof NodeSelection) {
11
+ return DecorationSet.create(tr.doc, [Decoration.node(selection.from, selection.to, {
11
12
  class: akEditorSelectedNodeClassName
12
13
  })]);
13
14
  }
14
- if (tr.selection instanceof TextSelection || tr.selection instanceof AllSelection) {
15
- var decorations = getNodesToDecorateFromSelection(tr.selection, tr.doc).map(function (_ref) {
15
+ if (selection instanceof TextSelection || selection instanceof AllSelection) {
16
+ if (manualSelection && manualSelection.anchor >= 0 && manualSelection.head >= 0 && manualSelection.anchor <= tr.doc.nodeSize && manualSelection.head <= tr.doc.nodeSize) {
17
+ selection = TextSelection.create(tr.doc, manualSelection.anchor, manualSelection.head);
18
+ }
19
+ var decorations = getNodesToDecorateFromSelection(selection, tr.doc).map(function (_ref) {
16
20
  var node = _ref.node,
17
21
  pos = _ref.pos;
18
22
  return Decoration.node(pos, pos + node.nodeSize, {
@@ -1,4 +1,7 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+ 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; }
4
+ 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) { _defineProperty(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; }
2
5
  import { fg } from '@atlaskit/platform-feature-flags';
3
6
  import { createAutoExpandSelectionRangeOnInlineNodePlugin } from './pm-plugins/auto-expand-selection-range-on-inline-node-main';
4
7
  import { selectNearNode as _selectNearNode } from './pm-plugins/commands';
@@ -17,17 +20,40 @@ var displayGapCursor = function displayGapCursor(toggle) {
17
20
  });
18
21
  };
19
22
  };
20
- export var selectionPlugin = function selectionPlugin(_ref2) {
21
- var options = _ref2.config;
23
+ var clearManualSelection = function clearManualSelection() {
24
+ return function (_ref2) {
25
+ var tr = _ref2.tr;
26
+ var currMeta = tr.getMeta(selectionPluginKey);
27
+ return tr.setMeta(selectionPluginKey, _objectSpread(_objectSpread({}, currMeta), {}, {
28
+ manualSelection: {}
29
+ }));
30
+ };
31
+ };
32
+ var setManualSelection = function setManualSelection(anchor, head) {
33
+ return function (_ref3) {
34
+ var tr = _ref3.tr;
35
+ var currMeta = tr.getMeta(selectionPluginKey);
36
+ return tr.setMeta(selectionPluginKey, _objectSpread(_objectSpread({}, currMeta), {}, {
37
+ manualSelection: {
38
+ anchor: anchor,
39
+ head: head
40
+ }
41
+ }));
42
+ };
43
+ };
44
+ export var selectionPlugin = function selectionPlugin(_ref4) {
45
+ var options = _ref4.config;
22
46
  return {
23
47
  name: 'selection',
24
48
  commands: {
25
- displayGapCursor: displayGapCursor
49
+ displayGapCursor: displayGapCursor,
50
+ clearManualSelection: clearManualSelection,
51
+ setManualSelection: setManualSelection
26
52
  },
27
53
  actions: {
28
- selectNearNode: function selectNearNode(_ref3) {
29
- var selectionRelativeToNode = _ref3.selectionRelativeToNode,
30
- selection = _ref3.selection;
54
+ selectNearNode: function selectNearNode(_ref5) {
55
+ var selectionRelativeToNode = _ref5.selectionRelativeToNode,
56
+ selection = _ref5.selection;
31
57
  return function (state) {
32
58
  return _selectNearNode(selectionRelativeToNode, selection)({
33
59
  tr: state.tr
@@ -48,9 +74,9 @@ export var selectionPlugin = function selectionPlugin(_ref2) {
48
74
  pmPlugins: function pmPlugins() {
49
75
  return [{
50
76
  name: 'selection',
51
- plugin: function plugin(_ref4) {
52
- var dispatch = _ref4.dispatch,
53
- dispatchAnalyticsEvent = _ref4.dispatchAnalyticsEvent;
77
+ plugin: function plugin(_ref6) {
78
+ var dispatch = _ref6.dispatch,
79
+ dispatchAnalyticsEvent = _ref6.dispatchAnalyticsEvent;
54
80
  return createPlugin(dispatch, dispatchAnalyticsEvent, options);
55
81
  }
56
82
  }, {
@@ -3,7 +3,10 @@ import type { EditorState, ReadonlyTransaction, Transaction } from '@atlaskit/ed
3
3
  import { Selection } from '@atlaskit/editor-prosemirror/state';
4
4
  import type { ContentNodeWithPos, NodeWithPos } from '@atlaskit/editor-prosemirror/utils';
5
5
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
6
- export declare const getDecorations: (tr: Transaction | ReadonlyTransaction) => DecorationSet;
6
+ export declare const getDecorations: (tr: Transaction | ReadonlyTransaction, manualSelection?: {
7
+ anchor: number;
8
+ head: number;
9
+ }) => DecorationSet;
7
10
  /**
8
11
  * Use `getNodesToDecorateFromSelection` to collect and return
9
12
  * a list of nodes within the Selection that should have Selection
@@ -6,6 +6,8 @@ export type SelectionPlugin = NextEditorPlugin<'selection', {
6
6
  actions: EditorSelectionAPI;
7
7
  commands: {
8
8
  displayGapCursor: (toggle: boolean) => EditorCommand;
9
+ clearManualSelection: () => EditorCommand;
10
+ setManualSelection: (anchor: number, head: number) => EditorCommand;
9
11
  };
10
12
  sharedState: SelectionSharedState;
11
13
  }>;
@@ -3,7 +3,10 @@ import type { EditorState, ReadonlyTransaction, Transaction } from '@atlaskit/ed
3
3
  import { Selection } from '@atlaskit/editor-prosemirror/state';
4
4
  import type { ContentNodeWithPos, NodeWithPos } from '@atlaskit/editor-prosemirror/utils';
5
5
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
6
- export declare const getDecorations: (tr: Transaction | ReadonlyTransaction) => DecorationSet;
6
+ export declare const getDecorations: (tr: Transaction | ReadonlyTransaction, manualSelection?: {
7
+ anchor: number;
8
+ head: number;
9
+ }) => DecorationSet;
7
10
  /**
8
11
  * Use `getNodesToDecorateFromSelection` to collect and return
9
12
  * a list of nodes within the Selection that should have Selection
@@ -6,6 +6,8 @@ export type SelectionPlugin = NextEditorPlugin<'selection', {
6
6
  actions: EditorSelectionAPI;
7
7
  commands: {
8
8
  displayGapCursor: (toggle: boolean) => EditorCommand;
9
+ clearManualSelection: () => EditorCommand;
10
+ setManualSelection: (anchor: number, head: number) => EditorCommand;
9
11
  };
10
12
  sharedState: SelectionSharedState;
11
13
  }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-selection",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
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": "^99.10.0",
23
+ "@atlaskit/editor-common": "^99.11.0",
24
24
  "@atlaskit/editor-prosemirror": "7.0.0",
25
25
  "@atlaskit/editor-shared-styles": "^3.2.0",
26
26
  "@atlaskit/editor-tables": "^2.9.0",
27
27
  "@atlaskit/platform-feature-flags": "^1.0.0",
28
- "@atlaskit/tmp-editor-statsig": "2.43.0",
28
+ "@atlaskit/tmp-editor-statsig": "2.44.0",
29
29
  "@atlaskit/tokens": "^3.3.0",
30
30
  "@babel/runtime": "^7.0.0"
31
31
  },