@atlaskit/editor-plugin-quick-insert 27.0.1 → 27.0.3

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,22 @@
1
1
  # @atlaskit/editor-plugin-quick-insert
2
2
 
3
+ ## 27.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 27.0.2
10
+
11
+ ### Patch Changes
12
+
13
+ - [`96522a3034d5f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/96522a3034d5f) -
14
+ Fix the slash command Element Browser opening on All instead of the requested section the first
15
+ time a section's View more is used in a fresh editor (platform_editor_slash_command). The registry
16
+ snapshot is now taken during the open render, so the requested section is resolved against that
17
+ open's components.
18
+ - Updated dependencies
19
+
3
20
  ## 27.0.1
4
21
 
5
22
  ### Patch Changes
@@ -33,18 +33,16 @@ var RegistryElementBrowserContainer = exports.RegistryElementBrowserContainer =
33
33
  currentEmptyStateHandler = _useSharedPluginState.emptyStateHandler,
34
34
  isElementBrowserOpen = _useSharedPluginState.isElementBrowserOpen,
35
35
  mode = _useSharedPluginState.mode;
36
- var _useState = (0, _react.useState)([]),
36
+ // Snapshot once per open, during render, so the browser's open-time section reset sees the
37
+ // registry for this open rather than the previous (or empty) snapshot.
38
+ var components = (0, _react.useMemo)(function () {
39
+ var _pluginInjectionAPI$u, _pluginInjectionAPI$u2;
40
+ return isElementBrowserOpen ? (_pluginInjectionAPI$u = pluginInjectionAPI === null || pluginInjectionAPI === void 0 || (_pluginInjectionAPI$u2 = pluginInjectionAPI.uiControlRegistry) === null || _pluginInjectionAPI$u2 === void 0 ? void 0 : _pluginInjectionAPI$u2.actions.getComponents(_keys.MENU.key)) !== null && _pluginInjectionAPI$u !== void 0 ? _pluginInjectionAPI$u : [] : [];
41
+ }, [isElementBrowserOpen, pluginInjectionAPI]);
42
+ var _useState = (0, _react.useState)(),
37
43
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
38
- snapshot = _useState2[0],
39
- setSnapshot = _useState2[1];
40
- var _useState3 = (0, _react.useState)(false),
41
- _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
42
- hasInitialized = _useState4[0],
43
- setHasInitialized = _useState4[1];
44
- var _useState5 = (0, _react.useState)(),
45
- _useState6 = (0, _slicedToArray2.default)(_useState5, 2),
46
- emptyStateHandler = _useState6[0],
47
- setEmptyStateHandler = _useState6[1];
44
+ emptyStateHandler = _useState2[0],
45
+ setEmptyStateHandler = _useState2[1];
48
46
  var wasOpen = (0, _react.useRef)(false);
49
47
  var selectionHandler = (0, _react.useRef)(undefined);
50
48
  var isInsertConfirmed = (0, _react.useRef)(false);
@@ -62,9 +60,6 @@ var RegistryElementBrowserContainer = exports.RegistryElementBrowserContainer =
62
60
  }, [pluginInjectionAPI]);
63
61
  (0, _react.useEffect)(function () {
64
62
  if (isElementBrowserOpen && !wasOpen.current) {
65
- var _pluginInjectionAPI$u, _pluginInjectionAPI$u2;
66
- setSnapshot((_pluginInjectionAPI$u = pluginInjectionAPI === null || pluginInjectionAPI === void 0 || (_pluginInjectionAPI$u2 = pluginInjectionAPI.uiControlRegistry) === null || _pluginInjectionAPI$u2 === void 0 ? void 0 : _pluginInjectionAPI$u2.actions.getComponents(_keys.MENU.key)) !== null && _pluginInjectionAPI$u !== void 0 ? _pluginInjectionAPI$u : []);
67
- setHasInitialized(true);
68
63
  selectionHandler.current = undefined;
69
64
  setEmptyStateHandler(function () {
70
65
  return currentEmptyStateHandler;
@@ -77,7 +72,7 @@ var RegistryElementBrowserContainer = exports.RegistryElementBrowserContainer =
77
72
  fireLifecycleEvent(_enums.ACTION.CLOSED);
78
73
  }
79
74
  wasOpen.current = isElementBrowserOpen;
80
- }, [currentEmptyStateHandler, fireLifecycleEvent, isElementBrowserOpen, pluginInjectionAPI]);
75
+ }, [currentEmptyStateHandler, fireLifecycleEvent, isElementBrowserOpen]);
81
76
  (0, _react.useEffect)(function () {
82
77
  return function () {
83
78
  if (lifecycleOpen.current) {
@@ -133,13 +128,12 @@ var RegistryElementBrowserContainer = exports.RegistryElementBrowserContainer =
133
128
  onClose();
134
129
  }, [onClose]);
135
130
  return /*#__PURE__*/_react.default.createElement(_RegistryElementBrowser.RegistryElementBrowser, {
136
- components: snapshot,
131
+ components: components,
137
132
  emptyStateHandler: emptyStateHandler,
138
133
  helpUrl: helpUrl,
139
134
  defaultSection: (_pluginKey$getState = _pluginKey.pluginKey.getState(editorView.state)) === null || _pluginKey$getState === void 0 ? void 0 : _pluginKey$getState.elementBrowserInitialCategory,
140
135
  editorView: editorView,
141
136
  isOffline: (0, _isOfflineMode.isOfflineMode)(mode),
142
- isLoading: !hasInitialized,
143
137
  isOpen: isElementBrowserOpen,
144
138
  onClearSelection: onClearSelection,
145
139
  onClose: onClose,
@@ -1,4 +1,4 @@
1
- import React, { useCallback, useEffect, useRef, useState } from 'react';
1
+ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
2
2
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics/types/enums';
3
3
  import { isOfflineMode } from '@atlaskit/editor-common/connectivity/isOfflineMode';
4
4
  import { insertSelectedItem } from '@atlaskit/editor-common/insert';
@@ -25,8 +25,12 @@ export const RegistryElementBrowserContainer = ({
25
25
  mode: (_state$connectivitySt = state.connectivityState) === null || _state$connectivitySt === void 0 ? void 0 : _state$connectivitySt.mode
26
26
  };
27
27
  });
28
- const [snapshot, setSnapshot] = useState([]);
29
- const [hasInitialized, setHasInitialized] = useState(false);
28
+ // Snapshot once per open, during render, so the browser's open-time section reset sees the
29
+ // registry for this open rather than the previous (or empty) snapshot.
30
+ const components = useMemo(() => {
31
+ var _pluginInjectionAPI$u, _pluginInjectionAPI$u2;
32
+ return isElementBrowserOpen ? (_pluginInjectionAPI$u = pluginInjectionAPI === null || pluginInjectionAPI === void 0 ? void 0 : (_pluginInjectionAPI$u2 = pluginInjectionAPI.uiControlRegistry) === null || _pluginInjectionAPI$u2 === void 0 ? void 0 : _pluginInjectionAPI$u2.actions.getComponents(MENU.key)) !== null && _pluginInjectionAPI$u !== void 0 ? _pluginInjectionAPI$u : [] : [];
33
+ }, [isElementBrowserOpen, pluginInjectionAPI]);
30
34
  const [emptyStateHandler, setEmptyStateHandler] = useState();
31
35
  const wasOpen = useRef(false);
32
36
  const selectionHandler = useRef(undefined);
@@ -45,9 +49,6 @@ export const RegistryElementBrowserContainer = ({
45
49
  }, [pluginInjectionAPI]);
46
50
  useEffect(() => {
47
51
  if (isElementBrowserOpen && !wasOpen.current) {
48
- var _pluginInjectionAPI$u, _pluginInjectionAPI$u2;
49
- setSnapshot((_pluginInjectionAPI$u = pluginInjectionAPI === null || pluginInjectionAPI === void 0 ? void 0 : (_pluginInjectionAPI$u2 = pluginInjectionAPI.uiControlRegistry) === null || _pluginInjectionAPI$u2 === void 0 ? void 0 : _pluginInjectionAPI$u2.actions.getComponents(MENU.key)) !== null && _pluginInjectionAPI$u !== void 0 ? _pluginInjectionAPI$u : []);
50
- setHasInitialized(true);
51
52
  selectionHandler.current = undefined;
52
53
  setEmptyStateHandler(() => currentEmptyStateHandler);
53
54
  isInsertConfirmed.current = false;
@@ -58,7 +59,7 @@ export const RegistryElementBrowserContainer = ({
58
59
  fireLifecycleEvent(ACTION.CLOSED);
59
60
  }
60
61
  wasOpen.current = isElementBrowserOpen;
61
- }, [currentEmptyStateHandler, fireLifecycleEvent, isElementBrowserOpen, pluginInjectionAPI]);
62
+ }, [currentEmptyStateHandler, fireLifecycleEvent, isElementBrowserOpen]);
62
63
  useEffect(() => () => {
63
64
  if (lifecycleOpen.current) {
64
65
  lifecycleOpen.current = false;
@@ -109,13 +110,12 @@ export const RegistryElementBrowserContainer = ({
109
110
  onClose();
110
111
  }, [onClose]);
111
112
  return /*#__PURE__*/React.createElement(RegistryElementBrowser, {
112
- components: snapshot,
113
+ components: components,
113
114
  emptyStateHandler: emptyStateHandler,
114
115
  helpUrl: helpUrl,
115
116
  defaultSection: (_pluginKey$getState = pluginKey.getState(editorView.state)) === null || _pluginKey$getState === void 0 ? void 0 : _pluginKey$getState.elementBrowserInitialCategory,
116
117
  editorView: editorView,
117
118
  isOffline: isOfflineMode(mode),
118
- isLoading: !hasInitialized,
119
119
  isOpen: isElementBrowserOpen,
120
120
  onClearSelection: onClearSelection,
121
121
  onClose: onClose,
@@ -1,5 +1,5 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import React, { useCallback, useEffect, useRef, useState } from 'react';
2
+ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
3
3
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics/types/enums';
4
4
  import { isOfflineMode } from '@atlaskit/editor-common/connectivity/isOfflineMode';
5
5
  import { insertSelectedItem } from '@atlaskit/editor-common/insert';
@@ -24,18 +24,16 @@ export var RegistryElementBrowserContainer = function RegistryElementBrowserCont
24
24
  currentEmptyStateHandler = _useSharedPluginState.emptyStateHandler,
25
25
  isElementBrowserOpen = _useSharedPluginState.isElementBrowserOpen,
26
26
  mode = _useSharedPluginState.mode;
27
- var _useState = useState([]),
27
+ // Snapshot once per open, during render, so the browser's open-time section reset sees the
28
+ // registry for this open rather than the previous (or empty) snapshot.
29
+ var components = useMemo(function () {
30
+ var _pluginInjectionAPI$u, _pluginInjectionAPI$u2;
31
+ return isElementBrowserOpen ? (_pluginInjectionAPI$u = pluginInjectionAPI === null || pluginInjectionAPI === void 0 || (_pluginInjectionAPI$u2 = pluginInjectionAPI.uiControlRegistry) === null || _pluginInjectionAPI$u2 === void 0 ? void 0 : _pluginInjectionAPI$u2.actions.getComponents(MENU.key)) !== null && _pluginInjectionAPI$u !== void 0 ? _pluginInjectionAPI$u : [] : [];
32
+ }, [isElementBrowserOpen, pluginInjectionAPI]);
33
+ var _useState = useState(),
28
34
  _useState2 = _slicedToArray(_useState, 2),
29
- snapshot = _useState2[0],
30
- setSnapshot = _useState2[1];
31
- var _useState3 = useState(false),
32
- _useState4 = _slicedToArray(_useState3, 2),
33
- hasInitialized = _useState4[0],
34
- setHasInitialized = _useState4[1];
35
- var _useState5 = useState(),
36
- _useState6 = _slicedToArray(_useState5, 2),
37
- emptyStateHandler = _useState6[0],
38
- setEmptyStateHandler = _useState6[1];
35
+ emptyStateHandler = _useState2[0],
36
+ setEmptyStateHandler = _useState2[1];
39
37
  var wasOpen = useRef(false);
40
38
  var selectionHandler = useRef(undefined);
41
39
  var isInsertConfirmed = useRef(false);
@@ -53,9 +51,6 @@ export var RegistryElementBrowserContainer = function RegistryElementBrowserCont
53
51
  }, [pluginInjectionAPI]);
54
52
  useEffect(function () {
55
53
  if (isElementBrowserOpen && !wasOpen.current) {
56
- var _pluginInjectionAPI$u, _pluginInjectionAPI$u2;
57
- setSnapshot((_pluginInjectionAPI$u = pluginInjectionAPI === null || pluginInjectionAPI === void 0 || (_pluginInjectionAPI$u2 = pluginInjectionAPI.uiControlRegistry) === null || _pluginInjectionAPI$u2 === void 0 ? void 0 : _pluginInjectionAPI$u2.actions.getComponents(MENU.key)) !== null && _pluginInjectionAPI$u !== void 0 ? _pluginInjectionAPI$u : []);
58
- setHasInitialized(true);
59
54
  selectionHandler.current = undefined;
60
55
  setEmptyStateHandler(function () {
61
56
  return currentEmptyStateHandler;
@@ -68,7 +63,7 @@ export var RegistryElementBrowserContainer = function RegistryElementBrowserCont
68
63
  fireLifecycleEvent(ACTION.CLOSED);
69
64
  }
70
65
  wasOpen.current = isElementBrowserOpen;
71
- }, [currentEmptyStateHandler, fireLifecycleEvent, isElementBrowserOpen, pluginInjectionAPI]);
66
+ }, [currentEmptyStateHandler, fireLifecycleEvent, isElementBrowserOpen]);
72
67
  useEffect(function () {
73
68
  return function () {
74
69
  if (lifecycleOpen.current) {
@@ -124,13 +119,12 @@ export var RegistryElementBrowserContainer = function RegistryElementBrowserCont
124
119
  onClose();
125
120
  }, [onClose]);
126
121
  return /*#__PURE__*/React.createElement(RegistryElementBrowser, {
127
- components: snapshot,
122
+ components: components,
128
123
  emptyStateHandler: emptyStateHandler,
129
124
  helpUrl: helpUrl,
130
125
  defaultSection: (_pluginKey$getState = pluginKey.getState(editorView.state)) === null || _pluginKey$getState === void 0 ? void 0 : _pluginKey$getState.elementBrowserInitialCategory,
131
126
  editorView: editorView,
132
127
  isOffline: isOfflineMode(mode),
133
- isLoading: !hasInitialized,
134
128
  isOpen: isElementBrowserOpen,
135
129
  onClearSelection: onClearSelection,
136
130
  onClose: onClose,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-quick-insert",
3
- "version": "27.0.1",
3
+ "version": "27.0.3",
4
4
  "description": "Quick insert plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -44,7 +44,7 @@
44
44
  "@atlaskit/platform-feature-flags": "^2.2.0",
45
45
  "@atlaskit/primitives": "^22.5.0",
46
46
  "@atlaskit/textfield": "^10.2.0",
47
- "@atlaskit/tmp-editor-statsig": "^236.0.0",
47
+ "@atlaskit/tmp-editor-statsig": "^238.0.0",
48
48
  "@atlaskit/tokens": "^20.5.0",
49
49
  "@atlaskit/tooltip": "^24.4.0",
50
50
  "@babel/runtime": "^7.0.0",
@@ -52,7 +52,7 @@
52
52
  "@emotion/react": "^11.7.1"
53
53
  },
54
54
  "peerDependencies": {
55
- "@atlaskit/editor-common": "^131.0.0",
55
+ "@atlaskit/editor-common": "^131.1.0",
56
56
  "react": "^18.2.0 || ^19.2.0",
57
57
  "react-dom": "^18.2.0 || ^19.2.0",
58
58
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"