@atlaskit/editor-plugin-block-controls 13.2.16 → 13.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -0
- package/dist/cjs/pm-plugins/utils/drag-handle-positions.js +8 -1
- package/dist/cjs/ui/consts.js +3 -1
- package/dist/cjs/ui/drag-handle.js +70 -44
- package/dist/cjs/ui/global-styles.js +22 -5
- package/dist/cjs/ui/quick-insert-button.js +40 -28
- package/dist/cjs/ui/visibility-container.js +12 -5
- package/dist/es2019/pm-plugins/utils/drag-handle-positions.js +8 -1
- package/dist/es2019/ui/consts.js +2 -0
- package/dist/es2019/ui/drag-handle.js +33 -6
- package/dist/es2019/ui/global-styles.js +20 -6
- package/dist/es2019/ui/quick-insert-button.js +17 -4
- package/dist/es2019/ui/visibility-container.js +12 -5
- package/dist/esm/pm-plugins/utils/drag-handle-positions.js +8 -1
- package/dist/esm/ui/consts.js +2 -0
- package/dist/esm/ui/drag-handle.js +71 -45
- package/dist/esm/ui/global-styles.js +23 -6
- package/dist/esm/ui/quick-insert-button.js +41 -29
- package/dist/esm/ui/visibility-container.js +12 -5
- package/dist/types/pm-plugins/utils/drag-handle-positions.d.ts +1 -1
- package/dist/types/ui/consts.d.ts +2 -0
- package/dist/types/ui/visibility-container.d.ts +5 -1
- package/package.json +8 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 13.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`fee74586b3125`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/fee74586b3125) -
|
|
8
|
+
Improve block controls anchor reliability by adding control-specific fallback anchor names for
|
|
9
|
+
active drag-handle and quick-insert nodes.
|
|
10
|
+
|
|
11
|
+
When reliable-anchor mode is enabled, active nodes now expose fallback anchor names in addition to
|
|
12
|
+
`data-node-anchor`, so controls can resolve positioning even when primary anchor lookup is
|
|
13
|
+
temporarily out of sync.
|
|
14
|
+
|
|
15
|
+
Example of resulting CSS anchor usage:
|
|
16
|
+
- Drag handle:
|
|
17
|
+
`anchor(<data-node-anchor> start, anchor(--editor-block-controls-active-drag-handle-anchor start))`
|
|
18
|
+
- Quick insert:
|
|
19
|
+
`anchor(<data-node-anchor> start, anchor(--editor-block-controls-active-quick-insert-anchor start))`
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Updated dependencies
|
|
24
|
+
|
|
25
|
+
## 13.2.17
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- [`161922d5b8cee`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/161922d5b8cee) -
|
|
30
|
+
Fix editor tooltips affected by inline top-layer rendering. Table cell menu tooltips are no longer
|
|
31
|
+
constrained by the button background selector, and layout column drag handles now own their
|
|
32
|
+
wrapper layout without flattening the tooltip's visual surface.
|
|
33
|
+
- Updated dependencies
|
|
34
|
+
|
|
3
35
|
## 13.2.16
|
|
4
36
|
|
|
5
37
|
### Patch Changes
|
|
@@ -69,7 +69,14 @@ var getStickyNodes = (0, _memoizeOne.default)(function () {
|
|
|
69
69
|
var shouldBeSticky = exports.shouldBeSticky = function shouldBeSticky(nodeType) {
|
|
70
70
|
return (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && getStickyNodes().includes(nodeType);
|
|
71
71
|
};
|
|
72
|
-
var getControlBottomCSSValue = exports.getControlBottomCSSValue = function getControlBottomCSSValue(anchor, isSticky, isTopLevelNode, isLayoutColumn) {
|
|
72
|
+
var getControlBottomCSSValue = exports.getControlBottomCSSValue = function getControlBottomCSSValue(anchor, isSticky, isTopLevelNode, isLayoutColumn, fallbackAnchor) {
|
|
73
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_controls_reliable_anchor', 'isEnabled', true)) {
|
|
74
|
+
return (0, _experiments.editorExperiment)('advanced_layouts', true) && isLayoutColumn || !isSticky || !isTopLevelNode ? {
|
|
75
|
+
bottom: 'unset'
|
|
76
|
+
} : {
|
|
77
|
+
bottom: fallbackAnchor ? "anchor(".concat(anchor, " end, anchor(").concat(fallbackAnchor, " end))") : "anchor(".concat(anchor, " end)")
|
|
78
|
+
};
|
|
79
|
+
}
|
|
73
80
|
return (0, _experiments.editorExperiment)('advanced_layouts', true) && isLayoutColumn || !isSticky || !isTopLevelNode ? {
|
|
74
81
|
bottom: 'unset'
|
|
75
82
|
} : {
|
package/dist/cjs/ui/consts.js
CHANGED
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.topPositionAdjustment = exports.spacingBetweenNodesForPreview = exports.spaceLookupMap = exports.rootElementGap = exports.nodeMargins = exports.getNestedNodeLeftPaddingMargin = exports.dropTargetMarginMap = exports.dragHandleGap = exports.STICKY_CONTROLS_TOP_MARGIN_FOR_STICKY_HEADER = exports.STICKY_CONTROLS_TOP_MARGIN = exports.QUICK_INSERT_WIDTH = exports.QUICK_INSERT_LEFT_OFFSET = exports.QUICK_INSERT_HEIGHT = exports.QUICK_INSERT_DIMENSIONS = exports.DRAG_HANDLE_ZINDEX = exports.DRAG_HANDLE_WRAPPED_MEDIA_EMBED_TOP_ADJUSTMENT = exports.DRAG_HANDLE_SYNCED_BLOCK_GAP = exports.DRAG_HANDLE_PARAGRAPH_TOP_ADJUSTMENT = exports.DRAG_HANDLE_PARAGRAPH_SMALL_TOP_ADJUSTMENT = exports.DRAG_HANDLE_NARROW_GAP = exports.DRAG_HANDLE_MAX_WIDTH_PLUS_GAP = exports.DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH = exports.DRAG_HANDLE_MAX_GAP = exports.DRAG_HANDLE_LAYOUT_SECTION_TOP_ADJUSTMENT = exports.DRAG_HANDLE_HEIGHT = exports.DRAG_HANDLE_H6_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H5_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H4_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H3_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H2_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H1_TOP_ADJUSTMENT = exports.DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT = exports.DRAG_HANDLE_DEFAULT_GAP = exports.DRAG_HANDLE_BORDER_RADIUS = exports.DEFAULT_COLUMN_DISTRIBUTIONS = exports.ACTIVE_QUICK_INSERT_ATTR = exports.ACTIVE_DRAG_HANDLE_ATTR = void 0;
|
|
7
|
+
exports.topPositionAdjustment = exports.spacingBetweenNodesForPreview = exports.spaceLookupMap = exports.rootElementGap = exports.nodeMargins = exports.getNestedNodeLeftPaddingMargin = exports.dropTargetMarginMap = exports.dragHandleGap = exports.STICKY_CONTROLS_TOP_MARGIN_FOR_STICKY_HEADER = exports.STICKY_CONTROLS_TOP_MARGIN = exports.QUICK_INSERT_WIDTH = exports.QUICK_INSERT_LEFT_OFFSET = exports.QUICK_INSERT_HEIGHT = exports.QUICK_INSERT_DIMENSIONS = exports.DRAG_HANDLE_ZINDEX = exports.DRAG_HANDLE_WRAPPED_MEDIA_EMBED_TOP_ADJUSTMENT = exports.DRAG_HANDLE_SYNCED_BLOCK_GAP = exports.DRAG_HANDLE_PARAGRAPH_TOP_ADJUSTMENT = exports.DRAG_HANDLE_PARAGRAPH_SMALL_TOP_ADJUSTMENT = exports.DRAG_HANDLE_NARROW_GAP = exports.DRAG_HANDLE_MAX_WIDTH_PLUS_GAP = exports.DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH = exports.DRAG_HANDLE_MAX_GAP = exports.DRAG_HANDLE_LAYOUT_SECTION_TOP_ADJUSTMENT = exports.DRAG_HANDLE_HEIGHT = exports.DRAG_HANDLE_H6_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H5_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H4_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H3_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H2_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H1_TOP_ADJUSTMENT = exports.DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT = exports.DRAG_HANDLE_DEFAULT_GAP = exports.DRAG_HANDLE_BORDER_RADIUS = exports.DEFAULT_COLUMN_DISTRIBUTIONS = exports.ACTIVE_QUICK_INSERT_FALLBACK_ANCHOR_NAME = exports.ACTIVE_QUICK_INSERT_ATTR = exports.ACTIVE_DRAG_HANDLE_FALLBACK_ANCHOR_NAME = exports.ACTIVE_DRAG_HANDLE_ATTR = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
10
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
@@ -16,6 +16,8 @@ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
|
16
16
|
var _dropTargetMarginMap;
|
|
17
17
|
var ACTIVE_DRAG_HANDLE_ATTR = exports.ACTIVE_DRAG_HANDLE_ATTR = 'data-active-drag-handle';
|
|
18
18
|
var ACTIVE_QUICK_INSERT_ATTR = exports.ACTIVE_QUICK_INSERT_ATTR = 'data-active-quick-insert';
|
|
19
|
+
var ACTIVE_DRAG_HANDLE_FALLBACK_ANCHOR_NAME = exports.ACTIVE_DRAG_HANDLE_FALLBACK_ANCHOR_NAME = '--editor-block-controls-active-drag-handle-anchor';
|
|
20
|
+
var ACTIVE_QUICK_INSERT_FALLBACK_ANCHOR_NAME = exports.ACTIVE_QUICK_INSERT_FALLBACK_ANCHOR_NAME = '--editor-block-controls-active-quick-insert-anchor';
|
|
19
21
|
var DRAG_HANDLE_HEIGHT = exports.DRAG_HANDLE_HEIGHT = 24;
|
|
20
22
|
var DRAG_HANDLE_BORDER_RADIUS = exports.DRAG_HANDLE_BORDER_RADIUS = 4;
|
|
21
23
|
var DRAG_HANDLE_ZINDEX = exports.DRAG_HANDLE_ZINDEX = _editorSharedStyles.akRichMediaResizeZIndex + _editorSharedStyles.akEditorUnitZIndex; //place above legacy resizer
|
|
@@ -383,18 +383,26 @@ var buildToggleLayoutColumnMenuMeta = function buildToggleLayoutColumnMenuMeta(a
|
|
|
383
383
|
openedViaKeyboard: openedViaKeyboard
|
|
384
384
|
});
|
|
385
385
|
};
|
|
386
|
-
var
|
|
386
|
+
var getDragHandleAnchorReference = function getDragHandleAnchorReference(_ref) {
|
|
387
|
+
var edge = _ref.edge,
|
|
388
|
+
safeAnchorName = _ref.safeAnchorName;
|
|
389
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_controls_reliable_anchor', 'isEnabled', true)) {
|
|
390
|
+
return "anchor(".concat(safeAnchorName, " ").concat(edge, ", anchor(").concat(_consts2.ACTIVE_DRAG_HANDLE_FALLBACK_ANCHOR_NAME, " ").concat(edge, "))");
|
|
391
|
+
}
|
|
392
|
+
return "anchor(".concat(safeAnchorName, " ").concat(edge, ")");
|
|
393
|
+
};
|
|
394
|
+
var DragHandle = exports.DragHandle = function DragHandle(_ref2) {
|
|
387
395
|
var _api$core4, _api$blockControls8;
|
|
388
|
-
var view =
|
|
389
|
-
api =
|
|
390
|
-
formatMessage =
|
|
391
|
-
getPos =
|
|
392
|
-
anchorName =
|
|
393
|
-
nodeType =
|
|
394
|
-
handleOptions =
|
|
395
|
-
|
|
396
|
-
isTopLevelNode =
|
|
397
|
-
anchorRectCache =
|
|
396
|
+
var view = _ref2.view,
|
|
397
|
+
api = _ref2.api,
|
|
398
|
+
formatMessage = _ref2.formatMessage,
|
|
399
|
+
getPos = _ref2.getPos,
|
|
400
|
+
anchorName = _ref2.anchorName,
|
|
401
|
+
nodeType = _ref2.nodeType,
|
|
402
|
+
handleOptions = _ref2.handleOptions,
|
|
403
|
+
_ref2$isTopLevelNode = _ref2.isTopLevelNode,
|
|
404
|
+
isTopLevelNode = _ref2$isTopLevelNode === void 0 ? true : _ref2$isTopLevelNode,
|
|
405
|
+
anchorRectCache = _ref2.anchorRectCache;
|
|
398
406
|
var buttonRef = (0, _react.useRef)(null);
|
|
399
407
|
var mouseDownRef = (0, _react.useRef)(false);
|
|
400
408
|
var _useState = (0, _react.useState)(false),
|
|
@@ -507,9 +515,9 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
507
515
|
}, []);
|
|
508
516
|
var handleOnClickNew = (0, _react.useCallback)(function (e) {
|
|
509
517
|
var _api$core;
|
|
510
|
-
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (
|
|
518
|
+
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref3) {
|
|
511
519
|
var _selectionPreservatio, _api$analytics, _resolvedStartPos$nod, _api$blockControls, _api$blockControls2;
|
|
512
|
-
var tr =
|
|
520
|
+
var tr = _ref3.tr;
|
|
513
521
|
var startPos = getPos();
|
|
514
522
|
if (startPos === undefined) {
|
|
515
523
|
return tr;
|
|
@@ -558,9 +566,9 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
558
566
|
}, [api, view, getPos, nodeType, anchorName]);
|
|
559
567
|
var handleOnClick = (0, _react.useCallback)(function (e) {
|
|
560
568
|
var _api$core2;
|
|
561
|
-
api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(function (
|
|
569
|
+
api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(function (_ref4) {
|
|
562
570
|
var _api$blockControls$sh, _api$analytics2;
|
|
563
|
-
var tr =
|
|
571
|
+
var tr = _ref4.tr;
|
|
564
572
|
var startPos = getPos();
|
|
565
573
|
if (startPos === undefined) {
|
|
566
574
|
return tr;
|
|
@@ -603,8 +611,8 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
603
611
|
if (!e.repeat && e.key === ' ') {
|
|
604
612
|
var _api$core3;
|
|
605
613
|
var startPos = getPos();
|
|
606
|
-
api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(function (
|
|
607
|
-
var tr =
|
|
614
|
+
api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(function (_ref5) {
|
|
615
|
+
var tr = _ref5.tr;
|
|
608
616
|
if (startPos === undefined) {
|
|
609
617
|
return tr;
|
|
610
618
|
}
|
|
@@ -635,9 +643,9 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
635
643
|
e.preventDefault();
|
|
636
644
|
e.stopPropagation();
|
|
637
645
|
var startPos = getPos();
|
|
638
|
-
api === null || api === void 0 || (_api$core5 = api.core) === null || _api$core5 === void 0 || _api$core5.actions.execute(function (
|
|
646
|
+
api === null || api === void 0 || (_api$core5 = api.core) === null || _api$core5 === void 0 || _api$core5.actions.execute(function (_ref6) {
|
|
639
647
|
var _selectionPreservatio2, _api$blockControls4, _api$blockControls5, _api$userIntent;
|
|
640
|
-
var tr =
|
|
648
|
+
var tr = _ref6.tr;
|
|
641
649
|
if (startPos === undefined) {
|
|
642
650
|
return tr;
|
|
643
651
|
}
|
|
@@ -696,11 +704,11 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
696
704
|
start: start
|
|
697
705
|
};
|
|
698
706
|
},
|
|
699
|
-
onGenerateDragPreview: function onGenerateDragPreview(
|
|
707
|
+
onGenerateDragPreview: function onGenerateDragPreview(_ref7) {
|
|
700
708
|
var _api$core6, _api$blockControls$sh2;
|
|
701
|
-
var nativeSetDragImage =
|
|
702
|
-
api === null || api === void 0 || (_api$core6 = api.core) === null || _api$core6 === void 0 || _api$core6.actions.execute(function (
|
|
703
|
-
var tr =
|
|
709
|
+
var nativeSetDragImage = _ref7.nativeSetDragImage;
|
|
710
|
+
api === null || api === void 0 || (_api$core6 = api.core) === null || _api$core6 === void 0 || _api$core6.actions.execute(function (_ref8) {
|
|
711
|
+
var tr = _ref8.tr;
|
|
704
712
|
var handlePos = getPos();
|
|
705
713
|
if (typeof handlePos !== 'number') {
|
|
706
714
|
return tr;
|
|
@@ -777,8 +785,8 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
777
785
|
};
|
|
778
786
|
}
|
|
779
787
|
},
|
|
780
|
-
render: function render(
|
|
781
|
-
var container =
|
|
788
|
+
render: function render(_ref9) {
|
|
789
|
+
var container = _ref9.container;
|
|
782
790
|
var dom = view.dom.querySelector("[".concat((0, _domAttrName.getAnchorAttrName)(), "=\"").concat(anchorName, "\"]"));
|
|
783
791
|
if (!dom) {
|
|
784
792
|
return;
|
|
@@ -814,9 +822,9 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
814
822
|
if (start === undefined) {
|
|
815
823
|
return;
|
|
816
824
|
}
|
|
817
|
-
api === null || api === void 0 || (_api$core7 = api.core) === null || _api$core7 === void 0 || _api$core7.actions.execute(function (
|
|
825
|
+
api === null || api === void 0 || (_api$core7 = api.core) === null || _api$core7 === void 0 || _api$core7.actions.execute(function (_ref0) {
|
|
818
826
|
var _api$blockControls$sh3, _api$blockControls7, _api$analytics3;
|
|
819
|
-
var tr =
|
|
827
|
+
var tr = _ref0.tr;
|
|
820
828
|
var nodeTypes, hasSelectedMultipleNodes;
|
|
821
829
|
var resolvedMovingNode = tr.doc.resolve(start);
|
|
822
830
|
var maybeNode = resolvedMovingNode.nodeAfter;
|
|
@@ -893,10 +901,26 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
893
901
|
var isEdgeCase = (hasResizer || isExtension || isEmbedCard || isBlockCard) && innerContainer;
|
|
894
902
|
var isSticky = (0, _dragHandlePositions.shouldBeSticky)(nodeType);
|
|
895
903
|
if (supportsAnchor) {
|
|
896
|
-
var
|
|
904
|
+
var anchorStart = getDragHandleAnchorReference({
|
|
905
|
+
edge: 'start',
|
|
906
|
+
safeAnchorName: safeAnchorName
|
|
907
|
+
});
|
|
908
|
+
var anchorTop = getDragHandleAnchorReference({
|
|
909
|
+
edge: 'top',
|
|
910
|
+
safeAnchorName: safeAnchorName
|
|
911
|
+
});
|
|
912
|
+
var anchorLeft = getDragHandleAnchorReference({
|
|
913
|
+
edge: 'left',
|
|
914
|
+
safeAnchorName: safeAnchorName
|
|
915
|
+
});
|
|
916
|
+
var anchorRight = getDragHandleAnchorReference({
|
|
917
|
+
edge: 'right',
|
|
918
|
+
safeAnchorName: safeAnchorName
|
|
919
|
+
});
|
|
920
|
+
var bottom = (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? (0, _dragHandlePositions.getControlBottomCSSValue)(safeAnchorName, isSticky, isTopLevelNodeValue, isLayoutColumn, _consts2.ACTIVE_DRAG_HANDLE_FALLBACK_ANCHOR_NAME) : {};
|
|
897
921
|
return _objectSpread({
|
|
898
|
-
left: isEdgeCase ? "calc(
|
|
899
|
-
top: (0, _experiments.editorExperiment)('advanced_layouts', true) && isLayoutColumn ? "calc(
|
|
922
|
+
left: isEdgeCase ? "calc(".concat(anchorStart, " + ").concat((0, _dragHandlePositions.getLeftPosition)(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType), ")") : (0, _experiments.editorExperiment)('advanced_layouts', true) && isLayoutColumn ? "calc((".concat(anchorRight, " + ").concat(anchorLeft, ")/2 - ").concat(_consts2.DRAG_HANDLE_HEIGHT / 2, "px)") : "calc(".concat(anchorStart, " - ").concat(_styles.DRAG_HANDLE_WIDTH, "px - ").concat((0, _consts2.dragHandleGap)(nodeType, parentNodeType), "px)"),
|
|
923
|
+
top: (0, _experiments.editorExperiment)('advanced_layouts', true) && isLayoutColumn ? "calc(".concat(anchorTop, " - ").concat(_styles.DRAG_HANDLE_WIDTH, "px)") : "calc(".concat(anchorStart, " + ").concat((0, _consts2.topPositionAdjustment)((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? $pos && $pos.nodeAfter && (0, _decorationsCommon.getNodeTypeWithLevel)($pos.nodeAfter) || nodeType : nodeType, (dom === null || dom === void 0 ? void 0 : dom.getAttribute('layout')) || ''), "px)")
|
|
900
924
|
}, bottom);
|
|
901
925
|
}
|
|
902
926
|
var height = (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? (0, _dragHandlePositions.getControlHeightCSSValue)((0, _dragHandlePositions.getNodeHeight)(dom, safeAnchorName, anchorRectCache) || 0, isSticky, isTopLevelNodeValue, "".concat(_consts2.DRAG_HANDLE_HEIGHT), isLayoutColumn) : {};
|
|
@@ -1133,8 +1157,8 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
1133
1157
|
var _pos = getPos();
|
|
1134
1158
|
if (_pos !== undefined) {
|
|
1135
1159
|
var _api$core8;
|
|
1136
|
-
api === null || api === void 0 || (_api$core8 = api.core) === null || _api$core8 === void 0 || _api$core8.actions.execute(function (
|
|
1137
|
-
var tr =
|
|
1160
|
+
api === null || api === void 0 || (_api$core8 = api.core) === null || _api$core8 === void 0 || _api$core8.actions.execute(function (_ref1) {
|
|
1161
|
+
var tr = _ref1.tr;
|
|
1138
1162
|
tr.setMeta(_main.key, {
|
|
1139
1163
|
activeNode: {
|
|
1140
1164
|
pos: _pos,
|
|
@@ -1177,7 +1201,8 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
1177
1201
|
}, (0, _react2.jsx)(_tooltip.default, {
|
|
1178
1202
|
content: tooltipContent,
|
|
1179
1203
|
ignoreTooltipPointerEvents: true,
|
|
1180
|
-
position: 'top'
|
|
1204
|
+
position: 'top',
|
|
1205
|
+
tag: (0, _platformFeatureFlags.fg)('platform-dst-top-layer-tooltip') ? 'span' : 'div'
|
|
1181
1206
|
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
1182
1207
|
,
|
|
1183
1208
|
onShow: function onShow() {
|
|
@@ -1234,16 +1259,16 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
1234
1259
|
var render = isTooltip ? buttonWithTooltip() : renderButton();
|
|
1235
1260
|
return (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? stickyRender : render;
|
|
1236
1261
|
};
|
|
1237
|
-
var DragHandleWithVisibility = exports.DragHandleWithVisibility = function DragHandleWithVisibility(
|
|
1238
|
-
var view =
|
|
1239
|
-
api =
|
|
1240
|
-
formatMessage =
|
|
1241
|
-
getPos =
|
|
1242
|
-
anchorName =
|
|
1243
|
-
nodeType =
|
|
1244
|
-
handleOptions =
|
|
1245
|
-
isTopLevelNode =
|
|
1246
|
-
anchorRectCache =
|
|
1262
|
+
var DragHandleWithVisibility = exports.DragHandleWithVisibility = function DragHandleWithVisibility(_ref10) {
|
|
1263
|
+
var view = _ref10.view,
|
|
1264
|
+
api = _ref10.api,
|
|
1265
|
+
formatMessage = _ref10.formatMessage,
|
|
1266
|
+
getPos = _ref10.getPos,
|
|
1267
|
+
anchorName = _ref10.anchorName,
|
|
1268
|
+
nodeType = _ref10.nodeType,
|
|
1269
|
+
handleOptions = _ref10.handleOptions,
|
|
1270
|
+
isTopLevelNode = _ref10.isTopLevelNode,
|
|
1271
|
+
anchorRectCache = _ref10.anchorRectCache;
|
|
1247
1272
|
var rightSideControlsEnabled = (0, _hooks.useSharedPluginStateWithSelector)(api, ['blockControls'], function (states) {
|
|
1248
1273
|
var _states$blockControls2, _states$blockControls3;
|
|
1249
1274
|
return {
|
|
@@ -1264,7 +1289,8 @@ var DragHandleWithVisibility = exports.DragHandleWithVisibility = function DragH
|
|
|
1264
1289
|
return (0, _react2.jsx)(_visibilityContainer.VisibilityContainer, {
|
|
1265
1290
|
api: api,
|
|
1266
1291
|
controlSide: !isLayoutColumn && !skipControlSideRestriction && rightSideControlsEnabled ? 'left' : undefined,
|
|
1267
|
-
forceVisibleOnMouseOut: (0, _expValEquals.expValEquals)('platform_editor_drag_handle_keyboard_a11y', 'isEnabled', true) && !!(handleOptions !== null && handleOptions !== void 0 && handleOptions.isFocused)
|
|
1292
|
+
forceVisibleOnMouseOut: (0, _expValEquals.expValEquals)('platform_editor_drag_handle_keyboard_a11y', 'isEnabled', true) && !!(handleOptions !== null && handleOptions !== void 0 && handleOptions.isFocused),
|
|
1293
|
+
shouldUseDisplayContents: isLayoutColumn && (0, _platformFeatureFlags.fg)('platform-dst-top-layer-tooltip')
|
|
1268
1294
|
}, (0, _react2.jsx)(DragHandle, {
|
|
1269
1295
|
view: view,
|
|
1270
1296
|
api: api,
|
|
@@ -348,6 +348,9 @@ var nextAnchorSelector = ['&[data-node-anchor]',
|
|
|
348
348
|
// adjacent sibling with anchor (when next to a widget like gap cursor)
|
|
349
349
|
'&.ProseMirror-widget + :not([data-node-anchor]) [data-node-anchor]:first-of-type' // first nested anchor inside adjacent sibling (when next to a widget like gap cursor)
|
|
350
350
|
].join(', ');
|
|
351
|
+
|
|
352
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values
|
|
353
|
+
var combinedControlsFallbackAnchorNames = "".concat(_consts.ACTIVE_DRAG_HANDLE_FALLBACK_ANCHOR_NAME, ", ").concat(_consts.ACTIVE_QUICK_INSERT_FALLBACK_ANCHOR_NAME);
|
|
351
354
|
var dragHandlerAnchorStyles = (0, _react.css)({
|
|
352
355
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
353
356
|
'.ProseMirror': {
|
|
@@ -363,17 +366,31 @@ var dragHandlerAnchorStyles = (0, _react.css)({
|
|
|
363
366
|
})
|
|
364
367
|
}
|
|
365
368
|
});
|
|
366
|
-
var activeControlsSelector = "[".concat(_consts.ACTIVE_DRAG_HANDLE_ATTR, "], [").concat(_consts.ACTIVE_QUICK_INSERT_ATTR, "]");
|
|
367
369
|
|
|
368
370
|
// Applies anchor-name via node decoration attributes rather than adjacency CSS selectors.
|
|
369
371
|
// This is more reliable than dragHandlerAnchorStyles which depends on DOM structure.
|
|
370
372
|
// Only nodes decorated with data-active-drag-handle / data-active-quick-insert get anchor-name.
|
|
371
373
|
var staticControlsAnchorStyles = (0, _react.css)({
|
|
372
374
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
373
|
-
'.ProseMirror':
|
|
374
|
-
//
|
|
375
|
-
|
|
376
|
-
|
|
375
|
+
'.ProseMirror': {
|
|
376
|
+
// Active node can be both drag-handle and quick-insert target. Expose all three names:
|
|
377
|
+
// node anchor + both control-specific fallback anchors.
|
|
378
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
379
|
+
'[data-active-drag-handle][data-active-quick-insert][data-node-anchor]': {
|
|
380
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
381
|
+
anchorName: "".concat(combinedControlsFallbackAnchorNames, ", var(").concat(_styles.ANCHOR_VARIABLE_NAME, ", attr(data-node-anchor type(<custom-ident>)))")
|
|
382
|
+
},
|
|
383
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
384
|
+
'[data-active-drag-handle][data-node-anchor]': {
|
|
385
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
386
|
+
anchorName: "".concat(_consts.ACTIVE_DRAG_HANDLE_FALLBACK_ANCHOR_NAME, ", var(").concat(_styles.ANCHOR_VARIABLE_NAME, ", attr(data-node-anchor type(<custom-ident>)))")
|
|
387
|
+
},
|
|
388
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
389
|
+
'[data-active-quick-insert][data-node-anchor]': {
|
|
390
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
391
|
+
anchorName: "".concat(_consts.ACTIVE_QUICK_INSERT_FALLBACK_ANCHOR_NAME, ", var(").concat(_styles.ANCHOR_VARIABLE_NAME, ", attr(data-node-anchor type(<custom-ident>)))")
|
|
392
|
+
}
|
|
393
|
+
}
|
|
377
394
|
});
|
|
378
395
|
|
|
379
396
|
// Styles applied to nodes with anchors when dragging
|
|
@@ -151,15 +151,23 @@ var tooltipContainerStylesImprovedStickyHeaderWithMarksFix = (0, _react2.css)({
|
|
|
151
151
|
|
|
152
152
|
// TODO: ED-26959 - Share prop types between DragHandle - generic enough to create a type for block control decoration
|
|
153
153
|
|
|
154
|
-
var
|
|
155
|
-
var
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
154
|
+
var getQuickInsertAnchorReference = function getQuickInsertAnchorReference(_ref) {
|
|
155
|
+
var edge = _ref.edge,
|
|
156
|
+
safeAnchorName = _ref.safeAnchorName;
|
|
157
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_controls_reliable_anchor', 'isEnabled', true)) {
|
|
158
|
+
return "anchor(".concat(safeAnchorName, " ").concat(edge, ", anchor(").concat(_consts.ACTIVE_QUICK_INSERT_FALLBACK_ANCHOR_NAME, " ").concat(edge, "))");
|
|
159
|
+
}
|
|
160
|
+
return "anchor(".concat(safeAnchorName, " ").concat(edge, ")");
|
|
161
|
+
};
|
|
162
|
+
var TypeAheadControl = exports.TypeAheadControl = function TypeAheadControl(_ref2) {
|
|
163
|
+
var view = _ref2.view,
|
|
164
|
+
api = _ref2.api,
|
|
165
|
+
formatMessage = _ref2.formatMessage,
|
|
166
|
+
getPos = _ref2.getPos,
|
|
167
|
+
anchorName = _ref2.anchorName,
|
|
168
|
+
rootAnchorName = _ref2.rootAnchorName,
|
|
169
|
+
rootNodeType = _ref2.rootNodeType,
|
|
170
|
+
anchorRectCache = _ref2.anchorRectCache;
|
|
163
171
|
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['featureFlags'], function (states) {
|
|
164
172
|
var _states$featureFlagsS;
|
|
165
173
|
return {
|
|
@@ -217,12 +225,16 @@ var TypeAheadControl = exports.TypeAheadControl = function TypeAheadControl(_ref
|
|
|
217
225
|
}
|
|
218
226
|
var isEdgeCase = (hasResizer || isExtension || isEmbedCard || isBlockCard) && innerContainer;
|
|
219
227
|
var isSticky = (0, _dragHandlePositions.shouldBeSticky)(rootNodeType);
|
|
220
|
-
var
|
|
228
|
+
var anchorStart = getQuickInsertAnchorReference({
|
|
229
|
+
edge: 'start',
|
|
230
|
+
safeAnchorName: safeAnchorName
|
|
231
|
+
});
|
|
232
|
+
var bottom = (0, _dragHandlePositions.getControlBottomCSSValue)(safeAnchorName || anchorName, isSticky, true, false, _consts.ACTIVE_QUICK_INSERT_FALLBACK_ANCHOR_NAME);
|
|
221
233
|
if (supportsAnchor) {
|
|
222
234
|
return _objectSpread({
|
|
223
|
-
left: isEdgeCase ? "calc(
|
|
235
|
+
left: isEdgeCase ? "calc(".concat(anchorStart, " + ").concat((0, _widgetPositions.getLeftPositionForRootElement)(dom, rootNodeType, _consts.QUICK_INSERT_DIMENSIONS, innerContainer, isMacroInteractionUpdates), " + -").concat(_consts.QUICK_INSERT_LEFT_OFFSET, "px)") : "calc(".concat(anchorStart, " - ").concat(_consts.QUICK_INSERT_DIMENSIONS.width, "px - ").concat((0, _consts.rootElementGap)(rootNodeType), "px + -").concat(_consts.QUICK_INSERT_LEFT_OFFSET, "px)"),
|
|
224
236
|
// small text requires further tweaking to positioning, re-using existing methods to calculate to keep it unified with drag handle
|
|
225
|
-
top: "calc(
|
|
237
|
+
top: "calc(".concat(anchorStart, " + ").concat((0, _consts.topPositionAdjustment)(node && node.type.name === 'paragraph' && (0, _expValEquals.expValEquals)('platform_editor_small_font_size', 'isEnabled', true) ? (0, _decorationsCommon.getNodeTypeWithLevel)(node) : rootNodeType), "px)")
|
|
226
238
|
}, bottom);
|
|
227
239
|
}
|
|
228
240
|
|
|
@@ -287,8 +299,8 @@ var TypeAheadControl = exports.TypeAheadControl = function TypeAheadControl(_ref
|
|
|
287
299
|
var newPos =
|
|
288
300
|
//if the current selection is selected from right to left, then set the selection to the start of the paragraph
|
|
289
301
|
currentSelection.anchor === currentSelection.to ? currentParagraphNode.pos : currentParagraphNode.pos + currentParagraphNode.node.nodeSize - 1;
|
|
290
|
-
api.core.actions.execute(function (
|
|
291
|
-
var tr =
|
|
302
|
+
api.core.actions.execute(function (_ref3) {
|
|
303
|
+
var tr = _ref3.tr;
|
|
292
304
|
tr.setSelection(_state.TextSelection.create(view.state.selection.$from.doc, newPos));
|
|
293
305
|
return tr;
|
|
294
306
|
});
|
|
@@ -302,8 +314,8 @@ var TypeAheadControl = exports.TypeAheadControl = function TypeAheadControl(_ref
|
|
|
302
314
|
// otherwise need to force the selection to be at the start of the node, because
|
|
303
315
|
// prosemirror is keeping it as NodeSelection for nested nodes. Do this to keep it
|
|
304
316
|
// consistent NodeSelection for root level nodes.
|
|
305
|
-
api.core.actions.execute(function (
|
|
306
|
-
var tr =
|
|
317
|
+
api.core.actions.execute(function (_ref4) {
|
|
318
|
+
var tr = _ref4.tr;
|
|
307
319
|
(0, _editorCommands.createNewLine)(view.state.selection.from)({
|
|
308
320
|
tr: tr
|
|
309
321
|
});
|
|
@@ -315,8 +327,8 @@ var TypeAheadControl = exports.TypeAheadControl = function TypeAheadControl(_ref
|
|
|
315
327
|
if (currentSelection instanceof _cellSelection.CellSelection) {
|
|
316
328
|
// find the last inline position in the selection
|
|
317
329
|
var lastInlinePosition = _state.TextSelection.near(view.state.selection.$to, -1);
|
|
318
|
-
lastInlinePosition && api.core.actions.execute(function (
|
|
319
|
-
var tr =
|
|
330
|
+
lastInlinePosition && api.core.actions.execute(function (_ref5) {
|
|
331
|
+
var tr = _ref5.tr;
|
|
320
332
|
if (!(lastInlinePosition instanceof _state.TextSelection)) {
|
|
321
333
|
// this will create a new line after the node
|
|
322
334
|
(0, _editorCommands.createNewLine)(lastInlinePosition.from)({
|
|
@@ -375,16 +387,16 @@ var TypeAheadControl = exports.TypeAheadControl = function TypeAheadControl(_ref
|
|
|
375
387
|
css: [tooltipContainerStyles, (0, _expValEquals.expValEquals)('platform_editor_table_sticky_header_improvements', 'cohort', 'test_with_overflow') ? tooltipContainerImprovedStylesStickyHeader : tooltipContainerStylesStickyHeader, (0, _expValEquals.expValEquals)('platform_editor_table_sticky_header_improvements', 'cohort', 'test_with_overflow') ? tooltipContainerStylesImprovedStickyHeaderWithMarksFix : tooltipContainerStylesStickyHeaderWithMarksFix]
|
|
376
388
|
}, tooltipPressable()));
|
|
377
389
|
};
|
|
378
|
-
var QuickInsertWithVisibility = exports.QuickInsertWithVisibility = function QuickInsertWithVisibility(
|
|
379
|
-
var view =
|
|
380
|
-
api =
|
|
381
|
-
formatMessage =
|
|
382
|
-
getPos =
|
|
383
|
-
nodeType =
|
|
384
|
-
anchorName =
|
|
385
|
-
rootAnchorName =
|
|
386
|
-
rootNodeType =
|
|
387
|
-
anchorRectCache =
|
|
390
|
+
var QuickInsertWithVisibility = exports.QuickInsertWithVisibility = function QuickInsertWithVisibility(_ref6) {
|
|
391
|
+
var view = _ref6.view,
|
|
392
|
+
api = _ref6.api,
|
|
393
|
+
formatMessage = _ref6.formatMessage,
|
|
394
|
+
getPos = _ref6.getPos,
|
|
395
|
+
nodeType = _ref6.nodeType,
|
|
396
|
+
anchorName = _ref6.anchorName,
|
|
397
|
+
rootAnchorName = _ref6.rootAnchorName,
|
|
398
|
+
rootNodeType = _ref6.rootNodeType,
|
|
399
|
+
anchorRectCache = _ref6.anchorRectCache;
|
|
388
400
|
var rightSideControlsEnabled = (0, _hooks.useSharedPluginStateWithSelector)(api, ['blockControls'], function (states) {
|
|
389
401
|
var _states$blockControls, _states$blockControls2;
|
|
390
402
|
return {
|
|
@@ -37,6 +37,9 @@ var hiddenStyles = (0, _primitives.xcss)({
|
|
|
37
37
|
opacity: 0,
|
|
38
38
|
visibility: 'hidden'
|
|
39
39
|
});
|
|
40
|
+
var displayContentsStyles = (0, _primitives.xcss)({
|
|
41
|
+
display: 'contents'
|
|
42
|
+
});
|
|
40
43
|
var baseStylesCSS = (0, _react2.css)((0, _defineProperty2.default)({
|
|
41
44
|
transition: 'opacity 0.1s ease-in-out, visibility 0.1s ease-in-out'
|
|
42
45
|
}, "@container editor-area (max-width: ".concat(_editorSharedStyles.akEditorFullPageNarrowBreakout, "px)"), {
|
|
@@ -51,11 +54,15 @@ var hiddenStylesCSS = (0, _react2.css)({
|
|
|
51
54
|
opacity: 0,
|
|
52
55
|
visibility: 'hidden'
|
|
53
56
|
});
|
|
57
|
+
var displayContentsStylesCSS = (0, _react2.css)({
|
|
58
|
+
display: 'contents'
|
|
59
|
+
});
|
|
54
60
|
var VisibilityContainer = exports.VisibilityContainer = function VisibilityContainer(_ref) {
|
|
55
61
|
var api = _ref.api,
|
|
56
62
|
children = _ref.children,
|
|
57
63
|
controlSide = _ref.controlSide,
|
|
58
|
-
forceVisibleOnMouseOut = _ref.forceVisibleOnMouseOut
|
|
64
|
+
forceVisibleOnMouseOut = _ref.forceVisibleOnMouseOut,
|
|
65
|
+
shouldUseDisplayContents = _ref.shouldUseDisplayContents;
|
|
59
66
|
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['typeAhead', 'blockControls', 'editorViewMode', 'userIntent'], function (states) {
|
|
60
67
|
var _states$typeAheadStat, _states$blockControls, _states$blockControls2, _states$blockControls3, _states$editorViewMod, _states$userIntentSta, _states$blockControls4;
|
|
61
68
|
return {
|
|
@@ -128,12 +135,12 @@ var VisibilityContainer = exports.VisibilityContainer = function VisibilityConta
|
|
|
128
135
|
exposure: true
|
|
129
136
|
})) {
|
|
130
137
|
return (0, _react2.jsx)("div", {
|
|
131
|
-
css: [baseStylesCSS, shouldHide ? hiddenStylesCSS : visibleStylesCSS]
|
|
138
|
+
css: [baseStylesCSS, shouldHide ? hiddenStylesCSS : visibleStylesCSS, shouldUseDisplayContents && displayContentsStylesCSS]
|
|
132
139
|
}, children);
|
|
133
140
|
}
|
|
134
|
-
|
|
141
|
+
return (0, _react2.jsx)(_primitives.Box
|
|
135
142
|
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
136
|
-
|
|
137
|
-
xcss: [baseStyles, shouldHide ? hiddenStyles : visibleStyles]
|
|
143
|
+
, {
|
|
144
|
+
xcss: [baseStyles, shouldHide ? hiddenStyles : visibleStyles, shouldUseDisplayContents && displayContentsStyles]
|
|
138
145
|
}, children);
|
|
139
146
|
};
|
|
@@ -57,7 +57,14 @@ const getStickyNodes = memoizeOne(() => [...STICKY_NODES, ...(expValEquals('conf
|
|
|
57
57
|
export const shouldBeSticky = nodeType => {
|
|
58
58
|
return editorExperiment('platform_editor_controls', 'variant1') && getStickyNodes().includes(nodeType);
|
|
59
59
|
};
|
|
60
|
-
export const getControlBottomCSSValue = (anchor, isSticky, isTopLevelNode, isLayoutColumn) => {
|
|
60
|
+
export const getControlBottomCSSValue = (anchor, isSticky, isTopLevelNode, isLayoutColumn, fallbackAnchor) => {
|
|
61
|
+
if (expValEquals('platform_editor_controls_reliable_anchor', 'isEnabled', true)) {
|
|
62
|
+
return editorExperiment('advanced_layouts', true) && isLayoutColumn || !isSticky || !isTopLevelNode ? {
|
|
63
|
+
bottom: 'unset'
|
|
64
|
+
} : {
|
|
65
|
+
bottom: fallbackAnchor ? `anchor(${anchor} end, anchor(${fallbackAnchor} end))` : `anchor(${anchor} end)`
|
|
66
|
+
};
|
|
67
|
+
}
|
|
61
68
|
return editorExperiment('advanced_layouts', true) && isLayoutColumn || !isSticky || !isTopLevelNode ? {
|
|
62
69
|
bottom: 'unset'
|
|
63
70
|
} : {
|
package/dist/es2019/ui/consts.js
CHANGED
|
@@ -6,6 +6,8 @@ import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equ
|
|
|
6
6
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
7
7
|
export const ACTIVE_DRAG_HANDLE_ATTR = 'data-active-drag-handle';
|
|
8
8
|
export const ACTIVE_QUICK_INSERT_ATTR = 'data-active-quick-insert';
|
|
9
|
+
export const ACTIVE_DRAG_HANDLE_FALLBACK_ANCHOR_NAME = '--editor-block-controls-active-drag-handle-anchor';
|
|
10
|
+
export const ACTIVE_QUICK_INSERT_FALLBACK_ANCHOR_NAME = '--editor-block-controls-active-quick-insert-anchor';
|
|
9
11
|
export const DRAG_HANDLE_HEIGHT = 24;
|
|
10
12
|
export const DRAG_HANDLE_BORDER_RADIUS = 4;
|
|
11
13
|
export const DRAG_HANDLE_ZINDEX = akRichMediaResizeZIndex + akEditorUnitZIndex; //place above legacy resizer
|
|
@@ -35,7 +35,7 @@ import { getControlBottomCSSValue, getControlHeightCSSValue, getLeftPosition, ge
|
|
|
35
35
|
import { expandAndUpdateSelection } from '../pm-plugins/utils/expand-and-update-selection';
|
|
36
36
|
import { isHandleCorrelatedToSelection, selectNode } from '../pm-plugins/utils/getSelection';
|
|
37
37
|
import { alignAnchorHeadInDirectionOfPos, expandSelectionHeadToNodeAtPos } from '../pm-plugins/utils/selection';
|
|
38
|
-
import { ACTIVE_DRAG_HANDLE_ATTR, DRAG_HANDLE_BORDER_RADIUS, DRAG_HANDLE_HEIGHT, DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH, DRAG_HANDLE_ZINDEX, dragHandleGap, nodeMargins, spacingBetweenNodesForPreview, STICKY_CONTROLS_TOP_MARGIN, STICKY_CONTROLS_TOP_MARGIN_FOR_STICKY_HEADER, topPositionAdjustment } from './consts';
|
|
38
|
+
import { ACTIVE_DRAG_HANDLE_ATTR, ACTIVE_DRAG_HANDLE_FALLBACK_ANCHOR_NAME, DRAG_HANDLE_BORDER_RADIUS, DRAG_HANDLE_HEIGHT, DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH, DRAG_HANDLE_ZINDEX, dragHandleGap, nodeMargins, spacingBetweenNodesForPreview, STICKY_CONTROLS_TOP_MARGIN, STICKY_CONTROLS_TOP_MARGIN_FOR_STICKY_HEADER, topPositionAdjustment } from './consts';
|
|
39
39
|
import { DragHandleNestedIcon } from './drag-handle-nested-icon';
|
|
40
40
|
import { dragPreview } from './drag-preview';
|
|
41
41
|
import { shouldUseNestedDragHandleIcon } from './should-use-nested-drag-handle-icon';
|
|
@@ -375,6 +375,15 @@ const buildToggleLayoutColumnMenuMeta = (anchorPos, openedViaKeyboard) => ({
|
|
|
375
375
|
} : {}),
|
|
376
376
|
openedViaKeyboard
|
|
377
377
|
});
|
|
378
|
+
const getDragHandleAnchorReference = ({
|
|
379
|
+
edge,
|
|
380
|
+
safeAnchorName
|
|
381
|
+
}) => {
|
|
382
|
+
if (expValEquals('platform_editor_controls_reliable_anchor', 'isEnabled', true)) {
|
|
383
|
+
return `anchor(${safeAnchorName} ${edge}, anchor(${ACTIVE_DRAG_HANDLE_FALLBACK_ANCHOR_NAME} ${edge}))`;
|
|
384
|
+
}
|
|
385
|
+
return `anchor(${safeAnchorName} ${edge})`;
|
|
386
|
+
};
|
|
378
387
|
export const DragHandle = ({
|
|
379
388
|
view,
|
|
380
389
|
api,
|
|
@@ -871,10 +880,26 @@ export const DragHandle = ({
|
|
|
871
880
|
const isEdgeCase = (hasResizer || isExtension || isEmbedCard || isBlockCard) && innerContainer;
|
|
872
881
|
const isSticky = shouldBeSticky(nodeType);
|
|
873
882
|
if (supportsAnchor) {
|
|
874
|
-
const
|
|
883
|
+
const anchorStart = getDragHandleAnchorReference({
|
|
884
|
+
edge: 'start',
|
|
885
|
+
safeAnchorName
|
|
886
|
+
});
|
|
887
|
+
const anchorTop = getDragHandleAnchorReference({
|
|
888
|
+
edge: 'top',
|
|
889
|
+
safeAnchorName
|
|
890
|
+
});
|
|
891
|
+
const anchorLeft = getDragHandleAnchorReference({
|
|
892
|
+
edge: 'left',
|
|
893
|
+
safeAnchorName
|
|
894
|
+
});
|
|
895
|
+
const anchorRight = getDragHandleAnchorReference({
|
|
896
|
+
edge: 'right',
|
|
897
|
+
safeAnchorName
|
|
898
|
+
});
|
|
899
|
+
const bottom = editorExperiment('platform_editor_controls', 'variant1') ? getControlBottomCSSValue(safeAnchorName, isSticky, isTopLevelNodeValue, isLayoutColumn, ACTIVE_DRAG_HANDLE_FALLBACK_ANCHOR_NAME) : {};
|
|
875
900
|
return {
|
|
876
|
-
left: isEdgeCase ? `calc(
|
|
877
|
-
top: editorExperiment('advanced_layouts', true) && isLayoutColumn ? `calc(
|
|
901
|
+
left: isEdgeCase ? `calc(${anchorStart} + ${getLeftPosition(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType)})` : editorExperiment('advanced_layouts', true) && isLayoutColumn ? `calc((${anchorRight} + ${anchorLeft})/2 - ${DRAG_HANDLE_HEIGHT / 2}px)` : `calc(${anchorStart} - ${DRAG_HANDLE_WIDTH}px - ${dragHandleGap(nodeType, parentNodeType)}px)`,
|
|
902
|
+
top: editorExperiment('advanced_layouts', true) && isLayoutColumn ? `calc(${anchorTop} - ${DRAG_HANDLE_WIDTH}px)` : `calc(${anchorStart} + ${topPositionAdjustment(expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? $pos && $pos.nodeAfter && getNodeTypeWithLevel($pos.nodeAfter) || nodeType : nodeType, (dom === null || dom === void 0 ? void 0 : dom.getAttribute('layout')) || '')}px)`,
|
|
878
903
|
...bottom
|
|
879
904
|
};
|
|
880
905
|
}
|
|
@@ -1154,7 +1179,8 @@ export const DragHandle = ({
|
|
|
1154
1179
|
}, jsx(Tooltip, {
|
|
1155
1180
|
content: tooltipContent,
|
|
1156
1181
|
ignoreTooltipPointerEvents: true,
|
|
1157
|
-
position: 'top'
|
|
1182
|
+
position: 'top',
|
|
1183
|
+
tag: fg('platform-dst-top-layer-tooltip') ? 'span' : 'div'
|
|
1158
1184
|
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
1159
1185
|
,
|
|
1160
1186
|
onShow: () => {
|
|
@@ -1237,7 +1263,8 @@ export const DragHandleWithVisibility = ({
|
|
|
1237
1263
|
return jsx(VisibilityContainer, {
|
|
1238
1264
|
api: api,
|
|
1239
1265
|
controlSide: !isLayoutColumn && !skipControlSideRestriction && rightSideControlsEnabled ? 'left' : undefined,
|
|
1240
|
-
forceVisibleOnMouseOut: expValEquals('platform_editor_drag_handle_keyboard_a11y', 'isEnabled', true) && !!(handleOptions !== null && handleOptions !== void 0 && handleOptions.isFocused)
|
|
1266
|
+
forceVisibleOnMouseOut: expValEquals('platform_editor_drag_handle_keyboard_a11y', 'isEnabled', true) && !!(handleOptions !== null && handleOptions !== void 0 && handleOptions.isFocused),
|
|
1267
|
+
shouldUseDisplayContents: isLayoutColumn && fg('platform-dst-top-layer-tooltip')
|
|
1241
1268
|
}, jsx(DragHandle, {
|
|
1242
1269
|
view: view,
|
|
1243
1270
|
api: api,
|