@atlaskit/editor-plugin-block-type 3.0.15 → 3.0.17

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,18 @@
1
1
  # @atlaskit/editor-plugin-block-type
2
2
 
3
+ ## 3.0.17
4
+
5
+ ### Patch Changes
6
+
7
+ - [#67557](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/67557) [`124d0c6d5286`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/124d0c6d5286) - Migrating block-type, text-color, and text-formatting to use useSharedPluginState rather than WithPluginState. Removing unused option on default preset. Adding formattingIsPresent prop to TextFormattingState.
8
+ - Updated dependencies
9
+
10
+ ## 3.0.16
11
+
12
+ ### Patch Changes
13
+
14
+ - [#67238](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/67238) [`40533849b2ec`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/40533849b2ec) - [ED-21835] Change EditorAPI type to always union with undefined
15
+
3
16
  ## 3.0.15
4
17
 
5
18
  ### Patch Changes
@@ -19,14 +19,13 @@ var _keymaps = require("@atlaskit/editor-common/keymaps");
19
19
  var _messages = require("@atlaskit/editor-common/messages");
20
20
  var _quickInsert = require("@atlaskit/editor-common/quick-insert");
21
21
  var _types = require("@atlaskit/editor-common/types");
22
- var _withPluginState = require("@atlaskit/editor-common/with-plugin-state");
23
22
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
24
23
  var _commands = require("./commands");
25
24
  var _blockType = require("./commands/block-type");
26
25
  var _inputRule = _interopRequireDefault(require("./pm-plugins/input-rule"));
27
26
  var _keymap = _interopRequireDefault(require("./pm-plugins/keymap"));
28
27
  var _main = require("./pm-plugins/main");
29
- var _ToolbarBlockType = _interopRequireDefault(require("./ui/ToolbarBlockType"));
28
+ var _PrimaryToolbarComponent = require("./ui/PrimaryToolbarComponent");
30
29
  var headingPluginOptions = function headingPluginOptions(_ref, isAllowed, editorAnalyticsApi) {
31
30
  var formatMessage = _ref.formatMessage;
32
31
  if (!isAllowed) {
@@ -174,45 +173,28 @@ var blockTypePlugin = exports.blockTypePlugin = function blockTypePlugin(_ref3)
174
173
  return _main.pluginKey.getState(editorState);
175
174
  },
176
175
  primaryToolbarComponent: function primaryToolbarComponent(_ref7) {
177
- var editorView = _ref7.editorView,
178
- popupsMountPoint = _ref7.popupsMountPoint,
176
+ var popupsMountPoint = _ref7.popupsMountPoint,
179
177
  popupsBoundariesElement = _ref7.popupsBoundariesElement,
180
178
  popupsScrollableElement = _ref7.popupsScrollableElement,
181
179
  toolbarSize = _ref7.toolbarSize,
182
180
  disabled = _ref7.disabled,
183
- isToolbarReducedSpacing = _ref7.isToolbarReducedSpacing,
184
- eventDispatcher = _ref7.eventDispatcher;
181
+ isToolbarReducedSpacing = _ref7.isToolbarReducedSpacing;
185
182
  var isSmall = options && options.isUndoRedoButtonsEnabled ? toolbarSize < _types.ToolbarSize.XXL : toolbarSize < _types.ToolbarSize.XL;
186
- var boundSetBlockType = function boundSetBlockType(name) {
187
- var _api$analytics5;
188
- api === null || api === void 0 || api.core.actions.execute((0, _commands.setBlockTypeWithAnalytics)(name, _analytics.INPUT_METHOD.TOOLBAR, api === null || api === void 0 || (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions));
189
- };
190
- return /*#__PURE__*/_react.default.createElement(_withPluginState.WithPluginState, {
191
- editorView: editorView,
192
- eventDispatcher: eventDispatcher,
193
- plugins: {
194
- pluginState: _main.pluginKey
195
- },
196
- render: function render(_ref8) {
197
- var pluginState = _ref8.pluginState;
198
- return /*#__PURE__*/_react.default.createElement(_ToolbarBlockType.default, {
199
- isSmall: isSmall,
200
- isDisabled: disabled,
201
- isReducedSpacing: isToolbarReducedSpacing,
202
- setTextLevel: boundSetBlockType,
203
- pluginState: pluginState,
204
- popupsMountPoint: popupsMountPoint,
205
- popupsBoundariesElement: popupsBoundariesElement,
206
- popupsScrollableElement: popupsScrollableElement
207
- });
208
- }
183
+ return /*#__PURE__*/_react.default.createElement(_PrimaryToolbarComponent.PrimaryToolbarComponent, {
184
+ isSmall: isSmall,
185
+ disabled: disabled,
186
+ isToolbarReducedSpacing: isToolbarReducedSpacing,
187
+ api: api,
188
+ popupsMountPoint: popupsMountPoint,
189
+ popupsBoundariesElement: popupsBoundariesElement,
190
+ popupsScrollableElement: popupsScrollableElement
209
191
  });
210
192
  },
211
193
  pluginsOptions: {
212
194
  quickInsert: function quickInsert(intl) {
213
- var _api$analytics6, _api$analytics7;
195
+ var _api$analytics5, _api$analytics6;
214
196
  var exclude = options && options.allowBlockType && options.allowBlockType.exclude ? options.allowBlockType.exclude : [];
215
- return [].concat((0, _toConsumableArray2.default)(blockquotePluginOptions(intl, exclude.indexOf('blockquote') === -1, api === null || api === void 0 || (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : _api$analytics6.actions)), (0, _toConsumableArray2.default)(headingPluginOptions(intl, exclude.indexOf('heading') === -1, api === null || api === void 0 || (_api$analytics7 = api.analytics) === null || _api$analytics7 === void 0 ? void 0 : _api$analytics7.actions)));
197
+ return [].concat((0, _toConsumableArray2.default)(blockquotePluginOptions(intl, exclude.indexOf('blockquote') === -1, api === null || api === void 0 || (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions)), (0, _toConsumableArray2.default)(headingPluginOptions(intl, exclude.indexOf('heading') === -1, api === null || api === void 0 || (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : _api$analytics6.actions)));
216
198
  }
217
199
  }
218
200
  };
@@ -130,11 +130,11 @@ var createPlugin = exports.createPlugin = function createPlugin(editorAPI, dispa
130
130
  var headingLevel = _consts.HEADING_KEYS.indexOf(event.keyCode);
131
131
  if (headingLevel > -1 && event.altKey) {
132
132
  if (_utils.browser.mac && event.metaKey) {
133
- var _editorAPI$core$actio;
134
- return (_editorAPI$core$actio = editorAPI === null || editorAPI === void 0 ? void 0 : editorAPI.core.actions.execute(autoformatHeading(headingLevel, editorAnalyticsApi))) !== null && _editorAPI$core$actio !== void 0 ? _editorAPI$core$actio : false;
133
+ var _editorAPI$core$actio, _editorAPI$core;
134
+ return (_editorAPI$core$actio = editorAPI === null || editorAPI === void 0 || (_editorAPI$core = editorAPI.core) === null || _editorAPI$core === void 0 ? void 0 : _editorAPI$core.actions.execute(autoformatHeading(headingLevel, editorAnalyticsApi))) !== null && _editorAPI$core$actio !== void 0 ? _editorAPI$core$actio : false;
135
135
  } else if (!_utils.browser.mac && event.ctrlKey && altKeyLocation !== event.DOM_KEY_LOCATION_RIGHT) {
136
- var _editorAPI$core$actio2;
137
- return (_editorAPI$core$actio2 = editorAPI === null || editorAPI === void 0 ? void 0 : editorAPI.core.actions.execute(autoformatHeading(headingLevel, editorAnalyticsApi))) !== null && _editorAPI$core$actio2 !== void 0 ? _editorAPI$core$actio2 : false;
136
+ var _editorAPI$core$actio2, _editorAPI$core2;
137
+ return (_editorAPI$core$actio2 = editorAPI === null || editorAPI === void 0 || (_editorAPI$core2 = editorAPI.core) === null || _editorAPI$core2 === void 0 ? void 0 : _editorAPI$core2.actions.execute(autoformatHeading(headingLevel, editorAnalyticsApi))) !== null && _editorAPI$core$actio2 !== void 0 ? _editorAPI$core$actio2 : false;
138
138
  }
139
139
  } else if (event.key === 'Alt') {
140
140
  // event.location is for the current key only; when a user hits Ctrl-Alt-1 the
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.PrimaryToolbarComponent = PrimaryToolbarComponent;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _analytics = require("@atlaskit/editor-common/analytics");
10
+ var _hooks = require("@atlaskit/editor-common/hooks");
11
+ var _ToolbarBlockType = _interopRequireDefault(require("./ToolbarBlockType"));
12
+ function PrimaryToolbarComponent(_ref) {
13
+ var api = _ref.api,
14
+ isSmall = _ref.isSmall,
15
+ disabled = _ref.disabled,
16
+ isToolbarReducedSpacing = _ref.isToolbarReducedSpacing,
17
+ popupsMountPoint = _ref.popupsMountPoint,
18
+ popupsBoundariesElement = _ref.popupsBoundariesElement,
19
+ popupsScrollableElement = _ref.popupsScrollableElement;
20
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['blockType']),
21
+ blockTypeState = _useSharedPluginState.blockTypeState;
22
+ var boundSetBlockType = function boundSetBlockType(name) {
23
+ var _api$blockType;
24
+ return api === null || api === 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));
25
+ };
26
+ return /*#__PURE__*/_react.default.createElement(_ToolbarBlockType.default, {
27
+ isSmall: isSmall,
28
+ isDisabled: disabled,
29
+ isReducedSpacing: isToolbarReducedSpacing,
30
+ setTextLevel: boundSetBlockType,
31
+ pluginState: blockTypeState,
32
+ popupsMountPoint: popupsMountPoint,
33
+ popupsBoundariesElement: popupsBoundariesElement,
34
+ popupsScrollableElement: popupsScrollableElement
35
+ });
36
+ }
@@ -5,14 +5,13 @@ import { keymap, toggleBlockQuote, tooltip } from '@atlaskit/editor-common/keyma
5
5
  import { blockTypeMessages as messages } from '@atlaskit/editor-common/messages';
6
6
  import { IconHeading, IconQuote } from '@atlaskit/editor-common/quick-insert';
7
7
  import { ToolbarSize } from '@atlaskit/editor-common/types';
8
- import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
9
8
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
10
9
  import { setBlockTypeWithAnalytics } from './commands';
11
10
  import { insertBlockQuoteWithAnalytics } from './commands/block-type';
12
11
  import inputRulePlugin from './pm-plugins/input-rule';
13
12
  import keymapPlugin from './pm-plugins/keymap';
14
13
  import { createPlugin, pluginKey } from './pm-plugins/main';
15
- import ToolbarBlockType from './ui/ToolbarBlockType';
14
+ import { PrimaryToolbarComponent } from './ui/PrimaryToolbarComponent';
16
15
  const headingPluginOptions = ({
17
16
  formatMessage
18
17
  }, isAllowed, editorAnalyticsApi) => {
@@ -157,47 +156,29 @@ const blockTypePlugin = ({
157
156
  return pluginKey.getState(editorState);
158
157
  },
159
158
  primaryToolbarComponent({
160
- editorView,
161
159
  popupsMountPoint,
162
160
  popupsBoundariesElement,
163
161
  popupsScrollableElement,
164
162
  toolbarSize,
165
163
  disabled,
166
- isToolbarReducedSpacing,
167
- eventDispatcher
164
+ isToolbarReducedSpacing
168
165
  }) {
169
166
  const isSmall = options && options.isUndoRedoButtonsEnabled ? toolbarSize < ToolbarSize.XXL : toolbarSize < ToolbarSize.XL;
170
- const boundSetBlockType = name => {
171
- var _api$analytics5;
172
- api === null || api === void 0 ? void 0 : api.core.actions.execute(setBlockTypeWithAnalytics(name, INPUT_METHOD.TOOLBAR, api === null || api === void 0 ? void 0 : (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions));
173
- };
174
- return /*#__PURE__*/React.createElement(WithPluginState, {
175
- editorView: editorView,
176
- eventDispatcher: eventDispatcher,
177
- plugins: {
178
- pluginState: pluginKey
179
- },
180
- render: ({
181
- pluginState
182
- }) => {
183
- return /*#__PURE__*/React.createElement(ToolbarBlockType, {
184
- isSmall: isSmall,
185
- isDisabled: disabled,
186
- isReducedSpacing: isToolbarReducedSpacing,
187
- setTextLevel: boundSetBlockType,
188
- pluginState: pluginState,
189
- popupsMountPoint: popupsMountPoint,
190
- popupsBoundariesElement: popupsBoundariesElement,
191
- popupsScrollableElement: popupsScrollableElement
192
- });
193
- }
167
+ return /*#__PURE__*/React.createElement(PrimaryToolbarComponent, {
168
+ isSmall: isSmall,
169
+ disabled: disabled,
170
+ isToolbarReducedSpacing: isToolbarReducedSpacing,
171
+ api: api,
172
+ popupsMountPoint: popupsMountPoint,
173
+ popupsBoundariesElement: popupsBoundariesElement,
174
+ popupsScrollableElement: popupsScrollableElement
194
175
  });
195
176
  },
196
177
  pluginsOptions: {
197
178
  quickInsert: intl => {
198
- var _api$analytics6, _api$analytics7;
179
+ var _api$analytics5, _api$analytics6;
199
180
  const exclude = options && options.allowBlockType && options.allowBlockType.exclude ? options.allowBlockType.exclude : [];
200
- return [...blockquotePluginOptions(intl, exclude.indexOf('blockquote') === -1, api === null || api === void 0 ? void 0 : (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : _api$analytics6.actions), ...headingPluginOptions(intl, exclude.indexOf('heading') === -1, api === null || api === void 0 ? void 0 : (_api$analytics7 = api.analytics) === null || _api$analytics7 === void 0 ? void 0 : _api$analytics7.actions)];
181
+ return [...blockquotePluginOptions(intl, exclude.indexOf('blockquote') === -1, api === null || api === void 0 ? void 0 : (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions), ...headingPluginOptions(intl, exclude.indexOf('heading') === -1, api === null || api === void 0 ? void 0 : (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : _api$analytics6.actions)];
201
182
  }
202
183
  }
203
184
  });
@@ -118,11 +118,11 @@ export const createPlugin = (editorAPI, dispatch, lastNodeMustBeParagraph) => {
118
118
  const headingLevel = HEADING_KEYS.indexOf(event.keyCode);
119
119
  if (headingLevel > -1 && event.altKey) {
120
120
  if (browser.mac && event.metaKey) {
121
- var _editorAPI$core$actio;
122
- return (_editorAPI$core$actio = editorAPI === null || editorAPI === void 0 ? void 0 : editorAPI.core.actions.execute(autoformatHeading(headingLevel, editorAnalyticsApi))) !== null && _editorAPI$core$actio !== void 0 ? _editorAPI$core$actio : false;
121
+ var _editorAPI$core$actio, _editorAPI$core;
122
+ return (_editorAPI$core$actio = editorAPI === null || editorAPI === void 0 ? void 0 : (_editorAPI$core = editorAPI.core) === null || _editorAPI$core === void 0 ? void 0 : _editorAPI$core.actions.execute(autoformatHeading(headingLevel, editorAnalyticsApi))) !== null && _editorAPI$core$actio !== void 0 ? _editorAPI$core$actio : false;
123
123
  } else if (!browser.mac && event.ctrlKey && altKeyLocation !== event.DOM_KEY_LOCATION_RIGHT) {
124
- var _editorAPI$core$actio2;
125
- return (_editorAPI$core$actio2 = editorAPI === null || editorAPI === void 0 ? void 0 : editorAPI.core.actions.execute(autoformatHeading(headingLevel, editorAnalyticsApi))) !== null && _editorAPI$core$actio2 !== void 0 ? _editorAPI$core$actio2 : false;
124
+ var _editorAPI$core$actio2, _editorAPI$core2;
125
+ return (_editorAPI$core$actio2 = editorAPI === null || editorAPI === void 0 ? void 0 : (_editorAPI$core2 = editorAPI.core) === null || _editorAPI$core2 === void 0 ? void 0 : _editorAPI$core2.actions.execute(autoformatHeading(headingLevel, editorAnalyticsApi))) !== null && _editorAPI$core$actio2 !== void 0 ? _editorAPI$core$actio2 : false;
126
126
  }
127
127
  } else if (event.key === 'Alt') {
128
128
  // event.location is for the current key only; when a user hits Ctrl-Alt-1 the
@@ -0,0 +1,31 @@
1
+ import React from 'react';
2
+ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
4
+ import ToolbarBlockType from './ToolbarBlockType';
5
+ export function PrimaryToolbarComponent({
6
+ api,
7
+ isSmall,
8
+ disabled,
9
+ isToolbarReducedSpacing,
10
+ popupsMountPoint,
11
+ popupsBoundariesElement,
12
+ popupsScrollableElement
13
+ }) {
14
+ const {
15
+ blockTypeState
16
+ } = useSharedPluginState(api, ['blockType']);
17
+ const boundSetBlockType = name => {
18
+ var _api$blockType, _api$blockType$comman;
19
+ return api === null || api === 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));
20
+ };
21
+ return /*#__PURE__*/React.createElement(ToolbarBlockType, {
22
+ isSmall: isSmall,
23
+ isDisabled: disabled,
24
+ isReducedSpacing: isToolbarReducedSpacing,
25
+ setTextLevel: boundSetBlockType,
26
+ pluginState: blockTypeState,
27
+ popupsMountPoint: popupsMountPoint,
28
+ popupsBoundariesElement: popupsBoundariesElement,
29
+ popupsScrollableElement: popupsScrollableElement
30
+ });
31
+ }
@@ -6,14 +6,13 @@ import { keymap, toggleBlockQuote, tooltip } from '@atlaskit/editor-common/keyma
6
6
  import { blockTypeMessages as messages } from '@atlaskit/editor-common/messages';
7
7
  import { IconHeading, IconQuote } from '@atlaskit/editor-common/quick-insert';
8
8
  import { ToolbarSize } from '@atlaskit/editor-common/types';
9
- import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
10
9
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
11
10
  import { setBlockTypeWithAnalytics } from './commands';
12
11
  import { insertBlockQuoteWithAnalytics } from './commands/block-type';
13
12
  import inputRulePlugin from './pm-plugins/input-rule';
14
13
  import keymapPlugin from './pm-plugins/keymap';
15
14
  import { createPlugin, pluginKey } from './pm-plugins/main';
16
- import ToolbarBlockType from './ui/ToolbarBlockType';
15
+ import { PrimaryToolbarComponent } from './ui/PrimaryToolbarComponent';
17
16
  var headingPluginOptions = function headingPluginOptions(_ref, isAllowed, editorAnalyticsApi) {
18
17
  var formatMessage = _ref.formatMessage;
19
18
  if (!isAllowed) {
@@ -161,45 +160,28 @@ var blockTypePlugin = function blockTypePlugin(_ref3) {
161
160
  return pluginKey.getState(editorState);
162
161
  },
163
162
  primaryToolbarComponent: function primaryToolbarComponent(_ref7) {
164
- var editorView = _ref7.editorView,
165
- popupsMountPoint = _ref7.popupsMountPoint,
163
+ var popupsMountPoint = _ref7.popupsMountPoint,
166
164
  popupsBoundariesElement = _ref7.popupsBoundariesElement,
167
165
  popupsScrollableElement = _ref7.popupsScrollableElement,
168
166
  toolbarSize = _ref7.toolbarSize,
169
167
  disabled = _ref7.disabled,
170
- isToolbarReducedSpacing = _ref7.isToolbarReducedSpacing,
171
- eventDispatcher = _ref7.eventDispatcher;
168
+ isToolbarReducedSpacing = _ref7.isToolbarReducedSpacing;
172
169
  var isSmall = options && options.isUndoRedoButtonsEnabled ? toolbarSize < ToolbarSize.XXL : toolbarSize < ToolbarSize.XL;
173
- var boundSetBlockType = function boundSetBlockType(name) {
174
- var _api$analytics5;
175
- api === null || api === void 0 || api.core.actions.execute(setBlockTypeWithAnalytics(name, INPUT_METHOD.TOOLBAR, api === null || api === void 0 || (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions));
176
- };
177
- return /*#__PURE__*/React.createElement(WithPluginState, {
178
- editorView: editorView,
179
- eventDispatcher: eventDispatcher,
180
- plugins: {
181
- pluginState: pluginKey
182
- },
183
- render: function render(_ref8) {
184
- var pluginState = _ref8.pluginState;
185
- return /*#__PURE__*/React.createElement(ToolbarBlockType, {
186
- isSmall: isSmall,
187
- isDisabled: disabled,
188
- isReducedSpacing: isToolbarReducedSpacing,
189
- setTextLevel: boundSetBlockType,
190
- pluginState: pluginState,
191
- popupsMountPoint: popupsMountPoint,
192
- popupsBoundariesElement: popupsBoundariesElement,
193
- popupsScrollableElement: popupsScrollableElement
194
- });
195
- }
170
+ return /*#__PURE__*/React.createElement(PrimaryToolbarComponent, {
171
+ isSmall: isSmall,
172
+ disabled: disabled,
173
+ isToolbarReducedSpacing: isToolbarReducedSpacing,
174
+ api: api,
175
+ popupsMountPoint: popupsMountPoint,
176
+ popupsBoundariesElement: popupsBoundariesElement,
177
+ popupsScrollableElement: popupsScrollableElement
196
178
  });
197
179
  },
198
180
  pluginsOptions: {
199
181
  quickInsert: function quickInsert(intl) {
200
- var _api$analytics6, _api$analytics7;
182
+ var _api$analytics5, _api$analytics6;
201
183
  var exclude = options && options.allowBlockType && options.allowBlockType.exclude ? options.allowBlockType.exclude : [];
202
- return [].concat(_toConsumableArray(blockquotePluginOptions(intl, exclude.indexOf('blockquote') === -1, api === null || api === void 0 || (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : _api$analytics6.actions)), _toConsumableArray(headingPluginOptions(intl, exclude.indexOf('heading') === -1, api === null || api === void 0 || (_api$analytics7 = api.analytics) === null || _api$analytics7 === void 0 ? void 0 : _api$analytics7.actions)));
184
+ return [].concat(_toConsumableArray(blockquotePluginOptions(intl, exclude.indexOf('blockquote') === -1, api === null || api === void 0 || (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions)), _toConsumableArray(headingPluginOptions(intl, exclude.indexOf('heading') === -1, api === null || api === void 0 || (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : _api$analytics6.actions)));
203
185
  }
204
186
  }
205
187
  };
@@ -123,11 +123,11 @@ export var createPlugin = function createPlugin(editorAPI, dispatch, lastNodeMus
123
123
  var headingLevel = HEADING_KEYS.indexOf(event.keyCode);
124
124
  if (headingLevel > -1 && event.altKey) {
125
125
  if (browser.mac && event.metaKey) {
126
- var _editorAPI$core$actio;
127
- return (_editorAPI$core$actio = editorAPI === null || editorAPI === void 0 ? void 0 : editorAPI.core.actions.execute(autoformatHeading(headingLevel, editorAnalyticsApi))) !== null && _editorAPI$core$actio !== void 0 ? _editorAPI$core$actio : false;
126
+ var _editorAPI$core$actio, _editorAPI$core;
127
+ return (_editorAPI$core$actio = editorAPI === null || editorAPI === void 0 || (_editorAPI$core = editorAPI.core) === null || _editorAPI$core === void 0 ? void 0 : _editorAPI$core.actions.execute(autoformatHeading(headingLevel, editorAnalyticsApi))) !== null && _editorAPI$core$actio !== void 0 ? _editorAPI$core$actio : false;
128
128
  } else if (!browser.mac && event.ctrlKey && altKeyLocation !== event.DOM_KEY_LOCATION_RIGHT) {
129
- var _editorAPI$core$actio2;
130
- return (_editorAPI$core$actio2 = editorAPI === null || editorAPI === void 0 ? void 0 : editorAPI.core.actions.execute(autoformatHeading(headingLevel, editorAnalyticsApi))) !== null && _editorAPI$core$actio2 !== void 0 ? _editorAPI$core$actio2 : false;
129
+ var _editorAPI$core$actio2, _editorAPI$core2;
130
+ return (_editorAPI$core$actio2 = editorAPI === null || editorAPI === void 0 || (_editorAPI$core2 = editorAPI.core) === null || _editorAPI$core2 === void 0 ? void 0 : _editorAPI$core2.actions.execute(autoformatHeading(headingLevel, editorAnalyticsApi))) !== null && _editorAPI$core$actio2 !== void 0 ? _editorAPI$core$actio2 : false;
131
131
  }
132
132
  } else if (event.key === 'Alt') {
133
133
  // event.location is for the current key only; when a user hits Ctrl-Alt-1 the
@@ -0,0 +1,29 @@
1
+ import React from 'react';
2
+ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
4
+ import ToolbarBlockType from './ToolbarBlockType';
5
+ export function PrimaryToolbarComponent(_ref) {
6
+ var api = _ref.api,
7
+ isSmall = _ref.isSmall,
8
+ disabled = _ref.disabled,
9
+ isToolbarReducedSpacing = _ref.isToolbarReducedSpacing,
10
+ popupsMountPoint = _ref.popupsMountPoint,
11
+ popupsBoundariesElement = _ref.popupsBoundariesElement,
12
+ popupsScrollableElement = _ref.popupsScrollableElement;
13
+ var _useSharedPluginState = useSharedPluginState(api, ['blockType']),
14
+ blockTypeState = _useSharedPluginState.blockTypeState;
15
+ var boundSetBlockType = function boundSetBlockType(name) {
16
+ var _api$blockType;
17
+ return api === null || api === 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));
18
+ };
19
+ return /*#__PURE__*/React.createElement(ToolbarBlockType, {
20
+ isSmall: isSmall,
21
+ isDisabled: disabled,
22
+ isReducedSpacing: isToolbarReducedSpacing,
23
+ setTextLevel: boundSetBlockType,
24
+ pluginState: blockTypeState,
25
+ popupsMountPoint: popupsMountPoint,
26
+ popupsBoundariesElement: popupsBoundariesElement,
27
+ popupsScrollableElement: popupsScrollableElement
28
+ });
29
+ }
@@ -0,0 +1,14 @@
1
+ /// <reference types="react" />
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { BlockTypePlugin } from '../index';
4
+ interface PrimaryToolbarComponentProps {
5
+ isSmall: boolean;
6
+ isToolbarReducedSpacing: boolean;
7
+ disabled: boolean;
8
+ api: ExtractInjectionAPI<BlockTypePlugin> | undefined;
9
+ popupsMountPoint?: HTMLElement;
10
+ popupsBoundariesElement?: HTMLElement;
11
+ popupsScrollableElement?: HTMLElement;
12
+ }
13
+ export declare function PrimaryToolbarComponent({ api, isSmall, disabled, isToolbarReducedSpacing, popupsMountPoint, popupsBoundariesElement, popupsScrollableElement, }: PrimaryToolbarComponentProps): JSX.Element;
14
+ export {};
@@ -12,4 +12,4 @@ export interface BlockTypeButtonProps {
12
12
  onKeyDown(e: React.KeyboardEvent): void;
13
13
  formatMessage: WrappedComponentProps['intl']['formatMessage'];
14
14
  }
15
- export declare const BlockTypeButton: React.StatelessComponent<BlockTypeButtonProps>;
15
+ export declare const BlockTypeButton: React.FunctionComponent<BlockTypeButtonProps>;
@@ -0,0 +1,14 @@
1
+ /// <reference types="react" />
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { BlockTypePlugin } from '../index';
4
+ interface PrimaryToolbarComponentProps {
5
+ isSmall: boolean;
6
+ isToolbarReducedSpacing: boolean;
7
+ disabled: boolean;
8
+ api: ExtractInjectionAPI<BlockTypePlugin> | undefined;
9
+ popupsMountPoint?: HTMLElement;
10
+ popupsBoundariesElement?: HTMLElement;
11
+ popupsScrollableElement?: HTMLElement;
12
+ }
13
+ export declare function PrimaryToolbarComponent({ api, isSmall, disabled, isToolbarReducedSpacing, popupsMountPoint, popupsBoundariesElement, popupsScrollableElement, }: PrimaryToolbarComponentProps): JSX.Element;
14
+ export {};
@@ -12,4 +12,4 @@ export interface BlockTypeButtonProps {
12
12
  onKeyDown(e: React.KeyboardEvent): void;
13
13
  formatMessage: WrappedComponentProps['intl']['formatMessage'];
14
14
  }
15
- export declare const BlockTypeButton: React.StatelessComponent<BlockTypeButtonProps>;
15
+ export declare const BlockTypeButton: React.FunctionComponent<BlockTypeButtonProps>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-type",
3
- "version": "3.0.15",
3
+ "version": "3.0.17",
4
4
  "description": "BlockType plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -14,7 +14,7 @@
14
14
  "releaseModel": "continuous",
15
15
  "runReact18": false
16
16
  },
17
- "repository": "https://bitbucket.org/atlassian/atlassian-frontend",
17
+ "repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
18
18
  "main": "dist/cjs/index.js",
19
19
  "module": "dist/esm/index.js",
20
20
  "module:es2019": "dist/es2019/index.js",
@@ -36,7 +36,7 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@atlaskit/adf-schema": "^35.3.0",
39
- "@atlaskit/editor-common": "^76.35.0",
39
+ "@atlaskit/editor-common": "^76.40.0",
40
40
  "@atlaskit/editor-plugin-analytics": "^0.4.0",
41
41
  "@atlaskit/editor-prosemirror": "1.1.0",
42
42
  "@atlaskit/editor-shared-styles": "^2.9.0",