@monolith-forensics/monolith-ui 1.1.46 → 1.1.48

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 (50) hide show
  1. package/dist/Button/Button.d.ts +1 -0
  2. package/dist/Button/Button.js +3 -1
  3. package/dist/DropDownMenu/DropDownMenu.d.ts +6 -10
  4. package/dist/DropDownMenu/DropDownMenu.js +13 -6
  5. package/dist/DropDownMenu/index.d.ts +1 -0
  6. package/dist/DropDownMenu/types.d.ts +9 -0
  7. package/dist/DropDownMenu/types.js +1 -0
  8. package/dist/MonolithUIProvider/GlobalStyle.js +18 -0
  9. package/dist/MonolithUIProvider/MonolithUIProvider.d.ts +1 -1
  10. package/dist/RichTextEditor/Components/BubbleMenu.d.ts +34 -0
  11. package/dist/RichTextEditor/Components/BubbleMenu.js +276 -0
  12. package/dist/RichTextEditor/Components/SaveBadge.d.ts +6 -0
  13. package/dist/RichTextEditor/Components/SaveBadge.js +16 -0
  14. package/dist/RichTextEditor/Enums/Extensions.d.ts +26 -0
  15. package/dist/RichTextEditor/Enums/Extensions.js +27 -0
  16. package/dist/RichTextEditor/Enums/SlashCommands.d.ts +13 -0
  17. package/dist/RichTextEditor/Enums/SlashCommands.js +14 -0
  18. package/dist/RichTextEditor/Extensions/BubbleMenuExtension.d.ts +7 -0
  19. package/dist/RichTextEditor/Extensions/BubbleMenuExtension.js +157 -0
  20. package/dist/RichTextEditor/Extensions/SlashCommandList.d.ts +9 -0
  21. package/dist/RichTextEditor/Extensions/SlashCommandList.js +133 -0
  22. package/dist/RichTextEditor/Extensions/getSlashCommand.d.ts +10 -0
  23. package/dist/RichTextEditor/Extensions/getSlashCommand.js +296 -0
  24. package/dist/RichTextEditor/Extensions/getTiptapExtensions.d.ts +13 -0
  25. package/dist/RichTextEditor/Extensions/getTiptapExtensions.js +180 -0
  26. package/dist/RichTextEditor/Plugins/UploadImagesPlugin.d.ts +16 -0
  27. package/dist/RichTextEditor/Plugins/UploadImagesPlugin.js +114 -0
  28. package/dist/RichTextEditor/RichTextEditor.d.ts +24 -0
  29. package/dist/RichTextEditor/RichTextEditor.js +308 -0
  30. package/dist/RichTextEditor/Toolbar/Control.d.ts +14 -0
  31. package/dist/RichTextEditor/Toolbar/Control.js +33 -0
  32. package/dist/RichTextEditor/Toolbar/Controls.d.ts +21 -0
  33. package/dist/RichTextEditor/Toolbar/Controls.js +120 -0
  34. package/dist/RichTextEditor/Toolbar/ControlsGroup.d.ts +8 -0
  35. package/dist/RichTextEditor/Toolbar/ControlsGroup.js +26 -0
  36. package/dist/RichTextEditor/Toolbar/Labels.d.ts +41 -0
  37. package/dist/RichTextEditor/Toolbar/Labels.js +46 -0
  38. package/dist/RichTextEditor/Toolbar/Toolbar.d.ts +7 -0
  39. package/dist/RichTextEditor/Toolbar/Toolbar.js +17 -0
  40. package/dist/RichTextEditor/Toolbar/index.d.ts +1 -0
  41. package/dist/RichTextEditor/Toolbar/index.js +1 -0
  42. package/dist/RichTextEditor/index.d.ts +3 -0
  43. package/dist/RichTextEditor/index.js +3 -0
  44. package/dist/Utilities/calculateFileHash.d.ts +8 -0
  45. package/dist/Utilities/calculateFileHash.js +38 -0
  46. package/dist/Utilities/readFileAsBuffer.d.ts +2 -0
  47. package/dist/Utilities/readFileAsBuffer.js +10 -0
  48. package/dist/index.d.ts +3 -0
  49. package/dist/index.js +1 -0
  50. package/package.json +21 -1
@@ -13,6 +13,7 @@ export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
13
13
  variant?: Variant;
14
14
  color?: string;
15
15
  disabled?: boolean;
16
+ selected?: boolean;
16
17
  onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
