@monolith-forensics/monolith-ui 1.1.84 → 1.1.85

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.
@@ -1,11 +1,13 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import styled from "styled-components";
3
3
  import Extensions from "../Enums/Extensions";
4
- import { BoldIcon, ItalicIcon, UnderlineIcon, CaseSensitiveIcon, ListIcon, ListOrderedIcon, StrikethroughIcon, Heading1Icon, Heading2Icon, Heading3Icon, Heading4Icon, RemoveFormattingIcon, } from "lucide-react";
4
+ import { BoldIcon, ItalicIcon, UnderlineIcon, CaseSensitiveIcon, ListIcon, ListOrderedIcon, StrikethroughIcon, Heading1Icon, Heading2Icon, Heading3Icon, Heading4Icon, RemoveFormattingIcon, SquircleIcon, } from "lucide-react";
5
5
  import DropDownMenu from "../../DropDownMenu";
6
6
  import { FloatingPortal, useFloating } from "@floating-ui/react";
7
7
  import { useEffect, useRef } from "react";
8
8
  import Button from "../../Button";
9
+ import TextColors from "../Enums/TextColors";
10
+ import DefaultColorIcon from "./DefaultColorIcon";
9
11
  const getMenuItems = (editor, customMenuItems) => {
10
12
  var _a, _b, _c, _d, _e, _f, _g;
11
13
  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;
@@ -133,6 +135,45 @@ const getMenuItems = (editor, customMenuItems) => {
133
135
  },
134
136
  ],
135
137
  },
138
+ {
139
+ name: "color",
140
+ label: "Color",
141
+ type: "menu",
142
+ arrow: true,
143
+ buttonProps: {
144
+ // leftSection: nodeTypeIcon,
145
+ style: { fontSize: 11, padding: "4px" },
146
+ },
147
+ items: [
148
+ // remove Color Style
149
+ {
150
+ label: "Default",
151
+ value: "default",
152
+ leftSection: _jsx(DefaultColorIcon, { size: 12 }),
153
+ data: {
154
+ command: (editor) => {
155
+ editor.chain().focus().unsetColor().run();
156
+ },
157
+ },
158
+ },
159
+ ...Object.keys(TextColors).map((color) => {
160
+ const colorKey = color;
161
+ return {
162
+ label: color,
163
+ value: TextColors[colorKey],
164
+ leftSection: (_jsx(SquircleIcon, { size: 12, color: TextColors[colorKey], style: {
165
+ backgroundColor: TextColors[colorKey],
166
+ borderRadius: "3px",
167
+ } })),
168
+ data: {
169
+ command: (editor) => {
170
+ editor.chain().focus().setColor(TextColors[colorKey]).run();
171
+ },
172
+ },
173
+ };
174
+ }),
175
+ ],
176
+ },
136
177
  {
137
178
  name: Extensions.Bold,
138
179
  icon: BoldIcon,
@@ -0,0 +1,4 @@
1
+ declare const DefaultColorIcon: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>, "ref"> & {
2
+ ref?: ((instance: SVGSVGElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<SVGSVGElement> | null | undefined;
3
+ }, never>> & string & Omit<import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>, keyof import("react").Component<any, {}, any>>;
4
+ export default DefaultColorIcon;
@@ -0,0 +1,7 @@
1
+ import { SquircleIcon } from "lucide-react";
2
+ import styled from "styled-components";
3
+ const DefaultColorIcon = styled(SquircleIcon) `
4
+ background-color: ${({ theme }) => theme.palette.text.primary};
5
+ border-radius: 3px;
6
+ `;
7
+ export default DefaultColorIcon;
@@ -15,6 +15,7 @@ declare enum Controls {
15
15
  TEXT_ALIGN_CENTER = "textAlignCenter",
16
16
  TEXT_ALIGN_RIGHT = "textAlignRight",
17
17
  TEXT_ALIGN_JUSTIFIED = "textAlignJustified",
18
- FONT = "font"
18
+ FONT = "font",
19
+ COLOR = "color"
19
20
  }
20
21
  export default Controls;
@@ -17,5 +17,6 @@ var Controls;
17
17
  Controls["TEXT_ALIGN_RIGHT"] = "textAlignRight";
18
18
  Controls["TEXT_ALIGN_JUSTIFIED"] = "textAlignJustified";
19
19
  Controls["FONT"] = "font";
20
+ Controls["COLOR"] = "color";
20
21
  })(Controls || (Controls = {}));
21
22
  export default Controls;
@@ -4,6 +4,8 @@ declare enum Extensions {
4
4
  Underline = "underline",
5
5
  Bold = "bold",
6
6
  Italic = "italic",
7
+ Color = "color",
8
+ TextStyle = "textStyle",
7
9
  Strike = "strike",
8
10
  BulletList = "bulletList",
9
11
  OrderedList = "orderedList",
@@ -5,6 +5,8 @@ var Extensions;
5
5
  Extensions["Underline"] = "underline";
6
6
  Extensions["Bold"] = "bold";
7
7
  Extensions["Italic"] = "italic";
8
+ Extensions["Color"] = "color";
9
+ Extensions["TextStyle"] = "textStyle";
8
10
  Extensions["Strike"] = "strike";
9
11
  Extensions["BulletList"] = "bulletList";
10
12
  Extensions["OrderedList"] = "orderedList";
@@ -0,0 +1,13 @@
1
+ declare enum TextColors {
2
+ Black = "black",
3
+ Gray = "gray",
4
+ White = "white",
5
+ Red = "red",
6
+ Green = "limegreen",
7
+ Blue = "#4782da",
8
+ Yellow = "yellow",
9
+ Pink = "pink",
10
+ Purple = "purple",
11
+ Orange = "#f59e0b"
12
+ }
13
+ export default TextColors;
@@ -0,0 +1,14 @@
1
+ var TextColors;
2
+ (function (TextColors) {
3
+ TextColors["Black"] = "black";
4
+ TextColors["Gray"] = "gray";
5
+ TextColors["White"] = "white";
6
+ TextColors["Red"] = "red";
7
+ TextColors["Green"] = "limegreen";
8
+ TextColors["Blue"] = "#4782da";
9
+ TextColors["Yellow"] = "yellow";
10
+ TextColors["Pink"] = "pink";
11
+ TextColors["Purple"] = "purple";
12
+ TextColors["Orange"] = "#f59e0b";
13
+ })(TextColors || (TextColors = {}));
14
+ export default TextColors;
@@ -8,6 +8,8 @@ import TableCell from "@tiptap/extension-table-cell";
8
8
  import TableHeader from "@tiptap/extension-table-header";
9
9
  import TableRow from "@tiptap/extension-table-row";
10
10
  import Placeholder from "@tiptap/extension-placeholder";
11
+ import { Color } from "@tiptap/extension-color";
12
+ import TextStyle from "@tiptap/extension-text-style";
11
13
  import { InputRule, Extension } from "@tiptap/core";
12
14
  import Focus from "@tiptap/extension-focus";
13
15
  import UploadImagesPlugin from "../Plugins/UploadImagesPlugin";
@@ -72,6 +74,16 @@ const getTipTapExtensions = ({ extensions = [], slashCommands = [], bubbleMenuOp
72
74
  gapcursor: false,
73
75
  }),
74
76
  },
77
+ {
78
+ name: Extensions.TextStyle,
79
+ category: "default",
80
+ extension: TextStyle,
81
+ },
82
+ {
83
+ name: Extensions.Color,
84
+ category: "default",
85
+ extension: Color,
86
+ },
75
87
  {
76
88
  name: Extensions.Underline,
77
89
  category: "default",
@@ -8,10 +8,14 @@ import Fonts from "../Enums/Fonts";
8
8
  import { useContext } from "react";
9
9
  import RichTextEditorContext from "../Contexts/RichTextEditorContext";
10
10
  import Button from "../../Button";
11
+ import TextColors from "../Enums/TextColors";
12
+ import DefaultColorIcon from "../Components/DefaultColorIcon";
13
+ import { SquircleIcon } from "lucide-react";
11
14
  const Toolbar = styled(({ className, editor, toolbarOptions }) => {
12
15
  var _a;
13
16
  const { controls } = toolbarOptions || {};
14
- const customItems = controls === null || controls === void 0 ? void 0 : controls.filter((control) => typeof control !== "string" && control.type === ("menu" || "button"));
17
+ const customItems = controls === null || controls === void 0 ? void 0 : controls.filter((control) => typeof control !== "string" &&
18
+ (control.type === "menu" || control.type === "button"));
15
19
  const { font, setFont } = useContext(RichTextEditorContext);
16
20
  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
21
  var _a, _b;
@@ -32,7 +36,35 @@ const Toolbar = styled(({ className, editor, toolbarOptions }) => {
32
36
  fontWeight: "normal",
33
37
  },
34
38
  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 }))] })] }));
