@atlaskit/editor-plugin-block-controls 1.4.7 → 1.4.9

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/.eslintrc.js CHANGED
@@ -1,14 +1,14 @@
1
1
  module.exports = {
2
- rules: {
3
- '@typescript-eslint/no-duplicate-imports': 'error',
4
- '@typescript-eslint/no-explicit-any': 'error',
5
- },
6
- overrides: [
7
- {
8
- files: ['**/__tests__/**/*.{js,ts,tsx}', '**/examples/**/*.{js,ts,tsx}'],
9
- rules: {
10
- '@typescript-eslint/no-explicit-any': 'off',
11
- },
12
- },
13
- ],
2
+ rules: {
3
+ '@typescript-eslint/no-duplicate-imports': 'error',
4
+ '@typescript-eslint/no-explicit-any': 'error',
5
+ },
6
+ overrides: [
7
+ {
8
+ files: ['**/__tests__/**/*.{js,ts,tsx}', '**/examples/**/*.{js,ts,tsx}'],
9
+ rules: {
10
+ '@typescript-eslint/no-explicit-any': 'off',
11
+ },
12
+ },
13
+ ],
14
14
  };
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 1.4.9
4
+
5
+ ### Patch Changes
6
+
7
+ - [#106586](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/106586)
8
+ [`861ecd061c72`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/861ecd061c72) -
9
+ Increase the editor page guttering for full page appearance to support block drag and drop
10
+ - [#107579](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/107579)
11
+ [`4953d4a32c98`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/4953d4a32c98) -
12
+ [ux] Expand blocks drop target to full doc width
13
+ - Updated dependencies
14
+
15
+ ## 1.4.8
16
+
17
+ ### Patch Changes
18
+
19
+ - [#103640](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/103640)
20
+ [`8efbf0dd0174`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8efbf0dd0174) -
21
+ Hide floating toolbar on dragging
22
+ - [#105200](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/105200)
23
+ [`6ba0d6402f38`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/6ba0d6402f38) -
24
+ Fix drag handle position when the node contains nested image
25
+
3
26
  ## 1.4.7
4
27
 
5
28
  ### Patch Changes
package/LICENSE.md CHANGED
@@ -1,13 +1,11 @@
1
1
  Copyright 2023 Atlassian Pty Ltd
2
2
 
3
- Licensed under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License.
5
- You may obtain a copy of the License at
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
4
+ compliance with the License. You may obtain a copy of the License at
6
5
 
7
6
  http://www.apache.org/licenses/LICENSE-2.0
8
7
 
9
- Unless required by applicable law or agreed to in writing, software
10
- distributed under the License is distributed on an "AS IS" BASIS,
11
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- See the License for the specific language governing permissions and
13
- limitations under the License.
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is
9
+ distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
10
+ implied. See the License for the specific language governing permissions and limitations under the
11
+ License.
@@ -41,14 +41,15 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
41
41
  }
42
42
  },
43
43
  getSharedState: function getSharedState(editorState) {
44
- var _key$getState$isMenuO, _key$getState, _key$getState$activeN, _key$getState2, _key$getState$decorat, _key$getState3;
44
+ var _key$getState$isMenuO, _key$getState, _key$getState$activeN, _key$getState2, _key$getState$decorat, _key$getState3, _key$getState$isDragg, _key$getState4;
45
45
  if (!editorState) {
46
46
  return undefined;
47
47
  }
48
48
  return {
49
49
  isMenuOpen: (_key$getState$isMenuO = (_key$getState = _main.key.getState(editorState)) === null || _key$getState === void 0 ? void 0 : _key$getState.isMenuOpen) !== null && _key$getState$isMenuO !== void 0 ? _key$getState$isMenuO : false,
50
50
  activeNode: (_key$getState$activeN = (_key$getState2 = _main.key.getState(editorState)) === null || _key$getState2 === void 0 ? void 0 : _key$getState2.activeNode) !== null && _key$getState$activeN !== void 0 ? _key$getState$activeN : null,
51
- decorationState: (_key$getState$decorat = (_key$getState3 = _main.key.getState(editorState)) === null || _key$getState3 === void 0 ? void 0 : _key$getState3.decorationState) !== null && _key$getState$decorat !== void 0 ? _key$getState$decorat : []
51
+ decorationState: (_key$getState$decorat = (_key$getState3 = _main.key.getState(editorState)) === null || _key$getState3 === void 0 ? void 0 : _key$getState3.decorationState) !== null && _key$getState$decorat !== void 0 ? _key$getState$decorat : [],
52
+ isDragging: (_key$getState$isDragg = (_key$getState4 = _main.key.getState(editorState)) === null || _key$getState4 === void 0 ? void 0 : _key$getState4.isDragging) !== null && _key$getState$isDragg !== void 0 ? _key$getState$isDragg : false
52
53
  };
53
54
  },
54
55
  contentComponent: function contentComponent() {
@@ -66,11 +66,13 @@ var dragHandleDecoration = exports.dragHandleDecoration = function dragHandleDec
66
66
  }), element);
