@atlaskit/editor-plugin-mentions 9.2.10 → 9.3.1
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 +20 -0
- package/README.md +11 -1
- package/dist/cjs/mentionsPlugin.js +11 -1
- package/dist/cjs/nodeviews/mentionNodeView.js +22 -6
- package/dist/cjs/pm-plugins/main.js +1 -1
- package/dist/cjs/pm-plugins/mentionPlaceholder.js +52 -0
- package/dist/cjs/ui/InlineInviteRecaptchaContainer.js +22 -4
- package/dist/cjs/ui/type-ahead/index.js +7 -0
- package/dist/es2019/mentionsPlugin.js +9 -1
- package/dist/es2019/nodeviews/mentionNodeView.js +21 -6
- package/dist/es2019/pm-plugins/main.js +1 -1
- package/dist/es2019/pm-plugins/mentionPlaceholder.js +44 -0
- package/dist/es2019/ui/InlineInviteRecaptchaContainer.js +24 -4
- package/dist/es2019/ui/type-ahead/index.js +9 -0
- package/dist/esm/mentionsPlugin.js +11 -1
- package/dist/esm/nodeviews/mentionNodeView.js +22 -6
- package/dist/esm/pm-plugins/main.js +1 -1
- package/dist/esm/pm-plugins/mentionPlaceholder.js +44 -0
- package/dist/esm/ui/InlineInviteRecaptchaContainer.js +22 -4
- package/dist/esm/ui/type-ahead/index.js +7 -0
- package/dist/types/nodeviews/mentionNodeView.d.ts +1 -0
- package/dist/types/pm-plugins/mentionPlaceholder.d.ts +11 -0
- package/dist/types/types/index.d.ts +8 -0
- package/dist/types-ts4.5/nodeviews/mentionNodeView.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/mentionPlaceholder.d.ts +11 -0
- package/dist/types-ts4.5/types/index.d.ts +8 -0
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-mentions
|
|
2
2
|
|
|
3
|
+
## 9.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 9.3.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`0e055e3f3f4e9`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0e055e3f3f4e9) -
|
|
14
|
+
[ux] Mentionplaceholder plugin to display placeholder for inline invite
|
|
15
|
+
- [`0942e8da58d56`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0942e8da58d56) -
|
|
16
|
+
Add currentUserId option to support immediate self-mention highlighting without waiting for
|
|
17
|
+
provider
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
|
|
3
23
|
## 9.2.10
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
|
-
# Editor
|
|
1
|
+
# Editor Plugin Mentions
|
|
2
2
|
|
|
3
3
|
Mentions plugin for @atlaskit/editor-core
|
|
4
4
|
|
|
5
5
|
**Note:** This component is designed for internal Atlassian development.
|
|
6
6
|
External contributors will be able to use this component but will not be able to submit issues.
|
|
7
7
|
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
The Mentions plugin provides the ability to mention users and other entities within the Atlassian Editor. It integrates with @atlaskit/editor-core to enable mention functionality for editor users.
|
|
11
|
+
|
|
12
|
+
## Key features
|
|
13
|
+
|
|
14
|
+
- **User mentions** - Mention users within editor content
|
|
15
|
+
- **Entity resolution** - Resolve mentions to user profiles and data
|
|
16
|
+
- **Mention rendering** - Display mentions with appropriate styling and information
|
|
17
|
+
|
|
8
18
|
## Install
|
|
9
19
|
---
|
|
10
20
|
- **Install** - *yarn add @atlaskit/editor-plugin-mentions*
|
|
@@ -23,6 +23,7 @@ var _editorCommands = require("./editor-commands");
|
|
|
23
23
|
var _mentionNodeSpec = require("./nodeviews/mentionNodeSpec");
|
|
24
24
|
var _key = require("./pm-plugins/key");
|
|
25
25
|
var _main = require("./pm-plugins/main");
|
|
26
|
+
var _mentionPlaceholder = require("./pm-plugins/mentionPlaceholder");
|
|
26
27
|
var _InlineInviteRecaptchaContainer = require("./ui/InlineInviteRecaptchaContainer");
|
|
27
28
|
var _SecondaryToolbarComponent = require("./ui/SecondaryToolbarComponent");
|
|
28
29
|
var _typeAhead = require("./ui/type-ahead");
|
|
@@ -115,7 +116,7 @@ var mentionsPlugin = exports.mentionsPlugin = function mentionsPlugin(_ref3) {
|
|
|
115
116
|
}];
|
|
116
117
|
},
|
|
117
118
|
pmPlugins: function pmPlugins() {
|
|
118
|
-
|
|
119
|
+
var plugins = [{
|
|
119
120
|
name: 'mention',
|
|
120
121
|
plugin: function plugin(pmPluginFactoryParams) {
|
|
121
122
|
return (0, _main.createMentionPlugin)({
|
|
@@ -126,6 +127,15 @@ var mentionsPlugin = exports.mentionsPlugin = function mentionsPlugin(_ref3) {
|
|
|
126
127
|
});
|
|
127
128
|
}
|
|
128
129
|
}];
|
|
130
|
+
if ((0, _platformFeatureFlags.fg)('jira_invites_auto_tag_new_user_in_mentions_fg')) {
|
|
131
|
+
plugins.push({
|
|
132
|
+
name: 'mentionPlaceholder',
|
|
133
|
+
plugin: function plugin() {
|
|
134
|
+
return (0, _mentionPlaceholder.createMentionPlaceholderPlugin)();
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
return plugins;
|
|
129
139
|
},
|
|
130
140
|
contentComponent: function contentComponent(_ref4) {
|
|
131
141
|
var editorView = _ref4.editorView,
|
|
@@ -159,18 +159,34 @@ var MentionNodeView = exports.MentionNodeView = /*#__PURE__*/function () {
|
|
|
159
159
|
this.mentionPrimitiveElement.textContent = name;
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
|
+
}, {
|
|
163
|
+
key: "shouldHighlightMention",
|
|
164
|
+
value: function shouldHighlightMention(mentionProvider) {
|
|
165
|
+
var _this$config$options;
|
|
166
|
+
var _ref4 = (_this$config$options = this.config.options) !== null && _this$config$options !== void 0 ? _this$config$options : {},
|
|
167
|
+
currentUserId = _ref4.currentUserId;
|
|
168
|
+
// Check options first (immediate), then provider (async), then default to false
|
|
169
|
+
if (currentUserId && this.node.attrs.id === currentUserId) {
|
|
170
|
+
return true;
|
|
171
|
+
} else {
|
|
172
|
+
var _mentionProvider$shou;
|
|
173
|
+
return (_mentionProvider$shou = mentionProvider === null || mentionProvider === void 0 ? void 0 : mentionProvider.shouldHighlightMention({
|
|
174
|
+
id: this.node.attrs.id
|
|
175
|
+
})) !== null && _mentionProvider$shou !== void 0 ? _mentionProvider$shou : false;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
162
178
|
}, {
|
|
163
179
|
key: "updateState",
|
|
164
180
|
value: function () {
|
|
165
181
|
var _updateState = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(mentionProvider) {
|
|
166
|
-
var _mentionProvider$
|
|
182
|
+
var _mentionProvider$shou2, _this$config$options2;
|
|
167
183
|
var isHighlighted, newState, name;
|
|
168
184
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
169
185
|
while (1) switch (_context2.prev = _context2.next) {
|
|
170
186
|
case 0:
|
|
171
|
-
isHighlighted = (_mentionProvider$
|
|
187
|
+
isHighlighted = (0, _expValEquals.expValEquals)('platform_editor_vc90_transition_fixes_batch_1', 'isEnabled', true) ? this.shouldHighlightMention(mentionProvider) : (_mentionProvider$shou2 = mentionProvider === null || mentionProvider === void 0 ? void 0 : mentionProvider.shouldHighlightMention({
|
|
172
188
|
id: this.node.attrs.id
|
|
173
|
-
})) !== null && _mentionProvider$
|
|
189
|
+
})) !== null && _mentionProvider$shou2 !== void 0 ? _mentionProvider$shou2 : false;
|
|
174
190
|
newState = getNewState(isHighlighted, (0, _types.isRestricted)(this.node.attrs.accessLevel));
|
|
175
191
|
if (newState !== this.state) {
|
|
176
192
|
this.setClassList(newState);
|
|
@@ -181,7 +197,7 @@ var MentionNodeView = exports.MentionNodeView = /*#__PURE__*/function () {
|
|
|
181
197
|
case 5:
|
|
182
198
|
name = _context2.sent;
|
|
183
199
|
this.setTextContent(name);
|
|
184
|
-
if (name && this.domElement && (_this$config$
|
|
200
|
+
if (name && this.domElement && (_this$config$options2 = this.config.options) !== null && _this$config$options2 !== void 0 && _this$config$options2.profilecardProvider) {
|
|
185
201
|
this.domElement.setAttribute('aria-label', getAccessibilityLabelFromName(name));
|
|
186
202
|
}
|
|
187
203
|
case 8:
|
|
@@ -198,8 +214,8 @@ var MentionNodeView = exports.MentionNodeView = /*#__PURE__*/function () {
|
|
|
198
214
|
}, {
|
|
199
215
|
key: "nodeIsEqual",
|
|
200
216
|
value: function nodeIsEqual(nextNode) {
|
|
201
|
-
var _this$config$
|
|
202
|
-
if ((_this$config$
|
|
217
|
+
var _this$config$options3;
|
|
218
|
+
if ((_this$config$options3 = this.config.options) !== null && _this$config$options3 !== void 0 && _this$config$options3.sanitizePrivateContent) {
|
|
203
219
|
// Compare nodes but ignore the text parameter as it may be sanitized
|
|
204
220
|
var nextNodeAttrs = _objectSpread(_objectSpread({}, nextNode.attrs), {}, {
|
|
205
221
|
text: this.node.attrs.text
|
|
@@ -23,7 +23,7 @@ var ACTIONS = exports.ACTIONS = {
|
|
|
23
23
|
SET_PROVIDER: 'SET_PROVIDER'
|
|
24
24
|
};
|
|
25
25
|
var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
|
|
26
|
-
var PACKAGE_VERSION = "
|
|
26
|
+
var PACKAGE_VERSION = "0.0.0-development";
|
|
27
27
|
var setProvider = function setProvider(provider) {
|
|
28
28
|
return function (state, dispatch) {
|
|
29
29
|
if (dispatch) {
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.MENTION_PLACEHOLDER_ACTIONS = void 0;
|
|
7
|
+
exports.createMentionPlaceholderPlugin = createMentionPlaceholderPlugin;
|
|
8
|
+
exports.mentionPlaceholderPluginKey = void 0;
|
|
9
|
+
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
10
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
11
|
+
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
12
|
+
var _colors = require("@atlaskit/theme/colors");
|
|
13
|
+
var mentionPlaceholderPluginKey = exports.mentionPlaceholderPluginKey = new _state.PluginKey('mentionPlaceholderPlugin');
|
|
14
|
+
var MENTION_PLACEHOLDER_ACTIONS = exports.MENTION_PLACEHOLDER_ACTIONS = {
|
|
15
|
+
SHOW_PLACEHOLDER: 'SHOW_PLACEHOLDER',
|
|
16
|
+
HIDE_PLACEHOLDER: 'HIDE_PLACEHOLDER'
|
|
17
|
+
};
|
|
18
|
+
function createMentionPlaceholderPlugin() {
|
|
19
|
+
return new _safePlugin.SafePlugin({
|
|
20
|
+
key: mentionPlaceholderPluginKey,
|
|
21
|
+
state: {
|
|
22
|
+
init: function init() {
|
|
23
|
+
return {};
|
|
24
|
+
},
|
|
25
|
+
apply: function apply(tr, pluginState) {
|
|
26
|
+
var meta = tr.getMeta(mentionPlaceholderPluginKey);
|
|
27
|
+
if ((meta === null || meta === void 0 ? void 0 : meta.action) === MENTION_PLACEHOLDER_ACTIONS.SHOW_PLACEHOLDER) {
|
|
28
|
+
return {
|
|
29
|
+
placeholder: meta.placeholder
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
if ((meta === null || meta === void 0 ? void 0 : meta.action) === MENTION_PLACEHOLDER_ACTIONS.HIDE_PLACEHOLDER) {
|
|
33
|
+
return {};
|
|
34
|
+
}
|
|
35
|
+
return pluginState;
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
props: {
|
|
39
|
+
decorations: function decorations(state) {
|
|
40
|
+
var pluginState = mentionPlaceholderPluginKey.getState(state);
|
|
41
|
+
if (pluginState !== null && pluginState !== void 0 && pluginState.placeholder) {
|
|
42
|
+
var selection = state.selection;
|
|
43
|
+
var span = document.createElement('span');
|
|
44
|
+
span.textContent = pluginState.placeholder;
|
|
45
|
+
span.style.setProperty('color', "var(--ds-text-accent-blue, ".concat(_colors.B400, ")"));
|
|
46
|
+
return _view.DecorationSet.create(state.doc, [_view.Decoration.widget(selection.from, span)]);
|
|
47
|
+
}
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
@@ -10,6 +10,7 @@ exports.InlineInviteRecaptchaContainer = void 0;
|
|
|
10
10
|
var _runtime = require("@compiled/react/runtime");
|
|
11
11
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
12
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
|
+
var _mentionPlaceholder = require("../pm-plugins/mentionPlaceholder");
|
|
13
14
|
var _analytics = require("../ui/type-ahead/analytics");
|
|
14
15
|
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); }
|
|
15
16
|
/**
|
|
@@ -19,7 +20,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
19
20
|
* mentionProvider.showInlineInviteRecaptcha(email) which passes email to the component.
|
|
20
21
|
*/
|
|
21
22
|
var InlineInviteRecaptchaContainer = exports.InlineInviteRecaptchaContainer = function InlineInviteRecaptchaContainer(_ref) {
|
|
22
|
-
var _api$mention2, _api$
|
|
23
|
+
var _api$mention2, _api$core3;
|
|
23
24
|
var mentionProvider = _ref.mentionProvider,
|
|
24
25
|
api = _ref.api;
|
|
25
26
|
var _useState = (0, _react.useState)(null),
|
|
@@ -56,10 +57,27 @@ var InlineInviteRecaptchaContainer = exports.InlineInviteRecaptchaContainer = fu
|
|
|
56
57
|
userType: 'DEFAULT',
|
|
57
58
|
accessLevel: 'CONTAINER'
|
|
58
59
|
}));
|
|
60
|
+
api.core.actions.execute(function (_ref2) {
|
|
61
|
+
var tr = _ref2.tr;
|
|
62
|
+
tr.setMeta(_mentionPlaceholder.mentionPlaceholderPluginKey, {
|
|
63
|
+
action: _mentionPlaceholder.MENTION_PLACEHOLDER_ACTIONS.HIDE_PLACEHOLDER
|
|
64
|
+
});
|
|
65
|
+
return tr;
|
|
66
|
+
});
|
|
59
67
|
}, [api]);
|
|
60
68
|
var handleClose = (0, _react.useCallback)(function () {
|
|
61
|
-
|
|
62
|
-
|
|
69
|
+
var _api$core2;
|
|
70
|
+
if (!(api !== null && api !== void 0 && (_api$core2 = api.core) !== null && _api$core2 !== void 0 && (_api$core2 = _api$core2.actions) !== null && _api$core2 !== void 0 && _api$core2.execute)) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
api.core.actions.execute(function (_ref3) {
|
|
74
|
+
var tr = _ref3.tr;
|
|
75
|
+
tr.setMeta(_mentionPlaceholder.mentionPlaceholderPluginKey, {
|
|
76
|
+
action: _mentionPlaceholder.MENTION_PLACEHOLDER_ACTIONS.HIDE_PLACEHOLDER
|
|
77
|
+
});
|
|
78
|
+
return tr;
|
|
79
|
+
});
|
|
80
|
+
}, [api]);
|
|
63
81
|
var handleReady = (0, _react.useCallback)(function (showRecaptcha) {
|
|
64
82
|
if (provider) {
|
|
65
83
|
if (showRecaptcha) {
|
|
@@ -69,7 +87,7 @@ var InlineInviteRecaptchaContainer = exports.InlineInviteRecaptchaContainer = fu
|
|
|
69
87
|
}
|
|
70
88
|
}
|
|
71
89
|
}, [provider]);
|
|
72
|
-
if (!(provider !== null && provider !== void 0 && provider.InlineInviteRecaptcha) || !(api !== null && api !== void 0 && (_api$mention2 = api.mention) !== null && _api$mention2 !== void 0 && (_api$mention2 = _api$mention2.commands) !== null && _api$mention2 !== void 0 && _api$mention2.insertMention) || !(api !== null && api !== void 0 && (_api$
|
|
90
|
+
if (!(provider !== null && provider !== void 0 && provider.InlineInviteRecaptcha) || !(api !== null && api !== void 0 && (_api$mention2 = api.mention) !== null && _api$mention2 !== void 0 && (_api$mention2 = _api$mention2.commands) !== null && _api$mention2 !== void 0 && _api$mention2.insertMention) || !(api !== null && api !== void 0 && (_api$core3 = api.core) !== null && _api$core3 !== void 0 && (_api$core3 = _api$core3.actions) !== null && _api$core3 !== void 0 && _api$core3.execute)) {
|
|
73
91
|
return null;
|
|
74
92
|
}
|
|
75
93
|
var RecaptchaComponent = provider.InlineInviteRecaptcha;
|
|
@@ -20,6 +20,7 @@ var _resource = require("@atlaskit/mention/resource");
|
|
|
20
20
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
21
21
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
22
22
|
var _editorCommands = require("../../editor-commands");
|
|
23
|
+
var _mentionPlaceholder = require("../../pm-plugins/mentionPlaceholder");
|
|
23
24
|
var _utils2 = require("../../pm-plugins/utils");
|
|
24
25
|
var _InviteItem = _interopRequireWildcard(require("../InviteItem"));
|
|
25
26
|
var _InviteItemWithEmailDomain = _interopRequireDefault(require("../InviteItem/InviteItemWithEmailDomain"));
|
|
@@ -361,6 +362,12 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
|
|
|
361
362
|
// If query already includes @, use it as is
|
|
362
363
|
if (email && mentionProvider.showInlineInviteRecaptcha) {
|
|
363
364
|
mentionProvider.showInlineInviteRecaptcha(email);
|
|
365
|
+
var tr = state.tr;
|
|
366
|
+
tr.setMeta(_mentionPlaceholder.mentionPlaceholderPluginKey, {
|
|
367
|
+
action: _mentionPlaceholder.MENTION_PLACEHOLDER_ACTIONS.SHOW_PLACEHOLDER,
|
|
368
|
+
placeholder: "@".concat(query)
|
|
369
|
+
});
|
|
370
|
+
return tr;
|
|
364
371
|
}
|
|
365
372
|
} else if (mentionProvider.onInviteItemClick) {
|
|
366
373
|
// Fallback to old behavior for backward compatibility
|
|
@@ -13,6 +13,7 @@ import { insertMention } from './editor-commands';
|
|
|
13
13
|
import { mentionNodeSpec } from './nodeviews/mentionNodeSpec';
|
|
14
14
|
import { mentionPluginKey } from './pm-plugins/key';
|
|
15
15
|
import { ACTIONS, createMentionPlugin } from './pm-plugins/main';
|
|
16
|
+
import { createMentionPlaceholderPlugin } from './pm-plugins/mentionPlaceholder';
|
|
16
17
|
import { InlineInviteRecaptchaContainer } from './ui/InlineInviteRecaptchaContainer';
|
|
17
18
|
import { SecondaryToolbarComponent } from './ui/SecondaryToolbarComponent';
|
|
18
19
|
import { createTypeAheadConfig } from './ui/type-ahead';
|
|
@@ -113,7 +114,7 @@ const mentionsPlugin = ({
|
|
|
113
114
|
}];
|
|
114
115
|
},
|
|
115
116
|
pmPlugins() {
|
|
116
|
-
|
|
117
|
+
const plugins = [{
|
|
117
118
|
name: 'mention',
|
|
118
119
|
plugin: pmPluginFactoryParams => createMentionPlugin({
|
|
119
120
|
pmPluginFactoryParams,
|
|
@@ -122,6 +123,13 @@ const mentionsPlugin = ({
|
|
|
122
123
|
api
|
|
123
124
|
})
|
|
124
125
|
}];
|
|
126
|
+
if (fg('jira_invites_auto_tag_new_user_in_mentions_fg')) {
|
|
127
|
+
plugins.push({
|
|
128
|
+
name: 'mentionPlaceholder',
|
|
129
|
+
plugin: () => createMentionPlaceholderPlugin()
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
return plugins;
|
|
125
133
|
},
|
|
126
134
|
contentComponent({
|
|
127
135
|
editorView,
|
|
@@ -125,11 +125,26 @@ export class MentionNodeView {
|
|
|
125
125
|
this.mentionPrimitiveElement.textContent = name;
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
|
+
shouldHighlightMention(mentionProvider) {
|
|
129
|
+
var _this$config$options;
|
|
130
|
+
const {
|
|
131
|
+
currentUserId
|
|
132
|
+
} = (_this$config$options = this.config.options) !== null && _this$config$options !== void 0 ? _this$config$options : {};
|
|
133
|
+
// Check options first (immediate), then provider (async), then default to false
|
|
134
|
+
if (currentUserId && this.node.attrs.id === currentUserId) {
|
|
135
|
+
return true;
|
|
136
|
+
} else {
|
|
137
|
+
var _mentionProvider$shou;
|
|
138
|
+
return (_mentionProvider$shou = mentionProvider === null || mentionProvider === void 0 ? void 0 : mentionProvider.shouldHighlightMention({
|
|
139
|
+
id: this.node.attrs.id
|
|
140
|
+
})) !== null && _mentionProvider$shou !== void 0 ? _mentionProvider$shou : false;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
128
143
|
async updateState(mentionProvider) {
|
|
129
|
-
var _mentionProvider$
|
|
130
|
-
const isHighlighted = (_mentionProvider$
|
|
144
|
+
var _mentionProvider$shou2, _this$config$options2;
|
|
145
|
+
const isHighlighted = expValEquals('platform_editor_vc90_transition_fixes_batch_1', 'isEnabled', true) ? this.shouldHighlightMention(mentionProvider) : (_mentionProvider$shou2 = mentionProvider === null || mentionProvider === void 0 ? void 0 : mentionProvider.shouldHighlightMention({
|
|
131
146
|
id: this.node.attrs.id
|
|
132
|
-
})) !== null && _mentionProvider$
|
|
147
|
+
})) !== null && _mentionProvider$shou2 !== void 0 ? _mentionProvider$shou2 : false;
|
|
133
148
|
const newState = getNewState(isHighlighted, isRestricted(this.node.attrs.accessLevel));
|
|
134
149
|
if (newState !== this.state) {
|
|
135
150
|
this.setClassList(newState);
|
|
@@ -137,13 +152,13 @@ export class MentionNodeView {
|
|
|
137
152
|
}
|
|
138
153
|
const name = await handleProviderName(mentionProvider, this.node);
|
|
139
154
|
this.setTextContent(name);
|
|
140
|
-
if (name && this.domElement && (_this$config$
|
|
155
|
+
if (name && this.domElement && (_this$config$options2 = this.config.options) !== null && _this$config$options2 !== void 0 && _this$config$options2.profilecardProvider) {
|
|
141
156
|
this.domElement.setAttribute('aria-label', getAccessibilityLabelFromName(name));
|
|
142
157
|
}
|
|
143
158
|
}
|
|
144
159
|
nodeIsEqual(nextNode) {
|
|
145
|
-
var _this$config$
|
|
146
|
-
if ((_this$config$
|
|
160
|
+
var _this$config$options3;
|
|
161
|
+
if ((_this$config$options3 = this.config.options) !== null && _this$config$options3 !== void 0 && _this$config$options3.sanitizePrivateContent) {
|
|
147
162
|
// Compare nodes but ignore the text parameter as it may be sanitized
|
|
148
163
|
const nextNodeAttrs = {
|
|
149
164
|
...nextNode.attrs,
|
|
@@ -12,7 +12,7 @@ export const ACTIONS = {
|
|
|
12
12
|
SET_PROVIDER: 'SET_PROVIDER'
|
|
13
13
|
};
|
|
14
14
|
const PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
|
|
15
|
-
const PACKAGE_VERSION = "
|
|
15
|
+
const PACKAGE_VERSION = "0.0.0-development";
|
|
16
16
|
const setProvider = provider => (state, dispatch) => {
|
|
17
17
|
if (dispatch) {
|
|
18
18
|
dispatch(state.tr.setMeta(mentionPluginKey, {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
+
import { B400 } from '@atlaskit/theme/colors';
|
|
5
|
+
export const mentionPlaceholderPluginKey = new PluginKey('mentionPlaceholderPlugin');
|
|
6
|
+
export const MENTION_PLACEHOLDER_ACTIONS = {
|
|
7
|
+
SHOW_PLACEHOLDER: 'SHOW_PLACEHOLDER',
|
|
8
|
+
HIDE_PLACEHOLDER: 'HIDE_PLACEHOLDER'
|
|
9
|
+
};
|
|
10
|
+
export function createMentionPlaceholderPlugin() {
|
|
11
|
+
return new SafePlugin({
|
|
12
|
+
key: mentionPlaceholderPluginKey,
|
|
13
|
+
state: {
|
|
14
|
+
init: () => ({}),
|
|
15
|
+
apply(tr, pluginState) {
|
|
16
|
+
const meta = tr.getMeta(mentionPlaceholderPluginKey);
|
|
17
|
+
if ((meta === null || meta === void 0 ? void 0 : meta.action) === MENTION_PLACEHOLDER_ACTIONS.SHOW_PLACEHOLDER) {
|
|
18
|
+
return {
|
|
19
|
+
placeholder: meta.placeholder
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
if ((meta === null || meta === void 0 ? void 0 : meta.action) === MENTION_PLACEHOLDER_ACTIONS.HIDE_PLACEHOLDER) {
|
|
23
|
+
return {};
|
|
24
|
+
}
|
|
25
|
+
return pluginState;
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
props: {
|
|
29
|
+
decorations: state => {
|
|
30
|
+
const pluginState = mentionPlaceholderPluginKey.getState(state);
|
|
31
|
+
if (pluginState !== null && pluginState !== void 0 && pluginState.placeholder) {
|
|
32
|
+
const {
|
|
33
|
+
selection
|
|
34
|
+
} = state;
|
|
35
|
+
const span = document.createElement('span');
|
|
36
|
+
span.textContent = pluginState.placeholder;
|
|
37
|
+
span.style.setProperty('color', `var(--ds-text-accent-blue, ${B400})`);
|
|
38
|
+
return DecorationSet.create(state.doc, [Decoration.widget(selection.from, span)]);
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* InlineInviteRecaptchaContainer.tsx generated by @compiled/babel-plugin v0.38.1 */
|
|
2
2
|
import { ax, ix } from "@compiled/react/runtime";
|
|
3
3
|
import React, { useCallback, useEffect, useState } from 'react';
|
|
4
|
+
import { mentionPlaceholderPluginKey, MENTION_PLACEHOLDER_ACTIONS } from '../pm-plugins/mentionPlaceholder';
|
|
4
5
|
import { MENTION_SOURCE } from '../ui/type-ahead/analytics';
|
|
5
6
|
/**
|
|
6
7
|
* Container that renders the recaptcha component from the mention provider and manages handleSuccess.
|
|
@@ -12,7 +13,7 @@ export const InlineInviteRecaptchaContainer = ({
|
|
|
12
13
|
mentionProvider,
|
|
13
14
|
api
|
|
14
15
|
}) => {
|
|
15
|
-
var _api$mention2, _api$mention2$command, _api$
|
|
16
|
+
var _api$mention2, _api$mention2$command, _api$core3, _api$core3$actions;
|
|
16
17
|
const [provider, setProvider] = useState(null);
|
|
17
18
|
useEffect(() => {
|
|
18
19
|
if (!mentionProvider) {
|
|
@@ -44,10 +45,29 @@ export const InlineInviteRecaptchaContainer = ({
|
|
|
44
45
|
userType: 'DEFAULT',
|
|
45
46
|
accessLevel: 'CONTAINER'
|
|
46
47
|
}));
|
|
48
|
+
api.core.actions.execute(({
|
|
49
|
+
tr
|
|
50
|
+
}) => {
|
|
51
|
+
tr.setMeta(mentionPlaceholderPluginKey, {
|
|
52
|
+
action: MENTION_PLACEHOLDER_ACTIONS.HIDE_PLACEHOLDER
|
|
53
|
+
});
|
|
54
|
+
return tr;
|
|
55
|
+
});
|
|
47
56
|
}, [api]);
|
|
48
57
|
const handleClose = useCallback(() => {
|
|
49
|
-
|
|
50
|
-
|
|
58
|
+
var _api$core2, _api$core2$actions;
|
|
59
|
+
if (!(api !== null && api !== void 0 && (_api$core2 = api.core) !== null && _api$core2 !== void 0 && (_api$core2$actions = _api$core2.actions) !== null && _api$core2$actions !== void 0 && _api$core2$actions.execute)) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
api.core.actions.execute(({
|
|
63
|
+
tr
|
|
64
|
+
}) => {
|
|
65
|
+
tr.setMeta(mentionPlaceholderPluginKey, {
|
|
66
|
+
action: MENTION_PLACEHOLDER_ACTIONS.HIDE_PLACEHOLDER
|
|
67
|
+
});
|
|
68
|
+
return tr;
|
|
69
|
+
});
|
|
70
|
+
}, [api]);
|
|
51
71
|
const handleReady = useCallback(showRecaptcha => {
|
|
52
72
|
if (provider) {
|
|
53
73
|
if (showRecaptcha) {
|
|
@@ -57,7 +77,7 @@ export const InlineInviteRecaptchaContainer = ({
|
|
|
57
77
|
}
|
|
58
78
|
}
|
|
59
79
|
}, [provider]);
|
|
60
|
-
if (!(provider !== null && provider !== void 0 && provider.InlineInviteRecaptcha) || !(api !== null && api !== void 0 && (_api$mention2 = api.mention) !== null && _api$mention2 !== void 0 && (_api$mention2$command = _api$mention2.commands) !== null && _api$mention2$command !== void 0 && _api$mention2$command.insertMention) || !(api !== null && api !== void 0 && (_api$
|
|
80
|
+
if (!(provider !== null && provider !== void 0 && provider.InlineInviteRecaptcha) || !(api !== null && api !== void 0 && (_api$mention2 = api.mention) !== null && _api$mention2 !== void 0 && (_api$mention2$command = _api$mention2.commands) !== null && _api$mention2$command !== void 0 && _api$mention2$command.insertMention) || !(api !== null && api !== void 0 && (_api$core3 = api.core) !== null && _api$core3 !== void 0 && (_api$core3$actions = _api$core3.actions) !== null && _api$core3$actions !== void 0 && _api$core3$actions.execute)) {
|
|
61
81
|
return null;
|
|
62
82
|
}
|
|
63
83
|
const RecaptchaComponent = provider.InlineInviteRecaptcha;
|
|
@@ -10,6 +10,7 @@ import { isResolvingMentionProvider } from '@atlaskit/mention/resource';
|
|
|
10
10
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
11
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
12
12
|
import { createSingleMentionFragment } from '../../editor-commands';
|
|
13
|
+
import { mentionPlaceholderPluginKey, MENTION_PLACEHOLDER_ACTIONS } from '../../pm-plugins/mentionPlaceholder';
|
|
13
14
|
import { getMentionPluginState } from '../../pm-plugins/utils';
|
|
14
15
|
import InviteItem, { INVITE_ITEM_DESCRIPTION } from '../InviteItem';
|
|
15
16
|
import InviteItemWithEmailDomain from '../InviteItem/InviteItemWithEmailDomain';
|
|
@@ -350,6 +351,14 @@ export const createTypeAheadConfig = ({
|
|
|
350
351
|
// If query already includes @, use it as is
|
|
351
352
|
if (email && mentionProvider.showInlineInviteRecaptcha) {
|
|
352
353
|
mentionProvider.showInlineInviteRecaptcha(email);
|
|
354
|
+
const {
|
|
355
|
+
tr
|
|
356
|
+
} = state;
|
|
357
|
+
tr.setMeta(mentionPlaceholderPluginKey, {
|
|
358
|
+
action: MENTION_PLACEHOLDER_ACTIONS.SHOW_PLACEHOLDER,
|
|
359
|
+
placeholder: `@${query}`
|
|
360
|
+
});
|
|
361
|
+
return tr;
|
|
353
362
|
}
|
|
354
363
|
} else if (mentionProvider.onInviteItemClick) {
|
|
355
364
|
// Fallback to old behavior for backward compatibility
|
|
@@ -18,6 +18,7 @@ import { insertMention } from './editor-commands';
|
|
|
18
18
|
import { mentionNodeSpec } from './nodeviews/mentionNodeSpec';
|
|
19
19
|
import { mentionPluginKey } from './pm-plugins/key';
|
|
20
20
|
import { ACTIONS, createMentionPlugin } from './pm-plugins/main';
|
|
21
|
+
import { createMentionPlaceholderPlugin } from './pm-plugins/mentionPlaceholder';
|
|
21
22
|
import { InlineInviteRecaptchaContainer } from './ui/InlineInviteRecaptchaContainer';
|
|
22
23
|
import { SecondaryToolbarComponent } from './ui/SecondaryToolbarComponent';
|
|
23
24
|
import { createTypeAheadConfig } from './ui/type-ahead';
|
|
@@ -107,7 +108,7 @@ var mentionsPlugin = function mentionsPlugin(_ref3) {
|
|
|
107
108
|
}];
|
|
108
109
|
},
|
|
109
110
|
pmPlugins: function pmPlugins() {
|
|
110
|
-
|
|
111
|
+
var plugins = [{
|
|
111
112
|
name: 'mention',
|
|
112
113
|
plugin: function plugin(pmPluginFactoryParams) {
|
|
113
114
|
return createMentionPlugin({
|
|
@@ -118,6 +119,15 @@ var mentionsPlugin = function mentionsPlugin(_ref3) {
|
|
|
118
119
|
});
|
|
119
120
|
}
|
|
120
121
|
}];
|
|
122
|
+
if (fg('jira_invites_auto_tag_new_user_in_mentions_fg')) {
|
|
123
|
+
plugins.push({
|
|
124
|
+
name: 'mentionPlaceholder',
|
|
125
|
+
plugin: function plugin() {
|
|
126
|
+
return createMentionPlaceholderPlugin();
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
return plugins;
|
|
121
131
|
},
|
|
122
132
|
contentComponent: function contentComponent(_ref4) {
|
|
123
133
|
var editorView = _ref4.editorView,
|
|
@@ -152,18 +152,34 @@ export var MentionNodeView = /*#__PURE__*/function () {
|
|
|
152
152
|
this.mentionPrimitiveElement.textContent = name;
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
|
+
}, {
|
|
156
|
+
key: "shouldHighlightMention",
|
|
157
|
+
value: function shouldHighlightMention(mentionProvider) {
|
|
158
|
+
var _this$config$options;
|
|
159
|
+
var _ref4 = (_this$config$options = this.config.options) !== null && _this$config$options !== void 0 ? _this$config$options : {},
|
|
160
|
+
currentUserId = _ref4.currentUserId;
|
|
161
|
+
// Check options first (immediate), then provider (async), then default to false
|
|
162
|
+
if (currentUserId && this.node.attrs.id === currentUserId) {
|
|
163
|
+
return true;
|
|
164
|
+
} else {
|
|
165
|
+
var _mentionProvider$shou;
|
|
166
|
+
return (_mentionProvider$shou = mentionProvider === null || mentionProvider === void 0 ? void 0 : mentionProvider.shouldHighlightMention({
|
|
167
|
+
id: this.node.attrs.id
|
|
168
|
+
})) !== null && _mentionProvider$shou !== void 0 ? _mentionProvider$shou : false;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
155
171
|
}, {
|
|
156
172
|
key: "updateState",
|
|
157
173
|
value: function () {
|
|
158
174
|
var _updateState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(mentionProvider) {
|
|
159
|
-
var _mentionProvider$
|
|
175
|
+
var _mentionProvider$shou2, _this$config$options2;
|
|
160
176
|
var isHighlighted, newState, name;
|
|
161
177
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
162
178
|
while (1) switch (_context2.prev = _context2.next) {
|
|
163
179
|
case 0:
|
|
164
|
-
isHighlighted = (_mentionProvider$
|
|
180
|
+
isHighlighted = expValEquals('platform_editor_vc90_transition_fixes_batch_1', 'isEnabled', true) ? this.shouldHighlightMention(mentionProvider) : (_mentionProvider$shou2 = mentionProvider === null || mentionProvider === void 0 ? void 0 : mentionProvider.shouldHighlightMention({
|
|
165
181
|
id: this.node.attrs.id
|
|
166
|
-
})) !== null && _mentionProvider$
|
|
182
|
+
})) !== null && _mentionProvider$shou2 !== void 0 ? _mentionProvider$shou2 : false;
|
|
167
183
|
newState = getNewState(isHighlighted, isRestricted(this.node.attrs.accessLevel));
|
|
168
184
|
if (newState !== this.state) {
|
|
169
185
|
this.setClassList(newState);
|
|
@@ -174,7 +190,7 @@ export var MentionNodeView = /*#__PURE__*/function () {
|
|
|
174
190
|
case 5:
|
|
175
191
|
name = _context2.sent;
|
|
176
192
|
this.setTextContent(name);
|
|
177
|
-
if (name && this.domElement && (_this$config$
|
|
193
|
+
if (name && this.domElement && (_this$config$options2 = this.config.options) !== null && _this$config$options2 !== void 0 && _this$config$options2.profilecardProvider) {
|
|
178
194
|
this.domElement.setAttribute('aria-label', getAccessibilityLabelFromName(name));
|
|
179
195
|
}
|
|
180
196
|
case 8:
|
|
@@ -191,8 +207,8 @@ export var MentionNodeView = /*#__PURE__*/function () {
|
|
|
191
207
|
}, {
|
|
192
208
|
key: "nodeIsEqual",
|
|
193
209
|
value: function nodeIsEqual(nextNode) {
|
|
194
|
-
var _this$config$
|
|
195
|
-
if ((_this$config$
|
|
210
|
+
var _this$config$options3;
|
|
211
|
+
if ((_this$config$options3 = this.config.options) !== null && _this$config$options3 !== void 0 && _this$config$options3.sanitizePrivateContent) {
|
|
196
212
|
// Compare nodes but ignore the text parameter as it may be sanitized
|
|
197
213
|
var nextNodeAttrs = _objectSpread(_objectSpread({}, nextNode.attrs), {}, {
|
|
198
214
|
text: this.node.attrs.text
|
|
@@ -15,7 +15,7 @@ export var ACTIONS = {
|
|
|
15
15
|
SET_PROVIDER: 'SET_PROVIDER'
|
|
16
16
|
};
|
|
17
17
|
var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
|
|
18
|
-
var PACKAGE_VERSION = "
|
|
18
|
+
var PACKAGE_VERSION = "0.0.0-development";
|
|
19
19
|
var setProvider = function setProvider(provider) {
|
|
20
20
|
return function (state, dispatch) {
|
|
21
21
|
if (dispatch) {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
+
import { B400 } from '@atlaskit/theme/colors';
|
|
5
|
+
export var mentionPlaceholderPluginKey = new PluginKey('mentionPlaceholderPlugin');
|
|
6
|
+
export var MENTION_PLACEHOLDER_ACTIONS = {
|
|
7
|
+
SHOW_PLACEHOLDER: 'SHOW_PLACEHOLDER',
|
|
8
|
+
HIDE_PLACEHOLDER: 'HIDE_PLACEHOLDER'
|
|
9
|
+
};
|
|
10
|
+
export function createMentionPlaceholderPlugin() {
|
|
11
|
+
return new SafePlugin({
|
|
12
|
+
key: mentionPlaceholderPluginKey,
|
|
13
|
+
state: {
|
|
14
|
+
init: function init() {
|
|
15
|
+
return {};
|
|
16
|
+
},
|
|
17
|
+
apply: function apply(tr, pluginState) {
|
|
18
|
+
var meta = tr.getMeta(mentionPlaceholderPluginKey);
|
|
19
|
+
if ((meta === null || meta === void 0 ? void 0 : meta.action) === MENTION_PLACEHOLDER_ACTIONS.SHOW_PLACEHOLDER) {
|
|
20
|
+
return {
|
|
21
|
+
placeholder: meta.placeholder
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
if ((meta === null || meta === void 0 ? void 0 : meta.action) === MENTION_PLACEHOLDER_ACTIONS.HIDE_PLACEHOLDER) {
|
|
25
|
+
return {};
|
|
26
|
+
}
|
|
27
|
+
return pluginState;
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
props: {
|
|
31
|
+
decorations: function decorations(state) {
|
|
32
|
+
var pluginState = mentionPlaceholderPluginKey.getState(state);
|
|
33
|
+
if (pluginState !== null && pluginState !== void 0 && pluginState.placeholder) {
|
|
34
|
+
var selection = state.selection;
|
|
35
|
+
var span = document.createElement('span');
|
|
36
|
+
span.textContent = pluginState.placeholder;
|
|
37
|
+
span.style.setProperty('color', "var(--ds-text-accent-blue, ".concat(B400, ")"));
|
|
38
|
+
return DecorationSet.create(state.doc, [Decoration.widget(selection.from, span)]);
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
import { ax, ix } from "@compiled/react/runtime";
|
|
4
4
|
import React, { useCallback, useEffect, useState } from 'react';
|
|
5
|
+
import { mentionPlaceholderPluginKey, MENTION_PLACEHOLDER_ACTIONS } from '../pm-plugins/mentionPlaceholder';
|
|
5
6
|
import { MENTION_SOURCE } from '../ui/type-ahead/analytics';
|
|
6
7
|
/**
|
|
7
8
|
* Container that renders the recaptcha component from the mention provider and manages handleSuccess.
|
|
@@ -10,7 +11,7 @@ import { MENTION_SOURCE } from '../ui/type-ahead/analytics';
|
|
|
10
11
|
* mentionProvider.showInlineInviteRecaptcha(email) which passes email to the component.
|
|
11
12
|
*/
|
|
12
13
|
export var InlineInviteRecaptchaContainer = function InlineInviteRecaptchaContainer(_ref) {
|
|
13
|
-
var _api$mention2, _api$
|
|
14
|
+
var _api$mention2, _api$core3;
|
|
14
15
|
var mentionProvider = _ref.mentionProvider,
|
|
15
16
|
api = _ref.api;
|
|
16
17
|
var _useState = useState(null),
|
|
@@ -47,10 +48,27 @@ export var InlineInviteRecaptchaContainer = function InlineInviteRecaptchaContai
|
|
|
47
48
|
userType: 'DEFAULT',
|
|
48
49
|
accessLevel: 'CONTAINER'
|
|
49
50
|
}));
|
|
51
|
+
api.core.actions.execute(function (_ref2) {
|
|
52
|
+
var tr = _ref2.tr;
|
|
53
|
+
tr.setMeta(mentionPlaceholderPluginKey, {
|
|
54
|
+
action: MENTION_PLACEHOLDER_ACTIONS.HIDE_PLACEHOLDER
|
|
55
|
+
});
|
|
56
|
+
return tr;
|
|
57
|
+
});
|
|
50
58
|
}, [api]);
|
|
51
59
|
var handleClose = useCallback(function () {
|
|
52
|
-
|
|
53
|
-
|
|
60
|
+
var _api$core2;
|
|
61
|
+
if (!(api !== null && api !== void 0 && (_api$core2 = api.core) !== null && _api$core2 !== void 0 && (_api$core2 = _api$core2.actions) !== null && _api$core2 !== void 0 && _api$core2.execute)) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
api.core.actions.execute(function (_ref3) {
|
|
65
|
+
var tr = _ref3.tr;
|
|
66
|
+
tr.setMeta(mentionPlaceholderPluginKey, {
|
|
67
|
+
action: MENTION_PLACEHOLDER_ACTIONS.HIDE_PLACEHOLDER
|
|
68
|
+
});
|
|
69
|
+
return tr;
|
|
70
|
+
});
|
|
71
|
+
}, [api]);
|
|
54
72
|
var handleReady = useCallback(function (showRecaptcha) {
|
|
55
73
|
if (provider) {
|
|
56
74
|
if (showRecaptcha) {
|
|
@@ -60,7 +78,7 @@ export var InlineInviteRecaptchaContainer = function InlineInviteRecaptchaContai
|
|
|
60
78
|
}
|
|
61
79
|
}
|
|
62
80
|
}, [provider]);
|
|
63
|
-
if (!(provider !== null && provider !== void 0 && provider.InlineInviteRecaptcha) || !(api !== null && api !== void 0 && (_api$mention2 = api.mention) !== null && _api$mention2 !== void 0 && (_api$mention2 = _api$mention2.commands) !== null && _api$mention2 !== void 0 && _api$mention2.insertMention) || !(api !== null && api !== void 0 && (_api$
|
|
81
|
+
if (!(provider !== null && provider !== void 0 && provider.InlineInviteRecaptcha) || !(api !== null && api !== void 0 && (_api$mention2 = api.mention) !== null && _api$mention2 !== void 0 && (_api$mention2 = _api$mention2.commands) !== null && _api$mention2 !== void 0 && _api$mention2.insertMention) || !(api !== null && api !== void 0 && (_api$core3 = api.core) !== null && _api$core3 !== void 0 && (_api$core3 = _api$core3.actions) !== null && _api$core3 !== void 0 && _api$core3.execute)) {
|
|
64
82
|
return null;
|
|
65
83
|
}
|
|
66
84
|
var RecaptchaComponent = provider.InlineInviteRecaptcha;
|
|
@@ -17,6 +17,7 @@ import { isResolvingMentionProvider } from '@atlaskit/mention/resource';
|
|
|
17
17
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
18
18
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
19
19
|
import { createSingleMentionFragment } from '../../editor-commands';
|
|
20
|
+
import { mentionPlaceholderPluginKey, MENTION_PLACEHOLDER_ACTIONS } from '../../pm-plugins/mentionPlaceholder';
|
|
20
21
|
import { getMentionPluginState } from '../../pm-plugins/utils';
|
|
21
22
|
import InviteItem, { INVITE_ITEM_DESCRIPTION } from '../InviteItem';
|
|
22
23
|
import InviteItemWithEmailDomain from '../InviteItem/InviteItemWithEmailDomain';
|
|
@@ -352,6 +353,12 @@ export var createTypeAheadConfig = function createTypeAheadConfig(_ref6) {
|
|
|
352
353
|
// If query already includes @, use it as is
|
|
353
354
|
if (email && mentionProvider.showInlineInviteRecaptcha) {
|
|
354
355
|
mentionProvider.showInlineInviteRecaptcha(email);
|
|
356
|
+
var tr = state.tr;
|
|
357
|
+
tr.setMeta(mentionPlaceholderPluginKey, {
|
|
358
|
+
action: MENTION_PLACEHOLDER_ACTIONS.SHOW_PLACEHOLDER,
|
|
359
|
+
placeholder: "@".concat(query)
|
|
360
|
+
});
|
|
361
|
+
return tr;
|
|
355
362
|
}
|
|
356
363
|
} else if (mentionProvider.onInviteItemClick) {
|
|
357
364
|
// Fallback to old behavior for backward compatibility
|
|
@@ -23,6 +23,7 @@ export declare class MentionNodeView implements NodeView {
|
|
|
23
23
|
constructor(node: PMNode, config: MentionNodeViewProps);
|
|
24
24
|
private setClassList;
|
|
25
25
|
private setTextContent;
|
|
26
|
+
private shouldHighlightMention;
|
|
26
27
|
private updateState;
|
|
27
28
|
private nodeIsEqual;
|
|
28
29
|
update(node: PMNode): boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
export declare const mentionPlaceholderPluginKey: PluginKey<any>;
|
|
4
|
+
export declare const MENTION_PLACEHOLDER_ACTIONS: {
|
|
5
|
+
SHOW_PLACEHOLDER: string;
|
|
6
|
+
HIDE_PLACEHOLDER: string;
|
|
7
|
+
};
|
|
8
|
+
export type MentionPlaceholderPluginState = {
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function createMentionPlaceholderPlugin(): SafePlugin<{}>;
|
|
@@ -23,6 +23,14 @@ export type MentionsChangedHandler = (changes: {
|
|
|
23
23
|
export interface MentionsPluginOptions extends MentionPluginConfig {
|
|
24
24
|
allowZeroWidthSpaceAfter?: boolean;
|
|
25
25
|
handleMentionsChanged?: MentionsChangedHandler;
|
|
26
|
+
/**
|
|
27
|
+
* User ID to highlight as a self-mention (typically the current user).
|
|
28
|
+
*
|
|
29
|
+
* When provided, mentions matching this ID will be highlighted immediately,
|
|
30
|
+
* without waiting for the mention provider to load. This enables instant highlighting on initial render.
|
|
31
|
+
* Takes priority over `MentionProvider.shouldHighlightMention()` if both are present.
|
|
32
|
+
*/
|
|
33
|
+
currentUserId?: string;
|
|
26
34
|
mentionProvider?: Providers['mentionProvider'];
|
|
27
35
|
sanitizePrivateContent?: boolean;
|
|
28
36
|
}
|
|
@@ -23,6 +23,7 @@ export declare class MentionNodeView implements NodeView {
|
|
|
23
23
|
constructor(node: PMNode, config: MentionNodeViewProps);
|
|
24
24
|
private setClassList;
|
|
25
25
|
private setTextContent;
|
|
26
|
+
private shouldHighlightMention;
|
|
26
27
|
private updateState;
|
|
27
28
|
private nodeIsEqual;
|
|
28
29
|
update(node: PMNode): boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
export declare const mentionPlaceholderPluginKey: PluginKey<any>;
|
|
4
|
+
export declare const MENTION_PLACEHOLDER_ACTIONS: {
|
|
5
|
+
SHOW_PLACEHOLDER: string;
|
|
6
|
+
HIDE_PLACEHOLDER: string;
|
|
7
|
+
};
|
|
8
|
+
export type MentionPlaceholderPluginState = {
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function createMentionPlaceholderPlugin(): SafePlugin<{}>;
|
|
@@ -23,6 +23,14 @@ export type MentionsChangedHandler = (changes: {
|
|
|
23
23
|
export interface MentionsPluginOptions extends MentionPluginConfig {
|
|
24
24
|
allowZeroWidthSpaceAfter?: boolean;
|
|
25
25
|
handleMentionsChanged?: MentionsChangedHandler;
|
|
26
|
+
/**
|
|
27
|
+
* User ID to highlight as a self-mention (typically the current user).
|
|
28
|
+
*
|
|
29
|
+
* When provided, mentions matching this ID will be highlighted immediately,
|
|
30
|
+
* without waiting for the mention provider to load. This enables instant highlighting on initial render.
|
|
31
|
+
* Takes priority over `MentionProvider.shouldHighlightMention()` if both are present.
|
|
32
|
+
*/
|
|
33
|
+
currentUserId?: string;
|
|
26
34
|
mentionProvider?: Providers['mentionProvider'];
|
|
27
35
|
sanitizePrivateContent?: boolean;
|
|
28
36
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-mentions",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.3.1",
|
|
4
4
|
"description": "Mentions plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -37,19 +37,19 @@
|
|
|
37
37
|
"@atlaskit/editor-plugin-selection": "^7.0.0",
|
|
38
38
|
"@atlaskit/editor-plugin-type-ahead": "^7.0.0",
|
|
39
39
|
"@atlaskit/editor-prosemirror": "^7.3.0",
|
|
40
|
-
"@atlaskit/icon": "^
|
|
40
|
+
"@atlaskit/icon": "^32.0.0",
|
|
41
41
|
"@atlaskit/insm": "^0.3.0",
|
|
42
42
|
"@atlaskit/link": "^3.3.0",
|
|
43
|
-
"@atlaskit/mention": "^24.
|
|
43
|
+
"@atlaskit/mention": "^24.5.0",
|
|
44
44
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
45
45
|
"@atlaskit/popper": "^7.1.0",
|
|
46
46
|
"@atlaskit/portal": "^5.2.0",
|
|
47
47
|
"@atlaskit/primitives": "^18.0.0",
|
|
48
48
|
"@atlaskit/profilecard": "^24.37.0",
|
|
49
49
|
"@atlaskit/theme": "^21.0.0",
|
|
50
|
-
"@atlaskit/tmp-editor-statsig": "^29.
|
|
50
|
+
"@atlaskit/tmp-editor-statsig": "^29.6.0",
|
|
51
51
|
"@atlaskit/tokens": "^11.0.0",
|
|
52
|
-
"@atlaskit/user-picker": "^11.
|
|
52
|
+
"@atlaskit/user-picker": "^11.23.0",
|
|
53
53
|
"@babel/runtime": "^7.0.0",
|
|
54
54
|
"@compiled/react": "^0.18.6",
|
|
55
55
|
"bind-event-listener": "^3.0.0",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"uuid": "^3.1.0"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"@atlaskit/editor-common": "^111.
|
|
60
|
+
"@atlaskit/editor-common": "^111.20.0",
|
|
61
61
|
"react": "^18.2.0",
|
|
62
62
|
"react-dom": "^18.2.0",
|
|
63
63
|
"react-intl-next": "npm:react-intl@^5.18.1"
|