@atlaskit/editor-plugin-block-controls 2.6.3 → 2.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/dist/cjs/commands/move-to-layout.js +76 -0
- package/dist/cjs/consts.js +3 -2
- package/dist/cjs/plugin.js +2 -0
- package/dist/cjs/pm-plugins/decorations.js +7 -7
- package/dist/cjs/pm-plugins/main.js +10 -10
- package/dist/cjs/ui/consts.js +8 -1
- package/dist/cjs/ui/drop-target-v2.js +24 -17
- package/dist/cjs/ui/inline-drop-target.js +153 -0
- package/dist/cjs/utils/advanced-layouts-flags.js +16 -0
- package/dist/cjs/utils/anchor-utils.js +71 -15
- package/dist/cjs/utils/inline-drop-target.js +18 -0
- package/dist/es2019/commands/move-to-layout.js +69 -0
- package/dist/es2019/consts.js +2 -1
- package/dist/es2019/plugin.js +2 -0
- package/dist/es2019/pm-plugins/decorations.js +7 -7
- package/dist/es2019/pm-plugins/main.js +11 -11
- package/dist/es2019/ui/consts.js +7 -0
- package/dist/es2019/ui/drop-target-v2.js +24 -16
- package/dist/es2019/ui/inline-drop-target.js +148 -0
- package/dist/es2019/utils/advanced-layouts-flags.js +11 -0
- package/dist/es2019/utils/anchor-utils.js +55 -9
- package/dist/es2019/utils/inline-drop-target.js +12 -0
- package/dist/esm/commands/move-to-layout.js +70 -0
- package/dist/esm/consts.js +2 -1
- package/dist/esm/plugin.js +2 -0
- package/dist/esm/pm-plugins/decorations.js +7 -7
- package/dist/esm/pm-plugins/main.js +11 -11
- package/dist/esm/ui/consts.js +7 -0
- package/dist/esm/ui/drop-target-v2.js +24 -17
- package/dist/esm/ui/inline-drop-target.js +145 -0
- package/dist/esm/utils/advanced-layouts-flags.js +11 -0
- package/dist/esm/utils/anchor-utils.js +70 -14
- package/dist/esm/utils/inline-drop-target.js +12 -0
- package/dist/types/commands/move-to-layout.d.ts +3 -0
- package/dist/types/consts.d.ts +1 -0
- package/dist/types/pm-plugins/decorations.d.ts +3 -3
- package/dist/types/pm-plugins/main.d.ts +3 -3
- package/dist/types/types.d.ts +1 -0
- package/dist/types/ui/consts.d.ts +3 -0
- package/dist/types/ui/drop-target-v2.d.ts +3 -3
- package/dist/types/ui/inline-drop-target.d.ts +20 -0
- package/dist/types/utils/advanced-layouts-flags.d.ts +2 -0
- package/dist/types/utils/anchor-utils.d.ts +16 -3
- package/dist/types/utils/inline-drop-target.d.ts +2 -0
- package/dist/types-ts4.5/commands/move-to-layout.d.ts +3 -0
- package/dist/types-ts4.5/consts.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/decorations.d.ts +3 -3
- package/dist/types-ts4.5/pm-plugins/main.d.ts +3 -3
- package/dist/types-ts4.5/types.d.ts +1 -0
- package/dist/types-ts4.5/ui/consts.d.ts +3 -0
- package/dist/types-ts4.5/ui/drop-target-v2.d.ts +3 -3
- package/dist/types-ts4.5/ui/inline-drop-target.d.ts +20 -0
- package/dist/types-ts4.5/utils/advanced-layouts-flags.d.ts +2 -0
- package/dist/types-ts4.5/utils/anchor-utils.d.ts +16 -3
- package/dist/types-ts4.5/utils/inline-drop-target.d.ts +2 -0
- package/package.json +8 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 2.7.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#153381](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/153381)
|
|
8
|
+
[`47cf4f0676e5a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/47cf4f0676e5a) -
|
|
9
|
+
ED-25040 setup feature flags and hooked up pre release-1
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 2.7.0
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- [#151244](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/151244)
|
|
17
|
+
[`10ba5860e515c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/10ba5860e515c) -
|
|
18
|
+
ED-25281 Implement DnD API for Advanced Layout
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- [#153270](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/153270)
|
|
23
|
+
[`311428de27cbc`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/311428de27cbc) -
|
|
24
|
+
[ux] [ED-25068] Implement inline drop zone and drop target (edge case excluded) behind FG
|
|
25
|
+
|
|
3
26
|
## 2.6.3
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.moveToLayout = void 0;
|
|
7
|
+
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
8
|
+
var _consts = require("../ui/consts");
|
|
9
|
+
var createNewLayout = function createNewLayout(schema, layoutContents) {
|
|
10
|
+
// TODO update with constant
|
|
11
|
+
if (layoutContents.length === 0 || layoutContents.length > 5) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
var width = _consts.DEFAULT_COLUMN_DISTRIBUTIONS[layoutContents.length];
|
|
15
|
+
if (!width) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
var _ref = schema.nodes || {},
|
|
19
|
+
layoutSection = _ref.layoutSection,
|
|
20
|
+
layoutColumn = _ref.layoutColumn;
|
|
21
|
+
try {
|
|
22
|
+
var layoutSectionNode = layoutSection.createChecked(undefined, _model.Fragment.fromArray(layoutContents.map(function (layoutContent) {
|
|
23
|
+
return layoutColumn.createChecked({
|
|
24
|
+
width: width
|
|
25
|
+
}, layoutContent);
|
|
26
|
+
})));
|
|
27
|
+
return layoutSectionNode;
|
|
28
|
+
} catch (error) {
|
|
29
|
+
// TODO analytics
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
};
|
|
33
|
+
var moveToLayout = exports.moveToLayout = function moveToLayout(api) {
|
|
34
|
+
return function (from, to, position) {
|
|
35
|
+
return function (_ref2) {
|
|
36
|
+
var tr = _ref2.tr;
|
|
37
|
+
var _ref3 = tr.doc.type.schema.nodes || {},
|
|
38
|
+
layoutSection = _ref3.layoutSection,
|
|
39
|
+
layoutColumn = _ref3.layoutColumn,
|
|
40
|
+
doc = _ref3.doc;
|
|
41
|
+
|
|
42
|
+
// layout plugin does not exist
|
|
43
|
+
if (!layoutSection || !layoutColumn) {
|
|
44
|
+
return tr;
|
|
45
|
+
}
|
|
46
|
+
var $to = tr.doc.resolve(to);
|
|
47
|
+
|
|
48
|
+
// invalid to position or not top level.
|
|
49
|
+
if (!$to.nodeAfter || $to.parent.type !== doc) {
|
|
50
|
+
return tr;
|
|
51
|
+
}
|
|
52
|
+
var $from = tr.doc.resolve(from);
|
|
53
|
+
|
|
54
|
+
// invalid from position
|
|
55
|
+
if (!$from.nodeAfter) {
|
|
56
|
+
return tr;
|
|
57
|
+
}
|
|
58
|
+
var toNode = $to.nodeAfter;
|
|
59
|
+
var fromNode = $from.nodeAfter;
|
|
60
|
+
var fromNodeEndPos = from + fromNode.nodeSize;
|
|
61
|
+
var toNodeEndPos = to + toNode.nodeSize;
|
|
62
|
+
if ($to.nodeAfter.type !== layoutSection) {
|
|
63
|
+
var layoutContents = position === 'left' ? [fromNode, toNode] : [toNode, fromNode];
|
|
64
|
+
var newLayout = createNewLayout(tr.doc.type.schema, layoutContents);
|
|
65
|
+
if (newLayout) {
|
|
66
|
+
tr.delete(from, fromNodeEndPos);
|
|
67
|
+
var mappedTo = tr.mapping.map(to);
|
|
68
|
+
tr.delete(mappedTo, toNodeEndPos);
|
|
69
|
+
tr.insert(mappedTo, newLayout); // insert the content at the new position
|
|
70
|
+
}
|
|
71
|
+
return tr;
|
|
72
|
+
}
|
|
73
|
+
return tr;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
};
|
package/dist/cjs/consts.js
CHANGED
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.DIRECTION = void 0;
|
|
6
|
+
exports.MAX_LAYOUT_COLUMN_SUPPORTED = exports.DIRECTION = void 0;
|
|
7
7
|
var DIRECTION = exports.DIRECTION = /*#__PURE__*/function (DIRECTION) {
|
|
8
8
|
DIRECTION["UP"] = "up";
|
|
9
9
|
DIRECTION["DOWN"] = "down";
|
|
10
10
|
DIRECTION["LEFT"] = "left";
|
|
11
11
|
DIRECTION["RIGHT"] = "right";
|
|
12
12
|
return DIRECTION;
|
|
13
|
-
}({});
|
|
13
|
+
}({});
|
|
14
|
+
var MAX_LAYOUT_COLUMN_SUPPORTED = exports.MAX_LAYOUT_COLUMN_SUPPORTED = 3;
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -10,6 +10,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
10
10
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
11
11
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
12
12
|
var _moveNode = require("./commands/move-node");
|
|
13
|
+
var _moveToLayout = require("./commands/move-to-layout");
|
|
13
14
|
var _emptyBlockExperiment = require("./pm-plugins/empty-block-experiment");
|
|
14
15
|
var _main = require("./pm-plugins/main");
|
|
15
16
|
var _dragHandleMenu = require("./ui/drag-handle-menu");
|
|
@@ -38,6 +39,7 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
|
|
|
38
39
|
},
|
|
39
40
|
commands: {
|
|
40
41
|
moveNode: (0, _moveNode.moveNode)(api),
|
|
42
|
+
moveToLayout: (0, _moveToLayout.moveToLayout)(api),
|
|
41
43
|
showDragHandleAt: function showDragHandleAt(pos, anchorName, nodeType, handleOptions) {
|
|
42
44
|
return function (_ref4) {
|
|
43
45
|
var tr = _ref4.tr;
|
|
@@ -129,7 +129,7 @@ var findNodeDecs = exports.findNodeDecs = function findNodeDecs(decorations, fro
|
|
|
129
129
|
return spec.type === TYPE_NODE_DEC;
|
|
130
130
|
});
|
|
131
131
|
};
|
|
132
|
-
var createDropTargetDecoration = exports.createDropTargetDecoration = function createDropTargetDecoration(pos, props, side,
|
|
132
|
+
var createDropTargetDecoration = exports.createDropTargetDecoration = function createDropTargetDecoration(pos, props, side, anchorRectCache) {
|
|
133
133
|
return _view.Decoration.widget(pos, function (_, getPos) {
|
|
134
134
|
var element = document.createElement('div');
|
|
135
135
|
element.setAttribute('data-blocks-drop-target-container', 'true');
|
|
@@ -144,7 +144,7 @@ var createDropTargetDecoration = exports.createDropTargetDecoration = function c
|
|
|
144
144
|
if ((0, _platformFeatureFlags.fg)('platform_editor_drag_and_drop_target_v2')) {
|
|
145
145
|
_reactDom.default.render( /*#__PURE__*/(0, _react.createElement)(_dropTargetV.DropTargetV2, _objectSpread(_objectSpread({}, props), {}, {
|
|
146
146
|
getPos: getPos,
|
|
147
|
-
|
|
147
|
+
anchorRectCache: anchorRectCache
|
|
148
148
|
})), element);
|
|
149
149
|
} else {
|
|
150
150
|
_reactDom.default.render( /*#__PURE__*/(0, _react.createElement)(_dropTarget.DropTarget, _objectSpread(_objectSpread({}, props), {}, {
|
|
@@ -157,7 +157,7 @@ var createDropTargetDecoration = exports.createDropTargetDecoration = function c
|
|
|
157
157
|
side: side
|
|
158
158
|
});
|
|
159
159
|
};
|
|
160
|
-
var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetDecorations(newState, api, formatMessage, activeNode,
|
|
160
|
+
var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetDecorations(newState, api, formatMessage, activeNode, anchorRectCache, from, to) {
|
|
161
161
|
unmountDecorations('data-blocks-drop-target-container');
|
|
162
162
|
var decs = [];
|
|
163
163
|
var POS_END_OF_DOC = newState.doc.nodeSize - 2;
|
|
@@ -166,7 +166,7 @@ var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetD
|
|
|
166
166
|
var prevNode;
|
|
167
167
|
var activeNodePos = activeNode === null || activeNode === void 0 ? void 0 : activeNode.pos;
|
|
168
168
|
var activePMNode = typeof activeNodePos === 'number' && newState.doc.resolve(activeNodePos).nodeAfter;
|
|
169
|
-
|
|
169
|
+
anchorRectCache === null || anchorRectCache === void 0 || anchorRectCache.clear();
|
|
170
170
|
var prevNodeStack = [];
|
|
171
171
|
var popNodeStack = function popNodeStack(depth) {
|
|
172
172
|
var result;
|
|
@@ -231,7 +231,7 @@ var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetD
|
|
|
231
231
|
parentNode: parent || undefined,
|
|
232
232
|
formatMessage: formatMessage,
|
|
233
233
|
dropTargetStyle: shouldShowFullHeight ? 'fullHeight' : 'default'
|
|
234
|
-
}, -1,
|
|
234
|
+
}, -1, anchorRectCache));
|
|
235
235
|
if (endPos !== undefined) {
|
|
236
236
|
decs.push(createDropTargetDecoration(endPos, {
|
|
237
237
|
api: api,
|
|
@@ -239,7 +239,7 @@ var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetD
|
|
|
239
239
|
parentNode: parent || undefined,
|
|
240
240
|
formatMessage: formatMessage,
|
|
241
241
|
dropTargetStyle: isInSupportedContainer ? 'fullHeight' : 'default'
|
|
242
|
-
}, -1,
|
|
242
|
+
}, -1, anchorRectCache));
|
|
243
243
|
}
|
|
244
244
|
if ((0, _platformFeatureFlags.fg)('platform_editor_drag_and_drop_target_v2')) {
|
|
245
245
|
pushNodeStack(node, depth);
|
|
@@ -254,7 +254,7 @@ var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetD
|
|
|
254
254
|
formatMessage: formatMessage,
|
|
255
255
|
prevNode: newState.doc.lastChild || undefined,
|
|
256
256
|
parentNode: newState.doc
|
|
257
|
-
}, undefined,
|
|
257
|
+
}, undefined, anchorRectCache));
|
|
258
258
|
}
|
|
259
259
|
return decs;
|
|
260
260
|
};
|
|
@@ -95,7 +95,7 @@ var initialState = {
|
|
|
95
95
|
isDocSizeLimitEnabled: null,
|
|
96
96
|
isPMDragging: false
|
|
97
97
|
};
|
|
98
|
-
var newApply = exports.newApply = function newApply(api, formatMessage, tr, currentState, newState, flags,
|
|
98
|
+
var newApply = exports.newApply = function newApply(api, formatMessage, tr, currentState, newState, flags, anchorRectCache) {
|
|
99
99
|
var _meta$activeNode, _activeNode, _activeNode2, _meta$activeNode$hand, _meta$isDragging, _meta$isDragging2, _meta$editorHeight, _meta$editorWidthLeft, _meta$editorWidthRigh, _meta$isPMDragging;
|
|
100
100
|
var activeNode = currentState.activeNode,
|
|
101
101
|
decorations = currentState.decorations,
|
|
@@ -201,7 +201,7 @@ var newApply = exports.newApply = function newApply(api, formatMessage, tr, curr
|
|
|
201
201
|
// Add drop targets when dragging starts or some are missing
|
|
202
202
|
if (api) {
|
|
203
203
|
if (meta !== null && meta !== void 0 && meta.isDragging || isDropTargetsMissing || (0, _dragTargetDebug.isBlocksDragTargetDebug)()) {
|
|
204
|
-
var decs = (0, _decorations.dropTargetDecorations)(newState, api, formatMessage, latestActiveNode,
|
|
204
|
+
var decs = (0, _decorations.dropTargetDecorations)(newState, api, formatMessage, latestActiveNode, anchorRectCache);
|
|
205
205
|
decorations = decorations.add(newState.doc, decs);
|
|
206
206
|
}
|
|
207
207
|
}
|
|
@@ -226,7 +226,7 @@ var newApply = exports.newApply = function newApply(api, formatMessage, tr, curr
|
|
|
226
226
|
isPMDragging: (_meta$isPMDragging = meta === null || meta === void 0 ? void 0 : meta.isPMDragging) !== null && _meta$isPMDragging !== void 0 ? _meta$isPMDragging : isPMDragging
|
|
227
227
|
};
|
|
228
228
|
};
|
|
229
|
-
var oldApply = exports.oldApply = function oldApply(api, formatMessage, tr, currentState, oldState, newState, flags,
|
|
229
|
+
var oldApply = exports.oldApply = function oldApply(api, formatMessage, tr, currentState, oldState, newState, flags, anchorRectCache) {
|
|
230
230
|
var _meta$activeNode2, _meta$activeNode$hand2, _activeNodeWithNewNod, _meta$activeNode8, _meta$isDragging4, _meta$editorHeight2, _meta$editorWidthLeft2, _meta$editorWidthRigh2, _meta$isPMDragging2;
|
|
231
231
|
var isNestedEnabled = flags.isNestedEnabled;
|
|
232
232
|
var activeNode = currentState.activeNode,
|
|
@@ -389,7 +389,7 @@ var oldApply = exports.oldApply = function oldApply(api, formatMessage, tr, curr
|
|
|
389
389
|
// if the transaction is only for analytics and user is dragging, continue to draw drop targets
|
|
390
390
|
if (shouldCreateDropTargets || (0, _dragTargetDebug.isBlocksDragTargetDebug)()) {
|
|
391
391
|
var _meta$activeNode7;
|
|
392
|
-
var _decs2 = (0, _decorations.dropTargetDecorations)(newState, api, formatMessage, isNestedEnabled ? (_meta$activeNode7 = meta === null || meta === void 0 ? void 0 : meta.activeNode) !== null && _meta$activeNode7 !== void 0 ? _meta$activeNode7 : mappedActiveNodePos : meta === null || meta === void 0 ? void 0 : meta.activeNode,
|
|
392
|
+
var _decs2 = (0, _decorations.dropTargetDecorations)(newState, api, formatMessage, isNestedEnabled ? (_meta$activeNode7 = meta === null || meta === void 0 ? void 0 : meta.activeNode) !== null && _meta$activeNode7 !== void 0 ? _meta$activeNode7 : mappedActiveNodePos : meta === null || meta === void 0 ? void 0 : meta.activeNode, anchorRectCache);
|
|
393
393
|
decorations = decorations.add(newState.doc, _decs2);
|
|
394
394
|
}
|
|
395
395
|
}
|
|
@@ -434,9 +434,9 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl) {
|
|
|
434
434
|
if ((0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_fix_patch_2')) {
|
|
435
435
|
// TODO: Remove this once FG is used in code
|
|
436
436
|
}
|
|
437
|
-
var
|
|
437
|
+
var anchorRectCache;
|
|
438
438
|
if (!(0, _anchorUtils.isAnchorSupported)() && (0, _platformFeatureFlags.fg)('platform_editor_drag_and_drop_target_v2')) {
|
|
439
|
-
|
|
439
|
+
anchorRectCache = new _anchorUtils.AnchorRectCache();
|
|
440
440
|
}
|
|
441
441
|
return new _safePlugin.SafePlugin({
|
|
442
442
|
key: key,
|
|
@@ -446,9 +446,9 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl) {
|
|
|
446
446
|
},
|
|
447
447
|
apply: function apply(tr, currentState, oldState, newState) {
|
|
448
448
|
if (isOptimisedApply) {
|
|
449
|
-
return newApply(api, formatMessage, tr, currentState, newState, flags,
|
|
449
|
+
return newApply(api, formatMessage, tr, currentState, newState, flags, anchorRectCache);
|
|
450
450
|
}
|
|
451
|
-
return oldApply(api, formatMessage, tr, currentState, oldState, newState, flags,
|
|
451
|
+
return oldApply(api, formatMessage, tr, currentState, oldState, newState, flags, anchorRectCache);
|
|
452
452
|
}
|
|
453
453
|
},
|
|
454
454
|
props: {
|
|
@@ -498,8 +498,8 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl) {
|
|
|
498
498
|
return false;
|
|
499
499
|
},
|
|
500
500
|
dragstart: function dragstart(view) {
|
|
501
|
-
var
|
|
502
|
-
(
|
|
501
|
+
var _anchorRectCache;
|
|
502
|
+
(_anchorRectCache = anchorRectCache) === null || _anchorRectCache === void 0 || _anchorRectCache.setEditorView(view);
|
|
503
503
|
view.dispatch(view.state.tr.setMeta(key, {
|
|
504
504
|
isPMDragging: true
|
|
505
505
|
}));
|
package/dist/cjs/ui/consts.js
CHANGED
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.topPositionAdjustment = exports.spaceLookupMap = exports.nodeMargins = exports.getNestedNodeLeftPaddingMargin = exports.dropTargetMarginMap = exports.dragHandleGap = exports.DRAG_HANDLE_ZINDEX = exports.DRAG_HANDLE_WIDTH = exports.DRAG_HANDLE_NARROW_GAP = exports.DRAG_HANDLE_MAX_WIDTH_PLUS_GAP = exports.DRAG_HANDLE_MAX_GAP = exports.DRAG_HANDLE_HEIGHT = exports.DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT = exports.DRAG_HANDLE_DEFAULT_GAP = exports.DRAG_HANDLE_BORDER_RADIUS = void 0;
|
|
7
|
+
exports.topPositionAdjustment = exports.spaceLookupMap = exports.nodeMargins = exports.getNestedNodeLeftPaddingMargin = exports.dropTargetMarginMap = exports.dragHandleGap = exports.DRAG_HANDLE_ZINDEX = exports.DRAG_HANDLE_WIDTH = exports.DRAG_HANDLE_NARROW_GAP = exports.DRAG_HANDLE_MAX_WIDTH_PLUS_GAP = exports.DRAG_HANDLE_MAX_GAP = exports.DRAG_HANDLE_HEIGHT = exports.DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT = exports.DRAG_HANDLE_DEFAULT_GAP = exports.DRAG_HANDLE_BORDER_RADIUS = 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
10
|
var _dropTargetMarginMap;
|
|
@@ -166,4 +166,11 @@ var nodeMargins = exports.nodeMargins = {
|
|
|
166
166
|
top: 0,
|
|
167
167
|
bottom: 0
|
|
168
168
|
}
|
|
169
|
+
};
|
|
170
|
+
var DEFAULT_COLUMN_DISTRIBUTIONS = exports.DEFAULT_COLUMN_DISTRIBUTIONS = {
|
|
171
|
+
1: 100,
|
|
172
|
+
2: 50,
|
|
173
|
+
3: 33.33,
|
|
174
|
+
4: 25,
|
|
175
|
+
5: 20
|
|
169
176
|
};
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_OFFSET = exports.EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_GAP = exports.DropTargetV2 = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
8
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
11
|
var _react = require("react");
|
|
@@ -17,7 +18,9 @@ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
|
17
18
|
var _decorations = require("../pm-plugins/decorations");
|
|
18
19
|
var _anchorUtils = require("../utils/anchor-utils");
|
|
19
20
|
var _dragTargetDebug = require("../utils/drag-target-debug");
|
|
21
|
+
var _inlineDropTarget = require("../utils/inline-drop-target");
|
|
20
22
|
var _consts = require("./consts");
|
|
23
|
+
var _inlineDropTarget2 = require("./inline-drop-target");
|
|
21
24
|
/**
|
|
22
25
|
* @jsxRuntime classic
|
|
23
26
|
* @jsx jsx
|
|
@@ -80,7 +83,7 @@ var HoverZone = function HoverZone(_ref) {
|
|
|
80
83
|
node = _ref.node,
|
|
81
84
|
parent = _ref.parent,
|
|
82
85
|
editorWidth = _ref.editorWidth,
|
|
83
|
-
|
|
86
|
+
anchorRectCache = _ref.anchorRectCache,
|
|
84
87
|
position = _ref.position,
|
|
85
88
|
isNestedDropTarget = _ref.isNestedDropTarget,
|
|
86
89
|
dropTargetStyle = _ref.dropTargetStyle;
|
|
@@ -99,7 +102,7 @@ var HoverZone = function HoverZone(_ref) {
|
|
|
99
102
|
var anchorName = node ? (0, _decorations.getNodeAnchor)(node) : '';
|
|
100
103
|
var heightStyleOffset = "var(--editor-block-controls-drop-indicator-gap, 0)/2";
|
|
101
104
|
var transformOffset = "var(".concat(EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_OFFSET, ", 0)");
|
|
102
|
-
var heightStyle = anchorName && enableDropZone.includes((node === null || node === void 0 ? void 0 : node.type.name) || '') ? (0, _anchorUtils.isAnchorSupported)() ? "calc(anchor-size(".concat(anchorName, " height)/2 + ").concat(heightStyleOffset, ")") : "calc(".concat(((
|
|
105
|
+
var heightStyle = anchorName && enableDropZone.includes((node === null || node === void 0 ? void 0 : node.type.name) || '') ? (0, _anchorUtils.isAnchorSupported)() ? "calc(anchor-size(".concat(anchorName, " height)/2 + ").concat(heightStyleOffset, ")") : "calc(".concat(((anchorRectCache === null || anchorRectCache === void 0 ? void 0 : anchorRectCache.getHeight(anchorName)) || 0) / 2, "px + ").concat(heightStyleOffset, ")") : '4px';
|
|
103
106
|
var transform = position === 'upper' ? "translateY(calc(-100% + ".concat(transformOffset, "))") : "translateY(".concat(transformOffset, ")");
|
|
104
107
|
return (0, _react2.css)({
|
|
105
108
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values
|
|
@@ -109,7 +112,7 @@ var HoverZone = function HoverZone(_ref) {
|
|
|
109
112
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values
|
|
110
113
|
maxWidth: "".concat(editorWidth || 0, "px")
|
|
111
114
|
});
|
|
112
|
-
}, [
|
|
115
|
+
}, [anchorRectCache, editorWidth, node, position]);
|
|
113
116
|
var isFullHeight = (0, _react.useMemo)(function () {
|
|
114
117
|
return dropTargetStyle === 'fullHeight';
|
|
115
118
|
}, [dropTargetStyle]);
|
|
@@ -129,16 +132,16 @@ var HoverZone = function HoverZone(_ref) {
|
|
|
129
132
|
hoverZoneUpperStyle, isFullHeight && fullHeightStyle, isFullHeightInLayout && fullHeightStyleAdjustZIndexStyle]
|
|
130
133
|
});
|
|
131
134
|
};
|
|
132
|
-
var DropTargetV2 = exports.DropTargetV2 = function DropTargetV2(
|
|
135
|
+
var DropTargetV2 = exports.DropTargetV2 = function DropTargetV2(props) {
|
|
133
136
|
var _dynamicStyle;
|
|
134
|
-
var api =
|
|
135
|
-
getPos =
|
|
136
|
-
prevNode =
|
|
137
|
-
nextNode =
|
|
138
|
-
parentNode =
|
|
139
|
-
formatMessage =
|
|
140
|
-
|
|
141
|
-
dropTargetStyle =
|
|
137
|
+
var api = props.api,
|
|
138
|
+
getPos = props.getPos,
|
|
139
|
+
prevNode = props.prevNode,
|
|
140
|
+
nextNode = props.nextNode,
|
|
141
|
+
parentNode = props.parentNode,
|
|
142
|
+
formatMessage = props.formatMessage,
|
|
143
|
+
anchorRectCache = props.anchorRectCache,
|
|
144
|
+
dropTargetStyle = props.dropTargetStyle;
|
|
142
145
|
var _useState = (0, _react.useState)(false),
|
|
143
146
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
144
147
|
isDraggedOver = _useState2[0],
|
|
@@ -148,8 +151,8 @@ var DropTargetV2 = exports.DropTargetV2 = function DropTargetV2(_ref2) {
|
|
|
148
151
|
var isNestedDropTarget = (parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name) !== 'doc';
|
|
149
152
|
var onDrop = function onDrop() {
|
|
150
153
|
var _api$blockControls;
|
|
151
|
-
var
|
|
152
|
-
activeNode =
|
|
154
|
+
var _ref2 = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
|
|
155
|
+
activeNode = _ref2.activeNode;
|
|
153
156
|
if (!activeNode) {
|
|
154
157
|
return;
|
|
155
158
|
}
|
|
@@ -174,7 +177,7 @@ var DropTargetV2 = exports.DropTargetV2 = function DropTargetV2(_ref2) {
|
|
|
174
177
|
onDrop: onDrop,
|
|
175
178
|
node: prevNode,
|
|
176
179
|
editorWidth: widthState === null || widthState === void 0 ? void 0 : widthState.lineLength,
|
|
177
|
-
|
|
180
|
+
anchorRectCache: anchorRectCache,
|
|
178
181
|
position: "upper",
|
|
179
182
|
isNestedDropTarget: isNestedDropTarget
|
|
180
183
|
}), (0, _react2.jsx)("div", {
|
|
@@ -202,9 +205,13 @@ var DropTargetV2 = exports.DropTargetV2 = function DropTargetV2(_ref2) {
|
|
|
202
205
|
node: nextNode,
|
|
203
206
|
parent: parentNode,
|
|
204
207
|
editorWidth: widthState === null || widthState === void 0 ? void 0 : widthState.lineLength,
|
|
205
|
-
|
|
208
|
+
anchorRectCache: anchorRectCache,
|
|
206
209
|
position: "lower",
|
|
207
210
|
isNestedDropTarget: isNestedDropTarget,
|
|
208
211
|
dropTargetStyle: dropTargetStyle
|
|
209
|
-
}))
|
|
212
|
+
}), (0, _inlineDropTarget.shouldAllowInlineDropTarget)(isNestedDropTarget, nextNode) && (0, _react2.jsx)(_react.Fragment, null, (0, _react2.jsx)(_inlineDropTarget2.InlineDropTarget, (0, _extends2.default)({}, props, {
|
|
213
|
+
position: "left"
|
|
214
|
+
})), (0, _react2.jsx)(_inlineDropTarget2.InlineDropTarget, (0, _extends2.default)({}, props, {
|
|
215
|
+
position: "right"
|
|
216
|
+
}))));
|
|
210
217
|
};
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.InlineHoverZone = exports.InlineDropTarget = void 0;
|
|
8
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
+
var _react = require("react");
|
|
10
|
+
var _react2 = require("@emotion/react");
|
|
11
|
+
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
12
|
+
var _box = require("@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box");
|
|
13
|
+
var _adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
|
|
14
|
+
var _decorations = require("../pm-plugins/decorations");
|
|
15
|
+
var _anchorUtils = require("../utils/anchor-utils");
|
|
16
|
+
/* eslint-disable @atlaskit/design-system/consistent-css-prop-usage */
|
|
17
|
+
/* eslint-disable @atlaskit/ui-styling-standard/no-unsafe-values */
|
|
18
|
+
/**
|
|
19
|
+
* @jsxRuntime classic
|
|
20
|
+
* @jsx jsx
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
24
|
+
|
|
25
|
+
var dropTargetCommonStyle = (0, _react2.css)({
|
|
26
|
+
position: 'absolute',
|
|
27
|
+
display: 'block'
|
|
28
|
+
});
|
|
29
|
+
var hideDropTargetStyle = (0, _react2.css)({
|
|
30
|
+
display: 'none'
|
|
31
|
+
});
|
|
32
|
+
var hoverZoneCommonStyle = (0, _react2.css)({
|
|
33
|
+
position: 'absolute',
|
|
34
|
+
// same value as block hover zone
|
|
35
|
+
zIndex: 110
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// gap between node boundary and drop indicator/drop zone
|
|
39
|
+
var GAP = 4;
|
|
40
|
+
var HOVER_ZONE_WIDTH_OFFSET = 40;
|
|
41
|
+
var HOVER_ZONE_HEIGHT_OFFSET = 10;
|
|
42
|
+
var HOVER_ZONE_DEFAULT_WIDTH = 40;
|
|
43
|
+
var InlineDropTarget = exports.InlineDropTarget = function InlineDropTarget(_ref) {
|
|
44
|
+
var api = _ref.api,
|
|
45
|
+
nextNode = _ref.nextNode,
|
|
46
|
+
position = _ref.position,
|
|
47
|
+
anchorRectCache = _ref.anchorRectCache,
|
|
48
|
+
getPos = _ref.getPos;
|
|
49
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['width']),
|
|
50
|
+
widthState = _useSharedPluginState.widthState;
|
|
51
|
+
var _useState = (0, _react.useState)(false),
|
|
52
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
53
|
+
isDraggedOver = _useState2[0],
|
|
54
|
+
setIsDraggedOver = _useState2[1];
|
|
55
|
+
var anchorName = nextNode ? (0, _decorations.getNodeAnchor)(nextNode) : '';
|
|
56
|
+
var handleDragEnter = (0, _react.useCallback)(function () {
|
|
57
|
+
setIsDraggedOver(true);
|
|
58
|
+
}, []);
|
|
59
|
+
var handleDragLeave = (0, _react.useCallback)(function () {
|
|
60
|
+
setIsDraggedOver(false);
|
|
61
|
+
}, []);
|
|
62
|
+
var dropTargetRectStyle = (0, _react.useMemo)(function () {
|
|
63
|
+
if ((0, _anchorUtils.isAnchorSupported)()) {
|
|
64
|
+
return (0, _react2.css)({
|
|
65
|
+
height: "calc(anchor-size(".concat(anchorName, " height))"),
|
|
66
|
+
positionAnchor: anchorName,
|
|
67
|
+
left: position === 'left' ? "calc(anchor(left) - ".concat(GAP, "px)") : "calc(anchor(right) + ".concat(GAP, "px)"),
|
|
68
|
+
top: "calc(anchor(top))"
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
var nodeRect = anchorRectCache === null || anchorRectCache === void 0 ? void 0 : anchorRectCache.getRect(anchorName);
|
|
72
|
+
return (0, _react2.css)({
|
|
73
|
+
height: "calc(".concat((nodeRect === null || nodeRect === void 0 ? void 0 : nodeRect.height) || 0, "px)"),
|
|
74
|
+
left: position === 'left' ? "".concat(((nodeRect === null || nodeRect === void 0 ? void 0 : nodeRect.left) || 0) - GAP, "px") : "".concat(((nodeRect === null || nodeRect === void 0 ? void 0 : nodeRect.right) || 0) + GAP, "px"),
|
|
75
|
+
top: "".concat((nodeRect === null || nodeRect === void 0 ? void 0 : nodeRect.top) || 0, "px")
|
|
76
|
+
});
|
|
77
|
+
}, [anchorName, anchorRectCache, position]);
|
|
78
|
+
var onDrop = (0, _react.useCallback)(function () {
|
|
79
|
+
var _api$blockControls;
|
|
80
|
+
var _ref2 = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
|
|
81
|
+
activeNode = _ref2.activeNode;
|
|
82
|
+
if (!activeNode) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
var toPos = getPos();
|
|
86
|
+
if (activeNode && toPos !== undefined) {
|
|
87
|
+
var _api$core, _api$blockControls2;
|
|
88
|
+
var start = activeNode.pos;
|
|
89
|
+
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 || (_api$blockControls2 = _api$blockControls2.commands) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.moveToLayout(start, toPos, position));
|
|
90
|
+
}
|
|
91
|
+
}, [api, getPos, position]);
|
|
92
|
+
return (0, _react2.jsx)(_react.Fragment, null, (0, _react2.jsx)("div", {
|
|
93
|
+
"data-test-id": "block-ctrl-drop-target-".concat(position),
|
|
94
|
+
css: [dropTargetCommonStyle, dropTargetRectStyle, !isDraggedOver && hideDropTargetStyle]
|
|
95
|
+
}, (0, _react2.jsx)(_box.DropIndicator, {
|
|
96
|
+
edge: position
|
|
97
|
+
})), (0, _react2.jsx)(InlineHoverZone, {
|
|
98
|
+
position: position,
|
|
99
|
+
node: nextNode,
|
|
100
|
+
editorWidthState: widthState,
|
|
101
|
+
anchorRectCache: anchorRectCache,
|
|
102
|
+
onDragEnter: handleDragEnter,
|
|
103
|
+
onDragLeave: handleDragLeave,
|
|
104
|
+
onDrop: onDrop
|
|
105
|
+
}));
|
|
106
|
+
};
|
|
107
|
+
var InlineHoverZone = exports.InlineHoverZone = function InlineHoverZone(_ref3) {
|
|
108
|
+
var node = _ref3.node,
|
|
109
|
+
editorWidthState = _ref3.editorWidthState,
|
|
110
|
+
anchorRectCache = _ref3.anchorRectCache,
|
|
111
|
+
position = _ref3.position,
|
|
112
|
+
onDragEnter = _ref3.onDragEnter,
|
|
113
|
+
onDragLeave = _ref3.onDragLeave,
|
|
114
|
+
onDrop = _ref3.onDrop;
|
|
115
|
+
var ref = (0, _react.useRef)(null);
|
|
116
|
+
var _ref4 = editorWidthState || {},
|
|
117
|
+
editorWith = _ref4.width;
|
|
118
|
+
var anchorName = node ? (0, _decorations.getNodeAnchor)(node) : '';
|
|
119
|
+
(0, _react.useEffect)(function () {
|
|
120
|
+
if (ref.current) {
|
|
121
|
+
return (0, _adapter.dropTargetForElements)({
|
|
122
|
+
element: ref.current,
|
|
123
|
+
onDragEnter: onDragEnter,
|
|
124
|
+
onDragLeave: onDragLeave,
|
|
125
|
+
onDrop: onDrop
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}, [onDragEnter, onDragLeave, onDrop]);
|
|
129
|
+
var inlineHoverZoneRectStyle = (0, _react.useMemo)(function () {
|
|
130
|
+
if ((0, _anchorUtils.isAnchorSupported)()) {
|
|
131
|
+
return (0, _react2.css)({
|
|
132
|
+
positionAnchor: anchorName,
|
|
133
|
+
left: position === 'left' ? 'unset' : "calc(anchor(right) + ".concat(GAP, "px)"),
|
|
134
|
+
right: position === 'left' ? "calc(anchor(left) + ".concat(GAP, "px)") : 'unset',
|
|
135
|
+
top: "calc(anchor(top))",
|
|
136
|
+
width: editorWith ? "calc((".concat(editorWith, "px - anchor-size(").concat(anchorName, " width))/2 - ").concat(HOVER_ZONE_WIDTH_OFFSET, "px)") : "".concat(HOVER_ZONE_DEFAULT_WIDTH, "px"),
|
|
137
|
+
height: "calc(anchor-size(".concat(anchorName, " height))")
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
var nodeRect = anchorRectCache === null || anchorRectCache === void 0 ? void 0 : anchorRectCache.getRect(anchorName);
|
|
141
|
+
var width = editorWith ? (editorWith - ((nodeRect === null || nodeRect === void 0 ? void 0 : nodeRect.width) || 0)) / 2 - HOVER_ZONE_WIDTH_OFFSET : HOVER_ZONE_DEFAULT_WIDTH;
|
|
142
|
+
return (0, _react2.css)({
|
|
143
|
+
left: position === 'left' ? "".concat(((nodeRect === null || nodeRect === void 0 ? void 0 : nodeRect.left) || 0) - width - GAP, "px") : "".concat(((nodeRect === null || nodeRect === void 0 ? void 0 : nodeRect.right) || 0) + GAP, "px"),
|
|
144
|
+
top: "".concat((nodeRect === null || nodeRect === void 0 ? void 0 : nodeRect.top) || 0, "px"),
|
|
145
|
+
width: "".concat(width, "px"),
|
|
146
|
+
height: "calc(".concat((anchorRectCache === null || anchorRectCache === void 0 ? void 0 : anchorRectCache.getHeight(anchorName)) || 0, "px - ").concat(HOVER_ZONE_HEIGHT_OFFSET, "px)")
|
|
147
|
+
});
|
|
148
|
+
}, [anchorName, anchorRectCache, editorWith, position]);
|
|
149
|
+
return (0, _react2.jsx)("div", {
|
|
150
|
+
ref: ref,
|
|
151
|
+
css: [hoverZoneCommonStyle, inlineHoverZoneRectStyle]
|
|
152
|
+
});
|
|
153
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isPreRelease2 = exports.isPreRelease1 = void 0;
|
|
7
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
8
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
9
|
+
// When we turn on re-release 2, will also turn on pre-release 1
|
|
10
|
+
// but not vice-versa
|
|
11
|
+
var isPreRelease1 = exports.isPreRelease1 = function isPreRelease1() {
|
|
12
|
+
return (0, _experiments.editorExperiment)('advanced_layouts', true) || (0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_pre_release_1') || (0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_pre_release_2');
|
|
13
|
+
};
|
|
14
|
+
var isPreRelease2 = exports.isPreRelease2 = function isPreRelease2() {
|
|
15
|
+
return (0, _experiments.editorExperiment)('advanced_layouts', true) || (0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_pre_release_2');
|
|
16
|
+
};
|