@atlaskit/editor-plugin-block-controls 3.15.9 → 3.15.11
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 +19 -0
- package/dist/cjs/pm-plugins/decorations-drag-handle.js +34 -9
- package/dist/cjs/pm-plugins/decorations-quick-insert-button.js +26 -9
- package/dist/cjs/ui/drag-handle.js +118 -27
- package/dist/es2019/pm-plugins/decorations-drag-handle.js +34 -9
- package/dist/es2019/pm-plugins/decorations-quick-insert-button.js +26 -9
- package/dist/es2019/ui/drag-handle.js +108 -18
- package/dist/esm/pm-plugins/decorations-drag-handle.js +34 -9
- package/dist/esm/pm-plugins/decorations-quick-insert-button.js +26 -9
- package/dist/esm/ui/drag-handle.js +119 -28
- package/dist/types/ui/drag-handle.d.ts +1 -1
- package/dist/types-ts4.5/ui/drag-handle.d.ts +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 3.15.11
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#166480](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/166480)
|
|
8
|
+
[`55d4dbd11d97d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/55d4dbd11d97d) -
|
|
9
|
+
Add 'marks: []' to both widgets to ensure PM renders them at the top level document, not inside
|
|
10
|
+
sibling elements wrapped with marks
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
13
|
+
## 3.15.10
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#165562](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/165562)
|
|
18
|
+
[`59af663a32c9a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/59af663a32c9a) -
|
|
19
|
+
Reduce block control re-renders under experiment
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
|
|
3
22
|
## 3.15.9
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
|
@@ -30,9 +30,41 @@ var findHandleDec = exports.findHandleDec = function findHandleDec(decorations,
|
|
|
30
30
|
});
|
|
31
31
|
};
|
|
32
32
|
var dragHandleDecoration = exports.dragHandleDecoration = function dragHandleDecoration(api, formatMessage, pos, anchorName, nodeType, nodeViewPortalProviderAPI, handleOptions, anchorRectCache) {
|
|
33
|
-
(0,
|
|
33
|
+
if (!(0, _experiments.editorExperiment)('platform_editor_block_control_optimise_render', true, {
|
|
34
|
+
exposure: true
|
|
35
|
+
})) {
|
|
36
|
+
(0, _decorationsCommon.unmountDecorations)(nodeViewPortalProviderAPI, 'data-blocks-drag-handle-container', 'data-blocks-drag-handle-key');
|
|
37
|
+
}
|
|
34
38
|
var unbind;
|
|
35
39
|
var key = (0, _uuid.default)();
|
|
40
|
+
var widgetSpec = (0, _experiments.editorExperiment)('platform_editor_breakout_resizing', true) ? {
|
|
41
|
+
side: -1,
|
|
42
|
+
type: _decorationsCommon.TYPE_HANDLE_DEC,
|
|
43
|
+
testid: "".concat(_decorationsCommon.TYPE_HANDLE_DEC, "-").concat((0, _uuid.default)()),
|
|
44
|
+
/**
|
|
45
|
+
* sigh - `marks` influences the position that the widget is drawn (as described on the `side` property).
|
|
46
|
+
* Leaving this 'undefined' causes the widget to be wrapped in the mark before this position which creates
|
|
47
|
+
* weird stacking context issues. Providing an empty array causes the widget to correctly render before
|
|
48
|
+
* this exact position at the top of the DOM.
|
|
49
|
+
*/
|
|
50
|
+
marks: [],
|
|
51
|
+
destroy: function destroy(node) {
|
|
52
|
+
unbind && unbind();
|
|
53
|
+
if ((0, _experiments.editorExperiment)('platform_editor_block_control_optimise_render', true) && node instanceof HTMLElement) {
|
|
54
|
+
_reactDom.default.unmountComponentAtNode(node);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
} : {
|
|
58
|
+
side: -1,
|
|
59
|
+
type: _decorationsCommon.TYPE_HANDLE_DEC,
|
|
60
|
+
testid: "".concat(_decorationsCommon.TYPE_HANDLE_DEC, "-").concat((0, _uuid.default)()),
|
|
61
|
+
destroy: function destroy(node) {
|
|
62
|
+
unbind && unbind();
|
|
63
|
+
if ((0, _experiments.editorExperiment)('platform_editor_block_control_optimise_render', true) && node instanceof HTMLElement) {
|
|
64
|
+
_reactDom.default.unmountComponentAtNode(node);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
36
68
|
return _view.Decoration.widget(pos, function (view, getPosUnsafe) {
|
|
37
69
|
var element = document.createElement('span');
|
|
38
70
|
// inline decoration causes focus issues when refocusing Editor into first line
|
|
@@ -122,12 +154,5 @@ var dragHandleDecoration = exports.dragHandleDecoration = function dragHandleDec
|
|
|
122
154
|
}), element);
|
|
123
155
|
}
|
|
124
156
|
return element;
|
|
125
|
-
},
|
|
126
|
-
side: -1,
|
|
127
|
-
type: _decorationsCommon.TYPE_HANDLE_DEC,
|
|
128
|
-
testid: "".concat(_decorationsCommon.TYPE_HANDLE_DEC, "-").concat((0, _uuid.default)()),
|
|
129
|
-
destroy: function destroy(_) {
|
|
130
|
-
unbind && unbind();
|
|
131
|
-
}
|
|
132
|
-
});
|
|
157
|
+
}, widgetSpec);
|
|
133
158
|
};
|
|
@@ -9,6 +9,7 @@ var _react = require("react");
|
|
|
9
9
|
var _uuid = _interopRequireDefault(require("uuid"));
|
|
10
10
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
11
11
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
12
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
12
13
|
var _quickInsertButton = require("../ui/quick-insert-button");
|
|
13
14
|
var TYPE_QUICK_INSERT = 'INSERT_BUTTON';
|
|
14
15
|
var findQuickInsertInsertButtonDecoration = exports.findQuickInsertInsertButtonDecoration = function findQuickInsertInsertButtonDecoration(decorations, from, to) {
|
|
@@ -18,6 +19,30 @@ var findQuickInsertInsertButtonDecoration = exports.findQuickInsertInsertButtonD
|
|
|
18
19
|
};
|
|
19
20
|
var quickInsertButtonDecoration = exports.quickInsertButtonDecoration = function quickInsertButtonDecoration(api, formatMessage, rootPos, anchorName, nodeType, nodeViewPortalProviderAPI, rootAnchorName, rootNodeType, anchorRectCache) {
|
|
20
21
|
var key = (0, _uuid.default)();
|
|
22
|
+
var widgetSpec = (0, _experiments.editorExperiment)('platform_editor_breakout_resizing', true) ? {
|
|
23
|
+
side: -2,
|
|
24
|
+
type: TYPE_QUICK_INSERT,
|
|
25
|
+
/**
|
|
26
|
+
* sigh - `marks` influences the position that the widget is drawn (as described on the `side` property).
|
|
27
|
+
* Leaving this 'undefined' causes the widget to be wrapped in the mark before this position which creates
|
|
28
|
+
* weird stacking context issues. Providing an empty array causes the widget to correctly render before
|
|
29
|
+
* this exact position at the top of the DOM.
|
|
30
|
+
*/
|
|
31
|
+
marks: [],
|
|
32
|
+
destroy: function destroy(_) {
|
|
33
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_fix_widget_destroy')) {
|
|
34
|
+
nodeViewPortalProviderAPI.remove(key);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
} : {
|
|
38
|
+
side: -2,
|
|
39
|
+
type: TYPE_QUICK_INSERT,
|
|
40
|
+
destroy: function destroy(_) {
|
|
41
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_fix_widget_destroy')) {
|
|
42
|
+
nodeViewPortalProviderAPI.remove(key);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
21
46
|
return _view.Decoration.widget(rootPos, function (view, getPos) {
|
|
22
47
|
var element = document.createElement('span');
|
|
23
48
|
element.contentEditable = 'false';
|
|
@@ -55,13 +80,5 @@ var quickInsertButtonDecoration = exports.quickInsertButtonDecoration = function
|
|
|
55
80
|
}, element, key);
|
|
56
81
|
}
|
|
57
82
|
return element;
|
|
58
|
-
},
|
|
59
|
-
side: -2,
|
|
60
|
-
type: TYPE_QUICK_INSERT,
|
|
61
|
-
destroy: function destroy(_) {
|
|
62
|
-
if ((0, _platformFeatureFlags.fg)('platform_editor_fix_widget_destroy')) {
|
|
63
|
-
nodeViewPortalProviderAPI.remove(key);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
});
|
|
83
|
+
}, widgetSpec);
|
|
67
84
|
};
|
|
@@ -20,8 +20,8 @@ var _styles = require("@atlaskit/editor-common/styles");
|
|
|
20
20
|
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
21
21
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
22
22
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
23
|
+
var _dragHandleVertical = _interopRequireDefault(require("@atlaskit/icon/core/drag-handle-vertical"));
|
|
23
24
|
var _dragHandler = _interopRequireDefault(require("@atlaskit/icon/glyph/drag-handler"));
|
|
24
|
-
var _dragHandleVertical = _interopRequireDefault(require("@atlaskit/icon/utility/drag-handle-vertical"));
|
|
25
25
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
26
26
|
var _adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
|
|
27
27
|
var _setCustomNativeDragPreview = require("@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview");
|
|
@@ -272,29 +272,42 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
272
272
|
_ref$isTopLevelNode = _ref.isTopLevelNode,
|
|
273
273
|
isTopLevelNode = _ref$isTopLevelNode === void 0 ? true : _ref$isTopLevelNode,
|
|
274
274
|
anchorRectCache = _ref.anchorRectCache;
|
|
275
|
-
var start = getPos();
|
|
276
275
|
var buttonRef = (0, _react.useRef)(null);
|
|
277
|
-
var _useState = (0, _react.useState)(
|
|
276
|
+
var _useState = (0, _react.useState)(false),
|
|
278
277
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
279
|
-
|
|
280
|
-
|
|
278
|
+
dragHandleSelected = _useState2[0],
|
|
279
|
+
setDragHandleSelected = _useState2[1];
|
|
281
280
|
var _useState3 = (0, _react.useState)(false),
|
|
282
281
|
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
var _useState5 = (0, _react.useState)(
|
|
282
|
+
dragHandleDisabled = _useState4[0],
|
|
283
|
+
setDragHandleDisabled = _useState4[1];
|
|
284
|
+
var _useState5 = (0, _react.useState)(768),
|
|
286
285
|
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
287
|
-
|
|
288
|
-
|
|
286
|
+
blockCardWidth = _useState6[0],
|
|
287
|
+
setBlockCardWidth = _useState6[1];
|
|
288
|
+
var _useState7 = (0, _react.useState)(false),
|
|
289
|
+
_useState8 = (0, _slicedToArray2.default)(_useState7, 2),
|
|
290
|
+
recalculatePosition = _useState8[0],
|
|
291
|
+
setRecalculatePosition = _useState8[1];
|
|
292
|
+
var _useState9 = (0, _react.useState)({
|
|
293
|
+
display: 'none'
|
|
294
|
+
}),
|
|
295
|
+
_useState0 = (0, _slicedToArray2.default)(_useState9, 2),
|
|
296
|
+
positionStylesOld = _useState0[0],
|
|
297
|
+
setPositionStylesOld = _useState0[1];
|
|
289
298
|
var _useDragHandlePluginS = useDragHandlePluginState(api),
|
|
290
299
|
macroInteractionUpdates = _useDragHandlePluginS.macroInteractionUpdates;
|
|
291
300
|
var selection = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'selection.selection');
|
|
292
301
|
var isShiftDown = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockControls.isShiftDown');
|
|
293
302
|
var _hasHadInteraction = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'interaction.hasHadInteraction') !== false;
|
|
294
303
|
var interactionState = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'interaction.interactionState');
|
|
304
|
+
var start = getPos();
|
|
295
305
|
var isLayoutColumn = nodeType === 'layoutColumn';
|
|
296
306
|
var isMultiSelect = (0, _experiments.editorExperiment)('platform_editor_element_drag_and_drop_multiselect', true);
|
|
297
307
|
(0, _react.useEffect)(function () {
|
|
308
|
+
if ((0, _experiments.editorExperiment)('platform_editor_block_control_optimise_render', true)) {
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
298
311
|
// blockCard/datasource width is rendered correctly after this decoraton does. We need to observe for changes.
|
|
299
312
|
if (nodeType === 'blockCard') {
|
|
300
313
|
var dom = view.dom.querySelector("[data-drag-handler-anchor-name=\"".concat(anchorName, "\"]"));
|
|
@@ -581,7 +594,61 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
581
594
|
}
|
|
582
595
|
});
|
|
583
596
|
}, [anchorName, api, getPos, isMultiSelect, nodeType, start, view]);
|
|
584
|
-
var
|
|
597
|
+
var positionStyles = (0, _react.useMemo)(function () {
|
|
598
|
+
if (!(0, _experiments.editorExperiment)('platform_editor_block_control_optimise_render', true)) {
|
|
599
|
+
return {};
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
// This is a no-op to allow recalculatePosition to be used as a dependency
|
|
603
|
+
if (recalculatePosition) {
|
|
604
|
+
setRecalculatePosition(recalculatePosition);
|
|
605
|
+
}
|
|
606
|
+
var pos = getPos();
|
|
607
|
+
var $pos = pos && view.state.doc.resolve(pos);
|
|
608
|
+
var parentPos = $pos && $pos.depth ? $pos.before() : undefined;
|
|
609
|
+
var node = parentPos !== undefined ? view.state.doc.nodeAt(parentPos) : undefined;
|
|
610
|
+
var parentNodeType = node === null || node === void 0 ? void 0 : node.type.name;
|
|
611
|
+
var supportsAnchor = CSS.supports('top', "anchor(".concat(anchorName, " start)")) && CSS.supports('left', "anchor(".concat(anchorName, " start)"));
|
|
612
|
+
var safeAnchorName = (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_2') ? (0, _anchorName.refreshAnchorName)({
|
|
613
|
+
getPos: getPos,
|
|
614
|
+
view: view,
|
|
615
|
+
anchorName: anchorName
|
|
616
|
+
}) : anchorName;
|
|
617
|
+
var dom = view.dom.querySelector("[data-drag-handler-anchor-name=\"".concat(safeAnchorName, "\"]"));
|
|
618
|
+
var hasResizer = nodeType === 'table' || nodeType === 'mediaSingle';
|
|
619
|
+
var isExtension = nodeType === 'extension' || nodeType === 'bodiedExtension' || nodeType === 'multiBodiedExtension' && (0, _platformFeatureFlags.fg)('platform_editor_multi_body_extension_extensibility');
|
|
620
|
+
var isBlockCard = nodeType === 'blockCard';
|
|
621
|
+
var isEmbedCard = nodeType === 'embedCard';
|
|
622
|
+
var isMacroInteractionUpdates = macroInteractionUpdates && isExtension;
|
|
623
|
+
var innerContainer = null;
|
|
624
|
+
if (dom) {
|
|
625
|
+
if (isEmbedCard) {
|
|
626
|
+
innerContainer = dom.querySelector('.rich-media-item');
|
|
627
|
+
} else if (hasResizer) {
|
|
628
|
+
innerContainer = dom.querySelector('.resizer-item');
|
|
629
|
+
} else if (isExtension) {
|
|
630
|
+
innerContainer = dom.querySelector('.extension-container[data-layout]');
|
|
631
|
+
} else if (isBlockCard) {
|
|
632
|
+
//specific to datasource blockCard
|
|
633
|
+
innerContainer = dom.querySelector('.datasourceView-content-inner-wrap');
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
var isEdgeCase = (hasResizer || isExtension || isEmbedCard || isBlockCard) && innerContainer;
|
|
637
|
+
var isSticky = (0, _dragHandlePositions.shouldBeSticky)(nodeType);
|
|
638
|
+
if (supportsAnchor) {
|
|
639
|
+
var bottom = (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? (0, _dragHandlePositions.getControlBottomCSSValue)(safeAnchorName, isSticky, isTopLevelNode, isLayoutColumn) : {};
|
|
640
|
+
return _objectSpread({
|
|
641
|
+
left: isEdgeCase ? "calc(anchor(".concat(safeAnchorName, " start) + ").concat((0, _dragHandlePositions.getLeftPosition)(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType), ")") : (0, _experiments.editorExperiment)('advanced_layouts', true) && isLayoutColumn ? "calc((anchor(".concat(safeAnchorName, " right) + anchor(").concat(safeAnchorName, " left))/2 - ").concat(_consts.DRAG_HANDLE_HEIGHT / 2, "px)") : "calc(anchor(".concat(safeAnchorName, " start) - ").concat(_consts.DRAG_HANDLE_WIDTH, "px - ").concat((0, _consts.dragHandleGap)(nodeType, parentNodeType), "px)"),
|
|
642
|
+
top: (0, _experiments.editorExperiment)('advanced_layouts', true) && isLayoutColumn ? "calc(anchor(".concat(safeAnchorName, " top) - ").concat(_consts.DRAG_HANDLE_WIDTH, "px)") : "calc(anchor(".concat(safeAnchorName, " start) + ").concat((0, _consts.topPositionAdjustment)(nodeType), "px)")
|
|
643
|
+
}, bottom);
|
|
644
|
+
}
|
|
645
|
+
var height = (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? (0, _dragHandlePositions.getControlHeightCSSValue)((0, _dragHandlePositions.getNodeHeight)(dom, safeAnchorName, anchorRectCache) || 0, isSticky, isTopLevelNode, "".concat(_consts.DRAG_HANDLE_HEIGHT), isLayoutColumn) : {};
|
|
646
|
+
return _objectSpread({
|
|
647
|
+
left: isEdgeCase ? "calc(".concat((dom === null || dom === void 0 ? void 0 : dom.offsetLeft) || 0, "px + ").concat((0, _dragHandlePositions.getLeftPosition)(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType), ")") : (0, _dragHandlePositions.getLeftPosition)(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType),
|
|
648
|
+
top: (0, _dragHandlePositions.getTopPosition)(dom, nodeType)
|
|
649
|
+
}, height);
|
|
650
|
+
}, [anchorName, getPos, view, nodeType, macroInteractionUpdates, anchorRectCache, isTopLevelNode, isLayoutColumn, recalculatePosition]);
|
|
651
|
+
var calculatePositionOld = (0, _react.useCallback)(function () {
|
|
585
652
|
var pos = getPos();
|
|
586
653
|
var $pos = pos && view.state.doc.resolve(pos);
|
|
587
654
|
var parentPos = $pos && $pos.depth ? $pos.before() : undefined;
|
|
@@ -627,13 +694,10 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
627
694
|
top: (0, _dragHandlePositions.getTopPosition)(dom, nodeType)
|
|
628
695
|
}, height);
|
|
629
696
|
}, [anchorName, getPos, view, nodeType, blockCardWidth, macroInteractionUpdates, anchorRectCache, isTopLevelNode, isLayoutColumn]);
|
|
630
|
-
var _useState7 = (0, _react.useState)({
|
|
631
|
-
display: 'none'
|
|
632
|
-
}),
|
|
633
|
-
_useState8 = (0, _slicedToArray2.default)(_useState7, 2),
|
|
634
|
-
positionStyles = _useState8[0],
|
|
635
|
-
setPositionStyles = _useState8[1];
|
|
636
697
|
(0, _react.useEffect)(function () {
|
|
698
|
+
if ((0, _experiments.editorExperiment)('platform_editor_block_control_optimise_render', true)) {
|
|
699
|
+
return;
|
|
700
|
+
}
|
|
637
701
|
var cleanUpTransitionListener;
|
|
638
702
|
if (nodeType === 'extension' || nodeType === 'embedCard') {
|
|
639
703
|
var dom = view.dom.querySelector("[data-drag-handler-anchor-name=\"".concat(anchorName, "\"]"));
|
|
@@ -643,19 +707,41 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
643
707
|
cleanUpTransitionListener = (0, _bindEventListener.bind)(dom, {
|
|
644
708
|
type: 'transitionend',
|
|
645
709
|
listener: function listener() {
|
|
646
|
-
|
|
710
|
+
setPositionStylesOld(calculatePositionOld());
|
|
647
711
|
}
|
|
648
712
|
});
|
|
649
713
|
}
|
|
650
714
|
var calcPos = requestAnimationFrame(function () {
|
|
651
|
-
|
|
715
|
+
setPositionStylesOld(calculatePositionOld());
|
|
652
716
|
});
|
|
653
717
|
return function () {
|
|
654
718
|
var _cleanUpTransitionLis;
|
|
655
719
|
cancelAnimationFrame(calcPos);
|
|
656
720
|
(_cleanUpTransitionLis = cleanUpTransitionListener) === null || _cleanUpTransitionLis === void 0 || _cleanUpTransitionLis();
|
|
657
721
|
};
|
|
658
|
-
}, [
|
|
722
|
+
}, [calculatePositionOld, view.dom, anchorName, nodeType]);
|
|
723
|
+
(0, _react.useEffect)(function () {
|
|
724
|
+
if (!(0, _experiments.editorExperiment)('platform_editor_block_control_optimise_render', true)) {
|
|
725
|
+
return;
|
|
726
|
+
}
|
|
727
|
+
var cleanUpTransitionListener;
|
|
728
|
+
if (nodeType === 'extension' || nodeType === 'embedCard') {
|
|
729
|
+
var dom = view.dom.querySelector("[data-drag-handler-anchor-name=\"".concat(anchorName, "\"]"));
|
|
730
|
+
if (!dom) {
|
|
731
|
+
return;
|
|
732
|
+
}
|
|
733
|
+
cleanUpTransitionListener = (0, _bindEventListener.bind)(dom, {
|
|
734
|
+
type: 'transitionend',
|
|
735
|
+
listener: function listener() {
|
|
736
|
+
setRecalculatePosition(!recalculatePosition);
|
|
737
|
+
}
|
|
738
|
+
});
|
|
739
|
+
}
|
|
740
|
+
return function () {
|
|
741
|
+
var _cleanUpTransitionLis2;
|
|
742
|
+
(_cleanUpTransitionLis2 = cleanUpTransitionListener) === null || _cleanUpTransitionLis2 === void 0 || _cleanUpTransitionLis2();
|
|
743
|
+
};
|
|
744
|
+
}, [view, anchorName, nodeType, recalculatePosition]);
|
|
659
745
|
(0, _react.useEffect)(function () {
|
|
660
746
|
if (handleOptions !== null && handleOptions !== void 0 && handleOptions.isFocused && buttonRef.current && (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_23873')) {
|
|
661
747
|
var id = requestAnimationFrame(function () {
|
|
@@ -664,7 +750,9 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
664
750
|
});
|
|
665
751
|
return function () {
|
|
666
752
|
cancelAnimationFrame(id);
|
|
667
|
-
|
|
753
|
+
if (!(0, _experiments.editorExperiment)('platform_editor_block_control_optimise_render', true)) {
|
|
754
|
+
view.focus();
|
|
755
|
+
}
|
|
668
756
|
};
|
|
669
757
|
}
|
|
670
758
|
}, [buttonRef, handleOptions === null || handleOptions === void 0 ? void 0 : handleOptions.isFocused, view]);
|
|
@@ -673,7 +761,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
673
761
|
return;
|
|
674
762
|
}
|
|
675
763
|
setDragHandleSelected((0, _getSelection.isHandleCorrelatedToSelection)(view.state, selection, start));
|
|
676
|
-
}, [start, selection, view
|
|
764
|
+
}, [start, selection, view, isMultiSelect]);
|
|
677
765
|
(0, _react.useEffect)(function () {
|
|
678
766
|
var _api$blockControls$sh4;
|
|
679
767
|
if (!isMultiSelect || isShiftDown === undefined || view.state.selection.empty || !(0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_shift_click_select')) {
|
|
@@ -686,7 +774,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
686
774
|
} else {
|
|
687
775
|
setDragHandleDisabled(false);
|
|
688
776
|
}
|
|
689
|
-
}, [api === null || api === void 0 ? void 0 : api.blockControls.sharedState, isMultiSelect, isShiftDown, isTopLevelNode, view
|
|
777
|
+
}, [api === null || api === void 0 ? void 0 : api.blockControls.sharedState, isMultiSelect, isShiftDown, isTopLevelNode, view]);
|
|
690
778
|
var helpDescriptors = isTopLevelNode ? [{
|
|
691
779
|
description: formatMessage(_messages.blockControlsMessages.dragToMove)
|
|
692
780
|
}, {
|
|
@@ -771,7 +859,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
771
859
|
ref: buttonRef
|
|
772
860
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
773
861
|
,
|
|
774
|
-
style: !(0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')
|
|
862
|
+
style: !(0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? (0, _experiments.editorExperiment)('platform_editor_block_control_optimise_render', true) ? positionStyles : positionStylesOld : {},
|
|
775
863
|
onClick: handleOnClick,
|
|
776
864
|
onMouseDown: handleMouseDown,
|
|
777
865
|
onKeyDown: handleKeyDown
|
|
@@ -790,7 +878,8 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
790
878
|
spacing: "spacious",
|
|
791
879
|
label: "",
|
|
792
880
|
LEGACY_fallbackIcon: _dragHandler.default,
|
|
793
|
-
LEGACY_size: "medium"
|
|
881
|
+
LEGACY_size: "medium",
|
|
882
|
+
size: "small"
|
|
794
883
|
})))
|
|
795
884
|
);
|
|
796
885
|
};
|
|
@@ -798,7 +887,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
798
887
|
return (0, _react2.jsx)(_primitives.Box
|
|
799
888
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
800
889
|
, {
|
|
801
|
-
style: positionStyles,
|
|
890
|
+
style: (0, _experiments.editorExperiment)('platform_editor_block_control_optimise_render', true) ? positionStyles : positionStylesOld,
|
|
802
891
|
xcss: [dragHandleContainerStyles],
|
|
803
892
|
as: "span",
|
|
804
893
|
testId: "block-ctrl-drag-handle-container"
|
|
@@ -824,7 +913,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
824
913
|
return (0, _react2.jsx)(_primitives.Box
|
|
825
914
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
826
915
|
, {
|
|
827
|
-
style: positionStyles,
|
|
916
|
+
style: (0, _experiments.editorExperiment)('platform_editor_block_control_optimise_render', true) ? positionStyles : positionStylesOld,
|
|
828
917
|
xcss: [dragHandleContainerStyles],
|
|
829
918
|
as: "span",
|
|
830
919
|
testId: "block-ctrl-drag-handle-container"
|
|
@@ -860,6 +949,7 @@ var DragHandleWithVisibility = exports.DragHandleWithVisibility = function DragH
|
|
|
860
949
|
getPos = _ref8.getPos,
|
|
861
950
|
anchorName = _ref8.anchorName,
|
|
862
951
|
nodeType = _ref8.nodeType,
|
|
952
|
+
handleOptions = _ref8.handleOptions,
|
|
863
953
|
anchorRectCache = _ref8.anchorRectCache;
|
|
864
954
|
return (0, _react2.jsx)(_visibilityContainer.VisibilityContainer, {
|
|
865
955
|
api: api
|
|
@@ -870,6 +960,7 @@ var DragHandleWithVisibility = exports.DragHandleWithVisibility = function DragH
|
|
|
870
960
|
getPos: getPos,
|
|
871
961
|
anchorName: anchorName,
|
|
872
962
|
nodeType: nodeType,
|
|
963
|
+
handleOptions: handleOptions,
|
|
873
964
|
anchorRectCache: anchorRectCache
|
|
874
965
|
}));
|
|
875
966
|
};
|
|
@@ -21,9 +21,41 @@ export const findHandleDec = (decorations, from, to) => {
|
|
|
21
21
|
return decorations.find(from, to, spec => spec.type === TYPE_HANDLE_DEC);
|
|
22
22
|
};
|
|
23
23
|
export const dragHandleDecoration = (api, formatMessage, pos, anchorName, nodeType, nodeViewPortalProviderAPI, handleOptions, anchorRectCache) => {
|
|
24
|
-
|
|
24
|
+
if (!editorExperiment('platform_editor_block_control_optimise_render', true, {
|
|
25
|
+
exposure: true
|
|
26
|
+
})) {
|
|
27
|
+
unmountDecorations(nodeViewPortalProviderAPI, 'data-blocks-drag-handle-container', 'data-blocks-drag-handle-key');
|
|
28
|
+
}
|
|
25
29
|
let unbind;
|
|
26
30
|
const key = uuid();
|
|
31
|
+
const widgetSpec = editorExperiment('platform_editor_breakout_resizing', true) ? {
|
|
32
|
+
side: -1,
|
|
33
|
+
type: TYPE_HANDLE_DEC,
|
|
34
|
+
testid: `${TYPE_HANDLE_DEC}-${uuid()}`,
|
|
35
|
+
/**
|
|
36
|
+
* sigh - `marks` influences the position that the widget is drawn (as described on the `side` property).
|
|
37
|
+
* Leaving this 'undefined' causes the widget to be wrapped in the mark before this position which creates
|
|
38
|
+
* weird stacking context issues. Providing an empty array causes the widget to correctly render before
|
|
39
|
+
* this exact position at the top of the DOM.
|
|
40
|
+
*/
|
|
41
|
+
marks: [],
|
|
42
|
+
destroy: node => {
|
|
43
|
+
unbind && unbind();
|
|
44
|
+
if (editorExperiment('platform_editor_block_control_optimise_render', true) && node instanceof HTMLElement) {
|
|
45
|
+
ReactDOM.unmountComponentAtNode(node);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
} : {
|
|
49
|
+
side: -1,
|
|
50
|
+
type: TYPE_HANDLE_DEC,
|
|
51
|
+
testid: `${TYPE_HANDLE_DEC}-${uuid()}`,
|
|
52
|
+
destroy: node => {
|
|
53
|
+
unbind && unbind();
|
|
54
|
+
if (editorExperiment('platform_editor_block_control_optimise_render', true) && node instanceof HTMLElement) {
|
|
55
|
+
ReactDOM.unmountComponentAtNode(node);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
27
59
|
return Decoration.widget(pos, (view, getPosUnsafe) => {
|
|
28
60
|
const element = document.createElement('span');
|
|
29
61
|
// inline decoration causes focus issues when refocusing Editor into first line
|
|
@@ -113,12 +145,5 @@ export const dragHandleDecoration = (api, formatMessage, pos, anchorName, nodeTy
|
|
|
113
145
|
}), element);
|
|
114
146
|
}
|
|
115
147
|
return element;
|
|
116
|
-
},
|
|
117
|
-
side: -1,
|
|
118
|
-
type: TYPE_HANDLE_DEC,
|
|
119
|
-
testid: `${TYPE_HANDLE_DEC}-${uuid()}`,
|
|
120
|
-
destroy: _ => {
|
|
121
|
-
unbind && unbind();
|
|
122
|
-
}
|
|
123
|
-
});
|
|
148
|
+
}, widgetSpec);
|
|
124
149
|
};
|
|
@@ -2,6 +2,7 @@ import { createElement } from 'react';
|
|
|
2
2
|
import uuid from 'uuid';
|
|
3
3
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
4
4
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
5
6
|
import { QuickInsertWithVisibility, TypeAheadControl } from '../ui/quick-insert-button';
|
|
6
7
|
const TYPE_QUICK_INSERT = 'INSERT_BUTTON';
|
|
7
8
|
export const findQuickInsertInsertButtonDecoration = (decorations, from, to) => {
|
|
@@ -9,6 +10,30 @@ export const findQuickInsertInsertButtonDecoration = (decorations, from, to) =>
|
|
|
9
10
|
};
|
|
10
11
|
export const quickInsertButtonDecoration = (api, formatMessage, rootPos, anchorName, nodeType, nodeViewPortalProviderAPI, rootAnchorName, rootNodeType, anchorRectCache) => {
|
|
11
12
|
const key = uuid();
|
|
13
|
+
const widgetSpec = editorExperiment('platform_editor_breakout_resizing', true) ? {
|
|
14
|
+
side: -2,
|
|
15
|
+
type: TYPE_QUICK_INSERT,
|
|
16
|
+
/**
|
|
17
|
+
* sigh - `marks` influences the position that the widget is drawn (as described on the `side` property).
|
|
18
|
+
* Leaving this 'undefined' causes the widget to be wrapped in the mark before this position which creates
|
|
19
|
+
* weird stacking context issues. Providing an empty array causes the widget to correctly render before
|
|
20
|
+
* this exact position at the top of the DOM.
|
|
21
|
+
*/
|
|
22
|
+
marks: [],
|
|
23
|
+
destroy: _ => {
|
|
24
|
+
if (fg('platform_editor_fix_widget_destroy')) {
|
|
25
|
+
nodeViewPortalProviderAPI.remove(key);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
} : {
|
|
29
|
+
side: -2,
|
|
30
|
+
type: TYPE_QUICK_INSERT,
|
|
31
|
+
destroy: _ => {
|
|
32
|
+
if (fg('platform_editor_fix_widget_destroy')) {
|
|
33
|
+
nodeViewPortalProviderAPI.remove(key);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
12
37
|
return Decoration.widget(rootPos, (view, getPos) => {
|
|
13
38
|
const element = document.createElement('span');
|
|
14
39
|
element.contentEditable = 'false';
|
|
@@ -42,13 +67,5 @@ export const quickInsertButtonDecoration = (api, formatMessage, rootPos, anchorN
|
|
|
42
67
|
}), element, key);
|
|
43
68
|
}
|
|
44
69
|
return element;
|
|
45
|
-
},
|
|
46
|
-
side: -2,
|
|
47
|
-
type: TYPE_QUICK_INSERT,
|
|
48
|
-
destroy: _ => {
|
|
49
|
-
if (fg('platform_editor_fix_widget_destroy')) {
|
|
50
|
-
nodeViewPortalProviderAPI.remove(key);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
});
|
|
70
|
+
}, widgetSpec);
|
|
54
71
|
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @jsx jsx
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
6
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
7
7
|
|
|
8
8
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
9
9
|
import { css, jsx } from '@emotion/react';
|
|
@@ -17,8 +17,8 @@ import { tableControlsSpacing } from '@atlaskit/editor-common/styles';
|
|
|
17
17
|
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
18
18
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
19
19
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
20
|
+
import DragHandleVerticalIcon from '@atlaskit/icon/core/drag-handle-vertical';
|
|
20
21
|
import DragHandlerIcon from '@atlaskit/icon/glyph/drag-handler';
|
|
21
|
-
import DragHandleVerticalIcon from '@atlaskit/icon/utility/drag-handle-vertical';
|
|
22
22
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
23
23
|
import { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
24
24
|
import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview';
|
|
@@ -265,11 +265,14 @@ export const DragHandle = ({
|
|
|
265
265
|
anchorRectCache
|
|
266
266
|
}) => {
|
|
267
267
|
var _api$core2, _api$blockControls3, _api$analytics2, _api$core4;
|
|
268
|
-
const start = getPos();
|
|
269
268
|
const buttonRef = useRef(null);
|
|
270
|
-
const [blockCardWidth, setBlockCardWidth] = useState(768);
|
|
271
269
|
const [dragHandleSelected, setDragHandleSelected] = useState(false);
|
|
272
270
|
const [dragHandleDisabled, setDragHandleDisabled] = useState(false);
|
|
271
|
+
const [blockCardWidth, setBlockCardWidth] = useState(768);
|
|
272
|
+
const [recalculatePosition, setRecalculatePosition] = useState(false);
|
|
273
|
+
const [positionStylesOld, setPositionStylesOld] = useState({
|
|
274
|
+
display: 'none'
|
|
275
|
+
});
|
|
273
276
|
const {
|
|
274
277
|
macroInteractionUpdates
|
|
275
278
|
} = useDragHandlePluginState(api);
|
|
@@ -277,9 +280,13 @@ export const DragHandle = ({
|
|
|
277
280
|
const isShiftDown = useSharedPluginStateSelector(api, 'blockControls.isShiftDown');
|
|
278
281
|
const _hasHadInteraction = useSharedPluginStateSelector(api, 'interaction.hasHadInteraction') !== false;
|
|
279
282
|
const interactionState = useSharedPluginStateSelector(api, 'interaction.interactionState');
|
|
283
|
+
const start = getPos();
|
|
280
284
|
const isLayoutColumn = nodeType === 'layoutColumn';
|
|
281
285
|
const isMultiSelect = editorExperiment('platform_editor_element_drag_and_drop_multiselect', true);
|
|
282
286
|
useEffect(() => {
|
|
287
|
+
if (editorExperiment('platform_editor_block_control_optimise_render', true)) {
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
283
290
|
// blockCard/datasource width is rendered correctly after this decoraton does. We need to observe for changes.
|
|
284
291
|
if (nodeType === 'blockCard') {
|
|
285
292
|
const dom = view.dom.querySelector(`[data-drag-handler-anchor-name="${anchorName}"]`);
|
|
@@ -571,7 +578,63 @@ export const DragHandle = ({
|
|
|
571
578
|
}
|
|
572
579
|
});
|
|
573
580
|
}, [anchorName, api, getPos, isMultiSelect, nodeType, start, view]);
|
|
574
|
-
const
|
|
581
|
+
const positionStyles = useMemo(() => {
|
|
582
|
+
if (!editorExperiment('platform_editor_block_control_optimise_render', true)) {
|
|
583
|
+
return {};
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
// This is a no-op to allow recalculatePosition to be used as a dependency
|
|
587
|
+
if (recalculatePosition) {
|
|
588
|
+
setRecalculatePosition(recalculatePosition);
|
|
589
|
+
}
|
|
590
|
+
const pos = getPos();
|
|
591
|
+
const $pos = pos && view.state.doc.resolve(pos);
|
|
592
|
+
const parentPos = $pos && $pos.depth ? $pos.before() : undefined;
|
|
593
|
+
const node = parentPos !== undefined ? view.state.doc.nodeAt(parentPos) : undefined;
|
|
594
|
+
const parentNodeType = node === null || node === void 0 ? void 0 : node.type.name;
|
|
595
|
+
const supportsAnchor = CSS.supports('top', `anchor(${anchorName} start)`) && CSS.supports('left', `anchor(${anchorName} start)`);
|
|
596
|
+
const safeAnchorName = editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_2') ? refreshAnchorName({
|
|
597
|
+
getPos,
|
|
598
|
+
view,
|
|
599
|
+
anchorName
|
|
600
|
+
}) : anchorName;
|
|
601
|
+
const dom = view.dom.querySelector(`[data-drag-handler-anchor-name="${safeAnchorName}"]`);
|
|
602
|
+
const hasResizer = nodeType === 'table' || nodeType === 'mediaSingle';
|
|
603
|
+
const isExtension = nodeType === 'extension' || nodeType === 'bodiedExtension' || nodeType === 'multiBodiedExtension' && fg('platform_editor_multi_body_extension_extensibility');
|
|
604
|
+
const isBlockCard = nodeType === 'blockCard';
|
|
605
|
+
const isEmbedCard = nodeType === 'embedCard';
|
|
606
|
+
const isMacroInteractionUpdates = macroInteractionUpdates && isExtension;
|
|
607
|
+
let innerContainer = null;
|
|
608
|
+
if (dom) {
|
|
609
|
+
if (isEmbedCard) {
|
|
610
|
+
innerContainer = dom.querySelector('.rich-media-item');
|
|
611
|
+
} else if (hasResizer) {
|
|
612
|
+
innerContainer = dom.querySelector('.resizer-item');
|
|
613
|
+
} else if (isExtension) {
|
|
614
|
+
innerContainer = dom.querySelector('.extension-container[data-layout]');
|
|
615
|
+
} else if (isBlockCard) {
|
|
616
|
+
//specific to datasource blockCard
|
|
617
|
+
innerContainer = dom.querySelector('.datasourceView-content-inner-wrap');
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
const isEdgeCase = (hasResizer || isExtension || isEmbedCard || isBlockCard) && innerContainer;
|
|
621
|
+
const isSticky = shouldBeSticky(nodeType);
|
|
622
|
+
if (supportsAnchor) {
|
|
623
|
+
const bottom = editorExperiment('platform_editor_controls', 'variant1') ? getControlBottomCSSValue(safeAnchorName, isSticky, isTopLevelNode, isLayoutColumn) : {};
|
|
624
|
+
return {
|
|
625
|
+
left: isEdgeCase ? `calc(anchor(${safeAnchorName} start) + ${getLeftPosition(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType)})` : editorExperiment('advanced_layouts', true) && isLayoutColumn ? `calc((anchor(${safeAnchorName} right) + anchor(${safeAnchorName} left))/2 - ${DRAG_HANDLE_HEIGHT / 2}px)` : `calc(anchor(${safeAnchorName} start) - ${DRAG_HANDLE_WIDTH}px - ${dragHandleGap(nodeType, parentNodeType)}px)`,
|
|
626
|
+
top: editorExperiment('advanced_layouts', true) && isLayoutColumn ? `calc(anchor(${safeAnchorName} top) - ${DRAG_HANDLE_WIDTH}px)` : `calc(anchor(${safeAnchorName} start) + ${topPositionAdjustment(nodeType)}px)`,
|
|
627
|
+
...bottom
|
|
628
|
+
};
|
|
629
|
+
}
|
|
630
|
+
const height = editorExperiment('platform_editor_controls', 'variant1') ? getControlHeightCSSValue(getNodeHeight(dom, safeAnchorName, anchorRectCache) || 0, isSticky, isTopLevelNode, `${DRAG_HANDLE_HEIGHT}`, isLayoutColumn) : {};
|
|
631
|
+
return {
|
|
632
|
+
left: isEdgeCase ? `calc(${(dom === null || dom === void 0 ? void 0 : dom.offsetLeft) || 0}px + ${getLeftPosition(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType)})` : getLeftPosition(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType),
|
|
633
|
+
top: getTopPosition(dom, nodeType),
|
|
634
|
+
...height
|
|
635
|
+
};
|
|
636
|
+
}, [anchorName, getPos, view, nodeType, macroInteractionUpdates, anchorRectCache, isTopLevelNode, isLayoutColumn, recalculatePosition]);
|
|
637
|
+
const calculatePositionOld = useCallback(() => {
|
|
575
638
|
const pos = getPos();
|
|
576
639
|
const $pos = pos && view.state.doc.resolve(pos);
|
|
577
640
|
const parentPos = $pos && $pos.depth ? $pos.before() : undefined;
|
|
@@ -619,10 +682,10 @@ export const DragHandle = ({
|
|
|
619
682
|
...height
|
|
620
683
|
};
|
|
621
684
|
}, [anchorName, getPos, view, nodeType, blockCardWidth, macroInteractionUpdates, anchorRectCache, isTopLevelNode, isLayoutColumn]);
|
|
622
|
-
const [positionStyles, setPositionStyles] = useState({
|
|
623
|
-
display: 'none'
|
|
624
|
-
});
|
|
625
685
|
useEffect(() => {
|
|
686
|
+
if (editorExperiment('platform_editor_block_control_optimise_render', true)) {
|
|
687
|
+
return;
|
|
688
|
+
}
|
|
626
689
|
let cleanUpTransitionListener;
|
|
627
690
|
if (nodeType === 'extension' || nodeType === 'embedCard') {
|
|
628
691
|
const dom = view.dom.querySelector(`[data-drag-handler-anchor-name="${anchorName}"]`);
|
|
@@ -632,19 +695,41 @@ export const DragHandle = ({
|
|
|
632
695
|
cleanUpTransitionListener = bind(dom, {
|
|
633
696
|
type: 'transitionend',
|
|
634
697
|
listener: () => {
|
|
635
|
-
|
|
698
|
+
setPositionStylesOld(calculatePositionOld());
|
|
636
699
|
}
|
|
637
700
|
});
|
|
638
701
|
}
|
|
639
702
|
const calcPos = requestAnimationFrame(() => {
|
|
640
|
-
|
|
703
|
+
setPositionStylesOld(calculatePositionOld());
|
|
641
704
|
});
|
|
642
705
|
return () => {
|
|
643
706
|
var _cleanUpTransitionLis;
|
|
644
707
|
cancelAnimationFrame(calcPos);
|
|
645
708
|
(_cleanUpTransitionLis = cleanUpTransitionListener) === null || _cleanUpTransitionLis === void 0 ? void 0 : _cleanUpTransitionLis();
|
|
646
709
|
};
|
|
647
|
-
}, [
|
|
710
|
+
}, [calculatePositionOld, view.dom, anchorName, nodeType]);
|
|
711
|
+
useEffect(() => {
|
|
712
|
+
if (!editorExperiment('platform_editor_block_control_optimise_render', true)) {
|
|
713
|
+
return;
|
|
714
|
+
}
|
|
715
|
+
let cleanUpTransitionListener;
|
|
716
|
+
if (nodeType === 'extension' || nodeType === 'embedCard') {
|
|
717
|
+
const dom = view.dom.querySelector(`[data-drag-handler-anchor-name="${anchorName}"]`);
|
|
718
|
+
if (!dom) {
|
|
719
|
+
return;
|
|
720
|
+
}
|
|
721
|
+
cleanUpTransitionListener = bind(dom, {
|
|
722
|
+
type: 'transitionend',
|
|
723
|
+
listener: () => {
|
|
724
|
+
setRecalculatePosition(!recalculatePosition);
|
|
725
|
+
}
|
|
726
|
+
});
|
|
727
|
+
}
|
|
728
|
+
return () => {
|
|
729
|
+
var _cleanUpTransitionLis2;
|
|
730
|
+
(_cleanUpTransitionLis2 = cleanUpTransitionListener) === null || _cleanUpTransitionLis2 === void 0 ? void 0 : _cleanUpTransitionLis2();
|
|
731
|
+
};
|
|
732
|
+
}, [view, anchorName, nodeType, recalculatePosition]);
|
|
648
733
|
useEffect(() => {
|
|
649
734
|
if (handleOptions !== null && handleOptions !== void 0 && handleOptions.isFocused && buttonRef.current && fg('platform_editor_element_drag_and_drop_ed_23873')) {
|
|
650
735
|
const id = requestAnimationFrame(() => {
|
|
@@ -653,7 +738,9 @@ export const DragHandle = ({
|
|
|
653
738
|
});
|
|
654
739
|
return () => {
|
|
655
740
|
cancelAnimationFrame(id);
|
|
656
|
-
|
|
741
|
+
if (!editorExperiment('platform_editor_block_control_optimise_render', true)) {
|
|
742
|
+
view.focus();
|
|
743
|
+
}
|
|
657
744
|
};
|
|
658
745
|
}
|
|
659
746
|
}, [buttonRef, handleOptions === null || handleOptions === void 0 ? void 0 : handleOptions.isFocused, view]);
|
|
@@ -662,7 +749,7 @@ export const DragHandle = ({
|
|
|
662
749
|
return;
|
|
663
750
|
}
|
|
664
751
|
setDragHandleSelected(isHandleCorrelatedToSelection(view.state, selection, start));
|
|
665
|
-
}, [start, selection, view
|
|
752
|
+
}, [start, selection, view, isMultiSelect]);
|
|
666
753
|
useEffect(() => {
|
|
667
754
|
var _api$blockControls$sh4;
|
|
668
755
|
if (!isMultiSelect || isShiftDown === undefined || view.state.selection.empty || !fg('platform_editor_elements_dnd_shift_click_select')) {
|
|
@@ -675,7 +762,7 @@ export const DragHandle = ({
|
|
|
675
762
|
} else {
|
|
676
763
|
setDragHandleDisabled(false);
|
|
677
764
|
}
|
|
678
|
-
}, [api === null || api === void 0 ? void 0 : api.blockControls.sharedState, isMultiSelect, isShiftDown, isTopLevelNode, view
|
|
765
|
+
}, [api === null || api === void 0 ? void 0 : api.blockControls.sharedState, isMultiSelect, isShiftDown, isTopLevelNode, view]);
|
|
679
766
|
let helpDescriptors = isTopLevelNode ? [{
|
|
680
767
|
description: formatMessage(blockControlsMessages.dragToMove)
|
|
681
768
|
}, {
|
|
@@ -759,7 +846,7 @@ export const DragHandle = ({
|
|
|
759
846
|
ref: buttonRef
|
|
760
847
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
761
848
|
,
|
|
762
|
-
style: !editorExperiment('platform_editor_controls', 'variant1')
|
|
849
|
+
style: !editorExperiment('platform_editor_controls', 'variant1') ? editorExperiment('platform_editor_block_control_optimise_render', true) ? positionStyles : positionStylesOld : {},
|
|
763
850
|
onClick: handleOnClick,
|
|
764
851
|
onMouseDown: handleMouseDown,
|
|
765
852
|
onKeyDown: handleKeyDown
|
|
@@ -778,12 +865,13 @@ export const DragHandle = ({
|
|
|
778
865
|
spacing: "spacious",
|
|
779
866
|
label: "",
|
|
780
867
|
LEGACY_fallbackIcon: DragHandlerIcon,
|
|
781
|
-
LEGACY_size: "medium"
|
|
868
|
+
LEGACY_size: "medium",
|
|
869
|
+
size: "small"
|
|
782
870
|
})));
|
|
783
871
|
const stickyWithTooltip = () => jsx(Box
|
|
784
872
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
785
873
|
, {
|
|
786
|
-
style: positionStyles,
|
|
874
|
+
style: editorExperiment('platform_editor_block_control_optimise_render', true) ? positionStyles : positionStylesOld,
|
|
787
875
|
xcss: [dragHandleContainerStyles],
|
|
788
876
|
as: "span",
|
|
789
877
|
testId: "block-ctrl-drag-handle-container"
|
|
@@ -807,7 +895,7 @@ export const DragHandle = ({
|
|
|
807
895
|
const stickyWithoutTooltip = () => jsx(Box
|
|
808
896
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
809
897
|
, {
|
|
810
|
-
style: positionStyles,
|
|
898
|
+
style: editorExperiment('platform_editor_block_control_optimise_render', true) ? positionStyles : positionStylesOld,
|
|
811
899
|
xcss: [dragHandleContainerStyles],
|
|
812
900
|
as: "span",
|
|
813
901
|
testId: "block-ctrl-drag-handle-container"
|
|
@@ -840,6 +928,7 @@ export const DragHandleWithVisibility = ({
|
|
|
840
928
|
getPos,
|
|
841
929
|
anchorName,
|
|
842
930
|
nodeType,
|
|
931
|
+
handleOptions,
|
|
843
932
|
anchorRectCache
|
|
844
933
|
}) => {
|
|
845
934
|
return jsx(VisibilityContainer, {
|
|
@@ -851,6 +940,7 @@ export const DragHandleWithVisibility = ({
|
|
|
851
940
|
getPos: getPos,
|
|
852
941
|
anchorName: anchorName,
|
|
853
942
|
nodeType: nodeType,
|
|
943
|
+
handleOptions: handleOptions,
|
|
854
944
|
anchorRectCache: anchorRectCache
|
|
855
945
|
}));
|
|
856
946
|
};
|
|
@@ -23,9 +23,41 @@ export var findHandleDec = function findHandleDec(decorations, from, to) {
|
|
|
23
23
|
});
|
|
24
24
|
};
|
|
25
25
|
export var dragHandleDecoration = function dragHandleDecoration(api, formatMessage, pos, anchorName, nodeType, nodeViewPortalProviderAPI, handleOptions, anchorRectCache) {
|
|
26
|
-
|
|
26
|
+
if (!editorExperiment('platform_editor_block_control_optimise_render', true, {
|
|
27
|
+
exposure: true
|
|
28
|
+
})) {
|
|
29
|
+
unmountDecorations(nodeViewPortalProviderAPI, 'data-blocks-drag-handle-container', 'data-blocks-drag-handle-key');
|
|
30
|
+
}
|
|
27
31
|
var unbind;
|
|
28
32
|
var key = uuid();
|
|
33
|
+
var widgetSpec = editorExperiment('platform_editor_breakout_resizing', true) ? {
|
|
34
|
+
side: -1,
|
|
35
|
+
type: TYPE_HANDLE_DEC,
|
|
36
|
+
testid: "".concat(TYPE_HANDLE_DEC, "-").concat(uuid()),
|
|
37
|
+
/**
|
|
38
|
+
* sigh - `marks` influences the position that the widget is drawn (as described on the `side` property).
|
|
39
|
+
* Leaving this 'undefined' causes the widget to be wrapped in the mark before this position which creates
|
|
40
|
+
* weird stacking context issues. Providing an empty array causes the widget to correctly render before
|
|
41
|
+
* this exact position at the top of the DOM.
|
|
42
|
+
*/
|
|
43
|
+
marks: [],
|
|
44
|
+
destroy: function destroy(node) {
|
|
45
|
+
unbind && unbind();
|
|
46
|
+
if (editorExperiment('platform_editor_block_control_optimise_render', true) && node instanceof HTMLElement) {
|
|
47
|
+
ReactDOM.unmountComponentAtNode(node);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
} : {
|
|
51
|
+
side: -1,
|
|
52
|
+
type: TYPE_HANDLE_DEC,
|
|
53
|
+
testid: "".concat(TYPE_HANDLE_DEC, "-").concat(uuid()),
|
|
54
|
+
destroy: function destroy(node) {
|
|
55
|
+
unbind && unbind();
|
|
56
|
+
if (editorExperiment('platform_editor_block_control_optimise_render', true) && node instanceof HTMLElement) {
|
|
57
|
+
ReactDOM.unmountComponentAtNode(node);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
29
61
|
return Decoration.widget(pos, function (view, getPosUnsafe) {
|
|
30
62
|
var element = document.createElement('span');
|
|
31
63
|
// inline decoration causes focus issues when refocusing Editor into first line
|
|
@@ -115,12 +147,5 @@ export var dragHandleDecoration = function dragHandleDecoration(api, formatMessa
|
|
|
115
147
|
}), element);
|
|
116
148
|
}
|
|
117
149
|
return element;
|
|
118
|
-
},
|
|
119
|
-
side: -1,
|
|
120
|
-
type: TYPE_HANDLE_DEC,
|
|
121
|
-
testid: "".concat(TYPE_HANDLE_DEC, "-").concat(uuid()),
|
|
122
|
-
destroy: function destroy(_) {
|
|
123
|
-
unbind && unbind();
|
|
124
|
-
}
|
|
125
|
-
});
|
|
150
|
+
}, widgetSpec);
|
|
126
151
|
};
|
|
@@ -2,6 +2,7 @@ import { createElement } from 'react';
|
|
|
2
2
|
import uuid from 'uuid';
|
|
3
3
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
4
4
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
5
6
|
import { QuickInsertWithVisibility, TypeAheadControl } from '../ui/quick-insert-button';
|
|
6
7
|
var TYPE_QUICK_INSERT = 'INSERT_BUTTON';
|
|
7
8
|
export var findQuickInsertInsertButtonDecoration = function findQuickInsertInsertButtonDecoration(decorations, from, to) {
|
|
@@ -11,6 +12,30 @@ export var findQuickInsertInsertButtonDecoration = function findQuickInsertInser
|
|
|
11
12
|
};
|
|
12
13
|
export var quickInsertButtonDecoration = function quickInsertButtonDecoration(api, formatMessage, rootPos, anchorName, nodeType, nodeViewPortalProviderAPI, rootAnchorName, rootNodeType, anchorRectCache) {
|
|
13
14
|
var key = uuid();
|
|
15
|
+
var widgetSpec = editorExperiment('platform_editor_breakout_resizing', true) ? {
|
|
16
|
+
side: -2,
|
|
17
|
+
type: TYPE_QUICK_INSERT,
|
|
18
|
+
/**
|
|
19
|
+
* sigh - `marks` influences the position that the widget is drawn (as described on the `side` property).
|
|
20
|
+
* Leaving this 'undefined' causes the widget to be wrapped in the mark before this position which creates
|
|
21
|
+
* weird stacking context issues. Providing an empty array causes the widget to correctly render before
|
|
22
|
+
* this exact position at the top of the DOM.
|
|
23
|
+
*/
|
|
24
|
+
marks: [],
|
|
25
|
+
destroy: function destroy(_) {
|
|
26
|
+
if (fg('platform_editor_fix_widget_destroy')) {
|
|
27
|
+
nodeViewPortalProviderAPI.remove(key);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
} : {
|
|
31
|
+
side: -2,
|
|
32
|
+
type: TYPE_QUICK_INSERT,
|
|
33
|
+
destroy: function destroy(_) {
|
|
34
|
+
if (fg('platform_editor_fix_widget_destroy')) {
|
|
35
|
+
nodeViewPortalProviderAPI.remove(key);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
14
39
|
return Decoration.widget(rootPos, function (view, getPos) {
|
|
15
40
|
var element = document.createElement('span');
|
|
16
41
|
element.contentEditable = 'false';
|
|
@@ -48,13 +73,5 @@ export var quickInsertButtonDecoration = function quickInsertButtonDecoration(ap
|
|
|
48
73
|
}, element, key);
|
|
49
74
|
}
|
|
50
75
|
return element;
|
|
51
|
-
},
|
|
52
|
-
side: -2,
|
|
53
|
-
type: TYPE_QUICK_INSERT,
|
|
54
|
-
destroy: function destroy(_) {
|
|
55
|
-
if (fg('platform_editor_fix_widget_destroy')) {
|
|
56
|
-
nodeViewPortalProviderAPI.remove(key);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
});
|
|
76
|
+
}, widgetSpec);
|
|
60
77
|
};
|
|
@@ -8,7 +8,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
8
8
|
* @jsx jsx
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
11
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
12
12
|
|
|
13
13
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
14
14
|
import { css, jsx } from '@emotion/react';
|
|
@@ -22,8 +22,8 @@ import { tableControlsSpacing } from '@atlaskit/editor-common/styles';
|
|
|
22
22
|
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
23
23
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
24
24
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
25
|
+
import DragHandleVerticalIcon from '@atlaskit/icon/core/drag-handle-vertical';
|
|
25
26
|
import DragHandlerIcon from '@atlaskit/icon/glyph/drag-handler';
|
|
26
|
-
import DragHandleVerticalIcon from '@atlaskit/icon/utility/drag-handle-vertical';
|
|
27
27
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
28
28
|
import { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
29
29
|
import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview';
|
|
@@ -269,29 +269,42 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
269
269
|
_ref$isTopLevelNode = _ref.isTopLevelNode,
|
|
270
270
|
isTopLevelNode = _ref$isTopLevelNode === void 0 ? true : _ref$isTopLevelNode,
|
|
271
271
|
anchorRectCache = _ref.anchorRectCache;
|
|
272
|
-
var start = getPos();
|
|
273
272
|
var buttonRef = useRef(null);
|
|
274
|
-
var _useState = useState(
|
|
273
|
+
var _useState = useState(false),
|
|
275
274
|
_useState2 = _slicedToArray(_useState, 2),
|
|
276
|
-
|
|
277
|
-
|
|
275
|
+
dragHandleSelected = _useState2[0],
|
|
276
|
+
setDragHandleSelected = _useState2[1];
|
|
278
277
|
var _useState3 = useState(false),
|
|
279
278
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
var _useState5 = useState(
|
|
279
|
+
dragHandleDisabled = _useState4[0],
|
|
280
|
+
setDragHandleDisabled = _useState4[1];
|
|
281
|
+
var _useState5 = useState(768),
|
|
283
282
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
284
|
-
|
|
285
|
-
|
|
283
|
+
blockCardWidth = _useState6[0],
|
|
284
|
+
setBlockCardWidth = _useState6[1];
|
|
285
|
+
var _useState7 = useState(false),
|
|
286
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
287
|
+
recalculatePosition = _useState8[0],
|
|
288
|
+
setRecalculatePosition = _useState8[1];
|
|
289
|
+
var _useState9 = useState({
|
|
290
|
+
display: 'none'
|
|
291
|
+
}),
|
|
292
|
+
_useState0 = _slicedToArray(_useState9, 2),
|
|
293
|
+
positionStylesOld = _useState0[0],
|
|
294
|
+
setPositionStylesOld = _useState0[1];
|
|
286
295
|
var _useDragHandlePluginS = useDragHandlePluginState(api),
|
|
287
296
|
macroInteractionUpdates = _useDragHandlePluginS.macroInteractionUpdates;
|
|
288
297
|
var selection = useSharedPluginStateSelector(api, 'selection.selection');
|
|
289
298
|
var isShiftDown = useSharedPluginStateSelector(api, 'blockControls.isShiftDown');
|
|
290
299
|
var _hasHadInteraction = useSharedPluginStateSelector(api, 'interaction.hasHadInteraction') !== false;
|
|
291
300
|
var interactionState = useSharedPluginStateSelector(api, 'interaction.interactionState');
|
|
301
|
+
var start = getPos();
|
|
292
302
|
var isLayoutColumn = nodeType === 'layoutColumn';
|
|
293
303
|
var isMultiSelect = editorExperiment('platform_editor_element_drag_and_drop_multiselect', true);
|
|
294
304
|
useEffect(function () {
|
|
305
|
+
if (editorExperiment('platform_editor_block_control_optimise_render', true)) {
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
295
308
|
// blockCard/datasource width is rendered correctly after this decoraton does. We need to observe for changes.
|
|
296
309
|
if (nodeType === 'blockCard') {
|
|
297
310
|
var dom = view.dom.querySelector("[data-drag-handler-anchor-name=\"".concat(anchorName, "\"]"));
|
|
@@ -578,7 +591,61 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
578
591
|
}
|
|
579
592
|
});
|
|
580
593
|
}, [anchorName, api, getPos, isMultiSelect, nodeType, start, view]);
|
|
581
|
-
var
|
|
594
|
+
var positionStyles = useMemo(function () {
|
|
595
|
+
if (!editorExperiment('platform_editor_block_control_optimise_render', true)) {
|
|
596
|
+
return {};
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
// This is a no-op to allow recalculatePosition to be used as a dependency
|
|
600
|
+
if (recalculatePosition) {
|
|
601
|
+
setRecalculatePosition(recalculatePosition);
|
|
602
|
+
}
|
|
603
|
+
var pos = getPos();
|
|
604
|
+
var $pos = pos && view.state.doc.resolve(pos);
|
|
605
|
+
var parentPos = $pos && $pos.depth ? $pos.before() : undefined;
|
|
606
|
+
var node = parentPos !== undefined ? view.state.doc.nodeAt(parentPos) : undefined;
|
|
607
|
+
var parentNodeType = node === null || node === void 0 ? void 0 : node.type.name;
|
|
608
|
+
var supportsAnchor = CSS.supports('top', "anchor(".concat(anchorName, " start)")) && CSS.supports('left', "anchor(".concat(anchorName, " start)"));
|
|
609
|
+
var safeAnchorName = editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_2') ? refreshAnchorName({
|
|
610
|
+
getPos: getPos,
|
|
611
|
+
view: view,
|
|
612
|
+
anchorName: anchorName
|
|
613
|
+
}) : anchorName;
|
|
614
|
+
var dom = view.dom.querySelector("[data-drag-handler-anchor-name=\"".concat(safeAnchorName, "\"]"));
|
|
615
|
+
var hasResizer = nodeType === 'table' || nodeType === 'mediaSingle';
|
|
616
|
+
var isExtension = nodeType === 'extension' || nodeType === 'bodiedExtension' || nodeType === 'multiBodiedExtension' && fg('platform_editor_multi_body_extension_extensibility');
|
|
617
|
+
var isBlockCard = nodeType === 'blockCard';
|
|
618
|
+
var isEmbedCard = nodeType === 'embedCard';
|
|
619
|
+
var isMacroInteractionUpdates = macroInteractionUpdates && isExtension;
|
|
620
|
+
var innerContainer = null;
|
|
621
|
+
if (dom) {
|
|
622
|
+
if (isEmbedCard) {
|
|
623
|
+
innerContainer = dom.querySelector('.rich-media-item');
|
|
624
|
+
} else if (hasResizer) {
|
|
625
|
+
innerContainer = dom.querySelector('.resizer-item');
|
|
626
|
+
} else if (isExtension) {
|
|
627
|
+
innerContainer = dom.querySelector('.extension-container[data-layout]');
|
|
628
|
+
} else if (isBlockCard) {
|
|
629
|
+
//specific to datasource blockCard
|
|
630
|
+
innerContainer = dom.querySelector('.datasourceView-content-inner-wrap');
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
var isEdgeCase = (hasResizer || isExtension || isEmbedCard || isBlockCard) && innerContainer;
|
|
634
|
+
var isSticky = shouldBeSticky(nodeType);
|
|
635
|
+
if (supportsAnchor) {
|
|
636
|
+
var bottom = editorExperiment('platform_editor_controls', 'variant1') ? getControlBottomCSSValue(safeAnchorName, isSticky, isTopLevelNode, isLayoutColumn) : {};
|
|
637
|
+
return _objectSpread({
|
|
638
|
+
left: isEdgeCase ? "calc(anchor(".concat(safeAnchorName, " start) + ").concat(getLeftPosition(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType), ")") : editorExperiment('advanced_layouts', true) && isLayoutColumn ? "calc((anchor(".concat(safeAnchorName, " right) + anchor(").concat(safeAnchorName, " left))/2 - ").concat(DRAG_HANDLE_HEIGHT / 2, "px)") : "calc(anchor(".concat(safeAnchorName, " start) - ").concat(DRAG_HANDLE_WIDTH, "px - ").concat(dragHandleGap(nodeType, parentNodeType), "px)"),
|
|
639
|
+
top: editorExperiment('advanced_layouts', true) && isLayoutColumn ? "calc(anchor(".concat(safeAnchorName, " top) - ").concat(DRAG_HANDLE_WIDTH, "px)") : "calc(anchor(".concat(safeAnchorName, " start) + ").concat(topPositionAdjustment(nodeType), "px)")
|
|
640
|
+
}, bottom);
|
|
641
|
+
}
|
|
642
|
+
var height = editorExperiment('platform_editor_controls', 'variant1') ? getControlHeightCSSValue(getNodeHeight(dom, safeAnchorName, anchorRectCache) || 0, isSticky, isTopLevelNode, "".concat(DRAG_HANDLE_HEIGHT), isLayoutColumn) : {};
|
|
643
|
+
return _objectSpread({
|
|
644
|
+
left: isEdgeCase ? "calc(".concat((dom === null || dom === void 0 ? void 0 : dom.offsetLeft) || 0, "px + ").concat(getLeftPosition(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType), ")") : getLeftPosition(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType),
|
|
645
|
+
top: getTopPosition(dom, nodeType)
|
|
646
|
+
}, height);
|
|
647
|
+
}, [anchorName, getPos, view, nodeType, macroInteractionUpdates, anchorRectCache, isTopLevelNode, isLayoutColumn, recalculatePosition]);
|
|
648
|
+
var calculatePositionOld = useCallback(function () {
|
|
582
649
|
var pos = getPos();
|
|
583
650
|
var $pos = pos && view.state.doc.resolve(pos);
|
|
584
651
|
var parentPos = $pos && $pos.depth ? $pos.before() : undefined;
|
|
@@ -624,13 +691,10 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
624
691
|
top: getTopPosition(dom, nodeType)
|
|
625
692
|
}, height);
|
|
626
693
|
}, [anchorName, getPos, view, nodeType, blockCardWidth, macroInteractionUpdates, anchorRectCache, isTopLevelNode, isLayoutColumn]);
|
|
627
|
-
var _useState7 = useState({
|
|
628
|
-
display: 'none'
|
|
629
|
-
}),
|
|
630
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
631
|
-
positionStyles = _useState8[0],
|
|
632
|
-
setPositionStyles = _useState8[1];
|
|
633
694
|
useEffect(function () {
|
|
695
|
+
if (editorExperiment('platform_editor_block_control_optimise_render', true)) {
|
|
696
|
+
return;
|
|
697
|
+
}
|
|
634
698
|
var cleanUpTransitionListener;
|
|
635
699
|
if (nodeType === 'extension' || nodeType === 'embedCard') {
|
|
636
700
|
var dom = view.dom.querySelector("[data-drag-handler-anchor-name=\"".concat(anchorName, "\"]"));
|
|
@@ -640,19 +704,41 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
640
704
|
cleanUpTransitionListener = bind(dom, {
|
|
641
705
|
type: 'transitionend',
|
|
642
706
|
listener: function listener() {
|
|
643
|
-
|
|
707
|
+
setPositionStylesOld(calculatePositionOld());
|
|
644
708
|
}
|
|
645
709
|
});
|
|
646
710
|
}
|
|
647
711
|
var calcPos = requestAnimationFrame(function () {
|
|
648
|
-
|
|
712
|
+
setPositionStylesOld(calculatePositionOld());
|
|
649
713
|
});
|
|
650
714
|
return function () {
|
|
651
715
|
var _cleanUpTransitionLis;
|
|
652
716
|
cancelAnimationFrame(calcPos);
|
|
653
717
|
(_cleanUpTransitionLis = cleanUpTransitionListener) === null || _cleanUpTransitionLis === void 0 || _cleanUpTransitionLis();
|
|
654
718
|
};
|
|
655
|
-
}, [
|
|
719
|
+
}, [calculatePositionOld, view.dom, anchorName, nodeType]);
|
|
720
|
+
useEffect(function () {
|
|
721
|
+
if (!editorExperiment('platform_editor_block_control_optimise_render', true)) {
|
|
722
|
+
return;
|
|
723
|
+
}
|
|
724
|
+
var cleanUpTransitionListener;
|
|
725
|
+
if (nodeType === 'extension' || nodeType === 'embedCard') {
|
|
726
|
+
var dom = view.dom.querySelector("[data-drag-handler-anchor-name=\"".concat(anchorName, "\"]"));
|
|
727
|
+
if (!dom) {
|
|
728
|
+
return;
|
|
729
|
+
}
|
|
730
|
+
cleanUpTransitionListener = bind(dom, {
|
|
731
|
+
type: 'transitionend',
|
|
732
|
+
listener: function listener() {
|
|
733
|
+
setRecalculatePosition(!recalculatePosition);
|
|
734
|
+
}
|
|
735
|
+
});
|
|
736
|
+
}
|
|
737
|
+
return function () {
|
|
738
|
+
var _cleanUpTransitionLis2;
|
|
739
|
+
(_cleanUpTransitionLis2 = cleanUpTransitionListener) === null || _cleanUpTransitionLis2 === void 0 || _cleanUpTransitionLis2();
|
|
740
|
+
};
|
|
741
|
+
}, [view, anchorName, nodeType, recalculatePosition]);
|
|
656
742
|
useEffect(function () {
|
|
657
743
|
if (handleOptions !== null && handleOptions !== void 0 && handleOptions.isFocused && buttonRef.current && fg('platform_editor_element_drag_and_drop_ed_23873')) {
|
|
658
744
|
var id = requestAnimationFrame(function () {
|
|
@@ -661,7 +747,9 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
661
747
|
});
|
|
662
748
|
return function () {
|
|
663
749
|
cancelAnimationFrame(id);
|
|
664
|
-
|
|
750
|
+
if (!editorExperiment('platform_editor_block_control_optimise_render', true)) {
|
|
751
|
+
view.focus();
|
|
752
|
+
}
|
|
665
753
|
};
|
|
666
754
|
}
|
|
667
755
|
}, [buttonRef, handleOptions === null || handleOptions === void 0 ? void 0 : handleOptions.isFocused, view]);
|
|
@@ -670,7 +758,7 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
670
758
|
return;
|
|
671
759
|
}
|
|
672
760
|
setDragHandleSelected(isHandleCorrelatedToSelection(view.state, selection, start));
|
|
673
|
-
}, [start, selection, view
|
|
761
|
+
}, [start, selection, view, isMultiSelect]);
|
|
674
762
|
useEffect(function () {
|
|
675
763
|
var _api$blockControls$sh4;
|
|
676
764
|
if (!isMultiSelect || isShiftDown === undefined || view.state.selection.empty || !fg('platform_editor_elements_dnd_shift_click_select')) {
|
|
@@ -683,7 +771,7 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
683
771
|
} else {
|
|
684
772
|
setDragHandleDisabled(false);
|
|
685
773
|
}
|
|
686
|
-
}, [api === null || api === void 0 ? void 0 : api.blockControls.sharedState, isMultiSelect, isShiftDown, isTopLevelNode, view
|
|
774
|
+
}, [api === null || api === void 0 ? void 0 : api.blockControls.sharedState, isMultiSelect, isShiftDown, isTopLevelNode, view]);
|
|
687
775
|
var helpDescriptors = isTopLevelNode ? [{
|
|
688
776
|
description: formatMessage(blockControlsMessages.dragToMove)
|
|
689
777
|
}, {
|
|
@@ -768,7 +856,7 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
768
856
|
ref: buttonRef
|
|
769
857
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
770
858
|
,
|
|
771
|
-
style: !editorExperiment('platform_editor_controls', 'variant1')
|
|
859
|
+
style: !editorExperiment('platform_editor_controls', 'variant1') ? editorExperiment('platform_editor_block_control_optimise_render', true) ? positionStyles : positionStylesOld : {},
|
|
772
860
|
onClick: handleOnClick,
|
|
773
861
|
onMouseDown: handleMouseDown,
|
|
774
862
|
onKeyDown: handleKeyDown
|
|
@@ -787,7 +875,8 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
787
875
|
spacing: "spacious",
|
|
788
876
|
label: "",
|
|
789
877
|
LEGACY_fallbackIcon: DragHandlerIcon,
|
|
790
|
-
LEGACY_size: "medium"
|
|
878
|
+
LEGACY_size: "medium",
|
|
879
|
+
size: "small"
|
|
791
880
|
})))
|
|
792
881
|
);
|
|
793
882
|
};
|
|
@@ -795,7 +884,7 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
795
884
|
return jsx(Box
|
|
796
885
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
797
886
|
, {
|
|
798
|
-
style: positionStyles,
|
|
887
|
+
style: editorExperiment('platform_editor_block_control_optimise_render', true) ? positionStyles : positionStylesOld,
|
|
799
888
|
xcss: [dragHandleContainerStyles],
|
|
800
889
|
as: "span",
|
|
801
890
|
testId: "block-ctrl-drag-handle-container"
|
|
@@ -821,7 +910,7 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
821
910
|
return jsx(Box
|
|
822
911
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
823
912
|
, {
|
|
824
|
-
style: positionStyles,
|
|
913
|
+
style: editorExperiment('platform_editor_block_control_optimise_render', true) ? positionStyles : positionStylesOld,
|
|
825
914
|
xcss: [dragHandleContainerStyles],
|
|
826
915
|
as: "span",
|
|
827
916
|
testId: "block-ctrl-drag-handle-container"
|
|
@@ -857,6 +946,7 @@ export var DragHandleWithVisibility = function DragHandleWithVisibility(_ref8) {
|
|
|
857
946
|
getPos = _ref8.getPos,
|
|
858
947
|
anchorName = _ref8.anchorName,
|
|
859
948
|
nodeType = _ref8.nodeType,
|
|
949
|
+
handleOptions = _ref8.handleOptions,
|
|
860
950
|
anchorRectCache = _ref8.anchorRectCache;
|
|
861
951
|
return jsx(VisibilityContainer, {
|
|
862
952
|
api: api
|
|
@@ -867,6 +957,7 @@ export var DragHandleWithVisibility = function DragHandleWithVisibility(_ref8) {
|
|
|
867
957
|
getPos: getPos,
|
|
868
958
|
anchorName: anchorName,
|
|
869
959
|
nodeType: nodeType,
|
|
960
|
+
handleOptions: handleOptions,
|
|
870
961
|
anchorRectCache: anchorRectCache
|
|
871
962
|
}));
|
|
872
963
|
};
|
|
@@ -16,5 +16,5 @@ type DragHandleProps = {
|
|
|
16
16
|
anchorRectCache?: AnchorRectCache;
|
|
17
17
|
};
|
|
18
18
|
export declare const DragHandle: ({ view, api, formatMessage, getPos, anchorName, nodeType, handleOptions, isTopLevelNode, anchorRectCache, }: DragHandleProps) => jsx.JSX.Element;
|
|
19
|
-
export declare const DragHandleWithVisibility: ({ view, api, formatMessage, getPos, anchorName, nodeType, anchorRectCache, }: DragHandleProps) => jsx.JSX.Element;
|
|
19
|
+
export declare const DragHandleWithVisibility: ({ view, api, formatMessage, getPos, anchorName, nodeType, handleOptions, anchorRectCache, }: DragHandleProps) => jsx.JSX.Element;
|
|
20
20
|
export {};
|
|
@@ -16,5 +16,5 @@ type DragHandleProps = {
|
|
|
16
16
|
anchorRectCache?: AnchorRectCache;
|
|
17
17
|
};
|
|
18
18
|
export declare const DragHandle: ({ view, api, formatMessage, getPos, anchorName, nodeType, handleOptions, isTopLevelNode, anchorRectCache, }: DragHandleProps) => jsx.JSX.Element;
|
|
19
|
-
export declare const DragHandleWithVisibility: ({ view, api, formatMessage, getPos, anchorName, nodeType, anchorRectCache, }: DragHandleProps) => jsx.JSX.Element;
|
|
19
|
+
export declare const DragHandleWithVisibility: ({ view, api, formatMessage, getPos, anchorName, nodeType, handleOptions, anchorRectCache, }: DragHandleProps) => jsx.JSX.Element;
|
|
20
20
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "3.15.
|
|
3
|
+
"version": "3.15.11",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@atlaskit/adf-schema": "^47.6.0",
|
|
36
|
-
"@atlaskit/editor-common": "^106.
|
|
36
|
+
"@atlaskit/editor-common": "^106.2.0",
|
|
37
37
|
"@atlaskit/editor-plugin-accessibility-utils": "^2.0.0",
|
|
38
38
|
"@atlaskit/editor-plugin-analytics": "^2.3.0",
|
|
39
39
|
"@atlaskit/editor-plugin-editor-disabled": "^2.0.0",
|
|
@@ -56,9 +56,9 @@
|
|
|
56
56
|
"@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^3.2.0",
|
|
57
57
|
"@atlaskit/primitives": "^14.8.0",
|
|
58
58
|
"@atlaskit/theme": "^18.0.0",
|
|
59
|
-
"@atlaskit/tmp-editor-statsig": "^5.
|
|
59
|
+
"@atlaskit/tmp-editor-statsig": "^5.12.0",
|
|
60
60
|
"@atlaskit/tokens": "^5.0.0",
|
|
61
|
-
"@atlaskit/tooltip": "^20.
|
|
61
|
+
"@atlaskit/tooltip": "^20.3.0",
|
|
62
62
|
"@babel/runtime": "^7.0.0",
|
|
63
63
|
"@emotion/react": "^11.7.1",
|
|
64
64
|
"bind-event-listener": "^3.0.0",
|