@atlaskit/editor-plugin-block-controls 2.4.0 → 2.5.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 +22 -0
- package/dist/cjs/ui/consts.js +6 -2
- package/dist/cjs/ui/drop-target.js +31 -1
- package/dist/cjs/ui/global-styles.js +8 -1
- package/dist/cjs/utils/validation.js +17 -0
- package/dist/es2019/ui/consts.js +5 -1
- package/dist/es2019/ui/drop-target.js +32 -2
- package/dist/es2019/ui/global-styles.js +11 -1
- package/dist/es2019/utils/validation.js +17 -0
- package/dist/esm/ui/consts.js +5 -1
- package/dist/esm/ui/drop-target.js +32 -2
- package/dist/esm/ui/global-styles.js +8 -1
- package/dist/esm/utils/validation.js +17 -0
- package/dist/types/ui/consts.d.ts +3 -0
- package/dist/types-ts4.5/ui/consts.d.ts +3 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 2.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#151707](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/151707)
|
|
8
|
+
[`e20a1b9e9ead0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/e20a1b9e9ead0) -
|
|
9
|
+
ED-25277 1 Port "nest-media-and-codeblock-in-quote" changes in drop target v2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
15
|
+
## 2.4.1
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [`9bbad837abcb7`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/9bbad837abcb7) -
|
|
20
|
+
[ux] ED-25119 Fix content shifting on drag if divider or media nested in panel
|
|
21
|
+
- [#151581](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/151581)
|
|
22
|
+
[`5a182ebfe8da5`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5a182ebfe8da5) -
|
|
23
|
+
[ux] Fix jittering issue in layout node when there is alignment or indentation applied
|
|
24
|
+
|
|
3
25
|
## 2.4.0
|
|
4
26
|
|
|
5
27
|
### Minor Changes
|
package/dist/cjs/ui/consts.js
CHANGED
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.topPositionAdjustment = exports.spaceLookupMap = exports.nodeMargins = exports.getNestedNodeLeftPaddingMargin = exports.dragHandleGap = exports.DRAG_HANDLE_ZINDEX = exports.DRAG_HANDLE_WIDTH = exports.DRAG_HANDLE_NARROW_GAP = exports.DRAG_HANDLE_MAX_WIDTH_PLUS_GAP = exports.DRAG_HANDLE_MAX_GAP = exports.DRAG_HANDLE_HEIGHT = exports.DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT = exports.DRAG_HANDLE_DEFAULT_GAP = exports.DRAG_HANDLE_BORDER_RADIUS = void 0;
|
|
7
|
+
exports.topPositionAdjustment = exports.spaceLookupMap = exports.nodeMargins = exports.getNestedNodeLeftPaddingMargin = exports.dropTargetMarginMap = exports.dragHandleGap = exports.DRAG_HANDLE_ZINDEX = exports.DRAG_HANDLE_WIDTH = exports.DRAG_HANDLE_NARROW_GAP = exports.DRAG_HANDLE_MAX_WIDTH_PLUS_GAP = exports.DRAG_HANDLE_MAX_GAP = exports.DRAG_HANDLE_HEIGHT = exports.DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT = exports.DRAG_HANDLE_DEFAULT_GAP = exports.DRAG_HANDLE_BORDER_RADIUS = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
10
10
|
var _dropTargetMarginMap;
|
|
@@ -57,7 +57,7 @@ var topPositionAdjustment = exports.topPositionAdjustment = function topPosition
|
|
|
57
57
|
return 0;
|
|
58
58
|
}
|
|
59
59
|
};
|
|
60
|
-
var dropTargetMarginMap = (_dropTargetMarginMap = {}, (0, _defineProperty2.default)(_dropTargetMarginMap, -24, "var(--ds-space-negative-300, -24px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, -20, "var(--ds-space-negative-250, -20px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, -16, "var(--ds-space-negative-200, -16px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, -12, "var(--ds-space-negative-150, -12px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, -8, "var(--ds-space-negative-100, -8px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, -6, "var(--ds-space-negative-075, -6px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, -4, "var(--ds-space-negative-050, -4px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, -2, "var(--ds-space-negative-025, -2px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, 0, "var(--ds-space-0, 0)"), (0, _defineProperty2.default)(_dropTargetMarginMap, 2, "var(--ds-space-025, 2px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, 4, "var(--ds-space-050, 4px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, 6, "var(--ds-space-075, 6px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, 8, "var(--ds-space-100, 8px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, 12, "var(--ds-space-150, 12px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, 16, "var(--ds-space-200, 16px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, 20, "var(--ds-space-250, 20px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, 24, "var(--ds-space-300, 24px)"), _dropTargetMarginMap);
|
|
60
|
+
var dropTargetMarginMap = exports.dropTargetMarginMap = (_dropTargetMarginMap = {}, (0, _defineProperty2.default)(_dropTargetMarginMap, -24, "var(--ds-space-negative-300, -24px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, -20, "var(--ds-space-negative-250, -20px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, -16, "var(--ds-space-negative-200, -16px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, -12, "var(--ds-space-negative-150, -12px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, -8, "var(--ds-space-negative-100, -8px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, -6, "var(--ds-space-negative-075, -6px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, -4, "var(--ds-space-negative-050, -4px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, -2, "var(--ds-space-negative-025, -2px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, 0, "var(--ds-space-0, 0)"), (0, _defineProperty2.default)(_dropTargetMarginMap, 2, "var(--ds-space-025, 2px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, 4, "var(--ds-space-050, 4px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, 6, "var(--ds-space-075, 6px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, 8, "var(--ds-space-100, 8px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, 12, "var(--ds-space-150, 12px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, 16, "var(--ds-space-200, 16px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, 20, "var(--ds-space-250, 20px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, 24, "var(--ds-space-300, 24px)"), _dropTargetMarginMap);
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
63
|
* This document serves as a quick reference map for correlating various space matches
|
|
@@ -122,6 +122,10 @@ var nodeMargins = exports.nodeMargins = {
|
|
|
122
122
|
top: 24,
|
|
123
123
|
bottom: 24
|
|
124
124
|
},
|
|
125
|
+
media: {
|
|
126
|
+
top: 24,
|
|
127
|
+
bottom: 24
|
|
128
|
+
},
|
|
125
129
|
bodiedExtension: {
|
|
126
130
|
top: 0,
|
|
127
131
|
bottom: 0
|
|
@@ -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 _hooks = require("@atlaskit/editor-common/hooks");
|
|
13
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
14
|
var _box = require("@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box");
|
|
14
15
|
var _adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
|
|
15
16
|
var _constants = require("@atlaskit/theme/constants");
|
|
@@ -66,6 +67,24 @@ var getNodeMargins = function getNodeMargins(node) {
|
|
|
66
67
|
}
|
|
67
68
|
return _consts.nodeMargins[nodeTypeName] || _consts.nodeMargins['default'];
|
|
68
69
|
};
|
|
70
|
+
var getNestedDropTargetMarginTop = function getNestedDropTargetMarginTop(prevNode, nextNode, isNestedDropTarget) {
|
|
71
|
+
if (!prevNode || !nextNode) {
|
|
72
|
+
return (0, _react2.css)({
|
|
73
|
+
marginTop: "var(--ds-space-negative-100, -8px)"
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
var top = getNodeMargins(nextNode).top;
|
|
77
|
+
var bottom = getNodeMargins(prevNode).bottom;
|
|
78
|
+
if (['rule', 'media', 'mediaSingle'].includes(prevNode.type.name) && isNestedDropTarget && top > 0 && bottom > 0) {
|
|
79
|
+
var collapsedMarginOffset = top === bottom ? top : Math.abs(top - bottom);
|
|
80
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values
|
|
81
|
+
var marginTop = _consts.dropTargetMarginMap[-collapsedMarginOffset - 8] || "-".concat(collapsedMarginOffset + 8, "px");
|
|
82
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
83
|
+
return (0, _react2.css)({
|
|
84
|
+
marginTop: marginTop
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
};
|
|
69
88
|
var getDropTargetOffsetStyle = function getDropTargetOffsetStyle(prevNode, nextNode) {
|
|
70
89
|
if (!prevNode || !nextNode) {
|
|
71
90
|
return null;
|
|
@@ -101,6 +120,8 @@ var DropTarget = exports.DropTarget = function DropTarget(_ref3) {
|
|
|
101
120
|
return;
|
|
102
121
|
}
|
|
103
122
|
|
|
123
|
+
// This should be moved to platform/packages/editor/editor-plugin-block-controls/src/utils/validation.ts
|
|
124
|
+
// Since we are moved to drop-target-v2
|
|
104
125
|
// Place experiments here instead of just inside move-node.ts as it stops the drag marker from appearing.
|
|
105
126
|
if ((0, _experiments.editorExperiment)('nest-media-and-codeblock-in-quote', false)) {
|
|
106
127
|
var _api$blockControls;
|
|
@@ -159,14 +180,23 @@ var DropTarget = exports.DropTarget = function DropTarget(_ref3) {
|
|
|
159
180
|
}
|
|
160
181
|
return getDropTargetOffsetStyle(prevNode, nextNode);
|
|
161
182
|
}, [prevNode, nextNode, parentNode]);
|
|
183
|
+
var dropTargetMarginTopStyles = (0, _react.useMemo)(function () {
|
|
184
|
+
if (parentNode === prevNode) {
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
return getNestedDropTargetMarginTop(prevNode, nextNode, isNestedDropTarget);
|
|
188
|
+
}, [prevNode, nextNode, parentNode, isNestedDropTarget]);
|
|
162
189
|
var dynamicStyle = (_dynamicStyle = {
|
|
163
190
|
width: isNestedDropTarget ? 'unset' : '100%'
|
|
164
191
|
}, (0, _defineProperty2.default)(_dynamicStyle, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH, isNestedDropTarget ? '100%' : "".concat((widthState === null || widthState === void 0 ? void 0 : widthState.lineLength) || DEFAULT_DROP_INDICATOR_WIDTH, "px")), (0, _defineProperty2.default)(_dynamicStyle, EDITOR_BLOCK_CONTROLS_DROP_TARGET_LEFT_MARGIN, isNestedDropTarget ? (0, _consts.getNestedNodeLeftPaddingMargin)(parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name) : '0'), (0, _defineProperty2.default)(_dynamicStyle, EDITOR_BLOCK_CONTROLS_DROP_TARGET_ZINDEX, (0, _experiments.editorExperiment)('nested-dnd', true) ? _constants.layers.navigation() : _constants.layers.card()), _dynamicStyle);
|
|
165
192
|
return (
|
|
166
193
|
// Note: Firefox has trouble with using a button element as the handle for drag and drop
|
|
167
194
|
(0, _react2.jsx)("div", {
|
|
195
|
+
css: [styleDropTarget,
|
|
196
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
197
|
+
dropTargetOffsetStyle, isNestedDropTarget && nestedDropIndicatorStyle,
|
|
168
198
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
169
|
-
|
|
199
|
+
(0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_fix_patch_2') && dropTargetMarginTopStyles]
|
|
170
200
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
171
201
|
,
|
|
172
202
|
style: dynamicStyle,
|
|
@@ -110,6 +110,7 @@ var indentatedParagraphWithTrailingBreakAsOnlyChild = '+ div.fabric-editor-inden
|
|
|
110
110
|
var paragraphWithPlaceholder = '+ p > .placeholder-decoration';
|
|
111
111
|
var dragHandleContainer = '.ProseMirror-widget[data-blocks-drag-handle-container="true"]';
|
|
112
112
|
var dragHandleSelector = 'button[data-testid="block-ctrl-drag-handle"]';
|
|
113
|
+
var dropTargetContainer = '.ProseMirror-widget[data-blocks-drop-target-container="true"]';
|
|
113
114
|
var withInlineNodeStyleSelectors = [".ProseMirror-widget[data-blocks-drag-handle-container=\"true\"]:has(".concat(paragraphWithTrailingBreakAsOnlyChild, ")"), ".ProseMirror-widget[data-blocks-drag-handle-container=\"true\"]:has(".concat(indentatedParagraphWithTrailingBreakAsOnlyChild, ")"), ".ProseMirror-widget[data-blocks-drag-handle-container=\"true\"]:has(".concat(paragraphWithPlaceholder, ")")].join(', ');
|
|
114
115
|
var dividerBodiedInCustomPanelWithNoIconSelector = '[data-panel-type].ak-editor-panel__no-icon .ProseMirror-widget:first-child + .ProseMirror-widget:nth-child(2) + hr, [data-panel-type] hr:first-child';
|
|
115
116
|
var withInlineNodeStyle = (0, _react.css)((0, _defineProperty2.default)({}, withInlineNodeStyleSelectors, {
|
|
@@ -117,6 +118,8 @@ var withInlineNodeStyle = (0, _react.css)((0, _defineProperty2.default)({}, with
|
|
|
117
118
|
display: 'none !important'
|
|
118
119
|
}));
|
|
119
120
|
var withInlineNodeStyleWithChromeFixSelectors = ["".concat(dragHandleContainer, ":has(").concat(paragraphWithTrailingBreakAsOnlyChild, ") ").concat(dragHandleSelector), "".concat(dragHandleContainer, ":has(").concat(indentatedParagraphWithTrailingBreakAsOnlyChild, ") ").concat(dragHandleSelector), "".concat(dragHandleContainer, ":has(").concat(paragraphWithPlaceholder, ") ").concat(dragHandleSelector)].join(', ');
|
|
121
|
+
var withFormatInLayoutStyleFixSelectors = ["".concat(dragHandleContainer, ":first-child + .fabric-editor-indentation-mark > p:first-child"), "".concat(dragHandleContainer, ":first-child + .fabric-editor-alignment > p:first-child"), "".concat(dragHandleContainer, ":first-child + ").concat(dropTargetContainer, " + .fabric-editor-indentation-mark > p:first-child"), "".concat(dragHandleContainer, ":first-child + ").concat(dropTargetContainer, " + .fabric-editor-alignment > p:first-child"), "".concat(dropTargetContainer, ":first-child + .fabric-editor-alignment > p:first-child"), "".concat(dropTargetContainer, ":first-child + .fabric-editor-indentation-mark > p:first-child")].join(', ');
|
|
122
|
+
|
|
120
123
|
/**
|
|
121
124
|
* Please do not change change transform to display:none, or visibility:hidden
|
|
122
125
|
* Otherwise it might break composition input for Chrome
|
|
@@ -153,6 +156,10 @@ var withMediaSingleStyleFix = (0, _react.css)((0, _defineProperty2.default)({},
|
|
|
153
156
|
userSelect: 'auto',
|
|
154
157
|
cursor: 'pointer'
|
|
155
158
|
}));
|
|
159
|
+
var withFormatInLayoutStyleFix = (0, _react.css)((0, _defineProperty2.default)({}, "".concat(withFormatInLayoutStyleFixSelectors), {
|
|
160
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
|
|
161
|
+
marginTop: '0 !important'
|
|
162
|
+
}));
|
|
156
163
|
var getTextNodeStyle = function getTextNodeStyle() {
|
|
157
164
|
return (0, _platformFeatureFlags.fg)('platform_editor_element_controls_chrome_input_fix') ? withInlineNodeStyleWithChromeFix : withInlineNodeStyle;
|
|
158
165
|
};
|
|
@@ -160,6 +167,6 @@ var GlobalStylesWrapper = exports.GlobalStylesWrapper = function GlobalStylesWra
|
|
|
160
167
|
return (0, _react.jsx)(_react.Global, {
|
|
161
168
|
styles: [globalStyles, (0, _experiments.editorExperiment)('nested-dnd', true) ? extendedHoverZoneNested : extendedHoverZone, getTextNodeStyle(), withDeleteLinesStyleFix, withMediaSingleStyleFix, (0, _experiments.editorExperiment)('platform_editor_empty_line_prompt', true, {
|
|
162
169
|
exposure: false
|
|
163
|
-
}) ? _globalStyles.emptyBlockExperimentGlobalStyles : undefined, (0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_fix_patch_1') ? withDividerInPanelStyleFix : undefined]
|
|
170
|
+
}) ? _globalStyles.emptyBlockExperimentGlobalStyles : undefined, (0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_fix_patch_1') ? withDividerInPanelStyleFix : undefined, (0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_fix_patch_2') ? withFormatInLayoutStyleFix : undefined]
|
|
164
171
|
});
|
|
165
172
|
};
|
|
@@ -8,6 +8,7 @@ exports.canMoveNodeToIndex = canMoveNodeToIndex;
|
|
|
8
8
|
exports.transformSliceExpandToNestedExpand = exports.transformExpandToNestedExpand = exports.memoizedTransformExpandToNestedExpand = exports.isNestedExpand = exports.isLayoutColumn = exports.isInsideTable = exports.isExpand = exports.isDoc = void 0;
|
|
9
9
|
var _memoizeOne = _interopRequireDefault(require("memoize-one"));
|
|
10
10
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
11
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
11
12
|
var isInsideTable = exports.isInsideTable = function isInsideTable(nodeType) {
|
|
12
13
|
var _nodeType$schema$node = nodeType.schema.nodes,
|
|
13
14
|
tableCell = _nodeType$schema$node.tableCell,
|
|
@@ -70,6 +71,22 @@ var memoizedTransformExpandToNestedExpand = exports.memoizedTransformExpandToNes
|
|
|
70
71
|
});
|
|
71
72
|
function canMoveNodeToIndex(destParent, indexIntoParent, srcNode) {
|
|
72
73
|
var srcNodeType = srcNode.type;
|
|
74
|
+
var parentNodeType = destParent === null || destParent === void 0 ? void 0 : destParent.type.name;
|
|
75
|
+
var activeNodeType = srcNode === null || srcNode === void 0 ? void 0 : srcNode.type.name;
|
|
76
|
+
|
|
77
|
+
// Place experiments here instead of just inside move-node.ts as it stops the drag marker from appearing.
|
|
78
|
+
if ((0, _experiments.editorExperiment)('nest-media-and-codeblock-in-quote', false)) {
|
|
79
|
+
if (parentNodeType === 'blockquote' && (activeNodeType === 'mediaGroup' || activeNodeType === 'mediaSingle' || activeNodeType === 'codeBlock')) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Place experiments here instead of just inside move-node.ts as it stops the drag marker from appearing.
|
|
85
|
+
if ((0, _experiments.editorExperiment)('nested-expand-in-expand', false)) {
|
|
86
|
+
if (parentNodeType === 'expand' && (activeNodeType === 'expand' || activeNodeType === 'nestedExpand')) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
73
90
|
if (isInsideTable(destParent.type) && isExpand(srcNodeType)) {
|
|
74
91
|
if (memoizedTransformExpandToNestedExpand(srcNode)) {
|
|
75
92
|
srcNodeType = srcNodeType.schema.nodes.nestedExpand;
|
package/dist/es2019/ui/consts.js
CHANGED
|
@@ -48,7 +48,7 @@ export const topPositionAdjustment = nodeType => {
|
|
|
48
48
|
return 0;
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
|
-
const dropTargetMarginMap = {
|
|
51
|
+
export const dropTargetMarginMap = {
|
|
52
52
|
[-24]: "var(--ds-space-negative-300, -24px)",
|
|
53
53
|
[-20]: "var(--ds-space-negative-250, -20px)",
|
|
54
54
|
[-16]: "var(--ds-space-negative-200, -16px)",
|
|
@@ -131,6 +131,10 @@ export const nodeMargins = {
|
|
|
131
131
|
top: 24,
|
|
132
132
|
bottom: 24
|
|
133
133
|
},
|
|
134
|
+
media: {
|
|
135
|
+
top: 24,
|
|
136
|
+
bottom: 24
|
|
137
|
+
},
|
|
134
138
|
bodiedExtension: {
|
|
135
139
|
top: 0,
|
|
136
140
|
bottom: 0
|
|
@@ -7,12 +7,13 @@ import { useEffect, useMemo, useRef, useState } from 'react';
|
|
|
7
7
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
8
8
|
import { css, jsx } from '@emotion/react';
|
|
9
9
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
10
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
11
|
import { DropIndicator } from '@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box';
|
|
11
12
|
import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
12
13
|
import { layers } from '@atlaskit/theme/constants';
|
|
13
14
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
14
15
|
import { isBlocksDragTargetDebug } from '../utils/drag-target-debug';
|
|
15
|
-
import { getNestedNodeLeftPaddingMargin, nodeMargins, spaceLookupMap } from './consts';
|
|
16
|
+
import { dropTargetMarginMap, getNestedNodeLeftPaddingMargin, nodeMargins, spaceLookupMap } from './consts';
|
|
16
17
|
const DEFAULT_DROP_INDICATOR_WIDTH = 760;
|
|
17
18
|
const EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH = '--editor-block-controls-drop-indicator-width';
|
|
18
19
|
const EDITOR_BLOCK_CONTROLS_DROP_TARGET_LEFT_MARGIN = '--editor-block-controls-drop-target-leftMargin';
|
|
@@ -51,6 +52,24 @@ const getNodeMargins = node => {
|
|
|
51
52
|
}
|
|
52
53
|
return nodeMargins[nodeTypeName] || nodeMargins['default'];
|
|
53
54
|
};
|
|
55
|
+
const getNestedDropTargetMarginTop = (prevNode, nextNode, isNestedDropTarget) => {
|
|
56
|
+
if (!prevNode || !nextNode) {
|
|
57
|
+
return css({
|
|
58
|
+
marginTop: "var(--ds-space-negative-100, -8px)"
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
const top = getNodeMargins(nextNode).top;
|
|
62
|
+
const bottom = getNodeMargins(prevNode).bottom;
|
|
63
|
+
if (['rule', 'media', 'mediaSingle'].includes(prevNode.type.name) && isNestedDropTarget && top > 0 && bottom > 0) {
|
|
64
|
+
const collapsedMarginOffset = top === bottom ? top : Math.abs(top - bottom);
|
|
65
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values
|
|
66
|
+
const marginTop = dropTargetMarginMap[-collapsedMarginOffset - 8] || `-${collapsedMarginOffset + 8}px`;
|
|
67
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
68
|
+
return css({
|
|
69
|
+
marginTop
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
};
|
|
54
73
|
const getDropTargetOffsetStyle = (prevNode, nextNode) => {
|
|
55
74
|
if (!prevNode || !nextNode) {
|
|
56
75
|
return null;
|
|
@@ -84,6 +103,8 @@ export const DropTarget = ({
|
|
|
84
103
|
return;
|
|
85
104
|
}
|
|
86
105
|
|
|
106
|
+
// This should be moved to platform/packages/editor/editor-plugin-block-controls/src/utils/validation.ts
|
|
107
|
+
// Since we are moved to drop-target-v2
|
|
87
108
|
// Place experiments here instead of just inside move-node.ts as it stops the drag marker from appearing.
|
|
88
109
|
if (editorExperiment('nest-media-and-codeblock-in-quote', false)) {
|
|
89
110
|
var _api$blockControls;
|
|
@@ -145,6 +166,12 @@ export const DropTarget = ({
|
|
|
145
166
|
}
|
|
146
167
|
return getDropTargetOffsetStyle(prevNode, nextNode);
|
|
147
168
|
}, [prevNode, nextNode, parentNode]);
|
|
169
|
+
const dropTargetMarginTopStyles = useMemo(() => {
|
|
170
|
+
if (parentNode === prevNode) {
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
return getNestedDropTargetMarginTop(prevNode, nextNode, isNestedDropTarget);
|
|
174
|
+
}, [prevNode, nextNode, parentNode, isNestedDropTarget]);
|
|
148
175
|
const dynamicStyle = {
|
|
149
176
|
width: isNestedDropTarget ? 'unset' : '100%',
|
|
150
177
|
[EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH]: isNestedDropTarget ? '100%' : `${(widthState === null || widthState === void 0 ? void 0 : widthState.lineLength) || DEFAULT_DROP_INDICATOR_WIDTH}px`,
|
|
@@ -154,8 +181,11 @@ export const DropTarget = ({
|
|
|
154
181
|
return (
|
|
155
182
|
// Note: Firefox has trouble with using a button element as the handle for drag and drop
|
|
156
183
|
jsx("div", {
|
|
184
|
+
css: [styleDropTarget,
|
|
185
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
186
|
+
dropTargetOffsetStyle, isNestedDropTarget && nestedDropIndicatorStyle,
|
|
157
187
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
158
|
-
|
|
188
|
+
fg('platform_editor_element_dnd_nested_fix_patch_2') && dropTargetMarginTopStyles]
|
|
159
189
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
160
190
|
,
|
|
161
191
|
style: dynamicStyle,
|
|
@@ -101,6 +101,7 @@ const indentatedParagraphWithTrailingBreakAsOnlyChild = '+ div.fabric-editor-ind
|
|
|
101
101
|
const paragraphWithPlaceholder = '+ p > .placeholder-decoration';
|
|
102
102
|
const dragHandleContainer = '.ProseMirror-widget[data-blocks-drag-handle-container="true"]';
|
|
103
103
|
const dragHandleSelector = 'button[data-testid="block-ctrl-drag-handle"]';
|
|
104
|
+
const dropTargetContainer = '.ProseMirror-widget[data-blocks-drop-target-container="true"]';
|
|
104
105
|
const withInlineNodeStyleSelectors = [`.ProseMirror-widget[data-blocks-drag-handle-container="true"]:has(${paragraphWithTrailingBreakAsOnlyChild})`, `.ProseMirror-widget[data-blocks-drag-handle-container="true"]:has(${indentatedParagraphWithTrailingBreakAsOnlyChild})`, `.ProseMirror-widget[data-blocks-drag-handle-container="true"]:has(${paragraphWithPlaceholder})`].join(', ');
|
|
105
106
|
const dividerBodiedInCustomPanelWithNoIconSelector = '[data-panel-type].ak-editor-panel__no-icon .ProseMirror-widget:first-child + .ProseMirror-widget:nth-child(2) + hr, [data-panel-type] hr:first-child';
|
|
106
107
|
const withInlineNodeStyle = css({
|
|
@@ -111,6 +112,8 @@ const withInlineNodeStyle = css({
|
|
|
111
112
|
}
|
|
112
113
|
});
|
|
113
114
|
const withInlineNodeStyleWithChromeFixSelectors = [`${dragHandleContainer}:has(${paragraphWithTrailingBreakAsOnlyChild}) ${dragHandleSelector}`, `${dragHandleContainer}:has(${indentatedParagraphWithTrailingBreakAsOnlyChild}) ${dragHandleSelector}`, `${dragHandleContainer}:has(${paragraphWithPlaceholder}) ${dragHandleSelector}`].join(', ');
|
|
115
|
+
const withFormatInLayoutStyleFixSelectors = [`${dragHandleContainer}:first-child + .fabric-editor-indentation-mark > p:first-child`, `${dragHandleContainer}:first-child + .fabric-editor-alignment > p:first-child`, `${dragHandleContainer}:first-child + ${dropTargetContainer} + .fabric-editor-indentation-mark > p:first-child`, `${dragHandleContainer}:first-child + ${dropTargetContainer} + .fabric-editor-alignment > p:first-child`, `${dropTargetContainer}:first-child + .fabric-editor-alignment > p:first-child`, `${dropTargetContainer}:first-child + .fabric-editor-indentation-mark > p:first-child`].join(', ');
|
|
116
|
+
|
|
114
117
|
/**
|
|
115
118
|
* Please do not change change transform to display:none, or visibility:hidden
|
|
116
119
|
* Otherwise it might break composition input for Chrome
|
|
@@ -159,6 +162,13 @@ const withMediaSingleStyleFix = css({
|
|
|
159
162
|
cursor: 'pointer'
|
|
160
163
|
}
|
|
161
164
|
});
|
|
165
|
+
const withFormatInLayoutStyleFix = css({
|
|
166
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
167
|
+
[`${withFormatInLayoutStyleFixSelectors}`]: {
|
|
168
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
|
|
169
|
+
marginTop: '0 !important'
|
|
170
|
+
}
|
|
171
|
+
});
|
|
162
172
|
const getTextNodeStyle = () => {
|
|
163
173
|
return fg('platform_editor_element_controls_chrome_input_fix') ? withInlineNodeStyleWithChromeFix : withInlineNodeStyle;
|
|
164
174
|
};
|
|
@@ -166,6 +176,6 @@ export const GlobalStylesWrapper = () => {
|
|
|
166
176
|
return jsx(Global, {
|
|
167
177
|
styles: [globalStyles, editorExperiment('nested-dnd', true) ? extendedHoverZoneNested : extendedHoverZone, getTextNodeStyle(), withDeleteLinesStyleFix, withMediaSingleStyleFix, editorExperiment('platform_editor_empty_line_prompt', true, {
|
|
168
178
|
exposure: false
|
|
169
|
-
}) ? emptyBlockExperimentGlobalStyles : undefined, fg('platform_editor_element_dnd_nested_fix_patch_1') ? withDividerInPanelStyleFix : undefined]
|
|
179
|
+
}) ? emptyBlockExperimentGlobalStyles : undefined, fg('platform_editor_element_dnd_nested_fix_patch_1') ? withDividerInPanelStyleFix : undefined, fg('platform_editor_element_dnd_nested_fix_patch_2') ? withFormatInLayoutStyleFix : undefined]
|
|
170
180
|
});
|
|
171
181
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import memoizeOne from 'memoize-one';
|
|
2
2
|
import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
3
4
|
export const isInsideTable = nodeType => {
|
|
4
5
|
const {
|
|
5
6
|
tableCell,
|
|
@@ -64,6 +65,22 @@ export const memoizedTransformExpandToNestedExpand = memoizeOne(node => {
|
|
|
64
65
|
});
|
|
65
66
|
export function canMoveNodeToIndex(destParent, indexIntoParent, srcNode) {
|
|
66
67
|
let srcNodeType = srcNode.type;
|
|
68
|
+
const parentNodeType = destParent === null || destParent === void 0 ? void 0 : destParent.type.name;
|
|
69
|
+
const activeNodeType = srcNode === null || srcNode === void 0 ? void 0 : srcNode.type.name;
|
|
70
|
+
|
|
71
|
+
// Place experiments here instead of just inside move-node.ts as it stops the drag marker from appearing.
|
|
72
|
+
if (editorExperiment('nest-media-and-codeblock-in-quote', false)) {
|
|
73
|
+
if (parentNodeType === 'blockquote' && (activeNodeType === 'mediaGroup' || activeNodeType === 'mediaSingle' || activeNodeType === 'codeBlock')) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Place experiments here instead of just inside move-node.ts as it stops the drag marker from appearing.
|
|
79
|
+
if (editorExperiment('nested-expand-in-expand', false)) {
|
|
80
|
+
if (parentNodeType === 'expand' && (activeNodeType === 'expand' || activeNodeType === 'nestedExpand')) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
67
84
|
if (isInsideTable(destParent.type) && isExpand(srcNodeType)) {
|
|
68
85
|
if (memoizedTransformExpandToNestedExpand(srcNode)) {
|
|
69
86
|
srcNodeType = srcNodeType.schema.nodes.nestedExpand;
|
package/dist/esm/ui/consts.js
CHANGED
|
@@ -50,7 +50,7 @@ export var topPositionAdjustment = function topPositionAdjustment(nodeType) {
|
|
|
50
50
|
return 0;
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
|
-
var dropTargetMarginMap = (_dropTargetMarginMap = {}, _defineProperty(_dropTargetMarginMap, -24, "var(--ds-space-negative-300, -24px)"), _defineProperty(_dropTargetMarginMap, -20, "var(--ds-space-negative-250, -20px)"), _defineProperty(_dropTargetMarginMap, -16, "var(--ds-space-negative-200, -16px)"), _defineProperty(_dropTargetMarginMap, -12, "var(--ds-space-negative-150, -12px)"), _defineProperty(_dropTargetMarginMap, -8, "var(--ds-space-negative-100, -8px)"), _defineProperty(_dropTargetMarginMap, -6, "var(--ds-space-negative-075, -6px)"), _defineProperty(_dropTargetMarginMap, -4, "var(--ds-space-negative-050, -4px)"), _defineProperty(_dropTargetMarginMap, -2, "var(--ds-space-negative-025, -2px)"), _defineProperty(_dropTargetMarginMap, 0, "var(--ds-space-0, 0)"), _defineProperty(_dropTargetMarginMap, 2, "var(--ds-space-025, 2px)"), _defineProperty(_dropTargetMarginMap, 4, "var(--ds-space-050, 4px)"), _defineProperty(_dropTargetMarginMap, 6, "var(--ds-space-075, 6px)"), _defineProperty(_dropTargetMarginMap, 8, "var(--ds-space-100, 8px)"), _defineProperty(_dropTargetMarginMap, 12, "var(--ds-space-150, 12px)"), _defineProperty(_dropTargetMarginMap, 16, "var(--ds-space-200, 16px)"), _defineProperty(_dropTargetMarginMap, 20, "var(--ds-space-250, 20px)"), _defineProperty(_dropTargetMarginMap, 24, "var(--ds-space-300, 24px)"), _dropTargetMarginMap);
|
|
53
|
+
export var dropTargetMarginMap = (_dropTargetMarginMap = {}, _defineProperty(_dropTargetMarginMap, -24, "var(--ds-space-negative-300, -24px)"), _defineProperty(_dropTargetMarginMap, -20, "var(--ds-space-negative-250, -20px)"), _defineProperty(_dropTargetMarginMap, -16, "var(--ds-space-negative-200, -16px)"), _defineProperty(_dropTargetMarginMap, -12, "var(--ds-space-negative-150, -12px)"), _defineProperty(_dropTargetMarginMap, -8, "var(--ds-space-negative-100, -8px)"), _defineProperty(_dropTargetMarginMap, -6, "var(--ds-space-negative-075, -6px)"), _defineProperty(_dropTargetMarginMap, -4, "var(--ds-space-negative-050, -4px)"), _defineProperty(_dropTargetMarginMap, -2, "var(--ds-space-negative-025, -2px)"), _defineProperty(_dropTargetMarginMap, 0, "var(--ds-space-0, 0)"), _defineProperty(_dropTargetMarginMap, 2, "var(--ds-space-025, 2px)"), _defineProperty(_dropTargetMarginMap, 4, "var(--ds-space-050, 4px)"), _defineProperty(_dropTargetMarginMap, 6, "var(--ds-space-075, 6px)"), _defineProperty(_dropTargetMarginMap, 8, "var(--ds-space-100, 8px)"), _defineProperty(_dropTargetMarginMap, 12, "var(--ds-space-150, 12px)"), _defineProperty(_dropTargetMarginMap, 16, "var(--ds-space-200, 16px)"), _defineProperty(_dropTargetMarginMap, 20, "var(--ds-space-250, 20px)"), _defineProperty(_dropTargetMarginMap, 24, "var(--ds-space-300, 24px)"), _dropTargetMarginMap);
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
56
|
* This document serves as a quick reference map for correlating various space matches
|
|
@@ -115,6 +115,10 @@ export var nodeMargins = {
|
|
|
115
115
|
top: 24,
|
|
116
116
|
bottom: 24
|
|
117
117
|
},
|
|
118
|
+
media: {
|
|
119
|
+
top: 24,
|
|
120
|
+
bottom: 24
|
|
121
|
+
},
|
|
118
122
|
bodiedExtension: {
|
|
119
123
|
top: 0,
|
|
120
124
|
bottom: 0
|
|
@@ -9,12 +9,13 @@ import { useEffect, useMemo, useRef, useState } from 'react';
|
|
|
9
9
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
10
10
|
import { css, jsx } from '@emotion/react';
|
|
11
11
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
12
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
13
|
import { DropIndicator } from '@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box';
|
|
13
14
|
import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
14
15
|
import { layers } from '@atlaskit/theme/constants';
|
|
15
16
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
16
17
|
import { isBlocksDragTargetDebug } from '../utils/drag-target-debug';
|
|
17
|
-
import { getNestedNodeLeftPaddingMargin, nodeMargins, spaceLookupMap } from './consts';
|
|
18
|
+
import { dropTargetMarginMap, getNestedNodeLeftPaddingMargin, nodeMargins, spaceLookupMap } from './consts';
|
|
18
19
|
var DEFAULT_DROP_INDICATOR_WIDTH = 760;
|
|
19
20
|
var EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH = '--editor-block-controls-drop-indicator-width';
|
|
20
21
|
var EDITOR_BLOCK_CONTROLS_DROP_TARGET_LEFT_MARGIN = '--editor-block-controls-drop-target-leftMargin';
|
|
@@ -58,6 +59,24 @@ var getNodeMargins = function getNodeMargins(node) {
|
|
|
58
59
|
}
|
|
59
60
|
return nodeMargins[nodeTypeName] || nodeMargins['default'];
|
|
60
61
|
};
|
|
62
|
+
var getNestedDropTargetMarginTop = function getNestedDropTargetMarginTop(prevNode, nextNode, isNestedDropTarget) {
|
|
63
|
+
if (!prevNode || !nextNode) {
|
|
64
|
+
return css({
|
|
65
|
+
marginTop: "var(--ds-space-negative-100, -8px)"
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
var top = getNodeMargins(nextNode).top;
|
|
69
|
+
var bottom = getNodeMargins(prevNode).bottom;
|
|
70
|
+
if (['rule', 'media', 'mediaSingle'].includes(prevNode.type.name) && isNestedDropTarget && top > 0 && bottom > 0) {
|
|
71
|
+
var collapsedMarginOffset = top === bottom ? top : Math.abs(top - bottom);
|
|
72
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values
|
|
73
|
+
var marginTop = dropTargetMarginMap[-collapsedMarginOffset - 8] || "-".concat(collapsedMarginOffset + 8, "px");
|
|
74
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
75
|
+
return css({
|
|
76
|
+
marginTop: marginTop
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
};
|
|
61
80
|
var getDropTargetOffsetStyle = function getDropTargetOffsetStyle(prevNode, nextNode) {
|
|
62
81
|
if (!prevNode || !nextNode) {
|
|
63
82
|
return null;
|
|
@@ -93,6 +112,8 @@ export var DropTarget = function DropTarget(_ref3) {
|
|
|
93
112
|
return;
|
|
94
113
|
}
|
|
95
114
|
|
|
115
|
+
// This should be moved to platform/packages/editor/editor-plugin-block-controls/src/utils/validation.ts
|
|
116
|
+
// Since we are moved to drop-target-v2
|
|
96
117
|
// Place experiments here instead of just inside move-node.ts as it stops the drag marker from appearing.
|
|
97
118
|
if (editorExperiment('nest-media-and-codeblock-in-quote', false)) {
|
|
98
119
|
var _api$blockControls;
|
|
@@ -151,14 +172,23 @@ export var DropTarget = function DropTarget(_ref3) {
|
|
|
151
172
|
}
|
|
152
173
|
return getDropTargetOffsetStyle(prevNode, nextNode);
|
|
153
174
|
}, [prevNode, nextNode, parentNode]);
|
|
175
|
+
var dropTargetMarginTopStyles = useMemo(function () {
|
|
176
|
+
if (parentNode === prevNode) {
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
return getNestedDropTargetMarginTop(prevNode, nextNode, isNestedDropTarget);
|
|
180
|
+
}, [prevNode, nextNode, parentNode, isNestedDropTarget]);
|
|
154
181
|
var dynamicStyle = (_dynamicStyle = {
|
|
155
182
|
width: isNestedDropTarget ? 'unset' : '100%'
|
|
156
183
|
}, _defineProperty(_dynamicStyle, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH, isNestedDropTarget ? '100%' : "".concat((widthState === null || widthState === void 0 ? void 0 : widthState.lineLength) || DEFAULT_DROP_INDICATOR_WIDTH, "px")), _defineProperty(_dynamicStyle, EDITOR_BLOCK_CONTROLS_DROP_TARGET_LEFT_MARGIN, isNestedDropTarget ? getNestedNodeLeftPaddingMargin(parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name) : '0'), _defineProperty(_dynamicStyle, EDITOR_BLOCK_CONTROLS_DROP_TARGET_ZINDEX, editorExperiment('nested-dnd', true) ? layers.navigation() : layers.card()), _dynamicStyle);
|
|
157
184
|
return (
|
|
158
185
|
// Note: Firefox has trouble with using a button element as the handle for drag and drop
|
|
159
186
|
jsx("div", {
|
|
187
|
+
css: [styleDropTarget,
|
|
188
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
189
|
+
dropTargetOffsetStyle, isNestedDropTarget && nestedDropIndicatorStyle,
|
|
160
190
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
161
|
-
|
|
191
|
+
fg('platform_editor_element_dnd_nested_fix_patch_2') && dropTargetMarginTopStyles]
|
|
162
192
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
163
193
|
,
|
|
164
194
|
style: dynamicStyle,
|
|
@@ -102,6 +102,7 @@ var indentatedParagraphWithTrailingBreakAsOnlyChild = '+ div.fabric-editor-inden
|
|
|
102
102
|
var paragraphWithPlaceholder = '+ p > .placeholder-decoration';
|
|
103
103
|
var dragHandleContainer = '.ProseMirror-widget[data-blocks-drag-handle-container="true"]';
|
|
104
104
|
var dragHandleSelector = 'button[data-testid="block-ctrl-drag-handle"]';
|
|
105
|
+
var dropTargetContainer = '.ProseMirror-widget[data-blocks-drop-target-container="true"]';
|
|
105
106
|
var withInlineNodeStyleSelectors = [".ProseMirror-widget[data-blocks-drag-handle-container=\"true\"]:has(".concat(paragraphWithTrailingBreakAsOnlyChild, ")"), ".ProseMirror-widget[data-blocks-drag-handle-container=\"true\"]:has(".concat(indentatedParagraphWithTrailingBreakAsOnlyChild, ")"), ".ProseMirror-widget[data-blocks-drag-handle-container=\"true\"]:has(".concat(paragraphWithPlaceholder, ")")].join(', ');
|
|
106
107
|
var dividerBodiedInCustomPanelWithNoIconSelector = '[data-panel-type].ak-editor-panel__no-icon .ProseMirror-widget:first-child + .ProseMirror-widget:nth-child(2) + hr, [data-panel-type] hr:first-child';
|
|
107
108
|
var withInlineNodeStyle = css(_defineProperty({}, withInlineNodeStyleSelectors, {
|
|
@@ -109,6 +110,8 @@ var withInlineNodeStyle = css(_defineProperty({}, withInlineNodeStyleSelectors,
|
|
|
109
110
|
display: 'none !important'
|
|
110
111
|
}));
|
|
111
112
|
var withInlineNodeStyleWithChromeFixSelectors = ["".concat(dragHandleContainer, ":has(").concat(paragraphWithTrailingBreakAsOnlyChild, ") ").concat(dragHandleSelector), "".concat(dragHandleContainer, ":has(").concat(indentatedParagraphWithTrailingBreakAsOnlyChild, ") ").concat(dragHandleSelector), "".concat(dragHandleContainer, ":has(").concat(paragraphWithPlaceholder, ") ").concat(dragHandleSelector)].join(', ');
|
|
113
|
+
var withFormatInLayoutStyleFixSelectors = ["".concat(dragHandleContainer, ":first-child + .fabric-editor-indentation-mark > p:first-child"), "".concat(dragHandleContainer, ":first-child + .fabric-editor-alignment > p:first-child"), "".concat(dragHandleContainer, ":first-child + ").concat(dropTargetContainer, " + .fabric-editor-indentation-mark > p:first-child"), "".concat(dragHandleContainer, ":first-child + ").concat(dropTargetContainer, " + .fabric-editor-alignment > p:first-child"), "".concat(dropTargetContainer, ":first-child + .fabric-editor-alignment > p:first-child"), "".concat(dropTargetContainer, ":first-child + .fabric-editor-indentation-mark > p:first-child")].join(', ');
|
|
114
|
+
|
|
112
115
|
/**
|
|
113
116
|
* Please do not change change transform to display:none, or visibility:hidden
|
|
114
117
|
* Otherwise it might break composition input for Chrome
|
|
@@ -145,6 +148,10 @@ var withMediaSingleStyleFix = css(_defineProperty({}, '.ProseMirror.ua-firefox .
|
|
|
145
148
|
userSelect: 'auto',
|
|
146
149
|
cursor: 'pointer'
|
|
147
150
|
}));
|
|
151
|
+
var withFormatInLayoutStyleFix = css(_defineProperty({}, "".concat(withFormatInLayoutStyleFixSelectors), {
|
|
152
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
|
|
153
|
+
marginTop: '0 !important'
|
|
154
|
+
}));
|
|
148
155
|
var getTextNodeStyle = function getTextNodeStyle() {
|
|
149
156
|
return fg('platform_editor_element_controls_chrome_input_fix') ? withInlineNodeStyleWithChromeFix : withInlineNodeStyle;
|
|
150
157
|
};
|
|
@@ -152,6 +159,6 @@ export var GlobalStylesWrapper = function GlobalStylesWrapper() {
|
|
|
152
159
|
return jsx(Global, {
|
|
153
160
|
styles: [globalStyles, editorExperiment('nested-dnd', true) ? extendedHoverZoneNested : extendedHoverZone, getTextNodeStyle(), withDeleteLinesStyleFix, withMediaSingleStyleFix, editorExperiment('platform_editor_empty_line_prompt', true, {
|
|
154
161
|
exposure: false
|
|
155
|
-
}) ? emptyBlockExperimentGlobalStyles : undefined, fg('platform_editor_element_dnd_nested_fix_patch_1') ? withDividerInPanelStyleFix : undefined]
|
|
162
|
+
}) ? emptyBlockExperimentGlobalStyles : undefined, fg('platform_editor_element_dnd_nested_fix_patch_1') ? withDividerInPanelStyleFix : undefined, fg('platform_editor_element_dnd_nested_fix_patch_2') ? withFormatInLayoutStyleFix : undefined]
|
|
156
163
|
});
|
|
157
164
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import memoizeOne from 'memoize-one';
|
|
2
2
|
import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
3
4
|
export var isInsideTable = function isInsideTable(nodeType) {
|
|
4
5
|
var _nodeType$schema$node = nodeType.schema.nodes,
|
|
5
6
|
tableCell = _nodeType$schema$node.tableCell,
|
|
@@ -62,6 +63,22 @@ export var memoizedTransformExpandToNestedExpand = memoizeOne(function (node) {
|
|
|
62
63
|
});
|
|
63
64
|
export function canMoveNodeToIndex(destParent, indexIntoParent, srcNode) {
|
|
64
65
|
var srcNodeType = srcNode.type;
|
|
66
|
+
var parentNodeType = destParent === null || destParent === void 0 ? void 0 : destParent.type.name;
|
|
67
|
+
var activeNodeType = srcNode === null || srcNode === void 0 ? void 0 : srcNode.type.name;
|
|
68
|
+
|
|
69
|
+
// Place experiments here instead of just inside move-node.ts as it stops the drag marker from appearing.
|
|
70
|
+
if (editorExperiment('nest-media-and-codeblock-in-quote', false)) {
|
|
71
|
+
if (parentNodeType === 'blockquote' && (activeNodeType === 'mediaGroup' || activeNodeType === 'mediaSingle' || activeNodeType === 'codeBlock')) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Place experiments here instead of just inside move-node.ts as it stops the drag marker from appearing.
|
|
77
|
+
if (editorExperiment('nested-expand-in-expand', false)) {
|
|
78
|
+
if (parentNodeType === 'expand' && (activeNodeType === 'expand' || activeNodeType === 'nestedExpand')) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
65
82
|
if (isInsideTable(destParent.type) && isExpand(srcNodeType)) {
|
|
66
83
|
if (memoizedTransformExpandToNestedExpand(srcNode)) {
|
|
67
84
|
srcNodeType = srcNodeType.schema.nodes.nestedExpand;
|
|
@@ -10,6 +10,9 @@ export declare const DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT: number;
|
|
|
10
10
|
export declare const dragHandleGap: (nodeType: string, parentNodeType?: string) => 4 | 8 | 12;
|
|
11
11
|
export declare const getNestedNodeLeftPaddingMargin: (nodeType?: string) => "8px" | "16px" | "20px" | "24px" | "28px" | "40px";
|
|
12
12
|
export declare const topPositionAdjustment: (nodeType: string) => number;
|
|
13
|
+
export declare const dropTargetMarginMap: {
|
|
14
|
+
[key: number]: string;
|
|
15
|
+
};
|
|
13
16
|
/**
|
|
14
17
|
* This document serves as a quick reference map for correlating various space matches
|
|
15
18
|
* to the table provided above.
|
|
@@ -10,6 +10,9 @@ export declare const DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT: number;
|
|
|
10
10
|
export declare const dragHandleGap: (nodeType: string, parentNodeType?: string) => 4 | 8 | 12;
|
|
11
11
|
export declare const getNestedNodeLeftPaddingMargin: (nodeType?: string) => "8px" | "16px" | "20px" | "24px" | "28px" | "40px";
|
|
12
12
|
export declare const topPositionAdjustment: (nodeType: string) => number;
|
|
13
|
+
export declare const dropTargetMarginMap: {
|
|
14
|
+
[key: number]: string;
|
|
15
|
+
};
|
|
13
16
|
/**
|
|
14
17
|
* This document serves as a quick reference map for correlating various space matches
|
|
15
18
|
* to the table provided above.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@atlaskit/adf-schema": "^40.9.4",
|
|
34
|
-
"@atlaskit/editor-common": "^93.
|
|
34
|
+
"@atlaskit/editor-common": "^93.4.0",
|
|
35
35
|
"@atlaskit/editor-plugin-accessibility-utils": "^1.2.0",
|
|
36
36
|
"@atlaskit/editor-plugin-analytics": "^1.9.0",
|
|
37
37
|
"@atlaskit/editor-plugin-editor-disabled": "^1.3.0",
|