@atlaskit/editor-plugin-text-formatting 3.0.7 → 3.0.8

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.
Files changed (53) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/cjs/editor-commands/clear-formatting.js +94 -1
  3. package/dist/cjs/{pm-plugins/commands.js → editor-commands/toggle-mark.js} +1 -1
  4. package/dist/cjs/editor-commands/types.js +5 -0
  5. package/dist/cjs/pm-plugins/clear-formatting-keymap.js +2 -2
  6. package/dist/cjs/pm-plugins/keymap.js +15 -15
  7. package/dist/cjs/textFormattingPlugin.js +24 -15
  8. package/dist/cjs/ui/Toolbar/components/Component.js +144 -0
  9. package/dist/cjs/ui/Toolbar/components/utils.js +127 -0
  10. package/dist/cjs/ui/Toolbar/hooks/formatting-icons.js +8 -8
  11. package/dist/cjs/ui/Toolbar/types.js +11 -1
  12. package/dist/cjs/ui/toolbar-components.js +130 -0
  13. package/dist/es2019/editor-commands/clear-formatting.js +94 -1
  14. package/dist/es2019/{pm-plugins/commands.js → editor-commands/toggle-mark.js} +1 -1
  15. package/dist/es2019/editor-commands/types.js +1 -0
  16. package/dist/es2019/pm-plugins/clear-formatting-keymap.js +4 -4
  17. package/dist/es2019/pm-plugins/keymap.js +1 -1
  18. package/dist/es2019/textFormattingPlugin.js +17 -8
  19. package/dist/es2019/ui/Toolbar/components/Component.js +145 -0
  20. package/dist/es2019/ui/Toolbar/components/utils.js +121 -0
  21. package/dist/es2019/ui/Toolbar/hooks/formatting-icons.js +1 -1
  22. package/dist/es2019/ui/Toolbar/types.js +10 -0
  23. package/dist/es2019/ui/toolbar-components.js +122 -0
  24. package/dist/esm/editor-commands/clear-formatting.js +93 -1
  25. package/dist/esm/{pm-plugins/commands.js → editor-commands/toggle-mark.js} +1 -1
  26. package/dist/esm/editor-commands/types.js +1 -0
  27. package/dist/esm/pm-plugins/clear-formatting-keymap.js +4 -4
  28. package/dist/esm/pm-plugins/keymap.js +1 -1
  29. package/dist/esm/textFormattingPlugin.js +17 -8
  30. package/dist/esm/ui/Toolbar/components/Component.js +137 -0
  31. package/dist/esm/ui/Toolbar/components/utils.js +120 -0
  32. package/dist/esm/ui/Toolbar/hooks/formatting-icons.js +1 -1
  33. package/dist/esm/ui/Toolbar/types.js +10 -0
  34. package/dist/esm/ui/toolbar-components.js +123 -0
  35. package/dist/types/editor-commands/clear-formatting.d.ts +6 -0
  36. package/dist/{types-ts4.5/pm-plugins/commands.d.ts → types/editor-commands/toggle-mark.d.ts} +2 -5
  37. package/dist/types/editor-commands/types.d.ts +6 -0
  38. package/dist/types/index.d.ts +1 -1
  39. package/dist/types/textFormattingPluginType.d.ts +4 -2
  40. package/dist/types/ui/Toolbar/components/Component.d.ts +11 -0
  41. package/dist/types/ui/Toolbar/components/utils.d.ts +38 -0
  42. package/dist/types/ui/Toolbar/types.d.ts +14 -0
  43. package/dist/types/ui/toolbar-components.d.ts +4 -0
  44. package/dist/types-ts4.5/editor-commands/clear-formatting.d.ts +6 -0
  45. package/dist/{types/pm-plugins/commands.d.ts → types-ts4.5/editor-commands/toggle-mark.d.ts} +2 -5
  46. package/dist/types-ts4.5/editor-commands/types.d.ts +6 -0
  47. package/dist/types-ts4.5/index.d.ts +1 -1
  48. package/dist/types-ts4.5/textFormattingPluginType.d.ts +4 -2
  49. package/dist/types-ts4.5/ui/Toolbar/components/Component.d.ts +11 -0
  50. package/dist/types-ts4.5/ui/Toolbar/components/utils.d.ts +38 -0
  51. package/dist/types-ts4.5/ui/Toolbar/types.d.ts +14 -0
  52. package/dist/types-ts4.5/ui/toolbar-components.d.ts +4 -0
  53. package/package.json +8 -6
