@atlaskit/editor-plugin-text-formatting 0.4.22 → 0.4.23
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 +7 -0
- package/dist/cjs/plugin.js +25 -30
- package/dist/cjs/ui/PrimaryToolbarComponent.js +34 -0
- package/dist/cjs/ui/Toolbar/hooks/clear-formatting-icon.js +3 -10
- package/dist/cjs/ui/Toolbar/hooks/formatting-icons.js +15 -26
- package/dist/cjs/ui/Toolbar/index.js +11 -10
- package/dist/es2019/plugin.js +23 -30
- package/dist/es2019/ui/PrimaryToolbarComponent.js +29 -0
- package/dist/es2019/ui/Toolbar/hooks/clear-formatting-icon.js +3 -8
- package/dist/es2019/ui/Toolbar/hooks/formatting-icons.js +15 -26
- package/dist/es2019/ui/Toolbar/index.js +11 -8
- package/dist/esm/plugin.js +25 -30
- package/dist/esm/ui/PrimaryToolbarComponent.js +27 -0
- package/dist/esm/ui/Toolbar/hooks/clear-formatting-icon.js +3 -10
- package/dist/esm/ui/Toolbar/hooks/formatting-icons.js +15 -26
- package/dist/esm/ui/Toolbar/index.js +11 -10
- package/dist/types/ui/PrimaryToolbarComponent.d.ts +16 -0
- package/dist/types/ui/Toolbar/hooks/clear-formatting-icon.d.ts +3 -1
- package/dist/types/ui/Toolbar/hooks/formatting-icons.d.ts +7 -4
- package/dist/types/ui/Toolbar/index.d.ts +4 -8
- package/dist/types/ui/Toolbar/types.d.ts +0 -2
- package/dist/types-ts4.5/ui/PrimaryToolbarComponent.d.ts +16 -0
- package/dist/types-ts4.5/ui/Toolbar/hooks/clear-formatting-icon.d.ts +3 -1
- package/dist/types-ts4.5/ui/Toolbar/hooks/formatting-icons.d.ts +7 -4
- package/dist/types-ts4.5/ui/Toolbar/index.d.ts +4 -8
- package/dist/types-ts4.5/ui/Toolbar/types.d.ts +0 -2
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-text-formatting
|
|
2
2
|
|
|
3
|
+
## 0.4.23
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#67557](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/67557) [`124d0c6d5286`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/124d0c6d5286) - Migrating block-type, text-color, and text-formatting to use useSharedPluginState rather than WithPluginState. Removing unused option on default preset. Adding formattingIsPresent prop to TextFormattingState.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
|
|
3
10
|
## 0.4.22
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.textFormattingPlugin = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
8
9
|
var _react = _interopRequireDefault(require("react"));
|
|
9
10
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
10
|
-
var _withPluginState = require("@atlaskit/editor-common/with-plugin-state");
|
|
11
11
|
var _commands = require("./commands");
|
|
12
12
|
var _clearFormatting = require("./pm-plugins/clear-formatting");
|
|
13
13
|
var _clearFormattingKeymap = _interopRequireDefault(require("./pm-plugins/clear-formatting-keymap"));
|
|
@@ -16,13 +16,15 @@ var _inputRule = _interopRequireDefault(require("./pm-plugins/input-rule"));
|
|
|
16
16
|
var _keymap = _interopRequireDefault(require("./pm-plugins/keymap"));
|
|
17
17
|
var _main = require("./pm-plugins/main");
|
|
18
18
|
var _smartInputRule = _interopRequireDefault(require("./pm-plugins/smart-input-rule"));
|
|
19
|
-
var
|
|
19
|
+
var _PrimaryToolbarComponent = require("./ui/PrimaryToolbarComponent");
|
|
20
|
+
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
|
+
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; }
|
|
20
22
|
/**
|
|
21
23
|
* Text formatting plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor`
|
|
22
24
|
* from `@atlaskit/editor-core`.
|
|
23
25
|
*/
|
|
24
26
|
var textFormattingPlugin = exports.textFormattingPlugin = function textFormattingPlugin(_ref) {
|
|
25
|
-
var _api$analytics7, _api$analytics8, _api$analytics9, _api$analytics10, _api$analytics11, _api$analytics12
|
|
27
|
+
var _api$analytics6, _api$analytics7, _api$analytics8, _api$analytics9, _api$analytics10, _api$analytics11, _api$analytics12;
|
|
26
28
|
var options = _ref.config,
|
|
27
29
|
api = _ref.api;
|
|
28
30
|
return {
|
|
@@ -96,10 +98,13 @@ var textFormattingPlugin = exports.textFormattingPlugin = function textFormattin
|
|
|
96
98
|
}];
|
|
97
99
|
},
|
|
98
100
|
getSharedState: function getSharedState(editorState) {
|
|
101
|
+
var _clearFormattingPlugi;
|
|
99
102
|
if (!editorState) {
|
|
100
103
|
return undefined;
|
|
101
104
|
}
|
|
102
|
-
return _main.pluginKey.getState(editorState)
|
|
105
|
+
return _objectSpread(_objectSpread({}, _main.pluginKey.getState(editorState)), {}, {
|
|
106
|
+
formattingIsPresent: (_clearFormattingPlugi = _clearFormatting.pluginKey.getState(editorState)) === null || _clearFormattingPlugi === void 0 ? void 0 : _clearFormattingPlugi.formattingIsPresent
|
|
107
|
+
});
|
|
103
108
|
},
|
|
104
109
|
primaryToolbarComponent: function primaryToolbarComponent(_ref6) {
|
|
105
110
|
var editorView = _ref6.editorView,
|
|
@@ -108,35 +113,25 @@ var textFormattingPlugin = exports.textFormattingPlugin = function textFormattin
|
|
|
108
113
|
isToolbarReducedSpacing = _ref6.isToolbarReducedSpacing,
|
|
109
114
|
toolbarSize = _ref6.toolbarSize,
|
|
110
115
|
disabled = _ref6.disabled;
|
|
111
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
popupsMountPoint: popupsMountPoint,
|
|
121
|
-
popupsScrollableElement: popupsScrollableElement,
|
|
122
|
-
toolbarSize: toolbarSize,
|
|
123
|
-
isReducedSpacing: isToolbarReducedSpacing,
|
|
124
|
-
editorView: editorView,
|
|
125
|
-
isToolbarDisabled: disabled,
|
|
126
|
-
shouldUseResponsiveToolbar: Boolean(options === null || options === void 0 ? void 0 : options.responsiveToolbarMenu),
|
|
127
|
-
editorAnalyticsAPI: api === null || api === void 0 || (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : _api$analytics6.actions
|
|
128
|
-
});
|
|
129
|
-
}
|
|
116
|
+
return /*#__PURE__*/_react.default.createElement(_PrimaryToolbarComponent.PrimaryToolbarComponent, {
|
|
117
|
+
api: api,
|
|
118
|
+
popupsMountPoint: popupsMountPoint,
|
|
119
|
+
popupsScrollableElement: popupsScrollableElement,
|
|
120
|
+
toolbarSize: toolbarSize,
|
|
121
|
+
isReducedSpacing: isToolbarReducedSpacing,
|
|
122
|
+
editorView: editorView,
|
|
123
|
+
disabled: disabled,
|
|
124
|
+
shouldUseResponsiveToolbar: Boolean(options === null || options === void 0 ? void 0 : options.responsiveToolbarMenu)
|
|
130
125
|
});
|
|
131
126
|
},
|
|
132
127
|
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$
|
|
128
|
+
toggleSuperscript: (0, _commands.toggleSuperscriptWithAnalytics)(api === null || api === void 0 || (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : _api$analytics6.actions),
|
|
129
|
+
toggleSubscript: (0, _commands.toggleSubscriptWithAnalytics)(api === null || api === void 0 || (_api$analytics7 = api.analytics) === null || _api$analytics7 === void 0 ? void 0 : _api$analytics7.actions),
|
|
130
|
+
toggleStrike: (0, _commands.toggleStrikeWithAnalytics)(api === null || api === void 0 || (_api$analytics8 = api.analytics) === null || _api$analytics8 === void 0 ? void 0 : _api$analytics8.actions),
|
|
131
|
+
toggleCode: (0, _commands.toggleCodeWithAnalytics)(api === null || api === void 0 || (_api$analytics9 = api.analytics) === null || _api$analytics9 === void 0 ? void 0 : _api$analytics9.actions),
|
|
132
|
+
toggleUnderline: (0, _commands.toggleUnderlineWithAnalytics)(api === null || api === void 0 || (_api$analytics10 = api.analytics) === null || _api$analytics10 === void 0 ? void 0 : _api$analytics10.actions),
|
|
133
|
+
toggleEm: (0, _commands.toggleEmWithAnalytics)(api === null || api === void 0 || (_api$analytics11 = api.analytics) === null || _api$analytics11 === void 0 ? void 0 : _api$analytics11.actions),
|
|
134
|
+
toggleStrong: (0, _commands.toggleStrongWithAnalytics)(api === null || api === void 0 || (_api$analytics12 = api.analytics) === null || _api$analytics12 === void 0 ? void 0 : _api$analytics12.actions)
|
|
140
135
|
}
|
|
141
136
|
};
|
|
142
137
|
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.PrimaryToolbarComponent = PrimaryToolbarComponent;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
10
|
+
var _Toolbar = _interopRequireDefault(require("./Toolbar"));
|
|
11
|
+
function PrimaryToolbarComponent(_ref) {
|
|
12
|
+
var _api$analytics;
|
|
13
|
+
var api = _ref.api,
|
|
14
|
+
popupsMountPoint = _ref.popupsMountPoint,
|
|
15
|
+
popupsScrollableElement = _ref.popupsScrollableElement,
|
|
16
|
+
toolbarSize = _ref.toolbarSize,
|
|
17
|
+
editorView = _ref.editorView,
|
|
18
|
+
disabled = _ref.disabled,
|
|
19
|
+
isReducedSpacing = _ref.isReducedSpacing,
|
|
20
|
+
shouldUseResponsiveToolbar = _ref.shouldUseResponsiveToolbar;
|
|
21
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['textFormatting']),
|
|
22
|
+
textFormattingState = _useSharedPluginState.textFormattingState;
|
|
23
|
+
return /*#__PURE__*/_react.default.createElement(_Toolbar.default, {
|
|
24
|
+
textFormattingState: textFormattingState,
|
|
25
|
+
popupsMountPoint: popupsMountPoint,
|
|
26
|
+
popupsScrollableElement: popupsScrollableElement,
|
|
27
|
+
toolbarSize: toolbarSize,
|
|
28
|
+
isReducedSpacing: isReducedSpacing,
|
|
29
|
+
editorView: editorView,
|
|
30
|
+
isToolbarDisabled: disabled,
|
|
31
|
+
shouldUseResponsiveToolbar: shouldUseResponsiveToolbar,
|
|
32
|
+
editorAnalyticsAPI: api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions
|
|
33
|
+
});
|
|
34
|
+
}
|
|
@@ -11,21 +11,14 @@ var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
|
11
11
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
12
12
|
var _shortcut = require("@atlaskit/editor-shared-styles/shortcut");
|
|
13
13
|
var _clearFormatting = require("../../../commands/clear-formatting");
|
|
14
|
-
var _clearFormatting2 = require("../../../pm-plugins/clear-formatting");
|
|
15
14
|
/** @jsx jsx */
|
|
16
15
|
|
|
17
|
-
var useClearFormattingPluginState = function useClearFormattingPluginState(editorState) {
|
|
18
|
-
return (0, _react.useMemo)(function () {
|
|
19
|
-
return _clearFormatting2.pluginKey.getState(editorState);
|
|
20
|
-
}, [editorState]);
|
|
21
|
-
};
|
|
22
16
|
var useClearIcon = exports.useClearIcon = function useClearIcon(_ref) {
|
|
23
17
|
var intl = _ref.intl,
|
|
24
|
-
|
|
18
|
+
textFormattingState = _ref.textFormattingState,
|
|
25
19
|
editorAnalyticsAPI = _ref.editorAnalyticsAPI;
|
|
26
|
-
var
|
|
27
|
-
var
|
|
28
|
-
var formattingIsPresent = Boolean(pluginState === null || pluginState === void 0 ? void 0 : pluginState.formattingIsPresent);
|
|
20
|
+
var isPluginAvailable = Boolean(textFormattingState);
|
|
21
|
+
var formattingIsPresent = Boolean(textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.formattingIsPresent);
|
|
29
22
|
var clearFormattingLabel = intl.formatMessage(_messages.toolbarMessages.clearFormatting);
|
|
30
23
|
var clearFormattingToolbar = (0, _react.useCallback)(function (state, dispatch) {
|
|
31
24
|
return (0, _clearFormatting.clearFormattingWithAnalytics)(_analytics.INPUT_METHOD.TOOLBAR, editorAnalyticsAPI)(state, dispatch);
|
|
@@ -17,7 +17,6 @@ var _shortcut = require("@atlaskit/editor-shared-styles/shortcut");
|
|
|
17
17
|
var _bold = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/bold"));
|
|
18
18
|
var _italic = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/italic"));
|
|
19
19
|
var _commands = require("../../../commands");
|
|
20
|
-
var _pluginKey = require("../../../pm-plugins/plugin-key");
|
|
21
20
|
var _types = require("../types");
|
|
22
21
|
var _IconsMarkSchema;
|
|
23
22
|
/** @jsx jsx */
|
|
@@ -115,8 +114,8 @@ var IconsMarkSchema = (_IconsMarkSchema = {}, (0, _defineProperty2.default)(_Ico
|
|
|
115
114
|
var buildMenuIconState = function buildMenuIconState(iconMark) {
|
|
116
115
|
return function (_ref2) {
|
|
117
116
|
var schema = _ref2.schema,
|
|
118
|
-
|
|
119
|
-
var hasPluginState = Boolean(Object.keys(
|
|
117
|
+
textFormattingState = _ref2.textFormattingState;
|
|
118
|
+
var hasPluginState = Boolean(Object.keys(textFormattingState || {}).length);
|
|
120
119
|
var markSchema = IconsMarkSchema[iconMark];
|
|
121
120
|
var hasSchemaMark = Boolean(schema.marks[markSchema]);
|
|
122
121
|
if (!hasPluginState) {
|
|
@@ -127,9 +126,9 @@ var buildMenuIconState = function buildMenuIconState(iconMark) {
|
|
|
127
126
|
hasSchemaMark: hasSchemaMark
|
|
128
127
|
};
|
|
129
128
|
}
|
|
130
|
-
var isActive =
|
|
131
|
-
var isDisabled =
|
|
132
|
-
var isHidden =
|
|
129
|
+
var isActive = textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState["".concat(iconMark, "Active")];
|
|
130
|
+
var isDisabled = textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState["".concat(iconMark, "Disabled")];
|
|
131
|
+
var isHidden = textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState["".concat(iconMark, "Hidden")];
|
|
133
132
|
return {
|
|
134
133
|
isActive: Boolean(isActive),
|
|
135
134
|
isDisabled: Boolean(isDisabled),
|
|
@@ -142,12 +141,12 @@ var buildIcon = function buildIcon(iconMark, editorAnalyticsAPI) {
|
|
|
142
141
|
var getState = buildMenuIconState(iconMark);
|
|
143
142
|
return function (_ref3) {
|
|
144
143
|
var schema = _ref3.schema,
|
|
145
|
-
|
|
144
|
+
textFormattingState = _ref3.textFormattingState,
|
|
146
145
|
intl = _ref3.intl,
|
|
147
146
|
isToolbarDisabled = _ref3.isToolbarDisabled;
|
|
148
147
|
var iconState = getState({
|
|
149
148
|
schema: schema,
|
|
150
|
-
|
|
149
|
+
textFormattingState: textFormattingState
|
|
151
150
|
});
|
|
152
151
|
var isActive = iconState.isActive,
|
|
153
152
|
isDisabled = iconState.isDisabled,
|
|
@@ -168,24 +167,15 @@ var buildIcon = function buildIcon(iconMark, editorAnalyticsAPI) {
|
|
|
168
167
|
}, [shouldRenderIcon, iconComponent]);
|
|
169
168
|
};
|
|
170
169
|
};
|
|
171
|
-
var useTextFormattingPluginState = function useTextFormattingPluginState(editorState) {
|
|
172
|
-
return (0, _react.useMemo)(function () {
|
|
173
|
-
var pluginState = _pluginKey.pluginKey.getState(editorState);
|
|
174
|
-
|
|
175
|
-
// TODO: ED-13910 for reasons that goes beyond my knowledge. This is the only way to make the current unit tests happy. Even thought this was wrong before
|
|
176
|
-
return pluginState;
|
|
177
|
-
}, [editorState]);
|
|
178
|
-
};
|
|
179
170
|
var useFormattingIcons = exports.useFormattingIcons = function useFormattingIcons(_ref4) {
|
|
180
171
|
var isToolbarDisabled = _ref4.isToolbarDisabled,
|
|
181
|
-
|
|
172
|
+
textFormattingState = _ref4.textFormattingState,
|
|
173
|
+
schema = _ref4.schema,
|
|
182
174
|
intl = _ref4.intl,
|
|
183
175
|
editorAnalyticsAPI = _ref4.editorAnalyticsAPI;
|
|
184
|
-
var textFormattingPluginState = useTextFormattingPluginState(editorState);
|
|
185
|
-
var schema = editorState.schema;
|
|
186
176
|
var props = {
|
|
187
177
|
schema: schema,
|
|
188
|
-
|
|
178
|
+
textFormattingState: textFormattingState,
|
|
189
179
|
intl: intl,
|
|
190
180
|
isToolbarDisabled: Boolean(isToolbarDisabled)
|
|
191
181
|
};
|
|
@@ -209,16 +199,15 @@ var useFormattingIcons = exports.useFormattingIcons = function useFormattingIcon
|
|
|
209
199
|
return result;
|
|
210
200
|
};
|
|
211
201
|
var useHasFormattingActived = exports.useHasFormattingActived = function useHasFormattingActived(_ref5) {
|
|
212
|
-
var
|
|
213
|
-
|
|
214
|
-
var textFormattingPluginState = useTextFormattingPluginState(editorState);
|
|
202
|
+
var iconTypeList = _ref5.iconTypeList,
|
|
203
|
+
textFormattingState = _ref5.textFormattingState;
|
|
215
204
|
var hasActiveFormatting = (0, _react.useMemo)(function () {
|
|
216
|
-
if (!
|
|
205
|
+
if (!textFormattingState) {
|
|
217
206
|
return false;
|
|
218
207
|
}
|
|
219
208
|
return iconTypeList.some(function (iconType) {
|
|
220
|
-
return
|
|
209
|
+
return textFormattingState["".concat(iconType, "Active")];
|
|
221
210
|
});
|
|
222
|
-
}, [
|
|
211
|
+
}, [textFormattingState, iconTypeList]);
|
|
223
212
|
return hasActiveFormatting;
|
|
224
213
|
};
|
|
@@ -34,22 +34,21 @@ var ToolbarFormatting = function ToolbarFormatting(_ref) {
|
|
|
34
34
|
isReducedSpacing = _ref.isReducedSpacing,
|
|
35
35
|
isToolbarDisabled = _ref.isToolbarDisabled,
|
|
36
36
|
intl = _ref.intl,
|
|
37
|
-
editorAnalyticsAPI = _ref.editorAnalyticsAPI
|
|
38
|
-
|
|
39
|
-
return editorView.state;
|
|
40
|
-
}, [editorView.state]);
|
|
37
|
+
editorAnalyticsAPI = _ref.editorAnalyticsAPI,
|
|
38
|
+
textFormattingState = _ref.textFormattingState;
|
|
41
39
|
var _useState = (0, _react.useState)(''),
|
|
42
40
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
43
41
|
message = _useState2[0],
|
|
44
42
|
setMessage = _useState2[1];
|
|
45
43
|
var defaultIcons = (0, _formattingIcons.useFormattingIcons)({
|
|
46
|
-
|
|
44
|
+
schema: editorView.state.schema,
|
|
47
45
|
intl: intl,
|
|
48
46
|
isToolbarDisabled: isToolbarDisabled,
|
|
49
|
-
editorAnalyticsAPI: editorAnalyticsAPI
|
|
47
|
+
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
48
|
+
textFormattingState: textFormattingState
|
|
50
49
|
});
|
|
51
50
|
var clearIcon = (0, _clearFormattingIcon.useClearIcon)({
|
|
52
|
-
|
|
51
|
+
textFormattingState: textFormattingState,
|
|
53
52
|
intl: intl,
|
|
54
53
|
editorAnalyticsAPI: editorAnalyticsAPI
|
|
55
54
|
});
|
|
@@ -58,8 +57,8 @@ var ToolbarFormatting = function ToolbarFormatting(_ref) {
|
|
|
58
57
|
responsivenessEnabled: shouldUseResponsiveToolbar
|
|
59
58
|
});
|
|
60
59
|
var hasFormattingActive = (0, _formattingIcons.useHasFormattingActived)({
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
iconTypeList: menuIconTypeList,
|
|
61
|
+
textFormattingState: textFormattingState
|
|
63
62
|
});
|
|
64
63
|
var _useResponsiveToolbar = (0, _responsiveToolbarButtons.useResponsiveToolbarButtons)({
|
|
65
64
|
icons: defaultIcons,
|
|
@@ -166,8 +165,10 @@ var Toolbar = function Toolbar(_ref2) {
|
|
|
166
165
|
isToolbarDisabled = _ref2.isToolbarDisabled,
|
|
167
166
|
shouldUseResponsiveToolbar = _ref2.shouldUseResponsiveToolbar,
|
|
168
167
|
intl = _ref2.intl,
|
|
169
|
-
editorAnalyticsAPI = _ref2.editorAnalyticsAPI
|
|
168
|
+
editorAnalyticsAPI = _ref2.editorAnalyticsAPI,
|
|
169
|
+
textFormattingState = _ref2.textFormattingState;
|
|
170
170
|
return (0, _react2.jsx)(ToolbarFormatting, {
|
|
171
|
+
textFormattingState: textFormattingState,
|
|
171
172
|
popupsMountPoint: popupsMountPoint,
|
|
172
173
|
popupsScrollableElement: popupsScrollableElement,
|
|
173
174
|
toolbarSize: toolbarSize,
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { code, em, strike, strong, subsup, underline } from '@atlaskit/adf-schema';
|
|
3
|
-
import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
|
|
4
3
|
import { toggleCodeWithAnalytics, toggleEmWithAnalytics, toggleStrikeWithAnalytics, toggleStrongWithAnalytics, toggleSubscriptWithAnalytics, toggleSuperscriptWithAnalytics, toggleUnderlineWithAnalytics } from './commands';
|
|
5
4
|
import { plugin as clearFormattingPlugin, pluginKey as clearFormattingPluginKey } from './pm-plugins/clear-formatting';
|
|
6
5
|
import clearFormattingKeymapPlugin from './pm-plugins/clear-formatting-keymap';
|
|
@@ -9,7 +8,7 @@ import textFormattingInputRulePlugin from './pm-plugins/input-rule';
|
|
|
9
8
|
import keymapPlugin from './pm-plugins/keymap';
|
|
10
9
|
import { plugin as pmPlugin, pluginKey as textFormattingPluginKey } from './pm-plugins/main';
|
|
11
10
|
import textFormattingSmartInputRulePlugin from './pm-plugins/smart-input-rule';
|
|
12
|
-
import
|
|
11
|
+
import { PrimaryToolbarComponent } from './ui/PrimaryToolbarComponent';
|
|
13
12
|
/**
|
|
14
13
|
* Text formatting plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor`
|
|
15
14
|
* from `@atlaskit/editor-core`.
|
|
@@ -18,7 +17,7 @@ export const textFormattingPlugin = ({
|
|
|
18
17
|
config: options,
|
|
19
18
|
api
|
|
20
19
|
}) => {
|
|
21
|
-
var _api$analytics7, _api$analytics8, _api$analytics9, _api$analytics10, _api$analytics11, _api$analytics12
|
|
20
|
+
var _api$analytics6, _api$analytics7, _api$analytics8, _api$analytics9, _api$analytics10, _api$analytics11, _api$analytics12;
|
|
22
21
|
return {
|
|
23
22
|
name: 'textFormatting',
|
|
24
23
|
marks() {
|
|
@@ -90,10 +89,14 @@ export const textFormattingPlugin = ({
|
|
|
90
89
|
}];
|
|
91
90
|
},
|
|
92
91
|
getSharedState(editorState) {
|
|
92
|
+
var _clearFormattingPlugi;
|
|
93
93
|
if (!editorState) {
|
|
94
94
|
return undefined;
|
|
95
95
|
}
|
|
96
|
-
return
|
|
96
|
+
return {
|
|
97
|
+
...textFormattingPluginKey.getState(editorState),
|
|
98
|
+
formattingIsPresent: (_clearFormattingPlugi = clearFormattingPluginKey.getState(editorState)) === null || _clearFormattingPlugi === void 0 ? void 0 : _clearFormattingPlugi.formattingIsPresent
|
|
99
|
+
};
|
|
97
100
|
},
|
|
98
101
|
primaryToolbarComponent({
|
|
99
102
|
editorView,
|
|
@@ -103,35 +106,25 @@ export const textFormattingPlugin = ({
|
|
|
103
106
|
toolbarSize,
|
|
104
107
|
disabled
|
|
105
108
|
}) {
|
|
106
|
-
return /*#__PURE__*/React.createElement(
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
popupsMountPoint: popupsMountPoint,
|
|
116
|
-
popupsScrollableElement: popupsScrollableElement,
|
|
117
|
-
toolbarSize: toolbarSize,
|
|
118
|
-
isReducedSpacing: isToolbarReducedSpacing,
|
|
119
|
-
editorView: editorView,
|
|
120
|
-
isToolbarDisabled: disabled,
|
|
121
|
-
shouldUseResponsiveToolbar: Boolean(options === null || options === void 0 ? void 0 : options.responsiveToolbarMenu),
|
|
122
|
-
editorAnalyticsAPI: api === null || api === void 0 ? void 0 : (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : _api$analytics6.actions
|
|
123
|
-
});
|
|
124
|
-
}
|
|
109
|
+
return /*#__PURE__*/React.createElement(PrimaryToolbarComponent, {
|
|
110
|
+
api: api,
|
|
111
|
+
popupsMountPoint: popupsMountPoint,
|
|
112
|
+
popupsScrollableElement: popupsScrollableElement,
|
|
113
|
+
toolbarSize: toolbarSize,
|
|
114
|
+
isReducedSpacing: isToolbarReducedSpacing,
|
|
115
|
+
editorView: editorView,
|
|
116
|
+
disabled: disabled,
|
|
117
|
+
shouldUseResponsiveToolbar: Boolean(options === null || options === void 0 ? void 0 : options.responsiveToolbarMenu)
|
|
125
118
|
});
|
|
126
119
|
},
|
|
127
120
|
commands: {
|
|
128
|
-
toggleSuperscript: toggleSuperscriptWithAnalytics(api === null || api === void 0 ? void 0 : (_api$
|
|
129
|
-
toggleSubscript: toggleSubscriptWithAnalytics(api === null || api === void 0 ? void 0 : (_api$
|
|
130
|
-
toggleStrike: toggleStrikeWithAnalytics(api === null || api === void 0 ? void 0 : (_api$
|
|
131
|
-
toggleCode: toggleCodeWithAnalytics(api === null || api === void 0 ? void 0 : (_api$
|
|
132
|
-
toggleUnderline: toggleUnderlineWithAnalytics(api === null || api === void 0 ? void 0 : (_api$
|
|
133
|
-
toggleEm: toggleEmWithAnalytics(api === null || api === void 0 ? void 0 : (_api$
|
|
134
|
-
toggleStrong: toggleStrongWithAnalytics(api === null || api === void 0 ? void 0 : (_api$
|
|
121
|
+
toggleSuperscript: toggleSuperscriptWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : _api$analytics6.actions),
|
|
122
|
+
toggleSubscript: toggleSubscriptWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics7 = api.analytics) === null || _api$analytics7 === void 0 ? void 0 : _api$analytics7.actions),
|
|
123
|
+
toggleStrike: toggleStrikeWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics8 = api.analytics) === null || _api$analytics8 === void 0 ? void 0 : _api$analytics8.actions),
|
|
124
|
+
toggleCode: toggleCodeWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics9 = api.analytics) === null || _api$analytics9 === void 0 ? void 0 : _api$analytics9.actions),
|
|
125
|
+
toggleUnderline: toggleUnderlineWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics10 = api.analytics) === null || _api$analytics10 === void 0 ? void 0 : _api$analytics10.actions),
|
|
126
|
+
toggleEm: toggleEmWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics11 = api.analytics) === null || _api$analytics11 === void 0 ? void 0 : _api$analytics11.actions),
|
|
127
|
+
toggleStrong: toggleStrongWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics12 = api.analytics) === null || _api$analytics12 === void 0 ? void 0 : _api$analytics12.actions)
|
|
135
128
|
}
|
|
136
129
|
};
|
|
137
130
|
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
3
|
+
import Toolbar from './Toolbar';
|
|
4
|
+
export function PrimaryToolbarComponent({
|
|
5
|
+
api,
|
|
6
|
+
popupsMountPoint,
|
|
7
|
+
popupsScrollableElement,
|
|
8
|
+
toolbarSize,
|
|
9
|
+
editorView,
|
|
10
|
+
disabled,
|
|
11
|
+
isReducedSpacing,
|
|
12
|
+
shouldUseResponsiveToolbar
|
|
13
|
+
}) {
|
|
14
|
+
var _api$analytics;
|
|
15
|
+
const {
|
|
16
|
+
textFormattingState
|
|
17
|
+
} = useSharedPluginState(api, ['textFormatting']);
|
|
18
|
+
return /*#__PURE__*/React.createElement(Toolbar, {
|
|
19
|
+
textFormattingState: textFormattingState,
|
|
20
|
+
popupsMountPoint: popupsMountPoint,
|
|
21
|
+
popupsScrollableElement: popupsScrollableElement,
|
|
22
|
+
toolbarSize: toolbarSize,
|
|
23
|
+
isReducedSpacing: isReducedSpacing,
|
|
24
|
+
editorView: editorView,
|
|
25
|
+
isToolbarDisabled: disabled,
|
|
26
|
+
shouldUseResponsiveToolbar: shouldUseResponsiveToolbar,
|
|
27
|
+
editorAnalyticsAPI: api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -6,18 +6,13 @@ import { clearFormatting as clearFormattingKeymap, tooltip } from '@atlaskit/edi
|
|
|
6
6
|
import { toolbarMessages } from '@atlaskit/editor-common/messages';
|
|
7
7
|
import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
|
|
8
8
|
import { clearFormattingWithAnalytics } from '../../../commands/clear-formatting';
|
|
9
|
-
import { pluginKey as clearFormattingPluginKey } from '../../../pm-plugins/clear-formatting';
|
|
10
|
-
const useClearFormattingPluginState = editorState => {
|
|
11
|
-
return useMemo(() => clearFormattingPluginKey.getState(editorState), [editorState]);
|
|
12
|
-
};
|
|
13
9
|
export const useClearIcon = ({
|
|
14
10
|
intl,
|
|
15
|
-
|
|
11
|
+
textFormattingState,
|
|
16
12
|
editorAnalyticsAPI
|
|
17
13
|
}) => {
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const formattingIsPresent = Boolean(pluginState === null || pluginState === void 0 ? void 0 : pluginState.formattingIsPresent);
|
|
14
|
+
const isPluginAvailable = Boolean(textFormattingState);
|
|
15
|
+
const formattingIsPresent = Boolean(textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.formattingIsPresent);
|
|
21
16
|
const clearFormattingLabel = intl.formatMessage(toolbarMessages.clearFormatting);
|
|
22
17
|
const clearFormattingToolbar = useCallback((state, dispatch) => clearFormattingWithAnalytics(INPUT_METHOD.TOOLBAR, editorAnalyticsAPI)(state, dispatch), [editorAnalyticsAPI]);
|
|
23
18
|
return useMemo(() => {
|
|
@@ -9,7 +9,6 @@ import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
|
|
|
9
9
|
import BoldIcon from '@atlaskit/icon/glyph/editor/bold';
|
|
10
10
|
import ItalicIcon from '@atlaskit/icon/glyph/editor/italic';
|
|
11
11
|
import { toggleCodeWithAnalytics, toggleEmWithAnalytics, toggleStrikeWithAnalytics, toggleStrongWithAnalytics, toggleSubscriptWithAnalytics, toggleSuperscriptWithAnalytics, toggleUnderlineWithAnalytics } from '../../../commands';
|
|
12
|
-
import { pluginKey as textFormattingPluginKey } from '../../../pm-plugins/plugin-key';
|
|
13
12
|
import { IconTypes } from '../types';
|
|
14
13
|
const withToolbarInputMethod = func => editorCommandToPMCommand(func(INPUT_METHOD.TOOLBAR));
|
|
15
14
|
const IconButtons = editorAnalyticsAPI => ({
|
|
@@ -105,9 +104,9 @@ const IconsMarkSchema = {
|
|
|
105
104
|
};
|
|
106
105
|
const buildMenuIconState = iconMark => ({
|
|
107
106
|
schema,
|
|
108
|
-
|
|
107
|
+
textFormattingState
|
|
109
108
|
}) => {
|
|
110
|
-
const hasPluginState = Boolean(Object.keys(
|
|
109
|
+
const hasPluginState = Boolean(Object.keys(textFormattingState || {}).length);
|
|
111
110
|
const markSchema = IconsMarkSchema[iconMark];
|
|
112
111
|
const hasSchemaMark = Boolean(schema.marks[markSchema]);
|
|
113
112
|
if (!hasPluginState) {
|
|
@@ -118,9 +117,9 @@ const buildMenuIconState = iconMark => ({
|
|
|
118
117
|
hasSchemaMark
|
|
119
118
|
};
|
|
120
119
|
}
|
|
121
|
-
const isActive =
|
|
122
|
-
const isDisabled =
|
|
123
|
-
const isHidden =
|
|
120
|
+
const isActive = textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState[`${iconMark}Active`];
|
|
121
|
+
const isDisabled = textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState[`${iconMark}Disabled`];
|
|
122
|
+
const isHidden = textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState[`${iconMark}Hidden`];
|
|
124
123
|
return {
|
|
125
124
|
isActive: Boolean(isActive),
|
|
126
125
|
isDisabled: Boolean(isDisabled),
|
|
@@ -132,13 +131,13 @@ const buildIcon = (iconMark, editorAnalyticsAPI) => {
|
|
|
132
131
|
const getState = buildMenuIconState(iconMark);
|
|
133
132
|
return ({
|
|
134
133
|
schema,
|
|
135
|
-
|
|
134
|
+
textFormattingState,
|
|
136
135
|
intl,
|
|
137
136
|
isToolbarDisabled
|
|
138
137
|
}) => {
|
|
139
138
|
const iconState = getState({
|
|
140
139
|
schema,
|
|
141
|
-
|
|
140
|
+
textFormattingState
|
|
142
141
|
});
|
|
143
142
|
const {
|
|
144
143
|
isActive,
|
|
@@ -157,25 +156,16 @@ const buildIcon = (iconMark, editorAnalyticsAPI) => {
|
|
|
157
156
|
return useMemo(() => shouldRenderIcon ? iconComponent : null, [shouldRenderIcon, iconComponent]);
|
|
158
157
|
};
|
|
159
158
|
};
|
|
160
|
-
const useTextFormattingPluginState = editorState => useMemo(() => {
|
|
161
|
-
const pluginState = textFormattingPluginKey.getState(editorState);
|
|
162
|
-
|
|
163
|
-
// TODO: ED-13910 for reasons that goes beyond my knowledge. This is the only way to make the current unit tests happy. Even thought this was wrong before
|
|
164
|
-
return pluginState;
|
|
165
|
-
}, [editorState]);
|
|
166
159
|
export const useFormattingIcons = ({
|
|
167
160
|
isToolbarDisabled,
|
|
168
|
-
|
|
161
|
+
textFormattingState,
|
|
162
|
+
schema,
|
|
169
163
|
intl,
|
|
170
164
|
editorAnalyticsAPI
|
|
171
165
|
}) => {
|
|
172
|
-
const textFormattingPluginState = useTextFormattingPluginState(editorState);
|
|
173
|
-
const {
|
|
174
|
-
schema
|
|
175
|
-
} = editorState;
|
|
176
166
|
const props = {
|
|
177
167
|
schema,
|
|
178
|
-
|
|
168
|
+
textFormattingState,
|
|
179
169
|
intl,
|
|
180
170
|
isToolbarDisabled: Boolean(isToolbarDisabled)
|
|
181
171
|
};
|
|
@@ -197,15 +187,14 @@ export const useFormattingIcons = ({
|
|
|
197
187
|
return result;
|
|
198
188
|
};
|
|
199
189
|
export const useHasFormattingActived = ({
|
|
200
|
-
|
|
201
|
-
|
|
190
|
+
iconTypeList,
|
|
191
|
+
textFormattingState
|
|
202
192
|
}) => {
|
|
203
|
-
const textFormattingPluginState = useTextFormattingPluginState(editorState);
|
|
204
193
|
const hasActiveFormatting = useMemo(() => {
|
|
205
|
-
if (!
|
|
194
|
+
if (!textFormattingState) {
|
|
206
195
|
return false;
|
|
207
196
|
}
|
|
208
|
-
return iconTypeList.some(iconType =>
|
|
209
|
-
}, [
|
|
197
|
+
return iconTypeList.some(iconType => textFormattingState[`${iconType}Active`]);
|
|
198
|
+
}, [textFormattingState, iconTypeList]);
|
|
210
199
|
return hasActiveFormatting;
|
|
211
200
|
};
|
|
@@ -23,19 +23,20 @@ const ToolbarFormatting = ({
|
|
|
23
23
|
isReducedSpacing,
|
|
24
24
|
isToolbarDisabled,
|
|
25
25
|
intl,
|
|
26
|
-
editorAnalyticsAPI
|
|
26
|
+
editorAnalyticsAPI,
|
|
27
|
+
textFormattingState
|
|
27
28
|
}) => {
|
|
28
29
|
var _usePreviousState;
|
|
29
|
-
const editorState = useMemo(() => editorView.state, [editorView.state]);
|
|
30
30
|
const [message, setMessage] = useState('');
|
|
31
31
|
const defaultIcons = useFormattingIcons({
|
|
32
|
-
|
|
32
|
+
schema: editorView.state.schema,
|
|
33
33
|
intl,
|
|
34
34
|
isToolbarDisabled,
|
|
35
|
-
editorAnalyticsAPI
|
|
35
|
+
editorAnalyticsAPI,
|
|
36
|
+
textFormattingState
|
|
36
37
|
});
|
|
37
38
|
const clearIcon = useClearIcon({
|
|
38
|
-
|
|
39
|
+
textFormattingState,
|
|
39
40
|
intl,
|
|
40
41
|
editorAnalyticsAPI
|
|
41
42
|
});
|
|
@@ -44,8 +45,8 @@ const ToolbarFormatting = ({
|
|
|
44
45
|
responsivenessEnabled: shouldUseResponsiveToolbar
|
|
45
46
|
});
|
|
46
47
|
const hasFormattingActive = useHasFormattingActived({
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
iconTypeList: menuIconTypeList,
|
|
49
|
+
textFormattingState
|
|
49
50
|
});
|
|
50
51
|
const {
|
|
51
52
|
dropdownItems,
|
|
@@ -151,9 +152,11 @@ const Toolbar = ({
|
|
|
151
152
|
isToolbarDisabled,
|
|
152
153
|
shouldUseResponsiveToolbar,
|
|
153
154
|
intl,
|
|
154
|
-
editorAnalyticsAPI
|
|
155
|
+
editorAnalyticsAPI,
|
|
156
|
+
textFormattingState
|
|
155
157
|
}) => {
|
|
156
158
|
return jsx(ToolbarFormatting, {
|
|
159
|
+
textFormattingState: textFormattingState,
|
|
157
160
|
popupsMountPoint: popupsMountPoint,
|
|
158
161
|
popupsScrollableElement: popupsScrollableElement,
|
|
159
162
|
toolbarSize: toolbarSize,
|
package/dist/esm/plugin.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
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; }
|
|
3
|
+
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) { _defineProperty(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; }
|
|
1
4
|
import React from 'react';
|
|
2
5
|
import { code, em, strike, strong, subsup, underline } from '@atlaskit/adf-schema';
|
|
3
|
-
import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
|
|
4
6
|
import { toggleCodeWithAnalytics, toggleEmWithAnalytics, toggleStrikeWithAnalytics, toggleStrongWithAnalytics, toggleSubscriptWithAnalytics, toggleSuperscriptWithAnalytics, toggleUnderlineWithAnalytics } from './commands';
|
|
5
7
|
import { plugin as clearFormattingPlugin, pluginKey as clearFormattingPluginKey } from './pm-plugins/clear-formatting';
|
|
6
8
|
import clearFormattingKeymapPlugin from './pm-plugins/clear-formatting-keymap';
|
|
@@ -9,13 +11,13 @@ import textFormattingInputRulePlugin from './pm-plugins/input-rule';
|
|
|
9
11
|
import keymapPlugin from './pm-plugins/keymap';
|
|
10
12
|
import { plugin as pmPlugin, pluginKey as textFormattingPluginKey } from './pm-plugins/main';
|
|
11
13
|
import textFormattingSmartInputRulePlugin from './pm-plugins/smart-input-rule';
|
|
12
|
-
import
|
|
14
|
+
import { PrimaryToolbarComponent } from './ui/PrimaryToolbarComponent';
|
|
13
15
|
/**
|
|
14
16
|
* Text formatting plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor`
|
|
15
17
|
* from `@atlaskit/editor-core`.
|
|
16
18
|
*/
|
|
17
19
|
export var textFormattingPlugin = function textFormattingPlugin(_ref) {
|
|
18
|
-
var _api$analytics7, _api$analytics8, _api$analytics9, _api$analytics10, _api$analytics11, _api$analytics12
|
|
20
|
+
var _api$analytics6, _api$analytics7, _api$analytics8, _api$analytics9, _api$analytics10, _api$analytics11, _api$analytics12;
|
|
19
21
|
var options = _ref.config,
|
|
20
22
|
api = _ref.api;
|
|
21
23
|
return {
|
|
@@ -89,10 +91,13 @@ export var textFormattingPlugin = function textFormattingPlugin(_ref) {
|
|
|
89
91
|
}];
|
|
90
92
|
},
|
|
91
93
|
getSharedState: function getSharedState(editorState) {
|
|
94
|
+
var _clearFormattingPlugi;
|
|
92
95
|
if (!editorState) {
|
|
93
96
|
return undefined;
|
|
94
97
|
}
|
|
95
|
-
return textFormattingPluginKey.getState(editorState)
|
|
98
|
+
return _objectSpread(_objectSpread({}, textFormattingPluginKey.getState(editorState)), {}, {
|
|
99
|
+
formattingIsPresent: (_clearFormattingPlugi = clearFormattingPluginKey.getState(editorState)) === null || _clearFormattingPlugi === void 0 ? void 0 : _clearFormattingPlugi.formattingIsPresent
|
|
100
|
+
});
|
|
96
101
|
},
|
|
97
102
|
primaryToolbarComponent: function primaryToolbarComponent(_ref6) {
|
|
98
103
|
var editorView = _ref6.editorView,
|
|
@@ -101,35 +106,25 @@ export var textFormattingPlugin = function textFormattingPlugin(_ref) {
|
|
|
101
106
|
isToolbarReducedSpacing = _ref6.isToolbarReducedSpacing,
|
|
102
107
|
toolbarSize = _ref6.toolbarSize,
|
|
103
108
|
disabled = _ref6.disabled;
|
|
104
|
-
return /*#__PURE__*/React.createElement(
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
popupsMountPoint: popupsMountPoint,
|
|
114
|
-
popupsScrollableElement: popupsScrollableElement,
|
|
115
|
-
toolbarSize: toolbarSize,
|
|
116
|
-
isReducedSpacing: isToolbarReducedSpacing,
|
|
117
|
-
editorView: editorView,
|
|
118
|
-
isToolbarDisabled: disabled,
|
|
119
|
-
shouldUseResponsiveToolbar: Boolean(options === null || options === void 0 ? void 0 : options.responsiveToolbarMenu),
|
|
120
|
-
editorAnalyticsAPI: api === null || api === void 0 || (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : _api$analytics6.actions
|
|
121
|
-
});
|
|
122
|
-
}
|
|
109
|
+
return /*#__PURE__*/React.createElement(PrimaryToolbarComponent, {
|
|
110
|
+
api: api,
|
|
111
|
+
popupsMountPoint: popupsMountPoint,
|
|
112
|
+
popupsScrollableElement: popupsScrollableElement,
|
|
113
|
+
toolbarSize: toolbarSize,
|
|
114
|
+
isReducedSpacing: isToolbarReducedSpacing,
|
|
115
|
+
editorView: editorView,
|
|
116
|
+
disabled: disabled,
|
|
117
|
+
shouldUseResponsiveToolbar: Boolean(options === null || options === void 0 ? void 0 : options.responsiveToolbarMenu)
|
|
123
118
|
});
|
|
124
119
|
},
|
|
125
120
|
commands: {
|
|
126
|
-
toggleSuperscript: toggleSuperscriptWithAnalytics(api === null || api === void 0 || (_api$
|
|
127
|
-
toggleSubscript: toggleSubscriptWithAnalytics(api === null || api === void 0 || (_api$
|
|
128
|
-
toggleStrike: toggleStrikeWithAnalytics(api === null || api === void 0 || (_api$
|
|
129
|
-
toggleCode: toggleCodeWithAnalytics(api === null || api === void 0 || (_api$
|
|
130
|
-
toggleUnderline: toggleUnderlineWithAnalytics(api === null || api === void 0 || (_api$
|
|
131
|
-
toggleEm: toggleEmWithAnalytics(api === null || api === void 0 || (_api$
|
|
132
|
-
toggleStrong: toggleStrongWithAnalytics(api === null || api === void 0 || (_api$
|
|
121
|
+
toggleSuperscript: toggleSuperscriptWithAnalytics(api === null || api === void 0 || (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : _api$analytics6.actions),
|
|
122
|
+
toggleSubscript: toggleSubscriptWithAnalytics(api === null || api === void 0 || (_api$analytics7 = api.analytics) === null || _api$analytics7 === void 0 ? void 0 : _api$analytics7.actions),
|
|
123
|
+
toggleStrike: toggleStrikeWithAnalytics(api === null || api === void 0 || (_api$analytics8 = api.analytics) === null || _api$analytics8 === void 0 ? void 0 : _api$analytics8.actions),
|
|
124
|
+
toggleCode: toggleCodeWithAnalytics(api === null || api === void 0 || (_api$analytics9 = api.analytics) === null || _api$analytics9 === void 0 ? void 0 : _api$analytics9.actions),
|
|
125
|
+
toggleUnderline: toggleUnderlineWithAnalytics(api === null || api === void 0 || (_api$analytics10 = api.analytics) === null || _api$analytics10 === void 0 ? void 0 : _api$analytics10.actions),
|
|
126
|
+
toggleEm: toggleEmWithAnalytics(api === null || api === void 0 || (_api$analytics11 = api.analytics) === null || _api$analytics11 === void 0 ? void 0 : _api$analytics11.actions),
|
|
127
|
+
toggleStrong: toggleStrongWithAnalytics(api === null || api === void 0 || (_api$analytics12 = api.analytics) === null || _api$analytics12 === void 0 ? void 0 : _api$analytics12.actions)
|
|
133
128
|
}
|
|
134
129
|
};
|
|
135
130
|
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
3
|
+
import Toolbar from './Toolbar';
|
|
4
|
+
export function PrimaryToolbarComponent(_ref) {
|
|
5
|
+
var _api$analytics;
|
|
6
|
+
var api = _ref.api,
|
|
7
|
+
popupsMountPoint = _ref.popupsMountPoint,
|
|
8
|
+
popupsScrollableElement = _ref.popupsScrollableElement,
|
|
9
|
+
toolbarSize = _ref.toolbarSize,
|
|
10
|
+
editorView = _ref.editorView,
|
|
11
|
+
disabled = _ref.disabled,
|
|
12
|
+
isReducedSpacing = _ref.isReducedSpacing,
|
|
13
|
+
shouldUseResponsiveToolbar = _ref.shouldUseResponsiveToolbar;
|
|
14
|
+
var _useSharedPluginState = useSharedPluginState(api, ['textFormatting']),
|
|
15
|
+
textFormattingState = _useSharedPluginState.textFormattingState;
|
|
16
|
+
return /*#__PURE__*/React.createElement(Toolbar, {
|
|
17
|
+
textFormattingState: textFormattingState,
|
|
18
|
+
popupsMountPoint: popupsMountPoint,
|
|
19
|
+
popupsScrollableElement: popupsScrollableElement,
|
|
20
|
+
toolbarSize: toolbarSize,
|
|
21
|
+
isReducedSpacing: isReducedSpacing,
|
|
22
|
+
editorView: editorView,
|
|
23
|
+
isToolbarDisabled: disabled,
|
|
24
|
+
shouldUseResponsiveToolbar: shouldUseResponsiveToolbar,
|
|
25
|
+
editorAnalyticsAPI: api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions
|
|
26
|
+
});
|
|
27
|
+
}
|
|
@@ -6,19 +6,12 @@ import { clearFormatting as clearFormattingKeymap, tooltip } from '@atlaskit/edi
|
|
|
6
6
|
import { toolbarMessages } from '@atlaskit/editor-common/messages';
|
|
7
7
|
import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
|
|
8
8
|
import { clearFormattingWithAnalytics } from '../../../commands/clear-formatting';
|
|
9
|
-
import { pluginKey as clearFormattingPluginKey } from '../../../pm-plugins/clear-formatting';
|
|
10
|
-
var useClearFormattingPluginState = function useClearFormattingPluginState(editorState) {
|
|
11
|
-
return useMemo(function () {
|
|
12
|
-
return clearFormattingPluginKey.getState(editorState);
|
|
13
|
-
}, [editorState]);
|
|
14
|
-
};
|
|
15
9
|
export var useClearIcon = function useClearIcon(_ref) {
|
|
16
10
|
var intl = _ref.intl,
|
|
17
|
-
|
|
11
|
+
textFormattingState = _ref.textFormattingState,
|
|
18
12
|
editorAnalyticsAPI = _ref.editorAnalyticsAPI;
|
|
19
|
-
var
|
|
20
|
-
var
|
|
21
|
-
var formattingIsPresent = Boolean(pluginState === null || pluginState === void 0 ? void 0 : pluginState.formattingIsPresent);
|
|
13
|
+
var isPluginAvailable = Boolean(textFormattingState);
|
|
14
|
+
var formattingIsPresent = Boolean(textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState.formattingIsPresent);
|
|
22
15
|
var clearFormattingLabel = intl.formatMessage(toolbarMessages.clearFormatting);
|
|
23
16
|
var clearFormattingToolbar = useCallback(function (state, dispatch) {
|
|
24
17
|
return clearFormattingWithAnalytics(INPUT_METHOD.TOOLBAR, editorAnalyticsAPI)(state, dispatch);
|
|
@@ -11,7 +11,6 @@ import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
|
|
|
11
11
|
import BoldIcon from '@atlaskit/icon/glyph/editor/bold';
|
|
12
12
|
import ItalicIcon from '@atlaskit/icon/glyph/editor/italic';
|
|
13
13
|
import { toggleCodeWithAnalytics, toggleEmWithAnalytics, toggleStrikeWithAnalytics, toggleStrongWithAnalytics, toggleSubscriptWithAnalytics, toggleSuperscriptWithAnalytics, toggleUnderlineWithAnalytics } from '../../../commands';
|
|
14
|
-
import { pluginKey as textFormattingPluginKey } from '../../../pm-plugins/plugin-key';
|
|
15
14
|
import { IconTypes } from '../types';
|
|
16
15
|
var withToolbarInputMethod = function withToolbarInputMethod(func) {
|
|
17
16
|
return editorCommandToPMCommand(func(INPUT_METHOD.TOOLBAR));
|
|
@@ -105,8 +104,8 @@ var IconsMarkSchema = (_IconsMarkSchema = {}, _defineProperty(_IconsMarkSchema,
|
|
|
105
104
|
var buildMenuIconState = function buildMenuIconState(iconMark) {
|
|
106
105
|
return function (_ref2) {
|
|
107
106
|
var schema = _ref2.schema,
|
|
108
|
-
|
|
109
|
-
var hasPluginState = Boolean(Object.keys(
|
|
107
|
+
textFormattingState = _ref2.textFormattingState;
|
|
108
|
+
var hasPluginState = Boolean(Object.keys(textFormattingState || {}).length);
|
|
110
109
|
var markSchema = IconsMarkSchema[iconMark];
|
|
111
110
|
var hasSchemaMark = Boolean(schema.marks[markSchema]);
|
|
112
111
|
if (!hasPluginState) {
|
|
@@ -117,9 +116,9 @@ var buildMenuIconState = function buildMenuIconState(iconMark) {
|
|
|
117
116
|
hasSchemaMark: hasSchemaMark
|
|
118
117
|
};
|
|
119
118
|
}
|
|
120
|
-
var isActive =
|
|
121
|
-
var isDisabled =
|
|
122
|
-
var isHidden =
|
|
119
|
+
var isActive = textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState["".concat(iconMark, "Active")];
|
|
120
|
+
var isDisabled = textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState["".concat(iconMark, "Disabled")];
|
|
121
|
+
var isHidden = textFormattingState === null || textFormattingState === void 0 ? void 0 : textFormattingState["".concat(iconMark, "Hidden")];
|
|
123
122
|
return {
|
|
124
123
|
isActive: Boolean(isActive),
|
|
125
124
|
isDisabled: Boolean(isDisabled),
|
|
@@ -132,12 +131,12 @@ var buildIcon = function buildIcon(iconMark, editorAnalyticsAPI) {
|
|
|
132
131
|
var getState = buildMenuIconState(iconMark);
|
|
133
132
|
return function (_ref3) {
|
|
134
133
|
var schema = _ref3.schema,
|
|
135
|
-
|
|
134
|
+
textFormattingState = _ref3.textFormattingState,
|
|
136
135
|
intl = _ref3.intl,
|
|
137
136
|
isToolbarDisabled = _ref3.isToolbarDisabled;
|
|
138
137
|
var iconState = getState({
|
|
139
138
|
schema: schema,
|
|
140
|
-
|
|
139
|
+
textFormattingState: textFormattingState
|
|
141
140
|
});
|
|
142
141
|
var isActive = iconState.isActive,
|
|
143
142
|
isDisabled = iconState.isDisabled,
|
|
@@ -158,24 +157,15 @@ var buildIcon = function buildIcon(iconMark, editorAnalyticsAPI) {
|
|
|
158
157
|
}, [shouldRenderIcon, iconComponent]);
|
|
159
158
|
};
|
|
160
159
|
};
|
|
161
|
-
var useTextFormattingPluginState = function useTextFormattingPluginState(editorState) {
|
|
162
|
-
return useMemo(function () {
|
|
163
|
-
var pluginState = textFormattingPluginKey.getState(editorState);
|
|
164
|
-
|
|
165
|
-
// TODO: ED-13910 for reasons that goes beyond my knowledge. This is the only way to make the current unit tests happy. Even thought this was wrong before
|
|
166
|
-
return pluginState;
|
|
167
|
-
}, [editorState]);
|
|
168
|
-
};
|
|
169
160
|
export var useFormattingIcons = function useFormattingIcons(_ref4) {
|
|
170
161
|
var isToolbarDisabled = _ref4.isToolbarDisabled,
|
|
171
|
-
|
|
162
|
+
textFormattingState = _ref4.textFormattingState,
|
|
163
|
+
schema = _ref4.schema,
|
|
172
164
|
intl = _ref4.intl,
|
|
173
165
|
editorAnalyticsAPI = _ref4.editorAnalyticsAPI;
|
|
174
|
-
var textFormattingPluginState = useTextFormattingPluginState(editorState);
|
|
175
|
-
var schema = editorState.schema;
|
|
176
166
|
var props = {
|
|
177
167
|
schema: schema,
|
|
178
|
-
|
|
168
|
+
textFormattingState: textFormattingState,
|
|
179
169
|
intl: intl,
|
|
180
170
|
isToolbarDisabled: Boolean(isToolbarDisabled)
|
|
181
171
|
};
|
|
@@ -199,16 +189,15 @@ export var useFormattingIcons = function useFormattingIcons(_ref4) {
|
|
|
199
189
|
return result;
|
|
200
190
|
};
|
|
201
191
|
export var useHasFormattingActived = function useHasFormattingActived(_ref5) {
|
|
202
|
-
var
|
|
203
|
-
|
|
204
|
-
var textFormattingPluginState = useTextFormattingPluginState(editorState);
|
|
192
|
+
var iconTypeList = _ref5.iconTypeList,
|
|
193
|
+
textFormattingState = _ref5.textFormattingState;
|
|
205
194
|
var hasActiveFormatting = useMemo(function () {
|
|
206
|
-
if (!
|
|
195
|
+
if (!textFormattingState) {
|
|
207
196
|
return false;
|
|
208
197
|
}
|
|
209
198
|
return iconTypeList.some(function (iconType) {
|
|
210
|
-
return
|
|
199
|
+
return textFormattingState["".concat(iconType, "Active")];
|
|
211
200
|
});
|
|
212
|
-
}, [
|
|
201
|
+
}, [textFormattingState, iconTypeList]);
|
|
213
202
|
return hasActiveFormatting;
|
|
214
203
|
};
|
|
@@ -26,22 +26,21 @@ var ToolbarFormatting = function ToolbarFormatting(_ref) {
|
|
|
26
26
|
isReducedSpacing = _ref.isReducedSpacing,
|
|
27
27
|
isToolbarDisabled = _ref.isToolbarDisabled,
|
|
28
28
|
intl = _ref.intl,
|
|
29
|
-
editorAnalyticsAPI = _ref.editorAnalyticsAPI
|
|
30
|
-
|
|
31
|
-
return editorView.state;
|
|
32
|
-
}, [editorView.state]);
|
|
29
|
+
editorAnalyticsAPI = _ref.editorAnalyticsAPI,
|
|
30
|
+
textFormattingState = _ref.textFormattingState;
|
|
33
31
|
var _useState = useState(''),
|
|
34
32
|
_useState2 = _slicedToArray(_useState, 2),
|
|
35
33
|
message = _useState2[0],
|
|
36
34
|
setMessage = _useState2[1];
|
|
37
35
|
var defaultIcons = useFormattingIcons({
|
|
38
|
-
|
|
36
|
+
schema: editorView.state.schema,
|
|
39
37
|
intl: intl,
|
|
40
38
|
isToolbarDisabled: isToolbarDisabled,
|
|
41
|
-
editorAnalyticsAPI: editorAnalyticsAPI
|
|
39
|
+
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
40
|
+
textFormattingState: textFormattingState
|
|
42
41
|
});
|
|
43
42
|
var clearIcon = useClearIcon({
|
|
44
|
-
|
|
43
|
+
textFormattingState: textFormattingState,
|
|
45
44
|
intl: intl,
|
|
46
45
|
editorAnalyticsAPI: editorAnalyticsAPI
|
|
47
46
|
});
|
|
@@ -50,8 +49,8 @@ var ToolbarFormatting = function ToolbarFormatting(_ref) {
|
|
|
50
49
|
responsivenessEnabled: shouldUseResponsiveToolbar
|
|
51
50
|
});
|
|
52
51
|
var hasFormattingActive = useHasFormattingActived({
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
iconTypeList: menuIconTypeList,
|
|
53
|
+
textFormattingState: textFormattingState
|
|
55
54
|
});
|
|
56
55
|
var _useResponsiveToolbar = useResponsiveToolbarButtons({
|
|
57
56
|
icons: defaultIcons,
|
|
@@ -158,8 +157,10 @@ var Toolbar = function Toolbar(_ref2) {
|
|
|
158
157
|
isToolbarDisabled = _ref2.isToolbarDisabled,
|
|
159
158
|
shouldUseResponsiveToolbar = _ref2.shouldUseResponsiveToolbar,
|
|
160
159
|
intl = _ref2.intl,
|
|
161
|
-
editorAnalyticsAPI = _ref2.editorAnalyticsAPI
|
|
160
|
+
editorAnalyticsAPI = _ref2.editorAnalyticsAPI,
|
|
161
|
+
textFormattingState = _ref2.textFormattingState;
|
|
162
162
|
return jsx(ToolbarFormatting, {
|
|
163
|
+
textFormattingState: textFormattingState,
|
|
163
164
|
popupsMountPoint: popupsMountPoint,
|
|
164
165
|
popupsScrollableElement: popupsScrollableElement,
|
|
165
166
|
toolbarSize: toolbarSize,
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { ExtractInjectionAPI, ToolbarSize } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
+
import type { TextFormattingPlugin } from '../plugin';
|
|
5
|
+
interface PrimaryToolbarComponentProps {
|
|
6
|
+
api: ExtractInjectionAPI<TextFormattingPlugin> | undefined;
|
|
7
|
+
editorView: EditorView;
|
|
8
|
+
popupsMountPoint?: HTMLElement;
|
|
9
|
+
popupsScrollableElement?: HTMLElement;
|
|
10
|
+
toolbarSize: ToolbarSize;
|
|
11
|
+
disabled: boolean;
|
|
12
|
+
isReducedSpacing: boolean;
|
|
13
|
+
shouldUseResponsiveToolbar: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare function PrimaryToolbarComponent({ api, popupsMountPoint, popupsScrollableElement, toolbarSize, editorView, disabled, isReducedSpacing, shouldUseResponsiveToolbar, }: PrimaryToolbarComponentProps): JSX.Element;
|
|
16
|
+
export {};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { TextFormattingState } from '@atlaskit/editor-common/types';
|
|
2
3
|
import type { IconHookProps, MenuIconItem } from '../types';
|
|
3
4
|
interface ClearIconHookProps extends IconHookProps {
|
|
4
5
|
editorAnalyticsAPI: EditorAnalyticsAPI | undefined;
|
|
6
|
+
textFormattingState: TextFormattingState | undefined;
|
|
5
7
|
}
|
|
6
|
-
export declare const useClearIcon: ({ intl,
|
|
8
|
+
export declare const useClearIcon: ({ intl, textFormattingState, editorAnalyticsAPI, }: ClearIconHookProps) => MenuIconItem | null;
|
|
7
9
|
export {};
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
|
-
import type {
|
|
2
|
+
import type { TextFormattingState } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { Schema } from '@atlaskit/editor-prosemirror/model';
|
|
3
4
|
import type { IconHookProps, MenuIconItem } from '../types';
|
|
4
5
|
import { IconTypes } from '../types';
|
|
5
6
|
interface FormattingIconHookProps extends IconHookProps {
|
|
6
7
|
editorAnalyticsAPI: EditorAnalyticsAPI | undefined;
|
|
8
|
+
textFormattingState: TextFormattingState | undefined;
|
|
9
|
+
schema: Schema;
|
|
7
10
|
}
|
|
8
|
-
export declare const useFormattingIcons: ({ isToolbarDisabled,
|
|
11
|
+
export declare const useFormattingIcons: ({ isToolbarDisabled, textFormattingState, schema, intl, editorAnalyticsAPI, }: FormattingIconHookProps) => Array<MenuIconItem | null>;
|
|
9
12
|
type Props = {
|
|
10
|
-
|
|
13
|
+
textFormattingState: TextFormattingState | undefined;
|
|
11
14
|
iconTypeList: IconTypes[];
|
|
12
15
|
};
|
|
13
|
-
export declare const useHasFormattingActived: ({
|
|
16
|
+
export declare const useHasFormattingActived: ({ iconTypeList, textFormattingState, }: Props) => boolean;
|
|
14
17
|
export {};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { WrappedComponentProps } from 'react-intl-next';
|
|
3
3
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
4
|
-
import type { ToolbarSize } from '@atlaskit/editor-common/types';
|
|
5
|
-
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
+
import type { TextFormattingState, ToolbarSize } from '@atlaskit/editor-common/types';
|
|
6
5
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
7
6
|
export type ToolbarFormattingProps = {
|
|
8
7
|
editorView: EditorView;
|
|
@@ -14,12 +13,9 @@ export type ToolbarFormattingProps = {
|
|
|
14
13
|
popupsBoundariesElement?: HTMLElement;
|
|
15
14
|
popupsScrollableElement?: HTMLElement;
|
|
16
15
|
editorAnalyticsAPI?: EditorAnalyticsAPI;
|
|
16
|
+
textFormattingState: TextFormattingState | undefined;
|
|
17
17
|
};
|
|
18
|
-
declare const _default: import("react").FC<import("react-intl-next").WithIntlProps<ToolbarFormattingProps & WrappedComponentProps<"intl"
|
|
19
|
-
|
|
20
|
-
}>> & {
|
|
21
|
-
WrappedComponent: import("react").ComponentType<ToolbarFormattingProps & WrappedComponentProps<"intl"> & {
|
|
22
|
-
editorState: EditorState;
|
|
23
|
-
}>;
|
|
18
|
+
declare const _default: import("react").FC<import("react-intl-next").WithIntlProps<ToolbarFormattingProps & WrappedComponentProps<"intl">>> & {
|
|
19
|
+
WrappedComponent: import("react").ComponentType<ToolbarFormattingProps & WrappedComponentProps<"intl">>;
|
|
24
20
|
};
|
|
25
21
|
export default _default;
|
|
@@ -3,7 +3,6 @@ import type { WrappedComponentProps } from 'react-intl-next';
|
|
|
3
3
|
import type { TOOLBAR_ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import type { Command } from '@atlaskit/editor-common/types';
|
|
5
5
|
import type { MenuItem } from '@atlaskit/editor-common/ui-menu';
|
|
6
|
-
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
7
6
|
export declare enum IconTypes {
|
|
8
7
|
strong = "strong",
|
|
9
8
|
em = "em",
|
|
@@ -28,5 +27,4 @@ export type MenuIconState = {
|
|
|
28
27
|
};
|
|
29
28
|
export type IconHookProps = {
|
|
30
29
|
isToolbarDisabled?: boolean;
|
|
31
|
-
editorState: EditorState;
|
|
32
30
|
} & WrappedComponentProps;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { ExtractInjectionAPI, ToolbarSize } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
+
import type { TextFormattingPlugin } from '../plugin';
|
|
5
|
+
interface PrimaryToolbarComponentProps {
|
|
6
|
+
api: ExtractInjectionAPI<TextFormattingPlugin> | undefined;
|
|
7
|
+
editorView: EditorView;
|
|
8
|
+
popupsMountPoint?: HTMLElement;
|
|
9
|
+
popupsScrollableElement?: HTMLElement;
|
|
10
|
+
toolbarSize: ToolbarSize;
|
|
11
|
+
disabled: boolean;
|
|
12
|
+
isReducedSpacing: boolean;
|
|
13
|
+
shouldUseResponsiveToolbar: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare function PrimaryToolbarComponent({ api, popupsMountPoint, popupsScrollableElement, toolbarSize, editorView, disabled, isReducedSpacing, shouldUseResponsiveToolbar, }: PrimaryToolbarComponentProps): JSX.Element;
|
|
16
|
+
export {};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { TextFormattingState } from '@atlaskit/editor-common/types';
|
|
2
3
|
import type { IconHookProps, MenuIconItem } from '../types';
|
|
3
4
|
interface ClearIconHookProps extends IconHookProps {
|
|
4
5
|
editorAnalyticsAPI: EditorAnalyticsAPI | undefined;
|
|
6
|
+
textFormattingState: TextFormattingState | undefined;
|
|
5
7
|
}
|
|
6
|
-
export declare const useClearIcon: ({ intl,
|
|
8
|
+
export declare const useClearIcon: ({ intl, textFormattingState, editorAnalyticsAPI, }: ClearIconHookProps) => MenuIconItem | null;
|
|
7
9
|
export {};
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
|
-
import type {
|
|
2
|
+
import type { TextFormattingState } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { Schema } from '@atlaskit/editor-prosemirror/model';
|
|
3
4
|
import type { IconHookProps, MenuIconItem } from '../types';
|
|
4
5
|
import { IconTypes } from '../types';
|
|
5
6
|
interface FormattingIconHookProps extends IconHookProps {
|
|
6
7
|
editorAnalyticsAPI: EditorAnalyticsAPI | undefined;
|
|
8
|
+
textFormattingState: TextFormattingState | undefined;
|
|
9
|
+
schema: Schema;
|
|
7
10
|
}
|
|
8
|
-
export declare const useFormattingIcons: ({ isToolbarDisabled,
|
|
11
|
+
export declare const useFormattingIcons: ({ isToolbarDisabled, textFormattingState, schema, intl, editorAnalyticsAPI, }: FormattingIconHookProps) => Array<MenuIconItem | null>;
|
|
9
12
|
type Props = {
|
|
10
|
-
|
|
13
|
+
textFormattingState: TextFormattingState | undefined;
|
|
11
14
|
iconTypeList: IconTypes[];
|
|
12
15
|
};
|
|
13
|
-
export declare const useHasFormattingActived: ({
|
|
16
|
+
export declare const useHasFormattingActived: ({ iconTypeList, textFormattingState, }: Props) => boolean;
|
|
14
17
|
export {};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { WrappedComponentProps } from 'react-intl-next';
|
|
3
3
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
4
|
-
import type { ToolbarSize } from '@atlaskit/editor-common/types';
|
|
5
|
-
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
+
import type { TextFormattingState, ToolbarSize } from '@atlaskit/editor-common/types';
|
|
6
5
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
7
6
|
export type ToolbarFormattingProps = {
|
|
8
7
|
editorView: EditorView;
|
|
@@ -14,12 +13,9 @@ export type ToolbarFormattingProps = {
|
|
|
14
13
|
popupsBoundariesElement?: HTMLElement;
|
|
15
14
|
popupsScrollableElement?: HTMLElement;
|
|
16
15
|
editorAnalyticsAPI?: EditorAnalyticsAPI;
|
|
16
|
+
textFormattingState: TextFormattingState | undefined;
|
|
17
17
|
};
|
|
18
|
-
declare const _default: import("react").FC<import("react-intl-next").WithIntlProps<ToolbarFormattingProps & WrappedComponentProps<"intl"
|
|
19
|
-
|
|
20
|
-
}>> & {
|
|
21
|
-
WrappedComponent: import("react").ComponentType<ToolbarFormattingProps & WrappedComponentProps<"intl"> & {
|
|
22
|
-
editorState: EditorState;
|
|
23
|
-
}>;
|
|
18
|
+
declare const _default: import("react").FC<import("react-intl-next").WithIntlProps<ToolbarFormattingProps & WrappedComponentProps<"intl">>> & {
|
|
19
|
+
WrappedComponent: import("react").ComponentType<ToolbarFormattingProps & WrappedComponentProps<"intl">>;
|
|
24
20
|
};
|
|
25
21
|
export default _default;
|
|
@@ -3,7 +3,6 @@ import type { WrappedComponentProps } from 'react-intl-next';
|
|
|
3
3
|
import type { TOOLBAR_ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import type { Command } from '@atlaskit/editor-common/types';
|
|
5
5
|
import type { MenuItem } from '@atlaskit/editor-common/ui-menu';
|
|
6
|
-
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
7
6
|
export declare enum IconTypes {
|
|
8
7
|
strong = "strong",
|
|
9
8
|
em = "em",
|
|
@@ -28,5 +27,4 @@ export type MenuIconState = {
|
|
|
28
27
|
};
|
|
29
28
|
export type IconHookProps = {
|
|
30
29
|
isToolbarDisabled?: boolean;
|
|
31
|
-
editorState: EditorState;
|
|
32
30
|
} & WrappedComponentProps;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-text-formatting",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.23",
|
|
4
4
|
"description": "Text-formatting plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"releaseModel": "continuous",
|
|
14
14
|
"runReact18": false
|
|
15
15
|
},
|
|
16
|
-
"repository": "https://bitbucket.org/atlassian/atlassian-frontend",
|
|
16
|
+
"repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
|
|
17
17
|
"main": "dist/cjs/index.js",
|
|
18
18
|
"module": "dist/esm/index.js",
|
|
19
19
|
"module:es2019": "dist/es2019/index.js",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@atlaskit/adf-schema": "^35.3.0",
|
|
36
|
-
"@atlaskit/editor-common": "^76.
|
|
36
|
+
"@atlaskit/editor-common": "^76.40.0",
|
|
37
37
|
"@atlaskit/editor-plugin-analytics": "^0.4.0",
|
|
38
38
|
"@atlaskit/editor-prosemirror": "1.1.0",
|
|
39
39
|
"@atlaskit/editor-shared-styles": "^2.9.0",
|