@livepreso/react-plugin-textfield 0.0.2
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/.lintstagedrc.js +6 -0
- package/.rush/temp/shrinkwrap-deps.json +311 -0
- package/.vscode/settings.json +22 -0
- package/CHANGELOG.json +17 -0
- package/CHANGELOG.md +9 -0
- package/components/BubbleMenu.js +181 -0
- package/components/BubbleMenu.module.scss +9 -0
- package/components/LinkEditDialog.js +105 -0
- package/components/LinkEditDialog.module.scss +171 -0
- package/components/Popover.js +43 -0
- package/components/Popover.module.scss +80 -0
- package/components/PrimaryToolbar.js +27 -0
- package/components/Select/Select.js +71 -0
- package/components/Select/Select.module.scss +100 -0
- package/components/Select/SelectGroup.js +37 -0
- package/components/Select/index.js +1 -0
- package/components/TableCellMenu.js +43 -0
- package/components/TableToolbar.js +41 -0
- package/components/Tooltip.js +34 -0
- package/components/Tooltip.module.scss +87 -0
- package/components/VerticalAlignToggle.js +65 -0
- package/components/color-picker/ColorPicker.js +28 -0
- package/components/color-picker/ColorPicker.module.scss +8 -0
- package/components/color-picker/ColorPickerChip.js +22 -0
- package/components/color-picker/ColorPickerChip.module.scss +25 -0
- package/components/color-picker/ColorPickerCombo.js +45 -0
- package/components/color-picker/ColorPickerCombo.module.scss +23 -0
- package/components/color-picker/TextColorIcon.js +18 -0
- package/components/editor-toolbars/EditorMenu.js +104 -0
- package/components/editor-toolbars/EditorMenu.module.scss +96 -0
- package/components/editor-toolbars/EditorToolbar.js +146 -0
- package/components/editor-toolbars/EditorToolbar.module.scss +75 -0
- package/components/editor-toolbars/MenuItem.js +24 -0
- package/components/editor-toolbars/SubMenu.js +50 -0
- package/components/editor-toolbars/ToolbarButton.js +26 -0
- package/components/editor-toolbars/ToolbarToggle.js +35 -0
- package/components/editor-toolbars/ToolbarToggleGroup.js +43 -0
- package/components/editor-toolbars/utils.js +7 -0
- package/components/hooks/use-presenter.js +5 -0
- package/components/style.module.scss +63 -0
- package/components/tiptap/ListItem.js +5 -0
- package/components/tiptap/Table.js +397 -0
- package/components/tiptap/TableCells.js +99 -0
- package/components/utils.js +84 -0
- package/configs/generate-toolbar-configuration.js +130 -0
- package/configs/generate-toolbar-options.js +96 -0
- package/configs/table-toolbar-configuration.js +187 -0
- package/configs/toolbar-configuration.js +330 -0
- package/constants.js +198 -0
- package/eslint.config.mjs +15 -0
- package/icons/AddColumnLeft.js +15 -0
- package/icons/AddColumnRight.js +15 -0
- package/icons/AddRowAbove.js +15 -0
- package/icons/AddRowBelow.js +15 -0
- package/icons/AlignHorizontalCenter.js +13 -0
- package/icons/AlignHorizontalLeft.js +13 -0
- package/icons/AlignHorizontalRight.js +13 -0
- package/icons/AlignVerticalBottom.js +13 -0
- package/icons/AlignVerticalCenter.js +13 -0
- package/icons/AlignVerticalTop.js +13 -0
- package/icons/Backspace.js +13 -0
- package/icons/Bold.js +14 -0
- package/icons/BorderAll.js +13 -0
- package/icons/BorderBottom.js +13 -0
- package/icons/BorderClear.js +13 -0
- package/icons/BorderHorizontal.js +13 -0
- package/icons/BorderInner.js +13 -0
- package/icons/BorderLeft.js +13 -0
- package/icons/BorderOuter.js +13 -0
- package/icons/BorderRight.js +13 -0
- package/icons/BorderTop.js +13 -0
- package/icons/BorderVertical.js +13 -0
- package/icons/Close.js +13 -0
- package/icons/Delete.js +13 -0
- package/icons/EvenlyDistribute.js +14 -0
- package/icons/FitWidth.js +13 -0
- package/icons/FitWidthArrows.js +21 -0
- package/icons/FormatAlignCenter.js +13 -0
- package/icons/FormatAlignJustify.js +13 -0
- package/icons/FormatAlignLeft.js +13 -0
- package/icons/FormatAlignRight.js +13 -0
- package/icons/FormatBold.js +13 -0
- package/icons/FormatClear.js +13 -0
- package/icons/FormatColorFill.js +13 -0
- package/icons/FormatColorText.js +13 -0
- package/icons/FormatItalic.js +13 -0
- package/icons/FormatLineSpacing.js +13 -0
- package/icons/FormatListBulleted.js +13 -0
- package/icons/FormatListNumbered.js +13 -0
- package/icons/FormatStrikethrough.js +13 -0
- package/icons/FormatUnderlined.js +13 -0
- package/icons/HorizontalRule.js +13 -0
- package/icons/Italic.js +14 -0
- package/icons/ItalicIcon.js +18 -0
- package/icons/Link.js +13 -0
- package/icons/LinkOff.js +13 -0
- package/icons/MergeCells.js +14 -0
- package/icons/Redo.js +13 -0
- package/icons/RemoveColumnOutline.js +28 -0
- package/icons/RemoveRowOutline.js +25 -0
- package/icons/SplitCells.js +14 -0
- package/icons/SplitScene.js +13 -0
- package/icons/Subscript.js +13 -0
- package/icons/Superscript.js +13 -0
- package/icons/Underline.js +14 -0
- package/icons/Undo.js +13 -0
- package/icons/VerticalAlignBottom.js +13 -0
- package/icons/VerticalAlignCenter.js +13 -0
- package/icons/VerticalAlignTop.js +13 -0
- package/icons/add_column_left.svg +6 -0
- package/icons/add_column_right.svg +6 -0
- package/icons/add_row_above.svg +6 -0
- package/icons/add_row_below.svg +6 -0
- package/icons/align_horizontal_center.svg +1 -0
- package/icons/align_horizontal_left.svg +1 -0
- package/icons/align_horizontal_right.svg +1 -0
- package/icons/align_vertical_bottom.svg +1 -0
- package/icons/align_vertical_center.svg +1 -0
- package/icons/align_vertical_top.svg +1 -0
- package/icons/backspace.svg +1 -0
- package/icons/bold.svg +1 -0
- package/icons/border_all.svg +1 -0
- package/icons/border_bottom.svg +1 -0
- package/icons/border_clear.svg +1 -0
- package/icons/border_horizontal.svg +1 -0
- package/icons/border_inner.svg +1 -0
- package/icons/border_left.svg +1 -0
- package/icons/border_outer.svg +1 -0
- package/icons/border_right.svg +1 -0
- package/icons/border_top.svg +1 -0
- package/icons/border_vertical.svg +1 -0
- package/icons/close.svg +1 -0
- package/icons/delete.svg +1 -0
- package/icons/evenly_distribute.svg +5 -0
- package/icons/fit_width.svg +1 -0
- package/icons/fit_width_arrows.svg +12 -0
- package/icons/format_align_center.svg +1 -0
- package/icons/format_align_justify.svg +1 -0
- package/icons/format_align_left.svg +1 -0
- package/icons/format_align_right.svg +1 -0
- package/icons/format_bold.svg +1 -0
- package/icons/format_clear.svg +1 -0
- package/icons/format_color_fill.svg +1 -0
- package/icons/format_color_text.svg +5 -0
- package/icons/format_color_text_ungrouped.svg +6 -0
- package/icons/format_italic.svg +1 -0
- package/icons/format_line_spacing.svg +1 -0
- package/icons/format_list_bulleted.svg +1 -0
- package/icons/format_list_numbered.svg +1 -0
- package/icons/format_strikethrough.svg +1 -0
- package/icons/format_underlined.svg +1 -0
- package/icons/horizontal_rule.svg +1 -0
- package/icons/index.js +191 -0
- package/icons/italic.svg +1 -0
- package/icons/link.svg +1 -0
- package/icons/link_off.svg +1 -0
- package/icons/merge_cells.svg +5 -0
- package/icons/redo.svg +1 -0
- package/icons/remove_column_outline.svg +20 -0
- package/icons/remove_row_outline.svg +17 -0
- package/icons/split_cells.svg +5 -0
- package/icons/split_scene.svg +1 -0
- package/icons/subscript.svg +1 -0
- package/icons/superscript.svg +1 -0
- package/icons/underline.svg +1 -0
- package/icons/undo.svg +1 -0
- package/icons/vertical_align_bottom.svg +1 -0
- package/icons/vertical_align_center.svg +1 -0
- package/icons/vertical_align_top.svg +1 -0
- package/index.js +334 -0
- package/index.module.scss +106 -0
- package/package.json +63 -0
- package/scripts/extract-svg.js +288 -0
- package/utils/color-utils.js +42 -0
- package/utils/generate-vertical-alignment-icon.js +22 -0
- package/utils/generateCustomExtensions.js +49 -0
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Toolbar, Tooltip as TooltipPrimitive } from "radix-ui";
|
|
3
|
+
|
|
4
|
+
import { Tooltip } from "../Tooltip";
|
|
5
|
+
import { TOOLBAR_COMPONENT_TYPES } from "../../constants";
|
|
6
|
+
import { Popover } from "../Popover";
|
|
7
|
+
import { getState } from "./utils";
|
|
8
|
+
import { ToolbarButton } from "./ToolbarButton";
|
|
9
|
+
import { ToolbarToggle } from "./ToolbarToggle";
|
|
10
|
+
import { ToolbarToggleGroup } from "./ToolbarToggleGroup";
|
|
11
|
+
import style from "./EditorToolbar.module.scss";
|
|
12
|
+
|
|
13
|
+
export function EditorToolbar({
|
|
14
|
+
configuration,
|
|
15
|
+
editor,
|
|
16
|
+
editorState,
|
|
17
|
+
userSelections,
|
|
18
|
+
}) {
|
|
19
|
+
const states = { editorState, userSelections };
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<TooltipPrimitive.Provider delayDuration={800} skipDelayDuration={500}>
|
|
23
|
+
<Toolbar.Root className={style.root} aria-label="Formatting options">
|
|
24
|
+
{configuration.flatMap(({ id: groupId, items = [] }, index) => [
|
|
25
|
+
index !== 0 && (
|
|
26
|
+
<Toolbar.Separator
|
|
27
|
+
key={`separator-${groupId}`}
|
|
28
|
+
className={style.separator}
|
|
29
|
+
/>
|
|
30
|
+
),
|
|
31
|
+
<div key={groupId} className={style.itemGroup}>
|
|
32
|
+
{items.map((item = {}) => {
|
|
33
|
+
const {
|
|
34
|
+
id,
|
|
35
|
+
type,
|
|
36
|
+
label,
|
|
37
|
+
tooltip,
|
|
38
|
+
icon: iconComponent,
|
|
39
|
+
renderIcon,
|
|
40
|
+
...itemsProps
|
|
41
|
+
} = item;
|
|
42
|
+
const { isEnabled, isActive, value } = getState(id, editorState);
|
|
43
|
+
const itemState = { isEnabled, isActive, value };
|
|
44
|
+
|
|
45
|
+
const icon = renderIcon ? renderIcon(editor) : iconComponent;
|
|
46
|
+
|
|
47
|
+
if (type === TOOLBAR_COMPONENT_TYPES.CUSTOM) {
|
|
48
|
+
const { renderContent } = itemsProps;
|
|
49
|
+
return (
|
|
50
|
+
<Tooltip content={label} key={id}>
|
|
51
|
+
<span>
|
|
52
|
+
{renderContent({
|
|
53
|
+
editor,
|
|
54
|
+
...states,
|
|
55
|
+
...itemState,
|
|
56
|
+
})}
|
|
57
|
+
</span>
|
|
58
|
+
</Tooltip>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (type === TOOLBAR_COMPONENT_TYPES.BUTTON) {
|
|
63
|
+
const { command = () => {} } = itemsProps;
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<Tooltip content={tooltip || label} key={id}>
|
|
67
|
+
<ToolbarButton
|
|
68
|
+
label={label}
|
|
69
|
+
icon={icon}
|
|
70
|
+
disabled={!isEnabled}
|
|
71
|
+
onClick={() => command(editor, states)}
|
|
72
|
+
/>
|
|
73
|
+
</Tooltip>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (type === TOOLBAR_COMPONENT_TYPES.POPOVER) {
|
|
78
|
+
const { renderContent } = itemsProps;
|
|
79
|
+
|
|
80
|
+
const trigger = (
|
|
81
|
+
<ToolbarButton key={id} icon={icon} disabled={!isEnabled} />
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<Tooltip content={tooltip || label} key={id}>
|
|
86
|
+
<Popover trigger={trigger}>
|
|
87
|
+
{renderContent({
|
|
88
|
+
editor,
|
|
89
|
+
...states,
|
|
90
|
+
...itemState,
|
|
91
|
+
})}
|
|
92
|
+
</Popover>
|
|
93
|
+
</Tooltip>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (type === TOOLBAR_COMPONENT_TYPES.TOGGLE) {
|
|
98
|
+
const { command = () => {} } = itemsProps;
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
<Tooltip content={tooltip || label} key={id}>
|
|
102
|
+
<ToolbarToggle
|
|
103
|
+
label={label}
|
|
104
|
+
icon={icon}
|
|
105
|
+
pressed={isActive}
|
|
106
|
+
disabled={!isEnabled}
|
|
107
|
+
onPressedChange={() => {
|
|
108
|
+
command(editor, states);
|
|
109
|
+
return true;
|
|
110
|
+
}}
|
|
111
|
+
/>
|
|
112
|
+
</Tooltip>
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (type === TOOLBAR_COMPONENT_TYPES.TOGGLE_GROUP) {
|
|
117
|
+
const {
|
|
118
|
+
command = () => {},
|
|
119
|
+
defaultValue,
|
|
120
|
+
options,
|
|
121
|
+
} = itemsProps;
|
|
122
|
+
|
|
123
|
+
return (
|
|
124
|
+
<ToolbarToggleGroup
|
|
125
|
+
key={id}
|
|
126
|
+
label={label}
|
|
127
|
+
type="single"
|
|
128
|
+
defaultValue={defaultValue}
|
|
129
|
+
onValueChange={(value) =>
|
|
130
|
+
command(editor, { value, ...states })
|
|
131
|
+
}
|
|
132
|
+
options={options.map(({ id: toggleId, ...opt } = {}) => {
|
|
133
|
+
return { id: toggleId, disabled: !isEnabled, ...opt };
|
|
134
|
+
})}
|
|
135
|
+
/>
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return null;
|
|
140
|
+
})}
|
|
141
|
+
</div>,
|
|
142
|
+
])}
|
|
143
|
+
</Toolbar.Root>
|
|
144
|
+
</TooltipPrimitive.Provider>
|
|
145
|
+
);
|
|
146
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
@import "../style.module.scss";
|
|
2
|
+
|
|
3
|
+
:global(.sp-presenter-overlay) {
|
|
4
|
+
.root {
|
|
5
|
+
@extend %root;
|
|
6
|
+
padding: 6px;
|
|
7
|
+
// min-width: 100%;
|
|
8
|
+
// min-width: 0;
|
|
9
|
+
// min-height: 0;
|
|
10
|
+
display: flex;
|
|
11
|
+
flex-wrap: wrap;
|
|
12
|
+
align-items: center;
|
|
13
|
+
row-gap: 8px;
|
|
14
|
+
|
|
15
|
+
// Loz: gets rid of the forced height applied to spans
|
|
16
|
+
// I don't like it...
|
|
17
|
+
> span {
|
|
18
|
+
line-height: 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.item-group {
|
|
22
|
+
display: flex;
|
|
23
|
+
flex-direction: row;
|
|
24
|
+
align-items: center;
|
|
25
|
+
height: $item-height;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.item {
|
|
29
|
+
@extend %item;
|
|
30
|
+
flex: 0 0 auto;
|
|
31
|
+
height: $item-height;
|
|
32
|
+
padding: 0 5px;
|
|
33
|
+
margin: 0 2px;
|
|
34
|
+
border-radius: 4px;
|
|
35
|
+
display: inline-flex;
|
|
36
|
+
align-items: center;
|
|
37
|
+
justify-content: center;
|
|
38
|
+
|
|
39
|
+
&:hover {
|
|
40
|
+
@extend %hover;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&:focus {
|
|
44
|
+
@extend %focus;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
&.toggle {
|
|
48
|
+
&[data-state="on"] {
|
|
49
|
+
@extend %active;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
&[data-disabled],
|
|
54
|
+
&[disabled] {
|
|
55
|
+
@extend %disabled;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.toggle-group {
|
|
60
|
+
display: flex;
|
|
61
|
+
align-items: center;
|
|
62
|
+
justify-content: center;
|
|
63
|
+
|
|
64
|
+
// Loz: gets rid of the forced height applied to spans
|
|
65
|
+
// I don't like it...
|
|
66
|
+
> span {
|
|
67
|
+
line-height: 0;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.separator {
|
|
72
|
+
@extend %separator-vertical;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { DropdownMenu } from "radix-ui";
|
|
3
|
+
|
|
4
|
+
import style from "./EditorMenu.module.scss";
|
|
5
|
+
|
|
6
|
+
export function MenuItem({
|
|
7
|
+
label,
|
|
8
|
+
icon,
|
|
9
|
+
disabled = false,
|
|
10
|
+
onClick = () => {},
|
|
11
|
+
}) {
|
|
12
|
+
return (
|
|
13
|
+
<DropdownMenu.Item
|
|
14
|
+
className={style.item}
|
|
15
|
+
value={label}
|
|
16
|
+
aria-label={label}
|
|
17
|
+
disabled={disabled}
|
|
18
|
+
onClick={onClick}
|
|
19
|
+
>
|
|
20
|
+
<div className={style.itemIcon}>{icon}</div>
|
|
21
|
+
<div className={style.itemLabel}>{label}</div>
|
|
22
|
+
</DropdownMenu.Item>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React, { Fragment } from "react";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
import { DropdownMenu } from "radix-ui";
|
|
4
|
+
|
|
5
|
+
import { ChevronRightIcon } from "@radix-ui/react-icons";
|
|
6
|
+
import { MenuItem } from "./MenuItem";
|
|
7
|
+
import style from "./EditorMenu.module.scss";
|
|
8
|
+
|
|
9
|
+
export function SubMenu({
|
|
10
|
+
label,
|
|
11
|
+
icon,
|
|
12
|
+
items = [],
|
|
13
|
+
disabled = false,
|
|
14
|
+
renderItem = null,
|
|
15
|
+
}) {
|
|
16
|
+
const div = window.Bridge.UI.overlay;
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<DropdownMenu.Sub>
|
|
20
|
+
<DropdownMenu.SubTrigger className={style.item}>
|
|
21
|
+
<div className={style.itemIcon}>{icon}</div>
|
|
22
|
+
<div className={style.itemLabel}>{label}</div>
|
|
23
|
+
<div className={classNames(style.itemIcon, style.itemIconRight)}>
|
|
24
|
+
<ChevronRightIcon />
|
|
25
|
+
</div>
|
|
26
|
+
</DropdownMenu.SubTrigger>
|
|
27
|
+
|
|
28
|
+
<DropdownMenu.Portal container={div}>
|
|
29
|
+
<DropdownMenu.SubContent
|
|
30
|
+
className={style.content}
|
|
31
|
+
sideOffset={-30}
|
|
32
|
+
alignOffset={-5}
|
|
33
|
+
collisionBoundary={div}
|
|
34
|
+
>
|
|
35
|
+
{items.map((item) => {
|
|
36
|
+
if (typeof renderItem === "function") {
|
|
37
|
+
return (
|
|
38
|
+
<Fragment key={item.id}>
|
|
39
|
+
{renderItem({ ...item, disabled })}
|
|
40
|
+
</Fragment>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return <MenuItem key={item.id} disabled={disabled} {...item} />;
|
|
45
|
+
})}
|
|
46
|
+
</DropdownMenu.SubContent>
|
|
47
|
+
</DropdownMenu.Portal>
|
|
48
|
+
</DropdownMenu.Sub>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
import { Toolbar } from "radix-ui";
|
|
4
|
+
|
|
5
|
+
import style from "./EditorToolbar.module.scss";
|
|
6
|
+
|
|
7
|
+
export const ToolbarButton = React.forwardRef(
|
|
8
|
+
(
|
|
9
|
+
{ label, icon, className, disabled, onClick = () => {}, ...props },
|
|
10
|
+
forwardedRef,
|
|
11
|
+
) => {
|
|
12
|
+
return (
|
|
13
|
+
<Toolbar.Button
|
|
14
|
+
ref={forwardedRef}
|
|
15
|
+
className={classNames(className, style.item)}
|
|
16
|
+
value={label}
|
|
17
|
+
aria-label={label}
|
|
18
|
+
disabled={disabled}
|
|
19
|
+
onClick={onClick}
|
|
20
|
+
{...props}
|
|
21
|
+
>
|
|
22
|
+
{icon}
|
|
23
|
+
</Toolbar.Button>
|
|
24
|
+
);
|
|
25
|
+
},
|
|
26
|
+
);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
import { Toggle } from "radix-ui";
|
|
4
|
+
|
|
5
|
+
import style from "./EditorToolbar.module.scss";
|
|
6
|
+
|
|
7
|
+
export const ToolbarToggle = React.forwardRef(
|
|
8
|
+
(
|
|
9
|
+
{
|
|
10
|
+
label,
|
|
11
|
+
icon,
|
|
12
|
+
pressed,
|
|
13
|
+
disabled,
|
|
14
|
+
onClick = () => {},
|
|
15
|
+
onPressedChange = () => {},
|
|
16
|
+
...props
|
|
17
|
+
},
|
|
18
|
+
forwardedRef,
|
|
19
|
+
) => {
|
|
20
|
+
return (
|
|
21
|
+
<Toggle.Root
|
|
22
|
+
ref={forwardedRef}
|
|
23
|
+
className={classNames(style.item, style.toggle)}
|
|
24
|
+
aria-label={label}
|
|
25
|
+
pressed={pressed}
|
|
26
|
+
disabled={disabled}
|
|
27
|
+
onPressedChange={onPressedChange}
|
|
28
|
+
onClick={onClick}
|
|
29
|
+
{...props}
|
|
30
|
+
>
|
|
31
|
+
{icon}
|
|
32
|
+
</Toggle.Root>
|
|
33
|
+
);
|
|
34
|
+
},
|
|
35
|
+
);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
import { Toolbar } from "radix-ui";
|
|
4
|
+
|
|
5
|
+
import { Tooltip } from "../Tooltip";
|
|
6
|
+
import style from "./EditorToolbar.module.scss";
|
|
7
|
+
|
|
8
|
+
export function ToolbarToggleGroup({
|
|
9
|
+
label,
|
|
10
|
+
defaultValue,
|
|
11
|
+
type = "single",
|
|
12
|
+
options = [],
|
|
13
|
+
value,
|
|
14
|
+
onValueChange = () => {},
|
|
15
|
+
}) {
|
|
16
|
+
return (
|
|
17
|
+
<Toolbar.ToggleGroup
|
|
18
|
+
type={type}
|
|
19
|
+
defaultValue={defaultValue}
|
|
20
|
+
aria-label={label}
|
|
21
|
+
className={style.toggleGroup}
|
|
22
|
+
onValueChange={onValueChange}
|
|
23
|
+
value={value}
|
|
24
|
+
>
|
|
25
|
+
{options.map(
|
|
26
|
+
({ id, value, icon, label: toggleLabel, tooltip, disabled } = {}) => {
|
|
27
|
+
return (
|
|
28
|
+
<Tooltip key={id} content={tooltip || toggleLabel}>
|
|
29
|
+
<Toolbar.ToggleItem
|
|
30
|
+
className={classNames(style.item, style.toggle)}
|
|
31
|
+
disabled={disabled}
|
|
32
|
+
value={value}
|
|
33
|
+
aria-label={`${label} aligned`}
|
|
34
|
+
>
|
|
35
|
+
{icon}
|
|
36
|
+
</Toolbar.ToggleItem>
|
|
37
|
+
</Tooltip>
|
|
38
|
+
);
|
|
39
|
+
},
|
|
40
|
+
)}
|
|
41
|
+
</Toolbar.ToggleGroup>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
$item-height: 30px;
|
|
2
|
+
|
|
3
|
+
%shadow {
|
|
4
|
+
box-shadow: 0 2px 10px var(--sp-toolbar-highlight-color);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
%root {
|
|
8
|
+
@extend %shadow;
|
|
9
|
+
display: flex;
|
|
10
|
+
border-radius: 6px;
|
|
11
|
+
color: var(--sp-toolbar-color);
|
|
12
|
+
background-color: var(--sp-toolbar-bg-color);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
%separator {
|
|
16
|
+
background-color: var(--sp-toolbar-separator-color);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
%separator-vertical {
|
|
20
|
+
@extend %separator;
|
|
21
|
+
width: 1px;
|
|
22
|
+
height: $item-height;
|
|
23
|
+
margin: 0 8px;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
%separator-horizontal {
|
|
27
|
+
@extend %separator;
|
|
28
|
+
height: 1px;
|
|
29
|
+
width: 100%;
|
|
30
|
+
margin: 6px 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
%item {
|
|
34
|
+
font-size: 13px;
|
|
35
|
+
line-height: 1em;
|
|
36
|
+
color: var(--sp-toolbar-color);
|
|
37
|
+
cursor: pointer;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
%item-vertical {
|
|
41
|
+
@extend %item;
|
|
42
|
+
padding: 4px 12px 4px 8px;
|
|
43
|
+
min-height: 32px;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
%disabled {
|
|
47
|
+
opacity: 0.4;
|
|
48
|
+
cursor: not-allowed;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
%hover {
|
|
52
|
+
border: 0;
|
|
53
|
+
background-color: var(--sp-toolbar-hover-color);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
%focus {
|
|
57
|
+
position: relative;
|
|
58
|
+
box-shadow: 0 0 0 1px var(--sp-toolbar-hover-color);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
%active {
|
|
62
|
+
background-color: var(--sp-toolbar-active-color);
|
|
63
|
+
}
|