@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
@@ -5,6 +5,9 @@ export declare enum Controls {
5
5
  ITALIC = "italic",
6
6
  UNDERLINE = "underline",
7
7
  STRIKE = "strike",
8
+ CLEAR_FORMATTING = "clearFormatting",
9
+ CODE = "code",
10
+ CODE_BLOCK = "codeBlock",
8
11
  HEADING_1 = "heading_1",
9
12
  HEADING_2 = "heading_2",
10
13
  HEADING_3 = "heading_3",
@@ -16,5 +19,8 @@ export declare enum Controls {
16
19
  TEXT_ALIGN_RIGHT = "textAlignRight",
17
20
  TEXT_ALIGN_JUSTIFIED = "textAlignJustified",
18
21
  FONT = "font",
19
- COLOR = "color"
22
+ COLOR = "color",
23
+ HIGHLIGHT = "highlight",
24
+ LINK = "link",
25
+ TABLE = "table"
20
26
  }
@@ -6,6 +6,9 @@ export var Controls;
6
6
  Controls["ITALIC"] = "italic";
7
7
  Controls["UNDERLINE"] = "underline";
8
8
  Controls["STRIKE"] = "strike";
9
+ Controls["CLEAR_FORMATTING"] = "clearFormatting";
10
+ Controls["CODE"] = "code";
11
+ Controls["CODE_BLOCK"] = "codeBlock";
9
12
  Controls["HEADING_1"] = "heading_1";
10
13
  Controls["HEADING_2"] = "heading_2";
11
14
  Controls["HEADING_3"] = "heading_3";
@@ -18,4 +21,7 @@ export var Controls;
18
21
  Controls["TEXT_ALIGN_JUSTIFIED"] = "textAlignJustified";
19
22
  Controls["FONT"] = "font";
20
23
  Controls["COLOR"] = "color";
24
+ Controls["HIGHLIGHT"] = "highlight";
25
+ Controls["LINK"] = "link";
26
+ Controls["TABLE"] = "table";
21
27
  })(Controls || (Controls = {}));
@@ -4,7 +4,11 @@ export declare enum Extensions {
4
4
  Underline = "underline",
5
5
  Bold = "bold",
6
6
  Italic = "italic",
7
+ Code = "code",
8
+ CodeBlock = "codeBlock",
7
9
  Color = "color",
10
+ Highlight = "highlight",
11
+ Link = "link",
8
12
  TextStyle = "textStyle",
9
13
  Strike = "strike",
10
14
  BulletList = "bulletList",
@@ -5,7 +5,11 @@ export var Extensions;
5
5
  Extensions["Underline"] = "underline";
6
6
  Extensions["Bold"] = "bold";
7
7
  Extensions["Italic"] = "italic";
8
+ Extensions["Code"] = "code";
9
+ Extensions["CodeBlock"] = "codeBlock";
8
10
  Extensions["Color"] = "color";
11
+ Extensions["Highlight"] = "highlight";
12
+ Extensions["Link"] = "link";
9
13
  Extensions["TextStyle"] = "textStyle";
10
14
  Extensions["Strike"] = "strike";
11
15
  Extensions["BulletList"] = "bulletList";
@@ -0,0 +1,9 @@
1
+ declare enum HighlightColors {
2
+ Yellow = "rgba(250, 204, 21, 0.38)",
3
+ Green = "rgba(34, 197, 94, 0.34)",
4
+ Blue = "rgba(59, 130, 246, 0.34)",
5
+ Pink = "rgba(236, 72, 153, 0.32)",
6
+ Purple = "rgba(168, 85, 247, 0.34)",
7
+ Orange = "rgba(249, 115, 22, 0.34)"
8
+ }
9
+ export default HighlightColors;
@@ -0,0 +1,10 @@
1
+ var HighlightColors;
2
+ (function (HighlightColors) {
3
+ HighlightColors["Yellow"] = "rgba(250, 204, 21, 0.38)";
4
+ HighlightColors["Green"] = "rgba(34, 197, 94, 0.34)";
5
+ HighlightColors["Blue"] = "rgba(59, 130, 246, 0.34)";
6
+ HighlightColors["Pink"] = "rgba(236, 72, 153, 0.32)";
7
+ HighlightColors["Purple"] = "rgba(168, 85, 247, 0.34)";
8
+ HighlightColors["Orange"] = "rgba(249, 115, 22, 0.34)";
9
+ })(HighlightColors || (HighlightColors = {}));
10
+ export default HighlightColors;
@@ -6,7 +6,10 @@ export declare enum SlashCommands {
6
6
  Heading4 = "Heading 4",
7
7
  BulletList = "Bullet List",
8
8
  NumberedList = "Numbered List",
9
+ Code = "Code",
10
+ CodeBlock = "Code Block",
9
11
  CurrentDate = "Current Date",
10
12
  CurrentTimestamp = "Current Timestamp",
11
- Image = "Image"
13
+ Image = "Image",
14
+ Table = "Table"
12
15
  }
@@ -7,7 +7,10 @@ export var SlashCommands;
7
7
  SlashCommands["Heading4"] = "Heading 4";
8
8
  SlashCommands["BulletList"] = "Bullet List";
9
9
  SlashCommands["NumberedList"] = "Numbered List";
10
+ SlashCommands["Code"] = "Code";
11
+ SlashCommands["CodeBlock"] = "Code Block";
10
12
  SlashCommands["CurrentDate"] = "Current Date";
11
13
  SlashCommands["CurrentTimestamp"] = "Current Timestamp";
12
14
  SlashCommands["Image"] = "Image";
15
+ SlashCommands["Table"] = "Table";
13
16
  })(SlashCommands || (SlashCommands = {}));
