@atlaskit/editor-plugin-text-formatting 1.15.7 → 1.16.0
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 +8 -0
- package/dist/cjs/input-method-utils.js +15 -0
- package/dist/cjs/plugin.js +39 -8
- package/dist/cjs/ui/FloatingToolbarComponent.js +71 -0
- package/dist/cjs/ui/PrimaryToolbarComponent.js +3 -1
- package/dist/cjs/ui/Toolbar/bold-button.js +61 -0
- package/dist/cjs/ui/Toolbar/dropdown-menu.js +24 -2
- package/dist/cjs/ui/Toolbar/hooks/clear-formatting-icon.js +5 -4
- package/dist/cjs/ui/Toolbar/hooks/formatting-icons.js +28 -23
- package/dist/cjs/ui/Toolbar/index.js +13 -6
- package/dist/cjs/ui/Toolbar/types.js +6 -1
- package/dist/es2019/input-method-utils.js +7 -0
- package/dist/es2019/plugin.js +39 -8
- package/dist/es2019/ui/FloatingToolbarComponent.js +64 -0
- package/dist/es2019/ui/PrimaryToolbarComponent.js +3 -1
- package/dist/es2019/ui/Toolbar/bold-button.js +54 -0
- package/dist/es2019/ui/Toolbar/dropdown-menu.js +24 -2
- package/dist/es2019/ui/Toolbar/hooks/clear-formatting-icon.js +4 -3
- package/dist/es2019/ui/Toolbar/hooks/formatting-icons.js +28 -23
- package/dist/es2019/ui/Toolbar/index.js +13 -6
- package/dist/es2019/ui/Toolbar/types.js +5 -0
- package/dist/esm/input-method-utils.js +8 -0
- package/dist/esm/plugin.js +39 -8
- package/dist/esm/ui/FloatingToolbarComponent.js +63 -0
- package/dist/esm/ui/PrimaryToolbarComponent.js +3 -1
- package/dist/esm/ui/Toolbar/bold-button.js +53 -0
- package/dist/esm/ui/Toolbar/dropdown-menu.js +24 -2
- package/dist/esm/ui/Toolbar/hooks/clear-formatting-icon.js +5 -4
- package/dist/esm/ui/Toolbar/hooks/formatting-icons.js +29 -24
- package/dist/esm/ui/Toolbar/index.js +13 -6
- package/dist/esm/ui/Toolbar/types.js +5 -0
- package/dist/types/commands/clear-formatting.d.ts +2 -2
- package/dist/types/input-method-utils.d.ts +6 -0
- package/dist/types/ui/FloatingToolbarComponent.d.ts +17 -0
- package/dist/types/ui/Toolbar/bold-button.d.ts +17 -0
- package/dist/types/ui/Toolbar/dropdown-menu.d.ts +4 -2
- package/dist/types/ui/Toolbar/hooks/clear-formatting-icon.d.ts +3 -2
- package/dist/types/ui/Toolbar/hooks/formatting-icons.d.ts +3 -2
- package/dist/types/ui/Toolbar/index.d.ts +2 -0
- package/dist/types/ui/Toolbar/types.d.ts +4 -0
- package/dist/types-ts4.5/commands/clear-formatting.d.ts +2 -2
- package/dist/types-ts4.5/input-method-utils.d.ts +6 -0
- package/dist/types-ts4.5/ui/FloatingToolbarComponent.d.ts +17 -0
- package/dist/types-ts4.5/ui/Toolbar/bold-button.d.ts +17 -0
- package/dist/types-ts4.5/ui/Toolbar/dropdown-menu.d.ts +4 -2
- package/dist/types-ts4.5/ui/Toolbar/hooks/clear-formatting-icon.d.ts +3 -2
- package/dist/types-ts4.5/ui/Toolbar/hooks/formatting-icons.d.ts +3 -2
- package/dist/types-ts4.5/ui/Toolbar/index.d.ts +2 -0
- package/dist/types-ts4.5/ui/Toolbar/types.d.ts +4 -0
- package/package.json +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-text-formatting
|
|
2
2
|
|
|
3
|
+
## 1.16.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#170931](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/170931)
|
|
8
|
+
[`5a4a927fac223`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5a4a927fac223) -
|
|
9
|
+
[ux] Adds text formatting option to the Selection toolbar.
|
|
10
|
+
|
|
3
11
|
## 1.15.7
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.toolbarTypeToInputMethod = exports.getInputMethod = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
10
|
+
var _types = require("./ui/Toolbar/types");
|
|
11
|
+
var _toolbarTypeToInputMe;
|
|
12
|
+
var toolbarTypeToInputMethod = exports.toolbarTypeToInputMethod = (_toolbarTypeToInputMe = {}, (0, _defineProperty2.default)(_toolbarTypeToInputMe, _types.ToolbarType.PRIMARY, _analytics.INPUT_METHOD.TOOLBAR), (0, _defineProperty2.default)(_toolbarTypeToInputMe, _types.ToolbarType.FLOATING, _analytics.INPUT_METHOD.FLOATING_TB), _toolbarTypeToInputMe);
|
|
13
|
+
var getInputMethod = exports.getInputMethod = function getInputMethod(toolbarType) {
|
|
14
|
+
return toolbarTypeToInputMethod[toolbarType];
|
|
15
|
+
};
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -8,6 +8,7 @@ exports.textFormattingPlugin = void 0;
|
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _react = _interopRequireDefault(require("react"));
|
|
10
10
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
11
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
11
12
|
var _commands = require("./commands");
|
|
12
13
|
var _clearFormatting = require("./pm-plugins/clear-formatting");
|
|
13
14
|
var _clearFormattingKeymap = _interopRequireDefault(require("./pm-plugins/clear-formatting-keymap"));
|
|
@@ -16,6 +17,7 @@ var _inputRule = _interopRequireDefault(require("./pm-plugins/input-rule"));
|
|
|
16
17
|
var _keymap = _interopRequireDefault(require("./pm-plugins/keymap"));
|
|
17
18
|
var _main = require("./pm-plugins/main");
|
|
18
19
|
var _smartInputRule = _interopRequireDefault(require("./pm-plugins/smart-input-rule"));
|
|
20
|
+
var _FloatingToolbarComponent = require("./ui/FloatingToolbarComponent");
|
|
19
21
|
var _PrimaryToolbarComponent = require("./ui/PrimaryToolbarComponent");
|
|
20
22
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
21
23
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -24,7 +26,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
24
26
|
* from `@atlaskit/editor-core`.
|
|
25
27
|
*/
|
|
26
28
|
var textFormattingPlugin = exports.textFormattingPlugin = function textFormattingPlugin(_ref) {
|
|
27
|
-
var _api$primaryToolbar, _api$
|
|
29
|
+
var _api$primaryToolbar, _api$analytics7, _api$analytics8, _api$analytics9, _api$analytics10, _api$analytics11, _api$analytics12, _api$analytics13;
|
|
28
30
|
var options = _ref.config,
|
|
29
31
|
api = _ref.api;
|
|
30
32
|
var primaryToolbarComponent = function primaryToolbarComponent(_ref2) {
|
|
@@ -128,15 +130,44 @@ var textFormattingPlugin = exports.textFormattingPlugin = function textFormattin
|
|
|
128
130
|
formattingIsPresent: (_clearFormattingPlugi = _clearFormatting.pluginKey.getState(editorState)) === null || _clearFormattingPlugi === void 0 ? void 0 : _clearFormattingPlugi.formattingIsPresent
|
|
129
131
|
});
|
|
130
132
|
},
|
|
133
|
+
pluginsOptions: {
|
|
134
|
+
selectionToolbar: function selectionToolbar() {
|
|
135
|
+
if ((0, _experiments.editorExperiment)('contextual_formatting_toolbar', true, {
|
|
136
|
+
exposure: true
|
|
137
|
+
})) {
|
|
138
|
+
var toolbarCustom = {
|
|
139
|
+
type: 'custom',
|
|
140
|
+
render: function render(view) {
|
|
141
|
+
var _api$analytics6;
|
|
142
|
+
if (!view) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
return /*#__PURE__*/_react.default.createElement(_FloatingToolbarComponent.FloatingToolbarTextFormalWithIntl, {
|
|
146
|
+
api: api,
|
|
147
|
+
editorView: view,
|
|
148
|
+
editorAnalyticsAPI: api === null || api === void 0 || (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : _api$analytics6.actions
|
|
149
|
+
});
|
|
150
|
+
},
|
|
151
|
+
fallback: []
|
|
152
|
+
};
|
|
153
|
+
return {
|
|
154
|
+
isToolbarAbove: true,
|
|
155
|
+
items: [toolbarCustom]
|
|
156
|
+
};
|
|
157
|
+
} else {
|
|
158
|
+
return undefined;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
},
|
|
131
162
|
primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined,
|
|
132
163
|
commands: {
|
|
133
|
-
toggleSuperscript: (0, _commands.toggleSuperscriptWithAnalytics)(api === null || api === void 0 || (_api$
|
|
134
|
-
toggleSubscript: (0, _commands.toggleSubscriptWithAnalytics)(api === null || api === void 0 || (_api$
|
|
135
|
-
toggleStrike: (0, _commands.toggleStrikeWithAnalytics)(api === null || api === void 0 || (_api$
|
|
136
|
-
toggleCode: (0, _commands.toggleCodeWithAnalytics)(api === null || api === void 0 || (_api$
|
|
137
|
-
toggleUnderline: (0, _commands.toggleUnderlineWithAnalytics)(api === null || api === void 0 || (_api$
|
|
138
|
-
toggleEm: (0, _commands.toggleEmWithAnalytics)(api === null || api === void 0 || (_api$
|
|
139
|
-
toggleStrong: (0, _commands.toggleStrongWithAnalytics)(api === null || api === void 0 || (_api$
|
|
164
|
+
toggleSuperscript: (0, _commands.toggleSuperscriptWithAnalytics)(api === null || api === void 0 || (_api$analytics7 = api.analytics) === null || _api$analytics7 === void 0 ? void 0 : _api$analytics7.actions),
|
|
165
|
+
toggleSubscript: (0, _commands.toggleSubscriptWithAnalytics)(api === null || api === void 0 || (_api$analytics8 = api.analytics) === null || _api$analytics8 === void 0 ? void 0 : _api$analytics8.actions),
|
|
166
|
+
toggleStrike: (0, _commands.toggleStrikeWithAnalytics)(api === null || api === void 0 || (_api$analytics9 = api.analytics) === null || _api$analytics9 === void 0 ? void 0 : _api$analytics9.actions),
|
|
167
|
+
toggleCode: (0, _commands.toggleCodeWithAnalytics)(api === null || api === void 0 || (_api$analytics10 = api.analytics) === null || _api$analytics10 === void 0 ? void 0 : _api$analytics10.actions),
|
|
168
|
+
toggleUnderline: (0, _commands.toggleUnderlineWithAnalytics)(api === null || api === void 0 || (_api$analytics11 = api.analytics) === null || _api$analytics11 === void 0 ? void 0 : _api$analytics11.actions),
|
|
169
|
+
toggleEm: (0, _commands.toggleEmWithAnalytics)(api === null || api === void 0 || (_api$analytics12 = api.analytics) === null || _api$analytics12 === void 0 ? void 0 : _api$analytics12.actions),
|
|
170
|
+
toggleStrong: (0, _commands.toggleStrongWithAnalytics)(api === null || api === void 0 || (_api$analytics13 = api.analytics) === null || _api$analytics13 === void 0 ? void 0 : _api$analytics13.actions)
|
|
140
171
|
}
|
|
141
172
|
};
|
|
142
173
|
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.FloatingToolbarTextFormalWithIntl = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
+
var _react = require("react");
|
|
10
|
+
var _react2 = require("@emotion/react");
|
|
11
|
+
var _reactIntlNext = require("react-intl-next");
|
|
12
|
+
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
13
|
+
var _types = require("@atlaskit/editor-common/types");
|
|
14
|
+
var _dropdownMenu = require("./Toolbar/dropdown-menu");
|
|
15
|
+
var _clearFormattingIcon = require("./Toolbar/hooks/clear-formatting-icon");
|
|
16
|
+
var _formattingIcons = require("./Toolbar/hooks/formatting-icons");
|
|
17
|
+
var _types2 = require("./Toolbar/types");
|
|
18
|
+
/**
|
|
19
|
+
* @jsxRuntime classic
|
|
20
|
+
* @jsx jsx
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
24
|
+
|
|
25
|
+
var FloatingToolbarSettings = {
|
|
26
|
+
disabled: false,
|
|
27
|
+
isReducedSpacing: true,
|
|
28
|
+
shouldUseResponsiveToolbar: false,
|
|
29
|
+
toolbarSize: _types.ToolbarSize.XXXS,
|
|
30
|
+
hasMoreButton: false,
|
|
31
|
+
moreButtonLabel: '',
|
|
32
|
+
toolbarType: _types2.ToolbarType.FLOATING
|
|
33
|
+
};
|
|
34
|
+
var FloatingToolbarTextFormat = function FloatingToolbarTextFormat(_ref) {
|
|
35
|
+
var api = _ref.api,
|
|
36
|
+
editorAnalyticsAPI = _ref.editorAnalyticsAPI,
|
|
37
|
+
editorView = _ref.editorView,
|
|
38
|
+
intl = _ref.intl;
|
|
39
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['textFormatting']),
|
|
40
|
+
textFormattingState = _useSharedPluginState.textFormattingState;
|
|
41
|
+
var defaultIcons = (0, _formattingIcons.useFormattingIcons)({
|
|
42
|
+
schema: editorView.state.schema,
|
|
43
|
+
intl: intl,
|
|
44
|
+
isToolbarDisabled: FloatingToolbarSettings.disabled,
|
|
45
|
+
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
46
|
+
textFormattingState: textFormattingState,
|
|
47
|
+
toolbarType: FloatingToolbarSettings.toolbarType
|
|
48
|
+
});
|
|
49
|
+
var clearIcon = (0, _clearFormattingIcon.useClearIcon)({
|
|
50
|
+
textFormattingState: textFormattingState,
|
|
51
|
+
intl: intl,
|
|
52
|
+
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
53
|
+
toolbarType: FloatingToolbarSettings.toolbarType
|
|
54
|
+
});
|
|
55
|
+
var items = (0, _react.useMemo)(function () {
|
|
56
|
+
if (!clearIcon) {
|
|
57
|
+
return defaultIcons;
|
|
58
|
+
}
|
|
59
|
+
return [].concat((0, _toConsumableArray2.default)(defaultIcons), [clearIcon]);
|
|
60
|
+
}, [clearIcon, defaultIcons]);
|
|
61
|
+
return (0, _react2.jsx)(_dropdownMenu.FormattingTextDropdownMenu, {
|
|
62
|
+
editorView: editorView,
|
|
63
|
+
items: items,
|
|
64
|
+
isReducedSpacing: FloatingToolbarSettings.isReducedSpacing,
|
|
65
|
+
moreButtonLabel: FloatingToolbarSettings.moreButtonLabel,
|
|
66
|
+
hasFormattingActive: FloatingToolbarSettings.hasMoreButton,
|
|
67
|
+
hasMoreButton: FloatingToolbarSettings.hasMoreButton,
|
|
68
|
+
intl: intl
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
var FloatingToolbarTextFormalWithIntl = exports.FloatingToolbarTextFormalWithIntl = (0, _reactIntlNext.injectIntl)(FloatingToolbarTextFormat);
|
|
@@ -8,6 +8,7 @@ exports.PrimaryToolbarComponent = PrimaryToolbarComponent;
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
10
10
|
var _Toolbar = _interopRequireDefault(require("./Toolbar"));
|
|
11
|
+
var _types = require("./Toolbar/types");
|
|
11
12
|
function PrimaryToolbarComponent(_ref) {
|
|
12
13
|
var _api$analytics;
|
|
13
14
|
var api = _ref.api,
|
|
@@ -30,6 +31,7 @@ function PrimaryToolbarComponent(_ref) {
|
|
|
30
31
|
isToolbarDisabled: disabled,
|
|
31
32
|
shouldUseResponsiveToolbar: shouldUseResponsiveToolbar,
|
|
32
33
|
editorAnalyticsAPI: api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions,
|
|
33
|
-
api: api
|
|
34
|
+
api: api,
|
|
35
|
+
toolbarType: _types.ToolbarType.PRIMARY
|
|
34
36
|
});
|
|
35
37
|
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.BoldToolbarButton = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _react2 = require("@emotion/react");
|
|
10
|
+
var _styles = require("@atlaskit/editor-common/styles");
|
|
11
|
+
var _uiMenu = require("@atlaskit/editor-common/ui-menu");
|
|
12
|
+
var _textBoldEditorBold = _interopRequireDefault(require("@atlaskit/icon/core/migration/text-bold--editor-bold"));
|
|
13
|
+
var _chevronDown = _interopRequireDefault(require("@atlaskit/icon/utility/migration/chevron-down"));
|
|
14
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
15
|
+
/**
|
|
16
|
+
* @jsxRuntime classic
|
|
17
|
+
* @jsx jsx
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
21
|
+
|
|
22
|
+
var BoldToolbarButton = exports.BoldToolbarButton = function BoldToolbarButton(_ref) {
|
|
23
|
+
var label = _ref.label,
|
|
24
|
+
isReducedSpacing = _ref.isReducedSpacing,
|
|
25
|
+
isDisabled = _ref.isDisabled,
|
|
26
|
+
isSelected = _ref.isSelected,
|
|
27
|
+
ariaExpanded = _ref['aria-expanded'],
|
|
28
|
+
onClick = _ref.onClick,
|
|
29
|
+
onKeyDown = _ref.onKeyDown;
|
|
30
|
+
return (0, _react2.jsx)(_uiMenu.ToolbarButton, {
|
|
31
|
+
testId: 'ak-editor-selection-toolbar-format-text-button',
|
|
32
|
+
spacing: isReducedSpacing ? 'none' : 'default',
|
|
33
|
+
disabled: isDisabled,
|
|
34
|
+
selected: isSelected,
|
|
35
|
+
"aria-label": label,
|
|
36
|
+
"aria-expanded": ariaExpanded,
|
|
37
|
+
"aria-haspopup": true,
|
|
38
|
+
title: label,
|
|
39
|
+
onClick: onClick,
|
|
40
|
+
onKeyDown: onKeyDown,
|
|
41
|
+
iconBefore: (0, _react2.jsx)("div", {
|
|
42
|
+
css:
|
|
43
|
+
// eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-registration
|
|
44
|
+
(0, _platformFeatureFlags.fg)('platform-visual-refresh-icons') ?
|
|
45
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
46
|
+
_styles.triggerWrapperStylesWithPadding :
|
|
47
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
48
|
+
_styles.triggerWrapperStyles
|
|
49
|
+
}, (0, _react2.jsx)(_textBoldEditorBold.default, {
|
|
50
|
+
color: "currentColor",
|
|
51
|
+
spacing: "spacious",
|
|
52
|
+
label: ""
|
|
53
|
+
}), (0, _react2.jsx)("span", {
|
|
54
|
+
css: _styles.expandIconContainerStyle
|
|
55
|
+
}, (0, _react2.jsx)(_chevronDown.default, {
|
|
56
|
+
label: "",
|
|
57
|
+
color: "currentColor",
|
|
58
|
+
LEGACY_margin: "0 0 0 -8px"
|
|
59
|
+
})))
|
|
60
|
+
});
|
|
61
|
+
};
|
|
@@ -8,8 +8,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.FormattingTextDropdownMenu = void 0;
|
|
9
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _messages = require("@atlaskit/editor-common/messages");
|
|
11
12
|
var _uiMenu = require("@atlaskit/editor-common/ui-menu");
|
|
12
13
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
14
|
+
var _boldButton = require("./bold-button");
|
|
13
15
|
var _menuState = require("./hooks/menu-state");
|
|
14
16
|
var _moreButton = require("./more-button");
|
|
15
17
|
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); }
|
|
@@ -22,7 +24,9 @@ var FormattingTextDropdownMenu = exports.FormattingTextDropdownMenu = /*#__PURE_
|
|
|
22
24
|
hasFormattingActive = _ref.hasFormattingActive,
|
|
23
25
|
popupsBoundariesElement = _ref.popupsBoundariesElement,
|
|
24
26
|
popupsMountPoint = _ref.popupsMountPoint,
|
|
25
|
-
popupsScrollableElement = _ref.popupsScrollableElement
|
|
27
|
+
popupsScrollableElement = _ref.popupsScrollableElement,
|
|
28
|
+
hasMoreButton = _ref.hasMoreButton,
|
|
29
|
+
intl = _ref.intl;
|
|
26
30
|
var _useMenuState = (0, _menuState.useMenuState)(),
|
|
27
31
|
_useMenuState2 = (0, _slicedToArray2.default)(_useMenuState, 3),
|
|
28
32
|
isMenuOpen = _useMenuState2[0],
|
|
@@ -66,7 +70,7 @@ var FormattingTextDropdownMenu = exports.FormattingTextDropdownMenu = /*#__PURE_
|
|
|
66
70
|
}
|
|
67
71
|
return isOpenedByKeyboard;
|
|
68
72
|
}
|
|
69
|
-
}, /*#__PURE__*/_react.default.createElement(_moreButton.MoreButton, {
|
|
73
|
+
}, hasMoreButton ? /*#__PURE__*/_react.default.createElement(_moreButton.MoreButton, {
|
|
70
74
|
isSelected: isMenuOpen || hasFormattingActive,
|
|
71
75
|
label: moreButtonLabel,
|
|
72
76
|
isReducedSpacing: isReducedSpacing,
|
|
@@ -83,5 +87,23 @@ var FormattingTextDropdownMenu = exports.FormattingTextDropdownMenu = /*#__PURE_
|
|
|
83
87
|
}
|
|
84
88
|
},
|
|
85
89
|
"aria-expanded": isMenuOpen
|
|
90
|
+
}) : /*#__PURE__*/_react.default.createElement(_boldButton.BoldToolbarButton, {
|
|
91
|
+
isReducedSpacing: isReducedSpacing,
|
|
92
|
+
isDisabled: false,
|
|
93
|
+
isSelected: isMenuOpen,
|
|
94
|
+
label: intl.formatMessage(_messages.toolbarMessages.textFormat),
|
|
95
|
+
"aria-expanded": isMenuOpen,
|
|
96
|
+
"aria-haspopup": true,
|
|
97
|
+
onClick: function onClick() {
|
|
98
|
+
toggleMenu();
|
|
99
|
+
setIsOpenedByKeyboard(false);
|
|
100
|
+
},
|
|
101
|
+
onKeyDown: function onKeyDown(event) {
|
|
102
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
103
|
+
event.preventDefault();
|
|
104
|
+
toggleMenu();
|
|
105
|
+
setIsOpenedByKeyboard(true);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
86
108
|
}));
|
|
87
109
|
});
|
|
@@ -6,11 +6,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.useClearIcon = void 0;
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _react2 = require("@emotion/react");
|
|
9
|
-
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
10
9
|
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
11
10
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
12
11
|
var _shortcut = require("@atlaskit/editor-shared-styles/shortcut");
|
|
13
12
|
var _clearFormatting = require("../../../commands/clear-formatting");
|
|
13
|
+
var _inputMethodUtils = require("../../../input-method-utils");
|
|
14
14
|
/**
|
|
15
15
|
* @jsxRuntime classic
|
|
16
16
|
* @jsx jsx
|
|
@@ -21,13 +21,14 @@ var _clearFormatting = require("../../../commands/clear-formatting");
|
|
|
21
21
|
var useClearIcon = exports.useClearIcon = function useClearIcon(_ref) {
|
|
22
22
|
var intl = _ref.intl,
|
|
23
23
|
textFormattingState = _ref.textFormattingState,
|
|
24
|
-
editorAnalyticsAPI = _ref.editorAnalyticsAPI
|
|
24
|
+
editorAnalyticsAPI = _ref.editorAnalyticsAPI,
|
|
25
|
+
toolbarType = _ref.toolbarType;
|
|
25
26
|
var isPluginAvailable = Boolean(textFormattingState);
|
|
26
27
|
var formattingIsPresent = Boolean(textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.formattingIsPresent);
|
|
27
28
|
var clearFormattingLabel = intl.formatMessage(_messages.toolbarMessages.clearFormatting);
|
|
28
29
|
var clearFormattingToolbar = (0, _react.useCallback)(function (state, dispatch) {
|
|
29
|
-
return (0, _clearFormatting.clearFormattingWithAnalytics)(
|
|
30
|
-
}, [editorAnalyticsAPI]);
|
|
30
|
+
return (0, _clearFormatting.clearFormattingWithAnalytics)((0, _inputMethodUtils.getInputMethod)(toolbarType), editorAnalyticsAPI)(state, dispatch);
|
|
31
|
+
}, [editorAnalyticsAPI, toolbarType]);
|
|
31
32
|
return (0, _react.useMemo)(function () {
|
|
32
33
|
if (!isPluginAvailable) {
|
|
33
34
|
return null;
|
|
@@ -17,6 +17,7 @@ var _shortcut = require("@atlaskit/editor-shared-styles/shortcut");
|
|
|
17
17
|
var _textBoldEditorBold = _interopRequireDefault(require("@atlaskit/icon/core/migration/text-bold--editor-bold"));
|
|
18
18
|
var _textItalicEditorItalic = _interopRequireDefault(require("@atlaskit/icon/core/migration/text-italic--editor-italic"));
|
|
19
19
|
var _commands = require("../../../commands");
|
|
20
|
+
var _inputMethodUtils = require("../../../input-method-utils");
|
|
20
21
|
var _types = require("../types");
|
|
21
22
|
var _IconsMarkSchema;
|
|
22
23
|
/**
|
|
@@ -26,14 +27,14 @@ var _IconsMarkSchema;
|
|
|
26
27
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
27
28
|
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); }
|
|
28
29
|
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; }
|
|
29
|
-
var
|
|
30
|
-
return (0, _preset.editorCommandToPMCommand)(func(
|
|
30
|
+
var withInputMethod = function withInputMethod(toolbarType, func) {
|
|
31
|
+
return (0, _preset.editorCommandToPMCommand)(func((0, _inputMethodUtils.getInputMethod)(toolbarType)));
|
|
31
32
|
};
|
|
32
|
-
var IconButtons = function IconButtons(editorAnalyticsAPI) {
|
|
33
|
+
var IconButtons = function IconButtons(editorAnalyticsAPI, toolbarType) {
|
|
33
34
|
return {
|
|
34
35
|
strong: {
|
|
35
36
|
buttonId: _analytics.TOOLBAR_ACTION_SUBJECT_ID.TEXT_FORMATTING_STRONG,
|
|
36
|
-
command:
|
|
37
|
+
command: withInputMethod(toolbarType, (0, _commands.toggleStrongWithAnalytics)(editorAnalyticsAPI)),
|
|
37
38
|
message: _messages.toolbarMessages.bold,
|
|
38
39
|
tooltipKeymap: _keymaps.toggleBold,
|
|
39
40
|
component: function component() {
|
|
@@ -46,7 +47,7 @@ var IconButtons = function IconButtons(editorAnalyticsAPI) {
|
|
|
46
47
|
},
|
|
47
48
|
em: {
|
|
48
49
|
buttonId: _analytics.TOOLBAR_ACTION_SUBJECT_ID.TEXT_FORMATTING_ITALIC,
|
|
49
|
-
command:
|
|
50
|
+
command: withInputMethod(toolbarType, (0, _commands.toggleEmWithAnalytics)(editorAnalyticsAPI)),
|
|
50
51
|
message: _messages.toolbarMessages.italic,
|
|
51
52
|
tooltipKeymap: _keymaps.toggleItalic,
|
|
52
53
|
component: function component() {
|
|
@@ -58,27 +59,27 @@ var IconButtons = function IconButtons(editorAnalyticsAPI) {
|
|
|
58
59
|
}
|
|
59
60
|
},
|
|
60
61
|
underline: {
|
|
61
|
-
command:
|
|
62
|
+
command: withInputMethod(toolbarType, (0, _commands.toggleUnderlineWithAnalytics)(editorAnalyticsAPI)),
|
|
62
63
|
message: _messages.toolbarMessages.underline,
|
|
63
64
|
tooltipKeymap: _keymaps.toggleUnderline
|
|
64
65
|
},
|
|
65
66
|
strike: {
|
|
66
|
-
command:
|
|
67
|
+
command: withInputMethod(toolbarType, (0, _commands.toggleStrikeWithAnalytics)(editorAnalyticsAPI)),
|
|
67
68
|
message: _messages.toolbarMessages.strike,
|
|
68
69
|
tooltipKeymap: _keymaps.toggleStrikethrough
|
|
69
70
|
},
|
|
70
71
|
code: {
|
|
71
|
-
command:
|
|
72
|
+
command: withInputMethod(toolbarType, (0, _commands.toggleCodeWithAnalytics)(editorAnalyticsAPI)),
|
|
72
73
|
message: _messages.toolbarMessages.code,
|
|
73
74
|
tooltipKeymap: _keymaps.toggleCode
|
|
74
75
|
},
|
|
75
76
|
subscript: {
|
|
76
|
-
command:
|
|
77
|
+
command: withInputMethod(toolbarType, (0, _commands.toggleSubscriptWithAnalytics)(editorAnalyticsAPI)),
|
|
77
78
|
message: _messages.toolbarMessages.subscript,
|
|
78
79
|
tooltipKeymap: _keymaps.toggleSubscript
|
|
79
80
|
},
|
|
80
81
|
superscript: {
|
|
81
|
-
command:
|
|
82
|
+
command: withInputMethod(toolbarType, (0, _commands.toggleSuperscriptWithAnalytics)(editorAnalyticsAPI)),
|
|
82
83
|
message: _messages.toolbarMessages.superscript,
|
|
83
84
|
tooltipKeymap: _keymaps.toggleSuperscript
|
|
84
85
|
}
|
|
@@ -89,8 +90,9 @@ var getIcon = function getIcon(_ref) {
|
|
|
89
90
|
isDisabled = _ref.isDisabled,
|
|
90
91
|
isActive = _ref.isActive,
|
|
91
92
|
intl = _ref.intl,
|
|
92
|
-
editorAnalyticsAPI = _ref.editorAnalyticsAPI
|
|
93
|
-
|
|
93
|
+
editorAnalyticsAPI = _ref.editorAnalyticsAPI,
|
|
94
|
+
toolbarType = _ref.toolbarType;
|
|
95
|
+
var icon = IconButtons(editorAnalyticsAPI, toolbarType)[iconType];
|
|
94
96
|
var content = intl.formatMessage(icon.message);
|
|
95
97
|
var tooltipKeymap = icon.tooltipKeymap;
|
|
96
98
|
return {
|
|
@@ -145,7 +147,7 @@ var buildMenuIconState = function buildMenuIconState(iconMark) {
|
|
|
145
147
|
};
|
|
146
148
|
};
|
|
147
149
|
};
|
|
148
|
-
var buildIcon = function buildIcon(iconMark, editorAnalyticsAPI) {
|
|
150
|
+
var buildIcon = function buildIcon(iconMark, editorAnalyticsAPI, toolbarType) {
|
|
149
151
|
var getState = buildMenuIconState(iconMark);
|
|
150
152
|
return function (_ref3) {
|
|
151
153
|
var schema = _ref3.schema,
|
|
@@ -166,7 +168,8 @@ var buildIcon = function buildIcon(iconMark, editorAnalyticsAPI) {
|
|
|
166
168
|
isDisabled: isToolbarDisabled || isDisabled,
|
|
167
169
|
isActive: isActive,
|
|
168
170
|
intl: intl,
|
|
169
|
-
editorAnalyticsAPI: editorAnalyticsAPI
|
|
171
|
+
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
172
|
+
toolbarType: toolbarType
|
|
170
173
|
});
|
|
171
174
|
}, [isToolbarDisabled, isDisabled, isActive, intl]);
|
|
172
175
|
var shouldRenderIcon = hasSchemaMark && !isHidden;
|
|
@@ -180,20 +183,22 @@ var useFormattingIcons = exports.useFormattingIcons = function useFormattingIcon
|
|
|
180
183
|
textFormattingState = _ref4.textFormattingState,
|
|
181
184
|
schema = _ref4.schema,
|
|
182
185
|
intl = _ref4.intl,
|
|
183
|
-
editorAnalyticsAPI = _ref4.editorAnalyticsAPI
|
|
186
|
+
editorAnalyticsAPI = _ref4.editorAnalyticsAPI,
|
|
187
|
+
toolbarType = _ref4.toolbarType;
|
|
184
188
|
var props = {
|
|
185
189
|
schema: schema,
|
|
186
190
|
textFormattingState: textFormattingState,
|
|
187
191
|
intl: intl,
|
|
188
|
-
isToolbarDisabled: Boolean(isToolbarDisabled)
|
|
192
|
+
isToolbarDisabled: Boolean(isToolbarDisabled),
|
|
193
|
+
toolbarType: toolbarType
|
|
189
194
|
};
|
|
190
|
-
var buildStrongIcon = buildIcon(_types.IconTypes.strong, editorAnalyticsAPI);
|
|
191
|
-
var buildEmIcon = buildIcon(_types.IconTypes.em, editorAnalyticsAPI);
|
|
192
|
-
var buildUnderlineIcon = buildIcon(_types.IconTypes.underline, editorAnalyticsAPI);
|
|
193
|
-
var buildStrikeIcon = buildIcon(_types.IconTypes.strike, editorAnalyticsAPI);
|
|
194
|
-
var buildCodeIcon = buildIcon(_types.IconTypes.code, editorAnalyticsAPI);
|
|
195
|
-
var buildSubscriptIcon = buildIcon(_types.IconTypes.subscript, editorAnalyticsAPI);
|
|
196
|
-
var buildSuperscriptIcon = buildIcon(_types.IconTypes.superscript, editorAnalyticsAPI);
|
|
195
|
+
var buildStrongIcon = buildIcon(_types.IconTypes.strong, editorAnalyticsAPI, toolbarType);
|
|
196
|
+
var buildEmIcon = buildIcon(_types.IconTypes.em, editorAnalyticsAPI, toolbarType);
|
|
197
|
+
var buildUnderlineIcon = buildIcon(_types.IconTypes.underline, editorAnalyticsAPI, toolbarType);
|
|
198
|
+
var buildStrikeIcon = buildIcon(_types.IconTypes.strike, editorAnalyticsAPI, toolbarType);
|
|
199
|
+
var buildCodeIcon = buildIcon(_types.IconTypes.code, editorAnalyticsAPI, toolbarType);
|
|
200
|
+
var buildSubscriptIcon = buildIcon(_types.IconTypes.subscript, editorAnalyticsAPI, toolbarType);
|
|
201
|
+
var buildSuperscriptIcon = buildIcon(_types.IconTypes.superscript, editorAnalyticsAPI, toolbarType);
|
|
197
202
|
var strongIcon = buildStrongIcon(props);
|
|
198
203
|
var emIcon = buildEmIcon(props);
|
|
199
204
|
var underlineIcon = buildUnderlineIcon(props);
|
|
@@ -41,7 +41,8 @@ var ToolbarFormatting = function ToolbarFormatting(_ref) {
|
|
|
41
41
|
intl = _ref.intl,
|
|
42
42
|
editorAnalyticsAPI = _ref.editorAnalyticsAPI,
|
|
43
43
|
textFormattingState = _ref.textFormattingState,
|
|
44
|
-
api = _ref.api
|
|
44
|
+
api = _ref.api,
|
|
45
|
+
toolbarType = _ref.toolbarType;
|
|
45
46
|
var _useState = (0, _react.useState)(''),
|
|
46
47
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
47
48
|
message = _useState2[0],
|
|
@@ -51,12 +52,14 @@ var ToolbarFormatting = function ToolbarFormatting(_ref) {
|
|
|
51
52
|
intl: intl,
|
|
52
53
|
isToolbarDisabled: isToolbarDisabled,
|
|
53
54
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
54
|
-
textFormattingState: textFormattingState
|
|
55
|
+
textFormattingState: textFormattingState,
|
|
56
|
+
toolbarType: toolbarType
|
|
55
57
|
});
|
|
56
58
|
var clearIcon = (0, _clearFormattingIcon.useClearIcon)({
|
|
57
59
|
textFormattingState: textFormattingState,
|
|
58
60
|
intl: intl,
|
|
59
|
-
editorAnalyticsAPI: editorAnalyticsAPI
|
|
61
|
+
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
62
|
+
toolbarType: toolbarType
|
|
60
63
|
});
|
|
61
64
|
var menuIconTypeList = (0, _responsiveToolbarButtons.useResponsiveIconTypeMenu)({
|
|
62
65
|
toolbarSize: toolbarSize,
|
|
@@ -163,7 +166,9 @@ var ToolbarFormatting = function ToolbarFormatting(_ref) {
|
|
|
163
166
|
isReducedSpacing: isReducedSpacing,
|
|
164
167
|
moreButtonLabel: moreFormattingButtonLabel,
|
|
165
168
|
hasFormattingActive: hasFormattingActive,
|
|
166
|
-
|
|
169
|
+
hasMoreButton: true,
|
|
170
|
+
items: items,
|
|
171
|
+
intl: intl
|
|
167
172
|
}))), !(api !== null && api !== void 0 && api.primaryToolbar) && /* eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage */
|
|
168
173
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
|
|
169
174
|
(0, _react2.jsx)("span", {
|
|
@@ -182,7 +187,8 @@ var Toolbar = function Toolbar(_ref2) {
|
|
|
182
187
|
intl = _ref2.intl,
|
|
183
188
|
editorAnalyticsAPI = _ref2.editorAnalyticsAPI,
|
|
184
189
|
textFormattingState = _ref2.textFormattingState,
|
|
185
|
-
api = _ref2.api
|
|
190
|
+
api = _ref2.api,
|
|
191
|
+
toolbarType = _ref2.toolbarType;
|
|
186
192
|
return (0, _react2.jsx)(ToolbarFormatting, {
|
|
187
193
|
textFormattingState: textFormattingState,
|
|
188
194
|
popupsMountPoint: popupsMountPoint,
|
|
@@ -194,7 +200,8 @@ var Toolbar = function Toolbar(_ref2) {
|
|
|
194
200
|
shouldUseResponsiveToolbar: shouldUseResponsiveToolbar,
|
|
195
201
|
intl: intl,
|
|
196
202
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
197
|
-
api: api
|
|
203
|
+
api: api,
|
|
204
|
+
toolbarType: toolbarType
|
|
198
205
|
});
|
|
199
206
|
};
|
|
200
207
|
var _default = exports.default = (0, _reactIntlNext.injectIntl)(Toolbar);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.IconTypes = void 0;
|
|
6
|
+
exports.ToolbarType = exports.IconTypes = void 0;
|
|
7
7
|
var IconTypes = exports.IconTypes = /*#__PURE__*/function (IconTypes) {
|
|
8
8
|
IconTypes["strong"] = "strong";
|
|
9
9
|
IconTypes["em"] = "em";
|
|
@@ -13,4 +13,9 @@ var IconTypes = exports.IconTypes = /*#__PURE__*/function (IconTypes) {
|
|
|
13
13
|
IconTypes["subscript"] = "subscript";
|
|
14
14
|
IconTypes["superscript"] = "superscript";
|
|
15
15
|
return IconTypes;
|
|
16
|
+
}({});
|
|
17
|
+
var ToolbarType = exports.ToolbarType = /*#__PURE__*/function (ToolbarType) {
|
|
18
|
+
ToolbarType["PRIMARY"] = "primaryToolbar";
|
|
19
|
+
ToolbarType["FLOATING"] = "floatingToolbar";
|
|
20
|
+
return ToolbarType;
|
|
16
21
|
}({});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { ToolbarType } from './ui/Toolbar/types';
|
|
3
|
+
export const toolbarTypeToInputMethod = {
|
|
4
|
+
[ToolbarType.PRIMARY]: INPUT_METHOD.TOOLBAR,
|
|
5
|
+
[ToolbarType.FLOATING]: INPUT_METHOD.FLOATING_TB
|
|
6
|
+
};
|
|
7
|
+
export const getInputMethod = toolbarType => toolbarTypeToInputMethod[toolbarType];
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { code, em, strike, strong, subsup, underline } from '@atlaskit/adf-schema';
|
|
3
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
3
4
|
import { toggleCodeWithAnalytics, toggleEmWithAnalytics, toggleStrikeWithAnalytics, toggleStrongWithAnalytics, toggleSubscriptWithAnalytics, toggleSuperscriptWithAnalytics, toggleUnderlineWithAnalytics } from './commands';
|
|
4
5
|
import { plugin as clearFormattingPlugin, pluginKey as clearFormattingPluginKey } from './pm-plugins/clear-formatting';
|
|
5
6
|
import clearFormattingKeymapPlugin from './pm-plugins/clear-formatting-keymap';
|
|
@@ -8,6 +9,7 @@ import textFormattingInputRulePlugin from './pm-plugins/input-rule';
|
|
|
8
9
|
import keymapPlugin from './pm-plugins/keymap';
|
|
9
10
|
import { plugin as pmPlugin, pluginKey as textFormattingPluginKey } from './pm-plugins/main';
|
|
10
11
|
import textFormattingSmartInputRulePlugin from './pm-plugins/smart-input-rule';
|
|
12
|
+
import { FloatingToolbarTextFormalWithIntl as FloatingToolbarComponent } from './ui/FloatingToolbarComponent';
|
|
11
13
|
import { PrimaryToolbarComponent } from './ui/PrimaryToolbarComponent';
|
|
12
14
|
/**
|
|
13
15
|
* Text formatting plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor`
|
|
@@ -17,7 +19,7 @@ export const textFormattingPlugin = ({
|
|
|
17
19
|
config: options,
|
|
18
20
|
api
|
|
19
21
|
}) => {
|
|
20
|
-
var _api$primaryToolbar, _api$
|
|
22
|
+
var _api$primaryToolbar, _api$analytics7, _api$analytics8, _api$analytics9, _api$analytics10, _api$analytics11, _api$analytics12, _api$analytics13;
|
|
21
23
|
const primaryToolbarComponent = ({
|
|
22
24
|
editorView,
|
|
23
25
|
popupsMountPoint,
|
|
@@ -121,15 +123,44 @@ export const textFormattingPlugin = ({
|
|
|
121
123
|
formattingIsPresent: (_clearFormattingPlugi = clearFormattingPluginKey.getState(editorState)) === null || _clearFormattingPlugi === void 0 ? void 0 : _clearFormattingPlugi.formattingIsPresent
|
|
122
124
|
};
|
|
123
125
|
},
|
|
126
|
+
pluginsOptions: {
|
|
127
|
+
selectionToolbar: () => {
|
|
128
|
+
if (editorExperiment('contextual_formatting_toolbar', true, {
|
|
129
|
+
exposure: true
|
|
130
|
+
})) {
|
|
131
|
+
const toolbarCustom = {
|
|
132
|
+
type: 'custom',
|
|
133
|
+
render: view => {
|
|
134
|
+
var _api$analytics6;
|
|
135
|
+
if (!view) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
return /*#__PURE__*/React.createElement(FloatingToolbarComponent, {
|
|
139
|
+
api: api,
|
|
140
|
+
editorView: view,
|
|
141
|
+
editorAnalyticsAPI: api === null || api === void 0 ? void 0 : (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : _api$analytics6.actions
|
|
142
|
+
});
|
|
143
|
+
},
|
|
144
|
+
fallback: []
|
|
145
|
+
};
|
|
146
|
+
return {
|
|
147
|
+
isToolbarAbove: true,
|
|
148
|
+
items: [toolbarCustom]
|
|
149
|
+
};
|
|
150
|
+
} else {
|
|
151
|
+
return undefined;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
},
|
|
124
155
|
primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined,
|
|
125
156
|
commands: {
|
|
126
|
-
toggleSuperscript: toggleSuperscriptWithAnalytics(api === null || api === void 0 ? void 0 : (_api$
|
|
127
|
-
toggleSubscript: toggleSubscriptWithAnalytics(api === null || api === void 0 ? void 0 : (_api$
|
|
128
|
-
toggleStrike: toggleStrikeWithAnalytics(api === null || api === void 0 ? void 0 : (_api$
|
|
129
|
-
toggleCode: toggleCodeWithAnalytics(api === null || api === void 0 ? void 0 : (_api$
|
|
130
|
-
toggleUnderline: toggleUnderlineWithAnalytics(api === null || api === void 0 ? void 0 : (_api$
|
|
131
|
-
toggleEm: toggleEmWithAnalytics(api === null || api === void 0 ? void 0 : (_api$
|
|
132
|
-
toggleStrong: toggleStrongWithAnalytics(api === null || api === void 0 ? void 0 : (_api$
|
|
157
|
+
toggleSuperscript: toggleSuperscriptWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics7 = api.analytics) === null || _api$analytics7 === void 0 ? void 0 : _api$analytics7.actions),
|
|
158
|
+
toggleSubscript: toggleSubscriptWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics8 = api.analytics) === null || _api$analytics8 === void 0 ? void 0 : _api$analytics8.actions),
|
|
159
|
+
toggleStrike: toggleStrikeWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics9 = api.analytics) === null || _api$analytics9 === void 0 ? void 0 : _api$analytics9.actions),
|
|
160
|
+
toggleCode: toggleCodeWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics10 = api.analytics) === null || _api$analytics10 === void 0 ? void 0 : _api$analytics10.actions),
|
|
161
|
+
toggleUnderline: toggleUnderlineWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics11 = api.analytics) === null || _api$analytics11 === void 0 ? void 0 : _api$analytics11.actions),
|
|
162
|
+
toggleEm: toggleEmWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics12 = api.analytics) === null || _api$analytics12 === void 0 ? void 0 : _api$analytics12.actions),
|
|
163
|
+
toggleStrong: toggleStrongWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics13 = api.analytics) === null || _api$analytics13 === void 0 ? void 0 : _api$analytics13.actions)
|
|
133
164
|
}
|
|
134
165
|
};
|
|
135
166
|
};
|