@atlaskit/editor-plugin-block-type 1.0.3 → 3.0.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.
Files changed (90) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/dist/cjs/i18n/cs.js +2 -3
  3. package/dist/cjs/i18n/da.js +2 -3
  4. package/dist/cjs/i18n/de.js +2 -3
  5. package/dist/cjs/i18n/en.js +2 -3
  6. package/dist/cjs/i18n/en_GB.js +2 -3
  7. package/dist/cjs/i18n/en_ZZ.js +2 -3
  8. package/dist/cjs/i18n/es.js +2 -3
  9. package/dist/cjs/i18n/fi.js +2 -3
  10. package/dist/cjs/i18n/fr.js +2 -3
  11. package/dist/cjs/i18n/hu.js +2 -3
  12. package/dist/cjs/i18n/it.js +2 -3
  13. package/dist/cjs/i18n/ja.js +2 -3
  14. package/dist/cjs/i18n/ko.js +2 -3
  15. package/dist/cjs/i18n/nb.js +2 -3
  16. package/dist/cjs/i18n/nl.js +8 -9
  17. package/dist/cjs/i18n/pl.js +2 -3
  18. package/dist/cjs/i18n/pt_BR.js +2 -3
  19. package/dist/cjs/i18n/ru.js +2 -3
  20. package/dist/cjs/i18n/sv.js +2 -3
  21. package/dist/cjs/i18n/th.js +2 -3
  22. package/dist/cjs/i18n/tr.js +2 -3
  23. package/dist/cjs/i18n/uk.js +2 -3
  24. package/dist/cjs/i18n/vi.js +2 -3
  25. package/dist/cjs/i18n/zh.js +2 -3
  26. package/dist/cjs/i18n/zh_TW.js +2 -3
  27. package/dist/cjs/plugin/block-types.js +29 -45
  28. package/dist/cjs/plugin/commands/block-type.js +95 -60
  29. package/dist/cjs/plugin/commands/delete-and-move-cursor.js +2 -3
  30. package/dist/cjs/plugin/commands/index.js +1 -8
  31. package/dist/cjs/plugin/consts.js +1 -2
  32. package/dist/cjs/plugin/index.js +26 -26
  33. package/dist/cjs/plugin/pm-plugins/input-rule.js +1 -2
  34. package/dist/cjs/plugin/pm-plugins/main.js +12 -12
  35. package/dist/cjs/plugin/styles.js +2 -3
  36. package/dist/cjs/plugin/ui/ToolbarBlockType/blocktype-button.js +5 -13
  37. package/dist/cjs/plugin/ui/ToolbarBlockType/index.js +2 -3
  38. package/dist/cjs/plugin/ui/ToolbarBlockType/styled.js +7 -14
  39. package/dist/cjs/plugin/utils.js +3 -6
  40. package/dist/es2019/i18n/nl.js +6 -6
  41. package/dist/es2019/plugin/block-types.js +1 -1
  42. package/dist/es2019/plugin/commands/block-type.js +101 -46
  43. package/dist/es2019/plugin/commands/index.js +1 -6
  44. package/dist/es2019/plugin/index.js +18 -19
  45. package/dist/es2019/plugin/pm-plugins/main.js +10 -8
  46. package/dist/es2019/plugin/ui/ToolbarBlockType/blocktype-button.js +3 -9
  47. package/dist/es2019/plugin/ui/ToolbarBlockType/index.js +1 -1
  48. package/dist/esm/i18n/nl.js +6 -6
  49. package/dist/esm/plugin/block-types.js +1 -1
  50. package/dist/esm/plugin/commands/block-type.js +90 -53
  51. package/dist/esm/plugin/commands/index.js +1 -6
  52. package/dist/esm/plugin/index.js +20 -19
  53. package/dist/esm/plugin/pm-plugins/main.js +10 -8
  54. package/dist/esm/plugin/ui/ToolbarBlockType/blocktype-button.js +3 -9
  55. package/dist/esm/plugin/ui/ToolbarBlockType/index.js +1 -1
  56. package/dist/types/index.d.ts +1 -0
  57. package/dist/types/plugin/block-types.d.ts +1 -0
  58. package/dist/types/plugin/commands/block-type.d.ts +8 -6
  59. package/dist/types/plugin/commands/index.d.ts +0 -5
  60. package/dist/types/plugin/index.d.ts +5 -2
  61. package/dist/types/plugin/pm-plugins/main.d.ts +3 -2
  62. package/dist/types/plugin/ui/ToolbarBlockType/blocktype-button.d.ts +0 -7
  63. package/dist/types/plugin/ui/ToolbarBlockType/index.d.ts +2 -1
  64. package/dist/types-ts4.5/index.d.ts +1 -0
  65. package/dist/types-ts4.5/plugin/block-types.d.ts +1 -0
  66. package/dist/types-ts4.5/plugin/commands/block-type.d.ts +8 -6
  67. package/dist/types-ts4.5/plugin/commands/index.d.ts +0 -5
  68. package/dist/types-ts4.5/plugin/index.d.ts +5 -2
  69. package/dist/types-ts4.5/plugin/pm-plugins/main.d.ts +3 -2
  70. package/dist/types-ts4.5/plugin/ui/ToolbarBlockType/blocktype-button.d.ts +0 -7
  71. package/dist/types-ts4.5/plugin/ui/ToolbarBlockType/index.d.ts +2 -1
  72. package/package.json +3 -4
  73. package/report.api.md +17 -1
  74. package/tmp/api-report-tmp.d.ts +7 -1
  75. package/dist/cjs/messages.js +0 -19
  76. package/dist/cjs/plugin/messages.js +0 -160
  77. package/dist/cjs/plugin/ui/ToolbarBlockType/toolbar-messages.js +0 -15
  78. package/dist/es2019/messages.js +0 -2
  79. package/dist/es2019/plugin/messages.js +0 -153
  80. package/dist/es2019/plugin/ui/ToolbarBlockType/toolbar-messages.js +0 -8
  81. package/dist/esm/messages.js +0 -2
  82. package/dist/esm/plugin/messages.js +0 -153
  83. package/dist/esm/plugin/ui/ToolbarBlockType/toolbar-messages.js +0 -8
  84. package/dist/types/messages.d.ts +0 -2
  85. package/dist/types/plugin/messages.d.ts +0 -152
  86. package/dist/types/plugin/ui/ToolbarBlockType/toolbar-messages.d.ts +0 -7
  87. package/dist/types-ts4.5/messages.d.ts +0 -2
  88. package/dist/types-ts4.5/plugin/messages.d.ts +0 -152
  89. package/dist/types-ts4.5/plugin/ui/ToolbarBlockType/toolbar-messages.d.ts +0 -7
  90. package/messages/package.json +0 -15
