@atlaskit/editor-plugin-insert-block 23.0.8 → 23.0.10

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,27 @@
1
1
  # @atlaskit/editor-plugin-insert-block
2
2
 
3
+ ## 23.0.10
4
+
5
+ ### Patch Changes
6
+
7
+ - [`051cd10867eae`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/051cd10867eae) -
8
+ Expose uploadStatus and mentionProviderStatus to distinguish pending providers from unavailable
9
+ capabilities. Under platform_editor_ssr_toolbar_optimistic, keep mention and media toolbar buttons
10
+ enabled while providers are pending, avoiding class changes on successful initialization while
11
+ preserving existing insertion restrictions.
12
+
13
+ When a view-only synchronous SSR media provider accompanies a pending full provider, keep uploads
14
+ pending until the full provider resolves instead of treating the SSR config as a permission
15
+ denial.
16
+
17
+ - Updated dependencies
18
+
19
+ ## 23.0.9
20
+
21
+ ### Patch Changes
22
+
23
+ - Updated dependencies
24
+
3
25
  ## 23.0.8
4
26
 
5
27
  ### Patch Changes
@@ -13,6 +13,7 @@ var _messages = require("@atlaskit/editor-common/messages");
13
13
  var _toolbar = require("@atlaskit/editor-common/toolbar");
14
14
  var _editorPluginConnectivity = require("@atlaskit/editor-plugin-connectivity");
15
15
  var _editorToolbar = require("@atlaskit/editor-toolbar");
16
+ var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
16
17
  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); }
17
18
  var MediaButton = exports.MediaButton = function MediaButton(_ref) {
18
19
  var api = _ref.api;
@@ -25,12 +26,14 @@ var MediaButton = exports.MediaButton = function MediaButton(_ref) {
25
26
  return {
26
27
  showMediaPicker: (_states$mediaState = states.mediaState) === null || _states$mediaState === void 0 ? void 0 : _states$mediaState.showMediaPicker,
27
28
  allowsUploads: (_states$mediaState2 = states.mediaState) === null || _states$mediaState2 === void 0 ? void 0 : _states$mediaState2.allowsUploads,
29
+ isUploadPending: !states.mediaState || states.mediaState.uploadStatus === 'pending',
28
30
  connectivityMode: (_states$connectivityS = states.connectivityState) === null || _states$connectivityS === void 0 ? void 0 : _states$connectivityS.mode
29
31
  };
30
32
  }),
31
33
  showMediaPicker = _useSharedPluginState.showMediaPicker,
32
34
  connectivityMode = _useSharedPluginState.connectivityMode,
33
- allowsUploads = _useSharedPluginState.allowsUploads;
35
+ allowsUploads = _useSharedPluginState.allowsUploads,
36
+ isUploadPending = _useSharedPluginState.isUploadPending;
34
37
  var mediaButtonRef = (0, _react.useRef)(null);
35
38
  if (!(api !== null && api !== void 0 && api.media)) {
36
39
  return null;
@@ -62,6 +65,7 @@ var MediaButton = exports.MediaButton = function MediaButton(_ref) {
62
65
  });
63
66
  };
64
67
  var isOffline = (0, _editorPluginConnectivity.isOfflineMode)(connectivityMode);
68
+ var isDisabled = isOffline || !(allowsUploads || (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_ssr_toolbar_optimistic') && isUploadPending);
65
69
  return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarTooltip, {
66
70
  content: formatMessage(_messages.toolbarInsertBlockMessages.addMediaFiles)
67
71
  }, /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarButton, {
@@ -71,7 +75,7 @@ var MediaButton = exports.MediaButton = function MediaButton(_ref) {
71
75
  }),
72
76
  onClick: onClick,
73
77
  ref: mediaButtonRef,
74
- isDisabled: isOffline || !allowsUploads,
78
+ isDisabled: isDisabled,
75
79
  testId: _toolbar.TOOLBAR_BUTTON_TEST_ID.MEDIA
76
80
  }));
77
81
  };
@@ -13,20 +13,25 @@ var _keymaps = require("@atlaskit/editor-common/keymaps");
13
13
  var _messages = require("@atlaskit/editor-common/messages");
14
14
  var _toolbar = require("@atlaskit/editor-common/toolbar");
15
15
  var _editorToolbar = require("@atlaskit/editor-toolbar");
