@atlaskit/editor-plugin-block-type 5.1.12 → 5.1.14
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 +18 -0
- package/dist/cjs/pm-plugins/block-types.js +35 -7
- package/dist/cjs/pm-plugins/ui/FloatingToolbarComponent.js +40 -6
- package/dist/cjs/pm-plugins/ui/PrimaryToolbarComponent.js +41 -6
- package/dist/cjs/pm-plugins/ui/ToolbarBlockType/blocktype-button.js +3 -0
- package/dist/cjs/pm-plugins/ui/ToolbarBlockType/index.js +35 -27
- package/dist/es2019/pm-plugins/block-types.js +35 -7
- package/dist/es2019/pm-plugins/ui/FloatingToolbarComponent.js +40 -6
- package/dist/es2019/pm-plugins/ui/PrimaryToolbarComponent.js +41 -6
- package/dist/es2019/pm-plugins/ui/ToolbarBlockType/blocktype-button.js +3 -0
- package/dist/es2019/pm-plugins/ui/ToolbarBlockType/index.js +21 -18
- package/dist/esm/pm-plugins/block-types.js +35 -7
- package/dist/esm/pm-plugins/ui/FloatingToolbarComponent.js +40 -6
- package/dist/esm/pm-plugins/ui/PrimaryToolbarComponent.js +41 -6
- package/dist/esm/pm-plugins/ui/ToolbarBlockType/blocktype-button.js +3 -0
- package/dist/esm/pm-plugins/ui/ToolbarBlockType/index.js +35 -27
- package/dist/types/pm-plugins/types.d.ts +1 -0
- package/dist/types/pm-plugins/ui/ToolbarBlockType/index.d.ts +5 -2
- package/dist/types-ts4.5/pm-plugins/types.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/ui/ToolbarBlockType/index.d.ts +5 -2
- package/package.json +14 -10
@@ -1,6 +1,8 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
3
3
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
4
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
5
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
4
6
|
import ToolbarBlockType from './ToolbarBlockType';
|
5
7
|
export function PrimaryToolbarComponent({
|
6
8
|
api,
|
@@ -14,7 +16,39 @@ export function PrimaryToolbarComponent({
|
|
14
16
|
}) {
|
15
17
|
const {
|
16
18
|
blockTypeState
|
17
|
-
} = useSharedPluginState(api, ['blockType']
|
19
|
+
} = useSharedPluginState(api, ['blockType'], {
|
20
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
|
21
|
+
});
|
22
|
+
|
23
|
+
// currentBlockType
|
24
|
+
const currentBlockTypeSelector = useSharedPluginStateSelector(api, 'blockType.currentBlockType', {
|
25
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
26
|
+
});
|
27
|
+
const currentBlockType = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? currentBlockTypeSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.currentBlockType;
|
28
|
+
|
29
|
+
// blockTypesDisabled
|
30
|
+
const blockTypesDisabledSelector = useSharedPluginStateSelector(api, 'blockType.blockTypesDisabled', {
|
31
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
32
|
+
});
|
33
|
+
const blockTypesDisabled = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? blockTypesDisabledSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.blockTypesDisabled;
|
34
|
+
|
35
|
+
// availableBlockTypes
|
36
|
+
const availableBlockTypesSelector = useSharedPluginStateSelector(api, 'blockType.availableBlockTypes', {
|
37
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
38
|
+
});
|
39
|
+
const availableBlockTypes = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? availableBlockTypesSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.availableBlockTypes;
|
40
|
+
|
41
|
+
// availableBlockTypesInDropdown
|
42
|
+
const availableBlockTypesInDropdownSelector = useSharedPluginStateSelector(api, 'blockType.availableBlockTypesInDropdown', {
|
43
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
44
|
+
});
|
45
|
+
const availableBlockTypesInDropdown = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? availableBlockTypesInDropdownSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.availableBlockTypesInDropdown;
|
46
|
+
|
47
|
+
// formattingIsPresent
|
48
|
+
const formattingIsPresentSelector = useSharedPluginStateSelector(api, 'blockType.formattingIsPresent', {
|
49
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
50
|
+
});
|
51
|
+
const formattingIsPresent = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? formattingIsPresentSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.formattingIsPresent;
|
18
52
|
const boundSetBlockType = (name, fromBlockQuote) => {
|
19
53
|
var _api$core, _api$blockType, _api$blockType$comman;
|
20
54
|
return api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(api === null || api === void 0 ? void 0 : (_api$blockType = api.blockType) === null || _api$blockType === void 0 ? void 0 : (_api$blockType$comman = _api$blockType.commands) === null || _api$blockType$comman === void 0 ? void 0 : _api$blockType$comman.setTextLevel(name, INPUT_METHOD.TOOLBAR, fromBlockQuote));
|
@@ -33,11 +67,12 @@ export function PrimaryToolbarComponent({
|
|
33
67
|
isReducedSpacing: isToolbarReducedSpacing,
|
34
68
|
setTextLevel: boundSetBlockType,
|
35
69
|
wrapBlockQuote: wrapBlockQuote,
|
36
|
-
clearFormatting: clearFormatting
|
37
|
-
|
38
|
-
|
39
|
-
,
|
40
|
-
|
70
|
+
clearFormatting: clearFormatting,
|
71
|
+
currentBlockType: currentBlockType,
|
72
|
+
blockTypesDisabled: blockTypesDisabled,
|
73
|
+
availableBlockTypes: availableBlockTypes,
|
74
|
+
availableBlockTypesInDropdown: availableBlockTypesInDropdown,
|
75
|
+
formattingIsPresent: formattingIsPresent,
|
41
76
|
popupsMountPoint: popupsMountPoint,
|
42
77
|
popupsBoundariesElement: popupsBoundariesElement,
|
43
78
|
popupsScrollableElement: popupsScrollableElement,
|
@@ -13,6 +13,7 @@ import { ToolbarButton } from '@atlaskit/editor-common/ui-menu';
|
|
13
13
|
import TextIcon from '@atlaskit/icon/core/text';
|
14
14
|
import { default as TextStyleIconLegacy } from '@atlaskit/icon/glyph/editor/text-style';
|
15
15
|
import ChevronDownIcon from '@atlaskit/icon/utility/migration/chevron-down';
|
16
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
16
17
|
import { Box, xcss } from '@atlaskit/primitives';
|
17
18
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
18
19
|
import { NORMAL_TEXT } from '../../block-types';
|
@@ -38,6 +39,7 @@ export const BlockTypeButton = props => {
|
|
38
39
|
color: "currentColor",
|
39
40
|
LEGACY_fallbackIcon: TextStyleIconLegacy
|
40
41
|
});
|
42
|
+
const chevronIconSpacing = props.isSmall && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_4') ? 'spacious' : 'none';
|
41
43
|
return jsx(ToolbarButton, {
|
42
44
|
spacing: props.isReducedSpacing ? 'none' : 'default',
|
43
45
|
selected: props.selected
|
@@ -59,6 +61,7 @@ export const BlockTypeButton = props => {
|
|
59
61
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
60
62
|
css: expandIconContainerStyle
|
61
63
|
}, jsx(ChevronDownIcon, {
|
64
|
+
spacing: chevronIconSpacing,
|
62
65
|
label: "",
|
63
66
|
color: "currentColor",
|
64
67
|
LEGACY_margin: "0 0 0 -8px"
|
@@ -13,6 +13,7 @@ import { toolbarMessages } from '@atlaskit/editor-common/messages';
|
|
13
13
|
import { separatorStyles, wrapperStyle } from '@atlaskit/editor-common/styles';
|
14
14
|
import { DropdownMenuWithKeyboardNavigation as DropdownMenu } from '@atlaskit/editor-common/ui-menu';
|
15
15
|
import { akEditorMenuZIndex } from '@atlaskit/editor-shared-styles';
|
16
|
+
import TextIcon from '@atlaskit/icon/core/text';
|
16
17
|
import { fg } from '@atlaskit/platform-feature-flags';
|
17
18
|
import { Box, xcss } from '@atlaskit/primitives';
|
18
19
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
@@ -61,18 +62,17 @@ class ToolbarBlockType extends React.PureComponent {
|
|
61
62
|
const {
|
62
63
|
intl: {
|
63
64
|
formatMessage
|
64
|
-
}
|
65
|
-
} = this.props;
|
66
|
-
const {
|
65
|
+
},
|
67
66
|
currentBlockType,
|
68
67
|
availableBlockTypesInDropdown,
|
69
68
|
formattingIsPresent
|
70
|
-
} = this.props
|
71
|
-
const items = availableBlockTypesInDropdown.map((blockType, index) => {
|
69
|
+
} = this.props;
|
70
|
+
const items = (availableBlockTypesInDropdown !== null && availableBlockTypesInDropdown !== void 0 ? availableBlockTypesInDropdown : []).map((blockType, index) => {
|
72
71
|
const isActive = currentBlockType === blockType;
|
73
72
|
const tagName = blockType.tagName || 'p';
|
74
73
|
const Tag = tagName;
|
75
74
|
const keyMap = findKeymapByDescription(blockType.title.defaultMessage);
|
75
|
+
const icon = fg('platform_editor_controls_patch_4') ? blockType === null || blockType === void 0 ? void 0 : blockType.icon : blockType.LEGACY_icon;
|
76
76
|
const item = {
|
77
77
|
content:
|
78
78
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
@@ -82,7 +82,7 @@ class ToolbarBlockType extends React.PureComponent {
|
|
82
82
|
value: blockType,
|
83
83
|
'aria-label': tooltip(keyMap, formatMessage(blockType.title)),
|
84
84
|
key: `${blockType.name}-${index}`,
|
85
|
-
elemBefore: editorExperiment('platform_editor_controls', 'variant1') ?
|
85
|
+
elemBefore: editorExperiment('platform_editor_controls', 'variant1') ? icon : undefined,
|
86
86
|
elemAfter:
|
87
87
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
88
88
|
jsx("div", {
|
@@ -92,7 +92,7 @@ class ToolbarBlockType extends React.PureComponent {
|
|
92
92
|
};
|
93
93
|
return item;
|
94
94
|
});
|
95
|
-
if (availableBlockTypesInDropdown.map(blockType => blockType.name).includes('blockquote') && editorExperiment('platform_editor_controls', 'control')) {
|
95
|
+
if ((availableBlockTypesInDropdown !== null && availableBlockTypesInDropdown !== void 0 ? availableBlockTypesInDropdown : []).map(blockType => blockType.name).includes('blockquote') && editorExperiment('platform_editor_controls', 'control')) {
|
96
96
|
const clearFormattingItem = {
|
97
97
|
content: jsx("div", null, jsx("p", null, toolbarMessages.clearFormatting.defaultMessage)),
|
98
98
|
value: {
|
@@ -129,7 +129,8 @@ class ToolbarBlockType extends React.PureComponent {
|
|
129
129
|
if (blockType.name === 'clearFormatting') {
|
130
130
|
this.props.clearFormatting();
|
131
131
|
} else {
|
132
|
-
|
132
|
+
var _this$props$currentBl;
|
133
|
+
const fromBlockQuote = ((_this$props$currentBl = this.props.currentBlockType) === null || _this$props$currentBl === void 0 ? void 0 : _this$props$currentBl.name) === 'blockquote';
|
133
134
|
this.props.setTextLevel(blockType.name, fromBlockQuote);
|
134
135
|
}
|
135
136
|
}
|
@@ -171,12 +172,10 @@ class ToolbarBlockType extends React.PureComponent {
|
|
171
172
|
popupsScrollableElement,
|
172
173
|
isSmall,
|
173
174
|
isReducedSpacing,
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
availableBlockTypesInDropdown
|
179
|
-
},
|
175
|
+
currentBlockType,
|
176
|
+
blockTypesDisabled,
|
177
|
+
availableBlockTypes = [],
|
178
|
+
availableBlockTypesInDropdown = [],
|
180
179
|
shouldUseDefaultRole,
|
181
180
|
intl: {
|
182
181
|
formatMessage
|
@@ -187,7 +186,11 @@ class ToolbarBlockType extends React.PureComponent {
|
|
187
186
|
if (isHeadingDisabled) {
|
188
187
|
return null;
|
189
188
|
}
|
190
|
-
const blockTypeTitles = availableBlockTypesInDropdown.filter(blockType => blockType.name === currentBlockType.name).map(blockType => blockType.title);
|
189
|
+
const blockTypeTitles = availableBlockTypesInDropdown.filter(blockType => blockType.name === (currentBlockType === null || currentBlockType === void 0 ? void 0 : currentBlockType.name)).map(blockType => blockType.title);
|
190
|
+
const defaultIcon = fg('platform_editor_controls_patch_4') ? jsx(TextIcon, {
|
191
|
+
label: ""
|
192
|
+
}) : jsx(Text, null);
|
193
|
+
const currentIcon = fg('platform_editor_controls_patch_4') ? currentBlockType === null || currentBlockType === void 0 ? void 0 : currentBlockType.icon : currentBlockType === null || currentBlockType === void 0 ? void 0 : currentBlockType.LEGACY_icon;
|
191
194
|
if (!this.props.isDisabled && !blockTypesDisabled) {
|
192
195
|
const items = this.createItems();
|
193
196
|
const button = jsx(BlockTypeButton, {
|
@@ -200,8 +203,8 @@ class ToolbarBlockType extends React.PureComponent {
|
|
200
203
|
onKeyDown: this.handleTriggerByKeyboard,
|
201
204
|
formatMessage: formatMessage,
|
202
205
|
"aria-expanded": active,
|
203
|
-
blockTypeName: currentBlockType.name,
|
204
|
-
blockTypeIcon:
|
206
|
+
blockTypeName: currentBlockType === null || currentBlockType === void 0 ? void 0 : currentBlockType.name,
|
207
|
+
blockTypeIcon: currentIcon || defaultIcon
|
205
208
|
});
|
206
209
|
return jsx("span", {
|
207
210
|
css: editorExperiment('platform_editor_blockquote_in_text_formatting_menu', true) ?
|
@@ -259,7 +262,7 @@ class ToolbarBlockType extends React.PureComponent {
|
|
259
262
|
onKeyDown: this.handleTriggerByKeyboard,
|
260
263
|
formatMessage: formatMessage,
|
261
264
|
"aria-expanded": active,
|
262
|
-
blockTypeName: currentBlockType.name
|
265
|
+
blockTypeName: currentBlockType === null || currentBlockType === void 0 ? void 0 : currentBlockType.name
|
263
266
|
}), !(api !== null && api !== void 0 && api.primaryToolbar) && jsx("span", {
|
264
267
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
265
268
|
css: separatorStyles
|
@@ -1,5 +1,12 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { blockTypeMessages as messages } from '@atlaskit/editor-common/messages';
|
3
|
+
import TextHeadingFiveIcon from '@atlaskit/icon-lab/core/text-heading-five';
|
4
|
+
import TextHeadingFourIcon from '@atlaskit/icon-lab/core/text-heading-four';
|
5
|
+
import TextHeadingOneIcon from '@atlaskit/icon-lab/core/text-heading-one';
|
6
|
+
import TextHeadingSixIcon from '@atlaskit/icon-lab/core/text-heading-six';
|
7
|
+
import TextHeadingThreeIcon from '@atlaskit/icon-lab/core/text-heading-three';
|
8
|
+
import TextHeadingTwoIcon from '@atlaskit/icon-lab/core/text-heading-two';
|
9
|
+
import TextIcon from '@atlaskit/icon/core/text';
|
3
10
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
4
11
|
import { Text, H1, H2, H3, H4, H5, H6 } from './ui/ToolbarBlockType/icons';
|
5
12
|
export var NORMAL_TEXT = {
|
@@ -7,7 +14,10 @@ export var NORMAL_TEXT = {
|
|
7
14
|
title: messages.normal,
|
8
15
|
nodeName: 'paragraph',
|
9
16
|
tagName: 'p',
|
10
|
-
icon: /*#__PURE__*/React.createElement(
|
17
|
+
icon: /*#__PURE__*/React.createElement(TextIcon, {
|
18
|
+
label: ""
|
19
|
+
}),
|
20
|
+
LEGACY_icon: /*#__PURE__*/React.createElement(Text, null)
|
11
21
|
};
|
12
22
|
export var HEADING_1 = {
|
13
23
|
name: 'heading1',
|
@@ -15,7 +25,10 @@ export var HEADING_1 = {
|
|
15
25
|
nodeName: 'heading',
|
16
26
|
tagName: 'h1',
|
17
27
|
level: 1,
|
18
|
-
icon: /*#__PURE__*/React.createElement(
|
28
|
+
icon: /*#__PURE__*/React.createElement(TextHeadingOneIcon, {
|
29
|
+
label: ""
|
30
|
+
}),
|
31
|
+
LEGACY_icon: /*#__PURE__*/React.createElement(H1, null)
|
19
32
|
};
|
20
33
|
export var HEADING_2 = {
|
21
34
|
name: 'heading2',
|
@@ -23,7 +36,10 @@ export var HEADING_2 = {
|
|
23
36
|
nodeName: 'heading',
|
24
37
|
tagName: 'h2',
|
25
38
|
level: 2,
|
26
|
-
icon: /*#__PURE__*/React.createElement(
|
39
|
+
icon: /*#__PURE__*/React.createElement(TextHeadingTwoIcon, {
|
40
|
+
label: ""
|
41
|
+
}),
|
42
|
+
LEGACY_icon: /*#__PURE__*/React.createElement(H2, null)
|
27
43
|
};
|
28
44
|
export var HEADING_3 = {
|
29
45
|
name: 'heading3',
|
@@ -31,7 +47,10 @@ export var HEADING_3 = {
|
|
31
47
|
nodeName: 'heading',
|
32
48
|
tagName: 'h3',
|
33
49
|
level: 3,
|
34
|
-
icon: /*#__PURE__*/React.createElement(
|
50
|
+
icon: /*#__PURE__*/React.createElement(TextHeadingThreeIcon, {
|
51
|
+
label: ""
|
52
|
+
}),
|
53
|
+
LEGACY_icon: /*#__PURE__*/React.createElement(H3, null)
|
35
54
|
};
|
36
55
|
export var HEADING_4 = {
|
37
56
|
name: 'heading4',
|
@@ -39,7 +58,10 @@ export var HEADING_4 = {
|
|
39
58
|
nodeName: 'heading',
|
40
59
|
tagName: 'h4',
|
41
60
|
level: 4,
|
42
|
-
icon: /*#__PURE__*/React.createElement(
|
61
|
+
icon: /*#__PURE__*/React.createElement(TextHeadingFourIcon, {
|
62
|
+
label: ""
|
63
|
+
}),
|
64
|
+
LEGACY_icon: /*#__PURE__*/React.createElement(H4, null)
|
43
65
|
};
|
44
66
|
export var HEADING_5 = {
|
45
67
|
name: 'heading5',
|
@@ -47,7 +69,10 @@ export var HEADING_5 = {
|
|
47
69
|
nodeName: 'heading',
|
48
70
|
tagName: 'h5',
|
49
71
|
level: 5,
|
50
|
-
icon: /*#__PURE__*/React.createElement(
|
72
|
+
icon: /*#__PURE__*/React.createElement(TextHeadingFiveIcon, {
|
73
|
+
label: ""
|
74
|
+
}),
|
75
|
+
LEGACY_icon: /*#__PURE__*/React.createElement(H5, null)
|
51
76
|
};
|
52
77
|
export var HEADING_6 = {
|
53
78
|
name: 'heading6',
|
@@ -55,7 +80,10 @@ export var HEADING_6 = {
|
|
55
80
|
nodeName: 'heading',
|
56
81
|
tagName: 'h6',
|
57
82
|
level: 6,
|
58
|
-
icon: /*#__PURE__*/React.createElement(
|
83
|
+
icon: /*#__PURE__*/React.createElement(TextHeadingSixIcon, {
|
84
|
+
label: ""
|
85
|
+
}),
|
86
|
+
LEGACY_icon: /*#__PURE__*/React.createElement(H6, null)
|
59
87
|
};
|
60
88
|
export var BLOCK_QUOTE = {
|
61
89
|
name: 'blockquote',
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import React, { useCallback } from 'react';
|
2
2
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
3
3
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
4
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
4
5
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
5
6
|
import ToolbarBlockType from './ToolbarBlockType';
|
6
7
|
var FloatingToolbarSettings = {
|
@@ -11,8 +12,40 @@ var FloatingToolbarSettings = {
|
|
11
12
|
};
|
12
13
|
export function FloatingToolbarComponent(_ref) {
|
13
14
|
var api = _ref.api;
|
14
|
-
var _useSharedPluginState = useSharedPluginState(api, ['blockType']
|
15
|
+
var _useSharedPluginState = useSharedPluginState(api, ['blockType'], {
|
16
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
|
17
|
+
}),
|
15
18
|
blockTypeState = _useSharedPluginState.blockTypeState;
|
19
|
+
|
20
|
+
// currentBlockType
|
21
|
+
var currentBlockTypeSelector = useSharedPluginStateSelector(api, 'blockType.currentBlockType', {
|
22
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
23
|
+
});
|
24
|
+
var currentBlockType = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? currentBlockTypeSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.currentBlockType;
|
25
|
+
|
26
|
+
// blockTypesDisabled
|
27
|
+
var blockTypesDisabledSelector = useSharedPluginStateSelector(api, 'blockType.blockTypesDisabled', {
|
28
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
29
|
+
});
|
30
|
+
var blockTypesDisabled = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? blockTypesDisabledSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.blockTypesDisabled;
|
31
|
+
|
32
|
+
// availableBlockTypes
|
33
|
+
var availableBlockTypesSelector = useSharedPluginStateSelector(api, 'blockType.availableBlockTypes', {
|
34
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
35
|
+
});
|
36
|
+
var availableBlockTypes = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? availableBlockTypesSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.availableBlockTypes;
|
37
|
+
|
38
|
+
// availableBlockTypesInDropdown
|
39
|
+
var availableBlockTypesInDropdownSelector = useSharedPluginStateSelector(api, 'blockType.availableBlockTypesInDropdown', {
|
40
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
41
|
+
});
|
42
|
+
var availableBlockTypesInDropdown = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? availableBlockTypesInDropdownSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.availableBlockTypesInDropdown;
|
43
|
+
|
44
|
+
// formattingIsPresent
|
45
|
+
var formattingIsPresentSelector = useSharedPluginStateSelector(api, 'blockType.formattingIsPresent', {
|
46
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
47
|
+
});
|
48
|
+
var formattingIsPresent = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? formattingIsPresentSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.formattingIsPresent;
|
16
49
|
var boundSetBlockType = useCallback(function (name) {
|
17
50
|
var _api$core, _api$blockType;
|
18
51
|
return api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(api === null || api === void 0 || (_api$blockType = api.blockType) === null || _api$blockType === void 0 || (_api$blockType = _api$blockType.commands) === null || _api$blockType === void 0 ? void 0 : _api$blockType.setTextLevel(name, INPUT_METHOD.FLOATING_TB));
|
@@ -29,11 +62,12 @@ export function FloatingToolbarComponent(_ref) {
|
|
29
62
|
isSmall: FloatingToolbarSettings.isSmall,
|
30
63
|
isDisabled: FloatingToolbarSettings.disabled,
|
31
64
|
isReducedSpacing: editorExperiment('platform_editor_controls', 'variant1') ? false : FloatingToolbarSettings.isToolbarReducedSpacing,
|
32
|
-
setTextLevel: boundSetBlockType
|
33
|
-
|
34
|
-
|
35
|
-
,
|
36
|
-
|
65
|
+
setTextLevel: boundSetBlockType,
|
66
|
+
currentBlockType: currentBlockType,
|
67
|
+
blockTypesDisabled: blockTypesDisabled,
|
68
|
+
availableBlockTypes: availableBlockTypes,
|
69
|
+
availableBlockTypesInDropdown: availableBlockTypesInDropdown,
|
70
|
+
formattingIsPresent: formattingIsPresent,
|
37
71
|
wrapBlockQuote: wrapBlockQuote,
|
38
72
|
clearFormatting: clearFormatting,
|
39
73
|
shouldUseDefaultRole: FloatingToolbarSettings.shouldUseDefaultRole,
|
@@ -1,6 +1,8 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
3
3
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
4
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
5
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
4
6
|
import ToolbarBlockType from './ToolbarBlockType';
|
5
7
|
export function PrimaryToolbarComponent(_ref) {
|
6
8
|
var api = _ref.api,
|
@@ -11,8 +13,40 @@ export function PrimaryToolbarComponent(_ref) {
|
|
11
13
|
popupsBoundariesElement = _ref.popupsBoundariesElement,
|
12
14
|
popupsScrollableElement = _ref.popupsScrollableElement,
|
13
15
|
shouldUseDefaultRole = _ref.shouldUseDefaultRole;
|
14
|
-
var _useSharedPluginState = useSharedPluginState(api, ['blockType']
|
16
|
+
var _useSharedPluginState = useSharedPluginState(api, ['blockType'], {
|
17
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
|
18
|
+
}),
|
15
19
|
blockTypeState = _useSharedPluginState.blockTypeState;
|
20
|
+
|
21
|
+
// currentBlockType
|
22
|
+
var currentBlockTypeSelector = useSharedPluginStateSelector(api, 'blockType.currentBlockType', {
|
23
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
24
|
+
});
|
25
|
+
var currentBlockType = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? currentBlockTypeSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.currentBlockType;
|
26
|
+
|
27
|
+
// blockTypesDisabled
|
28
|
+
var blockTypesDisabledSelector = useSharedPluginStateSelector(api, 'blockType.blockTypesDisabled', {
|
29
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
30
|
+
});
|
31
|
+
var blockTypesDisabled = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? blockTypesDisabledSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.blockTypesDisabled;
|
32
|
+
|
33
|
+
// availableBlockTypes
|
34
|
+
var availableBlockTypesSelector = useSharedPluginStateSelector(api, 'blockType.availableBlockTypes', {
|
35
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
36
|
+
});
|
37
|
+
var availableBlockTypes = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? availableBlockTypesSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.availableBlockTypes;
|
38
|
+
|
39
|
+
// availableBlockTypesInDropdown
|
40
|
+
var availableBlockTypesInDropdownSelector = useSharedPluginStateSelector(api, 'blockType.availableBlockTypesInDropdown', {
|
41
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
42
|
+
});
|
43
|
+
var availableBlockTypesInDropdown = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? availableBlockTypesInDropdownSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.availableBlockTypesInDropdown;
|
44
|
+
|
45
|
+
// formattingIsPresent
|
46
|
+
var formattingIsPresentSelector = useSharedPluginStateSelector(api, 'blockType.formattingIsPresent', {
|
47
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
48
|
+
});
|
49
|
+
var formattingIsPresent = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? formattingIsPresentSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.formattingIsPresent;
|
16
50
|
var boundSetBlockType = function boundSetBlockType(name, fromBlockQuote) {
|
17
51
|
var _api$core, _api$blockType;
|
18
52
|
return api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(api === null || api === void 0 || (_api$blockType = api.blockType) === null || _api$blockType === void 0 || (_api$blockType = _api$blockType.commands) === null || _api$blockType === void 0 ? void 0 : _api$blockType.setTextLevel(name, INPUT_METHOD.TOOLBAR, fromBlockQuote));
|
@@ -31,11 +65,12 @@ export function PrimaryToolbarComponent(_ref) {
|
|
31
65
|
isReducedSpacing: isToolbarReducedSpacing,
|
32
66
|
setTextLevel: boundSetBlockType,
|
33
67
|
wrapBlockQuote: wrapBlockQuote,
|
34
|
-
clearFormatting: clearFormatting
|
35
|
-
|
36
|
-
|
37
|
-
,
|
38
|
-
|
68
|
+
clearFormatting: clearFormatting,
|
69
|
+
currentBlockType: currentBlockType,
|
70
|
+
blockTypesDisabled: blockTypesDisabled,
|
71
|
+
availableBlockTypes: availableBlockTypes,
|
72
|
+
availableBlockTypesInDropdown: availableBlockTypesInDropdown,
|
73
|
+
formattingIsPresent: formattingIsPresent,
|
39
74
|
popupsMountPoint: popupsMountPoint,
|
40
75
|
popupsBoundariesElement: popupsBoundariesElement,
|
41
76
|
popupsScrollableElement: popupsScrollableElement,
|
@@ -13,6 +13,7 @@ import { ToolbarButton } from '@atlaskit/editor-common/ui-menu';
|
|
13
13
|
import TextIcon from '@atlaskit/icon/core/text';
|
14
14
|
import { default as TextStyleIconLegacy } from '@atlaskit/icon/glyph/editor/text-style';
|
15
15
|
import ChevronDownIcon from '@atlaskit/icon/utility/migration/chevron-down';
|
16
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
16
17
|
import { Box, xcss } from '@atlaskit/primitives';
|
17
18
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
18
19
|
import { NORMAL_TEXT } from '../../block-types';
|
@@ -38,6 +39,7 @@ export var BlockTypeButton = function BlockTypeButton(props) {
|
|
38
39
|
color: "currentColor",
|
39
40
|
LEGACY_fallbackIcon: TextStyleIconLegacy
|
40
41
|
});
|
42
|
+
var chevronIconSpacing = props.isSmall && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_4') ? 'spacious' : 'none';
|
41
43
|
return jsx(ToolbarButton, {
|
42
44
|
spacing: props.isReducedSpacing ? 'none' : 'default',
|
43
45
|
selected: props.selected
|
@@ -59,6 +61,7 @@ export var BlockTypeButton = function BlockTypeButton(props) {
|
|
59
61
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
60
62
|
css: expandIconContainerStyle
|
61
63
|
}, jsx(ChevronDownIcon, {
|
64
|
+
spacing: chevronIconSpacing,
|
62
65
|
label: "",
|
63
66
|
color: "currentColor",
|
64
67
|
LEGACY_margin: "0 0 0 -8px"
|
@@ -22,6 +22,7 @@ import { toolbarMessages } from '@atlaskit/editor-common/messages';
|
|
22
22
|
import { separatorStyles, wrapperStyle } from '@atlaskit/editor-common/styles';
|
23
23
|
import { DropdownMenuWithKeyboardNavigation as DropdownMenu } from '@atlaskit/editor-common/ui-menu';
|
24
24
|
import { akEditorMenuZIndex } from '@atlaskit/editor-shared-styles';
|
25
|
+
import TextIcon from '@atlaskit/icon/core/text';
|
25
26
|
import { fg } from '@atlaskit/platform-feature-flags';
|
26
27
|
import { Box, xcss } from '@atlaskit/primitives';
|
27
28
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
@@ -71,16 +72,17 @@ var ToolbarBlockType = /*#__PURE__*/function (_React$PureComponent) {
|
|
71
72
|
}
|
72
73
|
});
|
73
74
|
_defineProperty(_this, "createItems", function () {
|
74
|
-
var
|
75
|
-
|
76
|
-
currentBlockType = _this$props
|
77
|
-
availableBlockTypesInDropdown = _this$props
|
78
|
-
formattingIsPresent = _this$props
|
79
|
-
var items = availableBlockTypesInDropdown.map(function (blockType, index) {
|
75
|
+
var _this$props = _this.props,
|
76
|
+
formatMessage = _this$props.intl.formatMessage,
|
77
|
+
currentBlockType = _this$props.currentBlockType,
|
78
|
+
availableBlockTypesInDropdown = _this$props.availableBlockTypesInDropdown,
|
79
|
+
formattingIsPresent = _this$props.formattingIsPresent;
|
80
|
+
var items = (availableBlockTypesInDropdown !== null && availableBlockTypesInDropdown !== void 0 ? availableBlockTypesInDropdown : []).map(function (blockType, index) {
|
80
81
|
var isActive = currentBlockType === blockType;
|
81
82
|
var tagName = blockType.tagName || 'p';
|
82
83
|
var Tag = tagName;
|
83
84
|
var keyMap = findKeymapByDescription(blockType.title.defaultMessage);
|
85
|
+
var icon = fg('platform_editor_controls_patch_4') ? blockType === null || blockType === void 0 ? void 0 : blockType.icon : blockType.LEGACY_icon;
|
84
86
|
var item = {
|
85
87
|
content:
|
86
88
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
@@ -90,7 +92,7 @@ var ToolbarBlockType = /*#__PURE__*/function (_React$PureComponent) {
|
|
90
92
|
value: blockType,
|
91
93
|
'aria-label': tooltip(keyMap, formatMessage(blockType.title)),
|
92
94
|
key: "".concat(blockType.name, "-").concat(index),
|
93
|
-
elemBefore: editorExperiment('platform_editor_controls', 'variant1') ?
|
95
|
+
elemBefore: editorExperiment('platform_editor_controls', 'variant1') ? icon : undefined,
|
94
96
|
elemAfter:
|
95
97
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
96
98
|
jsx("div", {
|
@@ -100,7 +102,7 @@ var ToolbarBlockType = /*#__PURE__*/function (_React$PureComponent) {
|
|
100
102
|
};
|
101
103
|
return item;
|
102
104
|
});
|
103
|
-
if (availableBlockTypesInDropdown.map(function (blockType) {
|
105
|
+
if ((availableBlockTypesInDropdown !== null && availableBlockTypesInDropdown !== void 0 ? availableBlockTypesInDropdown : []).map(function (blockType) {
|
104
106
|
return blockType.name;
|
105
107
|
}).includes('blockquote') && editorExperiment('platform_editor_controls', 'control')) {
|
106
108
|
var clearFormattingItem = {
|
@@ -139,7 +141,8 @@ var ToolbarBlockType = /*#__PURE__*/function (_React$PureComponent) {
|
|
139
141
|
if (blockType.name === 'clearFormatting') {
|
140
142
|
_this.props.clearFormatting();
|
141
143
|
} else {
|
142
|
-
var
|
144
|
+
var _this$props$currentBl;
|
145
|
+
var fromBlockQuote = ((_this$props$currentBl = _this.props.currentBlockType) === null || _this$props$currentBl === void 0 ? void 0 : _this$props$currentBl.name) === 'blockquote';
|
143
146
|
_this.props.setTextLevel(blockType.name, fromBlockQuote);
|
144
147
|
}
|
145
148
|
}
|
@@ -182,20 +185,21 @@ var ToolbarBlockType = /*#__PURE__*/function (_React$PureComponent) {
|
|
182
185
|
var _this$state = this.state,
|
183
186
|
active = _this$state.active,
|
184
187
|
isOpenedByKeyboard = _this$state.isOpenedByKeyboard;
|
185
|
-
var _this$
|
186
|
-
popupsMountPoint = _this$
|
187
|
-
popupsBoundariesElement = _this$
|
188
|
-
popupsScrollableElement = _this$
|
189
|
-
isSmall = _this$
|
190
|
-
isReducedSpacing = _this$
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
availableBlockTypes = _this$
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
188
|
+
var _this$props2 = this.props,
|
189
|
+
popupsMountPoint = _this$props2.popupsMountPoint,
|
190
|
+
popupsBoundariesElement = _this$props2.popupsBoundariesElement,
|
191
|
+
popupsScrollableElement = _this$props2.popupsScrollableElement,
|
192
|
+
isSmall = _this$props2.isSmall,
|
193
|
+
isReducedSpacing = _this$props2.isReducedSpacing,
|
194
|
+
currentBlockType = _this$props2.currentBlockType,
|
195
|
+
blockTypesDisabled = _this$props2.blockTypesDisabled,
|
196
|
+
_this$props2$availabl = _this$props2.availableBlockTypes,
|
197
|
+
availableBlockTypes = _this$props2$availabl === void 0 ? [] : _this$props2$availabl,
|
198
|
+
_this$props2$availabl2 = _this$props2.availableBlockTypesInDropdown,
|
199
|
+
availableBlockTypesInDropdown = _this$props2$availabl2 === void 0 ? [] : _this$props2$availabl2,
|
200
|
+
shouldUseDefaultRole = _this$props2.shouldUseDefaultRole,
|
201
|
+
formatMessage = _this$props2.intl.formatMessage,
|
202
|
+
api = _this$props2.api;
|
199
203
|
var isHeadingDisabled = !availableBlockTypes.some(function (blockType) {
|
200
204
|
return blockType.nodeName === 'heading';
|
201
205
|
});
|
@@ -203,10 +207,14 @@ var ToolbarBlockType = /*#__PURE__*/function (_React$PureComponent) {
|
|
203
207
|
return null;
|
204
208
|
}
|
205
209
|
var blockTypeTitles = availableBlockTypesInDropdown.filter(function (blockType) {
|
206
|
-
return blockType.name === currentBlockType.name;
|
210
|
+
return blockType.name === (currentBlockType === null || currentBlockType === void 0 ? void 0 : currentBlockType.name);
|
207
211
|
}).map(function (blockType) {
|
208
212
|
return blockType.title;
|
209
213
|
});
|
214
|
+
var defaultIcon = fg('platform_editor_controls_patch_4') ? jsx(TextIcon, {
|
215
|
+
label: ""
|
216
|
+
}) : jsx(Text, null);
|
217
|
+
var currentIcon = fg('platform_editor_controls_patch_4') ? currentBlockType === null || currentBlockType === void 0 ? void 0 : currentBlockType.icon : currentBlockType === null || currentBlockType === void 0 ? void 0 : currentBlockType.LEGACY_icon;
|
210
218
|
if (!this.props.isDisabled && !blockTypesDisabled) {
|
211
219
|
var items = this.createItems();
|
212
220
|
var button = jsx(BlockTypeButton, {
|
@@ -219,8 +227,8 @@ var ToolbarBlockType = /*#__PURE__*/function (_React$PureComponent) {
|
|
219
227
|
onKeyDown: this.handleTriggerByKeyboard,
|
220
228
|
formatMessage: formatMessage,
|
221
229
|
"aria-expanded": active,
|
222
|
-
blockTypeName: currentBlockType.name,
|
223
|
-
blockTypeIcon:
|
230
|
+
blockTypeName: currentBlockType === null || currentBlockType === void 0 ? void 0 : currentBlockType.name,
|
231
|
+
blockTypeIcon: currentIcon || defaultIcon
|
224
232
|
});
|
225
233
|
return jsx("span", {
|
226
234
|
css: editorExperiment('platform_editor_blockquote_in_text_formatting_menu', true) ?
|
@@ -277,7 +285,7 @@ var ToolbarBlockType = /*#__PURE__*/function (_React$PureComponent) {
|
|
277
285
|
onKeyDown: this.handleTriggerByKeyboard,
|
278
286
|
formatMessage: formatMessage,
|
279
287
|
"aria-expanded": active,
|
280
|
-
blockTypeName: currentBlockType.name
|
288
|
+
blockTypeName: currentBlockType === null || currentBlockType === void 0 ? void 0 : currentBlockType.name
|
281
289
|
}), !(api !== null && api !== void 0 && api.primaryToolbar) && jsx("span", {
|
282
290
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
283
291
|
css: separatorStyles
|
@@ -10,7 +10,6 @@ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
10
10
|
import { ThemeMutationObserver } from '@atlaskit/tokens';
|
11
11
|
import type { BlockTypePlugin } from '../../../blockTypePluginType';
|
12
12
|
import type { TextBlockTypes } from '../../block-types';
|
13
|
-
import type { BlockTypeState } from '../../main';
|
14
13
|
import type { BlockType } from '../../types';
|
15
14
|
export type DropdownItem = MenuItem & {
|
16
15
|
value: BlockType;
|
@@ -19,7 +18,11 @@ export interface Props {
|
|
19
18
|
isDisabled?: boolean;
|
20
19
|
isSmall?: boolean;
|
21
20
|
isReducedSpacing?: boolean;
|
22
|
-
|
21
|
+
currentBlockType?: BlockType;
|
22
|
+
blockTypesDisabled?: boolean;
|
23
|
+
availableBlockTypes?: BlockType[];
|
24
|
+
availableBlockTypesInDropdown?: BlockType[];
|
25
|
+
formattingIsPresent?: boolean;
|
23
26
|
popupsMountPoint?: HTMLElement;
|
24
27
|
popupsBoundariesElement?: HTMLElement;
|
25
28
|
popupsScrollableElement?: HTMLElement;
|