@atlaskit/editor-plugin-block-controls 8.11.0 → 9.0.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,22 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 9.0.0
4
+
5
+ ### Patch Changes
6
+
7
+ - [`ae28f2e6bb741`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ae28f2e6bb741) -
8
+ Editor-4477: Removed the heading with alignment patch in the newGetSelection
9
+ - [`ae28f2e6bb741`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ae28f2e6bb741) -
10
+ Editor-5020-fix-inline-drop-hints-not-visible-in-sync-block
11
+ - Updated dependencies
12
+
13
+ ## 8.12.0
14
+
15
+ ### Minor Changes
16
+
17
+ - [`c78234abd2778`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c78234abd2778) -
18
+ EDITOR-5792 fix drop target for sync blocks
19
+
3
20
  ## 8.11.0
4
21
 
5
22
  ### Minor Changes
@@ -134,16 +134,21 @@ var canMoveToLayout = function canMoveToLayout(api, from, to, tr, moveNodeAtCurs
134
134
  var _ref3 = tr.doc.type.schema.nodes || {},
135
135
  layoutSection = _ref3.layoutSection,
136
136
  layoutColumn = _ref3.layoutColumn,
137
- doc = _ref3.doc;
137
+ doc = _ref3.doc,
138
+ bodiedSyncBlock = _ref3.bodiedSyncBlock;
138
139
 
139
140
  // layout plugin does not exist
140
141
  if (!layoutSection || !layoutColumn) {
141
142
  return;
142
143
  }
143
144
  var $to = tr.doc.resolve(to);
145
+ var allowedParentTypes = [doc, layoutSection];
146
+ if (bodiedSyncBlock && (0, _expValEquals.expValEquals)('platform_synced_block', 'isEnabled', true) && (0, _expValEquals.expValEquals)('platform_synced_block_patch_6', 'isEnabled', true)) {
147
+ allowedParentTypes.push(bodiedSyncBlock);
148
+ }
144
149
 
145
150
  // drop at invalid position, not top level, or not a layout column
146
- if (!$to.nodeAfter || ![doc, layoutSection].includes($to.parent.type)) {
151
+ if (!$to.nodeAfter || !allowedParentTypes.includes($to.parent.type)) {
147
152
  return;
148
153
  }
149
154
  var $from = tr.doc.resolve(from);
@@ -4,8 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.findSurroundingNodes = void 0;
7
+ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
7
8
  var IGNORE_NODES = ['tableRow', 'listItem', 'caption', 'media'];
8
9
  var blockLeafNodes = ['blockCard', 'rule', 'extension'];
10
+ var blockLeafNodeNext = ['blockCard', 'rule', 'extension', 'syncBlock'];
9
11
  var DISABLE_CHILD_DROP_TARGET = ['orderedList', 'bulletList'];
10
12
 
11
13
  /**
@@ -19,7 +21,9 @@ var DISABLE_CHILD_DROP_TARGET = ['orderedList', 'bulletList'];
19
21
  */
20
22
  var _findSurroundingNodes = exports.findSurroundingNodes = function findSurroundingNodes(state, $pos, nodeType) {
21
23
  var depth = $pos.depth;
22
- var blockLeafNodeList = blockLeafNodes;
24
+ var blockLeafNodeList = (0, _experiments.editorExperiment)('platform_synced_block_patch_6', true, {
25
+ exposure: true
26
+ }) ? blockLeafNodeNext : blockLeafNodes;
23
27
 
24
28
  // special cases like hr rule here
25
29
  if (blockLeafNodeList.includes(nodeType || '') || $pos.pos === 0) {
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.shouldAllowInlineDropTarget = void 0;
7
7
  var _utils = require("@atlaskit/editor-common/utils");
8
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
8
9
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
9
10
  var _checkMediaLayout = require("./check-media-layout");
10
11
  var _consts = require("./consts");
@@ -12,7 +13,13 @@ var syncedBlockTypes = ['syncBlock', 'bodiedSyncBlock'];
12
13
  var shouldAllowInlineDropTarget = exports.shouldAllowInlineDropTarget = function shouldAllowInlineDropTarget(isNested, node) {
13
14
  var isSameLayout = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
14
15
  var activeNode = arguments.length > 3 ? arguments[3] : undefined;
16
+ var parentNode = arguments.length > 4 ? arguments[4] : undefined;
17
+ var isInsideBodiedSyncBlock = (parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name) === 'bodiedSyncBlock';
15
18
  if ((0, _experiments.editorExperiment)('advanced_layouts', false) || isNested) {
19
+ // If nested inside bodiedSyncBlock, enable inline drop target so user can drop to create a layout inside it
20
+ if (isInsideBodiedSyncBlock && (0, _expValEquals.expValEquals)('platform_synced_block', 'isEnabled', true) && (0, _expValEquals.expValEquals)('platform_synced_block_patch_6', 'isEnabled', true)) {
21
+ return true;
22
+ }
16
23
  return false;
17
24
  }
18
25
  if ((0, _checkMediaLayout.isWrappedMedia)(node)) {
@@ -21,7 +28,7 @@ var shouldAllowInlineDropTarget = exports.shouldAllowInlineDropTarget = function
21
28
  if ((activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) === 'layoutSection') {
22
29
  return false;
23
30
  }
24
- if ((syncedBlockTypes.includes((activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) || '') || syncedBlockTypes.includes((node === null || node === void 0 ? void 0 : node.type.name) || '')) && (0, _experiments.editorExperiment)('platform_synced_block', true)) {
31
+ if ((syncedBlockTypes.includes((activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) || '') || syncedBlockTypes.includes((node === null || node === void 0 ? void 0 : node.type.name) || '')) && (0, _experiments.editorExperiment)('platform_synced_block', true) && !(0, _expValEquals.expValEquals)('platform_synced_block_patch_6', 'isEnabled', true)) {
25
32
  return false;
26
33
  }
27
34
  if ((node === null || node === void 0 ? void 0 : node.type.name) === 'layoutSection') {
@@ -70,6 +70,15 @@ var nestedDropZoneStyle = (0, _react2.css)({
70
70
  width: 'unset'
71
71
  });
72
72
  var enableDropZone = ['paragraph', 'mediaSingle', 'heading', 'codeBlock', 'decisionList', 'bulletList', 'orderedList', 'taskList', 'extension', 'blockCard'];
73
+ var enableDropZoneNext = ['paragraph', 'mediaSingle', 'heading', 'codeBlock', 'decisionList', 'bulletList', 'orderedList', 'taskList', 'extension', 'blockCard', 'syncBlock'];
74
+ var getEnableDropZone = function getEnableDropZone() {
75
+ if ((0, _experiments.editorExperiment)('platform_synced_block_patch_6', true, {
76
+ exposure: true
77
+ })) {
78
+ return enableDropZoneNext;
79
+ }
80
+ return enableDropZone;
81
+ };
73
82
 
74
83
  // This z index is used in container like layout
75
84
  var fullHeightStyleAdjustZIndexStyle = (0, _react2.css)({
@@ -104,12 +113,13 @@ var HoverZone = function HoverZone(_ref) {
104
113
  _useActiveAnchorTrack2 = (0, _slicedToArray2.default)(_useActiveAnchorTrack, 2),
105
114
  _isActive = _useActiveAnchorTrack2[0],
106
115
  setActiveAnchor = _useActiveAnchorTrack2[1];
116
+ var isInsideBodiedSyncBlock = parent && parent.type.name === 'bodiedSyncBlock' && (0, _expValEquals.expValEquals)('platform_synced_block', 'isEnabled', true) && (0, _expValEquals.expValEquals)('platform_synced_block_patch_6', 'isEnabled', true);
107
117
  (0, _react.useEffect)(function () {
108
118
  if (ref.current) {
109
119
  return (0, _adapter.dropTargetForElements)({
110
120
  element: ref.current,
111
121
  onDragEnter: function onDragEnter() {
112
- if (!isNestedDropTarget && (0, _experiments.editorExperiment)('advanced_layouts', true)) {
122
+ if ((!isNestedDropTarget || isInsideBodiedSyncBlock) && (0, _experiments.editorExperiment)('advanced_layouts', true)) {
113
123
  setActiveAnchor();
114
124
  }
115
125
  _onDragEnter();
@@ -118,11 +128,11 @@ var HoverZone = function HoverZone(_ref) {
118
128
  onDrop: onDrop
119
129
  });
120
130
  }
121
- }, [isNestedDropTarget, _onDragEnter, onDragLeave, onDrop, setActiveAnchor]);
131
+ }, [isNestedDropTarget, isInsideBodiedSyncBlock, _onDragEnter, onDragLeave, onDrop, setActiveAnchor]);
122
132
  var hoverZoneUpperStyle = (0, _react.useMemo)(function () {
123
133
  var heightStyleOffset = "var(--editor-block-controls-drop-indicator-gap, 0)/2";
124
134
  var transformOffset = "var(".concat(EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_OFFSET, ", 0)");
125
- var heightStyle = anchorName && enableDropZone.includes((node === null || node === void 0 ? void 0 : node.type.name) || '') ? (0, _anchorUtils.isAnchorSupported)() ? "calc(anchor-size(".concat(anchorName, " height)/2 + ").concat(heightStyleOffset, ")") : "calc(".concat(((anchorRectCache === null || anchorRectCache === void 0 ? void 0 : anchorRectCache.getHeight(anchorName)) || 0) / 2, "px + ").concat(heightStyleOffset, ")") : '4px';
135
+ var heightStyle = anchorName && getEnableDropZone().includes((node === null || node === void 0 ? void 0 : node.type.name) || '') ? (0, _anchorUtils.isAnchorSupported)() ? "calc(anchor-size(".concat(anchorName, " height)/2 + ").concat(heightStyleOffset, ")") : "calc(".concat(((anchorRectCache === null || anchorRectCache === void 0 ? void 0 : anchorRectCache.getHeight(anchorName)) || 0) / 2, "px + ").concat(heightStyleOffset, ")") : '4px';
126
136
  var transform = position === 'upper' ? "translateY(calc(-100% + ".concat(transformOffset, "))") : "translateY(".concat(transformOffset, ")");
127
137
  return (0, _react2.css)({
128
138
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values
@@ -147,7 +157,7 @@ var HoverZone = function HoverZone(_ref) {
147
157
  var _anchorName = node ? (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? (api === null || api === void 0 ? void 0 : api.core.actions.getAnchorIdForNode(node, pos || -1)) || '' : (0, _decorationsCommon.getNodeAnchor)(node) : '';
148
158
  var top = 'unset';
149
159
  if (_anchorName) {
150
- var enabledDropZone = enableDropZone.includes((node === null || node === void 0 ? void 0 : node.type.name) || '');
160
+ var enabledDropZone = getEnableDropZone().includes((node === null || node === void 0 ? void 0 : node.type.name) || '');
151
161
  if ((0, _anchorUtils.isAnchorSupported)()) {
152
162
  top = enabledDropZone ? "calc(anchor(".concat(_anchorName, " 50%))") : "calc(anchor(".concat(_anchorName, " bottom) - 4px)");
153
163
  } else if (anchorRectCache) {
@@ -229,6 +239,7 @@ var DropTarget = exports.DropTarget = function DropTarget(props) {
229
239
  var dynamicStyle = (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({
230
240
  width: isNestedDropTarget ? 'unset' : '100%'
231
241
  }, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH, isNestedDropTarget ? '100%' : "".concat(lineLength || DEFAULT_DROP_INDICATOR_WIDTH, "px")), EDITOR_BLOCK_CONTROLS_DROP_TARGET_LEFT_MARGIN, isNestedDropTarget ? (0, _consts.getNestedNodeLeftPaddingMargin)(parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name) : '0'), EDITOR_BLOCK_CONTROLS_DROP_TARGET_ZINDEX, _constants.layers.navigation());
242
+ var isShowInlineDropTarget = (0, _inlineDropTarget.shouldAllowInlineDropTarget)(isNestedDropTarget, nextNode, isSameLayout, activeNode, parentNode);
232
243
  return (0, _react2.jsx)(_react.Fragment, null, (0, _react2.jsx)(HoverZone, {
233
244
  onDragEnter: function onDragEnter() {
234
245
  return setIsDraggedOver(true);
@@ -273,7 +284,7 @@ var DropTarget = exports.DropTarget = function DropTarget(props) {
273
284
  position: "lower",
274
285
  isNestedDropTarget: isNestedDropTarget,
275
286
  api: api
276
- }), (0, _inlineDropTarget.shouldAllowInlineDropTarget)(isNestedDropTarget, nextNode, isSameLayout, activeNode) && (0, _react2.jsx)(_react.Fragment, null, (0, _react2.jsx)(_inlineDropTarget2.InlineDropTarget
287
+ }), isShowInlineDropTarget && (0, _react2.jsx)(_react.Fragment, null, (0, _react2.jsx)(_inlineDropTarget2.InlineDropTarget
277
288
  // Ignored via go/ees005
278
289
  // eslint-disable-next-line react/jsx-props-no-spreading
279
290
  , (0, _extends2.default)({}, props, {
@@ -130,7 +130,8 @@ const canMoveToLayout = (api, from, to, tr, moveNodeAtCursorPos) => {
130
130
  const {
131
131
  layoutSection,
132
132
  layoutColumn,
133
- doc
133
+ doc,
134
+ bodiedSyncBlock
134
135
  } = tr.doc.type.schema.nodes || {};
135
136
 
136
137
  // layout plugin does not exist
@@ -138,9 +139,13 @@ const canMoveToLayout = (api, from, to, tr, moveNodeAtCursorPos) => {
138
139
  return;
139
140
  }
140
141
  const $to = tr.doc.resolve(to);
142
+ const allowedParentTypes = [doc, layoutSection];
143
+ if (bodiedSyncBlock && expValEquals('platform_synced_block', 'isEnabled', true) && expValEquals('platform_synced_block_patch_6', 'isEnabled', true)) {
144
+ allowedParentTypes.push(bodiedSyncBlock);
145
+ }
141
146
 
142
147
  // drop at invalid position, not top level, or not a layout column
143
- if (!$to.nodeAfter || ![doc, layoutSection].includes($to.parent.type)) {
148
+ if (!$to.nodeAfter || !allowedParentTypes.includes($to.parent.type)) {
144
149
  return;
145
150
  }
146
151
  const $from = tr.doc.resolve(from);
@@ -1,5 +1,7 @@
1
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
1
2
  const IGNORE_NODES = ['tableRow', 'listItem', 'caption', 'media'];
2
3
  const blockLeafNodes = ['blockCard', 'rule', 'extension'];
4
+ const blockLeafNodeNext = ['blockCard', 'rule', 'extension', 'syncBlock'];
3
5
  const DISABLE_CHILD_DROP_TARGET = ['orderedList', 'bulletList'];
4
6
 
5
7
  /**
@@ -13,7 +15,9 @@ const DISABLE_CHILD_DROP_TARGET = ['orderedList', 'bulletList'];
13
15
  */
14
16
  export const findSurroundingNodes = (state, $pos, nodeType) => {
15
17
  const depth = $pos.depth;
16
- const blockLeafNodeList = blockLeafNodes;
18
+ const blockLeafNodeList = editorExperiment('platform_synced_block_patch_6', true, {
19
+ exposure: true
20
+ }) ? blockLeafNodeNext : blockLeafNodes;
17
21
 
18
22
  // special cases like hr rule here
19
23
  if (blockLeafNodeList.includes(nodeType || '') || $pos.pos === 0) {
@@ -1,4 +1,5 @@
1
1
  import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
2
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
2
3
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
3
4
  import { isWrappedMedia } from './check-media-layout';
4
5
  import { maxLayoutColumnSupported } from './consts';
@@ -7,8 +8,13 @@ export const shouldAllowInlineDropTarget = (isNested, node,
7
8
  /**
8
9
  * Is the active node in the same layout as the target node
9
10
  */
10
- isSameLayout = false, activeNode) => {
11
+ isSameLayout = false, activeNode, parentNode) => {
12
+ const isInsideBodiedSyncBlock = (parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name) === 'bodiedSyncBlock';
11
13
  if (editorExperiment('advanced_layouts', false) || isNested) {
14
+ // If nested inside bodiedSyncBlock, enable inline drop target so user can drop to create a layout inside it
15
+ if (isInsideBodiedSyncBlock && expValEquals('platform_synced_block', 'isEnabled', true) && expValEquals('platform_synced_block_patch_6', 'isEnabled', true)) {
16
+ return true;
17
+ }
12
18
  return false;
13
19
  }
14
20
  if (isWrappedMedia(node)) {
@@ -17,7 +23,7 @@ isSameLayout = false, activeNode) => {
17
23
  if ((activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) === 'layoutSection') {
18
24
  return false;
19
25
  }
20
- if ((syncedBlockTypes.includes((activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) || '') || syncedBlockTypes.includes((node === null || node === void 0 ? void 0 : node.type.name) || '')) && editorExperiment('platform_synced_block', true)) {
26
+ if ((syncedBlockTypes.includes((activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) || '') || syncedBlockTypes.includes((node === null || node === void 0 ? void 0 : node.type.name) || '')) && editorExperiment('platform_synced_block', true) && !expValEquals('platform_synced_block_patch_6', 'isEnabled', true)) {
21
27
  return false;
22
28
  }
23
29
  if ((node === null || node === void 0 ? void 0 : node.type.name) === 'layoutSection') {
@@ -60,6 +60,15 @@ const nestedDropZoneStyle = css({
60
60
  width: 'unset'
61
61
  });
62
62
  const enableDropZone = ['paragraph', 'mediaSingle', 'heading', 'codeBlock', 'decisionList', 'bulletList', 'orderedList', 'taskList', 'extension', 'blockCard'];
63
+ const enableDropZoneNext = ['paragraph', 'mediaSingle', 'heading', 'codeBlock', 'decisionList', 'bulletList', 'orderedList', 'taskList', 'extension', 'blockCard', 'syncBlock'];
64
+ const getEnableDropZone = () => {
65
+ if (editorExperiment('platform_synced_block_patch_6', true, {
66
+ exposure: true
67
+ })) {
68
+ return enableDropZoneNext;
69
+ }
70
+ return enableDropZone;
71
+ };
63
72
 
64
73
  // This z index is used in container like layout
65
74
  const fullHeightStyleAdjustZIndexStyle = css({
@@ -92,12 +101,13 @@ const HoverZone = ({
92
101
  return node ? getNodeAnchor(node) : '';
93
102
  }, [api, node, pos, position]);
94
103
  const [_isActive, setActiveAnchor] = useActiveAnchorTracker(anchorName);
104
+ const isInsideBodiedSyncBlock = parent && parent.type.name === 'bodiedSyncBlock' && expValEquals('platform_synced_block', 'isEnabled', true) && expValEquals('platform_synced_block_patch_6', 'isEnabled', true);
95
105
  useEffect(() => {
96
106
  if (ref.current) {
97
107
  return dropTargetForElements({
98
108
  element: ref.current,
99
109
  onDragEnter: () => {
100
- if (!isNestedDropTarget && editorExperiment('advanced_layouts', true)) {
110
+ if ((!isNestedDropTarget || isInsideBodiedSyncBlock) && editorExperiment('advanced_layouts', true)) {
101
111
  setActiveAnchor();
102
112
  }
103
113
  onDragEnter();
@@ -106,11 +116,11 @@ const HoverZone = ({
106
116
  onDrop
107
117
  });
108
118
  }
109
- }, [isNestedDropTarget, onDragEnter, onDragLeave, onDrop, setActiveAnchor]);
119
+ }, [isNestedDropTarget, isInsideBodiedSyncBlock, onDragEnter, onDragLeave, onDrop, setActiveAnchor]);
110
120
  const hoverZoneUpperStyle = useMemo(() => {
111
121
  const heightStyleOffset = `var(--editor-block-controls-drop-indicator-gap, 0)/2`;
112
122
  const transformOffset = `var(${EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_OFFSET}, 0)`;
113
- const heightStyle = anchorName && enableDropZone.includes((node === null || node === void 0 ? void 0 : node.type.name) || '') ? isAnchorSupported() ? `calc(anchor-size(${anchorName} height)/2 + ${heightStyleOffset})` : `calc(${((anchorRectCache === null || anchorRectCache === void 0 ? void 0 : anchorRectCache.getHeight(anchorName)) || 0) / 2}px + ${heightStyleOffset})` : '4px';
123
+ const heightStyle = anchorName && getEnableDropZone().includes((node === null || node === void 0 ? void 0 : node.type.name) || '') ? isAnchorSupported() ? `calc(anchor-size(${anchorName} height)/2 + ${heightStyleOffset})` : `calc(${((anchorRectCache === null || anchorRectCache === void 0 ? void 0 : anchorRectCache.getHeight(anchorName)) || 0) / 2}px + ${heightStyleOffset})` : '4px';
114
124
  const transform = position === 'upper' ? `translateY(calc(-100% + ${transformOffset}))` : `translateY(${transformOffset})`;
115
125
  return css({
116
126
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values
@@ -135,7 +145,7 @@ const HoverZone = ({
135
145
  const anchorName = node ? expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? (api === null || api === void 0 ? void 0 : api.core.actions.getAnchorIdForNode(node, pos || -1)) || '' : getNodeAnchor(node) : '';
136
146
  let top = 'unset';
137
147
  if (anchorName) {
138
- const enabledDropZone = enableDropZone.includes((node === null || node === void 0 ? void 0 : node.type.name) || '');
148
+ const enabledDropZone = getEnableDropZone().includes((node === null || node === void 0 ? void 0 : node.type.name) || '');
139
149
  if (isAnchorSupported()) {
140
150
  top = enabledDropZone ? `calc(anchor(${anchorName} 50%))` : `calc(anchor(${anchorName} bottom) - 4px)`;
141
151
  } else if (anchorRectCache) {
@@ -222,6 +232,7 @@ export const DropTarget = props => {
222
232
  [EDITOR_BLOCK_CONTROLS_DROP_TARGET_LEFT_MARGIN]: isNestedDropTarget ? getNestedNodeLeftPaddingMargin(parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name) : '0',
223
233
  [EDITOR_BLOCK_CONTROLS_DROP_TARGET_ZINDEX]: layers.navigation()
224
234
  };
235
+ const isShowInlineDropTarget = shouldAllowInlineDropTarget(isNestedDropTarget, nextNode, isSameLayout, activeNode, parentNode);
225
236
  return jsx(Fragment, null, jsx(HoverZone, {
226
237
  onDragEnter: () => setIsDraggedOver(true),
227
238
  onDragLeave: () => setIsDraggedOver(false),
@@ -258,7 +269,7 @@ export const DropTarget = props => {
258
269
  position: "lower",
259
270
  isNestedDropTarget: isNestedDropTarget,
260
271
  api: api
261
- }), shouldAllowInlineDropTarget(isNestedDropTarget, nextNode, isSameLayout, activeNode) && jsx(Fragment, null, jsx(InlineDropTarget
272
+ }), isShowInlineDropTarget && jsx(Fragment, null, jsx(InlineDropTarget
262
273
  // Ignored via go/ees005
263
274
  // eslint-disable-next-line react/jsx-props-no-spreading
264
275
  , _extends({}, props, {
@@ -128,16 +128,21 @@ var canMoveToLayout = function canMoveToLayout(api, from, to, tr, moveNodeAtCurs
128
128
  var _ref3 = tr.doc.type.schema.nodes || {},
129
129
  layoutSection = _ref3.layoutSection,
130
130
  layoutColumn = _ref3.layoutColumn,
131
- doc = _ref3.doc;
131
+ doc = _ref3.doc,
132
+ bodiedSyncBlock = _ref3.bodiedSyncBlock;
132
133
 
133
134
  // layout plugin does not exist
134
135
  if (!layoutSection || !layoutColumn) {
135
136
  return;
136
137
  }
137
138
  var $to = tr.doc.resolve(to);
139
+ var allowedParentTypes = [doc, layoutSection];
140
+ if (bodiedSyncBlock && expValEquals('platform_synced_block', 'isEnabled', true) && expValEquals('platform_synced_block_patch_6', 'isEnabled', true)) {
141
+ allowedParentTypes.push(bodiedSyncBlock);
142
+ }
138
143
 
139
144
  // drop at invalid position, not top level, or not a layout column
140
- if (!$to.nodeAfter || ![doc, layoutSection].includes($to.parent.type)) {
145
+ if (!$to.nodeAfter || !allowedParentTypes.includes($to.parent.type)) {
141
146
  return;
142
147
  }
143
148
  var $from = tr.doc.resolve(from);
@@ -1,5 +1,7 @@
1
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
1
2
  var IGNORE_NODES = ['tableRow', 'listItem', 'caption', 'media'];
2
3
  var blockLeafNodes = ['blockCard', 'rule', 'extension'];
4
+ var blockLeafNodeNext = ['blockCard', 'rule', 'extension', 'syncBlock'];
3
5
  var DISABLE_CHILD_DROP_TARGET = ['orderedList', 'bulletList'];
4
6
 
5
7
  /**
@@ -13,7 +15,9 @@ var DISABLE_CHILD_DROP_TARGET = ['orderedList', 'bulletList'];
13
15
  */
14
16
  var _findSurroundingNodes = function findSurroundingNodes(state, $pos, nodeType) {
15
17
  var depth = $pos.depth;
16
- var blockLeafNodeList = blockLeafNodes;
18
+ var blockLeafNodeList = editorExperiment('platform_synced_block_patch_6', true, {
19
+ exposure: true
20
+ }) ? blockLeafNodeNext : blockLeafNodes;
17
21
 
18
22
  // special cases like hr rule here
19
23
  if (blockLeafNodeList.includes(nodeType || '') || $pos.pos === 0) {
@@ -1,4 +1,5 @@
1
1
  import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
2
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
2
3
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
3
4
  import { isWrappedMedia } from './check-media-layout';
4
5
  import { maxLayoutColumnSupported } from './consts';
@@ -6,7 +7,13 @@ var syncedBlockTypes = ['syncBlock', 'bodiedSyncBlock'];
6
7
  export var shouldAllowInlineDropTarget = function shouldAllowInlineDropTarget(isNested, node) {
7
8
  var isSameLayout = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
8
9
  var activeNode = arguments.length > 3 ? arguments[3] : undefined;
10
+ var parentNode = arguments.length > 4 ? arguments[4] : undefined;
11
+ var isInsideBodiedSyncBlock = (parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name) === 'bodiedSyncBlock';
9
12
  if (editorExperiment('advanced_layouts', false) || isNested) {
13
+ // If nested inside bodiedSyncBlock, enable inline drop target so user can drop to create a layout inside it
14
+ if (isInsideBodiedSyncBlock && expValEquals('platform_synced_block', 'isEnabled', true) && expValEquals('platform_synced_block_patch_6', 'isEnabled', true)) {
15
+ return true;
16
+ }
10
17
  return false;
11
18
  }
12
19
  if (isWrappedMedia(node)) {
@@ -15,7 +22,7 @@ export var shouldAllowInlineDropTarget = function shouldAllowInlineDropTarget(is
15
22
  if ((activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) === 'layoutSection') {
16
23
  return false;
17
24
  }
18
- if ((syncedBlockTypes.includes((activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) || '') || syncedBlockTypes.includes((node === null || node === void 0 ? void 0 : node.type.name) || '')) && editorExperiment('platform_synced_block', true)) {
25
+ if ((syncedBlockTypes.includes((activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) || '') || syncedBlockTypes.includes((node === null || node === void 0 ? void 0 : node.type.name) || '')) && editorExperiment('platform_synced_block', true) && !expValEquals('platform_synced_block_patch_6', 'isEnabled', true)) {
19
26
  return false;
20
27
  }
21
28
  if ((node === null || node === void 0 ? void 0 : node.type.name) === 'layoutSection') {
@@ -62,6 +62,15 @@ var nestedDropZoneStyle = css({
62
62
  width: 'unset'
63
63
  });
64
64
  var enableDropZone = ['paragraph', 'mediaSingle', 'heading', 'codeBlock', 'decisionList', 'bulletList', 'orderedList', 'taskList', 'extension', 'blockCard'];
65
+ var enableDropZoneNext = ['paragraph', 'mediaSingle', 'heading', 'codeBlock', 'decisionList', 'bulletList', 'orderedList', 'taskList', 'extension', 'blockCard', 'syncBlock'];
66
+ var getEnableDropZone = function getEnableDropZone() {
67
+ if (editorExperiment('platform_synced_block_patch_6', true, {
68
+ exposure: true
69
+ })) {
70
+ return enableDropZoneNext;
71
+ }
72
+ return enableDropZone;
73
+ };
65
74
 
66
75
  // This z index is used in container like layout
67
76
  var fullHeightStyleAdjustZIndexStyle = css({
@@ -96,12 +105,13 @@ var HoverZone = function HoverZone(_ref) {
96
105
  _useActiveAnchorTrack2 = _slicedToArray(_useActiveAnchorTrack, 2),
97
106
  _isActive = _useActiveAnchorTrack2[0],
98
107
  setActiveAnchor = _useActiveAnchorTrack2[1];
108
+ var isInsideBodiedSyncBlock = parent && parent.type.name === 'bodiedSyncBlock' && expValEquals('platform_synced_block', 'isEnabled', true) && expValEquals('platform_synced_block_patch_6', 'isEnabled', true);
99
109
  useEffect(function () {
100
110
  if (ref.current) {
101
111
  return dropTargetForElements({
102
112
  element: ref.current,
103
113
  onDragEnter: function onDragEnter() {
104
- if (!isNestedDropTarget && editorExperiment('advanced_layouts', true)) {
114
+ if ((!isNestedDropTarget || isInsideBodiedSyncBlock) && editorExperiment('advanced_layouts', true)) {
105
115
  setActiveAnchor();
106
116
  }
107
117
  _onDragEnter();
@@ -110,11 +120,11 @@ var HoverZone = function HoverZone(_ref) {
110
120
  onDrop: onDrop
111
121
  });
112
122
  }
113
- }, [isNestedDropTarget, _onDragEnter, onDragLeave, onDrop, setActiveAnchor]);
123
+ }, [isNestedDropTarget, isInsideBodiedSyncBlock, _onDragEnter, onDragLeave, onDrop, setActiveAnchor]);
114
124
  var hoverZoneUpperStyle = useMemo(function () {
115
125
  var heightStyleOffset = "var(--editor-block-controls-drop-indicator-gap, 0)/2";
116
126
  var transformOffset = "var(".concat(EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_OFFSET, ", 0)");
117
- var heightStyle = anchorName && enableDropZone.includes((node === null || node === void 0 ? void 0 : node.type.name) || '') ? isAnchorSupported() ? "calc(anchor-size(".concat(anchorName, " height)/2 + ").concat(heightStyleOffset, ")") : "calc(".concat(((anchorRectCache === null || anchorRectCache === void 0 ? void 0 : anchorRectCache.getHeight(anchorName)) || 0) / 2, "px + ").concat(heightStyleOffset, ")") : '4px';
127
+ var heightStyle = anchorName && getEnableDropZone().includes((node === null || node === void 0 ? void 0 : node.type.name) || '') ? isAnchorSupported() ? "calc(anchor-size(".concat(anchorName, " height)/2 + ").concat(heightStyleOffset, ")") : "calc(".concat(((anchorRectCache === null || anchorRectCache === void 0 ? void 0 : anchorRectCache.getHeight(anchorName)) || 0) / 2, "px + ").concat(heightStyleOffset, ")") : '4px';
118
128
  var transform = position === 'upper' ? "translateY(calc(-100% + ".concat(transformOffset, "))") : "translateY(".concat(transformOffset, ")");
119
129
  return css({
120
130
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values
@@ -139,7 +149,7 @@ var HoverZone = function HoverZone(_ref) {
139
149
  var _anchorName = node ? expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? (api === null || api === void 0 ? void 0 : api.core.actions.getAnchorIdForNode(node, pos || -1)) || '' : getNodeAnchor(node) : '';
140
150
  var top = 'unset';
141
151
  if (_anchorName) {
142
- var enabledDropZone = enableDropZone.includes((node === null || node === void 0 ? void 0 : node.type.name) || '');
152
+ var enabledDropZone = getEnableDropZone().includes((node === null || node === void 0 ? void 0 : node.type.name) || '');
143
153
  if (isAnchorSupported()) {
144
154
  top = enabledDropZone ? "calc(anchor(".concat(_anchorName, " 50%))") : "calc(anchor(".concat(_anchorName, " bottom) - 4px)");
145
155
  } else if (anchorRectCache) {
@@ -221,6 +231,7 @@ export var DropTarget = function DropTarget(props) {
221
231
  var dynamicStyle = _defineProperty(_defineProperty(_defineProperty({
222
232
  width: isNestedDropTarget ? 'unset' : '100%'
223
233
  }, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH, isNestedDropTarget ? '100%' : "".concat(lineLength || DEFAULT_DROP_INDICATOR_WIDTH, "px")), EDITOR_BLOCK_CONTROLS_DROP_TARGET_LEFT_MARGIN, isNestedDropTarget ? getNestedNodeLeftPaddingMargin(parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name) : '0'), EDITOR_BLOCK_CONTROLS_DROP_TARGET_ZINDEX, layers.navigation());
234
+ var isShowInlineDropTarget = shouldAllowInlineDropTarget(isNestedDropTarget, nextNode, isSameLayout, activeNode, parentNode);
224
235
  return jsx(Fragment, null, jsx(HoverZone, {
225
236
  onDragEnter: function onDragEnter() {
226
237
  return setIsDraggedOver(true);
@@ -265,7 +276,7 @@ export var DropTarget = function DropTarget(props) {
265
276
  position: "lower",
266
277
  isNestedDropTarget: isNestedDropTarget,
267
278
  api: api
268
- }), shouldAllowInlineDropTarget(isNestedDropTarget, nextNode, isSameLayout, activeNode) && jsx(Fragment, null, jsx(InlineDropTarget
279
+ }), isShowInlineDropTarget && jsx(Fragment, null, jsx(InlineDropTarget
269
280
  // Ignored via go/ees005
270
281
  // eslint-disable-next-line react/jsx-props-no-spreading
271
282
  , _extends({}, props, {
@@ -4,4 +4,4 @@ export declare const shouldAllowInlineDropTarget: (isNested: boolean, node?: PMN
4
4
  /**
5
5
  * Is the active node in the same layout as the target node
6
6
  */
7
- isSameLayout?: boolean, activeNode?: ActiveNode) => boolean;
7
+ isSameLayout?: boolean, activeNode?: ActiveNode, parentNode?: PMNode) => boolean;
@@ -4,4 +4,4 @@ export declare const shouldAllowInlineDropTarget: (isNested: boolean, node?: PMN
4
4
  /**
5
5
  * Is the active node in the same layout as the target node
6
6
  */
7
- isSameLayout?: boolean, activeNode?: ActiveNode) => boolean;
7
+ isSameLayout?: boolean, activeNode?: ActiveNode, parentNode?: PMNode) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "8.11.0",
3
+ "version": "9.0.0",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -30,20 +30,20 @@
30
30
  "dependencies": {
31
31
  "@atlaskit/browser-apis": "^0.0.1",
32
32
  "@atlaskit/button": "^23.10.0",
33
- "@atlaskit/editor-plugin-accessibility-utils": "^7.0.0",
34
- "@atlaskit/editor-plugin-analytics": "^7.0.0",
35
- "@atlaskit/editor-plugin-editor-disabled": "^7.0.0",
36
- "@atlaskit/editor-plugin-editor-viewmode": "^9.0.0",
37
- "@atlaskit/editor-plugin-feature-flags": "^6.0.0",
38
- "@atlaskit/editor-plugin-interaction": "^14.0.0",
39
- "@atlaskit/editor-plugin-limited-mode": "^4.0.0",
40
- "@atlaskit/editor-plugin-metrics": "^8.0.0",
41
- "@atlaskit/editor-plugin-quick-insert": "^7.5.0",
42
- "@atlaskit/editor-plugin-selection": "^7.0.0",
43
- "@atlaskit/editor-plugin-toolbar": "^4.1.0",
44
- "@atlaskit/editor-plugin-type-ahead": "^7.0.0",
45
- "@atlaskit/editor-plugin-user-intent": "^5.0.0",
46
- "@atlaskit/editor-plugin-width": "^8.1.0",
33
+ "@atlaskit/editor-plugin-accessibility-utils": "^8.0.0",
34
+ "@atlaskit/editor-plugin-analytics": "^8.0.0",
35
+ "@atlaskit/editor-plugin-editor-disabled": "^8.0.0",
36
+ "@atlaskit/editor-plugin-editor-viewmode": "^10.0.0",
37
+ "@atlaskit/editor-plugin-feature-flags": "^7.0.0",
38
+ "@atlaskit/editor-plugin-interaction": "^15.0.0",
39
+ "@atlaskit/editor-plugin-limited-mode": "^5.0.0",
40
+ "@atlaskit/editor-plugin-metrics": "^9.0.0",
41
+ "@atlaskit/editor-plugin-quick-insert": "^8.0.0",
42
+ "@atlaskit/editor-plugin-selection": "^8.0.0",
43
+ "@atlaskit/editor-plugin-toolbar": "^5.0.0",
44
+ "@atlaskit/editor-plugin-type-ahead": "^8.0.0",
45
+ "@atlaskit/editor-plugin-user-intent": "^6.0.0",
46
+ "@atlaskit/editor-plugin-width": "^9.0.0",
47
47
  "@atlaskit/editor-prosemirror": "^7.3.0",
48
48
  "@atlaskit/editor-shared-styles": "^3.10.0",
49
49
  "@atlaskit/editor-tables": "^2.9.0",
@@ -56,8 +56,8 @@
56
56
  "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^3.2.0",
57
57
  "@atlaskit/primitives": "^18.0.0",
58
58
  "@atlaskit/theme": "^22.0.0",
59
- "@atlaskit/tmp-editor-statsig": "^35.4.0",
60
- "@atlaskit/tokens": "^11.0.0",
59
+ "@atlaskit/tmp-editor-statsig": "^35.10.0",
60
+ "@atlaskit/tokens": "^11.1.0",
61
61
  "@atlaskit/tooltip": "^20.14.0",
62
62
  "@babel/runtime": "^7.0.0",
63
63
  "@emotion/react": "^11.7.1",
@@ -67,7 +67,7 @@
67
67
  "uuid": "^3.1.0"
68
68
  },
69
69
  "peerDependencies": {
70
- "@atlaskit/editor-common": "^111.31.0",
70
+ "@atlaskit/editor-common": "^112.0.0",
71
71
  "react": "^18.2.0",
72
72
  "react-dom": "^18.2.0",
73
73
  "react-intl-next": "npm:react-intl@^5.18.1"