@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.
Files changed (176) hide show
  1. package/.lintstagedrc.js +6 -0
  2. package/.rush/temp/shrinkwrap-deps.json +311 -0
  3. package/.vscode/settings.json +22 -0
  4. package/CHANGELOG.json +17 -0
  5. package/CHANGELOG.md +9 -0
  6. package/components/BubbleMenu.js +181 -0
  7. package/components/BubbleMenu.module.scss +9 -0
  8. package/components/LinkEditDialog.js +105 -0
  9. package/components/LinkEditDialog.module.scss +171 -0
  10. package/components/Popover.js +43 -0
  11. package/components/Popover.module.scss +80 -0
  12. package/components/PrimaryToolbar.js +27 -0
  13. package/components/Select/Select.js +71 -0
  14. package/components/Select/Select.module.scss +100 -0
  15. package/components/Select/SelectGroup.js +37 -0
  16. package/components/Select/index.js +1 -0
  17. package/components/TableCellMenu.js +43 -0
  18. package/components/TableToolbar.js +41 -0
  19. package/components/Tooltip.js +34 -0
  20. package/components/Tooltip.module.scss +87 -0
  21. package/components/VerticalAlignToggle.js +65 -0
  22. package/components/color-picker/ColorPicker.js +28 -0
  23. package/components/color-picker/ColorPicker.module.scss +8 -0
  24. package/components/color-picker/ColorPickerChip.js +22 -0
  25. package/components/color-picker/ColorPickerChip.module.scss +25 -0
  26. package/components/color-picker/ColorPickerCombo.js +45 -0
  27. package/components/color-picker/ColorPickerCombo.module.scss +23 -0
  28. package/components/color-picker/TextColorIcon.js +18 -0
  29. package/components/editor-toolbars/EditorMenu.js +104 -0
  30. package/components/editor-toolbars/EditorMenu.module.scss +96 -0
  31. package/components/editor-toolbars/EditorToolbar.js +146 -0
  32. package/components/editor-toolbars/EditorToolbar.module.scss +75 -0
  33. package/components/editor-toolbars/MenuItem.js +24 -0
  34. package/components/editor-toolbars/SubMenu.js +50 -0
  35. package/components/editor-toolbars/ToolbarButton.js +26 -0
  36. package/components/editor-toolbars/ToolbarToggle.js +35 -0
  37. package/components/editor-toolbars/ToolbarToggleGroup.js +43 -0
  38. package/components/editor-toolbars/utils.js +7 -0
  39. package/components/hooks/use-presenter.js +5 -0
  40. package/components/style.module.scss +63 -0
  41. package/components/tiptap/ListItem.js +5 -0
  42. package/components/tiptap/Table.js +397 -0
  43. package/components/tiptap/TableCells.js +99 -0
  44. package/components/utils.js +84 -0
  45. package/configs/generate-toolbar-configuration.js +130 -0
  46. package/configs/generate-toolbar-options.js +96 -0
  47. package/configs/table-toolbar-configuration.js +187 -0
  48. package/configs/toolbar-configuration.js +330 -0
  49. package/constants.js +198 -0
  50. package/eslint.config.mjs +15 -0
  51. package/icons/AddColumnLeft.js +15 -0
  52. package/icons/AddColumnRight.js +15 -0
  53. package/icons/AddRowAbove.js +15 -0
  54. package/icons/AddRowBelow.js +15 -0
  55. package/icons/AlignHorizontalCenter.js +13 -0
  56. package/icons/AlignHorizontalLeft.js +13 -0
  57. package/icons/AlignHorizontalRight.js +13 -0
  58. package/icons/AlignVerticalBottom.js +13 -0
  59. package/icons/AlignVerticalCenter.js +13 -0
  60. package/icons/AlignVerticalTop.js +13 -0
  61. package/icons/Backspace.js +13 -0
  62. package/icons/Bold.js +14 -0
  63. package/icons/BorderAll.js +13 -0
  64. package/icons/BorderBottom.js +13 -0
  65. package/icons/BorderClear.js +13 -0
  66. package/icons/BorderHorizontal.js +13 -0
  67. package/icons/BorderInner.js +13 -0
  68. package/icons/BorderLeft.js +13 -0
  69. package/icons/BorderOuter.js +13 -0
  70. package/icons/BorderRight.js +13 -0
  71. package/icons/BorderTop.js +13 -0
  72. package/icons/BorderVertical.js +13 -0
  73. package/icons/Close.js +13 -0
  74. package/icons/Delete.js +13 -0
  75. package/icons/EvenlyDistribute.js +14 -0
  76. package/icons/FitWidth.js +13 -0
  77. package/icons/FitWidthArrows.js +21 -0
  78. package/icons/FormatAlignCenter.js +13 -0
  79. package/icons/FormatAlignJustify.js +13 -0
  80. package/icons/FormatAlignLeft.js +13 -0
  81. package/icons/FormatAlignRight.js +13 -0
  82. package/icons/FormatBold.js +13 -0
  83. package/icons/FormatClear.js +13 -0
  84. package/icons/FormatColorFill.js +13 -0
  85. package/icons/FormatColorText.js +13 -0
  86. package/icons/FormatItalic.js +13 -0
  87. package/icons/FormatLineSpacing.js +13 -0
  88. package/icons/FormatListBulleted.js +13 -0
  89. package/icons/FormatListNumbered.js +13 -0
  90. package/icons/FormatStrikethrough.js +13 -0
  91. package/icons/FormatUnderlined.js +13 -0
  92. package/icons/HorizontalRule.js +13 -0
  93. package/icons/Italic.js +14 -0
  94. package/icons/ItalicIcon.js +18 -0
  95. package/icons/Link.js +13 -0
  96. package/icons/LinkOff.js +13 -0
  97. package/icons/MergeCells.js +14 -0
  98. package/icons/Redo.js +13 -0
  99. package/icons/RemoveColumnOutline.js +28 -0
  100. package/icons/RemoveRowOutline.js +25 -0
  101. package/icons/SplitCells.js +14 -0
  102. package/icons/SplitScene.js +13 -0
  103. package/icons/Subscript.js +13 -0
  104. package/icons/Superscript.js +13 -0
  105. package/icons/Underline.js +14 -0
  106. package/icons/Undo.js +13 -0
  107. package/icons/VerticalAlignBottom.js +13 -0
  108. package/icons/VerticalAlignCenter.js +13 -0
  109. package/icons/VerticalAlignTop.js +13 -0
  110. package/icons/add_column_left.svg +6 -0
  111. package/icons/add_column_right.svg +6 -0
  112. package/icons/add_row_above.svg +6 -0
  113. package/icons/add_row_below.svg +6 -0
  114. package/icons/align_horizontal_center.svg +1 -0
  115. package/icons/align_horizontal_left.svg +1 -0
  116. package/icons/align_horizontal_right.svg +1 -0
  117. package/icons/align_vertical_bottom.svg +1 -0
  118. package/icons/align_vertical_center.svg +1 -0
  119. package/icons/align_vertical_top.svg +1 -0
  120. package/icons/backspace.svg +1 -0
  121. package/icons/bold.svg +1 -0
  122. package/icons/border_all.svg +1 -0
  123. package/icons/border_bottom.svg +1 -0
  124. package/icons/border_clear.svg +1 -0
  125. package/icons/border_horizontal.svg +1 -0
  126. package/icons/border_inner.svg +1 -0
  127. package/icons/border_left.svg +1 -0
  128. package/icons/border_outer.svg +1 -0
  129. package/icons/border_right.svg +1 -0
  130. package/icons/border_top.svg +1 -0
  131. package/icons/border_vertical.svg +1 -0
  132. package/icons/close.svg +1 -0
  133. package/icons/delete.svg +1 -0
  134. package/icons/evenly_distribute.svg +5 -0
  135. package/icons/fit_width.svg +1 -0
  136. package/icons/fit_width_arrows.svg +12 -0
  137. package/icons/format_align_center.svg +1 -0
  138. package/icons/format_align_justify.svg +1 -0
  139. package/icons/format_align_left.svg +1 -0
  140. package/icons/format_align_right.svg +1 -0
  141. package/icons/format_bold.svg +1 -0
  142. package/icons/format_clear.svg +1 -0
  143. package/icons/format_color_fill.svg +1 -0
  144. package/icons/format_color_text.svg +5 -0
  145. package/icons/format_color_text_ungrouped.svg +6 -0
  146. package/icons/format_italic.svg +1 -0
  147. package/icons/format_line_spacing.svg +1 -0
  148. package/icons/format_list_bulleted.svg +1 -0
  149. package/icons/format_list_numbered.svg +1 -0
  150. package/icons/format_strikethrough.svg +1 -0
  151. package/icons/format_underlined.svg +1 -0
  152. package/icons/horizontal_rule.svg +1 -0
  153. package/icons/index.js +191 -0
  154. package/icons/italic.svg +1 -0
  155. package/icons/link.svg +1 -0
  156. package/icons/link_off.svg +1 -0
  157. package/icons/merge_cells.svg +5 -0
  158. package/icons/redo.svg +1 -0
  159. package/icons/remove_column_outline.svg +20 -0
  160. package/icons/remove_row_outline.svg +17 -0
  161. package/icons/split_cells.svg +5 -0
  162. package/icons/split_scene.svg +1 -0
  163. package/icons/subscript.svg +1 -0
  164. package/icons/superscript.svg +1 -0
  165. package/icons/underline.svg +1 -0
  166. package/icons/undo.svg +1 -0
  167. package/icons/vertical_align_bottom.svg +1 -0
  168. package/icons/vertical_align_center.svg +1 -0
  169. package/icons/vertical_align_top.svg +1 -0
  170. package/index.js +334 -0
  171. package/index.module.scss +106 -0
  172. package/package.json +63 -0
  173. package/scripts/extract-svg.js +288 -0
  174. package/utils/color-utils.js +42 -0
  175. package/utils/generate-vertical-alignment-icon.js +22 -0
  176. package/utils/generateCustomExtensions.js +49 -0
