@atlaskit/editor-plugin-quick-insert 1.7.3 → 1.8.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 CHANGED
@@ -1,5 +1,20 @@
1
1
  # @atlaskit/editor-plugin-quick-insert
2
2
 
3
+ ## 1.8.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 1.8.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#173737](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/173737)
14
+ [`965f739a481f5`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/965f739a481f5) -
15
+ [ux] Items are disabled in the plus menu while offline. This affects arrow navigation in the plus
16
+ menu and element browser
17
+
3
18
  ## 1.7.3
4
19
 
5
20
  ### Patch Changes
@@ -6,28 +6,36 @@ Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.default = void 0;
9
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
10
  var _react = _interopRequireWildcard(require("react"));
10
11
  var _hooks = require("@atlaskit/editor-common/hooks");
11
12
  var _commands = require("../../pm-plugins/commands");
12
13
  var _ModalElementBrowser = _interopRequireDefault(require("./ModalElementBrowser"));
13
14
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
14
15
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
16
+ 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; }
17
+ 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; }
15
18
  var Modal = function Modal(_ref) {
16
19
  var quickInsertState = _ref.quickInsertState,
20
+ isOffline = _ref.isOffline,
17
21
  editorView = _ref.editorView,
18
22
  helpUrl = _ref.helpUrl,
19
23
  insertItem = _ref.insertItem,
20
24
  getSuggestions = _ref.getSuggestions;
21
25
  var getItems = (0, _react.useCallback)(function (query, category) {
22
- var _getSuggestions;
23
- return (_getSuggestions = getSuggestions === null || getSuggestions === void 0 ? void 0 : getSuggestions({
26
+ var _getSuggestions$map, _getSuggestions;
27
+ return (_getSuggestions$map = getSuggestions === null || getSuggestions === void 0 || (_getSuggestions = getSuggestions({
24
28
  query: query,
25
29
  category: category
26
- })) !== null && _getSuggestions !== void 0 ? _getSuggestions : [];
30
+ })) === null || _getSuggestions === void 0 ? void 0 : _getSuggestions.map(function (item) {
31
+ return isOffline && item.isDisabledOffline ? _objectSpread(_objectSpread({}, item), {}, {
32
+ isDisabled: true
33
+ }) : item;
34
+ })) !== null && _getSuggestions$map !== void 0 ? _getSuggestions$map : [];
27
35
  },
28
36
  // See: https://stash.atlassian.com/projects/ATLASSIAN/repos/atlassian-frontend-monorepo/pull-requests/157796/overview?commentId=8559952
29
37
  // eslint-disable-next-line react-hooks/exhaustive-deps
30
- [getSuggestions, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems]);
38
+ [getSuggestions, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems, isOffline]);
31
39
  var focusInEditor = (0, _react.useCallback)(function () {
32
40
  if (!editorView.hasFocus()) {
33
41
  editorView.focus();
@@ -72,12 +80,14 @@ var _default = exports.default = function _default(_ref2) {
72
80
  var editorView = _ref2.editorView,
73
81
  helpUrl = _ref2.helpUrl,
74
82
  pluginInjectionAPI = _ref2.pluginInjectionAPI;
75
- var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionAPI, ['quickInsert']),
76
- quickInsertState = _useSharedPluginState.quickInsertState;
83
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionAPI, ['quickInsert', 'connectivity']),
84
+ quickInsertState = _useSharedPluginState.quickInsertState,
85
+ connectivityState = _useSharedPluginState.connectivityState;
77
86
  return /*#__PURE__*/_react.default.createElement(Modal, {
78
87
  quickInsertState: quickInsertState !== null && quickInsertState !== void 0 ? quickInsertState : undefined,
79
88
  editorView: editorView,
80
89
  helpUrl: helpUrl,
90
+ isOffline: (connectivityState === null || connectivityState === void 0 ? void 0 : connectivityState.mode) === 'offline',
81
91
  insertItem: pluginInjectionAPI === null || pluginInjectionAPI === void 0 || (_pluginInjectionAPI$q = pluginInjectionAPI.quickInsert) === null || _pluginInjectionAPI$q === void 0 || (_pluginInjectionAPI$q = _pluginInjectionAPI$q.actions) === null || _pluginInjectionAPI$q === void 0 ? void 0 : _pluginInjectionAPI$q.insertItem,
82
92
  getSuggestions: pluginInjectionAPI === null || pluginInjectionAPI === void 0 || (_pluginInjectionAPI$q2 = pluginInjectionAPI.quickInsert) === null || _pluginInjectionAPI$q2 === void 0 || (_pluginInjectionAPI$q2 = _pluginInjectionAPI$q2.actions) === null || _pluginInjectionAPI$q2 === void 0 ? void 0 : _pluginInjectionAPI$q2.getSuggestions
83
93
  });
@@ -1 +1,4 @@
1
+ /* eslint-disable @atlaskit/editor/no-re-export */
2
+ // Entry file in package.json
3
+
1
4
  export { quickInsertPlugin } from './quickInsertPlugin';
@@ -4,21 +4,27 @@ import { closeElementBrowserModal } from '../../pm-plugins/commands';
4
4
  import ModalElementBrowser from './ModalElementBrowser';
5
5
  const Modal = ({
6
6
  quickInsertState,
7
+ isOffline,
7
8
  editorView,
8
9
  helpUrl,
9
10
  insertItem,
10
11
  getSuggestions
11
12
  }) => {
12
13
  const getItems = useCallback((query, category) => {
13
- var _getSuggestions;
14
- return (_getSuggestions = getSuggestions === null || getSuggestions === void 0 ? void 0 : getSuggestions({
14
+ var _getSuggestions$map, _getSuggestions;
15
+ return (_getSuggestions$map = getSuggestions === null || getSuggestions === void 0 ? void 0 : (_getSuggestions = getSuggestions({
15
16
  query,
16
17
  category
17
- })) !== null && _getSuggestions !== void 0 ? _getSuggestions : [];
18
+ })) === null || _getSuggestions === void 0 ? void 0 : _getSuggestions.map(item => {
19
+ return isOffline && item.isDisabledOffline ? {
20
+ ...item,
21
+ isDisabled: true
22
+ } : item;
23
+ })) !== null && _getSuggestions$map !== void 0 ? _getSuggestions$map : [];
18
24
  },
19
25
  // See: https://stash.atlassian.com/projects/ATLASSIAN/repos/atlassian-frontend-monorepo/pull-requests/157796/overview?commentId=8559952
20
26
  // eslint-disable-next-line react-hooks/exhaustive-deps
21
- [getSuggestions, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems]);
27
+ [getSuggestions, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems, isOffline]);
22
28
  const focusInEditor = useCallback(() => {
23
29
  if (!editorView.hasFocus()) {
24
30
  editorView.focus();
@@ -65,12 +71,14 @@ export default (({
65
71
  }) => {
66
72
  var _pluginInjectionAPI$q, _pluginInjectionAPI$q2, _pluginInjectionAPI$q3, _pluginInjectionAPI$q4;
67
73
  const {
68
- quickInsertState
69
- } = useSharedPluginState(pluginInjectionAPI, ['quickInsert']);
74
+ quickInsertState,
75
+ connectivityState
76
+ } = useSharedPluginState(pluginInjectionAPI, ['quickInsert', 'connectivity']);
70
77
  return /*#__PURE__*/React.createElement(Modal, {
71
78
  quickInsertState: quickInsertState !== null && quickInsertState !== void 0 ? quickInsertState : undefined,
72
79
  editorView: editorView,
73
80
  helpUrl: helpUrl,
81
+ isOffline: (connectivityState === null || connectivityState === void 0 ? void 0 : connectivityState.mode) === 'offline',
74
82
  insertItem: pluginInjectionAPI === null || pluginInjectionAPI === void 0 ? void 0 : (_pluginInjectionAPI$q = pluginInjectionAPI.quickInsert) === null || _pluginInjectionAPI$q === void 0 ? void 0 : (_pluginInjectionAPI$q2 = _pluginInjectionAPI$q.actions) === null || _pluginInjectionAPI$q2 === void 0 ? void 0 : _pluginInjectionAPI$q2.insertItem,
75
83
  getSuggestions: pluginInjectionAPI === null || pluginInjectionAPI === void 0 ? void 0 : (_pluginInjectionAPI$q3 = pluginInjectionAPI.quickInsert) === null || _pluginInjectionAPI$q3 === void 0 ? void 0 : (_pluginInjectionAPI$q4 = _pluginInjectionAPI$q3.actions) === null || _pluginInjectionAPI$q4 === void 0 ? void 0 : _pluginInjectionAPI$q4.getSuggestions
76
84
  });
package/dist/esm/index.js CHANGED
@@ -1 +1,4 @@
1
+ /* eslint-disable @atlaskit/editor/no-re-export */
2
+ // Entry file in package.json
3
+
1
4
  export { quickInsertPlugin } from './quickInsertPlugin';
@@ -1,23 +1,31 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ 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; }
3
+ 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) { _defineProperty(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; }
1
4
  import React, { useCallback } from 'react';
2
5
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
3
6
  import { closeElementBrowserModal } from '../../pm-plugins/commands';
4
7
  import ModalElementBrowser from './ModalElementBrowser';
5
8
  var Modal = function Modal(_ref) {
6
9
  var quickInsertState = _ref.quickInsertState,
10
+ isOffline = _ref.isOffline,
7
11
  editorView = _ref.editorView,
8
12
  helpUrl = _ref.helpUrl,
9
13
  insertItem = _ref.insertItem,
10
14
  getSuggestions = _ref.getSuggestions;
11
15
  var getItems = useCallback(function (query, category) {
12
- var _getSuggestions;
13
- return (_getSuggestions = getSuggestions === null || getSuggestions === void 0 ? void 0 : getSuggestions({
16
+ var _getSuggestions$map, _getSuggestions;
17
+ return (_getSuggestions$map = getSuggestions === null || getSuggestions === void 0 || (_getSuggestions = getSuggestions({
14
18
  query: query,
15
19
  category: category
16
- })) !== null && _getSuggestions !== void 0 ? _getSuggestions : [];
20
+ })) === null || _getSuggestions === void 0 ? void 0 : _getSuggestions.map(function (item) {
21
+ return isOffline && item.isDisabledOffline ? _objectSpread(_objectSpread({}, item), {}, {
22
+ isDisabled: true
23
+ }) : item;
24
+ })) !== null && _getSuggestions$map !== void 0 ? _getSuggestions$map : [];
17
25
  },
18
26
  // See: https://stash.atlassian.com/projects/ATLASSIAN/repos/atlassian-frontend-monorepo/pull-requests/157796/overview?commentId=8559952
19
27
  // eslint-disable-next-line react-hooks/exhaustive-deps
20
- [getSuggestions, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems]);
28
+ [getSuggestions, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems, isOffline]);
21
29
  var focusInEditor = useCallback(function () {
22
30
  if (!editorView.hasFocus()) {
23
31
  editorView.focus();
@@ -62,12 +70,14 @@ export default (function (_ref2) {
62
70
  var editorView = _ref2.editorView,
63
71
  helpUrl = _ref2.helpUrl,
64
72
  pluginInjectionAPI = _ref2.pluginInjectionAPI;
65
- var _useSharedPluginState = useSharedPluginState(pluginInjectionAPI, ['quickInsert']),
66
- quickInsertState = _useSharedPluginState.quickInsertState;
73
+ var _useSharedPluginState = useSharedPluginState(pluginInjectionAPI, ['quickInsert', 'connectivity']),
74
+ quickInsertState = _useSharedPluginState.quickInsertState,
75
+ connectivityState = _useSharedPluginState.connectivityState;
67
76
  return /*#__PURE__*/React.createElement(Modal, {
68
77
  quickInsertState: quickInsertState !== null && quickInsertState !== void 0 ? quickInsertState : undefined,
69
78
  editorView: editorView,
70
79
  helpUrl: helpUrl,
80
+ isOffline: (connectivityState === null || connectivityState === void 0 ? void 0 : connectivityState.mode) === 'offline',
71
81
  insertItem: pluginInjectionAPI === null || pluginInjectionAPI === void 0 || (_pluginInjectionAPI$q = pluginInjectionAPI.quickInsert) === null || _pluginInjectionAPI$q === void 0 || (_pluginInjectionAPI$q = _pluginInjectionAPI$q.actions) === null || _pluginInjectionAPI$q === void 0 ? void 0 : _pluginInjectionAPI$q.insertItem,
72
82
  getSuggestions: pluginInjectionAPI === null || pluginInjectionAPI === void 0 || (_pluginInjectionAPI$q2 = pluginInjectionAPI.quickInsert) === null || _pluginInjectionAPI$q2 === void 0 || (_pluginInjectionAPI$q2 = _pluginInjectionAPI$q2.actions) === null || _pluginInjectionAPI$q2 === void 0 ? void 0 : _pluginInjectionAPI$q2.getSuggestions
73
83
  });
@@ -1,4 +1,2 @@
1
- import type { QuickInsertPluginOptions } from '@atlaskit/editor-common/types';
2
1
  import { type QuickInsertPlugin } from './quickInsertPluginType';
3
- export type { QuickInsertPluginOptions };
4
2
  export declare const quickInsertPlugin: QuickInsertPlugin;
@@ -1,13 +1,14 @@
1
1
  import type { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
2
  import type { QuickInsertItem } from '@atlaskit/editor-common/provider-factory';
3
- import type { Command, QuickInsertSharedState as CommonQuickInsertSharedState, EditorCommand, NextEditorPlugin, QuickInsertHandler, QuickInsertPluginOptions, QuickInsertSearchOptions, TypeAheadHandler } from '@atlaskit/editor-common/types';
3
+ import type { Command, QuickInsertSharedState as CommonQuickInsertSharedState, EditorCommand, NextEditorPlugin, OptionalPlugin, QuickInsertHandler, QuickInsertPluginOptions, QuickInsertSearchOptions, TypeAheadHandler } from '@atlaskit/editor-common/types';
4
+ import { type ConnectivityPlugin } from '@atlaskit/editor-plugin-connectivity';
4
5
  import type { TypeAheadInputMethod, TypeAheadPlugin } from '@atlaskit/editor-plugin-type-ahead';
5
6
  export type QuickInsertSharedState = CommonQuickInsertSharedState & {
6
7
  typeAheadHandler: TypeAheadHandler;
7
8
  };
8
9
  export type QuickInsertPlugin = NextEditorPlugin<'quickInsert', {
9
10
  pluginConfiguration: QuickInsertPluginOptions | undefined;
10
- dependencies: [TypeAheadPlugin];
11
+ dependencies: [TypeAheadPlugin, OptionalPlugin<ConnectivityPlugin>];
11
12
  sharedState: QuickInsertSharedState | null;
12
13
  actions: {
13
14
  openTypeAhead: (inputMethod: TypeAheadInputMethod) => boolean;
@@ -1,4 +1,2 @@
1
- import type { QuickInsertPluginOptions } from '@atlaskit/editor-common/types';
2
1
  import { type QuickInsertPlugin } from './quickInsertPluginType';
3
- export type { QuickInsertPluginOptions };
4
2
  export declare const quickInsertPlugin: QuickInsertPlugin;
@@ -1,6 +1,7 @@
1
1
  import type { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
2
  import type { QuickInsertItem } from '@atlaskit/editor-common/provider-factory';
3
- import type { Command, QuickInsertSharedState as CommonQuickInsertSharedState, EditorCommand, NextEditorPlugin, QuickInsertHandler, QuickInsertPluginOptions, QuickInsertSearchOptions, TypeAheadHandler } from '@atlaskit/editor-common/types';
3
+ import type { Command, QuickInsertSharedState as CommonQuickInsertSharedState, EditorCommand, NextEditorPlugin, OptionalPlugin, QuickInsertHandler, QuickInsertPluginOptions, QuickInsertSearchOptions, TypeAheadHandler } from '@atlaskit/editor-common/types';
4
+ import { type ConnectivityPlugin } from '@atlaskit/editor-plugin-connectivity';
4
5
  import type { TypeAheadInputMethod, TypeAheadPlugin } from '@atlaskit/editor-plugin-type-ahead';
5
6
  export type QuickInsertSharedState = CommonQuickInsertSharedState & {
6
7
  typeAheadHandler: TypeAheadHandler;
@@ -8,7 +9,8 @@ export type QuickInsertSharedState = CommonQuickInsertSharedState & {
8
9
  export type QuickInsertPlugin = NextEditorPlugin<'quickInsert', {
9
10
  pluginConfiguration: QuickInsertPluginOptions | undefined;
10
11
  dependencies: [
11
- TypeAheadPlugin
12
+ TypeAheadPlugin,
13
+ OptionalPlugin<ConnectivityPlugin>
12
14
  ];
13
15
  sharedState: QuickInsertSharedState | null;
14
16
  actions: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-quick-insert",
3
- "version": "1.7.3",
3
+ "version": "1.8.1",
4
4
  "description": "Quick insert plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -32,13 +32,14 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@atlaskit/button": "^20.3.0",
35
- "@atlaskit/editor-common": "^96.0.0",
35
+ "@atlaskit/editor-common": "^97.0.0",
36
+ "@atlaskit/editor-plugin-connectivity": "^1.1.0",
36
37
  "@atlaskit/editor-plugin-type-ahead": "^1.11.0",
37
38
  "@atlaskit/editor-prosemirror": "6.2.1",
38
- "@atlaskit/icon": "^23.0.0",
39
+ "@atlaskit/icon": "^23.1.0",
39
40
  "@atlaskit/modal-dialog": "^12.18.0",
40
41
  "@atlaskit/theme": "^14.0.0",
41
- "@atlaskit/tokens": "^2.4.0",
42
+ "@atlaskit/tokens": "^2.5.0",
42
43
  "@babel/runtime": "^7.0.0",
43
44
  "@emotion/react": "^11.7.1"
44
45
  },