@atlaskit/editor-plugin-block-controls 23.0.2 → 23.0.4
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 +24 -0
- package/dist/cjs/blockControlsPlugin.js +4 -6
- package/dist/cjs/pm-plugins/handle-mouse-over.js +0 -5
- package/dist/cjs/pm-plugins/handle-sparse-mouse-over.js +0 -4
- package/dist/cjs/pm-plugins/main.js +2 -20
- package/dist/cjs/pm-plugins/utils/selection.js +1 -30
- package/dist/cjs/ui/block-controls-surface-drag-handle-utils.js +3 -11
- package/dist/cjs/ui/block-controls-surface-drag-handle.js +6 -23
- package/dist/cjs/ui/consts.js +1 -9
- package/dist/cjs/ui/drag-handle.js +22 -67
- package/dist/cjs/ui/should-use-nested-drag-handle-icon.js +2 -6
- package/dist/es2019/blockControlsPlugin.js +4 -6
- package/dist/es2019/pm-plugins/handle-mouse-over.js +0 -5
- package/dist/es2019/pm-plugins/handle-sparse-mouse-over.js +0 -4
- package/dist/es2019/pm-plugins/main.js +2 -22
- package/dist/es2019/pm-plugins/utils/selection.js +1 -30
- package/dist/es2019/ui/block-controls-surface-drag-handle-utils.js +0 -4
- package/dist/es2019/ui/block-controls-surface-drag-handle.js +6 -23
- package/dist/es2019/ui/consts.js +0 -8
- package/dist/es2019/ui/drag-handle.js +9 -49
- package/dist/es2019/ui/should-use-nested-drag-handle-icon.js +2 -7
- package/dist/esm/blockControlsPlugin.js +4 -6
- package/dist/esm/pm-plugins/handle-mouse-over.js +0 -5
- package/dist/esm/pm-plugins/handle-sparse-mouse-over.js +0 -4
- package/dist/esm/pm-plugins/main.js +2 -20
- package/dist/esm/pm-plugins/utils/selection.js +1 -30
- package/dist/esm/ui/block-controls-surface-drag-handle-utils.js +3 -10
- package/dist/esm/ui/block-controls-surface-drag-handle.js +6 -23
- package/dist/esm/ui/consts.js +0 -8
- package/dist/esm/ui/drag-handle.js +23 -68
- package/dist/esm/ui/should-use-nested-drag-handle-icon.js +2 -7
- package/dist/types/blockControlsPluginType.d.ts +0 -2
- package/dist/types/pm-plugins/main.d.ts +0 -2
- package/dist/types/pm-plugins/utils/selection.d.ts +2 -14
- package/dist/types/ui/block-controls-surface-drag-handle-utils.d.ts +0 -1
- package/dist/types/ui/consts.d.ts +0 -7
- package/package.json +4 -11
|
@@ -18,14 +18,12 @@ import { blockControlsMessages } from '@atlaskit/editor-common/messages';
|
|
|
18
18
|
import DragHandleVerticalIcon from '@atlaskit/icon/core/drag-handle-vertical';
|
|
19
19
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
20
20
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
21
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
22
21
|
import Tooltip from '@atlaskit/tooltip/Tooltip';
|
|
23
22
|
import { selectionPreservationPluginKey } from '../pm-plugins/selection-preservation/plugin-key';
|
|
24
23
|
import { prepareCollapsedHeadingSelection } from '../pm-plugins/utils/collapsed-heading';
|
|
25
24
|
import { expandAndUpdateSelection } from '../pm-plugins/utils/expand-and-update-selection';
|
|
26
25
|
import { isHandleCorrelatedToSelection } from '../pm-plugins/utils/getSelection';
|
|
27
26
|
import { buildLayoutColumnMenuMeta } from './block-controls-surface-drag-handle-utils';
|
|
28
|
-
import { DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH } from './consts';
|
|
29
27
|
import { DragHandleNestedIcon } from './drag-handle-nested-icon';
|
|
30
28
|
import { shouldUseNestedDragHandleIcon } from './should-use-nested-drag-handle-icon';
|
|
31
29
|
import { useSurfaceEditorView } from './surface-editor-view-context';
|
|
@@ -82,19 +80,17 @@ export var BlockControlsSurfaceDragHandle = function BlockControlsSurfaceDragHan
|
|
|
82
80
|
return posRef.current;
|
|
83
81
|
}, []);
|
|
84
82
|
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['blockControls', 'interaction', 'selection'], function (states) {
|
|
85
|
-
var _states$blockControls, _states$blockControls2, _states$interactionSt, _states$
|
|
83
|
+
var _states$blockControls, _states$blockControls2, _states$interactionSt, _states$selectionStat;
|
|
86
84
|
return {
|
|
87
85
|
activeNodeAnchorName: (_states$blockControls = states.blockControlsState) === null || _states$blockControls === void 0 || (_states$blockControls = _states$blockControls.activeNode) === null || _states$blockControls === void 0 ? void 0 : _states$blockControls.anchorName,
|
|
88
86
|
handleOptions: (_states$blockControls2 = states.blockControlsState) === null || _states$blockControls2 === void 0 || (_states$blockControls2 = _states$blockControls2.activeNode) === null || _states$blockControls2 === void 0 ? void 0 : _states$blockControls2.handleOptions,
|
|
89
87
|
interactionState: (_states$interactionSt = states.interactionState) === null || _states$interactionSt === void 0 ? void 0 : _states$interactionSt.interactionState,
|
|
90
|
-
isShiftDown: (_states$blockControls3 = states.blockControlsState) === null || _states$blockControls3 === void 0 ? void 0 : _states$blockControls3.isShiftDown,
|
|
91
88
|
selection: (_states$selectionStat = states.selectionState) === null || _states$selectionStat === void 0 ? void 0 : _states$selectionStat.selection
|
|
92
89
|
};
|
|
93
90
|
}),
|
|
94
91
|
activeNodeAnchorName = _useSharedPluginState.activeNodeAnchorName,
|
|
95
92
|
handleOptions = _useSharedPluginState.handleOptions,
|
|
96
93
|
interactionState = _useSharedPluginState.interactionState,
|
|
97
|
-
isShiftDown = _useSharedPluginState.isShiftDown,
|
|
98
94
|
selection = _useSharedPluginState.selection;
|
|
99
95
|
var _useState = useState(false),
|
|
100
96
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -105,21 +101,9 @@ export var BlockControlsSurfaceDragHandle = function BlockControlsSurfaceDragHan
|
|
|
105
101
|
}, [pos, selection, view]);
|
|
106
102
|
var isLayoutColumn = nodeType === 'layoutColumn';
|
|
107
103
|
var isTopLevelNode = (activeNode === null || activeNode === void 0 ? void 0 : activeNode.parentType) === 'doc';
|
|
108
|
-
var isDisabled = useMemo(function () {
|
|
109
|
-
var _api$blockControls$sh;
|
|
110
|
-
if (!isShiftDown || !view || view.state.selection.empty || !fg('platform_editor_elements_dnd_shift_click_select')) {
|
|
111
|
-
return false;
|
|
112
|
-
}
|
|
113
|
-
if (isLayoutColumn && expValEquals('platform_editor_layout_column_menu', 'isEnabled', true)) {
|
|
114
|
-
return false;
|
|
115
|
-
}
|
|
116
|
-
var multiSelect = api === null || api === void 0 || (_api$blockControls$sh = api.blockControls.sharedState.currentState()) === null || _api$blockControls$sh === void 0 ? void 0 : _api$blockControls$sh.multiSelectDnD;
|
|
117
|
-
var $anchor = (multiSelect === null || multiSelect === void 0 ? void 0 : multiSelect.anchor) !== undefined ? view.state.doc.resolve(multiSelect.anchor) : view.state.selection.$anchor;
|
|
118
|
-
return !isTopLevelNode || $anchor.depth > DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH;
|
|
119
|
-
}, [api, isLayoutColumn, isShiftDown, isTopLevelNode, view]);
|
|
120
104
|
var getAnchorName = useCallback(function () {
|
|
121
|
-
var _api$blockControls$
|
|
122
|
-
var surfaceAnchor = posRef.current === undefined ? undefined : api === null || api === void 0 || (_api$blockControls$
|
|
105
|
+
var _api$blockControls$sh, _ref2, _ref3, _dom$getAttribute, _dom$closest;
|
|
106
|
+
var surfaceAnchor = posRef.current === undefined ? undefined : api === null || api === void 0 || (_api$blockControls$sh = api.blockControls.sharedState.currentState()) === null || _api$blockControls$sh === void 0 || (_api$blockControls$sh = _api$blockControls$sh.surfaceAnchors) === null || _api$blockControls$sh === void 0 ? void 0 : _api$blockControls$sh.get(posRef.current);
|
|
123
107
|
if (surfaceAnchor) {
|
|
124
108
|
return surfaceAnchor;
|
|
125
109
|
}
|
|
@@ -187,7 +171,7 @@ export var BlockControlsSurfaceDragHandle = function BlockControlsSurfaceDragHan
|
|
|
187
171
|
}, [api]);
|
|
188
172
|
var handleClick = useCallback(function (event) {
|
|
189
173
|
var _api$core2;
|
|
190
|
-
if (!view
|
|
174
|
+
if (!view) {
|
|
191
175
|
return;
|
|
192
176
|
}
|
|
193
177
|
var openedViaKeyboard = event.detail === 0;
|
|
@@ -198,7 +182,7 @@ export var BlockControlsSurfaceDragHandle = function BlockControlsSurfaceDragHan
|
|
|
198
182
|
if (startPos === undefined) {
|
|
199
183
|
return tr;
|
|
200
184
|
}
|
|
201
|
-
if (nodeType === 'layoutColumn'
|
|
185
|
+
if (nodeType === 'layoutColumn') {
|
|
202
186
|
tr.setMeta('toggleLayoutColumnMenu', buildLayoutColumnMenuMeta(startPos, openedViaKeyboard));
|
|
203
187
|
}
|
|
204
188
|
var selection = (_selectionPreservatio = (_selectionPreservatio2 = selectionPreservationPluginKey.getState(view.state)) === null || _selectionPreservatio2 === void 0 ? void 0 : _selectionPreservatio2.preservedSelection) !== null && _selectionPreservatio !== void 0 ? _selectionPreservatio : tr.selection;
|
|
@@ -247,7 +231,7 @@ export var BlockControlsSurfaceDragHandle = function BlockControlsSurfaceDragHan
|
|
|
247
231
|
return tr;
|
|
248
232
|
});
|
|
249
233
|
view.focus();
|
|
250
|
-
}, [activeNode === null || activeNode === void 0 ? void 0 : activeNode.rootPos, api, getAnchorName, getPos,
|
|
234
|
+
}, [activeNode === null || activeNode === void 0 ? void 0 : activeNode.rootPos, api, getAnchorName, getPos, nodeType, view]);
|
|
251
235
|
var label = formatMessage(blockControlsMessages.dragToMoveClickToOpen, {
|
|
252
236
|
br: ' '
|
|
253
237
|
});
|
|
@@ -275,7 +259,6 @@ export var BlockControlsSurfaceDragHandle = function BlockControlsSurfaceDragHan
|
|
|
275
259
|
ref: buttonRef,
|
|
276
260
|
type: "button",
|
|
277
261
|
"aria-label": label,
|
|
278
|
-
disabled: isDisabled,
|
|
279
262
|
onClick: handleClick,
|
|
280
263
|
onMouseDown: handleMouseDown
|
|
281
264
|
// eslint-disable-next-line @atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop -- Pragmatic DnD owns this native drag source.
|
package/dist/esm/ui/consts.js
CHANGED
|
@@ -40,14 +40,6 @@ export var DRAG_HANDLE_LAYOUT_SECTION_TOP_ADJUSTMENT = 8;
|
|
|
40
40
|
export var DRAG_HANDLE_PARAGRAPH_TOP_ADJUSTMENT = 2;
|
|
41
41
|
export var DRAG_HANDLE_PARAGRAPH_SMALL_TOP_ADJUSTMENT = 0;
|
|
42
42
|
export var DRAG_HANDLE_WRAPPED_MEDIA_EMBED_TOP_ADJUSTMENT = 8;
|
|
43
|
-
|
|
44
|
-
/** We only want to shift-select nodes that are at the top level of a document.
|
|
45
|
-
* This is because funky things happen when selecting inside of tableCells, but we
|
|
46
|
-
* also want to avoid heavily nested cases to descope potential corner cases.
|
|
47
|
-
* Various top level nodes have their selection 'from' at depths other than 0,
|
|
48
|
-
* so we allow for some leniency to capture them all. e.g. Table is depth 3.
|
|
49
|
-
*/
|
|
50
|
-
export var DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH = 3;
|
|
51
43
|
export var STICKY_CONTROLS_TOP_MARGIN = 8;
|
|
52
44
|
export var STICKY_CONTROLS_TOP_MARGIN_FOR_STICKY_HEADER = 24;
|
|
53
45
|
export var QUICK_INSERT_HEIGHT = 24;
|
|
@@ -39,7 +39,7 @@ import { getMultiSelectAnalyticsAttributes } from '../pm-plugins/utils/analytics
|
|
|
39
39
|
import { getControlBottomCSSValue, getControlHeightCSSValue, getLeftPosition, getNodeHeight, getTopPosition, shouldBeSticky, shouldMaskNodeControls } from '../pm-plugins/utils/drag-handle-positions';
|
|
40
40
|
import { expandAndUpdateSelection } from '../pm-plugins/utils/expand-and-update-selection';
|
|
41
41
|
import { isHandleCorrelatedToSelection, selectNode } from '../pm-plugins/utils/getSelection';
|
|
42
|
-
import { ACTIVE_DRAG_HANDLE_ATTR, ACTIVE_DRAG_HANDLE_FALLBACK_ANCHOR_NAME, DRAG_HANDLE_BORDER_RADIUS, DRAG_HANDLE_HEIGHT,
|
|
42
|
+
import { ACTIVE_DRAG_HANDLE_ATTR, ACTIVE_DRAG_HANDLE_FALLBACK_ANCHOR_NAME, DRAG_HANDLE_BORDER_RADIUS, DRAG_HANDLE_HEIGHT, DRAG_HANDLE_ZINDEX, dragHandleGap, nodeMargins, spacingBetweenNodesForPreview, STICKY_CONTROLS_TOP_MARGIN, STICKY_CONTROLS_TOP_MARGIN_FOR_STICKY_HEADER, topPositionAdjustment } from './consts';
|
|
43
43
|
import { DragHandleNestedIcon } from './drag-handle-nested-icon';
|
|
44
44
|
import { dragPreview } from './drag-preview';
|
|
45
45
|
import { shouldUseNestedDragHandleIcon } from './should-use-nested-drag-handle-icon';
|
|
@@ -329,16 +329,12 @@ var getNodeMargins = function getNodeMargins(node) {
|
|
|
329
329
|
return nodeMargins[nodeTypeName] || nodeMargins['default'];
|
|
330
330
|
};
|
|
331
331
|
|
|
332
|
-
//
|
|
333
|
-
// `isOpen: true` for legacy always-open. Centralised so all dispatch sites stay in sync.
|
|
332
|
+
// Omit `isOpen` so the reducer toggles the menu for a re-clicked layout column.
|
|
334
333
|
var buildToggleLayoutColumnMenuMeta = function buildToggleLayoutColumnMenuMeta(anchorPos, openedViaKeyboard) {
|
|
335
|
-
return
|
|
336
|
-
anchorPos: anchorPos
|
|
337
|
-
}, fg('platform_editor_layout_column_menu_kill_switch_1') ? {
|
|
338
|
-
isOpen: true
|
|
339
|
-
} : {}), {}, {
|
|
334
|
+
return {
|
|
335
|
+
anchorPos: anchorPos,
|
|
340
336
|
openedViaKeyboard: openedViaKeyboard
|
|
341
|
-
}
|
|
337
|
+
};
|
|
342
338
|
};
|
|
343
339
|
var getDragHandleAnchorReference = function getDragHandleAnchorReference(_ref) {
|
|
344
340
|
var edge = _ref.edge,
|
|
@@ -349,7 +345,6 @@ var getDragHandleAnchorReference = function getDragHandleAnchorReference(_ref) {
|
|
|
349
345
|
return "anchor(".concat(safeAnchorName, " ").concat(edge, ")");
|
|
350
346
|
};
|
|
351
347
|
export var DragHandle = function DragHandle(_ref2) {
|
|
352
|
-
var _api$blockControls7;
|
|
353
348
|
var view = _ref2.view,
|
|
354
349
|
api = _ref2.api,
|
|
355
350
|
formatMessage = _ref2.formatMessage,
|
|
@@ -364,41 +359,35 @@ export var DragHandle = function DragHandle(_ref2) {
|
|
|
364
359
|
_useState2 = _slicedToArray(_useState, 2),
|
|
365
360
|
dragHandleSelected = _useState2[0],
|
|
366
361
|
setDragHandleSelected = _useState2[1];
|
|
367
|
-
var _useState3 = useState(
|
|
362
|
+
var _useState3 = useState(768),
|
|
368
363
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
var _useState5 = useState(
|
|
372
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
373
|
-
blockCardWidth = _useState6[0],
|
|
374
|
-
setBlockCardWidth = _useState6[1];
|
|
375
|
-
var _useState7 = useState({
|
|
364
|
+
blockCardWidth = _useState4[0],
|
|
365
|
+
setBlockCardWidth = _useState4[1];
|
|
366
|
+
var _useState5 = useState({
|
|
376
367
|
display: 'none'
|
|
377
368
|
}),
|
|
378
|
-
|
|
379
|
-
positionStylesOld =
|
|
380
|
-
setPositionStylesOld =
|
|
369
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
370
|
+
positionStylesOld = _useState6[0],
|
|
371
|
+
setPositionStylesOld = _useState6[1];
|
|
381
372
|
// Tracks whether the initial position calculation has been performed at least once.
|
|
382
373
|
// The reliable-anchor early-return optimisation must not fire before the first calculation,
|
|
383
374
|
// otherwise positionStylesOld stays as { display: 'none' } and the handle is never shown.
|
|
384
375
|
var hasCalculatedInitialPosition = useRef(false);
|
|
385
|
-
var
|
|
386
|
-
|
|
387
|
-
isFocused =
|
|
388
|
-
setIsFocused =
|
|
376
|
+
var _useState7 = useState(Boolean(handleOptions === null || handleOptions === void 0 ? void 0 : handleOptions.isFocused)),
|
|
377
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
378
|
+
isFocused = _useState8[0],
|
|
379
|
+
setIsFocused = _useState8[1];
|
|
389
380
|
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['featureFlags', 'selection', 'blockControls', 'interaction', 'userIntent'], function (states) {
|
|
390
|
-
var _states$featureFlagsS, _states$selectionStat, _states$
|
|
381
|
+
var _states$featureFlagsS, _states$selectionStat, _states$interactionSt, _states$userIntentSta;
|
|
391
382
|
return {
|
|
392
383
|
macroInteractionUpdates: (_states$featureFlagsS = states.featureFlagsState) === null || _states$featureFlagsS === void 0 ? void 0 : _states$featureFlagsS.macroInteractionUpdates,
|
|
393
384
|
selection: (_states$selectionStat = states.selectionState) === null || _states$selectionStat === void 0 ? void 0 : _states$selectionStat.selection,
|
|
394
|
-
isShiftDown: (_states$blockControls = states.blockControlsState) === null || _states$blockControls === void 0 ? void 0 : _states$blockControls.isShiftDown,
|
|
395
385
|
interactionState: (_states$interactionSt = states.interactionState) === null || _states$interactionSt === void 0 ? void 0 : _states$interactionSt.interactionState,
|
|
396
386
|
currentUserIntent: (_states$userIntentSta = states.userIntentState) === null || _states$userIntentSta === void 0 ? void 0 : _states$userIntentSta.currentUserIntent
|
|
397
387
|
};
|
|
398
388
|
}),
|
|
399
389
|
macroInteractionUpdates = _useSharedPluginState.macroInteractionUpdates,
|
|
400
390
|
selection = _useSharedPluginState.selection,
|
|
401
|
-
isShiftDown = _useSharedPluginState.isShiftDown,
|
|
402
391
|
interactionState = _useSharedPluginState.interactionState,
|
|
403
392
|
currentUserIntent = _useSharedPluginState.currentUserIntent;
|
|
404
393
|
var start = getPos();
|
|
@@ -469,7 +458,7 @@ export var DragHandle = function DragHandle(_ref2) {
|
|
|
469
458
|
if (startPos === undefined) {
|
|
470
459
|
return tr;
|
|
471
460
|
}
|
|
472
|
-
if (nodeType === 'layoutColumn'
|
|
461
|
+
if (nodeType === 'layoutColumn') {
|
|
473
462
|
tr.setMeta('toggleLayoutColumnMenu', buildToggleLayoutColumnMenuMeta(startPos, false));
|
|
474
463
|
}
|
|
475
464
|
var resolvedStartPos = tr.doc.resolve(startPos);
|
|
@@ -539,7 +528,7 @@ export var DragHandle = function DragHandle(_ref2) {
|
|
|
539
528
|
api === null || api === void 0 || (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 || _api$blockControls3.commands.startPreservingSelection()({
|
|
540
529
|
tr: tr
|
|
541
530
|
});
|
|
542
|
-
if (nodeType === 'layoutColumn'
|
|
531
|
+
if (nodeType === 'layoutColumn') {
|
|
543
532
|
tr.setMeta('toggleLayoutColumnMenu', buildToggleLayoutColumnMenuMeta(startPos, true));
|
|
544
533
|
}
|
|
545
534
|
var triggerByNode = {
|
|
@@ -949,20 +938,6 @@ export var DragHandle = function DragHandle(_ref2) {
|
|
|
949
938
|
}
|
|
950
939
|
setDragHandleSelected(isHandleCorrelatedToSelection(view.state, selection, start));
|
|
951
940
|
}, [start, selection, view]);
|
|
952
|
-
useEffect(function () {
|
|
953
|
-
var _api$blockControls$sh3;
|
|
954
|
-
if (isShiftDown === undefined || view.state.selection.empty || !fg('platform_editor_elements_dnd_shift_click_select')) {
|
|
955
|
-
return;
|
|
956
|
-
}
|
|
957
|
-
var mSelect = api === null || api === void 0 || (_api$blockControls$sh3 = api.blockControls.sharedState.currentState()) === null || _api$blockControls$sh3 === void 0 ? void 0 : _api$blockControls$sh3.multiSelectDnD;
|
|
958
|
-
var $anchor = (mSelect === null || mSelect === void 0 ? void 0 : mSelect.anchor) !== undefined ? view.state.doc.resolve(mSelect === null || mSelect === void 0 ? void 0 : mSelect.anchor) : view.state.selection.$anchor;
|
|
959
|
-
var isLayoutColumnMenuEnabled = expValEquals('platform_editor_layout_column_menu', 'isEnabled', true);
|
|
960
|
-
if (isShiftDown && !(isLayoutColumnMenuEnabled && isLayoutColumn) && (!isTopLevelNodeValue || isTopLevelNodeValue && $anchor.depth > DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH)) {
|
|
961
|
-
setDragHandleDisabled(true);
|
|
962
|
-
} else {
|
|
963
|
-
setDragHandleDisabled(false);
|
|
964
|
-
}
|
|
965
|
-
}, [api === null || api === void 0 || (_api$blockControls7 = api.blockControls) === null || _api$blockControls7 === void 0 ? void 0 : _api$blockControls7.sharedState, isLayoutColumn, isShiftDown, isTopLevelNodeValue, view]);
|
|
966
941
|
var dragHandleMessage = formatMessage(blockControlsMessages.dragToMoveClickToOpen, {
|
|
967
942
|
br: jsx("br", null)
|
|
968
943
|
});
|
|
@@ -1064,7 +1039,6 @@ export var DragHandle = function DragHandle(_ref2) {
|
|
|
1064
1039
|
// eslint-disable-next-line @atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop
|
|
1065
1040
|
,
|
|
1066
1041
|
onDrop: handleOnDrop,
|
|
1067
|
-
disabled: dragHandleDisabled,
|
|
1068
1042
|
"data-editor-block-ctrl-drag-handle": true,
|
|
1069
1043
|
"data-blocks-drag-handle": fg('confluence_remix_button_right_side_block_fg') || undefined,
|
|
1070
1044
|
"data-testid": "block-ctrl-drag-handle",
|
|
@@ -1131,22 +1105,6 @@ export var DragHandle = function DragHandle(_ref2) {
|
|
|
1131
1105
|
css: [shouldMaskNodeControls(nodeType, isTopLevelNodeValue) && buttonWrapperStylesNoBackground, buttonWrapperStylesPatch]
|
|
1132
1106
|
}, renderButton()))));
|
|
1133
1107
|
};
|
|
1134
|
-
var stickyWithoutTooltip = function stickyWithoutTooltip() {
|
|
1135
|
-
return jsx(Box
|
|
1136
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
1137
|
-
, {
|
|
1138
|
-
style: positionStylesOld
|
|
1139
|
-
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
1140
|
-
,
|
|
1141
|
-
xcss: [dragHandleContainerStyles],
|
|
1142
|
-
as: "span",
|
|
1143
|
-
testId: "block-ctrl-drag-handle-container"
|
|
1144
|
-
}, jsx("span", {
|
|
1145
|
-
css: [tooltipContainerStyles, shouldMaskNodeControls(nodeType, isTopLevelNodeValue) && tooltipContainerStylesStickyHeaderWithMask, !shouldMaskNodeControls(nodeType, isTopLevelNodeValue) && tooltipContainerStylesStickyHeaderWithoutMask]
|
|
1146
|
-
}, jsx("span", {
|
|
1147
|
-
css: [shouldMaskNodeControls(nodeType, isTopLevelNodeValue) && buttonWrapperStylesNoBackground, buttonWrapperStylesPatch]
|
|
1148
|
-
}, renderButton())));
|
|
1149
|
-
};
|
|
1150
1108
|
var buttonWithTooltip = function buttonWithTooltip() {
|
|
1151
1109
|
return jsx(Tooltip, {
|
|
1152
1110
|
content: tooltipContent,
|
|
@@ -1161,13 +1119,10 @@ export var DragHandle = function DragHandle(_ref2) {
|
|
|
1161
1119
|
}
|
|
1162
1120
|
}, renderButton());
|
|
1163
1121
|
};
|
|
1164
|
-
var tooltipContent = isLayoutColumn &&
|
|
1122
|
+
var tooltipContent = isLayoutColumn && currentUserIntent === 'layoutColumnMenuPopupOpen' ? null : jsx(TooltipContentWithMultipleShortcuts, {
|
|
1165
1123
|
helpDescriptors: helpDescriptors
|
|
1166
1124
|
});
|
|
1167
|
-
|
|
1168
|
-
var stickyRender = isTooltip ? stickyWithTooltip() : stickyWithoutTooltip();
|
|
1169
|
-
var render = isTooltip ? buttonWithTooltip() : renderButton();
|
|
1170
|
-
return editorExperiment('platform_editor_controls', 'variant1') ? stickyRender : render;
|
|
1125
|
+
return editorExperiment('platform_editor_controls', 'variant1') ? stickyWithTooltip() : buttonWithTooltip();
|
|
1171
1126
|
};
|
|
1172
1127
|
export var DragHandleWithVisibility = function DragHandleWithVisibility(_ref0) {
|
|
1173
1128
|
var view = _ref0.view,
|
|
@@ -1180,9 +1135,9 @@ export var DragHandleWithVisibility = function DragHandleWithVisibility(_ref0) {
|
|
|
1180
1135
|
isTopLevelNode = _ref0.isTopLevelNode,
|
|
1181
1136
|
anchorRectCache = _ref0.anchorRectCache;
|
|
1182
1137
|
var rightSideControlsEnabled = useSharedPluginStateWithSelector(api, ['blockControls'], function (states) {
|
|
1183
|
-
var _states$
|
|
1138
|
+
var _states$blockControls, _states$blockControls2;
|
|
1184
1139
|
return {
|
|
1185
|
-
rightSideControlsEnabled: (_states$
|
|
1140
|
+
rightSideControlsEnabled: (_states$blockControls = (_states$blockControls2 = states.blockControlsState) === null || _states$blockControls2 === void 0 ? void 0 : _states$blockControls2.rightSideControlsEnabled) !== null && _states$blockControls !== void 0 ? _states$blockControls : false
|
|
1186
1141
|
};
|
|
1187
1142
|
}).rightSideControlsEnabled;
|
|
1188
1143
|
// Layout column drag handles sit at the top-centre of each column, not on a left/right edge.
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
// Nested icon for non-top-level nodes. Exception: with the
|
|
4
|
-
// kill switch OFF, layout columns use the full block handle instead.
|
|
5
|
-
// TODO: EDITOR-7732 - remove this whole function when
|
|
6
|
-
// `platform_editor_layout_column_menu_kill_switch_1` is cleaned up
|
|
1
|
+
// Nested layout columns use the full block handle; other non-top-level nodes use the nested icon.
|
|
7
2
|
export var shouldUseNestedDragHandleIcon = function shouldUseNestedDragHandleIcon(isTopLevelNode, isLayoutColumn) {
|
|
8
3
|
if (isTopLevelNode) {
|
|
9
4
|
return false;
|
|
10
5
|
}
|
|
11
|
-
if (isLayoutColumn
|
|
6
|
+
if (isLayoutColumn) {
|
|
12
7
|
return false;
|
|
13
8
|
}
|
|
14
9
|
return true;
|
|
@@ -74,7 +74,6 @@ export interface PluginState {
|
|
|
74
74
|
isPMDragging: boolean;
|
|
75
75
|
isResizerResizing: boolean;
|
|
76
76
|
isSelectedViaDragHandle?: boolean;
|
|
77
|
-
isShiftDown?: boolean;
|
|
78
77
|
lastDragCancelled: boolean;
|
|
79
78
|
menuTriggerBy?: string;
|
|
80
79
|
menuTriggerByNode?: TriggerByNode;
|
|
@@ -108,7 +107,6 @@ export type BlockControlsSharedState = {
|
|
|
108
107
|
isMouseOut?: boolean;
|
|
109
108
|
isPMDragging: boolean;
|
|
110
109
|
isSelectedViaDragHandle?: boolean;
|
|
111
|
-
isShiftDown?: boolean;
|
|
112
110
|
lastDragCancelled: boolean;
|
|
113
111
|
menuTriggerBy?: string;
|
|
114
112
|
menuTriggerByNode?: TriggerByNode;
|
|
@@ -32,7 +32,6 @@ export declare const apply: (api: ExtractInjectionAPI<BlockControlsPlugin> | und
|
|
|
32
32
|
isPMDragging: any;
|
|
33
33
|
isResizerResizing: boolean;
|
|
34
34
|
isSelectedViaDragHandle: any;
|
|
35
|
-
isShiftDown: any;
|
|
36
35
|
lastDragCancelled: any;
|
|
37
36
|
menuTriggerBy: any;
|
|
38
37
|
menuTriggerByNode: any;
|
|
@@ -57,7 +56,6 @@ export declare const createPlugin: (api: ExtractInjectionAPI<BlockControlsPlugin
|
|
|
57
56
|
isPMDragging: any;
|
|
58
57
|
isResizerResizing: boolean;
|
|
59
58
|
isSelectedViaDragHandle: any;
|
|
60
|
-
isShiftDown: any;
|
|
61
59
|
lastDragCancelled: any;
|
|
62
60
|
menuTriggerBy: any;
|
|
63
61
|
menuTriggerByNode: any;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { ResolvedPos } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
-
import {
|
|
4
|
-
import type { ReadonlyTransaction, Selection, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
+
import type { NodeSelection, ReadonlyTransaction, Selection, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
5
5
|
import type { CellSelection } from '@atlaskit/editor-tables';
|
|
6
6
|
import type { BlockControlsPlugin } from '../../blockControlsPluginType';
|
|
7
7
|
export declare const getMultiSelectionIfPosInside: (api: ExtractInjectionAPI<BlockControlsPlugin>, pos: number, tr?: Transaction) => {
|
|
@@ -21,18 +21,6 @@ export declare const getSelectedSlicePosition: (handlePos: number, tr: Transacti
|
|
|
21
21
|
from: number;
|
|
22
22
|
to: number;
|
|
23
23
|
};
|
|
24
|
-
/**
|
|
25
|
-
* Takes a position and expands the selection to encompass the node at that position. Ignores empty or out of range selections.
|
|
26
|
-
* Ignores positions that are in text blocks (i.e. not start of a node)
|
|
27
|
-
* @returns TextSelection if expanded, otherwise returns Selection that was passed in.
|
|
28
|
-
*/
|
|
29
|
-
export declare const expandSelectionHeadToNodeAtPos: (selection: Selection, nodePos: number) => Selection;
|
|
30
|
-
/**
|
|
31
|
-
* This swaps the anchor/head for NodeSelections when its anchor > pos.
|
|
32
|
-
* This is because NodeSelection always has an anchor at the start of the node,
|
|
33
|
-
* which may not align with the existing selection.
|
|
34
|
-
*/
|
|
35
|
-
export declare const alignAnchorHeadInDirectionOfPos: (selection: Selection, pos: number) => Selection;
|
|
36
24
|
/**
|
|
37
25
|
* This maps a preserved selection through a transaction, expanding text selections to block boundaries.
|
|
38
26
|
*
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
export declare const buildLayoutColumnMenuMeta: (anchorPos: number, openedViaKeyboard: boolean) => {
|
|
3
3
|
anchorPos: number;
|
|
4
|
-
isOpen?: true;
|
|
5
4
|
openedViaKeyboard: boolean;
|
|
6
5
|
};
|
|
7
6
|
export declare const getNodeSpacingForDragPreview: (node?: PMNode | null) => {
|
|
@@ -21,13 +21,6 @@ export declare const DRAG_HANDLE_LAYOUT_SECTION_TOP_ADJUSTMENT = 8;
|
|
|
21
21
|
export declare const DRAG_HANDLE_PARAGRAPH_TOP_ADJUSTMENT = 2;
|
|
22
22
|
export declare const DRAG_HANDLE_PARAGRAPH_SMALL_TOP_ADJUSTMENT = 0;
|
|
23
23
|
export declare const DRAG_HANDLE_WRAPPED_MEDIA_EMBED_TOP_ADJUSTMENT = 8;
|
|
24
|
-
/** We only want to shift-select nodes that are at the top level of a document.
|
|
25
|
-
* This is because funky things happen when selecting inside of tableCells, but we
|
|
26
|
-
* also want to avoid heavily nested cases to descope potential corner cases.
|
|
27
|
-
* Various top level nodes have their selection 'from' at depths other than 0,
|
|
28
|
-
* so we allow for some leniency to capture them all. e.g. Table is depth 3.
|
|
29
|
-
*/
|
|
30
|
-
export declare const DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH = 3;
|
|
31
24
|
export declare const STICKY_CONTROLS_TOP_MARGIN = 8;
|
|
32
25
|
export declare const STICKY_CONTROLS_TOP_MARGIN_FOR_STICKY_HEADER = 24;
|
|
33
26
|
export declare const QUICK_INSERT_HEIGHT = 24;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "23.0.
|
|
3
|
+
"version": "23.0.4",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@atlaskit/editor-tables": "^3.2.0",
|
|
52
52
|
"@atlaskit/editor-ui-control-model": "^2.10.0",
|
|
53
53
|
"@atlaskit/icon": "^38.0.0",
|
|
54
|
-
"@atlaskit/icon-lab": "^7.
|
|
54
|
+
"@atlaskit/icon-lab": "^7.11.0",
|
|
55
55
|
"@atlaskit/link": "^5.1.0",
|
|
56
56
|
"@atlaskit/platform-feature-experiments": "^0.3.0",
|
|
57
57
|
"@atlaskit/platform-feature-flags": "^2.2.0",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@atlaskit/primitives": "^22.5.0",
|
|
62
62
|
"@atlaskit/section-message": "^10.2.0",
|
|
63
63
|
"@atlaskit/theme": "^28.2.0",
|
|
64
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
64
|
+
"@atlaskit/tmp-editor-statsig": "^213.0.0",
|
|
65
65
|
"@atlaskit/tokens": "^20.1.0",
|
|
66
66
|
"@atlaskit/tooltip": "^24.3.0",
|
|
67
67
|
"@babel/runtime": "^7.0.0",
|
|
@@ -73,15 +73,12 @@
|
|
|
73
73
|
"uuid": "^11.1.1"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
|
-
"@atlaskit/editor-common": "^126.
|
|
76
|
+
"@atlaskit/editor-common": "^126.2.0",
|
|
77
77
|
"react": "^18.2.0 || ^19.2.0",
|
|
78
78
|
"react-dom": "^18.2.0 || ^19.2.0",
|
|
79
79
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|
|
80
80
|
},
|
|
81
81
|
"platform-feature-flags": {
|
|
82
|
-
"platform_editor_elements_dnd_shift_click_select": {
|
|
83
|
-
"type": "boolean"
|
|
84
|
-
},
|
|
85
82
|
"platform_editor_ease_of_use_metrics": {
|
|
86
83
|
"type": "boolean"
|
|
87
84
|
},
|
|
@@ -103,10 +100,6 @@
|
|
|
103
100
|
"platform_editor_controls_reliable_anchor_patch_1": {
|
|
104
101
|
"type": "boolean"
|
|
105
102
|
},
|
|
106
|
-
"platform_editor_layout_column_menu_kill_switch_1": {
|
|
107
|
-
"type": "boolean",
|
|
108
|
-
"referenceOnly": true
|
|
109
|
-
},
|
|
110
103
|
"platform-dst-top-layer-tooltip": {
|
|
111
104
|
"type": "boolean",
|
|
112
105
|
"referenceOnly": true
|