@atlaskit/editor-plugin-block-controls 23.0.2 → 23.0.4
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 +24 -0
- package/dist/cjs/blockControlsPlugin.js +4 -6
- package/dist/cjs/pm-plugins/handle-mouse-over.js +0 -5
- package/dist/cjs/pm-plugins/handle-sparse-mouse-over.js +0 -4
- package/dist/cjs/pm-plugins/main.js +2 -20
- package/dist/cjs/pm-plugins/utils/selection.js +1 -30
- package/dist/cjs/ui/block-controls-surface-drag-handle-utils.js +3 -11
- package/dist/cjs/ui/block-controls-surface-drag-handle.js +6 -23
- package/dist/cjs/ui/consts.js +1 -9
- package/dist/cjs/ui/drag-handle.js +22 -67
- package/dist/cjs/ui/should-use-nested-drag-handle-icon.js +2 -6
- package/dist/es2019/blockControlsPlugin.js +4 -6
- package/dist/es2019/pm-plugins/handle-mouse-over.js +0 -5
- package/dist/es2019/pm-plugins/handle-sparse-mouse-over.js +0 -4
- package/dist/es2019/pm-plugins/main.js +2 -22
- package/dist/es2019/pm-plugins/utils/selection.js +1 -30
- package/dist/es2019/ui/block-controls-surface-drag-handle-utils.js +0 -4
- package/dist/es2019/ui/block-controls-surface-drag-handle.js +6 -23
- package/dist/es2019/ui/consts.js +0 -8
- package/dist/es2019/ui/drag-handle.js +9 -49
- package/dist/es2019/ui/should-use-nested-drag-handle-icon.js +2 -7
- package/dist/esm/blockControlsPlugin.js +4 -6
- package/dist/esm/pm-plugins/handle-mouse-over.js +0 -5
- package/dist/esm/pm-plugins/handle-sparse-mouse-over.js +0 -4
- package/dist/esm/pm-plugins/main.js +2 -20
- package/dist/esm/pm-plugins/utils/selection.js +1 -30
- package/dist/esm/ui/block-controls-surface-drag-handle-utils.js +3 -10
- package/dist/esm/ui/block-controls-surface-drag-handle.js +6 -23
- package/dist/esm/ui/consts.js +0 -8
- package/dist/esm/ui/drag-handle.js +23 -68
- package/dist/esm/ui/should-use-nested-drag-handle-icon.js +2 -7
- package/dist/types/blockControlsPluginType.d.ts +0 -2
- package/dist/types/pm-plugins/main.d.ts +0 -2
- package/dist/types/pm-plugins/utils/selection.d.ts +2 -14
- package/dist/types/ui/block-controls-surface-drag-handle-utils.d.ts +0 -1
- package/dist/types/ui/consts.d.ts +0 -7
- package/package.json +4 -11
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
2
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
3
2
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
4
3
|
import { getNodeTypeWithLevel } from './decorations-common';
|
|
5
4
|
const OPAQUE_BLOCKS = new Set(['table', 'bulletList', 'orderedList', 'taskList', 'decisionList', 'mediaSingle']);
|
|
@@ -100,9 +99,6 @@ export const handleSparseMouseOver = (view, event, api) => {
|
|
|
100
99
|
if (isPanelNodeTypeName(parentNode.type.name) && !(parentDOM instanceof HTMLElement && parentDOM.classList.contains('ak-editor-panel__no-icon')) && $target.index() === 0) {
|
|
101
100
|
return false;
|
|
102
101
|
}
|
|
103
|
-
if (node.type.name === 'layoutColumn' && parentNode.type.name === 'layoutSection' && parentNode.childCount === 1 && expValEqualsNoExposure('advanced_layouts', 'isEnabled', true) && !expValEquals('platform_editor_layout_column_menu', 'isEnabled', true)) {
|
|
104
|
-
return false;
|
|
105
|
-
}
|
|
106
102
|
const anchors = controls === null || controls === void 0 ? void 0 : controls.surfaceAnchors;
|
|
107
103
|
const anchorName = (_anchors$get = anchors === null || anchors === void 0 ? void 0 : anchors.get(targetPosition)) !== null && _anchors$get !== void 0 ? _anchors$get : api.core.actions.getAnchorIdForNode(node, targetPosition);
|
|
108
104
|
const rootPos = $target.depth > 0 ? $target.before(1) : targetPosition;
|
|
@@ -233,7 +233,7 @@ const getDecorationAtPos = (state, decorations, pos, to) => {
|
|
|
233
233
|
return nodeDecAtActivePos;
|
|
234
234
|
};
|
|
235
235
|
export const apply = (api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled = false, quickInsertButtonEnabled = true, anchorRectCache, resizeObserverWidth, pragmaticCleanup, limitedModeTeardown) => {
|
|
236
|
-
var _meta$multiSelectDnD, _api$editorViewMode, _api$editorViewMode$s, _activeNode, _activeNode2, _meta$activeNode$hand, _activeNode3, _activeNode4, _meta$isDragging2, _meta$toggleMenu, _meta$isDragging3, _meta$toggleMenu2, _meta$toggleMenu3, _meta$toggleMenu4, _meta$toggleMenu5, _meta$toggleMenu6, _meta$toggleMenu7, _meta$toggleMenu8, _meta$editorHeight, _meta$editorWidthLeft, _meta$editorWidthRigh, _meta$isPMDragging, _meta$
|
|
236
|
+
var _meta$multiSelectDnD, _api$editorViewMode, _api$editorViewMode$s, _activeNode, _activeNode2, _meta$activeNode$hand, _activeNode3, _activeNode4, _meta$isDragging2, _meta$toggleMenu, _meta$isDragging3, _meta$toggleMenu2, _meta$toggleMenu3, _meta$toggleMenu4, _meta$toggleMenu5, _meta$toggleMenu6, _meta$toggleMenu7, _meta$toggleMenu8, _meta$editorHeight, _meta$editorWidthLeft, _meta$editorWidthRigh, _meta$isPMDragging, _meta$lastDragCancell;
|
|
237
237
|
let {
|
|
238
238
|
activeNode,
|
|
239
239
|
decorations,
|
|
@@ -253,7 +253,6 @@ export const apply = (api, formatMessage, tr, currentState, newState, flags, nod
|
|
|
253
253
|
menuTriggerByNode,
|
|
254
254
|
blockMenuOptions,
|
|
255
255
|
isPMDragging,
|
|
256
|
-
isShiftDown,
|
|
257
256
|
lastDragCancelled,
|
|
258
257
|
isSelectedViaDragHandle
|
|
259
258
|
} = currentState;
|
|
@@ -877,7 +876,6 @@ export const apply = (api, formatMessage, tr, currentState, newState, flags, nod
|
|
|
877
876
|
isDocSizeLimitEnabled: initialState.isDocSizeLimitEnabled,
|
|
878
877
|
isPMDragging: (_meta$isPMDragging = meta === null || meta === void 0 ? void 0 : meta.isPMDragging) !== null && _meta$isPMDragging !== void 0 ? _meta$isPMDragging : isPMDragging,
|
|
879
878
|
multiSelectDnD,
|
|
880
|
-
isShiftDown: (_meta$isShiftDown = meta === null || meta === void 0 ? void 0 : meta.isShiftDown) !== null && _meta$isShiftDown !== void 0 ? _meta$isShiftDown : isShiftDown,
|
|
881
879
|
lastDragCancelled: (_meta$lastDragCancell = meta === null || meta === void 0 ? void 0 : meta.lastDragCancelled) !== null && _meta$lastDragCancell !== void 0 ? _meta$lastDragCancell : lastDragCancelled,
|
|
882
880
|
isSelectedViaDragHandle: isSelectedViaDragHandleNew
|
|
883
881
|
};
|
|
@@ -1124,31 +1122,13 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI, nodeDecora
|
|
|
1124
1122
|
api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(false));
|
|
1125
1123
|
}
|
|
1126
1124
|
}
|
|
1127
|
-
if (!event.repeat && event.shiftKey && fg('platform_editor_elements_dnd_shift_click_select')) {
|
|
1128
|
-
view.dispatch(view.state.tr.setMeta(key, {
|
|
1129
|
-
...view.state.tr.getMeta(key),
|
|
1130
|
-
isShiftDown: true
|
|
1131
|
-
}));
|
|
1132
|
-
}
|
|
1133
1125
|
return false;
|
|
1134
1126
|
},
|
|
1135
|
-
|
|
1127
|
+
blur(view, event) {
|
|
1136
1128
|
var _api$limitedMode0, _api$limitedMode0$sha;
|
|
1137
1129
|
if (api !== null && api !== void 0 && (_api$limitedMode0 = api.limitedMode) !== null && _api$limitedMode0 !== void 0 && (_api$limitedMode0$sha = _api$limitedMode0.sharedState.currentState()) !== null && _api$limitedMode0$sha !== void 0 && _api$limitedMode0$sha.enabled) {
|
|
1138
1130
|
return;
|
|
1139
1131
|
}
|
|
1140
|
-
if (!event.repeat && event.key === 'Shift') {
|
|
1141
|
-
view.dispatch(view.state.tr.setMeta(key, {
|
|
1142
|
-
...view.state.tr.getMeta(key),
|
|
1143
|
-
isShiftDown: false
|
|
1144
|
-
}));
|
|
1145
|
-
}
|
|
1146
|
-
},
|
|
1147
|
-
blur(view, event) {
|
|
1148
|
-
var _api$limitedMode1, _api$limitedMode1$sha;
|
|
1149
|
-
if (api !== null && api !== void 0 && (_api$limitedMode1 = api.limitedMode) !== null && _api$limitedMode1 !== void 0 && (_api$limitedMode1$sha = _api$limitedMode1.sharedState.currentState()) !== null && _api$limitedMode1$sha !== void 0 && _api$limitedMode1$sha.enabled) {
|
|
1150
|
-
return;
|
|
1151
|
-
}
|
|
1152
1132
|
if (editorExperiment('platform_editor_controls', 'variant1')) {
|
|
1153
1133
|
var _api$core2;
|
|
1154
1134
|
// Focus moving into the registry surface remains inside the editor experience.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { INSERTED_TRAILING_PARAGRAPH_TO_LAST_NODE_META } from '@atlaskit/editor-common/block-type';
|
|
2
2
|
import { expandToBlockRange, isMultiBlockRange } from '@atlaskit/editor-common/selection';
|
|
3
|
-
import {
|
|
3
|
+
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
import { getTableSelectionClosesToPos } from '@atlaskit/editor-tables/utils';
|
|
5
5
|
import { getBlockControlsMeta, key } from '../main';
|
|
6
6
|
import { newGetSelection } from './getSelection';
|
|
@@ -49,35 +49,6 @@ export const getSelectedSlicePosition = (handlePos, tr, api) => {
|
|
|
49
49
|
};
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
-
/**
|
|
53
|
-
* Takes a position and expands the selection to encompass the node at that position. Ignores empty or out of range selections.
|
|
54
|
-
* Ignores positions that are in text blocks (i.e. not start of a node)
|
|
55
|
-
* @returns TextSelection if expanded, otherwise returns Selection that was passed in.
|
|
56
|
-
*/
|
|
57
|
-
export const expandSelectionHeadToNodeAtPos = (selection, nodePos) => {
|
|
58
|
-
const doc = selection.$anchor.doc;
|
|
59
|
-
if (nodePos < 0 || nodePos > doc.nodeSize - 2 || selection.empty) {
|
|
60
|
-
return selection;
|
|
61
|
-
}
|
|
62
|
-
const $pos = doc.resolve(nodePos);
|
|
63
|
-
const node = $pos.nodeAfter;
|
|
64
|
-
if ($pos.node().isTextblock || !node) {
|
|
65
|
-
return selection;
|
|
66
|
-
}
|
|
67
|
-
const $newHead = nodePos < selection.anchor ? $pos : doc.resolve(node.nodeSize + nodePos);
|
|
68
|
-
const textSelection = new TextSelection(selection.$anchor, $newHead);
|
|
69
|
-
return textSelection;
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* This swaps the anchor/head for NodeSelections when its anchor > pos.
|
|
74
|
-
* This is because NodeSelection always has an anchor at the start of the node,
|
|
75
|
-
* which may not align with the existing selection.
|
|
76
|
-
*/
|
|
77
|
-
export const alignAnchorHeadInDirectionOfPos = (selection, pos) => {
|
|
78
|
-
return selection instanceof NodeSelection && Math.max(pos, selection.anchor) === selection.anchor ? new TextSelection(selection.$head, selection.$anchor) : selection;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
52
|
/**
|
|
82
53
|
* This maps a preserved selection through a transaction, expanding text selections to block boundaries.
|
|
83
54
|
*
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
2
1
|
import { nodeMargins, spacingBetweenNodesForPreview } from './consts';
|
|
3
2
|
export const buildLayoutColumnMenuMeta = (anchorPos, openedViaKeyboard) => ({
|
|
4
3
|
anchorPos,
|
|
5
|
-
...(fg('platform_editor_layout_column_menu_kill_switch_1') ? {
|
|
6
|
-
isOpen: true
|
|
7
|
-
} : {}),
|
|
8
4
|
openedViaKeyboard
|
|
9
5
|
});
|
|
10
6
|
export const getNodeSpacingForDragPreview = node => {
|
|
@@ -17,14 +17,12 @@ import { blockControlsMessages } from '@atlaskit/editor-common/messages';
|
|
|
17
17
|
import DragHandleVerticalIcon from '@atlaskit/icon/core/drag-handle-vertical';
|
|
18
18
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
19
19
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
20
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
21
20
|
import Tooltip from '@atlaskit/tooltip/Tooltip';
|
|
22
21
|
import { selectionPreservationPluginKey } from '../pm-plugins/selection-preservation/plugin-key';
|
|
23
22
|
import { prepareCollapsedHeadingSelection } from '../pm-plugins/utils/collapsed-heading';
|
|
24
23
|
import { expandAndUpdateSelection } from '../pm-plugins/utils/expand-and-update-selection';
|
|
25
24
|
import { isHandleCorrelatedToSelection } from '../pm-plugins/utils/getSelection';
|
|
26
25
|
import { buildLayoutColumnMenuMeta } from './block-controls-surface-drag-handle-utils';
|
|
27
|
-
import { DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH } from './consts';
|
|
28
26
|
import { DragHandleNestedIcon } from './drag-handle-nested-icon';
|
|
29
27
|
import { shouldUseNestedDragHandleIcon } from './should-use-nested-drag-handle-icon';
|
|
30
28
|
import { useSurfaceEditorView } from './surface-editor-view-context';
|
|
@@ -84,15 +82,13 @@ export const BlockControlsSurfaceDragHandle = ({
|
|
|
84
82
|
activeNodeAnchorName,
|
|
85
83
|
handleOptions,
|
|
86
84
|
interactionState,
|
|
87
|
-
isShiftDown,
|
|
88
85
|
selection
|
|
89
86
|
} = useSharedPluginStateWithSelector(api, ['blockControls', 'interaction', 'selection'], states => {
|
|
90
|
-
var _states$blockControls, _states$blockControls2, _states$blockControls3, _states$blockControls4, _states$interactionSt, _states$
|
|
87
|
+
var _states$blockControls, _states$blockControls2, _states$blockControls3, _states$blockControls4, _states$interactionSt, _states$selectionStat;
|
|
91
88
|
return {
|
|
92
89
|
activeNodeAnchorName: (_states$blockControls = states.blockControlsState) === null || _states$blockControls === void 0 ? void 0 : (_states$blockControls2 = _states$blockControls.activeNode) === null || _states$blockControls2 === void 0 ? void 0 : _states$blockControls2.anchorName,
|
|
93
90
|
handleOptions: (_states$blockControls3 = states.blockControlsState) === null || _states$blockControls3 === void 0 ? void 0 : (_states$blockControls4 = _states$blockControls3.activeNode) === null || _states$blockControls4 === void 0 ? void 0 : _states$blockControls4.handleOptions,
|
|
94
91
|
interactionState: (_states$interactionSt = states.interactionState) === null || _states$interactionSt === void 0 ? void 0 : _states$interactionSt.interactionState,
|
|
95
|
-
isShiftDown: (_states$blockControls5 = states.blockControlsState) === null || _states$blockControls5 === void 0 ? void 0 : _states$blockControls5.isShiftDown,
|
|
96
92
|
selection: (_states$selectionStat = states.selectionState) === null || _states$selectionStat === void 0 ? void 0 : _states$selectionStat.selection
|
|
97
93
|
};
|
|
98
94
|
});
|
|
@@ -102,21 +98,9 @@ export const BlockControlsSurfaceDragHandle = ({
|
|
|
102
98
|
}, [pos, selection, view]);
|
|
103
99
|
const isLayoutColumn = nodeType === 'layoutColumn';
|
|
104
100
|
const isTopLevelNode = (activeNode === null || activeNode === void 0 ? void 0 : activeNode.parentType) === 'doc';
|
|
105
|
-
const isDisabled = useMemo(() => {
|
|
106
|
-
var _api$blockControls$sh;
|
|
107
|
-
if (!isShiftDown || !view || view.state.selection.empty || !fg('platform_editor_elements_dnd_shift_click_select')) {
|
|
108
|
-
return false;
|
|
109
|
-
}
|
|
110
|
-
if (isLayoutColumn && expValEquals('platform_editor_layout_column_menu', 'isEnabled', true)) {
|
|
111
|
-
return false;
|
|
112
|
-
}
|
|
113
|
-
const multiSelect = 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;
|
|
114
|
-
const $anchor = (multiSelect === null || multiSelect === void 0 ? void 0 : multiSelect.anchor) !== undefined ? view.state.doc.resolve(multiSelect.anchor) : view.state.selection.$anchor;
|
|
115
|
-
return !isTopLevelNode || $anchor.depth > DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH;
|
|
116
|
-
}, [api, isLayoutColumn, isShiftDown, isTopLevelNode, view]);
|
|
117
101
|
const getAnchorName = useCallback(() => {
|
|
118
|
-
var _api$blockControls$
|
|
119
|
-
const surfaceAnchor = posRef.current === undefined ? undefined : api === null || api === void 0 ? void 0 : (_api$blockControls$
|
|
102
|
+
var _api$blockControls$sh, _api$blockControls$sh2, _ref, _ref2, _dom$getAttribute, _dom$closest;
|
|
103
|
+
const surfaceAnchor = posRef.current === undefined ? undefined : api === null || api === void 0 ? void 0 : (_api$blockControls$sh = api.blockControls.sharedState.currentState()) === null || _api$blockControls$sh === void 0 ? void 0 : (_api$blockControls$sh2 = _api$blockControls$sh.surfaceAnchors) === null || _api$blockControls$sh2 === void 0 ? void 0 : _api$blockControls$sh2.get(posRef.current);
|
|
120
104
|
if (surfaceAnchor) {
|
|
121
105
|
return surfaceAnchor;
|
|
122
106
|
}
|
|
@@ -182,7 +166,7 @@ export const BlockControlsSurfaceDragHandle = ({
|
|
|
182
166
|
}, [api]);
|
|
183
167
|
const handleClick = useCallback(event => {
|
|
184
168
|
var _api$core2;
|
|
185
|
-
if (!view
|
|
169
|
+
if (!view) {
|
|
186
170
|
return;
|
|
187
171
|
}
|
|
188
172
|
const openedViaKeyboard = event.detail === 0;
|
|
@@ -194,7 +178,7 @@ export const BlockControlsSurfaceDragHandle = ({
|
|
|
194
178
|
if (startPos === undefined) {
|
|
195
179
|
return tr;
|
|
196
180
|
}
|
|
197
|
-
if (nodeType === 'layoutColumn'
|
|
181
|
+
if (nodeType === 'layoutColumn') {
|
|
198
182
|
tr.setMeta('toggleLayoutColumnMenu', buildLayoutColumnMenuMeta(startPos, openedViaKeyboard));
|
|
199
183
|
}
|
|
200
184
|
const selection = (_selectionPreservatio = (_selectionPreservatio2 = selectionPreservationPluginKey.getState(view.state)) === null || _selectionPreservatio2 === void 0 ? void 0 : _selectionPreservatio2.preservedSelection) !== null && _selectionPreservatio !== void 0 ? _selectionPreservatio : tr.selection;
|
|
@@ -243,7 +227,7 @@ export const BlockControlsSurfaceDragHandle = ({
|
|
|
243
227
|
return tr;
|
|
244
228
|
});
|
|
245
229
|
view.focus();
|
|
246
|
-
}, [activeNode === null || activeNode === void 0 ? void 0 : activeNode.rootPos, api, getAnchorName, getPos,
|
|
230
|
+
}, [activeNode === null || activeNode === void 0 ? void 0 : activeNode.rootPos, api, getAnchorName, getPos, nodeType, view]);
|
|
247
231
|
const label = formatMessage(blockControlsMessages.dragToMoveClickToOpen, {
|
|
248
232
|
br: ' '
|
|
249
233
|
});
|
|
@@ -269,7 +253,6 @@ export const BlockControlsSurfaceDragHandle = ({
|
|
|
269
253
|
ref: buttonRef,
|
|
270
254
|
type: "button",
|
|
271
255
|
"aria-label": label,
|
|
272
|
-
disabled: isDisabled,
|
|
273
256
|
onClick: handleClick,
|
|
274
257
|
onMouseDown: handleMouseDown
|
|
275
258
|
// eslint-disable-next-line @atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop -- Pragmatic DnD owns this native drag source.
|
package/dist/es2019/ui/consts.js
CHANGED
|
@@ -35,14 +35,6 @@ export const DRAG_HANDLE_LAYOUT_SECTION_TOP_ADJUSTMENT = 8;
|
|
|
35
35
|
export const DRAG_HANDLE_PARAGRAPH_TOP_ADJUSTMENT = 2;
|
|
36
36
|
export const DRAG_HANDLE_PARAGRAPH_SMALL_TOP_ADJUSTMENT = 0;
|
|
37
37
|
export const DRAG_HANDLE_WRAPPED_MEDIA_EMBED_TOP_ADJUSTMENT = 8;
|
|
38
|
-
|
|
39
|
-
/** We only want to shift-select nodes that are at the top level of a document.
|
|
40
|
-
* This is because funky things happen when selecting inside of tableCells, but we
|
|
41
|
-
* also want to avoid heavily nested cases to descope potential corner cases.
|
|
42
|
-
* Various top level nodes have their selection 'from' at depths other than 0,
|
|
43
|
-
* so we allow for some leniency to capture them all. e.g. Table is depth 3.
|
|
44
|
-
*/
|
|
45
|
-
export const DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH = 3;
|
|
46
38
|
export const STICKY_CONTROLS_TOP_MARGIN = 8;
|
|
47
39
|
export const STICKY_CONTROLS_TOP_MARGIN_FOR_STICKY_HEADER = 24;
|
|
48
40
|
export const QUICK_INSERT_HEIGHT = 24;
|
|
@@ -34,7 +34,7 @@ import { getMultiSelectAnalyticsAttributes } from '../pm-plugins/utils/analytics
|
|
|
34
34
|
import { getControlBottomCSSValue, getControlHeightCSSValue, getLeftPosition, getNodeHeight, getTopPosition, shouldBeSticky, shouldMaskNodeControls } from '../pm-plugins/utils/drag-handle-positions';
|
|
35
35
|
import { expandAndUpdateSelection } from '../pm-plugins/utils/expand-and-update-selection';
|
|
36
36
|
import { isHandleCorrelatedToSelection, selectNode } from '../pm-plugins/utils/getSelection';
|
|
37
|
-
import { ACTIVE_DRAG_HANDLE_ATTR, ACTIVE_DRAG_HANDLE_FALLBACK_ANCHOR_NAME, DRAG_HANDLE_BORDER_RADIUS, DRAG_HANDLE_HEIGHT,
|
|
37
|
+
import { ACTIVE_DRAG_HANDLE_ATTR, ACTIVE_DRAG_HANDLE_FALLBACK_ANCHOR_NAME, DRAG_HANDLE_BORDER_RADIUS, DRAG_HANDLE_HEIGHT, DRAG_HANDLE_ZINDEX, dragHandleGap, nodeMargins, spacingBetweenNodesForPreview, STICKY_CONTROLS_TOP_MARGIN, STICKY_CONTROLS_TOP_MARGIN_FOR_STICKY_HEADER, topPositionAdjustment } from './consts';
|
|
38
38
|
import { DragHandleNestedIcon } from './drag-handle-nested-icon';
|
|
39
39
|
import { dragPreview } from './drag-preview';
|
|
40
40
|
import { shouldUseNestedDragHandleIcon } from './should-use-nested-drag-handle-icon';
|
|
@@ -327,13 +327,9 @@ const getNodeMargins = node => {
|
|
|
327
327
|
return nodeMargins[nodeTypeName] || nodeMargins['default'];
|
|
328
328
|
};
|
|
329
329
|
|
|
330
|
-
//
|
|
331
|
-
// `isOpen: true` for legacy always-open. Centralised so all dispatch sites stay in sync.
|
|
330
|
+
// Omit `isOpen` so the reducer toggles the menu for a re-clicked layout column.
|
|
332
331
|
const buildToggleLayoutColumnMenuMeta = (anchorPos, openedViaKeyboard) => ({
|
|
333
332
|
anchorPos,
|
|
334
|
-
...(fg('platform_editor_layout_column_menu_kill_switch_1') ? {
|
|
335
|
-
isOpen: true
|
|
336
|
-
} : {}),
|
|
337
333
|
openedViaKeyboard
|
|
338
334
|
});
|
|
339
335
|
const getDragHandleAnchorReference = ({
|
|
@@ -355,11 +351,9 @@ export const DragHandle = ({
|
|
|
355
351
|
handleOptions,
|
|
356
352
|
anchorRectCache
|
|
357
353
|
}) => {
|
|
358
|
-
var _api$blockControls7;
|
|
359
354
|
const buttonRef = useRef(null);
|
|
360
355
|
const mouseDownRef = useRef(false);
|
|
361
356
|
const [dragHandleSelected, setDragHandleSelected] = useState(false);
|
|
362
|
-
const [dragHandleDisabled, setDragHandleDisabled] = useState(false);
|
|
363
357
|
const [blockCardWidth, setBlockCardWidth] = useState(768);
|
|
364
358
|
const [positionStylesOld, setPositionStylesOld] = useState({
|
|
365
359
|
display: 'none'
|
|
@@ -372,15 +366,13 @@ export const DragHandle = ({
|
|
|
372
366
|
const {
|
|
373
367
|
macroInteractionUpdates,
|
|
374
368
|
selection,
|
|
375
|
-
isShiftDown,
|
|
376
369
|
interactionState,
|
|
377
370
|
currentUserIntent
|
|
378
371
|
} = useSharedPluginStateWithSelector(api, ['featureFlags', 'selection', 'blockControls', 'interaction', 'userIntent'], states => {
|
|
379
|
-
var _states$featureFlagsS, _states$selectionStat, _states$
|
|
372
|
+
var _states$featureFlagsS, _states$selectionStat, _states$interactionSt, _states$userIntentSta;
|
|
380
373
|
return {
|
|
381
374
|
macroInteractionUpdates: (_states$featureFlagsS = states.featureFlagsState) === null || _states$featureFlagsS === void 0 ? void 0 : _states$featureFlagsS.macroInteractionUpdates,
|
|
382
375
|
selection: (_states$selectionStat = states.selectionState) === null || _states$selectionStat === void 0 ? void 0 : _states$selectionStat.selection,
|
|
383
|
-
isShiftDown: (_states$blockControls = states.blockControlsState) === null || _states$blockControls === void 0 ? void 0 : _states$blockControls.isShiftDown,
|
|
384
376
|
interactionState: (_states$interactionSt = states.interactionState) === null || _states$interactionSt === void 0 ? void 0 : _states$interactionSt.interactionState,
|
|
385
377
|
currentUserIntent: (_states$userIntentSta = states.userIntentState) === null || _states$userIntentSta === void 0 ? void 0 : _states$userIntentSta.currentUserIntent
|
|
386
378
|
};
|
|
@@ -448,7 +440,7 @@ export const DragHandle = ({
|
|
|
448
440
|
if (startPos === undefined) {
|
|
449
441
|
return tr;
|
|
450
442
|
}
|
|
451
|
-
if (nodeType === 'layoutColumn'
|
|
443
|
+
if (nodeType === 'layoutColumn') {
|
|
452
444
|
tr.setMeta('toggleLayoutColumnMenu', buildToggleLayoutColumnMenuMeta(startPos, false));
|
|
453
445
|
}
|
|
454
446
|
const resolvedStartPos = tr.doc.resolve(startPos);
|
|
@@ -519,7 +511,7 @@ export const DragHandle = ({
|
|
|
519
511
|
api === null || api === void 0 ? void 0 : (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 ? void 0 : _api$blockControls3.commands.startPreservingSelection()({
|
|
520
512
|
tr
|
|
521
513
|
});
|
|
522
|
-
if (nodeType === 'layoutColumn'
|
|
514
|
+
if (nodeType === 'layoutColumn') {
|
|
523
515
|
tr.setMeta('toggleLayoutColumnMenu', buildToggleLayoutColumnMenuMeta(startPos, true));
|
|
524
516
|
}
|
|
525
517
|
const triggerByNode = {
|
|
@@ -935,20 +927,6 @@ export const DragHandle = ({
|
|
|
935
927
|
}
|
|
936
928
|
setDragHandleSelected(isHandleCorrelatedToSelection(view.state, selection, start));
|
|
937
929
|
}, [start, selection, view]);
|
|
938
|
-
useEffect(() => {
|
|
939
|
-
var _api$blockControls$sh3;
|
|
940
|
-
if (isShiftDown === undefined || view.state.selection.empty || !fg('platform_editor_elements_dnd_shift_click_select')) {
|
|
941
|
-
return;
|
|
942
|
-
}
|
|
943
|
-
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;
|
|
944
|
-
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;
|
|
945
|
-
const isLayoutColumnMenuEnabled = expValEquals('platform_editor_layout_column_menu', 'isEnabled', true);
|
|
946
|
-
if (isShiftDown && !(isLayoutColumnMenuEnabled && isLayoutColumn) && (!isTopLevelNodeValue || isTopLevelNodeValue && $anchor.depth > DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH)) {
|
|
947
|
-
setDragHandleDisabled(true);
|
|
948
|
-
} else {
|
|
949
|
-
setDragHandleDisabled(false);
|
|
950
|
-
}
|
|
951
|
-
}, [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]);
|
|
952
930
|
const dragHandleMessage = formatMessage(blockControlsMessages.dragToMoveClickToOpen, {
|
|
953
931
|
br: jsx("br", null)
|
|
954
932
|
});
|
|
@@ -1049,7 +1027,6 @@ export const DragHandle = ({
|
|
|
1049
1027
|
// eslint-disable-next-line @atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop
|
|
1050
1028
|
,
|
|
1051
1029
|
onDrop: handleOnDrop,
|
|
1052
|
-
disabled: dragHandleDisabled,
|
|
1053
1030
|
"data-editor-block-ctrl-drag-handle": true,
|
|
1054
1031
|
"data-blocks-drag-handle": fg('confluence_remix_button_right_side_block_fg') || undefined,
|
|
1055
1032
|
"data-testid": "block-ctrl-drag-handle",
|
|
@@ -1113,20 +1090,6 @@ export const DragHandle = ({
|
|
|
1113
1090
|
}, jsx("span", {
|
|
1114
1091
|
css: [shouldMaskNodeControls(nodeType, isTopLevelNodeValue) && buttonWrapperStylesNoBackground, buttonWrapperStylesPatch]
|
|
1115
1092
|
}, renderButton()))));
|
|
1116
|
-
const stickyWithoutTooltip = () => jsx(Box
|
|
1117
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
1118
|
-
, {
|
|
1119
|
-
style: positionStylesOld
|
|
1120
|
-
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
1121
|
-
,
|
|
1122
|
-
xcss: [dragHandleContainerStyles],
|
|
1123
|
-
as: "span",
|
|
1124
|
-
testId: "block-ctrl-drag-handle-container"
|
|
1125
|
-
}, jsx("span", {
|
|
1126
|
-
css: [tooltipContainerStyles, shouldMaskNodeControls(nodeType, isTopLevelNodeValue) && tooltipContainerStylesStickyHeaderWithMask, !shouldMaskNodeControls(nodeType, isTopLevelNodeValue) && tooltipContainerStylesStickyHeaderWithoutMask]
|
|
1127
|
-
}, jsx("span", {
|
|
1128
|
-
css: [shouldMaskNodeControls(nodeType, isTopLevelNodeValue) && buttonWrapperStylesNoBackground, buttonWrapperStylesPatch]
|
|
1129
|
-
}, renderButton())));
|
|
1130
1093
|
const buttonWithTooltip = () => jsx(Tooltip, {
|
|
1131
1094
|
content: tooltipContent,
|
|
1132
1095
|
ignoreTooltipPointerEvents: true
|
|
@@ -1139,13 +1102,10 @@ export const DragHandle = ({
|
|
|
1139
1102
|
});
|
|
1140
1103
|
}
|
|
1141
1104
|
}, renderButton());
|
|
1142
|
-
const tooltipContent = isLayoutColumn &&
|
|
1105
|
+
const tooltipContent = isLayoutColumn && currentUserIntent === 'layoutColumnMenuPopupOpen' ? null : jsx(TooltipContentWithMultipleShortcuts, {
|
|
1143
1106
|
helpDescriptors: helpDescriptors
|
|
1144
1107
|
});
|
|
1145
|
-
|
|
1146
|
-
const stickyRender = isTooltip ? stickyWithTooltip() : stickyWithoutTooltip();
|
|
1147
|
-
const render = isTooltip ? buttonWithTooltip() : renderButton();
|
|
1148
|
-
return editorExperiment('platform_editor_controls', 'variant1') ? stickyRender : render;
|
|
1108
|
+
return editorExperiment('platform_editor_controls', 'variant1') ? stickyWithTooltip() : buttonWithTooltip();
|
|
1149
1109
|
};
|
|
1150
1110
|
export const DragHandleWithVisibility = ({
|
|
1151
1111
|
view,
|
|
@@ -1159,9 +1119,9 @@ export const DragHandleWithVisibility = ({
|
|
|
1159
1119
|
anchorRectCache
|
|
1160
1120
|
}) => {
|
|
1161
1121
|
const rightSideControlsEnabled = useSharedPluginStateWithSelector(api, ['blockControls'], states => {
|
|
1162
|
-
var _states$
|
|
1122
|
+
var _states$blockControls, _states$blockControls2;
|
|
1163
1123
|
return {
|
|
1164
|
-
rightSideControlsEnabled: (_states$
|
|
1124
|
+
rightSideControlsEnabled: (_states$blockControls = (_states$blockControls2 = states.blockControlsState) === null || _states$blockControls2 === void 0 ? void 0 : _states$blockControls2.rightSideControlsEnabled) !== null && _states$blockControls !== void 0 ? _states$blockControls : false
|
|
1165
1125
|
};
|
|
1166
1126
|
}).rightSideControlsEnabled;
|
|
1167
1127
|
// Layout column drag handles sit at the top-centre of each column, not on a left/right edge.
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
// Nested icon for non-top-level nodes. Exception: with the
|
|
4
|
-
// kill switch OFF, layout columns use the full block handle instead.
|
|
5
|
-
// TODO: EDITOR-7732 - remove this whole function when
|
|
6
|
-
// `platform_editor_layout_column_menu_kill_switch_1` is cleaned up
|
|
1
|
+
// Nested layout columns use the full block handle; other non-top-level nodes use the nested icon.
|
|
7
2
|
export const shouldUseNestedDragHandleIcon = (isTopLevelNode, isLayoutColumn) => {
|
|
8
3
|
if (isTopLevelNode) {
|
|
9
4
|
return false;
|
|
10
5
|
}
|
|
11
|
-
if (isLayoutColumn
|
|
6
|
+
if (isLayoutColumn) {
|
|
12
7
|
return false;
|
|
13
8
|
}
|
|
14
9
|
return true;
|
|
@@ -11,7 +11,6 @@ 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
13
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
14
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
15
14
|
import { handleKeyDownWithPreservedSelection } from './editor-commands/handle-key-down-with-preserved-selection';
|
|
16
15
|
import { mapPreservedSelection as _mapPreservedSelection } from './editor-commands/map-preserved-selection';
|
|
17
16
|
import { moveNode } from './editor-commands/move-node';
|
|
@@ -80,7 +79,7 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
|
80
79
|
// so that adjacent cells are not fused (e.g. 'hello world' + 'foo' must not
|
|
81
80
|
// become 'hello worldfoo'). Intl.Segmenter word-counting requires correct
|
|
82
81
|
// word boundaries, which raw textContent fusion breaks.
|
|
83
|
-
if (preservedSelection instanceof CellSelection
|
|
82
|
+
if (preservedSelection instanceof CellSelection) {
|
|
84
83
|
// Use node(1) to reliably target the table node regardless of $anchorCell depth.
|
|
85
84
|
// node(-1) would return tableRow if $anchorCell is at tableCell depth.
|
|
86
85
|
var tableNode = preservedSelection.$anchorCell.node(1);
|
|
@@ -451,7 +450,7 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
|
451
450
|
}
|
|
452
451
|
},
|
|
453
452
|
getSharedState: function getSharedState(editorState) {
|
|
454
|
-
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$
|
|
453
|
+
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$lastDra, _key$getState0, _interactionTrackingP, _key$getState$isSelec, _key$getState1, _selectionPreservatio;
|
|
455
454
|
if (!editorState) {
|
|
456
455
|
return undefined;
|
|
457
456
|
}
|
|
@@ -465,10 +464,9 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
|
465
464
|
isDragging: (_key$getState$isDragg = (_key$getState7 = key.getState(editorState)) === null || _key$getState7 === void 0 ? void 0 : _key$getState7.isDragging) !== null && _key$getState$isDragg !== void 0 ? _key$getState$isDragg : false,
|
|
466
465
|
isPMDragging: (_key$getState$isPMDra = (_key$getState8 = key.getState(editorState)) === null || _key$getState8 === void 0 ? void 0 : _key$getState8.isPMDragging) !== null && _key$getState$isPMDra !== void 0 ? _key$getState$isPMDra : false,
|
|
467
466
|
multiSelectDnD: (_key$getState$multiSe = (_key$getState9 = key.getState(editorState)) === null || _key$getState9 === void 0 ? void 0 : _key$getState9.multiSelectDnD) !== null && _key$getState$multiSe !== void 0 ? _key$getState$multiSe : undefined,
|
|
468
|
-
|
|
469
|
-
lastDragCancelled: (_key$getState$lastDra = (_key$getState1 = key.getState(editorState)) === null || _key$getState1 === void 0 ? void 0 : _key$getState1.lastDragCancelled) !== null && _key$getState$lastDra !== void 0 ? _key$getState$lastDra : false,
|
|
467
|
+
lastDragCancelled: (_key$getState$lastDra = (_key$getState0 = key.getState(editorState)) === null || _key$getState0 === void 0 ? void 0 : _key$getState0.lastDragCancelled) !== null && _key$getState$lastDra !== void 0 ? _key$getState$lastDra : false,
|
|
470
468
|
isEditing: (_interactionTrackingP = interactionTrackingPluginKey.getState(editorState)) === null || _interactionTrackingP === void 0 ? void 0 : _interactionTrackingP.isEditing,
|
|
471
|
-
isSelectedViaDragHandle: (_key$getState$isSelec = (_key$
|
|
469
|
+
isSelectedViaDragHandle: (_key$getState$isSelec = (_key$getState1 = key.getState(editorState)) === null || _key$getState1 === void 0 ? void 0 : _key$getState1.isSelectedViaDragHandle) !== null && _key$getState$isSelec !== void 0 ? _key$getState$isSelec : false
|
|
472
470
|
};
|
|
473
471
|
if (registryBlockControlsEnabled) {
|
|
474
472
|
var surfaces = sparseSurfacesKey.getState(editorState);
|
|
@@ -243,11 +243,6 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
|
|
|
243
243
|
} else {
|
|
244
244
|
pos = view.posAtDOM(rootElement, 0);
|
|
245
245
|
}
|
|
246
|
-
if (parentRootElement && parentRootElement.getAttribute('data-layout-section') === 'true' && parentRootElement.querySelectorAll('[data-layout-column]').length === 1 && editorExperiment('advanced_layouts', true) && !expValEquals('platform_editor_layout_column_menu', 'isEnabled', true)) {
|
|
247
|
-
// Don't show drag handle for layout column in a single column layout,
|
|
248
|
-
// unless the layout column menu is enabled (menu needs the handle to be accessible).
|
|
249
|
-
return false;
|
|
250
|
-
}
|
|
251
246
|
var targetPos = view.state.doc.resolve(pos).pos;
|
|
252
247
|
var rootAnchorName;
|
|
253
248
|
var rootNodeType;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
2
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
3
2
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
4
3
|
import { getNodeTypeWithLevel } from './decorations-common';
|
|
5
4
|
var OPAQUE_BLOCKS = new Set(['table', 'bulletList', 'orderedList', 'taskList', 'decisionList', 'mediaSingle']);
|
|
@@ -103,9 +102,6 @@ export var handleSparseMouseOver = function handleSparseMouseOver(view, event, a
|
|
|
103
102
|
if (isPanelNodeTypeName(parentNode.type.name) && !(parentDOM instanceof HTMLElement && parentDOM.classList.contains('ak-editor-panel__no-icon')) && $target.index() === 0) {
|
|
104
103
|
return false;
|
|
105
104
|
}
|
|
106
|
-
if (node.type.name === 'layoutColumn' && parentNode.type.name === 'layoutSection' && parentNode.childCount === 1 && expValEqualsNoExposure('advanced_layouts', 'isEnabled', true) && !expValEquals('platform_editor_layout_column_menu', 'isEnabled', true)) {
|
|
107
|
-
return false;
|
|
108
|
-
}
|
|
109
105
|
var anchors = controls === null || controls === void 0 ? void 0 : controls.surfaceAnchors;
|
|
110
106
|
var anchorName = (_anchors$get = anchors === null || anchors === void 0 ? void 0 : anchors.get(targetPosition)) !== null && _anchors$get !== void 0 ? _anchors$get : api.core.actions.getAnchorIdForNode(node, targetPosition);
|
|
111
107
|
var rootPos = $target.depth > 0 ? $target.before(1) : targetPosition;
|
|
@@ -234,7 +234,7 @@ var getDecorationAtPos = function getDecorationAtPos(state, decorations, pos, to
|
|
|
234
234
|
return nodeDecAtActivePos;
|
|
235
235
|
};
|
|
236
236
|
var _apply = function apply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, nodeDecorationRegistry) {
|
|
237
|
-
var _meta$multiSelectDnD, _api$editorViewMode, _activeNode, _activeNode2, _meta$activeNode$hand, _activeNode3, _activeNode4, _meta$isDragging2, _meta$toggleMenu, _meta$isDragging3, _meta$toggleMenu2, _meta$toggleMenu3, _meta$toggleMenu4, _meta$toggleMenu5, _meta$toggleMenu6, _meta$toggleMenu7, _meta$toggleMenu8, _meta$editorHeight, _meta$editorWidthLeft, _meta$editorWidthRigh, _meta$isPMDragging, _meta$
|
|
237
|
+
var _meta$multiSelectDnD, _api$editorViewMode, _activeNode, _activeNode2, _meta$activeNode$hand, _activeNode3, _activeNode4, _meta$isDragging2, _meta$toggleMenu, _meta$isDragging3, _meta$toggleMenu2, _meta$toggleMenu3, _meta$toggleMenu4, _meta$toggleMenu5, _meta$toggleMenu6, _meta$toggleMenu7, _meta$toggleMenu8, _meta$editorHeight, _meta$editorWidthLeft, _meta$editorWidthRigh, _meta$isPMDragging, _meta$lastDragCancell;
|
|
238
238
|
var rightSideControlsEnabled = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : false;
|
|
239
239
|
var quickInsertButtonEnabled = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : true;
|
|
240
240
|
var anchorRectCache = arguments.length > 10 ? arguments[10] : undefined;
|
|
@@ -255,7 +255,6 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
|
|
|
255
255
|
menuTriggerByNode = currentState.menuTriggerByNode,
|
|
256
256
|
blockMenuOptions = currentState.blockMenuOptions,
|
|
257
257
|
isPMDragging = currentState.isPMDragging,
|
|
258
|
-
isShiftDown = currentState.isShiftDown,
|
|
259
258
|
lastDragCancelled = currentState.lastDragCancelled,
|
|
260
259
|
isSelectedViaDragHandle = currentState.isSelectedViaDragHandle;
|
|
261
260
|
var isActiveNodeDeleted = false;
|
|
@@ -966,7 +965,6 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
|
|
|
966
965
|
isDocSizeLimitEnabled: initialState.isDocSizeLimitEnabled,
|
|
967
966
|
isPMDragging: (_meta$isPMDragging = meta === null || meta === void 0 ? void 0 : meta.isPMDragging) !== null && _meta$isPMDragging !== void 0 ? _meta$isPMDragging : isPMDragging,
|
|
968
967
|
multiSelectDnD: multiSelectDnD,
|
|
969
|
-
isShiftDown: (_meta$isShiftDown = meta === null || meta === void 0 ? void 0 : meta.isShiftDown) !== null && _meta$isShiftDown !== void 0 ? _meta$isShiftDown : isShiftDown,
|
|
970
968
|
lastDragCancelled: (_meta$lastDragCancell = meta === null || meta === void 0 ? void 0 : meta.lastDragCancelled) !== null && _meta$lastDragCancell !== void 0 ? _meta$lastDragCancell : lastDragCancelled,
|
|
971
969
|
isSelectedViaDragHandle: isSelectedViaDragHandleNew
|
|
972
970
|
};
|
|
@@ -1210,29 +1208,13 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
1210
1208
|
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(false));
|
|
1211
1209
|
}
|
|
1212
1210
|
}
|
|
1213
|
-
if (!event.repeat && event.shiftKey && fg('platform_editor_elements_dnd_shift_click_select')) {
|
|
1214
|
-
view.dispatch(view.state.tr.setMeta(key, _objectSpread(_objectSpread({}, view.state.tr.getMeta(key)), {}, {
|
|
1215
|
-
isShiftDown: true
|
|
1216
|
-
})));
|
|
1217
|
-
}
|
|
1218
1211
|
return false;
|
|
1219
1212
|
},
|
|
1220
|
-
|
|
1213
|
+
blur: function blur(view, event) {
|
|
1221
1214
|
var _api$limitedMode0;
|
|
1222
1215
|
if (api !== null && api !== void 0 && (_api$limitedMode0 = api.limitedMode) !== null && _api$limitedMode0 !== void 0 && (_api$limitedMode0 = _api$limitedMode0.sharedState.currentState()) !== null && _api$limitedMode0 !== void 0 && _api$limitedMode0.enabled) {
|
|
1223
1216
|
return;
|
|
1224
1217
|
}
|
|
1225
|
-
if (!event.repeat && event.key === 'Shift') {
|
|
1226
|
-
view.dispatch(view.state.tr.setMeta(key, _objectSpread(_objectSpread({}, view.state.tr.getMeta(key)), {}, {
|
|
1227
|
-
isShiftDown: false
|
|
1228
|
-
})));
|
|
1229
|
-
}
|
|
1230
|
-
},
|
|
1231
|
-
blur: function blur(view, event) {
|
|
1232
|
-
var _api$limitedMode1;
|
|
1233
|
-
if (api !== null && api !== void 0 && (_api$limitedMode1 = api.limitedMode) !== null && _api$limitedMode1 !== void 0 && (_api$limitedMode1 = _api$limitedMode1.sharedState.currentState()) !== null && _api$limitedMode1 !== void 0 && _api$limitedMode1.enabled) {
|
|
1234
|
-
return;
|
|
1235
|
-
}
|
|
1236
1218
|
if (editorExperiment('platform_editor_controls', 'variant1')) {
|
|
1237
1219
|
var _api$core2;
|
|
1238
1220
|
// Focus moving into the registry surface remains inside the editor experience.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { INSERTED_TRAILING_PARAGRAPH_TO_LAST_NODE_META } from '@atlaskit/editor-common/block-type';
|
|
2
2
|
import { expandToBlockRange, isMultiBlockRange } from '@atlaskit/editor-common/selection';
|
|
3
|
-
import {
|
|
3
|
+
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
import { getTableSelectionClosesToPos } from '@atlaskit/editor-tables/utils';
|
|
5
5
|
import { getBlockControlsMeta, key } from '../main';
|
|
6
6
|
import { newGetSelection } from './getSelection';
|
|
@@ -48,35 +48,6 @@ export var getSelectedSlicePosition = function getSelectedSlicePosition(handlePo
|
|
|
48
48
|
};
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
/**
|
|
52
|
-
* Takes a position and expands the selection to encompass the node at that position. Ignores empty or out of range selections.
|
|
53
|
-
* Ignores positions that are in text blocks (i.e. not start of a node)
|
|
54
|
-
* @returns TextSelection if expanded, otherwise returns Selection that was passed in.
|
|
55
|
-
*/
|
|
56
|
-
export var expandSelectionHeadToNodeAtPos = function expandSelectionHeadToNodeAtPos(selection, nodePos) {
|
|
57
|
-
var doc = selection.$anchor.doc;
|
|
58
|
-
if (nodePos < 0 || nodePos > doc.nodeSize - 2 || selection.empty) {
|
|
59
|
-
return selection;
|
|
60
|
-
}
|
|
61
|
-
var $pos = doc.resolve(nodePos);
|
|
62
|
-
var node = $pos.nodeAfter;
|
|
63
|
-
if ($pos.node().isTextblock || !node) {
|
|
64
|
-
return selection;
|
|
65
|
-
}
|
|
66
|
-
var $newHead = nodePos < selection.anchor ? $pos : doc.resolve(node.nodeSize + nodePos);
|
|
67
|
-
var textSelection = new TextSelection(selection.$anchor, $newHead);
|
|
68
|
-
return textSelection;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* This swaps the anchor/head for NodeSelections when its anchor > pos.
|
|
73
|
-
* This is because NodeSelection always has an anchor at the start of the node,
|
|
74
|
-
* which may not align with the existing selection.
|
|
75
|
-
*/
|
|
76
|
-
export var alignAnchorHeadInDirectionOfPos = function alignAnchorHeadInDirectionOfPos(selection, pos) {
|
|
77
|
-
return selection instanceof NodeSelection && Math.max(pos, selection.anchor) === selection.anchor ? new TextSelection(selection.$head, selection.$anchor) : selection;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
51
|
/**
|
|
81
52
|
* This maps a preserved selection through a transaction, expanding text selections to block boundaries.
|
|
82
53
|
*
|
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
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
|
-
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
5
1
|
import { nodeMargins, spacingBetweenNodesForPreview } from './consts';
|
|
6
2
|
export var buildLayoutColumnMenuMeta = function buildLayoutColumnMenuMeta(anchorPos, openedViaKeyboard) {
|
|
7
|
-
return
|
|
8
|
-
anchorPos: anchorPos
|
|
9
|
-
}, fg('platform_editor_layout_column_menu_kill_switch_1') ? {
|
|
10
|
-
isOpen: true
|
|
11
|
-
} : {}), {}, {
|
|
3
|
+
return {
|
|
4
|
+
anchorPos: anchorPos,
|
|
12
5
|
openedViaKeyboard: openedViaKeyboard
|
|
13
|
-
}
|
|
6
|
+
};
|
|
14
7
|
};
|
|
15
8
|
export var getNodeSpacingForDragPreview = function getNodeSpacingForDragPreview(node) {
|
|
16
9
|
var _spacingBetweenNodesF2;
|