@atlaskit/editor-plugin-block-controls 3.8.0 → 3.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/dist/cjs/editor-commands/move-node.js +7 -1
- package/dist/cjs/pm-plugins/handle-mouse-down.js +25 -0
- package/dist/cjs/pm-plugins/main.js +2 -0
- package/dist/cjs/pm-plugins/utils/validation.js +38 -31
- package/dist/cjs/ui/drag-handle.js +17 -10
- package/dist/cjs/ui/quick-insert-button.js +15 -8
- package/dist/cjs/ui/utils/anchor-name.js +34 -0
- package/dist/es2019/editor-commands/move-node.js +7 -1
- package/dist/es2019/pm-plugins/handle-mouse-down.js +17 -0
- package/dist/es2019/pm-plugins/main.js +2 -0
- package/dist/es2019/pm-plugins/utils/validation.js +36 -27
- package/dist/es2019/ui/drag-handle.js +17 -10
- package/dist/es2019/ui/quick-insert-button.js +15 -8
- package/dist/es2019/ui/utils/anchor-name.js +29 -0
- package/dist/esm/editor-commands/move-node.js +7 -1
- package/dist/esm/pm-plugins/handle-mouse-down.js +19 -0
- package/dist/esm/pm-plugins/main.js +2 -0
- package/dist/esm/pm-plugins/utils/validation.js +37 -31
- package/dist/esm/ui/drag-handle.js +17 -10
- package/dist/esm/ui/quick-insert-button.js +15 -8
- package/dist/esm/ui/utils/anchor-name.js +28 -0
- package/dist/types/pm-plugins/handle-mouse-down.d.ts +4 -0
- package/dist/types/pm-plugins/utils/validation.d.ts +1 -0
- package/dist/types/ui/utils/anchor-name.d.ts +12 -0
- package/dist/types-ts4.5/pm-plugins/handle-mouse-down.d.ts +4 -0
- package/dist/types-ts4.5/pm-plugins/utils/validation.d.ts +1 -0
- package/dist/types-ts4.5/ui/utils/anchor-name.d.ts +12 -0
- package/package.json +9 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 3.8.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#135614](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/135614)
|
|
8
|
+
[`ed711343dbd01`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ed711343dbd01) -
|
|
9
|
+
ED-27111: Dnd layout column into panel
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 3.8.1
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#135962](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/135962)
|
|
17
|
+
[`b7caf17e63935`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b7caf17e63935) -
|
|
18
|
+
Add refreshAnchorName function to fetch new anchor name if current anchor name isnt provided,
|
|
19
|
+
which is possible as a new mouseDown event listener has been added to fetch position even if
|
|
20
|
+
editor isnt ready
|
|
21
|
+
|
|
3
22
|
## 3.8.0
|
|
4
23
|
|
|
5
24
|
### Minor Changes
|
|
@@ -92,6 +92,10 @@ var isDragLayoutColumnIntoTable = function isDragLayoutColumnIntoTable($from, $t
|
|
|
92
92
|
var _$from$nodeAfter2;
|
|
93
93
|
return ((_$from$nodeAfter2 = $from.nodeAfter) === null || _$from$nodeAfter2 === void 0 ? void 0 : _$from$nodeAfter2.type.name) === 'layoutColumn' && $from.parent.type.name === 'layoutSection' && ($to.parent.type.name === 'tableCell' || $to.parent.type.name === 'tableHeader');
|
|
94
94
|
};
|
|
95
|
+
var isDragLayoutColumnIntoPanel = function isDragLayoutColumnIntoPanel($from, $to) {
|
|
96
|
+
var _$from$nodeAfter3;
|
|
97
|
+
return ((_$from$nodeAfter3 = $from.nodeAfter) === null || _$from$nodeAfter3 === void 0 ? void 0 : _$from$nodeAfter3.type.name) === 'layoutColumn' && $from.parent.type.name === 'layoutSection' && $to.parent.type.name === 'panel';
|
|
98
|
+
};
|
|
95
99
|
|
|
96
100
|
/**
|
|
97
101
|
*
|
|
@@ -387,11 +391,13 @@ var moveNode = exports.moveNode = function moveNode(api) {
|
|
|
387
391
|
var sourceNode = $handlePos.nodeAfter;
|
|
388
392
|
var dragLayoutColumnToTopLevel = isDragLayoutColumnToTopLevel($handlePos, $to);
|
|
389
393
|
var dragLayoutColumnIntoTable = isDragLayoutColumnIntoTable($handlePos, $to);
|
|
394
|
+
var dragLayoutColumnIntoPanel = isDragLayoutColumnIntoPanel($handlePos, $to);
|
|
390
395
|
|
|
391
396
|
//TODO: ED-26959 - Does this need to be updated with new selection logic above? ^
|
|
392
397
|
// Move a layout column to top level
|
|
393
398
|
// Move a layout column into a table cell, only moves the content into the cell
|
|
394
|
-
|
|
399
|
+
// Move a layout column into a panel, only moves the content into the panel
|
|
400
|
+
if (sourceNode && (dragLayoutColumnToTopLevel || dragLayoutColumnIntoTable || dragLayoutColumnIntoPanel)) {
|
|
395
401
|
// need update after we support single column layout.
|
|
396
402
|
var layoutColumnContent = sourceNode.content;
|
|
397
403
|
var fragment;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.handleMouseDown = void 0;
|
|
7
|
+
var handleMouseDown = exports.handleMouseDown = function handleMouseDown(api) {
|
|
8
|
+
return function (view, event) {
|
|
9
|
+
if (view.editable) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
if (event.target instanceof HTMLElement) {
|
|
13
|
+
var _rootNode$type$name, _rootNode$type$name2;
|
|
14
|
+
var targetPos = view.posAtDOM(event.target, 0);
|
|
15
|
+
// always fetch top level position for mouseDown to avoid drag handle positions being incorrect
|
|
16
|
+
var rootPos = view.state.doc.resolve(targetPos).before(1);
|
|
17
|
+
var rootNode = view.state.doc.nodeAt(rootPos);
|
|
18
|
+
if (!rootNode) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.showDragHandleAt(rootPos, '', (_rootNode$type$name = rootNode.type.name) !== null && _rootNode$type$name !== void 0 ? _rootNode$type$name : '', undefined, rootPos, '', (_rootNode$type$name2 = rootNode.type.name) !== null && _rootNode$type$name2 !== void 0 ? _rootNode$type$name2 : ''));
|
|
22
|
+
}
|
|
23
|
+
return false;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
@@ -26,6 +26,7 @@ var _decorationsAnchor = require("./decorations-anchor");
|
|
|
26
26
|
var _decorationsDragHandle = require("./decorations-drag-handle");
|
|
27
27
|
var _decorationsDropTarget = require("./decorations-drop-target");
|
|
28
28
|
var _decorationsQuickInsertButton = require("./decorations-quick-insert-button");
|
|
29
|
+
var _handleMouseDown = require("./handle-mouse-down");
|
|
29
30
|
var _handleMouseOver = require("./handle-mouse-over");
|
|
30
31
|
var _keymap = require("./keymap");
|
|
31
32
|
var _activeAnchorTracker = require("./utils/active-anchor-tracker");
|
|
@@ -728,6 +729,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
|
|
|
728
729
|
(0, _handleMouseOver.handleMouseOver)(view, event, api);
|
|
729
730
|
return false;
|
|
730
731
|
},
|
|
732
|
+
mousedown: (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_2') ? (0, _handleMouseDown.handleMouseDown)(api) : undefined,
|
|
731
733
|
keydown: function keydown(view, event) {
|
|
732
734
|
if (isMultiSelectEnabled) {
|
|
733
735
|
if (event.shiftKey && event.ctrlKey) {
|
|
@@ -4,6 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
+
exports.canCreateNodeWithContentInsideAnotherNode = void 0;
|
|
7
8
|
exports.canMoveNodeToIndex = canMoveNodeToIndex;
|
|
8
9
|
exports.canMoveSliceToIndex = canMoveSliceToIndex;
|
|
9
10
|
exports.transformSliceExpandToNestedExpand = exports.transformFragmentExpandToNestedExpand = exports.transformExpandToNestedExpand = exports.memoizedTransformExpandToNestedExpand = exports.isNestedExpand = exports.isLayoutColumn = exports.isInsideTable = exports.isInSameLayout = exports.isExpand = exports.isDoc = void 0;
|
|
@@ -87,69 +88,75 @@ var memoizedTransformExpandToNestedExpand = exports.memoizedTransformExpandToNes
|
|
|
87
88
|
return null;
|
|
88
89
|
}
|
|
89
90
|
});
|
|
91
|
+
var canCreateNodeWithContentInsideAnotherNode = exports.canCreateNodeWithContentInsideAnotherNode = function canCreateNodeWithContentInsideAnotherNode(nodeTypesToCreate, nodeWithTargetFragment) {
|
|
92
|
+
try {
|
|
93
|
+
return !!nodeTypesToCreate.every(function (nodeType) {
|
|
94
|
+
return nodeType.createChecked({}, nodeWithTargetFragment);
|
|
95
|
+
});
|
|
96
|
+
} catch (e) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
90
100
|
function canMoveNodeToIndex(destParent, indexIntoParent, srcNode, $destNodePos, destNode) {
|
|
91
101
|
var srcNodeType = srcNode.type;
|
|
92
|
-
var
|
|
102
|
+
var schema = srcNodeType.schema;
|
|
103
|
+
var destParentNodeType = destParent === null || destParent === void 0 ? void 0 : destParent.type.name;
|
|
93
104
|
var activeNodeType = srcNode === null || srcNode === void 0 ? void 0 : srcNode.type.name;
|
|
105
|
+
var layoutColumnContent = srcNode.content;
|
|
94
106
|
var isNestingTablesSupported = (0, _platformFeatureFlags.fg)('platform_editor_use_nested_table_pm_nodes') && (0, _experiments.editorExperiment)('nested-tables-in-tables', true, {
|
|
95
107
|
exposure: true
|
|
96
108
|
});
|
|
97
|
-
var tableNodeType =
|
|
98
|
-
var expandNodeType = srcNode.type.schema.nodes.expand;
|
|
109
|
+
var tableNodeType = schema.nodes.table;
|
|
99
110
|
if (activeNodeType === 'layoutColumn' && (0, _experiments.editorExperiment)('advanced_layouts', true)) {
|
|
100
111
|
// Allow drag layout column and drop into layout section
|
|
101
|
-
if ((destNode === null || destNode === void 0 ? void 0 : destNode.type.name) === 'layoutSection' ||
|
|
112
|
+
if ((destNode === null || destNode === void 0 ? void 0 : destNode.type.name) === 'layoutSection' || destParentNodeType === 'doc') {
|
|
102
113
|
return true;
|
|
103
114
|
}
|
|
104
|
-
if ((
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
return
|
|
115
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_drag_layout_column_into_nodes')) {
|
|
116
|
+
if (destParentNodeType === 'tableCell' || destParentNodeType === 'tableHeader') {
|
|
117
|
+
var _schema$nodes = schema.nodes,
|
|
118
|
+
tableCell = _schema$nodes.tableCell,
|
|
119
|
+
tableHeader = _schema$nodes.tableHeader,
|
|
120
|
+
expand = _schema$nodes.expand;
|
|
121
|
+
var contentContainsExpand = (0, _utils.findChildrenByType)(srcNode, expand).length > 0;
|
|
122
|
+
//convert expand to nestedExpand if there are expands inside the layout column
|
|
123
|
+
// otherwise, the createChecked will fail as expand is not a valid child of tableCell/tableHeader, but nestedExpand is
|
|
124
|
+
var convertedFragment = contentContainsExpand ? transformFragmentExpandToNestedExpand(layoutColumnContent) : layoutColumnContent;
|
|
125
|
+
if (!convertedFragment) {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
return canCreateNodeWithContentInsideAnotherNode([tableCell, tableHeader], convertedFragment);
|
|
118
129
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
var isAnyTableNestedInExpand = maybeExpandNodesArray.some(function (result) {
|
|
123
|
-
return (0, _utils.findChildrenByType)(result.node, tableNodeType).length > 0;
|
|
124
|
-
});
|
|
125
|
-
return !isAnyTableNestedInExpand;
|
|
130
|
+
if (destParentNodeType === 'panel') {
|
|
131
|
+
var panel = schema.nodes.panel;
|
|
132
|
+
return canCreateNodeWithContentInsideAnotherNode([panel], layoutColumnContent);
|
|
126
133
|
}
|
|
127
134
|
}
|
|
128
135
|
}
|
|
129
136
|
|
|
130
137
|
// Place experiments here instead of just inside move-node.ts as it stops the drag marker from appearing.
|
|
131
138
|
if ((0, _experiments.editorExperiment)('nested-expand-in-expand', false)) {
|
|
132
|
-
if (
|
|
139
|
+
if (destParentNodeType === 'expand' && (activeNodeType === 'expand' || activeNodeType === 'nestedExpand')) {
|
|
133
140
|
return false;
|
|
134
141
|
}
|
|
135
142
|
}
|
|
136
143
|
|
|
137
144
|
// NOTE: this will block drop targets from showing for dragging a table into another table
|
|
138
145
|
// unless nested tables are supported and the nesting depth does not exceed 1
|
|
139
|
-
if ((
|
|
140
|
-
var
|
|
141
|
-
if (!isNestingTablesSupported || isNestingTablesSupported &&
|
|
146
|
+
if ((destParentNodeType === 'tableCell' || destParentNodeType === 'tableHeader') && activeNodeType === 'table') {
|
|
147
|
+
var nestingDepth = (0, _nesting.getParentOfTypeCount)(tableNodeType)($destNodePos);
|
|
148
|
+
if (!isNestingTablesSupported || isNestingTablesSupported && nestingDepth > 1) {
|
|
142
149
|
return false;
|
|
143
150
|
}
|
|
144
151
|
}
|
|
145
152
|
if (isInsideTable(destParent.type) && isExpand(srcNodeType)) {
|
|
146
153
|
if (memoizedTransformExpandToNestedExpand(srcNode)) {
|
|
147
|
-
srcNodeType =
|
|
154
|
+
srcNodeType = schema.nodes.nestedExpand;
|
|
148
155
|
} else {
|
|
149
156
|
return false;
|
|
150
157
|
}
|
|
151
158
|
} else if ((isDoc(destParent.type) || isLayoutColumn(destParent.type)) && isNestedExpand(srcNodeType)) {
|
|
152
|
-
srcNodeType =
|
|
159
|
+
srcNodeType = schema.nodes.expand;
|
|
153
160
|
}
|
|
154
161
|
return destParent.canReplaceWith(indexIntoParent, indexIntoParent, srcNodeType);
|
|
155
162
|
}
|
|
@@ -34,6 +34,7 @@ var _getSelection = require("../pm-plugins/utils/getSelection");
|
|
|
34
34
|
var _selection = require("../pm-plugins/utils/selection");
|
|
35
35
|
var _consts = require("./consts");
|
|
36
36
|
var _dragPreview = require("./drag-preview");
|
|
37
|
+
var _anchorName = require("./utils/anchor-name");
|
|
37
38
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
38
39
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } /**
|
|
39
40
|
* @jsxRuntime classic
|
|
@@ -130,8 +131,9 @@ var dragHandleContainerStyles = (0, _primitives.xcss)({
|
|
|
130
131
|
boxSizing: 'border-box',
|
|
131
132
|
zIndex: 'card'
|
|
132
133
|
});
|
|
133
|
-
var
|
|
134
|
-
top: '
|
|
134
|
+
var tooltipContainerStyles = (0, _primitives.xcss)({
|
|
135
|
+
top: '8px',
|
|
136
|
+
bottom: '-8px',
|
|
135
137
|
position: 'sticky',
|
|
136
138
|
zIndex: 'card'
|
|
137
139
|
});
|
|
@@ -518,7 +520,12 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
518
520
|
parentNodeType = node === null || node === void 0 ? void 0 : node.type.name;
|
|
519
521
|
}
|
|
520
522
|
var supportsAnchor = CSS.supports('top', "anchor(".concat(anchorName, " start)")) && CSS.supports('left', "anchor(".concat(anchorName, " start)"));
|
|
521
|
-
var
|
|
523
|
+
var safeAnchorName = (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_2') ? (0, _anchorName.refreshAnchorName)({
|
|
524
|
+
getPos: getPos,
|
|
525
|
+
view: view,
|
|
526
|
+
anchorName: anchorName
|
|
527
|
+
}) : anchorName;
|
|
528
|
+
var dom = view.dom.querySelector("[data-drag-handler-anchor-name=\"".concat(safeAnchorName, "\"]"));
|
|
522
529
|
var hasResizer = nodeType === 'table' || nodeType === 'mediaSingle';
|
|
523
530
|
var isExtension = nodeType === 'extension' || nodeType === 'bodiedExtension' || nodeType === 'multiBodiedExtension' && (0, _platformFeatureFlags.fg)('platform_editor_multi_body_extension_extensibility');
|
|
524
531
|
var isBlockCard = nodeType === 'blockCard' && !!blockCardWidth;
|
|
@@ -540,18 +547,18 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
540
547
|
var isEdgeCase = (hasResizer || isExtension || isEmbedCard || isBlockCard) && innerContainer;
|
|
541
548
|
var isSticky = (0, _dragHandlePositions.shouldBeSticky)(nodeType);
|
|
542
549
|
if (supportsAnchor) {
|
|
543
|
-
var bottom = (0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') ? (0, _dragHandlePositions.getControlBottomCSSValue)(
|
|
550
|
+
var bottom = (0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') ? (0, _dragHandlePositions.getControlBottomCSSValue)(safeAnchorName, isSticky, isTopLevelNode, isLayoutColumn) : {};
|
|
544
551
|
return _objectSpread({
|
|
545
|
-
left: isEdgeCase ? "calc(anchor(".concat(
|
|
546
|
-
top: (0, _experiments.editorExperiment)('advanced_layouts', true) && isLayoutColumn ? "calc(anchor(".concat(
|
|
552
|
+
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(_consts.DRAG_HANDLE_HEIGHT / 2, "px)") : "calc(anchor(".concat(safeAnchorName, " start) - ").concat(_consts.DRAG_HANDLE_WIDTH, "px - ").concat((0, _consts.dragHandleGap)(nodeType, parentNodeType), "px)"),
|
|
553
|
+
top: (0, _experiments.editorExperiment)('advanced_layouts', true) && isLayoutColumn ? "calc(anchor(".concat(safeAnchorName, " top) - ").concat(_consts.DRAG_HANDLE_WIDTH, "px)") : "calc(anchor(".concat(safeAnchorName, " start) + ").concat((0, _consts.topPositionAdjustment)(nodeType), "px)")
|
|
547
554
|
}, bottom);
|
|
548
555
|
}
|
|
549
|
-
var height = (0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') ? (0, _dragHandlePositions.getControlHeightCSSValue)((0, _dragHandlePositions.getNodeHeight)(dom,
|
|
556
|
+
var height = (0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') ? (0, _dragHandlePositions.getControlHeightCSSValue)((0, _dragHandlePositions.getNodeHeight)(dom, safeAnchorName, anchorRectCache) || 0, isSticky, isTopLevelNode, "".concat(_consts.DRAG_HANDLE_HEIGHT), isLayoutColumn) : {};
|
|
550
557
|
return _objectSpread({
|
|
551
558
|
left: isEdgeCase ? "calc(".concat((dom === null || dom === void 0 ? void 0 : dom.offsetLeft) || 0, "px + ").concat((0, _dragHandlePositions.getLeftPosition)(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType), ")") : (0, _dragHandlePositions.getLeftPosition)(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType),
|
|
552
559
|
top: (0, _dragHandlePositions.getTopPosition)(dom, nodeType)
|
|
553
560
|
}, height);
|
|
554
|
-
}, [anchorName,
|
|
561
|
+
}, [anchorName, getPos, view, nodeType, blockCardWidth, macroInteractionUpdates, anchorRectCache, isTopLevelNode, isLayoutColumn]);
|
|
555
562
|
var _useState7 = (0, _react.useState)({
|
|
556
563
|
display: 'none'
|
|
557
564
|
}),
|
|
@@ -728,7 +735,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
728
735
|
as: "span",
|
|
729
736
|
testId: "block-ctrl-drag-handle-container"
|
|
730
737
|
}, (0, _react2.jsx)(_primitives.Box, {
|
|
731
|
-
xcss: [
|
|
738
|
+
xcss: [tooltipContainerStyles],
|
|
732
739
|
as: "span"
|
|
733
740
|
}, (0, _react2.jsx)(_tooltip.default, {
|
|
734
741
|
content: (0, _react2.jsx)(_keymaps.TooltipContentWithMultipleShortcuts, {
|
|
@@ -753,7 +760,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
753
760
|
as: "span",
|
|
754
761
|
testId: "block-ctrl-drag-handle-container"
|
|
755
762
|
}, (0, _react2.jsx)(_primitives.Box, {
|
|
756
|
-
xcss: [
|
|
763
|
+
xcss: [tooltipContainerStyles],
|
|
757
764
|
as: "span"
|
|
758
765
|
}, renderButton()));
|
|
759
766
|
};
|
|
@@ -22,6 +22,7 @@ var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
|
|
|
22
22
|
var _dragHandlePositions = require("../pm-plugins/utils/drag-handle-positions");
|
|
23
23
|
var _widgetPositions = require("../pm-plugins/utils/widget-positions");
|
|
24
24
|
var _consts = require("./consts");
|
|
25
|
+
var _anchorName = require("./utils/anchor-name");
|
|
25
26
|
var _documentChecks = require("./utils/document-checks");
|
|
26
27
|
var _editorCommands = require("./utils/editor-commands");
|
|
27
28
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
@@ -94,7 +95,8 @@ var disabledContainerStyles = (0, _primitives.xcss)({
|
|
|
94
95
|
cursor: 'not-allowed'
|
|
95
96
|
});
|
|
96
97
|
var tooltipContainerStyles = (0, _primitives.xcss)({
|
|
97
|
-
top: '
|
|
98
|
+
top: '8px',
|
|
99
|
+
bottom: '-8px',
|
|
98
100
|
position: 'sticky',
|
|
99
101
|
zIndex: 'card'
|
|
100
102
|
});
|
|
@@ -127,7 +129,12 @@ var TypeAheadControl = exports.TypeAheadControl = function TypeAheadControl(_ref
|
|
|
127
129
|
// CHANGES - `removed editorExperiment('advanced_layouts', true) && isLayoutColumn` checks as quick insert button will not be positioned for layout column
|
|
128
130
|
var calculatePosition = (0, _react.useCallback)(function () {
|
|
129
131
|
var supportsAnchor = CSS.supports('top', "anchor(".concat(rootAnchorName, " start)")) && CSS.supports('left', "anchor(".concat(rootAnchorName, " start)"));
|
|
130
|
-
var
|
|
132
|
+
var safeAnchorName = (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_2') ? (0, _anchorName.refreshAnchorName)({
|
|
133
|
+
getPos: getPos,
|
|
134
|
+
view: view,
|
|
135
|
+
anchorName: rootAnchorName
|
|
136
|
+
}) : rootAnchorName;
|
|
137
|
+
var dom = view.dom.querySelector("[data-drag-handler-anchor-name=\"".concat(safeAnchorName, "\"]"));
|
|
131
138
|
var hasResizer = rootNodeType === 'table' || rootNodeType === 'mediaSingle';
|
|
132
139
|
var isExtension = rootNodeType === 'extension' || rootNodeType === 'bodiedExtension';
|
|
133
140
|
var isBlockCard = rootNodeType === 'blockCard';
|
|
@@ -148,24 +155,24 @@ var TypeAheadControl = exports.TypeAheadControl = function TypeAheadControl(_ref
|
|
|
148
155
|
}
|
|
149
156
|
var isEdgeCase = (hasResizer || isExtension || isEmbedCard || isBlockCard) && innerContainer;
|
|
150
157
|
var isSticky = (0, _dragHandlePositions.shouldBeSticky)(rootNodeType);
|
|
151
|
-
var bottom = (0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') ? (0, _dragHandlePositions.getControlBottomCSSValue)(
|
|
158
|
+
var bottom = (0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') ? (0, _dragHandlePositions.getControlBottomCSSValue)(safeAnchorName || anchorName, isSticky, true) : {};
|
|
152
159
|
if (supportsAnchor) {
|
|
153
160
|
return _objectSpread({
|
|
154
|
-
left: isEdgeCase ? "calc(anchor(".concat(
|
|
155
|
-
top: "calc(anchor(".concat(
|
|
161
|
+
left: isEdgeCase ? "calc(anchor(".concat(safeAnchorName, " start) + ").concat((0, _widgetPositions.getLeftPositionForRootElement)(dom, rootNodeType, _consts.QUICK_INSERT_DIMENSIONS, innerContainer, isMacroInteractionUpdates), " + -").concat(_consts.QUICK_INSERT_LEFT_OFFSET, "px)") : "calc(anchor(".concat(safeAnchorName, " start) - ").concat(_consts.QUICK_INSERT_DIMENSIONS.width, "px - ").concat((0, _consts.rootElementGap)(rootNodeType), "px + -").concat(_consts.QUICK_INSERT_LEFT_OFFSET, "px)"),
|
|
162
|
+
top: "calc(anchor(".concat(safeAnchorName, " start) + ").concat((0, _consts.topPositionAdjustment)(rootNodeType), "px)")
|
|
156
163
|
}, bottom);
|
|
157
164
|
}
|
|
158
165
|
|
|
159
166
|
// expensive, calls offsetHeight, guard behind FG
|
|
160
167
|
var nodeHeight =
|
|
161
168
|
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
162
|
-
(0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') && (0, _dragHandlePositions.getNodeHeight)(dom,
|
|
169
|
+
(0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') && (0, _dragHandlePositions.getNodeHeight)(dom, safeAnchorName || anchorName, anchorRectCache) || 0;
|
|
163
170
|
var height = (0, _platformFeatureFlags.fg)('platform_editor_controls_sticky_controls') ? (0, _dragHandlePositions.getControlHeightCSSValue)(nodeHeight, isSticky, true, "var(--ds-space-300, 24px)") : {};
|
|
164
171
|
return _objectSpread({
|
|
165
172
|
left: isEdgeCase ? "calc(".concat((dom === null || dom === void 0 ? void 0 : dom.offsetLeft) || 0, "px + ").concat((0, _widgetPositions.getLeftPositionForRootElement)(dom, rootNodeType, _consts.QUICK_INSERT_DIMENSIONS, innerContainer, isMacroInteractionUpdates), " + -").concat(_consts.QUICK_INSERT_LEFT_OFFSET, "px)") : "calc(".concat((0, _widgetPositions.getLeftPositionForRootElement)(dom, rootNodeType, _consts.QUICK_INSERT_DIMENSIONS, innerContainer, isMacroInteractionUpdates), " + -").concat(_consts.QUICK_INSERT_LEFT_OFFSET, "px)"),
|
|
166
173
|
top: (0, _dragHandlePositions.getTopPosition)(dom, rootNodeType)
|
|
167
174
|
}, height);
|
|
168
|
-
}, [rootAnchorName, view
|
|
175
|
+
}, [rootAnchorName, getPos, view, rootNodeType, macroInteractionUpdates, anchorName, anchorRectCache]);
|
|
169
176
|
(0, _react.useEffect)(function () {
|
|
170
177
|
var cleanUpTransitionListener;
|
|
171
178
|
if (rootNodeType === 'extension' || rootNodeType === 'embedCard') {
|
|
@@ -239,7 +246,7 @@ var TypeAheadControl = exports.TypeAheadControl = function TypeAheadControl(_ref
|
|
|
239
246
|
}
|
|
240
247
|
}
|
|
241
248
|
}
|
|
242
|
-
(_api$quickInsert = api.quickInsert) === null || _api$quickInsert === void 0 || _api$quickInsert.actions.openTypeAhead('blockControl');
|
|
249
|
+
(_api$quickInsert = api.quickInsert) === null || _api$quickInsert === void 0 || _api$quickInsert.actions.openTypeAhead('blockControl', true);
|
|
243
250
|
}, [api, getPos, view]);
|
|
244
251
|
var handleMouseDown = (0, _react.useCallback)(function () {
|
|
245
252
|
var _api$typeAhead;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.refreshAnchorName = void 0;
|
|
7
|
+
var _decorationsAnchor = require("../../pm-plugins/decorations-anchor");
|
|
8
|
+
var _main = require("../../pm-plugins/main");
|
|
9
|
+
/**
|
|
10
|
+
* Checks for plugin state for latest anchorName based on the position, returns
|
|
11
|
+
* provided anchorName if available
|
|
12
|
+
*/
|
|
13
|
+
var refreshAnchorName = exports.refreshAnchorName = function refreshAnchorName(_ref) {
|
|
14
|
+
var getPos = _ref.getPos,
|
|
15
|
+
view = _ref.view,
|
|
16
|
+
anchorName = _ref.anchorName;
|
|
17
|
+
var newAnchorName = anchorName || '';
|
|
18
|
+
var pos = getPos();
|
|
19
|
+
if (anchorName || pos === undefined) {
|
|
20
|
+
return newAnchorName;
|
|
21
|
+
}
|
|
22
|
+
var node = view.state.doc.nodeAt(pos);
|
|
23
|
+
var state = _main.key.getState(view.state);
|
|
24
|
+
if (state !== null && state !== void 0 && state.decorations) {
|
|
25
|
+
var _node$nodeSize;
|
|
26
|
+
var nodeDecs = (0, _decorationsAnchor.findNodeDecs)(state.decorations, pos, pos + ((_node$nodeSize = node === null || node === void 0 ? void 0 : node.nodeSize) !== null && _node$nodeSize !== void 0 ? _node$nodeSize : 0));
|
|
27
|
+
var nodeDec = nodeDecs.at(0);
|
|
28
|
+
if (!nodeDec) {
|
|
29
|
+
return newAnchorName;
|
|
30
|
+
}
|
|
31
|
+
newAnchorName = nodeDec.spec.anchorName;
|
|
32
|
+
}
|
|
33
|
+
return newAnchorName;
|
|
34
|
+
};
|
|
@@ -85,6 +85,10 @@ const isDragLayoutColumnIntoTable = ($from, $to) => {
|
|
|
85
85
|
var _$from$nodeAfter2;
|
|
86
86
|
return ((_$from$nodeAfter2 = $from.nodeAfter) === null || _$from$nodeAfter2 === void 0 ? void 0 : _$from$nodeAfter2.type.name) === 'layoutColumn' && $from.parent.type.name === 'layoutSection' && ($to.parent.type.name === 'tableCell' || $to.parent.type.name === 'tableHeader');
|
|
87
87
|
};
|
|
88
|
+
const isDragLayoutColumnIntoPanel = ($from, $to) => {
|
|
89
|
+
var _$from$nodeAfter3;
|
|
90
|
+
return ((_$from$nodeAfter3 = $from.nodeAfter) === null || _$from$nodeAfter3 === void 0 ? void 0 : _$from$nodeAfter3.type.name) === 'layoutColumn' && $from.parent.type.name === 'layoutSection' && $to.parent.type.name === 'panel';
|
|
91
|
+
};
|
|
88
92
|
|
|
89
93
|
/**
|
|
90
94
|
*
|
|
@@ -390,11 +394,13 @@ export const moveNode = api => (start, to, inputMethod = INPUT_METHOD.DRAG_AND_D
|
|
|
390
394
|
const sourceNode = $handlePos.nodeAfter;
|
|
391
395
|
const dragLayoutColumnToTopLevel = isDragLayoutColumnToTopLevel($handlePos, $to);
|
|
392
396
|
const dragLayoutColumnIntoTable = isDragLayoutColumnIntoTable($handlePos, $to);
|
|
397
|
+
const dragLayoutColumnIntoPanel = isDragLayoutColumnIntoPanel($handlePos, $to);
|
|
393
398
|
|
|
394
399
|
//TODO: ED-26959 - Does this need to be updated with new selection logic above? ^
|
|
395
400
|
// Move a layout column to top level
|
|
396
401
|
// Move a layout column into a table cell, only moves the content into the cell
|
|
397
|
-
|
|
402
|
+
// Move a layout column into a panel, only moves the content into the panel
|
|
403
|
+
if (sourceNode && (dragLayoutColumnToTopLevel || dragLayoutColumnIntoTable || dragLayoutColumnIntoPanel)) {
|
|
398
404
|
// need update after we support single column layout.
|
|
399
405
|
const layoutColumnContent = sourceNode.content;
|
|
400
406
|
let fragment;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const handleMouseDown = api => (view, event) => {
|
|
2
|
+
if (view.editable) {
|
|
3
|
+
return false;
|
|
4
|
+
}
|
|
5
|
+
if (event.target instanceof HTMLElement) {
|
|
6
|
+
var _rootNode$type$name, _rootNode$type$name2;
|
|
7
|
+
const targetPos = view.posAtDOM(event.target, 0);
|
|
8
|
+
// always fetch top level position for mouseDown to avoid drag handle positions being incorrect
|
|
9
|
+
const rootPos = view.state.doc.resolve(targetPos).before(1);
|
|
10
|
+
const rootNode = view.state.doc.nodeAt(rootPos);
|
|
11
|
+
if (!rootNode) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.showDragHandleAt(rootPos, '', (_rootNode$type$name = rootNode.type.name) !== null && _rootNode$type$name !== void 0 ? _rootNode$type$name : '', undefined, rootPos, '', (_rootNode$type$name2 = rootNode.type.name) !== null && _rootNode$type$name2 !== void 0 ? _rootNode$type$name2 : ''));
|
|
15
|
+
}
|
|
16
|
+
return false;
|
|
17
|
+
};
|
|
@@ -17,6 +17,7 @@ import { findNodeDecs, nodeDecorations } from './decorations-anchor';
|
|
|
17
17
|
import { dragHandleDecoration, emptyParagraphNodeDecorations, findHandleDec } from './decorations-drag-handle';
|
|
18
18
|
import { dropTargetDecorations, findDropTargetDecs } from './decorations-drop-target';
|
|
19
19
|
import { findQuickInsertInsertButtonDecoration, quickInsertButtonDecoration } from './decorations-quick-insert-button';
|
|
20
|
+
import { handleMouseDown } from './handle-mouse-down';
|
|
20
21
|
import { handleMouseOver } from './handle-mouse-over';
|
|
21
22
|
import { boundKeydownHandler } from './keymap';
|
|
22
23
|
import { defaultActiveAnchorTracker } from './utils/active-anchor-tracker';
|
|
@@ -714,6 +715,7 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI) => {
|
|
|
714
715
|
handleMouseOver(view, event, api);
|
|
715
716
|
return false;
|
|
716
717
|
},
|
|
718
|
+
mousedown: editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_2') ? handleMouseDown(api) : undefined,
|
|
717
719
|
keydown(view, event) {
|
|
718
720
|
if (isMultiSelectEnabled) {
|
|
719
721
|
if (event.shiftKey && event.ctrlKey) {
|
|
@@ -80,54 +80,63 @@ export const memoizedTransformExpandToNestedExpand = memoizeOne(node => {
|
|
|
80
80
|
return null;
|
|
81
81
|
}
|
|
82
82
|
});
|
|
83
|
+
export const canCreateNodeWithContentInsideAnotherNode = (nodeTypesToCreate, nodeWithTargetFragment) => {
|
|
84
|
+
try {
|
|
85
|
+
return !!nodeTypesToCreate.every(nodeType => nodeType.createChecked({}, nodeWithTargetFragment));
|
|
86
|
+
} catch (e) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
83
90
|
export function canMoveNodeToIndex(destParent, indexIntoParent, srcNode, $destNodePos, destNode) {
|
|
84
91
|
let srcNodeType = srcNode.type;
|
|
85
|
-
const
|
|
92
|
+
const schema = srcNodeType.schema;
|
|
93
|
+
const destParentNodeType = destParent === null || destParent === void 0 ? void 0 : destParent.type.name;
|
|
86
94
|
const activeNodeType = srcNode === null || srcNode === void 0 ? void 0 : srcNode.type.name;
|
|
95
|
+
const layoutColumnContent = srcNode.content;
|
|
87
96
|
const isNestingTablesSupported = fg('platform_editor_use_nested_table_pm_nodes') && editorExperiment('nested-tables-in-tables', true, {
|
|
88
97
|
exposure: true
|
|
89
98
|
});
|
|
90
|
-
const tableNodeType =
|
|
91
|
-
const expandNodeType = srcNode.type.schema.nodes.expand;
|
|
99
|
+
const tableNodeType = schema.nodes.table;
|
|
92
100
|
if (activeNodeType === 'layoutColumn' && editorExperiment('advanced_layouts', true)) {
|
|
93
101
|
// Allow drag layout column and drop into layout section
|
|
94
|
-
if ((destNode === null || destNode === void 0 ? void 0 : destNode.type.name) === 'layoutSection' ||
|
|
102
|
+
if ((destNode === null || destNode === void 0 ? void 0 : destNode.type.name) === 'layoutSection' || destParentNodeType === 'doc') {
|
|
95
103
|
return true;
|
|
96
104
|
}
|
|
97
|
-
if (
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
105
|
+
if (fg('platform_editor_drag_layout_column_into_nodes')) {
|
|
106
|
+
if (destParentNodeType === 'tableCell' || destParentNodeType === 'tableHeader') {
|
|
107
|
+
const {
|
|
108
|
+
tableCell,
|
|
109
|
+
tableHeader,
|
|
110
|
+
expand
|
|
111
|
+
} = schema.nodes;
|
|
112
|
+
const contentContainsExpand = findChildrenByType(srcNode, expand).length > 0;
|
|
113
|
+
//convert expand to nestedExpand if there are expands inside the layout column
|
|
114
|
+
// otherwise, the createChecked will fail as expand is not a valid child of tableCell/tableHeader, but nestedExpand is
|
|
115
|
+
const convertedFragment = contentContainsExpand ? transformFragmentExpandToNestedExpand(layoutColumnContent) : layoutColumnContent;
|
|
116
|
+
if (!convertedFragment) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
return canCreateNodeWithContentInsideAnotherNode([tableCell, tableHeader], convertedFragment);
|
|
111
120
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
return
|
|
121
|
+
if (destParentNodeType === 'panel') {
|
|
122
|
+
const {
|
|
123
|
+
panel
|
|
124
|
+
} = schema.nodes;
|
|
125
|
+
return canCreateNodeWithContentInsideAnotherNode([panel], layoutColumnContent);
|
|
117
126
|
}
|
|
118
127
|
}
|
|
119
128
|
}
|
|
120
129
|
|
|
121
130
|
// Place experiments here instead of just inside move-node.ts as it stops the drag marker from appearing.
|
|
122
131
|
if (editorExperiment('nested-expand-in-expand', false)) {
|
|
123
|
-
if (
|
|
132
|
+
if (destParentNodeType === 'expand' && (activeNodeType === 'expand' || activeNodeType === 'nestedExpand')) {
|
|
124
133
|
return false;
|
|
125
134
|
}
|
|
126
135
|
}
|
|
127
136
|
|
|
128
137
|
// NOTE: this will block drop targets from showing for dragging a table into another table
|
|
129
138
|
// unless nested tables are supported and the nesting depth does not exceed 1
|
|
130
|
-
if ((
|
|
139
|
+
if ((destParentNodeType === 'tableCell' || destParentNodeType === 'tableHeader') && activeNodeType === 'table') {
|
|
131
140
|
const nestingDepth = getParentOfTypeCount(tableNodeType)($destNodePos);
|
|
132
141
|
if (!isNestingTablesSupported || isNestingTablesSupported && nestingDepth > 1) {
|
|
133
142
|
return false;
|
|
@@ -135,12 +144,12 @@ export function canMoveNodeToIndex(destParent, indexIntoParent, srcNode, $destNo
|
|
|
135
144
|
}
|
|
136
145
|
if (isInsideTable(destParent.type) && isExpand(srcNodeType)) {
|
|
137
146
|
if (memoizedTransformExpandToNestedExpand(srcNode)) {
|
|
138
|
-
srcNodeType =
|
|
147
|
+
srcNodeType = schema.nodes.nestedExpand;
|
|
139
148
|
} else {
|
|
140
149
|
return false;
|
|
141
150
|
}
|
|
142
151
|
} else if ((isDoc(destParent.type) || isLayoutColumn(destParent.type)) && isNestedExpand(srcNodeType)) {
|
|
143
|
-
srcNodeType =
|
|
152
|
+
srcNodeType = schema.nodes.expand;
|
|
144
153
|
}
|
|
145
154
|
return destParent.canReplaceWith(indexIntoParent, indexIntoParent, srcNodeType);
|
|
146
155
|
}
|