@@ -0,0 +1,120 @@
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; }
4
+ import { useIntl } from 'react-intl-next';
5
+ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
6
+ import { toggleBold, toggleCode, toggleItalic, toggleStrikethrough, toggleSubscript, toggleSuperscript, toggleUnderline, tooltip } from '@atlaskit/editor-common/keymaps';
7
+ import { toolbarMessages } from '@atlaskit/editor-common/messages';
8
+ import { TEXT_FORMAT_OPTION_MENU_RANK } from '@atlaskit/editor-common/toolbar';
9
+ import { BoldIcon, ItalicIcon, UnderlineIcon, CodeIcon, StrikeThroughIcon, SubscriptIcon, SuperscriptIcon } from '@atlaskit/editor-toolbar';
10
+ import { toggleStrongWithAnalytics, toggleEmWithAnalytics, toggleUnderlineWithAnalytics, toggleCodeWithAnalytics, toggleStrikeWithAnalytics, toggleSubscriptWithAnalytics, toggleSuperscriptWithAnalytics } from '../../../editor-commands/toggle-mark';
11
+ import { getInputMethod } from '../input-method-utils';
12
+ import { ToolbarType } from '../types';
13
+ export var getInputMethodFromParentKeys = function getInputMethodFromParentKeys(parentKeys) {
14
+ var _parentKeys$at;
15
+ return getInputMethod(
16
+ // TODO: ED-28682 - replace with const
17
+ ((_parentKeys$at = parentKeys.at(-1)) === null || _parentKeys$at === void 0 ? void 0 : _parentKeys$at.key) === 'inline-text-toolbar' ? ToolbarType.FLOATING : ToolbarType.PRIMARY);
18
+ };
19
+ export var useComponentInfo = function useComponentInfo(_ref) {
20
+ var api = _ref.api,
21
+ optionType = _ref.optionType,
22
+ title = _ref.title,
23
+ shortcut = _ref.shortcut,
24
+ toggleMarkWithAnalyticsCallback = _ref.toggleMarkWithAnalyticsCallback,
25
+ parents = _ref.parents;
26
+ var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['textFormatting'], function (states) {
27
+ var _states$textFormattin, _states$textFormattin2, _states$textFormattin3, _states$textFormattin4;
28
+ return {
29
+ isActive: (_states$textFormattin = states.textFormattingState) === null || _states$textFormattin === void 0 ? void 0 : _states$textFormattin["".concat(optionType, "Active")],
30
+ isDisabled: (_states$textFormattin2 = states.textFormattingState) === null || _states$textFormattin2 === void 0 ? void 0 : _states$textFormattin2["".concat(optionType, "Disabled")],
31
+ isHidden: (_states$textFormattin3 = states.textFormattingState) === null || _states$textFormattin3 === void 0 ? void 0 : _states$textFormattin3["".concat(optionType, "Hidden")],
32
+ isPluginInitialised: (_states$textFormattin4 = states.textFormattingState) === null || _states$textFormattin4 === void 0 ? void 0 : _states$textFormattin4.isInitialised
33
+ };
34
+ }),
35
+ isActive = _useSharedPluginState.isActive,
36
+ isDisabled = _useSharedPluginState.isDisabled,
37
+ isHidden = _useSharedPluginState.isHidden,
38
+ isPluginInitialised = _useSharedPluginState.isPluginInitialised;
39
+ var formatOptionState;
40
+ if (!isPluginInitialised) {
41
+ formatOptionState = {
42
+ isActive: false,
43
+ isDisabled: true,
44
+ isHidden: false
45
+ };
46
+ } else {
47
+ formatOptionState = {
48
+ isActive: Boolean(isActive),
49
+ isDisabled: Boolean(isDisabled),
50
+ // TODO: ED-28682 - also need to check if mark is present in the schema
51
+ isHidden: Boolean(isHidden)
52
+ };
53
+ }
54
+ var _useIntl = useIntl(),
55
+ formatMessage = _useIntl.formatMessage;
56
+ var formatTitle = formatMessage(title);
57
+ var shortcutContent = tooltip(shortcut);
58
+ var ariaLabel = tooltip(shortcut, formatTitle);
59
+ var onClick = function onClick() {
60
+ var _api$analytics;
61
+ api === null || api === void 0 || api.core.actions.execute(toggleMarkWithAnalyticsCallback(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(getInputMethodFromParentKeys(parents)));
62
+ };
63
+ return _objectSpread(_objectSpread({}, formatOptionState), {}, {
64
+ formatTitle: formatTitle,
65
+ shortcutContent: shortcutContent,
66
+ ariaLabel: ariaLabel || formatTitle,
67
+ onClick: onClick
68
+ });
69
+ };
70
+ export var formatOptions = {
71
+ strong: {
72
+ rank: TEXT_FORMAT_OPTION_MENU_RANK.BOLD,
73
+ icon: BoldIcon,
74
+ title: toolbarMessages.bold,
75
+ command: toggleStrongWithAnalytics,
76
+ shortcut: toggleBold
77
+ },
78
+ em: {
79
+ rank: TEXT_FORMAT_OPTION_MENU_RANK.ITALIC,
80
+ icon: ItalicIcon,
81
+ title: toolbarMessages.italic,
82
+ command: toggleEmWithAnalytics,
83
+ shortcut: toggleItalic
84
+ },
85
+ underline: {
86
+ rank: TEXT_FORMAT_OPTION_MENU_RANK.UNDERLINE,
87
+ icon: UnderlineIcon,
88
+ title: toolbarMessages.underline,
89
+ command: toggleUnderlineWithAnalytics,
90
+ shortcut: toggleUnderline
91
+ },
92
+ strike: {
93
+ rank: TEXT_FORMAT_OPTION_MENU_RANK.STRIKETHROUGH,
94
+ icon: StrikeThroughIcon,
95
+ title: toolbarMessages.strike,
96
+ command: toggleStrikeWithAnalytics,
97
+ shortcut: toggleStrikethrough
98
+ },
99
+ code: {
100
+ rank: TEXT_FORMAT_OPTION_MENU_RANK.CODE,
101
+ icon: CodeIcon,
102
+ title: toolbarMessages.code,
103
+ command: toggleCodeWithAnalytics,
104
+ shortcut: toggleCode
105
+ },
106
+ subscript: {
107
+ rank: TEXT_FORMAT_OPTION_MENU_RANK.SUBSCRIPT,
108
+ icon: SubscriptIcon,
109
+ title: toolbarMessages.subscript,
110
+ command: toggleSubscriptWithAnalytics,
111
+ shortcut: toggleSubscript
112
+ },
113
+ superscript: {
114
+ rank: TEXT_FORMAT_OPTION_MENU_RANK.SUPERSCRIPT,
115
+ icon: SuperscriptIcon,
116
+ title: toolbarMessages.superscript,
117
+ command: toggleSuperscriptWithAnalytics,
118
+ shortcut: toggleSuperscript
119
+ }
120
+ };
@@ -18,7 +18,7 @@ import ItalicIcon from '@atlaskit/icon/core/migration/text-italic--editor-italic
18
18
  import TextStrikethroughIcon from '@atlaskit/icon/core/text-strikethrough';
