@atlaskit/editor-plugin-block-controls 3.7.1 → 3.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -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/main.js +2 -2
- package/dist/cjs/pm-plugins/utils/drag-handle-positions.js +25 -1
- package/dist/cjs/ui/drag-handle.js +115 -21
- package/dist/cjs/ui/quick-insert-button.js +72 -23
- 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/main.js +2 -2
- package/dist/es2019/pm-plugins/utils/drag-handle-positions.js +22 -0
- package/dist/es2019/ui/drag-handle.js +100 -10
- package/dist/es2019/ui/quick-insert-button.js +59 -13
- 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/main.js +2 -2
- package/dist/esm/pm-plugins/utils/drag-handle-positions.js +24 -0
- package/dist/esm/ui/drag-handle.js +116 -22
- package/dist/esm/ui/quick-insert-button.js +73 -24
- 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/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-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/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/package.json +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 3.8.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#132443](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/132443)
|
|
8
|
+
[`d4f6243b5f21a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d4f6243b5f21a) -
|
|
9
|
+
[ux] Add sticky controls under experiment
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
3
15
|
## 3.7.1
|
|
4
16
|
|
|
5
17
|
### 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;
|
|
@@ -355,14 +355,14 @@ var newApply = exports.newApply = function newApply(api, formatMessage, tr, curr
|
|
|
355
355
|
var _activeNode9, _activeNode10, _latestActiveNode, _latestActiveNode2, _latestActiveNode3, _latestActiveNode4;
|
|
356
356
|
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
357
|
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);
|
|
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, anchorRectCache);
|
|
359
359
|
decorations = decorations.add(newState.doc, [handleDec]);
|
|
360
360
|
}
|
|
361
361
|
if (shouldRecreateQuickInsertButton && ((_latestActiveNode5 = latestActiveNode) === null || _latestActiveNode5 === void 0 ? void 0 : _latestActiveNode5.rootPos) !== undefined && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
|
|
362
362
|
var _activeNode11, _activeNode12, _latestActiveNode6, _latestActiveNode7, _latestActiveNode8, _latestActiveNode9, _latestActiveNode10;
|
|
363
363
|
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
364
|
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);
|
|
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, anchorRectCache);
|
|
366
366
|
decorations = decorations.add(newState.doc, [quickInsertButton]);
|
|
367
367
|
}
|
|
368
368
|
}
|
|
@@ -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
|
};
|
|
@@ -50,6 +50,43 @@ var dragHandleColor = (0, _react2.css)({
|
|
|
50
50
|
color: "var(--ds-icon-subtle, #626F86)"
|
|
51
51
|
});
|
|
52
52
|
var dragHandleButtonStyles = (0, _react2.css)({
|
|
53
|
+
display: 'flex',
|
|
54
|
+
boxSizing: 'border-box',
|
|
55
|
+
flexDirection: 'column',
|
|
56
|
+
justifyContent: 'center',
|
|
57
|
+
alignItems: 'center',
|
|
58
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
59
|
+
height: _consts.DRAG_HANDLE_HEIGHT,
|
|
60
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
61
|
+
width: _consts.DRAG_HANDLE_WIDTH,
|
|
62
|
+
border: 'none',
|
|
63
|
+
background: 'transparent',
|
|
64
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
65
|
+
borderRadius: _consts.DRAG_HANDLE_BORDER_RADIUS,
|
|
66
|
+
// when platform_editor_controls is enabled, the drag handle color is overridden. Update color here when experiment is cleaned up.
|
|
67
|
+
color: "var(--ds-icon, #44546F)",
|
|
68
|
+
cursor: 'grab',
|
|
69
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
70
|
+
zIndex: _consts.DRAG_HANDLE_ZINDEX,
|
|
71
|
+
outline: 'none',
|
|
72
|
+
'&:hover': {
|
|
73
|
+
backgroundColor: "var(--ds-background-neutral-subtle-hovered, #091E420F)"
|
|
74
|
+
},
|
|
75
|
+
'&:active': {
|
|
76
|
+
backgroundColor: "var(--ds-background-neutral-subtle-pressed, #091E4224)"
|
|
77
|
+
},
|
|
78
|
+
'&:focus': {
|
|
79
|
+
outline: "2px solid ".concat("var(--ds-border-focused, #388BFF)")
|
|
80
|
+
},
|
|
81
|
+
'&:disabled': {
|
|
82
|
+
color: "var(--ds-icon-disabled, #8993A4)",
|
|
83
|
+
backgroundColor: 'transparent'
|
|
84
|
+
},
|
|
85
|
+
'&:hover:disabled': {
|
|
86
|
+
backgroundColor: "var(--ds-background-disabled, transparent)"
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
var dragHandleButtonStylesOld = (0, _react2.css)({
|
|
53
90
|
position: 'absolute',
|
|
54
91
|
padding: "var(--ds-space-025, 2px)".concat(" 0"),
|
|
55
92
|
boxSizing: 'border-box',
|
|
@@ -88,6 +125,16 @@ var dragHandleButtonStyles = (0, _react2.css)({
|
|
|
88
125
|
backgroundColor: "var(--ds-background-disabled, transparent)"
|
|
89
126
|
}
|
|
90
127
|
});
|
|
128
|
+
var dragHandleContainerStyles = (0, _primitives.xcss)({
|
|
129
|
+
position: 'absolute',
|
|
130
|
+
boxSizing: 'border-box',
|
|
131
|
+
zIndex: 'card'
|
|
132
|
+
});
|
|
133
|
+
var controlContainerStyles = (0, _primitives.xcss)({
|
|
134
|
+
top: '0',
|
|
135
|
+
position: 'sticky',
|
|
136
|
+
zIndex: 'card'
|
|
137
|
+
});
|
|
91
138
|
var dragHandleMultiLineSelectionFixFirefox = (0, _react2.css)({
|
|
92
139
|
'&::selection': {
|
|
93
140
|
backgroundColor: 'transparent'
|
|
@@ -151,7 +198,8 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
151
198
|
nodeType = _ref.nodeType,
|
|
152
199
|
handleOptions = _ref.handleOptions,
|
|
153
200
|
_ref$isTopLevelNode = _ref.isTopLevelNode,
|
|
154
|
-
isTopLevelNode = _ref$isTopLevelNode === void 0 ? true : _ref$isTopLevelNode
|
|
201
|
+
isTopLevelNode = _ref$isTopLevelNode === void 0 ? true : _ref$isTopLevelNode,
|
|
202
|
+
anchorRectCache = _ref.anchorRectCache;
|
|
155
203
|
var start = getPos();
|
|
156
204
|
var buttonRef = (0, _react.useRef)(null);
|
|
157
205
|
var _useState = (0, _react.useState)(768),
|
|
@@ -490,17 +538,20 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
490
538
|
}
|
|
491
539
|
}
|
|
492
540
|
var isEdgeCase = (hasResizer || isExtension || isEmbedCard || isBlockCard) && innerContainer;
|
|
541
|
+
var isSticky = (0, _dragHandlePositions.shouldBeSticky)(nodeType);
|
|
493
542
|
if (supportsAnchor) {
|
|
494
|
-
|
|
543
|
+
var bottom = (0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') ? (0, _dragHandlePositions.getControlBottomCSSValue)(anchorName, isSticky, isTopLevelNode, isLayoutColumn) : {};
|
|
544
|
+
return _objectSpread({
|
|
495
545
|
left: isEdgeCase ? "calc(anchor(".concat(anchorName, " start) + ").concat((0, _dragHandlePositions.getLeftPosition)(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType), ")") : (0, _experiments.editorExperiment)('advanced_layouts', true) && isLayoutColumn ? "calc((anchor(".concat(anchorName, " right) + anchor(").concat(anchorName, " left))/2 - ").concat(_consts.DRAG_HANDLE_HEIGHT / 2, "px)") : "calc(anchor(".concat(anchorName, " start) - ").concat(_consts.DRAG_HANDLE_WIDTH, "px - ").concat((0, _consts.dragHandleGap)(nodeType, parentNodeType), "px)"),
|
|
496
546
|
top: (0, _experiments.editorExperiment)('advanced_layouts', true) && isLayoutColumn ? "calc(anchor(".concat(anchorName, " top) - ").concat(_consts.DRAG_HANDLE_WIDTH, "px)") : "calc(anchor(".concat(anchorName, " start) + ").concat((0, _consts.topPositionAdjustment)(nodeType), "px)")
|
|
497
|
-
};
|
|
547
|
+
}, bottom);
|
|
498
548
|
}
|
|
499
|
-
|
|
549
|
+
var height = (0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') ? (0, _dragHandlePositions.getControlHeightCSSValue)((0, _dragHandlePositions.getNodeHeight)(dom, anchorName, anchorRectCache) || 0, isSticky, isTopLevelNode, "".concat(_consts.DRAG_HANDLE_HEIGHT), isLayoutColumn) : {};
|
|
550
|
+
return _objectSpread({
|
|
500
551
|
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
552
|
top: (0, _dragHandlePositions.getTopPosition)(dom, nodeType)
|
|
502
|
-
};
|
|
503
|
-
}, [anchorName,
|
|
553
|
+
}, height);
|
|
554
|
+
}, [anchorName, view.dom, view.state.doc, nodeType, blockCardWidth, macroInteractionUpdates, isTopLevelNode, isLayoutColumn, getPos, anchorRectCache]);
|
|
504
555
|
var _useState7 = (0, _react.useState)({
|
|
505
556
|
display: 'none'
|
|
506
557
|
}),
|
|
@@ -637,14 +688,14 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
637
688
|
// eslint-disable-next-line @atlaskit/design-system/no-html-button
|
|
638
689
|
(0, _react2.jsx)("button", {
|
|
639
690
|
type: "button",
|
|
640
|
-
css: [dragHandleButtonStyles, (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && dragHandleColor,
|
|
691
|
+
css: [(0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') ? dragHandleButtonStyles : dragHandleButtonStylesOld, (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && dragHandleColor,
|
|
641
692
|
// ED-26266: Fixed the drag handle highlight when selecting multiple line in Firefox
|
|
642
693
|
// See https://product-fabric.atlassian.net/browse/ED-26266
|
|
643
694
|
_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
695
|
ref: buttonRef
|
|
645
696
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
646
697
|
,
|
|
647
|
-
style: positionStyles,
|
|
698
|
+
style: !(0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') && positionStyles || {},
|
|
648
699
|
onClick: handleOnClick,
|
|
649
700
|
onMouseDown: handleMouseDown,
|
|
650
701
|
onKeyDown: handleKeyDown
|
|
@@ -668,17 +719,60 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
668
719
|
})))
|
|
669
720
|
);
|
|
670
721
|
};
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
}
|
|
683
|
-
|
|
722
|
+
var stickyWithTooltip = function stickyWithTooltip() {
|
|
723
|
+
return (0, _react2.jsx)(_primitives.Box
|
|
724
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
725
|
+
, {
|
|
726
|
+
style: positionStyles,
|
|
727
|
+
xcss: [dragHandleContainerStyles],
|
|
728
|
+
as: "span",
|
|
729
|
+
testId: "block-ctrl-drag-handle-container"
|
|
730
|
+
}, (0, _react2.jsx)(_primitives.Box, {
|
|
731
|
+
xcss: [controlContainerStyles],
|
|
732
|
+
as: "span"
|
|
733
|
+
}, (0, _react2.jsx)(_tooltip.default, {
|
|
734
|
+
content: (0, _react2.jsx)(_keymaps.TooltipContentWithMultipleShortcuts, {
|
|
735
|
+
helpDescriptors: helpDescriptors
|
|
736
|
+
}),
|
|
737
|
+
ignoreTooltipPointerEvents: true,
|
|
738
|
+
position: 'top',
|
|
739
|
+
onShow: function onShow() {
|
|
740
|
+
var _api$accessibilityUti;
|
|
741
|
+
api === null || api === void 0 || (_api$accessibilityUti = api.accessibilityUtils) === null || _api$accessibilityUti === void 0 || _api$accessibilityUti.actions.ariaNotify(message, {
|
|
742
|
+
priority: 'important'
|
|
743
|
+
});
|
|
744
|
+
}
|
|
745
|
+
}, renderButton())));
|
|
746
|
+
};
|
|
747
|
+
var stickyWithoutTooltip = function stickyWithoutTooltip() {
|
|
748
|
+
return (0, _react2.jsx)(_primitives.Box
|
|
749
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
750
|
+
, {
|
|
751
|
+
style: positionStyles,
|
|
752
|
+
xcss: [dragHandleContainerStyles],
|
|
753
|
+
as: "span",
|
|
754
|
+
testId: "block-ctrl-drag-handle-container"
|
|
755
|
+
}, (0, _react2.jsx)(_primitives.Box, {
|
|
756
|
+
xcss: [controlContainerStyles],
|
|
757
|
+
as: "span"
|
|
758
|
+
}, renderButton()));
|
|
759
|
+
};
|
|
760
|
+
var buttonWithTooltip = function buttonWithTooltip() {
|
|
761
|
+
return (0, _react2.jsx)(_tooltip.default, {
|
|
762
|
+
content: (0, _react2.jsx)(_keymaps.TooltipContentWithMultipleShortcuts, {
|
|
763
|
+
helpDescriptors: helpDescriptors
|
|
764
|
+
}),
|
|
765
|
+
ignoreTooltipPointerEvents: true,
|
|
766
|
+
onShow: function onShow() {
|
|
767
|
+
var _api$accessibilityUti2;
|
|
768
|
+
api === null || api === void 0 || (_api$accessibilityUti2 = api.accessibilityUtils) === null || _api$accessibilityUti2 === void 0 || _api$accessibilityUti2.actions.ariaNotify(message, {
|
|
769
|
+
priority: 'important'
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
}, renderButton());
|
|
773
|
+
};
|
|
774
|
+
var isTooltip = !dragHandleDisabled && (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_23873');
|
|
775
|
+
var stickyRender = isTooltip ? stickyWithTooltip() : stickyWithoutTooltip();
|
|
776
|
+
var render = isTooltip ? buttonWithTooltip() : renderButton();
|
|
777
|
+
return (0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') ? stickyRender : render;
|
|
684
778
|
};
|
|
@@ -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");
|
|
@@ -25,6 +26,8 @@ var _documentChecks = require("./utils/document-checks");
|
|
|
25
26
|
var _editorCommands = require("./utils/editor-commands");
|
|
26
27
|
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
28
|
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; }
|
|
29
|
+
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; }
|
|
30
|
+
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
31
|
var TEXT_PARENT_TYPES = ['paragraph', 'heading', 'blockquote', 'taskItem', 'decisionItem'];
|
|
29
32
|
var buttonStyles = (0, _primitives.xcss)({
|
|
30
33
|
boxSizing: 'border-box',
|
|
@@ -58,6 +61,31 @@ var disabledStyles = (0, _primitives.xcss)({
|
|
|
58
61
|
backgroundColor: 'color.background.disabled'
|
|
59
62
|
}
|
|
60
63
|
});
|
|
64
|
+
var stickyButtonStyles = (0, _primitives.xcss)({
|
|
65
|
+
top: '0',
|
|
66
|
+
position: 'sticky',
|
|
67
|
+
boxSizing: 'border-box',
|
|
68
|
+
display: 'flex',
|
|
69
|
+
flexDirection: 'column',
|
|
70
|
+
justifyContent: 'center',
|
|
71
|
+
alignItems: 'center',
|
|
72
|
+
height: "var(--ds-space-300, 24px)",
|
|
73
|
+
width: "var(--ds-space-300, 24px)",
|
|
74
|
+
border: 'none',
|
|
75
|
+
backgroundColor: 'color.background.neutral.subtle',
|
|
76
|
+
borderRadius: '50%',
|
|
77
|
+
zIndex: 'card',
|
|
78
|
+
outline: 'none',
|
|
79
|
+
':hover': {
|
|
80
|
+
backgroundColor: 'color.background.neutral.subtle.hovered'
|
|
81
|
+
},
|
|
82
|
+
':active': {
|
|
83
|
+
backgroundColor: 'color.background.neutral.subtle.pressed'
|
|
84
|
+
},
|
|
85
|
+
':focus': {
|
|
86
|
+
outline: "2px solid ".concat("var(--ds-border-focused, #388BFF)")
|
|
87
|
+
}
|
|
88
|
+
});
|
|
61
89
|
var containerStaticStyles = (0, _primitives.xcss)({
|
|
62
90
|
position: 'absolute',
|
|
63
91
|
zIndex: 'card'
|
|
@@ -65,6 +93,11 @@ var containerStaticStyles = (0, _primitives.xcss)({
|
|
|
65
93
|
var disabledContainerStyles = (0, _primitives.xcss)({
|
|
66
94
|
cursor: 'not-allowed'
|
|
67
95
|
});
|
|
96
|
+
var tooltipContainerStyles = (0, _primitives.xcss)({
|
|
97
|
+
top: '0',
|
|
98
|
+
position: 'sticky',
|
|
99
|
+
zIndex: 'card'
|
|
100
|
+
});
|
|
68
101
|
|
|
69
102
|
// TODO: ED-26959 - Share prop types between DragHandle - generic enough to create a type for block control decoration
|
|
70
103
|
|
|
@@ -73,8 +106,11 @@ var TypeAheadControl = exports.TypeAheadControl = function TypeAheadControl(_ref
|
|
|
73
106
|
api = _ref.api,
|
|
74
107
|
formatMessage = _ref.formatMessage,
|
|
75
108
|
getPos = _ref.getPos,
|
|
109
|
+
nodeType = _ref.nodeType,
|
|
110
|
+
anchorName = _ref.anchorName,
|
|
76
111
|
rootAnchorName = _ref.rootAnchorName,
|
|
77
|
-
rootNodeType = _ref.rootNodeType
|
|
112
|
+
rootNodeType = _ref.rootNodeType,
|
|
113
|
+
anchorRectCache = _ref.anchorRectCache;
|
|
78
114
|
var macroInteractionUpdates = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'featureFlags.macroInteractionUpdates');
|
|
79
115
|
var isTypeAheadOpen = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'typeAhead.isOpen');
|
|
80
116
|
var _useState = (0, _react.useState)({
|
|
@@ -111,17 +147,25 @@ var TypeAheadControl = exports.TypeAheadControl = function TypeAheadControl(_ref
|
|
|
111
147
|
}
|
|
112
148
|
}
|
|
113
149
|
var isEdgeCase = (hasResizer || isExtension || isEmbedCard || isBlockCard) && innerContainer;
|
|
150
|
+
var isSticky = (0, _dragHandlePositions.shouldBeSticky)(rootNodeType);
|
|
151
|
+
var bottom = (0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') ? (0, _dragHandlePositions.getControlBottomCSSValue)(rootAnchorName || anchorName, isSticky, true) : {};
|
|
114
152
|
if (supportsAnchor) {
|
|
115
|
-
return {
|
|
153
|
+
return _objectSpread({
|
|
116
154
|
left: isEdgeCase ? "calc(anchor(".concat(rootAnchorName, " start) + ").concat((0, _widgetPositions.getLeftPositionForRootElement)(dom, rootNodeType, _consts.QUICK_INSERT_DIMENSIONS, innerContainer, isMacroInteractionUpdates), " + -").concat(_consts.QUICK_INSERT_LEFT_OFFSET, "px)") : "calc(anchor(".concat(rootAnchorName, " start) - ").concat(_consts.QUICK_INSERT_DIMENSIONS.width, "px - ").concat((0, _consts.rootElementGap)(rootNodeType), "px + -").concat(_consts.QUICK_INSERT_LEFT_OFFSET, "px)"),
|
|
117
155
|
top: "calc(anchor(".concat(rootAnchorName, " start) + ").concat((0, _consts.topPositionAdjustment)(rootNodeType), "px)")
|
|
118
|
-
};
|
|
156
|
+
}, bottom);
|
|
119
157
|
}
|
|
120
|
-
|
|
158
|
+
|
|
159
|
+
// expensive, calls offsetHeight, guard behind FG
|
|
160
|
+
var nodeHeight =
|
|
161
|
+
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
162
|
+
(0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') && (0, _dragHandlePositions.getNodeHeight)(dom, rootAnchorName || anchorName, anchorRectCache) || 0;
|
|
163
|
+
var height = (0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') ? (0, _dragHandlePositions.getControlHeightCSSValue)(nodeHeight, isSticky, true, "var(--ds-space-300, 24px)") : {};
|
|
164
|
+
return _objectSpread({
|
|
121
165
|
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
166
|
top: (0, _dragHandlePositions.getTopPosition)(dom, rootNodeType)
|
|
123
|
-
};
|
|
124
|
-
}, [rootAnchorName, view.dom, rootNodeType, macroInteractionUpdates]);
|
|
167
|
+
}, height);
|
|
168
|
+
}, [rootAnchorName, view.dom, rootNodeType, macroInteractionUpdates, anchorName, anchorRectCache]);
|
|
125
169
|
(0, _react.useEffect)(function () {
|
|
126
170
|
var cleanUpTransitionListener;
|
|
127
171
|
if (rootNodeType === 'extension' || rootNodeType === 'embedCard') {
|
|
@@ -206,26 +250,31 @@ var TypeAheadControl = exports.TypeAheadControl = function TypeAheadControl(_ref
|
|
|
206
250
|
});
|
|
207
251
|
}
|
|
208
252
|
}, [api, view.state]);
|
|
253
|
+
var tooltipPressable = function tooltipPressable() {
|
|
254
|
+
return /*#__PURE__*/_react.default.createElement(_tooltip.default, {
|
|
255
|
+
position: "top",
|
|
256
|
+
content: /*#__PURE__*/_react.default.createElement(_keymaps.ToolTipContent, {
|
|
257
|
+
description: formatMessage(_messages.blockControlsMessages.insert)
|
|
258
|
+
})
|
|
259
|
+
}, /*#__PURE__*/_react.default.createElement(_primitives.Pressable, {
|
|
260
|
+
testId: "editor-quick-insert-button",
|
|
261
|
+
type: "button",
|
|
262
|
+
"aria-label": formatMessage(_messages.blockControlsMessages.insert),
|
|
263
|
+
xcss: [(0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') ? buttonStyles : stickyButtonStyles, isTypeAheadOpen && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_1') && disabledStyles],
|
|
264
|
+
onClick: handleQuickInsert,
|
|
265
|
+
onMouseDown: (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_1') ? undefined : handleMouseDown,
|
|
266
|
+
isDisabled: (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_1') ? isTypeAheadOpen : undefined
|
|
267
|
+
}, /*#__PURE__*/_react.default.createElement(_add.default, {
|
|
268
|
+
label: "add",
|
|
269
|
+
color: isTypeAheadOpen ? "var(--ds-icon-disabled, #091E424F)" : "var(--ds-icon-subtle, #626F86)"
|
|
270
|
+
})));
|
|
271
|
+
};
|
|
209
272
|
return /*#__PURE__*/_react.default.createElement(_primitives.Box
|
|
210
273
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
211
274
|
, {
|
|
212
275
|
style: positionStyles,
|
|
213
276
|
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
|
-
}))));
|
|
277
|
+
}, (0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') ? /*#__PURE__*/_react.default.createElement(_primitives.Box, {
|
|
278
|
+
xcss: [tooltipContainerStyles]
|
|
279
|
+
}, tooltipPressable()) : tooltipPressable());
|
|
231
280
|
};
|
|
@@ -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
|
}, {
|
|
@@ -352,14 +352,14 @@ export const newApply = (api, formatMessage, tr, currentState, newState, flags,
|
|
|
352
352
|
var _activeNode9, _activeNode10, _latestActiveNode, _latestActiveNode2, _latestActiveNode3, _latestActiveNode4;
|
|
353
353
|
const oldHandle = findHandleDec(decorations, (_activeNode9 = activeNode) === null || _activeNode9 === void 0 ? void 0 : _activeNode9.pos, (_activeNode10 = activeNode) === null || _activeNode10 === void 0 ? void 0 : _activeNode10.pos);
|
|
354
354
|
decorations = decorations.remove(oldHandle);
|
|
355
|
-
const handleDec = 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);
|
|
355
|
+
const handleDec = 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);
|
|
356
356
|
decorations = decorations.add(newState.doc, [handleDec]);
|
|
357
357
|
}
|
|
358
358
|
if (shouldRecreateQuickInsertButton && ((_latestActiveNode5 = latestActiveNode) === null || _latestActiveNode5 === void 0 ? void 0 : _latestActiveNode5.rootPos) !== undefined && editorExperiment('platform_editor_controls', 'variant1')) {
|
|
359
359
|
var _activeNode11, _activeNode12, _latestActiveNode6, _latestActiveNode7, _latestActiveNode8, _latestActiveNode9, _latestActiveNode10;
|
|
360
360
|
const oldQuickInsertButton = findQuickInsertInsertButtonDecoration(decorations, (_activeNode11 = activeNode) === null || _activeNode11 === void 0 ? void 0 : _activeNode11.rootPos, (_activeNode12 = activeNode) === null || _activeNode12 === void 0 ? void 0 : _activeNode12.rootPos);
|
|
361
361
|
decorations = decorations.remove(oldQuickInsertButton);
|
|
362
|
-
const quickInsertButton = 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);
|
|
362
|
+
const quickInsertButton = 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);
|
|
363
363
|
decorations = decorations.add(newState.doc, [quickInsertButton]);
|
|
364
364
|
}
|
|
365
365
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
1
2
|
import { DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT, DRAG_HANDLE_H1_TOP_ADJUSTMENT, DRAG_HANDLE_H2_TOP_ADJUSTMENT, DRAG_HANDLE_H4_TOP_ADJUSTMENT, DRAG_HANDLE_H5_TOP_ADJUSTMENT, DRAG_HANDLE_H6_TOP_ADJUSTMENT, DRAG_HANDLE_HEIGHT, DRAG_HANDLE_PARAGRAPH_TOP_ADJUSTMENT, DRAG_HANDLE_WIDTH, dragHandleGap } from '../../ui/consts';
|
|
3
|
+
const STICKY_NODES = ['panel', 'table', 'expand', 'layoutSection', 'bodiedExtension'];
|
|
2
4
|
export const getTopPosition = (dom, type) => {
|
|
3
5
|
if (!dom) {
|
|
4
6
|
return 'auto';
|
|
@@ -42,4 +44,24 @@ export const getLeftPosition = (dom, type, innerContainer, macroInteractionUpdat
|
|
|
42
44
|
const relativeSpan = macroInteractionUpdates ? dom.querySelector('span.relative') : null;
|
|
43
45
|
const leftAdjustment = relativeSpan ? relativeSpan.offsetLeft : 0;
|
|
44
46
|
return getComputedStyle(innerContainer).transform === 'none' ? `${innerContainer.offsetLeft + leftAdjustment - dragHandleGap(type, parentType) - DRAG_HANDLE_WIDTH}px` : `${innerContainer.offsetLeft + leftAdjustment - innerContainer.offsetWidth / 2 - dragHandleGap(type, parentType) - DRAG_HANDLE_WIDTH}px`;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// anchorRectCache seems to have a 100% cache miss rate
|
|
50
|
+
export const getNodeHeight = (dom, anchor, anchorRectCache) => (anchorRectCache === null || anchorRectCache === void 0 ? void 0 : anchorRectCache.getHeight(anchor)) || (dom === null || dom === void 0 ? void 0 : dom.offsetHeight);
|
|
51
|
+
export const shouldBeSticky = nodeType => {
|
|
52
|
+
return editorExperiment('platform_editor_controls', 'variant1') && STICKY_NODES.includes(nodeType);
|
|
53
|
+
};
|
|
54
|
+
export const getControlBottomCSSValue = (anchor, isSticky, isTopLevelNode, isLayoutColumn) => {
|
|
55
|
+
return editorExperiment('advanced_layouts', true) && isLayoutColumn || !isSticky || !isTopLevelNode ? {
|
|
56
|
+
bottom: 'unset'
|
|
57
|
+
} : {
|
|
58
|
+
bottom: `anchor(${anchor} end)`
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
export const getControlHeightCSSValue = (nodeHeight, isSticky, isTopLevelNode, fallbackPxHeight, isLayoutColumn) => {
|
|
62
|
+
return editorExperiment('advanced_layouts', true) && isLayoutColumn || !isSticky || !isTopLevelNode ? {
|
|
63
|
+
height: 'unset'
|
|
64
|
+
} : {
|
|
65
|
+
height: `${nodeHeight || fallbackPxHeight}px`
|
|
66
|
+
};
|
|
45
67
|
};
|