@atlaskit/editor-plugin-block-controls 13.1.1 → 13.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/cjs/pm-plugins/decorations-anchor.js +1 -5
- package/dist/cjs/pm-plugins/handle-mouse-over.js +32 -36
- package/dist/cjs/ui/consts.js +1 -1
- package/dist/es2019/pm-plugins/decorations-anchor.js +1 -5
- package/dist/es2019/pm-plugins/handle-mouse-over.js +32 -36
- package/dist/es2019/ui/consts.js +1 -1
- package/dist/esm/pm-plugins/decorations-anchor.js +1 -5
- package/dist/esm/pm-plugins/handle-mouse-over.js +32 -36
- package/dist/esm/ui/consts.js +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 13.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`0aced23fb1739`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0aced23fb1739) -
|
|
8
|
+
Clean up experiment platform_editor_fix_selection_wrapped_media_embed
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
3
11
|
## 13.1.1
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -29,8 +29,6 @@ var shouldDescendIntoNode = exports.shouldDescendIntoNode = function shouldDesce
|
|
|
29
29
|
};
|
|
30
30
|
var shouldIgnoreNode = function shouldIgnoreNode(node, ignore_nodes, depth, parent) {
|
|
31
31
|
var _nodeTypes$table, _node$attrs, _node$attrs2;
|
|
32
|
-
var isEmbedCard = node.type.name === 'embedCard';
|
|
33
|
-
var isMediaSingle = node.type.name === 'mediaSingle';
|
|
34
32
|
var nodeTypes = node.type.schema.nodes;
|
|
35
33
|
var isTable = node.type.name === (nodeTypes === null || nodeTypes === void 0 || (_nodeTypes$table = nodeTypes.table) === null || _nodeTypes$table === void 0 ? void 0 : _nodeTypes$table.name);
|
|
36
34
|
var parentIsTable = parent && [nodeTypes.tableHeader, nodeTypes.tableCell].includes(parent.type);
|
|
@@ -46,9 +44,7 @@ var shouldIgnoreNode = function shouldIgnoreNode(node, ignore_nodes, depth, pare
|
|
|
46
44
|
if (isLegacyContentMacroExtension) {
|
|
47
45
|
return true;
|
|
48
46
|
}
|
|
49
|
-
return
|
|
50
|
-
exposure: true
|
|
51
|
-
}) ? true : ignore_nodes.includes(node.type.name);
|
|
47
|
+
return ignore_nodes.includes(node.type.name);
|
|
52
48
|
};
|
|
53
49
|
|
|
54
50
|
/**
|
|
@@ -55,6 +55,33 @@ var getBlockMarkPanelIndexAdjustment = function getBlockMarkPanelIndexAdjustment
|
|
|
55
55
|
}
|
|
56
56
|
return index;
|
|
57
57
|
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* If the hovered element is a paragraph adjacent to a wrapped mediaSingle/embedCard,
|
|
61
|
+
* redirect to the media node so only one drag handle shows (ED-26959).
|
|
62
|
+
*/
|
|
63
|
+
var redirectParagraphToWrappedMedia = function redirectParagraphToWrappedMedia(rootElement, isNativeAnchorSupported) {
|
|
64
|
+
var hoveredNodeType = isNativeAnchorSupported ? (0, _domAttrName.getTypeNameFromDom)(rootElement) : rootElement.getAttribute('data-drag-handler-node-type');
|
|
65
|
+
if (hoveredNodeType !== 'paragraph') {
|
|
66
|
+
return rootElement;
|
|
67
|
+
}
|
|
68
|
+
var isWrappedMediaEmbedSibling = function isWrappedMediaEmbedSibling(sibling) {
|
|
69
|
+
if (!sibling || !sibling.getAttribute((0, _domAttrName.getAnchorAttrName)())) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
var siblingType = isNativeAnchorSupported ? (0, _domAttrName.getTypeNameFromDom)(sibling) : sibling.getAttribute('data-drag-handler-node-type');
|
|
73
|
+
var siblingLayout = sibling.getAttribute('layout') || '';
|
|
74
|
+
return (siblingType === 'mediaSingle' || siblingType === 'embedCard') && ['wrap-left', 'wrap-right'].includes(siblingLayout);
|
|
75
|
+
};
|
|
76
|
+
var prevSibling = rootElement.previousElementSibling;
|
|
77
|
+
var nextSibling = rootElement.nextElementSibling;
|
|
78
|
+
if (prevSibling && isWrappedMediaEmbedSibling(prevSibling)) {
|
|
79
|
+
return prevSibling;
|
|
80
|
+
} else if (nextSibling && isWrappedMediaEmbedSibling(nextSibling)) {
|
|
81
|
+
return nextSibling;
|
|
82
|
+
}
|
|
83
|
+
return rootElement;
|
|
84
|
+
};
|
|
58
85
|
var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, event, api) {
|
|
59
86
|
var _api$blockControls, _api$editorDisabled, _api$editorViewMode, _api$blockControls$sh, _api$blockControls2, _target$classList;
|
|
60
87
|
var _ref = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
|
|
@@ -157,35 +184,14 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, e
|
|
|
157
184
|
}
|
|
158
185
|
}
|
|
159
186
|
|
|
160
|
-
//
|
|
161
|
-
//
|
|
162
|
-
// is a
|
|
163
|
-
//
|
|
187
|
+
// A wrapped mediaSingle/embedCard and the paragraph(s) it floats next to both have
|
|
188
|
+
// anchor decorations. If the hovered rootElement is a paragraph whose adjacent DOM sibling
|
|
189
|
+
// is a wrapped mediaSingle/embedCard with an anchor, redirect the handle to the media node
|
|
190
|
+
// so only one handle shows (ED-26959).
|
|
164
191
|
// We check previousElementSibling (wrap-left: media precedes text in DOM) and
|
|
165
192
|
// nextElementSibling (wrap-right: media follows text in DOM).
|
|
166
193
|
// This must happen before anchorName is read so the correct node's handle is shown.
|
|
167
|
-
|
|
168
|
-
exposure: true
|
|
169
|
-
})) {
|
|
170
|
-
var _rootNodeType = isNativeAnchorSupported ? (0, _domAttrName.getTypeNameFromDom)(rootElement) : rootElement.getAttribute('data-drag-handler-node-type');
|
|
171
|
-
if (_rootNodeType === 'paragraph') {
|
|
172
|
-
var isWrappedMediaEmbedSibling = function isWrappedMediaEmbedSibling(sibling) {
|
|
173
|
-
if (!sibling || !sibling.getAttribute((0, _domAttrName.getAnchorAttrName)())) {
|
|
174
|
-
return false;
|
|
175
|
-
}
|
|
176
|
-
var siblingType = isNativeAnchorSupported ? (0, _domAttrName.getTypeNameFromDom)(sibling) : sibling.getAttribute('data-drag-handler-node-type');
|
|
177
|
-
var siblingLayout = sibling.getAttribute('layout') || '';
|
|
178
|
-
return (siblingType === 'mediaSingle' || siblingType === 'embedCard') && ['wrap-left', 'wrap-right'].includes(siblingLayout);
|
|
179
|
-
};
|
|
180
|
-
var prevSibling = rootElement.previousElementSibling;
|
|
181
|
-
var nextSibling = rootElement.nextElementSibling;
|
|
182
|
-
if (prevSibling && isWrappedMediaEmbedSibling(prevSibling)) {
|
|
183
|
-
rootElement = prevSibling;
|
|
184
|
-
} else if (nextSibling && isWrappedMediaEmbedSibling(nextSibling)) {
|
|
185
|
-
rootElement = nextSibling;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
194
|
+
rootElement = redirectParagraphToWrappedMedia(rootElement, isNativeAnchorSupported);
|
|
189
195
|
var anchorName;
|
|
190
196
|
if ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
191
197
|
anchorName = rootElement.getAttribute((0, _domAttrName.getAnchorAttrName)());
|
|
@@ -209,16 +215,6 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, e
|
|
|
209
215
|
if ((activeNode === null || activeNode === void 0 ? void 0 : activeNode.anchorName) === anchorName) {
|
|
210
216
|
return false;
|
|
211
217
|
}
|
|
212
|
-
if (!(0, _experiments.editorExperiment)('platform_editor_fix_selection_wrapped_media_embed', true, {
|
|
213
|
-
exposure: true
|
|
214
|
-
})) {
|
|
215
|
-
// We want to exclude handles from showing for wrapped nodes
|
|
216
|
-
// TODO: ED-26959 - We should be able remove these check if we decided to
|
|
217
|
-
// go we not decoration for wrapped image solution.
|
|
218
|
-
if (['wrap-right', 'wrap-left'].includes(rootElement.getAttribute('layout') || '')) {
|
|
219
|
-
return false;
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
218
|
var parentRootElement = rootElement.parentElement;
|
|
223
219
|
var pos;
|
|
224
220
|
if (parentRootElement) {
|
package/dist/cjs/ui/consts.js
CHANGED
|
@@ -122,7 +122,7 @@ var topPositionAdjustment = exports.topPositionAdjustment = function topPosition
|
|
|
122
122
|
return DRAG_HANDLE_LAYOUT_SECTION_TOP_ADJUSTMENT;
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
-
if ((nodeType === 'mediaSingle' || nodeType === 'embedCard') && layout && ['wrap-left', 'wrap-right'].includes(layout)
|
|
125
|
+
if ((nodeType === 'mediaSingle' || nodeType === 'embedCard') && layout && ['wrap-left', 'wrap-right'].includes(layout)) {
|
|
126
126
|
return DRAG_HANDLE_WRAPPED_MEDIA_EMBED_TOP_ADJUSTMENT;
|
|
127
127
|
}
|
|
128
128
|
switch (nodeType) {
|
|
@@ -21,8 +21,6 @@ export const shouldDescendIntoNode = node => {
|
|
|
21
21
|
};
|
|
22
22
|
const shouldIgnoreNode = (node, ignore_nodes, depth, parent) => {
|
|
23
23
|
var _nodeTypes$table, _node$attrs, _node$attrs2;
|
|
24
|
-
const isEmbedCard = node.type.name === 'embedCard';
|
|
25
|
-
const isMediaSingle = node.type.name === 'mediaSingle';
|
|
26
24
|
const nodeTypes = node.type.schema.nodes;
|
|
27
25
|
const isTable = node.type.name === (nodeTypes === null || nodeTypes === void 0 ? void 0 : (_nodeTypes$table = nodeTypes.table) === null || _nodeTypes$table === void 0 ? void 0 : _nodeTypes$table.name);
|
|
28
26
|
const parentIsTable = parent && [nodeTypes.tableHeader, nodeTypes.tableCell].includes(parent.type);
|
|
@@ -38,9 +36,7 @@ const shouldIgnoreNode = (node, ignore_nodes, depth, parent) => {
|
|
|
38
36
|
if (isLegacyContentMacroExtension) {
|
|
39
37
|
return true;
|
|
40
38
|
}
|
|
41
|
-
return
|
|
42
|
-
exposure: true
|
|
43
|
-
}) ? true : ignore_nodes.includes(node.type.name);
|
|
39
|
+
return ignore_nodes.includes(node.type.name);
|
|
44
40
|
};
|
|
45
41
|
|
|
46
42
|
/**
|
|
@@ -45,6 +45,33 @@ const getBlockMarkPanelIndexAdjustment = (parentRootElement, index) => {
|
|
|
45
45
|
}
|
|
46
46
|
return index;
|
|
47
47
|
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* If the hovered element is a paragraph adjacent to a wrapped mediaSingle/embedCard,
|
|
51
|
+
* redirect to the media node so only one drag handle shows (ED-26959).
|
|
52
|
+
*/
|
|
53
|
+
const redirectParagraphToWrappedMedia = (rootElement, isNativeAnchorSupported) => {
|
|
54
|
+
const hoveredNodeType = isNativeAnchorSupported ? getTypeNameFromDom(rootElement) : rootElement.getAttribute('data-drag-handler-node-type');
|
|
55
|
+
if (hoveredNodeType !== 'paragraph') {
|
|
56
|
+
return rootElement;
|
|
57
|
+
}
|
|
58
|
+
const isWrappedMediaEmbedSibling = sibling => {
|
|
59
|
+
if (!sibling || !sibling.getAttribute(getAnchorAttrName())) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
const siblingType = isNativeAnchorSupported ? getTypeNameFromDom(sibling) : sibling.getAttribute('data-drag-handler-node-type');
|
|
63
|
+
const siblingLayout = sibling.getAttribute('layout') || '';
|
|
64
|
+
return (siblingType === 'mediaSingle' || siblingType === 'embedCard') && ['wrap-left', 'wrap-right'].includes(siblingLayout);
|
|
65
|
+
};
|
|
66
|
+
const prevSibling = rootElement.previousElementSibling;
|
|
67
|
+
const nextSibling = rootElement.nextElementSibling;
|
|
68
|
+
if (prevSibling && isWrappedMediaEmbedSibling(prevSibling)) {
|
|
69
|
+
return prevSibling;
|
|
70
|
+
} else if (nextSibling && isWrappedMediaEmbedSibling(nextSibling)) {
|
|
71
|
+
return nextSibling;
|
|
72
|
+
}
|
|
73
|
+
return rootElement;
|
|
74
|
+
};
|
|
48
75
|
export const handleMouseOver = (view, event, api) => {
|
|
49
76
|
var _api$blockControls, _api$editorDisabled, _api$editorViewMode, _api$editorViewMode$s, _api$blockControls$sh, _api$blockControls2, _api$blockControls2$s, _target$classList;
|
|
50
77
|
const {
|
|
@@ -149,35 +176,14 @@ export const handleMouseOver = (view, event, api) => {
|
|
|
149
176
|
}
|
|
150
177
|
}
|
|
151
178
|
|
|
152
|
-
//
|
|
153
|
-
//
|
|
154
|
-
// is a
|
|
155
|
-
//
|
|
179
|
+
// A wrapped mediaSingle/embedCard and the paragraph(s) it floats next to both have
|
|
180
|
+
// anchor decorations. If the hovered rootElement is a paragraph whose adjacent DOM sibling
|
|
181
|
+
// is a wrapped mediaSingle/embedCard with an anchor, redirect the handle to the media node
|
|
182
|
+
// so only one handle shows (ED-26959).
|
|
156
183
|
// We check previousElementSibling (wrap-left: media precedes text in DOM) and
|
|
157
184
|
// nextElementSibling (wrap-right: media follows text in DOM).
|
|
158
185
|
// This must happen before anchorName is read so the correct node's handle is shown.
|
|
159
|
-
|
|
160
|
-
exposure: true
|
|
161
|
-
})) {
|
|
162
|
-
const rootNodeType = isNativeAnchorSupported ? getTypeNameFromDom(rootElement) : rootElement.getAttribute('data-drag-handler-node-type');
|
|
163
|
-
if (rootNodeType === 'paragraph') {
|
|
164
|
-
const isWrappedMediaEmbedSibling = sibling => {
|
|
165
|
-
if (!sibling || !sibling.getAttribute(getAnchorAttrName())) {
|
|
166
|
-
return false;
|
|
167
|
-
}
|
|
168
|
-
const siblingType = isNativeAnchorSupported ? getTypeNameFromDom(sibling) : sibling.getAttribute('data-drag-handler-node-type');
|
|
169
|
-
const siblingLayout = sibling.getAttribute('layout') || '';
|
|
170
|
-
return (siblingType === 'mediaSingle' || siblingType === 'embedCard') && ['wrap-left', 'wrap-right'].includes(siblingLayout);
|
|
171
|
-
};
|
|
172
|
-
const prevSibling = rootElement.previousElementSibling;
|
|
173
|
-
const nextSibling = rootElement.nextElementSibling;
|
|
174
|
-
if (prevSibling && isWrappedMediaEmbedSibling(prevSibling)) {
|
|
175
|
-
rootElement = prevSibling;
|
|
176
|
-
} else if (nextSibling && isWrappedMediaEmbedSibling(nextSibling)) {
|
|
177
|
-
rootElement = nextSibling;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
186
|
+
rootElement = redirectParagraphToWrappedMedia(rootElement, isNativeAnchorSupported);
|
|
181
187
|
let anchorName;
|
|
182
188
|
if (expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
183
189
|
anchorName = rootElement.getAttribute(getAnchorAttrName());
|
|
@@ -201,16 +207,6 @@ export const handleMouseOver = (view, event, api) => {
|
|
|
201
207
|
if ((activeNode === null || activeNode === void 0 ? void 0 : activeNode.anchorName) === anchorName) {
|
|
202
208
|
return false;
|
|
203
209
|
}
|
|
204
|
-
if (!editorExperiment('platform_editor_fix_selection_wrapped_media_embed', true, {
|
|
205
|
-
exposure: true
|
|
206
|
-
})) {
|
|
207
|
-
// We want to exclude handles from showing for wrapped nodes
|
|
208
|
-
// TODO: ED-26959 - We should be able remove these check if we decided to
|
|
209
|
-
// go we not decoration for wrapped image solution.
|
|
210
|
-
if (['wrap-right', 'wrap-left'].includes(rootElement.getAttribute('layout') || '')) {
|
|
211
|
-
return false;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
210
|
const parentRootElement = rootElement.parentElement;
|
|
215
211
|
let pos;
|
|
216
212
|
if (parentRootElement) {
|
package/dist/es2019/ui/consts.js
CHANGED
|
@@ -113,7 +113,7 @@ export const topPositionAdjustment = (nodeType, layout) => {
|
|
|
113
113
|
return DRAG_HANDLE_LAYOUT_SECTION_TOP_ADJUSTMENT;
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
|
-
if ((nodeType === 'mediaSingle' || nodeType === 'embedCard') && layout && ['wrap-left', 'wrap-right'].includes(layout)
|
|
116
|
+
if ((nodeType === 'mediaSingle' || nodeType === 'embedCard') && layout && ['wrap-left', 'wrap-right'].includes(layout)) {
|
|
117
117
|
return DRAG_HANDLE_WRAPPED_MEDIA_EMBED_TOP_ADJUSTMENT;
|
|
118
118
|
}
|
|
119
119
|
switch (nodeType) {
|
|
@@ -22,8 +22,6 @@ export var shouldDescendIntoNode = function shouldDescendIntoNode(node) {
|
|
|
22
22
|
};
|
|
23
23
|
var shouldIgnoreNode = function shouldIgnoreNode(node, ignore_nodes, depth, parent) {
|
|
24
24
|
var _nodeTypes$table, _node$attrs, _node$attrs2;
|
|
25
|
-
var isEmbedCard = node.type.name === 'embedCard';
|
|
26
|
-
var isMediaSingle = node.type.name === 'mediaSingle';
|
|
27
25
|
var nodeTypes = node.type.schema.nodes;
|
|
28
26
|
var isTable = node.type.name === (nodeTypes === null || nodeTypes === void 0 || (_nodeTypes$table = nodeTypes.table) === null || _nodeTypes$table === void 0 ? void 0 : _nodeTypes$table.name);
|
|
29
27
|
var parentIsTable = parent && [nodeTypes.tableHeader, nodeTypes.tableCell].includes(parent.type);
|
|
@@ -39,9 +37,7 @@ var shouldIgnoreNode = function shouldIgnoreNode(node, ignore_nodes, depth, pare
|
|
|
39
37
|
if (isLegacyContentMacroExtension) {
|
|
40
38
|
return true;
|
|
41
39
|
}
|
|
42
|
-
return
|
|
43
|
-
exposure: true
|
|
44
|
-
}) ? true : ignore_nodes.includes(node.type.name);
|
|
40
|
+
return ignore_nodes.includes(node.type.name);
|
|
45
41
|
};
|
|
46
42
|
|
|
47
43
|
/**
|
|
@@ -48,6 +48,33 @@ var getBlockMarkPanelIndexAdjustment = function getBlockMarkPanelIndexAdjustment
|
|
|
48
48
|
}
|
|
49
49
|
return index;
|
|
50
50
|
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* If the hovered element is a paragraph adjacent to a wrapped mediaSingle/embedCard,
|
|
54
|
+
* redirect to the media node so only one drag handle shows (ED-26959).
|
|
55
|
+
*/
|
|
56
|
+
var redirectParagraphToWrappedMedia = function redirectParagraphToWrappedMedia(rootElement, isNativeAnchorSupported) {
|
|
57
|
+
var hoveredNodeType = isNativeAnchorSupported ? getTypeNameFromDom(rootElement) : rootElement.getAttribute('data-drag-handler-node-type');
|
|
58
|
+
if (hoveredNodeType !== 'paragraph') {
|
|
59
|
+
return rootElement;
|
|
60
|
+
}
|
|
61
|
+
var isWrappedMediaEmbedSibling = function isWrappedMediaEmbedSibling(sibling) {
|
|
62
|
+
if (!sibling || !sibling.getAttribute(getAnchorAttrName())) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
var siblingType = isNativeAnchorSupported ? getTypeNameFromDom(sibling) : sibling.getAttribute('data-drag-handler-node-type');
|
|
66
|
+
var siblingLayout = sibling.getAttribute('layout') || '';
|
|
67
|
+
return (siblingType === 'mediaSingle' || siblingType === 'embedCard') && ['wrap-left', 'wrap-right'].includes(siblingLayout);
|
|
68
|
+
};
|
|
69
|
+
var prevSibling = rootElement.previousElementSibling;
|
|
70
|
+
var nextSibling = rootElement.nextElementSibling;
|
|
71
|
+
if (prevSibling && isWrappedMediaEmbedSibling(prevSibling)) {
|
|
72
|
+
return prevSibling;
|
|
73
|
+
} else if (nextSibling && isWrappedMediaEmbedSibling(nextSibling)) {
|
|
74
|
+
return nextSibling;
|
|
75
|
+
}
|
|
76
|
+
return rootElement;
|
|
77
|
+
};
|
|
51
78
|
export var handleMouseOver = function handleMouseOver(view, event, api) {
|
|
52
79
|
var _api$blockControls, _api$editorDisabled, _api$editorViewMode, _api$blockControls$sh, _api$blockControls2, _target$classList;
|
|
53
80
|
var _ref = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
|
|
@@ -150,35 +177,14 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
|
|
|
150
177
|
}
|
|
151
178
|
}
|
|
152
179
|
|
|
153
|
-
//
|
|
154
|
-
//
|
|
155
|
-
// is a
|
|
156
|
-
//
|
|
180
|
+
// A wrapped mediaSingle/embedCard and the paragraph(s) it floats next to both have
|
|
181
|
+
// anchor decorations. If the hovered rootElement is a paragraph whose adjacent DOM sibling
|
|
182
|
+
// is a wrapped mediaSingle/embedCard with an anchor, redirect the handle to the media node
|
|
183
|
+
// so only one handle shows (ED-26959).
|
|
157
184
|
// We check previousElementSibling (wrap-left: media precedes text in DOM) and
|
|
158
185
|
// nextElementSibling (wrap-right: media follows text in DOM).
|
|
159
186
|
// This must happen before anchorName is read so the correct node's handle is shown.
|
|
160
|
-
|
|
161
|
-
exposure: true
|
|
162
|
-
})) {
|
|
163
|
-
var _rootNodeType = isNativeAnchorSupported ? getTypeNameFromDom(rootElement) : rootElement.getAttribute('data-drag-handler-node-type');
|
|
164
|
-
if (_rootNodeType === 'paragraph') {
|
|
165
|
-
var isWrappedMediaEmbedSibling = function isWrappedMediaEmbedSibling(sibling) {
|
|
166
|
-
if (!sibling || !sibling.getAttribute(getAnchorAttrName())) {
|
|
167
|
-
return false;
|
|
168
|
-
}
|
|
169
|
-
var siblingType = isNativeAnchorSupported ? getTypeNameFromDom(sibling) : sibling.getAttribute('data-drag-handler-node-type');
|
|
170
|
-
var siblingLayout = sibling.getAttribute('layout') || '';
|
|
171
|
-
return (siblingType === 'mediaSingle' || siblingType === 'embedCard') && ['wrap-left', 'wrap-right'].includes(siblingLayout);
|
|
172
|
-
};
|
|
173
|
-
var prevSibling = rootElement.previousElementSibling;
|
|
174
|
-
var nextSibling = rootElement.nextElementSibling;
|
|
175
|
-
if (prevSibling && isWrappedMediaEmbedSibling(prevSibling)) {
|
|
176
|
-
rootElement = prevSibling;
|
|
177
|
-
} else if (nextSibling && isWrappedMediaEmbedSibling(nextSibling)) {
|
|
178
|
-
rootElement = nextSibling;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
187
|
+
rootElement = redirectParagraphToWrappedMedia(rootElement, isNativeAnchorSupported);
|
|
182
188
|
var anchorName;
|
|
183
189
|
if (expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
|
|
184
190
|
anchorName = rootElement.getAttribute(getAnchorAttrName());
|
|
@@ -202,16 +208,6 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
|
|
|
202
208
|
if ((activeNode === null || activeNode === void 0 ? void 0 : activeNode.anchorName) === anchorName) {
|
|
203
209
|
return false;
|
|
204
210
|
}
|
|
205
|
-
if (!editorExperiment('platform_editor_fix_selection_wrapped_media_embed', true, {
|
|
206
|
-
exposure: true
|
|
207
|
-
})) {
|
|
208
|
-
// We want to exclude handles from showing for wrapped nodes
|
|
209
|
-
// TODO: ED-26959 - We should be able remove these check if we decided to
|
|
210
|
-
// go we not decoration for wrapped image solution.
|
|
211
|
-
if (['wrap-right', 'wrap-left'].includes(rootElement.getAttribute('layout') || '')) {
|
|
212
|
-
return false;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
211
|
var parentRootElement = rootElement.parentElement;
|
|
216
212
|
var pos;
|
|
217
213
|
if (parentRootElement) {
|
package/dist/esm/ui/consts.js
CHANGED
|
@@ -115,7 +115,7 @@ export var topPositionAdjustment = function topPositionAdjustment(nodeType, layo
|
|
|
115
115
|
return DRAG_HANDLE_LAYOUT_SECTION_TOP_ADJUSTMENT;
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
|
-
if ((nodeType === 'mediaSingle' || nodeType === 'embedCard') && layout && ['wrap-left', 'wrap-right'].includes(layout)
|
|
118
|
+
if ((nodeType === 'mediaSingle' || nodeType === 'embedCard') && layout && ['wrap-left', 'wrap-right'].includes(layout)) {
|
|
119
119
|
return DRAG_HANDLE_WRAPPED_MEDIA_EMBED_TOP_ADJUSTMENT;
|
|
120
120
|
}
|
|
121
121
|
switch (nodeType) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "13.1.
|
|
3
|
+
"version": "13.1.2",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^4.0.0",
|
|
49
49
|
"@atlaskit/primitives": "^20.0.0",
|
|
50
50
|
"@atlaskit/theme": "^26.0.0",
|
|
51
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
51
|
+
"@atlaskit/tmp-editor-statsig": "^113.0.0",
|
|
52
52
|
"@atlaskit/tokens": "^15.0.0",
|
|
53
53
|
"@atlaskit/tooltip": "^23.0.0",
|
|
54
54
|
"@babel/runtime": "^7.0.0",
|