@atlaskit/editor-plugin-block-controls 20.0.0 → 20.0.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 +18 -0
- package/dist/cjs/blockControlsPlugin.js +12 -16
- package/dist/cjs/editor-commands/move-node-with-block-menu.js +0 -4
- package/dist/cjs/editor-commands/move-node.js +2 -2
- package/dist/cjs/editor-commands/utils/move-node-utils.js +6 -9
- package/dist/cjs/pm-plugins/handle-mouse-down.js +5 -13
- package/dist/cjs/pm-plugins/handle-mouse-over.js +17 -26
- package/dist/cjs/pm-plugins/main.js +11 -15
- package/dist/cjs/pm-plugins/utils/expand-and-update-selection.js +1 -5
- package/dist/cjs/pm-plugins/utils/getSelection.js +11 -95
- package/dist/cjs/ui/drag-handle.js +49 -127
- package/dist/es2019/blockControlsPlugin.js +12 -16
- package/dist/es2019/editor-commands/move-node-with-block-menu.js +0 -4
- package/dist/es2019/editor-commands/move-node.js +2 -2
- package/dist/es2019/editor-commands/utils/move-node-utils.js +6 -9
- package/dist/es2019/pm-plugins/handle-mouse-down.js +5 -13
- package/dist/es2019/pm-plugins/handle-mouse-over.js +17 -26
- package/dist/es2019/pm-plugins/main.js +11 -15
- package/dist/es2019/pm-plugins/utils/expand-and-update-selection.js +1 -5
- package/dist/es2019/pm-plugins/utils/getSelection.js +7 -93
- package/dist/es2019/ui/drag-handle.js +31 -109
- package/dist/esm/blockControlsPlugin.js +12 -16
- package/dist/esm/editor-commands/move-node-with-block-menu.js +0 -4
- package/dist/esm/editor-commands/move-node.js +2 -2
- package/dist/esm/editor-commands/utils/move-node-utils.js +6 -9
- package/dist/esm/pm-plugins/handle-mouse-down.js +5 -13
- package/dist/esm/pm-plugins/handle-mouse-over.js +17 -26
- package/dist/esm/pm-plugins/main.js +11 -15
- package/dist/esm/pm-plugins/utils/expand-and-update-selection.js +1 -5
- package/dist/esm/pm-plugins/utils/getSelection.js +11 -95
- package/dist/esm/ui/drag-handle.js +49 -127
- package/dist/types/pm-plugins/utils/getSelection.d.ts +1 -1
- package/package.json +3 -3
|
@@ -379,7 +379,7 @@ export const apply = (api, formatMessage, tr, currentState, newState, flags, nod
|
|
|
379
379
|
// Which caused the drag handle onClick event not firing, then block menu wouldn't be opened
|
|
380
380
|
// This is caused by the mappedPos.deletedAfter sometimes returning true in webkit browsers even though the active node still exists
|
|
381
381
|
// 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
|
|
382
|
-
if (browser.webkit
|
|
382
|
+
if (browser.webkit) {
|
|
383
383
|
mappedPos = tr.mapping.mapResult(activeNode.pos);
|
|
384
384
|
isActiveNodeDeleted = mappedPos.deleted;
|
|
385
385
|
} else {
|
|
@@ -803,7 +803,7 @@ export const apply = (api, formatMessage, tr, currentState, newState, flags, nod
|
|
|
803
803
|
// handle - so findHandleDec is always empty. Don't clear activeNode in that case.
|
|
804
804
|
const hasHandleOrViewModeControls = !flags.legacyDragHandleEnabled || isViewMode && rightSideControlsEnabled || findHandleDec(decorations, (_latestActiveNode11 = latestActiveNode) === null || _latestActiveNode11 === void 0 ? void 0 : _latestActiveNode11.pos, (_latestActiveNode12 = latestActiveNode) === null || _latestActiveNode12 === void 0 ? void 0 : _latestActiveNode12.pos).length > 0;
|
|
805
805
|
// Keep the registry surface mounted while its Block Menu owns focus.
|
|
806
|
-
const keepActiveNodeForOpenBlockMenu = !flags.legacyDragHandleEnabled && isMenuOpen
|
|
806
|
+
const keepActiveNodeForOpenBlockMenu = !flags.legacyDragHandleEnabled && isMenuOpen;
|
|
807
807
|
newActiveNode = meta !== null && meta !== void 0 && meta.editorBlurred && !keepActiveNodeForOpenBlockMenu || !(meta !== null && meta !== void 0 && meta.activeNode) && !hasHandleOrViewModeControls ? null : latestActiveNode;
|
|
808
808
|
} else {
|
|
809
809
|
var _latestActiveNode13, _latestActiveNode14;
|
|
@@ -822,15 +822,11 @@ export const apply = (api, formatMessage, tr, currentState, newState, flags, nod
|
|
|
822
822
|
});
|
|
823
823
|
}
|
|
824
824
|
let isMenuOpenNew = isMenuOpen;
|
|
825
|
-
if (
|
|
826
|
-
|
|
827
|
-
isMenuOpenNew = false;
|
|
828
|
-
} else if (meta !== null && meta !== void 0 && meta.toggleMenu) {
|
|
829
|
-
const isSameAnchor = (meta === null || meta === void 0 ? void 0 : meta.toggleMenu.anchorName) === menuTriggerBy;
|
|
830
|
-
isMenuOpenNew = menuTriggerBy === undefined || isSameAnchor || !isMenuOpen && !isSameAnchor ? !isMenuOpen : isMenuOpen;
|
|
831
|
-
}
|
|
825
|
+
if (meta !== null && meta !== void 0 && meta.closeMenu) {
|
|
826
|
+
isMenuOpenNew = false;
|
|
832
827
|
} else if (meta !== null && meta !== void 0 && meta.toggleMenu) {
|
|
833
|
-
|
|
828
|
+
const isSameAnchor = (meta === null || meta === void 0 ? void 0 : meta.toggleMenu.anchorName) === menuTriggerBy;
|
|
829
|
+
isMenuOpenNew = menuTriggerBy === undefined || isSameAnchor || !isMenuOpen && !isSameAnchor ? !isMenuOpen : isMenuOpen;
|
|
834
830
|
}
|
|
835
831
|
let isSelectedViaDragHandleNew;
|
|
836
832
|
if (flags.toolbarFlagsEnabled) {
|
|
@@ -845,13 +841,13 @@ export const apply = (api, formatMessage, tr, currentState, newState, flags, nod
|
|
|
845
841
|
activeDropTargetNode: currentActiveDropTargetNode,
|
|
846
842
|
isDragging: (_meta$isDragging3 = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging3 !== void 0 ? _meta$isDragging3 : isDragging,
|
|
847
843
|
isMenuOpen: isMenuOpenNew,
|
|
848
|
-
menuTriggerBy:
|
|
844
|
+
menuTriggerBy: (meta === null || meta === void 0 ? void 0 : (_meta$toggleMenu = meta.toggleMenu) === null || _meta$toggleMenu === void 0 ? void 0 : _meta$toggleMenu.anchorName) || menuTriggerBy,
|
|
849
845
|
menuTriggerByNode: (meta === null || meta === void 0 ? void 0 : (_meta$toggleMenu2 = meta.toggleMenu) === null || _meta$toggleMenu2 === void 0 ? void 0 : _meta$toggleMenu2.triggerByNode) || menuTriggerByNode,
|
|
850
|
-
blockMenuOptions:
|
|
846
|
+
blockMenuOptions: {
|
|
851
847
|
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,
|
|
852
848
|
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,
|
|
853
849
|
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
|
|
854
|
-
}
|
|
850
|
+
},
|
|
855
851
|
editorHeight: (_meta$editorHeight = meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== null && _meta$editorHeight !== void 0 ? _meta$editorHeight : editorHeight,
|
|
856
852
|
editorWidthLeft: (_meta$editorWidthLeft = meta === null || meta === void 0 ? void 0 : meta.editorWidthLeft) !== null && _meta$editorWidthLeft !== void 0 ? _meta$editorWidthLeft : editorWidthLeft,
|
|
857
853
|
editorWidthRight: (_meta$editorWidthRigh = meta === null || meta === void 0 ? void 0 : meta.editorWidthRight) !== null && _meta$editorWidthRigh !== void 0 ? _meta$editorWidthRigh : editorWidthRight,
|
|
@@ -1100,12 +1096,12 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI, nodeDecora
|
|
|
1100
1096
|
}
|
|
1101
1097
|
}
|
|
1102
1098
|
if ((event.key === 'Enter' || event.key === ' ') && event.target instanceof HTMLElement && editorExperiment('platform_editor_controls', 'variant1')) {
|
|
1103
|
-
const isDragHandle = event.target.closest(
|
|
1099
|
+
const isDragHandle = event.target.closest(DRAG_HANDLE_SELECTOR) !== null;
|
|
1104
1100
|
api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(isDragHandle));
|
|
1105
1101
|
}
|
|
1106
1102
|
if ((event.key === 'ArrowLeft' || event.key === 'ArrowRight' || event.key === 'ArrowDown' || event.key === 'ArrowUp') && editorExperiment('platform_editor_controls', 'variant1')) {
|
|
1107
1103
|
var _api$blockControls$sh2, _api$blockControls$sh3;
|
|
1108
|
-
const isBlockMenuOpen =
|
|
1104
|
+
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;
|
|
1109
1105
|
// when block menu is just open, and we press arrow keys, we want to use the arrow keys to navigate the block menu
|
|
1110
1106
|
// in this scenario, isSelectedViaDragHandle should not be set to false
|
|
1111
1107
|
if (api !== null && api !== void 0 && (_api$blockControls$sh3 = api.blockControls.sharedState.currentState()) !== null && _api$blockControls$sh3 !== void 0 && _api$blockControls$sh3.isSelectedViaDragHandle && !isBlockMenuOpen) {
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { selectNodeAtPos } from '@atlaskit/editor-common/node-selection';
|
|
2
2
|
import { expandToBlockRange, isMultiBlockRange } from '@atlaskit/editor-common/selection';
|
|
3
|
-
import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
|
|
4
3
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
5
4
|
import { selectTableClosestToPos } from '@atlaskit/editor-tables/utils';
|
|
6
5
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
7
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
8
6
|
import { selectNode } from './getSelection';
|
|
9
7
|
import { adjustSelectionBoundsForEdgePositions } from './selection';
|
|
10
8
|
const isPosWithinRange = (pos, range) => {
|
|
@@ -60,9 +58,7 @@ export const expandAndUpdateSelection = ({
|
|
|
60
58
|
if (expandedRange.range && isPosWithinRange(startPos, expandedRange.range) && isMultiBlockRange(expandedRange.range)) {
|
|
61
59
|
// Then create a selection from the start of the first node to the end of the last node
|
|
62
60
|
tr.setSelection(TextSelection.create(tr.doc, Math.min(selection.from, expandedRange.$from.pos), Math.max(selection.to, expandedRange.$to.pos)));
|
|
63
|
-
} else if (
|
|
64
|
-
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
65
|
-
fg('platform_editor_maui_jira_updates') && (areToolbarFlagsEnabled(Boolean(api === null || api === void 0 ? void 0 : api.toolbar)) || editorExperiment('platform_editor_block_menu', true))) {
|
|
61
|
+
} else if (fg('platform_editor_maui_jira_updates')) {
|
|
66
62
|
// Under the gate (and when on the simplified newGetSelection path), use
|
|
67
63
|
// the platform-level composer — same path as open-remix-modal, no drift.
|
|
68
64
|
selectNodeAtPos(tr, startPos, nodeType);
|
|
@@ -5,7 +5,6 @@ import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state
|
|
|
5
5
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
6
6
|
import { selectTableClosestToPos } from '@atlaskit/editor-tables/utils';
|
|
7
7
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
8
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
9
8
|
export const getInlineNodePos = (doc, start, nodeSize) => {
|
|
10
9
|
const $startPos = doc.resolve(start);
|
|
11
10
|
// To trigger the annotation floating toolbar for non-selectable node, we need to select inline nodes
|
|
@@ -38,46 +37,6 @@ export const isNodeWithCodeBlock = (tr, start, nodeSize) => {
|
|
|
38
37
|
});
|
|
39
38
|
return hasCodeBlock;
|
|
40
39
|
};
|
|
41
|
-
const isNodeWithMediaOrExtension = (doc, start, nodeSize) => {
|
|
42
|
-
const $startPos = doc.resolve(start);
|
|
43
|
-
let hasMediaOrExtension = false;
|
|
44
|
-
doc.nodesBetween($startPos.pos, $startPos.pos + nodeSize, n => {
|
|
45
|
-
if (['media', 'extension'].includes(n.type.name)) {
|
|
46
|
-
hasMediaOrExtension = true;
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
return hasMediaOrExtension;
|
|
50
|
-
};
|
|
51
|
-
const oldGetSelection = (tr, start) => {
|
|
52
|
-
const node = tr.doc.nodeAt(start);
|
|
53
|
-
const isNodeSelection = node && NodeSelection.isSelectable(node);
|
|
54
|
-
const nodeSize = node ? node.nodeSize : 1;
|
|
55
|
-
const $startPos = tr.doc.resolve(start);
|
|
56
|
-
const nodeName = node === null || node === void 0 ? void 0 : node.type.name;
|
|
57
|
-
const isBlockQuoteWithMediaOrExtension = nodeName === 'blockquote' && isNodeWithMediaOrExtension(tr.doc, start, nodeSize);
|
|
58
|
-
const isListWithMediaOrExtension = nodeName === 'bulletList' && isNodeWithMediaOrExtension(tr.doc, start, nodeSize) || nodeName === 'orderedList' && isNodeWithMediaOrExtension(tr.doc, start, nodeSize);
|
|
59
|
-
if (isNodeSelection && nodeName !== 'blockquote' || isListWithMediaOrExtension || isBlockQuoteWithMediaOrExtension ||
|
|
60
|
-
// decisionList/layoutColumn node is not selectable, but we want to select the whole node not just text
|
|
61
|
-
['decisionList', 'layoutColumn'].includes(nodeName || '')) {
|
|
62
|
-
return new NodeSelection($startPos);
|
|
63
|
-
} else if (nodeName === 'mediaGroup' && (node === null || node === void 0 ? void 0 : node.childCount) === 1) {
|
|
64
|
-
const $mediaStartPos = tr.doc.resolve(start + 1);
|
|
65
|
-
return new NodeSelection($mediaStartPos);
|
|
66
|
-
} else if (
|
|
67
|
-
// Even though mediaGroup is not selectable,
|
|
68
|
-
// we need a quick way to make all child media nodes appear as selected without the need for a custom selection
|
|
69
|
-
nodeName === 'mediaGroup') {
|
|
70
|
-
return new NodeSelection($startPos);
|
|
71
|
-
} else if (nodeName === 'taskList') {
|
|
72
|
-
return TextSelection.create(tr.doc, start, start + nodeSize);
|
|
73
|
-
} else {
|
|
74
|
-
const {
|
|
75
|
-
inlineNodePos,
|
|
76
|
-
inlineNodeEndPos
|
|
77
|
-
} = getInlineNodePos(tr.doc, start, nodeSize);
|
|
78
|
-
return new TextSelection(tr.doc.resolve(inlineNodePos), tr.doc.resolve(inlineNodeEndPos));
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
40
|
|
|
82
41
|
/**
|
|
83
42
|
* Gets the appropriate selection for the node at the given start position.
|
|
@@ -88,76 +47,31 @@ const oldGetSelection = (tr, start) => {
|
|
|
88
47
|
* @returns The appropriate selection for the node.
|
|
89
48
|
*/
|
|
90
49
|
export const newGetSelection = (doc, selectionEmpty, start) => {
|
|
91
|
-
|
|
92
|
-
// platform_editor_block_menu is on — getNodeSelectionForPos matches that
|
|
93
|
-
// simplified path (NodeSelection for all nodes). When block_menu is off,
|
|
94
|
-
// fall through to the oldGetSelection branch which handles expand/taskList/
|
|
95
|
-
// inline nodes correctly with TextSelection.
|
|
96
|
-
if (
|
|
97
|
-
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
98
|
-
fg('platform_editor_maui_jira_updates') && editorExperiment('platform_editor_block_menu', true)) {
|
|
50
|
+
if (fg('platform_editor_maui_jira_updates')) {
|
|
99
51
|
return getNodeSelectionForPos(doc, start) || false;
|
|
100
52
|
}
|
|
101
53
|
const node = doc.nodeAt(start);
|
|
102
|
-
const isNodeSelection = node && NodeSelection.isSelectable(node);
|
|
103
|
-
const nodeSize = node ? node.nodeSize : 1;
|
|
104
54
|
const nodeName = node === null || node === void 0 ? void 0 : node.type.name;
|
|
105
|
-
if (editorExperiment('platform_editor_block_menu', true)) {
|
|
106
|
-
// if mediaGroup only has a single child, we want to select the child
|
|
107
|
-
if (nodeName === 'mediaGroup' && (node === null || node === void 0 ? void 0 : node.childCount) === 1) {
|
|
108
|
-
const $mediaStartPos = doc.resolve(start + 1);
|
|
109
|
-
return new NodeSelection($mediaStartPos);
|
|
110
|
-
}
|
|
111
|
-
return new NodeSelection(doc.resolve(start));
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// this is a fix for empty paragraph selection - put first to avoid any extra work
|
|
115
|
-
if (nodeName === 'paragraph' && selectionEmpty && (node === null || node === void 0 ? void 0 : node.childCount) === 0) {
|
|
116
|
-
return false;
|
|
117
|
-
}
|
|
118
|
-
const isBlockQuoteWithMediaOrExtension = nodeName === 'blockquote' && isNodeWithMediaOrExtension(doc, start, nodeSize);
|
|
119
|
-
const isListWithMediaOrExtension = nodeName === 'bulletList' && isNodeWithMediaOrExtension(doc, start, nodeSize) || nodeName === 'orderedList' && isNodeWithMediaOrExtension(doc, start, nodeSize);
|
|
120
|
-
if (isNodeSelection && nodeName !== 'blockquote' || isListWithMediaOrExtension || isBlockQuoteWithMediaOrExtension ||
|
|
121
|
-
// decisionList/layoutColumn node is not selectable, but we want to select the whole node not just text
|
|
122
|
-
['decisionList', 'layoutColumn'].includes(nodeName || '') || nodeName === 'mediaGroup' && typeof (node === null || node === void 0 ? void 0 : node.childCount) === 'number' && (node === null || node === void 0 ? void 0 : node.childCount) > 1) {
|
|
123
|
-
return new NodeSelection(doc.resolve(start));
|
|
124
|
-
}
|
|
125
55
|
|
|
126
56
|
// if mediaGroup only has a single child, we want to select the child
|
|
127
|
-
if (nodeName === 'mediaGroup') {
|
|
57
|
+
if (nodeName === 'mediaGroup' && (node === null || node === void 0 ? void 0 : node.childCount) === 1) {
|
|
128
58
|
const $mediaStartPos = doc.resolve(start + 1);
|
|
129
59
|
return new NodeSelection($mediaStartPos);
|
|
130
60
|
}
|
|
131
|
-
|
|
132
|
-
return TextSelection.create(doc, start, start + nodeSize);
|
|
133
|
-
}
|
|
134
|
-
const {
|
|
135
|
-
inlineNodePos,
|
|
136
|
-
inlineNodeEndPos
|
|
137
|
-
} = getInlineNodePos(doc, start, nodeSize);
|
|
138
|
-
return new TextSelection(doc.resolve(inlineNodePos), doc.resolve(inlineNodeEndPos));
|
|
61
|
+
return new NodeSelection(doc.resolve(start));
|
|
139
62
|
};
|
|
140
|
-
export const getSelection = (tr, start
|
|
141
|
-
|
|
142
|
-
return newGetSelection(tr.doc, tr.selection.empty, start);
|
|
143
|
-
}
|
|
144
|
-
return oldGetSelection(tr, start);
|
|
63
|
+
export const getSelection = (tr, start) => {
|
|
64
|
+
return newGetSelection(tr.doc, tr.selection.empty, start);
|
|
145
65
|
};
|
|
146
66
|
export const selectNode = (tr, start, nodeType, api) => {
|
|
147
|
-
|
|
148
|
-
// branch — i.e. when platform_editor_block_menu is on or toolbar flags are
|
|
149
|
-
// enabled. This preserves oldGetSelection behaviour (e.g. taskList →
|
|
150
|
-
// TextSelection) in legacy contexts where those flags are off.
|
|
151
|
-
if (
|
|
152
|
-
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
153
|
-
fg('platform_editor_maui_jira_updates') && editorExperiment('platform_editor_block_menu', true)) {
|
|
67
|
+
if (fg('platform_editor_maui_jira_updates')) {
|
|
154
68
|
return selectNodeAtPos(tr, start, nodeType);
|
|
155
69
|
}
|
|
156
70
|
if (nodeType === 'table') {
|
|
157
71
|
tr = selectTableClosestToPos(tr, tr.doc.resolve(start + 1));
|
|
158
72
|
return tr;
|
|
159
73
|
}
|
|
160
|
-
const selection = getSelection(tr, start
|
|
74
|
+
const selection = getSelection(tr, start);
|
|
161
75
|
if (selection) {
|
|
162
76
|
tr.setSelection(selection);
|
|
163
77
|
}
|
|
@@ -14,7 +14,6 @@ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks'
|
|
|
14
14
|
import { dragToMoveDown, dragToMoveLeft, dragToMoveRight, dragToMoveUp, getAriaKeyshortcuts, TooltipContentWithMultipleShortcuts } from '@atlaskit/editor-common/keymaps';
|
|
15
15
|
import { blockControlsMessages } from '@atlaskit/editor-common/messages';
|
|
16
16
|
import { DRAG_HANDLE_WIDTH, tableControlsSpacing } from '@atlaskit/editor-common/styles';
|
|
17
|
-
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
18
17
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
19
18
|
import { akEditorFullPageNarrowBreakout, akEditorTableToolbarSize, relativeSizeToBaseFontSize } from '@atlaskit/editor-shared-styles/consts';
|
|
20
19
|
import DragHandleVerticalIcon from '@atlaskit/icon/core/drag-handle-vertical';
|
|
@@ -35,7 +34,6 @@ import { getMultiSelectAnalyticsAttributes } from '../pm-plugins/utils/analytics
|
|
|
35
34
|
import { getControlBottomCSSValue, getControlHeightCSSValue, getLeftPosition, getNodeHeight, getTopPosition, shouldBeSticky, shouldMaskNodeControls } from '../pm-plugins/utils/drag-handle-positions';
|
|
36
35
|
import { expandAndUpdateSelection } from '../pm-plugins/utils/expand-and-update-selection';
|
|
37
36
|
import { isHandleCorrelatedToSelection, selectNode } from '../pm-plugins/utils/getSelection';
|
|
38
|
-
import { alignAnchorHeadInDirectionOfPos, expandSelectionHeadToNodeAtPos } from '../pm-plugins/utils/selection';
|
|
39
37
|
import { ACTIVE_DRAG_HANDLE_ATTR, ACTIVE_DRAG_HANDLE_FALLBACK_ANCHOR_NAME, DRAG_HANDLE_BORDER_RADIUS, DRAG_HANDLE_HEIGHT, DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH, DRAG_HANDLE_ZINDEX, dragHandleGap, nodeMargins, spacingBetweenNodesForPreview, STICKY_CONTROLS_TOP_MARGIN, STICKY_CONTROLS_TOP_MARGIN_FOR_STICKY_HEADER, topPositionAdjustment } from './consts';
|
|
40
38
|
import { DragHandleNestedIcon } from './drag-handle-nested-icon';
|
|
41
39
|
import { dragPreview } from './drag-preview';
|
|
@@ -187,11 +185,6 @@ const dragHandleButtonStylesOld = css({
|
|
|
187
185
|
backgroundColor: "var(--ds-background-disabled, #0515240F)"
|
|
188
186
|
}
|
|
189
187
|
});
|
|
190
|
-
const focusedStylesOld = css({
|
|
191
|
-
'&:focus': {
|
|
192
|
-
outline: `${"var(--ds-border-width-focused, 2px)"} solid ${"var(--ds-border-focused, #4688EC)"}`
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
188
|
const focusedStyles = css({
|
|
196
189
|
'&:focus-visible': {
|
|
197
190
|
outline: `${"var(--ds-border-width-focused, 2px)"} solid ${"var(--ds-border-focused, #4688EC)"}`
|
|
@@ -362,7 +355,7 @@ export const DragHandle = ({
|
|
|
362
355
|
handleOptions,
|
|
363
356
|
anchorRectCache
|
|
364
357
|
}) => {
|
|
365
|
-
var _api$
|
|
358
|
+
var _api$blockControls7;
|
|
366
359
|
const buttonRef = useRef(null);
|
|
367
360
|
const mouseDownRef = useRef(false);
|
|
368
361
|
const [dragHandleSelected, setDragHandleSelected] = useState(false);
|
|
@@ -497,89 +490,20 @@ export const DragHandle = ({
|
|
|
497
490
|
});
|
|
498
491
|
view.focus();
|
|
499
492
|
}, [api, view, getPos, nodeType, anchorName]);
|
|
500
|
-
const handleOnClick = useCallback(e => {
|
|
501
|
-
var _api$core2;
|
|
502
|
-
api === null || api === void 0 ? void 0 : (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions.execute(({
|
|
503
|
-
tr
|
|
504
|
-
}) => {
|
|
505
|
-
var _api$blockControls$sh, _api$analytics2;
|
|
506
|
-
const startPos = getPos();
|
|
507
|
-
if (startPos === undefined) {
|
|
508
|
-
return tr;
|
|
509
|
-
}
|
|
510
|
-
if (nodeType === 'layoutColumn' && expValEquals('platform_editor_layout_column_menu', 'isEnabled', true)) {
|
|
511
|
-
tr.setMeta('toggleLayoutColumnMenu', buildToggleLayoutColumnMenuMeta(startPos, false));
|
|
512
|
-
}
|
|
513
|
-
const mSelect = 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.multiSelectDnD;
|
|
514
|
-
const $anchor = (mSelect === null || mSelect === void 0 ? void 0 : mSelect.anchor) !== undefined ? tr.doc.resolve(mSelect === null || mSelect === void 0 ? void 0 : mSelect.anchor) : tr.selection.$anchor;
|
|
515
|
-
if (tr.selection.empty || !e.shiftKey) {
|
|
516
|
-
tr = selectNode(tr, startPos, nodeType, api);
|
|
517
|
-
} else if (isTopLevelNodeValue && $anchor.depth <= DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH && e.shiftKey && fg('platform_editor_elements_dnd_shift_click_select')) {
|
|
518
|
-
var _api$blockControls3;
|
|
519
|
-
const alignAnchorHeadToSel = alignAnchorHeadInDirectionOfPos(tr.selection, startPos);
|
|
520
|
-
const selectionWithExpandedHead = expandSelectionHeadToNodeAtPos(alignAnchorHeadToSel, startPos);
|
|
521
|
-
tr.setSelection(selectionWithExpandedHead);
|
|
522
|
-
api === null || api === void 0 ? void 0 : (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 ? void 0 : _api$blockControls3.commands.setMultiSelectPositions()({
|
|
523
|
-
tr
|
|
524
|
-
});
|
|
525
|
-
}
|
|
526
|
-
const resolvedMovingNode = tr.doc.resolve(startPos);
|
|
527
|
-
const maybeNode = resolvedMovingNode.nodeAfter;
|
|
528
|
-
tr.setMeta('scrollIntoView', false);
|
|
529
|
-
api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions.attachAnalyticsEvent({
|
|
530
|
-
eventType: EVENT_TYPE.UI,
|
|
531
|
-
action: ACTION.CLICKED,
|
|
532
|
-
actionSubject: ACTION_SUBJECT.BUTTON,
|
|
533
|
-
actionSubjectId: ACTION_SUBJECT_ID.ELEMENT_DRAG_HANDLE,
|
|
534
|
-
attributes: {
|
|
535
|
-
nodeDepth: resolvedMovingNode.depth,
|
|
536
|
-
nodeTypes: (maybeNode === null || maybeNode === void 0 ? void 0 : maybeNode.type.name) || ''
|
|
537
|
-
}
|
|
538
|
-
})(tr);
|
|
539
|
-
return tr;
|
|
540
|
-
});
|
|
541
|
-
view.focus();
|
|
542
|
-
}, [api, view, getPos, isTopLevelNodeValue, nodeType]);
|
|
543
|
-
const handleKeyDown = useCallback(e => {
|
|
544
|
-
// allow user to use spacebar to select the node
|
|
545
|
-
if (!e.repeat && e.key === ' ') {
|
|
546
|
-
var _api$core3;
|
|
547
|
-
const startPos = getPos();
|
|
548
|
-
api === null || api === void 0 ? void 0 : (_api$core3 = api.core) === null || _api$core3 === void 0 ? void 0 : _api$core3.actions.execute(({
|
|
549
|
-
tr
|
|
550
|
-
}) => {
|
|
551
|
-
if (startPos === undefined) {
|
|
552
|
-
return tr;
|
|
553
|
-
}
|
|
554
|
-
const node = tr.doc.nodeAt(startPos);
|
|
555
|
-
if (!node) {
|
|
556
|
-
return tr;
|
|
557
|
-
}
|
|
558
|
-
const $startPos = tr.doc.resolve(startPos + node.nodeSize);
|
|
559
|
-
const selection = new TextSelection($startPos);
|
|
560
|
-
tr.setSelection(selection);
|
|
561
|
-
return tr;
|
|
562
|
-
});
|
|
563
|
-
} else if (![e.altKey, e.ctrlKey, e.shiftKey].some(pressed => pressed)) {
|
|
564
|
-
// If not trying to press shortcut keys,
|
|
565
|
-
// return focus to editor to resume editing from caret position
|
|
566
|
-
view.focus();
|
|
567
|
-
}
|
|
568
|
-
}, [getPos, api === null || api === void 0 ? void 0 : (_api$core4 = api.core) === null || _api$core4 === void 0 ? void 0 : _api$core4.actions, view]);
|
|
569
493
|
const handleKeyDownNew = useCallback(e => {
|
|
570
494
|
// allow user to use spacebar to select the node
|
|
571
495
|
if (e.key === 'Enter' || !e.repeat && e.key === ' ') {
|
|
572
|
-
var _getDocument, _api$
|
|
496
|
+
var _getDocument, _api$core2;
|
|
573
497
|
if (((_getDocument = getDocument()) === null || _getDocument === void 0 ? void 0 : _getDocument.activeElement) !== buttonRef.current) {
|
|
574
498
|
return;
|
|
575
499
|
}
|
|
576
500
|
e.preventDefault();
|
|
577
501
|
e.stopPropagation();
|
|
578
502
|
const startPos = getPos();
|
|
579
|
-
api === null || api === void 0 ? void 0 : (_api$
|
|
503
|
+
api === null || api === void 0 ? void 0 : (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions.execute(({
|
|
580
504
|
tr
|
|
581
505
|
}) => {
|
|
582
|
-
var _selectionPreservatio2, _api$
|
|
506
|
+
var _selectionPreservatio2, _api$blockControls3, _api$blockControls4, _api$userIntent;
|
|
583
507
|
if (startPos === undefined) {
|
|
584
508
|
return tr;
|
|
585
509
|
}
|
|
@@ -592,7 +516,7 @@ export const DragHandle = ({
|
|
|
592
516
|
nodeType,
|
|
593
517
|
api
|
|
594
518
|
});
|
|
595
|
-
api === null || api === void 0 ? void 0 : (_api$
|
|
519
|
+
api === null || api === void 0 ? void 0 : (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 ? void 0 : _api$blockControls3.commands.startPreservingSelection()({
|
|
596
520
|
tr
|
|
597
521
|
});
|
|
598
522
|
if (nodeType === 'layoutColumn' && expValEquals('platform_editor_layout_column_menu', 'isEnabled', true)) {
|
|
@@ -603,7 +527,7 @@ export const DragHandle = ({
|
|
|
603
527
|
pos: startPos,
|
|
604
528
|
rootPos: tr.doc.resolve(startPos).before(1)
|
|
605
529
|
};
|
|
606
|
-
api === null || api === void 0 ? void 0 : (_api$
|
|
530
|
+
api === null || api === void 0 ? void 0 : (_api$blockControls4 = api.blockControls) === null || _api$blockControls4 === void 0 ? void 0 : _api$blockControls4.commands.toggleBlockMenu({
|
|
607
531
|
anchorName,
|
|
608
532
|
triggerByNode,
|
|
609
533
|
openedViaKeyboard: true
|
|
@@ -636,8 +560,8 @@ export const DragHandle = ({
|
|
|
636
560
|
onGenerateDragPreview: ({
|
|
637
561
|
nativeSetDragImage
|
|
638
562
|
}) => {
|
|
639
|
-
var _api$
|
|
640
|
-
api === null || api === void 0 ? void 0 : (_api$
|
|
563
|
+
var _api$core3, _api$blockControls$sh;
|
|
564
|
+
api === null || api === void 0 ? void 0 : (_api$core3 = api.core) === null || _api$core3 === void 0 ? void 0 : _api$core3.actions.execute(({
|
|
641
565
|
tr
|
|
642
566
|
}) => {
|
|
643
567
|
const handlePos = getPos();
|
|
@@ -646,8 +570,8 @@ export const DragHandle = ({
|
|
|
646
570
|
}
|
|
647
571
|
const newHandlePosCheck = isHandleCorrelatedToSelection(view.state, tr.selection, handlePos);
|
|
648
572
|
if (!tr.selection.empty && newHandlePosCheck) {
|
|
649
|
-
var _api$
|
|
650
|
-
api === null || api === void 0 ? void 0 : (_api$
|
|
573
|
+
var _api$blockControls5;
|
|
574
|
+
api === null || api === void 0 ? void 0 : (_api$blockControls5 = api.blockControls) === null || _api$blockControls5 === void 0 ? void 0 : _api$blockControls5.commands.setMultiSelectPositions()({
|
|
651
575
|
tr
|
|
652
576
|
});
|
|
653
577
|
} else {
|
|
@@ -663,7 +587,7 @@ export const DragHandle = ({
|
|
|
663
587
|
} = state;
|
|
664
588
|
let sliceFrom = selection.from;
|
|
665
589
|
let sliceTo = selection.to;
|
|
666
|
-
const mSelect = api === null || api === void 0 ? void 0 : (_api$blockControls$
|
|
590
|
+
const mSelect = 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.multiSelectDnD;
|
|
667
591
|
if (mSelect) {
|
|
668
592
|
const {
|
|
669
593
|
anchor,
|
|
@@ -754,18 +678,18 @@ export const DragHandle = ({
|
|
|
754
678
|
});
|
|
755
679
|
},
|
|
756
680
|
onDragStart() {
|
|
757
|
-
var _api$
|
|
681
|
+
var _api$core4;
|
|
758
682
|
if (start === undefined) {
|
|
759
683
|
return;
|
|
760
684
|
}
|
|
761
|
-
api === null || api === void 0 ? void 0 : (_api$
|
|
685
|
+
api === null || api === void 0 ? void 0 : (_api$core4 = api.core) === null || _api$core4 === void 0 ? void 0 : _api$core4.actions.execute(({
|
|
762
686
|
tr
|
|
763
687
|
}) => {
|
|
764
|
-
var _api$blockControls$
|
|
688
|
+
var _api$blockControls$sh2, _api$blockControls6, _api$analytics2;
|
|
765
689
|
let nodeTypes, hasSelectedMultipleNodes;
|
|
766
690
|
const resolvedMovingNode = tr.doc.resolve(start);
|
|
767
691
|
const maybeNode = resolvedMovingNode.nodeAfter;
|
|
768
|
-
const mSelect = api === null || api === void 0 ? void 0 : (_api$blockControls$
|
|
692
|
+
const mSelect = 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.multiSelectDnD;
|
|
769
693
|
if (mSelect) {
|
|
770
694
|
const attributes = getMultiSelectAnalyticsAttributes(tr, mSelect.anchor, mSelect.head);
|
|
771
695
|
nodeTypes = attributes.nodeTypes;
|
|
@@ -774,11 +698,11 @@ export const DragHandle = ({
|
|
|
774
698
|
nodeTypes = maybeNode === null || maybeNode === void 0 ? void 0 : maybeNode.type.name;
|
|
775
699
|
hasSelectedMultipleNodes = false;
|
|
776
700
|
}
|
|
777
|
-
api === null || api === void 0 ? void 0 : (_api$
|
|
701
|
+
api === null || api === void 0 ? void 0 : (_api$blockControls6 = api.blockControls) === null || _api$blockControls6 === void 0 ? void 0 : _api$blockControls6.commands.setNodeDragged(getPos, anchorName, nodeType)({
|
|
778
702
|
tr
|
|
779
703
|
});
|
|
780
704
|
tr.setMeta('scrollIntoView', false);
|
|
781
|
-
api === null || api === void 0 ? void 0 : (_api$
|
|
705
|
+
api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions.attachAnalyticsEvent({
|
|
782
706
|
eventType: EVENT_TYPE.UI,
|
|
783
707
|
action: ACTION.DRAGGED,
|
|
784
708
|
actionSubject: ACTION_SUBJECT.ELEMENT,
|
|
@@ -1010,11 +934,11 @@ export const DragHandle = ({
|
|
|
1010
934
|
setDragHandleSelected(isHandleCorrelatedToSelection(view.state, selection, start));
|
|
1011
935
|
}, [start, selection, view]);
|
|
1012
936
|
useEffect(() => {
|
|
1013
|
-
var _api$blockControls$
|
|
937
|
+
var _api$blockControls$sh3;
|
|
1014
938
|
if (isShiftDown === undefined || view.state.selection.empty || !fg('platform_editor_elements_dnd_shift_click_select')) {
|
|
1015
939
|
return;
|
|
1016
940
|
}
|
|
1017
|
-
const mSelect = api === null || api === void 0 ? void 0 : (_api$blockControls$
|
|
941
|
+
const mSelect = api === null || api === void 0 ? void 0 : (_api$blockControls$sh3 = api.blockControls.sharedState.currentState()) === null || _api$blockControls$sh3 === void 0 ? void 0 : _api$blockControls$sh3.multiSelectDnD;
|
|
1018
942
|
const $anchor = (mSelect === null || mSelect === void 0 ? void 0 : mSelect.anchor) !== undefined ? view.state.doc.resolve(mSelect === null || mSelect === void 0 ? void 0 : mSelect.anchor) : view.state.selection.$anchor;
|
|
1019
943
|
const isLayoutColumnMenuEnabled = expValEquals('platform_editor_layout_column_menu', 'isEnabled', true);
|
|
1020
944
|
if (isShiftDown && !(isLayoutColumnMenuEnabled && isLayoutColumn) && (!isTopLevelNodeValue || isTopLevelNodeValue && $anchor.depth > DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH)) {
|
|
@@ -1022,15 +946,15 @@ export const DragHandle = ({
|
|
|
1022
946
|
} else {
|
|
1023
947
|
setDragHandleDisabled(false);
|
|
1024
948
|
}
|
|
1025
|
-
}, [api === null || api === void 0 ? void 0 : (_api$
|
|
1026
|
-
const dragHandleMessage =
|
|
949
|
+
}, [api === null || api === void 0 ? void 0 : (_api$blockControls7 = api.blockControls) === null || _api$blockControls7 === void 0 ? void 0 : _api$blockControls7.sharedState, isLayoutColumn, isShiftDown, isTopLevelNodeValue, view]);
|
|
950
|
+
const dragHandleMessage = formatMessage(blockControlsMessages.dragToMoveClickToOpen, {
|
|
1027
951
|
br: jsx("br", null)
|
|
1028
|
-
})
|
|
952
|
+
});
|
|
1029
953
|
|
|
1030
954
|
// Create a string version for aria-label
|
|
1031
|
-
const dragHandleAriaLabel =
|
|
955
|
+
const dragHandleAriaLabel = formatMessage(blockControlsMessages.dragToMoveClickToOpen, {
|
|
1032
956
|
br: ' '
|
|
1033
|
-
})
|
|
957
|
+
});
|
|
1034
958
|
let helpDescriptors = isTopLevelNodeValue ? [{
|
|
1035
959
|
description: dragHandleMessage
|
|
1036
960
|
}, {
|
|
@@ -1111,15 +1035,15 @@ export const DragHandle = ({
|
|
|
1111
1035
|
css: [editorExperiment('platform_editor_controls', 'variant1') ? dragHandleButtonStyles : dragHandleButtonStylesOld, editorExperiment('platform_editor_controls', 'variant1') && dragHandleColor,
|
|
1112
1036
|
// ED-26266: Fixed the drag handle highlight when selecting multiple line in Firefox
|
|
1113
1037
|
// See https://product-fabric.atlassian.net/browse/ED-26266
|
|
1114
|
-
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,
|
|
1038
|
+
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, isFocused && keyboardFocusedDragHandleStyles, focusedStyles, dragHandleButtonScaledStyles],
|
|
1115
1039
|
ref: buttonRef
|
|
1116
1040
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
1117
1041
|
,
|
|
1118
1042
|
style: !editorExperiment('platform_editor_controls', 'variant1') ? positionStylesOld : {},
|
|
1119
1043
|
onMouseDown: expValEqualsNoExposure('platform_editor_selection_toolbar_block_handle', 'isEnabled', true) ? handleMouseDown : undefined,
|
|
1120
|
-
onMouseUp:
|
|
1121
|
-
onClick:
|
|
1122
|
-
onKeyDown:
|
|
1044
|
+
onMouseUp: handleMouseUp,
|
|
1045
|
+
onClick: handleOnClickNew,
|
|
1046
|
+
onKeyDown: handleKeyDownNew
|
|
1123
1047
|
// eslint-disable-next-line @atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop
|
|
1124
1048
|
,
|
|
1125
1049
|
onDrop: handleOnDrop,
|
|
@@ -1129,13 +1053,11 @@ export const DragHandle = ({
|
|
|
1129
1053
|
"data-testid": "block-ctrl-drag-handle",
|
|
1130
1054
|
"aria-label": dragHandleAriaLabel,
|
|
1131
1055
|
onBlur: () => {
|
|
1132
|
-
|
|
1133
|
-
setIsFocused(false);
|
|
1134
|
-
}
|
|
1056
|
+
setIsFocused(false);
|
|
1135
1057
|
const pos = getPos();
|
|
1136
1058
|
if (pos !== undefined) {
|
|
1137
|
-
var _api$
|
|
1138
|
-
api === null || api === void 0 ? void 0 : (_api$
|
|
1059
|
+
var _api$core5;
|
|
1060
|
+
api === null || api === void 0 ? void 0 : (_api$core5 = api.core) === null || _api$core5 === void 0 ? void 0 : _api$core5.actions.execute(({
|
|
1139
1061
|
tr
|
|
1140
1062
|
}) => {
|
|
1141
1063
|
tr.setMeta(key, {
|
|
@@ -10,8 +10,8 @@ import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
|
10
10
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
11
11
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
12
12
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
13
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
14
13
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
14
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
15
15
|
import { handleKeyDownWithPreservedSelection } from './editor-commands/handle-key-down-with-preserved-selection';
|
|
16
16
|
import { mapPreservedSelection as _mapPreservedSelection } from './editor-commands/map-preserved-selection';
|
|
17
17
|
import { moveNode } from './editor-commands/move-node';
|
|
@@ -146,15 +146,17 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
|
146
146
|
}
|
|
147
147
|
});
|
|
148
148
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
});
|
|
154
|
-
}
|
|
149
|
+
pmPlugins.push({
|
|
150
|
+
name: 'blockControlsSelectionPreservationPlugin',
|
|
151
|
+
plugin: createSelectionPreservationPlugin(api)
|
|
152
|
+
});
|
|
155
153
|
|
|
156
154
|
// platform_editor_controls note: quick insert rendering fixes
|
|
157
|
-
|
|
155
|
+
//
|
|
156
|
+
// Not registered under the registry migration: the decoration puts an inline
|
|
157
|
+
// `margin-top: 0` on the first document node, which fights features that render their own
|
|
158
|
+
// content above it — a leading show-diff widget is left flush against the node below.
|
|
159
|
+
if (areToolbarFlagsEnabled(Boolean(api === null || api === void 0 ? void 0 : api.toolbar)) && legacyBlockControlsEnabled) {
|
|
158
160
|
pmPlugins.push({
|
|
159
161
|
name: 'firstNodeDec',
|
|
160
162
|
plugin: firstNodeDecPlugin
|
|
@@ -205,9 +207,6 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
|
205
207
|
return function (_ref6) {
|
|
206
208
|
var _api$userIntent, _api$blockControls2, _options$anchorName, _api$blockControls3;
|
|
207
209
|
var tr = _ref6.tr;
|
|
208
|
-
if (!editorExperiment('platform_editor_block_menu', true)) {
|
|
209
|
-
return tr;
|
|
210
|
-
}
|
|
211
210
|
var currMeta = tr.getMeta(key);
|
|
212
211
|
var currentUserIntent = 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;
|
|
213
212
|
var isMenuCurrentlyOpen = api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || (_api$blockControls2 = _api$blockControls2.sharedState.currentState()) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.isMenuOpen;
|
|
@@ -418,7 +417,7 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
|
418
417
|
}
|
|
419
418
|
},
|
|
420
419
|
getSharedState: function getSharedState(editorState) {
|
|
421
|
-
var _key$getState$isMenuO, _key$getState, _key$getState$menuTri, _key$getState2, _key$getState$menuTri2, _key$getState3, _key$getState$blockMe, _key$getState4, _key$getState$activeN, _key$getState5, _key$getState$activeD, _key$getState6, _key$getState$isDragg, _key$getState7, _key$getState$isPMDra, _key$getState8, _key$getState$multiSe, _key$getState9, _key$getState$isShift, _key$getState0, _key$getState$lastDra, _key$getState1, _interactionTrackingP, _key$getState$isSelec, _key$getState10;
|
|
420
|
+
var _key$getState$isMenuO, _key$getState, _key$getState$menuTri, _key$getState2, _key$getState$menuTri2, _key$getState3, _key$getState$blockMe, _key$getState4, _key$getState$activeN, _key$getState5, _key$getState$activeD, _key$getState6, _key$getState$isDragg, _key$getState7, _key$getState$isPMDra, _key$getState8, _key$getState$multiSe, _key$getState9, _key$getState$isShift, _key$getState0, _key$getState$lastDra, _key$getState1, _interactionTrackingP, _key$getState$isSelec, _key$getState10, _selectionPreservatio;
|
|
422
421
|
if (!editorState) {
|
|
423
422
|
return undefined;
|
|
424
423
|
}
|
|
@@ -448,10 +447,7 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
|
448
447
|
sharedState.rightSideControlsEnabled = rightSideControlsEnabled;
|
|
449
448
|
sharedState.hoverSide = rightSideControlsEnabled ? (_interactionTrackingP4 = interactionTrackingPluginKey.getState(editorState)) === null || _interactionTrackingP4 === void 0 ? void 0 : _interactionTrackingP4.hoverSide : undefined;
|
|
450
449
|
}
|
|
451
|
-
|
|
452
|
-
var _selectionPreservatio;
|
|
453
|
-
sharedState.preservedSelection = (_selectionPreservatio = selectionPreservationPluginKey.getState(editorState)) === null || _selectionPreservatio === void 0 ? void 0 : _selectionPreservatio.preservedSelection;
|
|
454
|
-
}
|
|
450
|
+
sharedState.preservedSelection = (_selectionPreservatio = selectionPreservationPluginKey.getState(editorState)) === null || _selectionPreservatio === void 0 ? void 0 : _selectionPreservatio.preservedSelection;
|
|
455
451
|
return sharedState;
|
|
456
452
|
},
|
|
457
453
|
contentComponent: function contentComponent(_ref0) {
|
|
@@ -3,7 +3,6 @@ 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 { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
7
6
|
import { key } from '../pm-plugins/main';
|
|
8
7
|
import { mapPreservedSelection } from '../pm-plugins/utils/selection';
|
|
9
8
|
import { moveNode } from './move-node';
|
|
@@ -23,9 +22,6 @@ export var moveNodeWithBlockMenu = function moveNodeWithBlockMenu(api, direction
|
|
|
23
22
|
return function (_ref) {
|
|
24
23
|
var _api$blockControls$sh;
|
|
25
24
|
var tr = _ref.tr;
|
|
26
|
-
if (!editorExperiment('platform_editor_block_menu', true)) {
|
|
27
|
-
return tr;
|
|
28
|
-
}
|
|
29
25
|
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;
|
|
30
26
|
var selection = preservedSelection !== null && preservedSelection !== void 0 ? preservedSelection : tr.selection;
|
|
31
27
|
|
|
@@ -374,7 +374,7 @@ export var moveNode = function moveNode(api) {
|
|
|
374
374
|
tr: tr
|
|
375
375
|
});
|
|
376
376
|
}
|
|
377
|
-
var preservedSelection =
|
|
377
|
+
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;
|
|
378
378
|
if (preservedSelection) {
|
|
379
379
|
var $from = tr.doc.resolve(Math.min(start, preservedSelection.from));
|
|
380
380
|
var expandedRange = $from.blockRange(preservedSelection.$to);
|
|
@@ -478,7 +478,7 @@ export var moveNode = function moveNode(api) {
|
|
|
478
478
|
}));
|
|
479
479
|
if (
|
|
480
480
|
// 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
|
|
481
|
-
|
|
481
|
+
inputMethod !== INPUT_METHOD.BLOCK_MENU) {
|
|
482
482
|
api === null || api === void 0 || api.core.actions.focus();
|
|
483
483
|
}
|
|
484
484
|
var $mappedTo = tr.doc.resolve(mappedTo);
|