@atlaskit/editor-plugin-mentions 16.0.3 → 16.1.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.
Files changed (36) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/anchored-popup/package.json +10 -0
  3. package/dist/cjs/entry-points/anchored-popup.js +12 -0
  4. package/dist/cjs/mentionsPlugin.js +4 -12
  5. package/dist/cjs/pm-plugins/main.js +1 -1
  6. package/dist/cjs/ui/AnchoredPopup.js +37 -0
  7. package/dist/cjs/ui/InlineInvitePopupContainer.js +157 -0
  8. package/dist/cjs/ui/type-ahead/analytics.js +2 -1
  9. package/dist/cjs/ui/type-ahead/index.js +26 -18
  10. package/dist/es2019/entry-points/anchored-popup.js +2 -0
  11. package/dist/es2019/mentionsPlugin.js +4 -10
  12. package/dist/es2019/pm-plugins/main.js +1 -1
  13. package/dist/es2019/ui/AnchoredPopup.js +28 -0
  14. package/dist/es2019/ui/InlineInvitePopupContainer.js +146 -0
  15. package/dist/es2019/ui/type-ahead/analytics.js +2 -1
  16. package/dist/es2019/ui/type-ahead/index.js +26 -20
  17. package/dist/esm/entry-points/anchored-popup.js +2 -0
  18. package/dist/esm/mentionsPlugin.js +4 -12
  19. package/dist/esm/pm-plugins/main.js +1 -1
  20. package/dist/esm/ui/AnchoredPopup.js +29 -0
  21. package/dist/esm/ui/InlineInvitePopupContainer.js +148 -0
  22. package/dist/esm/ui/type-ahead/analytics.js +2 -1
  23. package/dist/esm/ui/type-ahead/index.js +26 -18
  24. package/dist/types/entry-points/anchored-popup.d.ts +2 -0
  25. package/dist/types/ui/AnchoredPopup.d.ts +13 -0
  26. package/dist/types/ui/InlineInvitePopupContainer.d.ts +11 -0
  27. package/dist/types/ui/type-ahead/analytics.d.ts +1 -1
  28. package/package.json +11 -5
  29. package/dist/cjs/pm-plugins/mentionPlaceholder.js +0 -52
  30. package/dist/cjs/ui/InlineInviteRecaptchaContainer.js +0 -100
  31. package/dist/es2019/pm-plugins/mentionPlaceholder.js +0 -44
  32. package/dist/es2019/ui/InlineInviteRecaptchaContainer.js +0 -90
  33. package/dist/esm/pm-plugins/mentionPlaceholder.js +0 -44
  34. package/dist/esm/ui/InlineInviteRecaptchaContainer.js +0 -91
  35. package/dist/types/pm-plugins/mentionPlaceholder.d.ts +0 -11
  36. package/dist/types/ui/InlineInviteRecaptchaContainer.d.ts +0 -15
