@atlaskit/editor-plugin-block-controls 8.7.1 → 8.8.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 +19 -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 +10 -5
- 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 +10 -4
- 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 +10 -5
- 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 +5 -7
|
@@ -243,8 +243,12 @@ var getDecorationAtPos = function getDecorationAtPos(state, decorations, pos, to
|
|
|
243
243
|
var nodeDecAtActivePos = nodeDecsAtActivePos.pop();
|
|
244
244
|
return nodeDecAtActivePos;
|
|
245
245
|
};
|
|
246
|
-
var _apply = exports.apply = function apply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, nodeDecorationRegistry
|
|
247
|
-
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;
|
|
246
|
+
var _apply = exports.apply = function apply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, nodeDecorationRegistry) {
|
|
247
|
+
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;
|
|
248
|
+
var rightSideControlsEnabled = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : false;
|
|
249
|
+
var anchorRectCache = arguments.length > 9 ? arguments[9] : undefined;
|
|
250
|
+
var resizeObserverWidth = arguments.length > 10 ? arguments[10] : undefined;
|
|
251
|
+
var pragmaticCleanup = arguments.length > 11 ? arguments[11] : undefined;
|
|
248
252
|
var activeNode = currentState.activeNode,
|
|
249
253
|
decorations = currentState.decorations,
|
|
250
254
|
isResizerResizing = currentState.isResizerResizing,
|
|
@@ -352,6 +356,7 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
|
|
|
352
356
|
}
|
|
353
357
|
var maybeNodeCountChanged = !isAllText && numReplaceSteps > 0;
|
|
354
358
|
var latestActiveNode = meta === null || meta === void 0 ? void 0 : meta.activeNode;
|
|
359
|
+
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';
|
|
355
360
|
if (!latestActiveNode && (!isActiveNodeDeleted || isReplacedWithSameSize)) {
|
|
356
361
|
latestActiveNode = activeNode;
|
|
357
362
|
}
|
|
@@ -463,12 +468,35 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
|
|
|
463
468
|
_iterator.f();
|
|
464
469
|
}
|
|
465
470
|
}
|
|
471
|
+
if (rightSideControlsEnabled && (0, _expValEquals.expValEquals)('confluence_remix_icon_right_side', 'isEnabled', true) && isViewMode) {
|
|
472
|
+
var _iterator2 = _createForOfIteratorHelper(nodeDecorationRegistry),
|
|
473
|
+
_step2;
|
|
474
|
+
try {
|
|
475
|
+
var _loop2 = function _loop2() {
|
|
476
|
+
var factory = _step2.value;
|
|
477
|
+
if (factory.showInViewMode) {
|
|
478
|
+
var _activeNode1, _activeNode10;
|
|
479
|
+
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) {
|
|
480
|
+
return spec.type === factory.type;
|
|
481
|
+
});
|
|
482
|
+
decorations = decorations.remove(old);
|
|
483
|
+
}
|
|
484
|
+
};
|
|
485
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
486
|
+
_loop2();
|
|
487
|
+
}
|
|
488
|
+
} catch (err) {
|
|
489
|
+
_iterator2.e(err);
|
|
490
|
+
} finally {
|
|
491
|
+
_iterator2.f();
|
|
492
|
+
}
|
|
493
|
+
}
|
|
466
494
|
}
|
|
467
495
|
} else if (api) {
|
|
468
|
-
var _latestActiveNode5;
|
|
469
|
-
if (shouldRecreateHandle) {
|
|
470
|
-
var
|
|
471
|
-
var _oldHandle = (0, _decorationsDragHandle.findHandleDec)(decorations, (
|
|
496
|
+
var _latestActiveNode5, _latestActiveNode14;
|
|
497
|
+
if (shouldRecreateHandle && (!rightSideControlsEnabled || !isViewMode)) {
|
|
498
|
+
var _activeNode11, _activeNode12, _latestActiveNode, _latestActiveNode2, _latestActiveNode3, _latestActiveNode4;
|
|
499
|
+
var _oldHandle = (0, _decorationsDragHandle.findHandleDec)(decorations, (_activeNode11 = activeNode) === null || _activeNode11 === void 0 ? void 0 : _activeNode11.pos, (_activeNode12 = activeNode) === null || _activeNode12 === void 0 ? void 0 : _activeNode12.pos);
|
|
472
500
|
decorations = decorations.remove(_oldHandle);
|
|
473
501
|
var handleDec = (0, _decorationsDragHandle.dragHandleDecoration)({
|
|
474
502
|
api: api,
|
|
@@ -485,9 +513,9 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
|
|
|
485
513
|
}
|
|
486
514
|
if (shouldRecreateQuickInsertButton && ((_latestActiveNode5 = latestActiveNode) === null || _latestActiveNode5 === void 0 ? void 0 : _latestActiveNode5.rootPos) !== undefined &&
|
|
487
515
|
// platform_editor_controls note: enables quick insert
|
|
488
|
-
flags.toolbarFlagsEnabled) {
|
|
489
|
-
var
|
|
490
|
-
var _oldQuickInsertButton = (0, _decorationsQuickInsertButton.findQuickInsertInsertButtonDecoration)(decorations, (
|
|
516
|
+
flags.toolbarFlagsEnabled && (!rightSideControlsEnabled || !isViewMode)) {
|
|
517
|
+
var _activeNode13, _activeNode14, _latestActiveNode6, _latestActiveNode7, _latestActiveNode8, _latestActiveNode9, _latestActiveNode0;
|
|
518
|
+
var _oldQuickInsertButton = (0, _decorationsQuickInsertButton.findQuickInsertInsertButtonDecoration)(decorations, (_activeNode13 = activeNode) === null || _activeNode13 === void 0 ? void 0 : _activeNode13.rootPos, (_activeNode14 = activeNode) === null || _activeNode14 === void 0 ? void 0 : _activeNode14.rootPos);
|
|
491
519
|
decorations = decorations.remove(_oldQuickInsertButton);
|
|
492
520
|
var quickInsertButton = (0, _decorationsQuickInsertButton.quickInsertButtonDecoration)({
|
|
493
521
|
api: api,
|
|
@@ -503,13 +531,13 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
|
|
|
503
531
|
});
|
|
504
532
|
decorations = decorations.add(newState.doc, [quickInsertButton]);
|
|
505
533
|
if ((0, _platformFeatureFlags.fg)('platform_editor_expose_block_controls_deco_api')) {
|
|
506
|
-
var
|
|
507
|
-
|
|
534
|
+
var _iterator3 = _createForOfIteratorHelper(nodeDecorationRegistry),
|
|
535
|
+
_step3;
|
|
508
536
|
try {
|
|
509
|
-
var
|
|
510
|
-
var
|
|
511
|
-
var factory =
|
|
512
|
-
var old = decorations.find((
|
|
537
|
+
var _loop3 = function _loop3() {
|
|
538
|
+
var _activeNode15, _activeNode16, _latestActiveNode1, _latestActiveNode10, _latestActiveNode11, _latestActiveNode12, _latestActiveNode13;
|
|
539
|
+
var factory = _step3.value;
|
|
540
|
+
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) {
|
|
513
541
|
return spec.type === factory.type;
|
|
514
542
|
});
|
|
515
543
|
decorations = decorations.remove(old);
|
|
@@ -524,16 +552,83 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
|
|
|
524
552
|
});
|
|
525
553
|
decorations = decorations.add(newState.doc, [dec]);
|
|
526
554
|
};
|
|
527
|
-
for (
|
|
528
|
-
|
|
555
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
556
|
+
_loop3();
|
|
529
557
|
}
|
|
530
558
|
} catch (err) {
|
|
531
|
-
|
|
559
|
+
_iterator3.e(err);
|
|
532
560
|
} finally {
|
|
533
|
-
|
|
561
|
+
_iterator3.f();
|
|
534
562
|
}
|
|
535
563
|
}
|
|
536
564
|
}
|
|
565
|
+
|
|
566
|
+
// In view mode (edit/live pages), show right-side controls on block hover (without drag handle or quick insert)
|
|
567
|
+
if (isViewMode && ((_latestActiveNode14 = latestActiveNode) === null || _latestActiveNode14 === void 0 ? void 0 : _latestActiveNode14.rootPos) !== undefined && flags.toolbarFlagsEnabled && rightSideControlsEnabled && (0, _expValEquals.expValEquals)('confluence_remix_icon_right_side', 'isEnabled', true)) {
|
|
568
|
+
var rootPos = latestActiveNode.rootPos;
|
|
569
|
+
var _iterator4 = _createForOfIteratorHelper(nodeDecorationRegistry),
|
|
570
|
+
_step4;
|
|
571
|
+
try {
|
|
572
|
+
var _loop4 = function _loop4() {
|
|
573
|
+
var factory = _step4.value;
|
|
574
|
+
if (factory.showInViewMode) {
|
|
575
|
+
var _latestActiveNode15, _latestActiveNode16, _latestActiveNode17, _latestActiveNode18, _latestActiveNode19;
|
|
576
|
+
var existingAtPos = decorations.find(rootPos, rootPos, function (spec) {
|
|
577
|
+
return spec.type === factory.type;
|
|
578
|
+
});
|
|
579
|
+
// Skip remove/re-add when decoration already exists at correct position - avoids
|
|
580
|
+
// flickering from widget destroy/recreate on every transaction (e.g. on hover).
|
|
581
|
+
if (existingAtPos.length > 0) {
|
|
582
|
+
return 1; // continue
|
|
583
|
+
}
|
|
584
|
+
// Remove any stale decoration at a different position (e.g. after moving to another block)
|
|
585
|
+
var stale = decorations.find(0, newState.doc.nodeSize, function (spec) {
|
|
586
|
+
return spec.type === factory.type;
|
|
587
|
+
});
|
|
588
|
+
decorations = decorations.remove(stale);
|
|
589
|
+
var dec = factory.create({
|
|
590
|
+
editorState: newState,
|
|
591
|
+
nodeViewPortalProviderAPI: nodeViewPortalProviderAPI,
|
|
592
|
+
anchorName: (_latestActiveNode15 = latestActiveNode) === null || _latestActiveNode15 === void 0 ? void 0 : _latestActiveNode15.anchorName,
|
|
593
|
+
nodeType: (_latestActiveNode16 = latestActiveNode) === null || _latestActiveNode16 === void 0 ? void 0 : _latestActiveNode16.nodeType,
|
|
594
|
+
rootPos: (_latestActiveNode17 = latestActiveNode) === null || _latestActiveNode17 === void 0 ? void 0 : _latestActiveNode17.rootPos,
|
|
595
|
+
rootAnchorName: (_latestActiveNode18 = latestActiveNode) === null || _latestActiveNode18 === void 0 ? void 0 : _latestActiveNode18.rootAnchorName,
|
|
596
|
+
rootNodeType: (_latestActiveNode19 = latestActiveNode) === null || _latestActiveNode19 === void 0 ? void 0 : _latestActiveNode19.rootNodeType
|
|
597
|
+
});
|
|
598
|
+
decorations = decorations.add(newState.doc, [dec]);
|
|
599
|
+
}
|
|
600
|
+
};
|
|
601
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
602
|
+
if (_loop4()) continue;
|
|
603
|
+
}
|
|
604
|
+
} catch (err) {
|
|
605
|
+
_iterator4.e(err);
|
|
606
|
+
} finally {
|
|
607
|
+
_iterator4.f();
|
|
608
|
+
}
|
|
609
|
+
} else if (isViewMode && rightSideControlsEnabled && (0, _expValEquals.expValEquals)('confluence_remix_icon_right_side', 'isEnabled', true)) {
|
|
610
|
+
// Remove view-mode right-side decorations when no active node
|
|
611
|
+
var _iterator5 = _createForOfIteratorHelper(nodeDecorationRegistry),
|
|
612
|
+
_step5;
|
|
613
|
+
try {
|
|
614
|
+
var _loop5 = function _loop5() {
|
|
615
|
+
var factory = _step5.value;
|
|
616
|
+
if (factory.showInViewMode) {
|
|
617
|
+
var old = decorations.find(0, newState.doc.nodeSize, function (spec) {
|
|
618
|
+
return spec.type === factory.type;
|
|
619
|
+
});
|
|
620
|
+
decorations = decorations.remove(old);
|
|
621
|
+
}
|
|
622
|
+
};
|
|
623
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
624
|
+
_loop5();
|
|
625
|
+
}
|
|
626
|
+
} catch (err) {
|
|
627
|
+
_iterator5.e(err);
|
|
628
|
+
} finally {
|
|
629
|
+
_iterator5.f();
|
|
630
|
+
}
|
|
631
|
+
}
|
|
537
632
|
}
|
|
538
633
|
|
|
539
634
|
// Drop targets may be missing when the node count is being changed during a drag
|
|
@@ -580,12 +675,15 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
|
|
|
580
675
|
var newActiveNode;
|
|
581
676
|
// platform_editor_controls note: enables quick insert
|
|
582
677
|
if (flags.toolbarFlagsEnabled) {
|
|
583
|
-
var
|
|
678
|
+
var _latestActiveNode20, _latestActiveNode21;
|
|
584
679
|
// remove isEmptyDoc check and let decorations render and determine their own visibility
|
|
585
|
-
|
|
680
|
+
// In view mode with right-side controls we render node decorations (right-edge button), not the
|
|
681
|
+
// handle - so findHandleDec is always empty. Don't clear activeNode in that case.
|
|
682
|
+
var hasHandleOrViewModeControls = (0, _decorationsDragHandle.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;
|
|
683
|
+
newActiveNode = meta !== null && meta !== void 0 && meta.editorBlurred || !(meta !== null && meta !== void 0 && meta.activeNode) && !hasHandleOrViewModeControls ? null : latestActiveNode;
|
|
586
684
|
} else {
|
|
587
|
-
var
|
|
588
|
-
newActiveNode = isEmptyDoc || !(meta !== null && meta !== void 0 && meta.activeNode) && (0, _decorationsDragHandle.findHandleDec)(decorations, (
|
|
685
|
+
var _latestActiveNode22, _latestActiveNode23;
|
|
686
|
+
newActiveNode = isEmptyDoc || !(meta !== null && meta !== void 0 && meta.activeNode) && (0, _decorationsDragHandle.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;
|
|
589
687
|
}
|
|
590
688
|
var isMenuOpenNew = isMenuOpen;
|
|
591
689
|
if ((0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true)) {
|
|
@@ -630,6 +728,7 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
|
|
|
630
728
|
};
|
|
631
729
|
};
|
|
632
730
|
var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, nodeViewPortalProviderAPI, nodeDecorationRegistry) {
|
|
731
|
+
var rightSideControlsEnabled = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
633
732
|
var _getIntl = getIntl(),
|
|
634
733
|
formatMessage = _getIntl.formatMessage;
|
|
635
734
|
var isAdvancedLayoutEnabled = (0, _experiments.editorExperiment)('advanced_layouts', true, {
|
|
@@ -656,7 +755,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
|
|
|
656
755
|
return initialState;
|
|
657
756
|
},
|
|
658
757
|
apply: function apply(tr, currentState, _, newState) {
|
|
659
|
-
return _apply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, nodeDecorationRegistry, anchorRectCache, resizeObserverWidth, pragmaticCleanup);
|
|
758
|
+
return _apply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled, anchorRectCache, resizeObserverWidth, pragmaticCleanup);
|
|
660
759
|
}
|
|
661
760
|
},
|
|
662
761
|
props: {
|
|
@@ -667,7 +766,12 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
|
|
|
667
766
|
}
|
|
668
767
|
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;
|
|
669
768
|
if (isDisabled) {
|
|
670
|
-
|
|
769
|
+
var _api$editorViewMode2;
|
|
770
|
+
var remixRightSideEnabled = rightSideControlsEnabled && (0, _expValEquals.expValEquals)('confluence_remix_icon_right_side', 'isEnabled', true);
|
|
771
|
+
// Hide decorations when disabled, except in view mode when right-side controls are enabled
|
|
772
|
+
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') {
|
|
773
|
+
return;
|
|
774
|
+
}
|
|
671
775
|
}
|
|
672
776
|
return (_key$getState2 = key.getState(state)) === null || _key$getState2 === void 0 ? void 0 : _key$getState2.decorations;
|
|
673
777
|
},
|
|
@@ -13,6 +13,7 @@ var _model = require("@atlaskit/editor-prosemirror/model");
|
|
|
13
13
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
14
14
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
15
15
|
var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
16
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
16
17
|
var _documentChecks = require("../ui/utils/document-checks");
|
|
17
18
|
var _editorCommands = require("../ui/utils/editor-commands");
|
|
18
19
|
var _quickInsertCalculatePosition = require("./quick-insert-calculate-position");
|
|
@@ -63,7 +64,7 @@ var vanillaQuickInsert = function vanillaQuickInsert(_ref) {
|
|
|
63
64
|
* Create a Node which contains the quick insert button
|
|
64
65
|
*/
|
|
65
66
|
var createVanillaButton = exports.createVanillaButton = function createVanillaButton(props) {
|
|
66
|
-
var _props$api$typeAhead, _props$api$blockContr, _props$api$typeAhead2, _props$api$
|
|
67
|
+
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;
|
|
67
68
|
var _DOMSerializer$render = _model.DOMSerializer.renderSpec(document, vanillaQuickInsert(props)),
|
|
68
69
|
dom = _DOMSerializer$render.dom;
|
|
69
70
|
if (dom instanceof HTMLElement) {
|
|
@@ -82,11 +83,18 @@ var createVanillaButton = exports.createVanillaButton = function createVanillaBu
|
|
|
82
83
|
// Dynamically control the visibility of the node
|
|
83
84
|
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;
|
|
84
85
|
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;
|
|
86
|
+
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;
|
|
87
|
+
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;
|
|
88
|
+
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;
|
|
85
89
|
var changeDOMVisibility = function changeDOMVisibility() {
|
|
86
90
|
if (!(dom instanceof HTMLElement)) {
|
|
87
91
|
return;
|
|
88
92
|
}
|
|
89
|
-
|
|
93
|
+
var isViewMode = editorViewMode === 'view';
|
|
94
|
+
var shouldRestrictBySide = rightSideControlsEnabled && (0, _expValEquals.expValEquals)('confluence_remix_icon_right_side', 'isEnabled', true) && !isViewMode;
|
|
95
|
+
// Only restrict by side when hoverSide is known. When undefined, show quick insert.
|
|
96
|
+
var sideHidden = shouldRestrictBySide && hoverSide !== undefined ? hoverSide !== 'left' : false;
|
|
97
|
+
if (isTypeAheadOpen || isEditing || sideHidden) {
|
|
90
98
|
dom.classList.add('blocks-quick-insert-invisible-container');
|
|
91
99
|
dom.classList.remove('blocks-quick-insert-visible-container');
|
|
92
100
|
} else {
|
|
@@ -100,19 +108,34 @@ var createVanillaButton = exports.createVanillaButton = function createVanillaBu
|
|
|
100
108
|
isTypeAheadOpen = nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.isOpen;
|
|
101
109
|
changeDOMVisibility();
|
|
102
110
|
}));
|
|
103
|
-
props.cleanupCallbacks.push((_props$api$
|
|
111
|
+
props.cleanupCallbacks.push((_props$api$blockContr5 = props.api.blockControls) === null || _props$api$blockContr5 === void 0 ? void 0 : _props$api$blockContr5.sharedState.onChange(function (_ref3) {
|
|
112
|
+
var _nextSharedState$righ;
|
|
104
113
|
var nextSharedState = _ref3.nextSharedState;
|
|
105
114
|
isEditing = nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.isEditing;
|
|
115
|
+
hoverSide = nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.hoverSide;
|
|
116
|
+
rightSideControlsEnabled = (_nextSharedState$righ = nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.rightSideControlsEnabled) !== null && _nextSharedState$righ !== void 0 ? _nextSharedState$righ : false;
|
|
106
117
|
changeDOMVisibility();
|
|
107
118
|
}));
|
|
119
|
+
// Only subscribe to view mode when right-side controls are enabled (editorViewMode affects side restriction)
|
|
120
|
+
if (rightSideControlsEnabled && (0, _expValEquals.expValEquals)('confluence_remix_icon_right_side', 'isEnabled', true)) {
|
|
121
|
+
var _props$api$editorView2, _props$api$editorView3, _props$api$editorView4;
|
|
122
|
+
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) {
|
|
123
|
+
var nextSharedState = _ref4.nextSharedState;
|
|
124
|
+
editorViewMode = nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.mode;
|
|
125
|
+
changeDOMVisibility();
|
|
126
|
+
});
|
|
127
|
+
if (unsubscribeViewMode) {
|
|
128
|
+
props.cleanupCallbacks.push(unsubscribeViewMode);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
108
131
|
return dom;
|
|
109
132
|
};
|
|
110
133
|
var TEXT_PARENT_TYPES = ['paragraph', 'heading', 'blockquote', 'taskItem', 'decisionItem'];
|
|
111
|
-
var handleQuickInsert = function handleQuickInsert(
|
|
134
|
+
var handleQuickInsert = function handleQuickInsert(_ref5) {
|
|
112
135
|
var _api$quickInsert;
|
|
113
|
-
var api =
|
|
114
|
-
view =
|
|
115
|
-
getPos =
|
|
136
|
+
var api = _ref5.api,
|
|
137
|
+
view = _ref5.view,
|
|
138
|
+
getPos = _ref5.getPos;
|
|
116
139
|
// if the selection is not within the node this decoration is rendered at
|
|
117
140
|
// then insert a newline and trigger quick insert
|
|
118
141
|
var start = getPos();
|
|
@@ -141,8 +164,8 @@ var handleQuickInsert = function handleQuickInsert(_ref4) {
|
|
|
141
164
|
var newPos =
|
|
142
165
|
//if the current selection is selected from right to left, then set the selection to the start of the paragraph
|
|
143
166
|
currentSelection.anchor === currentSelection.to ? currentParagraphNode.pos : currentParagraphNode.pos + currentParagraphNode.node.nodeSize - 1;
|
|
144
|
-
api.core.actions.execute(function (
|
|
145
|
-
var tr =
|
|
167
|
+
api.core.actions.execute(function (_ref6) {
|
|
168
|
+
var tr = _ref6.tr;
|
|
146
169
|
tr.setSelection(_state.TextSelection.create(view.state.selection.$from.doc, newPos));
|
|
147
170
|
return tr;
|
|
148
171
|
});
|
|
@@ -156,8 +179,8 @@ var handleQuickInsert = function handleQuickInsert(_ref4) {
|
|
|
156
179
|
// otherwise need to force the selection to be at the start of the node, because
|
|
157
180
|
// prosemirror is keeping it as NodeSelection for nested nodes. Do this to keep it
|
|
158
181
|
// consistent NodeSelection for root level nodes.
|
|
159
|
-
api.core.actions.execute(function (
|
|
160
|
-
var tr =
|
|
182
|
+
api.core.actions.execute(function (_ref7) {
|
|
183
|
+
var tr = _ref7.tr;
|
|
161
184
|
(0, _editorCommands.createNewLine)(view.state.selection.from)({
|
|
162
185
|
tr: tr
|
|
163
186
|
});
|
|
@@ -169,8 +192,8 @@ var handleQuickInsert = function handleQuickInsert(_ref4) {
|
|
|
169
192
|
if (currentSelection instanceof _cellSelection.CellSelection) {
|
|
170
193
|
// find the last inline position in the selection
|
|
171
194
|
var lastInlinePosition = _state.TextSelection.near(view.state.selection.$to, -1);
|
|
172
|
-
lastInlinePosition && api.core.actions.execute(function (
|
|
173
|
-
var tr =
|
|
195
|
+
lastInlinePosition && api.core.actions.execute(function (_ref8) {
|
|
196
|
+
var tr = _ref8.tr;
|
|
174
197
|
if (!(lastInlinePosition instanceof _state.TextSelection)) {
|
|
175
198
|
// this will create a new line after the node
|
|
176
199
|
(0, _editorCommands.createNewLine)(lastInlinePosition.from)({
|
|
@@ -19,7 +19,6 @@ var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
|
19
19
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
20
20
|
var _selection = require("@atlaskit/editor-common/selection");
|
|
21
21
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
22
|
-
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
23
22
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
24
23
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
25
24
|
var _consts = require("@atlaskit/editor-shared-styles/consts");
|
|
@@ -435,16 +434,19 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref3) {
|
|
|
435
434
|
_useState10 = (0, _slicedToArray2.default)(_useState1, 2),
|
|
436
435
|
isFocused = _useState10[0],
|
|
437
436
|
setIsFocused = _useState10[1];
|
|
438
|
-
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['featureFlags'], function (states) {
|
|
439
|
-
var _states$featureFlagsS;
|
|
437
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['featureFlags', 'selection', 'blockControls', 'interaction'], function (states) {
|
|
438
|
+
var _states$featureFlagsS, _states$selectionStat, _states$blockControls, _states$interactionSt;
|
|
440
439
|
return {
|
|
441
|
-
macroInteractionUpdates: (_states$featureFlagsS = states.featureFlagsState) === null || _states$featureFlagsS === void 0 ? void 0 : _states$featureFlagsS.macroInteractionUpdates
|
|
440
|
+
macroInteractionUpdates: (_states$featureFlagsS = states.featureFlagsState) === null || _states$featureFlagsS === void 0 ? void 0 : _states$featureFlagsS.macroInteractionUpdates,
|
|
441
|
+
selection: (_states$selectionStat = states.selectionState) === null || _states$selectionStat === void 0 ? void 0 : _states$selectionStat.selection,
|
|
442
|
+
isShiftDown: (_states$blockControls = states.blockControlsState) === null || _states$blockControls === void 0 ? void 0 : _states$blockControls.isShiftDown,
|
|
443
|
+
interactionState: (_states$interactionSt = states.interactionState) === null || _states$interactionSt === void 0 ? void 0 : _states$interactionSt.interactionState
|
|
442
444
|
};
|
|
443
445
|
}),
|
|
444
|
-
macroInteractionUpdates = _useSharedPluginState.macroInteractionUpdates
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
446
|
+
macroInteractionUpdates = _useSharedPluginState.macroInteractionUpdates,
|
|
447
|
+
selection = _useSharedPluginState.selection,
|
|
448
|
+
isShiftDown = _useSharedPluginState.isShiftDown,
|
|
449
|
+
interactionState = _useSharedPluginState.interactionState;
|
|
448
450
|
var start = getPos();
|
|
449
451
|
var isLayoutColumn = nodeType === 'layoutColumn';
|
|
450
452
|
var isMultiSelect = (0, _experiments.editorExperiment)('platform_editor_element_drag_and_drop_multiselect', true);
|
|
@@ -1122,6 +1124,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref3) {
|
|
|
1122
1124
|
onDrop: handleOnDrop,
|
|
1123
1125
|
disabled: dragHandleDisabled,
|
|
1124
1126
|
"data-editor-block-ctrl-drag-handle": true,
|
|
1127
|
+
"data-blocks-drag-handle": (0, _expValEquals.expValEquals)('confluence_remix_icon_right_side', 'isEnabled', true) || undefined,
|
|
1125
1128
|
"data-testid": "block-ctrl-drag-handle",
|
|
1126
1129
|
"aria-label": dragHandleAriaLabel,
|
|
1127
1130
|
onBlur: (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true) ? function () {
|
|
@@ -1208,8 +1211,15 @@ var DragHandleWithVisibility = exports.DragHandleWithVisibility = function DragH
|
|
|
1208
1211
|
handleOptions = _ref10.handleOptions,
|
|
1209
1212
|
isTopLevelNode = _ref10.isTopLevelNode,
|
|
1210
1213
|
anchorRectCache = _ref10.anchorRectCache;
|
|
1214
|
+
var rightSideControlsEnabled = (0, _hooks.useSharedPluginStateWithSelector)(api, ['blockControls'], function (states) {
|
|
1215
|
+
var _states$blockControls2, _states$blockControls3;
|
|
1216
|
+
return {
|
|
1217
|
+
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
|
|
1218
|
+
};
|
|
1219
|
+
}).rightSideControlsEnabled;
|
|
1211
1220
|
return (0, _react2.jsx)(_visibilityContainer.VisibilityContainer, {
|
|
1212
|
-
api: api
|
|
1221
|
+
api: api,
|
|
1222
|
+
controlSide: rightSideControlsEnabled ? 'left' : undefined
|
|
1213
1223
|
}, (0, _react2.jsx)(DragHandle, {
|
|
1214
1224
|
view: view,
|
|
1215
1225
|
api: api,
|
|
@@ -7,9 +7,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.GlobalStylesWrapper = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _react = require("@emotion/react");
|
|
10
|
+
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
10
11
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
11
12
|
var _toolbarFlagCheck = require("@atlaskit/editor-common/toolbar-flag-check");
|
|
12
|
-
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
13
13
|
var _whitespace = require("@atlaskit/editor-common/whitespace");
|
|
14
14
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
15
15
|
var _constants = require("@atlaskit/theme/constants");
|
|
@@ -301,7 +301,7 @@ var quickInsertStyles = function quickInsertStyles() {
|
|
|
301
301
|
maxWidth: '240px',
|
|
302
302
|
backgroundColor: "var(--ds-background-neutral-bold, #292A2E)",
|
|
303
303
|
color: "var(--ds-text-inverse, #FFFFFF)",
|
|
304
|
-
font: "var(--ds-font-body-
|
|
304
|
+
font: "var(--ds-font-body-small, normal 400 12px/16px \"Atlassian Sans\", ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, \"Helvetica Neue\", sans-serif)",
|
|
305
305
|
insetBlockStart: "var(--ds-space-0, 0px)",
|
|
306
306
|
insetInlineStart: "var(--ds-space-0, 0px)",
|
|
307
307
|
overflowWrap: 'break-word',
|
|
@@ -459,9 +459,14 @@ var dragAnchorStyles = (0, _react.css)({
|
|
|
459
459
|
});
|
|
460
460
|
var GlobalStylesWrapper = exports.GlobalStylesWrapper = function GlobalStylesWrapper(_ref) {
|
|
461
461
|
var api = _ref.api;
|
|
462
|
-
var
|
|
463
|
-
|
|
464
|
-
|
|
462
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['blockControls'], function (states) {
|
|
463
|
+
var _states$blockControls;
|
|
464
|
+
return {
|
|
465
|
+
isDragging: (_states$blockControls = states.blockControlsState) === null || _states$blockControls === void 0 ? void 0 : _states$blockControls.isDragging
|
|
466
|
+
};
|
|
467
|
+
}),
|
|
468
|
+
isDraggingFromState = _useSharedPluginState.isDragging;
|
|
469
|
+
var isDragging = (0, _expValEquals.expValEquals)('platform_editor_block_controls_perf_optimization', 'isEnabled', true) ? isDraggingFromState : false;
|
|
465
470
|
var shouldRenderAnchors = (0, _styles.isCSSAnchorSupported)() && (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true);
|
|
466
471
|
var toolbarFlagsEnabled = (0, _toolbarFlagCheck.areToolbarFlagsEnabled)(Boolean(api === null || api === void 0 ? void 0 : api.toolbar));
|
|
467
472
|
return (0, _react.jsx)(_react.Global, {
|
|
@@ -11,10 +11,10 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
11
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
12
12
|
var _react2 = require("@emotion/react");
|
|
13
13
|
var _bindEventListener = require("bind-event-listener");
|
|
14
|
+
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
14
15
|
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
15
16
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
16
17
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
17
|
-
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
18
18
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
19
19
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
20
20
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
@@ -160,7 +160,13 @@ var TypeAheadControl = exports.TypeAheadControl = function TypeAheadControl(_ref
|
|
|
160
160
|
rootAnchorName = _ref.rootAnchorName,
|
|
161
161
|
rootNodeType = _ref.rootNodeType,
|
|
162
162
|
anchorRectCache = _ref.anchorRectCache;
|
|
163
|
-
var
|
|
163
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['featureFlags'], function (states) {
|
|
164
|
+
var _states$featureFlagsS;
|
|
165
|
+
return {
|
|
166
|
+
macroInteractionUpdates: (_states$featureFlagsS = states.featureFlagsState) === null || _states$featureFlagsS === void 0 ? void 0 : _states$featureFlagsS.macroInteractionUpdates
|
|
167
|
+
};
|
|
168
|
+
}),
|
|
169
|
+
macroInteractionUpdates = _useSharedPluginState.macroInteractionUpdates;
|
|
164
170
|
var _useState = (0, _react.useState)({
|
|
165
171
|
display: 'none'
|
|
166
172
|
}),
|
|
@@ -364,8 +370,15 @@ var QuickInsertWithVisibility = exports.QuickInsertWithVisibility = function Qui
|
|
|
364
370
|
rootAnchorName = _ref5.rootAnchorName,
|
|
365
371
|
rootNodeType = _ref5.rootNodeType,
|
|
366
372
|
anchorRectCache = _ref5.anchorRectCache;
|
|
373
|
+
var rightSideControlsEnabled = (0, _hooks.useSharedPluginStateWithSelector)(api, ['blockControls'], function (states) {
|
|
374
|
+
var _states$blockControls, _states$blockControls2;
|
|
375
|
+
return {
|
|
376
|
+
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
|
|
377
|
+
};
|
|
378
|
+
}).rightSideControlsEnabled;
|
|
367
379
|
return (0, _react2.jsx)(_visibilityContainer.VisibilityContainer, {
|
|
368
|
-
api: api
|
|
380
|
+
api: api,
|
|
381
|
+
controlSide: rightSideControlsEnabled ? 'left' : undefined
|
|
369
382
|
}, (0, _react2.jsx)(TypeAheadControl, {
|
|
370
383
|
view: view,
|
|
371
384
|
api: api,
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports.VisibilityContainer = void 0;
|
|
9
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
8
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _react =
|
|
11
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
12
|
var _react2 = require("@emotion/react");
|
|
11
|
-
var
|
|
13
|
+
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
12
14
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
13
15
|
var _primitives = require("@atlaskit/primitives");
|
|
16
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
14
17
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
18
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
15
19
|
/**
|
|
16
20
|
* @jsxRuntime classic
|
|
17
21
|
* @jsx jsx
|
|
@@ -21,6 +25,7 @@ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
|
21
25
|
|
|
22
26
|
// eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
|
|
23
27
|
|
|
28
|
+
var RIGHT_CONTROL_HIDE_DELAY_MS = 150;
|
|
24
29
|
var baseStyles = (0, _primitives.xcss)({
|
|
25
30
|
transition: 'opacity 0.1s ease-in-out, visibility 0.1s ease-in-out'
|
|
26
31
|
});
|
|
@@ -48,14 +53,70 @@ var hiddenStylesCSS = (0, _react2.css)({
|
|
|
48
53
|
});
|
|
49
54
|
var VisibilityContainer = exports.VisibilityContainer = function VisibilityContainer(_ref) {
|
|
50
55
|
var api = _ref.api,
|
|
51
|
-
children = _ref.children
|
|
52
|
-
|
|
53
|
-
var
|
|
54
|
-
|
|
56
|
+
children = _ref.children,
|
|
57
|
+
controlSide = _ref.controlSide;
|
|
58
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['typeAhead', 'blockControls', 'editorViewMode', 'userIntent'], function (states) {
|
|
59
|
+
var _states$typeAheadStat, _states$blockControls, _states$blockControls2, _states$blockControls3, _states$editorViewMod, _states$userIntentSta, _states$blockControls4;
|
|
60
|
+
return {
|
|
61
|
+
isTypeAheadOpen: (_states$typeAheadStat = states.typeAheadState) === null || _states$typeAheadStat === void 0 ? void 0 : _states$typeAheadStat.isOpen,
|
|
62
|
+
isEditing: (_states$blockControls = states.blockControlsState) === null || _states$blockControls === void 0 ? void 0 : _states$blockControls.isEditing,
|
|
63
|
+
isMouseOut: (_states$blockControls2 = states.blockControlsState) === null || _states$blockControls2 === void 0 ? void 0 : _states$blockControls2.isMouseOut,
|
|
64
|
+
hoverSide: (_states$blockControls3 = states.blockControlsState) === null || _states$blockControls3 === void 0 ? void 0 : _states$blockControls3.hoverSide,
|
|
65
|
+
editorViewMode: (_states$editorViewMod = states.editorViewModeState) === null || _states$editorViewMod === void 0 ? void 0 : _states$editorViewMod.mode,
|
|
66
|
+
userIntent: (_states$userIntentSta = states.userIntentState) === null || _states$userIntentSta === void 0 ? void 0 : _states$userIntentSta.currentUserIntent,
|
|
67
|
+
rightSideControlsEnabled: (_states$blockControls4 = states.blockControlsState) === null || _states$blockControls4 === void 0 ? void 0 : _states$blockControls4.rightSideControlsEnabled
|
|
68
|
+
};
|
|
69
|
+
}),
|
|
70
|
+
isTypeAheadOpen = _useSharedPluginState.isTypeAheadOpen,
|
|
71
|
+
isEditing = _useSharedPluginState.isEditing,
|
|
72
|
+
isMouseOut = _useSharedPluginState.isMouseOut,
|
|
73
|
+
hoverSide = _useSharedPluginState.hoverSide,
|
|
74
|
+
editorViewMode = _useSharedPluginState.editorViewMode,
|
|
75
|
+
userIntent = _useSharedPluginState.userIntent,
|
|
76
|
+
rightSideControlsEnabled = _useSharedPluginState.rightSideControlsEnabled;
|
|
77
|
+
var isViewMode = editorViewMode === 'view';
|
|
78
|
+
var shouldRestrictBySide = rightSideControlsEnabled && (0, _expValEquals.expValEquals)('confluence_remix_icon_right_side', 'isEnabled', true) && controlSide !== undefined && !isViewMode;
|
|
79
|
+
// Only restrict by side when hoverSide is known (after mousemove). When undefined, show both
|
|
80
|
+
// controls so drag handle is visible on load and for keyboard-only users.
|
|
81
|
+
var sideHidden = shouldRestrictBySide && hoverSide !== undefined ? hoverSide !== controlSide : false;
|
|
82
|
+
// In view mode with right-side controls, we delay hiding on isMouseOut (see below) so the right-edge
|
|
83
|
+
// button stays visible when the user moves from the block toward the button (e.g. in edit/live
|
|
84
|
+
// pages), avoiding flicker as the mouse crosses boundaries.
|
|
85
|
+
var hideOnMouseOut = isMouseOut;
|
|
86
|
+
var shouldHideImmediate = isTypeAheadOpen || isEditing || hideOnMouseOut || userIntent === 'aiStreaming' || sideHidden;
|
|
55
87
|
|
|
56
|
-
//
|
|
57
|
-
|
|
58
|
-
var
|
|
88
|
+
// Delay hiding the right control in view mode to reduce flickering when moving from block
|
|
89
|
+
// toward the right-edge button (avoids rapid show/hide as mouse crosses boundaries).
|
|
90
|
+
var isRightControlViewMode = isViewMode && rightSideControlsEnabled && (0, _expValEquals.expValEquals)('confluence_remix_icon_right_side', 'isEnabled', true) && controlSide === 'right';
|
|
91
|
+
// When in right-control view mode, we delay hiding so start visible; useEffect will update after delay
|
|
92
|
+
var _useState = (0, _react.useState)(false),
|
|
93
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
94
|
+
delayedShouldHide = _useState2[0],
|
|
95
|
+
setDelayedShouldHide = _useState2[1];
|
|
96
|
+
var hideTimeoutRef = (0, _react.useRef)(null);
|
|
97
|
+
(0, _react.useEffect)(function () {
|
|
98
|
+
if (!isRightControlViewMode) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (!shouldHideImmediate) {
|
|
102
|
+
if (hideTimeoutRef.current) {
|
|
103
|
+
clearTimeout(hideTimeoutRef.current);
|
|
104
|
+
hideTimeoutRef.current = null;
|
|
105
|
+
}
|
|
106
|
+
setDelayedShouldHide(false);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
hideTimeoutRef.current = setTimeout(function () {
|
|
110
|
+
hideTimeoutRef.current = null;
|
|
111
|
+
setDelayedShouldHide(true);
|
|
112
|
+
}, RIGHT_CONTROL_HIDE_DELAY_MS);
|
|
113
|
+
return function () {
|
|
114
|
+
if (hideTimeoutRef.current) {
|
|
115
|
+
clearTimeout(hideTimeoutRef.current);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
}, [shouldHideImmediate, isRightControlViewMode]);
|
|
119
|
+
var shouldHide = isRightControlViewMode ? delayedShouldHide : shouldHideImmediate;
|
|
59
120
|
if ((0, _experiments.editorExperiment)('platform_editor_preview_panel_responsiveness', true, {
|
|
60
121
|
exposure: true
|
|
61
122
|
})) {
|