@atlaskit/editor-plugin-block-controls 7.4.2 → 7.5.0
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 +16 -0
- package/dist/cjs/blockControlsPlugin.js +6 -1
- package/dist/cjs/editor-commands/move-node.js +3 -3
- package/dist/cjs/pm-plugins/handle-mouse-over.js +7 -2
- package/dist/cjs/pm-plugins/main.js +25 -13
- package/dist/cjs/pm-plugins/utils/getSelection.js +7 -7
- package/dist/cjs/pm-plugins/utils/transactions.js +4 -3
- package/dist/cjs/ui/drag-handle.js +23 -23
- package/dist/cjs/ui/global-styles.js +5 -1
- package/dist/es2019/blockControlsPlugin.js +6 -1
- package/dist/es2019/editor-commands/move-node.js +3 -3
- package/dist/es2019/pm-plugins/handle-mouse-over.js +7 -2
- package/dist/es2019/pm-plugins/main.js +25 -13
- package/dist/es2019/pm-plugins/utils/getSelection.js +7 -7
- package/dist/es2019/pm-plugins/utils/transactions.js +4 -3
- package/dist/es2019/ui/drag-handle.js +23 -23
- package/dist/es2019/ui/global-styles.js +5 -1
- package/dist/esm/blockControlsPlugin.js +6 -1
- package/dist/esm/editor-commands/move-node.js +3 -3
- package/dist/esm/pm-plugins/handle-mouse-over.js +7 -2
- package/dist/esm/pm-plugins/main.js +25 -13
- package/dist/esm/pm-plugins/utils/getSelection.js +7 -7
- package/dist/esm/pm-plugins/utils/transactions.js +4 -3
- package/dist/esm/ui/drag-handle.js +23 -23
- package/dist/esm/ui/global-styles.js +5 -1
- package/dist/types/blockControlsPluginType.d.ts +3 -1
- package/dist/types/pm-plugins/main.d.ts +1 -0
- package/dist/types/pm-plugins/utils/getSelection.d.ts +5 -3
- package/dist/types/pm-plugins/utils/transactions.d.ts +2 -1
- package/dist/types-ts4.5/blockControlsPluginType.d.ts +3 -1
- package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/utils/getSelection.d.ts +5 -3
- package/dist/types-ts4.5/pm-plugins/utils/transactions.d.ts +2 -1
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 7.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`f54c8f46bb85f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f54c8f46bb85f) -
|
|
8
|
+
Add @atlaskit/editor-plugin-toolbar as an optional dependency, and check its presence to enable
|
|
9
|
+
the floating insert button
|
|
10
|
+
|
|
11
|
+
## 7.4.3
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`c28cd65d12c24`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c28cd65d12c24) -
|
|
16
|
+
EDITOR-2447 Bump adf-schema to 51.3.1
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 7.4.2
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -8,6 +8,7 @@ exports.blockControlsPlugin = void 0;
|
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _react = _interopRequireDefault(require("react"));
|
|
10
10
|
var _selection = require("@atlaskit/editor-common/selection");
|
|
11
|
+
var _toolbarFlagCheck = require("@atlaskit/editor-common/toolbar-flag-check");
|
|
11
12
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
12
13
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
14
|
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
@@ -43,6 +44,10 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
|
|
|
43
44
|
name: 'blockControlsInteractionTrackingPlugin',
|
|
44
45
|
plugin: _pmPlugin.createInteractionTrackingPlugin
|
|
45
46
|
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// platform_editor_controls note: quick insert rendering fixes
|
|
50
|
+
if ((0, _toolbarFlagCheck.areToolbarFlagsEnabled)(Boolean(api === null || api === void 0 ? void 0 : api.toolbar))) {
|
|
46
51
|
pmPlugins.push({
|
|
47
52
|
name: 'firstNodeDec',
|
|
48
53
|
plugin: _firstNodeDecPlugin.firstNodeDecPlugin
|
|
@@ -197,7 +202,7 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
|
|
|
197
202
|
var $to = $expandedAnchor.max($expandedHead);
|
|
198
203
|
var expandedNormalisedSel;
|
|
199
204
|
if ($from.nodeAfter === $to.nodeBefore) {
|
|
200
|
-
(0, _getSelection.selectNode)(tr, $from.pos, $expandedAnchor.node().type.name);
|
|
205
|
+
(0, _getSelection.selectNode)(tr, $from.pos, $expandedAnchor.node().type.name, api);
|
|
201
206
|
expandedNormalisedSel = tr.selection;
|
|
202
207
|
} else if (((_$to$nodeBefore = $to.nodeBefore) === null || _$to$nodeBefore === void 0 ? void 0 : _$to$nodeBefore.type.name) === 'mediaSingle' || ((_$from$nodeAfter = $from.nodeAfter) === null || _$from$nodeAfter === void 0 ? void 0 : _$from$nodeAfter.type.name) === 'mediaSingle') {
|
|
203
208
|
expandedNormalisedSel = new _state.TextSelection($expandedAnchor, $expandedHead);
|
|
@@ -290,7 +290,7 @@ var moveNodeViaShortcut = exports.moveNodeViaShortcut = function moveNodeViaShor
|
|
|
290
290
|
// If the node is first/last one, only select the node
|
|
291
291
|
api === null || api === void 0 || (_api$core8 = api.core) === null || _api$core8 === void 0 || _api$core8.actions.execute(function (_ref5) {
|
|
292
292
|
var tr = _ref5.tr;
|
|
293
|
-
(0, _getSelection.selectNode)(tr, currentNodePos, nodeType);
|
|
293
|
+
(0, _getSelection.selectNode)(tr, currentNodePos, nodeType, api);
|
|
294
294
|
tr.scrollIntoView();
|
|
295
295
|
return tr;
|
|
296
296
|
});
|
|
@@ -402,9 +402,9 @@ var moveNode = exports.moveNode = function moveNode(api) {
|
|
|
402
402
|
tr.insert(mappedTo, convertedNode);
|
|
403
403
|
}
|
|
404
404
|
var sliceSize = sliceTo - sliceFrom;
|
|
405
|
-
tr = inputMethod === _analytics.INPUT_METHOD.DRAG_AND_DROP ? (0, _getSelection.setCursorPositionAtMovedNode)(tr, mappedTo) : isMultiSelect ? (_api$blockControls$co = api === null || api === void 0 ? void 0 : api.blockControls.commands.setMultiSelectPositions(mappedTo, mappedTo + sliceSize)({
|
|
405
|
+
tr = inputMethod === _analytics.INPUT_METHOD.DRAG_AND_DROP ? (0, _getSelection.setCursorPositionAtMovedNode)(tr, mappedTo, api) : isMultiSelect ? (_api$blockControls$co = api === null || api === void 0 ? void 0 : api.blockControls.commands.setMultiSelectPositions(mappedTo, mappedTo + sliceSize)({
|
|
406
406
|
tr: tr
|
|
407
|
-
})) !== null && _api$blockControls$co !== void 0 ? _api$blockControls$co : tr : (0, _getSelection.selectNode)(tr, mappedTo, handleNode.type.name);
|
|
407
|
+
})) !== null && _api$blockControls$co !== void 0 ? _api$blockControls$co : tr : (0, _getSelection.selectNode)(tr, mappedTo, handleNode.type.name, api);
|
|
408
408
|
var currMeta = tr.getMeta(_main.key);
|
|
409
409
|
tr.setMeta(_main.key, _objectSpread(_objectSpread({}, currMeta), {}, {
|
|
410
410
|
nodeMoved: true
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.handleMouseOver = void 0;
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
9
|
var _memoizeOne = _interopRequireDefault(require("memoize-one"));
|
|
10
|
+
var _toolbarFlagCheck = require("@atlaskit/editor-common/toolbar-flag-check");
|
|
10
11
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
11
12
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
12
13
|
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
@@ -49,6 +50,7 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, e
|
|
|
49
50
|
editorDisabled: false
|
|
50
51
|
},
|
|
51
52
|
editorDisabled = _ref2.editorDisabled;
|
|
53
|
+
var toolbarFlagsEnabled = (0, _toolbarFlagCheck.areToolbarFlagsEnabled)(Boolean(api === null || api === void 0 ? void 0 : api.toolbar));
|
|
52
54
|
|
|
53
55
|
// We shouldn't be firing mouse over transactions when the editor is disabled
|
|
54
56
|
if (editorDisabled && (0, _platformFeatureFlags.fg)('aifc_create_enabled')) {
|
|
@@ -150,7 +152,9 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, e
|
|
|
150
152
|
var rootAnchorName;
|
|
151
153
|
var rootNodeType;
|
|
152
154
|
var rootPos;
|
|
153
|
-
|
|
155
|
+
|
|
156
|
+
// platform_editor_controls note: enables quick insert
|
|
157
|
+
if (toolbarFlagsEnabled) {
|
|
154
158
|
rootPos = view.state.doc.resolve(pos).before(1);
|
|
155
159
|
if (targetPos !== rootPos) {
|
|
156
160
|
var rootDOM = view.nodeDOM(rootPos);
|
|
@@ -163,7 +167,8 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, e
|
|
|
163
167
|
}
|
|
164
168
|
var nodeType = isNativeAnchorSupported ? (0, _domAttrName.getTypeNameFromDom)(rootElement) : rootElement.getAttribute('data-drag-handler-node-type');
|
|
165
169
|
if (nodeType) {
|
|
166
|
-
|
|
170
|
+
// platform_editor_controls note: enables quick insert
|
|
171
|
+
if (toolbarFlagsEnabled) {
|
|
167
172
|
var _api$core, _api$blockControls2;
|
|
168
173
|
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.commands.showDragHandleAt(targetPos, anchorName, nodeType, undefined, rootPos !== null && rootPos !== void 0 ? rootPos : targetPos, rootAnchorName !== null && rootAnchorName !== void 0 ? rootAnchorName : anchorName, rootNodeType !== null && rootNodeType !== void 0 ? rootNodeType : nodeType));
|
|
169
174
|
} else {
|
|
@@ -12,6 +12,7 @@ var _browser = require("@atlaskit/editor-common/browser");
|
|
|
12
12
|
var _performanceMeasures = require("@atlaskit/editor-common/performance-measures");
|
|
13
13
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
14
14
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
15
|
+
var _toolbarFlagCheck = require("@atlaskit/editor-common/toolbar-flag-check");
|
|
15
16
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
16
17
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
17
18
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
@@ -126,7 +127,7 @@ var destroyFn = function destroyFn(api, editorView) {
|
|
|
126
127
|
var $head = tr.doc.resolve(multiSelectDnD.userHead);
|
|
127
128
|
if ($head.node() === $anchor.node()) {
|
|
128
129
|
var $from = $anchor.min($head);
|
|
129
|
-
(0, _getSelection.selectNode)(tr, $from.pos, $from.node().type.name);
|
|
130
|
+
(0, _getSelection.selectNode)(tr, $from.pos, $from.node().type.name, api);
|
|
130
131
|
} else {
|
|
131
132
|
tr.setSelection(_state.TextSelection.create(tr.doc, multiSelectDnD.userAnchor, multiSelectDnD.userHead));
|
|
132
133
|
}
|
|
@@ -257,7 +258,7 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
|
|
|
257
258
|
lastDragCancelled = currentState.lastDragCancelled,
|
|
258
259
|
isSelectedViaDragHandle = currentState.isSelectedViaDragHandle;
|
|
259
260
|
var isActiveNodeDeleted = false;
|
|
260
|
-
var _getTrMetadata = (0, _transactions.getTrMetadata)(tr),
|
|
261
|
+
var _getTrMetadata = (0, _transactions.getTrMetadata)(tr, flags),
|
|
261
262
|
from = _getTrMetadata.from,
|
|
262
263
|
to = _getTrMetadata.to,
|
|
263
264
|
numReplaceSteps = _getTrMetadata.numReplaceSteps,
|
|
@@ -281,8 +282,9 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
|
|
|
281
282
|
if (tr.docChanged) {
|
|
282
283
|
decorations = decorations.map(tr.mapping, tr.doc);
|
|
283
284
|
|
|
285
|
+
// platform_editor_controls note: enables quick insert
|
|
284
286
|
// don't remap activeNode if it's being dragged
|
|
285
|
-
if (
|
|
287
|
+
if (!flags.toolbarFlagsEnabled) {
|
|
286
288
|
if (activeNode) {
|
|
287
289
|
var mappedPos = tr.mapping.mapResult(activeNode.pos);
|
|
288
290
|
isActiveNodeDeleted = mappedPos.deleted;
|
|
@@ -360,7 +362,9 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
|
|
|
360
362
|
decorations = decorations.remove(oldNodeDecs);
|
|
361
363
|
var newNodeDecs = (0, _decorationsAnchor.nodeDecorations)(newState, isDecSetEmpty ? undefined : from, isDecSetEmpty ? undefined : to);
|
|
362
364
|
decorations = decorations.add(newState.doc, newNodeDecs);
|
|
363
|
-
|
|
365
|
+
|
|
366
|
+
// platform_editor_controls note: enables quick insert
|
|
367
|
+
if (!flags.toolbarFlagsEnabled) {
|
|
364
368
|
if (latestActiveNode && !isActiveNodeDeleted) {
|
|
365
369
|
// Find the newly minted node decs that touch the active node
|
|
366
370
|
var findNewNodeDecs = (0, _decorationsAnchor.findNodeDecs)(newState, decorations, (0, _experiments.editorExperiment)('platform_editor_block_control_optimise_render', true) ? latestActiveNode.pos : latestActiveNode.pos - 1, to);
|
|
@@ -417,7 +421,9 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
|
|
|
417
421
|
|
|
418
422
|
// If the active node is missing, we need to remove the handle
|
|
419
423
|
var shouldRemoveHandle = latestActiveNode ? isResizerResizing || isActiveNodeDeleted && !isReplacedWithSameSize || (meta === null || meta === void 0 ? void 0 : meta.nodeMoved) : true;
|
|
420
|
-
|
|
424
|
+
|
|
425
|
+
// platform_editor_controls note: enables quick insert
|
|
426
|
+
if (flags.toolbarFlagsEnabled) {
|
|
421
427
|
// Remove handle dec when editor is blurred
|
|
422
428
|
shouldRemoveHandle = shouldRemoveHandle || (meta === null || meta === void 0 ? void 0 : meta.editorBlurred);
|
|
423
429
|
}
|
|
@@ -425,7 +431,8 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
|
|
|
425
431
|
var _activeNode5, _activeNode6;
|
|
426
432
|
var oldHandle = (0, _decorationsDragHandle.findHandleDec)(decorations, (_activeNode5 = activeNode) === null || _activeNode5 === void 0 ? void 0 : _activeNode5.pos, (_activeNode6 = activeNode) === null || _activeNode6 === void 0 ? void 0 : _activeNode6.pos);
|
|
427
433
|
decorations = decorations.remove(oldHandle);
|
|
428
|
-
|
|
434
|
+
// platform_editor_controls note: enables quick insert
|
|
435
|
+
if (flags.toolbarFlagsEnabled) {
|
|
429
436
|
var _activeNode7, _activeNode8;
|
|
430
437
|
var oldQuickInsertButton = (0, _decorationsQuickInsertButton.findQuickInsertInsertButtonDecoration)(decorations, (_activeNode7 = activeNode) === null || _activeNode7 === void 0 ? void 0 : _activeNode7.rootPos, (_activeNode8 = activeNode) === null || _activeNode8 === void 0 ? void 0 : _activeNode8.rootPos);
|
|
431
438
|
decorations = decorations.remove(oldQuickInsertButton);
|
|
@@ -449,7 +456,9 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
|
|
|
449
456
|
});
|
|
450
457
|
decorations = decorations.add(newState.doc, [handleDec]);
|
|
451
458
|
}
|
|
452
|
-
if (shouldRecreateQuickInsertButton && ((_latestActiveNode5 = latestActiveNode) === null || _latestActiveNode5 === void 0 ? void 0 : _latestActiveNode5.rootPos) !== undefined &&
|
|
459
|
+
if (shouldRecreateQuickInsertButton && ((_latestActiveNode5 = latestActiveNode) === null || _latestActiveNode5 === void 0 ? void 0 : _latestActiveNode5.rootPos) !== undefined &&
|
|
460
|
+
// platform_editor_controls note: enables quick insert
|
|
461
|
+
flags.toolbarFlagsEnabled) {
|
|
453
462
|
var _activeNode1, _activeNode10, _latestActiveNode6, _latestActiveNode7, _latestActiveNode8, _latestActiveNode9, _latestActiveNode0;
|
|
454
463
|
var _oldQuickInsertButton = (0, _decorationsQuickInsertButton.findQuickInsertInsertButtonDecoration)(decorations, (_activeNode1 = activeNode) === null || _activeNode1 === void 0 ? void 0 : _activeNode1.rootPos, (_activeNode10 = activeNode) === null || _activeNode10 === void 0 ? void 0 : _activeNode10.rootPos);
|
|
455
464
|
decorations = decorations.remove(_oldQuickInsertButton);
|
|
@@ -511,7 +520,8 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
|
|
|
511
520
|
}
|
|
512
521
|
}
|
|
513
522
|
var newActiveNode;
|
|
514
|
-
|
|
523
|
+
// platform_editor_controls note: enables quick insert
|
|
524
|
+
if (flags.toolbarFlagsEnabled) {
|
|
515
525
|
var _latestActiveNode1, _latestActiveNode10;
|
|
516
526
|
// remove isEmptyDoc check and let decorations render and determine their own visibility
|
|
517
527
|
newActiveNode = !(meta !== null && meta !== void 0 && meta.activeNode) && (0, _decorationsDragHandle.findHandleDec)(decorations, (_latestActiveNode1 = latestActiveNode) === null || _latestActiveNode1 === void 0 ? void 0 : _latestActiveNode1.pos, (_latestActiveNode10 = latestActiveNode) === null || _latestActiveNode10 === void 0 ? void 0 : _latestActiveNode10.pos).length === 0 ? null : latestActiveNode;
|
|
@@ -520,7 +530,7 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
|
|
|
520
530
|
newActiveNode = isEmptyDoc || !(meta !== null && meta !== void 0 && meta.activeNode) && (0, _decorationsDragHandle.findHandleDec)(decorations, (_latestActiveNode11 = latestActiveNode) === null || _latestActiveNode11 === void 0 ? void 0 : _latestActiveNode11.pos, (_latestActiveNode12 = latestActiveNode) === null || _latestActiveNode12 === void 0 ? void 0 : _latestActiveNode12.pos).length === 0 ? null : latestActiveNode;
|
|
521
531
|
}
|
|
522
532
|
var isMenuOpenNew = isMenuOpen;
|
|
523
|
-
if (_consts.BLOCK_MENU_ENABLED &&
|
|
533
|
+
if (_consts.BLOCK_MENU_ENABLED && flags.toolbarFlagsEnabled || (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true)) {
|
|
524
534
|
if (meta !== null && meta !== void 0 && meta.closeMenu) {
|
|
525
535
|
isMenuOpenNew = false;
|
|
526
536
|
} else if (meta !== null && meta !== void 0 && meta.toggleMenu) {
|
|
@@ -531,10 +541,10 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
|
|
|
531
541
|
isMenuOpenNew = !isMenuOpen;
|
|
532
542
|
}
|
|
533
543
|
var isSelectedViaDragHandleNew;
|
|
534
|
-
if (
|
|
544
|
+
if (flags.toolbarFlagsEnabled && (0, _expValEquals.expValEquals)('platform_editor_controls_block_controls_state_fix', 'isEnabled', true)) {
|
|
535
545
|
isSelectedViaDragHandleNew = (meta === null || meta === void 0 ? void 0 : meta.isSelectedViaDragHandle) !== undefined ? meta === null || meta === void 0 ? void 0 : meta.isSelectedViaDragHandle : isSelectedViaDragHandle;
|
|
536
546
|
} else {
|
|
537
|
-
isSelectedViaDragHandleNew = (meta === null || meta === void 0 ? void 0 : meta.isSelectedViaDragHandle) !== undefined &&
|
|
547
|
+
isSelectedViaDragHandleNew = (meta === null || meta === void 0 ? void 0 : meta.isSelectedViaDragHandle) !== undefined && flags.toolbarFlagsEnabled && (meta === null || meta === void 0 ? void 0 : meta.isSelectedViaDragHandle);
|
|
538
548
|
}
|
|
539
549
|
return {
|
|
540
550
|
decorations: decorations,
|
|
@@ -542,7 +552,7 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
|
|
|
542
552
|
activeDropTargetNode: currentActiveDropTargetNode,
|
|
543
553
|
isDragging: (_meta$isDragging3 = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging3 !== void 0 ? _meta$isDragging3 : isDragging,
|
|
544
554
|
isMenuOpen: isMenuOpenNew,
|
|
545
|
-
menuTriggerBy:
|
|
555
|
+
menuTriggerBy: flags.toolbarFlagsEnabled || (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true) ? (meta === null || meta === void 0 || (_meta$toggleMenu = meta.toggleMenu) === null || _meta$toggleMenu === void 0 ? void 0 : _meta$toggleMenu.anchorName) || menuTriggerBy : undefined,
|
|
546
556
|
blockMenuOptions: (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true) ? {
|
|
547
557
|
canMoveUp: (meta === null || meta === void 0 || (_meta$toggleMenu2 = meta.toggleMenu) === null || _meta$toggleMenu2 === void 0 ? void 0 : _meta$toggleMenu2.moveUp) !== undefined ? meta === null || meta === void 0 || (_meta$toggleMenu3 = meta.toggleMenu) === null || _meta$toggleMenu3 === void 0 ? void 0 : _meta$toggleMenu3.moveUp : blockMenuOptions === null || blockMenuOptions === void 0 ? void 0 : blockMenuOptions.canMoveUp,
|
|
548
558
|
canMoveDown: (meta === null || meta === void 0 || (_meta$toggleMenu4 = meta.toggleMenu) === null || _meta$toggleMenu4 === void 0 ? void 0 : _meta$toggleMenu4.moveDown) !== undefined ? meta === null || meta === void 0 || (_meta$toggleMenu5 = meta.toggleMenu) === null || _meta$toggleMenu5 === void 0 ? void 0 : _meta$toggleMenu5.moveDown : blockMenuOptions === null || blockMenuOptions === void 0 ? void 0 : blockMenuOptions.canMoveDown,
|
|
@@ -569,8 +579,10 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
|
|
|
569
579
|
var isMultiSelectEnabled = (0, _experiments.editorExperiment)('platform_editor_element_drag_and_drop_multiselect', true, {
|
|
570
580
|
exposure: true
|
|
571
581
|
});
|
|
582
|
+
var toolbarFlagsEnabled = (0, _toolbarFlagCheck.areToolbarFlagsEnabled)(Boolean(api === null || api === void 0 ? void 0 : api.toolbar));
|
|
572
583
|
var flags = {
|
|
573
|
-
isMultiSelectEnabled: isMultiSelectEnabled
|
|
584
|
+
isMultiSelectEnabled: isMultiSelectEnabled,
|
|
585
|
+
toolbarFlagsEnabled: toolbarFlagsEnabled
|
|
574
586
|
};
|
|
575
587
|
var anchorRectCache;
|
|
576
588
|
if (!(0, _anchorUtils.isAnchorSupported)()) {
|
|
@@ -5,11 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.setCursorPositionAtMovedNode = exports.selectNode = exports.rootTaskListDepth = exports.rootListDepth = exports.isNodeWithCodeBlock = exports.isHandleCorrelatedToSelection = exports.getSelection = exports.getInlineNodePos = void 0;
|
|
7
7
|
var _selection2 = require("@atlaskit/editor-common/selection");
|
|
8
|
+
var _toolbarFlagCheck = require("@atlaskit/editor-common/toolbar-flag-check");
|
|
8
9
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
9
10
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
10
11
|
var _utils2 = require("@atlaskit/editor-tables/utils");
|
|
11
12
|
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
12
|
-
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
13
13
|
var getInlineNodePos = exports.getInlineNodePos = function getInlineNodePos(tr, start, nodeSize) {
|
|
14
14
|
var $startPos = tr.doc.resolve(start);
|
|
15
15
|
// To trigger the annotation floating toolbar for non-selectable node, we need to select inline nodes
|
|
@@ -121,25 +121,25 @@ var newGetSelection = function newGetSelection(tr, start) {
|
|
|
121
121
|
inlineNodeEndPos = _getInlineNodePos2.inlineNodeEndPos;
|
|
122
122
|
return new _state.TextSelection(tr.doc.resolve(inlineNodePos), tr.doc.resolve(inlineNodeEndPos));
|
|
123
123
|
};
|
|
124
|
-
var getSelection = exports.getSelection = function getSelection(tr, start) {
|
|
125
|
-
if ((0,
|
|
124
|
+
var getSelection = exports.getSelection = function getSelection(tr, start, api) {
|
|
125
|
+
if ((0, _toolbarFlagCheck.areToolbarFlagsEnabled)(Boolean(api === null || api === void 0 ? void 0 : api.toolbar))) {
|
|
126
126
|
return newGetSelection(tr, start);
|
|
127
127
|
}
|
|
128
128
|
return oldGetSelection(tr, start);
|
|
129
129
|
};
|
|
130
|
-
var selectNode = exports.selectNode = function selectNode(tr, start, nodeType) {
|
|
130
|
+
var selectNode = exports.selectNode = function selectNode(tr, start, nodeType, api) {
|
|
131
131
|
// For table, we need to do cell selection instead of node selection
|
|
132
132
|
if (nodeType === 'table') {
|
|
133
133
|
tr = (0, _utils2.selectTableClosestToPos)(tr, tr.doc.resolve(start + 1));
|
|
134
134
|
return tr;
|
|
135
135
|
}
|
|
136
|
-
var selection = getSelection(tr, start);
|
|
136
|
+
var selection = getSelection(tr, start, api);
|
|
137
137
|
if (selection) {
|
|
138
138
|
tr.setSelection(selection);
|
|
139
139
|
}
|
|
140
140
|
return tr;
|
|
141
141
|
};
|
|
142
|
-
var setCursorPositionAtMovedNode = exports.setCursorPositionAtMovedNode = function setCursorPositionAtMovedNode(tr, start) {
|
|
142
|
+
var setCursorPositionAtMovedNode = exports.setCursorPositionAtMovedNode = function setCursorPositionAtMovedNode(tr, start, api) {
|
|
143
143
|
var node = tr.doc.nodeAt(start);
|
|
144
144
|
var isNodeSelection = node && _state.NodeSelection.isSelectable(node);
|
|
145
145
|
var nodeSize = node ? node.nodeSize : 1;
|
|
@@ -153,7 +153,7 @@ var setCursorPositionAtMovedNode = exports.setCursorPositionAtMovedNode = functi
|
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
// this is a fix for empty paragraph selection - can safely use start position as the paragraph is empty
|
|
156
|
-
if ((node === null || node === void 0 ? void 0 : node.type.name) === 'paragraph' && (node === null || node === void 0 ? void 0 : node.childCount) === 0 && (0,
|
|
156
|
+
if ((node === null || node === void 0 ? void 0 : node.type.name) === 'paragraph' && (node === null || node === void 0 ? void 0 : node.childCount) === 0 && (0, _toolbarFlagCheck.areToolbarFlagsEnabled)(Boolean(api === null || api === void 0 ? void 0 : api.toolbar))) {
|
|
157
157
|
var _selection = new _state.TextSelection(tr.doc.resolve(start));
|
|
158
158
|
tr.setSelection(_selection);
|
|
159
159
|
return tr;
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.isStepText = exports.isStepDelete = exports.getTrMetadata = void 0;
|
|
7
7
|
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
8
|
-
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
9
8
|
/**
|
|
10
9
|
* Checks if step adds inline char
|
|
11
10
|
* @param s
|
|
@@ -47,7 +46,7 @@ var isStepContentReplacedWithAnotherOfSameSize = function isStepContentReplacedW
|
|
|
47
46
|
* Number of ReplaceStep and ReplaceAroundStep steps 'numReplaceSteps'.
|
|
48
47
|
* 'isAllText' if all steps are represent adding inline text or a backspace/delete or no-op
|
|
49
48
|
*/
|
|
50
|
-
var getTrMetadata = exports.getTrMetadata = function getTrMetadata(tr) {
|
|
49
|
+
var getTrMetadata = exports.getTrMetadata = function getTrMetadata(tr, flags) {
|
|
51
50
|
var from;
|
|
52
51
|
var to;
|
|
53
52
|
var numReplaceSteps = 0;
|
|
@@ -58,7 +57,9 @@ var getTrMetadata = exports.getTrMetadata = function getTrMetadata(tr) {
|
|
|
58
57
|
if (s instanceof _transform.ReplaceAroundStep || s instanceof _transform.ReplaceStep && !isStepText(s) && !isStepDelete(s)) {
|
|
59
58
|
isAllText = false;
|
|
60
59
|
}
|
|
61
|
-
|
|
60
|
+
// Fixes drag handle and quick insert button overlap issues
|
|
61
|
+
if (flags.toolbarFlagsEnabled) {
|
|
62
|
+
// platform_editor_controls note: fixes drag handle and quick insert button overlap issues
|
|
62
63
|
isReplacedWithSameSize = isStepContentReplacedWithAnotherOfSameSize(s);
|
|
63
64
|
}
|
|
64
65
|
var mappedTo = tr.mapping.map(s.to);
|
|
@@ -296,7 +296,7 @@ var getNodeMargins = function getNodeMargins(node) {
|
|
|
296
296
|
return _consts2.nodeMargins[nodeTypeName] || _consts2.nodeMargins['default'];
|
|
297
297
|
};
|
|
298
298
|
var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
299
|
-
var _api$
|
|
299
|
+
var _api$core3;
|
|
300
300
|
var view = _ref.view,
|
|
301
301
|
api = _ref.api,
|
|
302
302
|
formatMessage = _ref.formatMessage,
|
|
@@ -391,10 +391,10 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
391
391
|
var _selection = new _state.NodeSelection(tr.doc.resolve(startPos));
|
|
392
392
|
tr.setSelection(_selection);
|
|
393
393
|
} else {
|
|
394
|
-
tr = (0, _getSelection.selectNode)(tr, startPos, nodeType);
|
|
394
|
+
tr = (0, _getSelection.selectNode)(tr, startPos, nodeType, api);
|
|
395
395
|
}
|
|
396
396
|
} else {
|
|
397
|
-
tr = (0, _getSelection.selectNode)(tr, startPos, nodeType);
|
|
397
|
+
tr = (0, _getSelection.selectNode)(tr, startPos, nodeType, api);
|
|
398
398
|
}
|
|
399
399
|
if (_consts2.BLOCK_MENU_ENABLED && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
|
|
400
400
|
var _api$blockControls;
|
|
@@ -440,7 +440,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
440
440
|
return tr;
|
|
441
441
|
});
|
|
442
442
|
view.focus();
|
|
443
|
-
}, [isMultiSelect, api
|
|
443
|
+
}, [isMultiSelect, api, view, dragHandleSelected, getPos, isTopLevelNode, nodeType, anchorName]);
|
|
444
444
|
|
|
445
445
|
// TODO: ED-26959 - This needs to be investigated further. Drag preview generation is not always working
|
|
446
446
|
// as expected with a node selection. This workaround sets the selection to the node on mouseDown,
|
|
@@ -458,9 +458,9 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
458
458
|
var handleKeyDown = (0, _react.useCallback)(function (e) {
|
|
459
459
|
// allow user to use spacebar to select the node
|
|
460
460
|
if (!e.repeat && e.key === ' ') {
|
|
461
|
-
var _api$
|
|
461
|
+
var _api$core2;
|
|
462
462
|
var startPos = getPos();
|
|
463
|
-
api === null || api === void 0 || (_api$
|
|
463
|
+
api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(function (_ref3) {
|
|
464
464
|
var tr = _ref3.tr;
|
|
465
465
|
if (startPos === undefined) {
|
|
466
466
|
return tr;
|
|
@@ -484,28 +484,28 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
484
484
|
// return focus to editor to resume editing from caret position
|
|
485
485
|
view.focus();
|
|
486
486
|
}
|
|
487
|
-
}, [getPos, api === null || api === void 0 || (_api$
|
|
487
|
+
}, [getPos, api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 ? void 0 : _api$core3.actions, isMultiSelect, view]);
|
|
488
488
|
var handleKeyDownNew = (0, _react.useCallback)(function (e) {
|
|
489
489
|
// allow user to use spacebar to select the node
|
|
490
490
|
if (e.key === 'Enter' || !e.repeat && e.key === ' ') {
|
|
491
|
-
var _api$
|
|
491
|
+
var _api$core4;
|
|
492
492
|
if (document.activeElement !== buttonRef.current) {
|
|
493
493
|
return;
|
|
494
494
|
}
|
|
495
495
|
e.preventDefault();
|
|
496
496
|
e.stopPropagation();
|
|
497
497
|
var startPos = getPos();
|
|
498
|
-
api === null || api === void 0 || (_api$
|
|
499
|
-
var _api$
|
|
498
|
+
api === null || api === void 0 || (_api$core4 = api.core) === null || _api$core4 === void 0 || _api$core4.actions.execute(function (_ref4) {
|
|
499
|
+
var _api$blockControls4, _api$userIntent;
|
|
500
500
|
var tr = _ref4.tr;
|
|
501
501
|
if (startPos === undefined) {
|
|
502
502
|
return tr;
|
|
503
503
|
}
|
|
504
|
-
tr = (0, _getSelection.selectNode)(tr, startPos, nodeType);
|
|
504
|
+
tr = (0, _getSelection.selectNode)(tr, startPos, nodeType, api);
|
|
505
505
|
!isMultiSelect && tr.setMeta(_main.key, {
|
|
506
506
|
pos: startPos
|
|
507
507
|
});
|
|
508
|
-
api === null || api === void 0 || (_api$
|
|
508
|
+
api === null || api === void 0 || (_api$blockControls4 = api.blockControls) === null || _api$blockControls4 === void 0 || _api$blockControls4.commands.toggleBlockMenu({
|
|
509
509
|
anchorName: anchorName,
|
|
510
510
|
openedViaKeyboard: true
|
|
511
511
|
})({
|
|
@@ -523,7 +523,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
523
523
|
// return focus to editor to resume editing from caret position
|
|
524
524
|
view.focus();
|
|
525
525
|
}
|
|
526
|
-
}, [getPos, api
|
|
526
|
+
}, [getPos, api, nodeType, isMultiSelect, anchorName, view]);
|
|
527
527
|
(0, _react.useEffect)(function () {
|
|
528
528
|
var element = buttonRef.current;
|
|
529
529
|
if (!element) {
|
|
@@ -541,8 +541,8 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
541
541
|
var _api$blockControls$sh2;
|
|
542
542
|
var nativeSetDragImage = _ref5.nativeSetDragImage;
|
|
543
543
|
if (isMultiSelect) {
|
|
544
|
-
var _api$
|
|
545
|
-
api === null || api === void 0 || (_api$
|
|
544
|
+
var _api$core5;
|
|
545
|
+
api === null || api === void 0 || (_api$core5 = api.core) === null || _api$core5 === void 0 || _api$core5.actions.execute(function (_ref6) {
|
|
546
546
|
var tr = _ref6.tr;
|
|
547
547
|
var handlePos = getPos();
|
|
548
548
|
if (typeof handlePos !== 'number') {
|
|
@@ -550,12 +550,12 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
550
550
|
}
|
|
551
551
|
var newHandlePosCheck = (0, _getSelection.isHandleCorrelatedToSelection)(view.state, tr.selection, handlePos);
|
|
552
552
|
if (!tr.selection.empty && newHandlePosCheck) {
|
|
553
|
-
var _api$
|
|
554
|
-
api === null || api === void 0 || (_api$
|
|
553
|
+
var _api$blockControls5;
|
|
554
|
+
api === null || api === void 0 || (_api$blockControls5 = api.blockControls) === null || _api$blockControls5 === void 0 || _api$blockControls5.commands.setMultiSelectPositions()({
|
|
555
555
|
tr: tr
|
|
556
556
|
});
|
|
557
557
|
} else if ((0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_select_node_on_drag')) {
|
|
558
|
-
tr = (0, _getSelection.selectNode)(tr, handlePos, nodeType);
|
|
558
|
+
tr = (0, _getSelection.selectNode)(tr, handlePos, nodeType, api);
|
|
559
559
|
}
|
|
560
560
|
return tr;
|
|
561
561
|
});
|
|
@@ -654,12 +654,12 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
654
654
|
});
|
|
655
655
|
},
|
|
656
656
|
onDragStart: function onDragStart() {
|
|
657
|
-
var _api$
|
|
657
|
+
var _api$core6;
|
|
658
658
|
if (start === undefined) {
|
|
659
659
|
return;
|
|
660
660
|
}
|
|
661
|
-
api === null || api === void 0 || (_api$
|
|
662
|
-
var _api$blockControls$sh3, _api$
|
|
661
|
+
api === null || api === void 0 || (_api$core6 = api.core) === null || _api$core6 === void 0 || _api$core6.actions.execute(function (_ref8) {
|
|
662
|
+
var _api$blockControls$sh3, _api$blockControls6, _api$analytics2;
|
|
663
663
|
var tr = _ref8.tr;
|
|
664
664
|
var nodeTypes, hasSelectedMultipleNodes;
|
|
665
665
|
var resolvedMovingNode = tr.doc.resolve(start);
|
|
@@ -673,11 +673,11 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
673
673
|
nodeTypes = maybeNode === null || maybeNode === void 0 ? void 0 : maybeNode.type.name;
|
|
674
674
|
hasSelectedMultipleNodes = false;
|
|
675
675
|
}
|
|
676
|
-
api === null || api === void 0 || (_api$
|
|
676
|
+
api === null || api === void 0 || (_api$blockControls6 = api.blockControls) === null || _api$blockControls6 === void 0 || _api$blockControls6.commands.setNodeDragged(getPos, anchorName, nodeType)({
|
|
677
677
|
tr: tr
|
|
678
678
|
});
|
|
679
679
|
tr.setMeta('scrollIntoView', false);
|
|
680
|
-
api === null || api === void 0 || (_api$
|
|
680
|
+
api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || _api$analytics2.actions.attachAnalyticsEvent({
|
|
681
681
|
eventType: _analytics.EVENT_TYPE.UI,
|
|
682
682
|
action: _analytics.ACTION.DRAGGED,
|
|
683
683
|
actionSubject: _analytics.ACTION_SUBJECT.ELEMENT,
|
|
@@ -8,6 +8,7 @@ exports.GlobalStylesWrapper = void 0;
|
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _react = require("@emotion/react");
|
|
10
10
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
11
|
+
var _toolbarFlagCheck = require("@atlaskit/editor-common/toolbar-flag-check");
|
|
11
12
|
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
12
13
|
var _whitespace = require("@atlaskit/editor-common/whitespace");
|
|
13
14
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
@@ -409,9 +410,12 @@ var GlobalStylesWrapper = exports.GlobalStylesWrapper = function GlobalStylesWra
|
|
|
409
410
|
var isDragging = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockControls.isDragging', {
|
|
410
411
|
disabled: !(0, _expValEquals.expValEquals)('platform_editor_block_controls_perf_optimization', 'isEnabled', true)
|
|
411
412
|
});
|
|
413
|
+
var toolbarFlagsEnabled = (0, _toolbarFlagCheck.areToolbarFlagsEnabled)(Boolean(api === null || api === void 0 ? void 0 : api.toolbar));
|
|
412
414
|
return (0, _react.jsx)(_react.Global, {
|
|
413
415
|
styles: [globalStyles(), globalDnDStyle, (0, _expValEquals.expValEquals)('platform_editor_native_anchor_support', 'isEnabled', true) ? extendedHoverZoneNext() : extendedHoverZone(), isDragging && ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_support', 'isEnabled', true) ? extendedDragZoneNext : extendedDragZone), (0, _experiments.editorExperiment)('platform_editor_preview_panel_responsiveness', true, {
|
|
414
416
|
exposure: true
|
|
415
|
-
}) ? (0, _expValEquals.expValEquals)('platform_editor_native_anchor_support', 'isEnabled', true) ? extendHoverZoneReducedNext : extendHoverZoneReduced : undefined,
|
|
417
|
+
}) ? (0, _expValEquals.expValEquals)('platform_editor_native_anchor_support', 'isEnabled', true) ? extendHoverZoneReducedNext : extendHoverZoneReduced : undefined,
|
|
418
|
+
// platform_editor_controls note: this allows drag handles to render on empty lines
|
|
419
|
+
toolbarFlagsEnabled ? undefined : withInlineNodeStyle, (0, _experiments.editorExperiment)('platform_editor_block_control_optimise_render', true) ? quickInsertStyles : undefined, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, (0, _experiments.editorExperiment)('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, (0, _expValEquals.expValEquals)('platform_editor_native_anchor_support', 'isEnabled', true) ? withRelativePosStyleNext : withRelativePosStyle, topLevelNodeMarginStyles, (0, _expValEquals.expValEquals)('platform_editor_native_anchor_support', 'isEnabled', true) ? withAnchorNameZindexStyleNext : withAnchorNameZindexStyle, (0, _expValEquals.expValEquals)('platform_editor_native_anchor_support', 'isEnabled', true) && (0, _expValEquals.expValEquals)('advanced_layouts', 'isEnabled', true) ? layoutColumnExtendedHoverZone : layoutColumnWithoutHoverZone]
|
|
416
420
|
});
|
|
417
421
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { expandSelectionBounds } from '@atlaskit/editor-common/selection';
|
|
3
|
+
import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
|
|
3
4
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
4
5
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
6
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
@@ -32,6 +33,10 @@ export const blockControlsPlugin = ({
|
|
|
32
33
|
name: 'blockControlsInteractionTrackingPlugin',
|
|
33
34
|
plugin: createInteractionTrackingPlugin
|
|
34
35
|
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// platform_editor_controls note: quick insert rendering fixes
|
|
39
|
+
if (areToolbarFlagsEnabled(Boolean(api === null || api === void 0 ? void 0 : api.toolbar))) {
|
|
35
40
|
pmPlugins.push({
|
|
36
41
|
name: 'firstNodeDec',
|
|
37
42
|
plugin: firstNodeDecPlugin
|
|
@@ -191,7 +196,7 @@ export const blockControlsPlugin = ({
|
|
|
191
196
|
const $to = $expandedAnchor.max($expandedHead);
|
|
192
197
|
let expandedNormalisedSel;
|
|
193
198
|
if ($from.nodeAfter === $to.nodeBefore) {
|
|
194
|
-
selectNode(tr, $from.pos, $expandedAnchor.node().type.name);
|
|
199
|
+
selectNode(tr, $from.pos, $expandedAnchor.node().type.name, api);
|
|
195
200
|
expandedNormalisedSel = tr.selection;
|
|
196
201
|
} else if (((_$to$nodeBefore = $to.nodeBefore) === null || _$to$nodeBefore === void 0 ? void 0 : _$to$nodeBefore.type.name) === 'mediaSingle' || ((_$from$nodeAfter = $from.nodeAfter) === null || _$from$nodeAfter === void 0 ? void 0 : _$from$nodeAfter.type.name) === 'mediaSingle') {
|
|
197
202
|
expandedNormalisedSel = new TextSelection($expandedAnchor, $expandedHead);
|
|
@@ -293,7 +293,7 @@ export const moveNodeViaShortcut = (api, direction, formatMessage) => {
|
|
|
293
293
|
api === null || api === void 0 ? void 0 : (_api$core8 = api.core) === null || _api$core8 === void 0 ? void 0 : _api$core8.actions.execute(({
|
|
294
294
|
tr
|
|
295
295
|
}) => {
|
|
296
|
-
selectNode(tr, currentNodePos, nodeType);
|
|
296
|
+
selectNode(tr, currentNodePos, nodeType, api);
|
|
297
297
|
tr.scrollIntoView();
|
|
298
298
|
return tr;
|
|
299
299
|
});
|
|
@@ -404,9 +404,9 @@ export const moveNode = api => (start, to, inputMethod = INPUT_METHOD.DRAG_AND_D
|
|
|
404
404
|
tr.insert(mappedTo, convertedNode);
|
|
405
405
|
}
|
|
406
406
|
const sliceSize = sliceTo - sliceFrom;
|
|
407
|
-
tr = inputMethod === INPUT_METHOD.DRAG_AND_DROP ? setCursorPositionAtMovedNode(tr, mappedTo) : isMultiSelect ? (_api$blockControls$co2 = api === null || api === void 0 ? void 0 : api.blockControls.commands.setMultiSelectPositions(mappedTo, mappedTo + sliceSize)({
|
|
407
|
+
tr = inputMethod === INPUT_METHOD.DRAG_AND_DROP ? setCursorPositionAtMovedNode(tr, mappedTo, api) : isMultiSelect ? (_api$blockControls$co2 = api === null || api === void 0 ? void 0 : api.blockControls.commands.setMultiSelectPositions(mappedTo, mappedTo + sliceSize)({
|
|
408
408
|
tr
|
|
409
|
-
})) !== null && _api$blockControls$co2 !== void 0 ? _api$blockControls$co2 : tr : selectNode(tr, mappedTo, handleNode.type.name);
|
|
409
|
+
})) !== null && _api$blockControls$co2 !== void 0 ? _api$blockControls$co2 : tr : selectNode(tr, mappedTo, handleNode.type.name, api);
|
|
410
410
|
const currMeta = tr.getMeta(key);
|
|
411
411
|
tr.setMeta(key, {
|
|
412
412
|
...currMeta,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import memoizeOne from 'memoize-one';
|
|
2
|
+
import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
|
|
2
3
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
4
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
4
5
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
@@ -39,6 +40,7 @@ export const handleMouseOver = (view, event, api) => {
|
|
|
39
40
|
} = (api === null || api === void 0 ? void 0 : (_api$editorDisabled = api.editorDisabled) === null || _api$editorDisabled === void 0 ? void 0 : _api$editorDisabled.sharedState.currentState()) || {
|
|
40
41
|
editorDisabled: false
|
|
41
42
|
};
|
|
43
|
+
const toolbarFlagsEnabled = areToolbarFlagsEnabled(Boolean(api === null || api === void 0 ? void 0 : api.toolbar));
|
|
42
44
|
|
|
43
45
|
// We shouldn't be firing mouse over transactions when the editor is disabled
|
|
44
46
|
if (editorDisabled && fg('aifc_create_enabled')) {
|
|
@@ -140,7 +142,9 @@ export const handleMouseOver = (view, event, api) => {
|
|
|
140
142
|
let rootAnchorName;
|
|
141
143
|
let rootNodeType;
|
|
142
144
|
let rootPos;
|
|
143
|
-
|
|
145
|
+
|
|
146
|
+
// platform_editor_controls note: enables quick insert
|
|
147
|
+
if (toolbarFlagsEnabled) {
|
|
144
148
|
rootPos = view.state.doc.resolve(pos).before(1);
|
|
145
149
|
if (targetPos !== rootPos) {
|
|
146
150
|
const rootDOM = view.nodeDOM(rootPos);
|
|
@@ -153,7 +157,8 @@ export const handleMouseOver = (view, event, api) => {
|
|
|
153
157
|
}
|
|
154
158
|
const nodeType = isNativeAnchorSupported ? getTypeNameFromDom(rootElement) : rootElement.getAttribute('data-drag-handler-node-type');
|
|
155
159
|
if (nodeType) {
|
|
156
|
-
|
|
160
|
+
// platform_editor_controls note: enables quick insert
|
|
161
|
+
if (toolbarFlagsEnabled) {
|
|
157
162
|
var _api$core, _api$blockControls2, _rootPos, _rootAnchorName, _rootNodeType;
|
|
158
163
|
api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(api === null || api === void 0 ? void 0 : (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.commands.showDragHandleAt(targetPos, anchorName, nodeType, undefined, (_rootPos = rootPos) !== null && _rootPos !== void 0 ? _rootPos : targetPos, (_rootAnchorName = rootAnchorName) !== null && _rootAnchorName !== void 0 ? _rootAnchorName : anchorName, (_rootNodeType = rootNodeType) !== null && _rootNodeType !== void 0 ? _rootNodeType : nodeType));
|
|
159
164
|
} else {
|