@@ -62,7 +62,6 @@ const CommandDescription = styled.div `
62
62
  color: ${({ theme }) => theme.palette.text.secondary};
63
63
  text-overflow: ellipsis;
64
64
  overflow: hidden;
65
- white-space: nowrap;
66
65
  `;
67
66
  const updateScrollView = (container, item) => {
68
67
  const containerHeight = container.offsetHeight;
@@ -11,12 +11,13 @@ import { Extension } from "@tiptap/core";
11
11
  import Suggestion from "@tiptap/suggestion";
12
12
  import { ReactRenderer } from "@tiptap/react";
13
13
  import tippy from "tippy.js";
14
- import { Heading1, Heading2, Heading3, Heading4, List, ListOrdered, Text, Image as ImageIcon, Calendar, ClockIcon, } from "lucide-react";
14
+ import { Heading1, Heading2, Heading3, Heading4, List, ListOrdered, Text, Image as ImageIcon, Calendar, CodeIcon, ClockIcon, SquareCodeIcon, Table2Icon, } from "lucide-react";
15
15
  import { startImageUpload, } from "../Plugins/UploadImagesPlugin.js";
16
16
  import { PluginKey } from "@tiptap/pm/state";
17
17
  import SlashCommandList from "./SlashCommandList";
18
18
  import { SlashCommands } from "../Enums";
19
19
  import moment from "moment/moment.js";
20
+ import { DEFAULT_CODE_BLOCK_LANGUAGE } from "../Utils/codeBlockUtils";
20
21
  const SlashCommandPluginKey = new PluginKey("slash-command");
21
22
  const getCommandItems = (values, options) => {
22
23
  var _a;
@@ -115,6 +116,29 @@ const getCommandItems = (values, options) => {
115
116
  editor.chain().focus().deleteRange(range).toggleOrderedList().run();
116
117
  },
117
118
  },
119
+ {
120
+ title: SlashCommands.Code,
121
+ description: "Start typing inline code.",
122
+ searchTerms: ["inline", "monospace"],
123
+ icon: CodeIcon,
124
+ command: ({ editor, range }) => {
125
+ editor.chain().focus().deleteRange(range).setCode().run();
126
+ },
127
+ },
128
+ {
129
+ title: SlashCommands.CodeBlock,
130
+ description: "Create a syntax-highlighted code block.",
131
+ searchTerms: ["code", "pre", "snippet"],
132
+ icon: SquareCodeIcon,
133
+ command: ({ editor, range }) => {
134
+ editor
135
+ .chain()
136
+ .focus()
137
+ .deleteRange(range)
138
+ .setCodeBlock({ language: DEFAULT_CODE_BLOCK_LANGUAGE })
139
+ .run();
140
+ },
141
+ },
118
142
  {
119
143
  title: SlashCommands.CurrentDate,
120
144
  description: "Insert the current date.",
@@ -170,6 +194,20 @@ const getCommandItems = (values, options) => {
170
194
  input.click();
171
195
  },
172
196
  },
197
+ {
198
+ title: SlashCommands.Table,
199
+ description: "Insert a 3 by 3 table.",
200
+ searchTerms: ["grid", "rows", "columns"],
201
+ icon: Table2Icon,
202
+ command: ({ editor, range }) => {
203
+ editor
204
+ .chain()
205
+ .focus()
206
+ .deleteRange(range)
207
+ .insertTable({ rows: 3, cols: 3, withHeaderRow: true })
208
+ .run();
209
+ },
210
+ },
173
211
  ]
