@atlaskit/editor-plugin-block-controls 7.2.12 → 7.4.0
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 +37 -0
- package/dist/cjs/blockControlsPlugin.js +15 -7
- package/dist/cjs/editor-commands/move-node.js +34 -59
- package/dist/cjs/pm-plugins/handle-mouse-down.js +28 -1
- package/dist/cjs/pm-plugins/handle-mouse-over.js +9 -8
- package/dist/cjs/pm-plugins/utils/getSelection.js +18 -37
- package/dist/cjs/pm-plugins/utils/validation.js +1 -1
- package/dist/cjs/ui/drag-handle.js +13 -4
- package/dist/cjs/ui/inline-drop-target.js +2 -1
- package/dist/cjs/ui/quick-insert-button.js +14 -1
- package/dist/es2019/blockControlsPlugin.js +15 -7
- package/dist/es2019/editor-commands/move-node.js +35 -61
- package/dist/es2019/pm-plugins/handle-mouse-down.js +29 -1
- package/dist/es2019/pm-plugins/handle-mouse-over.js +9 -8
- package/dist/es2019/pm-plugins/utils/getSelection.js +18 -37
- package/dist/es2019/pm-plugins/utils/validation.js +1 -1
- package/dist/es2019/ui/drag-handle.js +14 -5
- package/dist/es2019/ui/inline-drop-target.js +2 -1
- package/dist/es2019/ui/quick-insert-button.js +15 -2
- package/dist/esm/blockControlsPlugin.js +15 -7
- package/dist/esm/editor-commands/move-node.js +34 -59
- package/dist/esm/pm-plugins/handle-mouse-down.js +28 -1
- package/dist/esm/pm-plugins/handle-mouse-over.js +9 -8
- package/dist/esm/pm-plugins/utils/getSelection.js +18 -37
- package/dist/esm/pm-plugins/utils/validation.js +1 -1
- package/dist/esm/ui/drag-handle.js +14 -5
- package/dist/esm/ui/inline-drop-target.js +2 -1
- package/dist/esm/ui/quick-insert-button.js +15 -2
- package/package.json +18 -15
|
@@ -31,52 +31,38 @@ import { getPosWhenMoveNodeDown, getPosWhenMoveNodeUp } from './utils/move-node-
|
|
|
31
31
|
function transformSourceSlice(nodeCopy, destType) {
|
|
32
32
|
const srcNode = nodeCopy.content.firstChild;
|
|
33
33
|
const schema = srcNode === null || srcNode === void 0 ? void 0 : srcNode.type.schema;
|
|
34
|
-
if (
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const destTypeInDocOrLayoutCol = [doc, layoutColumn].includes(destType);
|
|
34
|
+
if (!schema) {
|
|
35
|
+
return nodeCopy;
|
|
36
|
+
}
|
|
37
|
+
const {
|
|
38
|
+
doc,
|
|
39
|
+
layoutColumn
|
|
40
|
+
} = schema.nodes;
|
|
41
|
+
const destTypeInTable = isInsideTable(destType);
|
|
42
|
+
const destTypeInDocOrLayoutCol = [doc, layoutColumn].includes(destType);
|
|
44
43
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
if (containsExpand && containsNestedExpand) {
|
|
59
|
-
break;
|
|
60
|
-
}
|
|
44
|
+
// No need to loop over slice content if destination requires no transformations
|
|
45
|
+
if (!destTypeInTable && !destTypeInDocOrLayoutCol) {
|
|
46
|
+
return nodeCopy;
|
|
47
|
+
}
|
|
48
|
+
let containsExpand = false;
|
|
49
|
+
let containsNestedExpand = false;
|
|
50
|
+
for (let i = 0; i < nodeCopy.content.childCount; i++) {
|
|
51
|
+
const node = nodeCopy.content.child(i);
|
|
52
|
+
if (node.type === schema.nodes.expand) {
|
|
53
|
+
containsExpand = true;
|
|
54
|
+
} else if (node.type === schema.nodes.nestedExpand) {
|
|
55
|
+
containsNestedExpand = true;
|
|
61
56
|
}
|
|
62
|
-
if (containsExpand &&
|
|
63
|
-
|
|
64
|
-
} else if (containsNestedExpand && destTypeInDocOrLayoutCol) {
|
|
65
|
-
return transformSliceNestedExpandToExpand(nodeCopy, schema);
|
|
66
|
-
}
|
|
67
|
-
} else {
|
|
68
|
-
if (srcNode && schema) {
|
|
69
|
-
const {
|
|
70
|
-
doc,
|
|
71
|
-
layoutColumn
|
|
72
|
-
} = schema.nodes;
|
|
73
|
-
if (srcNode.type === schema.nodes.nestedExpand && [doc, layoutColumn].includes(destType)) {
|
|
74
|
-
return transformSliceNestedExpandToExpand(nodeCopy, schema);
|
|
75
|
-
} else if (srcNode.type === schema.nodes.expand && isInsideTable(destType)) {
|
|
76
|
-
return transformSliceExpandToNestedExpand(nodeCopy);
|
|
77
|
-
}
|
|
57
|
+
if (containsExpand && containsNestedExpand) {
|
|
58
|
+
break;
|
|
78
59
|
}
|
|
79
60
|
}
|
|
61
|
+
if (containsExpand && destTypeInTable) {
|
|
62
|
+
return transformSliceExpandToNestedExpand(nodeCopy);
|
|
63
|
+
} else if (containsNestedExpand && destTypeInDocOrLayoutCol) {
|
|
64
|
+
return transformSliceNestedExpandToExpand(nodeCopy, schema);
|
|
65
|
+
}
|
|
80
66
|
return nodeCopy;
|
|
81
67
|
}
|
|
82
68
|
const nodesSupportDragLayoutColumnInto = ['tableCell', 'tableHeader', 'panel', 'expand', 'nestedExpand'];
|
|
@@ -145,7 +131,7 @@ export const moveNodeViaShortcut = (api, direction, formatMessage) => {
|
|
|
145
131
|
let hoistedPos;
|
|
146
132
|
const from = Math.min(expandedAnchor, expandedHead);
|
|
147
133
|
// Nodes like lists nest within themselves, we need to find the top most position
|
|
148
|
-
if (isParentNodeOfTypeLayout
|
|
134
|
+
if (isParentNodeOfTypeLayout) {
|
|
149
135
|
const LAYOUT_COL_DEPTH = 3;
|
|
150
136
|
hoistedPos = state.doc.resolve(from).before(LAYOUT_COL_DEPTH);
|
|
151
137
|
}
|
|
@@ -291,15 +277,9 @@ export const moveNodeViaShortcut = (api, direction, formatMessage) => {
|
|
|
291
277
|
api === null || api === void 0 ? void 0 : (_api$core7 = api.core) === null || _api$core7 === void 0 ? void 0 : _api$core7.actions.execute(({
|
|
292
278
|
tr
|
|
293
279
|
}) => {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
});
|
|
298
|
-
} else {
|
|
299
|
-
api === null || api === void 0 ? void 0 : api.blockControls.commands.setMultiSelectPositions(expandedAnchor, expandedHead)({
|
|
300
|
-
tr
|
|
301
|
-
});
|
|
302
|
-
}
|
|
280
|
+
api === null || api === void 0 ? void 0 : api.blockControls.commands.setMultiSelectPositions($newAnchor.pos, $newHead.pos)({
|
|
281
|
+
tr
|
|
282
|
+
});
|
|
303
283
|
moveNode(api)(currentNodePos, moveToPos, INPUT_METHOD.SHORTCUT, formatMessage)({
|
|
304
284
|
tr
|
|
305
285
|
});
|
|
@@ -323,15 +303,9 @@ export const moveNodeViaShortcut = (api, direction, formatMessage) => {
|
|
|
323
303
|
api === null || api === void 0 ? void 0 : (_api$core9 = api.core) === null || _api$core9 === void 0 ? void 0 : _api$core9.actions.execute(({
|
|
324
304
|
tr
|
|
325
305
|
}) => {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
});
|
|
330
|
-
} else {
|
|
331
|
-
api === null || api === void 0 ? void 0 : api.blockControls.commands.setMultiSelectPositions(expandedAnchor, expandedHead)({
|
|
332
|
-
tr
|
|
333
|
-
});
|
|
334
|
-
}
|
|
306
|
+
api === null || api === void 0 ? void 0 : api.blockControls.commands.setMultiSelectPositions($newAnchor.pos, $newHead.pos)({
|
|
307
|
+
tr
|
|
308
|
+
});
|
|
335
309
|
tr.scrollIntoView();
|
|
336
310
|
return tr;
|
|
337
311
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DRAG_HANDLE_SELECTOR } from '@atlaskit/editor-common/styles';
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
3
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
3
4
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
4
5
|
export const handleMouseDown = api => (view, event) => {
|
|
@@ -28,7 +29,34 @@ export const handleMouseDown = api => (view, event) => {
|
|
|
28
29
|
}
|
|
29
30
|
} else {
|
|
30
31
|
const isDragHandle = event.target.closest(expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) ? DRAG_HANDLE_SELECTOR : '[data-editor-block-ctrl-drag-handle]') !== null;
|
|
31
|
-
api === null || api === void 0 ? void 0 : api.core.actions.execute(
|
|
32
|
+
api === null || api === void 0 ? void 0 : api.core.actions.execute(({
|
|
33
|
+
tr
|
|
34
|
+
}) => {
|
|
35
|
+
api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(isDragHandle)({
|
|
36
|
+
tr
|
|
37
|
+
});
|
|
38
|
+
/**
|
|
39
|
+
* When block menu is enabled, reset intent back to 'default' as editor-plugin-block-menu sets the user intent to 'blockMenuOpen', and setting here
|
|
40
|
+
* causes flickering as this runs before editor-plugin-block-menu.
|
|
41
|
+
*/
|
|
42
|
+
if (fg('platform_editor_toolbar_aifc_user_intent_fix')) {
|
|
43
|
+
if (expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true)) {
|
|
44
|
+
// if target is drag handle, block menu will be opened
|
|
45
|
+
if (!isDragHandle) {
|
|
46
|
+
var _api$userIntent;
|
|
47
|
+
api === null || api === void 0 ? void 0 : (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 ? void 0 : _api$userIntent.commands.setCurrentUserIntent('default')({
|
|
48
|
+
tr
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
} else {
|
|
52
|
+
var _api$userIntent2;
|
|
53
|
+
(_api$userIntent2 = api.userIntent) === null || _api$userIntent2 === void 0 ? void 0 : _api$userIntent2.commands.setCurrentUserIntent(isDragHandle ? 'dragHandleSelected' : 'default')({
|
|
54
|
+
tr
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return tr;
|
|
59
|
+
});
|
|
32
60
|
}
|
|
33
61
|
return false;
|
|
34
62
|
};
|
|
@@ -24,7 +24,7 @@ const getNodeSelector = (ignoreNodes, ignoreNodeDescendants) => {
|
|
|
24
24
|
};
|
|
25
25
|
const getDefaultNodeSelector = memoizeOne(() => {
|
|
26
26
|
// we don't show handler for node nested in table
|
|
27
|
-
return getNodeSelector([...IGNORE_NODES_NEXT], [...IGNORE_NODE_DESCENDANTS_ADVANCED_LAYOUT, 'table']);
|
|
27
|
+
return getNodeSelector([...IGNORE_NODES_NEXT, 'media'], [...IGNORE_NODE_DESCENDANTS_ADVANCED_LAYOUT, 'table']);
|
|
28
28
|
});
|
|
29
29
|
export const handleMouseOver = (view, event, api) => {
|
|
30
30
|
var _api$blockControls, _api$editorDisabled, _target$classList;
|
|
@@ -41,7 +41,7 @@ export const handleMouseOver = (view, event, api) => {
|
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
// We shouldn't be firing mouse over transactions when the editor is disabled
|
|
44
|
-
if (editorDisabled && fg('
|
|
44
|
+
if (editorDisabled && fg('aifc_create_enabled')) {
|
|
45
45
|
return false;
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -54,24 +54,25 @@ export const handleMouseOver = (view, event, api) => {
|
|
|
54
54
|
// Ignored via go/ees005
|
|
55
55
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
56
56
|
const target = event.target;
|
|
57
|
+
const isNativeAnchorSupported = expValEquals('platform_editor_native_anchor_support', 'isEnabled', true);
|
|
57
58
|
if (target !== null && target !== void 0 && (_target$classList = target.classList) !== null && _target$classList !== void 0 && _target$classList.contains('ProseMirror')) {
|
|
58
59
|
return false;
|
|
59
60
|
}
|
|
60
|
-
let rootElement = target === null || target === void 0 ? void 0 : target.closest(
|
|
61
|
+
let rootElement = target === null || target === void 0 ? void 0 : target.closest(isNativeAnchorSupported ? getDefaultNodeSelector() : `[data-drag-handler-anchor-name]`);
|
|
61
62
|
if (rootElement) {
|
|
62
63
|
var _rootElement$parentEl;
|
|
63
64
|
// We want to exlude handles from showing for empty paragraph and heading nodes
|
|
64
65
|
if (isEmptyNestedParagraphOrHeading(rootElement)) {
|
|
65
66
|
return false;
|
|
66
67
|
}
|
|
67
|
-
if (rootElement.getAttribute(getTypeNameAttrName()) === 'media' && editorExperiment('advanced_layouts', true)) {
|
|
68
|
+
if (rootElement.getAttribute(getTypeNameAttrName()) === 'media' && editorExperiment('advanced_layouts', true) && !isNativeAnchorSupported) {
|
|
68
69
|
rootElement = rootElement.closest(`[${getAnchorAttrName()}][${getTypeNameAttrName()}="mediaSingle"]`);
|
|
69
70
|
if (!rootElement) {
|
|
70
71
|
return false;
|
|
71
72
|
}
|
|
72
73
|
}
|
|
73
74
|
const parentElement = (_rootElement$parentEl = rootElement.parentElement) === null || _rootElement$parentEl === void 0 ? void 0 : _rootElement$parentEl.closest(`[${getAnchorAttrName()}]`);
|
|
74
|
-
const parentElementType =
|
|
75
|
+
const parentElementType = isNativeAnchorSupported ? getTypeNameFromDom(parentElement) : parentElement === null || parentElement === void 0 ? void 0 : parentElement.getAttribute('data-drag-handler-node-type');
|
|
75
76
|
if (editorExperiment('advanced_layouts', true)) {
|
|
76
77
|
// We want to exclude handles from showing for direct descendant of table nodes (i.e. nodes in cells)
|
|
77
78
|
if (parentElement && parentElementType === 'table') {
|
|
@@ -79,7 +80,7 @@ export const handleMouseOver = (view, event, api) => {
|
|
|
79
80
|
} else if (parentElement && parentElementType === 'tableRow') {
|
|
80
81
|
var _parentElement$parent;
|
|
81
82
|
const grandparentElement = parentElement === null || parentElement === void 0 ? void 0 : (_parentElement$parent = parentElement.parentElement) === null || _parentElement$parent === void 0 ? void 0 : _parentElement$parent.closest(`[${getAnchorAttrName()}]`);
|
|
82
|
-
const grandparentElementType =
|
|
83
|
+
const grandparentElementType = isNativeAnchorSupported ? getTypeNameFromDom(grandparentElement) : grandparentElement === null || grandparentElement === void 0 ? void 0 : grandparentElement.getAttribute('data-drag-handler-node-type');
|
|
83
84
|
if (grandparentElement && grandparentElementType === 'table') {
|
|
84
85
|
rootElement = grandparentElement;
|
|
85
86
|
}
|
|
@@ -146,11 +147,11 @@ export const handleMouseOver = (view, event, api) => {
|
|
|
146
147
|
if (rootDOM instanceof HTMLElement) {
|
|
147
148
|
var _rootDOM$getAttribute;
|
|
148
149
|
rootAnchorName = (_rootDOM$getAttribute = rootDOM.getAttribute(getAnchorAttrName())) !== null && _rootDOM$getAttribute !== void 0 ? _rootDOM$getAttribute : undefined;
|
|
149
|
-
rootNodeType =
|
|
150
|
+
rootNodeType = isNativeAnchorSupported ? getTypeNameFromDom(rootDOM) : rootDOM.getAttribute('data-drag-handler-node-type');
|
|
150
151
|
}
|
|
151
152
|
}
|
|
152
153
|
}
|
|
153
|
-
const nodeType =
|
|
154
|
+
const nodeType = isNativeAnchorSupported ? getTypeNameFromDom(rootElement) : rootElement.getAttribute('data-drag-handler-node-type');
|
|
154
155
|
if (nodeType) {
|
|
155
156
|
if (editorExperiment('platform_editor_controls', 'variant1')) {
|
|
156
157
|
var _api$core, _api$blockControls2, _rootPos, _rootAnchorName, _rootNodeType;
|
|
@@ -2,7 +2,6 @@ import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
|
|
|
2
2
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
4
4
|
import { selectTableClosestToPos } from '@atlaskit/editor-tables/utils';
|
|
5
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
5
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
7
6
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
8
7
|
export const getInlineNodePos = (tr, start, nodeSize) => {
|
|
@@ -67,7 +66,7 @@ const oldGetSelection = (tr, start) => {
|
|
|
67
66
|
// we need a quick way to make all child media nodes appear as selected without the need for a custom selection
|
|
68
67
|
nodeName === 'mediaGroup') {
|
|
69
68
|
return new NodeSelection($startPos);
|
|
70
|
-
} else if (nodeName === 'taskList'
|
|
69
|
+
} else if (nodeName === 'taskList') {
|
|
71
70
|
return TextSelection.create(tr.doc, start, start + nodeSize);
|
|
72
71
|
} else {
|
|
73
72
|
const {
|
|
@@ -109,7 +108,7 @@ const newGetSelection = (tr, start) => {
|
|
|
109
108
|
const $mediaStartPos = tr.doc.resolve(start + 1);
|
|
110
109
|
return new NodeSelection($mediaStartPos);
|
|
111
110
|
}
|
|
112
|
-
if (nodeName === 'taskList' && !expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true)
|
|
111
|
+
if (nodeName === 'taskList' && !expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true)) {
|
|
113
112
|
return TextSelection.create(tr.doc, start, start + nodeSize);
|
|
114
113
|
}
|
|
115
114
|
const {
|
|
@@ -176,40 +175,22 @@ export const isHandleCorrelatedToSelection = (state, selection, handlePos) => {
|
|
|
176
175
|
}
|
|
177
176
|
let nodeStart;
|
|
178
177
|
const $selectionFrom = selection.$from;
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
nodeStart = $resolvedNodePos.before();
|
|
196
|
-
}
|
|
197
|
-
} else {
|
|
198
|
-
const selectionFrom = $selectionFrom.pos;
|
|
199
|
-
nodeStart = $selectionFrom.depth ? $selectionFrom.before() : selectionFrom;
|
|
200
|
-
const $resolvedNodePos = state.doc.resolve(nodeStart);
|
|
201
|
-
if (['tableRow', 'tableCell', 'tableHeader'].includes($resolvedNodePos.node().type.name)) {
|
|
202
|
-
const parentNodeFindRes = findParentNodeOfType(state.schema.nodes['table'])(selection);
|
|
203
|
-
const tablePos = parentNodeFindRes === null || parentNodeFindRes === void 0 ? void 0 : parentNodeFindRes.pos;
|
|
204
|
-
nodeStart = typeof tablePos === 'undefined' ? nodeStart : tablePos;
|
|
205
|
-
} else if (['listItem'].includes($resolvedNodePos.node().type.name)) {
|
|
206
|
-
nodeStart = $resolvedNodePos.before(rootListDepth($resolvedNodePos));
|
|
207
|
-
} else if (['taskList'].includes($resolvedNodePos.node().type.name)) {
|
|
208
|
-
const listdepth = rootTaskListDepth($resolvedNodePos);
|
|
209
|
-
nodeStart = $resolvedNodePos.before(listdepth);
|
|
210
|
-
} else if (['blockquote'].includes($resolvedNodePos.node().type.name)) {
|
|
211
|
-
nodeStart = $resolvedNodePos.before();
|
|
212
|
-
}
|
|
178
|
+
nodeStart = $selectionFrom.before($selectionFrom.sharedDepth(selection.to) + 1);
|
|
179
|
+
if (nodeStart === $selectionFrom.pos) {
|
|
180
|
+
nodeStart = $selectionFrom.depth ? $selectionFrom.before() : $selectionFrom.pos;
|
|
181
|
+
}
|
|
182
|
+
const $resolvedNodePos = state.doc.resolve(nodeStart);
|
|
183
|
+
if (['tableRow', 'tableCell', 'tableHeader'].includes($resolvedNodePos.node().type.name)) {
|
|
184
|
+
const parentNodeFindRes = findParentNodeOfType(state.schema.nodes['table'])(selection);
|
|
185
|
+
const tablePos = parentNodeFindRes === null || parentNodeFindRes === void 0 ? void 0 : parentNodeFindRes.pos;
|
|
186
|
+
nodeStart = typeof tablePos === 'undefined' ? nodeStart : tablePos;
|
|
187
|
+
} else if (['listItem'].includes($resolvedNodePos.node().type.name)) {
|
|
188
|
+
nodeStart = $resolvedNodePos.before(rootListDepth($resolvedNodePos));
|
|
189
|
+
} else if (['taskList'].includes($resolvedNodePos.node().type.name)) {
|
|
190
|
+
const listdepth = rootTaskListDepth($resolvedNodePos);
|
|
191
|
+
nodeStart = $resolvedNodePos.before(listdepth);
|
|
192
|
+
} else if (['blockquote'].includes($resolvedNodePos.node().type.name)) {
|
|
193
|
+
nodeStart = $resolvedNodePos.before();
|
|
213
194
|
}
|
|
214
195
|
return Boolean(handlePos < selection.$to.pos && handlePos >= nodeStart);
|
|
215
196
|
};
|
|
@@ -164,7 +164,7 @@ export function canMoveSliceToIndex(slice, sliceFromPos, sliceToPos, destParent,
|
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
// Multiple layout columns do not drop correctly.
|
|
167
|
-
if (((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.type.name) === 'layoutColumn'
|
|
167
|
+
if (((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.type.name) === 'layoutColumn') {
|
|
168
168
|
return false;
|
|
169
169
|
}
|
|
170
170
|
for (let i = 0; i < slice.content.childCount; i++) {
|
|
@@ -17,7 +17,7 @@ import { tableControlsSpacing, DRAG_HANDLE_WIDTH } from '@atlaskit/editor-common
|
|
|
17
17
|
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
18
18
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
19
19
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
20
|
-
import { akEditorTableToolbarSize, akEditorFullPageNarrowBreakout } from '@atlaskit/editor-shared-styles/consts';
|
|
20
|
+
import { akEditorTableToolbarSize, akEditorFullPageNarrowBreakout, akEditorFullPageDefaultFontSize } from '@atlaskit/editor-shared-styles/consts';
|
|
21
21
|
import DragHandleVerticalIcon from '@atlaskit/icon/core/drag-handle-vertical';
|
|
22
22
|
import DragHandlerIcon from '@atlaskit/icon/glyph/drag-handler';
|
|
23
23
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
@@ -127,6 +127,16 @@ const dragHandleButtonStyles = css({
|
|
|
127
127
|
backgroundColor: "var(--ds-background-disabled, transparent)"
|
|
128
128
|
}
|
|
129
129
|
});
|
|
130
|
+
|
|
131
|
+
// Calculate scaled dimensions based on the base font size using CSS calc()
|
|
132
|
+
// Default font size is 16px, scale proportionally
|
|
133
|
+
// Standard: 16px -> 24h x 12w, Dense: 13px -> 18h x 9w
|
|
134
|
+
const dragHandleButtonDenseModeStyles = css({
|
|
135
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
136
|
+
height: `calc(${DRAG_HANDLE_HEIGHT}px * var(--ak-editor-base-font-size) / ${akEditorFullPageDefaultFontSize}px)`,
|
|
137
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
138
|
+
width: `calc(${DRAG_HANDLE_WIDTH}px * var(--ak-editor-base-font-size) / ${akEditorFullPageDefaultFontSize}px)`
|
|
139
|
+
});
|
|
130
140
|
const dragHandleButtonSmallScreenStyles = css({
|
|
131
141
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-container-queries, @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
132
142
|
[`@container editor-area (max-width: ${akEditorFullPageNarrowBreakout}px)`]: {
|
|
@@ -513,9 +523,8 @@ export const DragHandle = ({
|
|
|
513
523
|
if (typeof handlePos !== 'number') {
|
|
514
524
|
return tr;
|
|
515
525
|
}
|
|
516
|
-
const oldHandlePosCheck = handlePos >= tr.selection.$from.start() - 1 && handlePos <= tr.selection.to;
|
|
517
526
|
const newHandlePosCheck = isHandleCorrelatedToSelection(view.state, tr.selection, handlePos);
|
|
518
|
-
if (!tr.selection.empty &&
|
|
527
|
+
if (!tr.selection.empty && newHandlePosCheck) {
|
|
519
528
|
var _api$blockControls7;
|
|
520
529
|
api === null || api === void 0 ? void 0 : (_api$blockControls7 = api.blockControls) === null || _api$blockControls7 === void 0 ? void 0 : _api$blockControls7.commands.setMultiSelectPositions()({
|
|
521
530
|
tr
|
|
@@ -714,7 +723,7 @@ export const DragHandle = ({
|
|
|
714
723
|
const bottom = editorExperiment('platform_editor_controls', 'variant1') ? getControlBottomCSSValue(safeAnchorName, isSticky, isTopLevelNode, isLayoutColumn) : {};
|
|
715
724
|
return {
|
|
716
725
|
left: isEdgeCase ? `calc(anchor(${safeAnchorName} start) + ${getLeftPosition(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType)})` : editorExperiment('advanced_layouts', true) && isLayoutColumn ? `calc((anchor(${safeAnchorName} right) + anchor(${safeAnchorName} left))/2 - ${DRAG_HANDLE_HEIGHT / 2}px)` : `calc(anchor(${safeAnchorName} start) - ${DRAG_HANDLE_WIDTH}px - ${dragHandleGap(nodeType, parentNodeType)}px)`,
|
|
717
|
-
top: editorExperiment('advanced_layouts', true) && isLayoutColumn ? `calc(anchor(${safeAnchorName} top) - ${DRAG_HANDLE_WIDTH}px)` : `calc(anchor(${safeAnchorName} start)
|
|
726
|
+
top: editorExperiment('advanced_layouts', true) && isLayoutColumn ? `calc(anchor(${safeAnchorName} top) - ${DRAG_HANDLE_WIDTH}px)` : `calc(anchor(${safeAnchorName} start)+ ${topPositionAdjustment(expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) ? $pos && $pos.nodeAfter && getNodeTypeWithLevel($pos.nodeAfter) || nodeType : nodeType)}px)`,
|
|
718
727
|
...bottom
|
|
719
728
|
};
|
|
720
729
|
}
|
|
@@ -942,7 +951,7 @@ export const DragHandle = ({
|
|
|
942
951
|
css: [editorExperiment('platform_editor_controls', 'variant1') ? dragHandleButtonStyles : dragHandleButtonStylesOld, editorExperiment('platform_editor_controls', 'variant1') && dragHandleColor,
|
|
943
952
|
// ED-26266: Fixed the drag handle highlight when selecting multiple line in Firefox
|
|
944
953
|
// See https://product-fabric.atlassian.net/browse/ED-26266
|
|
945
|
-
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, expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) && expValEqualsNoExposure('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true) && isFocused && keyboardFocusedDragHandleStyles, expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) && expValEqualsNoExposure('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true) ? focusedStyles : focusedStylesOld],
|
|
954
|
+
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, expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) && expValEqualsNoExposure('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true) && isFocused && keyboardFocusedDragHandleStyles, expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) && expValEqualsNoExposure('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true) ? focusedStyles : focusedStylesOld, expValEquals('cc_editor_ai_content_mode', 'variant', 'test') && fg('platform_editor_content_mode_button_mvp') && dragHandleButtonDenseModeStyles],
|
|
946
955
|
ref: buttonRef
|
|
947
956
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
948
957
|
,
|
|
@@ -90,7 +90,8 @@ export const InlineDropTarget = ({
|
|
|
90
90
|
const [isDraggedOver, setIsDraggedOver] = useState(false);
|
|
91
91
|
const anchorName = useMemo(() => {
|
|
92
92
|
if (expValEquals('platform_editor_native_anchor_support', 'isEnabled', true)) {
|
|
93
|
-
|
|
93
|
+
var _getPos;
|
|
94
|
+
return nextNode ? (api === null || api === void 0 ? void 0 : api.core.actions.getAnchorIdForNode(nextNode, (_getPos = getPos()) !== null && _getPos !== void 0 ? _getPos : -1)) || '' : '';
|
|
94
95
|
}
|
|
95
96
|
return nextNode ? getNodeAnchor(nextNode) : '';
|
|
96
97
|
}, [api, getPos, nextNode]);
|
|
@@ -14,14 +14,17 @@ import { tableControlsSpacing } from '@atlaskit/editor-common/styles';
|
|
|
14
14
|
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
15
15
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
16
16
|
import { findParentNode, findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
17
|
+
import { akEditorFullPageDefaultFontSize } from '@atlaskit/editor-shared-styles';
|
|
17
18
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
18
19
|
import AddIcon from '@atlaskit/icon/core/add';
|
|
20
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
19
21
|
// eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
|
|
20
22
|
import { Box, Pressable, xcss } from '@atlaskit/primitives';
|
|
23
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
21
24
|
import Tooltip from '@atlaskit/tooltip';
|
|
22
25
|
import { getControlBottomCSSValue, getControlHeightCSSValue, getNodeHeight, getTopPosition, shouldBeSticky } from '../pm-plugins/utils/drag-handle-positions';
|
|
23
26
|
import { getLeftPositionForRootElement } from '../pm-plugins/utils/widget-positions';
|
|
24
|
-
import { QUICK_INSERT_DIMENSIONS, QUICK_INSERT_LEFT_OFFSET, rootElementGap, topPositionAdjustment } from './consts';
|
|
27
|
+
import { QUICK_INSERT_DIMENSIONS, QUICK_INSERT_HEIGHT, QUICK_INSERT_LEFT_OFFSET, QUICK_INSERT_WIDTH, rootElementGap, topPositionAdjustment } from './consts';
|
|
25
28
|
import { refreshAnchorName } from './utils/anchor-name';
|
|
26
29
|
import { isInTextSelection, isNestedNodeSelected, isNonEditableBlock, isSelectionInNode } from './utils/document-checks';
|
|
27
30
|
import { getAnchorAttrName } from './utils/dom-attr-name';
|
|
@@ -53,6 +56,16 @@ const stickyButtonStyles = xcss({
|
|
|
53
56
|
outline: `${"var(--ds-border-width-focused, 2px)"} solid ${"var(--ds-border-focused, #388BFF)"}`
|
|
54
57
|
}
|
|
55
58
|
});
|
|
59
|
+
|
|
60
|
+
// Calculate scaled dimensions based on the base font size using CSS calc()
|
|
61
|
+
// Default font size is 16px, scale proportionally
|
|
62
|
+
// Standard: 16px -> 24px x 24px, Dense: 13px -> ~18.5px x ~18.5px
|
|
63
|
+
const stickyButtonDenseModeStyles = xcss({
|
|
64
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
65
|
+
height: `calc(${QUICK_INSERT_HEIGHT}px * var(--ak-editor-base-font-size) / ${akEditorFullPageDefaultFontSize}px)`,
|
|
66
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
67
|
+
width: `calc(${QUICK_INSERT_WIDTH}px * var(--ak-editor-base-font-size) / ${akEditorFullPageDefaultFontSize}px)`
|
|
68
|
+
});
|
|
56
69
|
const containerStaticStyles = xcss({
|
|
57
70
|
position: 'absolute',
|
|
58
71
|
zIndex: 'card'
|
|
@@ -273,7 +286,7 @@ export const TypeAheadControl = ({
|
|
|
273
286
|
testId: "editor-quick-insert-button",
|
|
274
287
|
type: "button",
|
|
275
288
|
"aria-label": formatMessage(messages.insert),
|
|
276
|
-
xcss: [stickyButtonStyles],
|
|
289
|
+
xcss: [stickyButtonStyles, expValEquals('cc_editor_ai_content_mode', 'variant', 'test') && fg('platform_editor_content_mode_button_mvp') && stickyButtonDenseModeStyles],
|
|
277
290
|
onClick: handleQuickInsert,
|
|
278
291
|
onMouseDown: handleMouseDown
|
|
279
292
|
}, jsx(AddIcon, {
|
|
@@ -118,18 +118,26 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
|
118
118
|
toggleMenu: toggleMenuMeta
|
|
119
119
|
}));
|
|
120
120
|
if ((menuTriggerBy === undefined || !!menuTriggerBy && menuTriggerBy === (options === null || options === void 0 ? void 0 : options.anchorName)) && currentUserIntent === 'blockMenuOpen') {
|
|
121
|
-
var
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
121
|
+
var state = api === null || api === void 0 ? void 0 : api.blockControls.sharedState.currentState();
|
|
122
|
+
if (state !== null && state !== void 0 && state.isSelectedViaDragHandle && fg('platform_editor_toolbar_aifc_user_intent_fix')) {
|
|
123
|
+
var _api$userIntent4;
|
|
124
|
+
api === null || api === void 0 || (_api$userIntent4 = api.userIntent) === null || _api$userIntent4 === void 0 || _api$userIntent4.commands.setCurrentUserIntent('dragHandleSelected')({
|
|
125
|
+
tr: tr
|
|
126
|
+
});
|
|
127
|
+
} else {
|
|
128
|
+
var _api$userIntent5;
|
|
129
|
+
// Toggled from drag handle
|
|
130
|
+
api === null || api === void 0 || (_api$userIntent5 = api.userIntent) === null || _api$userIntent5 === void 0 || _api$userIntent5.commands.setCurrentUserIntent('default')({
|
|
131
|
+
tr: tr
|
|
132
|
+
});
|
|
133
|
+
}
|
|
126
134
|
}
|
|
127
135
|
return tr;
|
|
128
136
|
};
|
|
129
137
|
},
|
|
130
138
|
setNodeDragged: function setNodeDragged(getPos, anchorName, nodeType) {
|
|
131
139
|
return function (_ref5) {
|
|
132
|
-
var _api$
|
|
140
|
+
var _api$userIntent6;
|
|
133
141
|
var tr = _ref5.tr;
|
|
134
142
|
var pos = getPos();
|
|
135
143
|
if (pos === undefined) {
|
|
@@ -153,7 +161,7 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
|
153
161
|
tr: tr
|
|
154
162
|
});
|
|
155
163
|
}
|
|
156
|
-
api === null || api === void 0 || (_api$
|
|
164
|
+
api === null || api === void 0 || (_api$userIntent6 = api.userIntent) === null || _api$userIntent6 === void 0 || _api$userIntent6.commands.setCurrentUserIntent('dragging')({
|
|
157
165
|
tr: tr
|
|
158
166
|
});
|
|
159
167
|
return tr;
|
|
@@ -34,50 +34,37 @@ import { getPosWhenMoveNodeDown, getPosWhenMoveNodeUp } from './utils/move-node-
|
|
|
34
34
|
function transformSourceSlice(nodeCopy, destType) {
|
|
35
35
|
var srcNode = nodeCopy.content.firstChild;
|
|
36
36
|
var schema = srcNode === null || srcNode === void 0 ? void 0 : srcNode.type.schema;
|
|
37
|
-
if (
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
var destTypeInDocOrLayoutCol = [doc, layoutColumn].includes(destType);
|
|
37
|
+
if (!schema) {
|
|
38
|
+
return nodeCopy;
|
|
39
|
+
}
|
|
40
|
+
var _schema$nodes = schema.nodes,
|
|
41
|
+
doc = _schema$nodes.doc,
|
|
42
|
+
layoutColumn = _schema$nodes.layoutColumn;
|
|
43
|
+
var destTypeInTable = isInsideTable(destType);
|
|
44
|
+
var destTypeInDocOrLayoutCol = [doc, layoutColumn].includes(destType);
|
|
46
45
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
if (containsExpand && containsNestedExpand) {
|
|
61
|
-
break;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
if (containsExpand && destTypeInTable) {
|
|
65
|
-
return transformSliceExpandToNestedExpand(nodeCopy);
|
|
66
|
-
} else if (containsNestedExpand && destTypeInDocOrLayoutCol) {
|
|
67
|
-
return transformSliceNestedExpandToExpand(nodeCopy, schema);
|
|
46
|
+
// No need to loop over slice content if destination requires no transformations
|
|
47
|
+
if (!destTypeInTable && !destTypeInDocOrLayoutCol) {
|
|
48
|
+
return nodeCopy;
|
|
49
|
+
}
|
|
50
|
+
var containsExpand = false;
|
|
51
|
+
var containsNestedExpand = false;
|
|
52
|
+
for (var i = 0; i < nodeCopy.content.childCount; i++) {
|
|
53
|
+
var node = nodeCopy.content.child(i);
|
|
54
|
+
if (node.type === schema.nodes.expand) {
|
|
55
|
+
containsExpand = true;
|
|
56
|
+
} else if (node.type === schema.nodes.nestedExpand) {
|
|
57
|
+
containsNestedExpand = true;
|
|
68
58
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
var _schema$nodes2 = schema.nodes,
|
|
72
|
-
_doc = _schema$nodes2.doc,
|
|
73
|
-
_layoutColumn = _schema$nodes2.layoutColumn;
|
|
74
|
-
if (srcNode.type === schema.nodes.nestedExpand && [_doc, _layoutColumn].includes(destType)) {
|
|
75
|
-
return transformSliceNestedExpandToExpand(nodeCopy, schema);
|
|
76
|
-
} else if (srcNode.type === schema.nodes.expand && isInsideTable(destType)) {
|
|
77
|
-
return transformSliceExpandToNestedExpand(nodeCopy);
|
|
78
|
-
}
|
|
59
|
+
if (containsExpand && containsNestedExpand) {
|
|
60
|
+
break;
|
|
79
61
|
}
|
|
80
62
|
}
|
|
63
|
+
if (containsExpand && destTypeInTable) {
|
|
64
|
+
return transformSliceExpandToNestedExpand(nodeCopy);
|
|
65
|
+
} else if (containsNestedExpand && destTypeInDocOrLayoutCol) {
|
|
66
|
+
return transformSliceNestedExpandToExpand(nodeCopy, schema);
|
|
67
|
+
}
|
|
81
68
|
return nodeCopy;
|
|
82
69
|
}
|
|
83
70
|
var nodesSupportDragLayoutColumnInto = ['tableCell', 'tableHeader', 'panel', 'expand', 'nestedExpand'];
|
|
@@ -140,7 +127,7 @@ export var moveNodeViaShortcut = function moveNodeViaShortcut(api, direction, fo
|
|
|
140
127
|
var hoistedPos;
|
|
141
128
|
var from = Math.min(expandedAnchor, expandedHead);
|
|
142
129
|
// Nodes like lists nest within themselves, we need to find the top most position
|
|
143
|
-
if (isParentNodeOfTypeLayout
|
|
130
|
+
if (isParentNodeOfTypeLayout) {
|
|
144
131
|
var LAYOUT_COL_DEPTH = 3;
|
|
145
132
|
hoistedPos = state.doc.resolve(from).before(LAYOUT_COL_DEPTH);
|
|
146
133
|
}
|
|
@@ -282,15 +269,9 @@ export var moveNodeViaShortcut = function moveNodeViaShortcut(api, direction, fo
|
|
|
282
269
|
var _api$core7;
|
|
283
270
|
api === null || api === void 0 || (_api$core7 = api.core) === null || _api$core7 === void 0 || _api$core7.actions.execute(function (_ref4) {
|
|
284
271
|
var tr = _ref4.tr;
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
});
|
|
289
|
-
} else {
|
|
290
|
-
api === null || api === void 0 || api.blockControls.commands.setMultiSelectPositions(expandedAnchor, expandedHead)({
|
|
291
|
-
tr: tr
|
|
292
|
-
});
|
|
293
|
-
}
|
|
272
|
+
api === null || api === void 0 || api.blockControls.commands.setMultiSelectPositions($newAnchor.pos, $newHead.pos)({
|
|
273
|
+
tr: tr
|
|
274
|
+
});
|
|
294
275
|
moveNode(api)(currentNodePos, moveToPos, INPUT_METHOD.SHORTCUT, formatMessage)({
|
|
295
276
|
tr: tr
|
|
296
277
|
});
|
|
@@ -312,15 +293,9 @@ export var moveNodeViaShortcut = function moveNodeViaShortcut(api, direction, fo
|
|
|
312
293
|
var _api$core9;
|
|
313
294
|
api === null || api === void 0 || (_api$core9 = api.core) === null || _api$core9 === void 0 || _api$core9.actions.execute(function (_ref6) {
|
|
314
295
|
var tr = _ref6.tr;
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
});
|
|
319
|
-
} else {
|
|
320
|
-
api === null || api === void 0 || api.blockControls.commands.setMultiSelectPositions(expandedAnchor, expandedHead)({
|
|
321
|
-
tr: tr
|
|
322
|
-
});
|
|
323
|
-
}
|
|
296
|
+
api === null || api === void 0 || api.blockControls.commands.setMultiSelectPositions($newAnchor.pos, $newHead.pos)({
|
|
297
|
+
tr: tr
|
|
298
|
+
});
|
|
324
299
|
tr.scrollIntoView();
|
|
325
300
|
return tr;
|
|
326
301
|
});
|