@atlaskit/editor-plugin-insert-block 31.0.15 → 31.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,19 @@
1
1
  # @atlaskit/editor-plugin-insert-block
2
2
 
3
+ ## 31.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`059477aa93f45`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/059477aa93f45) -
8
+ Add an optimistic-toolbar opt-out to plugin configuration. Exclude Live pages from
9
+ platform_editor_ssr_toolbar_optimistic, including early editor-state exposure, toolbar rendering,
10
+ and asynchronous media and mention provider initialization. Preserve the experiment for Edit pages
11
+ regardless of toolbar docking position.
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies
16
+
3
17
  ## 31.0.15
4
18
 
5
19
  ### Patch Changes
@@ -32,10 +32,11 @@ var POPUP_OFFSET = [0, 3];
32
32
  * and menu model as slash command.
33
33
  */
34
34
  var RegisteredInsertButton = exports.RegisteredInsertButton = function RegisteredInsertButton(_ref) {
35
- var api = _ref.api;
35
+ var api = _ref.api,
36
+ disableOptimisticToolbar = _ref.disableOptimisticToolbar;
36
37
  var _useEditorToolbar = (0, _context.useEditorToolbar)(),
37
38
  editorView = _useEditorToolbar.editorView;
38
- var isOptimistic = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_ssr_toolbar_optimistic');
39
+ var isOptimistic = !disableOptimisticToolbar && (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_ssr_toolbar_optimistic');
39
40
  var _useIntl = (0, _reactIntl.useIntl)(),
40
41
  formatMessage = _useIntl.formatMessage;
41
42
  var _useToolbarUI = (0, _uiContext.useToolbarUI)(),
@@ -19,7 +19,8 @@ var _uiContext = require("@atlaskit/editor-toolbar/ui-context");
19
19
  var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
20
20
  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); }
21
21
  var MediaButton = exports.MediaButton = function MediaButton(_ref) {
22
- var api = _ref.api;
22
+ var api = _ref.api,
23
+ disableOptimisticToolbar = _ref.disableOptimisticToolbar;
23
24
  var _useIntl = (0, _reactIntl.useIntl)(),
24
25
  formatMessage = _useIntl.formatMessage;
25
26
  var _useToolbarUI = (0, _uiContext.useToolbarUI)(),
@@ -68,7 +69,7 @@ var MediaButton = exports.MediaButton = function MediaButton(_ref) {
68
69
  });
69
70
  };
70
71
  var isOffline = (0, _isOfflineMode.isOfflineMode)(connectivityMode);
