@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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 34.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`9ab5a817ea01c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9ab5a817ea01c) -
|
|
8
|
+
Clean up the `cc_maui_remix_button_hover_corridor` experiment, retaining the shipped
|
|
9
|
+
`isEnabled: true` Remix button hover corridor behaviour and removing the experiment from the
|
|
10
|
+
editor experiments config.
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
13
|
+
## 34.0.0
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [`cabf3c7e59b8d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/cabf3c7e59b8d) -
|
|
18
|
+
Remove internal uses of the always-true `areToolbarFlagsEnabled` helper and delete legacy toolbar
|
|
19
|
+
code that only rendered when it returned false (`ScrollButtons`, `LinkToolbarAppearance`,
|
|
20
|
+
`HyperlinkToolbarAppearance` and the media `LayoutGroup`).
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
|
|
3
23
|
## 33.0.0
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -10,7 +10,6 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
|
|
|
10
10
|
var _react = _interopRequireDefault(require("react"));
|
|
11
11
|
var _surfaceKeys = require("@atlaskit/editor-common/block-controls/surface-keys");
|
|
12
12
|
var _selection = require("@atlaskit/editor-common/selection");
|
|
13
|
-
var _toolbarFlagCheck = require("@atlaskit/editor-common/toolbar-flag-check");
|
|
14
13
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
15
14
|
var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
16
15
|
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
@@ -177,7 +176,7 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
|
|
|
177
176
|
// Not registered under the registry migration: the decoration puts an inline
|
|
178
177
|
// `margin-top: 0` on the first document node, which fights features that render their own
|
|
179
178
|
// content above it — a leading show-diff widget is left flush against the node below.
|
|
180
|
-
if (
|
|
179
|
+
if (!registryBlockControlsEnabled) {
|
|
181
180
|
pmPlugins.push({
|
|
182
181
|
name: 'firstNodeDec',
|
|
183
182
|
plugin: _firstNodeDecPlugin.firstNodeDecPlugin
|
|
@@ -466,7 +466,7 @@ var moveNode = exports.moveNode = function moveNode(api) {
|
|
|
466
466
|
}
|
|
467
467
|
var sliceSize = sliceTo - sliceFrom;
|
|
468
468
|
if (inputMethod === _enums.INPUT_METHOD.DRAG_AND_DROP) {
|
|
469
|
-
tr = (0, _getSelection.setCursorPositionAtMovedNode)(tr, mappedTo
|
|
469
|
+
tr = (0, _getSelection.setCursorPositionAtMovedNode)(tr, mappedTo);
|
|
470
470
|
} else if (preservedSelection) {
|
|
471
471
|
var _currMeta = tr.getMeta(_main.key);
|
|
472
472
|
var nodeMovedOffset = mappedTo - sliceFrom;
|
|
@@ -8,7 +8,6 @@ exports.handleMouseOver = void 0;
|
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
9
|
var _memoizeOne = _interopRequireDefault(require("memoize-one"));
|
|
10
10
|
var _utils = require("@atlaskit/editor-common/selection/utils");
|
|
11
|
-
var _toolbarFlagCheck = require("@atlaskit/editor-common/toolbar-flag-check");
|
|
12
11
|
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
13
12
|
var _fg = require("@atlaskit/platform-feature-flags/fg");
|
|
14
13
|
var _editorExperiment = require("@atlaskit/tmp-editor-statsig/editor-experiment");
|
|
@@ -109,7 +108,6 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, e
|
|
|
109
108
|
editorDisabled = _ref2.editorDisabled;
|
|
110
109
|
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;
|
|
111
110
|
var isViewMode = editorViewMode === 'view';
|
|
112
|
-
var toolbarFlagsEnabled = (0, _toolbarFlagCheck.areToolbarFlagsEnabled)(Boolean(api === null || api === void 0 ? void 0 : api.toolbar));
|
|
113
111
|
|
|
114
112
|
// EDITOR-7926: bail out while a diff is on screen (or a suggestion card is open) so hovering
|
|
115
113
|
// doesn't dispatch showDragHandleAt and cause the drag handle to jitter over the diff.
|
|
@@ -253,47 +251,37 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, e
|
|
|
253
251
|
var targetPos = view.state.doc.resolve(pos).pos;
|
|
254
252
|
var rootAnchorName;
|
|
255
253
|
var rootNodeType;
|
|
256
|
-
var rootPos;
|
|
257
|
-
|
|
258
254
|
// enables quick insert
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
(_rootDOM$getAttribute2 = rootDOM.getAttribute('data-drag-handler-node-type')) !== null && _rootDOM$getAttribute2 !== void 0 ? _rootDOM$getAttribute2 : (0, _domAttrName.getTypeNameFromDom)(rootDOM);
|
|
269
|
-
}
|
|
255
|
+
var rootPos = view.state.doc.resolve(pos).before(1);
|
|
256
|
+
if (targetPos !== rootPos) {
|
|
257
|
+
var rootDOM = view.nodeDOM(rootPos);
|
|
258
|
+
if (rootDOM instanceof HTMLElement) {
|
|
259
|
+
var _ref4, _rootDOM$getAttribute, _rootDOM$getAttribute2;
|
|
260
|
+
rootAnchorName = (_ref4 = (_rootDOM$getAttribute = rootDOM.getAttribute((0, _domAttrName.getAnchorAttrName)())) !== null && _rootDOM$getAttribute !== void 0 ? _rootDOM$getAttribute : rootDOM.getAttribute(_domAttrName.NODE_ANCHOR_ATTR_NAME)) !== null && _ref4 !== void 0 ? _ref4 : undefined;
|
|
261
|
+
rootNodeType = isNativeAnchorSupported ? (0, _domAttrName.getTypeNameFromDom)(rootDOM) : // Fallback: breakout mark wrappers have no data-drag-handler-node-type;
|
|
262
|
+
// use data-prosemirror-node-name instead.
|
|
263
|
+
(_rootDOM$getAttribute2 = rootDOM.getAttribute('data-drag-handler-node-type')) !== null && _rootDOM$getAttribute2 !== void 0 ? _rootDOM$getAttribute2 : (0, _domAttrName.getTypeNameFromDom)(rootDOM);
|
|
270
264
|
}
|
|
271
265
|
}
|
|
272
266
|
var nodeType = isNativeAnchorSupported ? (0, _domAttrName.getTypeNameFromDom)(rootElement) : // Fallback for table nodes: tr has data-prosemirror-node-name but not data-drag-handler-node-type.
|
|
273
267
|
(_rootElement$getAttri2 = rootElement.getAttribute('data-drag-handler-node-type')) !== null && _rootElement$getAttri2 !== void 0 ? _rootElement$getAttri2 : (0, _domAttrName.getTypeNameFromDom)(rootElement);
|
|
274
268
|
if (nodeType) {
|
|
275
|
-
var _api$userIntent2;
|
|
269
|
+
var _selectionPreservatio, _api$userIntent2;
|
|
276
270
|
// enables quick insert
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
var selection = preservedSelection || view.state.selection;
|
|
281
|
-
var isMultipleSelected = selection && (0, _utils.isMultiBlockSelection)(selection);
|
|
271
|
+
var preservedSelection = (_selectionPreservatio = _pluginKey.selectionPreservationPluginKey.getState(view.state)) === null || _selectionPreservatio === void 0 ? void 0 : _selectionPreservatio.preservedSelection;
|
|
272
|
+
var selection = preservedSelection || view.state.selection;
|
|
273
|
+
var isMultipleSelected = selection && (0, _utils.isMultiBlockSelection)(selection);
|
|
282
274
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
}
|
|
290
|
-
} else {
|
|
291
|
-
var _api$core2, _api$blockControls4;
|
|
292
|
-
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));
|
|
275
|
+
// Only execute when selection is not a multi-selection, block menu is open, and menu is opened via keyboard
|
|
276
|
+
// as when it is a multi-selection, the showDragHandleAt command interfere with selection
|
|
277
|
+
// sometimes makes the multi-selection not continous after block menu is opened with keyboard
|
|
278
|
+
if (!(isMultipleSelected && isMenuOpen && blockMenuOptions !== null && blockMenuOptions !== void 0 && blockMenuOptions.openedViaKeyboard)) {
|
|
279
|
+
var _api$core, _api$blockControls3;
|
|
280
|
+
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));
|
|
293
281
|
}
|
|
294
282
|
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') {
|
|
295
|
-
var _api$
|
|
296
|
-
api === null || api === void 0 || (_api$
|
|
283
|
+
var _api$core2, _api$blockControls4;
|
|
284
|
+
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());
|
|
297
285
|
}
|
|
298
286
|
}
|
|
299
287
|
}
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.handleMouseMove = exports.handleMouseLeave = exports.handleMouseEnter = void 0;
|
|
7
7
|
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
8
|
-
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
9
8
|
var _handleMouseOver = require("../handle-mouse-over");
|
|
10
9
|
var _commands = require("./commands");
|
|
11
10
|
var _constants = require("./constants");
|
|
@@ -87,9 +86,7 @@ var classifyRightMarginPosition = function classifyRightMarginPosition(view, eve
|
|
|
87
86
|
if (event.clientX <= found.rect.right) {
|
|
88
87
|
return null;
|
|
89
88
|
}
|
|
90
|
-
return
|
|
91
|
-
type: 'gap'
|
|
92
|
-
} : {
|
|
89
|
+
return {
|
|
93
90
|
type: 'active',
|
|
94
91
|
block: found.block
|
|
95
92
|
};
|
|
@@ -126,7 +123,7 @@ var processHoverSide = function processHoverSide(view, api) {
|
|
|
126
123
|
// This is more reliable than bounds when controls are in portals outside the editor DOM.
|
|
127
124
|
var rightEdgeElement = target === null || target === void 0 ? void 0 : target.closest(getRightControlSelector());
|
|
128
125
|
if (rightEdgeElement) {
|
|
129
|
-
if (state !== null && state !== void 0 && state.isMouseOut
|
|
126
|
+
if (state !== null && state !== void 0 && state.isMouseOut) {
|
|
130
127
|
(0, _commands.mouseEnter)(view, 'right');
|
|
131
128
|
return;
|
|
132
129
|
}
|
|
@@ -154,11 +151,8 @@ var processHoverSide = function processHoverSide(view, api) {
|
|
|
154
151
|
}, api);
|
|
155
152
|
// mouseenter doesn't fire over the click overlay, so clear isMouseOut here to re-show.
|
|
156
153
|
if (state !== null && state !== void 0 && state.isMouseOut) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
(0, _commands.mouseEnter)(view);
|
|
154
|
+
(0, _commands.mouseEnter)(view, 'right');
|
|
155
|
+
return;
|
|
162
156
|
}
|
|
163
157
|
if ((state === null || state === void 0 ? void 0 : state.hoverSide) !== 'right') {
|
|
164
158
|
(0, _commands.setHoverSide)(view, 'right');
|
|
@@ -166,9 +160,9 @@ var processHoverSide = function processHoverSide(view, api) {
|
|
|
166
160
|
return;
|
|
167
161
|
}
|
|
168
162
|
|
|
169
|
-
//
|
|
170
|
-
//
|
|
171
|
-
if (
|
|
163
|
+
// Explicitly marked control surfaces handle the Rovo area, so the rest of the right margin
|
|
164
|
+
// remains hoverable; only clear hover when past the boundary and not over a block.
|
|
165
|
+
if (event.clientX > getRightMarginBoundary(view) && !blockElement) {
|
|
172
166
|
if (!(state !== null && state !== void 0 && state.isMouseOut)) {
|
|
173
167
|
(0, _commands.clearHoverSide)(view);
|
|
174
168
|
(0, _commands.mouseLeave)(view);
|
|
@@ -186,7 +180,7 @@ var processHoverSide = function processHoverSide(view, api) {
|
|
|
186
180
|
var midpoint = (left + right) / 2;
|
|
187
181
|
var nextHoverSide = event.clientX > midpoint ? 'right' : 'left';
|
|
188
182
|
if ((state === null || state === void 0 ? void 0 : state.hoverSide) !== nextHoverSide) {
|
|
189
|
-
if (state !== null && state !== void 0 && state.isMouseOut && target !== null && target !== void 0 && target.closest(BLOCK_SELECTORS)
|
|
183
|
+
if (state !== null && state !== void 0 && state.isMouseOut && target !== null && target !== void 0 && target.closest(BLOCK_SELECTORS)) {
|
|
190
184
|
(0, _commands.mouseEnter)(view, nextHoverSide);
|
|
191
185
|
return;
|
|
192
186
|
}
|
|
@@ -11,7 +11,6 @@ var _blockControlsSuppression = require("@atlaskit/editor-common/block-controls-
|
|
|
11
11
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
12
12
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
13
13
|
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
14
|
-
var _unsafeExpValNoExposure = require("@atlaskit/platform-feature-experiments/unsafe-exp-val-no-exposure");
|
|
15
14
|
var _constants = require("./constants");
|
|
16
15
|
var _handleKeyDown = require("./handle-key-down");
|
|
17
16
|
var _handleMouseMove = require("./handle-mouse-move");
|
|
@@ -128,22 +127,22 @@ var createInteractionTrackingPlugin = exports.createInteractionTrackingPlugin =
|
|
|
128
127
|
mouseLeaveTimeoutId = null;
|
|
129
128
|
}
|
|
130
129
|
|
|
131
|
-
// Preserve
|
|
130
|
+
// Preserve hover while moving onto block controls or an active click area.
|
|
132
131
|
if (rightSideControlsEnabled && (isMovingToBlockControlsArea(event.relatedTarget) || isOverActiveClickArea(event.relatedTarget, event.clientX))) {
|
|
133
132
|
return;
|
|
134
133
|
}
|
|
135
|
-
if (rightSideControlsEnabled &&
|
|
134
|
+
if (rightSideControlsEnabled && isOverTreatmentClickArea(event.relatedTarget, editorContentArea, event.clientX)) {
|
|
136
135
|
return;
|
|
137
136
|
}
|
|
138
137
|
mouseLeaveTimeoutId = setTimeout(function () {
|
|
139
138
|
mouseLeaveTimeoutId = null;
|
|
140
|
-
// Re-check
|
|
139
|
+
// Re-check hover targets after the debounce.
|
|
141
140
|
if (rightSideControlsEnabled && typeof document !== 'undefined') {
|
|
142
141
|
var el = document.elementFromPoint(lastMousePosition.x, lastMousePosition.y);
|
|
143
142
|
if (el && (isMovingToBlockControlsArea(el) || isOverActiveClickArea(el, lastMousePosition.x))) {
|
|
144
143
|
return;
|
|
145
144
|
}
|
|
146
|
-
if (el &&
|
|
145
|
+
if (el && isOverTreatmentClickArea(el, editorContentArea, lastMousePosition.x)) {
|
|
147
146
|
return;
|
|
148
147
|
}
|
|
149
148
|
}
|
|
@@ -185,25 +184,13 @@ var createInteractionTrackingPlugin = exports.createInteractionTrackingPlugin =
|
|
|
185
184
|
};
|
|
186
185
|
if (editorContentArea) {
|
|
187
186
|
if (rightSideControlsEnabled && typeof document !== 'undefined') {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
passive: true
|
|
196
|
-
}
|
|
197
|
-
});
|
|
198
|
-
} else {
|
|
199
|
-
unbindDocumentMouseMove = (0, _bindEventListener.bind)(document, {
|
|
200
|
-
type: 'mousemove',
|
|
201
|
-
listener: handleDocumentMouseMove,
|
|
202
|
-
options: {
|
|
203
|
-
passive: true
|
|
204
|
-
}
|
|
205
|
-
});
|
|
206
|
-
}
|
|
187
|
+
unbindDocumentMouseMove = (0, _bindEventListener.bind)(document, {
|
|
188
|
+
type: 'mousemove',
|
|
189
|
+
listener: handleTreatmentDocumentMouseMove,
|
|
190
|
+
options: {
|
|
191
|
+
passive: true
|
|
192
|
+
}
|
|
193
|
+
});
|
|
207
194
|
}
|
|
208
195
|
unbindMouseEnter = (0, _bindEventListener.bind)(editorContentArea, {
|
|
209
196
|
type: 'mouseenter',
|