@atlaskit/editor-plugin-block-controls 3.7.1 → 3.8.1
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 +22 -0
- package/dist/cjs/pm-plugins/decorations-drag-handle.js +3 -2
- package/dist/cjs/pm-plugins/decorations-quick-insert-button.js +3 -2
- package/dist/cjs/pm-plugins/handle-mouse-down.js +25 -0
- package/dist/cjs/pm-plugins/main.js +4 -2
- package/dist/cjs/pm-plugins/utils/drag-handle-positions.js +25 -1
- package/dist/cjs/ui/drag-handle.js +125 -24
- package/dist/cjs/ui/quick-insert-button.js +82 -26
- package/dist/cjs/ui/utils/anchor-name.js +34 -0
- package/dist/es2019/pm-plugins/decorations-drag-handle.js +3 -2
- package/dist/es2019/pm-plugins/decorations-quick-insert-button.js +3 -2
- package/dist/es2019/pm-plugins/handle-mouse-down.js +17 -0
- package/dist/es2019/pm-plugins/main.js +4 -2
- package/dist/es2019/pm-plugins/utils/drag-handle-positions.js +22 -0
- package/dist/es2019/ui/drag-handle.js +109 -12
- package/dist/es2019/ui/quick-insert-button.js +68 -15
- package/dist/es2019/ui/utils/anchor-name.js +29 -0
- package/dist/esm/pm-plugins/decorations-drag-handle.js +3 -2
- package/dist/esm/pm-plugins/decorations-quick-insert-button.js +3 -2
- package/dist/esm/pm-plugins/handle-mouse-down.js +19 -0
- package/dist/esm/pm-plugins/main.js +4 -2
- package/dist/esm/pm-plugins/utils/drag-handle-positions.js +24 -0
- package/dist/esm/ui/drag-handle.js +126 -25
- package/dist/esm/ui/quick-insert-button.js +83 -27
- package/dist/esm/ui/utils/anchor-name.js +28 -0
- package/dist/types/pm-plugins/decorations-drag-handle.d.ts +2 -1
- package/dist/types/pm-plugins/decorations-quick-insert-button.d.ts +2 -1
- package/dist/types/pm-plugins/handle-mouse-down.d.ts +4 -0
- package/dist/types/pm-plugins/utils/drag-handle-positions.d.ts +9 -0
- package/dist/types/ui/drag-handle.d.ts +4 -2
- package/dist/types/ui/quick-insert-button.d.ts +3 -1
- package/dist/types/ui/utils/anchor-name.d.ts +12 -0
- package/dist/types-ts4.5/pm-plugins/decorations-drag-handle.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/decorations-quick-insert-button.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/handle-mouse-down.d.ts +4 -0
- package/dist/types-ts4.5/pm-plugins/utils/drag-handle-positions.d.ts +9 -0
- package/dist/types-ts4.5/ui/drag-handle.d.ts +4 -2
- package/dist/types-ts4.5/ui/quick-insert-button.d.ts +3 -1
- package/dist/types-ts4.5/ui/utils/anchor-name.d.ts +12 -0
- package/package.json +12 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 3.8.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#135962](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/135962)
|
|
8
|
+
[`b7caf17e63935`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b7caf17e63935) -
|
|
9
|
+
Add refreshAnchorName function to fetch new anchor name if current anchor name isnt provided,
|
|
10
|
+
which is possible as a new mouseDown event listener has been added to fetch position even if
|
|
11
|
+
editor isnt ready
|
|
12
|
+
|
|
13
|
+
## 3.8.0
|
|
14
|
+
|
|
15
|
+
### Minor Changes
|
|
16
|
+
|
|
17
|
+
- [#132443](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/132443)
|
|
18
|
+
[`d4f6243b5f21a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d4f6243b5f21a) -
|
|
19
|
+
[ux] Add sticky controls under experiment
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Updated dependencies
|
|
24
|
+
|
|
3
25
|
## 3.7.1
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
|
@@ -28,7 +28,7 @@ var findHandleDec = exports.findHandleDec = function findHandleDec(decorations,
|
|
|
28
28
|
return spec.type === _decorationsCommon.TYPE_HANDLE_DEC;
|
|
29
29
|
});
|
|
30
30
|
};
|
|
31
|
-
var dragHandleDecoration = exports.dragHandleDecoration = function dragHandleDecoration(api, formatMessage, pos, anchorName, nodeType, nodeViewPortalProviderAPI, handleOptions) {
|
|
31
|
+
var dragHandleDecoration = exports.dragHandleDecoration = function dragHandleDecoration(api, formatMessage, pos, anchorName, nodeType, nodeViewPortalProviderAPI, handleOptions, anchorRectCache) {
|
|
32
32
|
(0, _decorationsCommon.unmountDecorations)(nodeViewPortalProviderAPI, 'data-blocks-drag-handle-container', 'data-blocks-drag-handle-key');
|
|
33
33
|
var unbind;
|
|
34
34
|
var key = (0, _uuid.default)();
|
|
@@ -100,7 +100,8 @@ var dragHandleDecoration = exports.dragHandleDecoration = function dragHandleDec
|
|
|
100
100
|
anchorName: anchorName,
|
|
101
101
|
nodeType: nodeType,
|
|
102
102
|
handleOptions: handleOptions,
|
|
103
|
-
isTopLevelNode: isTopLevelNode
|
|
103
|
+
isTopLevelNode: isTopLevelNode,
|
|
104
|
+
anchorRectCache: anchorRectCache
|
|
104
105
|
}), element);
|
|
105
106
|
//}
|
|
106
107
|
return element;
|
|
@@ -15,7 +15,7 @@ var findQuickInsertInsertButtonDecoration = exports.findQuickInsertInsertButtonD
|
|
|
15
15
|
return spec.type === TYPE_QUICK_INSERT;
|
|
16
16
|
});
|
|
17
17
|
};
|
|
18
|
-
var quickInsertButtonDecoration = exports.quickInsertButtonDecoration = function quickInsertButtonDecoration(api, formatMessage, rootPos, anchorName, nodeType, nodeViewPortalProviderAPI, rootAnchorName, rootNodeType) {
|
|
18
|
+
var quickInsertButtonDecoration = exports.quickInsertButtonDecoration = function quickInsertButtonDecoration(api, formatMessage, rootPos, anchorName, nodeType, nodeViewPortalProviderAPI, rootAnchorName, rootNodeType, anchorRectCache) {
|
|
19
19
|
var key = (0, _uuid.default)();
|
|
20
20
|
return _view.Decoration.widget(rootPos, function (view, getPos) {
|
|
21
21
|
var element = document.createElement('span');
|
|
@@ -31,7 +31,8 @@ var quickInsertButtonDecoration = exports.quickInsertButtonDecoration = function
|
|
|
31
31
|
nodeType: nodeType,
|
|
32
32
|
anchorName: anchorName,
|
|
33
33
|
rootAnchorName: rootAnchorName,
|
|
34
|
-
rootNodeType: rootNodeType !== null && rootNodeType !== void 0 ? rootNodeType : nodeType
|
|
34
|
+
rootNodeType: rootNodeType !== null && rootNodeType !== void 0 ? rootNodeType : nodeType,
|
|
35
|
+
anchorRectCache: anchorRectCache
|
|
35
36
|
});
|
|
36
37
|
}, element, key);
|
|
37
38
|
return element;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.handleMouseDown = void 0;
|
|
7
|
+
var handleMouseDown = exports.handleMouseDown = function handleMouseDown(api) {
|
|
8
|
+
return function (view, event) {
|
|
9
|
+
if (view.editable) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
if (event.target instanceof HTMLElement) {
|
|
13
|
+
var _rootNode$type$name, _rootNode$type$name2;
|
|
14
|
+
var targetPos = view.posAtDOM(event.target, 0);
|
|
15
|
+
// always fetch top level position for mouseDown to avoid drag handle positions being incorrect
|
|
16
|
+
var rootPos = view.state.doc.resolve(targetPos).before(1);
|
|
17
|
+
var rootNode = view.state.doc.nodeAt(rootPos);
|
|
18
|
+
if (!rootNode) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.showDragHandleAt(rootPos, '', (_rootNode$type$name = rootNode.type.name) !== null && _rootNode$type$name !== void 0 ? _rootNode$type$name : '', undefined, rootPos, '', (_rootNode$type$name2 = rootNode.type.name) !== null && _rootNode$type$name2 !== void 0 ? _rootNode$type$name2 : ''));
|
|
22
|
+
}
|
|
23
|
+
return false;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
@@ -26,6 +26,7 @@ var _decorationsAnchor = require("./decorations-anchor");
|
|
|
26
26
|
var _decorationsDragHandle = require("./decorations-drag-handle");
|
|
27
27
|
var _decorationsDropTarget = require("./decorations-drop-target");
|
|
28
28
|
var _decorationsQuickInsertButton = require("./decorations-quick-insert-button");
|
|
29
|
+
var _handleMouseDown = require("./handle-mouse-down");
|
|
29
30
|
var _handleMouseOver = require("./handle-mouse-over");
|
|
30
31
|
var _keymap = require("./keymap");
|
|
31
32
|
var _activeAnchorTracker = require("./utils/active-anchor-tracker");
|
|
@@ -355,14 +356,14 @@ var newApply = exports.newApply = function newApply(api, formatMessage, tr, curr
|
|
|
355
356
|
var _activeNode9, _activeNode10, _latestActiveNode, _latestActiveNode2, _latestActiveNode3, _latestActiveNode4;
|
|
356
357
|
var _oldHandle = (0, _decorationsDragHandle.findHandleDec)(decorations, (_activeNode9 = activeNode) === null || _activeNode9 === void 0 ? void 0 : _activeNode9.pos, (_activeNode10 = activeNode) === null || _activeNode10 === void 0 ? void 0 : _activeNode10.pos);
|
|
357
358
|
decorations = decorations.remove(_oldHandle);
|
|
358
|
-
var handleDec = (0, _decorationsDragHandle.dragHandleDecoration)(api, formatMessage, (_latestActiveNode = latestActiveNode) === null || _latestActiveNode === void 0 ? void 0 : _latestActiveNode.pos, (_latestActiveNode2 = latestActiveNode) === null || _latestActiveNode2 === void 0 ? void 0 : _latestActiveNode2.anchorName, (_latestActiveNode3 = latestActiveNode) === null || _latestActiveNode3 === void 0 ? void 0 : _latestActiveNode3.nodeType, nodeViewPortalProviderAPI, (_latestActiveNode4 = latestActiveNode) === null || _latestActiveNode4 === void 0 ? void 0 : _latestActiveNode4.handleOptions);
|
|
359
|
+
var handleDec = (0, _decorationsDragHandle.dragHandleDecoration)(api, formatMessage, (_latestActiveNode = latestActiveNode) === null || _latestActiveNode === void 0 ? void 0 : _latestActiveNode.pos, (_latestActiveNode2 = latestActiveNode) === null || _latestActiveNode2 === void 0 ? void 0 : _latestActiveNode2.anchorName, (_latestActiveNode3 = latestActiveNode) === null || _latestActiveNode3 === void 0 ? void 0 : _latestActiveNode3.nodeType, nodeViewPortalProviderAPI, (_latestActiveNode4 = latestActiveNode) === null || _latestActiveNode4 === void 0 ? void 0 : _latestActiveNode4.handleOptions, anchorRectCache);
|
|
359
360
|
decorations = decorations.add(newState.doc, [handleDec]);
|
|
360
361
|
}
|
|
361
362
|
if (shouldRecreateQuickInsertButton && ((_latestActiveNode5 = latestActiveNode) === null || _latestActiveNode5 === void 0 ? void 0 : _latestActiveNode5.rootPos) !== undefined && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
|
|
362
363
|
var _activeNode11, _activeNode12, _latestActiveNode6, _latestActiveNode7, _latestActiveNode8, _latestActiveNode9, _latestActiveNode10;
|
|
363
364
|
var _oldQuickInsertButton = (0, _decorationsQuickInsertButton.findQuickInsertInsertButtonDecoration)(decorations, (_activeNode11 = activeNode) === null || _activeNode11 === void 0 ? void 0 : _activeNode11.rootPos, (_activeNode12 = activeNode) === null || _activeNode12 === void 0 ? void 0 : _activeNode12.rootPos);
|
|
364
365
|
decorations = decorations.remove(_oldQuickInsertButton);
|
|
365
|
-
var quickInsertButton = (0, _decorationsQuickInsertButton.quickInsertButtonDecoration)(api, formatMessage, (_latestActiveNode6 = latestActiveNode) === null || _latestActiveNode6 === void 0 ? void 0 : _latestActiveNode6.rootPos, (_latestActiveNode7 = latestActiveNode) === null || _latestActiveNode7 === void 0 ? void 0 : _latestActiveNode7.anchorName, (_latestActiveNode8 = latestActiveNode) === null || _latestActiveNode8 === void 0 ? void 0 : _latestActiveNode8.nodeType, nodeViewPortalProviderAPI, (_latestActiveNode9 = latestActiveNode) === null || _latestActiveNode9 === void 0 ? void 0 : _latestActiveNode9.rootAnchorName, (_latestActiveNode10 = latestActiveNode) === null || _latestActiveNode10 === void 0 ? void 0 : _latestActiveNode10.rootNodeType);
|
|
366
|
+
var quickInsertButton = (0, _decorationsQuickInsertButton.quickInsertButtonDecoration)(api, formatMessage, (_latestActiveNode6 = latestActiveNode) === null || _latestActiveNode6 === void 0 ? void 0 : _latestActiveNode6.rootPos, (_latestActiveNode7 = latestActiveNode) === null || _latestActiveNode7 === void 0 ? void 0 : _latestActiveNode7.anchorName, (_latestActiveNode8 = latestActiveNode) === null || _latestActiveNode8 === void 0 ? void 0 : _latestActiveNode8.nodeType, nodeViewPortalProviderAPI, (_latestActiveNode9 = latestActiveNode) === null || _latestActiveNode9 === void 0 ? void 0 : _latestActiveNode9.rootAnchorName, (_latestActiveNode10 = latestActiveNode) === null || _latestActiveNode10 === void 0 ? void 0 : _latestActiveNode10.rootNodeType, anchorRectCache);
|
|
366
367
|
decorations = decorations.add(newState.doc, [quickInsertButton]);
|
|
367
368
|
}
|
|
368
369
|
}
|
|
@@ -728,6 +729,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
|
|
|
728
729
|
(0, _handleMouseOver.handleMouseOver)(view, event, api);
|
|
729
730
|
return false;
|
|
730
731
|
},
|
|
732
|
+
mousedown: (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_2') ? (0, _handleMouseDown.handleMouseDown)(api) : undefined,
|
|
731
733
|
keydown: function keydown(view, event) {
|
|
732
734
|
if (isMultiSelectEnabled) {
|
|
733
735
|
if (event.shiftKey && event.ctrlKey) {
|
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.getTopPosition = exports.getLeftPosition = void 0;
|
|
6
|
+
exports.shouldBeSticky = exports.getTopPosition = exports.getNodeHeight = exports.getLeftPosition = exports.getControlHeightCSSValue = exports.getControlBottomCSSValue = void 0;
|
|
7
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
7
8
|
var _consts = require("../../ui/consts");
|
|
9
|
+
var STICKY_NODES = ['panel', 'table', 'expand', 'layoutSection', 'bodiedExtension'];
|
|
8
10
|
var getTopPosition = exports.getTopPosition = function getTopPosition(dom, type) {
|
|
9
11
|
if (!dom) {
|
|
10
12
|
return 'auto';
|
|
@@ -48,4 +50,26 @@ var getLeftPosition = exports.getLeftPosition = function getLeftPosition(dom, ty
|
|
|
48
50
|
var relativeSpan = macroInteractionUpdates ? dom.querySelector('span.relative') : null;
|
|
49
51
|
var leftAdjustment = relativeSpan ? relativeSpan.offsetLeft : 0;
|
|
50
52
|
return getComputedStyle(innerContainer).transform === 'none' ? "".concat(innerContainer.offsetLeft + leftAdjustment - (0, _consts.dragHandleGap)(type, parentType) - _consts.DRAG_HANDLE_WIDTH, "px") : "".concat(innerContainer.offsetLeft + leftAdjustment - innerContainer.offsetWidth / 2 - (0, _consts.dragHandleGap)(type, parentType) - _consts.DRAG_HANDLE_WIDTH, "px");
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// anchorRectCache seems to have a 100% cache miss rate
|
|
56
|
+
var getNodeHeight = exports.getNodeHeight = function getNodeHeight(dom, anchor, anchorRectCache) {
|
|
57
|
+
return (anchorRectCache === null || anchorRectCache === void 0 ? void 0 : anchorRectCache.getHeight(anchor)) || (dom === null || dom === void 0 ? void 0 : dom.offsetHeight);
|
|
58
|
+
};
|
|
59
|
+
var shouldBeSticky = exports.shouldBeSticky = function shouldBeSticky(nodeType) {
|
|
60
|
+
return (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && STICKY_NODES.includes(nodeType);
|
|
61
|
+
};
|
|
62
|
+
var getControlBottomCSSValue = exports.getControlBottomCSSValue = function getControlBottomCSSValue(anchor, isSticky, isTopLevelNode, isLayoutColumn) {
|
|
63
|
+
return (0, _experiments.editorExperiment)('advanced_layouts', true) && isLayoutColumn || !isSticky || !isTopLevelNode ? {
|
|
64
|
+
bottom: 'unset'
|
|
65
|
+
} : {
|
|
66
|
+
bottom: "anchor(".concat(anchor, " end)")
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
var getControlHeightCSSValue = exports.getControlHeightCSSValue = function getControlHeightCSSValue(nodeHeight, isSticky, isTopLevelNode, fallbackPxHeight, isLayoutColumn) {
|
|
70
|
+
return (0, _experiments.editorExperiment)('advanced_layouts', true) && isLayoutColumn || !isSticky || !isTopLevelNode ? {
|
|
71
|
+
height: 'unset'
|
|
72
|
+
} : {
|
|
73
|
+
height: "".concat(nodeHeight || fallbackPxHeight, "px")
|
|
74
|
+
};
|
|
51
75
|
};
|
|
@@ -34,6 +34,7 @@ var _getSelection = require("../pm-plugins/utils/getSelection");
|
|
|
34
34
|
var _selection = require("../pm-plugins/utils/selection");
|
|
35
35
|
var _consts = require("./consts");
|
|
36
36
|
var _dragPreview = require("./drag-preview");
|
|
37
|
+
var _anchorName = require("./utils/anchor-name");
|
|
37
38
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
38
39
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } /**
|
|
39
40
|
* @jsxRuntime classic
|
|
@@ -50,6 +51,43 @@ var dragHandleColor = (0, _react2.css)({
|
|
|
50
51
|
color: "var(--ds-icon-subtle, #626F86)"
|
|
51
52
|
});
|
|
52
53
|
var dragHandleButtonStyles = (0, _react2.css)({
|
|
54
|
+
display: 'flex',
|
|
55
|
+
boxSizing: 'border-box',
|
|
56
|
+
flexDirection: 'column',
|
|
57
|
+
justifyContent: 'center',
|
|
58
|
+
alignItems: 'center',
|
|
59
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
60
|
+
height: _consts.DRAG_HANDLE_HEIGHT,
|
|
61
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
62
|
+
width: _consts.DRAG_HANDLE_WIDTH,
|
|
63
|
+
border: 'none',
|
|
64
|
+
background: 'transparent',
|
|
65
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
66
|
+
borderRadius: _consts.DRAG_HANDLE_BORDER_RADIUS,
|
|
67
|
+
// when platform_editor_controls is enabled, the drag handle color is overridden. Update color here when experiment is cleaned up.
|
|
68
|
+
color: "var(--ds-icon, #44546F)",
|
|
69
|
+
cursor: 'grab',
|
|
70
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
71
|
+
zIndex: _consts.DRAG_HANDLE_ZINDEX,
|
|
72
|
+
outline: 'none',
|
|
73
|
+
'&:hover': {
|
|
74
|
+
backgroundColor: "var(--ds-background-neutral-subtle-hovered, #091E420F)"
|
|
75
|
+
},
|
|
76
|
+
'&:active': {
|
|
77
|
+
backgroundColor: "var(--ds-background-neutral-subtle-pressed, #091E4224)"
|
|
78
|
+
},
|
|
79
|
+
'&:focus': {
|
|
80
|
+
outline: "2px solid ".concat("var(--ds-border-focused, #388BFF)")
|
|
81
|
+
},
|
|
82
|
+
'&:disabled': {
|
|
83
|
+
color: "var(--ds-icon-disabled, #8993A4)",
|
|
84
|
+
backgroundColor: 'transparent'
|
|
85
|
+
},
|
|
86
|
+
'&:hover:disabled': {
|
|
87
|
+
backgroundColor: "var(--ds-background-disabled, transparent)"
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
var dragHandleButtonStylesOld = (0, _react2.css)({
|
|
53
91
|
position: 'absolute',
|
|
54
92
|
padding: "var(--ds-space-025, 2px)".concat(" 0"),
|
|
55
93
|
boxSizing: 'border-box',
|
|
@@ -88,6 +126,17 @@ var dragHandleButtonStyles = (0, _react2.css)({
|
|
|
88
126
|
backgroundColor: "var(--ds-background-disabled, transparent)"
|
|
89
127
|
}
|
|
90
128
|
});
|
|
129
|
+
var dragHandleContainerStyles = (0, _primitives.xcss)({
|
|
130
|
+
position: 'absolute',
|
|
131
|
+
boxSizing: 'border-box',
|
|
132
|
+
zIndex: 'card'
|
|
133
|
+
});
|
|
134
|
+
var tooltipContainerStyles = (0, _primitives.xcss)({
|
|
135
|
+
top: '8px',
|
|
136
|
+
bottom: '-8px',
|
|
137
|
+
position: 'sticky',
|
|
138
|
+
zIndex: 'card'
|
|
139
|
+
});
|
|
91
140
|
var dragHandleMultiLineSelectionFixFirefox = (0, _react2.css)({
|
|
92
141
|
'&::selection': {
|
|
93
142
|
backgroundColor: 'transparent'
|
|
@@ -151,7 +200,8 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
151
200
|
nodeType = _ref.nodeType,
|
|
152
201
|
handleOptions = _ref.handleOptions,
|
|
153
202
|
_ref$isTopLevelNode = _ref.isTopLevelNode,
|
|
154
|
-
isTopLevelNode = _ref$isTopLevelNode === void 0 ? true : _ref$isTopLevelNode
|
|
203
|
+
isTopLevelNode = _ref$isTopLevelNode === void 0 ? true : _ref$isTopLevelNode,
|
|
204
|
+
anchorRectCache = _ref.anchorRectCache;
|
|
155
205
|
var start = getPos();
|
|
156
206
|
var buttonRef = (0, _react.useRef)(null);
|
|
157
207
|
var _useState = (0, _react.useState)(768),
|
|
@@ -470,7 +520,12 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
470
520
|
parentNodeType = node === null || node === void 0 ? void 0 : node.type.name;
|
|
471
521
|
}
|
|
472
522
|
var supportsAnchor = CSS.supports('top', "anchor(".concat(anchorName, " start)")) && CSS.supports('left', "anchor(".concat(anchorName, " start)"));
|
|
473
|
-
var
|
|
523
|
+
var safeAnchorName = (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_2') ? (0, _anchorName.refreshAnchorName)({
|
|
524
|
+
getPos: getPos,
|
|
525
|
+
view: view,
|
|
526
|
+
anchorName: anchorName
|
|
527
|
+
}) : anchorName;
|
|
528
|
+
var dom = view.dom.querySelector("[data-drag-handler-anchor-name=\"".concat(safeAnchorName, "\"]"));
|
|
474
529
|
var hasResizer = nodeType === 'table' || nodeType === 'mediaSingle';
|
|
475
530
|
var isExtension = nodeType === 'extension' || nodeType === 'bodiedExtension' || nodeType === 'multiBodiedExtension' && (0, _platformFeatureFlags.fg)('platform_editor_multi_body_extension_extensibility');
|
|
476
531
|
var isBlockCard = nodeType === 'blockCard' && !!blockCardWidth;
|
|
@@ -490,17 +545,20 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
490
545
|
}
|
|
491
546
|
}
|
|
492
547
|
var isEdgeCase = (hasResizer || isExtension || isEmbedCard || isBlockCard) && innerContainer;
|
|
548
|
+
var isSticky = (0, _dragHandlePositions.shouldBeSticky)(nodeType);
|
|
493
549
|
if (supportsAnchor) {
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
550
|
+
var bottom = (0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') ? (0, _dragHandlePositions.getControlBottomCSSValue)(safeAnchorName, isSticky, isTopLevelNode, isLayoutColumn) : {};
|
|
551
|
+
return _objectSpread({
|
|
552
|
+
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)"),
|
|
553
|
+
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)")
|
|
554
|
+
}, bottom);
|
|
498
555
|
}
|
|
499
|
-
|
|
556
|
+
var height = (0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') ? (0, _dragHandlePositions.getControlHeightCSSValue)((0, _dragHandlePositions.getNodeHeight)(dom, safeAnchorName, anchorRectCache) || 0, isSticky, isTopLevelNode, "".concat(_consts.DRAG_HANDLE_HEIGHT), isLayoutColumn) : {};
|
|
557
|
+
return _objectSpread({
|
|
500
558
|
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),
|
|
501
559
|
top: (0, _dragHandlePositions.getTopPosition)(dom, nodeType)
|
|
502
|
-
};
|
|
503
|
-
}, [anchorName,
|
|
560
|
+
}, height);
|
|
561
|
+
}, [anchorName, getPos, view, nodeType, blockCardWidth, macroInteractionUpdates, anchorRectCache, isTopLevelNode, isLayoutColumn]);
|
|
504
562
|
var _useState7 = (0, _react.useState)({
|
|
505
563
|
display: 'none'
|
|
506
564
|
}),
|
|
@@ -637,14 +695,14 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
637
695
|
// eslint-disable-next-line @atlaskit/design-system/no-html-button
|
|
638
696
|
(0, _react2.jsx)("button", {
|
|
639
697
|
type: "button",
|
|
640
|
-
css: [dragHandleButtonStyles, (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && dragHandleColor,
|
|
698
|
+
css: [(0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') ? dragHandleButtonStyles : dragHandleButtonStylesOld, (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && dragHandleColor,
|
|
641
699
|
// ED-26266: Fixed the drag handle highlight when selecting multiple line in Firefox
|
|
642
700
|
// See https://product-fabric.atlassian.net/browse/ED-26266
|
|
643
701
|
_browser.browser.gecko && (0, _platformFeatureFlags.fg)('platform_editor_dnd_handle_highlight_fix_firefox') && dragHandleMultiLineSelectionFixFirefox, (0, _experiments.editorExperiment)('advanced_layouts', true) && isLayoutColumn && layoutColumnDragHandleStyles, dragHandleSelected && selectedStyles],
|
|
644
702
|
ref: buttonRef
|
|
645
703
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
646
704
|
,
|
|
647
|
-
style: positionStyles,
|
|
705
|
+
style: !(0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') && positionStyles || {},
|
|
648
706
|
onClick: handleOnClick,
|
|
649
707
|
onMouseDown: handleMouseDown,
|
|
650
708
|
onKeyDown: handleKeyDown
|
|
@@ -668,17 +726,60 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
668
726
|
})))
|
|
669
727
|
);
|
|
670
728
|
};
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
}
|
|
683
|
-
|
|
729
|
+
var stickyWithTooltip = function stickyWithTooltip() {
|
|
730
|
+
return (0, _react2.jsx)(_primitives.Box
|
|
731
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
732
|
+
, {
|
|
733
|
+
style: positionStyles,
|
|
734
|
+
xcss: [dragHandleContainerStyles],
|
|
735
|
+
as: "span",
|
|
736
|
+
testId: "block-ctrl-drag-handle-container"
|
|
737
|
+
}, (0, _react2.jsx)(_primitives.Box, {
|
|
738
|
+
xcss: [tooltipContainerStyles],
|
|
739
|
+
as: "span"
|
|
740
|
+
}, (0, _react2.jsx)(_tooltip.default, {
|
|
741
|
+
content: (0, _react2.jsx)(_keymaps.TooltipContentWithMultipleShortcuts, {
|
|
742
|
+
helpDescriptors: helpDescriptors
|
|
743
|
+
}),
|
|
744
|
+
ignoreTooltipPointerEvents: true,
|
|
745
|
+
position: 'top',
|
|
746
|
+
onShow: function onShow() {
|
|
747
|
+
var _api$accessibilityUti;
|
|
748
|
+
api === null || api === void 0 || (_api$accessibilityUti = api.accessibilityUtils) === null || _api$accessibilityUti === void 0 || _api$accessibilityUti.actions.ariaNotify(message, {
|
|
749
|
+
priority: 'important'
|
|
750
|
+
});
|
|
751
|
+
}
|
|
752
|
+
}, renderButton())));
|
|
753
|
+
};
|
|
754
|
+
var stickyWithoutTooltip = function stickyWithoutTooltip() {
|
|
755
|
+
return (0, _react2.jsx)(_primitives.Box
|
|
756
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
757
|
+
, {
|
|
758
|
+
style: positionStyles,
|
|
759
|
+
xcss: [dragHandleContainerStyles],
|
|
760
|
+
as: "span",
|
|
761
|
+
testId: "block-ctrl-drag-handle-container"
|
|
762
|
+
}, (0, _react2.jsx)(_primitives.Box, {
|
|
763
|
+
xcss: [tooltipContainerStyles],
|
|
764
|
+
as: "span"
|
|
765
|
+
}, renderButton()));
|
|
766
|
+
};
|
|
767
|
+
var buttonWithTooltip = function buttonWithTooltip() {
|
|
768
|
+
return (0, _react2.jsx)(_tooltip.default, {
|
|
769
|
+
content: (0, _react2.jsx)(_keymaps.TooltipContentWithMultipleShortcuts, {
|
|
770
|
+
helpDescriptors: helpDescriptors
|
|
771
|
+
}),
|
|
772
|
+
ignoreTooltipPointerEvents: true,
|
|
773
|
+
onShow: function onShow() {
|
|
774
|
+
var _api$accessibilityUti2;
|
|
775
|
+
api === null || api === void 0 || (_api$accessibilityUti2 = api.accessibilityUtils) === null || _api$accessibilityUti2 === void 0 || _api$accessibilityUti2.actions.ariaNotify(message, {
|
|
776
|
+
priority: 'important'
|
|
777
|
+
});
|
|
778
|
+
}
|
|
779
|
+
}, renderButton());
|
|
780
|
+
};
|
|
781
|
+
var isTooltip = !dragHandleDisabled && (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_23873');
|
|
782
|
+
var stickyRender = isTooltip ? stickyWithTooltip() : stickyWithoutTooltip();
|
|
783
|
+
var render = isTooltip ? buttonWithTooltip() : renderButton();
|
|
784
|
+
return (0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') ? stickyRender : render;
|
|
684
785
|
};
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.TypeAheadControl = void 0;
|
|
9
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
12
|
var _bindEventListener = require("bind-event-listener");
|
|
@@ -21,10 +22,13 @@ var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
|
|
|
21
22
|
var _dragHandlePositions = require("../pm-plugins/utils/drag-handle-positions");
|
|
22
23
|
var _widgetPositions = require("../pm-plugins/utils/widget-positions");
|
|
23
24
|
var _consts = require("./consts");
|
|
25
|
+
var _anchorName = require("./utils/anchor-name");
|
|
24
26
|
var _documentChecks = require("./utils/document-checks");
|
|
25
27
|
var _editorCommands = require("./utils/editor-commands");
|
|
26
28
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
27
29
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
30
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
31
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
28
32
|
var TEXT_PARENT_TYPES = ['paragraph', 'heading', 'blockquote', 'taskItem', 'decisionItem'];
|
|
29
33
|
var buttonStyles = (0, _primitives.xcss)({
|
|
30
34
|
boxSizing: 'border-box',
|
|
@@ -58,6 +62,31 @@ var disabledStyles = (0, _primitives.xcss)({
|
|
|
58
62
|
backgroundColor: 'color.background.disabled'
|
|
59
63
|
}
|
|
60
64
|
});
|
|
65
|
+
var stickyButtonStyles = (0, _primitives.xcss)({
|
|
66
|
+
top: '0',
|
|
67
|
+
position: 'sticky',
|
|
68
|
+
boxSizing: 'border-box',
|
|
69
|
+
display: 'flex',
|
|
70
|
+
flexDirection: 'column',
|
|
71
|
+
justifyContent: 'center',
|
|
72
|
+
alignItems: 'center',
|
|
73
|
+
height: "var(--ds-space-300, 24px)",
|
|
74
|
+
width: "var(--ds-space-300, 24px)",
|
|
75
|
+
border: 'none',
|
|
76
|
+
backgroundColor: 'color.background.neutral.subtle',
|
|
77
|
+
borderRadius: '50%',
|
|
78
|
+
zIndex: 'card',
|
|
79
|
+
outline: 'none',
|
|
80
|
+
':hover': {
|
|
81
|
+
backgroundColor: 'color.background.neutral.subtle.hovered'
|
|
82
|
+
},
|
|
83
|
+
':active': {
|
|
84
|
+
backgroundColor: 'color.background.neutral.subtle.pressed'
|
|
85
|
+
},
|
|
86
|
+
':focus': {
|
|
87
|
+
outline: "2px solid ".concat("var(--ds-border-focused, #388BFF)")
|
|
88
|
+
}
|
|
89
|
+
});
|
|
61
90
|
var containerStaticStyles = (0, _primitives.xcss)({
|
|
62
91
|
position: 'absolute',
|
|
63
92
|
zIndex: 'card'
|
|
@@ -65,6 +94,12 @@ var containerStaticStyles = (0, _primitives.xcss)({
|
|
|
65
94
|
var disabledContainerStyles = (0, _primitives.xcss)({
|
|
66
95
|
cursor: 'not-allowed'
|
|
67
96
|
});
|
|
97
|
+
var tooltipContainerStyles = (0, _primitives.xcss)({
|
|
98
|
+
top: '8px',
|
|
99
|
+
bottom: '-8px',
|
|
100
|
+
position: 'sticky',
|
|
101
|
+
zIndex: 'card'
|
|
102
|
+
});
|
|
68
103
|
|
|
69
104
|
// TODO: ED-26959 - Share prop types between DragHandle - generic enough to create a type for block control decoration
|
|
70
105
|
|
|
@@ -73,8 +108,11 @@ var TypeAheadControl = exports.TypeAheadControl = function TypeAheadControl(_ref
|
|
|
73
108
|
api = _ref.api,
|
|
74
109
|
formatMessage = _ref.formatMessage,
|
|
75
110
|
getPos = _ref.getPos,
|
|
111
|
+
nodeType = _ref.nodeType,
|
|
112
|
+
anchorName = _ref.anchorName,
|
|
76
113
|
rootAnchorName = _ref.rootAnchorName,
|
|
77
|
-
rootNodeType = _ref.rootNodeType
|
|
114
|
+
rootNodeType = _ref.rootNodeType,
|
|
115
|
+
anchorRectCache = _ref.anchorRectCache;
|
|
78
116
|
var macroInteractionUpdates = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'featureFlags.macroInteractionUpdates');
|
|
79
117
|
var isTypeAheadOpen = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'typeAhead.isOpen');
|
|
80
118
|
var _useState = (0, _react.useState)({
|
|
@@ -91,7 +129,12 @@ var TypeAheadControl = exports.TypeAheadControl = function TypeAheadControl(_ref
|
|
|
91
129
|
// CHANGES - `removed editorExperiment('advanced_layouts', true) && isLayoutColumn` checks as quick insert button will not be positioned for layout column
|
|
92
130
|
var calculatePosition = (0, _react.useCallback)(function () {
|
|
93
131
|
var supportsAnchor = CSS.supports('top', "anchor(".concat(rootAnchorName, " start)")) && CSS.supports('left', "anchor(".concat(rootAnchorName, " start)"));
|
|
94
|
-
var
|
|
132
|
+
var safeAnchorName = (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_2') ? (0, _anchorName.refreshAnchorName)({
|
|
133
|
+
getPos: getPos,
|
|
134
|
+
view: view,
|
|
135
|
+
anchorName: rootAnchorName
|
|
136
|
+
}) : rootAnchorName;
|
|
137
|
+
var dom = view.dom.querySelector("[data-drag-handler-anchor-name=\"".concat(safeAnchorName, "\"]"));
|
|
95
138
|
var hasResizer = rootNodeType === 'table' || rootNodeType === 'mediaSingle';
|
|
96
139
|
var isExtension = rootNodeType === 'extension' || rootNodeType === 'bodiedExtension';
|
|
97
140
|
var isBlockCard = rootNodeType === 'blockCard';
|
|
@@ -111,17 +154,25 @@ var TypeAheadControl = exports.TypeAheadControl = function TypeAheadControl(_ref
|
|
|
111
154
|
}
|
|
112
155
|
}
|
|
113
156
|
var isEdgeCase = (hasResizer || isExtension || isEmbedCard || isBlockCard) && innerContainer;
|
|
157
|
+
var isSticky = (0, _dragHandlePositions.shouldBeSticky)(rootNodeType);
|
|
158
|
+
var bottom = (0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') ? (0, _dragHandlePositions.getControlBottomCSSValue)(safeAnchorName || anchorName, isSticky, true) : {};
|
|
114
159
|
if (supportsAnchor) {
|
|
115
|
-
return {
|
|
116
|
-
left: isEdgeCase ? "calc(anchor(".concat(
|
|
117
|
-
top: "calc(anchor(".concat(
|
|
118
|
-
};
|
|
160
|
+
return _objectSpread({
|
|
161
|
+
left: isEdgeCase ? "calc(anchor(".concat(safeAnchorName, " start) + ").concat((0, _widgetPositions.getLeftPositionForRootElement)(dom, rootNodeType, _consts.QUICK_INSERT_DIMENSIONS, innerContainer, isMacroInteractionUpdates), " + -").concat(_consts.QUICK_INSERT_LEFT_OFFSET, "px)") : "calc(anchor(".concat(safeAnchorName, " start) - ").concat(_consts.QUICK_INSERT_DIMENSIONS.width, "px - ").concat((0, _consts.rootElementGap)(rootNodeType), "px + -").concat(_consts.QUICK_INSERT_LEFT_OFFSET, "px)"),
|
|
162
|
+
top: "calc(anchor(".concat(safeAnchorName, " start) + ").concat((0, _consts.topPositionAdjustment)(rootNodeType), "px)")
|
|
163
|
+
}, bottom);
|
|
119
164
|
}
|
|
120
|
-
|
|
165
|
+
|
|
166
|
+
// expensive, calls offsetHeight, guard behind FG
|
|
167
|
+
var nodeHeight =
|
|
168
|
+
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
169
|
+
(0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') && (0, _dragHandlePositions.getNodeHeight)(dom, safeAnchorName || anchorName, anchorRectCache) || 0;
|
|
170
|
+
var height = (0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') ? (0, _dragHandlePositions.getControlHeightCSSValue)(nodeHeight, isSticky, true, "var(--ds-space-300, 24px)") : {};
|
|
171
|
+
return _objectSpread({
|
|
121
172
|
left: isEdgeCase ? "calc(".concat((dom === null || dom === void 0 ? void 0 : dom.offsetLeft) || 0, "px + ").concat((0, _widgetPositions.getLeftPositionForRootElement)(dom, rootNodeType, _consts.QUICK_INSERT_DIMENSIONS, innerContainer, isMacroInteractionUpdates), " + -").concat(_consts.QUICK_INSERT_LEFT_OFFSET, "px)") : "calc(".concat((0, _widgetPositions.getLeftPositionForRootElement)(dom, rootNodeType, _consts.QUICK_INSERT_DIMENSIONS, innerContainer, isMacroInteractionUpdates), " + -").concat(_consts.QUICK_INSERT_LEFT_OFFSET, "px)"),
|
|
122
173
|
top: (0, _dragHandlePositions.getTopPosition)(dom, rootNodeType)
|
|
123
|
-
};
|
|
124
|
-
}, [rootAnchorName, view
|
|
174
|
+
}, height);
|
|
175
|
+
}, [rootAnchorName, getPos, view, rootNodeType, macroInteractionUpdates, anchorName, anchorRectCache]);
|
|
125
176
|
(0, _react.useEffect)(function () {
|
|
126
177
|
var cleanUpTransitionListener;
|
|
127
178
|
if (rootNodeType === 'extension' || rootNodeType === 'embedCard') {
|
|
@@ -206,26 +257,31 @@ var TypeAheadControl = exports.TypeAheadControl = function TypeAheadControl(_ref
|
|
|
206
257
|
});
|
|
207
258
|
}
|
|
208
259
|
}, [api, view.state]);
|
|
260
|
+
var tooltipPressable = function tooltipPressable() {
|
|
261
|
+
return /*#__PURE__*/_react.default.createElement(_tooltip.default, {
|
|
262
|
+
position: "top",
|
|
263
|
+
content: /*#__PURE__*/_react.default.createElement(_keymaps.ToolTipContent, {
|
|
264
|
+
description: formatMessage(_messages.blockControlsMessages.insert)
|
|
265
|
+
})
|
|
266
|
+
}, /*#__PURE__*/_react.default.createElement(_primitives.Pressable, {
|
|
267
|
+
testId: "editor-quick-insert-button",
|
|
268
|
+
type: "button",
|
|
269
|
+
"aria-label": formatMessage(_messages.blockControlsMessages.insert),
|
|
270
|
+
xcss: [(0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') ? buttonStyles : stickyButtonStyles, isTypeAheadOpen && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_1') && disabledStyles],
|
|
271
|
+
onClick: handleQuickInsert,
|
|
272
|
+
onMouseDown: (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_1') ? undefined : handleMouseDown,
|
|
273
|
+
isDisabled: (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_1') ? isTypeAheadOpen : undefined
|
|
274
|
+
}, /*#__PURE__*/_react.default.createElement(_add.default, {
|
|
275
|
+
label: "add",
|
|
276
|
+
color: isTypeAheadOpen ? "var(--ds-icon-disabled, #091E424F)" : "var(--ds-icon-subtle, #626F86)"
|
|
277
|
+
})));
|
|
278
|
+
};
|
|
209
279
|
return /*#__PURE__*/_react.default.createElement(_primitives.Box
|
|
210
280
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
211
281
|
, {
|
|
212
282
|
style: positionStyles,
|
|
213
283
|
xcss: [containerStaticStyles, isTypeAheadOpen && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_1') && disabledContainerStyles]
|
|
214
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
description: formatMessage(_messages.blockControlsMessages.insert)
|
|
218
|
-
})
|
|
219
|
-
}, /*#__PURE__*/_react.default.createElement(_primitives.Pressable, {
|
|
220
|
-
testId: "editor-quick-insert-button",
|
|
221
|
-
type: "button",
|
|
222
|
-
"aria-label": formatMessage(_messages.blockControlsMessages.insert),
|
|
223
|
-
xcss: [buttonStyles, isTypeAheadOpen && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_1') && disabledStyles],
|
|
224
|
-
onClick: handleQuickInsert,
|
|
225
|
-
onMouseDown: (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_1') ? undefined : handleMouseDown,
|
|
226
|
-
isDisabled: (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_1') ? isTypeAheadOpen : undefined
|
|
227
|
-
}, /*#__PURE__*/_react.default.createElement(_add.default, {
|
|
228
|
-
label: "add",
|
|
229
|
-
color: isTypeAheadOpen ? "var(--ds-icon-disabled, #091E424F)" : "var(--ds-icon-subtle, #626F86)"
|
|
230
|
-
}))));
|
|
284
|
+
}, (0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') ? /*#__PURE__*/_react.default.createElement(_primitives.Box, {
|
|
285
|
+
xcss: [tooltipContainerStyles]
|
|
286
|
+
}, tooltipPressable()) : tooltipPressable());
|
|
231
287
|
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.refreshAnchorName = void 0;
|
|
7
|
+
var _decorationsAnchor = require("../../pm-plugins/decorations-anchor");
|
|
8
|
+
var _main = require("../../pm-plugins/main");
|
|
9
|
+
/**
|
|
10
|
+
* Checks for plugin state for latest anchorName based on the position, returns
|
|
11
|
+
* provided anchorName if available
|
|
12
|
+
*/
|
|
13
|
+
var refreshAnchorName = exports.refreshAnchorName = function refreshAnchorName(_ref) {
|
|
14
|
+
var getPos = _ref.getPos,
|
|
15
|
+
view = _ref.view,
|
|
16
|
+
anchorName = _ref.anchorName;
|
|
17
|
+
var newAnchorName = anchorName || '';
|
|
18
|
+
var pos = getPos();
|
|
19
|
+
if (anchorName || pos === undefined) {
|
|
20
|
+
return newAnchorName;
|
|
21
|
+
}
|
|
22
|
+
var node = view.state.doc.nodeAt(pos);
|
|
23
|
+
var state = _main.key.getState(view.state);
|
|
24
|
+
if (state !== null && state !== void 0 && state.decorations) {
|
|
25
|
+
var _node$nodeSize;
|
|
26
|
+
var nodeDecs = (0, _decorationsAnchor.findNodeDecs)(state.decorations, pos, pos + ((_node$nodeSize = node === null || node === void 0 ? void 0 : node.nodeSize) !== null && _node$nodeSize !== void 0 ? _node$nodeSize : 0));
|
|
27
|
+
var nodeDec = nodeDecs.at(0);
|
|
28
|
+
if (!nodeDec) {
|
|
29
|
+
return newAnchorName;
|
|
30
|
+
}
|
|
31
|
+
newAnchorName = nodeDec.spec.anchorName;
|
|
32
|
+
}
|
|
33
|
+
return newAnchorName;
|
|
34
|
+
};
|
|
@@ -19,7 +19,7 @@ export const emptyParagraphNodeDecorations = () => {
|
|
|
19
19
|
export const findHandleDec = (decorations, from, to) => {
|
|
20
20
|
return decorations.find(from, to, spec => spec.type === TYPE_HANDLE_DEC);
|
|
21
21
|
};
|
|
22
|
-
export const dragHandleDecoration = (api, formatMessage, pos, anchorName, nodeType, nodeViewPortalProviderAPI, handleOptions) => {
|
|
22
|
+
export const dragHandleDecoration = (api, formatMessage, pos, anchorName, nodeType, nodeViewPortalProviderAPI, handleOptions, anchorRectCache) => {
|
|
23
23
|
unmountDecorations(nodeViewPortalProviderAPI, 'data-blocks-drag-handle-container', 'data-blocks-drag-handle-key');
|
|
24
24
|
let unbind;
|
|
25
25
|
const key = uuid();
|
|
@@ -91,7 +91,8 @@ export const dragHandleDecoration = (api, formatMessage, pos, anchorName, nodeTy
|
|
|
91
91
|
anchorName,
|
|
92
92
|
nodeType,
|
|
93
93
|
handleOptions,
|
|
94
|
-
isTopLevelNode
|
|
94
|
+
isTopLevelNode,
|
|
95
|
+
anchorRectCache
|
|
95
96
|
}), element);
|
|
96
97
|
//}
|
|
97
98
|
return element;
|
|
@@ -6,7 +6,7 @@ const TYPE_QUICK_INSERT = 'INSERT_BUTTON';
|
|
|
6
6
|
export const findQuickInsertInsertButtonDecoration = (decorations, from, to) => {
|
|
7
7
|
return decorations.find(from, to, spec => spec.type === TYPE_QUICK_INSERT);
|
|
8
8
|
};
|
|
9
|
-
export const quickInsertButtonDecoration = (api, formatMessage, rootPos, anchorName, nodeType, nodeViewPortalProviderAPI, rootAnchorName, rootNodeType) => {
|
|
9
|
+
export const quickInsertButtonDecoration = (api, formatMessage, rootPos, anchorName, nodeType, nodeViewPortalProviderAPI, rootAnchorName, rootNodeType, anchorRectCache) => {
|
|
10
10
|
const key = uuid();
|
|
11
11
|
return Decoration.widget(rootPos, (view, getPos) => {
|
|
12
12
|
const element = document.createElement('span');
|
|
@@ -21,7 +21,8 @@ export const quickInsertButtonDecoration = (api, formatMessage, rootPos, anchorN
|
|
|
21
21
|
nodeType,
|
|
22
22
|
anchorName,
|
|
23
23
|
rootAnchorName,
|
|
24
|
-
rootNodeType: rootNodeType !== null && rootNodeType !== void 0 ? rootNodeType : nodeType
|
|
24
|
+
rootNodeType: rootNodeType !== null && rootNodeType !== void 0 ? rootNodeType : nodeType,
|
|
25
|
+
anchorRectCache
|
|
25
26
|
}), element, key);
|
|
26
27
|
return element;
|
|
27
28
|
}, {
|