@monolith-forensics/monolith-ui 1.1.49 → 1.1.51
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/dist/Button/Button.js +3 -1
- package/dist/DropDownMenu/DropDownMenu.d.ts +18 -4
- package/dist/DropDownMenu/DropDownMenu.js +224 -110
- package/dist/DropDownMenu/types.d.ts +1 -0
- package/dist/MonolithUIProvider/GlobalStyle.js +2 -0
- package/dist/RichTextEditor/Components/BubbleMenu.d.ts +12 -2
- package/dist/RichTextEditor/Contexts/RichTextEditorContext.d.ts +5 -0
- package/dist/RichTextEditor/Contexts/RichTextEditorContext.js +7 -0
- package/dist/RichTextEditor/Enums/Controls.d.ts +20 -0
- package/dist/RichTextEditor/Enums/Controls.js +21 -0
- package/dist/RichTextEditor/Enums/Fonts.d.ts +10 -0
- package/dist/RichTextEditor/Enums/Fonts.js +11 -0
- package/dist/RichTextEditor/RichTextEditor.d.ts +2 -0
- package/dist/RichTextEditor/RichTextEditor.js +55 -3
- package/dist/RichTextEditor/Toolbar/ControlsGroup.js +3 -0
- package/dist/RichTextEditor/Toolbar/Toolbar.d.ts +19 -1
- package/dist/RichTextEditor/Toolbar/Toolbar.js +31 -2
- package/dist/RichTextEditor/index.d.ts +3 -0
- package/dist/RichTextEditor/index.js +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/Button/Button.js
CHANGED
|
@@ -203,6 +203,8 @@ const StyledButton = styled.button `
|
|
|
203
203
|
|
|
204
204
|
[data-position="right"] {
|
|
205
205
|
margin-inline-start: 6px;
|
|
206
|
+
padding-inline-start: 6px;
|
|
207
|
+
margin-left: auto;
|
|
206
208
|
display: flex;
|
|
207
209
|
align-items: center;
|
|
208
210
|
}
|
|
@@ -323,7 +325,7 @@ const StyledLoader = styled.span `
|
|
|
323
325
|
`;
|
|
324
326
|
const Button = forwardRef((props, ref) => {
|
|
325
327
|
const { children, loading = false, leftSection = null, rightSection = null, href = null, download = null } = props, other = __rest(props, ["children", "loading", "leftSection", "rightSection", "href", "download"]);
|
|
326
|
-
const buttonContent = (_jsx("span", { className: "inner-span", style: { height: "100%" }, children: loading ? (_jsx(StyledLoader, { children: _jsx(Loader2Icon, {}) })) : (_jsxs(_Fragment, { children: [leftSection && _jsx("span", { "data-position": "left", children: leftSection }), _jsx("span", { className: "button-label", children: children }), rightSection && _jsx("span", { "data-position": "right", children: rightSection })] })) }));
|
|
328
|
+
const buttonContent = (_jsx("span", { className: "inner-span", style: { height: "100%", width: "100%" }, children: loading ? (_jsx(StyledLoader, { children: _jsx(Loader2Icon, {}) })) : (_jsxs(_Fragment, { children: [leftSection && _jsx("span", { "data-position": "left", children: leftSection }), _jsx("span", { className: "button-label", children: children }), rightSection && _jsx("span", { "data-position": "right", children: rightSection })] })) }));
|
|
327
329
|
return (_jsx(StyledButton, Object.assign({ ref: ref }, other, { children: href ? (_jsx(StyledAnchor, { href: href, download: download, children: buttonContent })) : (buttonContent) })));
|
|
328
330
|
});
|
|
329
331
|
export default Button;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComponentPropsWithoutRef, ComponentType, ReactElement, ReactNode, UIEvent } from "react";
|
|
1
|
+
import React, { ComponentPropsWithoutRef, ComponentType, ReactElement, ReactNode, UIEvent } from "react";
|
|
2
2
|
import { ButtonProps } from "../Button";
|
|
3
3
|
import { Size, Variant } from "../core";
|
|
4
4
|
import { DropDownItem } from "./types";
|
|
@@ -6,11 +6,12 @@ interface StyledContentProps {
|
|
|
6
6
|
maxDropdownHeight?: number | string;
|
|
7
7
|
variant?: Variant;
|
|
8
8
|
}
|
|
9
|
-
declare const StyledContent: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<
|
|
9
|
+
declare const StyledContent: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, StyledContentProps>> & string;
|
|
10
10
|
export interface DropDownMenuProps {
|
|
11
11
|
className?: string;
|
|
12
12
|
children?: ReactNode | string;
|
|
13
|
-
|
|
13
|
+
label?: string;
|
|
14
|
+
data: DropDownItem[];
|
|
14
15
|
variant?: Variant;
|
|
15
16
|
defaultValue?: DropDownItem[];
|
|
16
17
|
multiselect?: boolean;
|
|
@@ -28,5 +29,18 @@ export interface DropDownMenuProps {
|
|
|
28
29
|
buttonRender?: (props: any) => ReactElement;
|
|
29
30
|
buttonProps?: ButtonProps;
|
|
30
31
|
}
|
|
31
|
-
|
|
32
|
+
interface MenuProps {
|
|
33
|
+
label?: any;
|
|
34
|
+
nested?: boolean;
|
|
35
|
+
children?: React.ReactNode;
|
|
36
|
+
buttonRender?: (props: any) => ReactElement;
|
|
37
|
+
arrow?: boolean;
|
|
38
|
+
variant?: Variant;
|
|
39
|
+
buttonProps?: ButtonProps;
|
|
40
|
+
size?: Size;
|
|
41
|
+
buttonSize?: Size;
|
|
42
|
+
multiselect?: boolean;
|
|
43
|
+
}
|
|
44
|
+
export declare const Menu: React.ForwardRefExoticComponent<Omit<React.HTMLProps<HTMLButtonElement> & MenuProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
45
|
+
declare const DropDownMenu: ({ data, children, defaultValue, variant, arrow, size, searchable, loading, onScroll, multiselect, renderOption, onItemSelect, onChange, buttonProps, TooltipContent, }: DropDownMenuProps) => import("react/jsx-runtime").JSX.Element;
|
|
32
46
|
export default DropDownMenu;
|
|
@@ -1,12 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
|
+
import { FloatingFocusManager, FloatingList, FloatingNode, FloatingPortal, FloatingTree, autoUpdate, flip, offset, safePolygon, shift, useClick, useDismiss, useFloating, useFloatingNodeId, useFloatingParentNodeId, useFloatingTree, useHover, useInteractions, useListItem, useListNavigation, useMergeRefs, useRole, useTypeahead, } from "@floating-ui/react";
|
|
14
|
+
import React, { forwardRef, useRef, useState, } from "react";
|
|
4
15
|
import styled from "styled-components";
|
|
5
16
|
import { Button, Tooltip, CheckBox, Input } from "..";
|
|
6
17
|
import { useDebouncedCallback } from "use-debounce";
|
|
7
|
-
import { ChevronDownIcon } from "lucide-react";
|
|
18
|
+
import { ChevronDownIcon, ChevronRightIcon } from "lucide-react";
|
|
8
19
|
const StyledFloatContainer = styled.div `
|
|
9
20
|
z-index: 1500;
|
|
21
|
+
outline: none;
|
|
10
22
|
`;
|
|
11
23
|
const StyledInnerItemContainer = styled.div `
|
|
12
24
|
overflow-y: auto;
|
|
@@ -16,28 +28,53 @@ const StyledInnerItemContainer = styled.div `
|
|
|
16
28
|
}
|
|
17
29
|
`;
|
|
18
30
|
const SearchInput = forwardRef((props, ref) => _jsx(Input, Object.assign({ ref: ref, style: { marginBottom: 8 } }, props)));
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
const MenuItem = styled(React.forwardRef((_a, forwardedRef) => {
|
|
32
|
+
var { label, children, disabled, multiselect } = _a, props = __rest(_a, ["label", "children", "disabled", "multiselect"]);
|
|
33
|
+
const menu = React.useContext(MenuContext);
|
|
34
|
+
const item = useListItem({ label: disabled ? null : label });
|
|
35
|
+
const tree = useFloatingTree();
|
|
36
|
+
const isActive = item.index === menu.activeIndex;
|
|
37
|
+
return (_jsx(Button, Object.assign({}, props, { ref: useMergeRefs([item.ref, forwardedRef]), type: "button", role: "menuitem", tabIndex: isActive ? 0 : -1, disabled: disabled }, menu.getItemProps({
|
|
38
|
+
onClick(event) {
|
|
39
|
+
var _a;
|
|
40
|
+
(_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
41
|
+
tree === null || tree === void 0 ? void 0 : tree.events.emit("click");
|
|
42
|
+
},
|
|
43
|
+
onFocus(event) {
|
|
44
|
+
var _a;
|
|
45
|
+
(_a = props.onFocus) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
46
|
+
menu.setHasFocusInside(true);
|
|
47
|
+
},
|
|
48
|
+
}), { children: label || children })));
|
|
49
|
+
})) `
|
|
50
|
+
&.MenuItem {
|
|
51
|
+
color: ${(props) => props.theme.palette.text.primary};
|
|
52
|
+
border-radius: 3px;
|
|
53
|
+
display: flex;
|
|
54
|
+
flex-direction: row;
|
|
55
|
+
gap: 5px;
|
|
56
|
+
align-items: center;
|
|
57
|
+
min-height: 25px;
|
|
58
|
+
width: 100%;
|
|
59
|
+
min-width: fit-content;
|
|
60
|
+
height: auto;
|
|
61
|
+
position: relative;
|
|
62
|
+
user-select: none;
|
|
63
|
+
outline: none;
|
|
31
64
|
|
|
32
|
-
|
|
33
|
-
overflow: hidden;
|
|
34
|
-
text-overflow: ellipsis;
|
|
65
|
+
border: none;
|
|
35
66
|
|
|
36
|
-
|
|
67
|
+
white-space: nowrap;
|
|
68
|
+
overflow: hidden;
|
|
69
|
+
text-overflow: ellipsis;
|
|
37
70
|
|
|
38
|
-
|
|
71
|
+
cursor: pointer;
|
|
72
|
+
text-decoration: none;
|
|
39
73
|
|
|
40
|
-
|
|
74
|
+
font-weight: normal;
|
|
75
|
+
letter-spacing: normal;
|
|
76
|
+
|
|
77
|
+
font-size: ${({ size }) => size === "xs"
|
|
41
78
|
? "11px"
|
|
42
79
|
: size === "sm"
|
|
43
80
|
? "13px"
|
|
@@ -49,7 +86,7 @@ const StyledItem = styled.div `
|
|
|
49
86
|
? "19px"
|
|
50
87
|
: "11px"};
|
|
51
88
|
|
|
52
|
-
|
|
89
|
+
padding: ${({ size }) => size === "xs"
|
|
53
90
|
? "2px 8px"
|
|
54
91
|
: size === "sm"
|
|
55
92
|
? "4px 10px"
|
|
@@ -61,14 +98,26 @@ const StyledItem = styled.div `
|
|
|
61
98
|
? "6px 16px"
|
|
62
99
|
: "2px 8px"};
|
|
63
100
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
101
|
+
&[data-disabled] {
|
|
102
|
+
color: ${(props) => props.theme.palette.text.secondary};
|
|
103
|
+
pointer-events: "none";
|
|
104
|
+
}
|
|
68
105
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
106
|
+
&:hover {
|
|
107
|
+
background-color: ${(props) => props.theme.palette.action.hover};
|
|
108
|
+
color: ${(props) => props.theme.palette.text.primary};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
&:active {
|
|
112
|
+
translate: none;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.button-label {
|
|
116
|
+
display: flex;
|
|
117
|
+
flex-direction: row;
|
|
118
|
+
gap: 5px;
|
|
119
|
+
align-items: center;
|
|
120
|
+
}
|
|
72
121
|
}
|
|
73
122
|
`;
|
|
74
123
|
const StyledContent = styled.div `
|
|
@@ -79,6 +128,8 @@ const StyledContent = styled.div `
|
|
|
79
128
|
overflow-y: hidden;
|
|
80
129
|
overflow-x: hidden;
|
|
81
130
|
|
|
131
|
+
min-width: 150px;
|
|
132
|
+
max-width: 400px;
|
|
82
133
|
max-height: ${({ maxDropdownHeight }) => Number.isInteger(maxDropdownHeight)
|
|
83
134
|
? `${maxDropdownHeight}px`
|
|
84
135
|
: maxDropdownHeight || "250px"};
|
|
@@ -99,6 +150,7 @@ const StyledContent = styled.div `
|
|
|
99
150
|
|
|
100
151
|
border-radius: 5px;
|
|
101
152
|
border: 1px solid ${(props) => props.theme.palette.divider};
|
|
153
|
+
outline: none;
|
|
102
154
|
padding: 5px;
|
|
103
155
|
animation-duration: 400ms;
|
|
104
156
|
animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
|
|
@@ -108,22 +160,123 @@ const StyledContent = styled.div `
|
|
|
108
160
|
display: none;
|
|
109
161
|
}
|
|
110
162
|
`;
|
|
111
|
-
const
|
|
163
|
+
const MenuContext = React.createContext({
|
|
164
|
+
getItemProps: () => ({}),
|
|
165
|
+
activeIndex: null,
|
|
166
|
+
setActiveIndex: () => { },
|
|
167
|
+
setHasFocusInside: () => { },
|
|
168
|
+
isOpen: false,
|
|
169
|
+
});
|
|
170
|
+
const MenuComponent = React.forwardRef((_a, forwardedRef) => {
|
|
171
|
+
var { children, label, arrow, size, buttonSize, variant, buttonProps, buttonRender, multiselect } = _a, props = __rest(_a, ["children", "label", "arrow", "size", "buttonSize", "variant", "buttonProps", "buttonRender", "multiselect"]);
|
|
172
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
173
|
+
const [hasFocusInside, setHasFocusInside] = React.useState(false);
|
|
174
|
+
const [activeIndex, setActiveIndex] = React.useState(null);
|
|
175
|
+
const elementsRef = React.useRef([]);
|
|
176
|
+
const labelsRef = React.useRef([]);
|
|
177
|
+
const parent = React.useContext(MenuContext);
|
|
178
|
+
const tree = useFloatingTree();
|
|
179
|
+
const nodeId = useFloatingNodeId();
|
|
180
|
+
const parentId = useFloatingParentNodeId();
|
|
181
|
+
const item = useListItem();
|
|
182
|
+
const isNested = parentId != null;
|
|
183
|
+
const { floatingStyles, refs, context } = useFloating({
|
|
184
|
+
nodeId,
|
|
185
|
+
open: isOpen,
|
|
186
|
+
onOpenChange: setIsOpen,
|
|
187
|
+
placement: isNested ? "right-start" : "bottom-start",
|
|
188
|
+
middleware: [
|
|
189
|
+
offset({
|
|
190
|
+
mainAxis: isNested ? 0 : 2,
|
|
191
|
+
alignmentAxis: isNested ? -4 : 0,
|
|
192
|
+
}),
|
|
193
|
+
flip(),
|
|
194
|
+
shift(),
|
|
195
|
+
],
|
|
196
|
+
whileElementsMounted: autoUpdate,
|
|
197
|
+
});
|
|
198
|
+
const hover = useHover(context, {
|
|
199
|
+
enabled: isNested,
|
|
200
|
+
delay: { open: 75 },
|
|
201
|
+
handleClose: safePolygon({ blockPointerEvents: true }),
|
|
202
|
+
});
|
|
203
|
+
const click = useClick(context, {
|
|
204
|
+
event: "click",
|
|
205
|
+
toggle: !isNested,
|
|
206
|
+
ignoreMouse: isNested,
|
|
207
|
+
});
|
|
208
|
+
const role = useRole(context, { role: "menu" });
|
|
209
|
+
const dismiss = useDismiss(context, { bubbles: true });
|
|
210
|
+
const listNavigation = useListNavigation(context, {
|
|
211
|
+
listRef: elementsRef,
|
|
212
|
+
activeIndex,
|
|
213
|
+
nested: isNested,
|
|
214
|
+
onNavigate: setActiveIndex,
|
|
215
|
+
});
|
|
216
|
+
const typeahead = useTypeahead(context, {
|
|
217
|
+
listRef: labelsRef,
|
|
218
|
+
onMatch: isOpen ? setActiveIndex : undefined,
|
|
219
|
+
activeIndex,
|
|
220
|
+
});
|
|
221
|
+
const { getReferenceProps, getFloatingProps, getItemProps } = useInteractions([hover, click, role, dismiss]);
|
|
222
|
+
// Event emitter allows you to communicate across tree components.
|
|
223
|
+
// This effect closes all menus when an item gets clicked anywhere
|
|
224
|
+
// in the tree.
|
|
225
|
+
React.useEffect(() => {
|
|
226
|
+
if (!tree)
|
|
227
|
+
return;
|
|
228
|
+
function handleTreeClick() {
|
|
229
|
+
if (!multiselect) {
|
|
230
|
+
setIsOpen(false);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
function onSubMenuOpen(event) {
|
|
234
|
+
if (event.nodeId !== nodeId && event.parentId === parentId) {
|
|
235
|
+
setIsOpen(false);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
tree.events.on("click", handleTreeClick);
|
|
239
|
+
tree.events.on("menuopen", onSubMenuOpen);
|
|
240
|
+
return () => {
|
|
241
|
+
tree.events.off("click", handleTreeClick);
|
|
242
|
+
tree.events.off("menuopen", onSubMenuOpen);
|
|
243
|
+
};
|
|
244
|
+
}, [tree, nodeId, parentId]);
|
|
245
|
+
React.useEffect(() => {
|
|
246
|
+
if (isOpen && tree) {
|
|
247
|
+
tree.events.emit("menuopen", { parentId, nodeId });
|
|
248
|
+
}
|
|
249
|
+
}, [tree, isOpen, nodeId, parentId]);
|
|
250
|
+
return (_jsxs(FloatingNode, { id: nodeId, children: [_jsx(MenuItem, Object.assign({ ref: useMergeRefs([refs.setReference, item.ref, forwardedRef]), tabIndex: !isNested ? undefined : parent.activeIndex === item.index ? 0 : -1, role: isNested ? "menuitem" : undefined, className: isNested ? "MenuItem" : "RootMenu", "data-open": isOpen ? "" : undefined, "data-nested": isNested ? "" : undefined, "data-focus-inside": hasFocusInside ? "" : undefined }, getReferenceProps(parent.getItemProps(Object.assign(Object.assign({}, props), { onFocus(event) {
|
|
251
|
+
var _a;
|
|
252
|
+
(_a = props.onFocus) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
253
|
+
setHasFocusInside(false);
|
|
254
|
+
parent.setHasFocusInside(true);
|
|
255
|
+
} }))), { rightSection: arrow ? (_jsx(ChevronDownIcon, { size: 12 })) : isNested ? (_jsx(ChevronRightIcon, { size: 12 })) : null, size: buttonSize, variant: variant, selected: isOpen }, buttonProps, { children: label })), _jsx(MenuContext.Provider, { value: {
|
|
256
|
+
activeIndex,
|
|
257
|
+
setActiveIndex,
|
|
258
|
+
getItemProps,
|
|
259
|
+
setHasFocusInside,
|
|
260
|
+
isOpen,
|
|
261
|
+
}, children: _jsx(FloatingList, { elementsRef: elementsRef, labelsRef: labelsRef, children: isOpen && (_jsx(FloatingPortal, { children: _jsx(FloatingFocusManager, { context: context, modal: false, initialFocus: isNested ? -1 : 0, returnFocus: !isNested, children: _jsx(StyledFloatContainer, Object.assign({ ref: refs.setFloating, className: "Menu", style: floatingStyles }, getFloatingProps(), { children: _jsx(StyledContent, { className: "mfFloatingContent", children: children }) })) }) })) }) })] }));
|
|
262
|
+
});
|
|
263
|
+
export const Menu = React.forwardRef((props, ref) => {
|
|
264
|
+
const parentId = useFloatingParentNodeId();
|
|
265
|
+
if (parentId === null) {
|
|
266
|
+
return (_jsx(FloatingTree, { children: _jsx(MenuComponent, Object.assign({}, props, { ref: ref })) }));
|
|
267
|
+
}
|
|
268
|
+
return _jsx(MenuComponent, Object.assign({}, props, { ref: ref }));
|
|
269
|
+
});
|
|
270
|
+
const DropDownMenu = ({ data, children, defaultValue, variant, arrow, size, searchable, loading, onScroll, multiselect, renderOption, onItemSelect, onChange, buttonProps, TooltipContent, }) => {
|
|
112
271
|
var _a, _b, _c;
|
|
113
272
|
const isObjectArray = (_a = Object.keys((data === null || data === void 0 ? void 0 : data[0]) || {})) === null || _a === void 0 ? void 0 : _a.includes("label");
|
|
114
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
115
273
|
const [selected, setSelected] = useState(defaultValue || []);
|
|
116
274
|
const [searchValue, setSearchValue] = useState("");
|
|
117
275
|
const scrollContainerRef = useRef(null);
|
|
118
276
|
const searchInputRef = useRef(null);
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
placement: "bottom-start",
|
|
123
|
-
strategy: "absolute",
|
|
124
|
-
// Handle collisions with the viewport
|
|
125
|
-
middleware: [flip(), offset(3)],
|
|
126
|
-
});
|
|
277
|
+
const handleSearch = useDebouncedCallback((e) => {
|
|
278
|
+
setSearchValue(e.target.value);
|
|
279
|
+
}, 150);
|
|
127
280
|
const handleAddItem = (item) => {
|
|
128
281
|
setSelected((prev) => {
|
|
129
282
|
let newSelected = [...prev, item];
|
|
@@ -140,76 +293,37 @@ const DropDownMenu = styled(({ className, children, data = [], variant = "outlin
|
|
|
140
293
|
return newSelected;
|
|
141
294
|
});
|
|
142
295
|
};
|
|
143
|
-
const handleSearch = useDebouncedCallback((e) => {
|
|
144
|
-
setSearchValue(e.target.value);
|
|
145
|
-
}, 150);
|
|
146
|
-
// Close on outside click
|
|
147
|
-
useEffect(() => {
|
|
148
|
-
const close = (e) => {
|
|
149
|
-
var _a, _b, _c, _d;
|
|
150
|
-
const target = e.target;
|
|
151
|
-
const referenceElement = (_a = refs === null || refs === void 0 ? void 0 : refs.reference) === null || _a === void 0 ? void 0 : _a.current;
|
|
152
|
-
const floatingElement = (_b = refs === null || refs === void 0 ? void 0 : refs.floating) === null || _b === void 0 ? void 0 : _b.current;
|
|
153
|
-
if (floatingElement && // Check if the floating element exists
|
|
154
|
-
e.target !== referenceElement && // Check if the target is not the reference (input)
|
|
155
|
-
!((_c = referenceElement === null || referenceElement === void 0 ? void 0 : referenceElement.contains) === null || _c === void 0 ? void 0 : _c.call(referenceElement, target)) && // Check if the target is not inside the reference (input)
|
|
156
|
-
!((_d = floatingElement === null || floatingElement === void 0 ? void 0 : floatingElement.contains) === null || _d === void 0 ? void 0 : _d.call(floatingElement, target)) // Check if the target is not inside the floating element (content)
|
|
157
|
-
) {
|
|
158
|
-
setIsOpen(false);
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
document.addEventListener("mousedown", close);
|
|
162
|
-
return () => document.removeEventListener("mousdown", close);
|
|
163
|
-
}, [refs.floating, refs.reference]);
|
|
164
|
-
useEffect(() => {
|
|
165
|
-
var _a, _b;
|
|
166
|
-
if (isOpen && searchable) {
|
|
167
|
-
(_b = (_a = searchInputRef === null || searchInputRef === void 0 ? void 0 : searchInputRef.current) === null || _a === void 0 ? void 0 : _a.focus) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
168
|
-
}
|
|
169
|
-
if (!isOpen) {
|
|
170
|
-
setSearchValue("");
|
|
171
|
-
}
|
|
172
|
-
}, [isOpen, searchable]);
|
|
173
296
|
const scrollActive = (((_b = scrollContainerRef === null || scrollContainerRef === void 0 ? void 0 : scrollContainerRef.current) === null || _b === void 0 ? void 0 : _b.scrollHeight) || 0) >
|
|
174
297
|
(((_c = scrollContainerRef === null || scrollContainerRef === void 0 ? void 0 : scrollContainerRef.current) === null || _c === void 0 ? void 0 : _c.clientHeight) || 0);
|
|
175
|
-
return (_jsxs("
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
}
|
|
207
|
-
else {
|
|
208
|
-
setIsOpen(false);
|
|
209
|
-
}
|
|
210
|
-
onItemSelect === null || onItemSelect === void 0 ? void 0 : onItemSelect(item);
|
|
211
|
-
(_a = item === null || item === void 0 ? void 0 : item.onClick) === null || _a === void 0 ? void 0 : _a.call(item, item);
|
|
212
|
-
}, "data-selected": isSelected, size: size, children: [multiselect && _jsx(CheckBox, { value: isSelected }), (item === null || item === void 0 ? void 0 : item.leftSection) || null, _jsx(_Fragment, { children: (renderOption === null || renderOption === void 0 ? void 0 : renderOption(item)) || (item === null || item === void 0 ? void 0 : item.label) || item }), (item === null || item === void 0 ? void 0 : item.rightSection) || null] }) }, index));
|
|
213
|
-
})] }) })) }) }) }))] }));
|
|
214
|
-
}) ``;
|
|
298
|
+
return (_jsx(Menu, { label: children, arrow: arrow, buttonSize: size, variant: variant, multiselect: multiselect, buttonProps: buttonProps, children: _jsxs(StyledInnerItemContainer, { ref: scrollContainerRef, "data-scroll-active": scrollActive, onScroll: onScroll, children: [loading && _jsx("div", { children: "Loading..." }), searchable && (_jsx(SearchInput, { ref: searchInputRef, variant: "outlined", size: size, placeholder: "Search", onChange: handleSearch })), !loading &&
|
|
299
|
+
data
|
|
300
|
+
.filter((item) => {
|
|
301
|
+
var _a, _b, _c;
|
|
302
|
+
if (!searchable)
|
|
303
|
+
return true;
|
|
304
|
+
if (isObjectArray) {
|
|
305
|
+
return (((_a = item === null || item === void 0 ? void 0 : item.label) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(searchValue.toLowerCase())) ||
|
|
306
|
+
((_b = item === null || item === void 0 ? void 0 : item.value) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes(searchValue.toLowerCase())));
|
|
307
|
+
}
|
|
308
|
+
return (_c = item.toLowerCase) === null || _c === void 0 ? void 0 : _c.call(item).includes(searchValue.toLowerCase());
|
|
309
|
+
})
|
|
310
|
+
.map((item, index) => {
|
|
311
|
+
const isSelected = !!(selected === null || selected === void 0 ? void 0 : selected.find((s) => isObjectArray ? (s === null || s === void 0 ? void 0 : s.value) === (item === null || item === void 0 ? void 0 : item.value) : s === item));
|
|
312
|
+
if (item.items) {
|
|
313
|
+
return (_jsx(DropDownMenu, { data: item.items, children: item.label }));
|
|
314
|
+
}
|
|
315
|
+
return (_jsx(Tooltip, { content: TooltipContent ? _jsx(TooltipContent, { data: item.data }) : null, side: "left", children: _jsxs(MenuItem, { className: "MenuItem", "data-selected": isSelected, leftSection: multiselect && _jsx(CheckBox, { value: isSelected, size: size }), multiselect: multiselect, size: size, onClick: (e) => {
|
|
316
|
+
var _a;
|
|
317
|
+
e.preventDefault();
|
|
318
|
+
e.stopPropagation();
|
|
319
|
+
if (multiselect) {
|
|
320
|
+
isSelected
|
|
321
|
+
? handleRemoveItem(item)
|
|
322
|
+
: handleAddItem(item);
|
|
323
|
+
}
|
|
324
|
+
onItemSelect === null || onItemSelect === void 0 ? void 0 : onItemSelect(item);
|
|
325
|
+
(_a = item === null || item === void 0 ? void 0 : item.onClick) === null || _a === void 0 ? void 0 : _a.call(item, item);
|
|
326
|
+
}, children: [(item === null || item === void 0 ? void 0 : item.leftSection) || null, _jsx(_Fragment, { children: (renderOption === null || renderOption === void 0 ? void 0 : renderOption(item)) || (item === null || item === void 0 ? void 0 : item.label) || item }), (item === null || item === void 0 ? void 0 : item.rightSection) || null] }, index) }, index));
|
|
327
|
+
})] }) }));
|
|
328
|
+
};
|
|
215
329
|
export default DropDownMenu;
|
|
@@ -20,15 +20,25 @@ interface BubbleMenuDropDownItem extends DropDownItem {
|
|
|
20
20
|
export type BubbleItem = {
|
|
21
21
|
name: Extensions | string;
|
|
22
22
|
icon?: React.FC<any>;
|
|
23
|
-
type
|
|
23
|
+
type: "menu";
|
|
24
24
|
label?: string | Element;
|
|
25
|
-
items
|
|
25
|
+
items: BubbleMenuDropDownItem[];
|
|
26
26
|
arrow?: boolean;
|
|
27
27
|
isActive?: (editor: Editor) => boolean;
|
|
28
28
|
buttonRender?: (props: any) => ReactElement;
|
|
29
29
|
buttonProps?: ButtonProps;
|
|
30
30
|
dropDownProps?: DropDownMenuProps;
|
|
31
31
|
onClick?: (editor: Editor) => void;
|
|
32
|
+
} | {
|
|
33
|
+
name: Extensions | string;
|
|
34
|
+
icon?: React.FC<any>;
|
|
35
|
+
type: "button";
|
|
36
|
+
label?: string | Element;
|
|
37
|
+
arrow?: boolean;
|
|
38
|
+
isActive?: (editor: Editor) => boolean;
|
|
39
|
+
buttonRender?: (props: any) => ReactElement;
|
|
40
|
+
buttonProps?: ButtonProps;
|
|
41
|
+
onClick?: (editor: Editor) => void;
|
|
32
42
|
};
|
|
33
43
|
declare const BubbleMenu: React.FC<BubbleMenuProps>;
|
|
34
44
|
export default BubbleMenu;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare enum Controls {
|
|
2
|
+
UNDO = "undo",
|
|
3
|
+
REDO = "redo",
|
|
4
|
+
BOLD = "bold",
|
|
5
|
+
ITALIC = "italic",
|
|
6
|
+
UNDERLINE = "underline",
|
|
7
|
+
STRIKE = "strike",
|
|
8
|
+
HEADING_1 = "heading_1",
|
|
9
|
+
HEADING_2 = "heading_2",
|
|
10
|
+
HEADING_3 = "heading_3",
|
|
11
|
+
HEADING_4 = "heading_4",
|
|
12
|
+
BULLET_LIST = "bulletList",
|
|
13
|
+
ORDERED_LIST = "orderedList",
|
|
14
|
+
TEXT_ALIGN_LEFT = "textAlignLeft",
|
|
15
|
+
TEXT_ALIGN_CENTER = "textAlignCenter",
|
|
16
|
+
TEXT_ALIGN_RIGHT = "textAlignRight",
|
|
17
|
+
TEXT_ALIGN_JUSTIFIED = "textAlignJustified",
|
|
18
|
+
FONT = "font"
|
|
19
|
+
}
|
|
20
|
+
export default Controls;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
var Controls;
|
|
2
|
+
(function (Controls) {
|
|
3
|
+
Controls["UNDO"] = "undo";
|
|
4
|
+
Controls["REDO"] = "redo";
|
|
5
|
+
Controls["BOLD"] = "bold";
|
|
6
|
+
Controls["ITALIC"] = "italic";
|
|
7
|
+
Controls["UNDERLINE"] = "underline";
|
|
8
|
+
Controls["STRIKE"] = "strike";
|
|
9
|
+
Controls["HEADING_1"] = "heading_1";
|
|
10
|
+
Controls["HEADING_2"] = "heading_2";
|
|
11
|
+
Controls["HEADING_3"] = "heading_3";
|
|
12
|
+
Controls["HEADING_4"] = "heading_4";
|
|
13
|
+
Controls["BULLET_LIST"] = "bulletList";
|
|
14
|
+
Controls["ORDERED_LIST"] = "orderedList";
|
|
15
|
+
Controls["TEXT_ALIGN_LEFT"] = "textAlignLeft";
|
|
16
|
+
Controls["TEXT_ALIGN_CENTER"] = "textAlignCenter";
|
|
17
|
+
Controls["TEXT_ALIGN_RIGHT"] = "textAlignRight";
|
|
18
|
+
Controls["TEXT_ALIGN_JUSTIFIED"] = "textAlignJustified";
|
|
19
|
+
Controls["FONT"] = "font";
|
|
20
|
+
})(Controls || (Controls = {}));
|
|
21
|
+
export default Controls;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
var Fonts;
|
|
2
|
+
(function (Fonts) {
|
|
3
|
+
Fonts["DEFAULT"] = "Default";
|
|
4
|
+
Fonts["ARIAL"] = "Arial";
|
|
5
|
+
Fonts["COURIER_NEW"] = "Courier New";
|
|
6
|
+
Fonts["TIMES_NEW_ROMAN"] = "Times New Roman";
|
|
7
|
+
Fonts["SEGOE_UI"] = "Segoe UI";
|
|
8
|
+
Fonts["ROBOTO"] = "Roboto";
|
|
9
|
+
Fonts["VERANDA"] = "Veranda";
|
|
10
|
+
})(Fonts || (Fonts = {}));
|
|
11
|
+
export default Fonts;
|
|
@@ -2,6 +2,7 @@ import { Editor } from "@tiptap/react";
|
|
|
2
2
|
import { ExtensionType } from "./Extensions/getTiptapExtensions";
|
|
3
3
|
import { HandleImageUpload } from "./Plugins/UploadImagesPlugin";
|
|
4
4
|
import { BubbleMenuOptions } from "./Extensions/BubbleMenuExtension";
|
|
5
|
+
import { ToolbarOptions } from "./Toolbar/Toolbar";
|
|
5
6
|
interface RichTextEditorProps {
|
|
6
7
|
className?: string;
|
|
7
8
|
editorInstanceRef?: React.RefObject<Editor>;
|
|
@@ -16,6 +17,7 @@ interface RichTextEditorProps {
|
|
|
16
17
|
onChange?: (value: string) => void;
|
|
17
18
|
handleImageUpload?: HandleImageUpload;
|
|
18
19
|
bubbleMenuOptions?: BubbleMenuOptions;
|
|
20
|
+
toolbarOptions?: ToolbarOptions;
|
|
19
21
|
style?: React.CSSProperties;
|
|
20
22
|
}
|
|
21
23
|
declare const RichTextEditor: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<RichTextEditorProps & import("react").RefAttributes<unknown>, "ref"> & {
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useEffect } from "react";
|
|
2
|
+
import { forwardRef, useEffect, useState } from "react";
|
|
3
3
|
import styled from "styled-components";
|
|
4
4
|
import { EditorContent, useEditor } from "@tiptap/react";
|
|
5
5
|
import Toolbar from "./Toolbar";
|
|
6
6
|
import getTipTapExtensions from "./Extensions/getTiptapExtensions";
|
|
7
7
|
import Extensions from "./Enums/Extensions";
|
|
8
|
+
import { startImageUpload, } from "./Plugins/UploadImagesPlugin";
|
|
8
9
|
import SaveBadge from "./Components/SaveBadge";
|
|
9
|
-
|
|
10
|
+
import Fonts from "./Enums/Fonts";
|
|
11
|
+
import RichTextEditorContext from "./Contexts/RichTextEditorContext";
|
|
12
|
+
const RichTextEditor = styled(forwardRef(({ className, editorInstanceRef, defaultValue = "", readOnly = false, font, showToolbar = true, saving = false, extensions = [], slashCommands = [], bubbleMenuOptions, toolbarOptions, onChange, handleImageUpload, style, }, ref) => {
|
|
13
|
+
const [fontState, setFontState] = useState(font || Fonts.DEFAULT);
|
|
10
14
|
// check if image extension is included
|
|
11
15
|
if (extensions === null || extensions === void 0 ? void 0 : extensions.includes(Extensions.Image)) {
|
|
12
16
|
// Ensure that handleImageUpload is provided
|
|
@@ -23,6 +27,49 @@ const RichTextEditor = styled(forwardRef(({ className, editorInstanceRef, defaul
|
|
|
23
27
|
bubbleMenuOptions,
|
|
24
28
|
handleImageUpload,
|
|
25
29
|
}),
|
|
30
|
+
editorProps: {
|
|
31
|
+
handlePaste: (view, event) => {
|
|
32
|
+
if (!handleImageUpload)
|
|
33
|
+
return false;
|
|
34
|
+
if (!(event === null || event === void 0 ? void 0 : event.clipboardData))
|
|
35
|
+
return false;
|
|
36
|
+
if (event.clipboardData.types.includes("text/html") ||
|
|
37
|
+
event.clipboardData.types.includes("text/plain") ||
|
|
38
|
+
event.clipboardData.types.includes("text/rtf"))
|
|
39
|
+
return false;
|
|
40
|
+
if (event.clipboardData &&
|
|
41
|
+
event.clipboardData.files &&
|
|
42
|
+
event.clipboardData.files[0]) {
|
|
43
|
+
event.preventDefault();
|
|
44
|
+
const file = event.clipboardData.files[0];
|
|
45
|
+
const pos = view.state.selection.from;
|
|
46
|
+
startImageUpload(file, view, pos, handleImageUpload);
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
return false;
|
|
50
|
+
},
|
|
51
|
+
handleDrop: (view, event, _slice, moved) => {
|
|
52
|
+
if (!handleImageUpload)
|
|
53
|
+
return false;
|
|
54
|
+
if (!moved &&
|
|
55
|
+
event.dataTransfer &&
|
|
56
|
+
event.dataTransfer.files &&
|
|
57
|
+
event.dataTransfer.files[0]) {
|
|
58
|
+
event.preventDefault();
|
|
59
|
+
const file = event.dataTransfer.files[0];
|
|
60
|
+
const coordinates = view.posAtCoords({
|
|
61
|
+
left: event.clientX,
|
|
62
|
+
top: event.clientY,
|
|
63
|
+
});
|
|
64
|
+
if (!coordinates)
|
|
65
|
+
return false;
|
|
66
|
+
// here we deduct 1 from the pos or else the image will create an extra node
|
|
67
|
+
startImageUpload(file, view, coordinates.pos - 1, handleImageUpload);
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
return false;
|
|
71
|
+
},
|
|
72
|
+
},
|
|
26
73
|
onUpdate: ({ editor }) => {
|
|
27
74
|
onChange === null || onChange === void 0 ? void 0 : onChange(editor.getHTML());
|
|
28
75
|
},
|
|
@@ -33,7 +80,10 @@ const RichTextEditor = styled(forwardRef(({ className, editorInstanceRef, defaul
|
|
|
33
80
|
_ref.current = editor;
|
|
34
81
|
}
|
|
35
82
|
}, [editor]);
|
|
36
|
-
return (
|
|
83
|
+
return (_jsx("div", { className: className, children: _jsxs(RichTextEditorContext.Provider, { value: {
|
|
84
|
+
font: fontState,
|
|
85
|
+
setFont: setFontState,
|
|
86
|
+
}, children: [showToolbar && (_jsx(Toolbar, { editor: editor, toolbarOptions: toolbarOptions })), saving && _jsx(SaveBadge, {}), _jsx(EditorContent, { className: "editor-content", editor: editor, "data-font": fontState || null, style: style })] }) }));
|
|
37
87
|
})) `
|
|
38
88
|
position: relative;
|
|
39
89
|
display: flex;
|
|
@@ -136,9 +186,11 @@ const RichTextEditor = styled(forwardRef(({ className, editorInstanceRef, defaul
|
|
|
136
186
|
}
|
|
137
187
|
ul {
|
|
138
188
|
margin: 0;
|
|
189
|
+
font-size: 0.8rem;
|
|
139
190
|
}
|
|
140
191
|
ol {
|
|
141
192
|
margin: 0;
|
|
193
|
+
font-size: 0.8rem;
|
|
142
194
|
}
|
|
143
195
|
.editor-link {
|
|
144
196
|
color: ${({ theme }) => theme.palette.primary.main};
|
|
@@ -2,6 +2,9 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
import styled from "styled-components";
|
|
4
4
|
const ControlsGroup = styled(forwardRef(({ className, children }, ref) => {
|
|
5
|
+
if (!children) {
|
|
6
|
+
return null;
|
|
7
|
+
}
|
|
5
8
|
return (_jsx("div", { className: className + " controls-group", ref: ref, children: children }));
|
|
6
9
|
})) `
|
|
7
10
|
& {
|
|
@@ -1,7 +1,25 @@
|
|
|
1
1
|
import { Editor } from "@tiptap/react";
|
|
2
|
+
import Controls from "../Enums/Controls";
|
|
3
|
+
import { ReactNode } from "react";
|
|
4
|
+
import { DropDownMenuProps } from "../../DropDownMenu/DropDownMenu";
|
|
5
|
+
import { ButtonProps } from "../../Button";
|
|
6
|
+
export type CustomItem = {
|
|
7
|
+
type: "button";
|
|
8
|
+
options: ButtonProps & {
|
|
9
|
+
label: ReactNode;
|
|
10
|
+
};
|
|
11
|
+
} | {
|
|
12
|
+
type: "menu";
|
|
13
|
+
options: DropDownMenuProps;
|
|
14
|
+
};
|
|
15
|
+
export interface ToolbarOptions {
|
|
16
|
+
controls?: Array<Controls | CustomItem>;
|
|
17
|
+
customItems?: CustomItem[];
|
|
18
|
+
}
|
|
2
19
|
interface ToolbarProps {
|
|
3
20
|
className?: string;
|
|
4
21
|
editor: Editor | null;
|
|
22
|
+
toolbarOptions?: ToolbarOptions;
|
|
5
23
|
}
|
|
6
|
-
declare const Toolbar: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<ToolbarProps, never>> & string & Omit<({ className, editor }: ToolbarProps) => import("react/jsx-runtime").JSX.Element, keyof import("react").Component<any, {}, any>>;
|
|
24
|
+
declare const Toolbar: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<ToolbarProps, never>> & string & Omit<({ className, editor, toolbarOptions }: ToolbarProps) => import("react/jsx-runtime").JSX.Element, keyof import("react").Component<any, {}, any>>;
|
|
7
25
|
export default Toolbar;
|
|
@@ -2,8 +2,37 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import styled from "styled-components";
|
|
3
3
|
import ControlsGroup from "./ControlsGroup";
|
|
4
4
|
import { UndoControl, RedoControl, BoldControl, ItalicControl, UnderlineControl, StrikeThroughControl, Heading1Control, Heading2Control, Heading3Control, Heading4Control, BulletListControl, OrderedListControl, AlignLeftControl, AlignCenterControl, AlignRightControl, AlignJustifiedControl, } from "./Controls";
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
import Controls from "../Enums/Controls";
|
|
6
|
+
import DropDownMenu from "../../DropDownMenu";
|
|
7
|
+
import Fonts from "../Enums/Fonts";
|
|
8
|
+
import { useContext } from "react";
|
|
9
|
+
import RichTextEditorContext from "../Contexts/RichTextEditorContext";
|
|
10
|
+
import Button from "../../Button";
|
|
11
|
+
const Toolbar = styled(({ className, editor, toolbarOptions }) => {
|
|
12
|
+
var _a;
|
|
13
|
+
const { controls } = toolbarOptions || {};
|
|
14
|
+
const customItems = controls === null || controls === void 0 ? void 0 : controls.filter((control) => typeof control !== "string" && control.type === ("menu" || "button"));
|
|
15
|
+
const { font, setFont } = useContext(RichTextEditorContext);
|
|
16
|
+
return (_jsxs("div", { className: className, children: [(_a = customItems === null || customItems === void 0 ? void 0 : customItems.map) === null || _a === void 0 ? void 0 : _a.call(customItems, (item, index) => {
|
|
17
|
+
var _a, _b;
|
|
18
|
+
if (item.type === "button") {
|
|
19
|
+
return (_jsx(Button, Object.assign({}, item.options, { children: (_a = item === null || item === void 0 ? void 0 : item.options) === null || _a === void 0 ? void 0 : _a.label }), index));
|
|
20
|
+
}
|
|
21
|
+
else if (item.type === "menu") {
|
|
22
|
+
return (_jsx(DropDownMenu, Object.assign({}, item.options, { children: (_b = item === null || item === void 0 ? void 0 : item.options) === null || _b === void 0 ? void 0 : _b.label }), index));
|
|
23
|
+
}
|
|
24
|
+
}), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.FONT)) && (_jsx(DropDownMenu, { data: Object.values(Fonts).map((font) => ({
|
|
25
|
+
label: font,
|
|
26
|
+
value: font,
|
|
27
|
+
onClick: () => {
|
|
28
|
+
setFont(font);
|
|
29
|
+
},
|
|
30
|
+
})), size: "xxs", variant: "outlined", arrow: true, buttonProps: {
|
|
31
|
+
style: {
|
|
32
|
+
fontWeight: "normal",
|
|
33
|
+
},
|
|
34
|
+
title: "Select Font",
|
|
35
|
+
}, children: (font || Fonts.DEFAULT) })), _jsxs(ControlsGroup, { children: [(controls === null || controls === void 0 ? void 0 : controls.includes(Controls.UNDO)) && _jsx(UndoControl, { editor: editor }), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.REDO)) && _jsx(RedoControl, { editor: editor })] }), _jsxs(ControlsGroup, { children: [(controls === null || controls === void 0 ? void 0 : controls.includes(Controls.BOLD)) && _jsx(BoldControl, { editor: editor }), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.ITALIC)) && (_jsx(ItalicControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.UNDERLINE)) && (_jsx(UnderlineControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.STRIKE)) && (_jsx(StrikeThroughControl, { editor: editor }))] }), _jsxs(ControlsGroup, { children: [(controls === null || controls === void 0 ? void 0 : controls.includes(Controls.HEADING_1)) && (_jsx(Heading1Control, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.HEADING_2)) && (_jsx(Heading2Control, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.HEADING_3)) && (_jsx(Heading3Control, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.HEADING_4)) && (_jsx(Heading4Control, { editor: editor }))] }), _jsxs(ControlsGroup, { children: [(controls === null || controls === void 0 ? void 0 : controls.includes(Controls.BULLET_LIST)) && (_jsx(BulletListControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.ORDERED_LIST)) && (_jsx(OrderedListControl, { editor: editor }))] }), _jsxs(ControlsGroup, { children: [(controls === null || controls === void 0 ? void 0 : controls.includes(Controls.TEXT_ALIGN_LEFT)) && (_jsx(AlignLeftControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.TEXT_ALIGN_CENTER)) && (_jsx(AlignCenterControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.TEXT_ALIGN_RIGHT)) && (_jsx(AlignRightControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.TEXT_ALIGN_JUSTIFIED)) && (_jsx(AlignJustifiedControl, { editor: editor }))] })] }));
|
|
7
36
|
}) `
|
|
8
37
|
display: flex;
|
|
9
38
|
flex-direction: row;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
export { default } from "./RichTextEditor";
|
|
2
2
|
export { default as Extensions } from "./Enums/Extensions";
|
|
3
3
|
export { default as SlashCommands } from "./Enums/SlashCommands";
|
|
4
|
+
export { default as Controls } from "./Enums/Controls";
|
|
5
|
+
export type { CustomItem } from "./Toolbar/Toolbar";
|
|
6
|
+
export type { ToolbarOptions } from "./Toolbar/Toolbar";
|
package/dist/index.d.ts
CHANGED
|
@@ -26,4 +26,5 @@ export { default as Table } from "./Table";
|
|
|
26
26
|
export { Column } from "./Table";
|
|
27
27
|
export { default as MonolithUIProvider } from "./MonolithUIProvider";
|
|
28
28
|
export { useMonolithUITheme } from "./MonolithUIProvider";
|
|
29
|
-
export { default as RichTextEditor, Extensions, SlashCommands, } from "./RichTextEditor";
|
|
29
|
+
export { default as RichTextEditor, Extensions, SlashCommands, Controls, } from "./RichTextEditor";
|
|
30
|
+
export type { CustomItem, ToolbarOptions } from "./RichTextEditor";
|
package/dist/index.js
CHANGED
|
@@ -24,4 +24,4 @@ export { default as Table } from "./Table";
|
|
|
24
24
|
export { Column } from "./Table";
|
|
25
25
|
export { default as MonolithUIProvider } from "./MonolithUIProvider";
|
|
26
26
|
export { useMonolithUITheme } from "./MonolithUIProvider";
|
|
27
|
-
export { default as RichTextEditor, Extensions, SlashCommands, } from "./RichTextEditor";
|
|
27
|
+
export { default as RichTextEditor, Extensions, SlashCommands, Controls, } from "./RichTextEditor";
|