17
18
  }
18
19
  declare const Button: import("react").ForwardRefExoticComponent<ButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
@@ -117,7 +117,7 @@ const StyledButton = styled.button `
117
117
  }
118
118
  }};
119
119
 
120
- background-color: ${({ theme, variant, color }) => {
120
+ background-color: ${({ theme, variant, color, selected }) => {
121
121
  var _a, _b, _c, _d, _e, _f;
122
122
  if (variant === "default")
123
123
  return "transparent";
@@ -144,6 +144,8 @@ const StyledButton = styled.button `
144
144
  return "transparent";
145
145
  case "text":
146
146
  return "transparent";
147
+ case "subtle":
148
+ return selected ? theme.palette.action.hover : "transparent";
147
149
  default:
148
150
  return "transparent";
149
151
  }
@@ -1,20 +1,15 @@
1
- import { ComponentPropsWithoutRef, ComponentType, ReactNode, UIEvent } from "react";
1
+ import { ComponentPropsWithoutRef, ComponentType, ReactElement, ReactNode, UIEvent } from "react";
2
2
  import { ButtonProps } from "../Button";
3
3
  import { Size, Variant } from "../core";
4
+ import { DropDownItem } from "./types";
4
5
  interface StyledContentProps {
5
6
  maxDropdownHeight?: number | string;
6
7
  variant?: Variant;
7
8
  }
8
9
  declare const StyledContent: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, StyledContentProps>> & string;
