@atlaskit/editor-plugin-mentions 32.1.7 → 32.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/dist/cjs/nodeviews/mentionNodeView.js +5 -31
- package/dist/cjs/pm-plugins/main.js +1 -1
- package/dist/es2019/nodeviews/mentionNodeView.js +5 -33
- package/dist/es2019/pm-plugins/main.js +1 -1
- package/dist/esm/nodeviews/mentionNodeView.js +5 -31
- package/dist/esm/pm-plugins/main.js +1 -1
- package/dist/types/nodeviews/mentionNodeView.d.ts +0 -1
- package/package.json +5 -5
- package/dist/cjs/nodeviews/disabledTooltipRenderer.compiled.css +0 -1
- package/dist/cjs/nodeviews/disabledTooltipRenderer.js +0 -193
- package/dist/es2019/nodeviews/disabledTooltipRenderer.compiled.css +0 -1
- package/dist/es2019/nodeviews/disabledTooltipRenderer.js +0 -168
- package/dist/esm/nodeviews/disabledTooltipRenderer.compiled.css +0 -1
- package/dist/esm/nodeviews/disabledTooltipRenderer.js +0 -184
- package/dist/types/nodeviews/disabledTooltipRenderer.d.ts +0 -25
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-mentions
|
|
2
2
|
|
|
3
|
+
## 32.1.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`49fcffc905097`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/49fcffc905097) -
|
|
8
|
+
Clean up experiment `platform_editor_use_vanilla_components`, keeping the shipped vanilla DOM
|
|
9
|
+
tooltip implementations and removing the React-based control paths.
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 32.1.8
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
3
18
|
## 32.1.7
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -23,7 +23,6 @@ var _types = require("@atlaskit/mention/types");
|
|
|
23
23
|
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
24
24
|
var _fg = require("@atlaskit/platform-feature-flags/fg");
|
|
25
25
|
var _expVal = require("@atlaskit/tmp-editor-statsig/expVal");
|
|
26
|
-
var _disabledTooltipRenderer = require("./disabledTooltipRenderer");
|
|
27
26
|
var _mentionAvatarRenderer = require("./mentionAvatarRenderer");
|
|
28
27
|
var _profileCardRenderer2 = require("./profileCardRenderer");
|
|
29
28
|
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; }
|
|
@@ -523,27 +522,7 @@ var MentionNodeView = exports.MentionNodeView = /*#__PURE__*/function () {
|
|
|
523
522
|
// branch on a truthy string instead of re-asserting non-null fields
|
|
524
523
|
// off of `disabledState`.
|
|
525
524
|
var tooltipText = disabledState !== null && disabledState !== void 0 && disabledState.disabled ? disabledState.tooltip : undefined;
|
|
526
|
-
|
|
527
|
-
this.syncVanillaDisabledTooltip(tooltipText);
|
|
528
|
-
return;
|
|
529
|
-
}
|
|
530
|
-
var chip = this.mentionPrimitiveElement;
|
|
531
|
-
var portalProviderAPI = this.config.portalProviderAPI;
|
|
532
|
-
if (!chip || !portalProviderAPI) {
|
|
533
|
-
return;
|
|
534
|
-
}
|
|
535
|
-
if (tooltipText) {
|
|
536
|
-
if (!this.disabledTooltip) {
|
|
537
|
-
this.disabledTooltip = (0, _disabledTooltipRenderer.disabledTooltipRenderer)({
|
|
538
|
-
chipElement: chip,
|
|
539
|
-
portalProviderAPI: portalProviderAPI
|
|
540
|
-
});
|
|
541
|
-
}
|
|
542
|
-
this.disabledTooltip.setTooltip(tooltipText);
|
|
543
|
-
} else if (this.disabledTooltip) {
|
|
544
|
-
this.disabledTooltip.destroy();
|
|
545
|
-
this.disabledTooltip = undefined;
|
|
546
|
-
}
|
|
525
|
+
this.syncVanillaDisabledTooltip(tooltipText);
|
|
547
526
|
}
|
|
548
527
|
}, {
|
|
549
528
|
key: "setTextContent",
|
|
@@ -691,7 +670,7 @@ var MentionNodeView = exports.MentionNodeView = /*#__PURE__*/function () {
|
|
|
691
670
|
}, {
|
|
692
671
|
key: "destroy",
|
|
693
672
|
value: function destroy() {
|
|
694
|
-
var _this$cleanup, _this$cleanupRovoChat2, _this$destroyProfileC, _this$mentionAvatar, _this$
|
|
673
|
+
var _this$cleanup, _this$cleanupRovoChat2, _this$destroyProfileC, _this$mentionAvatar, _this$vanillaDisabled2, _this$unsubscribeFrom2;
|
|
695
674
|
this.isDestroyed = true;
|
|
696
675
|
// Surface the destruction to the provider before tearing down so the
|
|
697
676
|
// chat layer can react (e.g. drop the agent id from `selectedAgentIds`).
|
|
@@ -712,14 +691,9 @@ var MentionNodeView = exports.MentionNodeView = /*#__PURE__*/function () {
|
|
|
712
691
|
(_this$destroyProfileC = this.destroyProfileCard) === null || _this$destroyProfileC === void 0 || _this$destroyProfileC.call(this);
|
|
713
692
|
(_this$mentionAvatar = this.mentionAvatar) === null || _this$mentionAvatar === void 0 || _this$mentionAvatar.destroy();
|
|
714
693
|
this.mentionAvatar = undefined;
|
|
715
|
-
(_this$
|
|
716
|
-
this.
|
|
717
|
-
|
|
718
|
-
var _this$vanillaDisabled2;
|
|
719
|
-
(_this$vanillaDisabled2 = this.vanillaDisabledTooltip) === null || _this$vanillaDisabled2 === void 0 || _this$vanillaDisabled2.destroy();
|
|
720
|
-
this.vanillaDisabledTooltip = undefined;
|
|
721
|
-
this.vanillaDisabledTooltipText = undefined;
|
|
722
|
-
}
|
|
694
|
+
(_this$vanillaDisabled2 = this.vanillaDisabledTooltip) === null || _this$vanillaDisabled2 === void 0 || _this$vanillaDisabled2.destroy();
|
|
695
|
+
this.vanillaDisabledTooltip = undefined;
|
|
696
|
+
this.vanillaDisabledTooltipText = undefined;
|
|
723
697
|
(_this$unsubscribeFrom2 = this.unsubscribeFromDisabledStateChanges) === null || _this$unsubscribeFrom2 === void 0 || _this$unsubscribeFrom2.call(this);
|
|
724
698
|
this.unsubscribeFromDisabledStateChanges = undefined;
|
|
725
699
|
this.subscribedProvider = undefined;
|
|
@@ -45,7 +45,7 @@ var ACTIONS = exports.ACTIONS = {
|
|
|
45
45
|
CLEAR_PENDING_PASTED_AGENT_MENTION: 'CLEAR_PENDING_PASTED_AGENT_MENTION'
|
|
46
46
|
};
|
|
47
47
|
var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
|
|
48
|
-
var PACKAGE_VERSION = "32.1.
|
|
48
|
+
var PACKAGE_VERSION = "32.1.8";
|
|
49
49
|
var setProvider = function setProvider(provider) {
|
|
50
50
|
return function (state, dispatch) {
|
|
51
51
|
if (dispatch) {
|
|
@@ -14,7 +14,6 @@ import { MentionNameStatus } from '@atlaskit/mention/types';
|
|
|
14
14
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
15
15
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
16
16
|
import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
|
|
17
|
-
import { disabledTooltipRenderer } from './disabledTooltipRenderer';
|
|
18
17
|
import { mentionAvatarRenderer } from './mentionAvatarRenderer';
|
|
19
18
|
import { profileCardRenderer } from './profileCardRenderer';
|
|
20
19
|
const primitiveClassName = 'editor-mention-primitive';
|
|
@@ -420,29 +419,7 @@ export class MentionNodeView {
|
|
|
420
419
|
// branch on a truthy string instead of re-asserting non-null fields
|
|
421
420
|
// off of `disabledState`.
|
|
422
421
|
const tooltipText = disabledState !== null && disabledState !== void 0 && disabledState.disabled ? disabledState.tooltip : undefined;
|
|
423
|
-
|
|
424
|
-
this.syncVanillaDisabledTooltip(tooltipText);
|
|
425
|
-
return;
|
|
426
|
-
}
|
|
427
|
-
const chip = this.mentionPrimitiveElement;
|
|
428
|
-
const {
|
|
429
|
-
portalProviderAPI
|
|
430
|
-
} = this.config;
|
|
431
|
-
if (!chip || !portalProviderAPI) {
|
|
432
|
-
return;
|
|
433
|
-
}
|
|
434
|
-
if (tooltipText) {
|
|
435
|
-
if (!this.disabledTooltip) {
|
|
436
|
-
this.disabledTooltip = disabledTooltipRenderer({
|
|
437
|
-
chipElement: chip,
|
|
438
|
-
portalProviderAPI
|
|
439
|
-
});
|
|
440
|
-
}
|
|
441
|
-
this.disabledTooltip.setTooltip(tooltipText);
|
|
442
|
-
} else if (this.disabledTooltip) {
|
|
443
|
-
this.disabledTooltip.destroy();
|
|
444
|
-
this.disabledTooltip = undefined;
|
|
445
|
-
}
|
|
422
|
+
this.syncVanillaDisabledTooltip(tooltipText);
|
|
446
423
|
}
|
|
447
424
|
setTextContent(name, isAgentMentionsEnabled) {
|
|
448
425
|
// Also overwrite when text is a raw AAID so the resolved name takes precedence.
|
|
@@ -558,7 +535,7 @@ export class MentionNodeView {
|
|
|
558
535
|
return true;
|
|
559
536
|
}
|
|
560
537
|
destroy() {
|
|
561
|
-
var _this$cleanup, _this$cleanupRovoChat2, _this$destroyProfileC, _this$mentionAvatar2, _this$
|
|
538
|
+
var _this$cleanup, _this$cleanupRovoChat2, _this$destroyProfileC, _this$mentionAvatar2, _this$vanillaDisabled2, _this$unsubscribeFrom2;
|
|
562
539
|
this.isDestroyed = true;
|
|
563
540
|
// Surface the destruction to the provider before tearing down so the
|
|
564
541
|
// chat layer can react (e.g. drop the agent id from `selectedAgentIds`).
|
|
@@ -579,14 +556,9 @@ export class MentionNodeView {
|
|
|
579
556
|
(_this$destroyProfileC = this.destroyProfileCard) === null || _this$destroyProfileC === void 0 ? void 0 : _this$destroyProfileC.call(this);
|
|
580
557
|
(_this$mentionAvatar2 = this.mentionAvatar) === null || _this$mentionAvatar2 === void 0 ? void 0 : _this$mentionAvatar2.destroy();
|
|
581
558
|
this.mentionAvatar = undefined;
|
|
582
|
-
(_this$
|
|
583
|
-
this.
|
|
584
|
-
|
|
585
|
-
var _this$vanillaDisabled2;
|
|
586
|
-
(_this$vanillaDisabled2 = this.vanillaDisabledTooltip) === null || _this$vanillaDisabled2 === void 0 ? void 0 : _this$vanillaDisabled2.destroy();
|
|
587
|
-
this.vanillaDisabledTooltip = undefined;
|
|
588
|
-
this.vanillaDisabledTooltipText = undefined;
|
|
589
|
-
}
|
|
559
|
+
(_this$vanillaDisabled2 = this.vanillaDisabledTooltip) === null || _this$vanillaDisabled2 === void 0 ? void 0 : _this$vanillaDisabled2.destroy();
|
|
560
|
+
this.vanillaDisabledTooltip = undefined;
|
|
561
|
+
this.vanillaDisabledTooltipText = undefined;
|
|
590
562
|
(_this$unsubscribeFrom2 = this.unsubscribeFromDisabledStateChanges) === null || _this$unsubscribeFrom2 === void 0 ? void 0 : _this$unsubscribeFrom2.call(this);
|
|
591
563
|
this.unsubscribeFromDisabledStateChanges = undefined;
|
|
592
564
|
this.subscribedProvider = undefined;
|
|
@@ -34,7 +34,7 @@ export const ACTIONS = {
|
|
|
34
34
|
CLEAR_PENDING_PASTED_AGENT_MENTION: 'CLEAR_PENDING_PASTED_AGENT_MENTION'
|
|
35
35
|
};
|
|
36
36
|
const PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
|
|
37
|
-
const PACKAGE_VERSION = "32.1.
|
|
37
|
+
const PACKAGE_VERSION = "32.1.8";
|
|
38
38
|
const setProvider = provider => (state, dispatch) => {
|
|
39
39
|
if (dispatch) {
|
|
40
40
|
dispatch(state.tr.setMeta(mentionPluginKey, {
|
|
@@ -20,7 +20,6 @@ import { MentionNameStatus } from '@atlaskit/mention/types';
|
|
|
20
20
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
21
21
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
22
22
|
import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
|
|
23
|
-
import { disabledTooltipRenderer } from './disabledTooltipRenderer';
|
|
24
23
|
import { mentionAvatarRenderer } from './mentionAvatarRenderer';
|
|
25
24
|
import { profileCardRenderer } from './profileCardRenderer';
|
|
26
25
|
var primitiveClassName = 'editor-mention-primitive';
|
|
@@ -518,27 +517,7 @@ export var MentionNodeView = /*#__PURE__*/function () {
|
|
|
518
517
|
// branch on a truthy string instead of re-asserting non-null fields
|
|
519
518
|
// off of `disabledState`.
|
|
520
519
|
var tooltipText = disabledState !== null && disabledState !== void 0 && disabledState.disabled ? disabledState.tooltip : undefined;
|
|
521
|
-
|
|
522
|
-
this.syncVanillaDisabledTooltip(tooltipText);
|
|
523
|
-
return;
|
|
524
|
-
}
|
|
525
|
-
var chip = this.mentionPrimitiveElement;
|
|
526
|
-
var portalProviderAPI = this.config.portalProviderAPI;
|
|
527
|
-
if (!chip || !portalProviderAPI) {
|
|
528
|
-
return;
|
|
529
|
-
}
|
|
530
|
-
if (tooltipText) {
|
|
531
|
-
if (!this.disabledTooltip) {
|
|
532
|
-
this.disabledTooltip = disabledTooltipRenderer({
|
|
533
|
-
chipElement: chip,
|
|
534
|
-
portalProviderAPI: portalProviderAPI
|
|
535
|
-
});
|
|
536
|
-
}
|
|
537
|
-
this.disabledTooltip.setTooltip(tooltipText);
|
|
538
|
-
} else if (this.disabledTooltip) {
|
|
539
|
-
this.disabledTooltip.destroy();
|
|
540
|
-
this.disabledTooltip = undefined;
|
|
541
|
-
}
|
|
520
|
+
this.syncVanillaDisabledTooltip(tooltipText);
|
|
542
521
|
}
|
|
543
522
|
}, {
|
|
544
523
|
key: "setTextContent",
|
|
@@ -686,7 +665,7 @@ export var MentionNodeView = /*#__PURE__*/function () {
|
|
|
686
665
|
}, {
|
|
687
666
|
key: "destroy",
|
|
688
667
|
value: function destroy() {
|
|
689
|
-
var _this$cleanup, _this$cleanupRovoChat2, _this$destroyProfileC, _this$mentionAvatar, _this$
|
|
668
|
+
var _this$cleanup, _this$cleanupRovoChat2, _this$destroyProfileC, _this$mentionAvatar, _this$vanillaDisabled2, _this$unsubscribeFrom2;
|
|
690
669
|
this.isDestroyed = true;
|
|
691
670
|
// Surface the destruction to the provider before tearing down so the
|
|
692
671
|
// chat layer can react (e.g. drop the agent id from `selectedAgentIds`).
|
|
@@ -707,14 +686,9 @@ export var MentionNodeView = /*#__PURE__*/function () {
|
|
|
707
686
|
(_this$destroyProfileC = this.destroyProfileCard) === null || _this$destroyProfileC === void 0 || _this$destroyProfileC.call(this);
|
|
708
687
|
(_this$mentionAvatar = this.mentionAvatar) === null || _this$mentionAvatar === void 0 || _this$mentionAvatar.destroy();
|
|
709
688
|
this.mentionAvatar = undefined;
|
|
710
|
-
(_this$
|
|
711
|
-
this.
|
|
712
|
-
|
|
713
|
-
var _this$vanillaDisabled2;
|
|
714
|
-
(_this$vanillaDisabled2 = this.vanillaDisabledTooltip) === null || _this$vanillaDisabled2 === void 0 || _this$vanillaDisabled2.destroy();
|
|
715
|
-
this.vanillaDisabledTooltip = undefined;
|
|
716
|
-
this.vanillaDisabledTooltipText = undefined;
|
|
717
|
-
}
|
|
689
|
+
(_this$vanillaDisabled2 = this.vanillaDisabledTooltip) === null || _this$vanillaDisabled2 === void 0 || _this$vanillaDisabled2.destroy();
|
|
690
|
+
this.vanillaDisabledTooltip = undefined;
|
|
691
|
+
this.vanillaDisabledTooltipText = undefined;
|
|
718
692
|
(_this$unsubscribeFrom2 = this.unsubscribeFromDisabledStateChanges) === null || _this$unsubscribeFrom2 === void 0 || _this$unsubscribeFrom2.call(this);
|
|
719
693
|
this.unsubscribeFromDisabledStateChanges = undefined;
|
|
720
694
|
this.subscribedProvider = undefined;
|
|
@@ -37,7 +37,7 @@ export var ACTIONS = {
|
|
|
37
37
|
CLEAR_PENDING_PASTED_AGENT_MENTION: 'CLEAR_PENDING_PASTED_AGENT_MENTION'
|
|
38
38
|
};
|
|
39
39
|
var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
|
|
40
|
-
var PACKAGE_VERSION = "32.1.
|
|
40
|
+
var PACKAGE_VERSION = "32.1.8";
|
|
41
41
|
var setProvider = function setProvider(provider) {
|
|
42
42
|
return function (state, dispatch) {
|
|
43
43
|
if (dispatch) {
|
|
@@ -28,7 +28,6 @@ export declare class MentionNodeView implements NodeView {
|
|
|
28
28
|
private hasRovoChatStyles;
|
|
29
29
|
private hasAvatarSlot;
|
|
30
30
|
private isDestroyed;
|
|
31
|
-
private disabledTooltip;
|
|
32
31
|
private vanillaDisabledTooltip;
|
|
33
32
|
private vanillaDisabledTooltipText;
|
|
34
33
|
private unsubscribeFromDisabledStateChanges;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-mentions",
|
|
3
|
-
"version": "32.1.
|
|
3
|
+
"version": "32.1.9",
|
|
4
4
|
"description": "Mentions plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -41,13 +41,13 @@
|
|
|
41
41
|
"@atlaskit/popper": "^9.4.0",
|
|
42
42
|
"@atlaskit/popup": "^10.2.0",
|
|
43
43
|
"@atlaskit/portal": "^7.1.0",
|
|
44
|
-
"@atlaskit/primitives": "^22.
|
|
44
|
+
"@atlaskit/primitives": "^22.7.0",
|
|
45
45
|
"@atlaskit/profilecard": "^27.6.0",
|
|
46
46
|
"@atlaskit/section-message": "^10.2.0",
|
|
47
47
|
"@atlaskit/teams-app-config": "^3.1.0",
|
|
48
48
|
"@atlaskit/theme": "^28.2.0",
|
|
49
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
50
|
-
"@atlaskit/tokens": "^20.
|
|
49
|
+
"@atlaskit/tmp-editor-statsig": "^259.0.0",
|
|
50
|
+
"@atlaskit/tokens": "^20.10.0",
|
|
51
51
|
"@atlaskit/tooltip": "^24.4.0",
|
|
52
52
|
"@atlaskit/user-picker": "^14.5.0",
|
|
53
53
|
"@babel/runtime": "^7.0.0",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@atlaskit/button": "^25.7.0",
|
|
69
69
|
"@atlaskit/editor-common": "^134.9.0",
|
|
70
|
-
"@atlaskit/editor-core": "^242.
|
|
70
|
+
"@atlaskit/editor-core": "^242.1.0",
|
|
71
71
|
"@atlassian/workbench": "workspace:*",
|
|
72
72
|
"react": "^19.2.0",
|
|
73
73
|
"react-dom": "^19.2.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
._1e0cglyw{display:none}
|
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
/* disabledTooltipRenderer.tsx generated by @compiled/babel-plugin v3.0.2 */
|
|
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.disabledTooltipRenderer = void 0;
|
|
10
|
-
require("./disabledTooltipRenderer.compiled.css");
|
|
11
|
-
var _runtime = require("@compiled/react/runtime");
|
|
12
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
14
|
-
var _bindEventListener = require("bind-event-listener");
|
|
15
|
-
var _uuid = require("uuid");
|
|
16
|
-
var _Tooltip = _interopRequireDefault(require("@atlaskit/tooltip/Tooltip"));
|
|
17
|
-
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); }
|
|
18
|
-
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- mirror existing renderer pattern
|
|
19
|
-
var styles = {
|
|
20
|
-
hiddenTrigger: "_1e0cglyw"
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* ADS `<Tooltip>` hands us a ref via its render-prop child. That ref may be
|
|
25
|
-
* either a callback ref or a mutable ref object — React supports both shapes
|
|
26
|
-
* and ADS's typing keeps both possible. This helper assigns the supplied
|
|
27
|
-
* element to whichever ref shape was provided so the tooltip ends up using
|
|
28
|
-
* the chip's bounding box for positioning and its DOM for trigger events.
|
|
29
|
-
*/
|
|
30
|
-
var assignRef = function assignRef(ref, element) {
|
|
31
|
-
if (typeof ref === 'function') {
|
|
32
|
-
ref(element);
|
|
33
|
-
} else if (ref) {
|
|
34
|
-
ref.current = element;
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Names of the React-style trigger-prop handlers we forward from ADS
|
|
40
|
-
* `<Tooltip>` onto the chip element.
|
|
41
|
-
*/
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Maps each React-style trigger-prop handler ADS `<Tooltip>` hands us in its
|
|
45
|
-
* render-prop callback to the DOM event name we attach to the chip via
|
|
46
|
-
* `bind-event-listener`. The chip lives in the ProseMirror document and is
|
|
47
|
-
* not a React child of the tooltip, so we have to bridge React handlers to
|
|
48
|
-
* native event listeners ourselves.
|
|
49
|
-
*
|
|
50
|
-
* Names are listed in the same order ADS internally registers them.
|
|
51
|
-
*/
|
|
52
|
-
var TRIGGER_EVENT_MAP = [['onMouseOver', 'mouseover'], ['onMouseOut', 'mouseout'], ['onMouseMove', 'mousemove'], ['onMouseDown', 'mousedown'], ['onFocus', 'focusin'], ['onBlur', 'focusout']];
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Anchors an ADS `<Tooltip>` to a ProseMirror chip element that is **not** a
|
|
56
|
-
* React child of the tooltip. The chip itself stays in the PM document; this
|
|
57
|
-
* renderer mounts an always-present React subtree via `portalProviderAPI` whose
|
|
58
|
-
* sole job is to host the tooltip and forward the ADS-provided trigger ref +
|
|
59
|
-
* event handlers onto the chip.
|
|
60
|
-
*
|
|
61
|
-
* The forwarding is deliberate: ADS `<Tooltip>` expects to attach its hover /
|
|
62
|
-
* focus / blur listeners to its render-prop child, but our render-prop child
|
|
63
|
-
* is a `display: none` placeholder span that no real event can reach. We bridge
|
|
64
|
-
* those listeners to the chip via `addEventListener` so the tooltip opens and
|
|
65
|
-
* closes in response to the user actually interacting with the chip — keyboard
|
|
66
|
-
* focus, mouse hover, screen-reader focus, the lot.
|
|
67
|
-
*/
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Hook that mirrors ADS Tooltip's React trigger props onto a DOM element
|
|
71
|
-
* which is not a React child of the tooltip. Re-attaches whenever ADS hands
|
|
72
|
-
* us a fresh set of props (which happens on every render of the render-prop
|
|
73
|
-
* child) and cleans up on unmount.
|
|
74
|
-
*
|
|
75
|
-
* We use `bind-event-listener`'s `bindAll` rather than raw
|
|
76
|
-
* `addEventListener` / `removeEventListener` calls so the lifetime of every
|
|
77
|
-
* subscription is paired with a single `UnbindFn` — the AFM-mandated pattern
|
|
78
|
-
* for keeping listener bookkeeping leak-free.
|
|
79
|
-
*/
|
|
80
|
-
var useBridgedTriggerListeners = function useBridgedTriggerListeners(chip, triggerProps) {
|
|
81
|
-
(0, _react.useEffect)(function () {
|
|
82
|
-
// Build the bindAll bindings array out of only the handlers ADS actually
|
|
83
|
-
// supplied. Each React handler is wrapped in a thin adapter so the
|
|
84
|
-
// listener signature matches the native `EventListener` shape; ADS
|
|
85
|
-
// handlers ignore the synthetic-event-only fields they don't use
|
|
86
|
-
// (target, currentTarget), so passing the raw DOM event through
|
|
87
|
-
// `unknown` is safe in practice.
|
|
88
|
-
var bindings = TRIGGER_EVENT_MAP.flatMap(function (_ref) {
|
|
89
|
-
var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
|
|
90
|
-
propName = _ref2[0],
|
|
91
|
-
eventName = _ref2[1];
|
|
92
|
-
var handler = triggerProps[propName];
|
|
93
|
-
if (!handler) {
|
|
94
|
-
return [];
|
|
95
|
-
}
|
|
96
|
-
return [{
|
|
97
|
-
type: eventName,
|
|
98
|
-
listener: function listener(event) {
|
|
99
|
-
handler(event);
|
|
100
|
-
}
|
|
101
|
-
}];
|
|
102
|
-
});
|
|
103
|
-
if (bindings.length === 0) {
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
var unbind = (0, _bindEventListener.bindAll)(chip, bindings);
|
|
107
|
-
return unbind;
|
|
108
|
-
}, [chip, triggerProps]);
|
|
109
|
-
};
|
|
110
|
-
var AnchoredTooltip = function AnchoredTooltip(_ref3) {
|
|
111
|
-
var subscribe = _ref3.subscribe,
|
|
112
|
-
getInitialTooltip = _ref3.getInitialTooltip,
|
|
113
|
-
referenceElement = _ref3.referenceElement;
|
|
114
|
-
var _useState = (0, _react.useState)(getInitialTooltip),
|
|
115
|
-
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
116
|
-
tooltip = _useState2[0],
|
|
117
|
-
setTooltipState = _useState2[1];
|
|
118
|
-
(0, _react.useEffect)(function () {
|
|
119
|
-
return subscribe(setTooltipState);
|
|
120
|
-
}, [subscribe]);
|
|
121
|
-
if (!tooltip) {
|
|
122
|
-
return null;
|
|
123
|
-
}
|
|
124
|
-
return /*#__PURE__*/_react.default.createElement(_Tooltip.default, {
|
|
125
|
-
content: tooltip,
|
|
126
|
-
position: "top"
|
|
127
|
-
}, function (tooltipProps) {
|
|
128
|
-
return /*#__PURE__*/_react.default.createElement(TriggerBridge, {
|
|
129
|
-
referenceElement: referenceElement,
|
|
130
|
-
tooltipProps: tooltipProps
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Render-prop child for ADS `<Tooltip>`. The element it returns is a
|
|
137
|
-
* `display: none` placeholder that satisfies the render-prop API; the
|
|
138
|
-
* real trigger surface is the chip in the PM document, which receives
|
|
139
|
-
* both the ADS ref and the bridged event listeners via the side-effects
|
|
140
|
-
* declared on this component.
|
|
141
|
-
*/
|
|
142
|
-
var TriggerBridge = function TriggerBridge(_ref4) {
|
|
143
|
-
var referenceElement = _ref4.referenceElement,
|
|
144
|
-
tooltipProps = _ref4.tooltipProps;
|
|
145
|
-
useBridgedTriggerListeners(referenceElement, tooltipProps);
|
|
146
|
-
return /*#__PURE__*/_react.default.createElement("span", {
|
|
147
|
-
ref: function ref() {
|
|
148
|
-
return assignRef(tooltipProps.ref, referenceElement);
|
|
149
|
-
},
|
|
150
|
-
"aria-hidden": "true",
|
|
151
|
-
className: (0, _runtime.ax)([styles.hiddenTrigger])
|
|
152
|
-
});
|
|
153
|
-
};
|
|
154
|
-
var disabledTooltipRenderer = exports.disabledTooltipRenderer = function disabledTooltipRenderer(_ref5) {
|
|
155
|
-
var chipElement = _ref5.chipElement,
|
|
156
|
-
portalProviderAPI = _ref5.portalProviderAPI;
|
|
157
|
-
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- mirror existing renderer pattern
|
|
158
|
-
var key = (0, _uuid.v4)();
|
|
159
|
-
var currentTooltip;
|
|
160
|
-
var listeners = new Set();
|
|
161
|
-
var broadcast = function broadcast() {
|
|
162
|
-
listeners.forEach(function (listener) {
|
|
163
|
-
return listener(currentTooltip);
|
|
164
|
-
});
|
|
165
|
-
};
|
|
166
|
-
var getInitialTooltip = function getInitialTooltip() {
|
|
167
|
-
return currentTooltip;
|
|
168
|
-
};
|
|
169
|
-
var subscribe = function subscribe(listener) {
|
|
170
|
-
listeners.add(listener);
|
|
171
|
-
return function () {
|
|
172
|
-
listeners.delete(listener);
|
|
173
|
-
};
|
|
174
|
-
};
|
|
175
|
-
var renderElement = function renderElement() {
|
|
176
|
-
return /*#__PURE__*/_react.default.createElement(AnchoredTooltip, {
|
|
177
|
-
referenceElement: chipElement,
|
|
178
|
-
getInitialTooltip: getInitialTooltip,
|
|
179
|
-
subscribe: subscribe
|
|
180
|
-
});
|
|
181
|
-
};
|
|
182
|
-
portalProviderAPI.render(renderElement, chipElement, key);
|
|
183
|
-
return {
|
|
184
|
-
setTooltip: function setTooltip(text) {
|
|
185
|
-
currentTooltip = text;
|
|
186
|
-
broadcast();
|
|
187
|
-
},
|
|
188
|
-
destroy: function destroy() {
|
|
189
|
-
portalProviderAPI.remove(key);
|
|
190
|
-
listeners.clear();
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
._1e0cglyw{display:none}
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
/* disabledTooltipRenderer.tsx generated by @compiled/babel-plugin v3.0.2 */
|
|
2
|
-
import "./disabledTooltipRenderer.compiled.css";
|
|
3
|
-
import { ax, ix } from "@compiled/react/runtime";
|
|
4
|
-
import React, { useEffect, useState } from 'react';
|
|
5
|
-
import { bindAll } from 'bind-event-listener';
|
|
6
|
-
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- mirror existing renderer pattern
|
|
7
|
-
import { v4 as uuid } from 'uuid';
|
|
8
|
-
import Tooltip from '@atlaskit/tooltip/Tooltip';
|
|
9
|
-
const styles = {
|
|
10
|
-
hiddenTrigger: "_1e0cglyw"
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* ADS `<Tooltip>` hands us a ref via its render-prop child. That ref may be
|
|
15
|
-
* either a callback ref or a mutable ref object — React supports both shapes
|
|
16
|
-
* and ADS's typing keeps both possible. This helper assigns the supplied
|
|
17
|
-
* element to whichever ref shape was provided so the tooltip ends up using
|
|
18
|
-
* the chip's bounding box for positioning and its DOM for trigger events.
|
|
19
|
-
*/
|
|
20
|
-
const assignRef = (ref, element) => {
|
|
21
|
-
if (typeof ref === 'function') {
|
|
22
|
-
ref(element);
|
|
23
|
-
} else if (ref) {
|
|
24
|
-
ref.current = element;
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Names of the React-style trigger-prop handlers we forward from ADS
|
|
30
|
-
* `<Tooltip>` onto the chip element.
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Maps each React-style trigger-prop handler ADS `<Tooltip>` hands us in its
|
|
35
|
-
* render-prop callback to the DOM event name we attach to the chip via
|
|
36
|
-
* `bind-event-listener`. The chip lives in the ProseMirror document and is
|
|
37
|
-
* not a React child of the tooltip, so we have to bridge React handlers to
|
|
38
|
-
* native event listeners ourselves.
|
|
39
|
-
*
|
|
40
|
-
* Names are listed in the same order ADS internally registers them.
|
|
41
|
-
*/
|
|
42
|
-
const TRIGGER_EVENT_MAP = [['onMouseOver', 'mouseover'], ['onMouseOut', 'mouseout'], ['onMouseMove', 'mousemove'], ['onMouseDown', 'mousedown'], ['onFocus', 'focusin'], ['onBlur', 'focusout']];
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Anchors an ADS `<Tooltip>` to a ProseMirror chip element that is **not** a
|
|
46
|
-
* React child of the tooltip. The chip itself stays in the PM document; this
|
|
47
|
-
* renderer mounts an always-present React subtree via `portalProviderAPI` whose
|
|
48
|
-
* sole job is to host the tooltip and forward the ADS-provided trigger ref +
|
|
49
|
-
* event handlers onto the chip.
|
|
50
|
-
*
|
|
51
|
-
* The forwarding is deliberate: ADS `<Tooltip>` expects to attach its hover /
|
|
52
|
-
* focus / blur listeners to its render-prop child, but our render-prop child
|
|
53
|
-
* is a `display: none` placeholder span that no real event can reach. We bridge
|
|
54
|
-
* those listeners to the chip via `addEventListener` so the tooltip opens and
|
|
55
|
-
* closes in response to the user actually interacting with the chip — keyboard
|
|
56
|
-
* focus, mouse hover, screen-reader focus, the lot.
|
|
57
|
-
*/
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Hook that mirrors ADS Tooltip's React trigger props onto a DOM element
|
|
61
|
-
* which is not a React child of the tooltip. Re-attaches whenever ADS hands
|
|
62
|
-
* us a fresh set of props (which happens on every render of the render-prop
|
|
63
|
-
* child) and cleans up on unmount.
|
|
64
|
-
*
|
|
65
|
-
* We use `bind-event-listener`'s `bindAll` rather than raw
|
|
66
|
-
* `addEventListener` / `removeEventListener` calls so the lifetime of every
|
|
67
|
-
* subscription is paired with a single `UnbindFn` — the AFM-mandated pattern
|
|
68
|
-
* for keeping listener bookkeeping leak-free.
|
|
69
|
-
*/
|
|
70
|
-
const useBridgedTriggerListeners = (chip, triggerProps) => {
|
|
71
|
-
useEffect(() => {
|
|
72
|
-
// Build the bindAll bindings array out of only the handlers ADS actually
|
|
73
|
-
// supplied. Each React handler is wrapped in a thin adapter so the
|
|
74
|
-
// listener signature matches the native `EventListener` shape; ADS
|
|
75
|
-
// handlers ignore the synthetic-event-only fields they don't use
|
|
76
|
-
// (target, currentTarget), so passing the raw DOM event through
|
|
77
|
-
// `unknown` is safe in practice.
|
|
78
|
-
const bindings = TRIGGER_EVENT_MAP.flatMap(([propName, eventName]) => {
|
|
79
|
-
const handler = triggerProps[propName];
|
|
80
|
-
if (!handler) {
|
|
81
|
-
return [];
|
|
82
|
-
}
|
|
83
|
-
return [{
|
|
84
|
-
type: eventName,
|
|
85
|
-
listener: event => {
|
|
86
|
-
handler(event);
|
|
87
|
-
}
|
|
88
|
-
}];
|
|
89
|
-
});
|
|
90
|
-
if (bindings.length === 0) {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
const unbind = bindAll(chip, bindings);
|
|
94
|
-
return unbind;
|
|
95
|
-
}, [chip, triggerProps]);
|
|
96
|
-
};
|
|
97
|
-
const AnchoredTooltip = ({
|
|
98
|
-
subscribe,
|
|
99
|
-
getInitialTooltip,
|
|
100
|
-
referenceElement
|
|
101
|
-
}) => {
|
|
102
|
-
const [tooltip, setTooltipState] = useState(getInitialTooltip);
|
|
103
|
-
useEffect(() => subscribe(setTooltipState), [subscribe]);
|
|
104
|
-
if (!tooltip) {
|
|
105
|
-
return null;
|
|
106
|
-
}
|
|
107
|
-
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
108
|
-
content: tooltip,
|
|
109
|
-
position: "top"
|
|
110
|
-
}, tooltipProps => /*#__PURE__*/React.createElement(TriggerBridge, {
|
|
111
|
-
referenceElement: referenceElement,
|
|
112
|
-
tooltipProps: tooltipProps
|
|
113
|
-
}));
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Render-prop child for ADS `<Tooltip>`. The element it returns is a
|
|
118
|
-
* `display: none` placeholder that satisfies the render-prop API; the
|
|
119
|
-
* real trigger surface is the chip in the PM document, which receives
|
|
120
|
-
* both the ADS ref and the bridged event listeners via the side-effects
|
|
121
|
-
* declared on this component.
|
|
122
|
-
*/
|
|
123
|
-
const TriggerBridge = ({
|
|
124
|
-
referenceElement,
|
|
125
|
-
tooltipProps
|
|
126
|
-
}) => {
|
|
127
|
-
useBridgedTriggerListeners(referenceElement, tooltipProps);
|
|
128
|
-
return /*#__PURE__*/React.createElement("span", {
|
|
129
|
-
ref: () => assignRef(tooltipProps.ref, referenceElement),
|
|
130
|
-
"aria-hidden": "true",
|
|
131
|
-
className: ax([styles.hiddenTrigger])
|
|
132
|
-
});
|
|
133
|
-
};
|
|
134
|
-
export const disabledTooltipRenderer = ({
|
|
135
|
-
chipElement,
|
|
136
|
-
portalProviderAPI
|
|
137
|
-
}) => {
|
|
138
|
-
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- mirror existing renderer pattern
|
|
139
|
-
const key = uuid();
|
|
140
|
-
let currentTooltip;
|
|
141
|
-
const listeners = new Set();
|
|
142
|
-
const broadcast = () => {
|
|
143
|
-
listeners.forEach(listener => listener(currentTooltip));
|
|
144
|
-
};
|
|
145
|
-
const getInitialTooltip = () => currentTooltip;
|
|
146
|
-
const subscribe = listener => {
|
|
147
|
-
listeners.add(listener);
|
|
148
|
-
return () => {
|
|
149
|
-
listeners.delete(listener);
|
|
150
|
-
};
|
|
151
|
-
};
|
|
152
|
-
const renderElement = () => /*#__PURE__*/React.createElement(AnchoredTooltip, {
|
|
153
|
-
referenceElement: chipElement,
|
|
154
|
-
getInitialTooltip: getInitialTooltip,
|
|
155
|
-
subscribe: subscribe
|
|
156
|
-
});
|
|
157
|
-
portalProviderAPI.render(renderElement, chipElement, key);
|
|
158
|
-
return {
|
|
159
|
-
setTooltip(text) {
|
|
160
|
-
currentTooltip = text;
|
|
161
|
-
broadcast();
|
|
162
|
-
},
|
|
163
|
-
destroy() {
|
|
164
|
-
portalProviderAPI.remove(key);
|
|
165
|
-
listeners.clear();
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
._1e0cglyw{display:none}
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
/* disabledTooltipRenderer.tsx generated by @compiled/babel-plugin v3.0.2 */
|
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
-
import "./disabledTooltipRenderer.compiled.css";
|
|
4
|
-
import { ax, ix } from "@compiled/react/runtime";
|
|
5
|
-
import React, { useEffect, useState } from 'react';
|
|
6
|
-
import { bindAll } from 'bind-event-listener';
|
|
7
|
-
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- mirror existing renderer pattern
|
|
8
|
-
import { v4 as uuid } from 'uuid';
|
|
9
|
-
import Tooltip from '@atlaskit/tooltip/Tooltip';
|
|
10
|
-
var styles = {
|
|
11
|
-
hiddenTrigger: "_1e0cglyw"
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* ADS `<Tooltip>` hands us a ref via its render-prop child. That ref may be
|
|
16
|
-
* either a callback ref or a mutable ref object — React supports both shapes
|
|
17
|
-
* and ADS's typing keeps both possible. This helper assigns the supplied
|
|
18
|
-
* element to whichever ref shape was provided so the tooltip ends up using
|
|
19
|
-
* the chip's bounding box for positioning and its DOM for trigger events.
|
|
20
|
-
*/
|
|
21
|
-
var assignRef = function assignRef(ref, element) {
|
|
22
|
-
if (typeof ref === 'function') {
|
|
23
|
-
ref(element);
|
|
24
|
-
} else if (ref) {
|
|
25
|
-
ref.current = element;
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Names of the React-style trigger-prop handlers we forward from ADS
|
|
31
|
-
* `<Tooltip>` onto the chip element.
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Maps each React-style trigger-prop handler ADS `<Tooltip>` hands us in its
|
|
36
|
-
* render-prop callback to the DOM event name we attach to the chip via
|
|
37
|
-
* `bind-event-listener`. The chip lives in the ProseMirror document and is
|
|
38
|
-
* not a React child of the tooltip, so we have to bridge React handlers to
|
|
39
|
-
* native event listeners ourselves.
|
|
40
|
-
*
|
|
41
|
-
* Names are listed in the same order ADS internally registers them.
|
|
42
|
-
*/
|
|
43
|
-
var TRIGGER_EVENT_MAP = [['onMouseOver', 'mouseover'], ['onMouseOut', 'mouseout'], ['onMouseMove', 'mousemove'], ['onMouseDown', 'mousedown'], ['onFocus', 'focusin'], ['onBlur', 'focusout']];
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Anchors an ADS `<Tooltip>` to a ProseMirror chip element that is **not** a
|
|
47
|
-
* React child of the tooltip. The chip itself stays in the PM document; this
|
|
48
|
-
* renderer mounts an always-present React subtree via `portalProviderAPI` whose
|
|
49
|
-
* sole job is to host the tooltip and forward the ADS-provided trigger ref +
|
|
50
|
-
* event handlers onto the chip.
|
|
51
|
-
*
|
|
52
|
-
* The forwarding is deliberate: ADS `<Tooltip>` expects to attach its hover /
|
|
53
|
-
* focus / blur listeners to its render-prop child, but our render-prop child
|
|
54
|
-
* is a `display: none` placeholder span that no real event can reach. We bridge
|
|
55
|
-
* those listeners to the chip via `addEventListener` so the tooltip opens and
|
|
56
|
-
* closes in response to the user actually interacting with the chip — keyboard
|
|
57
|
-
* focus, mouse hover, screen-reader focus, the lot.
|
|
58
|
-
*/
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Hook that mirrors ADS Tooltip's React trigger props onto a DOM element
|
|
62
|
-
* which is not a React child of the tooltip. Re-attaches whenever ADS hands
|
|
63
|
-
* us a fresh set of props (which happens on every render of the render-prop
|
|
64
|
-
* child) and cleans up on unmount.
|
|
65
|
-
*
|
|
66
|
-
* We use `bind-event-listener`'s `bindAll` rather than raw
|
|
67
|
-
* `addEventListener` / `removeEventListener` calls so the lifetime of every
|
|
68
|
-
* subscription is paired with a single `UnbindFn` — the AFM-mandated pattern
|
|
69
|
-
* for keeping listener bookkeeping leak-free.
|
|
70
|
-
*/
|
|
71
|
-
var useBridgedTriggerListeners = function useBridgedTriggerListeners(chip, triggerProps) {
|
|
72
|
-
useEffect(function () {
|
|
73
|
-
// Build the bindAll bindings array out of only the handlers ADS actually
|
|
74
|
-
// supplied. Each React handler is wrapped in a thin adapter so the
|
|
75
|
-
// listener signature matches the native `EventListener` shape; ADS
|
|
76
|
-
// handlers ignore the synthetic-event-only fields they don't use
|
|
77
|
-
// (target, currentTarget), so passing the raw DOM event through
|
|
78
|
-
// `unknown` is safe in practice.
|
|
79
|
-
var bindings = TRIGGER_EVENT_MAP.flatMap(function (_ref) {
|
|
80
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
81
|
-
propName = _ref2[0],
|
|
82
|
-
eventName = _ref2[1];
|
|
83
|
-
var handler = triggerProps[propName];
|
|
84
|
-
if (!handler) {
|
|
85
|
-
return [];
|
|
86
|
-
}
|
|
87
|
-
return [{
|
|
88
|
-
type: eventName,
|
|
89
|
-
listener: function listener(event) {
|
|
90
|
-
handler(event);
|
|
91
|
-
}
|
|
92
|
-
}];
|
|
93
|
-
});
|
|
94
|
-
if (bindings.length === 0) {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
var unbind = bindAll(chip, bindings);
|
|
98
|
-
return unbind;
|
|
99
|
-
}, [chip, triggerProps]);
|
|
100
|
-
};
|
|
101
|
-
var AnchoredTooltip = function AnchoredTooltip(_ref3) {
|
|
102
|
-
var subscribe = _ref3.subscribe,
|
|
103
|
-
getInitialTooltip = _ref3.getInitialTooltip,
|
|
104
|
-
referenceElement = _ref3.referenceElement;
|
|
105
|
-
var _useState = useState(getInitialTooltip),
|
|
106
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
107
|
-
tooltip = _useState2[0],
|
|
108
|
-
setTooltipState = _useState2[1];
|
|
109
|
-
useEffect(function () {
|
|
110
|
-
return subscribe(setTooltipState);
|
|
111
|
-
}, [subscribe]);
|
|
112
|
-
if (!tooltip) {
|
|
113
|
-
return null;
|
|
114
|
-
}
|
|
115
|
-
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
116
|
-
content: tooltip,
|
|
117
|
-
position: "top"
|
|
118
|
-
}, function (tooltipProps) {
|
|
119
|
-
return /*#__PURE__*/React.createElement(TriggerBridge, {
|
|
120
|
-
referenceElement: referenceElement,
|
|
121
|
-
tooltipProps: tooltipProps
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Render-prop child for ADS `<Tooltip>`. The element it returns is a
|
|
128
|
-
* `display: none` placeholder that satisfies the render-prop API; the
|
|
129
|
-
* real trigger surface is the chip in the PM document, which receives
|
|
130
|
-
* both the ADS ref and the bridged event listeners via the side-effects
|
|
131
|
-
* declared on this component.
|
|
132
|
-
*/
|
|
133
|
-
var TriggerBridge = function TriggerBridge(_ref4) {
|
|
134
|
-
var referenceElement = _ref4.referenceElement,
|
|
135
|
-
tooltipProps = _ref4.tooltipProps;
|
|
136
|
-
useBridgedTriggerListeners(referenceElement, tooltipProps);
|
|
137
|
-
return /*#__PURE__*/React.createElement("span", {
|
|
138
|
-
ref: function ref() {
|
|
139
|
-
return assignRef(tooltipProps.ref, referenceElement);
|
|
140
|
-
},
|
|
141
|
-
"aria-hidden": "true",
|
|
142
|
-
className: ax([styles.hiddenTrigger])
|
|
143
|
-
});
|
|
144
|
-
};
|
|
145
|
-
export var disabledTooltipRenderer = function disabledTooltipRenderer(_ref5) {
|
|
146
|
-
var chipElement = _ref5.chipElement,
|
|
147
|
-
portalProviderAPI = _ref5.portalProviderAPI;
|
|
148
|
-
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- mirror existing renderer pattern
|
|
149
|
-
var key = uuid();
|
|
150
|
-
var currentTooltip;
|
|
151
|
-
var listeners = new Set();
|
|
152
|
-
var broadcast = function broadcast() {
|
|
153
|
-
listeners.forEach(function (listener) {
|
|
154
|
-
return listener(currentTooltip);
|
|
155
|
-
});
|
|
156
|
-
};
|
|
157
|
-
var getInitialTooltip = function getInitialTooltip() {
|
|
158
|
-
return currentTooltip;
|
|
159
|
-
};
|
|
160
|
-
var subscribe = function subscribe(listener) {
|
|
161
|
-
listeners.add(listener);
|
|
162
|
-
return function () {
|
|
163
|
-
listeners.delete(listener);
|
|
164
|
-
};
|
|
165
|
-
};
|
|
166
|
-
var renderElement = function renderElement() {
|
|
167
|
-
return /*#__PURE__*/React.createElement(AnchoredTooltip, {
|
|
168
|
-
referenceElement: chipElement,
|
|
169
|
-
getInitialTooltip: getInitialTooltip,
|
|
170
|
-
subscribe: subscribe
|
|
171
|
-
});
|
|
172
|
-
};
|
|
173
|
-
portalProviderAPI.render(renderElement, chipElement, key);
|
|
174
|
-
return {
|
|
175
|
-
setTooltip: function setTooltip(text) {
|
|
176
|
-
currentTooltip = text;
|
|
177
|
-
broadcast();
|
|
178
|
-
},
|
|
179
|
-
destroy: function destroy() {
|
|
180
|
-
portalProviderAPI.remove(key);
|
|
181
|
-
listeners.clear();
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { PortalProviderAPI } from '@atlaskit/editor-common/common';
|
|
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;
|