@atlaskit/editor-plugin-block-controls 1.4.27 → 1.4.28
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/main.js +13 -5
- package/dist/cjs/ui/consts.js +4 -1
- package/dist/cjs/ui/drag-handle.js +46 -10
- package/dist/cjs/ui/mouse-move-wrapper.js +3 -1
- package/dist/cjs/utils/getSelection.js +3 -1
- package/dist/es2019/pm-plugins/main.js +13 -5
- package/dist/es2019/ui/consts.js +3 -0
- package/dist/es2019/ui/drag-handle.js +39 -8
- package/dist/es2019/ui/mouse-move-wrapper.js +3 -1
- package/dist/es2019/utils/getSelection.js +3 -1
- package/dist/esm/pm-plugins/main.js +13 -5
- package/dist/esm/ui/consts.js +3 -0
- package/dist/esm/ui/drag-handle.js +47 -11
- package/dist/esm/ui/mouse-move-wrapper.js +3 -1
- package/dist/esm/utils/getSelection.js +3 -1
- package/dist/types/ui/consts.d.ts +1 -0
- package/dist/types/ui/drag-handle.d.ts +1 -1
- package/dist/types/ui/mouse-move-wrapper.d.ts +1 -1
- package/dist/types-ts4.5/ui/consts.d.ts +1 -0
- package/dist/types-ts4.5/ui/drag-handle.d.ts +1 -1
- package/dist/types-ts4.5/ui/mouse-move-wrapper.d.ts +1 -1
- package/package.json +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 1.4.28
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#113750](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/113750)
|
|
8
|
+
[`f0bb95b1231d8`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/f0bb95b1231d8) -
|
|
9
|
+
[ux] Fix drag handle pos for block and embed card nodes
|
|
10
|
+
- [#114031](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/114031)
|
|
11
|
+
[`a9de475bcf1f7`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a9de475bcf1f7) -
|
|
12
|
+
Highlight whole node when selecting decistion list via drag handle
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
3
15
|
## 1.4.27
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -248,15 +248,23 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
248
248
|
var dom = editorView.dom;
|
|
249
249
|
|
|
250
250
|
// Use ResizeObserver to observe height changes
|
|
251
|
-
var resizeObserver = new ResizeObserver((0, _rafSchd.default)(function () {
|
|
252
|
-
var editorHeight =
|
|
251
|
+
var resizeObserver = new ResizeObserver((0, _rafSchd.default)(function (entries) {
|
|
252
|
+
var editorHeight = entries[0].contentBoxSize[0].blockSize;
|
|
253
253
|
|
|
254
254
|
// Update the plugin state when the height changes
|
|
255
255
|
var pluginState = key.getState(editorView.state);
|
|
256
256
|
if (!(pluginState !== null && pluginState !== void 0 && pluginState.isDragging)) {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
257
|
+
var isResizerResizing = !!dom.querySelector('.is-resizing');
|
|
258
|
+
var transaction = editorView.state.tr;
|
|
259
|
+
if ((pluginState === null || pluginState === void 0 ? void 0 : pluginState.isResizerResizing) !== isResizerResizing) {
|
|
260
|
+
transaction.setMeta('is-resizer-resizing', isResizerResizing);
|
|
261
|
+
}
|
|
262
|
+
if (!isResizerResizing) {
|
|
263
|
+
transaction.setMeta(key, {
|
|
264
|
+
editorHeight: editorHeight
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
editorView.dispatch(transaction);
|
|
260
268
|
}
|
|
261
269
|
}));
|
|
262
270
|
|
package/dist/cjs/ui/consts.js
CHANGED
|
@@ -3,10 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.dragHandleGap = exports.DRAG_HANDLE_WIDTH = exports.DRAG_HANDLE_HEIGHT = exports.DRAG_HANDLE_BORDER_RADIUS = void 0;
|
|
6
|
+
exports.dragHandleGap = exports.DRAG_HANDLE_ZINDEX = exports.DRAG_HANDLE_WIDTH = exports.DRAG_HANDLE_HEIGHT = exports.DRAG_HANDLE_BORDER_RADIUS = void 0;
|
|
7
|
+
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
7
8
|
var DRAG_HANDLE_HEIGHT = exports.DRAG_HANDLE_HEIGHT = 24;
|
|
8
9
|
var DRAG_HANDLE_WIDTH = exports.DRAG_HANDLE_WIDTH = 12;
|
|
9
10
|
var DRAG_HANDLE_BORDER_RADIUS = exports.DRAG_HANDLE_BORDER_RADIUS = 4;
|
|
11
|
+
var DRAG_HANDLE_ZINDEX = exports.DRAG_HANDLE_ZINDEX = _editorSharedStyles.akRichMediaResizeZIndex + _editorSharedStyles.akEditorUnitZIndex; //place above legacy resizer
|
|
12
|
+
|
|
10
13
|
var nodeTypeExcludeList = ['embedCard', 'mediaSingle', 'table'];
|
|
11
14
|
var dragHandleGap = exports.dragHandleGap = function dragHandleGap(nodeType) {
|
|
12
15
|
if (nodeTypeExcludeList.includes(nodeType)) {
|
|
@@ -40,7 +40,8 @@ var dragHandleButtonStyles = (0, _react2.css)({
|
|
|
40
40
|
borderRadius: _consts.DRAG_HANDLE_BORDER_RADIUS,
|
|
41
41
|
color: "var(--ds-icon, #44546F)",
|
|
42
42
|
cursor: 'grab',
|
|
43
|
-
|
|
43
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
44
|
+
zIndex: _consts.DRAG_HANDLE_ZINDEX,
|
|
44
45
|
'&:hover': {
|
|
45
46
|
backgroundColor: "var(--ds-background-neutral-subtle-hovered, #091E420F)"
|
|
46
47
|
},
|
|
@@ -60,12 +61,33 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
60
61
|
nodeType = _ref.nodeType;
|
|
61
62
|
var start = getPos();
|
|
62
63
|
var buttonRef = (0, _react.useRef)(null);
|
|
63
|
-
var _useState = (0, _react.useState)(
|
|
64
|
+
var _useState = (0, _react.useState)(768),
|
|
64
65
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
blockCardWidth = _useState2[0],
|
|
67
|
+
setBlockCardWidth = _useState2[1];
|
|
68
|
+
var _useState3 = (0, _react.useState)(false),
|
|
69
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
70
|
+
dragHandleSelected = _useState4[0],
|
|
71
|
+
setDragHandleSelected = _useState4[1];
|
|
67
72
|
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['featureFlags']),
|
|
68
73
|
featureFlagsState = _useSharedPluginState.featureFlagsState;
|
|
74
|
+
(0, _react.useEffect)(function () {
|
|
75
|
+
// blockCard/datasource width is rendered correctly after this decoraton does. We need to observe for changes.
|
|
76
|
+
if (nodeType === 'blockCard') {
|
|
77
|
+
var dom = view.dom.querySelector("[data-drag-handler-anchor-name=\"".concat(anchorName, "\"]"));
|
|
78
|
+
var container = dom === null || dom === void 0 ? void 0 : dom.querySelector('.datasourceView-content-inner-wrap');
|
|
79
|
+
if (container) {
|
|
80
|
+
var resizeObserver = new ResizeObserver(function (entries) {
|
|
81
|
+
var width = entries[0].contentBoxSize[0].inlineSize;
|
|
82
|
+
setBlockCardWidth(width);
|
|
83
|
+
});
|
|
84
|
+
resizeObserver.observe(container);
|
|
85
|
+
return function () {
|
|
86
|
+
return resizeObserver.unobserve(container);
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}, [anchorName, nodeType, view.dom]);
|
|
69
91
|
var handleOnClick = (0, _react.useCallback)(function () {
|
|
70
92
|
var _api$core, _api$core2;
|
|
71
93
|
setDragHandleSelected(!dragHandleSelected);
|
|
@@ -156,17 +178,31 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
156
178
|
api === null || api === void 0 || (_api$core6 = api.core) === null || _api$core6 === void 0 || _api$core6.actions.focus();
|
|
157
179
|
}
|
|
158
180
|
});
|
|
159
|
-
}, [api,
|
|
181
|
+
}, [anchorName, api, nodeType, view, start]);
|
|
160
182
|
var macroInteractionUpdates = featureFlagsState === null || featureFlagsState === void 0 ? void 0 : featureFlagsState.macroInteractionUpdates;
|
|
161
183
|
var positionStyles = (0, _react.useMemo)(function () {
|
|
162
184
|
var supportsAnchor = CSS.supports('top', "anchor(".concat(anchorName, " start)")) && CSS.supports('left', "anchor(".concat(anchorName, " start)"));
|
|
163
185
|
var dom = view.dom.querySelector("[data-drag-handler-anchor-name=\"".concat(anchorName, "\"]"));
|
|
164
|
-
var hasResizer =
|
|
165
|
-
var isExtension =
|
|
166
|
-
var
|
|
186
|
+
var hasResizer = nodeType === 'table' || nodeType === 'mediaSingle';
|
|
187
|
+
var isExtension = nodeType === 'extension' || nodeType === 'bodiedExtension';
|
|
188
|
+
var isBlockCard = nodeType === 'blockCard' && !!blockCardWidth;
|
|
189
|
+
var isEmbedCard = nodeType === 'embedCard';
|
|
190
|
+
var innerContainer = null;
|
|
191
|
+
if (dom) {
|
|
192
|
+
if (isEmbedCard) {
|
|
193
|
+
innerContainer = dom.querySelector('.rich-media-item');
|
|
194
|
+
} else if (hasResizer) {
|
|
195
|
+
innerContainer = dom.querySelector('.resizer-item');
|
|
196
|
+
} else if (isExtension) {
|
|
197
|
+
innerContainer = dom.querySelector('.extension-container[data-layout]');
|
|
198
|
+
} else if (isBlockCard) {
|
|
199
|
+
//specific to datasource blockCard
|
|
200
|
+
innerContainer = dom.querySelector('.datasourceView-content-inner-wrap');
|
|
201
|
+
}
|
|
202
|
+
}
|
|
167
203
|
if (supportsAnchor) {
|
|
168
204
|
return {
|
|
169
|
-
left: hasResizer || isExtension ? (0, _dragHandlePositions.getLeftPosition)(dom, nodeType, innerContainer, macroInteractionUpdates) : "calc(anchor(".concat(anchorName, " start) - ").concat(_consts.DRAG_HANDLE_WIDTH, "px - ").concat((0, _consts.dragHandleGap)(nodeType), "px)"),
|
|
205
|
+
left: hasResizer || isExtension || isBlockCard || isEmbedCard ? (0, _dragHandlePositions.getLeftPosition)(dom, nodeType, innerContainer, macroInteractionUpdates) : "calc(anchor(".concat(anchorName, " start) - ").concat(_consts.DRAG_HANDLE_WIDTH, "px - ").concat((0, _consts.dragHandleGap)(nodeType), "px)"),
|
|
170
206
|
top: anchorName.includes('table') ? "calc(anchor(".concat(anchorName, " start) + ").concat(_consts.DRAG_HANDLE_HEIGHT, "px)") : "anchor(".concat(anchorName, " start)")
|
|
171
207
|
};
|
|
172
208
|
}
|
|
@@ -174,7 +210,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
174
210
|
left: (0, _dragHandlePositions.getLeftPosition)(dom, nodeType, innerContainer, macroInteractionUpdates),
|
|
175
211
|
top: (0, _dragHandlePositions.getTopPosition)(dom)
|
|
176
212
|
};
|
|
177
|
-
}, [anchorName, view,
|
|
213
|
+
}, [anchorName, nodeType, view, blockCardWidth, macroInteractionUpdates]);
|
|
178
214
|
return (0, _react2.jsx)("button", {
|
|
179
215
|
type: "button",
|
|
180
216
|
css: [dragHandleButtonStyles, dragHandleSelected && selectedStyles],
|
|
@@ -10,6 +10,7 @@ var _react = require("react");
|
|
|
10
10
|
var _react2 = require("@emotion/react");
|
|
11
11
|
var _bindEventListener = require("bind-event-listener");
|
|
12
12
|
var _dragHandlePositions = require("../utils/drag-handle-positions");
|
|
13
|
+
var _consts = require("./consts");
|
|
13
14
|
/** @jsx jsx */
|
|
14
15
|
|
|
15
16
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
@@ -22,7 +23,8 @@ var basicStyles = (0, _react2.css)({
|
|
|
22
23
|
zIndex: -1
|
|
23
24
|
});
|
|
24
25
|
var mouseMoveWrapperStyles = (0, _react2.css)({
|
|
25
|
-
|
|
26
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
27
|
+
zIndex: _consts.DRAG_HANDLE_ZINDEX
|
|
26
28
|
});
|
|
27
29
|
var MouseMoveWrapper = exports.MouseMoveWrapper = function MouseMoveWrapper(_ref) {
|
|
28
30
|
var view = _ref.view,
|
|
@@ -11,7 +11,9 @@ var getSelection = exports.getSelection = function getSelection(tr, start) {
|
|
|
11
11
|
var isNodeSelection = node && _state.NodeSelection.isSelectable(node);
|
|
12
12
|
var nodeSize = node ? node.nodeSize : 1;
|
|
13
13
|
var $startPos = tr.doc.resolve(start);
|
|
14
|
-
|
|
14
|
+
|
|
15
|
+
// decisionList node is not selectable, but we want to select the whole node not just text
|
|
16
|
+
if (isNodeSelection || (node === null || node === void 0 ? void 0 : node.type.name) === 'decisionList') {
|
|
15
17
|
return new _state.NodeSelection($startPos);
|
|
16
18
|
} else {
|
|
17
19
|
// To trigger the annotation floating toolbar for non-selectable node, we need to select inline nodes
|
|
@@ -243,15 +243,23 @@ export const createPlugin = api => {
|
|
|
243
243
|
const dom = editorView.dom;
|
|
244
244
|
|
|
245
245
|
// Use ResizeObserver to observe height changes
|
|
246
|
-
const resizeObserver = new ResizeObserver(rafSchedule(
|
|
247
|
-
const editorHeight =
|
|
246
|
+
const resizeObserver = new ResizeObserver(rafSchedule(entries => {
|
|
247
|
+
const editorHeight = entries[0].contentBoxSize[0].blockSize;
|
|
248
248
|
|
|
249
249
|
// Update the plugin state when the height changes
|
|
250
250
|
const pluginState = key.getState(editorView.state);
|
|
251
251
|
if (!(pluginState !== null && pluginState !== void 0 && pluginState.isDragging)) {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
252
|
+
const isResizerResizing = !!dom.querySelector('.is-resizing');
|
|
253
|
+
const transaction = editorView.state.tr;
|
|
254
|
+
if ((pluginState === null || pluginState === void 0 ? void 0 : pluginState.isResizerResizing) !== isResizerResizing) {
|
|
255
|
+
transaction.setMeta('is-resizer-resizing', isResizerResizing);
|
|
256
|
+
}
|
|
257
|
+
if (!isResizerResizing) {
|
|
258
|
+
transaction.setMeta(key, {
|
|
259
|
+
editorHeight
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
editorView.dispatch(transaction);
|
|
255
263
|
}
|
|
256
264
|
}));
|
|
257
265
|
|
package/dist/es2019/ui/consts.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { akEditorUnitZIndex, akRichMediaResizeZIndex } from '@atlaskit/editor-shared-styles';
|
|
1
2
|
export const DRAG_HANDLE_HEIGHT = 24;
|
|
2
3
|
export const DRAG_HANDLE_WIDTH = 12;
|
|
3
4
|
export const DRAG_HANDLE_BORDER_RADIUS = 4;
|
|
5
|
+
export const DRAG_HANDLE_ZINDEX = akRichMediaResizeZIndex + akEditorUnitZIndex; //place above legacy resizer
|
|
6
|
+
|
|
4
7
|
const nodeTypeExcludeList = ['embedCard', 'mediaSingle', 'table'];
|
|
5
8
|
export const dragHandleGap = nodeType => {
|
|
6
9
|
if (nodeTypeExcludeList.includes(nodeType)) {
|
|
@@ -11,7 +11,7 @@ import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/el
|
|
|
11
11
|
import { key } from '../pm-plugins/main';
|
|
12
12
|
import { selectNode } from '../utils';
|
|
13
13
|
import { getLeftPosition, getTopPosition } from '../utils/drag-handle-positions';
|
|
14
|
-
import { DRAG_HANDLE_BORDER_RADIUS, DRAG_HANDLE_HEIGHT, DRAG_HANDLE_WIDTH, dragHandleGap } from './consts';
|
|
14
|
+
import { DRAG_HANDLE_BORDER_RADIUS, DRAG_HANDLE_HEIGHT, DRAG_HANDLE_WIDTH, DRAG_HANDLE_ZINDEX, dragHandleGap } from './consts';
|
|
15
15
|
import { dragPreview } from './drag-preview';
|
|
16
16
|
const dragHandleButtonStyles = css({
|
|
17
17
|
position: 'absolute',
|
|
@@ -31,7 +31,8 @@ const dragHandleButtonStyles = css({
|
|
|
31
31
|
borderRadius: DRAG_HANDLE_BORDER_RADIUS,
|
|
32
32
|
color: "var(--ds-icon, #44546F)",
|
|
33
33
|
cursor: 'grab',
|
|
34
|
-
|
|
34
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
35
|
+
zIndex: DRAG_HANDLE_ZINDEX,
|
|
35
36
|
'&:hover': {
|
|
36
37
|
backgroundColor: "var(--ds-background-neutral-subtle-hovered, #091E420F)"
|
|
37
38
|
},
|
|
@@ -52,10 +53,26 @@ export const DragHandle = ({
|
|
|
52
53
|
}) => {
|
|
53
54
|
const start = getPos();
|
|
54
55
|
const buttonRef = useRef(null);
|
|
56
|
+
const [blockCardWidth, setBlockCardWidth] = useState(768);
|
|
55
57
|
const [dragHandleSelected, setDragHandleSelected] = useState(false);
|
|
56
58
|
const {
|
|
57
59
|
featureFlagsState
|
|
58
60
|
} = useSharedPluginState(api, ['featureFlags']);
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
// blockCard/datasource width is rendered correctly after this decoraton does. We need to observe for changes.
|
|
63
|
+
if (nodeType === 'blockCard') {
|
|
64
|
+
const dom = view.dom.querySelector(`[data-drag-handler-anchor-name="${anchorName}"]`);
|
|
65
|
+
const container = dom === null || dom === void 0 ? void 0 : dom.querySelector('.datasourceView-content-inner-wrap');
|
|
66
|
+
if (container) {
|
|
67
|
+
const resizeObserver = new ResizeObserver(entries => {
|
|
68
|
+
const width = entries[0].contentBoxSize[0].inlineSize;
|
|
69
|
+
setBlockCardWidth(width);
|
|
70
|
+
});
|
|
71
|
+
resizeObserver.observe(container);
|
|
72
|
+
return () => resizeObserver.unobserve(container);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}, [anchorName, nodeType, view.dom]);
|
|
59
76
|
const handleOnClick = useCallback(() => {
|
|
60
77
|
var _api$core, _api$core2;
|
|
61
78
|
setDragHandleSelected(!dragHandleSelected);
|
|
@@ -149,17 +166,31 @@ export const DragHandle = ({
|
|
|
149
166
|
api === null || api === void 0 ? void 0 : (_api$core6 = api.core) === null || _api$core6 === void 0 ? void 0 : _api$core6.actions.focus();
|
|
150
167
|
}
|
|
151
168
|
});
|
|
152
|
-
}, [api,
|
|
169
|
+
}, [anchorName, api, nodeType, view, start]);
|
|
153
170
|
const macroInteractionUpdates = featureFlagsState === null || featureFlagsState === void 0 ? void 0 : featureFlagsState.macroInteractionUpdates;
|
|
154
171
|
const positionStyles = useMemo(() => {
|
|
155
172
|
const supportsAnchor = CSS.supports('top', `anchor(${anchorName} start)`) && CSS.supports('left', `anchor(${anchorName} start)`);
|
|
156
173
|
const dom = view.dom.querySelector(`[data-drag-handler-anchor-name="${anchorName}"]`);
|
|
157
|
-
const hasResizer =
|
|
158
|
-
const isExtension =
|
|
159
|
-
const
|
|
174
|
+
const hasResizer = nodeType === 'table' || nodeType === 'mediaSingle';
|
|
175
|
+
const isExtension = nodeType === 'extension' || nodeType === 'bodiedExtension';
|
|
176
|
+
const isBlockCard = nodeType === 'blockCard' && !!blockCardWidth;
|
|
177
|
+
const isEmbedCard = nodeType === 'embedCard';
|
|
178
|
+
let innerContainer = null;
|
|
179
|
+
if (dom) {
|
|
180
|
+
if (isEmbedCard) {
|
|
181
|
+
innerContainer = dom.querySelector('.rich-media-item');
|
|
182
|
+
} else if (hasResizer) {
|
|
183
|
+
innerContainer = dom.querySelector('.resizer-item');
|
|
184
|
+
} else if (isExtension) {
|
|
185
|
+
innerContainer = dom.querySelector('.extension-container[data-layout]');
|
|
186
|
+
} else if (isBlockCard) {
|
|
187
|
+
//specific to datasource blockCard
|
|
188
|
+
innerContainer = dom.querySelector('.datasourceView-content-inner-wrap');
|
|
189
|
+
}
|
|
190
|
+
}
|
|
160
191
|
if (supportsAnchor) {
|
|
161
192
|
return {
|
|
162
|
-
left: hasResizer || isExtension ? getLeftPosition(dom, nodeType, innerContainer, macroInteractionUpdates) : `calc(anchor(${anchorName} start) - ${DRAG_HANDLE_WIDTH}px - ${dragHandleGap(nodeType)}px)`,
|
|
193
|
+
left: hasResizer || isExtension || isBlockCard || isEmbedCard ? getLeftPosition(dom, nodeType, innerContainer, macroInteractionUpdates) : `calc(anchor(${anchorName} start) - ${DRAG_HANDLE_WIDTH}px - ${dragHandleGap(nodeType)}px)`,
|
|
163
194
|
top: anchorName.includes('table') ? `calc(anchor(${anchorName} start) + ${DRAG_HANDLE_HEIGHT}px)` : `anchor(${anchorName} start)`
|
|
164
195
|
};
|
|
165
196
|
}
|
|
@@ -167,7 +198,7 @@ export const DragHandle = ({
|
|
|
167
198
|
left: getLeftPosition(dom, nodeType, innerContainer, macroInteractionUpdates),
|
|
168
199
|
top: getTopPosition(dom)
|
|
169
200
|
};
|
|
170
|
-
}, [anchorName, view,
|
|
201
|
+
}, [anchorName, nodeType, view, blockCardWidth, macroInteractionUpdates]);
|
|
171
202
|
return jsx("button", {
|
|
172
203
|
type: "button",
|
|
173
204
|
css: [dragHandleButtonStyles, dragHandleSelected && selectedStyles],
|
|
@@ -5,6 +5,7 @@ import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react
|
|
|
5
5
|
import { css, jsx } from '@emotion/react';
|
|
6
6
|
import { bind } from 'bind-event-listener';
|
|
7
7
|
import { getTopPosition } from '../utils/drag-handle-positions';
|
|
8
|
+
import { DRAG_HANDLE_ZINDEX } from './consts';
|
|
8
9
|
const basicStyles = css({
|
|
9
10
|
position: 'absolute',
|
|
10
11
|
width: '100%',
|
|
@@ -13,7 +14,8 @@ const basicStyles = css({
|
|
|
13
14
|
zIndex: -1
|
|
14
15
|
});
|
|
15
16
|
const mouseMoveWrapperStyles = css({
|
|
16
|
-
|
|
17
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
18
|
+
zIndex: DRAG_HANDLE_ZINDEX
|
|
17
19
|
});
|
|
18
20
|
export const MouseMoveWrapper = ({
|
|
19
21
|
view,
|
|
@@ -5,7 +5,9 @@ export const getSelection = (tr, start) => {
|
|
|
5
5
|
const isNodeSelection = node && NodeSelection.isSelectable(node);
|
|
6
6
|
const nodeSize = node ? node.nodeSize : 1;
|
|
7
7
|
const $startPos = tr.doc.resolve(start);
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
// decisionList node is not selectable, but we want to select the whole node not just text
|
|
10
|
+
if (isNodeSelection || (node === null || node === void 0 ? void 0 : node.type.name) === 'decisionList') {
|
|
9
11
|
return new NodeSelection($startPos);
|
|
10
12
|
} else {
|
|
11
13
|
// To trigger the annotation floating toolbar for non-selectable node, we need to select inline nodes
|
|
@@ -241,15 +241,23 @@ export var createPlugin = function createPlugin(api) {
|
|
|
241
241
|
var dom = editorView.dom;
|
|
242
242
|
|
|
243
243
|
// Use ResizeObserver to observe height changes
|
|
244
|
-
var resizeObserver = new ResizeObserver(rafSchedule(function () {
|
|
245
|
-
var editorHeight =
|
|
244
|
+
var resizeObserver = new ResizeObserver(rafSchedule(function (entries) {
|
|
245
|
+
var editorHeight = entries[0].contentBoxSize[0].blockSize;
|
|
246
246
|
|
|
247
247
|
// Update the plugin state when the height changes
|
|
248
248
|
var pluginState = key.getState(editorView.state);
|
|
249
249
|
if (!(pluginState !== null && pluginState !== void 0 && pluginState.isDragging)) {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
250
|
+
var isResizerResizing = !!dom.querySelector('.is-resizing');
|
|
251
|
+
var transaction = editorView.state.tr;
|
|
252
|
+
if ((pluginState === null || pluginState === void 0 ? void 0 : pluginState.isResizerResizing) !== isResizerResizing) {
|
|
253
|
+
transaction.setMeta('is-resizer-resizing', isResizerResizing);
|
|
254
|
+
}
|
|
255
|
+
if (!isResizerResizing) {
|
|
256
|
+
transaction.setMeta(key, {
|
|
257
|
+
editorHeight: editorHeight
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
editorView.dispatch(transaction);
|
|
253
261
|
}
|
|
254
262
|
}));
|
|
255
263
|
|
package/dist/esm/ui/consts.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { akEditorUnitZIndex, akRichMediaResizeZIndex } from '@atlaskit/editor-shared-styles';
|
|
1
2
|
export var DRAG_HANDLE_HEIGHT = 24;
|
|
2
3
|
export var DRAG_HANDLE_WIDTH = 12;
|
|
3
4
|
export var DRAG_HANDLE_BORDER_RADIUS = 4;
|
|
5
|
+
export var DRAG_HANDLE_ZINDEX = akRichMediaResizeZIndex + akEditorUnitZIndex; //place above legacy resizer
|
|
6
|
+
|
|
4
7
|
var nodeTypeExcludeList = ['embedCard', 'mediaSingle', 'table'];
|
|
5
8
|
export var dragHandleGap = function dragHandleGap(nodeType) {
|
|
6
9
|
if (nodeTypeExcludeList.includes(nodeType)) {
|
|
@@ -12,7 +12,7 @@ import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/el
|
|
|
12
12
|
import { key } from '../pm-plugins/main';
|
|
13
13
|
import { selectNode } from '../utils';
|
|
14
14
|
import { getLeftPosition, getTopPosition } from '../utils/drag-handle-positions';
|
|
15
|
-
import { DRAG_HANDLE_BORDER_RADIUS, DRAG_HANDLE_HEIGHT, DRAG_HANDLE_WIDTH, dragHandleGap } from './consts';
|
|
15
|
+
import { DRAG_HANDLE_BORDER_RADIUS, DRAG_HANDLE_HEIGHT, DRAG_HANDLE_WIDTH, DRAG_HANDLE_ZINDEX, dragHandleGap } from './consts';
|
|
16
16
|
import { dragPreview } from './drag-preview';
|
|
17
17
|
var dragHandleButtonStyles = css({
|
|
18
18
|
position: 'absolute',
|
|
@@ -32,7 +32,8 @@ var dragHandleButtonStyles = css({
|
|
|
32
32
|
borderRadius: DRAG_HANDLE_BORDER_RADIUS,
|
|
33
33
|
color: "var(--ds-icon, #44546F)",
|
|
34
34
|
cursor: 'grab',
|
|
35
|
-
|
|
35
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
36
|
+
zIndex: DRAG_HANDLE_ZINDEX,
|
|
36
37
|
'&:hover': {
|
|
37
38
|
backgroundColor: "var(--ds-background-neutral-subtle-hovered, #091E420F)"
|
|
38
39
|
},
|
|
@@ -52,12 +53,33 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
52
53
|
nodeType = _ref.nodeType;
|
|
53
54
|
var start = getPos();
|
|
54
55
|
var buttonRef = useRef(null);
|
|
55
|
-
var _useState = useState(
|
|
56
|
+
var _useState = useState(768),
|
|
56
57
|
_useState2 = _slicedToArray(_useState, 2),
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
blockCardWidth = _useState2[0],
|
|
59
|
+
setBlockCardWidth = _useState2[1];
|
|
60
|
+
var _useState3 = useState(false),
|
|
61
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
62
|
+
dragHandleSelected = _useState4[0],
|
|
63
|
+
setDragHandleSelected = _useState4[1];
|
|
59
64
|
var _useSharedPluginState = useSharedPluginState(api, ['featureFlags']),
|
|
60
65
|
featureFlagsState = _useSharedPluginState.featureFlagsState;
|
|
66
|
+
useEffect(function () {
|
|
67
|
+
// blockCard/datasource width is rendered correctly after this decoraton does. We need to observe for changes.
|
|
68
|
+
if (nodeType === 'blockCard') {
|
|
69
|
+
var dom = view.dom.querySelector("[data-drag-handler-anchor-name=\"".concat(anchorName, "\"]"));
|
|
70
|
+
var container = dom === null || dom === void 0 ? void 0 : dom.querySelector('.datasourceView-content-inner-wrap');
|
|
71
|
+
if (container) {
|
|
72
|
+
var resizeObserver = new ResizeObserver(function (entries) {
|
|
73
|
+
var width = entries[0].contentBoxSize[0].inlineSize;
|
|
74
|
+
setBlockCardWidth(width);
|
|
75
|
+
});
|
|
76
|
+
resizeObserver.observe(container);
|
|
77
|
+
return function () {
|
|
78
|
+
return resizeObserver.unobserve(container);
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}, [anchorName, nodeType, view.dom]);
|
|
61
83
|
var handleOnClick = useCallback(function () {
|
|
62
84
|
var _api$core, _api$core2;
|
|
63
85
|
setDragHandleSelected(!dragHandleSelected);
|
|
@@ -148,17 +170,31 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
148
170
|
api === null || api === void 0 || (_api$core6 = api.core) === null || _api$core6 === void 0 || _api$core6.actions.focus();
|
|
149
171
|
}
|
|
150
172
|
});
|
|
151
|
-
}, [api,
|
|
173
|
+
}, [anchorName, api, nodeType, view, start]);
|
|
152
174
|
var macroInteractionUpdates = featureFlagsState === null || featureFlagsState === void 0 ? void 0 : featureFlagsState.macroInteractionUpdates;
|
|
153
175
|
var positionStyles = useMemo(function () {
|
|
154
176
|
var supportsAnchor = CSS.supports('top', "anchor(".concat(anchorName, " start)")) && CSS.supports('left', "anchor(".concat(anchorName, " start)"));
|
|
155
177
|
var dom = view.dom.querySelector("[data-drag-handler-anchor-name=\"".concat(anchorName, "\"]"));
|
|
156
|
-
var hasResizer =
|
|
157
|
-
var isExtension =
|
|
158
|
-
var
|
|
178
|
+
var hasResizer = nodeType === 'table' || nodeType === 'mediaSingle';
|
|
179
|
+
var isExtension = nodeType === 'extension' || nodeType === 'bodiedExtension';
|
|
180
|
+
var isBlockCard = nodeType === 'blockCard' && !!blockCardWidth;
|
|
181
|
+
var isEmbedCard = nodeType === 'embedCard';
|
|
182
|
+
var innerContainer = null;
|
|
183
|
+
if (dom) {
|
|
184
|
+
if (isEmbedCard) {
|
|
185
|
+
innerContainer = dom.querySelector('.rich-media-item');
|
|
186
|
+
} else if (hasResizer) {
|
|
187
|
+
innerContainer = dom.querySelector('.resizer-item');
|
|
188
|
+
} else if (isExtension) {
|
|
189
|
+
innerContainer = dom.querySelector('.extension-container[data-layout]');
|
|
190
|
+
} else if (isBlockCard) {
|
|
191
|
+
//specific to datasource blockCard
|
|
192
|
+
innerContainer = dom.querySelector('.datasourceView-content-inner-wrap');
|
|
193
|
+
}
|
|
194
|
+
}
|
|
159
195
|
if (supportsAnchor) {
|
|
160
196
|
return {
|
|
161
|
-
left: hasResizer || isExtension ? getLeftPosition(dom, nodeType, innerContainer, macroInteractionUpdates) : "calc(anchor(".concat(anchorName, " start) - ").concat(DRAG_HANDLE_WIDTH, "px - ").concat(dragHandleGap(nodeType), "px)"),
|
|
197
|
+
left: hasResizer || isExtension || isBlockCard || isEmbedCard ? getLeftPosition(dom, nodeType, innerContainer, macroInteractionUpdates) : "calc(anchor(".concat(anchorName, " start) - ").concat(DRAG_HANDLE_WIDTH, "px - ").concat(dragHandleGap(nodeType), "px)"),
|
|
162
198
|
top: anchorName.includes('table') ? "calc(anchor(".concat(anchorName, " start) + ").concat(DRAG_HANDLE_HEIGHT, "px)") : "anchor(".concat(anchorName, " start)")
|
|
163
199
|
};
|
|
164
200
|
}
|
|
@@ -166,7 +202,7 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
166
202
|
left: getLeftPosition(dom, nodeType, innerContainer, macroInteractionUpdates),
|
|
167
203
|
top: getTopPosition(dom)
|
|
168
204
|
};
|
|
169
|
-
}, [anchorName, view,
|
|
205
|
+
}, [anchorName, nodeType, view, blockCardWidth, macroInteractionUpdates]);
|
|
170
206
|
return jsx("button", {
|
|
171
207
|
type: "button",
|
|
172
208
|
css: [dragHandleButtonStyles, dragHandleSelected && selectedStyles],
|
|
@@ -6,6 +6,7 @@ import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react
|
|
|
6
6
|
import { css, jsx } from '@emotion/react';
|
|
7
7
|
import { bind } from 'bind-event-listener';
|
|
8
8
|
import { getTopPosition } from '../utils/drag-handle-positions';
|
|
9
|
+
import { DRAG_HANDLE_ZINDEX } from './consts';
|
|
9
10
|
var basicStyles = css({
|
|
10
11
|
position: 'absolute',
|
|
11
12
|
width: '100%',
|
|
@@ -14,7 +15,8 @@ var basicStyles = css({
|
|
|
14
15
|
zIndex: -1
|
|
15
16
|
});
|
|
16
17
|
var mouseMoveWrapperStyles = css({
|
|
17
|
-
|
|
18
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
19
|
+
zIndex: DRAG_HANDLE_ZINDEX
|
|
18
20
|
});
|
|
19
21
|
export var MouseMoveWrapper = function MouseMoveWrapper(_ref) {
|
|
20
22
|
var view = _ref.view,
|
|
@@ -5,7 +5,9 @@ export var getSelection = function getSelection(tr, start) {
|
|
|
5
5
|
var isNodeSelection = node && NodeSelection.isSelectable(node);
|
|
6
6
|
var nodeSize = node ? node.nodeSize : 1;
|
|
7
7
|
var $startPos = tr.doc.resolve(start);
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
// decisionList node is not selectable, but we want to select the whole node not just text
|
|
10
|
+
if (isNodeSelection || (node === null || node === void 0 ? void 0 : node.type.name) === 'decisionList') {
|
|
9
11
|
return new NodeSelection($startPos);
|
|
10
12
|
} else {
|
|
11
13
|
// To trigger the annotation floating toolbar for non-selectable node, we need to select inline nodes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from '@emotion/react';
|
|
2
2
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
-
import {
|
|
3
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
4
4
|
import type { BlockControlsPlugin } from '../types';
|
|
5
5
|
export declare const DragHandle: ({ view, api, getPos, anchorName, nodeType, }: {
|
|
6
6
|
view: EditorView;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from '@emotion/react';
|
|
2
2
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
-
import {
|
|
3
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
4
4
|
import type { BlockControlsPlugin } from '../types';
|
|
5
5
|
export declare const MouseMoveWrapper: ({ view, api, anchorName, nodeType, getPos, }: {
|
|
6
6
|
view: EditorView;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from '@emotion/react';
|
|
2
2
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
-
import {
|
|
3
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
4
4
|
import type { BlockControlsPlugin } from '../types';
|
|
5
5
|
export declare const DragHandle: ({ view, api, getPos, anchorName, nodeType, }: {
|
|
6
6
|
view: EditorView;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from '@emotion/react';
|
|
2
2
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
-
import {
|
|
3
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
4
4
|
import type { BlockControlsPlugin } from '../types';
|
|
5
5
|
export declare const MouseMoveWrapper: ({ view, api, anchorName, nodeType, getPos, }: {
|
|
6
6
|
view: EditorView;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.28",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,13 +31,14 @@
|
|
|
31
31
|
".": "./src/index.ts"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@atlaskit/adf-schema": "^
|
|
35
|
-
"@atlaskit/editor-common": "^82.
|
|
36
|
-
"@atlaskit/editor-plugin-analytics": "^1.
|
|
34
|
+
"@atlaskit/adf-schema": "^37.0.0",
|
|
35
|
+
"@atlaskit/editor-common": "^82.12.0",
|
|
36
|
+
"@atlaskit/editor-plugin-analytics": "^1.3.0",
|
|
37
37
|
"@atlaskit/editor-plugin-editor-disabled": "^1.1.5",
|
|
38
38
|
"@atlaskit/editor-plugin-feature-flags": "^1.1.0",
|
|
39
39
|
"@atlaskit/editor-plugin-width": "^1.1.0",
|
|
40
40
|
"@atlaskit/editor-prosemirror": "4.0.1",
|
|
41
|
+
"@atlaskit/editor-shared-styles": "^2.12.0",
|
|
41
42
|
"@atlaskit/editor-tables": "^2.7.0",
|
|
42
43
|
"@atlaskit/icon": "^22.4.0",
|
|
43
44
|
"@atlaskit/platform-feature-flags": "^0.2.0",
|
|
@@ -45,7 +46,7 @@
|
|
|
45
46
|
"@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^1.3.0",
|
|
46
47
|
"@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^1.1.0",
|
|
47
48
|
"@atlaskit/theme": "^12.11.0",
|
|
48
|
-
"@atlaskit/tokens": "^1.
|
|
49
|
+
"@atlaskit/tokens": "^1.53.0",
|
|
49
50
|
"@babel/runtime": "^7.0.0",
|
|
50
51
|
"@emotion/react": "^11.7.1",
|
|
51
52
|
"bind-event-listener": "^3.0.0",
|