67
67
  element.style.position = 'absolute';
68
68
  element.style.zIndex = '1';
69
- var resizer = meta.dom.querySelector('.resizer-item');
69
+
70
+ // If the selected node is a table or mediaSingle with resizer, we need to adjust the position of the drag handle
71
+ var resizer = ['table', 'mediaSingle'].includes(meta.type) ? meta.dom.querySelector('.resizer-item') : null;
70
72
  if (resizer) {
71
- element.style.left = getComputedStyle(resizer).transform === 'none' ? "".concat(resizer.offsetLeft - _consts.DRAG_HANDLE_NODE_GAP - _consts.DRAG_HANDLE_WIDTH, "px") : "".concat(resizer.offsetLeft - resizer.offsetWidth / 2 - _consts.DRAG_HANDLE_NODE_GAP - _consts.DRAG_HANDLE_WIDTH, "px");
73
+ element.style.left = getComputedStyle(resizer).transform === 'none' ? "".concat(resizer.offsetLeft - (0, _consts.dragHandleGap)(meta.type) - _consts.DRAG_HANDLE_WIDTH, "px") : "".concat(resizer.offsetLeft - resizer.offsetWidth / 2 - (0, _consts.dragHandleGap)(meta.type) - _consts.DRAG_HANDLE_WIDTH, "px");
72
74
  } else {
73
- element.style.left = "".concat(meta.dom.offsetLeft - _consts.DRAG_HANDLE_NODE_GAP - _consts.DRAG_HANDLE_WIDTH, "px");
75
+ element.style.left = "".concat(meta.dom.offsetLeft - (0, _consts.dragHandleGap)(meta.type) - _consts.DRAG_HANDLE_WIDTH, "px");
74
76
  }
