@atlaskit/editor-plugin-block-controls 20.0.3 → 20.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/dist/cjs/blockControlsPlugin.js +53 -17
- package/dist/cjs/editor-commands/show-drag-handle.js +17 -5
- package/dist/cjs/pm-plugins/decorations-anchor.js +2 -1
- package/dist/cjs/pm-plugins/decorations-drop-target-active.js +2 -1
- package/dist/cjs/pm-plugins/decorations-drop-target.js +2 -1
- package/dist/cjs/pm-plugins/decorations-surface-anchor.js +72 -0
- package/dist/cjs/pm-plugins/handle-mouse-down.js +2 -1
- package/dist/cjs/pm-plugins/handle-mouse-over.js +3 -2
- package/dist/cjs/pm-plugins/handle-sparse-mouse-over.js +125 -0
- package/dist/cjs/pm-plugins/main.js +66 -54
- package/dist/cjs/pm-plugins/sparse-surfaces.js +49 -0
- package/dist/cjs/pm-plugins/utils/sparse-surface-candidates.js +419 -0
- package/dist/cjs/pm-plugins/utils/sparse-surfaces-mapping.js +108 -0
- package/dist/cjs/pm-plugins/utils/sparse-surfaces-state.js +53 -0
- package/dist/cjs/pm-plugins/utils/sparse-surfaces-view.js +134 -0
- package/dist/cjs/pm-plugins/utils/surface-viewport.js +223 -0
- package/dist/cjs/pm-plugins/utils/transactions.js +5 -0
- package/dist/cjs/ui/block-controls-left-surfaces.js +31 -25
- package/dist/cjs/ui/block-controls-right-surfaces.js +31 -25
- package/dist/cjs/ui/block-controls-surface-context.js +1 -0
- package/dist/cjs/ui/block-controls-surface-drag-handle-registration.js +6 -7
- package/dist/cjs/ui/block-controls-surface-drag-handle.js +6 -2
- package/dist/cjs/ui/drag-handle.js +5 -3
- package/dist/cjs/ui/drop-target-layout.js +3 -2
- package/dist/cjs/ui/drop-target.js +3 -2
- package/dist/cjs/ui/global-styles.js +69 -27
- package/dist/cjs/ui/inline-drop-target.js +6 -5
- package/dist/cjs/ui/utils/anchor-name.js +2 -1
- package/dist/cjs/ui/utils/dom-attr-name.js +3 -2
- package/dist/cjs/ui/utils/get-surface-placement.js +2 -1
- package/dist/es2019/blockControlsPlugin.js +42 -8
- package/dist/es2019/editor-commands/show-drag-handle.js +14 -2
- package/dist/es2019/pm-plugins/decorations-anchor.js +2 -1
- package/dist/es2019/pm-plugins/decorations-drop-target-active.js +2 -1
- package/dist/es2019/pm-plugins/decorations-drop-target.js +2 -1
- package/dist/es2019/pm-plugins/decorations-surface-anchor.js +56 -0
- package/dist/es2019/pm-plugins/handle-mouse-down.js +2 -1
- package/dist/es2019/pm-plugins/handle-mouse-over.js +3 -2
- package/dist/es2019/pm-plugins/handle-sparse-mouse-over.js +116 -0
- package/dist/es2019/pm-plugins/main.js +70 -54
- package/dist/es2019/pm-plugins/sparse-surfaces.js +37 -0
- package/dist/es2019/pm-plugins/utils/sparse-surface-candidates.js +305 -0
- package/dist/es2019/pm-plugins/utils/sparse-surfaces-mapping.js +78 -0
- package/dist/es2019/pm-plugins/utils/sparse-surfaces-state.js +39 -0
- package/dist/es2019/pm-plugins/utils/sparse-surfaces-view.js +121 -0
- package/dist/es2019/pm-plugins/utils/surface-viewport.js +192 -0
- package/dist/es2019/pm-plugins/utils/transactions.js +5 -0
- package/dist/es2019/ui/block-controls-left-surfaces.js +21 -14
- package/dist/es2019/ui/block-controls-right-surfaces.js +21 -14
- package/dist/es2019/ui/block-controls-surface-context.js +1 -0
- package/dist/es2019/ui/block-controls-surface-drag-handle-registration.js +4 -5
- package/dist/es2019/ui/block-controls-surface-drag-handle.js +6 -2
- package/dist/es2019/ui/drag-handle.js +5 -3
- package/dist/es2019/ui/drop-target-layout.js +3 -2
- package/dist/es2019/ui/drop-target.js +3 -2
- package/dist/es2019/ui/global-styles.js +67 -28
- package/dist/es2019/ui/inline-drop-target.js +6 -5
- package/dist/es2019/ui/utils/anchor-name.js +2 -1
- package/dist/es2019/ui/utils/dom-attr-name.js +3 -2
- package/dist/es2019/ui/utils/get-surface-placement.js +2 -1
- package/dist/esm/blockControlsPlugin.js +53 -17
- package/dist/esm/editor-commands/show-drag-handle.js +17 -5
- package/dist/esm/pm-plugins/decorations-anchor.js +2 -1
- package/dist/esm/pm-plugins/decorations-drop-target-active.js +2 -1
- package/dist/esm/pm-plugins/decorations-drop-target.js +2 -1
- package/dist/esm/pm-plugins/decorations-surface-anchor.js +65 -0
- package/dist/esm/pm-plugins/handle-mouse-down.js +2 -1
- package/dist/esm/pm-plugins/handle-mouse-over.js +3 -2
- package/dist/esm/pm-plugins/handle-sparse-mouse-over.js +119 -0
- package/dist/esm/pm-plugins/main.js +66 -54
- package/dist/esm/pm-plugins/sparse-surfaces.js +43 -0
- package/dist/esm/pm-plugins/utils/sparse-surface-candidates.js +413 -0
- package/dist/esm/pm-plugins/utils/sparse-surfaces-mapping.js +101 -0
- package/dist/esm/pm-plugins/utils/sparse-surfaces-state.js +46 -0
- package/dist/esm/pm-plugins/utils/sparse-surfaces-view.js +127 -0
- package/dist/esm/pm-plugins/utils/surface-viewport.js +217 -0
- package/dist/esm/pm-plugins/utils/transactions.js +5 -0
- package/dist/esm/ui/block-controls-left-surfaces.js +33 -27
- package/dist/esm/ui/block-controls-right-surfaces.js +33 -27
- package/dist/esm/ui/block-controls-surface-context.js +1 -0
- package/dist/esm/ui/block-controls-surface-drag-handle-registration.js +7 -8
- package/dist/esm/ui/block-controls-surface-drag-handle.js +6 -2
- package/dist/esm/ui/drag-handle.js +5 -3
- package/dist/esm/ui/drop-target-layout.js +3 -2
- package/dist/esm/ui/drop-target.js +3 -2
- package/dist/esm/ui/global-styles.js +70 -28
- package/dist/esm/ui/inline-drop-target.js +6 -5
- package/dist/esm/ui/utils/anchor-name.js +2 -1
- package/dist/esm/ui/utils/dom-attr-name.js +3 -2
- package/dist/esm/ui/utils/get-surface-placement.js +2 -1
- package/dist/types/blockControlsPluginType.d.ts +10 -3
- package/dist/types/pm-plugins/decorations-surface-anchor.d.ts +22 -0
- package/dist/types/pm-plugins/handle-sparse-mouse-over.d.ts +5 -0
- package/dist/types/pm-plugins/main.d.ts +2 -9
- package/dist/types/pm-plugins/sparse-surfaces.d.ts +8 -0
- package/dist/types/pm-plugins/utils/sparse-surface-candidates.d.ts +89 -0
- package/dist/types/pm-plugins/utils/sparse-surfaces-mapping.d.ts +20 -0
- package/dist/types/pm-plugins/utils/sparse-surfaces-state.d.ts +27 -0
- package/dist/types/pm-plugins/utils/sparse-surfaces-view.d.ts +15 -0
- package/dist/types/pm-plugins/utils/surface-viewport.d.ts +10 -0
- package/dist/types/ui/utils/get-surface-placement.d.ts +3 -2
- package/package.json +5 -5
- package/dist/cjs/pm-plugins/utils/surface-node-positions.js +0 -100
- package/dist/es2019/pm-plugins/utils/surface-node-positions.js +0 -78
- package/dist/esm/pm-plugins/utils/surface-node-positions.js +0 -93
- package/dist/types/pm-plugins/utils/surface-node-positions.d.ts +0 -14
|
@@ -14,7 +14,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
14
14
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
15
15
|
var getBlockControlsSurfaceDragHandleComponents = exports.getBlockControlsSurfaceDragHandleComponents = function getBlockControlsSurfaceDragHandleComponents(_ref) {
|
|
16
16
|
var api = _ref.api;
|
|
17
|
-
return [{
|
|
17
|
+
return [_objectSpread(_objectSpread({
|
|
18
18
|
component: function component(_ref2) {
|
|
19
19
|
var surfaceContext = _ref2.surfaceContext;
|
|
20
20
|
return /*#__PURE__*/_react.default.createElement(_blockControlsSurfaceDragHandle.BlockControlsSurfaceDragHandle, {
|
|
@@ -26,12 +26,11 @@ var getBlockControlsSurfaceDragHandleComponents = exports.getBlockControlsSurfac
|
|
|
26
26
|
var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
27
27
|
surfaceContext = _ref3.surfaceContext;
|
|
28
28
|
var context = surfaceContext === null || surfaceContext === void 0 ? void 0 : surfaceContext.get(_blockControlUiContext.BLOCK_CONTROL_UI_CONTEXT);
|
|
29
|
-
return !(context !== null && context !== void 0 && context.activeNode) || context.targetNode.pos !== context.activeNode.pos;
|
|
30
|
-
}
|
|
31
|
-
|
|
29
|
+
return !(context !== null && context !== void 0 && context.activeNode) || context.targetNode.pos !== context.activeNode.pos || context.activeControlKey !== undefined && context.activeControlKey !== _surfaceKeys.BLOCK_CONTROLS_DRAG_HANDLE.key;
|
|
30
|
+
}
|
|
31
|
+
}, _surfaceKeys.BLOCK_CONTROLS_DRAG_HANDLE), {}, {
|
|
32
32
|
parents: [_objectSpread(_objectSpread({}, _surfaceKeys.BLOCK_CONTROLS_LEFT_GROUP), {}, {
|
|
33
33
|
rank: 200
|
|
34
|
-
})]
|
|
35
|
-
|
|
36
|
-
}];
|
|
34
|
+
})]
|
|
35
|
+
})];
|
|
37
36
|
};
|
|
@@ -124,7 +124,11 @@ var BlockControlsSurfaceDragHandle = exports.BlockControlsSurfaceDragHandle = fu
|
|
|
124
124
|
return !isTopLevelNode || $anchor.depth > _consts.DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH;
|
|
125
125
|
}, [api, isLayoutColumn, isShiftDown, isTopLevelNode, view]);
|
|
126
126
|
var getAnchorName = (0, _react.useCallback)(function () {
|
|
127
|
-
var _ref2, _ref3, _dom$getAttribute, _dom$closest;
|
|
127
|
+
var _api$blockControls$sh2, _ref2, _ref3, _dom$getAttribute, _dom$closest;
|
|
128
|
+
var surfaceAnchor = posRef.current === undefined ? undefined : api === null || api === void 0 || (_api$blockControls$sh2 = api.blockControls.sharedState.currentState()) === null || _api$blockControls$sh2 === void 0 || (_api$blockControls$sh2 = _api$blockControls$sh2.surfaceAnchors) === null || _api$blockControls$sh2 === void 0 ? void 0 : _api$blockControls$sh2.get(posRef.current);
|
|
129
|
+
if (surfaceAnchor) {
|
|
130
|
+
return surfaceAnchor;
|
|
131
|
+
}
|
|
128
132
|
if (activeNodeAnchorName) {
|
|
129
133
|
return activeNodeAnchorName;
|
|
130
134
|
}
|
|
@@ -138,7 +142,7 @@ var BlockControlsSurfaceDragHandle = exports.BlockControlsSurfaceDragHandle = fu
|
|
|
138
142
|
}
|
|
139
143
|
var anchorAttrName = (0, _domAttrName.getAnchorAttrName)();
|
|
140
144
|
return (_ref2 = (_ref3 = (_dom$getAttribute = dom.getAttribute(anchorAttrName)) !== null && _dom$getAttribute !== void 0 ? _dom$getAttribute : dom.getAttribute(_domAttrName.NODE_ANCHOR_ATTR_NAME)) !== null && _ref3 !== void 0 ? _ref3 : (_dom$closest = dom.closest("[".concat(anchorAttrName, "]"))) === null || _dom$closest === void 0 ? void 0 : _dom$closest.getAttribute(anchorAttrName)) !== null && _ref2 !== void 0 ? _ref2 : '';
|
|
141
|
-
}, [activeNodeAnchorName, view]);
|
|
145
|
+
}, [activeNodeAnchorName, api, view]);
|
|
142
146
|
(0, _react.useLayoutEffect)(function () {
|
|
143
147
|
var element = buttonRef.current;
|
|
144
148
|
if (!view || !element) {
|
|
@@ -740,10 +740,12 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref2) {
|
|
|
740
740
|
});
|
|
741
741
|
}, [anchorName, api, getPos, nodeType, start, view]);
|
|
742
742
|
var calculatePositionOld = (0, _react.useCallback)(function () {
|
|
743
|
+
var _$pos$nodeAfter;
|
|
743
744
|
var pos = getPos();
|
|
744
|
-
var $pos =
|
|
745
|
+
var $pos = typeof pos === 'number' ? view.state.doc.resolve(pos) : undefined;
|
|
745
746
|
var parentPos = $pos && $pos.depth ? $pos.before() : undefined;
|
|
746
747
|
var node = parentPos !== undefined ? view.state.doc.nodeAt(parentPos) : undefined;
|
|
748
|
+
var nodeTypeWithLevel = $pos !== null && $pos !== void 0 && (_$pos$nodeAfter = $pos.nodeAfter) !== null && _$pos$nodeAfter !== void 0 && _$pos$nodeAfter.isBlock ? (0, _decorationsCommon.getNodeTypeWithLevel)($pos.nodeAfter) : nodeType;
|
|
747
749
|
var parentNodeType = node === null || node === void 0 ? void 0 : node.type.name;
|
|
748
750
|
var supportsAnchor = CSS.supports('top', "anchor(".concat(anchorName, " start)")) && CSS.supports('left', "anchor(".concat(anchorName, " start)"));
|
|
749
751
|
var safeAnchorName = (0, _editorExperiment.editorExperiment)('platform_editor_controls', 'variant1') ? (0, _anchorName.refreshAnchorName)({
|
|
@@ -801,13 +803,13 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref2) {
|
|
|
801
803
|
var bottom = (0, _editorExperiment.editorExperiment)('platform_editor_controls', 'variant1') ? (0, _dragHandlePositions.getControlBottomCSSValue)(safeAnchorName, isSticky, isTopLevelNodeValue, isLayoutColumn, _consts2.ACTIVE_DRAG_HANDLE_FALLBACK_ANCHOR_NAME) : {};
|
|
802
804
|
return _objectSpread({
|
|
803
805
|
left: isEdgeCase ? "calc(".concat(anchorStart, " + ").concat((0, _dragHandlePositions.getLeftPosition)(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType), ")") : (0, _editorExperiment.editorExperiment)('advanced_layouts', true) && isLayoutColumn ? "calc((".concat(anchorRight, " + ").concat(anchorLeft, ")/2 - ").concat(_consts2.DRAG_HANDLE_HEIGHT / 2, "px)") : "calc(".concat(anchorStart, " - ").concat(_styles.DRAG_HANDLE_WIDTH, "px - ").concat((0, _consts2.dragHandleGap)(nodeType, parentNodeType), "px)"),
|
|
804
|
-
top: (0, _editorExperiment.editorExperiment)('advanced_layouts', true) && isLayoutColumn ? "calc(".concat(anchorTop, " - ").concat(_styles.DRAG_HANDLE_WIDTH, "px)") : "calc(".concat(anchorStart, " + ").concat((0, _consts2.topPositionAdjustment)(
|
|
806
|
+
top: (0, _editorExperiment.editorExperiment)('advanced_layouts', true) && isLayoutColumn ? "calc(".concat(anchorTop, " - ").concat(_styles.DRAG_HANDLE_WIDTH, "px)") : "calc(".concat(anchorStart, " + ").concat((0, _consts2.topPositionAdjustment)(nodeTypeWithLevel, (dom === null || dom === void 0 ? void 0 : dom.getAttribute('layout')) || ''), "px)")
|
|
805
807
|
}, bottom);
|
|
806
808
|
}
|
|
807
809
|
var height = (0, _editorExperiment.editorExperiment)('platform_editor_controls', 'variant1') ? (0, _dragHandlePositions.getControlHeightCSSValue)((0, _dragHandlePositions.getNodeHeight)(dom, safeAnchorName, anchorRectCache) || 0, isSticky, isTopLevelNodeValue, "".concat(_consts2.DRAG_HANDLE_HEIGHT), isLayoutColumn) : {};
|
|
808
810
|
return _objectSpread({
|
|
809
811
|
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),
|
|
810
|
-
top: (0, _dragHandlePositions.getTopPosition)(dom,
|
|
812
|
+
top: (0, _dragHandlePositions.getTopPosition)(dom, nodeTypeWithLevel)
|
|
811
813
|
}, height);
|
|
812
814
|
}, [anchorName, getPos, view, nodeType, blockCardWidth, macroInteractionUpdates, anchorRectCache, isTopLevelNodeValue, isLayoutColumn]);
|
|
813
815
|
var isReliableAnchorEnabled = (0, _expValEquals.expValEquals)('platform_editor_controls_reliable_anchor', 'isEnabled', true);
|
|
@@ -10,6 +10,7 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
10
10
|
var _react = require("react");
|
|
11
11
|
var _react2 = require("@emotion/react");
|
|
12
12
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
13
|
+
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
13
14
|
var _box = require("@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box");
|
|
14
15
|
var _elementAdapter = require("@atlaskit/pragmatic-drag-and-drop/adapter/element-adapter");
|
|
15
16
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
@@ -128,7 +129,7 @@ var DropTargetLayout = exports.DropTargetLayout = function DropTargetLayout(prop
|
|
|
128
129
|
}, isDraggedOver ? (0, _react2.jsx)(_box.DropIndicator, {
|
|
129
130
|
edge: "right",
|
|
130
131
|
gap: "-".concat(DROP_TARGET_LAYOUT_DROP_ZONE_WIDTH, "px")
|
|
131
|
-
}) : (isActiveAnchor || (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) && (0, _react2.jsx)("div", {
|
|
132
|
+
}) : (isActiveAnchor || (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration')) && (0, _react2.jsx)("div", {
|
|
132
133
|
"data-testid": "block-ctrl-drop-hint",
|
|
133
134
|
css: dropTargetLayoutHintStyle
|
|
134
135
|
}));
|
|
@@ -243,7 +244,7 @@ var DropTargetLayoutNativeAnchorSupport = exports.DropTargetLayoutNativeAnchorSu
|
|
|
243
244
|
}, isDraggedOver ? (0, _react2.jsx)(_box.DropIndicator, {
|
|
244
245
|
edge: "right",
|
|
245
246
|
gap: "-".concat(DROP_TARGET_LAYOUT_DROP_ZONE_WIDTH, "px")
|
|
246
|
-
}) : (isActiveAnchor || (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) && (0, _react2.jsx)("div", {
|
|
247
|
+
}) : (isActiveAnchor || (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration')) && (0, _react2.jsx)("div", {
|
|
247
248
|
"data-testid": "block-ctrl-drop-hint",
|
|
248
249
|
css: dropTargetLayoutHintStyle
|
|
249
250
|
}));
|
|
@@ -12,6 +12,7 @@ var _react = require("react");
|
|
|
12
12
|
var _react2 = require("@emotion/react");
|
|
13
13
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
14
14
|
var _nodeTypeUtils = require("@atlaskit/editor-common/utils/node-type-utils");
|
|
15
|
+
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
15
16
|
var _box = require("@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box");
|
|
16
17
|
var _elementAdapter = require("@atlaskit/pragmatic-drag-and-drop/adapter/element-adapter");
|
|
17
18
|
var _constants = require("@atlaskit/theme/constants");
|
|
@@ -95,7 +96,7 @@ var HoverZone = function HoverZone(_ref) {
|
|
|
95
96
|
var ref = (0, _react.useRef)(null);
|
|
96
97
|
var isRemainingheight = dropTargetStyle === 'remainingHeight';
|
|
97
98
|
var anchorName = (0, _react.useMemo)(function () {
|
|
98
|
-
if ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
99
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration')) {
|
|
99
100
|
if (node && typeof pos === 'number') {
|
|
100
101
|
var posOffset = position === 'upper' ? -node.nodeSize : 0;
|
|
101
102
|
return (api === null || api === void 0 ? void 0 : api.core.actions.getAnchorIdForNode(node, pos + posOffset)) || '';
|
|
@@ -149,7 +150,7 @@ var HoverZone = function HoverZone(_ref) {
|
|
|
149
150
|
// only apply upper drop zone
|
|
150
151
|
if (isRemainingheight && position === 'upper') {
|
|
151
152
|
// previous node
|
|
152
|
-
var _anchorName = node ? (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? (api === null || api === void 0 ? void 0 : api.core.actions.getAnchorIdForNode(node, pos || -1)) || '' : (0, _decorationsCommon.getNodeAnchor)(node) : '';
|
|
153
|
+
var _anchorName = node ? (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration') ? (api === null || api === void 0 ? void 0 : api.core.actions.getAnchorIdForNode(node, pos || -1)) || '' : (0, _decorationsCommon.getNodeAnchor)(node) : '';
|
|
153
154
|
var top = 'unset';
|
|
154
155
|
if (_anchorName) {
|
|
155
156
|
var enabledDropZone = getEnableDropZone().includes((node === null || node === void 0 ? void 0 : node.type.name) || '');
|
|
@@ -376,17 +376,70 @@ var staticControlsAnchorStyles = (0, _react.css)({
|
|
|
376
376
|
}
|
|
377
377
|
}
|
|
378
378
|
});
|
|
379
|
+
var sparseSurfaceAnchorName = 'var(--block-controls-surface-anchor-name)';
|
|
379
380
|
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
*/
|
|
384
|
-
var surfaceAnchorStyles = (0, _react.css)({
|
|
381
|
+
// Inner node-view boxes own the visible geometry for these nodes. The root arm keeps a sparse
|
|
382
|
+
// marker useful when a node view has not mounted its inner box yet.
|
|
383
|
+
var sparseSurfaceAnchorStyles = (0, _react.css)({
|
|
385
384
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
386
|
-
'.ProseMirror':
|
|
387
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-
|
|
388
|
-
|
|
389
|
-
|
|
385
|
+
'.ProseMirror': {
|
|
386
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
387
|
+
'[data-block-controls-surface-anchor][data-block-controls-surface-node-type="blockCard"]:has(.datasourceView-content-inner-wrap) .datasourceView-content-inner-wrap': {
|
|
388
|
+
anchorName: sparseSurfaceAnchorName
|
|
389
|
+
},
|
|
390
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
391
|
+
'[data-block-controls-surface-anchor][data-block-controls-surface-node-type="blockCard"]:not(:has(.datasourceView-content-inner-wrap))': {
|
|
392
|
+
anchorName: sparseSurfaceAnchorName
|
|
393
|
+
},
|
|
394
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
395
|
+
'[data-block-controls-surface-anchor][data-block-controls-surface-node-type="bodiedExtension"]:has(.extension-container[data-layout]) .extension-container[data-layout]': {
|
|
396
|
+
anchorName: sparseSurfaceAnchorName
|
|
397
|
+
},
|
|
398
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
399
|
+
'[data-block-controls-surface-anchor][data-block-controls-surface-node-type="bodiedExtension"]:not(:has(.extension-container[data-layout]))': {
|
|
400
|
+
anchorName: sparseSurfaceAnchorName
|
|
401
|
+
},
|
|
402
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
403
|
+
'[data-block-controls-surface-anchor][data-block-controls-surface-node-type="embedCard"]:has(.rich-media-item) .rich-media-item': {
|
|
404
|
+
anchorName: sparseSurfaceAnchorName
|
|
405
|
+
},
|
|
406
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
407
|
+
'[data-block-controls-surface-anchor][data-block-controls-surface-node-type="embedCard"]:not(:has(.rich-media-item))': {
|
|
408
|
+
anchorName: sparseSurfaceAnchorName
|
|
409
|
+
},
|
|
410
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
411
|
+
'[data-block-controls-surface-anchor][data-block-controls-surface-node-type="extension"]:has(.extension-container[data-layout]) .extension-container[data-layout]': {
|
|
412
|
+
anchorName: sparseSurfaceAnchorName
|
|
413
|
+
},
|
|
414
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
415
|
+
'[data-block-controls-surface-anchor][data-block-controls-surface-node-type="extension"]:not(:has(.extension-container[data-layout]))': {
|
|
416
|
+
anchorName: sparseSurfaceAnchorName
|
|
417
|
+
},
|
|
418
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
419
|
+
'[data-block-controls-surface-anchor][data-block-controls-surface-node-type="mediaSingle"]:has(.resizer-item) .resizer-item': {
|
|
420
|
+
anchorName: sparseSurfaceAnchorName
|
|
421
|
+
},
|
|
422
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
423
|
+
'[data-block-controls-surface-anchor][data-block-controls-surface-node-type="mediaSingle"]:not(:has(.resizer-item))': {
|
|
424
|
+
anchorName: sparseSurfaceAnchorName
|
|
425
|
+
},
|
|
426
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
427
|
+
'[data-block-controls-surface-anchor][data-block-controls-surface-node-type="multiBodiedExtension"]:has(.extension-container[data-layout]) .extension-container[data-layout]': {
|
|
428
|
+
anchorName: sparseSurfaceAnchorName
|
|
429
|
+
},
|
|
430
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
431
|
+
'[data-block-controls-surface-anchor][data-block-controls-surface-node-type="multiBodiedExtension"]:not(:has(.extension-container[data-layout]))': {
|
|
432
|
+
anchorName: sparseSurfaceAnchorName
|
|
433
|
+
},
|
|
434
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
435
|
+
'[data-block-controls-surface-anchor][data-block-controls-surface-node-type="table"]:has(.resizer-item) .resizer-item': {
|
|
436
|
+
anchorName: sparseSurfaceAnchorName
|
|
437
|
+
},
|
|
438
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
439
|
+
'[data-block-controls-surface-anchor][data-block-controls-surface-node-type="table"]:not(:has(.resizer-item))': {
|
|
440
|
+
anchorName: sparseSurfaceAnchorName
|
|
441
|
+
}
|
|
442
|
+
}
|
|
390
443
|
});
|
|
391
444
|
|
|
392
445
|
// Styles applied to nodes with anchors when dragging
|
|
@@ -426,33 +479,22 @@ var GlobalStylesWrapper = exports.GlobalStylesWrapper = function GlobalStylesWra
|
|
|
426
479
|
};
|
|
427
480
|
}),
|
|
428
481
|
isDraggingFromState = _useSharedPluginState.isDragging;
|
|
429
|
-
var
|
|
482
|
+
var sparseSurfacesEnabled = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration');
|
|
483
|
+
var isDragging = sparseSurfacesEnabled || (0, _expValEquals.expValEquals)('platform_editor_block_controls_perf_optimization', 'isEnabled', true) ? isDraggingFromState : false;
|
|
430
484
|
var shouldRenderAnchors = (0, _styles.isCSSAnchorSupported)() && (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true);
|
|
431
|
-
|
|
432
|
-
// The surfaces anchor to blocks they render against rather than only to the hovered one, so they
|
|
433
|
-
// need a name on every node. Added alongside whichever conditional rule applies rather than
|
|
434
|
-
// replacing it: this one matches only non-active nodes, so the two sets are disjoint.
|
|
435
|
-
//
|
|
436
|
-
// The migration check is what scopes this. Unlike the surfaces, this component renders for every
|
|
437
|
-
// editor, so without it the rule would name anchors on documents that have no surface to anchor.
|
|
438
|
-
var shouldRenderSurfaceAnchors =
|
|
439
|
-
// eslint-disable-next-line @atlaskit/platform/no-preconditioning -- browser capability, not a flag: an anchor name is meaningless where `anchor()` cannot resolve
|
|
440
|
-
Boolean((0, _styles.isCSSAnchorSupported)()) && (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration');
|
|
485
|
+
var sparseSurfaceAnchorsEnabled = Boolean((0, _styles.isCSSAnchorSupported)()) && sparseSurfacesEnabled;
|
|
441
486
|
var toolbarFlagsEnabled = (0, _toolbarFlagCheck.areToolbarFlagsEnabled)(Boolean(api === null || api === void 0 ? void 0 : api.toolbar));
|
|
442
487
|
return (0, _react.jsx)(_react.Global
|
|
443
488
|
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
444
489
|
, {
|
|
445
|
-
styles: [globalStyles(), globalDnDStyle, (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? extendedHoverZoneNext() : extendedHoverZone(), isDragging && ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? extendedDragZoneNext : extendedDragZone), (0, _editorExperiment.editorExperiment)('platform_editor_preview_panel_responsiveness', true, {
|
|
490
|
+
styles: [globalStyles(), globalDnDStyle, (!sparseSurfacesEnabled || isDragging) && ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration') ? extendedHoverZoneNext() : extendedHoverZone()), isDragging && ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration') ? extendedDragZoneNext : extendedDragZone), (!sparseSurfacesEnabled || isDragging) && (0, _editorExperiment.editorExperiment)('platform_editor_preview_panel_responsiveness', true, {
|
|
446
491
|
exposure: true
|
|
447
|
-
}) ? (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? extendHoverZoneReducedNext : extendHoverZoneReduced : undefined,
|
|
492
|
+
}) ? (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration') ? extendHoverZoneReducedNext : extendHoverZoneReduced : undefined,
|
|
448
493
|
// platform_editor_controls note: this allows drag handles to render on empty lines
|
|
449
|
-
toolbarFlagsEnabled ? undefined : withInlineNodeStyle, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, (0, _editorExperiment.editorExperiment)('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? withRelativePosStyleNext : withRelativePosStyle, (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? withAnchorNameZindexStyleNext : withAnchorNameZindexStyle, (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) && (0, _expValEquals.expValEquals)('advanced_layouts', 'isEnabled', true) ? layoutColumnExtendedHoverZone : layoutColumnWithoutHoverZone, (0, _expValEquals.expValEquals)('platform_editor_controls_reliable_anchor', 'isEnabled', true) ?
|
|
494
|
+
toolbarFlagsEnabled ? undefined : withInlineNodeStyle, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, (0, _editorExperiment.editorExperiment)('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, (!sparseSurfacesEnabled || isDragging) && ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration') ? withRelativePosStyleNext : withRelativePosStyle), (!sparseSurfacesEnabled || isDragging) && ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration') ? withAnchorNameZindexStyleNext : withAnchorNameZindexStyle), (!sparseSurfacesEnabled || isDragging) && (((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration')) && (0, _expValEquals.expValEquals)('advanced_layouts', 'isEnabled', true) ? layoutColumnExtendedHoverZone : layoutColumnWithoutHoverZone), sparseSurfaceAnchorsEnabled ? isDragging ? dragAnchorStyles : false : (0, _expValEquals.expValEquals)('platform_editor_controls_reliable_anchor', 'isEnabled', true) ?
|
|
450
495
|
// dragAnchorStyles sets anchor-name on ALL nodes during drag (needed for drop target positioning).
|
|
451
496
|
// staticControlsAnchorStyles handles anchor-name via node decorations for non-drag state.
|
|
452
497
|
// shouldRenderAnchors guards both: only apply anchor styles on browsers that support CSS anchor positioning.
|
|
453
|
-
shouldRenderAnchors ? isDragging ? dragAnchorStyles : staticControlsAnchorStyles : false : shouldRenderAnchors && (isDragging ? dragAnchorStyles : dragHandlerAnchorStyles),
|
|
454
|
-
// Last so that, at equal specificity, the surfaces' own anchor names are the ones that
|
|
455
|
-
// stand. It cannot overlap the active-node rules above, which this selector excludes.
|
|
456
|
-
shouldRenderSurfaceAnchors && surfaceAnchorStyles]
|
|
498
|
+
shouldRenderAnchors ? isDragging ? dragAnchorStyles : staticControlsAnchorStyles : false : shouldRenderAnchors && (isDragging ? dragAnchorStyles : dragHandlerAnchorStyles), sparseSurfaceAnchorsEnabled && sparseSurfaceAnchorStyles]
|
|
457
499
|
});
|
|
458
500
|
};
|
|
@@ -10,6 +10,7 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
10
10
|
var _react = require("react");
|
|
11
11
|
var _react2 = require("@emotion/react");
|
|
12
12
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
13
|
+
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
13
14
|
var _box = require("@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box");
|
|
14
15
|
var _elementAdapter = require("@atlaskit/pragmatic-drag-and-drop/adapter/element-adapter");
|
|
15
16
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
@@ -100,7 +101,7 @@ var InlineDropTarget = exports.InlineDropTarget = function InlineDropTarget(_ref
|
|
|
100
101
|
isDraggedOver = _useState2[0],
|
|
101
102
|
setIsDraggedOver = _useState2[1];
|
|
102
103
|
var anchorName = (0, _react.useMemo)(function () {
|
|
103
|
-
if ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
104
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration')) {
|
|
104
105
|
var _getPos;
|
|
105
106
|
return nextNode ? (api === null || api === void 0 ? void 0 : api.core.actions.getAnchorIdForNode(nextNode, (_getPos = getPos()) !== null && _getPos !== void 0 ? _getPos : -1)) || '' : '';
|
|
106
107
|
}
|
|
@@ -133,7 +134,7 @@ var InlineDropTarget = exports.InlineDropTarget = function InlineDropTarget(_ref
|
|
|
133
134
|
innerContainerWidth = "calc(var(--ak-editor--line-length) * ".concat(percentageWidth, ")");
|
|
134
135
|
}
|
|
135
136
|
} else if (nextNode.type.name === 'table' && nextNode.firstChild) {
|
|
136
|
-
var tableWidthAnchor = (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? typeof nextNodePos === 'number' ? (api === null || api === void 0 ? void 0 : api.core.actions.getAnchorIdForNode(nextNode.firstChild, nextNodePos + 1)) || '' : '' : (0, _decorationsCommon.getNodeAnchor)(nextNode.firstChild);
|
|
137
|
+
var tableWidthAnchor = (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration') ? typeof nextNodePos === 'number' ? (api === null || api === void 0 ? void 0 : api.core.actions.getAnchorIdForNode(nextNode.firstChild, nextNodePos + 1)) || '' : '' : (0, _decorationsCommon.getNodeAnchor)(nextNode.firstChild);
|
|
137
138
|
var isNumberColumnEnabled = Boolean(nextNode.attrs.isNumberColumnEnabled);
|
|
138
139
|
if ((0, _anchorUtils.isAnchorSupported)()) {
|
|
139
140
|
innerContainerWidth = isNumberColumnEnabled ? "calc(anchor-size(".concat(tableWidthAnchor, " width) + ").concat(TABLE_NUMBERED_COLUMN_WIDTH, "px)") : "anchor-size(".concat(tableWidthAnchor, " width)");
|
|
@@ -146,7 +147,7 @@ var InlineDropTarget = exports.InlineDropTarget = function InlineDropTarget(_ref
|
|
|
146
147
|
innerContainerWidth = "min(".concat(nextNode.attrs.width, "px, ").concat(innerContainerWidth, ")");
|
|
147
148
|
}
|
|
148
149
|
} else if (nextNode.type.name === 'mediaSingle' && nextNode.firstChild) {
|
|
149
|
-
if ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
150
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration')) {
|
|
150
151
|
var _nextNode$firstChild;
|
|
151
152
|
// check pos is a number
|
|
152
153
|
if (typeof nextNodePos === 'number' && ((_nextNode$firstChild = nextNode.firstChild) === null || _nextNode$firstChild === void 0 ? void 0 : _nextNode$firstChild.type.name) === 'media') {
|
|
@@ -161,7 +162,7 @@ var InlineDropTarget = exports.InlineDropTarget = function InlineDropTarget(_ref
|
|
|
161
162
|
var heightTargetAnchorName = targetAnchorName;
|
|
162
163
|
if (nextNode.type.name === 'layoutSection' && nextNode.firstChild && nextNode.lastChild) {
|
|
163
164
|
if (isLeftPosition) {
|
|
164
|
-
if ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
165
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration')) {
|
|
165
166
|
if (typeof nextNodePos === 'number') {
|
|
166
167
|
heightTargetAnchorName = (api === null || api === void 0 ? void 0 : api.core.actions.getAnchorIdForNode(nextNode.firstChild, nextNodePos + 1)) || '';
|
|
167
168
|
} else {
|
|
@@ -171,7 +172,7 @@ var InlineDropTarget = exports.InlineDropTarget = function InlineDropTarget(_ref
|
|
|
171
172
|
heightTargetAnchorName = (0, _decorationsCommon.getNodeAnchor)(nextNode.firstChild);
|
|
172
173
|
}
|
|
173
174
|
} else {
|
|
174
|
-
if ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
175
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration')) {
|
|
175
176
|
if (typeof nextNodePos === 'number') {
|
|
176
177
|
var lastNodeStartPos = nextNode.content.size - nextNode.lastChild.nodeSize;
|
|
177
178
|
heightTargetAnchorName = (api === null || api === void 0 ? void 0 : api.core.actions.getAnchorIdForNode(nextNode.lastChild, lastNodeStartPos + 1)) || '';
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.refreshAnchorName = void 0;
|
|
7
|
+
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
7
8
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
8
9
|
var _decorationsAnchor = require("../../pm-plugins/decorations-anchor");
|
|
9
10
|
var _main = require("../../pm-plugins/main");
|
|
@@ -16,7 +17,7 @@ var refreshAnchorName = exports.refreshAnchorName = function refreshAnchorName(_
|
|
|
16
17
|
view = _ref.view,
|
|
17
18
|
anchorName = _ref.anchorName;
|
|
18
19
|
var newAnchorName = anchorName || '';
|
|
19
|
-
if ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
20
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration')) {
|
|
20
21
|
return newAnchorName;
|
|
21
22
|
}
|
|
22
23
|
var pos = getPos();
|
|
@@ -4,17 +4,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getTypeNameFromDom = exports.getTypeNameAttrName = exports.getAnchorAttrName = exports.NODE_NODE_TYPE_ATTR_NAME = exports.NODE_ANCHOR_ATTR_NAME = void 0;
|
|
7
|
+
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
7
8
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
8
9
|
var NODE_ANCHOR_ATTR_NAME = exports.NODE_ANCHOR_ATTR_NAME = 'data-node-anchor';
|
|
9
10
|
var NODE_NODE_TYPE_ATTR_NAME = exports.NODE_NODE_TYPE_ATTR_NAME = 'data-prosemirror-node-name';
|
|
10
11
|
var getAnchorAttrName = exports.getAnchorAttrName = function getAnchorAttrName() {
|
|
11
|
-
if ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
12
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration')) {
|
|
12
13
|
return NODE_ANCHOR_ATTR_NAME;
|
|
13
14
|
}
|
|
14
15
|
return 'data-drag-handler-anchor-name';
|
|
15
16
|
};
|
|
16
17
|
var getTypeNameAttrName = exports.getTypeNameAttrName = function getTypeNameAttrName() {
|
|
17
|
-
if ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
18
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration')) {
|
|
18
19
|
return NODE_NODE_TYPE_ATTR_NAME;
|
|
19
20
|
}
|
|
20
21
|
return 'data-drag-handler-node-type';
|
|
@@ -105,6 +105,7 @@ var INVALID_ANCHOR_FALLBACK_TOP = "-".concat(INVALID_ANCHOR_OFFSCREEN_PX, "px");
|
|
|
105
105
|
var INVALID_ANCHOR_FALLBACK_BOTTOM = "".concat(INVALID_ANCHOR_OFFSCREEN_PX, "px");
|
|
106
106
|
var getAnchoredSurfacePlacement = exports.getAnchoredSurfacePlacement = function getAnchoredSurfacePlacement(_ref3) {
|
|
107
107
|
var anchorName = _ref3.anchorName,
|
|
108
|
+
layout = _ref3.layout,
|
|
108
109
|
nodeType = _ref3.nodeType,
|
|
109
110
|
nodeTypeWithLevel = _ref3.nodeTypeWithLevel,
|
|
110
111
|
parentNodeType = _ref3.parentNodeType,
|
|
@@ -131,7 +132,7 @@ var getAnchoredSurfacePlacement = exports.getAnchoredSurfacePlacement = function
|
|
|
131
132
|
} : {}), {}, {
|
|
132
133
|
left: side === 'right' ? "calc(anchor(".concat(anchorName, " right) + ").concat(gap, "px)") : "anchor(".concat(anchorName, " left)"),
|
|
133
134
|
positionAnchor: anchorName,
|
|
134
|
-
top: "calc(anchor(".concat(anchorName, " top, ").concat(INVALID_ANCHOR_FALLBACK_TOP, ") + ").concat((0, _consts.topPositionAdjustment)(nodeTypeWithLevel), "px)"),
|
|
135
|
+
top: "calc(anchor(".concat(anchorName, " top, ").concat(INVALID_ANCHOR_FALLBACK_TOP, ") + ").concat((0, _consts.topPositionAdjustment)(nodeTypeWithLevel, layout), "px)"),
|
|
135
136
|
// The left side grows away from the node without knowing its own width, so it pulls itself
|
|
136
137
|
// back past its own box and the gap. The right side grows into the margin, so the gap is
|
|
137
138
|
// already folded into `left` above.
|
|
@@ -14,12 +14,14 @@ import { moveNode } from './editor-commands/move-node';
|
|
|
14
14
|
import { moveNodeWithBlockMenu } from './editor-commands/move-node-with-block-menu';
|
|
15
15
|
import { moveToLayout } from './editor-commands/move-to-layout';
|
|
16
16
|
import { canMoveNodeUpOrDown } from './editor-commands/utils/move-node-utils';
|
|
17
|
+
import { getNodeTypeWithLevel } from './pm-plugins/decorations-common';
|
|
17
18
|
import { firstNodeDecPlugin } from './pm-plugins/first-node-dec-plugin';
|
|
18
19
|
import { createInteractionTrackingPlugin, interactionTrackingPluginKey } from './pm-plugins/interaction-tracking/pm-plugin';
|
|
19
20
|
import { createPlugin, key } from './pm-plugins/main';
|
|
20
21
|
import { startPreservingSelection, stopPreservingSelection } from './pm-plugins/selection-preservation/editor-commands';
|
|
21
22
|
import { selectionPreservationPluginKey } from './pm-plugins/selection-preservation/plugin-key';
|
|
22
23
|
import { createSelectionPreservationPlugin } from './pm-plugins/selection-preservation/pm-plugin';
|
|
24
|
+
import { createSparseSurfacesPlugin, sparseSurfacesKey } from './pm-plugins/sparse-surfaces';
|
|
23
25
|
import { expandAndUpdateSelection } from './pm-plugins/utils/expand-and-update-selection';
|
|
24
26
|
import { selectNode } from './pm-plugins/utils/getSelection';
|
|
25
27
|
import { BlockControlsLeftSurfaces } from './ui/block-controls-left-surfaces';
|
|
@@ -36,7 +38,6 @@ export const blockControlsPlugin = ({
|
|
|
36
38
|
const rightSideControlsEnabled = (_config$rightSideCont = config === null || config === void 0 ? void 0 : config.rightSideControlsEnabled) !== null && _config$rightSideCont !== void 0 ? _config$rightSideCont : false;
|
|
37
39
|
const quickInsertButtonEnabled = (_config$quickInsertBu = config === null || config === void 0 ? void 0 : config.quickInsertButtonEnabled) !== null && _config$quickInsertBu !== void 0 ? _config$quickInsertBu : true;
|
|
38
40
|
const registryBlockControlsEnabled = isExperimentEnabled('platform_editor_block_control_migration');
|
|
39
|
-
const legacyBlockControlsEnabled = !registryBlockControlsEnabled;
|
|
40
41
|
if (registryBlockControlsEnabled) {
|
|
41
42
|
var _api$uiControlRegistr, _api$uiControlRegistr2;
|
|
42
43
|
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, {
|
|
@@ -140,8 +141,14 @@ export const blockControlsPlugin = ({
|
|
|
140
141
|
plugin: ({
|
|
141
142
|
getIntl,
|
|
142
143
|
nodeViewPortalProviderAPI
|
|
143
|
-
}) => createPlugin(api, getIntl, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled, quickInsertButtonEnabled &&
|
|
144
|
+
}) => createPlugin(api, getIntl, nodeViewPortalProviderAPI, registryBlockControlsEnabled ? [] : nodeDecorationRegistry, rightSideControlsEnabled, quickInsertButtonEnabled && !registryBlockControlsEnabled)
|
|
144
145
|
}];
|
|
146
|
+
if (registryBlockControlsEnabled) {
|
|
147
|
+
pmPlugins.push({
|
|
148
|
+
name: 'blockControlsSparseSurfaces',
|
|
149
|
+
plugin: () => createSparseSurfacesPlugin(api)
|
|
150
|
+
});
|
|
151
|
+
}
|
|
145
152
|
if (editorExperiment('platform_editor_controls', 'variant1')) {
|
|
146
153
|
pmPlugins.push({
|
|
147
154
|
name: 'blockControlsInteractionTrackingPlugin',
|
|
@@ -158,7 +165,7 @@ export const blockControlsPlugin = ({
|
|
|
158
165
|
// Not registered under the registry migration: the decoration puts an inline
|
|
159
166
|
// `margin-top: 0` on the first document node, which fights features that render their own
|
|
160
167
|
// content above it — a leading show-diff widget is left flush against the node below.
|
|
161
|
-
if (areToolbarFlagsEnabled(Boolean(api === null || api === void 0 ? void 0 : api.toolbar)) &&
|
|
168
|
+
if (areToolbarFlagsEnabled(Boolean(api === null || api === void 0 ? void 0 : api.toolbar)) && !registryBlockControlsEnabled) {
|
|
162
169
|
pmPlugins.push({
|
|
163
170
|
name: 'firstNodeDec',
|
|
164
171
|
plugin: firstNodeDecPlugin
|
|
@@ -205,10 +212,34 @@ export const blockControlsPlugin = ({
|
|
|
205
212
|
});
|
|
206
213
|
return tr;
|
|
207
214
|
},
|
|
215
|
+
showControlAtPosition: (pos, control, options) => ({
|
|
216
|
+
tr
|
|
217
|
+
}) => {
|
|
218
|
+
const node = tr.doc.nodeAt(pos);
|
|
219
|
+
if (!node) {
|
|
220
|
+
return tr;
|
|
221
|
+
}
|
|
222
|
+
const anchorName = api === null || api === void 0 ? void 0 : api.core.actions.getAnchorIdForNode(node, pos);
|
|
223
|
+
if (!anchorName) {
|
|
224
|
+
return tr;
|
|
225
|
+
}
|
|
226
|
+
const currMeta = tr.getMeta(key);
|
|
227
|
+
tr.setMeta(key, {
|
|
228
|
+
...currMeta,
|
|
229
|
+
activeNode: {
|
|
230
|
+
pos,
|
|
231
|
+
anchorName,
|
|
232
|
+
controlKey: control.key,
|
|
233
|
+
nodeType: getNodeTypeWithLevel(node),
|
|
234
|
+
handleOptions: options
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
return tr;
|
|
238
|
+
},
|
|
208
239
|
toggleBlockMenu: options => ({
|
|
209
240
|
tr
|
|
210
241
|
}) => {
|
|
211
|
-
var _api$userIntent, _api$userIntent$share, _api$blockControls2, _api$blockControls2$s, _options$anchorName, _api$blockControls3, _api$blockControls3$s;
|
|
242
|
+
var _api$userIntent, _api$userIntent$share, _api$blockControls2, _api$blockControls2$s, _options$triggerByNod, _options$anchorName, _api$blockControls3, _api$blockControls3$s;
|
|
212
243
|
const currMeta = tr.getMeta(key);
|
|
213
244
|
const currentUserIntent = api === null || api === void 0 ? void 0 : (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 ? void 0 : (_api$userIntent$share = _api$userIntent.sharedState.currentState()) === null || _api$userIntent$share === void 0 ? void 0 : _api$userIntent$share.currentUserIntent;
|
|
214
245
|
const isMenuCurrentlyOpen = api === null || api === void 0 ? void 0 : (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : (_api$blockControls2$s = _api$blockControls2.sharedState.currentState()) === null || _api$blockControls2$s === void 0 ? void 0 : _api$blockControls2$s.isMenuOpen;
|
|
@@ -234,8 +265,9 @@ export const blockControlsPlugin = ({
|
|
|
234
265
|
return tr;
|
|
235
266
|
}
|
|
236
267
|
|
|
237
|
-
// Do not open
|
|
238
|
-
|
|
268
|
+
// Do not open the block menu for layout columns. Anchor resolution can lag behind
|
|
269
|
+
// a migrated surface click, so prefer the explicit node metadata when available.
|
|
270
|
+
if ((options === null || options === void 0 ? void 0 : (_options$triggerByNod = options.triggerByNode) === null || _options$triggerByNod === void 0 ? void 0 : _options$triggerByNod.nodeType) === 'layoutColumn' || options !== null && options !== void 0 && (_options$anchorName = options.anchorName) !== null && _options$anchorName !== void 0 && _options$anchorName.includes('layoutColumn')) {
|
|
239
271
|
if (currentUserIntent === 'blockMenuOpen') {
|
|
240
272
|
var _api$userIntent3;
|
|
241
273
|
api === null || api === void 0 ? void 0 : (_api$userIntent3 = api.userIntent) === null || _api$userIntent3 === void 0 ? void 0 : _api$userIntent3.commands.setCurrentUserIntent('default')({
|
|
@@ -436,8 +468,10 @@ export const blockControlsPlugin = ({
|
|
|
436
468
|
isSelectedViaDragHandle: (_key$getState$isSelec = (_key$getState10 = key.getState(editorState)) === null || _key$getState10 === void 0 ? void 0 : _key$getState10.isSelectedViaDragHandle) !== null && _key$getState$isSelec !== void 0 ? _key$getState$isSelec : false
|
|
437
469
|
};
|
|
438
470
|
if (registryBlockControlsEnabled) {
|
|
439
|
-
|
|
440
|
-
sharedState.surfaceNodePositions =
|
|
471
|
+
const surfaces = sparseSurfacesKey.getState(editorState);
|
|
472
|
+
sharedState.surfaceNodePositions = surfaces === null || surfaces === void 0 ? void 0 : surfaces.candidates.positions;
|
|
473
|
+
sharedState.surfaceAnchors = surfaces === null || surfaces === void 0 ? void 0 : surfaces.anchors;
|
|
474
|
+
sharedState.surfaceActiveNodes = surfaces === null || surfaces === void 0 ? void 0 : surfaces.activeNodesByPosition;
|
|
441
475
|
}
|
|
442
476
|
if (editorExperiment('platform_editor_controls', 'variant1')) {
|
|
443
477
|
var _interactionTrackingP2, _interactionTrackingP3, _interactionTrackingP4;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
2
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
2
3
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
3
4
|
import { findNodeDecs } from '../pm-plugins/decorations-anchor';
|
|
5
|
+
import { getNodeTypeWithLevel } from '../pm-plugins/decorations-common';
|
|
4
6
|
import { getDecorations, key } from '../pm-plugins/main';
|
|
5
7
|
import { getNestedNodePosition, getNestedNodeStartingPosition } from '../pm-plugins/utils/getNestedNodePosition';
|
|
6
8
|
import { NODE_ANCHOR_ATTR_NAME, NODE_NODE_TYPE_ATTR_NAME } from '../ui/utils/dom-attr-name';
|
|
@@ -14,7 +16,6 @@ const findParentPosForHandle = state => {
|
|
|
14
16
|
const {
|
|
15
17
|
activeNode
|
|
16
18
|
} = key.getState(state) || {};
|
|
17
|
-
|
|
18
19
|
// if a node handle is already focused, return the parent pos of that node (with focused handle)
|
|
19
20
|
if (activeNode && (_activeNode$handleOpt = activeNode.handleOptions) !== null && _activeNode$handleOpt !== void 0 && _activeNode$handleOpt.isFocused) {
|
|
20
21
|
const $activeNodePos = state.doc.resolve(activeNode.pos);
|
|
@@ -38,7 +39,7 @@ const findParentPosForHandle = state => {
|
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
// else find closest parent node
|
|
41
|
-
return expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ?
|
|
42
|
+
return expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || isExperimentEnabled('platform_editor_block_control_migration') ?
|
|
42
43
|
// With native anchor enabled, all nodes have anchor name attribute despite no drag handle support, e.g. listItem, caption,
|
|
43
44
|
// as opposed to old approach, node decoration is only added to the node that have drag handle,
|
|
44
45
|
// hence, we need to return the exact position of the node that can have drag handle
|
|
@@ -111,6 +112,17 @@ const findNextAnchorNode = view => {
|
|
|
111
112
|
}
|
|
112
113
|
};
|
|
113
114
|
export const showDragHandleAtSelection = api => (state, _, view) => {
|
|
115
|
+
if (api && isExperimentEnabled('platform_editor_block_control_migration')) {
|
|
116
|
+
const pos = findParentPosForHandle(state);
|
|
117
|
+
const node = pos === undefined ? undefined : state.doc.nodeAt(pos);
|
|
118
|
+
const anchorName = node && pos !== undefined ? api.core.actions.getAnchorIdForNode(node, pos) : undefined;
|
|
119
|
+
if (!node || pos === undefined || !anchorName) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
return api.core.actions.execute(api.blockControls.commands.showDragHandleAt(pos, anchorName, getNodeTypeWithLevel(node), {
|
|
123
|
+
isFocused: true
|
|
124
|
+
}));
|
|
125
|
+
}
|
|
114
126
|
if (view && expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
115
127
|
const anchorNode = findNextAnchorNode(view);
|
|
116
128
|
if (api && anchorNode) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
2
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
2
3
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
3
4
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
4
5
|
import { getNodeAnchor, getNodeTypeWithLevel, NESTED_DEPTH, TYPE_NODE_DEC } from './decorations-common';
|
|
@@ -67,7 +68,7 @@ export const findNodeDecs = (state, decorations, from, to) => {
|
|
|
67
68
|
};
|
|
68
69
|
export const nodeDecorations = (newState, from, to) => {
|
|
69
70
|
const decs = [];
|
|
70
|
-
if (expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
71
|
+
if (expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || isExperimentEnabled('platform_editor_block_control_migration')) {
|
|
71
72
|
return [];
|
|
72
73
|
}
|
|
73
74
|
const docFrom = from === undefined || from < 0 ? 0 : from;
|
|
@@ -3,6 +3,7 @@ import { expandSelectionBounds } from '@atlaskit/editor-common/selection';
|
|
|
3
3
|
import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
4
4
|
import { getBaseNodeTypeName } from '@atlaskit/editor-common/utils/node-type-utils';
|
|
5
5
|
import { findChildrenByType } from '@atlaskit/editor-prosemirror/utils';
|
|
6
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
6
7
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
7
8
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
8
9
|
import { getNodeAnchor } from './decorations-common';
|
|
@@ -236,7 +237,7 @@ export const getActiveDropTargetDecorations = (activeDropTargetNode, state, api,
|
|
|
236
237
|
}
|
|
237
238
|
}
|
|
238
239
|
}
|
|
239
|
-
defaultActiveAnchorTracker.emit(expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? api.core.actions.getAnchorIdForNode(anchorEmitNodeWithPos.node, anchorEmitNodeWithPos.pos) || '' : getNodeAnchor(anchorEmitNodeWithPos.node));
|
|
240
|
+
defaultActiveAnchorTracker.emit(expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || isExperimentEnabled('platform_editor_block_control_migration') ? api.core.actions.getAnchorIdForNode(anchorEmitNodeWithPos.node, anchorEmitNodeWithPos.pos) || '' : getNodeAnchor(anchorEmitNodeWithPos.node));
|
|
240
241
|
return {
|
|
241
242
|
decsToAdd,
|
|
242
243
|
decsToRemove
|
|
@@ -6,6 +6,7 @@ import { expandSelectionBounds } from '@atlaskit/editor-common/selection';
|
|
|
6
6
|
import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
7
7
|
import { getBaseNodeTypeName } from '@atlaskit/editor-common/utils/node-type-utils';
|
|
8
8
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
9
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
9
10
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
10
11
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
11
12
|
import { nodeMargins } from '../ui/consts';
|
|
@@ -138,7 +139,7 @@ export const createLayoutDropTargetDecoration = (pos, props, nodeViewPortalProvi
|
|
|
138
139
|
element.setAttribute('data-blocks-drop-target-container', 'true');
|
|
139
140
|
element.setAttribute('data-blocks-drop-target-key', key);
|
|
140
141
|
element.style.clear = 'unset';
|
|
141
|
-
const DropTargetLayoutComponent = expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? DropTargetLayoutNativeAnchorSupport : DropTargetLayout;
|
|
142
|
+
const DropTargetLayoutComponent = expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || isExperimentEnabled('platform_editor_block_control_migration') ? DropTargetLayoutNativeAnchorSupport : DropTargetLayout;
|
|
142
143
|
nodeViewPortalProviderAPI.render(() => /*#__PURE__*/createElement(DropTargetLayoutComponent, {
|
|
143
144
|
...props,
|
|
144
145
|
getPos,
|