@@ -1,8 +1,3 @@
1
1
  export { cleanUpAtTheStartOfDocument, insertBlockQuoteWithAnalytics, setBlockType, setBlockTypeWithAnalytics, setHeadingWithAnalytics, setNormalText, setNormalTextWithAnalytics } from './block-type';
2
2
  export { deleteAndMoveCursor } from './delete-and-move-cursor';
3
- export { deleteBlockContent } from './delete-block-content';
4
- /**
5
- * @private
6
- * @deprecated use import from @atlaskit/editor-common/commands
7
- */
8
- export { setHeading } from '@atlaskit/editor-common/commands';
3
+ export { deleteBlockContent } from './delete-block-content';
@@ -3,12 +3,12 @@ import React from 'react';
3
3
  import { blockquote, hardBreak, heading } from '@atlaskit/adf-schema';
4
4
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
5
5
  import { keymap, toggleBlockQuote, tooltip } from '@atlaskit/editor-common/keymaps';
6
+ import { blockTypeMessages as messages } from '@atlaskit/editor-common/messages';
6
7
  import { IconHeading, IconQuote } from '@atlaskit/editor-common/quick-insert';
7
8
  import { ToolbarSize } from '@atlaskit/editor-common/types';
8
9
  import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
9
10
  import { setBlockTypeWithAnalytics } from './commands';
10
11
  import { insertBlockQuoteWithAnalytics } from './commands/block-type';
11
- import { messages } from './messages';
12
12
  import inputRulePlugin from './pm-plugins/input-rule';
13
13
  import keymapPlugin from './pm-plugins/keymap';
14
14
  import { createPlugin, pluginKey } from './pm-plugins/main';
