@atlaskit/editor-plugin-mentions 13.1.1 → 13.3.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 +86 -0
- package/dist/cjs/mentionsPlugin.js +10 -2
- package/dist/cjs/nodeviews/disabledTooltipRenderer.compiled.css +1 -0
- package/dist/cjs/nodeviews/disabledTooltipRenderer.js +193 -0
- package/dist/cjs/nodeviews/mentionNodeView.js +128 -12
- package/dist/cjs/pm-plugins/main.js +1 -1
- package/dist/es2019/mentionsPlugin.js +10 -2
- package/dist/es2019/nodeviews/disabledTooltipRenderer.compiled.css +1 -0
- package/dist/es2019/nodeviews/disabledTooltipRenderer.js +168 -0
- package/dist/es2019/nodeviews/mentionNodeView.js +123 -12
- package/dist/es2019/pm-plugins/main.js +1 -1
- package/dist/esm/mentionsPlugin.js +10 -2
- package/dist/esm/nodeviews/disabledTooltipRenderer.compiled.css +1 -0
- package/dist/esm/nodeviews/disabledTooltipRenderer.js +184 -0
- package/dist/esm/nodeviews/mentionNodeView.js +128 -12
- package/dist/esm/pm-plugins/main.js +1 -1
- package/dist/types/mentionsPluginType.d.ts +3 -1
- package/dist/types/nodeviews/disabledTooltipRenderer.d.ts +25 -0
- package/dist/types/nodeviews/mentionNodeView.d.ts +18 -1
- package/dist/types-ts4.5/mentionsPluginType.d.ts +3 -1
- package/dist/types-ts4.5/nodeviews/disabledTooltipRenderer.d.ts +25 -0
- package/dist/types-ts4.5/nodeviews/mentionNodeView.d.ts +18 -1
- package/package.json +6 -5
|
@@ -12,6 +12,7 @@ import { isResolvingMentionProvider, MentionNameStatus } from '@atlaskit/mention
|
|
|
12
12
|
import { isRestricted } from '@atlaskit/mention/types';
|
|
13
13
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
14
14
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
15
|
+
import { disabledTooltipRenderer } from './disabledTooltipRenderer';
|
|
15
16
|
import { profileCardRenderer } from './profileCardRenderer';
|
|
16
17
|
var primitiveClassName = 'editor-mention-primitive';
|
|
17
18
|
// @ts-ignore - TS1501 TypeScript 5.9.2 upgrade
|
|
@@ -81,7 +82,10 @@ var handleProviderName = /*#__PURE__*/function () {
|
|
|
81
82
|
return _ref.apply(this, arguments);
|
|
82
83
|
};
|
|
83
84
|
}();
|
|
84
|
-
var getNewState = function getNewState(isHighlighted, isRestricted) {
|
|
85
|
+
var getNewState = function getNewState(isHighlighted, isRestricted, isDisabled) {
|
|
86
|
+
if (isDisabled) {
|
|
87
|
+
return 'disabled';
|
|
88
|
+
}
|
|
85
89
|
if (isHighlighted) {
|
|
86
90
|
return 'self';
|
|
87
91
|
}
|
|
@@ -96,7 +100,6 @@ export var MentionNodeView = /*#__PURE__*/function () {
|
|
|
96
100
|
_api$mention$sharedSt,
|
|
97
101
|
_this = this;
|
|
98
102
|
_classCallCheck(this, MentionNodeView);
|
|
99
|
-
_defineProperty(this, "state", 'default');
|
|
100
103
|
var options = config.options,
|
|
101
104
|
api = config.api,
|
|
102
105
|
portalProviderAPI = config.portalProviderAPI;
|
|
@@ -112,9 +115,11 @@ export var MentionNodeView = /*#__PURE__*/function () {
|
|
|
112
115
|
var _ref2 = (_api$mention$sharedSt = api === null || api === void 0 ? void 0 : api.mention.sharedState.currentState()) !== null && _api$mention$sharedSt !== void 0 ? _api$mention$sharedSt : {},
|
|
113
116
|
mentionProvider = _ref2.mentionProvider;
|
|
114
117
|
this.updateState(mentionProvider);
|
|
118
|
+
this.subscribeToProviderDisabledStateChanges(mentionProvider);
|
|
115
119
|
this.cleanup = api === null || api === void 0 ? void 0 : api.mention.sharedState.onChange(function (_ref3) {
|
|
116
120
|
var nextSharedState = _ref3.nextSharedState;
|
|
117
121
|
_this.updateState(nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.mentionProvider);
|
|
122
|
+
_this.subscribeToProviderDisabledStateChanges(nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.mentionProvider);
|
|
118
123
|
});
|
|
119
124
|
var _profileCardRenderer = profileCardRenderer({
|
|
120
125
|
dom: dom,
|
|
@@ -140,10 +145,93 @@ export var MentionNodeView = /*#__PURE__*/function () {
|
|
|
140
145
|
}
|
|
141
146
|
return _createClass(MentionNodeView, [{
|
|
142
147
|
key: "setClassList",
|
|
143
|
-
value: function setClassList(state) {
|
|
144
|
-
var _this$mentionPrimitiv, _this$mentionPrimitiv2;
|
|
148
|
+
value: function setClassList(state, disabledTooltip) {
|
|
149
|
+
var _this$mentionPrimitiv, _this$mentionPrimitiv2, _this$mentionPrimitiv3;
|
|
145
150
|
(_this$mentionPrimitiv = this.mentionPrimitiveElement) === null || _this$mentionPrimitiv === void 0 || _this$mentionPrimitiv.classList.toggle('mention-self', state === 'self');
|
|
146
151
|
(_this$mentionPrimitiv2 = this.mentionPrimitiveElement) === null || _this$mentionPrimitiv2 === void 0 || _this$mentionPrimitiv2.classList.toggle('mention-restricted', state === 'restricted');
|
|
152
|
+
(_this$mentionPrimitiv3 = this.mentionPrimitiveElement) === null || _this$mentionPrimitiv3 === void 0 || _this$mentionPrimitiv3.classList.toggle('mention-disabled', state === 'disabled');
|
|
153
|
+
// Mirror the React `<Mention>` a11y behaviour: when the chip is
|
|
154
|
+
// disabled, expose `aria-disabled` so assistive tech announces it as
|
|
155
|
+
// such. Also surface the tooltip text via `aria-label` so screen-reader
|
|
156
|
+
// users hear *why* the chip is disabled, matching the React `<Mention>`
|
|
157
|
+
// behaviour at `Mention/index.tsx` line 152.
|
|
158
|
+
if (this.domElement) {
|
|
159
|
+
if (state === 'disabled') {
|
|
160
|
+
this.domElement.setAttribute('aria-disabled', 'true');
|
|
161
|
+
if (disabledTooltip) {
|
|
162
|
+
var text = this.node.attrs.text || '@...';
|
|
163
|
+
this.domElement.setAttribute('aria-label', "".concat(text, " \u2014 ").concat(disabledTooltip));
|
|
164
|
+
}
|
|
165
|
+
} else {
|
|
166
|
+
this.domElement.removeAttribute('aria-disabled');
|
|
167
|
+
this.domElement.removeAttribute('aria-label');
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}, {
|
|
172
|
+
key: "getDisabledState",
|
|
173
|
+
value: function getDisabledState(mentionProvider) {
|
|
174
|
+
var _mentionProvider$getM;
|
|
175
|
+
var input = {
|
|
176
|
+
id: this.node.attrs.id
|
|
177
|
+
};
|
|
178
|
+
return mentionProvider === null || mentionProvider === void 0 || (_mentionProvider$getM = mentionProvider.getMentionDisabledState) === null || _mentionProvider$getM === void 0 ? void 0 : _mentionProvider$getM.call(mentionProvider, input);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Subscribes this NodeView to disabled-state-change notifications on the
|
|
183
|
+
* supplied provider so already-rendered chips can re-evaluate themselves
|
|
184
|
+
* when the consumer's predicate inputs change (e.g. the active agent
|
|
185
|
+
* selection toggling in Rovo Chat). No-op for providers that don't
|
|
186
|
+
* implement `subscribeToDisabledStateChanges`.
|
|
187
|
+
*
|
|
188
|
+
* Idempotent: re-calling with the same provider keeps the existing
|
|
189
|
+
* subscription; passing a different provider tears the old subscription
|
|
190
|
+
* down before attaching the new one. Safe to call from the sharedState
|
|
191
|
+
* `onChange` handler when the editor swaps providers.
|
|
192
|
+
*/
|
|
193
|
+
}, {
|
|
194
|
+
key: "subscribeToProviderDisabledStateChanges",
|
|
195
|
+
value: function subscribeToProviderDisabledStateChanges(mentionProvider) {
|
|
196
|
+
var _this$unsubscribeFrom,
|
|
197
|
+
_this2 = this;
|
|
198
|
+
if (this.subscribedProvider === mentionProvider) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
(_this$unsubscribeFrom = this.unsubscribeFromDisabledStateChanges) === null || _this$unsubscribeFrom === void 0 || _this$unsubscribeFrom.call(this);
|
|
202
|
+
this.unsubscribeFromDisabledStateChanges = undefined;
|
|
203
|
+
this.subscribedProvider = mentionProvider;
|
|
204
|
+
if (!(mentionProvider !== null && mentionProvider !== void 0 && mentionProvider.subscribeToDisabledStateChanges)) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
this.unsubscribeFromDisabledStateChanges = mentionProvider.subscribeToDisabledStateChanges(function () {
|
|
208
|
+
_this2.updateState(_this2.subscribedProvider);
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
}, {
|
|
212
|
+
key: "syncDisabledTooltip",
|
|
213
|
+
value: function syncDisabledTooltip(disabledState) {
|
|
214
|
+
// Capture the tooltip text into a local so the rest of the method can
|
|
215
|
+
// branch on a truthy string instead of re-asserting non-null fields
|
|
216
|
+
// off of `disabledState`.
|
|
217
|
+
var tooltipText = disabledState !== null && disabledState !== void 0 && disabledState.disabled ? disabledState.tooltip : undefined;
|
|
218
|
+
var chip = this.mentionPrimitiveElement;
|
|
219
|
+
var portalProviderAPI = this.config.portalProviderAPI;
|
|
220
|
+
if (!chip || !portalProviderAPI) {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
if (tooltipText) {
|
|
224
|
+
if (!this.disabledTooltip) {
|
|
225
|
+
this.disabledTooltip = disabledTooltipRenderer({
|
|
226
|
+
chipElement: chip,
|
|
227
|
+
portalProviderAPI: portalProviderAPI
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
this.disabledTooltip.setTooltip(tooltipText);
|
|
231
|
+
} else if (this.disabledTooltip) {
|
|
232
|
+
this.disabledTooltip.destroy();
|
|
233
|
+
this.disabledTooltip = undefined;
|
|
234
|
+
}
|
|
147
235
|
}
|
|
148
236
|
}, {
|
|
149
237
|
key: "setTextContent",
|
|
@@ -173,24 +261,34 @@ export var MentionNodeView = /*#__PURE__*/function () {
|
|
|
173
261
|
value: function () {
|
|
174
262
|
var _updateState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(mentionProvider) {
|
|
175
263
|
var _mentionProvider$shou2, _this$config$options2;
|
|
176
|
-
var isHighlighted, newState, name;
|
|
264
|
+
var isHighlighted, disabledState, isDisabled, newState, disabledTooltip, name;
|
|
177
265
|
return _regeneratorRuntime.wrap(function (_context2) {
|
|
178
266
|
while (1) switch (_context2.prev = _context2.next) {
|
|
179
267
|
case 0:
|
|
180
268
|
isHighlighted = expValEquals('platform_editor_vc90_transition_mentions', 'isEnabled', true) ? this.shouldHighlightMention(mentionProvider) : (_mentionProvider$shou2 = mentionProvider === null || mentionProvider === void 0 ? void 0 : mentionProvider.shouldHighlightMention({
|
|
181
269
|
id: this.node.attrs.id
|
|
182
270
|
})) !== null && _mentionProvider$shou2 !== void 0 ? _mentionProvider$shou2 : false;
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
271
|
+
disabledState = this.getDisabledState(mentionProvider);
|
|
272
|
+
isDisabled = !!(disabledState !== null && disabledState !== void 0 && disabledState.disabled);
|
|
273
|
+
newState = getNewState(isHighlighted, isRestricted(this.node.attrs.accessLevel), isDisabled);
|
|
274
|
+
disabledTooltip = disabledState !== null && disabledState !== void 0 && disabledState.disabled ? disabledState.tooltip : undefined; // `setClassList` always runs so the aria-label (which depends on the
|
|
275
|
+
// tooltip text) stays in sync when the tooltip reason changes while
|
|
276
|
+
// the chip remains disabled. State-change-only writes would leave a
|
|
277
|
+
// stale aria-label after a tooltip-text-only update.
|
|
278
|
+
this.setClassList(newState, disabledTooltip);
|
|
279
|
+
// Tooltip wiring runs every update (not just on state change) so that
|
|
280
|
+
// the tooltip text stays in sync if the disabled reason changes while
|
|
281
|
+
// the chip is already disabled.
|
|
282
|
+
this.syncDisabledTooltip(disabledState);
|
|
188
283
|
_context2.next = 1;
|
|
189
284
|
return handleProviderName(mentionProvider, this.node);
|
|
190
285
|
case 1:
|
|
191
286
|
name = _context2.sent;
|
|
192
287
|
this.setTextContent(name);
|
|
193
|
-
|
|
288
|
+
// Only overwrite the disabled-state aria-label with the name-based one
|
|
289
|
+
// when the chip is NOT disabled; otherwise the disabled reason set in
|
|
290
|
+
// `setClassList` would be silently clobbered, regressing a11y.
|
|
291
|
+
if (name && this.domElement && (_this$config$options2 = this.config.options) !== null && _this$config$options2 !== void 0 && _this$config$options2.profilecardProvider && newState !== 'disabled') {
|
|
194
292
|
this.domElement.setAttribute('aria-label', getAccessibilityLabelFromName(name));
|
|
195
293
|
}
|
|
196
294
|
case 2:
|
|
@@ -229,9 +327,27 @@ export var MentionNodeView = /*#__PURE__*/function () {
|
|
|
229
327
|
}, {
|
|
230
328
|
key: "destroy",
|
|
231
329
|
value: function destroy() {
|
|
232
|
-
var _this$cleanup, _this$destroyProfileC;
|
|
330
|
+
var _this$cleanup, _this$destroyProfileC, _this$disabledTooltip, _this$unsubscribeFrom2;
|
|
331
|
+
// Surface the destruction to the provider before tearing down so the
|
|
332
|
+
// chat layer can react (e.g. drop the agent id from `selectedAgentIds`).
|
|
333
|
+
// This is the lowest-level deletion signal — fires for backspace,
|
|
334
|
+
// select-and-delete, programmatic doc replaces, and editor unmount.
|
|
335
|
+
try {
|
|
336
|
+
var _this$subscribedProvi, _this$subscribedProvi2;
|
|
337
|
+
(_this$subscribedProvi = this.subscribedProvider) === null || _this$subscribedProvi === void 0 || (_this$subscribedProvi2 = _this$subscribedProvi.notifyMentionDestroyed) === null || _this$subscribedProvi2 === void 0 || _this$subscribedProvi2.call(_this$subscribedProvi, {
|
|
338
|
+
id: this.node.attrs.id
|
|
339
|
+
});
|
|
340
|
+
} catch (_error) {
|
|
341
|
+
// Defensive: never let consumer-side notification errors prevent
|
|
342
|
+
// the NodeView from cleaning up its own resources below.
|
|
343
|
+
}
|
|
233
344
|
(_this$cleanup = this.cleanup) === null || _this$cleanup === void 0 || _this$cleanup.call(this);
|
|
234
345
|
(_this$destroyProfileC = this.destroyProfileCard) === null || _this$destroyProfileC === void 0 || _this$destroyProfileC.call(this);
|
|
346
|
+
(_this$disabledTooltip = this.disabledTooltip) === null || _this$disabledTooltip === void 0 || _this$disabledTooltip.destroy();
|
|
347
|
+
this.disabledTooltip = undefined;
|
|
348
|
+
(_this$unsubscribeFrom2 = this.unsubscribeFromDisabledStateChanges) === null || _this$unsubscribeFrom2 === void 0 || _this$unsubscribeFrom2.call(this);
|
|
349
|
+
this.unsubscribeFromDisabledStateChanges = undefined;
|
|
350
|
+
this.subscribedProvider = undefined;
|
|
235
351
|
}
|
|
236
352
|
}, {
|
|
237
353
|
key: "deselectNode",
|
|
@@ -24,7 +24,7 @@ export var ACTIONS = {
|
|
|
24
24
|
var AGENT_USER_TYPES = new Set(['APP', 'AGENT']);
|
|
25
25
|
var AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
|
|
26
26
|
var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
|
|
27
|
-
var PACKAGE_VERSION = "13.
|
|
27
|
+
var PACKAGE_VERSION = "13.2.0";
|
|
28
28
|
var setProvider = function setProvider(provider) {
|
|
29
29
|
return function (state, dispatch) {
|
|
30
30
|
if (dispatch) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { NextEditorPlugin, OptionalPlugin, EditorCommand } from '@atlaskit/editor-common/types';
|
|
1
|
+
import type { NextEditorPlugin, OptionalPlugin, EditorCommand, TypeAheadSectionTitleUpdate } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
3
3
|
import type { BasePlugin } from '@atlaskit/editor-plugin-base';
|
|
4
4
|
import type { ContextIdentifierPlugin } from '@atlaskit/editor-plugin-context-identifier';
|
|
@@ -16,10 +16,12 @@ export type MentionActionAnnounceMentionsInsertion = (mentionIds: {
|
|
|
16
16
|
type: 'added' | 'deleted';
|
|
17
17
|
}[]) => void;
|
|
18
18
|
export type MentionActionSetProvider = (provider: Promise<MentionProvider>) => Promise<boolean>;
|
|
19
|
+
export type MentionActionUpdateSectionTitle = (props: TypeAheadSectionTitleUpdate) => boolean;
|
|
19
20
|
export type MentionActions = {
|
|
20
21
|
announceMentionsInsertion: MentionActionAnnounceMentionsInsertion;
|
|
21
22
|
openTypeAhead: MentionActionOpenTypeAhead;
|
|
22
23
|
setProvider: MentionActionSetProvider;
|
|
24
|
+
updateSectionTitle: MentionActionUpdateSectionTitle;
|
|
23
25
|
};
|
|
24
26
|
export type MentionPluginDependencies = [
|
|
25
27
|
OptionalPlugin<AnalyticsPlugin>,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { PortalProviderAPI } from '@atlaskit/editor-common/portal';
|
|
2
|
+
/**
|
|
3
|
+
* Anchors an ADS `<Tooltip>` to a ProseMirror chip element that is **not** a
|
|
4
|
+
* React child of the tooltip. The chip itself stays in the PM document; this
|
|
5
|
+
* renderer mounts an always-present React subtree via `portalProviderAPI` whose
|
|
6
|
+
* sole job is to host the tooltip and forward the ADS-provided trigger ref +
|
|
7
|
+
* event handlers onto the chip.
|
|
8
|
+
*
|
|
9
|
+
* The forwarding is deliberate: ADS `<Tooltip>` expects to attach its hover /
|
|
10
|
+
* focus / blur listeners to its render-prop child, but our render-prop child
|
|
11
|
+
* is a `display: none` placeholder span that no real event can reach. We bridge
|
|
12
|
+
* those listeners to the chip via `addEventListener` so the tooltip opens and
|
|
13
|
+
* closes in response to the user actually interacting with the chip — keyboard
|
|
14
|
+
* focus, mouse hover, screen-reader focus, the lot.
|
|
15
|
+
*/
|
|
16
|
+
export interface DisabledTooltipController {
|
|
17
|
+
/** Tear down the React subtree. */
|
|
18
|
+
destroy: () => void;
|
|
19
|
+
/** Update the tooltip text. Passing `undefined` hides the tooltip. */
|
|
20
|
+
setTooltip: (text: string | undefined) => void;
|
|
21
|
+
}
|
|
22
|
+
export declare const disabledTooltipRenderer: ({ chipElement, portalProviderAPI, }: {
|
|
23
|
+
chipElement: HTMLElement;
|
|
24
|
+
portalProviderAPI: PortalProviderAPI;
|
|
25
|
+
}) => DisabledTooltipController;
|
|
@@ -10,7 +10,6 @@ interface MentionNodeViewProps {
|
|
|
10
10
|
portalProviderAPI: PortalProviderAPI;
|
|
11
11
|
}
|
|
12
12
|
export declare class MentionNodeView implements NodeView {
|
|
13
|
-
private state;
|
|
14
13
|
dom: Node;
|
|
15
14
|
domElement: HTMLElement | undefined;
|
|
16
15
|
contentDOM: HTMLElement | undefined;
|
|
@@ -20,8 +19,26 @@ export declare class MentionNodeView implements NodeView {
|
|
|
20
19
|
private destroyProfileCard;
|
|
21
20
|
private removeProfileCard;
|
|
22
21
|
private mentionPrimitiveElement;
|
|
22
|
+
private disabledTooltip;
|
|
23
|
+
private unsubscribeFromDisabledStateChanges;
|
|
24
|
+
private subscribedProvider;
|
|
23
25
|
constructor(node: PMNode, config: MentionNodeViewProps);
|
|
24
26
|
private setClassList;
|
|
27
|
+
private getDisabledState;
|
|
28
|
+
/**
|
|
29
|
+
* Subscribes this NodeView to disabled-state-change notifications on the
|
|
30
|
+
* supplied provider so already-rendered chips can re-evaluate themselves
|
|
31
|
+
* when the consumer's predicate inputs change (e.g. the active agent
|
|
32
|
+
* selection toggling in Rovo Chat). No-op for providers that don't
|
|
33
|
+
* implement `subscribeToDisabledStateChanges`.
|
|
34
|
+
*
|
|
35
|
+
* Idempotent: re-calling with the same provider keeps the existing
|
|
36
|
+
* subscription; passing a different provider tears the old subscription
|
|
37
|
+
* down before attaching the new one. Safe to call from the sharedState
|
|
38
|
+
* `onChange` handler when the editor swaps providers.
|
|
39
|
+
*/
|
|
40
|
+
private subscribeToProviderDisabledStateChanges;
|
|
41
|
+
private syncDisabledTooltip;
|
|
25
42
|
private setTextContent;
|
|
26
43
|
private shouldHighlightMention;
|
|
27
44
|
private updateState;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { NextEditorPlugin, OptionalPlugin, EditorCommand } from '@atlaskit/editor-common/types';
|
|
1
|
+
import type { NextEditorPlugin, OptionalPlugin, EditorCommand, TypeAheadSectionTitleUpdate } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
3
3
|
import type { BasePlugin } from '@atlaskit/editor-plugin-base';
|
|
4
4
|
import type { ContextIdentifierPlugin } from '@atlaskit/editor-plugin-context-identifier';
|
|
@@ -16,10 +16,12 @@ export type MentionActionAnnounceMentionsInsertion = (mentionIds: {
|
|
|
16
16
|
type: 'added' | 'deleted';
|
|
17
17
|
}[]) => void;
|
|
18
18
|
export type MentionActionSetProvider = (provider: Promise<MentionProvider>) => Promise<boolean>;
|
|
19
|
+
export type MentionActionUpdateSectionTitle = (props: TypeAheadSectionTitleUpdate) => boolean;
|
|
19
20
|
export type MentionActions = {
|
|
20
21
|
announceMentionsInsertion: MentionActionAnnounceMentionsInsertion;
|
|
21
22
|
openTypeAhead: MentionActionOpenTypeAhead;
|
|
22
23
|
setProvider: MentionActionSetProvider;
|
|
24
|
+
updateSectionTitle: MentionActionUpdateSectionTitle;
|
|
23
25
|
};
|
|
24
26
|
export type MentionPluginDependencies = [
|
|
25
27
|
OptionalPlugin<AnalyticsPlugin>,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { PortalProviderAPI } from '@atlaskit/editor-common/portal';
|
|
2
|
+
/**
|
|
3
|
+
* Anchors an ADS `<Tooltip>` to a ProseMirror chip element that is **not** a
|
|
4
|
+
* React child of the tooltip. The chip itself stays in the PM document; this
|
|
5
|
+
* renderer mounts an always-present React subtree via `portalProviderAPI` whose
|
|
6
|
+
* sole job is to host the tooltip and forward the ADS-provided trigger ref +
|
|
7
|
+
* event handlers onto the chip.
|
|
8
|
+
*
|
|
9
|
+
* The forwarding is deliberate: ADS `<Tooltip>` expects to attach its hover /
|
|
10
|
+
* focus / blur listeners to its render-prop child, but our render-prop child
|
|
11
|
+
* is a `display: none` placeholder span that no real event can reach. We bridge
|
|
12
|
+
* those listeners to the chip via `addEventListener` so the tooltip opens and
|
|
13
|
+
* closes in response to the user actually interacting with the chip — keyboard
|
|
14
|
+
* focus, mouse hover, screen-reader focus, the lot.
|
|
15
|
+
*/
|
|
16
|
+
export interface DisabledTooltipController {
|
|
17
|
+
/** Tear down the React subtree. */
|
|
18
|
+
destroy: () => void;
|
|
19
|
+
/** Update the tooltip text. Passing `undefined` hides the tooltip. */
|
|
20
|
+
setTooltip: (text: string | undefined) => void;
|
|
21
|
+
}
|
|
22
|
+
export declare const disabledTooltipRenderer: ({ chipElement, portalProviderAPI, }: {
|
|
23
|
+
chipElement: HTMLElement;
|
|
24
|
+
portalProviderAPI: PortalProviderAPI;
|
|
25
|
+
}) => DisabledTooltipController;
|
|
@@ -10,7 +10,6 @@ interface MentionNodeViewProps {
|
|
|
10
10
|
portalProviderAPI: PortalProviderAPI;
|
|
11
11
|
}
|
|
12
12
|
export declare class MentionNodeView implements NodeView {
|
|
13
|
-
private state;
|
|
14
13
|
dom: Node;
|
|
15
14
|
domElement: HTMLElement | undefined;
|
|
16
15
|
contentDOM: HTMLElement | undefined;
|
|
@@ -20,8 +19,26 @@ export declare class MentionNodeView implements NodeView {
|
|
|
20
19
|
private destroyProfileCard;
|
|
21
20
|
private removeProfileCard;
|
|
22
21
|
private mentionPrimitiveElement;
|
|
22
|
+
private disabledTooltip;
|
|
23
|
+
private unsubscribeFromDisabledStateChanges;
|
|
24
|
+
private subscribedProvider;
|
|
23
25
|
constructor(node: PMNode, config: MentionNodeViewProps);
|
|
24
26
|
private setClassList;
|
|
27
|
+
private getDisabledState;
|
|
28
|
+
/**
|
|
29
|
+
* Subscribes this NodeView to disabled-state-change notifications on the
|
|
30
|
+
* supplied provider so already-rendered chips can re-evaluate themselves
|
|
31
|
+
* when the consumer's predicate inputs change (e.g. the active agent
|
|
32
|
+
* selection toggling in Rovo Chat). No-op for providers that don't
|
|
33
|
+
* implement `subscribeToDisabledStateChanges`.
|
|
34
|
+
*
|
|
35
|
+
* Idempotent: re-calling with the same provider keeps the existing
|
|
36
|
+
* subscription; passing a different provider tears the old subscription
|
|
37
|
+
* down before attaching the new one. Safe to call from the sharedState
|
|
38
|
+
* `onChange` handler when the editor swaps providers.
|
|
39
|
+
*/
|
|
40
|
+
private subscribeToProviderDisabledStateChanges;
|
|
41
|
+
private syncDisabledTooltip;
|
|
25
42
|
private setTextContent;
|
|
26
43
|
private shouldHighlightMention;
|
|
27
44
|
private updateState;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-mentions",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.3.0",
|
|
4
4
|
"description": "Mentions plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -35,12 +35,12 @@
|
|
|
35
35
|
"@atlaskit/editor-plugin-base": "^12.0.0",
|
|
36
36
|
"@atlaskit/editor-plugin-context-identifier": "^11.0.0",
|
|
37
37
|
"@atlaskit/editor-plugin-selection": "^11.0.0",
|
|
38
|
-
"@atlaskit/editor-plugin-type-ahead": "^11.
|
|
38
|
+
"@atlaskit/editor-plugin-type-ahead": "^11.1.0",
|
|
39
39
|
"@atlaskit/editor-prosemirror": "^7.3.0",
|
|
40
40
|
"@atlaskit/icon": "^35.4.0",
|
|
41
41
|
"@atlaskit/insm": "^0.4.0",
|
|
42
42
|
"@atlaskit/link": "^3.4.0",
|
|
43
|
-
"@atlaskit/mention": "^26.
|
|
43
|
+
"@atlaskit/mention": "^26.2.0",
|
|
44
44
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
45
45
|
"@atlaskit/popper": "^7.2.0",
|
|
46
46
|
"@atlaskit/portal": "^5.5.0",
|
|
@@ -48,8 +48,9 @@
|
|
|
48
48
|
"@atlaskit/profilecard": "^25.8.0",
|
|
49
49
|
"@atlaskit/teams-app-config": "^1.12.0",
|
|
50
50
|
"@atlaskit/theme": "^25.0.0",
|
|
51
|
-
"@atlaskit/tmp-editor-statsig": "^89.
|
|
51
|
+
"@atlaskit/tmp-editor-statsig": "^89.1.0",
|
|
52
52
|
"@atlaskit/tokens": "^13.1.0",
|
|
53
|
+
"@atlaskit/tooltip": "^22.6.0",
|
|
53
54
|
"@atlaskit/user-picker": "^12.1.0",
|
|
54
55
|
"@babel/runtime": "^7.0.0",
|
|
55
56
|
"@compiled/react": "^0.20.0",
|
|
@@ -59,7 +60,7 @@
|
|
|
59
60
|
"uuid": "^3.1.0"
|
|
60
61
|
},
|
|
61
62
|
"peerDependencies": {
|
|
62
|
-
"@atlaskit/editor-common": "^115.
|
|
63
|
+
"@atlaskit/editor-common": "^115.5.0",
|
|
63
64
|
"react": "^18.2.0",
|
|
64
65
|
"react-dom": "^18.2.0",
|
|
65
66
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|