@atlaskit/editor-plugin-block-controls 31.1.17 → 31.1.19

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
+ ## 31.1.19
4
+
5
+ ### Patch Changes
6
+
7
+ - [`e2b5df4f05fe3`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e2b5df4f05fe3) -
8
+ Cleanup experiment `platform_editor_block_controls_perf_optimization`. The experiment shipped with
9
+ `isEnabled: true` to all tenants. Test overrides and config definitions removed from
10
+ `tmp-editor-statsig`. No behaviour change.
11
+ - Updated dependencies
12
+
13
+ ## 31.1.18
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies
18
+
3
19
  ## 31.1.17
4
20
 
5
21
  ### Patch Changes
@@ -4,36 +4,19 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.findDropTargetDecs = exports.dropTargetDecorations = exports.createLayoutDropTargetDecoration = exports.createDropTargetDecoration = void 0;
7
+ exports.findDropTargetDecs = exports.createLayoutDropTargetDecoration = exports.createDropTargetDecoration = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
10
9
  var _react = require("react");
11
- var _memoizeOne = _interopRequireDefault(require("memoize-one"));
12
10
  var _uuid = require("uuid");
13
- var _selection = require("@atlaskit/editor-common/selection");
14
- var _utils = require("@atlaskit/editor-common/utils");
15
- var _nodeTypeUtils = require("@atlaskit/editor-common/utils/node-type-utils");
16
11
  var _view = require("@atlaskit/editor-prosemirror/view");
17
12
  var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
18
- var _editorExperiment = require("@atlaskit/tmp-editor-statsig/editor-experiment");
19
13
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
20
14
  var _consts = require("../ui/consts");
21
15
  var _dropTarget = require("../ui/drop-target");
22
16
  var _dropTargetLayout = require("../ui/drop-target-layout");
23
17
  var _decorationsCommon = require("./decorations-common");
24
- var _consts2 = require("./utils/consts");
25
- var _validation = require("./utils/validation");
26
18
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
27
19
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
28
- var IGNORE_NODES = ['tableCell', 'tableHeader', 'tableRow', 'layoutColumn', 'listItem', 'caption'];
29
- var PARENT_WITH_END_DROP_TARGET = ['tableCell', 'tableHeader', 'panel', 'layoutColumn', 'expand', 'nestedExpand', 'bodiedExtension'];
30
- var DISABLE_CHILD_DROP_TARGET = ['orderedList', 'bulletList'];
31
- var getParentTypesWithEndDropTarget = (0, _memoizeOne.default)(function () {
32
- return [].concat(PARENT_WITH_END_DROP_TARGET, (0, _toConsumableArray2.default)((0, _expValEquals.expValEquals)('confluence_native_tabs_experiment', 'isEnabled', true) ? ['multiBodiedExtension'] : []), ['bodiedSyncBlock']);
33
- });
34
- var shouldDescend = function shouldDescend(node) {
35
- return !['mediaSingle', 'paragraph', 'heading'].includes(node.type.name);
36
- };
37
20
  var getNodeMargins = function getNodeMargins(node) {
38
21
  if (!node) {
39
22
  return _consts.nodeMargins['default'];
@@ -169,123 +152,4 @@ var createLayoutDropTargetDecoration = exports.createLayoutDropTargetDecoration
169
152
  nodeViewPortalProviderAPI.remove(key);
170
153
  }
171
154
  });
