@atlaskit/editor-plugin-block-controls 3.11.1 → 3.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/dist/cjs/ui/block-menu.js +19 -3
- package/dist/cjs/ui/drag-handle-menu.js +10 -2
- package/dist/cjs/ui/drag-handle.js +7 -2
- package/dist/cjs/ui/drop-target.js +13 -4
- package/dist/es2019/ui/block-menu.js +19 -3
- package/dist/es2019/ui/drag-handle-menu.js +10 -2
- package/dist/es2019/ui/drag-handle.js +7 -2
- package/dist/es2019/ui/drop-target.js +13 -4
- package/dist/esm/ui/block-menu.js +19 -3
- package/dist/esm/ui/drag-handle-menu.js +10 -2
- package/dist/esm/ui/drag-handle.js +7 -2
- package/dist/esm/ui/drop-target.js +13 -4
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 3.11.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#144898](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/144898)
|
|
8
|
+
[`b9a10d6716ef4`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b9a10d6716ef4) -
|
|
9
|
+
Enable useSharedPluginStateSelector in block-controls, block-type and breakout plugins
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
3
12
|
## 3.11.1
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
|
@@ -10,7 +10,9 @@ var _reactIntlNext = require("react-intl-next");
|
|
|
10
10
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
11
11
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
12
12
|
var _uiMenu = require("@atlaskit/editor-common/ui-menu");
|
|
13
|
+
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
13
14
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
15
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
14
16
|
var _blockMenuItems = require("./block-menu-items");
|
|
15
17
|
var _consts = require("./consts");
|
|
16
18
|
var BlockMenu = function BlockMenu(_ref) {
|
|
@@ -20,12 +22,26 @@ var BlockMenu = function BlockMenu(_ref) {
|
|
|
20
22
|
scrollableElement = _ref.scrollableElement,
|
|
21
23
|
api = _ref.api,
|
|
22
24
|
formatMessage = _ref.intl.formatMessage;
|
|
23
|
-
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['blockControls']
|
|
25
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['blockControls'], {
|
|
26
|
+
disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true)
|
|
27
|
+
}),
|
|
24
28
|
blockControlsState = _useSharedPluginState.blockControlsState;
|
|
25
|
-
|
|
29
|
+
|
|
30
|
+
// isMenuOpen
|
|
31
|
+
var isMenuOpenSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockControls.isMenuOpen', {
|
|
32
|
+
disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
|
|
33
|
+
});
|
|
34
|
+
var isMenuOpen = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? isMenuOpenSelector : blockControlsState === null || blockControlsState === void 0 ? void 0 : blockControlsState.isMenuOpen;
|
|
35
|
+
|
|
36
|
+
// menuTriggerBy
|
|
37
|
+
var menuTriggerBySelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockControls.menuTriggerBy', {
|
|
38
|
+
disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
|
|
39
|
+
});
|
|
40
|
+
var menuTriggerBy = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? menuTriggerBySelector : blockControlsState === null || blockControlsState === void 0 ? void 0 : blockControlsState.menuTriggerBy;
|
|
41
|
+
if (isMenuOpen) {
|
|
26
42
|
return null;
|
|
27
43
|
}
|
|
28
|
-
var activeNodeSelector = "[data-drag-handler-anchor-name=".concat(
|
|
44
|
+
var activeNodeSelector = "[data-drag-handler-anchor-name=".concat(menuTriggerBy, "]");
|
|
29
45
|
var targetHandleRef = document.querySelector(activeNodeSelector);
|
|
30
46
|
var items = (0, _blockMenuItems.getBlockMenuItems)(formatMessage);
|
|
31
47
|
var handleOpenChange = function handleOpenChange(payload) {
|
|
@@ -7,9 +7,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.DragHandleMenu = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
10
|
+
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
11
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
10
12
|
var DragHandleMenu = exports.DragHandleMenu = function DragHandleMenu(_ref) {
|
|
11
13
|
var api = _ref.api;
|
|
12
|
-
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['blockControls']
|
|
14
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['blockControls'], {
|
|
15
|
+
disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true)
|
|
16
|
+
}),
|
|
13
17
|
blockControlsState = _useSharedPluginState.blockControlsState;
|
|
14
|
-
|
|
18
|
+
var isMenuOpenSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockControls.isMenuOpen', {
|
|
19
|
+
disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
|
|
20
|
+
});
|
|
21
|
+
var isMenuOpen = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? isMenuOpenSelector : blockControlsState === null || blockControlsState === void 0 ? void 0 : blockControlsState.isMenuOpen;
|
|
22
|
+
return isMenuOpen ? /*#__PURE__*/_react.default.createElement("div", null, "menu") : null;
|
|
15
23
|
};
|
|
@@ -274,8 +274,14 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
274
274
|
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
275
275
|
dragHandleDisabled = _useState6[0],
|
|
276
276
|
setDragHandleDisabled = _useState6[1];
|
|
277
|
-
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['featureFlags']
|
|
277
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['featureFlags'], {
|
|
278
|
+
disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true)
|
|
279
|
+
}),
|
|
278
280
|
featureFlagsState = _useSharedPluginState.featureFlagsState;
|
|
281
|
+
var macroInteractionUpdatesSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'featureFlags.macroInteractionUpdates', {
|
|
282
|
+
disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
|
|
283
|
+
});
|
|
284
|
+
var macroInteractionUpdates = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? macroInteractionUpdatesSelector : featureFlagsState === null || featureFlagsState === void 0 ? void 0 : featureFlagsState.macroInteractionUpdates;
|
|
279
285
|
var selection = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'selection.selection');
|
|
280
286
|
var isShiftDown = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockControls.isShiftDown');
|
|
281
287
|
var hasHadInteraction = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'interaction.hasHadInteraction') !== false;
|
|
@@ -568,7 +574,6 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
568
574
|
}
|
|
569
575
|
});
|
|
570
576
|
}, [anchorName, api, getPos, isMultiSelect, nodeType, start, view]);
|
|
571
|
-
var macroInteractionUpdates = featureFlagsState === null || featureFlagsState === void 0 ? void 0 : featureFlagsState.macroInteractionUpdates;
|
|
572
577
|
var calculatePosition = (0, _react.useCallback)(function () {
|
|
573
578
|
var pos = getPos();
|
|
574
579
|
var $pos = pos && view.state.doc.resolve(pos);
|
|
@@ -11,6 +11,7 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
11
11
|
var _react = require("react");
|
|
12
12
|
var _react2 = require("@emotion/react");
|
|
13
13
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
14
|
+
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
14
15
|
var _box = require("@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box");
|
|
15
16
|
var _adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
|
|
16
17
|
var _constants = require("@atlaskit/theme/constants");
|
|
@@ -195,8 +196,16 @@ var DropTarget = exports.DropTarget = function DropTarget(props) {
|
|
|
195
196
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
196
197
|
isDraggedOver = _useState2[0],
|
|
197
198
|
setIsDraggedOver = _useState2[1];
|
|
198
|
-
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['width']
|
|
199
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['width'], {
|
|
200
|
+
disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true)
|
|
201
|
+
}),
|
|
199
202
|
widthState = _useSharedPluginState.widthState;
|
|
203
|
+
|
|
204
|
+
// lineLength
|
|
205
|
+
var lineLengthSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'width.lineLength', {
|
|
206
|
+
disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
|
|
207
|
+
});
|
|
208
|
+
var lineLength = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? lineLengthSelector : widthState === null || widthState === void 0 ? void 0 : widthState.lineLength;
|
|
200
209
|
var isNestedDropTarget = (parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name) !== 'doc';
|
|
201
210
|
var _ref2 = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
|
|
202
211
|
activeNode = _ref2.activeNode;
|
|
@@ -213,7 +222,7 @@ var DropTarget = exports.DropTarget = function DropTarget(props) {
|
|
|
213
222
|
};
|
|
214
223
|
var dynamicStyle = (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({
|
|
215
224
|
width: isNestedDropTarget ? 'unset' : '100%'
|
|
216
|
-
}, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH, isNestedDropTarget ? '100%' : "".concat(
|
|
225
|
+
}, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH, isNestedDropTarget ? '100%' : "".concat(lineLength || DEFAULT_DROP_INDICATOR_WIDTH, "px")), EDITOR_BLOCK_CONTROLS_DROP_TARGET_LEFT_MARGIN, isNestedDropTarget ? (0, _consts.getNestedNodeLeftPaddingMargin)(parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name) : '0'), EDITOR_BLOCK_CONTROLS_DROP_TARGET_ZINDEX, _constants.layers.navigation());
|
|
217
226
|
return (0, _react2.jsx)(_react.Fragment, null, (0, _react2.jsx)(HoverZone, {
|
|
218
227
|
onDragEnter: function onDragEnter() {
|
|
219
228
|
return setIsDraggedOver(true);
|
|
@@ -223,7 +232,7 @@ var DropTarget = exports.DropTarget = function DropTarget(props) {
|
|
|
223
232
|
},
|
|
224
233
|
onDrop: onDrop,
|
|
225
234
|
node: prevNode,
|
|
226
|
-
editorWidth:
|
|
235
|
+
editorWidth: lineLength,
|
|
227
236
|
anchorRectCache: anchorRectCache,
|
|
228
237
|
position: "upper",
|
|
229
238
|
isNestedDropTarget: isNestedDropTarget,
|
|
@@ -250,7 +259,7 @@ var DropTarget = exports.DropTarget = function DropTarget(props) {
|
|
|
250
259
|
onDrop: onDrop,
|
|
251
260
|
node: nextNode,
|
|
252
261
|
parent: parentNode,
|
|
253
|
-
editorWidth:
|
|
262
|
+
editorWidth: lineLength,
|
|
254
263
|
anchorRectCache: anchorRectCache,
|
|
255
264
|
position: "lower",
|
|
256
265
|
isNestedDropTarget: isNestedDropTarget
|
|
@@ -3,7 +3,9 @@ import { injectIntl } from 'react-intl-next';
|
|
|
3
3
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
4
4
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
5
5
|
import { ArrowKeyNavigationType, DropdownMenu } from '@atlaskit/editor-common/ui-menu';
|
|
6
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
6
7
|
import { akEditorFloatingOverlapPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
8
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
7
9
|
import { getBlockMenuItems, menuItemsCallback } from './block-menu-items';
|
|
8
10
|
import { BLOCK_MENU_WIDTH } from './consts';
|
|
9
11
|
const BlockMenu = ({
|
|
@@ -18,11 +20,25 @@ const BlockMenu = ({
|
|
|
18
20
|
}) => {
|
|
19
21
|
const {
|
|
20
22
|
blockControlsState
|
|
21
|
-
} = useSharedPluginState(api, ['blockControls']
|
|
22
|
-
|
|
23
|
+
} = useSharedPluginState(api, ['blockControls'], {
|
|
24
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// isMenuOpen
|
|
28
|
+
const isMenuOpenSelector = useSharedPluginStateSelector(api, 'blockControls.isMenuOpen', {
|
|
29
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
30
|
+
});
|
|
31
|
+
const isMenuOpen = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isMenuOpenSelector : blockControlsState === null || blockControlsState === void 0 ? void 0 : blockControlsState.isMenuOpen;
|
|
32
|
+
|
|
33
|
+
// menuTriggerBy
|
|
34
|
+
const menuTriggerBySelector = useSharedPluginStateSelector(api, 'blockControls.menuTriggerBy', {
|
|
35
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
36
|
+
});
|
|
37
|
+
const menuTriggerBy = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? menuTriggerBySelector : blockControlsState === null || blockControlsState === void 0 ? void 0 : blockControlsState.menuTriggerBy;
|
|
38
|
+
if (isMenuOpen) {
|
|
23
39
|
return null;
|
|
24
40
|
}
|
|
25
|
-
const activeNodeSelector = `[data-drag-handler-anchor-name=${
|
|
41
|
+
const activeNodeSelector = `[data-drag-handler-anchor-name=${menuTriggerBy}]`;
|
|
26
42
|
const targetHandleRef = document.querySelector(activeNodeSelector);
|
|
27
43
|
const items = getBlockMenuItems(formatMessage);
|
|
28
44
|
const handleOpenChange = payload => {
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
3
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
4
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
3
5
|
export const DragHandleMenu = ({
|
|
4
6
|
api
|
|
5
7
|
}) => {
|
|
6
8
|
const {
|
|
7
9
|
blockControlsState
|
|
8
|
-
} = useSharedPluginState(api, ['blockControls']
|
|
9
|
-
|
|
10
|
+
} = useSharedPluginState(api, ['blockControls'], {
|
|
11
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
|
|
12
|
+
});
|
|
13
|
+
const isMenuOpenSelector = useSharedPluginStateSelector(api, 'blockControls.isMenuOpen', {
|
|
14
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
15
|
+
});
|
|
16
|
+
const isMenuOpen = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isMenuOpenSelector : blockControlsState === null || blockControlsState === void 0 ? void 0 : blockControlsState.isMenuOpen;
|
|
17
|
+
return isMenuOpen ? /*#__PURE__*/React.createElement("div", null, "menu") : null;
|
|
10
18
|
};
|
|
@@ -259,7 +259,13 @@ export const DragHandle = ({
|
|
|
259
259
|
const [dragHandleDisabled, setDragHandleDisabled] = useState(false);
|
|
260
260
|
const {
|
|
261
261
|
featureFlagsState
|
|
262
|
-
} = useSharedPluginState(api, ['featureFlags']
|
|
262
|
+
} = useSharedPluginState(api, ['featureFlags'], {
|
|
263
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
|
|
264
|
+
});
|
|
265
|
+
const macroInteractionUpdatesSelector = useSharedPluginStateSelector(api, 'featureFlags.macroInteractionUpdates', {
|
|
266
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
267
|
+
});
|
|
268
|
+
const macroInteractionUpdates = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? macroInteractionUpdatesSelector : featureFlagsState === null || featureFlagsState === void 0 ? void 0 : featureFlagsState.macroInteractionUpdates;
|
|
263
269
|
const selection = useSharedPluginStateSelector(api, 'selection.selection');
|
|
264
270
|
const isShiftDown = useSharedPluginStateSelector(api, 'blockControls.isShiftDown');
|
|
265
271
|
const hasHadInteraction = useSharedPluginStateSelector(api, 'interaction.hasHadInteraction') !== false;
|
|
@@ -557,7 +563,6 @@ export const DragHandle = ({
|
|
|
557
563
|
}
|
|
558
564
|
});
|
|
559
565
|
}, [anchorName, api, getPos, isMultiSelect, nodeType, start, view]);
|
|
560
|
-
const macroInteractionUpdates = featureFlagsState === null || featureFlagsState === void 0 ? void 0 : featureFlagsState.macroInteractionUpdates;
|
|
561
566
|
const calculatePosition = useCallback(() => {
|
|
562
567
|
const pos = getPos();
|
|
563
568
|
const $pos = pos && view.state.doc.resolve(pos);
|
|
@@ -8,6 +8,7 @@ import { Fragment, useEffect, useMemo, useRef, useState } from 'react';
|
|
|
8
8
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
9
9
|
import { css, jsx } from '@emotion/react';
|
|
10
10
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
11
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
11
12
|
import { DropIndicator } from '@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box';
|
|
12
13
|
import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
13
14
|
import { layers } from '@atlaskit/theme/constants';
|
|
@@ -183,7 +184,15 @@ export const DropTarget = props => {
|
|
|
183
184
|
const [isDraggedOver, setIsDraggedOver] = useState(false);
|
|
184
185
|
const {
|
|
185
186
|
widthState
|
|
186
|
-
} = useSharedPluginState(api, ['width']
|
|
187
|
+
} = useSharedPluginState(api, ['width'], {
|
|
188
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
// lineLength
|
|
192
|
+
const lineLengthSelector = useSharedPluginStateSelector(api, 'width.lineLength', {
|
|
193
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
194
|
+
});
|
|
195
|
+
const lineLength = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? lineLengthSelector : widthState === null || widthState === void 0 ? void 0 : widthState.lineLength;
|
|
187
196
|
const isNestedDropTarget = (parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name) !== 'doc';
|
|
188
197
|
const {
|
|
189
198
|
activeNode
|
|
@@ -203,7 +212,7 @@ export const DropTarget = props => {
|
|
|
203
212
|
};
|
|
204
213
|
const dynamicStyle = {
|
|
205
214
|
width: isNestedDropTarget ? 'unset' : '100%',
|
|
206
|
-
[EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH]: isNestedDropTarget ? '100%' : `${
|
|
215
|
+
[EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH]: isNestedDropTarget ? '100%' : `${lineLength || DEFAULT_DROP_INDICATOR_WIDTH}px`,
|
|
207
216
|
[EDITOR_BLOCK_CONTROLS_DROP_TARGET_LEFT_MARGIN]: isNestedDropTarget ? getNestedNodeLeftPaddingMargin(parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name) : '0',
|
|
208
217
|
[EDITOR_BLOCK_CONTROLS_DROP_TARGET_ZINDEX]: layers.navigation()
|
|
209
218
|
};
|
|
@@ -212,7 +221,7 @@ export const DropTarget = props => {
|
|
|
212
221
|
onDragLeave: () => setIsDraggedOver(false),
|
|
213
222
|
onDrop: onDrop,
|
|
214
223
|
node: prevNode,
|
|
215
|
-
editorWidth:
|
|
224
|
+
editorWidth: lineLength,
|
|
216
225
|
anchorRectCache: anchorRectCache,
|
|
217
226
|
position: "upper",
|
|
218
227
|
isNestedDropTarget: isNestedDropTarget,
|
|
@@ -235,7 +244,7 @@ export const DropTarget = props => {
|
|
|
235
244
|
onDrop: onDrop,
|
|
236
245
|
node: nextNode,
|
|
237
246
|
parent: parentNode,
|
|
238
|
-
editorWidth:
|
|
247
|
+
editorWidth: lineLength,
|
|
239
248
|
anchorRectCache: anchorRectCache,
|
|
240
249
|
position: "lower",
|
|
241
250
|
isNestedDropTarget: isNestedDropTarget
|
|
@@ -3,7 +3,9 @@ import { injectIntl } from 'react-intl-next';
|
|
|
3
3
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
4
4
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
5
5
|
import { ArrowKeyNavigationType, DropdownMenu } from '@atlaskit/editor-common/ui-menu';
|
|
6
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
6
7
|
import { akEditorFloatingOverlapPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
8
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
7
9
|
import { getBlockMenuItems, menuItemsCallback } from './block-menu-items';
|
|
8
10
|
import { BLOCK_MENU_WIDTH } from './consts';
|
|
9
11
|
var BlockMenu = function BlockMenu(_ref) {
|
|
@@ -13,12 +15,26 @@ var BlockMenu = function BlockMenu(_ref) {
|
|
|
13
15
|
scrollableElement = _ref.scrollableElement,
|
|
14
16
|
api = _ref.api,
|
|
15
17
|
formatMessage = _ref.intl.formatMessage;
|
|
16
|
-
var _useSharedPluginState = useSharedPluginState(api, ['blockControls']
|
|
18
|
+
var _useSharedPluginState = useSharedPluginState(api, ['blockControls'], {
|
|
19
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
|
|
20
|
+
}),
|
|
17
21
|
blockControlsState = _useSharedPluginState.blockControlsState;
|
|
18
|
-
|
|
22
|
+
|
|
23
|
+
// isMenuOpen
|
|
24
|
+
var isMenuOpenSelector = useSharedPluginStateSelector(api, 'blockControls.isMenuOpen', {
|
|
25
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
26
|
+
});
|
|
27
|
+
var isMenuOpen = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isMenuOpenSelector : blockControlsState === null || blockControlsState === void 0 ? void 0 : blockControlsState.isMenuOpen;
|
|
28
|
+
|
|
29
|
+
// menuTriggerBy
|
|
30
|
+
var menuTriggerBySelector = useSharedPluginStateSelector(api, 'blockControls.menuTriggerBy', {
|
|
31
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
32
|
+
});
|
|
33
|
+
var menuTriggerBy = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? menuTriggerBySelector : blockControlsState === null || blockControlsState === void 0 ? void 0 : blockControlsState.menuTriggerBy;
|
|
34
|
+
if (isMenuOpen) {
|
|
19
35
|
return null;
|
|
20
36
|
}
|
|
21
|
-
var activeNodeSelector = "[data-drag-handler-anchor-name=".concat(
|
|
37
|
+
var activeNodeSelector = "[data-drag-handler-anchor-name=".concat(menuTriggerBy, "]");
|
|
22
38
|
var targetHandleRef = document.querySelector(activeNodeSelector);
|
|
23
39
|
var items = getBlockMenuItems(formatMessage);
|
|
24
40
|
var handleOpenChange = function handleOpenChange(payload) {
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
3
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
4
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
3
5
|
export var DragHandleMenu = function DragHandleMenu(_ref) {
|
|
4
6
|
var api = _ref.api;
|
|
5
|
-
var _useSharedPluginState = useSharedPluginState(api, ['blockControls']
|
|
7
|
+
var _useSharedPluginState = useSharedPluginState(api, ['blockControls'], {
|
|
8
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
|
|
9
|
+
}),
|
|
6
10
|
blockControlsState = _useSharedPluginState.blockControlsState;
|
|
7
|
-
|
|
11
|
+
var isMenuOpenSelector = useSharedPluginStateSelector(api, 'blockControls.isMenuOpen', {
|
|
12
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
13
|
+
});
|
|
14
|
+
var isMenuOpen = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isMenuOpenSelector : blockControlsState === null || blockControlsState === void 0 ? void 0 : blockControlsState.isMenuOpen;
|
|
15
|
+
return isMenuOpen ? /*#__PURE__*/React.createElement("div", null, "menu") : null;
|
|
8
16
|
};
|
|
@@ -271,8 +271,14 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
271
271
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
272
272
|
dragHandleDisabled = _useState6[0],
|
|
273
273
|
setDragHandleDisabled = _useState6[1];
|
|
274
|
-
var _useSharedPluginState = useSharedPluginState(api, ['featureFlags']
|
|
274
|
+
var _useSharedPluginState = useSharedPluginState(api, ['featureFlags'], {
|
|
275
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
|
|
276
|
+
}),
|
|
275
277
|
featureFlagsState = _useSharedPluginState.featureFlagsState;
|
|
278
|
+
var macroInteractionUpdatesSelector = useSharedPluginStateSelector(api, 'featureFlags.macroInteractionUpdates', {
|
|
279
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
280
|
+
});
|
|
281
|
+
var macroInteractionUpdates = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? macroInteractionUpdatesSelector : featureFlagsState === null || featureFlagsState === void 0 ? void 0 : featureFlagsState.macroInteractionUpdates;
|
|
276
282
|
var selection = useSharedPluginStateSelector(api, 'selection.selection');
|
|
277
283
|
var isShiftDown = useSharedPluginStateSelector(api, 'blockControls.isShiftDown');
|
|
278
284
|
var hasHadInteraction = useSharedPluginStateSelector(api, 'interaction.hasHadInteraction') !== false;
|
|
@@ -565,7 +571,6 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
565
571
|
}
|
|
566
572
|
});
|
|
567
573
|
}, [anchorName, api, getPos, isMultiSelect, nodeType, start, view]);
|
|
568
|
-
var macroInteractionUpdates = featureFlagsState === null || featureFlagsState === void 0 ? void 0 : featureFlagsState.macroInteractionUpdates;
|
|
569
574
|
var calculatePosition = useCallback(function () {
|
|
570
575
|
var pos = getPos();
|
|
571
576
|
var $pos = pos && view.state.doc.resolve(pos);
|
|
@@ -10,6 +10,7 @@ import { Fragment, useEffect, useMemo, useRef, useState } from 'react';
|
|
|
10
10
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
11
11
|
import { css, jsx } from '@emotion/react';
|
|
12
12
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
13
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
13
14
|
import { DropIndicator } from '@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box';
|
|
14
15
|
import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
15
16
|
import { layers } from '@atlaskit/theme/constants';
|
|
@@ -187,8 +188,16 @@ export var DropTarget = function DropTarget(props) {
|
|
|
187
188
|
_useState2 = _slicedToArray(_useState, 2),
|
|
188
189
|
isDraggedOver = _useState2[0],
|
|
189
190
|
setIsDraggedOver = _useState2[1];
|
|
190
|
-
var _useSharedPluginState = useSharedPluginState(api, ['width']
|
|
191
|
+
var _useSharedPluginState = useSharedPluginState(api, ['width'], {
|
|
192
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
|
|
193
|
+
}),
|
|
191
194
|
widthState = _useSharedPluginState.widthState;
|
|
195
|
+
|
|
196
|
+
// lineLength
|
|
197
|
+
var lineLengthSelector = useSharedPluginStateSelector(api, 'width.lineLength', {
|
|
198
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
199
|
+
});
|
|
200
|
+
var lineLength = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? lineLengthSelector : widthState === null || widthState === void 0 ? void 0 : widthState.lineLength;
|
|
192
201
|
var isNestedDropTarget = (parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name) !== 'doc';
|
|
193
202
|
var _ref2 = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
|
|
194
203
|
activeNode = _ref2.activeNode;
|
|
@@ -205,7 +214,7 @@ export var DropTarget = function DropTarget(props) {
|
|
|
205
214
|
};
|
|
206
215
|
var dynamicStyle = _defineProperty(_defineProperty(_defineProperty({
|
|
207
216
|
width: isNestedDropTarget ? 'unset' : '100%'
|
|
208
|
-
}, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH, isNestedDropTarget ? '100%' : "".concat(
|
|
217
|
+
}, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH, isNestedDropTarget ? '100%' : "".concat(lineLength || DEFAULT_DROP_INDICATOR_WIDTH, "px")), EDITOR_BLOCK_CONTROLS_DROP_TARGET_LEFT_MARGIN, isNestedDropTarget ? getNestedNodeLeftPaddingMargin(parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name) : '0'), EDITOR_BLOCK_CONTROLS_DROP_TARGET_ZINDEX, layers.navigation());
|
|
209
218
|
return jsx(Fragment, null, jsx(HoverZone, {
|
|
210
219
|
onDragEnter: function onDragEnter() {
|
|
211
220
|
return setIsDraggedOver(true);
|
|
@@ -215,7 +224,7 @@ export var DropTarget = function DropTarget(props) {
|
|
|
215
224
|
},
|
|
216
225
|
onDrop: onDrop,
|
|
217
226
|
node: prevNode,
|
|
218
|
-
editorWidth:
|
|
227
|
+
editorWidth: lineLength,
|
|
219
228
|
anchorRectCache: anchorRectCache,
|
|
220
229
|
position: "upper",
|
|
221
230
|
isNestedDropTarget: isNestedDropTarget,
|
|
@@ -242,7 +251,7 @@ export var DropTarget = function DropTarget(props) {
|
|
|
242
251
|
onDrop: onDrop,
|
|
243
252
|
node: nextNode,
|
|
244
253
|
parent: parentNode,
|
|
245
|
-
editorWidth:
|
|
254
|
+
editorWidth: lineLength,
|
|
246
255
|
anchorRectCache: anchorRectCache,
|
|
247
256
|
position: "lower",
|
|
248
257
|
isNestedDropTarget: isNestedDropTarget
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "3.11.
|
|
3
|
+
"version": "3.11.2",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@atlaskit/adf-schema": "^47.6.0",
|
|
36
|
-
"@atlaskit/editor-common": "^103.
|
|
36
|
+
"@atlaskit/editor-common": "^103.16.0",
|
|
37
37
|
"@atlaskit/editor-plugin-accessibility-utils": "^2.0.0",
|
|
38
38
|
"@atlaskit/editor-plugin-analytics": "^2.2.0",
|
|
39
39
|
"@atlaskit/editor-plugin-editor-disabled": "^2.0.0",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^3.1.0",
|
|
56
56
|
"@atlaskit/primitives": "^14.4.0",
|
|
57
57
|
"@atlaskit/theme": "^18.0.0",
|
|
58
|
-
"@atlaskit/tmp-editor-statsig": "^4.
|
|
58
|
+
"@atlaskit/tmp-editor-statsig": "^4.14.0",
|
|
59
59
|
"@atlaskit/tokens": "^4.8.0",
|
|
60
60
|
"@atlaskit/tooltip": "^20.0.0",
|
|
61
61
|
"@babel/runtime": "^7.0.0",
|