75
77
  if (meta.type === 'table') {
76
78
  var table = meta.dom.querySelector('table');
@@ -3,8 +3,14 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.DRAG_HANDLE_WIDTH = exports.DRAG_HANDLE_NODE_GAP = exports.DRAG_HANDLE_HEIGHT = exports.DRAG_HANDLE_BORDER_RADIUS = void 0;
6
+ exports.dragHandleGap = exports.DRAG_HANDLE_WIDTH = exports.DRAG_HANDLE_HEIGHT = exports.DRAG_HANDLE_BORDER_RADIUS = void 0;
7
7
  var DRAG_HANDLE_HEIGHT = exports.DRAG_HANDLE_HEIGHT = 24;
8
8
  var DRAG_HANDLE_WIDTH = exports.DRAG_HANDLE_WIDTH = 12;
9
9
  var DRAG_HANDLE_BORDER_RADIUS = exports.DRAG_HANDLE_BORDER_RADIUS = 4;
10
- var DRAG_HANDLE_NODE_GAP = exports.DRAG_HANDLE_NODE_GAP = 12;
10
+ var nodeTypeExcludeList = ['embedCard', 'mediaSingle', 'table'];
11
+ var dragHandleGap = exports.dragHandleGap = function dragHandleGap(nodeType) {
12
+ if (nodeTypeExcludeList.includes(nodeType)) {
13
+ return 12;
14
+ }
15
+ return 8;
16
+ };
@@ -8,15 +8,26 @@ exports.DropTarget = void 0;
8
8
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
9
  var _react = require("react");
10
10
  var _react2 = require("@emotion/react");
11
+ var _hooks = require("@atlaskit/editor-common/hooks");
11
12
  var _element = require("@atlaskit/pragmatic-drag-and-drop-auto-scroll/element");
12
13
  var _box = require("@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box");
13
14
  var _combine = require("@atlaskit/pragmatic-drag-and-drop/combine");
14
15
  var _adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
15
16
  /** @jsx jsx */
16
17
 
18
+ var DEFAULT_DROP_INDICATOR_WIDTH = 760;
17
19
  var styleDropTarget = (0, _react2.css)({
18
20
  height: "var(--ds-space-100, 8px)",
19
21
  marginTop: "var(--ds-space-negative-100, -8px)",
22
+ position: 'absolute',
23
+ width: '100%',
24
+ left: '0',
25
+ display: 'block'
26
+ });
27
+ var styleDropIndicator = (0, _react2.css)({
28
+ height: '100%',
29
+ width: '100%',
30
+ margin: '0 auto',
20
31
  position: 'relative'
21
32
  });
22
33
  var DropTarget = exports.DropTarget = function DropTarget(_ref) {
@@ -27,6 +38,9 @@ var DropTarget = exports.DropTarget = function DropTarget(_ref) {
27
38
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
28
39
  isDraggedOver = _useState2[0],
29
40
  setIsDraggedOver = _useState2[1];
41
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['width']),
42
+ widthState = _useSharedPluginState.widthState;
43
+ var lineLength = (widthState === null || widthState === void 0 ? void 0 : widthState.lineLength) || DEFAULT_DROP_INDICATOR_WIDTH;
30
44
  (0, _react.useEffect)(function () {
31
45
  var element = ref.current;
32
46
  if (!element) {
@@ -83,9 +97,15 @@ var DropTarget = exports.DropTarget = function DropTarget(_ref) {
83
97
  "data-testid": "block-ctrl-drop-target"
84
98
  },
85
99
  //4px gap to clear expand node border
86
- isDraggedOver && (0, _react2.jsx)(_box.DropIndicator, {
100
+ isDraggedOver && (0, _react2.jsx)("div", {
101
+ css: styleDropIndicator,
102
+ style: {
103
+ 'width': "".concat(lineLength, "px")
104
+ },
105
+ "data-testid": "block-ctrl-drop-indicator"
106
+ }, (0, _react2.jsx)(_box.DropIndicator, {
87
107
  edge: "bottom",
88
108
  gap: "4px"
89
- }))
109
+ })))
90
110
  );
91
111
  };
@@ -31,14 +31,15 @@ export const blockControlsPlugin = ({
31
31
  }
32
32
  },
33
33
  getSharedState(editorState) {
34
- var _key$getState$isMenuO, _key$getState, _key$getState$activeN, _key$getState2, _key$getState$decorat, _key$getState3;
34
+ var _key$getState$isMenuO, _key$getState, _key$getState$activeN, _key$getState2, _key$getState$decorat, _key$getState3, _key$getState$isDragg, _key$getState4;
35
35
  if (!editorState) {
36
36
  return undefined;
37
37
  }
38
38
  return {
39
39
  isMenuOpen: (_key$getState$isMenuO = (_key$getState = key.getState(editorState)) === null || _key$getState === void 0 ? void 0 : _key$getState.isMenuOpen) !== null && _key$getState$isMenuO !== void 0 ? _key$getState$isMenuO : false,
40
40
  activeNode: (_key$getState$activeN = (_key$getState2 = key.getState(editorState)) === null || _key$getState2 === void 0 ? void 0 : _key$getState2.activeNode) !== null && _key$getState$activeN !== void 0 ? _key$getState$activeN : null,
41
- decorationState: (_key$getState$decorat = (_key$getState3 = key.getState(editorState)) === null || _key$getState3 === void 0 ? void 0 : _key$getState3.decorationState) !== null && _key$getState$decorat !== void 0 ? _key$getState$decorat : []
41
+ decorationState: (_key$getState$decorat = (_key$getState3 = key.getState(editorState)) === null || _key$getState3 === void 0 ? void 0 : _key$getState3.decorationState) !== null && _key$getState$decorat !== void 0 ? _key$getState$decorat : [],
42
+ isDragging: (_key$getState$isDragg = (_key$getState4 = key.getState(editorState)) === null || _key$getState4 === void 0 ? void 0 : _key$getState4.isDragging) !== null && _key$getState$isDragg !== void 0 ? _key$getState$isDragg : false
42
43
  };
43
44
  },
44
45
  contentComponent() {
@@ -1,7 +1,7 @@
1
1
  import { createElement } from 'react';
2
2
  import ReactDOM from 'react-dom';
3
3
  import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
4
- import { DRAG_HANDLE_NODE_GAP, DRAG_HANDLE_WIDTH } from '../ui/consts';
4
+ import { DRAG_HANDLE_WIDTH, dragHandleGap } from '../ui/consts';
5
5
  import { DragHandle } from '../ui/drag-handle';
6
6
  import { DropTarget } from '../ui/drop-target';
7
7
  export const dropTargetDecorations = (oldState, newState, api) => {
@@ -59,11 +59,13 @@ export const dragHandleDecoration = (oldState, meta, api) => {
59
59
  }), element);
60
60
  element.style.position = 'absolute';
61
61
  element.style.zIndex = '1';
62
- const resizer = meta.dom.querySelector('.resizer-item');
62
+
63
+ // If the selected node is a table or mediaSingle with resizer, we need to adjust the position of the drag handle
64
+ const resizer = ['table', 'mediaSingle'].includes(meta.type) ? meta.dom.querySelector('.resizer-item') : null;
63
65
  if (resizer) {
64
- element.style.left = getComputedStyle(resizer).transform === 'none' ? `${resizer.offsetLeft - DRAG_HANDLE_NODE_GAP - DRAG_HANDLE_WIDTH}px` : `${resizer.offsetLeft - resizer.offsetWidth / 2 - DRAG_HANDLE_NODE_GAP - DRAG_HANDLE_WIDTH}px`;
66
+ element.style.left = getComputedStyle(resizer).transform === 'none' ? `${resizer.offsetLeft - dragHandleGap(meta.type) - DRAG_HANDLE_WIDTH}px` : `${resizer.offsetLeft - resizer.offsetWidth / 2 - dragHandleGap(meta.type) - DRAG_HANDLE_WIDTH}px`;
65
67
  } else {
66
- element.style.left = `${meta.dom.offsetLeft - DRAG_HANDLE_NODE_GAP - DRAG_HANDLE_WIDTH}px`;
68
+ element.style.left = `${meta.dom.offsetLeft - dragHandleGap(meta.type) - DRAG_HANDLE_WIDTH}px`;
67
69
  }
68
70
  if (meta.type === 'table') {
69
71
  const table = meta.dom.querySelector('table');
@@ -1,4 +1,10 @@
1
1
  export const DRAG_HANDLE_HEIGHT = 24;
2
2
  export const DRAG_HANDLE_WIDTH = 12;
3
3
  export const DRAG_HANDLE_BORDER_RADIUS = 4;
4
- export const DRAG_HANDLE_NODE_GAP = 12;
4
+ const nodeTypeExcludeList = ['embedCard', 'mediaSingle', 'table'];
5
+ export const dragHandleGap = nodeType => {
6
+ if (nodeTypeExcludeList.includes(nodeType)) {
7
+ return 12;
8
+ }
9
+ return 8;
10
+ };
@@ -1,13 +1,24 @@
1
1
  /** @jsx jsx */
2
2
  import { useEffect, useRef, useState } from 'react';
3
3
  import { css, jsx } from '@emotion/react';
4
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
4
5
  import { autoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-scroll/element';
5
6
  import { DropIndicator } from '@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box';
6
7
  import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
7
8
  import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
9
+ const DEFAULT_DROP_INDICATOR_WIDTH = 760;
8
10
  const styleDropTarget = css({
9
11
  height: "var(--ds-space-100, 8px)",
10
12
  marginTop: "var(--ds-space-negative-100, -8px)",
13
+ position: 'absolute',
14
+ width: '100%',
15
+ left: '0',
16
+ display: 'block'
17
+ });
18
+ const styleDropIndicator = css({
19
+ height: '100%',
20
+ width: '100%',
21
+ margin: '0 auto',
11
22
  position: 'relative'
12
23
  });
13
24
  export const DropTarget = ({
@@ -16,6 +27,10 @@ export const DropTarget = ({
16
27
  }) => {
17
28
  const ref = useRef(null);
18
29
  const [isDraggedOver, setIsDraggedOver] = useState(false);
30
+ const {
31
+ widthState
32
+ } = useSharedPluginState(api, ['width']);
33
+ const lineLength = (widthState === null || widthState === void 0 ? void 0 : widthState.lineLength) || DEFAULT_DROP_INDICATOR_WIDTH;
19
34
  useEffect(() => {
20
35
  const element = ref.current;
21
36
  if (!element) {
@@ -68,9 +83,15 @@ export const DropTarget = ({
68
83
  "data-testid": "block-ctrl-drop-target"
69
84
  },
70
85
  //4px gap to clear expand node border
71
- isDraggedOver && jsx(DropIndicator, {
86
+ isDraggedOver && jsx("div", {
87
+ css: styleDropIndicator,
88
+ style: {
89
+ 'width': `${lineLength}px`
90
+ },
91
+ "data-testid": "block-ctrl-drop-indicator"
92
+ }, jsx(DropIndicator, {
72
93
  edge: "bottom",
73
94
  gap: "4px"
74
- }))
95
+ })))
75
96
  );
76
97
  };
@@ -34,14 +34,15 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
34
34
  }
35
35
  },
36
36
  getSharedState: function getSharedState(editorState) {
37
- var _key$getState$isMenuO, _key$getState, _key$getState$activeN, _key$getState2, _key$getState$decorat, _key$getState3;
37
+ var _key$getState$isMenuO, _key$getState, _key$getState$activeN, _key$getState2, _key$getState$decorat, _key$getState3, _key$getState$isDragg, _key$getState4;
38
38
  if (!editorState) {
39
39
  return undefined;
40
40
  }
41
41
  return {
42
42
  isMenuOpen: (_key$getState$isMenuO = (_key$getState = key.getState(editorState)) === null || _key$getState === void 0 ? void 0 : _key$getState.isMenuOpen) !== null && _key$getState$isMenuO !== void 0 ? _key$getState$isMenuO : false,
43
43
  activeNode: (_key$getState$activeN = (_key$getState2 = key.getState(editorState)) === null || _key$getState2 === void 0 ? void 0 : _key$getState2.activeNode) !== null && _key$getState$activeN !== void 0 ? _key$getState$activeN : null,
44
- decorationState: (_key$getState$decorat = (_key$getState3 = key.getState(editorState)) === null || _key$getState3 === void 0 ? void 0 : _key$getState3.decorationState) !== null && _key$getState$decorat !== void 0 ? _key$getState$decorat : []
44
+ decorationState: (_key$getState$decorat = (_key$getState3 = key.getState(editorState)) === null || _key$getState3 === void 0 ? void 0 : _key$getState3.decorationState) !== null && _key$getState$decorat !== void 0 ? _key$getState$decorat : [],
45
+ isDragging: (_key$getState$isDragg = (_key$getState4 = key.getState(editorState)) === null || _key$getState4 === void 0 ? void 0 : _key$getState4.isDragging) !== null && _key$getState$isDragg !== void 0 ? _key$getState$isDragg : false
45
46
  };
46
47
  },
47
48
  contentComponent: function contentComponent() {
@@ -1,7 +1,7 @@
1
1
  import { createElement } from 'react';
2
2
  import ReactDOM from 'react-dom';
3
3
  import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
4
- import { DRAG_HANDLE_NODE_GAP, DRAG_HANDLE_WIDTH } from '../ui/consts';
4
+ import { DRAG_HANDLE_WIDTH, dragHandleGap } from '../ui/consts';
5
5
  import { DragHandle } from '../ui/drag-handle';
6
6
  import { DropTarget } from '../ui/drop-target';
7
7
  export var dropTargetDecorations = function dropTargetDecorations(oldState, newState, api) {
@@ -59,11 +59,13 @@ export var dragHandleDecoration = function dragHandleDecoration(oldState, meta,
59
59
  }), element);
60
60
  element.style.position = 'absolute';
61
61
  element.style.zIndex = '1';
62
- var resizer = meta.dom.querySelector('.resizer-item');
62
+
63
+ // If the selected node is a table or mediaSingle with resizer, we need to adjust the position of the drag handle
64
+ var resizer = ['table', 'mediaSingle'].includes(meta.type) ? meta.dom.querySelector('.resizer-item') : null;
63
65
  if (resizer) {
64
- element.style.left = getComputedStyle(resizer).transform === 'none' ? "".concat(resizer.offsetLeft - DRAG_HANDLE_NODE_GAP - DRAG_HANDLE_WIDTH, "px") : "".concat(resizer.offsetLeft - resizer.offsetWidth / 2 - DRAG_HANDLE_NODE_GAP - DRAG_HANDLE_WIDTH, "px");
66
+ element.style.left = getComputedStyle(resizer).transform === 'none' ? "".concat(resizer.offsetLeft - dragHandleGap(meta.type) - DRAG_HANDLE_WIDTH, "px") : "".concat(resizer.offsetLeft - resizer.offsetWidth / 2 - dragHandleGap(meta.type) - DRAG_HANDLE_WIDTH, "px");
65
67
  } else {
66
- element.style.left = "".concat(meta.dom.offsetLeft - DRAG_HANDLE_NODE_GAP - DRAG_HANDLE_WIDTH, "px");
68
+ element.style.left = "".concat(meta.dom.offsetLeft - dragHandleGap(meta.type) - DRAG_HANDLE_WIDTH, "px");
67
69
  }
68
70
  if (meta.type === 'table') {
69
71
  var table = meta.dom.querySelector('table');
@@ -1,4 +1,10 @@
1
1
  export var DRAG_HANDLE_HEIGHT = 24;
2
2
  export var DRAG_HANDLE_WIDTH = 12;
3
3
  export var DRAG_HANDLE_BORDER_RADIUS = 4;
4
- export var DRAG_HANDLE_NODE_GAP = 12;
4
+ var nodeTypeExcludeList = ['embedCard', 'mediaSingle', 'table'];
5
+ export var dragHandleGap = function dragHandleGap(nodeType) {
6
+ if (nodeTypeExcludeList.includes(nodeType)) {
7
+ return 12;
8
+ }
9
+ return 8;
10
+ };
@@ -2,13 +2,24 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  /** @jsx jsx */
3
3
  import { useEffect, useRef, useState } from 'react';
4
4
  import { css, jsx } from '@emotion/react';
5
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
5
6
  import { autoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-scroll/element';
6
7
  import { DropIndicator } from '@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box';
7
8
  import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
8
9
  import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
10
+ var DEFAULT_DROP_INDICATOR_WIDTH = 760;
9
11
  var styleDropTarget = css({
10
12
  height: "var(--ds-space-100, 8px)",
11
13
  marginTop: "var(--ds-space-negative-100, -8px)",
14
+ position: 'absolute',
15
+ width: '100%',
16
+ left: '0',
17
+ display: 'block'
18
+ });
19
+ var styleDropIndicator = css({
20
+ height: '100%',
21
+ width: '100%',
22
+ margin: '0 auto',
12
23
  position: 'relative'
13
24
  });
14
25
  export var DropTarget = function DropTarget(_ref) {
@@ -19,6 +30,9 @@ export var DropTarget = function DropTarget(_ref) {
19
30
  _useState2 = _slicedToArray(_useState, 2),
20
31
  isDraggedOver = _useState2[0],
21
32
  setIsDraggedOver = _useState2[1];
33
+ var _useSharedPluginState = useSharedPluginState(api, ['width']),
34
+ widthState = _useSharedPluginState.widthState;
35
+ var lineLength = (widthState === null || widthState === void 0 ? void 0 : widthState.lineLength) || DEFAULT_DROP_INDICATOR_WIDTH;
22
36
  useEffect(function () {
23
37
  var element = ref.current;
24
38
  if (!element) {
@@ -75,9 +89,15 @@ export var DropTarget = function DropTarget(_ref) {
75
89
  "data-testid": "block-ctrl-drop-target"
76
90
  },
77
91
  //4px gap to clear expand node border
78
- isDraggedOver && jsx(DropIndicator, {
92
+ isDraggedOver && jsx("div", {
93
+ css: styleDropIndicator,
94
+ style: {
95
+ 'width': "".concat(lineLength, "px")
96
+ },
97
+ "data-testid": "block-ctrl-drop-indicator"
98
+ }, jsx(DropIndicator, {
79
99
  edge: "bottom",
80
100
  gap: "4px"
81
- }))
101
+ })))
82
102
  );
83
103
  };
@@ -1,2 +1,2 @@
1
1
  export { blockControlsPlugin } from './plugin';
2
- export type { BlockControlsPlugin } from './types';
2
+ export type { BlockControlsPlugin, DecorationState } from './types';
@@ -1,2 +1,2 @@
1
- import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
2
- export declare const blockControlsPlugin: NextEditorPlugin<'blockControls'>;
1
+ import type { BlockControlsPlugin } from './types';
2
+ export declare const blockControlsPlugin: BlockControlsPlugin;
@@ -1,4 +1,5 @@
1
- import type { EditorCommand, NextEditorPlugin } from '@atlaskit/editor-common/types';
1
+ import type { EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
+ import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
2
3
  import { type DecorationSet } from '@atlaskit/editor-prosemirror/view';
3
4
  export interface PluginState {
4
5
  decorations: DecorationSet;
@@ -11,15 +12,15 @@ export interface PluginState {
11
12
  }
12
13
  export type ReleaseHiddenDecoration = () => boolean | undefined;
13
14
  export type BlockControlsPlugin = NextEditorPlugin<'blockControls', {
14
- dependencies: [];
15
+ dependencies: [OptionalPlugin<WidthPlugin>];
15
16
  sharedState: {
16
17
  isMenuOpen: boolean;
17
18
  activeNode: {
18
19
  pos: number;
19
- };
20
+ } | null;
20
21
  decorationState: DecorationState;
22
+ isDragging: boolean;
21
23
  } | undefined;
22
- actions: {};
23
24
  commands: {
24
25
  moveNode: (start: number, to: number) => EditorCommand;
25
26
  };
@@ -1,4 +1,4 @@
1
1
  export declare const DRAG_HANDLE_HEIGHT = 24;
2
2
  export declare const DRAG_HANDLE_WIDTH = 12;
3
3
  export declare const DRAG_HANDLE_BORDER_RADIUS = 4;
4
- export declare const DRAG_HANDLE_NODE_GAP = 12;
4
+ export declare const dragHandleGap: (nodeType: string) => 12 | 8;
@@ -1,2 +1,2 @@
1
1
  export { blockControlsPlugin } from './plugin';
2
- export type { BlockControlsPlugin } from './types';
2
+ export type { BlockControlsPlugin, DecorationState } from './types';
@@ -1,2 +1,2 @@
1
- import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
2
- export declare const blockControlsPlugin: NextEditorPlugin<'blockControls'>;
1
+ import type { BlockControlsPlugin } from './types';
2
+ export declare const blockControlsPlugin: BlockControlsPlugin;
@@ -1,4 +1,5 @@
1
- import type { EditorCommand, NextEditorPlugin } from '@atlaskit/editor-common/types';
1
+ import type { EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
+ import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
2
3
  import { type DecorationSet } from '@atlaskit/editor-prosemirror/view';
3
4
  export interface PluginState {
4
5
  decorations: DecorationSet;
@@ -12,15 +13,16 @@ export interface PluginState {
12
13
  export type ReleaseHiddenDecoration = () => boolean | undefined;
13
14
  export type BlockControlsPlugin = NextEditorPlugin<'blockControls', {
14
15
  dependencies: [
16
+ OptionalPlugin<WidthPlugin>
15
17
  ];
16
18
  sharedState: {
17
19
  isMenuOpen: boolean;
18
20
  activeNode: {
19
21
  pos: number;
20
- };
22
+ } | null;
21
23
  decorationState: DecorationState;
24
+ isDragging: boolean;
22
25
  } | undefined;
23
- actions: {};
24
26
  commands: {
25
27
  moveNode: (start: number, to: number) => EditorCommand;
26
28
  };
@@ -1,4 +1,4 @@
1
1
  export declare const DRAG_HANDLE_HEIGHT = 24;
2
2
  export declare const DRAG_HANDLE_WIDTH = 12;
3
3
  export declare const DRAG_HANDLE_BORDER_RADIUS = 4;
4
- export declare const DRAG_HANDLE_NODE_GAP = 12;
4
+ export declare const dragHandleGap: (nodeType: string) => 12 | 8;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "1.4.7",
3
+ "version": "1.4.9",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -31,7 +31,8 @@
31
31
  ".": "./src/index.ts"
32
32
  },
33
33
  "dependencies": {
34
- "@atlaskit/editor-common": "^81.1.0",
34
+ "@atlaskit/editor-common": "^82.0.0",
35
+ "@atlaskit/editor-plugin-width": "^1.1.0",
35
36
  "@atlaskit/editor-prosemirror": "4.0.1",
36
37
  "@atlaskit/icon": "^22.3.0",
37
38
  "@atlaskit/pragmatic-drag-and-drop": "^1.1.0",