@@ -0,0 +1,41 @@
1
+ import React from "react";
2
+
3
+ import { useTransitions } from "@livepreso/content-react";
4
+
5
+ import { BubbleMenu } from "./BubbleMenu.js";
6
+ import { EditorToolbar } from "./editor-toolbars/EditorToolbar.js";
7
+
8
+ export function TableToolbar({
9
+ editor,
10
+ editorState,
11
+ userSelections,
12
+ configuration = [],
13
+ maskSelector,
14
+ }) {
15
+ const { exited } = useTransitions();
16
+
17
+ if (exited) {
18
+ return null;
19
+ }
20
+
21
+ return (
22
+ <BubbleMenu
23
+ editor={editor}
24
+ options={{
25
+ placement: "bottom-start",
26
+ closestSelector: "table",
27
+ maskSelector,
28
+ }}
29
+ shouldShow={({ editor }) => {
30
+ return editor.isFocused && editor.isActive("table");
31
+ }}
32
+ >
33
+ <EditorToolbar
34
+ configuration={configuration}
35
+ editor={editor}
36
+ editorState={editorState}
37
+ userSelections={userSelections}
38
+ />
39
+ </BubbleMenu>
40
+ );
41
+ }
@@ -0,0 +1,34 @@
1
+ // your-tooltip.jsx
2
+ import React from "react";
3
+ import { Tooltip as TooltipPrimitive } from "radix-ui";
4
+ import style from "./Tooltip.module.scss";
5
+
6
+ export function Tooltip({
7
+ children,
8
+ content,
9
+ open,
10
+ defaultOpen,
11
+ onOpenChange,
12
+ ...props
13
+ }) {
14
+ return (
15
+ <TooltipPrimitive.Root
16
+ open={open}
17
+ defaultOpen={defaultOpen}
18
+ onOpenChange={onOpenChange}
19
+ >
20
+ <TooltipPrimitive.Trigger asChild>
21
+ <span>{children}</span>
22
+ </TooltipPrimitive.Trigger>
23
+ <TooltipPrimitive.Content
24
+ side="top"
25
+ align="center"
26
+ {...props}
27
+ className={style.content}
28
+ >
29
+ {content}
30
+ <TooltipPrimitive.Arrow width={11} height={5} className={style.arrow} />
31
+ </TooltipPrimitive.Content>
32
+ </TooltipPrimitive.Root>
33
+ );
34
+ }
@@ -0,0 +1,87 @@
1
+ @import "./style.module.scss";
2
+
3
+ $background_colour: var(--sp-toolbar-color);
4
+
5
+ :global(.sp-presenter-overlay) {
6
+ .content {
7
+ position: relative;
8
+ top: -12px;
9
+ border-radius: 4px;
10
+ padding: 6px 10px;
11
+ font-size: 12px;
12
+ line-height: 1;
13
+ color: var(--sp-toolbar-color-white);
14
+ background-color: $background_colour;
15
+ box-shadow:
16
+ hsl(206 22% 7% / 35%) 0px 10px 38px -10px,
17
+ hsl(206 22% 7% / 20%) 0px 10px 20px -15px;
18
+ user-select: none;
19
+ animation-duration: 400ms;
20
+ animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
21
+ will-change: transform, opacity;
22
+
23
+ &[data-state="delayed-open"] {
24
+ animation-name: slideUpAndFade;
25
+ }
26
+ &[data-state="delayed-open"][data-side="top"] {
27
+ animation-name: slideUpAndFade;
28
+ }
29
+ &[data-state="delayed-open"][data-side="right"] {
30
+ animation-name: slideRightAndFade;
31
+ }
32
+ &[data-state="delayed-open"][data-side="bottom"] {
33
+ animation-name: slideDownAndFade;
34
+ }
35
+ &[data-state="delayed-open"][data-side="left"] {
36
+ animation-name: slideLeftAndFade;
37
+ }
38
+ }
39
+
40
+ .arrow {
41
+ fill: $background_colour;
42
+ }
43
+ }
44
+
45
+ @keyframes slideUpAndFade {
46
+ from {
47
+ opacity: 0;
48
+ transform: translateY(2px);
49
+ }
50
+ to {
51
+ opacity: 1;
52
+ transform: translateY(0);
53
+ }
54
+ }
55
+
56
+ @keyframes slideRightAndFade {
57
+ from {
58
+ opacity: 0;
59
+ transform: translateX(-2px);
60
+ }
61
+ to {
62
+ opacity: 1;
63
+ transform: translateX(0);
64
+ }
65
+ }
66
+
67
+ @keyframes slideDownAndFade {
68
+ from {
69
+ opacity: 0;
70
+ transform: translateY(-2px);
71
+ }
72
+ to {
73
+ opacity: 1;
74
+ transform: translateY(0);
75
+ }
76
+ }
77
+
78
+ @keyframes slideLeftAndFade {
79
+ from {
80
+ opacity: 0;
81
+ transform: translateX(2px);
82
+ }
83
+ to {
84
+ opacity: 1;
85
+ transform: translateX(0);
86
+ }
87
+ }
@@ -0,0 +1,65 @@
1
+ import React from "react";
2
+
3
+ import icons from "../icons";
4
+ import { Toolbar, Tooltip } from "radix-ui";
5
+ import { ToolbarToggleGroup } from "./editor-toolbars/ToolbarToggleGroup";
6
+ import toolbarBaseStyle from "./editor-toolbars/EditorToolbar.module.scss";
7
+ import classNames from "classnames";
8
+
9
+ /**
10
+ * A component that renders a toggle group for vertical alignment options.
11
+ *
12
+ * @param {Object} props - The component props
13
+ * @param {string} props.id - The unique identifier for the toggle group
14
+ * @param {string} props.className - CSS class name to apply to the toolbar
15
+ * @param {Function} props.onChange - Callback function triggered when the alignment selection changes
16
+ * @param {string} props.value - The currently selected vertical alignment value
17
+ * @returns {React.Element} A toolbar component containing vertical alignment toggle options
18
+ */
19
+
20
+ export function VerticalAlignToggle({
21
+ id,
22
+ className,
23
+ onChange = () => {},
24
+ value,
25
+ }) {
26
+ return (
27
+ <Tooltip.Provider delayDuration={800} skipDelayDuration={500}>
28
+ <Toolbar.Root className={classNames(toolbarBaseStyle.root, className)}>
29
+ <ToolbarToggleGroup
30
+ key={id}
31
+ label="Vertical alignment"
32
+ type="single"
33
+ value={value}
34
+ options={[
35
+ {
36
+ id: "align-top",
37
+ tooltip: "Align top",
38
+ label: "Top",
39
+ value: "top",
40
+ icon: <icons.VerticalAlignTop />,
41
+ },
42
+ {
43
+ id: "align-middle",
44
+ tooltip: "Align middle",
45
+ label: "Middle",
46
+ value: "middle",
47
+ icon: <icons.VerticalAlignCenter />,
48
+ },
49
+ {
50
+ id: "align-bottom",
51
+ tooltip: "Align bottom",
52
+ label: "Bottom",
53
+ value: "bottom",
54
+ icon: <icons.VerticalAlignBottom />,
55
+ },
56
+ ]}
57
+ onValueChange={(value) => {
58
+ onChange(value);
59
+ }}
60
+ defaultValue="top"
61
+ />
62
+ </Toolbar.Root>
63
+ </Tooltip.Provider>
64
+ );
65
+ }
@@ -0,0 +1,28 @@
1
+ import React from "react";
2
+
3
+ import style from "./ColorPicker.module.scss";
4
+ import { ColorPickerChip } from "./ColorPickerChip";
5
+
6
+ export function ColorPicker({
7
+ className,
8
+ colors = [],
9
+ onChange = () => {},
10
+ value,
11
+ }) {
12
+ function handleChange(color) {
13
+ onChange(color);
14
+ }
15
+
16
+ return (
17
+ <div className={style.options}>
18
+ {colors.map((color, idx) => (
19
+ <ColorPickerChip
20
+ key={`${color}_${idx}`}
21
+ selected={value === color}
22
+ color={color}
23
+ onClick={() => handleChange(color)}
24
+ />
25
+ ))}
26
+ </div>
27
+ );
28
+ }
@@ -0,0 +1,8 @@
1
+ :global(.sp-presenter-overlay) {
2
+ .options {
3
+ display: flex;
4
+ flex-direction: row;
5
+ flex-wrap: wrap;
6
+ width: 180px;
7
+ }
8
+ }
@@ -0,0 +1,22 @@
1
+ import React from "react";
2
+
3
+ import classNames from "classnames";
4
+
5
+ import style from "./ColorPickerChip.module.scss";
6
+
7
+ export function ColorPickerChip({
8
+ className,
9
+ color = "#000000",
10
+ selected = false,
11
+ onClick,
12
+ }) {
13
+ return (
14
+ <div
15
+ onClick={onClick}
16
+ className={classNames(style.colorPickerChip, className, {
17
+ [style.selected]: selected,
18
+ })}
19
+ style={{ backgroundColor: color }}
20
+ />
21
+ );
22
+ }
@@ -0,0 +1,25 @@
1
+ :global(.sp-presenter-overlay) {
2
+ .color-picker-chip {
3
+ width: 30px;
4
+ height: 30px;
5
+ border: 0;
6
+ transition:
7
+ transform 100ms ease-out,
8
+ border-width 100ms ease-out;
9
+ cursor: pointer;
10
+
11
+ &:hover {
12
+ border: 1px solid var(--sp-toolbar-highlight-color);
13
+ transform: scale(0.8);
14
+ }
15
+
16
+ &.selected {
17
+ border: 1px solid var(--sp-toolbar-highlight-color);
18
+ transform: scale(0.8);
19
+
20
+ &:hover {
21
+ transform: scale(0.6);
22
+ }
23
+ }
24
+ }
25
+ }
@@ -0,0 +1,45 @@
1
+ import React from "react";
2
+ import classNames from "classnames";
3
+
4
+ import { ColorPicker } from "./ColorPicker";
5
+ import { Popover } from "../Popover";
6
+ import { ChevronDownIcon } from "@radix-ui/react-icons";
7
+ import { ToolbarButton } from "../editor-toolbars/ToolbarButton";
8
+ import { TextColorIcon } from "./TextColorIcon";
9
+ import toolbarStyle from "../editor-toolbars/EditorToolbar.module.scss";
10
+ import style from "./ColorPickerCombo.module.scss";
11
+
12
+ export function ColorPickerCombo({
13
+ colors,
14
+ onChange,
15
+ value,
16
+ pickerValue,
17
+ disabled,
18
+ }) {
19
+ return (
20
+ <div className={style.container}>
21
+ <ToolbarButton
22
+ className={style.button}
23
+ icon={<TextColorIcon color={value} />}
24
+ onClick={() => onChange(value)}
25
+ disabled={disabled}
26
+ />
27
+ <Popover
28
+ triggerClassName={classNames(
29
+ toolbarStyle.item,
30
+ style.button,
31
+ style.dropdown,
32
+ )}
33
+ trigger={<ChevronDownIcon disabled={disabled} />}
34
+ disabled={disabled}
35
+ >
36
+ <ColorPicker
37
+ colors={colors}
38
+ // null and empty string may be valid for "no color"
39
+ value={typeof pickerValue === "undefined" ? value : pickerValue}
40
+ onChange={onChange}
41
+ />
42
+ </Popover>
43
+ </div>
44
+ );
45
+ }
@@ -0,0 +1,23 @@
1
+ @import "../style.module.scss";
2
+
3
+ :global(.sp-presenter-overlay) {
4
+ .container {
5
+ display: flex;
6
+ flex-direction: row;
7
+ align-items: center;
8
+ justify-content: flex-start;
9
+ height: $item-height;
10
+ border-radius: 4px;
11
+ background-color: var(--sp-toolbar-select-trigger);
12
+
13
+ .button {
14
+ margin: 0;
15
+ line-height: 0;
16
+
17
+ &.dropdown {
18
+ width: 25px;
19
+ padding: 0;
20
+ }
21
+ }
22
+ }
23
+ }
@@ -0,0 +1,18 @@
1
+ import * as React from "react";
2
+
3
+ export function TextColorIcon({ color, ...props }) {
4
+ return (
5
+ <svg
6
+ id="Layer_1"
7
+ xmlns="http://www.w3.org/2000/svg"
8
+ version="1.1"
9
+ height="24px"
10
+ width="24px"
11
+ viewBox="0 0 24 24"
12
+ {...props}
13
+ >
14
+ <rect x="2.5" y="20.3" width="19" height="3.7" fill={color} />
15
+ <path d="M12.9,3.5h-1.7l-5.3,13.5h1.8l1.4-3.6h6l1.3,3.6h1.8L12.9,3.5ZM9.5,11.9l2.4-6.3h.1l2.4,6.3h-4.9Z" />
16
+ </svg>
17
+ );
18
+ }
@@ -0,0 +1,104 @@
1
+ import React, { Fragment } from "react";
2
+ import classNames from "classnames";
3
+ import { DropdownMenu } from "radix-ui";
4
+ import { ChevronDownIcon } from "@radix-ui/react-icons";
5
+
6
+ import { TOOLBAR_COMPONENT_TYPES } from "../../constants";
7
+ import { MenuItem } from "./MenuItem";
8
+ import { SubMenu } from "./SubMenu";
9
+ import { getState } from "./utils";
10
+ import style from "./EditorMenu.module.scss";
11
+
12
+ export function EditorMenu({
13
+ configuration,
14
+ editor,
15
+ editorState,
16
+ userSelections,
17
+ }) {
18
+ const div = window.Bridge.UI.overlay;
19
+ const states = { editorState, userSelections };
20
+
21
+ return (
22
+ <DropdownMenu.Root aria-label="Formatting options">
23
+ <DropdownMenu.Trigger className={classNames(style.trigger, style.light)}>
24
+ <ChevronDownIcon />
25
+ </DropdownMenu.Trigger>
26
+
27
+ <DropdownMenu.Portal container={div}>
28
+ <DropdownMenu.Content
29
+ className={style.content}
30
+ onCloseAutoFocus={(e) => e.preventDefault()}
31
+ align="start"
32
+ sideOffset={5}
33
+ collisionBoundary={div}
34
+ >
35
+ {configuration.flatMap(({ id: groupId, items = [] }, index) => [
36
+ index !== 0 && (
37
+ <DropdownMenu.Separator
38
+ key={`separator-${groupId}`}
39
+ className={style.separator}
40
+ />
41
+ ),
42
+ ...items.map(
43
+ ({
44
+ id,
45
+ type,
46
+ label,
47
+ icon: iconComponent,
48
+ renderIcon,
49
+ ...itemsProps
50
+ }) => {
51
+ const icon = renderIcon ? renderIcon(editor) : iconComponent;
52
+
53
+ if (type === TOOLBAR_COMPONENT_TYPES.CUSTOM) {
54
+ const { renderContent } = itemsProps;
55
+ return (
56
+ <Fragment key={id}>
57
+ {renderContent(editor, states)}
58
+ </Fragment>
59
+ );
60
+ }
61
+
62
+ if (type === TOOLBAR_COMPONENT_TYPES.SUB) {
63
+ const { items, renderItem } = itemsProps;
64
+ const { isEnabled, value } = getState(id, editorState);
65
+
66
+ return (
67
+ <SubMenu
68
+ key={id}
69
+ icon={icon}
70
+ label={label}
71
+ items={items}
72
+ disabled={!isEnabled}
73
+ renderItem={(item) =>
74
+ renderItem(item, { editor, value, ...states })
75
+ }
76
+ />
77
+ );
78
+ }
79
+
80
+ if (type === TOOLBAR_COMPONENT_TYPES.BUTTON) {
81
+ const { command = () => {} } = itemsProps;
82
+ const { isEnabled } = getState(id, editorState);
83
+
84
+ return (
85
+ <MenuItem
86
+ key={id}
87
+ icon={icon}
88
+ label={label}
89
+ className={style.item}
90
+ onClick={() => command(editor, states)}
91
+ disabled={!isEnabled}
92
+ />
93
+ );
94
+ }
95
+
96
+ return null;
97
+ },
98
+ ),
99
+ ])}
100
+ </DropdownMenu.Content>
101
+ </DropdownMenu.Portal>
102
+ </DropdownMenu.Root>
103
+ );
104
+ }
@@ -0,0 +1,96 @@
1
+ @import "../style.module.scss";
2
+
3
+ :global(.sp-presenter-overlay) {
4
+ button.trigger {
5
+ @extend %shadow;
6
+ padding: 5px;
7
+ min-width: max-content;
8
+ border-radius: 6px;
9
+ height: auto;
10
+ cursor: pointer;
11
+ line-height: 0;
12
+
13
+ &[data-disabled] {
14
+ @extend %disabled;
15
+ }
16
+
17
+ &.light {
18
+ background-color: white;
19
+ }
20
+ }
21
+
22
+ .content {
23
+ @extend %root;
24
+ flex-direction: column;
25
+ // min-height: max-content;
26
+ overflow-y: auto;
27
+ overflow-x: hidden;
28
+ max-height: var(--radix-dropdown-menu-content-available-height);
29
+ // overflow: hidden;
30
+
31
+ .item {
32
+ @extend %item-vertical;
33
+ display: flex;
34
+ flex-direction: row;
35
+ flex: 0 0 auto;
36
+ align-items: center;
37
+ justify-content: flex-start;
38
+
39
+ &:first-child {
40
+ padding-top: 8px;
41
+ }
42
+
43
+ &:last-child {
44
+ padding-bottom: 8px;
45
+ }
46
+
47
+ &-label {
48
+ flex: 1;
49
+ }
50
+
51
+ &-icon {
52
+ display: flex;
53
+ justify-content: center;
54
+ align-items: center;
55
+ width: 24px;
56
+ height: 24px;
57
+
58
+ &.item-icon-right {
59
+ justify-content: flex-end;
60
+ }
61
+ }
62
+
63
+ &-label,
64
+ &-icon {
65
+ margin: 0 4px;
66
+
67
+ &:first-child {
68
+ margin-left: 0;
69
+ }
70
+
71
+ &:last-child {
72
+ margin-right: 0;
73
+ }
74
+ }
75
+
76
+ &:hover {
77
+ @extend %hover;
78
+ }
79
+
80
+ &:focus {
81
+ @extend %focus;
82
+ box-shadow: none;
83
+ }
84
+
85
+ &[data-disabled],
86
+ &[disabled] {
87
+ @extend %disabled;
88
+ }
89
+ }
90
+
91
+ .separator {
92
+ @extend %separator-horizontal;
93
+ flex: none;
94
+ }
95
+ }
96
+ }