@atlaskit/editor-plugin-block-controls 7.8.0 → 7.10.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 +23 -5
- package/dist/cjs/editor-commands/show-drag-handle.js +2 -2
- package/dist/cjs/pm-plugins/decorations-anchor.js +1 -1
- package/dist/cjs/pm-plugins/decorations-drop-target-active.js +1 -1
- package/dist/cjs/pm-plugins/decorations-drop-target.js +1 -2
- package/dist/cjs/pm-plugins/handle-mouse-down.js +1 -1
- package/dist/cjs/pm-plugins/handle-mouse-over.js +3 -3
- package/dist/cjs/pm-plugins/main.js +2 -2
- package/dist/cjs/ui/drag-handle.js +4 -4
- package/dist/cjs/ui/drop-target-layout.js +2 -2
- package/dist/cjs/ui/drop-target.js +2 -2
- package/dist/cjs/ui/global-styles.js +33 -5
- package/dist/cjs/ui/inline-drop-target.js +5 -5
- package/dist/cjs/ui/utils/anchor-name.js +1 -1
- package/dist/cjs/ui/utils/dom-attr-name.js +2 -2
- package/dist/es2019/editor-commands/show-drag-handle.js +2 -2
- package/dist/es2019/pm-plugins/decorations-anchor.js +1 -1
- package/dist/es2019/pm-plugins/decorations-drop-target-active.js +1 -1
- package/dist/es2019/pm-plugins/decorations-drop-target.js +1 -2
- package/dist/es2019/pm-plugins/handle-mouse-down.js +1 -1
- package/dist/es2019/pm-plugins/handle-mouse-over.js +3 -3
- package/dist/es2019/pm-plugins/main.js +2 -2
- package/dist/es2019/ui/drag-handle.js +4 -4
- package/dist/es2019/ui/drop-target-layout.js +2 -2
- package/dist/es2019/ui/drop-target.js +2 -2
- package/dist/es2019/ui/global-styles.js +34 -6
- package/dist/es2019/ui/inline-drop-target.js +5 -5
- package/dist/es2019/ui/utils/anchor-name.js +1 -1
- package/dist/es2019/ui/utils/dom-attr-name.js +2 -2
- package/dist/esm/editor-commands/show-drag-handle.js +2 -2
- package/dist/esm/pm-plugins/decorations-anchor.js +1 -1
- package/dist/esm/pm-plugins/decorations-drop-target-active.js +1 -1
- package/dist/esm/pm-plugins/decorations-drop-target.js +1 -2
- package/dist/esm/pm-plugins/handle-mouse-down.js +1 -1
- package/dist/esm/pm-plugins/handle-mouse-over.js +3 -3
- package/dist/esm/pm-plugins/main.js +2 -2
- package/dist/esm/ui/drag-handle.js +4 -4
- package/dist/esm/ui/drop-target-layout.js +2 -2
- package/dist/esm/ui/drop-target.js +2 -2
- package/dist/esm/ui/global-styles.js +34 -6
- package/dist/esm/ui/inline-drop-target.js +5 -5
- package/dist/esm/ui/utils/anchor-name.js +1 -1
- package/dist/esm/ui/utils/dom-attr-name.js +2 -2
- package/package.json +4 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 7.10.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`d84e4018e7a77`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d84e4018e7a77) -
|
|
8
|
+
ED-29689 create new exp
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
|
|
14
|
+
## 7.9.0
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- [`b168fe8504b3d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b168fe8504b3d) -
|
|
19
|
+
ED-29688 update dragging native anchor styles
|
|
20
|
+
|
|
3
21
|
## 7.8.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
|
@@ -207,7 +225,7 @@
|
|
|
207
225
|
### Patch Changes
|
|
208
226
|
|
|
209
227
|
- [`9ca86d5ced1c4`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9ca86d5ced1c4) -
|
|
210
|
-
ED-294112 fix extended hover zone for
|
|
228
|
+
ED-294112 fix extended hover zone for platform_editor_native_anchor_with_dnd to match existing
|
|
211
229
|
behaviour; no hover zones for inline elements, headerCells or (when advanced_layouts is off)
|
|
212
230
|
layout columns
|
|
213
231
|
- Updated dependencies
|
|
@@ -240,7 +258,7 @@
|
|
|
240
258
|
- [`0b0ef25b2f529`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0b0ef25b2f529) -
|
|
241
259
|
Cleanup various feature gates and align them to aifc_create_enabled
|
|
242
260
|
- [`3feef799ad0a5`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3feef799ad0a5) -
|
|
243
|
-
[ED-29333] Fix 2 issues when
|
|
261
|
+
[ED-29333] Fix 2 issues when platform_editor_native_anchor_with_dnd is enabled
|
|
244
262
|
1. Drag handle is rendered for media node
|
|
245
263
|
2. When advanced_layouts experiment is off, quick insert button is rendered based on child node
|
|
246
264
|
inside layout column (as opposed to layout section node )
|
|
@@ -263,7 +281,7 @@
|
|
|
263
281
|
|
|
264
282
|
- [`606c3303a0d61`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/606c3303a0d61) -
|
|
265
283
|
[ux] ED-29331 fix block controls misalignment on first line of empty document with
|
|
266
|
-
|
|
284
|
+
platform_editor_native_anchor_with_dnd on
|
|
267
285
|
- Updated dependencies
|
|
268
286
|
|
|
269
287
|
## 7.2.10
|
|
@@ -272,7 +290,7 @@
|
|
|
272
290
|
|
|
273
291
|
- [`2470543de66c4`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/2470543de66c4) -
|
|
274
292
|
[ux] ED-29341 fix block quote drag handle is hard to trigger behind with
|
|
275
|
-
|
|
293
|
+
platform_editor_native_anchor_with_dnd on
|
|
276
294
|
- Updated dependencies
|
|
277
295
|
|
|
278
296
|
## 7.2.9
|
|
@@ -287,7 +305,7 @@
|
|
|
287
305
|
### Patch Changes
|
|
288
306
|
|
|
289
307
|
- [`435745247f7ef`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/435745247f7ef) -
|
|
290
|
-
[ED-29337] Fix drag handle cannot be focus via shorcut when
|
|
308
|
+
[ED-29337] Fix drag handle cannot be focus via shorcut when platform_editor_native_anchor_with_dnd
|
|
291
309
|
is enabled
|
|
292
310
|
|
|
293
311
|
## 7.2.7
|
|
@@ -39,7 +39,7 @@ var findParentPosForHandle = function findParentPosForHandle(state) {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
// else find closest parent node
|
|
42
|
-
return (0, _expValEquals.expValEquals)('
|
|
42
|
+
return (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ?
|
|
43
43
|
// With native anchor enabled, all nodes have anchor name attribute despite no drag handle support, e.g. listItem, caption,
|
|
44
44
|
// as opposed to old approach, node decoration is only added to the node that have drag handle,
|
|
45
45
|
// hence, we need to return the exact position of the node that can have drag handle
|
|
@@ -113,7 +113,7 @@ var findNextAnchorNode = function findNextAnchorNode(view) {
|
|
|
113
113
|
};
|
|
114
114
|
var showDragHandleAtSelection = exports.showDragHandleAtSelection = function showDragHandleAtSelection(api) {
|
|
115
115
|
return function (state, _, view) {
|
|
116
|
-
if (view && (0, _expValEquals.expValEquals)('
|
|
116
|
+
if (view && (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
117
117
|
var anchorNode = findNextAnchorNode(view);
|
|
118
118
|
if (api && anchorNode) {
|
|
119
119
|
var pos = anchorNode.pos,
|
|
@@ -107,7 +107,7 @@ var findNodeDecs = exports.findNodeDecs = function findNodeDecs(state, decoratio
|
|
|
107
107
|
};
|
|
108
108
|
var nodeDecorations = exports.nodeDecorations = function nodeDecorations(newState, from, to) {
|
|
109
109
|
var decs = [];
|
|
110
|
-
if ((0, _expValEquals.expValEquals)('
|
|
110
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
111
111
|
return [];
|
|
112
112
|
}
|
|
113
113
|
var docFrom = from === undefined || from < 0 ? 0 : from;
|
|
@@ -239,7 +239,7 @@ var getActiveDropTargetDecorations = exports.getActiveDropTargetDecorations = fu
|
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
|
-
_activeAnchorTracker.defaultActiveAnchorTracker.emit((0, _expValEquals.expValEquals)('
|
|
242
|
+
_activeAnchorTracker.defaultActiveAnchorTracker.emit((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? api.core.actions.getAnchorIdForNode(rootNodeWithPos.node, rootNodeWithPos.pos) || '' : (0, _decorationsCommon.getNodeAnchor)(rootNodeWithPos.node));
|
|
243
243
|
return {
|
|
244
244
|
decsToAdd: decsToAdd,
|
|
245
245
|
decsToRemove: decsToRemove
|
|
@@ -11,7 +11,6 @@ var _uuid = _interopRequireDefault(require("uuid"));
|
|
|
11
11
|
var _selection = require("@atlaskit/editor-common/selection");
|
|
12
12
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
13
13
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
14
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
15
14
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
16
15
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
17
16
|
var _consts = require("../ui/consts");
|
|
@@ -138,7 +137,7 @@ var createLayoutDropTargetDecoration = exports.createLayoutDropTargetDecoration
|
|
|
138
137
|
element.setAttribute('data-blocks-drop-target-container', 'true');
|
|
139
138
|
element.setAttribute('data-blocks-drop-target-key', key);
|
|
140
139
|
element.style.clear = 'unset';
|
|
141
|
-
var DropTargetLayoutComponent = (0, _expValEquals.expValEquals)('
|
|
140
|
+
var DropTargetLayoutComponent = (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? _dropTargetLayout.DropTargetLayoutNativeAnchorSupport : _dropTargetLayout.DropTargetLayout;
|
|
142
141
|
nodeViewPortalProviderAPI.render(function () {
|
|
143
142
|
return /*#__PURE__*/(0, _react.createElement)(DropTargetLayoutComponent, _objectSpread(_objectSpread({}, props), {}, {
|
|
144
143
|
getPos: getPos,
|
|
@@ -21,7 +21,7 @@ var handleMouseDown = exports.handleMouseDown = function handleMouseDown(api) {
|
|
|
21
21
|
if (!rootNode) {
|
|
22
22
|
return false;
|
|
23
23
|
}
|
|
24
|
-
if ((0, _expValEquals.expValEquals)('
|
|
24
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
25
25
|
var _rootNode$type$name, _rootNode$type$name2;
|
|
26
26
|
var anchorName = api === null || api === void 0 ? void 0 : api.core.actions.getAnchorIdForNode(rootNode, rootPos);
|
|
27
27
|
|
|
@@ -30,7 +30,7 @@ var getNodeSelector = function getNodeSelector(ignoreNodes, ignoreNodeDescendant
|
|
|
30
30
|
return "[data-prosemirror-node-name=\"".concat(node, "\"]");
|
|
31
31
|
});
|
|
32
32
|
var ignoreNodeDescendantsSelectorList = ignoreNodeDescendants.map(function (node) {
|
|
33
|
-
if (node === 'table'
|
|
33
|
+
if (node === 'table') {
|
|
34
34
|
// Special case for table to exclude its direct descendants
|
|
35
35
|
return ["[data-prosemirror-node-name=\"tableCell\"] > [data-node-anchor]", "[data-prosemirror-node-name=\"tableHeader\"] > [data-node-anchor]"];
|
|
36
36
|
}
|
|
@@ -70,7 +70,7 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, e
|
|
|
70
70
|
// Ignored via go/ees005
|
|
71
71
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
72
72
|
var target = event.target;
|
|
73
|
-
var isNativeAnchorSupported = (0, _expValEquals.expValEquals)('
|
|
73
|
+
var isNativeAnchorSupported = (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true);
|
|
74
74
|
if (target !== null && target !== void 0 && (_target$classList = target.classList) !== null && _target$classList !== void 0 && _target$classList.contains('ProseMirror')) {
|
|
75
75
|
return false;
|
|
76
76
|
}
|
|
@@ -108,7 +108,7 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, e
|
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
var anchorName;
|
|
111
|
-
if ((0, _expValEquals.expValEquals)('
|
|
111
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
112
112
|
anchorName = rootElement.getAttribute((0, _domAttrName.getAnchorAttrName)());
|
|
113
113
|
|
|
114
114
|
// don't show handles if we can't find an anchor
|
|
@@ -358,7 +358,7 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
|
|
|
358
358
|
var isNodeDecsMissing = isDecSetEmpty || maybeNodeCountChanged || (0, _experiments.editorExperiment)('platform_editor_breakout_resizing', true) && hasJustFinishedResizing;
|
|
359
359
|
var shouldRedrawNodeDecs = !isResizerResizing && (isNodeDecsMissing || (meta === null || meta === void 0 ? void 0 : meta.isDragging)) &&
|
|
360
360
|
// Skip expensive anchor node decoration recalculations when native anchor support is enabled
|
|
361
|
-
!((0, _expValEquals.expValEquals)('
|
|
361
|
+
!((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) && (0, _platformFeatureFlags.fg)('editor_native_anchor_remove_decoration_in_apply'));
|
|
362
362
|
var isActiveNodeModified = false;
|
|
363
363
|
if (api && shouldRedrawNodeDecs) {
|
|
364
364
|
var oldNodeDecs = (0, _decorationsAnchor.findNodeDecs)(newState, decorations, from, to);
|
|
@@ -516,7 +516,7 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
|
|
|
516
516
|
}
|
|
517
517
|
}
|
|
518
518
|
var isEmptyDoc = (0, _utils.isEmptyDocument)(newState.doc);
|
|
519
|
-
if (isEmptyDoc && !(0, _expValEquals.expValEquals)('
|
|
519
|
+
if (isEmptyDoc && !(0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
520
520
|
var hasNodeDecoration = !!(0, _decorationsAnchor.findNodeDecs)(newState, decorations).length;
|
|
521
521
|
if (!hasNodeDecoration) {
|
|
522
522
|
decorations = decorations.add(newState.doc, [(0, _decorationsDragHandle.emptyParagraphNodeDecorations)()]);
|
|
@@ -815,7 +815,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref2) {
|
|
|
815
815
|
setRecalculatePosition(recalculatePosition);
|
|
816
816
|
}
|
|
817
817
|
var pos = getPos();
|
|
818
|
-
var $pos = (0, _expValEquals.expValEquals)('
|
|
818
|
+
var $pos = (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? typeof pos === 'number' && view.state.doc.resolve(pos) : pos && view.state.doc.resolve(pos);
|
|
819
819
|
var parentPos = $pos && $pos.depth ? $pos.before() : undefined;
|
|
820
820
|
var node = parentPos !== undefined ? view.state.doc.nodeAt(parentPos) : undefined;
|
|
821
821
|
var parentNodeType = node === null || node === void 0 ? void 0 : node.type.name;
|
|
@@ -850,7 +850,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref2) {
|
|
|
850
850
|
var bottom = (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? (0, _dragHandlePositions.getControlBottomCSSValue)(safeAnchorName, isSticky, isTopLevelNode, isLayoutColumn) : {};
|
|
851
851
|
return _objectSpread({
|
|
852
852
|
left: isEdgeCase ? "calc(anchor(".concat(safeAnchorName, " start) + ").concat((0, _dragHandlePositions.getLeftPosition)(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType), ")") : (0, _experiments.editorExperiment)('advanced_layouts', true) && isLayoutColumn ? "calc((anchor(".concat(safeAnchorName, " right) + anchor(").concat(safeAnchorName, " left))/2 - ").concat(_consts2.DRAG_HANDLE_HEIGHT / 2, "px)") : "calc(anchor(".concat(safeAnchorName, " start) - ").concat(_styles.DRAG_HANDLE_WIDTH, "px - ").concat((0, _consts2.dragHandleGap)(nodeType, parentNodeType), "px)"),
|
|
853
|
-
top: (0, _experiments.editorExperiment)('advanced_layouts', true) && isLayoutColumn ? "calc(anchor(".concat(safeAnchorName, " top) - ").concat(_styles.DRAG_HANDLE_WIDTH, "px)") : "calc(anchor(".concat(safeAnchorName, " start)+ ").concat((0, _consts2.topPositionAdjustment)((0, _expValEquals.expValEquals)('
|
|
853
|
+
top: (0, _experiments.editorExperiment)('advanced_layouts', true) && isLayoutColumn ? "calc(anchor(".concat(safeAnchorName, " top) - ").concat(_styles.DRAG_HANDLE_WIDTH, "px)") : "calc(anchor(".concat(safeAnchorName, " start)+ ").concat((0, _consts2.topPositionAdjustment)((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? $pos && $pos.nodeAfter && (0, _decorationsCommon.getNodeTypeWithLevel)($pos.nodeAfter) || nodeType : nodeType), "px)")
|
|
854
854
|
}, bottom);
|
|
855
855
|
}
|
|
856
856
|
var height = (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? (0, _dragHandlePositions.getControlHeightCSSValue)((0, _dragHandlePositions.getNodeHeight)(dom, safeAnchorName, anchorRectCache) || 0, isSticky, isTopLevelNode, "".concat(_consts2.DRAG_HANDLE_HEIGHT), isLayoutColumn) : {};
|
|
@@ -861,7 +861,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref2) {
|
|
|
861
861
|
}, [anchorName, getPos, view, nodeType, macroInteractionUpdates, anchorRectCache, isTopLevelNode, isLayoutColumn, recalculatePosition]);
|
|
862
862
|
var calculatePositionOld = (0, _react.useCallback)(function () {
|
|
863
863
|
var pos = getPos();
|
|
864
|
-
var $pos = (0, _expValEquals.expValEquals)('
|
|
864
|
+
var $pos = (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? typeof pos === 'number' && view.state.doc.resolve(pos) : pos && view.state.doc.resolve(pos);
|
|
865
865
|
var parentPos = $pos && $pos.depth ? $pos.before() : undefined;
|
|
866
866
|
var node = parentPos !== undefined ? view.state.doc.nodeAt(parentPos) : undefined;
|
|
867
867
|
var parentNodeType = node === null || node === void 0 ? void 0 : node.type.name;
|
|
@@ -896,7 +896,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref2) {
|
|
|
896
896
|
var bottom = (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? (0, _dragHandlePositions.getControlBottomCSSValue)(safeAnchorName, isSticky, isTopLevelNode, isLayoutColumn) : {};
|
|
897
897
|
return _objectSpread({
|
|
898
898
|
left: isEdgeCase ? "calc(anchor(".concat(safeAnchorName, " start) + ").concat((0, _dragHandlePositions.getLeftPosition)(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType), ")") : (0, _experiments.editorExperiment)('advanced_layouts', true) && isLayoutColumn ? "calc((anchor(".concat(safeAnchorName, " right) + anchor(").concat(safeAnchorName, " left))/2 - ").concat(_consts2.DRAG_HANDLE_HEIGHT / 2, "px)") : "calc(anchor(".concat(safeAnchorName, " start) - ").concat(_styles.DRAG_HANDLE_WIDTH, "px - ").concat((0, _consts2.dragHandleGap)(nodeType, parentNodeType), "px)"),
|
|
899
|
-
top: (0, _experiments.editorExperiment)('advanced_layouts', true) && isLayoutColumn ? "calc(anchor(".concat(safeAnchorName, " top) - ").concat(_styles.DRAG_HANDLE_WIDTH, "px)") : "calc(anchor(".concat(safeAnchorName, " start) + ").concat((0, _consts2.topPositionAdjustment)((0, _expValEquals.expValEquals)('
|
|
899
|
+
top: (0, _experiments.editorExperiment)('advanced_layouts', true) && isLayoutColumn ? "calc(anchor(".concat(safeAnchorName, " top) - ").concat(_styles.DRAG_HANDLE_WIDTH, "px)") : "calc(anchor(".concat(safeAnchorName, " start) + ").concat((0, _consts2.topPositionAdjustment)((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? $pos && $pos.nodeAfter && (0, _decorationsCommon.getNodeTypeWithLevel)($pos.nodeAfter) || nodeType : nodeType), "px)")
|
|
900
900
|
}, bottom);
|
|
901
901
|
}
|
|
902
902
|
var height = (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? (0, _dragHandlePositions.getControlHeightCSSValue)((0, _dragHandlePositions.getNodeHeight)(dom, safeAnchorName, anchorRectCache) || 0, isSticky, isTopLevelNode, "".concat(_consts2.DRAG_HANDLE_HEIGHT), isLayoutColumn) : {};
|
|
@@ -129,7 +129,7 @@ var DropTargetLayout = exports.DropTargetLayout = function DropTargetLayout(prop
|
|
|
129
129
|
}, isDraggedOver ? (0, _react2.jsx)(_box.DropIndicator, {
|
|
130
130
|
edge: "right",
|
|
131
131
|
gap: "-".concat(DROP_TARGET_LAYOUT_DROP_ZONE_WIDTH, "px")
|
|
132
|
-
}) : (isActiveAnchor || (0, _expValEquals.expValEquals)('
|
|
132
|
+
}) : (isActiveAnchor || (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) && (0, _react2.jsx)("div", {
|
|
133
133
|
"data-testid": "block-ctrl-drop-hint",
|
|
134
134
|
css: dropTargetLayoutHintStyle
|
|
135
135
|
}));
|
|
@@ -244,7 +244,7 @@ var DropTargetLayoutNativeAnchorSupport = exports.DropTargetLayoutNativeAnchorSu
|
|
|
244
244
|
}, isDraggedOver ? (0, _react2.jsx)(_box.DropIndicator, {
|
|
245
245
|
edge: "right",
|
|
246
246
|
gap: "-".concat(DROP_TARGET_LAYOUT_DROP_ZONE_WIDTH, "px")
|
|
247
|
-
}) : (isActiveAnchor || (0, _expValEquals.expValEquals)('
|
|
247
|
+
}) : (isActiveAnchor || (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) && (0, _react2.jsx)("div", {
|
|
248
248
|
"data-testid": "block-ctrl-drop-hint",
|
|
249
249
|
css: dropTargetLayoutHintStyle
|
|
250
250
|
}));
|
|
@@ -91,7 +91,7 @@ var HoverZone = function HoverZone(_ref) {
|
|
|
91
91
|
var ref = (0, _react.useRef)(null);
|
|
92
92
|
var isRemainingheight = dropTargetStyle === 'remainingHeight';
|
|
93
93
|
var anchorName = (0, _react.useMemo)(function () {
|
|
94
|
-
if ((0, _expValEquals.expValEquals)('
|
|
94
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
95
95
|
if (node && typeof pos === 'number') {
|
|
96
96
|
var posOffset = position === 'upper' ? -node.nodeSize : 0;
|
|
97
97
|
return (api === null || api === void 0 ? void 0 : api.core.actions.getAnchorIdForNode(node, pos + posOffset)) || '';
|
|
@@ -144,7 +144,7 @@ var HoverZone = function HoverZone(_ref) {
|
|
|
144
144
|
// only apply upper drop zone
|
|
145
145
|
if (isRemainingheight && position === 'upper') {
|
|
146
146
|
// previous node
|
|
147
|
-
var _anchorName = node ? (0, _expValEquals.expValEquals)('
|
|
147
|
+
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) : '';
|
|
148
148
|
var top = 'unset';
|
|
149
149
|
if (_anchorName) {
|
|
150
150
|
var enabledDropZone = enableDropZone.includes((node === null || node === void 0 ? void 0 : node.type.name) || '');
|
|
@@ -12,7 +12,6 @@ var _toolbarFlagCheck = require("@atlaskit/editor-common/toolbar-flag-check");
|
|
|
12
12
|
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
13
13
|
var _whitespace = require("@atlaskit/editor-common/whitespace");
|
|
14
14
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
15
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
16
15
|
var _constants = require("@atlaskit/theme/constants");
|
|
17
16
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
18
17
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
@@ -431,18 +430,47 @@ var dragHandlerAnchorStyles = (0, _react.css)({
|
|
|
431
430
|
}
|
|
432
431
|
}
|
|
433
432
|
});
|
|
433
|
+
|
|
434
|
+
// Styles applied to nodes with anchors when dragging
|
|
435
|
+
var dragAnchorStyles = (0, _react.css)({
|
|
436
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
437
|
+
'.ProseMirror': {
|
|
438
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
439
|
+
'[data-node-anchor]:not([data-node-anchor] [data-node-anchor])': {
|
|
440
|
+
// all top level nodes with anchor
|
|
441
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
442
|
+
anchorName: "var(".concat(_styles.ANCHOR_VARIABLE_NAME, ", attr(data-node-anchor type(<custom-ident>)))")
|
|
443
|
+
},
|
|
444
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
445
|
+
'[data-node-anchor]:has([data-blocks-drop-target-container]) [data-node-anchor]': {
|
|
446
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
447
|
+
anchorName: "var(".concat(_styles.ANCHOR_VARIABLE_NAME, ", attr(data-node-anchor type(<custom-ident>)))")
|
|
448
|
+
},
|
|
449
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
450
|
+
'[data-prosemirror-node-name="media"][data-node-anchor]': {
|
|
451
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
452
|
+
anchorName: "var(".concat(_styles.ANCHOR_VARIABLE_NAME, ", attr(data-node-anchor type(<custom-ident>)))")
|
|
453
|
+
},
|
|
454
|
+
// first table row to avoid multiple anchors in table
|
|
455
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
456
|
+
'[data-prosemirror-node-name="table"] [data-prosemirror-node-name="tableRow"][data-node-anchor]:first-of-type': {
|
|
457
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
458
|
+
anchorName: "var(".concat(_styles.ANCHOR_VARIABLE_NAME, ", attr(data-node-anchor type(<custom-ident>)))")
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
});
|
|
434
462
|
var GlobalStylesWrapper = exports.GlobalStylesWrapper = function GlobalStylesWrapper(_ref) {
|
|
435
463
|
var api = _ref.api;
|
|
436
464
|
var isDragging = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockControls.isDragging', {
|
|
437
465
|
disabled: !(0, _expValEquals.expValEquals)('platform_editor_block_controls_perf_optimization', 'isEnabled', true)
|
|
438
466
|
});
|
|
439
|
-
var shouldRenderAnchors = (0, _styles.isCSSAnchorSupported)() && (0, _expValEquals.expValEquals)('
|
|
467
|
+
var shouldRenderAnchors = (0, _styles.isCSSAnchorSupported)() && (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true);
|
|
440
468
|
var toolbarFlagsEnabled = (0, _toolbarFlagCheck.areToolbarFlagsEnabled)(Boolean(api === null || api === void 0 ? void 0 : api.toolbar));
|
|
441
469
|
return (0, _react.jsx)(_react.Global, {
|
|
442
|
-
styles: [globalStyles(), globalDnDStyle, (0, _expValEquals.expValEquals)('
|
|
470
|
+
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, _experiments.editorExperiment)('platform_editor_preview_panel_responsiveness', true, {
|
|
443
471
|
exposure: true
|
|
444
|
-
}) ? (0, _expValEquals.expValEquals)('
|
|
472
|
+
}) ? (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? extendHoverZoneReducedNext : extendHoverZoneReduced : undefined,
|
|
445
473
|
// platform_editor_controls note: this allows drag handles to render on empty lines
|
|
446
|
-
toolbarFlagsEnabled ? undefined : withInlineNodeStyle, (0, _experiments.editorExperiment)('platform_editor_block_control_optimise_render', true) ? quickInsertStyles : undefined, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, (0, _experiments.editorExperiment)('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, (0, _expValEquals.expValEquals)('
|
|
474
|
+
toolbarFlagsEnabled ? undefined : withInlineNodeStyle, (0, _experiments.editorExperiment)('platform_editor_block_control_optimise_render', true) ? quickInsertStyles : undefined, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, (0, _experiments.editorExperiment)('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? withRelativePosStyleNext : withRelativePosStyle, topLevelNodeMarginStyles, (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, shouldRenderAnchors && (isDragging ? dragAnchorStyles : dragHandlerAnchorStyles)]
|
|
447
475
|
});
|
|
448
476
|
};
|
|
@@ -101,7 +101,7 @@ var InlineDropTarget = exports.InlineDropTarget = function InlineDropTarget(_ref
|
|
|
101
101
|
isDraggedOver = _useState2[0],
|
|
102
102
|
setIsDraggedOver = _useState2[1];
|
|
103
103
|
var anchorName = (0, _react.useMemo)(function () {
|
|
104
|
-
if ((0, _expValEquals.expValEquals)('
|
|
104
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
105
105
|
var _getPos;
|
|
106
106
|
return nextNode ? (api === null || api === void 0 ? void 0 : api.core.actions.getAnchorIdForNode(nextNode, (_getPos = getPos()) !== null && _getPos !== void 0 ? _getPos : -1)) || '' : '';
|
|
107
107
|
}
|
|
@@ -134,7 +134,7 @@ var InlineDropTarget = exports.InlineDropTarget = function InlineDropTarget(_ref
|
|
|
134
134
|
innerContainerWidth = "calc(var(--ak-editor--line-length) * ".concat(percentageWidth, ")");
|
|
135
135
|
}
|
|
136
136
|
} else if (nextNode.type.name === 'table' && nextNode.firstChild) {
|
|
137
|
-
var tableWidthAnchor = (0, _expValEquals.expValEquals)('
|
|
137
|
+
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);
|
|
138
138
|
var isNumberColumnEnabled = Boolean(nextNode.attrs.isNumberColumnEnabled);
|
|
139
139
|
if ((0, _anchorUtils.isAnchorSupported)()) {
|
|
140
140
|
innerContainerWidth = isNumberColumnEnabled ? "calc(anchor-size(".concat(tableWidthAnchor, " width) + ").concat(TABLE_NUMBERED_COLUMN_WIDTH, "px)") : "anchor-size(".concat(tableWidthAnchor, " width)");
|
|
@@ -147,7 +147,7 @@ var InlineDropTarget = exports.InlineDropTarget = function InlineDropTarget(_ref
|
|
|
147
147
|
innerContainerWidth = "min(".concat(nextNode.attrs.width, "px, ").concat(innerContainerWidth, ")");
|
|
148
148
|
}
|
|
149
149
|
} else if (nextNode.type.name === 'mediaSingle' && nextNode.firstChild) {
|
|
150
|
-
if ((0, _expValEquals.expValEquals)('
|
|
150
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
151
151
|
var _nextNode$firstChild;
|
|
152
152
|
// check pos is a number
|
|
153
153
|
if (typeof nextNodePos === 'number' && ((_nextNode$firstChild = nextNode.firstChild) === null || _nextNode$firstChild === void 0 ? void 0 : _nextNode$firstChild.type.name) === 'media') {
|
|
@@ -162,7 +162,7 @@ var InlineDropTarget = exports.InlineDropTarget = function InlineDropTarget(_ref
|
|
|
162
162
|
var heightTargetAnchorName = targetAnchorName;
|
|
163
163
|
if (nextNode.type.name === 'layoutSection' && nextNode.firstChild && nextNode.lastChild) {
|
|
164
164
|
if (isLeftPosition) {
|
|
165
|
-
if ((0, _expValEquals.expValEquals)('
|
|
165
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
166
166
|
if (typeof nextNodePos === 'number') {
|
|
167
167
|
heightTargetAnchorName = (api === null || api === void 0 ? void 0 : api.core.actions.getAnchorIdForNode(nextNode.firstChild, nextNodePos + 1)) || '';
|
|
168
168
|
} else {
|
|
@@ -172,7 +172,7 @@ var InlineDropTarget = exports.InlineDropTarget = function InlineDropTarget(_ref
|
|
|
172
172
|
heightTargetAnchorName = (0, _decorationsCommon.getNodeAnchor)(nextNode.firstChild);
|
|
173
173
|
}
|
|
174
174
|
} else {
|
|
175
|
-
if ((0, _expValEquals.expValEquals)('
|
|
175
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
176
176
|
if (typeof nextNodePos === 'number') {
|
|
177
177
|
var lastNodeStartPos = nextNode.content.size - nextNode.lastChild.nodeSize;
|
|
178
178
|
heightTargetAnchorName = (api === null || api === void 0 ? void 0 : api.core.actions.getAnchorIdForNode(nextNode.lastChild, lastNodeStartPos + 1)) || '';
|
|
@@ -16,7 +16,7 @@ var refreshAnchorName = exports.refreshAnchorName = function refreshAnchorName(_
|
|
|
16
16
|
view = _ref.view,
|
|
17
17
|
anchorName = _ref.anchorName;
|
|
18
18
|
var newAnchorName = anchorName || '';
|
|
19
|
-
if ((0, _expValEquals.expValEquals)('
|
|
19
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
20
20
|
return newAnchorName;
|
|
21
21
|
}
|
|
22
22
|
var pos = getPos();
|
|
@@ -8,13 +8,13 @@ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
|
8
8
|
var NODE_ANCHOR_ATTR_NAME = exports.NODE_ANCHOR_ATTR_NAME = 'data-node-anchor';
|
|
9
9
|
var NODE_NODE_TYPE_ATTR_NAME = exports.NODE_NODE_TYPE_ATTR_NAME = 'data-prosemirror-node-name';
|
|
10
10
|
var getAnchorAttrName = exports.getAnchorAttrName = function getAnchorAttrName() {
|
|
11
|
-
if ((0, _expValEquals.expValEquals)('
|
|
11
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
12
12
|
return NODE_ANCHOR_ATTR_NAME;
|
|
13
13
|
}
|
|
14
14
|
return 'data-drag-handler-anchor-name';
|
|
15
15
|
};
|
|
16
16
|
var getTypeNameAttrName = exports.getTypeNameAttrName = function getTypeNameAttrName() {
|
|
17
|
-
if ((0, _expValEquals.expValEquals)('
|
|
17
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
18
18
|
return NODE_NODE_TYPE_ATTR_NAME;
|
|
19
19
|
}
|
|
20
20
|
return 'data-drag-handler-node-type';
|
|
@@ -38,7 +38,7 @@ const findParentPosForHandle = state => {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
// else find closest parent node
|
|
41
|
-
return expValEquals('
|
|
41
|
+
return expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ?
|
|
42
42
|
// With native anchor enabled, all nodes have anchor name attribute despite no drag handle support, e.g. listItem, caption,
|
|
43
43
|
// as opposed to old approach, node decoration is only added to the node that have drag handle,
|
|
44
44
|
// hence, we need to return the exact position of the node that can have drag handle
|
|
@@ -111,7 +111,7 @@ const findNextAnchorNode = view => {
|
|
|
111
111
|
}
|
|
112
112
|
};
|
|
113
113
|
export const showDragHandleAtSelection = api => (state, _, view) => {
|
|
114
|
-
if (view && expValEquals('
|
|
114
|
+
if (view && expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
115
115
|
const anchorNode = findNextAnchorNode(view);
|
|
116
116
|
if (api && anchorNode) {
|
|
117
117
|
const {
|
|
@@ -95,7 +95,7 @@ export const findNodeDecs = (state, decorations, from, to) => {
|
|
|
95
95
|
};
|
|
96
96
|
export const nodeDecorations = (newState, from, to) => {
|
|
97
97
|
const decs = [];
|
|
98
|
-
if (expValEquals('
|
|
98
|
+
if (expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
99
99
|
return [];
|
|
100
100
|
}
|
|
101
101
|
const docFrom = from === undefined || from < 0 ? 0 : from;
|
|
@@ -220,7 +220,7 @@ export const getActiveDropTargetDecorations = (activeDropTargetNode, state, api,
|
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
|
-
defaultActiveAnchorTracker.emit(expValEquals('
|
|
223
|
+
defaultActiveAnchorTracker.emit(expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? api.core.actions.getAnchorIdForNode(rootNodeWithPos.node, rootNodeWithPos.pos) || '' : getNodeAnchor(rootNodeWithPos.node));
|
|
224
224
|
return {
|
|
225
225
|
decsToAdd,
|
|
226
226
|
decsToRemove
|
|
@@ -4,7 +4,6 @@ import uuid from 'uuid';
|
|
|
4
4
|
import { expandSelectionBounds } from '@atlaskit/editor-common/selection';
|
|
5
5
|
import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
6
6
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
7
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
7
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
9
8
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
10
9
|
import { nodeMargins } from '../ui/consts';
|
|
@@ -127,7 +126,7 @@ export const createLayoutDropTargetDecoration = (pos, props, nodeViewPortalProvi
|
|
|
127
126
|
element.setAttribute('data-blocks-drop-target-container', 'true');
|
|
128
127
|
element.setAttribute('data-blocks-drop-target-key', key);
|
|
129
128
|
element.style.clear = 'unset';
|
|
130
|
-
const DropTargetLayoutComponent = expValEquals('
|
|
129
|
+
const DropTargetLayoutComponent = expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? DropTargetLayoutNativeAnchorSupport : DropTargetLayout;
|
|
131
130
|
nodeViewPortalProviderAPI.render(() => /*#__PURE__*/createElement(DropTargetLayoutComponent, {
|
|
132
131
|
...props,
|
|
133
132
|
getPos,
|
|
@@ -14,7 +14,7 @@ export const handleMouseDown = api => (view, event) => {
|
|
|
14
14
|
if (!rootNode) {
|
|
15
15
|
return false;
|
|
16
16
|
}
|
|
17
|
-
if (expValEquals('
|
|
17
|
+
if (expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
18
18
|
var _rootNode$type$name, _rootNode$type$name2;
|
|
19
19
|
const anchorName = api === null || api === void 0 ? void 0 : api.core.actions.getAnchorIdForNode(rootNode, rootPos);
|
|
20
20
|
|
|
@@ -20,7 +20,7 @@ const getNodeSelector = (ignoreNodes, ignoreNodeDescendants) => {
|
|
|
20
20
|
}
|
|
21
21
|
const ignoreNodeSelectorList = ignoreNodes.map(node => `[data-prosemirror-node-name="${node}"]`);
|
|
22
22
|
const ignoreNodeDescendantsSelectorList = ignoreNodeDescendants.map(node => {
|
|
23
|
-
if (node === 'table'
|
|
23
|
+
if (node === 'table') {
|
|
24
24
|
// Special case for table to exclude its direct descendants
|
|
25
25
|
return [`[data-prosemirror-node-name="tableCell"] > [data-node-anchor]`, `[data-prosemirror-node-name="tableHeader"] > [data-node-anchor]`];
|
|
26
26
|
}
|
|
@@ -62,7 +62,7 @@ export const handleMouseOver = (view, event, api) => {
|
|
|
62
62
|
// Ignored via go/ees005
|
|
63
63
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
64
64
|
const target = event.target;
|
|
65
|
-
const isNativeAnchorSupported = expValEquals('
|
|
65
|
+
const isNativeAnchorSupported = expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true);
|
|
66
66
|
if (target !== null && target !== void 0 && (_target$classList = target.classList) !== null && _target$classList !== void 0 && _target$classList.contains('ProseMirror')) {
|
|
67
67
|
return false;
|
|
68
68
|
}
|
|
@@ -100,7 +100,7 @@ export const handleMouseOver = (view, event, api) => {
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
let anchorName;
|
|
103
|
-
if (expValEquals('
|
|
103
|
+
if (expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
104
104
|
anchorName = rootElement.getAttribute(getAnchorAttrName());
|
|
105
105
|
|
|
106
106
|
// don't show handles if we can't find an anchor
|
|
@@ -357,7 +357,7 @@ export const apply = (api, formatMessage, tr, currentState, newState, flags, nod
|
|
|
357
357
|
const isNodeDecsMissing = isDecSetEmpty || maybeNodeCountChanged || editorExperiment('platform_editor_breakout_resizing', true) && hasJustFinishedResizing;
|
|
358
358
|
const shouldRedrawNodeDecs = !isResizerResizing && (isNodeDecsMissing || (meta === null || meta === void 0 ? void 0 : meta.isDragging)) &&
|
|
359
359
|
// Skip expensive anchor node decoration recalculations when native anchor support is enabled
|
|
360
|
-
!(expValEquals('
|
|
360
|
+
!(expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) && fg('editor_native_anchor_remove_decoration_in_apply'));
|
|
361
361
|
let isActiveNodeModified = false;
|
|
362
362
|
if (api && shouldRedrawNodeDecs) {
|
|
363
363
|
const oldNodeDecs = findNodeDecs(newState, decorations, from, to);
|
|
@@ -514,7 +514,7 @@ export const apply = (api, formatMessage, tr, currentState, newState, flags, nod
|
|
|
514
514
|
}
|
|
515
515
|
}
|
|
516
516
|
const isEmptyDoc = isEmptyDocument(newState.doc);
|
|
517
|
-
if (isEmptyDoc && !expValEquals('
|
|
517
|
+
if (isEmptyDoc && !expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
518
518
|
const hasNodeDecoration = !!findNodeDecs(newState, decorations).length;
|
|
519
519
|
if (!hasNodeDecoration) {
|
|
520
520
|
decorations = decorations.add(newState.doc, [emptyParagraphNodeDecorations()]);
|
|
@@ -800,7 +800,7 @@ export const DragHandle = ({
|
|
|
800
800
|
setRecalculatePosition(recalculatePosition);
|
|
801
801
|
}
|
|
802
802
|
const pos = getPos();
|
|
803
|
-
const $pos = expValEquals('
|
|
803
|
+
const $pos = expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? typeof pos === 'number' && view.state.doc.resolve(pos) : pos && view.state.doc.resolve(pos);
|
|
804
804
|
const parentPos = $pos && $pos.depth ? $pos.before() : undefined;
|
|
805
805
|
const node = parentPos !== undefined ? view.state.doc.nodeAt(parentPos) : undefined;
|
|
806
806
|
const parentNodeType = node === null || node === void 0 ? void 0 : node.type.name;
|
|
@@ -835,7 +835,7 @@ export const DragHandle = ({
|
|
|
835
835
|
const bottom = editorExperiment('platform_editor_controls', 'variant1') ? getControlBottomCSSValue(safeAnchorName, isSticky, isTopLevelNode, isLayoutColumn) : {};
|
|
836
836
|
return {
|
|
837
837
|
left: isEdgeCase ? `calc(anchor(${safeAnchorName} start) + ${getLeftPosition(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType)})` : editorExperiment('advanced_layouts', true) && isLayoutColumn ? `calc((anchor(${safeAnchorName} right) + anchor(${safeAnchorName} left))/2 - ${DRAG_HANDLE_HEIGHT / 2}px)` : `calc(anchor(${safeAnchorName} start) - ${DRAG_HANDLE_WIDTH}px - ${dragHandleGap(nodeType, parentNodeType)}px)`,
|
|
838
|
-
top: editorExperiment('advanced_layouts', true) && isLayoutColumn ? `calc(anchor(${safeAnchorName} top) - ${DRAG_HANDLE_WIDTH}px)` : `calc(anchor(${safeAnchorName} start)+ ${topPositionAdjustment(expValEquals('
|
|
838
|
+
top: editorExperiment('advanced_layouts', true) && isLayoutColumn ? `calc(anchor(${safeAnchorName} top) - ${DRAG_HANDLE_WIDTH}px)` : `calc(anchor(${safeAnchorName} start)+ ${topPositionAdjustment(expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? $pos && $pos.nodeAfter && getNodeTypeWithLevel($pos.nodeAfter) || nodeType : nodeType)}px)`,
|
|
839
839
|
...bottom
|
|
840
840
|
};
|
|
841
841
|
}
|
|
@@ -848,7 +848,7 @@ export const DragHandle = ({
|
|
|
848
848
|
}, [anchorName, getPos, view, nodeType, macroInteractionUpdates, anchorRectCache, isTopLevelNode, isLayoutColumn, recalculatePosition]);
|
|
849
849
|
const calculatePositionOld = useCallback(() => {
|
|
850
850
|
const pos = getPos();
|
|
851
|
-
const $pos = expValEquals('
|
|
851
|
+
const $pos = expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? typeof pos === 'number' && view.state.doc.resolve(pos) : pos && view.state.doc.resolve(pos);
|
|
852
852
|
const parentPos = $pos && $pos.depth ? $pos.before() : undefined;
|
|
853
853
|
const node = parentPos !== undefined ? view.state.doc.nodeAt(parentPos) : undefined;
|
|
854
854
|
const parentNodeType = node === null || node === void 0 ? void 0 : node.type.name;
|
|
@@ -883,7 +883,7 @@ export const DragHandle = ({
|
|
|
883
883
|
const bottom = editorExperiment('platform_editor_controls', 'variant1') ? getControlBottomCSSValue(safeAnchorName, isSticky, isTopLevelNode, isLayoutColumn) : {};
|
|
884
884
|
return {
|
|
885
885
|
left: isEdgeCase ? `calc(anchor(${safeAnchorName} start) + ${getLeftPosition(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType)})` : editorExperiment('advanced_layouts', true) && isLayoutColumn ? `calc((anchor(${safeAnchorName} right) + anchor(${safeAnchorName} left))/2 - ${DRAG_HANDLE_HEIGHT / 2}px)` : `calc(anchor(${safeAnchorName} start) - ${DRAG_HANDLE_WIDTH}px - ${dragHandleGap(nodeType, parentNodeType)}px)`,
|
|
886
|
-
top: editorExperiment('advanced_layouts', true) && isLayoutColumn ? `calc(anchor(${safeAnchorName} top) - ${DRAG_HANDLE_WIDTH}px)` : `calc(anchor(${safeAnchorName} start) + ${topPositionAdjustment(expValEquals('
|
|
886
|
+
top: editorExperiment('advanced_layouts', true) && isLayoutColumn ? `calc(anchor(${safeAnchorName} top) - ${DRAG_HANDLE_WIDTH}px)` : `calc(anchor(${safeAnchorName} start) + ${topPositionAdjustment(expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? $pos && $pos.nodeAfter && getNodeTypeWithLevel($pos.nodeAfter) || nodeType : nodeType)}px)`,
|
|
887
887
|
...bottom
|
|
888
888
|
};
|
|
889
889
|
}
|
|
@@ -126,7 +126,7 @@ export const DropTargetLayout = props => {
|
|
|
126
126
|
}, isDraggedOver ? jsx(DropIndicator, {
|
|
127
127
|
edge: "right",
|
|
128
128
|
gap: `-${DROP_TARGET_LAYOUT_DROP_ZONE_WIDTH}px`
|
|
129
|
-
}) : (isActiveAnchor || expValEquals('
|
|
129
|
+
}) : (isActiveAnchor || expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) && jsx("div", {
|
|
130
130
|
"data-testid": "block-ctrl-drop-hint",
|
|
131
131
|
css: dropTargetLayoutHintStyle
|
|
132
132
|
}));
|
|
@@ -240,7 +240,7 @@ export const DropTargetLayoutNativeAnchorSupport = props => {
|
|
|
240
240
|
}, isDraggedOver ? jsx(DropIndicator, {
|
|
241
241
|
edge: "right",
|
|
242
242
|
gap: `-${DROP_TARGET_LAYOUT_DROP_ZONE_WIDTH}px`
|
|
243
|
-
}) : (isActiveAnchor || expValEquals('
|
|
243
|
+
}) : (isActiveAnchor || expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) && jsx("div", {
|
|
244
244
|
"data-testid": "block-ctrl-drop-hint",
|
|
245
245
|
css: dropTargetLayoutHintStyle
|
|
246
246
|
}));
|
|
@@ -82,7 +82,7 @@ const HoverZone = ({
|
|
|
82
82
|
const ref = useRef(null);
|
|
83
83
|
const isRemainingheight = dropTargetStyle === 'remainingHeight';
|
|
84
84
|
const anchorName = useMemo(() => {
|
|
85
|
-
if (expValEquals('
|
|
85
|
+
if (expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
86
86
|
if (node && typeof pos === 'number') {
|
|
87
87
|
const posOffset = position === 'upper' ? -node.nodeSize : 0;
|
|
88
88
|
return (api === null || api === void 0 ? void 0 : api.core.actions.getAnchorIdForNode(node, pos + posOffset)) || '';
|
|
@@ -132,7 +132,7 @@ const HoverZone = ({
|
|
|
132
132
|
// only apply upper drop zone
|
|
133
133
|
if (isRemainingheight && position === 'upper') {
|
|
134
134
|
// previous node
|
|
135
|
-
const anchorName = node ? expValEquals('
|
|
135
|
+
const anchorName = node ? expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? (api === null || api === void 0 ? void 0 : api.core.actions.getAnchorIdForNode(node, pos || -1)) || '' : getNodeAnchor(node) : '';
|
|
136
136
|
let top = 'unset';
|
|
137
137
|
if (anchorName) {
|
|
138
138
|
const enabledDropZone = enableDropZone.includes((node === null || node === void 0 ? void 0 : node.type.name) || '');
|
|
@@ -4,12 +4,11 @@
|
|
|
4
4
|
*/
|
|
5
5
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles, @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
6
6
|
import { css, Global, jsx } from '@emotion/react';
|
|
7
|
-
import { ANCHOR_VARIABLE_NAME, DRAG_HANDLE_WIDTH, isCSSAnchorSupported,
|
|
7
|
+
import { ANCHOR_VARIABLE_NAME, DRAG_HANDLE_WIDTH, isCSSAnchorSupported, tableControlsSpacing } from '@atlaskit/editor-common/styles';
|
|
8
8
|
import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
|
|
9
9
|
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
10
10
|
import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/whitespace';
|
|
11
11
|
import { akEditorBreakoutPadding, akEditorCalculatedWideLayoutWidth, akEditorCalculatedWideLayoutWidthSmallViewport, akEditorFullPageNarrowBreakout, akEditorGutterPaddingDynamic, akEditorGutterPaddingReduced } from '@atlaskit/editor-shared-styles';
|
|
12
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
13
12
|
import { layers } from '@atlaskit/theme/constants';
|
|
14
13
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
15
14
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
@@ -509,19 +508,48 @@ const dragHandlerAnchorStyles = css({
|
|
|
509
508
|
}
|
|
510
509
|
}
|
|
511
510
|
});
|
|
511
|
+
|
|
512
|
+
// Styles applied to nodes with anchors when dragging
|
|
513
|
+
const dragAnchorStyles = css({
|
|
514
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
515
|
+
'.ProseMirror': {
|
|
516
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
517
|
+
'[data-node-anchor]:not([data-node-anchor] [data-node-anchor])': {
|
|
518
|
+
// all top level nodes with anchor
|
|
519
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
520
|
+
anchorName: `var(${ANCHOR_VARIABLE_NAME}, attr(data-node-anchor type(<custom-ident>)))`
|
|
521
|
+
},
|
|
522
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
523
|
+
'[data-node-anchor]:has([data-blocks-drop-target-container]) [data-node-anchor]': {
|
|
524
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
525
|
+
anchorName: `var(${ANCHOR_VARIABLE_NAME}, attr(data-node-anchor type(<custom-ident>)))`
|
|
526
|
+
},
|
|
527
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
528
|
+
'[data-prosemirror-node-name="media"][data-node-anchor]': {
|
|
529
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
530
|
+
anchorName: `var(${ANCHOR_VARIABLE_NAME}, attr(data-node-anchor type(<custom-ident>)))`
|
|
531
|
+
},
|
|
532
|
+
// first table row to avoid multiple anchors in table
|
|
533
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
534
|
+
'[data-prosemirror-node-name="table"] [data-prosemirror-node-name="tableRow"][data-node-anchor]:first-of-type': {
|
|
535
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
536
|
+
anchorName: `var(${ANCHOR_VARIABLE_NAME}, attr(data-node-anchor type(<custom-ident>)))`
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
});
|
|
512
540
|
export const GlobalStylesWrapper = ({
|
|
513
541
|
api
|
|
514
542
|
}) => {
|
|
515
543
|
const isDragging = useSharedPluginStateSelector(api, 'blockControls.isDragging', {
|
|
516
544
|
disabled: !expValEquals('platform_editor_block_controls_perf_optimization', 'isEnabled', true)
|
|
517
545
|
});
|
|
518
|
-
const shouldRenderAnchors = isCSSAnchorSupported() && expValEquals('
|
|
546
|
+
const shouldRenderAnchors = isCSSAnchorSupported() && expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true);
|
|
519
547
|
const toolbarFlagsEnabled = areToolbarFlagsEnabled(Boolean(api === null || api === void 0 ? void 0 : api.toolbar));
|
|
520
548
|
return jsx(Global, {
|
|
521
|
-
styles: [globalStyles(), globalDnDStyle, expValEquals('
|
|
549
|
+
styles: [globalStyles(), globalDnDStyle, expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? extendedHoverZoneNext() : extendedHoverZone(), isDragging && (expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? extendedDragZoneNext : extendedDragZone), editorExperiment('platform_editor_preview_panel_responsiveness', true, {
|
|
522
550
|
exposure: true
|
|
523
|
-
}) ? expValEquals('
|
|
551
|
+
}) ? expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? extendHoverZoneReducedNext : extendHoverZoneReduced : undefined,
|
|
524
552
|
// platform_editor_controls note: this allows drag handles to render on empty lines
|
|
525
|
-
toolbarFlagsEnabled ? undefined : withInlineNodeStyle, editorExperiment('platform_editor_block_control_optimise_render', true) ? quickInsertStyles : undefined, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, expValEquals('
|
|
553
|
+
toolbarFlagsEnabled ? undefined : withInlineNodeStyle, editorExperiment('platform_editor_block_control_optimise_render', true) ? quickInsertStyles : undefined, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? withRelativePosStyleNext : withRelativePosStyle, topLevelNodeMarginStyles, expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? withAnchorNameZindexStyleNext : withAnchorNameZindexStyle, expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) && expValEquals('advanced_layouts', 'isEnabled', true) ? layoutColumnExtendedHoverZone : layoutColumnWithoutHoverZone, shouldRenderAnchors && (isDragging ? dragAnchorStyles : dragHandlerAnchorStyles)]
|
|
526
554
|
});
|
|
527
555
|
};
|
|
@@ -89,7 +89,7 @@ export const InlineDropTarget = ({
|
|
|
89
89
|
const ref = useRef(null);
|
|
90
90
|
const [isDraggedOver, setIsDraggedOver] = useState(false);
|
|
91
91
|
const anchorName = useMemo(() => {
|
|
92
|
-
if (expValEquals('
|
|
92
|
+
if (expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
93
93
|
var _getPos;
|
|
94
94
|
return nextNode ? (api === null || api === void 0 ? void 0 : api.core.actions.getAnchorIdForNode(nextNode, (_getPos = getPos()) !== null && _getPos !== void 0 ? _getPos : -1)) || '' : '';
|
|
95
95
|
}
|
|
@@ -120,7 +120,7 @@ export const InlineDropTarget = ({
|
|
|
120
120
|
innerContainerWidth = `calc(var(--ak-editor--line-length) * ${percentageWidth})`;
|
|
121
121
|
}
|
|
122
122
|
} else if (nextNode.type.name === 'table' && nextNode.firstChild) {
|
|
123
|
-
const tableWidthAnchor = expValEquals('
|
|
123
|
+
const tableWidthAnchor = 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)) || '' : '' : getNodeAnchor(nextNode.firstChild);
|
|
124
124
|
const isNumberColumnEnabled = Boolean(nextNode.attrs.isNumberColumnEnabled);
|
|
125
125
|
if (isAnchorSupported()) {
|
|
126
126
|
innerContainerWidth = isNumberColumnEnabled ? `calc(anchor-size(${tableWidthAnchor} width) + ${TABLE_NUMBERED_COLUMN_WIDTH}px)` : `anchor-size(${tableWidthAnchor} width)`;
|
|
@@ -133,7 +133,7 @@ export const InlineDropTarget = ({
|
|
|
133
133
|
innerContainerWidth = `min(${nextNode.attrs.width}px, ${innerContainerWidth})`;
|
|
134
134
|
}
|
|
135
135
|
} else if (nextNode.type.name === 'mediaSingle' && nextNode.firstChild) {
|
|
136
|
-
if (expValEquals('
|
|
136
|
+
if (expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
137
137
|
var _nextNode$firstChild;
|
|
138
138
|
// check pos is a number
|
|
139
139
|
if (typeof nextNodePos === 'number' && ((_nextNode$firstChild = nextNode.firstChild) === null || _nextNode$firstChild === void 0 ? void 0 : _nextNode$firstChild.type.name) === 'media') {
|
|
@@ -148,7 +148,7 @@ export const InlineDropTarget = ({
|
|
|
148
148
|
let heightTargetAnchorName = targetAnchorName;
|
|
149
149
|
if (nextNode.type.name === 'layoutSection' && nextNode.firstChild && nextNode.lastChild) {
|
|
150
150
|
if (isLeftPosition) {
|
|
151
|
-
if (expValEquals('
|
|
151
|
+
if (expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
152
152
|
if (typeof nextNodePos === 'number') {
|
|
153
153
|
heightTargetAnchorName = (api === null || api === void 0 ? void 0 : api.core.actions.getAnchorIdForNode(nextNode.firstChild, nextNodePos + 1)) || '';
|
|
154
154
|
} else {
|
|
@@ -158,7 +158,7 @@ export const InlineDropTarget = ({
|
|
|
158
158
|
heightTargetAnchorName = getNodeAnchor(nextNode.firstChild);
|
|
159
159
|
}
|
|
160
160
|
} else {
|
|
161
|
-
if (expValEquals('
|
|
161
|
+
if (expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
162
162
|
if (typeof nextNodePos === 'number') {
|
|
163
163
|
const lastNodeStartPos = nextNode.content.size - nextNode.lastChild.nodeSize;
|
|
164
164
|
heightTargetAnchorName = (api === null || api === void 0 ? void 0 : api.core.actions.getAnchorIdForNode(nextNode.lastChild, lastNodeStartPos + 1)) || '';
|
|
@@ -11,7 +11,7 @@ export const refreshAnchorName = ({
|
|
|
11
11
|
anchorName
|
|
12
12
|
}) => {
|
|
13
13
|
let newAnchorName = anchorName || '';
|
|
14
|
-
if (expValEquals('
|
|
14
|
+
if (expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
15
15
|
return newAnchorName;
|
|
16
16
|
}
|
|
17
17
|
const pos = getPos();
|
|
@@ -2,13 +2,13 @@ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
|
2
2
|
export const NODE_ANCHOR_ATTR_NAME = 'data-node-anchor';
|
|
3
3
|
export const NODE_NODE_TYPE_ATTR_NAME = 'data-prosemirror-node-name';
|
|
4
4
|
export const getAnchorAttrName = () => {
|
|
5
|
-
if (expValEquals('
|
|
5
|
+
if (expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
6
6
|
return NODE_ANCHOR_ATTR_NAME;
|
|
7
7
|
}
|
|
8
8
|
return 'data-drag-handler-anchor-name';
|
|
9
9
|
};
|
|
10
10
|
export const getTypeNameAttrName = () => {
|
|
11
|
-
if (expValEquals('
|
|
11
|
+
if (expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
12
12
|
return NODE_NODE_TYPE_ATTR_NAME;
|
|
13
13
|
}
|
|
14
14
|
return 'data-drag-handler-node-type';
|
|
@@ -33,7 +33,7 @@ var findParentPosForHandle = function findParentPosForHandle(state) {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
// else find closest parent node
|
|
36
|
-
return expValEquals('
|
|
36
|
+
return expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ?
|
|
37
37
|
// With native anchor enabled, all nodes have anchor name attribute despite no drag handle support, e.g. listItem, caption,
|
|
38
38
|
// as opposed to old approach, node decoration is only added to the node that have drag handle,
|
|
39
39
|
// hence, we need to return the exact position of the node that can have drag handle
|
|
@@ -107,7 +107,7 @@ var findNextAnchorNode = function findNextAnchorNode(view) {
|
|
|
107
107
|
};
|
|
108
108
|
export var showDragHandleAtSelection = function showDragHandleAtSelection(api) {
|
|
109
109
|
return function (state, _, view) {
|
|
110
|
-
if (view && expValEquals('
|
|
110
|
+
if (view && expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
111
111
|
var anchorNode = findNextAnchorNode(view);
|
|
112
112
|
if (api && anchorNode) {
|
|
113
113
|
var pos = anchorNode.pos,
|
|
@@ -100,7 +100,7 @@ export var findNodeDecs = function findNodeDecs(state, decorations, from, to) {
|
|
|
100
100
|
};
|
|
101
101
|
export var nodeDecorations = function nodeDecorations(newState, from, to) {
|
|
102
102
|
var decs = [];
|
|
103
|
-
if (expValEquals('
|
|
103
|
+
if (expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
104
104
|
return [];
|
|
105
105
|
}
|
|
106
106
|
var docFrom = from === undefined || from < 0 ? 0 : from;
|
|
@@ -234,7 +234,7 @@ export var getActiveDropTargetDecorations = function getActiveDropTargetDecorati
|
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
|
-
defaultActiveAnchorTracker.emit(expValEquals('
|
|
237
|
+
defaultActiveAnchorTracker.emit(expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? api.core.actions.getAnchorIdForNode(rootNodeWithPos.node, rootNodeWithPos.pos) || '' : getNodeAnchor(rootNodeWithPos.node));
|
|
238
238
|
return {
|
|
239
239
|
decsToAdd: decsToAdd,
|
|
240
240
|
decsToRemove: decsToRemove
|
|
@@ -7,7 +7,6 @@ import uuid from 'uuid';
|
|
|
7
7
|
import { expandSelectionBounds } from '@atlaskit/editor-common/selection';
|
|
8
8
|
import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
9
9
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
10
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
10
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
12
11
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
13
12
|
import { nodeMargins } from '../ui/consts';
|
|
@@ -132,7 +131,7 @@ export var createLayoutDropTargetDecoration = function createLayoutDropTargetDec
|
|
|
132
131
|
element.setAttribute('data-blocks-drop-target-container', 'true');
|
|
133
132
|
element.setAttribute('data-blocks-drop-target-key', key);
|
|
134
133
|
element.style.clear = 'unset';
|
|
135
|
-
var DropTargetLayoutComponent = expValEquals('
|
|
134
|
+
var DropTargetLayoutComponent = expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? DropTargetLayoutNativeAnchorSupport : DropTargetLayout;
|
|
136
135
|
nodeViewPortalProviderAPI.render(function () {
|
|
137
136
|
return /*#__PURE__*/createElement(DropTargetLayoutComponent, _objectSpread(_objectSpread({}, props), {}, {
|
|
138
137
|
getPos: getPos,
|
|
@@ -15,7 +15,7 @@ export var handleMouseDown = function handleMouseDown(api) {
|
|
|
15
15
|
if (!rootNode) {
|
|
16
16
|
return false;
|
|
17
17
|
}
|
|
18
|
-
if (expValEquals('
|
|
18
|
+
if (expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
19
19
|
var _rootNode$type$name, _rootNode$type$name2;
|
|
20
20
|
var anchorName = api === null || api === void 0 ? void 0 : api.core.actions.getAnchorIdForNode(rootNode, rootPos);
|
|
21
21
|
|
|
@@ -23,7 +23,7 @@ var getNodeSelector = function getNodeSelector(ignoreNodes, ignoreNodeDescendant
|
|
|
23
23
|
return "[data-prosemirror-node-name=\"".concat(node, "\"]");
|
|
24
24
|
});
|
|
25
25
|
var ignoreNodeDescendantsSelectorList = ignoreNodeDescendants.map(function (node) {
|
|
26
|
-
if (node === 'table'
|
|
26
|
+
if (node === 'table') {
|
|
27
27
|
// Special case for table to exclude its direct descendants
|
|
28
28
|
return ["[data-prosemirror-node-name=\"tableCell\"] > [data-node-anchor]", "[data-prosemirror-node-name=\"tableHeader\"] > [data-node-anchor]"];
|
|
29
29
|
}
|
|
@@ -63,7 +63,7 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
|
|
|
63
63
|
// Ignored via go/ees005
|
|
64
64
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
65
65
|
var target = event.target;
|
|
66
|
-
var isNativeAnchorSupported = expValEquals('
|
|
66
|
+
var isNativeAnchorSupported = expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true);
|
|
67
67
|
if (target !== null && target !== void 0 && (_target$classList = target.classList) !== null && _target$classList !== void 0 && _target$classList.contains('ProseMirror')) {
|
|
68
68
|
return false;
|
|
69
69
|
}
|
|
@@ -101,7 +101,7 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
|
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
var anchorName;
|
|
104
|
-
if (expValEquals('
|
|
104
|
+
if (expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
105
105
|
anchorName = rootElement.getAttribute(getAnchorAttrName());
|
|
106
106
|
|
|
107
107
|
// don't show handles if we can't find an anchor
|
|
@@ -351,7 +351,7 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
|
|
|
351
351
|
var isNodeDecsMissing = isDecSetEmpty || maybeNodeCountChanged || editorExperiment('platform_editor_breakout_resizing', true) && hasJustFinishedResizing;
|
|
352
352
|
var shouldRedrawNodeDecs = !isResizerResizing && (isNodeDecsMissing || (meta === null || meta === void 0 ? void 0 : meta.isDragging)) &&
|
|
353
353
|
// Skip expensive anchor node decoration recalculations when native anchor support is enabled
|
|
354
|
-
!(expValEquals('
|
|
354
|
+
!(expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) && fg('editor_native_anchor_remove_decoration_in_apply'));
|
|
355
355
|
var isActiveNodeModified = false;
|
|
356
356
|
if (api && shouldRedrawNodeDecs) {
|
|
357
357
|
var oldNodeDecs = findNodeDecs(newState, decorations, from, to);
|
|
@@ -509,7 +509,7 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
|
|
|
509
509
|
}
|
|
510
510
|
}
|
|
511
511
|
var isEmptyDoc = isEmptyDocument(newState.doc);
|
|
512
|
-
if (isEmptyDoc && !expValEquals('
|
|
512
|
+
if (isEmptyDoc && !expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
513
513
|
var hasNodeDecoration = !!findNodeDecs(newState, decorations).length;
|
|
514
514
|
if (!hasNodeDecoration) {
|
|
515
515
|
decorations = decorations.add(newState.doc, [emptyParagraphNodeDecorations()]);
|
|
@@ -812,7 +812,7 @@ export var DragHandle = function DragHandle(_ref2) {
|
|
|
812
812
|
setRecalculatePosition(recalculatePosition);
|
|
813
813
|
}
|
|
814
814
|
var pos = getPos();
|
|
815
|
-
var $pos = expValEquals('
|
|
815
|
+
var $pos = expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? typeof pos === 'number' && view.state.doc.resolve(pos) : pos && view.state.doc.resolve(pos);
|
|
816
816
|
var parentPos = $pos && $pos.depth ? $pos.before() : undefined;
|
|
817
817
|
var node = parentPos !== undefined ? view.state.doc.nodeAt(parentPos) : undefined;
|
|
818
818
|
var parentNodeType = node === null || node === void 0 ? void 0 : node.type.name;
|
|
@@ -847,7 +847,7 @@ export var DragHandle = function DragHandle(_ref2) {
|
|
|
847
847
|
var bottom = editorExperiment('platform_editor_controls', 'variant1') ? getControlBottomCSSValue(safeAnchorName, isSticky, isTopLevelNode, isLayoutColumn) : {};
|
|
848
848
|
return _objectSpread({
|
|
849
849
|
left: isEdgeCase ? "calc(anchor(".concat(safeAnchorName, " start) + ").concat(getLeftPosition(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType), ")") : editorExperiment('advanced_layouts', true) && isLayoutColumn ? "calc((anchor(".concat(safeAnchorName, " right) + anchor(").concat(safeAnchorName, " left))/2 - ").concat(DRAG_HANDLE_HEIGHT / 2, "px)") : "calc(anchor(".concat(safeAnchorName, " start) - ").concat(DRAG_HANDLE_WIDTH, "px - ").concat(dragHandleGap(nodeType, parentNodeType), "px)"),
|
|
850
|
-
top: editorExperiment('advanced_layouts', true) && isLayoutColumn ? "calc(anchor(".concat(safeAnchorName, " top) - ").concat(DRAG_HANDLE_WIDTH, "px)") : "calc(anchor(".concat(safeAnchorName, " start)+ ").concat(topPositionAdjustment(expValEquals('
|
|
850
|
+
top: editorExperiment('advanced_layouts', true) && isLayoutColumn ? "calc(anchor(".concat(safeAnchorName, " top) - ").concat(DRAG_HANDLE_WIDTH, "px)") : "calc(anchor(".concat(safeAnchorName, " start)+ ").concat(topPositionAdjustment(expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? $pos && $pos.nodeAfter && getNodeTypeWithLevel($pos.nodeAfter) || nodeType : nodeType), "px)")
|
|
851
851
|
}, bottom);
|
|
852
852
|
}
|
|
853
853
|
var height = editorExperiment('platform_editor_controls', 'variant1') ? getControlHeightCSSValue(getNodeHeight(dom, safeAnchorName, anchorRectCache) || 0, isSticky, isTopLevelNode, "".concat(DRAG_HANDLE_HEIGHT), isLayoutColumn) : {};
|
|
@@ -858,7 +858,7 @@ export var DragHandle = function DragHandle(_ref2) {
|
|
|
858
858
|
}, [anchorName, getPos, view, nodeType, macroInteractionUpdates, anchorRectCache, isTopLevelNode, isLayoutColumn, recalculatePosition]);
|
|
859
859
|
var calculatePositionOld = useCallback(function () {
|
|
860
860
|
var pos = getPos();
|
|
861
|
-
var $pos = expValEquals('
|
|
861
|
+
var $pos = expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? typeof pos === 'number' && view.state.doc.resolve(pos) : pos && view.state.doc.resolve(pos);
|
|
862
862
|
var parentPos = $pos && $pos.depth ? $pos.before() : undefined;
|
|
863
863
|
var node = parentPos !== undefined ? view.state.doc.nodeAt(parentPos) : undefined;
|
|
864
864
|
var parentNodeType = node === null || node === void 0 ? void 0 : node.type.name;
|
|
@@ -893,7 +893,7 @@ export var DragHandle = function DragHandle(_ref2) {
|
|
|
893
893
|
var bottom = editorExperiment('platform_editor_controls', 'variant1') ? getControlBottomCSSValue(safeAnchorName, isSticky, isTopLevelNode, isLayoutColumn) : {};
|
|
894
894
|
return _objectSpread({
|
|
895
895
|
left: isEdgeCase ? "calc(anchor(".concat(safeAnchorName, " start) + ").concat(getLeftPosition(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType), ")") : editorExperiment('advanced_layouts', true) && isLayoutColumn ? "calc((anchor(".concat(safeAnchorName, " right) + anchor(").concat(safeAnchorName, " left))/2 - ").concat(DRAG_HANDLE_HEIGHT / 2, "px)") : "calc(anchor(".concat(safeAnchorName, " start) - ").concat(DRAG_HANDLE_WIDTH, "px - ").concat(dragHandleGap(nodeType, parentNodeType), "px)"),
|
|
896
|
-
top: editorExperiment('advanced_layouts', true) && isLayoutColumn ? "calc(anchor(".concat(safeAnchorName, " top) - ").concat(DRAG_HANDLE_WIDTH, "px)") : "calc(anchor(".concat(safeAnchorName, " start) + ").concat(topPositionAdjustment(expValEquals('
|
|
896
|
+
top: editorExperiment('advanced_layouts', true) && isLayoutColumn ? "calc(anchor(".concat(safeAnchorName, " top) - ").concat(DRAG_HANDLE_WIDTH, "px)") : "calc(anchor(".concat(safeAnchorName, " start) + ").concat(topPositionAdjustment(expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? $pos && $pos.nodeAfter && getNodeTypeWithLevel($pos.nodeAfter) || nodeType : nodeType), "px)")
|
|
897
897
|
}, bottom);
|
|
898
898
|
}
|
|
899
899
|
var height = editorExperiment('platform_editor_controls', 'variant1') ? getControlHeightCSSValue(getNodeHeight(dom, safeAnchorName, anchorRectCache) || 0, isSticky, isTopLevelNode, "".concat(DRAG_HANDLE_HEIGHT), isLayoutColumn) : {};
|
|
@@ -122,7 +122,7 @@ export var DropTargetLayout = function DropTargetLayout(props) {
|
|
|
122
122
|
}, isDraggedOver ? jsx(DropIndicator, {
|
|
123
123
|
edge: "right",
|
|
124
124
|
gap: "-".concat(DROP_TARGET_LAYOUT_DROP_ZONE_WIDTH, "px")
|
|
125
|
-
}) : (isActiveAnchor || expValEquals('
|
|
125
|
+
}) : (isActiveAnchor || expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) && jsx("div", {
|
|
126
126
|
"data-testid": "block-ctrl-drop-hint",
|
|
127
127
|
css: dropTargetLayoutHintStyle
|
|
128
128
|
}));
|
|
@@ -237,7 +237,7 @@ export var DropTargetLayoutNativeAnchorSupport = function DropTargetLayoutNative
|
|
|
237
237
|
}, isDraggedOver ? jsx(DropIndicator, {
|
|
238
238
|
edge: "right",
|
|
239
239
|
gap: "-".concat(DROP_TARGET_LAYOUT_DROP_ZONE_WIDTH, "px")
|
|
240
|
-
}) : (isActiveAnchor || expValEquals('
|
|
240
|
+
}) : (isActiveAnchor || expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) && jsx("div", {
|
|
241
241
|
"data-testid": "block-ctrl-drop-hint",
|
|
242
242
|
css: dropTargetLayoutHintStyle
|
|
243
243
|
}));
|
|
@@ -83,7 +83,7 @@ var HoverZone = function HoverZone(_ref) {
|
|
|
83
83
|
var ref = useRef(null);
|
|
84
84
|
var isRemainingheight = dropTargetStyle === 'remainingHeight';
|
|
85
85
|
var anchorName = useMemo(function () {
|
|
86
|
-
if (expValEquals('
|
|
86
|
+
if (expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
87
87
|
if (node && typeof pos === 'number') {
|
|
88
88
|
var posOffset = position === 'upper' ? -node.nodeSize : 0;
|
|
89
89
|
return (api === null || api === void 0 ? void 0 : api.core.actions.getAnchorIdForNode(node, pos + posOffset)) || '';
|
|
@@ -136,7 +136,7 @@ var HoverZone = function HoverZone(_ref) {
|
|
|
136
136
|
// only apply upper drop zone
|
|
137
137
|
if (isRemainingheight && position === 'upper') {
|
|
138
138
|
// previous node
|
|
139
|
-
var _anchorName = node ? expValEquals('
|
|
139
|
+
var _anchorName = node ? expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? (api === null || api === void 0 ? void 0 : api.core.actions.getAnchorIdForNode(node, pos || -1)) || '' : getNodeAnchor(node) : '';
|
|
140
140
|
var top = 'unset';
|
|
141
141
|
if (_anchorName) {
|
|
142
142
|
var enabledDropZone = enableDropZone.includes((node === null || node === void 0 ? void 0 : node.type.name) || '');
|
|
@@ -5,12 +5,11 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
5
5
|
*/
|
|
6
6
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles, @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
7
7
|
import { css, Global, jsx } from '@emotion/react';
|
|
8
|
-
import { ANCHOR_VARIABLE_NAME, DRAG_HANDLE_WIDTH, isCSSAnchorSupported,
|
|
8
|
+
import { ANCHOR_VARIABLE_NAME, DRAG_HANDLE_WIDTH, isCSSAnchorSupported, tableControlsSpacing } from '@atlaskit/editor-common/styles';
|
|
9
9
|
import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
|
|
10
10
|
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
11
11
|
import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/whitespace';
|
|
12
12
|
import { akEditorBreakoutPadding, akEditorCalculatedWideLayoutWidth, akEditorCalculatedWideLayoutWidthSmallViewport, akEditorFullPageNarrowBreakout, akEditorGutterPaddingDynamic, akEditorGutterPaddingReduced } from '@atlaskit/editor-shared-styles';
|
|
13
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
14
13
|
import { layers } from '@atlaskit/theme/constants';
|
|
15
14
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
16
15
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
@@ -424,18 +423,47 @@ var dragHandlerAnchorStyles = css({
|
|
|
424
423
|
}
|
|
425
424
|
}
|
|
426
425
|
});
|
|
426
|
+
|
|
427
|
+
// Styles applied to nodes with anchors when dragging
|
|
428
|
+
var dragAnchorStyles = css({
|
|
429
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
430
|
+
'.ProseMirror': {
|
|
431
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
432
|
+
'[data-node-anchor]:not([data-node-anchor] [data-node-anchor])': {
|
|
433
|
+
// all top level nodes with anchor
|
|
434
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
435
|
+
anchorName: "var(".concat(ANCHOR_VARIABLE_NAME, ", attr(data-node-anchor type(<custom-ident>)))")
|
|
436
|
+
},
|
|
437
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
438
|
+
'[data-node-anchor]:has([data-blocks-drop-target-container]) [data-node-anchor]': {
|
|
439
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
440
|
+
anchorName: "var(".concat(ANCHOR_VARIABLE_NAME, ", attr(data-node-anchor type(<custom-ident>)))")
|
|
441
|
+
},
|
|
442
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
443
|
+
'[data-prosemirror-node-name="media"][data-node-anchor]': {
|
|
444
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
445
|
+
anchorName: "var(".concat(ANCHOR_VARIABLE_NAME, ", attr(data-node-anchor type(<custom-ident>)))")
|
|
446
|
+
},
|
|
447
|
+
// first table row to avoid multiple anchors in table
|
|
448
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
449
|
+
'[data-prosemirror-node-name="table"] [data-prosemirror-node-name="tableRow"][data-node-anchor]:first-of-type': {
|
|
450
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
451
|
+
anchorName: "var(".concat(ANCHOR_VARIABLE_NAME, ", attr(data-node-anchor type(<custom-ident>)))")
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
});
|
|
427
455
|
export var GlobalStylesWrapper = function GlobalStylesWrapper(_ref) {
|
|
428
456
|
var api = _ref.api;
|
|
429
457
|
var isDragging = useSharedPluginStateSelector(api, 'blockControls.isDragging', {
|
|
430
458
|
disabled: !expValEquals('platform_editor_block_controls_perf_optimization', 'isEnabled', true)
|
|
431
459
|
});
|
|
432
|
-
var shouldRenderAnchors = isCSSAnchorSupported() && expValEquals('
|
|
460
|
+
var shouldRenderAnchors = isCSSAnchorSupported() && expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true);
|
|
433
461
|
var toolbarFlagsEnabled = areToolbarFlagsEnabled(Boolean(api === null || api === void 0 ? void 0 : api.toolbar));
|
|
434
462
|
return jsx(Global, {
|
|
435
|
-
styles: [globalStyles(), globalDnDStyle, expValEquals('
|
|
463
|
+
styles: [globalStyles(), globalDnDStyle, expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? extendedHoverZoneNext() : extendedHoverZone(), isDragging && (expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? extendedDragZoneNext : extendedDragZone), editorExperiment('platform_editor_preview_panel_responsiveness', true, {
|
|
436
464
|
exposure: true
|
|
437
|
-
}) ? expValEquals('
|
|
465
|
+
}) ? expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? extendHoverZoneReducedNext : extendHoverZoneReduced : undefined,
|
|
438
466
|
// platform_editor_controls note: this allows drag handles to render on empty lines
|
|
439
|
-
toolbarFlagsEnabled ? undefined : withInlineNodeStyle, editorExperiment('platform_editor_block_control_optimise_render', true) ? quickInsertStyles : undefined, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, expValEquals('
|
|
467
|
+
toolbarFlagsEnabled ? undefined : withInlineNodeStyle, editorExperiment('platform_editor_block_control_optimise_render', true) ? quickInsertStyles : undefined, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? withRelativePosStyleNext : withRelativePosStyle, topLevelNodeMarginStyles, expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? withAnchorNameZindexStyleNext : withAnchorNameZindexStyle, expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) && expValEquals('advanced_layouts', 'isEnabled', true) ? layoutColumnExtendedHoverZone : layoutColumnWithoutHoverZone, shouldRenderAnchors && (isDragging ? dragAnchorStyles : dragHandlerAnchorStyles)]
|
|
440
468
|
});
|
|
441
469
|
};
|
|
@@ -93,7 +93,7 @@ export var InlineDropTarget = function InlineDropTarget(_ref) {
|
|
|
93
93
|
isDraggedOver = _useState2[0],
|
|
94
94
|
setIsDraggedOver = _useState2[1];
|
|
95
95
|
var anchorName = useMemo(function () {
|
|
96
|
-
if (expValEquals('
|
|
96
|
+
if (expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
97
97
|
var _getPos;
|
|
98
98
|
return nextNode ? (api === null || api === void 0 ? void 0 : api.core.actions.getAnchorIdForNode(nextNode, (_getPos = getPos()) !== null && _getPos !== void 0 ? _getPos : -1)) || '' : '';
|
|
99
99
|
}
|
|
@@ -126,7 +126,7 @@ export var InlineDropTarget = function InlineDropTarget(_ref) {
|
|
|
126
126
|
innerContainerWidth = "calc(var(--ak-editor--line-length) * ".concat(percentageWidth, ")");
|
|
127
127
|
}
|
|
128
128
|
} else if (nextNode.type.name === 'table' && nextNode.firstChild) {
|
|
129
|
-
var tableWidthAnchor = expValEquals('
|
|
129
|
+
var tableWidthAnchor = 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)) || '' : '' : getNodeAnchor(nextNode.firstChild);
|
|
130
130
|
var isNumberColumnEnabled = Boolean(nextNode.attrs.isNumberColumnEnabled);
|
|
131
131
|
if (isAnchorSupported()) {
|
|
132
132
|
innerContainerWidth = isNumberColumnEnabled ? "calc(anchor-size(".concat(tableWidthAnchor, " width) + ").concat(TABLE_NUMBERED_COLUMN_WIDTH, "px)") : "anchor-size(".concat(tableWidthAnchor, " width)");
|
|
@@ -139,7 +139,7 @@ export var InlineDropTarget = function InlineDropTarget(_ref) {
|
|
|
139
139
|
innerContainerWidth = "min(".concat(nextNode.attrs.width, "px, ").concat(innerContainerWidth, ")");
|
|
140
140
|
}
|
|
141
141
|
} else if (nextNode.type.name === 'mediaSingle' && nextNode.firstChild) {
|
|
142
|
-
if (expValEquals('
|
|
142
|
+
if (expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
143
143
|
var _nextNode$firstChild;
|
|
144
144
|
// check pos is a number
|
|
145
145
|
if (typeof nextNodePos === 'number' && ((_nextNode$firstChild = nextNode.firstChild) === null || _nextNode$firstChild === void 0 ? void 0 : _nextNode$firstChild.type.name) === 'media') {
|
|
@@ -154,7 +154,7 @@ export var InlineDropTarget = function InlineDropTarget(_ref) {
|
|
|
154
154
|
var heightTargetAnchorName = targetAnchorName;
|
|
155
155
|
if (nextNode.type.name === 'layoutSection' && nextNode.firstChild && nextNode.lastChild) {
|
|
156
156
|
if (isLeftPosition) {
|
|
157
|
-
if (expValEquals('
|
|
157
|
+
if (expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
158
158
|
if (typeof nextNodePos === 'number') {
|
|
159
159
|
heightTargetAnchorName = (api === null || api === void 0 ? void 0 : api.core.actions.getAnchorIdForNode(nextNode.firstChild, nextNodePos + 1)) || '';
|
|
160
160
|
} else {
|
|
@@ -164,7 +164,7 @@ export var InlineDropTarget = function InlineDropTarget(_ref) {
|
|
|
164
164
|
heightTargetAnchorName = getNodeAnchor(nextNode.firstChild);
|
|
165
165
|
}
|
|
166
166
|
} else {
|
|
167
|
-
if (expValEquals('
|
|
167
|
+
if (expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
168
168
|
if (typeof nextNodePos === 'number') {
|
|
169
169
|
var lastNodeStartPos = nextNode.content.size - nextNode.lastChild.nodeSize;
|
|
170
170
|
heightTargetAnchorName = (api === null || api === void 0 ? void 0 : api.core.actions.getAnchorIdForNode(nextNode.lastChild, lastNodeStartPos + 1)) || '';
|
|
@@ -10,7 +10,7 @@ export var refreshAnchorName = function refreshAnchorName(_ref) {
|
|
|
10
10
|
view = _ref.view,
|
|
11
11
|
anchorName = _ref.anchorName;
|
|
12
12
|
var newAnchorName = anchorName || '';
|
|
13
|
-
if (expValEquals('
|
|
13
|
+
if (expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
14
14
|
return newAnchorName;
|
|
15
15
|
}
|
|
16
16
|
var pos = getPos();
|
|
@@ -2,13 +2,13 @@ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
|
2
2
|
export var NODE_ANCHOR_ATTR_NAME = 'data-node-anchor';
|
|
3
3
|
export var NODE_NODE_TYPE_ATTR_NAME = 'data-prosemirror-node-name';
|
|
4
4
|
export var getAnchorAttrName = function getAnchorAttrName() {
|
|
5
|
-
if (expValEquals('
|
|
5
|
+
if (expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
6
6
|
return NODE_ANCHOR_ATTR_NAME;
|
|
7
7
|
}
|
|
8
8
|
return 'data-drag-handler-anchor-name';
|
|
9
9
|
};
|
|
10
10
|
export var getTypeNameAttrName = function getTypeNameAttrName() {
|
|
11
|
-
if (expValEquals('
|
|
11
|
+
if (expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
12
12
|
return NODE_NODE_TYPE_ATTR_NAME;
|
|
13
13
|
}
|
|
14
14
|
return 'data-drag-handler-node-type';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.10.0",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
"@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^3.2.0",
|
|
55
55
|
"@atlaskit/primitives": "^16.4.0",
|
|
56
56
|
"@atlaskit/theme": "^21.0.0",
|
|
57
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
58
|
-
"@atlaskit/tokens": "^8.
|
|
57
|
+
"@atlaskit/tmp-editor-statsig": "^14.0.0",
|
|
58
|
+
"@atlaskit/tokens": "^8.4.0",
|
|
59
59
|
"@atlaskit/tooltip": "^20.10.0",
|
|
60
60
|
"@babel/runtime": "^7.0.0",
|
|
61
61
|
"@emotion/react": "^11.7.1",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"uuid": "^3.1.0"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
|
-
"@atlaskit/editor-common": "^110.
|
|
69
|
+
"@atlaskit/editor-common": "^110.36.0",
|
|
70
70
|
"react": "^18.2.0",
|
|
71
71
|
"react-dom": "^18.2.0",
|
|
72
72
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
@@ -143,9 +143,6 @@
|
|
|
143
143
|
"dst-a11y__replace-anchor-with-link__editor-jenga": {
|
|
144
144
|
"type": "boolean"
|
|
145
145
|
},
|
|
146
|
-
"platform_native_anchor_use_css_style": {
|
|
147
|
-
"type": "boolean"
|
|
148
|
-
},
|
|
149
146
|
"editor_native_anchor_remove_decoration_in_apply": {
|
|
150
147
|
"type": "boolean"
|
|
151
148
|
},
|
|
@@ -154,12 +151,6 @@
|
|
|
154
151
|
},
|
|
155
152
|
"platform_editor_toolbar_aifc_user_intent_fix": {
|
|
156
153
|
"type": "boolean"
|
|
157
|
-
},
|
|
158
|
-
"platform_editor_native_anchor_table_nested_fix": {
|
|
159
|
-
"type": "boolean"
|
|
160
|
-
},
|
|
161
|
-
"editor_native_anchor_update_layout_drop_hint": {
|
|
162
|
-
"type": "boolean"
|
|
163
154
|
}
|
|
164
155
|
}
|
|
165
156
|
}
|