@atlaskit/editor-plugin-block-controls 1.4.8 → 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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
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
+
3
15
  ## 1.4.8
4
16
 
5
17
  ### Patch Changes
@@ -70,9 +70,9 @@ var dragHandleDecoration = exports.dragHandleDecoration = function dragHandleDec
70
70
  // If the selected node is a table or mediaSingle with resizer, we need to adjust the position of the drag handle
71
71
  var resizer = ['table', 'mediaSingle'].includes(meta.type) ? meta.dom.querySelector('.resizer-item') : null;
72
72
  if (resizer) {
73
- 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");
74
74
  } else {
75
- 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");
76
76
  }
77
77
  if (meta.type === 'table') {
78
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
  };
@@ -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) => {
@@ -63,9 +63,9 @@ export const dragHandleDecoration = (oldState, meta, api) => {
63
63
  // If the selected node is a table or mediaSingle with resizer, we need to adjust the position of the drag handle
64
64
  const resizer = ['table', 'mediaSingle'].includes(meta.type) ? meta.dom.querySelector('.resizer-item') : null;
65
65
  if (resizer) {
66
- 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`;
67
67
  } else {
68
- 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`;
69
69
  }
70
70
  if (meta.type === 'table') {
71
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
  };
@@ -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) {
@@ -63,9 +63,9 @@ export var dragHandleDecoration = function dragHandleDecoration(oldState, meta,
63
63
  // If the selected node is a table or mediaSingle with resizer, we need to adjust the position of the drag handle
64
64
  var resizer = ['table', 'mediaSingle'].includes(meta.type) ? meta.dom.querySelector('.resizer-item') : null;
65
65
  if (resizer) {
66
- 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");
67
67
  } else {
68
- 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");
69
69
  }
70
70
  if (meta.type === 'table') {
71
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
- 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,16 +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;
21
22
  isDragging: boolean;
22
23
  } | undefined;
23
- actions: {};
24
24
  commands: {
25
25
  moveNode: (start: number, to: number) => EditorCommand;
26
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
- 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,16 +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;
22
24
  isDragging: boolean;
23
25
  } | undefined;
24
- actions: {};
25
26
  commands: {
26
27
  moveNode: (start: number, to: number) => EditorCommand;
27
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.8",
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",