@atlaskit/editor-plugin-block-controls 1.10.1 → 1.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/dist/cjs/commands/move-node.js +24 -6
- package/dist/cjs/pm-plugins/decorations.js +13 -3
- package/dist/cjs/pm-plugins/keymap.js +5 -5
- package/dist/cjs/pm-plugins/main.js +12 -8
- package/dist/cjs/ui/drag-handle.js +28 -16
- package/dist/cjs/ui/drop-target.js +4 -3
- package/dist/cjs/ui/global-styles.js +2 -21
- package/dist/cjs/utils/validation.js +9 -0
- package/dist/es2019/commands/move-node.js +24 -7
- package/dist/es2019/pm-plugins/decorations.js +13 -3
- package/dist/es2019/pm-plugins/keymap.js +4 -4
- package/dist/es2019/pm-plugins/main.js +14 -8
- package/dist/es2019/ui/drag-handle.js +14 -3
- package/dist/es2019/ui/drop-target.js +4 -3
- package/dist/es2019/ui/global-styles.js +2 -31
- package/dist/es2019/utils/validation.js +3 -0
- package/dist/esm/commands/move-node.js +24 -6
- package/dist/esm/pm-plugins/decorations.js +13 -3
- package/dist/esm/pm-plugins/keymap.js +5 -5
- package/dist/esm/pm-plugins/main.js +12 -8
- package/dist/esm/ui/drag-handle.js +29 -17
- package/dist/esm/ui/drop-target.js +4 -3
- package/dist/esm/ui/global-styles.js +2 -21
- package/dist/esm/utils/validation.js +3 -0
- package/dist/types/commands/move-node.d.ts +3 -2
- package/dist/types/pm-plugins/decorations.d.ts +1 -1
- package/dist/types/pm-plugins/keymap.d.ts +2 -1
- package/dist/types/types.d.ts +5 -2
- package/dist/types/ui/drop-target.d.ts +7 -1
- package/dist/types/utils/validation.d.ts +2 -0
- package/dist/types-ts4.5/commands/move-node.d.ts +3 -2
- package/dist/types-ts4.5/pm-plugins/decorations.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/keymap.d.ts +2 -1
- package/dist/types-ts4.5/types.d.ts +5 -2
- package/dist/types-ts4.5/ui/drop-target.d.ts +7 -1
- package/dist/types-ts4.5/utils/validation.d.ts +2 -0
- package/package.json +5 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,34 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 1.10.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#127123](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/127123)
|
|
8
|
+
[`7a68ab6404094`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/7a68ab6404094) -
|
|
9
|
+
[ux] Add validation to node move, only show valid drop targets
|
|
10
|
+
- [#126802](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/126802)
|
|
11
|
+
[`2cd334b37d1d8`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/2cd334b37d1d8) -
|
|
12
|
+
Clean up FFs
|
|
13
|
+
|
|
14
|
+
## 1.10.2
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [`63d659eb3e73d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/63d659eb3e73d) -
|
|
19
|
+
ED-24315 improve a11y for block controls
|
|
20
|
+
|
|
3
21
|
## 1.10.1
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
6
24
|
|
|
25
|
+
- [#125984](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/125984)
|
|
26
|
+
[`167a210dfd672`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/167a210dfd672) -
|
|
27
|
+
[ux] Update shortcuts for element dnd
|
|
7
28
|
- [#125542](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/125542)
|
|
8
29
|
[`06bc2f65f892e`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/06bc2f65f892e) -
|
|
9
30
|
ED-24304 resolve range error issue
|
|
31
|
+
- Updated dependencies
|
|
10
32
|
|
|
11
33
|
## 1.10.0
|
|
12
34
|
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.moveNodeViaShortcut = exports.moveNode = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
10
|
+
var _messages = require("@atlaskit/editor-common/messages");
|
|
10
11
|
var _selection = require("@atlaskit/editor-common/selection");
|
|
11
12
|
var _transforms = require("@atlaskit/editor-common/transforms");
|
|
12
13
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
@@ -14,12 +15,14 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
|
14
15
|
var _consts = require("../consts");
|
|
15
16
|
var _main = require("../pm-plugins/main");
|
|
16
17
|
var _utils2 = require("../utils");
|
|
18
|
+
var _validation = require("../utils/validation");
|
|
17
19
|
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; }
|
|
18
20
|
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; }
|
|
19
21
|
function transformNested(nodeCopy, destType) {
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
var srcNode = nodeCopy.content.firstChild;
|
|
23
|
+
var schema = srcNode === null || srcNode === void 0 ? void 0 : srcNode.type.schema;
|
|
24
|
+
if (srcNode && schema && srcNode.type === schema.nodes.nestedExpand && destType === schema.nodes.doc) {
|
|
25
|
+
return (0, _transforms.transformSliceNestedExpandToExpand)(nodeCopy, schema);
|
|
23
26
|
}
|
|
24
27
|
return nodeCopy;
|
|
25
28
|
}
|
|
@@ -53,7 +56,7 @@ var getCurrentNodePos = function getCurrentNodePos(state) {
|
|
|
53
56
|
}
|
|
54
57
|
return currentNodePos;
|
|
55
58
|
};
|
|
56
|
-
var moveNodeViaShortcut = exports.moveNodeViaShortcut = function moveNodeViaShortcut(api, direction) {
|
|
59
|
+
var moveNodeViaShortcut = exports.moveNodeViaShortcut = function moveNodeViaShortcut(api, direction, formatMessage) {
|
|
57
60
|
return function (state) {
|
|
58
61
|
var currentNodePos = getCurrentNodePos(state);
|
|
59
62
|
if (currentNodePos > -1) {
|
|
@@ -79,7 +82,7 @@ var moveNodeViaShortcut = exports.moveNodeViaShortcut = function moveNodeViaShor
|
|
|
79
82
|
var _api$core;
|
|
80
83
|
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref2) {
|
|
81
84
|
var tr = _ref2.tr;
|
|
82
|
-
moveNode(api)(currentNodePos, moveToPos, _analytics.INPUT_METHOD.SHORTCUT)({
|
|
85
|
+
moveNode(api)(currentNodePos, moveToPos, _analytics.INPUT_METHOD.SHORTCUT, formatMessage)({
|
|
83
86
|
tr: tr
|
|
84
87
|
});
|
|
85
88
|
tr.scrollIntoView();
|
|
@@ -104,6 +107,7 @@ var moveNodeViaShortcut = exports.moveNodeViaShortcut = function moveNodeViaShor
|
|
|
104
107
|
var moveNode = exports.moveNode = function moveNode(api) {
|
|
105
108
|
return function (start, to) {
|
|
106
109
|
var inputMethod = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _analytics.INPUT_METHOD.DRAG_AND_DROP;
|
|
110
|
+
var formatMessage = arguments.length > 3 ? arguments[3] : undefined;
|
|
107
111
|
return function (_ref4) {
|
|
108
112
|
var _node$nodeSize, _api$analytics;
|
|
109
113
|
var tr = _ref4.tr;
|
|
@@ -117,7 +121,14 @@ var moveNode = exports.moveNode = function moveNode(api) {
|
|
|
117
121
|
var mappedTo;
|
|
118
122
|
if ((0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_nested')) {
|
|
119
123
|
var nodeCopy = tr.doc.slice(start, end, false); // cut the content
|
|
120
|
-
var
|
|
124
|
+
var $to = tr.doc.resolve(to);
|
|
125
|
+
var $from = tr.doc.resolve(start);
|
|
126
|
+
var destType = $to.node().type;
|
|
127
|
+
var srcType = $from.node().child($from.index()).type;
|
|
128
|
+
var destParent = $to.node($to.depth);
|
|
129
|
+
if (!(0, _validation.canMoveToIndex)(destParent, $to.index(), srcType)) {
|
|
130
|
+
return tr;
|
|
131
|
+
}
|
|
121
132
|
var convertedNode = transformNested(nodeCopy, destType).content;
|
|
122
133
|
tr.delete(start, end); // delete the content from the original position
|
|
123
134
|
mappedTo = tr.mapping.map(to);
|
|
@@ -145,6 +156,13 @@ var moveNode = exports.moveNode = function moveNode(api) {
|
|
|
145
156
|
inputMethod: inputMethod
|
|
146
157
|
})
|
|
147
158
|
})(tr);
|
|
159
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_23873')) {
|
|
160
|
+
var _api$accessibilityUti;
|
|
161
|
+
var movedMessage = to > start ? _messages.blockControlsMessages.movedDown : _messages.blockControlsMessages.movedup;
|
|
162
|
+
api === null || api === void 0 || (_api$accessibilityUti = api.accessibilityUtils) === null || _api$accessibilityUti === void 0 || _api$accessibilityUti.actions.ariaNotify(formatMessage ? formatMessage(movedMessage) : movedMessage.defaultMessage, {
|
|
163
|
+
priority: 'important'
|
|
164
|
+
});
|
|
165
|
+
}
|
|
148
166
|
return tr;
|
|
149
167
|
};
|
|
150
168
|
};
|
|
@@ -15,9 +15,10 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
|
15
15
|
var _dragHandle = require("../ui/drag-handle");
|
|
16
16
|
var _dropTarget = require("../ui/drop-target");
|
|
17
17
|
var _mouseMoveWrapper = require("../ui/mouse-move-wrapper");
|
|
18
|
+
var _validation = require("../utils/validation");
|
|
18
19
|
var IGNORE_NODES = ['tableCell', 'tableHeader', 'tableRow', 'layoutColumn'];
|
|
19
20
|
var NESTED_DEPTH = (0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_nested') ? 100 : 0;
|
|
20
|
-
var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetDecorations(oldState, newState, api) {
|
|
21
|
+
var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetDecorations(oldState, newState, api, formatMessage, activeNodeType) {
|
|
21
22
|
var decs = [];
|
|
22
23
|
unmountDecorations('data-blocks-drop-target-container');
|
|
23
24
|
// Decoration state is used to keep track of the position of the drop targets
|
|
@@ -25,8 +26,9 @@ var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetD
|
|
|
25
26
|
var decorationState = [];
|
|
26
27
|
var prevNode;
|
|
27
28
|
var state = (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_24372') ? newState : oldState;
|
|
28
|
-
state.doc.nodesBetween(0, newState.doc.nodeSize - 2, function (node, pos,
|
|
29
|
+
state.doc.nodesBetween(0, newState.doc.nodeSize - 2, function (node, pos, parent, index) {
|
|
29
30
|
var depth = 0;
|
|
31
|
+
var nodeType = newState.doc.type.schema.nodes[activeNodeType];
|
|
30
32
|
if ((0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_nested')) {
|
|
31
33
|
depth = newState.doc.resolve(pos).depth;
|
|
32
34
|
if (node.isInline) {
|
|
@@ -35,6 +37,12 @@ var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetD
|
|
|
35
37
|
if (IGNORE_NODES.includes(node.type.name)) {
|
|
36
38
|
return true; //skip over, don't consider it a valid depth
|
|
37
39
|
}
|
|
40
|
+
var canDrop = parent && activeNodeType && (0, _validation.canMoveToIndex)(parent, index, nodeType);
|
|
41
|
+
|
|
42
|
+
//NOTE: This will block drop targets showing for nodes that are valid after transformation (i.e. expand -> nestedExpand)
|
|
43
|
+
if (!canDrop) {
|
|
44
|
+
return false; //not valid pos, so nested not valid either
|
|
45
|
+
}
|
|
38
46
|
decorationState.push({
|
|
39
47
|
id: pos,
|
|
40
48
|
pos: pos
|
|
@@ -48,6 +56,7 @@ var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetD
|
|
|
48
56
|
var dropTargetDec = /*#__PURE__*/(0, _react.createElement)(_dropTarget.DropTarget, {
|
|
49
57
|
api: api,
|
|
50
58
|
id: (0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_nested') ? pos : index,
|
|
59
|
+
formatMessage: formatMessage,
|
|
51
60
|
prevNode: prevNode,
|
|
52
61
|
nextNode: node
|
|
53
62
|
});
|
|
@@ -90,7 +99,8 @@ var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetD
|
|
|
90
99
|
element.setAttribute('data-blocks-drop-target-container', 'true');
|
|
91
100
|
_reactDom.default.render( /*#__PURE__*/(0, _react.createElement)(_dropTarget.DropTarget, {
|
|
92
101
|
api: api,
|
|
93
|
-
id: (0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_nested') ? lastPos : decorationState.length
|
|
102
|
+
id: (0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_nested') ? lastPos : decorationState.length,
|
|
103
|
+
formatMessage: formatMessage
|
|
94
104
|
}), element);
|
|
95
105
|
return element;
|
|
96
106
|
}, {
|
|
@@ -10,7 +10,7 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
|
10
10
|
var _moveNode = require("../commands/move-node");
|
|
11
11
|
var _showDragHandle = require("../commands/show-drag-handle");
|
|
12
12
|
var _consts = require("../consts");
|
|
13
|
-
function keymapList(api) {
|
|
13
|
+
function keymapList(api, formatMessage) {
|
|
14
14
|
var keymapList = {};
|
|
15
15
|
if (api && (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_23873')) {
|
|
16
16
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.showElementDragHandle.common, function (state, dispatch, view) {
|
|
@@ -18,11 +18,11 @@ function keymapList(api) {
|
|
|
18
18
|
//we always want to handle this shortcut to prevent default browser special char insert when option + alphabetical key is used
|
|
19
19
|
return true;
|
|
20
20
|
}, keymapList);
|
|
21
|
-
(0, _keymaps.bindKeymapWithCommand)(_keymaps.dragToMoveUp.common, (0, _moveNode.moveNodeViaShortcut)(api, _consts.DIRECTION.UP), keymapList);
|
|
22
|
-
(0, _keymaps.bindKeymapWithCommand)(_keymaps.dragToMoveDown.common, (0, _moveNode.moveNodeViaShortcut)(api, _consts.DIRECTION.DOWN), keymapList);
|
|
21
|
+
(0, _keymaps.bindKeymapWithCommand)(_keymaps.dragToMoveUp.common, (0, _moveNode.moveNodeViaShortcut)(api, _consts.DIRECTION.UP, formatMessage), keymapList);
|
|
22
|
+
(0, _keymaps.bindKeymapWithCommand)(_keymaps.dragToMoveDown.common, (0, _moveNode.moveNodeViaShortcut)(api, _consts.DIRECTION.DOWN, formatMessage), keymapList);
|
|
23
23
|
}
|
|
24
24
|
return keymapList;
|
|
25
25
|
}
|
|
26
|
-
var boundKeydownHandler = exports.boundKeydownHandler = function boundKeydownHandler(api) {
|
|
27
|
-
return (0, _keymap.keydownHandler)(keymapList(api));
|
|
26
|
+
var boundKeydownHandler = exports.boundKeydownHandler = function boundKeydownHandler(api, formatMessage) {
|
|
27
|
+
return (0, _keymap.keydownHandler)(keymapList(api, formatMessage));
|
|
28
28
|
};
|
|
@@ -94,7 +94,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl) {
|
|
|
94
94
|
return initialState;
|
|
95
95
|
},
|
|
96
96
|
apply: function apply(tr, currentState, oldState, newState) {
|
|
97
|
-
var _meta$activeNode, _meta$activeNode$hand, _meta$
|
|
97
|
+
var _meta$activeNode, _meta$activeNode$hand, _meta$activeNode4, _meta$isDragging, _meta$editorHeight, _meta$editorWidthLeft, _meta$editorWidthRigh, _meta$isPMDragging;
|
|
98
98
|
if (initialState.isDocSizeLimitEnabled === null) {
|
|
99
99
|
if ((0, _platformFeatureFlags.fg)('platform.editor.elements.drag-and-drop-doc-size-limit_7k4vq')) {
|
|
100
100
|
initialState.isDocSizeLimitEnabled = true;
|
|
@@ -184,6 +184,8 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl) {
|
|
|
184
184
|
// The activeNode is from the previous rendering cycle, and verify if they share the same anchor.
|
|
185
185
|
var maybeNodeWidthUpdated = (meta === null || meta === void 0 ? void 0 : meta.activeNode) && (meta === null || meta === void 0 || (_meta$activeNode = meta.activeNode) === null || _meta$activeNode === void 0 ? void 0 : _meta$activeNode.nodeType) === 'table' && meta.activeNode.anchorName === (activeNode === null || activeNode === void 0 ? void 0 : activeNode.anchorName);
|
|
186
186
|
var redrawDecorations = decorations === _view.DecorationSet.empty || (meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== undefined && (meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== editorHeight || (meta === null || meta === void 0 ? void 0 : meta.editorWidthLeft) !== undefined && (meta === null || meta === void 0 ? void 0 : meta.editorWidthLeft) !== editorWidthLeft || (meta === null || meta === void 0 ? void 0 : meta.editorWidthRight) !== undefined && (meta === null || meta === void 0 ? void 0 : meta.editorWidthRight) !== editorWidthRight || maybeWidthUpdated || nodeCountChanged || maybeNodeWidthUpdated || resizerMeta === false || isDecsMissing || !!(meta !== null && meta !== void 0 && meta.nodeMoved) && tr.docChanged;
|
|
187
|
+
var _getIntl = getIntl(),
|
|
188
|
+
formatMessage = _getIntl.formatMessage;
|
|
187
189
|
|
|
188
190
|
// Draw node and mouseWrapper decorations at top level node if decorations is empty, editor height changes or node is moved
|
|
189
191
|
if (redrawDecorations && !isResizerResizing && api) {
|
|
@@ -273,7 +275,8 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl) {
|
|
|
273
275
|
// Add drop targets when node is being dragged
|
|
274
276
|
// if the transaction is only for analytics and user is dragging, continue to draw drop targets
|
|
275
277
|
if (shouldUpdateDropTargets || (0, _dragTargetDebug.isBlocksDragTargetDebug)()) {
|
|
276
|
-
var
|
|
278
|
+
var _meta$activeNode2;
|
|
279
|
+
var _dropTargetDecoration = (0, _decorations.dropTargetDecorations)(oldState, newState, api, formatMessage, meta === null || meta === void 0 || (_meta$activeNode2 = meta.activeNode) === null || _meta$activeNode2 === void 0 ? void 0 : _meta$activeNode2.nodeType),
|
|
277
280
|
_decs2 = _dropTargetDecoration.decs,
|
|
278
281
|
updatedDecorationState = _dropTargetDecoration.decorationState;
|
|
279
282
|
decorationState = updatedDecorationState;
|
|
@@ -298,7 +301,8 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl) {
|
|
|
298
301
|
// if the transaction is only for analytics and user is dragging, continue to draw drop targets
|
|
299
302
|
var shouldShowDragTarget = (meta === null || meta === void 0 ? void 0 : meta.isDragging) && (!tr.docChanged || tr.docChanged && isAnalyticTr);
|
|
300
303
|
if (shouldShowDragTarget || (0, _dragTargetDebug.isBlocksDragTargetDebug)()) {
|
|
301
|
-
var
|
|
304
|
+
var _meta$activeNode3;
|
|
305
|
+
var _dropTargetDecoration2 = (0, _decorations.dropTargetDecorations)(oldState, newState, api, formatMessage, meta === null || meta === void 0 || (_meta$activeNode3 = meta.activeNode) === null || _meta$activeNode3 === void 0 ? void 0 : _meta$activeNode3.nodeType),
|
|
302
306
|
_decs3 = _dropTargetDecoration2.decs,
|
|
303
307
|
_updatedDecorationState = _dropTargetDecoration2.decorationState;
|
|
304
308
|
decorationState = _updatedDecorationState;
|
|
@@ -359,7 +363,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl) {
|
|
|
359
363
|
return {
|
|
360
364
|
decorations: decorations,
|
|
361
365
|
decorationState: decorationState,
|
|
362
|
-
activeNode: isEmptyDoc || isHandleMissing ? null : (_meta$
|
|
366
|
+
activeNode: isEmptyDoc || isHandleMissing ? null : (_meta$activeNode4 = meta === null || meta === void 0 ? void 0 : meta.activeNode) !== null && _meta$activeNode4 !== void 0 ? _meta$activeNode4 : mappedActiveNodePos,
|
|
363
367
|
isDragging: (_meta$isDragging = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging !== void 0 ? _meta$isDragging : isDragging,
|
|
364
368
|
isMenuOpen: meta !== null && meta !== void 0 && meta.toggleMenu ? !isMenuOpen : isMenuOpen,
|
|
365
369
|
editorHeight: (_meta$editorHeight = meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== null && _meta$editorHeight !== void 0 ? _meta$editorHeight : currentState.editorHeight,
|
|
@@ -454,11 +458,11 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl) {
|
|
|
454
458
|
return true;
|
|
455
459
|
}
|
|
456
460
|
}
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
461
|
+
if (event.shiftKey && event.ctrlKey && (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_23873')) {
|
|
462
|
+
var _getIntl2 = getIntl(),
|
|
463
|
+
formatMessage = _getIntl2.formatMessage;
|
|
460
464
|
//prevent holding down key combo from firing repeatedly
|
|
461
|
-
if (!event.repeat && (0, _keymap.boundKeydownHandler)(api)(view, event)) {
|
|
465
|
+
if (!event.repeat && (0, _keymap.boundKeydownHandler)(api, formatMessage)(view, event)) {
|
|
462
466
|
event.preventDefault();
|
|
463
467
|
return true;
|
|
464
468
|
}
|
|
@@ -367,27 +367,39 @@ var DragHandleInternal = function DragHandleInternal(_ref) {
|
|
|
367
367
|
description: formatMessage(_messages.blockControlsMessages.moveDown),
|
|
368
368
|
keymap: _keymaps.dragToMoveDown
|
|
369
369
|
}];
|
|
370
|
+
var message = helpDescriptors.map(function (descriptor) {
|
|
371
|
+
return descriptor.keymap ? [descriptor.description, (0, _keymaps.getAriaKeyshortcuts)(descriptor.keymap)] : [descriptor.description];
|
|
372
|
+
}).join('. ');
|
|
370
373
|
var renderButton = function renderButton() {
|
|
371
|
-
return (
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
374
|
+
return (
|
|
375
|
+
// eslint-disable-next-line @atlaskit/design-system/no-html-button
|
|
376
|
+
(0, _react2.jsx)("button", {
|
|
377
|
+
type: "button",
|
|
378
|
+
css: [dragHandleButtonStyles, dragHandleSelected && selectedStyles],
|
|
379
|
+
ref: buttonRef
|
|
380
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
381
|
+
,
|
|
382
|
+
style: (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_23896') ? newPositionStyles : positionStyles,
|
|
383
|
+
onClick: handleOnClick,
|
|
384
|
+
onMouseDown: (0, _platformFeatureFlags.fg)('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2') ? handleMouseDownWrapperRemoved : handleMouseDown,
|
|
385
|
+
onKeyDown: handleKeyDown,
|
|
386
|
+
"data-testid": "block-ctrl-drag-handle"
|
|
387
|
+
}, (0, _react2.jsx)(_dragHandler.default, {
|
|
388
|
+
label: "",
|
|
389
|
+
size: "medium"
|
|
390
|
+
}))
|
|
391
|
+
);
|
|
386
392
|
};
|
|
387
393
|
return (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_23873') ? (0, _react2.jsx)(_tooltip.default, {
|
|
388
394
|
content: (0, _react2.jsx)(_keymaps.TooltipContentWithMultipleShortcuts, {
|
|
389
395
|
helpDescriptors: helpDescriptors
|
|
390
|
-
})
|
|
396
|
+
}),
|
|
397
|
+
onShow: function onShow() {
|
|
398
|
+
var _api$accessibilityUti;
|
|
399
|
+
api === null || api === void 0 || (_api$accessibilityUti = api.accessibilityUtils) === null || _api$accessibilityUti === void 0 || _api$accessibilityUti.actions.ariaNotify(message, {
|
|
400
|
+
priority: 'important'
|
|
401
|
+
});
|
|
402
|
+
}
|
|
391
403
|
}, renderButton()) : renderButton();
|
|
392
404
|
};
|
|
393
405
|
var DragHandle = exports.DragHandle = (0, _reactIntlNext.injectIntl)(DragHandleInternal);
|
|
@@ -79,7 +79,8 @@ var DropTarget = exports.DropTarget = function DropTarget(_ref3) {
|
|
|
79
79
|
var api = _ref3.api,
|
|
80
80
|
id = _ref3.id,
|
|
81
81
|
prevNode = _ref3.prevNode,
|
|
82
|
-
nextNode = _ref3.nextNode
|
|
82
|
+
nextNode = _ref3.nextNode,
|
|
83
|
+
formatMessage = _ref3.formatMessage;
|
|
83
84
|
var ref = (0, _react.useRef)(null);
|
|
84
85
|
var _useState = (0, _react.useState)(false),
|
|
85
86
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
@@ -119,11 +120,11 @@ var DropTarget = exports.DropTarget = function DropTarget(_ref3) {
|
|
|
119
120
|
if (activeNode && pos !== undefined) {
|
|
120
121
|
var _api$core, _api$blockControls2;
|
|
121
122
|
var start = activeNode.pos;
|
|
122
|
-
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.moveNode(start, pos));
|
|
123
|
+
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.moveNode(start, pos, undefined, formatMessage));
|
|
123
124
|
}
|
|
124
125
|
}
|
|
125
126
|
});
|
|
126
|
-
}, [id, api]);
|
|
127
|
+
}, [id, api, formatMessage]);
|
|
127
128
|
var topTargetMarginStyle = (0, _react.useMemo)(function () {
|
|
128
129
|
return getDropTargetPositionStyle(prevNode, nextNode);
|
|
129
130
|
}, [prevNode, nextNode]);
|
|
@@ -90,30 +90,15 @@ var extendedHoverZoneNested = (0, _react.css)({
|
|
|
90
90
|
display: 'none'
|
|
91
91
|
}
|
|
92
92
|
});
|
|
93
|
-
var paragraphWithTrailingBreak = '+ p > .ProseMirror-trailingBreak';
|
|
94
|
-
var paragraphWithCursorTarget = '+ p > .cursor-target';
|
|
95
93
|
var paragraphWithTrailingBreakAsOnlyChild = '+ p > .ProseMirror-trailingBreak:only-child';
|
|
96
94
|
var paragraphWithPlaceholder = '+ p > .placeholder-decoration';
|
|
97
95
|
var dragHandleContainer = '.ProseMirror-widget[data-blocks-drag-handle-container="true"]';
|
|
98
96
|
var dragHandleSelector = 'button[data-testid="block-ctrl-drag-handle"]';
|
|
99
|
-
var withoutInlineNodeStyle = (0, _react.css)((0, _defineProperty2.default)({}, ".ProseMirror-widget[data-blocks-drag-handle-container=\"true\"]:has(".concat(paragraphWithTrailingBreak, "):not(:has(").concat(paragraphWithCursorTarget, "))"), {
|
|
100
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
|
|
101
|
-
display: 'none !important'
|
|
102
|
-
}));
|
|
103
97
|
var withInlineNodeStyle = (0, _react.css)((0, _defineProperty2.default)({}, ".ProseMirror-widget[data-blocks-drag-handle-container=\"true\"]:has(".concat(paragraphWithTrailingBreakAsOnlyChild, "), .ProseMirror-widget[data-blocks-drag-handle-container=\"true\"]:has(").concat(paragraphWithPlaceholder, ")"), {
|
|
104
98
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
|
|
105
99
|
display: 'none !important'
|
|
106
100
|
}));
|
|
107
101
|
|
|
108
|
-
/**
|
|
109
|
-
* Please do not change change transform to display:none, or visibility:hidden
|
|
110
|
-
* Otherwise it might break composition input for Chrome
|
|
111
|
-
* https://product-fabric.atlassian.net/browse/ED-24136
|
|
112
|
-
*/
|
|
113
|
-
var withoutInlineNodeStyleWithChromeFix = (0, _react.css)((0, _defineProperty2.default)({}, "".concat(dragHandleContainer, ":has(").concat(paragraphWithTrailingBreak, "):not(:has(").concat(paragraphWithCursorTarget, ")) ").concat(dragHandleSelector), {
|
|
114
|
-
transform: 'scale(0)'
|
|
115
|
-
}));
|
|
116
|
-
|
|
117
102
|
/**
|
|
118
103
|
* Please do not change change transform to display:none, or visibility:hidden
|
|
119
104
|
* Otherwise it might break composition input for Chrome
|
|
@@ -141,14 +126,10 @@ var withMediaSingleStyleFix = (0, _react.css)((0, _defineProperty2.default)({},
|
|
|
141
126
|
cursor: 'pointer'
|
|
142
127
|
}));
|
|
143
128
|
var getTextNodeStyle = function getTextNodeStyle() {
|
|
144
|
-
|
|
145
|
-
return (0, _platformFeatureFlags.fg)('platform_editor_element_controls_chrome_input_fix') ? withInlineNodeStyleWithChromeFix : withInlineNodeStyle;
|
|
146
|
-
} else {
|
|
147
|
-
return (0, _platformFeatureFlags.fg)('platform_editor_element_controls_chrome_input_fix') ? withoutInlineNodeStyleWithChromeFix : withoutInlineNodeStyle;
|
|
148
|
-
}
|
|
129
|
+
return (0, _platformFeatureFlags.fg)('platform_editor_element_controls_chrome_input_fix') ? withInlineNodeStyleWithChromeFix : withInlineNodeStyle;
|
|
149
130
|
};
|
|
150
131
|
var GlobalStylesWrapper = exports.GlobalStylesWrapper = function GlobalStylesWrapper() {
|
|
151
132
|
return (0, _react.jsx)(_react.Global, {
|
|
152
|
-
styles: [globalStyles, (0, _platformFeatureFlags.fg)('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2') ? (0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_nested') ? extendedHoverZoneNested : extendedHoverZone : false, getTextNodeStyle(),
|
|
133
|
+
styles: [globalStyles, (0, _platformFeatureFlags.fg)('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2') ? (0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_nested') ? extendedHoverZoneNested : extendedHoverZone : false, getTextNodeStyle(), withDeleteLinesStyleFix, withMediaSingleStyleFix]
|
|
153
134
|
});
|
|
154
135
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.canMoveToIndex = canMoveToIndex;
|
|
7
|
+
function canMoveToIndex(destParent, indexIntoParent, srcType) {
|
|
8
|
+
return destParent.canReplaceWith(indexIntoParent, indexIntoParent, srcType);
|
|
9
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { blockControlsMessages } from '@atlaskit/editor-common/messages';
|
|
2
3
|
import { GapCursorSelection } from '@atlaskit/editor-common/selection';
|
|
3
4
|
import { transformSliceNestedExpandToExpand } from '@atlaskit/editor-common/transforms';
|
|
4
5
|
import { findTable, isInTable, isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
@@ -6,10 +7,12 @@ import { fg } from '@atlaskit/platform-feature-flags';
|
|
|
6
7
|
import { DIRECTION } from '../consts';
|
|
7
8
|
import { key } from '../pm-plugins/main';
|
|
8
9
|
import { selectNode } from '../utils';
|
|
10
|
+
import { canMoveToIndex } from '../utils/validation';
|
|
9
11
|
function transformNested(nodeCopy, destType) {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
const srcNode = nodeCopy.content.firstChild;
|
|
13
|
+
const schema = srcNode === null || srcNode === void 0 ? void 0 : srcNode.type.schema;
|
|
14
|
+
if (srcNode && schema && srcNode.type === schema.nodes.nestedExpand && destType === schema.nodes.doc) {
|
|
15
|
+
return transformSliceNestedExpandToExpand(nodeCopy, schema);
|
|
13
16
|
}
|
|
14
17
|
return nodeCopy;
|
|
15
18
|
}
|
|
@@ -46,7 +49,7 @@ const getCurrentNodePos = state => {
|
|
|
46
49
|
}
|
|
47
50
|
return currentNodePos;
|
|
48
51
|
};
|
|
49
|
-
export const moveNodeViaShortcut = (api, direction) => {
|
|
52
|
+
export const moveNodeViaShortcut = (api, direction, formatMessage) => {
|
|
50
53
|
return state => {
|
|
51
54
|
const currentNodePos = getCurrentNodePos(state);
|
|
52
55
|
if (currentNodePos > -1) {
|
|
@@ -73,7 +76,7 @@ export const moveNodeViaShortcut = (api, direction) => {
|
|
|
73
76
|
api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(({
|
|
74
77
|
tr
|
|
75
78
|
}) => {
|
|
76
|
-
moveNode(api)(currentNodePos, moveToPos, INPUT_METHOD.SHORTCUT)({
|
|
79
|
+
moveNode(api)(currentNodePos, moveToPos, INPUT_METHOD.SHORTCUT, formatMessage)({
|
|
77
80
|
tr
|
|
78
81
|
});
|
|
79
82
|
tr.scrollIntoView();
|
|
@@ -96,7 +99,7 @@ export const moveNodeViaShortcut = (api, direction) => {
|
|
|
96
99
|
return false;
|
|
97
100
|
};
|
|
98
101
|
};
|
|
99
|
-
export const moveNode = api => (start, to, inputMethod = INPUT_METHOD.DRAG_AND_DROP) => ({
|
|
102
|
+
export const moveNode = api => (start, to, inputMethod = INPUT_METHOD.DRAG_AND_DROP, formatMessage) => ({
|
|
100
103
|
tr
|
|
101
104
|
}) => {
|
|
102
105
|
var _node$nodeSize, _api$analytics;
|
|
@@ -110,7 +113,14 @@ export const moveNode = api => (start, to, inputMethod = INPUT_METHOD.DRAG_AND_D
|
|
|
110
113
|
let mappedTo;
|
|
111
114
|
if (fg('platform_editor_elements_dnd_nested')) {
|
|
112
115
|
const nodeCopy = tr.doc.slice(start, end, false); // cut the content
|
|
113
|
-
const
|
|
116
|
+
const $to = tr.doc.resolve(to);
|
|
117
|
+
const $from = tr.doc.resolve(start);
|
|
118
|
+
const destType = $to.node().type;
|
|
119
|
+
const srcType = $from.node().child($from.index()).type;
|
|
120
|
+
const destParent = $to.node($to.depth);
|
|
121
|
+
if (!canMoveToIndex(destParent, $to.index(), srcType)) {
|
|
122
|
+
return tr;
|
|
123
|
+
}
|
|
114
124
|
const convertedNode = transformNested(nodeCopy, destType).content;
|
|
115
125
|
tr.delete(start, end); // delete the content from the original position
|
|
116
126
|
mappedTo = tr.mapping.map(to);
|
|
@@ -139,5 +149,12 @@ export const moveNode = api => (start, to, inputMethod = INPUT_METHOD.DRAG_AND_D
|
|
|
139
149
|
})
|
|
140
150
|
}
|
|
141
151
|
})(tr);
|
|
152
|
+
if (fg('platform_editor_element_drag_and_drop_ed_23873')) {
|
|
153
|
+
var _api$accessibilityUti;
|
|
154
|
+
const movedMessage = to > start ? blockControlsMessages.movedDown : blockControlsMessages.movedup;
|
|
155
|
+
api === null || api === void 0 ? void 0 : (_api$accessibilityUti = api.accessibilityUtils) === null || _api$accessibilityUti === void 0 ? void 0 : _api$accessibilityUti.actions.ariaNotify(formatMessage ? formatMessage(movedMessage) : movedMessage.defaultMessage, {
|
|
156
|
+
priority: 'important'
|
|
157
|
+
});
|
|
158
|
+
}
|
|
142
159
|
return tr;
|
|
143
160
|
};
|
|
@@ -7,9 +7,10 @@ import { fg } from '@atlaskit/platform-feature-flags';
|
|
|
7
7
|
import { DragHandle } from '../ui/drag-handle';
|
|
8
8
|
import { DropTarget } from '../ui/drop-target';
|
|
9
9
|
import { MouseMoveWrapper } from '../ui/mouse-move-wrapper';
|
|
10
|
+
import { canMoveToIndex } from '../utils/validation';
|
|
10
11
|
const IGNORE_NODES = ['tableCell', 'tableHeader', 'tableRow', 'layoutColumn'];
|
|
11
12
|
const NESTED_DEPTH = fg('platform_editor_elements_dnd_nested') ? 100 : 0;
|
|
12
|
-
export const dropTargetDecorations = (oldState, newState, api) => {
|
|
13
|
+
export const dropTargetDecorations = (oldState, newState, api, formatMessage, activeNodeType) => {
|
|
13
14
|
const decs = [];
|
|
14
15
|
unmountDecorations('data-blocks-drop-target-container');
|
|
15
16
|
// Decoration state is used to keep track of the position of the drop targets
|
|
@@ -17,8 +18,9 @@ export const dropTargetDecorations = (oldState, newState, api) => {
|
|
|
17
18
|
const decorationState = [];
|
|
18
19
|
let prevNode;
|
|
19
20
|
const state = fg('platform_editor_element_drag_and_drop_ed_24372') ? newState : oldState;
|
|
20
|
-
state.doc.nodesBetween(0, newState.doc.nodeSize - 2, (node, pos,
|
|
21
|
+
state.doc.nodesBetween(0, newState.doc.nodeSize - 2, (node, pos, parent, index) => {
|
|
21
22
|
let depth = 0;
|
|
23
|
+
const nodeType = newState.doc.type.schema.nodes[activeNodeType];
|
|
22
24
|
if (fg('platform_editor_elements_dnd_nested')) {
|
|
23
25
|
depth = newState.doc.resolve(pos).depth;
|
|
24
26
|
if (node.isInline) {
|
|
@@ -27,6 +29,12 @@ export const dropTargetDecorations = (oldState, newState, api) => {
|
|
|
27
29
|
if (IGNORE_NODES.includes(node.type.name)) {
|
|
28
30
|
return true; //skip over, don't consider it a valid depth
|
|
29
31
|
}
|
|
32
|
+
const canDrop = parent && activeNodeType && canMoveToIndex(parent, index, nodeType);
|
|
33
|
+
|
|
34
|
+
//NOTE: This will block drop targets showing for nodes that are valid after transformation (i.e. expand -> nestedExpand)
|
|
35
|
+
if (!canDrop) {
|
|
36
|
+
return false; //not valid pos, so nested not valid either
|
|
37
|
+
}
|
|
30
38
|
decorationState.push({
|
|
31
39
|
id: pos,
|
|
32
40
|
pos
|
|
@@ -40,6 +48,7 @@ export const dropTargetDecorations = (oldState, newState, api) => {
|
|
|
40
48
|
const dropTargetDec = /*#__PURE__*/createElement(DropTarget, {
|
|
41
49
|
api,
|
|
42
50
|
id: fg('platform_editor_elements_dnd_nested') ? pos : index,
|
|
51
|
+
formatMessage,
|
|
43
52
|
prevNode,
|
|
44
53
|
nextNode: node
|
|
45
54
|
});
|
|
@@ -82,7 +91,8 @@ export const dropTargetDecorations = (oldState, newState, api) => {
|
|
|
82
91
|
element.setAttribute('data-blocks-drop-target-container', 'true');
|
|
83
92
|
ReactDOM.render( /*#__PURE__*/createElement(DropTarget, {
|
|
84
93
|
api,
|
|
85
|
-
id: fg('platform_editor_elements_dnd_nested') ? lastPos : decorationState.length
|
|
94
|
+
id: fg('platform_editor_elements_dnd_nested') ? lastPos : decorationState.length,
|
|
95
|
+
formatMessage
|
|
86
96
|
}), element);
|
|
87
97
|
return element;
|
|
88
98
|
}, {
|
|
@@ -4,7 +4,7 @@ import { fg } from '@atlaskit/platform-feature-flags';
|
|
|
4
4
|
import { moveNodeViaShortcut } from '../commands/move-node';
|
|
5
5
|
import { showDragHandleAtSelection } from '../commands/show-drag-handle';
|
|
6
6
|
import { DIRECTION } from '../consts';
|
|
7
|
-
function keymapList(api) {
|
|
7
|
+
function keymapList(api, formatMessage) {
|
|
8
8
|
let keymapList = {};
|
|
9
9
|
if (api && fg('platform_editor_element_drag_and_drop_ed_23873')) {
|
|
10
10
|
bindKeymapWithCommand(showElementDragHandle.common, (state, dispatch, view) => {
|
|
@@ -12,9 +12,9 @@ function keymapList(api) {
|
|
|
12
12
|
//we always want to handle this shortcut to prevent default browser special char insert when option + alphabetical key is used
|
|
13
13
|
return true;
|
|
14
14
|
}, keymapList);
|
|
15
|
-
bindKeymapWithCommand(dragToMoveUp.common, moveNodeViaShortcut(api, DIRECTION.UP), keymapList);
|
|
16
|
-
bindKeymapWithCommand(dragToMoveDown.common, moveNodeViaShortcut(api, DIRECTION.DOWN), keymapList);
|
|
15
|
+
bindKeymapWithCommand(dragToMoveUp.common, moveNodeViaShortcut(api, DIRECTION.UP, formatMessage), keymapList);
|
|
16
|
+
bindKeymapWithCommand(dragToMoveDown.common, moveNodeViaShortcut(api, DIRECTION.DOWN, formatMessage), keymapList);
|
|
17
17
|
}
|
|
18
18
|
return keymapList;
|
|
19
19
|
}
|
|
20
|
-
export const boundKeydownHandler = api => keydownHandler(keymapList(api));
|
|
20
|
+
export const boundKeydownHandler = (api, formatMessage) => keydownHandler(keymapList(api, formatMessage));
|
|
@@ -88,7 +88,7 @@ export const createPlugin = (api, getIntl) => {
|
|
|
88
88
|
return initialState;
|
|
89
89
|
},
|
|
90
90
|
apply(tr, currentState, oldState, newState) {
|
|
91
|
-
var _meta$activeNode, _meta$activeNode$hand, _meta$
|
|
91
|
+
var _meta$activeNode, _meta$activeNode$hand, _meta$activeNode4, _meta$isDragging, _meta$editorHeight, _meta$editorWidthLeft, _meta$editorWidthRigh, _meta$isPMDragging;
|
|
92
92
|
if (initialState.isDocSizeLimitEnabled === null) {
|
|
93
93
|
if (fg('platform.editor.elements.drag-and-drop-doc-size-limit_7k4vq')) {
|
|
94
94
|
initialState.isDocSizeLimitEnabled = true;
|
|
@@ -174,6 +174,9 @@ export const createPlugin = (api, getIntl) => {
|
|
|
174
174
|
// The activeNode is from the previous rendering cycle, and verify if they share the same anchor.
|
|
175
175
|
const maybeNodeWidthUpdated = (meta === null || meta === void 0 ? void 0 : meta.activeNode) && (meta === null || meta === void 0 ? void 0 : (_meta$activeNode = meta.activeNode) === null || _meta$activeNode === void 0 ? void 0 : _meta$activeNode.nodeType) === 'table' && meta.activeNode.anchorName === (activeNode === null || activeNode === void 0 ? void 0 : activeNode.anchorName);
|
|
176
176
|
const redrawDecorations = decorations === DecorationSet.empty || (meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== undefined && (meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== editorHeight || (meta === null || meta === void 0 ? void 0 : meta.editorWidthLeft) !== undefined && (meta === null || meta === void 0 ? void 0 : meta.editorWidthLeft) !== editorWidthLeft || (meta === null || meta === void 0 ? void 0 : meta.editorWidthRight) !== undefined && (meta === null || meta === void 0 ? void 0 : meta.editorWidthRight) !== editorWidthRight || maybeWidthUpdated || nodeCountChanged || maybeNodeWidthUpdated || resizerMeta === false || isDecsMissing || !!(meta !== null && meta !== void 0 && meta.nodeMoved) && tr.docChanged;
|
|
177
|
+
const {
|
|
178
|
+
formatMessage
|
|
179
|
+
} = getIntl();
|
|
177
180
|
|
|
178
181
|
// Draw node and mouseWrapper decorations at top level node if decorations is empty, editor height changes or node is moved
|
|
179
182
|
if (redrawDecorations && !isResizerResizing && api) {
|
|
@@ -259,10 +262,11 @@ export const createPlugin = (api, getIntl) => {
|
|
|
259
262
|
// Add drop targets when node is being dragged
|
|
260
263
|
// if the transaction is only for analytics and user is dragging, continue to draw drop targets
|
|
261
264
|
if (shouldUpdateDropTargets || isBlocksDragTargetDebug()) {
|
|
265
|
+
var _meta$activeNode2;
|
|
262
266
|
const {
|
|
263
267
|
decs,
|
|
264
268
|
decorationState: updatedDecorationState
|
|
265
|
-
} = dropTargetDecorations(oldState, newState, api);
|
|
269
|
+
} = dropTargetDecorations(oldState, newState, api, formatMessage, meta === null || meta === void 0 ? void 0 : (_meta$activeNode2 = meta.activeNode) === null || _meta$activeNode2 === void 0 ? void 0 : _meta$activeNode2.nodeType);
|
|
266
270
|
decorationState = updatedDecorationState;
|
|
267
271
|
decorations = decorations.add(newState.doc, decs);
|
|
268
272
|
}
|
|
@@ -286,10 +290,11 @@ export const createPlugin = (api, getIntl) => {
|
|
|
286
290
|
// if the transaction is only for analytics and user is dragging, continue to draw drop targets
|
|
287
291
|
const shouldShowDragTarget = (meta === null || meta === void 0 ? void 0 : meta.isDragging) && (!tr.docChanged || tr.docChanged && isAnalyticTr);
|
|
288
292
|
if (shouldShowDragTarget || isBlocksDragTargetDebug()) {
|
|
293
|
+
var _meta$activeNode3;
|
|
289
294
|
const {
|
|
290
295
|
decs,
|
|
291
296
|
decorationState: updatedDecorationState
|
|
292
|
-
} = dropTargetDecorations(oldState, newState, api);
|
|
297
|
+
} = dropTargetDecorations(oldState, newState, api, formatMessage, meta === null || meta === void 0 ? void 0 : (_meta$activeNode3 = meta.activeNode) === null || _meta$activeNode3 === void 0 ? void 0 : _meta$activeNode3.nodeType);
|
|
293
298
|
decorationState = updatedDecorationState;
|
|
294
299
|
decorations = decorations.add(newState.doc, decs);
|
|
295
300
|
}
|
|
@@ -347,7 +352,7 @@ export const createPlugin = (api, getIntl) => {
|
|
|
347
352
|
return {
|
|
348
353
|
decorations,
|
|
349
354
|
decorationState,
|
|
350
|
-
activeNode: isEmptyDoc || isHandleMissing ? null : (_meta$
|
|
355
|
+
activeNode: isEmptyDoc || isHandleMissing ? null : (_meta$activeNode4 = meta === null || meta === void 0 ? void 0 : meta.activeNode) !== null && _meta$activeNode4 !== void 0 ? _meta$activeNode4 : mappedActiveNodePos,
|
|
351
356
|
isDragging: (_meta$isDragging = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging !== void 0 ? _meta$isDragging : isDragging,
|
|
352
357
|
isMenuOpen: meta !== null && meta !== void 0 && meta.toggleMenu ? !isMenuOpen : isMenuOpen,
|
|
353
358
|
editorHeight: (_meta$editorHeight = meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== null && _meta$editorHeight !== void 0 ? _meta$editorHeight : currentState.editorHeight,
|
|
@@ -447,11 +452,12 @@ export const createPlugin = (api, getIntl) => {
|
|
|
447
452
|
return true;
|
|
448
453
|
}
|
|
449
454
|
}
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
455
|
+
if (event.shiftKey && event.ctrlKey && fg('platform_editor_element_drag_and_drop_ed_23873')) {
|
|
456
|
+
const {
|
|
457
|
+
formatMessage
|
|
458
|
+
} = getIntl();
|
|
453
459
|
//prevent holding down key combo from firing repeatedly
|
|
454
|
-
if (!event.repeat && boundKeydownHandler(api)(view, event)) {
|
|
460
|
+
if (!event.repeat && boundKeydownHandler(api, formatMessage)(view, event)) {
|
|
455
461
|
event.preventDefault();
|
|
456
462
|
return true;
|
|
457
463
|
}
|