@atlaskit/editor-common 118.11.0 → 118.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/compass.yml +2 -2
- package/dist/cjs/core-utils/index.js +1 -8
- package/dist/cjs/extensibility/ExtensionSSRReactContextsProvider.js +1 -2
- package/dist/cjs/monitoring/error.js +1 -1
- package/dist/cjs/portal/common.js +2 -3
- package/dist/cjs/react-node-view/NodeViewContentHole.js +1 -2
- package/dist/cjs/react-node-view/index.js +1 -1
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/cjs/ui/Mention/index.js +20 -1
- package/dist/cjs/ui/Mention/mention-node-data-provider.js +5 -0
- package/dist/cjs/ui/Mention/mention-with-profilecard.js +8 -0
- package/dist/cjs/ui/Mention/mention-with-providers.js +92 -15
- package/dist/es2019/core-utils/index.js +1 -2
- package/dist/es2019/extensibility/ExtensionSSRReactContextsProvider.js +1 -2
- package/dist/es2019/monitoring/error.js +1 -1
- package/dist/es2019/portal/common.js +2 -3
- package/dist/es2019/react-node-view/NodeViewContentHole.js +1 -2
- package/dist/es2019/react-node-view/index.js +2 -2
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/es2019/ui/Mention/index.js +21 -2
- package/dist/es2019/ui/Mention/mention-node-data-provider.js +1 -0
- package/dist/es2019/ui/Mention/mention-with-profilecard.js +8 -0
- package/dist/es2019/ui/Mention/mention-with-providers.js +69 -2
- package/dist/esm/core-utils/index.js +1 -2
- package/dist/esm/extensibility/ExtensionSSRReactContextsProvider.js +1 -2
- package/dist/esm/monitoring/error.js +1 -1
- package/dist/esm/portal/common.js +2 -3
- package/dist/esm/react-node-view/NodeViewContentHole.js +1 -2
- package/dist/esm/react-node-view/index.js +2 -2
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/esm/ui/Mention/index.js +21 -2
- package/dist/esm/ui/Mention/mention-node-data-provider.js +1 -0
- package/dist/esm/ui/Mention/mention-with-profilecard.js +8 -0
- package/dist/esm/ui/Mention/mention-with-providers.js +92 -15
- package/dist/types/core-utils/index.d.ts +0 -1
- package/dist/types/mention.d.ts +1 -0
- package/dist/types/ui/Mention/index.d.ts +2 -0
- package/dist/types/ui/Mention/mention-node-data-provider.d.ts +32 -0
- package/dist/types/ui/Mention/mention-with-profilecard.d.ts +5 -1
- package/dist/types/ui/Mention/mention-with-providers.d.ts +11 -1
- package/package.json +9 -3
- package/dist/cjs/core-utils/is-ssr-streaming.js +0 -22
- package/dist/es2019/core-utils/is-ssr-streaming.js +0 -16
- package/dist/esm/core-utils/is-ssr-streaming.js +0 -16
- package/dist/types/core-utils/is-ssr-streaming.d.ts +0 -10
|
@@ -1,15 +1,54 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React, { useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
2
3
|
import { ResourcedMention } from '@atlaskit/mention/element';
|
|
3
4
|
import ResourcedMentionWithProfilecard from './mention-with-profilecard';
|
|
4
5
|
const GENERIC_USER_IDS = ['HipChat', 'all', 'here'];
|
|
6
|
+
const useMentionNodeData = ({
|
|
7
|
+
id,
|
|
8
|
+
mentionNodeDataProvider,
|
|
9
|
+
userType
|
|
10
|
+
}) => {
|
|
11
|
+
var _state$data;
|
|
12
|
+
const mention = useMemo(() => ({
|
|
13
|
+
id,
|
|
14
|
+
userType
|
|
15
|
+
}), [id, userType]);
|
|
16
|
+
const mentionKey = `${userType !== null && userType !== void 0 ? userType : 'DEFAULT'}:${id}`;
|
|
17
|
+
const synchronousData = useMemo(() => mentionNodeDataProvider.getMentionDataFromCache(mention), [mention, mentionNodeDataProvider]);
|
|
18
|
+
const [state, setState] = useState(() => ({
|
|
19
|
+
data: synchronousData,
|
|
20
|
+
key: mentionKey
|
|
21
|
+
}));
|
|
22
|
+
const data = state.key === mentionKey ? (_state$data = state.data) !== null && _state$data !== void 0 ? _state$data : synchronousData : synchronousData;
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (synchronousData) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
let isActive = true;
|
|
28
|
+
mentionNodeDataProvider.getMentionData(mention, payload => {
|
|
29
|
+
if (isActive && payload.data) {
|
|
30
|
+
setState({
|
|
31
|
+
data: payload.data,
|
|
32
|
+
key: mentionKey
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
return () => {
|
|
37
|
+
isActive = false;
|
|
38
|
+
};
|
|
39
|
+
}, [mention, mentionKey, mentionNodeDataProvider, synchronousData]);
|
|
40
|
+
return data;
|
|
41
|
+
};
|
|
5
42
|
export const MentionWithProviders = /*#__PURE__*/React.memo(({
|
|
6
43
|
accessLevel,
|
|
7
44
|
disabledTooltip,
|
|
8
45
|
eventHandlers,
|
|
9
46
|
id,
|
|
10
47
|
isDisabled,
|
|
48
|
+
mentionNodeData,
|
|
11
49
|
mentionProvider,
|
|
12
50
|
profilecardProvider: profilecardProviderResolver,
|
|
51
|
+
renderAvatarSlot = false,
|
|
13
52
|
text,
|
|
14
53
|
localId,
|
|
15
54
|
userType
|
|
@@ -49,11 +88,15 @@ export const MentionWithProviders = /*#__PURE__*/React.memo(({
|
|
|
49
88
|
accessLevel: accessLevel,
|
|
50
89
|
localId: localId,
|
|
51
90
|
mentionProvider: mentionProvider,
|
|
91
|
+
appType: mentionNodeData === null || mentionNodeData === void 0 ? void 0 : mentionNodeData.appType,
|
|
92
|
+
avatarUrl: mentionNodeData === null || mentionNodeData === void 0 ? void 0 : mentionNodeData.avatarUrl,
|
|
93
|
+
isAvatarImagePreShaped: mentionNodeData === null || mentionNodeData === void 0 ? void 0 : mentionNodeData.isAvatarImagePreShaped,
|
|
52
94
|
isDisabled: true,
|
|
53
95
|
disabledTooltip: disabledTooltip,
|
|
54
96
|
onClick: eventHandlers === null || eventHandlers === void 0 ? void 0 : eventHandlers.onClick,
|
|
55
97
|
onMouseEnter: eventHandlers === null || eventHandlers === void 0 ? void 0 : eventHandlers.onMouseEnter,
|
|
56
98
|
onMouseLeave: eventHandlers === null || eventHandlers === void 0 ? void 0 : eventHandlers.onMouseLeave,
|
|
99
|
+
renderAvatarSlot: renderAvatarSlot,
|
|
57
100
|
ssrPlaceholderId: ssrPlaceholderId
|
|
58
101
|
});
|
|
59
102
|
}
|
|
@@ -63,7 +106,10 @@ export const MentionWithProviders = /*#__PURE__*/React.memo(({
|
|
|
63
106
|
accessLevel: accessLevel,
|
|
64
107
|
localId: localId,
|
|
65
108
|
userType: userType,
|
|
66
|
-
mentionProvider: mentionProvider
|
|
109
|
+
mentionProvider: mentionProvider,
|
|
110
|
+
appType: mentionNodeData === null || mentionNodeData === void 0 ? void 0 : mentionNodeData.appType,
|
|
111
|
+
avatarUrl: mentionNodeData === null || mentionNodeData === void 0 ? void 0 : mentionNodeData.avatarUrl,
|
|
112
|
+
isAvatarImagePreShaped: mentionNodeData === null || mentionNodeData === void 0 ? void 0 : mentionNodeData.isAvatarImagePreShaped
|
|
67
113
|
// Ignored via go/ees005
|
|
68
114
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
69
115
|
,
|
|
@@ -71,6 +117,27 @@ export const MentionWithProviders = /*#__PURE__*/React.memo(({
|
|
|
71
117
|
onClick: eventHandlers === null || eventHandlers === void 0 ? void 0 : eventHandlers.onClick,
|
|
72
118
|
onMouseEnter: eventHandlers === null || eventHandlers === void 0 ? void 0 : eventHandlers.onMouseEnter,
|
|
73
119
|
onMouseLeave: eventHandlers === null || eventHandlers === void 0 ? void 0 : eventHandlers.onMouseLeave,
|
|
120
|
+
renderAvatarSlot: renderAvatarSlot,
|
|
74
121
|
ssrPlaceholderId: ssrPlaceholderId
|
|
75
122
|
});
|
|
123
|
+
});
|
|
124
|
+
export const MentionWithAvatarProviders = /*#__PURE__*/React.memo(({
|
|
125
|
+
id,
|
|
126
|
+
mentionNodeDataProvider,
|
|
127
|
+
userType,
|
|
128
|
+
...props
|
|
129
|
+
}) => {
|
|
130
|
+
const mentionNodeData = useMentionNodeData({
|
|
131
|
+
id,
|
|
132
|
+
mentionNodeDataProvider,
|
|
133
|
+
userType
|
|
134
|
+
});
|
|
135
|
+
return /*#__PURE__*/React.createElement(MentionWithProviders
|
|
136
|
+
// eslint-disable-next-line react/jsx-props-no-spreading -- The treatment adds only resolved avatar data to the existing mention props.
|
|
137
|
+
, _extends({}, props, {
|
|
138
|
+
id: id,
|
|
139
|
+
mentionNodeData: mentionNodeData,
|
|
140
|
+
renderAvatarSlot: true,
|
|
141
|
+
userType: userType
|
|
142
|
+
}));
|
|
76
143
|
});
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { RawIntlProvider } from 'react-intl';
|
|
3
3
|
import { isSSR } from '../core-utils/is-ssr';
|
|
4
|
-
import { isSSRStreaming } from '../core-utils/is-ssr-streaming';
|
|
5
4
|
export function ExtensionSSRReactContextsProvider(_ref) {
|
|
6
5
|
var children = _ref.children,
|
|
7
6
|
intl = _ref.intl;
|
|
8
|
-
if (!isSSR()
|
|
7
|
+
if (!isSSR()) {
|
|
9
8
|
return children;
|
|
10
9
|
}
|
|
11
10
|
if (!intl) {
|
|
@@ -20,7 +20,7 @@ var NETWORK_FAILURE_REGEX = /^network failure/i;
|
|
|
20
20
|
var RESIZE_OBSERVER_LOOP_REGEX = /ResizeObserver loop completed with undelivered notifications/;
|
|
21
21
|
var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
22
22
|
var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
23
|
-
var packageVersion = "118.
|
|
23
|
+
var packageVersion = "118.11.0";
|
|
24
24
|
var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
|
|
25
25
|
// Remove URL as it has UGC
|
|
26
26
|
// Ignored via go/ees007
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React, { memo } from 'react';
|
|
2
2
|
import { createPortal } from 'react-dom';
|
|
3
3
|
import { isSSR } from '../core-utils/is-ssr';
|
|
4
|
-
import { isSSRStreaming } from '../core-utils/is-ssr-streaming';
|
|
5
4
|
import { PortalRenderWrapperInner } from './PortalRenderWrapperInner';
|
|
6
5
|
var PortalRenderWrapper = /*#__PURE__*/memo(PortalRenderWrapperInner);
|
|
7
6
|
PortalRenderWrapper.displayName = 'PortalRenderWrapper';
|
|
@@ -39,7 +38,7 @@ export var getPortalProviderAPI = function getPortalProviderAPI(portalManager) {
|
|
|
39
38
|
return {
|
|
40
39
|
render: function render(children, container, key, onBeforeReactDomRender) {
|
|
41
40
|
var immediate = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
42
|
-
if (isSSR()
|
|
41
|
+
if (isSSR()) {
|
|
43
42
|
var html = '';
|
|
44
43
|
try {
|
|
45
44
|
var renderToStaticMarkup = getRenderToStaticMarkup();
|
|
@@ -72,7 +71,7 @@ export var getPortalProviderAPI = function getPortalProviderAPI(portalManager) {
|
|
|
72
71
|
},
|
|
73
72
|
remove: function remove(key) {
|
|
74
73
|
var _portalsMap$get;
|
|
75
|
-
if (isSSR()
|
|
74
|
+
if (isSSR()) {
|
|
76
75
|
return;
|
|
77
76
|
}
|
|
78
77
|
(_portalsMap$get = portalsMap.get(key)) === null || _portalsMap$get === void 0 || _portalsMap$get();
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React, { forwardRef } from 'react';
|
|
3
3
|
import { isSSR } from '../core-utils/is-ssr';
|
|
4
|
-
import { isSSRStreaming } from '../core-utils/is-ssr-streaming';
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* A component that serves as a placeholder for the content DOM of a ProseMirror NodeView.
|
|
@@ -10,6 +9,6 @@ import { isSSRStreaming } from '../core-utils/is-ssr-streaming';
|
|
|
10
9
|
export var NodeViewContentHole = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
11
10
|
return /*#__PURE__*/React.createElement("div", _extends({}, props, {
|
|
12
11
|
ref: ref,
|
|
13
|
-
"data-ssr-content-dom-ref": isSSR()
|
|
12
|
+
"data-ssr-content-dom-ref": isSSR() ? '' : undefined
|
|
14
13
|
}));
|
|
15
14
|
});
|
|
@@ -7,7 +7,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
7
7
|
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import { ACTION_SUBJECT, ACTION_SUBJECT_ID } from '../analytics';
|
|
10
|
-
import { isSSR
|
|
10
|
+
import { isSSR } from '../core-utils';
|
|
11
11
|
import { createDispatch } from '../event-dispatcher';
|
|
12
12
|
import { ErrorBoundary } from '../ui/ErrorBoundary';
|
|
13
13
|
import { getPerformanceOptions, startMeasureReactNodeViewRendered, stopMeasureReactNodeViewRendered } from '../utils';
|
|
@@ -99,7 +99,7 @@ var ReactNodeView = /*#__PURE__*/function () {
|
|
|
99
99
|
// contentDOMWrapper that was appended above. The React ref callback
|
|
100
100
|
// (forwardRef) never fires in renderToStaticMarkup, so contentDOM is
|
|
101
101
|
// left detached. Re-attach it by finding the marked SSR ref target.
|
|
102
|
-
if (isSSR() &&
|
|
102
|
+
if (isSSR() && this.domRef) {
|
|
103
103
|
var refTarget = this.domRef.querySelector('[data-ssr-content-dom-ref]');
|
|
104
104
|
if (refTarget) {
|
|
105
105
|
this.handleRef(refTarget);
|
|
@@ -21,7 +21,7 @@ import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
|
|
|
21
21
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
22
22
|
import Layer from '../Layer';
|
|
23
23
|
var packageName = "@atlaskit/editor-common";
|
|
24
|
-
var packageVersion = "118.
|
|
24
|
+
var packageVersion = "118.11.0";
|
|
25
25
|
var halfFocusRing = 1;
|
|
26
26
|
var dropOffset = '0, 8';
|
|
27
27
|
var fadeIn = keyframes({
|
|
@@ -8,10 +8,12 @@ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstruct
|
|
|
8
8
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
9
9
|
/* eslint-disable @repo/internal/react/no-class-components */
|
|
10
10
|
import React, { PureComponent } from 'react';
|
|
11
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
11
12
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
12
13
|
import { ProviderFactory, WithProviders } from '../../provider-factory';
|
|
13
|
-
import { MentionWithProviders } from './mention-with-providers';
|
|
14
|
+
import { MentionWithAvatarProviders, MentionWithProviders } from './mention-with-providers';
|
|
14
15
|
var MENTION_PROVIDERS = ['mentionProvider', 'profilecardProvider'];
|
|
16
|
+
var GENERIC_MENTION_IDS = ['HipChat', 'all', 'here'];
|
|
15
17
|
var Mention = /*#__PURE__*/function (_PureComponent) {
|
|
16
18
|
function Mention(props) {
|
|
17
19
|
var _this;
|
|
@@ -26,9 +28,26 @@ var Mention = /*#__PURE__*/function (_PureComponent) {
|
|
|
26
28
|
localId = _this$props.localId,
|
|
27
29
|
userType = _this$props.userType,
|
|
28
30
|
isDisabled = _this$props.isDisabled,
|
|
29
|
-
disabledTooltip = _this$props.disabledTooltip
|
|
31
|
+
disabledTooltip = _this$props.disabledTooltip,
|
|
32
|
+
mentionNodeDataProvider = _this$props.mentionNodeDataProvider;
|
|
30
33
|
var mentionProvider = providers.mentionProvider,
|
|
31
34
|
profilecardProvider = providers.profilecardProvider;
|
|
35
|
+
var isAvatarEnabled = Boolean(mentionNodeDataProvider) && userType !== 'SPECIAL' && !GENERIC_MENTION_IDS.includes(id) && isExperimentEnabled('platform_editor_mention_node_avatar');
|
|
36
|
+
if (isAvatarEnabled && mentionNodeDataProvider) {
|
|
37
|
+
return /*#__PURE__*/React.createElement(MentionWithAvatarProviders, {
|
|
38
|
+
id: id,
|
|
39
|
+
text: text,
|
|
40
|
+
accessLevel: accessLevel,
|
|
41
|
+
localId: localId,
|
|
42
|
+
userType: userType,
|
|
43
|
+
isDisabled: isDisabled,
|
|
44
|
+
disabledTooltip: disabledTooltip,
|
|
45
|
+
eventHandlers: eventHandlers,
|
|
46
|
+
mentionProvider: mentionProvider,
|
|
47
|
+
mentionNodeDataProvider: mentionNodeDataProvider,
|
|
48
|
+
profilecardProvider: profilecardProvider
|
|
49
|
+
});
|
|
50
|
+
}
|
|
32
51
|
return /*#__PURE__*/React.createElement(MentionWithProviders, {
|
|
33
52
|
id: id,
|
|
34
53
|
text: text,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -37,11 +37,15 @@ export default function MentionWithProfileCard(_ref) {
|
|
|
37
37
|
id = _ref.id,
|
|
38
38
|
text = _ref.text,
|
|
39
39
|
accessLevel = _ref.accessLevel,
|
|
40
|
+
appType = _ref.appType,
|
|
41
|
+
avatarUrl = _ref.avatarUrl,
|
|
42
|
+
isAvatarImagePreShaped = _ref.isAvatarImagePreShaped,
|
|
40
43
|
mentionProvider = _ref.mentionProvider,
|
|
41
44
|
profilecardProvider = _ref.profilecardProvider,
|
|
42
45
|
onClick = _ref.onClick,
|
|
43
46
|
onMouseEnter = _ref.onMouseEnter,
|
|
44
47
|
onMouseLeave = _ref.onMouseLeave,
|
|
48
|
+
renderAvatarSlot = _ref.renderAvatarSlot,
|
|
45
49
|
localId = _ref.localId,
|
|
46
50
|
ssrPlaceholderId = _ref.ssrPlaceholderId,
|
|
47
51
|
userType = _ref.userType;
|
|
@@ -55,11 +59,15 @@ export default function MentionWithProfileCard(_ref) {
|
|
|
55
59
|
id: id,
|
|
56
60
|
text: text,
|
|
57
61
|
accessLevel: accessLevel,
|
|
62
|
+
appType: appType,
|
|
63
|
+
avatarUrl: avatarUrl,
|
|
64
|
+
isAvatarImagePreShaped: isAvatarImagePreShaped,
|
|
58
65
|
localId: localId,
|
|
59
66
|
mentionProvider: mentionProvider,
|
|
60
67
|
onClick: onClick,
|
|
61
68
|
onMouseEnter: onMouseEnter,
|
|
62
69
|
onMouseLeave: onMouseLeave,
|
|
70
|
+
renderAvatarSlot: renderAvatarSlot,
|
|
63
71
|
ssrPlaceholderId: ssrPlaceholderId
|
|
64
72
|
});
|
|
65
73
|
|
|
@@ -1,23 +1,73 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
1
3
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
|
|
4
|
+
var _excluded = ["id", "mentionNodeDataProvider", "userType"];
|
|
5
|
+
import React, { useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
3
6
|
import { ResourcedMention } from '@atlaskit/mention/element';
|
|
4
7
|
import ResourcedMentionWithProfilecard from './mention-with-profilecard';
|
|
5
8
|
var GENERIC_USER_IDS = ['HipChat', 'all', 'here'];
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
id = _ref.id,
|
|
11
|
-
isDisabled = _ref.isDisabled,
|
|
12
|
-
mentionProvider = _ref.mentionProvider,
|
|
13
|
-
profilecardProviderResolver = _ref.profilecardProvider,
|
|
14
|
-
text = _ref.text,
|
|
15
|
-
localId = _ref.localId,
|
|
9
|
+
var useMentionNodeData = function useMentionNodeData(_ref) {
|
|
10
|
+
var _state$data;
|
|
11
|
+
var id = _ref.id,
|
|
12
|
+
mentionNodeDataProvider = _ref.mentionNodeDataProvider,
|
|
16
13
|
userType = _ref.userType;
|
|
17
|
-
var
|
|
14
|
+
var mention = useMemo(function () {
|
|
15
|
+
return {
|
|
16
|
+
id: id,
|
|
17
|
+
userType: userType
|
|
18
|
+
};
|
|
19
|
+
}, [id, userType]);
|
|
20
|
+
var mentionKey = "".concat(userType !== null && userType !== void 0 ? userType : 'DEFAULT', ":").concat(id);
|
|
21
|
+
var synchronousData = useMemo(function () {
|
|
22
|
+
return mentionNodeDataProvider.getMentionDataFromCache(mention);
|
|
23
|
+
}, [mention, mentionNodeDataProvider]);
|
|
24
|
+
var _useState = useState(function () {
|
|
25
|
+
return {
|
|
26
|
+
data: synchronousData,
|
|
27
|
+
key: mentionKey
|
|
28
|
+
};
|
|
29
|
+
}),
|
|
18
30
|
_useState2 = _slicedToArray(_useState, 2),
|
|
19
|
-
|
|
20
|
-
|
|
31
|
+
state = _useState2[0],
|
|
32
|
+
setState = _useState2[1];
|
|
33
|
+
var data = state.key === mentionKey ? (_state$data = state.data) !== null && _state$data !== void 0 ? _state$data : synchronousData : synchronousData;
|
|
34
|
+
useEffect(function () {
|
|
35
|
+
if (synchronousData) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
var isActive = true;
|
|
39
|
+
mentionNodeDataProvider.getMentionData(mention, function (payload) {
|
|
40
|
+
if (isActive && payload.data) {
|
|
41
|
+
setState({
|
|
42
|
+
data: payload.data,
|
|
43
|
+
key: mentionKey
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
return function () {
|
|
48
|
+
isActive = false;
|
|
49
|
+
};
|
|
50
|
+
}, [mention, mentionKey, mentionNodeDataProvider, synchronousData]);
|
|
51
|
+
return data;
|
|
52
|
+
};
|
|
53
|
+
export var MentionWithProviders = /*#__PURE__*/React.memo(function (_ref2) {
|
|
54
|
+
var accessLevel = _ref2.accessLevel,
|
|
55
|
+
disabledTooltip = _ref2.disabledTooltip,
|
|
56
|
+
eventHandlers = _ref2.eventHandlers,
|
|
57
|
+
id = _ref2.id,
|
|
58
|
+
isDisabled = _ref2.isDisabled,
|
|
59
|
+
mentionNodeData = _ref2.mentionNodeData,
|
|
60
|
+
mentionProvider = _ref2.mentionProvider,
|
|
61
|
+
profilecardProviderResolver = _ref2.profilecardProvider,
|
|
62
|
+
_ref2$renderAvatarSlo = _ref2.renderAvatarSlot,
|
|
63
|
+
renderAvatarSlot = _ref2$renderAvatarSlo === void 0 ? false : _ref2$renderAvatarSlo,
|
|
64
|
+
text = _ref2.text,
|
|
65
|
+
localId = _ref2.localId,
|
|
66
|
+
userType = _ref2.userType;
|
|
67
|
+
var _useState3 = useState(null),
|
|
68
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
69
|
+
profilecardProvider = _useState4[0],
|
|
70
|
+
setProfilecardProvider = _useState4[1];
|
|
21
71
|
var mountedRef = useRef(true);
|
|
22
72
|
useLayoutEffect(function () {
|
|
23
73
|
mountedRef.current = true;
|
|
@@ -52,11 +102,15 @@ export var MentionWithProviders = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
52
102
|
accessLevel: accessLevel,
|
|
53
103
|
localId: localId,
|
|
54
104
|
mentionProvider: mentionProvider,
|
|
105
|
+
appType: mentionNodeData === null || mentionNodeData === void 0 ? void 0 : mentionNodeData.appType,
|
|
106
|
+
avatarUrl: mentionNodeData === null || mentionNodeData === void 0 ? void 0 : mentionNodeData.avatarUrl,
|
|
107
|
+
isAvatarImagePreShaped: mentionNodeData === null || mentionNodeData === void 0 ? void 0 : mentionNodeData.isAvatarImagePreShaped,
|
|
55
108
|
isDisabled: true,
|
|
56
109
|
disabledTooltip: disabledTooltip,
|
|
57
110
|
onClick: eventHandlers === null || eventHandlers === void 0 ? void 0 : eventHandlers.onClick,
|
|
58
111
|
onMouseEnter: eventHandlers === null || eventHandlers === void 0 ? void 0 : eventHandlers.onMouseEnter,
|
|
59
112
|
onMouseLeave: eventHandlers === null || eventHandlers === void 0 ? void 0 : eventHandlers.onMouseLeave,
|
|
113
|
+
renderAvatarSlot: renderAvatarSlot,
|
|
60
114
|
ssrPlaceholderId: ssrPlaceholderId
|
|
61
115
|
});
|
|
62
116
|
}
|
|
@@ -66,7 +120,10 @@ export var MentionWithProviders = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
66
120
|
accessLevel: accessLevel,
|
|
67
121
|
localId: localId,
|
|
68
122
|
userType: userType,
|
|
69
|
-
mentionProvider: mentionProvider
|
|
123
|
+
mentionProvider: mentionProvider,
|
|
124
|
+
appType: mentionNodeData === null || mentionNodeData === void 0 ? void 0 : mentionNodeData.appType,
|
|
125
|
+
avatarUrl: mentionNodeData === null || mentionNodeData === void 0 ? void 0 : mentionNodeData.avatarUrl,
|
|
126
|
+
isAvatarImagePreShaped: mentionNodeData === null || mentionNodeData === void 0 ? void 0 : mentionNodeData.isAvatarImagePreShaped
|
|
70
127
|
// Ignored via go/ees005
|
|
71
128
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
72
129
|
,
|
|
@@ -74,6 +131,26 @@ export var MentionWithProviders = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
74
131
|
onClick: eventHandlers === null || eventHandlers === void 0 ? void 0 : eventHandlers.onClick,
|
|
75
132
|
onMouseEnter: eventHandlers === null || eventHandlers === void 0 ? void 0 : eventHandlers.onMouseEnter,
|
|
76
133
|
onMouseLeave: eventHandlers === null || eventHandlers === void 0 ? void 0 : eventHandlers.onMouseLeave,
|
|
134
|
+
renderAvatarSlot: renderAvatarSlot,
|
|
77
135
|
ssrPlaceholderId: ssrPlaceholderId
|
|
78
136
|
});
|
|
137
|
+
});
|
|
138
|
+
export var MentionWithAvatarProviders = /*#__PURE__*/React.memo(function (_ref3) {
|
|
139
|
+
var id = _ref3.id,
|
|
140
|
+
mentionNodeDataProvider = _ref3.mentionNodeDataProvider,
|
|
141
|
+
userType = _ref3.userType,
|
|
142
|
+
props = _objectWithoutProperties(_ref3, _excluded);
|
|
143
|
+
var mentionNodeData = useMentionNodeData({
|
|
144
|
+
id: id,
|
|
145
|
+
mentionNodeDataProvider: mentionNodeDataProvider,
|
|
146
|
+
userType: userType
|
|
147
|
+
});
|
|
148
|
+
return /*#__PURE__*/React.createElement(MentionWithProviders
|
|
149
|
+
// eslint-disable-next-line react/jsx-props-no-spreading -- The treatment adds only resolved avatar data to the existing mention props.
|
|
150
|
+
, _extends({}, props, {
|
|
151
|
+
id: id,
|
|
152
|
+
mentionNodeData: mentionNodeData,
|
|
153
|
+
renderAvatarSlot: true,
|
|
154
|
+
userType: userType
|
|
155
|
+
}));
|
|
79
156
|
});
|
package/dist/types/mention.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { default as Mention } from './ui/Mention';
|
|
2
|
+
export type { MentionNodeDataCallback, MentionNodeDataIdentifier, MentionNodeDataProvider, MentionNodeDataUserType, } from './ui/Mention/mention-node-data-provider';
|
|
2
3
|
export { MentionSharedCssClassName } from './styles/shared/mention';
|
|
3
4
|
export { default as MentionWithProfileCard } from './ui/Mention/mention-with-profilecard';
|
|
@@ -3,6 +3,7 @@ import type { MentionUserType } from '@atlaskit/adf-schema';
|
|
|
3
3
|
import { ProviderFactory } from '../../provider-factory';
|
|
4
4
|
import type { ProfilecardProvider } from '../../provider-factory/profile-card-provider';
|
|
5
5
|
import type { MentionEventHandlers } from '../EventHandlers';
|
|
6
|
+
import type { MentionNodeDataProvider } from './mention-node-data-provider';
|
|
6
7
|
export interface MentionProps {
|
|
7
8
|
accessLevel?: string;
|
|
8
9
|
disabledTooltip?: string;
|
|
@@ -10,6 +11,7 @@ export interface MentionProps {
|
|
|
10
11
|
id: string;
|
|
11
12
|
isDisabled?: boolean;
|
|
12
13
|
localId?: string;
|
|
14
|
+
mentionNodeDataProvider?: MentionNodeDataProvider;
|
|
13
15
|
providers?: ProviderFactory;
|
|
14
16
|
text: string;
|
|
15
17
|
userType?: MentionUserType;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { MentionUserType } from '@atlaskit/adf-schema/mention';
|
|
2
|
+
import type { MentionNodeData } from '@atlaskit/mention/types';
|
|
3
|
+
export type MentionNodeDataCallback = (payload: {
|
|
4
|
+
data: MentionNodeData;
|
|
5
|
+
error?: undefined;
|
|
6
|
+
} | {
|
|
7
|
+
data?: undefined;
|
|
8
|
+
error: Error;
|
|
9
|
+
}) => void;
|
|
10
|
+
/** `AGENT` is emitted by editor agent sources at runtime but is not serialized as an ADF user type. */
|
|
11
|
+
export type MentionNodeDataUserType = MentionUserType | 'AGENT';
|
|
12
|
+
export interface MentionNodeDataIdentifier {
|
|
13
|
+
id: string;
|
|
14
|
+
userType?: MentionNodeDataUserType;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Product-facing bridge between mention data resolution and mention UI.
|
|
18
|
+
*
|
|
19
|
+
* Create one provider per renderer or editor instance and pass it through the
|
|
20
|
+
* renderer props or mentions plugin options. `getMentionDataFromCache` is used
|
|
21
|
+
* during render, including SSR, so it must never start a network request.
|
|
22
|
+
* Deterministic products may return data from it synchronously; network-backed
|
|
23
|
+
* products should return cached data or `undefined`, then resolve through
|
|
24
|
+
* `getMentionData` on the client.
|
|
25
|
+
*
|
|
26
|
+
* The UI depends only on these mention-specific methods to avoid a package
|
|
27
|
+
* cycle with the reusable implementation in editor-plugin-mentions.
|
|
28
|
+
*/
|
|
29
|
+
export interface MentionNodeDataProvider {
|
|
30
|
+
getMentionData: (mention: MentionNodeDataIdentifier, callback: MentionNodeDataCallback) => void;
|
|
31
|
+
getMentionDataFromCache: (mention: MentionNodeDataIdentifier) => MentionNodeData | undefined;
|
|
32
|
+
}
|
|
@@ -5,14 +5,18 @@ import type { ProfilecardProvider } from '../../provider-factory/profile-card-pr
|
|
|
5
5
|
import type { MentionEventHandler } from '../EventHandlers';
|
|
6
6
|
export interface Props {
|
|
7
7
|
accessLevel?: string;
|
|
8
|
+
appType?: string | null;
|
|
8
9
|
autoFocus?: boolean;
|
|
10
|
+
avatarUrl?: string;
|
|
9
11
|
id: string;
|
|
12
|
+
isAvatarImagePreShaped?: boolean;
|
|
10
13
|
localId?: string;
|
|
11
14
|
mentionProvider?: Promise<MentionProvider>;
|
|
12
15
|
onClick?: MentionEventHandler;
|
|
13
16
|
onMouseEnter?: MentionEventHandler;
|
|
14
17
|
onMouseLeave?: MentionEventHandler;
|
|
15
18
|
profilecardProvider: ProfilecardProvider;
|
|
19
|
+
renderAvatarSlot?: boolean;
|
|
16
20
|
ssrPlaceholderId?: string;
|
|
17
21
|
text: string;
|
|
18
22
|
userType?: MentionUserType;
|
|
@@ -22,4 +26,4 @@ export interface Props {
|
|
|
22
26
|
* 1. Agent mentions (`userType === 'APP'`, behind the `rovo_chat_mention_agents` experiment) open the Rovo agent profile card on click.
|
|
23
27
|
* 2. Otherwise renders the person profile card (either via the provider's `renderUserMentionCard`/link fallback or the default user `ProfileCardTrigger`).
|
|
24
28
|
*/
|
|
25
|
-
export default function MentionWithProfileCard({ autoFocus, id, text, accessLevel, mentionProvider, profilecardProvider, onClick, onMouseEnter, onMouseLeave, localId, ssrPlaceholderId, userType, }: Props): React.JSX.Element;
|
|
29
|
+
export default function MentionWithProfileCard({ autoFocus, id, text, accessLevel, appType, avatarUrl, isAvatarImagePreShaped, mentionProvider, profilecardProvider, onClick, onMouseEnter, onMouseLeave, renderAvatarSlot, localId, ssrPlaceholderId, userType, }: Props): React.JSX.Element;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { MentionUserType } from '@atlaskit/adf-schema';
|
|
3
3
|
import type { MentionProvider } from '@atlaskit/mention/resource';
|
|
4
|
+
import type { MentionNodeData } from '@atlaskit/mention/types';
|
|
4
5
|
import type { ProfilecardProvider } from '../../provider-factory/profile-card-provider';
|
|
5
6
|
import type { MentionEventHandlers } from '../EventHandlers';
|
|
7
|
+
import type { MentionNodeDataProvider } from './mention-node-data-provider';
|
|
6
8
|
export interface Props {
|
|
7
9
|
accessLevel?: string;
|
|
8
10
|
disabledTooltip?: string;
|
|
@@ -10,12 +12,20 @@ export interface Props {
|
|
|
10
12
|
id: string;
|
|
11
13
|
isDisabled?: boolean;
|
|
12
14
|
localId?: string;
|
|
15
|
+
mentionNodeDataProvider?: MentionNodeDataProvider;
|
|
13
16
|
mentionProvider?: Promise<MentionProvider>;
|
|
14
17
|
profilecardProvider?: Promise<ProfilecardProvider>;
|
|
15
18
|
text: string;
|
|
16
19
|
userType?: MentionUserType;
|
|
17
20
|
}
|
|
21
|
+
export interface MentionWithProvidersProps extends Props {
|
|
22
|
+
mentionNodeData?: MentionNodeData;
|
|
23
|
+
renderAvatarSlot?: boolean;
|
|
24
|
+
}
|
|
18
25
|
export interface State {
|
|
19
26
|
profilecardProvider: ProfilecardProvider | null;
|
|
20
27
|
}
|
|
21
|
-
export declare const MentionWithProviders: React.MemoExoticComponent<(
|
|
28
|
+
export declare const MentionWithProviders: React.MemoExoticComponent<(props: MentionWithProvidersProps) => React.JSX.Element>;
|
|
29
|
+
export declare const MentionWithAvatarProviders: React.MemoExoticComponent<(props: Props & {
|
|
30
|
+
mentionNodeDataProvider: MentionNodeDataProvider;
|
|
31
|
+
}) => React.JSX.Element>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-common",
|
|
3
|
-
"version": "118.
|
|
3
|
+
"version": "118.12.0",
|
|
4
4
|
"description": "A package that contains common classes and components for editor and renderer",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"@atlaskit/media-picker": "^72.1.0",
|
|
65
65
|
"@atlaskit/media-ui": "^30.11.0",
|
|
66
66
|
"@atlaskit/media-viewer": "^54.5.0",
|
|
67
|
-
"@atlaskit/mention": "^27.
|
|
67
|
+
"@atlaskit/mention": "^27.16.0",
|
|
68
68
|
"@atlaskit/menu": "^10.0.0",
|
|
69
69
|
"@atlaskit/object": "^2.2.0",
|
|
70
70
|
"@atlaskit/onboarding": "^15.1.0",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"@atlaskit/task-decision": "^21.8.0",
|
|
85
85
|
"@atlaskit/teams-app-config": "^2.2.0",
|
|
86
86
|
"@atlaskit/textfield": "^10.0.0",
|
|
87
|
-
"@atlaskit/tmp-editor-statsig": "^147.
|
|
87
|
+
"@atlaskit/tmp-editor-statsig": "^147.1.0",
|
|
88
88
|
"@atlaskit/tokens": "^16.7.0",
|
|
89
89
|
"@atlaskit/tooltip": "^24.0.0",
|
|
90
90
|
"@atlaskit/width-detector": "^7.0.0",
|
|
@@ -266,5 +266,11 @@
|
|
|
266
266
|
"platform_editor_embed_height_only_fallback": {
|
|
267
267
|
"type": "boolean"
|
|
268
268
|
}
|
|
269
|
+
},
|
|
270
|
+
"platform-experiments": {
|
|
271
|
+
"platform_editor_mention_node_avatar": {
|
|
272
|
+
"param": "isEnabled",
|
|
273
|
+
"defaultValue": false
|
|
274
|
+
}
|
|
269
275
|
}
|
|
270
276
|
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isSSRStreaming = isSSRStreaming;
|
|
7
|
-
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
8
|
-
/** Returns true if React SSR streaming is actually active at runtime. */
|
|
9
|
-
function isSSRStreaming() {
|
|
10
|
-
try {
|
|
11
|
-
var _process$env;
|
|
12
|
-
var isSSRRendered =
|
|
13
|
-
// In most places there is no document when running on server-side
|
|
14
|
-
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage
|
|
15
|
-
typeof document === 'undefined' || typeof process !== 'undefined' && ((_process$env = process.env) === null || _process$env === void 0 ? void 0 : _process$env.REACT_SSR) || typeof window !== 'undefined' && window.__SSR_RENDERED__ || globalThis.__SSR_RENDERED__;
|
|
16
|
-
var isSSRReactStreaming = typeof window !== 'undefined' && window.__SSR_REACT_STREAMING__ || globalThis.__SSR_REACT_STREAMING__;
|
|
17
|
-
return Boolean(isSSRRendered) && (0, _expValEquals.expValEquals)('platform_editor_editor_ssr_streaming', 'isEnabled', true) && Boolean(isSSRReactStreaming);
|
|
18
|
-
} catch (_unused) {
|
|
19
|
-
// Catch possible error that might occur and just return false
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
2
|
-
/** Returns true if React SSR streaming is actually active at runtime. */
|
|
3
|
-
export function isSSRStreaming() {
|
|
4
|
-
try {
|
|
5
|
-
var _process$env;
|
|
6
|
-
const isSSRRendered =
|
|
7
|
-
// In most places there is no document when running on server-side
|
|
8
|
-
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage
|
|
9
|
-
typeof document === 'undefined' || typeof process !== 'undefined' && ((_process$env = process.env) === null || _process$env === void 0 ? void 0 : _process$env.REACT_SSR) || typeof window !== 'undefined' && window.__SSR_RENDERED__ || globalThis.__SSR_RENDERED__;
|
|
10
|
-
const isSSRReactStreaming = typeof window !== 'undefined' && window.__SSR_REACT_STREAMING__ || globalThis.__SSR_REACT_STREAMING__;
|
|
11
|
-
return Boolean(isSSRRendered) && expValEquals('platform_editor_editor_ssr_streaming', 'isEnabled', true) && Boolean(isSSRReactStreaming);
|
|
12
|
-
} catch {
|
|
13
|
-
// Catch possible error that might occur and just return false
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
2
|
-
/** Returns true if React SSR streaming is actually active at runtime. */
|
|
3
|
-
export function isSSRStreaming() {
|
|
4
|
-
try {
|
|
5
|
-
var _process$env;
|
|
6
|
-
var isSSRRendered =
|
|
7
|
-
// In most places there is no document when running on server-side
|
|
8
|
-
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage
|
|
9
|
-
typeof document === 'undefined' || typeof process !== 'undefined' && ((_process$env = process.env) === null || _process$env === void 0 ? void 0 : _process$env.REACT_SSR) || typeof window !== 'undefined' && window.__SSR_RENDERED__ || globalThis.__SSR_RENDERED__;
|
|
10
|
-
var isSSRReactStreaming = typeof window !== 'undefined' && window.__SSR_REACT_STREAMING__ || globalThis.__SSR_REACT_STREAMING__;
|
|
11
|
-
return Boolean(isSSRRendered) && expValEquals('platform_editor_editor_ssr_streaming', 'isEnabled', true) && Boolean(isSSRReactStreaming);
|
|
12
|
-
} catch (_unused) {
|
|
13
|
-
// Catch possible error that might occur and just return false
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
}
|