@atlaskit/editor-plugin-mentions 0.1.16 → 0.1.18

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/editor-plugin-mentions
2
2
 
3
+ ## 0.1.18
4
+
5
+ ### Patch Changes
6
+
7
+ - [#67189](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/67189) [`93cbf53ca0e0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/93cbf53ca0e0) - Removing instances of WithPluginState from mentions and type-ahead plugins.
8
+
9
+ ## 0.1.17
10
+
11
+ ### Patch Changes
12
+
13
+ - [#65802](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/65802) [`438ead060875`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/438ead060875) - Ensure all editor plugins are marked as singletons
14
+
3
15
  ## 0.1.16
4
16
 
5
17
  ### Patch Changes
@@ -12,12 +12,11 @@ var _adfSchema = require("@atlaskit/adf-schema");
12
12
  var _analytics = require("@atlaskit/editor-common/analytics");
13
13
  var _messages = require("@atlaskit/editor-common/messages");
14
14
  var _quickInsert = require("@atlaskit/editor-common/quick-insert");
15
- var _withPluginState = require("@atlaskit/editor-common/with-plugin-state");
16
15
  var _resource = require("@atlaskit/mention/resource");
17
16
  var _key = require("./pm-plugins/key");
18
17
  var _main = require("./pm-plugins/main");
19
18
  var _typeAhead = require("./type-ahead");
20
- var _ToolbarMention = _interopRequireDefault(require("./ui/ToolbarMention"));
19
+ var _SecondaryToolbarComponent = require("./ui/SecondaryToolbarComponent");
21
20
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
22
21
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
23
22
  var mentionsPlugin = exports.mentionsPlugin = function mentionsPlugin(_ref) {
@@ -61,33 +60,17 @@ var mentionsPlugin = exports.mentionsPlugin = function mentionsPlugin(_ref) {
61
60
  secondaryToolbarComponent: function secondaryToolbarComponent(_ref3) {
62
61
  var editorView = _ref3.editorView,
63
62
  disabled = _ref3.disabled;
64
- var openMentionTypeAhead = function openMentionTypeAhead() {
65
- var _api$typeAhead;
66
- api === null || api === void 0 || (_api$typeAhead = api.typeAhead) === null || _api$typeAhead === void 0 || (_api$typeAhead = _api$typeAhead.actions) === null || _api$typeAhead === void 0 || _api$typeAhead.open({
67
- triggerHandler: typeAhead,
68
- inputMethod: _analytics.INPUT_METHOD.INSERT_MENU
69
- });
70
- };
71
- return /*#__PURE__*/_react.default.createElement(_withPluginState.WithPluginState, {
63
+ return /*#__PURE__*/_react.default.createElement(_SecondaryToolbarComponent.SecondaryToolbarComponent, {
72
64
  editorView: editorView,
73
- plugins: {
74
- mentionState: _key.mentionPluginKey
75
- },
76
- render: function render(_ref4) {
77
- var _ref4$mentionState = _ref4.mentionState,
78
- mentionState = _ref4$mentionState === void 0 ? {} : _ref4$mentionState;
79
- return !mentionState.mentionProvider ? null : /*#__PURE__*/_react.default.createElement(_ToolbarMention.default, {
80
- editorView: editorView,
81
- onInsertMention: openMentionTypeAhead,
82
- isDisabled: disabled || (api === null || api === void 0 ? void 0 : api.typeAhead.actions.isAllowed(editorView.state))
83
- });
84
- }
65
+ api: api,
66
+ disabled: disabled,
67
+ typeAhead: typeAhead
85
68
  });
86
69
  },
87
70
  actions: {
88
71
  openTypeAhead: function openTypeAhead(inputMethod) {
89
- var _api$typeAhead2;
90
- return Boolean(api === null || api === void 0 || (_api$typeAhead2 = api.typeAhead) === null || _api$typeAhead2 === void 0 || (_api$typeAhead2 = _api$typeAhead2.actions) === null || _api$typeAhead2 === void 0 ? void 0 : _api$typeAhead2.open({
72
+ var _api$typeAhead;
73
+ return Boolean(api === null || api === void 0 || (_api$typeAhead = api.typeAhead) === null || _api$typeAhead === void 0 || (_api$typeAhead = _api$typeAhead.actions) === null || _api$typeAhead === void 0 ? void 0 : _api$typeAhead.open({
91
74
  triggerHandler: typeAhead,
92
75
  inputMethod: inputMethod
93
76
  }));
@@ -103,8 +86,8 @@ var mentionsPlugin = exports.mentionsPlugin = function mentionsPlugin(_ref) {
103
86
  });
104
87
  },
105
88
  pluginsOptions: {
106
- quickInsert: function quickInsert(_ref5) {
107
- var formatMessage = _ref5.formatMessage;
89
+ quickInsert: function quickInsert(_ref4) {
90
+ var formatMessage = _ref4.formatMessage;
108
91
  return [{
109
92
  id: 'mention',
110
93
  title: formatMessage(_messages.toolbarInsertBlockMessages.mention),
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.SecondaryToolbarComponent = SecondaryToolbarComponent;
9
+ var _react = _interopRequireWildcard(require("react"));
10
+ var _analytics = require("@atlaskit/editor-common/analytics");
11
+ var _hooks = require("@atlaskit/editor-common/hooks");
12
+ var _ToolbarMention = _interopRequireDefault(require("./ToolbarMention"));
13
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
14
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15
+ function SecondaryToolbarComponent(_ref) {
16
+ var editorView = _ref.editorView,
17
+ api = _ref.api,
18
+ typeAhead = _ref.typeAhead,
19
+ disabled = _ref.disabled;
20
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['mention']),
21
+ mentionState = _useSharedPluginState.mentionState;
22
+ var openMentionTypeAhead = (0, _react.useCallback)(function () {
23
+ var _api$typeAhead;
24
+ api === null || api === void 0 || (_api$typeAhead = api.typeAhead) === null || _api$typeAhead === void 0 || (_api$typeAhead = _api$typeAhead.actions) === null || _api$typeAhead === void 0 || _api$typeAhead.open({
25
+ triggerHandler: typeAhead,
26
+ inputMethod: _analytics.INPUT_METHOD.INSERT_MENU
27
+ });
28
+ }, [api, typeAhead]);
29
+ return !(mentionState !== null && mentionState !== void 0 && mentionState.mentionProvider) ? null : /*#__PURE__*/_react.default.createElement(_ToolbarMention.default, {
30
+ editorView: editorView,
31
+ onInsertMention: openMentionTypeAhead,
32
+ isDisabled: disabled || (api === null || api === void 0 ? void 0 : api.typeAhead.actions.isAllowed(editorView.state))
33
+ });
34
+ }
@@ -4,12 +4,11 @@ import { mention } from '@atlaskit/adf-schema';
4
4
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
5
5
  import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
6
6
  import { IconMention } from '@atlaskit/editor-common/quick-insert';
7
- import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
8
7
  import { ELEMENTS_CHANNEL } from '@atlaskit/mention/resource';
9
8
  import { mentionPluginKey } from './pm-plugins/key';
10
9
  import { createMentionPlugin } from './pm-plugins/main';
11
10
  import { createTypeAheadConfig } from './type-ahead';
12
- import ToolbarMention from './ui/ToolbarMention';
11
+ import { SecondaryToolbarComponent } from './ui/SecondaryToolbarComponent';
13
12
  const mentionsPlugin = ({
14
13
  config: options,
15
14
  api
@@ -52,31 +51,17 @@ const mentionsPlugin = ({
52
51
  editorView,
53
52
  disabled
54
53
  }) {
55
- const openMentionTypeAhead = () => {
56
- var _api$typeAhead, _api$typeAhead$action;
57
- api === null || api === void 0 ? void 0 : (_api$typeAhead = api.typeAhead) === null || _api$typeAhead === void 0 ? void 0 : (_api$typeAhead$action = _api$typeAhead.actions) === null || _api$typeAhead$action === void 0 ? void 0 : _api$typeAhead$action.open({
58
- triggerHandler: typeAhead,
59
- inputMethod: INPUT_METHOD.INSERT_MENU
60
- });
61
- };
62
- return /*#__PURE__*/React.createElement(WithPluginState, {
54
+ return /*#__PURE__*/React.createElement(SecondaryToolbarComponent, {
63
55
  editorView: editorView,
64
- plugins: {
65
- mentionState: mentionPluginKey
66
- },
67
- render: ({
68
- mentionState = {}
69
- }) => !mentionState.mentionProvider ? null : /*#__PURE__*/React.createElement(ToolbarMention, {
70
- editorView: editorView,
71
- onInsertMention: openMentionTypeAhead,
72
- isDisabled: disabled || (api === null || api === void 0 ? void 0 : api.typeAhead.actions.isAllowed(editorView.state))
73
- })
56
+ api: api,
57
+ disabled: disabled,
58
+ typeAhead: typeAhead
74
59
  });
75
60
  },
76
61
  actions: {
77
62
  openTypeAhead(inputMethod) {
78
- var _api$typeAhead2, _api$typeAhead2$actio;
79
- return Boolean(api === null || api === void 0 ? void 0 : (_api$typeAhead2 = api.typeAhead) === null || _api$typeAhead2 === void 0 ? void 0 : (_api$typeAhead2$actio = _api$typeAhead2.actions) === null || _api$typeAhead2$actio === void 0 ? void 0 : _api$typeAhead2$actio.open({
63
+ var _api$typeAhead, _api$typeAhead$action;
64
+ return Boolean(api === null || api === void 0 ? void 0 : (_api$typeAhead = api.typeAhead) === null || _api$typeAhead === void 0 ? void 0 : (_api$typeAhead$action = _api$typeAhead.actions) === null || _api$typeAhead$action === void 0 ? void 0 : _api$typeAhead$action.open({
80
65
  triggerHandler: typeAhead,
81
66
  inputMethod
82
67
  }));
@@ -0,0 +1,26 @@
1
+ import React, { useCallback } from 'react';
2
+ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
4
+ import ToolbarMention from './ToolbarMention';
5
+ export function SecondaryToolbarComponent({
6
+ editorView,
7
+ api,
8
+ typeAhead,
9
+ disabled
10
+ }) {
11
+ const {
12
+ mentionState
13
+ } = useSharedPluginState(api, ['mention']);
14
+ const openMentionTypeAhead = useCallback(() => {
15
+ var _api$typeAhead, _api$typeAhead$action;
16
+ api === null || api === void 0 ? void 0 : (_api$typeAhead = api.typeAhead) === null || _api$typeAhead === void 0 ? void 0 : (_api$typeAhead$action = _api$typeAhead.actions) === null || _api$typeAhead$action === void 0 ? void 0 : _api$typeAhead$action.open({
17
+ triggerHandler: typeAhead,
18
+ inputMethod: INPUT_METHOD.INSERT_MENU
19
+ });
20
+ }, [api, typeAhead]);
21
+ return !(mentionState !== null && mentionState !== void 0 && mentionState.mentionProvider) ? null : /*#__PURE__*/React.createElement(ToolbarMention, {
22
+ editorView: editorView,
23
+ onInsertMention: openMentionTypeAhead,
24
+ isDisabled: disabled || (api === null || api === void 0 ? void 0 : api.typeAhead.actions.isAllowed(editorView.state))
25
+ });
26
+ }
@@ -7,12 +7,11 @@ import { mention } from '@atlaskit/adf-schema';
7
7
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
8
8
  import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
9
9
  import { IconMention } from '@atlaskit/editor-common/quick-insert';
10
- import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
11
10
  import { ELEMENTS_CHANNEL } from '@atlaskit/mention/resource';
12
11
  import { mentionPluginKey } from './pm-plugins/key';
13
12
  import { createMentionPlugin } from './pm-plugins/main';
14
13
  import { createTypeAheadConfig } from './type-ahead';
15
- import ToolbarMention from './ui/ToolbarMention';
14
+ import { SecondaryToolbarComponent } from './ui/SecondaryToolbarComponent';
16
15
  var mentionsPlugin = function mentionsPlugin(_ref) {
17
16
  var options = _ref.config,
18
17
  api = _ref.api;
@@ -54,33 +53,17 @@ var mentionsPlugin = function mentionsPlugin(_ref) {
54
53
  secondaryToolbarComponent: function secondaryToolbarComponent(_ref3) {
55
54
  var editorView = _ref3.editorView,
56
55
  disabled = _ref3.disabled;
57
- var openMentionTypeAhead = function openMentionTypeAhead() {
58
- var _api$typeAhead;
59
- api === null || api === void 0 || (_api$typeAhead = api.typeAhead) === null || _api$typeAhead === void 0 || (_api$typeAhead = _api$typeAhead.actions) === null || _api$typeAhead === void 0 || _api$typeAhead.open({
60
- triggerHandler: typeAhead,
61
- inputMethod: INPUT_METHOD.INSERT_MENU
62
- });
63
- };
64
- return /*#__PURE__*/React.createElement(WithPluginState, {
56
+ return /*#__PURE__*/React.createElement(SecondaryToolbarComponent, {
65
57
  editorView: editorView,
66
- plugins: {
67
- mentionState: mentionPluginKey
68
- },
69
- render: function render(_ref4) {
70
- var _ref4$mentionState = _ref4.mentionState,
71
- mentionState = _ref4$mentionState === void 0 ? {} : _ref4$mentionState;
72
- return !mentionState.mentionProvider ? null : /*#__PURE__*/React.createElement(ToolbarMention, {
73
- editorView: editorView,
74
- onInsertMention: openMentionTypeAhead,
75
- isDisabled: disabled || (api === null || api === void 0 ? void 0 : api.typeAhead.actions.isAllowed(editorView.state))
76
- });
77
- }
58
+ api: api,
59
+ disabled: disabled,
60
+ typeAhead: typeAhead
78
61
  });
79
62
  },
80
63
  actions: {
81
64
  openTypeAhead: function openTypeAhead(inputMethod) {
82
- var _api$typeAhead2;
83
- return Boolean(api === null || api === void 0 || (_api$typeAhead2 = api.typeAhead) === null || _api$typeAhead2 === void 0 || (_api$typeAhead2 = _api$typeAhead2.actions) === null || _api$typeAhead2 === void 0 ? void 0 : _api$typeAhead2.open({
65
+ var _api$typeAhead;
66
+ return Boolean(api === null || api === void 0 || (_api$typeAhead = api.typeAhead) === null || _api$typeAhead === void 0 || (_api$typeAhead = _api$typeAhead.actions) === null || _api$typeAhead === void 0 ? void 0 : _api$typeAhead.open({
84
67
  triggerHandler: typeAhead,
85
68
  inputMethod: inputMethod
86
69
  }));
@@ -96,8 +79,8 @@ var mentionsPlugin = function mentionsPlugin(_ref) {
96
79
  });
97
80
  },
98
81
  pluginsOptions: {
99
- quickInsert: function quickInsert(_ref5) {
100
- var formatMessage = _ref5.formatMessage;
82
+ quickInsert: function quickInsert(_ref4) {
83
+ var formatMessage = _ref4.formatMessage;
101
84
  return [{
102
85
  id: 'mention',
103
86
  title: formatMessage(messages.mention),
@@ -0,0 +1,24 @@
1
+ import React, { useCallback } from 'react';
2
+ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
4
+ import ToolbarMention from './ToolbarMention';
5
+ export function SecondaryToolbarComponent(_ref) {
6
+ var editorView = _ref.editorView,
7
+ api = _ref.api,
8
+ typeAhead = _ref.typeAhead,
9
+ disabled = _ref.disabled;
10
+ var _useSharedPluginState = useSharedPluginState(api, ['mention']),
11
+ mentionState = _useSharedPluginState.mentionState;
12
+ var openMentionTypeAhead = useCallback(function () {
13
+ var _api$typeAhead;
14
+ api === null || api === void 0 || (_api$typeAhead = api.typeAhead) === null || _api$typeAhead === void 0 || (_api$typeAhead = _api$typeAhead.actions) === null || _api$typeAhead === void 0 || _api$typeAhead.open({
15
+ triggerHandler: typeAhead,
16
+ inputMethod: INPUT_METHOD.INSERT_MENU
17
+ });
18
+ }, [api, typeAhead]);
19
+ return !(mentionState !== null && mentionState !== void 0 && mentionState.mentionProvider) ? null : /*#__PURE__*/React.createElement(ToolbarMention, {
20
+ editorView: editorView,
21
+ onInsertMention: openMentionTypeAhead,
22
+ isDisabled: disabled || (api === null || api === void 0 ? void 0 : api.typeAhead.actions.isAllowed(editorView.state))
23
+ });
24
+ }
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ import type { ExtractInjectionAPI, TypeAheadHandler } from '@atlaskit/editor-common/types';
3
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
+ import type { MentionsPlugin } from '../types';
5
+ interface SecondaryToolbarComponentProps {
6
+ editorView: EditorView;
7
+ api: ExtractInjectionAPI<MentionsPlugin> | undefined;
8
+ typeAhead: TypeAheadHandler;
9
+ disabled: boolean;
10
+ }
11
+ export declare function SecondaryToolbarComponent({ editorView, api, typeAhead, disabled, }: SecondaryToolbarComponentProps): JSX.Element | null;
12
+ export {};
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ import type { ExtractInjectionAPI, TypeAheadHandler } from '@atlaskit/editor-common/types';
3
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
+ import type { MentionsPlugin } from '../types';
5
+ interface SecondaryToolbarComponentProps {
6
+ editorView: EditorView;
7
+ api: ExtractInjectionAPI<MentionsPlugin> | undefined;
8
+ typeAhead: TypeAheadHandler;
9
+ disabled: boolean;
10
+ }
11
+ export declare function SecondaryToolbarComponent({ editorView, api, typeAhead, disabled, }: SecondaryToolbarComponentProps): JSX.Element | null;
12
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-mentions",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "description": "Mentions plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -9,11 +9,12 @@
9
9
  },
10
10
  "atlassian": {
11
11
  "team": "Editor: AI",
12
+ "singleton": true,
12
13
  "inPublicMirror": false,
13
14
  "releaseModel": "continuous",
14
15
  "runReact18": false
15
16
  },
16
- "repository": "https://bitbucket.org/atlassian/atlassian-frontend",
17
+ "repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
17
18
  "main": "dist/cjs/index.js",
18
19
  "module": "dist/esm/index.js",
19
20
  "module:es2019": "dist/es2019/index.js",
@@ -34,7 +35,7 @@
34
35
  "dependencies": {
35
36
  "@atlaskit/adf-schema": "^35.3.0",
36
37
  "@atlaskit/analytics-gas-types": "^5.1.0",
37
- "@atlaskit/editor-common": "^76.35.0",
38
+ "@atlaskit/editor-common": "^76.39.0",
38
39
  "@atlaskit/editor-plugin-analytics": "^0.4.0",
39
40
  "@atlaskit/editor-plugin-type-ahead": "^0.9.0",
40
41
  "@atlaskit/editor-prosemirror": "1.1.0",
@@ -55,7 +56,6 @@
55
56
  "@af/visual-regression": "*",
56
57
  "@atlaskit/ssr": "*",
57
58
  "@atlaskit/visual-regression": "*",
58
- "@atlaskit/webdriver-runner": "*",
59
59
  "@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
60
60
  "@testing-library/react": "^12.1.5",
61
61
  "react-dom": "^16.8.0",