@monolith-forensics/monolith-ui 1.9.1-dev.8 → 1.9.3-dev.0

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 (93) hide show
  1. package/dist/DropDownMenu/components/MenuItemList.js +32 -12
  2. package/dist/DropDownMenu/components/StyledContent.js +1 -1
  3. package/dist/DropDownMenu/components/StyledInnerItemContainer.js +1 -0
  4. package/dist/FileViewer/FileViewer.js +32 -8
  5. package/dist/FileViewer/viewers/ImageViewer.d.ts +1 -0
  6. package/dist/FileViewer/viewers/ImageViewer.js +36 -15
  7. package/dist/MonolithUIProvider/MonolithUIProvider.d.ts +23 -0
  8. package/dist/RichTextEditor/Components/BubbleMenu.d.ts +8 -8
  9. package/dist/RichTextEditor/Components/BubbleMenu.js +202 -94
  10. package/dist/RichTextEditor/Components/CodeBlockBaseButton.d.ts +18 -0
  11. package/dist/RichTextEditor/Components/CodeBlockBaseButton.js +6 -0
  12. package/dist/RichTextEditor/Components/CodeBlockCopyButton.d.ts +9 -0
  13. package/dist/RichTextEditor/Components/CodeBlockCopyButton.js +42 -0
  14. package/dist/RichTextEditor/Components/CodeBlockFormatButton.d.ts +10 -0
  15. package/dist/RichTextEditor/Components/CodeBlockFormatButton.js +60 -0
  16. package/dist/RichTextEditor/Components/CodeBlockLanguageSelect.d.ts +9 -0
  17. package/dist/RichTextEditor/Components/CodeBlockLanguageSelect.js +30 -0
  18. package/dist/RichTextEditor/Components/CodeBlockNodeView.d.ts +3 -0
  19. package/dist/RichTextEditor/Components/CodeBlockNodeView.js +28 -0
  20. package/dist/RichTextEditor/Components/CodeBlockWrapButton.d.ts +10 -0
  21. package/dist/RichTextEditor/Components/CodeBlockWrapButton.js +17 -0
  22. package/dist/RichTextEditor/Components/LinkEditor.d.ts +8 -0
  23. package/dist/RichTextEditor/Components/LinkEditor.js +94 -0
  24. package/dist/RichTextEditor/Components/TableCornerMenu.d.ts +16 -0
  25. package/dist/RichTextEditor/Components/TableCornerMenu.js +202 -0
  26. package/dist/RichTextEditor/Components/TableTools/TableCornerMenu.d.ts +2 -0
  27. package/dist/RichTextEditor/Components/TableTools/TableCornerMenu.js +19 -0
  28. package/dist/RichTextEditor/Components/TableTools/TableInsertControls.d.ts +2 -0
  29. package/dist/RichTextEditor/Components/TableTools/TableInsertControls.js +24 -0
  30. package/dist/RichTextEditor/Components/TableTools/TableRails.d.ts +2 -0
  31. package/dist/RichTextEditor/Components/TableTools/TableRails.js +180 -0
  32. package/dist/RichTextEditor/Components/TableTools/TableToolMenu.d.ts +5 -0
  33. package/dist/RichTextEditor/Components/TableTools/TableToolMenu.js +6 -0
  34. package/dist/RichTextEditor/Components/TableTools/TableTools.actions.d.ts +5 -0
  35. package/dist/RichTextEditor/Components/TableTools/TableTools.actions.js +183 -0
  36. package/dist/RichTextEditor/Components/TableTools/TableTools.commands.d.ts +16 -0
  37. package/dist/RichTextEditor/Components/TableTools/TableTools.commands.js +217 -0
  38. package/dist/RichTextEditor/Components/TableTools/TableTools.constants.d.ts +8 -0
  39. package/dist/RichTextEditor/Components/TableTools/TableTools.constants.js +11 -0
  40. package/dist/RichTextEditor/Components/TableTools/TableTools.d.ts +3 -0
  41. package/dist/RichTextEditor/Components/TableTools/TableTools.geometry.d.ts +23 -0
  42. package/dist/RichTextEditor/Components/TableTools/TableTools.geometry.js +75 -0
  43. package/dist/RichTextEditor/Components/TableTools/TableTools.js +3 -0
  44. package/dist/RichTextEditor/Components/TableTools/TableTools.selectors.d.ts +16 -0
  45. package/dist/RichTextEditor/Components/TableTools/TableTools.selectors.js +53 -0
  46. package/dist/RichTextEditor/Components/TableTools/TableTools.styled.d.ts +40 -0
  47. package/dist/RichTextEditor/Components/TableTools/TableTools.styled.js +167 -0
  48. package/dist/RichTextEditor/Components/TableTools/TableTools.types.d.ts +76 -0
  49. package/dist/RichTextEditor/Components/TableTools/TableTools.types.js +1 -0
  50. package/dist/RichTextEditor/Components/TableTools/TableTools.utils.d.ts +4 -0
  51. package/dist/RichTextEditor/Components/TableTools/TableTools.utils.js +4 -0
  52. package/dist/RichTextEditor/Components/TableTools/TableToolsPopover.d.ts +2 -0
  53. package/dist/RichTextEditor/Components/TableTools/TableToolsPopover.js +12 -0
  54. package/dist/RichTextEditor/Components/TableTools/index.d.ts +3 -0
  55. package/dist/RichTextEditor/Components/TableTools/index.js +2 -0
  56. package/dist/RichTextEditor/Components/TableTools.d.ts +44 -0
  57. package/dist/RichTextEditor/Components/TableTools.js +790 -0
  58. package/dist/RichTextEditor/Enums/Controls.d.ts +7 -1
  59. package/dist/RichTextEditor/Enums/Controls.js +6 -0
  60. package/dist/RichTextEditor/Enums/Extensions.d.ts +4 -0
  61. package/dist/RichTextEditor/Enums/Extensions.js +4 -0
  62. package/dist/RichTextEditor/Enums/HighlightColors.d.ts +9 -0
  63. package/dist/RichTextEditor/Enums/HighlightColors.js +10 -0
  64. package/dist/RichTextEditor/Enums/SlashCommands.d.ts +4 -1
  65. package/dist/RichTextEditor/Enums/SlashCommands.js +3 -0
  66. package/dist/RichTextEditor/Extensions/SlashCommandList.js +0 -1
  67. package/dist/RichTextEditor/Extensions/getSlashCommand.js +39 -1
  68. package/dist/RichTextEditor/Extensions/getTiptapExtensions.d.ts +10 -2
  69. package/dist/RichTextEditor/Extensions/getTiptapExtensions.js +157 -30
  70. package/dist/RichTextEditor/Plugins/ImageActionsPlugin.js +4 -7
  71. package/dist/RichTextEditor/RichTextEditor.d.ts +4 -2
  72. package/dist/RichTextEditor/RichTextEditor.js +395 -15
  73. package/dist/RichTextEditor/Toolbar/Control.d.ts +6 -2
  74. package/dist/RichTextEditor/Toolbar/Control.js +13 -6
  75. package/dist/RichTextEditor/Toolbar/Controls.d.ts +6 -0
  76. package/dist/RichTextEditor/Toolbar/Controls.js +118 -1
  77. package/dist/RichTextEditor/Toolbar/ControlsGroup.js +17 -6
  78. package/dist/RichTextEditor/Toolbar/Labels.d.ts +1 -0
  79. package/dist/RichTextEditor/Toolbar/Labels.js +1 -0
  80. package/dist/RichTextEditor/Toolbar/Toolbar.d.ts +1 -2
  81. package/dist/RichTextEditor/Toolbar/Toolbar.js +32 -67
  82. package/dist/RichTextEditor/Utils/codeBlockUtils.d.ts +20 -0
  83. package/dist/RichTextEditor/Utils/codeBlockUtils.js +137 -0
  84. package/dist/RichTextEditor/Utils/codeUtils.d.ts +3 -0
  85. package/dist/RichTextEditor/Utils/codeUtils.js +12 -0
  86. package/dist/RichTextEditor/Utils/linkUtils.d.ts +19 -0
  87. package/dist/RichTextEditor/Utils/linkUtils.js +57 -0
  88. package/dist/RichTextEditor/Utils/tableUtils.d.ts +1 -0
  89. package/dist/RichTextEditor/Utils/tableUtils.js +1 -0
  90. package/dist/theme/variants.js +46 -0
  91. package/package.json +8 -1
  92. package/dist/RichTextEditor/Extensions/BubbleMenuExtension.d.ts +0 -7
  93. package/dist/RichTextEditor/Extensions/BubbleMenuExtension.js +0 -157
