@atlaskit/editor-plugin-block-type 21.0.1 → 21.0.4
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 +21 -0
- package/dist/cjs/blockTypePlugin.js +3 -1
- package/dist/cjs/ui/SmallTextBlockMenuItem.js +54 -0
- package/dist/cjs/ui/index.js +37 -10
- package/dist/cjs/ui/types.js +1 -0
- package/dist/es2019/blockTypePlugin.js +6 -2
- package/dist/es2019/ui/SmallTextBlockMenuItem.js +49 -0
- package/dist/es2019/ui/index.js +37 -12
- package/dist/es2019/ui/types.js +0 -0
- package/dist/esm/blockTypePlugin.js +3 -1
- package/dist/esm/ui/SmallTextBlockMenuItem.js +47 -0
- package/dist/esm/ui/index.js +37 -11
- package/dist/esm/ui/types.js +0 -0
- package/dist/types/ui/SmallTextBlockMenuItem.d.ts +10 -0
- package/dist/types/ui/index.d.ts +2 -1
- package/dist/types/ui/types.d.ts +5 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-type
|
|
2
2
|
|
|
3
|
+
## 21.0.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`ea8de35330d10`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ea8de35330d10) -
|
|
8
|
+
Register the gated Small text action in the block menu and hide it when the schema lacks font-size
|
|
9
|
+
support.
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 21.0.3
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
18
|
+
## 21.0.2
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies
|
|
23
|
+
|
|
3
24
|
## 21.0.1
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
|
@@ -146,7 +146,9 @@ var blockTypePlugin = exports.blockTypePlugin = function blockTypePlugin(_ref3)
|
|
|
146
146
|
}
|
|
147
147
|
if ((0, _editorExperiment.editorExperiment)('platform_editor_block_menu', true)) {
|
|
148
148
|
var _api$blockMenu;
|
|
149
|
-
api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 || _api$blockMenu.actions.registerBlockMenuComponents((0, _ui.getBlockTypeComponents)(api
|
|
149
|
+
api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 || _api$blockMenu.actions.registerBlockMenuComponents((0, _ui.getBlockTypeComponents)(api, {
|
|
150
|
+
allowFontSize: options === null || options === void 0 ? void 0 : options.allowFontSize
|
|
151
|
+
}));
|
|
150
152
|
}
|
|
151
153
|
if (isRegisteredSlashCommandEnabled) {
|
|
152
154
|
var _api$uiControlRegistr, _options$allowBlockTy, _options$allowBlockTy2;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.createSmallTextBlockMenuItem = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _reactIntl = require("react-intl");
|
|
10
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
11
|
+
var _messages = require("@atlaskit/editor-common/messages");
|
|
12
|
+
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
13
|
+
var NODE_NAME = 'paragraph';
|
|
14
|
+
var SmallTextBlockMenuItem = function SmallTextBlockMenuItem(_ref) {
|
|
15
|
+
var api = _ref.api,
|
|
16
|
+
isSuggested = _ref.isSuggested;
|
|
17
|
+
var _useIntl = (0, _reactIntl.useIntl)(),
|
|
18
|
+
formatMessage = _useIntl.formatMessage;
|
|
19
|
+
var handleClick = function handleClick(event) {
|
|
20
|
+
var triggeredFrom = event.nativeEvent instanceof KeyboardEvent || event.nativeEvent.detail === 0 ? _analytics.INPUT_METHOD.KEYBOARD : _analytics.INPUT_METHOD.MOUSE;
|
|
21
|
+
var inputMethod = _analytics.INPUT_METHOD.BLOCK_MENU;
|
|
22
|
+
api === null || api === void 0 || api.core.actions.execute(function (_ref2) {
|
|
23
|
+
var _api$blockMenu;
|
|
24
|
+
var tr = _ref2.tr;
|
|
25
|
+
var command = api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 ? void 0 : _api$blockMenu.commands.transformNode(tr.doc.type.schema.nodes.paragraph, {
|
|
26
|
+
inputMethod: inputMethod,
|
|
27
|
+
isSuggested: isSuggested,
|
|
28
|
+
triggeredFrom: triggeredFrom,
|
|
29
|
+
targetTypeName: NODE_NAME
|
|
30
|
+
});
|
|
31
|
+
return command ? command({
|
|
32
|
+
tr: tr
|
|
33
|
+
}) : null;
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
|
|
37
|
+
onClick: handleClick,
|
|
38
|
+
elemBefore: /*#__PURE__*/_react.default.createElement(_editorToolbar.TextSmallIcon, {
|
|
39
|
+
label: "",
|
|
40
|
+
size: "small"
|
|
41
|
+
})
|
|
42
|
+
}, formatMessage(_messages.blockTypeMessages.smallText));
|
|
43
|
+
};
|
|
44
|
+
var createSmallTextBlockMenuItem = exports.createSmallTextBlockMenuItem = function createSmallTextBlockMenuItem(_ref3) {
|
|
45
|
+
var api = _ref3.api;
|
|
46
|
+
return function () {
|
|
47
|
+
var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
48
|
+
isSuggested = _ref4.isSuggested;
|
|
49
|
+
return /*#__PURE__*/_react.default.createElement(SmallTextBlockMenuItem, {
|
|
50
|
+
api: api,
|
|
51
|
+
isSuggested: isSuggested
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
};
|
package/dist/cjs/ui/index.js
CHANGED
|
@@ -1,20 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.getBlockTypeComponents = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
7
9
|
var _blockMenu = require("@atlaskit/editor-common/block-menu");
|
|
10
|
+
var _key = require("@atlaskit/editor-common/block-menu/key");
|
|
8
11
|
var _rank = require("@atlaskit/editor-common/block-menu/rank");
|
|
9
12
|
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
10
13
|
var _HeadingBlockMenuItem = require("./HeadingBlockMenuItem");
|
|
11
14
|
var _ParagraphBlockMenuItem = require("./ParagraphBlockMenuItem");
|
|
12
15
|
var _QuoteBlockMenuItem = require("./QuoteBlockMenuItem");
|
|
16
|
+
var _SmallTextBlockMenuItem = require("./SmallTextBlockMenuItem");
|
|
13
17
|
var HEADING_NODE_NAME = 'heading';
|
|
14
18
|
var QUOTE_NODE_NAME = 'blockquote';
|
|
15
19
|
var PARAGRAPH_NODE_NAME = 'paragraph';
|
|
16
20
|
var getBlockTypeComponents = exports.getBlockTypeComponents = function getBlockTypeComponents(api) {
|
|
21
|
+
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
22
|
+
allowFontSize = _ref.allowFontSize,
|
|
23
|
+
isTextFormattingItemHidden = _ref.isHidden;
|
|
17
24
|
var isSmallTextExperimentEnabled = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_menu_small_text');
|
|
25
|
+
var isSmallTextEnabled = Boolean(allowFontSize && isSmallTextExperimentEnabled);
|
|
18
26
|
var textFormattingRank = isSmallTextExperimentEnabled ? _rank.TRANSFORM_TEXT_FORMATTING_MENU_SECTION_RANK : _blockMenu.TRANSFORM_HEADINGS_MENU_SECTION_RANK;
|
|
19
27
|
var isTransformHeadingDisabled = function isTransformHeadingDisabled(level) {
|
|
20
28
|
var _api$blockMenu;
|
|
@@ -27,7 +35,7 @@ var getBlockTypeComponents = exports.getBlockTypeComponents = function getBlockT
|
|
|
27
35
|
key: _blockMenu.TRANSFORM_HEADINGS_H1_MENU_ITEM.key,
|
|
28
36
|
parent: {
|
|
29
37
|
type: 'block-menu-section',
|
|
30
|
-
key:
|
|
38
|
+
key: _key.TRANSFORM_TEXTFORMATTING_MENU_SECTION.key,
|
|
31
39
|
rank: textFormattingRank[_blockMenu.TRANSFORM_HEADINGS_H1_MENU_ITEM.key]
|
|
32
40
|
},
|
|
33
41
|
component: (0, _HeadingBlockMenuItem.createHeadingBlockMenuItem)({
|
|
@@ -42,7 +50,7 @@ var getBlockTypeComponents = exports.getBlockTypeComponents = function getBlockT
|
|
|
42
50
|
key: _blockMenu.TRANSFORM_HEADINGS_H2_MENU_ITEM.key,
|
|
43
51
|
parent: {
|
|
44
52
|
type: 'block-menu-section',
|
|
45
|
-
key:
|
|
53
|
+
key: _key.TRANSFORM_TEXTFORMATTING_MENU_SECTION.key,
|
|
46
54
|
rank: textFormattingRank[_blockMenu.TRANSFORM_HEADINGS_H2_MENU_ITEM.key]
|
|
47
55
|
},
|
|
48
56
|
component: (0, _HeadingBlockMenuItem.createHeadingBlockMenuItem)({
|
|
@@ -57,7 +65,7 @@ var getBlockTypeComponents = exports.getBlockTypeComponents = function getBlockT
|
|
|
57
65
|
key: _blockMenu.TRANSFORM_HEADINGS_H3_MENU_ITEM.key,
|
|
58
66
|
parent: {
|
|
59
67
|
type: 'block-menu-section',
|
|
60
|
-
key:
|
|
68
|
+
key: _key.TRANSFORM_TEXTFORMATTING_MENU_SECTION.key,
|
|
61
69
|
rank: textFormattingRank[_blockMenu.TRANSFORM_HEADINGS_H3_MENU_ITEM.key]
|
|
62
70
|
},
|
|
63
71
|
component: (0, _HeadingBlockMenuItem.createHeadingBlockMenuItem)({
|
|
@@ -72,7 +80,7 @@ var getBlockTypeComponents = exports.getBlockTypeComponents = function getBlockT
|
|
|
72
80
|
key: _blockMenu.TRANSFORM_HEADINGS_H4_MENU_ITEM.key,
|
|
73
81
|
parent: {
|
|
74
82
|
type: 'block-menu-section',
|
|
75
|
-
key:
|
|
83
|
+
key: _key.TRANSFORM_TEXTFORMATTING_MENU_SECTION.key,
|
|
76
84
|
rank: textFormattingRank[_blockMenu.TRANSFORM_HEADINGS_H4_MENU_ITEM.key]
|
|
77
85
|
},
|
|
78
86
|
component: (0, _HeadingBlockMenuItem.createHeadingBlockMenuItem)({
|
|
@@ -87,7 +95,7 @@ var getBlockTypeComponents = exports.getBlockTypeComponents = function getBlockT
|
|
|
87
95
|
key: _blockMenu.TRANSFORM_HEADINGS_H5_MENU_ITEM.key,
|
|
88
96
|
parent: {
|
|
89
97
|
type: 'block-menu-section',
|
|
90
|
-
key:
|
|
98
|
+
key: _key.TRANSFORM_TEXTFORMATTING_MENU_SECTION.key,
|
|
91
99
|
rank: textFormattingRank[_blockMenu.TRANSFORM_HEADINGS_H5_MENU_ITEM.key]
|
|
92
100
|
},
|
|
93
101
|
component: (0, _HeadingBlockMenuItem.createHeadingBlockMenuItem)({
|
|
@@ -102,7 +110,7 @@ var getBlockTypeComponents = exports.getBlockTypeComponents = function getBlockT
|
|
|
102
110
|
key: _blockMenu.TRANSFORM_HEADINGS_H6_MENU_ITEM.key,
|
|
103
111
|
parent: {
|
|
104
112
|
type: 'block-menu-section',
|
|
105
|
-
key:
|
|
113
|
+
key: _key.TRANSFORM_TEXTFORMATTING_MENU_SECTION.key,
|
|
106
114
|
rank: textFormattingRank[_blockMenu.TRANSFORM_HEADINGS_H6_MENU_ITEM.key]
|
|
107
115
|
},
|
|
108
116
|
component: (0, _HeadingBlockMenuItem.createHeadingBlockMenuItem)({
|
|
@@ -117,7 +125,7 @@ var getBlockTypeComponents = exports.getBlockTypeComponents = function getBlockT
|
|
|
117
125
|
key: _blockMenu.TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key,
|
|
118
126
|
parent: {
|
|
119
127
|
type: 'block-menu-section',
|
|
120
|
-
key: isSmallTextExperimentEnabled ?
|
|
128
|
+
key: isSmallTextExperimentEnabled ? _key.TRANSFORM_TEXTFORMATTING_MENU_SECTION.key : _blockMenu.TRANSFORM_STRUCTURE_MENU_SECTION.key,
|
|
121
129
|
rank: isSmallTextExperimentEnabled ? _rank.TRANSFORM_TEXT_FORMATTING_MENU_SECTION_RANK[_blockMenu.TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key] : _blockMenu.TRANSFORM_STRUCTURE_MENU_SECTION_RANK[_blockMenu.TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key]
|
|
122
130
|
},
|
|
123
131
|
component: (0, _QuoteBlockMenuItem.createQuoteBlockMenuItem)({
|
|
@@ -132,7 +140,7 @@ var getBlockTypeComponents = exports.getBlockTypeComponents = function getBlockT
|
|
|
132
140
|
key: _blockMenu.TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key,
|
|
133
141
|
parent: {
|
|
134
142
|
type: 'block-menu-section',
|
|
135
|
-
key: isSmallTextExperimentEnabled ?
|
|
143
|
+
key: isSmallTextExperimentEnabled ? _key.TRANSFORM_TEXTFORMATTING_MENU_SECTION.key : _blockMenu.TRANSFORM_STRUCTURE_MENU_SECTION.key,
|
|
136
144
|
rank: isSmallTextExperimentEnabled ? _rank.TRANSFORM_TEXT_FORMATTING_MENU_SECTION_RANK[_blockMenu.TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key] : _blockMenu.TRANSFORM_STRUCTURE_MENU_SECTION_RANK[_blockMenu.TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key]
|
|
137
145
|
},
|
|
138
146
|
component: (0, _ParagraphBlockMenuItem.createParagraphBlockMenuItem)({
|
|
@@ -140,7 +148,26 @@ var getBlockTypeComponents = exports.getBlockTypeComponents = function getBlockT
|
|
|
140
148
|
}),
|
|
141
149
|
isHidden: function isHidden() {
|
|
142
150
|
var _api$blockMenu3;
|
|
143
|
-
|
|
151
|
+
var injectedResult = isSmallTextExperimentEnabled ? isTextFormattingItemHidden === null || isTextFormattingItemHidden === void 0 ? void 0 : isTextFormattingItemHidden('normal-text') : undefined;
|
|
152
|
+
return injectedResult !== null && injectedResult !== void 0 ? injectedResult : Boolean(api === null || api === void 0 || (_api$blockMenu3 = api.blockMenu) === null || _api$blockMenu3 === void 0 ? void 0 : _api$blockMenu3.actions.isTransformOptionDisabled(PARAGRAPH_NODE_NAME));
|
|
144
153
|
}
|
|
145
|
-
}]
|
|
154
|
+
}].concat((0, _toConsumableArray2.default)(isSmallTextEnabled ? [{
|
|
155
|
+
type: 'block-menu-item',
|
|
156
|
+
key: _key.TRANSFORM_TEXT_FORMATTING_SMALL_TEXT_MENU_ITEM.key,
|
|
157
|
+
parent: {
|
|
158
|
+
type: 'block-menu-section',
|
|
159
|
+
key: _key.TRANSFORM_TEXTFORMATTING_MENU_SECTION.key,
|
|
160
|
+
rank: _rank.TRANSFORM_TEXT_FORMATTING_MENU_SECTION_RANK[_key.TRANSFORM_TEXT_FORMATTING_SMALL_TEXT_MENU_ITEM.key]
|
|
161
|
+
},
|
|
162
|
+
component: (0, _SmallTextBlockMenuItem.createSmallTextBlockMenuItem)({
|
|
163
|
+
api: api
|
|
164
|
+
}),
|
|
165
|
+
isHidden: function isHidden() {
|
|
166
|
+
var _api$core$sharedState, _api$blockMenu4, _isTextFormattingItem;
|
|
167
|
+
if (!(api !== null && api !== void 0 && (_api$core$sharedState = api.core.sharedState.currentState()) !== null && _api$core$sharedState !== void 0 && (_api$core$sharedState = _api$core$sharedState.schema) !== null && _api$core$sharedState !== void 0 && _api$core$sharedState.marks.fontSize) || Boolean(api === null || api === void 0 || (_api$blockMenu4 = api.blockMenu) === null || _api$blockMenu4 === void 0 ? void 0 : _api$blockMenu4.actions.isTransformOptionDisabled(PARAGRAPH_NODE_NAME)) && isTransformHeadingDisabled(1)) {
|
|
168
|
+
return true;
|
|
169
|
+
}
|
|
170
|
+
return (_isTextFormattingItem = isTextFormattingItemHidden === null || isTextFormattingItemHidden === void 0 ? void 0 : isTextFormattingItemHidden('small-text')) !== null && _isTextFormattingItem !== void 0 ? _isTextFormattingItem : false;
|
|
171
|
+
}
|
|
172
|
+
}] : []));
|
|
146
173
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -135,7 +135,9 @@ const blockTypePlugin = ({
|
|
|
135
135
|
}
|
|
136
136
|
if (editorExperiment('platform_editor_block_menu', true)) {
|
|
137
137
|
var _api$blockMenu;
|
|
138
|
-
api === null || api === void 0 ? void 0 : (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 ? void 0 : _api$blockMenu.actions.registerBlockMenuComponents(getBlockTypeComponents(api
|
|
138
|
+
api === null || api === void 0 ? void 0 : (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 ? void 0 : _api$blockMenu.actions.registerBlockMenuComponents(getBlockTypeComponents(api, {
|
|
139
|
+
allowFontSize: options === null || options === void 0 ? void 0 : options.allowFontSize
|
|
140
|
+
}));
|
|
139
141
|
}
|
|
140
142
|
if (isRegisteredSlashCommandEnabled) {
|
|
141
143
|
var _api$uiControlRegistr, _options$allowBlockTy, _options$allowBlockTy2;
|
|
@@ -177,7 +179,9 @@ const blockTypePlugin = ({
|
|
|
177
179
|
name: 'blockType',
|
|
178
180
|
plugin: ({
|
|
179
181
|
dispatch
|
|
180
|
-
}) =>
|
|
182
|
+
}) => {
|
|
183
|
+
return createPlugin(api, dispatch, options && options.lastNodeMustBeParagraph, options === null || options === void 0 ? void 0 : options.includeBlockQuoteAsTextstyleOption, options === null || options === void 0 ? void 0 : options.allowFontSize);
|
|
184
|
+
}
|
|
181
185
|
}, {
|
|
182
186
|
name: 'blockTypeInputRule',
|
|
183
187
|
plugin: ({
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl';
|
|
3
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
|
+
import { blockTypeMessages } from '@atlaskit/editor-common/messages';
|
|
5
|
+
import { TextSmallIcon, ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
|
|
6
|
+
const NODE_NAME = 'paragraph';
|
|
7
|
+
const SmallTextBlockMenuItem = ({
|
|
8
|
+
api,
|
|
9
|
+
isSuggested
|
|
10
|
+
}) => {
|
|
11
|
+
const {
|
|
12
|
+
formatMessage
|
|
13
|
+
} = useIntl();
|
|
14
|
+
const handleClick = event => {
|
|
15
|
+
const triggeredFrom = event.nativeEvent instanceof KeyboardEvent || event.nativeEvent.detail === 0 ? INPUT_METHOD.KEYBOARD : INPUT_METHOD.MOUSE;
|
|
16
|
+
const inputMethod = INPUT_METHOD.BLOCK_MENU;
|
|
17
|
+
api === null || api === void 0 ? void 0 : api.core.actions.execute(({
|
|
18
|
+
tr
|
|
19
|
+
}) => {
|
|
20
|
+
var _api$blockMenu;
|
|
21
|
+
const command = api === null || api === void 0 ? void 0 : (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 ? void 0 : _api$blockMenu.commands.transformNode(tr.doc.type.schema.nodes.paragraph, {
|
|
22
|
+
inputMethod,
|
|
23
|
+
isSuggested,
|
|
24
|
+
triggeredFrom,
|
|
25
|
+
targetTypeName: NODE_NAME
|
|
26
|
+
});
|
|
27
|
+
return command ? command({
|
|
28
|
+
tr
|
|
29
|
+
}) : null;
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
33
|
+
onClick: handleClick,
|
|
34
|
+
elemBefore: /*#__PURE__*/React.createElement(TextSmallIcon, {
|
|
35
|
+
label: "",
|
|
36
|
+
size: "small"
|
|
37
|
+
})
|
|
38
|
+
}, formatMessage(blockTypeMessages.smallText));
|
|
39
|
+
};
|
|
40
|
+
export const createSmallTextBlockMenuItem = ({
|
|
41
|
+
api
|
|
42
|
+
}) => {
|
|
43
|
+
return ({
|
|
44
|
+
isSuggested
|
|
45
|
+
} = {}) => /*#__PURE__*/React.createElement(SmallTextBlockMenuItem, {
|
|
46
|
+
api: api,
|
|
47
|
+
isSuggested: isSuggested
|
|
48
|
+
});
|
|
49
|
+
};
|
package/dist/es2019/ui/index.js
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TRANSFORM_HEADINGS_MENU_SECTION_RANK, TRANSFORM_HEADINGS_H1_MENU_ITEM, TRANSFORM_HEADINGS_H2_MENU_ITEM, TRANSFORM_HEADINGS_H3_MENU_ITEM, TRANSFORM_HEADINGS_H4_MENU_ITEM, TRANSFORM_HEADINGS_H5_MENU_ITEM, TRANSFORM_HEADINGS_H6_MENU_ITEM, TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM, TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM, TRANSFORM_STRUCTURE_MENU_SECTION, TRANSFORM_STRUCTURE_MENU_SECTION_RANK } from '@atlaskit/editor-common/block-menu';
|
|
2
|
+
import { TRANSFORM_TEXTFORMATTING_MENU_SECTION, TRANSFORM_TEXT_FORMATTING_SMALL_TEXT_MENU_ITEM } from '@atlaskit/editor-common/block-menu/key';
|
|
2
3
|
import { TRANSFORM_TEXT_FORMATTING_MENU_SECTION_RANK } from '@atlaskit/editor-common/block-menu/rank';
|
|
3
4
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
4
5
|
import { createHeadingBlockMenuItem } from './HeadingBlockMenuItem';
|
|
5
6
|
import { createParagraphBlockMenuItem } from './ParagraphBlockMenuItem';
|
|
6
7
|
import { createQuoteBlockMenuItem } from './QuoteBlockMenuItem';
|
|
8
|
+
import { createSmallTextBlockMenuItem } from './SmallTextBlockMenuItem';
|
|
7
9
|
const HEADING_NODE_NAME = 'heading';
|
|
8
10
|
const QUOTE_NODE_NAME = 'blockquote';
|
|
9
11
|
const PARAGRAPH_NODE_NAME = 'paragraph';
|
|
10
|
-
export const getBlockTypeComponents = api
|
|
12
|
+
export const getBlockTypeComponents = (api, {
|
|
13
|
+
allowFontSize,
|
|
14
|
+
isHidden: isTextFormattingItemHidden
|
|
15
|
+
} = {}) => {
|
|
11
16
|
const isSmallTextExperimentEnabled = isExperimentEnabled('platform_editor_block_menu_small_text');
|
|
17
|
+
const isSmallTextEnabled = Boolean(allowFontSize && isSmallTextExperimentEnabled);
|
|
12
18
|
const textFormattingRank = isSmallTextExperimentEnabled ? TRANSFORM_TEXT_FORMATTING_MENU_SECTION_RANK : TRANSFORM_HEADINGS_MENU_SECTION_RANK;
|
|
13
19
|
const isTransformHeadingDisabled = level => {
|
|
14
20
|
var _api$blockMenu;
|
|
@@ -21,7 +27,7 @@ export const getBlockTypeComponents = api => {
|
|
|
21
27
|
key: TRANSFORM_HEADINGS_H1_MENU_ITEM.key,
|
|
22
28
|
parent: {
|
|
23
29
|
type: 'block-menu-section',
|
|
24
|
-
key:
|
|
30
|
+
key: TRANSFORM_TEXTFORMATTING_MENU_SECTION.key,
|
|
25
31
|
rank: textFormattingRank[TRANSFORM_HEADINGS_H1_MENU_ITEM.key]
|
|
26
32
|
},
|
|
27
33
|
component: createHeadingBlockMenuItem({
|
|
@@ -34,7 +40,7 @@ export const getBlockTypeComponents = api => {
|
|
|
34
40
|
key: TRANSFORM_HEADINGS_H2_MENU_ITEM.key,
|
|
35
41
|
parent: {
|
|
36
42
|
type: 'block-menu-section',
|
|
37
|
-
key:
|
|
43
|
+
key: TRANSFORM_TEXTFORMATTING_MENU_SECTION.key,
|
|
38
44
|
rank: textFormattingRank[TRANSFORM_HEADINGS_H2_MENU_ITEM.key]
|
|
39
45
|
},
|
|
40
46
|
component: createHeadingBlockMenuItem({
|
|
@@ -47,7 +53,7 @@ export const getBlockTypeComponents = api => {
|
|
|
47
53
|
key: TRANSFORM_HEADINGS_H3_MENU_ITEM.key,
|
|
48
54
|
parent: {
|
|
49
55
|
type: 'block-menu-section',
|
|
50
|
-
key:
|
|
56
|
+
key: TRANSFORM_TEXTFORMATTING_MENU_SECTION.key,
|
|
51
57
|
rank: textFormattingRank[TRANSFORM_HEADINGS_H3_MENU_ITEM.key]
|
|
52
58
|
},
|
|
53
59
|
component: createHeadingBlockMenuItem({
|
|
@@ -60,7 +66,7 @@ export const getBlockTypeComponents = api => {
|
|
|
60
66
|
key: TRANSFORM_HEADINGS_H4_MENU_ITEM.key,
|
|
61
67
|
parent: {
|
|
62
68
|
type: 'block-menu-section',
|
|
63
|
-
key:
|
|
69
|
+
key: TRANSFORM_TEXTFORMATTING_MENU_SECTION.key,
|
|
64
70
|
rank: textFormattingRank[TRANSFORM_HEADINGS_H4_MENU_ITEM.key]
|
|
65
71
|
},
|
|
66
72
|
component: createHeadingBlockMenuItem({
|
|
@@ -73,7 +79,7 @@ export const getBlockTypeComponents = api => {
|
|
|
73
79
|
key: TRANSFORM_HEADINGS_H5_MENU_ITEM.key,
|
|
74
80
|
parent: {
|
|
75
81
|
type: 'block-menu-section',
|
|
76
|
-
key:
|
|
82
|
+
key: TRANSFORM_TEXTFORMATTING_MENU_SECTION.key,
|
|
77
83
|
rank: textFormattingRank[TRANSFORM_HEADINGS_H5_MENU_ITEM.key]
|
|
78
84
|
},
|
|
79
85
|
component: createHeadingBlockMenuItem({
|
|
@@ -86,7 +92,7 @@ export const getBlockTypeComponents = api => {
|
|
|
86
92
|
key: TRANSFORM_HEADINGS_H6_MENU_ITEM.key,
|
|
87
93
|
parent: {
|
|
88
94
|
type: 'block-menu-section',
|
|
89
|
-
key:
|
|
95
|
+
key: TRANSFORM_TEXTFORMATTING_MENU_SECTION.key,
|
|
90
96
|
rank: textFormattingRank[TRANSFORM_HEADINGS_H6_MENU_ITEM.key]
|
|
91
97
|
},
|
|
92
98
|
component: createHeadingBlockMenuItem({
|
|
@@ -99,7 +105,7 @@ export const getBlockTypeComponents = api => {
|
|
|
99
105
|
key: TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key,
|
|
100
106
|
parent: {
|
|
101
107
|
type: 'block-menu-section',
|
|
102
|
-
key: isSmallTextExperimentEnabled ?
|
|
108
|
+
key: isSmallTextExperimentEnabled ? TRANSFORM_TEXTFORMATTING_MENU_SECTION.key : TRANSFORM_STRUCTURE_MENU_SECTION.key,
|
|
103
109
|
rank: isSmallTextExperimentEnabled ? TRANSFORM_TEXT_FORMATTING_MENU_SECTION_RANK[TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key] : TRANSFORM_STRUCTURE_MENU_SECTION_RANK[TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key]
|
|
104
110
|
},
|
|
105
111
|
component: createQuoteBlockMenuItem({
|
|
@@ -114,7 +120,7 @@ export const getBlockTypeComponents = api => {
|
|
|
114
120
|
key: TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key,
|
|
115
121
|
parent: {
|
|
116
122
|
type: 'block-menu-section',
|
|
117
|
-
key: isSmallTextExperimentEnabled ?
|
|
123
|
+
key: isSmallTextExperimentEnabled ? TRANSFORM_TEXTFORMATTING_MENU_SECTION.key : TRANSFORM_STRUCTURE_MENU_SECTION.key,
|
|
118
124
|
rank: isSmallTextExperimentEnabled ? TRANSFORM_TEXT_FORMATTING_MENU_SECTION_RANK[TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key] : TRANSFORM_STRUCTURE_MENU_SECTION_RANK[TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key]
|
|
119
125
|
},
|
|
120
126
|
component: createParagraphBlockMenuItem({
|
|
@@ -122,7 +128,26 @@ export const getBlockTypeComponents = api => {
|
|
|
122
128
|
}),
|
|
123
129
|
isHidden: () => {
|
|
124
130
|
var _api$blockMenu3;
|
|
125
|
-
|
|
131
|
+
const injectedResult = isSmallTextExperimentEnabled ? isTextFormattingItemHidden === null || isTextFormattingItemHidden === void 0 ? void 0 : isTextFormattingItemHidden('normal-text') : undefined;
|
|
132
|
+
return injectedResult !== null && injectedResult !== void 0 ? injectedResult : Boolean(api === null || api === void 0 ? void 0 : (_api$blockMenu3 = api.blockMenu) === null || _api$blockMenu3 === void 0 ? void 0 : _api$blockMenu3.actions.isTransformOptionDisabled(PARAGRAPH_NODE_NAME));
|
|
126
133
|
}
|
|
127
|
-
}
|
|
134
|
+
}, ...(isSmallTextEnabled ? [{
|
|
135
|
+
type: 'block-menu-item',
|
|
136
|
+
key: TRANSFORM_TEXT_FORMATTING_SMALL_TEXT_MENU_ITEM.key,
|
|
137
|
+
parent: {
|
|
138
|
+
type: 'block-menu-section',
|
|
139
|
+
key: TRANSFORM_TEXTFORMATTING_MENU_SECTION.key,
|
|
140
|
+
rank: TRANSFORM_TEXT_FORMATTING_MENU_SECTION_RANK[TRANSFORM_TEXT_FORMATTING_SMALL_TEXT_MENU_ITEM.key]
|
|
141
|
+
},
|
|
142
|
+
component: createSmallTextBlockMenuItem({
|
|
143
|
+
api
|
|
144
|
+
}),
|
|
145
|
+
isHidden: () => {
|
|
146
|
+
var _api$core$sharedState, _api$core$sharedState2, _api$blockMenu4, _isTextFormattingItem;
|
|
147
|
+
if (!(api !== null && api !== void 0 && (_api$core$sharedState = api.core.sharedState.currentState()) !== null && _api$core$sharedState !== void 0 && (_api$core$sharedState2 = _api$core$sharedState.schema) !== null && _api$core$sharedState2 !== void 0 && _api$core$sharedState2.marks.fontSize) || Boolean(api === null || api === void 0 ? void 0 : (_api$blockMenu4 = api.blockMenu) === null || _api$blockMenu4 === void 0 ? void 0 : _api$blockMenu4.actions.isTransformOptionDisabled(PARAGRAPH_NODE_NAME)) && isTransformHeadingDisabled(1)) {
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
return (_isTextFormattingItem = isTextFormattingItemHidden === null || isTextFormattingItemHidden === void 0 ? void 0 : isTextFormattingItemHidden('small-text')) !== null && _isTextFormattingItem !== void 0 ? _isTextFormattingItem : false;
|
|
151
|
+
}
|
|
152
|
+
}] : [])];
|
|
128
153
|
};
|
|
File without changes
|
|
@@ -139,7 +139,9 @@ var blockTypePlugin = function blockTypePlugin(_ref3) {
|
|
|
139
139
|
}
|
|
140
140
|
if (editorExperiment('platform_editor_block_menu', true)) {
|
|
141
141
|
var _api$blockMenu;
|
|
142
|
-
api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 || _api$blockMenu.actions.registerBlockMenuComponents(getBlockTypeComponents(api
|
|
142
|
+
api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 || _api$blockMenu.actions.registerBlockMenuComponents(getBlockTypeComponents(api, {
|
|
143
|
+
allowFontSize: options === null || options === void 0 ? void 0 : options.allowFontSize
|
|
144
|
+
}));
|
|
143
145
|
}
|
|
144
146
|
if (isRegisteredSlashCommandEnabled) {
|
|
145
147
|
var _api$uiControlRegistr, _options$allowBlockTy, _options$allowBlockTy2;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl';
|
|
3
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
|
+
import { blockTypeMessages } from '@atlaskit/editor-common/messages';
|
|
5
|
+
import { TextSmallIcon, ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
|
|
6
|
+
var NODE_NAME = 'paragraph';
|
|
7
|
+
var SmallTextBlockMenuItem = function SmallTextBlockMenuItem(_ref) {
|
|
8
|
+
var api = _ref.api,
|
|
9
|
+
isSuggested = _ref.isSuggested;
|
|
10
|
+
var _useIntl = useIntl(),
|
|
11
|
+
formatMessage = _useIntl.formatMessage;
|
|
12
|
+
var handleClick = function handleClick(event) {
|
|
13
|
+
var triggeredFrom = event.nativeEvent instanceof KeyboardEvent || event.nativeEvent.detail === 0 ? INPUT_METHOD.KEYBOARD : INPUT_METHOD.MOUSE;
|
|
14
|
+
var inputMethod = INPUT_METHOD.BLOCK_MENU;
|
|
15
|
+
api === null || api === void 0 || api.core.actions.execute(function (_ref2) {
|
|
16
|
+
var _api$blockMenu;
|
|
17
|
+
var tr = _ref2.tr;
|
|
18
|
+
var command = api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 ? void 0 : _api$blockMenu.commands.transformNode(tr.doc.type.schema.nodes.paragraph, {
|
|
19
|
+
inputMethod: inputMethod,
|
|
20
|
+
isSuggested: isSuggested,
|
|
21
|
+
triggeredFrom: triggeredFrom,
|
|
22
|
+
targetTypeName: NODE_NAME
|
|
23
|
+
});
|
|
24
|
+
return command ? command({
|
|
25
|
+
tr: tr
|
|
26
|
+
}) : null;
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
30
|
+
onClick: handleClick,
|
|
31
|
+
elemBefore: /*#__PURE__*/React.createElement(TextSmallIcon, {
|
|
32
|
+
label: "",
|
|
33
|
+
size: "small"
|
|
34
|
+
})
|
|
35
|
+
}, formatMessage(blockTypeMessages.smallText));
|
|
36
|
+
};
|
|
37
|
+
export var createSmallTextBlockMenuItem = function createSmallTextBlockMenuItem(_ref3) {
|
|
38
|
+
var api = _ref3.api;
|
|
39
|
+
return function () {
|
|
40
|
+
var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
41
|
+
isSuggested = _ref4.isSuggested;
|
|
42
|
+
return /*#__PURE__*/React.createElement(SmallTextBlockMenuItem, {
|
|
43
|
+
api: api,
|
|
44
|
+
isSuggested: isSuggested
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
};
|
package/dist/esm/ui/index.js
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import { TRANSFORM_HEADINGS_MENU_SECTION_RANK, TRANSFORM_HEADINGS_H1_MENU_ITEM, TRANSFORM_HEADINGS_H2_MENU_ITEM, TRANSFORM_HEADINGS_H3_MENU_ITEM, TRANSFORM_HEADINGS_H4_MENU_ITEM, TRANSFORM_HEADINGS_H5_MENU_ITEM, TRANSFORM_HEADINGS_H6_MENU_ITEM, TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM, TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM, TRANSFORM_STRUCTURE_MENU_SECTION, TRANSFORM_STRUCTURE_MENU_SECTION_RANK } from '@atlaskit/editor-common/block-menu';
|
|
3
|
+
import { TRANSFORM_TEXTFORMATTING_MENU_SECTION, TRANSFORM_TEXT_FORMATTING_SMALL_TEXT_MENU_ITEM } from '@atlaskit/editor-common/block-menu/key';
|
|
2
4
|
import { TRANSFORM_TEXT_FORMATTING_MENU_SECTION_RANK } from '@atlaskit/editor-common/block-menu/rank';
|
|
3
5
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
4
6
|
import { createHeadingBlockMenuItem } from './HeadingBlockMenuItem';
|
|
5
7
|
import { createParagraphBlockMenuItem } from './ParagraphBlockMenuItem';
|
|
6
8
|
import { createQuoteBlockMenuItem } from './QuoteBlockMenuItem';
|
|
9
|
+
import { createSmallTextBlockMenuItem } from './SmallTextBlockMenuItem';
|
|
7
10
|
var HEADING_NODE_NAME = 'heading';
|
|
8
11
|
var QUOTE_NODE_NAME = 'blockquote';
|
|
9
12
|
var PARAGRAPH_NODE_NAME = 'paragraph';
|
|
10
13
|
export var getBlockTypeComponents = function getBlockTypeComponents(api) {
|
|
14
|
+
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
15
|
+
allowFontSize = _ref.allowFontSize,
|
|
16
|
+
isTextFormattingItemHidden = _ref.isHidden;
|
|
11
17
|
var isSmallTextExperimentEnabled = isExperimentEnabled('platform_editor_block_menu_small_text');
|
|
18
|
+
var isSmallTextEnabled = Boolean(allowFontSize && isSmallTextExperimentEnabled);
|
|
12
19
|
var textFormattingRank = isSmallTextExperimentEnabled ? TRANSFORM_TEXT_FORMATTING_MENU_SECTION_RANK : TRANSFORM_HEADINGS_MENU_SECTION_RANK;
|
|
13
20
|
var isTransformHeadingDisabled = function isTransformHeadingDisabled(level) {
|
|
14
21
|
var _api$blockMenu;
|
|
@@ -21,7 +28,7 @@ export var getBlockTypeComponents = function getBlockTypeComponents(api) {
|
|
|
21
28
|
key: TRANSFORM_HEADINGS_H1_MENU_ITEM.key,
|
|
22
29
|
parent: {
|
|
23
30
|
type: 'block-menu-section',
|
|
24
|
-
key:
|
|
31
|
+
key: TRANSFORM_TEXTFORMATTING_MENU_SECTION.key,
|
|
25
32
|
rank: textFormattingRank[TRANSFORM_HEADINGS_H1_MENU_ITEM.key]
|
|
26
33
|
},
|
|
27
34
|
component: createHeadingBlockMenuItem({
|
|
@@ -36,7 +43,7 @@ export var getBlockTypeComponents = function getBlockTypeComponents(api) {
|
|
|
36
43
|
key: TRANSFORM_HEADINGS_H2_MENU_ITEM.key,
|
|
37
44
|
parent: {
|
|
38
45
|
type: 'block-menu-section',
|
|
39
|
-
key:
|
|
46
|
+
key: TRANSFORM_TEXTFORMATTING_MENU_SECTION.key,
|
|
40
47
|
rank: textFormattingRank[TRANSFORM_HEADINGS_H2_MENU_ITEM.key]
|
|
41
48
|
},
|
|
42
49
|
component: createHeadingBlockMenuItem({
|
|
@@ -51,7 +58,7 @@ export var getBlockTypeComponents = function getBlockTypeComponents(api) {
|
|
|
51
58
|
key: TRANSFORM_HEADINGS_H3_MENU_ITEM.key,
|
|
52
59
|
parent: {
|
|
53
60
|
type: 'block-menu-section',
|
|
54
|
-
key:
|
|
61
|
+
key: TRANSFORM_TEXTFORMATTING_MENU_SECTION.key,
|
|
55
62
|
rank: textFormattingRank[TRANSFORM_HEADINGS_H3_MENU_ITEM.key]
|
|
56
63
|
},
|
|
57
64
|
component: createHeadingBlockMenuItem({
|
|
@@ -66,7 +73,7 @@ export var getBlockTypeComponents = function getBlockTypeComponents(api) {
|
|
|
66
73
|
key: TRANSFORM_HEADINGS_H4_MENU_ITEM.key,
|
|
67
74
|
parent: {
|
|
68
75
|
type: 'block-menu-section',
|
|
69
|
-
key:
|
|
76
|
+
key: TRANSFORM_TEXTFORMATTING_MENU_SECTION.key,
|
|
70
77
|
rank: textFormattingRank[TRANSFORM_HEADINGS_H4_MENU_ITEM.key]
|
|
71
78
|
},
|
|
72
79
|
component: createHeadingBlockMenuItem({
|
|
@@ -81,7 +88,7 @@ export var getBlockTypeComponents = function getBlockTypeComponents(api) {
|
|
|
81
88
|
key: TRANSFORM_HEADINGS_H5_MENU_ITEM.key,
|
|
82
89
|
parent: {
|
|
83
90
|
type: 'block-menu-section',
|
|
84
|
-
key:
|
|
91
|
+
key: TRANSFORM_TEXTFORMATTING_MENU_SECTION.key,
|
|
85
92
|
rank: textFormattingRank[TRANSFORM_HEADINGS_H5_MENU_ITEM.key]
|
|
86
93
|
},
|
|
87
94
|
component: createHeadingBlockMenuItem({
|
|
@@ -96,7 +103,7 @@ export var getBlockTypeComponents = function getBlockTypeComponents(api) {
|
|
|
96
103
|
key: TRANSFORM_HEADINGS_H6_MENU_ITEM.key,
|
|
97
104
|
parent: {
|
|
98
105
|
type: 'block-menu-section',
|
|
99
|
-
key:
|
|
106
|
+
key: TRANSFORM_TEXTFORMATTING_MENU_SECTION.key,
|
|
100
107
|
rank: textFormattingRank[TRANSFORM_HEADINGS_H6_MENU_ITEM.key]
|
|
101
108
|
},
|
|
102
109
|
component: createHeadingBlockMenuItem({
|
|
@@ -111,7 +118,7 @@ export var getBlockTypeComponents = function getBlockTypeComponents(api) {
|
|
|
111
118
|
key: TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key,
|
|
112
119
|
parent: {
|
|
113
120
|
type: 'block-menu-section',
|
|
114
|
-
key: isSmallTextExperimentEnabled ?
|
|
121
|
+
key: isSmallTextExperimentEnabled ? TRANSFORM_TEXTFORMATTING_MENU_SECTION.key : TRANSFORM_STRUCTURE_MENU_SECTION.key,
|
|
115
122
|
rank: isSmallTextExperimentEnabled ? TRANSFORM_TEXT_FORMATTING_MENU_SECTION_RANK[TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key] : TRANSFORM_STRUCTURE_MENU_SECTION_RANK[TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key]
|
|
116
123
|
},
|
|
117
124
|
component: createQuoteBlockMenuItem({
|
|
@@ -126,7 +133,7 @@ export var getBlockTypeComponents = function getBlockTypeComponents(api) {
|
|
|
126
133
|
key: TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key,
|
|
127
134
|
parent: {
|
|
128
135
|
type: 'block-menu-section',
|
|
129
|
-
key: isSmallTextExperimentEnabled ?
|
|
136
|
+
key: isSmallTextExperimentEnabled ? TRANSFORM_TEXTFORMATTING_MENU_SECTION.key : TRANSFORM_STRUCTURE_MENU_SECTION.key,
|
|
130
137
|
rank: isSmallTextExperimentEnabled ? TRANSFORM_TEXT_FORMATTING_MENU_SECTION_RANK[TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key] : TRANSFORM_STRUCTURE_MENU_SECTION_RANK[TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key]
|
|
131
138
|
},
|
|
132
139
|
component: createParagraphBlockMenuItem({
|
|
@@ -134,7 +141,26 @@ export var getBlockTypeComponents = function getBlockTypeComponents(api) {
|
|
|
134
141
|
}),
|
|
135
142
|
isHidden: function isHidden() {
|
|
136
143
|
var _api$blockMenu3;
|
|
137
|
-
|
|
144
|
+
var injectedResult = isSmallTextExperimentEnabled ? isTextFormattingItemHidden === null || isTextFormattingItemHidden === void 0 ? void 0 : isTextFormattingItemHidden('normal-text') : undefined;
|
|
145
|
+
return injectedResult !== null && injectedResult !== void 0 ? injectedResult : Boolean(api === null || api === void 0 || (_api$blockMenu3 = api.blockMenu) === null || _api$blockMenu3 === void 0 ? void 0 : _api$blockMenu3.actions.isTransformOptionDisabled(PARAGRAPH_NODE_NAME));
|
|
138
146
|
}
|
|
139
|
-
}]
|
|
147
|
+
}].concat(_toConsumableArray(isSmallTextEnabled ? [{
|
|
148
|
+
type: 'block-menu-item',
|
|
149
|
+
key: TRANSFORM_TEXT_FORMATTING_SMALL_TEXT_MENU_ITEM.key,
|
|
150
|
+
parent: {
|
|
151
|
+
type: 'block-menu-section',
|
|
152
|
+
key: TRANSFORM_TEXTFORMATTING_MENU_SECTION.key,
|
|
153
|
+
rank: TRANSFORM_TEXT_FORMATTING_MENU_SECTION_RANK[TRANSFORM_TEXT_FORMATTING_SMALL_TEXT_MENU_ITEM.key]
|
|
154
|
+
},
|
|
155
|
+
component: createSmallTextBlockMenuItem({
|
|
156
|
+
api: api
|
|
157
|
+
}),
|
|
158
|
+
isHidden: function isHidden() {
|
|
159
|
+
var _api$core$sharedState, _api$blockMenu4, _isTextFormattingItem;
|
|
160
|
+
if (!(api !== null && api !== void 0 && (_api$core$sharedState = api.core.sharedState.currentState()) !== null && _api$core$sharedState !== void 0 && (_api$core$sharedState = _api$core$sharedState.schema) !== null && _api$core$sharedState !== void 0 && _api$core$sharedState.marks.fontSize) || Boolean(api === null || api === void 0 || (_api$blockMenu4 = api.blockMenu) === null || _api$blockMenu4 === void 0 ? void 0 : _api$blockMenu4.actions.isTransformOptionDisabled(PARAGRAPH_NODE_NAME)) && isTransformHeadingDisabled(1)) {
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
return (_isTextFormattingItem = isTextFormattingItemHidden === null || isTextFormattingItemHidden === void 0 ? void 0 : isTextFormattingItemHidden('small-text')) !== null && _isTextFormattingItem !== void 0 ? _isTextFormattingItem : false;
|
|
164
|
+
}
|
|
165
|
+
}] : []));
|
|
140
166
|
};
|
|
File without changes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { BlockMenuItemComponentProps } from '@atlaskit/editor-plugin-block-menu/blockMenuPluginType';
|
|
4
|
+
import type { BlockTypePlugin } from '../blockTypePluginType';
|
|
5
|
+
type SmallTextBlockMenuItemProps = {
|
|
6
|
+
api: ExtractInjectionAPI<BlockTypePlugin> | undefined;
|
|
7
|
+
isSuggested?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare const createSmallTextBlockMenuItem: ({ api }: SmallTextBlockMenuItemProps) => ({ isSuggested }?: BlockMenuItemComponentProps) => React.JSX.Element;
|
|
10
|
+
export {};
|
package/dist/types/ui/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { RegisterBlockMenuComponent } from '@atlaskit/editor-plugin-block-menu';
|
|
3
3
|
import type { BlockTypePlugin } from '../blockTypePluginType';
|
|
4
|
-
|
|
4
|
+
import type { TextFormattingBlockMenuOptions } from './types';
|
|
5
|
+
export declare const getBlockTypeComponents: (api: ExtractInjectionAPI<BlockTypePlugin> | undefined, { allowFontSize, isHidden: isTextFormattingItemHidden }?: TextFormattingBlockMenuOptions) => RegisterBlockMenuComponent[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-type",
|
|
3
|
-
"version": "21.0.
|
|
3
|
+
"version": "21.0.4",
|
|
4
4
|
"description": "BlockType plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -43,14 +43,14 @@
|
|
|
43
43
|
"@atlaskit/primitives": "^22.5.0",
|
|
44
44
|
"@atlaskit/prosemirror-history": "^1.2.0",
|
|
45
45
|
"@atlaskit/prosemirror-input-rules": "^4.1.0",
|
|
46
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
46
|
+
"@atlaskit/tmp-editor-statsig": "^182.0.0",
|
|
47
47
|
"@atlaskit/tokens": "^16.11.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": "^121.
|
|
53
|
+
"@atlaskit/editor-common": "^121.2.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"
|