@atlaskit/editor-plugin-text-formatting 5.2.2 → 5.3.1
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 +19 -0
- package/dist/cjs/ui/Toolbar/components/BoldButtonGroup.js +63 -0
- package/dist/cjs/ui/Toolbar/components/TextFormattingGroupForInlineToolbar.js +53 -0
- package/dist/cjs/ui/Toolbar/components/TextFormattingGroups.js +111 -0
- package/dist/cjs/ui/Toolbar/components/TextFormattingMenuGroup.js +118 -0
- package/dist/cjs/ui/Toolbar/components/UnderlineButtonGroup.js +63 -0
- package/dist/cjs/ui/toolbar-components.js +20 -47
- package/dist/es2019/ui/Toolbar/components/BoldButtonGroup.js +59 -0
- package/dist/es2019/ui/Toolbar/components/TextFormattingGroupForInlineToolbar.js +47 -0
- package/dist/es2019/ui/Toolbar/components/TextFormattingGroups.js +112 -0
- package/dist/es2019/ui/Toolbar/components/TextFormattingMenuGroup.js +109 -0
- package/dist/es2019/ui/Toolbar/components/UnderlineButtonGroup.js +59 -0
- package/dist/es2019/ui/toolbar-components.js +12 -37
- package/dist/esm/ui/Toolbar/components/BoldButtonGroup.js +56 -0
- package/dist/esm/ui/Toolbar/components/TextFormattingGroupForInlineToolbar.js +46 -0
- package/dist/esm/ui/Toolbar/components/TextFormattingGroups.js +104 -0
- package/dist/esm/ui/Toolbar/components/TextFormattingMenuGroup.js +111 -0
- package/dist/esm/ui/Toolbar/components/UnderlineButtonGroup.js +56 -0
- package/dist/esm/ui/toolbar-components.js +20 -47
- package/dist/types/ui/Toolbar/components/BoldButtonGroup.d.ts +4 -0
- package/dist/types/ui/Toolbar/components/TextFormattingGroupForInlineToolbar.d.ts +4 -0
- package/dist/types/ui/Toolbar/components/TextFormattingGroups.d.ts +4 -0
- package/dist/types/ui/Toolbar/components/TextFormattingMenuGroup.d.ts +4 -0
- package/dist/types/ui/Toolbar/components/UnderlineButtonGroup.d.ts +4 -0
- package/dist/types/ui/toolbar-components.d.ts +1 -0
- package/dist/types-ts4.5/ui/Toolbar/components/BoldButtonGroup.d.ts +4 -0
- package/dist/types-ts4.5/ui/Toolbar/components/TextFormattingGroupForInlineToolbar.d.ts +4 -0
- package/dist/types-ts4.5/ui/Toolbar/components/TextFormattingGroups.d.ts +4 -0
- package/dist/types-ts4.5/ui/Toolbar/components/TextFormattingMenuGroup.d.ts +4 -0
- package/dist/types-ts4.5/ui/Toolbar/components/UnderlineButtonGroup.d.ts +4 -0
- package/dist/types-ts4.5/ui/toolbar-components.d.ts +1 -0
- package/package.json +7 -7
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TEXT_FORMATTING_GROUP, TEXT_FORMATTING_HERO_BUTTON, TEXT_FORMATTING_GROUP_COLLAPSED, TEXT_FORMATTING_HERO_BUTTON_COLLAPSED, TEXT_SECTION_PRIMARY_TOOLBAR, TEXT_FORMAT_GROUP_RANK, TEXT_FORMAT_GROUP_COLLAPSED_RANK, TEXT_SECTION_PRIMARY_TOOLBAR_RANK, useEditorToolbar } from '@atlaskit/editor-common/toolbar';
|
|
3
|
+
import { Show, ToolbarButtonGroup } from '@atlaskit/editor-toolbar';
|
|
4
|
+
import { FormatOptions } from '../types';
|
|
5
|
+
import { FormatButton } from './Component';
|
|
6
|
+
import { formatOptions } from './utils';
|
|
7
|
+
const TextFormattingGroup = ({
|
|
8
|
+
children
|
|
9
|
+
}) => {
|
|
10
|
+
const {
|
|
11
|
+
editorAppearance
|
|
12
|
+
} = useEditorToolbar();
|
|
13
|
+
if (editorAppearance === 'full-page') {
|
|
14
|
+
return /*#__PURE__*/React.createElement(Show, {
|
|
15
|
+
above: "xl"
|
|
16
|
+
}, /*#__PURE__*/React.createElement(ToolbarButtonGroup, null, children));
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const TextFormattingGroupCollapsed = ({
|
|
20
|
+
children
|
|
21
|
+
}) => {
|
|
22
|
+
const {
|
|
23
|
+
editorAppearance
|
|
24
|
+
} = useEditorToolbar();
|
|
25
|
+
if (editorAppearance === 'full-page') {
|
|
26
|
+
return /*#__PURE__*/React.createElement(Show, {
|
|
27
|
+
below: "xl"
|
|
28
|
+
}, /*#__PURE__*/React.createElement(ToolbarButtonGroup, null, children));
|
|
29
|
+
}
|
|
30
|
+
return /*#__PURE__*/React.createElement(ToolbarButtonGroup, null, children);
|
|
31
|
+
};
|
|
32
|
+
export const textFormattingGroupForPrimaryToolbar = api => [{
|
|
33
|
+
type: TEXT_FORMATTING_GROUP.type,
|
|
34
|
+
key: TEXT_FORMATTING_GROUP.key,
|
|
35
|
+
parents: [{
|
|
36
|
+
type: TEXT_SECTION_PRIMARY_TOOLBAR.type,
|
|
37
|
+
key: TEXT_SECTION_PRIMARY_TOOLBAR.key,
|
|
38
|
+
rank: TEXT_SECTION_PRIMARY_TOOLBAR_RANK[TEXT_FORMATTING_GROUP.key]
|
|
39
|
+
}],
|
|
40
|
+
component: ({
|
|
41
|
+
children
|
|
42
|
+
}) => {
|
|
43
|
+
return /*#__PURE__*/React.createElement(TextFormattingGroup, null, children);
|
|
44
|
+
}
|
|
45
|
+
}, {
|
|
46
|
+
type: TEXT_FORMATTING_GROUP_COLLAPSED.type,
|
|
47
|
+
key: TEXT_FORMATTING_GROUP_COLLAPSED.key,
|
|
48
|
+
parents: [{
|
|
49
|
+
type: TEXT_SECTION_PRIMARY_TOOLBAR.type,
|
|
50
|
+
key: TEXT_SECTION_PRIMARY_TOOLBAR.key,
|
|
51
|
+
rank: TEXT_SECTION_PRIMARY_TOOLBAR_RANK[TEXT_FORMATTING_GROUP.key]
|
|
52
|
+
}],
|
|
53
|
+
component: ({
|
|
54
|
+
children
|
|
55
|
+
}) => {
|
|
56
|
+
return /*#__PURE__*/React.createElement(TextFormattingGroupCollapsed, null, children);
|
|
57
|
+
}
|
|
58
|
+
}, {
|
|
59
|
+
type: TEXT_FORMATTING_HERO_BUTTON.type,
|
|
60
|
+
key: TEXT_FORMATTING_HERO_BUTTON.key,
|
|
61
|
+
parents: [{
|
|
62
|
+
type: TEXT_FORMATTING_GROUP.type,
|
|
63
|
+
key: TEXT_FORMATTING_GROUP.key,
|
|
64
|
+
rank: TEXT_FORMAT_GROUP_RANK[TEXT_FORMATTING_HERO_BUTTON.key]
|
|
65
|
+
}],
|
|
66
|
+
component: ({
|
|
67
|
+
parents
|
|
68
|
+
}) => {
|
|
69
|
+
const {
|
|
70
|
+
icon,
|
|
71
|
+
command,
|
|
72
|
+
shortcut,
|
|
73
|
+
title
|
|
74
|
+
} = formatOptions().em;
|
|
75
|
+
return /*#__PURE__*/React.createElement(FormatButton, {
|
|
76
|
+
api: api,
|
|
77
|
+
parents: parents,
|
|
78
|
+
icon: icon,
|
|
79
|
+
title: title,
|
|
80
|
+
shortcut: shortcut,
|
|
81
|
+
optionType: FormatOptions.em,
|
|
82
|
+
toggleMarkWithAnalyticsCallback: command
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}, {
|
|
86
|
+
type: TEXT_FORMATTING_HERO_BUTTON_COLLAPSED.type,
|
|
87
|
+
key: TEXT_FORMATTING_HERO_BUTTON_COLLAPSED.key,
|
|
88
|
+
parents: [{
|
|
89
|
+
type: TEXT_FORMATTING_GROUP_COLLAPSED.type,
|
|
90
|
+
key: TEXT_FORMATTING_GROUP_COLLAPSED.key,
|
|
91
|
+
rank: TEXT_FORMAT_GROUP_COLLAPSED_RANK[TEXT_FORMATTING_HERO_BUTTON_COLLAPSED.key]
|
|
92
|
+
}],
|
|
93
|
+
component: ({
|
|
94
|
+
parents
|
|
95
|
+
}) => {
|
|
96
|
+
const {
|
|
97
|
+
icon,
|
|
98
|
+
command,
|
|
99
|
+
shortcut,
|
|
100
|
+
title
|
|
101
|
+
} = formatOptions().strong;
|
|
102
|
+
return /*#__PURE__*/React.createElement(FormatButton, {
|
|
103
|
+
api: api,
|
|
104
|
+
parents: parents,
|
|
105
|
+
icon: icon,
|
|
106
|
+
title: title,
|
|
107
|
+
shortcut: shortcut,
|
|
108
|
+
optionType: FormatOptions.strong,
|
|
109
|
+
toggleMarkWithAnalyticsCallback: command
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}];
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CLEAR_FORMARTTING_MENU_SECTION, CLEAR_FORMATTING_MENU_ITEM, TEXT_FORMATTING_MENU, TEXT_FORMATTING_MENU_SECTION, TEXT_FORMATTING_GROUP, TEXT_FORMATTING_GROUP_COLLAPSED, TEXT_FORMATTING_GROUP_INLINE, TEXT_FORMATTING_HERO_BUTTON, TEXT_FORMAT_GROUP_RANK, TEXT_FORMAT_MENU_RANK, CLEAR_FORMARTTING_MENU_SECTION_RANK, TEXT_COLLAPSED_MENU_RANK, TEXT_COLLAPSED_MENU } from '@atlaskit/editor-common/toolbar';
|
|
3
|
+
import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
|
|
4
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
5
|
+
import { ClearFormatMenuItem, MoreFormattingMenu, MenuSection, FormatMenuItem } from './Component';
|
|
6
|
+
import { formatOptions } from './utils';
|
|
7
|
+
const getFormatMenuItems = api => {
|
|
8
|
+
return Object.entries(formatOptions()).map(([optionType, {
|
|
9
|
+
icon,
|
|
10
|
+
shortcut,
|
|
11
|
+
title,
|
|
12
|
+
command,
|
|
13
|
+
rank,
|
|
14
|
+
key
|
|
15
|
+
}]) => {
|
|
16
|
+
return {
|
|
17
|
+
type: 'menu-item',
|
|
18
|
+
key,
|
|
19
|
+
parents: [{
|
|
20
|
+
type: TEXT_FORMATTING_MENU_SECTION.type,
|
|
21
|
+
key: TEXT_FORMATTING_MENU_SECTION.key,
|
|
22
|
+
rank
|
|
23
|
+
}],
|
|
24
|
+
component: ({
|
|
25
|
+
parents
|
|
26
|
+
}) => {
|
|
27
|
+
return /*#__PURE__*/React.createElement(FormatMenuItem, {
|
|
28
|
+
api: api,
|
|
29
|
+
parents: parents,
|
|
30
|
+
icon: icon,
|
|
31
|
+
shortcut: shortcut,
|
|
32
|
+
title: title,
|
|
33
|
+
optionType: optionType,
|
|
34
|
+
toggleMarkWithAnalyticsCallback: command
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
export const textFormattingMenuGroup = api => [{
|
|
41
|
+
type: TEXT_FORMATTING_MENU.type,
|
|
42
|
+
key: TEXT_FORMATTING_MENU.key,
|
|
43
|
+
parents: [{
|
|
44
|
+
type: TEXT_FORMATTING_GROUP.type,
|
|
45
|
+
key: TEXT_FORMATTING_GROUP.key,
|
|
46
|
+
rank: TEXT_FORMAT_GROUP_RANK[TEXT_FORMATTING_MENU.key]
|
|
47
|
+
}, {
|
|
48
|
+
type: TEXT_FORMATTING_GROUP_COLLAPSED.type,
|
|
49
|
+
key: TEXT_FORMATTING_GROUP_COLLAPSED.key,
|
|
50
|
+
rank: TEXT_FORMAT_GROUP_RANK[TEXT_FORMATTING_MENU.key]
|
|
51
|
+
}, {
|
|
52
|
+
type: TEXT_FORMATTING_GROUP_INLINE.type,
|
|
53
|
+
key: TEXT_FORMATTING_GROUP_INLINE.key,
|
|
54
|
+
rank: TEXT_FORMAT_GROUP_RANK[TEXT_FORMATTING_HERO_BUTTON.key]
|
|
55
|
+
}],
|
|
56
|
+
component: ({
|
|
57
|
+
children
|
|
58
|
+
}) => {
|
|
59
|
+
return /*#__PURE__*/React.createElement(MoreFormattingMenu, null, children);
|
|
60
|
+
}
|
|
61
|
+
}, {
|
|
62
|
+
type: TEXT_FORMATTING_MENU_SECTION.type,
|
|
63
|
+
key: TEXT_FORMATTING_MENU_SECTION.key,
|
|
64
|
+
parents: [{
|
|
65
|
+
type: TEXT_FORMATTING_MENU.type,
|
|
66
|
+
key: TEXT_FORMATTING_MENU.key,
|
|
67
|
+
rank: TEXT_FORMAT_MENU_RANK[TEXT_FORMATTING_MENU_SECTION.key]
|
|
68
|
+
}, ...(expValEquals('platform_editor_toolbar_aifc_responsive', 'isEnabled', true) ? [{
|
|
69
|
+
type: TEXT_COLLAPSED_MENU.type,
|
|
70
|
+
key: TEXT_COLLAPSED_MENU.key,
|
|
71
|
+
rank: TEXT_COLLAPSED_MENU_RANK[TEXT_FORMATTING_MENU_SECTION.key]
|
|
72
|
+
}] : [])],
|
|
73
|
+
component: expValEquals('platform_editor_toolbar_aifc_responsive', 'isEnabled', true) ? MenuSection : undefined
|
|
74
|
+
}, ...getFormatMenuItems(api), {
|
|
75
|
+
type: CLEAR_FORMARTTING_MENU_SECTION.type,
|
|
76
|
+
key: CLEAR_FORMARTTING_MENU_SECTION.key,
|
|
77
|
+
parents: [{
|
|
78
|
+
type: TEXT_FORMATTING_MENU.type,
|
|
79
|
+
key: TEXT_FORMATTING_MENU.key,
|
|
80
|
+
rank: TEXT_FORMAT_MENU_RANK[CLEAR_FORMARTTING_MENU_SECTION.key]
|
|
81
|
+
}, ...(expValEquals('platform_editor_toolbar_aifc_responsive', 'isEnabled', true) ? [{
|
|
82
|
+
type: TEXT_COLLAPSED_MENU.type,
|
|
83
|
+
key: TEXT_COLLAPSED_MENU.key,
|
|
84
|
+
rank: TEXT_COLLAPSED_MENU_RANK[CLEAR_FORMARTTING_MENU_SECTION.key]
|
|
85
|
+
}] : [])],
|
|
86
|
+
component: ({
|
|
87
|
+
children
|
|
88
|
+
}) => {
|
|
89
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
|
|
90
|
+
hasSeparator: true
|
|
91
|
+
}, children);
|
|
92
|
+
}
|
|
93
|
+
}, {
|
|
94
|
+
type: CLEAR_FORMATTING_MENU_ITEM.type,
|
|
95
|
+
key: CLEAR_FORMATTING_MENU_ITEM.key,
|
|
96
|
+
parents: [{
|
|
97
|
+
type: CLEAR_FORMARTTING_MENU_SECTION.type,
|
|
98
|
+
key: CLEAR_FORMARTTING_MENU_SECTION.key,
|
|
99
|
+
rank: CLEAR_FORMARTTING_MENU_SECTION_RANK[CLEAR_FORMATTING_MENU_ITEM.key]
|
|
100
|
+
}],
|
|
101
|
+
component: ({
|
|
102
|
+
parents
|
|
103
|
+
}) => {
|
|
104
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ClearFormatMenuItem, {
|
|
105
|
+
parents: parents,
|
|
106
|
+
api: api
|
|
107
|
+
}));
|
|
108
|
+
}
|
|
109
|
+
}];
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { UNDERLINE_BUTTON_GROUP, UNDERLINE_BUTTON, TEXT_SECTION_PRIMARY_TOOLBAR, TEXT_FORMAT_GROUP_RANK, useEditorToolbar } from '@atlaskit/editor-common/toolbar';
|
|
3
|
+
import { Show, ToolbarButtonGroup } from '@atlaskit/editor-toolbar';
|
|
4
|
+
import { FormatOptions } from '../types';
|
|
5
|
+
import { FormatButton } from './Component';
|
|
6
|
+
import { formatOptions } from './utils';
|
|
7
|
+
const UnderlineButtonGroup = ({
|
|
8
|
+
children
|
|
9
|
+
}) => {
|
|
10
|
+
const {
|
|
11
|
+
editorAppearance
|
|
12
|
+
} = useEditorToolbar();
|
|
13
|
+
if (editorAppearance === 'full-page') {
|
|
14
|
+
return /*#__PURE__*/React.createElement(Show, {
|
|
15
|
+
above: "xl"
|
|
16
|
+
}, /*#__PURE__*/React.createElement(ToolbarButtonGroup, null, children));
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
export const underlineButtonGroup = api => [{
|
|
20
|
+
type: UNDERLINE_BUTTON_GROUP.type,
|
|
21
|
+
key: UNDERLINE_BUTTON_GROUP.key,
|
|
22
|
+
parents: [{
|
|
23
|
+
type: TEXT_SECTION_PRIMARY_TOOLBAR.type,
|
|
24
|
+
key: TEXT_SECTION_PRIMARY_TOOLBAR.key,
|
|
25
|
+
rank: TEXT_FORMAT_GROUP_RANK[UNDERLINE_BUTTON_GROUP.key]
|
|
26
|
+
}],
|
|
27
|
+
component: ({
|
|
28
|
+
children
|
|
29
|
+
}) => {
|
|
30
|
+
return /*#__PURE__*/React.createElement(UnderlineButtonGroup, null, children);
|
|
31
|
+
}
|
|
32
|
+
}, {
|
|
33
|
+
type: UNDERLINE_BUTTON.type,
|
|
34
|
+
key: UNDERLINE_BUTTON.key,
|
|
35
|
+
parents: [{
|
|
36
|
+
type: UNDERLINE_BUTTON_GROUP.type,
|
|
37
|
+
key: UNDERLINE_BUTTON_GROUP.key,
|
|
38
|
+
rank: 100
|
|
39
|
+
}],
|
|
40
|
+
component: ({
|
|
41
|
+
parents
|
|
42
|
+
}) => {
|
|
43
|
+
const {
|
|
44
|
+
icon,
|
|
45
|
+
command,
|
|
46
|
+
shortcut,
|
|
47
|
+
title
|
|
48
|
+
} = formatOptions().underline;
|
|
49
|
+
return /*#__PURE__*/React.createElement(FormatButton, {
|
|
50
|
+
api: api,
|
|
51
|
+
parents: parents,
|
|
52
|
+
icon: icon,
|
|
53
|
+
title: title,
|
|
54
|
+
shortcut: shortcut,
|
|
55
|
+
optionType: FormatOptions.underline,
|
|
56
|
+
toggleMarkWithAnalyticsCallback: command
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}];
|
|
@@ -2,43 +2,15 @@ import React from 'react';
|
|
|
2
2
|
import { CLEAR_FORMARTTING_MENU_SECTION, CLEAR_FORMATTING_MENU_ITEM, TEXT_FORMATTING_GROUP, TEXT_FORMATTING_HERO_BUTTON, TEXT_FORMATTING_MENU, TEXT_FORMATTING_MENU_SECTION, TEXT_SECTION, TEXT_SECTION_RANK, TEXT_FORMAT_GROUP_RANK, TEXT_FORMAT_MENU_RANK, CLEAR_FORMARTTING_MENU_SECTION_RANK, TEXT_COLLAPSED_MENU_RANK, TEXT_COLLAPSED_MENU } from '@atlaskit/editor-common/toolbar';
|
|
3
3
|
import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
|
|
4
4
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
5
|
-
import {
|
|
5
|
+
import { boldButtonGroup } from './Toolbar/components/BoldButtonGroup';
|
|
6
|
+
import { FormatButton, ClearFormatMenuItem, MoreFormattingMenu, MenuSection } from './Toolbar/components/Component';
|
|
7
|
+
import { textFormattingGroupForInlineToolbar } from './Toolbar/components/TextFormattingGroupForInlineToolbar';
|
|
8
|
+
import { textFormattingGroupForPrimaryToolbar } from './Toolbar/components/TextFormattingGroups';
|
|
9
|
+
import { textFormattingMenuGroup } from './Toolbar/components/TextFormattingMenuGroup';
|
|
10
|
+
import { underlineButtonGroup } from './Toolbar/components/UnderlineButtonGroup';
|
|
6
11
|
import { formatOptions } from './Toolbar/components/utils';
|
|
7
12
|
import { FormatOptions } from './Toolbar/types';
|
|
8
|
-
const
|
|
9
|
-
return Object.entries(formatOptions()).map(([optionType, {
|
|
10
|
-
icon,
|
|
11
|
-
shortcut,
|
|
12
|
-
title,
|
|
13
|
-
command,
|
|
14
|
-
rank,
|
|
15
|
-
key
|
|
16
|
-
}]) => {
|
|
17
|
-
return {
|
|
18
|
-
type: 'menu-item',
|
|
19
|
-
key,
|
|
20
|
-
parents: [{
|
|
21
|
-
type: TEXT_FORMATTING_MENU_SECTION.type,
|
|
22
|
-
key: TEXT_FORMATTING_MENU_SECTION.key,
|
|
23
|
-
rank
|
|
24
|
-
}],
|
|
25
|
-
component: ({
|
|
26
|
-
parents
|
|
27
|
-
}) => {
|
|
28
|
-
return /*#__PURE__*/React.createElement(FormatMenuItem, {
|
|
29
|
-
api: api,
|
|
30
|
-
parents: parents,
|
|
31
|
-
icon: icon,
|
|
32
|
-
shortcut: shortcut,
|
|
33
|
-
title: title,
|
|
34
|
-
optionType: optionType,
|
|
35
|
-
toggleMarkWithAnalyticsCallback: command
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
|
-
export const getToolbarComponents = api => [{
|
|
13
|
+
export const getToolbarComponents = api => expValEquals('platform_editor_toolbar_aifc_responsiveness_update', 'isEnabled', true) ? getToolbarComponentsResponsivenessUpdate(api) : [{
|
|
42
14
|
type: TEXT_FORMATTING_GROUP.type,
|
|
43
15
|
key: TEXT_FORMATTING_GROUP.key,
|
|
44
16
|
parents: [{
|
|
@@ -99,7 +71,7 @@ export const getToolbarComponents = api => [{
|
|
|
99
71
|
rank: TEXT_COLLAPSED_MENU_RANK[TEXT_FORMATTING_MENU_SECTION.key]
|
|
100
72
|
}] : [])],
|
|
101
73
|
component: expValEquals('platform_editor_toolbar_aifc_responsive', 'isEnabled', true) ? MenuSection : undefined
|
|
102
|
-
},
|
|
74
|
+
}, {
|
|
103
75
|
type: CLEAR_FORMARTTING_MENU_SECTION.type,
|
|
104
76
|
key: CLEAR_FORMARTTING_MENU_SECTION.key,
|
|
105
77
|
parents: [{
|
|
@@ -134,4 +106,7 @@ export const getToolbarComponents = api => [{
|
|
|
134
106
|
api: api
|
|
135
107
|
}));
|
|
136
108
|
}
|
|
137
|
-
}];
|
|
109
|
+
}];
|
|
110
|
+
export const getToolbarComponentsResponsivenessUpdate = api => {
|
|
111
|
+
return [...textFormattingGroupForPrimaryToolbar(api), ...textFormattingGroupForInlineToolbar(api), ...boldButtonGroup(api), ...underlineButtonGroup(api), ...textFormattingMenuGroup(api)];
|
|
112
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BOLD_BUTTON_GROUP, BOLD_BUTTON, TEXT_SECTION_PRIMARY_TOOLBAR, TEXT_FORMAT_GROUP_RANK, useEditorToolbar } from '@atlaskit/editor-common/toolbar';
|
|
3
|
+
import { Show, ToolbarButtonGroup } from '@atlaskit/editor-toolbar';
|
|
4
|
+
import { FormatOptions } from '../types';
|
|
5
|
+
import { FormatButton } from './Component';
|
|
6
|
+
import { formatOptions } from './utils';
|
|
7
|
+
var BoldButtonGroup = function BoldButtonGroup(_ref) {
|
|
8
|
+
var children = _ref.children;
|
|
9
|
+
var _useEditorToolbar = useEditorToolbar(),
|
|
10
|
+
editorAppearance = _useEditorToolbar.editorAppearance;
|
|
11
|
+
if (editorAppearance === 'full-page') {
|
|
12
|
+
return /*#__PURE__*/React.createElement(Show, {
|
|
13
|
+
above: "xl"
|
|
14
|
+
}, /*#__PURE__*/React.createElement(ToolbarButtonGroup, null, children));
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
export var boldButtonGroup = function boldButtonGroup(api) {
|
|
18
|
+
return [{
|
|
19
|
+
type: BOLD_BUTTON_GROUP.type,
|
|
20
|
+
key: BOLD_BUTTON_GROUP.key,
|
|
21
|
+
parents: [{
|
|
22
|
+
type: TEXT_SECTION_PRIMARY_TOOLBAR.type,
|
|
23
|
+
key: TEXT_SECTION_PRIMARY_TOOLBAR.key,
|
|
24
|
+
rank: TEXT_FORMAT_GROUP_RANK[BOLD_BUTTON_GROUP.key]
|
|
25
|
+
}],
|
|
26
|
+
component: function component(_ref2) {
|
|
27
|
+
var children = _ref2.children;
|
|
28
|
+
return /*#__PURE__*/React.createElement(BoldButtonGroup, null, children);
|
|
29
|
+
}
|
|
30
|
+
}, {
|
|
31
|
+
type: BOLD_BUTTON.type,
|
|
32
|
+
key: BOLD_BUTTON.key,
|
|
33
|
+
parents: [{
|
|
34
|
+
type: BOLD_BUTTON_GROUP.type,
|
|
35
|
+
key: BOLD_BUTTON_GROUP.key,
|
|
36
|
+
rank: 100
|
|
37
|
+
}],
|
|
38
|
+
component: function component(_ref3) {
|
|
39
|
+
var parents = _ref3.parents;
|
|
40
|
+
var _formatOptions$strong = formatOptions().strong,
|
|
41
|
+
icon = _formatOptions$strong.icon,
|
|
42
|
+
command = _formatOptions$strong.command,
|
|
43
|
+
shortcut = _formatOptions$strong.shortcut,
|
|
44
|
+
title = _formatOptions$strong.title;
|
|
45
|
+
return /*#__PURE__*/React.createElement(FormatButton, {
|
|
46
|
+
api: api,
|
|
47
|
+
parents: parents,
|
|
48
|
+
icon: icon,
|
|
49
|
+
title: title,
|
|
50
|
+
shortcut: shortcut,
|
|
51
|
+
optionType: FormatOptions.strong,
|
|
52
|
+
toggleMarkWithAnalyticsCallback: command
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}];
|
|
56
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TEXT_FORMATTING_GROUP_INLINE, TEXT_FORMATTING_HERO_BUTTON, TEXT_SECTION, TEXT_SECTION_RANK, TEXT_FORMATTING_GROUP, TEXT_FORMAT_GROUP_RANK } from '@atlaskit/editor-common/toolbar';
|
|
3
|
+
import { ToolbarButtonGroup } from '@atlaskit/editor-toolbar';
|
|
4
|
+
import { FormatOptions } from '../types';
|
|
5
|
+
import { FormatButton } from './Component';
|
|
6
|
+
import { formatOptions } from './utils';
|
|
7
|
+
export var textFormattingGroupForInlineToolbar = function textFormattingGroupForInlineToolbar(api) {
|
|
8
|
+
return [{
|
|
9
|
+
type: TEXT_FORMATTING_GROUP_INLINE.type,
|
|
10
|
+
key: TEXT_FORMATTING_GROUP_INLINE.key,
|
|
11
|
+
parents: [{
|
|
12
|
+
type: TEXT_SECTION.type,
|
|
13
|
+
key: TEXT_SECTION.key,
|
|
14
|
+
rank: TEXT_SECTION_RANK[TEXT_FORMATTING_GROUP.key]
|
|
15
|
+
}],
|
|
16
|
+
component: function component(_ref) {
|
|
17
|
+
var children = _ref.children;
|
|
18
|
+
return /*#__PURE__*/React.createElement(ToolbarButtonGroup, null, children);
|
|
19
|
+
}
|
|
20
|
+
}, {
|
|
21
|
+
type: TEXT_FORMATTING_HERO_BUTTON.type,
|
|
22
|
+
key: TEXT_FORMATTING_HERO_BUTTON.key,
|
|
23
|
+
parents: [{
|
|
24
|
+
type: TEXT_FORMATTING_GROUP_INLINE.type,
|
|
25
|
+
key: TEXT_FORMATTING_GROUP_INLINE.key,
|
|
26
|
+
rank: TEXT_FORMAT_GROUP_RANK[TEXT_FORMATTING_HERO_BUTTON.key]
|
|
27
|
+
}],
|
|
28
|
+
component: function component(_ref2) {
|
|
29
|
+
var parents = _ref2.parents;
|
|
30
|
+
var _formatOptions$strong = formatOptions().strong,
|
|
31
|
+
icon = _formatOptions$strong.icon,
|
|
32
|
+
command = _formatOptions$strong.command,
|
|
33
|
+
shortcut = _formatOptions$strong.shortcut,
|
|
34
|
+
title = _formatOptions$strong.title;
|
|
35
|
+
return /*#__PURE__*/React.createElement(FormatButton, {
|
|
36
|
+
api: api,
|
|
37
|
+
parents: parents,
|
|
38
|
+
icon: icon,
|
|
39
|
+
title: title,
|
|
40
|
+
shortcut: shortcut,
|
|
41
|
+
optionType: FormatOptions.strong,
|
|
42
|
+
toggleMarkWithAnalyticsCallback: command
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}];
|
|
46
|
+
};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TEXT_FORMATTING_GROUP, TEXT_FORMATTING_HERO_BUTTON, TEXT_FORMATTING_GROUP_COLLAPSED, TEXT_FORMATTING_HERO_BUTTON_COLLAPSED, TEXT_SECTION_PRIMARY_TOOLBAR, TEXT_FORMAT_GROUP_RANK, TEXT_FORMAT_GROUP_COLLAPSED_RANK, TEXT_SECTION_PRIMARY_TOOLBAR_RANK, useEditorToolbar } from '@atlaskit/editor-common/toolbar';
|
|
3
|
+
import { Show, ToolbarButtonGroup } from '@atlaskit/editor-toolbar';
|
|
4
|
+
import { FormatOptions } from '../types';
|
|
5
|
+
import { FormatButton } from './Component';
|
|
6
|
+
import { formatOptions } from './utils';
|
|
7
|
+
var TextFormattingGroup = function TextFormattingGroup(_ref) {
|
|
8
|
+
var children = _ref.children;
|
|
9
|
+
var _useEditorToolbar = useEditorToolbar(),
|
|
10
|
+
editorAppearance = _useEditorToolbar.editorAppearance;
|
|
11
|
+
if (editorAppearance === 'full-page') {
|
|
12
|
+
return /*#__PURE__*/React.createElement(Show, {
|
|
13
|
+
above: "xl"
|
|
14
|
+
}, /*#__PURE__*/React.createElement(ToolbarButtonGroup, null, children));
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var TextFormattingGroupCollapsed = function TextFormattingGroupCollapsed(_ref2) {
|
|
18
|
+
var children = _ref2.children;
|
|
19
|
+
var _useEditorToolbar2 = useEditorToolbar(),
|
|
20
|
+
editorAppearance = _useEditorToolbar2.editorAppearance;
|
|
21
|
+
if (editorAppearance === 'full-page') {
|
|
22
|
+
return /*#__PURE__*/React.createElement(Show, {
|
|
23
|
+
below: "xl"
|
|
24
|
+
}, /*#__PURE__*/React.createElement(ToolbarButtonGroup, null, children));
|
|
25
|
+
}
|
|
26
|
+
return /*#__PURE__*/React.createElement(ToolbarButtonGroup, null, children);
|
|
27
|
+
};
|
|
28
|
+
export var textFormattingGroupForPrimaryToolbar = function textFormattingGroupForPrimaryToolbar(api) {
|
|
29
|
+
return [{
|
|
30
|
+
type: TEXT_FORMATTING_GROUP.type,
|
|
31
|
+
key: TEXT_FORMATTING_GROUP.key,
|
|
32
|
+
parents: [{
|
|
33
|
+
type: TEXT_SECTION_PRIMARY_TOOLBAR.type,
|
|
34
|
+
key: TEXT_SECTION_PRIMARY_TOOLBAR.key,
|
|
35
|
+
rank: TEXT_SECTION_PRIMARY_TOOLBAR_RANK[TEXT_FORMATTING_GROUP.key]
|
|
36
|
+
}],
|
|
37
|
+
component: function component(_ref3) {
|
|
38
|
+
var children = _ref3.children;
|
|
39
|
+
return /*#__PURE__*/React.createElement(TextFormattingGroup, null, children);
|
|
40
|
+
}
|
|
41
|
+
}, {
|
|
42
|
+
type: TEXT_FORMATTING_GROUP_COLLAPSED.type,
|
|
43
|
+
key: TEXT_FORMATTING_GROUP_COLLAPSED.key,
|
|
44
|
+
parents: [{
|
|
45
|
+
type: TEXT_SECTION_PRIMARY_TOOLBAR.type,
|
|
46
|
+
key: TEXT_SECTION_PRIMARY_TOOLBAR.key,
|
|
47
|
+
rank: TEXT_SECTION_PRIMARY_TOOLBAR_RANK[TEXT_FORMATTING_GROUP.key]
|
|
48
|
+
}],
|
|
49
|
+
component: function component(_ref4) {
|
|
50
|
+
var children = _ref4.children;
|
|
51
|
+
return /*#__PURE__*/React.createElement(TextFormattingGroupCollapsed, null, children);
|
|
52
|
+
}
|
|
53
|
+
}, {
|
|
54
|
+
type: TEXT_FORMATTING_HERO_BUTTON.type,
|
|
55
|
+
key: TEXT_FORMATTING_HERO_BUTTON.key,
|
|
56
|
+
parents: [{
|
|
57
|
+
type: TEXT_FORMATTING_GROUP.type,
|
|
58
|
+
key: TEXT_FORMATTING_GROUP.key,
|
|
59
|
+
rank: TEXT_FORMAT_GROUP_RANK[TEXT_FORMATTING_HERO_BUTTON.key]
|
|
60
|
+
}],
|
|
61
|
+
component: function component(_ref5) {
|
|
62
|
+
var parents = _ref5.parents;
|
|
63
|
+
var _formatOptions$em = formatOptions().em,
|
|
64
|
+
icon = _formatOptions$em.icon,
|
|
65
|
+
command = _formatOptions$em.command,
|
|
66
|
+
shortcut = _formatOptions$em.shortcut,
|
|
67
|
+
title = _formatOptions$em.title;
|
|
68
|
+
return /*#__PURE__*/React.createElement(FormatButton, {
|
|
69
|
+
api: api,
|
|
70
|
+
parents: parents,
|
|
71
|
+
icon: icon,
|
|
72
|
+
title: title,
|
|
73
|
+
shortcut: shortcut,
|
|
74
|
+
optionType: FormatOptions.em,
|
|
75
|
+
toggleMarkWithAnalyticsCallback: command
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}, {
|
|
79
|
+
type: TEXT_FORMATTING_HERO_BUTTON_COLLAPSED.type,
|
|
80
|
+
key: TEXT_FORMATTING_HERO_BUTTON_COLLAPSED.key,
|
|
81
|
+
parents: [{
|
|
82
|
+
type: TEXT_FORMATTING_GROUP_COLLAPSED.type,
|
|
83
|
+
key: TEXT_FORMATTING_GROUP_COLLAPSED.key,
|
|
84
|
+
rank: TEXT_FORMAT_GROUP_COLLAPSED_RANK[TEXT_FORMATTING_HERO_BUTTON_COLLAPSED.key]
|
|
85
|
+
}],
|
|
86
|
+
component: function component(_ref6) {
|
|
87
|
+
var parents = _ref6.parents;
|
|
88
|
+
var _formatOptions$strong = formatOptions().strong,
|
|
89
|
+
icon = _formatOptions$strong.icon,
|
|
90
|
+
command = _formatOptions$strong.command,
|
|
91
|
+
shortcut = _formatOptions$strong.shortcut,
|
|
92
|
+
title = _formatOptions$strong.title;
|
|
93
|
+
return /*#__PURE__*/React.createElement(FormatButton, {
|
|
94
|
+
api: api,
|
|
95
|
+
parents: parents,
|
|
96
|
+
icon: icon,
|
|
97
|
+
title: title,
|
|
98
|
+
shortcut: shortcut,
|
|
99
|
+
optionType: FormatOptions.strong,
|
|
100
|
+
toggleMarkWithAnalyticsCallback: command
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}];
|
|
104
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { CLEAR_FORMARTTING_MENU_SECTION, CLEAR_FORMATTING_MENU_ITEM, TEXT_FORMATTING_MENU, TEXT_FORMATTING_MENU_SECTION, TEXT_FORMATTING_GROUP, TEXT_FORMATTING_GROUP_COLLAPSED, TEXT_FORMATTING_GROUP_INLINE, TEXT_FORMATTING_HERO_BUTTON, TEXT_FORMAT_GROUP_RANK, TEXT_FORMAT_MENU_RANK, CLEAR_FORMARTTING_MENU_SECTION_RANK, TEXT_COLLAPSED_MENU_RANK, TEXT_COLLAPSED_MENU } from '@atlaskit/editor-common/toolbar';
|
|
5
|
+
import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
|
|
6
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
7
|
+
import { ClearFormatMenuItem, MoreFormattingMenu, MenuSection, FormatMenuItem } from './Component';
|
|
8
|
+
import { formatOptions } from './utils';
|
|
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
|
+
key = _ref2$.key;
|
|
20
|
+
return {
|
|
21
|
+
type: 'menu-item',
|
|
22
|
+
key: key,
|
|
23
|
+
parents: [{
|
|
24
|
+
type: TEXT_FORMATTING_MENU_SECTION.type,
|
|
25
|
+
key: TEXT_FORMATTING_MENU_SECTION.key,
|
|
26
|
+
rank: rank
|
|
27
|
+
}],
|
|
28
|
+
component: function component(_ref3) {
|
|
29
|
+
var parents = _ref3.parents;
|
|
30
|
+
return /*#__PURE__*/React.createElement(FormatMenuItem, {
|
|
31
|
+
api: api,
|
|
32
|
+
parents: parents,
|
|
33
|
+
icon: icon,
|
|
34
|
+
shortcut: shortcut,
|
|
35
|
+
title: title,
|
|
36
|
+
optionType: optionType,
|
|
37
|
+
toggleMarkWithAnalyticsCallback: command
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
export var textFormattingMenuGroup = function textFormattingMenuGroup(api) {
|
|
44
|
+
return [{
|
|
45
|
+
type: TEXT_FORMATTING_MENU.type,
|
|
46
|
+
key: TEXT_FORMATTING_MENU.key,
|
|
47
|
+
parents: [{
|
|
48
|
+
type: TEXT_FORMATTING_GROUP.type,
|
|
49
|
+
key: TEXT_FORMATTING_GROUP.key,
|
|
50
|
+
rank: TEXT_FORMAT_GROUP_RANK[TEXT_FORMATTING_MENU.key]
|
|
51
|
+
}, {
|
|
52
|
+
type: TEXT_FORMATTING_GROUP_COLLAPSED.type,
|
|
53
|
+
key: TEXT_FORMATTING_GROUP_COLLAPSED.key,
|
|
54
|
+
rank: TEXT_FORMAT_GROUP_RANK[TEXT_FORMATTING_MENU.key]
|
|
55
|
+
}, {
|
|
56
|
+
type: TEXT_FORMATTING_GROUP_INLINE.type,
|
|
57
|
+
key: TEXT_FORMATTING_GROUP_INLINE.key,
|
|
58
|
+
rank: TEXT_FORMAT_GROUP_RANK[TEXT_FORMATTING_HERO_BUTTON.key]
|
|
59
|
+
}],
|
|
60
|
+
component: function component(_ref4) {
|
|
61
|
+
var children = _ref4.children;
|
|
62
|
+
return /*#__PURE__*/React.createElement(MoreFormattingMenu, null, children);
|
|
63
|
+
}
|
|
64
|
+
}, {
|
|
65
|
+
type: TEXT_FORMATTING_MENU_SECTION.type,
|
|
66
|
+
key: TEXT_FORMATTING_MENU_SECTION.key,
|
|
67
|
+
parents: [{
|
|
68
|
+
type: TEXT_FORMATTING_MENU.type,
|
|
69
|
+
key: TEXT_FORMATTING_MENU.key,
|
|
70
|
+
rank: TEXT_FORMAT_MENU_RANK[TEXT_FORMATTING_MENU_SECTION.key]
|
|
71
|
+
}].concat(_toConsumableArray(expValEquals('platform_editor_toolbar_aifc_responsive', 'isEnabled', true) ? [{
|
|
72
|
+
type: TEXT_COLLAPSED_MENU.type,
|
|
73
|
+
key: TEXT_COLLAPSED_MENU.key,
|
|
74
|
+
rank: TEXT_COLLAPSED_MENU_RANK[TEXT_FORMATTING_MENU_SECTION.key]
|
|
75
|
+
}] : [])),
|
|
76
|
+
component: expValEquals('platform_editor_toolbar_aifc_responsive', 'isEnabled', true) ? MenuSection : undefined
|
|
77
|
+
}].concat(_toConsumableArray(getFormatMenuItems(api)), [{
|
|
78
|
+
type: CLEAR_FORMARTTING_MENU_SECTION.type,
|
|
79
|
+
key: CLEAR_FORMARTTING_MENU_SECTION.key,
|
|
80
|
+
parents: [{
|
|
81
|
+
type: TEXT_FORMATTING_MENU.type,
|
|
82
|
+
key: TEXT_FORMATTING_MENU.key,
|
|
83
|
+
rank: TEXT_FORMAT_MENU_RANK[CLEAR_FORMARTTING_MENU_SECTION.key]
|
|
84
|
+
}].concat(_toConsumableArray(expValEquals('platform_editor_toolbar_aifc_responsive', 'isEnabled', true) ? [{
|
|
85
|
+
type: TEXT_COLLAPSED_MENU.type,
|
|
86
|
+
key: TEXT_COLLAPSED_MENU.key,
|
|
87
|
+
rank: TEXT_COLLAPSED_MENU_RANK[CLEAR_FORMARTTING_MENU_SECTION.key]
|
|
88
|
+
}] : [])),
|
|
89
|
+
component: function component(_ref5) {
|
|
90
|
+
var children = _ref5.children;
|
|
91
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
|
|
92
|
+
hasSeparator: true
|
|
93
|
+
}, children);
|
|
94
|
+
}
|
|
95
|
+
}, {
|
|
96
|
+
type: CLEAR_FORMATTING_MENU_ITEM.type,
|
|
97
|
+
key: CLEAR_FORMATTING_MENU_ITEM.key,
|
|
98
|
+
parents: [{
|
|
99
|
+
type: CLEAR_FORMARTTING_MENU_SECTION.type,
|
|
100
|
+
key: CLEAR_FORMARTTING_MENU_SECTION.key,
|
|
101
|
+
rank: CLEAR_FORMARTTING_MENU_SECTION_RANK[CLEAR_FORMATTING_MENU_ITEM.key]
|
|
102
|
+
}],
|
|
103
|
+
component: function component(_ref6) {
|
|
104
|
+
var parents = _ref6.parents;
|
|
105
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ClearFormatMenuItem, {
|
|
106
|
+
parents: parents,
|
|
107
|
+
api: api
|
|
108
|
+
}));
|
|
109
|
+
}
|
|
110
|
+
}]);
|
|
111
|
+
};
|