@atlaskit/editor-plugin-insert-block 2.4.15 → 2.4.16

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,13 @@
1
1
  # @atlaskit/editor-plugin-insert-block
2
2
 
3
+ ## 2.4.16
4
+
5
+ ### Patch Changes
6
+
7
+ - [#169233](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/169233)
8
+ [`2ca37f881a673`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/2ca37f881a673) -
9
+ [ux] Disable media, emoji, and mention toolbar items while the editor is offline.
10
+
3
11
  ## 2.4.15
4
12
 
5
13
  ### Patch Changes
@@ -309,7 +309,7 @@ function ToolbarInsertBlockWithInjectionApi(_ref4) {
309
309
  options = _ref4.options,
310
310
  appearance = _ref4.appearance;
311
311
  var buttons = toolbarSizeToButtons(toolbarSize, appearance);
312
- var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['hyperlink', 'date', 'imageUpload', 'mention', 'emoji', 'blockType', 'media', 'typeAhead', 'placeholderText', 'insertBlock']),
312
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['hyperlink', 'date', 'imageUpload', 'mention', 'emoji', 'blockType', 'media', 'typeAhead', 'placeholderText', 'insertBlock', 'connectivity']),
313
313
  dateState = _useSharedPluginState.dateState,
314
314
  hyperlinkState = _useSharedPluginState.hyperlinkState,
315
315
  imageUploadState = _useSharedPluginState.imageUploadState,
