@atlaskit/editor-plugin-block-controls 3.1.1 → 3.1.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 +17 -0
- package/dist/cjs/blockControlsPlugin.js +15 -9
- package/dist/cjs/pm-plugins/decorations-quick-insert-button.js +40 -0
- package/dist/cjs/pm-plugins/handle-mouse-over.js +24 -5
- package/dist/cjs/pm-plugins/main.js +35 -6
- package/dist/cjs/pm-plugins/utils/widget-positions.js +25 -0
- package/dist/cjs/ui/block-menu.js +7 -4
- package/dist/cjs/ui/consts.js +18 -1
- package/dist/cjs/ui/drag-handle.js +6 -2
- package/dist/cjs/ui/quick-insert-button.js +164 -0
- package/dist/es2019/blockControlsPlugin.js +15 -9
- package/dist/es2019/pm-plugins/decorations-quick-insert-button.js +29 -0
- package/dist/es2019/pm-plugins/handle-mouse-over.js +24 -5
- package/dist/es2019/pm-plugins/main.js +35 -7
- package/dist/es2019/pm-plugins/utils/widget-positions.js +20 -0
- package/dist/es2019/ui/block-menu.js +7 -4
- package/dist/es2019/ui/consts.js +17 -0
- package/dist/es2019/ui/drag-handle.js +6 -2
- package/dist/es2019/ui/quick-insert-button.js +152 -0
- package/dist/esm/blockControlsPlugin.js +15 -9
- package/dist/esm/pm-plugins/decorations-quick-insert-button.js +33 -0
- package/dist/esm/pm-plugins/handle-mouse-over.js +24 -5
- package/dist/esm/pm-plugins/main.js +35 -6
- package/dist/esm/pm-plugins/utils/widget-positions.js +20 -0
- package/dist/esm/ui/block-menu.js +7 -4
- package/dist/esm/ui/consts.js +17 -0
- package/dist/esm/ui/drag-handle.js +6 -2
- package/dist/esm/ui/quick-insert-button.js +154 -0
- package/dist/types/blockControlsPluginType.d.ts +7 -1
- package/dist/types/pm-plugins/decorations-quick-insert-button.d.ts +7 -0
- package/dist/types/pm-plugins/main.d.ts +1 -0
- package/dist/types/pm-plugins/utils/widget-positions.d.ts +4 -0
- package/dist/types/ui/consts.d.ts +7 -0
- package/dist/types/ui/quick-insert-button.d.ts +17 -0
- package/dist/types-ts4.5/blockControlsPluginType.d.ts +7 -1
- package/dist/types-ts4.5/pm-plugins/decorations-quick-insert-button.d.ts +7 -0
- package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/utils/widget-positions.d.ts +4 -0
- package/dist/types-ts4.5/ui/consts.d.ts +7 -0
- package/dist/types-ts4.5/ui/quick-insert-button.d.ts +17 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 3.1.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#118581](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/118581)
|
|
8
|
+
[`8e3b48ccfe22f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/8e3b48ccfe22f) -
|
|
9
|
+
Persist block menu while mouse moving
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 3.1.2
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#117869](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/117869)
|
|
17
|
+
[`1668bcd621203`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1668bcd621203) -
|
|
18
|
+
COMPHUB-2622 Added data attributes for editor elements
|
|
19
|
+
|
|
3
20
|
## 3.1.1
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -36,7 +36,7 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
|
|
|
36
36
|
commands: {
|
|
37
37
|
moveNode: (0, _moveNode.moveNode)(api),
|
|
38
38
|
moveToLayout: (0, _moveToLayout.moveToLayout)(api),
|
|
39
|
-
showDragHandleAt: function showDragHandleAt(pos, anchorName, nodeType, handleOptions) {
|
|
39
|
+
showDragHandleAt: function showDragHandleAt(pos, anchorName, nodeType, handleOptions, rootPos, rootAnchorName, rootNodeType) {
|
|
40
40
|
return function (_ref3) {
|
|
41
41
|
var tr = _ref3.tr;
|
|
42
42
|
var currMeta = tr.getMeta(_main.key);
|
|
@@ -45,7 +45,10 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
|
|
|
45
45
|
pos: pos,
|
|
46
46
|
anchorName: anchorName,
|
|
47
47
|
nodeType: nodeType,
|
|
48
|
-
handleOptions: handleOptions
|
|
48
|
+
handleOptions: handleOptions,
|
|
49
|
+
rootPos: rootPos,
|
|
50
|
+
rootAnchorName: rootAnchorName,
|
|
51
|
+
rootNodeType: rootNodeType
|
|
49
52
|
},
|
|
50
53
|
closeMenu: (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? true : undefined
|
|
51
54
|
}));
|
|
@@ -63,7 +66,9 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
|
|
|
63
66
|
return tr;
|
|
64
67
|
}
|
|
65
68
|
tr.setMeta(_main.key, _objectSpread(_objectSpread({}, currMeta), {}, {
|
|
66
|
-
toggleMenu:
|
|
69
|
+
toggleMenu: {
|
|
70
|
+
anchorName: options === null || options === void 0 ? void 0 : options.anchorName
|
|
71
|
+
}
|
|
67
72
|
}));
|
|
68
73
|
return tr;
|
|
69
74
|
};
|
|
@@ -137,17 +142,18 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
|
|
|
137
142
|
}
|
|
138
143
|
},
|
|
139
144
|
getSharedState: function getSharedState(editorState) {
|
|
140
|
-
var _key$getState$isMenuO, _key$getState, _key$getState$
|
|
145
|
+
var _key$getState$isMenuO, _key$getState, _key$getState$menuTri, _key$getState2, _key$getState$activeN, _key$getState3, _key$getState$isDragg, _key$getState4, _key$getState$isPMDra, _key$getState5, _key$getState$multiSe, _key$getState6, _key$getState$isShift, _key$getState7;
|
|
141
146
|
if (!editorState) {
|
|
142
147
|
return undefined;
|
|
143
148
|
}
|
|
144
149
|
return {
|
|
145
150
|
isMenuOpen: (_key$getState$isMenuO = (_key$getState = _main.key.getState(editorState)) === null || _key$getState === void 0 ? void 0 : _key$getState.isMenuOpen) !== null && _key$getState$isMenuO !== void 0 ? _key$getState$isMenuO : false,
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
+
menuTriggerBy: (_key$getState$menuTri = (_key$getState2 = _main.key.getState(editorState)) === null || _key$getState2 === void 0 ? void 0 : _key$getState2.menuTriggerBy) !== null && _key$getState$menuTri !== void 0 ? _key$getState$menuTri : undefined,
|
|
152
|
+
activeNode: (_key$getState$activeN = (_key$getState3 = _main.key.getState(editorState)) === null || _key$getState3 === void 0 ? void 0 : _key$getState3.activeNode) !== null && _key$getState$activeN !== void 0 ? _key$getState$activeN : undefined,
|
|
153
|
+
isDragging: (_key$getState$isDragg = (_key$getState4 = _main.key.getState(editorState)) === null || _key$getState4 === void 0 ? void 0 : _key$getState4.isDragging) !== null && _key$getState$isDragg !== void 0 ? _key$getState$isDragg : false,
|
|
154
|
+
isPMDragging: (_key$getState$isPMDra = (_key$getState5 = _main.key.getState(editorState)) === null || _key$getState5 === void 0 ? void 0 : _key$getState5.isPMDragging) !== null && _key$getState$isPMDra !== void 0 ? _key$getState$isPMDra : false,
|
|
155
|
+
multiSelectDnD: (_key$getState$multiSe = (_key$getState6 = _main.key.getState(editorState)) === null || _key$getState6 === void 0 ? void 0 : _key$getState6.multiSelectDnD) !== null && _key$getState$multiSe !== void 0 ? _key$getState$multiSe : undefined,
|
|
156
|
+
isShiftDown: (_key$getState$isShift = (_key$getState7 = _main.key.getState(editorState)) === null || _key$getState7 === void 0 ? void 0 : _key$getState7.isShiftDown) !== null && _key$getState$isShift !== void 0 ? _key$getState$isShift : undefined
|
|
151
157
|
};
|
|
152
158
|
},
|
|
153
159
|
contentComponent: function contentComponent(_ref7) {
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.quickInsertButtonDecoration = exports.findQuickInsertInsertButtonDecoration = void 0;
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _uuid = _interopRequireDefault(require("uuid"));
|
|
10
|
+
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
11
|
+
var _quickInsertButton = require("../ui/quick-insert-button");
|
|
12
|
+
var TYPE_QUICK_INSERT = 'INSERT_BUTTON';
|
|
13
|
+
var findQuickInsertInsertButtonDecoration = exports.findQuickInsertInsertButtonDecoration = function findQuickInsertInsertButtonDecoration(decorations, from, to) {
|
|
14
|
+
return decorations.find(from, to, function (spec) {
|
|
15
|
+
return spec.type === TYPE_QUICK_INSERT;
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
var quickInsertButtonDecoration = exports.quickInsertButtonDecoration = function quickInsertButtonDecoration(api, formatMessage, rootPos, anchorName, nodeType, nodeViewPortalProviderAPI, rootAnchorName, rootNodeType) {
|
|
19
|
+
var key = (0, _uuid.default)();
|
|
20
|
+
return _view.Decoration.widget(rootPos, function (view, getPos) {
|
|
21
|
+
var element = document.createElement('span');
|
|
22
|
+
element.contentEditable = 'false';
|
|
23
|
+
nodeViewPortalProviderAPI.render(function () {
|
|
24
|
+
return /*#__PURE__*/(0, _react.createElement)(_quickInsertButton.TypeAheadControl, {
|
|
25
|
+
api: api,
|
|
26
|
+
getPos: getPos,
|
|
27
|
+
formatMessage: formatMessage,
|
|
28
|
+
view: view,
|
|
29
|
+
nodeType: nodeType,
|
|
30
|
+
anchorName: anchorName,
|
|
31
|
+
rootAnchorName: rootAnchorName,
|
|
32
|
+
rootNodeType: rootNodeType !== null && rootNodeType !== void 0 ? rootNodeType : nodeType
|
|
33
|
+
});
|
|
34
|
+
}, element, key);
|
|
35
|
+
return element;
|
|
36
|
+
}, {
|
|
37
|
+
side: -1,
|
|
38
|
+
type: TYPE_QUICK_INSERT
|
|
39
|
+
});
|
|
40
|
+
};
|
|
@@ -92,16 +92,35 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, e
|
|
|
92
92
|
// Don't show drag handle for layout column in a single column layout
|
|
93
93
|
return false;
|
|
94
94
|
}
|
|
95
|
-
var
|
|
95
|
+
var targetPos;
|
|
96
96
|
if ((0, _experiments.editorExperiment)('nested-dnd', true)) {
|
|
97
|
-
|
|
97
|
+
targetPos = view.state.doc.resolve(pos).pos;
|
|
98
98
|
} else {
|
|
99
|
-
|
|
99
|
+
targetPos = view.state.doc.resolve(pos).start(1) - 1;
|
|
100
|
+
}
|
|
101
|
+
var rootAnchorName;
|
|
102
|
+
var rootNodeType;
|
|
103
|
+
var rootPos;
|
|
104
|
+
if ((0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
|
|
105
|
+
rootPos = view.state.doc.resolve(pos).before(1);
|
|
106
|
+
if (targetPos !== rootPos) {
|
|
107
|
+
var rootDOM = view.nodeDOM(rootPos);
|
|
108
|
+
if (rootDOM instanceof HTMLElement) {
|
|
109
|
+
var _rootDOM$getAttribute, _rootDOM$getAttribute2;
|
|
110
|
+
rootAnchorName = (_rootDOM$getAttribute = rootDOM.getAttribute('data-drag-handler-anchor-name')) !== null && _rootDOM$getAttribute !== void 0 ? _rootDOM$getAttribute : undefined;
|
|
111
|
+
rootNodeType = (_rootDOM$getAttribute2 = rootDOM.getAttribute('data-drag-handler-node-type')) !== null && _rootDOM$getAttribute2 !== void 0 ? _rootDOM$getAttribute2 : undefined;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
100
114
|
}
|
|
101
115
|
var nodeType = rootElement.getAttribute('data-drag-handler-node-type');
|
|
102
116
|
if (nodeType) {
|
|
103
|
-
|
|
104
|
-
|
|
117
|
+
if ((0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
|
|
118
|
+
var _api$core, _api$blockControls2, _rootPos, _rootAnchorName, _rootNodeType;
|
|
119
|
+
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.commands.showDragHandleAt(targetPos, anchorName, nodeType, undefined, (_rootPos = rootPos) !== null && _rootPos !== void 0 ? _rootPos : targetPos, (_rootAnchorName = rootAnchorName) !== null && _rootAnchorName !== void 0 ? _rootAnchorName : anchorName, (_rootNodeType = rootNodeType) !== null && _rootNodeType !== void 0 ? _rootNodeType : nodeType));
|
|
120
|
+
} else {
|
|
121
|
+
var _api$core2, _api$blockControls3;
|
|
122
|
+
api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(api === null || api === void 0 || (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 ? void 0 : _api$blockControls3.commands.showDragHandleAt(targetPos, anchorName, nodeType));
|
|
123
|
+
}
|
|
105
124
|
}
|
|
106
125
|
}
|
|
107
126
|
};
|
|
@@ -26,6 +26,7 @@ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
|
26
26
|
var _decorationsAnchor = require("./decorations-anchor");
|
|
27
27
|
var _decorationsDragHandle = require("./decorations-drag-handle");
|
|
28
28
|
var _decorationsDropTarget = require("./decorations-drop-target");
|
|
29
|
+
var _decorationsQuickInsertButton = require("./decorations-quick-insert-button");
|
|
29
30
|
var _handleMouseOver = require("./handle-mouse-over");
|
|
30
31
|
var _keymap = require("./keymap");
|
|
31
32
|
var _activeAnchorTracker = require("./utils/active-anchor-tracker");
|
|
@@ -157,7 +158,7 @@ var getDecorations = exports.getDecorations = function getDecorations(state) {
|
|
|
157
158
|
return (_key$getState = key.getState(state)) === null || _key$getState === void 0 ? void 0 : _key$getState.decorations;
|
|
158
159
|
};
|
|
159
160
|
var newApply = exports.newApply = function newApply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, anchorRectCache) {
|
|
160
|
-
var _meta$multiSelectDnD, _meta$activeNode, _activeNode, _activeNode2, _meta$activeNode$hand, _meta$isDragging, _meta$isDragging2, _meta$editorHeight, _meta$editorWidthLeft, _meta$editorWidthRigh, _meta$isPMDragging, _meta$isShiftDown;
|
|
161
|
+
var _meta$multiSelectDnD, _meta$activeNode, _activeNode, _activeNode2, _meta$activeNode$hand, _meta$isDragging, _meta$isDragging2, _meta$toggleMenu, _meta$editorHeight, _meta$editorWidthLeft, _meta$editorWidthRigh, _meta$isPMDragging, _meta$isShiftDown;
|
|
161
162
|
var activeNode = currentState.activeNode,
|
|
162
163
|
decorations = currentState.decorations,
|
|
163
164
|
isResizerResizing = currentState.isResizerResizing,
|
|
@@ -167,6 +168,7 @@ var newApply = exports.newApply = function newApply(api, formatMessage, tr, curr
|
|
|
167
168
|
editorWidthRight = currentState.editorWidthRight,
|
|
168
169
|
isDragging = currentState.isDragging,
|
|
169
170
|
isMenuOpen = currentState.isMenuOpen,
|
|
171
|
+
menuTriggerBy = currentState.menuTriggerBy,
|
|
170
172
|
isPMDragging = currentState.isPMDragging,
|
|
171
173
|
isShiftDown = currentState.isShiftDown;
|
|
172
174
|
var isActiveNodeDeleted = false;
|
|
@@ -180,7 +182,10 @@ var newApply = exports.newApply = function newApply(api, formatMessage, tr, curr
|
|
|
180
182
|
activeNode = {
|
|
181
183
|
pos: mappedPos.pos,
|
|
182
184
|
anchorName: activeNode.anchorName,
|
|
183
|
-
nodeType: activeNode.nodeType
|
|
185
|
+
nodeType: activeNode.nodeType,
|
|
186
|
+
rootPos: activeNode.rootPos,
|
|
187
|
+
rootAnchorName: activeNode.rootAnchorName,
|
|
188
|
+
rootNodeType: activeNode.rootNodeType
|
|
184
189
|
};
|
|
185
190
|
}
|
|
186
191
|
if (multiSelectDnD && flags.isMultiSelectEnabled) {
|
|
@@ -252,12 +257,25 @@ var newApply = exports.newApply = function newApply(api, formatMessage, tr, curr
|
|
|
252
257
|
var _activeNode3, _activeNode4;
|
|
253
258
|
var oldHandle = (0, _decorationsDragHandle.findHandleDec)(decorations, (_activeNode3 = activeNode) === null || _activeNode3 === void 0 ? void 0 : _activeNode3.pos, (_activeNode4 = activeNode) === null || _activeNode4 === void 0 ? void 0 : _activeNode4.pos);
|
|
254
259
|
decorations = decorations.remove(oldHandle);
|
|
260
|
+
if ((0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
|
|
261
|
+
var _activeNode5, _activeNode6;
|
|
262
|
+
var oldQuickInsertButton = (0, _decorationsQuickInsertButton.findQuickInsertInsertButtonDecoration)(decorations, (_activeNode5 = activeNode) === null || _activeNode5 === void 0 ? void 0 : _activeNode5.rootPos, (_activeNode6 = activeNode) === null || _activeNode6 === void 0 ? void 0 : _activeNode6.rootPos);
|
|
263
|
+
decorations = decorations.remove(oldQuickInsertButton);
|
|
264
|
+
}
|
|
255
265
|
} else if (api && shouldRecreateHandle) {
|
|
256
|
-
var
|
|
257
|
-
var _oldHandle = (0, _decorationsDragHandle.findHandleDec)(decorations, (
|
|
266
|
+
var _activeNode7, _activeNode8;
|
|
267
|
+
var _oldHandle = (0, _decorationsDragHandle.findHandleDec)(decorations, (_activeNode7 = activeNode) === null || _activeNode7 === void 0 ? void 0 : _activeNode7.pos, (_activeNode8 = activeNode) === null || _activeNode8 === void 0 ? void 0 : _activeNode8.pos);
|
|
258
268
|
decorations = decorations.remove(_oldHandle);
|
|
259
269
|
var handleDec = (0, _decorationsDragHandle.dragHandleDecoration)(api, formatMessage, latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.pos, latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.anchorName, latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.nodeType, nodeViewPortalProviderAPI, latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.handleOptions);
|
|
260
|
-
|
|
270
|
+
if ((0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
|
|
271
|
+
var _activeNode9, _activeNode10;
|
|
272
|
+
var _oldQuickInsertButton = (0, _decorationsQuickInsertButton.findQuickInsertInsertButtonDecoration)(decorations, (_activeNode9 = activeNode) === null || _activeNode9 === void 0 ? void 0 : _activeNode9.rootPos, (_activeNode10 = activeNode) === null || _activeNode10 === void 0 ? void 0 : _activeNode10.rootPos);
|
|
273
|
+
decorations = decorations.remove(_oldQuickInsertButton);
|
|
274
|
+
var quickInsertButton = (0, _decorationsQuickInsertButton.quickInsertButtonDecoration)(api, formatMessage, latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.rootPos, latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.anchorName, latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.nodeType, nodeViewPortalProviderAPI, latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.rootAnchorName, latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.rootNodeType);
|
|
275
|
+
decorations = decorations.add(newState.doc, [handleDec, quickInsertButton]);
|
|
276
|
+
} else {
|
|
277
|
+
decorations = decorations.add(newState.doc, [handleDec]);
|
|
278
|
+
}
|
|
261
279
|
}
|
|
262
280
|
|
|
263
281
|
// Drop targets may be missing when the node count is being changed during a drag
|
|
@@ -284,12 +302,23 @@ var newApply = exports.newApply = function newApply(api, formatMessage, tr, curr
|
|
|
284
302
|
}
|
|
285
303
|
}
|
|
286
304
|
var newActiveNode = isEmptyDoc || !(meta !== null && meta !== void 0 && meta.activeNode) && (0, _decorationsDragHandle.findHandleDec)(decorations, latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.pos, latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.pos).length === 0 ? null : latestActiveNode;
|
|
287
|
-
var isMenuOpenNew =
|
|
305
|
+
var isMenuOpenNew = isMenuOpen;
|
|
306
|
+
if ((0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
|
|
307
|
+
if (meta !== null && meta !== void 0 && meta.closeMenu) {
|
|
308
|
+
isMenuOpenNew = false;
|
|
309
|
+
} else if (meta !== null && meta !== void 0 && meta.toggleMenu) {
|
|
310
|
+
var isSameAnchor = (meta === null || meta === void 0 ? void 0 : meta.toggleMenu.anchorName) === menuTriggerBy;
|
|
311
|
+
isMenuOpenNew = menuTriggerBy === undefined || isSameAnchor || !isMenuOpen && !isSameAnchor ? !isMenuOpen : isMenuOpen;
|
|
312
|
+
}
|
|
313
|
+
} else if (meta !== null && meta !== void 0 && meta.toggleMenu) {
|
|
314
|
+
isMenuOpenNew = !isMenuOpen;
|
|
315
|
+
}
|
|
288
316
|
return {
|
|
289
317
|
decorations: decorations,
|
|
290
318
|
activeNode: newActiveNode,
|
|
291
319
|
isDragging: (_meta$isDragging2 = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging2 !== void 0 ? _meta$isDragging2 : isDragging,
|
|
292
320
|
isMenuOpen: isMenuOpenNew,
|
|
321
|
+
menuTriggerBy: (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? (meta === null || meta === void 0 || (_meta$toggleMenu = meta.toggleMenu) === null || _meta$toggleMenu === void 0 ? void 0 : _meta$toggleMenu.anchorName) || menuTriggerBy : undefined,
|
|
293
322
|
editorHeight: (_meta$editorHeight = meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== null && _meta$editorHeight !== void 0 ? _meta$editorHeight : editorHeight,
|
|
294
323
|
editorWidthLeft: (_meta$editorWidthLeft = meta === null || meta === void 0 ? void 0 : meta.editorWidthLeft) !== null && _meta$editorWidthLeft !== void 0 ? _meta$editorWidthLeft : editorWidthLeft,
|
|
295
324
|
editorWidthRight: (_meta$editorWidthRigh = meta === null || meta === void 0 ? void 0 : meta.editorWidthRight) !== null && _meta$editorWidthRigh !== void 0 ? _meta$editorWidthRigh : editorWidthRight,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getLeftPositionForRootElement = void 0;
|
|
7
|
+
var _consts = require("../../ui/consts");
|
|
8
|
+
// Adapted from `src/pm-plugins/utils/drag-handle-positions.ts`
|
|
9
|
+
// CHANGES - removed parentNodeType, use only for positioning widgets for top level element
|
|
10
|
+
// CHANGES - removed layout
|
|
11
|
+
// CHANGES - added overrides for constants for widget dimensions
|
|
12
|
+
var getLeftPositionForRootElement = exports.getLeftPositionForRootElement = function getLeftPositionForRootElement(dom, nodeType, widgetDimensions, innerContainer, macroInteractionUpdates) {
|
|
13
|
+
if (!dom) {
|
|
14
|
+
return 'auto';
|
|
15
|
+
}
|
|
16
|
+
if (!innerContainer) {
|
|
17
|
+
return "".concat(dom.offsetLeft - (0, _consts.rootElementGap)(nodeType) - widgetDimensions.width, "px");
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// There is a showMacroInteractionDesignUpdates prop in extension node wrapper that can add a relative span under the top level div
|
|
21
|
+
// We need to adjust the left offset position of the drag handle to account for the relative span
|
|
22
|
+
var relativeSpan = macroInteractionUpdates ? dom.querySelector('span.relative') : null;
|
|
23
|
+
var leftAdjustment = relativeSpan ? relativeSpan.offsetLeft : 0;
|
|
24
|
+
return getComputedStyle(innerContainer).transform === 'none' ? "".concat(innerContainer.offsetLeft + leftAdjustment - (0, _consts.rootElementGap)(nodeType) - widgetDimensions.width, "px") : "".concat(innerContainer.offsetLeft + leftAdjustment - innerContainer.offsetWidth / 2 - (0, _consts.rootElementGap)(nodeType) - widgetDimensions.width, "px");
|
|
25
|
+
};
|
|
@@ -13,7 +13,6 @@ var _uiMenu = require("@atlaskit/editor-common/ui-menu");
|
|
|
13
13
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
14
14
|
var _blockMenuItems = require("./block-menu-items");
|
|
15
15
|
var _consts = require("./consts");
|
|
16
|
-
var dragHandleSelector = '[data-blocks-drag-handle-container="true"] button';
|
|
17
16
|
var BlockMenu = function BlockMenu(_ref) {
|
|
18
17
|
var editorView = _ref.editorView,
|
|
19
18
|
mountPoint = _ref.mountPoint,
|
|
@@ -26,7 +25,8 @@ var BlockMenu = function BlockMenu(_ref) {
|
|
|
26
25
|
if (!(blockControlsState !== null && blockControlsState !== void 0 && blockControlsState.isMenuOpen)) {
|
|
27
26
|
return null;
|
|
28
27
|
}
|
|
29
|
-
var
|
|
28
|
+
var activeNodeSelector = "[data-drag-handler-anchor-name=".concat(blockControlsState === null || blockControlsState === void 0 ? void 0 : blockControlsState.menuTriggerBy, "]");
|
|
29
|
+
var targetHandleRef = document.querySelector(activeNodeSelector);
|
|
30
30
|
var items = (0, _blockMenuItems.getBlockMenuItems)(formatMessage);
|
|
31
31
|
var handleOpenChange = function handleOpenChange(payload) {
|
|
32
32
|
if (!(payload !== null && payload !== void 0 && payload.isOpen)) {
|
|
@@ -40,10 +40,13 @@ var BlockMenu = function BlockMenu(_ref) {
|
|
|
40
40
|
if (editorView) {
|
|
41
41
|
var _menuItemsCallback, _menuItemsCallback$ca;
|
|
42
42
|
(_menuItemsCallback = _blockMenuItems.menuItemsCallback[item.value.name]) === null || _menuItemsCallback === void 0 || (_menuItemsCallback$ca = _menuItemsCallback.call(_blockMenuItems.menuItemsCallback, api, formatMessage)) === null || _menuItemsCallback$ca === void 0 || _menuItemsCallback$ca(editorView.state, editorView.dispatch, editorView);
|
|
43
|
+
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.toggleBlockMenu({
|
|
44
|
+
closeMenu: true
|
|
45
|
+
}));
|
|
43
46
|
}
|
|
44
47
|
};
|
|
45
48
|
return /*#__PURE__*/_react.default.createElement(_ui.Popup, {
|
|
46
|
-
alignX: '
|
|
49
|
+
alignX: 'left',
|
|
47
50
|
alignY: 'start'
|
|
48
51
|
// Ignored via go/ees005
|
|
49
52
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
@@ -53,7 +56,7 @@ var BlockMenu = function BlockMenu(_ref) {
|
|
|
53
56
|
zIndex: _editorSharedStyles.akEditorFloatingOverlapPanelZIndex,
|
|
54
57
|
forcePlacement: true,
|
|
55
58
|
stick: true,
|
|
56
|
-
offset: [-
|
|
59
|
+
offset: [-6, 8]
|
|
57
60
|
}, /*#__PURE__*/_react.default.createElement(_uiMenu.DropdownMenu, {
|
|
58
61
|
mountTo: mountPoint,
|
|
59
62
|
boundariesElement: boundariesElement,
|
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.spacingBetweenNodesForPreview = exports.spaceLookupMap = exports.nodeMargins = exports.getNestedNodeLeftPaddingMargin = exports.dropTargetMarginMap = exports.dragHandleGap = exports.DRAG_HANDLE_ZINDEX = exports.DRAG_HANDLE_WIDTH = exports.DRAG_HANDLE_PARAGRAPH_TOP_ADJUSTMENT = exports.DRAG_HANDLE_NARROW_GAP = exports.DRAG_HANDLE_MAX_WIDTH_PLUS_GAP = exports.DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH = exports.DRAG_HANDLE_MAX_GAP = exports.DRAG_HANDLE_LAYOUT_SECTION_TOP_ADJUSTMENT = 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_H2_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H1_TOP_ADJUSTMENT = exports.DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT = exports.DRAG_HANDLE_DEFAULT_GAP = exports.DRAG_HANDLE_BORDER_RADIUS = exports.DEFAULT_COLUMN_DISTRIBUTIONS = exports.BLOCK_MENU_WIDTH = void 0;
|
|
7
|
+
exports.topPositionAdjustment = exports.spacingBetweenNodesForPreview = exports.spaceLookupMap = exports.rootElementGap = exports.nodeMargins = exports.getNestedNodeLeftPaddingMargin = exports.dropTargetMarginMap = exports.dragHandleGap = exports.QUICK_INSERT_WIDTH = exports.QUICK_INSERT_HEIGHT = exports.QUICK_INSERT_DIMENSIONS = exports.DRAG_HANDLE_ZINDEX = exports.DRAG_HANDLE_WIDTH = exports.DRAG_HANDLE_PARAGRAPH_TOP_ADJUSTMENT = exports.DRAG_HANDLE_NARROW_GAP = exports.DRAG_HANDLE_MAX_WIDTH_PLUS_GAP = exports.DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH = exports.DRAG_HANDLE_MAX_GAP = exports.DRAG_HANDLE_LAYOUT_SECTION_TOP_ADJUSTMENT = 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_H2_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H1_TOP_ADJUSTMENT = exports.DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT = exports.DRAG_HANDLE_DEFAULT_GAP = exports.DRAG_HANDLE_BORDER_RADIUS = exports.DEFAULT_COLUMN_DISTRIBUTIONS = exports.BLOCK_MENU_WIDTH = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
10
10
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
@@ -35,6 +35,12 @@ var DRAG_HANDLE_PARAGRAPH_TOP_ADJUSTMENT = exports.DRAG_HANDLE_PARAGRAPH_TOP_ADJ
|
|
|
35
35
|
* so we allow for some leniency to capture them all. e.g. Table is depth 3.
|
|
36
36
|
*/
|
|
37
37
|
var DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH = exports.DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH = 3;
|
|
38
|
+
var QUICK_INSERT_HEIGHT = exports.QUICK_INSERT_HEIGHT = 24;
|
|
39
|
+
var QUICK_INSERT_WIDTH = exports.QUICK_INSERT_WIDTH = 24;
|
|
40
|
+
var QUICK_INSERT_DIMENSIONS = exports.QUICK_INSERT_DIMENSIONS = {
|
|
41
|
+
width: QUICK_INSERT_WIDTH,
|
|
42
|
+
height: QUICK_INSERT_HEIGHT
|
|
43
|
+
};
|
|
38
44
|
var nodeTypeExcludeList = ['embedCard', 'mediaSingle', 'table'];
|
|
39
45
|
var dragHandleGap = exports.dragHandleGap = function dragHandleGap(nodeType, parentNodeType) {
|
|
40
46
|
if (nodeType === 'layoutSection' && (0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_2')) {
|
|
@@ -51,6 +57,17 @@ var dragHandleGap = exports.dragHandleGap = function dragHandleGap(nodeType, par
|
|
|
51
57
|
}
|
|
52
58
|
return DRAG_HANDLE_DEFAULT_GAP;
|
|
53
59
|
};
|
|
60
|
+
|
|
61
|
+
// use for returning hap only for root level elements
|
|
62
|
+
var rootElementGap = exports.rootElementGap = function rootElementGap(nodeType) {
|
|
63
|
+
if (nodeTypeExcludeList.includes(nodeType)) {
|
|
64
|
+
return DRAG_HANDLE_MAX_GAP;
|
|
65
|
+
}
|
|
66
|
+
if (nodeType === 'layoutSection') {
|
|
67
|
+
return DRAG_HANDLE_MAX_GAP + 12;
|
|
68
|
+
}
|
|
69
|
+
return DRAG_HANDLE_DEFAULT_GAP;
|
|
70
|
+
};
|
|
54
71
|
var getNestedNodeLeftPaddingMargin = exports.getNestedNodeLeftPaddingMargin = function getNestedNodeLeftPaddingMargin(nodeType) {
|
|
55
72
|
switch (nodeType) {
|
|
56
73
|
case 'bodiedExtension':
|
|
@@ -192,9 +192,12 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
192
192
|
tr = (0, _getSelection.selectNode)(tr, startPos, nodeType);
|
|
193
193
|
if ((0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
|
|
194
194
|
var _api$blockControls;
|
|
195
|
-
api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || _api$blockControls.commands.toggleBlockMenu(
|
|
195
|
+
api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || _api$blockControls.commands.toggleBlockMenu({
|
|
196
|
+
anchorName: anchorName
|
|
197
|
+
})({
|
|
196
198
|
tr: tr
|
|
197
199
|
});
|
|
200
|
+
e.stopPropagation();
|
|
198
201
|
}
|
|
199
202
|
} else if (isTopLevelNode && $anchor.depth <= _consts.DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH && e.shiftKey) {
|
|
200
203
|
var _api$blockControls2;
|
|
@@ -221,7 +224,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
221
224
|
return tr;
|
|
222
225
|
});
|
|
223
226
|
view.focus();
|
|
224
|
-
}, [isMultiSelect, api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, api === null || api === void 0 || (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 ? void 0 : _api$blockControls3.commands, view, dragHandleSelected, getPos, multiSelectDnD === null || multiSelectDnD === void 0 ? void 0 : multiSelectDnD.anchor, isTopLevelNode, nodeType]);
|
|
227
|
+
}, [isMultiSelect, api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, api === null || api === void 0 || (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 ? void 0 : _api$blockControls3.commands, view, dragHandleSelected, getPos, multiSelectDnD === null || multiSelectDnD === void 0 ? void 0 : multiSelectDnD.anchor, isTopLevelNode, nodeType, anchorName]);
|
|
225
228
|
|
|
226
229
|
// TODO - This needs to be investigated further. Drag preview generation is not always working
|
|
227
230
|
// as expected with a node selection. This workaround sets the selection to the node on mouseDown,
|
|
@@ -624,6 +627,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
624
627
|
,
|
|
625
628
|
onDrop: handleOnDrop,
|
|
626
629
|
disabled: dragHandleDisabled,
|
|
630
|
+
"data-editor-block-ctrl-drag-handle": true,
|
|
627
631
|
"data-testid": "block-ctrl-drag-handle"
|
|
628
632
|
}, (0, _react2.jsx)(_primitives.Box, {
|
|
629
633
|
as: "span",
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.TypeAheadControl = void 0;
|
|
9
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _bindEventListener = require("bind-event-listener");
|
|
12
|
+
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
13
|
+
var _messages = require("@atlaskit/editor-common/messages");
|
|
14
|
+
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
15
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
16
|
+
var _add = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/add"));
|
|
17
|
+
var _primitives = require("@atlaskit/primitives");
|
|
18
|
+
var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
|
|
19
|
+
var _dragHandlePositions = require("../pm-plugins/utils/drag-handle-positions");
|
|
20
|
+
var _widgetPositions = require("../pm-plugins/utils/widget-positions");
|
|
21
|
+
var _consts = require("./consts");
|
|
22
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
23
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
24
|
+
var buttonStyles = (0, _primitives.xcss)({
|
|
25
|
+
boxSizing: 'border-box',
|
|
26
|
+
display: 'flex',
|
|
27
|
+
flexDirection: 'column',
|
|
28
|
+
justifyContent: 'center',
|
|
29
|
+
alignItems: 'center',
|
|
30
|
+
height: "var(--ds-space-300, 24px)",
|
|
31
|
+
width: "var(--ds-space-300, 24px)",
|
|
32
|
+
border: 'none',
|
|
33
|
+
backgroundColor: 'color.background.neutral',
|
|
34
|
+
borderRadius: '50%',
|
|
35
|
+
color: 'color.text.accent.gray',
|
|
36
|
+
zIndex: 'card',
|
|
37
|
+
outline: 'none',
|
|
38
|
+
':hover': {
|
|
39
|
+
backgroundColor: 'color.background.neutral.hovered'
|
|
40
|
+
},
|
|
41
|
+
':active': {
|
|
42
|
+
backgroundColor: 'color.background.neutral.pressed'
|
|
43
|
+
},
|
|
44
|
+
':focus': {
|
|
45
|
+
outline: "2px solid ".concat("var(--ds-border-focused, #388BFF)")
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
var containerStaticStyles = (0, _primitives.xcss)({
|
|
49
|
+
position: 'absolute',
|
|
50
|
+
zIndex: 'card'
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// TODO: Share prop types between DragHandle - generic enough to create a type for block control decoration
|
|
54
|
+
|
|
55
|
+
var TypeAheadControl = exports.TypeAheadControl = function TypeAheadControl(_ref) {
|
|
56
|
+
var view = _ref.view,
|
|
57
|
+
api = _ref.api,
|
|
58
|
+
formatMessage = _ref.formatMessage,
|
|
59
|
+
getPos = _ref.getPos,
|
|
60
|
+
nodeType = _ref.nodeType,
|
|
61
|
+
anchorName = _ref.anchorName,
|
|
62
|
+
rootAnchorName = _ref.rootAnchorName,
|
|
63
|
+
rootNodeType = _ref.rootNodeType;
|
|
64
|
+
var macroInteractionUpdates = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'featureFlags.macroInteractionUpdates');
|
|
65
|
+
var _useState = (0, _react.useState)({}),
|
|
66
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
67
|
+
positionStyles = _useState2[0],
|
|
68
|
+
setPositionStyles = _useState2[1];
|
|
69
|
+
|
|
70
|
+
// Adapted from `src/ui/drag-handle.tsx` as positioning logic is similar
|
|
71
|
+
// CHANGES - added an offset so quick insert button can be positioned beside drag handle
|
|
72
|
+
// CHANGES - removed `editorExperiment('nested-dnd', true)` check and rootNodeType calculation
|
|
73
|
+
// CHANGES - replace anchorName with rootAnchorName
|
|
74
|
+
// CHANGES - `removed editorExperiment('advanced_layouts', true) && isLayoutColumn` checks as quick insert button will not be positioned for layout column
|
|
75
|
+
var calculatePosition = (0, _react.useCallback)(function () {
|
|
76
|
+
var supportsAnchor = CSS.supports('top', "anchor(".concat(rootAnchorName, " start)")) && CSS.supports('left', "anchor(".concat(rootAnchorName, " start)"));
|
|
77
|
+
var dom = view.dom.querySelector("[data-drag-handler-anchor-name=\"".concat(rootAnchorName, "\"]"));
|
|
78
|
+
var hasResizer = rootNodeType === 'table' || rootNodeType === 'mediaSingle';
|
|
79
|
+
var isExtension = rootNodeType === 'extension' || rootNodeType === 'bodiedExtension';
|
|
80
|
+
var isBlockCard = rootNodeType === 'blockCard';
|
|
81
|
+
var isEmbedCard = rootNodeType === 'embedCard';
|
|
82
|
+
var isMacroInteractionUpdates = macroInteractionUpdates && isExtension;
|
|
83
|
+
var innerContainer = null;
|
|
84
|
+
if (dom) {
|
|
85
|
+
if (isEmbedCard) {
|
|
86
|
+
innerContainer = dom.querySelector('.rich-media-item');
|
|
87
|
+
} else if (hasResizer) {
|
|
88
|
+
innerContainer = dom.querySelector('.resizer-item');
|
|
89
|
+
} else if (isExtension) {
|
|
90
|
+
innerContainer = dom.querySelector('.extension-container[data-layout]');
|
|
91
|
+
} else if (isBlockCard) {
|
|
92
|
+
//specific to datasource blockCard
|
|
93
|
+
innerContainer = dom.querySelector('.datasourceView-content-inner-wrap');
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
var isEdgeCase = (hasResizer || isExtension || isEmbedCard || isBlockCard) && innerContainer;
|
|
97
|
+
var neighboringWidthOffset = anchorName === rootAnchorName ? '-16px' : '0px';
|
|
98
|
+
if (supportsAnchor) {
|
|
99
|
+
return {
|
|
100
|
+
left: isEdgeCase ? "calc(anchor(".concat(rootAnchorName, " start) + ").concat((0, _widgetPositions.getLeftPositionForRootElement)(dom, rootNodeType, _consts.QUICK_INSERT_DIMENSIONS, innerContainer, isMacroInteractionUpdates), " + ").concat(neighboringWidthOffset, ")") : "calc(anchor(".concat(rootAnchorName, " start) - ").concat(_consts.QUICK_INSERT_DIMENSIONS.width, "px - ").concat((0, _consts.rootElementGap)(rootNodeType), "px + ").concat(neighboringWidthOffset, ")"),
|
|
101
|
+
top: "calc(anchor(".concat(rootAnchorName, " start) + ").concat((0, _consts.topPositionAdjustment)(rootNodeType), "px)")
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
left: isEdgeCase ? "calc(".concat((dom === null || dom === void 0 ? void 0 : dom.offsetLeft) || 0, "px + ").concat((0, _widgetPositions.getLeftPositionForRootElement)(dom, rootNodeType, _consts.QUICK_INSERT_DIMENSIONS, innerContainer, isMacroInteractionUpdates), " + ").concat(neighboringWidthOffset, ")") : "calc(".concat((0, _widgetPositions.getLeftPositionForRootElement)(dom, rootNodeType, _consts.QUICK_INSERT_DIMENSIONS, innerContainer, isMacroInteractionUpdates), " + ").concat(neighboringWidthOffset, ")"),
|
|
106
|
+
top: (0, _dragHandlePositions.getTopPosition)(dom, rootNodeType)
|
|
107
|
+
};
|
|
108
|
+
}, [rootAnchorName, view.dom, rootNodeType, macroInteractionUpdates, anchorName]);
|
|
109
|
+
(0, _react.useEffect)(function () {
|
|
110
|
+
var cleanUpTransitionListener;
|
|
111
|
+
if (rootNodeType === 'extension' || rootNodeType === 'embedCard') {
|
|
112
|
+
var dom = view.dom.querySelector("[data-drag-handler-anchor-name=\"".concat(rootAnchorName, "\"]"));
|
|
113
|
+
if (!dom) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
cleanUpTransitionListener = (0, _bindEventListener.bind)(dom, {
|
|
117
|
+
type: 'transitionend',
|
|
118
|
+
listener: function listener() {
|
|
119
|
+
setPositionStyles(calculatePosition());
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
var calcPos = requestAnimationFrame(function () {
|
|
124
|
+
setPositionStyles(calculatePosition());
|
|
125
|
+
});
|
|
126
|
+
return function () {
|
|
127
|
+
var _cleanUpTransitionLis;
|
|
128
|
+
cancelAnimationFrame(calcPos);
|
|
129
|
+
(_cleanUpTransitionLis = cleanUpTransitionListener) === null || _cleanUpTransitionLis === void 0 || _cleanUpTransitionLis();
|
|
130
|
+
};
|
|
131
|
+
}, [calculatePosition, view.dom, rootAnchorName, rootNodeType]);
|
|
132
|
+
return (
|
|
133
|
+
/*#__PURE__*/
|
|
134
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
135
|
+
_react.default.createElement(_primitives.Box, {
|
|
136
|
+
style: positionStyles,
|
|
137
|
+
xcss: [containerStaticStyles]
|
|
138
|
+
}, /*#__PURE__*/_react.default.createElement(_tooltip.default, {
|
|
139
|
+
content: /*#__PURE__*/_react.default.createElement(_keymaps.ToolTipContent, {
|
|
140
|
+
description: formatMessage(_messages.blockControlsMessages.insert),
|
|
141
|
+
shortcutOverride: "/"
|
|
142
|
+
})
|
|
143
|
+
}, /*#__PURE__*/_react.default.createElement(_primitives.Pressable, {
|
|
144
|
+
type: "button",
|
|
145
|
+
"aria-label": formatMessage(_messages.blockControlsMessages.insert),
|
|
146
|
+
xcss: [buttonStyles],
|
|
147
|
+
onClick: function onClick() {
|
|
148
|
+
var _api$core, _api$quickInsert;
|
|
149
|
+
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref2) {
|
|
150
|
+
var tr = _ref2.tr;
|
|
151
|
+
var start = getPos();
|
|
152
|
+
if (!start) {
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
return tr.setSelection(_state.TextSelection.create(tr.doc, start));
|
|
156
|
+
});
|
|
157
|
+
api === null || api === void 0 || (_api$quickInsert = api.quickInsert) === null || _api$quickInsert === void 0 || _api$quickInsert.actions.openTypeAhead('blockControl');
|
|
158
|
+
}
|
|
159
|
+
}, /*#__PURE__*/_react.default.createElement(_add.default, {
|
|
160
|
+
label: "add",
|
|
161
|
+
size: "medium"
|
|
162
|
+
}))))
|
|
163
|
+
);
|
|
164
|
+
};
|
|
@@ -25,7 +25,7 @@ export const blockControlsPlugin = ({
|
|
|
25
25
|
commands: {
|
|
26
26
|
moveNode: moveNode(api),
|
|
27
27
|
moveToLayout: moveToLayout(api),
|
|
28
|
-
showDragHandleAt: (pos, anchorName, nodeType, handleOptions) => ({
|
|
28
|
+
showDragHandleAt: (pos, anchorName, nodeType, handleOptions, rootPos, rootAnchorName, rootNodeType) => ({
|
|
29
29
|
tr
|
|
30
30
|
}) => {
|
|
31
31
|
const currMeta = tr.getMeta(key);
|
|
@@ -35,7 +35,10 @@ export const blockControlsPlugin = ({
|
|
|
35
35
|
pos,
|
|
36
36
|
anchorName,
|
|
37
37
|
nodeType,
|
|
38
|
-
handleOptions
|
|
38
|
+
handleOptions,
|
|
39
|
+
rootPos,
|
|
40
|
+
rootAnchorName,
|
|
41
|
+
rootNodeType
|
|
39
42
|
},
|
|
40
43
|
closeMenu: editorExperiment('platform_editor_controls', 'variant1') ? true : undefined
|
|
41
44
|
});
|
|
@@ -54,7 +57,9 @@ export const blockControlsPlugin = ({
|
|
|
54
57
|
}
|
|
55
58
|
tr.setMeta(key, {
|
|
56
59
|
...currMeta,
|
|
57
|
-
toggleMenu:
|
|
60
|
+
toggleMenu: {
|
|
61
|
+
anchorName: options === null || options === void 0 ? void 0 : options.anchorName
|
|
62
|
+
}
|
|
58
63
|
});
|
|
59
64
|
return tr;
|
|
60
65
|
},
|
|
@@ -128,17 +133,18 @@ export const blockControlsPlugin = ({
|
|
|
128
133
|
}
|
|
129
134
|
},
|
|
130
135
|
getSharedState(editorState) {
|
|
131
|
-
var _key$getState$isMenuO, _key$getState, _key$getState$
|
|
136
|
+
var _key$getState$isMenuO, _key$getState, _key$getState$menuTri, _key$getState2, _key$getState$activeN, _key$getState3, _key$getState$isDragg, _key$getState4, _key$getState$isPMDra, _key$getState5, _key$getState$multiSe, _key$getState6, _key$getState$isShift, _key$getState7;
|
|
132
137
|
if (!editorState) {
|
|
133
138
|
return undefined;
|
|
134
139
|
}
|
|
135
140
|
return {
|
|
136
141
|
isMenuOpen: (_key$getState$isMenuO = (_key$getState = key.getState(editorState)) === null || _key$getState === void 0 ? void 0 : _key$getState.isMenuOpen) !== null && _key$getState$isMenuO !== void 0 ? _key$getState$isMenuO : false,
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
+
menuTriggerBy: (_key$getState$menuTri = (_key$getState2 = key.getState(editorState)) === null || _key$getState2 === void 0 ? void 0 : _key$getState2.menuTriggerBy) !== null && _key$getState$menuTri !== void 0 ? _key$getState$menuTri : undefined,
|
|
143
|
+
activeNode: (_key$getState$activeN = (_key$getState3 = key.getState(editorState)) === null || _key$getState3 === void 0 ? void 0 : _key$getState3.activeNode) !== null && _key$getState$activeN !== void 0 ? _key$getState$activeN : undefined,
|
|
144
|
+
isDragging: (_key$getState$isDragg = (_key$getState4 = key.getState(editorState)) === null || _key$getState4 === void 0 ? void 0 : _key$getState4.isDragging) !== null && _key$getState$isDragg !== void 0 ? _key$getState$isDragg : false,
|
|
145
|
+
isPMDragging: (_key$getState$isPMDra = (_key$getState5 = key.getState(editorState)) === null || _key$getState5 === void 0 ? void 0 : _key$getState5.isPMDragging) !== null && _key$getState$isPMDra !== void 0 ? _key$getState$isPMDra : false,
|
|
146
|
+
multiSelectDnD: (_key$getState$multiSe = (_key$getState6 = key.getState(editorState)) === null || _key$getState6 === void 0 ? void 0 : _key$getState6.multiSelectDnD) !== null && _key$getState$multiSe !== void 0 ? _key$getState$multiSe : undefined,
|
|
147
|
+
isShiftDown: (_key$getState$isShift = (_key$getState7 = key.getState(editorState)) === null || _key$getState7 === void 0 ? void 0 : _key$getState7.isShiftDown) !== null && _key$getState$isShift !== void 0 ? _key$getState$isShift : undefined
|
|
142
148
|
};
|
|
143
149
|
},
|
|
144
150
|
contentComponent({
|