@atlaskit/editor-plugin-block-type 18.0.5 → 19.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @atlaskit/editor-plugin-block-type
2
2
 
3
+ ## 19.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`4273da2e1a648`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4273da2e1a648) -
8
+ Register native Quick Insert items behind `platform_editor_slash_command`.
9
+ - Updated dependencies
10
+
11
+ ## 19.0.0
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies
16
+
3
17
  ## 18.0.5
4
18
 
5
19
  ### Patch Changes
package/compass.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  configVersion: 1
2
2
  id: ari:cloud:compass:a436116f-02ce-4520-8fbb-7301462a1674:component/c5751cc6-3513-4070-9deb-af31e86aed34/cb1603f9-3837-498f-a3d0-4452521a95a9
3
3
  name: '@atlaskit/editor-plugin-block-type'
4
- ownerId: ari:cloud:identity::team/ce353f56-2a90-491b-b272-b90dca4fffa2 # Editor FE Platform
4
+ ownerId: ari:cloud:identity::team/cf6a670b-5252-4c68-a769-9207de366beb # Editor Developers
5
5
  labels:
6
6
  - platform-code
7
7
  - platform-afm
@@ -16,14 +16,14 @@ links:
16
16
  url: https://bitbucket.org/atlassian/atlassian-frontend-monorepo/src/master
17
17
  - name: Slack Channel
18
18
  type: CHAT_CHANNEL
19
- url: https://atlassian.enterprise.slack.com/archives/C03SD6QJWPP # #cc-editor-lego
19
+ url: https://atlassian.enterprise.slack.com/archives/CFG3PSQ9E # #help-editor
20
20
  - name: Editor Plugin Block Type
21
21
  type: REPOSITORY
22
22
  url: https://bitbucket.org/atlassian/atlassian-frontend-monorepo/src/master/platform/packages/editor/editor-plugin-block-type
23
23
  customFields:
24
24
  - name: Department
25
25
  type: text
26
- value: Eng - Editor Frontend Platform
26
+ value: Editor Developers
27
27
  - name: Trusted Reviewer Teams
28
28
  type: text
29
29
  value: ari:cloud:identity::team/cf6a670b-5252-4c68-a769-9207de366beb
@@ -12,9 +12,10 @@ var _adfSchema = require("@atlaskit/adf-schema");
12
12
  var _analytics = require("@atlaskit/editor-common/analytics");
13
13
  var _keymaps = require("@atlaskit/editor-common/keymaps");
14
14
  var _messages = require("@atlaskit/editor-common/messages");
15
- var _quickInsert = require("@atlaskit/editor-common/quick-insert");
15
+ var _assets = require("@atlaskit/editor-common/assets");
16
16
  var _types = require("@atlaskit/editor-common/types");
17
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
17
+ var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
18
+ var _fg = require("@atlaskit/platform-feature-flags/fg");
18
19
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
19
20
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
20
21
  var _blockType = require("./pm-plugins/commands/block-type");