19
19
  import UnderlineIcon from '@atlaskit/icon/core/text-underline';
20
20
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
21
- import { toggleCodeWithAnalytics, toggleEmWithAnalytics, toggleStrikeWithAnalytics, toggleStrongWithAnalytics, toggleSubscriptWithAnalytics, toggleSuperscriptWithAnalytics, toggleUnderlineWithAnalytics } from '../../../pm-plugins/commands';
21
+ import { toggleCodeWithAnalytics, toggleEmWithAnalytics, toggleStrikeWithAnalytics, toggleStrongWithAnalytics, toggleSubscriptWithAnalytics, toggleSuperscriptWithAnalytics, toggleUnderlineWithAnalytics } from '../../../editor-commands/toggle-mark';
22
22
  import { Subscript, Superscript } from '../icons';
23
23
  import { getInputMethod } from '../input-method-utils';
24
24
  import { IconTypes } from '../types';
@@ -8,6 +8,16 @@ export var IconTypes = /*#__PURE__*/function (IconTypes) {
8
8
  IconTypes["superscript"] = "superscript";
9
9
  return IconTypes;
10
10
  }({});
11
+ export var FormatOptions = /*#__PURE__*/function (FormatOptions) {
12
+ FormatOptions["strong"] = "strong";
13
+ FormatOptions["em"] = "em";
14
+ FormatOptions["underline"] = "underline";
15
+ FormatOptions["strike"] = "strike";
16
+ FormatOptions["code"] = "code";
17
+ FormatOptions["subscript"] = "subscript";
18
+ FormatOptions["superscript"] = "superscript";
19
+ return FormatOptions;
20
+ }({});
11
21
  export var ToolbarType = /*#__PURE__*/function (ToolbarType) {
12
22
  ToolbarType["PRIMARY"] = "primaryToolbar";
13
23
  ToolbarType["FLOATING"] = "floatingToolbar";
@@ -0,0 +1,123 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+ import React from 'react';
4
+ import { TEXT_FORMAT_CLEAR_MENU_RANK, TEXT_FORMAT_GROUP_RANK, TEXT_FORMAT_MENU_SECTION_RANK, TEXT_SECTION_RANK } from '@atlaskit/editor-common/toolbar';
5
+ import { ToolbarDropdownDivider } from '@atlaskit/editor-toolbar';
6
+ import { FormatMenuItem, FormatButton, ClearFormatMenuItem, MoreFormattingMenu } from './Toolbar/components/Component';
7
+ import { formatOptions } from './Toolbar/components/utils';
8
+ import { FormatOptions } from './Toolbar/types';
9
+ var getFormatMenuItems = function getFormatMenuItems(api) {
10
+ return Object.entries(formatOptions).map(function (_ref) {
11
+ var _ref2 = _slicedToArray(_ref, 2),
12
+ optionType = _ref2[0],
13
+ _ref2$ = _ref2[1],
14
+ icon = _ref2$.icon,
15
+ shortcut = _ref2$.shortcut,
16
+ title = _ref2$.title,
17
+ command = _ref2$.command,
18
+ rank = _ref2$.rank;
19
+ return {
20
+ type: 'menu-item',
21
+ key: optionType,
22
+ parents: [{
23
+ type: 'menu-section',
24
+ key: 'text-formatting-section',
25
+ rank: rank
26
+ }],
27
+ component: function component(_ref3) {
28
+ var parents = _ref3.parents;
29
+ return /*#__PURE__*/React.createElement(FormatMenuItem, {
30
+ api: api,
31
+ parents: parents,
32
+ icon: icon,
33
+ shortcut: shortcut,
34
+ title: title,
35
+ optionType: optionType,
36
+ toggleMarkWithAnalyticsCallback: command
37
+ });
38
+ }
39
+ };
40
+ });
41
+ };
42
+ export var getToolbarComponents = function getToolbarComponents(api) {
43
+ return [{
44
+ type: 'group',
45
+ key: 'text-formatting',
46
+ parents: [{
47
+ type: 'section',
48
+ key: 'text-section',
49
+ rank: TEXT_SECTION_RANK.FORMAT
50
+ }]
51
+ }, {
52
+ type: 'button',
53
+ key: 'bold',
54
+ parents: [{
55
+ type: 'group',
56
+ key: 'text-formatting',
57
+ rank: TEXT_FORMAT_GROUP_RANK.FORMAT_BUTTON
58
+ }],
59
+ component: function component(_ref4) {
60
+ var parents = _ref4.parents;
61
+ var _formatOptions$strong = formatOptions.strong,
62
+ icon = _formatOptions$strong.icon,
63
+ command = _formatOptions$strong.command,
64
+ shortcut = _formatOptions$strong.shortcut,
65
+ title = _formatOptions$strong.title;
66
+ return /*#__PURE__*/React.createElement(FormatButton, {
67
+ api: api,
68
+ parents: parents,
69
+ icon: icon,
70
+ title: title,
71
+ shortcut: shortcut,
72
+ optionType: FormatOptions.strong,
73
+ toggleMarkWithAnalyticsCallback: command
74
+ });
75
+ }
76
+ }, {
77
+ type: 'menu',
78
+ key: 'more-formatting',
79
+ parents: [{
80
+ type: 'group',
81
+ key: 'text-formatting',
82
+ rank: TEXT_FORMAT_GROUP_RANK.MORE_FORMATTING
83
+ }],
84
+ component: function component(_ref5) {
85
+ var children = _ref5.children,
86
+ groupLocation = _ref5.groupLocation;
87
+ return /*#__PURE__*/React.createElement(MoreFormattingMenu, {
88
+ groupLocation: groupLocation
89
+ }, children);
90
+ }
91
+ }, {
92
+ type: 'menu-section',
93
+ key: 'text-formatting-section',
94
+ parents: [{
95
+ type: 'menu',
96
+ key: 'more-formatting',
97
+ rank: TEXT_FORMAT_MENU_SECTION_RANK.FORMAT_OPTIONS
98
+ }]
99
+ }].concat(_toConsumableArray(getFormatMenuItems(api)), [{
100
+ type: 'menu-section',
101
+ key: 'clear-formatting-section',
102
+ parents: [{
103
+ type: 'menu',
104
+ key: 'more-formatting',
105
+ rank: TEXT_FORMAT_MENU_SECTION_RANK.CLEAR_FORMAT
106
+ }]
107
+ }, {
108
+ type: 'menu-item',
109
+ key: 'clear-formatting',
110
+ parents: [{
111
+ type: 'menu-section',
112
+ key: 'clear-formatting-section',
113
+ rank: TEXT_FORMAT_CLEAR_MENU_RANK.CLEAR_FORMAT
114
+ }],
115
+ component: function component(_ref6) {
116
+ var parents = _ref6.parents;
117
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ToolbarDropdownDivider, null), /*#__PURE__*/React.createElement(ClearFormatMenuItem, {
118
+ parents: parents,
119
+ api: api
120
+ }));
121
+ }
122
+ }]);
123
+ };
@@ -1,7 +1,13 @@
1
1
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
2
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
3
  import type { Command } from '@atlaskit/editor-common/types';
