@atlaskit/editor-plugin-block-type 5.1.13 → 5.1.14

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,14 @@
1
1
  # @atlaskit/editor-plugin-block-type
2
2
 
3
+ ## 5.1.14
4
+
5
+ ### Patch Changes
6
+
7
+ - [#144898](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/144898)
8
+ [`b9a10d6716ef4`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b9a10d6716ef4) -
9
+ Enable useSharedPluginStateSelector in block-controls, block-type and breakout plugins
10
+ - Updated dependencies
11
+
3
12
  ## 5.1.13
4
13
 
5
14
  ### Patch Changes
@@ -9,6 +9,7 @@ exports.FloatingToolbarComponent = FloatingToolbarComponent;
9
9
  var _react = _interopRequireWildcard(require("react"));
10
10
  var _analytics = require("@atlaskit/editor-common/analytics");
11
11
  var _hooks = require("@atlaskit/editor-common/hooks");
12
+ var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
12
13
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
13
14
  var _ToolbarBlockType = _interopRequireDefault(require("./ToolbarBlockType"));
14
15
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
@@ -21,8 +22,40 @@ var FloatingToolbarSettings = {
21
22
  };
22
23
  function FloatingToolbarComponent(_ref) {
23
24
  var api = _ref.api;
24
- var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['blockType']),
25
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['blockType'], {
26
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true)
27
+ }),
25
28
  blockTypeState = _useSharedPluginState.blockTypeState;
29
+
30
+ // currentBlockType
31
+ var currentBlockTypeSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockType.currentBlockType', {
32
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
33
+ });
34
+ var currentBlockType = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? currentBlockTypeSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.currentBlockType;
35
+
36
+ // blockTypesDisabled
37
+ var blockTypesDisabledSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockType.blockTypesDisabled', {
38
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
39
+ });
40
+ var blockTypesDisabled = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? blockTypesDisabledSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.blockTypesDisabled;
41
+
42
+ // availableBlockTypes
43
+ var availableBlockTypesSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockType.availableBlockTypes', {
44
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
45
+ });
46
+ var availableBlockTypes = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? availableBlockTypesSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.availableBlockTypes;
47
+
48
+ // availableBlockTypesInDropdown
49
+ var availableBlockTypesInDropdownSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockType.availableBlockTypesInDropdown', {
50
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
51
+ });
52
+ var availableBlockTypesInDropdown = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? availableBlockTypesInDropdownSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.availableBlockTypesInDropdown;
53
+
54
+ // formattingIsPresent
55
+ var formattingIsPresentSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockType.formattingIsPresent', {
56
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
57
+ });
58
+ var formattingIsPresent = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? formattingIsPresentSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.formattingIsPresent;
26
59
  var boundSetBlockType = (0, _react.useCallback)(function (name) {
27
60
  var _api$core, _api$blockType;
28
61
  return api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(api === null || api === void 0 || (_api$blockType = api.blockType) === null || _api$blockType === void 0 || (_api$blockType = _api$blockType.commands) === null || _api$blockType === void 0 ? void 0 : _api$blockType.setTextLevel(name, _analytics.INPUT_METHOD.FLOATING_TB));
@@ -39,11 +72,12 @@ function FloatingToolbarComponent(_ref) {
39
72
  isSmall: FloatingToolbarSettings.isSmall,
40
73
  isDisabled: FloatingToolbarSettings.disabled,
41
74
  isReducedSpacing: (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? false : FloatingToolbarSettings.isToolbarReducedSpacing,
42
- setTextLevel: boundSetBlockType
43
- // Ignored via go/ees005
44
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
45
- ,
46
- pluginState: blockTypeState,
75
+ setTextLevel: boundSetBlockType,
76
+ currentBlockType: currentBlockType,
77
+ blockTypesDisabled: blockTypesDisabled,
78
+ availableBlockTypes: availableBlockTypes,
79
+ availableBlockTypesInDropdown: availableBlockTypesInDropdown,
80
+ formattingIsPresent: formattingIsPresent,
47
81
  wrapBlockQuote: wrapBlockQuote,
48
82
  clearFormatting: clearFormatting,
49
83
  shouldUseDefaultRole: FloatingToolbarSettings.shouldUseDefaultRole,
@@ -8,6 +8,8 @@ exports.PrimaryToolbarComponent = PrimaryToolbarComponent;
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _analytics = require("@atlaskit/editor-common/analytics");
10
10
  var _hooks = require("@atlaskit/editor-common/hooks");
11
+ var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
12
+ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
11
13
  var _ToolbarBlockType = _interopRequireDefault(require("./ToolbarBlockType"));
12
14
  function PrimaryToolbarComponent(_ref) {
13
15
  var api = _ref.api,
@@ -18,8 +20,40 @@ function PrimaryToolbarComponent(_ref) {
18
20
  popupsBoundariesElement = _ref.popupsBoundariesElement,
19
21
  popupsScrollableElement = _ref.popupsScrollableElement,
20
22
  shouldUseDefaultRole = _ref.shouldUseDefaultRole;
21
- var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['blockType']),
23
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['blockType'], {
24
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true)
25
+ }),
22
26
  blockTypeState = _useSharedPluginState.blockTypeState;
27
+
28
+ // currentBlockType
29
+ var currentBlockTypeSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockType.currentBlockType', {
30
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
31
+ });
32
+ var currentBlockType = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? currentBlockTypeSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.currentBlockType;
33
+
34
+ // blockTypesDisabled
35
+ var blockTypesDisabledSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockType.blockTypesDisabled', {
36
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
37
+ });
38
+ var blockTypesDisabled = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? blockTypesDisabledSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.blockTypesDisabled;
39
+
40
+ // availableBlockTypes
41
+ var availableBlockTypesSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockType.availableBlockTypes', {
42
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
43
+ });
44
+ var availableBlockTypes = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? availableBlockTypesSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.availableBlockTypes;
45
+
46
+ // availableBlockTypesInDropdown
47
+ var availableBlockTypesInDropdownSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockType.availableBlockTypesInDropdown', {
48
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
49
+ });
50
+ var availableBlockTypesInDropdown = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? availableBlockTypesInDropdownSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.availableBlockTypesInDropdown;
51
+
52
+ // formattingIsPresent
53
+ var formattingIsPresentSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockType.formattingIsPresent', {
54
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
55
+ });
56
+ var formattingIsPresent = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? formattingIsPresentSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.formattingIsPresent;
23
57
  var boundSetBlockType = function boundSetBlockType(name, fromBlockQuote) {
24
58
  var _api$core, _api$blockType;
25
59
  return api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(api === null || api === void 0 || (_api$blockType = api.blockType) === null || _api$blockType === void 0 || (_api$blockType = _api$blockType.commands) === null || _api$blockType === void 0 ? void 0 : _api$blockType.setTextLevel(name, _analytics.INPUT_METHOD.TOOLBAR, fromBlockQuote));
@@ -38,11 +72,12 @@ function PrimaryToolbarComponent(_ref) {
38
72
  isReducedSpacing: isToolbarReducedSpacing,
39
73
  setTextLevel: boundSetBlockType,
40
74
  wrapBlockQuote: wrapBlockQuote,
41
- clearFormatting: clearFormatting
42
- // Ignored via go/ees005
43
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
44
- ,
45
- pluginState: blockTypeState,
75
+ clearFormatting: clearFormatting,
76
+ currentBlockType: currentBlockType,
77
+ blockTypesDisabled: blockTypesDisabled,
78
+ availableBlockTypes: availableBlockTypes,
79
+ availableBlockTypesInDropdown: availableBlockTypesInDropdown,
80
+ formattingIsPresent: formattingIsPresent,
46
81
  popupsMountPoint: popupsMountPoint,
47
82
  popupsBoundariesElement: popupsBoundariesElement,
48
83
  popupsScrollableElement: popupsScrollableElement,
@@ -76,12 +76,12 @@ var ToolbarBlockType = /*#__PURE__*/function (_React$PureComponent) {
76
76
  }
77
77
  });