@@ -25,6 +26,7 @@ var _FloatingToolbarComponent = require("./pm-plugins/ui/FloatingToolbarComponen
25
26
  var _PrimaryToolbarComponent = require("./pm-plugins/ui/PrimaryToolbarComponent");
26
27
  var _toolbarComponents = require("./pm-plugins/ui/toolbar-components");
27
28
  var _ui = require("./ui");
29
+ var _getBlockTypeQuickInsertComponents = require("./ui/quick-insert/getBlockTypeQuickInsertComponents");
28
30
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
29
31
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
30
32
  var headingPluginOptions = function headingPluginOptions(_ref, isAllowed, editorAnalyticsApi) {
@@ -50,7 +52,7 @@ var headingPluginOptions = function headingPluginOptions(_ref, isAllowed, editor
50
52
  keywords: ["h".concat(level)],
51
53
  keyshortcut: keyshortcut,
52
54
  icon: function icon() {
53
- return /*#__PURE__*/_react.default.createElement(_quickInsert.IconHeading, {
55
+ return /*#__PURE__*/_react.default.createElement(_assets.IconHeading, {
54
56
  level: level
55
57
  });
56
58
  },
@@ -85,7 +87,7 @@ var blockquotePluginOptions = function blockquotePluginOptions(_ref2, isAllowed,
85
87
  priority: 1300,
86
88
  keyshortcut: '>',
87
89
  icon: function icon() {
88
- return /*#__PURE__*/_react.default.createElement(_quickInsert.IconQuote, null);
90
+ return /*#__PURE__*/_react.default.createElement(_assets.IconQuote, null);
89
91
  },
90
92
  action: function action(insert, state) {
91
93
  var tr = insert(state.schema.nodes.blockquote.createChecked({}, state.schema.nodes.paragraph.createChecked()));
@@ -106,6 +108,7 @@ var blockTypePlugin = exports.blockTypePlugin = function blockTypePlugin(_ref3)
106
108
  var options = _ref3.config,
107
109
  api = _ref3.api;
108
110
  var isToolbarAIFCEnabled = Boolean(api === null || api === void 0 ? void 0 : api.toolbar);
111
+ var isRegisteredSlashCommandEnabled = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_slash_command');
109
112
  var primaryToolbarComponent = function primaryToolbarComponent(_ref4) {
110
113
  var popupsMountPoint = _ref4.popupsMountPoint,
111
114
  popupsBoundariesElement = _ref4.popupsBoundariesElement,
@@ -114,7 +117,7 @@ var blockTypePlugin = exports.blockTypePlugin = function blockTypePlugin(_ref3)
114
117
  disabled = _ref4.disabled,
115
118
  isToolbarReducedSpacing = _ref4.isToolbarReducedSpacing;
116
119
  var isSmall = options && options.isUndoRedoButtonsEnabled ? toolbarSize < _types.ToolbarSize.XXL : toolbarSize < _types.ToolbarSize.XL;
117
- if ((0, _platformFeatureFlags.fg)('platform_editor_toolbar_responsive_fixes')) {
120
+ if ((0, _fg.fg)('platform_editor_toolbar_responsive_fixes')) {
118
121
  isSmall = toolbarSize < _types.ToolbarSize.XXL;
119
122
  }
120
123
  return /*#__PURE__*/_react.default.createElement(_PrimaryToolbarComponent.PrimaryToolbarComponent, {
@@ -142,6 +145,13 @@ var blockTypePlugin = exports.blockTypePlugin = function blockTypePlugin(_ref3)
142
145
  var _api$blockMenu;
143
146
  api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 || _api$blockMenu.actions.registerBlockMenuComponents((0, _ui.getBlockTypeComponents)(api));
144
147
  }
148
+ if (isRegisteredSlashCommandEnabled) {
149
+ var _api$uiControlRegistr, _options$allowBlockTy, _options$allowBlockTy2;
150
+ api === null || api === void 0 || (_api$uiControlRegistr = api.uiControlRegistry) === null || _api$uiControlRegistr === void 0 || _api$uiControlRegistr.actions.register((0, _getBlockTypeQuickInsertComponents.getBlockTypeQuickInsertComponents)({
151
+ api: api,
152
+ exclude: (_options$allowBlockTy = options === null || options === void 0 || (_options$allowBlockTy2 = options.allowBlockType) === null || _options$allowBlockTy2 === void 0 ? void 0 : _options$allowBlockTy2.exclude) !== null && _options$allowBlockTy !== void 0 ? _options$allowBlockTy : []
153
+ }));
154
+ }
145
155
  return {
146
156
  name: 'blockType',
147
157
  nodes: function nodes() {
@@ -150,7 +160,7 @@ var blockTypePlugin = exports.blockTypePlugin = function blockTypePlugin(_ref3)
150
160
  node: _adfSchema.heading
151
161
  }, {
152
162
  name: 'blockquote',
153
- node: (0, _platformFeatureFlags.fg)('platform_editor_adf_with_localid') ? _adfSchema.extendedBlockquoteWithLocalId : _adfSchema.extendedBlockquote
163
+ node: (0, _fg.fg)('platform_editor_adf_with_localid') ? _adfSchema.extendedBlockquoteWithLocalId : _adfSchema.extendedBlockquote
154
164
  }, {
155
165
  name: 'hardBreak',
156
166
  node: _adfSchema.hardBreak
@@ -231,7 +241,7 @@ var blockTypePlugin = exports.blockTypePlugin = function blockTypePlugin(_ref3)
231
241
  pluginsOptions: _objectSpread(_objectSpread({}, !isToolbarAIFCEnabled && {
232
242
  selectionToolbar: function selectionToolbar() {
233
243
  var _api$userPreferences, _api$selectionToolbar;
234
- var toolbarDocking = (0, _platformFeatureFlags.fg)('platform_editor_use_preferences_plugin') ? api === null || api === void 0 || (_api$userPreferences = api.userPreferences) === null || _api$userPreferences === void 0 || (_api$userPreferences = _api$userPreferences.sharedState.currentState()) === null || _api$userPreferences === void 0 || (_api$userPreferences = _api$userPreferences.preferences) === null || _api$userPreferences === void 0 ? void 0 : _api$userPreferences.toolbarDockingPosition : api === null || api === void 0 || (_api$selectionToolbar = api.selectionToolbar) === null || _api$selectionToolbar === void 0 || (_api$selectionToolbar = _api$selectionToolbar.sharedState) === null || _api$selectionToolbar === void 0 || (_api$selectionToolbar = _api$selectionToolbar.currentState()) === null || _api$selectionToolbar === void 0 ? void 0 : _api$selectionToolbar.toolbarDocking;
244
+ var toolbarDocking = (0, _fg.fg)('platform_editor_use_preferences_plugin') ? api === null || api === void 0 || (_api$userPreferences = api.userPreferences) === null || _api$userPreferences === void 0 || (_api$userPreferences = _api$userPreferences.sharedState.currentState()) === null || _api$userPreferences === void 0 || (_api$userPreferences = _api$userPreferences.preferences) === null || _api$userPreferences === void 0 ? void 0 : _api$userPreferences.toolbarDockingPosition : api === null || api === void 0 || (_api$selectionToolbar = api.selectionToolbar) === null || _api$selectionToolbar === void 0 || (_api$selectionToolbar = _api$selectionToolbar.sharedState) === null || _api$selectionToolbar === void 0 || (_api$selectionToolbar = _api$selectionToolbar.currentState()) === null || _api$selectionToolbar === void 0 ? void 0 : _api$selectionToolbar.toolbarDocking;
235
245
  if (toolbarDocking === 'none' && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1', {
236
246
  exposure: true
237
247
  })) {
@@ -256,7 +266,7 @@ var blockTypePlugin = exports.blockTypePlugin = function blockTypePlugin(_ref3)
256
266
  return undefined;
257
267
  }
258
268
  }
259
- }), {}, {
269
+ }), !isRegisteredSlashCommandEnabled && {
260
270
  quickInsert: function quickInsert(intl) {
261
271
  var _api$analytics7, _api$analytics8;
262
272
  var exclude = options && options.allowBlockType && options.allowBlockType.exclude ? options.allowBlockType.exclude : [];
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+
3
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.getHeadingQuickInsertShortcut = exports.getHeadingQuickInsertMessages = exports.BlockTypeQuickInsertMenuItem = void 0;
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _reactIntl = require("react-intl");
10
+ var _analytics = require("@atlaskit/editor-common/analytics");
11
+ var _keymaps = require("@atlaskit/editor-common/keymaps");
12
+ var _messages = require("@atlaskit/editor-common/messages");
13
+ var _assets = require("@atlaskit/editor-common/assets");
14
+ var _menuItem = require("@atlaskit/editor-common/quick-insert/menu-item");
15
+ var _tooltip, _tooltip2, _tooltip3, _tooltip4, _tooltip5, _tooltip6;
16
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
17
+ var headingQuickInsertMessages = {
18
+ 1: {
19
+ description: _messages.blockTypeMessages.heading1Description,
20
+ title: _messages.blockTypeMessages.heading1
21
+ },
22
+ 2: {
23
+ description: _messages.blockTypeMessages.heading2Description,
24
+ title: _messages.blockTypeMessages.heading2
25
+ },
26
+ 3: {
27
+ description: _messages.blockTypeMessages.heading3Description,
28
+ title: _messages.blockTypeMessages.heading3
29
+ },
30
+ 4: {
31
+ description: _messages.blockTypeMessages.heading4Description,
32
+ title: _messages.blockTypeMessages.heading4
33
+ },
34
+ 5: {
35
+ description: _messages.blockTypeMessages.heading5Description,
36
+ title: _messages.blockTypeMessages.heading5
37
+ },
38
+ 6: {
39
+ description: _messages.blockTypeMessages.heading6Description,
40
+ title: _messages.blockTypeMessages.heading6
41
+ }
42
+ };
43
+ var headingQuickInsertShortcuts = {
44
+ 1: (_tooltip = (0, _keymaps.tooltip)(_keymaps.toggleHeading1)) !== null && _tooltip !== void 0 ? _tooltip : '',
45
+ 2: (_tooltip2 = (0, _keymaps.tooltip)(_keymaps.toggleHeading2)) !== null && _tooltip2 !== void 0 ? _tooltip2 : '',
46
+ 3: (_tooltip3 = (0, _keymaps.tooltip)(_keymaps.toggleHeading3)) !== null && _tooltip3 !== void 0 ? _tooltip3 : '',
47
+ 4: (_tooltip4 = (0, _keymaps.tooltip)(_keymaps.toggleHeading4)) !== null && _tooltip4 !== void 0 ? _tooltip4 : '',
48
+ 5: (_tooltip5 = (0, _keymaps.tooltip)(_keymaps.toggleHeading5)) !== null && _tooltip5 !== void 0 ? _tooltip5 : '',
49
+ 6: (_tooltip6 = (0, _keymaps.tooltip)(_keymaps.toggleHeading6)) !== null && _tooltip6 !== void 0 ? _tooltip6 : ''
50
+ };
51
+ var getHeadingQuickInsertMessages = exports.getHeadingQuickInsertMessages = function getHeadingQuickInsertMessages(level) {
52
+ return headingQuickInsertMessages[level];
53
+ };
54
+ var getHeadingQuickInsertShortcut = exports.getHeadingQuickInsertShortcut = function getHeadingQuickInsertShortcut(level) {
55
+ return headingQuickInsertShortcuts[level];
56
+ };
57
+ var BlockTypeQuickInsertMenuItem = exports.BlockTypeQuickInsertMenuItem = function BlockTypeQuickInsertMenuItem(_ref) {
58
+ var api = _ref.api,
59
+ item = _ref.item;
60
+ var _useIntl = (0, _reactIntl.useIntl)(),
61
+ formatMessage = _useIntl.formatMessage;
62
+ var isBlockquote = item === 'blockquote';
63
+ var shortcut = (0, _react.useMemo)(function () {
64
+ return isBlockquote ? '>' : getHeadingQuickInsertShortcut(item);
65
+ }, [isBlockquote, item]);
66
+ var title = formatMessage(item === 'blockquote' ? _messages.blockTypeMessages.blockquote : getHeadingQuickInsertMessages(item).title);
67
+ var onSelect = (0, _react.useCallback)(function (_ref2) {
68
+ var editorView = _ref2.editorView,
69
+ insert = _ref2.insert;
70
+ var schema = editorView.state.schema;
71
+ var tr = isBlockquote ? insert(schema.nodes.blockquote.createChecked({}, schema.nodes.paragraph.createChecked())) : insert(schema.nodes.heading.createChecked({
72
+ level: item
73
+ }));
74
+ if (item === 'blockquote') {
75
+ var _api$analytics;
76
+ api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
77
+ action: _analytics.ACTION.FORMATTED,
78
+ actionSubject: _analytics.ACTION_SUBJECT.TEXT,
79
+ actionSubjectId: _analytics.ACTION_SUBJECT_ID.FORMAT_BLOCK_QUOTE,
80
+ attributes: {
81
+ inputMethod: _analytics.INPUT_METHOD.QUICK_INSERT
82
+ },
83
+ eventType: _analytics.EVENT_TYPE.TRACK
84
+ })(tr);
85
+ } else {
86
+ var _api$analytics2;
87
+ api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || _api$analytics2.actions.attachAnalyticsEvent({
88
+ action: _analytics.ACTION.FORMATTED,
89
+ actionSubject: _analytics.ACTION_SUBJECT.TEXT,
90
+ actionSubjectId: _analytics.ACTION_SUBJECT_ID.FORMAT_HEADING,
91
+ attributes: {
92
+ inputMethod: _analytics.INPUT_METHOD.QUICK_INSERT,
93
+ newHeadingLevel: item
94
+ },
95
+ eventType: _analytics.EVENT_TYPE.TRACK
96
+ })(tr);
97
+ }
98
+ return tr;
99
+ }, [api, isBlockquote, item]);
100
+ return /*#__PURE__*/_react.default.createElement(_menuItem.QuickInsertMenuItem, {
101
+ iconBefore: isBlockquote ? /*#__PURE__*/_react.default.createElement(_assets.IconQuote, null) : /*#__PURE__*/_react.default.createElement(_assets.IconHeading, {
102
+ level: item
103
+ }),
104
+ onSelect: onSelect,
105
+ shortcut: shortcut,
106
+ title: title
107
+ });
108
+ };
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.getBlockTypeQuickInsertComponents = void 0;
8
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
+ var _react = _interopRequireDefault(require("react"));
10
+ var _messages = require("@atlaskit/editor-common/messages");
11
+ var _createQuickInsertMatcher = require("@atlaskit/editor-common/quick-insert/create-quick-insert-matcher");
12
+ var _keys = require("@atlaskit/editor-common/quick-insert/keys");
13
+ var _rank = require("@atlaskit/editor-common/quick-insert/rank");
14
+ var _BlockTypeQuickInsertMenuItem = require("./BlockTypeQuickInsertMenuItem");
15
+ var headingItems = [{
16
+ item: _keys.HEADING_1_MENU_ITEM,
17
+ level: 1
18
+ }, {
19
+ item: _keys.HEADING_2_MENU_ITEM,
20
+ level: 2
21
+ }, {
22
+ item: _keys.HEADING_3_MENU_ITEM,
23
+ level: 3
24
+ }, {
25
+ item: _keys.HEADING_4_MENU_ITEM,
26
+ level: 4
27
+ }, {
28
+ item: _keys.HEADING_5_MENU_ITEM,
29
+ level: 5
30
+ }, {
31
+ item: _keys.HEADING_6_MENU_ITEM,
32
+ level: 6
33
+ }];
34
+ var getParent = function getParent(key) {
35
+ return [{
36
+ key: _keys.TEXT_FORMATTING_SECTION.key,
37
+ type: _keys.TEXT_FORMATTING_SECTION.type,
38
+ rank: _rank.TEXT_FORMATTING_SECTION_RANK[key]
39
+ }];
40
+ };
41
+ var getBlockTypeQuickInsertComponents = exports.getBlockTypeQuickInsertComponents = function getBlockTypeQuickInsertComponents(_ref) {
42
+ var api = _ref.api,
43
+ exclude = _ref.exclude;
44
+ return [].concat((0, _toConsumableArray2.default)(headingItems.filter(function () {
45
+ return !exclude.includes('heading');
46
+ }).map(function (_ref2) {
47
+ var item = _ref2.item,
48
+ headingLevel = _ref2.level;
49
+ var headingMessages = (0, _BlockTypeQuickInsertMenuItem.getHeadingQuickInsertMessages)(headingLevel);
50
+ return {
51
+ key: item.key,
52
+ type: item.type,
53
+ parents: getParent(item.key),
54
+ match: (0, _createQuickInsertMatcher.createQuickInsertMatcher)(function (_ref3) {
55
+ var formatMessage = _ref3.formatMessage;
56
+ return {
57
+ description: formatMessage(headingMessages.description),
58
+ keywords: ["h".concat(headingLevel)],
59
+ shortcut: (0, _BlockTypeQuickInsertMenuItem.getHeadingQuickInsertShortcut)(headingLevel),
60
+ title: formatMessage(headingMessages.title)
61
+ };
62
+ }),
63
+ component: function component() {
64
+ return /*#__PURE__*/_react.default.createElement(_BlockTypeQuickInsertMenuItem.BlockTypeQuickInsertMenuItem, {
65
+ api: api,
66
+ item: headingLevel
67
+ });
68
+ }
69
+ };
70
+ })), (0, _toConsumableArray2.default)(!exclude.includes('blockquote') ? [{
71
+ key: _keys.BLOCKQUOTE_MENU_ITEM.key,
72
+ type: _keys.BLOCKQUOTE_MENU_ITEM.type,
73
+ parents: getParent(_keys.BLOCKQUOTE_MENU_ITEM.key),
74
+ match: (0, _createQuickInsertMatcher.createQuickInsertMatcher)(function (_ref4) {
75
+ var formatMessage = _ref4.formatMessage;
76
+ return {
77
+ description: formatMessage(_messages.blockTypeMessages.blockquoteDescription),
78
+ shortcut: '>',
79
+ title: formatMessage(_messages.blockTypeMessages.blockquote)
80
+ };
81
+ }),
82
+ component: function component() {
83
+ return /*#__PURE__*/_react.default.createElement(_BlockTypeQuickInsertMenuItem.BlockTypeQuickInsertMenuItem, {
84
+ api: api,
85
+ item: "blockquote"
86
+ });
87
+ }
88
+ }] : []));
89
+ };
@@ -3,9 +3,10 @@ import { extendedBlockquote, extendedBlockquoteWithLocalId, fontSize, hardBreak,
3
3
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
4
  import { keymap, tooltip } from '@atlaskit/editor-common/keymaps';
5
5
  import { blockTypeMessages as messages } from '@atlaskit/editor-common/messages';
6
- import { IconHeading, IconQuote } from '@atlaskit/editor-common/quick-insert';
6
+ import { IconHeading, IconQuote } from '@atlaskit/editor-common/assets';
7
7
  import { ToolbarSize } from '@atlaskit/editor-common/types';
8
- import { fg } from '@atlaskit/platform-feature-flags';
8
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
9
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
9
10
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
10
11
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
11
12
  import { clearFormatting, insertBlockQuoteWithAnalytics, insertBlockQuoteWithAnalyticsCommand, setBlockTypeWithAnalytics } from './pm-plugins/commands/block-type';
@@ -16,6 +17,7 @@ import { FloatingToolbarComponent } from './pm-plugins/ui/FloatingToolbarCompone
16
17
  import { PrimaryToolbarComponent } from './pm-plugins/ui/PrimaryToolbarComponent';
17
18
  import { getToolbarComponents } from './pm-plugins/ui/toolbar-components';
18
19
  import { getBlockTypeComponents } from './ui';
20
+ import { getBlockTypeQuickInsertComponents } from './ui/quick-insert/getBlockTypeQuickInsertComponents';
19
21
  const headingPluginOptions = ({
20
22
  formatMessage
21
23
  }, isAllowed, editorAnalyticsApi) => {
@@ -94,6 +96,7 @@ const blockTypePlugin = ({
94
96
  api
95
97
  }) => {
96
98
  const isToolbarAIFCEnabled = Boolean(api === null || api === void 0 ? void 0 : api.toolbar);
99
+ const isRegisteredSlashCommandEnabled = isExperimentEnabled('platform_editor_slash_command');
97
100
  const primaryToolbarComponent = ({
98
101
  popupsMountPoint,
99
102
  popupsBoundariesElement,
@@ -131,6 +134,13 @@ const blockTypePlugin = ({
131
134
  var _api$blockMenu;
132
135
  api === null || api === void 0 ? void 0 : (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 ? void 0 : _api$blockMenu.actions.registerBlockMenuComponents(getBlockTypeComponents(api));
133
136
  }
137
+ if (isRegisteredSlashCommandEnabled) {
138
+ var _api$uiControlRegistr, _options$allowBlockTy, _options$allowBlockTy2;
139
+ api === null || api === void 0 ? void 0 : (_api$uiControlRegistr = api.uiControlRegistry) === null || _api$uiControlRegistr === void 0 ? void 0 : _api$uiControlRegistr.actions.register(getBlockTypeQuickInsertComponents({
140
+ api,
141
+ exclude: (_options$allowBlockTy = options === null || options === void 0 ? void 0 : (_options$allowBlockTy2 = options.allowBlockType) === null || _options$allowBlockTy2 === void 0 ? void 0 : _options$allowBlockTy2.exclude) !== null && _options$allowBlockTy !== void 0 ? _options$allowBlockTy : []
142
+ }));
143
+ }
134
144
  return {
135
145
  name: 'blockType',
136
146
  nodes() {
@@ -245,11 +255,13 @@ const blockTypePlugin = ({
245
255
  }
246
256
  }
247
257
  }),
248
- quickInsert: intl => {
249
- var _api$analytics7, _api$analytics8;
250
- const exclude = options && options.allowBlockType && options.allowBlockType.exclude ? options.allowBlockType.exclude : [];
251
- return [...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), ...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)];
252
- }
258
+ ...(!isRegisteredSlashCommandEnabled && {
259
+ quickInsert: intl => {
260
+ var _api$analytics7, _api$analytics8;
261
+ const exclude = options && options.allowBlockType && options.allowBlockType.exclude ? options.allowBlockType.exclude : [];
262
+ return [...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), ...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)];
263
+ }
264
+ })
253
265
  }
254
266
  };
255
267
  };
@@ -0,0 +1,99 @@
1
+ var _tooltip, _tooltip2, _tooltip3, _tooltip4, _tooltip5, _tooltip6;
2
+ import React, { useCallback, useMemo } from 'react';
3
+ import { useIntl } from 'react-intl';
4
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
5
+ import { toggleHeading1, toggleHeading2, toggleHeading3, toggleHeading4, toggleHeading5, toggleHeading6, tooltip } from '@atlaskit/editor-common/keymaps';
6
+ import { blockTypeMessages as messages } from '@atlaskit/editor-common/messages';
7
+ import { IconHeading, IconQuote } from '@atlaskit/editor-common/assets';
8
+ import { QuickInsertMenuItem } from '@atlaskit/editor-common/quick-insert/menu-item';
9
+ const headingQuickInsertMessages = {
10
+ 1: {
11
+ description: messages.heading1Description,
12
+ title: messages.heading1
13
+ },
14
+ 2: {
15
+ description: messages.heading2Description,
16
+ title: messages.heading2
17
+ },
18
+ 3: {
19
+ description: messages.heading3Description,
20
+ title: messages.heading3
21
+ },
22
+ 4: {
23
+ description: messages.heading4Description,
24
+ title: messages.heading4
25
+ },
26
+ 5: {
27
+ description: messages.heading5Description,
28
+ title: messages.heading5
29
+ },
30
+ 6: {
31
+ description: messages.heading6Description,
32
+ title: messages.heading6
33
+ }
34
+ };
35
+ const headingQuickInsertShortcuts = {
36
+ 1: (_tooltip = tooltip(toggleHeading1)) !== null && _tooltip !== void 0 ? _tooltip : '',
37
+ 2: (_tooltip2 = tooltip(toggleHeading2)) !== null && _tooltip2 !== void 0 ? _tooltip2 : '',
38
+ 3: (_tooltip3 = tooltip(toggleHeading3)) !== null && _tooltip3 !== void 0 ? _tooltip3 : '',
39
+ 4: (_tooltip4 = tooltip(toggleHeading4)) !== null && _tooltip4 !== void 0 ? _tooltip4 : '',
40
+ 5: (_tooltip5 = tooltip(toggleHeading5)) !== null && _tooltip5 !== void 0 ? _tooltip5 : '',
41
+ 6: (_tooltip6 = tooltip(toggleHeading6)) !== null && _tooltip6 !== void 0 ? _tooltip6 : ''
42
+ };
43
+ export const getHeadingQuickInsertMessages = level => headingQuickInsertMessages[level];
44
+ export const getHeadingQuickInsertShortcut = level => headingQuickInsertShortcuts[level];
45
+ export const BlockTypeQuickInsertMenuItem = ({
46
+ api,
47
+ item
48
+ }) => {
49
+ const {
50
+ formatMessage
51
+ } = useIntl();
52
+ const isBlockquote = item === 'blockquote';
53
+ const shortcut = useMemo(() => isBlockquote ? '>' : getHeadingQuickInsertShortcut(item), [isBlockquote, item]);
54
+ const title = formatMessage(item === 'blockquote' ? messages.blockquote : getHeadingQuickInsertMessages(item).title);
55
+ const onSelect = useCallback(({
56
+ editorView,
57
+ insert
58
+ }) => {
59
+ const {
60
+ schema
61
+ } = editorView.state;
62
+ const tr = isBlockquote ? insert(schema.nodes.blockquote.createChecked({}, schema.nodes.paragraph.createChecked())) : insert(schema.nodes.heading.createChecked({
63
+ level: item
64
+ }));
65
+ if (item === 'blockquote') {
66
+ var _api$analytics;
67
+ api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.attachAnalyticsEvent({
68
+ action: ACTION.FORMATTED,
69
+ actionSubject: ACTION_SUBJECT.TEXT,
70
+ actionSubjectId: ACTION_SUBJECT_ID.FORMAT_BLOCK_QUOTE,
71
+ attributes: {
72
+ inputMethod: INPUT_METHOD.QUICK_INSERT
73
+ },
74
+ eventType: EVENT_TYPE.TRACK
75
+ })(tr);
76
+ } else {
77
+ var _api$analytics2;
78
+ api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions.attachAnalyticsEvent({
79
+ action: ACTION.FORMATTED,
80
+ actionSubject: ACTION_SUBJECT.TEXT,
81
+ actionSubjectId: ACTION_SUBJECT_ID.FORMAT_HEADING,
82
+ attributes: {
83
+ inputMethod: INPUT_METHOD.QUICK_INSERT,
84
+ newHeadingLevel: item
85
+ },
86
+ eventType: EVENT_TYPE.TRACK
87
+ })(tr);
88
+ }
89
+ return tr;
90
+ }, [api, isBlockquote, item]);
91
+ return /*#__PURE__*/React.createElement(QuickInsertMenuItem, {
92
+ iconBefore: isBlockquote ? /*#__PURE__*/React.createElement(IconQuote, null) : /*#__PURE__*/React.createElement(IconHeading, {
93
+ level: item
94
+ }),
95
+ onSelect: onSelect,
96
+ shortcut: shortcut,
97
+ title: title
98
+ });
99
+ };
@@ -0,0 +1,71 @@
1
+ import React from 'react';
2
+ import { blockTypeMessages as messages } from '@atlaskit/editor-common/messages';
3
+ import { createQuickInsertMatcher } from '@atlaskit/editor-common/quick-insert/create-quick-insert-matcher';
4
+ import { BLOCKQUOTE_MENU_ITEM, HEADING_1_MENU_ITEM, HEADING_2_MENU_ITEM, HEADING_3_MENU_ITEM, HEADING_4_MENU_ITEM, HEADING_5_MENU_ITEM, HEADING_6_MENU_ITEM, TEXT_FORMATTING_SECTION } from '@atlaskit/editor-common/quick-insert/keys';
5
+ import { TEXT_FORMATTING_SECTION_RANK } from '@atlaskit/editor-common/quick-insert/rank';
6
+ import { BlockTypeQuickInsertMenuItem, getHeadingQuickInsertMessages, getHeadingQuickInsertShortcut } from './BlockTypeQuickInsertMenuItem';
7
+ const headingItems = [{
8
+ item: HEADING_1_MENU_ITEM,
9
+ level: 1
10
+ }, {
11
+ item: HEADING_2_MENU_ITEM,
12
+ level: 2
13
+ }, {
14
+ item: HEADING_3_MENU_ITEM,
15
+ level: 3
16
+ }, {
17
+ item: HEADING_4_MENU_ITEM,
18
+ level: 4
19
+ }, {
20
+ item: HEADING_5_MENU_ITEM,
21
+ level: 5
22
+ }, {
23
+ item: HEADING_6_MENU_ITEM,
24
+ level: 6
25
+ }];
26
+ const getParent = key => [{
27
+ key: TEXT_FORMATTING_SECTION.key,
28
+ type: TEXT_FORMATTING_SECTION.type,
29
+ rank: TEXT_FORMATTING_SECTION_RANK[key]
30
+ }];
31
+ export const getBlockTypeQuickInsertComponents = ({
32
+ api,
33
+ exclude
34
+ }) => [...headingItems.filter(() => !exclude.includes('heading')).map(({
35
+ item,
36
+ level: headingLevel
37
+ }) => {
38
+ const headingMessages = getHeadingQuickInsertMessages(headingLevel);
39
+ return {
40
+ key: item.key,
41
+ type: item.type,
42
+ parents: getParent(item.key),
43
+ match: createQuickInsertMatcher(({
44
+ formatMessage
45
+ }) => ({
46
+ description: formatMessage(headingMessages.description),
47
+ keywords: [`h${headingLevel}`],
48
+ shortcut: getHeadingQuickInsertShortcut(headingLevel),
49
+ title: formatMessage(headingMessages.title)
50
+ })),
51
+ component: () => /*#__PURE__*/React.createElement(BlockTypeQuickInsertMenuItem, {
52
+ api: api,
53
+ item: headingLevel
54
+ })
55
+ };
56
+ }), ...(!exclude.includes('blockquote') ? [{
57
+ key: BLOCKQUOTE_MENU_ITEM.key,
58
+ type: BLOCKQUOTE_MENU_ITEM.type,
59
+ parents: getParent(BLOCKQUOTE_MENU_ITEM.key),
60
+ match: createQuickInsertMatcher(({
61
+ formatMessage
62
+ }) => ({
63
+ description: formatMessage(messages.blockquoteDescription),
64
+ shortcut: '>',
65
+ title: formatMessage(messages.blockquote)
66
+ })),
67
+ component: () => /*#__PURE__*/React.createElement(BlockTypeQuickInsertMenuItem, {
68
+ api: api,
69
+ item: "blockquote"
70
+ })
71
+ }] : [])];
@@ -7,9 +7,10 @@ import { extendedBlockquote, extendedBlockquoteWithLocalId, fontSize, hardBreak,
7
7
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
8
8
  import { keymap, tooltip } from '@atlaskit/editor-common/keymaps';
9
9
  import { blockTypeMessages as messages } from '@atlaskit/editor-common/messages';
10
- import { IconHeading, IconQuote } from '@atlaskit/editor-common/quick-insert';
10
+ import { IconHeading, IconQuote } from '@atlaskit/editor-common/assets';
11
11
  import { ToolbarSize } from '@atlaskit/editor-common/types';
12
- import { fg } from '@atlaskit/platform-feature-flags';
12
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
13
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
13
14
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
14
15
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
15
16
  import { clearFormatting as _clearFormatting, insertBlockQuoteWithAnalytics, insertBlockQuoteWithAnalyticsCommand, setBlockTypeWithAnalytics } from './pm-plugins/commands/block-type';
@@ -20,6 +21,7 @@ import { FloatingToolbarComponent } from './pm-plugins/ui/FloatingToolbarCompone
20
21
  import { PrimaryToolbarComponent } from './pm-plugins/ui/PrimaryToolbarComponent';
21
22
  import { getToolbarComponents } from './pm-plugins/ui/toolbar-components';
22
23
  import { getBlockTypeComponents } from './ui';
24
+ import { getBlockTypeQuickInsertComponents } from './ui/quick-insert/getBlockTypeQuickInsertComponents';
23
25
  var headingPluginOptions = function headingPluginOptions(_ref, isAllowed, editorAnalyticsApi) {
24
26
  var formatMessage = _ref.formatMessage;
25
27
  if (!isAllowed) {
@@ -99,6 +101,7 @@ var blockTypePlugin = function blockTypePlugin(_ref3) {
99
101
  var options = _ref3.config,
100
102
  api = _ref3.api;
101
103
  var isToolbarAIFCEnabled = Boolean(api === null || api === void 0 ? void 0 : api.toolbar);
104
+ var isRegisteredSlashCommandEnabled = isExperimentEnabled('platform_editor_slash_command');
102
105
  var primaryToolbarComponent = function primaryToolbarComponent(_ref4) {
103
106
  var popupsMountPoint = _ref4.popupsMountPoint,
104
107
  popupsBoundariesElement = _ref4.popupsBoundariesElement,
@@ -135,6 +138,13 @@ var blockTypePlugin = function blockTypePlugin(_ref3) {
135
138
  var _api$blockMenu;
136
139
  api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 || _api$blockMenu.actions.registerBlockMenuComponents(getBlockTypeComponents(api));
137
140
  }
141
+ if (isRegisteredSlashCommandEnabled) {
142
+ var _api$uiControlRegistr, _options$allowBlockTy, _options$allowBlockTy2;
143
+ api === null || api === void 0 || (_api$uiControlRegistr = api.uiControlRegistry) === null || _api$uiControlRegistr === void 0 || _api$uiControlRegistr.actions.register(getBlockTypeQuickInsertComponents({
144
+ api: api,
145
+ exclude: (_options$allowBlockTy = options === null || options === void 0 || (_options$allowBlockTy2 = options.allowBlockType) === null || _options$allowBlockTy2 === void 0 ? void 0 : _options$allowBlockTy2.exclude) !== null && _options$allowBlockTy !== void 0 ? _options$allowBlockTy : []
146
+ }));
147
+ }
138
148
  return {
139
149
  name: 'blockType',
140
150
  nodes: function nodes() {
@@ -249,7 +259,7 @@ var blockTypePlugin = function blockTypePlugin(_ref3) {
249
259
  return undefined;
250
260
  }
251
261
  }
252
- }), {}, {
262
+ }), !isRegisteredSlashCommandEnabled && {
253
263
  quickInsert: function quickInsert(intl) {
254
264
  var _api$analytics7, _api$analytics8;
255
265
  var exclude = options && options.allowBlockType && options.allowBlockType.exclude ? options.allowBlockType.exclude : [];
@@ -0,0 +1,100 @@
1
+ var _tooltip, _tooltip2, _tooltip3, _tooltip4, _tooltip5, _tooltip6;
2
+ import React, { useCallback, useMemo } from 'react';
3
+ import { useIntl } from 'react-intl';
4
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
5
+ import { toggleHeading1, toggleHeading2, toggleHeading3, toggleHeading4, toggleHeading5, toggleHeading6, tooltip } from '@atlaskit/editor-common/keymaps';
6
+ import { blockTypeMessages as messages } from '@atlaskit/editor-common/messages';
7
+ import { IconHeading, IconQuote } from '@atlaskit/editor-common/assets';
8
+ import { QuickInsertMenuItem } from '@atlaskit/editor-common/quick-insert/menu-item';
9
+ var headingQuickInsertMessages = {
10
+ 1: {
11
+ description: messages.heading1Description,
12
+ title: messages.heading1
13
+ },
14
+ 2: {
15
+ description: messages.heading2Description,
16
+ title: messages.heading2
17
+ },
18
+ 3: {
19
+ description: messages.heading3Description,
20
+ title: messages.heading3
21
+ },
22
+ 4: {
23
+ description: messages.heading4Description,
24
+ title: messages.heading4
25
+ },
26
+ 5: {
27
+ description: messages.heading5Description,
28
+ title: messages.heading5
29
+ },
30
+ 6: {
31
+ description: messages.heading6Description,
32
+ title: messages.heading6
33
+ }
34
+ };
35
+ var headingQuickInsertShortcuts = {
36
+ 1: (_tooltip = tooltip(toggleHeading1)) !== null && _tooltip !== void 0 ? _tooltip : '',
37
+ 2: (_tooltip2 = tooltip(toggleHeading2)) !== null && _tooltip2 !== void 0 ? _tooltip2 : '',
38
+ 3: (_tooltip3 = tooltip(toggleHeading3)) !== null && _tooltip3 !== void 0 ? _tooltip3 : '',
39
+ 4: (_tooltip4 = tooltip(toggleHeading4)) !== null && _tooltip4 !== void 0 ? _tooltip4 : '',
40
+ 5: (_tooltip5 = tooltip(toggleHeading5)) !== null && _tooltip5 !== void 0 ? _tooltip5 : '',
41
+ 6: (_tooltip6 = tooltip(toggleHeading6)) !== null && _tooltip6 !== void 0 ? _tooltip6 : ''
42
+ };
43
+ export var getHeadingQuickInsertMessages = function getHeadingQuickInsertMessages(level) {
44
+ return headingQuickInsertMessages[level];
45
+ };
46
+ export var getHeadingQuickInsertShortcut = function getHeadingQuickInsertShortcut(level) {
47
+ return headingQuickInsertShortcuts[level];
48
+ };
49
+ export var BlockTypeQuickInsertMenuItem = function BlockTypeQuickInsertMenuItem(_ref) {
50
+ var api = _ref.api,
51
+ item = _ref.item;
52
+ var _useIntl = useIntl(),
53
+ formatMessage = _useIntl.formatMessage;
54
+ var isBlockquote = item === 'blockquote';
55
+ var shortcut = useMemo(function () {
56
+ return isBlockquote ? '>' : getHeadingQuickInsertShortcut(item);
57
+ }, [isBlockquote, item]);
58
+ var title = formatMessage(item === 'blockquote' ? messages.blockquote : getHeadingQuickInsertMessages(item).title);
59
+ var onSelect = useCallback(function (_ref2) {
60
+ var editorView = _ref2.editorView,
61
+ insert = _ref2.insert;
62
+ var schema = editorView.state.schema;
63
+ var tr = isBlockquote ? insert(schema.nodes.blockquote.createChecked({}, schema.nodes.paragraph.createChecked())) : insert(schema.nodes.heading.createChecked({
64
+ level: item
65
+ }));
66
+ if (item === 'blockquote') {
67
+ var _api$analytics;
68
+ api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
69
+ action: ACTION.FORMATTED,
70
+ actionSubject: ACTION_SUBJECT.TEXT,
71
+ actionSubjectId: ACTION_SUBJECT_ID.FORMAT_BLOCK_QUOTE,
72
+ attributes: {
73
+ inputMethod: INPUT_METHOD.QUICK_INSERT
74
+ },
75
+ eventType: EVENT_TYPE.TRACK
76
+ })(tr);
77
+ } else {
78
+ var _api$analytics2;
79
+ api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || _api$analytics2.actions.attachAnalyticsEvent({
80
+ action: ACTION.FORMATTED,
81
+ actionSubject: ACTION_SUBJECT.TEXT,
82
+ actionSubjectId: ACTION_SUBJECT_ID.FORMAT_HEADING,
83
+ attributes: {
84
+ inputMethod: INPUT_METHOD.QUICK_INSERT,
85
+ newHeadingLevel: item
86
+ },
87
+ eventType: EVENT_TYPE.TRACK
88
+ })(tr);
89
+ }
90
+ return tr;
91
+ }, [api, isBlockquote, item]);
92
+ return /*#__PURE__*/React.createElement(QuickInsertMenuItem, {
93
+ iconBefore: isBlockquote ? /*#__PURE__*/React.createElement(IconQuote, null) : /*#__PURE__*/React.createElement(IconHeading, {
94
+ level: item
95
+ }),
96
+ onSelect: onSelect,
97
+ shortcut: shortcut,
98
+ title: title
99
+ });
100
+ };
@@ -0,0 +1,82 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import React from 'react';
3
+ import { blockTypeMessages as messages } from '@atlaskit/editor-common/messages';
4
+ import { createQuickInsertMatcher } from '@atlaskit/editor-common/quick-insert/create-quick-insert-matcher';
5
+ import { BLOCKQUOTE_MENU_ITEM, HEADING_1_MENU_ITEM, HEADING_2_MENU_ITEM, HEADING_3_MENU_ITEM, HEADING_4_MENU_ITEM, HEADING_5_MENU_ITEM, HEADING_6_MENU_ITEM, TEXT_FORMATTING_SECTION } from '@atlaskit/editor-common/quick-insert/keys';
6
+ import { TEXT_FORMATTING_SECTION_RANK } from '@atlaskit/editor-common/quick-insert/rank';
7
+ import { BlockTypeQuickInsertMenuItem, getHeadingQuickInsertMessages, getHeadingQuickInsertShortcut } from './BlockTypeQuickInsertMenuItem';
8
+ var headingItems = [{
9
+ item: HEADING_1_MENU_ITEM,
10
+ level: 1
11
+ }, {
12
+ item: HEADING_2_MENU_ITEM,
13
+ level: 2
14
+ }, {
15
+ item: HEADING_3_MENU_ITEM,
16
+ level: 3
17
+ }, {
18
+ item: HEADING_4_MENU_ITEM,
19
+ level: 4
20
+ }, {
21
+ item: HEADING_5_MENU_ITEM,
22
+ level: 5
23
+ }, {
24
+ item: HEADING_6_MENU_ITEM,
25
+ level: 6
26
+ }];
27
+ var getParent = function getParent(key) {
28
+ return [{
29
+ key: TEXT_FORMATTING_SECTION.key,
30
+ type: TEXT_FORMATTING_SECTION.type,
31
+ rank: TEXT_FORMATTING_SECTION_RANK[key]
32
+ }];
33
+ };
34
+ export var getBlockTypeQuickInsertComponents = function getBlockTypeQuickInsertComponents(_ref) {
35
+ var api = _ref.api,
36
+ exclude = _ref.exclude;
37
+ return [].concat(_toConsumableArray(headingItems.filter(function () {
38
+ return !exclude.includes('heading');
39
+ }).map(function (_ref2) {
40
+ var item = _ref2.item,
41
+ headingLevel = _ref2.level;
42
+ var headingMessages = getHeadingQuickInsertMessages(headingLevel);
43
+ return {
44
+ key: item.key,
45
+ type: item.type,
46
+ parents: getParent(item.key),
47
+ match: createQuickInsertMatcher(function (_ref3) {
48
+ var formatMessage = _ref3.formatMessage;
49
+ return {
50
+ description: formatMessage(headingMessages.description),
51
+ keywords: ["h".concat(headingLevel)],
52
+ shortcut: getHeadingQuickInsertShortcut(headingLevel),
53
+ title: formatMessage(headingMessages.title)
54
+ };
55
+ }),
56
+ component: function component() {
57
+ return /*#__PURE__*/React.createElement(BlockTypeQuickInsertMenuItem, {
58
+ api: api,
59
+ item: headingLevel
60
+ });
61
+ }
62
+ };
63
+ })), _toConsumableArray(!exclude.includes('blockquote') ? [{
64
+ key: BLOCKQUOTE_MENU_ITEM.key,
65
+ type: BLOCKQUOTE_MENU_ITEM.type,
66
+ parents: getParent(BLOCKQUOTE_MENU_ITEM.key),
67
+ match: createQuickInsertMatcher(function (_ref4) {
68
+ var formatMessage = _ref4.formatMessage;
69
+ return {
70
+ description: formatMessage(messages.blockquoteDescription),
71
+ shortcut: '>',
72
+ title: formatMessage(messages.blockquote)
73
+ };
74
+ }),
75
+ component: function component() {
76
+ return /*#__PURE__*/React.createElement(BlockTypeQuickInsertMenuItem, {
77
+ api: api,
78
+ item: "blockquote"
79
+ });
80
+ }
81
+ }] : []));
82
+ };
@@ -8,6 +8,7 @@ import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
8
8
  import type { SelectionToolbarPlugin } from '@atlaskit/editor-plugin-selection-toolbar';
9
9
  import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
10
10
  import type { UserPreferencesPlugin } from '@atlaskit/editor-plugin-user-preferences';
11
+ import type { UiControlRegistryPlugin } from '@atlaskit/editor-plugin-ui-control-registry';
11
12
  import type { TextBlockTypes } from './pm-plugins/block-types';
12
13
  import type { ClearFormattingInputMethod, InputMethod } from './pm-plugins/commands/block-type';
13
14
  import type { BlockTypeState } from './pm-plugins/main';
@@ -31,7 +32,8 @@ export type BlockTypePlugin = NextEditorPlugin<'blockType', {
31
32
  OptionalPlugin<ListPlugin>,
32
33
  OptionalPlugin<SelectionPlugin>,
33
34
  OptionalPlugin<InteractionPlugin>,
34
- OptionalPlugin<_MarkdownModePluginStub>
35
+ OptionalPlugin<_MarkdownModePluginStub>,
36
+ OptionalPlugin<UiControlRegistryPlugin>
35
37
  ];
36
38
  pluginConfiguration: BlockTypePluginOptions | undefined;
37
39
  sharedState: BlockTypeState | undefined;
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import type { MessageDescriptor } from 'react-intl';
3
+ import type { ExtractInjectionAPI, HeadingLevels } from '@atlaskit/editor-common/types';
4
+ import type { BlockTypePlugin } from '../../blockTypePluginType';
5
+ export type BlockTypeQuickInsertItem = 'blockquote' | HeadingLevels;
6
+ type Props = {
7
+ api: ExtractInjectionAPI<BlockTypePlugin> | undefined;
8
+ item: BlockTypeQuickInsertItem;
9
+ };
10
+ type HeadingQuickInsertMessages = {
11
+ description: MessageDescriptor;
12
+ title: MessageDescriptor;
13
+ };
14
+ export declare const getHeadingQuickInsertMessages: (level: HeadingLevels) => HeadingQuickInsertMessages;
15
+ export declare const getHeadingQuickInsertShortcut: (level: HeadingLevels) => string;
16
+ export declare const BlockTypeQuickInsertMenuItem: ({ api, item }: Props) => React.JSX.Element;
17
+ export {};
@@ -0,0 +1,9 @@
1
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
+ import type { RegisterMenuItem } from '@atlaskit/editor-ui-control-model/types';
3
+ import type { BlockTypePlugin } from '../../blockTypePluginType';
4
+ type Params = {
5
+ api: ExtractInjectionAPI<BlockTypePlugin> | undefined;
6
+ exclude: readonly string[];
7
+ };
8
+ export declare const getBlockTypeQuickInsertComponents: ({ api, exclude }: Params) => RegisterMenuItem[];
9
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-type",
3
- "version": "18.0.5",
3
+ "version": "19.0.1",
4
4
  "description": "BlockType plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -23,14 +23,14 @@
23
23
  "dependencies": {
24
24
  "@atlaskit/adf-schema": "^56.7.0",
25
25
  "@atlaskit/css": "^1.0.0",
26
- "@atlaskit/editor-plugin-analytics": "^14.0.0",
27
- "@atlaskit/editor-plugin-block-menu": "^13.0.0",
28
- "@atlaskit/editor-plugin-interaction": "^25.0.0",
29
- "@atlaskit/editor-plugin-list": "^16.0.0",
30
- "@atlaskit/editor-plugin-primary-toolbar": "^15.0.0",
31
- "@atlaskit/editor-plugin-selection": "^14.0.0",
32
- "@atlaskit/editor-plugin-selection-toolbar": "^15.0.0",
33
- "@atlaskit/editor-plugin-toolbar": "^11.0.0",
26
+ "@atlaskit/editor-plugin-analytics": "^15.0.0",
27
+ "@atlaskit/editor-plugin-block-menu": "^14.0.0",
28
+ "@atlaskit/editor-plugin-interaction": "^26.0.0",
29
+ "@atlaskit/editor-plugin-list": "^17.0.0",
30
+ "@atlaskit/editor-plugin-primary-toolbar": "^16.0.0",
31
+ "@atlaskit/editor-plugin-selection": "^15.0.0",
32
+ "@atlaskit/editor-plugin-selection-toolbar": "^16.0.0",
33
+ "@atlaskit/editor-plugin-toolbar": "^12.0.0",
34
34
  "@atlaskit/editor-prosemirror": "^8.0.0",
35
35
  "@atlaskit/editor-shared-styles": "^4.0.0",
36
36
  "@atlaskit/editor-tables": "^3.0.0",
@@ -43,14 +43,14 @@
43
43
  "@atlaskit/primitives": "^22.2.0",
44
44
  "@atlaskit/prosemirror-history": "^1.1.0",
45
45
  "@atlaskit/prosemirror-input-rules": "^4.0.0",
46
- "@atlaskit/tmp-editor-statsig": "^147.0.0",
46
+ "@atlaskit/tmp-editor-statsig": "^147.1.0",
47
47
  "@atlaskit/tokens": "^16.7.0",
48
48
  "@babel/runtime": "^7.0.0",
49
49
  "@compiled/react": "^1.0.2",
50
50
  "@emotion/react": "^11.7.1"
51
51
  },
52
52
  "peerDependencies": {
53
- "@atlaskit/editor-common": "^118.10.0",
53
+ "@atlaskit/editor-common": "^119.1.0",
54
54
  "react": "^18.2.0 || ^19.2.0",
55
55
  "react-dom": "^18.2.0 || ^19.2.0",
56
56
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"