174
212
  .filter((item) => {
175
213
  if (options === null || options === void 0 ? void 0 : options.commands) {
@@ -1,12 +1,20 @@
1
1
  import { Extension } from "@tiptap/core";
2
2
  import { HandleImageUpload } from "../Plugins";
3
3
  import { Extensions } from "../Enums";
4
- import { BubbleMenuOptions } from "./BubbleMenuExtension";
4
+ export type ExtensionPreset = "minimal" | "basic" | "full";
5
5
  export type ExtensionType = (typeof Extensions)[keyof typeof Extensions];
6
+ export declare const BASIC_EXTENSIONS: ExtensionType[];
7
+ export declare const MINIMAL_EXTENSIONS: ExtensionType[];
8
+ export declare const FULL_EXTENSIONS: ExtensionType[];
9
+ export declare const resolveExtensions: ({ disabledExtensions, extensionPreset, extensions, }: {
10
+ disabledExtensions?: ExtensionType[];
11
+ extensionPreset?: ExtensionPreset;
12
+ extensions?: ExtensionType[];
13
+ }) => ExtensionType[];
6
14
  interface GetTipTapExtensionsProps {
15
+ disabledExtensions?: ExtensionType[];
7
16
  extensions?: ExtensionType[];
8
17
  slashCommands?: any[];
9
- bubbleMenuOptions?: BubbleMenuOptions;
10
18
  handleImageUpload?: HandleImageUpload;
11
19
  }
12
20
  declare const getTipTapExtensions: (props: GetTipTapExtensionsProps) => Extension[];
@@ -1,16 +1,38 @@
1
1
  import TiptapImage from "@tiptap/extension-image";
2
2
  import StarterKit from "@tiptap/starter-kit";
3
+ import { CodeBlockLowlight } from "@tiptap/extension-code-block-lowlight";
3
4
  import HorizontalRule from "@tiptap/extension-horizontal-rule";
4
5
  import TextAlign from "@tiptap/extension-text-align";
5
6
  import { Table, TableCell, TableHeader, TableRow, } from "@tiptap/extension-table";
6
7
  import { Focus, Placeholder } from "@tiptap/extensions";
7
8
  import { Color } from "@tiptap/extension-color";
9
+ import { Highlight } from "@tiptap/extension-highlight";
10
+ import { Link } from "@tiptap/extension-link";
8
11
  import { TextStyle } from "@tiptap/extension-text-style";
9
12
  import { InputRule, Extension } from "@tiptap/core";
13
+ import { ReactNodeViewRenderer } from "@tiptap/react";
14
+ import { common, createLowlight } from "lowlight";
10
15
  import { ImageActionsPlugin, UploadImagesPlugin, } from "../Plugins";
11
16
  import getSlashCommand from "./getSlashCommand";
12
17
  import { Extensions } from "../Enums";
13
- import BubbleMenu from "./BubbleMenuExtension";
18
+ import { LINK_REL, LINK_TARGET, normalizeLinkUrl } from "../Utils/linkUtils";
19
+ import CodeBlockNodeView from "../Components/CodeBlockNodeView";
20
+ import { DEFAULT_CODE_BLOCK_LANGUAGE } from "../Utils/codeBlockUtils";
21
+ import { TABLE_CELL_MIN_WIDTH } from "../Utils/tableUtils";
22
+ const lowlight = createLowlight(common);
23
+ const CustomCodeBlockLowlight = CodeBlockLowlight.extend({
24
+ addAttributes() {
25
+ var _a;
26
+ return Object.assign(Object.assign({}, (_a = this.parent) === null || _a === void 0 ? void 0 : _a.call(this)), { wrap: {
27
+ default: false,
28
+ parseHTML: (element) => element.getAttribute("data-wrap") === "true",
29
+ renderHTML: (attributes) => attributes.wrap ? { "data-wrap": "true" } : {},
30
+ } });
31
+ },
32
+ addNodeView() {
33
+ return ReactNodeViewRenderer(CodeBlockNodeView);
34
+ },
35
+ });
14
36
  const CustomImage = TiptapImage.extend({
15
37
  // Add data-uuid attribute to image
16
38
  addAttributes() {
@@ -42,27 +64,107 @@ const CustomStorage = Extension.create({
42
64
  };
43
65
  },
44
66
  });
45
- const getTipTapExtensions = ({ extensions = [], slashCommands = [], bubbleMenuOptions, handleImageUpload, }) => {
67
+ export const BASIC_EXTENSIONS = [
68
+ Extensions.Bold,
69
+ Extensions.Italic,
70
+ Extensions.Underline,
71
+ Extensions.Strike,
72
+ Extensions.Code,
73
+ Extensions.BulletList,
74
+ Extensions.OrderedList,
75
+ Extensions.TextStyle,
76
+ Extensions.Color,
77
+ Extensions.Highlight,
78
+ Extensions.Link,
79
+ Extensions.TextAlign,
80
+ Extensions.Focus,
81
+ Extensions.CustomStorage,
82
+ ];
83
+ export const MINIMAL_EXTENSIONS = [
84
+ Extensions.Focus,
85
+ Extensions.CustomStorage,
86
+ ];
87
+ export const FULL_EXTENSIONS = [
88
+ ...BASIC_EXTENSIONS,
89
+ Extensions.CodeBlock,
90
+ Extensions.HorizontalRule,
91
+ Extensions.Table,
92
+ Extensions.TableCell,
93
+ Extensions.TableHeader,
94
+ Extensions.TableRow,
95
+ Extensions.Placeholder,
96
+ Extensions.SlashCommand,
97
+ Extensions.BubbleMenu,
98
+ ];
99
+ const EXTENSION_PRESETS = {
100
+ minimal: MINIMAL_EXTENSIONS,
101
+ basic: BASIC_EXTENSIONS,
102
+ full: FULL_EXTENSIONS,
103
+ };
104
+ export const resolveExtensions = ({ disabledExtensions = [], extensionPreset = "basic", extensions = [], }) => {
105
+ const disabled = new Set(disabledExtensions);
106
+ const resolved = new Set([
107
+ ...(EXTENSION_PRESETS[extensionPreset] || BASIC_EXTENSIONS),
108
+ ...extensions,
109
+ ]);
110
+ if (resolved.has(Extensions.Color)) {
111
+ resolved.add(Extensions.TextStyle);
112
+ }
113
+ if (resolved.has(Extensions.Table)) {
114
+ resolved.add(Extensions.TableRow);
115
+ resolved.add(Extensions.TableCell);
116
+ resolved.add(Extensions.TableHeader);
117
+ }
118
+ disabled.forEach((extension) => resolved.delete(extension));
119
+ return Array.from(resolved);
120
+ };
121
+ const getTipTapExtensions = ({ disabledExtensions = [], extensions = [], slashCommands = [], handleImageUpload, }) => {
122
+ const disabled = new Set(disabledExtensions);
123
+ const enabled = new Set(extensions);
124
+ const isEnabled = (extension) => enabled.has(extension) && !disabled.has(extension);
46
125
  return [
47
126
  {
48
127
  name: "starterKit",
49
- category: "default",
50
128
  extension: StarterKit.configure({
51
- bulletList: {
52
- HTMLAttributes: {
53
- class: "",
54
- },
55
- },
56
- orderedList: {
57
- HTMLAttributes: {
58
- class: "",
59
- },
60
- },
61
- listItem: {
62
- HTMLAttributes: {
63
- class: "",
64
- },
65
- },
129
+ bold: isEnabled(Extensions.Bold) ? {} : false,
130
+ italic: isEnabled(Extensions.Italic) ? {} : false,
131
+ underline: isEnabled(Extensions.Underline) ? {} : false,
132
+ strike: isEnabled(Extensions.Strike) ? {} : false,
133
+ bulletList: isEnabled(Extensions.BulletList)
134
+ ? {
135
+ HTMLAttributes: {
136
+ class: "",
137
+ },
138
+ }
139
+ : false,
140
+ orderedList: isEnabled(Extensions.OrderedList)
141
+ ? {
142
+ HTMLAttributes: {
143
+ class: "",
144
+ },
145
+ }
146
+ : false,
147
+ listItem: isEnabled(Extensions.BulletList) ||
148
+ isEnabled(Extensions.OrderedList)
149
+ ? {
150
+ HTMLAttributes: {
151
+ class: "",
152
+ },
153
+ }
154
+ : false,
155
+ listKeymap: isEnabled(Extensions.BulletList) ||
156
+ isEnabled(Extensions.OrderedList)
157
+ ? {}
158
+ : false,
159
+ link: false,
160
+ code: isEnabled(Extensions.Code)
161
+ ? {
162
+ HTMLAttributes: {
163
+ class: "editor-inline-code",
164
+ },
165
+ }
166
+ : false,
167
+ codeBlock: false,
66
168
  horizontalRule: false,
67
169
  dropcursor: {
68
170
  color: "#DBEAFE",
@@ -71,24 +173,53 @@ const getTipTapExtensions = ({ extensions = [], slashCommands = [], bubbleMenuOp
71
173
  gapcursor: false,
72
174
  }),
73
175
  },
176
+ {
177
+ name: Extensions.CodeBlock,
178
+ extension: CustomCodeBlockLowlight.configure({
179
+ lowlight,
180
+ defaultLanguage: DEFAULT_CODE_BLOCK_LANGUAGE,
181
+ enableTabIndentation: true,
182
+ HTMLAttributes: {
183
+ class: "editor-code-block",
184
+ },
185
+ }),
186
+ },
74
187
  {
75
188
  name: Extensions.TextStyle,
76
- category: "default",
77
189
  extension: TextStyle,
78
190
  },
79
191
  {
80
192
  name: Extensions.Color,
81
- category: "default",
82
193
  extension: Color,
83
194
  },
195
+ {
196
+ name: Extensions.Highlight,
197
+ extension: Highlight.configure({ multicolor: true }),
198
+ },
199
+ {
200
+ name: Extensions.Link,
201
+ extension: Link.configure({
202
+ autolink: true,
203
+ linkOnPaste: true,
204
+ openOnClick: false,
205
+ enableClickSelection: false,
206
+ defaultProtocol: "https",
207
+ protocols: ["http", "https"],
208
+ isAllowedUri: (url) => normalizeLinkUrl(url).isValid,
209
+ shouldAutoLink: (url) => normalizeLinkUrl(url).isValid,
210
+ HTMLAttributes: {
211
+ class: "editor-link",
212
+ target: LINK_TARGET,
213
+ rel: LINK_REL,
214
+ },
215
+ }),
216
+ },
84
217
  {
85
218
  name: Extensions.TextAlign,
86
- category: "default",
87
219
  extension: TextAlign.configure({ types: ["heading", "paragraph"] }),
88
220
  },
89
221
  {
90
222
  name: Extensions.Focus,
91
- category: "default",
92
223
  extension: Focus.configure({ className: "has-focus", mode: "all" }),
93
224
  },
94
225
  // patch to fix horizontal rule bug: https://github.com/ueberdosis/tiptap/pull/3859#issuecomment-1536799740
@@ -115,6 +246,7 @@ const getTipTapExtensions = ({ extensions = [], slashCommands = [], bubbleMenuOp
115
246
  name: Extensions.Table,
116
247
  extension: Table.configure({
117
248
  resizable: true,
249
+ cellMinWidth: TABLE_CELL_MIN_WIDTH,
118
250
  }),
119
251
  },
120
252
  {
@@ -159,14 +291,8 @@ const getTipTapExtensions = ({ extensions = [], slashCommands = [], bubbleMenuOp
159
291
  },
160
292
  {
161
293
  name: Extensions.CustomStorage,
162
- category: "default",
163
294
  extension: CustomStorage,
164
295
  },
165
- {
166
- name: Extensions.BubbleMenu,
167
- category: "default",
168
- extension: BubbleMenu.configure(bubbleMenuOptions),
169
- },
170
296
  {
171
297
  name: Extensions.SlashCommand,
172
298
  extension: getSlashCommand({
@@ -176,8 +302,9 @@ const getTipTapExtensions = ({ extensions = [], slashCommands = [], bubbleMenuOp
176
302
  },
177
303
  ]
178
304
  .filter((ext) => {
179
- return (extensions.includes(ext.name) ||
180
- ext.category === "default");
305
+ if (ext.name === "starterKit")
306
+ return true;
307
+ return isEnabled(ext.name);
181
308
  })
182
309
  .map((ext) => ext.extension);
183
310
  };
@@ -11,7 +11,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
11
11
  import { Plugin, PluginKey } from "@tiptap/pm/state";
12
12
  import { ReactRenderer } from "@tiptap/react";
13
13
  import { CopyIcon, DownloadIcon, FullscreenIcon } from "lucide-react";
14
- import styled from "styled-components";
14
+ import styled, { useTheme } from "styled-components";
15
15
  import { Button } from "../../Button";
16
16
  import { FileViewer } from "../../FileViewer";
17
17
  import { useState } from "react";
@@ -19,10 +19,6 @@ const imageActionsKey = new PluginKey("image-actions");
19
19
  const ImageActionsMenuRoot = styled.div `
20
20
  display: flex;
21
21
  gap: 4px;
22
- padding: 4px;
23
- border-radius: 5px;
24
-
25
- box-shadow: 0 4px 14px rgba(0, 0, 0, 0.16);
26
22
 
27
23
  button {
28
24
  width: 24px;
@@ -30,16 +26,17 @@ const ImageActionsMenuRoot = styled.div `
30
26
  }
31
27
  `;
32
28
  const ImageActionsMenu = ({ onCopy, onDownload, getFile, onMouseEnter, onMouseLeave, }) => {
29
+ const theme = useTheme();
33
30
  const [viewerFile, setViewerFile] = useState(null);
34
31
  const keepEditorFocus = (event) => {
35
32
  event.preventDefault();
36
33
  };
37
- return (_jsxs(_Fragment, { children: [_jsxs(ImageActionsMenuRoot, { onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, children: [_jsx(Button, { type: "button", size: "xxs", variant: "outlined", "aria-label": "Copy image", title: "Copy image", onMouseDown: keepEditorFocus, onClick: onCopy, children: _jsx(CopyIcon, { size: 14 }) }), _jsx(Button, { type: "button", size: "xxs", variant: "outlined", "aria-label": "Download image", title: "Download image", onMouseDown: keepEditorFocus, onClick: onDownload, children: _jsx(DownloadIcon, { size: 14 }) }), _jsx(Button, { type: "button", size: "xxs", variant: "outlined", "aria-label": "View image fullscreen", title: "View image fullscreen", onMouseDown: keepEditorFocus, onClick: () => {
34
+ return (_jsxs(_Fragment, { children: [_jsxs(ImageActionsMenuRoot, { onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, children: [_jsx(Button, { type: "button", size: "xxs", variant: "outlined", "aria-label": "Copy image", title: "Copy image", onMouseDown: keepEditorFocus, onClick: onCopy, style: { backgroundColor: theme.palette.background.paper }, children: _jsx(CopyIcon, { size: 14 }) }), _jsx(Button, { type: "button", size: "xxs", variant: "outlined", "aria-label": "Download image", title: "Download image", onMouseDown: keepEditorFocus, onClick: onDownload, style: { backgroundColor: theme.palette.background.paper }, children: _jsx(DownloadIcon, { size: 14 }) }), _jsx(Button, { type: "button", size: "xxs", variant: "outlined", "aria-label": "View image fullscreen", title: "View image fullscreen", onMouseDown: keepEditorFocus, onClick: () => {
38
35
  const file = getFile();
39
36
  if (file) {
40
37
  setViewerFile(file);
41
38
  }
42
- }, children: _jsx(FullscreenIcon, { size: 14 }) })] }), _jsx(FileViewer, { file: viewerFile || undefined, open: Boolean(viewerFile), onClose: () => setViewerFile(null) })] }));
39
+ }, style: { backgroundColor: theme.palette.background.paper }, children: _jsx(FullscreenIcon, { size: 14 }) })] }), _jsx(FileViewer, { file: viewerFile || undefined, open: Boolean(viewerFile), onClose: () => setViewerFile(null) })] }));
43
40
  };
44
41
  const getImageFilename = (image) => {
45
42
  var _a, _b;
@@ -1,12 +1,14 @@
1
1
  import { Editor } from "@tiptap/react";
2
- import { ExtensionType } from "./Extensions/getTiptapExtensions";
2
+ import { ExtensionPreset, ExtensionType } from "./Extensions/getTiptapExtensions";
3
3
  import { HandleImageUrlUpload, HandleImageUpload } from "./Plugins/UploadImagesPlugin";
4
- import { BubbleMenuOptions } from "./Extensions/BubbleMenuExtension";
4
+ import { BubbleMenuOptions } from "./Components/BubbleMenu";
5
5
  import { ToolbarOptions } from "./Toolbar/Toolbar";
6
6
  type RichTextEditorProps = {
7
7
  className?: string;
8
8
  editorInstanceRef?: React.RefObject<Editor | null>;
9
9
  extensions?: ExtensionType[];
10
+ disabledExtensions?: ExtensionType[];
11
+ extensionPreset?: ExtensionPreset;
10
12
  slashCommands?: any[];
11
13
  defaultValue?: string;
12
14
  value?: string;