@atlaskit/editor-plugin-text-formatting 2.1.2 → 2.1.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.
Files changed (50) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/pm-plugins/cursor.js +1 -1
  3. package/dist/cjs/pm-plugins/main.js +1 -1
  4. package/dist/cjs/textFormattingPlugin.js +1 -10
  5. package/dist/cjs/ui/FloatingToolbarComponent.js +23 -7
  6. package/dist/cjs/ui/Toolbar/constants.js +2 -1
  7. package/dist/cjs/ui/Toolbar/dropdown-menu.js +9 -4
  8. package/dist/cjs/ui/Toolbar/{bold-button.js → dropdown-toolbar-button.js} +6 -5
  9. package/dist/cjs/ui/Toolbar/hooks/clear-formatting-icon.js +6 -0
  10. package/dist/cjs/ui/Toolbar/hooks/formatting-icons.js +45 -4
  11. package/dist/cjs/ui/Toolbar/hooks/responsive-toolbar-buttons.js +5 -23
  12. package/dist/cjs/ui/Toolbar/hooks/use-icon-list.js +34 -0
  13. package/dist/cjs/ui/Toolbar/icons.js +64 -0
  14. package/dist/es2019/pm-plugins/cursor.js +1 -1
  15. package/dist/es2019/pm-plugins/main.js +1 -1
  16. package/dist/es2019/textFormattingPlugin.js +1 -10
  17. package/dist/es2019/ui/FloatingToolbarComponent.js +21 -7
  18. package/dist/es2019/ui/Toolbar/constants.js +1 -0
  19. package/dist/es2019/ui/Toolbar/dropdown-menu.js +7 -4
  20. package/dist/es2019/ui/Toolbar/{bold-button.js → dropdown-toolbar-button.js} +5 -4
  21. package/dist/es2019/ui/Toolbar/hooks/clear-formatting-icon.js +5 -0
  22. package/dist/es2019/ui/Toolbar/hooks/formatting-icons.js +45 -1
  23. package/dist/es2019/ui/Toolbar/hooks/responsive-toolbar-buttons.js +5 -21
  24. package/dist/es2019/ui/Toolbar/hooks/use-icon-list.js +27 -0
  25. package/dist/es2019/ui/Toolbar/icons.js +49 -0
  26. package/dist/esm/pm-plugins/cursor.js +1 -1
  27. package/dist/esm/pm-plugins/main.js +1 -1
  28. package/dist/esm/textFormattingPlugin.js +1 -10
  29. package/dist/esm/ui/FloatingToolbarComponent.js +20 -7
  30. package/dist/esm/ui/Toolbar/constants.js +1 -0
  31. package/dist/esm/ui/Toolbar/dropdown-menu.js +9 -4
  32. package/dist/esm/ui/Toolbar/{bold-button.js → dropdown-toolbar-button.js} +5 -4
  33. package/dist/esm/ui/Toolbar/hooks/clear-formatting-icon.js +5 -0
  34. package/dist/esm/ui/Toolbar/hooks/formatting-icons.js +45 -1
  35. package/dist/esm/ui/Toolbar/hooks/responsive-toolbar-buttons.js +5 -22
  36. package/dist/esm/ui/Toolbar/hooks/use-icon-list.js +27 -0
  37. package/dist/esm/ui/Toolbar/icons.js +56 -0
  38. package/dist/types/ui/FloatingToolbarComponent.d.ts +7 -3
  39. package/dist/types/ui/Toolbar/constants.d.ts +1 -0
  40. package/dist/{types-ts4.5/ui/Toolbar/bold-button.d.ts → types/ui/Toolbar/dropdown-toolbar-button.d.ts} +4 -3
  41. package/dist/types/ui/Toolbar/hooks/responsive-toolbar-buttons.d.ts +1 -5
  42. package/dist/types/ui/Toolbar/hooks/use-icon-list.d.ts +11 -0
  43. package/dist/types/ui/Toolbar/icons.d.ts +4 -0
  44. package/dist/types-ts4.5/ui/FloatingToolbarComponent.d.ts +7 -3
  45. package/dist/types-ts4.5/ui/Toolbar/constants.d.ts +1 -0
  46. package/dist/{types/ui/Toolbar/bold-button.d.ts → types-ts4.5/ui/Toolbar/dropdown-toolbar-button.d.ts} +4 -3
  47. package/dist/types-ts4.5/ui/Toolbar/hooks/responsive-toolbar-buttons.d.ts +1 -5
  48. package/dist/types-ts4.5/ui/Toolbar/hooks/use-icon-list.d.ts +11 -0
  49. package/dist/types-ts4.5/ui/Toolbar/icons.d.ts +4 -0
  50. package/package.json +5 -5
@@ -2,7 +2,8 @@ import React, { useCallback, useState } from 'react';
2
2
  import { toolbarMessages } from '@atlaskit/editor-common/messages';
3
3
  import { DropdownMenuWithKeyboardNavigation as DropdownMenu } from '@atlaskit/editor-common/ui-menu';
4
4
  import { akEditorMenuZIndex } from '@atlaskit/editor-shared-styles';
