@atlaskit/editor-plugin-block-controls 1.3.11 → 1.4.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,21 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 1.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#101384](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/101384)
8
+ [`649f601103e0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/649f601103e0) -
9
+ [ux] Add autoscroller support to blocks plugin
10
+
11
+ ## 1.3.12
12
+
13
+ ### Patch Changes
14
+
15
+ - [#101305](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/101305)
16
+ [`8df2f2cd6748`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8df2f2cd6748) -
17
+ Refactor drop target to use Pragmatic DnD indicator package
18
+
3
19
  ## 1.3.11
4
20
 
5
21
  ### Patch Changes
@@ -3,10 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.DROP_TARGET_LINE_WIDTH = exports.DROP_TARGET_CIRCLE_DIAMETER = exports.DRAG_HANDLE_WIDTH = exports.DRAG_HANDLE_NODE_GAP = exports.DRAG_HANDLE_HEIGHT = exports.DRAG_HANDLE_BORDER_RADIUS = void 0;
6
+ exports.DRAG_HANDLE_WIDTH = exports.DRAG_HANDLE_NODE_GAP = 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;
11
- var DROP_TARGET_LINE_WIDTH = exports.DROP_TARGET_LINE_WIDTH = 2;
12
- var DROP_TARGET_CIRCLE_DIAMETER = exports.DROP_TARGET_CIRCLE_DIAMETER = 8;
10
+ var DRAG_HANDLE_NODE_GAP = exports.DRAG_HANDLE_NODE_GAP = 12;
@@ -8,41 +8,16 @@ 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 _element = require("@atlaskit/pragmatic-drag-and-drop-auto-scroll/element");
12
+ var _box = require("@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box");
13
+ var _combine = require("@atlaskit/pragmatic-drag-and-drop/combine");
11
14
  var _adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
12
- var _colors = require("@atlaskit/theme/colors");
13
- var _consts = require("./consts");
14
15
  /** @jsx jsx */
15
16
 
16
- var styleHighlighted = (0, _react2.css)({
17
+ var styleDropTarget = (0, _react2.css)({
17
18
  height: "var(--ds-space-100, 8px)",
18
- marginTop: "calc(".concat("var(--ds-space-negative-100, -8px)", " - ", _consts.DROP_TARGET_LINE_WIDTH, "px)"),
19
- marginLeft: "var(--ds-space-negative-100, -8px)",
20
- top: "calc(".concat("var(--ds-space-100, 8px)", " / 2 - 1px)"),
21
- //1px to help clear expand node margin
22
- position: 'relative',
23
- borderBottom: "solid ".concat("var(--ds-border-selected, ".concat(_colors.B300, ")"), " ", _consts.DROP_TARGET_LINE_WIDTH, "px"),
24
- "&:before": {
25
- content: '""',
26
- width: "".concat(_consts.DROP_TARGET_CIRCLE_DIAMETER, "px"),
27
- height: "".concat(_consts.DROP_TARGET_CIRCLE_DIAMETER, "px"),
28
- marginTop: "".concat(_consts.DROP_TARGET_CIRCLE_DIAMETER, "px"),
29
- borderRadius: '50%',
30
- border: "solid ".concat("var(--ds-border-selected, ".concat(_colors.B300, ")"), " ", _consts.DROP_TARGET_LINE_WIDTH, "px"),
31
- backgroundColor: "var(--ds-background-input, white)",
32
- display: 'block',
33
- position: 'absolute',
34
- bottom: "".concat(-(_consts.DROP_TARGET_CIRCLE_DIAMETER + _consts.DROP_TARGET_LINE_WIDTH) / 2, "px"),
35
- boxSizing: 'border-box'
36
- }
37
- });
38
- var styleDisabled = (0, _react2.css)({
39
- height: "var(--ds-space-100, 8px)",
40
- marginTop: "calc(".concat("var(--ds-space-negative-100, -8px)", " - ", _consts.DROP_TARGET_LINE_WIDTH, "px)"),
41
- position: 'relative',
42
- borderBottom: "solid transparent ".concat(_consts.DROP_TARGET_LINE_WIDTH, "px"),
43
- "&:before": {
44
- border: "solid transparent ".concat(_consts.DROP_TARGET_LINE_WIDTH, "px")
45
- }
19
+ marginTop: "calc(".concat("var(--ds-space-negative-100, -8px)", ")"),
20
+ position: 'relative'
46
21
  });
47
22
  var DropTarget = exports.DropTarget = function DropTarget(_ref) {
48
23
  var api = _ref.api,
@@ -57,11 +32,24 @@ var DropTarget = exports.DropTarget = function DropTarget(_ref) {
57
32
  if (!element) {
58
33
  return;
59
34
  }
60
- return (0, _adapter.dropTargetForElements)({
35
+ var combined = [];
36
+ var scrollable = document.querySelector('.fabric-editor-popup-scroll-parent');
37
+ if (scrollable) {
38
+ combined.push((0, _element.autoScrollForElements)({
39
+ element: scrollable,
40
+ canScroll: function canScroll() {
41
+ return true;
42
+ }
43
+ }));
44
+ }
45
+ combined.push((0, _adapter.dropTargetForElements)({
61
46
  element: element,
62
47
  getIsSticky: function getIsSticky() {
63
48
  return true;
64
49
  },
50
+ onDrag: function onDrag() {
51
+ scrollable.style.setProperty('scroll-behavior', 'unset');
52
+ },
65
53
  onDragEnter: function onDragEnter() {
66
54
  return setIsDraggedOver(true);
67
55
  },
@@ -70,6 +58,7 @@ var DropTarget = exports.DropTarget = function DropTarget(_ref) {
70
58
  },
71
59
  onDrop: function onDrop() {
72
60
  var _api$blockControls;
61
+ scrollable.style.setProperty('scroll-behavior', null);
73
62
  var _ref2 = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
74
63
  activeNode = _ref2.activeNode,
75
64
  decorationState = _ref2.decorationState;
@@ -86,13 +75,19 @@ var DropTarget = exports.DropTarget = function DropTarget(_ref) {
86
75
  api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || (_api$blockControls2 = _api$blockControls2.commands) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.moveNode(start, pos));
87
76
  }
88
77
  }
89
- });
78
+ }));
79
+ return _combine.combine.apply(void 0, combined);
90
80
  }, [index, api]);
91
81
  return (
92
82
  // Note: Firefox has trouble with using a button element as the handle for drag and drop
93
83
  (0, _react2.jsx)("div", {
94
- css: isDraggedOver ? styleHighlighted : styleDisabled,
84
+ css: styleDropTarget,
95
85
  ref: ref
96
- })
86
+ },
87
+ //4px gap to clear expand node border
88
+ isDraggedOver && (0, _react2.jsx)(_box.DropIndicator, {
89
+ edge: "bottom",
90
+ gap: "4px"
91
+ }))
97
92
  );
98
93
  };
@@ -1,6 +1,4 @@
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;
5
- export const DROP_TARGET_LINE_WIDTH = 2;
6
- export const DROP_TARGET_CIRCLE_DIAMETER = 8;
4
+ export const DRAG_HANDLE_NODE_GAP = 12;
@@ -1,39 +1,14 @@
1
1
  /** @jsx jsx */
2
2
  import { useEffect, useRef, useState } from 'react';
3
3
  import { css, jsx } from '@emotion/react';
4
+ import { autoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-scroll/element';
5
+ import { DropIndicator } from '@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box';
6
+ import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
4
7
  import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
5
- import { B300 } from '@atlaskit/theme/colors';
6
- import { DROP_TARGET_CIRCLE_DIAMETER, DROP_TARGET_LINE_WIDTH } from './consts';
7
- const styleHighlighted = css({
8
+ const styleDropTarget = css({
8
9
  height: "var(--ds-space-100, 8px)",
9
- marginTop: `calc(${"var(--ds-space-negative-100, -8px)"} - ${DROP_TARGET_LINE_WIDTH}px)`,
10
- marginLeft: "var(--ds-space-negative-100, -8px)",
11
- top: `calc(${"var(--ds-space-100, 8px)"} / 2 - 1px)`,
12
- //1px to help clear expand node margin
13
- position: 'relative',
14
- borderBottom: `solid ${`var(--ds-border-selected, ${B300})`} ${DROP_TARGET_LINE_WIDTH}px`,
15
- "&:before": {
16
- content: '""',
17
- width: `${DROP_TARGET_CIRCLE_DIAMETER}px`,
18
- height: `${DROP_TARGET_CIRCLE_DIAMETER}px`,
19
- marginTop: `${DROP_TARGET_CIRCLE_DIAMETER}px`,
20
- borderRadius: '50%',
21
- border: `solid ${`var(--ds-border-selected, ${B300})`} ${DROP_TARGET_LINE_WIDTH}px`,
22
- backgroundColor: "var(--ds-background-input, white)",
23
- display: 'block',
24
- position: 'absolute',
25
- bottom: `${-(DROP_TARGET_CIRCLE_DIAMETER + DROP_TARGET_LINE_WIDTH) / 2}px`,
26
- boxSizing: 'border-box'
27
- }
28
- });
29
- const styleDisabled = css({
30
- height: "var(--ds-space-100, 8px)",
31
- marginTop: `calc(${"var(--ds-space-negative-100, -8px)"} - ${DROP_TARGET_LINE_WIDTH}px)`,
32
- position: 'relative',
33
- borderBottom: `solid transparent ${DROP_TARGET_LINE_WIDTH}px`,
34
- "&:before": {
35
- border: `solid transparent ${DROP_TARGET_LINE_WIDTH}px`
36
- }
10
+ marginTop: `calc(${"var(--ds-space-negative-100, -8px)"})`,
11
+ position: 'relative'
37
12
  });
38
13
  export const DropTarget = ({
39
14
  api,
@@ -46,13 +21,27 @@ export const DropTarget = ({
46
21
  if (!element) {
47
22
  return;
48
23
  }
49
- return dropTargetForElements({
24
+ const combined = [];
25
+ const scrollable = document.querySelector('.fabric-editor-popup-scroll-parent');
26
+ if (scrollable) {
27
+ combined.push(autoScrollForElements({
28
+ element: scrollable,
29
+ canScroll: () => {
30
+ return true;
31
+ }
32
+ }));
33
+ }
34
+ combined.push(dropTargetForElements({
50
35
  element,
51
36
  getIsSticky: () => true,
37
+ onDrag: () => {
38
+ scrollable.style.setProperty('scroll-behavior', 'unset');
39
+ },
52
40
  onDragEnter: () => setIsDraggedOver(true),
53
41
  onDragLeave: () => setIsDraggedOver(false),
54
42
  onDrop: () => {
55
43
  var _api$blockControls;
44
+ scrollable.style.setProperty('scroll-behavior', null);
56
45
  const {
57
46
  activeNode,
58
47
  decorationState
@@ -71,13 +60,19 @@ export const DropTarget = ({
71
60
  api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(api === null || api === void 0 ? void 0 : (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : (_api$blockControls2$c = _api$blockControls2.commands) === null || _api$blockControls2$c === void 0 ? void 0 : _api$blockControls2$c.moveNode(start, pos));
72
61
  }
73
62
  }
74
- });
63
+ }));
64
+ return combine(...combined);
75
65
  }, [index, api]);
76
66
  return (
77
67
  // Note: Firefox has trouble with using a button element as the handle for drag and drop
78
68
  jsx("div", {
79
- css: isDraggedOver ? styleHighlighted : styleDisabled,
69
+ css: styleDropTarget,
80
70
  ref: ref
81
- })
71
+ },
72
+ //4px gap to clear expand node border
73
+ isDraggedOver && jsx(DropIndicator, {
74
+ edge: "bottom",
75
+ gap: "4px"
76
+ }))
82
77
  );
83
78
  };
@@ -1,6 +1,4 @@
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;
5
- export var DROP_TARGET_LINE_WIDTH = 2;
6
- export var DROP_TARGET_CIRCLE_DIAMETER = 8;
4
+ export var DRAG_HANDLE_NODE_GAP = 12;
@@ -2,39 +2,14 @@ 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 { autoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-scroll/element';
6
+ import { DropIndicator } from '@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box';
7
+ import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
5
8
  import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
6
- import { B300 } from '@atlaskit/theme/colors';
7
- import { DROP_TARGET_CIRCLE_DIAMETER, DROP_TARGET_LINE_WIDTH } from './consts';
8
- var styleHighlighted = css({
9
+ var styleDropTarget = css({
9
10
  height: "var(--ds-space-100, 8px)",
10
- marginTop: "calc(".concat("var(--ds-space-negative-100, -8px)", " - ", DROP_TARGET_LINE_WIDTH, "px)"),
11
- marginLeft: "var(--ds-space-negative-100, -8px)",
12
- top: "calc(".concat("var(--ds-space-100, 8px)", " / 2 - 1px)"),
13
- //1px to help clear expand node margin
14
- position: 'relative',
15
- borderBottom: "solid ".concat("var(--ds-border-selected, ".concat(B300, ")"), " ", DROP_TARGET_LINE_WIDTH, "px"),
16
- "&:before": {
17
- content: '""',
18
- width: "".concat(DROP_TARGET_CIRCLE_DIAMETER, "px"),
19
- height: "".concat(DROP_TARGET_CIRCLE_DIAMETER, "px"),
20
- marginTop: "".concat(DROP_TARGET_CIRCLE_DIAMETER, "px"),
21
- borderRadius: '50%',
22
- border: "solid ".concat("var(--ds-border-selected, ".concat(B300, ")"), " ", DROP_TARGET_LINE_WIDTH, "px"),
23
- backgroundColor: "var(--ds-background-input, white)",
24
- display: 'block',
25
- position: 'absolute',
26
- bottom: "".concat(-(DROP_TARGET_CIRCLE_DIAMETER + DROP_TARGET_LINE_WIDTH) / 2, "px"),
27
- boxSizing: 'border-box'
28
- }
29
- });
30
- var styleDisabled = css({
31
- height: "var(--ds-space-100, 8px)",
32
- marginTop: "calc(".concat("var(--ds-space-negative-100, -8px)", " - ", DROP_TARGET_LINE_WIDTH, "px)"),
33
- position: 'relative',
34
- borderBottom: "solid transparent ".concat(DROP_TARGET_LINE_WIDTH, "px"),
35
- "&:before": {
36
- border: "solid transparent ".concat(DROP_TARGET_LINE_WIDTH, "px")
37
- }
11
+ marginTop: "calc(".concat("var(--ds-space-negative-100, -8px)", ")"),
12
+ position: 'relative'
38
13
  });
39
14
  export var DropTarget = function DropTarget(_ref) {
40
15
  var api = _ref.api,
@@ -49,11 +24,24 @@ export var DropTarget = function DropTarget(_ref) {
49
24
  if (!element) {
50
25
  return;
51
26
  }
52
- return dropTargetForElements({
27
+ var combined = [];
28
+ var scrollable = document.querySelector('.fabric-editor-popup-scroll-parent');
29
+ if (scrollable) {
30
+ combined.push(autoScrollForElements({
31
+ element: scrollable,
32
+ canScroll: function canScroll() {
33
+ return true;
34
+ }
35
+ }));
36
+ }
37
+ combined.push(dropTargetForElements({
53
38
  element: element,
54
39
  getIsSticky: function getIsSticky() {
55
40
  return true;
56
41
  },
42
+ onDrag: function onDrag() {
43
+ scrollable.style.setProperty('scroll-behavior', 'unset');
44
+ },
57
45
  onDragEnter: function onDragEnter() {
58
46
  return setIsDraggedOver(true);
59
47
  },
@@ -62,6 +50,7 @@ export var DropTarget = function DropTarget(_ref) {
62
50
  },
63
51
  onDrop: function onDrop() {
64
52
  var _api$blockControls;
53
+ scrollable.style.setProperty('scroll-behavior', null);
65
54
  var _ref2 = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
66
55
  activeNode = _ref2.activeNode,
67
56
  decorationState = _ref2.decorationState;
@@ -78,13 +67,19 @@ export var DropTarget = function DropTarget(_ref) {
78
67
  api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || (_api$blockControls2 = _api$blockControls2.commands) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.moveNode(start, pos));
79
68
  }
80
69
  }
81
- });
70
+ }));
71
+ return combine.apply(void 0, combined);
82
72
  }, [index, api]);
83
73
  return (
84
74
  // Note: Firefox has trouble with using a button element as the handle for drag and drop
85
75
  jsx("div", {
86
- css: isDraggedOver ? styleHighlighted : styleDisabled,
76
+ css: styleDropTarget,
87
77
  ref: ref
88
- })
78
+ },
79
+ //4px gap to clear expand node border
80
+ isDraggedOver && jsx(DropIndicator, {
81
+ edge: "bottom",
82
+ gap: "4px"
83
+ }))
89
84
  );
90
85
  };
@@ -2,5 +2,3 @@ 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
4
  export declare const DRAG_HANDLE_NODE_GAP = 12;
5
- export declare const DROP_TARGET_LINE_WIDTH = 2;
6
- export declare const DROP_TARGET_CIRCLE_DIAMETER = 8;
@@ -2,5 +2,3 @@ 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
4
  export declare const DRAG_HANDLE_NODE_GAP = 12;
5
- export declare const DROP_TARGET_LINE_WIDTH = 2;
6
- export declare const DROP_TARGET_CIRCLE_DIAMETER = 8;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "1.3.11",
3
+ "version": "1.4.0",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -35,7 +35,8 @@
35
35
  "@atlaskit/editor-prosemirror": "4.0.1",
36
36
  "@atlaskit/icon": "^22.2.0",
37
37
  "@atlaskit/pragmatic-drag-and-drop": "^1.1.0",
38
- "@atlaskit/theme": "^12.8.0",
38
+ "@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^1.3.0",
39
+ "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^1.1.0",
39
40
  "@atlaskit/tokens": "^1.48.0",
40
41
  "@babel/runtime": "^7.0.0",
41
42
  "@emotion/react": "^11.7.1"