@atlaskit/editor-plugin-synced-block 5.1.11 → 5.1.12
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 +8 -0
- package/afm-cc/tsconfig.json +10 -4
- package/afm-jira/tsconfig.json +9 -0
- package/afm-products/tsconfig.json +9 -0
- package/dist/cjs/ui/SyncedLocationDropdown.compiled.css +26 -0
- package/dist/cjs/ui/SyncedLocationDropdown.js +302 -0
- package/dist/cjs/ui/floating-toolbar.js +20 -0
- package/dist/es2019/ui/SyncedLocationDropdown.compiled.css +26 -0
- package/dist/es2019/ui/SyncedLocationDropdown.js +254 -0
- package/dist/es2019/ui/floating-toolbar.js +21 -0
- package/dist/esm/ui/SyncedLocationDropdown.compiled.css +26 -0
- package/dist/esm/ui/SyncedLocationDropdown.js +293 -0
- package/dist/esm/ui/floating-toolbar.js +20 -0
- package/dist/types/ui/SyncedLocationDropdown.d.ts +12 -0
- package/dist/types-ts4.5/ui/SyncedLocationDropdown.d.ts +12 -0
- package/package.json +7 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-synced-block
|
|
2
2
|
|
|
3
|
+
## 5.1.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`f0124a523d8f1`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f0124a523d8f1) -
|
|
8
|
+
[ux] [EDITOR-2845] Implement synced location for source and reference sync block
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
3
11
|
## 5.1.11
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/afm-cc/tsconfig.json
CHANGED
|
@@ -7,10 +7,7 @@
|
|
|
7
7
|
"composite": true,
|
|
8
8
|
"noCheck": true
|
|
9
9
|
},
|
|
10
|
-
"include": [
|
|
11
|
-
"../src/**/*.ts",
|
|
12
|
-
"../src/**/*.tsx"
|
|
13
|
-
],
|
|
10
|
+
"include": ["../src/**/*.ts", "../src/**/*.tsx"],
|
|
14
11
|
"exclude": [
|
|
15
12
|
"../src/**/__tests__/*",
|
|
16
13
|
"../src/**/*.test.*",
|
|
@@ -29,6 +26,9 @@
|
|
|
29
26
|
{
|
|
30
27
|
"path": "../../../design-system/button/afm-cc/tsconfig.json"
|
|
31
28
|
},
|
|
29
|
+
{
|
|
30
|
+
"path": "../../../design-system/dropdown-menu/afm-cc/tsconfig.json"
|
|
31
|
+
},
|
|
32
32
|
{
|
|
33
33
|
"path": "../../editor-json-transformer/afm-cc/tsconfig.json"
|
|
34
34
|
},
|
|
@@ -74,6 +74,9 @@
|
|
|
74
74
|
{
|
|
75
75
|
"path": "../../../design-system/icon-lab/afm-cc/tsconfig.json"
|
|
76
76
|
},
|
|
77
|
+
{
|
|
78
|
+
"path": "../../../design-system/logo/afm-cc/tsconfig.json"
|
|
79
|
+
},
|
|
77
80
|
{
|
|
78
81
|
"path": "../../../design-system/lozenge/afm-cc/tsconfig.json"
|
|
79
82
|
},
|
|
@@ -86,6 +89,9 @@
|
|
|
86
89
|
{
|
|
87
90
|
"path": "../../../design-system/primitives/afm-cc/tsconfig.json"
|
|
88
91
|
},
|
|
92
|
+
{
|
|
93
|
+
"path": "../../../design-system/spinner/afm-cc/tsconfig.json"
|
|
94
|
+
},
|
|
89
95
|
{
|
|
90
96
|
"path": "../../tmp-editor-statsig/afm-cc/tsconfig.json"
|
|
91
97
|
},
|
package/afm-jira/tsconfig.json
CHANGED
|
@@ -29,6 +29,9 @@
|
|
|
29
29
|
{
|
|
30
30
|
"path": "../../../design-system/button/afm-jira/tsconfig.json"
|
|
31
31
|
},
|
|
32
|
+
{
|
|
33
|
+
"path": "../../../design-system/dropdown-menu/afm-jira/tsconfig.json"
|
|
34
|
+
},
|
|
32
35
|
{
|
|
33
36
|
"path": "../../editor-json-transformer/afm-jira/tsconfig.json"
|
|
34
37
|
},
|
|
@@ -74,6 +77,9 @@
|
|
|
74
77
|
{
|
|
75
78
|
"path": "../../../design-system/icon-lab/afm-jira/tsconfig.json"
|
|
76
79
|
},
|
|
80
|
+
{
|
|
81
|
+
"path": "../../../design-system/logo/afm-jira/tsconfig.json"
|
|
82
|
+
},
|
|
77
83
|
{
|
|
78
84
|
"path": "../../../design-system/lozenge/afm-jira/tsconfig.json"
|
|
79
85
|
},
|
|
@@ -86,6 +92,9 @@
|
|
|
86
92
|
{
|
|
87
93
|
"path": "../../../design-system/primitives/afm-jira/tsconfig.json"
|
|
88
94
|
},
|
|
95
|
+
{
|
|
96
|
+
"path": "../../../design-system/spinner/afm-jira/tsconfig.json"
|
|
97
|
+
},
|
|
89
98
|
{
|
|
90
99
|
"path": "../../tmp-editor-statsig/afm-jira/tsconfig.json"
|
|
91
100
|
},
|
|
@@ -29,6 +29,9 @@
|
|
|
29
29
|
{
|
|
30
30
|
"path": "../../../design-system/button/afm-products/tsconfig.json"
|
|
31
31
|
},
|
|
32
|
+
{
|
|
33
|
+
"path": "../../../design-system/dropdown-menu/afm-products/tsconfig.json"
|
|
34
|
+
},
|
|
32
35
|
{
|
|
33
36
|
"path": "../../editor-json-transformer/afm-products/tsconfig.json"
|
|
34
37
|
},
|
|
@@ -74,6 +77,9 @@
|
|
|
74
77
|
{
|
|
75
78
|
"path": "../../../design-system/icon-lab/afm-products/tsconfig.json"
|
|
76
79
|
},
|
|
80
|
+
{
|
|
81
|
+
"path": "../../../design-system/logo/afm-products/tsconfig.json"
|
|
82
|
+
},
|
|
77
83
|
{
|
|
78
84
|
"path": "../../../design-system/lozenge/afm-products/tsconfig.json"
|
|
79
85
|
},
|
|
@@ -86,6 +92,9 @@
|
|
|
86
92
|
{
|
|
87
93
|
"path": "../../../design-system/primitives/afm-products/tsconfig.json"
|
|
88
94
|
},
|
|
95
|
+
{
|
|
96
|
+
"path": "../../../design-system/spinner/afm-products/tsconfig.json"
|
|
97
|
+
},
|
|
89
98
|
{
|
|
90
99
|
"path": "../../tmp-editor-statsig/afm-products/tsconfig.json"
|
|
91
100
|
},
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
|
|
2
|
+
._1mour5cr{margin-block:var(--ds-space-negative-050,-4px)}
|
|
3
|
+
._1rjcv77o{padding-block:var(--ds-space-025,2px)}
|
|
4
|
+
._ku9g126e [data-ds--menu--heading-item]{margin-block:var(--ds-space-050,4px)!important}._18bk1rpy [data-ds--menu--heading-item]{color:var(--ds-text-subtlest,#6b6e76)}
|
|
5
|
+
._18m915vq{overflow-y:hidden}
|
|
6
|
+
._18m91wug{overflow-y:auto}
|
|
7
|
+
._1bah1h6o{justify-content:center}
|
|
8
|
+
._1bsb1osq{width:100%}
|
|
9
|
+
._1bsb96ou{width:327px}
|
|
10
|
+
._1bsbo8uj{width:235px}
|
|
11
|
+
._1bto1l2s{text-overflow:ellipsis}
|
|
12
|
+
._1e0c1txw{display:flex}
|
|
13
|
+
._1hmsglyw{text-decoration-line:none}
|
|
14
|
+
._1reo15vq{overflow-x:hidden}
|
|
15
|
+
._1tkeqkoa{min-height:9pc}
|
|
16
|
+
._1ul91wqb{min-width:60px}
|
|
17
|
+
._1wpz1fhb{align-self:stretch}
|
|
18
|
+
._4bfu1r31{text-decoration-color:currentColor}
|
|
19
|
+
._4cvr1h6o{align-items:center}
|
|
20
|
+
._ahbq1b66{margin-inline-start:var(--ds-space-050,4px)}
|
|
21
|
+
._ajmmnqa1{text-decoration-style:solid}
|
|
22
|
+
._c71lko4j{max-height:19pc}
|
|
23
|
+
._o5721q9c{white-space:nowrap}
|
|
24
|
+
._syaz1rpy{color:var(--ds-text-subtlest,#6b6e76)}
|
|
25
|
+
._syazazsu{color:var(--ds-text-subtle,#505258)}
|
|
26
|
+
._y3gn1h6o{text-align:center}
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
/* SyncedLocationDropdown.tsx generated by @compiled/babel-plugin v0.38.1 */
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
exports.processReferenceData = exports.SyncedLocationDropdown = void 0;
|
|
10
|
+
require("./SyncedLocationDropdown.compiled.css");
|
|
11
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
12
|
+
var React = _react;
|
|
13
|
+
var _runtime = require("@compiled/react/runtime");
|
|
14
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
15
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
16
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
17
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
18
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
19
|
+
var _dropdownMenu = _interopRequireWildcard(require("@atlaskit/dropdown-menu"));
|
|
20
|
+
var _messages = require("@atlaskit/editor-common/messages");
|
|
21
|
+
var _ui = require("@atlaskit/editor-common/ui");
|
|
22
|
+
var _icon = require("@atlaskit/icon");
|
|
23
|
+
var _pageLiveDoc = _interopRequireDefault(require("@atlaskit/icon-lab/core/page-live-doc"));
|
|
24
|
+
var _chevronDown = _interopRequireDefault(require("@atlaskit/icon/core/chevron-down"));
|
|
25
|
+
var _page = _interopRequireDefault(require("@atlaskit/icon/core/page"));
|
|
26
|
+
var _statusError = _interopRequireDefault(require("@atlaskit/icon/core/status-error"));
|
|
27
|
+
var _logo = require("@atlaskit/logo");
|
|
28
|
+
var _lozenge = _interopRequireDefault(require("@atlaskit/lozenge"));
|
|
29
|
+
var _compiled = require("@atlaskit/primitives/compiled");
|
|
30
|
+
var _spinner = _interopRequireDefault(require("@atlaskit/spinner"));
|
|
31
|
+
var _excluded = ["triggerRef"];
|
|
32
|
+
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); }
|
|
33
|
+
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; } } }; }
|
|
34
|
+
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; } }
|
|
35
|
+
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; }
|
|
36
|
+
var headingStyles = null;
|
|
37
|
+
var styles = {
|
|
38
|
+
title: "_1reo15vq _18m915vq _syazazsu _1bto1l2s _o5721q9c",
|
|
39
|
+
note: "_syaz1rpy _o5721q9c",
|
|
40
|
+
lozenge: "_ahbq1b66 _1ul91wqb",
|
|
41
|
+
noResultsContainer: "_1bsbo8uj _y3gn1h6o",
|
|
42
|
+
dropdownContent: "_1rjcv77o _1bsb96ou _1tkeqkoa _c71lko4j _1e0c1txw _1bah1h6o _4cvr1h6o",
|
|
43
|
+
contentContainer: "_1bsb1osq _1wpz1fhb _18m91wug",
|
|
44
|
+
errorContainer: "_1bsbo8uj _1e0c1txw",
|
|
45
|
+
errorIcon: "_1mour5cr",
|
|
46
|
+
learnMoreLink: "_4bfu1r31 _1hmsglyw _ajmmnqa1"
|
|
47
|
+
};
|
|
48
|
+
var ItemTitle = function ItemTitle(_ref) {
|
|
49
|
+
var title = _ref.title,
|
|
50
|
+
formatMessage = _ref.formatMessage,
|
|
51
|
+
onSamePage = _ref.onSamePage,
|
|
52
|
+
isSource = _ref.isSource;
|
|
53
|
+
return /*#__PURE__*/React.createElement(_compiled.Inline, null, /*#__PURE__*/React.createElement(_compiled.Box, {
|
|
54
|
+
as: "span",
|
|
55
|
+
xcss: styles.title
|
|
56
|
+
}, title), onSamePage && /*#__PURE__*/React.createElement(_compiled.Box, {
|
|
57
|
+
as: "span",
|
|
58
|
+
xcss: styles.note
|
|
59
|
+
}, "\xA0- ", formatMessage(_messages.syncBlockMessages.syncedLocationDropdownTitleNote)), isSource && /*#__PURE__*/React.createElement(_compiled.Box, {
|
|
60
|
+
as: "span",
|
|
61
|
+
xcss: styles.lozenge
|
|
62
|
+
}, /*#__PURE__*/React.createElement(_lozenge.default, null, formatMessage(_messages.syncBlockMessages.syncedLocationDropdownSourceLozenge))));
|
|
63
|
+
};
|
|
64
|
+
var Logo = function Logo(_ref2) {
|
|
65
|
+
var product = _ref2.product;
|
|
66
|
+
switch (product) {
|
|
67
|
+
case 'confluence-page':
|
|
68
|
+
return /*#__PURE__*/React.createElement(_logo.ConfluenceIcon, {
|
|
69
|
+
size: "xsmall"
|
|
70
|
+
});
|
|
71
|
+
case 'jira-work-item':
|
|
72
|
+
return /*#__PURE__*/React.createElement(_logo.JiraIcon, {
|
|
73
|
+
size: "xsmall"
|
|
74
|
+
});
|
|
75
|
+
default:
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
var ItemIcon = function ItemIcon(_ref3) {
|
|
80
|
+
var reference = _ref3.reference;
|
|
81
|
+
var hasAccess = reference.hasAccess,
|
|
82
|
+
subType = reference.subType;
|
|
83
|
+
var icon = hasAccess ? subType ? _pageLiveDoc.default : _page.default : function () {
|
|
84
|
+
return /*#__PURE__*/React.createElement(Logo, {
|
|
85
|
+
product: reference.productType
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
return /*#__PURE__*/React.createElement(_icon.IconTile, {
|
|
89
|
+
icon: icon,
|
|
90
|
+
label: "",
|
|
91
|
+
appearance: hasAccess ? 'grayBold' : 'gray',
|
|
92
|
+
size: "xsmall"
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
var processReferenceData = exports.processReferenceData = function processReferenceData(referenceData, intl) {
|
|
96
|
+
var formatMessage = intl.formatMessage;
|
|
97
|
+
var sourceInfoMap = new Map();
|
|
98
|
+
referenceData === null || referenceData === void 0 || referenceData.forEach(function (reference) {
|
|
99
|
+
if (!reference) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (sourceInfoMap.has(reference.sourceAri)) {
|
|
103
|
+
var _sourceInfoMap$get;
|
|
104
|
+
(_sourceInfoMap$get = sourceInfoMap.get(reference.sourceAri)) === null || _sourceInfoMap$get === void 0 || _sourceInfoMap$get.push(reference);
|
|
105
|
+
} else {
|
|
106
|
+
sourceInfoMap.set(reference.sourceAri, [reference]);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
var _iterator = _createForOfIteratorHelper(sourceInfoMap.values()),
|
|
110
|
+
_step;
|
|
111
|
+
try {
|
|
112
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
113
|
+
var references = _step.value;
|
|
114
|
+
if (references.length > 1) {
|
|
115
|
+
references.forEach(function (reference, index) {
|
|
116
|
+
return reference.title = "".concat(reference.title, ": ").concat(formatMessage(_messages.syncBlockMessages.syncedLocationDropdownTitleBlockIndex, {
|
|
117
|
+
index: index + 1
|
|
118
|
+
}));
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
} catch (err) {
|
|
123
|
+
_iterator.e(err);
|
|
124
|
+
} finally {
|
|
125
|
+
_iterator.f();
|
|
126
|
+
}
|
|
127
|
+
var sortedReferences = Array.from(sourceInfoMap.values()).flat().sort(function (a, b) {
|
|
128
|
+
if (a.isSource !== b.isSource) {
|
|
129
|
+
return b.isSource ? 1 : -1;
|
|
130
|
+
}
|
|
131
|
+
if (a.hasAccess !== b.hasAccess) {
|
|
132
|
+
return a.hasAccess ? -1 : 1;
|
|
133
|
+
}
|
|
134
|
+
return (a.title || '').localeCompare(b.title || '');
|
|
135
|
+
});
|
|
136
|
+
return sortedReferences;
|
|
137
|
+
};
|
|
138
|
+
var SyncedLocationDropdown = exports.SyncedLocationDropdown = function SyncedLocationDropdown(_ref4) {
|
|
139
|
+
var syncBlockStore = _ref4.syncBlockStore,
|
|
140
|
+
resourceId = _ref4.resourceId,
|
|
141
|
+
intl = _ref4.intl,
|
|
142
|
+
isSource = _ref4.isSource,
|
|
143
|
+
localId = _ref4.localId;
|
|
144
|
+
var formatMessage = intl.formatMessage;
|
|
145
|
+
var triggerTitle = formatMessage(_messages.syncBlockMessages.syncedLocationDropdownTitle);
|
|
146
|
+
var _useState = (0, _react.useState)(false),
|
|
147
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
148
|
+
isOpen = _useState2[0],
|
|
149
|
+
setIsOpen = _useState2[1];
|
|
150
|
+
return /*#__PURE__*/React.createElement(_dropdownMenu.default, {
|
|
151
|
+
isOpen: isOpen,
|
|
152
|
+
onOpenChange: function onOpenChange(_ref5) {
|
|
153
|
+
var isOpen = _ref5.isOpen;
|
|
154
|
+
return setIsOpen(isOpen);
|
|
155
|
+
},
|
|
156
|
+
trigger: function trigger(_ref6) {
|
|
157
|
+
var triggerRef = _ref6.triggerRef,
|
|
158
|
+
triggerProps = (0, _objectWithoutProperties2.default)(_ref6, _excluded);
|
|
159
|
+
return /*#__PURE__*/React.createElement(_ui.FloatingToolbarButton, (0, _extends2.default)({
|
|
160
|
+
ref: triggerRef,
|
|
161
|
+
areAnyNewToolbarFlagsEnabled: true,
|
|
162
|
+
iconAfter: /*#__PURE__*/React.createElement(_chevronDown.default, {
|
|
163
|
+
color: "currentColor",
|
|
164
|
+
spacing: "spacious",
|
|
165
|
+
label: "",
|
|
166
|
+
size: "small"
|
|
167
|
+
})
|
|
168
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
169
|
+
}, triggerProps), triggerTitle);
|
|
170
|
+
}
|
|
171
|
+
}, isOpen && /*#__PURE__*/React.createElement(DropdownContent, {
|
|
172
|
+
syncBlockStore: syncBlockStore,
|
|
173
|
+
resourceId: resourceId,
|
|
174
|
+
intl: intl,
|
|
175
|
+
isSource: isSource,
|
|
176
|
+
localId: localId
|
|
177
|
+
}));
|
|
178
|
+
};
|
|
179
|
+
var DropdownContent = function DropdownContent(_ref7) {
|
|
180
|
+
var syncBlockStore = _ref7.syncBlockStore,
|
|
181
|
+
resourceId = _ref7.resourceId,
|
|
182
|
+
intl = _ref7.intl,
|
|
183
|
+
isSource = _ref7.isSource,
|
|
184
|
+
localId = _ref7.localId;
|
|
185
|
+
var formatMessage = intl.formatMessage;
|
|
186
|
+
var _useState3 = (0, _react.useState)('none'),
|
|
187
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
188
|
+
fetchStatus = _useState4[0],
|
|
189
|
+
setFetchStatus = _useState4[1];
|
|
190
|
+
var _useState5 = (0, _react.useState)([]),
|
|
191
|
+
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
192
|
+
referenceData = _useState6[0],
|
|
193
|
+
setReferenceData = _useState6[1];
|
|
194
|
+
(0, _react.useEffect)(function () {
|
|
195
|
+
setFetchStatus('loading');
|
|
196
|
+
var getReferenceData = /*#__PURE__*/function () {
|
|
197
|
+
var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
198
|
+
var response;
|
|
199
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
200
|
+
while (1) switch (_context.prev = _context.next) {
|
|
201
|
+
case 0:
|
|
202
|
+
_context.next = 2;
|
|
203
|
+
return syncBlockStore.fetchReferencesSourceInfo(resourceId, localId, isSource);
|
|
204
|
+
case 2:
|
|
205
|
+
response = _context.sent;
|
|
206
|
+
if (!response.error) {
|
|
207
|
+
_context.next = 6;
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
setFetchStatus('error');
|
|
211
|
+
return _context.abrupt("return");
|
|
212
|
+
case 6:
|
|
213
|
+
setReferenceData(processReferenceData(response.references, intl));
|
|
214
|
+
setFetchStatus('success');
|
|
215
|
+
case 8:
|
|
216
|
+
case "end":
|
|
217
|
+
return _context.stop();
|
|
218
|
+
}
|
|
219
|
+
}, _callee);
|
|
220
|
+
}));
|
|
221
|
+
return function getReferenceData() {
|
|
222
|
+
return _ref8.apply(this, arguments);
|
|
223
|
+
};
|
|
224
|
+
}();
|
|
225
|
+
getReferenceData();
|
|
226
|
+
}, [syncBlockStore, intl, isSource, localId, resourceId]);
|
|
227
|
+
var content = function content() {
|
|
228
|
+
switch (fetchStatus) {
|
|
229
|
+
case 'loading':
|
|
230
|
+
return /*#__PURE__*/React.createElement(LoadingScreen, null);
|
|
231
|
+
case 'error':
|
|
232
|
+
return /*#__PURE__*/React.createElement(ErrorScreen, {
|
|
233
|
+
formatMessage: formatMessage
|
|
234
|
+
});
|
|
235
|
+
case 'success':
|
|
236
|
+
if (referenceData.length > 0) {
|
|
237
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
238
|
+
"data-testid": "synced-locations-dropdown-content",
|
|
239
|
+
className: (0, _runtime.ax)([styles.contentContainer, "_ku9g126e _18bk1rpy"])
|
|
240
|
+
}, /*#__PURE__*/React.createElement(_dropdownMenu.DropdownItemGroup, {
|
|
241
|
+
title: formatMessage(_messages.syncBlockMessages.syncedLocationDropdownHeading, {
|
|
242
|
+
count: "".concat(referenceData.length > 99 ? '99+' : referenceData.length)
|
|
243
|
+
})
|
|
244
|
+
}, referenceData.map(function (reference) {
|
|
245
|
+
return /*#__PURE__*/React.createElement(_dropdownMenu.DropdownItem, {
|
|
246
|
+
elemBefore: /*#__PURE__*/React.createElement(ItemIcon, {
|
|
247
|
+
reference: reference
|
|
248
|
+
}),
|
|
249
|
+
href: reference.url,
|
|
250
|
+
key: reference.title
|
|
251
|
+
}, /*#__PURE__*/React.createElement(ItemTitle, {
|
|
252
|
+
title: reference.title || reference.url || '',
|
|
253
|
+
formatMessage: formatMessage,
|
|
254
|
+
onSamePage: reference.onSamePage,
|
|
255
|
+
isSource: reference.isSource
|
|
256
|
+
}));
|
|
257
|
+
})));
|
|
258
|
+
} else {
|
|
259
|
+
return /*#__PURE__*/React.createElement(NoResultScreen, {
|
|
260
|
+
formatMessage: formatMessage
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
return /*#__PURE__*/React.createElement(_compiled.Box, {
|
|
266
|
+
xcss: styles.dropdownContent
|
|
267
|
+
}, content());
|
|
268
|
+
};
|
|
269
|
+
var LoadingScreen = function LoadingScreen() {
|
|
270
|
+
return /*#__PURE__*/React.createElement(_compiled.Box, null, /*#__PURE__*/React.createElement(_spinner.default, null));
|
|
271
|
+
};
|
|
272
|
+
var ErrorScreen = function ErrorScreen(_ref9) {
|
|
273
|
+
var formatMessage = _ref9.formatMessage;
|
|
274
|
+
return /*#__PURE__*/React.createElement(_compiled.Box, {
|
|
275
|
+
xcss: styles.errorContainer
|
|
276
|
+
}, /*#__PURE__*/React.createElement(_compiled.Box, {
|
|
277
|
+
xcss: styles.errorIcon
|
|
278
|
+
}, /*#__PURE__*/React.createElement(_statusError.default, {
|
|
279
|
+
color: "var(--ds-icon-danger, #C9372C)",
|
|
280
|
+
spacing: "spacious",
|
|
281
|
+
label: "",
|
|
282
|
+
size: "small"
|
|
283
|
+
})), /*#__PURE__*/React.createElement(_compiled.Text, {
|
|
284
|
+
as: "p",
|
|
285
|
+
size: "medium"
|
|
286
|
+
}, formatMessage(_messages.syncBlockMessages.syncedLocationDropdownError)));
|
|
287
|
+
};
|
|
288
|
+
var NoResultScreen = function NoResultScreen(_ref0) {
|
|
289
|
+
var formatMessage = _ref0.formatMessage;
|
|
290
|
+
return /*#__PURE__*/React.createElement(_compiled.Stack, {
|
|
291
|
+
xcss: styles.noResultsContainer,
|
|
292
|
+
space: "space.100"
|
|
293
|
+
}, /*#__PURE__*/React.createElement(_compiled.Text, {
|
|
294
|
+
as: "p"
|
|
295
|
+
}, formatMessage(_messages.syncBlockMessages.syncedLocationDropdownNoResults)), /*#__PURE__*/React.createElement(_compiled.Text, {
|
|
296
|
+
as: "p"
|
|
297
|
+
}, /*#__PURE__*/React.createElement(_compiled.Anchor, {
|
|
298
|
+
href: "https://hello.atlassian.net/wiki/x/tAtCeAE",
|
|
299
|
+
target: "_blank",
|
|
300
|
+
xcss: styles.learnMoreLink
|
|
301
|
+
}, formatMessage(_messages.syncBlockMessages.syncedLocationDropdownLearnMoreLink))));
|
|
302
|
+
};
|
|
@@ -18,6 +18,7 @@ var _edit = _interopRequireDefault(require("@atlaskit/icon/core/edit"));
|
|
|
18
18
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
19
19
|
var _editorCommands = require("../editor-commands");
|
|
20
20
|
var _utils2 = require("../pm-plugins/utils/utils");
|
|
21
|
+
var _SyncedLocationDropdown = require("./SyncedLocationDropdown");
|
|
21
22
|
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); }
|
|
22
23
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
23
24
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -31,6 +32,9 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(stat
|
|
|
31
32
|
var isUnsyncedBlock = (syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.error) === _editorSyncedBlockProvider.SyncBlockError.NotFound;
|
|
32
33
|
var bodiedSyncBlock = state.schema.nodes.bodiedSyncBlock;
|
|
33
34
|
var isBodiedSyncBlock = (0, _utils2.isBodiedSyncBlockNode)(syncBlockObject.node, bodiedSyncBlock);
|
|
35
|
+
var _syncBlockObject$node = syncBlockObject.node.attrs,
|
|
36
|
+
resourceId = _syncBlockObject$node.resourceId,
|
|
37
|
+
localId = _syncBlockObject$node.localId;
|
|
34
38
|
var formatMessage = intl.formatMessage;
|
|
35
39
|
var nodeType = syncBlockObject.node.type;
|
|
36
40
|
var hoverDecoration = api === null || api === void 0 || (_api$decorations = api.decorations) === null || _api$decorations === void 0 ? void 0 : _api$decorations.actions.hoverDecoration;
|
|
@@ -53,6 +57,22 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(stat
|
|
|
53
57
|
}, hoverDecorationProps(nodeType, _consts.akEditorSelectedNodeClassName));
|
|
54
58
|
items.push(deleteButton);
|
|
55
59
|
} else {
|
|
60
|
+
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
61
|
+
var syncedLocation = {
|
|
62
|
+
type: 'custom',
|
|
63
|
+
fallback: [],
|
|
64
|
+
render: function render() {
|
|
65
|
+
return /*#__PURE__*/_react.default.createElement(_SyncedLocationDropdown.SyncedLocationDropdown, {
|
|
66
|
+
syncBlockStore: syncBlockStore,
|
|
67
|
+
resourceId: resourceId,
|
|
68
|
+
localId: localId,
|
|
69
|
+
intl: intl,
|
|
70
|
+
isSource: isBodiedSyncBlock
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
items.push(syncedLocation);
|
|
75
|
+
}
|
|
56
76
|
var copyButton = _objectSpread({
|
|
57
77
|
id: 'editor.syncedBlock.copy',
|
|
58
78
|
type: 'button',
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
|
|
2
|
+
._1mour5cr{margin-block:var(--ds-space-negative-050,-4px)}
|
|
3
|
+
._1rjcv77o{padding-block:var(--ds-space-025,2px)}
|
|
4
|
+
._ku9g126e [data-ds--menu--heading-item]{margin-block:var(--ds-space-050,4px)!important}._18bk1rpy [data-ds--menu--heading-item]{color:var(--ds-text-subtlest,#6b6e76)}
|
|
5
|
+
._18m915vq{overflow-y:hidden}
|
|
6
|
+
._18m91wug{overflow-y:auto}
|
|
7
|
+
._1bah1h6o{justify-content:center}
|
|
8
|
+
._1bsb1osq{width:100%}
|
|
9
|
+
._1bsb96ou{width:327px}
|
|
10
|
+
._1bsbo8uj{width:235px}
|
|
11
|
+
._1bto1l2s{text-overflow:ellipsis}
|
|
12
|
+
._1e0c1txw{display:flex}
|
|
13
|
+
._1hmsglyw{text-decoration-line:none}
|
|
14
|
+
._1reo15vq{overflow-x:hidden}
|
|
15
|
+
._1tkeqkoa{min-height:9pc}
|
|
16
|
+
._1ul91wqb{min-width:60px}
|
|
17
|
+
._1wpz1fhb{align-self:stretch}
|
|
18
|
+
._4bfu1r31{text-decoration-color:currentColor}
|
|
19
|
+
._4cvr1h6o{align-items:center}
|
|
20
|
+
._ahbq1b66{margin-inline-start:var(--ds-space-050,4px)}
|
|
21
|
+
._ajmmnqa1{text-decoration-style:solid}
|
|
22
|
+
._c71lko4j{max-height:19pc}
|
|
23
|
+
._o5721q9c{white-space:nowrap}
|
|
24
|
+
._syaz1rpy{color:var(--ds-text-subtlest,#6b6e76)}
|
|
25
|
+
._syazazsu{color:var(--ds-text-subtle,#505258)}
|
|
26
|
+
._y3gn1h6o{text-align:center}
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
/* SyncedLocationDropdown.tsx generated by @compiled/babel-plugin v0.38.1 */
|
|
2
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
3
|
+
import "./SyncedLocationDropdown.compiled.css";
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
6
|
+
import { useState, useEffect } from 'react';
|
|
7
|
+
import DropdownMenu, { DropdownItem, DropdownItemGroup } from '@atlaskit/dropdown-menu';
|
|
8
|
+
import { syncBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
9
|
+
import { FloatingToolbarButton as Button } from '@atlaskit/editor-common/ui';
|
|
10
|
+
import { IconTile } from '@atlaskit/icon';
|
|
11
|
+
import PageLiveDocIcon from '@atlaskit/icon-lab/core/page-live-doc';
|
|
12
|
+
import ChevronDownIcon from '@atlaskit/icon/core/chevron-down';
|
|
13
|
+
import PageIcon from '@atlaskit/icon/core/page';
|
|
14
|
+
import StatusErrorIcon from '@atlaskit/icon/core/status-error';
|
|
15
|
+
import { ConfluenceIcon, JiraIcon } from '@atlaskit/logo';
|
|
16
|
+
import Lozenge from '@atlaskit/lozenge';
|
|
17
|
+
import { Box, Text, Inline, Anchor, Stack } from '@atlaskit/primitives/compiled';
|
|
18
|
+
import Spinner from '@atlaskit/spinner';
|
|
19
|
+
const headingStyles = null;
|
|
20
|
+
const styles = {
|
|
21
|
+
title: "_1reo15vq _18m915vq _syazazsu _1bto1l2s _o5721q9c",
|
|
22
|
+
note: "_syaz1rpy _o5721q9c",
|
|
23
|
+
lozenge: "_ahbq1b66 _1ul91wqb",
|
|
24
|
+
noResultsContainer: "_1bsbo8uj _y3gn1h6o",
|
|
25
|
+
dropdownContent: "_1rjcv77o _1bsb96ou _1tkeqkoa _c71lko4j _1e0c1txw _1bah1h6o _4cvr1h6o",
|
|
26
|
+
contentContainer: "_1bsb1osq _1wpz1fhb _18m91wug",
|
|
27
|
+
errorContainer: "_1bsbo8uj _1e0c1txw",
|
|
28
|
+
errorIcon: "_1mour5cr",
|
|
29
|
+
learnMoreLink: "_4bfu1r31 _1hmsglyw _ajmmnqa1"
|
|
30
|
+
};
|
|
31
|
+
const ItemTitle = ({
|
|
32
|
+
title,
|
|
33
|
+
formatMessage,
|
|
34
|
+
onSamePage,
|
|
35
|
+
isSource
|
|
36
|
+
}) => {
|
|
37
|
+
return /*#__PURE__*/React.createElement(Inline, null, /*#__PURE__*/React.createElement(Box, {
|
|
38
|
+
as: "span",
|
|
39
|
+
xcss: styles.title
|
|
40
|
+
}, title), onSamePage && /*#__PURE__*/React.createElement(Box, {
|
|
41
|
+
as: "span",
|
|
42
|
+
xcss: styles.note
|
|
43
|
+
}, "\xA0- ", formatMessage(messages.syncedLocationDropdownTitleNote)), isSource && /*#__PURE__*/React.createElement(Box, {
|
|
44
|
+
as: "span",
|
|
45
|
+
xcss: styles.lozenge
|
|
46
|
+
}, /*#__PURE__*/React.createElement(Lozenge, null, formatMessage(messages.syncedLocationDropdownSourceLozenge))));
|
|
47
|
+
};
|
|
48
|
+
const Logo = ({
|
|
49
|
+
product
|
|
50
|
+
}) => {
|
|
51
|
+
switch (product) {
|
|
52
|
+
case 'confluence-page':
|
|
53
|
+
return /*#__PURE__*/React.createElement(ConfluenceIcon, {
|
|
54
|
+
size: "xsmall"
|
|
55
|
+
});
|
|
56
|
+
case 'jira-work-item':
|
|
57
|
+
return /*#__PURE__*/React.createElement(JiraIcon, {
|
|
58
|
+
size: "xsmall"
|
|
59
|
+
});
|
|
60
|
+
default:
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const ItemIcon = ({
|
|
65
|
+
reference
|
|
66
|
+
}) => {
|
|
67
|
+
const {
|
|
68
|
+
hasAccess,
|
|
69
|
+
subType
|
|
70
|
+
} = reference;
|
|
71
|
+
const icon = hasAccess ? subType ? PageLiveDocIcon : PageIcon : () => /*#__PURE__*/React.createElement(Logo, {
|
|
72
|
+
product: reference.productType
|
|
73
|
+
});
|
|
74
|
+
return /*#__PURE__*/React.createElement(IconTile, {
|
|
75
|
+
icon: icon,
|
|
76
|
+
label: "",
|
|
77
|
+
appearance: hasAccess ? 'grayBold' : 'gray',
|
|
78
|
+
size: "xsmall"
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
export const processReferenceData = (referenceData, intl) => {
|
|
82
|
+
const {
|
|
83
|
+
formatMessage
|
|
84
|
+
} = intl;
|
|
85
|
+
const sourceInfoMap = new Map();
|
|
86
|
+
referenceData === null || referenceData === void 0 ? void 0 : referenceData.forEach(reference => {
|
|
87
|
+
if (!reference) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (sourceInfoMap.has(reference.sourceAri)) {
|
|
91
|
+
var _sourceInfoMap$get;
|
|
92
|
+
(_sourceInfoMap$get = sourceInfoMap.get(reference.sourceAri)) === null || _sourceInfoMap$get === void 0 ? void 0 : _sourceInfoMap$get.push(reference);
|
|
93
|
+
} else {
|
|
94
|
+
sourceInfoMap.set(reference.sourceAri, [reference]);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
for (const references of sourceInfoMap.values()) {
|
|
98
|
+
if (references.length > 1) {
|
|
99
|
+
references.forEach((reference, index) => reference.title = `${reference.title}: ${formatMessage(messages.syncedLocationDropdownTitleBlockIndex, {
|
|
100
|
+
index: index + 1
|
|
101
|
+
})}`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
const sortedReferences = Array.from(sourceInfoMap.values()).flat().sort((a, b) => {
|
|
105
|
+
if (a.isSource !== b.isSource) {
|
|
106
|
+
return b.isSource ? 1 : -1;
|
|
107
|
+
}
|
|
108
|
+
if (a.hasAccess !== b.hasAccess) {
|
|
109
|
+
return a.hasAccess ? -1 : 1;
|
|
110
|
+
}
|
|
111
|
+
return (a.title || '').localeCompare(b.title || '');
|
|
112
|
+
});
|
|
113
|
+
return sortedReferences;
|
|
114
|
+
};
|
|
115
|
+
export const SyncedLocationDropdown = ({
|
|
116
|
+
syncBlockStore,
|
|
117
|
+
resourceId,
|
|
118
|
+
intl,
|
|
119
|
+
isSource,
|
|
120
|
+
localId
|
|
121
|
+
}) => {
|
|
122
|
+
const {
|
|
123
|
+
formatMessage
|
|
124
|
+
} = intl;
|
|
125
|
+
const triggerTitle = formatMessage(messages.syncedLocationDropdownTitle);
|
|
126
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
127
|
+
return /*#__PURE__*/React.createElement(DropdownMenu, {
|
|
128
|
+
isOpen: isOpen,
|
|
129
|
+
onOpenChange: ({
|
|
130
|
+
isOpen
|
|
131
|
+
}) => setIsOpen(isOpen),
|
|
132
|
+
trigger: ({
|
|
133
|
+
triggerRef,
|
|
134
|
+
...triggerProps
|
|
135
|
+
}) => /*#__PURE__*/React.createElement(Button, _extends({
|
|
136
|
+
ref: triggerRef,
|
|
137
|
+
areAnyNewToolbarFlagsEnabled: true,
|
|
138
|
+
iconAfter: /*#__PURE__*/React.createElement(ChevronDownIcon, {
|
|
139
|
+
color: "currentColor",
|
|
140
|
+
spacing: "spacious",
|
|
141
|
+
label: "",
|
|
142
|
+
size: "small"
|
|
143
|
+
})
|
|
144
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
145
|
+
}, triggerProps), triggerTitle)
|
|
146
|
+
}, isOpen && /*#__PURE__*/React.createElement(DropdownContent, {
|
|
147
|
+
syncBlockStore: syncBlockStore,
|
|
148
|
+
resourceId: resourceId,
|
|
149
|
+
intl: intl,
|
|
150
|
+
isSource: isSource,
|
|
151
|
+
localId: localId
|
|
152
|
+
}));
|
|
153
|
+
};
|
|
154
|
+
const DropdownContent = ({
|
|
155
|
+
syncBlockStore,
|
|
156
|
+
resourceId,
|
|
157
|
+
intl,
|
|
158
|
+
isSource,
|
|
159
|
+
localId
|
|
160
|
+
}) => {
|
|
161
|
+
const {
|
|
162
|
+
formatMessage
|
|
163
|
+
} = intl;
|
|
164
|
+
const [fetchStatus, setFetchStatus] = useState('none');
|
|
165
|
+
const [referenceData, setReferenceData] = useState([]);
|
|
166
|
+
useEffect(() => {
|
|
167
|
+
setFetchStatus('loading');
|
|
168
|
+
const getReferenceData = async () => {
|
|
169
|
+
const response = await syncBlockStore.fetchReferencesSourceInfo(resourceId, localId, isSource);
|
|
170
|
+
if (response.error) {
|
|
171
|
+
setFetchStatus('error');
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
setReferenceData(processReferenceData(response.references, intl));
|
|
175
|
+
setFetchStatus('success');
|
|
176
|
+
};
|
|
177
|
+
getReferenceData();
|
|
178
|
+
}, [syncBlockStore, intl, isSource, localId, resourceId]);
|
|
179
|
+
const content = () => {
|
|
180
|
+
switch (fetchStatus) {
|
|
181
|
+
case 'loading':
|
|
182
|
+
return /*#__PURE__*/React.createElement(LoadingScreen, null);
|
|
183
|
+
case 'error':
|
|
184
|
+
return /*#__PURE__*/React.createElement(ErrorScreen, {
|
|
185
|
+
formatMessage: formatMessage
|
|
186
|
+
});
|
|
187
|
+
case 'success':
|
|
188
|
+
if (referenceData.length > 0) {
|
|
189
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
190
|
+
"data-testid": "synced-locations-dropdown-content",
|
|
191
|
+
className: ax([styles.contentContainer, "_ku9g126e _18bk1rpy"])
|
|
192
|
+
}, /*#__PURE__*/React.createElement(DropdownItemGroup, {
|
|
193
|
+
title: formatMessage(messages.syncedLocationDropdownHeading, {
|
|
194
|
+
count: `${referenceData.length > 99 ? '99+' : referenceData.length}`
|
|
195
|
+
})
|
|
196
|
+
}, referenceData.map(reference => /*#__PURE__*/React.createElement(DropdownItem, {
|
|
197
|
+
elemBefore: /*#__PURE__*/React.createElement(ItemIcon, {
|
|
198
|
+
reference: reference
|
|
199
|
+
}),
|
|
200
|
+
href: reference.url,
|
|
201
|
+
key: reference.title
|
|
202
|
+
}, /*#__PURE__*/React.createElement(ItemTitle, {
|
|
203
|
+
title: reference.title || reference.url || '',
|
|
204
|
+
formatMessage: formatMessage,
|
|
205
|
+
onSamePage: reference.onSamePage,
|
|
206
|
+
isSource: reference.isSource
|
|
207
|
+
})))));
|
|
208
|
+
} else {
|
|
209
|
+
return /*#__PURE__*/React.createElement(NoResultScreen, {
|
|
210
|
+
formatMessage: formatMessage
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
216
|
+
xcss: styles.dropdownContent
|
|
217
|
+
}, content());
|
|
218
|
+
};
|
|
219
|
+
const LoadingScreen = () => {
|
|
220
|
+
return /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(Spinner, null));
|
|
221
|
+
};
|
|
222
|
+
const ErrorScreen = ({
|
|
223
|
+
formatMessage
|
|
224
|
+
}) => {
|
|
225
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
226
|
+
xcss: styles.errorContainer
|
|
227
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
228
|
+
xcss: styles.errorIcon
|
|
229
|
+
}, /*#__PURE__*/React.createElement(StatusErrorIcon, {
|
|
230
|
+
color: "var(--ds-icon-danger, #C9372C)",
|
|
231
|
+
spacing: "spacious",
|
|
232
|
+
label: "",
|
|
233
|
+
size: "small"
|
|
234
|
+
})), /*#__PURE__*/React.createElement(Text, {
|
|
235
|
+
as: "p",
|
|
236
|
+
size: "medium"
|
|
237
|
+
}, formatMessage(messages.syncedLocationDropdownError)));
|
|
238
|
+
};
|
|
239
|
+
const NoResultScreen = ({
|
|
240
|
+
formatMessage
|
|
241
|
+
}) => {
|
|
242
|
+
return /*#__PURE__*/React.createElement(Stack, {
|
|
243
|
+
xcss: styles.noResultsContainer,
|
|
244
|
+
space: "space.100"
|
|
245
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
246
|
+
as: "p"
|
|
247
|
+
}, formatMessage(messages.syncedLocationDropdownNoResults)), /*#__PURE__*/React.createElement(Text, {
|
|
248
|
+
as: "p"
|
|
249
|
+
}, /*#__PURE__*/React.createElement(Anchor, {
|
|
250
|
+
href: "https://hello.atlassian.net/wiki/x/tAtCeAE",
|
|
251
|
+
target: "_blank",
|
|
252
|
+
xcss: styles.learnMoreLink
|
|
253
|
+
}, formatMessage(messages.syncedLocationDropdownLearnMoreLink))));
|
|
254
|
+
};
|
|
@@ -9,6 +9,7 @@ import EditIcon from '@atlaskit/icon/core/edit';
|
|
|
9
9
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
10
|
import { copySyncedBlockReferenceToClipboard, editSyncedBlockSource, removeSyncedBlock } from '../editor-commands';
|
|
11
11
|
import { findSyncBlockOrBodiedSyncBlock, isBodiedSyncBlockNode } from '../pm-plugins/utils/utils';
|
|
12
|
+
import { SyncedLocationDropdown } from './SyncedLocationDropdown';
|
|
12
13
|
export const getToolbarConfig = (state, intl, api, syncBlockStore) => {
|
|
13
14
|
var _api$decorations, _api$connectivity, _api$connectivity$sha;
|
|
14
15
|
const syncBlockObject = findSyncBlockOrBodiedSyncBlock(state.schema, state.selection);
|
|
@@ -25,6 +26,10 @@ export const getToolbarConfig = (state, intl, api, syncBlockStore) => {
|
|
|
25
26
|
}
|
|
26
27
|
} = state;
|
|
27
28
|
const isBodiedSyncBlock = isBodiedSyncBlockNode(syncBlockObject.node, bodiedSyncBlock);
|
|
29
|
+
const {
|
|
30
|
+
resourceId,
|
|
31
|
+
localId
|
|
32
|
+
} = syncBlockObject.node.attrs;
|
|
28
33
|
const {
|
|
29
34
|
formatMessage
|
|
30
35
|
} = intl;
|
|
@@ -48,6 +53,22 @@ export const getToolbarConfig = (state, intl, api, syncBlockStore) => {
|
|
|
48
53
|
};
|
|
49
54
|
items.push(deleteButton);
|
|
50
55
|
} else {
|
|
56
|
+
if (fg('platform_synced_block_dogfooding')) {
|
|
57
|
+
const syncedLocation = {
|
|
58
|
+
type: 'custom',
|
|
59
|
+
fallback: [],
|
|
60
|
+
render: () => {
|
|
61
|
+
return /*#__PURE__*/React.createElement(SyncedLocationDropdown, {
|
|
62
|
+
syncBlockStore: syncBlockStore,
|
|
63
|
+
resourceId: resourceId,
|
|
64
|
+
localId: localId,
|
|
65
|
+
intl: intl,
|
|
66
|
+
isSource: isBodiedSyncBlock
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
items.push(syncedLocation);
|
|
71
|
+
}
|
|
51
72
|
const copyButton = {
|
|
52
73
|
id: 'editor.syncedBlock.copy',
|
|
53
74
|
type: 'button',
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
|
|
2
|
+
._1mour5cr{margin-block:var(--ds-space-negative-050,-4px)}
|
|
3
|
+
._1rjcv77o{padding-block:var(--ds-space-025,2px)}
|
|
4
|
+
._ku9g126e [data-ds--menu--heading-item]{margin-block:var(--ds-space-050,4px)!important}._18bk1rpy [data-ds--menu--heading-item]{color:var(--ds-text-subtlest,#6b6e76)}
|
|
5
|
+
._18m915vq{overflow-y:hidden}
|
|
6
|
+
._18m91wug{overflow-y:auto}
|
|
7
|
+
._1bah1h6o{justify-content:center}
|
|
8
|
+
._1bsb1osq{width:100%}
|
|
9
|
+
._1bsb96ou{width:327px}
|
|
10
|
+
._1bsbo8uj{width:235px}
|
|
11
|
+
._1bto1l2s{text-overflow:ellipsis}
|
|
12
|
+
._1e0c1txw{display:flex}
|
|
13
|
+
._1hmsglyw{text-decoration-line:none}
|
|
14
|
+
._1reo15vq{overflow-x:hidden}
|
|
15
|
+
._1tkeqkoa{min-height:9pc}
|
|
16
|
+
._1ul91wqb{min-width:60px}
|
|
17
|
+
._1wpz1fhb{align-self:stretch}
|
|
18
|
+
._4bfu1r31{text-decoration-color:currentColor}
|
|
19
|
+
._4cvr1h6o{align-items:center}
|
|
20
|
+
._ahbq1b66{margin-inline-start:var(--ds-space-050,4px)}
|
|
21
|
+
._ajmmnqa1{text-decoration-style:solid}
|
|
22
|
+
._c71lko4j{max-height:19pc}
|
|
23
|
+
._o5721q9c{white-space:nowrap}
|
|
24
|
+
._syaz1rpy{color:var(--ds-text-subtlest,#6b6e76)}
|
|
25
|
+
._syazazsu{color:var(--ds-text-subtle,#505258)}
|
|
26
|
+
._y3gn1h6o{text-align:center}
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
/* SyncedLocationDropdown.tsx generated by @compiled/babel-plugin v0.38.1 */
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
4
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
5
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
6
|
+
var _excluded = ["triggerRef"];
|
|
7
|
+
import "./SyncedLocationDropdown.compiled.css";
|
|
8
|
+
import * as React from 'react';
|
|
9
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
10
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
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
|
+
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
|
+
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 { useState, useEffect } from 'react';
|
|
15
|
+
import DropdownMenu, { DropdownItem, DropdownItemGroup } from '@atlaskit/dropdown-menu';
|
|
16
|
+
import { syncBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
17
|
+
import { FloatingToolbarButton as Button } from '@atlaskit/editor-common/ui';
|
|
18
|
+
import { IconTile } from '@atlaskit/icon';
|
|
19
|
+
import PageLiveDocIcon from '@atlaskit/icon-lab/core/page-live-doc';
|
|
20
|
+
import ChevronDownIcon from '@atlaskit/icon/core/chevron-down';
|
|
21
|
+
import PageIcon from '@atlaskit/icon/core/page';
|
|
22
|
+
import StatusErrorIcon from '@atlaskit/icon/core/status-error';
|
|
23
|
+
import { ConfluenceIcon, JiraIcon } from '@atlaskit/logo';
|
|
24
|
+
import Lozenge from '@atlaskit/lozenge';
|
|
25
|
+
import { Box, Text, Inline, Anchor, Stack } from '@atlaskit/primitives/compiled';
|
|
26
|
+
import Spinner from '@atlaskit/spinner';
|
|
27
|
+
var headingStyles = null;
|
|
28
|
+
var styles = {
|
|
29
|
+
title: "_1reo15vq _18m915vq _syazazsu _1bto1l2s _o5721q9c",
|
|
30
|
+
note: "_syaz1rpy _o5721q9c",
|
|
31
|
+
lozenge: "_ahbq1b66 _1ul91wqb",
|
|
32
|
+
noResultsContainer: "_1bsbo8uj _y3gn1h6o",
|
|
33
|
+
dropdownContent: "_1rjcv77o _1bsb96ou _1tkeqkoa _c71lko4j _1e0c1txw _1bah1h6o _4cvr1h6o",
|
|
34
|
+
contentContainer: "_1bsb1osq _1wpz1fhb _18m91wug",
|
|
35
|
+
errorContainer: "_1bsbo8uj _1e0c1txw",
|
|
36
|
+
errorIcon: "_1mour5cr",
|
|
37
|
+
learnMoreLink: "_4bfu1r31 _1hmsglyw _ajmmnqa1"
|
|
38
|
+
};
|
|
39
|
+
var ItemTitle = function ItemTitle(_ref) {
|
|
40
|
+
var title = _ref.title,
|
|
41
|
+
formatMessage = _ref.formatMessage,
|
|
42
|
+
onSamePage = _ref.onSamePage,
|
|
43
|
+
isSource = _ref.isSource;
|
|
44
|
+
return /*#__PURE__*/React.createElement(Inline, null, /*#__PURE__*/React.createElement(Box, {
|
|
45
|
+
as: "span",
|
|
46
|
+
xcss: styles.title
|
|
47
|
+
}, title), onSamePage && /*#__PURE__*/React.createElement(Box, {
|
|
48
|
+
as: "span",
|
|
49
|
+
xcss: styles.note
|
|
50
|
+
}, "\xA0- ", formatMessage(messages.syncedLocationDropdownTitleNote)), isSource && /*#__PURE__*/React.createElement(Box, {
|
|
51
|
+
as: "span",
|
|
52
|
+
xcss: styles.lozenge
|
|
53
|
+
}, /*#__PURE__*/React.createElement(Lozenge, null, formatMessage(messages.syncedLocationDropdownSourceLozenge))));
|
|
54
|
+
};
|
|
55
|
+
var Logo = function Logo(_ref2) {
|
|
56
|
+
var product = _ref2.product;
|
|
57
|
+
switch (product) {
|
|
58
|
+
case 'confluence-page':
|
|
59
|
+
return /*#__PURE__*/React.createElement(ConfluenceIcon, {
|
|
60
|
+
size: "xsmall"
|
|
61
|
+
});
|
|
62
|
+
case 'jira-work-item':
|
|
63
|
+
return /*#__PURE__*/React.createElement(JiraIcon, {
|
|
64
|
+
size: "xsmall"
|
|
65
|
+
});
|
|
66
|
+
default:
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
var ItemIcon = function ItemIcon(_ref3) {
|
|
71
|
+
var reference = _ref3.reference;
|
|
72
|
+
var hasAccess = reference.hasAccess,
|
|
73
|
+
subType = reference.subType;
|
|
74
|
+
var icon = hasAccess ? subType ? PageLiveDocIcon : PageIcon : function () {
|
|
75
|
+
return /*#__PURE__*/React.createElement(Logo, {
|
|
76
|
+
product: reference.productType
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
return /*#__PURE__*/React.createElement(IconTile, {
|
|
80
|
+
icon: icon,
|
|
81
|
+
label: "",
|
|
82
|
+
appearance: hasAccess ? 'grayBold' : 'gray',
|
|
83
|
+
size: "xsmall"
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
export var processReferenceData = function processReferenceData(referenceData, intl) {
|
|
87
|
+
var formatMessage = intl.formatMessage;
|
|
88
|
+
var sourceInfoMap = new Map();
|
|
89
|
+
referenceData === null || referenceData === void 0 || referenceData.forEach(function (reference) {
|
|
90
|
+
if (!reference) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (sourceInfoMap.has(reference.sourceAri)) {
|
|
94
|
+
var _sourceInfoMap$get;
|
|
95
|
+
(_sourceInfoMap$get = sourceInfoMap.get(reference.sourceAri)) === null || _sourceInfoMap$get === void 0 || _sourceInfoMap$get.push(reference);
|
|
96
|
+
} else {
|
|
97
|
+
sourceInfoMap.set(reference.sourceAri, [reference]);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
var _iterator = _createForOfIteratorHelper(sourceInfoMap.values()),
|
|
101
|
+
_step;
|
|
102
|
+
try {
|
|
103
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
104
|
+
var references = _step.value;
|
|
105
|
+
if (references.length > 1) {
|
|
106
|
+
references.forEach(function (reference, index) {
|
|
107
|
+
return reference.title = "".concat(reference.title, ": ").concat(formatMessage(messages.syncedLocationDropdownTitleBlockIndex, {
|
|
108
|
+
index: index + 1
|
|
109
|
+
}));
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
} catch (err) {
|
|
114
|
+
_iterator.e(err);
|
|
115
|
+
} finally {
|
|
116
|
+
_iterator.f();
|
|
117
|
+
}
|
|
118
|
+
var sortedReferences = Array.from(sourceInfoMap.values()).flat().sort(function (a, b) {
|
|
119
|
+
if (a.isSource !== b.isSource) {
|
|
120
|
+
return b.isSource ? 1 : -1;
|
|
121
|
+
}
|
|
122
|
+
if (a.hasAccess !== b.hasAccess) {
|
|
123
|
+
return a.hasAccess ? -1 : 1;
|
|
124
|
+
}
|
|
125
|
+
return (a.title || '').localeCompare(b.title || '');
|
|
126
|
+
});
|
|
127
|
+
return sortedReferences;
|
|
128
|
+
};
|
|
129
|
+
export var SyncedLocationDropdown = function SyncedLocationDropdown(_ref4) {
|
|
130
|
+
var syncBlockStore = _ref4.syncBlockStore,
|
|
131
|
+
resourceId = _ref4.resourceId,
|
|
132
|
+
intl = _ref4.intl,
|
|
133
|
+
isSource = _ref4.isSource,
|
|
134
|
+
localId = _ref4.localId;
|
|
135
|
+
var formatMessage = intl.formatMessage;
|
|
136
|
+
var triggerTitle = formatMessage(messages.syncedLocationDropdownTitle);
|
|
137
|
+
var _useState = useState(false),
|
|
138
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
139
|
+
isOpen = _useState2[0],
|
|
140
|
+
setIsOpen = _useState2[1];
|
|
141
|
+
return /*#__PURE__*/React.createElement(DropdownMenu, {
|
|
142
|
+
isOpen: isOpen,
|
|
143
|
+
onOpenChange: function onOpenChange(_ref5) {
|
|
144
|
+
var isOpen = _ref5.isOpen;
|
|
145
|
+
return setIsOpen(isOpen);
|
|
146
|
+
},
|
|
147
|
+
trigger: function trigger(_ref6) {
|
|
148
|
+
var triggerRef = _ref6.triggerRef,
|
|
149
|
+
triggerProps = _objectWithoutProperties(_ref6, _excluded);
|
|
150
|
+
return /*#__PURE__*/React.createElement(Button, _extends({
|
|
151
|
+
ref: triggerRef,
|
|
152
|
+
areAnyNewToolbarFlagsEnabled: true,
|
|
153
|
+
iconAfter: /*#__PURE__*/React.createElement(ChevronDownIcon, {
|
|
154
|
+
color: "currentColor",
|
|
155
|
+
spacing: "spacious",
|
|
156
|
+
label: "",
|
|
157
|
+
size: "small"
|
|
158
|
+
})
|
|
159
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
160
|
+
}, triggerProps), triggerTitle);
|
|
161
|
+
}
|
|
162
|
+
}, isOpen && /*#__PURE__*/React.createElement(DropdownContent, {
|
|
163
|
+
syncBlockStore: syncBlockStore,
|
|
164
|
+
resourceId: resourceId,
|
|
165
|
+
intl: intl,
|
|
166
|
+
isSource: isSource,
|
|
167
|
+
localId: localId
|
|
168
|
+
}));
|
|
169
|
+
};
|
|
170
|
+
var DropdownContent = function DropdownContent(_ref7) {
|
|
171
|
+
var syncBlockStore = _ref7.syncBlockStore,
|
|
172
|
+
resourceId = _ref7.resourceId,
|
|
173
|
+
intl = _ref7.intl,
|
|
174
|
+
isSource = _ref7.isSource,
|
|
175
|
+
localId = _ref7.localId;
|
|
176
|
+
var formatMessage = intl.formatMessage;
|
|
177
|
+
var _useState3 = useState('none'),
|
|
178
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
179
|
+
fetchStatus = _useState4[0],
|
|
180
|
+
setFetchStatus = _useState4[1];
|
|
181
|
+
var _useState5 = useState([]),
|
|
182
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
183
|
+
referenceData = _useState6[0],
|
|
184
|
+
setReferenceData = _useState6[1];
|
|
185
|
+
useEffect(function () {
|
|
186
|
+
setFetchStatus('loading');
|
|
187
|
+
var getReferenceData = /*#__PURE__*/function () {
|
|
188
|
+
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
189
|
+
var response;
|
|
190
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
191
|
+
while (1) switch (_context.prev = _context.next) {
|
|
192
|
+
case 0:
|
|
193
|
+
_context.next = 2;
|
|
194
|
+
return syncBlockStore.fetchReferencesSourceInfo(resourceId, localId, isSource);
|
|
195
|
+
case 2:
|
|
196
|
+
response = _context.sent;
|
|
197
|
+
if (!response.error) {
|
|
198
|
+
_context.next = 6;
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
setFetchStatus('error');
|
|
202
|
+
return _context.abrupt("return");
|
|
203
|
+
case 6:
|
|
204
|
+
setReferenceData(processReferenceData(response.references, intl));
|
|
205
|
+
setFetchStatus('success');
|
|
206
|
+
case 8:
|
|
207
|
+
case "end":
|
|
208
|
+
return _context.stop();
|
|
209
|
+
}
|
|
210
|
+
}, _callee);
|
|
211
|
+
}));
|
|
212
|
+
return function getReferenceData() {
|
|
213
|
+
return _ref8.apply(this, arguments);
|
|
214
|
+
};
|
|
215
|
+
}();
|
|
216
|
+
getReferenceData();
|
|
217
|
+
}, [syncBlockStore, intl, isSource, localId, resourceId]);
|
|
218
|
+
var content = function content() {
|
|
219
|
+
switch (fetchStatus) {
|
|
220
|
+
case 'loading':
|
|
221
|
+
return /*#__PURE__*/React.createElement(LoadingScreen, null);
|
|
222
|
+
case 'error':
|
|
223
|
+
return /*#__PURE__*/React.createElement(ErrorScreen, {
|
|
224
|
+
formatMessage: formatMessage
|
|
225
|
+
});
|
|
226
|
+
case 'success':
|
|
227
|
+
if (referenceData.length > 0) {
|
|
228
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
229
|
+
"data-testid": "synced-locations-dropdown-content",
|
|
230
|
+
className: ax([styles.contentContainer, "_ku9g126e _18bk1rpy"])
|
|
231
|
+
}, /*#__PURE__*/React.createElement(DropdownItemGroup, {
|
|
232
|
+
title: formatMessage(messages.syncedLocationDropdownHeading, {
|
|
233
|
+
count: "".concat(referenceData.length > 99 ? '99+' : referenceData.length)
|
|
234
|
+
})
|
|
235
|
+
}, referenceData.map(function (reference) {
|
|
236
|
+
return /*#__PURE__*/React.createElement(DropdownItem, {
|
|
237
|
+
elemBefore: /*#__PURE__*/React.createElement(ItemIcon, {
|
|
238
|
+
reference: reference
|
|
239
|
+
}),
|
|
240
|
+
href: reference.url,
|
|
241
|
+
key: reference.title
|
|
242
|
+
}, /*#__PURE__*/React.createElement(ItemTitle, {
|
|
243
|
+
title: reference.title || reference.url || '',
|
|
244
|
+
formatMessage: formatMessage,
|
|
245
|
+
onSamePage: reference.onSamePage,
|
|
246
|
+
isSource: reference.isSource
|
|
247
|
+
}));
|
|
248
|
+
})));
|
|
249
|
+
} else {
|
|
250
|
+
return /*#__PURE__*/React.createElement(NoResultScreen, {
|
|
251
|
+
formatMessage: formatMessage
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
257
|
+
xcss: styles.dropdownContent
|
|
258
|
+
}, content());
|
|
259
|
+
};
|
|
260
|
+
var LoadingScreen = function LoadingScreen() {
|
|
261
|
+
return /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(Spinner, null));
|
|
262
|
+
};
|
|
263
|
+
var ErrorScreen = function ErrorScreen(_ref9) {
|
|
264
|
+
var formatMessage = _ref9.formatMessage;
|
|
265
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
266
|
+
xcss: styles.errorContainer
|
|
267
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
268
|
+
xcss: styles.errorIcon
|
|
269
|
+
}, /*#__PURE__*/React.createElement(StatusErrorIcon, {
|
|
270
|
+
color: "var(--ds-icon-danger, #C9372C)",
|
|
271
|
+
spacing: "spacious",
|
|
272
|
+
label: "",
|
|
273
|
+
size: "small"
|
|
274
|
+
})), /*#__PURE__*/React.createElement(Text, {
|
|
275
|
+
as: "p",
|
|
276
|
+
size: "medium"
|
|
277
|
+
}, formatMessage(messages.syncedLocationDropdownError)));
|
|
278
|
+
};
|
|
279
|
+
var NoResultScreen = function NoResultScreen(_ref0) {
|
|
280
|
+
var formatMessage = _ref0.formatMessage;
|
|
281
|
+
return /*#__PURE__*/React.createElement(Stack, {
|
|
282
|
+
xcss: styles.noResultsContainer,
|
|
283
|
+
space: "space.100"
|
|
284
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
285
|
+
as: "p"
|
|
286
|
+
}, formatMessage(messages.syncedLocationDropdownNoResults)), /*#__PURE__*/React.createElement(Text, {
|
|
287
|
+
as: "p"
|
|
288
|
+
}, /*#__PURE__*/React.createElement(Anchor, {
|
|
289
|
+
href: "https://hello.atlassian.net/wiki/x/tAtCeAE",
|
|
290
|
+
target: "_blank",
|
|
291
|
+
xcss: styles.learnMoreLink
|
|
292
|
+
}, formatMessage(messages.syncedLocationDropdownLearnMoreLink))));
|
|
293
|
+
};
|
|
@@ -12,6 +12,7 @@ import EditIcon from '@atlaskit/icon/core/edit';
|
|
|
12
12
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
13
13
|
import { copySyncedBlockReferenceToClipboard, editSyncedBlockSource, removeSyncedBlock } from '../editor-commands';
|
|
14
14
|
import { findSyncBlockOrBodiedSyncBlock, isBodiedSyncBlockNode } from '../pm-plugins/utils/utils';
|
|
15
|
+
import { SyncedLocationDropdown } from './SyncedLocationDropdown';
|
|
15
16
|
export var getToolbarConfig = function getToolbarConfig(state, intl, api, syncBlockStore) {
|
|
16
17
|
var _api$decorations, _api$connectivity;
|
|
17
18
|
var syncBlockObject = findSyncBlockOrBodiedSyncBlock(state.schema, state.selection);
|
|
@@ -22,6 +23,9 @@ export var getToolbarConfig = function getToolbarConfig(state, intl, api, syncBl
|
|
|
22
23
|
var isUnsyncedBlock = (syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.error) === SyncBlockError.NotFound;
|
|
23
24
|
var bodiedSyncBlock = state.schema.nodes.bodiedSyncBlock;
|
|
24
25
|
var isBodiedSyncBlock = isBodiedSyncBlockNode(syncBlockObject.node, bodiedSyncBlock);
|
|
26
|
+
var _syncBlockObject$node = syncBlockObject.node.attrs,
|
|
27
|
+
resourceId = _syncBlockObject$node.resourceId,
|
|
28
|
+
localId = _syncBlockObject$node.localId;
|
|
25
29
|
var formatMessage = intl.formatMessage;
|
|
26
30
|
var nodeType = syncBlockObject.node.type;
|
|
27
31
|
var hoverDecoration = api === null || api === void 0 || (_api$decorations = api.decorations) === null || _api$decorations === void 0 ? void 0 : _api$decorations.actions.hoverDecoration;
|
|
@@ -44,6 +48,22 @@ export var getToolbarConfig = function getToolbarConfig(state, intl, api, syncBl
|
|
|
44
48
|
}, hoverDecorationProps(nodeType, akEditorSelectedNodeClassName));
|
|
45
49
|
items.push(deleteButton);
|
|
46
50
|
} else {
|
|
51
|
+
if (fg('platform_synced_block_dogfooding')) {
|
|
52
|
+
var syncedLocation = {
|
|
53
|
+
type: 'custom',
|
|
54
|
+
fallback: [],
|
|
55
|
+
render: function render() {
|
|
56
|
+
return /*#__PURE__*/React.createElement(SyncedLocationDropdown, {
|
|
57
|
+
syncBlockStore: syncBlockStore,
|
|
58
|
+
resourceId: resourceId,
|
|
59
|
+
localId: localId,
|
|
60
|
+
intl: intl,
|
|
61
|
+
isSource: isBodiedSyncBlock
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
items.push(syncedLocation);
|
|
66
|
+
}
|
|
47
67
|
var copyButton = _objectSpread({
|
|
48
68
|
id: 'editor.syncedBlock.copy',
|
|
49
69
|
type: 'button',
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type IntlShape } from 'react-intl-next';
|
|
2
|
+
import type { SyncBlockSourceInfo, SyncBlockStoreManager, ReferencesSourceInfo } from '@atlaskit/editor-synced-block-provider';
|
|
3
|
+
interface Props {
|
|
4
|
+
intl: IntlShape;
|
|
5
|
+
isSource: boolean;
|
|
6
|
+
localId: string;
|
|
7
|
+
resourceId: string;
|
|
8
|
+
syncBlockStore: SyncBlockStoreManager;
|
|
9
|
+
}
|
|
10
|
+
export declare const processReferenceData: (referenceData: ReferencesSourceInfo["references"], intl: IntlShape) => SyncBlockSourceInfo[];
|
|
11
|
+
export declare const SyncedLocationDropdown: ({ syncBlockStore, resourceId, intl, isSource, localId, }: Props) => JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type IntlShape } from 'react-intl-next';
|
|
2
|
+
import type { SyncBlockSourceInfo, SyncBlockStoreManager, ReferencesSourceInfo } from '@atlaskit/editor-synced-block-provider';
|
|
3
|
+
interface Props {
|
|
4
|
+
intl: IntlShape;
|
|
5
|
+
isSource: boolean;
|
|
6
|
+
localId: string;
|
|
7
|
+
resourceId: string;
|
|
8
|
+
syncBlockStore: SyncBlockStoreManager;
|
|
9
|
+
}
|
|
10
|
+
export declare const processReferenceData: (referenceData: ReferencesSourceInfo["references"], intl: IntlShape) => SyncBlockSourceInfo[];
|
|
11
|
+
export declare const SyncedLocationDropdown: ({ syncBlockStore, resourceId, intl, isSource, localId, }: Props) => JSX.Element;
|
|
12
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-synced-block",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.12",
|
|
4
4
|
"description": "SyncedBlock plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@atlaskit/adf-schema": "^51.5.0",
|
|
32
32
|
"@atlaskit/button": "23.9.3",
|
|
33
|
+
"@atlaskit/dropdown-menu": "16.4.1",
|
|
33
34
|
"@atlaskit/editor-json-transformer": "^8.31.0",
|
|
34
35
|
"@atlaskit/editor-plugin-analytics": "^7.0.0",
|
|
35
36
|
"@atlaskit/editor-plugin-block-menu": "^6.0.0",
|
|
@@ -45,15 +46,18 @@
|
|
|
45
46
|
"@atlaskit/flag": "^17.8.0",
|
|
46
47
|
"@atlaskit/icon": "29.4.1",
|
|
47
48
|
"@atlaskit/icon-lab": "^5.14.0",
|
|
49
|
+
"@atlaskit/logo": "^19.10.0",
|
|
48
50
|
"@atlaskit/lozenge": "^13.3.0",
|
|
49
51
|
"@atlaskit/modal-dialog": "^14.10.0",
|
|
50
52
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
51
|
-
"@atlaskit/primitives": "^17.
|
|
52
|
-
"@atlaskit/
|
|
53
|
+
"@atlaskit/primitives": "^17.1.0",
|
|
54
|
+
"@atlaskit/spinner": "19.0.8",
|
|
55
|
+
"@atlaskit/tmp-editor-statsig": "^16.22.0",
|
|
53
56
|
"@atlaskit/tokens": "9.1.2",
|
|
54
57
|
"@atlaskit/tooltip": "^20.14.0",
|
|
55
58
|
"@atlaskit/visually-hidden": "^3.0.0",
|
|
56
59
|
"@babel/runtime": "^7.0.0",
|
|
60
|
+
"@compiled/react": "^0.18.6",
|
|
57
61
|
"bind-event-listener": "^3.0.0",
|
|
58
62
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
59
63
|
},
|