4
+ import type { ClearFormattingWithAnalyticsEditorCommand } from './types';
4
5
  export declare const FORMATTING_NODE_TYPES: string[];
5
6
  export declare const FORMATTING_MARK_TYPES: string[];
7
+ /**
8
+ * Consider removing this function when cleaning up platform_editor–toolbar_aifc
9
+ * @deprecated use `clearFormattingWithAnalyticsNext` instead, which returns EditorCommand
10
+ */
6
11
  export declare function clearFormattingWithAnalytics(inputMethod: INPUT_METHOD.TOOLBAR | INPUT_METHOD.SHORTCUT | INPUT_METHOD.FLOATING_TB, editorAnalyticsAPI: EditorAnalyticsAPI | undefined): Command;
7
12
  export declare function clearFormatting(inputMethod?: INPUT_METHOD.TOOLBAR | INPUT_METHOD.SHORTCUT | INPUT_METHOD.FLOATING_TB, editorAnalyticsAPI?: EditorAnalyticsAPI | undefined): Command;
13
+ export declare const clearFormattingWithAnalyticsNext: ClearFormattingWithAnalyticsEditorCommand;
@@ -1,8 +1,6 @@
1
- import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
- import type { EditorCommand, ExtractInjectionAPI, InputMethodBasic } from '@atlaskit/editor-common/types';
1
+ import type { EditorCommand, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
2
  import type { TextFormattingPlugin } from '../textFormattingPluginType';
4
- type ToggleMarkWithAnalyticsEditorCommand = (editorAnalyticsApi: EditorAnalyticsAPI | undefined, api?: ExtractInjectionAPI<TextFormattingPlugin>) => ToggleMarkEditorCommand;
5
- export type ToggleMarkEditorCommand = (inputMethod: InputMethodBasic) => EditorCommand;
3
+ import type { ToggleMarkWithAnalyticsEditorCommand } from './types';
6
4
  export declare const toggleEm: EditorCommand;
7
5
  export declare const toggleEmWithAnalytics: ToggleMarkWithAnalyticsEditorCommand;
8
6
  export declare const toggleStrike: EditorCommand;
@@ -19,4 +17,3 @@ export declare const toggleCode: ({ api }: {
19
17
  api: ExtractInjectionAPI<TextFormattingPlugin> | undefined;
20
18
  }) => EditorCommand;
21
19
  export declare const toggleCodeWithAnalytics: ToggleMarkWithAnalyticsEditorCommand;
22
- export {};
@@ -0,0 +1,6 @@
1
+ import type { EditorAnalyticsAPI, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
+ import type { EditorCommand, ExtractInjectionAPI, InputMethodBasic } from '@atlaskit/editor-common/types';
3
+ import type { TextFormattingPlugin } from '../textFormattingPluginType';
4
+ export type ToggleMarkWithAnalyticsEditorCommand = (editorAnalyticsApi: EditorAnalyticsAPI | undefined, api?: ExtractInjectionAPI<TextFormattingPlugin>) => ToggleMarkEditorCommand;
5
+ export type ToggleMarkEditorCommand = (inputMethod: InputMethodBasic) => EditorCommand;
6
+ export type ClearFormattingWithAnalyticsEditorCommand = (editorAnalyticsApi: EditorAnalyticsAPI | undefined) => (inputMethod: INPUT_METHOD.TOOLBAR | INPUT_METHOD.SHORTCUT | INPUT_METHOD.FLOATING_TB) => EditorCommand;
@@ -1,3 +1,3 @@
1
1
  export { textFormattingPlugin } from './textFormattingPlugin';
2
2
  export type { TextFormattingPlugin, TextFormattingPluginOptions } from './textFormattingPluginType';
3
- export type { ToggleMarkEditorCommand } from './pm-plugins/commands';
3
+ export type { ToggleMarkEditorCommand } from './editor-commands/types';
@@ -3,8 +3,9 @@ import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
3
3
  import type { BasePlugin } from '@atlaskit/editor-plugin-base';
4
4
  import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
5
5
  import type { SelectionToolbarPlugin } from '@atlaskit/editor-plugin-selection-toolbar';
6
+ import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
6
7
  import type { UserPreferencesPlugin } from '@atlaskit/editor-plugin-user-preferences';
7
- import type { ToggleMarkEditorCommand } from './pm-plugins/commands';
8
+ import type { ToggleMarkEditorCommand } from './editor-commands/types';
8
9
  export type TextFormattingPluginOptions = CommonTextFormattingOptions;
9
10
  export type TextFormattingPlugin = NextEditorPlugin<'textFormatting', {
10
11
  pluginConfiguration: TextFormattingPluginOptions | undefined;
@@ -13,7 +14,8 @@ export type TextFormattingPlugin = NextEditorPlugin<'textFormatting', {
13
14
  OptionalPlugin<PrimaryToolbarPlugin>,
14
15
  OptionalPlugin<BasePlugin>,
15
16
  OptionalPlugin<SelectionToolbarPlugin>,
16
- OptionalPlugin<UserPreferencesPlugin>
17
+ OptionalPlugin<UserPreferencesPlugin>,
18
+ OptionalPlugin<ToolbarPlugin>
17
19
  ];
18
20
  commands: {
19
21
  toggleSuperscript: ToggleMarkEditorCommand;
@@ -0,0 +1,11 @@
1
+ import type { ReactNode } from 'react';
2
+ import React from 'react';
3
+ import { type ToolbarButtonGroupLocation } from '@atlaskit/editor-toolbar';
4
+ import type { FormatComponentProps } from './utils';
5
+ export declare const FormatMenuItem: ({ parents, api, optionType, toggleMarkWithAnalyticsCallback, icon, shortcut, title, }: FormatComponentProps) => React.JSX.Element | null;
6
+ export declare const FormatButton: ({ parents, api, optionType, toggleMarkWithAnalyticsCallback, icon, shortcut, title, groupLocation, }: FormatComponentProps) => React.JSX.Element;
7
+ export declare const ClearFormatMenuItem: ({ api, parents, }: Pick<FormatComponentProps, 'api' | 'parents'>) => React.JSX.Element | null;
8
+ export declare const MoreFormattingMenu: ({ children, groupLocation, }: {
9
+ children?: ReactNode;
10
+ groupLocation?: ToolbarButtonGroupLocation | undefined;
11
+ }) => React.JSX.Element;
@@ -0,0 +1,38 @@
1
+ import type { MessageDescriptor } from 'react-intl-next';
2
+ import type { Keymap } from '@atlaskit/editor-common/keymaps';
3
+ import { type ExtractInjectionAPI } from '@atlaskit/editor-common/types';
4
+ import { type IconComponent, type ToolbarButtonGroupLocation } from '@atlaskit/editor-toolbar';
5
+ import type { ComponentTypes } from '@atlaskit/editor-toolbar-model';
6
+ import type { ToggleMarkWithAnalyticsEditorCommand, ClearFormattingWithAnalyticsEditorCommand } from '../../../editor-commands/types';
7
+ import { type TextFormattingPlugin } from '../../../textFormattingPluginType';
8
+ import type { FormatOptions } from '../types';
9
+ export type FormatComponentProps = {
10
+ api?: ExtractInjectionAPI<TextFormattingPlugin>;
11
+ parents: ComponentTypes;
12
+ icon: IconComponent;
13
+ shortcut: Keymap;
14
+ title: MessageDescriptor;
15
+ optionType: string;
16
+ toggleMarkWithAnalyticsCallback: ToggleMarkWithAnalyticsEditorCommand | ClearFormattingWithAnalyticsEditorCommand;
17
+ ariaLabel?: string;
18
+ groupLocation?: ToolbarButtonGroupLocation;
19
+ };
20
+ export declare const getInputMethodFromParentKeys: (parentKeys: ComponentTypes) => import("@atlaskit/editor-common/types").InputMethodToolbar;
21
+ export declare const useComponentInfo: ({ api, optionType, title, shortcut, toggleMarkWithAnalyticsCallback, parents, }: Omit<FormatComponentProps, 'icon' | 'ariaLabel' | 'groupLocation'>) => {
22
+ formatTitle: string;
23
+ shortcutContent: string | undefined;
24
+ ariaLabel: string;
25
+ onClick: () => void;
26
+ isActive: boolean;
27
+ isDisabled: boolean;
28
+ isHidden: boolean;
29
+ };
30
+ type FormatOptionInfo = {
31
+ rank: number;
32
+ icon: IconComponent;
33
+ title: MessageDescriptor;
34
+ command: ToggleMarkWithAnalyticsEditorCommand;
35
+ shortcut: Keymap;
36
+ };
37
+ export declare const formatOptions: Record<FormatOptions, FormatOptionInfo>;
38
+ export {};
@@ -12,6 +12,20 @@ export declare enum IconTypes {
12
12
  subscript = "subscript",
13
13
  superscript = "superscript"
14
14
  }
15
+ export declare enum FormatOptions {
16
+ strong = "strong",
17
+ em = "em",
18
+ underline = "underline",
19
+ strike = "strike",
20
+ code = "code",
21
+ subscript = "subscript",
22
+ superscript = "superscript"
23
+ }
24
+ export type FormatOptionState = {
25
+ isActive: boolean;
26
+ isDisabled: boolean;
27
+ isHidden: boolean;
28
+ };
15
29
  export interface MenuIconItem extends MenuItem {
16
30
  command: Command;
17
31
  iconMark?: IconTypes;
@@ -0,0 +1,4 @@
1
+ import { type ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
+ import { type RegisterComponent } from '@atlaskit/editor-toolbar-model';
3
+ import { type TextFormattingPlugin } from '../textFormattingPluginType';
4
+ export declare const getToolbarComponents: (api?: ExtractInjectionAPI<TextFormattingPlugin>) => RegisterComponent[];
@@ -1,7 +1,13 @@
1
1
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
2
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
3
  import type { Command } from '@atlaskit/editor-common/types';
4
+ import type { ClearFormattingWithAnalyticsEditorCommand } from './types';
4
5
  export declare const FORMATTING_NODE_TYPES: string[];
5
6
  export declare const FORMATTING_MARK_TYPES: string[];
7
+ /**
8
+ * Consider removing this function when cleaning up platform_editor–toolbar_aifc
9
+ * @deprecated use `clearFormattingWithAnalyticsNext` instead, which returns EditorCommand
10
+ */
6
11
  export declare function clearFormattingWithAnalytics(inputMethod: INPUT_METHOD.TOOLBAR | INPUT_METHOD.SHORTCUT | INPUT_METHOD.FLOATING_TB, editorAnalyticsAPI: EditorAnalyticsAPI | undefined): Command;
7
12
  export declare function clearFormatting(inputMethod?: INPUT_METHOD.TOOLBAR | INPUT_METHOD.SHORTCUT | INPUT_METHOD.FLOATING_TB, editorAnalyticsAPI?: EditorAnalyticsAPI | undefined): Command;
13
+ export declare const clearFormattingWithAnalyticsNext: ClearFormattingWithAnalyticsEditorCommand;
@@ -1,8 +1,6 @@
1
- import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
- import type { EditorCommand, ExtractInjectionAPI, InputMethodBasic } from '@atlaskit/editor-common/types';
1
+ import type { EditorCommand, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
2
  import type { TextFormattingPlugin } from '../textFormattingPluginType';
4
- type ToggleMarkWithAnalyticsEditorCommand = (editorAnalyticsApi: EditorAnalyticsAPI | undefined, api?: ExtractInjectionAPI<TextFormattingPlugin>) => ToggleMarkEditorCommand;
5
- export type ToggleMarkEditorCommand = (inputMethod: InputMethodBasic) => EditorCommand;
3
+ import type { ToggleMarkWithAnalyticsEditorCommand } from './types';
6
4
  export declare const toggleEm: EditorCommand;
7
5
  export declare const toggleEmWithAnalytics: ToggleMarkWithAnalyticsEditorCommand;
8
6
  export declare const toggleStrike: EditorCommand;
@@ -19,4 +17,3 @@ export declare const toggleCode: ({ api }: {
19
17
  api: ExtractInjectionAPI<TextFormattingPlugin> | undefined;
20
18
  }) => EditorCommand;
21
19
  export declare const toggleCodeWithAnalytics: ToggleMarkWithAnalyticsEditorCommand;
22
- export {};
@@ -0,0 +1,6 @@
1
+ import type { EditorAnalyticsAPI, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
+ import type { EditorCommand, ExtractInjectionAPI, InputMethodBasic } from '@atlaskit/editor-common/types';
3
+ import type { TextFormattingPlugin } from '../textFormattingPluginType';
4
+ export type ToggleMarkWithAnalyticsEditorCommand = (editorAnalyticsApi: EditorAnalyticsAPI | undefined, api?: ExtractInjectionAPI<TextFormattingPlugin>) => ToggleMarkEditorCommand;
5
+ export type ToggleMarkEditorCommand = (inputMethod: InputMethodBasic) => EditorCommand;
6
+ export type ClearFormattingWithAnalyticsEditorCommand = (editorAnalyticsApi: EditorAnalyticsAPI | undefined) => (inputMethod: INPUT_METHOD.TOOLBAR | INPUT_METHOD.SHORTCUT | INPUT_METHOD.FLOATING_TB) => EditorCommand;
@@ -1,3 +1,3 @@
1
1
  export { textFormattingPlugin } from './textFormattingPlugin';
2
2
  export type { TextFormattingPlugin, TextFormattingPluginOptions } from './textFormattingPluginType';
3
- export type { ToggleMarkEditorCommand } from './pm-plugins/commands';
3
+ export type { ToggleMarkEditorCommand } from './editor-commands/types';
@@ -3,8 +3,9 @@ import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
3
3
  import type { BasePlugin } from '@atlaskit/editor-plugin-base';
4
4
  import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
5
5
  import type { SelectionToolbarPlugin } from '@atlaskit/editor-plugin-selection-toolbar';
6
+ import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
6
7
  import type { UserPreferencesPlugin } from '@atlaskit/editor-plugin-user-preferences';
7
- import type { ToggleMarkEditorCommand } from './pm-plugins/commands';
8
+ import type { ToggleMarkEditorCommand } from './editor-commands/types';
8
9
  export type TextFormattingPluginOptions = CommonTextFormattingOptions;
9
10
  export type TextFormattingPlugin = NextEditorPlugin<'textFormatting', {
10
11
  pluginConfiguration: TextFormattingPluginOptions | undefined;
@@ -13,7 +14,8 @@ export type TextFormattingPlugin = NextEditorPlugin<'textFormatting', {
13
14
  OptionalPlugin<PrimaryToolbarPlugin>,
14
15
  OptionalPlugin<BasePlugin>,
15
16
  OptionalPlugin<SelectionToolbarPlugin>,
16
- OptionalPlugin<UserPreferencesPlugin>
17
+ OptionalPlugin<UserPreferencesPlugin>,
18
+ OptionalPlugin<ToolbarPlugin>
17
19
  ];
18
20
  commands: {
19
21
  toggleSuperscript: ToggleMarkEditorCommand;
@@ -0,0 +1,11 @@
1
+ import type { ReactNode } from 'react';
2
+ import React from 'react';
3
+ import { type ToolbarButtonGroupLocation } from '@atlaskit/editor-toolbar';
4
+ import type { FormatComponentProps } from './utils';
5
+ export declare const FormatMenuItem: ({ parents, api, optionType, toggleMarkWithAnalyticsCallback, icon, shortcut, title, }: FormatComponentProps) => React.JSX.Element | null;
6
+ export declare const FormatButton: ({ parents, api, optionType, toggleMarkWithAnalyticsCallback, icon, shortcut, title, groupLocation, }: FormatComponentProps) => React.JSX.Element;
7
+ export declare const ClearFormatMenuItem: ({ api, parents, }: Pick<FormatComponentProps, 'api' | 'parents'>) => React.JSX.Element | null;
8
+ export declare const MoreFormattingMenu: ({ children, groupLocation, }: {
9
+ children?: ReactNode;
10
+ groupLocation?: ToolbarButtonGroupLocation | undefined;
11
+ }) => React.JSX.Element;
@@ -0,0 +1,38 @@
1
+ import type { MessageDescriptor } from 'react-intl-next';
2
+ import type { Keymap } from '@atlaskit/editor-common/keymaps';
3
+ import { type ExtractInjectionAPI } from '@atlaskit/editor-common/types';
4
+ import { type IconComponent, type ToolbarButtonGroupLocation } from '@atlaskit/editor-toolbar';
5
+ import type { ComponentTypes } from '@atlaskit/editor-toolbar-model';
6
+ import type { ToggleMarkWithAnalyticsEditorCommand, ClearFormattingWithAnalyticsEditorCommand } from '../../../editor-commands/types';
7
+ import { type TextFormattingPlugin } from '../../../textFormattingPluginType';
8
+ import type { FormatOptions } from '../types';
9
+ export type FormatComponentProps = {
10
+ api?: ExtractInjectionAPI<TextFormattingPlugin>;
11
+ parents: ComponentTypes;
12
+ icon: IconComponent;
13
+ shortcut: Keymap;
14
+ title: MessageDescriptor;
15
+ optionType: string;
16
+ toggleMarkWithAnalyticsCallback: ToggleMarkWithAnalyticsEditorCommand | ClearFormattingWithAnalyticsEditorCommand;
17
+ ariaLabel?: string;
18
+ groupLocation?: ToolbarButtonGroupLocation;
19
+ };
20
+ export declare const getInputMethodFromParentKeys: (parentKeys: ComponentTypes) => import("@atlaskit/editor-common/types").InputMethodToolbar;
21
+ export declare const useComponentInfo: ({ api, optionType, title, shortcut, toggleMarkWithAnalyticsCallback, parents, }: Omit<FormatComponentProps, 'icon' | 'ariaLabel' | 'groupLocation'>) => {
22
+ formatTitle: string;
23
+ shortcutContent: string | undefined;
24
+ ariaLabel: string;
25
+ onClick: () => void;
26
+ isActive: boolean;
27
+ isDisabled: boolean;
28
+ isHidden: boolean;
29
+ };
30
+ type FormatOptionInfo = {
31
+ rank: number;
32
+ icon: IconComponent;
33
+ title: MessageDescriptor;
34
+ command: ToggleMarkWithAnalyticsEditorCommand;
35
+ shortcut: Keymap;
36
+ };
37
+ export declare const formatOptions: Record<FormatOptions, FormatOptionInfo>;
38
+ export {};
@@ -12,6 +12,20 @@ export declare enum IconTypes {
12
12
  subscript = "subscript",
13
13
  superscript = "superscript"
14
14
  }
15
+ export declare enum FormatOptions {
16
+ strong = "strong",
17
+ em = "em",
18
+ underline = "underline",
19
+ strike = "strike",
20
+ code = "code",
21
+ subscript = "subscript",
22
+ superscript = "superscript"
23
+ }
24
+ export type FormatOptionState = {
25
+ isActive: boolean;
26
+ isDisabled: boolean;
27
+ isHidden: boolean;
28
+ };
15
29
  export interface MenuIconItem extends MenuItem {
16
30
  command: Command;
17
31
  iconMark?: IconTypes;
@@ -0,0 +1,4 @@
1
+ import { type ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
+ import { type RegisterComponent } from '@atlaskit/editor-toolbar-model';
3
+ import { type TextFormattingPlugin } from '../textFormattingPluginType';
4
+ export declare const getToolbarComponents: (api?: ExtractInjectionAPI<TextFormattingPlugin>) => RegisterComponent[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-text-formatting",
3
- "version": "3.0.7",
3
+ "version": "3.0.8",
4
4
  "description": "Text-formatting plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -37,28 +37,30 @@
37
37
  "@atlaskit/editor-plugin-base": "^4.1.0",
38
38
  "@atlaskit/editor-plugin-primary-toolbar": "^4.1.0",
39
39
  "@atlaskit/editor-plugin-selection-toolbar": "^4.2.0",
40
+ "@atlaskit/editor-plugin-toolbar": "^0.0.5",
40
41
  "@atlaskit/editor-prosemirror": "7.0.0",
41
42
  "@atlaskit/editor-shared-styles": "^3.5.0",
42
43
  "@atlaskit/editor-tables": "^2.9.0",
44
+ "@atlaskit/editor-toolbar": "^0.0.9",
45
+ "@atlaskit/editor-toolbar-model": "^0.0.4",
43
46
  "@atlaskit/icon": "^27.9.0",
44
47
  "@atlaskit/platform-feature-flags": "^1.1.0",
45
- "@atlaskit/prosemirror-input-rules": "^3.3.0",
46
- "@atlaskit/tmp-editor-statsig": "^9.22.0",
48
+ "@atlaskit/prosemirror-input-rules": "^3.4.0",
49
+ "@atlaskit/tmp-editor-statsig": "^9.24.0",
47
50
  "@atlaskit/tokens": "^6.0.0",
48
51
  "@babel/runtime": "^7.0.0",
49
52
  "@emotion/react": "^11.7.1",
50
53
  "react-intl-next": "npm:react-intl@^5.18.1"
51
54
  },
52
55
  "peerDependencies": {
53
- "@atlaskit/editor-common": "^107.16.0",
56
+ "@atlaskit/editor-common": "^107.17.0",
54
57
  "react": "^18.2.0"
55
58
  },
56
59
  "devDependencies": {
57
60
  "@atlaskit/editor-plugin-composition": "^2.0.0",
58
61
  "@atlaskit/editor-plugin-decorations": "^3.0.0",
59
62
  "@atlaskit/editor-plugin-feature-flags": "^2.0.0",
60
- "@testing-library/react": "^13.4.0",
61
- "typescript": "~5.4.2"
63
+ "@testing-library/react": "^13.4.0"
62
64
  },
63
65
  "techstack": {
64
66
  "@atlassian/frontend": {