@atlaskit/editor-plugin-block-controls 3.8.0 → 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 +10 -0
- package/dist/cjs/pm-plugins/handle-mouse-down.js +25 -0
- package/dist/cjs/pm-plugins/main.js +2 -0
- package/dist/cjs/ui/drag-handle.js +17 -10
- package/dist/cjs/ui/quick-insert-button.js +14 -7
- package/dist/cjs/ui/utils/anchor-name.js +34 -0
- package/dist/es2019/pm-plugins/handle-mouse-down.js +17 -0
- package/dist/es2019/pm-plugins/main.js +2 -0
- package/dist/es2019/ui/drag-handle.js +17 -10
- package/dist/es2019/ui/quick-insert-button.js +14 -7
- package/dist/es2019/ui/utils/anchor-name.js +29 -0
- package/dist/esm/pm-plugins/handle-mouse-down.js +19 -0
- package/dist/esm/pm-plugins/main.js +2 -0
- package/dist/esm/ui/drag-handle.js +17 -10
- package/dist/esm/ui/quick-insert-button.js +14 -7
- package/dist/esm/ui/utils/anchor-name.js +28 -0
- package/dist/types/pm-plugins/handle-mouse-down.d.ts +4 -0
- package/dist/types/ui/utils/anchor-name.d.ts +12 -0
- package/dist/types-ts4.5/pm-plugins/handle-mouse-down.d.ts +4 -0
- package/dist/types-ts4.5/ui/utils/anchor-name.d.ts +12 -0
- package/package.json +9 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
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
|
+
|
|
3
13
|
## 3.8.0
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
|
@@ -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");
|
|
@@ -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) {
|
|
@@ -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
|
|
@@ -130,8 +131,9 @@ var dragHandleContainerStyles = (0, _primitives.xcss)({
|
|
|
130
131
|
boxSizing: 'border-box',
|
|
131
132
|
zIndex: 'card'
|
|
132
133
|
});
|
|
133
|
-
var
|
|
134
|
-
top: '
|
|
134
|
+
var tooltipContainerStyles = (0, _primitives.xcss)({
|
|
135
|
+
top: '8px',
|
|
136
|
+
bottom: '-8px',
|
|
135
137
|
position: 'sticky',
|
|
136
138
|
zIndex: 'card'
|
|
137
139
|
});
|
|
@@ -518,7 +520,12 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
518
520
|
parentNodeType = node === null || node === void 0 ? void 0 : node.type.name;
|
|
519
521
|
}
|
|
520
522
|
var supportsAnchor = CSS.supports('top', "anchor(".concat(anchorName, " start)")) && CSS.supports('left', "anchor(".concat(anchorName, " start)"));
|
|
521
|
-
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, "\"]"));
|
|
522
529
|
var hasResizer = nodeType === 'table' || nodeType === 'mediaSingle';
|
|
523
530
|
var isExtension = nodeType === 'extension' || nodeType === 'bodiedExtension' || nodeType === 'multiBodiedExtension' && (0, _platformFeatureFlags.fg)('platform_editor_multi_body_extension_extensibility');
|
|
524
531
|
var isBlockCard = nodeType === 'blockCard' && !!blockCardWidth;
|
|
@@ -540,18 +547,18 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
540
547
|
var isEdgeCase = (hasResizer || isExtension || isEmbedCard || isBlockCard) && innerContainer;
|
|
541
548
|
var isSticky = (0, _dragHandlePositions.shouldBeSticky)(nodeType);
|
|
542
549
|
if (supportsAnchor) {
|
|
543
|
-
var bottom = (0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') ? (0, _dragHandlePositions.getControlBottomCSSValue)(
|
|
550
|
+
var bottom = (0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') ? (0, _dragHandlePositions.getControlBottomCSSValue)(safeAnchorName, isSticky, isTopLevelNode, isLayoutColumn) : {};
|
|
544
551
|
return _objectSpread({
|
|
545
|
-
left: isEdgeCase ? "calc(anchor(".concat(
|
|
546
|
-
top: (0, _experiments.editorExperiment)('advanced_layouts', true) && isLayoutColumn ? "calc(anchor(".concat(
|
|
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)")
|
|
547
554
|
}, bottom);
|
|
548
555
|
}
|
|
549
|
-
var height = (0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') ? (0, _dragHandlePositions.getControlHeightCSSValue)((0, _dragHandlePositions.getNodeHeight)(dom,
|
|
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) : {};
|
|
550
557
|
return _objectSpread({
|
|
551
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),
|
|
552
559
|
top: (0, _dragHandlePositions.getTopPosition)(dom, nodeType)
|
|
553
560
|
}, height);
|
|
554
|
-
}, [anchorName,
|
|
561
|
+
}, [anchorName, getPos, view, nodeType, blockCardWidth, macroInteractionUpdates, anchorRectCache, isTopLevelNode, isLayoutColumn]);
|
|
555
562
|
var _useState7 = (0, _react.useState)({
|
|
556
563
|
display: 'none'
|
|
557
564
|
}),
|
|
@@ -728,7 +735,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
728
735
|
as: "span",
|
|
729
736
|
testId: "block-ctrl-drag-handle-container"
|
|
730
737
|
}, (0, _react2.jsx)(_primitives.Box, {
|
|
731
|
-
xcss: [
|
|
738
|
+
xcss: [tooltipContainerStyles],
|
|
732
739
|
as: "span"
|
|
733
740
|
}, (0, _react2.jsx)(_tooltip.default, {
|
|
734
741
|
content: (0, _react2.jsx)(_keymaps.TooltipContentWithMultipleShortcuts, {
|
|
@@ -753,7 +760,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
753
760
|
as: "span",
|
|
754
761
|
testId: "block-ctrl-drag-handle-container"
|
|
755
762
|
}, (0, _react2.jsx)(_primitives.Box, {
|
|
756
|
-
xcss: [
|
|
763
|
+
xcss: [tooltipContainerStyles],
|
|
757
764
|
as: "span"
|
|
758
765
|
}, renderButton()));
|
|
759
766
|
};
|
|
@@ -22,6 +22,7 @@ var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
|
|
|
22
22
|
var _dragHandlePositions = require("../pm-plugins/utils/drag-handle-positions");
|
|
23
23
|
var _widgetPositions = require("../pm-plugins/utils/widget-positions");
|
|
24
24
|
var _consts = require("./consts");
|
|
25
|
+
var _anchorName = require("./utils/anchor-name");
|
|
25
26
|
var _documentChecks = require("./utils/document-checks");
|
|
26
27
|
var _editorCommands = require("./utils/editor-commands");
|
|
27
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); }
|
|
@@ -94,7 +95,8 @@ var disabledContainerStyles = (0, _primitives.xcss)({
|
|
|
94
95
|
cursor: 'not-allowed'
|
|
95
96
|
});
|
|
96
97
|
var tooltipContainerStyles = (0, _primitives.xcss)({
|
|
97
|
-
top: '
|
|
98
|
+
top: '8px',
|
|
99
|
+
bottom: '-8px',
|
|
98
100
|
position: 'sticky',
|
|
99
101
|
zIndex: 'card'
|
|
100
102
|
});
|
|
@@ -127,7 +129,12 @@ var TypeAheadControl = exports.TypeAheadControl = function TypeAheadControl(_ref
|
|
|
127
129
|
// CHANGES - `removed editorExperiment('advanced_layouts', true) && isLayoutColumn` checks as quick insert button will not be positioned for layout column
|
|
128
130
|
var calculatePosition = (0, _react.useCallback)(function () {
|
|
129
131
|
var supportsAnchor = CSS.supports('top', "anchor(".concat(rootAnchorName, " start)")) && CSS.supports('left', "anchor(".concat(rootAnchorName, " start)"));
|
|
130
|
-
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, "\"]"));
|
|
131
138
|
var hasResizer = rootNodeType === 'table' || rootNodeType === 'mediaSingle';
|
|
132
139
|
var isExtension = rootNodeType === 'extension' || rootNodeType === 'bodiedExtension';
|
|
133
140
|
var isBlockCard = rootNodeType === 'blockCard';
|
|
@@ -148,24 +155,24 @@ var TypeAheadControl = exports.TypeAheadControl = function TypeAheadControl(_ref
|
|
|
148
155
|
}
|
|
149
156
|
var isEdgeCase = (hasResizer || isExtension || isEmbedCard || isBlockCard) && innerContainer;
|
|
150
157
|
var isSticky = (0, _dragHandlePositions.shouldBeSticky)(rootNodeType);
|
|
151
|
-
var bottom = (0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') ? (0, _dragHandlePositions.getControlBottomCSSValue)(
|
|
158
|
+
var bottom = (0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') ? (0, _dragHandlePositions.getControlBottomCSSValue)(safeAnchorName || anchorName, isSticky, true) : {};
|
|
152
159
|
if (supportsAnchor) {
|
|
153
160
|
return _objectSpread({
|
|
154
|
-
left: isEdgeCase ? "calc(anchor(".concat(
|
|
155
|
-
top: "calc(anchor(".concat(
|
|
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)")
|
|
156
163
|
}, bottom);
|
|
157
164
|
}
|
|
158
165
|
|
|
159
166
|
// expensive, calls offsetHeight, guard behind FG
|
|
160
167
|
var nodeHeight =
|
|
161
168
|
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
162
|
-
(0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') && (0, _dragHandlePositions.getNodeHeight)(dom,
|
|
169
|
+
(0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') && (0, _dragHandlePositions.getNodeHeight)(dom, safeAnchorName || anchorName, anchorRectCache) || 0;
|
|
163
170
|
var height = (0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') ? (0, _dragHandlePositions.getControlHeightCSSValue)(nodeHeight, isSticky, true, "var(--ds-space-300, 24px)") : {};
|
|
164
171
|
return _objectSpread({
|
|
165
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)"),
|
|
166
173
|
top: (0, _dragHandlePositions.getTopPosition)(dom, rootNodeType)
|
|
167
174
|
}, height);
|
|
168
|
-
}, [rootAnchorName, view
|
|
175
|
+
}, [rootAnchorName, getPos, view, rootNodeType, macroInteractionUpdates, anchorName, anchorRectCache]);
|
|
169
176
|
(0, _react.useEffect)(function () {
|
|
170
177
|
var cleanUpTransitionListener;
|
|
171
178
|
if (rootNodeType === 'extension' || rootNodeType === 'embedCard') {
|
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const handleMouseDown = api => (view, event) => {
|
|
2
|
+
if (view.editable) {
|
|
3
|
+
return false;
|
|
4
|
+
}
|
|
5
|
+
if (event.target instanceof HTMLElement) {
|
|
6
|
+
var _rootNode$type$name, _rootNode$type$name2;
|
|
7
|
+
const targetPos = view.posAtDOM(event.target, 0);
|
|
8
|
+
// always fetch top level position for mouseDown to avoid drag handle positions being incorrect
|
|
9
|
+
const rootPos = view.state.doc.resolve(targetPos).before(1);
|
|
10
|
+
const rootNode = view.state.doc.nodeAt(rootPos);
|
|
11
|
+
if (!rootNode) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
api === null || api === void 0 ? 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 : ''));
|
|
15
|
+
}
|
|
16
|
+
return false;
|
|
17
|
+
};
|
|
@@ -17,6 +17,7 @@ import { findNodeDecs, nodeDecorations } from './decorations-anchor';
|
|
|
17
17
|
import { dragHandleDecoration, emptyParagraphNodeDecorations, findHandleDec } from './decorations-drag-handle';
|
|
18
18
|
import { dropTargetDecorations, findDropTargetDecs } from './decorations-drop-target';
|
|
19
19
|
import { findQuickInsertInsertButtonDecoration, quickInsertButtonDecoration } from './decorations-quick-insert-button';
|
|
20
|
+
import { handleMouseDown } from './handle-mouse-down';
|
|
20
21
|
import { handleMouseOver } from './handle-mouse-over';
|
|
21
22
|
import { boundKeydownHandler } from './keymap';
|
|
22
23
|
import { defaultActiveAnchorTracker } from './utils/active-anchor-tracker';
|
|
@@ -714,6 +715,7 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI) => {
|
|
|
714
715
|
handleMouseOver(view, event, api);
|
|
715
716
|
return false;
|
|
716
717
|
},
|
|
718
|
+
mousedown: editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_2') ? handleMouseDown(api) : undefined,
|
|
717
719
|
keydown(view, event) {
|
|
718
720
|
if (isMultiSelectEnabled) {
|
|
719
721
|
if (event.shiftKey && event.ctrlKey) {
|
|
@@ -31,6 +31,7 @@ import { isHandleCorrelatedToSelection, selectNode } from '../pm-plugins/utils/g
|
|
|
31
31
|
import { alignAnchorHeadInDirectionOfPos, expandSelectionHeadToNodeAtPos } from '../pm-plugins/utils/selection';
|
|
32
32
|
import { BLOCK_MENU_ENABLED, DRAG_HANDLE_BORDER_RADIUS, DRAG_HANDLE_HEIGHT, DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH, DRAG_HANDLE_WIDTH, DRAG_HANDLE_ZINDEX, dragHandleGap, nodeMargins, spacingBetweenNodesForPreview, topPositionAdjustment } from './consts';
|
|
33
33
|
import { dragPreview } from './drag-preview';
|
|
34
|
+
import { refreshAnchorName } from './utils/anchor-name';
|
|
34
35
|
const iconWrapperStyles = xcss({
|
|
35
36
|
display: 'flex',
|
|
36
37
|
justifyContent: 'center',
|
|
@@ -122,8 +123,9 @@ const dragHandleContainerStyles = xcss({
|
|
|
122
123
|
boxSizing: 'border-box',
|
|
123
124
|
zIndex: 'card'
|
|
124
125
|
});
|
|
125
|
-
const
|
|
126
|
-
top: '
|
|
126
|
+
const tooltipContainerStyles = xcss({
|
|
127
|
+
top: '8px',
|
|
128
|
+
bottom: '-8px',
|
|
127
129
|
position: 'sticky',
|
|
128
130
|
zIndex: 'card'
|
|
129
131
|
});
|
|
@@ -507,7 +509,12 @@ export const DragHandle = ({
|
|
|
507
509
|
parentNodeType = node === null || node === void 0 ? void 0 : node.type.name;
|
|
508
510
|
}
|
|
509
511
|
const supportsAnchor = CSS.supports('top', `anchor(${anchorName} start)`) && CSS.supports('left', `anchor(${anchorName} start)`);
|
|
510
|
-
const
|
|
512
|
+
const safeAnchorName = editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_2') ? refreshAnchorName({
|
|
513
|
+
getPos,
|
|
514
|
+
view,
|
|
515
|
+
anchorName
|
|
516
|
+
}) : anchorName;
|
|
517
|
+
const dom = view.dom.querySelector(`[data-drag-handler-anchor-name="${safeAnchorName}"]`);
|
|
511
518
|
const hasResizer = nodeType === 'table' || nodeType === 'mediaSingle';
|
|
512
519
|
const isExtension = nodeType === 'extension' || nodeType === 'bodiedExtension' || nodeType === 'multiBodiedExtension' && fg('platform_editor_multi_body_extension_extensibility');
|
|
513
520
|
const isBlockCard = nodeType === 'blockCard' && !!blockCardWidth;
|
|
@@ -529,20 +536,20 @@ export const DragHandle = ({
|
|
|
529
536
|
const isEdgeCase = (hasResizer || isExtension || isEmbedCard || isBlockCard) && innerContainer;
|
|
530
537
|
const isSticky = shouldBeSticky(nodeType);
|
|
531
538
|
if (supportsAnchor) {
|
|
532
|
-
const bottom = fg('platform_editor_controls_sticky_controls') ? getControlBottomCSSValue(
|
|
539
|
+
const bottom = fg('platform_editor_controls_sticky_controls') ? getControlBottomCSSValue(safeAnchorName, isSticky, isTopLevelNode, isLayoutColumn) : {};
|
|
533
540
|
return {
|
|
534
|
-
left: isEdgeCase ? `calc(anchor(${
|
|
535
|
-
top: editorExperiment('advanced_layouts', true) && isLayoutColumn ? `calc(anchor(${
|
|
541
|
+
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)`,
|
|
542
|
+
top: editorExperiment('advanced_layouts', true) && isLayoutColumn ? `calc(anchor(${safeAnchorName} top) - ${DRAG_HANDLE_WIDTH}px)` : `calc(anchor(${safeAnchorName} start) + ${topPositionAdjustment(nodeType)}px)`,
|
|
536
543
|
...bottom
|
|
537
544
|
};
|
|
538
545
|
}
|
|
539
|
-
const height = fg('platform_editor_controls_sticky_controls') ? getControlHeightCSSValue(getNodeHeight(dom,
|
|
546
|
+
const height = fg('platform_editor_controls_sticky_controls') ? getControlHeightCSSValue(getNodeHeight(dom, safeAnchorName, anchorRectCache) || 0, isSticky, isTopLevelNode, `${DRAG_HANDLE_HEIGHT}`, isLayoutColumn) : {};
|
|
540
547
|
return {
|
|
541
548
|
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),
|
|
542
549
|
top: getTopPosition(dom, nodeType),
|
|
543
550
|
...height
|
|
544
551
|
};
|
|
545
|
-
}, [anchorName,
|
|
552
|
+
}, [anchorName, getPos, view, nodeType, blockCardWidth, macroInteractionUpdates, anchorRectCache, isTopLevelNode, isLayoutColumn]);
|
|
546
553
|
const [positionStyles, setPositionStyles] = useState({
|
|
547
554
|
display: 'none'
|
|
548
555
|
});
|
|
@@ -712,7 +719,7 @@ export const DragHandle = ({
|
|
|
712
719
|
as: "span",
|
|
713
720
|
testId: "block-ctrl-drag-handle-container"
|
|
714
721
|
}, jsx(Box, {
|
|
715
|
-
xcss: [
|
|
722
|
+
xcss: [tooltipContainerStyles],
|
|
716
723
|
as: "span"
|
|
717
724
|
}, jsx(Tooltip, {
|
|
718
725
|
content: jsx(TooltipContentWithMultipleShortcuts, {
|
|
@@ -735,7 +742,7 @@ export const DragHandle = ({
|
|
|
735
742
|
as: "span",
|
|
736
743
|
testId: "block-ctrl-drag-handle-container"
|
|
737
744
|
}, jsx(Box, {
|
|
738
|
-
xcss: [
|
|
745
|
+
xcss: [tooltipContainerStyles],
|
|
739
746
|
as: "span"
|
|
740
747
|
}, renderButton()));
|
|
741
748
|
const buttonWithTooltip = () => jsx(Tooltip, {
|
|
@@ -12,6 +12,7 @@ import Tooltip from '@atlaskit/tooltip';
|
|
|
12
12
|
import { getControlBottomCSSValue, getControlHeightCSSValue, getNodeHeight, getTopPosition, shouldBeSticky } from '../pm-plugins/utils/drag-handle-positions';
|
|
13
13
|
import { getLeftPositionForRootElement } from '../pm-plugins/utils/widget-positions';
|
|
14
14
|
import { rootElementGap, topPositionAdjustment, QUICK_INSERT_DIMENSIONS, QUICK_INSERT_LEFT_OFFSET } from './consts';
|
|
15
|
+
import { refreshAnchorName } from './utils/anchor-name';
|
|
15
16
|
import { isInTextSelection, isNestedNodeSelected, isNonEditableBlock, isSelectionInNode } from './utils/document-checks';
|
|
16
17
|
import { createNewLine } from './utils/editor-commands';
|
|
17
18
|
const TEXT_PARENT_TYPES = ['paragraph', 'heading', 'blockquote', 'taskItem', 'decisionItem'];
|
|
@@ -80,7 +81,8 @@ const disabledContainerStyles = xcss({
|
|
|
80
81
|
cursor: 'not-allowed'
|
|
81
82
|
});
|
|
82
83
|
const tooltipContainerStyles = xcss({
|
|
83
|
-
top: '
|
|
84
|
+
top: '8px',
|
|
85
|
+
bottom: '-8px',
|
|
84
86
|
position: 'sticky',
|
|
85
87
|
zIndex: 'card'
|
|
86
88
|
});
|
|
@@ -111,7 +113,12 @@ export const TypeAheadControl = ({
|
|
|
111
113
|
// CHANGES - `removed editorExperiment('advanced_layouts', true) && isLayoutColumn` checks as quick insert button will not be positioned for layout column
|
|
112
114
|
const calculatePosition = useCallback(() => {
|
|
113
115
|
const supportsAnchor = CSS.supports('top', `anchor(${rootAnchorName} start)`) && CSS.supports('left', `anchor(${rootAnchorName} start)`);
|
|
114
|
-
const
|
|
116
|
+
const safeAnchorName = fg('platform_editor_controls_patch_2') ? refreshAnchorName({
|
|
117
|
+
getPos,
|
|
118
|
+
view,
|
|
119
|
+
anchorName: rootAnchorName
|
|
120
|
+
}) : rootAnchorName;
|
|
121
|
+
const dom = view.dom.querySelector(`[data-drag-handler-anchor-name="${safeAnchorName}"]`);
|
|
115
122
|
const hasResizer = rootNodeType === 'table' || rootNodeType === 'mediaSingle';
|
|
116
123
|
const isExtension = rootNodeType === 'extension' || rootNodeType === 'bodiedExtension';
|
|
117
124
|
const isBlockCard = rootNodeType === 'blockCard';
|
|
@@ -132,11 +139,11 @@ export const TypeAheadControl = ({
|
|
|
132
139
|
}
|
|
133
140
|
const isEdgeCase = (hasResizer || isExtension || isEmbedCard || isBlockCard) && innerContainer;
|
|
134
141
|
const isSticky = shouldBeSticky(rootNodeType);
|
|
135
|
-
const bottom = fg('platform_editor_controls_sticky_controls') ? getControlBottomCSSValue(
|
|
142
|
+
const bottom = fg('platform_editor_controls_sticky_controls') ? getControlBottomCSSValue(safeAnchorName || anchorName, isSticky, true) : {};
|
|
136
143
|
if (supportsAnchor) {
|
|
137
144
|
return {
|
|
138
|
-
left: isEdgeCase ? `calc(anchor(${
|
|
139
|
-
top: `calc(anchor(${
|
|
145
|
+
left: isEdgeCase ? `calc(anchor(${safeAnchorName} start) + ${getLeftPositionForRootElement(dom, rootNodeType, QUICK_INSERT_DIMENSIONS, innerContainer, isMacroInteractionUpdates)} + -${QUICK_INSERT_LEFT_OFFSET}px)` : `calc(anchor(${safeAnchorName} start) - ${QUICK_INSERT_DIMENSIONS.width}px - ${rootElementGap(rootNodeType)}px + -${QUICK_INSERT_LEFT_OFFSET}px)`,
|
|
146
|
+
top: `calc(anchor(${safeAnchorName} start) + ${topPositionAdjustment(rootNodeType)}px)`,
|
|
140
147
|
...bottom
|
|
141
148
|
};
|
|
142
149
|
}
|
|
@@ -144,14 +151,14 @@ export const TypeAheadControl = ({
|
|
|
144
151
|
// expensive, calls offsetHeight, guard behind FG
|
|
145
152
|
const nodeHeight =
|
|
146
153
|
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
147
|
-
fg('platform_editor_controls_sticky_controls') && getNodeHeight(dom,
|
|
154
|
+
fg('platform_editor_controls_sticky_controls') && getNodeHeight(dom, safeAnchorName || anchorName, anchorRectCache) || 0;
|
|
148
155
|
const height = fg('platform_editor_controls_sticky_controls') ? getControlHeightCSSValue(nodeHeight, isSticky, true, "var(--ds-space-300, 24px)") : {};
|
|
149
156
|
return {
|
|
150
157
|
left: isEdgeCase ? `calc(${(dom === null || dom === void 0 ? void 0 : dom.offsetLeft) || 0}px + ${getLeftPositionForRootElement(dom, rootNodeType, QUICK_INSERT_DIMENSIONS, innerContainer, isMacroInteractionUpdates)} + -${QUICK_INSERT_LEFT_OFFSET}px)` : `calc(${getLeftPositionForRootElement(dom, rootNodeType, QUICK_INSERT_DIMENSIONS, innerContainer, isMacroInteractionUpdates)} + -${QUICK_INSERT_LEFT_OFFSET}px)`,
|
|
151
158
|
top: getTopPosition(dom, rootNodeType),
|
|
152
159
|
...height
|
|
153
160
|
};
|
|
154
|
-
}, [rootAnchorName, view
|
|
161
|
+
}, [rootAnchorName, getPos, view, rootNodeType, macroInteractionUpdates, anchorName, anchorRectCache]);
|
|
155
162
|
useEffect(() => {
|
|
156
163
|
let cleanUpTransitionListener;
|
|
157
164
|
if (rootNodeType === 'extension' || rootNodeType === 'embedCard') {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { findNodeDecs } from '../../pm-plugins/decorations-anchor';
|
|
2
|
+
import { key } from '../../pm-plugins/main';
|
|
3
|
+
/**
|
|
4
|
+
* Checks for plugin state for latest anchorName based on the position, returns
|
|
5
|
+
* provided anchorName if available
|
|
6
|
+
*/
|
|
7
|
+
export const refreshAnchorName = ({
|
|
8
|
+
getPos,
|
|
9
|
+
view,
|
|
10
|
+
anchorName
|
|
11
|
+
}) => {
|
|
12
|
+
let newAnchorName = anchorName || '';
|
|
13
|
+
const pos = getPos();
|
|
14
|
+
if (anchorName || pos === undefined) {
|
|
15
|
+
return newAnchorName;
|
|
16
|
+
}
|
|
17
|
+
const node = view.state.doc.nodeAt(pos);
|
|
18
|
+
const state = key.getState(view.state);
|
|
19
|
+
if (state !== null && state !== void 0 && state.decorations) {
|
|
20
|
+
var _node$nodeSize;
|
|
21
|
+
const nodeDecs = findNodeDecs(state.decorations, pos, pos + ((_node$nodeSize = node === null || node === void 0 ? void 0 : node.nodeSize) !== null && _node$nodeSize !== void 0 ? _node$nodeSize : 0));
|
|
22
|
+
const nodeDec = nodeDecs.at(0);
|
|
23
|
+
if (!nodeDec) {
|
|
24
|
+
return newAnchorName;
|
|
25
|
+
}
|
|
26
|
+
newAnchorName = nodeDec.spec.anchorName;
|
|
27
|
+
}
|
|
28
|
+
return newAnchorName;
|
|
29
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export var handleMouseDown = function handleMouseDown(api) {
|
|
2
|
+
return function (view, event) {
|
|
3
|
+
if (view.editable) {
|
|
4
|
+
return false;
|
|
5
|
+
}
|
|
6
|
+
if (event.target instanceof HTMLElement) {
|
|
7
|
+
var _rootNode$type$name, _rootNode$type$name2;
|
|
8
|
+
var targetPos = view.posAtDOM(event.target, 0);
|
|
9
|
+
// always fetch top level position for mouseDown to avoid drag handle positions being incorrect
|
|
10
|
+
var rootPos = view.state.doc.resolve(targetPos).before(1);
|
|
11
|
+
var rootNode = view.state.doc.nodeAt(rootPos);
|
|
12
|
+
if (!rootNode) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
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 : ''));
|
|
16
|
+
}
|
|
17
|
+
return false;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
@@ -21,6 +21,7 @@ import { findNodeDecs, nodeDecorations } from './decorations-anchor';
|
|
|
21
21
|
import { dragHandleDecoration, emptyParagraphNodeDecorations, findHandleDec } from './decorations-drag-handle';
|
|
22
22
|
import { dropTargetDecorations, findDropTargetDecs } from './decorations-drop-target';
|
|
23
23
|
import { findQuickInsertInsertButtonDecoration, quickInsertButtonDecoration } from './decorations-quick-insert-button';
|
|
24
|
+
import { handleMouseDown } from './handle-mouse-down';
|
|
24
25
|
import { handleMouseOver } from './handle-mouse-over';
|
|
25
26
|
import { boundKeydownHandler } from './keymap';
|
|
26
27
|
import { defaultActiveAnchorTracker } from './utils/active-anchor-tracker';
|
|
@@ -721,6 +722,7 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
721
722
|
handleMouseOver(view, event, api);
|
|
722
723
|
return false;
|
|
723
724
|
},
|
|
725
|
+
mousedown: editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_2') ? handleMouseDown(api) : undefined,
|
|
724
726
|
keydown: function keydown(view, event) {
|
|
725
727
|
if (isMultiSelectEnabled) {
|
|
726
728
|
if (event.shiftKey && event.ctrlKey) {
|
|
@@ -36,6 +36,7 @@ import { isHandleCorrelatedToSelection, selectNode } from '../pm-plugins/utils/g
|
|
|
36
36
|
import { alignAnchorHeadInDirectionOfPos, expandSelectionHeadToNodeAtPos } from '../pm-plugins/utils/selection';
|
|
37
37
|
import { BLOCK_MENU_ENABLED, DRAG_HANDLE_BORDER_RADIUS, DRAG_HANDLE_HEIGHT, DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH, DRAG_HANDLE_WIDTH, DRAG_HANDLE_ZINDEX, dragHandleGap, nodeMargins, spacingBetweenNodesForPreview, topPositionAdjustment } from './consts';
|
|
38
38
|
import { dragPreview } from './drag-preview';
|
|
39
|
+
import { refreshAnchorName } from './utils/anchor-name';
|
|
39
40
|
var iconWrapperStyles = xcss({
|
|
40
41
|
display: 'flex',
|
|
41
42
|
justifyContent: 'center',
|
|
@@ -127,8 +128,9 @@ var dragHandleContainerStyles = xcss({
|
|
|
127
128
|
boxSizing: 'border-box',
|
|
128
129
|
zIndex: 'card'
|
|
129
130
|
});
|
|
130
|
-
var
|
|
131
|
-
top: '
|
|
131
|
+
var tooltipContainerStyles = xcss({
|
|
132
|
+
top: '8px',
|
|
133
|
+
bottom: '-8px',
|
|
132
134
|
position: 'sticky',
|
|
133
135
|
zIndex: 'card'
|
|
134
136
|
});
|
|
@@ -515,7 +517,12 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
515
517
|
parentNodeType = node === null || node === void 0 ? void 0 : node.type.name;
|
|
516
518
|
}
|
|
517
519
|
var supportsAnchor = CSS.supports('top', "anchor(".concat(anchorName, " start)")) && CSS.supports('left', "anchor(".concat(anchorName, " start)"));
|
|
518
|
-
var
|
|
520
|
+
var safeAnchorName = editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_2') ? refreshAnchorName({
|
|
521
|
+
getPos: getPos,
|
|
522
|
+
view: view,
|
|
523
|
+
anchorName: anchorName
|
|
524
|
+
}) : anchorName;
|
|
525
|
+
var dom = view.dom.querySelector("[data-drag-handler-anchor-name=\"".concat(safeAnchorName, "\"]"));
|
|
519
526
|
var hasResizer = nodeType === 'table' || nodeType === 'mediaSingle';
|
|
520
527
|
var isExtension = nodeType === 'extension' || nodeType === 'bodiedExtension' || nodeType === 'multiBodiedExtension' && fg('platform_editor_multi_body_extension_extensibility');
|
|
521
528
|
var isBlockCard = nodeType === 'blockCard' && !!blockCardWidth;
|
|
@@ -537,18 +544,18 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
537
544
|
var isEdgeCase = (hasResizer || isExtension || isEmbedCard || isBlockCard) && innerContainer;
|
|
538
545
|
var isSticky = shouldBeSticky(nodeType);
|
|
539
546
|
if (supportsAnchor) {
|
|
540
|
-
var bottom = fg('platform_editor_controls_sticky_controls') ? getControlBottomCSSValue(
|
|
547
|
+
var bottom = fg('platform_editor_controls_sticky_controls') ? getControlBottomCSSValue(safeAnchorName, isSticky, isTopLevelNode, isLayoutColumn) : {};
|
|
541
548
|
return _objectSpread({
|
|
542
|
-
left: isEdgeCase ? "calc(anchor(".concat(
|
|
543
|
-
top: editorExperiment('advanced_layouts', true) && isLayoutColumn ? "calc(anchor(".concat(
|
|
549
|
+
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)"),
|
|
550
|
+
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)")
|
|
544
551
|
}, bottom);
|
|
545
552
|
}
|
|
546
|
-
var height = fg('platform_editor_controls_sticky_controls') ? getControlHeightCSSValue(getNodeHeight(dom,
|
|
553
|
+
var height = fg('platform_editor_controls_sticky_controls') ? getControlHeightCSSValue(getNodeHeight(dom, safeAnchorName, anchorRectCache) || 0, isSticky, isTopLevelNode, "".concat(DRAG_HANDLE_HEIGHT), isLayoutColumn) : {};
|
|
547
554
|
return _objectSpread({
|
|
548
555
|
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),
|
|
549
556
|
top: getTopPosition(dom, nodeType)
|
|
550
557
|
}, height);
|
|
551
|
-
}, [anchorName,
|
|
558
|
+
}, [anchorName, getPos, view, nodeType, blockCardWidth, macroInteractionUpdates, anchorRectCache, isTopLevelNode, isLayoutColumn]);
|
|
552
559
|
var _useState7 = useState({
|
|
553
560
|
display: 'none'
|
|
554
561
|
}),
|
|
@@ -725,7 +732,7 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
725
732
|
as: "span",
|
|
726
733
|
testId: "block-ctrl-drag-handle-container"
|
|
727
734
|
}, jsx(Box, {
|
|
728
|
-
xcss: [
|
|
735
|
+
xcss: [tooltipContainerStyles],
|
|
729
736
|
as: "span"
|
|
730
737
|
}, jsx(Tooltip, {
|
|
731
738
|
content: jsx(TooltipContentWithMultipleShortcuts, {
|
|
@@ -750,7 +757,7 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
750
757
|
as: "span",
|
|
751
758
|
testId: "block-ctrl-drag-handle-container"
|
|
752
759
|
}, jsx(Box, {
|
|
753
|
-
xcss: [
|
|
760
|
+
xcss: [tooltipContainerStyles],
|
|
754
761
|
as: "span"
|
|
755
762
|
}, renderButton()));
|
|
756
763
|
};
|
|
@@ -16,6 +16,7 @@ import Tooltip from '@atlaskit/tooltip';
|
|
|
16
16
|
import { getControlBottomCSSValue, getControlHeightCSSValue, getNodeHeight, getTopPosition, shouldBeSticky } from '../pm-plugins/utils/drag-handle-positions';
|
|
17
17
|
import { getLeftPositionForRootElement } from '../pm-plugins/utils/widget-positions';
|
|
18
18
|
import { rootElementGap, topPositionAdjustment, QUICK_INSERT_DIMENSIONS, QUICK_INSERT_LEFT_OFFSET } from './consts';
|
|
19
|
+
import { refreshAnchorName } from './utils/anchor-name';
|
|
19
20
|
import { isInTextSelection, isNestedNodeSelected, isNonEditableBlock, isSelectionInNode } from './utils/document-checks';
|
|
20
21
|
import { createNewLine } from './utils/editor-commands';
|
|
21
22
|
var TEXT_PARENT_TYPES = ['paragraph', 'heading', 'blockquote', 'taskItem', 'decisionItem'];
|
|
@@ -84,7 +85,8 @@ var disabledContainerStyles = xcss({
|
|
|
84
85
|
cursor: 'not-allowed'
|
|
85
86
|
});
|
|
86
87
|
var tooltipContainerStyles = xcss({
|
|
87
|
-
top: '
|
|
88
|
+
top: '8px',
|
|
89
|
+
bottom: '-8px',
|
|
88
90
|
position: 'sticky',
|
|
89
91
|
zIndex: 'card'
|
|
90
92
|
});
|
|
@@ -117,7 +119,12 @@ export var TypeAheadControl = function TypeAheadControl(_ref) {
|
|
|
117
119
|
// CHANGES - `removed editorExperiment('advanced_layouts', true) && isLayoutColumn` checks as quick insert button will not be positioned for layout column
|
|
118
120
|
var calculatePosition = useCallback(function () {
|
|
119
121
|
var supportsAnchor = CSS.supports('top', "anchor(".concat(rootAnchorName, " start)")) && CSS.supports('left', "anchor(".concat(rootAnchorName, " start)"));
|
|
120
|
-
var
|
|
122
|
+
var safeAnchorName = fg('platform_editor_controls_patch_2') ? refreshAnchorName({
|
|
123
|
+
getPos: getPos,
|
|
124
|
+
view: view,
|
|
125
|
+
anchorName: rootAnchorName
|
|
126
|
+
}) : rootAnchorName;
|
|
127
|
+
var dom = view.dom.querySelector("[data-drag-handler-anchor-name=\"".concat(safeAnchorName, "\"]"));
|
|
121
128
|
var hasResizer = rootNodeType === 'table' || rootNodeType === 'mediaSingle';
|
|
122
129
|
var isExtension = rootNodeType === 'extension' || rootNodeType === 'bodiedExtension';
|
|
123
130
|
var isBlockCard = rootNodeType === 'blockCard';
|
|
@@ -138,24 +145,24 @@ export var TypeAheadControl = function TypeAheadControl(_ref) {
|
|
|
138
145
|
}
|
|
139
146
|
var isEdgeCase = (hasResizer || isExtension || isEmbedCard || isBlockCard) && innerContainer;
|
|
140
147
|
var isSticky = shouldBeSticky(rootNodeType);
|
|
141
|
-
var bottom = fg('platform_editor_controls_sticky_controls') ? getControlBottomCSSValue(
|
|
148
|
+
var bottom = fg('platform_editor_controls_sticky_controls') ? getControlBottomCSSValue(safeAnchorName || anchorName, isSticky, true) : {};
|
|
142
149
|
if (supportsAnchor) {
|
|
143
150
|
return _objectSpread({
|
|
144
|
-
left: isEdgeCase ? "calc(anchor(".concat(
|
|
145
|
-
top: "calc(anchor(".concat(
|
|
151
|
+
left: isEdgeCase ? "calc(anchor(".concat(safeAnchorName, " start) + ").concat(getLeftPositionForRootElement(dom, rootNodeType, QUICK_INSERT_DIMENSIONS, innerContainer, isMacroInteractionUpdates), " + -").concat(QUICK_INSERT_LEFT_OFFSET, "px)") : "calc(anchor(".concat(safeAnchorName, " start) - ").concat(QUICK_INSERT_DIMENSIONS.width, "px - ").concat(rootElementGap(rootNodeType), "px + -").concat(QUICK_INSERT_LEFT_OFFSET, "px)"),
|
|
152
|
+
top: "calc(anchor(".concat(safeAnchorName, " start) + ").concat(topPositionAdjustment(rootNodeType), "px)")
|
|
146
153
|
}, bottom);
|
|
147
154
|
}
|
|
148
155
|
|
|
149
156
|
// expensive, calls offsetHeight, guard behind FG
|
|
150
157
|
var nodeHeight =
|
|
151
158
|
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
152
|
-
fg('platform_editor_controls_sticky_controls') && getNodeHeight(dom,
|
|
159
|
+
fg('platform_editor_controls_sticky_controls') && getNodeHeight(dom, safeAnchorName || anchorName, anchorRectCache) || 0;
|
|
153
160
|
var height = fg('platform_editor_controls_sticky_controls') ? getControlHeightCSSValue(nodeHeight, isSticky, true, "var(--ds-space-300, 24px)") : {};
|
|
154
161
|
return _objectSpread({
|
|
155
162
|
left: isEdgeCase ? "calc(".concat((dom === null || dom === void 0 ? void 0 : dom.offsetLeft) || 0, "px + ").concat(getLeftPositionForRootElement(dom, rootNodeType, QUICK_INSERT_DIMENSIONS, innerContainer, isMacroInteractionUpdates), " + -").concat(QUICK_INSERT_LEFT_OFFSET, "px)") : "calc(".concat(getLeftPositionForRootElement(dom, rootNodeType, QUICK_INSERT_DIMENSIONS, innerContainer, isMacroInteractionUpdates), " + -").concat(QUICK_INSERT_LEFT_OFFSET, "px)"),
|
|
156
163
|
top: getTopPosition(dom, rootNodeType)
|
|
157
164
|
}, height);
|
|
158
|
-
}, [rootAnchorName, view
|
|
165
|
+
}, [rootAnchorName, getPos, view, rootNodeType, macroInteractionUpdates, anchorName, anchorRectCache]);
|
|
159
166
|
useEffect(function () {
|
|
160
167
|
var cleanUpTransitionListener;
|
|
161
168
|
if (rootNodeType === 'extension' || rootNodeType === 'embedCard') {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { findNodeDecs } from '../../pm-plugins/decorations-anchor';
|
|
2
|
+
import { key } from '../../pm-plugins/main';
|
|
3
|
+
/**
|
|
4
|
+
* Checks for plugin state for latest anchorName based on the position, returns
|
|
5
|
+
* provided anchorName if available
|
|
6
|
+
*/
|
|
7
|
+
export var refreshAnchorName = function refreshAnchorName(_ref) {
|
|
8
|
+
var getPos = _ref.getPos,
|
|
9
|
+
view = _ref.view,
|
|
10
|
+
anchorName = _ref.anchorName;
|
|
11
|
+
var newAnchorName = anchorName || '';
|
|
12
|
+
var pos = getPos();
|
|
13
|
+
if (anchorName || pos === undefined) {
|
|
14
|
+
return newAnchorName;
|
|
15
|
+
}
|
|
16
|
+
var node = view.state.doc.nodeAt(pos);
|
|
17
|
+
var state = key.getState(view.state);
|
|
18
|
+
if (state !== null && state !== void 0 && state.decorations) {
|
|
19
|
+
var _node$nodeSize;
|
|
20
|
+
var nodeDecs = findNodeDecs(state.decorations, pos, pos + ((_node$nodeSize = node === null || node === void 0 ? void 0 : node.nodeSize) !== null && _node$nodeSize !== void 0 ? _node$nodeSize : 0));
|
|
21
|
+
var nodeDec = nodeDecs.at(0);
|
|
22
|
+
if (!nodeDec) {
|
|
23
|
+
return newAnchorName;
|
|
24
|
+
}
|
|
25
|
+
newAnchorName = nodeDec.spec.anchorName;
|
|
26
|
+
}
|
|
27
|
+
return newAnchorName;
|
|
28
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
+
import { BlockControlsPlugin } from '../blockControlsPluginType';
|
|
4
|
+
export declare const handleMouseDown: (api?: ExtractInjectionAPI<BlockControlsPlugin>) => (view: EditorView, event: MouseEvent) => boolean;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
2
|
+
type RefreshAnchorNameParams = {
|
|
3
|
+
getPos: () => number | undefined;
|
|
4
|
+
view: EditorView;
|
|
5
|
+
anchorName?: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Checks for plugin state for latest anchorName based on the position, returns
|
|
9
|
+
* provided anchorName if available
|
|
10
|
+
*/
|
|
11
|
+
export declare const refreshAnchorName: ({ getPos, view, anchorName }: RefreshAnchorNameParams) => string;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
+
import { BlockControlsPlugin } from '../blockControlsPluginType';
|
|
4
|
+
export declare const handleMouseDown: (api?: ExtractInjectionAPI<BlockControlsPlugin>) => (view: EditorView, event: MouseEvent) => boolean;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
2
|
+
type RefreshAnchorNameParams = {
|
|
3
|
+
getPos: () => number | undefined;
|
|
4
|
+
view: EditorView;
|
|
5
|
+
anchorName?: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Checks for plugin state for latest anchorName based on the position, returns
|
|
9
|
+
* provided anchorName if available
|
|
10
|
+
*/
|
|
11
|
+
export declare const refreshAnchorName: ({ getPos, view, anchorName }: RefreshAnchorNameParams) => string;
|
|
12
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "3.8.
|
|
3
|
+
"version": "3.8.1",
|
|
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": "^102.
|
|
36
|
+
"@atlaskit/editor-common": "^102.18.0",
|
|
37
37
|
"@atlaskit/editor-plugin-accessibility-utils": "^2.0.0",
|
|
38
38
|
"@atlaskit/editor-plugin-analytics": "^2.2.0",
|
|
39
39
|
"@atlaskit/editor-plugin-editor-disabled": "^2.0.0",
|
|
@@ -41,20 +41,20 @@
|
|
|
41
41
|
"@atlaskit/editor-plugin-metrics": "^3.4.0",
|
|
42
42
|
"@atlaskit/editor-plugin-quick-insert": "^2.2.0",
|
|
43
43
|
"@atlaskit/editor-plugin-selection": "^2.1.0",
|
|
44
|
-
"@atlaskit/editor-plugin-type-ahead": "^2.
|
|
44
|
+
"@atlaskit/editor-plugin-type-ahead": "^2.3.0",
|
|
45
45
|
"@atlaskit/editor-plugin-width": "^3.0.0",
|
|
46
46
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
47
47
|
"@atlaskit/editor-shared-styles": "^3.4.0",
|
|
48
48
|
"@atlaskit/editor-tables": "^2.9.0",
|
|
49
|
-
"@atlaskit/icon": "^25.
|
|
49
|
+
"@atlaskit/icon": "^25.5.0",
|
|
50
50
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
51
51
|
"@atlaskit/pragmatic-drag-and-drop": "^1.5.0",
|
|
52
52
|
"@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^2.1.0",
|
|
53
53
|
"@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^3.0.0",
|
|
54
|
-
"@atlaskit/primitives": "^14.
|
|
54
|
+
"@atlaskit/primitives": "^14.3.0",
|
|
55
55
|
"@atlaskit/theme": "^18.0.0",
|
|
56
56
|
"@atlaskit/tmp-editor-statsig": "^4.6.0",
|
|
57
|
-
"@atlaskit/tokens": "^4.
|
|
57
|
+
"@atlaskit/tokens": "^4.6.0",
|
|
58
58
|
"@atlaskit/tooltip": "^20.0.0",
|
|
59
59
|
"@babel/runtime": "^7.0.0",
|
|
60
60
|
"@emotion/react": "^11.7.1",
|
|
@@ -170,6 +170,9 @@
|
|
|
170
170
|
},
|
|
171
171
|
"platform_editor_controls_sticky_controls": {
|
|
172
172
|
"type": "boolean"
|
|
173
|
+
},
|
|
174
|
+
"platform_editor_controls_patch_2": {
|
|
175
|
+
"type": "boolean"
|
|
173
176
|
}
|
|
174
177
|
}
|
|
175
178
|
}
|