@atlaskit/editor-plugin-block-controls 1.12.8 → 1.12.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.12.9
4
+
5
+ ### Patch Changes
6
+
7
+ - [#136177](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/136177)
8
+ [`557c5bcfce83c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/557c5bcfce83c) -
9
+ [ux] Adjust margin of drop targets in nested scenarios
10
+ - [#136348](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/136348)
11
+ [`fb4fb56f1da7c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/fb4fb56f1da7c) -
12
+ Use optimised entry-points on editor-common for browser.
13
+ - Updated dependencies
14
+
3
15
  ## 1.12.8
4
16
 
5
17
  ### Patch Changes
@@ -8,8 +8,8 @@ exports.key = exports.createPlugin = void 0;
8
8
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
9
  var _rafSchd = _interopRequireDefault(require("raf-schd"));
10
10
  var _analytics = require("@atlaskit/editor-common/analytics");
11
+ var _browser = require("@atlaskit/editor-common/browser");
11
12
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
12
- var _utils = require("@atlaskit/editor-common/utils");
13
13
  var _state = require("@atlaskit/editor-prosemirror/state");
14
14
  var _view = require("@atlaskit/editor-prosemirror/view");
15
15
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
@@ -391,7 +391,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl) {
391
391
  selection = _view$state.selection,
392
392
  doc = _view$state.doc,
393
393
  tr = _view$state.tr;
394
- var metaKey = _utils.browser.mac ? event.metaKey : event.ctrlKey;
394
+ var metaKey = _browser.browser.mac ? event.metaKey : event.ctrlKey;
395
395
  if (event.key === 'ArrowUp' && event.shiftKey && metaKey) {
396
396
  if (selection instanceof _state.TextSelection || selection instanceof _state.NodeSelection) {
397
397
  var newSelection = _state.TextSelection.create(doc, selection.head, 1);
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.topPositionAdjustment = exports.spaceLookupMap = exports.nodeMargins = exports.dragHandleGap = exports.DRAG_HANDLE_ZINDEX = exports.DRAG_HANDLE_WIDTH = exports.DRAG_HANDLE_NARROW_GAP = exports.DRAG_HANDLE_MAX_WIDTH_PLUS_GAP = exports.DRAG_HANDLE_MAX_GAP = exports.DRAG_HANDLE_HEIGHT = exports.DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT = exports.DRAG_HANDLE_DEFAULT_GAP = exports.DRAG_HANDLE_BORDER_RADIUS = void 0;
7
+ exports.topPositionAdjustment = exports.spaceLookupMap = exports.nodeMargins = exports.getNestedNodeLeftPaddingMargin = exports.dragHandleGap = exports.DRAG_HANDLE_ZINDEX = exports.DRAG_HANDLE_WIDTH = exports.DRAG_HANDLE_NARROW_GAP = exports.DRAG_HANDLE_MAX_WIDTH_PLUS_GAP = exports.DRAG_HANDLE_MAX_GAP = exports.DRAG_HANDLE_HEIGHT = exports.DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT = exports.DRAG_HANDLE_DEFAULT_GAP = exports.DRAG_HANDLE_BORDER_RADIUS = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
10
10
  var _dropTargetMarginMap;
@@ -28,6 +28,25 @@ var dragHandleGap = exports.dragHandleGap = function dragHandleGap(nodeType, par
28
28
  }
29
29
  return DRAG_HANDLE_DEFAULT_GAP;
30
30
  };
31
+ var getNestedNodeLeftPaddingMargin = exports.getNestedNodeLeftPaddingMargin = function getNestedNodeLeftPaddingMargin(nodeType) {
32
+ switch (nodeType) {
33
+ case 'bodiedExtension':
34
+ return '28px';
35
+ case 'expand':
36
+ case 'nestedExpand':
37
+ return '24px';
38
+ case 'layoutColumn':
39
+ return '20px';
40
+ case 'panel':
41
+ return '44px';
42
+ case 'tableCell':
43
+ return '8px';
44
+ case 'tableHeader':
45
+ return '8px';
46
+ default:
47
+ return "".concat(DRAG_HANDLE_WIDTH + DRAG_HANDLE_NARROW_GAP, "px");
48
+ }
49
+ };
31
50
  var topPositionAdjustment = exports.topPositionAdjustment = function topPositionAdjustment(nodeType) {
32
51
  switch (nodeType) {
33
52
  case 'rule':
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.dragPreview = void 0;
7
- var _utils = require("@atlaskit/editor-common/utils");
7
+ var _browser = require("@atlaskit/editor-common/browser");
8
8
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
9
9
  var _colors = require("@atlaskit/theme/colors");
10
10
  var previewStyle = {
@@ -50,7 +50,7 @@ var dragPreview = exports.dragPreview = function dragPreview(container, dom, nod
50
50
  clonedDom.style.marginRight = '0';
51
51
  clonedDom.style.marginBottom = '0';
52
52
  clonedDom.style.boxShadow = 'none';
53
- clonedDom.style.opacity = _utils.browser.windows ? '1' : (0, _platformFeatureFlags.fg)('platform_editor_elements_drag_and_drop_ed_23189') ? '0.31' : '0.4';
53
+ clonedDom.style.opacity = _browser.browser.windows ? '1' : (0, _platformFeatureFlags.fg)('platform_editor_elements_drag_and_drop_ed_23189') ? '0.31' : '0.4';
54
54
  parent.appendChild(clonedDom);
55
55
  }
56
56
  container.appendChild(parent);
@@ -24,11 +24,13 @@ var _consts = require("./consts");
24
24
 
25
25
  var DEFAULT_DROP_INDICATOR_WIDTH = 760;
26
26
  var EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH = '--editor-block-controls-drop-indicator-width';
27
+ var EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_LEFT_MARGIN = '--editor-block-controls-drop-indicator-leftMargin';
27
28
  var styleDropTarget = (0, _react2.css)({
28
29
  height: "var(--ds-space-100, 8px)",
29
30
  marginTop: "var(--ds-space-negative-100, -8px)",
31
+ marginLeft: "calc(-1 * var(".concat(EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_LEFT_MARGIN, ", 0))"),
32
+ paddingLeft: "var(".concat(EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_LEFT_MARGIN, ", 0)"),
30
33
  position: 'absolute',
31
- width: '100%',
32
34
  left: '0',
33
35
  display: 'block',
34
36
  zIndex: _constants.layers.card()
@@ -76,6 +78,7 @@ var getDropTargetOffsetStyle = function getDropTargetOffsetStyle(prevNode, nextN
76
78
  return marginLookupMap[offset];
77
79
  };
78
80
  var DropTarget = exports.DropTarget = function DropTarget(_ref3) {
81
+ var _widthStyle;
79
82
  var api = _ref3.api,
80
83
  id = _ref3.id,
81
84
  prevNode = _ref3.prevNode,
@@ -136,7 +139,9 @@ var DropTarget = exports.DropTarget = function DropTarget(_ref3) {
136
139
  }
137
140
  return getDropTargetOffsetStyle(prevNode, nextNode);
138
141
  }, [prevNode, nextNode, parentNode]);
139
- var widthStyle = (0, _defineProperty2.default)({}, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH, isNestedDropTarget ? '100%' : "".concat((widthState === null || widthState === void 0 ? void 0 : widthState.lineLength) || DEFAULT_DROP_INDICATOR_WIDTH, "px"));
142
+ var widthStyle = (_widthStyle = {
143
+ width: isNestedDropTarget ? 'unset' : '100%'
144
+ }, (0, _defineProperty2.default)(_widthStyle, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH, isNestedDropTarget ? '100%' : "".concat((widthState === null || widthState === void 0 ? void 0 : widthState.lineLength) || DEFAULT_DROP_INDICATOR_WIDTH, "px")), (0, _defineProperty2.default)(_widthStyle, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_LEFT_MARGIN, isNestedDropTarget ? (0, _consts.getNestedNodeLeftPaddingMargin)(parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name) : '0'), _widthStyle);
140
145
  return (
141
146
  // Note: Firefox has trouble with using a button element as the handle for drag and drop
142
147
  (0, _react2.jsx)("div", {
@@ -1,7 +1,7 @@
1
1
  import rafSchedule from 'raf-schd';
2
2
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
3
+ import { browser } from '@atlaskit/editor-common/browser';
3
4
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
4
- import { browser } from '@atlaskit/editor-common/utils';
5
5
  import { NodeSelection, PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
6
6
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
7
7
  import { fg } from '@atlaskit/platform-feature-flags';
@@ -19,6 +19,25 @@ export const dragHandleGap = (nodeType, parentNodeType) => {
19
19
  }
20
20
  return DRAG_HANDLE_DEFAULT_GAP;
21
21
  };
22
+ export const getNestedNodeLeftPaddingMargin = nodeType => {
23
+ switch (nodeType) {
24
+ case 'bodiedExtension':
25
+ return '28px';
26
+ case 'expand':
27
+ case 'nestedExpand':
28
+ return '24px';
29
+ case 'layoutColumn':
30
+ return '20px';
31
+ case 'panel':
32
+ return '44px';
33
+ case 'tableCell':
34
+ return '8px';
35
+ case 'tableHeader':
36
+ return '8px';
37
+ default:
38
+ return `${DRAG_HANDLE_WIDTH + DRAG_HANDLE_NARROW_GAP}px`;
39
+ }
40
+ };
22
41
  export const topPositionAdjustment = nodeType => {
23
42
  switch (nodeType) {
24
43
  case 'rule':
@@ -1,4 +1,4 @@
1
- import { browser } from '@atlaskit/editor-common/utils';
1
+ import { browser } from '@atlaskit/editor-common/browser';
2
2
  import { fg } from '@atlaskit/platform-feature-flags';
3
3
  import { B200, N20, N30 } from '@atlaskit/theme/colors';
4
4
  const previewStyle = {
@@ -11,14 +11,16 @@ import { DropIndicator } from '@atlaskit/pragmatic-drag-and-drop-react-drop-indi
11
11
  import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
12
12
  import { layers } from '@atlaskit/theme/constants';
13
13
  import { isBlocksDragTargetDebug } from '../utils/drag-target-debug';
14
- import { nodeMargins, spaceLookupMap } from './consts';
14
+ import { getNestedNodeLeftPaddingMargin, nodeMargins, spaceLookupMap } from './consts';
15
15
  const DEFAULT_DROP_INDICATOR_WIDTH = 760;
16
16
  const EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH = '--editor-block-controls-drop-indicator-width';
17
+ const EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_LEFT_MARGIN = '--editor-block-controls-drop-indicator-leftMargin';
17
18
  const styleDropTarget = css({
18
19
  height: "var(--ds-space-100, 8px)",
19
20
  marginTop: "var(--ds-space-negative-100, -8px)",
21
+ marginLeft: `calc(-1 * var(${EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_LEFT_MARGIN}, 0))`,
22
+ paddingLeft: `var(${EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_LEFT_MARGIN}, 0)`,
20
23
  position: 'absolute',
21
- width: '100%',
22
24
  left: '0',
23
25
  display: 'block',
24
26
  zIndex: layers.card()
@@ -121,7 +123,9 @@ export const DropTarget = ({
121
123
  return getDropTargetOffsetStyle(prevNode, nextNode);
122
124
  }, [prevNode, nextNode, parentNode]);
123
125
  const widthStyle = {
124
- [EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH]: isNestedDropTarget ? '100%' : `${(widthState === null || widthState === void 0 ? void 0 : widthState.lineLength) || DEFAULT_DROP_INDICATOR_WIDTH}px`
126
+ width: isNestedDropTarget ? 'unset' : '100%',
127
+ [EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH]: isNestedDropTarget ? '100%' : `${(widthState === null || widthState === void 0 ? void 0 : widthState.lineLength) || DEFAULT_DROP_INDICATOR_WIDTH}px`,
128
+ [EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_LEFT_MARGIN]: isNestedDropTarget ? getNestedNodeLeftPaddingMargin(parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name) : '0'
125
129
  };
126
130
  return (
127
131
  // Note: Firefox has trouble with using a button element as the handle for drag and drop
@@ -1,8 +1,8 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
2
  import rafSchedule from 'raf-schd';
3
3
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
4
+ import { browser } from '@atlaskit/editor-common/browser';
4
5
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
5
- import { browser } from '@atlaskit/editor-common/utils';
6
6
  import { NodeSelection, PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
7
7
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
8
8
  import { fg } from '@atlaskit/platform-feature-flags';
@@ -21,6 +21,25 @@ export var dragHandleGap = function dragHandleGap(nodeType, parentNodeType) {
21
21
  }
22
22
  return DRAG_HANDLE_DEFAULT_GAP;
23
23
  };
24
+ export var getNestedNodeLeftPaddingMargin = function getNestedNodeLeftPaddingMargin(nodeType) {
25
+ switch (nodeType) {
26
+ case 'bodiedExtension':
27
+ return '28px';
28
+ case 'expand':
29
+ case 'nestedExpand':
30
+ return '24px';
31
+ case 'layoutColumn':
32
+ return '20px';
33
+ case 'panel':
34
+ return '44px';
35
+ case 'tableCell':
36
+ return '8px';
37
+ case 'tableHeader':
38
+ return '8px';
39
+ default:
40
+ return "".concat(DRAG_HANDLE_WIDTH + DRAG_HANDLE_NARROW_GAP, "px");
41
+ }
42
+ };
24
43
  export var topPositionAdjustment = function topPositionAdjustment(nodeType) {
25
44
  switch (nodeType) {
26
45
  case 'rule':
@@ -1,4 +1,4 @@
1
- import { browser } from '@atlaskit/editor-common/utils';
1
+ import { browser } from '@atlaskit/editor-common/browser';
2
2
  import { fg } from '@atlaskit/platform-feature-flags';
3
3
  import { B200, N20, N30 } from '@atlaskit/theme/colors';
4
4
  var previewStyle = {
@@ -13,14 +13,16 @@ import { DropIndicator } from '@atlaskit/pragmatic-drag-and-drop-react-drop-indi
13
13
  import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
14
14
  import { layers } from '@atlaskit/theme/constants';
15
15
  import { isBlocksDragTargetDebug } from '../utils/drag-target-debug';
16
- import { nodeMargins, spaceLookupMap } from './consts';
16
+ import { getNestedNodeLeftPaddingMargin, nodeMargins, spaceLookupMap } from './consts';
17
17
  var DEFAULT_DROP_INDICATOR_WIDTH = 760;
18
18
  var EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH = '--editor-block-controls-drop-indicator-width';
19
+ var EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_LEFT_MARGIN = '--editor-block-controls-drop-indicator-leftMargin';
19
20
  var styleDropTarget = css({
20
21
  height: "var(--ds-space-100, 8px)",
21
22
  marginTop: "var(--ds-space-negative-100, -8px)",
23
+ marginLeft: "calc(-1 * var(".concat(EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_LEFT_MARGIN, ", 0))"),
24
+ paddingLeft: "var(".concat(EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_LEFT_MARGIN, ", 0)"),
22
25
  position: 'absolute',
23
- width: '100%',
24
26
  left: '0',
25
27
  display: 'block',
26
28
  zIndex: layers.card()
@@ -68,6 +70,7 @@ var getDropTargetOffsetStyle = function getDropTargetOffsetStyle(prevNode, nextN
68
70
  return marginLookupMap[offset];
69
71
  };
70
72
  export var DropTarget = function DropTarget(_ref3) {
73
+ var _widthStyle;
71
74
  var api = _ref3.api,
72
75
  id = _ref3.id,
73
76
  prevNode = _ref3.prevNode,
@@ -128,7 +131,9 @@ export var DropTarget = function DropTarget(_ref3) {
128
131
  }
129
132
  return getDropTargetOffsetStyle(prevNode, nextNode);
130
133
  }, [prevNode, nextNode, parentNode]);
131
- var widthStyle = _defineProperty({}, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH, isNestedDropTarget ? '100%' : "".concat((widthState === null || widthState === void 0 ? void 0 : widthState.lineLength) || DEFAULT_DROP_INDICATOR_WIDTH, "px"));
134
+ var widthStyle = (_widthStyle = {
135
+ width: isNestedDropTarget ? 'unset' : '100%'
136
+ }, _defineProperty(_widthStyle, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH, isNestedDropTarget ? '100%' : "".concat((widthState === null || widthState === void 0 ? void 0 : widthState.lineLength) || DEFAULT_DROP_INDICATOR_WIDTH, "px")), _defineProperty(_widthStyle, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_LEFT_MARGIN, isNestedDropTarget ? getNestedNodeLeftPaddingMargin(parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name) : '0'), _widthStyle);
132
137
  return (
133
138
  // Note: Firefox has trouble with using a button element as the handle for drag and drop
134
139
  jsx("div", {
@@ -8,6 +8,7 @@ export declare const DRAG_HANDLE_MAX_GAP = 12;
8
8
  export declare const DRAG_HANDLE_MAX_WIDTH_PLUS_GAP: number;
9
9
  export declare const DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT: number;
10
10
  export declare const dragHandleGap: (nodeType: string, parentNodeType?: string) => 4 | 8 | 12;
11
+ export declare const getNestedNodeLeftPaddingMargin: (nodeType?: string) => "8px" | "16px" | "20px" | "24px" | "28px" | "44px";
11
12
  export declare const topPositionAdjustment: (nodeType: string) => number;
12
13
  /**
13
14
  * This document serves as a quick reference map for correlating various space matches
@@ -8,6 +8,7 @@ export declare const DRAG_HANDLE_MAX_GAP = 12;
8
8
  export declare const DRAG_HANDLE_MAX_WIDTH_PLUS_GAP: number;
9
9
  export declare const DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT: number;
10
10
  export declare const dragHandleGap: (nodeType: string, parentNodeType?: string) => 4 | 8 | 12;
11
+ export declare const getNestedNodeLeftPaddingMargin: (nodeType?: string) => "8px" | "16px" | "20px" | "24px" | "28px" | "44px";
11
12
  export declare const topPositionAdjustment: (nodeType: string) => number;
12
13
  /**
13
14
  * This document serves as a quick reference map for correlating various space matches
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "1.12.8",
3
+ "version": "1.12.9",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -29,7 +29,7 @@
29
29
  ".": "./src/index.ts"
30
30
  },
31
31
  "dependencies": {
32
- "@atlaskit/editor-common": "^88.6.0",
32
+ "@atlaskit/editor-common": "^88.8.0",
33
33
  "@atlaskit/editor-plugin-accessibility-utils": "^1.2.0",
34
34
  "@atlaskit/editor-plugin-analytics": "^1.8.0",
35
35
  "@atlaskit/editor-plugin-editor-disabled": "^1.3.0",
@@ -44,7 +44,7 @@
44
44
  "@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^1.4.0",
45
45
  "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^1.1.0",
46
46
  "@atlaskit/theme": "^13.0.0",
47
- "@atlaskit/tmp-editor-statsig": "^2.0.0",
47
+ "@atlaskit/tmp-editor-statsig": "^2.1.0",
48
48
  "@atlaskit/tokens": "^1.59.0",
49
49
  "@atlaskit/tooltip": "^18.7.0",
50
50
  "@babel/runtime": "^7.0.0",