@@ -319,7 +319,8 @@ function ToolbarInsertBlockWithInjectionApi(_ref4) {
319
319
  mediaState = _useSharedPluginState.mediaState,
320
320
  typeAheadState = _useSharedPluginState.typeAheadState,
321
321
  placeholderTextState = _useSharedPluginState.placeholderTextState,
322
- insertBlockState = _useSharedPluginState.insertBlockState;
322
+ insertBlockState = _useSharedPluginState.insertBlockState,
323
+ connectivityState = _useSharedPluginState.connectivityState;
323
324
  var getEmojiProvider = function getEmojiProvider() {
324
325
  if (emojiState !== null && emojiState !== void 0 && emojiState.emojiProvider) {
325
326
  return Promise.resolve(emojiState === null || emojiState === void 0 ? void 0 : emojiState.emojiProvider);
@@ -358,6 +359,7 @@ function ToolbarInsertBlockWithInjectionApi(_ref4) {
358
359
  mediaUploadsEnabled: (_ref5 = mediaState && mediaState.allowsUploads) !== null && _ref5 !== void 0 ? _ref5 : undefined,
359
360
  onShowMediaPicker: onShowMediaPicker,
360
361
  mediaSupported: !!mediaState,
362
+ isEditorOffline: (connectivityState === null || connectivityState === void 0 ? void 0 : connectivityState.mode) === 'offline',
361
363
  imageUploadSupported: !!(pluginInjectionApi !== null && pluginInjectionApi !== void 0 && pluginInjectionApi.imageUpload),
362
364
  imageUploadEnabled: imageUploadState === null || imageUploadState === void 0 ? void 0 : imageUploadState.enabled,
363
365
  handleImageUpload: pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$i = pluginInjectionApi.imageUpload) === null || _pluginInjectionApi$i === void 0 ? void 0 : _pluginInjectionApi$i.actions.startUpload,
@@ -63,8 +63,10 @@ var createInsertBlockItems = function createInsertBlockItems(config) {
63
63
  expandEnabled = config.expandEnabled,
64
64
  numberOfButtons = config.numberOfButtons,
65
65
  schema = config.schema,
66
- formatMessage = config.formatMessage;
66
+ formatMessage = config.formatMessage,
67
+ isEditorOffline = config.isEditorOffline;
67
68
  var items = [];
69
+ var isOffline = isEditorOffline === true;
68
70
  if (actionSupported) {
69
71
  items.push((0, _item.action)({
70
72
  content: formatMessage(_messages2.messages.action),
@@ -84,20 +86,20 @@ var createInsertBlockItems = function createInsertBlockItems(config) {
84
86
  items.push((0, _item.media)({
85
87
  content: formatMessage(_messages2.messages.addMediaFiles),
86
88
  tooltipDescription: formatMessage(_messages2.messages.mediaFilesDescription),
87
- disabled: false
89
+ disabled: isOffline
88
90
  }));
89
91
  }
90
92
  if (imageUploadSupported) {
91
93
  items.push((0, _item.imageUpload)({
92
94
  content: formatMessage(_messages2.messages.image),
93
- disabled: !imageUploadEnabled
95
+ disabled: !imageUploadEnabled || isOffline
94
96
  }));
95
97
  }
96
98
  if (mentionsSupported) {
97
99
  items.push((0, _item.mention)({
98
100
  content: formatMessage(_messages2.messages.mention),
99
101
  tooltipDescription: formatMessage(_messages2.messages.mentionDescription),
100
- disabled: !isTypeAheadAllowed || !!mentionsDisabled,
102
+ disabled: !isTypeAheadAllowed || !!mentionsDisabled || isOffline,
101
103
  'aria-haspopup': 'listbox'
102
104
  }));
103
105
  }
@@ -105,7 +107,7 @@ var createInsertBlockItems = function createInsertBlockItems(config) {
105
107
  items.push((0, _item.emoji)({
106
108
  content: formatMessage(_messages2.messages.emoji),
107
109
  tooltipDescription: formatMessage(_messages2.messages.emojiDescription),
108
- disabled: emojiDisabled || !isTypeAheadAllowed,
110
+ disabled: emojiDisabled || !isTypeAheadAllowed || isOffline,
109
111
  'aria-haspopup': 'dialog'
110
112
  }));
111
113
  }
@@ -826,6 +826,7 @@ var ToolbarInsertBlock = exports.ToolbarInsertBlock = /*#__PURE__*/function (_Re
826
826
  tableSelectorSupported: props.tableSelectorSupported,
827
827
  mediaUploadsEnabled: props.mediaUploadsEnabled,
828
828
  mediaSupported: props.mediaSupported,
829
+ isEditorOffline: props.isEditorOffline,
829
830
  imageUploadSupported: props.imageUploadSupported,
830
831
  imageUploadEnabled: props.imageUploadEnabled,
831
832
  mentionsSupported: props.mentionsSupported,
@@ -315,8 +315,9 @@ function ToolbarInsertBlockWithInjectionApi({
315
315
  mediaState,
316
316
  typeAheadState,
317
317
  placeholderTextState,
318
- insertBlockState
319
- } = useSharedPluginState(pluginInjectionApi, ['hyperlink', 'date', 'imageUpload', 'mention', 'emoji', 'blockType', 'media', 'typeAhead', 'placeholderText', 'insertBlock']);
318
+ insertBlockState,
319
+ connectivityState
320
+ } = useSharedPluginState(pluginInjectionApi, ['hyperlink', 'date', 'imageUpload', 'mention', 'emoji', 'blockType', 'media', 'typeAhead', 'placeholderText', 'insertBlock', 'connectivity']);
320
321
  const getEmojiProvider = () => {
321
322
  if (emojiState !== null && emojiState !== void 0 && emojiState.emojiProvider) {
322
323
  return Promise.resolve(emojiState === null || emojiState === void 0 ? void 0 : emojiState.emojiProvider);
@@ -355,6 +356,7 @@ function ToolbarInsertBlockWithInjectionApi({
355
356
  mediaUploadsEnabled: (_ref = mediaState && mediaState.allowsUploads) !== null && _ref !== void 0 ? _ref : undefined,
356
357
  onShowMediaPicker: onShowMediaPicker,
357
358
  mediaSupported: !!mediaState,
359
+ isEditorOffline: (connectivityState === null || connectivityState === void 0 ? void 0 : connectivityState.mode) === 'offline',
358
360
  imageUploadSupported: !!(pluginInjectionApi !== null && pluginInjectionApi !== void 0 && pluginInjectionApi.imageUpload),
359
361
  imageUploadEnabled: imageUploadState === null || imageUploadState === void 0 ? void 0 : imageUploadState.enabled,
360
362
  handleImageUpload: pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$i = pluginInjectionApi.imageUpload) === null || _pluginInjectionApi$i === void 0 ? void 0 : _pluginInjectionApi$i.actions.startUpload,
@@ -49,9 +49,11 @@ const createInsertBlockItems = config => {
49
49
  expandEnabled,
50
50
  numberOfButtons,
51
51
  schema,
52
- formatMessage
52
+ formatMessage,
53
+ isEditorOffline
53
54
  } = config;
54
55
  const items = [];
56
+ const isOffline = isEditorOffline === true;
55
57
  if (actionSupported) {
56
58
  items.push(action({
57
59
  content: formatMessage(messages.action),
@@ -71,20 +73,20 @@ const createInsertBlockItems = config => {
71
73
  items.push(media({
72
74
  content: formatMessage(messages.addMediaFiles),
73
75
  tooltipDescription: formatMessage(messages.mediaFilesDescription),
74
- disabled: false
76
+ disabled: isOffline
75
77
  }));
76
78
  }
77
79
  if (imageUploadSupported) {
78
80
  items.push(imageUpload({
79
81
  content: formatMessage(messages.image),
80
- disabled: !imageUploadEnabled
82
+ disabled: !imageUploadEnabled || isOffline
81
83
  }));
82
84
  }
83
85
  if (mentionsSupported) {
84
86
  items.push(mention({
85
87
  content: formatMessage(messages.mention),
86
88
  tooltipDescription: formatMessage(messages.mentionDescription),
87
- disabled: !isTypeAheadAllowed || !!mentionsDisabled,
89
+ disabled: !isTypeAheadAllowed || !!mentionsDisabled || isOffline,
88
90
  'aria-haspopup': 'listbox'
89
91
  }));
90
92
  }
@@ -92,7 +94,7 @@ const createInsertBlockItems = config => {
92
94
  items.push(emoji({
93
95
  content: formatMessage(messages.emoji),
94
96
  tooltipDescription: formatMessage(messages.emojiDescription),
95
- disabled: emojiDisabled || !isTypeAheadAllowed,
97
+ disabled: emojiDisabled || !isTypeAheadAllowed || isOffline,
96
98
  'aria-haspopup': 'dialog'
97
99
  }));
98
100
  }
@@ -577,6 +577,7 @@ export class ToolbarInsertBlock extends React.PureComponent {
577
577
  tableSelectorSupported: props.tableSelectorSupported,
578
578
  mediaUploadsEnabled: props.mediaUploadsEnabled,
579
579
  mediaSupported: props.mediaSupported,
580
+ isEditorOffline: props.isEditorOffline,
580
581
  imageUploadSupported: props.imageUploadSupported,
581
582
  imageUploadEnabled: props.imageUploadEnabled,
582
583
  mentionsSupported: props.mentionsSupported,
@@ -302,7 +302,7 @@ function ToolbarInsertBlockWithInjectionApi(_ref4) {
302
302
  options = _ref4.options,
303
303
  appearance = _ref4.appearance;
304
304
  var buttons = toolbarSizeToButtons(toolbarSize, appearance);
305
- var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['hyperlink', 'date', 'imageUpload', 'mention', 'emoji', 'blockType', 'media', 'typeAhead', 'placeholderText', 'insertBlock']),
305
+ var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['hyperlink', 'date', 'imageUpload', 'mention', 'emoji', 'blockType', 'media', 'typeAhead', 'placeholderText', 'insertBlock', 'connectivity']),
306
306
  dateState = _useSharedPluginState.dateState,
307
307
  hyperlinkState = _useSharedPluginState.hyperlinkState,
308
308
  imageUploadState = _useSharedPluginState.imageUploadState,
@@ -312,7 +312,8 @@ function ToolbarInsertBlockWithInjectionApi(_ref4) {
312
312
  mediaState = _useSharedPluginState.mediaState,
313
313
  typeAheadState = _useSharedPluginState.typeAheadState,
314
314
  placeholderTextState = _useSharedPluginState.placeholderTextState,
315
- insertBlockState = _useSharedPluginState.insertBlockState;
315
+ insertBlockState = _useSharedPluginState.insertBlockState,
316
+ connectivityState = _useSharedPluginState.connectivityState;
316
317
  var getEmojiProvider = function getEmojiProvider() {
317
318
  if (emojiState !== null && emojiState !== void 0 && emojiState.emojiProvider) {
318
319
  return Promise.resolve(emojiState === null || emojiState === void 0 ? void 0 : emojiState.emojiProvider);
@@ -351,6 +352,7 @@ function ToolbarInsertBlockWithInjectionApi(_ref4) {
351
352
  mediaUploadsEnabled: (_ref5 = mediaState && mediaState.allowsUploads) !== null && _ref5 !== void 0 ? _ref5 : undefined,
352
353
  onShowMediaPicker: onShowMediaPicker,
353
354
  mediaSupported: !!mediaState,
355
+ isEditorOffline: (connectivityState === null || connectivityState === void 0 ? void 0 : connectivityState.mode) === 'offline',
354
356
  imageUploadSupported: !!(pluginInjectionApi !== null && pluginInjectionApi !== void 0 && pluginInjectionApi.imageUpload),
355
357
  imageUploadEnabled: imageUploadState === null || imageUploadState === void 0 ? void 0 : imageUploadState.enabled,
356
358
  handleImageUpload: pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$i = pluginInjectionApi.imageUpload) === null || _pluginInjectionApi$i === void 0 ? void 0 : _pluginInjectionApi$i.actions.startUpload,
@@ -56,8 +56,10 @@ var createInsertBlockItems = function createInsertBlockItems(config) {
56
56
  expandEnabled = config.expandEnabled,
57
57
  numberOfButtons = config.numberOfButtons,
58
58
  schema = config.schema,
59
- formatMessage = config.formatMessage;
59
+ formatMessage = config.formatMessage,
60
+ isEditorOffline = config.isEditorOffline;
60
61
  var items = [];
62
+ var isOffline = isEditorOffline === true;
61
63
  if (actionSupported) {
62
64
  items.push(action({
63
65
  content: formatMessage(messages.action),
@@ -77,20 +79,20 @@ var createInsertBlockItems = function createInsertBlockItems(config) {
77
79
  items.push(media({
78
80
  content: formatMessage(messages.addMediaFiles),
79
81
  tooltipDescription: formatMessage(messages.mediaFilesDescription),
80
- disabled: false
82
+ disabled: isOffline
81
83
  }));
82
84
  }
83
85
  if (imageUploadSupported) {
84
86
  items.push(imageUpload({
85
87
  content: formatMessage(messages.image),
86
- disabled: !imageUploadEnabled
88
+ disabled: !imageUploadEnabled || isOffline
87
89
  }));
88
90
  }
89
91
  if (mentionsSupported) {
90
92
  items.push(mention({
91
93
  content: formatMessage(messages.mention),
92
94
  tooltipDescription: formatMessage(messages.mentionDescription),
93
- disabled: !isTypeAheadAllowed || !!mentionsDisabled,
95
+ disabled: !isTypeAheadAllowed || !!mentionsDisabled || isOffline,
94
96
  'aria-haspopup': 'listbox'
95
97
  }));
96
98
  }
@@ -98,7 +100,7 @@ var createInsertBlockItems = function createInsertBlockItems(config) {
98
100
  items.push(emoji({
99
101
  content: formatMessage(messages.emoji),
100
102
  tooltipDescription: formatMessage(messages.emojiDescription),
101
- disabled: emojiDisabled || !isTypeAheadAllowed,
103
+ disabled: emojiDisabled || !isTypeAheadAllowed || isOffline,
102
104
  'aria-haspopup': 'dialog'
103
105
  }));
104
106
  }
@@ -817,6 +817,7 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
817
817
  tableSelectorSupported: props.tableSelectorSupported,
818
818
  mediaUploadsEnabled: props.mediaUploadsEnabled,
819
819
  mediaSupported: props.mediaSupported,
820
+ isEditorOffline: props.isEditorOffline,
820
821
  imageUploadSupported: props.imageUploadSupported,
821
822
  imageUploadEnabled: props.imageUploadEnabled,
822
823
  mentionsSupported: props.mentionsSupported,
@@ -2,6 +2,7 @@ import type { OptionalPlugin } from '@atlaskit/editor-common/types';
2
2
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
3
3
  import type { BlockTypePlugin } from '@atlaskit/editor-plugin-block-type';
4
4
  import type { CodeBlockPlugin } from '@atlaskit/editor-plugin-code-block';
5
+ import type { ConnectivityPlugin } from '@atlaskit/editor-plugin-connectivity';
5
6
  import type { ContextPanelPlugin } from '@atlaskit/editor-plugin-context-panel';
6
7
  import type { DatePlugin } from '@atlaskit/editor-plugin-date';
7
8
  import type { EmojiPlugin } from '@atlaskit/editor-plugin-emoji';
@@ -47,5 +48,6 @@ export type InsertBlockPluginDependencies = [
47
48
  OptionalPlugin<TasksAndDecisionsPlugin>,
48
49
  OptionalPlugin<PrimaryToolbarPlugin>,
49
50
  OptionalPlugin<FeatureFlagsPlugin>,
50
- OptionalPlugin<ContextPanelPlugin>
51
+ OptionalPlugin<ContextPanelPlugin>,
52
+ OptionalPlugin<ConnectivityPlugin>
51
53
  ];
@@ -33,6 +33,7 @@ export interface CreateItemsConfig {
33
33
  numberOfButtons: number;
34
34
  formatMessage: WrappedComponentProps['intl']['formatMessage'];
35
35
  isNewMenuEnabled?: boolean;
36
+ isEditorOffline?: boolean;
36
37
  }
37
38
  export interface BlockMenuItem extends MenuItem {
38
39
  title: JSX.Element | null;
@@ -23,6 +23,7 @@ export interface Props {
23
23
  mentionsSupported?: boolean;
24
24
  mediaUploadsEnabled?: boolean;
25
25
  mediaSupported?: boolean;
26
+ isEditorOffline?: boolean;
26
27
  imageUploadSupported?: boolean;
27
28
  imageUploadEnabled?: boolean;
28
29
  handleImageUpload?: (event?: ImageUploadPluginReferenceEvent) => Command;
@@ -2,6 +2,7 @@ import type { OptionalPlugin } from '@atlaskit/editor-common/types';
2
2
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
3
3
  import type { BlockTypePlugin } from '@atlaskit/editor-plugin-block-type';
4
4
  import type { CodeBlockPlugin } from '@atlaskit/editor-plugin-code-block';
5
+ import type { ConnectivityPlugin } from '@atlaskit/editor-plugin-connectivity';
5
6
  import type { ContextPanelPlugin } from '@atlaskit/editor-plugin-context-panel';
6
7
  import type { DatePlugin } from '@atlaskit/editor-plugin-date';
7
8
  import type { EmojiPlugin } from '@atlaskit/editor-plugin-emoji';
@@ -47,5 +48,6 @@ export type InsertBlockPluginDependencies = [
47
48
  OptionalPlugin<TasksAndDecisionsPlugin>,
48
49
  OptionalPlugin<PrimaryToolbarPlugin>,
49
50
  OptionalPlugin<FeatureFlagsPlugin>,
50
- OptionalPlugin<ContextPanelPlugin>
51
+ OptionalPlugin<ContextPanelPlugin>,
52
+ OptionalPlugin<ConnectivityPlugin>
51
53
  ];
@@ -33,6 +33,7 @@ export interface CreateItemsConfig {
33
33
  numberOfButtons: number;
34
34
  formatMessage: WrappedComponentProps['intl']['formatMessage'];
35
35
  isNewMenuEnabled?: boolean;
36
+ isEditorOffline?: boolean;
36
37
  }
37
38
  export interface BlockMenuItem extends MenuItem {
38
39
  title: JSX.Element | null;
@@ -23,6 +23,7 @@ export interface Props {
23
23
  mentionsSupported?: boolean;
24
24
  mediaUploadsEnabled?: boolean;
25
25
  mediaSupported?: boolean;
26
+ isEditorOffline?: boolean;
26
27
  imageUploadSupported?: boolean;
27
28
  imageUploadEnabled?: boolean;
28
29
  handleImageUpload?: (event?: ImageUploadPluginReferenceEvent) => Command;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-insert-block",
3
- "version": "2.4.15",
3
+ "version": "2.4.16",
4
4
  "description": "Insert block plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -32,10 +32,11 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@atlaskit/button": "^20.3.0",
35
- "@atlaskit/editor-common": "^95.6.0",
35
+ "@atlaskit/editor-common": "^95.7.0",
36
36
  "@atlaskit/editor-plugin-analytics": "^1.10.0",
37
37
  "@atlaskit/editor-plugin-block-type": "^4.0.0",
38
38
  "@atlaskit/editor-plugin-code-block": "^3.5.0",
39
+ "@atlaskit/editor-plugin-connectivity": "^1.0.0",
39
40
  "@atlaskit/editor-plugin-date": "^2.4.0",
40
41
  "@atlaskit/editor-plugin-emoji": "^2.7.0",
41
42
  "@atlaskit/editor-plugin-expand": "^2.10.0",
@@ -63,9 +64,9 @@
63
64
  "@atlaskit/icon": "^22.26.0",
64
65
  "@atlaskit/icon-lab": "^1.2.0",
65
66
  "@atlaskit/platform-feature-flags": "^0.3.0",
66
- "@atlaskit/primitives": "^13.2.0",
67
+ "@atlaskit/primitives": "^13.3.0",
67
68
  "@atlaskit/theme": "^14.0.0",
68
- "@atlaskit/tmp-editor-statsig": "^2.20.0",
69
+ "@atlaskit/tmp-editor-statsig": "^2.21.0",
69
70
  "@atlaskit/tokens": "^2.3.0",
70
71
  "@atlaskit/tooltip": "18.9.3",
71
72
  "@babel/runtime": "^7.0.0",