@atlaskit/editor-plugin-block-controls 33.0.0 → 34.0.1
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 +20 -0
- package/dist/cjs/blockControlsPlugin.js +1 -2
- package/dist/cjs/editor-commands/move-node.js +1 -1
- package/dist/cjs/pm-plugins/handle-mouse-over.js +21 -33
- package/dist/cjs/pm-plugins/interaction-tracking/handle-mouse-move.js +8 -14
- package/dist/cjs/pm-plugins/interaction-tracking/pm-plugin.js +11 -24
- package/dist/cjs/pm-plugins/main.js +115 -170
- package/dist/cjs/pm-plugins/utils/getSelection.js +2 -3
- package/dist/cjs/pm-plugins/utils/transactions.js +2 -5
- package/dist/cjs/ui/global-styles.js +1 -19
- package/dist/es2019/blockControlsPlugin.js +1 -2
- package/dist/es2019/editor-commands/move-node.js +1 -1
- package/dist/es2019/pm-plugins/handle-mouse-over.js +21 -33
- package/dist/es2019/pm-plugins/interaction-tracking/handle-mouse-move.js +8 -14
- package/dist/es2019/pm-plugins/interaction-tracking/pm-plugin.js +11 -24
- package/dist/es2019/pm-plugins/main.js +85 -138
- package/dist/es2019/pm-plugins/utils/getSelection.js +2 -3
- package/dist/es2019/pm-plugins/utils/transactions.js +2 -5
- package/dist/es2019/ui/global-styles.js +1 -22
- package/dist/esm/blockControlsPlugin.js +1 -2
- package/dist/esm/editor-commands/move-node.js +1 -1
- package/dist/esm/pm-plugins/handle-mouse-over.js +21 -33
- package/dist/esm/pm-plugins/interaction-tracking/handle-mouse-move.js +8 -14
- package/dist/esm/pm-plugins/interaction-tracking/pm-plugin.js +11 -24
- package/dist/esm/pm-plugins/main.js +115 -170
- package/dist/esm/pm-plugins/utils/getSelection.js +2 -3
- package/dist/esm/pm-plugins/utils/transactions.js +2 -5
- package/dist/esm/ui/global-styles.js +1 -19
- package/dist/types/pm-plugins/main.d.ts +1 -4
- package/dist/types/pm-plugins/utils/getSelection.d.ts +1 -1
- package/dist/types/pm-plugins/utils/transactions.d.ts +1 -2
- package/package.json +25 -22
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
import { css, Global, jsx } from '@emotion/react';
|
|
7
7
|
import { DRAG_HANDLE_WIDTH } from '@atlaskit/editor-common/styles/drag-handle';
|
|
8
8
|
import { ANCHOR_VARIABLE_NAME, isCSSAnchorSupported } from '@atlaskit/editor-common/styles/native-anchor';
|
|
9
|
-
import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
|
|
10
9
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/useSharedPluginStateWithSelector';
|
|
11
10
|
import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/whitespace/whitespace';
|
|
12
11
|
import { akEditorBreakoutPadding, akEditorCalculatedWideLayoutWidth, akEditorCalculatedWideLayoutWidthSmallViewport, akEditorFullPageNarrowBreakout, akEditorGutterPaddingDynamic, akEditorGutterPaddingReduced } from '@atlaskit/editor-shared-styles/constants';
|
|
@@ -248,27 +247,10 @@ const extendedDragZoneNext = css({
|
|
|
248
247
|
}
|
|
249
248
|
}
|
|
250
249
|
});
|
|
251
|
-
const paragraphWithTrailingBreakAsOnlyChild = '+ :is(p, h1, h2, h3, h4, h5, h6) > .ProseMirror-trailingBreak:only-child';
|
|
252
|
-
const indentatedParagraphWithTrailingBreakAsOnlyChild = '+ div.fabric-editor-indentation-mark > :is(p, h1, h2, h3, h4, h5, h6) > .ProseMirror-trailingBreak:only-child';
|
|
253
|
-
const paragraphWithPlaceholder = '+ p > .placeholder-decoration';
|
|
254
250
|
const dragHandleContainer = '.ProseMirror-widget[data-blocks-drag-handle-container="true"]';
|
|
255
|
-
const dragHandleSelector = 'button[data-testid="block-ctrl-drag-handle"]';
|
|
256
251
|
const dropTargetContainer = '.ProseMirror-widget[data-blocks-drop-target-container="true"]';
|
|
257
252
|
const dividerBodiedInCustomPanelWithNoIconSelector = '[data-panel-type].ak-editor-panel__no-icon .ProseMirror-widget:first-child + .ProseMirror-widget:nth-child(2) + hr, [data-panel-type] hr:first-child';
|
|
258
|
-
const withInlineNodeStyleSelectors = [`${dragHandleContainer}:has(${paragraphWithTrailingBreakAsOnlyChild}) ${dragHandleSelector}`, `${dragHandleContainer}:has(${indentatedParagraphWithTrailingBreakAsOnlyChild}) ${dragHandleSelector}`, `${dragHandleContainer}:has(${paragraphWithPlaceholder}) ${dragHandleSelector}`].join(', ');
|
|
259
253
|
const withFormatInLayoutStyleFixSelectors = [`${dragHandleContainer}:first-child + .fabric-editor-indentation-mark > p:first-child`, `${dragHandleContainer}:first-child + .fabric-editor-alignment > p:first-child`, `${dragHandleContainer}:first-child + .fabric-editor-font-size > p:first-child`, `${dragHandleContainer}:first-child + ${dropTargetContainer} + .fabric-editor-indentation-mark > p:first-child`, `${dragHandleContainer}:first-child + ${dropTargetContainer} + .fabric-editor-alignment > p:first-child`, `${dragHandleContainer}:first-child + ${dropTargetContainer} + .fabric-editor-font-size > p:first-child`, `${dropTargetContainer}:first-child + .fabric-editor-alignment > p:first-child`, `${dropTargetContainer}:first-child + .fabric-editor-indentation-mark > p:first-child`, `${dropTargetContainer}:first-child + .fabric-editor-font-size > p:first-child`, `${dragHandleContainer}:first-child + .fabric-editor-indentation-mark > :is(h1, h2, h3, h4, h5, h6):first-child`, `${dragHandleContainer}:first-child + .fabric-editor-font-size > :is(h1, h2, h3, h4, h5, h6):first-child`].join(', ');
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
* Please do not change change transform to display:none, or visibility:hidden
|
|
263
|
-
* Otherwise it might break composition input for Chrome
|
|
264
|
-
* https://product-fabric.atlassian.net/browse/ED-24136
|
|
265
|
-
*/
|
|
266
|
-
const withInlineNodeStyle = css({
|
|
267
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
268
|
-
[withInlineNodeStyleSelectors]: {
|
|
269
|
-
transform: 'scale(0)'
|
|
270
|
-
}
|
|
271
|
-
});
|
|
272
254
|
const legacyBreakoutWideLayoutStyle = css({
|
|
273
255
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
274
256
|
'.ProseMirror-widget[data-blocks-drop-target-container="true"]': {
|
|
@@ -587,15 +569,12 @@ export const GlobalStylesWrapper = ({
|
|
|
587
569
|
const isDragging = isDraggingFromState;
|
|
588
570
|
const shouldRenderAnchors = isCSSAnchorSupported() && expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true);
|
|
589
571
|
const sparseSurfaceAnchorsEnabled = Boolean(isCSSAnchorSupported()) && sparseSurfacesEnabled;
|
|
590
|
-
const toolbarFlagsEnabled = areToolbarFlagsEnabled(Boolean(api === null || api === void 0 ? void 0 : api.toolbar));
|
|
591
572
|
return jsx(Global
|
|
592
573
|
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
593
574
|
, {
|
|
594
575
|
styles: [globalStyles(), globalDnDStyle, (!sparseSurfacesEnabled || isDragging) && (expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || isExperimentEnabled('platform_editor_block_control_migration') ? extendedHoverZoneNext() : extendedHoverZone()), isDragging && (expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || isExperimentEnabled('platform_editor_block_control_migration') ? extendedDragZoneNext : extendedDragZone), (!sparseSurfacesEnabled || isDragging) && editorExperiment('platform_editor_preview_panel_responsiveness', true, {
|
|
595
576
|
exposure: true
|
|
596
|
-
}) ? expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || isExperimentEnabled('platform_editor_block_control_migration') ? extendHoverZoneReducedNext : extendHoverZoneReduced : undefined,
|
|
597
|
-
// this allows drag handles to render on empty lines
|
|
598
|
-
toolbarFlagsEnabled ? undefined : withInlineNodeStyle, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, isExperimentEnabled('platform_editor_lovability_dividers') && withRuleOverflowStyleFix, withFormatInLayoutStyleFix, (!sparseSurfacesEnabled || isDragging) && (expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || isExperimentEnabled('platform_editor_block_control_migration') ? withRelativePosStyleNext : withRelativePosStyle), (!sparseSurfacesEnabled || isDragging) && (expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || isExperimentEnabled('platform_editor_block_control_migration') ? withAnchorNameZindexStyleNext : withAnchorNameZindexStyle), (!sparseSurfacesEnabled || isDragging) && ((expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || isExperimentEnabled('platform_editor_block_control_migration')) && expValEquals('advanced_layouts', 'isEnabled', true) ? layoutColumnExtendedHoverZone : layoutColumnWithoutHoverZone), sparseSurfaceAnchorsEnabled ? isDragging ? dragAnchorStyles : false : expValEquals('platform_editor_controls_reliable_anchor', 'isEnabled', true) ?
|
|
577
|
+
}) ? expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || isExperimentEnabled('platform_editor_block_control_migration') ? extendHoverZoneReducedNext : extendHoverZoneReduced : undefined, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, isExperimentEnabled('platform_editor_lovability_dividers') && withRuleOverflowStyleFix, withFormatInLayoutStyleFix, (!sparseSurfacesEnabled || isDragging) && (expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || isExperimentEnabled('platform_editor_block_control_migration') ? withRelativePosStyleNext : withRelativePosStyle), (!sparseSurfacesEnabled || isDragging) && (expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || isExperimentEnabled('platform_editor_block_control_migration') ? withAnchorNameZindexStyleNext : withAnchorNameZindexStyle), (!sparseSurfacesEnabled || isDragging) && ((expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || isExperimentEnabled('platform_editor_block_control_migration')) && expValEquals('advanced_layouts', 'isEnabled', true) ? layoutColumnExtendedHoverZone : layoutColumnWithoutHoverZone), sparseSurfaceAnchorsEnabled ? isDragging ? dragAnchorStyles : false : expValEquals('platform_editor_controls_reliable_anchor', 'isEnabled', true) ?
|
|
599
578
|
// dragAnchorStyles sets anchor-name on ALL nodes during drag (needed for drop target positioning).
|
|
600
579
|
// staticControlsAnchorStyles handles anchor-name via node decorations for non-drag state.
|
|
601
580
|
// shouldRenderAnchors guards both: only apply anchor styles on browsers that support CSS anchor positioning.
|
|
@@ -5,7 +5,6 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { BLOCK_CONTROLS_LEFT_GROUP, BLOCK_CONTROLS_LEFT_SECTION, BLOCK_CONTROLS_LEFT_SURFACE, BLOCK_CONTROLS_RIGHT_GROUP, BLOCK_CONTROLS_RIGHT_SECTION, BLOCK_CONTROLS_RIGHT_SURFACE } from '@atlaskit/editor-common/block-controls/surface-keys';
|
|
7
7
|
import { expandSelectionBounds } from '@atlaskit/editor-common/selection';
|
|
8
|
-
import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
|
|
9
8
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
10
9
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
11
10
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
@@ -170,7 +169,7 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
|
170
169
|
// Not registered under the registry migration: the decoration puts an inline
|
|
171
170
|
// `margin-top: 0` on the first document node, which fights features that render their own
|
|
172
171
|
// content above it — a leading show-diff widget is left flush against the node below.
|
|
173
|
-
if (
|
|
172
|
+
if (!registryBlockControlsEnabled) {
|
|
174
173
|
pmPlugins.push({
|
|
175
174
|
name: 'firstNodeDec',
|
|
176
175
|
plugin: firstNodeDecPlugin
|
|
@@ -460,7 +460,7 @@ export var moveNode = function moveNode(api) {
|
|
|
460
460
|
}
|
|
461
461
|
var sliceSize = sliceTo - sliceFrom;
|
|
462
462
|
if (inputMethod === INPUT_METHOD.DRAG_AND_DROP) {
|
|
463
|
-
tr = setCursorPositionAtMovedNode(tr, mappedTo
|
|
463
|
+
tr = setCursorPositionAtMovedNode(tr, mappedTo);
|
|
464
464
|
} else if (preservedSelection) {
|
|
465
465
|
var _currMeta = tr.getMeta(key);
|
|
466
466
|
var nodeMovedOffset = mappedTo - sliceFrom;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
2
|
import memoizeOne from 'memoize-one';
|
|
3
3
|
import { isMultiBlockSelection } from '@atlaskit/editor-common/selection/utils';
|
|
4
|
-
import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
|
|
5
4
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
6
5
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
7
6
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
@@ -102,7 +101,6 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
|
|
|
102
101
|
editorDisabled = _ref2.editorDisabled;
|
|
103
102
|
var editorViewMode = api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 || (_api$editorViewMode = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.mode;
|
|
104
103
|
var isViewMode = editorViewMode === 'view';
|
|
105
|
-
var toolbarFlagsEnabled = areToolbarFlagsEnabled(Boolean(api === null || api === void 0 ? void 0 : api.toolbar));
|
|
106
104
|
|
|
107
105
|
// EDITOR-7926: bail out while a diff is on screen (or a suggestion card is open) so hovering
|
|
108
106
|
// doesn't dispatch showDragHandleAt and cause the drag handle to jitter over the diff.
|
|
@@ -246,47 +244,37 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
|
|
|
246
244
|
var targetPos = view.state.doc.resolve(pos).pos;
|
|
247
245
|
var rootAnchorName;
|
|
248
246
|
var rootNodeType;
|
|
249
|
-
var rootPos;
|
|
250
|
-
|
|
251
247
|
// enables quick insert
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
(_rootDOM$getAttribute2 = rootDOM.getAttribute('data-drag-handler-node-type')) !== null && _rootDOM$getAttribute2 !== void 0 ? _rootDOM$getAttribute2 : getTypeNameFromDom(rootDOM);
|
|
262
|
-
}
|
|
248
|
+
var rootPos = view.state.doc.resolve(pos).before(1);
|
|
249
|
+
if (targetPos !== rootPos) {
|
|
250
|
+
var rootDOM = view.nodeDOM(rootPos);
|
|
251
|
+
if (rootDOM instanceof HTMLElement) {
|
|
252
|
+
var _ref4, _rootDOM$getAttribute, _rootDOM$getAttribute2;
|
|
253
|
+
rootAnchorName = (_ref4 = (_rootDOM$getAttribute = rootDOM.getAttribute(getAnchorAttrName())) !== null && _rootDOM$getAttribute !== void 0 ? _rootDOM$getAttribute : rootDOM.getAttribute(NODE_ANCHOR_ATTR_NAME)) !== null && _ref4 !== void 0 ? _ref4 : undefined;
|
|
254
|
+
rootNodeType = isNativeAnchorSupported ? getTypeNameFromDom(rootDOM) : // Fallback: breakout mark wrappers have no data-drag-handler-node-type;
|
|
255
|
+
// use data-prosemirror-node-name instead.
|
|
256
|
+
(_rootDOM$getAttribute2 = rootDOM.getAttribute('data-drag-handler-node-type')) !== null && _rootDOM$getAttribute2 !== void 0 ? _rootDOM$getAttribute2 : getTypeNameFromDom(rootDOM);
|
|
263
257
|
}
|
|
264
258
|
}
|
|
265
259
|
var nodeType = isNativeAnchorSupported ? getTypeNameFromDom(rootElement) : // Fallback for table nodes: tr has data-prosemirror-node-name but not data-drag-handler-node-type.
|
|
266
260
|
(_rootElement$getAttri2 = rootElement.getAttribute('data-drag-handler-node-type')) !== null && _rootElement$getAttri2 !== void 0 ? _rootElement$getAttri2 : getTypeNameFromDom(rootElement);
|
|
267
261
|
if (nodeType) {
|
|
268
|
-
var _api$userIntent2;
|
|
262
|
+
var _selectionPreservatio, _api$userIntent2;
|
|
269
263
|
// enables quick insert
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
var selection = preservedSelection || view.state.selection;
|
|
274
|
-
var isMultipleSelected = selection && isMultiBlockSelection(selection);
|
|
264
|
+
var preservedSelection = (_selectionPreservatio = selectionPreservationPluginKey.getState(view.state)) === null || _selectionPreservatio === void 0 ? void 0 : _selectionPreservatio.preservedSelection;
|
|
265
|
+
var selection = preservedSelection || view.state.selection;
|
|
266
|
+
var isMultipleSelected = selection && isMultiBlockSelection(selection);
|
|
275
267
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
}
|
|
283
|
-
} else {
|
|
284
|
-
var _api$core2, _api$blockControls4;
|
|
285
|
-
api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(api === null || api === void 0 || (_api$blockControls4 = api.blockControls) === null || _api$blockControls4 === void 0 ? void 0 : _api$blockControls4.commands.showDragHandleAt(targetPos, anchorName, nodeType));
|
|
268
|
+
// Only execute when selection is not a multi-selection, block menu is open, and menu is opened via keyboard
|
|
269
|
+
// as when it is a multi-selection, the showDragHandleAt command interfere with selection
|
|
270
|
+
// sometimes makes the multi-selection not continous after block menu is opened with keyboard
|
|
271
|
+
if (!(isMultipleSelected && isMenuOpen && blockMenuOptions !== null && blockMenuOptions !== void 0 && blockMenuOptions.openedViaKeyboard)) {
|
|
272
|
+
var _api$core, _api$blockControls3;
|
|
273
|
+
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api === null || api === void 0 || (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 ? void 0 : _api$blockControls3.commands.showDragHandleAt(targetPos, anchorName, nodeType, undefined, rootPos, rootAnchorName !== null && rootAnchorName !== void 0 ? rootAnchorName : anchorName, rootNodeType !== null && rootNodeType !== void 0 ? rootNodeType : nodeType));
|
|
286
274
|
}
|
|
287
275
|
if (isMenuOpen && originalAnchorName && (api === null || api === void 0 || (_api$userIntent2 = api.userIntent) === null || _api$userIntent2 === void 0 || (_api$userIntent2 = _api$userIntent2.sharedState.currentState()) === null || _api$userIntent2 === void 0 ? void 0 : _api$userIntent2.currentUserIntent) === 'blockMenuOpen') {
|
|
288
|
-
var _api$
|
|
289
|
-
api === null || api === void 0 || (_api$
|
|
276
|
+
var _api$core2, _api$blockControls4;
|
|
277
|
+
api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(api === null || api === void 0 || (_api$blockControls4 = api.blockControls) === null || _api$blockControls4 === void 0 ? void 0 : _api$blockControls4.commands.toggleBlockMenu());
|
|
290
278
|
}
|
|
291
279
|
}
|
|
292
280
|
}
|
|
@@ -2,7 +2,6 @@ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol
|
|
|
2
2
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
3
3
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
4
4
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
5
|
-
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
6
5
|
import { handleMouseOver } from '../handle-mouse-over';
|
|
7
6
|
import { clearHoverSide, mouseEnter, mouseLeave, setHoverSide, stopEditing } from './commands';
|
|
8
7
|
import { RIGHT_MARGIN_ROVO_GAP_PX } from './constants';
|
|
@@ -82,9 +81,7 @@ var classifyRightMarginPosition = function classifyRightMarginPosition(view, eve
|
|
|
82
81
|
if (event.clientX <= found.rect.right) {
|
|
83
82
|
return null;
|
|
84
83
|
}
|
|
85
|
-
return
|
|
86
|
-
type: 'gap'
|
|
87
|
-
} : {
|
|
84
|
+
return {
|
|
88
85
|
type: 'active',
|
|
89
86
|
block: found.block
|
|
90
87
|
};
|
|
@@ -121,7 +118,7 @@ var processHoverSide = function processHoverSide(view, api) {
|
|
|
121
118
|
// This is more reliable than bounds when controls are in portals outside the editor DOM.
|
|
122
119
|
var rightEdgeElement = target === null || target === void 0 ? void 0 : target.closest(getRightControlSelector());
|
|
123
120
|
if (rightEdgeElement) {
|
|
124
|
-
if (state !== null && state !== void 0 && state.isMouseOut
|
|
121
|
+
if (state !== null && state !== void 0 && state.isMouseOut) {
|
|
125
122
|
mouseEnter(view, 'right');
|
|
126
123
|
return;
|
|
127
124
|
}
|
|
@@ -149,11 +146,8 @@ var processHoverSide = function processHoverSide(view, api) {
|
|
|
149
146
|
}, api);
|
|
150
147
|
// mouseenter doesn't fire over the click overlay, so clear isMouseOut here to re-show.
|
|
151
148
|
if (state !== null && state !== void 0 && state.isMouseOut) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
mouseEnter(view);
|
|
149
|
+
mouseEnter(view, 'right');
|
|
150
|
+
return;
|
|
157
151
|
}
|
|
158
152
|
if ((state === null || state === void 0 ? void 0 : state.hoverSide) !== 'right') {
|
|
159
153
|
setHoverSide(view, 'right');
|
|
@@ -161,9 +155,9 @@ var processHoverSide = function processHoverSide(view, api) {
|
|
|
161
155
|
return;
|
|
162
156
|
}
|
|
163
157
|
|
|
164
|
-
//
|
|
165
|
-
//
|
|
166
|
-
if (
|
|
158
|
+
// Explicitly marked control surfaces handle the Rovo area, so the rest of the right margin
|
|
159
|
+
// remains hoverable; only clear hover when past the boundary and not over a block.
|
|
160
|
+
if (event.clientX > getRightMarginBoundary(view) && !blockElement) {
|
|
167
161
|
if (!(state !== null && state !== void 0 && state.isMouseOut)) {
|
|
168
162
|
clearHoverSide(view);
|
|
169
163
|
mouseLeave(view);
|
|
@@ -181,7 +175,7 @@ var processHoverSide = function processHoverSide(view, api) {
|
|
|
181
175
|
var midpoint = (left + right) / 2;
|
|
182
176
|
var nextHoverSide = event.clientX > midpoint ? 'right' : 'left';
|
|
183
177
|
if ((state === null || state === void 0 ? void 0 : state.hoverSide) !== nextHoverSide) {
|
|
184
|
-
if (state !== null && state !== void 0 && state.isMouseOut && target !== null && target !== void 0 && target.closest(BLOCK_SELECTORS)
|
|
178
|
+
if (state !== null && state !== void 0 && state.isMouseOut && target !== null && target !== void 0 && target.closest(BLOCK_SELECTORS)) {
|
|
185
179
|
mouseEnter(view, nextHoverSide);
|
|
186
180
|
return;
|
|
187
181
|
}
|
|
@@ -6,7 +6,6 @@ import { isBlockControlsSuppressionTarget } from '@atlaskit/editor-common/block-
|
|
|
6
6
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
7
7
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
8
8
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
9
|
-
import { UNSAFE_expValNoExposure } from '@atlaskit/platform-feature-experiments/unsafe-exp-val-no-exposure';
|
|
10
9
|
import { RIGHT_MARGIN_ROVO_GAP_PX } from './constants';
|
|
11
10
|
import { handleKeyDown } from './handle-key-down';
|
|
12
11
|
import { handleMouseEnter, handleMouseLeave, handleMouseMove } from './handle-mouse-move';
|
|
@@ -122,22 +121,22 @@ export var createInteractionTrackingPlugin = function createInteractionTrackingP
|
|
|
122
121
|
mouseLeaveTimeoutId = null;
|
|
123
122
|
}
|
|
124
123
|
|
|
125
|
-
// Preserve
|
|
124
|
+
// Preserve hover while moving onto block controls or an active click area.
|
|
126
125
|
if (rightSideControlsEnabled && (isMovingToBlockControlsArea(event.relatedTarget) || isOverActiveClickArea(event.relatedTarget, event.clientX))) {
|
|
127
126
|
return;
|
|
128
127
|
}
|
|
129
|
-
if (rightSideControlsEnabled &&
|
|
128
|
+
if (rightSideControlsEnabled && isOverTreatmentClickArea(event.relatedTarget, editorContentArea, event.clientX)) {
|
|
130
129
|
return;
|
|
131
130
|
}
|
|
132
131
|
mouseLeaveTimeoutId = setTimeout(function () {
|
|
133
132
|
mouseLeaveTimeoutId = null;
|
|
134
|
-
// Re-check
|
|
133
|
+
// Re-check hover targets after the debounce.
|
|
135
134
|
if (rightSideControlsEnabled && typeof document !== 'undefined') {
|
|
136
135
|
var el = document.elementFromPoint(lastMousePosition.x, lastMousePosition.y);
|
|
137
136
|
if (el && (isMovingToBlockControlsArea(el) || isOverActiveClickArea(el, lastMousePosition.x))) {
|
|
138
137
|
return;
|
|
139
138
|
}
|
|
140
|
-
if (el &&
|
|
139
|
+
if (el && isOverTreatmentClickArea(el, editorContentArea, lastMousePosition.x)) {
|
|
141
140
|
return;
|
|
142
141
|
}
|
|
143
142
|
}
|
|
@@ -179,25 +178,13 @@ export var createInteractionTrackingPlugin = function createInteractionTrackingP
|
|
|
179
178
|
};
|
|
180
179
|
if (editorContentArea) {
|
|
181
180
|
if (rightSideControlsEnabled && typeof document !== 'undefined') {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
passive: true
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
} else {
|
|
193
|
-
unbindDocumentMouseMove = bind(document, {
|
|
194
|
-
type: 'mousemove',
|
|
195
|
-
listener: handleDocumentMouseMove,
|
|
196
|
-
options: {
|
|
197
|
-
passive: true
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
}
|
|
181
|
+
unbindDocumentMouseMove = bind(document, {
|
|
182
|
+
type: 'mousemove',
|
|
183
|
+
listener: handleTreatmentDocumentMouseMove,
|
|
184
|
+
options: {
|
|
185
|
+
passive: true
|
|
186
|
+
}
|
|
187
|
+
});
|
|
201
188
|
}
|
|
202
189
|
unbindMouseEnter = bind(editorContentArea, {
|
|
203
190
|
type: 'mouseenter',
|