@atlaskit/editor-plugin-text-formatting 3.0.12 → 3.0.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 +14 -0
- package/dist/cjs/pm-plugins/main.js +1 -2
- package/dist/cjs/ui/FloatingToolbarComponent.js +3 -26
- package/dist/cjs/ui/Toolbar/dropdown-menu.js +2 -9
- package/dist/cjs/ui/Toolbar/hooks/formatting-icons.js +13 -17
- package/dist/cjs/ui/Toolbar/single-toolbar-buttons.js +1 -2
- package/dist/es2019/pm-plugins/main.js +1 -2
- package/dist/es2019/ui/FloatingToolbarComponent.js +3 -30
- package/dist/es2019/ui/Toolbar/dropdown-menu.js +2 -9
- package/dist/es2019/ui/Toolbar/hooks/formatting-icons.js +13 -17
- package/dist/es2019/ui/Toolbar/single-toolbar-buttons.js +1 -2
- package/dist/esm/pm-plugins/main.js +1 -2
- package/dist/esm/ui/FloatingToolbarComponent.js +3 -26
- package/dist/esm/ui/Toolbar/dropdown-menu.js +2 -9
- package/dist/esm/ui/Toolbar/hooks/formatting-icons.js +13 -17
- package/dist/esm/ui/Toolbar/single-toolbar-buttons.js +1 -2
- package/dist/types/ui/Toolbar/dropdown-menu.d.ts +1 -2
- package/dist/types/ui/Toolbar/dropdown-toolbar-button.d.ts +2 -2
- package/dist/types/ui/Toolbar/hooks/formatting-icons.d.ts +1 -3
- package/dist/types/ui/Toolbar/single-toolbar-buttons.d.ts +1 -2
- package/dist/types-ts4.5/ui/Toolbar/dropdown-menu.d.ts +1 -2
- package/dist/types-ts4.5/ui/Toolbar/dropdown-toolbar-button.d.ts +2 -2
- package/dist/types-ts4.5/ui/Toolbar/hooks/formatting-icons.d.ts +1 -3
- package/dist/types-ts4.5/ui/Toolbar/single-toolbar-buttons.d.ts +1 -2
- package/package.json +5 -8
- package/dist/cjs/ui/Toolbar/formatting-in-selection-utils.js +0 -52
- package/dist/es2019/ui/Toolbar/formatting-in-selection-utils.js +0 -34
- package/dist/esm/ui/Toolbar/formatting-in-selection-utils.js +0 -46
- package/dist/types/ui/Toolbar/formatting-in-selection-utils.d.ts +0 -7
- package/dist/types-ts4.5/ui/Toolbar/formatting-in-selection-utils.d.ts +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-text-formatting
|
|
2
2
|
|
|
3
|
+
## 3.0.14
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 3.0.13
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`9a547b35d41b0`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9a547b35d41b0) -
|
|
14
|
+
Cleanup platform_editor_common_marks
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 3.0.12
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -14,7 +14,6 @@ var _utils = require("@atlaskit/editor-common/utils");
|
|
|
14
14
|
var _commands = require("@atlaskit/editor-prosemirror/commands");
|
|
15
15
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
16
16
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
17
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
18
17
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
19
18
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
20
19
|
var _textFormatting = _interopRequireWildcard(require("../editor-commands/text-formatting"));
|
|
@@ -53,7 +52,7 @@ var getTextFormattingState = function getTextFormattingState(editorState, editor
|
|
|
53
52
|
var state = {
|
|
54
53
|
isInitialised: true
|
|
55
54
|
};
|
|
56
|
-
var showOnlyCommonMarks = (0, _expValEquals.expValEquals)('platform_editor_controls', 'cohort', 'variant1')
|
|
55
|
+
var showOnlyCommonMarks = (0, _expValEquals.expValEquals)('platform_editor_controls', 'cohort', 'variant1');
|
|
57
56
|
if (showOnlyCommonMarks) {
|
|
58
57
|
// Code marks will disable all other formatting options when they are included in a
|
|
59
58
|
// selection but (for now) we do not want to make it behave differently in regards to which
|
|
@@ -12,12 +12,9 @@ var _react2 = require("@emotion/react");
|
|
|
12
12
|
var _reactIntlNext = require("react-intl-next");
|
|
13
13
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
14
14
|
var _types = require("@atlaskit/editor-common/types");
|
|
15
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
16
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
17
15
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
18
16
|
var _constants = require("./Toolbar/constants");
|
|
19
17
|
var _dropdownMenu = require("./Toolbar/dropdown-menu");
|
|
20
|
-
var _formattingInSelectionUtils = require("./Toolbar/formatting-in-selection-utils");
|
|
21
18
|
var _clearFormattingIcon = require("./Toolbar/hooks/clear-formatting-icon");
|
|
22
19
|
var _formattingIcons = require("./Toolbar/hooks/formatting-icons");
|
|
23
20
|
var _useIconList2 = require("./Toolbar/hooks/use-icon-list");
|
|
@@ -153,31 +150,13 @@ var FloatingToolbarTextFormat = function FloatingToolbarTextFormat(_ref) {
|
|
|
153
150
|
var textFormattingState = useSharedState(api);
|
|
154
151
|
var formattingIsPresent = textFormattingState.formattingIsPresent,
|
|
155
152
|
formattingIconState = (0, _objectWithoutProperties2.default)(textFormattingState, _excluded);
|
|
156
|
-
var hasMultiplePartsWithFormattingSelected;
|
|
157
|
-
var commonActiveMarks;
|
|
158
|
-
if ((0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
|
|
159
|
-
var selection = editorView.state.selection;
|
|
160
|
-
var from = selection.from,
|
|
161
|
-
to = selection.to;
|
|
162
|
-
var selectedContent = selection instanceof _state.TextSelection ? editorView.state.doc.slice(from, to).content.content.slice() : undefined;
|
|
163
|
-
hasMultiplePartsWithFormattingSelected = (0, _platformFeatureFlags.fg)('platform_editor_common_marks') ? false : (0, _formattingInSelectionUtils.hasMultiplePartsWithFormattingInSelection)({
|
|
164
|
-
selectedContent: selectedContent
|
|
165
|
-
});
|
|
166
|
-
if (!(0, _platformFeatureFlags.fg)('platform_editor_common_marks')) {
|
|
167
|
-
commonActiveMarks = (0, _formattingInSelectionUtils.getCommonActiveMarks)({
|
|
168
|
-
selectedContent: selectedContent
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
153
|
var defaultIcons = (0, _formattingIcons.useFormattingIcons)({
|
|
173
154
|
schema: editorView.state.schema,
|
|
174
155
|
intl: intl,
|
|
175
156
|
isToolbarDisabled: FloatingToolbarSettings.disabled,
|
|
176
157
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
177
158
|
textFormattingState: formattingIconState,
|
|
178
|
-
toolbarType: FloatingToolbarSettings.toolbarType
|
|
179
|
-
hasMultiplePartsWithFormattingSelected: (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? hasMultiplePartsWithFormattingSelected : undefined,
|
|
180
|
-
commonActiveMarks: (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? commonActiveMarks : undefined
|
|
159
|
+
toolbarType: FloatingToolbarSettings.toolbarType
|
|
181
160
|
});
|
|
182
161
|
var _useIconList = (0, _useIconList2.useIconList)({
|
|
183
162
|
icons: defaultIcons,
|
|
@@ -207,8 +186,7 @@ var FloatingToolbarTextFormat = function FloatingToolbarTextFormat(_ref) {
|
|
|
207
186
|
return (0, _react2.jsx)(_react.default.Fragment, null, (0, _react2.jsx)(_singleToolbarButtons.SingleToolbarButtons, {
|
|
208
187
|
items: singleItems,
|
|
209
188
|
editorView: editorView,
|
|
210
|
-
isReducedSpacing: false
|
|
211
|
-
hasMultiplePartsWithFormattingSelected: hasMultiplePartsWithFormattingSelected
|
|
189
|
+
isReducedSpacing: false
|
|
212
190
|
}), (0, _react2.jsx)(_dropdownMenu.FormattingTextDropdownMenu, {
|
|
213
191
|
editorView: editorView,
|
|
214
192
|
items: items,
|
|
@@ -217,8 +195,7 @@ var FloatingToolbarTextFormat = function FloatingToolbarTextFormat(_ref) {
|
|
|
217
195
|
hasFormattingActive: FloatingToolbarSettings.hasMoreButton,
|
|
218
196
|
hasMoreButton: FloatingToolbarSettings.hasMoreButton,
|
|
219
197
|
intl: intl,
|
|
220
|
-
toolbarType: FloatingToolbarSettings.toolbarType
|
|
221
|
-
hasMultiplePartsWithFormattingSelected: hasMultiplePartsWithFormattingSelected
|
|
198
|
+
toolbarType: FloatingToolbarSettings.toolbarType
|
|
222
199
|
}));
|
|
223
200
|
};
|
|
224
201
|
var FloatingToolbarTextFormalWithIntl = exports.FloatingToolbarTextFormalWithIntl = (0, _reactIntlNext.injectIntl)(FloatingToolbarTextFormat);
|
|
@@ -29,7 +29,6 @@ var FormattingTextDropdownMenu = exports.FormattingTextDropdownMenu = /*#__PURE_
|
|
|
29
29
|
hasMoreButton = _ref.hasMoreButton,
|
|
30
30
|
intl = _ref.intl,
|
|
31
31
|
toolbarType = _ref.toolbarType,
|
|
32
|
-
hasMultiplePartsWithFormattingSelected = _ref.hasMultiplePartsWithFormattingSelected,
|
|
33
32
|
isDisabled = _ref.isDisabled;
|
|
34
33
|
var _useMenuState = (0, _menuState.useMenuState)(),
|
|
35
34
|
_useMenuState2 = (0, _slicedToArray2.default)(_useMenuState, 3),
|
|
@@ -56,14 +55,8 @@ var FormattingTextDropdownMenu = exports.FormattingTextDropdownMenu = /*#__PURE_
|
|
|
56
55
|
});
|
|
57
56
|
var defaultIcon = (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? (_items$0$items$ = items[0].items[0]) === null || _items$0$items$ === void 0 ? void 0 : _items$0$items$.elemBefore : undefined;
|
|
58
57
|
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;
|
|
59
|
-
var iconBefore;
|
|
60
|
-
var activeIconName = defaultIconName;
|
|
61
|
-
if (hasMultiplePartsWithFormattingSelected && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
|
|
62
|
-
iconBefore = defaultIcon;
|
|
63
|
-
} else {
|
|
64
|
-
iconBefore = activeItem ? activeItem === null || activeItem === void 0 ? void 0 : activeItem.elemBefore : defaultIcon;
|
|
65
|
-
activeIconName = (activeItem === null || activeItem === void 0 ? void 0 : activeItem.value.name) || defaultIconName;
|
|
66
|
-
}
|
|
58
|
+
var iconBefore = activeItem ? activeItem === null || activeItem === void 0 ? void 0 : activeItem.elemBefore : defaultIcon;
|
|
59
|
+
var activeIconName = (activeItem === null || activeItem === void 0 ? void 0 : activeItem.value.name) || defaultIconName;
|
|
67
60
|
return /*#__PURE__*/_react.default.createElement(_uiMenu.DropdownMenuWithKeyboardNavigation, {
|
|
68
61
|
mountTo: popupsMountPoint,
|
|
69
62
|
onOpenChange: closeMenu,
|
|
@@ -175,7 +175,7 @@ var getIcon = function getIcon(_ref) {
|
|
|
175
175
|
};
|
|
176
176
|
};
|
|
177
177
|
var IconsMarkSchema = (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _types.IconTypes.strong, 'strong'), _types.IconTypes.em, 'em'), _types.IconTypes.strike, 'strike'), _types.IconTypes.code, 'code'), _types.IconTypes.underline, 'underline'), _types.IconTypes.superscript, 'subsup'), _types.IconTypes.subscript, 'subsup');
|
|
178
|
-
var buildMenuIconState = function buildMenuIconState(iconMark
|
|
178
|
+
var buildMenuIconState = function buildMenuIconState(iconMark) {
|
|
179
179
|
return function (_ref2) {
|
|
180
180
|
var schema = _ref2.schema,
|
|
181
181
|
textFormattingState = _ref2.textFormattingState;
|
|
@@ -190,7 +190,7 @@ var buildMenuIconState = function buildMenuIconState(iconMark, hasMultiplePartsW
|
|
|
190
190
|
hasSchemaMark: hasSchemaMark
|
|
191
191
|
};
|
|
192
192
|
}
|
|
193
|
-
var isActive =
|
|
193
|
+
var isActive = textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState["".concat(iconMark, "Active")];
|
|
194
194
|
var isDisabled = textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState["".concat(iconMark, "Disabled")];
|
|
195
195
|
var isHidden = textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState["".concat(iconMark, "Hidden")];
|
|
196
196
|
return {
|
|
@@ -201,8 +201,8 @@ var buildMenuIconState = function buildMenuIconState(iconMark, hasMultiplePartsW
|
|
|
201
201
|
};
|
|
202
202
|
};
|
|
203
203
|
};
|
|
204
|
-
var buildIcon = function buildIcon(iconMark, editorAnalyticsAPI, toolbarType
|
|
205
|
-
var getState = buildMenuIconState(iconMark
|
|
204
|
+
var buildIcon = function buildIcon(iconMark, editorAnalyticsAPI, toolbarType) {
|
|
205
|
+
var getState = buildMenuIconState(iconMark);
|
|
206
206
|
return function (_ref3) {
|
|
207
207
|
var schema = _ref3.schema,
|
|
208
208
|
textFormattingState = _ref3.textFormattingState,
|
|
@@ -238,25 +238,21 @@ var useFormattingIcons = exports.useFormattingIcons = function useFormattingIcon
|
|
|
238
238
|
schema = _ref4.schema,
|
|
239
239
|
intl = _ref4.intl,
|
|
240
240
|
editorAnalyticsAPI = _ref4.editorAnalyticsAPI,
|
|
241
|
-
toolbarType = _ref4.toolbarType
|
|
242
|
-
hasMultiplePartsWithFormattingSelected = _ref4.hasMultiplePartsWithFormattingSelected,
|
|
243
|
-
commonActiveMarks = _ref4.commonActiveMarks;
|
|
241
|
+
toolbarType = _ref4.toolbarType;
|
|
244
242
|
var props = {
|
|
245
243
|
schema: schema,
|
|
246
244
|
textFormattingState: textFormattingState,
|
|
247
245
|
intl: intl,
|
|
248
246
|
isToolbarDisabled: Boolean(isToolbarDisabled),
|
|
249
|
-
toolbarType: toolbarType
|
|
250
|
-
hasMultiplePartsWithFormattingSelected: hasMultiplePartsWithFormattingSelected,
|
|
251
|
-
commonActiveMarks: commonActiveMarks
|
|
247
|
+
toolbarType: toolbarType
|
|
252
248
|
};
|
|
253
|
-
var buildStrongIcon = buildIcon(_types.IconTypes.strong, editorAnalyticsAPI, toolbarType
|
|
254
|
-
var buildEmIcon = buildIcon(_types.IconTypes.em, editorAnalyticsAPI, toolbarType
|
|
255
|
-
var buildUnderlineIcon = buildIcon(_types.IconTypes.underline, editorAnalyticsAPI, toolbarType
|
|
256
|
-
var buildStrikeIcon = buildIcon(_types.IconTypes.strike, editorAnalyticsAPI, toolbarType
|
|
257
|
-
var buildCodeIcon = buildIcon(_types.IconTypes.code, editorAnalyticsAPI, toolbarType
|
|
258
|
-
var buildSubscriptIcon = buildIcon(_types.IconTypes.subscript, editorAnalyticsAPI, toolbarType
|
|
259
|
-
var buildSuperscriptIcon = buildIcon(_types.IconTypes.superscript, editorAnalyticsAPI, toolbarType
|
|
249
|
+
var buildStrongIcon = buildIcon(_types.IconTypes.strong, editorAnalyticsAPI, toolbarType);
|
|
250
|
+
var buildEmIcon = buildIcon(_types.IconTypes.em, editorAnalyticsAPI, toolbarType);
|
|
251
|
+
var buildUnderlineIcon = buildIcon(_types.IconTypes.underline, editorAnalyticsAPI, toolbarType);
|
|
252
|
+
var buildStrikeIcon = buildIcon(_types.IconTypes.strike, editorAnalyticsAPI, toolbarType);
|
|
253
|
+
var buildCodeIcon = buildIcon(_types.IconTypes.code, editorAnalyticsAPI, toolbarType);
|
|
254
|
+
var buildSubscriptIcon = buildIcon(_types.IconTypes.subscript, editorAnalyticsAPI, toolbarType);
|
|
255
|
+
var buildSuperscriptIcon = buildIcon(_types.IconTypes.superscript, editorAnalyticsAPI, toolbarType);
|
|
260
256
|
var strongIcon = buildStrongIcon(props);
|
|
261
257
|
var emIcon = buildEmIcon(props);
|
|
262
258
|
var underlineIcon = buildUnderlineIcon(props);
|
|
@@ -21,8 +21,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
21
21
|
var SingleToolbarButtons = exports.SingleToolbarButtons = /*#__PURE__*/_react.default.memo(function (_ref) {
|
|
22
22
|
var items = _ref.items,
|
|
23
23
|
isReducedSpacing = _ref.isReducedSpacing,
|
|
24
|
-
editorView = _ref.editorView
|
|
25
|
-
hasMultiplePartsWithFormattingSelected = _ref.hasMultiplePartsWithFormattingSelected;
|
|
24
|
+
editorView = _ref.editorView;
|
|
26
25
|
var onClick = (0, _react.useCallback)(function (command) {
|
|
27
26
|
return function () {
|
|
28
27
|
command(editorView.state, editorView.dispatch);
|
|
@@ -8,7 +8,6 @@ import { shallowEqual } from '@atlaskit/editor-common/utils';
|
|
|
8
8
|
import { toggleMark } from '@atlaskit/editor-prosemirror/commands';
|
|
9
9
|
import { MarkType } from '@atlaskit/editor-prosemirror/model';
|
|
10
10
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
11
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
11
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
13
12
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
14
13
|
import { createInlineCodeFromTextInputWithAnalytics } from '../editor-commands/text-formatting';
|
|
@@ -43,7 +42,7 @@ const getTextFormattingState = (editorState, editorAnalyticsAPI) => {
|
|
|
43
42
|
const state = {
|
|
44
43
|
isInitialised: true
|
|
45
44
|
};
|
|
46
|
-
const showOnlyCommonMarks = expValEquals('platform_editor_controls', 'cohort', 'variant1')
|
|
45
|
+
const showOnlyCommonMarks = expValEquals('platform_editor_controls', 'cohort', 'variant1');
|
|
47
46
|
if (showOnlyCommonMarks) {
|
|
48
47
|
// Code marks will disable all other formatting options when they are included in a
|
|
49
48
|
// selection but (for now) we do not want to make it behave differently in regards to which
|
|
@@ -9,12 +9,9 @@ import { jsx } from '@emotion/react';
|
|
|
9
9
|
import { injectIntl } from 'react-intl-next';
|
|
10
10
|
import { useSharedPluginState, sharedPluginStateHookMigratorFactory, useSharedPluginStateWithSelector } 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';
|
|
14
12
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
15
13
|
import { ToolbarButtonsStrong } from './Toolbar/constants';
|
|
16
14
|
import { FormattingTextDropdownMenu } from './Toolbar/dropdown-menu';
|
|
17
|
-
import { getCommonActiveMarks, hasMultiplePartsWithFormattingInSelection } from './Toolbar/formatting-in-selection-utils';
|
|
18
15
|
import { useClearIcon } from './Toolbar/hooks/clear-formatting-icon';
|
|
19
16
|
import { useFormattingIcons } from './Toolbar/hooks/formatting-icons';
|
|
20
17
|
import { useIconList } from './Toolbar/hooks/use-icon-list';
|
|
@@ -148,35 +145,13 @@ const FloatingToolbarTextFormat = ({
|
|
|
148
145
|
formattingIsPresent,
|
|
149
146
|
...formattingIconState
|
|
150
147
|
} = textFormattingState;
|
|
151
|
-
let hasMultiplePartsWithFormattingSelected;
|
|
152
|
-
let commonActiveMarks;
|
|
153
|
-
if (editorExperiment('platform_editor_controls', 'variant1')) {
|
|
154
|
-
const {
|
|
155
|
-
selection
|
|
156
|
-
} = editorView.state;
|
|
157
|
-
const {
|
|
158
|
-
from,
|
|
159
|
-
to
|
|
160
|
-
} = selection;
|
|
161
|
-
const selectedContent = selection instanceof TextSelection ? editorView.state.doc.slice(from, to).content.content.slice() : undefined;
|
|
162
|
-
hasMultiplePartsWithFormattingSelected = fg('platform_editor_common_marks') ? false : hasMultiplePartsWithFormattingInSelection({
|
|
163
|
-
selectedContent
|
|
164
|
-
});
|
|
165
|
-
if (!fg('platform_editor_common_marks')) {
|
|
166
|
-
commonActiveMarks = getCommonActiveMarks({
|
|
167
|
-
selectedContent
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
148
|
const defaultIcons = useFormattingIcons({
|
|
172
149
|
schema: editorView.state.schema,
|
|
173
150
|
intl,
|
|
174
151
|
isToolbarDisabled: FloatingToolbarSettings.disabled,
|
|
175
152
|
editorAnalyticsAPI,
|
|
176
153
|
textFormattingState: formattingIconState,
|
|
177
|
-
toolbarType: FloatingToolbarSettings.toolbarType
|
|
178
|
-
hasMultiplePartsWithFormattingSelected: editorExperiment('platform_editor_controls', 'variant1') ? hasMultiplePartsWithFormattingSelected : undefined,
|
|
179
|
-
commonActiveMarks: editorExperiment('platform_editor_controls', 'variant1') ? commonActiveMarks : undefined
|
|
154
|
+
toolbarType: FloatingToolbarSettings.toolbarType
|
|
180
155
|
});
|
|
181
156
|
const {
|
|
182
157
|
dropdownItems,
|
|
@@ -207,8 +182,7 @@ const FloatingToolbarTextFormat = ({
|
|
|
207
182
|
return jsx(React.Fragment, null, jsx(SingleToolbarButtons, {
|
|
208
183
|
items: singleItems,
|
|
209
184
|
editorView: editorView,
|
|
210
|
-
isReducedSpacing: false
|
|
211
|
-
hasMultiplePartsWithFormattingSelected: hasMultiplePartsWithFormattingSelected
|
|
185
|
+
isReducedSpacing: false
|
|
212
186
|
}), jsx(FormattingTextDropdownMenu, {
|
|
213
187
|
editorView: editorView,
|
|
214
188
|
items: items,
|
|
@@ -217,8 +191,7 @@ const FloatingToolbarTextFormat = ({
|
|
|
217
191
|
hasFormattingActive: FloatingToolbarSettings.hasMoreButton,
|
|
218
192
|
hasMoreButton: FloatingToolbarSettings.hasMoreButton,
|
|
219
193
|
intl: intl,
|
|
220
|
-
toolbarType: FloatingToolbarSettings.toolbarType
|
|
221
|
-
hasMultiplePartsWithFormattingSelected: hasMultiplePartsWithFormattingSelected
|
|
194
|
+
toolbarType: FloatingToolbarSettings.toolbarType
|
|
222
195
|
}));
|
|
223
196
|
};
|
|
224
197
|
export const FloatingToolbarTextFormalWithIntl = injectIntl(FloatingToolbarTextFormat);
|
|
@@ -18,7 +18,6 @@ export const FormattingTextDropdownMenu = /*#__PURE__*/React.memo(({
|
|
|
18
18
|
hasMoreButton,
|
|
19
19
|
intl,
|
|
20
20
|
toolbarType,
|
|
21
|
-
hasMultiplePartsWithFormattingSelected,
|
|
22
21
|
isDisabled
|
|
23
22
|
}) => {
|
|
24
23
|
var _items$0$items$, _items$0$items$2;
|
|
@@ -38,14 +37,8 @@ export const FormattingTextDropdownMenu = /*#__PURE__*/React.memo(({
|
|
|
38
37
|
const activeItem = items[0].items.find(item => item.isActive);
|
|
39
38
|
const defaultIcon = editorExperiment('platform_editor_controls', 'variant1') ? (_items$0$items$ = items[0].items[0]) === null || _items$0$items$ === void 0 ? void 0 : _items$0$items$.elemBefore : undefined;
|
|
40
39
|
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
|
-
|
|
42
|
-
|
|
43
|
-
if (hasMultiplePartsWithFormattingSelected && editorExperiment('platform_editor_controls', 'variant1')) {
|
|
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
|
-
}
|
|
40
|
+
const iconBefore = activeItem ? activeItem === null || activeItem === void 0 ? void 0 : activeItem.elemBefore : defaultIcon;
|
|
41
|
+
const activeIconName = (activeItem === null || activeItem === void 0 ? void 0 : activeItem.value.name) || defaultIconName;
|
|
49
42
|
return /*#__PURE__*/React.createElement(DropdownMenu, {
|
|
50
43
|
mountTo: popupsMountPoint,
|
|
51
44
|
onOpenChange: closeMenu,
|
|
@@ -167,7 +167,7 @@ const IconsMarkSchema = {
|
|
|
167
167
|
[IconTypes.superscript]: 'subsup',
|
|
168
168
|
[IconTypes.subscript]: 'subsup'
|
|
169
169
|
};
|
|
170
|
-
const buildMenuIconState =
|
|
170
|
+
const buildMenuIconState = iconMark => ({
|
|
171
171
|
schema,
|
|
172
172
|
textFormattingState
|
|
173
173
|
}) => {
|
|
@@ -182,7 +182,7 @@ const buildMenuIconState = (iconMark, hasMultiplePartsWithFormattingSelected, co
|
|
|
182
182
|
hasSchemaMark
|
|
183
183
|
};
|
|
184
184
|
}
|
|
185
|
-
const isActive =
|
|
185
|
+
const isActive = textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState[`${iconMark}Active`];
|
|
186
186
|
const isDisabled = textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState[`${iconMark}Disabled`];
|
|
187
187
|
const isHidden = textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState[`${iconMark}Hidden`];
|
|
188
188
|
return {
|
|
@@ -192,8 +192,8 @@ const buildMenuIconState = (iconMark, hasMultiplePartsWithFormattingSelected, co
|
|
|
192
192
|
hasSchemaMark
|
|
193
193
|
};
|
|
194
194
|
};
|
|
195
|
-
const buildIcon = (iconMark, editorAnalyticsAPI, toolbarType
|
|
196
|
-
const getState = buildMenuIconState(iconMark
|
|
195
|
+
const buildIcon = (iconMark, editorAnalyticsAPI, toolbarType) => {
|
|
196
|
+
const getState = buildMenuIconState(iconMark);
|
|
197
197
|
return ({
|
|
198
198
|
schema,
|
|
199
199
|
textFormattingState,
|
|
@@ -228,26 +228,22 @@ export const useFormattingIcons = ({
|
|
|
228
228
|
schema,
|
|
229
229
|
intl,
|
|
230
230
|
editorAnalyticsAPI,
|
|
231
|
-
toolbarType
|
|
232
|
-
hasMultiplePartsWithFormattingSelected,
|
|
233
|
-
commonActiveMarks
|
|
231
|
+
toolbarType
|
|
234
232
|
}) => {
|
|
235
233
|
const props = {
|
|
236
234
|
schema,
|
|
237
235
|
textFormattingState,
|
|
238
236
|
intl,
|
|
239
237
|
isToolbarDisabled: Boolean(isToolbarDisabled),
|
|
240
|
-
toolbarType
|
|
241
|
-
hasMultiplePartsWithFormattingSelected,
|
|
242
|
-
commonActiveMarks
|
|
238
|
+
toolbarType
|
|
243
239
|
};
|
|
244
|
-
const buildStrongIcon = buildIcon(IconTypes.strong, editorAnalyticsAPI, toolbarType
|
|
245
|
-
const buildEmIcon = buildIcon(IconTypes.em, editorAnalyticsAPI, toolbarType
|
|
246
|
-
const buildUnderlineIcon = buildIcon(IconTypes.underline, editorAnalyticsAPI, toolbarType
|
|
247
|
-
const buildStrikeIcon = buildIcon(IconTypes.strike, editorAnalyticsAPI, toolbarType
|
|
248
|
-
const buildCodeIcon = buildIcon(IconTypes.code, editorAnalyticsAPI, toolbarType
|
|
249
|
-
const buildSubscriptIcon = buildIcon(IconTypes.subscript, editorAnalyticsAPI, toolbarType
|
|
250
|
-
const buildSuperscriptIcon = buildIcon(IconTypes.superscript, editorAnalyticsAPI, toolbarType
|
|
240
|
+
const buildStrongIcon = buildIcon(IconTypes.strong, editorAnalyticsAPI, toolbarType);
|
|
241
|
+
const buildEmIcon = buildIcon(IconTypes.em, editorAnalyticsAPI, toolbarType);
|
|
242
|
+
const buildUnderlineIcon = buildIcon(IconTypes.underline, editorAnalyticsAPI, toolbarType);
|
|
243
|
+
const buildStrikeIcon = buildIcon(IconTypes.strike, editorAnalyticsAPI, toolbarType);
|
|
244
|
+
const buildCodeIcon = buildIcon(IconTypes.code, editorAnalyticsAPI, toolbarType);
|
|
245
|
+
const buildSubscriptIcon = buildIcon(IconTypes.subscript, editorAnalyticsAPI, toolbarType);
|
|
246
|
+
const buildSuperscriptIcon = buildIcon(IconTypes.superscript, editorAnalyticsAPI, toolbarType);
|
|
251
247
|
const strongIcon = buildStrongIcon(props);
|
|
252
248
|
const emIcon = buildEmIcon(props);
|
|
253
249
|
const underlineIcon = buildUnderlineIcon(props);
|
|
@@ -12,8 +12,7 @@ import { fg } from '@atlaskit/platform-feature-flags';
|
|
|
12
12
|
export const SingleToolbarButtons = /*#__PURE__*/React.memo(({
|
|
13
13
|
items,
|
|
14
14
|
isReducedSpacing,
|
|
15
|
-
editorView
|
|
16
|
-
hasMultiplePartsWithFormattingSelected
|
|
15
|
+
editorView
|
|
17
16
|
}) => {
|
|
18
17
|
const onClick = useCallback(command => {
|
|
19
18
|
return () => {
|
|
@@ -12,7 +12,6 @@ import { shallowEqual } from '@atlaskit/editor-common/utils';
|
|
|
12
12
|
import { toggleMark } from '@atlaskit/editor-prosemirror/commands';
|
|
13
13
|
import { MarkType } from '@atlaskit/editor-prosemirror/model';
|
|
14
14
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
15
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
16
15
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
17
16
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
18
17
|
import { createInlineCodeFromTextInputWithAnalytics } from '../editor-commands/text-formatting';
|
|
@@ -46,7 +45,7 @@ var getTextFormattingState = function getTextFormattingState(editorState, editor
|
|
|
46
45
|
var state = {
|
|
47
46
|
isInitialised: true
|
|
48
47
|
};
|
|
49
|
-
var showOnlyCommonMarks = expValEquals('platform_editor_controls', 'cohort', 'variant1')
|
|
48
|
+
var showOnlyCommonMarks = expValEquals('platform_editor_controls', 'cohort', 'variant1');
|
|
50
49
|
if (showOnlyCommonMarks) {
|
|
51
50
|
// Code marks will disable all other formatting options when they are included in a
|
|
52
51
|
// selection but (for now) we do not want to make it behave differently in regards to which
|
|
@@ -11,12 +11,9 @@ import { jsx } from '@emotion/react';
|
|
|
11
11
|
import { injectIntl } from 'react-intl-next';
|
|
12
12
|
import { useSharedPluginState, sharedPluginStateHookMigratorFactory, useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
13
13
|
import { ToolbarSize } from '@atlaskit/editor-common/types';
|
|
14
|
-
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
15
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
16
14
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
17
15
|
import { ToolbarButtonsStrong } from './Toolbar/constants';
|
|
18
16
|
import { FormattingTextDropdownMenu } from './Toolbar/dropdown-menu';
|
|
19
|
-
import { getCommonActiveMarks, hasMultiplePartsWithFormattingInSelection } from './Toolbar/formatting-in-selection-utils';
|
|
20
17
|
import { useClearIcon } from './Toolbar/hooks/clear-formatting-icon';
|
|
21
18
|
import { useFormattingIcons } from './Toolbar/hooks/formatting-icons';
|
|
22
19
|
import { useIconList } from './Toolbar/hooks/use-icon-list';
|
|
@@ -145,31 +142,13 @@ var FloatingToolbarTextFormat = function FloatingToolbarTextFormat(_ref) {
|
|
|
145
142
|
var textFormattingState = useSharedState(api);
|
|
146
143
|
var formattingIsPresent = textFormattingState.formattingIsPresent,
|
|
147
144
|
formattingIconState = _objectWithoutProperties(textFormattingState, _excluded);
|
|
148
|
-
var hasMultiplePartsWithFormattingSelected;
|
|
149
|
-
var commonActiveMarks;
|
|
150
|
-
if (editorExperiment('platform_editor_controls', 'variant1')) {
|
|
151
|
-
var selection = editorView.state.selection;
|
|
152
|
-
var from = selection.from,
|
|
153
|
-
to = selection.to;
|
|
154
|
-
var selectedContent = selection instanceof TextSelection ? editorView.state.doc.slice(from, to).content.content.slice() : undefined;
|
|
155
|
-
hasMultiplePartsWithFormattingSelected = fg('platform_editor_common_marks') ? false : hasMultiplePartsWithFormattingInSelection({
|
|
156
|
-
selectedContent: selectedContent
|
|
157
|
-
});
|
|
158
|
-
if (!fg('platform_editor_common_marks')) {
|
|
159
|
-
commonActiveMarks = getCommonActiveMarks({
|
|
160
|
-
selectedContent: selectedContent
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
145
|
var defaultIcons = useFormattingIcons({
|
|
165
146
|
schema: editorView.state.schema,
|
|
166
147
|
intl: intl,
|
|
167
148
|
isToolbarDisabled: FloatingToolbarSettings.disabled,
|
|
168
149
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
169
150
|
textFormattingState: formattingIconState,
|
|
170
|
-
toolbarType: FloatingToolbarSettings.toolbarType
|
|
171
|
-
hasMultiplePartsWithFormattingSelected: editorExperiment('platform_editor_controls', 'variant1') ? hasMultiplePartsWithFormattingSelected : undefined,
|
|
172
|
-
commonActiveMarks: editorExperiment('platform_editor_controls', 'variant1') ? commonActiveMarks : undefined
|
|
151
|
+
toolbarType: FloatingToolbarSettings.toolbarType
|
|
173
152
|
});
|
|
174
153
|
var _useIconList = useIconList({
|
|
175
154
|
icons: defaultIcons,
|
|
@@ -199,8 +178,7 @@ var FloatingToolbarTextFormat = function FloatingToolbarTextFormat(_ref) {
|
|
|
199
178
|
return jsx(React.Fragment, null, jsx(SingleToolbarButtons, {
|
|
200
179
|
items: singleItems,
|
|
201
180
|
editorView: editorView,
|
|
202
|
-
isReducedSpacing: false
|
|
203
|
-
hasMultiplePartsWithFormattingSelected: hasMultiplePartsWithFormattingSelected
|
|
181
|
+
isReducedSpacing: false
|
|
204
182
|
}), jsx(FormattingTextDropdownMenu, {
|
|
205
183
|
editorView: editorView,
|
|
206
184
|
items: items,
|
|
@@ -209,8 +187,7 @@ var FloatingToolbarTextFormat = function FloatingToolbarTextFormat(_ref) {
|
|
|
209
187
|
hasFormattingActive: FloatingToolbarSettings.hasMoreButton,
|
|
210
188
|
hasMoreButton: FloatingToolbarSettings.hasMoreButton,
|
|
211
189
|
intl: intl,
|
|
212
|
-
toolbarType: FloatingToolbarSettings.toolbarType
|
|
213
|
-
hasMultiplePartsWithFormattingSelected: hasMultiplePartsWithFormattingSelected
|
|
190
|
+
toolbarType: FloatingToolbarSettings.toolbarType
|
|
214
191
|
}));
|
|
215
192
|
};
|
|
216
193
|
export var FloatingToolbarTextFormalWithIntl = injectIntl(FloatingToolbarTextFormat);
|
|
@@ -20,7 +20,6 @@ export var FormattingTextDropdownMenu = /*#__PURE__*/React.memo(function (_ref)
|
|
|
20
20
|
hasMoreButton = _ref.hasMoreButton,
|
|
21
21
|
intl = _ref.intl,
|
|
22
22
|
toolbarType = _ref.toolbarType,
|
|
23
|
-
hasMultiplePartsWithFormattingSelected = _ref.hasMultiplePartsWithFormattingSelected,
|
|
24
23
|
isDisabled = _ref.isDisabled;
|
|
25
24
|
var _useMenuState = useMenuState(),
|
|
26
25
|
_useMenuState2 = _slicedToArray(_useMenuState, 3),
|
|
@@ -47,14 +46,8 @@ export var FormattingTextDropdownMenu = /*#__PURE__*/React.memo(function (_ref)
|
|
|
47
46
|
});
|
|
48
47
|
var defaultIcon = editorExperiment('platform_editor_controls', 'variant1') ? (_items$0$items$ = items[0].items[0]) === null || _items$0$items$ === void 0 ? void 0 : _items$0$items$.elemBefore : undefined;
|
|
49
48
|
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 (hasMultiplePartsWithFormattingSelected && editorExperiment('platform_editor_controls', 'variant1')) {
|
|
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
|
-
}
|
|
49
|
+
var iconBefore = activeItem ? activeItem === null || activeItem === void 0 ? void 0 : activeItem.elemBefore : defaultIcon;
|
|
50
|
+
var activeIconName = (activeItem === null || activeItem === void 0 ? void 0 : activeItem.value.name) || defaultIconName;
|
|
58
51
|
return /*#__PURE__*/React.createElement(DropdownMenu, {
|
|
59
52
|
mountTo: popupsMountPoint,
|
|
60
53
|
onOpenChange: closeMenu,
|
|
@@ -167,7 +167,7 @@ var getIcon = function getIcon(_ref) {
|
|
|
167
167
|
};
|
|
168
168
|
};
|
|
169
169
|
var IconsMarkSchema = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, IconTypes.strong, 'strong'), IconTypes.em, 'em'), IconTypes.strike, 'strike'), IconTypes.code, 'code'), IconTypes.underline, 'underline'), IconTypes.superscript, 'subsup'), IconTypes.subscript, 'subsup');
|
|
170
|
-
var buildMenuIconState = function buildMenuIconState(iconMark
|
|
170
|
+
var buildMenuIconState = function buildMenuIconState(iconMark) {
|
|
171
171
|
return function (_ref2) {
|
|
172
172
|
var schema = _ref2.schema,
|
|
173
173
|
textFormattingState = _ref2.textFormattingState;
|
|
@@ -182,7 +182,7 @@ var buildMenuIconState = function buildMenuIconState(iconMark, hasMultiplePartsW
|
|
|
182
182
|
hasSchemaMark: hasSchemaMark
|
|
183
183
|
};
|
|
184
184
|
}
|
|
185
|
-
var isActive =
|
|
185
|
+
var isActive = textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState["".concat(iconMark, "Active")];
|
|
186
186
|
var isDisabled = textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState["".concat(iconMark, "Disabled")];
|
|
187
187
|
var isHidden = textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState["".concat(iconMark, "Hidden")];
|
|
188
188
|
return {
|
|
@@ -193,8 +193,8 @@ var buildMenuIconState = function buildMenuIconState(iconMark, hasMultiplePartsW
|
|
|
193
193
|
};
|
|
194
194
|
};
|
|
195
195
|
};
|
|
196
|
-
var buildIcon = function buildIcon(iconMark, editorAnalyticsAPI, toolbarType
|
|
197
|
-
var getState = buildMenuIconState(iconMark
|
|
196
|
+
var buildIcon = function buildIcon(iconMark, editorAnalyticsAPI, toolbarType) {
|
|
197
|
+
var getState = buildMenuIconState(iconMark);
|
|
198
198
|
return function (_ref3) {
|
|
199
199
|
var schema = _ref3.schema,
|
|
200
200
|
textFormattingState = _ref3.textFormattingState,
|
|
@@ -230,25 +230,21 @@ export var useFormattingIcons = function useFormattingIcons(_ref4) {
|
|
|
230
230
|
schema = _ref4.schema,
|
|
231
231
|
intl = _ref4.intl,
|
|
232
232
|
editorAnalyticsAPI = _ref4.editorAnalyticsAPI,
|
|
233
|
-
toolbarType = _ref4.toolbarType
|
|
234
|
-
hasMultiplePartsWithFormattingSelected = _ref4.hasMultiplePartsWithFormattingSelected,
|
|
235
|
-
commonActiveMarks = _ref4.commonActiveMarks;
|
|
233
|
+
toolbarType = _ref4.toolbarType;
|
|
236
234
|
var props = {
|
|
237
235
|
schema: schema,
|
|
238
236
|
textFormattingState: textFormattingState,
|
|
239
237
|
intl: intl,
|
|
240
238
|
isToolbarDisabled: Boolean(isToolbarDisabled),
|
|
241
|
-
toolbarType: toolbarType
|
|
242
|
-
hasMultiplePartsWithFormattingSelected: hasMultiplePartsWithFormattingSelected,
|
|
243
|
-
commonActiveMarks: commonActiveMarks
|
|
239
|
+
toolbarType: toolbarType
|
|
244
240
|
};
|
|
245
|
-
var buildStrongIcon = buildIcon(IconTypes.strong, editorAnalyticsAPI, toolbarType
|
|
246
|
-
var buildEmIcon = buildIcon(IconTypes.em, editorAnalyticsAPI, toolbarType
|
|
247
|
-
var buildUnderlineIcon = buildIcon(IconTypes.underline, editorAnalyticsAPI, toolbarType
|
|
248
|
-
var buildStrikeIcon = buildIcon(IconTypes.strike, editorAnalyticsAPI, toolbarType
|
|
249
|
-
var buildCodeIcon = buildIcon(IconTypes.code, editorAnalyticsAPI, toolbarType
|
|
250
|
-
var buildSubscriptIcon = buildIcon(IconTypes.subscript, editorAnalyticsAPI, toolbarType
|
|
251
|
-
var buildSuperscriptIcon = buildIcon(IconTypes.superscript, editorAnalyticsAPI, toolbarType
|
|
241
|
+
var buildStrongIcon = buildIcon(IconTypes.strong, editorAnalyticsAPI, toolbarType);
|
|
242
|
+
var buildEmIcon = buildIcon(IconTypes.em, editorAnalyticsAPI, toolbarType);
|
|
243
|
+
var buildUnderlineIcon = buildIcon(IconTypes.underline, editorAnalyticsAPI, toolbarType);
|
|
244
|
+
var buildStrikeIcon = buildIcon(IconTypes.strike, editorAnalyticsAPI, toolbarType);
|
|
245
|
+
var buildCodeIcon = buildIcon(IconTypes.code, editorAnalyticsAPI, toolbarType);
|
|
246
|
+
var buildSubscriptIcon = buildIcon(IconTypes.subscript, editorAnalyticsAPI, toolbarType);
|
|
247
|
+
var buildSuperscriptIcon = buildIcon(IconTypes.superscript, editorAnalyticsAPI, toolbarType);
|
|
252
248
|
var strongIcon = buildStrongIcon(props);
|
|
253
249
|
var emIcon = buildEmIcon(props);
|
|
254
250
|
var underlineIcon = buildUnderlineIcon(props);
|
|
@@ -12,8 +12,7 @@ import { fg } from '@atlaskit/platform-feature-flags';
|
|
|
12
12
|
export var SingleToolbarButtons = /*#__PURE__*/React.memo(function (_ref) {
|
|
13
13
|
var items = _ref.items,
|
|
14
14
|
isReducedSpacing = _ref.isReducedSpacing,
|
|
15
|
-
editorView = _ref.editorView
|
|
16
|
-
hasMultiplePartsWithFormattingSelected = _ref.hasMultiplePartsWithFormattingSelected;
|
|
15
|
+
editorView = _ref.editorView;
|
|
17
16
|
var onClick = useCallback(function (command) {
|
|
18
17
|
return function () {
|
|
19
18
|
command(editorView.state, editorView.dispatch);
|
|
@@ -15,8 +15,7 @@ type DropdownMenuProps = {
|
|
|
15
15
|
popupsScrollableElement?: HTMLElement;
|
|
16
16
|
hasMoreButton: boolean;
|
|
17
17
|
toolbarType: ToolbarType;
|
|
18
|
-
hasMultiplePartsWithFormattingSelected?: boolean;
|
|
19
18
|
isDisabled?: boolean;
|
|
20
19
|
} & WrappedComponentProps;
|
|
21
|
-
export declare const FormattingTextDropdownMenu: React.MemoExoticComponent<({ editorView, moreButtonLabel, isReducedSpacing, items, hasFormattingActive, popupsBoundariesElement, popupsMountPoint, popupsScrollableElement, hasMoreButton, intl, toolbarType,
|
|
20
|
+
export declare const FormattingTextDropdownMenu: React.MemoExoticComponent<({ editorView, moreButtonLabel, isReducedSpacing, items, hasFormattingActive, popupsBoundariesElement, popupsMountPoint, popupsScrollableElement, hasMoreButton, intl, toolbarType, isDisabled, }: DropdownMenuProps) => React.JSX.Element>;
|
|
22
21
|
export {};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @jsxRuntime classic
|
|
3
3
|
* @jsx jsx
|
|
4
4
|
*/
|
|
5
|
-
import React
|
|
5
|
+
import React from 'react';
|
|
6
6
|
import { jsx } from '@emotion/react';
|
|
7
7
|
import { ToolbarType } from './types';
|
|
8
8
|
type DropdownButtonProps = {
|
|
@@ -14,7 +14,7 @@ type DropdownButtonProps = {
|
|
|
14
14
|
onClick?: (event: React.MouseEvent<HTMLElement>) => void;
|
|
15
15
|
onKeyDown?: (event: React.KeyboardEvent) => void;
|
|
16
16
|
toolbarType: ToolbarType;
|
|
17
|
-
iconBefore?: ReactElement;
|
|
17
|
+
iconBefore?: React.ReactElement;
|
|
18
18
|
activeIconName?: string;
|
|
19
19
|
};
|
|
20
20
|
export declare const DropdownToolbarButton: ({ label, isReducedSpacing, isDisabled, isSelected, "aria-expanded": ariaExpanded, onClick, onKeyDown, toolbarType, iconBefore, activeIconName, }: DropdownButtonProps) => jsx.JSX.Element;
|
|
@@ -8,10 +8,8 @@ interface FormattingIconHookProps extends IconHookProps {
|
|
|
8
8
|
textFormattingState: TextFormattingState | undefined;
|
|
9
9
|
schema: Schema;
|
|
10
10
|
toolbarType: ToolbarType;
|
|
11
|
-
hasMultiplePartsWithFormattingSelected?: boolean;
|
|
12
|
-
commonActiveMarks?: string[];
|
|
13
11
|
}
|
|
14
|
-
export declare const useFormattingIcons: ({ isToolbarDisabled, textFormattingState, schema, intl, editorAnalyticsAPI, toolbarType,
|
|
12
|
+
export declare const useFormattingIcons: ({ isToolbarDisabled, textFormattingState, schema, intl, editorAnalyticsAPI, toolbarType, }: FormattingIconHookProps) => Array<MenuIconItem | null>;
|
|
15
13
|
type Props = {
|
|
16
14
|
textFormattingState: TextFormattingState | undefined;
|
|
17
15
|
iconTypeList: IconTypes[];
|
|
@@ -6,9 +6,8 @@ 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, }: {
|
|
10
10
|
items: MenuIconItem[];
|
|
11
11
|
isReducedSpacing: boolean;
|
|
12
12
|
editorView: EditorView;
|
|
13
|
-
hasMultiplePartsWithFormattingSelected?: boolean;
|
|
14
13
|
}) => jsx.JSX.Element>;
|
|
@@ -15,8 +15,7 @@ type DropdownMenuProps = {
|
|
|
15
15
|
popupsScrollableElement?: HTMLElement;
|
|
16
16
|
hasMoreButton: boolean;
|
|
17
17
|
toolbarType: ToolbarType;
|
|
18
|
-
hasMultiplePartsWithFormattingSelected?: boolean;
|
|
19
18
|
isDisabled?: boolean;
|
|
20
19
|
} & WrappedComponentProps;
|
|
21
|
-
export declare const FormattingTextDropdownMenu: React.MemoExoticComponent<({ editorView, moreButtonLabel, isReducedSpacing, items, hasFormattingActive, popupsBoundariesElement, popupsMountPoint, popupsScrollableElement, hasMoreButton, intl, toolbarType,
|
|
20
|
+
export declare const FormattingTextDropdownMenu: React.MemoExoticComponent<({ editorView, moreButtonLabel, isReducedSpacing, items, hasFormattingActive, popupsBoundariesElement, popupsMountPoint, popupsScrollableElement, hasMoreButton, intl, toolbarType, isDisabled, }: DropdownMenuProps) => React.JSX.Element>;
|
|
22
21
|
export {};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @jsxRuntime classic
|
|
3
3
|
* @jsx jsx
|
|
4
4
|
*/
|
|
5
|
-
import React
|
|
5
|
+
import React from 'react';
|
|
6
6
|
import { jsx } from '@emotion/react';
|
|
7
7
|
import { ToolbarType } from './types';
|
|
8
8
|
type DropdownButtonProps = {
|
|
@@ -14,7 +14,7 @@ type DropdownButtonProps = {
|
|
|
14
14
|
onClick?: (event: React.MouseEvent<HTMLElement>) => void;
|
|
15
15
|
onKeyDown?: (event: React.KeyboardEvent) => void;
|
|
16
16
|
toolbarType: ToolbarType;
|
|
17
|
-
iconBefore?: ReactElement;
|
|
17
|
+
iconBefore?: React.ReactElement;
|
|
18
18
|
activeIconName?: string;
|
|
19
19
|
};
|
|
20
20
|
export declare const DropdownToolbarButton: ({ label, isReducedSpacing, isDisabled, isSelected, "aria-expanded": ariaExpanded, onClick, onKeyDown, toolbarType, iconBefore, activeIconName, }: DropdownButtonProps) => jsx.JSX.Element;
|
|
@@ -8,10 +8,8 @@ interface FormattingIconHookProps extends IconHookProps {
|
|
|
8
8
|
textFormattingState: TextFormattingState | undefined;
|
|
9
9
|
schema: Schema;
|
|
10
10
|
toolbarType: ToolbarType;
|
|
11
|
-
hasMultiplePartsWithFormattingSelected?: boolean;
|
|
12
|
-
commonActiveMarks?: string[];
|
|
13
11
|
}
|
|
14
|
-
export declare const useFormattingIcons: ({ isToolbarDisabled, textFormattingState, schema, intl, editorAnalyticsAPI, toolbarType,
|
|
12
|
+
export declare const useFormattingIcons: ({ isToolbarDisabled, textFormattingState, schema, intl, editorAnalyticsAPI, toolbarType, }: FormattingIconHookProps) => Array<MenuIconItem | null>;
|
|
15
13
|
type Props = {
|
|
16
14
|
textFormattingState: TextFormattingState | undefined;
|
|
17
15
|
iconTypeList: IconTypes[];
|
|
@@ -6,9 +6,8 @@ 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, }: {
|
|
10
10
|
items: MenuIconItem[];
|
|
11
11
|
isReducedSpacing: boolean;
|
|
12
12
|
editorView: EditorView;
|
|
13
|
-
hasMultiplePartsWithFormattingSelected?: boolean;
|
|
14
13
|
}) => jsx.JSX.Element>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-text-formatting",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.14",
|
|
4
4
|
"description": "Text-formatting plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -41,19 +41,19 @@
|
|
|
41
41
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
42
42
|
"@atlaskit/editor-shared-styles": "^3.6.0",
|
|
43
43
|
"@atlaskit/editor-tables": "^2.9.0",
|
|
44
|
-
"@atlaskit/editor-toolbar": "^0.
|
|
44
|
+
"@atlaskit/editor-toolbar": "^0.3.0",
|
|
45
45
|
"@atlaskit/editor-toolbar-model": "^0.1.0",
|
|
46
|
-
"@atlaskit/icon": "^27.
|
|
46
|
+
"@atlaskit/icon": "^27.12.0",
|
|
47
47
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
48
48
|
"@atlaskit/prosemirror-input-rules": "^3.4.0",
|
|
49
|
-
"@atlaskit/tmp-editor-statsig": "^9.
|
|
49
|
+
"@atlaskit/tmp-editor-statsig": "^9.28.0",
|
|
50
50
|
"@atlaskit/tokens": "^6.0.0",
|
|
51
51
|
"@babel/runtime": "^7.0.0",
|
|
52
52
|
"@emotion/react": "^11.7.1",
|
|
53
53
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@atlaskit/editor-common": "^107.
|
|
56
|
+
"@atlaskit/editor-common": "^107.23.0",
|
|
57
57
|
"react": "^18.2.0"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
@@ -113,9 +113,6 @@
|
|
|
113
113
|
},
|
|
114
114
|
"platform_editor_use_preferences_plugin": {
|
|
115
115
|
"type": "boolean"
|
|
116
|
-
},
|
|
117
|
-
"platform_editor_common_marks": {
|
|
118
|
-
"type": "boolean"
|
|
119
116
|
}
|
|
120
117
|
}
|
|
121
118
|
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.hasMultiplePartsWithFormattingInSelection = exports.getCommonActiveMarks = 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
|
-
|
|
19
|
-
// Check if there are multiple parts with formatting or if only one part has formatting and the rest have none
|
|
20
|
-
var contentWithMarks = selectedContent.filter(function (child) {
|
|
21
|
-
return isMarkInIconTypes(child);
|
|
22
|
-
});
|
|
23
|
-
var hasFormatting = contentWithMarks.length > 0;
|
|
24
|
-
var allPartsHaveFormatting = contentWithMarks.length === selectedContent.length;
|
|
25
|
-
return hasFormatting && (!allPartsHaveFormatting || contentWithMarks.length > 1);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
// Clean up when platform_editor_common_marks is removed
|
|
29
|
-
var getCommonActiveMarks = exports.getCommonActiveMarks = function getCommonActiveMarks(_ref2) {
|
|
30
|
-
var selectedContent = _ref2.selectedContent;
|
|
31
|
-
if (!selectedContent || selectedContent.length === 0) {
|
|
32
|
-
return [];
|
|
33
|
-
}
|
|
34
|
-
// filter out fragment node contains only spaces
|
|
35
|
-
var filteredSelectedContent = selectedContent.filter(function (child) {
|
|
36
|
-
var _child$text;
|
|
37
|
-
return ((_child$text = child.text) === null || _child$text === void 0 ? void 0 : _child$text.trim()) !== '';
|
|
38
|
-
});
|
|
39
|
-
// find the active mark type in first part
|
|
40
|
-
var firstPartMarks = selectedContent[0].marks.map(function (mark) {
|
|
41
|
-
return mark.type.name;
|
|
42
|
-
});
|
|
43
|
-
// check if all other parts have the same mark type as the first part and return the common mark types
|
|
44
|
-
var commonMarkTypes = firstPartMarks.filter(function (mark) {
|
|
45
|
-
return filteredSelectedContent.every(function (child) {
|
|
46
|
-
return child.marks.some(function (m) {
|
|
47
|
-
return m.type.name === mark;
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
return commonMarkTypes;
|
|
52
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
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
|
-
|
|
10
|
-
// Check if there are multiple parts with formatting or if only one part has formatting and the rest have none
|
|
11
|
-
const contentWithMarks = selectedContent.filter(child => isMarkInIconTypes(child));
|
|
12
|
-
const hasFormatting = contentWithMarks.length > 0;
|
|
13
|
-
const allPartsHaveFormatting = contentWithMarks.length === selectedContent.length;
|
|
14
|
-
return hasFormatting && (!allPartsHaveFormatting || contentWithMarks.length > 1);
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
// Clean up when platform_editor_common_marks is removed
|
|
18
|
-
export const getCommonActiveMarks = ({
|
|
19
|
-
selectedContent
|
|
20
|
-
}) => {
|
|
21
|
-
if (!selectedContent || selectedContent.length === 0) {
|
|
22
|
-
return [];
|
|
23
|
-
}
|
|
24
|
-
// filter out fragment node contains only spaces
|
|
25
|
-
const filteredSelectedContent = selectedContent.filter(child => {
|
|
26
|
-
var _child$text;
|
|
27
|
-
return ((_child$text = child.text) === null || _child$text === void 0 ? void 0 : _child$text.trim()) !== '';
|
|
28
|
-
});
|
|
29
|
-
// find the active mark type in first part
|
|
30
|
-
const firstPartMarks = selectedContent[0].marks.map(mark => mark.type.name);
|
|
31
|
-
// check if all other parts have the same mark type as the first part and return the common mark types
|
|
32
|
-
const commonMarkTypes = firstPartMarks.filter(mark => filteredSelectedContent.every(child => child.marks.some(m => m.type.name === mark)));
|
|
33
|
-
return commonMarkTypes;
|
|
34
|
-
};
|
|
@@ -1,46 +0,0 @@
|
|
|
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
|
-
|
|
13
|
-
// Check if there are multiple parts with formatting or if only one part has formatting and the rest have none
|
|
14
|
-
var contentWithMarks = selectedContent.filter(function (child) {
|
|
15
|
-
return isMarkInIconTypes(child);
|
|
16
|
-
});
|
|
17
|
-
var hasFormatting = contentWithMarks.length > 0;
|
|
18
|
-
var allPartsHaveFormatting = contentWithMarks.length === selectedContent.length;
|
|
19
|
-
return hasFormatting && (!allPartsHaveFormatting || contentWithMarks.length > 1);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
// Clean up when platform_editor_common_marks is removed
|
|
23
|
-
export var getCommonActiveMarks = function getCommonActiveMarks(_ref2) {
|
|
24
|
-
var selectedContent = _ref2.selectedContent;
|
|
25
|
-
if (!selectedContent || selectedContent.length === 0) {
|
|
26
|
-
return [];
|
|
27
|
-
}
|
|
28
|
-
// filter out fragment node contains only spaces
|
|
29
|
-
var filteredSelectedContent = selectedContent.filter(function (child) {
|
|
30
|
-
var _child$text;
|
|
31
|
-
return ((_child$text = child.text) === null || _child$text === void 0 ? void 0 : _child$text.trim()) !== '';
|
|
32
|
-
});
|
|
33
|
-
// find the active mark type in first part
|
|
34
|
-
var firstPartMarks = selectedContent[0].marks.map(function (mark) {
|
|
35
|
-
return mark.type.name;
|
|
36
|
-
});
|
|
37
|
-
// check if all other parts have the same mark type as the first part and return the common mark types
|
|
38
|
-
var commonMarkTypes = firstPartMarks.filter(function (mark) {
|
|
39
|
-
return filteredSelectedContent.every(function (child) {
|
|
40
|
-
return child.marks.some(function (m) {
|
|
41
|
-
return m.type.name === mark;
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
return commonMarkTypes;
|
|
46
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
-
export declare const hasMultiplePartsWithFormattingInSelection: ({ selectedContent, }: {
|
|
3
|
-
selectedContent?: PMNode[];
|
|
4
|
-
}) => boolean;
|
|
5
|
-
export declare const getCommonActiveMarks: ({ selectedContent }: {
|
|
6
|
-
selectedContent?: PMNode[];
|
|
7
|
-
}) => string[];
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
-
export declare const hasMultiplePartsWithFormattingInSelection: ({ selectedContent, }: {
|
|
3
|
-
selectedContent?: PMNode[];
|
|
4
|
-
}) => boolean;
|
|
5
|
-
export declare const getCommonActiveMarks: ({ selectedContent }: {
|
|
6
|
-
selectedContent?: PMNode[];
|
|
7
|
-
}) => string[];
|