@atlaskit/editor-plugin-block-controls 2.13.29 → 2.13.31
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 +24 -0
- package/dist/cjs/pm-plugins/decorations-anchor.js +3 -4
- package/dist/cjs/pm-plugins/decorations-drop-target.js +1 -2
- package/dist/cjs/pm-plugins/handle-mouse-over.js +1 -27
- package/dist/cjs/pm-plugins/main.js +2 -3
- package/dist/cjs/pm-plugins/utils/active-anchor-tracker.js +2 -2
- package/dist/cjs/pm-plugins/utils/consts.js +2 -2
- package/dist/cjs/pm-plugins/utils/inline-drop-target.js +4 -4
- package/dist/cjs/pm-plugins/utils/validation.js +1 -2
- package/dist/cjs/ui/consts.js +3 -3
- package/dist/cjs/ui/drag-handle.js +5 -6
- package/dist/cjs/ui/drop-target-v2.js +1 -2
- package/dist/cjs/ui/inline-drop-target.js +34 -21
- package/dist/es2019/pm-plugins/decorations-anchor.js +3 -4
- package/dist/es2019/pm-plugins/decorations-drop-target.js +1 -2
- package/dist/es2019/pm-plugins/handle-mouse-over.js +1 -27
- package/dist/es2019/pm-plugins/main.js +2 -3
- package/dist/es2019/pm-plugins/utils/active-anchor-tracker.js +2 -2
- package/dist/es2019/pm-plugins/utils/consts.js +2 -2
- package/dist/es2019/pm-plugins/utils/inline-drop-target.js +4 -4
- package/dist/es2019/pm-plugins/utils/validation.js +1 -2
- package/dist/es2019/ui/consts.js +3 -3
- package/dist/es2019/ui/drag-handle.js +5 -6
- package/dist/es2019/ui/drop-target-v2.js +1 -2
- package/dist/es2019/ui/inline-drop-target.js +38 -21
- package/dist/esm/pm-plugins/decorations-anchor.js +3 -4
- package/dist/esm/pm-plugins/decorations-drop-target.js +1 -2
- package/dist/esm/pm-plugins/handle-mouse-over.js +1 -27
- package/dist/esm/pm-plugins/main.js +2 -3
- package/dist/esm/pm-plugins/utils/active-anchor-tracker.js +2 -2
- package/dist/esm/pm-plugins/utils/consts.js +2 -2
- package/dist/esm/pm-plugins/utils/inline-drop-target.js +4 -4
- package/dist/esm/pm-plugins/utils/validation.js +1 -2
- package/dist/esm/ui/consts.js +3 -3
- package/dist/esm/ui/drag-handle.js +5 -6
- package/dist/esm/ui/drop-target-v2.js +1 -2
- package/dist/esm/ui/inline-drop-target.js +34 -21
- package/package.json +4 -13
- package/dist/cjs/pm-plugins/utils/advanced-layouts-flags.js +0 -19
- package/dist/es2019/pm-plugins/utils/advanced-layouts-flags.js +0 -14
- package/dist/esm/pm-plugins/utils/advanced-layouts-flags.js +0 -14
- package/dist/types/pm-plugins/utils/advanced-layouts-flags.d.ts +0 -3
- package/dist/types-ts4.5/pm-plugins/utils/advanced-layouts-flags.d.ts +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 2.13.31
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#171553](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/171553)
|
|
8
|
+
[`ef0f90dd048d8`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ef0f90dd048d8) -
|
|
9
|
+
[ED-25917] Replace dynamic styles for inline hover zone with css var
|
|
10
|
+
- [#171077](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/171077)
|
|
11
|
+
[`0a92cf56671ac`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/0a92cf56671ac) -
|
|
12
|
+
ED-25867 always show drag handler for layout columns
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
15
|
+
## 2.13.30
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [#171014](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/171014)
|
|
20
|
+
[`6163248356c63`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/6163248356c63) -
|
|
21
|
+
[ED-25833] Replace the following FGs with experiment `platform_editor_advanced_layouts`
|
|
22
|
+
|
|
23
|
+
- platform_editor_advanced_layouts_breakout_resizing
|
|
24
|
+
- platform_editor_advanced_layouts_pre_release_1
|
|
25
|
+
- platform_editor_advanced_layouts_pre_release_2
|
|
26
|
+
|
|
3
27
|
## 2.13.29
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
|
@@ -10,7 +10,6 @@ var _view = require("@atlaskit/editor-prosemirror/view");
|
|
|
10
10
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
11
11
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
12
12
|
var _decorationsCommon = require("./decorations-common");
|
|
13
|
-
var _advancedLayoutsFlags = require("./utils/advanced-layouts-flags");
|
|
14
13
|
var IGNORE_NODES = ['tableCell', 'tableHeader', 'tableRow', 'listItem', 'caption', 'layoutColumn'];
|
|
15
14
|
var IGNORE_NODES_NEXT = ['tableCell', 'tableHeader', 'tableRow', 'listItem', 'caption'];
|
|
16
15
|
var IGNORE_NODE_DESCENDANTS = ['listItem', 'taskList', 'decisionList', 'mediaSingle'];
|
|
@@ -23,7 +22,7 @@ var shouldDescendIntoNode = exports.shouldDescendIntoNode = function shouldDesce
|
|
|
23
22
|
return false;
|
|
24
23
|
}
|
|
25
24
|
}
|
|
26
|
-
if ((0,
|
|
25
|
+
if ((0, _experiments.editorExperiment)('advanced_layouts', true)) {
|
|
27
26
|
return !IGNORE_NODE_DESCENDANTS_ADVANCED_LAYOUT.includes(node.type.name);
|
|
28
27
|
}
|
|
29
28
|
return !IGNORE_NODE_DESCENDANTS.includes(node.type.name);
|
|
@@ -33,7 +32,7 @@ var shouldIgnoreNode = function shouldIgnoreNode(node, ignore_nodes, depth, pare
|
|
|
33
32
|
|
|
34
33
|
// TODO use isWrappedMedia when clean up the feature flag
|
|
35
34
|
var isMediaSingle = 'mediaSingle' === node.type.name && (0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_fix_patch_1');
|
|
36
|
-
var isFirstTableRow = (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'table' && depth === 1 && node === parent.firstChild && 'tableRow' === node.type.name && (0,
|
|
35
|
+
var isFirstTableRow = (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'table' && depth === 1 && node === parent.firstChild && 'tableRow' === node.type.name && (0, _experiments.editorExperiment)('advanced_layouts', true);
|
|
37
36
|
if (isFirstTableRow) {
|
|
38
37
|
return false;
|
|
39
38
|
}
|
|
@@ -73,7 +72,7 @@ var nodeDecorations = exports.nodeDecorations = function nodeDecorations(newStat
|
|
|
73
72
|
var decs = [];
|
|
74
73
|
var docFrom = from === undefined || from < 0 ? 0 : from;
|
|
75
74
|
var docTo = to === undefined || to > newState.doc.nodeSize - 2 ? newState.doc.nodeSize - 2 : to;
|
|
76
|
-
var ignore_nodes = (0,
|
|
75
|
+
var ignore_nodes = (0, _experiments.editorExperiment)('advanced_layouts', true) ? IGNORE_NODES_NEXT : IGNORE_NODES;
|
|
77
76
|
newState.doc.nodesBetween(docFrom, docTo, function (node, pos, parent, index) {
|
|
78
77
|
var _Decoration$node;
|
|
79
78
|
var depth = 0;
|
|
@@ -18,7 +18,6 @@ var _dropTarget = require("../ui/drop-target");
|
|
|
18
18
|
var _dropTargetLayout = require("../ui/drop-target-layout");
|
|
19
19
|
var _dropTargetV = require("../ui/drop-target-v2");
|
|
20
20
|
var _decorationsCommon = require("./decorations-common");
|
|
21
|
-
var _advancedLayoutsFlags = require("./utils/advanced-layouts-flags");
|
|
22
21
|
var _consts2 = require("./utils/consts");
|
|
23
22
|
var _dragTargetDebug = require("./utils/drag-target-debug");
|
|
24
23
|
var _validation = require("./utils/validation");
|
|
@@ -186,7 +185,7 @@ var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetD
|
|
|
186
185
|
popNodeStack(depth);
|
|
187
186
|
prevNodeStack.push(node);
|
|
188
187
|
};
|
|
189
|
-
var isAdvancedLayoutsPreRelease2 = (0,
|
|
188
|
+
var isAdvancedLayoutsPreRelease2 = (0, _experiments.editorExperiment)('advanced_layouts', true);
|
|
190
189
|
newState.doc.nodesBetween(docFrom, docTo, function (node, pos, parent, index) {
|
|
191
190
|
var depth = 0;
|
|
192
191
|
// drop target deco at the end position
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.handleMouseOver = void 0;
|
|
7
7
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
8
8
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
9
|
-
var _advancedLayoutsFlags = require("./utils/advanced-layouts-flags");
|
|
10
9
|
var isEmptyNestedParagraphOrHeading = function isEmptyNestedParagraphOrHeading(target) {
|
|
11
10
|
if (target instanceof HTMLHeadingElement || target instanceof HTMLParagraphElement) {
|
|
12
11
|
var _target$parentElement;
|
|
@@ -14,26 +13,6 @@ var isEmptyNestedParagraphOrHeading = function isEmptyNestedParagraphOrHeading(t
|
|
|
14
13
|
}
|
|
15
14
|
return false;
|
|
16
15
|
};
|
|
17
|
-
var isEmptyParagraphOrPlaceholder = function isEmptyParagraphOrPlaceholder(node) {
|
|
18
|
-
if (node && node.type.name === 'paragraph') {
|
|
19
|
-
var _node$firstChild;
|
|
20
|
-
return node.childCount === 0 || node.childCount === 1 && ((_node$firstChild = node.firstChild) === null || _node$firstChild === void 0 ? void 0 : _node$firstChild.type.name) === 'placeholder';
|
|
21
|
-
}
|
|
22
|
-
return false;
|
|
23
|
-
};
|
|
24
|
-
var isLayoutColumnWithoutContent = function isLayoutColumnWithoutContent(node) {
|
|
25
|
-
if ((node === null || node === void 0 ? void 0 : node.type.name) === 'layoutColumn') {
|
|
26
|
-
var foundNonEmptyNode = false;
|
|
27
|
-
for (var i = 0; i < node.childCount; i++) {
|
|
28
|
-
var child = node.child(i);
|
|
29
|
-
if (!isEmptyParagraphOrPlaceholder(child)) {
|
|
30
|
-
foundNonEmptyNode = true;
|
|
31
|
-
break;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return !foundNonEmptyNode;
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
16
|
var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, event, api) {
|
|
38
17
|
var _api$blockControls, _target$classList;
|
|
39
18
|
var _ref = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
|
|
@@ -56,7 +35,7 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, e
|
|
|
56
35
|
if ((0, _experiments.editorExperiment)('nested-dnd', true) && isEmptyNestedParagraphOrHeading(rootElement)) {
|
|
57
36
|
return false;
|
|
58
37
|
}
|
|
59
|
-
if (rootElement.getAttribute('data-drag-handler-node-type') === 'media' && (0,
|
|
38
|
+
if (rootElement.getAttribute('data-drag-handler-node-type') === 'media' && (0, _experiments.editorExperiment)('advanced_layouts', true)) {
|
|
60
39
|
rootElement = rootElement.closest('[data-drag-handler-anchor-name][data-drag-handler-node-type="mediaSingle"]');
|
|
61
40
|
if (!rootElement) {
|
|
62
41
|
return false;
|
|
@@ -99,11 +78,6 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, e
|
|
|
99
78
|
} else {
|
|
100
79
|
pos = view.posAtDOM(rootElement, 0);
|
|
101
80
|
}
|
|
102
|
-
var node = view.state.doc.nodeAt(pos);
|
|
103
|
-
if ((0, _advancedLayoutsFlags.isPreRelease2)() && node && isLayoutColumnWithoutContent(node)) {
|
|
104
|
-
// Don't show drag handle when there is no content/only placeholder in layout column
|
|
105
|
-
return false;
|
|
106
|
-
}
|
|
107
81
|
var rootPos;
|
|
108
82
|
if ((0, _experiments.editorExperiment)('nested-dnd', true)) {
|
|
109
83
|
rootPos = view.state.doc.resolve(pos).pos;
|
|
@@ -25,7 +25,6 @@ var _decorationsDropTarget = require("./decorations-drop-target");
|
|
|
25
25
|
var _handleMouseOver = require("./handle-mouse-over");
|
|
26
26
|
var _keymap = require("./keymap");
|
|
27
27
|
var _activeAnchorTracker = require("./utils/active-anchor-tracker");
|
|
28
|
-
var _advancedLayoutsFlags = require("./utils/advanced-layouts-flags");
|
|
29
28
|
var _anchorUtils = require("./utils/anchor-utils");
|
|
30
29
|
var _dragTargetDebug = require("./utils/drag-target-debug");
|
|
31
30
|
var _transactions = require("./utils/transactions");
|
|
@@ -502,7 +501,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
|
|
|
502
501
|
return false;
|
|
503
502
|
},
|
|
504
503
|
dragenter: function dragenter(_view, event) {
|
|
505
|
-
if ((0,
|
|
504
|
+
if ((0, _experiments.editorExperiment)('advanced_layouts', true)) {
|
|
506
505
|
if (isHTMLElement(event.target)) {
|
|
507
506
|
var closestParentElement = event.target.closest('[data-drag-handler-anchor-depth="0"]');
|
|
508
507
|
if (closestParentElement) {
|
|
@@ -516,7 +515,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
|
|
|
516
515
|
},
|
|
517
516
|
dragstart: function dragstart(view) {
|
|
518
517
|
var _anchorRectCache;
|
|
519
|
-
if ((0,
|
|
518
|
+
if ((0, _experiments.editorExperiment)('advanced_layouts', true)) {
|
|
520
519
|
_activeAnchorTracker.defaultActiveAnchorTracker.reset();
|
|
521
520
|
}
|
|
522
521
|
(_anchorRectCache = anchorRectCache) === null || _anchorRectCache === void 0 || _anchorRectCache.setEditorView(view);
|
|
@@ -11,7 +11,7 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
|
|
|
11
11
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
12
12
|
var _events = require("events");
|
|
13
13
|
var _react = require("react");
|
|
14
|
-
var
|
|
14
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
15
15
|
var ActiveAnchorTracker = exports.ActiveAnchorTracker = /*#__PURE__*/function () {
|
|
16
16
|
function ActiveAnchorTracker() {
|
|
17
17
|
(0, _classCallCheck2.default)(this, ActiveAnchorTracker);
|
|
@@ -67,7 +67,7 @@ var useActiveAnchorTracker = exports.useActiveAnchorTracker = function useActive
|
|
|
67
67
|
setIsActive(eventIsActive);
|
|
68
68
|
};
|
|
69
69
|
(0, _react.useEffect)(function () {
|
|
70
|
-
if (activeAnchorTracker && anchorName && (0,
|
|
70
|
+
if (activeAnchorTracker && anchorName && (0, _experiments.editorExperiment)('advanced_layouts', true)) {
|
|
71
71
|
activeAnchorTracker.subscribe(anchorName, onActive);
|
|
72
72
|
var unsubscribe = function unsubscribe() {
|
|
73
73
|
activeAnchorTracker.unsubscribe(anchorName, onActive);
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.maxLayoutColumnSupported = exports.MIN_LAYOUT_COLUMN = exports.DIRECTION = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
8
8
|
var DIRECTION = exports.DIRECTION = /*#__PURE__*/function (DIRECTION) {
|
|
9
9
|
DIRECTION["UP"] = "up";
|
|
10
10
|
DIRECTION["DOWN"] = "down";
|
|
@@ -13,6 +13,6 @@ var DIRECTION = exports.DIRECTION = /*#__PURE__*/function (DIRECTION) {
|
|
|
13
13
|
return DIRECTION;
|
|
14
14
|
}({});
|
|
15
15
|
var maxLayoutColumnSupported = exports.maxLayoutColumnSupported = function maxLayoutColumnSupported() {
|
|
16
|
-
return (0,
|
|
16
|
+
return (0, _experiments.editorExperiment)('advanced_layouts', true) ? 5 : 3;
|
|
17
17
|
};
|
|
18
18
|
var MIN_LAYOUT_COLUMN = exports.MIN_LAYOUT_COLUMN = 2;
|
|
@@ -5,23 +5,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.shouldAllowInlineDropTarget = void 0;
|
|
7
7
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
8
|
-
var
|
|
8
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
9
9
|
var _checkMediaLayout = require("./check-media-layout");
|
|
10
10
|
var _consts = require("./consts");
|
|
11
11
|
var shouldAllowInlineDropTarget = exports.shouldAllowInlineDropTarget = function shouldAllowInlineDropTarget(isNested, node) {
|
|
12
12
|
var isSameLayout = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
13
13
|
var activeNode = arguments.length > 3 ? arguments[3] : undefined;
|
|
14
|
-
if (
|
|
14
|
+
if ((0, _experiments.editorExperiment)('advanced_layouts', false) || isNested) {
|
|
15
15
|
return false;
|
|
16
16
|
}
|
|
17
17
|
if ((0, _checkMediaLayout.isWrappedMedia)(node)) {
|
|
18
18
|
return false;
|
|
19
19
|
}
|
|
20
|
-
if ((
|
|
20
|
+
if ((activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) === 'layoutSection') {
|
|
21
21
|
return false;
|
|
22
22
|
}
|
|
23
23
|
if ((node === null || node === void 0 ? void 0 : node.type.name) === 'layoutSection') {
|
|
24
|
-
return node.childCount < (0, _consts.maxLayoutColumnSupported)() ||
|
|
24
|
+
return node.childCount < (0, _consts.maxLayoutColumnSupported)() || isSameLayout;
|
|
25
25
|
}
|
|
26
26
|
return !(0, _utils.isEmptyParagraph)(node);
|
|
27
27
|
};
|
|
@@ -9,7 +9,6 @@ exports.transformSliceExpandToNestedExpand = exports.transformExpandToNestedExpa
|
|
|
9
9
|
var _memoizeOne = _interopRequireDefault(require("memoize-one"));
|
|
10
10
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
11
11
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
12
|
-
var _advancedLayoutsFlags = require("./advanced-layouts-flags");
|
|
13
12
|
var isInsideTable = exports.isInsideTable = function isInsideTable(nodeType) {
|
|
14
13
|
var _nodeType$schema$node = nodeType.schema.nodes,
|
|
15
14
|
tableCell = _nodeType$schema$node.tableCell,
|
|
@@ -81,7 +80,7 @@ function canMoveNodeToIndex(destParent, indexIntoParent, srcNode, destNode) {
|
|
|
81
80
|
var srcNodeType = srcNode.type;
|
|
82
81
|
var parentNodeType = destParent === null || destParent === void 0 ? void 0 : destParent.type.name;
|
|
83
82
|
var activeNodeType = srcNode === null || srcNode === void 0 ? void 0 : srcNode.type.name;
|
|
84
|
-
if ((0,
|
|
83
|
+
if (activeNodeType === 'layoutColumn' && (0, _experiments.editorExperiment)('advanced_layouts', true)) {
|
|
85
84
|
// Allow drag layout column and drop into layout section
|
|
86
85
|
if ((destNode === null || destNode === void 0 ? void 0 : destNode.type.name) === 'layoutSection' || parentNodeType === 'doc') {
|
|
87
86
|
return true;
|
package/dist/cjs/ui/consts.js
CHANGED
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
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_H6_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H5_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H4_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H3_TOP_ADJUSTMENT = exports.DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT = exports.DRAG_HANDLE_DEFAULT_GAP = exports.DRAG_HANDLE_BORDER_RADIUS = exports.DEFAULT_COLUMN_DISTRIBUTIONS = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
10
|
-
var
|
|
10
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
11
11
|
var _dropTargetMarginMap;
|
|
12
12
|
var DRAG_HANDLE_HEIGHT = exports.DRAG_HANDLE_HEIGHT = 24;
|
|
13
13
|
var DRAG_HANDLE_WIDTH = exports.DRAG_HANDLE_WIDTH = 12;
|
|
@@ -27,7 +27,7 @@ var dragHandleGap = exports.dragHandleGap = function dragHandleGap(nodeType, par
|
|
|
27
27
|
if (parentNodeType && parentNodeType !== 'doc') {
|
|
28
28
|
return DRAG_HANDLE_NARROW_GAP;
|
|
29
29
|
}
|
|
30
|
-
if (nodeType === 'layoutSection' && (0,
|
|
30
|
+
if (nodeType === 'layoutSection' && (0, _experiments.editorExperiment)('advanced_layouts', true)) {
|
|
31
31
|
return DRAG_HANDLE_MAX_GAP + 12;
|
|
32
32
|
}
|
|
33
33
|
if (nodeTypeExcludeList.includes(nodeType)) {
|
|
@@ -55,7 +55,7 @@ var getNestedNodeLeftPaddingMargin = exports.getNestedNodeLeftPaddingMargin = fu
|
|
|
55
55
|
}
|
|
56
56
|
};
|
|
57
57
|
var topPositionAdjustment = exports.topPositionAdjustment = function topPositionAdjustment(nodeType) {
|
|
58
|
-
if ((0,
|
|
58
|
+
if ((0, _experiments.editorExperiment)('advanced_layouts', true)) {
|
|
59
59
|
switch (nodeType) {
|
|
60
60
|
case 'rule':
|
|
61
61
|
return -DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT;
|
|
@@ -23,7 +23,6 @@ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
|
23
23
|
var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
|
|
24
24
|
var _main = require("../pm-plugins/main");
|
|
25
25
|
var _utils = require("../pm-plugins/utils");
|
|
26
|
-
var _advancedLayoutsFlags = require("../pm-plugins/utils/advanced-layouts-flags");
|
|
27
26
|
var _dragHandlePositions = require("../pm-plugins/utils/drag-handle-positions");
|
|
28
27
|
var _consts = require("./consts");
|
|
29
28
|
var _dragPreview = require("./drag-preview");
|
|
@@ -147,7 +146,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
147
146
|
// but ensures the preview is generated correctly.
|
|
148
147
|
var handleMouseDown = (0, _react.useCallback)(function () {
|
|
149
148
|
var _api$core3;
|
|
150
|
-
if (!(isLayoutColumn && (0,
|
|
149
|
+
if (!(isLayoutColumn && (0, _experiments.editorExperiment)('advanced_layouts', true)) && (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_24885')) {
|
|
151
150
|
return undefined;
|
|
152
151
|
}
|
|
153
152
|
api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(function (_ref3) {
|
|
@@ -161,7 +160,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
161
160
|
return tr;
|
|
162
161
|
}
|
|
163
162
|
var selection;
|
|
164
|
-
if (isLayoutColumn && (0,
|
|
163
|
+
if (isLayoutColumn && (0, _experiments.editorExperiment)('advanced_layouts', true)) {
|
|
165
164
|
selection = new _state.NodeSelection(tr.doc.resolve(startPos));
|
|
166
165
|
} else {
|
|
167
166
|
var $startPos = tr.doc.resolve(startPos + node.nodeSize);
|
|
@@ -294,8 +293,8 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
294
293
|
var isEdgeCase = (hasResizer || isExtension || isEmbedCard || isBlockCard) && innerContainer;
|
|
295
294
|
if (supportsAnchor) {
|
|
296
295
|
return {
|
|
297
|
-
left: isEdgeCase ? "calc(anchor(".concat(anchorName, " start) + ").concat((0, _dragHandlePositions.getLeftPosition)(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType), ")") : (0,
|
|
298
|
-
top: (0,
|
|
296
|
+
left: isEdgeCase ? "calc(anchor(".concat(anchorName, " start) + ").concat((0, _dragHandlePositions.getLeftPosition)(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType), ")") : (0, _experiments.editorExperiment)('advanced_layouts', true) && isLayoutColumn ? "calc((anchor(".concat(anchorName, " right) + anchor(").concat(anchorName, " left))/2 - ").concat(_consts.DRAG_HANDLE_HEIGHT / 2, "px)") : "calc(anchor(".concat(anchorName, " start) - ").concat(_consts.DRAG_HANDLE_WIDTH, "px - ").concat((0, _consts.dragHandleGap)(nodeType, parentNodeType), "px)"),
|
|
297
|
+
top: (0, _experiments.editorExperiment)('advanced_layouts', true) && isLayoutColumn ? "calc(anchor(".concat(anchorName, " top) - ").concat(_consts.DRAG_HANDLE_WIDTH, "px)") : (0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_ed_23674') ? "calc(anchor(".concat(anchorName, " start) + ").concat((0, _consts.topPositionAdjustment)(nodeType), "px)") : anchorName.includes('table') ? "calc(anchor(".concat(anchorName, " start) + ").concat(_consts.DRAG_HANDLE_HEIGHT, "px)") : "anchor(".concat(anchorName, " start)")
|
|
299
298
|
};
|
|
300
299
|
}
|
|
301
300
|
return {
|
|
@@ -418,7 +417,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
418
417
|
// eslint-disable-next-line @atlaskit/design-system/no-html-button
|
|
419
418
|
(0, _react2.jsx)("button", {
|
|
420
419
|
type: "button",
|
|
421
|
-
css: [dragHandleButtonStyles, (0,
|
|
420
|
+
css: [dragHandleButtonStyles, (0, _experiments.editorExperiment)('advanced_layouts', true) && isLayoutColumn && layoutColumnDragHandleStyles, dragHandleSelected && selectedStyles],
|
|
422
421
|
ref: buttonRef
|
|
423
422
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
424
423
|
,
|
|
@@ -17,7 +17,6 @@ var _constants = require("@atlaskit/theme/constants");
|
|
|
17
17
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
18
18
|
var _decorationsCommon = require("../pm-plugins/decorations-common");
|
|
19
19
|
var _activeAnchorTracker = require("../pm-plugins/utils/active-anchor-tracker");
|
|
20
|
-
var _advancedLayoutsFlags = require("../pm-plugins/utils/advanced-layouts-flags");
|
|
21
20
|
var _anchorUtils = require("../pm-plugins/utils/anchor-utils");
|
|
22
21
|
var _dragTargetDebug = require("../pm-plugins/utils/drag-target-debug");
|
|
23
22
|
var _inlineDropTarget = require("../pm-plugins/utils/inline-drop-target");
|
|
@@ -97,7 +96,7 @@ var HoverZone = function HoverZone(_ref) {
|
|
|
97
96
|
return (0, _adapter.dropTargetForElements)({
|
|
98
97
|
element: ref.current,
|
|
99
98
|
onDragEnter: function onDragEnter() {
|
|
100
|
-
if (!isNestedDropTarget && (0,
|
|
99
|
+
if (!isNestedDropTarget && (0, _experiments.editorExperiment)('advanced_layouts', true)) {
|
|
101
100
|
setActiveAnchor();
|
|
102
101
|
}
|
|
103
102
|
_onDragEnter();
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.InlineDropTarget = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
8
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
10
|
var _react = require("react");
|
|
10
11
|
var _react2 = require("@emotion/react");
|
|
@@ -14,7 +15,6 @@ var _adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
|
|
|
14
15
|
var _colors = require("@atlaskit/theme/colors");
|
|
15
16
|
var _decorationsCommon = require("../pm-plugins/decorations-common");
|
|
16
17
|
var _activeAnchorTracker = require("../pm-plugins/utils/active-anchor-tracker");
|
|
17
|
-
var _advancedLayoutsFlags = require("../pm-plugins/utils/advanced-layouts-flags");
|
|
18
18
|
var _anchorUtils = require("../pm-plugins/utils/anchor-utils");
|
|
19
19
|
var _dragTargetDebug = require("../pm-plugins/utils/drag-target-debug");
|
|
20
20
|
/* eslint-disable @atlaskit/design-system/consistent-css-prop-usage */
|
|
@@ -26,10 +26,31 @@ var _dragTargetDebug = require("../pm-plugins/utils/drag-target-debug");
|
|
|
26
26
|
|
|
27
27
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled
|
|
28
28
|
|
|
29
|
+
var HOVER_ZONE_WIDTH = '--editor-blocks-inline-hover-zone-width';
|
|
30
|
+
var HOVER_ZONE_HEIGHT = '--editor-blocks-inline-hover-zone-height';
|
|
31
|
+
var HOVER_ZONE_TOP = '--editor-blocks-inline-hover-zone-top';
|
|
32
|
+
var HOVER_ZONE_BOTTOM = '--editor-blocks-inline-hover-zone-bottom';
|
|
33
|
+
var HOVER_ZONE_ANCHOR_NAME = '--editor-blocks-inline-hover-zone-anchor-name';
|
|
29
34
|
var hoverZoneCommonStyle = (0, _react2.css)({
|
|
30
35
|
position: 'absolute',
|
|
31
36
|
// above the top and bottom drop zone as block hover zone
|
|
32
|
-
zIndex: 120
|
|
37
|
+
zIndex: 120,
|
|
38
|
+
positionAnchor: "var(".concat(HOVER_ZONE_ANCHOR_NAME, ")"),
|
|
39
|
+
minWidth: "var(--ds-space-100, 8px)",
|
|
40
|
+
left: 0,
|
|
41
|
+
right: 0,
|
|
42
|
+
width: "var(".concat(HOVER_ZONE_WIDTH, ")"),
|
|
43
|
+
height: "var(".concat(HOVER_ZONE_HEIGHT, ")")
|
|
44
|
+
});
|
|
45
|
+
var leftHoverZoneStyle = (0, _react2.css)({
|
|
46
|
+
right: "unset",
|
|
47
|
+
top: "var(".concat(HOVER_ZONE_TOP, ")"),
|
|
48
|
+
bottom: 'unset'
|
|
49
|
+
});
|
|
50
|
+
var rightHoverZoneStyle = (0, _react2.css)({
|
|
51
|
+
left: "unset",
|
|
52
|
+
top: 'unset',
|
|
53
|
+
bottom: "var(".concat(HOVER_ZONE_BOTTOM, ")")
|
|
33
54
|
});
|
|
34
55
|
|
|
35
56
|
// gap between node boundary and drop indicator/drop zone
|
|
@@ -85,7 +106,6 @@ var InlineDropTarget = exports.InlineDropTarget = function InlineDropTarget(_ref
|
|
|
85
106
|
_useActiveAnchorTrack2 = (0, _slicedToArray2.default)(_useActiveAnchorTrack, 1),
|
|
86
107
|
isActiveAnchor = _useActiveAnchorTrack2[0];
|
|
87
108
|
var isLeftPosition = position === 'left';
|
|
88
|
-
var shouldShowResponsiveLayout = (0, _advancedLayoutsFlags.showResponsiveLayout)();
|
|
89
109
|
var nodeDimension = (0, _react.useMemo)(function () {
|
|
90
110
|
if (!nextNode) {
|
|
91
111
|
return defaultNodeDimension;
|
|
@@ -126,7 +146,7 @@ var InlineDropTarget = exports.InlineDropTarget = function InlineDropTarget(_ref
|
|
|
126
146
|
|
|
127
147
|
// Set the height target anchor name to the first or last column of the layout section so that it also works for stacked layout
|
|
128
148
|
var heightTargetAnchorName = targetAnchorName;
|
|
129
|
-
if (
|
|
149
|
+
if (nextNode.type.name === 'layoutSection' && nextNode.firstChild && nextNode.lastChild) {
|
|
130
150
|
heightTargetAnchorName = isLeftPosition ? (0, _decorationsCommon.getNodeAnchor)(nextNode.firstChild) : (0, _decorationsCommon.getNodeAnchor)(nextNode.lastChild);
|
|
131
151
|
}
|
|
132
152
|
if ((0, _anchorUtils.isAnchorSupported)()) {
|
|
@@ -159,7 +179,7 @@ var InlineDropTarget = exports.InlineDropTarget = function InlineDropTarget(_ref
|
|
|
159
179
|
};
|
|
160
180
|
}
|
|
161
181
|
return defaultNodeDimension;
|
|
162
|
-
}, [anchorName, anchorRectCache, nextNode, position, isLeftPosition
|
|
182
|
+
}, [anchorName, anchorRectCache, nextNode, position, isLeftPosition]);
|
|
163
183
|
var onDrop = (0, _react.useCallback)(function () {
|
|
164
184
|
var _api$blockControls;
|
|
165
185
|
var _ref2 = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
|
|
@@ -176,27 +196,17 @@ var InlineDropTarget = exports.InlineDropTarget = function InlineDropTarget(_ref
|
|
|
176
196
|
}));
|
|
177
197
|
}
|
|
178
198
|
}, [api, getPos, position]);
|
|
179
|
-
var
|
|
199
|
+
var hoverZoneRectStyle = (0, _react.useMemo)(function () {
|
|
200
|
+
var _ref3;
|
|
180
201
|
var isLayoutNode = (nextNode === null || nextNode === void 0 ? void 0 : nextNode.type.name) === 'layoutSection';
|
|
181
|
-
var layoutAdjustment = isLayoutNode
|
|
202
|
+
var layoutAdjustment = isLayoutNode ? {
|
|
182
203
|
width: 11,
|
|
183
204
|
height: 4,
|
|
184
205
|
top: 6,
|
|
185
206
|
bottom: 2
|
|
186
207
|
} : undefined;
|
|
187
|
-
return (0,
|
|
188
|
-
|
|
189
|
-
minWidth: "var(--ds-space-100, 8px)",
|
|
190
|
-
left: isLeftPosition ? 0 : 'unset',
|
|
191
|
-
right: isLeftPosition ? 'unset' : 0,
|
|
192
|
-
top: "calc(anchor(top))",
|
|
193
|
-
width: nodeDimension.widthOffset ? "calc((100% - ".concat(nodeDimension.width, ")/2 - ").concat(GAP, "px + ").concat(nodeDimension.widthOffset, " - ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.width) || 0, "px)") : "calc((100% - ".concat(nodeDimension.width, ")/2 - ").concat(GAP, "px - ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.width) || 0, "px)"),
|
|
194
|
-
height: "calc(".concat(nodeDimension.height, " + ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.height) || 0, "px)")
|
|
195
|
-
}, isLayoutNode && shouldShowResponsiveLayout && {
|
|
196
|
-
top: isLeftPosition ? "calc(".concat(nodeDimension.top, " + ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.top) || 0, "px)") : 'unset',
|
|
197
|
-
bottom: isLeftPosition ? 'unset' : "calc(".concat(nodeDimension.bottom, " - ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.bottom) || 0, "px)")
|
|
198
|
-
});
|
|
199
|
-
}, [anchorName, isLeftPosition, nodeDimension, nextNode, shouldShowResponsiveLayout]);
|
|
208
|
+
return _ref3 = {}, (0, _defineProperty2.default)(_ref3, HOVER_ZONE_WIDTH, nodeDimension.widthOffset ? "calc((100% - ".concat(nodeDimension.width, ")/2 - ").concat(GAP, "px + ").concat(nodeDimension.widthOffset, " - ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.width) || 0, "px)") : "calc((100% - ".concat(nodeDimension.width, ")/2 - ").concat(GAP, "px - ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.width) || 0, "px)")), (0, _defineProperty2.default)(_ref3, HOVER_ZONE_HEIGHT, "calc(".concat(nodeDimension.height, " + ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.height) || 0, "px)")), (0, _defineProperty2.default)(_ref3, HOVER_ZONE_TOP, "calc(".concat(nodeDimension.top, " + ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.top) || 0, "px)")), (0, _defineProperty2.default)(_ref3, HOVER_ZONE_BOTTOM, "calc(".concat(nodeDimension.bottom, " - ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.bottom) || 0, "px)")), (0, _defineProperty2.default)(_ref3, HOVER_ZONE_ANCHOR_NAME, anchorName), _ref3;
|
|
209
|
+
}, [nextNode === null || nextNode === void 0 ? void 0 : nextNode.type.name, nodeDimension, anchorName]);
|
|
200
210
|
var dropIndicatorPos = (0, _react.useMemo)(function () {
|
|
201
211
|
return isLeftPosition ? 'right' : 'left';
|
|
202
212
|
}, [isLeftPosition]);
|
|
@@ -217,7 +227,10 @@ var InlineDropTarget = exports.InlineDropTarget = function InlineDropTarget(_ref
|
|
|
217
227
|
return (0, _react2.jsx)("div", {
|
|
218
228
|
ref: ref,
|
|
219
229
|
"data-testid": "drop-target-hover-zone-".concat(position),
|
|
220
|
-
css: [hoverZoneCommonStyle,
|
|
230
|
+
css: [hoverZoneCommonStyle, isLeftPosition ? leftHoverZoneStyle : rightHoverZoneStyle]
|
|
231
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
232
|
+
,
|
|
233
|
+
style: hoverZoneRectStyle
|
|
221
234
|
}, isDraggedOver || (0, _dragTargetDebug.isBlocksDragTargetDebug)() ? (0, _react2.jsx)(_box.DropIndicator, {
|
|
222
235
|
edge: dropIndicatorPos
|
|
223
236
|
}) : isActiveAnchor && (0, _react2.jsx)("div", {
|
|
@@ -2,7 +2,6 @@ import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
|
2
2
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
3
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
4
4
|
import { getNestedDepth, getNodeAnchor, TYPE_NODE_DEC } from './decorations-common';
|
|
5
|
-
import { isPreRelease1, isPreRelease2 } from './utils/advanced-layouts-flags';
|
|
6
5
|
const IGNORE_NODES = ['tableCell', 'tableHeader', 'tableRow', 'listItem', 'caption', 'layoutColumn'];
|
|
7
6
|
const IGNORE_NODES_NEXT = ['tableCell', 'tableHeader', 'tableRow', 'listItem', 'caption'];
|
|
8
7
|
const IGNORE_NODE_DESCENDANTS = ['listItem', 'taskList', 'decisionList', 'mediaSingle'];
|
|
@@ -15,7 +14,7 @@ export const shouldDescendIntoNode = node => {
|
|
|
15
14
|
return false;
|
|
16
15
|
}
|
|
17
16
|
}
|
|
18
|
-
if (
|
|
17
|
+
if (editorExperiment('advanced_layouts', true)) {
|
|
19
18
|
return !IGNORE_NODE_DESCENDANTS_ADVANCED_LAYOUT.includes(node.type.name);
|
|
20
19
|
}
|
|
21
20
|
return !IGNORE_NODE_DESCENDANTS.includes(node.type.name);
|
|
@@ -25,7 +24,7 @@ const shouldIgnoreNode = (node, ignore_nodes, depth, parent) => {
|
|
|
25
24
|
|
|
26
25
|
// TODO use isWrappedMedia when clean up the feature flag
|
|
27
26
|
const isMediaSingle = 'mediaSingle' === node.type.name && fg('platform_editor_element_dnd_nested_fix_patch_1');
|
|
28
|
-
const isFirstTableRow = (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'table' && depth === 1 && node === parent.firstChild && 'tableRow' === node.type.name &&
|
|
27
|
+
const isFirstTableRow = (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'table' && depth === 1 && node === parent.firstChild && 'tableRow' === node.type.name && editorExperiment('advanced_layouts', true);
|
|
29
28
|
if (isFirstTableRow) {
|
|
30
29
|
return false;
|
|
31
30
|
}
|
|
@@ -63,7 +62,7 @@ export const nodeDecorations = (newState, from, to) => {
|
|
|
63
62
|
const decs = [];
|
|
64
63
|
const docFrom = from === undefined || from < 0 ? 0 : from;
|
|
65
64
|
const docTo = to === undefined || to > newState.doc.nodeSize - 2 ? newState.doc.nodeSize - 2 : to;
|
|
66
|
-
const ignore_nodes =
|
|
65
|
+
const ignore_nodes = editorExperiment('advanced_layouts', true) ? IGNORE_NODES_NEXT : IGNORE_NODES;
|
|
67
66
|
newState.doc.nodesBetween(docFrom, docTo, (node, pos, parent, index) => {
|
|
68
67
|
let depth = 0;
|
|
69
68
|
let anchorName;
|
|
@@ -10,7 +10,6 @@ import { DropTarget } from '../ui/drop-target';
|
|
|
10
10
|
import { DropTargetLayout } from '../ui/drop-target-layout';
|
|
11
11
|
import { DropTargetV2, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_GAP, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_OFFSET } from '../ui/drop-target-v2';
|
|
12
12
|
import { getNestedDepth, TYPE_DROP_TARGET_DEC, unmountDecorations } from './decorations-common';
|
|
13
|
-
import { isPreRelease2 } from './utils/advanced-layouts-flags';
|
|
14
13
|
import { maxLayoutColumnSupported } from './utils/consts';
|
|
15
14
|
import { isBlocksDragTargetDebug } from './utils/drag-target-debug';
|
|
16
15
|
import { canMoveNodeToIndex, isInSameLayout } from './utils/validation';
|
|
@@ -175,7 +174,7 @@ export const dropTargetDecorations = (newState, api, formatMessage, nodeViewPort
|
|
|
175
174
|
popNodeStack(depth);
|
|
176
175
|
prevNodeStack.push(node);
|
|
177
176
|
};
|
|
178
|
-
const isAdvancedLayoutsPreRelease2 =
|
|
177
|
+
const isAdvancedLayoutsPreRelease2 = editorExperiment('advanced_layouts', true);
|
|
179
178
|
newState.doc.nodesBetween(docFrom, docTo, (node, pos, parent, index) => {
|
|
180
179
|
let depth = 0;
|
|
181
180
|
// drop target deco at the end position
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
2
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
3
|
-
import { isPreRelease1, isPreRelease2 } from './utils/advanced-layouts-flags';
|
|
4
3
|
const isEmptyNestedParagraphOrHeading = target => {
|
|
5
4
|
if (target instanceof HTMLHeadingElement || target instanceof HTMLParagraphElement) {
|
|
6
5
|
var _target$parentElement;
|
|
@@ -8,26 +7,6 @@ const isEmptyNestedParagraphOrHeading = target => {
|
|
|
8
7
|
}
|
|
9
8
|
return false;
|
|
10
9
|
};
|
|
11
|
-
const isEmptyParagraphOrPlaceholder = node => {
|
|
12
|
-
if (node && node.type.name === 'paragraph') {
|
|
13
|
-
var _node$firstChild;
|
|
14
|
-
return node.childCount === 0 || node.childCount === 1 && ((_node$firstChild = node.firstChild) === null || _node$firstChild === void 0 ? void 0 : _node$firstChild.type.name) === 'placeholder';
|
|
15
|
-
}
|
|
16
|
-
return false;
|
|
17
|
-
};
|
|
18
|
-
const isLayoutColumnWithoutContent = node => {
|
|
19
|
-
if ((node === null || node === void 0 ? void 0 : node.type.name) === 'layoutColumn') {
|
|
20
|
-
let foundNonEmptyNode = false;
|
|
21
|
-
for (let i = 0; i < node.childCount; i++) {
|
|
22
|
-
const child = node.child(i);
|
|
23
|
-
if (!isEmptyParagraphOrPlaceholder(child)) {
|
|
24
|
-
foundNonEmptyNode = true;
|
|
25
|
-
break;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return !foundNonEmptyNode;
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
10
|
export const handleMouseOver = (view, event, api) => {
|
|
32
11
|
var _api$blockControls, _target$classList;
|
|
33
12
|
const {
|
|
@@ -51,7 +30,7 @@ export const handleMouseOver = (view, event, api) => {
|
|
|
51
30
|
if (editorExperiment('nested-dnd', true) && isEmptyNestedParagraphOrHeading(rootElement)) {
|
|
52
31
|
return false;
|
|
53
32
|
}
|
|
54
|
-
if (rootElement.getAttribute('data-drag-handler-node-type') === 'media' &&
|
|
33
|
+
if (rootElement.getAttribute('data-drag-handler-node-type') === 'media' && editorExperiment('advanced_layouts', true)) {
|
|
55
34
|
rootElement = rootElement.closest('[data-drag-handler-anchor-name][data-drag-handler-node-type="mediaSingle"]');
|
|
56
35
|
if (!rootElement) {
|
|
57
36
|
return false;
|
|
@@ -94,11 +73,6 @@ export const handleMouseOver = (view, event, api) => {
|
|
|
94
73
|
} else {
|
|
95
74
|
pos = view.posAtDOM(rootElement, 0);
|
|
96
75
|
}
|
|
97
|
-
const node = view.state.doc.nodeAt(pos);
|
|
98
|
-
if (isPreRelease2() && node && isLayoutColumnWithoutContent(node)) {
|
|
99
|
-
// Don't show drag handle when there is no content/only placeholder in layout column
|
|
100
|
-
return false;
|
|
101
|
-
}
|
|
102
76
|
let rootPos;
|
|
103
77
|
if (editorExperiment('nested-dnd', true)) {
|
|
104
78
|
rootPos = view.state.doc.resolve(pos).pos;
|
|
@@ -17,7 +17,6 @@ import { dropTargetDecorations, findDropTargetDecs } from './decorations-drop-ta
|
|
|
17
17
|
import { handleMouseOver } from './handle-mouse-over';
|
|
18
18
|
import { boundKeydownHandler } from './keymap';
|
|
19
19
|
import { defaultActiveAnchorTracker } from './utils/active-anchor-tracker';
|
|
20
|
-
import { isPreRelease2 } from './utils/advanced-layouts-flags';
|
|
21
20
|
import { AnchorRectCache, isAnchorSupported } from './utils/anchor-utils';
|
|
22
21
|
import { isBlocksDragTargetDebug } from './utils/drag-target-debug';
|
|
23
22
|
import { getTrMetadata } from './utils/transactions';
|
|
@@ -479,7 +478,7 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI) => {
|
|
|
479
478
|
return false;
|
|
480
479
|
},
|
|
481
480
|
dragenter(_view, event) {
|
|
482
|
-
if (
|
|
481
|
+
if (editorExperiment('advanced_layouts', true)) {
|
|
483
482
|
if (isHTMLElement(event.target)) {
|
|
484
483
|
const closestParentElement = event.target.closest('[data-drag-handler-anchor-depth="0"]');
|
|
485
484
|
if (closestParentElement) {
|
|
@@ -493,7 +492,7 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI) => {
|
|
|
493
492
|
},
|
|
494
493
|
dragstart(view) {
|
|
495
494
|
var _anchorRectCache;
|
|
496
|
-
if (
|
|
495
|
+
if (editorExperiment('advanced_layouts', true)) {
|
|
497
496
|
defaultActiveAnchorTracker.reset();
|
|
498
497
|
}
|
|
499
498
|
(_anchorRectCache = anchorRectCache) === null || _anchorRectCache === void 0 ? void 0 : _anchorRectCache.setEditorView(view);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
3
|
import { useCallback, useEffect, useState } from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
5
5
|
export class ActiveAnchorTracker {
|
|
6
6
|
constructor() {
|
|
7
7
|
_defineProperty(this, "lastActiveAnchor", '');
|
|
@@ -44,7 +44,7 @@ export const useActiveAnchorTracker = (anchorName, activeAnchorTracker = default
|
|
|
44
44
|
setIsActive(eventIsActive);
|
|
45
45
|
};
|
|
46
46
|
useEffect(() => {
|
|
47
|
-
if (activeAnchorTracker && anchorName &&
|
|
47
|
+
if (activeAnchorTracker && anchorName && editorExperiment('advanced_layouts', true)) {
|
|
48
48
|
activeAnchorTracker.subscribe(anchorName, onActive);
|
|
49
49
|
const unsubscribe = () => {
|
|
50
50
|
activeAnchorTracker.unsubscribe(anchorName, onActive);
|