@atlaskit/editor-plugin-block-controls 3.1.0 → 3.1.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,21 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 3.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#117869](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/117869)
8
+ [`1668bcd621203`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1668bcd621203) -
9
+ COMPHUB-2622 Added data attributes for editor elements
10
+
11
+ ## 3.1.1
12
+
13
+ ### Patch Changes
14
+
15
+ - [#117391](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/117391)
16
+ [`1655b74fcb544`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1655b74fcb544) -
17
+ Fix drop table on table trigger native dnd
18
+
3
19
  ## 3.1.0
4
20
 
5
21
  ### Minor Changes
@@ -13,9 +13,11 @@ var _analytics = require("@atlaskit/editor-common/analytics");
13
13
  var _browser = require("@atlaskit/editor-common/browser");
14
14
  var _performanceMeasures = require("@atlaskit/editor-common/performance-measures");
15
15
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
16
+ var _selection2 = require("@atlaskit/editor-common/selection");
16
17
  var _utils = require("@atlaskit/editor-common/utils");
17
18
  var _state = require("@atlaskit/editor-prosemirror/state");
18
19
  var _view2 = require("@atlaskit/editor-prosemirror/view");
20
+ var _editorTables = require("@atlaskit/editor-tables");
19
21
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
20
22
  var _element = require("@atlaskit/pragmatic-drag-and-drop-auto-scroll/element");
21
23
  var _combine = require("@atlaskit/pragmatic-drag-and-drop/combine");
@@ -29,7 +31,7 @@ var _keymap = require("./keymap");
29
31
  var _activeAnchorTracker = require("./utils/active-anchor-tracker");
30
32
  var _analytics2 = require("./utils/analytics");
31
33
  var _anchorUtils = require("./utils/anchor-utils");
32
- var _selection2 = require("./utils/selection");
34
+ var _selection3 = require("./utils/selection");
33
35
  var _transactions = require("./utils/transactions");
34
36
  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; }
35
37
  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; }