@@ -44,7 +44,7 @@ var headingPluginOptions = function headingPluginOptions(_ref, isAllowed, editor
44
44
  var tr = insert(state.schema.nodes.heading.createChecked({
45
45
  level: level
46
46
  }));
47
- editorAnalyticsApi === null || editorAnalyticsApi === void 0 ? void 0 : editorAnalyticsApi.attachAnalyticsEvent({
47
+ editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.attachAnalyticsEvent({
48
48
  action: ACTION.FORMATTED,
49
49
  actionSubject: ACTION_SUBJECT.TEXT,
50
50
  eventType: EVENT_TYPE.TRACK,
@@ -75,7 +75,7 @@ var blockquotePluginOptions = function blockquotePluginOptions(_ref2, isAllowed,
75
75
  },
76
76
  action: function action(insert, state) {
77
77
  var tr = insert(state.schema.nodes.blockquote.createChecked({}, state.schema.nodes.paragraph.createChecked()));
78
- editorAnalyticsApi === null || editorAnalyticsApi === void 0 ? void 0 : editorAnalyticsApi.attachAnalyticsEvent({
78
+ editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.attachAnalyticsEvent({
79
79
  action: ACTION.FORMATTED,
80
80
  actionSubject: ACTION_SUBJECT.TEXT,
81
81
  eventType: EVENT_TYPE.TRACK,
@@ -116,17 +116,16 @@ var blockTypePlugin = function blockTypePlugin(_ref3) {
116
116
  return [{
117
117
  name: 'blockType',
118
118
  plugin: function plugin(_ref4) {
119
- var _api$analytics;
120
119
  var dispatch = _ref4.dispatch;
121
- return createPlugin(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, dispatch, options && options.lastNodeMustBeParagraph);
120
+ return createPlugin(api, dispatch, options && options.lastNodeMustBeParagraph);
122
121
  }
123
122
  }, {
124
123
  name: 'blockTypeInputRule',
125
124
  plugin: function plugin(_ref5) {
126
- var _api$analytics2;
125
+ var _api$analytics;
127
126
  var schema = _ref5.schema,
128
127
  featureFlags = _ref5.featureFlags;
129
- return inputRulePlugin(api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, schema, featureFlags);
128
+ return inputRulePlugin(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, schema, featureFlags);
130
129
  }
131
130
  },
132
131
  // Needs to be lower priority than editor-tables.tableEditing
@@ -134,21 +133,23 @@ var blockTypePlugin = function blockTypePlugin(_ref3) {
134
133
  {
135
134
  name: 'blockTypeKeyMap',
136
135
  plugin: function plugin(_ref6) {
137
- var _api$analytics3;
136
+ var _api$analytics2;
138
137
  var schema = _ref6.schema,
139
138
  featureFlags = _ref6.featureFlags;
140
- return keymapPlugin(api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions, schema, featureFlags);
139
+ return keymapPlugin(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, schema, featureFlags);
141
140
  }
142
141
  }];
143
142
  },
144
143
  actions: {
145
144
  insertBlockQuote: function insertBlockQuote(inputMethod) {
145
+ var _api$analytics3;
146
+ return insertBlockQuoteWithAnalytics(inputMethod, api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions);
147
+ }
148
+ },
149
+ commands: {
150
+ setTextLevel: function setTextLevel(level, inputMethod) {
146
151
  var _api$analytics4;
147
- return insertBlockQuoteWithAnalytics(inputMethod, api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions);
148
- },
149
- setBlockType: function setBlockType(name, inputMethod) {
150
- var _api$analytics5;
151
- return setBlockTypeWithAnalytics(name, inputMethod, api === null || api === void 0 ? void 0 : (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions);
152
+ return setBlockTypeWithAnalytics(level, inputMethod, api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions);
152
153
  }
153
154
  },
154
155
  getSharedState: function getSharedState(editorState) {
@@ -168,8 +169,8 @@ var blockTypePlugin = function blockTypePlugin(_ref3) {
168
169
  eventDispatcher = _ref7.eventDispatcher;
169
170
  var isSmall = options && options.isUndoRedoButtonsEnabled ? toolbarSize < ToolbarSize.XXL : toolbarSize < ToolbarSize.XL;
170
171
  var boundSetBlockType = function boundSetBlockType(name) {
171
- var _api$analytics6;
172
- return setBlockTypeWithAnalytics(name, INPUT_METHOD.TOOLBAR, api === null || api === void 0 ? void 0 : (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : _api$analytics6.actions)(editorView.state, editorView.dispatch);
172
+ var _api$analytics5;
173
+ 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));
173
174
  };
174
175
  return /*#__PURE__*/React.createElement(WithPluginState, {
175
176
  editorView: editorView,
@@ -183,7 +184,7 @@ var blockTypePlugin = function blockTypePlugin(_ref3) {
183
184
  isSmall: isSmall,
184
185
  isDisabled: disabled,
185
186
  isReducedSpacing: isToolbarReducedSpacing,
186
- setBlockType: boundSetBlockType,
187
+ setTextLevel: boundSetBlockType,
187
188
  pluginState: pluginState,
188
189
  popupsMountPoint: popupsMountPoint,
189
190
  popupsBoundariesElement: popupsBoundariesElement,
@@ -194,9 +195,9 @@ var blockTypePlugin = function blockTypePlugin(_ref3) {
194
195
  },
195
196
  pluginsOptions: {
196
197
  quickInsert: function quickInsert(intl) {
197
- var _api$analytics7, _api$analytics8;
198
+ var _api$analytics6, _api$analytics7;
198
199
  var exclude = options && options.allowBlockType && options.allowBlockType.exclude ? options.allowBlockType.exclude : [];
199
- return [].concat(_toConsumableArray(blockquotePluginOptions(intl, exclude.indexOf('blockquote') === -1, api === null || api === void 0 ? void 0 : (_api$analytics7 = api.analytics) === null || _api$analytics7 === void 0 ? void 0 : _api$analytics7.actions)), _toConsumableArray(headingPluginOptions(intl, exclude.indexOf('heading') === -1, api === null || api === void 0 ? void 0 : (_api$analytics8 = api.analytics) === null || _api$analytics8 === void 0 ? void 0 : _api$analytics8.actions)));
200
+ 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)));
200
201
  }
201
202
  }
202
203
  };
@@ -63,16 +63,16 @@ var detectBlockType = function detectBlockType(availableBlockTypes, state) {
63
63
  });
64
64
  return blockType || OTHER;
65
65
  };
66
- var autoformatHeading = function autoformatHeading(headingLevel, view, editorAnalyticsApi) {
66
+ var autoformatHeading = function autoformatHeading(headingLevel, editorAnalyticsApi) {
67
67
  if (headingLevel === 0) {
68
- setNormalTextWithAnalytics(INPUT_METHOD.FORMATTING, editorAnalyticsApi)(view.state, view.dispatch);
69
- } else {
70
- setHeadingWithAnalytics(headingLevel, INPUT_METHOD.FORMATTING, editorAnalyticsApi)(view.state, view.dispatch);
68
+ return setNormalTextWithAnalytics(INPUT_METHOD.FORMATTING, editorAnalyticsApi);
71
69
  }
72
- return true;
70
+ return setHeadingWithAnalytics(headingLevel, INPUT_METHOD.FORMATTING, editorAnalyticsApi);
73
71
  };
74
72
  export var pluginKey = new PluginKey('blockTypePlugin');
75
- export var createPlugin = function createPlugin(editorAnalyticsApi, dispatch, lastNodeMustBeParagraph) {
73
+ export var createPlugin = function createPlugin(editorAPI, dispatch, lastNodeMustBeParagraph) {
74
+ var _editorAPI$analytics;
75
+ var editorAnalyticsApi = editorAPI === null || editorAPI === void 0 || (_editorAPI$analytics = editorAPI.analytics) === null || _editorAPI$analytics === void 0 ? void 0 : _editorAPI$analytics.actions;
76
76
  var altKeyLocation = 0;
77
77
  return new SafePlugin({
78
78
  appendTransaction: function appendTransaction(_transactions, _oldState, newState) {
@@ -123,9 +123,11 @@ export var createPlugin = function createPlugin(editorAnalyticsApi, dispatch, la
123
123
  var headingLevel = HEADING_KEYS.indexOf(event.keyCode);
124
124
  if (headingLevel > -1 && event.altKey) {
125
125
  if (browser.mac && event.metaKey) {
126
- return autoformatHeading(headingLevel, view, editorAnalyticsApi);
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;
127
128
  } else if (!browser.mac && event.ctrlKey && altKeyLocation !== event.DOM_KEY_LOCATION_RIGHT) {
128
- return autoformatHeading(headingLevel, view, editorAnalyticsApi);
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
131
  }
130
132
  } else if (event.key === 'Alt') {
131
133
  // event.location is for the current key only; when a user hits Ctrl-Alt-1 the
@@ -1,22 +1,16 @@
1
1
  /** @jsx jsx */
2
2
  import React from 'react';
3
3
  import { jsx } from '@emotion/react';
4
- import { defineMessages, FormattedMessage } from 'react-intl-next';
4
+ import { FormattedMessage } from 'react-intl-next';
5
+ import { toolbarMessages } from '@atlaskit/editor-common/messages';
5
6
  import { wrapperStyle } from '@atlaskit/editor-common/styles';
6
7
  import { ToolbarButton } from '@atlaskit/editor-common/ui-menu';
7
8
  import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
8
9
  import TextStyleIcon from '@atlaskit/icon/glyph/editor/text-style';
9
10
  import { NORMAL_TEXT } from '../../block-types';
10
11
  import { buttonContentReducedSpacingStyle, buttonContentStyle, expandIconWrapperStyle, wrapperSmallStyle } from './styled';
11
- export var messages = defineMessages({
12
- textStyles: {
13
- id: 'fabric.editor.textStyles',
14
- defaultMessage: 'Text styles',
15
- description: 'Menu provides access to various heading styles or normal text'
16
- }
17
- });
18
12
  export var BlockTypeButton = function BlockTypeButton(props) {
19
- var labelTextStyles = props.formatMessage(messages.textStyles);
13
+ var labelTextStyles = props.formatMessage(toolbarMessages.textStyles);
20
14
  return jsx(ToolbarButton, {
21
15
  spacing: props.isReducedSpacing ? 'none' : 'default',
22
16
  selected: props.selected,
@@ -94,7 +94,7 @@ var ToolbarBlockType = /*#__PURE__*/function (_React$PureComponent) {
94
94
  _ref$shouldCloseMenu = _ref.shouldCloseMenu,
95
95
  shouldCloseMenu = _ref$shouldCloseMenu === void 0 ? true : _ref$shouldCloseMenu;
96
96
  var blockType = item.value;
97
- _this.props.setBlockType(blockType.name);
97
+ _this.props.setTextLevel(blockType.name);
98
98
  if (shouldCloseMenu) {
99
99
  _this.setState(_objectSpread(_objectSpread({}, _this.state), {}, {
100
100
  active: false
@@ -4,3 +4,4 @@ export type { BlockTypePluginOptions, BlockType } from './plugin/types';
4
4
  export type { BlockTypeState } from './plugin/pm-plugins/main';
5
5
  export type { InputMethod } from './plugin/commands';
6
6
  export type { DropdownItem } from './plugin/ui/ToolbarBlockType';
7
+ export type { TextBlockTypes } from './plugin/block-types';
@@ -11,6 +11,7 @@ export declare const CODE_BLOCK: BlockType;
11
11
  export declare const PANEL: BlockType;
12
12
  export declare const OTHER: BlockType;
13
13
  export declare const TEXT_BLOCK_TYPES: BlockType[];
14
+ export type TextBlockTypes = 'normal' | 'heading1' | 'heading2' | 'heading3' | 'heading4' | 'heading5' | 'heading6';
14
15
  export declare const WRAPPER_BLOCK_TYPES: BlockType[];
15
16
  export declare const ALL_BLOCK_TYPES: BlockType[];
16
17
  export declare const HEADINGS_BY_LEVEL: Record<number, BlockType>;
@@ -1,11 +1,13 @@
1
1
  import type { EditorAnalyticsAPI, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
- import type { Command, HeadingLevelsAndNormalText } from '@atlaskit/editor-common/types';
2
+ import type { Command, EditorCommand, HeadingLevelsAndNormalText } from '@atlaskit/editor-common/types';
3
+ import type { TextBlockTypes } from '../block-types';
3
4
  export type InputMethod = INPUT_METHOD.TOOLBAR | INPUT_METHOD.INSERT_MENU | INPUT_METHOD.SHORTCUT | INPUT_METHOD.FORMATTING | INPUT_METHOD.KEYBOARD;
4
- export declare function setBlockType(name: string): Command;
5
- export declare function setBlockTypeWithAnalytics(name: string, inputMethod: InputMethod, editorAnalyticsApi: EditorAnalyticsAPI | undefined): Command;
6
- export declare function setNormalText(): Command;
7
- export declare function setNormalTextWithAnalytics(inputMethod: InputMethod, editorAnalyticsApi: EditorAnalyticsAPI | undefined): Command;
8
- export declare const setHeadingWithAnalytics: (newHeadingLevel: HeadingLevelsAndNormalText, inputMethod: InputMethod, editorAnalyticsApi: EditorAnalyticsAPI | undefined) => Command;
5
+ export declare function setBlockType(name: TextBlockTypes): EditorCommand;
6
+ export declare function setHeading(level: HeadingLevelsAndNormalText): EditorCommand;
7
+ export declare function setBlockTypeWithAnalytics(name: TextBlockTypes, inputMethod: InputMethod, editorAnalyticsApi: EditorAnalyticsAPI | undefined): EditorCommand;
8
+ export declare function setNormalText(): EditorCommand;
9
+ export declare function setNormalTextWithAnalytics(inputMethod: InputMethod, editorAnalyticsApi: EditorAnalyticsAPI | undefined): EditorCommand;
10
+ export declare const setHeadingWithAnalytics: (newHeadingLevel: HeadingLevelsAndNormalText, inputMethod: InputMethod, editorAnalyticsApi: EditorAnalyticsAPI | undefined) => EditorCommand;
9
11
  /**
10
12
  *
11
13
  * @param name - block type name
@@ -2,8 +2,3 @@ export { cleanUpAtTheStartOfDocument, insertBlockQuoteWithAnalytics, setBlockTyp
2
2
  export type { InputMethod } from './block-type';
3
3
  export { deleteAndMoveCursor } from './delete-and-move-cursor';
4
4
  export { deleteBlockContent } from './delete-block-content';
5
- /**
6
- * @private
7
- * @deprecated use import from @atlaskit/editor-common/commands
8
- */
9
- export { setHeading } from '@atlaskit/editor-common/commands';
@@ -1,5 +1,6 @@
1
- import type { Command, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
1
+ import type { Command, EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
2
  import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
3
+ import type { TextBlockTypes } from './block-types';
3
4
  import type { InputMethod } from './commands/block-type';
4
5
  import type { BlockTypeState } from './pm-plugins/main';
5
6
  import type { BlockTypePluginOptions } from './types';
@@ -9,7 +10,9 @@ export type BlockTypePlugin = NextEditorPlugin<'blockType', {
9
10
  sharedState: BlockTypeState | undefined;
10
11
  actions: {
11
12
  insertBlockQuote: (inputMethod: InputMethod) => Command;
12
- setBlockType: (name: string, inputMethod: InputMethod) => Command;
13
+ };
14
+ commands: {
15
+ setTextLevel: (level: TextBlockTypes, inputMethod: InputMethod) => EditorCommand;
13
16
  };
14
17
  }>;
15
18
  declare const blockTypePlugin: BlockTypePlugin;
@@ -1,6 +1,7 @@
1
- import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
3
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
4
+ import type { BlockTypePlugin } from '../index';
4
5
  import type { BlockType } from '../types';
5
6
  export type BlockTypeState = {
6
7
  currentBlockType: BlockType;
@@ -9,7 +10,7 @@ export type BlockTypeState = {
9
10
  availableWrapperBlockTypes: BlockType[];
10
11
  };
11
12
  export declare const pluginKey: PluginKey<BlockTypeState>;
12
- export declare const createPlugin: (editorAnalyticsApi: EditorAnalyticsAPI | undefined, dispatch: (eventName: string | PluginKey, data: any) => void, lastNodeMustBeParagraph?: boolean) => SafePlugin<{
13
+ export declare const createPlugin: (editorAPI: ExtractInjectionAPI<BlockTypePlugin> | undefined, dispatch: (eventName: string | PluginKey, data: any) => void, lastNodeMustBeParagraph?: boolean) => SafePlugin<{
13
14
  currentBlockType: BlockType;
14
15
  blockTypesDisabled: boolean;
15
16
  availableBlockTypes: BlockType[];
@@ -12,11 +12,4 @@ export interface BlockTypeButtonProps {
12
12
  onKeyDown(e: React.KeyboardEvent): void;
13
13
  formatMessage: WrappedComponentProps['intl']['formatMessage'];
14
14
  }
15
- export declare const messages: {
16
- textStyles: {
17
- id: string;
18
- defaultMessage: string;
19
- description: string;
20
- };
21
- };
22
15
  export declare const BlockTypeButton: React.StatelessComponent<BlockTypeButtonProps>;
@@ -3,6 +3,7 @@ import React from 'react';
3
3
  import type { WrappedComponentProps } from 'react-intl-next';
4
4
  import type { MenuItem } from '@atlaskit/editor-common/ui-menu';
5
5
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
+ import type { TextBlockTypes } from '../../block-types';
6
7
  import type { BlockTypeState } from '../../pm-plugins/main';
7
8
  import type { BlockType } from '../../types';
8
9
  export type DropdownItem = MenuItem & {
@@ -17,7 +18,7 @@ export interface Props {
17
18
  popupsBoundariesElement?: HTMLElement;
18
19
  popupsScrollableElement?: HTMLElement;
19
20
  editorView?: EditorView;
20
- setBlockType: (type: string) => void;
21
+ setTextLevel: (type: TextBlockTypes) => void;
21
22
  }
22
23
  export interface State {
23
24
  active: boolean;
@@ -4,3 +4,4 @@ export type { BlockTypePluginOptions, BlockType } from './plugin/types';
4
4
  export type { BlockTypeState } from './plugin/pm-plugins/main';
5
5
  export type { InputMethod } from './plugin/commands';
6
6
  export type { DropdownItem } from './plugin/ui/ToolbarBlockType';
7
+ export type { TextBlockTypes } from './plugin/block-types';
@@ -11,6 +11,7 @@ export declare const CODE_BLOCK: BlockType;
11
11
  export declare const PANEL: BlockType;
12
12
  export declare const OTHER: BlockType;
13
13
  export declare const TEXT_BLOCK_TYPES: BlockType[];
14
+ export type TextBlockTypes = 'normal' | 'heading1' | 'heading2' | 'heading3' | 'heading4' | 'heading5' | 'heading6';
14
15
  export declare const WRAPPER_BLOCK_TYPES: BlockType[];
15
16
  export declare const ALL_BLOCK_TYPES: BlockType[];
16
17
  export declare const HEADINGS_BY_LEVEL: Record<number, BlockType>;
@@ -1,11 +1,13 @@
1
1
  import type { EditorAnalyticsAPI, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
- import type { Command, HeadingLevelsAndNormalText } from '@atlaskit/editor-common/types';
2
+ import type { Command, EditorCommand, HeadingLevelsAndNormalText } from '@atlaskit/editor-common/types';
3
+ import type { TextBlockTypes } from '../block-types';
3
4
  export type InputMethod = INPUT_METHOD.TOOLBAR | INPUT_METHOD.INSERT_MENU | INPUT_METHOD.SHORTCUT | INPUT_METHOD.FORMATTING | INPUT_METHOD.KEYBOARD;
4
- export declare function setBlockType(name: string): Command;
5
- export declare function setBlockTypeWithAnalytics(name: string, inputMethod: InputMethod, editorAnalyticsApi: EditorAnalyticsAPI | undefined): Command;
6
- export declare function setNormalText(): Command;
7
- export declare function setNormalTextWithAnalytics(inputMethod: InputMethod, editorAnalyticsApi: EditorAnalyticsAPI | undefined): Command;
8
- export declare const setHeadingWithAnalytics: (newHeadingLevel: HeadingLevelsAndNormalText, inputMethod: InputMethod, editorAnalyticsApi: EditorAnalyticsAPI | undefined) => Command;
5
+ export declare function setBlockType(name: TextBlockTypes): EditorCommand;
6
+ export declare function setHeading(level: HeadingLevelsAndNormalText): EditorCommand;
7
+ export declare function setBlockTypeWithAnalytics(name: TextBlockTypes, inputMethod: InputMethod, editorAnalyticsApi: EditorAnalyticsAPI | undefined): EditorCommand;
8
+ export declare function setNormalText(): EditorCommand;
9
+ export declare function setNormalTextWithAnalytics(inputMethod: InputMethod, editorAnalyticsApi: EditorAnalyticsAPI | undefined): EditorCommand;
10
+ export declare const setHeadingWithAnalytics: (newHeadingLevel: HeadingLevelsAndNormalText, inputMethod: InputMethod, editorAnalyticsApi: EditorAnalyticsAPI | undefined) => EditorCommand;
9
11
  /**
10
12
  *
11
13
  * @param name - block type name
@@ -2,8 +2,3 @@ export { cleanUpAtTheStartOfDocument, insertBlockQuoteWithAnalytics, setBlockTyp
2
2
  export type { InputMethod } from './block-type';
3
3
  export { deleteAndMoveCursor } from './delete-and-move-cursor';
4
4
  export { deleteBlockContent } from './delete-block-content';
5
- /**
6
- * @private
7
- * @deprecated use import from @atlaskit/editor-common/commands
8
- */
9
- export { setHeading } from '@atlaskit/editor-common/commands';
@@ -1,5 +1,6 @@
1
- import type { Command, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
1
+ import type { Command, EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
2
  import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
3
+ import type { TextBlockTypes } from './block-types';
3
4
  import type { InputMethod } from './commands/block-type';
4
5
  import type { BlockTypeState } from './pm-plugins/main';
5
6
  import type { BlockTypePluginOptions } from './types';
@@ -11,7 +12,9 @@ export type BlockTypePlugin = NextEditorPlugin<'blockType', {
11
12
  sharedState: BlockTypeState | undefined;
12
13
  actions: {
13
14
  insertBlockQuote: (inputMethod: InputMethod) => Command;
14
- setBlockType: (name: string, inputMethod: InputMethod) => Command;
15
+ };
16
+ commands: {
17
+ setTextLevel: (level: TextBlockTypes, inputMethod: InputMethod) => EditorCommand;
15
18
  };
16
19
  }>;
17
20
  declare const blockTypePlugin: BlockTypePlugin;
@@ -1,6 +1,7 @@
1
- import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
3
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
4
+ import type { BlockTypePlugin } from '../index';
4
5
  import type { BlockType } from '../types';
5
6
  export type BlockTypeState = {
6
7
  currentBlockType: BlockType;
@@ -9,7 +10,7 @@ export type BlockTypeState = {
9
10
  availableWrapperBlockTypes: BlockType[];
10
11
  };
11
12
  export declare const pluginKey: PluginKey<BlockTypeState>;
12
- export declare const createPlugin: (editorAnalyticsApi: EditorAnalyticsAPI | undefined, dispatch: (eventName: string | PluginKey, data: any) => void, lastNodeMustBeParagraph?: boolean) => SafePlugin<{
13
+ export declare const createPlugin: (editorAPI: ExtractInjectionAPI<BlockTypePlugin> | undefined, dispatch: (eventName: string | PluginKey, data: any) => void, lastNodeMustBeParagraph?: boolean) => SafePlugin<{
13
14
  currentBlockType: BlockType;
14
15
  blockTypesDisabled: boolean;
15
16
  availableBlockTypes: BlockType[];
@@ -12,11 +12,4 @@ export interface BlockTypeButtonProps {
12
12
  onKeyDown(e: React.KeyboardEvent): void;
13
13
  formatMessage: WrappedComponentProps['intl']['formatMessage'];
14
14
  }
15
- export declare const messages: {
16
- textStyles: {
17
- id: string;
18
- defaultMessage: string;
19
- description: string;
20
- };
21
- };
22
15
  export declare const BlockTypeButton: React.StatelessComponent<BlockTypeButtonProps>;
@@ -3,6 +3,7 @@ import React from 'react';
3
3
  import type { WrappedComponentProps } from 'react-intl-next';
4
4
  import type { MenuItem } from '@atlaskit/editor-common/ui-menu';
5
5
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
+ import type { TextBlockTypes } from '../../block-types';
6
7
  import type { BlockTypeState } from '../../pm-plugins/main';
7
8
  import type { BlockType } from '../../types';
8
9
  export type DropdownItem = MenuItem & {
@@ -17,7 +18,7 @@ export interface Props {
17
18
  popupsBoundariesElement?: HTMLElement;
18
19
  popupsScrollableElement?: HTMLElement;
19
20
  editorView?: EditorView;
20
- setBlockType: (type: string) => void;
21
+ setTextLevel: (type: TextBlockTypes) => void;
21
22
  }
22
23
  export interface State {
23
24
  active: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-type",
3
- "version": "1.0.3",
3
+ "version": "3.0.0",
4
4
  "description": "BlockType plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -34,12 +34,11 @@
34
34
  "af:exports": {
35
35
  ".": "./src/index.ts",
36
36
  "./consts": "./src/consts.ts",
37
- "./messages": "./src/messages.ts",
38
37
  "./styles": "./src/styles.ts"
39
38
  },
40
39
  "dependencies": {
41
40
  "@atlaskit/adf-schema": "^32.0.0",
42
- "@atlaskit/editor-common": "^76.1.0",
41
+ "@atlaskit/editor-common": "^76.15.0",
43
42
  "@atlaskit/editor-plugin-analytics": "^0.2.0",
44
43
  "@atlaskit/editor-prosemirror": "1.1.0",
45
44
  "@atlaskit/editor-shared-styles": "^2.8.0",
@@ -47,7 +46,7 @@
47
46
  "@atlaskit/icon": "^21.12.0",
48
47
  "@atlaskit/prosemirror-input-rules": "^2.4.0",
49
48
  "@atlaskit/theme": "^12.6.0",
50
- "@atlaskit/tokens": "^1.25.0",
49
+ "@atlaskit/tokens": "^1.28.0",
51
50
  "@babel/runtime": "^7.0.0",
52
51
  "@emotion/react": "^11.7.1"
53
52
  },
package/report.api.md CHANGED
@@ -18,6 +18,7 @@
18
18
  import type { AllowedBlockTypes } from '@atlaskit/editor-common/types';
19
19
  import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
20
20
  import type { Command } from '@atlaskit/editor-common/types';
21
+ import type { EditorCommand } from '@atlaskit/editor-common/types';
21
22
  import type { HeadingLevelsAndNormalText } from '@atlaskit/editor-common/types';
22
23
  import type { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
23
24
  import type { MenuItem } from '@atlaskit/editor-common/ui-menu';
@@ -48,7 +49,12 @@ export type BlockTypePlugin = NextEditorPlugin<
48
49
  sharedState: BlockTypeState | undefined;
49
50
  actions: {
50
51
  insertBlockQuote: (inputMethod: InputMethod) => Command;
51
- setBlockType: (name: string, inputMethod: InputMethod) => Command;
52
+ };
53
+ commands: {
54
+ setTextLevel: (
55
+ level: TextBlockTypes,
56
+ inputMethod: InputMethod,
57
+ ) => EditorCommand;
52
58
  };
53
59
  }
54
60
  >;
@@ -89,6 +95,16 @@ export type InputMethod =
89
95
  | INPUT_METHOD.SHORTCUT
90
96
  | INPUT_METHOD.TOOLBAR;
91
97
 
98
+ // @public (undocumented)
99
+ export type TextBlockTypes =
100
+ | 'heading1'
101
+ | 'heading2'
102
+ | 'heading3'
103
+ | 'heading4'
104
+ | 'heading5'
105
+ | 'heading6'
106
+ | 'normal';
107
+
92
108
  // (No @packageDocumentation comment for this package)
93
109
  ```
94
110
 
@@ -7,6 +7,7 @@
7
7
  import type { AllowedBlockTypes } from '@atlaskit/editor-common/types';
8
8
  import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
9
9
  import type { Command } from '@atlaskit/editor-common/types';
10
+ import type { EditorCommand } from '@atlaskit/editor-common/types';
10
11
  import type { HeadingLevelsAndNormalText } from '@atlaskit/editor-common/types';
11
12
  import type { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
12
13
  import type { MenuItem } from '@atlaskit/editor-common/ui-menu';
@@ -35,7 +36,9 @@ export type BlockTypePlugin = NextEditorPlugin<'blockType', {
35
36
  sharedState: BlockTypeState | undefined;
36
37
  actions: {
37
38
  insertBlockQuote: (inputMethod: InputMethod) => Command;
38
- setBlockType: (name: string, inputMethod: InputMethod) => Command;
39
+ };
40
+ commands: {
41
+ setTextLevel: (level: TextBlockTypes, inputMethod: InputMethod) => EditorCommand;
39
42
  };
40
43
  }>;
41
44
 
@@ -70,6 +73,9 @@ export type DropdownItem = MenuItem & {
70
73
  // @public (undocumented)
71
74
  export type InputMethod = INPUT_METHOD.FORMATTING | INPUT_METHOD.INSERT_MENU | INPUT_METHOD.KEYBOARD | INPUT_METHOD.SHORTCUT | INPUT_METHOD.TOOLBAR;
72
75
 
76
+ // @public (undocumented)
77
+ export type TextBlockTypes = 'heading1' | 'heading2' | 'heading3' | 'heading4' | 'heading5' | 'heading6' | 'normal';
78
+
73
79
  // (No @packageDocumentation comment for this package)
74
80
 
75
81
  ```
@@ -1,19 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "messages", {
7
- enumerable: true,
8
- get: function get() {
9
- return _messages.messages;
10
- }
11
- });
12
- Object.defineProperty(exports, "toolbarMessages", {
13
- enumerable: true,
14
- get: function get() {
15
- return _toolbarMessages.toolbarMessages;
16
- }
17
- });
18
- var _messages = require("./plugin/messages");
19
- var _toolbarMessages = require("./plugin/ui/ToolbarBlockType/toolbar-messages");