78
78
  (0, _defineProperty2.default)(_this, "createItems", function () {
79
- var formatMessage = _this.props.intl.formatMessage;
80
- var _this$props$pluginSta = _this.props.pluginState,
81
- currentBlockType = _this$props$pluginSta.currentBlockType,
82
- availableBlockTypesInDropdown = _this$props$pluginSta.availableBlockTypesInDropdown,
83
- formattingIsPresent = _this$props$pluginSta.formattingIsPresent;
84
- var items = availableBlockTypesInDropdown.map(function (blockType, index) {
79
+ var _this$props = _this.props,
80
+ formatMessage = _this$props.intl.formatMessage,
81
+ currentBlockType = _this$props.currentBlockType,
82
+ availableBlockTypesInDropdown = _this$props.availableBlockTypesInDropdown,
83
+ formattingIsPresent = _this$props.formattingIsPresent;
84
+ var items = (availableBlockTypesInDropdown !== null && availableBlockTypesInDropdown !== void 0 ? availableBlockTypesInDropdown : []).map(function (blockType, index) {
85
85
  var isActive = currentBlockType === blockType;
86
86
  var tagName = blockType.tagName || 'p';
87
87
  var Tag = tagName;
@@ -106,7 +106,7 @@ var ToolbarBlockType = /*#__PURE__*/function (_React$PureComponent) {
106
106
  };
107
107
  return item;
108
108
  });
109
- if (availableBlockTypesInDropdown.map(function (blockType) {
109
+ if ((availableBlockTypesInDropdown !== null && availableBlockTypesInDropdown !== void 0 ? availableBlockTypesInDropdown : []).map(function (blockType) {
110
110
  return blockType.name;
111
111
  }).includes('blockquote') && (0, _experiments.editorExperiment)('platform_editor_controls', 'control')) {
112
112
  var clearFormattingItem = {
@@ -145,7 +145,8 @@ var ToolbarBlockType = /*#__PURE__*/function (_React$PureComponent) {
145
145
  if (blockType.name === 'clearFormatting') {
146
146
  _this.props.clearFormatting();
147
147
  } else {
148
- var fromBlockQuote = _this.props.pluginState.currentBlockType.name === 'blockquote';
148
+ var _this$props$currentBl;
149
+ var fromBlockQuote = ((_this$props$currentBl = _this.props.currentBlockType) === null || _this$props$currentBl === void 0 ? void 0 : _this$props$currentBl.name) === 'blockquote';
149
150
  _this.props.setTextLevel(blockType.name, fromBlockQuote);
150
151
  }
151
152
  }
@@ -188,20 +189,21 @@ var ToolbarBlockType = /*#__PURE__*/function (_React$PureComponent) {
188
189
  var _this$state = this.state,
189
190
  active = _this$state.active,
190
191
  isOpenedByKeyboard = _this$state.isOpenedByKeyboard;
191
- var _this$props = this.props,
192
- popupsMountPoint = _this$props.popupsMountPoint,
193
- popupsBoundariesElement = _this$props.popupsBoundariesElement,
194
- popupsScrollableElement = _this$props.popupsScrollableElement,
195
- isSmall = _this$props.isSmall,
196
- isReducedSpacing = _this$props.isReducedSpacing,
197
- _this$props$pluginSta2 = _this$props.pluginState,
198
- currentBlockType = _this$props$pluginSta2.currentBlockType,
199
- blockTypesDisabled = _this$props$pluginSta2.blockTypesDisabled,
200
- availableBlockTypes = _this$props$pluginSta2.availableBlockTypes,
201
- availableBlockTypesInDropdown = _this$props$pluginSta2.availableBlockTypesInDropdown,
202
- shouldUseDefaultRole = _this$props.shouldUseDefaultRole,
203
- formatMessage = _this$props.intl.formatMessage,
204
- api = _this$props.api;
192
+ var _this$props2 = this.props,
193
+ popupsMountPoint = _this$props2.popupsMountPoint,
194
+ popupsBoundariesElement = _this$props2.popupsBoundariesElement,
195
+ popupsScrollableElement = _this$props2.popupsScrollableElement,
196
+ isSmall = _this$props2.isSmall,
197
+ isReducedSpacing = _this$props2.isReducedSpacing,
198
+ currentBlockType = _this$props2.currentBlockType,
199
+ blockTypesDisabled = _this$props2.blockTypesDisabled,
200
+ _this$props2$availabl = _this$props2.availableBlockTypes,
201
+ availableBlockTypes = _this$props2$availabl === void 0 ? [] : _this$props2$availabl,
202
+ _this$props2$availabl2 = _this$props2.availableBlockTypesInDropdown,
203
+ availableBlockTypesInDropdown = _this$props2$availabl2 === void 0 ? [] : _this$props2$availabl2,
204
+ shouldUseDefaultRole = _this$props2.shouldUseDefaultRole,
205
+ formatMessage = _this$props2.intl.formatMessage,
206
+ api = _this$props2.api;
205
207
  var isHeadingDisabled = !availableBlockTypes.some(function (blockType) {
206
208
  return blockType.nodeName === 'heading';
207
209
  });
@@ -209,7 +211,7 @@ var ToolbarBlockType = /*#__PURE__*/function (_React$PureComponent) {
209
211
  return null;
210
212
  }
211
213
  var blockTypeTitles = availableBlockTypesInDropdown.filter(function (blockType) {
212
- return blockType.name === currentBlockType.name;
214
+ return blockType.name === (currentBlockType === null || currentBlockType === void 0 ? void 0 : currentBlockType.name);
213
215
  }).map(function (blockType) {
214
216
  return blockType.title;
215
217
  });
@@ -229,7 +231,7 @@ var ToolbarBlockType = /*#__PURE__*/function (_React$PureComponent) {
229
231
  onKeyDown: this.handleTriggerByKeyboard,
230
232
  formatMessage: formatMessage,
231
233
  "aria-expanded": active,
232
- blockTypeName: currentBlockType.name,
234
+ blockTypeName: currentBlockType === null || currentBlockType === void 0 ? void 0 : currentBlockType.name,
233
235
  blockTypeIcon: currentIcon || defaultIcon
234
236
  });
235
237
  return (0, _react2.jsx)("span", {
@@ -287,7 +289,7 @@ var ToolbarBlockType = /*#__PURE__*/function (_React$PureComponent) {
287
289
  onKeyDown: this.handleTriggerByKeyboard,
288
290
  formatMessage: formatMessage,
289
291
  "aria-expanded": active,
290
- blockTypeName: currentBlockType.name
292
+ blockTypeName: currentBlockType === null || currentBlockType === void 0 ? void 0 : currentBlockType.name
291
293
  }), !(api !== null && api !== void 0 && api.primaryToolbar) && (0, _react2.jsx)("span", {
292
294
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
293
295
  css: _styles.separatorStyles
@@ -1,6 +1,7 @@
1
1
  import React, { useCallback } from 'react';
2
2
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
3
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
4
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
4
5
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
5
6
  import ToolbarBlockType from './ToolbarBlockType';
6
7
  const FloatingToolbarSettings = {
@@ -14,7 +15,39 @@ export function FloatingToolbarComponent({
14
15
  }) {
15
16
  const {
16
17
  blockTypeState
17
- } = useSharedPluginState(api, ['blockType']);
18
+ } = useSharedPluginState(api, ['blockType'], {
19
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
20
+ });
21
+
22
+ // currentBlockType
23
+ const currentBlockTypeSelector = useSharedPluginStateSelector(api, 'blockType.currentBlockType', {
24
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
25
+ });
26
+ const currentBlockType = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? currentBlockTypeSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.currentBlockType;
27
+
28
+ // blockTypesDisabled
29
+ const blockTypesDisabledSelector = useSharedPluginStateSelector(api, 'blockType.blockTypesDisabled', {
30
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
31
+ });
32
+ const blockTypesDisabled = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? blockTypesDisabledSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.blockTypesDisabled;
33
+
34
+ // availableBlockTypes
35
+ const availableBlockTypesSelector = useSharedPluginStateSelector(api, 'blockType.availableBlockTypes', {
36
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
37
+ });
38
+ const availableBlockTypes = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? availableBlockTypesSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.availableBlockTypes;
39
+
40
+ // availableBlockTypesInDropdown
41
+ const availableBlockTypesInDropdownSelector = useSharedPluginStateSelector(api, 'blockType.availableBlockTypesInDropdown', {
42
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
43
+ });
44
+ const availableBlockTypesInDropdown = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? availableBlockTypesInDropdownSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.availableBlockTypesInDropdown;
45
+
46
+ // formattingIsPresent
47
+ const formattingIsPresentSelector = useSharedPluginStateSelector(api, 'blockType.formattingIsPresent', {
48
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
49
+ });
50
+ const formattingIsPresent = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? formattingIsPresentSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.formattingIsPresent;
18
51
  const boundSetBlockType = useCallback(name => {
19
52
  var _api$core, _api$blockType, _api$blockType$comman;
20
53
  return api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(api === null || api === void 0 ? void 0 : (_api$blockType = api.blockType) === null || _api$blockType === void 0 ? void 0 : (_api$blockType$comman = _api$blockType.commands) === null || _api$blockType$comman === void 0 ? void 0 : _api$blockType$comman.setTextLevel(name, INPUT_METHOD.FLOATING_TB));
@@ -31,11 +64,12 @@ export function FloatingToolbarComponent({
31
64
  isSmall: FloatingToolbarSettings.isSmall,
32
65
  isDisabled: FloatingToolbarSettings.disabled,
33
66
  isReducedSpacing: editorExperiment('platform_editor_controls', 'variant1') ? false : FloatingToolbarSettings.isToolbarReducedSpacing,
34
- setTextLevel: boundSetBlockType
35
- // Ignored via go/ees005
36
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
37
- ,
38
- pluginState: blockTypeState,
67
+ setTextLevel: boundSetBlockType,
68
+ currentBlockType: currentBlockType,
69
+ blockTypesDisabled: blockTypesDisabled,
70
+ availableBlockTypes: availableBlockTypes,
71
+ availableBlockTypesInDropdown: availableBlockTypesInDropdown,
72
+ formattingIsPresent: formattingIsPresent,
39
73
  wrapBlockQuote: wrapBlockQuote,
40
74
  clearFormatting: clearFormatting,
41
75
  shouldUseDefaultRole: FloatingToolbarSettings.shouldUseDefaultRole,
@@ -1,6 +1,8 @@
1
1
  import React from 'react';
2
2
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
3
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
4
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
5
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
4
6
  import ToolbarBlockType from './ToolbarBlockType';
5
7
  export function PrimaryToolbarComponent({
6
8
  api,
@@ -14,7 +16,39 @@ export function PrimaryToolbarComponent({
14
16
  }) {
15
17
  const {
16
18
  blockTypeState
17
- } = useSharedPluginState(api, ['blockType']);
19
+ } = useSharedPluginState(api, ['blockType'], {
20
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
21
+ });
22
+
23
+ // currentBlockType
24
+ const currentBlockTypeSelector = useSharedPluginStateSelector(api, 'blockType.currentBlockType', {
25
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
26
+ });
27
+ const currentBlockType = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? currentBlockTypeSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.currentBlockType;
28
+
29
+ // blockTypesDisabled
30
+ const blockTypesDisabledSelector = useSharedPluginStateSelector(api, 'blockType.blockTypesDisabled', {
31
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
32
+ });
33
+ const blockTypesDisabled = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? blockTypesDisabledSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.blockTypesDisabled;
34
+
35
+ // availableBlockTypes
36
+ const availableBlockTypesSelector = useSharedPluginStateSelector(api, 'blockType.availableBlockTypes', {
37
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
38
+ });
39
+ const availableBlockTypes = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? availableBlockTypesSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.availableBlockTypes;
40
+
41
+ // availableBlockTypesInDropdown
42
+ const availableBlockTypesInDropdownSelector = useSharedPluginStateSelector(api, 'blockType.availableBlockTypesInDropdown', {
43
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
44
+ });
45
+ const availableBlockTypesInDropdown = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? availableBlockTypesInDropdownSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.availableBlockTypesInDropdown;
46
+
47
+ // formattingIsPresent
48
+ const formattingIsPresentSelector = useSharedPluginStateSelector(api, 'blockType.formattingIsPresent', {
49
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
50
+ });
51
+ const formattingIsPresent = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? formattingIsPresentSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.formattingIsPresent;
18
52
  const boundSetBlockType = (name, fromBlockQuote) => {
19
53
  var _api$core, _api$blockType, _api$blockType$comman;
20
54
  return api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(api === null || api === void 0 ? void 0 : (_api$blockType = api.blockType) === null || _api$blockType === void 0 ? void 0 : (_api$blockType$comman = _api$blockType.commands) === null || _api$blockType$comman === void 0 ? void 0 : _api$blockType$comman.setTextLevel(name, INPUT_METHOD.TOOLBAR, fromBlockQuote));
@@ -33,11 +67,12 @@ export function PrimaryToolbarComponent({
33
67
  isReducedSpacing: isToolbarReducedSpacing,
34
68
  setTextLevel: boundSetBlockType,
35
69
  wrapBlockQuote: wrapBlockQuote,
36
- clearFormatting: clearFormatting
37
- // Ignored via go/ees005
38
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
39
- ,
40
- pluginState: blockTypeState,
70
+ clearFormatting: clearFormatting,
71
+ currentBlockType: currentBlockType,
72
+ blockTypesDisabled: blockTypesDisabled,
73
+ availableBlockTypes: availableBlockTypes,
74
+ availableBlockTypesInDropdown: availableBlockTypesInDropdown,
75
+ formattingIsPresent: formattingIsPresent,
41
76
  popupsMountPoint: popupsMountPoint,
42
77
  popupsBoundariesElement: popupsBoundariesElement,
43
78
  popupsScrollableElement: popupsScrollableElement,
@@ -62,14 +62,12 @@ class ToolbarBlockType extends React.PureComponent {
62
62
  const {
63
63
  intl: {
64
64
  formatMessage
65
- }
66
- } = this.props;
67
- const {
65
+ },
68
66
  currentBlockType,
69
67
  availableBlockTypesInDropdown,
70
68
  formattingIsPresent
71
- } = this.props.pluginState;
72
- const items = availableBlockTypesInDropdown.map((blockType, index) => {
69
+ } = this.props;
70
+ const items = (availableBlockTypesInDropdown !== null && availableBlockTypesInDropdown !== void 0 ? availableBlockTypesInDropdown : []).map((blockType, index) => {
73
71
  const isActive = currentBlockType === blockType;
74
72
  const tagName = blockType.tagName || 'p';
75
73
  const Tag = tagName;
@@ -94,7 +92,7 @@ class ToolbarBlockType extends React.PureComponent {
94
92
  };
95
93
  return item;
96
94
  });
97
- if (availableBlockTypesInDropdown.map(blockType => blockType.name).includes('blockquote') && editorExperiment('platform_editor_controls', 'control')) {
95
+ if ((availableBlockTypesInDropdown !== null && availableBlockTypesInDropdown !== void 0 ? availableBlockTypesInDropdown : []).map(blockType => blockType.name).includes('blockquote') && editorExperiment('platform_editor_controls', 'control')) {
98
96
  const clearFormattingItem = {
99
97
  content: jsx("div", null, jsx("p", null, toolbarMessages.clearFormatting.defaultMessage)),
100
98
  value: {
@@ -131,7 +129,8 @@ class ToolbarBlockType extends React.PureComponent {
131
129
  if (blockType.name === 'clearFormatting') {
132
130
  this.props.clearFormatting();
133
131
  } else {
134
- const fromBlockQuote = this.props.pluginState.currentBlockType.name === 'blockquote';
132
+ var _this$props$currentBl;
133
+ const fromBlockQuote = ((_this$props$currentBl = this.props.currentBlockType) === null || _this$props$currentBl === void 0 ? void 0 : _this$props$currentBl.name) === 'blockquote';
135
134
  this.props.setTextLevel(blockType.name, fromBlockQuote);
136
135
  }
137
136
  }
@@ -173,12 +172,10 @@ class ToolbarBlockType extends React.PureComponent {
173
172
  popupsScrollableElement,
174
173
  isSmall,
175
174
  isReducedSpacing,
176
- pluginState: {
177
- currentBlockType,
178
- blockTypesDisabled,
179
- availableBlockTypes,
180
- availableBlockTypesInDropdown
181
- },
175
+ currentBlockType,
176
+ blockTypesDisabled,
177
+ availableBlockTypes = [],
178
+ availableBlockTypesInDropdown = [],
182
179
  shouldUseDefaultRole,
183
180
  intl: {
184
181
  formatMessage
@@ -189,7 +186,7 @@ class ToolbarBlockType extends React.PureComponent {
189
186
  if (isHeadingDisabled) {
190
187
  return null;
191
188
  }
192
- const blockTypeTitles = availableBlockTypesInDropdown.filter(blockType => blockType.name === currentBlockType.name).map(blockType => blockType.title);
189
+ const blockTypeTitles = availableBlockTypesInDropdown.filter(blockType => blockType.name === (currentBlockType === null || currentBlockType === void 0 ? void 0 : currentBlockType.name)).map(blockType => blockType.title);
193
190
  const defaultIcon = fg('platform_editor_controls_patch_4') ? jsx(TextIcon, {
194
191
  label: ""
195
192
  }) : jsx(Text, null);
@@ -206,7 +203,7 @@ class ToolbarBlockType extends React.PureComponent {
206
203
  onKeyDown: this.handleTriggerByKeyboard,
207
204
  formatMessage: formatMessage,
208
205
  "aria-expanded": active,
209
- blockTypeName: currentBlockType.name,
206
+ blockTypeName: currentBlockType === null || currentBlockType === void 0 ? void 0 : currentBlockType.name,
210
207
  blockTypeIcon: currentIcon || defaultIcon
211
208
  });
212
209
  return jsx("span", {
@@ -265,7 +262,7 @@ class ToolbarBlockType extends React.PureComponent {
265
262
  onKeyDown: this.handleTriggerByKeyboard,
266
263
  formatMessage: formatMessage,
267
264
  "aria-expanded": active,
268
- blockTypeName: currentBlockType.name
265
+ blockTypeName: currentBlockType === null || currentBlockType === void 0 ? void 0 : currentBlockType.name
269
266
  }), !(api !== null && api !== void 0 && api.primaryToolbar) && jsx("span", {
270
267
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
271
268
  css: separatorStyles
@@ -1,6 +1,7 @@
1
1
  import React, { useCallback } from 'react';
2
2
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
3
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
4
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
4
5
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
5
6
  import ToolbarBlockType from './ToolbarBlockType';
6
7
  var FloatingToolbarSettings = {
@@ -11,8 +12,40 @@ var FloatingToolbarSettings = {
11
12
  };
12
13
  export function FloatingToolbarComponent(_ref) {
13
14
  var api = _ref.api;
14
- var _useSharedPluginState = useSharedPluginState(api, ['blockType']),
15
+ var _useSharedPluginState = useSharedPluginState(api, ['blockType'], {
16
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
17
+ }),
15
18
  blockTypeState = _useSharedPluginState.blockTypeState;
19
+
20
+ // currentBlockType
21
+ var currentBlockTypeSelector = useSharedPluginStateSelector(api, 'blockType.currentBlockType', {
22
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
23
+ });
24
+ var currentBlockType = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? currentBlockTypeSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.currentBlockType;
25
+
26
+ // blockTypesDisabled
27
+ var blockTypesDisabledSelector = useSharedPluginStateSelector(api, 'blockType.blockTypesDisabled', {
28
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
29
+ });
30
+ var blockTypesDisabled = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? blockTypesDisabledSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.blockTypesDisabled;
31
+
32
+ // availableBlockTypes
33
+ var availableBlockTypesSelector = useSharedPluginStateSelector(api, 'blockType.availableBlockTypes', {
34
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
35
+ });
36
+ var availableBlockTypes = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? availableBlockTypesSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.availableBlockTypes;
37
+
38
+ // availableBlockTypesInDropdown
39
+ var availableBlockTypesInDropdownSelector = useSharedPluginStateSelector(api, 'blockType.availableBlockTypesInDropdown', {
40
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
41
+ });
42
+ var availableBlockTypesInDropdown = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? availableBlockTypesInDropdownSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.availableBlockTypesInDropdown;
43
+
44
+ // formattingIsPresent
45
+ var formattingIsPresentSelector = useSharedPluginStateSelector(api, 'blockType.formattingIsPresent', {
46
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
47
+ });
48
+ var formattingIsPresent = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? formattingIsPresentSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.formattingIsPresent;
16
49
  var boundSetBlockType = useCallback(function (name) {
17
50
  var _api$core, _api$blockType;
18
51
  return api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(api === null || api === void 0 || (_api$blockType = api.blockType) === null || _api$blockType === void 0 || (_api$blockType = _api$blockType.commands) === null || _api$blockType === void 0 ? void 0 : _api$blockType.setTextLevel(name, INPUT_METHOD.FLOATING_TB));
@@ -29,11 +62,12 @@ export function FloatingToolbarComponent(_ref) {
29
62
  isSmall: FloatingToolbarSettings.isSmall,
30
63
  isDisabled: FloatingToolbarSettings.disabled,
31
64
  isReducedSpacing: editorExperiment('platform_editor_controls', 'variant1') ? false : FloatingToolbarSettings.isToolbarReducedSpacing,
32
- setTextLevel: boundSetBlockType
33
- // Ignored via go/ees005
34
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
35
- ,
36
- pluginState: blockTypeState,
65
+ setTextLevel: boundSetBlockType,
66
+ currentBlockType: currentBlockType,
67
+ blockTypesDisabled: blockTypesDisabled,
68
+ availableBlockTypes: availableBlockTypes,
69
+ availableBlockTypesInDropdown: availableBlockTypesInDropdown,
70
+ formattingIsPresent: formattingIsPresent,
37
71
  wrapBlockQuote: wrapBlockQuote,
38
72
  clearFormatting: clearFormatting,
39
73
  shouldUseDefaultRole: FloatingToolbarSettings.shouldUseDefaultRole,
@@ -1,6 +1,8 @@
1
1
  import React from 'react';
2
2
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
3
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
4
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
5
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
4
6
  import ToolbarBlockType from './ToolbarBlockType';
5
7
  export function PrimaryToolbarComponent(_ref) {
6
8
  var api = _ref.api,
@@ -11,8 +13,40 @@ export function PrimaryToolbarComponent(_ref) {
11
13
  popupsBoundariesElement = _ref.popupsBoundariesElement,
12
14
  popupsScrollableElement = _ref.popupsScrollableElement,
13
15
  shouldUseDefaultRole = _ref.shouldUseDefaultRole;
14
- var _useSharedPluginState = useSharedPluginState(api, ['blockType']),
16
+ var _useSharedPluginState = useSharedPluginState(api, ['blockType'], {
17
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
18
+ }),
15
19
  blockTypeState = _useSharedPluginState.blockTypeState;
20
+
21
+ // currentBlockType
22
+ var currentBlockTypeSelector = useSharedPluginStateSelector(api, 'blockType.currentBlockType', {
23
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
24
+ });
25
+ var currentBlockType = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? currentBlockTypeSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.currentBlockType;
26
+
27
+ // blockTypesDisabled
28
+ var blockTypesDisabledSelector = useSharedPluginStateSelector(api, 'blockType.blockTypesDisabled', {
29
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
30
+ });
31
+ var blockTypesDisabled = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? blockTypesDisabledSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.blockTypesDisabled;
32
+
33
+ // availableBlockTypes
34
+ var availableBlockTypesSelector = useSharedPluginStateSelector(api, 'blockType.availableBlockTypes', {
35
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
36
+ });
37
+ var availableBlockTypes = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? availableBlockTypesSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.availableBlockTypes;
38
+
39
+ // availableBlockTypesInDropdown
40
+ var availableBlockTypesInDropdownSelector = useSharedPluginStateSelector(api, 'blockType.availableBlockTypesInDropdown', {
41
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
42
+ });
43
+ var availableBlockTypesInDropdown = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? availableBlockTypesInDropdownSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.availableBlockTypesInDropdown;
44
+
45
+ // formattingIsPresent
46
+ var formattingIsPresentSelector = useSharedPluginStateSelector(api, 'blockType.formattingIsPresent', {
47
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
48
+ });
49
+ var formattingIsPresent = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? formattingIsPresentSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.formattingIsPresent;
16
50
  var boundSetBlockType = function boundSetBlockType(name, fromBlockQuote) {
17
51
  var _api$core, _api$blockType;
18
52
  return api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(api === null || api === void 0 || (_api$blockType = api.blockType) === null || _api$blockType === void 0 || (_api$blockType = _api$blockType.commands) === null || _api$blockType === void 0 ? void 0 : _api$blockType.setTextLevel(name, INPUT_METHOD.TOOLBAR, fromBlockQuote));
@@ -31,11 +65,12 @@ export function PrimaryToolbarComponent(_ref) {
31
65
  isReducedSpacing: isToolbarReducedSpacing,
32
66
  setTextLevel: boundSetBlockType,
33
67
  wrapBlockQuote: wrapBlockQuote,
34
- clearFormatting: clearFormatting
35
- // Ignored via go/ees005
36
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
37
- ,
38
- pluginState: blockTypeState,
68
+ clearFormatting: clearFormatting,
69
+ currentBlockType: currentBlockType,
70
+ blockTypesDisabled: blockTypesDisabled,
71
+ availableBlockTypes: availableBlockTypes,
72
+ availableBlockTypesInDropdown: availableBlockTypesInDropdown,
73
+ formattingIsPresent: formattingIsPresent,
39
74
  popupsMountPoint: popupsMountPoint,
40
75
  popupsBoundariesElement: popupsBoundariesElement,
41
76
  popupsScrollableElement: popupsScrollableElement,
@@ -72,12 +72,12 @@ var ToolbarBlockType = /*#__PURE__*/function (_React$PureComponent) {
72
72
  }
73
73
  });
74
74
  _defineProperty(_this, "createItems", function () {
75
- var formatMessage = _this.props.intl.formatMessage;
76
- var _this$props$pluginSta = _this.props.pluginState,
77
- currentBlockType = _this$props$pluginSta.currentBlockType,
78
- availableBlockTypesInDropdown = _this$props$pluginSta.availableBlockTypesInDropdown,
79
- formattingIsPresent = _this$props$pluginSta.formattingIsPresent;
80
- var items = availableBlockTypesInDropdown.map(function (blockType, index) {
75
+ var _this$props = _this.props,
76
+ formatMessage = _this$props.intl.formatMessage,
77
+ currentBlockType = _this$props.currentBlockType,
78
+ availableBlockTypesInDropdown = _this$props.availableBlockTypesInDropdown,
79
+ formattingIsPresent = _this$props.formattingIsPresent;
80
+ var items = (availableBlockTypesInDropdown !== null && availableBlockTypesInDropdown !== void 0 ? availableBlockTypesInDropdown : []).map(function (blockType, index) {
81
81
  var isActive = currentBlockType === blockType;
82
82
  var tagName = blockType.tagName || 'p';
83
83
  var Tag = tagName;
@@ -102,7 +102,7 @@ var ToolbarBlockType = /*#__PURE__*/function (_React$PureComponent) {
102
102
  };
103
103
  return item;
104
104
  });
105
- if (availableBlockTypesInDropdown.map(function (blockType) {
105
+ if ((availableBlockTypesInDropdown !== null && availableBlockTypesInDropdown !== void 0 ? availableBlockTypesInDropdown : []).map(function (blockType) {
106
106
  return blockType.name;
107
107
  }).includes('blockquote') && editorExperiment('platform_editor_controls', 'control')) {
108
108
  var clearFormattingItem = {
@@ -141,7 +141,8 @@ var ToolbarBlockType = /*#__PURE__*/function (_React$PureComponent) {
141
141
  if (blockType.name === 'clearFormatting') {
142
142
  _this.props.clearFormatting();
143
143
  } else {
144
- var fromBlockQuote = _this.props.pluginState.currentBlockType.name === 'blockquote';
144
+ var _this$props$currentBl;
145
+ var fromBlockQuote = ((_this$props$currentBl = _this.props.currentBlockType) === null || _this$props$currentBl === void 0 ? void 0 : _this$props$currentBl.name) === 'blockquote';
145
146
  _this.props.setTextLevel(blockType.name, fromBlockQuote);
146
147
  }
147
148
  }
@@ -184,20 +185,21 @@ var ToolbarBlockType = /*#__PURE__*/function (_React$PureComponent) {
184
185
  var _this$state = this.state,
185
186
  active = _this$state.active,
186
187
  isOpenedByKeyboard = _this$state.isOpenedByKeyboard;
187
- var _this$props = this.props,
188
- popupsMountPoint = _this$props.popupsMountPoint,
189
- popupsBoundariesElement = _this$props.popupsBoundariesElement,
190
- popupsScrollableElement = _this$props.popupsScrollableElement,
191
- isSmall = _this$props.isSmall,
192
- isReducedSpacing = _this$props.isReducedSpacing,
193
- _this$props$pluginSta2 = _this$props.pluginState,
194
- currentBlockType = _this$props$pluginSta2.currentBlockType,
195
- blockTypesDisabled = _this$props$pluginSta2.blockTypesDisabled,
196
- availableBlockTypes = _this$props$pluginSta2.availableBlockTypes,
197
- availableBlockTypesInDropdown = _this$props$pluginSta2.availableBlockTypesInDropdown,
198
- shouldUseDefaultRole = _this$props.shouldUseDefaultRole,
199
- formatMessage = _this$props.intl.formatMessage,
200
- api = _this$props.api;
188
+ var _this$props2 = this.props,
189
+ popupsMountPoint = _this$props2.popupsMountPoint,
190
+ popupsBoundariesElement = _this$props2.popupsBoundariesElement,
191
+ popupsScrollableElement = _this$props2.popupsScrollableElement,
192
+ isSmall = _this$props2.isSmall,
193
+ isReducedSpacing = _this$props2.isReducedSpacing,
194
+ currentBlockType = _this$props2.currentBlockType,
195
+ blockTypesDisabled = _this$props2.blockTypesDisabled,
196
+ _this$props2$availabl = _this$props2.availableBlockTypes,
197
+ availableBlockTypes = _this$props2$availabl === void 0 ? [] : _this$props2$availabl,
198
+ _this$props2$availabl2 = _this$props2.availableBlockTypesInDropdown,
199
+ availableBlockTypesInDropdown = _this$props2$availabl2 === void 0 ? [] : _this$props2$availabl2,
200
+ shouldUseDefaultRole = _this$props2.shouldUseDefaultRole,
201
+ formatMessage = _this$props2.intl.formatMessage,
202
+ api = _this$props2.api;
201
203
  var isHeadingDisabled = !availableBlockTypes.some(function (blockType) {
202
204
  return blockType.nodeName === 'heading';
203
205
  });
@@ -205,7 +207,7 @@ var ToolbarBlockType = /*#__PURE__*/function (_React$PureComponent) {
205
207
  return null;
206
208
  }
207
209
  var blockTypeTitles = availableBlockTypesInDropdown.filter(function (blockType) {
208
- return blockType.name === currentBlockType.name;
210
+ return blockType.name === (currentBlockType === null || currentBlockType === void 0 ? void 0 : currentBlockType.name);
209
211
  }).map(function (blockType) {
210
212
  return blockType.title;
211
213
  });
@@ -225,7 +227,7 @@ var ToolbarBlockType = /*#__PURE__*/function (_React$PureComponent) {
225
227
  onKeyDown: this.handleTriggerByKeyboard,
226
228
  formatMessage: formatMessage,
227
229
  "aria-expanded": active,
228
- blockTypeName: currentBlockType.name,
230
+ blockTypeName: currentBlockType === null || currentBlockType === void 0 ? void 0 : currentBlockType.name,
229
231
  blockTypeIcon: currentIcon || defaultIcon
230
232
  });
231
233
  return jsx("span", {
@@ -283,7 +285,7 @@ var ToolbarBlockType = /*#__PURE__*/function (_React$PureComponent) {
283
285
  onKeyDown: this.handleTriggerByKeyboard,
284
286
  formatMessage: formatMessage,
285
287
  "aria-expanded": active,
286
- blockTypeName: currentBlockType.name
288
+ blockTypeName: currentBlockType === null || currentBlockType === void 0 ? void 0 : currentBlockType.name
287
289
  }), !(api !== null && api !== void 0 && api.primaryToolbar) && jsx("span", {
288
290
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
289
291
  css: separatorStyles
@@ -10,7 +10,6 @@ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
10
10
  import { ThemeMutationObserver } from '@atlaskit/tokens';
11
11
  import type { BlockTypePlugin } from '../../../blockTypePluginType';
12
12
  import type { TextBlockTypes } from '../../block-types';
13
- import type { BlockTypeState } from '../../main';
14
13
  import type { BlockType } from '../../types';
15
14
  export type DropdownItem = MenuItem & {
16
15
  value: BlockType;
@@ -19,7 +18,11 @@ export interface Props {
19
18
  isDisabled?: boolean;
20
19
  isSmall?: boolean;
21
20
  isReducedSpacing?: boolean;
22
- pluginState: BlockTypeState;
21
+ currentBlockType?: BlockType;
22
+ blockTypesDisabled?: boolean;
23
+ availableBlockTypes?: BlockType[];
24
+ availableBlockTypesInDropdown?: BlockType[];
25
+ formattingIsPresent?: boolean;
23
26
  popupsMountPoint?: HTMLElement;
24
27
  popupsBoundariesElement?: HTMLElement;
25
28
  popupsScrollableElement?: HTMLElement;
@@ -10,7 +10,6 @@ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
10
10
  import { ThemeMutationObserver } from '@atlaskit/tokens';
11
11
  import type { BlockTypePlugin } from '../../../blockTypePluginType';
12
12
  import type { TextBlockTypes } from '../../block-types';
13
- import type { BlockTypeState } from '../../main';
14
13
  import type { BlockType } from '../../types';
15
14
  export type DropdownItem = MenuItem & {
16
15
  value: BlockType;
@@ -19,7 +18,11 @@ export interface Props {
19
18
  isDisabled?: boolean;
20
19
  isSmall?: boolean;
21
20
  isReducedSpacing?: boolean;
22
- pluginState: BlockTypeState;
21
+ currentBlockType?: BlockType;
22
+ blockTypesDisabled?: boolean;
23
+ availableBlockTypes?: BlockType[];
24
+ availableBlockTypesInDropdown?: BlockType[];
25
+ formattingIsPresent?: boolean;
23
26
  popupsMountPoint?: HTMLElement;
24
27
  popupsBoundariesElement?: HTMLElement;
25
28
  popupsScrollableElement?: HTMLElement;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-type",
3
- "version": "5.1.13",
3
+ "version": "5.1.14",
4
4
  "description": "BlockType plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -36,21 +36,21 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@atlaskit/adf-schema": "^47.6.0",
39
- "@atlaskit/editor-common": "^103.6.0",
39
+ "@atlaskit/editor-common": "^103.16.0",
40
40
  "@atlaskit/editor-plugin-analytics": "^2.2.0",
41
41
  "@atlaskit/editor-plugin-primary-toolbar": "^3.2.0",
42
- "@atlaskit/editor-plugin-selection-toolbar": "^3.4.0",
42
+ "@atlaskit/editor-plugin-selection-toolbar": "^3.5.0",
43
43
  "@atlaskit/editor-prosemirror": "7.0.0",
44
44
  "@atlaskit/editor-shared-styles": "^3.4.0",
45
45
  "@atlaskit/editor-tables": "^2.9.0",
46
- "@atlaskit/icon": "^25.5.0",
47
- "@atlaskit/icon-lab": "^4.7.0",
46
+ "@atlaskit/icon": "^25.6.0",
47
+ "@atlaskit/icon-lab": "^4.9.0",
48
48
  "@atlaskit/platform-feature-flags": "^1.1.0",
49
49
  "@atlaskit/primitives": "^14.4.0",
50
50
  "@atlaskit/prosemirror-input-rules": "^3.3.0",
51
51
  "@atlaskit/theme": "^18.0.0",
52
- "@atlaskit/tmp-editor-statsig": "^4.6.0",
53
- "@atlaskit/tokens": "^4.7.0",
52
+ "@atlaskit/tmp-editor-statsig": "^4.14.0",
53
+ "@atlaskit/tokens": "^4.8.0",
54
54
  "@babel/runtime": "^7.0.0",
55
55
  "@emotion/react": "^11.7.1"
56
56
  },
@@ -62,8 +62,8 @@
62
62
  "devDependencies": {
63
63
  "@af/visual-regression": "^1.3.0",
64
64
  "@atlaskit/analytics-next": "^11.0.0",
65
- "@atlaskit/editor-plugin-quick-insert": "^2.3.0",
66
- "@atlaskit/editor-plugin-type-ahead": "^2.4.0",
65
+ "@atlaskit/editor-plugin-quick-insert": "^2.4.0",
66
+ "@atlaskit/editor-plugin-type-ahead": "^2.5.0",
67
67
  "@atlaskit/ssr": "^0.4.0",
68
68
  "@atlaskit/visual-regression": "^0.10.0",
69
69
  "@testing-library/react": "^13.4.0",