@atlaskit/editor-plugin-block-controls 8.7.2 → 8.8.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 +17 -0
- package/dist/cjs/blockControlsPlugin.js +14 -3
- package/dist/cjs/pm-plugins/decorations-drag-handle.js +3 -0
- package/dist/cjs/pm-plugins/decorations-quick-insert-button.js +3 -0
- package/dist/cjs/pm-plugins/handle-mouse-over.js +27 -11
- package/dist/cjs/pm-plugins/interaction-tracking/commands.js +12 -1
- package/dist/cjs/pm-plugins/interaction-tracking/handle-mouse-move.js +96 -1
- package/dist/cjs/pm-plugins/interaction-tracking/pm-plugin.js +92 -3
- package/dist/cjs/pm-plugins/main.js +129 -25
- package/dist/cjs/pm-plugins/vanilla-quick-insert.js +36 -13
- package/dist/cjs/ui/drag-handle.js +19 -9
- package/dist/cjs/ui/global-styles.js +9 -4
- package/dist/cjs/ui/quick-insert-button.js +16 -3
- package/dist/cjs/ui/visibility-container.js +70 -9
- package/dist/es2019/blockControlsPlugin.js +12 -3
- package/dist/es2019/pm-plugins/decorations-drag-handle.js +3 -0
- package/dist/es2019/pm-plugins/decorations-quick-insert-button.js +3 -0
- package/dist/es2019/pm-plugins/handle-mouse-over.js +27 -11
- package/dist/es2019/pm-plugins/interaction-tracking/commands.js +11 -0
- package/dist/es2019/pm-plugins/interaction-tracking/handle-mouse-move.js +98 -3
- package/dist/es2019/pm-plugins/interaction-tracking/pm-plugin.js +89 -4
- package/dist/es2019/pm-plugins/main.js +73 -18
- package/dist/es2019/pm-plugins/vanilla-quick-insert.js +27 -3
- package/dist/es2019/ui/drag-handle.js +19 -9
- package/dist/es2019/ui/global-styles.js +9 -3
- package/dist/es2019/ui/quick-insert-button.js +17 -3
- package/dist/es2019/ui/visibility-container.js +65 -9
- package/dist/esm/blockControlsPlugin.js +14 -3
- package/dist/esm/pm-plugins/decorations-drag-handle.js +3 -0
- package/dist/esm/pm-plugins/decorations-quick-insert-button.js +3 -0
- package/dist/esm/pm-plugins/handle-mouse-over.js +27 -11
- package/dist/esm/pm-plugins/interaction-tracking/commands.js +11 -0
- package/dist/esm/pm-plugins/interaction-tracking/handle-mouse-move.js +98 -2
- package/dist/esm/pm-plugins/interaction-tracking/pm-plugin.js +93 -3
- package/dist/esm/pm-plugins/main.js +129 -25
- package/dist/esm/pm-plugins/vanilla-quick-insert.js +36 -13
- package/dist/esm/ui/drag-handle.js +19 -9
- package/dist/esm/ui/global-styles.js +9 -4
- package/dist/esm/ui/quick-insert-button.js +16 -3
- package/dist/esm/ui/visibility-container.js +68 -9
- package/dist/types/blockControlsPluginType.d.ts +25 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/pm-plugins/interaction-tracking/commands.d.ts +2 -0
- package/dist/types/pm-plugins/interaction-tracking/handle-mouse-move.d.ts +2 -2
- package/dist/types/pm-plugins/interaction-tracking/pm-plugin.d.ts +5 -1
- package/dist/types/pm-plugins/main.d.ts +2 -2
- package/dist/types/ui/visibility-container.d.ts +2 -1
- package/dist/types-ts4.5/blockControlsPluginType.d.ts +27 -1
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/interaction-tracking/commands.d.ts +2 -0
- package/dist/types-ts4.5/pm-plugins/interaction-tracking/handle-mouse-move.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/interaction-tracking/pm-plugin.d.ts +5 -1
- package/dist/types-ts4.5/pm-plugins/main.d.ts +2 -2
- package/dist/types-ts4.5/ui/visibility-container.d.ts +2 -1
- package/package.json +7 -9
|
@@ -4,11 +4,20 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
4
|
import { bind } from 'bind-event-listener';
|
|
5
5
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
6
6
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
7
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
7
8
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
8
9
|
import { handleKeyDown } from './handle-key-down';
|
|
9
10
|
import { handleMouseEnter, handleMouseLeave, handleMouseMove } from './handle-mouse-move';
|
|
11
|
+
|
|
12
|
+
/** Elements that extend the editor hover area (block controls, right-edge button, etc.) */
|
|
13
|
+
var BLOCK_CONTROLS_HOVER_AREA_SELECTOR = '[data-blocks-right-edge-button-container], [data-blocks-drag-handle-container], [data-testid="block-ctrl-drag-handle"], [data-testid="block-ctrl-drag-handle-container"], [data-testid="block-ctrl-decorator-widget"], [data-testid="block-ctrl-quick-insert-button"]';
|
|
14
|
+
var MOUSE_LEAVE_DEBOUNCE_MS = 200;
|
|
15
|
+
var isMovingToBlockControlsArea = function isMovingToBlockControlsArea(target) {
|
|
16
|
+
return target instanceof Element && !!target.closest(BLOCK_CONTROLS_HOVER_AREA_SELECTOR);
|
|
17
|
+
};
|
|
10
18
|
export var interactionTrackingPluginKey = new PluginKey('interactionTrackingPlugin');
|
|
11
19
|
export var createInteractionTrackingPlugin = function createInteractionTrackingPlugin() {
|
|
20
|
+
var rightSideControlsEnabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
12
21
|
return new SafePlugin({
|
|
13
22
|
key: interactionTrackingPluginKey,
|
|
14
23
|
state: {
|
|
@@ -33,10 +42,17 @@ export var createInteractionTrackingPlugin = function createInteractionTrackingP
|
|
|
33
42
|
break;
|
|
34
43
|
case 'mouseLeave':
|
|
35
44
|
newState.isMouseOut = true;
|
|
45
|
+
newState.hoverSide = undefined;
|
|
36
46
|
break;
|
|
37
47
|
case 'mouseEnter':
|
|
38
48
|
newState.isMouseOut = false;
|
|
39
49
|
break;
|
|
50
|
+
case 'setHoverSide':
|
|
51
|
+
newState.hoverSide = meta.side;
|
|
52
|
+
break;
|
|
53
|
+
case 'clearHoverSide':
|
|
54
|
+
newState.hoverSide = undefined;
|
|
55
|
+
break;
|
|
40
56
|
}
|
|
41
57
|
return _objectSpread(_objectSpread({}, pluginState), newState);
|
|
42
58
|
}
|
|
@@ -44,30 +60,104 @@ export var createInteractionTrackingPlugin = function createInteractionTrackingP
|
|
|
44
60
|
props: {
|
|
45
61
|
handleKeyDown: handleKeyDown,
|
|
46
62
|
handleDOMEvents: {
|
|
47
|
-
mousemove:
|
|
63
|
+
mousemove: function mousemove(view, event) {
|
|
64
|
+
return handleMouseMove(view, event, rightSideControlsEnabled && expValEquals('confluence_remix_icon_right_side', 'isEnabled', true));
|
|
65
|
+
}
|
|
48
66
|
}
|
|
49
67
|
},
|
|
50
68
|
view: editorExperiment('platform_editor_controls', 'variant1') ? function (view) {
|
|
51
69
|
var editorContentArea = view.dom.closest('.ak-editor-content-area');
|
|
70
|
+
var remixRightSideEnabled = rightSideControlsEnabled && expValEquals('confluence_remix_icon_right_side', 'isEnabled', true);
|
|
52
71
|
var unbindMouseEnter;
|
|
53
72
|
var unbindMouseLeave;
|
|
73
|
+
var unbindDocumentMouseMove;
|
|
74
|
+
var mouseLeaveTimeoutId = null;
|
|
75
|
+
var lastMousePosition = {
|
|
76
|
+
x: 0,
|
|
77
|
+
y: 0
|
|
78
|
+
};
|
|
79
|
+
var scheduleMouseLeave = function scheduleMouseLeave(event) {
|
|
80
|
+
if (mouseLeaveTimeoutId) {
|
|
81
|
+
clearTimeout(mouseLeaveTimeoutId);
|
|
82
|
+
mouseLeaveTimeoutId = null;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Don't set isMouseOut when moving to block controls (right-edge button, drag handle, etc.)
|
|
86
|
+
if (rightSideControlsEnabled && expValEquals('confluence_remix_icon_right_side', 'isEnabled', true) && isMovingToBlockControlsArea(event.relatedTarget)) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
mouseLeaveTimeoutId = setTimeout(function () {
|
|
90
|
+
mouseLeaveTimeoutId = null;
|
|
91
|
+
// Before dispatching, check if mouse has moved to block controls (e.g. through empty space)
|
|
92
|
+
if (rightSideControlsEnabled && expValEquals('confluence_remix_icon_right_side', 'isEnabled', true) && typeof document !== 'undefined') {
|
|
93
|
+
var el = document.elementFromPoint(lastMousePosition.x, lastMousePosition.y);
|
|
94
|
+
if (el && isMovingToBlockControlsArea(el)) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
handleMouseLeave(view, rightSideControlsEnabled && expValEquals('confluence_remix_icon_right_side', 'isEnabled', true));
|
|
99
|
+
}, MOUSE_LEAVE_DEBOUNCE_MS);
|
|
100
|
+
};
|
|
101
|
+
var cancelScheduledMouseLeave = function cancelScheduledMouseLeave() {
|
|
102
|
+
if (mouseLeaveTimeoutId) {
|
|
103
|
+
clearTimeout(mouseLeaveTimeoutId);
|
|
104
|
+
mouseLeaveTimeoutId = null;
|
|
105
|
+
}
|
|
106
|
+
};
|
|
54
107
|
if (editorContentArea) {
|
|
108
|
+
if (remixRightSideEnabled && typeof document !== 'undefined') {
|
|
109
|
+
unbindDocumentMouseMove = bind(document, {
|
|
110
|
+
type: 'mousemove',
|
|
111
|
+
listener: function listener(event) {
|
|
112
|
+
lastMousePosition = {
|
|
113
|
+
x: event.clientX,
|
|
114
|
+
y: event.clientY
|
|
115
|
+
};
|
|
116
|
+
// Use document-level mousemove so we get events when hovering over block
|
|
117
|
+
// controls (which may be in portals outside the editor DOM). Without this,
|
|
118
|
+
// handleDOMEvents.mousemove only fires when over the editor content.
|
|
119
|
+
if (editorContentArea.contains(event.target) || isMovingToBlockControlsArea(event.target)) {
|
|
120
|
+
handleMouseMove(view, event, rightSideControlsEnabled && expValEquals('confluence_remix_icon_right_side', 'isEnabled', true));
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
options: {
|
|
124
|
+
passive: true
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
55
128
|
unbindMouseEnter = bind(editorContentArea, {
|
|
56
129
|
type: 'mouseenter',
|
|
57
130
|
listener: function listener() {
|
|
131
|
+
if (remixRightSideEnabled) {
|
|
132
|
+
cancelScheduledMouseLeave();
|
|
133
|
+
}
|
|
58
134
|
handleMouseEnter(view);
|
|
59
135
|
}
|
|
60
136
|
});
|
|
61
137
|
unbindMouseLeave = bind(editorContentArea, {
|
|
62
138
|
type: 'mouseleave',
|
|
63
|
-
listener: function listener() {
|
|
64
|
-
|
|
139
|
+
listener: function listener(event) {
|
|
140
|
+
var e = event;
|
|
141
|
+
lastMousePosition = {
|
|
142
|
+
x: e.clientX,
|
|
143
|
+
y: e.clientY
|
|
144
|
+
};
|
|
145
|
+
if (remixRightSideEnabled) {
|
|
146
|
+
scheduleMouseLeave(e);
|
|
147
|
+
} else {
|
|
148
|
+
handleMouseLeave(view, false);
|
|
149
|
+
}
|
|
65
150
|
}
|
|
66
151
|
});
|
|
67
152
|
}
|
|
68
153
|
return {
|
|
69
154
|
destroy: function destroy() {
|
|
70
155
|
var _unbindMouseEnter, _unbindMouseLeave;
|
|
156
|
+
if (remixRightSideEnabled) {
|
|
157
|
+
var _unbindDocumentMouseM;
|
|
158
|
+
cancelScheduledMouseLeave();
|
|
159
|
+
(_unbindDocumentMouseM = unbindDocumentMouseMove) === null || _unbindDocumentMouseM === void 0 || _unbindDocumentMouseM();
|
|
160
|
+
}
|
|
71
161
|
(_unbindMouseEnter = unbindMouseEnter) === null || _unbindMouseEnter === void 0 || _unbindMouseEnter();
|
|
72
162
|
(_unbindMouseLeave = unbindMouseLeave) === null || _unbindMouseLeave === void 0 || _unbindMouseLeave();
|
|
73
163
|
}
|
|
@@ -236,8 +236,12 @@ var getDecorationAtPos = function getDecorationAtPos(state, decorations, pos, to
|
|
|
236
236
|
var nodeDecAtActivePos = nodeDecsAtActivePos.pop();
|
|
237
237
|
return nodeDecAtActivePos;
|
|
238
238
|
};
|
|
239
|
-
var _apply = function apply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, nodeDecorationRegistry
|
|
240
|
-
var _api$limitedMode, _meta$multiSelectDnD, _activeNode, _activeNode2, _meta$activeNode$hand, _activeNode3, _activeNode4, _meta$isDragging2, _meta$isDragging3, _meta$toggleMenu, _meta$toggleMenu2, _meta$toggleMenu3, _meta$toggleMenu4, _meta$toggleMenu5, _meta$toggleMenu6, _meta$toggleMenu7, _meta$toggleMenu8, _meta$editorHeight, _meta$editorWidthLeft, _meta$editorWidthRigh, _meta$isPMDragging, _meta$isShiftDown, _meta$lastDragCancell;
|
|
239
|
+
var _apply = function apply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, nodeDecorationRegistry) {
|
|
240
|
+
var _api$limitedMode, _meta$multiSelectDnD, _api$editorViewMode, _activeNode, _activeNode2, _meta$activeNode$hand, _activeNode3, _activeNode4, _meta$isDragging2, _meta$isDragging3, _meta$toggleMenu, _meta$toggleMenu2, _meta$toggleMenu3, _meta$toggleMenu4, _meta$toggleMenu5, _meta$toggleMenu6, _meta$toggleMenu7, _meta$toggleMenu8, _meta$editorHeight, _meta$editorWidthLeft, _meta$editorWidthRigh, _meta$isPMDragging, _meta$isShiftDown, _meta$lastDragCancell;
|
|
241
|
+
var rightSideControlsEnabled = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : false;
|
|
242
|
+
var anchorRectCache = arguments.length > 9 ? arguments[9] : undefined;
|
|
243
|
+
var resizeObserverWidth = arguments.length > 10 ? arguments[10] : undefined;
|
|
244
|
+
var pragmaticCleanup = arguments.length > 11 ? arguments[11] : undefined;
|
|
241
245
|
var activeNode = currentState.activeNode,
|
|
242
246
|
decorations = currentState.decorations,
|
|
243
247
|
isResizerResizing = currentState.isResizerResizing,
|
|
@@ -345,6 +349,7 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
|
|
|
345
349
|
}
|
|
346
350
|
var maybeNodeCountChanged = !isAllText && numReplaceSteps > 0;
|
|
347
351
|
var latestActiveNode = meta === null || meta === void 0 ? void 0 : meta.activeNode;
|
|
352
|
+
var isViewMode = (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) === 'view';
|
|
348
353
|
if (!latestActiveNode && (!isActiveNodeDeleted || isReplacedWithSameSize)) {
|
|
349
354
|
latestActiveNode = activeNode;
|
|
350
355
|
}
|
|
@@ -456,12 +461,35 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
|
|
|
456
461
|
_iterator.f();
|
|
457
462
|
}
|
|
458
463
|
}
|
|
464
|
+
if (rightSideControlsEnabled && expValEquals('confluence_remix_icon_right_side', 'isEnabled', true) && isViewMode) {
|
|
465
|
+
var _iterator2 = _createForOfIteratorHelper(nodeDecorationRegistry),
|
|
466
|
+
_step2;
|
|
467
|
+
try {
|
|
468
|
+
var _loop2 = function _loop2() {
|
|
469
|
+
var factory = _step2.value;
|
|
470
|
+
if (factory.showInViewMode) {
|
|
471
|
+
var _activeNode1, _activeNode10;
|
|
472
|
+
var old = decorations.find((_activeNode1 = activeNode) === null || _activeNode1 === void 0 ? void 0 : _activeNode1.rootPos, (_activeNode10 = activeNode) === null || _activeNode10 === void 0 ? void 0 : _activeNode10.rootPos, function (spec) {
|
|
473
|
+
return spec.type === factory.type;
|
|
474
|
+
});
|
|
475
|
+
decorations = decorations.remove(old);
|
|
476
|
+
}
|
|
477
|
+
};
|
|
478
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
479
|
+
_loop2();
|
|
480
|
+
}
|
|
481
|
+
} catch (err) {
|
|
482
|
+
_iterator2.e(err);
|
|
483
|
+
} finally {
|
|
484
|
+
_iterator2.f();
|
|
485
|
+
}
|
|
486
|
+
}
|
|
459
487
|
}
|
|
460
488
|
} else if (api) {
|
|
461
|
-
var _latestActiveNode5;
|
|
462
|
-
if (shouldRecreateHandle) {
|
|
463
|
-
var
|
|
464
|
-
var _oldHandle = findHandleDec(decorations, (
|
|
489
|
+
var _latestActiveNode5, _latestActiveNode14;
|
|
490
|
+
if (shouldRecreateHandle && (!rightSideControlsEnabled || !isViewMode)) {
|
|
491
|
+
var _activeNode11, _activeNode12, _latestActiveNode, _latestActiveNode2, _latestActiveNode3, _latestActiveNode4;
|
|
492
|
+
var _oldHandle = findHandleDec(decorations, (_activeNode11 = activeNode) === null || _activeNode11 === void 0 ? void 0 : _activeNode11.pos, (_activeNode12 = activeNode) === null || _activeNode12 === void 0 ? void 0 : _activeNode12.pos);
|
|
465
493
|
decorations = decorations.remove(_oldHandle);
|
|
466
494
|
var handleDec = dragHandleDecoration({
|
|
467
495
|
api: api,
|
|
@@ -478,9 +506,9 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
|
|
|
478
506
|
}
|
|
479
507
|
if (shouldRecreateQuickInsertButton && ((_latestActiveNode5 = latestActiveNode) === null || _latestActiveNode5 === void 0 ? void 0 : _latestActiveNode5.rootPos) !== undefined &&
|
|
480
508
|
// platform_editor_controls note: enables quick insert
|
|
481
|
-
flags.toolbarFlagsEnabled) {
|
|
482
|
-
var
|
|
483
|
-
var _oldQuickInsertButton = findQuickInsertInsertButtonDecoration(decorations, (
|
|
509
|
+
flags.toolbarFlagsEnabled && (!rightSideControlsEnabled || !isViewMode)) {
|
|
510
|
+
var _activeNode13, _activeNode14, _latestActiveNode6, _latestActiveNode7, _latestActiveNode8, _latestActiveNode9, _latestActiveNode0;
|
|
511
|
+
var _oldQuickInsertButton = findQuickInsertInsertButtonDecoration(decorations, (_activeNode13 = activeNode) === null || _activeNode13 === void 0 ? void 0 : _activeNode13.rootPos, (_activeNode14 = activeNode) === null || _activeNode14 === void 0 ? void 0 : _activeNode14.rootPos);
|
|
484
512
|
decorations = decorations.remove(_oldQuickInsertButton);
|
|
485
513
|
var quickInsertButton = quickInsertButtonDecoration({
|
|
486
514
|
api: api,
|
|
@@ -496,13 +524,13 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
|
|
|
496
524
|
});
|
|
497
525
|
decorations = decorations.add(newState.doc, [quickInsertButton]);
|
|
498
526
|
if (fg('platform_editor_expose_block_controls_deco_api')) {
|
|
499
|
-
var
|
|
500
|
-
|
|
527
|
+
var _iterator3 = _createForOfIteratorHelper(nodeDecorationRegistry),
|
|
528
|
+
_step3;
|
|
501
529
|
try {
|
|
502
|
-
var
|
|
503
|
-
var
|
|
504
|
-
var factory =
|
|
505
|
-
var old = decorations.find((
|
|
530
|
+
var _loop3 = function _loop3() {
|
|
531
|
+
var _activeNode15, _activeNode16, _latestActiveNode1, _latestActiveNode10, _latestActiveNode11, _latestActiveNode12, _latestActiveNode13;
|
|
532
|
+
var factory = _step3.value;
|
|
533
|
+
var old = decorations.find((_activeNode15 = activeNode) === null || _activeNode15 === void 0 ? void 0 : _activeNode15.rootPos, (_activeNode16 = activeNode) === null || _activeNode16 === void 0 ? void 0 : _activeNode16.rootPos, function (spec) {
|
|
506
534
|
return spec.type === factory.type;
|
|
507
535
|
});
|
|
508
536
|
decorations = decorations.remove(old);
|
|
@@ -517,16 +545,83 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
|
|
|
517
545
|
});
|
|
518
546
|
decorations = decorations.add(newState.doc, [dec]);
|
|
519
547
|
};
|
|
520
|
-
for (
|
|
521
|
-
|
|
548
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
549
|
+
_loop3();
|
|
522
550
|
}
|
|
523
551
|
} catch (err) {
|
|
524
|
-
|
|
552
|
+
_iterator3.e(err);
|
|
525
553
|
} finally {
|
|
526
|
-
|
|
554
|
+
_iterator3.f();
|
|
527
555
|
}
|
|
528
556
|
}
|
|
529
557
|
}
|
|
558
|
+
|
|
559
|
+
// In view mode (edit/live pages), show right-side controls on block hover (without drag handle or quick insert)
|
|
560
|
+
if (isViewMode && ((_latestActiveNode14 = latestActiveNode) === null || _latestActiveNode14 === void 0 ? void 0 : _latestActiveNode14.rootPos) !== undefined && flags.toolbarFlagsEnabled && rightSideControlsEnabled && expValEquals('confluence_remix_icon_right_side', 'isEnabled', true)) {
|
|
561
|
+
var rootPos = latestActiveNode.rootPos;
|
|
562
|
+
var _iterator4 = _createForOfIteratorHelper(nodeDecorationRegistry),
|
|
563
|
+
_step4;
|
|
564
|
+
try {
|
|
565
|
+
var _loop4 = function _loop4() {
|
|
566
|
+
var factory = _step4.value;
|
|
567
|
+
if (factory.showInViewMode) {
|
|
568
|
+
var _latestActiveNode15, _latestActiveNode16, _latestActiveNode17, _latestActiveNode18, _latestActiveNode19;
|
|
569
|
+
var existingAtPos = decorations.find(rootPos, rootPos, function (spec) {
|
|
570
|
+
return spec.type === factory.type;
|
|
571
|
+
});
|
|
572
|
+
// Skip remove/re-add when decoration already exists at correct position - avoids
|
|
573
|
+
// flickering from widget destroy/recreate on every transaction (e.g. on hover).
|
|
574
|
+
if (existingAtPos.length > 0) {
|
|
575
|
+
return 1; // continue
|
|
576
|
+
}
|
|
577
|
+
// Remove any stale decoration at a different position (e.g. after moving to another block)
|
|
578
|
+
var stale = decorations.find(0, newState.doc.nodeSize, function (spec) {
|
|
579
|
+
return spec.type === factory.type;
|
|
580
|
+
});
|
|
581
|
+
decorations = decorations.remove(stale);
|
|
582
|
+
var dec = factory.create({
|
|
583
|
+
editorState: newState,
|
|
584
|
+
nodeViewPortalProviderAPI: nodeViewPortalProviderAPI,
|
|
585
|
+
anchorName: (_latestActiveNode15 = latestActiveNode) === null || _latestActiveNode15 === void 0 ? void 0 : _latestActiveNode15.anchorName,
|
|
586
|
+
nodeType: (_latestActiveNode16 = latestActiveNode) === null || _latestActiveNode16 === void 0 ? void 0 : _latestActiveNode16.nodeType,
|
|
587
|
+
rootPos: (_latestActiveNode17 = latestActiveNode) === null || _latestActiveNode17 === void 0 ? void 0 : _latestActiveNode17.rootPos,
|
|
588
|
+
rootAnchorName: (_latestActiveNode18 = latestActiveNode) === null || _latestActiveNode18 === void 0 ? void 0 : _latestActiveNode18.rootAnchorName,
|
|
589
|
+
rootNodeType: (_latestActiveNode19 = latestActiveNode) === null || _latestActiveNode19 === void 0 ? void 0 : _latestActiveNode19.rootNodeType
|
|
590
|
+
});
|
|
591
|
+
decorations = decorations.add(newState.doc, [dec]);
|
|
592
|
+
}
|
|
593
|
+
};
|
|
594
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
595
|
+
if (_loop4()) continue;
|
|
596
|
+
}
|
|
597
|
+
} catch (err) {
|
|
598
|
+
_iterator4.e(err);
|
|
599
|
+
} finally {
|
|
600
|
+
_iterator4.f();
|
|
601
|
+
}
|
|
602
|
+
} else if (isViewMode && rightSideControlsEnabled && expValEquals('confluence_remix_icon_right_side', 'isEnabled', true)) {
|
|
603
|
+
// Remove view-mode right-side decorations when no active node
|
|
604
|
+
var _iterator5 = _createForOfIteratorHelper(nodeDecorationRegistry),
|
|
605
|
+
_step5;
|
|
606
|
+
try {
|
|
607
|
+
var _loop5 = function _loop5() {
|
|
608
|
+
var factory = _step5.value;
|
|
609
|
+
if (factory.showInViewMode) {
|
|
610
|
+
var old = decorations.find(0, newState.doc.nodeSize, function (spec) {
|
|
611
|
+
return spec.type === factory.type;
|
|
612
|
+
});
|
|
613
|
+
decorations = decorations.remove(old);
|
|
614
|
+
}
|
|
615
|
+
};
|
|
616
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
617
|
+
_loop5();
|
|
618
|
+
}
|
|
619
|
+
} catch (err) {
|
|
620
|
+
_iterator5.e(err);
|
|
621
|
+
} finally {
|
|
622
|
+
_iterator5.f();
|
|
623
|
+
}
|
|
624
|
+
}
|
|
530
625
|
}
|
|
531
626
|
|
|
532
627
|
// Drop targets may be missing when the node count is being changed during a drag
|
|
@@ -573,12 +668,15 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
|
|
|
573
668
|
var newActiveNode;
|
|
574
669
|
// platform_editor_controls note: enables quick insert
|
|
575
670
|
if (flags.toolbarFlagsEnabled) {
|
|
576
|
-
var
|
|
671
|
+
var _latestActiveNode20, _latestActiveNode21;
|
|
577
672
|
// remove isEmptyDoc check and let decorations render and determine their own visibility
|
|
578
|
-
|
|
673
|
+
// In view mode with right-side controls we render node decorations (right-edge button), not the
|
|
674
|
+
// handle - so findHandleDec is always empty. Don't clear activeNode in that case.
|
|
675
|
+
var hasHandleOrViewModeControls = findHandleDec(decorations, (_latestActiveNode20 = latestActiveNode) === null || _latestActiveNode20 === void 0 ? void 0 : _latestActiveNode20.pos, (_latestActiveNode21 = latestActiveNode) === null || _latestActiveNode21 === void 0 ? void 0 : _latestActiveNode21.pos).length > 0 || isViewMode && rightSideControlsEnabled;
|
|
676
|
+
newActiveNode = meta !== null && meta !== void 0 && meta.editorBlurred || !(meta !== null && meta !== void 0 && meta.activeNode) && !hasHandleOrViewModeControls ? null : latestActiveNode;
|
|
579
677
|
} else {
|
|
580
|
-
var
|
|
581
|
-
newActiveNode = isEmptyDoc || !(meta !== null && meta !== void 0 && meta.activeNode) && findHandleDec(decorations, (
|
|
678
|
+
var _latestActiveNode22, _latestActiveNode23;
|
|
679
|
+
newActiveNode = isEmptyDoc || !(meta !== null && meta !== void 0 && meta.activeNode) && findHandleDec(decorations, (_latestActiveNode22 = latestActiveNode) === null || _latestActiveNode22 === void 0 ? void 0 : _latestActiveNode22.pos, (_latestActiveNode23 = latestActiveNode) === null || _latestActiveNode23 === void 0 ? void 0 : _latestActiveNode23.pos).length === 0 ? null : latestActiveNode;
|
|
582
680
|
}
|
|
583
681
|
var isMenuOpenNew = isMenuOpen;
|
|
584
682
|
if (expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true)) {
|
|
@@ -624,6 +722,7 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
|
|
|
624
722
|
};
|
|
625
723
|
export { _apply as apply };
|
|
626
724
|
export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProviderAPI, nodeDecorationRegistry) {
|
|
725
|
+
var rightSideControlsEnabled = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
627
726
|
var _getIntl = getIntl(),
|
|
628
727
|
formatMessage = _getIntl.formatMessage;
|
|
629
728
|
var isAdvancedLayoutEnabled = editorExperiment('advanced_layouts', true, {
|
|
@@ -650,7 +749,7 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
650
749
|
return initialState;
|
|
651
750
|
},
|
|
652
751
|
apply: function apply(tr, currentState, _, newState) {
|
|
653
|
-
return _apply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, nodeDecorationRegistry, anchorRectCache, resizeObserverWidth, pragmaticCleanup);
|
|
752
|
+
return _apply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled, anchorRectCache, resizeObserverWidth, pragmaticCleanup);
|
|
654
753
|
}
|
|
655
754
|
},
|
|
656
755
|
props: {
|
|
@@ -661,7 +760,12 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
661
760
|
}
|
|
662
761
|
var isDisabled = api === null || api === void 0 || (_api$editorDisabled = api.editorDisabled) === null || _api$editorDisabled === void 0 || (_api$editorDisabled = _api$editorDisabled.sharedState.currentState()) === null || _api$editorDisabled === void 0 ? void 0 : _api$editorDisabled.editorDisabled;
|
|
663
762
|
if (isDisabled) {
|
|
664
|
-
|
|
763
|
+
var _api$editorViewMode2;
|
|
764
|
+
var remixRightSideEnabled = rightSideControlsEnabled && expValEquals('confluence_remix_icon_right_side', 'isEnabled', true);
|
|
765
|
+
// Hide decorations when disabled, except in view mode when right-side controls are enabled
|
|
766
|
+
if (!remixRightSideEnabled || (api === null || api === void 0 || (_api$editorViewMode2 = api.editorViewMode) === null || _api$editorViewMode2 === void 0 || (_api$editorViewMode2 = _api$editorViewMode2.sharedState.currentState()) === null || _api$editorViewMode2 === void 0 ? void 0 : _api$editorViewMode2.mode) !== 'view') {
|
|
767
|
+
return;
|
|
768
|
+
}
|
|
665
769
|
}
|
|
666
770
|
return (_key$getState2 = key.getState(state)) === null || _key$getState2 === void 0 ? void 0 : _key$getState2.decorations;
|
|
667
771
|
},
|
|
@@ -8,6 +8,7 @@ import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
|
8
8
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
9
9
|
import { findParentNode, findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
10
10
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
11
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
11
12
|
import { isInTextSelection, isNestedNodeSelected, isNonEditableBlock, isSelectionInNode } from '../ui/utils/document-checks';
|
|
12
13
|
import { createNewLine } from '../ui/utils/editor-commands';
|
|
13
14
|
import { calculatePosition } from './quick-insert-calculate-position';
|
|
@@ -56,7 +57,7 @@ var vanillaQuickInsert = function vanillaQuickInsert(_ref) {
|
|
|
56
57
|
* Create a Node which contains the quick insert button
|
|
57
58
|
*/
|
|
58
59
|
export var createVanillaButton = function createVanillaButton(props) {
|
|
59
|
-
var _props$api$typeAhead, _props$api$blockContr, _props$api$typeAhead2, _props$api$
|
|
60
|
+
var _props$api$typeAhead, _props$api$blockContr, _props$api$blockContr2, _props$api$blockContr3, _props$api$blockContr4, _props$api$editorView, _props$api$typeAhead2, _props$api$blockContr5;
|
|
60
61
|
var _DOMSerializer$render = DOMSerializer.renderSpec(document, vanillaQuickInsert(props)),
|
|
61
62
|
dom = _DOMSerializer$render.dom;
|
|
62
63
|
if (dom instanceof HTMLElement) {
|
|
@@ -75,11 +76,18 @@ export var createVanillaButton = function createVanillaButton(props) {
|
|
|
75
76
|
// Dynamically control the visibility of the node
|
|
76
77
|
var isTypeAheadOpen = (_props$api$typeAhead = props.api.typeAhead) === null || _props$api$typeAhead === void 0 || (_props$api$typeAhead = _props$api$typeAhead.sharedState.currentState()) === null || _props$api$typeAhead === void 0 ? void 0 : _props$api$typeAhead.isOpen;
|
|
77
78
|
var isEditing = (_props$api$blockContr = props.api.blockControls) === null || _props$api$blockContr === void 0 || (_props$api$blockContr = _props$api$blockContr.sharedState.currentState()) === null || _props$api$blockContr === void 0 ? void 0 : _props$api$blockContr.isEditing;
|
|
79
|
+
var hoverSide = (_props$api$blockContr2 = props.api.blockControls) === null || _props$api$blockContr2 === void 0 || (_props$api$blockContr2 = _props$api$blockContr2.sharedState.currentState()) === null || _props$api$blockContr2 === void 0 ? void 0 : _props$api$blockContr2.hoverSide;
|
|
80
|
+
var rightSideControlsEnabled = (_props$api$blockContr3 = (_props$api$blockContr4 = props.api.blockControls) === null || _props$api$blockContr4 === void 0 || (_props$api$blockContr4 = _props$api$blockContr4.sharedState.currentState()) === null || _props$api$blockContr4 === void 0 ? void 0 : _props$api$blockContr4.rightSideControlsEnabled) !== null && _props$api$blockContr3 !== void 0 ? _props$api$blockContr3 : false;
|
|
81
|
+
var editorViewMode = (_props$api$editorView = props.api.editorViewMode) === null || _props$api$editorView === void 0 || (_props$api$editorView = _props$api$editorView.sharedState.currentState()) === null || _props$api$editorView === void 0 ? void 0 : _props$api$editorView.mode;
|
|
78
82
|
var changeDOMVisibility = function changeDOMVisibility() {
|
|
79
83
|
if (!(dom instanceof HTMLElement)) {
|
|
80
84
|
return;
|
|
81
85
|
}
|
|
82
|
-
|
|
86
|
+
var isViewMode = editorViewMode === 'view';
|
|
87
|
+
var shouldRestrictBySide = rightSideControlsEnabled && expValEquals('confluence_remix_icon_right_side', 'isEnabled', true) && !isViewMode;
|
|
88
|
+
// Only restrict by side when hoverSide is known. When undefined, show quick insert.
|
|
89
|
+
var sideHidden = shouldRestrictBySide && hoverSide !== undefined ? hoverSide !== 'left' : false;
|
|
90
|
+
if (isTypeAheadOpen || isEditing || sideHidden) {
|
|
83
91
|
dom.classList.add('blocks-quick-insert-invisible-container');
|
|
84
92
|
dom.classList.remove('blocks-quick-insert-visible-container');
|
|
85
93
|
} else {
|
|
@@ -93,19 +101,34 @@ export var createVanillaButton = function createVanillaButton(props) {
|
|
|
93
101
|
isTypeAheadOpen = nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.isOpen;
|
|
94
102
|
changeDOMVisibility();
|
|
95
103
|
}));
|
|
96
|
-
props.cleanupCallbacks.push((_props$api$
|
|
104
|
+
props.cleanupCallbacks.push((_props$api$blockContr5 = props.api.blockControls) === null || _props$api$blockContr5 === void 0 ? void 0 : _props$api$blockContr5.sharedState.onChange(function (_ref3) {
|
|
105
|
+
var _nextSharedState$righ;
|
|
97
106
|
var nextSharedState = _ref3.nextSharedState;
|
|
98
107
|
isEditing = nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.isEditing;
|
|
108
|
+
hoverSide = nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.hoverSide;
|
|
109
|
+
rightSideControlsEnabled = (_nextSharedState$righ = nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.rightSideControlsEnabled) !== null && _nextSharedState$righ !== void 0 ? _nextSharedState$righ : false;
|
|
99
110
|
changeDOMVisibility();
|
|
100
111
|
}));
|
|
112
|
+
// Only subscribe to view mode when right-side controls are enabled (editorViewMode affects side restriction)
|
|
113
|
+
if (rightSideControlsEnabled && expValEquals('confluence_remix_icon_right_side', 'isEnabled', true)) {
|
|
114
|
+
var _props$api$editorView2, _props$api$editorView3, _props$api$editorView4;
|
|
115
|
+
var unsubscribeViewMode = (_props$api$editorView2 = props.api.editorViewMode) === null || _props$api$editorView2 === void 0 || (_props$api$editorView3 = (_props$api$editorView4 = _props$api$editorView2.sharedState).onChange) === null || _props$api$editorView3 === void 0 ? void 0 : _props$api$editorView3.call(_props$api$editorView4, function (_ref4) {
|
|
116
|
+
var nextSharedState = _ref4.nextSharedState;
|
|
117
|
+
editorViewMode = nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.mode;
|
|
118
|
+
changeDOMVisibility();
|
|
119
|
+
});
|
|
120
|
+
if (unsubscribeViewMode) {
|
|
121
|
+
props.cleanupCallbacks.push(unsubscribeViewMode);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
101
124
|
return dom;
|
|
102
125
|
};
|
|
103
126
|
var TEXT_PARENT_TYPES = ['paragraph', 'heading', 'blockquote', 'taskItem', 'decisionItem'];
|
|
104
|
-
var handleQuickInsert = function handleQuickInsert(
|
|
127
|
+
var handleQuickInsert = function handleQuickInsert(_ref5) {
|
|
105
128
|
var _api$quickInsert;
|
|
106
|
-
var api =
|
|
107
|
-
view =
|
|
108
|
-
getPos =
|
|
129
|
+
var api = _ref5.api,
|
|
130
|
+
view = _ref5.view,
|
|
131
|
+
getPos = _ref5.getPos;
|
|
109
132
|
// if the selection is not within the node this decoration is rendered at
|
|
110
133
|
// then insert a newline and trigger quick insert
|
|
111
134
|
var start = getPos();
|
|
@@ -134,8 +157,8 @@ var handleQuickInsert = function handleQuickInsert(_ref4) {
|
|
|
134
157
|
var newPos =
|
|
135
158
|
//if the current selection is selected from right to left, then set the selection to the start of the paragraph
|
|
136
159
|
currentSelection.anchor === currentSelection.to ? currentParagraphNode.pos : currentParagraphNode.pos + currentParagraphNode.node.nodeSize - 1;
|
|
137
|
-
api.core.actions.execute(function (
|
|
138
|
-
var tr =
|
|
160
|
+
api.core.actions.execute(function (_ref6) {
|
|
161
|
+
var tr = _ref6.tr;
|
|
139
162
|
tr.setSelection(TextSelection.create(view.state.selection.$from.doc, newPos));
|
|
140
163
|
return tr;
|
|
141
164
|
});
|
|
@@ -149,8 +172,8 @@ var handleQuickInsert = function handleQuickInsert(_ref4) {
|
|
|
149
172
|
// otherwise need to force the selection to be at the start of the node, because
|
|
150
173
|
// prosemirror is keeping it as NodeSelection for nested nodes. Do this to keep it
|
|
151
174
|
// consistent NodeSelection for root level nodes.
|
|
152
|
-
api.core.actions.execute(function (
|
|
153
|
-
var tr =
|
|
175
|
+
api.core.actions.execute(function (_ref7) {
|
|
176
|
+
var tr = _ref7.tr;
|
|
154
177
|
createNewLine(view.state.selection.from)({
|
|
155
178
|
tr: tr
|
|
156
179
|
});
|
|
@@ -162,8 +185,8 @@ var handleQuickInsert = function handleQuickInsert(_ref4) {
|
|
|
162
185
|
if (currentSelection instanceof CellSelection) {
|
|
163
186
|
// find the last inline position in the selection
|
|
164
187
|
var lastInlinePosition = TextSelection.near(view.state.selection.$to, -1);
|
|
165
|
-
lastInlinePosition && api.core.actions.execute(function (
|
|
166
|
-
var tr =
|
|
188
|
+
lastInlinePosition && api.core.actions.execute(function (_ref8) {
|
|
189
|
+
var tr = _ref8.tr;
|
|
167
190
|
if (!(lastInlinePosition instanceof TextSelection)) {
|
|
168
191
|
// this will create a new line after the node
|
|
169
192
|
createNewLine(lastInlinePosition.from)({
|
|
@@ -21,7 +21,6 @@ import { dragToMoveDown, dragToMoveLeft, dragToMoveRight, dragToMoveUp, getAriaK
|
|
|
21
21
|
import { blockControlsMessages } from '@atlaskit/editor-common/messages';
|
|
22
22
|
import { expandToBlockRange, isMultiBlockRange } from '@atlaskit/editor-common/selection';
|
|
23
23
|
import { DRAG_HANDLE_WIDTH, tableControlsSpacing } from '@atlaskit/editor-common/styles';
|
|
24
|
-
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
25
24
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
26
25
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
27
26
|
import { akEditorFullPageNarrowBreakout, akEditorTableToolbarSize, relativeSizeToBaseFontSize } from '@atlaskit/editor-shared-styles/consts';
|
|
@@ -432,16 +431,19 @@ export var DragHandle = function DragHandle(_ref3) {
|
|
|
432
431
|
_useState10 = _slicedToArray(_useState1, 2),
|
|
433
432
|
isFocused = _useState10[0],
|
|
434
433
|
setIsFocused = _useState10[1];
|
|
435
|
-
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['featureFlags'], function (states) {
|
|
436
|
-
var _states$featureFlagsS;
|
|
434
|
+
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['featureFlags', 'selection', 'blockControls', 'interaction'], function (states) {
|
|
435
|
+
var _states$featureFlagsS, _states$selectionStat, _states$blockControls, _states$interactionSt;
|
|
437
436
|
return {
|
|
438
|
-
macroInteractionUpdates: (_states$featureFlagsS = states.featureFlagsState) === null || _states$featureFlagsS === void 0 ? void 0 : _states$featureFlagsS.macroInteractionUpdates
|
|
437
|
+
macroInteractionUpdates: (_states$featureFlagsS = states.featureFlagsState) === null || _states$featureFlagsS === void 0 ? void 0 : _states$featureFlagsS.macroInteractionUpdates,
|
|
438
|
+
selection: (_states$selectionStat = states.selectionState) === null || _states$selectionStat === void 0 ? void 0 : _states$selectionStat.selection,
|
|
439
|
+
isShiftDown: (_states$blockControls = states.blockControlsState) === null || _states$blockControls === void 0 ? void 0 : _states$blockControls.isShiftDown,
|
|
440
|
+
interactionState: (_states$interactionSt = states.interactionState) === null || _states$interactionSt === void 0 ? void 0 : _states$interactionSt.interactionState
|
|
439
441
|
};
|
|
440
442
|
}),
|
|
441
|
-
macroInteractionUpdates = _useSharedPluginState.macroInteractionUpdates
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
443
|
+
macroInteractionUpdates = _useSharedPluginState.macroInteractionUpdates,
|
|
444
|
+
selection = _useSharedPluginState.selection,
|
|
445
|
+
isShiftDown = _useSharedPluginState.isShiftDown,
|
|
446
|
+
interactionState = _useSharedPluginState.interactionState;
|
|
445
447
|
var start = getPos();
|
|
446
448
|
var isLayoutColumn = nodeType === 'layoutColumn';
|
|
447
449
|
var isMultiSelect = editorExperiment('platform_editor_element_drag_and_drop_multiselect', true);
|
|
@@ -1119,6 +1121,7 @@ export var DragHandle = function DragHandle(_ref3) {
|
|
|
1119
1121
|
onDrop: handleOnDrop,
|
|
1120
1122
|
disabled: dragHandleDisabled,
|
|
1121
1123
|
"data-editor-block-ctrl-drag-handle": true,
|
|
1124
|
+
"data-blocks-drag-handle": expValEquals('confluence_remix_icon_right_side', 'isEnabled', true) || undefined,
|
|
1122
1125
|
"data-testid": "block-ctrl-drag-handle",
|
|
1123
1126
|
"aria-label": dragHandleAriaLabel,
|
|
1124
1127
|
onBlur: expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) ? function () {
|
|
@@ -1205,8 +1208,15 @@ export var DragHandleWithVisibility = function DragHandleWithVisibility(_ref10)
|
|
|
1205
1208
|
handleOptions = _ref10.handleOptions,
|
|
1206
1209
|
isTopLevelNode = _ref10.isTopLevelNode,
|
|
1207
1210
|
anchorRectCache = _ref10.anchorRectCache;
|
|
1211
|
+
var rightSideControlsEnabled = useSharedPluginStateWithSelector(api, ['blockControls'], function (states) {
|
|
1212
|
+
var _states$blockControls2, _states$blockControls3;
|
|
1213
|
+
return {
|
|
1214
|
+
rightSideControlsEnabled: (_states$blockControls2 = (_states$blockControls3 = states.blockControlsState) === null || _states$blockControls3 === void 0 ? void 0 : _states$blockControls3.rightSideControlsEnabled) !== null && _states$blockControls2 !== void 0 ? _states$blockControls2 : false
|
|
1215
|
+
};
|
|
1216
|
+
}).rightSideControlsEnabled;
|
|
1208
1217
|
return jsx(VisibilityContainer, {
|
|
1209
|
-
api: api
|
|
1218
|
+
api: api,
|
|
1219
|
+
controlSide: rightSideControlsEnabled ? 'left' : undefined
|
|
1210
1220
|
}, jsx(DragHandle, {
|
|
1211
1221
|
view: view,
|
|
1212
1222
|
api: api,
|
|
@@ -5,9 +5,9 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
5
5
|
*/
|
|
6
6
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles, @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
7
7
|
import { css, Global, jsx } from '@emotion/react';
|
|
8
|
+
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
8
9
|
import { ANCHOR_VARIABLE_NAME, DRAG_HANDLE_WIDTH, isCSSAnchorSupported, tableControlsSpacing } from '@atlaskit/editor-common/styles';
|
|
9
10
|
import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
|
|
10
|
-
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
11
11
|
import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/whitespace';
|
|
12
12
|
import { akEditorBreakoutPadding, akEditorCalculatedWideLayoutWidth, akEditorCalculatedWideLayoutWidthSmallViewport, akEditorFullPageNarrowBreakout, akEditorGutterPaddingDynamic, akEditorGutterPaddingReduced } from '@atlaskit/editor-shared-styles';
|
|
13
13
|
import { layers } from '@atlaskit/theme/constants';
|
|
@@ -452,9 +452,14 @@ var dragAnchorStyles = css({
|
|
|
452
452
|
});
|
|
453
453
|
export var GlobalStylesWrapper = function GlobalStylesWrapper(_ref) {
|
|
454
454
|
var api = _ref.api;
|
|
455
|
-
var
|
|
456
|
-
|
|
457
|
-
|
|
455
|
+
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['blockControls'], function (states) {
|
|
456
|
+
var _states$blockControls;
|
|
457
|
+
return {
|
|
458
|
+
isDragging: (_states$blockControls = states.blockControlsState) === null || _states$blockControls === void 0 ? void 0 : _states$blockControls.isDragging
|
|
459
|
+
};
|
|
460
|
+
}),
|
|
461
|
+
isDraggingFromState = _useSharedPluginState.isDragging;
|
|
462
|
+
var isDragging = expValEquals('platform_editor_block_controls_perf_optimization', 'isEnabled', true) ? isDraggingFromState : false;
|
|
458
463
|
var shouldRenderAnchors = isCSSAnchorSupported() && expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true);
|
|
459
464
|
var toolbarFlagsEnabled = areToolbarFlagsEnabled(Boolean(api === null || api === void 0 ? void 0 : api.toolbar));
|
|
460
465
|
return jsx(Global, {
|
|
@@ -12,10 +12,10 @@ import React, { useCallback, useEffect, useState } from 'react';
|
|
|
12
12
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
13
13
|
import { css, jsx } from '@emotion/react';
|
|
14
14
|
import { bind } from 'bind-event-listener';
|
|
15
|
+
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
15
16
|
import { ToolTipContent } from '@atlaskit/editor-common/keymaps';
|
|
16
17
|
import { blockControlsMessages as messages } from '@atlaskit/editor-common/messages';
|
|
17
18
|
import { tableControlsSpacing } from '@atlaskit/editor-common/styles';
|
|
18
|
-
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
19
19
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
20
20
|
import { findParentNode, findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
21
21
|
import { relativeSizeToBaseFontSize } from '@atlaskit/editor-shared-styles';
|
|
@@ -155,7 +155,13 @@ export var TypeAheadControl = function TypeAheadControl(_ref) {
|
|
|
155
155
|
rootAnchorName = _ref.rootAnchorName,
|
|
156
156
|
rootNodeType = _ref.rootNodeType,
|
|
157
157
|
anchorRectCache = _ref.anchorRectCache;
|
|
158
|
-
var
|
|
158
|
+
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['featureFlags'], function (states) {
|
|
159
|
+
var _states$featureFlagsS;
|
|
160
|
+
return {
|
|
161
|
+
macroInteractionUpdates: (_states$featureFlagsS = states.featureFlagsState) === null || _states$featureFlagsS === void 0 ? void 0 : _states$featureFlagsS.macroInteractionUpdates
|
|
162
|
+
};
|
|
163
|
+
}),
|
|
164
|
+
macroInteractionUpdates = _useSharedPluginState.macroInteractionUpdates;
|
|
159
165
|
var _useState = useState({
|
|
160
166
|
display: 'none'
|
|
161
167
|
}),
|
|
@@ -359,8 +365,15 @@ export var QuickInsertWithVisibility = function QuickInsertWithVisibility(_ref5)
|
|
|
359
365
|
rootAnchorName = _ref5.rootAnchorName,
|
|
360
366
|
rootNodeType = _ref5.rootNodeType,
|
|
361
367
|
anchorRectCache = _ref5.anchorRectCache;
|
|
368
|
+
var rightSideControlsEnabled = useSharedPluginStateWithSelector(api, ['blockControls'], function (states) {
|
|
369
|
+
var _states$blockControls, _states$blockControls2;
|
|
370
|
+
return {
|
|
371
|
+
rightSideControlsEnabled: (_states$blockControls = (_states$blockControls2 = states.blockControlsState) === null || _states$blockControls2 === void 0 ? void 0 : _states$blockControls2.rightSideControlsEnabled) !== null && _states$blockControls !== void 0 ? _states$blockControls : false
|
|
372
|
+
};
|
|
373
|
+
}).rightSideControlsEnabled;
|
|
362
374
|
return jsx(VisibilityContainer, {
|
|
363
|
-
api: api
|
|
375
|
+
api: api,
|
|
376
|
+
controlSide: rightSideControlsEnabled ? 'left' : undefined
|
|
364
377
|
}, jsx(TypeAheadControl, {
|
|
365
378
|
view: view,
|
|
366
379
|
api: api,
|