71
- var isDisabled = isOffline || !(allowsUploads || (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_ssr_toolbar_optimistic') && isUploadPending);
72
+ var isDisabled = isOffline || !(allowsUploads || !disableOptimisticToolbar && (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_ssr_toolbar_optimistic') && isUploadPending);
72
73
  return /*#__PURE__*/_react.default.createElement(_toolbarTooltip.ToolbarTooltip, {
73
74
  content: formatMessage(_insertBlock.toolbarInsertBlockMessages.addMediaFiles)
74
75
  }, /*#__PURE__*/_react.default.createElement(_toolbarButton.ToolbarButton, {
@@ -17,7 +17,8 @@ var _toolbarButton = require("@atlaskit/editor-toolbar/toolbar-button");
17
17
  var _toolbarTooltip = require("@atlaskit/editor-toolbar/toolbar-tooltip");
18
18
  var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
19
19
  var MentionButton = exports.MentionButton = function MentionButton(_ref) {
20
- var api = _ref.api;
20
+ var api = _ref.api,
21
+ disableOptimisticToolbar = _ref.disableOptimisticToolbar;
21
22
  var _useIntl = (0, _reactIntl.useIntl)(),
22
23
  formatMessage = _useIntl.formatMessage;
23
24
  var _useSharedPluginState = (0, _useSharedPluginStateWithSelector.useSharedPluginStateWithSelector)(api, ['mention', 'typeAhead'], function (states) {
@@ -45,7 +46,7 @@ var MentionButton = exports.MentionButton = function MentionButton(_ref) {
45
46
 
46
47
  // The SSR state cannot resolve providers. Keep pending and available visually identical,
47
48
  // while preserving known selection restrictions and settled provider failures.
48
- var isDisabled = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_ssr_toolbar_optimistic') ? canInsertMention === false || hasMentionState && isTypeAheadAllowed === false || mentionProviderStatus !== 'pending' && hasMentionState && !mentionProvider : !canInsertMention || !mentionProvider || !isTypeAheadAllowed;
49
+ var isDisabled = !disableOptimisticToolbar && (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_ssr_toolbar_optimistic') ? canInsertMention === false || hasMentionState && isTypeAheadAllowed === false || mentionProviderStatus !== 'pending' && hasMentionState && !mentionProvider : !canInsertMention || !mentionProvider || !isTypeAheadAllowed;
49
50
  return /*#__PURE__*/_react.default.createElement(_toolbarTooltip.ToolbarTooltip, {
50
51
  content: /*#__PURE__*/_react.default.createElement(_keymaps.ToolTipContent, {
51
52
  description: formatMessage(_insertBlock.toolbarInsertBlockMessages.mention),
@@ -99,7 +99,8 @@ var getToolbarComponents = exports.getToolbarComponents = function getToolbarCom
99
99
  return !!(api !== null && api !== void 0 && api.imageUpload) ? /*#__PURE__*/_react.default.createElement(_ImageButton.ImageButton, {
100
100
  api: api
101
101
  }) : /*#__PURE__*/_react.default.createElement(_MediaButton.MediaButton, {
102
- api: api
102
+ api: api,
103
+ disableOptimisticToolbar: options.disableOptimisticToolbar
103
104
  });
104
105
  }
105
106
  });
@@ -156,7 +157,8 @@ var getToolbarComponents = exports.getToolbarComponents = function getToolbarCom
156
157
  }],
157
158
  component: function component() {
158
159
  return /*#__PURE__*/_react.default.createElement(_MentionButton.MentionButton, {
159
- api: api
160
+ api: api,
161
+ disableOptimisticToolbar: options.disableOptimisticToolbar
160
162
  });
161
163
  }
162
164
  });
@@ -268,7 +270,8 @@ var getToolbarComponents = exports.getToolbarComponents = function getToolbarCom
268
270
  var createInsertButtonComponent = function createInsertButtonComponent(breakpoint) {
269
271
  return function () {
270
272
  return (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_slash_command') ? /*#__PURE__*/_react.default.createElement(_RegisteredInsertButton.RegisteredInsertButton, {
271
- api: api
273
+ api: api,
274
+ disableOptimisticToolbar: options.disableOptimisticToolbar
272
275
  }) : /*#__PURE__*/_react.default.createElement(_InsertButton.InsertButton, {
273
276
  api: api,
274
277
  breakpoint: breakpoint,
@@ -22,12 +22,13 @@ const POPUP_OFFSET = [0, 3];
22
22
  * and menu model as slash command.
23
23
  */
24
24
  export const RegisteredInsertButton = ({
25
- api
25
+ api,
26
+ disableOptimisticToolbar
26
27
  }) => {
27
28
  const {
28
29
  editorView
29
30
  } = useEditorToolbar();
30
- const isOptimistic = isExperimentEnabled('platform_editor_ssr_toolbar_optimistic');
31
+ const isOptimistic = !disableOptimisticToolbar && isExperimentEnabled('platform_editor_ssr_toolbar_optimistic');
31
32
  const {
32
33
  formatMessage
33
34
  } = useIntl();
@@ -11,7 +11,8 @@ import { ToolbarTooltip } from '@atlaskit/editor-toolbar/toolbar-tooltip';
11
11
  import { useToolbarUI } from '@atlaskit/editor-toolbar/ui-context';
12
12
  import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
13
13
  export const MediaButton = ({
14
- api
14
+ api,
15
+ disableOptimisticToolbar
15
16
  }) => {
16
17
  const {
17
18
  formatMessage
@@ -64,7 +65,7 @@ export const MediaButton = ({
64
65
  });
65
66
  };
66
67
  const isOffline = isOfflineMode(connectivityMode);
67
- const isDisabled = isOffline || !(allowsUploads || isExperimentEnabled('platform_editor_ssr_toolbar_optimistic') && isUploadPending);
68
+ const isDisabled = isOffline || !(allowsUploads || !disableOptimisticToolbar && isExperimentEnabled('platform_editor_ssr_toolbar_optimistic') && isUploadPending);
68
69
  return /*#__PURE__*/React.createElement(ToolbarTooltip, {
69
70
  content: formatMessage(messages.addMediaFiles)
70
71
  }, /*#__PURE__*/React.createElement(ToolbarButton, {
@@ -10,7 +10,8 @@ import { ToolbarButton } from '@atlaskit/editor-toolbar/toolbar-button';
10
10
  import { ToolbarTooltip } from '@atlaskit/editor-toolbar/toolbar-tooltip';
11
11
  import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
12
12
  export const MentionButton = ({
13
- api
13
+ api,
14
+ disableOptimisticToolbar
14
15
  }) => {
15
16
  const {
16
17
  formatMessage
@@ -41,7 +42,7 @@ export const MentionButton = ({
41
42
 
42
43
  // The SSR state cannot resolve providers. Keep pending and available visually identical,
43
44
  // while preserving known selection restrictions and settled provider failures.
44
- const isDisabled = isExperimentEnabled('platform_editor_ssr_toolbar_optimistic') ? canInsertMention === false || hasMentionState && isTypeAheadAllowed === false || mentionProviderStatus !== 'pending' && hasMentionState && !mentionProvider : !canInsertMention || !mentionProvider || !isTypeAheadAllowed;
45
+ const isDisabled = !disableOptimisticToolbar && isExperimentEnabled('platform_editor_ssr_toolbar_optimistic') ? canInsertMention === false || hasMentionState && isTypeAheadAllowed === false || mentionProviderStatus !== 'pending' && hasMentionState && !mentionProvider : !canInsertMention || !mentionProvider || !isTypeAheadAllowed;
45
46
  return /*#__PURE__*/React.createElement(ToolbarTooltip, {
46
47
  content: /*#__PURE__*/React.createElement(ToolTipContent, {
47
48
  description: formatMessage(messages.mention),
@@ -89,7 +89,8 @@ export const getToolbarComponents = ({
89
89
  component: () => !!(api !== null && api !== void 0 && api.imageUpload) ? /*#__PURE__*/React.createElement(ImageButton, {
90
90
  api: api
91
91
  }) : /*#__PURE__*/React.createElement(MediaButton, {
92
- api: api
92
+ api: api,
93
+ disableOptimisticToolbar: options.disableOptimisticToolbar
93
94
  })
94
95
  });
95
96
  }
@@ -142,7 +143,8 @@ export const getToolbarComponents = ({
142
143
  rank: MENTION_GROUP_RANK[MENTION_BUTTON.key]
143
144
  }],
144
145
  component: () => /*#__PURE__*/React.createElement(MentionButton, {
145
- api: api
146
+ api: api,
147
+ disableOptimisticToolbar: options.disableOptimisticToolbar
146
148
  })
147
149
  });
148
150
  }
@@ -244,7 +246,8 @@ export const getToolbarComponents = ({
244
246
  if ((_config$insert = config.insert) !== null && _config$insert !== void 0 && _config$insert.enabled) {
245
247
  const createInsertButtonComponent = breakpoint => {
246
248
  return () => isExperimentEnabled('platform_editor_slash_command') ? /*#__PURE__*/React.createElement(RegisteredInsertButton, {
247
- api: api
249
+ api: api,
250
+ disableOptimisticToolbar: options.disableOptimisticToolbar
248
251
  }) : /*#__PURE__*/React.createElement(InsertButton, {
249
252
  api: api,
250
253
  breakpoint: breakpoint,
@@ -23,10 +23,11 @@ var POPUP_OFFSET = [0, 3];
23
23
  * and menu model as slash command.
24
24
  */
25
25
  export var RegisteredInsertButton = function RegisteredInsertButton(_ref) {
26
- var api = _ref.api;
26
+ var api = _ref.api,
27
+ disableOptimisticToolbar = _ref.disableOptimisticToolbar;
27
28
  var _useEditorToolbar = useEditorToolbar(),
28
29
  editorView = _useEditorToolbar.editorView;
29
- var isOptimistic = isExperimentEnabled('platform_editor_ssr_toolbar_optimistic');
30
+ var isOptimistic = !disableOptimisticToolbar && isExperimentEnabled('platform_editor_ssr_toolbar_optimistic');
30
31
  var _useIntl = useIntl(),
31
32
  formatMessage = _useIntl.formatMessage;
32
33
  var _useToolbarUI = useToolbarUI(),
@@ -11,7 +11,8 @@ import { ToolbarTooltip } from '@atlaskit/editor-toolbar/toolbar-tooltip';
11
11
  import { useToolbarUI } from '@atlaskit/editor-toolbar/ui-context';
12
12
  import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
13
13
  export var MediaButton = function MediaButton(_ref) {
14
- var api = _ref.api;
14
+ var api = _ref.api,
15
+ disableOptimisticToolbar = _ref.disableOptimisticToolbar;
15
16
  var _useIntl = useIntl(),
16
17
  formatMessage = _useIntl.formatMessage;
17
18
  var _useToolbarUI = useToolbarUI(),
@@ -60,7 +61,7 @@ export var MediaButton = function MediaButton(_ref) {
60
61
  });
61
62
  };
62
63
  var isOffline = isOfflineMode(connectivityMode);
63
- var isDisabled = isOffline || !(allowsUploads || isExperimentEnabled('platform_editor_ssr_toolbar_optimistic') && isUploadPending);
64
+ var isDisabled = isOffline || !(allowsUploads || !disableOptimisticToolbar && isExperimentEnabled('platform_editor_ssr_toolbar_optimistic') && isUploadPending);
64
65
  return /*#__PURE__*/React.createElement(ToolbarTooltip, {
65
66
  content: formatMessage(messages.addMediaFiles)
66
67
  }, /*#__PURE__*/React.createElement(ToolbarButton, {
@@ -10,7 +10,8 @@ import { ToolbarButton } from '@atlaskit/editor-toolbar/toolbar-button';
10
10
  import { ToolbarTooltip } from '@atlaskit/editor-toolbar/toolbar-tooltip';
11
11
  import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
12
12
  export var MentionButton = function MentionButton(_ref) {
13
- var api = _ref.api;
13
+ var api = _ref.api,
14
+ disableOptimisticToolbar = _ref.disableOptimisticToolbar;
14
15
  var _useIntl = useIntl(),
15
16
  formatMessage = _useIntl.formatMessage;
16
17
  var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['mention', 'typeAhead'], function (states) {
@@ -38,7 +39,7 @@ export var MentionButton = function MentionButton(_ref) {
38
39
 
39
40
  // The SSR state cannot resolve providers. Keep pending and available visually identical,
40
41
  // while preserving known selection restrictions and settled provider failures.
41
- var isDisabled = isExperimentEnabled('platform_editor_ssr_toolbar_optimistic') ? canInsertMention === false || hasMentionState && isTypeAheadAllowed === false || mentionProviderStatus !== 'pending' && hasMentionState && !mentionProvider : !canInsertMention || !mentionProvider || !isTypeAheadAllowed;
42
+ var isDisabled = !disableOptimisticToolbar && isExperimentEnabled('platform_editor_ssr_toolbar_optimistic') ? canInsertMention === false || hasMentionState && isTypeAheadAllowed === false || mentionProviderStatus !== 'pending' && hasMentionState && !mentionProvider : !canInsertMention || !mentionProvider || !isTypeAheadAllowed;
42
43
  return /*#__PURE__*/React.createElement(ToolbarTooltip, {
43
44
  content: /*#__PURE__*/React.createElement(ToolTipContent, {
44
45
  description: formatMessage(messages.mention),
@@ -92,7 +92,8 @@ export var getToolbarComponents = function getToolbarComponents(_ref) {
92
92
  return !!(api !== null && api !== void 0 && api.imageUpload) ? /*#__PURE__*/React.createElement(ImageButton, {
93
93
  api: api
94
94
  }) : /*#__PURE__*/React.createElement(MediaButton, {
95
- api: api
95
+ api: api,
96
+ disableOptimisticToolbar: options.disableOptimisticToolbar
96
97
  });
97
98
  }
98
99
  });
@@ -149,7 +150,8 @@ export var getToolbarComponents = function getToolbarComponents(_ref) {
149
150
  }],
150
151
  component: function component() {
151
152
  return /*#__PURE__*/React.createElement(MentionButton, {
152
- api: api
153
+ api: api,
154
+ disableOptimisticToolbar: options.disableOptimisticToolbar
153
155
  });
154
156
  }
155
157
  });
@@ -261,7 +263,8 @@ export var getToolbarComponents = function getToolbarComponents(_ref) {
261
263
  var createInsertButtonComponent = function createInsertButtonComponent(breakpoint) {
262
264
  return function () {
263
265
  return isExperimentEnabled('platform_editor_slash_command') ? /*#__PURE__*/React.createElement(RegisteredInsertButton, {
264
- api: api
266
+ api: api,
267
+ disableOptimisticToolbar: options.disableOptimisticToolbar
265
268
  }) : /*#__PURE__*/React.createElement(InsertButton, {
266
269
  api: api,
267
270
  breakpoint: breakpoint,
@@ -67,6 +67,8 @@ export interface InsertBlockPluginOptions {
67
67
  allowExpand?: boolean;
68
68
  allowTables?: boolean;
69
69
  appearance?: EditorAppearance;
70
+ /** Opt this editor surface out of the optimistic SSR toolbar experiment. */
71
+ disableOptimisticToolbar?: boolean;
70
72
  horizontalRuleEnabled?: boolean;
71
73
  insertMenuItems?: any;
72
74
  /**
@@ -3,10 +3,11 @@ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types/next-edi
3
3
  import type { InsertBlockPlugin } from '../../insertBlockPluginType';
4
4
  type Props = {
5
5
  api?: ExtractInjectionAPI<InsertBlockPlugin>;
6
+ disableOptimisticToolbar?: boolean;
6
7
  };
7
8
  /**
8
9
  * The toolbar owns its popup lifecycle, but renders the same registered items
9
10
  * and menu model as slash command.
10
11
  */
11
- export declare const RegisteredInsertButton: ({ api }: Props) => React.JSX.Element | null;
12
+ export declare const RegisteredInsertButton: ({ api, disableOptimisticToolbar, }: Props) => React.JSX.Element | null;
12
13
  export {};
@@ -3,6 +3,7 @@ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types/next-edi
3
3
  import type { InsertBlockPlugin } from '../../insertBlockPluginType';
4
4
  type MediaButtonProps = {
5
5
  api?: ExtractInjectionAPI<InsertBlockPlugin>;
6
+ disableOptimisticToolbar?: boolean;
6
7
  };
7
- export declare const MediaButton: ({ api }: MediaButtonProps) => React.JSX.Element | null;
8
+ export declare const MediaButton: ({ api, disableOptimisticToolbar, }: MediaButtonProps) => React.JSX.Element | null;
8
9
  export {};
@@ -3,6 +3,7 @@ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types/next-edi
3
3
  import type { InsertBlockPlugin } from '../../insertBlockPluginType';
4
4
  type MentionButtonProps = {
5
5
  api?: ExtractInjectionAPI<InsertBlockPlugin>;
6
+ disableOptimisticToolbar?: boolean;
6
7
  };
7
- export declare const MentionButton: ({ api }: MentionButtonProps) => React.JSX.Element | null;
8
+ export declare const MentionButton: ({ api, disableOptimisticToolbar, }: MentionButtonProps) => React.JSX.Element | null;
8
9
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-insert-block",
3
- "version": "31.0.15",
3
+ "version": "31.1.0",
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": "^32.0.0",
36
36
  "@atlaskit/editor-plugin-image-upload": "^30.0.0",
37
37
  "@atlaskit/editor-plugin-layout": "^31.0.0",
38
- "@atlaskit/editor-plugin-media": "^32.2.0",
38
+ "@atlaskit/editor-plugin-media": "^32.3.0",
39
39
  "@atlaskit/editor-plugin-media-insert": "^48.0.0",
40
- "@atlaskit/editor-plugin-mentions": "^32.1.0",
40
+ "@atlaskit/editor-plugin-mentions": "^32.2.0",
41
41
  "@atlaskit/editor-plugin-metrics": "^31.0.0",
42
42
  "@atlaskit/editor-plugin-panel": "^32.0.0",
43
43
  "@atlaskit/editor-plugin-placeholder-text": "^31.0.0",
@@ -60,10 +60,10 @@
60
60
  "@atlaskit/icon-lab": "^7.11.0",
61
61
  "@atlaskit/platform-feature-experiments": "^0.3.0",
62
62
  "@atlaskit/platform-feature-flags": "^2.2.0",
63
- "@atlaskit/primitives": "^22.6.0",
63
+ "@atlaskit/primitives": "^22.7.0",
64
64
  "@atlaskit/textfield": "^10.3.0",
65
- "@atlaskit/tmp-editor-statsig": "^259.0.0",
66
- "@atlaskit/tokens": "^20.9.0",
65
+ "@atlaskit/tmp-editor-statsig": "^260.0.0",
66
+ "@atlaskit/tokens": "^20.10.0",
67
67
  "@babel/runtime": "^7.0.0",
68
68
  "@emotion/react": "^11.7.1",
69
69
  "bind-event-listener": "^3.0.0",