@atlaskit/editor-plugin-block-controls 9.0.15 → 9.0.16
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 +8 -0
- package/dist/cjs/blockControlsPlugin.js +3 -4
- package/dist/cjs/editor-commands/move-node-with-block-menu.js +2 -2
- package/dist/cjs/editor-commands/move-node.js +1 -1
- package/dist/cjs/editor-commands/utils/move-node-utils.js +4 -4
- package/dist/cjs/pm-plugins/handle-mouse-down.js +3 -3
- package/dist/cjs/pm-plugins/handle-mouse-over.js +5 -3
- package/dist/cjs/pm-plugins/main.js +8 -8
- package/dist/cjs/pm-plugins/utils/getSelection.js +3 -3
- package/dist/cjs/ui/drag-handle.js +6 -6
- package/dist/es2019/blockControlsPlugin.js +3 -4
- package/dist/es2019/editor-commands/move-node-with-block-menu.js +2 -2
- package/dist/es2019/editor-commands/move-node.js +1 -1
- package/dist/es2019/editor-commands/utils/move-node-utils.js +4 -4
- package/dist/es2019/pm-plugins/handle-mouse-down.js +3 -3
- package/dist/es2019/pm-plugins/handle-mouse-over.js +5 -3
- package/dist/es2019/pm-plugins/main.js +8 -8
- package/dist/es2019/pm-plugins/utils/getSelection.js +3 -3
- package/dist/es2019/ui/drag-handle.js +6 -6
- package/dist/esm/blockControlsPlugin.js +3 -4
- package/dist/esm/editor-commands/move-node-with-block-menu.js +2 -2
- package/dist/esm/editor-commands/move-node.js +1 -1
- package/dist/esm/editor-commands/utils/move-node-utils.js +4 -4
- package/dist/esm/pm-plugins/handle-mouse-down.js +3 -3
- package/dist/esm/pm-plugins/handle-mouse-over.js +5 -3
- package/dist/esm/pm-plugins/main.js +8 -8
- package/dist/esm/pm-plugins/utils/getSelection.js +3 -3
- package/dist/esm/ui/drag-handle.js +6 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 9.0.16
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`9ed32aea2c1d3`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9ed32aea2c1d3) -
|
|
8
|
+
Replace feature experiment util with cross platform alternative for platform_editor_block_menu
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
3
11
|
## 9.0.15
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -11,7 +11,6 @@ var _selection = require("@atlaskit/editor-common/selection");
|
|
|
11
11
|
var _toolbarFlagCheck = require("@atlaskit/editor-common/toolbar-flag-check");
|
|
12
12
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
13
13
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
14
|
-
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
15
14
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
16
15
|
var _handleKeyDownWithPreservedSelection = require("./editor-commands/handle-key-down-with-preserved-selection");
|
|
17
16
|
var _mapPreservedSelection2 = require("./editor-commands/map-preserved-selection");
|
|
@@ -68,7 +67,7 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
|
|
|
68
67
|
}
|
|
69
68
|
});
|
|
70
69
|
}
|
|
71
|
-
if ((0,
|
|
70
|
+
if ((0, _experiments.editorExperiment)('platform_editor_block_menu', true)) {
|
|
72
71
|
pmPlugins.push({
|
|
73
72
|
name: 'blockControlsSelectionPreservationPlugin',
|
|
74
73
|
plugin: (0, _pmPlugin2.createSelectionPreservationPlugin)(api)
|
|
@@ -109,7 +108,7 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
|
|
|
109
108
|
return function (_ref4) {
|
|
110
109
|
var _api$userIntent, _api$blockControls, _options$anchorName, _api$blockControls2;
|
|
111
110
|
var tr = _ref4.tr;
|
|
112
|
-
if (!(0,
|
|
111
|
+
if (!(0, _experiments.editorExperiment)('platform_editor_block_menu', true)) {
|
|
113
112
|
return tr;
|
|
114
113
|
}
|
|
115
114
|
var currMeta = tr.getMeta(_main.key);
|
|
@@ -342,7 +341,7 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
|
|
|
342
341
|
sharedState.rightSideControlsEnabled = rightSideControlsEnabled;
|
|
343
342
|
sharedState.hoverSide = rightSideControlsEnabled ? (_interactionTrackingP4 = _pmPlugin.interactionTrackingPluginKey.getState(editorState)) === null || _interactionTrackingP4 === void 0 ? void 0 : _interactionTrackingP4.hoverSide : undefined;
|
|
344
343
|
}
|
|
345
|
-
if ((0,
|
|
344
|
+
if ((0, _experiments.editorExperiment)('platform_editor_block_menu', true)) {
|
|
346
345
|
var _selectionPreservatio;
|
|
347
346
|
sharedState.preservedSelection = (_selectionPreservatio = _pluginKey.selectionPreservationPluginKey.getState(editorState)) === null || _selectionPreservatio === void 0 ? void 0 : _selectionPreservatio.preservedSelection;
|
|
348
347
|
}
|
|
@@ -8,7 +8,7 @@ exports.moveNodeWithBlockMenu = void 0;
|
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
10
10
|
var _types = require("@atlaskit/editor-common/types");
|
|
11
|
-
var
|
|
11
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
12
12
|
var _main = require("../pm-plugins/main");
|
|
13
13
|
var _selection = require("../pm-plugins/utils/selection");
|
|
14
14
|
var _moveNode = require("./move-node");
|
|
@@ -30,7 +30,7 @@ var moveNodeWithBlockMenu = exports.moveNodeWithBlockMenu = function moveNodeWit
|
|
|
30
30
|
return function (_ref) {
|
|
31
31
|
var _api$blockControls$sh;
|
|
32
32
|
var tr = _ref.tr;
|
|
33
|
-
if (!(0,
|
|
33
|
+
if (!(0, _experiments.editorExperiment)('platform_editor_block_menu', true)) {
|
|
34
34
|
return tr;
|
|
35
35
|
}
|
|
36
36
|
var preservedSelection = api === null || api === void 0 || (_api$blockControls$sh = api.blockControls.sharedState.currentState()) === null || _api$blockControls$sh === void 0 ? void 0 : _api$blockControls$sh.preservedSelection;
|
|
@@ -443,7 +443,7 @@ var moveNode = exports.moveNode = function moveNode(api) {
|
|
|
443
443
|
}));
|
|
444
444
|
if (
|
|
445
445
|
// when move node via block menu, we need to keep the focus on block menu popup, so don't move focus to editor in this scenario
|
|
446
|
-
!(inputMethod === _analytics.INPUT_METHOD.BLOCK_MENU && (0,
|
|
446
|
+
!(inputMethod === _analytics.INPUT_METHOD.BLOCK_MENU && (0, _experiments.editorExperiment)('platform_editor_block_menu', true))) {
|
|
447
447
|
api === null || api === void 0 || api.core.actions.focus();
|
|
448
448
|
}
|
|
449
449
|
var $mappedTo = tr.doc.resolve(mappedTo);
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.getShouldMoveNode = exports.getPosWhenMoveNodeUp = exports.getPosWhenMoveNodeDown = exports.getNodeBoundsFromSelection = exports.canMoveNodeUpOrDown = void 0;
|
|
7
7
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
8
8
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
9
|
-
var
|
|
9
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
10
10
|
var _selection = require("../../pm-plugins/utils/selection");
|
|
11
11
|
/**
|
|
12
12
|
* Gets the current node position and bounds from the selection using the preserved selection logic.
|
|
@@ -33,7 +33,7 @@ var getNodeBoundsFromSelection = exports.getNodeBoundsFromSelection = function g
|
|
|
33
33
|
// Special case: if a media node (file) is selected, we need to get the parent mediaGroup
|
|
34
34
|
// This handles the case where clicking on a file creates a NodeSelection of the media node
|
|
35
35
|
// but we want to move the entire mediaGroup that wraps it
|
|
36
|
-
if (selection instanceof _state.NodeSelection && selection.node.type.name === 'media' && selection.node.attrs.type === 'file' && (0,
|
|
36
|
+
if (selection instanceof _state.NodeSelection && selection.node.type.name === 'media' && selection.node.attrs.type === 'file' && (0, _experiments.editorExperiment)('platform_editor_block_menu', true)) {
|
|
37
37
|
// The media node is wrapped in a mediaGroup, so we need to get the parent position
|
|
38
38
|
var mediaGroupPos = selection.$from.pos - 1;
|
|
39
39
|
var mediaGroupNode = selection.$from.doc.nodeAt(mediaGroupPos);
|
|
@@ -58,7 +58,7 @@ var getNodeBoundsFromSelection = exports.getNodeBoundsFromSelection = function g
|
|
|
58
58
|
var getPosWhenMoveNodeUp = exports.getPosWhenMoveNodeUp = function getPosWhenMoveNodeUp($currentNodePos, currentNodePos) {
|
|
59
59
|
var nodeIndex = $currentNodePos.index();
|
|
60
60
|
var nodeBefore = $currentNodePos.depth > 1 && nodeIndex === 0 ? $currentNodePos.node($currentNodePos.depth) : $currentNodePos.nodeBefore;
|
|
61
|
-
if ((nodeBefore === null || nodeBefore === void 0 ? void 0 : nodeBefore.type.name) === 'layoutColumn' && (0,
|
|
61
|
+
if ((nodeBefore === null || nodeBefore === void 0 ? void 0 : nodeBefore.type.name) === 'layoutColumn' && (0, _experiments.editorExperiment)('platform_editor_block_menu', true)) {
|
|
62
62
|
return -1;
|
|
63
63
|
}
|
|
64
64
|
return nodeBefore ? currentNodePos - nodeBefore.nodeSize : -1;
|
|
@@ -72,7 +72,7 @@ var getPosWhenMoveNodeDown = exports.getPosWhenMoveNodeDown = function getPosWhe
|
|
|
72
72
|
return -1;
|
|
73
73
|
}
|
|
74
74
|
var nodeAfter = tr.doc.nodeAt(nodeAfterPos);
|
|
75
|
-
if ((0,
|
|
75
|
+
if ((0, _experiments.editorExperiment)('platform_editor_block_menu', true)) {
|
|
76
76
|
var nodeAtCurrentPos = tr.doc.nodeAt($currentNodePos.pos);
|
|
77
77
|
// if move empty line down to another empty line, move to the position of the next empty line
|
|
78
78
|
if ((nodeAtCurrentPos === null || nodeAtCurrentPos === void 0 ? void 0 : nodeAtCurrentPos.content.size) === 0 && nodeAtCurrentPos.type.name !== 'extension' && (nodeAfter === null || nodeAfter === void 0 ? void 0 : nodeAfter.content.size) === 0 && nodeAfter.type.name !== 'extension') {
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.handleMouseDown = void 0;
|
|
7
7
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
8
8
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
9
|
-
var
|
|
9
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
10
10
|
var handleMouseDown = exports.handleMouseDown = function handleMouseDown(api) {
|
|
11
11
|
return function (view, event) {
|
|
12
12
|
if (!(event.target instanceof HTMLElement)) {
|
|
@@ -34,7 +34,7 @@ var handleMouseDown = exports.handleMouseDown = function handleMouseDown(api) {
|
|
|
34
34
|
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.showDragHandleAt(rootPos, '', (_rootNode$type$name3 = rootNode.type.name) !== null && _rootNode$type$name3 !== void 0 ? _rootNode$type$name3 : '', undefined, rootPos, '', (_rootNode$type$name4 = rootNode.type.name) !== null && _rootNode$type$name4 !== void 0 ? _rootNode$type$name4 : ''));
|
|
35
35
|
}
|
|
36
36
|
} else {
|
|
37
|
-
var isDragHandle = event.target.closest((0,
|
|
37
|
+
var isDragHandle = event.target.closest((0, _experiments.editorExperiment)('platform_editor_block_menu', true) ? _styles.DRAG_HANDLE_SELECTOR : '[data-editor-block-ctrl-drag-handle]') !== null;
|
|
38
38
|
api === null || api === void 0 || api.core.actions.execute(function (_ref) {
|
|
39
39
|
var tr = _ref.tr;
|
|
40
40
|
api === null || api === void 0 || api.blockControls.commands.setSelectedViaDragHandle(isDragHandle)({
|
|
@@ -44,7 +44,7 @@ var handleMouseDown = exports.handleMouseDown = function handleMouseDown(api) {
|
|
|
44
44
|
* When block menu is enabled, reset intent back to 'default' as editor-plugin-block-menu sets the user intent to 'blockMenuOpen', and setting here
|
|
45
45
|
* causes flickering as this runs before editor-plugin-block-menu.
|
|
46
46
|
*/
|
|
47
|
-
if ((0,
|
|
47
|
+
if ((0, _experiments.editorExperiment)('platform_editor_block_menu', true)) {
|
|
48
48
|
// if target is drag handle, block menu will be opened
|
|
49
49
|
if (!isDragHandle) {
|
|
50
50
|
var _api$userIntent;
|
|
@@ -68,7 +68,9 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, e
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
// If the editor view is not in focus when the block menu is open, do not update the drag handle
|
|
71
|
-
if (!view.hasFocus() && isMenuOpen && (0,
|
|
71
|
+
if (!view.hasFocus() && isMenuOpen && (0, _experiments.editorExperiment)('platform_editor_block_menu', true, {
|
|
72
|
+
exposure: true
|
|
73
|
+
})) {
|
|
72
74
|
return false;
|
|
73
75
|
}
|
|
74
76
|
|
|
@@ -196,7 +198,7 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, e
|
|
|
196
198
|
if (nodeType) {
|
|
197
199
|
// platform_editor_controls note: enables quick insert
|
|
198
200
|
if (toolbarFlagsEnabled) {
|
|
199
|
-
if ((0,
|
|
201
|
+
if ((0, _experiments.editorExperiment)('platform_editor_block_menu', true)) {
|
|
200
202
|
var _selectionPreservatio;
|
|
201
203
|
var preservedSelection = (_selectionPreservatio = _pluginKey.selectionPreservationPluginKey.getState(view.state)) === null || _selectionPreservatio === void 0 ? void 0 : _selectionPreservatio.preservedSelection;
|
|
202
204
|
var selection = preservedSelection || view.state.selection;
|
|
@@ -217,7 +219,7 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, e
|
|
|
217
219
|
var _api$core3, _api$blockControls5;
|
|
218
220
|
api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(api === null || api === void 0 || (_api$blockControls5 = api.blockControls) === null || _api$blockControls5 === void 0 ? void 0 : _api$blockControls5.commands.showDragHandleAt(targetPos, anchorName, nodeType));
|
|
219
221
|
}
|
|
220
|
-
if ((0,
|
|
222
|
+
if ((0, _experiments.editorExperiment)('platform_editor_block_menu', true)) {
|
|
221
223
|
var _api$userIntent;
|
|
222
224
|
if (isMenuOpen && originalAnchorName && (api === null || api === void 0 || (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 || (_api$userIntent = _api$userIntent.sharedState.currentState()) === null || _api$userIntent === void 0 ? void 0 : _api$userIntent.currentUserIntent) === 'blockMenuOpen') {
|
|
223
225
|
var _api$core4, _api$blockControls6;
|
|
@@ -313,7 +313,7 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
|
|
|
313
313
|
// Which caused the drag handle onClick event not firing, then block menu wouldn't be opened
|
|
314
314
|
// This is caused by the mappedPos.deletedAfter sometimes returning true in webkit browsers even though the active node still exists
|
|
315
315
|
// This is likely a prosemirror and safari integration bug, but to unblock the issue, we are going to use mappedPos.deleted in safari for now
|
|
316
|
-
if (browser.webkit && (0,
|
|
316
|
+
if (browser.webkit && (0, _experiments.editorExperiment)('platform_editor_block_menu', true)) {
|
|
317
317
|
_mappedPos = tr.mapping.mapResult(activeNode.pos);
|
|
318
318
|
isActiveNodeDeleted = _mappedPos.deleted;
|
|
319
319
|
} else {
|
|
@@ -731,7 +731,7 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
|
|
|
731
731
|
newActiveNode = isEmptyDoc || !(meta !== null && meta !== void 0 && meta.activeNode) && (0, _decorationsDragHandle.findHandleDec)(decorations, (_latestActiveNode12 = latestActiveNode) === null || _latestActiveNode12 === void 0 ? void 0 : _latestActiveNode12.pos, (_latestActiveNode13 = latestActiveNode) === null || _latestActiveNode13 === void 0 ? void 0 : _latestActiveNode13.pos).length === 0 ? null : latestActiveNode;
|
|
732
732
|
}
|
|
733
733
|
var isMenuOpenNew = isMenuOpen;
|
|
734
|
-
if ((0,
|
|
734
|
+
if ((0, _experiments.editorExperiment)('platform_editor_block_menu', true)) {
|
|
735
735
|
if (meta !== null && meta !== void 0 && meta.closeMenu) {
|
|
736
736
|
isMenuOpenNew = false;
|
|
737
737
|
} else if (meta !== null && meta !== void 0 && meta.toggleMenu) {
|
|
@@ -753,9 +753,9 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
|
|
|
753
753
|
activeDropTargetNode: currentActiveDropTargetNode,
|
|
754
754
|
isDragging: (_meta$isDragging3 = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging3 !== void 0 ? _meta$isDragging3 : isDragging,
|
|
755
755
|
isMenuOpen: isMenuOpenNew,
|
|
756
|
-
menuTriggerBy: flags.toolbarFlagsEnabled || (0,
|
|
756
|
+
menuTriggerBy: flags.toolbarFlagsEnabled || (0, _experiments.editorExperiment)('platform_editor_block_menu', true) ? (meta === null || meta === void 0 || (_meta$toggleMenu = meta.toggleMenu) === null || _meta$toggleMenu === void 0 ? void 0 : _meta$toggleMenu.anchorName) || menuTriggerBy : undefined,
|
|
757
757
|
menuTriggerByNode: (0, _experiments.editorExperiment)('platform_synced_block', true) ? (meta === null || meta === void 0 || (_meta$toggleMenu2 = meta.toggleMenu) === null || _meta$toggleMenu2 === void 0 ? void 0 : _meta$toggleMenu2.triggerByNode) || menuTriggerByNode : undefined,
|
|
758
|
-
blockMenuOptions: (0,
|
|
758
|
+
blockMenuOptions: (0, _experiments.editorExperiment)('platform_editor_block_menu', true) ? {
|
|
759
759
|
canMoveUp: (meta === null || meta === void 0 || (_meta$toggleMenu3 = meta.toggleMenu) === null || _meta$toggleMenu3 === void 0 ? void 0 : _meta$toggleMenu3.moveUp) !== undefined ? meta === null || meta === void 0 || (_meta$toggleMenu4 = meta.toggleMenu) === null || _meta$toggleMenu4 === void 0 ? void 0 : _meta$toggleMenu4.moveUp : blockMenuOptions === null || blockMenuOptions === void 0 ? void 0 : blockMenuOptions.canMoveUp,
|
|
760
760
|
canMoveDown: (meta === null || meta === void 0 || (_meta$toggleMenu5 = meta.toggleMenu) === null || _meta$toggleMenu5 === void 0 ? void 0 : _meta$toggleMenu5.moveDown) !== undefined ? meta === null || meta === void 0 || (_meta$toggleMenu6 = meta.toggleMenu) === null || _meta$toggleMenu6 === void 0 ? void 0 : _meta$toggleMenu6.moveDown : blockMenuOptions === null || blockMenuOptions === void 0 ? void 0 : blockMenuOptions.canMoveDown,
|
|
761
761
|
openedViaKeyboard: (meta === null || meta === void 0 || (_meta$toggleMenu7 = meta.toggleMenu) === null || _meta$toggleMenu7 === void 0 ? void 0 : _meta$toggleMenu7.openedViaKeyboard) !== undefined ? meta === null || meta === void 0 || (_meta$toggleMenu8 = meta.toggleMenu) === null || _meta$toggleMenu8 === void 0 ? void 0 : _meta$toggleMenu8.openedViaKeyboard : blockMenuOptions === null || blockMenuOptions === void 0 ? void 0 : blockMenuOptions.openedViaKeyboard
|
|
@@ -986,12 +986,12 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
|
|
|
986
986
|
}
|
|
987
987
|
}
|
|
988
988
|
if ((event.key === 'Enter' || event.key === ' ') && event.target instanceof HTMLElement && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
|
|
989
|
-
var isDragHandle = event.target.closest((0,
|
|
989
|
+
var isDragHandle = event.target.closest((0, _experiments.editorExperiment)('platform_editor_block_menu', true) ? _styles.DRAG_HANDLE_SELECTOR : '[data-editor-block-ctrl-drag-handle="true"]') !== null;
|
|
990
990
|
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(isDragHandle));
|
|
991
991
|
}
|
|
992
992
|
if ((event.key === 'ArrowLeft' || event.key === 'ArrowRight' || event.key === 'ArrowDown' || event.key === 'ArrowUp') && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
|
|
993
993
|
var _api$blockControls$sh2, _api$blockControls$sh3;
|
|
994
|
-
var isBlockMenuOpen = (api === null || api === void 0 || (_api$blockControls$sh2 = api.blockControls.sharedState.currentState()) === null || _api$blockControls$sh2 === void 0 ? void 0 : _api$blockControls$sh2.isMenuOpen) && (0,
|
|
994
|
+
var isBlockMenuOpen = (api === null || api === void 0 || (_api$blockControls$sh2 = api.blockControls.sharedState.currentState()) === null || _api$blockControls$sh2 === void 0 ? void 0 : _api$blockControls$sh2.isMenuOpen) && (0, _experiments.editorExperiment)('platform_editor_block_menu', true);
|
|
995
995
|
// when block menu is just open, and we press arrow keys, we want to use the arrow keys to navigate the block menu
|
|
996
996
|
// in this scenario, isSelectedViaDragHandle should not be set to false
|
|
997
997
|
if (api !== null && api !== void 0 && (_api$blockControls$sh3 = api.blockControls.sharedState.currentState()) !== null && _api$blockControls$sh3 !== void 0 && _api$blockControls$sh3.isSelectedViaDragHandle && !isBlockMenuOpen) {
|
|
@@ -1013,12 +1013,12 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
|
|
|
1013
1013
|
}
|
|
1014
1014
|
}
|
|
1015
1015
|
if ((event.key === 'Enter' || event.key === ' ') && event.target instanceof HTMLElement && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
|
|
1016
|
-
var _isDragHandle = event.target.closest((0,
|
|
1016
|
+
var _isDragHandle = event.target.closest((0, _experiments.editorExperiment)('platform_editor_block_menu', true) ? _styles.DRAG_HANDLE_SELECTOR : '[data-editor-block-ctrl-drag-handle="true"]') !== null;
|
|
1017
1017
|
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(_isDragHandle));
|
|
1018
1018
|
}
|
|
1019
1019
|
if ((event.key === 'ArrowLeft' || event.key === 'ArrowRight' || event.key === 'ArrowDown' || event.key === 'ArrowUp') && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
|
|
1020
1020
|
var _api$blockControls$sh4, _api$blockControls$sh5;
|
|
1021
|
-
var _isBlockMenuOpen = (api === null || api === void 0 || (_api$blockControls$sh4 = api.blockControls.sharedState.currentState()) === null || _api$blockControls$sh4 === void 0 ? void 0 : _api$blockControls$sh4.isMenuOpen) && (0,
|
|
1021
|
+
var _isBlockMenuOpen = (api === null || api === void 0 || (_api$blockControls$sh4 = api.blockControls.sharedState.currentState()) === null || _api$blockControls$sh4 === void 0 ? void 0 : _api$blockControls$sh4.isMenuOpen) && (0, _experiments.editorExperiment)('platform_editor_block_menu', true);
|
|
1022
1022
|
// when block menu is just open, and we press arrow keys, we want to use the arrow keys to navigate the block menu
|
|
1023
1023
|
// in this scenario, isSelectedViaDragHandle should not be set to false
|
|
1024
1024
|
if (api !== null && api !== void 0 && (_api$blockControls$sh5 = api.blockControls.sharedState.currentState()) !== null && _api$blockControls$sh5 !== void 0 && _api$blockControls$sh5.isSelectedViaDragHandle && !_isBlockMenuOpen) {
|
|
@@ -10,7 +10,7 @@ var _state = require("@atlaskit/editor-prosemirror/state");
|
|
|
10
10
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
11
11
|
var _utils2 = require("@atlaskit/editor-tables/utils");
|
|
12
12
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
|
-
var
|
|
13
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
14
14
|
var getInlineNodePos = exports.getInlineNodePos = function getInlineNodePos(doc, start, nodeSize) {
|
|
15
15
|
var $startPos = doc.resolve(start);
|
|
16
16
|
// To trigger the annotation floating toolbar for non-selectable node, we need to select inline nodes
|
|
@@ -96,7 +96,7 @@ var newGetSelection = exports.newGetSelection = function newGetSelection(doc, se
|
|
|
96
96
|
var isNodeSelection = node && _state.NodeSelection.isSelectable(node);
|
|
97
97
|
var nodeSize = node ? node.nodeSize : 1;
|
|
98
98
|
var nodeName = node === null || node === void 0 ? void 0 : node.type.name;
|
|
99
|
-
if ((0,
|
|
99
|
+
if ((0, _experiments.editorExperiment)('platform_editor_block_menu', true)) {
|
|
100
100
|
var _doc$nodeAt;
|
|
101
101
|
// if mediaGroup only has a single child, we want to select the child
|
|
102
102
|
if (nodeName === 'mediaGroup' && (node === null || node === void 0 ? void 0 : node.childCount) === 1) {
|
|
@@ -141,7 +141,7 @@ var newGetSelection = exports.newGetSelection = function newGetSelection(doc, se
|
|
|
141
141
|
return new _state.TextSelection(doc.resolve(inlineNodePos), doc.resolve(inlineNodeEndPos));
|
|
142
142
|
};
|
|
143
143
|
var getSelection = exports.getSelection = function getSelection(tr, start, api) {
|
|
144
|
-
if ((0, _toolbarFlagCheck.areToolbarFlagsEnabled)(Boolean(api === null || api === void 0 ? void 0 : api.toolbar)) || (0,
|
|
144
|
+
if ((0, _toolbarFlagCheck.areToolbarFlagsEnabled)(Boolean(api === null || api === void 0 ? void 0 : api.toolbar)) || (0, _experiments.editorExperiment)('platform_editor_block_menu', true)) {
|
|
145
145
|
return newGetSelection(tr.doc, tr.selection.empty, start);
|
|
146
146
|
}
|
|
147
147
|
return oldGetSelection(tr, start);
|
|
@@ -1047,7 +1047,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref3) {
|
|
|
1047
1047
|
setDragHandleDisabled(false);
|
|
1048
1048
|
}
|
|
1049
1049
|
}, [api === null || api === void 0 ? void 0 : api.blockControls.sharedState, isMultiSelect, isShiftDown, isTopLevelNodeValue, view]);
|
|
1050
|
-
var dragHandleMessage = (0,
|
|
1050
|
+
var dragHandleMessage = (0, _experiments.editorExperiment)('platform_editor_block_menu', true) ? formatMessage(_messages.blockControlsMessages.dragToMoveClickToOpen, {
|
|
1051
1051
|
br: (0, _react2.jsx)("br", null)
|
|
1052
1052
|
}) : formatMessage(_messages.blockControlsMessages.dragToMove);
|
|
1053
1053
|
|
|
@@ -1136,15 +1136,15 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref3) {
|
|
|
1136
1136
|
css: [(0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? dragHandleButtonStyles : dragHandleButtonStylesOld, (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && dragHandleColor,
|
|
1137
1137
|
// ED-26266: Fixed the drag handle highlight when selecting multiple line in Firefox
|
|
1138
1138
|
// See https://product-fabric.atlassian.net/browse/ED-26266
|
|
1139
|
-
browser.gecko && dragHandleMultiLineSelectionFixFirefox, (0, _experiments.editorExperiment)('advanced_layouts', true) && isLayoutColumn && layoutColumnDragHandleStyles, dragHandleSelected && hasHadInteraction && selectedStyles, (0, _experiments.editorExperiment)('platform_editor_preview_panel_responsiveness', true) && (0, _experiments.editorExperiment)('platform_editor_controls', 'control') && dragHandleButtonSmallScreenStyles, (0,
|
|
1139
|
+
browser.gecko && dragHandleMultiLineSelectionFixFirefox, (0, _experiments.editorExperiment)('advanced_layouts', true) && isLayoutColumn && layoutColumnDragHandleStyles, dragHandleSelected && hasHadInteraction && selectedStyles, (0, _experiments.editorExperiment)('platform_editor_preview_panel_responsiveness', true) && (0, _experiments.editorExperiment)('platform_editor_controls', 'control') && dragHandleButtonSmallScreenStyles, (0, _experiments.editorExperiment)('platform_editor_block_menu', true) && isFocused && keyboardFocusedDragHandleStyles, (0, _experiments.editorExperiment)('platform_editor_block_menu', true) ? focusedStyles : focusedStylesOld, ((0, _expValEquals.expValEquals)('confluence_compact_text_format', 'isEnabled', true) || (0, _expValEquals.expValEquals)('cc_editor_ai_content_mode', 'variant', 'test') && (0, _platformFeatureFlags.fg)('platform_editor_content_mode_button_mvp')) && dragHandleButtonDenseModeStyles],
|
|
1140
1140
|
ref: buttonRef
|
|
1141
1141
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
1142
1142
|
,
|
|
1143
1143
|
style: !(0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? (0, _experiments.editorExperiment)('platform_editor_block_control_optimise_render', true) ? positionStyles : positionStylesOld : {},
|
|
1144
1144
|
onMouseDown: (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_selection_toolbar_block_handle', 'isEnabled', true) ? handleMouseDown : undefined,
|
|
1145
|
-
onMouseUp: (0,
|
|
1146
|
-
onClick: (0,
|
|
1147
|
-
onKeyDown: (0,
|
|
1145
|
+
onMouseUp: (0, _experiments.editorExperiment)('platform_editor_block_menu', true) ? handleMouseUp : undefined,
|
|
1146
|
+
onClick: (0, _experiments.editorExperiment)('platform_editor_block_menu', true) ? handleOnClickNew : handleOnClick,
|
|
1147
|
+
onKeyDown: (0, _experiments.editorExperiment)('platform_editor_block_menu', true) ? handleKeyDownNew : handleKeyDown
|
|
1148
1148
|
// eslint-disable-next-line @atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop
|
|
1149
1149
|
,
|
|
1150
1150
|
onDrop: handleOnDrop,
|
|
@@ -1153,7 +1153,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref3) {
|
|
|
1153
1153
|
"data-blocks-drag-handle": (0, _expValEqualsNoExposure.expValEqualsNoExposure)('confluence_remix_icon_right_side', 'isEnabled', true) || undefined,
|
|
1154
1154
|
"data-testid": "block-ctrl-drag-handle",
|
|
1155
1155
|
"aria-label": dragHandleAriaLabel,
|
|
1156
|
-
onBlur: (0,
|
|
1156
|
+
onBlur: (0, _experiments.editorExperiment)('platform_editor_block_menu', true) ? function () {
|
|
1157
1157
|
return setIsFocused(false);
|
|
1158
1158
|
} : undefined
|
|
1159
1159
|
}, (0, _react2.jsx)(_primitives.Box, {
|
|
@@ -3,7 +3,6 @@ import { expandSelectionBounds } from '@atlaskit/editor-common/selection';
|
|
|
3
3
|
import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
|
|
4
4
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
5
5
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
|
-
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
7
6
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
8
7
|
import { handleKeyDownWithPreservedSelection } from './editor-commands/handle-key-down-with-preserved-selection';
|
|
9
8
|
import { mapPreservedSelection } from './editor-commands/map-preserved-selection';
|
|
@@ -54,7 +53,7 @@ export const blockControlsPlugin = ({
|
|
|
54
53
|
plugin: () => createInteractionTrackingPlugin(rightSideControlsEnabled)
|
|
55
54
|
});
|
|
56
55
|
}
|
|
57
|
-
if (
|
|
56
|
+
if (editorExperiment('platform_editor_block_menu', true)) {
|
|
58
57
|
pmPlugins.push({
|
|
59
58
|
name: 'blockControlsSelectionPreservationPlugin',
|
|
60
59
|
plugin: createSelectionPreservationPlugin(api)
|
|
@@ -95,7 +94,7 @@ export const blockControlsPlugin = ({
|
|
|
95
94
|
tr
|
|
96
95
|
}) => {
|
|
97
96
|
var _api$userIntent, _api$userIntent$share, _api$blockControls, _api$blockControls$sh, _options$anchorName, _api$blockControls2, _api$blockControls2$s;
|
|
98
|
-
if (!
|
|
97
|
+
if (!editorExperiment('platform_editor_block_menu', true)) {
|
|
99
98
|
return tr;
|
|
100
99
|
}
|
|
101
100
|
const currMeta = tr.getMeta(key);
|
|
@@ -325,7 +324,7 @@ export const blockControlsPlugin = ({
|
|
|
325
324
|
sharedState.rightSideControlsEnabled = rightSideControlsEnabled;
|
|
326
325
|
sharedState.hoverSide = rightSideControlsEnabled ? (_interactionTrackingP4 = interactionTrackingPluginKey.getState(editorState)) === null || _interactionTrackingP4 === void 0 ? void 0 : _interactionTrackingP4.hoverSide : undefined;
|
|
327
326
|
}
|
|
328
|
-
if (
|
|
327
|
+
if (editorExperiment('platform_editor_block_menu', true)) {
|
|
329
328
|
var _selectionPreservatio;
|
|
330
329
|
sharedState.preservedSelection = (_selectionPreservatio = selectionPreservationPluginKey.getState(editorState)) === null || _selectionPreservatio === void 0 ? void 0 : _selectionPreservatio.preservedSelection;
|
|
331
330
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { DIRECTION } from '@atlaskit/editor-common/types';
|
|
3
|
-
import {
|
|
3
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
4
4
|
import { key } from '../pm-plugins/main';
|
|
5
5
|
import { mapPreservedSelection } from '../pm-plugins/utils/selection';
|
|
6
6
|
import { moveNode } from './move-node';
|
|
@@ -21,7 +21,7 @@ export const moveNodeWithBlockMenu = (api, direction) => {
|
|
|
21
21
|
tr
|
|
22
22
|
}) => {
|
|
23
23
|
var _api$blockControls$sh;
|
|
24
|
-
if (!
|
|
24
|
+
if (!editorExperiment('platform_editor_block_menu', true)) {
|
|
25
25
|
return tr;
|
|
26
26
|
}
|
|
27
27
|
const preservedSelection = api === null || api === void 0 ? void 0 : (_api$blockControls$sh = api.blockControls.sharedState.currentState()) === null || _api$blockControls$sh === void 0 ? void 0 : _api$blockControls$sh.preservedSelection;
|
|
@@ -445,7 +445,7 @@ export const moveNode = api => (start, to, inputMethod = INPUT_METHOD.DRAG_AND_D
|
|
|
445
445
|
});
|
|
446
446
|
if (
|
|
447
447
|
// when move node via block menu, we need to keep the focus on block menu popup, so don't move focus to editor in this scenario
|
|
448
|
-
!(inputMethod === INPUT_METHOD.BLOCK_MENU &&
|
|
448
|
+
!(inputMethod === INPUT_METHOD.BLOCK_MENU && editorExperiment('platform_editor_block_menu', true))) {
|
|
449
449
|
api === null || api === void 0 ? void 0 : api.core.actions.focus();
|
|
450
450
|
}
|
|
451
451
|
const $mappedTo = tr.doc.resolve(mappedTo);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
2
2
|
import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
3
|
-
import {
|
|
3
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
4
4
|
import { createPreservedSelection } from '../../pm-plugins/utils/selection';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -28,7 +28,7 @@ export const getNodeBoundsFromSelection = selection => {
|
|
|
28
28
|
// Special case: if a media node (file) is selected, we need to get the parent mediaGroup
|
|
29
29
|
// This handles the case where clicking on a file creates a NodeSelection of the media node
|
|
30
30
|
// but we want to move the entire mediaGroup that wraps it
|
|
31
|
-
if (selection instanceof NodeSelection && selection.node.type.name === 'media' && selection.node.attrs.type === 'file' &&
|
|
31
|
+
if (selection instanceof NodeSelection && selection.node.type.name === 'media' && selection.node.attrs.type === 'file' && editorExperiment('platform_editor_block_menu', true)) {
|
|
32
32
|
// The media node is wrapped in a mediaGroup, so we need to get the parent position
|
|
33
33
|
const mediaGroupPos = selection.$from.pos - 1;
|
|
34
34
|
const mediaGroupNode = selection.$from.doc.nodeAt(mediaGroupPos);
|
|
@@ -53,7 +53,7 @@ export const getNodeBoundsFromSelection = selection => {
|
|
|
53
53
|
export const getPosWhenMoveNodeUp = ($currentNodePos, currentNodePos) => {
|
|
54
54
|
const nodeIndex = $currentNodePos.index();
|
|
55
55
|
const nodeBefore = $currentNodePos.depth > 1 && nodeIndex === 0 ? $currentNodePos.node($currentNodePos.depth) : $currentNodePos.nodeBefore;
|
|
56
|
-
if ((nodeBefore === null || nodeBefore === void 0 ? void 0 : nodeBefore.type.name) === 'layoutColumn' &&
|
|
56
|
+
if ((nodeBefore === null || nodeBefore === void 0 ? void 0 : nodeBefore.type.name) === 'layoutColumn' && editorExperiment('platform_editor_block_menu', true)) {
|
|
57
57
|
return -1;
|
|
58
58
|
}
|
|
59
59
|
return nodeBefore ? currentNodePos - nodeBefore.nodeSize : -1;
|
|
@@ -68,7 +68,7 @@ export const getPosWhenMoveNodeDown = ({
|
|
|
68
68
|
return -1;
|
|
69
69
|
}
|
|
70
70
|
const nodeAfter = tr.doc.nodeAt(nodeAfterPos);
|
|
71
|
-
if (
|
|
71
|
+
if (editorExperiment('platform_editor_block_menu', true)) {
|
|
72
72
|
const nodeAtCurrentPos = tr.doc.nodeAt($currentNodePos.pos);
|
|
73
73
|
// if move empty line down to another empty line, move to the position of the next empty line
|
|
74
74
|
if ((nodeAtCurrentPos === null || nodeAtCurrentPos === void 0 ? void 0 : nodeAtCurrentPos.content.size) === 0 && nodeAtCurrentPos.type.name !== 'extension' && (nodeAfter === null || nodeAfter === void 0 ? void 0 : nodeAfter.content.size) === 0 && nodeAfter.type.name !== 'extension') {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DRAG_HANDLE_SELECTOR } from '@atlaskit/editor-common/styles';
|
|
2
2
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
3
|
-
import {
|
|
3
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
4
4
|
export const handleMouseDown = api => (view, event) => {
|
|
5
5
|
if (!(event.target instanceof HTMLElement)) {
|
|
6
6
|
return false;
|
|
@@ -27,7 +27,7 @@ export const handleMouseDown = api => (view, event) => {
|
|
|
27
27
|
api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.showDragHandleAt(rootPos, '', (_rootNode$type$name3 = rootNode.type.name) !== null && _rootNode$type$name3 !== void 0 ? _rootNode$type$name3 : '', undefined, rootPos, '', (_rootNode$type$name4 = rootNode.type.name) !== null && _rootNode$type$name4 !== void 0 ? _rootNode$type$name4 : ''));
|
|
28
28
|
}
|
|
29
29
|
} else {
|
|
30
|
-
const isDragHandle = event.target.closest(
|
|
30
|
+
const isDragHandle = event.target.closest(editorExperiment('platform_editor_block_menu', true) ? DRAG_HANDLE_SELECTOR : '[data-editor-block-ctrl-drag-handle]') !== null;
|
|
31
31
|
api === null || api === void 0 ? void 0 : api.core.actions.execute(({
|
|
32
32
|
tr
|
|
33
33
|
}) => {
|
|
@@ -38,7 +38,7 @@ export const handleMouseDown = api => (view, event) => {
|
|
|
38
38
|
* When block menu is enabled, reset intent back to 'default' as editor-plugin-block-menu sets the user intent to 'blockMenuOpen', and setting here
|
|
39
39
|
* causes flickering as this runs before editor-plugin-block-menu.
|
|
40
40
|
*/
|
|
41
|
-
if (
|
|
41
|
+
if (editorExperiment('platform_editor_block_menu', true)) {
|
|
42
42
|
// if target is drag handle, block menu will be opened
|
|
43
43
|
if (!isDragHandle) {
|
|
44
44
|
var _api$userIntent;
|
|
@@ -60,7 +60,9 @@ export const handleMouseOver = (view, event, api) => {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
// If the editor view is not in focus when the block menu is open, do not update the drag handle
|
|
63
|
-
if (!view.hasFocus() && isMenuOpen &&
|
|
63
|
+
if (!view.hasFocus() && isMenuOpen && editorExperiment('platform_editor_block_menu', true, {
|
|
64
|
+
exposure: true
|
|
65
|
+
})) {
|
|
64
66
|
return false;
|
|
65
67
|
}
|
|
66
68
|
|
|
@@ -188,7 +190,7 @@ export const handleMouseOver = (view, event, api) => {
|
|
|
188
190
|
if (nodeType) {
|
|
189
191
|
// platform_editor_controls note: enables quick insert
|
|
190
192
|
if (toolbarFlagsEnabled) {
|
|
191
|
-
if (
|
|
193
|
+
if (editorExperiment('platform_editor_block_menu', true)) {
|
|
192
194
|
var _selectionPreservatio;
|
|
193
195
|
const preservedSelection = (_selectionPreservatio = selectionPreservationPluginKey.getState(view.state)) === null || _selectionPreservatio === void 0 ? void 0 : _selectionPreservatio.preservedSelection;
|
|
194
196
|
const selection = preservedSelection || view.state.selection;
|
|
@@ -209,7 +211,7 @@ export const handleMouseOver = (view, event, api) => {
|
|
|
209
211
|
var _api$core3, _api$blockControls5;
|
|
210
212
|
api === null || api === void 0 ? void 0 : (_api$core3 = api.core) === null || _api$core3 === void 0 ? void 0 : _api$core3.actions.execute(api === null || api === void 0 ? void 0 : (_api$blockControls5 = api.blockControls) === null || _api$blockControls5 === void 0 ? void 0 : _api$blockControls5.commands.showDragHandleAt(targetPos, anchorName, nodeType));
|
|
211
213
|
}
|
|
212
|
-
if (
|
|
214
|
+
if (editorExperiment('platform_editor_block_menu', true)) {
|
|
213
215
|
var _api$userIntent, _api$userIntent$share;
|
|
214
216
|
if (isMenuOpen && originalAnchorName && (api === null || api === void 0 ? void 0 : (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 ? void 0 : (_api$userIntent$share = _api$userIntent.sharedState.currentState()) === null || _api$userIntent$share === void 0 ? void 0 : _api$userIntent$share.currentUserIntent) === 'blockMenuOpen') {
|
|
215
217
|
var _api$core4, _api$blockControls6;
|
|
@@ -304,7 +304,7 @@ export const apply = (api, formatMessage, tr, currentState, newState, flags, nod
|
|
|
304
304
|
// Which caused the drag handle onClick event not firing, then block menu wouldn't be opened
|
|
305
305
|
// This is caused by the mappedPos.deletedAfter sometimes returning true in webkit browsers even though the active node still exists
|
|
306
306
|
// This is likely a prosemirror and safari integration bug, but to unblock the issue, we are going to use mappedPos.deleted in safari for now
|
|
307
|
-
if (browser.webkit &&
|
|
307
|
+
if (browser.webkit && editorExperiment('platform_editor_block_menu', true)) {
|
|
308
308
|
mappedPos = tr.mapping.mapResult(activeNode.pos);
|
|
309
309
|
isActiveNodeDeleted = mappedPos.deleted;
|
|
310
310
|
} else {
|
|
@@ -631,7 +631,7 @@ export const apply = (api, formatMessage, tr, currentState, newState, flags, nod
|
|
|
631
631
|
newActiveNode = isEmptyDoc || !(meta !== null && meta !== void 0 && meta.activeNode) && findHandleDec(decorations, (_latestActiveNode12 = latestActiveNode) === null || _latestActiveNode12 === void 0 ? void 0 : _latestActiveNode12.pos, (_latestActiveNode13 = latestActiveNode) === null || _latestActiveNode13 === void 0 ? void 0 : _latestActiveNode13.pos).length === 0 ? null : latestActiveNode;
|
|
632
632
|
}
|
|
633
633
|
let isMenuOpenNew = isMenuOpen;
|
|
634
|
-
if (
|
|
634
|
+
if (editorExperiment('platform_editor_block_menu', true)) {
|
|
635
635
|
if (meta !== null && meta !== void 0 && meta.closeMenu) {
|
|
636
636
|
isMenuOpenNew = false;
|
|
637
637
|
} else if (meta !== null && meta !== void 0 && meta.toggleMenu) {
|
|
@@ -653,9 +653,9 @@ export const apply = (api, formatMessage, tr, currentState, newState, flags, nod
|
|
|
653
653
|
activeDropTargetNode: currentActiveDropTargetNode,
|
|
654
654
|
isDragging: (_meta$isDragging3 = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging3 !== void 0 ? _meta$isDragging3 : isDragging,
|
|
655
655
|
isMenuOpen: isMenuOpenNew,
|
|
656
|
-
menuTriggerBy: flags.toolbarFlagsEnabled ||
|
|
656
|
+
menuTriggerBy: flags.toolbarFlagsEnabled || editorExperiment('platform_editor_block_menu', true) ? (meta === null || meta === void 0 ? void 0 : (_meta$toggleMenu = meta.toggleMenu) === null || _meta$toggleMenu === void 0 ? void 0 : _meta$toggleMenu.anchorName) || menuTriggerBy : undefined,
|
|
657
657
|
menuTriggerByNode: editorExperiment('platform_synced_block', true) ? (meta === null || meta === void 0 ? void 0 : (_meta$toggleMenu2 = meta.toggleMenu) === null || _meta$toggleMenu2 === void 0 ? void 0 : _meta$toggleMenu2.triggerByNode) || menuTriggerByNode : undefined,
|
|
658
|
-
blockMenuOptions:
|
|
658
|
+
blockMenuOptions: editorExperiment('platform_editor_block_menu', true) ? {
|
|
659
659
|
canMoveUp: (meta === null || meta === void 0 ? void 0 : (_meta$toggleMenu3 = meta.toggleMenu) === null || _meta$toggleMenu3 === void 0 ? void 0 : _meta$toggleMenu3.moveUp) !== undefined ? meta === null || meta === void 0 ? void 0 : (_meta$toggleMenu4 = meta.toggleMenu) === null || _meta$toggleMenu4 === void 0 ? void 0 : _meta$toggleMenu4.moveUp : blockMenuOptions === null || blockMenuOptions === void 0 ? void 0 : blockMenuOptions.canMoveUp,
|
|
660
660
|
canMoveDown: (meta === null || meta === void 0 ? void 0 : (_meta$toggleMenu5 = meta.toggleMenu) === null || _meta$toggleMenu5 === void 0 ? void 0 : _meta$toggleMenu5.moveDown) !== undefined ? meta === null || meta === void 0 ? void 0 : (_meta$toggleMenu6 = meta.toggleMenu) === null || _meta$toggleMenu6 === void 0 ? void 0 : _meta$toggleMenu6.moveDown : blockMenuOptions === null || blockMenuOptions === void 0 ? void 0 : blockMenuOptions.canMoveDown,
|
|
661
661
|
openedViaKeyboard: (meta === null || meta === void 0 ? void 0 : (_meta$toggleMenu7 = meta.toggleMenu) === null || _meta$toggleMenu7 === void 0 ? void 0 : _meta$toggleMenu7.openedViaKeyboard) !== undefined ? meta === null || meta === void 0 ? void 0 : (_meta$toggleMenu8 = meta.toggleMenu) === null || _meta$toggleMenu8 === void 0 ? void 0 : _meta$toggleMenu8.openedViaKeyboard : blockMenuOptions === null || blockMenuOptions === void 0 ? void 0 : blockMenuOptions.openedViaKeyboard
|
|
@@ -890,12 +890,12 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI, nodeDecora
|
|
|
890
890
|
}
|
|
891
891
|
}
|
|
892
892
|
if ((event.key === 'Enter' || event.key === ' ') && event.target instanceof HTMLElement && editorExperiment('platform_editor_controls', 'variant1')) {
|
|
893
|
-
const isDragHandle = event.target.closest(
|
|
893
|
+
const isDragHandle = event.target.closest(editorExperiment('platform_editor_block_menu', true) ? DRAG_HANDLE_SELECTOR : '[data-editor-block-ctrl-drag-handle="true"]') !== null;
|
|
894
894
|
api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(isDragHandle));
|
|
895
895
|
}
|
|
896
896
|
if ((event.key === 'ArrowLeft' || event.key === 'ArrowRight' || event.key === 'ArrowDown' || event.key === 'ArrowUp') && editorExperiment('platform_editor_controls', 'variant1')) {
|
|
897
897
|
var _api$blockControls$sh2, _api$blockControls$sh3;
|
|
898
|
-
const isBlockMenuOpen = (api === null || api === void 0 ? void 0 : (_api$blockControls$sh2 = api.blockControls.sharedState.currentState()) === null || _api$blockControls$sh2 === void 0 ? void 0 : _api$blockControls$sh2.isMenuOpen) &&
|
|
898
|
+
const isBlockMenuOpen = (api === null || api === void 0 ? void 0 : (_api$blockControls$sh2 = api.blockControls.sharedState.currentState()) === null || _api$blockControls$sh2 === void 0 ? void 0 : _api$blockControls$sh2.isMenuOpen) && editorExperiment('platform_editor_block_menu', true);
|
|
899
899
|
// when block menu is just open, and we press arrow keys, we want to use the arrow keys to navigate the block menu
|
|
900
900
|
// in this scenario, isSelectedViaDragHandle should not be set to false
|
|
901
901
|
if (api !== null && api !== void 0 && (_api$blockControls$sh3 = api.blockControls.sharedState.currentState()) !== null && _api$blockControls$sh3 !== void 0 && _api$blockControls$sh3.isSelectedViaDragHandle && !isBlockMenuOpen) {
|
|
@@ -918,12 +918,12 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI, nodeDecora
|
|
|
918
918
|
}
|
|
919
919
|
}
|
|
920
920
|
if ((event.key === 'Enter' || event.key === ' ') && event.target instanceof HTMLElement && editorExperiment('platform_editor_controls', 'variant1')) {
|
|
921
|
-
const isDragHandle = event.target.closest(
|
|
921
|
+
const isDragHandle = event.target.closest(editorExperiment('platform_editor_block_menu', true) ? DRAG_HANDLE_SELECTOR : '[data-editor-block-ctrl-drag-handle="true"]') !== null;
|
|
922
922
|
api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(isDragHandle));
|
|
923
923
|
}
|
|
924
924
|
if ((event.key === 'ArrowLeft' || event.key === 'ArrowRight' || event.key === 'ArrowDown' || event.key === 'ArrowUp') && editorExperiment('platform_editor_controls', 'variant1')) {
|
|
925
925
|
var _api$blockControls$sh4, _api$blockControls$sh5;
|
|
926
|
-
const isBlockMenuOpen = (api === null || api === void 0 ? void 0 : (_api$blockControls$sh4 = api.blockControls.sharedState.currentState()) === null || _api$blockControls$sh4 === void 0 ? void 0 : _api$blockControls$sh4.isMenuOpen) &&
|
|
926
|
+
const isBlockMenuOpen = (api === null || api === void 0 ? void 0 : (_api$blockControls$sh4 = api.blockControls.sharedState.currentState()) === null || _api$blockControls$sh4 === void 0 ? void 0 : _api$blockControls$sh4.isMenuOpen) && editorExperiment('platform_editor_block_menu', true);
|
|
927
927
|
// when block menu is just open, and we press arrow keys, we want to use the arrow keys to navigate the block menu
|
|
928
928
|
// in this scenario, isSelectedViaDragHandle should not be set to false
|
|
929
929
|
if (api !== null && api !== void 0 && (_api$blockControls$sh5 = api.blockControls.sharedState.currentState()) !== null && _api$blockControls$sh5 !== void 0 && _api$blockControls$sh5.isSelectedViaDragHandle && !isBlockMenuOpen) {
|
|
@@ -4,7 +4,7 @@ import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state
|
|
|
4
4
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
5
5
|
import { selectTableClosestToPos } from '@atlaskit/editor-tables/utils';
|
|
6
6
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
|
-
import {
|
|
7
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
8
8
|
export const getInlineNodePos = (doc, start, nodeSize) => {
|
|
9
9
|
const $startPos = doc.resolve(start);
|
|
10
10
|
// To trigger the annotation floating toolbar for non-selectable node, we need to select inline nodes
|
|
@@ -91,7 +91,7 @@ export const newGetSelection = (doc, selectionEmpty, start) => {
|
|
|
91
91
|
const isNodeSelection = node && NodeSelection.isSelectable(node);
|
|
92
92
|
const nodeSize = node ? node.nodeSize : 1;
|
|
93
93
|
const nodeName = node === null || node === void 0 ? void 0 : node.type.name;
|
|
94
|
-
if (
|
|
94
|
+
if (editorExperiment('platform_editor_block_menu', true)) {
|
|
95
95
|
var _doc$nodeAt;
|
|
96
96
|
// if mediaGroup only has a single child, we want to select the child
|
|
97
97
|
if (nodeName === 'mediaGroup' && (node === null || node === void 0 ? void 0 : node.childCount) === 1) {
|
|
@@ -135,7 +135,7 @@ export const newGetSelection = (doc, selectionEmpty, start) => {
|
|
|
135
135
|
return new TextSelection(doc.resolve(inlineNodePos), doc.resolve(inlineNodeEndPos));
|
|
136
136
|
};
|
|
137
137
|
export const getSelection = (tr, start, api) => {
|
|
138
|
-
if (areToolbarFlagsEnabled(Boolean(api === null || api === void 0 ? void 0 : api.toolbar)) ||
|
|
138
|
+
if (areToolbarFlagsEnabled(Boolean(api === null || api === void 0 ? void 0 : api.toolbar)) || editorExperiment('platform_editor_block_menu', true)) {
|
|
139
139
|
return newGetSelection(tr.doc, tr.selection.empty, start);
|
|
140
140
|
}
|
|
141
141
|
return oldGetSelection(tr, start);
|
|
@@ -1032,7 +1032,7 @@ export const DragHandle = ({
|
|
|
1032
1032
|
setDragHandleDisabled(false);
|
|
1033
1033
|
}
|
|
1034
1034
|
}, [api === null || api === void 0 ? void 0 : api.blockControls.sharedState, isMultiSelect, isShiftDown, isTopLevelNodeValue, view]);
|
|
1035
|
-
const dragHandleMessage =
|
|
1035
|
+
const dragHandleMessage = editorExperiment('platform_editor_block_menu', true) ? formatMessage(blockControlsMessages.dragToMoveClickToOpen, {
|
|
1036
1036
|
br: jsx("br", null)
|
|
1037
1037
|
}) : formatMessage(blockControlsMessages.dragToMove);
|
|
1038
1038
|
|
|
@@ -1120,15 +1120,15 @@ export const DragHandle = ({
|
|
|
1120
1120
|
css: [editorExperiment('platform_editor_controls', 'variant1') ? dragHandleButtonStyles : dragHandleButtonStylesOld, editorExperiment('platform_editor_controls', 'variant1') && dragHandleColor,
|
|
1121
1121
|
// ED-26266: Fixed the drag handle highlight when selecting multiple line in Firefox
|
|
1122
1122
|
// See https://product-fabric.atlassian.net/browse/ED-26266
|
|
1123
|
-
browser.gecko && dragHandleMultiLineSelectionFixFirefox, editorExperiment('advanced_layouts', true) && isLayoutColumn && layoutColumnDragHandleStyles, dragHandleSelected && hasHadInteraction && selectedStyles, editorExperiment('platform_editor_preview_panel_responsiveness', true) && editorExperiment('platform_editor_controls', 'control') && dragHandleButtonSmallScreenStyles,
|
|
1123
|
+
browser.gecko && dragHandleMultiLineSelectionFixFirefox, editorExperiment('advanced_layouts', true) && isLayoutColumn && layoutColumnDragHandleStyles, dragHandleSelected && hasHadInteraction && selectedStyles, editorExperiment('platform_editor_preview_panel_responsiveness', true) && editorExperiment('platform_editor_controls', 'control') && dragHandleButtonSmallScreenStyles, editorExperiment('platform_editor_block_menu', true) && isFocused && keyboardFocusedDragHandleStyles, editorExperiment('platform_editor_block_menu', true) ? focusedStyles : focusedStylesOld, (expValEquals('confluence_compact_text_format', 'isEnabled', true) || expValEquals('cc_editor_ai_content_mode', 'variant', 'test') && fg('platform_editor_content_mode_button_mvp')) && dragHandleButtonDenseModeStyles],
|
|
1124
1124
|
ref: buttonRef
|
|
1125
1125
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
1126
1126
|
,
|
|
1127
1127
|
style: !editorExperiment('platform_editor_controls', 'variant1') ? editorExperiment('platform_editor_block_control_optimise_render', true) ? positionStyles : positionStylesOld : {},
|
|
1128
1128
|
onMouseDown: expValEqualsNoExposure('platform_editor_selection_toolbar_block_handle', 'isEnabled', true) ? handleMouseDown : undefined,
|
|
1129
|
-
onMouseUp:
|
|
1130
|
-
onClick:
|
|
1131
|
-
onKeyDown:
|
|
1129
|
+
onMouseUp: editorExperiment('platform_editor_block_menu', true) ? handleMouseUp : undefined,
|
|
1130
|
+
onClick: editorExperiment('platform_editor_block_menu', true) ? handleOnClickNew : handleOnClick,
|
|
1131
|
+
onKeyDown: editorExperiment('platform_editor_block_menu', true) ? handleKeyDownNew : handleKeyDown
|
|
1132
1132
|
// eslint-disable-next-line @atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop
|
|
1133
1133
|
,
|
|
1134
1134
|
onDrop: handleOnDrop,
|
|
@@ -1137,7 +1137,7 @@ export const DragHandle = ({
|
|
|
1137
1137
|
"data-blocks-drag-handle": expValEqualsNoExposure('confluence_remix_icon_right_side', 'isEnabled', true) || undefined,
|
|
1138
1138
|
"data-testid": "block-ctrl-drag-handle",
|
|
1139
1139
|
"aria-label": dragHandleAriaLabel,
|
|
1140
|
-
onBlur:
|
|
1140
|
+
onBlur: editorExperiment('platform_editor_block_menu', true) ? () => setIsFocused(false) : undefined
|
|
1141
1141
|
}, jsx(Box, {
|
|
1142
1142
|
xcss: iconWrapperStyles
|
|
1143
1143
|
// eslint-disable-next-line @atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop
|
|
@@ -6,7 +6,6 @@ import { expandSelectionBounds } from '@atlaskit/editor-common/selection';
|
|
|
6
6
|
import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
|
|
7
7
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
8
8
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
|
-
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
10
9
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
11
10
|
import { handleKeyDownWithPreservedSelection } from './editor-commands/handle-key-down-with-preserved-selection';
|
|
12
11
|
import { mapPreservedSelection as _mapPreservedSelection } from './editor-commands/map-preserved-selection';
|
|
@@ -61,7 +60,7 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
|
61
60
|
}
|
|
62
61
|
});
|
|
63
62
|
}
|
|
64
|
-
if (
|
|
63
|
+
if (editorExperiment('platform_editor_block_menu', true)) {
|
|
65
64
|
pmPlugins.push({
|
|
66
65
|
name: 'blockControlsSelectionPreservationPlugin',
|
|
67
66
|
plugin: createSelectionPreservationPlugin(api)
|
|
@@ -102,7 +101,7 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
|
102
101
|
return function (_ref4) {
|
|
103
102
|
var _api$userIntent, _api$blockControls, _options$anchorName, _api$blockControls2;
|
|
104
103
|
var tr = _ref4.tr;
|
|
105
|
-
if (!
|
|
104
|
+
if (!editorExperiment('platform_editor_block_menu', true)) {
|
|
106
105
|
return tr;
|
|
107
106
|
}
|
|
108
107
|
var currMeta = tr.getMeta(key);
|
|
@@ -335,7 +334,7 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
|
335
334
|
sharedState.rightSideControlsEnabled = rightSideControlsEnabled;
|
|
336
335
|
sharedState.hoverSide = rightSideControlsEnabled ? (_interactionTrackingP4 = interactionTrackingPluginKey.getState(editorState)) === null || _interactionTrackingP4 === void 0 ? void 0 : _interactionTrackingP4.hoverSide : undefined;
|
|
337
336
|
}
|
|
338
|
-
if (
|
|
337
|
+
if (editorExperiment('platform_editor_block_menu', true)) {
|
|
339
338
|
var _selectionPreservatio;
|
|
340
339
|
sharedState.preservedSelection = (_selectionPreservatio = selectionPreservationPluginKey.getState(editorState)) === null || _selectionPreservatio === void 0 ? void 0 : _selectionPreservatio.preservedSelection;
|
|
341
340
|
}
|
|
@@ -3,7 +3,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
3
3
|
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) { _defineProperty(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; }
|
|
4
4
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
5
5
|
import { DIRECTION } from '@atlaskit/editor-common/types';
|
|
6
|
-
import {
|
|
6
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
7
7
|
import { key } from '../pm-plugins/main';
|
|
8
8
|
import { mapPreservedSelection } from '../pm-plugins/utils/selection';
|
|
9
9
|
import { moveNode } from './move-node';
|
|
@@ -23,7 +23,7 @@ export var moveNodeWithBlockMenu = function moveNodeWithBlockMenu(api, direction
|
|
|
23
23
|
return function (_ref) {
|
|
24
24
|
var _api$blockControls$sh;
|
|
25
25
|
var tr = _ref.tr;
|
|
26
|
-
if (!
|
|
26
|
+
if (!editorExperiment('platform_editor_block_menu', true)) {
|
|
27
27
|
return tr;
|
|
28
28
|
}
|
|
29
29
|
var preservedSelection = api === null || api === void 0 || (_api$blockControls$sh = api.blockControls.sharedState.currentState()) === null || _api$blockControls$sh === void 0 ? void 0 : _api$blockControls$sh.preservedSelection;
|
|
@@ -437,7 +437,7 @@ export var moveNode = function moveNode(api) {
|
|
|
437
437
|
}));
|
|
438
438
|
if (
|
|
439
439
|
// when move node via block menu, we need to keep the focus on block menu popup, so don't move focus to editor in this scenario
|
|
440
|
-
!(inputMethod === INPUT_METHOD.BLOCK_MENU &&
|
|
440
|
+
!(inputMethod === INPUT_METHOD.BLOCK_MENU && editorExperiment('platform_editor_block_menu', true))) {
|
|
441
441
|
api === null || api === void 0 || api.core.actions.focus();
|
|
442
442
|
}
|
|
443
443
|
var $mappedTo = tr.doc.resolve(mappedTo);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
2
2
|
import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
3
|
-
import {
|
|
3
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
4
4
|
import { createPreservedSelection } from '../../pm-plugins/utils/selection';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -28,7 +28,7 @@ export var getNodeBoundsFromSelection = function getNodeBoundsFromSelection(sele
|
|
|
28
28
|
// Special case: if a media node (file) is selected, we need to get the parent mediaGroup
|
|
29
29
|
// This handles the case where clicking on a file creates a NodeSelection of the media node
|
|
30
30
|
// but we want to move the entire mediaGroup that wraps it
|
|
31
|
-
if (selection instanceof NodeSelection && selection.node.type.name === 'media' && selection.node.attrs.type === 'file' &&
|
|
31
|
+
if (selection instanceof NodeSelection && selection.node.type.name === 'media' && selection.node.attrs.type === 'file' && editorExperiment('platform_editor_block_menu', true)) {
|
|
32
32
|
// The media node is wrapped in a mediaGroup, so we need to get the parent position
|
|
33
33
|
var mediaGroupPos = selection.$from.pos - 1;
|
|
34
34
|
var mediaGroupNode = selection.$from.doc.nodeAt(mediaGroupPos);
|
|
@@ -53,7 +53,7 @@ export var getNodeBoundsFromSelection = function getNodeBoundsFromSelection(sele
|
|
|
53
53
|
export var getPosWhenMoveNodeUp = function getPosWhenMoveNodeUp($currentNodePos, currentNodePos) {
|
|
54
54
|
var nodeIndex = $currentNodePos.index();
|
|
55
55
|
var nodeBefore = $currentNodePos.depth > 1 && nodeIndex === 0 ? $currentNodePos.node($currentNodePos.depth) : $currentNodePos.nodeBefore;
|
|
56
|
-
if ((nodeBefore === null || nodeBefore === void 0 ? void 0 : nodeBefore.type.name) === 'layoutColumn' &&
|
|
56
|
+
if ((nodeBefore === null || nodeBefore === void 0 ? void 0 : nodeBefore.type.name) === 'layoutColumn' && editorExperiment('platform_editor_block_menu', true)) {
|
|
57
57
|
return -1;
|
|
58
58
|
}
|
|
59
59
|
return nodeBefore ? currentNodePos - nodeBefore.nodeSize : -1;
|
|
@@ -67,7 +67,7 @@ export var getPosWhenMoveNodeDown = function getPosWhenMoveNodeDown(_ref) {
|
|
|
67
67
|
return -1;
|
|
68
68
|
}
|
|
69
69
|
var nodeAfter = tr.doc.nodeAt(nodeAfterPos);
|
|
70
|
-
if (
|
|
70
|
+
if (editorExperiment('platform_editor_block_menu', true)) {
|
|
71
71
|
var nodeAtCurrentPos = tr.doc.nodeAt($currentNodePos.pos);
|
|
72
72
|
// if move empty line down to another empty line, move to the position of the next empty line
|
|
73
73
|
if ((nodeAtCurrentPos === null || nodeAtCurrentPos === void 0 ? void 0 : nodeAtCurrentPos.content.size) === 0 && nodeAtCurrentPos.type.name !== 'extension' && (nodeAfter === null || nodeAfter === void 0 ? void 0 : nodeAfter.content.size) === 0 && nodeAfter.type.name !== 'extension') {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DRAG_HANDLE_SELECTOR } from '@atlaskit/editor-common/styles';
|
|
2
2
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
3
|
-
import {
|
|
3
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
4
4
|
export var handleMouseDown = function handleMouseDown(api) {
|
|
5
5
|
return function (view, event) {
|
|
6
6
|
if (!(event.target instanceof HTMLElement)) {
|
|
@@ -28,7 +28,7 @@ export var handleMouseDown = function handleMouseDown(api) {
|
|
|
28
28
|
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.showDragHandleAt(rootPos, '', (_rootNode$type$name3 = rootNode.type.name) !== null && _rootNode$type$name3 !== void 0 ? _rootNode$type$name3 : '', undefined, rootPos, '', (_rootNode$type$name4 = rootNode.type.name) !== null && _rootNode$type$name4 !== void 0 ? _rootNode$type$name4 : ''));
|
|
29
29
|
}
|
|
30
30
|
} else {
|
|
31
|
-
var isDragHandle = event.target.closest(
|
|
31
|
+
var isDragHandle = event.target.closest(editorExperiment('platform_editor_block_menu', true) ? DRAG_HANDLE_SELECTOR : '[data-editor-block-ctrl-drag-handle]') !== null;
|
|
32
32
|
api === null || api === void 0 || api.core.actions.execute(function (_ref) {
|
|
33
33
|
var tr = _ref.tr;
|
|
34
34
|
api === null || api === void 0 || api.blockControls.commands.setSelectedViaDragHandle(isDragHandle)({
|
|
@@ -38,7 +38,7 @@ export var handleMouseDown = function handleMouseDown(api) {
|
|
|
38
38
|
* When block menu is enabled, reset intent back to 'default' as editor-plugin-block-menu sets the user intent to 'blockMenuOpen', and setting here
|
|
39
39
|
* causes flickering as this runs before editor-plugin-block-menu.
|
|
40
40
|
*/
|
|
41
|
-
if (
|
|
41
|
+
if (editorExperiment('platform_editor_block_menu', true)) {
|
|
42
42
|
// if target is drag handle, block menu will be opened
|
|
43
43
|
if (!isDragHandle) {
|
|
44
44
|
var _api$userIntent;
|
|
@@ -61,7 +61,9 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
// If the editor view is not in focus when the block menu is open, do not update the drag handle
|
|
64
|
-
if (!view.hasFocus() && isMenuOpen &&
|
|
64
|
+
if (!view.hasFocus() && isMenuOpen && editorExperiment('platform_editor_block_menu', true, {
|
|
65
|
+
exposure: true
|
|
66
|
+
})) {
|
|
65
67
|
return false;
|
|
66
68
|
}
|
|
67
69
|
|
|
@@ -189,7 +191,7 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
|
|
|
189
191
|
if (nodeType) {
|
|
190
192
|
// platform_editor_controls note: enables quick insert
|
|
191
193
|
if (toolbarFlagsEnabled) {
|
|
192
|
-
if (
|
|
194
|
+
if (editorExperiment('platform_editor_block_menu', true)) {
|
|
193
195
|
var _selectionPreservatio;
|
|
194
196
|
var preservedSelection = (_selectionPreservatio = selectionPreservationPluginKey.getState(view.state)) === null || _selectionPreservatio === void 0 ? void 0 : _selectionPreservatio.preservedSelection;
|
|
195
197
|
var selection = preservedSelection || view.state.selection;
|
|
@@ -210,7 +212,7 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
|
|
|
210
212
|
var _api$core3, _api$blockControls5;
|
|
211
213
|
api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(api === null || api === void 0 || (_api$blockControls5 = api.blockControls) === null || _api$blockControls5 === void 0 ? void 0 : _api$blockControls5.commands.showDragHandleAt(targetPos, anchorName, nodeType));
|
|
212
214
|
}
|
|
213
|
-
if (
|
|
215
|
+
if (editorExperiment('platform_editor_block_menu', true)) {
|
|
214
216
|
var _api$userIntent;
|
|
215
217
|
if (isMenuOpen && originalAnchorName && (api === null || api === void 0 || (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 || (_api$userIntent = _api$userIntent.sharedState.currentState()) === null || _api$userIntent === void 0 ? void 0 : _api$userIntent.currentUserIntent) === 'blockMenuOpen') {
|
|
216
218
|
var _api$core4, _api$blockControls6;
|
|
@@ -306,7 +306,7 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
|
|
|
306
306
|
// Which caused the drag handle onClick event not firing, then block menu wouldn't be opened
|
|
307
307
|
// This is caused by the mappedPos.deletedAfter sometimes returning true in webkit browsers even though the active node still exists
|
|
308
308
|
// This is likely a prosemirror and safari integration bug, but to unblock the issue, we are going to use mappedPos.deleted in safari for now
|
|
309
|
-
if (browser.webkit &&
|
|
309
|
+
if (browser.webkit && editorExperiment('platform_editor_block_menu', true)) {
|
|
310
310
|
_mappedPos = tr.mapping.mapResult(activeNode.pos);
|
|
311
311
|
isActiveNodeDeleted = _mappedPos.deleted;
|
|
312
312
|
} else {
|
|
@@ -724,7 +724,7 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
|
|
|
724
724
|
newActiveNode = isEmptyDoc || !(meta !== null && meta !== void 0 && meta.activeNode) && findHandleDec(decorations, (_latestActiveNode12 = latestActiveNode) === null || _latestActiveNode12 === void 0 ? void 0 : _latestActiveNode12.pos, (_latestActiveNode13 = latestActiveNode) === null || _latestActiveNode13 === void 0 ? void 0 : _latestActiveNode13.pos).length === 0 ? null : latestActiveNode;
|
|
725
725
|
}
|
|
726
726
|
var isMenuOpenNew = isMenuOpen;
|
|
727
|
-
if (
|
|
727
|
+
if (editorExperiment('platform_editor_block_menu', true)) {
|
|
728
728
|
if (meta !== null && meta !== void 0 && meta.closeMenu) {
|
|
729
729
|
isMenuOpenNew = false;
|
|
730
730
|
} else if (meta !== null && meta !== void 0 && meta.toggleMenu) {
|
|
@@ -746,9 +746,9 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
|
|
|
746
746
|
activeDropTargetNode: currentActiveDropTargetNode,
|
|
747
747
|
isDragging: (_meta$isDragging3 = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging3 !== void 0 ? _meta$isDragging3 : isDragging,
|
|
748
748
|
isMenuOpen: isMenuOpenNew,
|
|
749
|
-
menuTriggerBy: flags.toolbarFlagsEnabled ||
|
|
749
|
+
menuTriggerBy: flags.toolbarFlagsEnabled || editorExperiment('platform_editor_block_menu', true) ? (meta === null || meta === void 0 || (_meta$toggleMenu = meta.toggleMenu) === null || _meta$toggleMenu === void 0 ? void 0 : _meta$toggleMenu.anchorName) || menuTriggerBy : undefined,
|
|
750
750
|
menuTriggerByNode: editorExperiment('platform_synced_block', true) ? (meta === null || meta === void 0 || (_meta$toggleMenu2 = meta.toggleMenu) === null || _meta$toggleMenu2 === void 0 ? void 0 : _meta$toggleMenu2.triggerByNode) || menuTriggerByNode : undefined,
|
|
751
|
-
blockMenuOptions:
|
|
751
|
+
blockMenuOptions: editorExperiment('platform_editor_block_menu', true) ? {
|
|
752
752
|
canMoveUp: (meta === null || meta === void 0 || (_meta$toggleMenu3 = meta.toggleMenu) === null || _meta$toggleMenu3 === void 0 ? void 0 : _meta$toggleMenu3.moveUp) !== undefined ? meta === null || meta === void 0 || (_meta$toggleMenu4 = meta.toggleMenu) === null || _meta$toggleMenu4 === void 0 ? void 0 : _meta$toggleMenu4.moveUp : blockMenuOptions === null || blockMenuOptions === void 0 ? void 0 : blockMenuOptions.canMoveUp,
|
|
753
753
|
canMoveDown: (meta === null || meta === void 0 || (_meta$toggleMenu5 = meta.toggleMenu) === null || _meta$toggleMenu5 === void 0 ? void 0 : _meta$toggleMenu5.moveDown) !== undefined ? meta === null || meta === void 0 || (_meta$toggleMenu6 = meta.toggleMenu) === null || _meta$toggleMenu6 === void 0 ? void 0 : _meta$toggleMenu6.moveDown : blockMenuOptions === null || blockMenuOptions === void 0 ? void 0 : blockMenuOptions.canMoveDown,
|
|
754
754
|
openedViaKeyboard: (meta === null || meta === void 0 || (_meta$toggleMenu7 = meta.toggleMenu) === null || _meta$toggleMenu7 === void 0 ? void 0 : _meta$toggleMenu7.openedViaKeyboard) !== undefined ? meta === null || meta === void 0 || (_meta$toggleMenu8 = meta.toggleMenu) === null || _meta$toggleMenu8 === void 0 ? void 0 : _meta$toggleMenu8.openedViaKeyboard : blockMenuOptions === null || blockMenuOptions === void 0 ? void 0 : blockMenuOptions.openedViaKeyboard
|
|
@@ -980,12 +980,12 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
980
980
|
}
|
|
981
981
|
}
|
|
982
982
|
if ((event.key === 'Enter' || event.key === ' ') && event.target instanceof HTMLElement && editorExperiment('platform_editor_controls', 'variant1')) {
|
|
983
|
-
var isDragHandle = event.target.closest(
|
|
983
|
+
var isDragHandle = event.target.closest(editorExperiment('platform_editor_block_menu', true) ? DRAG_HANDLE_SELECTOR : '[data-editor-block-ctrl-drag-handle="true"]') !== null;
|
|
984
984
|
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(isDragHandle));
|
|
985
985
|
}
|
|
986
986
|
if ((event.key === 'ArrowLeft' || event.key === 'ArrowRight' || event.key === 'ArrowDown' || event.key === 'ArrowUp') && editorExperiment('platform_editor_controls', 'variant1')) {
|
|
987
987
|
var _api$blockControls$sh2, _api$blockControls$sh3;
|
|
988
|
-
var isBlockMenuOpen = (api === null || api === void 0 || (_api$blockControls$sh2 = api.blockControls.sharedState.currentState()) === null || _api$blockControls$sh2 === void 0 ? void 0 : _api$blockControls$sh2.isMenuOpen) &&
|
|
988
|
+
var isBlockMenuOpen = (api === null || api === void 0 || (_api$blockControls$sh2 = api.blockControls.sharedState.currentState()) === null || _api$blockControls$sh2 === void 0 ? void 0 : _api$blockControls$sh2.isMenuOpen) && editorExperiment('platform_editor_block_menu', true);
|
|
989
989
|
// when block menu is just open, and we press arrow keys, we want to use the arrow keys to navigate the block menu
|
|
990
990
|
// in this scenario, isSelectedViaDragHandle should not be set to false
|
|
991
991
|
if (api !== null && api !== void 0 && (_api$blockControls$sh3 = api.blockControls.sharedState.currentState()) !== null && _api$blockControls$sh3 !== void 0 && _api$blockControls$sh3.isSelectedViaDragHandle && !isBlockMenuOpen) {
|
|
@@ -1007,12 +1007,12 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
1007
1007
|
}
|
|
1008
1008
|
}
|
|
1009
1009
|
if ((event.key === 'Enter' || event.key === ' ') && event.target instanceof HTMLElement && editorExperiment('platform_editor_controls', 'variant1')) {
|
|
1010
|
-
var _isDragHandle = event.target.closest(
|
|
1010
|
+
var _isDragHandle = event.target.closest(editorExperiment('platform_editor_block_menu', true) ? DRAG_HANDLE_SELECTOR : '[data-editor-block-ctrl-drag-handle="true"]') !== null;
|
|
1011
1011
|
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(_isDragHandle));
|
|
1012
1012
|
}
|
|
1013
1013
|
if ((event.key === 'ArrowLeft' || event.key === 'ArrowRight' || event.key === 'ArrowDown' || event.key === 'ArrowUp') && editorExperiment('platform_editor_controls', 'variant1')) {
|
|
1014
1014
|
var _api$blockControls$sh4, _api$blockControls$sh5;
|
|
1015
|
-
var _isBlockMenuOpen = (api === null || api === void 0 || (_api$blockControls$sh4 = api.blockControls.sharedState.currentState()) === null || _api$blockControls$sh4 === void 0 ? void 0 : _api$blockControls$sh4.isMenuOpen) &&
|
|
1015
|
+
var _isBlockMenuOpen = (api === null || api === void 0 || (_api$blockControls$sh4 = api.blockControls.sharedState.currentState()) === null || _api$blockControls$sh4 === void 0 ? void 0 : _api$blockControls$sh4.isMenuOpen) && editorExperiment('platform_editor_block_menu', true);
|
|
1016
1016
|
// when block menu is just open, and we press arrow keys, we want to use the arrow keys to navigate the block menu
|
|
1017
1017
|
// in this scenario, isSelectedViaDragHandle should not be set to false
|
|
1018
1018
|
if (api !== null && api !== void 0 && (_api$blockControls$sh5 = api.blockControls.sharedState.currentState()) !== null && _api$blockControls$sh5 !== void 0 && _api$blockControls$sh5.isSelectedViaDragHandle && !_isBlockMenuOpen) {
|
|
@@ -4,7 +4,7 @@ import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state
|
|
|
4
4
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
5
5
|
import { selectTableClosestToPos } from '@atlaskit/editor-tables/utils';
|
|
6
6
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
|
-
import {
|
|
7
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
8
8
|
export var getInlineNodePos = function getInlineNodePos(doc, start, nodeSize) {
|
|
9
9
|
var $startPos = doc.resolve(start);
|
|
10
10
|
// To trigger the annotation floating toolbar for non-selectable node, we need to select inline nodes
|
|
@@ -90,7 +90,7 @@ export var newGetSelection = function newGetSelection(doc, selectionEmpty, start
|
|
|
90
90
|
var isNodeSelection = node && NodeSelection.isSelectable(node);
|
|
91
91
|
var nodeSize = node ? node.nodeSize : 1;
|
|
92
92
|
var nodeName = node === null || node === void 0 ? void 0 : node.type.name;
|
|
93
|
-
if (
|
|
93
|
+
if (editorExperiment('platform_editor_block_menu', true)) {
|
|
94
94
|
var _doc$nodeAt;
|
|
95
95
|
// if mediaGroup only has a single child, we want to select the child
|
|
96
96
|
if (nodeName === 'mediaGroup' && (node === null || node === void 0 ? void 0 : node.childCount) === 1) {
|
|
@@ -135,7 +135,7 @@ export var newGetSelection = function newGetSelection(doc, selectionEmpty, start
|
|
|
135
135
|
return new TextSelection(doc.resolve(inlineNodePos), doc.resolve(inlineNodeEndPos));
|
|
136
136
|
};
|
|
137
137
|
export var getSelection = function getSelection(tr, start, api) {
|
|
138
|
-
if (areToolbarFlagsEnabled(Boolean(api === null || api === void 0 ? void 0 : api.toolbar)) ||
|
|
138
|
+
if (areToolbarFlagsEnabled(Boolean(api === null || api === void 0 ? void 0 : api.toolbar)) || editorExperiment('platform_editor_block_menu', true)) {
|
|
139
139
|
return newGetSelection(tr.doc, tr.selection.empty, start);
|
|
140
140
|
}
|
|
141
141
|
return oldGetSelection(tr, start);
|
|
@@ -1044,7 +1044,7 @@ export var DragHandle = function DragHandle(_ref3) {
|
|
|
1044
1044
|
setDragHandleDisabled(false);
|
|
1045
1045
|
}
|
|
1046
1046
|
}, [api === null || api === void 0 ? void 0 : api.blockControls.sharedState, isMultiSelect, isShiftDown, isTopLevelNodeValue, view]);
|
|
1047
|
-
var dragHandleMessage =
|
|
1047
|
+
var dragHandleMessage = editorExperiment('platform_editor_block_menu', true) ? formatMessage(blockControlsMessages.dragToMoveClickToOpen, {
|
|
1048
1048
|
br: jsx("br", null)
|
|
1049
1049
|
}) : formatMessage(blockControlsMessages.dragToMove);
|
|
1050
1050
|
|
|
@@ -1133,15 +1133,15 @@ export var DragHandle = function DragHandle(_ref3) {
|
|
|
1133
1133
|
css: [editorExperiment('platform_editor_controls', 'variant1') ? dragHandleButtonStyles : dragHandleButtonStylesOld, editorExperiment('platform_editor_controls', 'variant1') && dragHandleColor,
|
|
1134
1134
|
// ED-26266: Fixed the drag handle highlight when selecting multiple line in Firefox
|
|
1135
1135
|
// See https://product-fabric.atlassian.net/browse/ED-26266
|
|
1136
|
-
browser.gecko && dragHandleMultiLineSelectionFixFirefox, editorExperiment('advanced_layouts', true) && isLayoutColumn && layoutColumnDragHandleStyles, dragHandleSelected && hasHadInteraction && selectedStyles, editorExperiment('platform_editor_preview_panel_responsiveness', true) && editorExperiment('platform_editor_controls', 'control') && dragHandleButtonSmallScreenStyles,
|
|
1136
|
+
browser.gecko && dragHandleMultiLineSelectionFixFirefox, editorExperiment('advanced_layouts', true) && isLayoutColumn && layoutColumnDragHandleStyles, dragHandleSelected && hasHadInteraction && selectedStyles, editorExperiment('platform_editor_preview_panel_responsiveness', true) && editorExperiment('platform_editor_controls', 'control') && dragHandleButtonSmallScreenStyles, editorExperiment('platform_editor_block_menu', true) && isFocused && keyboardFocusedDragHandleStyles, editorExperiment('platform_editor_block_menu', true) ? focusedStyles : focusedStylesOld, (expValEquals('confluence_compact_text_format', 'isEnabled', true) || expValEquals('cc_editor_ai_content_mode', 'variant', 'test') && fg('platform_editor_content_mode_button_mvp')) && dragHandleButtonDenseModeStyles],
|
|
1137
1137
|
ref: buttonRef
|
|
1138
1138
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
1139
1139
|
,
|
|
1140
1140
|
style: !editorExperiment('platform_editor_controls', 'variant1') ? editorExperiment('platform_editor_block_control_optimise_render', true) ? positionStyles : positionStylesOld : {},
|
|
1141
1141
|
onMouseDown: expValEqualsNoExposure('platform_editor_selection_toolbar_block_handle', 'isEnabled', true) ? handleMouseDown : undefined,
|
|
1142
|
-
onMouseUp:
|
|
1143
|
-
onClick:
|
|
1144
|
-
onKeyDown:
|
|
1142
|
+
onMouseUp: editorExperiment('platform_editor_block_menu', true) ? handleMouseUp : undefined,
|
|
1143
|
+
onClick: editorExperiment('platform_editor_block_menu', true) ? handleOnClickNew : handleOnClick,
|
|
1144
|
+
onKeyDown: editorExperiment('platform_editor_block_menu', true) ? handleKeyDownNew : handleKeyDown
|
|
1145
1145
|
// eslint-disable-next-line @atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop
|
|
1146
1146
|
,
|
|
1147
1147
|
onDrop: handleOnDrop,
|
|
@@ -1150,7 +1150,7 @@ export var DragHandle = function DragHandle(_ref3) {
|
|
|
1150
1150
|
"data-blocks-drag-handle": expValEqualsNoExposure('confluence_remix_icon_right_side', 'isEnabled', true) || undefined,
|
|
1151
1151
|
"data-testid": "block-ctrl-drag-handle",
|
|
1152
1152
|
"aria-label": dragHandleAriaLabel,
|
|
1153
|
-
onBlur:
|
|
1153
|
+
onBlur: editorExperiment('platform_editor_block_menu', true) ? function () {
|
|
1154
1154
|
return setIsFocused(false);
|
|
1155
1155
|
} : undefined
|
|
1156
1156
|
}, jsx(Box, {
|