@atlaskit/editor-plugin-synced-block 25.0.5 → 25.0.7
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
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-synced-block
|
|
2
2
|
|
|
3
|
+
## 25.0.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`3268110f0c1c7`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3268110f0c1c7) -
|
|
8
|
+
Measure the synced locations dropdown once per opening so it can flip above the toolbar, behind
|
|
9
|
+
platform_editor_blocks_patch_12.
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 25.0.6
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
3
18
|
## 25.0.5
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -63,6 +63,8 @@ var logoTileStyles = null;
|
|
|
63
63
|
// Jira rows aligned with the tiled Confluence rows.
|
|
64
64
|
var issueTypeAvatarStyles = null;
|
|
65
65
|
var SYNCED_LOCATIONS_DROPDOWN_TEST_ID = 'synced-block-synced-locations-dropdown';
|
|
66
|
+
// Match the existing vertical gap in editor-common's DropList.
|
|
67
|
+
var SYNCED_LOCATIONS_DROPDOWN_VERTICAL_GAP = 8;
|
|
66
68
|
var styles = {
|
|
67
69
|
title: "_1reo15vq _18m915vq _syazazsu _1bto1l2s _o5721q9c",
|
|
68
70
|
note: "_syaz1rpy _o5721q9c",
|
|
@@ -461,25 +463,26 @@ var toSyncedLocations = function toSyncedLocations(references, intl) {
|
|
|
461
463
|
references: processReferenceData(references, intl)
|
|
462
464
|
};
|
|
463
465
|
};
|
|
464
|
-
var
|
|
465
|
-
var
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
466
|
+
var MeasuredDropdownContent = function MeasuredDropdownContent(_ref6) {
|
|
467
|
+
var children = _ref6.children,
|
|
468
|
+
onHeightChange = _ref6.onHeightChange;
|
|
469
|
+
var contentRef = (0, _react.useRef)(null);
|
|
470
|
+
var measured = (0, _react.useRef)(false);
|
|
471
|
+
(0, _react.useLayoutEffect)(function () {
|
|
472
|
+
var _contentRef$current;
|
|
473
|
+
// This wrapper is rendered directly inside the DropList menu.
|
|
474
|
+
var menu = (_contentRef$current = contentRef.current) === null || _contentRef$current === void 0 ? void 0 : _contentRef$current.parentElement;
|
|
475
|
+
if (menu && !measured.current) {
|
|
476
|
+
measured.current = true;
|
|
477
|
+
// Include the DropList padding and its existing gap from the toolbar.
|
|
478
|
+
onHeightChange(menu.getBoundingClientRect().height + SYNCED_LOCATIONS_DROPDOWN_VERTICAL_GAP);
|
|
479
|
+
}
|
|
480
|
+
}, [onHeightChange]);
|
|
481
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
482
|
+
ref: contentRef
|
|
483
|
+
}, children);
|
|
481
484
|
};
|
|
482
|
-
var
|
|
485
|
+
var SyncedLocationDropdown = exports.SyncedLocationDropdown = function SyncedLocationDropdown(_ref7) {
|
|
483
486
|
var syncBlockStore = _ref7.syncBlockStore,
|
|
484
487
|
resourceId = _ref7.resourceId,
|
|
485
488
|
intl = _ref7.intl,
|
|
@@ -492,6 +495,10 @@ var EditorPositionedSyncedLocationDropdown = function EditorPositionedSyncedLoca
|
|
|
492
495
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
493
496
|
isOpen = _useState2[0],
|
|
494
497
|
setIsOpen = _useState2[1];
|
|
498
|
+
var _useState3 = (0, _react.useState)(),
|
|
499
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
500
|
+
fitHeight = _useState4[0],
|
|
501
|
+
setFitHeight = _useState4[1];
|
|
495
502
|
var content = isOpen ? /*#__PURE__*/React.createElement(DropdownContent, {
|
|
496
503
|
syncBlockStore: syncBlockStore,
|
|
497
504
|
resourceId: resourceId,
|
|
@@ -501,11 +508,13 @@ var EditorPositionedSyncedLocationDropdown = function EditorPositionedSyncedLoca
|
|
|
501
508
|
api: api
|
|
502
509
|
}) : null;
|
|
503
510
|
var toggleOpen = (0, _react.useCallback)(function () {
|
|
511
|
+
setFitHeight(undefined);
|
|
504
512
|
setIsOpen(function (currentIsOpen) {
|
|
505
513
|
return !currentIsOpen;
|
|
506
514
|
});
|
|
507
515
|
}, []);
|
|
508
516
|
var closeDropdown = (0, _react.useCallback)(function () {
|
|
517
|
+
setFitHeight(undefined);
|
|
509
518
|
setIsOpen(false);
|
|
510
519
|
}, []);
|
|
511
520
|
var setDisableParentScroll = floatingToolbarRenderContext === null || floatingToolbarRenderContext === void 0 ? void 0 : floatingToolbarRenderContext.setDisableParentScroll;
|
|
@@ -536,6 +545,7 @@ var EditorPositionedSyncedLocationDropdown = function EditorPositionedSyncedLoca
|
|
|
536
545
|
return /*#__PURE__*/React.createElement(_DropdownContainer.DropdownContainer, {
|
|
537
546
|
testId: SYNCED_LOCATIONS_DROPDOWN_TEST_ID,
|
|
538
547
|
isOpen: isOpen,
|
|
548
|
+
fitHeight: fitHeight,
|
|
539
549
|
trigger: trigger,
|
|
540
550
|
handleClickOutside: closeDropdown,
|
|
541
551
|
handleEscapeKeydown: closeDropdown,
|
|
@@ -547,7 +557,9 @@ var EditorPositionedSyncedLocationDropdown = function EditorPositionedSyncedLoca
|
|
|
547
557
|
arrowKeyNavigationProviderOptions: {
|
|
548
558
|
type: _types.ArrowKeyNavigationType.MENU
|
|
549
559
|
}
|
|
550
|
-
},
|
|
560
|
+
}, (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_blocks_patch_12') ? /*#__PURE__*/React.createElement(MeasuredDropdownContent, {
|
|
561
|
+
onHeightChange: setFitHeight
|
|
562
|
+
}, content) : content);
|
|
551
563
|
};
|
|
552
564
|
var SyncedLocationDropdownWithCount = exports.SyncedLocationDropdownWithCount = function SyncedLocationDropdownWithCount(_ref8) {
|
|
553
565
|
var syncBlockStore = _ref8.syncBlockStore,
|
|
@@ -558,10 +570,14 @@ var SyncedLocationDropdownWithCount = exports.SyncedLocationDropdownWithCount =
|
|
|
558
570
|
localId = _ref8.localId,
|
|
559
571
|
api = _ref8.api,
|
|
560
572
|
floatingToolbarRenderContext = _ref8.floatingToolbarRenderContext;
|
|
561
|
-
var
|
|
562
|
-
|
|
563
|
-
isOpen =
|
|
564
|
-
setIsOpen =
|
|
573
|
+
var _useState5 = (0, _react.useState)(false),
|
|
574
|
+
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
575
|
+
isOpen = _useState6[0],
|
|
576
|
+
setIsOpen = _useState6[1];
|
|
577
|
+
var _useState7 = (0, _react.useState)(),
|
|
578
|
+
_useState8 = (0, _slicedToArray2.default)(_useState7, 2),
|
|
579
|
+
fitHeight = _useState8[0],
|
|
580
|
+
setFitHeight = _useState8[1];
|
|
565
581
|
var _useReferenceData = useReferenceData({
|
|
566
582
|
intl: intl,
|
|
567
583
|
isSource: isSource,
|
|
@@ -595,11 +611,13 @@ var SyncedLocationDropdownWithCount = exports.SyncedLocationDropdownWithCount =
|
|
|
595
611
|
locations: locations
|
|
596
612
|
}) : null;
|
|
597
613
|
var toggleOpen = (0, _react.useCallback)(function () {
|
|
614
|
+
setFitHeight(undefined);
|
|
598
615
|
setIsOpen(function (currentIsOpen) {
|
|
599
616
|
return !currentIsOpen;
|
|
600
617
|
});
|
|
601
618
|
}, []);
|
|
602
619
|
var closeDropdown = (0, _react.useCallback)(function () {
|
|
620
|
+
setFitHeight(undefined);
|
|
603
621
|
setIsOpen(false);
|
|
604
622
|
}, []);
|
|
605
623
|
var setDisableParentScroll = floatingToolbarRenderContext === null || floatingToolbarRenderContext === void 0 ? void 0 : floatingToolbarRenderContext.setDisableParentScroll;
|
|
@@ -637,6 +655,7 @@ var SyncedLocationDropdownWithCount = exports.SyncedLocationDropdownWithCount =
|
|
|
637
655
|
alignX: "left",
|
|
638
656
|
testId: SYNCED_LOCATIONS_DROPDOWN_TEST_ID,
|
|
639
657
|
isOpen: isOpen,
|
|
658
|
+
fitHeight: fitHeight,
|
|
640
659
|
trigger: trigger,
|
|
641
660
|
handleClickOutside: closeDropdown,
|
|
642
661
|
handleEscapeKeydown: closeDropdown,
|
|
@@ -648,7 +667,9 @@ var SyncedLocationDropdownWithCount = exports.SyncedLocationDropdownWithCount =
|
|
|
648
667
|
arrowKeyNavigationProviderOptions: {
|
|
649
668
|
type: _types.ArrowKeyNavigationType.MENU
|
|
650
669
|
}
|
|
651
|
-
},
|
|
670
|
+
}, (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_blocks_patch_12') ? /*#__PURE__*/React.createElement(MeasuredDropdownContent, {
|
|
671
|
+
onHeightChange: setFitHeight
|
|
672
|
+
}, content) : content);
|
|
652
673
|
};
|
|
653
674
|
var DropdownContent = function DropdownContent(_ref1) {
|
|
654
675
|
var syncBlockStore = _ref1.syncBlockStore,
|
|
@@ -657,14 +678,16 @@ var DropdownContent = function DropdownContent(_ref1) {
|
|
|
657
678
|
isSource = _ref1.isSource,
|
|
658
679
|
localId = _ref1.localId,
|
|
659
680
|
api = _ref1.api;
|
|
660
|
-
var
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
681
|
+
var _useState9 = (0, _react.useState)(function () {
|
|
682
|
+
return (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_blocks_patch_12') ? 'loading' : 'none';
|
|
683
|
+
}),
|
|
684
|
+
_useState0 = (0, _slicedToArray2.default)(_useState9, 2),
|
|
685
|
+
fetchStatus = _useState0[0],
|
|
686
|
+
setFetchStatus = _useState0[1];
|
|
687
|
+
var _useState1 = (0, _react.useState)(EMPTY_LOCATIONS),
|
|
688
|
+
_useState10 = (0, _slicedToArray2.default)(_useState1, 2),
|
|
689
|
+
locations = _useState10[0],
|
|
690
|
+
setLocations = _useState10[1];
|
|
668
691
|
(0, _react.useEffect)(function () {
|
|
669
692
|
setFetchStatus('loading');
|
|
670
693
|
var getReferenceData = /*#__PURE__*/function () {
|
|
@@ -714,23 +737,23 @@ var useReferenceData = function useReferenceData(_ref11) {
|
|
|
714
737
|
isSource = _ref11.isSource,
|
|
715
738
|
localId = _ref11.localId;
|
|
716
739
|
// Refresh locations when the toolbar opens, rather than on every document edit.
|
|
717
|
-
var
|
|
718
|
-
|
|
719
|
-
docAtMount =
|
|
720
|
-
var
|
|
740
|
+
var _useState11 = (0, _react.useState)(doc),
|
|
741
|
+
_useState12 = (0, _slicedToArray2.default)(_useState11, 1),
|
|
742
|
+
docAtMount = _useState12[0];
|
|
743
|
+
var _useState13 = (0, _react.useState)(function () {
|
|
721
744
|
return isSource && syncBlockStore.sourceManager.isNewSourceBlock(resourceId);
|
|
722
745
|
}),
|
|
723
|
-
|
|
724
|
-
isNewSourceBlock =
|
|
725
|
-
var
|
|
746
|
+
_useState14 = (0, _slicedToArray2.default)(_useState13, 1),
|
|
747
|
+
isNewSourceBlock = _useState14[0];
|
|
748
|
+
var _useState15 = (0, _react.useState)(function () {
|
|
726
749
|
return {
|
|
727
750
|
fetchStatus: isNewSourceBlock ? 'success' : 'loading',
|
|
728
751
|
locations: EMPTY_LOCATIONS
|
|
729
752
|
};
|
|
730
753
|
}),
|
|
731
|
-
|
|
732
|
-
state =
|
|
733
|
-
setState =
|
|
754
|
+
_useState16 = (0, _slicedToArray2.default)(_useState15, 2),
|
|
755
|
+
state = _useState16[0],
|
|
756
|
+
setState = _useState16[1];
|
|
734
757
|
(0, _react.useEffect)(function () {
|
|
735
758
|
var isCurrentRequest = true;
|
|
736
759
|
setState({
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import "./SyncedLocationDropdown.compiled.css";
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { ax, ix } from "@compiled/react/runtime";
|
|
5
|
-
import { Fragment, useCallback, useEffect, useMemo, useState } from 'react';
|
|
5
|
+
import { Fragment, useCallback, useEffect, useMemo, useState, useLayoutEffect, useRef } from 'react';
|
|
6
6
|
import { cx } from '@compiled/react';
|
|
7
7
|
import DropdownItem from '@atlaskit/dropdown-menu/dropdown-menu-item';
|
|
8
8
|
import DropdownItemGroup from '@atlaskit/dropdown-menu/dropdown-menu-item-group';
|
|
@@ -46,6 +46,8 @@ const logoTileStyles = null;
|
|
|
46
46
|
// Jira rows aligned with the tiled Confluence rows.
|
|
47
47
|
const issueTypeAvatarStyles = null;
|
|
48
48
|
const SYNCED_LOCATIONS_DROPDOWN_TEST_ID = 'synced-block-synced-locations-dropdown';
|
|
49
|
+
// Match the existing vertical gap in editor-common's DropList.
|
|
50
|
+
const SYNCED_LOCATIONS_DROPDOWN_VERTICAL_GAP = 8;
|
|
49
51
|
const styles = {
|
|
50
52
|
title: "_1reo15vq _18m915vq _syazazsu _1bto1l2s _o5721q9c",
|
|
51
53
|
note: "_syaz1rpy _o5721q9c",
|
|
@@ -425,26 +427,27 @@ const toSyncedLocations = (references, intl) => isFieldAwareLocationList(referen
|
|
|
425
427
|
kind: 'control',
|
|
426
428
|
references: processReferenceData(references, intl)
|
|
427
429
|
};
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
intl,
|
|
432
|
-
isSource,
|
|
433
|
-
localId,
|
|
434
|
-
api,
|
|
435
|
-
floatingToolbarRenderContext
|
|
430
|
+
const MeasuredDropdownContent = ({
|
|
431
|
+
children,
|
|
432
|
+
onHeightChange
|
|
436
433
|
}) => {
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
434
|
+
const contentRef = useRef(null);
|
|
435
|
+
const measured = useRef(false);
|
|
436
|
+
useLayoutEffect(() => {
|
|
437
|
+
var _contentRef$current;
|
|
438
|
+
// This wrapper is rendered directly inside the DropList menu.
|
|
439
|
+
const menu = (_contentRef$current = contentRef.current) === null || _contentRef$current === void 0 ? void 0 : _contentRef$current.parentElement;
|
|
440
|
+
if (menu && !measured.current) {
|
|
441
|
+
measured.current = true;
|
|
442
|
+
// Include the DropList padding and its existing gap from the toolbar.
|
|
443
|
+
onHeightChange(menu.getBoundingClientRect().height + SYNCED_LOCATIONS_DROPDOWN_VERTICAL_GAP);
|
|
444
|
+
}
|
|
445
|
+
}, [onHeightChange]);
|
|
446
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
447
|
+
ref: contentRef
|
|
448
|
+
}, children);
|
|
446
449
|
};
|
|
447
|
-
const
|
|
450
|
+
export const SyncedLocationDropdown = ({
|
|
448
451
|
syncBlockStore,
|
|
449
452
|
resourceId,
|
|
450
453
|
intl,
|
|
@@ -455,6 +458,7 @@ const EditorPositionedSyncedLocationDropdown = ({
|
|
|
455
458
|
}) => {
|
|
456
459
|
const triggerTitle = intl.formatMessage(messages.syncedLocationDropdownTitle);
|
|
457
460
|
const [isOpen, setIsOpen] = useState(false);
|
|
461
|
+
const [fitHeight, setFitHeight] = useState();
|
|
458
462
|
const content = isOpen ? /*#__PURE__*/React.createElement(DropdownContent, {
|
|
459
463
|
syncBlockStore: syncBlockStore,
|
|
460
464
|
resourceId: resourceId,
|
|
@@ -464,9 +468,11 @@ const EditorPositionedSyncedLocationDropdown = ({
|
|
|
464
468
|
api: api
|
|
465
469
|
}) : null;
|
|
466
470
|
const toggleOpen = useCallback(() => {
|
|
471
|
+
setFitHeight(undefined);
|
|
467
472
|
setIsOpen(currentIsOpen => !currentIsOpen);
|
|
468
473
|
}, []);
|
|
469
474
|
const closeDropdown = useCallback(() => {
|
|
475
|
+
setFitHeight(undefined);
|
|
470
476
|
setIsOpen(false);
|
|
471
477
|
}, []);
|
|
472
478
|
const setDisableParentScroll = floatingToolbarRenderContext === null || floatingToolbarRenderContext === void 0 ? void 0 : floatingToolbarRenderContext.setDisableParentScroll;
|
|
@@ -495,6 +501,7 @@ const EditorPositionedSyncedLocationDropdown = ({
|
|
|
495
501
|
return /*#__PURE__*/React.createElement(DropdownContainer, {
|
|
496
502
|
testId: SYNCED_LOCATIONS_DROPDOWN_TEST_ID,
|
|
497
503
|
isOpen: isOpen,
|
|
504
|
+
fitHeight: fitHeight,
|
|
498
505
|
trigger: trigger,
|
|
499
506
|
handleClickOutside: closeDropdown,
|
|
500
507
|
handleEscapeKeydown: closeDropdown,
|
|
@@ -506,7 +513,9 @@ const EditorPositionedSyncedLocationDropdown = ({
|
|
|
506
513
|
arrowKeyNavigationProviderOptions: {
|
|
507
514
|
type: ArrowKeyNavigationType.MENU
|
|
508
515
|
}
|
|
509
|
-
},
|
|
516
|
+
}, isExperimentEnabled('platform_editor_blocks_patch_12') ? /*#__PURE__*/React.createElement(MeasuredDropdownContent, {
|
|
517
|
+
onHeightChange: setFitHeight
|
|
518
|
+
}, content) : content);
|
|
510
519
|
};
|
|
511
520
|
export const SyncedLocationDropdownWithCount = ({
|
|
512
521
|
syncBlockStore,
|
|
@@ -519,6 +528,7 @@ export const SyncedLocationDropdownWithCount = ({
|
|
|
519
528
|
floatingToolbarRenderContext
|
|
520
529
|
}) => {
|
|
521
530
|
const [isOpen, setIsOpen] = useState(false);
|
|
531
|
+
const [fitHeight, setFitHeight] = useState();
|
|
522
532
|
const {
|
|
523
533
|
fetchStatus,
|
|
524
534
|
locations
|
|
@@ -551,9 +561,11 @@ export const SyncedLocationDropdownWithCount = ({
|
|
|
551
561
|
locations: locations
|
|
552
562
|
}) : null;
|
|
553
563
|
const toggleOpen = useCallback(() => {
|
|
564
|
+
setFitHeight(undefined);
|
|
554
565
|
setIsOpen(currentIsOpen => !currentIsOpen);
|
|
555
566
|
}, []);
|
|
556
567
|
const closeDropdown = useCallback(() => {
|
|
568
|
+
setFitHeight(undefined);
|
|
557
569
|
setIsOpen(false);
|
|
558
570
|
}, []);
|
|
559
571
|
const setDisableParentScroll = floatingToolbarRenderContext === null || floatingToolbarRenderContext === void 0 ? void 0 : floatingToolbarRenderContext.setDisableParentScroll;
|
|
@@ -589,6 +601,7 @@ export const SyncedLocationDropdownWithCount = ({
|
|
|
589
601
|
alignX: "left",
|
|
590
602
|
testId: SYNCED_LOCATIONS_DROPDOWN_TEST_ID,
|
|
591
603
|
isOpen: isOpen,
|
|
604
|
+
fitHeight: fitHeight,
|
|
592
605
|
trigger: trigger,
|
|
593
606
|
handleClickOutside: closeDropdown,
|
|
594
607
|
handleEscapeKeydown: closeDropdown,
|
|
@@ -600,7 +613,9 @@ export const SyncedLocationDropdownWithCount = ({
|
|
|
600
613
|
arrowKeyNavigationProviderOptions: {
|
|
601
614
|
type: ArrowKeyNavigationType.MENU
|
|
602
615
|
}
|
|
603
|
-
},
|
|
616
|
+
}, isExperimentEnabled('platform_editor_blocks_patch_12') ? /*#__PURE__*/React.createElement(MeasuredDropdownContent, {
|
|
617
|
+
onHeightChange: setFitHeight
|
|
618
|
+
}, content) : content);
|
|
604
619
|
};
|
|
605
620
|
const DropdownContent = ({
|
|
606
621
|
syncBlockStore,
|
|
@@ -610,7 +625,7 @@ const DropdownContent = ({
|
|
|
610
625
|
localId,
|
|
611
626
|
api
|
|
612
627
|
}) => {
|
|
613
|
-
const [fetchStatus, setFetchStatus] = useState('none');
|
|
628
|
+
const [fetchStatus, setFetchStatus] = useState(() => isExperimentEnabled('platform_editor_blocks_patch_12') ? 'loading' : 'none');
|
|
614
629
|
const [locations, setLocations] = useState(EMPTY_LOCATIONS);
|
|
615
630
|
useEffect(() => {
|
|
616
631
|
setFetchStatus('loading');
|
|
@@ -11,7 +11,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
11
11
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
12
12
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
13
13
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
14
|
-
import { Fragment, useCallback, useEffect, useMemo, useState } from 'react';
|
|
14
|
+
import { Fragment, useCallback, useEffect, useMemo, useState, useLayoutEffect, useRef } from 'react';
|
|
15
15
|
import { cx } from '@compiled/react';
|
|
16
16
|
import DropdownItem from '@atlaskit/dropdown-menu/dropdown-menu-item';
|
|
17
17
|
import DropdownItemGroup from '@atlaskit/dropdown-menu/dropdown-menu-item-group';
|
|
@@ -55,6 +55,8 @@ var logoTileStyles = null;
|
|
|
55
55
|
// Jira rows aligned with the tiled Confluence rows.
|
|
56
56
|
var issueTypeAvatarStyles = null;
|
|
57
57
|
var SYNCED_LOCATIONS_DROPDOWN_TEST_ID = 'synced-block-synced-locations-dropdown';
|
|
58
|
+
// Match the existing vertical gap in editor-common's DropList.
|
|
59
|
+
var SYNCED_LOCATIONS_DROPDOWN_VERTICAL_GAP = 8;
|
|
58
60
|
var styles = {
|
|
59
61
|
title: "_1reo15vq _18m915vq _syazazsu _1bto1l2s _o5721q9c",
|
|
60
62
|
note: "_syaz1rpy _o5721q9c",
|
|
@@ -453,25 +455,26 @@ var toSyncedLocations = function toSyncedLocations(references, intl) {
|
|
|
453
455
|
references: processReferenceData(references, intl)
|
|
454
456
|
};
|
|
455
457
|
};
|
|
456
|
-
|
|
457
|
-
var
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
458
|
+
var MeasuredDropdownContent = function MeasuredDropdownContent(_ref6) {
|
|
459
|
+
var children = _ref6.children,
|
|
460
|
+
onHeightChange = _ref6.onHeightChange;
|
|
461
|
+
var contentRef = useRef(null);
|
|
462
|
+
var measured = useRef(false);
|
|
463
|
+
useLayoutEffect(function () {
|
|
464
|
+
var _contentRef$current;
|
|
465
|
+
// This wrapper is rendered directly inside the DropList menu.
|
|
466
|
+
var menu = (_contentRef$current = contentRef.current) === null || _contentRef$current === void 0 ? void 0 : _contentRef$current.parentElement;
|
|
467
|
+
if (menu && !measured.current) {
|
|
468
|
+
measured.current = true;
|
|
469
|
+
// Include the DropList padding and its existing gap from the toolbar.
|
|
470
|
+
onHeightChange(menu.getBoundingClientRect().height + SYNCED_LOCATIONS_DROPDOWN_VERTICAL_GAP);
|
|
471
|
+
}
|
|
472
|
+
}, [onHeightChange]);
|
|
473
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
474
|
+
ref: contentRef
|
|
475
|
+
}, children);
|
|
473
476
|
};
|
|
474
|
-
var
|
|
477
|
+
export var SyncedLocationDropdown = function SyncedLocationDropdown(_ref7) {
|
|
475
478
|
var syncBlockStore = _ref7.syncBlockStore,
|
|
476
479
|
resourceId = _ref7.resourceId,
|
|
477
480
|
intl = _ref7.intl,
|
|
@@ -484,6 +487,10 @@ var EditorPositionedSyncedLocationDropdown = function EditorPositionedSyncedLoca
|
|
|
484
487
|
_useState2 = _slicedToArray(_useState, 2),
|
|
485
488
|
isOpen = _useState2[0],
|
|
486
489
|
setIsOpen = _useState2[1];
|
|
490
|
+
var _useState3 = useState(),
|
|
491
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
492
|
+
fitHeight = _useState4[0],
|
|
493
|
+
setFitHeight = _useState4[1];
|
|
487
494
|
var content = isOpen ? /*#__PURE__*/React.createElement(DropdownContent, {
|
|
488
495
|
syncBlockStore: syncBlockStore,
|
|
489
496
|
resourceId: resourceId,
|
|
@@ -493,11 +500,13 @@ var EditorPositionedSyncedLocationDropdown = function EditorPositionedSyncedLoca
|
|
|
493
500
|
api: api
|
|
494
501
|
}) : null;
|
|
495
502
|
var toggleOpen = useCallback(function () {
|
|
503
|
+
setFitHeight(undefined);
|
|
496
504
|
setIsOpen(function (currentIsOpen) {
|
|
497
505
|
return !currentIsOpen;
|
|
498
506
|
});
|
|
499
507
|
}, []);
|
|
500
508
|
var closeDropdown = useCallback(function () {
|
|
509
|
+
setFitHeight(undefined);
|
|
501
510
|
setIsOpen(false);
|
|
502
511
|
}, []);
|
|
503
512
|
var setDisableParentScroll = floatingToolbarRenderContext === null || floatingToolbarRenderContext === void 0 ? void 0 : floatingToolbarRenderContext.setDisableParentScroll;
|
|
@@ -528,6 +537,7 @@ var EditorPositionedSyncedLocationDropdown = function EditorPositionedSyncedLoca
|
|
|
528
537
|
return /*#__PURE__*/React.createElement(DropdownContainer, {
|
|
529
538
|
testId: SYNCED_LOCATIONS_DROPDOWN_TEST_ID,
|
|
530
539
|
isOpen: isOpen,
|
|
540
|
+
fitHeight: fitHeight,
|
|
531
541
|
trigger: trigger,
|
|
532
542
|
handleClickOutside: closeDropdown,
|
|
533
543
|
handleEscapeKeydown: closeDropdown,
|
|
@@ -539,7 +549,9 @@ var EditorPositionedSyncedLocationDropdown = function EditorPositionedSyncedLoca
|
|
|
539
549
|
arrowKeyNavigationProviderOptions: {
|
|
540
550
|
type: ArrowKeyNavigationType.MENU
|
|
541
551
|
}
|
|
542
|
-
},
|
|
552
|
+
}, isExperimentEnabled('platform_editor_blocks_patch_12') ? /*#__PURE__*/React.createElement(MeasuredDropdownContent, {
|
|
553
|
+
onHeightChange: setFitHeight
|
|
554
|
+
}, content) : content);
|
|
543
555
|
};
|
|
544
556
|
export var SyncedLocationDropdownWithCount = function SyncedLocationDropdownWithCount(_ref8) {
|
|
545
557
|
var syncBlockStore = _ref8.syncBlockStore,
|
|
@@ -550,10 +562,14 @@ export var SyncedLocationDropdownWithCount = function SyncedLocationDropdownWith
|
|
|
550
562
|
localId = _ref8.localId,
|
|
551
563
|
api = _ref8.api,
|
|
552
564
|
floatingToolbarRenderContext = _ref8.floatingToolbarRenderContext;
|
|
553
|
-
var
|
|
554
|
-
|
|
555
|
-
isOpen =
|
|
556
|
-
setIsOpen =
|
|
565
|
+
var _useState5 = useState(false),
|
|
566
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
567
|
+
isOpen = _useState6[0],
|
|
568
|
+
setIsOpen = _useState6[1];
|
|
569
|
+
var _useState7 = useState(),
|
|
570
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
571
|
+
fitHeight = _useState8[0],
|
|
572
|
+
setFitHeight = _useState8[1];
|
|
557
573
|
var _useReferenceData = useReferenceData({
|
|
558
574
|
intl: intl,
|
|
559
575
|
isSource: isSource,
|
|
@@ -587,11 +603,13 @@ export var SyncedLocationDropdownWithCount = function SyncedLocationDropdownWith
|
|
|
587
603
|
locations: locations
|
|
588
604
|
}) : null;
|
|
589
605
|
var toggleOpen = useCallback(function () {
|
|
606
|
+
setFitHeight(undefined);
|
|
590
607
|
setIsOpen(function (currentIsOpen) {
|
|
591
608
|
return !currentIsOpen;
|
|
592
609
|
});
|
|
593
610
|
}, []);
|
|
594
611
|
var closeDropdown = useCallback(function () {
|
|
612
|
+
setFitHeight(undefined);
|
|
595
613
|
setIsOpen(false);
|
|
596
614
|
}, []);
|
|
597
615
|
var setDisableParentScroll = floatingToolbarRenderContext === null || floatingToolbarRenderContext === void 0 ? void 0 : floatingToolbarRenderContext.setDisableParentScroll;
|
|
@@ -629,6 +647,7 @@ export var SyncedLocationDropdownWithCount = function SyncedLocationDropdownWith
|
|
|
629
647
|
alignX: "left",
|
|
630
648
|
testId: SYNCED_LOCATIONS_DROPDOWN_TEST_ID,
|
|
631
649
|
isOpen: isOpen,
|
|
650
|
+
fitHeight: fitHeight,
|
|
632
651
|
trigger: trigger,
|
|
633
652
|
handleClickOutside: closeDropdown,
|
|
634
653
|
handleEscapeKeydown: closeDropdown,
|
|
@@ -640,7 +659,9 @@ export var SyncedLocationDropdownWithCount = function SyncedLocationDropdownWith
|
|
|
640
659
|
arrowKeyNavigationProviderOptions: {
|
|
641
660
|
type: ArrowKeyNavigationType.MENU
|
|
642
661
|
}
|
|
643
|
-
},
|
|
662
|
+
}, isExperimentEnabled('platform_editor_blocks_patch_12') ? /*#__PURE__*/React.createElement(MeasuredDropdownContent, {
|
|
663
|
+
onHeightChange: setFitHeight
|
|
664
|
+
}, content) : content);
|
|
644
665
|
};
|
|
645
666
|
var DropdownContent = function DropdownContent(_ref1) {
|
|
646
667
|
var syncBlockStore = _ref1.syncBlockStore,
|
|
@@ -649,14 +670,16 @@ var DropdownContent = function DropdownContent(_ref1) {
|
|
|
649
670
|
isSource = _ref1.isSource,
|
|
650
671
|
localId = _ref1.localId,
|
|
651
672
|
api = _ref1.api;
|
|
652
|
-
var
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
673
|
+
var _useState9 = useState(function () {
|
|
674
|
+
return isExperimentEnabled('platform_editor_blocks_patch_12') ? 'loading' : 'none';
|
|
675
|
+
}),
|
|
676
|
+
_useState0 = _slicedToArray(_useState9, 2),
|
|
677
|
+
fetchStatus = _useState0[0],
|
|
678
|
+
setFetchStatus = _useState0[1];
|
|
679
|
+
var _useState1 = useState(EMPTY_LOCATIONS),
|
|
680
|
+
_useState10 = _slicedToArray(_useState1, 2),
|
|
681
|
+
locations = _useState10[0],
|
|
682
|
+
setLocations = _useState10[1];
|
|
660
683
|
useEffect(function () {
|
|
661
684
|
setFetchStatus('loading');
|
|
662
685
|
var getReferenceData = /*#__PURE__*/function () {
|
|
@@ -706,23 +729,23 @@ var useReferenceData = function useReferenceData(_ref11) {
|
|
|
706
729
|
isSource = _ref11.isSource,
|
|
707
730
|
localId = _ref11.localId;
|
|
708
731
|
// Refresh locations when the toolbar opens, rather than on every document edit.
|
|
709
|
-
var
|
|
710
|
-
|
|
711
|
-
docAtMount =
|
|
712
|
-
var
|
|
732
|
+
var _useState11 = useState(doc),
|
|
733
|
+
_useState12 = _slicedToArray(_useState11, 1),
|
|
734
|
+
docAtMount = _useState12[0];
|
|
735
|
+
var _useState13 = useState(function () {
|
|
713
736
|
return isSource && syncBlockStore.sourceManager.isNewSourceBlock(resourceId);
|
|
714
737
|
}),
|
|
715
|
-
|
|
716
|
-
isNewSourceBlock =
|
|
717
|
-
var
|
|
738
|
+
_useState14 = _slicedToArray(_useState13, 1),
|
|
739
|
+
isNewSourceBlock = _useState14[0];
|
|
740
|
+
var _useState15 = useState(function () {
|
|
718
741
|
return {
|
|
719
742
|
fetchStatus: isNewSourceBlock ? 'success' : 'loading',
|
|
720
743
|
locations: EMPTY_LOCATIONS
|
|
721
744
|
};
|
|
722
745
|
}),
|
|
723
|
-
|
|
724
|
-
state =
|
|
725
|
-
setState =
|
|
746
|
+
_useState16 = _slicedToArray(_useState15, 2),
|
|
747
|
+
state = _useState16[0],
|
|
748
|
+
setState = _useState16[1];
|
|
726
749
|
useEffect(function () {
|
|
727
750
|
var isCurrentRequest = true;
|
|
728
751
|
setState({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-synced-block",
|
|
3
|
-
"version": "25.0.
|
|
3
|
+
"version": "25.0.7",
|
|
4
4
|
"description": "SyncedBlock plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"atlaskit:src": "src/index.ts",
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@atlaskit/adf-schema": "^57.7.0",
|
|
24
|
-
"@atlaskit/button": "25.4.
|
|
24
|
+
"@atlaskit/button": "25.4.8",
|
|
25
25
|
"@atlaskit/dropdown-menu": "21.0.0",
|
|
26
26
|
"@atlaskit/editor-json-transformer": "^10.0.0",
|
|
27
27
|
"@atlaskit/editor-plugin-analytics": "^27.0.0",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@atlaskit/editor-plugin-user-intent": "^25.0.0",
|
|
42
42
|
"@atlaskit/editor-prosemirror": "^9.0.0",
|
|
43
43
|
"@atlaskit/editor-shared-styles": "^4.4.0",
|
|
44
|
-
"@atlaskit/editor-synced-block-provider": "^23.
|
|
44
|
+
"@atlaskit/editor-synced-block-provider": "^23.1.0",
|
|
45
45
|
"@atlaskit/editor-toolbar": "^2.8.0",
|
|
46
46
|
"@atlaskit/flag": "^19.0.0",
|
|
47
47
|
"@atlaskit/icon": "38.0.2",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"memoize-one": "^6.0.0"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
|
-
"@atlaskit/editor-common": "^131.
|
|
68
|
+
"@atlaskit/editor-common": "^131.3.0",
|
|
69
69
|
"react": "^18.2.0 || ^19.2.0",
|
|
70
70
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|
|
71
71
|
},
|