16
+ var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
16
17
  var MentionButton = exports.MentionButton = function MentionButton(_ref) {
17
18
  var api = _ref.api;
18
19
  var _useIntl = (0, _reactIntl.useIntl)(),
19
20
  formatMessage = _useIntl.formatMessage;
20
21
  var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['mention', 'typeAhead'], function (states) {
21
- var _states$mentionState, _states$mentionState2, _states$typeAheadStat;
22
+ var _states$mentionState, _states$mentionState2, _states$mentionState3, _states$typeAheadStat;
22
23
  return {
23
24
  canInsertMention: (_states$mentionState = states.mentionState) === null || _states$mentionState === void 0 ? void 0 : _states$mentionState.canInsertMention,
24
25
  mentionProvider: (_states$mentionState2 = states.mentionState) === null || _states$mentionState2 === void 0 ? void 0 : _states$mentionState2.mentionProvider,
26
+ mentionProviderStatus: (_states$mentionState3 = states.mentionState) === null || _states$mentionState3 === void 0 ? void 0 : _states$mentionState3.mentionProviderStatus,
27
+ hasMentionState: states.mentionState !== undefined,
25
28
  isTypeAheadAllowed: (_states$typeAheadStat = states.typeAheadState) === null || _states$typeAheadStat === void 0 ? void 0 : _states$typeAheadStat.isAllowed
26
29
  };
27
30
  }),
28
31
  canInsertMention = _useSharedPluginState.canInsertMention,
29
32
  mentionProvider = _useSharedPluginState.mentionProvider,
33
+ mentionProviderStatus = _useSharedPluginState.mentionProviderStatus,
34
+ hasMentionState = _useSharedPluginState.hasMentionState,
30
35
  isTypeAheadAllowed = _useSharedPluginState.isTypeAheadAllowed;
31
36
  if (!(api !== null && api !== void 0 && api.mention)) {
32
37
  return null;
@@ -35,6 +40,10 @@ var MentionButton = exports.MentionButton = function MentionButton(_ref) {
35
40
  var _api$mention;
36
41
  api === null || api === void 0 || (_api$mention = api.mention) === null || _api$mention === void 0 || (_api$mention = _api$mention.actions) === null || _api$mention === void 0 || _api$mention.openTypeAhead(_analytics.INPUT_METHOD.TOOLBAR);
37
42
  };
43
+
44
+ // The SSR state cannot resolve providers. Keep pending and available visually identical,
45
+ // while preserving known selection restrictions and settled provider failures.
46
+ var isDisabled = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_ssr_toolbar_optimistic') ? canInsertMention === false || hasMentionState && isTypeAheadAllowed === false || mentionProviderStatus !== 'pending' && hasMentionState && !mentionProvider : !canInsertMention || !mentionProvider || !isTypeAheadAllowed;
38
47
  return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarTooltip, {
39
48
  content: /*#__PURE__*/_react.default.createElement(_keymaps.ToolTipContent, {
40
49
  description: formatMessage(_messages.toolbarInsertBlockMessages.mention),
@@ -47,7 +56,7 @@ var MentionButton = exports.MentionButton = function MentionButton(_ref) {
47
56
  }),
48
57
  onClick: onClick,
49
58
  ariaKeyshortcuts: "Shift+2 Space",
50
- isDisabled: !canInsertMention || !mentionProvider || !isTypeAheadAllowed,
59
+ isDisabled: isDisabled,
51
60
  testId: _toolbar.TOOLBAR_BUTTON_TEST_ID.MENTION
52
61
  }));
53
62
  };
@@ -6,6 +6,7 @@ import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/
6
6
  import { TOOLBAR_BUTTON_TEST_ID } from '@atlaskit/editor-common/toolbar';
7
7
  import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
8
8
  import { ToolbarButton, ToolbarTooltip, ImageIcon, useToolbarUI } from '@atlaskit/editor-toolbar';
