@atlaskit/editor-plugin-block-type 3.3.0 → 3.4.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,20 @@
1
1
  # @atlaskit/editor-plugin-block-type
2
2
 
3
+ ## 3.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#101406](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/101406)
8
+ [`6daffd65aec4`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/6daffd65aec4) -
9
+ [ED-23298] Extract primary toolbar components to editor plugin to allow for custom ordering
10
+
11
+ ### Patch Changes
12
+
13
+ - [#102478](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/102478)
14
+ [`3378951608b0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3378951608b0) -
15
+ [ED-23332] Update adf-schema package to 36.10.1
16
+ - Updated dependencies
17
+
3
18
  ## 3.3.0
4
19
 
5
20
  ### Minor Changes
@@ -104,6 +104,25 @@ var blockquotePluginOptions = function blockquotePluginOptions(_ref2, isAllowed,
104
104
  var blockTypePlugin = exports.blockTypePlugin = function blockTypePlugin(_ref3) {
105
105
  var options = _ref3.config,
106
106
  api = _ref3.api;
107
+ var primaryToolbarComponent = function primaryToolbarComponent(_ref4) {
108
+ var popupsMountPoint = _ref4.popupsMountPoint,
109
+ popupsBoundariesElement = _ref4.popupsBoundariesElement,
110
+ popupsScrollableElement = _ref4.popupsScrollableElement,
111
+ toolbarSize = _ref4.toolbarSize,
112
+ disabled = _ref4.disabled,
113
+ isToolbarReducedSpacing = _ref4.isToolbarReducedSpacing;
114
+ var isSmall = options && options.isUndoRedoButtonsEnabled ? toolbarSize < _types.ToolbarSize.XXL : toolbarSize < _types.ToolbarSize.XL;
115
+ return /*#__PURE__*/_react.default.createElement(_PrimaryToolbarComponent.PrimaryToolbarComponent, {
116
+ isSmall: isSmall,
117
+ disabled: disabled,
118
+ isToolbarReducedSpacing: isToolbarReducedSpacing,
119
+ api: api,
120
+ popupsMountPoint: popupsMountPoint,
121
+ popupsBoundariesElement: popupsBoundariesElement,
122
+ popupsScrollableElement: popupsScrollableElement,
123
+ shouldUseDefaultRole: false
124
+ });
125
+ };
107
126
  return {
108
127
  name: 'blockType',
109
128
  nodes: function nodes() {
@@ -130,16 +149,16 @@ var blockTypePlugin = exports.blockTypePlugin = function blockTypePlugin(_ref3)
130
149
  pmPlugins: function pmPlugins() {
131
150
  return [{
132
151
  name: 'blockType',
133
- plugin: function plugin(_ref4) {
134
- var dispatch = _ref4.dispatch;
152
+ plugin: function plugin(_ref5) {
153
+ var dispatch = _ref5.dispatch;
135
154
  return (0, _main.createPlugin)(api, dispatch, options && options.lastNodeMustBeParagraph);
136
155
  }
137
156
  }, {
138
157
  name: 'blockTypeInputRule',
139
- plugin: function plugin(_ref5) {
158
+ plugin: function plugin(_ref6) {
140
159
  var _api$analytics;
141
- var schema = _ref5.schema,
142
- featureFlags = _ref5.featureFlags;
160
+ var schema = _ref6.schema,
161
+ featureFlags = _ref6.featureFlags;
143
162
  return (0, _inputRule.default)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, schema, featureFlags);
144
163
  }
145
164
  },
@@ -147,10 +166,10 @@ var blockTypePlugin = exports.blockTypePlugin = function blockTypePlugin(_ref3)
147
166
  // plugin as it is currently swallowing right/down arrow events inside tables
148
167
  {
149
168
  name: 'blockTypeKeyMap',
150
- plugin: function plugin(_ref6) {
169
+ plugin: function plugin(_ref7) {
151
170
  var _api$analytics2;
152
- var schema = _ref6.schema,
153
- featureFlags = _ref6.featureFlags;
171
+ var schema = _ref7.schema,
172
+ featureFlags = _ref7.featureFlags;
154
173
  return (0, _keymap.default)(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, schema, featureFlags);
155
174
  }
156
175
  }];
@@ -173,25 +192,14 @@ var blockTypePlugin = exports.blockTypePlugin = function blockTypePlugin(_ref3)
173
192
  }
174
193
  return _main.pluginKey.getState(editorState);
175
194
  },
176
- primaryToolbarComponent: function primaryToolbarComponent(_ref7) {
177
- var popupsMountPoint = _ref7.popupsMountPoint,
178
- popupsBoundariesElement = _ref7.popupsBoundariesElement,
179
- popupsScrollableElement = _ref7.popupsScrollableElement,
180
- toolbarSize = _ref7.toolbarSize,
181
- disabled = _ref7.disabled,
182
- isToolbarReducedSpacing = _ref7.isToolbarReducedSpacing;
183
- var isSmall = options && options.isUndoRedoButtonsEnabled ? toolbarSize < _types.ToolbarSize.XXL : toolbarSize < _types.ToolbarSize.XL;
184
- return /*#__PURE__*/_react.default.createElement(_PrimaryToolbarComponent.PrimaryToolbarComponent, {
185
- isSmall: isSmall,
186
- disabled: disabled,
187
- isToolbarReducedSpacing: isToolbarReducedSpacing,
188
- api: api,
189
- popupsMountPoint: popupsMountPoint,
190
- popupsBoundariesElement: popupsBoundariesElement,
191
- popupsScrollableElement: popupsScrollableElement,
192
- shouldUseDefaultRole: false
193
- });
195
+ usePluginHook: function usePluginHook() {
196
+ var _api$core, _api$primaryToolbar;
197
+ api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api === null || api === void 0 || (_api$primaryToolbar = api.primaryToolbar) === null || _api$primaryToolbar === void 0 ? void 0 : _api$primaryToolbar.commands.registerComponent({
198
+ name: 'blockType',
199
+ component: primaryToolbarComponent
200
+ }));
194
201
  },
202
+ primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined,
195
203
  pluginsOptions: {
196
204
  quickInsert: function quickInsert(intl) {
197
205
  var _api$analytics5, _api$analytics6;
@@ -33,6 +33,7 @@ function PrimaryToolbarComponent(_ref) {
33
33
  popupsMountPoint: popupsMountPoint,
34
34
  popupsBoundariesElement: popupsBoundariesElement,
35
35
  popupsScrollableElement: popupsScrollableElement,
36
- shouldUseDefaultRole: shouldUseDefaultRole
36
+ shouldUseDefaultRole: shouldUseDefaultRole,
37
+ api: api
37
38
  });
38
39
  }
@@ -127,7 +127,8 @@ var ToolbarBlockType = /*#__PURE__*/function (_React$PureComponent) {
127
127
  blockTypesDisabled = _this$props$pluginSta2.blockTypesDisabled,
128
128
  availableBlockTypes = _this$props$pluginSta2.availableBlockTypes,
129
129
  shouldUseDefaultRole = _this$props.shouldUseDefaultRole,
130
- formatMessage = _this$props.intl.formatMessage;
130
+ formatMessage = _this$props.intl.formatMessage,
131
+ api = _this$props.api;
131
132
  var isHeadingDisabled = !availableBlockTypes.some(function (blockType) {
132
133
  return blockType.nodeName === 'heading';
133
134
  });
@@ -177,7 +178,7 @@ var ToolbarBlockType = /*#__PURE__*/function (_React$PureComponent) {
177
178
  formatMessage: formatMessage,
178
179
  "aria-expanded": active,
179
180
  blockTypeName: currentBlockType.name
180
- })), (0, _react2.jsx)("span", {
181
+ })), !(api !== null && api !== void 0 && api.primaryToolbar) && (0, _react2.jsx)("span", {
181
182
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
182
183
  css: _styles.separatorStyles
183
184
  }))
@@ -88,82 +88,15 @@ const blockquotePluginOptions = ({
88
88
  const blockTypePlugin = ({
89
89
  config: options,
90
90
  api
91
- }) => ({
92
- name: 'blockType',
93
- nodes() {
94
- const blockquoteNode = getBooleanFF('platform.editor.allow-list-in-blockquote') ? blockquoteWithList : blockquote;
95
- const headingNode = getBooleanFF('platform.editor.enable-localid-for-paragraph-in-stage-0_cby7g') ? headingStage0 : heading;
96
- const nodes = [{
97
- name: 'heading',
98
- node: headingNode
99
- }, {
100
- name: 'blockquote',
101
- node: blockquoteNode
102
- }, {
103
- name: 'hardBreak',
104
- node: hardBreak
105
- }];
106
- if (options && options.allowBlockType) {
107
- const exclude = options.allowBlockType.exclude ? options.allowBlockType.exclude : [];
108
- return nodes.filter(node => exclude.indexOf(node.name) === -1);
109
- }
110
- return nodes;
111
- },
112
- pmPlugins() {
113
- return [{
114
- name: 'blockType',
115
- plugin: ({
116
- dispatch
117
- }) => createPlugin(api, dispatch, options && options.lastNodeMustBeParagraph)
118
- }, {
119
- name: 'blockTypeInputRule',
120
- plugin: ({
121
- schema,
122
- featureFlags
123
- }) => {
124
- var _api$analytics;
125
- return inputRulePlugin(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, schema, featureFlags);
126
- }
127
- },
128
- // Needs to be lower priority than editor-tables.tableEditing
129
- // plugin as it is currently swallowing right/down arrow events inside tables
130
- {
131
- name: 'blockTypeKeyMap',
132
- plugin: ({
133
- schema,
134
- featureFlags
135
- }) => {
136
- var _api$analytics2;
137
- return keymapPlugin(api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, schema, featureFlags);
138
- }
139
- }];
140
- },
141
- actions: {
142
- insertBlockQuote(inputMethod) {
143
- var _api$analytics3;
144
- return insertBlockQuoteWithAnalytics(inputMethod, api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions);
145
- }
146
- },
147
- commands: {
148
- setTextLevel(level, inputMethod) {
149
- var _api$analytics4;
150
- return setBlockTypeWithAnalytics(level, inputMethod, api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions);
151
- }
152
- },
153
- getSharedState(editorState) {
154
- if (!editorState) {
155
- return;
156
- }
157
- return pluginKey.getState(editorState);
158
- },
159
- primaryToolbarComponent({
91
+ }) => {
92
+ const primaryToolbarComponent = ({
160
93
  popupsMountPoint,
161
94
  popupsBoundariesElement,
162
95
  popupsScrollableElement,
163
96
  toolbarSize,
164
97
  disabled,
165
98
  isToolbarReducedSpacing
166
- }) {
99
+ }) => {
167
100
  const isSmall = options && options.isUndoRedoButtonsEnabled ? toolbarSize < ToolbarSize.XXL : toolbarSize < ToolbarSize.XL;
168
101
  return /*#__PURE__*/React.createElement(PrimaryToolbarComponent, {
169
102
  isSmall: isSmall,
@@ -175,14 +108,91 @@ const blockTypePlugin = ({
175
108
  popupsScrollableElement: popupsScrollableElement,
176
109
  shouldUseDefaultRole: false
177
110
  });
178
- },
179
- pluginsOptions: {
180
- quickInsert: intl => {
181
- var _api$analytics5, _api$analytics6;
182
- const exclude = options && options.allowBlockType && options.allowBlockType.exclude ? options.allowBlockType.exclude : [];
183
- 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)];
111
+ };
112
+ return {
113
+ name: 'blockType',
114
+ nodes() {
115
+ const blockquoteNode = getBooleanFF('platform.editor.allow-list-in-blockquote') ? blockquoteWithList : blockquote;
116
+ const headingNode = getBooleanFF('platform.editor.enable-localid-for-paragraph-in-stage-0_cby7g') ? headingStage0 : heading;
117
+ const nodes = [{
118
+ name: 'heading',
119
+ node: headingNode
120
+ }, {
121
+ name: 'blockquote',
122
+ node: blockquoteNode
123
+ }, {
124
+ name: 'hardBreak',
125
+ node: hardBreak
126
+ }];
127
+ if (options && options.allowBlockType) {
128
+ const exclude = options.allowBlockType.exclude ? options.allowBlockType.exclude : [];
129
+ return nodes.filter(node => exclude.indexOf(node.name) === -1);
130
+ }
131
+ return nodes;
132
+ },
133
+ pmPlugins() {
134
+ return [{
135
+ name: 'blockType',
136
+ plugin: ({
137
+ dispatch
138
+ }) => createPlugin(api, dispatch, options && options.lastNodeMustBeParagraph)
139
+ }, {
140
+ name: 'blockTypeInputRule',
141
+ plugin: ({
142
+ schema,
143
+ featureFlags
144
+ }) => {
145
+ var _api$analytics;
146
+ return inputRulePlugin(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, schema, featureFlags);
147
+ }
148
+ },
149
+ // Needs to be lower priority than editor-tables.tableEditing
150
+ // plugin as it is currently swallowing right/down arrow events inside tables
151
+ {
152
+ name: 'blockTypeKeyMap',
153
+ plugin: ({
154
+ schema,
155
+ featureFlags
156
+ }) => {
157
+ var _api$analytics2;
158
+ return keymapPlugin(api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, schema, featureFlags);
159
+ }
160
+ }];
161
+ },
162
+ actions: {
163
+ insertBlockQuote(inputMethod) {
164
+ var _api$analytics3;
165
+ return insertBlockQuoteWithAnalytics(inputMethod, api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions);
166
+ }
167
+ },
168
+ commands: {
169
+ setTextLevel(level, inputMethod) {
170
+ var _api$analytics4;
171
+ return setBlockTypeWithAnalytics(level, inputMethod, api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions);
172
+ }
173
+ },
174
+ getSharedState(editorState) {
175
+ if (!editorState) {
176
+ return;
177
+ }
178
+ return pluginKey.getState(editorState);
179
+ },
180
+ usePluginHook: () => {
181
+ var _api$core, _api$primaryToolbar;
182
+ 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$primaryToolbar = api.primaryToolbar) === null || _api$primaryToolbar === void 0 ? void 0 : _api$primaryToolbar.commands.registerComponent({
183
+ name: 'blockType',
184
+ component: primaryToolbarComponent
185
+ }));
186
+ },
187
+ primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined,
188
+ pluginsOptions: {
189
+ quickInsert: intl => {
190
+ var _api$analytics5, _api$analytics6;
191
+ const exclude = options && options.allowBlockType && options.allowBlockType.exclude ? options.allowBlockType.exclude : [];
192
+ 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)];
193
+ }
184
194
  }
185
- }
186
- });
195
+ };
196
+ };
187
197
  export { blockTypePlugin };
188
198
  export { pluginKey } from './pm-plugins/main';
@@ -28,6 +28,7 @@ export function PrimaryToolbarComponent({
28
28
  popupsMountPoint: popupsMountPoint,
29
29
  popupsBoundariesElement: popupsBoundariesElement,
30
30
  popupsScrollableElement: popupsScrollableElement,
31
- shouldUseDefaultRole: shouldUseDefaultRole
31
+ shouldUseDefaultRole: shouldUseDefaultRole,
32
+ api: api
32
33
  });
33
34
  }
@@ -111,7 +111,8 @@ class ToolbarBlockType extends React.PureComponent {
111
111
  shouldUseDefaultRole,
112
112
  intl: {
113
113
  formatMessage
114
- }
114
+ },
115
+ api
115
116
  } = this.props;
116
117
  const isHeadingDisabled = !availableBlockTypes.some(blockType => blockType.nodeName === 'heading');
117
118
  if (isHeadingDisabled) {
@@ -157,7 +158,7 @@ class ToolbarBlockType extends React.PureComponent {
157
158
  formatMessage: formatMessage,
158
159
  "aria-expanded": active,
159
160
  blockTypeName: currentBlockType.name
160
- })), jsx("span", {
161
+ })), !(api !== null && api !== void 0 && api.primaryToolbar) && jsx("span", {
161
162
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
162
163
  css: separatorStyles
163
164
  }))
@@ -91,6 +91,25 @@ var blockquotePluginOptions = function blockquotePluginOptions(_ref2, isAllowed,
91
91
  var blockTypePlugin = function blockTypePlugin(_ref3) {
92
92
  var options = _ref3.config,
93
93
  api = _ref3.api;
94
+ var primaryToolbarComponent = function primaryToolbarComponent(_ref4) {
95
+ var popupsMountPoint = _ref4.popupsMountPoint,
96
+ popupsBoundariesElement = _ref4.popupsBoundariesElement,
97
+ popupsScrollableElement = _ref4.popupsScrollableElement,
98
+ toolbarSize = _ref4.toolbarSize,
99
+ disabled = _ref4.disabled,
100
+ isToolbarReducedSpacing = _ref4.isToolbarReducedSpacing;
101
+ var isSmall = options && options.isUndoRedoButtonsEnabled ? toolbarSize < ToolbarSize.XXL : toolbarSize < ToolbarSize.XL;
102
+ return /*#__PURE__*/React.createElement(PrimaryToolbarComponent, {
103
+ isSmall: isSmall,
104
+ disabled: disabled,
105
+ isToolbarReducedSpacing: isToolbarReducedSpacing,
106
+ api: api,
107
+ popupsMountPoint: popupsMountPoint,
108
+ popupsBoundariesElement: popupsBoundariesElement,
109
+ popupsScrollableElement: popupsScrollableElement,
110
+ shouldUseDefaultRole: false
111
+ });
112
+ };
94
113
  return {
95
114
  name: 'blockType',
96
115
  nodes: function nodes() {
@@ -117,16 +136,16 @@ var blockTypePlugin = function blockTypePlugin(_ref3) {
117
136
  pmPlugins: function pmPlugins() {
118
137
  return [{
119
138
  name: 'blockType',
120
- plugin: function plugin(_ref4) {
121
- var dispatch = _ref4.dispatch;
139
+ plugin: function plugin(_ref5) {
140
+ var dispatch = _ref5.dispatch;
122
141
  return createPlugin(api, dispatch, options && options.lastNodeMustBeParagraph);
123
142
  }
124
143
  }, {
125
144
  name: 'blockTypeInputRule',
126
- plugin: function plugin(_ref5) {
145
+ plugin: function plugin(_ref6) {
127
146
  var _api$analytics;
128
- var schema = _ref5.schema,
129
- featureFlags = _ref5.featureFlags;
147
+ var schema = _ref6.schema,
148
+ featureFlags = _ref6.featureFlags;
130
149
  return inputRulePlugin(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, schema, featureFlags);
131
150
  }
132
151
  },
@@ -134,10 +153,10 @@ var blockTypePlugin = function blockTypePlugin(_ref3) {
134
153
  // plugin as it is currently swallowing right/down arrow events inside tables
135
154
  {
136
155
  name: 'blockTypeKeyMap',
137
- plugin: function plugin(_ref6) {
156
+ plugin: function plugin(_ref7) {
138
157
  var _api$analytics2;
139
- var schema = _ref6.schema,
140
- featureFlags = _ref6.featureFlags;
158
+ var schema = _ref7.schema,
159
+ featureFlags = _ref7.featureFlags;
141
160
  return keymapPlugin(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, schema, featureFlags);
142
161
  }
143
162
  }];
@@ -160,25 +179,14 @@ var blockTypePlugin = function blockTypePlugin(_ref3) {
160
179
  }
161
180
  return pluginKey.getState(editorState);
162
181
  },
163
- primaryToolbarComponent: function primaryToolbarComponent(_ref7) {
164
- var popupsMountPoint = _ref7.popupsMountPoint,
165
- popupsBoundariesElement = _ref7.popupsBoundariesElement,
166
- popupsScrollableElement = _ref7.popupsScrollableElement,
167
- toolbarSize = _ref7.toolbarSize,
168
- disabled = _ref7.disabled,
169
- isToolbarReducedSpacing = _ref7.isToolbarReducedSpacing;
170
- var isSmall = options && options.isUndoRedoButtonsEnabled ? toolbarSize < ToolbarSize.XXL : toolbarSize < ToolbarSize.XL;
171
- return /*#__PURE__*/React.createElement(PrimaryToolbarComponent, {
172
- isSmall: isSmall,
173
- disabled: disabled,
174
- isToolbarReducedSpacing: isToolbarReducedSpacing,
175
- api: api,
176
- popupsMountPoint: popupsMountPoint,
177
- popupsBoundariesElement: popupsBoundariesElement,
178
- popupsScrollableElement: popupsScrollableElement,
179
- shouldUseDefaultRole: false
180
- });
182
+ usePluginHook: function usePluginHook() {
183
+ var _api$core, _api$primaryToolbar;
184
+ api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api === null || api === void 0 || (_api$primaryToolbar = api.primaryToolbar) === null || _api$primaryToolbar === void 0 ? void 0 : _api$primaryToolbar.commands.registerComponent({
185
+ name: 'blockType',
186
+ component: primaryToolbarComponent
187
+ }));
181
188
  },
189
+ primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined,
182
190
  pluginsOptions: {
183
191
  quickInsert: function quickInsert(intl) {
184
192
  var _api$analytics5, _api$analytics6;
@@ -26,6 +26,7 @@ export function PrimaryToolbarComponent(_ref) {
26
26
  popupsMountPoint: popupsMountPoint,
27
27
  popupsBoundariesElement: popupsBoundariesElement,
28
28
  popupsScrollableElement: popupsScrollableElement,
29
- shouldUseDefaultRole: shouldUseDefaultRole
29
+ shouldUseDefaultRole: shouldUseDefaultRole,
30
+ api: api
30
31
  });
31
32
  }
@@ -121,7 +121,8 @@ var ToolbarBlockType = /*#__PURE__*/function (_React$PureComponent) {
121
121
  blockTypesDisabled = _this$props$pluginSta2.blockTypesDisabled,
122
122
  availableBlockTypes = _this$props$pluginSta2.availableBlockTypes,
123
123
  shouldUseDefaultRole = _this$props.shouldUseDefaultRole,
124
- formatMessage = _this$props.intl.formatMessage;
124
+ formatMessage = _this$props.intl.formatMessage,
125
+ api = _this$props.api;
125
126
  var isHeadingDisabled = !availableBlockTypes.some(function (blockType) {
126
127
  return blockType.nodeName === 'heading';
127
128
  });
@@ -171,7 +172,7 @@ var ToolbarBlockType = /*#__PURE__*/function (_React$PureComponent) {
171
172
  formatMessage: formatMessage,
172
173
  "aria-expanded": active,
173
174
  blockTypeName: currentBlockType.name
174
- })), jsx("span", {
175
+ })), !(api !== null && api !== void 0 && api.primaryToolbar) && jsx("span", {
175
176
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
176
177
  css: separatorStyles
177
178
  }))
@@ -1,12 +1,16 @@
1
1
  import type { Command, EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
- import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
2
+ import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
3
+ import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
3
4
  import type { TextBlockTypes } from './block-types';
4
5
  import type { InputMethod } from './commands/block-type';
5
6
  import type { BlockTypeState } from './pm-plugins/main';
6
7
  import type { BlockTypePluginOptions } from './types';
7
8
  export type BlockTypePlugin = NextEditorPlugin<'blockType', {
8
9
  pluginConfiguration: BlockTypePluginOptions | undefined;
9
- dependencies: [OptionalPlugin<typeof analyticsPlugin>];
10
+ dependencies: [
11
+ OptionalPlugin<AnalyticsPlugin>,
12
+ OptionalPlugin<PrimaryToolbarPlugin>
13
+ ];
10
14
  sharedState: BlockTypeState | undefined;
11
15
  actions: {
12
16
  insertBlockQuote: (inputMethod: InputMethod) => Command;
@@ -1,9 +1,11 @@
1
1
  /** @jsx jsx */
2
2
  import React from 'react';
3
3
  import type { WrappedComponentProps } from 'react-intl-next';
4
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
4
5
  import type { MenuItem } from '@atlaskit/editor-common/ui-menu';
5
6
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
7
  import type { TextBlockTypes } from '../../block-types';
8
+ import type { BlockTypePlugin } from '../../index';
7
9
  import type { BlockTypeState } from '../../pm-plugins/main';
8
10
  import type { BlockType } from '../../types';
9
11
  export type DropdownItem = MenuItem & {
@@ -20,6 +22,7 @@ export interface Props {
20
22
  editorView?: EditorView;
21
23
  setTextLevel: (type: TextBlockTypes) => void;
22
24
  shouldUseDefaultRole?: boolean;
25
+ api: ExtractInjectionAPI<BlockTypePlugin> | undefined;
23
26
  }
24
27
  export interface State {
25
28
  active: boolean;
@@ -1,5 +1,6 @@
1
1
  import type { Command, EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
- import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
2
+ import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
3
+ import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
3
4
  import type { TextBlockTypes } from './block-types';
4
5
  import type { InputMethod } from './commands/block-type';
5
6
  import type { BlockTypeState } from './pm-plugins/main';
@@ -7,7 +8,8 @@ import type { BlockTypePluginOptions } from './types';
7
8
  export type BlockTypePlugin = NextEditorPlugin<'blockType', {
8
9
  pluginConfiguration: BlockTypePluginOptions | undefined;
9
10
  dependencies: [
10
- OptionalPlugin<typeof analyticsPlugin>
11
+ OptionalPlugin<AnalyticsPlugin>,
12
+ OptionalPlugin<PrimaryToolbarPlugin>
11
13
  ];
12
14
  sharedState: BlockTypeState | undefined;
13
15
  actions: {
@@ -1,9 +1,11 @@
1
1
  /** @jsx jsx */
2
2
  import React from 'react';
3
3
  import type { WrappedComponentProps } from 'react-intl-next';
4
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
4
5
  import type { MenuItem } from '@atlaskit/editor-common/ui-menu';
5
6
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
7
  import type { TextBlockTypes } from '../../block-types';
8
+ import type { BlockTypePlugin } from '../../index';
7
9
  import type { BlockTypeState } from '../../pm-plugins/main';
8
10
  import type { BlockType } from '../../types';
9
11
  export type DropdownItem = MenuItem & {
@@ -20,6 +22,7 @@ export interface Props {
20
22
  editorView?: EditorView;
21
23
  setTextLevel: (type: TextBlockTypes) => void;
22
24
  shouldUseDefaultRole?: boolean;
25
+ api: ExtractInjectionAPI<BlockTypePlugin> | undefined;
23
26
  }
24
27
  export interface State {
25
28
  active: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-type",
3
- "version": "3.3.0",
3
+ "version": "3.4.0",
4
4
  "description": "BlockType plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -35,9 +35,10 @@
35
35
  "./styles": "./src/styles.ts"
36
36
  },
37
37
  "dependencies": {
38
- "@atlaskit/adf-schema": "^36.8.0",
39
- "@atlaskit/editor-common": "^80.4.0",
38
+ "@atlaskit/adf-schema": "^36.10.7",
39
+ "@atlaskit/editor-common": "^81.0.0",
40
40
  "@atlaskit/editor-plugin-analytics": "^1.2.0",
41
+ "@atlaskit/editor-plugin-primary-toolbar": "^1.1.0",
41
42
  "@atlaskit/editor-prosemirror": "4.0.1",
42
43
  "@atlaskit/editor-shared-styles": "^2.11.0",
43
44
  "@atlaskit/editor-tables": "^2.7.0",