@atlaskit/editor-plugin-mentions 20.1.5 → 20.2.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 +14 -0
- package/dist/cjs/isMentionTypeAheadEnabled.js +10 -0
- package/dist/cjs/mentionsPlugin.js +15 -2
- package/dist/cjs/pm-plugins/main.js +7 -4
- package/dist/cjs/ui/quick-insert/MentionQuickInsertMenuItem.js +4 -1
- package/dist/cjs/ui/quick-insert/getMentionQuickInsertComponents.js +5 -0
- package/dist/cjs/ui/type-ahead/index.js +3 -1
- package/dist/es2019/isMentionTypeAheadEnabled.js +2 -0
- package/dist/es2019/mentionsPlugin.js +13 -2
- package/dist/es2019/pm-plugins/main.js +5 -4
- package/dist/es2019/ui/quick-insert/MentionQuickInsertMenuItem.js +4 -1
- package/dist/es2019/ui/quick-insert/getMentionQuickInsertComponents.js +5 -0
- package/dist/es2019/ui/type-ahead/index.js +2 -0
- package/dist/esm/isMentionTypeAheadEnabled.js +4 -0
- package/dist/esm/mentionsPlugin.js +15 -2
- package/dist/esm/pm-plugins/main.js +7 -4
- package/dist/esm/ui/quick-insert/MentionQuickInsertMenuItem.js +4 -1
- package/dist/esm/ui/quick-insert/getMentionQuickInsertComponents.js +5 -0
- package/dist/esm/ui/type-ahead/index.js +3 -1
- package/dist/types/isMentionTypeAheadEnabled.d.ts +1 -0
- package/dist/types/types/index.d.ts +5 -0
- package/dist/types/ui/quick-insert/getMentionQuickInsertComponents.d.ts +2 -1
- package/dist/types/ui/type-ahead/index.d.ts +2 -1
- package/package.json +7 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-mentions
|
|
2
2
|
|
|
3
|
+
## 20.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`b51cc398d7701`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b51cc398d7701) -
|
|
8
|
+
Add the opt-in @mention availability predicate used by the gated Home Search mode, so Search
|
|
9
|
+
preserves existing Chat mentions as inactive content while preventing new mention typeahead and
|
|
10
|
+
`/mention` slash-menu insertion. The `editor-disable-feature` feature gate enables that predicate
|
|
11
|
+
for Home Search.
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 20.1.5
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isMentionTypeAheadEnabled = void 0;
|
|
7
|
+
var _fg = require("@atlaskit/platform-feature-flags/fg");
|
|
8
|
+
var isMentionTypeAheadEnabled = exports.isMentionTypeAheadEnabled = function isMentionTypeAheadEnabled(canOpenTypeAhead) {
|
|
9
|
+
return (canOpenTypeAhead === null || canOpenTypeAhead === void 0 ? void 0 : canOpenTypeAhead()) !== false || !(0, _fg.fg)('editor-disable-feature');
|
|
10
|
+
};
|
|
@@ -24,6 +24,7 @@ var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-ex
|
|
|
24
24
|
var _fg = require("@atlaskit/platform-feature-flags/fg");
|
|
25
25
|
var _editorExperiment = require("@atlaskit/tmp-editor-statsig/editor-experiment");
|
|
26
26
|
var _editorCommands = require("./editor-commands");
|
|
27
|
+
var _isMentionTypeAheadEnabled = require("./isMentionTypeAheadEnabled");
|
|
27
28
|
var _mentionNodeSpec = require("./nodeviews/mentionNodeSpec");
|
|
28
29
|
var _agent = require("./pm-plugins/agent");
|
|
29
30
|
var _key = require("./pm-plugins/key");
|
|
@@ -106,6 +107,7 @@ var mentionsPlugin = exports.mentionsPlugin = function mentionsPlugin(_ref3) {
|
|
|
106
107
|
fireAnalyticsEvent(payload, channel);
|
|
107
108
|
};
|
|
108
109
|
var typeAhead = (0, _typeAhead.createTypeAheadConfig)({
|
|
110
|
+
canOpenTypeAhead: options === null || options === void 0 ? void 0 : options.canOpenTypeAhead,
|
|
109
111
|
sanitizePrivateContent: options === null || options === void 0 ? void 0 : options.sanitizePrivateContent,
|
|
110
112
|
mentionInsertDisplayName: options === null || options === void 0 ? void 0 : options.insertDisplayName,
|
|
111
113
|
HighlightComponent: options === null || options === void 0 ? void 0 : options.HighlightComponent,
|
|
@@ -116,11 +118,15 @@ var mentionsPlugin = exports.mentionsPlugin = function mentionsPlugin(_ref3) {
|
|
|
116
118
|
fireEvent: fireEvent,
|
|
117
119
|
api: api
|
|
118
120
|
});
|
|
121
|
+
var canOpenMentionTypeAhead = function canOpenMentionTypeAhead() {
|
|
122
|
+
return (0, _isMentionTypeAheadEnabled.isMentionTypeAheadEnabled)(options === null || options === void 0 ? void 0 : options.canOpenTypeAhead);
|
|
123
|
+
};
|
|
119
124
|
var isRegisteredSlashCommandEnabled = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_slash_command');
|
|
120
125
|
if (isRegisteredSlashCommandEnabled) {
|
|
121
126
|
var _api$uiControlRegistr;
|
|
122
127
|
api === null || api === void 0 || (_api$uiControlRegistr = api.uiControlRegistry) === null || _api$uiControlRegistr === void 0 || _api$uiControlRegistr.actions.register((0, _getMentionQuickInsertComponents.getMentionQuickInsertComponents)({
|
|
123
128
|
api: api,
|
|
129
|
+
canOpenMentionTypeAhead: canOpenMentionTypeAhead,
|
|
124
130
|
typeAhead: typeAhead
|
|
125
131
|
}));
|
|
126
132
|
}
|
|
@@ -321,17 +327,24 @@ var mentionsPlugin = exports.mentionsPlugin = function mentionsPlugin(_ref3) {
|
|
|
321
327
|
icon: function icon() {
|
|
322
328
|
return /*#__PURE__*/_react.default.createElement(_assets.IconMention, null);
|
|
323
329
|
},
|
|
330
|
+
isHidden: function isHidden() {
|
|
331
|
+
var _api$mention$sharedSt;
|
|
332
|
+
return canOpenMentionTypeAhead() === false || (api === null || api === void 0 || (_api$mention$sharedSt = api.mention.sharedState.currentState()) === null || _api$mention$sharedSt === void 0 ? void 0 : _api$mention$sharedSt.canInsertMention) === false;
|
|
333
|
+
},
|
|
324
334
|
action: function action(insert, state) {
|
|
325
335
|
var _api$typeAhead3;
|
|
326
|
-
var tr = insert(undefined);
|
|
327
336
|
var pluginState = _key.mentionPluginKey.getState(state);
|
|
328
337
|
if (pluginState && pluginState.canInsertMention === false) {
|
|
329
338
|
return false;
|
|
330
339
|
}
|
|
331
|
-
|
|
340
|
+
var tr = insert(undefined);
|
|
341
|
+
var didOpen = api === null || api === void 0 || (_api$typeAhead3 = api.typeAhead) === null || _api$typeAhead3 === void 0 ? void 0 : _api$typeAhead3.actions.openAtTransaction({
|
|
332
342
|
triggerHandler: typeAhead,
|
|
333
343
|
inputMethod: _analytics.INPUT_METHOD.QUICK_INSERT
|
|
334
344
|
})(tr);
|
|
345
|
+
if (didOpen === false) {
|
|
346
|
+
return false;
|
|
347
|
+
}
|
|
335
348
|
return tr;
|
|
336
349
|
}
|
|
337
350
|
}];
|
|
@@ -13,6 +13,7 @@ var _insm = require("@atlaskit/insm");
|
|
|
13
13
|
var _analytics2 = require("@atlaskit/mention/analytics");
|
|
14
14
|
var _types = require("@atlaskit/mention/types");
|
|
15
15
|
var _fg = require("@atlaskit/platform-feature-flags/fg");
|
|
16
|
+
var _isMentionTypeAheadEnabled = require("../isMentionTypeAheadEnabled");
|
|
16
17
|
var _mentionNodeView = require("../nodeviews/mentionNodeView");
|
|
17
18
|
var _types2 = require("../types");
|
|
18
19
|
var _key = require("./key");
|
|
@@ -43,7 +44,7 @@ var ACTIONS = exports.ACTIONS = {
|
|
|
43
44
|
CLEAR_PENDING_PASTED_AGENT_MENTION: 'CLEAR_PENDING_PASTED_AGENT_MENTION'
|
|
44
45
|
};
|
|
45
46
|
var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
|
|
46
|
-
var PACKAGE_VERSION = "20.1.
|
|
47
|
+
var PACKAGE_VERSION = "20.1.5";
|
|
47
48
|
var setProvider = function setProvider(provider) {
|
|
48
49
|
return function (state, dispatch) {
|
|
49
50
|
if (dispatch) {
|
|
@@ -63,6 +64,9 @@ function createMentionPlugin(_ref) {
|
|
|
63
64
|
options = _ref.options,
|
|
64
65
|
api = _ref.api;
|
|
65
66
|
var mentionProvider;
|
|
67
|
+
var isMentionInsertionEnabled = function isMentionInsertionEnabled(state) {
|
|
68
|
+
return (0, _isMentionTypeAheadEnabled.isMentionTypeAheadEnabled)(options === null || options === void 0 ? void 0 : options.canOpenTypeAhead) && (0, _utils.canMentionBeCreatedInRange)(state.selection.from, state.selection.to)(state);
|
|
69
|
+
};
|
|
66
70
|
var sendAnalytics = function sendAnalytics(event, actionSubject, action, attributes) {
|
|
67
71
|
if (event === _analytics2.SLI_EVENT_TYPE || event === _analytics2.SMART_EVENT_TYPE) {
|
|
68
72
|
fireEvent({
|
|
@@ -81,9 +85,8 @@ function createMentionPlugin(_ref) {
|
|
|
81
85
|
key: _key.mentionPluginKey,
|
|
82
86
|
state: {
|
|
83
87
|
init: function init(_, state) {
|
|
84
|
-
var canInsertMention = (0, _utils.canMentionBeCreatedInRange)(state.selection.from, state.selection.to)(state);
|
|
85
88
|
return {
|
|
86
|
-
canInsertMention:
|
|
89
|
+
canInsertMention: isMentionInsertionEnabled(state)
|
|
87
90
|
};
|
|
88
91
|
},
|
|
89
92
|
apply: function apply(tr, pluginState, oldState, newState) {
|
|
@@ -98,7 +101,7 @@ function createMentionPlugin(_ref) {
|
|
|
98
101
|
var hasPositionChanged = oldState.selection.from !== newState.selection.from || oldState.selection.to !== newState.selection.to;
|
|
99
102
|
if (tr.docChanged || tr.selectionSet && hasPositionChanged) {
|
|
100
103
|
newPluginState = _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
101
|
-
canInsertMention: (
|
|
104
|
+
canInsertMention: isMentionInsertionEnabled(newState)
|
|
102
105
|
});
|
|
103
106
|
hasPublicPluginStateChanged = true;
|
|
104
107
|
}
|
|
@@ -27,10 +27,13 @@ var MentionQuickInsertMenuItem = exports.MentionQuickInsertMenuItem = function M
|
|
|
27
27
|
return false;
|
|
28
28
|
}
|
|
29
29
|
var tr = insert(undefined);
|
|
30
|
-
api === null || api === void 0 || (_api$typeAhead = api.typeAhead) === null || _api$typeAhead === void 0
|
|
30
|
+
var didOpen = api === null || api === void 0 || (_api$typeAhead = api.typeAhead) === null || _api$typeAhead === void 0 ? void 0 : _api$typeAhead.actions.openAtTransaction({
|
|
31
31
|
triggerHandler: typeAhead,
|
|
32
32
|
inputMethod: _analytics.INPUT_METHOD.QUICK_INSERT
|
|
33
33
|
})(tr);
|
|
34
|
+
if (didOpen === false) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
34
37
|
return tr;
|
|
35
38
|
}, [api, typeAhead]);
|
|
36
39
|
return /*#__PURE__*/_react.default.createElement(_menuItem.QuickInsertMenuItem, {
|
|
@@ -13,6 +13,7 @@ var _rank = require("@atlaskit/editor-common/quick-insert/rank");
|
|
|
13
13
|
var _MentionQuickInsertMenuItem = require("./MentionQuickInsertMenuItem");
|
|
14
14
|
var getMentionQuickInsertComponents = exports.getMentionQuickInsertComponents = function getMentionQuickInsertComponents(_ref) {
|
|
15
15
|
var api = _ref.api,
|
|
16
|
+
canOpenMentionTypeAhead = _ref.canOpenMentionTypeAhead,
|
|
16
17
|
typeAhead = _ref.typeAhead;
|
|
17
18
|
return [{
|
|
18
19
|
key: _keys.MENTION_MENU_ITEM.key,
|
|
@@ -22,6 +23,10 @@ var getMentionQuickInsertComponents = exports.getMentionQuickInsertComponents =
|
|
|
22
23
|
type: _keys.STRUCTURE_SECTION.type,
|
|
23
24
|
rank: _rank.STRUCTURE_SECTION_RANK[_keys.MENTION_MENU_ITEM.key]
|
|
24
25
|
}],
|
|
26
|
+
isHidden: function isHidden() {
|
|
27
|
+
var _api$mention$sharedSt;
|
|
28
|
+
return (canOpenMentionTypeAhead === null || canOpenMentionTypeAhead === void 0 ? void 0 : canOpenMentionTypeAhead()) === false || (api === null || api === void 0 || (_api$mention$sharedSt = api.mention.sharedState.currentState()) === null || _api$mention$sharedSt === void 0 ? void 0 : _api$mention$sharedSt.canInsertMention) === false;
|
|
29
|
+
},
|
|
25
30
|
match: (0, _createQuickInsertMatcher.createQuickInsertMatcher)(function (_ref2) {
|
|
26
31
|
var formatMessage = _ref2.formatMessage;
|
|
27
32
|
return {
|
|
@@ -395,7 +395,8 @@ var makeTransformMentionsToTypeAheadItems = function makeTransformMentionsToType
|
|
|
395
395
|
};
|
|
396
396
|
};
|
|
397
397
|
var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeAheadConfig(_ref1) {
|
|
398
|
-
var
|
|
398
|
+
var canOpenTypeAhead = _ref1.canOpenTypeAhead,
|
|
399
|
+
sanitizePrivateContent = _ref1.sanitizePrivateContent,
|
|
399
400
|
mentionInsertDisplayName = _ref1.mentionInsertDisplayName,
|
|
400
401
|
fireEvent = _ref1.fireEvent,
|
|
401
402
|
HighlightComponent = _ref1.HighlightComponent,
|
|
@@ -433,6 +434,7 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
|
|
|
433
434
|
})).call
|
|
434
435
|
});
|
|
435
436
|
var typeAhead = {
|
|
437
|
+
canOpen: canOpenTypeAhead,
|
|
436
438
|
id: _typeAhead.TypeAheadAvailableNodes.MENTION,
|
|
437
439
|
trigger: '@',
|
|
438
440
|
// Custom regex must have a capture group around trigger
|
|
@@ -13,6 +13,7 @@ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-e
|
|
|
13
13
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
14
14
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
15
15
|
import { insertMention } from './editor-commands';
|
|
16
|
+
import { isMentionTypeAheadEnabled } from './isMentionTypeAheadEnabled';
|
|
16
17
|
import { mentionNodeSpec } from './nodeviews/mentionNodeSpec';
|
|
17
18
|
import { agentMentionPluginKey, createAgentMentionPlugin } from './pm-plugins/agent';
|
|
18
19
|
import { mentionPluginKey } from './pm-plugins/key';
|
|
@@ -102,6 +103,7 @@ const mentionsPlugin = ({
|
|
|
102
103
|
fireAnalyticsEvent(payload, channel);
|
|
103
104
|
};
|
|
104
105
|
const typeAhead = createTypeAheadConfig({
|
|
106
|
+
canOpenTypeAhead: options === null || options === void 0 ? void 0 : options.canOpenTypeAhead,
|
|
105
107
|
sanitizePrivateContent: options === null || options === void 0 ? void 0 : options.sanitizePrivateContent,
|
|
106
108
|
mentionInsertDisplayName: options === null || options === void 0 ? void 0 : options.insertDisplayName,
|
|
107
109
|
HighlightComponent: options === null || options === void 0 ? void 0 : options.HighlightComponent,
|
|
@@ -112,11 +114,13 @@ const mentionsPlugin = ({
|
|
|
112
114
|
fireEvent,
|
|
113
115
|
api
|
|
114
116
|
});
|
|
117
|
+
const canOpenMentionTypeAhead = () => isMentionTypeAheadEnabled(options === null || options === void 0 ? void 0 : options.canOpenTypeAhead);
|
|
115
118
|
const isRegisteredSlashCommandEnabled = isExperimentEnabled('platform_editor_slash_command');
|
|
116
119
|
if (isRegisteredSlashCommandEnabled) {
|
|
117
120
|
var _api$uiControlRegistr;
|
|
118
121
|
api === null || api === void 0 ? void 0 : (_api$uiControlRegistr = api.uiControlRegistry) === null || _api$uiControlRegistr === void 0 ? void 0 : _api$uiControlRegistr.actions.register(getMentionQuickInsertComponents({
|
|
119
122
|
api,
|
|
123
|
+
canOpenMentionTypeAhead,
|
|
120
124
|
typeAhead
|
|
121
125
|
}));
|
|
122
126
|
}
|
|
@@ -293,17 +297,24 @@ const mentionsPlugin = ({
|
|
|
293
297
|
priority: 400,
|
|
294
298
|
keyshortcut: '@',
|
|
295
299
|
icon: () => /*#__PURE__*/React.createElement(IconMention, null),
|
|
300
|
+
isHidden: () => {
|
|
301
|
+
var _api$mention$sharedSt;
|
|
302
|
+
return canOpenMentionTypeAhead() === false || (api === null || api === void 0 ? void 0 : (_api$mention$sharedSt = api.mention.sharedState.currentState()) === null || _api$mention$sharedSt === void 0 ? void 0 : _api$mention$sharedSt.canInsertMention) === false;
|
|
303
|
+
},
|
|
296
304
|
action(insert, state) {
|
|
297
305
|
var _api$typeAhead3;
|
|
298
|
-
const tr = insert(undefined);
|
|
299
306
|
const pluginState = mentionPluginKey.getState(state);
|
|
300
307
|
if (pluginState && pluginState.canInsertMention === false) {
|
|
301
308
|
return false;
|
|
302
309
|
}
|
|
303
|
-
|
|
310
|
+
const tr = insert(undefined);
|
|
311
|
+
const didOpen = api === null || api === void 0 ? void 0 : (_api$typeAhead3 = api.typeAhead) === null || _api$typeAhead3 === void 0 ? void 0 : _api$typeAhead3.actions.openAtTransaction({
|
|
304
312
|
triggerHandler: typeAhead,
|
|
305
313
|
inputMethod: INPUT_METHOD.QUICK_INSERT
|
|
306
314
|
})(tr);
|
|
315
|
+
if (didOpen === false) {
|
|
316
|
+
return false;
|
|
317
|
+
}
|
|
307
318
|
return tr;
|
|
308
319
|
}
|
|
309
320
|
}],
|
|
@@ -4,6 +4,7 @@ import { insm } from '@atlaskit/insm';
|
|
|
4
4
|
import { SLI_EVENT_TYPE, SMART_EVENT_TYPE } from '@atlaskit/mention/analytics';
|
|
5
5
|
import { ComponentNames } from '@atlaskit/mention/types';
|
|
6
6
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
7
|
+
import { isMentionTypeAheadEnabled } from '../isMentionTypeAheadEnabled';
|
|
7
8
|
import { MentionNodeView } from '../nodeviews/mentionNodeView';
|
|
8
9
|
import { MENTION_PROVIDER_REJECTED, MENTION_PROVIDER_UNDEFINED } from '../types';
|
|
9
10
|
import { mentionPluginKey } from './key';
|
|
@@ -32,7 +33,7 @@ export const ACTIONS = {
|
|
|
32
33
|
CLEAR_PENDING_PASTED_AGENT_MENTION: 'CLEAR_PENDING_PASTED_AGENT_MENTION'
|
|
33
34
|
};
|
|
34
35
|
const PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
|
|
35
|
-
const PACKAGE_VERSION = "20.1.
|
|
36
|
+
const PACKAGE_VERSION = "20.1.5";
|
|
36
37
|
const setProvider = provider => (state, dispatch) => {
|
|
37
38
|
if (dispatch) {
|
|
38
39
|
dispatch(state.tr.setMeta(mentionPluginKey, {
|
|
@@ -51,6 +52,7 @@ export function createMentionPlugin({
|
|
|
51
52
|
api
|
|
52
53
|
}) {
|
|
53
54
|
let mentionProvider;
|
|
55
|
+
const isMentionInsertionEnabled = state => isMentionTypeAheadEnabled(options === null || options === void 0 ? void 0 : options.canOpenTypeAhead) && canMentionBeCreatedInRange(state.selection.from, state.selection.to)(state);
|
|
54
56
|
const sendAnalytics = (event, actionSubject, action, attributes) => {
|
|
55
57
|
if (event === SLI_EVENT_TYPE || event === SMART_EVENT_TYPE) {
|
|
56
58
|
fireEvent({
|
|
@@ -70,9 +72,8 @@ export function createMentionPlugin({
|
|
|
70
72
|
key: mentionPluginKey,
|
|
71
73
|
state: {
|
|
72
74
|
init(_, state) {
|
|
73
|
-
const canInsertMention = canMentionBeCreatedInRange(state.selection.from, state.selection.to)(state);
|
|
74
75
|
return {
|
|
75
|
-
canInsertMention
|
|
76
|
+
canInsertMention: isMentionInsertionEnabled(state)
|
|
76
77
|
};
|
|
77
78
|
},
|
|
78
79
|
apply(tr, pluginState, oldState, newState) {
|
|
@@ -89,7 +90,7 @@ export function createMentionPlugin({
|
|
|
89
90
|
if (tr.docChanged || tr.selectionSet && hasPositionChanged) {
|
|
90
91
|
newPluginState = {
|
|
91
92
|
...pluginState,
|
|
92
|
-
canInsertMention:
|
|
93
|
+
canInsertMention: isMentionInsertionEnabled(newState)
|
|
93
94
|
};
|
|
94
95
|
hasPublicPluginStateChanged = true;
|
|
95
96
|
}
|
|
@@ -21,10 +21,13 @@ export const MentionQuickInsertMenuItem = ({
|
|
|
21
21
|
return false;
|
|
22
22
|
}
|
|
23
23
|
const tr = insert(undefined);
|
|
24
|
-
api === null || api === void 0 ? void 0 : (_api$typeAhead = api.typeAhead) === null || _api$typeAhead === void 0 ? void 0 : _api$typeAhead.actions.openAtTransaction({
|
|
24
|
+
const didOpen = api === null || api === void 0 ? void 0 : (_api$typeAhead = api.typeAhead) === null || _api$typeAhead === void 0 ? void 0 : _api$typeAhead.actions.openAtTransaction({
|
|
25
25
|
triggerHandler: typeAhead,
|
|
26
26
|
inputMethod: INPUT_METHOD.QUICK_INSERT
|
|
27
27
|
})(tr);
|
|
28
|
+
if (didOpen === false) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
28
31
|
return tr;
|
|
29
32
|
}, [api, typeAhead]);
|
|
30
33
|
return /*#__PURE__*/React.createElement(QuickInsertMenuItem, {
|
|
@@ -6,6 +6,7 @@ import { STRUCTURE_SECTION_RANK } from '@atlaskit/editor-common/quick-insert/ran
|
|
|
6
6
|
import { MentionQuickInsertMenuItem } from './MentionQuickInsertMenuItem';
|
|
7
7
|
export const getMentionQuickInsertComponents = ({
|
|
8
8
|
api,
|
|
9
|
+
canOpenMentionTypeAhead,
|
|
9
10
|
typeAhead
|
|
10
11
|
}) => [{
|
|
11
12
|
key: MENTION_MENU_ITEM.key,
|
|
@@ -15,6 +16,10 @@ export const getMentionQuickInsertComponents = ({
|
|
|
15
16
|
type: STRUCTURE_SECTION.type,
|
|
16
17
|
rank: STRUCTURE_SECTION_RANK[MENTION_MENU_ITEM.key]
|
|
17
18
|
}],
|
|
19
|
+
isHidden: () => {
|
|
20
|
+
var _api$mention$sharedSt;
|
|
21
|
+
return (canOpenMentionTypeAhead === null || canOpenMentionTypeAhead === void 0 ? void 0 : canOpenMentionTypeAhead()) === false || (api === null || api === void 0 ? void 0 : (_api$mention$sharedSt = api.mention.sharedState.currentState()) === null || _api$mention$sharedSt === void 0 ? void 0 : _api$mention$sharedSt.canInsertMention) === false;
|
|
22
|
+
},
|
|
18
23
|
match: createQuickInsertMatcher(({
|
|
19
24
|
formatMessage
|
|
20
25
|
}) => ({
|
|
@@ -353,6 +353,7 @@ const makeTransformMentionsToTypeAheadItems = ({
|
|
|
353
353
|
};
|
|
354
354
|
};
|
|
355
355
|
export const createTypeAheadConfig = ({
|
|
356
|
+
canOpenTypeAhead,
|
|
356
357
|
sanitizePrivateContent,
|
|
357
358
|
mentionInsertDisplayName,
|
|
358
359
|
fireEvent,
|
|
@@ -386,6 +387,7 @@ export const createTypeAheadConfig = ({
|
|
|
386
387
|
})).call
|
|
387
388
|
});
|
|
388
389
|
const typeAhead = {
|
|
390
|
+
canOpen: canOpenTypeAhead,
|
|
389
391
|
id: TypeAheadAvailableNodes.MENTION,
|
|
390
392
|
trigger: '@',
|
|
391
393
|
// Custom regex must have a capture group around trigger
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
2
|
+
export var isMentionTypeAheadEnabled = function isMentionTypeAheadEnabled(canOpenTypeAhead) {
|
|
3
|
+
return (canOpenTypeAhead === null || canOpenTypeAhead === void 0 ? void 0 : canOpenTypeAhead()) !== false || !fg('editor-disable-feature');
|
|
4
|
+
};
|
|
@@ -20,6 +20,7 @@ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-e
|
|
|
20
20
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
21
21
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
22
22
|
import { insertMention } from './editor-commands';
|
|
23
|
+
import { isMentionTypeAheadEnabled } from './isMentionTypeAheadEnabled';
|
|
23
24
|
import { mentionNodeSpec } from './nodeviews/mentionNodeSpec';
|
|
24
25
|
import { agentMentionPluginKey, createAgentMentionPlugin } from './pm-plugins/agent';
|
|
25
26
|
import { mentionPluginKey } from './pm-plugins/key';
|
|
@@ -98,6 +99,7 @@ var mentionsPlugin = function mentionsPlugin(_ref3) {
|
|
|
98
99
|
fireAnalyticsEvent(payload, channel);
|
|
99
100
|
};
|
|
100
101
|
var typeAhead = createTypeAheadConfig({
|
|
102
|
+
canOpenTypeAhead: options === null || options === void 0 ? void 0 : options.canOpenTypeAhead,
|
|
101
103
|
sanitizePrivateContent: options === null || options === void 0 ? void 0 : options.sanitizePrivateContent,
|
|
102
104
|
mentionInsertDisplayName: options === null || options === void 0 ? void 0 : options.insertDisplayName,
|
|
103
105
|
HighlightComponent: options === null || options === void 0 ? void 0 : options.HighlightComponent,
|
|
@@ -108,11 +110,15 @@ var mentionsPlugin = function mentionsPlugin(_ref3) {
|
|
|
108
110
|
fireEvent: fireEvent,
|
|
109
111
|
api: api
|
|
110
112
|
});
|
|
113
|
+
var canOpenMentionTypeAhead = function canOpenMentionTypeAhead() {
|
|
114
|
+
return isMentionTypeAheadEnabled(options === null || options === void 0 ? void 0 : options.canOpenTypeAhead);
|
|
115
|
+
};
|
|
111
116
|
var isRegisteredSlashCommandEnabled = isExperimentEnabled('platform_editor_slash_command');
|
|
112
117
|
if (isRegisteredSlashCommandEnabled) {
|
|
113
118
|
var _api$uiControlRegistr;
|
|
114
119
|
api === null || api === void 0 || (_api$uiControlRegistr = api.uiControlRegistry) === null || _api$uiControlRegistr === void 0 || _api$uiControlRegistr.actions.register(getMentionQuickInsertComponents({
|
|
115
120
|
api: api,
|
|
121
|
+
canOpenMentionTypeAhead: canOpenMentionTypeAhead,
|
|
116
122
|
typeAhead: typeAhead
|
|
117
123
|
}));
|
|
118
124
|
}
|
|
@@ -313,17 +319,24 @@ var mentionsPlugin = function mentionsPlugin(_ref3) {
|
|
|
313
319
|
icon: function icon() {
|
|
314
320
|
return /*#__PURE__*/React.createElement(IconMention, null);
|
|
315
321
|
},
|
|
322
|
+
isHidden: function isHidden() {
|
|
323
|
+
var _api$mention$sharedSt;
|
|
324
|
+
return canOpenMentionTypeAhead() === false || (api === null || api === void 0 || (_api$mention$sharedSt = api.mention.sharedState.currentState()) === null || _api$mention$sharedSt === void 0 ? void 0 : _api$mention$sharedSt.canInsertMention) === false;
|
|
325
|
+
},
|
|
316
326
|
action: function action(insert, state) {
|
|
317
327
|
var _api$typeAhead3;
|
|
318
|
-
var tr = insert(undefined);
|
|
319
328
|
var pluginState = mentionPluginKey.getState(state);
|
|
320
329
|
if (pluginState && pluginState.canInsertMention === false) {
|
|
321
330
|
return false;
|
|
322
331
|
}
|
|
323
|
-
|
|
332
|
+
var tr = insert(undefined);
|
|
333
|
+
var didOpen = api === null || api === void 0 || (_api$typeAhead3 = api.typeAhead) === null || _api$typeAhead3 === void 0 ? void 0 : _api$typeAhead3.actions.openAtTransaction({
|
|
324
334
|
triggerHandler: typeAhead,
|
|
325
335
|
inputMethod: INPUT_METHOD.QUICK_INSERT
|
|
326
336
|
})(tr);
|
|
337
|
+
if (didOpen === false) {
|
|
338
|
+
return false;
|
|
339
|
+
}
|
|
327
340
|
return tr;
|
|
328
341
|
}
|
|
329
342
|
}];
|
|
@@ -7,6 +7,7 @@ import { insm } from '@atlaskit/insm';
|
|
|
7
7
|
import { SLI_EVENT_TYPE, SMART_EVENT_TYPE } from '@atlaskit/mention/analytics';
|
|
8
8
|
import { ComponentNames } from '@atlaskit/mention/types';
|
|
9
9
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
10
|
+
import { isMentionTypeAheadEnabled } from '../isMentionTypeAheadEnabled';
|
|
10
11
|
import { MentionNodeView } from '../nodeviews/mentionNodeView';
|
|
11
12
|
import { MENTION_PROVIDER_REJECTED, MENTION_PROVIDER_UNDEFINED } from '../types';
|
|
12
13
|
import { mentionPluginKey } from './key';
|
|
@@ -35,7 +36,7 @@ export var ACTIONS = {
|
|
|
35
36
|
CLEAR_PENDING_PASTED_AGENT_MENTION: 'CLEAR_PENDING_PASTED_AGENT_MENTION'
|
|
36
37
|
};
|
|
37
38
|
var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
|
|
38
|
-
var PACKAGE_VERSION = "20.1.
|
|
39
|
+
var PACKAGE_VERSION = "20.1.5";
|
|
39
40
|
var setProvider = function setProvider(provider) {
|
|
40
41
|
return function (state, dispatch) {
|
|
41
42
|
if (dispatch) {
|
|
@@ -55,6 +56,9 @@ export function createMentionPlugin(_ref) {
|
|
|
55
56
|
options = _ref.options,
|
|
56
57
|
api = _ref.api;
|
|
57
58
|
var mentionProvider;
|
|
59
|
+
var isMentionInsertionEnabled = function isMentionInsertionEnabled(state) {
|
|
60
|
+
return isMentionTypeAheadEnabled(options === null || options === void 0 ? void 0 : options.canOpenTypeAhead) && canMentionBeCreatedInRange(state.selection.from, state.selection.to)(state);
|
|
61
|
+
};
|
|
58
62
|
var sendAnalytics = function sendAnalytics(event, actionSubject, action, attributes) {
|
|
59
63
|
if (event === SLI_EVENT_TYPE || event === SMART_EVENT_TYPE) {
|
|
60
64
|
fireEvent({
|
|
@@ -73,9 +77,8 @@ export function createMentionPlugin(_ref) {
|
|
|
73
77
|
key: mentionPluginKey,
|
|
74
78
|
state: {
|
|
75
79
|
init: function init(_, state) {
|
|
76
|
-
var canInsertMention = canMentionBeCreatedInRange(state.selection.from, state.selection.to)(state);
|
|
77
80
|
return {
|
|
78
|
-
canInsertMention:
|
|
81
|
+
canInsertMention: isMentionInsertionEnabled(state)
|
|
79
82
|
};
|
|
80
83
|
},
|
|
81
84
|
apply: function apply(tr, pluginState, oldState, newState) {
|
|
@@ -90,7 +93,7 @@ export function createMentionPlugin(_ref) {
|
|
|
90
93
|
var hasPositionChanged = oldState.selection.from !== newState.selection.from || oldState.selection.to !== newState.selection.to;
|
|
91
94
|
if (tr.docChanged || tr.selectionSet && hasPositionChanged) {
|
|
92
95
|
newPluginState = _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
93
|
-
canInsertMention:
|
|
96
|
+
canInsertMention: isMentionInsertionEnabled(newState)
|
|
94
97
|
});
|
|
95
98
|
hasPublicPluginStateChanged = true;
|
|
96
99
|
}
|
|
@@ -18,10 +18,13 @@ export var MentionQuickInsertMenuItem = function MentionQuickInsertMenuItem(_ref
|
|
|
18
18
|
return false;
|
|
19
19
|
}
|
|
20
20
|
var tr = insert(undefined);
|
|
21
|
-
api === null || api === void 0 || (_api$typeAhead = api.typeAhead) === null || _api$typeAhead === void 0
|
|
21
|
+
var didOpen = api === null || api === void 0 || (_api$typeAhead = api.typeAhead) === null || _api$typeAhead === void 0 ? void 0 : _api$typeAhead.actions.openAtTransaction({
|
|
22
22
|
triggerHandler: typeAhead,
|
|
23
23
|
inputMethod: INPUT_METHOD.QUICK_INSERT
|
|
24
24
|
})(tr);
|
|
25
|
+
if (didOpen === false) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
25
28
|
return tr;
|
|
26
29
|
}, [api, typeAhead]);
|
|
27
30
|
return /*#__PURE__*/React.createElement(QuickInsertMenuItem, {
|
|
@@ -6,6 +6,7 @@ import { STRUCTURE_SECTION_RANK } from '@atlaskit/editor-common/quick-insert/ran
|
|
|
6
6
|
import { MentionQuickInsertMenuItem } from './MentionQuickInsertMenuItem';
|
|
7
7
|
export var getMentionQuickInsertComponents = function getMentionQuickInsertComponents(_ref) {
|
|
8
8
|
var api = _ref.api,
|
|
9
|
+
canOpenMentionTypeAhead = _ref.canOpenMentionTypeAhead,
|
|
9
10
|
typeAhead = _ref.typeAhead;
|
|
10
11
|
return [{
|
|
11
12
|
key: MENTION_MENU_ITEM.key,
|
|
@@ -15,6 +16,10 @@ export var getMentionQuickInsertComponents = function getMentionQuickInsertCompo
|
|
|
15
16
|
type: STRUCTURE_SECTION.type,
|
|
16
17
|
rank: STRUCTURE_SECTION_RANK[MENTION_MENU_ITEM.key]
|
|
17
18
|
}],
|
|
19
|
+
isHidden: function isHidden() {
|
|
20
|
+
var _api$mention$sharedSt;
|
|
21
|
+
return (canOpenMentionTypeAhead === null || canOpenMentionTypeAhead === void 0 ? void 0 : canOpenMentionTypeAhead()) === false || (api === null || api === void 0 || (_api$mention$sharedSt = api.mention.sharedState.currentState()) === null || _api$mention$sharedSt === void 0 ? void 0 : _api$mention$sharedSt.canInsertMention) === false;
|
|
22
|
+
},
|
|
18
23
|
match: createQuickInsertMatcher(function (_ref2) {
|
|
19
24
|
var formatMessage = _ref2.formatMessage;
|
|
20
25
|
return {
|
|
@@ -386,7 +386,8 @@ var makeTransformMentionsToTypeAheadItems = function makeTransformMentionsToType
|
|
|
386
386
|
};
|
|
387
387
|
};
|
|
388
388
|
export var createTypeAheadConfig = function createTypeAheadConfig(_ref1) {
|
|
389
|
-
var
|
|
389
|
+
var canOpenTypeAhead = _ref1.canOpenTypeAhead,
|
|
390
|
+
sanitizePrivateContent = _ref1.sanitizePrivateContent,
|
|
390
391
|
mentionInsertDisplayName = _ref1.mentionInsertDisplayName,
|
|
391
392
|
fireEvent = _ref1.fireEvent,
|
|
392
393
|
HighlightComponent = _ref1.HighlightComponent,
|
|
@@ -424,6 +425,7 @@ export var createTypeAheadConfig = function createTypeAheadConfig(_ref1) {
|
|
|
424
425
|
})).call
|
|
425
426
|
});
|
|
426
427
|
var typeAhead = {
|
|
428
|
+
canOpen: canOpenTypeAhead,
|
|
427
429
|
id: TypeAheadAvailableNodes.MENTION,
|
|
428
430
|
trigger: '@',
|
|
429
431
|
// Custom regex must have a capture group around trigger
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isMentionTypeAheadEnabled: (canOpenTypeAhead?: () => boolean) => boolean;
|
|
@@ -28,6 +28,11 @@ export type MentionChange = {
|
|
|
28
28
|
export type MentionsChangedHandler = (changes: MentionChange[]) => void;
|
|
29
29
|
export interface MentionsPluginOptions extends MentionPluginConfig {
|
|
30
30
|
allowZeroWidthSpaceAfter?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Optional predicate evaluated before opening the @mention typeahead. When
|
|
33
|
+
* false, a typed @ remains plain editor text.
|
|
34
|
+
*/
|
|
35
|
+
canOpenTypeAhead?: () => boolean;
|
|
31
36
|
/**
|
|
32
37
|
* User ID to highlight as a self-mention (typically the current user).
|
|
33
38
|
*
|
|
@@ -2,7 +2,8 @@ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
|
2
2
|
import type { TypeAheadHandler } from '@atlaskit/editor-plugin-type-ahead';
|
|
3
3
|
import type { RegisterMenuItem } from '@atlaskit/editor-ui-control-model/types';
|
|
4
4
|
import type { MentionsPlugin } from '../../mentionsPluginType';
|
|
5
|
-
export declare const getMentionQuickInsertComponents: ({ api, typeAhead, }: {
|
|
5
|
+
export declare const getMentionQuickInsertComponents: ({ api, canOpenMentionTypeAhead, typeAhead, }: {
|
|
6
6
|
api: ExtractInjectionAPI<MentionsPlugin> | undefined;
|
|
7
|
+
canOpenMentionTypeAhead?: () => boolean;
|
|
7
8
|
typeAhead: TypeAheadHandler;
|
|
8
9
|
}) => RegisterMenuItem[];
|
|
@@ -14,6 +14,7 @@ export declare function memoize<ResultFn extends (mention: MentionDescription) =
|
|
|
14
14
|
};
|
|
15
15
|
type Props = {
|
|
16
16
|
api: ExtractInjectionAPI<MentionsPlugin> | undefined;
|
|
17
|
+
canOpenTypeAhead?: () => boolean;
|
|
17
18
|
enableAgentSectioning?: boolean;
|
|
18
19
|
fireEvent: FireElementsChannelEvent;
|
|
19
20
|
handleMentionsChanged?: (mentionChanges: MentionChange[]) => void;
|
|
@@ -23,5 +24,5 @@ type Props = {
|
|
|
23
24
|
sanitizePrivateContent?: boolean;
|
|
24
25
|
showAgentMentionsLabsLozenge?: boolean;
|
|
25
26
|
};
|
|
26
|
-
export declare const createTypeAheadConfig: ({ sanitizePrivateContent, mentionInsertDisplayName, fireEvent, HighlightComponent, api, handleMentionsChanged, enableAgentSectioning, showAgentMentionsLabsLozenge, profilecardProvider, }: Props) => TypeAheadHandler;
|
|
27
|
+
export declare const createTypeAheadConfig: ({ canOpenTypeAhead, sanitizePrivateContent, mentionInsertDisplayName, fireEvent, HighlightComponent, api, handleMentionsChanged, enableAgentSectioning, showAgentMentionsLabsLozenge, profilecardProvider, }: Props) => TypeAheadHandler;
|
|
27
28
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-mentions",
|
|
3
|
-
"version": "20.
|
|
3
|
+
"version": "20.2.0",
|
|
4
4
|
"description": "Mentions plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@atlaskit/editor-plugin-base": "^19.0.0",
|
|
29
29
|
"@atlaskit/editor-plugin-context-identifier": "^18.0.0",
|
|
30
30
|
"@atlaskit/editor-plugin-selection": "^18.0.0",
|
|
31
|
-
"@atlaskit/editor-plugin-type-ahead": "^19.
|
|
31
|
+
"@atlaskit/editor-plugin-type-ahead": "^19.1.0",
|
|
32
32
|
"@atlaskit/editor-prosemirror": "^8.0.0",
|
|
33
33
|
"@atlaskit/feature-gate-js-client": "^6.0.0",
|
|
34
34
|
"@atlaskit/icon": "^37.7.0",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"uuid": "^11.1.1"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
|
-
"@atlaskit/editor-common": "^122.
|
|
62
|
+
"@atlaskit/editor-common": "^122.11.0",
|
|
63
63
|
"react": "^18.2.0 || ^19.2.0",
|
|
64
64
|
"react-dom": "^18.2.0 || ^19.2.0",
|
|
65
65
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|
|
@@ -75,6 +75,10 @@
|
|
|
75
75
|
"wait-for-expect": "^1.2.0"
|
|
76
76
|
},
|
|
77
77
|
"platform-feature-flags": {
|
|
78
|
+
"editor-disable-feature": {
|
|
79
|
+
"type": "boolean",
|
|
80
|
+
"referenceOnly": true
|
|
81
|
+
},
|
|
78
82
|
"team-mention-inline-smartlink": {
|
|
79
83
|
"type": "boolean"
|
|
80
84
|
},
|