@atlaskit/editor-plugin-block-controls 7.2.10 → 7.2.12
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 +17 -0
- package/dist/cjs/pm-plugins/handle-mouse-down.js +14 -2
- package/dist/cjs/pm-plugins/handle-mouse-over.js +13 -3
- package/dist/cjs/pm-plugins/main.js +3 -2
- package/dist/cjs/ui/drag-handle.js +4 -2
- package/dist/cjs/ui/drag-preview.js +3 -1
- package/dist/es2019/pm-plugins/handle-mouse-down.js +14 -2
- package/dist/es2019/pm-plugins/handle-mouse-over.js +13 -3
- package/dist/es2019/pm-plugins/main.js +3 -2
- package/dist/es2019/ui/drag-handle.js +3 -1
- package/dist/es2019/ui/drag-preview.js +3 -1
- package/dist/esm/pm-plugins/handle-mouse-down.js +14 -2
- package/dist/esm/pm-plugins/handle-mouse-over.js +13 -3
- package/dist/esm/pm-plugins/main.js +3 -2
- package/dist/esm/ui/drag-handle.js +3 -1
- package/dist/esm/ui/drag-preview.js +3 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 7.2.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`5e7e734485a98`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/5e7e734485a98) -
|
|
8
|
+
upgrade browser util api
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 7.2.11
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`606c3303a0d61`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/606c3303a0d61) -
|
|
16
|
+
[ux] ED-29331 fix block controls misalignment on first line of empty document with
|
|
17
|
+
platform_editor_native_anchor_support on
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
|
|
3
20
|
## 7.2.10
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.handleMouseDown = void 0;
|
|
7
7
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
8
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
8
9
|
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
9
10
|
var handleMouseDown = exports.handleMouseDown = function handleMouseDown(api) {
|
|
10
11
|
return function (view, event) {
|
|
@@ -12,7 +13,6 @@ var handleMouseDown = exports.handleMouseDown = function handleMouseDown(api) {
|
|
|
12
13
|
return false;
|
|
13
14
|
}
|
|
14
15
|
if (!view.editable) {
|
|
15
|
-
var _rootNode$type$name, _rootNode$type$name2;
|
|
16
16
|
var targetPos = view.posAtDOM(event.target, 0);
|
|
17
17
|
// always fetch top level position for mouseDown to avoid drag handle positions being incorrect
|
|
18
18
|
var rootPos = view.state.doc.resolve(targetPos).before(1);
|
|
@@ -20,7 +20,19 @@ var handleMouseDown = exports.handleMouseDown = function handleMouseDown(api) {
|
|
|
20
20
|
if (!rootNode) {
|
|
21
21
|
return false;
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_support', 'isEnabled', true)) {
|
|
24
|
+
var _rootNode$type$name, _rootNode$type$name2;
|
|
25
|
+
var anchorName = api === null || api === void 0 ? void 0 : api.core.actions.getAnchorIdForNode(rootNode, rootPos);
|
|
26
|
+
|
|
27
|
+
// don't show the handles if we can't find an anchor
|
|
28
|
+
if (!anchorName) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.showDragHandleAt(rootPos, anchorName, (_rootNode$type$name = rootNode.type.name) !== null && _rootNode$type$name !== void 0 ? _rootNode$type$name : '', undefined, rootPos, anchorName, (_rootNode$type$name2 = rootNode.type.name) !== null && _rootNode$type$name2 !== void 0 ? _rootNode$type$name2 : ''));
|
|
32
|
+
} else {
|
|
33
|
+
var _rootNode$type$name3, _rootNode$type$name4;
|
|
34
|
+
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.showDragHandleAt(rootPos, '', (_rootNode$type$name3 = rootNode.type.name) !== null && _rootNode$type$name3 !== void 0 ? _rootNode$type$name3 : '', undefined, rootPos, '', (_rootNode$type$name4 = rootNode.type.name) !== null && _rootNode$type$name4 !== void 0 ? _rootNode$type$name4 : ''));
|
|
35
|
+
}
|
|
24
36
|
} else {
|
|
25
37
|
var isDragHandle = event.target.closest((0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true) ? _styles.DRAG_HANDLE_SELECTOR : '[data-editor-block-ctrl-drag-handle]') !== null;
|
|
26
38
|
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(isDragHandle));
|
|
@@ -100,10 +100,20 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, e
|
|
|
100
100
|
rootElement = parentElement;
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
+
var anchorName;
|
|
104
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_support', 'isEnabled', true)) {
|
|
105
|
+
anchorName = rootElement.getAttribute((0, _domAttrName.getAnchorAttrName)());
|
|
106
|
+
|
|
107
|
+
// don't show handles if we can't find an anchor
|
|
108
|
+
if (!anchorName) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
} else {
|
|
112
|
+
// Ignored via go/ees005
|
|
113
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
114
|
+
anchorName = rootElement.getAttribute((0, _domAttrName.getAnchorAttrName)());
|
|
115
|
+
}
|
|
103
116
|
|
|
104
|
-
// Ignored via go/ees005
|
|
105
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
106
|
-
var anchorName = rootElement.getAttribute((0, _domAttrName.getAnchorAttrName)());
|
|
107
117
|
// No need to update handle position if its already there
|
|
108
118
|
if ((activeNode === null || activeNode === void 0 ? void 0 : activeNode.anchorName) === anchorName) {
|
|
109
119
|
return false;
|
|
@@ -296,12 +296,13 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
|
|
|
296
296
|
if (activeNode && (meta === null || meta === void 0 ? void 0 : meta.isDragging) !== true) {
|
|
297
297
|
var _mappedRootPos$pos, _mappedRootPos;
|
|
298
298
|
var _mappedPos;
|
|
299
|
+
var browser = (0, _expValEquals.expValEquals)('platform_editor_hydratable_ui', 'isEnabled', true) ? (0, _browser.getBrowserInfo)() : _browser.browser;
|
|
299
300
|
// In safari, when platform_editor_controls is on,
|
|
300
301
|
// sometimes the drag handle for the layout disppears after you click on the handle for a few times
|
|
301
302
|
// Which caused the drag handle onClick event not firing, then block menu wouldn't be opened
|
|
302
303
|
// This is caused by the mappedPos.deletedAfter sometimes returning true in webkit browsers even though the active node still exists
|
|
303
304
|
// This is likely a prosemirror and safari integration bug, but to unblock the issue, we are going to use mappedPos.deleted in safari for now
|
|
304
|
-
if (
|
|
305
|
+
if (browser.webkit && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true)) {
|
|
305
306
|
_mappedPos = tr.mapping.mapResult(activeNode.pos);
|
|
306
307
|
isActiveNodeDeleted = _mappedPos.deleted;
|
|
307
308
|
} else {
|
|
@@ -503,7 +504,7 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
|
|
|
503
504
|
}
|
|
504
505
|
}
|
|
505
506
|
var isEmptyDoc = (0, _utils.isEmptyDocument)(newState.doc);
|
|
506
|
-
if (isEmptyDoc) {
|
|
507
|
+
if (isEmptyDoc && !(0, _expValEquals.expValEquals)('platform_editor_native_anchor_support', 'isEnabled', true)) {
|
|
507
508
|
var hasNodeDecoration = !!(0, _decorationsAnchor.findNodeDecs)(newState, decorations).length;
|
|
508
509
|
if (!hasNodeDecoration) {
|
|
509
510
|
decorations = decorations.add(newState.doc, [(0, _decorationsDragHandle.emptyParagraphNodeDecorations)()]);
|
|
@@ -248,7 +248,8 @@ var selectedStyles = (0, _react2.css)({
|
|
|
248
248
|
// icon span receives dragStart event, instead of button, and since it is not registered as a draggable element
|
|
249
249
|
// with pragmatic DnD and pragmatic DnD is not triggered
|
|
250
250
|
var handleIconDragStart = function handleIconDragStart(e) {
|
|
251
|
-
|
|
251
|
+
var browser = (0, _expValEquals.expValEquals)('platform_editor_hydratable_ui', 'isEnabled', true) ? (0, _browser.getBrowserInfo)() : _browser.browser;
|
|
252
|
+
if (!browser.chrome) {
|
|
252
253
|
return;
|
|
253
254
|
}
|
|
254
255
|
// prevent dragStart handler triggered by icon
|
|
@@ -947,6 +948,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
947
948
|
(0, _experiments.editorExperiment)('platform_editor_element_drag_and_drop_multiselect', true) && event.stopPropagation();
|
|
948
949
|
};
|
|
949
950
|
var hasHadInteraction = interactionState !== 'hasNotHadInteraction';
|
|
951
|
+
var browser = (0, _expValEquals.expValEquals)('platform_editor_hydratable_ui', 'isEnabled', true) ? (0, _browser.getBrowserInfo)() : _browser.browser;
|
|
950
952
|
var renderButton = function renderButton() {
|
|
951
953
|
return (
|
|
952
954
|
// eslint-disable-next-line @atlaskit/design-system/no-html-button
|
|
@@ -955,7 +957,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
955
957
|
css: [(0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? dragHandleButtonStyles : dragHandleButtonStylesOld, (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && dragHandleColor,
|
|
956
958
|
// ED-26266: Fixed the drag handle highlight when selecting multiple line in Firefox
|
|
957
959
|
// See https://product-fabric.atlassian.net/browse/ED-26266
|
|
958
|
-
|
|
960
|
+
browser.gecko && dragHandleMultiLineSelectionFixFirefox, (0, _experiments.editorExperiment)('advanced_layouts', true) && isLayoutColumn && layoutColumnDragHandleStyles, dragHandleSelected && hasHadInteraction && selectedStyles, (0, _experiments.editorExperiment)('platform_editor_preview_panel_responsiveness', true) && (0, _experiments.editorExperiment)('platform_editor_controls', 'control') && dragHandleButtonSmallScreenStyles, (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true) && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true) && isFocused && keyboardFocusedDragHandleStyles, (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true) && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true) ? focusedStyles : focusedStylesOld],
|
|
959
961
|
ref: buttonRef
|
|
960
962
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
961
963
|
,
|
|
@@ -8,6 +8,7 @@ exports.dragPreview = void 0;
|
|
|
8
8
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
9
9
|
var _browser = require("@atlaskit/editor-common/browser");
|
|
10
10
|
var _colors = require("@atlaskit/theme/colors");
|
|
11
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
11
12
|
var previewStyle = {
|
|
12
13
|
borderColor: "var(--ds-border, ".concat(_colors.N30, ")"),
|
|
13
14
|
borderStyle: 'solid',
|
|
@@ -69,12 +70,13 @@ var createContentPreviewElement = function createContentPreviewElement(dom, node
|
|
|
69
70
|
// Ignored via go/ees005
|
|
70
71
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
71
72
|
dom.cloneNode(true);
|
|
73
|
+
var browser = (0, _expValEquals.expValEquals)('platform_editor_hydratable_ui', 'isEnabled', true) ? (0, _browser.getBrowserInfo)() : _browser.browser;
|
|
72
74
|
clonedDom.style.marginLeft = '0';
|
|
73
75
|
clonedDom.style.marginTop = nodeSpacing ? "".concat(nodeSpacing.top) : '0';
|
|
74
76
|
clonedDom.style.marginRight = '0';
|
|
75
77
|
clonedDom.style.marginBottom = nodeSpacing ? "".concat(nodeSpacing.bottom) : '0';
|
|
76
78
|
clonedDom.style.boxShadow = 'none';
|
|
77
|
-
clonedDom.style.opacity =
|
|
79
|
+
clonedDom.style.opacity = browser.windows ? '1' : '0.31';
|
|
78
80
|
contentPreviewOneElement.appendChild(clonedDom);
|
|
79
81
|
return contentPreviewOneElement;
|
|
80
82
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { DRAG_HANDLE_SELECTOR } from '@atlaskit/editor-common/styles';
|
|
2
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
2
3
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
3
4
|
export const handleMouseDown = api => (view, event) => {
|
|
4
5
|
if (!(event.target instanceof HTMLElement)) {
|
|
5
6
|
return false;
|
|
6
7
|
}
|
|
7
8
|
if (!view.editable) {
|
|
8
|
-
var _rootNode$type$name, _rootNode$type$name2;
|
|
9
9
|
const targetPos = view.posAtDOM(event.target, 0);
|
|
10
10
|
// always fetch top level position for mouseDown to avoid drag handle positions being incorrect
|
|
11
11
|
const rootPos = view.state.doc.resolve(targetPos).before(1);
|
|
@@ -13,7 +13,19 @@ export const handleMouseDown = api => (view, event) => {
|
|
|
13
13
|
if (!rootNode) {
|
|
14
14
|
return false;
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
if (expValEquals('platform_editor_native_anchor_support', 'isEnabled', true)) {
|
|
17
|
+
var _rootNode$type$name, _rootNode$type$name2;
|
|
18
|
+
const anchorName = api === null || api === void 0 ? void 0 : api.core.actions.getAnchorIdForNode(rootNode, rootPos);
|
|
19
|
+
|
|
20
|
+
// don't show the handles if we can't find an anchor
|
|
21
|
+
if (!anchorName) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.showDragHandleAt(rootPos, anchorName, (_rootNode$type$name = rootNode.type.name) !== null && _rootNode$type$name !== void 0 ? _rootNode$type$name : '', undefined, rootPos, anchorName, (_rootNode$type$name2 = rootNode.type.name) !== null && _rootNode$type$name2 !== void 0 ? _rootNode$type$name2 : ''));
|
|
25
|
+
} else {
|
|
26
|
+
var _rootNode$type$name3, _rootNode$type$name4;
|
|
27
|
+
api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.showDragHandleAt(rootPos, '', (_rootNode$type$name3 = rootNode.type.name) !== null && _rootNode$type$name3 !== void 0 ? _rootNode$type$name3 : '', undefined, rootPos, '', (_rootNode$type$name4 = rootNode.type.name) !== null && _rootNode$type$name4 !== void 0 ? _rootNode$type$name4 : ''));
|
|
28
|
+
}
|
|
17
29
|
} else {
|
|
18
30
|
const isDragHandle = event.target.closest(expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) ? DRAG_HANDLE_SELECTOR : '[data-editor-block-ctrl-drag-handle]') !== null;
|
|
19
31
|
api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(isDragHandle));
|
|
@@ -90,10 +90,20 @@ export const handleMouseOver = (view, event, api) => {
|
|
|
90
90
|
rootElement = parentElement;
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
+
let anchorName;
|
|
94
|
+
if (expValEquals('platform_editor_native_anchor_support', 'isEnabled', true)) {
|
|
95
|
+
anchorName = rootElement.getAttribute(getAnchorAttrName());
|
|
96
|
+
|
|
97
|
+
// don't show handles if we can't find an anchor
|
|
98
|
+
if (!anchorName) {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
} else {
|
|
102
|
+
// Ignored via go/ees005
|
|
103
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
104
|
+
anchorName = rootElement.getAttribute(getAnchorAttrName());
|
|
105
|
+
}
|
|
93
106
|
|
|
94
|
-
// Ignored via go/ees005
|
|
95
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
96
|
-
const anchorName = rootElement.getAttribute(getAnchorAttrName());
|
|
97
107
|
// No need to update handle position if its already there
|
|
98
108
|
if ((activeNode === null || activeNode === void 0 ? void 0 : activeNode.anchorName) === anchorName) {
|
|
99
109
|
return false;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import rafSchedule from 'raf-schd';
|
|
2
2
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
3
|
-
import { browser } from '@atlaskit/editor-common/browser';
|
|
3
|
+
import { browser as browserLegacy, getBrowserInfo } from '@atlaskit/editor-common/browser';
|
|
4
4
|
import { isMeasuring, startMeasure, stopMeasure } from '@atlaskit/editor-common/performance-measures';
|
|
5
5
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
6
6
|
import { DRAG_HANDLE_SELECTOR } from '@atlaskit/editor-common/styles';
|
|
@@ -295,6 +295,7 @@ export const apply = (api, formatMessage, tr, currentState, newState, flags, nod
|
|
|
295
295
|
if (activeNode && (meta === null || meta === void 0 ? void 0 : meta.isDragging) !== true) {
|
|
296
296
|
var _mappedRootPos$pos, _mappedRootPos;
|
|
297
297
|
let mappedPos;
|
|
298
|
+
const browser = expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) ? getBrowserInfo() : browserLegacy;
|
|
298
299
|
// In safari, when platform_editor_controls is on,
|
|
299
300
|
// sometimes the drag handle for the layout disppears after you click on the handle for a few times
|
|
300
301
|
// Which caused the drag handle onClick event not firing, then block menu wouldn't be opened
|
|
@@ -501,7 +502,7 @@ export const apply = (api, formatMessage, tr, currentState, newState, flags, nod
|
|
|
501
502
|
}
|
|
502
503
|
}
|
|
503
504
|
const isEmptyDoc = isEmptyDocument(newState.doc);
|
|
504
|
-
if (isEmptyDoc) {
|
|
505
|
+
if (isEmptyDoc && !expValEquals('platform_editor_native_anchor_support', 'isEnabled', true)) {
|
|
505
506
|
const hasNodeDecoration = !!findNodeDecs(newState, decorations).length;
|
|
506
507
|
if (!hasNodeDecoration) {
|
|
507
508
|
decorations = decorations.add(newState.doc, [emptyParagraphNodeDecorations()]);
|
|
@@ -9,7 +9,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
|
9
9
|
import { css, jsx } from '@emotion/react';
|
|
10
10
|
import { bind } from 'bind-event-listener';
|
|
11
11
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
12
|
-
import { browser } from '@atlaskit/editor-common/browser';
|
|
12
|
+
import { browser as browserLegacy, getBrowserInfo } from '@atlaskit/editor-common/browser';
|
|
13
13
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
14
14
|
import { dragToMoveDown, dragToMoveLeft, dragToMoveRight, dragToMoveUp, getAriaKeyshortcuts, TooltipContentWithMultipleShortcuts } from '@atlaskit/editor-common/keymaps';
|
|
15
15
|
import { blockControlsMessages } from '@atlaskit/editor-common/messages';
|
|
@@ -243,6 +243,7 @@ const selectedStyles = css({
|
|
|
243
243
|
// icon span receives dragStart event, instead of button, and since it is not registered as a draggable element
|
|
244
244
|
// with pragmatic DnD and pragmatic DnD is not triggered
|
|
245
245
|
const handleIconDragStart = e => {
|
|
246
|
+
const browser = expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) ? getBrowserInfo() : browserLegacy;
|
|
246
247
|
if (!browser.chrome) {
|
|
247
248
|
return;
|
|
248
249
|
}
|
|
@@ -933,6 +934,7 @@ export const DragHandle = ({
|
|
|
933
934
|
editorExperiment('platform_editor_element_drag_and_drop_multiselect', true) && event.stopPropagation();
|
|
934
935
|
};
|
|
935
936
|
const hasHadInteraction = interactionState !== 'hasNotHadInteraction';
|
|
937
|
+
const browser = expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) ? getBrowserInfo() : browserLegacy;
|
|
936
938
|
const renderButton = () =>
|
|
937
939
|
// eslint-disable-next-line @atlaskit/design-system/no-html-button
|
|
938
940
|
jsx("button", {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { browser } from '@atlaskit/editor-common/browser';
|
|
1
|
+
import { browser as browserLegacy, getBrowserInfo } from '@atlaskit/editor-common/browser';
|
|
2
2
|
import { N20, N30 } from '@atlaskit/theme/colors';
|
|
3
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
3
4
|
const previewStyle = {
|
|
4
5
|
borderColor: `var(--ds-border, ${N30})`,
|
|
5
6
|
borderStyle: 'solid',
|
|
@@ -62,6 +63,7 @@ const createContentPreviewElement = (dom, nodeType, nodeSpacing) => {
|
|
|
62
63
|
// Ignored via go/ees005
|
|
63
64
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
64
65
|
dom.cloneNode(true);
|
|
66
|
+
const browser = expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) ? getBrowserInfo() : browserLegacy;
|
|
65
67
|
clonedDom.style.marginLeft = '0';
|
|
66
68
|
clonedDom.style.marginTop = nodeSpacing ? `${nodeSpacing.top}` : '0';
|
|
67
69
|
clonedDom.style.marginRight = '0';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DRAG_HANDLE_SELECTOR } from '@atlaskit/editor-common/styles';
|
|
2
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
2
3
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
3
4
|
export var handleMouseDown = function handleMouseDown(api) {
|
|
4
5
|
return function (view, event) {
|
|
@@ -6,7 +7,6 @@ export var handleMouseDown = function handleMouseDown(api) {
|
|
|
6
7
|
return false;
|
|
7
8
|
}
|
|
8
9
|
if (!view.editable) {
|
|
9
|
-
var _rootNode$type$name, _rootNode$type$name2;
|
|
10
10
|
var targetPos = view.posAtDOM(event.target, 0);
|
|
11
11
|
// always fetch top level position for mouseDown to avoid drag handle positions being incorrect
|
|
12
12
|
var rootPos = view.state.doc.resolve(targetPos).before(1);
|
|
@@ -14,7 +14,19 @@ export var handleMouseDown = function handleMouseDown(api) {
|
|
|
14
14
|
if (!rootNode) {
|
|
15
15
|
return false;
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
if (expValEquals('platform_editor_native_anchor_support', 'isEnabled', true)) {
|
|
18
|
+
var _rootNode$type$name, _rootNode$type$name2;
|
|
19
|
+
var anchorName = api === null || api === void 0 ? void 0 : api.core.actions.getAnchorIdForNode(rootNode, rootPos);
|
|
20
|
+
|
|
21
|
+
// don't show the handles if we can't find an anchor
|
|
22
|
+
if (!anchorName) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.showDragHandleAt(rootPos, anchorName, (_rootNode$type$name = rootNode.type.name) !== null && _rootNode$type$name !== void 0 ? _rootNode$type$name : '', undefined, rootPos, anchorName, (_rootNode$type$name2 = rootNode.type.name) !== null && _rootNode$type$name2 !== void 0 ? _rootNode$type$name2 : ''));
|
|
26
|
+
} else {
|
|
27
|
+
var _rootNode$type$name3, _rootNode$type$name4;
|
|
28
|
+
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.showDragHandleAt(rootPos, '', (_rootNode$type$name3 = rootNode.type.name) !== null && _rootNode$type$name3 !== void 0 ? _rootNode$type$name3 : '', undefined, rootPos, '', (_rootNode$type$name4 = rootNode.type.name) !== null && _rootNode$type$name4 !== void 0 ? _rootNode$type$name4 : ''));
|
|
29
|
+
}
|
|
18
30
|
} else {
|
|
19
31
|
var isDragHandle = event.target.closest(expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) ? DRAG_HANDLE_SELECTOR : '[data-editor-block-ctrl-drag-handle]') !== null;
|
|
20
32
|
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(isDragHandle));
|
|
@@ -93,10 +93,20 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
|
|
|
93
93
|
rootElement = parentElement;
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
+
var anchorName;
|
|
97
|
+
if (expValEquals('platform_editor_native_anchor_support', 'isEnabled', true)) {
|
|
98
|
+
anchorName = rootElement.getAttribute(getAnchorAttrName());
|
|
99
|
+
|
|
100
|
+
// don't show handles if we can't find an anchor
|
|
101
|
+
if (!anchorName) {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
} else {
|
|
105
|
+
// Ignored via go/ees005
|
|
106
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
107
|
+
anchorName = rootElement.getAttribute(getAnchorAttrName());
|
|
108
|
+
}
|
|
96
109
|
|
|
97
|
-
// Ignored via go/ees005
|
|
98
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
99
|
-
var anchorName = rootElement.getAttribute(getAnchorAttrName());
|
|
100
110
|
// No need to update handle position if its already there
|
|
101
111
|
if ((activeNode === null || activeNode === void 0 ? void 0 : activeNode.anchorName) === anchorName) {
|
|
102
112
|
return false;
|
|
@@ -3,7 +3,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
4
|
import rafSchedule from 'raf-schd';
|
|
5
5
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
6
|
-
import { browser } from '@atlaskit/editor-common/browser';
|
|
6
|
+
import { browser as browserLegacy, getBrowserInfo } from '@atlaskit/editor-common/browser';
|
|
7
7
|
import { isMeasuring, startMeasure, stopMeasure } from '@atlaskit/editor-common/performance-measures';
|
|
8
8
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
9
9
|
import { DRAG_HANDLE_SELECTOR } from '@atlaskit/editor-common/styles';
|
|
@@ -289,6 +289,7 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
|
|
|
289
289
|
if (activeNode && (meta === null || meta === void 0 ? void 0 : meta.isDragging) !== true) {
|
|
290
290
|
var _mappedRootPos$pos, _mappedRootPos;
|
|
291
291
|
var _mappedPos;
|
|
292
|
+
var browser = expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) ? getBrowserInfo() : browserLegacy;
|
|
292
293
|
// In safari, when platform_editor_controls is on,
|
|
293
294
|
// sometimes the drag handle for the layout disppears after you click on the handle for a few times
|
|
294
295
|
// Which caused the drag handle onClick event not firing, then block menu wouldn't be opened
|
|
@@ -496,7 +497,7 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
|
|
|
496
497
|
}
|
|
497
498
|
}
|
|
498
499
|
var isEmptyDoc = isEmptyDocument(newState.doc);
|
|
499
|
-
if (isEmptyDoc) {
|
|
500
|
+
if (isEmptyDoc && !expValEquals('platform_editor_native_anchor_support', 'isEnabled', true)) {
|
|
500
501
|
var hasNodeDecoration = !!findNodeDecs(newState, decorations).length;
|
|
501
502
|
if (!hasNodeDecoration) {
|
|
502
503
|
decorations = decorations.add(newState.doc, [emptyParagraphNodeDecorations()]);
|
|
@@ -14,7 +14,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
|
14
14
|
import { css, jsx } from '@emotion/react';
|
|
15
15
|
import { bind } from 'bind-event-listener';
|
|
16
16
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
17
|
-
import { browser } from '@atlaskit/editor-common/browser';
|
|
17
|
+
import { browser as browserLegacy, getBrowserInfo } from '@atlaskit/editor-common/browser';
|
|
18
18
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
19
19
|
import { dragToMoveDown, dragToMoveLeft, dragToMoveRight, dragToMoveUp, getAriaKeyshortcuts, TooltipContentWithMultipleShortcuts } from '@atlaskit/editor-common/keymaps';
|
|
20
20
|
import { blockControlsMessages } from '@atlaskit/editor-common/messages';
|
|
@@ -245,6 +245,7 @@ var selectedStyles = css({
|
|
|
245
245
|
// icon span receives dragStart event, instead of button, and since it is not registered as a draggable element
|
|
246
246
|
// with pragmatic DnD and pragmatic DnD is not triggered
|
|
247
247
|
var handleIconDragStart = function handleIconDragStart(e) {
|
|
248
|
+
var browser = expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) ? getBrowserInfo() : browserLegacy;
|
|
248
249
|
if (!browser.chrome) {
|
|
249
250
|
return;
|
|
250
251
|
}
|
|
@@ -944,6 +945,7 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
944
945
|
editorExperiment('platform_editor_element_drag_and_drop_multiselect', true) && event.stopPropagation();
|
|
945
946
|
};
|
|
946
947
|
var hasHadInteraction = interactionState !== 'hasNotHadInteraction';
|
|
948
|
+
var browser = expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) ? getBrowserInfo() : browserLegacy;
|
|
947
949
|
var renderButton = function renderButton() {
|
|
948
950
|
return (
|
|
949
951
|
// eslint-disable-next-line @atlaskit/design-system/no-html-button
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _typeof from "@babel/runtime/helpers/typeof";
|
|
2
|
-
import { browser } from '@atlaskit/editor-common/browser';
|
|
2
|
+
import { browser as browserLegacy, getBrowserInfo } from '@atlaskit/editor-common/browser';
|
|
3
3
|
import { N20, N30 } from '@atlaskit/theme/colors';
|
|
4
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
4
5
|
var previewStyle = {
|
|
5
6
|
borderColor: "var(--ds-border, ".concat(N30, ")"),
|
|
6
7
|
borderStyle: 'solid',
|
|
@@ -62,6 +63,7 @@ var createContentPreviewElement = function createContentPreviewElement(dom, node
|
|
|
62
63
|
// Ignored via go/ees005
|
|
63
64
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
64
65
|
dom.cloneNode(true);
|
|
66
|
+
var browser = expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) ? getBrowserInfo() : browserLegacy;
|
|
65
67
|
clonedDom.style.marginLeft = '0';
|
|
66
68
|
clonedDom.style.marginTop = nodeSpacing ? "".concat(nodeSpacing.top) : '0';
|
|
67
69
|
clonedDom.style.marginRight = '0';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "7.2.
|
|
3
|
+
"version": "7.2.12",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@atlaskit/editor-plugin-analytics": "^6.1.0",
|
|
34
34
|
"@atlaskit/editor-plugin-editor-disabled": "^6.1.0",
|
|
35
35
|
"@atlaskit/editor-plugin-feature-flags": "^5.0.0",
|
|
36
|
-
"@atlaskit/editor-plugin-interaction": "^
|
|
36
|
+
"@atlaskit/editor-plugin-interaction": "^9.0.0",
|
|
37
37
|
"@atlaskit/editor-plugin-limited-mode": "^3.0.0",
|
|
38
38
|
"@atlaskit/editor-plugin-metrics": "^7.0.0",
|
|
39
39
|
"@atlaskit/editor-plugin-quick-insert": "^6.0.0",
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^3.2.0",
|
|
53
53
|
"@atlaskit/primitives": "^15.0.0",
|
|
54
54
|
"@atlaskit/theme": "^21.0.0",
|
|
55
|
-
"@atlaskit/tmp-editor-statsig": "^13.
|
|
56
|
-
"@atlaskit/tokens": "^
|
|
55
|
+
"@atlaskit/tmp-editor-statsig": "^13.13.0",
|
|
56
|
+
"@atlaskit/tokens": "^7.0.0",
|
|
57
57
|
"@atlaskit/tooltip": "^20.5.0",
|
|
58
58
|
"@babel/runtime": "^7.0.0",
|
|
59
59
|
"@emotion/react": "^11.7.1",
|