172
- };
173
- var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetDecorations(newState, api, formatMessage, nodeViewPortalProviderAPI, activeNode, anchorRectCache, from, to) {
174
- var decs = [];
175
- var POS_END_OF_DOC = newState.doc.nodeSize - 2;
176
- var docFrom = from === undefined || from < 0 ? 0 : from;
177
- var docTo = to === undefined || to > POS_END_OF_DOC ? POS_END_OF_DOC : to;
178
- var activeNodePos = activeNode === null || activeNode === void 0 ? void 0 : activeNode.pos;
179
- var $activeNodePos = typeof activeNodePos === 'number' && newState.doc.resolve(activeNodePos);
180
- var activePMNode = $activeNodePos && $activeNodePos.nodeAfter;
181
- anchorRectCache === null || anchorRectCache === void 0 || anchorRectCache.clear();
182
- var prevNodeStack = [];
183
- var popNodeStack = function popNodeStack(depth) {
184
- var result;
185
- var toDepth = Math.max(depth, 0);
186
- while (prevNodeStack.length > toDepth) {
187
- result = prevNodeStack.pop();
188
- }
189
- return result;
190
- };
191
- var pushNodeStack = function pushNodeStack(node, depth) {
192
- popNodeStack(depth);
193
- prevNodeStack.push(node);
194
- };
195
- var isAdvancedLayoutsPreRelease2 = (0, _editorExperiment.editorExperiment)('advanced_layouts', true);
196
-
197
- // For deciding to show drop targets or not when multiple nodes are selected
198
- var selection = newState.selection;
199
- var _expandSelectionBound = (0, _selection.expandSelectionBounds)(selection.$anchor, selection.$head),
200
- expandedAnchor = _expandSelectionBound.$anchor,
201
- expandedHead = _expandSelectionBound.$head;
202
- var selectionFrom = Math.min(expandedAnchor.pos, expandedHead.pos);
203
- var selectionTo = Math.max(expandedAnchor.pos, expandedHead.pos);
204
- var handleInsideSelection = activeNodePos !== undefined && activeNodePos >= selectionFrom && activeNodePos <= selectionTo;
205
- var parentTypesWithEndDropTarget = getParentTypesWithEndDropTarget();
206
- newState.doc.nodesBetween(docFrom, docTo, function (node, pos, parent, index) {
207
- var depth = 0;
208
- // drop target deco at the end position
209
- var endPos;
210
- var $pos = newState.doc.resolve(pos);
211
- var isSameLayout = $activeNodePos && (0, _validation.isInSameLayout)($activeNodePos, $pos);
212
- depth = $pos.depth;
213
- if (isAdvancedLayoutsPreRelease2) {
214
- if ((activeNode === null || activeNode === void 0 ? void 0 : activeNode.pos) === pos && activeNode.nodeType !== 'layoutColumn') {
215
- return false;
216
- }
217
- if (node.type.name === 'layoutColumn' && (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'layoutSection' && index !== 0 && (
218
- // Not the first node
219
- (parent === null || parent === void 0 ? void 0 : parent.childCount) < (0, _consts2.maxLayoutColumnSupported)() || isSameLayout)) {
220
- // Add drop target for layout columns
221
- decs.push(createLayoutDropTargetDecoration(pos, {
222
- api: api,
223
- parent: parent,
224
- formatMessage: formatMessage
225
- }, nodeViewPortalProviderAPI, anchorRectCache));
226
- }
227
- }
228
- if (node.isInline || !parent || DISABLE_CHILD_DROP_TARGET.includes(parent.type.name)) {
229
- pushNodeStack(node, depth);
230
- return false;
231
- }
232
- if (IGNORE_NODES.includes(node.type.name)) {
233
- pushNodeStack(node, depth);
234
- return shouldDescend(node); //skip over, don't consider it a valid depth
235
- }
236
-
237
- // validate all the nodes in the selection instead of just the handle node
238
- var selectionSlice = newState.doc.slice(selectionFrom, selectionTo, false);
239
- var selectionSliceChildCount = selectionSlice.content.childCount;
240
- var canDropSingleNode = true;
241
- var canDropMultipleNodes = true;
242
-
243
- // when there is only one node in the slice, use the same logic as when multi select is not on
244
- if (selectionSliceChildCount > 1 && handleInsideSelection) {
245
- canDropMultipleNodes = (0, _validation.canMoveSliceToIndex)(selectionSlice, selectionFrom, selectionTo, parent, index, $pos);
246
- } else {
247
- canDropSingleNode = !!(activePMNode && (0, _validation.canMoveNodeToIndex)(parent, index, activePMNode, $pos, node));
248
- }
249
- if (!canDropMultipleNodes || !canDropSingleNode) {
250
- pushNodeStack(node, depth);
251
- return false; //not valid pos, so nested not valid either
252
- }
253
- var parentTypeName = (0, _expValEquals.expValEquals)('platform_editor_nest_table_in_panel', 'isEnabled', true) ? (0, _nodeTypeUtils.getBaseNodeTypeName)(parent.type) : parent.type.name;
254
- if (parent.lastChild === node && !(0, _utils.isEmptyParagraph)(node) && parentTypesWithEndDropTarget.includes(parentTypeName)) {
255
- endPos = pos + node.nodeSize;
256
- }
257
- var previousNode = popNodeStack(depth); // created scoped variable
258
-
259
- // only table and layout need to render full height drop target
260
- var isInSupportedContainer = ['tableCell', 'tableHeader', 'layoutColumn'].includes((parent === null || parent === void 0 ? void 0 : parent.type.name) || '');
261
- var shouldShowFullHeight = isInSupportedContainer && (parent === null || parent === void 0 ? void 0 : parent.lastChild) === node && (0, _utils.isEmptyParagraph)(node);
262
- decs.push(createDropTargetDecoration(pos, {
263
- api: api,
264
- prevNode: previousNode,
265
- nextNode: node,
266
- parentNode: parent || undefined,
267
- formatMessage: formatMessage,
268
- dropTargetStyle: shouldShowFullHeight ? 'remainingHeight' : 'default'
269
- }, nodeViewPortalProviderAPI, -1, anchorRectCache, isSameLayout));
270
- if (endPos !== undefined) {
271
- decs.push(createDropTargetDecoration(endPos, {
272
- api: api,
273
- prevNode: node,
274
- parentNode: parent || undefined,
275
- formatMessage: formatMessage,
276
- dropTargetStyle: 'remainingHeight'
277
- }, nodeViewPortalProviderAPI, -1, anchorRectCache));
278
- }
279
- pushNodeStack(node, depth);
280
- return depth < _decorationsCommon.NESTED_DEPTH && shouldDescend(node);
281
- });
282
- if (docTo === POS_END_OF_DOC) {
283
- decs.push(createDropTargetDecoration(POS_END_OF_DOC, {
284
- api: api,
285
- formatMessage: formatMessage,
286
- prevNode: newState.doc.lastChild || undefined,
287
- parentNode: newState.doc
288
- }, nodeViewPortalProviderAPI, undefined, anchorRectCache));
289
- }
290
- return decs;
291
155
  };
@@ -372,7 +372,7 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
372
372
  multiSelectDnD = (_meta$multiSelectDnD = meta === null || meta === void 0 ? void 0 : meta.multiSelectDnD) !== null && _meta$multiSelectDnD !== void 0 ? _meta$multiSelectDnD : multiSelectDnD;
373
373
  if (multiSelectDnD) {
374
374
  var _meta$isDragging;
375
- if (((_meta$isDragging = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging !== void 0 ? _meta$isDragging : isDragging) && (0, _expValEquals.expValEquals)('platform_editor_block_controls_perf_optimization', 'isEnabled', true)) {
375
+ if ((_meta$isDragging = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging !== void 0 ? _meta$isDragging : isDragging) {
376
376
  // When dragging, we want to keep the multiSelectDnD object unless both document and selection
377
377
  // has changed, in which case we want to reset it.
378
378
  var shouldResetMultiSelectDnD = tr.docChanged && tr.selectionSet && tr.selection.empty;
@@ -814,28 +814,22 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
814
814
  }
815
815
  var currentActiveDropTargetNode = isDragging ? currentState.activeDropTargetNode : undefined;
816
816
  if (api) {
817
- if ((0, _expValEquals.expValEquals)('platform_editor_block_controls_perf_optimization', 'isEnabled', true)) {
818
- // If page is updated while dragging (likely by remote updates), we simply remove the drop targets
819
- // and add them back when the user interacts with the editor again
820
- if (isDropTargetsMissing) {
821
- var oldDropTargetDecs = (0, _decorationsDropTarget.findDropTargetDecs)(decorations);
822
- decorations = decorations.remove(oldDropTargetDecs);
823
- }
824
- if (meta !== null && meta !== void 0 && meta.activeDropTargetNode) {
825
- currentActiveDropTargetNode = meta === null || meta === void 0 ? void 0 : meta.activeDropTargetNode;
826
- var _oldDropTargetDecs = (0, _decorationsDropTarget.findDropTargetDecs)(decorations);
827
- var _getActiveDropTargetD = (0, _decorationsDropTargetActive.getActiveDropTargetDecorations)(meta.activeDropTargetNode, newState, api, _oldDropTargetDecs, formatMessage, nodeViewPortalProviderAPI, latestActiveNode, anchorRectCache),
828
- decsToAdd = _getActiveDropTargetD.decsToAdd,
829
- decsToRemove = _getActiveDropTargetD.decsToRemove;
830
- decorations = decorations.remove(decsToRemove);
831
- if (decsToAdd.length > 0) {
832
- decorations = decorations.add(newState.doc, decsToAdd);
833
- }
817
+ // If page is updated while dragging (likely by remote updates), we simply remove the drop targets
818
+ // and add them back when the user interacts with the editor again
819
+ if (isDropTargetsMissing) {
820
+ var oldDropTargetDecs = (0, _decorationsDropTarget.findDropTargetDecs)(decorations);
821
+ decorations = decorations.remove(oldDropTargetDecs);
822
+ }
823
+ if (meta !== null && meta !== void 0 && meta.activeDropTargetNode) {
824
+ currentActiveDropTargetNode = meta === null || meta === void 0 ? void 0 : meta.activeDropTargetNode;
825
+ var _oldDropTargetDecs = (0, _decorationsDropTarget.findDropTargetDecs)(decorations);
826
+ var _getActiveDropTargetD = (0, _decorationsDropTargetActive.getActiveDropTargetDecorations)(meta.activeDropTargetNode, newState, api, _oldDropTargetDecs, formatMessage, nodeViewPortalProviderAPI, latestActiveNode, anchorRectCache),
827
+ decsToAdd = _getActiveDropTargetD.decsToAdd,
828
+ decsToRemove = _getActiveDropTargetD.decsToRemove;
829
+ decorations = decorations.remove(decsToRemove);
830
+ if (decsToAdd.length > 0) {
831
+ decorations = decorations.add(newState.doc, decsToAdd);
834
832
  }
835
- } else if (meta !== null && meta !== void 0 && meta.isDragging || isDropTargetsMissing) {
836
- // Add drop targets when dragging starts or some are missing
837
- var decs = (0, _decorationsDropTarget.dropTargetDecorations)(newState, api, formatMessage, nodeViewPortalProviderAPI, latestActiveNode, anchorRectCache);
838
- decorations = decorations.add(newState.doc, decs);
839
833
  }
840
834
  }
841
835
  var isEmptyDoc = (0, _utils.isEmptyDocument)(newState.doc);
@@ -1063,7 +1057,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
1063
1057
  if (!((_key$getState3 = key.getState(view.state)) !== null && _key$getState3 !== void 0 && _key$getState3.isDragging)) {
1064
1058
  return;
1065
1059
  }
1066
- if (isHTMLElement(event.target) && (0, _expValEquals.expValEquals)('platform_editor_block_controls_perf_optimization', 'isEnabled', true)) {
1060
+ if (isHTMLElement(event.target)) {
1067
1061
  var targetElement = event.target.closest('[data-prosemirror-node-name]');
1068
1062
  if (targetElement) {
1069
1063
  var _api$blockControls$sh;
@@ -1080,30 +1074,17 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
1080
1074
  }));
1081
1075
  }
1082
1076
  }
1083
- } else if (isAdvancedLayoutEnabled) {
1084
- if (isHTMLElement(event.target)) {
1085
- var closestParentElement = event.target.closest('[data-drag-handler-anchor-depth="0"]');
1086
- if (closestParentElement) {
1087
- var currentAnchor = closestParentElement.getAttribute((0, _domAttrName.getAnchorAttrName)());
1088
- if (currentAnchor) {
1089
- _activeAnchorTracker.defaultActiveAnchorTracker.emit(currentAnchor);
1090
- }
1091
- }
1092
- }
1093
1077
  }
1094
1078
  },
1095
1079
  dragstart: function dragstart(view) {
1096
- var _api$limitedMode6, _anchorRectCache2;
1080
+ var _api$limitedMode6, _anchorRectCache, _anchorRectCache2;
1097
1081
  if (api !== null && api !== void 0 && (_api$limitedMode6 = api.limitedMode) !== null && _api$limitedMode6 !== void 0 && (_api$limitedMode6 = _api$limitedMode6.sharedState.currentState()) !== null && _api$limitedMode6 !== void 0 && _api$limitedMode6.enabled) {
1098
1082
  return;
1099
1083
  }
1100
1084
  if (isAdvancedLayoutEnabled) {
1101
1085
  _activeAnchorTracker.defaultActiveAnchorTracker.reset();
1102
1086
  }
1103
- if ((0, _expValEquals.expValEquals)('platform_editor_block_controls_perf_optimization', 'isEnabled', true)) {
1104
- var _anchorRectCache;
1105
- (_anchorRectCache = anchorRectCache) === null || _anchorRectCache === void 0 || _anchorRectCache.clear();
1106
- }
1087
+ (_anchorRectCache = anchorRectCache) === null || _anchorRectCache === void 0 || _anchorRectCache.clear();
1107
1088
  (_anchorRectCache2 = anchorRectCache) === null || _anchorRectCache2 === void 0 || _anchorRectCache2.setEditorView(view);
1108
1089
  view.dispatch(view.state.tr.setMeta(key, _objectSpread(_objectSpread({}, view.state.tr.getMeta(key)), {}, {
1109
1090
  isPMDragging: true
@@ -22,11 +22,9 @@ var getBlockControlsSurfaceDragHandleComponents = exports.getBlockControlsSurfac
22
22
  surfaceContext: surfaceContext
23
23
  });
24
24
  },
25
- isHidden: function isHidden() {
26
- var _api$editorViewMode;
27
- var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
28
- surfaceContext = _ref3.surfaceContext;
29
- var context = surfaceContext === null || surfaceContext === void 0 ? void 0 : surfaceContext.get(_blockControlUiContext.BLOCK_CONTROL_UI_CONTEXT);
25
+ isHidden: function isHidden(ctx) {
26
+ var _ctx$surfaceContext, _api$editorViewMode;
27
+ var context = ctx === null || ctx === void 0 || (_ctx$surfaceContext = ctx.surfaceContext) === null || _ctx$surfaceContext === void 0 ? void 0 : _ctx$surfaceContext.get(_blockControlUiContext.BLOCK_CONTROL_UI_CONTEXT);
30
28
  return (api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 || (_api$editorViewMode = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.mode) === 'view' || !(context !== null && context !== void 0 && context.activeNode) || context.targetNode.pos !== context.activeNode.pos || context.activeControlKey !== undefined && context.activeControlKey !== _surfaceKeys.BLOCK_CONTROLS_DRAG_HANDLE.key;
31
29
  }
32
30
  }, _surfaceKeys.BLOCK_CONTROLS_DRAG_HANDLE), {}, {
@@ -496,7 +496,7 @@ var GlobalStylesWrapper = exports.GlobalStylesWrapper = function GlobalStylesWra
496
496
  }),
497
497
  isDraggingFromState = _useSharedPluginState.isDragging;
498
498
  var sparseSurfacesEnabled = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration');
499
- var isDragging = sparseSurfacesEnabled || (0, _expValEquals.expValEquals)('platform_editor_block_controls_perf_optimization', 'isEnabled', true) ? isDraggingFromState : false;
499
+ var isDragging = isDraggingFromState;
500
500
  var shouldRenderAnchors = (0, _nativeAnchor.isCSSAnchorSupported)() && (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true);
501
501
  var sparseSurfaceAnchorsEnabled = Boolean((0, _nativeAnchor.isCSSAnchorSupported)()) && sparseSurfacesEnabled;
502
502
  var toolbarFlagsEnabled = (0, _toolbarFlagCheck.areToolbarFlagsEnabled)(Boolean(api === null || api === void 0 ? void 0 : api.toolbar));
@@ -1,27 +1,14 @@
1
1
  import { createElement } from 'react';
2
- import memoizeOne from 'memoize-one';
2
+
3
3
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
4
4
  import { v4 as uuid } from 'uuid';
5
- import { expandSelectionBounds } from '@atlaskit/editor-common/selection';
6
- import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
7
- import { getBaseNodeTypeName } from '@atlaskit/editor-common/utils/node-type-utils';
8
5
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
9
6
  import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
10
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
11
7
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
12
8
  import { nodeMargins } from '../ui/consts';
13
9
  import { DropTarget, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_GAP, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_OFFSET } from '../ui/drop-target';
14
10
  import { DropTargetLayout, DropTargetLayoutNativeAnchorSupport } from '../ui/drop-target-layout';
15
- import { NESTED_DEPTH, TYPE_DROP_TARGET_DEC } from './decorations-common';
16
- import { maxLayoutColumnSupported } from './utils/consts';
17
- import { canMoveNodeToIndex, canMoveSliceToIndex, isInSameLayout } from './utils/validation';
18
- const IGNORE_NODES = ['tableCell', 'tableHeader', 'tableRow', 'layoutColumn', 'listItem', 'caption'];
19
- const PARENT_WITH_END_DROP_TARGET = ['tableCell', 'tableHeader', 'panel', 'layoutColumn', 'expand', 'nestedExpand', 'bodiedExtension'];
20
- const DISABLE_CHILD_DROP_TARGET = ['orderedList', 'bulletList'];
21
- const getParentTypesWithEndDropTarget = memoizeOne(() => [...PARENT_WITH_END_DROP_TARGET, ...(expValEquals('confluence_native_tabs_experiment', 'isEnabled', true) ? ['multiBodiedExtension'] : []), 'bodiedSyncBlock']);
22
- const shouldDescend = node => {
23
- return !['mediaSingle', 'paragraph', 'heading'].includes(node.type.name);
24
- };
11
+ import { TYPE_DROP_TARGET_DEC } from './decorations-common';
25
12
  const getNodeMargins = node => {
26
13
  if (!node) {
27
14
  return nodeMargins['default'];
@@ -154,124 +141,4 @@ export const createLayoutDropTargetDecoration = (pos, props, nodeViewPortalProvi
154
141
  nodeViewPortalProviderAPI.remove(key);
155
142
  }
156
143
  });
157
- };
158
- export const dropTargetDecorations = (newState, api, formatMessage, nodeViewPortalProviderAPI, activeNode, anchorRectCache, from, to) => {
159
- const decs = [];
160
- const POS_END_OF_DOC = newState.doc.nodeSize - 2;
161
- const docFrom = from === undefined || from < 0 ? 0 : from;
162
- const docTo = to === undefined || to > POS_END_OF_DOC ? POS_END_OF_DOC : to;
163
- const activeNodePos = activeNode === null || activeNode === void 0 ? void 0 : activeNode.pos;
164
- const $activeNodePos = typeof activeNodePos === 'number' && newState.doc.resolve(activeNodePos);
165
- const activePMNode = $activeNodePos && $activeNodePos.nodeAfter;
166
- anchorRectCache === null || anchorRectCache === void 0 ? void 0 : anchorRectCache.clear();
167
- const prevNodeStack = [];
168
- const popNodeStack = depth => {
169
- let result;
170
- const toDepth = Math.max(depth, 0);
171
- while (prevNodeStack.length > toDepth) {
172
- result = prevNodeStack.pop();
173
- }
174
- return result;
175
- };
176
- const pushNodeStack = (node, depth) => {
177
- popNodeStack(depth);
178
- prevNodeStack.push(node);
179
- };
180
- const isAdvancedLayoutsPreRelease2 = editorExperiment('advanced_layouts', true);
181
-
182
- // For deciding to show drop targets or not when multiple nodes are selected
183
- const selection = newState.selection;
184
- const {
185
- $anchor: expandedAnchor,
186
- $head: expandedHead
187
- } = expandSelectionBounds(selection.$anchor, selection.$head);
188
- const selectionFrom = Math.min(expandedAnchor.pos, expandedHead.pos);
189
- const selectionTo = Math.max(expandedAnchor.pos, expandedHead.pos);
190
- const handleInsideSelection = activeNodePos !== undefined && activeNodePos >= selectionFrom && activeNodePos <= selectionTo;
191
- const parentTypesWithEndDropTarget = getParentTypesWithEndDropTarget();
192
- newState.doc.nodesBetween(docFrom, docTo, (node, pos, parent, index) => {
193
- let depth = 0;
194
- // drop target deco at the end position
195
- let endPos;
196
- const $pos = newState.doc.resolve(pos);
197
- const isSameLayout = $activeNodePos && isInSameLayout($activeNodePos, $pos);
198
- depth = $pos.depth;
199
- if (isAdvancedLayoutsPreRelease2) {
200
- if ((activeNode === null || activeNode === void 0 ? void 0 : activeNode.pos) === pos && activeNode.nodeType !== 'layoutColumn') {
201
- return false;
202
- }
203
- if (node.type.name === 'layoutColumn' && (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'layoutSection' && index !== 0 && (
204
- // Not the first node
205
- (parent === null || parent === void 0 ? void 0 : parent.childCount) < maxLayoutColumnSupported() || isSameLayout)) {
206
- // Add drop target for layout columns
207
- decs.push(createLayoutDropTargetDecoration(pos, {
208
- api,
209
- parent,
210
- formatMessage
211
- }, nodeViewPortalProviderAPI, anchorRectCache));
212
- }
213
- }
214
- if (node.isInline || !parent || DISABLE_CHILD_DROP_TARGET.includes(parent.type.name)) {
215
- pushNodeStack(node, depth);
216
- return false;
217
- }
218
- if (IGNORE_NODES.includes(node.type.name)) {
219
- pushNodeStack(node, depth);
220
- return shouldDescend(node); //skip over, don't consider it a valid depth
221
- }
222
-
223
- // validate all the nodes in the selection instead of just the handle node
224
- const selectionSlice = newState.doc.slice(selectionFrom, selectionTo, false);
225
- const selectionSliceChildCount = selectionSlice.content.childCount;
226
- let canDropSingleNode = true;
227
- let canDropMultipleNodes = true;
228
-
229
- // when there is only one node in the slice, use the same logic as when multi select is not on
230
- if (selectionSliceChildCount > 1 && handleInsideSelection) {
231
- canDropMultipleNodes = canMoveSliceToIndex(selectionSlice, selectionFrom, selectionTo, parent, index, $pos);
232
- } else {
233
- canDropSingleNode = !!(activePMNode && canMoveNodeToIndex(parent, index, activePMNode, $pos, node));
234
- }
235
- if (!canDropMultipleNodes || !canDropSingleNode) {
236
- pushNodeStack(node, depth);
237
- return false; //not valid pos, so nested not valid either
238
- }
239
- const parentTypeName = expValEquals('platform_editor_nest_table_in_panel', 'isEnabled', true) ? getBaseNodeTypeName(parent.type) : parent.type.name;
240
- if (parent.lastChild === node && !isEmptyParagraph(node) && parentTypesWithEndDropTarget.includes(parentTypeName)) {
241
- endPos = pos + node.nodeSize;
242
- }
243
- const previousNode = popNodeStack(depth); // created scoped variable
244
-
245
- // only table and layout need to render full height drop target
246
- const isInSupportedContainer = ['tableCell', 'tableHeader', 'layoutColumn'].includes((parent === null || parent === void 0 ? void 0 : parent.type.name) || '');
247
- const shouldShowFullHeight = isInSupportedContainer && (parent === null || parent === void 0 ? void 0 : parent.lastChild) === node && isEmptyParagraph(node);
248
- decs.push(createDropTargetDecoration(pos, {
249
- api,
250
- prevNode: previousNode,
251
- nextNode: node,
252
- parentNode: parent || undefined,
253
- formatMessage,
254
- dropTargetStyle: shouldShowFullHeight ? 'remainingHeight' : 'default'
255
- }, nodeViewPortalProviderAPI, -1, anchorRectCache, isSameLayout));
256
- if (endPos !== undefined) {
257
- decs.push(createDropTargetDecoration(endPos, {
258
- api,
259
- prevNode: node,
260
- parentNode: parent || undefined,
261
- formatMessage,
262
- dropTargetStyle: 'remainingHeight'
263
- }, nodeViewPortalProviderAPI, -1, anchorRectCache));
264
- }
265
- pushNodeStack(node, depth);
266
- return depth < NESTED_DEPTH && shouldDescend(node);
267
- });
268
- if (docTo === POS_END_OF_DOC) {
269
- decs.push(createDropTargetDecoration(POS_END_OF_DOC, {
270
- api,
271
- formatMessage,
272
- prevNode: newState.doc.lastChild || undefined,
273
- parentNode: newState.doc
274
- }, nodeViewPortalProviderAPI, undefined, anchorRectCache));
275
- }
276
- return decs;
277
144
  };
@@ -24,7 +24,7 @@ import { getAnchorAttrName } from '../ui/utils/dom-attr-name';
24
24
  import { findNodeDecs, nodeDecorations } from './decorations-anchor';
25
25
  import { getNodeTypeWithLevel } from './decorations-common';
26
26
  import { createActiveDragHandleNodeDecoration, dragHandleDecoration, emptyParagraphNodeDecorations, findActiveDragHandleNodeDec, findHandleDec, TYPE_ACTIVE_HANDLE_DEC } from './decorations-drag-handle';
27
- import { dropTargetDecorations, findDropTargetDecs } from './decorations-drop-target';
27
+ import { findDropTargetDecs } from './decorations-drop-target';
28
28
  import { getActiveDropTargetDecorations } from './decorations-drop-target-active';
29
29
  import { createActiveQuickInsertNodeDecoration, findActiveQuickInsertNodeDec, findQuickInsertInsertButtonDecoration, quickInsertButtonDecoration, TYPE_ACTIVE_QUICK_INSERT_NODE } from './decorations-quick-insert-button';
30
30
  import { handleMouseDown } from './handle-mouse-down';
@@ -365,7 +365,7 @@ export const apply = (api, formatMessage, tr, currentState, newState, flags, nod
365
365
  multiSelectDnD = (_meta$multiSelectDnD = meta === null || meta === void 0 ? void 0 : meta.multiSelectDnD) !== null && _meta$multiSelectDnD !== void 0 ? _meta$multiSelectDnD : multiSelectDnD;
366
366
  if (multiSelectDnD) {
367
367
  var _meta$isDragging;
368
- if (((_meta$isDragging = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging !== void 0 ? _meta$isDragging : isDragging) && expValEquals('platform_editor_block_controls_perf_optimization', 'isEnabled', true)) {
368
+ if ((_meta$isDragging = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging !== void 0 ? _meta$isDragging : isDragging) {
369
369
  // When dragging, we want to keep the multiSelectDnD object unless both document and selection
370
370
  // has changed, in which case we want to reset it.
371
371
  const shouldResetMultiSelectDnD = tr.docChanged && tr.selectionSet && tr.selection.empty;
@@ -715,29 +715,23 @@ export const apply = (api, formatMessage, tr, currentState, newState, flags, nod
715
715
  }
716
716
  let currentActiveDropTargetNode = isDragging ? currentState.activeDropTargetNode : undefined;
717
717
  if (api) {
718
- if (expValEquals('platform_editor_block_controls_perf_optimization', 'isEnabled', true)) {
719
- // If page is updated while dragging (likely by remote updates), we simply remove the drop targets
720
- // and add them back when the user interacts with the editor again
721
- if (isDropTargetsMissing) {
722
- const oldDropTargetDecs = findDropTargetDecs(decorations);
723
- decorations = decorations.remove(oldDropTargetDecs);
724
- }
725
- if (meta !== null && meta !== void 0 && meta.activeDropTargetNode) {
726
- currentActiveDropTargetNode = meta === null || meta === void 0 ? void 0 : meta.activeDropTargetNode;
727
- const oldDropTargetDecs = findDropTargetDecs(decorations);
728
- const {
729
- decsToAdd,
730
- decsToRemove
731
- } = getActiveDropTargetDecorations(meta.activeDropTargetNode, newState, api, oldDropTargetDecs, formatMessage, nodeViewPortalProviderAPI, latestActiveNode, anchorRectCache);
732
- decorations = decorations.remove(decsToRemove);
733
- if (decsToAdd.length > 0) {
734
- decorations = decorations.add(newState.doc, decsToAdd);
735
- }
718
+ // If page is updated while dragging (likely by remote updates), we simply remove the drop targets
719
+ // and add them back when the user interacts with the editor again
720
+ if (isDropTargetsMissing) {
721
+ const oldDropTargetDecs = findDropTargetDecs(decorations);
722
+ decorations = decorations.remove(oldDropTargetDecs);
723
+ }
724
+ if (meta !== null && meta !== void 0 && meta.activeDropTargetNode) {
725
+ currentActiveDropTargetNode = meta === null || meta === void 0 ? void 0 : meta.activeDropTargetNode;
726
+ const oldDropTargetDecs = findDropTargetDecs(decorations);
727
+ const {
728
+ decsToAdd,
729
+ decsToRemove
730
+ } = getActiveDropTargetDecorations(meta.activeDropTargetNode, newState, api, oldDropTargetDecs, formatMessage, nodeViewPortalProviderAPI, latestActiveNode, anchorRectCache);
731
+ decorations = decorations.remove(decsToRemove);
732
+ if (decsToAdd.length > 0) {
733
+ decorations = decorations.add(newState.doc, decsToAdd);
736
734
  }
737
- } else if (meta !== null && meta !== void 0 && meta.isDragging || isDropTargetsMissing) {
738
- // Add drop targets when dragging starts or some are missing
739
- const decs = dropTargetDecorations(newState, api, formatMessage, nodeViewPortalProviderAPI, latestActiveNode, anchorRectCache);
740
- decorations = decorations.add(newState.doc, decs);
741
735
  }
742
736
  }
743
737
  const isEmptyDoc = isEmptyDocument(newState.doc);
@@ -966,7 +960,7 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI, nodeDecora
966
960
  if (!((_key$getState3 = key.getState(view.state)) !== null && _key$getState3 !== void 0 && _key$getState3.isDragging)) {
967
961
  return;
968
962
  }
969
- if (isHTMLElement(event.target) && expValEquals('platform_editor_block_controls_perf_optimization', 'isEnabled', true)) {
963
+ if (isHTMLElement(event.target)) {
970
964
  const targetElement = event.target.closest('[data-prosemirror-node-name]');
971
965
  if (targetElement) {
972
966
  var _api$blockControls$sh;
@@ -983,30 +977,17 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI, nodeDecora
983
977
  }));
984
978
  }
985
979
  }
986
- } else if (isAdvancedLayoutEnabled) {
987
- if (isHTMLElement(event.target)) {
988
- const closestParentElement = event.target.closest('[data-drag-handler-anchor-depth="0"]');
989
- if (closestParentElement) {
990
- const currentAnchor = closestParentElement.getAttribute(getAnchorAttrName());
991
- if (currentAnchor) {
992
- defaultActiveAnchorTracker.emit(currentAnchor);
993
- }
994
- }
995
- }
996
980
  }
997
981
  },
998
982
  dragstart(view) {
999
- var _api$limitedMode6, _api$limitedMode6$sha, _anchorRectCache2;
983
+ var _api$limitedMode6, _api$limitedMode6$sha, _anchorRectCache, _anchorRectCache2;
1000
984
  if (api !== null && api !== void 0 && (_api$limitedMode6 = api.limitedMode) !== null && _api$limitedMode6 !== void 0 && (_api$limitedMode6$sha = _api$limitedMode6.sharedState.currentState()) !== null && _api$limitedMode6$sha !== void 0 && _api$limitedMode6$sha.enabled) {
1001
985
  return;
1002
986
  }
1003
987
  if (isAdvancedLayoutEnabled) {
1004
988
  defaultActiveAnchorTracker.reset();
1005
989
  }
1006
- if (expValEquals('platform_editor_block_controls_perf_optimization', 'isEnabled', true)) {
1007
- var _anchorRectCache;
1008
- (_anchorRectCache = anchorRectCache) === null || _anchorRectCache === void 0 ? void 0 : _anchorRectCache.clear();
1009
- }
990
+ (_anchorRectCache = anchorRectCache) === null || _anchorRectCache === void 0 ? void 0 : _anchorRectCache.clear();
1010
991
  (_anchorRectCache2 = anchorRectCache) === null || _anchorRectCache2 === void 0 ? void 0 : _anchorRectCache2.setEditorView(view);
1011
992
  view.dispatch(view.state.tr.setMeta(key, {
1012
993
  ...view.state.tr.getMeta(key),
@@ -11,11 +11,9 @@ export const getBlockControlsSurfaceDragHandleComponents = ({
11
11
  api: api,
12
12
  surfaceContext: surfaceContext
13
13
  }),
14
- isHidden: ({
15
- surfaceContext
16
- } = {}) => {
17
- var _api$editorViewMode, _api$editorViewMode$s;
18
- const context = surfaceContext === null || surfaceContext === void 0 ? void 0 : surfaceContext.get(BLOCK_CONTROL_UI_CONTEXT);
14
+ isHidden: ctx => {
15
+ var _ctx$surfaceContext, _api$editorViewMode, _api$editorViewMode$s;
16
+ const context = ctx === null || ctx === void 0 ? void 0 : (_ctx$surfaceContext = ctx.surfaceContext) === null || _ctx$surfaceContext === void 0 ? void 0 : _ctx$surfaceContext.get(BLOCK_CONTROL_UI_CONTEXT);
19
17
  return (api === null || api === void 0 ? void 0 : (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 ? void 0 : (_api$editorViewMode$s = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode$s === void 0 ? void 0 : _api$editorViewMode$s.mode) === 'view' || !(context !== null && context !== void 0 && context.activeNode) || context.targetNode.pos !== context.activeNode.pos || context.activeControlKey !== undefined && context.activeControlKey !== BLOCK_CONTROLS_DRAG_HANDLE.key;
20
18
  },
21
19
  ...BLOCK_CONTROLS_DRAG_HANDLE,
@@ -584,7 +584,7 @@ export const GlobalStylesWrapper = ({
584
584
  };
585
585
  });
586
586
  const sparseSurfacesEnabled = isExperimentEnabled('platform_editor_block_control_migration');
587
- const isDragging = sparseSurfacesEnabled || expValEquals('platform_editor_block_controls_perf_optimization', 'isEnabled', true) ? isDraggingFromState : false;
587
+ const isDragging = isDraggingFromState;
588
588
  const shouldRenderAnchors = isCSSAnchorSupported() && expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true);
589
589
  const sparseSurfaceAnchorsEnabled = Boolean(isCSSAnchorSupported()) && sparseSurfacesEnabled;
590
590
  const toolbarFlagsEnabled = areToolbarFlagsEnabled(Boolean(api === null || api === void 0 ? void 0 : api.toolbar));
@@ -1,33 +1,17 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
3
2
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
3
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
4
  import { createElement } from 'react';
6
- import memoizeOne from 'memoize-one';
5
+
7
6
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
8
7
  import { v4 as uuid } from 'uuid';
9
- import { expandSelectionBounds } from '@atlaskit/editor-common/selection';
10
- import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
11
- import { getBaseNodeTypeName } from '@atlaskit/editor-common/utils/node-type-utils';
12
8
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
13
9
  import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
14
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
15
10
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
16
11
  import { nodeMargins } from '../ui/consts';
17
12
  import { DropTarget, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_GAP, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_OFFSET } from '../ui/drop-target';
18
13
  import { DropTargetLayout, DropTargetLayoutNativeAnchorSupport } from '../ui/drop-target-layout';
19
- import { NESTED_DEPTH, TYPE_DROP_TARGET_DEC } from './decorations-common';
20
- import { maxLayoutColumnSupported } from './utils/consts';
21
- import { canMoveNodeToIndex, canMoveSliceToIndex, isInSameLayout } from './utils/validation';
22
- var IGNORE_NODES = ['tableCell', 'tableHeader', 'tableRow', 'layoutColumn', 'listItem', 'caption'];
23
- var PARENT_WITH_END_DROP_TARGET = ['tableCell', 'tableHeader', 'panel', 'layoutColumn', 'expand', 'nestedExpand', 'bodiedExtension'];
24
- var DISABLE_CHILD_DROP_TARGET = ['orderedList', 'bulletList'];
25
- var getParentTypesWithEndDropTarget = memoizeOne(function () {
26
- return [].concat(PARENT_WITH_END_DROP_TARGET, _toConsumableArray(expValEquals('confluence_native_tabs_experiment', 'isEnabled', true) ? ['multiBodiedExtension'] : []), ['bodiedSyncBlock']);
27
- });
28
- var shouldDescend = function shouldDescend(node) {
29
- return !['mediaSingle', 'paragraph', 'heading'].includes(node.type.name);
30
- };
14
+ import { TYPE_DROP_TARGET_DEC } from './decorations-common';
31
15
  var getNodeMargins = function getNodeMargins(node) {
32
16
  if (!node) {
33
17
  return nodeMargins['default'];
@@ -163,123 +147,4 @@ export var createLayoutDropTargetDecoration = function createLayoutDropTargetDec
163
147
  nodeViewPortalProviderAPI.remove(key);
164
148
  }
165
149
  });
166
- };
167
- export var dropTargetDecorations = function dropTargetDecorations(newState, api, formatMessage, nodeViewPortalProviderAPI, activeNode, anchorRectCache, from, to) {
168
- var decs = [];
169
- var POS_END_OF_DOC = newState.doc.nodeSize - 2;
170
- var docFrom = from === undefined || from < 0 ? 0 : from;
171
- var docTo = to === undefined || to > POS_END_OF_DOC ? POS_END_OF_DOC : to;
172
- var activeNodePos = activeNode === null || activeNode === void 0 ? void 0 : activeNode.pos;
173
- var $activeNodePos = typeof activeNodePos === 'number' && newState.doc.resolve(activeNodePos);
174
- var activePMNode = $activeNodePos && $activeNodePos.nodeAfter;
175
- anchorRectCache === null || anchorRectCache === void 0 || anchorRectCache.clear();
176
- var prevNodeStack = [];
177
- var popNodeStack = function popNodeStack(depth) {
178
- var result;
179
- var toDepth = Math.max(depth, 0);
180
- while (prevNodeStack.length > toDepth) {
181
- result = prevNodeStack.pop();
182
- }
183
- return result;
184
- };
185
- var pushNodeStack = function pushNodeStack(node, depth) {
186
- popNodeStack(depth);
187
- prevNodeStack.push(node);
188
- };
189
- var isAdvancedLayoutsPreRelease2 = editorExperiment('advanced_layouts', true);
190
-
191
- // For deciding to show drop targets or not when multiple nodes are selected
192
- var selection = newState.selection;
193
- var _expandSelectionBound = expandSelectionBounds(selection.$anchor, selection.$head),
194
- expandedAnchor = _expandSelectionBound.$anchor,
195
- expandedHead = _expandSelectionBound.$head;
196
- var selectionFrom = Math.min(expandedAnchor.pos, expandedHead.pos);
197
- var selectionTo = Math.max(expandedAnchor.pos, expandedHead.pos);
198
- var handleInsideSelection = activeNodePos !== undefined && activeNodePos >= selectionFrom && activeNodePos <= selectionTo;
199
- var parentTypesWithEndDropTarget = getParentTypesWithEndDropTarget();
200
- newState.doc.nodesBetween(docFrom, docTo, function (node, pos, parent, index) {
201
- var depth = 0;
202
- // drop target deco at the end position
203
- var endPos;
204
- var $pos = newState.doc.resolve(pos);
205
- var isSameLayout = $activeNodePos && isInSameLayout($activeNodePos, $pos);
206
- depth = $pos.depth;
207
- if (isAdvancedLayoutsPreRelease2) {
208
- if ((activeNode === null || activeNode === void 0 ? void 0 : activeNode.pos) === pos && activeNode.nodeType !== 'layoutColumn') {
209
- return false;
210
- }
211
- if (node.type.name === 'layoutColumn' && (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'layoutSection' && index !== 0 && (
212
- // Not the first node
213
- (parent === null || parent === void 0 ? void 0 : parent.childCount) < maxLayoutColumnSupported() || isSameLayout)) {
214
- // Add drop target for layout columns
215
- decs.push(createLayoutDropTargetDecoration(pos, {
216
- api: api,
217
- parent: parent,
218
- formatMessage: formatMessage
219
- }, nodeViewPortalProviderAPI, anchorRectCache));
220
- }
221
- }
222
- if (node.isInline || !parent || DISABLE_CHILD_DROP_TARGET.includes(parent.type.name)) {
223
- pushNodeStack(node, depth);
224
- return false;
225
- }
226
- if (IGNORE_NODES.includes(node.type.name)) {
227
- pushNodeStack(node, depth);
228
- return shouldDescend(node); //skip over, don't consider it a valid depth
229
- }
230
-
231
- // validate all the nodes in the selection instead of just the handle node
232
- var selectionSlice = newState.doc.slice(selectionFrom, selectionTo, false);
233
- var selectionSliceChildCount = selectionSlice.content.childCount;
234
- var canDropSingleNode = true;
235
- var canDropMultipleNodes = true;
236
-
237
- // when there is only one node in the slice, use the same logic as when multi select is not on
238
- if (selectionSliceChildCount > 1 && handleInsideSelection) {
239
- canDropMultipleNodes = canMoveSliceToIndex(selectionSlice, selectionFrom, selectionTo, parent, index, $pos);
240
- } else {
241
- canDropSingleNode = !!(activePMNode && canMoveNodeToIndex(parent, index, activePMNode, $pos, node));
242
- }
243
- if (!canDropMultipleNodes || !canDropSingleNode) {
244
- pushNodeStack(node, depth);
245
- return false; //not valid pos, so nested not valid either
246
- }
247
- var parentTypeName = expValEquals('platform_editor_nest_table_in_panel', 'isEnabled', true) ? getBaseNodeTypeName(parent.type) : parent.type.name;
248
- if (parent.lastChild === node && !isEmptyParagraph(node) && parentTypesWithEndDropTarget.includes(parentTypeName)) {
249
- endPos = pos + node.nodeSize;
250
- }
251
- var previousNode = popNodeStack(depth); // created scoped variable
252
-
253
- // only table and layout need to render full height drop target
254
- var isInSupportedContainer = ['tableCell', 'tableHeader', 'layoutColumn'].includes((parent === null || parent === void 0 ? void 0 : parent.type.name) || '');
255
- var shouldShowFullHeight = isInSupportedContainer && (parent === null || parent === void 0 ? void 0 : parent.lastChild) === node && isEmptyParagraph(node);
256
- decs.push(createDropTargetDecoration(pos, {
257
- api: api,
258
- prevNode: previousNode,
259
- nextNode: node,
260
- parentNode: parent || undefined,
261
- formatMessage: formatMessage,
262
- dropTargetStyle: shouldShowFullHeight ? 'remainingHeight' : 'default'
263
- }, nodeViewPortalProviderAPI, -1, anchorRectCache, isSameLayout));
264
- if (endPos !== undefined) {
265
- decs.push(createDropTargetDecoration(endPos, {
266
- api: api,
267
- prevNode: node,
268
- parentNode: parent || undefined,
269
- formatMessage: formatMessage,
270
- dropTargetStyle: 'remainingHeight'
271
- }, nodeViewPortalProviderAPI, -1, anchorRectCache));
272
- }
273
- pushNodeStack(node, depth);
274
- return depth < NESTED_DEPTH && shouldDescend(node);
275
- });
276
- if (docTo === POS_END_OF_DOC) {
277
- decs.push(createDropTargetDecoration(POS_END_OF_DOC, {
278
- api: api,
279
- formatMessage: formatMessage,
280
- prevNode: newState.doc.lastChild || undefined,
281
- parentNode: newState.doc
282
- }, nodeViewPortalProviderAPI, undefined, anchorRectCache));
283
- }
284
- return decs;
285
150
  };
@@ -30,7 +30,7 @@ import { getAnchorAttrName } from '../ui/utils/dom-attr-name';
30
30
  import { findNodeDecs, nodeDecorations } from './decorations-anchor';
31
31
  import { getNodeTypeWithLevel } from './decorations-common';
32
32
  import { createActiveDragHandleNodeDecoration, dragHandleDecoration, emptyParagraphNodeDecorations, findActiveDragHandleNodeDec, findHandleDec, TYPE_ACTIVE_HANDLE_DEC } from './decorations-drag-handle';
33
- import { dropTargetDecorations, findDropTargetDecs } from './decorations-drop-target';
33
+ import { findDropTargetDecs } from './decorations-drop-target';
34
34
  import { getActiveDropTargetDecorations } from './decorations-drop-target-active';
35
35
  import { createActiveQuickInsertNodeDecoration, findActiveQuickInsertNodeDec, findQuickInsertInsertButtonDecoration, quickInsertButtonDecoration, TYPE_ACTIVE_QUICK_INSERT_NODE } from './decorations-quick-insert-button';
36
36
  import { handleMouseDown } from './handle-mouse-down';
@@ -365,7 +365,7 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
365
365
  multiSelectDnD = (_meta$multiSelectDnD = meta === null || meta === void 0 ? void 0 : meta.multiSelectDnD) !== null && _meta$multiSelectDnD !== void 0 ? _meta$multiSelectDnD : multiSelectDnD;
366
366
  if (multiSelectDnD) {
367
367
  var _meta$isDragging;
368
- if (((_meta$isDragging = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging !== void 0 ? _meta$isDragging : isDragging) && expValEquals('platform_editor_block_controls_perf_optimization', 'isEnabled', true)) {
368
+ if ((_meta$isDragging = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging !== void 0 ? _meta$isDragging : isDragging) {
369
369
  // When dragging, we want to keep the multiSelectDnD object unless both document and selection
370
370
  // has changed, in which case we want to reset it.
371
371
  var shouldResetMultiSelectDnD = tr.docChanged && tr.selectionSet && tr.selection.empty;
@@ -807,28 +807,22 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
807
807
  }
808
808
  var currentActiveDropTargetNode = isDragging ? currentState.activeDropTargetNode : undefined;
809
809
  if (api) {
810
- if (expValEquals('platform_editor_block_controls_perf_optimization', 'isEnabled', true)) {
811
- // If page is updated while dragging (likely by remote updates), we simply remove the drop targets
812
- // and add them back when the user interacts with the editor again
813
- if (isDropTargetsMissing) {
814
- var oldDropTargetDecs = findDropTargetDecs(decorations);
815
- decorations = decorations.remove(oldDropTargetDecs);
816
- }
817
- if (meta !== null && meta !== void 0 && meta.activeDropTargetNode) {
818
- currentActiveDropTargetNode = meta === null || meta === void 0 ? void 0 : meta.activeDropTargetNode;
819
- var _oldDropTargetDecs = findDropTargetDecs(decorations);
820
- var _getActiveDropTargetD = getActiveDropTargetDecorations(meta.activeDropTargetNode, newState, api, _oldDropTargetDecs, formatMessage, nodeViewPortalProviderAPI, latestActiveNode, anchorRectCache),
821
- decsToAdd = _getActiveDropTargetD.decsToAdd,
822
- decsToRemove = _getActiveDropTargetD.decsToRemove;
823
- decorations = decorations.remove(decsToRemove);
824
- if (decsToAdd.length > 0) {
825
- decorations = decorations.add(newState.doc, decsToAdd);
826
- }
810
+ // If page is updated while dragging (likely by remote updates), we simply remove the drop targets
811
+ // and add them back when the user interacts with the editor again
812
+ if (isDropTargetsMissing) {
813
+ var oldDropTargetDecs = findDropTargetDecs(decorations);
814
+ decorations = decorations.remove(oldDropTargetDecs);
815
+ }
816
+ if (meta !== null && meta !== void 0 && meta.activeDropTargetNode) {
817
+ currentActiveDropTargetNode = meta === null || meta === void 0 ? void 0 : meta.activeDropTargetNode;
818
+ var _oldDropTargetDecs = findDropTargetDecs(decorations);
819
+ var _getActiveDropTargetD = getActiveDropTargetDecorations(meta.activeDropTargetNode, newState, api, _oldDropTargetDecs, formatMessage, nodeViewPortalProviderAPI, latestActiveNode, anchorRectCache),
820
+ decsToAdd = _getActiveDropTargetD.decsToAdd,
821
+ decsToRemove = _getActiveDropTargetD.decsToRemove;
822
+ decorations = decorations.remove(decsToRemove);
823
+ if (decsToAdd.length > 0) {
824
+ decorations = decorations.add(newState.doc, decsToAdd);
827
825
  }
828
- } else if (meta !== null && meta !== void 0 && meta.isDragging || isDropTargetsMissing) {
829
- // Add drop targets when dragging starts or some are missing
830
- var decs = dropTargetDecorations(newState, api, formatMessage, nodeViewPortalProviderAPI, latestActiveNode, anchorRectCache);
831
- decorations = decorations.add(newState.doc, decs);
832
826
  }
833
827
  }
834
828
  var isEmptyDoc = isEmptyDocument(newState.doc);
@@ -1057,7 +1051,7 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
1057
1051
  if (!((_key$getState3 = key.getState(view.state)) !== null && _key$getState3 !== void 0 && _key$getState3.isDragging)) {
1058
1052
  return;
1059
1053
  }
1060
- if (isHTMLElement(event.target) && expValEquals('platform_editor_block_controls_perf_optimization', 'isEnabled', true)) {
1054
+ if (isHTMLElement(event.target)) {
1061
1055
  var targetElement = event.target.closest('[data-prosemirror-node-name]');
1062
1056
  if (targetElement) {
1063
1057
  var _api$blockControls$sh;
@@ -1074,30 +1068,17 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
1074
1068
  }));
1075
1069
  }
1076
1070
  }
1077
- } else if (isAdvancedLayoutEnabled) {
1078
- if (isHTMLElement(event.target)) {
1079
- var closestParentElement = event.target.closest('[data-drag-handler-anchor-depth="0"]');
1080
- if (closestParentElement) {
1081
- var currentAnchor = closestParentElement.getAttribute(getAnchorAttrName());
1082
- if (currentAnchor) {
1083
- defaultActiveAnchorTracker.emit(currentAnchor);
1084
- }
1085
- }
1086
- }
1087
1071
  }
1088
1072
  },
1089
1073
  dragstart: function dragstart(view) {
1090
- var _api$limitedMode6, _anchorRectCache2;
1074
+ var _api$limitedMode6, _anchorRectCache, _anchorRectCache2;
1091
1075
  if (api !== null && api !== void 0 && (_api$limitedMode6 = api.limitedMode) !== null && _api$limitedMode6 !== void 0 && (_api$limitedMode6 = _api$limitedMode6.sharedState.currentState()) !== null && _api$limitedMode6 !== void 0 && _api$limitedMode6.enabled) {
1092
1076
  return;
1093
1077
  }
1094
1078
  if (isAdvancedLayoutEnabled) {
1095
1079
  defaultActiveAnchorTracker.reset();
1096
1080
  }
1097
- if (expValEquals('platform_editor_block_controls_perf_optimization', 'isEnabled', true)) {
1098
- var _anchorRectCache;
1099
- (_anchorRectCache = anchorRectCache) === null || _anchorRectCache === void 0 || _anchorRectCache.clear();
1100
- }
1081
+ (_anchorRectCache = anchorRectCache) === null || _anchorRectCache === void 0 || _anchorRectCache.clear();
1101
1082
  (_anchorRectCache2 = anchorRectCache) === null || _anchorRectCache2 === void 0 || _anchorRectCache2.setEditorView(view);
1102
1083
  view.dispatch(view.state.tr.setMeta(key, _objectSpread(_objectSpread({}, view.state.tr.getMeta(key)), {}, {
1103
1084
  isPMDragging: true
@@ -15,11 +15,9 @@ export var getBlockControlsSurfaceDragHandleComponents = function getBlockContro
15
15
  surfaceContext: surfaceContext
16
16
  });
17
17
  },
18
- isHidden: function isHidden() {
19
- var _api$editorViewMode;
20
- var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
21
- surfaceContext = _ref3.surfaceContext;
22
- var context = surfaceContext === null || surfaceContext === void 0 ? void 0 : surfaceContext.get(BLOCK_CONTROL_UI_CONTEXT);
18
+ isHidden: function isHidden(ctx) {
19
+ var _ctx$surfaceContext, _api$editorViewMode;
20
+ var context = ctx === null || ctx === void 0 || (_ctx$surfaceContext = ctx.surfaceContext) === null || _ctx$surfaceContext === void 0 ? void 0 : _ctx$surfaceContext.get(BLOCK_CONTROL_UI_CONTEXT);
23
21
  return (api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 || (_api$editorViewMode = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.mode) === 'view' || !(context !== null && context !== void 0 && context.activeNode) || context.targetNode.pos !== context.activeNode.pos || context.activeControlKey !== undefined && context.activeControlKey !== BLOCK_CONTROLS_DRAG_HANDLE.key;
24
22
  }
25
23
  }, BLOCK_CONTROLS_DRAG_HANDLE), {}, {
@@ -489,7 +489,7 @@ export var GlobalStylesWrapper = function GlobalStylesWrapper(_ref) {
489
489
  }),
490
490
  isDraggingFromState = _useSharedPluginState.isDragging;
491
491
  var sparseSurfacesEnabled = isExperimentEnabled('platform_editor_block_control_migration');
492
- var isDragging = sparseSurfacesEnabled || expValEquals('platform_editor_block_controls_perf_optimization', 'isEnabled', true) ? isDraggingFromState : false;
492
+ var isDragging = isDraggingFromState;
493
493
  var shouldRenderAnchors = isCSSAnchorSupported() && expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true);
494
494
  var sparseSurfaceAnchorsEnabled = Boolean(isCSSAnchorSupported()) && sparseSurfacesEnabled;
495
495
  var toolbarFlagsEnabled = areToolbarFlagsEnabled(Boolean(api === null || api === void 0 ? void 0 : api.toolbar));
@@ -1,10 +1,6 @@
1
- import type { IntlShape } from 'react-intl';
2
1
  import type { PortalProviderAPI } from '@atlaskit/editor-common/common';
3
- import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types/next-editor-plugin';
4
- import type { EditorState } from '@atlaskit/editor-prosemirror/state';
5
2
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
6
3
  import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
7
- import type { ActiveNode, BlockControlsPlugin } from '../blockControlsPluginType';
8
4
  import type { DropTargetProps } from '../ui/drop-target';
9
5
  import type { DropTargetLayoutProps } from '../ui/drop-target-layout';
10
6
  import type { AnchorRectCache } from './utils/anchor-utils';
@@ -18,4 +14,3 @@ import type { AnchorRectCache } from './utils/anchor-utils';
18
14
  export declare const findDropTargetDecs: (decorations: DecorationSet, from?: number, to?: number) => Decoration[];
19
15
  export declare const createDropTargetDecoration: (pos: number, props: Omit<DropTargetProps, 'getPos'>, nodeViewPortalProviderAPI: PortalProviderAPI, side?: number, anchorRectCache?: AnchorRectCache, isSameLayout?: boolean) => Decoration;
20
16
  export declare const createLayoutDropTargetDecoration: (pos: number, props: Omit<DropTargetLayoutProps, 'getPos'>, nodeViewPortalProviderAPI: PortalProviderAPI, anchorRectCache?: AnchorRectCache) => Decoration;
21
- export declare const dropTargetDecorations: (newState: EditorState, api: ExtractInjectionAPI<BlockControlsPlugin>, formatMessage: IntlShape['formatMessage'], nodeViewPortalProviderAPI: PortalProviderAPI, activeNode?: ActiveNode, anchorRectCache?: AnchorRectCache, from?: number, to?: number) => Decoration[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "31.1.17",
3
+ "version": "31.1.19",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -56,11 +56,11 @@
56
56
  "@atlaskit/platform-feature-flags": "^2.2.0",
57
57
  "@atlaskit/pragmatic-drag-and-drop": "^4.0.0",
58
58
  "@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^3.2.0",
59
- "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^4.2.0",
59
+ "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^4.3.0",
60
60
  "@atlaskit/primitives": "^22.7.0",
61
61
  "@atlaskit/section-message": "^10.3.0",
62
62
  "@atlaskit/theme": "^28.2.0",
63
- "@atlaskit/tmp-editor-statsig": "^262.0.0",
63
+ "@atlaskit/tmp-editor-statsig": "^264.0.0",
64
64
  "@atlaskit/tokens": "^20.12.0",
65
65
  "@atlaskit/tooltip": "^24.4.0",
66
66
  "@babel/runtime": "^7.0.0",
@@ -72,7 +72,7 @@
72
72
  "uuid": "^11.1.1"
73
73
  },
74
74
  "peerDependencies": {
75
- "@atlaskit/editor-common": "^134.19.0",
75
+ "@atlaskit/editor-common": "^134.20.0",
76
76
  "react": "^18.2.0 || ^19.2.0",
77
77
  "react-dom": "^18.2.0 || ^19.2.0",
78
78
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
@@ -96,7 +96,7 @@
96
96
  }
97
97
  },
98
98
  "devDependencies": {
99
- "@atlaskit/editor-common": "^134.19.0",
99
+ "@atlaskit/editor-common": "^134.20.0",
100
100
  "@atlassian/structured-docs-types": "workspace:^",
101
101
  "@atlassian/workbench": "workspace:*",
102
102
  "react": "^19.2.0",