@atlaskit/editor-plugin-block-controls 3.9.2 → 3.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/dist/cjs/blockControlsPlugin.js +17 -7
- package/dist/cjs/pm-plugins/handle-mouse-down.js +6 -2
- package/dist/cjs/pm-plugins/main.js +27 -4
- package/dist/cjs/pm-plugins/utils/drag-handle-positions.js +8 -1
- package/dist/cjs/ui/consts.js +2 -1
- package/dist/cjs/ui/drag-handle.js +44 -15
- package/dist/cjs/ui/quick-insert-button.js +1 -1
- package/dist/es2019/blockControlsPlugin.js +12 -2
- package/dist/es2019/pm-plugins/handle-mouse-down.js +6 -2
- package/dist/es2019/pm-plugins/main.js +27 -4
- package/dist/es2019/pm-plugins/utils/drag-handle-positions.js +7 -0
- package/dist/es2019/ui/consts.js +1 -0
- package/dist/es2019/ui/drag-handle.js +46 -17
- package/dist/es2019/ui/quick-insert-button.js +1 -1
- package/dist/esm/blockControlsPlugin.js +17 -7
- package/dist/esm/pm-plugins/handle-mouse-down.js +6 -2
- package/dist/esm/pm-plugins/main.js +27 -4
- package/dist/esm/pm-plugins/utils/drag-handle-positions.js +7 -0
- package/dist/esm/ui/consts.js +1 -0
- package/dist/esm/ui/drag-handle.js +46 -17
- package/dist/esm/ui/quick-insert-button.js +1 -1
- package/dist/types/blockControlsPluginType.d.ts +3 -0
- package/dist/types/pm-plugins/main.d.ts +1 -0
- package/dist/types/pm-plugins/utils/drag-handle-positions.d.ts +1 -0
- package/dist/types/ui/consts.d.ts +1 -0
- package/dist/types-ts4.5/blockControlsPluginType.d.ts +3 -0
- package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/utils/drag-handle-positions.d.ts +1 -0
- package/dist/types-ts4.5/ui/consts.d.ts +1 -0
- package/package.json +7 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 3.10.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#140783](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/140783)
|
|
8
|
+
[`a2d4bdd4841c5`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a2d4bdd4841c5) -
|
|
9
|
+
[ux] Extend drag handle background with gradient to obscure adjacent node controls for contrast
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 3.10.0
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- [#139189](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/139189)
|
|
17
|
+
[`33e0a9b6291ae`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/33e0a9b6291ae) -
|
|
18
|
+
[ux] When table is selected via drag handle, we show Table floating controls toolbar. If the table
|
|
19
|
+
selected via other means, we show the Text Formatting toolbar.
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Updated dependencies
|
|
24
|
+
|
|
3
25
|
## 3.9.2
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
|
@@ -164,10 +164,19 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
|
|
|
164
164
|
}));
|
|
165
165
|
return tr;
|
|
166
166
|
};
|
|
167
|
+
},
|
|
168
|
+
setSelectedViaDragHandle: function setSelectedViaDragHandle(isSelectedViaDragHandle) {
|
|
169
|
+
return function (_ref7) {
|
|
170
|
+
var tr = _ref7.tr;
|
|
171
|
+
var currMeta = tr.getMeta(_main.key);
|
|
172
|
+
return tr.setMeta(_main.key, _objectSpread(_objectSpread({}, currMeta), {}, {
|
|
173
|
+
isSelectedViaDragHandle: isSelectedViaDragHandle
|
|
174
|
+
}));
|
|
175
|
+
};
|
|
167
176
|
}
|
|
168
177
|
},
|
|
169
178
|
getSharedState: function getSharedState(editorState) {
|
|
170
|
-
var _key$getState$isMenuO, _key$getState, _key$getState$menuTri, _key$getState2, _key$getState$activeN, _key$getState3, _key$getState$isDragg, _key$getState4, _key$getState$isPMDra, _key$getState5, _key$getState$multiSe, _key$getState6, _key$getState$isShift, _key$getState7, _key$getState$lastDra, _key$getState8, _interactionTrackingP;
|
|
179
|
+
var _key$getState$isMenuO, _key$getState, _key$getState$menuTri, _key$getState2, _key$getState$activeN, _key$getState3, _key$getState$isDragg, _key$getState4, _key$getState$isPMDra, _key$getState5, _key$getState$multiSe, _key$getState6, _key$getState$isShift, _key$getState7, _key$getState$lastDra, _key$getState8, _interactionTrackingP, _key$getState$isSelec, _key$getState9;
|
|
171
180
|
if (!editorState) {
|
|
172
181
|
return undefined;
|
|
173
182
|
}
|
|
@@ -180,14 +189,15 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
|
|
|
180
189
|
multiSelectDnD: (_key$getState$multiSe = (_key$getState6 = _main.key.getState(editorState)) === null || _key$getState6 === void 0 ? void 0 : _key$getState6.multiSelectDnD) !== null && _key$getState$multiSe !== void 0 ? _key$getState$multiSe : undefined,
|
|
181
190
|
isShiftDown: (_key$getState$isShift = (_key$getState7 = _main.key.getState(editorState)) === null || _key$getState7 === void 0 ? void 0 : _key$getState7.isShiftDown) !== null && _key$getState$isShift !== void 0 ? _key$getState$isShift : undefined,
|
|
182
191
|
lastDragCancelled: (_key$getState$lastDra = (_key$getState8 = _main.key.getState(editorState)) === null || _key$getState8 === void 0 ? void 0 : _key$getState8.lastDragCancelled) !== null && _key$getState$lastDra !== void 0 ? _key$getState$lastDra : false,
|
|
183
|
-
isEditing: (_interactionTrackingP = _pmPlugin.interactionTrackingPluginKey.getState(editorState)) === null || _interactionTrackingP === void 0 ? void 0 : _interactionTrackingP.isEditing
|
|
192
|
+
isEditing: (_interactionTrackingP = _pmPlugin.interactionTrackingPluginKey.getState(editorState)) === null || _interactionTrackingP === void 0 ? void 0 : _interactionTrackingP.isEditing,
|
|
193
|
+
isSelectedViaDragHandle: (_key$getState$isSelec = (_key$getState9 = _main.key.getState(editorState)) === null || _key$getState9 === void 0 ? void 0 : _key$getState9.isSelectedViaDragHandle) !== null && _key$getState$isSelec !== void 0 ? _key$getState$isSelec : false
|
|
184
194
|
};
|
|
185
195
|
},
|
|
186
|
-
contentComponent: function contentComponent(
|
|
187
|
-
var editorView =
|
|
188
|
-
popupsMountPoint =
|
|
189
|
-
popupsBoundariesElement =
|
|
190
|
-
popupsScrollableElement =
|
|
196
|
+
contentComponent: function contentComponent(_ref8) {
|
|
197
|
+
var editorView = _ref8.editorView,
|
|
198
|
+
popupsMountPoint = _ref8.popupsMountPoint,
|
|
199
|
+
popupsBoundariesElement = _ref8.popupsBoundariesElement,
|
|
200
|
+
popupsScrollableElement = _ref8.popupsScrollableElement;
|
|
191
201
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? /*#__PURE__*/_react.default.createElement(_blockMenu.default, {
|
|
192
202
|
editorView: editorView,
|
|
193
203
|
mountPoint: popupsMountPoint,
|
|
@@ -4,12 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.handleMouseDown = void 0;
|
|
7
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
7
8
|
var handleMouseDown = exports.handleMouseDown = function handleMouseDown(api) {
|
|
8
9
|
return function (view, event) {
|
|
9
|
-
if (
|
|
10
|
+
if (!(event.target instanceof HTMLElement)) {
|
|
10
11
|
return false;
|
|
11
12
|
}
|
|
12
|
-
if (
|
|
13
|
+
if (!view.editable) {
|
|
13
14
|
var _rootNode$type$name, _rootNode$type$name2;
|
|
14
15
|
var targetPos = view.posAtDOM(event.target, 0);
|
|
15
16
|
// always fetch top level position for mouseDown to avoid drag handle positions being incorrect
|
|
@@ -19,6 +20,9 @@ var handleMouseDown = exports.handleMouseDown = function handleMouseDown(api) {
|
|
|
19
20
|
return false;
|
|
20
21
|
}
|
|
21
22
|
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.showDragHandleAt(rootPos, '', (_rootNode$type$name = rootNode.type.name) !== null && _rootNode$type$name !== void 0 ? _rootNode$type$name : '', undefined, rootPos, '', (_rootNode$type$name2 = rootNode.type.name) !== null && _rootNode$type$name2 !== void 0 ? _rootNode$type$name2 : ''));
|
|
23
|
+
} else if ((0, _platformFeatureFlags.fg)('platform_editor_controls_patch_5')) {
|
|
24
|
+
var isDragHandle = event.target.closest('[data-editor-block-ctrl-drag-handle]') !== null;
|
|
25
|
+
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(isDragHandle));
|
|
22
26
|
}
|
|
23
27
|
return false;
|
|
24
28
|
};
|
|
@@ -166,7 +166,8 @@ var initialState = {
|
|
|
166
166
|
isDocSizeLimitEnabled: null,
|
|
167
167
|
isPMDragging: false,
|
|
168
168
|
multiSelectDnD: undefined,
|
|
169
|
-
lastDragCancelled: false
|
|
169
|
+
lastDragCancelled: false,
|
|
170
|
+
isSelectedViaDragHandle: false
|
|
170
171
|
};
|
|
171
172
|
var getDecorations = exports.getDecorations = function getDecorations(state) {
|
|
172
173
|
var _key$getState;
|
|
@@ -199,7 +200,8 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
|
|
|
199
200
|
menuTriggerBy = currentState.menuTriggerBy,
|
|
200
201
|
isPMDragging = currentState.isPMDragging,
|
|
201
202
|
isShiftDown = currentState.isShiftDown,
|
|
202
|
-
lastDragCancelled = currentState.lastDragCancelled
|
|
203
|
+
lastDragCancelled = currentState.lastDragCancelled,
|
|
204
|
+
isSelectedViaDragHandle = currentState.isSelectedViaDragHandle;
|
|
203
205
|
var isActiveNodeDeleted = false;
|
|
204
206
|
var _getTrMetadata = (0, _transactions.getTrMetadata)(tr),
|
|
205
207
|
from = _getTrMetadata.from,
|
|
@@ -409,6 +411,7 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
|
|
|
409
411
|
} else if (meta !== null && meta !== void 0 && meta.toggleMenu) {
|
|
410
412
|
isMenuOpenNew = !isMenuOpen;
|
|
411
413
|
}
|
|
414
|
+
var isSelectedViaDragHandleNew = (meta === null || meta === void 0 ? void 0 : meta.isSelectedViaDragHandle) !== undefined && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_5') ? meta === null || meta === void 0 ? void 0 : meta.isSelectedViaDragHandle : isSelectedViaDragHandle;
|
|
412
415
|
return {
|
|
413
416
|
decorations: decorations,
|
|
414
417
|
activeNode: newActiveNode,
|
|
@@ -423,7 +426,8 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
|
|
|
423
426
|
isPMDragging: (_meta$isPMDragging = meta === null || meta === void 0 ? void 0 : meta.isPMDragging) !== null && _meta$isPMDragging !== void 0 ? _meta$isPMDragging : isPMDragging,
|
|
424
427
|
multiSelectDnD: multiSelectDnD,
|
|
425
428
|
isShiftDown: (_meta$isShiftDown = meta === null || meta === void 0 ? void 0 : meta.isShiftDown) !== null && _meta$isShiftDown !== void 0 ? _meta$isShiftDown : isShiftDown,
|
|
426
|
-
lastDragCancelled: (_meta$lastDragCancell = meta === null || meta === void 0 ? void 0 : meta.lastDragCancelled) !== null && _meta$lastDragCancell !== void 0 ? _meta$lastDragCancell : lastDragCancelled
|
|
429
|
+
lastDragCancelled: (_meta$lastDragCancell = meta === null || meta === void 0 ? void 0 : meta.lastDragCancelled) !== null && _meta$lastDragCancell !== void 0 ? _meta$lastDragCancell : lastDragCancelled,
|
|
430
|
+
isSelectedViaDragHandle: isSelectedViaDragHandleNew
|
|
427
431
|
};
|
|
428
432
|
};
|
|
429
433
|
var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, nodeViewPortalProviderAPI) {
|
|
@@ -580,6 +584,16 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
|
|
|
580
584
|
return true;
|
|
581
585
|
}
|
|
582
586
|
}
|
|
587
|
+
if ((event.key === 'Enter' || event.key === ' ') && event.target instanceof HTMLElement && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_5')) {
|
|
588
|
+
var isDragHandle = event.target.closest('[data-editor-block-ctrl-drag-handle="true"]') !== null;
|
|
589
|
+
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(isDragHandle));
|
|
590
|
+
}
|
|
591
|
+
if ((event.key === 'ArrowLeft' || event.key === 'ArrowRight' || event.key === 'ArrowDown' || event.key === 'ArrowUp') && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_5')) {
|
|
592
|
+
var _api$blockControls$sh;
|
|
593
|
+
if (api !== null && api !== void 0 && (_api$blockControls$sh = api.blockControls.sharedState.currentState()) !== null && _api$blockControls$sh !== void 0 && _api$blockControls$sh.isSelectedViaDragHandle) {
|
|
594
|
+
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(false));
|
|
595
|
+
}
|
|
596
|
+
}
|
|
583
597
|
if (!event.repeat && event.shiftKey && (0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_shift_click_select')) {
|
|
584
598
|
view.dispatch(view.state.tr.setMeta(key, _objectSpread(_objectSpread({}, view.state.tr.getMeta(key)), {}, {
|
|
585
599
|
isShiftDown: true
|
|
@@ -607,8 +621,17 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
|
|
|
607
621
|
return true;
|
|
608
622
|
}
|
|
609
623
|
}
|
|
624
|
+
if ((event.key === 'Enter' || event.key === ' ') && event.target instanceof HTMLElement && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_5')) {
|
|
625
|
+
var _isDragHandle = event.target.closest('[data-editor-block-ctrl-drag-handle="true"]') !== null;
|
|
626
|
+
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(_isDragHandle));
|
|
627
|
+
}
|
|
628
|
+
if ((event.key === 'ArrowLeft' || event.key === 'ArrowRight' || event.key === 'ArrowDown' || event.key === 'ArrowUp') && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_5')) {
|
|
629
|
+
var _api$blockControls$sh2;
|
|
630
|
+
if (api !== null && api !== void 0 && (_api$blockControls$sh2 = api.blockControls.sharedState.currentState()) !== null && _api$blockControls$sh2 !== void 0 && _api$blockControls$sh2.isSelectedViaDragHandle) {
|
|
631
|
+
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(false));
|
|
632
|
+
}
|
|
633
|
+
}
|
|
610
634
|
}
|
|
611
|
-
return false;
|
|
612
635
|
},
|
|
613
636
|
keyup: function keyup(view, event) {
|
|
614
637
|
if (!event.repeat && event.key === 'Shift') {
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.shouldBeSticky = exports.getTopPosition = exports.getNodeHeight = exports.getLeftPosition = exports.getControlHeightCSSValue = exports.getControlBottomCSSValue = void 0;
|
|
6
|
+
exports.shouldMaskNodeControls = exports.shouldBeSticky = exports.getTopPosition = exports.getNodeHeight = exports.getLeftPosition = exports.getControlHeightCSSValue = exports.getControlBottomCSSValue = void 0;
|
|
7
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
7
8
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
8
9
|
var _consts = require("../../ui/consts");
|
|
9
10
|
var STICKY_NODES = ['panel', 'table', 'expand', 'layoutSection', 'bodiedExtension'];
|
|
@@ -72,4 +73,10 @@ var getControlHeightCSSValue = exports.getControlHeightCSSValue = function getCo
|
|
|
72
73
|
} : {
|
|
73
74
|
height: "".concat(nodeHeight || fallbackPxHeight, "px")
|
|
74
75
|
};
|
|
76
|
+
};
|
|
77
|
+
var shouldMaskNodeControls = exports.shouldMaskNodeControls = function shouldMaskNodeControls(nodeType, isTopLevelNode) {
|
|
78
|
+
return (
|
|
79
|
+
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
80
|
+
isTopLevelNode && ['table'].includes(nodeType) && (0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')
|
|
81
|
+
);
|
|
75
82
|
};
|
package/dist/cjs/ui/consts.js
CHANGED
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.topPositionAdjustment = exports.spacingBetweenNodesForPreview = exports.spaceLookupMap = exports.rootElementGap = exports.nodeMargins = exports.getNestedNodeLeftPaddingMargin = exports.dropTargetMarginMap = exports.dragHandleGap = exports.QUICK_INSERT_WIDTH = exports.QUICK_INSERT_LEFT_OFFSET = exports.QUICK_INSERT_HEIGHT = exports.QUICK_INSERT_DIMENSIONS = exports.DRAG_HANDLE_ZINDEX = exports.DRAG_HANDLE_WIDTH = exports.DRAG_HANDLE_PARAGRAPH_TOP_ADJUSTMENT = exports.DRAG_HANDLE_NARROW_GAP = exports.DRAG_HANDLE_MAX_WIDTH_PLUS_GAP = exports.DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH = exports.DRAG_HANDLE_MAX_GAP = exports.DRAG_HANDLE_LAYOUT_SECTION_TOP_ADJUSTMENT = exports.DRAG_HANDLE_HEIGHT = exports.DRAG_HANDLE_H6_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H5_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H4_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H3_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H2_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H1_TOP_ADJUSTMENT = exports.DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT = exports.DRAG_HANDLE_DEFAULT_GAP = exports.DRAG_HANDLE_BORDER_RADIUS = exports.DEFAULT_COLUMN_DISTRIBUTIONS = exports.BLOCK_MENU_WIDTH = exports.BLOCK_MENU_ENABLED = void 0;
|
|
7
|
+
exports.topPositionAdjustment = exports.spacingBetweenNodesForPreview = exports.spaceLookupMap = exports.rootElementGap = exports.nodeMargins = exports.getNestedNodeLeftPaddingMargin = exports.dropTargetMarginMap = exports.dragHandleGap = exports.STICKY_CONTROLS_TOP_MARGIN = exports.QUICK_INSERT_WIDTH = exports.QUICK_INSERT_LEFT_OFFSET = exports.QUICK_INSERT_HEIGHT = exports.QUICK_INSERT_DIMENSIONS = exports.DRAG_HANDLE_ZINDEX = exports.DRAG_HANDLE_WIDTH = exports.DRAG_HANDLE_PARAGRAPH_TOP_ADJUSTMENT = exports.DRAG_HANDLE_NARROW_GAP = exports.DRAG_HANDLE_MAX_WIDTH_PLUS_GAP = exports.DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH = exports.DRAG_HANDLE_MAX_GAP = exports.DRAG_HANDLE_LAYOUT_SECTION_TOP_ADJUSTMENT = exports.DRAG_HANDLE_HEIGHT = exports.DRAG_HANDLE_H6_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H5_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H4_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H3_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H2_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H1_TOP_ADJUSTMENT = exports.DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT = exports.DRAG_HANDLE_DEFAULT_GAP = exports.DRAG_HANDLE_BORDER_RADIUS = exports.DEFAULT_COLUMN_DISTRIBUTIONS = exports.BLOCK_MENU_WIDTH = exports.BLOCK_MENU_ENABLED = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
10
10
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
@@ -34,6 +34,7 @@ var DRAG_HANDLE_PARAGRAPH_TOP_ADJUSTMENT = exports.DRAG_HANDLE_PARAGRAPH_TOP_ADJ
|
|
|
34
34
|
* so we allow for some leniency to capture them all. e.g. Table is depth 3.
|
|
35
35
|
*/
|
|
36
36
|
var DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH = exports.DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH = 3;
|
|
37
|
+
var STICKY_CONTROLS_TOP_MARGIN = exports.STICKY_CONTROLS_TOP_MARGIN = 8;
|
|
37
38
|
var QUICK_INSERT_HEIGHT = exports.QUICK_INSERT_HEIGHT = 24;
|
|
38
39
|
var QUICK_INSERT_WIDTH = exports.QUICK_INSERT_WIDTH = 24;
|
|
39
40
|
var QUICK_INSERT_DIMENSIONS = exports.QUICK_INSERT_DIMENSIONS = {
|
|
@@ -47,6 +47,19 @@ var iconWrapperStyles = (0, _primitives.xcss)({
|
|
|
47
47
|
justifyContent: 'center',
|
|
48
48
|
alignItems: 'center'
|
|
49
49
|
});
|
|
50
|
+
var extendedIconWrapperStyles = (0, _react2.css)({
|
|
51
|
+
display: 'flex',
|
|
52
|
+
justifyContent: 'center',
|
|
53
|
+
alignItems: 'center',
|
|
54
|
+
background: "var(--ds-surface, #FFFFFF)",
|
|
55
|
+
marginBottom: "var(--ds-space-negative-100, -8px)",
|
|
56
|
+
paddingBottom: "var(--ds-space-100, 8px)",
|
|
57
|
+
marginTop: "var(--ds-space-negative-100, -8px)",
|
|
58
|
+
paddingTop: "var(--ds-space-100, 8px)",
|
|
59
|
+
marginRight: "var(--ds-space-negative-100, -8px)",
|
|
60
|
+
paddingRight: "var(--ds-space-100, 8px)",
|
|
61
|
+
borderRadius: '6px'
|
|
62
|
+
});
|
|
50
63
|
|
|
51
64
|
// update color to match quick insert button for new editor controls
|
|
52
65
|
var dragHandleColor = (0, _react2.css)({
|
|
@@ -136,16 +149,25 @@ var dragHandleContainerStyles = (0, _primitives.xcss)({
|
|
|
136
149
|
boxSizing: 'border-box'
|
|
137
150
|
});
|
|
138
151
|
var tooltipContainerStyles = (0, _react2.css)({
|
|
139
|
-
|
|
140
|
-
|
|
152
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
153
|
+
top: "".concat(_consts.STICKY_CONTROLS_TOP_MARGIN, "px"),
|
|
154
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
155
|
+
bottom: "-".concat(_consts.STICKY_CONTROLS_TOP_MARGIN, "px"),
|
|
156
|
+
position: 'sticky',
|
|
157
|
+
zIndex: 100 // card = 100
|
|
158
|
+
});
|
|
159
|
+
var tooltipContainerStylesWithNodeControls = (0, _react2.css)({
|
|
160
|
+
top: '0',
|
|
161
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
162
|
+
bottom: "-".concat(_consts.STICKY_CONTROLS_TOP_MARGIN, "px"),
|
|
141
163
|
position: 'sticky',
|
|
142
|
-
zIndex:
|
|
164
|
+
zIndex: 100 // card = 100
|
|
143
165
|
});
|
|
144
166
|
var tooltipContainerStylesStickyHeader = (0, _react2.css)({
|
|
145
167
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
146
168
|
'[data-blocks-drag-handle-container]:has(+ [data-prosemirror-node-name="table"] .pm-table-with-controls tr.sticky) &': {
|
|
147
169
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
148
|
-
top: _styles.tableControlsSpacing
|
|
170
|
+
top: _styles.tableControlsSpacing - _consts.STICKY_CONTROLS_TOP_MARGIN
|
|
149
171
|
}
|
|
150
172
|
});
|
|
151
173
|
|
|
@@ -154,7 +176,7 @@ var tooltipContainerStylesStickyHeaderWithMarksFix = (0, _react2.css)({
|
|
|
154
176
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
155
177
|
'[data-prosemirror-mark-name="breakout"]:has([data-blocks-drag-handle-container]):has(+ [data-prosemirror-node-name="table"] .pm-table-with-controls tr.sticky) &': {
|
|
156
178
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
157
|
-
top: _styles.tableControlsSpacing
|
|
179
|
+
top: _styles.tableControlsSpacing - _consts.STICKY_CONTROLS_TOP_MARGIN
|
|
158
180
|
}
|
|
159
181
|
});
|
|
160
182
|
var dragHandleMultiLineSelectionFixFirefox = (0, _react2.css)({
|
|
@@ -564,13 +586,13 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
564
586
|
var isEdgeCase = (hasResizer || isExtension || isEmbedCard || isBlockCard) && innerContainer;
|
|
565
587
|
var isSticky = (0, _dragHandlePositions.shouldBeSticky)(nodeType);
|
|
566
588
|
if (supportsAnchor) {
|
|
567
|
-
var bottom = (0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') ? (0, _dragHandlePositions.getControlBottomCSSValue)(safeAnchorName, isSticky, isTopLevelNode, isLayoutColumn) : {};
|
|
589
|
+
var bottom = (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') ? (0, _dragHandlePositions.getControlBottomCSSValue)(safeAnchorName, isSticky, isTopLevelNode, isLayoutColumn) : {};
|
|
568
590
|
return _objectSpread({
|
|
569
591
|
left: isEdgeCase ? "calc(anchor(".concat(safeAnchorName, " start) + ").concat((0, _dragHandlePositions.getLeftPosition)(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType), ")") : (0, _experiments.editorExperiment)('advanced_layouts', true) && isLayoutColumn ? "calc((anchor(".concat(safeAnchorName, " right) + anchor(").concat(safeAnchorName, " left))/2 - ").concat(_consts.DRAG_HANDLE_HEIGHT / 2, "px)") : "calc(anchor(".concat(safeAnchorName, " start) - ").concat(_consts.DRAG_HANDLE_WIDTH, "px - ").concat((0, _consts.dragHandleGap)(nodeType, parentNodeType), "px)"),
|
|
570
592
|
top: (0, _experiments.editorExperiment)('advanced_layouts', true) && isLayoutColumn ? "calc(anchor(".concat(safeAnchorName, " top) - ").concat(_consts.DRAG_HANDLE_WIDTH, "px)") : "calc(anchor(".concat(safeAnchorName, " start) + ").concat((0, _consts.topPositionAdjustment)(nodeType), "px)")
|
|
571
593
|
}, bottom);
|
|
572
594
|
}
|
|
573
|
-
var height = (0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') ? (0, _dragHandlePositions.getControlHeightCSSValue)((0, _dragHandlePositions.getNodeHeight)(dom, safeAnchorName, anchorRectCache) || 0, isSticky, isTopLevelNode, "".concat(_consts.DRAG_HANDLE_HEIGHT), isLayoutColumn) : {};
|
|
595
|
+
var height = (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') ? (0, _dragHandlePositions.getControlHeightCSSValue)((0, _dragHandlePositions.getNodeHeight)(dom, safeAnchorName, anchorRectCache) || 0, isSticky, isTopLevelNode, "".concat(_consts.DRAG_HANDLE_HEIGHT), isLayoutColumn) : {};
|
|
574
596
|
return _objectSpread({
|
|
575
597
|
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),
|
|
576
598
|
top: (0, _dragHandlePositions.getTopPosition)(dom, nodeType)
|
|
@@ -712,14 +734,14 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
712
734
|
// eslint-disable-next-line @atlaskit/design-system/no-html-button
|
|
713
735
|
(0, _react2.jsx)("button", {
|
|
714
736
|
type: "button",
|
|
715
|
-
css: [(0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') ? dragHandleButtonStyles : dragHandleButtonStylesOld, (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && dragHandleColor,
|
|
737
|
+
css: [(0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') ? dragHandleButtonStyles : dragHandleButtonStylesOld, (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && dragHandleColor,
|
|
716
738
|
// ED-26266: Fixed the drag handle highlight when selecting multiple line in Firefox
|
|
717
739
|
// See https://product-fabric.atlassian.net/browse/ED-26266
|
|
718
740
|
_browser.browser.gecko && (0, _platformFeatureFlags.fg)('platform_editor_dnd_handle_highlight_fix_firefox') && dragHandleMultiLineSelectionFixFirefox, (0, _experiments.editorExperiment)('advanced_layouts', true) && isLayoutColumn && layoutColumnDragHandleStyles, dragHandleSelected && selectedStyles],
|
|
719
741
|
ref: buttonRef
|
|
720
742
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
721
743
|
,
|
|
722
|
-
style: !(0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') && positionStyles || {},
|
|
744
|
+
style: !((0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls')) && positionStyles || {},
|
|
723
745
|
onClick: handleOnClick,
|
|
724
746
|
onMouseDown: handleMouseDown,
|
|
725
747
|
onKeyDown: handleKeyDown
|
|
@@ -730,7 +752,6 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
730
752
|
"data-editor-block-ctrl-drag-handle": true,
|
|
731
753
|
"data-testid": "block-ctrl-drag-handle"
|
|
732
754
|
}, (0, _react2.jsx)(_primitives.Box, {
|
|
733
|
-
as: "span",
|
|
734
755
|
xcss: iconWrapperStyles
|
|
735
756
|
// eslint-disable-next-line @atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop
|
|
736
757
|
,
|
|
@@ -752,7 +773,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
752
773
|
as: "span",
|
|
753
774
|
testId: "block-ctrl-drag-handle-container"
|
|
754
775
|
}, (0, _react2.jsx)("span", {
|
|
755
|
-
css: [tooltipContainerStyles, (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_4') && tooltipContainerStylesStickyHeader, (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_4') && tooltipContainerStylesStickyHeaderWithMarksFix]
|
|
776
|
+
css: [(0, _dragHandlePositions.shouldMaskNodeControls)(nodeType, isTopLevelNode) ? tooltipContainerStylesWithNodeControls : tooltipContainerStyles, (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_4') && tooltipContainerStylesStickyHeader, (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_4') && tooltipContainerStylesStickyHeaderWithMarksFix]
|
|
756
777
|
}, (0, _react2.jsx)(_tooltip.default, {
|
|
757
778
|
content: (0, _react2.jsx)(_keymaps.TooltipContentWithMultipleShortcuts, {
|
|
758
779
|
helpDescriptors: helpDescriptors
|
|
@@ -765,7 +786,11 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
765
786
|
priority: 'important'
|
|
766
787
|
});
|
|
767
788
|
}
|
|
768
|
-
},
|
|
789
|
+
}, (0, _react2.jsx)("span", {
|
|
790
|
+
css:
|
|
791
|
+
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
792
|
+
(0, _dragHandlePositions.shouldMaskNodeControls)(nodeType, isTopLevelNode) && extendedIconWrapperStyles
|
|
793
|
+
}, renderButton()))));
|
|
769
794
|
};
|
|
770
795
|
var stickyWithoutTooltip = function stickyWithoutTooltip() {
|
|
771
796
|
return (0, _react2.jsx)(_primitives.Box
|
|
@@ -776,8 +801,12 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
776
801
|
as: "span",
|
|
777
802
|
testId: "block-ctrl-drag-handle-container"
|
|
778
803
|
}, (0, _react2.jsx)("span", {
|
|
779
|
-
css: [tooltipContainerStyles, (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_4') && tooltipContainerStylesStickyHeader, (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_4') && tooltipContainerStylesStickyHeaderWithMarksFix]
|
|
780
|
-
},
|
|
804
|
+
css: [(0, _dragHandlePositions.shouldMaskNodeControls)(nodeType, isTopLevelNode) ? tooltipContainerStylesWithNodeControls : tooltipContainerStyles, (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_4') && tooltipContainerStylesStickyHeader, (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_4') && tooltipContainerStylesStickyHeaderWithMarksFix]
|
|
805
|
+
}, (0, _react2.jsx)("span", {
|
|
806
|
+
css:
|
|
807
|
+
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
808
|
+
(0, _dragHandlePositions.shouldMaskNodeControls)(nodeType, isTopLevelNode) && extendedIconWrapperStyles
|
|
809
|
+
}, renderButton())));
|
|
781
810
|
};
|
|
782
811
|
var buttonWithTooltip = function buttonWithTooltip() {
|
|
783
812
|
return (0, _react2.jsx)(_tooltip.default, {
|
|
@@ -796,7 +825,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
796
825
|
var isTooltip = !dragHandleDisabled && (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_23873');
|
|
797
826
|
var stickyRender = isTooltip ? stickyWithTooltip() : stickyWithoutTooltip();
|
|
798
827
|
var render = isTooltip ? buttonWithTooltip() : renderButton();
|
|
799
|
-
return (0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') ? stickyRender : render;
|
|
828
|
+
return (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') ? stickyRender : render;
|
|
800
829
|
};
|
|
801
830
|
var DragHandleWithVisibility = exports.DragHandleWithVisibility = function DragHandleWithVisibility(_ref8) {
|
|
802
831
|
var view = _ref8.view,
|
|
@@ -309,7 +309,7 @@ var TypeAheadControl = exports.TypeAheadControl = function TypeAheadControl(_ref
|
|
|
309
309
|
testId: "editor-quick-insert-button",
|
|
310
310
|
type: "button",
|
|
311
311
|
"aria-label": formatMessage(_messages.blockControlsMessages.insert),
|
|
312
|
-
xcss: [(0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') ?
|
|
312
|
+
xcss: [(0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') ? stickyButtonStyles : buttonStyles, isTypeAheadOpen && !(0, _platformFeatureFlags.fg)('platform_editor_controls_widget_visibility') ? disabledStyles : undefined],
|
|
313
313
|
onClick: handleQuickInsert,
|
|
314
314
|
onMouseDown: handleMouseDown,
|
|
315
315
|
isDisabled: !(0, _platformFeatureFlags.fg)('platform_editor_controls_widget_visibility') && isTypeAheadOpen
|
|
@@ -155,10 +155,19 @@ export const blockControlsPlugin = ({
|
|
|
155
155
|
multiSelectDnD
|
|
156
156
|
});
|
|
157
157
|
return tr;
|
|
158
|
+
},
|
|
159
|
+
setSelectedViaDragHandle: isSelectedViaDragHandle => ({
|
|
160
|
+
tr
|
|
161
|
+
}) => {
|
|
162
|
+
const currMeta = tr.getMeta(key);
|
|
163
|
+
return tr.setMeta(key, {
|
|
164
|
+
...currMeta,
|
|
165
|
+
isSelectedViaDragHandle
|
|
166
|
+
});
|
|
158
167
|
}
|
|
159
168
|
},
|
|
160
169
|
getSharedState(editorState) {
|
|
161
|
-
var _key$getState$isMenuO, _key$getState, _key$getState$menuTri, _key$getState2, _key$getState$activeN, _key$getState3, _key$getState$isDragg, _key$getState4, _key$getState$isPMDra, _key$getState5, _key$getState$multiSe, _key$getState6, _key$getState$isShift, _key$getState7, _key$getState$lastDra, _key$getState8, _interactionTrackingP;
|
|
170
|
+
var _key$getState$isMenuO, _key$getState, _key$getState$menuTri, _key$getState2, _key$getState$activeN, _key$getState3, _key$getState$isDragg, _key$getState4, _key$getState$isPMDra, _key$getState5, _key$getState$multiSe, _key$getState6, _key$getState$isShift, _key$getState7, _key$getState$lastDra, _key$getState8, _interactionTrackingP, _key$getState$isSelec, _key$getState9;
|
|
162
171
|
if (!editorState) {
|
|
163
172
|
return undefined;
|
|
164
173
|
}
|
|
@@ -171,7 +180,8 @@ export const blockControlsPlugin = ({
|
|
|
171
180
|
multiSelectDnD: (_key$getState$multiSe = (_key$getState6 = key.getState(editorState)) === null || _key$getState6 === void 0 ? void 0 : _key$getState6.multiSelectDnD) !== null && _key$getState$multiSe !== void 0 ? _key$getState$multiSe : undefined,
|
|
172
181
|
isShiftDown: (_key$getState$isShift = (_key$getState7 = key.getState(editorState)) === null || _key$getState7 === void 0 ? void 0 : _key$getState7.isShiftDown) !== null && _key$getState$isShift !== void 0 ? _key$getState$isShift : undefined,
|
|
173
182
|
lastDragCancelled: (_key$getState$lastDra = (_key$getState8 = key.getState(editorState)) === null || _key$getState8 === void 0 ? void 0 : _key$getState8.lastDragCancelled) !== null && _key$getState$lastDra !== void 0 ? _key$getState$lastDra : false,
|
|
174
|
-
isEditing: (_interactionTrackingP = interactionTrackingPluginKey.getState(editorState)) === null || _interactionTrackingP === void 0 ? void 0 : _interactionTrackingP.isEditing
|
|
183
|
+
isEditing: (_interactionTrackingP = interactionTrackingPluginKey.getState(editorState)) === null || _interactionTrackingP === void 0 ? void 0 : _interactionTrackingP.isEditing,
|
|
184
|
+
isSelectedViaDragHandle: (_key$getState$isSelec = (_key$getState9 = key.getState(editorState)) === null || _key$getState9 === void 0 ? void 0 : _key$getState9.isSelectedViaDragHandle) !== null && _key$getState$isSelec !== void 0 ? _key$getState$isSelec : false
|
|
175
185
|
};
|
|
176
186
|
},
|
|
177
187
|
contentComponent({
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
1
2
|
export const handleMouseDown = api => (view, event) => {
|
|
2
|
-
if (
|
|
3
|
+
if (!(event.target instanceof HTMLElement)) {
|
|
3
4
|
return false;
|
|
4
5
|
}
|
|
5
|
-
if (
|
|
6
|
+
if (!view.editable) {
|
|
6
7
|
var _rootNode$type$name, _rootNode$type$name2;
|
|
7
8
|
const targetPos = view.posAtDOM(event.target, 0);
|
|
8
9
|
// always fetch top level position for mouseDown to avoid drag handle positions being incorrect
|
|
@@ -12,6 +13,9 @@ export const handleMouseDown = api => (view, event) => {
|
|
|
12
13
|
return false;
|
|
13
14
|
}
|
|
14
15
|
api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.showDragHandleAt(rootPos, '', (_rootNode$type$name = rootNode.type.name) !== null && _rootNode$type$name !== void 0 ? _rootNode$type$name : '', undefined, rootPos, '', (_rootNode$type$name2 = rootNode.type.name) !== null && _rootNode$type$name2 !== void 0 ? _rootNode$type$name2 : ''));
|
|
16
|
+
} else if (fg('platform_editor_controls_patch_5')) {
|
|
17
|
+
const isDragHandle = event.target.closest('[data-editor-block-ctrl-drag-handle]') !== null;
|
|
18
|
+
api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(isDragHandle));
|
|
15
19
|
}
|
|
16
20
|
return false;
|
|
17
21
|
};
|
|
@@ -163,7 +163,8 @@ const initialState = {
|
|
|
163
163
|
isDocSizeLimitEnabled: null,
|
|
164
164
|
isPMDragging: false,
|
|
165
165
|
multiSelectDnD: undefined,
|
|
166
|
-
lastDragCancelled: false
|
|
166
|
+
lastDragCancelled: false,
|
|
167
|
+
isSelectedViaDragHandle: false
|
|
167
168
|
};
|
|
168
169
|
export const getDecorations = state => {
|
|
169
170
|
var _key$getState;
|
|
@@ -197,7 +198,8 @@ export const apply = (api, formatMessage, tr, currentState, newState, flags, nod
|
|
|
197
198
|
menuTriggerBy,
|
|
198
199
|
isPMDragging,
|
|
199
200
|
isShiftDown,
|
|
200
|
-
lastDragCancelled
|
|
201
|
+
lastDragCancelled,
|
|
202
|
+
isSelectedViaDragHandle
|
|
201
203
|
} = currentState;
|
|
202
204
|
let isActiveNodeDeleted = false;
|
|
203
205
|
const {
|
|
@@ -407,6 +409,7 @@ export const apply = (api, formatMessage, tr, currentState, newState, flags, nod
|
|
|
407
409
|
} else if (meta !== null && meta !== void 0 && meta.toggleMenu) {
|
|
408
410
|
isMenuOpenNew = !isMenuOpen;
|
|
409
411
|
}
|
|
412
|
+
const isSelectedViaDragHandleNew = (meta === null || meta === void 0 ? void 0 : meta.isSelectedViaDragHandle) !== undefined && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_5') ? meta === null || meta === void 0 ? void 0 : meta.isSelectedViaDragHandle : isSelectedViaDragHandle;
|
|
410
413
|
return {
|
|
411
414
|
decorations,
|
|
412
415
|
activeNode: newActiveNode,
|
|
@@ -421,7 +424,8 @@ export const apply = (api, formatMessage, tr, currentState, newState, flags, nod
|
|
|
421
424
|
isPMDragging: (_meta$isPMDragging = meta === null || meta === void 0 ? void 0 : meta.isPMDragging) !== null && _meta$isPMDragging !== void 0 ? _meta$isPMDragging : isPMDragging,
|
|
422
425
|
multiSelectDnD,
|
|
423
426
|
isShiftDown: (_meta$isShiftDown = meta === null || meta === void 0 ? void 0 : meta.isShiftDown) !== null && _meta$isShiftDown !== void 0 ? _meta$isShiftDown : isShiftDown,
|
|
424
|
-
lastDragCancelled: (_meta$lastDragCancell = meta === null || meta === void 0 ? void 0 : meta.lastDragCancelled) !== null && _meta$lastDragCancell !== void 0 ? _meta$lastDragCancell : lastDragCancelled
|
|
427
|
+
lastDragCancelled: (_meta$lastDragCancell = meta === null || meta === void 0 ? void 0 : meta.lastDragCancelled) !== null && _meta$lastDragCancell !== void 0 ? _meta$lastDragCancell : lastDragCancelled,
|
|
428
|
+
isSelectedViaDragHandle: isSelectedViaDragHandleNew
|
|
425
429
|
};
|
|
426
430
|
};
|
|
427
431
|
export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI) => {
|
|
@@ -585,6 +589,16 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI) => {
|
|
|
585
589
|
return true;
|
|
586
590
|
}
|
|
587
591
|
}
|
|
592
|
+
if ((event.key === 'Enter' || event.key === ' ') && event.target instanceof HTMLElement && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_5')) {
|
|
593
|
+
const isDragHandle = event.target.closest('[data-editor-block-ctrl-drag-handle="true"]') !== null;
|
|
594
|
+
api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(isDragHandle));
|
|
595
|
+
}
|
|
596
|
+
if ((event.key === 'ArrowLeft' || event.key === 'ArrowRight' || event.key === 'ArrowDown' || event.key === 'ArrowUp') && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_5')) {
|
|
597
|
+
var _api$blockControls$sh;
|
|
598
|
+
if (api !== null && api !== void 0 && (_api$blockControls$sh = api.blockControls.sharedState.currentState()) !== null && _api$blockControls$sh !== void 0 && _api$blockControls$sh.isSelectedViaDragHandle) {
|
|
599
|
+
api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(false));
|
|
600
|
+
}
|
|
601
|
+
}
|
|
588
602
|
if (!event.repeat && event.shiftKey && fg('platform_editor_elements_dnd_shift_click_select')) {
|
|
589
603
|
view.dispatch(view.state.tr.setMeta(key, {
|
|
590
604
|
...view.state.tr.getMeta(key),
|
|
@@ -614,8 +628,17 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI) => {
|
|
|
614
628
|
return true;
|
|
615
629
|
}
|
|
616
630
|
}
|
|
631
|
+
if ((event.key === 'Enter' || event.key === ' ') && event.target instanceof HTMLElement && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_5')) {
|
|
632
|
+
const isDragHandle = event.target.closest('[data-editor-block-ctrl-drag-handle="true"]') !== null;
|
|
633
|
+
api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(isDragHandle));
|
|
634
|
+
}
|
|
635
|
+
if ((event.key === 'ArrowLeft' || event.key === 'ArrowRight' || event.key === 'ArrowDown' || event.key === 'ArrowUp') && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_5')) {
|
|
636
|
+
var _api$blockControls$sh2;
|
|
637
|
+
if (api !== null && api !== void 0 && (_api$blockControls$sh2 = api.blockControls.sharedState.currentState()) !== null && _api$blockControls$sh2 !== void 0 && _api$blockControls$sh2.isSelectedViaDragHandle) {
|
|
638
|
+
api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(false));
|
|
639
|
+
}
|
|
640
|
+
}
|
|
617
641
|
}
|
|
618
|
-
return false;
|
|
619
642
|
},
|
|
620
643
|
keyup(view, event) {
|
|
621
644
|
if (!event.repeat && event.key === 'Shift') {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
1
2
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
2
3
|
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
4
|
const STICKY_NODES = ['panel', 'table', 'expand', 'layoutSection', 'bodiedExtension'];
|
|
@@ -64,4 +65,10 @@ export const getControlHeightCSSValue = (nodeHeight, isSticky, isTopLevelNode, f
|
|
|
64
65
|
} : {
|
|
65
66
|
height: `${nodeHeight || fallbackPxHeight}px`
|
|
66
67
|
};
|
|
68
|
+
};
|
|
69
|
+
export const shouldMaskNodeControls = (nodeType, isTopLevelNode) => {
|
|
70
|
+
return (
|
|
71
|
+
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
72
|
+
isTopLevelNode && ['table'].includes(nodeType) && fg('platform_editor_controls_sticky_controls') && editorExperiment('platform_editor_controls', 'variant1')
|
|
73
|
+
);
|
|
67
74
|
};
|
package/dist/es2019/ui/consts.js
CHANGED
|
@@ -25,6 +25,7 @@ export const DRAG_HANDLE_PARAGRAPH_TOP_ADJUSTMENT = 2;
|
|
|
25
25
|
* so we allow for some leniency to capture them all. e.g. Table is depth 3.
|
|
26
26
|
*/
|
|
27
27
|
export const DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH = 3;
|
|
28
|
+
export const STICKY_CONTROLS_TOP_MARGIN = 8;
|
|
28
29
|
export const QUICK_INSERT_HEIGHT = 24;
|
|
29
30
|
export const QUICK_INSERT_WIDTH = 24;
|
|
30
31
|
export const QUICK_INSERT_DIMENSIONS = {
|
|
@@ -27,10 +27,10 @@ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
|
27
27
|
import Tooltip from '@atlaskit/tooltip';
|
|
28
28
|
import { key } from '../pm-plugins/main';
|
|
29
29
|
import { getMultiSelectAnalyticsAttributes } from '../pm-plugins/utils/analytics';
|
|
30
|
-
import { getControlBottomCSSValue, getControlHeightCSSValue, getLeftPosition, getNodeHeight, getTopPosition, shouldBeSticky } from '../pm-plugins/utils/drag-handle-positions';
|
|
30
|
+
import { getControlBottomCSSValue, getControlHeightCSSValue, getLeftPosition, getNodeHeight, getTopPosition, shouldBeSticky, shouldMaskNodeControls } from '../pm-plugins/utils/drag-handle-positions';
|
|
31
31
|
import { isHandleCorrelatedToSelection, selectNode } from '../pm-plugins/utils/getSelection';
|
|
32
32
|
import { alignAnchorHeadInDirectionOfPos, expandSelectionHeadToNodeAtPos } from '../pm-plugins/utils/selection';
|
|
33
|
-
import { BLOCK_MENU_ENABLED, DRAG_HANDLE_BORDER_RADIUS, DRAG_HANDLE_HEIGHT, DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH, DRAG_HANDLE_WIDTH, DRAG_HANDLE_ZINDEX, dragHandleGap, nodeMargins, spacingBetweenNodesForPreview, topPositionAdjustment } from './consts';
|
|
33
|
+
import { BLOCK_MENU_ENABLED, DRAG_HANDLE_BORDER_RADIUS, DRAG_HANDLE_HEIGHT, DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH, DRAG_HANDLE_WIDTH, DRAG_HANDLE_ZINDEX, dragHandleGap, nodeMargins, spacingBetweenNodesForPreview, STICKY_CONTROLS_TOP_MARGIN, topPositionAdjustment } from './consts';
|
|
34
34
|
import { dragPreview } from './drag-preview';
|
|
35
35
|
import { refreshAnchorName } from './utils/anchor-name';
|
|
36
36
|
import { VisibilityContainer } from './visibility-container';
|
|
@@ -39,6 +39,19 @@ const iconWrapperStyles = xcss({
|
|
|
39
39
|
justifyContent: 'center',
|
|
40
40
|
alignItems: 'center'
|
|
41
41
|
});
|
|
42
|
+
const extendedIconWrapperStyles = css({
|
|
43
|
+
display: 'flex',
|
|
44
|
+
justifyContent: 'center',
|
|
45
|
+
alignItems: 'center',
|
|
46
|
+
background: "var(--ds-surface, #FFFFFF)",
|
|
47
|
+
marginBottom: "var(--ds-space-negative-100, -8px)",
|
|
48
|
+
paddingBottom: "var(--ds-space-100, 8px)",
|
|
49
|
+
marginTop: "var(--ds-space-negative-100, -8px)",
|
|
50
|
+
paddingTop: "var(--ds-space-100, 8px)",
|
|
51
|
+
marginRight: "var(--ds-space-negative-100, -8px)",
|
|
52
|
+
paddingRight: "var(--ds-space-100, 8px)",
|
|
53
|
+
borderRadius: '6px'
|
|
54
|
+
});
|
|
42
55
|
|
|
43
56
|
// update color to match quick insert button for new editor controls
|
|
44
57
|
const dragHandleColor = css({
|
|
@@ -128,16 +141,25 @@ const dragHandleContainerStyles = xcss({
|
|
|
128
141
|
boxSizing: 'border-box'
|
|
129
142
|
});
|
|
130
143
|
const tooltipContainerStyles = css({
|
|
131
|
-
|
|
132
|
-
|
|
144
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
145
|
+
top: `${STICKY_CONTROLS_TOP_MARGIN}px`,
|
|
146
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
147
|
+
bottom: `-${STICKY_CONTROLS_TOP_MARGIN}px`,
|
|
148
|
+
position: 'sticky',
|
|
149
|
+
zIndex: 100 // card = 100
|
|
150
|
+
});
|
|
151
|
+
const tooltipContainerStylesWithNodeControls = css({
|
|
152
|
+
top: '0',
|
|
153
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
154
|
+
bottom: `-${STICKY_CONTROLS_TOP_MARGIN}px`,
|
|
133
155
|
position: 'sticky',
|
|
134
|
-
zIndex:
|
|
156
|
+
zIndex: 100 // card = 100
|
|
135
157
|
});
|
|
136
158
|
const tooltipContainerStylesStickyHeader = css({
|
|
137
159
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
138
160
|
'[data-blocks-drag-handle-container]:has(+ [data-prosemirror-node-name="table"] .pm-table-with-controls tr.sticky) &': {
|
|
139
161
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
140
|
-
top: tableControlsSpacing
|
|
162
|
+
top: tableControlsSpacing - STICKY_CONTROLS_TOP_MARGIN
|
|
141
163
|
}
|
|
142
164
|
});
|
|
143
165
|
|
|
@@ -146,7 +168,7 @@ const tooltipContainerStylesStickyHeaderWithMarksFix = css({
|
|
|
146
168
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
147
169
|
'[data-prosemirror-mark-name="breakout"]:has([data-blocks-drag-handle-container]):has(+ [data-prosemirror-node-name="table"] .pm-table-with-controls tr.sticky) &': {
|
|
148
170
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
149
|
-
top: tableControlsSpacing
|
|
171
|
+
top: tableControlsSpacing - STICKY_CONTROLS_TOP_MARGIN
|
|
150
172
|
}
|
|
151
173
|
});
|
|
152
174
|
const dragHandleMultiLineSelectionFixFirefox = css({
|
|
@@ -553,14 +575,14 @@ export const DragHandle = ({
|
|
|
553
575
|
const isEdgeCase = (hasResizer || isExtension || isEmbedCard || isBlockCard) && innerContainer;
|
|
554
576
|
const isSticky = shouldBeSticky(nodeType);
|
|
555
577
|
if (supportsAnchor) {
|
|
556
|
-
const bottom = fg('platform_editor_controls_sticky_controls') ? getControlBottomCSSValue(safeAnchorName, isSticky, isTopLevelNode, isLayoutColumn) : {};
|
|
578
|
+
const bottom = editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_sticky_controls') ? getControlBottomCSSValue(safeAnchorName, isSticky, isTopLevelNode, isLayoutColumn) : {};
|
|
557
579
|
return {
|
|
558
580
|
left: isEdgeCase ? `calc(anchor(${safeAnchorName} start) + ${getLeftPosition(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType)})` : editorExperiment('advanced_layouts', true) && isLayoutColumn ? `calc((anchor(${safeAnchorName} right) + anchor(${safeAnchorName} left))/2 - ${DRAG_HANDLE_HEIGHT / 2}px)` : `calc(anchor(${safeAnchorName} start) - ${DRAG_HANDLE_WIDTH}px - ${dragHandleGap(nodeType, parentNodeType)}px)`,
|
|
559
581
|
top: editorExperiment('advanced_layouts', true) && isLayoutColumn ? `calc(anchor(${safeAnchorName} top) - ${DRAG_HANDLE_WIDTH}px)` : `calc(anchor(${safeAnchorName} start) + ${topPositionAdjustment(nodeType)}px)`,
|
|
560
582
|
...bottom
|
|
561
583
|
};
|
|
562
584
|
}
|
|
563
|
-
const height = fg('platform_editor_controls_sticky_controls') ? getControlHeightCSSValue(getNodeHeight(dom, safeAnchorName, anchorRectCache) || 0, isSticky, isTopLevelNode, `${DRAG_HANDLE_HEIGHT}`, isLayoutColumn) : {};
|
|
585
|
+
const height = editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_sticky_controls') ? getControlHeightCSSValue(getNodeHeight(dom, safeAnchorName, anchorRectCache) || 0, isSticky, isTopLevelNode, `${DRAG_HANDLE_HEIGHT}`, isLayoutColumn) : {};
|
|
564
586
|
return {
|
|
565
587
|
left: isEdgeCase ? `calc(${(dom === null || dom === void 0 ? void 0 : dom.offsetLeft) || 0}px + ${getLeftPosition(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType)})` : getLeftPosition(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType),
|
|
566
588
|
top: getTopPosition(dom, nodeType),
|
|
@@ -699,14 +721,14 @@ export const DragHandle = ({
|
|
|
699
721
|
// eslint-disable-next-line @atlaskit/design-system/no-html-button
|
|
700
722
|
jsx("button", {
|
|
701
723
|
type: "button",
|
|
702
|
-
css: [fg('platform_editor_controls_sticky_controls') ? dragHandleButtonStyles : dragHandleButtonStylesOld, editorExperiment('platform_editor_controls', 'variant1') && dragHandleColor,
|
|
724
|
+
css: [editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_sticky_controls') ? dragHandleButtonStyles : dragHandleButtonStylesOld, editorExperiment('platform_editor_controls', 'variant1') && dragHandleColor,
|
|
703
725
|
// ED-26266: Fixed the drag handle highlight when selecting multiple line in Firefox
|
|
704
726
|
// See https://product-fabric.atlassian.net/browse/ED-26266
|
|
705
727
|
browser.gecko && fg('platform_editor_dnd_handle_highlight_fix_firefox') && dragHandleMultiLineSelectionFixFirefox, editorExperiment('advanced_layouts', true) && isLayoutColumn && layoutColumnDragHandleStyles, dragHandleSelected && selectedStyles],
|
|
706
728
|
ref: buttonRef
|
|
707
729
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
708
730
|
,
|
|
709
|
-
style: !fg('platform_editor_controls_sticky_controls') && positionStyles || {},
|
|
731
|
+
style: !(editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_sticky_controls')) && positionStyles || {},
|
|
710
732
|
onClick: handleOnClick,
|
|
711
733
|
onMouseDown: handleMouseDown,
|
|
712
734
|
onKeyDown: handleKeyDown
|
|
@@ -717,7 +739,6 @@ export const DragHandle = ({
|
|
|
717
739
|
"data-editor-block-ctrl-drag-handle": true,
|
|
718
740
|
"data-testid": "block-ctrl-drag-handle"
|
|
719
741
|
}, jsx(Box, {
|
|
720
|
-
as: "span",
|
|
721
742
|
xcss: iconWrapperStyles
|
|
722
743
|
// eslint-disable-next-line @atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop
|
|
723
744
|
,
|
|
@@ -736,7 +757,7 @@ export const DragHandle = ({
|
|
|
736
757
|
as: "span",
|
|
737
758
|
testId: "block-ctrl-drag-handle-container"
|
|
738
759
|
}, jsx("span", {
|
|
739
|
-
css: [tooltipContainerStyles, fg('platform_editor_controls_patch_4') && tooltipContainerStylesStickyHeader, fg('platform_editor_controls_patch_4') && tooltipContainerStylesStickyHeaderWithMarksFix]
|
|
760
|
+
css: [shouldMaskNodeControls(nodeType, isTopLevelNode) ? tooltipContainerStylesWithNodeControls : tooltipContainerStyles, fg('platform_editor_controls_patch_4') && tooltipContainerStylesStickyHeader, fg('platform_editor_controls_patch_4') && tooltipContainerStylesStickyHeaderWithMarksFix]
|
|
740
761
|
}, jsx(Tooltip, {
|
|
741
762
|
content: jsx(TooltipContentWithMultipleShortcuts, {
|
|
742
763
|
helpDescriptors: helpDescriptors
|
|
@@ -749,7 +770,11 @@ export const DragHandle = ({
|
|
|
749
770
|
priority: 'important'
|
|
750
771
|
});
|
|
751
772
|
}
|
|
752
|
-
},
|
|
773
|
+
}, jsx("span", {
|
|
774
|
+
css:
|
|
775
|
+
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
776
|
+
shouldMaskNodeControls(nodeType, isTopLevelNode) && extendedIconWrapperStyles
|
|
777
|
+
}, renderButton()))));
|
|
753
778
|
const stickyWithoutTooltip = () => jsx(Box
|
|
754
779
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
755
780
|
, {
|
|
@@ -758,8 +783,12 @@ export const DragHandle = ({
|
|
|
758
783
|
as: "span",
|
|
759
784
|
testId: "block-ctrl-drag-handle-container"
|
|
760
785
|
}, jsx("span", {
|
|
761
|
-
css: [tooltipContainerStyles, fg('platform_editor_controls_patch_4') && tooltipContainerStylesStickyHeader, fg('platform_editor_controls_patch_4') && tooltipContainerStylesStickyHeaderWithMarksFix]
|
|
762
|
-
},
|
|
786
|
+
css: [shouldMaskNodeControls(nodeType, isTopLevelNode) ? tooltipContainerStylesWithNodeControls : tooltipContainerStyles, fg('platform_editor_controls_patch_4') && tooltipContainerStylesStickyHeader, fg('platform_editor_controls_patch_4') && tooltipContainerStylesStickyHeaderWithMarksFix]
|
|
787
|
+
}, jsx("span", {
|
|
788
|
+
css:
|
|
789
|
+
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
790
|
+
shouldMaskNodeControls(nodeType, isTopLevelNode) && extendedIconWrapperStyles
|
|
791
|
+
}, renderButton())));
|
|
763
792
|
const buttonWithTooltip = () => jsx(Tooltip, {
|
|
764
793
|
content: jsx(TooltipContentWithMultipleShortcuts, {
|
|
765
794
|
helpDescriptors: helpDescriptors
|
|
@@ -775,7 +804,7 @@ export const DragHandle = ({
|
|
|
775
804
|
const isTooltip = !dragHandleDisabled && fg('platform_editor_element_drag_and_drop_ed_23873');
|
|
776
805
|
const stickyRender = isTooltip ? stickyWithTooltip() : stickyWithoutTooltip();
|
|
777
806
|
const render = isTooltip ? buttonWithTooltip() : renderButton();
|
|
778
|
-
return fg('platform_editor_controls_sticky_controls') ? stickyRender : render;
|
|
807
|
+
return editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_sticky_controls') ? stickyRender : render;
|
|
779
808
|
};
|
|
780
809
|
export const DragHandleWithVisibility = ({
|
|
781
810
|
view,
|
|
@@ -299,7 +299,7 @@ export const TypeAheadControl = ({
|
|
|
299
299
|
testId: "editor-quick-insert-button",
|
|
300
300
|
type: "button",
|
|
301
301
|
"aria-label": formatMessage(messages.insert),
|
|
302
|
-
xcss: [fg('platform_editor_controls_sticky_controls') ?
|
|
302
|
+
xcss: [fg('platform_editor_controls_sticky_controls') ? stickyButtonStyles : buttonStyles, isTypeAheadOpen && !fg('platform_editor_controls_widget_visibility') ? disabledStyles : undefined],
|
|
303
303
|
onClick: handleQuickInsert,
|
|
304
304
|
onMouseDown: handleMouseDown,
|
|
305
305
|
isDisabled: !fg('platform_editor_controls_widget_visibility') && isTypeAheadOpen
|
|
@@ -157,10 +157,19 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
|
157
157
|
}));
|
|
158
158
|
return tr;
|
|
159
159
|
};
|
|
160
|
+
},
|
|
161
|
+
setSelectedViaDragHandle: function setSelectedViaDragHandle(isSelectedViaDragHandle) {
|
|
162
|
+
return function (_ref7) {
|
|
163
|
+
var tr = _ref7.tr;
|
|
164
|
+
var currMeta = tr.getMeta(key);
|
|
165
|
+
return tr.setMeta(key, _objectSpread(_objectSpread({}, currMeta), {}, {
|
|
166
|
+
isSelectedViaDragHandle: isSelectedViaDragHandle
|
|
167
|
+
}));
|
|
168
|
+
};
|
|
160
169
|
}
|
|
161
170
|
},
|
|
162
171
|
getSharedState: function getSharedState(editorState) {
|
|
163
|
-
var _key$getState$isMenuO, _key$getState, _key$getState$menuTri, _key$getState2, _key$getState$activeN, _key$getState3, _key$getState$isDragg, _key$getState4, _key$getState$isPMDra, _key$getState5, _key$getState$multiSe, _key$getState6, _key$getState$isShift, _key$getState7, _key$getState$lastDra, _key$getState8, _interactionTrackingP;
|
|
172
|
+
var _key$getState$isMenuO, _key$getState, _key$getState$menuTri, _key$getState2, _key$getState$activeN, _key$getState3, _key$getState$isDragg, _key$getState4, _key$getState$isPMDra, _key$getState5, _key$getState$multiSe, _key$getState6, _key$getState$isShift, _key$getState7, _key$getState$lastDra, _key$getState8, _interactionTrackingP, _key$getState$isSelec, _key$getState9;
|
|
164
173
|
if (!editorState) {
|
|
165
174
|
return undefined;
|
|
166
175
|
}
|
|
@@ -173,14 +182,15 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
|
173
182
|
multiSelectDnD: (_key$getState$multiSe = (_key$getState6 = key.getState(editorState)) === null || _key$getState6 === void 0 ? void 0 : _key$getState6.multiSelectDnD) !== null && _key$getState$multiSe !== void 0 ? _key$getState$multiSe : undefined,
|
|
174
183
|
isShiftDown: (_key$getState$isShift = (_key$getState7 = key.getState(editorState)) === null || _key$getState7 === void 0 ? void 0 : _key$getState7.isShiftDown) !== null && _key$getState$isShift !== void 0 ? _key$getState$isShift : undefined,
|
|
175
184
|
lastDragCancelled: (_key$getState$lastDra = (_key$getState8 = key.getState(editorState)) === null || _key$getState8 === void 0 ? void 0 : _key$getState8.lastDragCancelled) !== null && _key$getState$lastDra !== void 0 ? _key$getState$lastDra : false,
|
|
176
|
-
isEditing: (_interactionTrackingP = interactionTrackingPluginKey.getState(editorState)) === null || _interactionTrackingP === void 0 ? void 0 : _interactionTrackingP.isEditing
|
|
185
|
+
isEditing: (_interactionTrackingP = interactionTrackingPluginKey.getState(editorState)) === null || _interactionTrackingP === void 0 ? void 0 : _interactionTrackingP.isEditing,
|
|
186
|
+
isSelectedViaDragHandle: (_key$getState$isSelec = (_key$getState9 = key.getState(editorState)) === null || _key$getState9 === void 0 ? void 0 : _key$getState9.isSelectedViaDragHandle) !== null && _key$getState$isSelec !== void 0 ? _key$getState$isSelec : false
|
|
177
187
|
};
|
|
178
188
|
},
|
|
179
|
-
contentComponent: function contentComponent(
|
|
180
|
-
var editorView =
|
|
181
|
-
popupsMountPoint =
|
|
182
|
-
popupsBoundariesElement =
|
|
183
|
-
popupsScrollableElement =
|
|
189
|
+
contentComponent: function contentComponent(_ref8) {
|
|
190
|
+
var editorView = _ref8.editorView,
|
|
191
|
+
popupsMountPoint = _ref8.popupsMountPoint,
|
|
192
|
+
popupsBoundariesElement = _ref8.popupsBoundariesElement,
|
|
193
|
+
popupsScrollableElement = _ref8.popupsScrollableElement;
|
|
184
194
|
return /*#__PURE__*/React.createElement(React.Fragment, null, editorExperiment('platform_editor_controls', 'variant1') ? /*#__PURE__*/React.createElement(BlockMenu, {
|
|
185
195
|
editorView: editorView,
|
|
186
196
|
mountPoint: popupsMountPoint,
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
1
2
|
export var handleMouseDown = function handleMouseDown(api) {
|
|
2
3
|
return function (view, event) {
|
|
3
|
-
if (
|
|
4
|
+
if (!(event.target instanceof HTMLElement)) {
|
|
4
5
|
return false;
|
|
5
6
|
}
|
|
6
|
-
if (
|
|
7
|
+
if (!view.editable) {
|
|
7
8
|
var _rootNode$type$name, _rootNode$type$name2;
|
|
8
9
|
var targetPos = view.posAtDOM(event.target, 0);
|
|
9
10
|
// always fetch top level position for mouseDown to avoid drag handle positions being incorrect
|
|
@@ -13,6 +14,9 @@ export var handleMouseDown = function handleMouseDown(api) {
|
|
|
13
14
|
return false;
|
|
14
15
|
}
|
|
15
16
|
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.showDragHandleAt(rootPos, '', (_rootNode$type$name = rootNode.type.name) !== null && _rootNode$type$name !== void 0 ? _rootNode$type$name : '', undefined, rootPos, '', (_rootNode$type$name2 = rootNode.type.name) !== null && _rootNode$type$name2 !== void 0 ? _rootNode$type$name2 : ''));
|
|
17
|
+
} else if (fg('platform_editor_controls_patch_5')) {
|
|
18
|
+
var isDragHandle = event.target.closest('[data-editor-block-ctrl-drag-handle]') !== null;
|
|
19
|
+
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(isDragHandle));
|
|
16
20
|
}
|
|
17
21
|
return false;
|
|
18
22
|
};
|
|
@@ -159,7 +159,8 @@ var initialState = {
|
|
|
159
159
|
isDocSizeLimitEnabled: null,
|
|
160
160
|
isPMDragging: false,
|
|
161
161
|
multiSelectDnD: undefined,
|
|
162
|
-
lastDragCancelled: false
|
|
162
|
+
lastDragCancelled: false,
|
|
163
|
+
isSelectedViaDragHandle: false
|
|
163
164
|
};
|
|
164
165
|
export var getDecorations = function getDecorations(state) {
|
|
165
166
|
var _key$getState;
|
|
@@ -192,7 +193,8 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
|
|
|
192
193
|
menuTriggerBy = currentState.menuTriggerBy,
|
|
193
194
|
isPMDragging = currentState.isPMDragging,
|
|
194
195
|
isShiftDown = currentState.isShiftDown,
|
|
195
|
-
lastDragCancelled = currentState.lastDragCancelled
|
|
196
|
+
lastDragCancelled = currentState.lastDragCancelled,
|
|
197
|
+
isSelectedViaDragHandle = currentState.isSelectedViaDragHandle;
|
|
196
198
|
var isActiveNodeDeleted = false;
|
|
197
199
|
var _getTrMetadata = getTrMetadata(tr),
|
|
198
200
|
from = _getTrMetadata.from,
|
|
@@ -402,6 +404,7 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
|
|
|
402
404
|
} else if (meta !== null && meta !== void 0 && meta.toggleMenu) {
|
|
403
405
|
isMenuOpenNew = !isMenuOpen;
|
|
404
406
|
}
|
|
407
|
+
var isSelectedViaDragHandleNew = (meta === null || meta === void 0 ? void 0 : meta.isSelectedViaDragHandle) !== undefined && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_5') ? meta === null || meta === void 0 ? void 0 : meta.isSelectedViaDragHandle : isSelectedViaDragHandle;
|
|
405
408
|
return {
|
|
406
409
|
decorations: decorations,
|
|
407
410
|
activeNode: newActiveNode,
|
|
@@ -416,7 +419,8 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
|
|
|
416
419
|
isPMDragging: (_meta$isPMDragging = meta === null || meta === void 0 ? void 0 : meta.isPMDragging) !== null && _meta$isPMDragging !== void 0 ? _meta$isPMDragging : isPMDragging,
|
|
417
420
|
multiSelectDnD: multiSelectDnD,
|
|
418
421
|
isShiftDown: (_meta$isShiftDown = meta === null || meta === void 0 ? void 0 : meta.isShiftDown) !== null && _meta$isShiftDown !== void 0 ? _meta$isShiftDown : isShiftDown,
|
|
419
|
-
lastDragCancelled: (_meta$lastDragCancell = meta === null || meta === void 0 ? void 0 : meta.lastDragCancelled) !== null && _meta$lastDragCancell !== void 0 ? _meta$lastDragCancell : lastDragCancelled
|
|
422
|
+
lastDragCancelled: (_meta$lastDragCancell = meta === null || meta === void 0 ? void 0 : meta.lastDragCancelled) !== null && _meta$lastDragCancell !== void 0 ? _meta$lastDragCancell : lastDragCancelled,
|
|
423
|
+
isSelectedViaDragHandle: isSelectedViaDragHandleNew
|
|
420
424
|
};
|
|
421
425
|
};
|
|
422
426
|
export { _apply as apply };
|
|
@@ -574,6 +578,16 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
574
578
|
return true;
|
|
575
579
|
}
|
|
576
580
|
}
|
|
581
|
+
if ((event.key === 'Enter' || event.key === ' ') && event.target instanceof HTMLElement && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_5')) {
|
|
582
|
+
var isDragHandle = event.target.closest('[data-editor-block-ctrl-drag-handle="true"]') !== null;
|
|
583
|
+
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(isDragHandle));
|
|
584
|
+
}
|
|
585
|
+
if ((event.key === 'ArrowLeft' || event.key === 'ArrowRight' || event.key === 'ArrowDown' || event.key === 'ArrowUp') && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_5')) {
|
|
586
|
+
var _api$blockControls$sh;
|
|
587
|
+
if (api !== null && api !== void 0 && (_api$blockControls$sh = api.blockControls.sharedState.currentState()) !== null && _api$blockControls$sh !== void 0 && _api$blockControls$sh.isSelectedViaDragHandle) {
|
|
588
|
+
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(false));
|
|
589
|
+
}
|
|
590
|
+
}
|
|
577
591
|
if (!event.repeat && event.shiftKey && fg('platform_editor_elements_dnd_shift_click_select')) {
|
|
578
592
|
view.dispatch(view.state.tr.setMeta(key, _objectSpread(_objectSpread({}, view.state.tr.getMeta(key)), {}, {
|
|
579
593
|
isShiftDown: true
|
|
@@ -601,8 +615,17 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
601
615
|
return true;
|
|
602
616
|
}
|
|
603
617
|
}
|
|
618
|
+
if ((event.key === 'Enter' || event.key === ' ') && event.target instanceof HTMLElement && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_5')) {
|
|
619
|
+
var _isDragHandle = event.target.closest('[data-editor-block-ctrl-drag-handle="true"]') !== null;
|
|
620
|
+
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(_isDragHandle));
|
|
621
|
+
}
|
|
622
|
+
if ((event.key === 'ArrowLeft' || event.key === 'ArrowRight' || event.key === 'ArrowDown' || event.key === 'ArrowUp') && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_5')) {
|
|
623
|
+
var _api$blockControls$sh2;
|
|
624
|
+
if (api !== null && api !== void 0 && (_api$blockControls$sh2 = api.blockControls.sharedState.currentState()) !== null && _api$blockControls$sh2 !== void 0 && _api$blockControls$sh2.isSelectedViaDragHandle) {
|
|
625
|
+
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(false));
|
|
626
|
+
}
|
|
627
|
+
}
|
|
604
628
|
}
|
|
605
|
-
return false;
|
|
606
629
|
},
|
|
607
630
|
keyup: function keyup(view, event) {
|
|
608
631
|
if (!event.repeat && event.key === 'Shift') {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
1
2
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
2
3
|
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
4
|
var STICKY_NODES = ['panel', 'table', 'expand', 'layoutSection', 'bodiedExtension'];
|
|
@@ -66,4 +67,10 @@ export var getControlHeightCSSValue = function getControlHeightCSSValue(nodeHeig
|
|
|
66
67
|
} : {
|
|
67
68
|
height: "".concat(nodeHeight || fallbackPxHeight, "px")
|
|
68
69
|
};
|
|
70
|
+
};
|
|
71
|
+
export var shouldMaskNodeControls = function shouldMaskNodeControls(nodeType, isTopLevelNode) {
|
|
72
|
+
return (
|
|
73
|
+
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
74
|
+
isTopLevelNode && ['table'].includes(nodeType) && fg('platform_editor_controls_sticky_controls') && editorExperiment('platform_editor_controls', 'variant1')
|
|
75
|
+
);
|
|
69
76
|
};
|
package/dist/esm/ui/consts.js
CHANGED
|
@@ -27,6 +27,7 @@ export var DRAG_HANDLE_PARAGRAPH_TOP_ADJUSTMENT = 2;
|
|
|
27
27
|
* so we allow for some leniency to capture them all. e.g. Table is depth 3.
|
|
28
28
|
*/
|
|
29
29
|
export var DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH = 3;
|
|
30
|
+
export var STICKY_CONTROLS_TOP_MARGIN = 8;
|
|
30
31
|
export var QUICK_INSERT_HEIGHT = 24;
|
|
31
32
|
export var QUICK_INSERT_WIDTH = 24;
|
|
32
33
|
export var QUICK_INSERT_DIMENSIONS = {
|
|
@@ -32,10 +32,10 @@ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
|
32
32
|
import Tooltip from '@atlaskit/tooltip';
|
|
33
33
|
import { key } from '../pm-plugins/main';
|
|
34
34
|
import { getMultiSelectAnalyticsAttributes } from '../pm-plugins/utils/analytics';
|
|
35
|
-
import { getControlBottomCSSValue, getControlHeightCSSValue, getLeftPosition, getNodeHeight, getTopPosition, shouldBeSticky } from '../pm-plugins/utils/drag-handle-positions';
|
|
35
|
+
import { getControlBottomCSSValue, getControlHeightCSSValue, getLeftPosition, getNodeHeight, getTopPosition, shouldBeSticky, shouldMaskNodeControls } from '../pm-plugins/utils/drag-handle-positions';
|
|
36
36
|
import { isHandleCorrelatedToSelection, selectNode } from '../pm-plugins/utils/getSelection';
|
|
37
37
|
import { alignAnchorHeadInDirectionOfPos, expandSelectionHeadToNodeAtPos } from '../pm-plugins/utils/selection';
|
|
38
|
-
import { BLOCK_MENU_ENABLED, DRAG_HANDLE_BORDER_RADIUS, DRAG_HANDLE_HEIGHT, DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH, DRAG_HANDLE_WIDTH, DRAG_HANDLE_ZINDEX, dragHandleGap, nodeMargins, spacingBetweenNodesForPreview, topPositionAdjustment } from './consts';
|
|
38
|
+
import { BLOCK_MENU_ENABLED, DRAG_HANDLE_BORDER_RADIUS, DRAG_HANDLE_HEIGHT, DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH, DRAG_HANDLE_WIDTH, DRAG_HANDLE_ZINDEX, dragHandleGap, nodeMargins, spacingBetweenNodesForPreview, STICKY_CONTROLS_TOP_MARGIN, topPositionAdjustment } from './consts';
|
|
39
39
|
import { dragPreview } from './drag-preview';
|
|
40
40
|
import { refreshAnchorName } from './utils/anchor-name';
|
|
41
41
|
import { VisibilityContainer } from './visibility-container';
|
|
@@ -44,6 +44,19 @@ var iconWrapperStyles = xcss({
|
|
|
44
44
|
justifyContent: 'center',
|
|
45
45
|
alignItems: 'center'
|
|
46
46
|
});
|
|
47
|
+
var extendedIconWrapperStyles = css({
|
|
48
|
+
display: 'flex',
|
|
49
|
+
justifyContent: 'center',
|
|
50
|
+
alignItems: 'center',
|
|
51
|
+
background: "var(--ds-surface, #FFFFFF)",
|
|
52
|
+
marginBottom: "var(--ds-space-negative-100, -8px)",
|
|
53
|
+
paddingBottom: "var(--ds-space-100, 8px)",
|
|
54
|
+
marginTop: "var(--ds-space-negative-100, -8px)",
|
|
55
|
+
paddingTop: "var(--ds-space-100, 8px)",
|
|
56
|
+
marginRight: "var(--ds-space-negative-100, -8px)",
|
|
57
|
+
paddingRight: "var(--ds-space-100, 8px)",
|
|
58
|
+
borderRadius: '6px'
|
|
59
|
+
});
|
|
47
60
|
|
|
48
61
|
// update color to match quick insert button for new editor controls
|
|
49
62
|
var dragHandleColor = css({
|
|
@@ -133,16 +146,25 @@ var dragHandleContainerStyles = xcss({
|
|
|
133
146
|
boxSizing: 'border-box'
|
|
134
147
|
});
|
|
135
148
|
var tooltipContainerStyles = css({
|
|
136
|
-
|
|
137
|
-
|
|
149
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
150
|
+
top: "".concat(STICKY_CONTROLS_TOP_MARGIN, "px"),
|
|
151
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
152
|
+
bottom: "-".concat(STICKY_CONTROLS_TOP_MARGIN, "px"),
|
|
153
|
+
position: 'sticky',
|
|
154
|
+
zIndex: 100 // card = 100
|
|
155
|
+
});
|
|
156
|
+
var tooltipContainerStylesWithNodeControls = css({
|
|
157
|
+
top: '0',
|
|
158
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
159
|
+
bottom: "-".concat(STICKY_CONTROLS_TOP_MARGIN, "px"),
|
|
138
160
|
position: 'sticky',
|
|
139
|
-
zIndex:
|
|
161
|
+
zIndex: 100 // card = 100
|
|
140
162
|
});
|
|
141
163
|
var tooltipContainerStylesStickyHeader = css({
|
|
142
164
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
143
165
|
'[data-blocks-drag-handle-container]:has(+ [data-prosemirror-node-name="table"] .pm-table-with-controls tr.sticky) &': {
|
|
144
166
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
145
|
-
top: tableControlsSpacing
|
|
167
|
+
top: tableControlsSpacing - STICKY_CONTROLS_TOP_MARGIN
|
|
146
168
|
}
|
|
147
169
|
});
|
|
148
170
|
|
|
@@ -151,7 +173,7 @@ var tooltipContainerStylesStickyHeaderWithMarksFix = css({
|
|
|
151
173
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
152
174
|
'[data-prosemirror-mark-name="breakout"]:has([data-blocks-drag-handle-container]):has(+ [data-prosemirror-node-name="table"] .pm-table-with-controls tr.sticky) &': {
|
|
153
175
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
154
|
-
top: tableControlsSpacing
|
|
176
|
+
top: tableControlsSpacing - STICKY_CONTROLS_TOP_MARGIN
|
|
155
177
|
}
|
|
156
178
|
});
|
|
157
179
|
var dragHandleMultiLineSelectionFixFirefox = css({
|
|
@@ -561,13 +583,13 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
561
583
|
var isEdgeCase = (hasResizer || isExtension || isEmbedCard || isBlockCard) && innerContainer;
|
|
562
584
|
var isSticky = shouldBeSticky(nodeType);
|
|
563
585
|
if (supportsAnchor) {
|
|
564
|
-
var bottom = fg('platform_editor_controls_sticky_controls') ? getControlBottomCSSValue(safeAnchorName, isSticky, isTopLevelNode, isLayoutColumn) : {};
|
|
586
|
+
var bottom = editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_sticky_controls') ? getControlBottomCSSValue(safeAnchorName, isSticky, isTopLevelNode, isLayoutColumn) : {};
|
|
565
587
|
return _objectSpread({
|
|
566
588
|
left: isEdgeCase ? "calc(anchor(".concat(safeAnchorName, " start) + ").concat(getLeftPosition(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType), ")") : editorExperiment('advanced_layouts', true) && isLayoutColumn ? "calc((anchor(".concat(safeAnchorName, " right) + anchor(").concat(safeAnchorName, " left))/2 - ").concat(DRAG_HANDLE_HEIGHT / 2, "px)") : "calc(anchor(".concat(safeAnchorName, " start) - ").concat(DRAG_HANDLE_WIDTH, "px - ").concat(dragHandleGap(nodeType, parentNodeType), "px)"),
|
|
567
589
|
top: editorExperiment('advanced_layouts', true) && isLayoutColumn ? "calc(anchor(".concat(safeAnchorName, " top) - ").concat(DRAG_HANDLE_WIDTH, "px)") : "calc(anchor(".concat(safeAnchorName, " start) + ").concat(topPositionAdjustment(nodeType), "px)")
|
|
568
590
|
}, bottom);
|
|
569
591
|
}
|
|
570
|
-
var height = fg('platform_editor_controls_sticky_controls') ? getControlHeightCSSValue(getNodeHeight(dom, safeAnchorName, anchorRectCache) || 0, isSticky, isTopLevelNode, "".concat(DRAG_HANDLE_HEIGHT), isLayoutColumn) : {};
|
|
592
|
+
var height = editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_sticky_controls') ? getControlHeightCSSValue(getNodeHeight(dom, safeAnchorName, anchorRectCache) || 0, isSticky, isTopLevelNode, "".concat(DRAG_HANDLE_HEIGHT), isLayoutColumn) : {};
|
|
571
593
|
return _objectSpread({
|
|
572
594
|
left: isEdgeCase ? "calc(".concat((dom === null || dom === void 0 ? void 0 : dom.offsetLeft) || 0, "px + ").concat(getLeftPosition(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType), ")") : getLeftPosition(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType),
|
|
573
595
|
top: getTopPosition(dom, nodeType)
|
|
@@ -709,14 +731,14 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
709
731
|
// eslint-disable-next-line @atlaskit/design-system/no-html-button
|
|
710
732
|
jsx("button", {
|
|
711
733
|
type: "button",
|
|
712
|
-
css: [fg('platform_editor_controls_sticky_controls') ? dragHandleButtonStyles : dragHandleButtonStylesOld, editorExperiment('platform_editor_controls', 'variant1') && dragHandleColor,
|
|
734
|
+
css: [editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_sticky_controls') ? dragHandleButtonStyles : dragHandleButtonStylesOld, editorExperiment('platform_editor_controls', 'variant1') && dragHandleColor,
|
|
713
735
|
// ED-26266: Fixed the drag handle highlight when selecting multiple line in Firefox
|
|
714
736
|
// See https://product-fabric.atlassian.net/browse/ED-26266
|
|
715
737
|
browser.gecko && fg('platform_editor_dnd_handle_highlight_fix_firefox') && dragHandleMultiLineSelectionFixFirefox, editorExperiment('advanced_layouts', true) && isLayoutColumn && layoutColumnDragHandleStyles, dragHandleSelected && selectedStyles],
|
|
716
738
|
ref: buttonRef
|
|
717
739
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
718
740
|
,
|
|
719
|
-
style: !fg('platform_editor_controls_sticky_controls') && positionStyles || {},
|
|
741
|
+
style: !(editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_sticky_controls')) && positionStyles || {},
|
|
720
742
|
onClick: handleOnClick,
|
|
721
743
|
onMouseDown: handleMouseDown,
|
|
722
744
|
onKeyDown: handleKeyDown
|
|
@@ -727,7 +749,6 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
727
749
|
"data-editor-block-ctrl-drag-handle": true,
|
|
728
750
|
"data-testid": "block-ctrl-drag-handle"
|
|
729
751
|
}, jsx(Box, {
|
|
730
|
-
as: "span",
|
|
731
752
|
xcss: iconWrapperStyles
|
|
732
753
|
// eslint-disable-next-line @atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop
|
|
733
754
|
,
|
|
@@ -749,7 +770,7 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
749
770
|
as: "span",
|
|
750
771
|
testId: "block-ctrl-drag-handle-container"
|
|
751
772
|
}, jsx("span", {
|
|
752
|
-
css: [tooltipContainerStyles, fg('platform_editor_controls_patch_4') && tooltipContainerStylesStickyHeader, fg('platform_editor_controls_patch_4') && tooltipContainerStylesStickyHeaderWithMarksFix]
|
|
773
|
+
css: [shouldMaskNodeControls(nodeType, isTopLevelNode) ? tooltipContainerStylesWithNodeControls : tooltipContainerStyles, fg('platform_editor_controls_patch_4') && tooltipContainerStylesStickyHeader, fg('platform_editor_controls_patch_4') && tooltipContainerStylesStickyHeaderWithMarksFix]
|
|
753
774
|
}, jsx(Tooltip, {
|
|
754
775
|
content: jsx(TooltipContentWithMultipleShortcuts, {
|
|
755
776
|
helpDescriptors: helpDescriptors
|
|
@@ -762,7 +783,11 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
762
783
|
priority: 'important'
|
|
763
784
|
});
|
|
764
785
|
}
|
|
765
|
-
},
|
|
786
|
+
}, jsx("span", {
|
|
787
|
+
css:
|
|
788
|
+
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
789
|
+
shouldMaskNodeControls(nodeType, isTopLevelNode) && extendedIconWrapperStyles
|
|
790
|
+
}, renderButton()))));
|
|
766
791
|
};
|
|
767
792
|
var stickyWithoutTooltip = function stickyWithoutTooltip() {
|
|
768
793
|
return jsx(Box
|
|
@@ -773,8 +798,12 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
773
798
|
as: "span",
|
|
774
799
|
testId: "block-ctrl-drag-handle-container"
|
|
775
800
|
}, jsx("span", {
|
|
776
|
-
css: [tooltipContainerStyles, fg('platform_editor_controls_patch_4') && tooltipContainerStylesStickyHeader, fg('platform_editor_controls_patch_4') && tooltipContainerStylesStickyHeaderWithMarksFix]
|
|
777
|
-
},
|
|
801
|
+
css: [shouldMaskNodeControls(nodeType, isTopLevelNode) ? tooltipContainerStylesWithNodeControls : tooltipContainerStyles, fg('platform_editor_controls_patch_4') && tooltipContainerStylesStickyHeader, fg('platform_editor_controls_patch_4') && tooltipContainerStylesStickyHeaderWithMarksFix]
|
|
802
|
+
}, jsx("span", {
|
|
803
|
+
css:
|
|
804
|
+
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
805
|
+
shouldMaskNodeControls(nodeType, isTopLevelNode) && extendedIconWrapperStyles
|
|
806
|
+
}, renderButton())));
|
|
778
807
|
};
|
|
779
808
|
var buttonWithTooltip = function buttonWithTooltip() {
|
|
780
809
|
return jsx(Tooltip, {
|
|
@@ -793,7 +822,7 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
793
822
|
var isTooltip = !dragHandleDisabled && fg('platform_editor_element_drag_and_drop_ed_23873');
|
|
794
823
|
var stickyRender = isTooltip ? stickyWithTooltip() : stickyWithoutTooltip();
|
|
795
824
|
var render = isTooltip ? buttonWithTooltip() : renderButton();
|
|
796
|
-
return fg('platform_editor_controls_sticky_controls') ? stickyRender : render;
|
|
825
|
+
return editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_sticky_controls') ? stickyRender : render;
|
|
797
826
|
};
|
|
798
827
|
export var DragHandleWithVisibility = function DragHandleWithVisibility(_ref8) {
|
|
799
828
|
var view = _ref8.view,
|
|
@@ -303,7 +303,7 @@ export var TypeAheadControl = function TypeAheadControl(_ref) {
|
|
|
303
303
|
testId: "editor-quick-insert-button",
|
|
304
304
|
type: "button",
|
|
305
305
|
"aria-label": formatMessage(messages.insert),
|
|
306
|
-
xcss: [fg('platform_editor_controls_sticky_controls') ?
|
|
306
|
+
xcss: [fg('platform_editor_controls_sticky_controls') ? stickyButtonStyles : buttonStyles, isTypeAheadOpen && !fg('platform_editor_controls_widget_visibility') ? disabledStyles : undefined],
|
|
307
307
|
onClick: handleQuickInsert,
|
|
308
308
|
onMouseDown: handleMouseDown,
|
|
309
309
|
isDisabled: !fg('platform_editor_controls_widget_visibility') && isTypeAheadOpen
|
|
@@ -50,6 +50,7 @@ export interface PluginState {
|
|
|
50
50
|
multiSelectDnD?: MultiSelectDnD;
|
|
51
51
|
isShiftDown?: boolean;
|
|
52
52
|
lastDragCancelled: boolean;
|
|
53
|
+
isSelectedViaDragHandle?: boolean;
|
|
53
54
|
}
|
|
54
55
|
export type ReleaseHiddenDecoration = () => boolean | undefined;
|
|
55
56
|
export type BlockControlsSharedState = {
|
|
@@ -61,6 +62,7 @@ export type BlockControlsSharedState = {
|
|
|
61
62
|
multiSelectDnD?: MultiSelectDnD;
|
|
62
63
|
isShiftDown?: boolean;
|
|
63
64
|
isEditing?: boolean;
|
|
65
|
+
isSelectedViaDragHandle?: boolean;
|
|
64
66
|
} | undefined;
|
|
65
67
|
export type HandleOptions = {
|
|
66
68
|
isFocused: boolean;
|
|
@@ -101,6 +103,7 @@ export type BlockControlsPlugin = NextEditorPlugin<'blockControls', {
|
|
|
101
103
|
}) => EditorCommand;
|
|
102
104
|
setNodeDragged: (getPos: () => number | undefined, anchorName: string, nodeType: string) => EditorCommand;
|
|
103
105
|
setMultiSelectPositions: (anchor?: number, head?: number) => EditorCommand;
|
|
106
|
+
setSelectedViaDragHandle: (isSelectedViaDragHandle?: boolean) => EditorCommand;
|
|
104
107
|
};
|
|
105
108
|
}>;
|
|
106
109
|
export type BlockControlsMeta = {
|
|
@@ -27,5 +27,6 @@ export declare const apply: (api: ExtractInjectionAPI<BlockControlsPlugin> | und
|
|
|
27
27
|
multiSelectDnD: import("../blockControlsPluginType").MultiSelectDnD | undefined;
|
|
28
28
|
isShiftDown: any;
|
|
29
29
|
lastDragCancelled: any;
|
|
30
|
+
isSelectedViaDragHandle: boolean;
|
|
30
31
|
};
|
|
31
32
|
export declare const createPlugin: (api: ExtractInjectionAPI<BlockControlsPlugin> | undefined, getIntl: () => IntlShape, nodeViewPortalProviderAPI: PortalProviderAPI) => SafePlugin<PluginState>;
|
|
@@ -9,3 +9,4 @@ export declare const getControlBottomCSSValue: (anchor: string, isSticky: boolea
|
|
|
9
9
|
export declare const getControlHeightCSSValue: (nodeHeight: number, isSticky: boolean, isTopLevelNode: boolean, fallbackPxHeight: string, isLayoutColumn?: boolean) => {
|
|
10
10
|
height: string;
|
|
11
11
|
};
|
|
12
|
+
export declare const shouldMaskNodeControls: (nodeType: string, isTopLevelNode: boolean) => boolean;
|
|
@@ -22,6 +22,7 @@ export declare const DRAG_HANDLE_PARAGRAPH_TOP_ADJUSTMENT = 2;
|
|
|
22
22
|
* so we allow for some leniency to capture them all. e.g. Table is depth 3.
|
|
23
23
|
*/
|
|
24
24
|
export declare const DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH = 3;
|
|
25
|
+
export declare const STICKY_CONTROLS_TOP_MARGIN = 8;
|
|
25
26
|
export declare const QUICK_INSERT_HEIGHT = 24;
|
|
26
27
|
export declare const QUICK_INSERT_WIDTH = 24;
|
|
27
28
|
export declare const QUICK_INSERT_DIMENSIONS: {
|
|
@@ -50,6 +50,7 @@ export interface PluginState {
|
|
|
50
50
|
multiSelectDnD?: MultiSelectDnD;
|
|
51
51
|
isShiftDown?: boolean;
|
|
52
52
|
lastDragCancelled: boolean;
|
|
53
|
+
isSelectedViaDragHandle?: boolean;
|
|
53
54
|
}
|
|
54
55
|
export type ReleaseHiddenDecoration = () => boolean | undefined;
|
|
55
56
|
export type BlockControlsSharedState = {
|
|
@@ -61,6 +62,7 @@ export type BlockControlsSharedState = {
|
|
|
61
62
|
multiSelectDnD?: MultiSelectDnD;
|
|
62
63
|
isShiftDown?: boolean;
|
|
63
64
|
isEditing?: boolean;
|
|
65
|
+
isSelectedViaDragHandle?: boolean;
|
|
64
66
|
} | undefined;
|
|
65
67
|
export type HandleOptions = {
|
|
66
68
|
isFocused: boolean;
|
|
@@ -101,6 +103,7 @@ export type BlockControlsPlugin = NextEditorPlugin<'blockControls', {
|
|
|
101
103
|
}) => EditorCommand;
|
|
102
104
|
setNodeDragged: (getPos: () => number | undefined, anchorName: string, nodeType: string) => EditorCommand;
|
|
103
105
|
setMultiSelectPositions: (anchor?: number, head?: number) => EditorCommand;
|
|
106
|
+
setSelectedViaDragHandle: (isSelectedViaDragHandle?: boolean) => EditorCommand;
|
|
104
107
|
};
|
|
105
108
|
}>;
|
|
106
109
|
export type BlockControlsMeta = {
|
|
@@ -27,5 +27,6 @@ export declare const apply: (api: ExtractInjectionAPI<BlockControlsPlugin> | und
|
|
|
27
27
|
multiSelectDnD: import("../blockControlsPluginType").MultiSelectDnD | undefined;
|
|
28
28
|
isShiftDown: any;
|
|
29
29
|
lastDragCancelled: any;
|
|
30
|
+
isSelectedViaDragHandle: boolean;
|
|
30
31
|
};
|
|
31
32
|
export declare const createPlugin: (api: ExtractInjectionAPI<BlockControlsPlugin> | undefined, getIntl: () => IntlShape, nodeViewPortalProviderAPI: PortalProviderAPI) => SafePlugin<PluginState>;
|
|
@@ -9,3 +9,4 @@ export declare const getControlBottomCSSValue: (anchor: string, isSticky: boolea
|
|
|
9
9
|
export declare const getControlHeightCSSValue: (nodeHeight: number, isSticky: boolean, isTopLevelNode: boolean, fallbackPxHeight: string, isLayoutColumn?: boolean) => {
|
|
10
10
|
height: string;
|
|
11
11
|
};
|
|
12
|
+
export declare const shouldMaskNodeControls: (nodeType: string, isTopLevelNode: boolean) => boolean;
|
|
@@ -22,6 +22,7 @@ export declare const DRAG_HANDLE_PARAGRAPH_TOP_ADJUSTMENT = 2;
|
|
|
22
22
|
* so we allow for some leniency to capture them all. e.g. Table is depth 3.
|
|
23
23
|
*/
|
|
24
24
|
export declare const DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH = 3;
|
|
25
|
+
export declare const STICKY_CONTROLS_TOP_MARGIN = 8;
|
|
25
26
|
export declare const QUICK_INSERT_HEIGHT = 24;
|
|
26
27
|
export declare const QUICK_INSERT_WIDTH = 24;
|
|
27
28
|
export declare const QUICK_INSERT_DIMENSIONS: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.10.1",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@atlaskit/adf-schema": "^47.6.0",
|
|
36
|
-
"@atlaskit/editor-common": "^103.
|
|
36
|
+
"@atlaskit/editor-common": "^103.7.0",
|
|
37
37
|
"@atlaskit/editor-plugin-accessibility-utils": "^2.0.0",
|
|
38
38
|
"@atlaskit/editor-plugin-analytics": "^2.2.0",
|
|
39
39
|
"@atlaskit/editor-plugin-editor-disabled": "^2.0.0",
|
|
@@ -46,14 +46,14 @@
|
|
|
46
46
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
47
47
|
"@atlaskit/editor-shared-styles": "^3.4.0",
|
|
48
48
|
"@atlaskit/editor-tables": "^2.9.0",
|
|
49
|
-
"@atlaskit/icon": "^25.
|
|
49
|
+
"@atlaskit/icon": "^25.6.0",
|
|
50
50
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
51
51
|
"@atlaskit/pragmatic-drag-and-drop": "^1.5.0",
|
|
52
52
|
"@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^2.1.0",
|
|
53
53
|
"@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^3.1.0",
|
|
54
54
|
"@atlaskit/primitives": "^14.4.0",
|
|
55
55
|
"@atlaskit/theme": "^18.0.0",
|
|
56
|
-
"@atlaskit/tmp-editor-statsig": "^4.
|
|
56
|
+
"@atlaskit/tmp-editor-statsig": "^4.9.0",
|
|
57
57
|
"@atlaskit/tokens": "^4.7.0",
|
|
58
58
|
"@atlaskit/tooltip": "^20.0.0",
|
|
59
59
|
"@babel/runtime": "^7.0.0",
|
|
@@ -172,6 +172,9 @@
|
|
|
172
172
|
},
|
|
173
173
|
"platform_editor_controls_patch_4": {
|
|
174
174
|
"type": "boolean"
|
|
175
|
+
},
|
|
176
|
+
"platform_editor_controls_patch_5": {
|
|
177
|
+
"type": "boolean"
|
|
175
178
|
}
|
|
176
179
|
}
|
|
177
180
|
}
|