@atlaskit/editor-plugin-synced-block 10.4.1 → 10.4.3
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 +15 -0
- package/dist/cjs/ui/SyncedLocationDropdown.js +231 -31
- package/dist/cjs/ui/floating-toolbar.js +12 -0
- package/dist/es2019/ui/SyncedLocationDropdown.js +190 -21
- package/dist/es2019/ui/floating-toolbar.js +13 -1
- package/dist/esm/ui/SyncedLocationDropdown.js +230 -29
- package/dist/esm/ui/floating-toolbar.js +13 -1
- package/dist/types/ui/SyncedLocationDropdown.d.ts +1 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-synced-block
|
|
2
2
|
|
|
3
|
+
## 10.4.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`8b49fc1fd582e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/8b49fc1fd582e) -
|
|
8
|
+
Show the number of synced block references in the floating toolbar when the sync block activation
|
|
9
|
+
experiment is enabled.
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 10.4.2
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
3
18
|
## 10.4.1
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -6,7 +6,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", {
|
|
7
7
|
value: true
|
|
8
8
|
});
|
|
9
|
-
exports.processReferenceData = exports.SyncedLocationDropdown = void 0;
|
|
9
|
+
exports.processReferenceData = exports.SyncedLocationDropdownWithCount = exports.SyncedLocationDropdown = void 0;
|
|
10
10
|
require("./SyncedLocationDropdown.compiled.css");
|
|
11
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
12
12
|
var React = _react;
|
|
@@ -46,7 +46,7 @@ var _excluded = ["triggerRef"];
|
|
|
46
46
|
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); }
|
|
47
47
|
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; } } }; }
|
|
48
48
|
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; } }
|
|
49
|
-
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; }
|
|
49
|
+
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; } // eslint-disable-next-line import/order -- CI requires icon-lab imports before core icon imports.
|
|
50
50
|
var fadeIn = null;
|
|
51
51
|
var headingStyles = null;
|
|
52
52
|
var dropdownItemStyles = null;
|
|
@@ -311,24 +311,24 @@ var SyncedLocationDropdown = exports.SyncedLocationDropdown = function SyncedLoc
|
|
|
311
311
|
localId = _ref4.localId,
|
|
312
312
|
api = _ref4.api,
|
|
313
313
|
floatingToolbarRenderContext = _ref4.floatingToolbarRenderContext;
|
|
314
|
-
if ((0, _platformFeatureFlags.fg)('platform_synced_block_patch_13')) {
|
|
315
|
-
return /*#__PURE__*/React.createElement(
|
|
314
|
+
if (!(0, _platformFeatureFlags.fg)('platform_synced_block_patch_13')) {
|
|
315
|
+
return /*#__PURE__*/React.createElement(LegacySyncedLocationDropdown, {
|
|
316
316
|
syncBlockStore: syncBlockStore,
|
|
317
317
|
resourceId: resourceId,
|
|
318
318
|
intl: intl,
|
|
319
319
|
isSource: isSource,
|
|
320
320
|
localId: localId,
|
|
321
|
-
api: api
|
|
322
|
-
floatingToolbarRenderContext: floatingToolbarRenderContext
|
|
321
|
+
api: api
|
|
323
322
|
});
|
|
324
323
|
}
|
|
325
|
-
return /*#__PURE__*/React.createElement(
|
|
324
|
+
return /*#__PURE__*/React.createElement(EditorPositionedSyncedLocationDropdown, {
|
|
326
325
|
syncBlockStore: syncBlockStore,
|
|
327
326
|
resourceId: resourceId,
|
|
328
327
|
intl: intl,
|
|
329
328
|
isSource: isSource,
|
|
330
329
|
localId: localId,
|
|
331
|
-
api: api
|
|
330
|
+
api: api,
|
|
331
|
+
floatingToolbarRenderContext: floatingToolbarRenderContext
|
|
332
332
|
});
|
|
333
333
|
};
|
|
334
334
|
var EditorPositionedSyncedLocationDropdown = function EditorPositionedSyncedLocationDropdown(_ref5) {
|
|
@@ -339,8 +339,7 @@ var EditorPositionedSyncedLocationDropdown = function EditorPositionedSyncedLoca
|
|
|
339
339
|
localId = _ref5.localId,
|
|
340
340
|
api = _ref5.api,
|
|
341
341
|
floatingToolbarRenderContext = _ref5.floatingToolbarRenderContext;
|
|
342
|
-
var
|
|
343
|
-
var triggerTitle = formatMessage(_messages.syncBlockMessages.syncedLocationDropdownTitle);
|
|
342
|
+
var triggerTitle = intl.formatMessage(_messages.syncBlockMessages.syncedLocationDropdownTitle);
|
|
344
343
|
var _useState = (0, _react.useState)(false),
|
|
345
344
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
346
345
|
isOpen = _useState2[0],
|
|
@@ -409,8 +408,7 @@ var LegacySyncedLocationDropdown = function LegacySyncedLocationDropdown(_ref6)
|
|
|
409
408
|
isSource = _ref6.isSource,
|
|
410
409
|
localId = _ref6.localId,
|
|
411
410
|
api = _ref6.api;
|
|
412
|
-
var
|
|
413
|
-
var triggerTitle = formatMessage(_messages.syncBlockMessages.syncedLocationDropdownTitle);
|
|
411
|
+
var triggerTitle = intl.formatMessage(_messages.syncBlockMessages.syncedLocationDropdownTitle);
|
|
414
412
|
var _useState3 = (0, _react.useState)(false),
|
|
415
413
|
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
416
414
|
isOpen = _useState4[0],
|
|
@@ -452,26 +450,106 @@ var LegacySyncedLocationDropdown = function LegacySyncedLocationDropdown(_ref6)
|
|
|
452
450
|
}
|
|
453
451
|
}, content);
|
|
454
452
|
};
|
|
455
|
-
var
|
|
453
|
+
var SyncedLocationDropdownWithCount = exports.SyncedLocationDropdownWithCount = function SyncedLocationDropdownWithCount(_ref9) {
|
|
456
454
|
var syncBlockStore = _ref9.syncBlockStore,
|
|
457
455
|
resourceId = _ref9.resourceId,
|
|
458
456
|
intl = _ref9.intl,
|
|
459
457
|
isSource = _ref9.isSource,
|
|
460
458
|
localId = _ref9.localId,
|
|
461
|
-
api = _ref9.api
|
|
462
|
-
|
|
463
|
-
var _useState5 = (0, _react.useState)(
|
|
459
|
+
api = _ref9.api,
|
|
460
|
+
floatingToolbarRenderContext = _ref9.floatingToolbarRenderContext;
|
|
461
|
+
var _useState5 = (0, _react.useState)(false),
|
|
464
462
|
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
var
|
|
463
|
+
isOpen = _useState6[0],
|
|
464
|
+
setIsOpen = _useState6[1];
|
|
465
|
+
var _useReferenceData = useReferenceData({
|
|
466
|
+
intl: intl,
|
|
467
|
+
isSource: isSource,
|
|
468
|
+
localId: localId,
|
|
469
|
+
resourceId: resourceId,
|
|
470
|
+
syncBlockStore: syncBlockStore
|
|
471
|
+
}),
|
|
472
|
+
fetchStatus = _useReferenceData.fetchStatus,
|
|
473
|
+
referenceData = _useReferenceData.referenceData;
|
|
474
|
+
var content = isOpen ? /*#__PURE__*/React.createElement(DropdownContentWithReferenceData, {
|
|
475
|
+
resourceId: resourceId,
|
|
476
|
+
intl: intl,
|
|
477
|
+
api: api,
|
|
478
|
+
fetchStatus: fetchStatus,
|
|
479
|
+
referenceData: referenceData
|
|
480
|
+
}) : null;
|
|
481
|
+
var toggleOpen = (0, _react.useCallback)(function () {
|
|
482
|
+
setIsOpen(function (currentIsOpen) {
|
|
483
|
+
return !currentIsOpen;
|
|
484
|
+
});
|
|
485
|
+
}, []);
|
|
486
|
+
var closeDropdown = (0, _react.useCallback)(function () {
|
|
487
|
+
setIsOpen(false);
|
|
488
|
+
}, []);
|
|
489
|
+
var setDisableParentScroll = floatingToolbarRenderContext === null || floatingToolbarRenderContext === void 0 ? void 0 : floatingToolbarRenderContext.setDisableParentScroll;
|
|
490
|
+
(0, _react.useEffect)(function () {
|
|
491
|
+
if (!isOpen) {
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
setDisableParentScroll === null || setDisableParentScroll === void 0 || setDisableParentScroll(true);
|
|
495
|
+
return function () {
|
|
496
|
+
setDisableParentScroll === null || setDisableParentScroll === void 0 || setDisableParentScroll(false);
|
|
497
|
+
};
|
|
498
|
+
}, [isOpen, setDisableParentScroll]);
|
|
499
|
+
var trigger = (0, _react.useMemo)(function () {
|
|
500
|
+
return /*#__PURE__*/React.createElement(_ui.FloatingToolbarButton, {
|
|
501
|
+
areAnyNewToolbarFlagsEnabled: true,
|
|
502
|
+
testId: _types.SYNCED_BLOCK_BUTTON_TEST_ID.syncedBlockToolbarSyncedLocationsTrigger,
|
|
503
|
+
selected: isOpen,
|
|
504
|
+
iconAfter: /*#__PURE__*/React.createElement(_chevronDown.default, {
|
|
505
|
+
color: "currentColor",
|
|
506
|
+
spacing: "spacious",
|
|
507
|
+
label: "",
|
|
508
|
+
size: "small"
|
|
509
|
+
}),
|
|
510
|
+
onClick: toggleOpen,
|
|
511
|
+
ariaHasPopup: true
|
|
512
|
+
}, /*#__PURE__*/React.createElement(SyncedLocationTriggerContent, {
|
|
513
|
+
intl: intl,
|
|
514
|
+
fetchStatus: fetchStatus,
|
|
515
|
+
referenceData: referenceData
|
|
516
|
+
}));
|
|
517
|
+
}, [fetchStatus, intl, isOpen, referenceData, toggleOpen]);
|
|
518
|
+
return /*#__PURE__*/React.createElement(_uiMenu.DropdownContainer, {
|
|
519
|
+
testId: SYNCED_LOCATIONS_DROPDOWN_TEST_ID,
|
|
520
|
+
isOpen: isOpen,
|
|
521
|
+
trigger: trigger,
|
|
522
|
+
handleClickOutside: closeDropdown,
|
|
523
|
+
handleEscapeKeydown: closeDropdown,
|
|
524
|
+
mountTo: floatingToolbarRenderContext === null || floatingToolbarRenderContext === void 0 ? void 0 : floatingToolbarRenderContext.popupsMountPoint,
|
|
525
|
+
boundariesElement: floatingToolbarRenderContext === null || floatingToolbarRenderContext === void 0 ? void 0 : floatingToolbarRenderContext.popupsBoundariesElement,
|
|
526
|
+
scrollableElement: floatingToolbarRenderContext === null || floatingToolbarRenderContext === void 0 ? void 0 : floatingToolbarRenderContext.popupsScrollableElement
|
|
527
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
528
|
+
,
|
|
529
|
+
arrowKeyNavigationProviderOptions: {
|
|
530
|
+
type: _uiMenu.ArrowKeyNavigationType.MENU
|
|
531
|
+
}
|
|
532
|
+
}, content);
|
|
533
|
+
};
|
|
534
|
+
var DropdownContent = function DropdownContent(_ref0) {
|
|
535
|
+
var syncBlockStore = _ref0.syncBlockStore,
|
|
536
|
+
resourceId = _ref0.resourceId,
|
|
537
|
+
intl = _ref0.intl,
|
|
538
|
+
isSource = _ref0.isSource,
|
|
539
|
+
localId = _ref0.localId,
|
|
540
|
+
api = _ref0.api;
|
|
541
|
+
var _useState7 = (0, _react.useState)('none'),
|
|
468
542
|
_useState8 = (0, _slicedToArray2.default)(_useState7, 2),
|
|
469
|
-
|
|
470
|
-
|
|
543
|
+
fetchStatus = _useState8[0],
|
|
544
|
+
setFetchStatus = _useState8[1];
|
|
545
|
+
var _useState9 = (0, _react.useState)([]),
|
|
546
|
+
_useState0 = (0, _slicedToArray2.default)(_useState9, 2),
|
|
547
|
+
referenceData = _useState0[0],
|
|
548
|
+
setReferenceData = _useState0[1];
|
|
471
549
|
(0, _react.useEffect)(function () {
|
|
472
550
|
setFetchStatus('loading');
|
|
473
551
|
var getReferenceData = /*#__PURE__*/function () {
|
|
474
|
-
var
|
|
552
|
+
var _ref1 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
475
553
|
var response;
|
|
476
554
|
return _regenerator.default.wrap(function (_context) {
|
|
477
555
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -496,11 +574,128 @@ var DropdownContent = function DropdownContent(_ref9) {
|
|
|
496
574
|
}, _callee);
|
|
497
575
|
}));
|
|
498
576
|
return function getReferenceData() {
|
|
499
|
-
return
|
|
577
|
+
return _ref1.apply(this, arguments);
|
|
500
578
|
};
|
|
501
579
|
}();
|
|
502
|
-
getReferenceData();
|
|
580
|
+
void getReferenceData();
|
|
503
581
|
}, [syncBlockStore, intl, isSource, localId, resourceId]);
|
|
582
|
+
return /*#__PURE__*/React.createElement(DropdownContentWithReferenceData, {
|
|
583
|
+
resourceId: resourceId,
|
|
584
|
+
intl: intl,
|
|
585
|
+
api: api,
|
|
586
|
+
fetchStatus: fetchStatus,
|
|
587
|
+
referenceData: referenceData
|
|
588
|
+
});
|
|
589
|
+
};
|
|
590
|
+
var useReferenceData = function useReferenceData(_ref10) {
|
|
591
|
+
var syncBlockStore = _ref10.syncBlockStore,
|
|
592
|
+
resourceId = _ref10.resourceId,
|
|
593
|
+
intl = _ref10.intl,
|
|
594
|
+
isSource = _ref10.isSource,
|
|
595
|
+
localId = _ref10.localId;
|
|
596
|
+
var _useState1 = (0, _react.useState)({
|
|
597
|
+
fetchStatus: 'loading',
|
|
598
|
+
referenceData: []
|
|
599
|
+
}),
|
|
600
|
+
_useState10 = (0, _slicedToArray2.default)(_useState1, 2),
|
|
601
|
+
state = _useState10[0],
|
|
602
|
+
setState = _useState10[1];
|
|
603
|
+
(0, _react.useEffect)(function () {
|
|
604
|
+
var isCurrentRequest = true;
|
|
605
|
+
setState({
|
|
606
|
+
fetchStatus: 'loading',
|
|
607
|
+
referenceData: []
|
|
608
|
+
});
|
|
609
|
+
var getReferenceData = /*#__PURE__*/function () {
|
|
610
|
+
var _ref11 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
611
|
+
var response;
|
|
612
|
+
return _regenerator.default.wrap(function (_context2) {
|
|
613
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
614
|
+
case 0:
|
|
615
|
+
_context2.next = 1;
|
|
616
|
+
return syncBlockStore.fetchReferencesSourceInfo(resourceId, localId, isSource);
|
|
617
|
+
case 1:
|
|
618
|
+
response = _context2.sent;
|
|
619
|
+
if (isCurrentRequest) {
|
|
620
|
+
_context2.next = 2;
|
|
621
|
+
break;
|
|
622
|
+
}
|
|
623
|
+
return _context2.abrupt("return");
|
|
624
|
+
case 2:
|
|
625
|
+
if (!response.error) {
|
|
626
|
+
_context2.next = 3;
|
|
627
|
+
break;
|
|
628
|
+
}
|
|
629
|
+
setState({
|
|
630
|
+
fetchStatus: 'error',
|
|
631
|
+
referenceData: []
|
|
632
|
+
});
|
|
633
|
+
return _context2.abrupt("return");
|
|
634
|
+
case 3:
|
|
635
|
+
setState({
|
|
636
|
+
fetchStatus: 'success',
|
|
637
|
+
referenceData: processReferenceData(response.references, intl)
|
|
638
|
+
});
|
|
639
|
+
case 4:
|
|
640
|
+
case "end":
|
|
641
|
+
return _context2.stop();
|
|
642
|
+
}
|
|
643
|
+
}, _callee2);
|
|
644
|
+
}));
|
|
645
|
+
return function getReferenceData() {
|
|
646
|
+
return _ref11.apply(this, arguments);
|
|
647
|
+
};
|
|
648
|
+
}();
|
|
649
|
+
void getReferenceData();
|
|
650
|
+
return function () {
|
|
651
|
+
isCurrentRequest = false;
|
|
652
|
+
};
|
|
653
|
+
}, [syncBlockStore, resourceId, intl, isSource, localId]);
|
|
654
|
+
return {
|
|
655
|
+
fetchStatus: state.fetchStatus,
|
|
656
|
+
referenceData: state.referenceData
|
|
657
|
+
};
|
|
658
|
+
};
|
|
659
|
+
var SyncedLocationTriggerContent = function SyncedLocationTriggerContent(_ref12) {
|
|
660
|
+
var intl = _ref12.intl,
|
|
661
|
+
fetchStatus = _ref12.fetchStatus,
|
|
662
|
+
referenceData = _ref12.referenceData;
|
|
663
|
+
var formatMessage = intl.formatMessage;
|
|
664
|
+
var triggerTitle = formatMessage(_messages.syncBlockMessages.syncedLocationDropdownTitle);
|
|
665
|
+
var referenceCount = (0, _react.useMemo)(function () {
|
|
666
|
+
return referenceData.filter(function (_ref13) {
|
|
667
|
+
var isSource = _ref13.isSource;
|
|
668
|
+
return !isSource;
|
|
669
|
+
}).length;
|
|
670
|
+
}, [referenceData]);
|
|
671
|
+
switch (fetchStatus) {
|
|
672
|
+
case 'loading':
|
|
673
|
+
return /*#__PURE__*/React.createElement(_compiled.Inline, {
|
|
674
|
+
alignBlock: "center",
|
|
675
|
+
space: "space.050"
|
|
676
|
+
}, triggerTitle, /*#__PURE__*/React.createElement(_spinner.default, {
|
|
677
|
+
size: "small",
|
|
678
|
+
label: formatMessage(_messages.syncBlockMessages.syncedLocationDropdownLoading)
|
|
679
|
+
}));
|
|
680
|
+
case 'success':
|
|
681
|
+
{
|
|
682
|
+
var count = referenceCount === 0 ? formatMessage(_messages.syncBlockMessages.syncedLocationDropdownNone) : referenceCount > 99 ? '99+' : intl.formatNumber(referenceCount);
|
|
683
|
+
return formatMessage(_messages.syncBlockMessages.syncedLocationDropdownTitleWithCount, {
|
|
684
|
+
count: count
|
|
685
|
+
});
|
|
686
|
+
}
|
|
687
|
+
case 'none':
|
|
688
|
+
case 'error':
|
|
689
|
+
return triggerTitle;
|
|
690
|
+
}
|
|
691
|
+
};
|
|
692
|
+
var DropdownContentWithReferenceData = function DropdownContentWithReferenceData(_ref14) {
|
|
693
|
+
var resourceId = _ref14.resourceId,
|
|
694
|
+
intl = _ref14.intl,
|
|
695
|
+
api = _ref14.api,
|
|
696
|
+
fetchStatus = _ref14.fetchStatus,
|
|
697
|
+
referenceData = _ref14.referenceData;
|
|
698
|
+
var formatMessage = intl.formatMessage;
|
|
504
699
|
var handleLocationClick = function handleLocationClick() {
|
|
505
700
|
var _api$analytics;
|
|
506
701
|
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || (_api$analytics = _api$analytics.actions) === null || _api$analytics === void 0 || _api$analytics.fireAnalyticsEvent({
|
|
@@ -516,7 +711,9 @@ var DropdownContent = function DropdownContent(_ref9) {
|
|
|
516
711
|
var content = function content() {
|
|
517
712
|
switch (fetchStatus) {
|
|
518
713
|
case 'loading':
|
|
519
|
-
return /*#__PURE__*/React.createElement(LoadingScreen,
|
|
714
|
+
return /*#__PURE__*/React.createElement(LoadingScreen, {
|
|
715
|
+
formatMessage: formatMessage
|
|
716
|
+
});
|
|
520
717
|
case 'error':
|
|
521
718
|
return /*#__PURE__*/React.createElement(ErrorScreen, {
|
|
522
719
|
formatMessage: formatMessage
|
|
@@ -571,11 +768,14 @@ var DropdownContent = function DropdownContent(_ref9) {
|
|
|
571
768
|
xcss: (0, _react2.cx)(styles.dropdownContent, shouldApplyMinHeight(fetchStatus, referenceData.length) && styles.containerWithMinHeight)
|
|
572
769
|
}, content());
|
|
573
770
|
};
|
|
574
|
-
var LoadingScreen = function LoadingScreen() {
|
|
575
|
-
|
|
771
|
+
var LoadingScreen = function LoadingScreen(_ref15) {
|
|
772
|
+
var formatMessage = _ref15.formatMessage;
|
|
773
|
+
return /*#__PURE__*/React.createElement(_compiled.Box, null, /*#__PURE__*/React.createElement(_spinner.default, {
|
|
774
|
+
label: formatMessage(_messages.syncBlockMessages.syncedLocationDropdownLoading)
|
|
775
|
+
}));
|
|
576
776
|
};
|
|
577
|
-
var ErrorScreen = function ErrorScreen(
|
|
578
|
-
var formatMessage =
|
|
777
|
+
var ErrorScreen = function ErrorScreen(_ref16) {
|
|
778
|
+
var formatMessage = _ref16.formatMessage;
|
|
579
779
|
return /*#__PURE__*/React.createElement(_compiled.Box, {
|
|
580
780
|
xcss: styles.errorContainer,
|
|
581
781
|
testId: "synced-locations-dropdown-content-error"
|
|
@@ -591,8 +791,8 @@ var ErrorScreen = function ErrorScreen(_ref1) {
|
|
|
591
791
|
size: "medium"
|
|
592
792
|
}, formatMessage(_messages.syncBlockMessages.syncedLocationDropdownError)));
|
|
593
793
|
};
|
|
594
|
-
var NoResultScreen = function NoResultScreen(
|
|
595
|
-
var formatMessage =
|
|
794
|
+
var NoResultScreen = function NoResultScreen(_ref17) {
|
|
795
|
+
var formatMessage = _ref17.formatMessage;
|
|
596
796
|
return /*#__PURE__*/React.createElement(_compiled.Stack, {
|
|
597
797
|
xcss: styles.noResultsContainer,
|
|
598
798
|
space: "space.100",
|
|
@@ -96,6 +96,18 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(stat
|
|
|
96
96
|
type: 'custom',
|
|
97
97
|
fallback: [],
|
|
98
98
|
render: function render(_view, _idx, _dispatchAnalyticsEvent, floatingToolbarRenderContext) {
|
|
99
|
+
if (isSyncBlockActivationEnabled) {
|
|
100
|
+
return /*#__PURE__*/_react.default.createElement(_SyncedLocationDropdown.SyncedLocationDropdownWithCount, {
|
|
101
|
+
key: "".concat(resourceId, ":").concat(localId, ":").concat(isBodiedSyncBlock),
|
|
102
|
+
syncBlockStore: syncBlockStore,
|
|
103
|
+
resourceId: resourceId,
|
|
104
|
+
localId: localId,
|
|
105
|
+
intl: intl,
|
|
106
|
+
isSource: isBodiedSyncBlock,
|
|
107
|
+
api: api,
|
|
108
|
+
floatingToolbarRenderContext: floatingToolbarRenderContext
|
|
109
|
+
});
|
|
110
|
+
}
|
|
99
111
|
return /*#__PURE__*/_react.default.createElement(_SyncedLocationDropdown.SyncedLocationDropdown, {
|
|
100
112
|
syncBlockStore: syncBlockStore,
|
|
101
113
|
resourceId: resourceId,
|
|
@@ -13,6 +13,7 @@ import { FloatingToolbarButton as Button } from '@atlaskit/editor-common/ui';
|
|
|
13
13
|
import { ArrowKeyNavigationType, DropdownContainer } from '@atlaskit/editor-common/ui-menu';
|
|
14
14
|
import { getPageIdAndTypeFromConfluencePageAri } from '@atlaskit/editor-synced-block-provider';
|
|
15
15
|
import { IconTile } from '@atlaskit/icon';
|
|
16
|
+
// eslint-disable-next-line import/order -- CI requires icon-lab imports before core icon imports.
|
|
16
17
|
import PageLiveDocIcon from '@atlaskit/icon-lab/core/page-live-doc';
|
|
17
18
|
import BugIcon from '@atlaskit/icon/core/bug';
|
|
18
19
|
import ChevronDownIcon from '@atlaskit/icon/core/chevron-down';
|
|
@@ -290,24 +291,24 @@ export const SyncedLocationDropdown = ({
|
|
|
290
291
|
api,
|
|
291
292
|
floatingToolbarRenderContext
|
|
292
293
|
}) => {
|
|
293
|
-
if (fg('platform_synced_block_patch_13')) {
|
|
294
|
-
return /*#__PURE__*/React.createElement(
|
|
294
|
+
if (!fg('platform_synced_block_patch_13')) {
|
|
295
|
+
return /*#__PURE__*/React.createElement(LegacySyncedLocationDropdown, {
|
|
295
296
|
syncBlockStore: syncBlockStore,
|
|
296
297
|
resourceId: resourceId,
|
|
297
298
|
intl: intl,
|
|
298
299
|
isSource: isSource,
|
|
299
300
|
localId: localId,
|
|
300
|
-
api: api
|
|
301
|
-
floatingToolbarRenderContext: floatingToolbarRenderContext
|
|
301
|
+
api: api
|
|
302
302
|
});
|
|
303
303
|
}
|
|
304
|
-
return /*#__PURE__*/React.createElement(
|
|
304
|
+
return /*#__PURE__*/React.createElement(EditorPositionedSyncedLocationDropdown, {
|
|
305
305
|
syncBlockStore: syncBlockStore,
|
|
306
306
|
resourceId: resourceId,
|
|
307
307
|
intl: intl,
|
|
308
308
|
isSource: isSource,
|
|
309
309
|
localId: localId,
|
|
310
|
-
api: api
|
|
310
|
+
api: api,
|
|
311
|
+
floatingToolbarRenderContext: floatingToolbarRenderContext
|
|
311
312
|
});
|
|
312
313
|
};
|
|
313
314
|
const EditorPositionedSyncedLocationDropdown = ({
|
|
@@ -319,10 +320,7 @@ const EditorPositionedSyncedLocationDropdown = ({
|
|
|
319
320
|
api,
|
|
320
321
|
floatingToolbarRenderContext
|
|
321
322
|
}) => {
|
|
322
|
-
const
|
|
323
|
-
formatMessage
|
|
324
|
-
} = intl;
|
|
325
|
-
const triggerTitle = formatMessage(messages.syncedLocationDropdownTitle);
|
|
323
|
+
const triggerTitle = intl.formatMessage(messages.syncedLocationDropdownTitle);
|
|
326
324
|
const [isOpen, setIsOpen] = useState(false);
|
|
327
325
|
const content = isOpen ? /*#__PURE__*/React.createElement(DropdownContent, {
|
|
328
326
|
syncBlockStore: syncBlockStore,
|
|
@@ -385,10 +383,7 @@ const LegacySyncedLocationDropdown = ({
|
|
|
385
383
|
localId,
|
|
386
384
|
api
|
|
387
385
|
}) => {
|
|
388
|
-
const
|
|
389
|
-
formatMessage
|
|
390
|
-
} = intl;
|
|
391
|
-
const triggerTitle = formatMessage(messages.syncedLocationDropdownTitle);
|
|
386
|
+
const triggerTitle = intl.formatMessage(messages.syncedLocationDropdownTitle);
|
|
392
387
|
const [isOpen, setIsOpen] = useState(false);
|
|
393
388
|
const content = isOpen ? /*#__PURE__*/React.createElement(DropdownContent, {
|
|
394
389
|
syncBlockStore: syncBlockStore,
|
|
@@ -425,6 +420,82 @@ const LegacySyncedLocationDropdown = ({
|
|
|
425
420
|
}, triggerProps), triggerTitle)
|
|
426
421
|
}, content);
|
|
427
422
|
};
|
|
423
|
+
export const SyncedLocationDropdownWithCount = ({
|
|
424
|
+
syncBlockStore,
|
|
425
|
+
resourceId,
|
|
426
|
+
intl,
|
|
427
|
+
isSource,
|
|
428
|
+
localId,
|
|
429
|
+
api,
|
|
430
|
+
floatingToolbarRenderContext
|
|
431
|
+
}) => {
|
|
432
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
433
|
+
const {
|
|
434
|
+
fetchStatus,
|
|
435
|
+
referenceData
|
|
436
|
+
} = useReferenceData({
|
|
437
|
+
intl,
|
|
438
|
+
isSource,
|
|
439
|
+
localId,
|
|
440
|
+
resourceId,
|
|
441
|
+
syncBlockStore
|
|
442
|
+
});
|
|
443
|
+
const content = isOpen ? /*#__PURE__*/React.createElement(DropdownContentWithReferenceData, {
|
|
444
|
+
resourceId: resourceId,
|
|
445
|
+
intl: intl,
|
|
446
|
+
api: api,
|
|
447
|
+
fetchStatus: fetchStatus,
|
|
448
|
+
referenceData: referenceData
|
|
449
|
+
}) : null;
|
|
450
|
+
const toggleOpen = useCallback(() => {
|
|
451
|
+
setIsOpen(currentIsOpen => !currentIsOpen);
|
|
452
|
+
}, []);
|
|
453
|
+
const closeDropdown = useCallback(() => {
|
|
454
|
+
setIsOpen(false);
|
|
455
|
+
}, []);
|
|
456
|
+
const setDisableParentScroll = floatingToolbarRenderContext === null || floatingToolbarRenderContext === void 0 ? void 0 : floatingToolbarRenderContext.setDisableParentScroll;
|
|
457
|
+
useEffect(() => {
|
|
458
|
+
if (!isOpen) {
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
setDisableParentScroll === null || setDisableParentScroll === void 0 ? void 0 : setDisableParentScroll(true);
|
|
462
|
+
return () => {
|
|
463
|
+
setDisableParentScroll === null || setDisableParentScroll === void 0 ? void 0 : setDisableParentScroll(false);
|
|
464
|
+
};
|
|
465
|
+
}, [isOpen, setDisableParentScroll]);
|
|
466
|
+
const trigger = useMemo(() => /*#__PURE__*/React.createElement(Button, {
|
|
467
|
+
areAnyNewToolbarFlagsEnabled: true,
|
|
468
|
+
testId: SYNCED_BLOCK_BUTTON_TEST_ID.syncedBlockToolbarSyncedLocationsTrigger,
|
|
469
|
+
selected: isOpen,
|
|
470
|
+
iconAfter: /*#__PURE__*/React.createElement(ChevronDownIcon, {
|
|
471
|
+
color: "currentColor",
|
|
472
|
+
spacing: "spacious",
|
|
473
|
+
label: "",
|
|
474
|
+
size: "small"
|
|
475
|
+
}),
|
|
476
|
+
onClick: toggleOpen,
|
|
477
|
+
ariaHasPopup: true
|
|
478
|
+
}, /*#__PURE__*/React.createElement(SyncedLocationTriggerContent, {
|
|
479
|
+
intl: intl,
|
|
480
|
+
fetchStatus: fetchStatus,
|
|
481
|
+
referenceData: referenceData
|
|
482
|
+
})), [fetchStatus, intl, isOpen, referenceData, toggleOpen]);
|
|
483
|
+
return /*#__PURE__*/React.createElement(DropdownContainer, {
|
|
484
|
+
testId: SYNCED_LOCATIONS_DROPDOWN_TEST_ID,
|
|
485
|
+
isOpen: isOpen,
|
|
486
|
+
trigger: trigger,
|
|
487
|
+
handleClickOutside: closeDropdown,
|
|
488
|
+
handleEscapeKeydown: closeDropdown,
|
|
489
|
+
mountTo: floatingToolbarRenderContext === null || floatingToolbarRenderContext === void 0 ? void 0 : floatingToolbarRenderContext.popupsMountPoint,
|
|
490
|
+
boundariesElement: floatingToolbarRenderContext === null || floatingToolbarRenderContext === void 0 ? void 0 : floatingToolbarRenderContext.popupsBoundariesElement,
|
|
491
|
+
scrollableElement: floatingToolbarRenderContext === null || floatingToolbarRenderContext === void 0 ? void 0 : floatingToolbarRenderContext.popupsScrollableElement
|
|
492
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
493
|
+
,
|
|
494
|
+
arrowKeyNavigationProviderOptions: {
|
|
495
|
+
type: ArrowKeyNavigationType.MENU
|
|
496
|
+
}
|
|
497
|
+
}, content);
|
|
498
|
+
};
|
|
428
499
|
const DropdownContent = ({
|
|
429
500
|
syncBlockStore,
|
|
430
501
|
resourceId,
|
|
@@ -433,9 +504,6 @@ const DropdownContent = ({
|
|
|
433
504
|
localId,
|
|
434
505
|
api
|
|
435
506
|
}) => {
|
|
436
|
-
const {
|
|
437
|
-
formatMessage
|
|
438
|
-
} = intl;
|
|
439
507
|
const [fetchStatus, setFetchStatus] = useState('none');
|
|
440
508
|
const [referenceData, setReferenceData] = useState([]);
|
|
441
509
|
useEffect(() => {
|
|
@@ -449,8 +517,103 @@ const DropdownContent = ({
|
|
|
449
517
|
setReferenceData(processReferenceData(response.references, intl));
|
|
450
518
|
setFetchStatus('success');
|
|
451
519
|
};
|
|
452
|
-
getReferenceData();
|
|
520
|
+
void getReferenceData();
|
|
453
521
|
}, [syncBlockStore, intl, isSource, localId, resourceId]);
|
|
522
|
+
return /*#__PURE__*/React.createElement(DropdownContentWithReferenceData, {
|
|
523
|
+
resourceId: resourceId,
|
|
524
|
+
intl: intl,
|
|
525
|
+
api: api,
|
|
526
|
+
fetchStatus: fetchStatus,
|
|
527
|
+
referenceData: referenceData
|
|
528
|
+
});
|
|
529
|
+
};
|
|
530
|
+
const useReferenceData = ({
|
|
531
|
+
syncBlockStore,
|
|
532
|
+
resourceId,
|
|
533
|
+
intl,
|
|
534
|
+
isSource,
|
|
535
|
+
localId
|
|
536
|
+
}) => {
|
|
537
|
+
const [state, setState] = useState({
|
|
538
|
+
fetchStatus: 'loading',
|
|
539
|
+
referenceData: []
|
|
540
|
+
});
|
|
541
|
+
useEffect(() => {
|
|
542
|
+
let isCurrentRequest = true;
|
|
543
|
+
setState({
|
|
544
|
+
fetchStatus: 'loading',
|
|
545
|
+
referenceData: []
|
|
546
|
+
});
|
|
547
|
+
const getReferenceData = async () => {
|
|
548
|
+
const response = await syncBlockStore.fetchReferencesSourceInfo(resourceId, localId, isSource);
|
|
549
|
+
if (!isCurrentRequest) {
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
if (response.error) {
|
|
553
|
+
setState({
|
|
554
|
+
fetchStatus: 'error',
|
|
555
|
+
referenceData: []
|
|
556
|
+
});
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
559
|
+
setState({
|
|
560
|
+
fetchStatus: 'success',
|
|
561
|
+
referenceData: processReferenceData(response.references, intl)
|
|
562
|
+
});
|
|
563
|
+
};
|
|
564
|
+
void getReferenceData();
|
|
565
|
+
return () => {
|
|
566
|
+
isCurrentRequest = false;
|
|
567
|
+
};
|
|
568
|
+
}, [syncBlockStore, resourceId, intl, isSource, localId]);
|
|
569
|
+
return {
|
|
570
|
+
fetchStatus: state.fetchStatus,
|
|
571
|
+
referenceData: state.referenceData
|
|
572
|
+
};
|
|
573
|
+
};
|
|
574
|
+
const SyncedLocationTriggerContent = ({
|
|
575
|
+
intl,
|
|
576
|
+
fetchStatus,
|
|
577
|
+
referenceData
|
|
578
|
+
}) => {
|
|
579
|
+
const {
|
|
580
|
+
formatMessage
|
|
581
|
+
} = intl;
|
|
582
|
+
const triggerTitle = formatMessage(messages.syncedLocationDropdownTitle);
|
|
583
|
+
const referenceCount = useMemo(() => referenceData.filter(({
|
|
584
|
+
isSource
|
|
585
|
+
}) => !isSource).length, [referenceData]);
|
|
586
|
+
switch (fetchStatus) {
|
|
587
|
+
case 'loading':
|
|
588
|
+
return /*#__PURE__*/React.createElement(Inline, {
|
|
589
|
+
alignBlock: "center",
|
|
590
|
+
space: "space.050"
|
|
591
|
+
}, triggerTitle, /*#__PURE__*/React.createElement(Spinner, {
|
|
592
|
+
size: "small",
|
|
593
|
+
label: formatMessage(messages.syncedLocationDropdownLoading)
|
|
594
|
+
}));
|
|
595
|
+
case 'success':
|
|
596
|
+
{
|
|
597
|
+
const count = referenceCount === 0 ? formatMessage(messages.syncedLocationDropdownNone) : referenceCount > 99 ? '99+' : intl.formatNumber(referenceCount);
|
|
598
|
+
return formatMessage(messages.syncedLocationDropdownTitleWithCount, {
|
|
599
|
+
count
|
|
600
|
+
});
|
|
601
|
+
}
|
|
602
|
+
case 'none':
|
|
603
|
+
case 'error':
|
|
604
|
+
return triggerTitle;
|
|
605
|
+
}
|
|
606
|
+
};
|
|
607
|
+
const DropdownContentWithReferenceData = ({
|
|
608
|
+
resourceId,
|
|
609
|
+
intl,
|
|
610
|
+
api,
|
|
611
|
+
fetchStatus,
|
|
612
|
+
referenceData
|
|
613
|
+
}) => {
|
|
614
|
+
const {
|
|
615
|
+
formatMessage
|
|
616
|
+
} = intl;
|
|
454
617
|
const handleLocationClick = () => {
|
|
455
618
|
var _api$analytics, _api$analytics$action;
|
|
456
619
|
api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : (_api$analytics$action = _api$analytics.actions) === null || _api$analytics$action === void 0 ? void 0 : _api$analytics$action.fireAnalyticsEvent({
|
|
@@ -466,7 +629,9 @@ const DropdownContent = ({
|
|
|
466
629
|
const content = () => {
|
|
467
630
|
switch (fetchStatus) {
|
|
468
631
|
case 'loading':
|
|
469
|
-
return /*#__PURE__*/React.createElement(LoadingScreen,
|
|
632
|
+
return /*#__PURE__*/React.createElement(LoadingScreen, {
|
|
633
|
+
formatMessage: formatMessage
|
|
634
|
+
});
|
|
470
635
|
case 'error':
|
|
471
636
|
return /*#__PURE__*/React.createElement(ErrorScreen, {
|
|
472
637
|
formatMessage: formatMessage
|
|
@@ -519,8 +684,12 @@ const DropdownContent = ({
|
|
|
519
684
|
xcss: cx(styles.dropdownContent, shouldApplyMinHeight(fetchStatus, referenceData.length) && styles.containerWithMinHeight)
|
|
520
685
|
}, content());
|
|
521
686
|
};
|
|
522
|
-
const LoadingScreen = (
|
|
523
|
-
|
|
687
|
+
const LoadingScreen = ({
|
|
688
|
+
formatMessage
|
|
689
|
+
}) => {
|
|
690
|
+
return /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(Spinner, {
|
|
691
|
+
label: formatMessage(messages.syncedLocationDropdownLoading)
|
|
692
|
+
}));
|
|
524
693
|
};
|
|
525
694
|
const ErrorScreen = ({
|
|
526
695
|
formatMessage
|
|
@@ -16,7 +16,7 @@ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
|
16
16
|
import { copySyncedBlockReferenceToClipboard, editSyncedBlockSource, removeSyncedBlock, unsync } from '../editor-commands';
|
|
17
17
|
import { findSyncBlockOrBodiedSyncBlock, isBodiedSyncBlockNode } from '../pm-plugins/utils/utils';
|
|
18
18
|
import { SYNCED_BLOCK_BUTTON_TEST_ID } from '../types';
|
|
19
|
-
import { SyncedLocationDropdown } from './SyncedLocationDropdown';
|
|
19
|
+
import { SyncedLocationDropdown, SyncedLocationDropdownWithCount } from './SyncedLocationDropdown';
|
|
20
20
|
export const getToolbarConfig = (state, intl, api, syncBlockStore, isLivePage, onGiveFeedback) => {
|
|
21
21
|
var _syncBlockInstance$er, _api$decorations, _api$connectivity, _api$connectivity$sha;
|
|
22
22
|
const syncBlockObject = findSyncBlockOrBodiedSyncBlock(state.schema, state.selection);
|
|
@@ -92,6 +92,18 @@ export const getToolbarConfig = (state, intl, api, syncBlockStore, isLivePage, o
|
|
|
92
92
|
type: 'custom',
|
|
93
93
|
fallback: [],
|
|
94
94
|
render: (_view, _idx, _dispatchAnalyticsEvent, floatingToolbarRenderContext) => {
|
|
95
|
+
if (isSyncBlockActivationEnabled) {
|
|
96
|
+
return /*#__PURE__*/React.createElement(SyncedLocationDropdownWithCount, {
|
|
97
|
+
key: `${resourceId}:${localId}:${isBodiedSyncBlock}`,
|
|
98
|
+
syncBlockStore: syncBlockStore,
|
|
99
|
+
resourceId: resourceId,
|
|
100
|
+
localId: localId,
|
|
101
|
+
intl: intl,
|
|
102
|
+
isSource: isBodiedSyncBlock,
|
|
103
|
+
api: api,
|
|
104
|
+
floatingToolbarRenderContext: floatingToolbarRenderContext
|
|
105
|
+
});
|
|
106
|
+
}
|
|
95
107
|
return /*#__PURE__*/React.createElement(SyncedLocationDropdown, {
|
|
96
108
|
syncBlockStore: syncBlockStore,
|
|
97
109
|
resourceId: resourceId,
|
|
@@ -21,6 +21,7 @@ import { FloatingToolbarButton as Button } from '@atlaskit/editor-common/ui';
|
|
|
21
21
|
import { ArrowKeyNavigationType, DropdownContainer } from '@atlaskit/editor-common/ui-menu';
|
|
22
22
|
import { getPageIdAndTypeFromConfluencePageAri } from '@atlaskit/editor-synced-block-provider';
|
|
23
23
|
import { IconTile } from '@atlaskit/icon';
|
|
24
|
+
// eslint-disable-next-line import/order -- CI requires icon-lab imports before core icon imports.
|
|
24
25
|
import PageLiveDocIcon from '@atlaskit/icon-lab/core/page-live-doc';
|
|
25
26
|
import BugIcon from '@atlaskit/icon/core/bug';
|
|
26
27
|
import ChevronDownIcon from '@atlaskit/icon/core/chevron-down';
|
|
@@ -302,24 +303,24 @@ export var SyncedLocationDropdown = function SyncedLocationDropdown(_ref4) {
|
|
|
302
303
|
localId = _ref4.localId,
|
|
303
304
|
api = _ref4.api,
|
|
304
305
|
floatingToolbarRenderContext = _ref4.floatingToolbarRenderContext;
|
|
305
|
-
if (fg('platform_synced_block_patch_13')) {
|
|
306
|
-
return /*#__PURE__*/React.createElement(
|
|
306
|
+
if (!fg('platform_synced_block_patch_13')) {
|
|
307
|
+
return /*#__PURE__*/React.createElement(LegacySyncedLocationDropdown, {
|
|
307
308
|
syncBlockStore: syncBlockStore,
|
|
308
309
|
resourceId: resourceId,
|
|
309
310
|
intl: intl,
|
|
310
311
|
isSource: isSource,
|
|
311
312
|
localId: localId,
|
|
312
|
-
api: api
|
|
313
|
-
floatingToolbarRenderContext: floatingToolbarRenderContext
|
|
313
|
+
api: api
|
|
314
314
|
});
|
|
315
315
|
}
|
|
316
|
-
return /*#__PURE__*/React.createElement(
|
|
316
|
+
return /*#__PURE__*/React.createElement(EditorPositionedSyncedLocationDropdown, {
|
|
317
317
|
syncBlockStore: syncBlockStore,
|
|
318
318
|
resourceId: resourceId,
|
|
319
319
|
intl: intl,
|
|
320
320
|
isSource: isSource,
|
|
321
321
|
localId: localId,
|
|
322
|
-
api: api
|
|
322
|
+
api: api,
|
|
323
|
+
floatingToolbarRenderContext: floatingToolbarRenderContext
|
|
323
324
|
});
|
|
324
325
|
};
|
|
325
326
|
var EditorPositionedSyncedLocationDropdown = function EditorPositionedSyncedLocationDropdown(_ref5) {
|
|
@@ -330,8 +331,7 @@ var EditorPositionedSyncedLocationDropdown = function EditorPositionedSyncedLoca
|
|
|
330
331
|
localId = _ref5.localId,
|
|
331
332
|
api = _ref5.api,
|
|
332
333
|
floatingToolbarRenderContext = _ref5.floatingToolbarRenderContext;
|
|
333
|
-
var
|
|
334
|
-
var triggerTitle = formatMessage(messages.syncedLocationDropdownTitle);
|
|
334
|
+
var triggerTitle = intl.formatMessage(messages.syncedLocationDropdownTitle);
|
|
335
335
|
var _useState = useState(false),
|
|
336
336
|
_useState2 = _slicedToArray(_useState, 2),
|
|
337
337
|
isOpen = _useState2[0],
|
|
@@ -400,8 +400,7 @@ var LegacySyncedLocationDropdown = function LegacySyncedLocationDropdown(_ref6)
|
|
|
400
400
|
isSource = _ref6.isSource,
|
|
401
401
|
localId = _ref6.localId,
|
|
402
402
|
api = _ref6.api;
|
|
403
|
-
var
|
|
404
|
-
var triggerTitle = formatMessage(messages.syncedLocationDropdownTitle);
|
|
403
|
+
var triggerTitle = intl.formatMessage(messages.syncedLocationDropdownTitle);
|
|
405
404
|
var _useState3 = useState(false),
|
|
406
405
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
407
406
|
isOpen = _useState4[0],
|
|
@@ -443,26 +442,106 @@ var LegacySyncedLocationDropdown = function LegacySyncedLocationDropdown(_ref6)
|
|
|
443
442
|
}
|
|
444
443
|
}, content);
|
|
445
444
|
};
|
|
446
|
-
var
|
|
445
|
+
export var SyncedLocationDropdownWithCount = function SyncedLocationDropdownWithCount(_ref9) {
|
|
447
446
|
var syncBlockStore = _ref9.syncBlockStore,
|
|
448
447
|
resourceId = _ref9.resourceId,
|
|
449
448
|
intl = _ref9.intl,
|
|
450
449
|
isSource = _ref9.isSource,
|
|
451
450
|
localId = _ref9.localId,
|
|
452
|
-
api = _ref9.api
|
|
453
|
-
|
|
454
|
-
var _useState5 = useState(
|
|
451
|
+
api = _ref9.api,
|
|
452
|
+
floatingToolbarRenderContext = _ref9.floatingToolbarRenderContext;
|
|
453
|
+
var _useState5 = useState(false),
|
|
455
454
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
var
|
|
455
|
+
isOpen = _useState6[0],
|
|
456
|
+
setIsOpen = _useState6[1];
|
|
457
|
+
var _useReferenceData = useReferenceData({
|
|
458
|
+
intl: intl,
|
|
459
|
+
isSource: isSource,
|
|
460
|
+
localId: localId,
|
|
461
|
+
resourceId: resourceId,
|
|
462
|
+
syncBlockStore: syncBlockStore
|
|
463
|
+
}),
|
|
464
|
+
fetchStatus = _useReferenceData.fetchStatus,
|
|
465
|
+
referenceData = _useReferenceData.referenceData;
|
|
466
|
+
var content = isOpen ? /*#__PURE__*/React.createElement(DropdownContentWithReferenceData, {
|
|
467
|
+
resourceId: resourceId,
|
|
468
|
+
intl: intl,
|
|
469
|
+
api: api,
|
|
470
|
+
fetchStatus: fetchStatus,
|
|
471
|
+
referenceData: referenceData
|
|
472
|
+
}) : null;
|
|
473
|
+
var toggleOpen = useCallback(function () {
|
|
474
|
+
setIsOpen(function (currentIsOpen) {
|
|
475
|
+
return !currentIsOpen;
|
|
476
|
+
});
|
|
477
|
+
}, []);
|
|
478
|
+
var closeDropdown = useCallback(function () {
|
|
479
|
+
setIsOpen(false);
|
|
480
|
+
}, []);
|
|
481
|
+
var setDisableParentScroll = floatingToolbarRenderContext === null || floatingToolbarRenderContext === void 0 ? void 0 : floatingToolbarRenderContext.setDisableParentScroll;
|
|
482
|
+
useEffect(function () {
|
|
483
|
+
if (!isOpen) {
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
setDisableParentScroll === null || setDisableParentScroll === void 0 || setDisableParentScroll(true);
|
|
487
|
+
return function () {
|
|
488
|
+
setDisableParentScroll === null || setDisableParentScroll === void 0 || setDisableParentScroll(false);
|
|
489
|
+
};
|
|
490
|
+
}, [isOpen, setDisableParentScroll]);
|
|
491
|
+
var trigger = useMemo(function () {
|
|
492
|
+
return /*#__PURE__*/React.createElement(Button, {
|
|
493
|
+
areAnyNewToolbarFlagsEnabled: true,
|
|
494
|
+
testId: SYNCED_BLOCK_BUTTON_TEST_ID.syncedBlockToolbarSyncedLocationsTrigger,
|
|
495
|
+
selected: isOpen,
|
|
496
|
+
iconAfter: /*#__PURE__*/React.createElement(ChevronDownIcon, {
|
|
497
|
+
color: "currentColor",
|
|
498
|
+
spacing: "spacious",
|
|
499
|
+
label: "",
|
|
500
|
+
size: "small"
|
|
501
|
+
}),
|
|
502
|
+
onClick: toggleOpen,
|
|
503
|
+
ariaHasPopup: true
|
|
504
|
+
}, /*#__PURE__*/React.createElement(SyncedLocationTriggerContent, {
|
|
505
|
+
intl: intl,
|
|
506
|
+
fetchStatus: fetchStatus,
|
|
507
|
+
referenceData: referenceData
|
|
508
|
+
}));
|
|
509
|
+
}, [fetchStatus, intl, isOpen, referenceData, toggleOpen]);
|
|
510
|
+
return /*#__PURE__*/React.createElement(DropdownContainer, {
|
|
511
|
+
testId: SYNCED_LOCATIONS_DROPDOWN_TEST_ID,
|
|
512
|
+
isOpen: isOpen,
|
|
513
|
+
trigger: trigger,
|
|
514
|
+
handleClickOutside: closeDropdown,
|
|
515
|
+
handleEscapeKeydown: closeDropdown,
|
|
516
|
+
mountTo: floatingToolbarRenderContext === null || floatingToolbarRenderContext === void 0 ? void 0 : floatingToolbarRenderContext.popupsMountPoint,
|
|
517
|
+
boundariesElement: floatingToolbarRenderContext === null || floatingToolbarRenderContext === void 0 ? void 0 : floatingToolbarRenderContext.popupsBoundariesElement,
|
|
518
|
+
scrollableElement: floatingToolbarRenderContext === null || floatingToolbarRenderContext === void 0 ? void 0 : floatingToolbarRenderContext.popupsScrollableElement
|
|
519
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
520
|
+
,
|
|
521
|
+
arrowKeyNavigationProviderOptions: {
|
|
522
|
+
type: ArrowKeyNavigationType.MENU
|
|
523
|
+
}
|
|
524
|
+
}, content);
|
|
525
|
+
};
|
|
526
|
+
var DropdownContent = function DropdownContent(_ref0) {
|
|
527
|
+
var syncBlockStore = _ref0.syncBlockStore,
|
|
528
|
+
resourceId = _ref0.resourceId,
|
|
529
|
+
intl = _ref0.intl,
|
|
530
|
+
isSource = _ref0.isSource,
|
|
531
|
+
localId = _ref0.localId,
|
|
532
|
+
api = _ref0.api;
|
|
533
|
+
var _useState7 = useState('none'),
|
|
459
534
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
460
|
-
|
|
461
|
-
|
|
535
|
+
fetchStatus = _useState8[0],
|
|
536
|
+
setFetchStatus = _useState8[1];
|
|
537
|
+
var _useState9 = useState([]),
|
|
538
|
+
_useState0 = _slicedToArray(_useState9, 2),
|
|
539
|
+
referenceData = _useState0[0],
|
|
540
|
+
setReferenceData = _useState0[1];
|
|
462
541
|
useEffect(function () {
|
|
463
542
|
setFetchStatus('loading');
|
|
464
543
|
var getReferenceData = /*#__PURE__*/function () {
|
|
465
|
-
var
|
|
544
|
+
var _ref1 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
466
545
|
var response;
|
|
467
546
|
return _regeneratorRuntime.wrap(function (_context) {
|
|
468
547
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -487,11 +566,128 @@ var DropdownContent = function DropdownContent(_ref9) {
|
|
|
487
566
|
}, _callee);
|
|
488
567
|
}));
|
|
489
568
|
return function getReferenceData() {
|
|
490
|
-
return
|
|
569
|
+
return _ref1.apply(this, arguments);
|
|
491
570
|
};
|
|
492
571
|
}();
|
|
493
|
-
getReferenceData();
|
|
572
|
+
void getReferenceData();
|
|
494
573
|
}, [syncBlockStore, intl, isSource, localId, resourceId]);
|
|
574
|
+
return /*#__PURE__*/React.createElement(DropdownContentWithReferenceData, {
|
|
575
|
+
resourceId: resourceId,
|
|
576
|
+
intl: intl,
|
|
577
|
+
api: api,
|
|
578
|
+
fetchStatus: fetchStatus,
|
|
579
|
+
referenceData: referenceData
|
|
580
|
+
});
|
|
581
|
+
};
|
|
582
|
+
var useReferenceData = function useReferenceData(_ref10) {
|
|
583
|
+
var syncBlockStore = _ref10.syncBlockStore,
|
|
584
|
+
resourceId = _ref10.resourceId,
|
|
585
|
+
intl = _ref10.intl,
|
|
586
|
+
isSource = _ref10.isSource,
|
|
587
|
+
localId = _ref10.localId;
|
|
588
|
+
var _useState1 = useState({
|
|
589
|
+
fetchStatus: 'loading',
|
|
590
|
+
referenceData: []
|
|
591
|
+
}),
|
|
592
|
+
_useState10 = _slicedToArray(_useState1, 2),
|
|
593
|
+
state = _useState10[0],
|
|
594
|
+
setState = _useState10[1];
|
|
595
|
+
useEffect(function () {
|
|
596
|
+
var isCurrentRequest = true;
|
|
597
|
+
setState({
|
|
598
|
+
fetchStatus: 'loading',
|
|
599
|
+
referenceData: []
|
|
600
|
+
});
|
|
601
|
+
var getReferenceData = /*#__PURE__*/function () {
|
|
602
|
+
var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
603
|
+
var response;
|
|
604
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
605
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
606
|
+
case 0:
|
|
607
|
+
_context2.next = 1;
|
|
608
|
+
return syncBlockStore.fetchReferencesSourceInfo(resourceId, localId, isSource);
|
|
609
|
+
case 1:
|
|
610
|
+
response = _context2.sent;
|
|
611
|
+
if (isCurrentRequest) {
|
|
612
|
+
_context2.next = 2;
|
|
613
|
+
break;
|
|
614
|
+
}
|
|
615
|
+
return _context2.abrupt("return");
|
|
616
|
+
case 2:
|
|
617
|
+
if (!response.error) {
|
|
618
|
+
_context2.next = 3;
|
|
619
|
+
break;
|
|
620
|
+
}
|
|
621
|
+
setState({
|
|
622
|
+
fetchStatus: 'error',
|
|
623
|
+
referenceData: []
|
|
624
|
+
});
|
|
625
|
+
return _context2.abrupt("return");
|
|
626
|
+
case 3:
|
|
627
|
+
setState({
|
|
628
|
+
fetchStatus: 'success',
|
|
629
|
+
referenceData: processReferenceData(response.references, intl)
|
|
630
|
+
});
|
|
631
|
+
case 4:
|
|
632
|
+
case "end":
|
|
633
|
+
return _context2.stop();
|
|
634
|
+
}
|
|
635
|
+
}, _callee2);
|
|
636
|
+
}));
|
|
637
|
+
return function getReferenceData() {
|
|
638
|
+
return _ref11.apply(this, arguments);
|
|
639
|
+
};
|
|
640
|
+
}();
|
|
641
|
+
void getReferenceData();
|
|
642
|
+
return function () {
|
|
643
|
+
isCurrentRequest = false;
|
|
644
|
+
};
|
|
645
|
+
}, [syncBlockStore, resourceId, intl, isSource, localId]);
|
|
646
|
+
return {
|
|
647
|
+
fetchStatus: state.fetchStatus,
|
|
648
|
+
referenceData: state.referenceData
|
|
649
|
+
};
|
|
650
|
+
};
|
|
651
|
+
var SyncedLocationTriggerContent = function SyncedLocationTriggerContent(_ref12) {
|
|
652
|
+
var intl = _ref12.intl,
|
|
653
|
+
fetchStatus = _ref12.fetchStatus,
|
|
654
|
+
referenceData = _ref12.referenceData;
|
|
655
|
+
var formatMessage = intl.formatMessage;
|
|
656
|
+
var triggerTitle = formatMessage(messages.syncedLocationDropdownTitle);
|
|
657
|
+
var referenceCount = useMemo(function () {
|
|
658
|
+
return referenceData.filter(function (_ref13) {
|
|
659
|
+
var isSource = _ref13.isSource;
|
|
660
|
+
return !isSource;
|
|
661
|
+
}).length;
|
|
662
|
+
}, [referenceData]);
|
|
663
|
+
switch (fetchStatus) {
|
|
664
|
+
case 'loading':
|
|
665
|
+
return /*#__PURE__*/React.createElement(Inline, {
|
|
666
|
+
alignBlock: "center",
|
|
667
|
+
space: "space.050"
|
|
668
|
+
}, triggerTitle, /*#__PURE__*/React.createElement(Spinner, {
|
|
669
|
+
size: "small",
|
|
670
|
+
label: formatMessage(messages.syncedLocationDropdownLoading)
|
|
671
|
+
}));
|
|
672
|
+
case 'success':
|
|
673
|
+
{
|
|
674
|
+
var count = referenceCount === 0 ? formatMessage(messages.syncedLocationDropdownNone) : referenceCount > 99 ? '99+' : intl.formatNumber(referenceCount);
|
|
675
|
+
return formatMessage(messages.syncedLocationDropdownTitleWithCount, {
|
|
676
|
+
count: count
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
case 'none':
|
|
680
|
+
case 'error':
|
|
681
|
+
return triggerTitle;
|
|
682
|
+
}
|
|
683
|
+
};
|
|
684
|
+
var DropdownContentWithReferenceData = function DropdownContentWithReferenceData(_ref14) {
|
|
685
|
+
var resourceId = _ref14.resourceId,
|
|
686
|
+
intl = _ref14.intl,
|
|
687
|
+
api = _ref14.api,
|
|
688
|
+
fetchStatus = _ref14.fetchStatus,
|
|
689
|
+
referenceData = _ref14.referenceData;
|
|
690
|
+
var formatMessage = intl.formatMessage;
|
|
495
691
|
var handleLocationClick = function handleLocationClick() {
|
|
496
692
|
var _api$analytics;
|
|
497
693
|
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || (_api$analytics = _api$analytics.actions) === null || _api$analytics === void 0 || _api$analytics.fireAnalyticsEvent({
|
|
@@ -507,7 +703,9 @@ var DropdownContent = function DropdownContent(_ref9) {
|
|
|
507
703
|
var content = function content() {
|
|
508
704
|
switch (fetchStatus) {
|
|
509
705
|
case 'loading':
|
|
510
|
-
return /*#__PURE__*/React.createElement(LoadingScreen,
|
|
706
|
+
return /*#__PURE__*/React.createElement(LoadingScreen, {
|
|
707
|
+
formatMessage: formatMessage
|
|
708
|
+
});
|
|
511
709
|
case 'error':
|
|
512
710
|
return /*#__PURE__*/React.createElement(ErrorScreen, {
|
|
513
711
|
formatMessage: formatMessage
|
|
@@ -562,11 +760,14 @@ var DropdownContent = function DropdownContent(_ref9) {
|
|
|
562
760
|
xcss: cx(styles.dropdownContent, shouldApplyMinHeight(fetchStatus, referenceData.length) && styles.containerWithMinHeight)
|
|
563
761
|
}, content());
|
|
564
762
|
};
|
|
565
|
-
var LoadingScreen = function LoadingScreen() {
|
|
566
|
-
|
|
763
|
+
var LoadingScreen = function LoadingScreen(_ref15) {
|
|
764
|
+
var formatMessage = _ref15.formatMessage;
|
|
765
|
+
return /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(Spinner, {
|
|
766
|
+
label: formatMessage(messages.syncedLocationDropdownLoading)
|
|
767
|
+
}));
|
|
567
768
|
};
|
|
568
|
-
var ErrorScreen = function ErrorScreen(
|
|
569
|
-
var formatMessage =
|
|
769
|
+
var ErrorScreen = function ErrorScreen(_ref16) {
|
|
770
|
+
var formatMessage = _ref16.formatMessage;
|
|
570
771
|
return /*#__PURE__*/React.createElement(Box, {
|
|
571
772
|
xcss: styles.errorContainer,
|
|
572
773
|
testId: "synced-locations-dropdown-content-error"
|
|
@@ -582,8 +783,8 @@ var ErrorScreen = function ErrorScreen(_ref1) {
|
|
|
582
783
|
size: "medium"
|
|
583
784
|
}, formatMessage(messages.syncedLocationDropdownError)));
|
|
584
785
|
};
|
|
585
|
-
var NoResultScreen = function NoResultScreen(
|
|
586
|
-
var formatMessage =
|
|
786
|
+
var NoResultScreen = function NoResultScreen(_ref17) {
|
|
787
|
+
var formatMessage = _ref17.formatMessage;
|
|
587
788
|
return /*#__PURE__*/React.createElement(Stack, {
|
|
588
789
|
xcss: styles.noResultsContainer,
|
|
589
790
|
space: "space.100",
|
|
@@ -20,7 +20,7 @@ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
|
20
20
|
import { copySyncedBlockReferenceToClipboard, editSyncedBlockSource, removeSyncedBlock, unsync } from '../editor-commands';
|
|
21
21
|
import { findSyncBlockOrBodiedSyncBlock, isBodiedSyncBlockNode } from '../pm-plugins/utils/utils';
|
|
22
22
|
import { SYNCED_BLOCK_BUTTON_TEST_ID } from '../types';
|
|
23
|
-
import { SyncedLocationDropdown } from './SyncedLocationDropdown';
|
|
23
|
+
import { SyncedLocationDropdown, SyncedLocationDropdownWithCount } from './SyncedLocationDropdown';
|
|
24
24
|
export var getToolbarConfig = function getToolbarConfig(state, intl, api, syncBlockStore, isLivePage, onGiveFeedback) {
|
|
25
25
|
var _syncBlockInstance$er, _api$decorations, _api$connectivity;
|
|
26
26
|
var syncBlockObject = findSyncBlockOrBodiedSyncBlock(state.schema, state.selection);
|
|
@@ -87,6 +87,18 @@ export var getToolbarConfig = function getToolbarConfig(state, intl, api, syncBl
|
|
|
87
87
|
type: 'custom',
|
|
88
88
|
fallback: [],
|
|
89
89
|
render: function render(_view, _idx, _dispatchAnalyticsEvent, floatingToolbarRenderContext) {
|
|
90
|
+
if (isSyncBlockActivationEnabled) {
|
|
91
|
+
return /*#__PURE__*/React.createElement(SyncedLocationDropdownWithCount, {
|
|
92
|
+
key: "".concat(resourceId, ":").concat(localId, ":").concat(isBodiedSyncBlock),
|
|
93
|
+
syncBlockStore: syncBlockStore,
|
|
94
|
+
resourceId: resourceId,
|
|
95
|
+
localId: localId,
|
|
96
|
+
intl: intl,
|
|
97
|
+
isSource: isBodiedSyncBlock,
|
|
98
|
+
api: api,
|
|
99
|
+
floatingToolbarRenderContext: floatingToolbarRenderContext
|
|
100
|
+
});
|
|
101
|
+
}
|
|
90
102
|
return /*#__PURE__*/React.createElement(SyncedLocationDropdown, {
|
|
91
103
|
syncBlockStore: syncBlockStore,
|
|
92
104
|
resourceId: resourceId,
|
|
@@ -13,4 +13,5 @@ interface Props {
|
|
|
13
13
|
}
|
|
14
14
|
export declare const processReferenceData: (referenceData: ReferencesSourceInfo["references"], intl: IntlShape) => SyncBlockSourceInfo[];
|
|
15
15
|
export declare const SyncedLocationDropdown: ({ syncBlockStore, resourceId, intl, isSource, localId, api, floatingToolbarRenderContext, }: Props) => JSX.Element;
|
|
16
|
+
export declare const SyncedLocationDropdownWithCount: ({ syncBlockStore, resourceId, intl, isSource, localId, api, floatingToolbarRenderContext, }: Props) => JSX.Element;
|
|
16
17
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-synced-block",
|
|
3
|
-
"version": "10.4.
|
|
3
|
+
"version": "10.4.3",
|
|
4
4
|
"description": "SyncedBlock plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@atlaskit/platform-feature-flags": "^2.1.0",
|
|
47
47
|
"@atlaskit/primitives": "^22.2.0",
|
|
48
48
|
"@atlaskit/spinner": "20.1.1",
|
|
49
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
49
|
+
"@atlaskit/tmp-editor-statsig": "^133.1.0",
|
|
50
50
|
"@atlaskit/tokens": "16.3.0",
|
|
51
51
|
"@atlaskit/tooltip": "^23.1.0",
|
|
52
52
|
"@atlaskit/visually-hidden": "^4.2.0",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"memoize-one": "^6.0.0"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"@atlaskit/editor-common": "^116.
|
|
60
|
+
"@atlaskit/editor-common": "^116.39.0",
|
|
61
61
|
"react": "^18.2.0",
|
|
62
62
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|
|
63
63
|
},
|