@atlaskit/editor-plugin-type-ahead 15.0.4 → 15.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @atlaskit/editor-plugin-type-ahead
2
2
 
3
+ ## 15.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`c0cf420333ef1`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c0cf420333ef1) -
8
+ Add public registration APIs for provider-backed Quick Insert components.
9
+
10
+ Providers can expose registered items directly:
11
+
12
+ ```tsx
13
+ const getComponents = async () => [
14
+ {
15
+ key: 'insert-table',
16
+ component: TableItem,
17
+ parents: [{ type: 'menu-section', key: 'quick-insert', rank: 1 }],
18
+ },
19
+ ];
20
+ ```
21
+
22
+ ### Patch Changes
23
+
24
+ - Updated dependencies
25
+
3
26
  ## 15.0.4
4
27
 
5
28
  ### Patch Changes
@@ -20,6 +20,7 @@ var TypeAheadQuickInsertItem = exports.TypeAheadQuickInsertItem = function TypeA
20
20
  var contextValue = (0, _react.useMemo)(function () {
21
21
  return {
22
22
  editorView: quickInsertContext.editorView,
23
+ isOffline: quickInsertContext.isOffline,
23
24
  item: {
24
25
  id: id,
25
26
  isSelected: isSelected
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.TypeAheadQuickInsertProvider = void 0;
8
8
  var _react = _interopRequireWildcard(require("react"));
9
+ var _isOfflineMode = require("@atlaskit/editor-common/connectivity/isOfflineMode");
10
+ var _hooks = require("@atlaskit/editor-common/hooks");
9
11
  var _provider = require("@atlaskit/editor-common/quick-insert/provider");
10
12
  var _insertTypeAheadItem = require("../../../pm-plugins/commands/insert-type-ahead-item");
11
13
  var _useTypeAheadContext2 = require("../useTypeAheadContext");
@@ -13,11 +15,19 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
13
15
  var TypeAheadQuickInsertProvider = exports.TypeAheadQuickInsertProvider = function TypeAheadQuickInsertProvider(_ref) {
14
16
  var children = _ref.children;
15
17
  var _useTypeAheadContext = (0, _useTypeAheadContext2.useTypeAheadContext)(),
18
+ api = _useTypeAheadContext.api,
16
19
  editorView = _useTypeAheadContext.editorView,
17
20
  inputMethod = _useTypeAheadContext.inputMethod,
18
21
  onClose = _useTypeAheadContext.onClose,
19
22
  query = _useTypeAheadContext.query,
20
23
  triggerHandler = _useTypeAheadContext.triggerHandler;
24
+ var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['connectivity'], function (_ref2) {
25
+ var connectivityState = _ref2.connectivityState;
26
+ return {
27
+ isOffline: (0, _isOfflineMode.isOfflineMode)(connectivityState === null || connectivityState === void 0 ? void 0 : connectivityState.mode)
28
+ };
29
+ }),
30
+ isOffline = _useSharedPluginState.isOffline;
21
31
  var select = (0, _react.useCallback)(function (selectionHandler) {
22
32
  onClose();
23
33
  queueMicrotask(function () {
@@ -32,9 +42,10 @@ var TypeAheadQuickInsertProvider = exports.TypeAheadQuickInsertProvider = functi
32
42
  var contextValue = (0, _react.useMemo)(function () {
33
43
  return {
34
44
  editorView: editorView,
45
+ isOffline: isOffline,
35
46
  select: select
36
47
  };
37
- }, [editorView, select]);
48
+ }, [editorView, isOffline, select]);
38
49
  return /*#__PURE__*/_react.default.createElement(_provider.QuickInsertProvider, {
39
50
  value: contextValue
40
51
  }, children);
@@ -12,6 +12,7 @@ export const TypeAheadQuickInsertItem = ({
12
12
  const Component = (_registration$compone = registration.component) !== null && _registration$compone !== void 0 ? _registration$compone : PassThrough;
13
13
  const contextValue = useMemo(() => ({
14
14
  editorView: quickInsertContext.editorView,
15
+ isOffline: quickInsertContext.isOffline,
15
16
  item: {
16
17
  id,
17
18
  isSelected
@@ -1,4 +1,6 @@
1
1
  import React, { useCallback, useMemo } from 'react';
2
+ import { isOfflineMode } from '@atlaskit/editor-common/connectivity/isOfflineMode';
3
+ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
2
4
  import { QuickInsertProvider } from '@atlaskit/editor-common/quick-insert/provider';
3
5
  import { performTypeAheadSelection } from '../../../pm-plugins/commands/insert-type-ahead-item';
4
6
  import { useTypeAheadContext } from '../useTypeAheadContext';
@@ -6,12 +8,20 @@ export const TypeAheadQuickInsertProvider = ({
6
8
  children
7
9
  }) => {
8
10
  const {
11
+ api,
9
12
  editorView,
10
13
  inputMethod,
11
14
  onClose,
12
15
  query,
13
16
  triggerHandler
14
17
  } = useTypeAheadContext();
18
+ const {
19
+ isOffline
20
+ } = useSharedPluginStateWithSelector(api, ['connectivity'], ({
21
+ connectivityState
22
+ }) => ({
23
+ isOffline: isOfflineMode(connectivityState === null || connectivityState === void 0 ? void 0 : connectivityState.mode)
24
+ }));
15
25
  const select = useCallback(selectionHandler => {
16
26
  onClose();
17
27
  queueMicrotask(() => {
@@ -25,8 +35,9 @@ export const TypeAheadQuickInsertProvider = ({
25
35
  }, [editorView, inputMethod, onClose, query, triggerHandler]);
26
36
  const contextValue = useMemo(() => ({
27
37
  editorView,
38
+ isOffline,
28
39
  select
29
- }), [editorView, select]);
40
+ }), [editorView, isOffline, select]);
30
41
  return /*#__PURE__*/React.createElement(QuickInsertProvider, {
31
42
  value: contextValue
32
43
  }, children);
@@ -12,6 +12,7 @@ export var TypeAheadQuickInsertItem = function TypeAheadQuickInsertItem(_ref) {
12
12
  var contextValue = useMemo(function () {
13
13
  return {
14
14
  editorView: quickInsertContext.editorView,
15
+ isOffline: quickInsertContext.isOffline,
15
16
  item: {
16
17
  id: id,
17
18
  isSelected: isSelected
@@ -1,15 +1,25 @@
1
1
  import React, { useCallback, useMemo } from 'react';
2
+ import { isOfflineMode } from '@atlaskit/editor-common/connectivity/isOfflineMode';
3
+ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
2
4
  import { QuickInsertProvider } from '@atlaskit/editor-common/quick-insert/provider';
3
5
  import { performTypeAheadSelection } from '../../../pm-plugins/commands/insert-type-ahead-item';
4
6
  import { useTypeAheadContext } from '../useTypeAheadContext';
5
7
  export var TypeAheadQuickInsertProvider = function TypeAheadQuickInsertProvider(_ref) {
6
8
  var children = _ref.children;
7
9
  var _useTypeAheadContext = useTypeAheadContext(),
10
+ api = _useTypeAheadContext.api,
8
11
  editorView = _useTypeAheadContext.editorView,
9
12
  inputMethod = _useTypeAheadContext.inputMethod,
10
13
  onClose = _useTypeAheadContext.onClose,
11
14
  query = _useTypeAheadContext.query,
12
15
  triggerHandler = _useTypeAheadContext.triggerHandler;
16
+ var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['connectivity'], function (_ref2) {
17
+ var connectivityState = _ref2.connectivityState;
18
+ return {
19
+ isOffline: isOfflineMode(connectivityState === null || connectivityState === void 0 ? void 0 : connectivityState.mode)
20
+ };
21
+ }),
22
+ isOffline = _useSharedPluginState.isOffline;
13
23
  var select = useCallback(function (selectionHandler) {
14
24
  onClose();
15
25
  queueMicrotask(function () {
@@ -24,9 +34,10 @@ export var TypeAheadQuickInsertProvider = function TypeAheadQuickInsertProvider(
24
34
  var contextValue = useMemo(function () {
25
35
  return {
26
36
  editorView: editorView,
37
+ isOffline: isOffline,
27
38
  select: select
28
39
  };
29
- }, [editorView, select]);
40
+ }, [editorView, isOffline, select]);
30
41
  return /*#__PURE__*/React.createElement(QuickInsertProvider, {
31
42
  value: contextValue
32
43
  }, children);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-type-ahead",
3
- "version": "15.0.4",
3
+ "version": "15.1.0",
4
4
  "description": "Type-ahead plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -27,10 +27,10 @@
27
27
  "@atlaskit/editor-plugin-connectivity": "^14.0.0",
28
28
  "@atlaskit/editor-plugin-context-panel": "^16.0.0",
29
29
  "@atlaskit/editor-plugin-metrics": "^15.0.0",
30
- "@atlaskit/editor-plugin-ui-control-registry": "^8.0.0",
30
+ "@atlaskit/editor-plugin-ui-control-registry": "^8.1.0",
31
31
  "@atlaskit/editor-prosemirror": "^8.0.0",
32
32
  "@atlaskit/editor-shared-styles": "^4.0.0",
33
- "@atlaskit/editor-ui-control-model": "^2.4.0",
33
+ "@atlaskit/editor-ui-control-model": "^2.5.0",
34
34
  "@atlaskit/feature-gate-js-client": "^6.0.0",
35
35
  "@atlaskit/heading": "^7.0.0",
36
36
  "@atlaskit/icon": "^37.3.0",
@@ -53,7 +53,7 @@
53
53
  "w3c-keyname": "^2.1.8"
54
54
  },
55
55
  "peerDependencies": {
56
- "@atlaskit/editor-common": "^118.4.0",
56
+ "@atlaskit/editor-common": "^118.8.0",
57
57
  "react": "^18.2.0 || ^19.2.0",
58
58
  "react-dom": "^18.2.0 || ^19.2.0",
59
59
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"