@@ -1,6 +1,17 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { IconBold, IconItalic, IconUnderline, IconStrikethrough, IconH1, IconH2, IconH3, IconH4, IconList, IconListNumbers, IconAlignLeft, IconAlignRight, IconAlignCenter, IconAlignJustified, IconCornerUpLeft, IconCornerUpRight, } from "@tabler/icons-react";
3
+ import { CodeIcon, HighlighterIcon, PaletteIcon, RemoveFormattingIcon, SquircleIcon, TypeIcon, } from "lucide-react";
4
+ import { SquareCodeIcon } from "lucide-react";
3
5
  import { Control } from "./Control";
6
+ import { hasInlineCode, toggleInlineCode } from "../Utils/codeUtils";
7
+ import { hasSyntaxHighlightedCodeBlock, toggleCodeBlock, } from "../Utils/codeBlockUtils";
8
+ import { useContext } from "react";
9
+ import { useTheme } from "styled-components";
10
+ import { DropDownMenu } from "../../DropDownMenu";
11
+ import RichTextEditorContext from "../Contexts/RichTextEditorContext";
12
+ import Fonts from "../Enums/Fonts";
13
+ import TextColors from "../Enums/TextColors";
14
+ import HighlightColors from "../Enums/HighlightColors";
4
15
  export const UndoControl = ({ editor }) => {
5
16
  return (_jsx(Control, { editor: editor, label: "undoControlLabel", operation: {
6
17
  name: "undo",
@@ -11,6 +22,102 @@ export const RedoControl = ({ editor }) => {
11
22
  name: "redo",
12
23
  }, icon: IconCornerUpRight }));
13
24
  };
25
+ export const FontControl = () => {
26
+ const { font, setFont } = useContext(RichTextEditorContext);
27
+ return (_jsx(DropDownMenu, { data: Object.values(Fonts).map((font) => ({
28
+ label: font,
29
+ value: font,
30
+ onClick: () => {
31
+ setFont(font);
32
+ },
33
+ })), size: "xs", variant: "outlined", dropDownProps: {
34
+ style: {
35
+ width: 135,
36
+ },
37
+ }, buttonProps: {
38
+ title: "Select Font",
39
+ leftSection: _jsx(TypeIcon, { size: 12 }),
40
+ }, children: (font || Fonts.DEFAULT) }));
41
+ };
42
+ export const TextColorControl = ({ editor }) => {
43
+ const theme = useTheme();
44
+ return (_jsx(DropDownMenu, { data: [
45
+ {
46
+ label: "Default",
47
+ value: "default",
48
+ onClick: () => {
49
+ editor === null || editor === void 0 ? void 0 : editor.chain().focus().unsetColor().run();
50
+ },
51
+ },
52
+ ...Object.keys(TextColors).map((color) => {
53
+ const colorKey = color;
54
+ return {
55
+ label: color,
56
+ value: TextColors[colorKey],
57
+ onClick: () => {
58
+ editor === null || editor === void 0 ? void 0 : editor.chain().focus().setColor(TextColors[colorKey]).run();
59
+ },
60
+ };
61
+ }),
62
+ ], renderOption: (item) => (_jsxs("div", { style: { display: "flex", alignItems: "center", gap: 5 }, children: [_jsx(SquircleIcon, { size: 12, color: item.value === "default"
63
+ ? theme.palette.text.primary
64
+ : item.value, style: {
65
+ backgroundColor: item.value === "default"
66
+ ? theme.palette.text.primary
67
+ : item.value,
68
+ borderRadius: "3px",
69
+ } }), item.label] })), size: "xs", variant: "outlined", buttonProps: {
70
+ title: "Select Color",
71
+ style: { padding: "1px 6px" },
72
+ }, dropDownProps: {
73
+ style: {
74
+ width: 120,
75
+ },
76
+ }, children: _jsx(PaletteIcon, { size: 14 }) }));
77
+ };
78
+ export const HighlightControl = ({ editor }) => {
79
+ const theme = useTheme();
80
+ return (_jsx(DropDownMenu, { data: [
81
+ {
82
+ label: "Default",
83
+ value: "default",
84
+ onClick: () => {
85
+ editor === null || editor === void 0 ? void 0 : editor.chain().focus().unsetHighlight().run();
86
+ },
87
+ },
88
+ ...Object.keys(HighlightColors).map((color) => {
89
+ const colorKey = color;
90
+ return {
91
+ label: color,
92
+ value: HighlightColors[colorKey],
93
+ onClick: () => {
94
+ editor === null || editor === void 0 ? void 0 : editor.chain().focus().setHighlight({ color: HighlightColors[colorKey] }).run();
95
+ },
96
+ };
97
+ }),
98
+ ], renderOption: (item) => (_jsxs("div", { style: { display: "flex", alignItems: "center", gap: 5 }, children: [_jsx(SquircleIcon, { size: 12, color: item.value === "default"
99
+ ? theme.palette.text.primary
100
+ : item.value, style: {
101
+ backgroundColor: item.value === "default"
102
+ ? "transparent"
103
+ : item.value,
104
+ borderRadius: "3px",
105
+ } }), item.label] })), size: "xs", variant: "outlined", buttonProps: {
106
+ title: "Select Highlight",
107
+ style: { padding: "1px 6px" },
108
+ }, dropDownProps: {
109
+ style: {
110
+ width: 100,
111
+ height: 210,
112
+ },
113
+ }, children: _jsx(HighlighterIcon, { size: 14 }) }));
114
+ };
115
+ export const ClearFormattingControl = ({ editor }) => {
116
+ return (_jsx(Control, { editor: editor, label: "clearFormattingControlLabel", onClick: (editor) => {
117
+ editor === null || editor === void 0 ? void 0 : editor.chain().focus().setParagraph().run();
118
+ editor === null || editor === void 0 ? void 0 : editor.chain().focus().unsetAllMarks().run();
119
+ }, icon: RemoveFormattingIcon }));
120
+ };
14
121
  export const BoldControl = ({ editor }) => {
15
122
  return (_jsx(Control, { editor: editor, label: "boldControlLabel", isActive: {
16
123
  name: "bold",
@@ -39,6 +146,16 @@ export const StrikeThroughControl = ({ editor }) => {
39
146
  name: "toggleStrike",
40
147
  }, icon: IconStrikethrough }));
41
148
  };
149
+ export const CodeControl = ({ editor }) => {
150
+ return (_jsx(Control, { editor: editor, label: "codeControlLabel", isActive: {
151
+ name: "code",
152
+ }, onClick: toggleInlineCode, disabled: !hasInlineCode(editor), icon: CodeIcon }));
153
+ };
154
+ export const CodeBlockControl = ({ editor }) => {
155
+ return (_jsx(Control, { editor: editor, label: "codeBlockControlLabel", isActive: {
156
+ name: "codeBlock",
157
+ }, onClick: toggleCodeBlock, disabled: !hasSyntaxHighlightedCodeBlock(editor), icon: SquareCodeIcon }));
158
+ };
42
159
  export const Heading1Control = ({ editor }) => {
43
160
  return (_jsx(Control, { editor: editor, label: "h1ControlLabel", isActive: {
44
161
  name: "heading",
@@ -1,29 +1,40 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { forwardRef } from "react";
2
+ import { Children, forwardRef } from "react";
3
3
  import styled from "styled-components";
4
4
  const ControlsGroup = styled(forwardRef(({ className, children }, ref) => {
5
- if (!children) {
5
+ if (Children.toArray(children).length === 0) {
6
6
  return null;
7
7
  }
8
8
  return (_jsx("div", { className: className + " controls-group", ref: ref, children: children }));
9
9
  })) `
10
10
  & {
11
11
  display: flex;
12
+ flex: 0 0 auto;
12
13
  justify-content: flex-start;
13
14
  align-items: center;
14
15
  }
15
- & button {
16
+
17
+ & > button {
16
18
  border-radius: 0;
17
19
  border: 1px solid ${({ theme }) => theme.palette.divider};
18
- border-right: none;
19
20
  }
20
- & button:first-child {
21
+
22
+ & > button:not(:last-of-type) {
23
+ border-right: 1px solid transparent;
24
+ }
25
+
26
+ & > button:first-child {
21
27
  border-radius: 5px 0 0 5px;
22
28
  }
23
- & button:last-child {
29
+
30
+ & > button:last-of-type {
24
31
  border-radius: 0 5px 5px 0;
25
32
  border-right: 1px solid ${({ theme }) => theme.palette.divider};
26
33
  }
34
+
35
+ & > button:active {
36
+ translate: none;
37
+ }
27
38
  `;
28
39
  ControlsGroup.displayName = "ControlsGroup";
29
40
  export default ControlsGroup;
@@ -27,6 +27,7 @@ declare const Labels: {
27
27
  superscriptControlLabel: string;
28
28
  unsetColorControlLabel: string;
29
29
  hrControlLabel: string;
30
+ tableControlLabel: string;
30
31
  linkEditorInputLabel: string;
31
32
  linkEditorInputPlaceholder: string;
32
33
  linkEditorExternalLink: string;
@@ -29,6 +29,7 @@ const Labels = {
29
29
  superscriptControlLabel: "Superscript",
30
30
  unsetColorControlLabel: "Unset color",
31
31
  hrControlLabel: "Horizontal line",
32
+ tableControlLabel: "Table",
32
33
  // Link editor
33
34
  linkEditorInputLabel: "Enter URL",
34
35
  linkEditorInputPlaceholder: "https://example.com/",
@@ -17,8 +17,7 @@ export type ToolbarOptions = {
17
17
  customItems?: CustomItem[];
18
18
  };
19
19
  export type ToolbarProps = {
20
- className?: string;
21
20
  editor: Editor | null;
22
21
  toolbarOptions?: ToolbarOptions;
23
22
  };
24
- export 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>>;
23
+ export declare const Toolbar: ({ editor, toolbarOptions }: ToolbarProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,85 +1,50 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import styled, { useTheme } from "styled-components";
2
+ import styled from "styled-components";
3
3
  import ControlsGroup from "./ControlsGroup";
4
- import { UndoControl, RedoControl, BoldControl, ItalicControl, UnderlineControl, StrikeThroughControl, Heading1Control, Heading2Control, Heading3Control, Heading4Control, BulletListControl, OrderedListControl, AlignLeftControl, AlignCenterControl, AlignRightControl, AlignJustifiedControl, } from "./Controls";
4
+ import { UndoControl, RedoControl, FontControl, TextColorControl, HighlightControl, BoldControl, ItalicControl, UnderlineControl, StrikeThroughControl, ClearFormattingControl, CodeControl, CodeBlockControl, Heading1Control, Heading2Control, Heading3Control, Heading4Control, BulletListControl, OrderedListControl, AlignLeftControl, AlignCenterControl, AlignRightControl, AlignJustifiedControl, } from "./Controls";
5
5
  import { Controls } from "../Enums";
6
6
  import { DropDownMenu } from "../../DropDownMenu";
7
- import Fonts from "../Enums/Fonts";
8
- import { useContext } from "react";
9
- import RichTextEditorContext from "../Contexts/RichTextEditorContext";
7
+ import { useState } from "react";
10
8
  import { Button } from "../../Button";
11
- import TextColors from "../Enums/TextColors";
12
- import { SquircleIcon } from "lucide-react";
13
- export const Toolbar = styled(({ className, editor, toolbarOptions }) => {
9
+ import { Popover } from "../../Popover";
10
+ import LinkEditor from "../Components/LinkEditor";
11
+ import { TableToolsPopover } from "../Components/TableTools";
12
+ import { LinkIcon } from "lucide-react";
13
+ const ToolbarContainer = styled.div `
14
+ display: flex;
15
+ flex-direction: row;
16
+ flex-wrap: wrap;
17
+ justify-content: center;
18
+ align-items: center;
19
+ gap: 5px;
20
+ row-gap: 6px;
21
+ width: 100%;
22
+ margin-bottom: 10px;
23
+ border-radius: 5px 5px 0 0;
24
+ border: 1px solid transparent;
25
+
26
+ > button,
27
+ > .mfui-DropDownMenu {
28
+ flex: 0 0 auto;
29
+ }
30
+ `;
31
+ export const Toolbar = ({ editor, toolbarOptions }) => {
14
32
  var _a;
15
- const theme = useTheme();
16
33
  const { controls } = toolbarOptions || {};
34
+ const [linkPopoverOpen, setLinkPopoverOpen] = useState(false);
17
35
  const customItems = controls === null || controls === void 0 ? void 0 : controls.filter((control) => typeof control !== "string" &&
18
36
  (control.type === "menu" || control.type === "button"));
19
- const { font, setFont } = useContext(RichTextEditorContext);
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) => {
37
+ return (_jsxs(ToolbarContainer, { children: [(_a = customItems === null || customItems === void 0 ? void 0 : customItems.map) === null || _a === void 0 ? void 0 : _a.call(customItems, (item, index) => {
21
38
  var _a, _b;
22
39
  if (item.type === "button") {
23
- 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));
40
+ return (_jsx(Button, Object.assign({ size: "xs" }, item.options, { children: (_a = item === null || item === void 0 ? void 0 : item.options) === null || _a === void 0 ? void 0 : _a.label }), index));
24
41
  }
25
42
  else if (item.type === "menu") {
26
43
  return (_jsx(DropDownMenu, Object.assign({ dropDownProps: {
27
44
  style: {
28
45
  width: 135,
29
46
  },
30
- } }, item.options, { children: (_b = item === null || item === void 0 ? void 0 : item.options) === null || _b === void 0 ? void 0 : _b.label }), index));
47
+ } }, item.options, { size: "xs", children: (_b = item === null || item === void 0 ? void 0 : item.options) === null || _b === void 0 ? void 0 : _b.label }), index));
31
48
  }
32
- }), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.FONT)) && (_jsx(DropDownMenu, { data: Object.values(Fonts).map((font) => ({
33
- label: font,
34
- value: font,
35
- onClick: () => {
36
- setFont(font);
37
- },
38
- })), size: "xxs", variant: "outlined", arrow: true, dropDownProps: {
39
- style: {
40
- width: 135,
41
- },
42
- }, buttonProps: {
43
- title: "Select Font",
44
- }, 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: [
45
- {
46
- label: "Default",
47
- value: "default",
48
- onClick: () => {
49
- editor === null || editor === void 0 ? void 0 : editor.chain().focus().unsetColor().run();
50
- },
51
- },
52
- ...Object.keys(TextColors).map((color) => {
53
- const colorKey = color;
54
- return {
55
- label: color,
56
- value: TextColors[colorKey],
57
- onClick: () => {
58
- editor === null || editor === void 0 ? void 0 : editor.chain().focus().setColor(TextColors[colorKey]).run();
59
- },
60
- };
61
- }),
62
- ], renderOption: (item) => (_jsxs("div", { style: { display: "flex", alignItems: "center", gap: 5 }, children: [_jsx(SquircleIcon, { size: 12, color: item.value === "default"
63
- ? theme.palette.text.primary
64
- : item.value, style: {
65
- backgroundColor: item.value === "default"
66
- ? theme.palette.text.primary
67
- : item.value,
68
- borderRadius: "3px",
69
- } }), item.label] })), size: "xxs", variant: "outlined", arrow: true, buttonProps: {
70
- title: "Select Color",
71
- }, dropDownProps: {
72
- style: {
73
- width: 100,
74
- },
75
- }, 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 }))] })] }));
76
- }) `
77
- display: flex;
78
- flex-direction: row;
79
- justify-content: center;
80
- align-items: center;
81
- gap: 5px;
82
- margin-bottom: 10px;
83
- border-radius: 5px 5px 0 0;
84
- border: 1px solid transparent;
85
- `;
49
+ }), _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.FONT)) && _jsx(FontControl, {}), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.COLOR)) && (_jsx(TextColorControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.HIGHLIGHT)) && (_jsx(HighlightControl, { 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 }))] }), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.LINK)) && (_jsxs(Popover, { opened: linkPopoverOpen, onChange: setLinkPopoverOpen, position: "bottom", width: 330, trapFocus: true, children: [_jsx(Popover.Target, { children: _jsx(Button, { size: "xs", variant: "outlined", title: "Link", "aria-label": "Link", selected: linkPopoverOpen || Boolean(editor === null || editor === void 0 ? void 0 : editor.isActive("link")), disabled: !editor, style: { padding: "1px 6px" }, children: _jsx(LinkIcon, { size: 14 }) }) }), _jsx(Popover.Dropdown, { children: editor && (_jsx(LinkEditor, { editor: editor, autoFocus: linkPopoverOpen, onClose: () => setLinkPopoverOpen(false) })) })] })), _jsxs(ControlsGroup, { children: [(controls === null || controls === void 0 ? void 0 : controls.includes(Controls.CODE)) && _jsx(CodeControl, { editor: editor }), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.CODE_BLOCK)) && (_jsx(CodeBlockControl, { editor: editor }))] }), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.TABLE)) && (_jsx(TableToolsPopover, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.CLEAR_FORMATTING)) && (_jsx(ClearFormattingControl, { editor: editor }))] }));
50
+ };
@@ -0,0 +1,20 @@
1
+ import { Editor } from "@tiptap/react";
2
+ export type CodeBlockLanguage = {
3
+ label: string;
4
+ value: string;
5
+ };
6
+ export declare const DEFAULT_CODE_BLOCK_LANGUAGE = "plaintext";
7
+ export declare const CODE_BLOCK_LANGUAGES: CodeBlockLanguage[];
8
+ export declare const getCodeBlockLanguage: (editor: Editor | null) => string;
9
+ export declare const getCodeBlockLanguageOption: (language?: string) => CodeBlockLanguage;
10
+ export declare const canFormatCodeBlockLanguage: (language?: string) => boolean;
11
+ export declare const formatCodeBlockText: (text: string, language?: string) => Promise<string>;
12
+ export declare const hasSyntaxHighlightedCodeBlock: (editor: Editor | null) => boolean;
13
+ export declare const setCodeBlockLanguage: (editor: Editor | null, language: string) => void;
14
+ export declare const getCodeBlockWrap: (editor: Editor | null) => boolean;
15
+ export declare const toggleCodeBlockWrap: (editor: Editor | null) => void;
16
+ export declare const toggleCodeBlock: (editor: Editor | null) => void;
17
+ export declare const getActiveCodeBlockText: (editor: Editor | null) => string;
18
+ export declare const replaceCodeBlockContent: (editor: Editor, from: number, to: number, text: string) => boolean;
19
+ export declare const formatActiveCodeBlock: (editor: Editor | null) => Promise<void>;
20
+ export declare const copyCodeBlockText: (text: string) => Promise<void>;
@@ -0,0 +1,137 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import prettier from "prettier/standalone";
11
+ import * as prettierBabelPlugin from "prettier/plugins/babel";
12
+ import * as prettierEstreePlugin from "prettier/plugins/estree";
13
+ import * as prettierHtmlPlugin from "prettier/plugins/html";
14
+ import * as prettierMarkdownPlugin from "prettier/plugins/markdown";
15
+ import * as prettierPostcssPlugin from "prettier/plugins/postcss";
16
+ import * as prettierTypescriptPlugin from "prettier/plugins/typescript";
17
+ import * as prettierYamlPlugin from "prettier/plugins/yaml";
18
+ export const DEFAULT_CODE_BLOCK_LANGUAGE = "plaintext";
19
+ export const CODE_BLOCK_LANGUAGES = [
20
+ { label: "Plain Text", value: DEFAULT_CODE_BLOCK_LANGUAGE },
21
+ { label: "JavaScript", value: "javascript" },
22
+ { label: "TypeScript", value: "typescript" },
23
+ { label: "JSX", value: "jsx" },
24
+ { label: "TSX", value: "tsx" },
25
+ { label: "HTML", value: "html" },
26
+ { label: "CSS", value: "css" },
27
+ { label: "JSON", value: "json" },
28
+ { label: "Markdown", value: "markdown" },
29
+ { label: "Bash", value: "bash" },
30
+ { label: "Python", value: "python" },
31
+ { label: "SQL", value: "sql" },
32
+ { label: "YAML", value: "yaml" },
33
+ { label: "XML", value: "xml" },
34
+ ];
35
+ const PRETTIER_PARSERS = {
36
+ javascript: "babel",
37
+ jsx: "babel",
38
+ typescript: "typescript",
39
+ tsx: "typescript",
40
+ html: "html",
41
+ css: "css",
42
+ json: "json",
43
+ markdown: "markdown",
44
+ yaml: "yaml",
45
+ };
46
+ const PRETTIER_PLUGINS = [
47
+ prettierBabelPlugin,
48
+ prettierEstreePlugin,
49
+ prettierHtmlPlugin,
50
+ prettierMarkdownPlugin,
51
+ prettierPostcssPlugin,
52
+ prettierTypescriptPlugin,
53
+ prettierYamlPlugin,
54
+ ];
55
+ export const getCodeBlockLanguage = (editor) => {
56
+ var _a;
57
+ return (((_a = editor === null || editor === void 0 ? void 0 : editor.getAttributes("codeBlock")) === null || _a === void 0 ? void 0 : _a.language) ||
58
+ DEFAULT_CODE_BLOCK_LANGUAGE);
59
+ };
60
+ export const getCodeBlockLanguageOption = (language) => {
61
+ return (CODE_BLOCK_LANGUAGES.find((item) => item.value === language) ||
62
+ CODE_BLOCK_LANGUAGES[0]);
63
+ };
64
+ export const canFormatCodeBlockLanguage = (language) => {
65
+ return Boolean(language && PRETTIER_PARSERS[language]);
66
+ };
67
+ export const formatCodeBlockText = (text, language) => __awaiter(void 0, void 0, void 0, function* () {
68
+ const parser = language ? PRETTIER_PARSERS[language] : undefined;
69
+ if (!parser) {
70
+ throw new Error("Code formatting is not supported for this language.");
71
+ }
72
+ const formatted = yield prettier.format(text, {
73
+ parser,
74
+ plugins: PRETTIER_PLUGINS,
75
+ });
76
+ return formatted.replace(/\n$/, "");
77
+ });
78
+ export const hasSyntaxHighlightedCodeBlock = (editor) => {
79
+ return Boolean(editor === null || editor === void 0 ? void 0 : editor.extensionManager.extensions.find((extension) => { var _a; return extension.name === "codeBlock" && ((_a = extension.options) === null || _a === void 0 ? void 0 : _a.lowlight); }));
80
+ };
81
+ export const setCodeBlockLanguage = (editor, language) => {
82
+ if (!(editor === null || editor === void 0 ? void 0 : editor.isActive("codeBlock")))
83
+ return;
84
+ editor.chain().focus().updateAttributes("codeBlock", { language }).run();
85
+ };
86
+ export const getCodeBlockWrap = (editor) => {
87
+ var _a;
88
+ return Boolean((_a = editor === null || editor === void 0 ? void 0 : editor.getAttributes("codeBlock")) === null || _a === void 0 ? void 0 : _a.wrap);
89
+ };
90
+ export const toggleCodeBlockWrap = (editor) => {
91
+ if (!(editor === null || editor === void 0 ? void 0 : editor.isActive("codeBlock")))
92
+ return;
93
+ editor
94
+ .chain()
95
+ .focus()
96
+ .updateAttributes("codeBlock", { wrap: !getCodeBlockWrap(editor) })
97
+ .run();
98
+ };
99
+ export const toggleCodeBlock = (editor) => {
100
+ if (!editor)
101
+ return;
102
+ editor
103
+ .chain()
104
+ .focus()
105
+ .toggleCodeBlock({ language: DEFAULT_CODE_BLOCK_LANGUAGE })
106
+ .run();
107
+ };
108
+ export const getActiveCodeBlockText = (editor) => {
109
+ if (!(editor === null || editor === void 0 ? void 0 : editor.isActive("codeBlock")))
110
+ return "";
111
+ return editor.state.selection.$from.parent.textContent;
112
+ };
113
+ export const replaceCodeBlockContent = (editor, from, to, text) => {
114
+ return editor.commands.command(({ state, tr }) => {
115
+ if (text.length) {
116
+ tr.replaceWith(from, to, state.schema.text(text));
117
+ }
118
+ else {
119
+ tr.delete(from, to);
120
+ }
121
+ return true;
122
+ });
123
+ };
124
+ export const formatActiveCodeBlock = (editor) => __awaiter(void 0, void 0, void 0, function* () {
125
+ if (!(editor === null || editor === void 0 ? void 0 : editor.isActive("codeBlock")))
126
+ return;
127
+ const language = getCodeBlockLanguage(editor);
128
+ const formatted = yield formatCodeBlockText(getActiveCodeBlockText(editor), language);
129
+ replaceCodeBlockContent(editor, editor.state.selection.$from.start(), editor.state.selection.$from.end(), formatted);
130
+ });
131
+ export const copyCodeBlockText = (text) => __awaiter(void 0, void 0, void 0, function* () {
132
+ var _a;
133
+ if (!((_a = navigator.clipboard) === null || _a === void 0 ? void 0 : _a.writeText)) {
134
+ throw new Error("Clipboard copying is not supported by this browser.");
135
+ }
136
+ yield navigator.clipboard.writeText(text);
137
+ });
@@ -0,0 +1,3 @@
1
+ import { Editor } from "@tiptap/react";
2
+ export declare const hasInlineCode: (editor: Editor | null) => boolean;
3
+ export declare const toggleInlineCode: (editor: Editor | null) => void;
@@ -0,0 +1,12 @@
1
+ export const hasInlineCode = (editor) => {
2
+ return Boolean(editor === null || editor === void 0 ? void 0 : editor.extensionManager.extensions.find((extension) => extension.name === "code"));
3
+ };
4
+ export const toggleInlineCode = (editor) => {
5
+ if (!editor || !hasInlineCode(editor))
6
+ return;
7
+ if (editor.isActive("code")) {
8
+ editor.chain().focus().unsetCode().run();
9
+ return;
10
+ }
11
+ editor.chain().focus().unsetAllMarks().setCode().run();
12
+ };
@@ -0,0 +1,19 @@
1
+ import { EditorState } from "@tiptap/pm/state";
2
+ export declare const LINK_TARGET = "_blank";
3
+ export declare const LINK_REL = "noopener noreferrer nofollow";
4
+ export type NormalizedLink = {
5
+ href: string;
6
+ isValid: boolean;
7
+ };
8
+ export declare const normalizeLinkUrl: (value?: string | null) => NormalizedLink;
9
+ export declare const getLinkAttributes: (href: string) => {
10
+ href: string;
11
+ target: string;
12
+ rel: string;
13
+ class: string;
14
+ };
15
+ export declare const openLink: (href?: string | null) => void;
16
+ export declare const getLinkRangeAtPosition: (state: EditorState, pos: number) => void | import("@tiptap/core").Range;
17
+ export declare const getLinkAttributesAtPosition: (state: EditorState, pos: number) => {
18
+ href?: string;
19
+ } | undefined;
@@ -0,0 +1,57 @@
1
+ import { getMarkRange } from "@tiptap/core";
2
+ export const LINK_TARGET = "_blank";
3
+ export const LINK_REL = "noopener noreferrer nofollow";
4
+ export const normalizeLinkUrl = (value) => {
5
+ const trimmedValue = (value === null || value === void 0 ? void 0 : value.trim()) || "";
6
+ if (!trimmedValue) {
7
+ return { href: "", isValid: false };
8
+ }
9
+ const href = /^[a-z][a-z0-9+.-]*:/i.test(trimmedValue)
10
+ ? trimmedValue
11
+ : `https://${trimmedValue}`;
12
+ try {
13
+ const url = new URL(href);
14
+ const isValid = url.protocol === "http:" || url.protocol === "https:";
15
+ return {
16
+ href,
17
+ isValid,
18
+ };
19
+ }
20
+ catch (_a) {
21
+ return {
22
+ href,
23
+ isValid: false,
24
+ };
25
+ }
26
+ };
27
+ export const getLinkAttributes = (href) => ({
28
+ href,
29
+ target: LINK_TARGET,
30
+ rel: LINK_REL,
31
+ class: "editor-link",
32
+ });
33
+ export const openLink = (href) => {
34
+ if (!href)
35
+ return;
36
+ const normalizedLink = normalizeLinkUrl(href);
37
+ if (!normalizedLink.isValid)
38
+ return;
39
+ window.open(normalizedLink.href, "_blank", "noopener,noreferrer");
40
+ };
41
+ export const getLinkRangeAtPosition = (state, pos) => {
42
+ const linkMark = state.schema.marks.link;
43
+ if (!linkMark)
44
+ return;
45
+ return getMarkRange(state.doc.resolve(pos), linkMark);
46
+ };
47
+ export const getLinkAttributesAtPosition = (state, pos) => {
48
+ const linkMark = state.schema.marks.link;
49
+ if (!linkMark)
50
+ return;
51
+ const $pos = state.doc.resolve(pos);
52
+ const nextNode = $pos.parent.childAfter($pos.parentOffset).node;
53
+ const previousNode = $pos.parent.childBefore($pos.parentOffset).node;
54
+ const mark = (nextNode === null || nextNode === void 0 ? void 0 : nextNode.marks.find((mark) => mark.type === linkMark)) ||
55
+ (previousNode === null || previousNode === void 0 ? void 0 : previousNode.marks.find((mark) => mark.type === linkMark));
56
+ return mark === null || mark === void 0 ? void 0 : mark.attrs;
57
+ };
@@ -0,0 +1 @@
1
+ export declare const TABLE_CELL_MIN_WIDTH = 120;
@@ -0,0 +1 @@
1
+ export const TABLE_CELL_MIN_WIDTH = 120;