@atlaskit/editor-plugin-block-controls 1.12.8 → 1.12.10
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 +20 -0
- package/dist/cjs/pm-plugins/handle-mouse-over.js +8 -1
- package/dist/cjs/pm-plugins/main.js +2 -2
- package/dist/cjs/ui/consts.js +20 -1
- package/dist/cjs/ui/drag-preview.js +2 -2
- package/dist/cjs/ui/drop-target.js +7 -2
- package/dist/es2019/pm-plugins/handle-mouse-over.js +9 -2
- package/dist/es2019/pm-plugins/main.js +1 -1
- package/dist/es2019/ui/consts.js +19 -0
- package/dist/es2019/ui/drag-preview.js +1 -1
- package/dist/es2019/ui/drop-target.js +7 -3
- package/dist/esm/pm-plugins/handle-mouse-over.js +8 -1
- package/dist/esm/pm-plugins/main.js +1 -1
- package/dist/esm/ui/consts.js +19 -0
- package/dist/esm/ui/drag-preview.js +1 -1
- package/dist/esm/ui/drop-target.js +8 -3
- package/dist/types/ui/consts.d.ts +1 -0
- package/dist/types-ts4.5/ui/consts.d.ts +1 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 1.12.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#136410](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/136410)
|
|
8
|
+
[`52083ca79b5dc`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/52083ca79b5dc) -
|
|
9
|
+
[ux] ED-24603 Disable dragging nested nodes within table behind FF
|
|
10
|
+
|
|
11
|
+
## 1.12.9
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#136177](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/136177)
|
|
16
|
+
[`557c5bcfce83c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/557c5bcfce83c) -
|
|
17
|
+
[ux] Adjust margin of drop targets in nested scenarios
|
|
18
|
+
- [#136348](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/136348)
|
|
19
|
+
[`fb4fb56f1da7c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/fb4fb56f1da7c) -
|
|
20
|
+
Use optimised entry-points on editor-common for browser.
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
|
|
3
23
|
## 1.12.8
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -22,7 +22,14 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, e
|
|
|
22
22
|
}
|
|
23
23
|
var rootElement = target === null || target === void 0 ? void 0 : target.closest('[data-drag-handler-anchor-name]');
|
|
24
24
|
if (rootElement) {
|
|
25
|
+
var tableElement = rootElement.closest('[data-drag-handler-node-type="table"]');
|
|
26
|
+
if (tableElement && (0, _experiments.editorExperiment)('nested-dnd', true) && (0, _experiments.editorExperiment)('table-nested-dnd', false, {
|
|
27
|
+
exposure: true
|
|
28
|
+
})) {
|
|
29
|
+
rootElement = tableElement;
|
|
30
|
+
}
|
|
25
31
|
var anchorName = rootElement.getAttribute('data-drag-handler-anchor-name');
|
|
32
|
+
var nodeType = rootElement.getAttribute('data-drag-handler-node-type');
|
|
26
33
|
if ((activeNode === null || activeNode === void 0 ? void 0 : activeNode.anchorName) === anchorName) {
|
|
27
34
|
return false;
|
|
28
35
|
}
|
|
@@ -39,6 +46,7 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, e
|
|
|
39
46
|
var depth = $rootPos.depth;
|
|
40
47
|
var isParentAnIsolatingNode = ((_$rootPos$parent = $rootPos.parent) === null || _$rootPos$parent === void 0 ? void 0 : _$rootPos$parent.type.name) !== 'doc' && ((_$rootPos$parent2 = $rootPos.parent) === null || _$rootPos$parent2 === void 0 ? void 0 : _$rootPos$parent2.type.spec.isolating);
|
|
41
48
|
var isCurrentNodeAtom = (_$rootPos$nodeAfter = $rootPos.nodeAfter) === null || _$rootPos$nodeAfter === void 0 ? void 0 : _$rootPos$nodeAfter.isAtom;
|
|
49
|
+
|
|
42
50
|
/**
|
|
43
51
|
* If the parent node is an isolating node, the sides of nodes of this type are considered boundaries, such as a table cell.
|
|
44
52
|
* And the current node, as a direct child, is an atom node, meaning it does not have directly editable content.
|
|
@@ -51,7 +59,6 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, e
|
|
|
51
59
|
} else {
|
|
52
60
|
rootPos = view.state.doc.resolve(pos).start(1) - 1;
|
|
53
61
|
}
|
|
54
|
-
var nodeType = rootElement.getAttribute('data-drag-handler-node-type');
|
|
55
62
|
if (nodeType) {
|
|
56
63
|
var _api$core, _api$blockControls2;
|
|
57
64
|
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.commands.showDragHandleAt(rootPos, anchorName, nodeType));
|
|
@@ -8,8 +8,8 @@ exports.key = exports.createPlugin = void 0;
|
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
9
|
var _rafSchd = _interopRequireDefault(require("raf-schd"));
|
|
10
10
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
11
|
+
var _browser = require("@atlaskit/editor-common/browser");
|
|
11
12
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
12
|
-
var _utils = require("@atlaskit/editor-common/utils");
|
|
13
13
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
14
14
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
15
15
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
@@ -391,7 +391,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl) {
|
|
|
391
391
|
selection = _view$state.selection,
|
|
392
392
|
doc = _view$state.doc,
|
|
393
393
|
tr = _view$state.tr;
|
|
394
|
-
var metaKey =
|
|
394
|
+
var metaKey = _browser.browser.mac ? event.metaKey : event.ctrlKey;
|
|
395
395
|
if (event.key === 'ArrowUp' && event.shiftKey && metaKey) {
|
|
396
396
|
if (selection instanceof _state.TextSelection || selection instanceof _state.NodeSelection) {
|
|
397
397
|
var newSelection = _state.TextSelection.create(doc, selection.head, 1);
|
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.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.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;
|
|
@@ -28,6 +28,25 @@ var dragHandleGap = exports.dragHandleGap = function dragHandleGap(nodeType, par
|
|
|
28
28
|
}
|
|
29
29
|
return DRAG_HANDLE_DEFAULT_GAP;
|
|
30
30
|
};
|
|
31
|
+
var getNestedNodeLeftPaddingMargin = exports.getNestedNodeLeftPaddingMargin = function getNestedNodeLeftPaddingMargin(nodeType) {
|
|
32
|
+
switch (nodeType) {
|
|
33
|
+
case 'bodiedExtension':
|
|
34
|
+
return '28px';
|
|
35
|
+
case 'expand':
|
|
36
|
+
case 'nestedExpand':
|
|
37
|
+
return '24px';
|
|
38
|
+
case 'layoutColumn':
|
|
39
|
+
return '20px';
|
|
40
|
+
case 'panel':
|
|
41
|
+
return '44px';
|
|
42
|
+
case 'tableCell':
|
|
43
|
+
return '8px';
|
|
44
|
+
case 'tableHeader':
|
|
45
|
+
return '8px';
|
|
46
|
+
default:
|
|
47
|
+
return "".concat(DRAG_HANDLE_WIDTH + DRAG_HANDLE_NARROW_GAP, "px");
|
|
48
|
+
}
|
|
49
|
+
};
|
|
31
50
|
var topPositionAdjustment = exports.topPositionAdjustment = function topPositionAdjustment(nodeType) {
|
|
32
51
|
switch (nodeType) {
|
|
33
52
|
case 'rule':
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.dragPreview = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _browser = require("@atlaskit/editor-common/browser");
|
|
8
8
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
9
9
|
var _colors = require("@atlaskit/theme/colors");
|
|
10
10
|
var previewStyle = {
|
|
@@ -50,7 +50,7 @@ var dragPreview = exports.dragPreview = function dragPreview(container, dom, nod
|
|
|
50
50
|
clonedDom.style.marginRight = '0';
|
|
51
51
|
clonedDom.style.marginBottom = '0';
|
|
52
52
|
clonedDom.style.boxShadow = 'none';
|
|
53
|
-
clonedDom.style.opacity =
|
|
53
|
+
clonedDom.style.opacity = _browser.browser.windows ? '1' : (0, _platformFeatureFlags.fg)('platform_editor_elements_drag_and_drop_ed_23189') ? '0.31' : '0.4';
|
|
54
54
|
parent.appendChild(clonedDom);
|
|
55
55
|
}
|
|
56
56
|
container.appendChild(parent);
|
|
@@ -24,11 +24,13 @@ var _consts = require("./consts");
|
|
|
24
24
|
|
|
25
25
|
var DEFAULT_DROP_INDICATOR_WIDTH = 760;
|
|
26
26
|
var EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH = '--editor-block-controls-drop-indicator-width';
|
|
27
|
+
var EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_LEFT_MARGIN = '--editor-block-controls-drop-indicator-leftMargin';
|
|
27
28
|
var styleDropTarget = (0, _react2.css)({
|
|
28
29
|
height: "var(--ds-space-100, 8px)",
|
|
29
30
|
marginTop: "var(--ds-space-negative-100, -8px)",
|
|
31
|
+
marginLeft: "calc(-1 * var(".concat(EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_LEFT_MARGIN, ", 0))"),
|
|
32
|
+
paddingLeft: "var(".concat(EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_LEFT_MARGIN, ", 0)"),
|
|
30
33
|
position: 'absolute',
|
|
31
|
-
width: '100%',
|
|
32
34
|
left: '0',
|
|
33
35
|
display: 'block',
|
|
34
36
|
zIndex: _constants.layers.card()
|
|
@@ -76,6 +78,7 @@ var getDropTargetOffsetStyle = function getDropTargetOffsetStyle(prevNode, nextN
|
|
|
76
78
|
return marginLookupMap[offset];
|
|
77
79
|
};
|
|
78
80
|
var DropTarget = exports.DropTarget = function DropTarget(_ref3) {
|
|
81
|
+
var _widthStyle;
|
|
79
82
|
var api = _ref3.api,
|
|
80
83
|
id = _ref3.id,
|
|
81
84
|
prevNode = _ref3.prevNode,
|
|
@@ -136,7 +139,9 @@ var DropTarget = exports.DropTarget = function DropTarget(_ref3) {
|
|
|
136
139
|
}
|
|
137
140
|
return getDropTargetOffsetStyle(prevNode, nextNode);
|
|
138
141
|
}, [prevNode, nextNode, parentNode]);
|
|
139
|
-
var widthStyle = (
|
|
142
|
+
var widthStyle = (_widthStyle = {
|
|
143
|
+
width: isNestedDropTarget ? 'unset' : '100%'
|
|
144
|
+
}, (0, _defineProperty2.default)(_widthStyle, 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)(_widthStyle, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_LEFT_MARGIN, isNestedDropTarget ? (0, _consts.getNestedNodeLeftPaddingMargin)(parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name) : '0'), _widthStyle);
|
|
140
145
|
return (
|
|
141
146
|
// Note: Firefox has trouble with using a button element as the handle for drag and drop
|
|
142
147
|
(0, _react2.jsx)("div", {
|
|
@@ -15,9 +15,16 @@ export const handleMouseOver = (view, event, api) => {
|
|
|
15
15
|
if (target.classList.contains('ProseMirror')) {
|
|
16
16
|
return false;
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
let rootElement = target === null || target === void 0 ? void 0 : target.closest('[data-drag-handler-anchor-name]');
|
|
19
19
|
if (rootElement) {
|
|
20
|
+
const tableElement = rootElement.closest('[data-drag-handler-node-type="table"]');
|
|
21
|
+
if (tableElement && editorExperiment('nested-dnd', true) && editorExperiment('table-nested-dnd', false, {
|
|
22
|
+
exposure: true
|
|
23
|
+
})) {
|
|
24
|
+
rootElement = tableElement;
|
|
25
|
+
}
|
|
20
26
|
const anchorName = rootElement.getAttribute('data-drag-handler-anchor-name');
|
|
27
|
+
const nodeType = rootElement.getAttribute('data-drag-handler-node-type');
|
|
21
28
|
if ((activeNode === null || activeNode === void 0 ? void 0 : activeNode.anchorName) === anchorName) {
|
|
22
29
|
return false;
|
|
23
30
|
}
|
|
@@ -34,6 +41,7 @@ export const handleMouseOver = (view, event, api) => {
|
|
|
34
41
|
const depth = $rootPos.depth;
|
|
35
42
|
const isParentAnIsolatingNode = ((_$rootPos$parent = $rootPos.parent) === null || _$rootPos$parent === void 0 ? void 0 : _$rootPos$parent.type.name) !== 'doc' && ((_$rootPos$parent2 = $rootPos.parent) === null || _$rootPos$parent2 === void 0 ? void 0 : _$rootPos$parent2.type.spec.isolating);
|
|
36
43
|
const isCurrentNodeAtom = (_$rootPos$nodeAfter = $rootPos.nodeAfter) === null || _$rootPos$nodeAfter === void 0 ? void 0 : _$rootPos$nodeAfter.isAtom;
|
|
44
|
+
|
|
37
45
|
/**
|
|
38
46
|
* If the parent node is an isolating node, the sides of nodes of this type are considered boundaries, such as a table cell.
|
|
39
47
|
* And the current node, as a direct child, is an atom node, meaning it does not have directly editable content.
|
|
@@ -46,7 +54,6 @@ export const handleMouseOver = (view, event, api) => {
|
|
|
46
54
|
} else {
|
|
47
55
|
rootPos = view.state.doc.resolve(pos).start(1) - 1;
|
|
48
56
|
}
|
|
49
|
-
const nodeType = rootElement.getAttribute('data-drag-handler-node-type');
|
|
50
57
|
if (nodeType) {
|
|
51
58
|
var _api$core, _api$blockControls2;
|
|
52
59
|
api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(api === null || api === void 0 ? void 0 : (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.commands.showDragHandleAt(rootPos, anchorName, nodeType));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import rafSchedule from 'raf-schd';
|
|
2
2
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import { browser } from '@atlaskit/editor-common/browser';
|
|
3
4
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
|
-
import { browser } from '@atlaskit/editor-common/utils';
|
|
5
5
|
import { NodeSelection, PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
6
6
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
7
7
|
import { fg } from '@atlaskit/platform-feature-flags';
|
package/dist/es2019/ui/consts.js
CHANGED
|
@@ -19,6 +19,25 @@ export const dragHandleGap = (nodeType, parentNodeType) => {
|
|
|
19
19
|
}
|
|
20
20
|
return DRAG_HANDLE_DEFAULT_GAP;
|
|
21
21
|
};
|
|
22
|
+
export const getNestedNodeLeftPaddingMargin = nodeType => {
|
|
23
|
+
switch (nodeType) {
|
|
24
|
+
case 'bodiedExtension':
|
|
25
|
+
return '28px';
|
|
26
|
+
case 'expand':
|
|
27
|
+
case 'nestedExpand':
|
|
28
|
+
return '24px';
|
|
29
|
+
case 'layoutColumn':
|
|
30
|
+
return '20px';
|
|
31
|
+
case 'panel':
|
|
32
|
+
return '44px';
|
|
33
|
+
case 'tableCell':
|
|
34
|
+
return '8px';
|
|
35
|
+
case 'tableHeader':
|
|
36
|
+
return '8px';
|
|
37
|
+
default:
|
|
38
|
+
return `${DRAG_HANDLE_WIDTH + DRAG_HANDLE_NARROW_GAP}px`;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
22
41
|
export const topPositionAdjustment = nodeType => {
|
|
23
42
|
switch (nodeType) {
|
|
24
43
|
case 'rule':
|
|
@@ -11,14 +11,16 @@ import { DropIndicator } from '@atlaskit/pragmatic-drag-and-drop-react-drop-indi
|
|
|
11
11
|
import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
12
12
|
import { layers } from '@atlaskit/theme/constants';
|
|
13
13
|
import { isBlocksDragTargetDebug } from '../utils/drag-target-debug';
|
|
14
|
-
import { nodeMargins, spaceLookupMap } from './consts';
|
|
14
|
+
import { getNestedNodeLeftPaddingMargin, nodeMargins, spaceLookupMap } from './consts';
|
|
15
15
|
const DEFAULT_DROP_INDICATOR_WIDTH = 760;
|
|
16
16
|
const EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH = '--editor-block-controls-drop-indicator-width';
|
|
17
|
+
const EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_LEFT_MARGIN = '--editor-block-controls-drop-indicator-leftMargin';
|
|
17
18
|
const styleDropTarget = css({
|
|
18
19
|
height: "var(--ds-space-100, 8px)",
|
|
19
20
|
marginTop: "var(--ds-space-negative-100, -8px)",
|
|
21
|
+
marginLeft: `calc(-1 * var(${EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_LEFT_MARGIN}, 0))`,
|
|
22
|
+
paddingLeft: `var(${EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_LEFT_MARGIN}, 0)`,
|
|
20
23
|
position: 'absolute',
|
|
21
|
-
width: '100%',
|
|
22
24
|
left: '0',
|
|
23
25
|
display: 'block',
|
|
24
26
|
zIndex: layers.card()
|
|
@@ -121,7 +123,9 @@ export const DropTarget = ({
|
|
|
121
123
|
return getDropTargetOffsetStyle(prevNode, nextNode);
|
|
122
124
|
}, [prevNode, nextNode, parentNode]);
|
|
123
125
|
const widthStyle = {
|
|
124
|
-
|
|
126
|
+
width: isNestedDropTarget ? 'unset' : '100%',
|
|
127
|
+
[EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH]: isNestedDropTarget ? '100%' : `${(widthState === null || widthState === void 0 ? void 0 : widthState.lineLength) || DEFAULT_DROP_INDICATOR_WIDTH}px`,
|
|
128
|
+
[EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_LEFT_MARGIN]: isNestedDropTarget ? getNestedNodeLeftPaddingMargin(parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name) : '0'
|
|
125
129
|
};
|
|
126
130
|
return (
|
|
127
131
|
// Note: Firefox has trouble with using a button element as the handle for drag and drop
|
|
@@ -16,7 +16,14 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
|
|
|
16
16
|
}
|
|
17
17
|
var rootElement = target === null || target === void 0 ? void 0 : target.closest('[data-drag-handler-anchor-name]');
|
|
18
18
|
if (rootElement) {
|
|
19
|
+
var tableElement = rootElement.closest('[data-drag-handler-node-type="table"]');
|
|
20
|
+
if (tableElement && editorExperiment('nested-dnd', true) && editorExperiment('table-nested-dnd', false, {
|
|
21
|
+
exposure: true
|
|
22
|
+
})) {
|
|
23
|
+
rootElement = tableElement;
|
|
24
|
+
}
|
|
19
25
|
var anchorName = rootElement.getAttribute('data-drag-handler-anchor-name');
|
|
26
|
+
var nodeType = rootElement.getAttribute('data-drag-handler-node-type');
|
|
20
27
|
if ((activeNode === null || activeNode === void 0 ? void 0 : activeNode.anchorName) === anchorName) {
|
|
21
28
|
return false;
|
|
22
29
|
}
|
|
@@ -33,6 +40,7 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
|
|
|
33
40
|
var depth = $rootPos.depth;
|
|
34
41
|
var isParentAnIsolatingNode = ((_$rootPos$parent = $rootPos.parent) === null || _$rootPos$parent === void 0 ? void 0 : _$rootPos$parent.type.name) !== 'doc' && ((_$rootPos$parent2 = $rootPos.parent) === null || _$rootPos$parent2 === void 0 ? void 0 : _$rootPos$parent2.type.spec.isolating);
|
|
35
42
|
var isCurrentNodeAtom = (_$rootPos$nodeAfter = $rootPos.nodeAfter) === null || _$rootPos$nodeAfter === void 0 ? void 0 : _$rootPos$nodeAfter.isAtom;
|
|
43
|
+
|
|
36
44
|
/**
|
|
37
45
|
* If the parent node is an isolating node, the sides of nodes of this type are considered boundaries, such as a table cell.
|
|
38
46
|
* And the current node, as a direct child, is an atom node, meaning it does not have directly editable content.
|
|
@@ -45,7 +53,6 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
|
|
|
45
53
|
} else {
|
|
46
54
|
rootPos = view.state.doc.resolve(pos).start(1) - 1;
|
|
47
55
|
}
|
|
48
|
-
var nodeType = rootElement.getAttribute('data-drag-handler-node-type');
|
|
49
56
|
if (nodeType) {
|
|
50
57
|
var _api$core, _api$blockControls2;
|
|
51
58
|
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.commands.showDragHandleAt(rootPos, anchorName, nodeType));
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
2
|
import rafSchedule from 'raf-schd';
|
|
3
3
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
4
|
+
import { browser } from '@atlaskit/editor-common/browser';
|
|
4
5
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
5
|
-
import { browser } from '@atlaskit/editor-common/utils';
|
|
6
6
|
import { NodeSelection, PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
7
7
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
8
8
|
import { fg } from '@atlaskit/platform-feature-flags';
|
package/dist/esm/ui/consts.js
CHANGED
|
@@ -21,6 +21,25 @@ export var dragHandleGap = function dragHandleGap(nodeType, parentNodeType) {
|
|
|
21
21
|
}
|
|
22
22
|
return DRAG_HANDLE_DEFAULT_GAP;
|
|
23
23
|
};
|
|
24
|
+
export var getNestedNodeLeftPaddingMargin = function getNestedNodeLeftPaddingMargin(nodeType) {
|
|
25
|
+
switch (nodeType) {
|
|
26
|
+
case 'bodiedExtension':
|
|
27
|
+
return '28px';
|
|
28
|
+
case 'expand':
|
|
29
|
+
case 'nestedExpand':
|
|
30
|
+
return '24px';
|
|
31
|
+
case 'layoutColumn':
|
|
32
|
+
return '20px';
|
|
33
|
+
case 'panel':
|
|
34
|
+
return '44px';
|
|
35
|
+
case 'tableCell':
|
|
36
|
+
return '8px';
|
|
37
|
+
case 'tableHeader':
|
|
38
|
+
return '8px';
|
|
39
|
+
default:
|
|
40
|
+
return "".concat(DRAG_HANDLE_WIDTH + DRAG_HANDLE_NARROW_GAP, "px");
|
|
41
|
+
}
|
|
42
|
+
};
|
|
24
43
|
export var topPositionAdjustment = function topPositionAdjustment(nodeType) {
|
|
25
44
|
switch (nodeType) {
|
|
26
45
|
case 'rule':
|
|
@@ -13,14 +13,16 @@ import { DropIndicator } from '@atlaskit/pragmatic-drag-and-drop-react-drop-indi
|
|
|
13
13
|
import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
14
14
|
import { layers } from '@atlaskit/theme/constants';
|
|
15
15
|
import { isBlocksDragTargetDebug } from '../utils/drag-target-debug';
|
|
16
|
-
import { nodeMargins, spaceLookupMap } from './consts';
|
|
16
|
+
import { getNestedNodeLeftPaddingMargin, nodeMargins, spaceLookupMap } from './consts';
|
|
17
17
|
var DEFAULT_DROP_INDICATOR_WIDTH = 760;
|
|
18
18
|
var EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH = '--editor-block-controls-drop-indicator-width';
|
|
19
|
+
var EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_LEFT_MARGIN = '--editor-block-controls-drop-indicator-leftMargin';
|
|
19
20
|
var styleDropTarget = css({
|
|
20
21
|
height: "var(--ds-space-100, 8px)",
|
|
21
22
|
marginTop: "var(--ds-space-negative-100, -8px)",
|
|
23
|
+
marginLeft: "calc(-1 * var(".concat(EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_LEFT_MARGIN, ", 0))"),
|
|
24
|
+
paddingLeft: "var(".concat(EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_LEFT_MARGIN, ", 0)"),
|
|
22
25
|
position: 'absolute',
|
|
23
|
-
width: '100%',
|
|
24
26
|
left: '0',
|
|
25
27
|
display: 'block',
|
|
26
28
|
zIndex: layers.card()
|
|
@@ -68,6 +70,7 @@ var getDropTargetOffsetStyle = function getDropTargetOffsetStyle(prevNode, nextN
|
|
|
68
70
|
return marginLookupMap[offset];
|
|
69
71
|
};
|
|
70
72
|
export var DropTarget = function DropTarget(_ref3) {
|
|
73
|
+
var _widthStyle;
|
|
71
74
|
var api = _ref3.api,
|
|
72
75
|
id = _ref3.id,
|
|
73
76
|
prevNode = _ref3.prevNode,
|
|
@@ -128,7 +131,9 @@ export var DropTarget = function DropTarget(_ref3) {
|
|
|
128
131
|
}
|
|
129
132
|
return getDropTargetOffsetStyle(prevNode, nextNode);
|
|
130
133
|
}, [prevNode, nextNode, parentNode]);
|
|
131
|
-
var widthStyle =
|
|
134
|
+
var widthStyle = (_widthStyle = {
|
|
135
|
+
width: isNestedDropTarget ? 'unset' : '100%'
|
|
136
|
+
}, _defineProperty(_widthStyle, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH, isNestedDropTarget ? '100%' : "".concat((widthState === null || widthState === void 0 ? void 0 : widthState.lineLength) || DEFAULT_DROP_INDICATOR_WIDTH, "px")), _defineProperty(_widthStyle, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_LEFT_MARGIN, isNestedDropTarget ? getNestedNodeLeftPaddingMargin(parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name) : '0'), _widthStyle);
|
|
132
137
|
return (
|
|
133
138
|
// Note: Firefox has trouble with using a button element as the handle for drag and drop
|
|
134
139
|
jsx("div", {
|
|
@@ -8,6 +8,7 @@ export declare const DRAG_HANDLE_MAX_GAP = 12;
|
|
|
8
8
|
export declare const DRAG_HANDLE_MAX_WIDTH_PLUS_GAP: number;
|
|
9
9
|
export declare const DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT: number;
|
|
10
10
|
export declare const dragHandleGap: (nodeType: string, parentNodeType?: string) => 4 | 8 | 12;
|
|
11
|
+
export declare const getNestedNodeLeftPaddingMargin: (nodeType?: string) => "8px" | "16px" | "20px" | "24px" | "28px" | "44px";
|
|
11
12
|
export declare const topPositionAdjustment: (nodeType: string) => number;
|
|
12
13
|
/**
|
|
13
14
|
* This document serves as a quick reference map for correlating various space matches
|
|
@@ -8,6 +8,7 @@ export declare const DRAG_HANDLE_MAX_GAP = 12;
|
|
|
8
8
|
export declare const DRAG_HANDLE_MAX_WIDTH_PLUS_GAP: number;
|
|
9
9
|
export declare const DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT: number;
|
|
10
10
|
export declare const dragHandleGap: (nodeType: string, parentNodeType?: string) => 4 | 8 | 12;
|
|
11
|
+
export declare const getNestedNodeLeftPaddingMargin: (nodeType?: string) => "8px" | "16px" | "20px" | "24px" | "28px" | "44px";
|
|
11
12
|
export declare const topPositionAdjustment: (nodeType: string) => number;
|
|
12
13
|
/**
|
|
13
14
|
* This document serves as a quick reference map for correlating various space matches
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.10",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
".": "./src/index.ts"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@atlaskit/editor-common": "^88.
|
|
32
|
+
"@atlaskit/editor-common": "^88.8.0",
|
|
33
33
|
"@atlaskit/editor-plugin-accessibility-utils": "^1.2.0",
|
|
34
34
|
"@atlaskit/editor-plugin-analytics": "^1.8.0",
|
|
35
35
|
"@atlaskit/editor-plugin-editor-disabled": "^1.3.0",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^1.4.0",
|
|
45
45
|
"@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^1.1.0",
|
|
46
46
|
"@atlaskit/theme": "^13.0.0",
|
|
47
|
-
"@atlaskit/tmp-editor-statsig": "^2.
|
|
47
|
+
"@atlaskit/tmp-editor-statsig": "^2.1.0",
|
|
48
48
|
"@atlaskit/tokens": "^1.59.0",
|
|
49
49
|
"@atlaskit/tooltip": "^18.7.0",
|
|
50
50
|
"@babel/runtime": "^7.0.0",
|