@@ -1,100 +0,0 @@
1
- /* InlineInviteRecaptchaContainer.tsx generated by @compiled/babel-plugin v2.0.0 */
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.InlineInviteRecaptchaContainer = void 0;
10
- var _runtime = require("@compiled/react/runtime");
11
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
12
- var _react = _interopRequireWildcard(require("react"));
13
- var _mentionPlaceholder = require("../pm-plugins/mentionPlaceholder");
14
- var _analytics = require("../ui/type-ahead/analytics");
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); }
16
- /**
17
- * Container that renders the recaptcha component from the mention provider and manages handleSuccess.
18
- * Does NOT pass email - the provider's component uses useInlineInviteRecaptcha hook internally
19
- * and wires showRecaptcha to the provider. When user clicks invite item, type-ahead calls
20
- * mentionProvider.showInlineInviteRecaptcha(email) which passes email to the component.
21
- */
22
- var InlineInviteRecaptchaContainer = exports.InlineInviteRecaptchaContainer = function InlineInviteRecaptchaContainer(_ref) {
23
- var _api$mention2, _api$core3;
24
- var mentionProvider = _ref.mentionProvider,
25
- api = _ref.api;
26
- var _useState = (0, _react.useState)(null),
27
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
28
- provider = _useState2[0],
29
- setProvider = _useState2[1];
30
- (0, _react.useEffect)(function () {
31
- if (!mentionProvider) {
32
- return;
33
- }
34
- var isMounted = true;
35
- mentionProvider.then(function (resolvedProvider) {
36
- if (!isMounted) {
37
- return;
38
- }
39
- setProvider(resolvedProvider);
40
- }).catch(function () {
41
- // Silently handle promise rejection
42
- });
43
- return function () {
44
- isMounted = false;
45
- setProvider(null);
46
- };
47
- }, [mentionProvider]);
48
- var handleSuccess = (0, _react.useCallback)(function (userId, email) {
49
- var _api$mention, _api$core;
50
- if (!(api !== null && api !== void 0 && (_api$mention = api.mention) !== null && _api$mention !== void 0 && (_api$mention = _api$mention.commands) !== null && _api$mention !== void 0 && _api$mention.insertMention) || !(api !== null && api !== void 0 && (_api$core = api.core) !== null && _api$core !== void 0 && (_api$core = _api$core.actions) !== null && _api$core !== void 0 && _api$core.execute)) {
51
- return;
52
- }
53
- var name = email.split('@')[0] || email;
54
- api.core.actions.execute(api.mention.commands.insertMention({
55
- id: userId,
56
- name: name,
57
- userType: 'DEFAULT',
58
- accessLevel: 'CONTAINER'
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
- });
67
- }, [api]);
68
- var handleClose = (0, _react.useCallback)(function () {
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]);
81
- var handleReady = (0, _react.useCallback)(function (showRecaptcha) {
82
- if (provider) {
83
- if (showRecaptcha) {
84
- provider.showInlineInviteRecaptcha = showRecaptcha;
85
- } else {
86
- delete provider.showInlineInviteRecaptcha;
87
- }
88
- }
89
- }, [provider]);
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)) {
91
- return null;
92
- }
93
- var RecaptchaComponent = provider.InlineInviteRecaptcha;
94
- return /*#__PURE__*/_react.default.createElement(RecaptchaComponent, {
95
- analyticsSource: _analytics.MENTION_SOURCE,
96
- onSuccess: handleSuccess,
97
- onClose: handleClose,
98
- onReady: handleReady
99
- });
100
- };
@@ -1,44 +0,0 @@
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
- export const mentionPlaceholderPluginKey = new PluginKey('mentionPlaceholderPlugin');
5
- export const MENTION_PLACEHOLDER_ACTIONS = {
6
- SHOW_PLACEHOLDER: 'SHOW_PLACEHOLDER',
7
- HIDE_PLACEHOLDER: 'HIDE_PLACEHOLDER'
8
- };
9
- // eslint-disable-next-line @typescript-eslint/no-empty-object-type
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, #1558BC)");
38
- return DecorationSet.create(state.doc, [Decoration.widget(selection.from, span)]);
39
- }
40
- return null;
41
- }
42
- }
43
- });
44
- }
@@ -1,90 +0,0 @@
1
- /* InlineInviteRecaptchaContainer.tsx generated by @compiled/babel-plugin v2.0.0 */
2
- import { ax, ix } from "@compiled/react/runtime";
3
- import React, { useCallback, useEffect, useState } from 'react';
4
- import { mentionPlaceholderPluginKey, MENTION_PLACEHOLDER_ACTIONS } from '../pm-plugins/mentionPlaceholder';
5
- import { MENTION_SOURCE } from '../ui/type-ahead/analytics';
6
- /**
7
- * Container that renders the recaptcha component from the mention provider and manages handleSuccess.
8
- * Does NOT pass email - the provider's component uses useInlineInviteRecaptcha hook internally
9
- * and wires showRecaptcha to the provider. When user clicks invite item, type-ahead calls
10
- * mentionProvider.showInlineInviteRecaptcha(email) which passes email to the component.
11
- */
12
- export const InlineInviteRecaptchaContainer = ({
13
- mentionProvider,
14
- api
15
- }) => {
16
- var _api$mention2, _api$mention2$command, _api$core3, _api$core3$actions;
17
- const [provider, setProvider] = useState(null);
18
- useEffect(() => {
19
- if (!mentionProvider) {
20
- return;
21
- }
22
- let isMounted = true;
23
- mentionProvider.then(resolvedProvider => {
24
- if (!isMounted) {
25
- return;
26
- }
27
- setProvider(resolvedProvider);
28
- }).catch(() => {
29
- // Silently handle promise rejection
30
- });
31
- return () => {
32
- isMounted = false;
33
- setProvider(null);
34
- };
35
- }, [mentionProvider]);
36
- const handleSuccess = useCallback((userId, email) => {
37
- var _api$mention, _api$mention$commands, _api$core, _api$core$actions;
38
- if (!(api !== null && api !== void 0 && (_api$mention = api.mention) !== null && _api$mention !== void 0 && (_api$mention$commands = _api$mention.commands) !== null && _api$mention$commands !== void 0 && _api$mention$commands.insertMention) || !(api !== null && api !== void 0 && (_api$core = api.core) !== null && _api$core !== void 0 && (_api$core$actions = _api$core.actions) !== null && _api$core$actions !== void 0 && _api$core$actions.execute)) {
39
- return;
40
- }
41
- const name = email.split('@')[0] || email;
42
- api.core.actions.execute(api.mention.commands.insertMention({
43
- id: userId,
44
- name,
45
- userType: 'DEFAULT',
46
- accessLevel: 'CONTAINER'
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
- });
56
- }, [api]);
57
- const handleClose = useCallback(() => {
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]);
71
- const handleReady = useCallback(showRecaptcha => {
72
- if (provider) {
73
- if (showRecaptcha) {
74
- provider.showInlineInviteRecaptcha = showRecaptcha;
75
- } else {
76
- delete provider.showInlineInviteRecaptcha;
77
- }
78
- }
79
- }, [provider]);
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)) {
81
- return null;
82
- }
83
- const RecaptchaComponent = provider.InlineInviteRecaptcha;
84
- return /*#__PURE__*/React.createElement(RecaptchaComponent, {
85
- analyticsSource: MENTION_SOURCE,
86
- onSuccess: handleSuccess,
87
- onClose: handleClose,
88
- onReady: handleReady
89
- });
90
- };
@@ -1,44 +0,0 @@
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
- export var mentionPlaceholderPluginKey = new PluginKey('mentionPlaceholderPlugin');
5
- export var MENTION_PLACEHOLDER_ACTIONS = {
6
- SHOW_PLACEHOLDER: 'SHOW_PLACEHOLDER',
7
- HIDE_PLACEHOLDER: 'HIDE_PLACEHOLDER'
8
- };
9
- // eslint-disable-next-line @typescript-eslint/no-empty-object-type
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, #1558BC)");
38
- return DecorationSet.create(state.doc, [Decoration.widget(selection.from, span)]);
39
- }
40
- return null;
41
- }
42
- }
43
- });
44
- }
@@ -1,91 +0,0 @@
1
- /* InlineInviteRecaptchaContainer.tsx generated by @compiled/babel-plugin v2.0.0 */
2
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
- import { ax, ix } from "@compiled/react/runtime";
4
- import React, { useCallback, useEffect, useState } from 'react';
5
- import { mentionPlaceholderPluginKey, MENTION_PLACEHOLDER_ACTIONS } from '../pm-plugins/mentionPlaceholder';
6
- import { MENTION_SOURCE } from '../ui/type-ahead/analytics';
7
- /**
8
- * Container that renders the recaptcha component from the mention provider and manages handleSuccess.
9
- * Does NOT pass email - the provider's component uses useInlineInviteRecaptcha hook internally
10
- * and wires showRecaptcha to the provider. When user clicks invite item, type-ahead calls
11
- * mentionProvider.showInlineInviteRecaptcha(email) which passes email to the component.
12
- */
13
- export var InlineInviteRecaptchaContainer = function InlineInviteRecaptchaContainer(_ref) {
14
- var _api$mention2, _api$core3;
15
- var mentionProvider = _ref.mentionProvider,
16
- api = _ref.api;
17
- var _useState = useState(null),
18
- _useState2 = _slicedToArray(_useState, 2),
19
- provider = _useState2[0],
20
- setProvider = _useState2[1];
21
- useEffect(function () {
22
- if (!mentionProvider) {
23
- return;
24
- }
25
- var isMounted = true;
26
- mentionProvider.then(function (resolvedProvider) {
27
- if (!isMounted) {
28
- return;
29
- }
30
- setProvider(resolvedProvider);
31
- }).catch(function () {
32
- // Silently handle promise rejection
33
- });
34
- return function () {
35
- isMounted = false;
36
- setProvider(null);
37
- };
38
- }, [mentionProvider]);
39
- var handleSuccess = useCallback(function (userId, email) {
40
- var _api$mention, _api$core;
41
- if (!(api !== null && api !== void 0 && (_api$mention = api.mention) !== null && _api$mention !== void 0 && (_api$mention = _api$mention.commands) !== null && _api$mention !== void 0 && _api$mention.insertMention) || !(api !== null && api !== void 0 && (_api$core = api.core) !== null && _api$core !== void 0 && (_api$core = _api$core.actions) !== null && _api$core !== void 0 && _api$core.execute)) {
42
- return;
43
- }
44
- var name = email.split('@')[0] || email;
45
- api.core.actions.execute(api.mention.commands.insertMention({
46
- id: userId,
47
- name: name,
48
- userType: 'DEFAULT',
49
- accessLevel: 'CONTAINER'
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
- });
58
- }, [api]);
59
- var handleClose = useCallback(function () {
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]);
72
- var handleReady = useCallback(function (showRecaptcha) {
73
- if (provider) {
74
- if (showRecaptcha) {
75
- provider.showInlineInviteRecaptcha = showRecaptcha;
76
- } else {
77
- delete provider.showInlineInviteRecaptcha;
78
- }
79
- }
80
- }, [provider]);
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)) {
82
- return null;
83
- }
84
- var RecaptchaComponent = provider.InlineInviteRecaptcha;
85
- return /*#__PURE__*/React.createElement(RecaptchaComponent, {
86
- analyticsSource: MENTION_SOURCE,
87
- onSuccess: handleSuccess,
88
- onClose: handleClose,
89
- onReady: handleReady
90
- });
91
- };
@@ -1,11 +0,0 @@
1
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
- export declare const mentionPlaceholderPluginKey: PluginKey;
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<{}>;
@@ -1,15 +0,0 @@
1
- import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
- import type { MentionProvider } from '@atlaskit/mention/resource';
3
- import type { MentionsPlugin } from '../mentionsPluginType';
4
- interface Props {
5
- api: ExtractInjectionAPI<MentionsPlugin> | undefined;
6
- mentionProvider: Promise<MentionProvider> | undefined;
7
- }
8
- /**
9
- * Container that renders the recaptcha component from the mention provider and manages handleSuccess.
10
- * Does NOT pass email - the provider's component uses useInlineInviteRecaptcha hook internally
11
- * and wires showRecaptcha to the provider. When user clicks invite item, type-ahead calls
12
- * mentionProvider.showInlineInviteRecaptcha(email) which passes email to the component.
13
- */
14
- export declare const InlineInviteRecaptchaContainer: ({ mentionProvider, api, }: Props) => JSX.Element | null;
15
- export {};