@atlaskit/editor-plugin-text-formatting 2.2.5 → 2.2.6
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 +10 -0
- package/dist/cjs/pm-plugins/main.js +3 -1
- package/dist/cjs/textFormattingPlugin.js +4 -2
- package/dist/cjs/ui/FloatingToolbarComponent.js +90 -8
- package/dist/cjs/ui/PrimaryToolbarComponent.js +80 -2
- package/dist/cjs/ui/Toolbar/hooks/clear-formatting-icon.js +4 -3
- package/dist/cjs/ui/Toolbar/hooks/formatting-icons.js +2 -2
- package/dist/cjs/ui/Toolbar/index.js +7 -4
- package/dist/es2019/pm-plugins/main.js +3 -1
- package/dist/es2019/textFormattingPlugin.js +4 -2
- package/dist/es2019/ui/FloatingToolbarComponent.js +88 -5
- package/dist/es2019/ui/PrimaryToolbarComponent.js +82 -4
- package/dist/es2019/ui/Toolbar/hooks/clear-formatting-icon.js +4 -3
- package/dist/es2019/ui/Toolbar/hooks/formatting-icons.js +2 -2
- package/dist/es2019/ui/Toolbar/index.js +7 -2
- package/dist/esm/pm-plugins/main.js +3 -1
- package/dist/esm/textFormattingPlugin.js +4 -2
- package/dist/esm/ui/FloatingToolbarComponent.js +88 -5
- package/dist/esm/ui/PrimaryToolbarComponent.js +81 -3
- package/dist/esm/ui/Toolbar/hooks/clear-formatting-icon.js +4 -3
- package/dist/esm/ui/Toolbar/hooks/formatting-icons.js +2 -2
- package/dist/esm/ui/Toolbar/index.js +7 -2
- package/dist/types/ui/Toolbar/hooks/clear-formatting-icon.d.ts +3 -3
- package/dist/types/ui/Toolbar/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/Toolbar/hooks/clear-formatting-icon.d.ts +3 -3
- package/dist/types-ts4.5/ui/Toolbar/index.d.ts +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-text-formatting
|
|
2
2
|
|
|
3
|
+
## 2.2.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#154988](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/154988)
|
|
8
|
+
[`76019734ff982`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/76019734ff982) -
|
|
9
|
+
[ED-27560] Adds `isInitialised` state variable to text-formatting plugin and migrates it to
|
|
10
|
+
useSharedPluginStateSelector
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
3
13
|
## 2.2.5
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
|
@@ -48,7 +48,9 @@ var getTextFormattingState = function getTextFormattingState(editorState, editor
|
|
|
48
48
|
strong = _editorState$schema$m.strong,
|
|
49
49
|
subsup = _editorState$schema$m.subsup,
|
|
50
50
|
underline = _editorState$schema$m.underline;
|
|
51
|
-
var state = {
|
|
51
|
+
var state = {
|
|
52
|
+
isInitialised: true
|
|
53
|
+
};
|
|
52
54
|
if (code) {
|
|
53
55
|
state.codeActive = (0, _mark.anyMarkActive)(editorState, code.create());
|
|
54
56
|
state.codeDisabled = !checkNodeSelection(code, editorState);
|
|
@@ -127,8 +127,10 @@ var textFormattingPlugin = exports.textFormattingPlugin = function textFormattin
|
|
|
127
127
|
if (!editorState) {
|
|
128
128
|
return undefined;
|
|
129
129
|
}
|
|
130
|
-
|
|
131
|
-
|
|
130
|
+
var textFormattingState = _pluginKey.pluginKey.getState(editorState);
|
|
131
|
+
return _objectSpread(_objectSpread({}, textFormattingState), {}, {
|
|
132
|
+
formattingIsPresent: (_clearFormattingPlugi = _clearFormatting.pluginKey.getState(editorState)) === null || _clearFormattingPlugi === void 0 ? void 0 : _clearFormattingPlugi.formattingIsPresent,
|
|
133
|
+
isInitialised: !!(textFormattingState !== null && textFormattingState !== void 0 && textFormattingState.isInitialised)
|
|
132
134
|
});
|
|
133
135
|
},
|
|
134
136
|
pluginsOptions: {
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports.FloatingToolbarTextFormalWithIntl = void 0;
|
|
9
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
8
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
11
|
var _react2 = require("@emotion/react");
|
|
10
12
|
var _reactIntlNext = require("react-intl-next");
|
|
11
13
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
12
14
|
var _types = require("@atlaskit/editor-common/types");
|
|
15
|
+
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
13
16
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
14
17
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
15
18
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
@@ -21,15 +24,14 @@ var _formattingIcons = require("./Toolbar/hooks/formatting-icons");
|
|
|
21
24
|
var _useIconList2 = require("./Toolbar/hooks/use-icon-list");
|
|
22
25
|
var _singleToolbarButtons = require("./Toolbar/single-toolbar-buttons");
|
|
23
26
|
var _types2 = require("./Toolbar/types");
|
|
24
|
-
|
|
25
|
-
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; }
|
|
27
|
+
var _excluded = ["formattingIsPresent"];
|
|
26
28
|
/**
|
|
27
29
|
* @jsxRuntime classic
|
|
28
30
|
* @jsx jsx
|
|
29
31
|
*/
|
|
30
|
-
|
|
31
32
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
32
|
-
|
|
33
|
+
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); }
|
|
34
|
+
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; }
|
|
33
35
|
var FloatingToolbarSettings = {
|
|
34
36
|
disabled: false,
|
|
35
37
|
isReducedSpacing: true,
|
|
@@ -39,19 +41,98 @@ var FloatingToolbarSettings = {
|
|
|
39
41
|
moreButtonLabel: '',
|
|
40
42
|
toolbarType: _types2.ToolbarType.FLOATING
|
|
41
43
|
};
|
|
44
|
+
var useSharedState = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (api) {
|
|
45
|
+
var isInitialised = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.isInitialised');
|
|
46
|
+
var formattingIsPresent = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.formattingIsPresent');
|
|
47
|
+
var emActive = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.emActive');
|
|
48
|
+
var emDisabled = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.emDisabled');
|
|
49
|
+
var emHidden = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.emHidden');
|
|
50
|
+
var codeActive = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.codeActive');
|
|
51
|
+
var codeDisabled = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.codeDisabled');
|
|
52
|
+
var codeHidden = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.codeHidden');
|
|
53
|
+
var underlineActive = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.underlineActive');
|
|
54
|
+
var underlineDisabled = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.underlineDisabled');
|
|
55
|
+
var underlineHidden = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.underlineHidden');
|
|
56
|
+
var strikeActive = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.strikeActive');
|
|
57
|
+
var strikeDisabled = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.strikeDisabled');
|
|
58
|
+
var strikeHidden = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.strikeHidden');
|
|
59
|
+
var strongActive = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.strongActive');
|
|
60
|
+
var strongDisabled = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.strongDisabled');
|
|
61
|
+
var strongHidden = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.strongHidden');
|
|
62
|
+
var superscriptActive = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.superscriptActive');
|
|
63
|
+
var superscriptDisabled = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.superscriptDisabled');
|
|
64
|
+
var superscriptHidden = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.superscriptHidden');
|
|
65
|
+
var subscriptActive = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.subscriptActive');
|
|
66
|
+
var subscriptDisabled = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.subscriptDisabled');
|
|
67
|
+
var subscriptHidden = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.subscriptHidden');
|
|
68
|
+
return {
|
|
69
|
+
isInitialised: Boolean(isInitialised),
|
|
70
|
+
formattingIsPresent: formattingIsPresent,
|
|
71
|
+
emActive: emActive,
|
|
72
|
+
emDisabled: emDisabled,
|
|
73
|
+
emHidden: emHidden,
|
|
74
|
+
codeActive: codeActive,
|
|
75
|
+
codeDisabled: codeDisabled,
|
|
76
|
+
codeHidden: codeHidden,
|
|
77
|
+
underlineActive: underlineActive,
|
|
78
|
+
underlineDisabled: underlineDisabled,
|
|
79
|
+
underlineHidden: underlineHidden,
|
|
80
|
+
strikeActive: strikeActive,
|
|
81
|
+
strikeDisabled: strikeDisabled,
|
|
82
|
+
strikeHidden: strikeHidden,
|
|
83
|
+
strongActive: strongActive,
|
|
84
|
+
strongDisabled: strongDisabled,
|
|
85
|
+
strongHidden: strongHidden,
|
|
86
|
+
superscriptActive: superscriptActive,
|
|
87
|
+
superscriptDisabled: superscriptDisabled,
|
|
88
|
+
superscriptHidden: superscriptHidden,
|
|
89
|
+
subscriptActive: subscriptActive,
|
|
90
|
+
subscriptDisabled: subscriptDisabled,
|
|
91
|
+
subscriptHidden: subscriptHidden
|
|
92
|
+
};
|
|
93
|
+
}, function (api) {
|
|
94
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['textFormatting']),
|
|
95
|
+
textFormattingState = _useSharedPluginState.textFormattingState;
|
|
96
|
+
return {
|
|
97
|
+
isInitialised: Boolean(textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.isInitialised),
|
|
98
|
+
formattingIsPresent: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.formattingIsPresent,
|
|
99
|
+
emActive: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.emActive,
|
|
100
|
+
emDisabled: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.emDisabled,
|
|
101
|
+
emHidden: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.emHidden,
|
|
102
|
+
codeActive: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.codeActive,
|
|
103
|
+
codeDisabled: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.codeDisabled,
|
|
104
|
+
codeHidden: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.codeHidden,
|
|
105
|
+
underlineActive: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.underlineActive,
|
|
106
|
+
underlineDisabled: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.underlineDisabled,
|
|
107
|
+
underlineHidden: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.underlineHidden,
|
|
108
|
+
strikeActive: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.strikeActive,
|
|
109
|
+
strikeDisabled: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.strikeDisabled,
|
|
110
|
+
strikeHidden: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.strikeHidden,
|
|
111
|
+
strongActive: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.strongActive,
|
|
112
|
+
strongDisabled: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.strongDisabled,
|
|
113
|
+
strongHidden: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.strongHidden,
|
|
114
|
+
superscriptActive: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.superscriptActive,
|
|
115
|
+
superscriptDisabled: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.superscriptDisabled,
|
|
116
|
+
superscriptHidden: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.superscriptHidden,
|
|
117
|
+
subscriptActive: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.subscriptActive,
|
|
118
|
+
subscriptDisabled: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.subscriptDisabled,
|
|
119
|
+
subscriptHidden: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.subscriptHidden
|
|
120
|
+
};
|
|
121
|
+
});
|
|
42
122
|
var FloatingToolbarTextFormat = function FloatingToolbarTextFormat(_ref) {
|
|
43
123
|
var api = _ref.api,
|
|
44
124
|
editorAnalyticsAPI = _ref.editorAnalyticsAPI,
|
|
45
125
|
editorView = _ref.editorView,
|
|
46
126
|
intl = _ref.intl;
|
|
47
|
-
var
|
|
48
|
-
|
|
127
|
+
var textFormattingState = useSharedState(api);
|
|
128
|
+
var formattingIsPresent = textFormattingState.formattingIsPresent,
|
|
129
|
+
formattingIconState = (0, _objectWithoutProperties2.default)(textFormattingState, _excluded);
|
|
49
130
|
var defaultIcons = (0, _formattingIcons.useFormattingIcons)({
|
|
50
131
|
schema: editorView.state.schema,
|
|
51
132
|
intl: intl,
|
|
52
133
|
isToolbarDisabled: FloatingToolbarSettings.disabled,
|
|
53
134
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
54
|
-
textFormattingState:
|
|
135
|
+
textFormattingState: formattingIconState,
|
|
55
136
|
toolbarType: FloatingToolbarSettings.toolbarType
|
|
56
137
|
});
|
|
57
138
|
var hasMultiplePartsWithFormattingSelected;
|
|
@@ -72,7 +153,8 @@ var FloatingToolbarTextFormat = function FloatingToolbarTextFormat(_ref) {
|
|
|
72
153
|
dropdownItems = _useIconList.dropdownItems,
|
|
73
154
|
singleItems = _useIconList.singleItems;
|
|
74
155
|
var clearIcon = (0, _clearFormattingIcon.useClearIcon)({
|
|
75
|
-
|
|
156
|
+
formattingPluginInitialised: textFormattingState.isInitialised,
|
|
157
|
+
formattingIsPresent: formattingIsPresent,
|
|
76
158
|
intl: intl,
|
|
77
159
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
78
160
|
toolbarType: FloatingToolbarSettings.toolbarType
|
|
@@ -7,8 +7,87 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.PrimaryToolbarComponent = PrimaryToolbarComponent;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
10
|
+
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
10
11
|
var _Toolbar = _interopRequireDefault(require("./Toolbar"));
|
|
11
12
|
var _types = require("./Toolbar/types");
|
|
13
|
+
var useSharedState = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (api) {
|
|
14
|
+
var isInitialised = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.isInitialised');
|
|
15
|
+
var formattingIsPresent = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.formattingIsPresent');
|
|
16
|
+
var emActive = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.emActive');
|
|
17
|
+
var emDisabled = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.emDisabled');
|
|
18
|
+
var emHidden = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.emHidden');
|
|
19
|
+
var codeActive = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.codeActive');
|
|
20
|
+
var codeDisabled = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.codeDisabled');
|
|
21
|
+
var codeHidden = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.codeHidden');
|
|
22
|
+
var underlineActive = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.underlineActive');
|
|
23
|
+
var underlineDisabled = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.underlineDisabled');
|
|
24
|
+
var underlineHidden = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.underlineHidden');
|
|
25
|
+
var strikeActive = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.strikeActive');
|
|
26
|
+
var strikeDisabled = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.strikeDisabled');
|
|
27
|
+
var strikeHidden = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.strikeHidden');
|
|
28
|
+
var strongActive = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.strongActive');
|
|
29
|
+
var strongDisabled = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.strongDisabled');
|
|
30
|
+
var strongHidden = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.strongHidden');
|
|
31
|
+
var superscriptActive = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.superscriptActive');
|
|
32
|
+
var superscriptDisabled = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.superscriptDisabled');
|
|
33
|
+
var superscriptHidden = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.superscriptHidden');
|
|
34
|
+
var subscriptActive = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.subscriptActive');
|
|
35
|
+
var subscriptDisabled = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.subscriptDisabled');
|
|
36
|
+
var subscriptHidden = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'textFormatting.subscriptHidden');
|
|
37
|
+
return {
|
|
38
|
+
isInitialised: Boolean(isInitialised),
|
|
39
|
+
formattingIsPresent: formattingIsPresent,
|
|
40
|
+
emActive: emActive,
|
|
41
|
+
emDisabled: emDisabled,
|
|
42
|
+
emHidden: emHidden,
|
|
43
|
+
codeActive: codeActive,
|
|
44
|
+
codeDisabled: codeDisabled,
|
|
45
|
+
codeHidden: codeHidden,
|
|
46
|
+
underlineActive: underlineActive,
|
|
47
|
+
underlineDisabled: underlineDisabled,
|
|
48
|
+
underlineHidden: underlineHidden,
|
|
49
|
+
strikeActive: strikeActive,
|
|
50
|
+
strikeDisabled: strikeDisabled,
|
|
51
|
+
strikeHidden: strikeHidden,
|
|
52
|
+
strongActive: strongActive,
|
|
53
|
+
strongDisabled: strongDisabled,
|
|
54
|
+
strongHidden: strongHidden,
|
|
55
|
+
superscriptActive: superscriptActive,
|
|
56
|
+
superscriptDisabled: superscriptDisabled,
|
|
57
|
+
superscriptHidden: superscriptHidden,
|
|
58
|
+
subscriptActive: subscriptActive,
|
|
59
|
+
subscriptDisabled: subscriptDisabled,
|
|
60
|
+
subscriptHidden: subscriptHidden
|
|
61
|
+
};
|
|
62
|
+
}, function (api) {
|
|
63
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['textFormatting']),
|
|
64
|
+
textFormattingState = _useSharedPluginState.textFormattingState;
|
|
65
|
+
return {
|
|
66
|
+
isInitialised: Boolean(textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.isInitialised),
|
|
67
|
+
formattingIsPresent: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.formattingIsPresent,
|
|
68
|
+
emActive: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.emActive,
|
|
69
|
+
emDisabled: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.emDisabled,
|
|
70
|
+
emHidden: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.emHidden,
|
|
71
|
+
codeActive: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.codeActive,
|
|
72
|
+
codeDisabled: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.codeDisabled,
|
|
73
|
+
codeHidden: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.codeHidden,
|
|
74
|
+
underlineActive: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.underlineActive,
|
|
75
|
+
underlineDisabled: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.underlineDisabled,
|
|
76
|
+
underlineHidden: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.underlineHidden,
|
|
77
|
+
strikeActive: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.strikeActive,
|
|
78
|
+
strikeDisabled: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.strikeDisabled,
|
|
79
|
+
strikeHidden: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.strikeHidden,
|
|
80
|
+
strongActive: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.strongActive,
|
|
81
|
+
strongDisabled: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.strongDisabled,
|
|
82
|
+
strongHidden: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.strongHidden,
|
|
83
|
+
superscriptActive: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.superscriptActive,
|
|
84
|
+
superscriptDisabled: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.superscriptDisabled,
|
|
85
|
+
superscriptHidden: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.superscriptHidden,
|
|
86
|
+
subscriptActive: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.subscriptActive,
|
|
87
|
+
subscriptDisabled: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.subscriptDisabled,
|
|
88
|
+
subscriptHidden: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.subscriptHidden
|
|
89
|
+
};
|
|
90
|
+
});
|
|
12
91
|
function PrimaryToolbarComponent(_ref) {
|
|
13
92
|
var _api$analytics;
|
|
14
93
|
var api = _ref.api,
|
|
@@ -19,8 +98,7 @@ function PrimaryToolbarComponent(_ref) {
|
|
|
19
98
|
disabled = _ref.disabled,
|
|
20
99
|
isReducedSpacing = _ref.isReducedSpacing,
|
|
21
100
|
shouldUseResponsiveToolbar = _ref.shouldUseResponsiveToolbar;
|
|
22
|
-
var
|
|
23
|
-
textFormattingState = _useSharedPluginState.textFormattingState;
|
|
101
|
+
var textFormattingState = useSharedState(api);
|
|
24
102
|
return /*#__PURE__*/_react.default.createElement(_Toolbar.default, {
|
|
25
103
|
textFormattingState: textFormattingState,
|
|
26
104
|
popupsMountPoint: popupsMountPoint,
|
|
@@ -23,11 +23,12 @@ var _inputMethodUtils = require("../input-method-utils");
|
|
|
23
23
|
|
|
24
24
|
var useClearIcon = exports.useClearIcon = function useClearIcon(_ref) {
|
|
25
25
|
var intl = _ref.intl,
|
|
26
|
-
|
|
26
|
+
formattingPluginInitialised = _ref.formattingPluginInitialised,
|
|
27
|
+
formattingPresent = _ref.formattingIsPresent,
|
|
27
28
|
editorAnalyticsAPI = _ref.editorAnalyticsAPI,
|
|
28
29
|
toolbarType = _ref.toolbarType;
|
|
29
|
-
var isPluginAvailable = Boolean(
|
|
30
|
-
var formattingIsPresent = Boolean(
|
|
30
|
+
var isPluginAvailable = Boolean(formattingPluginInitialised);
|
|
31
|
+
var formattingIsPresent = Boolean(formattingPresent);
|
|
31
32
|
var clearFormattingLabel = intl.formatMessage(_messages.toolbarMessages.clearFormatting);
|
|
32
33
|
var clearFormattingToolbar = (0, _react.useCallback)(function (state, dispatch) {
|
|
33
34
|
return (0, _clearFormatting.clearFormattingWithAnalytics)((0, _inputMethodUtils.getInputMethod)(toolbarType), editorAnalyticsAPI)(state, dispatch);
|
|
@@ -176,7 +176,7 @@ var buildMenuIconState = function buildMenuIconState(iconMark) {
|
|
|
176
176
|
return function (_ref2) {
|
|
177
177
|
var schema = _ref2.schema,
|
|
178
178
|
textFormattingState = _ref2.textFormattingState;
|
|
179
|
-
var hasPluginState = Boolean(
|
|
179
|
+
var hasPluginState = Boolean(textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.isInitialised);
|
|
180
180
|
var markSchema = IconsMarkSchema[iconMark];
|
|
181
181
|
var hasSchemaMark = Boolean(schema.marks[markSchema]);
|
|
182
182
|
if (!hasPluginState) {
|
|
@@ -266,7 +266,7 @@ var useHasFormattingActived = exports.useHasFormattingActived = function useHasF
|
|
|
266
266
|
var iconTypeList = _ref5.iconTypeList,
|
|
267
267
|
textFormattingState = _ref5.textFormattingState;
|
|
268
268
|
var hasActiveFormatting = (0, _react.useMemo)(function () {
|
|
269
|
-
if (!textFormattingState) {
|
|
269
|
+
if (!(textFormattingState !== null && textFormattingState !== void 0 && textFormattingState.isInitialised)) {
|
|
270
270
|
return false;
|
|
271
271
|
}
|
|
272
272
|
return iconTypeList.some(function (iconType) {
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
9
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
11
|
var _react = require("react");
|
|
11
12
|
var _react2 = require("@emotion/react");
|
|
@@ -23,13 +24,12 @@ var _formattingIcons = require("./hooks/formatting-icons");
|
|
|
23
24
|
var _responsiveToolbarButtons = require("./hooks/responsive-toolbar-buttons");
|
|
24
25
|
var _moreButton = require("./more-button");
|
|
25
26
|
var _singleToolbarButtons = require("./single-toolbar-buttons");
|
|
27
|
+
var _excluded = ["formattingIsPresent"];
|
|
26
28
|
/**
|
|
27
29
|
* @jsxRuntime classic
|
|
28
30
|
* @jsx jsx
|
|
29
31
|
*/
|
|
30
|
-
|
|
31
32
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
32
|
-
|
|
33
33
|
var ToolbarFormatting = function ToolbarFormatting(_ref) {
|
|
34
34
|
var _usePreviousState;
|
|
35
35
|
var shouldUseResponsiveToolbar = _ref.shouldUseResponsiveToolbar,
|
|
@@ -49,16 +49,19 @@ var ToolbarFormatting = function ToolbarFormatting(_ref) {
|
|
|
49
49
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
50
50
|
message = _useState2[0],
|
|
51
51
|
setMessage = _useState2[1];
|
|
52
|
+
var formattingIsPresent = textFormattingState.formattingIsPresent,
|
|
53
|
+
formattingIconState = (0, _objectWithoutProperties2.default)(textFormattingState, _excluded);
|
|
52
54
|
var defaultIcons = (0, _formattingIcons.useFormattingIcons)({
|
|
53
55
|
schema: editorView.state.schema,
|
|
54
56
|
intl: intl,
|
|
55
57
|
isToolbarDisabled: isToolbarDisabled,
|
|
56
58
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
57
|
-
textFormattingState:
|
|
59
|
+
textFormattingState: formattingIconState,
|
|
58
60
|
toolbarType: toolbarType
|
|
59
61
|
});
|
|
60
62
|
var clearIcon = (0, _clearFormattingIcon.useClearIcon)({
|
|
61
|
-
|
|
63
|
+
formattingPluginInitialised: textFormattingState.isInitialised,
|
|
64
|
+
formattingIsPresent: formattingIsPresent,
|
|
62
65
|
intl: intl,
|
|
63
66
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
64
67
|
toolbarType: toolbarType
|
|
@@ -39,7 +39,9 @@ const getTextFormattingState = (editorState, editorAnalyticsAPI) => {
|
|
|
39
39
|
subsup,
|
|
40
40
|
underline
|
|
41
41
|
} = editorState.schema.marks;
|
|
42
|
-
const state = {
|
|
42
|
+
const state = {
|
|
43
|
+
isInitialised: true
|
|
44
|
+
};
|
|
43
45
|
if (code) {
|
|
44
46
|
state.codeActive = anyMarkActive(editorState, code.create());
|
|
45
47
|
state.codeDisabled = !checkNodeSelection(code, editorState);
|
|
@@ -120,9 +120,11 @@ export const textFormattingPlugin = ({
|
|
|
120
120
|
if (!editorState) {
|
|
121
121
|
return undefined;
|
|
122
122
|
}
|
|
123
|
+
const textFormattingState = textFormattingPluginKey.getState(editorState);
|
|
123
124
|
return {
|
|
124
|
-
...
|
|
125
|
-
formattingIsPresent: (_clearFormattingPlugi = clearFormattingPluginKey.getState(editorState)) === null || _clearFormattingPlugi === void 0 ? void 0 : _clearFormattingPlugi.formattingIsPresent
|
|
125
|
+
...textFormattingState,
|
|
126
|
+
formattingIsPresent: (_clearFormattingPlugi = clearFormattingPluginKey.getState(editorState)) === null || _clearFormattingPlugi === void 0 ? void 0 : _clearFormattingPlugi.formattingIsPresent,
|
|
127
|
+
isInitialised: !!(textFormattingState !== null && textFormattingState !== void 0 && textFormattingState.isInitialised)
|
|
126
128
|
};
|
|
127
129
|
},
|
|
128
130
|
pluginsOptions: {
|
|
@@ -7,8 +7,9 @@ import React, { useMemo } from 'react';
|
|
|
7
7
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
8
8
|
import { jsx } from '@emotion/react';
|
|
9
9
|
import { injectIntl } from 'react-intl-next';
|
|
10
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
10
|
+
import { useSharedPluginState, sharedPluginStateHookMigratorFactory } from '@atlaskit/editor-common/hooks';
|
|
11
11
|
import { ToolbarSize } from '@atlaskit/editor-common/types';
|
|
12
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
12
13
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
13
14
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
14
15
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
@@ -29,21 +30,102 @@ const FloatingToolbarSettings = {
|
|
|
29
30
|
moreButtonLabel: '',
|
|
30
31
|
toolbarType: ToolbarType.FLOATING
|
|
31
32
|
};
|
|
33
|
+
const useSharedState = sharedPluginStateHookMigratorFactory(api => {
|
|
34
|
+
const isInitialised = useSharedPluginStateSelector(api, 'textFormatting.isInitialised');
|
|
35
|
+
const formattingIsPresent = useSharedPluginStateSelector(api, 'textFormatting.formattingIsPresent');
|
|
36
|
+
const emActive = useSharedPluginStateSelector(api, 'textFormatting.emActive');
|
|
37
|
+
const emDisabled = useSharedPluginStateSelector(api, 'textFormatting.emDisabled');
|
|
38
|
+
const emHidden = useSharedPluginStateSelector(api, 'textFormatting.emHidden');
|
|
39
|
+
const codeActive = useSharedPluginStateSelector(api, 'textFormatting.codeActive');
|
|
40
|
+
const codeDisabled = useSharedPluginStateSelector(api, 'textFormatting.codeDisabled');
|
|
41
|
+
const codeHidden = useSharedPluginStateSelector(api, 'textFormatting.codeHidden');
|
|
42
|
+
const underlineActive = useSharedPluginStateSelector(api, 'textFormatting.underlineActive');
|
|
43
|
+
const underlineDisabled = useSharedPluginStateSelector(api, 'textFormatting.underlineDisabled');
|
|
44
|
+
const underlineHidden = useSharedPluginStateSelector(api, 'textFormatting.underlineHidden');
|
|
45
|
+
const strikeActive = useSharedPluginStateSelector(api, 'textFormatting.strikeActive');
|
|
46
|
+
const strikeDisabled = useSharedPluginStateSelector(api, 'textFormatting.strikeDisabled');
|
|
47
|
+
const strikeHidden = useSharedPluginStateSelector(api, 'textFormatting.strikeHidden');
|
|
48
|
+
const strongActive = useSharedPluginStateSelector(api, 'textFormatting.strongActive');
|
|
49
|
+
const strongDisabled = useSharedPluginStateSelector(api, 'textFormatting.strongDisabled');
|
|
50
|
+
const strongHidden = useSharedPluginStateSelector(api, 'textFormatting.strongHidden');
|
|
51
|
+
const superscriptActive = useSharedPluginStateSelector(api, 'textFormatting.superscriptActive');
|
|
52
|
+
const superscriptDisabled = useSharedPluginStateSelector(api, 'textFormatting.superscriptDisabled');
|
|
53
|
+
const superscriptHidden = useSharedPluginStateSelector(api, 'textFormatting.superscriptHidden');
|
|
54
|
+
const subscriptActive = useSharedPluginStateSelector(api, 'textFormatting.subscriptActive');
|
|
55
|
+
const subscriptDisabled = useSharedPluginStateSelector(api, 'textFormatting.subscriptDisabled');
|
|
56
|
+
const subscriptHidden = useSharedPluginStateSelector(api, 'textFormatting.subscriptHidden');
|
|
57
|
+
return {
|
|
58
|
+
isInitialised: Boolean(isInitialised),
|
|
59
|
+
formattingIsPresent,
|
|
60
|
+
emActive,
|
|
61
|
+
emDisabled,
|
|
62
|
+
emHidden,
|
|
63
|
+
codeActive,
|
|
64
|
+
codeDisabled,
|
|
65
|
+
codeHidden,
|
|
66
|
+
underlineActive,
|
|
67
|
+
underlineDisabled,
|
|
68
|
+
underlineHidden,
|
|
69
|
+
strikeActive,
|
|
70
|
+
strikeDisabled,
|
|
71
|
+
strikeHidden,
|
|
72
|
+
strongActive,
|
|
73
|
+
strongDisabled,
|
|
74
|
+
strongHidden,
|
|
75
|
+
superscriptActive,
|
|
76
|
+
superscriptDisabled,
|
|
77
|
+
superscriptHidden,
|
|
78
|
+
subscriptActive,
|
|
79
|
+
subscriptDisabled,
|
|
80
|
+
subscriptHidden
|
|
81
|
+
};
|
|
82
|
+
}, api => {
|
|
83
|
+
const {
|
|
84
|
+
textFormattingState
|
|
85
|
+
} = useSharedPluginState(api, ['textFormatting']);
|
|
86
|
+
return {
|
|
87
|
+
isInitialised: Boolean(textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.isInitialised),
|
|
88
|
+
formattingIsPresent: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.formattingIsPresent,
|
|
89
|
+
emActive: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.emActive,
|
|
90
|
+
emDisabled: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.emDisabled,
|
|
91
|
+
emHidden: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.emHidden,
|
|
92
|
+
codeActive: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.codeActive,
|
|
93
|
+
codeDisabled: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.codeDisabled,
|
|
94
|
+
codeHidden: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.codeHidden,
|
|
95
|
+
underlineActive: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.underlineActive,
|
|
96
|
+
underlineDisabled: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.underlineDisabled,
|
|
97
|
+
underlineHidden: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.underlineHidden,
|
|
98
|
+
strikeActive: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.strikeActive,
|
|
99
|
+
strikeDisabled: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.strikeDisabled,
|
|
100
|
+
strikeHidden: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.strikeHidden,
|
|
101
|
+
strongActive: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.strongActive,
|
|
102
|
+
strongDisabled: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.strongDisabled,
|
|
103
|
+
strongHidden: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.strongHidden,
|
|
104
|
+
superscriptActive: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.superscriptActive,
|
|
105
|
+
superscriptDisabled: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.superscriptDisabled,
|
|
106
|
+
superscriptHidden: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.superscriptHidden,
|
|
107
|
+
subscriptActive: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.subscriptActive,
|
|
108
|
+
subscriptDisabled: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.subscriptDisabled,
|
|
109
|
+
subscriptHidden: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.subscriptHidden
|
|
110
|
+
};
|
|
111
|
+
});
|
|
32
112
|
const FloatingToolbarTextFormat = ({
|
|
33
113
|
api,
|
|
34
114
|
editorAnalyticsAPI,
|
|
35
115
|
editorView,
|
|
36
116
|
intl
|
|
37
117
|
}) => {
|
|
118
|
+
const textFormattingState = useSharedState(api);
|
|
38
119
|
const {
|
|
39
|
-
|
|
40
|
-
|
|
120
|
+
formattingIsPresent,
|
|
121
|
+
...formattingIconState
|
|
122
|
+
} = textFormattingState;
|
|
41
123
|
const defaultIcons = useFormattingIcons({
|
|
42
124
|
schema: editorView.state.schema,
|
|
43
125
|
intl,
|
|
44
126
|
isToolbarDisabled: FloatingToolbarSettings.disabled,
|
|
45
127
|
editorAnalyticsAPI,
|
|
46
|
-
textFormattingState,
|
|
128
|
+
textFormattingState: formattingIconState,
|
|
47
129
|
toolbarType: FloatingToolbarSettings.toolbarType
|
|
48
130
|
});
|
|
49
131
|
let hasMultiplePartsWithFormattingSelected;
|
|
@@ -69,7 +151,8 @@ const FloatingToolbarTextFormat = ({
|
|
|
69
151
|
shouldUnselect: hasMultiplePartsWithFormattingSelected
|
|
70
152
|
});
|
|
71
153
|
const clearIcon = useClearIcon({
|
|
72
|
-
textFormattingState,
|
|
154
|
+
formattingPluginInitialised: textFormattingState.isInitialised,
|
|
155
|
+
formattingIsPresent,
|
|
73
156
|
intl,
|
|
74
157
|
editorAnalyticsAPI,
|
|
75
158
|
toolbarType: FloatingToolbarSettings.toolbarType
|
|
@@ -1,7 +1,87 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
2
|
+
import { useSharedPluginState, sharedPluginStateHookMigratorFactory } from '@atlaskit/editor-common/hooks';
|
|
3
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
3
4
|
import Toolbar from './Toolbar';
|
|
4
5
|
import { ToolbarType } from './Toolbar/types';
|
|
6
|
+
const useSharedState = sharedPluginStateHookMigratorFactory(api => {
|
|
7
|
+
const isInitialised = useSharedPluginStateSelector(api, 'textFormatting.isInitialised');
|
|
8
|
+
const formattingIsPresent = useSharedPluginStateSelector(api, 'textFormatting.formattingIsPresent');
|
|
9
|
+
const emActive = useSharedPluginStateSelector(api, 'textFormatting.emActive');
|
|
10
|
+
const emDisabled = useSharedPluginStateSelector(api, 'textFormatting.emDisabled');
|
|
11
|
+
const emHidden = useSharedPluginStateSelector(api, 'textFormatting.emHidden');
|
|
12
|
+
const codeActive = useSharedPluginStateSelector(api, 'textFormatting.codeActive');
|
|
13
|
+
const codeDisabled = useSharedPluginStateSelector(api, 'textFormatting.codeDisabled');
|
|
14
|
+
const codeHidden = useSharedPluginStateSelector(api, 'textFormatting.codeHidden');
|
|
15
|
+
const underlineActive = useSharedPluginStateSelector(api, 'textFormatting.underlineActive');
|
|
16
|
+
const underlineDisabled = useSharedPluginStateSelector(api, 'textFormatting.underlineDisabled');
|
|
17
|
+
const underlineHidden = useSharedPluginStateSelector(api, 'textFormatting.underlineHidden');
|
|
18
|
+
const strikeActive = useSharedPluginStateSelector(api, 'textFormatting.strikeActive');
|
|
19
|
+
const strikeDisabled = useSharedPluginStateSelector(api, 'textFormatting.strikeDisabled');
|
|
20
|
+
const strikeHidden = useSharedPluginStateSelector(api, 'textFormatting.strikeHidden');
|
|
21
|
+
const strongActive = useSharedPluginStateSelector(api, 'textFormatting.strongActive');
|
|
22
|
+
const strongDisabled = useSharedPluginStateSelector(api, 'textFormatting.strongDisabled');
|
|
23
|
+
const strongHidden = useSharedPluginStateSelector(api, 'textFormatting.strongHidden');
|
|
24
|
+
const superscriptActive = useSharedPluginStateSelector(api, 'textFormatting.superscriptActive');
|
|
25
|
+
const superscriptDisabled = useSharedPluginStateSelector(api, 'textFormatting.superscriptDisabled');
|
|
26
|
+
const superscriptHidden = useSharedPluginStateSelector(api, 'textFormatting.superscriptHidden');
|
|
27
|
+
const subscriptActive = useSharedPluginStateSelector(api, 'textFormatting.subscriptActive');
|
|
28
|
+
const subscriptDisabled = useSharedPluginStateSelector(api, 'textFormatting.subscriptDisabled');
|
|
29
|
+
const subscriptHidden = useSharedPluginStateSelector(api, 'textFormatting.subscriptHidden');
|
|
30
|
+
return {
|
|
31
|
+
isInitialised: Boolean(isInitialised),
|
|
32
|
+
formattingIsPresent,
|
|
33
|
+
emActive,
|
|
34
|
+
emDisabled,
|
|
35
|
+
emHidden,
|
|
36
|
+
codeActive,
|
|
37
|
+
codeDisabled,
|
|
38
|
+
codeHidden,
|
|
39
|
+
underlineActive,
|
|
40
|
+
underlineDisabled,
|
|
41
|
+
underlineHidden,
|
|
42
|
+
strikeActive,
|
|
43
|
+
strikeDisabled,
|
|
44
|
+
strikeHidden,
|
|
45
|
+
strongActive,
|
|
46
|
+
strongDisabled,
|
|
47
|
+
strongHidden,
|
|
48
|
+
superscriptActive,
|
|
49
|
+
superscriptDisabled,
|
|
50
|
+
superscriptHidden,
|
|
51
|
+
subscriptActive,
|
|
52
|
+
subscriptDisabled,
|
|
53
|
+
subscriptHidden
|
|
54
|
+
};
|
|
55
|
+
}, api => {
|
|
56
|
+
const {
|
|
57
|
+
textFormattingState
|
|
58
|
+
} = useSharedPluginState(api, ['textFormatting']);
|
|
59
|
+
return {
|
|
60
|
+
isInitialised: Boolean(textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.isInitialised),
|
|
61
|
+
formattingIsPresent: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.formattingIsPresent,
|
|
62
|
+
emActive: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.emActive,
|
|
63
|
+
emDisabled: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.emDisabled,
|
|
64
|
+
emHidden: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.emHidden,
|
|
65
|
+
codeActive: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.codeActive,
|
|
66
|
+
codeDisabled: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.codeDisabled,
|
|
67
|
+
codeHidden: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.codeHidden,
|
|
68
|
+
underlineActive: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.underlineActive,
|
|
69
|
+
underlineDisabled: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.underlineDisabled,
|
|
70
|
+
underlineHidden: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.underlineHidden,
|
|
71
|
+
strikeActive: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.strikeActive,
|
|
72
|
+
strikeDisabled: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.strikeDisabled,
|
|
73
|
+
strikeHidden: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.strikeHidden,
|
|
74
|
+
strongActive: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.strongActive,
|
|
75
|
+
strongDisabled: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.strongDisabled,
|
|
76
|
+
strongHidden: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.strongHidden,
|
|
77
|
+
superscriptActive: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.superscriptActive,
|
|
78
|
+
superscriptDisabled: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.superscriptDisabled,
|
|
79
|
+
superscriptHidden: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.superscriptHidden,
|
|
80
|
+
subscriptActive: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.subscriptActive,
|
|
81
|
+
subscriptDisabled: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.subscriptDisabled,
|
|
82
|
+
subscriptHidden: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.subscriptHidden
|
|
83
|
+
};
|
|
84
|
+
});
|
|
5
85
|
export function PrimaryToolbarComponent({
|
|
6
86
|
api,
|
|
7
87
|
popupsMountPoint,
|
|
@@ -13,9 +93,7 @@ export function PrimaryToolbarComponent({
|
|
|
13
93
|
shouldUseResponsiveToolbar
|
|
14
94
|
}) {
|
|
15
95
|
var _api$analytics;
|
|
16
|
-
const
|
|
17
|
-
textFormattingState
|
|
18
|
-
} = useSharedPluginState(api, ['textFormatting']);
|
|
96
|
+
const textFormattingState = useSharedState(api);
|
|
19
97
|
return /*#__PURE__*/React.createElement(Toolbar, {
|
|
20
98
|
textFormattingState: textFormattingState,
|
|
21
99
|
popupsMountPoint: popupsMountPoint,
|
|
@@ -15,12 +15,13 @@ import { clearFormattingWithAnalytics } from '../../../editor-commands/clear-for
|
|
|
15
15
|
import { getInputMethod } from '../input-method-utils';
|
|
16
16
|
export const useClearIcon = ({
|
|
17
17
|
intl,
|
|
18
|
-
|
|
18
|
+
formattingPluginInitialised,
|
|
19
|
+
formattingIsPresent: formattingPresent,
|
|
19
20
|
editorAnalyticsAPI,
|
|
20
21
|
toolbarType
|
|
21
22
|
}) => {
|
|
22
|
-
const isPluginAvailable = Boolean(
|
|
23
|
-
const formattingIsPresent = Boolean(
|
|
23
|
+
const isPluginAvailable = Boolean(formattingPluginInitialised);
|
|
24
|
+
const formattingIsPresent = Boolean(formattingPresent);
|
|
24
25
|
const clearFormattingLabel = intl.formatMessage(toolbarMessages.clearFormatting);
|
|
25
26
|
const clearFormattingToolbar = useCallback((state, dispatch) => clearFormattingWithAnalytics(getInputMethod(toolbarType), editorAnalyticsAPI)(state, dispatch), [editorAnalyticsAPI, toolbarType]);
|
|
26
27
|
return useMemo(() => {
|
|
@@ -168,7 +168,7 @@ const buildMenuIconState = iconMark => ({
|
|
|
168
168
|
schema,
|
|
169
169
|
textFormattingState
|
|
170
170
|
}) => {
|
|
171
|
-
const hasPluginState = Boolean(
|
|
171
|
+
const hasPluginState = Boolean(textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.isInitialised);
|
|
172
172
|
const markSchema = IconsMarkSchema[iconMark];
|
|
173
173
|
const hasSchemaMark = Boolean(schema.marks[markSchema]);
|
|
174
174
|
if (!hasPluginState) {
|
|
@@ -256,7 +256,7 @@ export const useHasFormattingActived = ({
|
|
|
256
256
|
textFormattingState
|
|
257
257
|
}) => {
|
|
258
258
|
const hasActiveFormatting = useMemo(() => {
|
|
259
|
-
if (!textFormattingState) {
|
|
259
|
+
if (!(textFormattingState !== null && textFormattingState !== void 0 && textFormattingState.isInitialised)) {
|
|
260
260
|
return false;
|
|
261
261
|
}
|
|
262
262
|
return iconTypeList.some(iconType => textFormattingState[`${iconType}Active`]);
|
|
@@ -37,16 +37,21 @@ const ToolbarFormatting = ({
|
|
|
37
37
|
}) => {
|
|
38
38
|
var _usePreviousState;
|
|
39
39
|
const [message, setMessage] = useState('');
|
|
40
|
+
const {
|
|
41
|
+
formattingIsPresent,
|
|
42
|
+
...formattingIconState
|
|
43
|
+
} = textFormattingState;
|
|
40
44
|
const defaultIcons = useFormattingIcons({
|
|
41
45
|
schema: editorView.state.schema,
|
|
42
46
|
intl,
|
|
43
47
|
isToolbarDisabled,
|
|
44
48
|
editorAnalyticsAPI,
|
|
45
|
-
textFormattingState,
|
|
49
|
+
textFormattingState: formattingIconState,
|
|
46
50
|
toolbarType
|
|
47
51
|
});
|
|
48
52
|
const clearIcon = useClearIcon({
|
|
49
|
-
textFormattingState,
|
|
53
|
+
formattingPluginInitialised: textFormattingState.isInitialised,
|
|
54
|
+
formattingIsPresent,
|
|
50
55
|
intl,
|
|
51
56
|
editorAnalyticsAPI,
|
|
52
57
|
toolbarType
|
|
@@ -38,7 +38,9 @@ var getTextFormattingState = function getTextFormattingState(editorState, editor
|
|
|
38
38
|
strong = _editorState$schema$m.strong,
|
|
39
39
|
subsup = _editorState$schema$m.subsup,
|
|
40
40
|
underline = _editorState$schema$m.underline;
|
|
41
|
-
var state = {
|
|
41
|
+
var state = {
|
|
42
|
+
isInitialised: true
|
|
43
|
+
};
|
|
42
44
|
if (code) {
|
|
43
45
|
state.codeActive = anyMarkActive(editorState, code.create());
|
|
44
46
|
state.codeDisabled = !checkNodeSelection(code, editorState);
|
|
@@ -121,8 +121,10 @@ export var textFormattingPlugin = function textFormattingPlugin(_ref) {
|
|
|
121
121
|
if (!editorState) {
|
|
122
122
|
return undefined;
|
|
123
123
|
}
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
var textFormattingState = textFormattingPluginKey.getState(editorState);
|
|
125
|
+
return _objectSpread(_objectSpread({}, textFormattingState), {}, {
|
|
126
|
+
formattingIsPresent: (_clearFormattingPlugi = clearFormattingPluginKey.getState(editorState)) === null || _clearFormattingPlugi === void 0 ? void 0 : _clearFormattingPlugi.formattingIsPresent,
|
|
127
|
+
isInitialised: !!(textFormattingState !== null && textFormattingState !== void 0 && textFormattingState.isInitialised)
|
|
126
128
|
});
|
|
127
129
|
},
|
|
128
130
|
pluginsOptions: {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
|
+
var _excluded = ["formattingIsPresent"];
|
|
1
3
|
/**
|
|
2
4
|
* @jsxRuntime classic
|
|
3
5
|
* @jsx jsx
|
|
@@ -7,8 +9,9 @@ import React, { useMemo } from 'react';
|
|
|
7
9
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
8
10
|
import { jsx } from '@emotion/react';
|
|
9
11
|
import { injectIntl } from 'react-intl-next';
|
|
10
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
12
|
+
import { useSharedPluginState, sharedPluginStateHookMigratorFactory } from '@atlaskit/editor-common/hooks';
|
|
11
13
|
import { ToolbarSize } from '@atlaskit/editor-common/types';
|
|
14
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
12
15
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
13
16
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
14
17
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
@@ -29,19 +32,98 @@ var FloatingToolbarSettings = {
|
|
|
29
32
|
moreButtonLabel: '',
|
|
30
33
|
toolbarType: ToolbarType.FLOATING
|
|
31
34
|
};
|
|
35
|
+
var useSharedState = sharedPluginStateHookMigratorFactory(function (api) {
|
|
36
|
+
var isInitialised = useSharedPluginStateSelector(api, 'textFormatting.isInitialised');
|
|
37
|
+
var formattingIsPresent = useSharedPluginStateSelector(api, 'textFormatting.formattingIsPresent');
|
|
38
|
+
var emActive = useSharedPluginStateSelector(api, 'textFormatting.emActive');
|
|
39
|
+
var emDisabled = useSharedPluginStateSelector(api, 'textFormatting.emDisabled');
|
|
40
|
+
var emHidden = useSharedPluginStateSelector(api, 'textFormatting.emHidden');
|
|
41
|
+
var codeActive = useSharedPluginStateSelector(api, 'textFormatting.codeActive');
|
|
42
|
+
var codeDisabled = useSharedPluginStateSelector(api, 'textFormatting.codeDisabled');
|
|
43
|
+
var codeHidden = useSharedPluginStateSelector(api, 'textFormatting.codeHidden');
|
|
44
|
+
var underlineActive = useSharedPluginStateSelector(api, 'textFormatting.underlineActive');
|
|
45
|
+
var underlineDisabled = useSharedPluginStateSelector(api, 'textFormatting.underlineDisabled');
|
|
46
|
+
var underlineHidden = useSharedPluginStateSelector(api, 'textFormatting.underlineHidden');
|
|
47
|
+
var strikeActive = useSharedPluginStateSelector(api, 'textFormatting.strikeActive');
|
|
48
|
+
var strikeDisabled = useSharedPluginStateSelector(api, 'textFormatting.strikeDisabled');
|
|
49
|
+
var strikeHidden = useSharedPluginStateSelector(api, 'textFormatting.strikeHidden');
|
|
50
|
+
var strongActive = useSharedPluginStateSelector(api, 'textFormatting.strongActive');
|
|
51
|
+
var strongDisabled = useSharedPluginStateSelector(api, 'textFormatting.strongDisabled');
|
|
52
|
+
var strongHidden = useSharedPluginStateSelector(api, 'textFormatting.strongHidden');
|
|
53
|
+
var superscriptActive = useSharedPluginStateSelector(api, 'textFormatting.superscriptActive');
|
|
54
|
+
var superscriptDisabled = useSharedPluginStateSelector(api, 'textFormatting.superscriptDisabled');
|
|
55
|
+
var superscriptHidden = useSharedPluginStateSelector(api, 'textFormatting.superscriptHidden');
|
|
56
|
+
var subscriptActive = useSharedPluginStateSelector(api, 'textFormatting.subscriptActive');
|
|
57
|
+
var subscriptDisabled = useSharedPluginStateSelector(api, 'textFormatting.subscriptDisabled');
|
|
58
|
+
var subscriptHidden = useSharedPluginStateSelector(api, 'textFormatting.subscriptHidden');
|
|
59
|
+
return {
|
|
60
|
+
isInitialised: Boolean(isInitialised),
|
|
61
|
+
formattingIsPresent: formattingIsPresent,
|
|
62
|
+
emActive: emActive,
|
|
63
|
+
emDisabled: emDisabled,
|
|
64
|
+
emHidden: emHidden,
|
|
65
|
+
codeActive: codeActive,
|
|
66
|
+
codeDisabled: codeDisabled,
|
|
67
|
+
codeHidden: codeHidden,
|
|
68
|
+
underlineActive: underlineActive,
|
|
69
|
+
underlineDisabled: underlineDisabled,
|
|
70
|
+
underlineHidden: underlineHidden,
|
|
71
|
+
strikeActive: strikeActive,
|
|
72
|
+
strikeDisabled: strikeDisabled,
|
|
73
|
+
strikeHidden: strikeHidden,
|
|
74
|
+
strongActive: strongActive,
|
|
75
|
+
strongDisabled: strongDisabled,
|
|
76
|
+
strongHidden: strongHidden,
|
|
77
|
+
superscriptActive: superscriptActive,
|
|
78
|
+
superscriptDisabled: superscriptDisabled,
|
|
79
|
+
superscriptHidden: superscriptHidden,
|
|
80
|
+
subscriptActive: subscriptActive,
|
|
81
|
+
subscriptDisabled: subscriptDisabled,
|
|
82
|
+
subscriptHidden: subscriptHidden
|
|
83
|
+
};
|
|
84
|
+
}, function (api) {
|
|
85
|
+
var _useSharedPluginState = useSharedPluginState(api, ['textFormatting']),
|
|
86
|
+
textFormattingState = _useSharedPluginState.textFormattingState;
|
|
87
|
+
return {
|
|
88
|
+
isInitialised: Boolean(textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.isInitialised),
|
|
89
|
+
formattingIsPresent: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.formattingIsPresent,
|
|
90
|
+
emActive: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.emActive,
|
|
91
|
+
emDisabled: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.emDisabled,
|
|
92
|
+
emHidden: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.emHidden,
|
|
93
|
+
codeActive: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.codeActive,
|
|
94
|
+
codeDisabled: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.codeDisabled,
|
|
95
|
+
codeHidden: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.codeHidden,
|
|
96
|
+
underlineActive: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.underlineActive,
|
|
97
|
+
underlineDisabled: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.underlineDisabled,
|
|
98
|
+
underlineHidden: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.underlineHidden,
|
|
99
|
+
strikeActive: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.strikeActive,
|
|
100
|
+
strikeDisabled: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.strikeDisabled,
|
|
101
|
+
strikeHidden: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.strikeHidden,
|
|
102
|
+
strongActive: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.strongActive,
|
|
103
|
+
strongDisabled: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.strongDisabled,
|
|
104
|
+
strongHidden: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.strongHidden,
|
|
105
|
+
superscriptActive: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.superscriptActive,
|
|
106
|
+
superscriptDisabled: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.superscriptDisabled,
|
|
107
|
+
superscriptHidden: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.superscriptHidden,
|
|
108
|
+
subscriptActive: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.subscriptActive,
|
|
109
|
+
subscriptDisabled: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.subscriptDisabled,
|
|
110
|
+
subscriptHidden: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.subscriptHidden
|
|
111
|
+
};
|
|
112
|
+
});
|
|
32
113
|
var FloatingToolbarTextFormat = function FloatingToolbarTextFormat(_ref) {
|
|
33
114
|
var api = _ref.api,
|
|
34
115
|
editorAnalyticsAPI = _ref.editorAnalyticsAPI,
|
|
35
116
|
editorView = _ref.editorView,
|
|
36
117
|
intl = _ref.intl;
|
|
37
|
-
var
|
|
38
|
-
|
|
118
|
+
var textFormattingState = useSharedState(api);
|
|
119
|
+
var formattingIsPresent = textFormattingState.formattingIsPresent,
|
|
120
|
+
formattingIconState = _objectWithoutProperties(textFormattingState, _excluded);
|
|
39
121
|
var defaultIcons = useFormattingIcons({
|
|
40
122
|
schema: editorView.state.schema,
|
|
41
123
|
intl: intl,
|
|
42
124
|
isToolbarDisabled: FloatingToolbarSettings.disabled,
|
|
43
125
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
44
|
-
textFormattingState:
|
|
126
|
+
textFormattingState: formattingIconState,
|
|
45
127
|
toolbarType: FloatingToolbarSettings.toolbarType
|
|
46
128
|
});
|
|
47
129
|
var hasMultiplePartsWithFormattingSelected;
|
|
@@ -62,7 +144,8 @@ var FloatingToolbarTextFormat = function FloatingToolbarTextFormat(_ref) {
|
|
|
62
144
|
dropdownItems = _useIconList.dropdownItems,
|
|
63
145
|
singleItems = _useIconList.singleItems;
|
|
64
146
|
var clearIcon = useClearIcon({
|
|
65
|
-
|
|
147
|
+
formattingPluginInitialised: textFormattingState.isInitialised,
|
|
148
|
+
formattingIsPresent: formattingIsPresent,
|
|
66
149
|
intl: intl,
|
|
67
150
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
68
151
|
toolbarType: FloatingToolbarSettings.toolbarType
|
|
@@ -1,7 +1,86 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
2
|
+
import { useSharedPluginState, sharedPluginStateHookMigratorFactory } from '@atlaskit/editor-common/hooks';
|
|
3
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
3
4
|
import Toolbar from './Toolbar';
|
|
4
5
|
import { ToolbarType } from './Toolbar/types';
|
|
6
|
+
var useSharedState = sharedPluginStateHookMigratorFactory(function (api) {
|
|
7
|
+
var isInitialised = useSharedPluginStateSelector(api, 'textFormatting.isInitialised');
|
|
8
|
+
var formattingIsPresent = useSharedPluginStateSelector(api, 'textFormatting.formattingIsPresent');
|
|
9
|
+
var emActive = useSharedPluginStateSelector(api, 'textFormatting.emActive');
|
|
10
|
+
var emDisabled = useSharedPluginStateSelector(api, 'textFormatting.emDisabled');
|
|
11
|
+
var emHidden = useSharedPluginStateSelector(api, 'textFormatting.emHidden');
|
|
12
|
+
var codeActive = useSharedPluginStateSelector(api, 'textFormatting.codeActive');
|
|
13
|
+
var codeDisabled = useSharedPluginStateSelector(api, 'textFormatting.codeDisabled');
|
|
14
|
+
var codeHidden = useSharedPluginStateSelector(api, 'textFormatting.codeHidden');
|
|
15
|
+
var underlineActive = useSharedPluginStateSelector(api, 'textFormatting.underlineActive');
|
|
16
|
+
var underlineDisabled = useSharedPluginStateSelector(api, 'textFormatting.underlineDisabled');
|
|
17
|
+
var underlineHidden = useSharedPluginStateSelector(api, 'textFormatting.underlineHidden');
|
|
18
|
+
var strikeActive = useSharedPluginStateSelector(api, 'textFormatting.strikeActive');
|
|
19
|
+
var strikeDisabled = useSharedPluginStateSelector(api, 'textFormatting.strikeDisabled');
|
|
20
|
+
var strikeHidden = useSharedPluginStateSelector(api, 'textFormatting.strikeHidden');
|
|
21
|
+
var strongActive = useSharedPluginStateSelector(api, 'textFormatting.strongActive');
|
|
22
|
+
var strongDisabled = useSharedPluginStateSelector(api, 'textFormatting.strongDisabled');
|
|
23
|
+
var strongHidden = useSharedPluginStateSelector(api, 'textFormatting.strongHidden');
|
|
24
|
+
var superscriptActive = useSharedPluginStateSelector(api, 'textFormatting.superscriptActive');
|
|
25
|
+
var superscriptDisabled = useSharedPluginStateSelector(api, 'textFormatting.superscriptDisabled');
|
|
26
|
+
var superscriptHidden = useSharedPluginStateSelector(api, 'textFormatting.superscriptHidden');
|
|
27
|
+
var subscriptActive = useSharedPluginStateSelector(api, 'textFormatting.subscriptActive');
|
|
28
|
+
var subscriptDisabled = useSharedPluginStateSelector(api, 'textFormatting.subscriptDisabled');
|
|
29
|
+
var subscriptHidden = useSharedPluginStateSelector(api, 'textFormatting.subscriptHidden');
|
|
30
|
+
return {
|
|
31
|
+
isInitialised: Boolean(isInitialised),
|
|
32
|
+
formattingIsPresent: formattingIsPresent,
|
|
33
|
+
emActive: emActive,
|
|
34
|
+
emDisabled: emDisabled,
|
|
35
|
+
emHidden: emHidden,
|
|
36
|
+
codeActive: codeActive,
|
|
37
|
+
codeDisabled: codeDisabled,
|
|
38
|
+
codeHidden: codeHidden,
|
|
39
|
+
underlineActive: underlineActive,
|
|
40
|
+
underlineDisabled: underlineDisabled,
|
|
41
|
+
underlineHidden: underlineHidden,
|
|
42
|
+
strikeActive: strikeActive,
|
|
43
|
+
strikeDisabled: strikeDisabled,
|
|
44
|
+
strikeHidden: strikeHidden,
|
|
45
|
+
strongActive: strongActive,
|
|
46
|
+
strongDisabled: strongDisabled,
|
|
47
|
+
strongHidden: strongHidden,
|
|
48
|
+
superscriptActive: superscriptActive,
|
|
49
|
+
superscriptDisabled: superscriptDisabled,
|
|
50
|
+
superscriptHidden: superscriptHidden,
|
|
51
|
+
subscriptActive: subscriptActive,
|
|
52
|
+
subscriptDisabled: subscriptDisabled,
|
|
53
|
+
subscriptHidden: subscriptHidden
|
|
54
|
+
};
|
|
55
|
+
}, function (api) {
|
|
56
|
+
var _useSharedPluginState = useSharedPluginState(api, ['textFormatting']),
|
|
57
|
+
textFormattingState = _useSharedPluginState.textFormattingState;
|
|
58
|
+
return {
|
|
59
|
+
isInitialised: Boolean(textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.isInitialised),
|
|
60
|
+
formattingIsPresent: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.formattingIsPresent,
|
|
61
|
+
emActive: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.emActive,
|
|
62
|
+
emDisabled: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.emDisabled,
|
|
63
|
+
emHidden: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.emHidden,
|
|
64
|
+
codeActive: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.codeActive,
|
|
65
|
+
codeDisabled: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.codeDisabled,
|
|
66
|
+
codeHidden: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.codeHidden,
|
|
67
|
+
underlineActive: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.underlineActive,
|
|
68
|
+
underlineDisabled: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.underlineDisabled,
|
|
69
|
+
underlineHidden: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.underlineHidden,
|
|
70
|
+
strikeActive: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.strikeActive,
|
|
71
|
+
strikeDisabled: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.strikeDisabled,
|
|
72
|
+
strikeHidden: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.strikeHidden,
|
|
73
|
+
strongActive: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.strongActive,
|
|
74
|
+
strongDisabled: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.strongDisabled,
|
|
75
|
+
strongHidden: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.strongHidden,
|
|
76
|
+
superscriptActive: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.superscriptActive,
|
|
77
|
+
superscriptDisabled: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.superscriptDisabled,
|
|
78
|
+
superscriptHidden: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.superscriptHidden,
|
|
79
|
+
subscriptActive: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.subscriptActive,
|
|
80
|
+
subscriptDisabled: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.subscriptDisabled,
|
|
81
|
+
subscriptHidden: textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.subscriptHidden
|
|
82
|
+
};
|
|
83
|
+
});
|
|
5
84
|
export function PrimaryToolbarComponent(_ref) {
|
|
6
85
|
var _api$analytics;
|
|
7
86
|
var api = _ref.api,
|
|
@@ -12,8 +91,7 @@ export function PrimaryToolbarComponent(_ref) {
|
|
|
12
91
|
disabled = _ref.disabled,
|
|
13
92
|
isReducedSpacing = _ref.isReducedSpacing,
|
|
14
93
|
shouldUseResponsiveToolbar = _ref.shouldUseResponsiveToolbar;
|
|
15
|
-
var
|
|
16
|
-
textFormattingState = _useSharedPluginState.textFormattingState;
|
|
94
|
+
var textFormattingState = useSharedState(api);
|
|
17
95
|
return /*#__PURE__*/React.createElement(Toolbar, {
|
|
18
96
|
textFormattingState: textFormattingState,
|
|
19
97
|
popupsMountPoint: popupsMountPoint,
|
|
@@ -15,11 +15,12 @@ import { clearFormattingWithAnalytics } from '../../../editor-commands/clear-for
|
|
|
15
15
|
import { getInputMethod } from '../input-method-utils';
|
|
16
16
|
export var useClearIcon = function useClearIcon(_ref) {
|
|
17
17
|
var intl = _ref.intl,
|
|
18
|
-
|
|
18
|
+
formattingPluginInitialised = _ref.formattingPluginInitialised,
|
|
19
|
+
formattingPresent = _ref.formattingIsPresent,
|
|
19
20
|
editorAnalyticsAPI = _ref.editorAnalyticsAPI,
|
|
20
21
|
toolbarType = _ref.toolbarType;
|
|
21
|
-
var isPluginAvailable = Boolean(
|
|
22
|
-
var formattingIsPresent = Boolean(
|
|
22
|
+
var isPluginAvailable = Boolean(formattingPluginInitialised);
|
|
23
|
+
var formattingIsPresent = Boolean(formattingPresent);
|
|
23
24
|
var clearFormattingLabel = intl.formatMessage(toolbarMessages.clearFormatting);
|
|
24
25
|
var clearFormattingToolbar = useCallback(function (state, dispatch) {
|
|
25
26
|
return clearFormattingWithAnalytics(getInputMethod(toolbarType), editorAnalyticsAPI)(state, dispatch);
|
|
@@ -168,7 +168,7 @@ var buildMenuIconState = function buildMenuIconState(iconMark) {
|
|
|
168
168
|
return function (_ref2) {
|
|
169
169
|
var schema = _ref2.schema,
|
|
170
170
|
textFormattingState = _ref2.textFormattingState;
|
|
171
|
-
var hasPluginState = Boolean(
|
|
171
|
+
var hasPluginState = Boolean(textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.isInitialised);
|
|
172
172
|
var markSchema = IconsMarkSchema[iconMark];
|
|
173
173
|
var hasSchemaMark = Boolean(schema.marks[markSchema]);
|
|
174
174
|
if (!hasPluginState) {
|
|
@@ -258,7 +258,7 @@ export var useHasFormattingActived = function useHasFormattingActived(_ref5) {
|
|
|
258
258
|
var iconTypeList = _ref5.iconTypeList,
|
|
259
259
|
textFormattingState = _ref5.textFormattingState;
|
|
260
260
|
var hasActiveFormatting = useMemo(function () {
|
|
261
|
-
if (!textFormattingState) {
|
|
261
|
+
if (!(textFormattingState !== null && textFormattingState !== void 0 && textFormattingState.isInitialised)) {
|
|
262
262
|
return false;
|
|
263
263
|
}
|
|
264
264
|
return iconTypeList.some(function (iconType) {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
3
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
|
+
var _excluded = ["formattingIsPresent"];
|
|
3
5
|
/**
|
|
4
6
|
* @jsxRuntime classic
|
|
5
7
|
* @jsx jsx
|
|
@@ -41,16 +43,19 @@ var ToolbarFormatting = function ToolbarFormatting(_ref) {
|
|
|
41
43
|
_useState2 = _slicedToArray(_useState, 2),
|
|
42
44
|
message = _useState2[0],
|
|
43
45
|
setMessage = _useState2[1];
|
|
46
|
+
var formattingIsPresent = textFormattingState.formattingIsPresent,
|
|
47
|
+
formattingIconState = _objectWithoutProperties(textFormattingState, _excluded);
|
|
44
48
|
var defaultIcons = useFormattingIcons({
|
|
45
49
|
schema: editorView.state.schema,
|
|
46
50
|
intl: intl,
|
|
47
51
|
isToolbarDisabled: isToolbarDisabled,
|
|
48
52
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
49
|
-
textFormattingState:
|
|
53
|
+
textFormattingState: formattingIconState,
|
|
50
54
|
toolbarType: toolbarType
|
|
51
55
|
});
|
|
52
56
|
var clearIcon = useClearIcon({
|
|
53
|
-
|
|
57
|
+
formattingPluginInitialised: textFormattingState.isInitialised,
|
|
58
|
+
formattingIsPresent: formattingIsPresent,
|
|
54
59
|
intl: intl,
|
|
55
60
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
56
61
|
toolbarType: toolbarType
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
|
-
import type { TextFormattingState } from '@atlaskit/editor-common/types';
|
|
3
2
|
import type { IconHookProps, MenuIconItem, ToolbarType } from '../types';
|
|
4
3
|
interface ClearIconHookProps extends IconHookProps {
|
|
5
4
|
editorAnalyticsAPI: EditorAnalyticsAPI | undefined;
|
|
6
|
-
|
|
5
|
+
formattingPluginInitialised: boolean | undefined;
|
|
6
|
+
formattingIsPresent: boolean | undefined;
|
|
7
7
|
toolbarType: ToolbarType;
|
|
8
8
|
}
|
|
9
|
-
export declare const useClearIcon: ({ intl,
|
|
9
|
+
export declare const useClearIcon: ({ intl, formattingPluginInitialised, formattingIsPresent: formattingPresent, editorAnalyticsAPI, toolbarType, }: ClearIconHookProps) => MenuIconItem | null;
|
|
10
10
|
export {};
|
|
@@ -15,7 +15,7 @@ export type ToolbarFormattingProps = {
|
|
|
15
15
|
popupsBoundariesElement?: HTMLElement;
|
|
16
16
|
popupsScrollableElement?: HTMLElement;
|
|
17
17
|
editorAnalyticsAPI?: EditorAnalyticsAPI;
|
|
18
|
-
textFormattingState: TextFormattingState
|
|
18
|
+
textFormattingState: TextFormattingState;
|
|
19
19
|
api: ExtractInjectionAPI<TextFormattingPlugin> | undefined;
|
|
20
20
|
toolbarType: ToolbarType;
|
|
21
21
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
|
-
import type { TextFormattingState } from '@atlaskit/editor-common/types';
|
|
3
2
|
import type { IconHookProps, MenuIconItem, ToolbarType } from '../types';
|
|
4
3
|
interface ClearIconHookProps extends IconHookProps {
|
|
5
4
|
editorAnalyticsAPI: EditorAnalyticsAPI | undefined;
|
|
6
|
-
|
|
5
|
+
formattingPluginInitialised: boolean | undefined;
|
|
6
|
+
formattingIsPresent: boolean | undefined;
|
|
7
7
|
toolbarType: ToolbarType;
|
|
8
8
|
}
|
|
9
|
-
export declare const useClearIcon: ({ intl,
|
|
9
|
+
export declare const useClearIcon: ({ intl, formattingPluginInitialised, formattingIsPresent: formattingPresent, editorAnalyticsAPI, toolbarType, }: ClearIconHookProps) => MenuIconItem | null;
|
|
10
10
|
export {};
|
|
@@ -15,7 +15,7 @@ export type ToolbarFormattingProps = {
|
|
|
15
15
|
popupsBoundariesElement?: HTMLElement;
|
|
16
16
|
popupsScrollableElement?: HTMLElement;
|
|
17
17
|
editorAnalyticsAPI?: EditorAnalyticsAPI;
|
|
18
|
-
textFormattingState: TextFormattingState
|
|
18
|
+
textFormattingState: TextFormattingState;
|
|
19
19
|
api: ExtractInjectionAPI<TextFormattingPlugin> | undefined;
|
|
20
20
|
toolbarType: ToolbarType;
|
|
21
21
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-text-formatting",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.6",
|
|
4
4
|
"description": "Text-formatting plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@atlaskit/adf-schema": "^47.6.0",
|
|
37
|
-
"@atlaskit/editor-common": "^105.
|
|
38
|
-
"@atlaskit/editor-plugin-analytics": "^2.
|
|
37
|
+
"@atlaskit/editor-common": "^105.2.0",
|
|
38
|
+
"@atlaskit/editor-plugin-analytics": "^2.3.0",
|
|
39
39
|
"@atlaskit/editor-plugin-base": "^3.0.0",
|
|
40
40
|
"@atlaskit/editor-plugin-primary-toolbar": "^3.2.0",
|
|
41
41
|
"@atlaskit/editor-plugin-selection-toolbar": "^3.6.0",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@atlaskit/icon": "^26.0.0",
|
|
46
46
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
47
47
|
"@atlaskit/prosemirror-input-rules": "^3.3.0",
|
|
48
|
-
"@atlaskit/tmp-editor-statsig": "^4.
|
|
48
|
+
"@atlaskit/tmp-editor-statsig": "^4.21.0",
|
|
49
49
|
"@atlaskit/tokens": "^4.8.0",
|
|
50
50
|
"@babel/runtime": "^7.0.0",
|
|
51
51
|
"@emotion/react": "^11.7.1",
|