9
- interface DropDownItem {
10
- toLowerCase?: () => string;
11
- label: string;
12
- value: string;
13
- data?: any;
14
- }
15
- interface DropDownMenuProps {
10
+ export interface DropDownMenuProps {
16
11
  className?: string;
17
- children?: ReactNode;
12
+ children?: ReactNode | string;
18
13
  data?: DropDownItem[];
19
14
  variant?: Variant;
20
15
  defaultValue?: DropDownItem[];
@@ -30,7 +25,8 @@ interface DropDownMenuProps {
30
25
  arrow?: boolean;
31
26
  searchable?: boolean;
32
27
  dropDownProps?: ComponentPropsWithoutRef<typeof StyledContent>;
28
+ buttonRender?: (props: any) => ReactElement;
33
29
  buttonProps?: ButtonProps;
34
30
  }
35
- declare const DropDownMenu: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<DropDownMenuProps, never>> & string & Omit<({ className, children, data, variant, defaultValue, multiselect, size, TooltipContent, renderOption, onChange, onItemSelect, onScroll, loading, arrow, searchable, dropDownProps, buttonProps, }: DropDownMenuProps) => import("react/jsx-runtime").JSX.Element, keyof import("react").Component<any, {}, any>>;
31
+ declare const DropDownMenu: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<DropDownMenuProps, never>> & string & Omit<({ className, children, data, variant, defaultValue, multiselect, size, TooltipContent, renderOption, onChange, onItemSelect, onScroll, loading, arrow, searchable, dropDownProps, buttonRender, buttonProps, }: DropDownMenuProps) => import("react/jsx-runtime").JSX.Element, keyof import("react").Component<any, {}, any>>;
36
32
  export default DropDownMenu;
@@ -1,9 +1,10 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { FloatingFocusManager, FloatingPortal, flip, useFloating, } from "@floating-ui/react";
2
+ import { FloatingFocusManager, FloatingPortal, flip, offset, useFloating, } from "@floating-ui/react";
3
3
  import { forwardRef, useEffect, useRef, useState, } from "react";
4
4
  import styled from "styled-components";
5
5
  import { Button, Tooltip, CheckBox, Input } from "..";
6
6
  import { useDebouncedCallback } from "use-debounce";
7
+ import { ChevronDownIcon } from "lucide-react";
7
8
  const StyledFloatContainer = styled.div `
8
9
  z-index: 1500;
9
10
  `;
@@ -107,7 +108,7 @@ const StyledContent = styled.div `
107
108
  display: none;
108
109
  }
109
110
  `;
110
- const DropDownMenu = styled(({ className, children, data = [], variant = "outlined", defaultValue, multiselect = false, size = "xs", TooltipContent, renderOption, onChange, onItemSelect, onScroll, loading, arrow, searchable, dropDownProps, buttonProps, }) => {
111
+ const DropDownMenu = styled(({ className, children, data = [], variant = "outlined", defaultValue, multiselect = false, size = "xs", TooltipContent, renderOption, onChange, onItemSelect, onScroll, loading, arrow, searchable, dropDownProps, buttonRender, buttonProps, }) => {
111
112
  var _a, _b, _c;
112
113
  const isObjectArray = (_a = Object.keys((data === null || data === void 0 ? void 0 : data[0]) || {})) === null || _a === void 0 ? void 0 : _a.includes("label");
113
114
  const [isOpen, setIsOpen] = useState(false);
@@ -121,7 +122,7 @@ const DropDownMenu = styled(({ className, children, data = [], variant = "outlin
121
122
  placement: "bottom-start",
122
123
  strategy: "absolute",
123
124
  // Handle collisions with the viewport
124
- middleware: [flip()],
125
+ middleware: [flip(), offset(3)],
125
126
  });
126
127
  const handleAddItem = (item) => {
127
128
  setSelected((prev) => {
@@ -171,9 +172,13 @@ const DropDownMenu = styled(({ className, children, data = [], variant = "outlin
171
172
  }, [isOpen, searchable]);
172
173
  const scrollActive = (((_b = scrollContainerRef === null || scrollContainerRef === void 0 ? void 0 : scrollContainerRef.current) === null || _b === void 0 ? void 0 : _b.scrollHeight) || 0) >
173
174
  (((_c = scrollContainerRef === null || scrollContainerRef === void 0 ? void 0 : scrollContainerRef.current) === null || _c === void 0 ? void 0 : _c.clientHeight) || 0);
174
- return (_jsxs("div", { className: className + " mfDropDownMenu", children: [_jsx(Button, Object.assign({ ref: (ref) => {
175
+ return (_jsxs("div", { className: className + " mfDropDownMenu", children: [buttonRender ? (buttonRender({
176
+ onClick: () => setIsOpen(!isOpen),
177
+ buttonRef: refs.setReference,
178
+ isOpen,
179
+ })) : (_jsx(Button, Object.assign({ ref: (ref) => {
175
180
  refs.setReference(ref);
176
- }, onMouseDown: () => setIsOpen(!isOpen), rightSection: arrow ? _jsx("span", { children: "\u25BC" }) : null, size: size }, buttonProps, { children: children })), isOpen && (_jsx(FloatingPortal, { preserveTabOrder: true, children: _jsx(FloatingFocusManager, { context: context, modal: false, children: _jsx(StyledFloatContainer, { ref: refs.setFloating, style: floatingStyles, className: "mfFloating", children: _jsx(StyledContent, Object.assign({ className: "mfFloatingContent", style: { width: 150, maxWidth: 400 }, variant: variant }, dropDownProps, { children: _jsxs(StyledInnerItemContainer, { ref: scrollContainerRef, "data-scroll-active": scrollActive, onScroll: onScroll, children: [loading && _jsx("div", { children: "Loading..." }), searchable && (_jsx(SearchInput, { ref: searchInputRef, variant: "outlined", placeholder: "Search", onChange: handleSearch })), !loading &&
181
+ }, onClick: () => setIsOpen(!isOpen), rightSection: arrow ? _jsx(ChevronDownIcon, { size: 12 }) : null, size: size, variant: variant, selected: isOpen }, buttonProps, { children: children }))), isOpen && (_jsx(FloatingPortal, { preserveTabOrder: true, children: _jsx(FloatingFocusManager, { context: context, modal: false, children: _jsx(StyledFloatContainer, { ref: refs.setFloating, style: floatingStyles, className: "mfFloating", children: _jsx(StyledContent, Object.assign({ className: "mfFloatingContent", style: { width: 150, maxWidth: 400 } }, dropDownProps, { 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 &&
177
182
  data
178
183
  .filter((item) => {
179
184
  var _a, _b, _c;
@@ -191,6 +196,7 @@ const DropDownMenu = styled(({ className, children, data = [], variant = "outlin
191
196
  ? (s === null || s === void 0 ? void 0 : s.value) === (item === null || item === void 0 ? void 0 : item.value)
192
197
  : s === item));
193
198
  return (_jsx(Tooltip, { content: TooltipContent ? (_jsx(TooltipContent, { data: item.data })) : null, side: "left", children: _jsxs(StyledItem, { className: "mfFloatingItem", onClick: (e) => {
199
+ var _a;
194
200
  e.preventDefault();
195
201
  e.stopPropagation();
196
202
  if (multiselect) {
@@ -202,7 +208,8 @@ const DropDownMenu = styled(({ className, children, data = [], variant = "outlin
202
208
  setIsOpen(false);
203
209
  }
204
210
  onItemSelect === null || onItemSelect === void 0 ? void 0 : onItemSelect(item);
205
- }, "data-selected": isSelected, size: size, children: [multiselect && _jsx(CheckBox, { value: isSelected }), _jsx(_Fragment, { children: (renderOption === null || renderOption === void 0 ? void 0 : renderOption(item)) || (item === null || item === void 0 ? void 0 : item.label) || item })] }) }, index));
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));
206
213
  })] }) })) }) }) }))] }));
207
214
  }) ``;
208
215
  export default DropDownMenu;
@@ -1 +1,2 @@
1
1
  export { default } from "./DropDownMenu";
2
+ export type { DropDownItem } from "./types";
@@ -0,0 +1,9 @@
1
+ export type DropDownItem = {
2
+ toLowerCase?: () => string;
3
+ label: string;
4
+ value: string;
5
+ onClick?: (args: any) => void;
6
+ data?: any;
7
+ leftSection?: React.ReactNode;
8
+ rightSection?: React.ReactNode;
9
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -47,5 +47,23 @@ const GlobalStyle = createGlobalStyle `
47
47
  text-decoration: none;
48
48
  color: unset;
49
49
  }
50
+
51
+ ::-webkit-scrollbar {
52
+ width: 6px;
53
+ height: 5px;
54
+ }
55
+
56
+ ::-webkit-scrollbar-track {
57
+ background: ${(props) => props.theme.scrollbar.track};
58
+ }
59
+
60
+ ::-webkit-scrollbar-thumb {
61
+
62
+ background: ${(props) => props.theme.scrollbar.thumb}
63
+ }
64
+
65
+ ::-webkit-scrollbar-thumb:hover {
66
+ background: ${(props) => props.theme.scrollbar.thumbHover};
67
+ }
50
68
  `;
51
69
  export default GlobalStyle;
@@ -11,7 +11,7 @@ export interface MonolithUIContextType {
11
11
  }
12
12
  export declare const MonolithUIContext: React.Context<MonolithUIContextType | undefined>;
13
13
  interface MonolithUIProviderProps {
14
- children: React.ReactNode | React.ReactNode[];
14
+ children?: React.ReactNode | React.ReactNode[];
15
15
  theme?: DefaultTheme;
16
16
  defaultColorScheme?: ColorScheme;
17
17
  colorScheme?: ColorScheme;
@@ -0,0 +1,34 @@
1
+ import Extensions from "../Enums/Extensions";
2
+ import { DropDownItem } from "../../DropDownMenu";
3
+ import { ReactElement } from "react";
4
+ import { ButtonProps } from "../../Button";
5
+ import { Editor } from "@tiptap/react";
6
+ import { DropDownMenuProps } from "../../DropDownMenu/DropDownMenu";
7
+ export interface BubbleMenuProps {
8
+ className?: string;
9
+ editor: Editor;
10
+ rect: DOMRect;
11
+ open: boolean;
12
+ onOpen?: (element: HTMLElement) => void;
13
+ customMenuItems?: BubbleItem[];
14
+ }
15
+ interface BubbleMenuDropDownItem extends DropDownItem {
16
+ data?: {
17
+ command?: (editor: Editor, selectedText: string) => void;
18
+ };
19
+ }
20
+ export type BubbleItem = {
21
+ name: Extensions | string;
22
+ icon?: React.FC<any>;
23
+ type?: "button" | "menu";
24
+ label?: string | Element;
25
+ items?: BubbleMenuDropDownItem[];
26
+ arrow?: boolean;
27
+ isActive?: (editor: Editor) => boolean;
28
+ buttonRender?: (props: any) => ReactElement;
29
+ buttonProps?: ButtonProps;
30
+ dropDownProps?: DropDownMenuProps;
31
+ onClick?: (editor: Editor) => void;
32
+ };
33
+ declare const BubbleMenu: React.FC<BubbleMenuProps>;
34
+ export default BubbleMenu;
@@ -0,0 +1,276 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import styled from "styled-components";
3
+ import Extensions from "../Enums/Extensions";
4
+ import { BoldIcon, ItalicIcon, UnderlineIcon, CaseSensitiveIcon, ListIcon, ListOrderedIcon, StrikethroughIcon, Heading1Icon, Heading2Icon, Heading3Icon, Heading4Icon, RemoveFormattingIcon, } from "lucide-react";
5
+ import DropDownMenu from "../../DropDownMenu";
6
+ import { FloatingPortal, useFloating } from "@floating-ui/react";
7
+ import { useEffect, useRef } from "react";
8
+ import Button from "../../Button";
9
+ const getMenuItems = (editor, customMenuItems) => {
10
+ var _a, _b, _c, _d, _e, _f, _g;
11
+ const node = (_c = (_b = (_a = editor === null || editor === void 0 ? void 0 : editor.state) === null || _a === void 0 ? void 0 : _a.selection) === null || _b === void 0 ? void 0 : _b.$from) === null || _c === void 0 ? void 0 : _c.parent;
12
+ const pos = (_e = (_d = editor === null || editor === void 0 ? void 0 : editor.state) === null || _d === void 0 ? void 0 : _d.selection) === null || _e === void 0 ? void 0 : _e.$from;
13
+ let withinUnorderedList = false;
14
+ let withinOrderedList = false;
15
+ // Traverse the node ancestors
16
+ pos.path.forEach((node) => {
17
+ var _a, _b;
18
+ if (((_a = node === null || node === void 0 ? void 0 : node.type) === null || _a === void 0 ? void 0 : _a.name) === "bulletList") {
19
+ withinUnorderedList = true;
20
+ }
21
+ else if (((_b = node === null || node === void 0 ? void 0 : node.type) === null || _b === void 0 ? void 0 : _b.name) === "orderedList") {
22
+ withinOrderedList = true;
23
+ }
24
+ });
25
+ const attrs = node === null || node === void 0 ? void 0 : node.attrs;
26
+ let nodeTypeLabel = "Select Type";
27
+ let nodeTypeIcon = null;
28
+ if (withinOrderedList) {
29
+ nodeTypeLabel = "Ordered List";
30
+ nodeTypeIcon = _jsx(ListOrderedIcon, { size: 16 });
31
+ }
32
+ else if (withinUnorderedList) {
33
+ nodeTypeLabel = "Bullet List";
34
+ nodeTypeIcon = _jsx(ListIcon, { size: 16 });
35
+ }
36
+ else if (((_f = node === null || node === void 0 ? void 0 : node.type) === null || _f === void 0 ? void 0 : _f.name) === "paragraph") {
37
+ nodeTypeLabel = "Text";
38
+ nodeTypeIcon = _jsx(CaseSensitiveIcon, { size: 16 });
39
+ }
40
+ else if (((_g = node === null || node === void 0 ? void 0 : node.type) === null || _g === void 0 ? void 0 : _g.name) === "heading") {
41
+ const level = attrs === null || attrs === void 0 ? void 0 : attrs.level;
42
+ nodeTypeLabel = `Heading ${level}`;
43
+ nodeTypeIcon =
44
+ level === 1 ? (_jsx(Heading1Icon, { size: 16 })) : level === 2 ? (_jsx(Heading2Icon, { size: 16 })) : level === 3 ? (_jsx(Heading3Icon, { size: 16 })) : (_jsx(Heading4Icon, { size: 16 }));
45
+ }
46
+ return [
47
+ ...customMenuItems,
48
+ {
49
+ name: "node_type",
50
+ label: nodeTypeLabel,
51
+ type: "menu",
52
+ arrow: true,
53
+ buttonProps: {
54
+ leftSection: nodeTypeIcon,
55
+ style: { fontSize: 11, padding: "4px" },
56
+ },
57
+ items: [
58
+ {
59
+ label: "Text",
60
+ value: "text",
61
+ leftSection: _jsx(CaseSensitiveIcon, { size: 16 }),
62
+ data: {
63
+ command: (editor) => {
64
+ // remove ordered list
65
+ editor
66
+ .chain()
67
+ .focus()
68
+ .liftListItem("listItem")
69
+ .setParagraph()
70
+ .run();
71
+ },
72
+ },
73
+ },
74
+ {
75
+ label: "Heading 1",
76
+ value: "heading_1",
77
+ leftSection: _jsx(Heading1Icon, { size: 16 }),
78
+ data: {
79
+ command: (editor) => {
80
+ editor.chain().focus().setHeading({ level: 1 }).run();
81
+ },
82
+ },
83
+ },
84
+ {
85
+ label: "Heading 2",
86
+ value: "heading_2",
87
+ leftSection: _jsx(Heading2Icon, { size: 16 }),
88
+ data: {
89
+ command: (editor) => {
90
+ editor.chain().focus().setHeading({ level: 2 }).run();
91
+ },
92
+ },
93
+ },
94
+ {
95
+ label: "Heading 3",
96
+ value: "heading_3",
97
+ leftSection: _jsx(Heading3Icon, { size: 16 }),
98
+ data: {
99
+ command: (editor) => {
100
+ editor.chain().focus().setHeading({ level: 3 }).run();
101
+ },
102
+ },
103
+ },
104
+ {
105
+ label: "Heading 4",
106
+ value: "heading_4",
107
+ leftSection: _jsx(Heading4Icon, { size: 16 }),
108
+ data: {
109
+ command: (editor) => {
110
+ editor.chain().focus().setHeading({ level: 4 }).run();
111
+ },
112
+ },
113
+ },
114
+ {
115
+ label: "Bullet List",
116
+ value: "bullet_list",
117
+ leftSection: _jsx(ListIcon, { size: 16 }),
118
+ data: {
119
+ command: (editor) => {
120
+ editor.chain().focus().toggleBulletList().run();
121
+ },
122
+ },
123
+ },
124
+ {
125
+ label: "Ordered List",
126
+ value: "ordered_list",
127
+ leftSection: _jsx(ListOrderedIcon, { size: 16 }),
128
+ data: {
129
+ command: (editor) => {
130
+ editor.chain().focus().toggleOrderedList().run();
131
+ },
132
+ },
133
+ },
134
+ ],
135
+ },
136
+ {
137
+ name: Extensions.Bold,
138
+ icon: BoldIcon,
139
+ type: "button",
140
+ isActive: (editor) => editor.isActive("bold"),
141
+ onClick: (editor) => {
142
+ editor.chain().focus().toggleBold().run();
143
+ },
144
+ },
145
+ {
146
+ name: Extensions.Italic,
147
+ icon: ItalicIcon,
148
+ type: "button",
149
+ isActive: (editor) => editor.isActive("italic"),
150
+ onClick: (editor) => {
151
+ editor.chain().focus().toggleItalic().run();
152
+ },
153
+ },
154
+ {
155
+ name: Extensions.Underline,
156
+ icon: UnderlineIcon,
157
+ type: "button",
158
+ isActive: (editor) => editor.isActive("underline"),
159
+ onClick: (editor) => {
160
+ editor.chain().focus().toggleUnderline().run();
161
+ },
162
+ },
163
+ {
164
+ name: Extensions.Strike,
165
+ icon: StrikethroughIcon,
166
+ type: "button",
167
+ isActive: (editor) => editor.isActive("strike"),
168
+ onClick: (editor) => {
169
+ editor.chain().focus().toggleStrike().run();
170
+ },
171
+ },
172
+ {
173
+ name: Extensions.ClearFormatting,
174
+ icon: RemoveFormattingIcon,
175
+ type: "button",
176
+ onClick: (editor) => {
177
+ editor.chain().focus().setParagraph().run();
178
+ editor.chain().focus().unsetAllMarks().run();
179
+ },
180
+ },
181
+ ];
182
+ };
183
+ const BubbleMenuContent = styled.div `
184
+ position: fixed;
185
+ display: flex;
186
+ justify-content: space-between;
187
+ align-items: center;
188
+ padding: 2px;
189
+ gap: 2px;
190
+
191
+ color: ${({ theme }) => theme.palette.text.primary};
192
+ background-color: ${({ theme }) => theme.palette.input.background};
193
+
194
+ border-radius: 5px;
195
+ border: 1px solid ${(props) => props.theme.palette.divider};
196
+
197
+ font-size: 0.8rem;
198
+
199
+ min-height: 30px;
200
+
201
+ opacity: 0;
202
+ transform: scale(0.25); /* Start at half size */
203
+ animation: fadeInEffect 90ms forwards;
204
+
205
+ /* Animation to handle the fade in */
206
+ @keyframes fadeInEffect {
207
+ 0% {
208
+ opacity: 0;
209
+ transform: scale(0.25);
210
+ }
211
+ 100% {
212
+ opacity: 1;
213
+ transform: scale(1);
214
+ }
215
+ }
216
+ `;
217
+ const BubbleItemButton = styled(Button) `
218
+ font-size: 0.5rem;
219
+ font-weight: 500;
220
+ padding: 4px;
221
+ height: auto;
222
+
223
+ &.is-active {
224
+ opacity: 1;
225
+ color: ${({ theme }) => theme.palette.primary.main};
226
+ }
227
+
228
+ &:hover {
229
+ background-color: ${({ theme }) => theme.palette.action.hover};
230
+ }
231
+ `;
232
+ const BubbleMenu = ({ editor, rect, open, onOpen, customMenuItems = [], }) => {
233
+ var _a;
234
+ const menuRef = useRef(null);
235
+ const { refs, elements } = useFloating();
236
+ useEffect(() => {
237
+ if (open && onOpen) {
238
+ onOpen(elements.floating);
239
+ }
240
+ }, [open, onOpen, elements.floating]);
241
+ const elementWidth = ((_a = elements.floating) === null || _a === void 0 ? void 0 : _a.offsetWidth) || 0;
242
+ const { from, to } = editor.state.selection;
243
+ const selectedText = editor.state.doc.textBetween(from, to);
244
+ let top = (rect === null || rect === void 0 ? void 0 : rect.top) ? rect.top - 50 : 0;
245
+ if (top < 10) {
246
+ top = 10; // add some padding
247
+ }
248
+ let left = (rect === null || rect === void 0 ? void 0 : rect.left) ? rect.left + rect.width / 2 - elementWidth / 2 : 0;
249
+ if (left < 10) {
250
+ left = 10; // add some padding
251
+ }
252
+ // Check if the menu is overflowing on the right
253
+ const rightOverflow = left + elementWidth - window.innerWidth;
254
+ if (rightOverflow > -10) {
255
+ left -= rightOverflow + 10; // add some padding
256
+ }
257
+ return (_jsx(FloatingPortal, { preserveTabOrder: true, children: open && (_jsx(BubbleMenuContent, { ref: (ref) => {
258
+ refs.setFloating(ref);
259
+ menuRef.current = ref;
260
+ }, style: {
261
+ top,
262
+ left,
263
+ }, children: getMenuItems(editor, customMenuItems).map((item) => {
264
+ var _a;
265
+ if (item.type === "button") {
266
+ const isActive = (_a = item.isActive) === null || _a === void 0 ? void 0 : _a.call(item, editor);
267
+ return (_jsx(BubbleItemButton, { variant: "subtle", onClick: () => { var _a; return (_a = item === null || item === void 0 ? void 0 : item.onClick) === null || _a === void 0 ? void 0 : _a.call(item, editor); }, color: isActive ? "primary" : undefined, selected: isActive, children: item.icon && _jsx(item.icon, { size: 14 }) }, item.name));
268
+ }
269
+ if (item.type === "menu") {
270
+ return (_jsx(DropDownMenu, Object.assign({ data: item.items, size: "xs", arrow: item.arrow, buttonProps: item.buttonProps, variant: "subtle", buttonRender: item.buttonRender, onItemSelect: (item) => { var _a, _b; return (_b = (_a = item === null || item === void 0 ? void 0 : item.data) === null || _a === void 0 ? void 0 : _a.command) === null || _b === void 0 ? void 0 : _b.call(_a, editor, selectedText); } }, item.dropDownProps, { children: item.icon
271
+ ? (_jsx(item.icon, { size: 14 }))
272
+ : (item.label || item.name) }), item.name));
273
+ }
274
+ }) })) }));
275
+ };
276
+ export default BubbleMenu;
@@ -0,0 +1,6 @@
1
+ declare const SavingBadge: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<{
2
+ className?: string;
3
+ }, never>> & string & Omit<({ className }: {
4
+ className?: string;
5
+ }) => import("react/jsx-runtime").JSX.Element, keyof import("react").Component<any, {}, any>>;
6
+ export default SavingBadge;
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import styled from "styled-components";
3
+ const SavingBadge = styled(({ className }) => {
4
+ return (_jsx("div", { className: className, children: _jsx("div", { className: "saving-badge", children: _jsx("span", { children: "Saving..." }) }) }));
5
+ }) `
6
+ position: absolute;
7
+ top: 0px;
8
+ left: 10px;
9
+ display: flex;
10
+ justify-content: center;
11
+ align-items: center;
12
+ font-size: 0.75rem;
13
+ font-weight: 500;
14
+ color: ${({ theme }) => theme.palette.text.secondary};
15
+ `;
16
+ export default SavingBadge;
@@ -0,0 +1,26 @@
1
+ declare enum Extensions {
2
+ ClearFormatting = "clearFormatting",
3
+ HorizontalRule = "horizontalRule",
4
+ Underline = "underline",
5
+ Bold = "bold",
6
+ Italic = "italic",
7
+ Strike = "strike",
8
+ BulletList = "bulletList",
9
+ OrderedList = "orderedList",
10
+ AlignLeft = "alignLeft",
11
+ AlignCenter = "alignCenter",
12
+ AlignRight = "alignRight",
13
+ AlignJustify = "alignJustify",
14
+ TextAlign = "textAlign",
15
+ Table = "table",
16
+ TableCell = "tableCell",
17
+ TableHeader = "tableHeader",
18
+ TableRow = "tableRow",
19
+ Placeholder = "placeholder",
20
+ Focus = "focus",
21
+ Image = "image",
22
+ CustomStorage = "storage",
23
+ SlashCommand = "slashCommand",
24
+ BubbleMenu = "bubbleMenu"
25
+ }
26
+ export default Extensions;
@@ -0,0 +1,27 @@
1
+ var Extensions;
2
+ (function (Extensions) {
3
+ Extensions["ClearFormatting"] = "clearFormatting";
4
+ Extensions["HorizontalRule"] = "horizontalRule";
5
+ Extensions["Underline"] = "underline";
6
+ Extensions["Bold"] = "bold";
7
+ Extensions["Italic"] = "italic";
8
+ Extensions["Strike"] = "strike";
9
+ Extensions["BulletList"] = "bulletList";
10
+ Extensions["OrderedList"] = "orderedList";
11
+ Extensions["AlignLeft"] = "alignLeft";
12
+ Extensions["AlignCenter"] = "alignCenter";
13
+ Extensions["AlignRight"] = "alignRight";
14
+ Extensions["AlignJustify"] = "alignJustify";
15
+ Extensions["TextAlign"] = "textAlign";
16
+ Extensions["Table"] = "table";
17
+ Extensions["TableCell"] = "tableCell";
18
+ Extensions["TableHeader"] = "tableHeader";
19
+ Extensions["TableRow"] = "tableRow";
20
+ Extensions["Placeholder"] = "placeholder";
21
+ Extensions["Focus"] = "focus";
22
+ Extensions["Image"] = "image";
23
+ Extensions["CustomStorage"] = "storage";
24
+ Extensions["SlashCommand"] = "slashCommand";
25
+ Extensions["BubbleMenu"] = "bubbleMenu";
26
+ })(Extensions || (Extensions = {}));
27
+ export default Extensions;
@@ -0,0 +1,13 @@
1
+ declare enum SlashCommands {
2
+ Text = "Text",
3
+ Heading1 = "Heading 1",
4
+ Heading2 = "Heading 2",
5
+ Heading3 = "Heading 3",
6
+ Heading4 = "Heading 4",
7
+ BulletList = "Bullet List",
8
+ NumberedList = "Numbered List",
9
+ CurrentDate = "Current Date",
10
+ CurrentTimestamp = "Current Timestamp",
11
+ Image = "Image"
12
+ }
13
+ export default SlashCommands;
@@ -0,0 +1,14 @@
1
+ var SlashCommands;
2
+ (function (SlashCommands) {
3
+ SlashCommands["Text"] = "Text";
4
+ SlashCommands["Heading1"] = "Heading 1";
5
+ SlashCommands["Heading2"] = "Heading 2";
6
+ SlashCommands["Heading3"] = "Heading 3";
7
+ SlashCommands["Heading4"] = "Heading 4";
8
+ SlashCommands["BulletList"] = "Bullet List";
9
+ SlashCommands["NumberedList"] = "Numbered List";
10
+ SlashCommands["CurrentDate"] = "Current Date";
11
+ SlashCommands["CurrentTimestamp"] = "Current Timestamp";
12
+ SlashCommands["Image"] = "Image";
13
+ })(SlashCommands || (SlashCommands = {}));
14
+ export default SlashCommands;
@@ -0,0 +1,7 @@
1
+ import { Extension } from "@tiptap/core";
2
+ import { BubbleItem } from "../Components/BubbleMenu";
3
+ export type BubbleMenuOptions = {
4
+ customMenuItems?: BubbleItem[];
5
+ };
6
+ declare const BubbleMenu: Extension<any, any>;
7
+ export default BubbleMenu;