@atlaskit/editor-plugin-selection 1.8.0 → 1.8.2

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,19 @@
1
1
  # @atlaskit/editor-plugin-selection
2
2
 
3
+ ## 1.8.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#112743](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/112743)
8
+ [`7f0dcc0e66696`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/7f0dcc0e66696) -
9
+ Refactor appendTransaction
10
+
11
+ ## 1.8.1
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies
16
+
3
17
  ## 1.8.0
4
18
 
5
19
  ### Minor Changes
@@ -1,11 +1,9 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.getInitialState = exports.createPlugin = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
7
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
10
8
  var _state = require("@atlaskit/editor-prosemirror/state");
11
9
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
@@ -15,8 +13,6 @@ var _createSelectionBetween = require("./events/create-selection-between");
15
13
  var _keydown = require("./events/keydown");
16
14
  var _pluginFactory = require("./plugin-factory");
17
15
  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; }
20
16
  var getInitialState = exports.getInitialState = function getInitialState(state) {
21
17
  return {
22
18
  decorationSet: (0, _utils.getDecorations)(state.tr),
@@ -29,26 +25,28 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, dispat
29
25
  key: _types.selectionPluginKey,
30
26
  state: (0, _pluginFactory.createPluginState)(dispatch, getInitialState),
31
27
  appendTransaction: function appendTransaction(transactions, oldEditorState, newEditorState) {
32
- var _combinedMeta, _combinedMeta2;
33
28
  var tr = newEditorState.tr;
34
- var combinedMeta = {};
29
+ var manualSelection;
35
30
  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
- });
31
+ // Start at most recent transaction, look for manualSelection meta
32
+ for (var i = transactions.length - 1; i >= 0; i--) {
33
+ var _transactions$i$getMe;
34
+ manualSelection = (_transactions$i$getMe = transactions[i].getMeta(_types.selectionPluginKey)) === null || _transactions$i$getMe === void 0 ? void 0 : _transactions$i$getMe.manualSelection;
35
+ if (manualSelection) {
36
+ break;
37
+ }
38
+ }
41
39
  }
42
40
  if (!(0, _utils.shouldRecalcDecorations)({
43
41
  oldEditorState: oldEditorState,
44
42
  newEditorState: newEditorState
45
- }) && ((_combinedMeta = combinedMeta) === null || _combinedMeta === void 0 ? void 0 : _combinedMeta.manualSelection) === undefined) {
43
+ }) && !manualSelection) {
46
44
  return;
47
45
  }
48
46
  tr.setMeta(_types.selectionPluginKey, {
49
47
  type: _actions.SelectionActionTypes.SET_DECORATIONS,
50
48
  selection: tr.selection,
51
- decorationSet: (0, _utils.getDecorations)(tr, (_combinedMeta2 = combinedMeta) === null || _combinedMeta2 === void 0 ? void 0 : _combinedMeta2.manualSelection)
49
+ decorationSet: (0, _utils.getDecorations)(tr, manualSelection)
52
50
  });
53
51
  return tr;
54
52
  },
@@ -16,29 +16,30 @@ export const createPlugin = (dispatch, dispatchAnalyticsEvent, options = {}) =>
16
16
  key: selectionPluginKey,
17
17
  state: createPluginState(dispatch, getInitialState),
18
18
  appendTransaction(transactions, oldEditorState, newEditorState) {
19
- var _combinedMeta, _combinedMeta2;
20
19
  const {
21
20
  tr
22
21
  } = newEditorState;
23
- let combinedMeta = {};
22
+ let manualSelection;
24
23
  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
- });
24
+ // Start at most recent transaction, look for manualSelection meta
25
+ for (let i = transactions.length - 1; i >= 0; i--) {
26
+ var _transactions$i$getMe;
27
+ manualSelection = (_transactions$i$getMe = transactions[i].getMeta(selectionPluginKey)) === null || _transactions$i$getMe === void 0 ? void 0 : _transactions$i$getMe.manualSelection;
28
+ if (manualSelection) {
29
+ break;
30
+ }
31
+ }
31
32
  }
32
33
  if (!shouldRecalcDecorations({
33
34
  oldEditorState,
34
35
  newEditorState
35
- }) && ((_combinedMeta = combinedMeta) === null || _combinedMeta === void 0 ? void 0 : _combinedMeta.manualSelection) === undefined) {
36
+ }) && !manualSelection) {
36
37
  return;
37
38
  }
38
39
  tr.setMeta(selectionPluginKey, {
39
40
  type: SelectionActionTypes.SET_DECORATIONS,
40
41
  selection: tr.selection,
41
- decorationSet: getDecorations(tr, (_combinedMeta2 = combinedMeta) === null || _combinedMeta2 === void 0 ? void 0 : _combinedMeta2.manualSelection)
42
+ decorationSet: getDecorations(tr, manualSelection)
42
43
  });
43
44
  return tr;
44
45
  },
@@ -1,6 +1,3 @@
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; }
4
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
5
2
  import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
6
3
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
@@ -22,26 +19,28 @@ export var createPlugin = function createPlugin(dispatch, dispatchAnalyticsEvent
22
19
  key: selectionPluginKey,
23
20
  state: createPluginState(dispatch, getInitialState),
24
21
  appendTransaction: function appendTransaction(transactions, oldEditorState, newEditorState) {
25
- var _combinedMeta, _combinedMeta2;
26
22
  var tr = newEditorState.tr;
27
- var combinedMeta = {};
23
+ var manualSelection;
28
24
  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
- });
25
+ // Start at most recent transaction, look for manualSelection meta
26
+ for (var i = transactions.length - 1; i >= 0; i--) {
27
+ var _transactions$i$getMe;
28
+ manualSelection = (_transactions$i$getMe = transactions[i].getMeta(selectionPluginKey)) === null || _transactions$i$getMe === void 0 ? void 0 : _transactions$i$getMe.manualSelection;
29
+ if (manualSelection) {
30
+ break;
31
+ }
32
+ }
34
33
  }
35
34
  if (!shouldRecalcDecorations({
36
35
  oldEditorState: oldEditorState,
37
36
  newEditorState: newEditorState
38
- }) && ((_combinedMeta = combinedMeta) === null || _combinedMeta === void 0 ? void 0 : _combinedMeta.manualSelection) === undefined) {
37
+ }) && !manualSelection) {
39
38
  return;
40
39
  }
41
40
  tr.setMeta(selectionPluginKey, {
42
41
  type: SelectionActionTypes.SET_DECORATIONS,
43
42
  selection: tr.selection,
44
- decorationSet: getDecorations(tr, (_combinedMeta2 = combinedMeta) === null || _combinedMeta2 === void 0 ? void 0 : _combinedMeta2.manualSelection)
43
+ decorationSet: getDecorations(tr, manualSelection)
45
44
  });
46
45
  return tr;
47
46
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-selection",
3
- "version": "1.8.0",
3
+ "version": "1.8.2",
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.11.0",
23
+ "@atlaskit/editor-common": "^99.13.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.44.0",
28
+ "@atlaskit/tmp-editor-statsig": "2.45.0",
29
29
  "@atlaskit/tokens": "^3.3.0",
30
30
  "@babel/runtime": "^7.0.0"
31
31
  },