39
+ }, 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 })] }), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.COLOR)) && (_jsx(DropDownMenu, { data: [
40
+ {
41
+ label: "Default",
42
+ value: "default",
43
+ leftSection: _jsx(DefaultColorIcon, { size: 12 }),
44
+ onClick: () => {
45
+ editor === null || editor === void 0 ? void 0 : editor.chain().focus().unsetColor().run();
46
+ },
47
+ },
48
+ ...Object.keys(TextColors).map((color) => {
49
+ const colorKey = color;
50
+ return {
51
+ label: color,
52
+ value: TextColors[colorKey],
53
+ leftSection: (_jsx(SquircleIcon, { size: 12, color: TextColors[colorKey], style: {
54
+ backgroundColor: TextColors[colorKey],
55
+ borderRadius: "3px",
56
+ } })),
57
+ onClick: () => {
58
+ editor === null || editor === void 0 ? void 0 : editor.chain().focus().setColor(TextColors[colorKey]).run();
59
+ },
60
+ };
61
+ }),
62
+ ], size: "xxs", variant: "outlined", arrow: true, buttonProps: {
63
+ style: {
64
+ fontWeight: "normal",
65
+ },
66
+ title: "Select Color",
67
+ }, children: "Color" })), _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 }))] })] }));
36
68
  }) `
37
69
  display: flex;
38
70
  flex-direction: row;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monolith-forensics/monolith-ui",
3
- "version": "1.1.84",
3
+ "version": "1.1.85",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "author": "Matt Danner (Monolith Forensics LLC)",
@@ -28,6 +28,7 @@
28
28
  "@radix-ui/react-switch": "^1.0.7",
29
29
  "@radix-ui/react-tooltip": "^1.0.7",
30
30
  "@tabler/icons-react": "^3.11.0",
31
+ "@tiptap/extension-color": "^2.9.1",
31
32
  "@tiptap/extension-focus": "^2.5.9",
32
33
  "@tiptap/extension-horizontal-rule": "^2.5.9",
33
34
  "@tiptap/extension-image": "^2.5.9",
@@ -37,6 +38,7 @@
37
38
  "@tiptap/extension-table-header": "^2.5.8",
38
39
  "@tiptap/extension-table-row": "^2.5.8",
39
40
  "@tiptap/extension-text-align": "^2.5.8",
41
+ "@tiptap/extension-text-style": "^2.9.1",
40
42
  "@tiptap/extension-underline": "^2.5.8",
41
43
  "@tiptap/pm": "^2.5.8",
42
44
  "@tiptap/react": "^2.5.8",