@monolith-forensics/monolith-ui 1.9.3-dev.3 → 1.9.3-dev.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/RichTextEditor/Enums/Controls.d.ts +1 -0
- package/dist/RichTextEditor/Enums/Controls.js +1 -0
- package/dist/RichTextEditor/Enums/SlashCommands.d.ts +1 -0
- package/dist/RichTextEditor/Enums/SlashCommands.js +1 -0
- package/dist/RichTextEditor/Extensions/getSlashCommand.js +10 -1
- package/dist/RichTextEditor/Extensions/getTiptapExtensions.js +1 -1
- package/dist/RichTextEditor/RichTextEditor.js +14 -1
- package/dist/RichTextEditor/Toolbar/Controls.d.ts +1 -0
- package/dist/RichTextEditor/Toolbar/Controls.js +6 -1
- package/dist/RichTextEditor/Toolbar/Toolbar.js +2 -2
- package/package.json +1 -1
|
@@ -9,6 +9,7 @@ export var Controls;
|
|
|
9
9
|
Controls["CLEAR_FORMATTING"] = "clearFormatting";
|
|
10
10
|
Controls["CODE"] = "code";
|
|
11
11
|
Controls["CODE_BLOCK"] = "codeBlock";
|
|
12
|
+
Controls["HORIZONTAL_RULE"] = "horizontalRule";
|
|
12
13
|
Controls["BLOCKQUOTE"] = "blockquote";
|
|
13
14
|
Controls["HEADING_1"] = "heading_1";
|
|
14
15
|
Controls["HEADING_2"] = "heading_2";
|
|
@@ -9,6 +9,7 @@ export var SlashCommands;
|
|
|
9
9
|
SlashCommands["NumberedList"] = "Numbered List";
|
|
10
10
|
SlashCommands["Code"] = "Code";
|
|
11
11
|
SlashCommands["CodeBlock"] = "Code Block";
|
|
12
|
+
SlashCommands["HorizontalRule"] = "Horizontal Rule";
|
|
12
13
|
SlashCommands["Blockquote"] = "Blockquote";
|
|
13
14
|
SlashCommands["CurrentDate"] = "Current Date";
|
|
14
15
|
SlashCommands["CurrentTimestamp"] = "Current Timestamp";
|
|
@@ -11,7 +11,7 @@ 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, TextQuote, Image as ImageIcon, Calendar, CodeIcon, ClockIcon, SquareCodeIcon, Table2Icon, } from "lucide-react";
|
|
14
|
+
import { Heading1, Heading2, Heading3, Heading4, List, ListOrdered, Text, TextQuote, Image as ImageIcon, Calendar, CodeIcon, ClockIcon, SeparatorHorizontalIcon, 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";
|
|
@@ -148,6 +148,15 @@ const getCommandItems = (values, options) => {
|
|
|
148
148
|
editor.chain().focus().deleteRange(range).toggleBlockquote().run();
|
|
149
149
|
},
|
|
150
150
|
},
|
|
151
|
+
{
|
|
152
|
+
title: SlashCommands.HorizontalRule,
|
|
153
|
+
description: "Insert a horizontal divider.",
|
|
154
|
+
searchTerms: ["divider", "line", "rule", "separator"],
|
|
155
|
+
icon: SeparatorHorizontalIcon,
|
|
156
|
+
command: ({ editor, range }) => {
|
|
157
|
+
editor.chain().focus().deleteRange(range).setHorizontalRule().run();
|
|
158
|
+
},
|
|
159
|
+
},
|
|
151
160
|
{
|
|
152
161
|
title: SlashCommands.CurrentDate,
|
|
153
162
|
description: "Insert the current date.",
|
|
@@ -71,6 +71,7 @@ export const BASIC_EXTENSIONS = [
|
|
|
71
71
|
Extensions.Strike,
|
|
72
72
|
Extensions.Code,
|
|
73
73
|
Extensions.Blockquote,
|
|
74
|
+
Extensions.HorizontalRule,
|
|
74
75
|
Extensions.BulletList,
|
|
75
76
|
Extensions.OrderedList,
|
|
76
77
|
Extensions.TextStyle,
|
|
@@ -88,7 +89,6 @@ export const MINIMAL_EXTENSIONS = [
|
|
|
88
89
|
export const FULL_EXTENSIONS = [
|
|
89
90
|
...BASIC_EXTENSIONS,
|
|
90
91
|
Extensions.CodeBlock,
|
|
91
|
-
Extensions.HorizontalRule,
|
|
92
92
|
Extensions.Table,
|
|
93
93
|
Extensions.TableCell,
|
|
94
94
|
Extensions.TableHeader,
|
|
@@ -14,7 +14,7 @@ import { EditorContent, useEditor } from "@tiptap/react";
|
|
|
14
14
|
import { BubbleMenu as TiptapBubbleMenu, } from "@tiptap/react/menus";
|
|
15
15
|
import { isTextSelection } from "@tiptap/core";
|
|
16
16
|
import { DOMParser as ProseMirrorDOMParser } from "@tiptap/pm/model";
|
|
17
|
-
import { TextSelection } from "@tiptap/pm/state";
|
|
17
|
+
import { NodeSelection, TextSelection } from "@tiptap/pm/state";
|
|
18
18
|
import { Toolbar } from "./Toolbar";
|
|
19
19
|
import getTipTapExtensions, { resolveExtensions, } from "./Extensions/getTiptapExtensions";
|
|
20
20
|
import { Controls, Extensions, SlashCommands } from "./Enums";
|
|
@@ -435,6 +435,12 @@ const StyledContent = styled.div `
|
|
|
435
435
|
margin: 0;
|
|
436
436
|
line-height: 1.5rem;
|
|
437
437
|
}
|
|
438
|
+
|
|
439
|
+
hr {
|
|
440
|
+
border: 1px solid ${({ theme }) => theme.palette.action.hover};
|
|
441
|
+
margin: 1rem 0;
|
|
442
|
+
}
|
|
443
|
+
|
|
438
444
|
.editor-inline-code,
|
|
439
445
|
:not(pre) > code {
|
|
440
446
|
padding: 0.1rem 0.25rem;
|
|
@@ -844,6 +850,9 @@ export const RichTextEditor = ({ className, editorInstanceRef, defaultValue = ""
|
|
|
844
850
|
if (command === SlashCommands.Blockquote) {
|
|
845
851
|
return resolvedExtensionSet.has(Extensions.Blockquote);
|
|
846
852
|
}
|
|
853
|
+
if (command === SlashCommands.HorizontalRule) {
|
|
854
|
+
return resolvedExtensionSet.has(Extensions.HorizontalRule);
|
|
855
|
+
}
|
|
847
856
|
if (command === SlashCommands.Table) {
|
|
848
857
|
return resolvedExtensionSet.has(Extensions.Table);
|
|
849
858
|
}
|
|
@@ -860,6 +869,7 @@ export const RichTextEditor = ({ className, editorInstanceRef, defaultValue = ""
|
|
|
860
869
|
[Controls.CODE]: Extensions.Code,
|
|
861
870
|
[Controls.CODE_BLOCK]: Extensions.CodeBlock,
|
|
862
871
|
[Controls.BLOCKQUOTE]: Extensions.Blockquote,
|
|
872
|
+
[Controls.HORIZONTAL_RULE]: Extensions.HorizontalRule,
|
|
863
873
|
[Controls.BULLET_LIST]: Extensions.BulletList,
|
|
864
874
|
[Controls.ORDERED_LIST]: Extensions.OrderedList,
|
|
865
875
|
[Controls.COLOR]: Extensions.Color,
|
|
@@ -917,8 +927,11 @@ export const RichTextEditor = ({ className, editorInstanceRef, defaultValue = ""
|
|
|
917
927
|
const hasEditorFocus = view.hasFocus() || isChildOfMenu;
|
|
918
928
|
const selectedText = state.doc.textBetween(from, to).trim();
|
|
919
929
|
const isEmptyTextBlock = !selectedText && isTextSelection(state.selection);
|
|
930
|
+
const isHorizontalRuleSelection = selection instanceof NodeSelection &&
|
|
931
|
+
selection.node.type.name === "horizontalRule";
|
|
920
932
|
if (!hasEditorFocus ||
|
|
921
933
|
selection.empty ||
|
|
934
|
+
isHorizontalRuleSelection ||
|
|
922
935
|
isEmptyTextBlock ||
|
|
923
936
|
!editor.isEditable) {
|
|
924
937
|
return false;
|
|
@@ -15,6 +15,7 @@ export declare const StrikeThroughControl: ({ editor }: ControlProps) => import(
|
|
|
15
15
|
export declare const CodeControl: ({ editor }: ControlProps) => import("react/jsx-runtime").JSX.Element;
|
|
16
16
|
export declare const CodeBlockControl: ({ editor }: ControlProps) => import("react/jsx-runtime").JSX.Element;
|
|
17
17
|
export declare const BlockquoteControl: ({ editor }: ControlProps) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export declare const HorizontalRuleControl: ({ editor }: ControlProps) => import("react/jsx-runtime").JSX.Element;
|
|
18
19
|
export declare const Heading1Control: ({ editor }: ControlProps) => import("react/jsx-runtime").JSX.Element;
|
|
19
20
|
export declare const Heading2Control: ({ editor }: ControlProps) => import("react/jsx-runtime").JSX.Element;
|
|
20
21
|
export declare const Heading3Control: ({ editor }: ControlProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { IconBold, IconItalic, IconUnderline, IconStrikethrough, IconH1, IconH2, IconH3, IconH4, IconList, IconListNumbers, IconAlignLeft, IconAlignRight, IconAlignCenter, IconAlignJustified, IconCornerUpLeft, IconCornerUpRight, IconBlockquote, } from "@tabler/icons-react";
|
|
2
|
+
import { IconBold, IconItalic, IconUnderline, IconStrikethrough, IconH1, IconH2, IconH3, IconH4, IconList, IconListNumbers, IconAlignLeft, IconAlignRight, IconAlignCenter, IconAlignJustified, IconCornerUpLeft, IconCornerUpRight, IconBlockquote, IconSeparatorHorizontal, } from "@tabler/icons-react";
|
|
3
3
|
import { CodeIcon, HighlighterIcon, PaletteIcon, RemoveFormattingIcon, SquircleIcon, TypeIcon, } from "lucide-react";
|
|
4
4
|
import { SquareCodeIcon } from "lucide-react";
|
|
5
5
|
import { Control } from "./Control";
|
|
@@ -163,6 +163,11 @@ export const BlockquoteControl = ({ editor }) => {
|
|
|
163
163
|
name: "toggleBlockquote",
|
|
164
164
|
}, icon: IconBlockquote }));
|
|
165
165
|
};
|
|
166
|
+
export const HorizontalRuleControl = ({ editor }) => {
|
|
167
|
+
return (_jsx(Control, { editor: editor, label: "hrControlLabel", operation: {
|
|
168
|
+
name: "setHorizontalRule",
|
|
169
|
+
}, icon: IconSeparatorHorizontal }));
|
|
170
|
+
};
|
|
166
171
|
export const Heading1Control = ({ editor }) => {
|
|
167
172
|
return (_jsx(Control, { editor: editor, label: "h1ControlLabel", isActive: {
|
|
168
173
|
name: "heading",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import styled from "styled-components";
|
|
3
3
|
import ControlsGroup from "./ControlsGroup";
|
|
4
|
-
import { UndoControl, RedoControl, FontControl, TextColorControl, HighlightControl, BoldControl, ItalicControl, UnderlineControl, StrikeThroughControl, ClearFormattingControl, CodeControl, CodeBlockControl, BlockquoteControl, 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, BlockquoteControl, HorizontalRuleControl, 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
7
|
import { useState } from "react";
|
|
@@ -46,5 +46,5 @@ export const Toolbar = ({ editor, toolbarOptions }) => {
|
|
|
46
46
|
},
|
|
47
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));
|
|
48
48
|
}
|
|
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 })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.BLOCKQUOTE)) && (_jsx(BlockquoteControl, { 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 }))] }));
|
|
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 })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.BLOCKQUOTE)) && (_jsx(BlockquoteControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.HORIZONTAL_RULE)) && (_jsx(HorizontalRuleControl, { 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
50
|
};
|