5
- import { BoldToolbarButton } from './bold-button';
5
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
6
+ import { DropdownToolbarButton } from './dropdown-toolbar-button';
6
7
  import { useMenuState } from './hooks/menu-state';
7
8
  import { MoreButton } from './more-button';
8
9
  export const FormattingTextDropdownMenu = /*#__PURE__*/React.memo(({
@@ -31,6 +32,7 @@ export const FormattingTextDropdownMenu = /*#__PURE__*/React.memo(({
31
32
  }
32
33
  }
33
34
  }, [editorView.state, editorView.dispatch, closeMenu]);
35
+ const activeItem = items[0].items.find(item => item.isActive);
34
36
  return /*#__PURE__*/React.createElement(DropdownMenu, {
35
37
  mountTo: popupsMountPoint,
36
38
  onOpenChange: closeMenu,
@@ -41,7 +43,7 @@ export const FormattingTextDropdownMenu = /*#__PURE__*/React.memo(({
41
43
  items: items,
42
44
  zIndex: akEditorMenuZIndex,
43
45
  fitHeight: 188,
44
- fitWidth: 136,
46
+ fitWidth: editorExperiment('platform_editor_controls', 'control') ? 136 : 230,
45
47
  shouldUseDefaultRole: true,
46
48
  section: {
47
49
  hasSeparator: true
@@ -69,7 +71,7 @@ export const FormattingTextDropdownMenu = /*#__PURE__*/React.memo(({
69
71
  }
70
72
  },
71
73
  "aria-expanded": isMenuOpen
72
- }) : /*#__PURE__*/React.createElement(BoldToolbarButton, {
74
+ }) : /*#__PURE__*/React.createElement(DropdownToolbarButton, {
73
75
  isReducedSpacing: isReducedSpacing,
74
76
  isDisabled: false,
75
77
  isSelected: isMenuOpen,
@@ -87,6 +89,7 @@ export const FormattingTextDropdownMenu = /*#__PURE__*/React.memo(({
87
89
  setIsOpenedByKeyboard(true);
88
90
  }
89
91
  },
90
- toolbarType: toolbarType
92
+ toolbarType: toolbarType,
93
+ iconBefore: activeItem ? activeItem === null || activeItem === void 0 ? void 0 : activeItem.elemBefore : undefined
91
94
  }));
92
95
  });
@@ -8,11 +8,11 @@ import React from 'react';
8
8
  import { jsx } from '@emotion/react';
9
9
  import { expandIconContainerStyle, triggerWrapperStyles, triggerWrapperStylesWithPadding, disableBlueBorderStyles } from '@atlaskit/editor-common/styles';
10
10
  import { ToolbarButton } from '@atlaskit/editor-common/ui-menu';
11
- import BoldIcon from '@atlaskit/icon/core/migration/text-bold--editor-bold';
11
+ import ItalicIcon from '@atlaskit/icon/core/migration/text-italic--editor-italic';
12
12
  import ChevronDownIcon from '@atlaskit/icon/utility/migration/chevron-down';
13
13
  import { fg } from '@atlaskit/platform-feature-flags';
14
14
  import { ToolbarType } from './types';
15
- export const BoldToolbarButton = ({
15
+ export const DropdownToolbarButton = ({
16
16
  label,
17
17
  isReducedSpacing,
18
18
  isDisabled,
@@ -20,7 +20,8 @@ export const BoldToolbarButton = ({
20
20
  'aria-expanded': ariaExpanded,
21
21
  onClick,
22
22
  onKeyDown,
23
- toolbarType
23
+ toolbarType,
24
+ iconBefore
24
25
  }) => {
25
26
  const reducedSpacing = toolbarType === ToolbarType.FLOATING ? 'compact' : 'none';
26
27
  return jsx(ToolbarButton
@@ -45,7 +46,7 @@ export const BoldToolbarButton = ({
45
46
  triggerWrapperStylesWithPadding :
46
47
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values
47
48
  triggerWrapperStyles
48
- }, jsx(BoldIcon, {
49
+ }, iconBefore ? iconBefore : jsx(ItalicIcon, {
49
50
  color: "currentColor",
50
51
  spacing: "spacious",
51
52
  label: ""
@@ -9,6 +9,8 @@ import { jsx } from '@emotion/react';
9
9
  import { clearFormatting as clearFormattingKeymap, tooltip } from '@atlaskit/editor-common/keymaps';
10
10
  import { toolbarMessages } from '@atlaskit/editor-common/messages';
11
11
  import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
12
+ import TableCellClearIcon from '@atlaskit/icon/core/table-cell-clear';
13
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
12
14
  import { clearFormattingWithAnalytics } from '../../../editor-commands/clear-formatting';
13
15
  import { getInputMethod } from '../input-method-utils';
14
16
  export const useClearIcon = ({
@@ -29,6 +31,9 @@ export const useClearIcon = ({
29
31
  key: 'clearFormatting',
30
32
  command: clearFormattingToolbar,
31
33
  content: clearFormattingLabel,
34
+ elemBefore: editorExperiment('platform_editor_controls', 'variant1') ? jsx(TableCellClearIcon, {
35
+ label: ""
36
+ }) : undefined,
32
37
  elemAfter:
33
38
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
34
39
  jsx("div", {
@@ -2,7 +2,7 @@
2
2
  * @jsxRuntime classic
3
3
  * @jsx jsx
4
4
  */
5
- import React, { useMemo } from 'react';
5
+ import { useMemo } from 'react';
6
6
 
7
7
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
8
8
  import { jsx } from '@emotion/react';
@@ -11,10 +11,13 @@ import { getAriaKeyshortcuts, toggleBold, toggleCode, toggleItalic, toggleStrike
11
11
  import { toolbarMessages } from '@atlaskit/editor-common/messages';
12
12
  import { editorCommandToPMCommand } from '@atlaskit/editor-common/preset';
13
13
  import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
14
+ import AngleBracketsIcon from '@atlaskit/icon/core/migration/angle-brackets--editor-code';
14
15
  import BoldIcon from '@atlaskit/icon/core/migration/text-bold--editor-bold';
15
16
  import ItalicIcon from '@atlaskit/icon/core/migration/text-italic--editor-italic';
16
17
  import UnderlineIcon from '@atlaskit/icon/core/text-underline';
18
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
17
19
  import { toggleCodeWithAnalytics, toggleEmWithAnalytics, toggleStrikeWithAnalytics, toggleStrongWithAnalytics, toggleSubscriptWithAnalytics, toggleSuperscriptWithAnalytics, toggleUnderlineWithAnalytics } from '../../../pm-plugins/commands';
20
+ import { Strikethrough, Subscript, Superscript } from '../icons';
18
21
  import { getInputMethod } from '../input-method-utils';
19
22
  import { IconTypes } from '../types';
20
23
  const withInputMethod = (toolbarType, func) => editorCommandToPMCommand(func(getInputMethod(toolbarType)));
@@ -73,6 +76,45 @@ const IconButtons = (editorAnalyticsAPI, toolbarType) => ({
73
76
  tooltipKeymap: toggleSuperscript
74
77
  }
75
78
  });
79
+ const IconBefore = {
80
+ strong: {
81
+ icon: jsx(BoldIcon, {
82
+ color: "currentColor",
83
+ spacing: "spacious",
84
+ label: ""
85
+ })
86
+ },
87
+ em: {
88
+ icon: jsx(ItalicIcon, {
89
+ color: "currentColor",
90
+ spacing: "spacious",
91
+ label: ""
92
+ })
93
+ },
94
+ underline: {
95
+ icon: jsx(UnderlineIcon, {
96
+ color: "currentColor",
97
+ spacing: "spacious",
98
+ label: ""
99
+ })
100
+ },
101
+ strike: {
102
+ icon: jsx(Strikethrough, null)
103
+ },
104
+ code: {
105
+ icon: jsx(AngleBracketsIcon, {
106
+ color: "currentColor",
107
+ spacing: "spacious",
108
+ label: ""
109
+ })
110
+ },
111
+ subscript: {
112
+ icon: jsx(Subscript, null)
113
+ },
114
+ superscript: {
115
+ icon: jsx(Superscript, null)
116
+ }
117
+ };
76
118
  const getIcon = ({
77
119
  iconType,
78
120
  isDisabled,
@@ -82,6 +124,7 @@ const getIcon = ({
82
124
  toolbarType
83
125
  }) => {
84
126
  const icon = IconButtons(editorAnalyticsAPI, toolbarType)[iconType];
127
+ const iconBefore = IconBefore[iconType].icon;
85
128
  const content = intl.formatMessage(icon.message);
86
129
  const {
87
130
  tooltipKeymap
@@ -97,6 +140,7 @@ const getIcon = ({
97
140
  description: content,
98
141
  keymap: tooltipKeymap
99
142
  }) : undefined,
143
+ elemBefore: editorExperiment('platform_editor_controls', 'variant1') ? iconBefore : undefined,
100
144
  elemAfter: tooltipKeymap ?
101
145
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
102
146
  jsx("div", {
@@ -1,6 +1,7 @@
1
1
  import { useMemo } from 'react';
2
2
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
3
3
  import { DefaultButtonsMenu, DefaultButtonsMenuNext, DefaultButtonsToolbar, DefaultButtonsToolbarNext, ResponsiveCustomButtonToolbar as ResponsiveCustomButtonToolbarLegacy, ResponsiveCustomButtonToolbarNext, ResponsiveCustomMenu as ResponsiveCustomMenuLegacy, ResponsiveCustomMenuNext } from '../constants';
4
+ import { useIconList } from './use-icon-list';
4
5
  export const useResponsiveIconTypeButtons = ({
5
6
  toolbarSize,
6
7
  responsivenessEnabled
@@ -32,26 +33,9 @@ export const useResponsiveToolbarButtons = ({
32
33
  toolbarSize,
33
34
  responsivenessEnabled
34
35
  });
35
- const iconsPosition = useMemo(() => {
36
- return icons.reduce((acc, icon) => {
37
- if (!icon || !icon.iconMark) {
38
- return acc;
39
- }
40
- const isIconSingleButton = iconTypeList.includes(icon.iconMark);
41
- if (isIconSingleButton) {
42
- return {
43
- dropdownItems: acc.dropdownItems,
44
- singleItems: [...acc.singleItems, icon]
45
- };
46
- }
47
- return {
48
- dropdownItems: [...acc.dropdownItems, icon],
49
- singleItems: acc.singleItems
50
- };
51
- }, {
52
- dropdownItems: [],
53
- singleItems: []
54
- });
55
- }, [icons, iconTypeList]);
36
+ const iconsPosition = useIconList({
37
+ icons,
38
+ iconTypeList
39
+ });
56
40
  return iconsPosition;
57
41
  };
@@ -0,0 +1,27 @@
1
+ import { useMemo } from 'react';
2
+ export const useIconList = ({
3
+ icons,
4
+ iconTypeList
5
+ }) => {
6
+ return useMemo(() => {
7
+ return icons.reduce((acc, icon) => {
8
+ if (!icon || !icon.iconMark) {
9
+ return acc;
10
+ }
11
+ const isIconSingleButton = iconTypeList.includes(icon.iconMark);
12
+ if (isIconSingleButton) {
13
+ return {
14
+ dropdownItems: acc.dropdownItems,
15
+ singleItems: [...acc.singleItems, icon]
16
+ };
17
+ }
18
+ return {
19
+ dropdownItems: [...acc.dropdownItems, icon],
20
+ singleItems: acc.singleItems
21
+ };
22
+ }, {
23
+ dropdownItems: [],
24
+ singleItems: []
25
+ });
26
+ }, [icons, iconTypeList]);
27
+ };
@@ -0,0 +1,49 @@
1
+ /* eslint-disable @atlaskit/ui-styling-standard/enforce-style-prop */
2
+ import React from 'react';
3
+ const SVGContainer = ({
4
+ children
5
+ }) => /*#__PURE__*/React.createElement("span", {
6
+ style: {
7
+ width: "var(--ds-space-300, 24px)",
8
+ height: "var(--ds-space-300, 24px)",
9
+ display: 'flex',
10
+ justifyContent: 'center',
11
+ alignItems: 'center'
12
+ }
13
+ }, children);
14
+ export const Strikethrough = () => /*#__PURE__*/React.createElement(SVGContainer, null, /*#__PURE__*/React.createElement("svg", {
15
+ width: "16",
16
+ height: "16",
17
+ viewBox: "0 0 16 16",
18
+ fill: "none",
19
+ xmlns: "http://www.w3.org/2000/svg"
20
+ }, /*#__PURE__*/React.createElement("path", {
21
+ "fill-rule": "evenodd",
22
+ "clip-rule": "evenodd",
23
+ d: "M8.39644 7.25348H13.9004V7.25421H15V8.75421H1V7.25421H2.125V7.25H4.96062C4.45271 6.59457 4.15039 5.77182 4.15039 4.87845C4.15039 2.73833 5.8853 1.00342 8.02542 1.00342H11.9004V2.50342H8.02542C6.71373 2.50342 5.65039 3.56676 5.65039 4.87845C5.65039 6.14664 6.64437 7.18267 7.89576 7.25H8.23074C8.28625 7.25 8.3415 7.25117 8.39644 7.25348ZM12.1058 11.125C12.1058 10.6424 12.0175 10.1804 11.8563 9.75421H10.1705C10.4446 10.1415 10.6058 10.6144 10.6058 11.125C10.6058 12.4367 9.54243 13.5001 8.23074 13.5001H3.15064V15.0001H8.23074C10.3709 15.0001 12.1058 13.2652 12.1058 11.125Z",
24
+ fill: "#44546F"
25
+ })));
26
+ export const Subscript = () => /*#__PURE__*/React.createElement(SVGContainer, null, /*#__PURE__*/React.createElement("svg", {
27
+ width: "16",
28
+ height: "16",
29
+ viewBox: "0 0 16 16",
30
+ fill: "none",
31
+ xmlns: "http://www.w3.org/2000/svg"
32
+ }, /*#__PURE__*/React.createElement("path", {
33
+ "fill-rule": "evenodd",
34
+ "clip-rule": "evenodd",
35
+ d: "M5.10609 6.54799L7.88895 2.09448L9.16102 2.88936L5.99047 7.9633L9.21219 13.1191L7.94012 13.914L5.10609 9.37861L2.27207 13.914L1 13.1191L4.2217 7.9633L1.05117 2.88939L2.32324 2.09451L5.10609 6.54799ZM10.858 15.0001V13.696H12.3499V10.3153L10.8418 11.4343V9.86413L12.3138 8.83114H13.8161V13.696H14.9999V15.0001H10.858Z",
36
+ fill: "#44546F"
37
+ })));
38
+ export const Superscript = () => /*#__PURE__*/React.createElement(SVGContainer, null, /*#__PURE__*/React.createElement("svg", {
39
+ width: "16",
40
+ height: "16",
41
+ viewBox: "0 0 16 16",
42
+ fill: "none",
43
+ xmlns: "http://www.w3.org/2000/svg"
44
+ }, /*#__PURE__*/React.createElement("path", {
45
+ "fill-rule": "evenodd",
46
+ "clip-rule": "evenodd",
47
+ d: "M10.858 7.16892V5.86487H12.3499V2.4842L10.8418 3.60312V2.03298L12.3138 1H13.8161V5.86487H14.9999V7.16892H10.858ZM5.10609 6.5479L7.88895 2.09439L9.16102 2.88927L5.99047 7.96321L9.21219 13.119L7.94012 13.9139L5.10609 9.37852L2.27207 13.9139L1 13.119L4.2217 7.96321L1.05117 2.8893L2.32324 2.09442L5.10609 6.5479Z",
48
+ fill: "#44546F"
49
+ })));
@@ -22,7 +22,7 @@ export default new SafePlugin({
22
22
  var clickWasNearACodeMark = code && ($click.nodeBefore && code.isInSet($click.nodeBefore.marks) || $click.nodeAfter && code.isInSet($click.nodeAfter.marks));
23
23
 
24
24
  // Find the starting position of the clicked dom-element
25
- // TODO: Remove calls to private API
25
+ // TODO: ED-26962 - Remove calls to private API
26
26
  var clickedDOMElementPosition = event.target && event.target instanceof Node && view.posAtDOM(event.target);
27
27
  var clickNode = view.state.doc.nodeAt(clickPos);
28
28
  var clickWasAtTextNode = !!(clickNode && clickNode.isText);
@@ -1,4 +1,4 @@
1
- // TODO: Ideally this should use the custom toggleMark function from @atlaskit/editor-common so we also disable the options when selecting inline nodes but it disables the marks when the selection is empty at this point in time which is undesirable
1
+ // TODO: ED-26962 - Ideally this should use the custom toggleMark function from @atlaskit/editor-common so we also disable the options when selecting inline nodes but it disables the marks when the selection is empty at this point in time which is undesirable
2
2
  // import { toggleMark } from '@atlaskit/editor-common/mark';
3
3
 
4
4
  import { moveLeft as keymapMoveLeft, moveRight as keymapMoveRight } from '@atlaskit/editor-common/keymaps';
@@ -128,16 +128,7 @@ export var textFormattingPlugin = function textFormattingPlugin(_ref) {
128
128
  pluginsOptions: {
129
129
  selectionToolbar: function selectionToolbar() {
130
130
  var _api$selectionToolbar;
131
- if ((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) === 'top' && editorExperiment('platform_editor_controls', 'variant1', {
132
- exposure: true
133
- })) {
134
- return undefined;
135
- }
136
- if (editorExperiment('contextual_formatting_toolbar', true, {
137
- exposure: true
138
- }) || editorExperiment('platform_editor_contextual_formatting_toolbar_v2', 'variant1', {
139
- exposure: true
140
- }) || editorExperiment('platform_editor_contextual_formatting_toolbar_v2', 'variant2', {
131
+ if ((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) === 'none' && editorExperiment('platform_editor_controls', 'variant1', {
141
132
  exposure: true
142
133
  })) {
143
134
  var toolbarCustom = {
@@ -2,7 +2,7 @@
2
2
  * @jsxRuntime classic
3
3
  * @jsx jsx
4
4
  */
5
- import { useMemo } from 'react';
5
+ import React, { useMemo } from 'react';
6
6
 
7
7
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
8
8
  import { jsx } from '@emotion/react';
@@ -10,15 +10,18 @@ import { injectIntl } from 'react-intl-next';
10
10
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
11
11
  import { ToolbarSize } from '@atlaskit/editor-common/types';
12
12
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
13
+ import { DefaultFloatingToolbarButtonsNext } from './Toolbar/constants';
13
14
  import { FormattingTextDropdownMenu } from './Toolbar/dropdown-menu';
14
15
  import { useClearIcon } from './Toolbar/hooks/clear-formatting-icon';
15
16
  import { useFormattingIcons } from './Toolbar/hooks/formatting-icons';
17
+ import { useIconList } from './Toolbar/hooks/use-icon-list';
18
+ import { SingleToolbarButtons } from './Toolbar/single-toolbar-buttons';
16
19
  import { ToolbarType } from './Toolbar/types';
17
20
  var FloatingToolbarSettings = {
18
21
  disabled: false,
19
22
  isReducedSpacing: true,
20
23
  shouldUseResponsiveToolbar: false,
21
- toolbarSize: ToolbarSize.XXXS,
24
+ toolbarSize: ToolbarSize.S,
22
25
  hasMoreButton: false,
23
26
  moreButtonLabel: '',
24
27
  toolbarType: ToolbarType.FLOATING
@@ -38,6 +41,12 @@ var FloatingToolbarTextFormat = function FloatingToolbarTextFormat(_ref) {
38
41
  textFormattingState: textFormattingState,
39
42
  toolbarType: FloatingToolbarSettings.toolbarType
40
43
  });
44
+ var _useIconList = useIconList({
45
+ icons: defaultIcons,
46
+ iconTypeList: DefaultFloatingToolbarButtonsNext
47
+ }),
48
+ dropdownItems = _useIconList.dropdownItems,
49
+ singleItems = _useIconList.singleItems;
41
50
  var clearIcon = useClearIcon({
42
51
  textFormattingState: textFormattingState,
43
52
  intl: intl,
@@ -47,16 +56,20 @@ var FloatingToolbarTextFormat = function FloatingToolbarTextFormat(_ref) {
47
56
  var items = useMemo(function () {
48
57
  if (!clearIcon) {
49
58
  return [{
50
- items: defaultIcons
59
+ items: dropdownItems
51
60
  }];
52
61
  }
53
62
  return [{
54
- items: defaultIcons
63
+ items: dropdownItems
55
64
  }, {
56
65
  items: [clearIcon]
57
66
  }];
58
- }, [clearIcon, defaultIcons]);
59
- return jsx(FormattingTextDropdownMenu, {
67
+ }, [clearIcon, dropdownItems]);
68
+ return jsx(React.Fragment, null, jsx(SingleToolbarButtons, {
69
+ items: singleItems,
70
+ editorView: editorView,
71
+ isReducedSpacing: false
72
+ }), jsx(FormattingTextDropdownMenu, {
60
73
  editorView: editorView,
61
74
  items: items,
62
75
  isReducedSpacing: editorExperiment('platform_editor_controls', 'variant1') ? false : FloatingToolbarSettings.isReducedSpacing,
@@ -65,6 +78,6 @@ var FloatingToolbarTextFormat = function FloatingToolbarTextFormat(_ref) {
65
78
  hasMoreButton: FloatingToolbarSettings.hasMoreButton,
66
79
  intl: intl,
67
80
  toolbarType: FloatingToolbarSettings.toolbarType
68
- });
81
+ }));
69
82
  };
70
83
  export var FloatingToolbarTextFormalWithIntl = injectIntl(FloatingToolbarTextFormat);
@@ -2,6 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import { ToolbarSize } from '@atlaskit/editor-common/types';
3
3
  import { IconTypes } from './types';
4
4
  export var DefaultButtonsToolbar = [IconTypes.strong, IconTypes.em];
5
+ export var DefaultFloatingToolbarButtonsNext = [IconTypes.strong];
5
6
  export var DefaultButtonsToolbarNext = [IconTypes.strong, IconTypes.em, IconTypes.underline];
6
7
  export var DefaultButtonsMenu = [IconTypes.underline, IconTypes.strike, IconTypes.code, IconTypes.subscript, IconTypes.superscript];
7
8
  export var DefaultButtonsMenuNext = [IconTypes.strike, IconTypes.code, IconTypes.subscript, IconTypes.superscript];
@@ -3,7 +3,8 @@ import React, { useCallback, useState } from 'react';
3
3
  import { toolbarMessages } from '@atlaskit/editor-common/messages';
4
4
  import { DropdownMenuWithKeyboardNavigation as DropdownMenu } from '@atlaskit/editor-common/ui-menu';
5
5
  import { akEditorMenuZIndex } from '@atlaskit/editor-shared-styles';
6
- import { BoldToolbarButton } from './bold-button';
6
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
7
+ import { DropdownToolbarButton } from './dropdown-toolbar-button';
7
8
  import { useMenuState } from './hooks/menu-state';
8
9
  import { MoreButton } from './more-button';
9
10
  export var FormattingTextDropdownMenu = /*#__PURE__*/React.memo(function (_ref) {
@@ -38,6 +39,9 @@ export var FormattingTextDropdownMenu = /*#__PURE__*/React.memo(function (_ref)
38
39
  }
39
40
  }
40
41
  }, [editorView.state, editorView.dispatch, closeMenu]);
42
+ var activeItem = items[0].items.find(function (item) {
43
+ return item.isActive;
44
+ });
41
45
  return /*#__PURE__*/React.createElement(DropdownMenu, {
42
46
  mountTo: popupsMountPoint,
43
47
  onOpenChange: closeMenu,
@@ -48,7 +52,7 @@ export var FormattingTextDropdownMenu = /*#__PURE__*/React.memo(function (_ref)
48
52
  items: items,
49
53
  zIndex: akEditorMenuZIndex,
50
54
  fitHeight: 188,
51
- fitWidth: 136,
55
+ fitWidth: editorExperiment('platform_editor_controls', 'control') ? 136 : 230,
52
56
  shouldUseDefaultRole: true,
53
57
  section: {
54
58
  hasSeparator: true
@@ -76,7 +80,7 @@ export var FormattingTextDropdownMenu = /*#__PURE__*/React.memo(function (_ref)
76
80
  }
77
81
  },
78
82
  "aria-expanded": isMenuOpen
79
- }) : /*#__PURE__*/React.createElement(BoldToolbarButton, {
83
+ }) : /*#__PURE__*/React.createElement(DropdownToolbarButton, {
80
84
  isReducedSpacing: isReducedSpacing,
81
85
  isDisabled: false,
82
86
  isSelected: isMenuOpen,
@@ -94,6 +98,7 @@ export var FormattingTextDropdownMenu = /*#__PURE__*/React.memo(function (_ref)
94
98
  setIsOpenedByKeyboard(true);
95
99
  }
96
100
  },
97
- toolbarType: toolbarType
101
+ toolbarType: toolbarType,
102
+ iconBefore: activeItem ? activeItem === null || activeItem === void 0 ? void 0 : activeItem.elemBefore : undefined
98
103
  }));
99
104
  });
@@ -8,11 +8,11 @@ import React from 'react';
8
8
  import { jsx } from '@emotion/react';
9
9
  import { expandIconContainerStyle, triggerWrapperStyles, triggerWrapperStylesWithPadding, disableBlueBorderStyles } from '@atlaskit/editor-common/styles';
10
10
  import { ToolbarButton } from '@atlaskit/editor-common/ui-menu';
11
- import BoldIcon from '@atlaskit/icon/core/migration/text-bold--editor-bold';
11
+ import ItalicIcon from '@atlaskit/icon/core/migration/text-italic--editor-italic';
12
12
  import ChevronDownIcon from '@atlaskit/icon/utility/migration/chevron-down';
13
13
  import { fg } from '@atlaskit/platform-feature-flags';
14
14
  import { ToolbarType } from './types';
15
- export var BoldToolbarButton = function BoldToolbarButton(_ref) {
15
+ export var DropdownToolbarButton = function DropdownToolbarButton(_ref) {
16
16
  var label = _ref.label,
17
17
  isReducedSpacing = _ref.isReducedSpacing,
18
18
  isDisabled = _ref.isDisabled,
@@ -20,7 +20,8 @@ export var BoldToolbarButton = function BoldToolbarButton(_ref) {
20
20
  ariaExpanded = _ref['aria-expanded'],
21
21
  onClick = _ref.onClick,
22
22
  onKeyDown = _ref.onKeyDown,
23
- toolbarType = _ref.toolbarType;
23
+ toolbarType = _ref.toolbarType,
24
+ iconBefore = _ref.iconBefore;
24
25
  var reducedSpacing = toolbarType === ToolbarType.FLOATING ? 'compact' : 'none';
25
26
  return jsx(ToolbarButton
26
27
  // eslint-disable-next-line @atlaskit/design-system/no-unsafe-style-overrides, @atlaskit/ui-styling-standard/no-imported-style-values
@@ -44,7 +45,7 @@ export var BoldToolbarButton = function BoldToolbarButton(_ref) {
44
45
  triggerWrapperStylesWithPadding :
45
46
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values
46
47
  triggerWrapperStyles
47
- }, jsx(BoldIcon, {
48
+ }, iconBefore ? iconBefore : jsx(ItalicIcon, {
48
49
  color: "currentColor",
49
50
  spacing: "spacious",
50
51
  label: ""
@@ -9,6 +9,8 @@ import { jsx } from '@emotion/react';
9
9
  import { clearFormatting as clearFormattingKeymap, tooltip } from '@atlaskit/editor-common/keymaps';
10
10
  import { toolbarMessages } from '@atlaskit/editor-common/messages';
11
11
  import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
12
+ import TableCellClearIcon from '@atlaskit/icon/core/table-cell-clear';
13
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
12
14
  import { clearFormattingWithAnalytics } from '../../../editor-commands/clear-formatting';
13
15
  import { getInputMethod } from '../input-method-utils';
14
16
  export var useClearIcon = function useClearIcon(_ref) {
@@ -30,6 +32,9 @@ export var useClearIcon = function useClearIcon(_ref) {
30
32
  key: 'clearFormatting',
31
33
  command: clearFormattingToolbar,
32
34
  content: clearFormattingLabel,
35
+ elemBefore: editorExperiment('platform_editor_controls', 'variant1') ? jsx(TableCellClearIcon, {
36
+ label: ""
37
+ }) : undefined,
33
38
  elemAfter:
34
39
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
35
40
  jsx("div", {
@@ -3,7 +3,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  * @jsxRuntime classic
4
4
  * @jsx jsx
5
5
  */
6
- import React, { useMemo } from 'react';
6
+ import { useMemo } from 'react';
7
7
 
8
8
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
9
9
  import { jsx } from '@emotion/react';
@@ -12,10 +12,13 @@ import { getAriaKeyshortcuts, toggleBold, toggleCode, toggleItalic, toggleStrike
12
12
  import { toolbarMessages } from '@atlaskit/editor-common/messages';
13
13
  import { editorCommandToPMCommand } from '@atlaskit/editor-common/preset';
14
14
  import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
15
+ import AngleBracketsIcon from '@atlaskit/icon/core/migration/angle-brackets--editor-code';
15
16
  import BoldIcon from '@atlaskit/icon/core/migration/text-bold--editor-bold';
16
17
  import ItalicIcon from '@atlaskit/icon/core/migration/text-italic--editor-italic';
17
18
  import UnderlineIcon from '@atlaskit/icon/core/text-underline';
19
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
18
20
  import { toggleCodeWithAnalytics, toggleEmWithAnalytics, toggleStrikeWithAnalytics, toggleStrongWithAnalytics, toggleSubscriptWithAnalytics, toggleSuperscriptWithAnalytics, toggleUnderlineWithAnalytics } from '../../../pm-plugins/commands';
21
+ import { Strikethrough, Subscript, Superscript } from '../icons';
19
22
  import { getInputMethod } from '../input-method-utils';
20
23
  import { IconTypes } from '../types';
21
24
  var withInputMethod = function withInputMethod(toolbarType, func) {
@@ -84,6 +87,45 @@ var IconButtons = function IconButtons(editorAnalyticsAPI, toolbarType) {
84
87
  }
85
88
  };
86
89
  };
90
+ var IconBefore = {
91
+ strong: {
92
+ icon: jsx(BoldIcon, {
93
+ color: "currentColor",
94
+ spacing: "spacious",
95
+ label: ""
96
+ })
97
+ },
98
+ em: {
99
+ icon: jsx(ItalicIcon, {
100
+ color: "currentColor",
101
+ spacing: "spacious",
102
+ label: ""
103
+ })
104
+ },
105
+ underline: {
106
+ icon: jsx(UnderlineIcon, {
107
+ color: "currentColor",
108
+ spacing: "spacious",
109
+ label: ""
110
+ })
111
+ },
112
+ strike: {
113
+ icon: jsx(Strikethrough, null)
114
+ },
115
+ code: {
116
+ icon: jsx(AngleBracketsIcon, {
117
+ color: "currentColor",
118
+ spacing: "spacious",
119
+ label: ""
120
+ })
121
+ },
122
+ subscript: {
123
+ icon: jsx(Subscript, null)
124
+ },
125
+ superscript: {
126
+ icon: jsx(Superscript, null)
127
+ }
128
+ };
87
129
  var getIcon = function getIcon(_ref) {
88
130
  var iconType = _ref.iconType,
89
131
  isDisabled = _ref.isDisabled,
@@ -92,6 +134,7 @@ var getIcon = function getIcon(_ref) {
92
134
  editorAnalyticsAPI = _ref.editorAnalyticsAPI,
93
135
  toolbarType = _ref.toolbarType;
94
136
  var icon = IconButtons(editorAnalyticsAPI, toolbarType)[iconType];
137
+ var iconBefore = IconBefore[iconType].icon;
95
138
  var content = intl.formatMessage(icon.message);
96
139
  var tooltipKeymap = icon.tooltipKeymap;
97
140
  return {
@@ -105,6 +148,7 @@ var getIcon = function getIcon(_ref) {
105
148
  description: content,
106
149
  keymap: tooltipKeymap
107
150
  }) : undefined,
151
+ elemBefore: editorExperiment('platform_editor_controls', 'variant1') ? iconBefore : undefined,
108
152
  elemAfter: tooltipKeymap ?
109
153
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
110
154
  jsx("div", {
@@ -1,7 +1,7 @@
1
- import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
1
  import { useMemo } from 'react';
3
2
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
4
3
  import { DefaultButtonsMenu, DefaultButtonsMenuNext, DefaultButtonsToolbar, DefaultButtonsToolbarNext, ResponsiveCustomButtonToolbar as ResponsiveCustomButtonToolbarLegacy, ResponsiveCustomButtonToolbarNext, ResponsiveCustomMenu as ResponsiveCustomMenuLegacy, ResponsiveCustomMenuNext } from '../constants';
4
+ import { useIconList } from './use-icon-list';
5
5
  export var useResponsiveIconTypeButtons = function useResponsiveIconTypeButtons(_ref) {
6
6
  var toolbarSize = _ref.toolbarSize,
7
7
  responsivenessEnabled = _ref.responsivenessEnabled;
@@ -34,26 +34,9 @@ export var useResponsiveToolbarButtons = function useResponsiveToolbarButtons(_r
34
34
  toolbarSize: toolbarSize,
35
35
  responsivenessEnabled: responsivenessEnabled
36
36
  });
37
- var iconsPosition = useMemo(function () {
38
- return icons.reduce(function (acc, icon) {
39
- if (!icon || !icon.iconMark) {
40
- return acc;
41
- }
42
- var isIconSingleButton = iconTypeList.includes(icon.iconMark);
43
- if (isIconSingleButton) {
44
- return {
45
- dropdownItems: acc.dropdownItems,
46
- singleItems: [].concat(_toConsumableArray(acc.singleItems), [icon])
47
- };
48
- }
49
- return {
50
- dropdownItems: [].concat(_toConsumableArray(acc.dropdownItems), [icon]),
51
- singleItems: acc.singleItems
52
- };
53
- }, {
54
- dropdownItems: [],
55
- singleItems: []
56
- });
57
- }, [icons, iconTypeList]);
37
+ var iconsPosition = useIconList({
38
+ icons: icons,
39
+ iconTypeList: iconTypeList
40
+ });
58
41
  return iconsPosition;
59
42
  };