@atlaskit/editor-plugin-block-controls 3.3.11 → 3.3.13
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/editor-commands/move-node.js +1 -3
- package/dist/cjs/editor-commands/move-to-layout.js +17 -63
- package/dist/cjs/pm-plugins/decorations-drop-target.js +1 -3
- package/dist/cjs/pm-plugins/handle-mouse-over.js +1 -1
- package/dist/cjs/pm-plugins/main.js +4 -2
- package/dist/cjs/pm-plugins/utils/drag-handle-positions.js +2 -7
- package/dist/cjs/ui/drag-handle.js +3 -7
- package/dist/cjs/ui/drag-preview.js +8 -19
- package/dist/cjs/ui/drop-target-layout.js +9 -15
- package/dist/cjs/ui/global-styles.js +1 -2
- package/dist/cjs/ui/inline-drop-target.js +9 -15
- package/dist/es2019/editor-commands/move-node.js +1 -3
- package/dist/es2019/editor-commands/move-to-layout.js +6 -54
- package/dist/es2019/pm-plugins/decorations-drop-target.js +1 -3
- package/dist/es2019/pm-plugins/handle-mouse-over.js +1 -1
- package/dist/es2019/pm-plugins/main.js +4 -2
- package/dist/es2019/pm-plugins/utils/drag-handle-positions.js +2 -7
- package/dist/es2019/ui/drag-handle.js +3 -7
- package/dist/es2019/ui/drag-preview.js +9 -20
- package/dist/es2019/ui/drop-target-layout.js +10 -16
- package/dist/es2019/ui/global-styles.js +1 -2
- package/dist/es2019/ui/inline-drop-target.js +10 -16
- package/dist/esm/editor-commands/move-node.js +1 -3
- package/dist/esm/editor-commands/move-to-layout.js +19 -65
- package/dist/esm/pm-plugins/decorations-drop-target.js +1 -3
- package/dist/esm/pm-plugins/handle-mouse-over.js +1 -1
- package/dist/esm/pm-plugins/main.js +4 -2
- package/dist/esm/pm-plugins/utils/drag-handle-positions.js +2 -7
- package/dist/esm/ui/drag-handle.js +3 -7
- package/dist/esm/ui/drag-preview.js +9 -20
- package/dist/esm/ui/drop-target-layout.js +9 -15
- package/dist/esm/ui/global-styles.js +1 -2
- package/dist/esm/ui/inline-drop-target.js +9 -15
- package/package.json +4 -10
|
@@ -1,21 +1,16 @@
|
|
|
1
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
1
|
import { DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT, DRAG_HANDLE_H1_TOP_ADJUSTMENT, DRAG_HANDLE_H2_TOP_ADJUSTMENT, DRAG_HANDLE_H4_TOP_ADJUSTMENT, DRAG_HANDLE_H5_TOP_ADJUSTMENT, DRAG_HANDLE_H6_TOP_ADJUSTMENT, DRAG_HANDLE_HEIGHT, DRAG_HANDLE_PARAGRAPH_TOP_ADJUSTMENT, DRAG_HANDLE_WIDTH, dragHandleGap } from '../../ui/consts';
|
|
3
2
|
export const getTopPosition = (dom, type) => {
|
|
4
3
|
if (!dom) {
|
|
5
4
|
return 'auto';
|
|
6
5
|
}
|
|
7
6
|
const table = dom.querySelector('table');
|
|
8
|
-
const isTable =
|
|
7
|
+
const isTable = table && (!type || type === 'table');
|
|
9
8
|
if (isTable) {
|
|
10
9
|
return `${dom.offsetTop + ((table === null || table === void 0 ? void 0 : table.offsetTop) || 0)}px`;
|
|
11
10
|
} else if (type === 'rule') {
|
|
12
11
|
return `${dom.offsetTop - DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT}px`;
|
|
13
12
|
} else if (type === 'layoutColumn') {
|
|
14
|
-
|
|
15
|
-
return `${-dom.offsetTop / 2}px`;
|
|
16
|
-
} else {
|
|
17
|
-
return `${-DRAG_HANDLE_WIDTH}px`;
|
|
18
|
-
}
|
|
13
|
+
return `${-dom.offsetTop / 2}px`;
|
|
19
14
|
} else if (type === 'heading-1') {
|
|
20
15
|
return `${dom.offsetTop + DRAG_HANDLE_H1_TOP_ADJUSTMENT}px`;
|
|
21
16
|
} else if (type === 'heading-2') {
|
|
@@ -148,9 +148,7 @@ export const DragHandle = ({
|
|
|
148
148
|
const selection = useSharedPluginStateSelector(api, 'selection.selection');
|
|
149
149
|
const isShiftDown = useSharedPluginStateSelector(api, 'blockControls.isShiftDown');
|
|
150
150
|
const isLayoutColumn = nodeType === 'layoutColumn';
|
|
151
|
-
const isMultiSelect = editorExperiment('platform_editor_element_drag_and_drop_multiselect', true
|
|
152
|
-
exposure: true
|
|
153
|
-
});
|
|
151
|
+
const isMultiSelect = editorExperiment('platform_editor_element_drag_and_drop_multiselect', true);
|
|
154
152
|
useEffect(() => {
|
|
155
153
|
// blockCard/datasource width is rendered correctly after this decoraton does. We need to observe for changes.
|
|
156
154
|
if (nodeType === 'blockCard') {
|
|
@@ -224,11 +222,9 @@ export const DragHandle = ({
|
|
|
224
222
|
// but ensures the preview is generated correctly.
|
|
225
223
|
const handleMouseDown = useCallback(() => {
|
|
226
224
|
if (editorExperiment('advanced_layouts', true)) {
|
|
225
|
+
var _buttonRef$current;
|
|
227
226
|
// prevent native drag and drop.
|
|
228
|
-
|
|
229
|
-
var _buttonRef$current;
|
|
230
|
-
(_buttonRef$current = buttonRef.current) === null || _buttonRef$current === void 0 ? void 0 : _buttonRef$current.focus();
|
|
231
|
-
}
|
|
227
|
+
(_buttonRef$current = buttonRef.current) === null || _buttonRef$current === void 0 ? void 0 : _buttonRef$current.focus();
|
|
232
228
|
if (!isLayoutColumn) {
|
|
233
229
|
return undefined;
|
|
234
230
|
}
|
|
@@ -1,29 +1,19 @@
|
|
|
1
1
|
import { browser } from '@atlaskit/editor-common/browser';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
const previewStyleNew = {
|
|
2
|
+
import { N20, N30 } from '@atlaskit/theme/colors';
|
|
3
|
+
const previewStyle = {
|
|
5
4
|
borderColor: `var(--ds-border, ${N30})`,
|
|
6
5
|
borderStyle: 'solid',
|
|
7
6
|
borderRadius: "var(--ds-border-radius-100, 3px)",
|
|
8
7
|
borderWidth: "var(--ds-border-width-outline, 2px)",
|
|
9
8
|
backgroundColor: `var(--ds-skeleton-subtle, ${N20})`
|
|
10
9
|
};
|
|
11
|
-
const previewStyleOld = {
|
|
12
|
-
borderColor: `var(--ds-border-focused, ${B200})`,
|
|
13
|
-
borderStyle: 'solid',
|
|
14
|
-
borderRadius: "var(--ds-border-radius-100, 3px)",
|
|
15
|
-
borderWidth: "var(--ds-border-width-outline, 2px)",
|
|
16
|
-
backgroundColor: "var(--ds-blanket-selected, #388BFF14)"
|
|
17
|
-
};
|
|
18
10
|
const getPreviewContainerDimensionsForSingle = (dom, nodeType) => {
|
|
19
11
|
let nodeContainer = dom;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
nodeContainer = iframeContainer;
|
|
26
|
-
}
|
|
12
|
+
const iframeContainer = dom.querySelector('iframe');
|
|
13
|
+
if (nodeType === 'embedCard') {
|
|
14
|
+
nodeContainer = dom.querySelector('.rich-media-item') || dom;
|
|
15
|
+
} else if (nodeType === 'extension' && iframeContainer) {
|
|
16
|
+
nodeContainer = iframeContainer;
|
|
27
17
|
}
|
|
28
18
|
const nodeContainerRect = nodeContainer.getBoundingClientRect();
|
|
29
19
|
return {
|
|
@@ -54,7 +44,6 @@ const createGenericPreview = () => {
|
|
|
54
44
|
const generalPreview = document.createElement('div');
|
|
55
45
|
// ProseMirror class is required to make sure the cloned dom is styled correctly
|
|
56
46
|
generalPreview.classList.add('ProseMirror', 'block-ctrl-drag-preview');
|
|
57
|
-
const previewStyle = fg('platform_editor_elements_drag_and_drop_ed_23189') ? previewStyleNew : previewStyleOld;
|
|
58
47
|
generalPreview.style.border = `${previewStyle.borderWidth} ${previewStyle.borderStyle} ${previewStyle.borderColor}`;
|
|
59
48
|
generalPreview.style.borderRadius = previewStyle.borderRadius;
|
|
60
49
|
generalPreview.style.backgroundColor = previewStyle.backgroundColor;
|
|
@@ -78,13 +67,13 @@ const createContentPreviewElement = (dom, nodeType, nodeSpacing) => {
|
|
|
78
67
|
clonedDom.style.marginRight = '0';
|
|
79
68
|
clonedDom.style.marginBottom = nodeSpacing ? `${nodeSpacing.bottom}` : '0';
|
|
80
69
|
clonedDom.style.boxShadow = 'none';
|
|
81
|
-
clonedDom.style.opacity = browser.windows ? '1' :
|
|
70
|
+
clonedDom.style.opacity = browser.windows ? '1' : '0.31';
|
|
82
71
|
contentPreviewOneElement.appendChild(clonedDom);
|
|
83
72
|
return contentPreviewOneElement;
|
|
84
73
|
};
|
|
85
74
|
const isGenericPreview = (dom, nodeType) => {
|
|
86
75
|
const embedCard = dom.querySelector('.embedCardView-content-wrap');
|
|
87
|
-
return
|
|
76
|
+
return nodeType === 'embedCard' || !!embedCard || nodeType === 'extension' && !!dom.querySelector('iframe');
|
|
88
77
|
};
|
|
89
78
|
const createPreviewForElement = (dom, nodeType, nodeSpacing) => {
|
|
90
79
|
const shouldBeGenericPreview = isGenericPreview(dom, nodeType);
|
|
@@ -7,7 +7,6 @@ import { useCallback, useEffect, useRef, useState } from 'react';
|
|
|
7
7
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled
|
|
8
8
|
import { css, jsx } from '@emotion/react';
|
|
9
9
|
import { layoutBreakpointWidth } from '@atlaskit/editor-shared-styles';
|
|
10
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
10
|
import { DropIndicator } from '@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box';
|
|
12
11
|
import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
13
12
|
import { B200 } from '@atlaskit/theme/colors';
|
|
@@ -73,7 +72,7 @@ export const DropTargetLayout = props => {
|
|
|
73
72
|
const to = getPos();
|
|
74
73
|
let mappedTo;
|
|
75
74
|
if (to !== undefined) {
|
|
76
|
-
var _api$core;
|
|
75
|
+
var _api$core, _api$core2;
|
|
77
76
|
const {
|
|
78
77
|
pos: from
|
|
79
78
|
} = activeNode;
|
|
@@ -84,23 +83,18 @@ export const DropTargetLayout = props => {
|
|
|
84
83
|
api === null || api === void 0 ? void 0 : (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : (_api$blockControls2$c = _api$blockControls2.commands) === null || _api$blockControls2$c === void 0 ? void 0 : _api$blockControls2$c.moveToLayout(from, to)({
|
|
85
84
|
tr
|
|
86
85
|
});
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
const insertColumnStep = getInsertLayoutStep(tr);
|
|
87
|
+
mappedTo = insertColumnStep === null || insertColumnStep === void 0 ? void 0 : insertColumnStep.from;
|
|
88
|
+
return tr;
|
|
89
|
+
});
|
|
90
|
+
api === null || api === void 0 ? void 0 : (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions.execute(({
|
|
91
|
+
tr
|
|
92
|
+
}) => {
|
|
93
|
+
if (mappedTo !== undefined) {
|
|
94
|
+
updateSelection(tr, mappedTo);
|
|
90
95
|
}
|
|
91
96
|
return tr;
|
|
92
97
|
});
|
|
93
|
-
if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
94
|
-
var _api$core2;
|
|
95
|
-
api === null || api === void 0 ? void 0 : (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions.execute(({
|
|
96
|
-
tr
|
|
97
|
-
}) => {
|
|
98
|
-
if (mappedTo !== undefined) {
|
|
99
|
-
updateSelection(tr, mappedTo);
|
|
100
|
-
}
|
|
101
|
-
return tr;
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
98
|
}
|
|
105
99
|
}, [api, getPos, activeNode]);
|
|
106
100
|
useEffect(() => {
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles, @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
6
6
|
import { css, Global, jsx } from '@emotion/react';
|
|
7
7
|
import { akEditorBreakoutPadding, akEditorCalculatedWideLayoutWidth, akEditorCalculatedWideLayoutWidthSmallViewport } from '@atlaskit/editor-shared-styles';
|
|
8
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
8
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
10
9
|
import { DRAG_HANDLE_MAX_WIDTH_PLUS_GAP, DRAG_HANDLE_WIDTH } from './consts';
|
|
11
10
|
|
|
@@ -260,6 +259,6 @@ const blockCardWithoutLayout = css({
|
|
|
260
259
|
});
|
|
261
260
|
export const GlobalStylesWrapper = () => {
|
|
262
261
|
return jsx(Global, {
|
|
263
|
-
styles: [globalStyles(),
|
|
262
|
+
styles: [globalStyles(), globalDnDStyle, editorExperiment('nested-dnd', true) ? extendedHoverZoneNested() : extendedHoverZone(), withInlineNodeStyle, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, withRelativePosStyle, topLevelNodeMarginStyles, editorExperiment('nested-dnd', true) ? withAnchorNameZindexNestedStyle : withAnchorNameZindexStyle,,]
|
|
264
263
|
});
|
|
265
264
|
};
|
|
@@ -9,7 +9,6 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
|
9
9
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled
|
|
10
10
|
import { css, jsx } from '@emotion/react';
|
|
11
11
|
import { akEditorBreakoutPadding } from '@atlaskit/editor-shared-styles';
|
|
12
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
13
12
|
import { DropIndicator } from '@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box';
|
|
14
13
|
import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
15
14
|
import { B200 } from '@atlaskit/theme/colors';
|
|
@@ -178,7 +177,7 @@ export const InlineDropTarget = ({
|
|
|
178
177
|
const toPos = getPos();
|
|
179
178
|
let mappedTo;
|
|
180
179
|
if (activeNode && toPos !== undefined) {
|
|
181
|
-
var _api$core;
|
|
180
|
+
var _api$core, _api$core2;
|
|
182
181
|
const {
|
|
183
182
|
pos: start
|
|
184
183
|
} = activeNode;
|
|
@@ -192,23 +191,18 @@ export const InlineDropTarget = ({
|
|
|
192
191
|
})({
|
|
193
192
|
tr
|
|
194
193
|
});
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
194
|
+
const insertLayoutStep = getInsertLayoutStep(tr);
|
|
195
|
+
mappedTo = insertLayoutStep === null || insertLayoutStep === void 0 ? void 0 : insertLayoutStep.from;
|
|
196
|
+
return tr;
|
|
197
|
+
});
|
|
198
|
+
api === null || api === void 0 ? void 0 : (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions.execute(({
|
|
199
|
+
tr
|
|
200
|
+
}) => {
|
|
201
|
+
if (mappedTo !== undefined) {
|
|
202
|
+
updateSelection(tr, mappedTo, moveToEnd);
|
|
198
203
|
}
|
|
199
204
|
return tr;
|
|
200
205
|
});
|
|
201
|
-
if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
202
|
-
var _api$core2;
|
|
203
|
-
api === null || api === void 0 ? void 0 : (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions.execute(({
|
|
204
|
-
tr
|
|
205
|
-
}) => {
|
|
206
|
-
if (mappedTo !== undefined) {
|
|
207
|
-
updateSelection(tr, mappedTo, moveToEnd);
|
|
208
|
-
}
|
|
209
|
-
return tr;
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
206
|
}
|
|
213
207
|
}, [api, getPos, position]);
|
|
214
208
|
const hoverZoneRectStyle = useMemo(() => {
|
|
@@ -341,9 +341,7 @@ export var moveNode = function moveNode(api) {
|
|
|
341
341
|
var sliceTo;
|
|
342
342
|
var mappedTo;
|
|
343
343
|
var sourceNodeTypes, hasSelectedMultipleNodes;
|
|
344
|
-
var isMultiSelect = editorExperiment('platform_editor_element_drag_and_drop_multiselect', true
|
|
345
|
-
exposure: true
|
|
346
|
-
});
|
|
344
|
+
var isMultiSelect = editorExperiment('platform_editor_element_drag_and_drop_multiselect', true);
|
|
347
345
|
if (fg('platform_editor_ease_of_use_metrics')) {
|
|
348
346
|
var _api$metrics;
|
|
349
347
|
api === null || api === void 0 || (_api$metrics = api.metrics) === null || _api$metrics === void 0 || _api$metrics.commands.setContentMoved()({
|
|
@@ -4,12 +4,11 @@ import { Fragment, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
|
4
4
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
5
5
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
6
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { attachMoveNodeAnalytics, fireInsertLayoutAnalytics, getMultiSelectAnalyticsAttributes } from '../pm-plugins/utils/analytics';
|
|
8
|
+
import { containsNodeOfType, isFragmentOfType } from '../pm-plugins/utils/check-fragment';
|
|
9
9
|
import { maxLayoutColumnSupported } from '../pm-plugins/utils/consts';
|
|
10
10
|
import { removeFromSource } from '../pm-plugins/utils/remove-from-source';
|
|
11
11
|
import { getMultiSelectionIfPosInside } from '../pm-plugins/utils/selection';
|
|
12
|
-
import { updateColumnWidths } from '../pm-plugins/utils/update-column-widths';
|
|
13
12
|
import { isInSameLayout } from '../pm-plugins/utils/validation';
|
|
14
13
|
import { DEFAULT_COLUMN_DISTRIBUTIONS } from '../ui/consts';
|
|
15
14
|
var createNewLayout = function createNewLayout(schema, layoutContents) {
|
|
@@ -64,20 +63,14 @@ var moveToExistingLayout = function moveToExistingLayout(toLayout, toLayoutPos,
|
|
|
64
63
|
tr.delete(from, sourceContentEndPos);
|
|
65
64
|
var mappedTo = tr.mapping.map(to);
|
|
66
65
|
tr.insert(mappedTo, sourceContent);
|
|
67
|
-
if (
|
|
66
|
+
if (selectMovedNode) {
|
|
68
67
|
tr.setSelection(new NodeSelection(tr.doc.resolve(mappedTo))).scrollIntoView();
|
|
69
68
|
}
|
|
70
69
|
attachMoveNodeAnalytics(tr, INPUT_METHOD.DRAG_AND_DROP, $originalFrom.depth, ((_$originalFrom$nodeAf = $originalFrom.nodeAfter) === null || _$originalFrom$nodeAf === void 0 ? void 0 : _$originalFrom$nodeAf.type.name) || '', 1, 'layoutSection', true, api, sourceNodeTypes, hasSelectedMultipleNodes);
|
|
71
70
|
} else if (toLayout.childCount < maxLayoutColumnSupported()) {
|
|
72
71
|
var _$originalFrom$nodeAf2;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
insertToDestinationNoWidthUpdate(tr, tr.mapping.map(to), sourceContent);
|
|
76
|
-
} else {
|
|
77
|
-
insertToDestination(tr, to, sourceContent, toLayout, toLayoutPos);
|
|
78
|
-
var mappedFrom = tr.mapping.map(from);
|
|
79
|
-
removeFromSource(tr, tr.doc.resolve(mappedFrom), tr.mapping.map(sourceContentEndPos));
|
|
80
|
-
}
|
|
72
|
+
removeFromSource(tr, tr.doc.resolve(from), sourceContentEndPos);
|
|
73
|
+
insertToDestinationNoWidthUpdate(tr, tr.mapping.map(to), sourceContent);
|
|
81
74
|
attachMoveNodeAnalytics(tr, INPUT_METHOD.DRAG_AND_DROP, $originalFrom.depth, ((_$originalFrom$nodeAf2 = $originalFrom.nodeAfter) === null || _$originalFrom$nodeAf2 === void 0 ? void 0 : _$originalFrom$nodeAf2.type.name) || '', 1, 'layoutSection', false, api, sourceNodeTypes, hasSelectedMultipleNodes);
|
|
82
75
|
}
|
|
83
76
|
return tr;
|
|
@@ -122,40 +115,6 @@ var insertToDestinationNoWidthUpdate = function insertToDestinationNoWidthUpdate
|
|
|
122
115
|
}
|
|
123
116
|
return tr;
|
|
124
117
|
};
|
|
125
|
-
var insertToDestination = function insertToDestination(tr, to, sourceContent, toLayout, toLayoutPos) {
|
|
126
|
-
var _ref3 = updateColumnWidths(tr, toLayout, toLayoutPos, toLayout.childCount + 1) || {},
|
|
127
|
-
newColumnWidth = _ref3.newColumnWidth;
|
|
128
|
-
var _ref4 = tr.doc.type.schema.nodes || {},
|
|
129
|
-
layoutColumn = _ref4.layoutColumn;
|
|
130
|
-
var content = null;
|
|
131
|
-
try {
|
|
132
|
-
if (editorExperiment('platform_editor_element_drag_and_drop_multiselect', true)) {
|
|
133
|
-
if (sourceContent instanceof Fragment) {
|
|
134
|
-
var _sourceContent$firstC;
|
|
135
|
-
content = layoutColumn.createChecked({
|
|
136
|
-
width: newColumnWidth
|
|
137
|
-
}, isFragmentOfType(sourceContent, 'layoutColumn') ? (_sourceContent$firstC = sourceContent.firstChild) === null || _sourceContent$firstC === void 0 ? void 0 : _sourceContent$firstC.content : sourceContent);
|
|
138
|
-
}
|
|
139
|
-
} else {
|
|
140
|
-
if (sourceContent instanceof PMNode) {
|
|
141
|
-
content = layoutColumn.createChecked({
|
|
142
|
-
width: newColumnWidth
|
|
143
|
-
}, sourceContent.type.name === 'layoutColumn' ? sourceContent.content : sourceContent);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
} catch (error) {
|
|
147
|
-
logException(error, {
|
|
148
|
-
location: 'editor-plugin-block-controls/move-to-layout'
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
if (content) {
|
|
152
|
-
tr.insert(to, content);
|
|
153
|
-
}
|
|
154
|
-
if (!fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
155
|
-
tr.setSelection(new NodeSelection(tr.doc.resolve(to))).scrollIntoView();
|
|
156
|
-
}
|
|
157
|
-
return tr;
|
|
158
|
-
};
|
|
159
118
|
|
|
160
119
|
/**
|
|
161
120
|
* Check if the node at `from` can be moved to node at `to` to create/expand a layout.
|
|
@@ -165,10 +124,10 @@ var canMoveToLayout = function canMoveToLayout(api, from, to, tr, moveNodeAtCurs
|
|
|
165
124
|
if (from === to) {
|
|
166
125
|
return;
|
|
167
126
|
}
|
|
168
|
-
var
|
|
169
|
-
layoutSection =
|
|
170
|
-
layoutColumn =
|
|
171
|
-
doc =
|
|
127
|
+
var _ref3 = tr.doc.type.schema.nodes || {},
|
|
128
|
+
layoutSection = _ref3.layoutSection,
|
|
129
|
+
layoutColumn = _ref3.layoutColumn,
|
|
130
|
+
doc = _ref3.doc;
|
|
172
131
|
|
|
173
132
|
// layout plugin does not exist
|
|
174
133
|
if (!layoutSection || !layoutColumn) {
|
|
@@ -181,9 +140,7 @@ var canMoveToLayout = function canMoveToLayout(api, from, to, tr, moveNodeAtCurs
|
|
|
181
140
|
return;
|
|
182
141
|
}
|
|
183
142
|
var $from = tr.doc.resolve(from);
|
|
184
|
-
var isMultiSelect = editorExperiment('platform_editor_element_drag_and_drop_multiselect', true
|
|
185
|
-
exposure: true
|
|
186
|
-
});
|
|
143
|
+
var isMultiSelect = editorExperiment('platform_editor_element_drag_and_drop_multiselect', true);
|
|
187
144
|
|
|
188
145
|
// invalid from position or dragging a layout
|
|
189
146
|
if (!$from.nodeAfter || $from.nodeAfter.type === layoutSection) {
|
|
@@ -220,8 +177,8 @@ var canMoveToLayout = function canMoveToLayout(api, from, to, tr, moveNodeAtCurs
|
|
|
220
177
|
};
|
|
221
178
|
var removeBreakoutMarks = function removeBreakoutMarks(tr, $from, to) {
|
|
222
179
|
var fromContentWithoutBreakout = $from.nodeAfter;
|
|
223
|
-
var
|
|
224
|
-
breakout =
|
|
180
|
+
var _ref4 = tr.doc.type.schema.marks || {},
|
|
181
|
+
breakout = _ref4.breakout;
|
|
225
182
|
if (editorExperiment('platform_editor_element_drag_and_drop_multiselect', true)) {
|
|
226
183
|
tr.doc.nodesBetween($from.pos, to, function (node, pos, parent) {
|
|
227
184
|
// breakout doesn't exist on nested nodes
|
|
@@ -284,8 +241,8 @@ var getBreakoutMode = function getBreakoutMode(content, breakout) {
|
|
|
284
241
|
// source content variable that has type of `PMNode | Fragment` should be updated to `Fragment` only
|
|
285
242
|
export var moveToLayout = function moveToLayout(api) {
|
|
286
243
|
return function (from, to, options) {
|
|
287
|
-
return function (
|
|
288
|
-
var tr =
|
|
244
|
+
return function (_ref5) {
|
|
245
|
+
var tr = _ref5.tr;
|
|
289
246
|
if (!api) {
|
|
290
247
|
return tr;
|
|
291
248
|
}
|
|
@@ -298,11 +255,11 @@ export var moveToLayout = function moveToLayout(api) {
|
|
|
298
255
|
sourceContent = canMove.sourceContent,
|
|
299
256
|
$sourceFrom = canMove.$sourceFrom,
|
|
300
257
|
sourceTo = canMove.sourceTo;
|
|
301
|
-
var
|
|
302
|
-
layoutSection =
|
|
303
|
-
layoutColumn =
|
|
304
|
-
var
|
|
305
|
-
breakout =
|
|
258
|
+
var _ref6 = tr.doc.type.schema.nodes || {},
|
|
259
|
+
layoutSection = _ref6.layoutSection,
|
|
260
|
+
layoutColumn = _ref6.layoutColumn;
|
|
261
|
+
var _ref7 = tr.doc.type.schema.marks || {},
|
|
262
|
+
breakout = _ref7.breakout;
|
|
306
263
|
|
|
307
264
|
// get breakout mode from destination node,
|
|
308
265
|
// if not found, get from source node,
|
|
@@ -360,9 +317,6 @@ export var moveToLayout = function moveToLayout(api) {
|
|
|
360
317
|
tr = removeFromSource(tr, $sourceFrom, sourceTo);
|
|
361
318
|
var mappedTo = tr.mapping.map(to);
|
|
362
319
|
tr.delete(mappedTo, mappedTo + toNodeWithoutBreakout.nodeSize).insert(mappedTo, newLayout);
|
|
363
|
-
if (!fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
364
|
-
tr.setSelection(new NodeSelection(tr.doc.resolve(mappedTo))).scrollIntoView();
|
|
365
|
-
}
|
|
366
320
|
breakoutMode && tr.setNodeMarkup(mappedTo, newLayout.type, newLayout.attrs, [breakout.create({
|
|
367
321
|
mode: breakoutMode
|
|
368
322
|
})]);
|
|
@@ -142,9 +142,7 @@ export var dropTargetDecorations = function dropTargetDecorations(newState, api,
|
|
|
142
142
|
var activeNodePos = activeNode === null || activeNode === void 0 ? void 0 : activeNode.pos;
|
|
143
143
|
var $activeNodePos = typeof activeNodePos === 'number' && newState.doc.resolve(activeNodePos);
|
|
144
144
|
var activePMNode = $activeNodePos && $activeNodePos.nodeAfter;
|
|
145
|
-
var isMultiSelect = editorExperiment('platform_editor_element_drag_and_drop_multiselect', true
|
|
146
|
-
exposure: true
|
|
147
|
-
});
|
|
145
|
+
var isMultiSelect = editorExperiment('platform_editor_element_drag_and_drop_multiselect', true);
|
|
148
146
|
anchorRectCache === null || anchorRectCache === void 0 || anchorRectCache.clear();
|
|
149
147
|
var prevNodeStack = [];
|
|
150
148
|
var popNodeStack = function popNodeStack(depth) {
|
|
@@ -40,7 +40,7 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
|
|
|
40
40
|
}
|
|
41
41
|
var parentElement = (_rootElement$parentEl = rootElement.parentElement) === null || _rootElement$parentEl === void 0 ? void 0 : _rootElement$parentEl.closest('[data-drag-handler-anchor-name]');
|
|
42
42
|
var parentElementType = parentElement === null || parentElement === void 0 ? void 0 : parentElement.getAttribute('data-drag-handler-node-type');
|
|
43
|
-
if (editorExperiment('advanced_layouts', true)
|
|
43
|
+
if (editorExperiment('advanced_layouts', true)) {
|
|
44
44
|
// We want to exclude handles from showing for direct descendant of table nodes (i.e. nodes in cells)
|
|
45
45
|
if (parentElement && (parentElementType === 'table' || parentElementType === 'tableRow') && editorExperiment('nested-dnd', true)) {
|
|
46
46
|
rootElement = parentElement;
|
|
@@ -573,7 +573,9 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
573
573
|
var isAdvancedLayoutEnabled = editorExperiment('advanced_layouts', true, {
|
|
574
574
|
exposure: true
|
|
575
575
|
});
|
|
576
|
-
var isMultiSelectEnabled = editorExperiment('platform_editor_element_drag_and_drop_multiselect', true
|
|
576
|
+
var isMultiSelectEnabled = editorExperiment('platform_editor_element_drag_and_drop_multiselect', true, {
|
|
577
|
+
exposure: true
|
|
578
|
+
});
|
|
577
579
|
var flags = {
|
|
578
580
|
isNestedEnabled: isNestedEnabled,
|
|
579
581
|
isMultiSelectEnabled: isMultiSelectEnabled
|
|
@@ -633,7 +635,7 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
633
635
|
// Currently we can only drag one node at a time
|
|
634
636
|
// so we only need to check first child
|
|
635
637
|
var draggable = dragging === null || dragging === void 0 ? void 0 : dragging.slice.content.firstChild;
|
|
636
|
-
if (dndDragCancelled && isMultiSelectEnabled || (draggable === null || draggable === void 0 ? void 0 : draggable.type.name) === 'layoutColumn'
|
|
638
|
+
if (dndDragCancelled && isMultiSelectEnabled || (draggable === null || draggable === void 0 ? void 0 : draggable.type.name) === 'layoutColumn') {
|
|
637
639
|
// we prevent native DnD for layoutColumn to prevent single column layout.
|
|
638
640
|
event.preventDefault();
|
|
639
641
|
return false;
|
|
@@ -1,21 +1,16 @@
|
|
|
1
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
1
|
import { DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT, DRAG_HANDLE_H1_TOP_ADJUSTMENT, DRAG_HANDLE_H2_TOP_ADJUSTMENT, DRAG_HANDLE_H4_TOP_ADJUSTMENT, DRAG_HANDLE_H5_TOP_ADJUSTMENT, DRAG_HANDLE_H6_TOP_ADJUSTMENT, DRAG_HANDLE_HEIGHT, DRAG_HANDLE_PARAGRAPH_TOP_ADJUSTMENT, DRAG_HANDLE_WIDTH, dragHandleGap } from '../../ui/consts';
|
|
3
2
|
export var getTopPosition = function getTopPosition(dom, type) {
|
|
4
3
|
if (!dom) {
|
|
5
4
|
return 'auto';
|
|
6
5
|
}
|
|
7
6
|
var table = dom.querySelector('table');
|
|
8
|
-
var isTable =
|
|
7
|
+
var isTable = table && (!type || type === 'table');
|
|
9
8
|
if (isTable) {
|
|
10
9
|
return "".concat(dom.offsetTop + ((table === null || table === void 0 ? void 0 : table.offsetTop) || 0), "px");
|
|
11
10
|
} else if (type === 'rule') {
|
|
12
11
|
return "".concat(dom.offsetTop - DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT, "px");
|
|
13
12
|
} else if (type === 'layoutColumn') {
|
|
14
|
-
|
|
15
|
-
return "".concat(-dom.offsetTop / 2, "px");
|
|
16
|
-
} else {
|
|
17
|
-
return "".concat(-DRAG_HANDLE_WIDTH, "px");
|
|
18
|
-
}
|
|
13
|
+
return "".concat(-dom.offsetTop / 2, "px");
|
|
19
14
|
} else if (type === 'heading-1') {
|
|
20
15
|
return "".concat(dom.offsetTop + DRAG_HANDLE_H1_TOP_ADJUSTMENT, "px");
|
|
21
16
|
} else if (type === 'heading-2') {
|
|
@@ -161,9 +161,7 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
161
161
|
var selection = useSharedPluginStateSelector(api, 'selection.selection');
|
|
162
162
|
var isShiftDown = useSharedPluginStateSelector(api, 'blockControls.isShiftDown');
|
|
163
163
|
var isLayoutColumn = nodeType === 'layoutColumn';
|
|
164
|
-
var isMultiSelect = editorExperiment('platform_editor_element_drag_and_drop_multiselect', true
|
|
165
|
-
exposure: true
|
|
166
|
-
});
|
|
164
|
+
var isMultiSelect = editorExperiment('platform_editor_element_drag_and_drop_multiselect', true);
|
|
167
165
|
useEffect(function () {
|
|
168
166
|
// blockCard/datasource width is rendered correctly after this decoraton does. We need to observe for changes.
|
|
169
167
|
if (nodeType === 'blockCard') {
|
|
@@ -238,11 +236,9 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
238
236
|
// but ensures the preview is generated correctly.
|
|
239
237
|
var handleMouseDown = useCallback(function () {
|
|
240
238
|
if (editorExperiment('advanced_layouts', true)) {
|
|
239
|
+
var _buttonRef$current;
|
|
241
240
|
// prevent native drag and drop.
|
|
242
|
-
|
|
243
|
-
var _buttonRef$current;
|
|
244
|
-
(_buttonRef$current = buttonRef.current) === null || _buttonRef$current === void 0 || _buttonRef$current.focus();
|
|
245
|
-
}
|
|
241
|
+
(_buttonRef$current = buttonRef.current) === null || _buttonRef$current === void 0 || _buttonRef$current.focus();
|
|
246
242
|
if (!isLayoutColumn) {
|
|
247
243
|
return undefined;
|
|
248
244
|
}
|
|
@@ -1,30 +1,20 @@
|
|
|
1
1
|
import _typeof from "@babel/runtime/helpers/typeof";
|
|
2
2
|
import { browser } from '@atlaskit/editor-common/browser';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
var previewStyleNew = {
|
|
3
|
+
import { N20, N30 } from '@atlaskit/theme/colors';
|
|
4
|
+
var previewStyle = {
|
|
6
5
|
borderColor: "var(--ds-border, ".concat(N30, ")"),
|
|
7
6
|
borderStyle: 'solid',
|
|
8
7
|
borderRadius: "var(--ds-border-radius-100, 3px)",
|
|
9
8
|
borderWidth: "var(--ds-border-width-outline, 2px)",
|
|
10
9
|
backgroundColor: "var(--ds-skeleton-subtle, ".concat(N20, ")")
|
|
11
10
|
};
|
|
12
|
-
var previewStyleOld = {
|
|
13
|
-
borderColor: "var(--ds-border-focused, ".concat(B200, ")"),
|
|
14
|
-
borderStyle: 'solid',
|
|
15
|
-
borderRadius: "var(--ds-border-radius-100, 3px)",
|
|
16
|
-
borderWidth: "var(--ds-border-width-outline, 2px)",
|
|
17
|
-
backgroundColor: "var(--ds-blanket-selected, #388BFF14)"
|
|
18
|
-
};
|
|
19
11
|
var getPreviewContainerDimensionsForSingle = function getPreviewContainerDimensionsForSingle(dom, nodeType) {
|
|
20
12
|
var nodeContainer = dom;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
nodeContainer = iframeContainer;
|
|
27
|
-
}
|
|
13
|
+
var iframeContainer = dom.querySelector('iframe');
|
|
14
|
+
if (nodeType === 'embedCard') {
|
|
15
|
+
nodeContainer = dom.querySelector('.rich-media-item') || dom;
|
|
16
|
+
} else if (nodeType === 'extension' && iframeContainer) {
|
|
17
|
+
nodeContainer = iframeContainer;
|
|
28
18
|
}
|
|
29
19
|
var nodeContainerRect = nodeContainer.getBoundingClientRect();
|
|
30
20
|
return {
|
|
@@ -54,7 +44,6 @@ var createGenericPreview = function createGenericPreview() {
|
|
|
54
44
|
var generalPreview = document.createElement('div');
|
|
55
45
|
// ProseMirror class is required to make sure the cloned dom is styled correctly
|
|
56
46
|
generalPreview.classList.add('ProseMirror', 'block-ctrl-drag-preview');
|
|
57
|
-
var previewStyle = fg('platform_editor_elements_drag_and_drop_ed_23189') ? previewStyleNew : previewStyleOld;
|
|
58
47
|
generalPreview.style.border = "".concat(previewStyle.borderWidth, " ").concat(previewStyle.borderStyle, " ").concat(previewStyle.borderColor);
|
|
59
48
|
generalPreview.style.borderRadius = previewStyle.borderRadius;
|
|
60
49
|
generalPreview.style.backgroundColor = previewStyle.backgroundColor;
|
|
@@ -78,13 +67,13 @@ var createContentPreviewElement = function createContentPreviewElement(dom, node
|
|
|
78
67
|
clonedDom.style.marginRight = '0';
|
|
79
68
|
clonedDom.style.marginBottom = nodeSpacing ? "".concat(nodeSpacing.bottom) : '0';
|
|
80
69
|
clonedDom.style.boxShadow = 'none';
|
|
81
|
-
clonedDom.style.opacity = browser.windows ? '1' :
|
|
70
|
+
clonedDom.style.opacity = browser.windows ? '1' : '0.31';
|
|
82
71
|
contentPreviewOneElement.appendChild(clonedDom);
|
|
83
72
|
return contentPreviewOneElement;
|
|
84
73
|
};
|
|
85
74
|
var isGenericPreview = function isGenericPreview(dom, nodeType) {
|
|
86
75
|
var embedCard = dom.querySelector('.embedCardView-content-wrap');
|
|
87
|
-
return
|
|
76
|
+
return nodeType === 'embedCard' || !!embedCard || nodeType === 'extension' && !!dom.querySelector('iframe');
|
|
88
77
|
};
|
|
89
78
|
var createPreviewForElement = function createPreviewForElement(dom, nodeType, nodeSpacing) {
|
|
90
79
|
var shouldBeGenericPreview = isGenericPreview(dom, nodeType);
|
|
@@ -9,7 +9,6 @@ import { useCallback, useEffect, useRef, useState } from 'react';
|
|
|
9
9
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled
|
|
10
10
|
import { css, jsx } from '@emotion/react';
|
|
11
11
|
import { layoutBreakpointWidth } from '@atlaskit/editor-shared-styles';
|
|
12
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
13
12
|
import { DropIndicator } from '@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box';
|
|
14
13
|
import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
15
14
|
import { B200 } from '@atlaskit/theme/colors';
|
|
@@ -74,7 +73,7 @@ export var DropTargetLayout = function DropTargetLayout(props) {
|
|
|
74
73
|
var to = getPos();
|
|
75
74
|
var mappedTo;
|
|
76
75
|
if (to !== undefined) {
|
|
77
|
-
var _api$core;
|
|
76
|
+
var _api$core, _api$core2;
|
|
78
77
|
var from = activeNode.pos;
|
|
79
78
|
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref2) {
|
|
80
79
|
var _api$blockControls2;
|
|
@@ -82,22 +81,17 @@ export var DropTargetLayout = function DropTargetLayout(props) {
|
|
|
82
81
|
api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || (_api$blockControls2 = _api$blockControls2.commands) === null || _api$blockControls2 === void 0 || _api$blockControls2.moveToLayout(from, to)({
|
|
83
82
|
tr: tr
|
|
84
83
|
});
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
84
|
+
var insertColumnStep = getInsertLayoutStep(tr);
|
|
85
|
+
mappedTo = insertColumnStep === null || insertColumnStep === void 0 ? void 0 : insertColumnStep.from;
|
|
86
|
+
return tr;
|
|
87
|
+
});
|
|
88
|
+
api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(function (_ref3) {
|
|
89
|
+
var tr = _ref3.tr;
|
|
90
|
+
if (mappedTo !== undefined) {
|
|
91
|
+
updateSelection(tr, mappedTo);
|
|
88
92
|
}
|
|
89
93
|
return tr;
|
|
90
94
|
});
|
|
91
|
-
if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
92
|
-
var _api$core2;
|
|
93
|
-
api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(function (_ref3) {
|
|
94
|
-
var tr = _ref3.tr;
|
|
95
|
-
if (mappedTo !== undefined) {
|
|
96
|
-
updateSelection(tr, mappedTo);
|
|
97
|
-
}
|
|
98
|
-
return tr;
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
95
|
}
|
|
102
96
|
}, [api, getPos, activeNode]);
|
|
103
97
|
useEffect(function () {
|
|
@@ -6,7 +6,6 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
6
6
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles, @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
7
7
|
import { css, Global, jsx } from '@emotion/react';
|
|
8
8
|
import { akEditorBreakoutPadding, akEditorCalculatedWideLayoutWidth, akEditorCalculatedWideLayoutWidthSmallViewport } from '@atlaskit/editor-shared-styles';
|
|
9
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
9
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
11
10
|
import { DRAG_HANDLE_MAX_WIDTH_PLUS_GAP, DRAG_HANDLE_WIDTH } from './consts';
|
|
12
11
|
|
|
@@ -209,6 +208,6 @@ var blockCardWithoutLayout = css({
|
|
|
209
208
|
});
|
|
210
209
|
export var GlobalStylesWrapper = function GlobalStylesWrapper() {
|
|
211
210
|
return jsx(Global, {
|
|
212
|
-
styles: [globalStyles(),
|
|
211
|
+
styles: [globalStyles(), globalDnDStyle, editorExperiment('nested-dnd', true) ? extendedHoverZoneNested() : extendedHoverZone(), withInlineNodeStyle, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, withRelativePosStyle, topLevelNodeMarginStyles, editorExperiment('nested-dnd', true) ? withAnchorNameZindexNestedStyle : withAnchorNameZindexStyle,,]
|
|
213
212
|
});
|
|
214
213
|
};
|