@atlaskit/editor-plugin-text-formatting 2.2.0 → 2.2.2
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 +16 -0
- package/dist/cjs/ui/FloatingToolbarComponent.js +19 -3
- package/dist/cjs/ui/Toolbar/dropdown-menu.js +14 -3
- package/dist/cjs/ui/Toolbar/dropdown-toolbar-button.js +4 -2
- package/dist/cjs/ui/Toolbar/formatting-in-selection-utils.js +22 -0
- package/dist/cjs/ui/Toolbar/hooks/use-icon-list.js +8 -2
- package/dist/cjs/ui/Toolbar/single-toolbar-buttons.js +5 -3
- package/dist/es2019/ui/FloatingToolbarComponent.js +23 -3
- package/dist/es2019/ui/Toolbar/dropdown-menu.js +14 -3
- package/dist/es2019/ui/Toolbar/dropdown-toolbar-button.js +4 -2
- package/dist/es2019/ui/Toolbar/formatting-in-selection-utils.js +11 -0
- package/dist/es2019/ui/Toolbar/hooks/use-icon-list.js +8 -2
- package/dist/es2019/ui/Toolbar/single-toolbar-buttons.js +5 -3
- package/dist/esm/ui/FloatingToolbarComponent.js +19 -3
- package/dist/esm/ui/Toolbar/dropdown-menu.js +14 -3
- package/dist/esm/ui/Toolbar/dropdown-toolbar-button.js +4 -2
- package/dist/esm/ui/Toolbar/formatting-in-selection-utils.js +16 -0
- package/dist/esm/ui/Toolbar/hooks/use-icon-list.js +8 -2
- package/dist/esm/ui/Toolbar/single-toolbar-buttons.js +5 -3
- package/dist/types/ui/Toolbar/dropdown-menu.d.ts +2 -1
- package/dist/types/ui/Toolbar/dropdown-toolbar-button.d.ts +2 -1
- package/dist/types/ui/Toolbar/formatting-in-selection-utils.d.ts +4 -0
- package/dist/types/ui/Toolbar/hooks/use-icon-list.d.ts +2 -1
- package/dist/types/ui/Toolbar/single-toolbar-buttons.d.ts +2 -1
- package/dist/types-ts4.5/ui/Toolbar/dropdown-menu.d.ts +2 -1
- package/dist/types-ts4.5/ui/Toolbar/dropdown-toolbar-button.d.ts +2 -1
- package/dist/types-ts4.5/ui/Toolbar/formatting-in-selection-utils.d.ts +4 -0
- package/dist/types-ts4.5/ui/Toolbar/hooks/use-icon-list.d.ts +2 -1
- package/dist/types-ts4.5/ui/Toolbar/single-toolbar-buttons.d.ts +2 -1
- package/package.json +9 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-text-formatting
|
|
2
2
|
|
|
3
|
+
## 2.2.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 2.2.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#147651](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/147651)
|
|
14
|
+
[`a17e1c3a38139`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a17e1c3a38139) -
|
|
15
|
+
[ux] Unselect text formatting icon in floating toolbar when multiple parts with format in
|
|
16
|
+
selection
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 2.2.0
|
|
4
20
|
|
|
5
21
|
### Minor Changes
|
|
@@ -10,9 +10,12 @@ var _react2 = require("@emotion/react");
|
|
|
10
10
|
var _reactIntlNext = require("react-intl-next");
|
|
11
11
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
12
12
|
var _types = require("@atlaskit/editor-common/types");
|
|
13
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
14
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
15
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
14
16
|
var _constants = require("./Toolbar/constants");
|
|
15
17
|
var _dropdownMenu = require("./Toolbar/dropdown-menu");
|
|
18
|
+
var _formattingInSelectionUtils = require("./Toolbar/formatting-in-selection-utils");
|
|
16
19
|
var _clearFormattingIcon = require("./Toolbar/hooks/clear-formatting-icon");
|
|
17
20
|
var _formattingIcons = require("./Toolbar/hooks/formatting-icons");
|
|
18
21
|
var _useIconList2 = require("./Toolbar/hooks/use-icon-list");
|
|
@@ -51,9 +54,20 @@ var FloatingToolbarTextFormat = function FloatingToolbarTextFormat(_ref) {
|
|
|
51
54
|
textFormattingState: textFormattingState,
|
|
52
55
|
toolbarType: FloatingToolbarSettings.toolbarType
|
|
53
56
|
});
|
|
57
|
+
var hasMultiplePartsWithFormattingSelected;
|
|
58
|
+
if ((0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_7')) {
|
|
59
|
+
var selection = editorView.state.selection;
|
|
60
|
+
var from = selection.from,
|
|
61
|
+
to = selection.to;
|
|
62
|
+
var selectedContent = selection instanceof _state.TextSelection ? editorView.state.doc.slice(from, to).content.content.slice() : undefined;
|
|
63
|
+
hasMultiplePartsWithFormattingSelected = (0, _formattingInSelectionUtils.hasMultiplePartsWithFormattingInSelection)({
|
|
64
|
+
selectedContent: selectedContent
|
|
65
|
+
});
|
|
66
|
+
}
|
|
54
67
|
var _useIconList = (0, _useIconList2.useIconList)({
|
|
55
68
|
icons: defaultIcons,
|
|
56
|
-
iconTypeList: _constants.DefaultFloatingToolbarButtonsNext
|
|
69
|
+
iconTypeList: _constants.DefaultFloatingToolbarButtonsNext,
|
|
70
|
+
shouldUnselect: hasMultiplePartsWithFormattingSelected
|
|
57
71
|
}),
|
|
58
72
|
dropdownItems = _useIconList.dropdownItems,
|
|
59
73
|
singleItems = _useIconList.singleItems;
|
|
@@ -78,7 +92,8 @@ var FloatingToolbarTextFormat = function FloatingToolbarTextFormat(_ref) {
|
|
|
78
92
|
return (0, _react2.jsx)(_react.default.Fragment, null, (0, _react2.jsx)(_singleToolbarButtons.SingleToolbarButtons, {
|
|
79
93
|
items: singleItems,
|
|
80
94
|
editorView: editorView,
|
|
81
|
-
isReducedSpacing: false
|
|
95
|
+
isReducedSpacing: false,
|
|
96
|
+
shouldUnselect: hasMultiplePartsWithFormattingSelected
|
|
82
97
|
}), (0, _react2.jsx)(_dropdownMenu.FormattingTextDropdownMenu, {
|
|
83
98
|
editorView: editorView,
|
|
84
99
|
items: items,
|
|
@@ -87,7 +102,8 @@ var FloatingToolbarTextFormat = function FloatingToolbarTextFormat(_ref) {
|
|
|
87
102
|
hasFormattingActive: FloatingToolbarSettings.hasMoreButton,
|
|
88
103
|
hasMoreButton: FloatingToolbarSettings.hasMoreButton,
|
|
89
104
|
intl: intl,
|
|
90
|
-
toolbarType: FloatingToolbarSettings.toolbarType
|
|
105
|
+
toolbarType: FloatingToolbarSettings.toolbarType,
|
|
106
|
+
shouldUnselect: hasMultiplePartsWithFormattingSelected
|
|
91
107
|
}));
|
|
92
108
|
};
|
|
93
109
|
var FloatingToolbarTextFormalWithIntl = exports.FloatingToolbarTextFormalWithIntl = (0, _reactIntlNext.injectIntl)(FloatingToolbarTextFormat);
|
|
@@ -19,7 +19,7 @@ var _moreButton = require("./more-button");
|
|
|
19
19
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
20
20
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
21
21
|
var FormattingTextDropdownMenu = exports.FormattingTextDropdownMenu = /*#__PURE__*/_react.default.memo(function (_ref) {
|
|
22
|
-
var _items$0$items
|
|
22
|
+
var _items$0$items$, _items$0$items$2;
|
|
23
23
|
var editorView = _ref.editorView,
|
|
24
24
|
moreButtonLabel = _ref.moreButtonLabel,
|
|
25
25
|
isReducedSpacing = _ref.isReducedSpacing,
|
|
@@ -30,7 +30,8 @@ var FormattingTextDropdownMenu = exports.FormattingTextDropdownMenu = /*#__PURE_
|
|
|
30
30
|
popupsScrollableElement = _ref.popupsScrollableElement,
|
|
31
31
|
hasMoreButton = _ref.hasMoreButton,
|
|
32
32
|
intl = _ref.intl,
|
|
33
|
-
toolbarType = _ref.toolbarType
|
|
33
|
+
toolbarType = _ref.toolbarType,
|
|
34
|
+
shouldUnselect = _ref.shouldUnselect;
|
|
34
35
|
var _useMenuState = (0, _menuState.useMenuState)(),
|
|
35
36
|
_useMenuState2 = (0, _slicedToArray2.default)(_useMenuState, 3),
|
|
36
37
|
isMenuOpen = _useMenuState2[0],
|
|
@@ -55,6 +56,15 @@ var FormattingTextDropdownMenu = exports.FormattingTextDropdownMenu = /*#__PURE_
|
|
|
55
56
|
return item.isActive;
|
|
56
57
|
});
|
|
57
58
|
var defaultIcon = (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_4') ? (_items$0$items$ = items[0].items[0]) === null || _items$0$items$ === void 0 ? void 0 : _items$0$items$.elemBefore : undefined;
|
|
59
|
+
var defaultIconName = (_items$0$items$2 = items[0].items[0]) === null || _items$0$items$2 === void 0 ? void 0 : _items$0$items$2.value.name;
|
|
60
|
+
var iconBefore;
|
|
61
|
+
var activeIconName = defaultIconName;
|
|
62
|
+
if (shouldUnselect && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_7')) {
|
|
63
|
+
iconBefore = defaultIcon;
|
|
64
|
+
} else {
|
|
65
|
+
iconBefore = activeItem ? activeItem === null || activeItem === void 0 ? void 0 : activeItem.elemBefore : defaultIcon;
|
|
66
|
+
activeIconName = (activeItem === null || activeItem === void 0 ? void 0 : activeItem.value.name) || defaultIconName;
|
|
67
|
+
}
|
|
58
68
|
return /*#__PURE__*/_react.default.createElement(_uiMenu.DropdownMenuWithKeyboardNavigation, {
|
|
59
69
|
mountTo: popupsMountPoint,
|
|
60
70
|
onOpenChange: closeMenu,
|
|
@@ -112,6 +122,7 @@ var FormattingTextDropdownMenu = exports.FormattingTextDropdownMenu = /*#__PURE_
|
|
|
112
122
|
}
|
|
113
123
|
},
|
|
114
124
|
toolbarType: toolbarType,
|
|
115
|
-
iconBefore:
|
|
125
|
+
iconBefore: iconBefore,
|
|
126
|
+
activeIconName: activeIconName
|
|
116
127
|
}));
|
|
117
128
|
});
|
|
@@ -29,7 +29,8 @@ var DropdownToolbarButton = exports.DropdownToolbarButton = function DropdownToo
|
|
|
29
29
|
onClick = _ref.onClick,
|
|
30
30
|
onKeyDown = _ref.onKeyDown,
|
|
31
31
|
toolbarType = _ref.toolbarType,
|
|
32
|
-
iconBefore = _ref.iconBefore
|
|
32
|
+
iconBefore = _ref.iconBefore,
|
|
33
|
+
activeIconName = _ref.activeIconName;
|
|
33
34
|
var reducedSpacing = toolbarType === _types.ToolbarType.FLOATING ? 'compact' : 'none';
|
|
34
35
|
return (0, _react2.jsx)(_uiMenu.ToolbarButton
|
|
35
36
|
// eslint-disable-next-line @atlaskit/design-system/no-unsafe-style-overrides, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
@@ -52,7 +53,8 @@ var DropdownToolbarButton = exports.DropdownToolbarButton = function DropdownToo
|
|
|
52
53
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
53
54
|
_styles.triggerWrapperStylesWithPadding :
|
|
54
55
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
55
|
-
_styles.triggerWrapperStyles
|
|
56
|
+
_styles.triggerWrapperStyles,
|
|
57
|
+
"data-testid": activeIconName ? "editor-toolbar__".concat(activeIconName) : undefined
|
|
56
58
|
}, iconBefore ? iconBefore : (0, _react2.jsx)(_textItalicEditorItalic.default, {
|
|
57
59
|
color: "currentColor",
|
|
58
60
|
spacing: "spacious",
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.hasMultiplePartsWithFormattingInSelection = void 0;
|
|
7
|
+
var _types = require("./types");
|
|
8
|
+
var isMarkInIconTypes = function isMarkInIconTypes(node) {
|
|
9
|
+
return node.marks.some(function (mark) {
|
|
10
|
+
return Object.values(_types.IconTypes).includes(mark.type.name);
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var hasMultiplePartsWithFormattingInSelection = exports.hasMultiplePartsWithFormattingInSelection = function hasMultiplePartsWithFormattingInSelection(_ref) {
|
|
14
|
+
var selectedContent = _ref.selectedContent;
|
|
15
|
+
if (!selectedContent) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
var marks = selectedContent.map(function (child) {
|
|
19
|
+
return isMarkInIconTypes(child) ? child.marks : undefined;
|
|
20
|
+
}).filter(Boolean);
|
|
21
|
+
return marks.length > 1;
|
|
22
|
+
};
|
|
@@ -7,14 +7,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.useIconList = void 0;
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
9
|
var _react = require("react");
|
|
10
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
11
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
10
12
|
var useIconList = exports.useIconList = function useIconList(_ref) {
|
|
11
13
|
var icons = _ref.icons,
|
|
12
|
-
iconTypeList = _ref.iconTypeList
|
|
14
|
+
iconTypeList = _ref.iconTypeList,
|
|
15
|
+
shouldUnselect = _ref.shouldUnselect;
|
|
13
16
|
return (0, _react.useMemo)(function () {
|
|
14
17
|
return icons.reduce(function (acc, icon) {
|
|
15
18
|
if (!icon || !icon.iconMark) {
|
|
16
19
|
return acc;
|
|
17
20
|
}
|
|
21
|
+
if (shouldUnselect && icon.isActive && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_7')) {
|
|
22
|
+
icon.isActive = false;
|
|
23
|
+
}
|
|
18
24
|
var isIconSingleButton = iconTypeList.includes(icon.iconMark);
|
|
19
25
|
if (isIconSingleButton) {
|
|
20
26
|
return {
|
|
@@ -30,5 +36,5 @@ var useIconList = exports.useIconList = function useIconList(_ref) {
|
|
|
30
36
|
dropdownItems: [],
|
|
31
37
|
singleItems: []
|
|
32
38
|
});
|
|
33
|
-
}, [icons, iconTypeList]);
|
|
39
|
+
}, [icons, shouldUnselect, iconTypeList]);
|
|
34
40
|
};
|
|
@@ -10,6 +10,7 @@ var _react2 = require("@emotion/react");
|
|
|
10
10
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
11
11
|
var _uiMenu = require("@atlaskit/editor-common/ui-menu");
|
|
12
12
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
13
14
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
14
15
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
15
16
|
/**
|
|
@@ -22,7 +23,8 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
22
23
|
var SingleToolbarButtons = exports.SingleToolbarButtons = /*#__PURE__*/_react.default.memo(function (_ref) {
|
|
23
24
|
var items = _ref.items,
|
|
24
25
|
isReducedSpacing = _ref.isReducedSpacing,
|
|
25
|
-
editorView = _ref.editorView
|
|
26
|
+
editorView = _ref.editorView,
|
|
27
|
+
shouldUnselect = _ref.shouldUnselect;
|
|
26
28
|
var onClick = (0, _react.useCallback)(function (command) {
|
|
27
29
|
return function () {
|
|
28
30
|
command(editorView.state, editorView.dispatch);
|
|
@@ -47,11 +49,11 @@ var SingleToolbarButtons = exports.SingleToolbarButtons = /*#__PURE__*/_react.de
|
|
|
47
49
|
buttonId: item.buttonId,
|
|
48
50
|
spacing: isReducedSpacing ? 'none' : 'default',
|
|
49
51
|
onClick: onClick(item.command),
|
|
50
|
-
selected: item.isActive,
|
|
52
|
+
selected: shouldUnselect && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_7') ? false : item.isActive,
|
|
51
53
|
disabled: item.isDisabled,
|
|
52
54
|
title: item.tooltipElement,
|
|
53
55
|
iconBefore: item.iconElement,
|
|
54
|
-
"aria-pressed": item.isActive,
|
|
56
|
+
"aria-pressed": shouldUnselect && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_7') ? false : item.isActive,
|
|
55
57
|
"aria-label": (_item$ariaLabel = item['aria-label']) !== null && _item$ariaLabel !== void 0 ? _item$ariaLabel : String(item.content),
|
|
56
58
|
"aria-keyshortcuts": item['aria-keyshortcuts']
|
|
57
59
|
});
|
|
@@ -9,9 +9,12 @@ import { jsx } from '@emotion/react';
|
|
|
9
9
|
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
|
+
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
13
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
14
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
13
15
|
import { DefaultFloatingToolbarButtonsNext } from './Toolbar/constants';
|
|
14
16
|
import { FormattingTextDropdownMenu } from './Toolbar/dropdown-menu';
|
|
17
|
+
import { hasMultiplePartsWithFormattingInSelection } from './Toolbar/formatting-in-selection-utils';
|
|
15
18
|
import { useClearIcon } from './Toolbar/hooks/clear-formatting-icon';
|
|
16
19
|
import { useFormattingIcons } from './Toolbar/hooks/formatting-icons';
|
|
17
20
|
import { useIconList } from './Toolbar/hooks/use-icon-list';
|
|
@@ -43,12 +46,27 @@ const FloatingToolbarTextFormat = ({
|
|
|
43
46
|
textFormattingState,
|
|
44
47
|
toolbarType: FloatingToolbarSettings.toolbarType
|
|
45
48
|
});
|
|
49
|
+
let hasMultiplePartsWithFormattingSelected;
|
|
50
|
+
if (editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_7')) {
|
|
51
|
+
const {
|
|
52
|
+
selection
|
|
53
|
+
} = editorView.state;
|
|
54
|
+
const {
|
|
55
|
+
from,
|
|
56
|
+
to
|
|
57
|
+
} = selection;
|
|
58
|
+
const selectedContent = selection instanceof TextSelection ? editorView.state.doc.slice(from, to).content.content.slice() : undefined;
|
|
59
|
+
hasMultiplePartsWithFormattingSelected = hasMultiplePartsWithFormattingInSelection({
|
|
60
|
+
selectedContent
|
|
61
|
+
});
|
|
62
|
+
}
|
|
46
63
|
const {
|
|
47
64
|
dropdownItems,
|
|
48
65
|
singleItems
|
|
49
66
|
} = useIconList({
|
|
50
67
|
icons: defaultIcons,
|
|
51
|
-
iconTypeList: DefaultFloatingToolbarButtonsNext
|
|
68
|
+
iconTypeList: DefaultFloatingToolbarButtonsNext,
|
|
69
|
+
shouldUnselect: hasMultiplePartsWithFormattingSelected
|
|
52
70
|
});
|
|
53
71
|
const clearIcon = useClearIcon({
|
|
54
72
|
textFormattingState,
|
|
@@ -71,7 +89,8 @@ const FloatingToolbarTextFormat = ({
|
|
|
71
89
|
return jsx(React.Fragment, null, jsx(SingleToolbarButtons, {
|
|
72
90
|
items: singleItems,
|
|
73
91
|
editorView: editorView,
|
|
74
|
-
isReducedSpacing: false
|
|
92
|
+
isReducedSpacing: false,
|
|
93
|
+
shouldUnselect: hasMultiplePartsWithFormattingSelected
|
|
75
94
|
}), jsx(FormattingTextDropdownMenu, {
|
|
76
95
|
editorView: editorView,
|
|
77
96
|
items: items,
|
|
@@ -80,7 +99,8 @@ const FloatingToolbarTextFormat = ({
|
|
|
80
99
|
hasFormattingActive: FloatingToolbarSettings.hasMoreButton,
|
|
81
100
|
hasMoreButton: FloatingToolbarSettings.hasMoreButton,
|
|
82
101
|
intl: intl,
|
|
83
|
-
toolbarType: FloatingToolbarSettings.toolbarType
|
|
102
|
+
toolbarType: FloatingToolbarSettings.toolbarType,
|
|
103
|
+
shouldUnselect: hasMultiplePartsWithFormattingSelected
|
|
84
104
|
}));
|
|
85
105
|
};
|
|
86
106
|
export const FloatingToolbarTextFormalWithIntl = injectIntl(FloatingToolbarTextFormat);
|
|
@@ -18,9 +18,10 @@ export const FormattingTextDropdownMenu = /*#__PURE__*/React.memo(({
|
|
|
18
18
|
popupsScrollableElement,
|
|
19
19
|
hasMoreButton,
|
|
20
20
|
intl,
|
|
21
|
-
toolbarType
|
|
21
|
+
toolbarType,
|
|
22
|
+
shouldUnselect
|
|
22
23
|
}) => {
|
|
23
|
-
var _items$0$items
|
|
24
|
+
var _items$0$items$, _items$0$items$2;
|
|
24
25
|
const [isMenuOpen, toggleMenu, closeMenu] = useMenuState();
|
|
25
26
|
const [isOpenedByKeyboard, setIsOpenedByKeyboard] = useState(false);
|
|
26
27
|
const onItemActivated = useCallback(({
|
|
@@ -36,6 +37,15 @@ export const FormattingTextDropdownMenu = /*#__PURE__*/React.memo(({
|
|
|
36
37
|
}, [editorView.state, editorView.dispatch, closeMenu]);
|
|
37
38
|
const activeItem = items[0].items.find(item => item.isActive);
|
|
38
39
|
const defaultIcon = editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_4') ? (_items$0$items$ = items[0].items[0]) === null || _items$0$items$ === void 0 ? void 0 : _items$0$items$.elemBefore : undefined;
|
|
40
|
+
const defaultIconName = (_items$0$items$2 = items[0].items[0]) === null || _items$0$items$2 === void 0 ? void 0 : _items$0$items$2.value.name;
|
|
41
|
+
let iconBefore;
|
|
42
|
+
let activeIconName = defaultIconName;
|
|
43
|
+
if (shouldUnselect && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_7')) {
|
|
44
|
+
iconBefore = defaultIcon;
|
|
45
|
+
} else {
|
|
46
|
+
iconBefore = activeItem ? activeItem === null || activeItem === void 0 ? void 0 : activeItem.elemBefore : defaultIcon;
|
|
47
|
+
activeIconName = (activeItem === null || activeItem === void 0 ? void 0 : activeItem.value.name) || defaultIconName;
|
|
48
|
+
}
|
|
39
49
|
return /*#__PURE__*/React.createElement(DropdownMenu, {
|
|
40
50
|
mountTo: popupsMountPoint,
|
|
41
51
|
onOpenChange: closeMenu,
|
|
@@ -93,6 +103,7 @@ export const FormattingTextDropdownMenu = /*#__PURE__*/React.memo(({
|
|
|
93
103
|
}
|
|
94
104
|
},
|
|
95
105
|
toolbarType: toolbarType,
|
|
96
|
-
iconBefore:
|
|
106
|
+
iconBefore: iconBefore,
|
|
107
|
+
activeIconName: activeIconName
|
|
97
108
|
}));
|
|
98
109
|
});
|
|
@@ -21,7 +21,8 @@ export const DropdownToolbarButton = ({
|
|
|
21
21
|
onClick,
|
|
22
22
|
onKeyDown,
|
|
23
23
|
toolbarType,
|
|
24
|
-
iconBefore
|
|
24
|
+
iconBefore,
|
|
25
|
+
activeIconName
|
|
25
26
|
}) => {
|
|
26
27
|
const reducedSpacing = toolbarType === ToolbarType.FLOATING ? 'compact' : 'none';
|
|
27
28
|
return jsx(ToolbarButton
|
|
@@ -45,7 +46,8 @@ export const DropdownToolbarButton = ({
|
|
|
45
46
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
46
47
|
triggerWrapperStylesWithPadding :
|
|
47
48
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
48
|
-
triggerWrapperStyles
|
|
49
|
+
triggerWrapperStyles,
|
|
50
|
+
"data-testid": activeIconName ? `editor-toolbar__${activeIconName}` : undefined
|
|
49
51
|
}, iconBefore ? iconBefore : jsx(ItalicIcon, {
|
|
50
52
|
color: "currentColor",
|
|
51
53
|
spacing: "spacious",
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IconTypes } from './types';
|
|
2
|
+
const isMarkInIconTypes = node => node.marks.some(mark => Object.values(IconTypes).includes(mark.type.name));
|
|
3
|
+
export const hasMultiplePartsWithFormattingInSelection = ({
|
|
4
|
+
selectedContent
|
|
5
|
+
}) => {
|
|
6
|
+
if (!selectedContent) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
const marks = selectedContent.map(child => isMarkInIconTypes(child) ? child.marks : undefined).filter(Boolean);
|
|
10
|
+
return marks.length > 1;
|
|
11
|
+
};
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
2
4
|
export const useIconList = ({
|
|
3
5
|
icons,
|
|
4
|
-
iconTypeList
|
|
6
|
+
iconTypeList,
|
|
7
|
+
shouldUnselect
|
|
5
8
|
}) => {
|
|
6
9
|
return useMemo(() => {
|
|
7
10
|
return icons.reduce((acc, icon) => {
|
|
8
11
|
if (!icon || !icon.iconMark) {
|
|
9
12
|
return acc;
|
|
10
13
|
}
|
|
14
|
+
if (shouldUnselect && icon.isActive && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_7')) {
|
|
15
|
+
icon.isActive = false;
|
|
16
|
+
}
|
|
11
17
|
const isIconSingleButton = iconTypeList.includes(icon.iconMark);
|
|
12
18
|
if (isIconSingleButton) {
|
|
13
19
|
return {
|
|
@@ -23,5 +29,5 @@ export const useIconList = ({
|
|
|
23
29
|
dropdownItems: [],
|
|
24
30
|
singleItems: []
|
|
25
31
|
});
|
|
26
|
-
}, [icons, iconTypeList]);
|
|
32
|
+
}, [icons, shouldUnselect, iconTypeList]);
|
|
27
33
|
};
|
|
@@ -9,10 +9,12 @@ import { jsx } from '@emotion/react';
|
|
|
9
9
|
import { buttonGroupStyle, buttonGroupStyleBeforeVisualRefresh } from '@atlaskit/editor-common/styles';
|
|
10
10
|
import { ToolbarButton } from '@atlaskit/editor-common/ui-menu';
|
|
11
11
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
12
13
|
export const SingleToolbarButtons = /*#__PURE__*/React.memo(({
|
|
13
14
|
items,
|
|
14
15
|
isReducedSpacing,
|
|
15
|
-
editorView
|
|
16
|
+
editorView,
|
|
17
|
+
shouldUnselect
|
|
16
18
|
}) => {
|
|
17
19
|
const onClick = useCallback(command => {
|
|
18
20
|
return () => {
|
|
@@ -38,11 +40,11 @@ export const SingleToolbarButtons = /*#__PURE__*/React.memo(({
|
|
|
38
40
|
buttonId: item.buttonId,
|
|
39
41
|
spacing: isReducedSpacing ? 'none' : 'default',
|
|
40
42
|
onClick: onClick(item.command),
|
|
41
|
-
selected: item.isActive,
|
|
43
|
+
selected: shouldUnselect && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_7') ? false : item.isActive,
|
|
42
44
|
disabled: item.isDisabled,
|
|
43
45
|
title: item.tooltipElement,
|
|
44
46
|
iconBefore: item.iconElement,
|
|
45
|
-
"aria-pressed": item.isActive,
|
|
47
|
+
"aria-pressed": shouldUnselect && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_7') ? false : item.isActive,
|
|
46
48
|
"aria-label": (_item$ariaLabel = item['aria-label']) !== null && _item$ariaLabel !== void 0 ? _item$ariaLabel : String(item.content),
|
|
47
49
|
"aria-keyshortcuts": item['aria-keyshortcuts']
|
|
48
50
|
});
|
|
@@ -9,9 +9,12 @@ import { jsx } from '@emotion/react';
|
|
|
9
9
|
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
|
+
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
13
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
14
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
13
15
|
import { DefaultFloatingToolbarButtonsNext } from './Toolbar/constants';
|
|
14
16
|
import { FormattingTextDropdownMenu } from './Toolbar/dropdown-menu';
|
|
17
|
+
import { hasMultiplePartsWithFormattingInSelection } from './Toolbar/formatting-in-selection-utils';
|
|
15
18
|
import { useClearIcon } from './Toolbar/hooks/clear-formatting-icon';
|
|
16
19
|
import { useFormattingIcons } from './Toolbar/hooks/formatting-icons';
|
|
17
20
|
import { useIconList } from './Toolbar/hooks/use-icon-list';
|
|
@@ -41,9 +44,20 @@ var FloatingToolbarTextFormat = function FloatingToolbarTextFormat(_ref) {
|
|
|
41
44
|
textFormattingState: textFormattingState,
|
|
42
45
|
toolbarType: FloatingToolbarSettings.toolbarType
|
|
43
46
|
});
|
|
47
|
+
var hasMultiplePartsWithFormattingSelected;
|
|
48
|
+
if (editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_7')) {
|
|
49
|
+
var selection = editorView.state.selection;
|
|
50
|
+
var from = selection.from,
|
|
51
|
+
to = selection.to;
|
|
52
|
+
var selectedContent = selection instanceof TextSelection ? editorView.state.doc.slice(from, to).content.content.slice() : undefined;
|
|
53
|
+
hasMultiplePartsWithFormattingSelected = hasMultiplePartsWithFormattingInSelection({
|
|
54
|
+
selectedContent: selectedContent
|
|
55
|
+
});
|
|
56
|
+
}
|
|
44
57
|
var _useIconList = useIconList({
|
|
45
58
|
icons: defaultIcons,
|
|
46
|
-
iconTypeList: DefaultFloatingToolbarButtonsNext
|
|
59
|
+
iconTypeList: DefaultFloatingToolbarButtonsNext,
|
|
60
|
+
shouldUnselect: hasMultiplePartsWithFormattingSelected
|
|
47
61
|
}),
|
|
48
62
|
dropdownItems = _useIconList.dropdownItems,
|
|
49
63
|
singleItems = _useIconList.singleItems;
|
|
@@ -68,7 +82,8 @@ var FloatingToolbarTextFormat = function FloatingToolbarTextFormat(_ref) {
|
|
|
68
82
|
return jsx(React.Fragment, null, jsx(SingleToolbarButtons, {
|
|
69
83
|
items: singleItems,
|
|
70
84
|
editorView: editorView,
|
|
71
|
-
isReducedSpacing: false
|
|
85
|
+
isReducedSpacing: false,
|
|
86
|
+
shouldUnselect: hasMultiplePartsWithFormattingSelected
|
|
72
87
|
}), jsx(FormattingTextDropdownMenu, {
|
|
73
88
|
editorView: editorView,
|
|
74
89
|
items: items,
|
|
@@ -77,7 +92,8 @@ var FloatingToolbarTextFormat = function FloatingToolbarTextFormat(_ref) {
|
|
|
77
92
|
hasFormattingActive: FloatingToolbarSettings.hasMoreButton,
|
|
78
93
|
hasMoreButton: FloatingToolbarSettings.hasMoreButton,
|
|
79
94
|
intl: intl,
|
|
80
|
-
toolbarType: FloatingToolbarSettings.toolbarType
|
|
95
|
+
toolbarType: FloatingToolbarSettings.toolbarType,
|
|
96
|
+
shouldUnselect: hasMultiplePartsWithFormattingSelected
|
|
81
97
|
}));
|
|
82
98
|
};
|
|
83
99
|
export var FloatingToolbarTextFormalWithIntl = injectIntl(FloatingToolbarTextFormat);
|
|
@@ -9,7 +9,7 @@ import { DropdownToolbarButton } from './dropdown-toolbar-button';
|
|
|
9
9
|
import { useMenuState } from './hooks/menu-state';
|
|
10
10
|
import { MoreButton } from './more-button';
|
|
11
11
|
export var FormattingTextDropdownMenu = /*#__PURE__*/React.memo(function (_ref) {
|
|
12
|
-
var _items$0$items
|
|
12
|
+
var _items$0$items$, _items$0$items$2;
|
|
13
13
|
var editorView = _ref.editorView,
|
|
14
14
|
moreButtonLabel = _ref.moreButtonLabel,
|
|
15
15
|
isReducedSpacing = _ref.isReducedSpacing,
|
|
@@ -20,7 +20,8 @@ export var FormattingTextDropdownMenu = /*#__PURE__*/React.memo(function (_ref)
|
|
|
20
20
|
popupsScrollableElement = _ref.popupsScrollableElement,
|
|
21
21
|
hasMoreButton = _ref.hasMoreButton,
|
|
22
22
|
intl = _ref.intl,
|
|
23
|
-
toolbarType = _ref.toolbarType
|
|
23
|
+
toolbarType = _ref.toolbarType,
|
|
24
|
+
shouldUnselect = _ref.shouldUnselect;
|
|
24
25
|
var _useMenuState = useMenuState(),
|
|
25
26
|
_useMenuState2 = _slicedToArray(_useMenuState, 3),
|
|
26
27
|
isMenuOpen = _useMenuState2[0],
|
|
@@ -45,6 +46,15 @@ export var FormattingTextDropdownMenu = /*#__PURE__*/React.memo(function (_ref)
|
|
|
45
46
|
return item.isActive;
|
|
46
47
|
});
|
|
47
48
|
var defaultIcon = editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_4') ? (_items$0$items$ = items[0].items[0]) === null || _items$0$items$ === void 0 ? void 0 : _items$0$items$.elemBefore : undefined;
|
|
49
|
+
var defaultIconName = (_items$0$items$2 = items[0].items[0]) === null || _items$0$items$2 === void 0 ? void 0 : _items$0$items$2.value.name;
|
|
50
|
+
var iconBefore;
|
|
51
|
+
var activeIconName = defaultIconName;
|
|
52
|
+
if (shouldUnselect && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_7')) {
|
|
53
|
+
iconBefore = defaultIcon;
|
|
54
|
+
} else {
|
|
55
|
+
iconBefore = activeItem ? activeItem === null || activeItem === void 0 ? void 0 : activeItem.elemBefore : defaultIcon;
|
|
56
|
+
activeIconName = (activeItem === null || activeItem === void 0 ? void 0 : activeItem.value.name) || defaultIconName;
|
|
57
|
+
}
|
|
48
58
|
return /*#__PURE__*/React.createElement(DropdownMenu, {
|
|
49
59
|
mountTo: popupsMountPoint,
|
|
50
60
|
onOpenChange: closeMenu,
|
|
@@ -102,6 +112,7 @@ export var FormattingTextDropdownMenu = /*#__PURE__*/React.memo(function (_ref)
|
|
|
102
112
|
}
|
|
103
113
|
},
|
|
104
114
|
toolbarType: toolbarType,
|
|
105
|
-
iconBefore:
|
|
115
|
+
iconBefore: iconBefore,
|
|
116
|
+
activeIconName: activeIconName
|
|
106
117
|
}));
|
|
107
118
|
});
|
|
@@ -21,7 +21,8 @@ export var DropdownToolbarButton = function DropdownToolbarButton(_ref) {
|
|
|
21
21
|
onClick = _ref.onClick,
|
|
22
22
|
onKeyDown = _ref.onKeyDown,
|
|
23
23
|
toolbarType = _ref.toolbarType,
|
|
24
|
-
iconBefore = _ref.iconBefore
|
|
24
|
+
iconBefore = _ref.iconBefore,
|
|
25
|
+
activeIconName = _ref.activeIconName;
|
|
25
26
|
var reducedSpacing = toolbarType === ToolbarType.FLOATING ? 'compact' : 'none';
|
|
26
27
|
return jsx(ToolbarButton
|
|
27
28
|
// eslint-disable-next-line @atlaskit/design-system/no-unsafe-style-overrides, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
@@ -44,7 +45,8 @@ export var DropdownToolbarButton = function DropdownToolbarButton(_ref) {
|
|
|
44
45
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
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
|
-
triggerWrapperStyles
|
|
48
|
+
triggerWrapperStyles,
|
|
49
|
+
"data-testid": activeIconName ? "editor-toolbar__".concat(activeIconName) : undefined
|
|
48
50
|
}, iconBefore ? iconBefore : jsx(ItalicIcon, {
|
|
49
51
|
color: "currentColor",
|
|
50
52
|
spacing: "spacious",
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { IconTypes } from './types';
|
|
2
|
+
var isMarkInIconTypes = function isMarkInIconTypes(node) {
|
|
3
|
+
return node.marks.some(function (mark) {
|
|
4
|
+
return Object.values(IconTypes).includes(mark.type.name);
|
|
5
|
+
});
|
|
6
|
+
};
|
|
7
|
+
export var hasMultiplePartsWithFormattingInSelection = function hasMultiplePartsWithFormattingInSelection(_ref) {
|
|
8
|
+
var selectedContent = _ref.selectedContent;
|
|
9
|
+
if (!selectedContent) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
var marks = selectedContent.map(function (child) {
|
|
13
|
+
return isMarkInIconTypes(child) ? child.marks : undefined;
|
|
14
|
+
}).filter(Boolean);
|
|
15
|
+
return marks.length > 1;
|
|
16
|
+
};
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
3
5
|
export var useIconList = function useIconList(_ref) {
|
|
4
6
|
var icons = _ref.icons,
|
|
5
|
-
iconTypeList = _ref.iconTypeList
|
|
7
|
+
iconTypeList = _ref.iconTypeList,
|
|
8
|
+
shouldUnselect = _ref.shouldUnselect;
|
|
6
9
|
return useMemo(function () {
|
|
7
10
|
return icons.reduce(function (acc, icon) {
|
|
8
11
|
if (!icon || !icon.iconMark) {
|
|
9
12
|
return acc;
|
|
10
13
|
}
|
|
14
|
+
if (shouldUnselect && icon.isActive && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_7')) {
|
|
15
|
+
icon.isActive = false;
|
|
16
|
+
}
|
|
11
17
|
var isIconSingleButton = iconTypeList.includes(icon.iconMark);
|
|
12
18
|
if (isIconSingleButton) {
|
|
13
19
|
return {
|
|
@@ -23,5 +29,5 @@ export var useIconList = function useIconList(_ref) {
|
|
|
23
29
|
dropdownItems: [],
|
|
24
30
|
singleItems: []
|
|
25
31
|
});
|
|
26
|
-
}, [icons, iconTypeList]);
|
|
32
|
+
}, [icons, shouldUnselect, iconTypeList]);
|
|
27
33
|
};
|
|
@@ -9,10 +9,12 @@ import { jsx } from '@emotion/react';
|
|
|
9
9
|
import { buttonGroupStyle, buttonGroupStyleBeforeVisualRefresh } from '@atlaskit/editor-common/styles';
|
|
10
10
|
import { ToolbarButton } from '@atlaskit/editor-common/ui-menu';
|
|
11
11
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
12
13
|
export var SingleToolbarButtons = /*#__PURE__*/React.memo(function (_ref) {
|
|
13
14
|
var items = _ref.items,
|
|
14
15
|
isReducedSpacing = _ref.isReducedSpacing,
|
|
15
|
-
editorView = _ref.editorView
|
|
16
|
+
editorView = _ref.editorView,
|
|
17
|
+
shouldUnselect = _ref.shouldUnselect;
|
|
16
18
|
var onClick = useCallback(function (command) {
|
|
17
19
|
return function () {
|
|
18
20
|
command(editorView.state, editorView.dispatch);
|
|
@@ -37,11 +39,11 @@ export var SingleToolbarButtons = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
37
39
|
buttonId: item.buttonId,
|
|
38
40
|
spacing: isReducedSpacing ? 'none' : 'default',
|
|
39
41
|
onClick: onClick(item.command),
|
|
40
|
-
selected: item.isActive,
|
|
42
|
+
selected: shouldUnselect && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_7') ? false : item.isActive,
|
|
41
43
|
disabled: item.isDisabled,
|
|
42
44
|
title: item.tooltipElement,
|
|
43
45
|
iconBefore: item.iconElement,
|
|
44
|
-
"aria-pressed": item.isActive,
|
|
46
|
+
"aria-pressed": shouldUnselect && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_7') ? false : item.isActive,
|
|
45
47
|
"aria-label": (_item$ariaLabel = item['aria-label']) !== null && _item$ariaLabel !== void 0 ? _item$ariaLabel : String(item.content),
|
|
46
48
|
"aria-keyshortcuts": item['aria-keyshortcuts']
|
|
47
49
|
});
|
|
@@ -15,6 +15,7 @@ type DropdownMenuProps = {
|
|
|
15
15
|
popupsScrollableElement?: HTMLElement;
|
|
16
16
|
hasMoreButton: boolean;
|
|
17
17
|
toolbarType: ToolbarType;
|
|
18
|
+
shouldUnselect?: boolean;
|
|
18
19
|
} & WrappedComponentProps;
|
|
19
|
-
export declare const FormattingTextDropdownMenu: React.MemoExoticComponent<({ editorView, moreButtonLabel, isReducedSpacing, items, hasFormattingActive, popupsBoundariesElement, popupsMountPoint, popupsScrollableElement, hasMoreButton, intl, toolbarType, }: DropdownMenuProps) => React.JSX.Element>;
|
|
20
|
+
export declare const FormattingTextDropdownMenu: React.MemoExoticComponent<({ editorView, moreButtonLabel, isReducedSpacing, items, hasFormattingActive, popupsBoundariesElement, popupsMountPoint, popupsScrollableElement, hasMoreButton, intl, toolbarType, shouldUnselect, }: DropdownMenuProps) => React.JSX.Element>;
|
|
20
21
|
export {};
|
|
@@ -15,6 +15,7 @@ type DropdownButtonProps = {
|
|
|
15
15
|
onKeyDown?: (event: React.KeyboardEvent) => void;
|
|
16
16
|
toolbarType: ToolbarType;
|
|
17
17
|
iconBefore?: ReactElement;
|
|
18
|
+
activeIconName?: string;
|
|
18
19
|
};
|
|
19
|
-
export declare const DropdownToolbarButton: ({ label, isReducedSpacing, isDisabled, isSelected, "aria-expanded": ariaExpanded, onClick, onKeyDown, toolbarType, iconBefore, }: DropdownButtonProps) => jsx.JSX.Element;
|
|
20
|
+
export declare const DropdownToolbarButton: ({ label, isReducedSpacing, isDisabled, isSelected, "aria-expanded": ariaExpanded, onClick, onKeyDown, toolbarType, iconBefore, activeIconName, }: DropdownButtonProps) => jsx.JSX.Element;
|
|
20
21
|
export {};
|
|
@@ -2,10 +2,11 @@ import type { IconTypes, MenuIconItem } from '../types';
|
|
|
2
2
|
interface UseIconsParams {
|
|
3
3
|
icons: Array<MenuIconItem | null>;
|
|
4
4
|
iconTypeList: IconTypes[];
|
|
5
|
+
shouldUnselect?: boolean;
|
|
5
6
|
}
|
|
6
7
|
export type IconsPositions = {
|
|
7
8
|
dropdownItems: Array<MenuIconItem>;
|
|
8
9
|
singleItems: Array<MenuIconItem>;
|
|
9
10
|
};
|
|
10
|
-
export declare const useIconList: ({ icons, iconTypeList }: UseIconsParams) => IconsPositions;
|
|
11
|
+
export declare const useIconList: ({ icons, iconTypeList, shouldUnselect }: UseIconsParams) => IconsPositions;
|
|
11
12
|
export {};
|
|
@@ -6,8 +6,9 @@ import React from 'react';
|
|
|
6
6
|
import { jsx } from '@emotion/react';
|
|
7
7
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
8
8
|
import type { MenuIconItem } from './types';
|
|
9
|
-
export declare const SingleToolbarButtons: React.MemoExoticComponent<({ items, isReducedSpacing, editorView, }: {
|
|
9
|
+
export declare const SingleToolbarButtons: React.MemoExoticComponent<({ items, isReducedSpacing, editorView, shouldUnselect, }: {
|
|
10
10
|
items: MenuIconItem[];
|
|
11
11
|
isReducedSpacing: boolean;
|
|
12
12
|
editorView: EditorView;
|
|
13
|
+
shouldUnselect?: boolean | undefined;
|
|
13
14
|
}) => jsx.JSX.Element>;
|
|
@@ -15,6 +15,7 @@ type DropdownMenuProps = {
|
|
|
15
15
|
popupsScrollableElement?: HTMLElement;
|
|
16
16
|
hasMoreButton: boolean;
|
|
17
17
|
toolbarType: ToolbarType;
|
|
18
|
+
shouldUnselect?: boolean;
|
|
18
19
|
} & WrappedComponentProps;
|
|
19
|
-
export declare const FormattingTextDropdownMenu: React.MemoExoticComponent<({ editorView, moreButtonLabel, isReducedSpacing, items, hasFormattingActive, popupsBoundariesElement, popupsMountPoint, popupsScrollableElement, hasMoreButton, intl, toolbarType, }: DropdownMenuProps) => React.JSX.Element>;
|
|
20
|
+
export declare const FormattingTextDropdownMenu: React.MemoExoticComponent<({ editorView, moreButtonLabel, isReducedSpacing, items, hasFormattingActive, popupsBoundariesElement, popupsMountPoint, popupsScrollableElement, hasMoreButton, intl, toolbarType, shouldUnselect, }: DropdownMenuProps) => React.JSX.Element>;
|
|
20
21
|
export {};
|
|
@@ -15,6 +15,7 @@ type DropdownButtonProps = {
|
|
|
15
15
|
onKeyDown?: (event: React.KeyboardEvent) => void;
|
|
16
16
|
toolbarType: ToolbarType;
|
|
17
17
|
iconBefore?: ReactElement;
|
|
18
|
+
activeIconName?: string;
|
|
18
19
|
};
|
|
19
|
-
export declare const DropdownToolbarButton: ({ label, isReducedSpacing, isDisabled, isSelected, "aria-expanded": ariaExpanded, onClick, onKeyDown, toolbarType, iconBefore, }: DropdownButtonProps) => jsx.JSX.Element;
|
|
20
|
+
export declare const DropdownToolbarButton: ({ label, isReducedSpacing, isDisabled, isSelected, "aria-expanded": ariaExpanded, onClick, onKeyDown, toolbarType, iconBefore, activeIconName, }: DropdownButtonProps) => jsx.JSX.Element;
|
|
20
21
|
export {};
|
|
@@ -2,10 +2,11 @@ import type { IconTypes, MenuIconItem } from '../types';
|
|
|
2
2
|
interface UseIconsParams {
|
|
3
3
|
icons: Array<MenuIconItem | null>;
|
|
4
4
|
iconTypeList: IconTypes[];
|
|
5
|
+
shouldUnselect?: boolean;
|
|
5
6
|
}
|
|
6
7
|
export type IconsPositions = {
|
|
7
8
|
dropdownItems: Array<MenuIconItem>;
|
|
8
9
|
singleItems: Array<MenuIconItem>;
|
|
9
10
|
};
|
|
10
|
-
export declare const useIconList: ({ icons, iconTypeList }: UseIconsParams) => IconsPositions;
|
|
11
|
+
export declare const useIconList: ({ icons, iconTypeList, shouldUnselect }: UseIconsParams) => IconsPositions;
|
|
11
12
|
export {};
|
|
@@ -6,8 +6,9 @@ import React from 'react';
|
|
|
6
6
|
import { jsx } from '@emotion/react';
|
|
7
7
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
8
8
|
import type { MenuIconItem } from './types';
|
|
9
|
-
export declare const SingleToolbarButtons: React.MemoExoticComponent<({ items, isReducedSpacing, editorView, }: {
|
|
9
|
+
export declare const SingleToolbarButtons: React.MemoExoticComponent<({ items, isReducedSpacing, editorView, shouldUnselect, }: {
|
|
10
10
|
items: MenuIconItem[];
|
|
11
11
|
isReducedSpacing: boolean;
|
|
12
12
|
editorView: EditorView;
|
|
13
|
+
shouldUnselect?: boolean | undefined;
|
|
13
14
|
}) => jsx.JSX.Element>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-text-formatting",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.2",
|
|
4
4
|
"description": "Text-formatting plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -34,19 +34,19 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@atlaskit/adf-schema": "^47.6.0",
|
|
37
|
-
"@atlaskit/editor-common": "^
|
|
37
|
+
"@atlaskit/editor-common": "^104.0.0",
|
|
38
38
|
"@atlaskit/editor-plugin-analytics": "^2.2.0",
|
|
39
39
|
"@atlaskit/editor-plugin-base": "^2.3.0",
|
|
40
40
|
"@atlaskit/editor-plugin-primary-toolbar": "^3.2.0",
|
|
41
|
-
"@atlaskit/editor-plugin-selection-toolbar": "^3.
|
|
41
|
+
"@atlaskit/editor-plugin-selection-toolbar": "^3.5.0",
|
|
42
42
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
43
43
|
"@atlaskit/editor-shared-styles": "^3.4.0",
|
|
44
44
|
"@atlaskit/editor-tables": "^2.9.0",
|
|
45
|
-
"@atlaskit/icon": "^25.
|
|
45
|
+
"@atlaskit/icon": "^25.6.0",
|
|
46
46
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
47
47
|
"@atlaskit/prosemirror-input-rules": "^3.3.0",
|
|
48
|
-
"@atlaskit/tmp-editor-statsig": "^4.
|
|
49
|
-
"@atlaskit/tokens": "^4.
|
|
48
|
+
"@atlaskit/tmp-editor-statsig": "^4.16.0",
|
|
49
|
+
"@atlaskit/tokens": "^4.8.0",
|
|
50
50
|
"@babel/runtime": "^7.0.0",
|
|
51
51
|
"@emotion/react": "^11.7.1",
|
|
52
52
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
@@ -112,6 +112,9 @@
|
|
|
112
112
|
},
|
|
113
113
|
"platform_editor_controls_patch_4": {
|
|
114
114
|
"type": "boolean"
|
|
115
|
+
},
|
|
116
|
+
"platform_editor_controls_patch_7": {
|
|
117
|
+
"type": "boolean"
|
|
115
118
|
}
|
|
116
119
|
}
|
|
117
120
|
}
|