@atlaskit/editor-plugin-block-controls 17.1.1 → 17.1.2
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 +9 -0
- package/dist/cjs/blockControlsPlugin.js +14 -6
- package/dist/cjs/pm-plugins/main.js +14 -6
- package/dist/cjs/ui/block-controls-surface-context.js +2 -1
- package/dist/cjs/ui/block-controls-surface-drag-handle-registration.js +37 -0
- package/dist/cjs/ui/block-controls-surface-drag-handle-utils.js +45 -0
- package/dist/cjs/ui/block-controls-surface-drag-handle.compiled.css +32 -0
- package/dist/cjs/ui/block-controls-surface-drag-handle.js +296 -0
- package/dist/cjs/ui/block-controls-surface.compiled.css +2 -1
- package/dist/cjs/ui/block-controls-surface.js +49 -24
- package/dist/cjs/ui/consts.js +2 -1
- package/dist/cjs/ui/surface-editor-view-context.js +12 -0
- package/dist/cjs/ui/use-block-controls-surface-drag-source.js +172 -0
- package/dist/cjs/ui/utils/get-surface-placement.js +8 -1
- package/dist/es2019/blockControlsPlugin.js +13 -6
- package/dist/es2019/pm-plugins/main.js +14 -7
- package/dist/es2019/ui/block-controls-surface-context.js +2 -2
- package/dist/es2019/ui/block-controls-surface-drag-handle-registration.js +26 -0
- package/dist/es2019/ui/block-controls-surface-drag-handle-utils.js +33 -0
- package/dist/es2019/ui/block-controls-surface-drag-handle.compiled.css +32 -0
- package/dist/es2019/ui/block-controls-surface-drag-handle.js +282 -0
- package/dist/es2019/ui/block-controls-surface.compiled.css +2 -1
- package/dist/es2019/ui/block-controls-surface.js +48 -22
- package/dist/es2019/ui/consts.js +1 -0
- package/dist/es2019/ui/surface-editor-view-context.js +4 -0
- package/dist/es2019/ui/use-block-controls-surface-drag-source.js +170 -0
- package/dist/es2019/ui/utils/get-surface-placement.js +15 -6
- package/dist/esm/blockControlsPlugin.js +14 -6
- package/dist/esm/pm-plugins/main.js +14 -6
- package/dist/esm/ui/block-controls-surface-context.js +2 -1
- package/dist/esm/ui/block-controls-surface-drag-handle-registration.js +30 -0
- package/dist/esm/ui/block-controls-surface-drag-handle-utils.js +38 -0
- package/dist/esm/ui/block-controls-surface-drag-handle.compiled.css +32 -0
- package/dist/esm/ui/block-controls-surface-drag-handle.js +290 -0
- package/dist/esm/ui/block-controls-surface.compiled.css +2 -1
- package/dist/esm/ui/block-controls-surface.js +49 -24
- package/dist/esm/ui/consts.js +1 -0
- package/dist/esm/ui/surface-editor-view-context.js +6 -0
- package/dist/esm/ui/use-block-controls-surface-drag-source.js +166 -0
- package/dist/esm/ui/utils/get-surface-placement.js +9 -2
- package/dist/types/pm-plugins/main.d.ts +6 -1
- package/dist/types/ui/block-controls-surface-context.d.ts +1 -1
- package/dist/types/ui/block-controls-surface-drag-handle-registration.d.ts +6 -0
- package/dist/types/ui/block-controls-surface-drag-handle-utils.d.ts +14 -0
- package/dist/types/ui/block-controls-surface-drag-handle.d.ts +10 -0
- package/dist/types/ui/block-controls-surface.d.ts +1 -0
- package/dist/types/ui/consts.d.ts +1 -0
- package/dist/types/ui/surface-editor-view-context.d.ts +5 -0
- package/dist/types/ui/use-block-controls-surface-drag-source.d.ts +19 -0
- package/dist/types/ui/utils/get-surface-placement.d.ts +1 -1
- package/package.json +3 -2
|
@@ -26,16 +26,12 @@ var _visibilityContainer = require("./visibility-container");
|
|
|
26
26
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
27
27
|
var BLOCK_CONTROLS_SURFACE_Z_INDEX = 100;
|
|
28
28
|
var surfaceStyles = null;
|
|
29
|
-
var
|
|
30
|
-
var _api$uiControlRegistr, _api$uiControlRegistr2;
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return {
|
|
36
|
-
activeNode: (_states$blockControls = states.blockControlsState) === null || _states$blockControls === void 0 ? void 0 : _states$blockControls.activeNode
|
|
37
|
-
};
|
|
38
|
-
}).activeNode;
|
|
29
|
+
var BlockControlsSurfaceAtTarget = function BlockControlsSurfaceAtTarget(_ref) {
|
|
30
|
+
var _api$uiControlRegistr, _api$uiControlRegistr2, _activeNode$handleOpt;
|
|
31
|
+
var activeNode = _ref.activeNode,
|
|
32
|
+
api = _ref.api,
|
|
33
|
+
editorView = _ref.editorView,
|
|
34
|
+
target = _ref.target;
|
|
39
35
|
var _useState = (0, _react.useState)(),
|
|
40
36
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
41
37
|
position = _useState2[0],
|
|
@@ -43,8 +39,8 @@ var BlockControlsSurface = exports.BlockControlsSurface = function BlockControls
|
|
|
43
39
|
var animationFrameRef = (0, _react.useRef)(undefined);
|
|
44
40
|
var components = (_api$uiControlRegistr = (_api$uiControlRegistr2 = api.uiControlRegistry) === null || _api$uiControlRegistr2 === void 0 ? void 0 : _api$uiControlRegistr2.actions.getComponents(_surfaceKeys.BLOCK_CONTROLS_LEFT_SURFACE)) !== null && _api$uiControlRegistr !== void 0 ? _api$uiControlRegistr : [];
|
|
45
41
|
var blockControlsContext = (0, _react.useMemo)(function () {
|
|
46
|
-
return (0, _blockControlsSurfaceContext.createBlockControlsSurfaceContext)(editorView, activeNode);
|
|
47
|
-
}, [activeNode, editorView]);
|
|
42
|
+
return (0, _blockControlsSurfaceContext.createBlockControlsSurfaceContext)(editorView, activeNode, target);
|
|
43
|
+
}, [activeNode, editorView, target]);
|
|
48
44
|
var surfaceContext = (0, _react.useMemo)(function () {
|
|
49
45
|
return blockControlsContext ? (0, _types.createSurfaceContext)(_blockControlUiContext.BLOCK_CONTROL_UI_CONTEXT, blockControlsContext) : undefined;
|
|
50
46
|
}, [blockControlsContext]);
|
|
@@ -54,29 +50,29 @@ var BlockControlsSurface = exports.BlockControlsSurface = function BlockControls
|
|
|
54
50
|
setPosition(undefined);
|
|
55
51
|
return;
|
|
56
52
|
}
|
|
57
|
-
var
|
|
58
|
-
var
|
|
59
|
-
if (!
|
|
53
|
+
var targetNodeElement = editorView.nodeDOM(blockControlsContext.targetNode.pos);
|
|
54
|
+
var targetElementRoot = targetNodeElement instanceof HTMLElement ? targetNodeElement : targetNodeElement === null || targetNodeElement === void 0 ? void 0 : targetNodeElement.parentElement;
|
|
55
|
+
if (!targetElementRoot) {
|
|
60
56
|
setPosition(undefined);
|
|
61
57
|
return;
|
|
62
58
|
}
|
|
63
|
-
var targetElement = (0, _getNodeContentElement.getNodeContentElement)(
|
|
59
|
+
var targetElement = (0, _getNodeContentElement.getNodeContentElement)(targetElementRoot, blockControlsContext.targetNode.type.name);
|
|
64
60
|
var offsetParent = editorView.dom.offsetParent;
|
|
65
61
|
var isDocumentOffsetParent = !offsetParent || offsetParent === ((_getDocument = (0, _browserApis.getDocument)()) === null || _getDocument === void 0 ? void 0 : _getDocument.body);
|
|
66
62
|
var scrollingOffsetParent = offsetParent instanceof HTMLElement && !isDocumentOffsetParent ? offsetParent : undefined;
|
|
67
63
|
var updatePosition = function updatePosition() {
|
|
68
|
-
var
|
|
64
|
+
var _targetElementRoot$ge, _scrollingOffsetParen, _scrollingOffsetParen2;
|
|
69
65
|
animationFrameRef.current = undefined;
|
|
70
|
-
if (!
|
|
66
|
+
if (!targetElementRoot.isConnected || !targetElement.isConnected) {
|
|
71
67
|
setPosition(undefined);
|
|
72
68
|
return;
|
|
73
69
|
}
|
|
74
70
|
var placement = (0, _getSurfacePlacement.getSurfacePlacement)({
|
|
75
|
-
layout: (
|
|
71
|
+
layout: (_targetElementRoot$ge = targetElementRoot.getAttribute('layout')) !== null && _targetElementRoot$ge !== void 0 ? _targetElementRoot$ge : '',
|
|
76
72
|
nodeRect: targetElement.getBoundingClientRect(),
|
|
77
|
-
nodeType: blockControlsContext.
|
|
78
|
-
nodeTypeWithLevel: (0, _decorationsCommon.getNodeTypeWithLevel)(blockControlsContext.
|
|
79
|
-
parentNodeType: blockControlsContext.
|
|
73
|
+
nodeType: blockControlsContext.targetNode.type.name,
|
|
74
|
+
nodeTypeWithLevel: (0, _decorationsCommon.getNodeTypeWithLevel)(blockControlsContext.targetNode.node),
|
|
75
|
+
parentNodeType: blockControlsContext.targetNode.parentType === 'doc' ? undefined : blockControlsContext.targetNode.parentType
|
|
80
76
|
});
|
|
81
77
|
var offsetParentRect = offsetParent === null || offsetParent === void 0 ? void 0 : offsetParent.getBoundingClientRect();
|
|
82
78
|
var offsetParentScrollTop = (_scrollingOffsetParen = scrollingOffsetParent === null || scrollingOffsetParent === void 0 ? void 0 : scrollingOffsetParent.scrollTop) !== null && _scrollingOffsetParen !== void 0 ? _scrollingOffsetParen : window.scrollY;
|
|
@@ -144,17 +140,46 @@ var BlockControlsSurface = exports.BlockControlsSurface = function BlockControls
|
|
|
144
140
|
return null;
|
|
145
141
|
}
|
|
146
142
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
143
|
+
"data-editor-block-controls-surface": true
|
|
147
144
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Placement is resolved from the active node's runtime DOM geometry.
|
|
145
|
+
,
|
|
148
146
|
style: position,
|
|
149
|
-
"data-testid":
|
|
150
|
-
className: (0, _runtime.ax)(["_1e0c1txw _kqswstnw _1pbyb4wl"])
|
|
147
|
+
"data-testid": target === 'root' ? 'block-controls-left-surface' : 'block-controls-left-surface-active',
|
|
148
|
+
className: (0, _runtime.ax)(["_zulpv77o _4cvr1h6o _1e0c1txw _kqswstnw _1pbyb4wl"])
|
|
151
149
|
}, /*#__PURE__*/_react.default.createElement(_visibilityContainer.VisibilityContainer, {
|
|
152
150
|
api: api,
|
|
153
151
|
controlSide: "left",
|
|
152
|
+
forceVisibleOnMouseOut: Boolean((_activeNode$handleOpt = activeNode.handleOptions) === null || _activeNode$handleOpt === void 0 ? void 0 : _activeNode$handleOpt.isFocused),
|
|
154
153
|
shouldUseDisplayContents: true
|
|
155
154
|
}, /*#__PURE__*/_react.default.createElement(_surfaceRenderer.SurfaceRenderer, {
|
|
156
155
|
components: components,
|
|
157
156
|
surface: _surfaceKeys.BLOCK_CONTROLS_LEFT_SURFACE,
|
|
158
157
|
surfaceContext: surfaceContext
|
|
159
158
|
})));
|
|
159
|
+
};
|
|
160
|
+
var BlockControlsSurface = exports.BlockControlsSurface = function BlockControlsSurface(_ref2) {
|
|
161
|
+
var _activeNode$rootPos;
|
|
162
|
+
var api = _ref2.api,
|
|
163
|
+
editorView = _ref2.editorView;
|
|
164
|
+
var activeNode = (0, _hooks.useSharedPluginStateWithSelector)(api, ['blockControls'], function (states) {
|
|
165
|
+
var _states$blockControls;
|
|
166
|
+
return {
|
|
167
|
+
activeNode: (_states$blockControls = states.blockControlsState) === null || _states$blockControls === void 0 ? void 0 : _states$blockControls.activeNode
|
|
168
|
+
};
|
|
169
|
+
}).activeNode;
|
|
170
|
+
if (!activeNode) {
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
var rootPos = (_activeNode$rootPos = activeNode.rootPos) !== null && _activeNode$rootPos !== void 0 ? _activeNode$rootPos : activeNode.pos;
|
|
174
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(BlockControlsSurfaceAtTarget, {
|
|
175
|
+
activeNode: activeNode,
|
|
176
|
+
api: api,
|
|
177
|
+
editorView: editorView,
|
|
178
|
+
target: "root"
|
|
179
|
+
}), rootPos !== activeNode.pos ? /*#__PURE__*/_react.default.createElement(BlockControlsSurfaceAtTarget, {
|
|
180
|
+
activeNode: activeNode,
|
|
181
|
+
api: api,
|
|
182
|
+
editorView: editorView,
|
|
183
|
+
target: "active"
|
|
184
|
+
}) : null);
|
|
160
185
|
};
|
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.STICKY_CONTROLS_TOP_MARGIN_FOR_STICKY_HEADER = 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_WRAPPED_MEDIA_EMBED_TOP_ADJUSTMENT = exports.DRAG_HANDLE_SYNCED_BLOCK_GAP = exports.DRAG_HANDLE_PARAGRAPH_TOP_ADJUSTMENT = exports.DRAG_HANDLE_PARAGRAPH_SMALL_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.ACTIVE_QUICK_INSERT_FALLBACK_ANCHOR_NAME = exports.ACTIVE_QUICK_INSERT_ATTR = exports.ACTIVE_DRAG_HANDLE_FALLBACK_ANCHOR_NAME = exports.ACTIVE_DRAG_HANDLE_ATTR = void 0;
|
|
7
|
+
exports.topPositionAdjustment = exports.spacingBetweenNodesForPreview = exports.spaceLookupMap = exports.rootElementGap = exports.nodeMargins = exports.getNestedNodeLeftPaddingMargin = exports.dropTargetMarginMap = exports.dragHandleGap = exports.STICKY_CONTROLS_TOP_MARGIN_FOR_STICKY_HEADER = 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_WRAPPED_MEDIA_EMBED_TOP_ADJUSTMENT = exports.DRAG_HANDLE_SYNCED_BLOCK_GAP = exports.DRAG_HANDLE_PARAGRAPH_TOP_ADJUSTMENT = exports.DRAG_HANDLE_PARAGRAPH_SMALL_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_CONTROLS_SURFACE_SELECTOR = exports.ACTIVE_QUICK_INSERT_FALLBACK_ANCHOR_NAME = exports.ACTIVE_QUICK_INSERT_ATTR = exports.ACTIVE_DRAG_HANDLE_FALLBACK_ANCHOR_NAME = exports.ACTIVE_DRAG_HANDLE_ATTR = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
10
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
@@ -17,6 +17,7 @@ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
|
17
17
|
var _dropTargetMarginMap;
|
|
18
18
|
var ACTIVE_DRAG_HANDLE_ATTR = exports.ACTIVE_DRAG_HANDLE_ATTR = 'data-active-drag-handle';
|
|
19
19
|
var ACTIVE_QUICK_INSERT_ATTR = exports.ACTIVE_QUICK_INSERT_ATTR = 'data-active-quick-insert';
|
|
20
|
+
var BLOCK_CONTROLS_SURFACE_SELECTOR = exports.BLOCK_CONTROLS_SURFACE_SELECTOR = '[data-editor-block-controls-surface]';
|
|
20
21
|
var ACTIVE_DRAG_HANDLE_FALLBACK_ANCHOR_NAME = exports.ACTIVE_DRAG_HANDLE_FALLBACK_ANCHOR_NAME = '--editor-block-controls-active-drag-handle-anchor';
|
|
21
22
|
var ACTIVE_QUICK_INSERT_FALLBACK_ANCHOR_NAME = exports.ACTIVE_QUICK_INSERT_FALLBACK_ANCHOR_NAME = '--editor-block-controls-active-quick-insert-anchor';
|
|
22
23
|
var DRAG_HANDLE_HEIGHT = exports.DRAG_HANDLE_HEIGHT = 24;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useSurfaceEditorView = exports.SurfaceEditorViewContext = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
/** Provides registered block-control surface contributors with their owning editor view. */
|
|
9
|
+
var SurfaceEditorViewContext = exports.SurfaceEditorViewContext = /*#__PURE__*/(0, _react.createContext)(undefined);
|
|
10
|
+
var useSurfaceEditorView = exports.useSurfaceEditorView = function useSurfaceEditorView() {
|
|
11
|
+
return (0, _react.useContext)(SurfaceEditorViewContext);
|
|
12
|
+
};
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useBlockControlsSurfaceDragSource = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
9
|
+
var _performanceMeasures = require("@atlaskit/editor-common/performance-measures");
|
|
10
|
+
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
11
|
+
var _elementAdapter = require("@atlaskit/pragmatic-drag-and-drop/adapter/element-adapter");
|
|
12
|
+
var _setCustomNativeDragPreview = require("@atlaskit/pragmatic-drag-and-drop/utils/set-custom-native-drag-preview");
|
|
13
|
+
var _activeAnchorTracker = require("../pm-plugins/utils/active-anchor-tracker");
|
|
14
|
+
var _analytics2 = require("../pm-plugins/utils/analytics");
|
|
15
|
+
var _getSelection = require("../pm-plugins/utils/getSelection");
|
|
16
|
+
var _dragPreview = require("./drag-preview");
|
|
17
|
+
var _blockControlsSurfaceDragHandleUtils = require("./block-controls-surface-drag-handle-utils");
|
|
18
|
+
var EDITOR_BLOCKS_DRAG_INIT = 'Editor Blocks Drag Initialization Time';
|
|
19
|
+
/**
|
|
20
|
+
* Registry surface drag source. This intentionally duplicates the stable widget handle's drag
|
|
21
|
+
* contract so the legacy implementation remains byte-for-byte unchanged during migration.
|
|
22
|
+
*/
|
|
23
|
+
var useBlockControlsSurfaceDragSource = exports.useBlockControlsSurfaceDragSource = function useBlockControlsSurfaceDragSource(_ref) {
|
|
24
|
+
var api = _ref.api,
|
|
25
|
+
elementRef = _ref.elementRef,
|
|
26
|
+
getAnchorName = _ref.getAnchorName,
|
|
27
|
+
getPos = _ref.getPos,
|
|
28
|
+
nodeType = _ref.nodeType,
|
|
29
|
+
start = _ref.start,
|
|
30
|
+
view = _ref.view;
|
|
31
|
+
(0, _react.useEffect)(function () {
|
|
32
|
+
var element = elementRef.current;
|
|
33
|
+
if (!element || !view) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
return (0, _elementAdapter.draggable)({
|
|
37
|
+
element: element,
|
|
38
|
+
getInitialData: function getInitialData() {
|
|
39
|
+
return {
|
|
40
|
+
type: 'element',
|
|
41
|
+
start: start
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
onGenerateDragPreview: function onGenerateDragPreview(_ref2) {
|
|
45
|
+
var _api$core, _api$blockControls$sh;
|
|
46
|
+
var nativeSetDragImage = _ref2.nativeSetDragImage;
|
|
47
|
+
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref3) {
|
|
48
|
+
var tr = _ref3.tr;
|
|
49
|
+
var handlePos = getPos();
|
|
50
|
+
if (typeof handlePos !== 'number') {
|
|
51
|
+
return tr;
|
|
52
|
+
}
|
|
53
|
+
if (!tr.selection.empty && (0, _getSelection.isHandleCorrelatedToSelection)(view.state, tr.selection, handlePos)) {
|
|
54
|
+
var _api$blockControls;
|
|
55
|
+
api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || _api$blockControls.commands.setMultiSelectPositions()({
|
|
56
|
+
tr: tr
|
|
57
|
+
});
|
|
58
|
+
} else {
|
|
59
|
+
tr = (0, _getSelection.selectNode)(tr, handlePos, nodeType, api);
|
|
60
|
+
}
|
|
61
|
+
return tr;
|
|
62
|
+
});
|
|
63
|
+
var startPos = getPos();
|
|
64
|
+
var _view$state = view.state,
|
|
65
|
+
doc = _view$state.doc,
|
|
66
|
+
selection = _view$state.selection;
|
|
67
|
+
var sliceFrom = selection.from;
|
|
68
|
+
var sliceTo = selection.to;
|
|
69
|
+
var multiSelect = api === null || api === void 0 || (_api$blockControls$sh = api.blockControls.sharedState.currentState()) === null || _api$blockControls$sh === void 0 ? void 0 : _api$blockControls$sh.multiSelectDnD;
|
|
70
|
+
if (multiSelect) {
|
|
71
|
+
sliceFrom = Math.min(multiSelect.anchor, multiSelect.head);
|
|
72
|
+
sliceTo = Math.max(multiSelect.anchor, multiSelect.head);
|
|
73
|
+
}
|
|
74
|
+
var expandedSlice = doc.slice(sliceFrom, sliceTo);
|
|
75
|
+
var isDraggingMultipleNodes = startPos !== undefined && startPos >= sliceFrom && startPos < sliceTo && expandedSlice.content.childCount > 1;
|
|
76
|
+
(0, _setCustomNativeDragPreview.setCustomNativeDragPreview)({
|
|
77
|
+
getOffset: function getOffset() {
|
|
78
|
+
if (!isDraggingMultipleNodes || startPos === undefined) {
|
|
79
|
+
return {
|
|
80
|
+
x: 0,
|
|
81
|
+
y: 0
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
var domAtPos = view.domAtPos.bind(view);
|
|
85
|
+
var heightBeforeHandle = 0;
|
|
86
|
+
var nodeStart = sliceFrom;
|
|
87
|
+
var activeNodeMarginTop = 0;
|
|
88
|
+
for (var index = 0; index < expandedSlice.content.childCount; index++) {
|
|
89
|
+
var _node$nodeSize;
|
|
90
|
+
var node = expandedSlice.content.maybeChild(index);
|
|
91
|
+
var nodeEnd = nodeStart + ((_node$nodeSize = node === null || node === void 0 ? void 0 : node.nodeSize) !== null && _node$nodeSize !== void 0 ? _node$nodeSize : 0);
|
|
92
|
+
if (nodeEnd <= startPos) {
|
|
93
|
+
var nodeElement = (0, _utils.findDomRefAtPos)(nodeStart, domAtPos);
|
|
94
|
+
var margins = (0, _blockControlsSurfaceDragHandleUtils.getNodeMarginsForDragPreview)(node);
|
|
95
|
+
heightBeforeHandle += (nodeElement instanceof HTMLElement ? nodeElement.offsetHeight : 0) + margins.top + margins.bottom;
|
|
96
|
+
} else {
|
|
97
|
+
activeNodeMarginTop = (0, _blockControlsSurfaceDragHandleUtils.getNodeMarginsForDragPreview)(node).top;
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
nodeStart = nodeEnd;
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
x: 0,
|
|
104
|
+
y: heightBeforeHandle + activeNodeMarginTop
|
|
105
|
+
};
|
|
106
|
+
},
|
|
107
|
+
render: function render(_ref4) {
|
|
108
|
+
var container = _ref4.container;
|
|
109
|
+
if (!isDraggingMultipleNodes && startPos !== undefined) {
|
|
110
|
+
var dom = (0, _utils.findDomRefAtPos)(startPos, view.domAtPos.bind(view));
|
|
111
|
+
return dom instanceof HTMLElement ? (0, _dragPreview.dragPreview)(container, {
|
|
112
|
+
dom: dom,
|
|
113
|
+
nodeType: nodeType
|
|
114
|
+
}) : undefined;
|
|
115
|
+
}
|
|
116
|
+
var previewContent = [];
|
|
117
|
+
expandedSlice.content.descendants(function (node, pos) {
|
|
118
|
+
var dom = (0, _utils.findDomRefAtPos)(sliceFrom + pos, view.domAtPos.bind(view));
|
|
119
|
+
if (dom instanceof HTMLElement) {
|
|
120
|
+
previewContent.push({
|
|
121
|
+
dom: dom,
|
|
122
|
+
nodeSpacing: (0, _blockControlsSurfaceDragHandleUtils.getNodeSpacingForDragPreview)(node),
|
|
123
|
+
nodeType: node.type.name
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
return false;
|
|
127
|
+
});
|
|
128
|
+
return previewContent.length > 0 ? (0, _dragPreview.dragPreview)(container, previewContent) : undefined;
|
|
129
|
+
},
|
|
130
|
+
nativeSetDragImage: nativeSetDragImage
|
|
131
|
+
});
|
|
132
|
+
},
|
|
133
|
+
onDragStart: function onDragStart() {
|
|
134
|
+
var _api$core2;
|
|
135
|
+
if (start === undefined) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// This handle is outside ProseMirror, so it owns the side effects normally started by PM.
|
|
140
|
+
(0, _performanceMeasures.startMeasure)(EDITOR_BLOCKS_DRAG_INIT);
|
|
141
|
+
_activeAnchorTracker.defaultActiveAnchorTracker.reset();
|
|
142
|
+
api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(function (_ref5) {
|
|
143
|
+
var _api$blockControls$sh2, _resolvedMovingNode$n, _api$blockControls2, _api$analytics;
|
|
144
|
+
var tr = _ref5.tr;
|
|
145
|
+
var resolvedMovingNode = tr.doc.resolve(start);
|
|
146
|
+
var multiSelect = api === null || api === void 0 || (_api$blockControls$sh2 = api.blockControls.sharedState.currentState()) === null || _api$blockControls$sh2 === void 0 ? void 0 : _api$blockControls$sh2.multiSelectDnD;
|
|
147
|
+
var attributes = multiSelect ? (0, _analytics2.getMultiSelectAnalyticsAttributes)(tr, multiSelect.anchor, multiSelect.head) : {
|
|
148
|
+
hasSelectedMultipleNodes: false,
|
|
149
|
+
nodeTypes: (_resolvedMovingNode$n = resolvedMovingNode.nodeAfter) === null || _resolvedMovingNode$n === void 0 ? void 0 : _resolvedMovingNode$n.type.name
|
|
150
|
+
};
|
|
151
|
+
api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || _api$blockControls2.commands.setNodeDragged(getPos, getAnchorName(), nodeType)({
|
|
152
|
+
tr: tr
|
|
153
|
+
});
|
|
154
|
+
tr.setMeta('scrollIntoView', false);
|
|
155
|
+
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
|
|
156
|
+
action: _analytics.ACTION.DRAGGED,
|
|
157
|
+
actionSubject: _analytics.ACTION_SUBJECT.ELEMENT,
|
|
158
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.ELEMENT_DRAG_HANDLE,
|
|
159
|
+
attributes: {
|
|
160
|
+
hasSelectedMultipleNodes: attributes.hasSelectedMultipleNodes,
|
|
161
|
+
nodeDepth: resolvedMovingNode.depth,
|
|
162
|
+
nodeTypes: attributes.nodeTypes || ''
|
|
163
|
+
},
|
|
164
|
+
eventType: _analytics.EVENT_TYPE.UI
|
|
165
|
+
})(tr);
|
|
166
|
+
return tr;
|
|
167
|
+
});
|
|
168
|
+
view.focus();
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
}, [api, elementRef, getAnchorName, getPos, nodeType, start, view]);
|
|
172
|
+
};
|
|
@@ -31,9 +31,16 @@ var getSurfacePlacement = exports.getSurfacePlacement = function getSurfacePlace
|
|
|
31
31
|
nodeType = _ref2.nodeType,
|
|
32
32
|
nodeTypeWithLevel = _ref2.nodeTypeWithLevel,
|
|
33
33
|
parentNodeType = _ref2.parentNodeType;
|
|
34
|
+
if (nodeType === 'layoutColumn') {
|
|
35
|
+
return {
|
|
36
|
+
left: nodeRect.left + nodeRect.width / 2,
|
|
37
|
+
top: nodeRect.top,
|
|
38
|
+
transform: 'translate(-50%, -50%)'
|
|
39
|
+
};
|
|
40
|
+
}
|
|
34
41
|
return {
|
|
35
42
|
left: nodeRect.left,
|
|
36
43
|
top: nodeRect.top + (0, _consts.topPositionAdjustment)(nodeTypeWithLevel, layout),
|
|
37
|
-
transform: "translateX(calc(-100% - ".concat((0, _consts.dragHandleGap)(nodeType, parentNodeType)
|
|
44
|
+
transform: "translateX(calc(-100% - ".concat((0, _consts.dragHandleGap)(nodeType, parentNodeType), "px))")
|
|
38
45
|
};
|
|
39
46
|
};
|
|
@@ -23,7 +23,9 @@ import { createSelectionPreservationPlugin } from './pm-plugins/selection-preser
|
|
|
23
23
|
import { expandAndUpdateSelection } from './pm-plugins/utils/expand-and-update-selection';
|
|
24
24
|
import { selectNode } from './pm-plugins/utils/getSelection';
|
|
25
25
|
import { BlockControlsSurface } from './ui/block-controls-surface';
|
|
26
|
+
import { getBlockControlsSurfaceDragHandleComponents } from './ui/block-controls-surface-drag-handle-registration';
|
|
26
27
|
import { GlobalStylesWrapper } from './ui/global-styles';
|
|
28
|
+
import { SurfaceEditorViewContext } from './ui/surface-editor-view-context';
|
|
27
29
|
export const blockControlsPlugin = ({
|
|
28
30
|
api,
|
|
29
31
|
config
|
|
@@ -32,8 +34,9 @@ export const blockControlsPlugin = ({
|
|
|
32
34
|
const nodeDecorationRegistry = [];
|
|
33
35
|
const rightSideControlsEnabled = (_config$rightSideCont = config === null || config === void 0 ? void 0 : config.rightSideControlsEnabled) !== null && _config$rightSideCont !== void 0 ? _config$rightSideCont : false;
|
|
34
36
|
const quickInsertButtonEnabled = (_config$quickInsertBu = config === null || config === void 0 ? void 0 : config.quickInsertButtonEnabled) !== null && _config$quickInsertBu !== void 0 ? _config$quickInsertBu : true;
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
+
const registryBlockControlsEnabled = isExperimentEnabled('platform_editor_block_control_migration');
|
|
38
|
+
const legacyBlockControlsEnabled = !registryBlockControlsEnabled;
|
|
39
|
+
if (registryBlockControlsEnabled) {
|
|
37
40
|
var _api$uiControlRegistr;
|
|
38
41
|
api === null || api === void 0 ? void 0 : (_api$uiControlRegistr = api.uiControlRegistry) === null || _api$uiControlRegistr === void 0 ? void 0 : _api$uiControlRegistr.actions.register([BLOCK_CONTROLS_LEFT_SURFACE, {
|
|
39
42
|
...BLOCK_CONTROLS_LEFT_SECTION,
|
|
@@ -47,7 +50,9 @@ export const blockControlsPlugin = ({
|
|
|
47
50
|
...BLOCK_CONTROLS_LEFT_SECTION,
|
|
48
51
|
rank: 100
|
|
49
52
|
}]
|
|
50
|
-
}
|
|
53
|
+
}, ...getBlockControlsSurfaceDragHandleComponents({
|
|
54
|
+
api
|
|
55
|
+
})]);
|
|
51
56
|
}
|
|
52
57
|
return {
|
|
53
58
|
name: 'blockControls',
|
|
@@ -117,7 +122,7 @@ export const blockControlsPlugin = ({
|
|
|
117
122
|
plugin: ({
|
|
118
123
|
getIntl,
|
|
119
124
|
nodeViewPortalProviderAPI
|
|
120
|
-
}) => createPlugin(api, getIntl, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled, quickInsertButtonEnabled &&
|
|
125
|
+
}) => createPlugin(api, getIntl, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled, quickInsertButtonEnabled && legacyBlockControlsEnabled, legacyBlockControlsEnabled)
|
|
121
126
|
}];
|
|
122
127
|
if (editorExperiment('platform_editor_controls', 'variant1')) {
|
|
123
128
|
pmPlugins.push({
|
|
@@ -431,10 +436,12 @@ export const blockControlsPlugin = ({
|
|
|
431
436
|
}) {
|
|
432
437
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(GlobalStylesWrapper, {
|
|
433
438
|
api: api
|
|
434
|
-
}),
|
|
439
|
+
}), registryBlockControlsEnabled && editorView && api ? /*#__PURE__*/React.createElement(SurfaceEditorViewContext.Provider, {
|
|
440
|
+
value: editorView
|
|
441
|
+
}, /*#__PURE__*/React.createElement(BlockControlsSurface, {
|
|
435
442
|
api: api,
|
|
436
443
|
editorView: editorView
|
|
437
|
-
}) : null);
|
|
444
|
+
})) : null);
|
|
438
445
|
}
|
|
439
446
|
};
|
|
440
447
|
};
|
|
@@ -17,6 +17,7 @@ import { combine } from '@atlaskit/pragmatic-drag-and-drop/utils/combine';
|
|
|
17
17
|
import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/adapter/element-adapter';
|
|
18
18
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
19
19
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
20
|
+
import { BLOCK_CONTROLS_SURFACE_SELECTOR } from '../ui/consts';
|
|
20
21
|
import { getAnchorAttrName } from '../ui/utils/dom-attr-name';
|
|
21
22
|
import { findNodeDecs, nodeDecorations } from './decorations-anchor';
|
|
22
23
|
import { createActiveDragHandleNodeDecoration, dragHandleDecoration, emptyParagraphNodeDecorations, findActiveDragHandleNodeDec, findHandleDec } from './decorations-drag-handle';
|
|
@@ -470,7 +471,8 @@ export const apply = (api, formatMessage, tr, currentState, newState, flags, nod
|
|
|
470
471
|
}
|
|
471
472
|
} else if (api) {
|
|
472
473
|
var _latestActiveNode5, _latestActiveNode10;
|
|
473
|
-
|
|
474
|
+
// The registry surface replaces the legacy drag-handle decorations during migration.
|
|
475
|
+
if (flags.legacyDragHandleEnabled && shouldRecreateHandle && (!rightSideControlsEnabled || !isViewMode)) {
|
|
474
476
|
var _activeNode11, _activeNode12, _latestActiveNode, _latestActiveNode2, _latestActiveNode3, _latestActiveNode4;
|
|
475
477
|
const oldHandle = findHandleDec(decorations, (_activeNode11 = activeNode) === null || _activeNode11 === void 0 ? void 0 : _activeNode11.pos, (_activeNode12 = activeNode) === null || _activeNode12 === void 0 ? void 0 : _activeNode12.pos);
|
|
476
478
|
decorations = decorations.remove(oldHandle);
|
|
@@ -487,7 +489,7 @@ export const apply = (api, formatMessage, tr, currentState, newState, flags, nod
|
|
|
487
489
|
});
|
|
488
490
|
decorations = decorations.add(newState.doc, [handleDec]);
|
|
489
491
|
}
|
|
490
|
-
if (expValEquals('platform_editor_controls_reliable_anchor', 'isEnabled', true) && latestActiveNode) {
|
|
492
|
+
if (flags.legacyDragHandleEnabled && expValEquals('platform_editor_controls_reliable_anchor', 'isEnabled', true) && latestActiveNode) {
|
|
491
493
|
// Recreate the drag handle node decoration when the active node changed,
|
|
492
494
|
// its content was modified, or the document changed (e.g. Enter splits a node).
|
|
493
495
|
// This runs independently of shouldRecreateHandle so that doc changes (like pressing
|
|
@@ -701,11 +703,13 @@ export const apply = (api, formatMessage, tr, currentState, newState, flags, nod
|
|
|
701
703
|
// remove isEmptyDoc check and let decorations render and determine their own visibility
|
|
702
704
|
// In view mode with right-side controls we render node decorations (right-edge button), not the
|
|
703
705
|
// handle - so findHandleDec is always empty. Don't clear activeNode in that case.
|
|
704
|
-
const hasHandleOrViewModeControls = findHandleDec(decorations, (_latestActiveNode11 = latestActiveNode) === null || _latestActiveNode11 === void 0 ? void 0 : _latestActiveNode11.pos, (_latestActiveNode12 = latestActiveNode) === null || _latestActiveNode12 === void 0 ? void 0 : _latestActiveNode12.pos).length > 0 || isViewMode && rightSideControlsEnabled;
|
|
705
|
-
|
|
706
|
+
const hasHandleOrViewModeControls = findHandleDec(decorations, (_latestActiveNode11 = latestActiveNode) === null || _latestActiveNode11 === void 0 ? void 0 : _latestActiveNode11.pos, (_latestActiveNode12 = latestActiveNode) === null || _latestActiveNode12 === void 0 ? void 0 : _latestActiveNode12.pos).length > 0 || isViewMode && rightSideControlsEnabled || !flags.legacyDragHandleEnabled;
|
|
707
|
+
// Keep the registry surface mounted while its Block Menu owns focus.
|
|
708
|
+
const keepActiveNodeForOpenBlockMenu = !flags.legacyDragHandleEnabled && isMenuOpen && editorExperiment('platform_editor_block_menu', true);
|
|
709
|
+
newActiveNode = meta !== null && meta !== void 0 && meta.editorBlurred && !keepActiveNodeForOpenBlockMenu || !(meta !== null && meta !== void 0 && meta.activeNode) && !hasHandleOrViewModeControls ? null : latestActiveNode;
|
|
706
710
|
} else {
|
|
707
711
|
var _latestActiveNode13, _latestActiveNode14;
|
|
708
|
-
newActiveNode = isEmptyDoc || !(meta !== null && meta !== void 0 && meta.activeNode) && findHandleDec(decorations, (_latestActiveNode13 = latestActiveNode) === null || _latestActiveNode13 === void 0 ? void 0 : _latestActiveNode13.pos, (_latestActiveNode14 = latestActiveNode) === null || _latestActiveNode14 === void 0 ? void 0 : _latestActiveNode14.pos).length === 0 ? null : latestActiveNode;
|
|
712
|
+
newActiveNode = isEmptyDoc || !(meta !== null && meta !== void 0 && meta.activeNode) && flags.legacyDragHandleEnabled && findHandleDec(decorations, (_latestActiveNode13 = latestActiveNode) === null || _latestActiveNode13 === void 0 ? void 0 : _latestActiveNode13.pos, (_latestActiveNode14 = latestActiveNode) === null || _latestActiveNode14 === void 0 ? void 0 : _latestActiveNode14.pos).length === 0 ? null : latestActiveNode;
|
|
709
713
|
}
|
|
710
714
|
let isMenuOpenNew = isMenuOpen;
|
|
711
715
|
if (editorExperiment('platform_editor_block_menu', true)) {
|
|
@@ -749,7 +753,7 @@ export const apply = (api, formatMessage, tr, currentState, newState, flags, nod
|
|
|
749
753
|
isSelectedViaDragHandle: isSelectedViaDragHandleNew
|
|
750
754
|
};
|
|
751
755
|
};
|
|
752
|
-
export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled = false, quickInsertButtonEnabled = true) => {
|
|
756
|
+
export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled = false, quickInsertButtonEnabled = true, legacyDragHandleEnabled = true) => {
|
|
753
757
|
const {
|
|
754
758
|
formatMessage
|
|
755
759
|
} = getIntl();
|
|
@@ -758,6 +762,7 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI, nodeDecora
|
|
|
758
762
|
});
|
|
759
763
|
const toolbarFlagsEnabled = areToolbarFlagsEnabled(Boolean(api === null || api === void 0 ? void 0 : api.toolbar));
|
|
760
764
|
const flags = {
|
|
765
|
+
legacyDragHandleEnabled,
|
|
761
766
|
toolbarFlagsEnabled
|
|
762
767
|
};
|
|
763
768
|
let anchorRectCache;
|
|
@@ -1010,11 +1015,13 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI, nodeDecora
|
|
|
1010
1015
|
}
|
|
1011
1016
|
if (editorExperiment('platform_editor_controls', 'variant1')) {
|
|
1012
1017
|
var _api$core2;
|
|
1018
|
+
// Focus moving into the registry surface remains inside the editor experience.
|
|
1019
|
+
const isChildOfSurface = !flags.legacyDragHandleEnabled && event.relatedTarget instanceof HTMLElement && event.relatedTarget.closest(BLOCK_CONTROLS_SURFACE_SELECTOR) !== null;
|
|
1013
1020
|
const isChildOfEditor = event.relatedTarget instanceof HTMLElement && event.relatedTarget.closest(`#${EDIT_AREA_ID}`) !== null;
|
|
1014
1021
|
|
|
1015
1022
|
// don't do anything if the event relatedTarget (the element receiving focus) is a child of the editor
|
|
1016
1023
|
// or if the editor has focus
|
|
1017
|
-
if (isChildOfEditor || view.hasFocus()) {
|
|
1024
|
+
if (isChildOfEditor || isChildOfSurface || view.hasFocus()) {
|
|
1018
1025
|
return false;
|
|
1019
1026
|
}
|
|
1020
1027
|
api === null || api === void 0 ? void 0 : (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions.execute(({
|
|
@@ -26,7 +26,7 @@ const getNodeContext = (view, pos) => {
|
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
28
|
};
|
|
29
|
-
export const createBlockControlsSurfaceContext = (view, activeNode) => {
|
|
29
|
+
export const createBlockControlsSurfaceContext = (view, activeNode, target = 'root') => {
|
|
30
30
|
var _activeNode$rootPos, _activeNode$rootNodeT;
|
|
31
31
|
if (!activeNode) {
|
|
32
32
|
return undefined;
|
|
@@ -46,6 +46,6 @@ export const createBlockControlsSurfaceContext = (view, activeNode) => {
|
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
48
|
rootNode: rootNodeContext,
|
|
49
|
-
targetNode: rootNodeContext
|
|
49
|
+
targetNode: target === 'active' ? activeNodeContext : rootNodeContext
|
|
50
50
|
};
|
|
51
51
|
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BLOCK_CONTROL_UI_CONTEXT } from '@atlaskit/editor-common/block-controls/block-control-ui-context';
|
|
3
|
+
import { BLOCK_CONTROLS_LEFT_GROUP } from '@atlaskit/editor-common/block-controls/surface-keys';
|
|
4
|
+
import { BlockControlsSurfaceDragHandle } from './block-controls-surface-drag-handle';
|
|
5
|
+
export const getBlockControlsSurfaceDragHandleComponents = ({
|
|
6
|
+
api
|
|
7
|
+
}) => [{
|
|
8
|
+
component: ({
|
|
9
|
+
surfaceContext
|
|
10
|
+
}) => /*#__PURE__*/React.createElement(BlockControlsSurfaceDragHandle, {
|
|
11
|
+
api: api,
|
|
12
|
+
surfaceContext: surfaceContext
|
|
13
|
+
}),
|
|
14
|
+
isHidden: ({
|
|
15
|
+
surfaceContext
|
|
16
|
+
} = {}) => {
|
|
17
|
+
const context = surfaceContext === null || surfaceContext === void 0 ? void 0 : surfaceContext.get(BLOCK_CONTROL_UI_CONTEXT);
|
|
18
|
+
return !(context !== null && context !== void 0 && context.activeNode) || context.targetNode.pos !== context.activeNode.pos;
|
|
19
|
+
},
|
|
20
|
+
key: 'block-controls-drag-handle',
|
|
21
|
+
parents: [{
|
|
22
|
+
...BLOCK_CONTROLS_LEFT_GROUP,
|
|
23
|
+
rank: 200
|
|
24
|
+
}],
|
|
25
|
+
type: 'button'
|
|
26
|
+
}];
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
2
|
+
import { nodeMargins, spacingBetweenNodesForPreview } from './consts';
|
|
3
|
+
export const buildLayoutColumnMenuMeta = (anchorPos, openedViaKeyboard) => ({
|
|
4
|
+
anchorPos,
|
|
5
|
+
...(fg('platform_editor_layout_column_menu_kill_switch_1') ? {
|
|
6
|
+
isOpen: true
|
|
7
|
+
} : {}),
|
|
8
|
+
openedViaKeyboard
|
|
9
|
+
});
|
|
10
|
+
export const getNodeSpacingForDragPreview = node => {
|
|
11
|
+
var _spacingBetweenNodesF2;
|
|
12
|
+
if (!node) {
|
|
13
|
+
return spacingBetweenNodesForPreview.default;
|
|
14
|
+
}
|
|
15
|
+
const nodeTypeName = node.type.name;
|
|
16
|
+
if (nodeTypeName === 'heading') {
|
|
17
|
+
var _spacingBetweenNodesF;
|
|
18
|
+
return (_spacingBetweenNodesF = spacingBetweenNodesForPreview[`heading${node.attrs.level}`]) !== null && _spacingBetweenNodesF !== void 0 ? _spacingBetweenNodesF : spacingBetweenNodesForPreview.default;
|
|
19
|
+
}
|
|
20
|
+
return (_spacingBetweenNodesF2 = spacingBetweenNodesForPreview[nodeTypeName]) !== null && _spacingBetweenNodesF2 !== void 0 ? _spacingBetweenNodesF2 : spacingBetweenNodesForPreview.default;
|
|
21
|
+
};
|
|
22
|
+
export const getNodeMarginsForDragPreview = node => {
|
|
23
|
+
var _nodeMargins$nodeType;
|
|
24
|
+
if (!node) {
|
|
25
|
+
return nodeMargins.default;
|
|
26
|
+
}
|
|
27
|
+
const nodeTypeName = node.type.name;
|
|
28
|
+
if (nodeTypeName === 'heading') {
|
|
29
|
+
var _nodeMargins;
|
|
30
|
+
return (_nodeMargins = nodeMargins[`heading${node.attrs.level}`]) !== null && _nodeMargins !== void 0 ? _nodeMargins : nodeMargins.default;
|
|
31
|
+
}
|
|
32
|
+
return (_nodeMargins$nodeType = nodeMargins[nodeTypeName]) !== null && _nodeMargins$nodeType !== void 0 ? _nodeMargins$nodeType : nodeMargins.default;
|
|
33
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
._19itglyw{border:none}
|
|
2
|
+
._1a37dfik{outline:var(--ds-border-width-focused,2px) solid var(--ds-border-focused,#4688ec)}
|
|
3
|
+
._2rko1y44{border-radius:4px}._12ji1r31{outline-color:currentColor}
|
|
4
|
+
._12y31o36{outline-width:medium}
|
|
5
|
+
._19bvze3t{padding-left:var(--ds-space-0,0)}
|
|
6
|
+
._1bah1h6o{justify-content:center}
|
|
7
|
+
._1bsb1crf{width:9pt}
|
|
8
|
+
._1bsbx5ub{width:calc(var(--ak-editor-base-font-size)*12/16)}
|
|
9
|
+
._1e0c1txw{display:flex}
|
|
10
|
+
._1p1y1j28::selection{background-color:transparent}
|
|
11
|
+
._1pbyb4wl{z-index:100}
|
|
12
|
+
._1qu2glyw{outline-style:none}
|
|
13
|
+
._2lx21bp4{flex-direction:column}
|
|
14
|
+
._4cvr1h6o{align-items:center}
|
|
15
|
+
._4t3i1myc{height:calc(var(--ak-editor-base-font-size)*24/16)}
|
|
16
|
+
._4t3i1tcg{height:24px}
|
|
17
|
+
._80om1qgj{cursor:grab}
|
|
18
|
+
._bfhk15s3{background-color:var(--ds-background-selected,#e9f2fe)}
|
|
19
|
+
._bfhksm61{background-color:var(--ds-background-neutral-subtle,#00000000)}
|
|
20
|
+
._ca0qze3t{padding-top:var(--ds-space-0,0)}
|
|
21
|
+
._cun91j28:disabled{background-color:transparent}
|
|
22
|
+
._n3tdze3t{padding-bottom:var(--ds-space-0,0)}
|
|
23
|
+
._syazdgkc{color:var(--ds-icon-subtle,#505258)}
|
|
24
|
+
._syazxl6c{color:var(--ds-icon-selected,#1868db)}
|
|
25
|
+
._t9ec14w8{transform:rotate(90deg)}
|
|
26
|
+
._u5f3ze3t{padding-right:var(--ds-space-0,0)}
|
|
27
|
+
._vbqb2sac:disabled{color:var(--ds-icon-disabled,#080f214a)}
|
|
28
|
+
._vchhusvi{box-sizing:border-box}
|
|
29
|
+
._1ygbdfik:focus-visible{outline:var(--ds-border-width-focused,2px) solid var(--ds-border-focused,#4688ec)}
|
|
30
|
+
._6g80187o:disabled:hover{background-color:var(--ds-background-disabled,#0515240f)}
|
|
31
|
+
._irr31dpa:hover{background-color:var(--ds-background-neutral-subtle-hovered,#0515240f)}
|
|
32
|
+
._1di6fcek:active{background-color:var(--ds-background-neutral-subtle-pressed,#0b120e24)}
|