9
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
9
10
  export const MediaButton = ({
10
11
  api
11
12
  }) => {
@@ -18,12 +19,14 @@ export const MediaButton = ({
18
19
  const {
19
20
  showMediaPicker,
20
21
  connectivityMode,
21
- allowsUploads
22
+ allowsUploads,
23
+ isUploadPending
22
24
  } = useSharedPluginStateWithSelector(api, ['media', 'connectivity'], states => {
23
25
  var _states$mediaState, _states$mediaState2, _states$connectivityS;
24
26
  return {
25
27
  showMediaPicker: (_states$mediaState = states.mediaState) === null || _states$mediaState === void 0 ? void 0 : _states$mediaState.showMediaPicker,
26
28
  allowsUploads: (_states$mediaState2 = states.mediaState) === null || _states$mediaState2 === void 0 ? void 0 : _states$mediaState2.allowsUploads,
29
+ isUploadPending: !states.mediaState || states.mediaState.uploadStatus === 'pending',
27
30
  connectivityMode: (_states$connectivityS = states.connectivityState) === null || _states$connectivityS === void 0 ? void 0 : _states$connectivityS.mode
28
31
  };
29
32
  });
@@ -58,6 +61,7 @@ export const MediaButton = ({
58
61
  });
59
62
  };
60
63
  const isOffline = isOfflineMode(connectivityMode);
64
+ const isDisabled = isOffline || !(allowsUploads || isExperimentEnabled('platform_editor_ssr_toolbar_optimistic') && isUploadPending);
61
65
  return /*#__PURE__*/React.createElement(ToolbarTooltip, {
62
66
  content: formatMessage(messages.addMediaFiles)
63
67
  }, /*#__PURE__*/React.createElement(ToolbarButton, {
@@ -67,7 +71,7 @@ export const MediaButton = ({
67
71
  }),
68
72
  onClick: onClick,
69
73
  ref: mediaButtonRef,
70
- isDisabled: isOffline || !allowsUploads,
74
+ isDisabled: isDisabled,
71
75
  testId: TOOLBAR_BUTTON_TEST_ID.MEDIA
72
76
  }));
73
77
  };
@@ -6,6 +6,7 @@ import { ToolTipContent, insertMention } from '@atlaskit/editor-common/keymaps';
6
6
  import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
7
7
  import { TOOLBAR_BUTTON_TEST_ID } from '@atlaskit/editor-common/toolbar';
8
8
  import { ToolbarButton, ToolbarTooltip, MentionIcon } from '@atlaskit/editor-toolbar';
9
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
9
10
  export const MentionButton = ({
10
11
  api
11
12
  }) => {
@@ -15,12 +16,16 @@ export const MentionButton = ({
15
16
  const {
16
17
  canInsertMention,
17
18
  mentionProvider,
19
+ mentionProviderStatus,
20
+ hasMentionState,
18
21
  isTypeAheadAllowed
19
22
  } = useSharedPluginStateWithSelector(api, ['mention', 'typeAhead'], states => {
20
- var _states$mentionState, _states$mentionState2, _states$typeAheadStat;
23
+ var _states$mentionState, _states$mentionState2, _states$mentionState3, _states$typeAheadStat;
21
24
  return {
22
25
  canInsertMention: (_states$mentionState = states.mentionState) === null || _states$mentionState === void 0 ? void 0 : _states$mentionState.canInsertMention,
23
26
  mentionProvider: (_states$mentionState2 = states.mentionState) === null || _states$mentionState2 === void 0 ? void 0 : _states$mentionState2.mentionProvider,
27
+ mentionProviderStatus: (_states$mentionState3 = states.mentionState) === null || _states$mentionState3 === void 0 ? void 0 : _states$mentionState3.mentionProviderStatus,
28
+ hasMentionState: states.mentionState !== undefined,
24
29
  isTypeAheadAllowed: (_states$typeAheadStat = states.typeAheadState) === null || _states$typeAheadStat === void 0 ? void 0 : _states$typeAheadStat.isAllowed
25
30
  };
26
31
  });
@@ -31,6 +36,10 @@ export const MentionButton = ({
31
36
  var _api$mention, _api$mention$actions;
32
37
  api === null || api === void 0 ? void 0 : (_api$mention = api.mention) === null || _api$mention === void 0 ? void 0 : (_api$mention$actions = _api$mention.actions) === null || _api$mention$actions === void 0 ? void 0 : _api$mention$actions.openTypeAhead(INPUT_METHOD.TOOLBAR);
33
38
  };
39
+
40
+ // The SSR state cannot resolve providers. Keep pending and available visually identical,
41
+ // while preserving known selection restrictions and settled provider failures.
42
+ const isDisabled = isExperimentEnabled('platform_editor_ssr_toolbar_optimistic') ? canInsertMention === false || hasMentionState && isTypeAheadAllowed === false || mentionProviderStatus !== 'pending' && hasMentionState && !mentionProvider : !canInsertMention || !mentionProvider || !isTypeAheadAllowed;
34
43
  return /*#__PURE__*/React.createElement(ToolbarTooltip, {
35
44
  content: /*#__PURE__*/React.createElement(ToolTipContent, {
36
45
  description: formatMessage(messages.mention),
@@ -43,7 +52,7 @@ export const MentionButton = ({
43
52
  }),
44
53
  onClick: onClick,
45
54
  ariaKeyshortcuts: "Shift+2 Space",
46
- isDisabled: !canInsertMention || !mentionProvider || !isTypeAheadAllowed,
55
+ isDisabled: isDisabled,
47
56
  testId: TOOLBAR_BUTTON_TEST_ID.MENTION
48
57
  }));
49
58
  };
@@ -6,6 +6,7 @@ import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/
6
6
  import { TOOLBAR_BUTTON_TEST_ID } from '@atlaskit/editor-common/toolbar';
7
7
  import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
8
8
  import { ToolbarButton, ToolbarTooltip, ImageIcon, useToolbarUI } from '@atlaskit/editor-toolbar';
9
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
9
10
  export var MediaButton = function MediaButton(_ref) {
10
11
  var api = _ref.api;
11
12
  var _useIntl = useIntl(),
@@ -17,12 +18,14 @@ export var MediaButton = function MediaButton(_ref) {
17
18
  return {
18
19
  showMediaPicker: (_states$mediaState = states.mediaState) === null || _states$mediaState === void 0 ? void 0 : _states$mediaState.showMediaPicker,
19
20
  allowsUploads: (_states$mediaState2 = states.mediaState) === null || _states$mediaState2 === void 0 ? void 0 : _states$mediaState2.allowsUploads,
21
+ isUploadPending: !states.mediaState || states.mediaState.uploadStatus === 'pending',
20
22
  connectivityMode: (_states$connectivityS = states.connectivityState) === null || _states$connectivityS === void 0 ? void 0 : _states$connectivityS.mode
21
23
  };
22
24
  }),
23
25
  showMediaPicker = _useSharedPluginState.showMediaPicker,
24
26
  connectivityMode = _useSharedPluginState.connectivityMode,
25
- allowsUploads = _useSharedPluginState.allowsUploads;
27
+ allowsUploads = _useSharedPluginState.allowsUploads,
28
+ isUploadPending = _useSharedPluginState.isUploadPending;
26
29
  var mediaButtonRef = useRef(null);
27
30
  if (!(api !== null && api !== void 0 && api.media)) {
28
31
  return null;
@@ -54,6 +57,7 @@ export var MediaButton = function MediaButton(_ref) {
54
57
  });
55
58
  };
56
59
  var isOffline = isOfflineMode(connectivityMode);
60
+ var isDisabled = isOffline || !(allowsUploads || isExperimentEnabled('platform_editor_ssr_toolbar_optimistic') && isUploadPending);
57
61
  return /*#__PURE__*/React.createElement(ToolbarTooltip, {
58
62
  content: formatMessage(messages.addMediaFiles)
59
63
  }, /*#__PURE__*/React.createElement(ToolbarButton, {
@@ -63,7 +67,7 @@ export var MediaButton = function MediaButton(_ref) {
63
67
  }),
64
68
  onClick: onClick,
65
69
  ref: mediaButtonRef,
66
- isDisabled: isOffline || !allowsUploads,
70
+ isDisabled: isDisabled,
67
71
  testId: TOOLBAR_BUTTON_TEST_ID.MEDIA
68
72
  }));
69
73
  };
@@ -6,20 +6,25 @@ import { ToolTipContent, insertMention } from '@atlaskit/editor-common/keymaps';
6
6
  import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
7
7
  import { TOOLBAR_BUTTON_TEST_ID } from '@atlaskit/editor-common/toolbar';
8
8
  import { ToolbarButton, ToolbarTooltip, MentionIcon } from '@atlaskit/editor-toolbar';
9
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
9
10
  export var MentionButton = function MentionButton(_ref) {
10
11
  var api = _ref.api;
11
12
  var _useIntl = useIntl(),
12
13
  formatMessage = _useIntl.formatMessage;
13
14
  var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['mention', 'typeAhead'], function (states) {
14
- var _states$mentionState, _states$mentionState2, _states$typeAheadStat;
15
+ var _states$mentionState, _states$mentionState2, _states$mentionState3, _states$typeAheadStat;
15
16
  return {
16
17
  canInsertMention: (_states$mentionState = states.mentionState) === null || _states$mentionState === void 0 ? void 0 : _states$mentionState.canInsertMention,
17
18
  mentionProvider: (_states$mentionState2 = states.mentionState) === null || _states$mentionState2 === void 0 ? void 0 : _states$mentionState2.mentionProvider,
19
+ mentionProviderStatus: (_states$mentionState3 = states.mentionState) === null || _states$mentionState3 === void 0 ? void 0 : _states$mentionState3.mentionProviderStatus,
20
+ hasMentionState: states.mentionState !== undefined,
18
21
  isTypeAheadAllowed: (_states$typeAheadStat = states.typeAheadState) === null || _states$typeAheadStat === void 0 ? void 0 : _states$typeAheadStat.isAllowed
19
22
  };
20
23
  }),
21
24
  canInsertMention = _useSharedPluginState.canInsertMention,
22
25
  mentionProvider = _useSharedPluginState.mentionProvider,
26
+ mentionProviderStatus = _useSharedPluginState.mentionProviderStatus,
27
+ hasMentionState = _useSharedPluginState.hasMentionState,
23
28
  isTypeAheadAllowed = _useSharedPluginState.isTypeAheadAllowed;
24
29
  if (!(api !== null && api !== void 0 && api.mention)) {
25
30
  return null;
@@ -28,6 +33,10 @@ export var MentionButton = function MentionButton(_ref) {
28
33
  var _api$mention;
29
34
  api === null || api === void 0 || (_api$mention = api.mention) === null || _api$mention === void 0 || (_api$mention = _api$mention.actions) === null || _api$mention === void 0 || _api$mention.openTypeAhead(INPUT_METHOD.TOOLBAR);
30
35
  };
36
+
37
+ // The SSR state cannot resolve providers. Keep pending and available visually identical,
38
+ // while preserving known selection restrictions and settled provider failures.
39
+ var isDisabled = isExperimentEnabled('platform_editor_ssr_toolbar_optimistic') ? canInsertMention === false || hasMentionState && isTypeAheadAllowed === false || mentionProviderStatus !== 'pending' && hasMentionState && !mentionProvider : !canInsertMention || !mentionProvider || !isTypeAheadAllowed;
31
40
  return /*#__PURE__*/React.createElement(ToolbarTooltip, {
32
41
  content: /*#__PURE__*/React.createElement(ToolTipContent, {
33
42
  description: formatMessage(messages.mention),
@@ -40,7 +49,7 @@ export var MentionButton = function MentionButton(_ref) {
40
49
  }),
41
50
  onClick: onClick,
42
51
  ariaKeyshortcuts: "Shift+2 Space",
43
- isDisabled: !canInsertMention || !mentionProvider || !isTypeAheadAllowed,
52
+ isDisabled: isDisabled,
44
53
  testId: TOOLBAR_BUTTON_TEST_ID.MENTION
45
54
  }));
46
55
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-insert-block",
3
- "version": "23.0.8",
3
+ "version": "23.0.10",
4
4
  "description": "Insert block plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -35,9 +35,9 @@
35
35
  "@atlaskit/editor-plugin-hyperlink": "^24.0.0",
36
36
  "@atlaskit/editor-plugin-image-upload": "^22.0.0",
37
37
  "@atlaskit/editor-plugin-layout": "^23.0.0",
38
- "@atlaskit/editor-plugin-media": "^24.0.0",
38
+ "@atlaskit/editor-plugin-media": "^24.1.0",
39
39
  "@atlaskit/editor-plugin-media-insert": "^40.0.0",
40
- "@atlaskit/editor-plugin-mentions": "^24.0.0",
40
+ "@atlaskit/editor-plugin-mentions": "^24.1.0",
41
41
  "@atlaskit/editor-plugin-metrics": "^23.0.0",
42
42
  "@atlaskit/editor-plugin-panel": "^24.0.0",
43
43
  "@atlaskit/editor-plugin-placeholder-text": "^23.0.0",
@@ -62,7 +62,7 @@
62
62
  "@atlaskit/platform-feature-flags": "^2.2.0",
63
63
  "@atlaskit/primitives": "^22.5.0",
64
64
  "@atlaskit/textfield": "^10.2.0",
65
- "@atlaskit/tmp-editor-statsig": "^217.0.0",
65
+ "@atlaskit/tmp-editor-statsig": "^218.0.0",
66
66
  "@atlaskit/tokens": "^20.1.0",
67
67
  "@babel/runtime": "^7.0.0",
68
68
  "@emotion/react": "^11.7.1",