@@ -107,7 +109,7 @@ var destroyFn = function destroyFn(api, editorView) {
107
109
  var _api$analytics2;
108
110
  var nodeTypes, hasSelectedMultipleNodes;
109
111
  if (isMultiSelect && api) {
110
- var position = (0, _selection2.getSelectedSlicePosition)(start, tr, api);
112
+ var position = (0, _selection3.getSelectedSlicePosition)(start, tr, api);
111
113
  var attributes = (0, _analytics2.getMultiSelectAnalyticsAttributes)(tr, position.from, position.to);
112
114
  nodeTypes = attributes.nodeTypes;
113
115
  hasSelectedMultipleNodes = attributes.hasSelectedMultipleNodes;
@@ -535,10 +537,26 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
535
537
  var domPos = Math.max(view.posAtDOM(nodeElement, 0) - 1, 0);
536
538
  var nodeTarget = state.doc.nodeAt(domPos);
537
539
  var isSameNode = !!(nodeTarget && draggable !== null && draggable !== void 0 && draggable.eq(nodeTarget));
538
- var isInSelection = domPos >= state.selection.$from.pos && domPos < state.selection.$to.pos;
539
540
 
540
- // Prevent the default drop behavior if the position is within the activeNode or Editor selection
541
- if (isSameNode || isInSelection && isMultiSelectEnabled) {
541
+ // CellSelection doesn't expose true from/to positions, we need to query the ranges
542
+ var selectionRange = state.selection instanceof _editorTables.CellSelection ? state.selection.ranges.reduce(function (previousValue, currentValue, _currentIndex, _array) {
543
+ return {
544
+ $from: currentValue.$from.min(previousValue.$from),
545
+ $to: currentValue.$to.max(previousValue.$to)
546
+ };
547
+ }) : {
548
+ $from: state.selection.$from,
549
+ $to: state.selection.$to
550
+ };
551
+ var expandedSelection = (0, _selection2.expandSelectionBounds)(selectionRange.$from, selectionRange.$to);
552
+ var expandedAnchor = expandedSelection.$anchor;
553
+ var expandedHead = expandedSelection.$head;
554
+ var expandedSelectionFrom = Math.min(expandedAnchor.pos, expandedHead.pos);
555
+ var expandedSelectionTo = Math.max(expandedAnchor.pos, expandedHead.pos);
556
+ var isInExpandedSelection = domPos >= expandedSelectionFrom && domPos < expandedSelectionTo;
557
+
558
+ // Prevent the default drop behavior if the position is within the activeNode or within the expanded selection when multiselect is on
559
+ if (isSameNode || isInExpandedSelection && isMultiSelectEnabled) {
542
560
  event.preventDefault();
543
561
  return true;
544
562
  }
@@ -624,6 +624,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
624
624
  ,
625
625
  onDrop: handleOnDrop,
626
626
  disabled: dragHandleDisabled,
627
+ "data-editor-block-ctrl-drag-handle": true,
627
628
  "data-testid": "block-ctrl-drag-handle"
628
629
  }, (0, _react2.jsx)(_primitives.Box, {
629
630
  as: "span",
@@ -4,9 +4,11 @@ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit
4
4
  import { browser } from '@atlaskit/editor-common/browser';
5
5
  import { isMeasuring, startMeasure, stopMeasure } from '@atlaskit/editor-common/performance-measures';
6
6
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
7
+ import { expandSelectionBounds } from '@atlaskit/editor-common/selection';
7
8
  import { isEmptyDocument, isTextInput } from '@atlaskit/editor-common/utils';
8
9
  import { NodeSelection, PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
9
10
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
11
+ import { CellSelection } from '@atlaskit/editor-tables';
10
12
  import { fg } from '@atlaskit/platform-feature-flags';
11
13
  import { autoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-scroll/element';
12
14
  import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
@@ -520,10 +522,26 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI) => {
520
522
  const domPos = Math.max(view.posAtDOM(nodeElement, 0) - 1, 0);
521
523
  const nodeTarget = state.doc.nodeAt(domPos);
522
524
  const isSameNode = !!(nodeTarget && draggable !== null && draggable !== void 0 && draggable.eq(nodeTarget));
523
- const isInSelection = domPos >= state.selection.$from.pos && domPos < state.selection.$to.pos;
524
525
 
525
- // Prevent the default drop behavior if the position is within the activeNode or Editor selection
526
- if (isSameNode || isInSelection && isMultiSelectEnabled) {
526
+ // CellSelection doesn't expose true from/to positions, we need to query the ranges
527
+ const selectionRange = state.selection instanceof CellSelection ? state.selection.ranges.reduce((previousValue, currentValue, _currentIndex, _array) => {
528
+ return {
529
+ $from: currentValue.$from.min(previousValue.$from),
530
+ $to: currentValue.$to.max(previousValue.$to)
531
+ };
532
+ }) : {
533
+ $from: state.selection.$from,
534
+ $to: state.selection.$to
535
+ };
536
+ const expandedSelection = expandSelectionBounds(selectionRange.$from, selectionRange.$to);
537
+ const expandedAnchor = expandedSelection.$anchor;
538
+ const expandedHead = expandedSelection.$head;
539
+ const expandedSelectionFrom = Math.min(expandedAnchor.pos, expandedHead.pos);
540
+ const expandedSelectionTo = Math.max(expandedAnchor.pos, expandedHead.pos);
541
+ const isInExpandedSelection = domPos >= expandedSelectionFrom && domPos < expandedSelectionTo;
542
+
543
+ // Prevent the default drop behavior if the position is within the activeNode or within the expanded selection when multiselect is on
544
+ if (isSameNode || isInExpandedSelection && isMultiSelectEnabled) {
527
545
  event.preventDefault();
528
546
  return true;
529
547
  }
@@ -607,6 +607,7 @@ export const DragHandle = ({
607
607
  ,
608
608
  onDrop: handleOnDrop,
609
609
  disabled: dragHandleDisabled,
610
+ "data-editor-block-ctrl-drag-handle": true,
610
611
  "data-testid": "block-ctrl-drag-handle"
611
612
  }, jsx(Box, {
612
613
  as: "span",
@@ -8,9 +8,11 @@ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit
8
8
  import { browser } from '@atlaskit/editor-common/browser';
9
9
  import { isMeasuring, startMeasure, stopMeasure } from '@atlaskit/editor-common/performance-measures';
10
10
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
11
+ import { expandSelectionBounds } from '@atlaskit/editor-common/selection';
11
12
  import { isEmptyDocument, isTextInput } from '@atlaskit/editor-common/utils';
12
13
  import { NodeSelection, PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
13
14
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
15
+ import { CellSelection } from '@atlaskit/editor-tables';
14
16
  import { fg } from '@atlaskit/platform-feature-flags';
15
17
  import { autoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-scroll/element';
16
18
  import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
@@ -528,10 +530,26 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
528
530
  var domPos = Math.max(view.posAtDOM(nodeElement, 0) - 1, 0);
529
531
  var nodeTarget = state.doc.nodeAt(domPos);
530
532
  var isSameNode = !!(nodeTarget && draggable !== null && draggable !== void 0 && draggable.eq(nodeTarget));
531
- var isInSelection = domPos >= state.selection.$from.pos && domPos < state.selection.$to.pos;
532
533
 
533
- // Prevent the default drop behavior if the position is within the activeNode or Editor selection
534
- if (isSameNode || isInSelection && isMultiSelectEnabled) {
534
+ // CellSelection doesn't expose true from/to positions, we need to query the ranges
535
+ var selectionRange = state.selection instanceof CellSelection ? state.selection.ranges.reduce(function (previousValue, currentValue, _currentIndex, _array) {
536
+ return {
537
+ $from: currentValue.$from.min(previousValue.$from),
538
+ $to: currentValue.$to.max(previousValue.$to)
539
+ };
540
+ }) : {
541
+ $from: state.selection.$from,
542
+ $to: state.selection.$to
543
+ };
544
+ var expandedSelection = expandSelectionBounds(selectionRange.$from, selectionRange.$to);
545
+ var expandedAnchor = expandedSelection.$anchor;
546
+ var expandedHead = expandedSelection.$head;
547
+ var expandedSelectionFrom = Math.min(expandedAnchor.pos, expandedHead.pos);
548
+ var expandedSelectionTo = Math.max(expandedAnchor.pos, expandedHead.pos);
549
+ var isInExpandedSelection = domPos >= expandedSelectionFrom && domPos < expandedSelectionTo;
550
+
551
+ // Prevent the default drop behavior if the position is within the activeNode or within the expanded selection when multiselect is on
552
+ if (isSameNode || isInExpandedSelection && isMultiSelectEnabled) {
535
553
  event.preventDefault();
536
554
  return true;
537
555
  }
@@ -619,6 +619,7 @@ export var DragHandle = function DragHandle(_ref) {
619
619
  ,
620
620
  onDrop: handleOnDrop,
621
621
  disabled: dragHandleDisabled,
622
+ "data-editor-block-ctrl-drag-handle": true,
622
623
  "data-testid": "block-ctrl-drag-handle"
623
624
  }, jsx(Box, {
624
625
  as: "span",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "3.1.0",
3
+ "version": "3.1.2",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -42,15 +42,15 @@
42
42
  "@atlaskit/editor-prosemirror": "7.0.0",
43
43
  "@atlaskit/editor-shared-styles": "^3.3.0",
44
44
  "@atlaskit/editor-tables": "^2.9.0",
45
- "@atlaskit/icon": "^24.0.0",
45
+ "@atlaskit/icon": "^24.1.0",
46
46
  "@atlaskit/platform-feature-flags": "^1.1.0",
47
47
  "@atlaskit/pragmatic-drag-and-drop": "^1.5.0",
48
48
  "@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^2.1.0",
49
49
  "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^2.0.0",
50
- "@atlaskit/primitives": "^14.0.0",
50
+ "@atlaskit/primitives": "^14.1.0",
51
51
  "@atlaskit/theme": "^17.0.0",
52
52
  "@atlaskit/tmp-editor-statsig": "^3.2.0",
53
- "@atlaskit/tokens": "^4.1.0",
53
+ "@atlaskit/tokens": "^4.2.0",
54
54
  "@atlaskit/tooltip": "^20.0.0",
55
55
  "@babel/runtime": "^7.0.0",
56
56
  "@emotion/react": "^11.7.1",