@monolith-forensics/monolith-ui 1.9.1-dev.1 → 1.9.1-dev.11
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/DropDownMenu/components/MenuItemList.js +32 -12
- package/dist/DropDownMenu/components/StyledInnerItemContainer.js +1 -0
- package/dist/MonolithUIProvider/MonolithUIProvider.d.ts +23 -0
- package/dist/RichTextEditor/Components/BubbleMenu.d.ts +8 -8
- package/dist/RichTextEditor/Components/BubbleMenu.js +195 -93
- package/dist/RichTextEditor/Components/CodeBlockBaseButton.d.ts +18 -0
- package/dist/RichTextEditor/Components/CodeBlockBaseButton.js +6 -0
- package/dist/RichTextEditor/Components/CodeBlockCopyButton.d.ts +9 -0
- package/dist/RichTextEditor/Components/CodeBlockCopyButton.js +42 -0
- package/dist/RichTextEditor/Components/CodeBlockFormatButton.d.ts +10 -0
- package/dist/RichTextEditor/Components/CodeBlockFormatButton.js +60 -0
- package/dist/RichTextEditor/Components/CodeBlockLanguageSelect.d.ts +9 -0
- package/dist/RichTextEditor/Components/CodeBlockLanguageSelect.js +30 -0
- package/dist/RichTextEditor/Components/CodeBlockNodeView.d.ts +3 -0
- package/dist/RichTextEditor/Components/CodeBlockNodeView.js +28 -0
- package/dist/RichTextEditor/Components/CodeBlockWrapButton.d.ts +10 -0
- package/dist/RichTextEditor/Components/CodeBlockWrapButton.js +17 -0
- package/dist/RichTextEditor/Components/LinkEditor.d.ts +8 -0
- package/dist/RichTextEditor/Components/LinkEditor.js +94 -0
- package/dist/RichTextEditor/Enums/Controls.d.ts +5 -1
- package/dist/RichTextEditor/Enums/Controls.js +4 -0
- package/dist/RichTextEditor/Enums/Extensions.d.ts +4 -0
- package/dist/RichTextEditor/Enums/Extensions.js +4 -0
- package/dist/RichTextEditor/Enums/HighlightColors.d.ts +9 -0
- package/dist/RichTextEditor/Enums/HighlightColors.js +10 -0
- package/dist/RichTextEditor/Enums/SlashCommands.d.ts +2 -0
- package/dist/RichTextEditor/Enums/SlashCommands.js +2 -0
- package/dist/RichTextEditor/Extensions/SlashCommandList.js +0 -1
- package/dist/RichTextEditor/Extensions/getSlashCommand.js +25 -1
- package/dist/RichTextEditor/Extensions/getTiptapExtensions.d.ts +10 -2
- package/dist/RichTextEditor/Extensions/getTiptapExtensions.js +158 -31
- package/dist/RichTextEditor/Plugins/ImageActionsPlugin.js +6 -109
- package/dist/RichTextEditor/Plugins/UploadImagesPlugin.js +1 -0
- package/dist/RichTextEditor/RichTextEditor.d.ts +4 -2
- package/dist/RichTextEditor/RichTextEditor.js +323 -13
- package/dist/RichTextEditor/Toolbar/Control.d.ts +6 -2
- package/dist/RichTextEditor/Toolbar/Control.js +13 -6
- package/dist/RichTextEditor/Toolbar/Controls.d.ts +2 -0
- package/dist/RichTextEditor/Toolbar/Controls.js +14 -0
- package/dist/RichTextEditor/Toolbar/ControlsGroup.js +1 -0
- package/dist/RichTextEditor/Toolbar/Toolbar.js +61 -9
- package/dist/RichTextEditor/Utils/codeBlockUtils.d.ts +20 -0
- package/dist/RichTextEditor/Utils/codeBlockUtils.js +137 -0
- package/dist/RichTextEditor/Utils/codeUtils.d.ts +3 -0
- package/dist/RichTextEditor/Utils/codeUtils.js +12 -0
- package/dist/RichTextEditor/Utils/linkUtils.d.ts +19 -0
- package/dist/RichTextEditor/Utils/linkUtils.js +57 -0
- package/dist/theme/variants.js +46 -0
- package/package.json +8 -1
- package/dist/RichTextEditor/Extensions/BubbleMenuExtension.d.ts +0 -7
- package/dist/RichTextEditor/Extensions/BubbleMenuExtension.js +0 -157
|
@@ -0,0 +1,60 @@
|
|
|
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 { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
import { useEffect, useState } from "react";
|
|
12
|
+
import { CheckIcon, TriangleAlertIcon, WandSparklesIcon } from "lucide-react";
|
|
13
|
+
import { canFormatCodeBlockLanguage, formatActiveCodeBlock, getCodeBlockLanguage, } from "../Utils/codeBlockUtils";
|
|
14
|
+
import { CodeBlockBaseButton } from "./CodeBlockBaseButton";
|
|
15
|
+
const CodeBlockFormatButton = ({ className, editor, language, onFormat, size = "xs", }) => {
|
|
16
|
+
const [formatted, setFormatted] = useState(false);
|
|
17
|
+
const [formatFailed, setFormatFailed] = useState(false);
|
|
18
|
+
const codeLanguage = language !== null && language !== void 0 ? language : getCodeBlockLanguage(editor || null);
|
|
19
|
+
const canFormat = canFormatCodeBlockLanguage(codeLanguage);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (!formatted && !formatFailed)
|
|
22
|
+
return;
|
|
23
|
+
const timeout = window.setTimeout(() => {
|
|
24
|
+
setFormatted(false);
|
|
25
|
+
setFormatFailed(false);
|
|
26
|
+
}, 1400);
|
|
27
|
+
return () => window.clearTimeout(timeout);
|
|
28
|
+
}, [formatted, formatFailed]);
|
|
29
|
+
return (_jsx(CodeBlockBaseButton, { className: className, size: size, variant: "outlined", title: !canFormat
|
|
30
|
+
? "Formatting is not supported for this language"
|
|
31
|
+
: formatFailed
|
|
32
|
+
? "Unable to format code"
|
|
33
|
+
: formatted
|
|
34
|
+
? "Formatted"
|
|
35
|
+
: "Format code", "aria-label": !canFormat
|
|
36
|
+
? "Formatting is not supported for this language"
|
|
37
|
+
: formatFailed
|
|
38
|
+
? "Unable to format code"
|
|
39
|
+
: formatted
|
|
40
|
+
? "Formatted"
|
|
41
|
+
: "Format code", disabled: !canFormat || (!onFormat && !(editor === null || editor === void 0 ? void 0 : editor.isActive("codeBlock"))), onClick: (event) => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
|
+
event.preventDefault();
|
|
43
|
+
event.stopPropagation();
|
|
44
|
+
try {
|
|
45
|
+
if (onFormat) {
|
|
46
|
+
yield onFormat();
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
yield formatActiveCodeBlock(editor || null);
|
|
50
|
+
}
|
|
51
|
+
setFormatted(true);
|
|
52
|
+
setFormatFailed(false);
|
|
53
|
+
}
|
|
54
|
+
catch (_a) {
|
|
55
|
+
setFormatted(false);
|
|
56
|
+
setFormatFailed(true);
|
|
57
|
+
}
|
|
58
|
+
}), children: formatted ? (_jsx(CheckIcon, { size: 14 })) : formatFailed ? (_jsx(TriangleAlertIcon, { size: 14 })) : (_jsx(WandSparklesIcon, { size: 14 })) }));
|
|
59
|
+
};
|
|
60
|
+
export default CodeBlockFormatButton;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Editor } from "@tiptap/react";
|
|
2
|
+
type CodeBlockLanguageSelectProps = {
|
|
3
|
+
className?: string;
|
|
4
|
+
editor?: Editor | null;
|
|
5
|
+
language?: string;
|
|
6
|
+
onLanguageChange?: (language: string) => void;
|
|
7
|
+
};
|
|
8
|
+
declare const CodeBlockLanguageSelect: ({ className, editor, language, onLanguageChange, }: CodeBlockLanguageSelectProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export default CodeBlockLanguageSelect;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { CodeXmlIcon } from "lucide-react";
|
|
3
|
+
import { DropDownMenu } from "../../DropDownMenu";
|
|
4
|
+
import { CODE_BLOCK_LANGUAGES, getCodeBlockLanguage, getCodeBlockLanguageOption, setCodeBlockLanguage, } from "../Utils/codeBlockUtils";
|
|
5
|
+
import { useTheme } from "styled-components";
|
|
6
|
+
const CodeBlockLanguageSelect = ({ className, editor, language, onLanguageChange, }) => {
|
|
7
|
+
const theme = useTheme();
|
|
8
|
+
const codeLanguage = language !== null && language !== void 0 ? language : getCodeBlockLanguage(editor || null);
|
|
9
|
+
const selectedLanguage = getCodeBlockLanguageOption(codeLanguage);
|
|
10
|
+
return (_jsx(DropDownMenu, { className: className, data: CODE_BLOCK_LANGUAGES, value: [selectedLanguage], enableSelectedOptionStyling: true, size: "xs", variant: "outlined", disabled: !onLanguageChange && !(editor === null || editor === void 0 ? void 0 : editor.isActive("codeBlock")), onItemSelect: (item) => {
|
|
11
|
+
if (onLanguageChange) {
|
|
12
|
+
onLanguageChange(item.value);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
setCodeBlockLanguage(editor || null, item.value);
|
|
16
|
+
}, buttonProps: {
|
|
17
|
+
title: "Select code language",
|
|
18
|
+
leftSection: _jsx(CodeXmlIcon, { size: 12 }),
|
|
19
|
+
style: {
|
|
20
|
+
padding: "1px 6px",
|
|
21
|
+
backgroundColor: theme.palette.background.paper,
|
|
22
|
+
},
|
|
23
|
+
}, dropDownProps: {
|
|
24
|
+
style: {
|
|
25
|
+
width: 150,
|
|
26
|
+
height: 250,
|
|
27
|
+
},
|
|
28
|
+
}, children: selectedLanguage.label }));
|
|
29
|
+
};
|
|
30
|
+
export default CodeBlockLanguageSelect;
|
|
@@ -0,0 +1,28 @@
|
|
|
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 { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { NodeViewContent, NodeViewWrapper, } from "@tiptap/react";
|
|
12
|
+
import CodeBlockCopyButton from "./CodeBlockCopyButton";
|
|
13
|
+
import CodeBlockWrapButton from "./CodeBlockWrapButton";
|
|
14
|
+
import CodeBlockFormatButton from "./CodeBlockFormatButton";
|
|
15
|
+
import CodeBlockLanguageSelect from "./CodeBlockLanguageSelect";
|
|
16
|
+
import { formatCodeBlockText, replaceCodeBlockContent, } from "../Utils/codeBlockUtils";
|
|
17
|
+
const CodeBlockNodeView = ({ editor, getPos, node, updateAttributes, }) => {
|
|
18
|
+
const language = node.attrs.language;
|
|
19
|
+
const wrap = Boolean(node.attrs.wrap);
|
|
20
|
+
return (_jsxs(NodeViewWrapper, { as: "pre", className: "editor-code-block", "data-language": language || "plaintext", "data-wrap": wrap ? "true" : "false", children: [_jsxs("div", { className: "editor-code-block-actions", contentEditable: false, children: [_jsx(CodeBlockLanguageSelect, { language: language, onLanguageChange: (language) => updateAttributes({ language }) }), _jsx(CodeBlockWrapButton, { active: wrap, onToggle: () => updateAttributes({ wrap: !wrap }) }), _jsx(CodeBlockFormatButton, { className: "editor-code-block-action", language: language, onFormat: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
+
const pos = getPos();
|
|
22
|
+
if (typeof pos !== "number")
|
|
23
|
+
return;
|
|
24
|
+
const formatted = yield formatCodeBlockText(node.textContent, language);
|
|
25
|
+
replaceCodeBlockContent(editor, pos + 1, pos + node.nodeSize - 1, formatted);
|
|
26
|
+
}) }), _jsx(CodeBlockCopyButton, { className: "editor-code-block-action", text: node.textContent })] }), _jsx(NodeViewContent, { as: "code", className: `hljs language-${language || "plaintext"}`, spellCheck: false })] }));
|
|
27
|
+
};
|
|
28
|
+
export default CodeBlockNodeView;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Editor } from "@tiptap/react";
|
|
2
|
+
type CodeBlockWrapButtonProps = {
|
|
3
|
+
className?: string;
|
|
4
|
+
editor?: Editor | null;
|
|
5
|
+
active?: boolean;
|
|
6
|
+
onToggle?: () => void;
|
|
7
|
+
size?: "xs" | "sm";
|
|
8
|
+
};
|
|
9
|
+
declare const CodeBlockWrapButton: ({ className, editor, active, onToggle, size, }: CodeBlockWrapButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export default CodeBlockWrapButton;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { WrapTextIcon } from "lucide-react";
|
|
3
|
+
import { getCodeBlockWrap, toggleCodeBlockWrap } from "../Utils/codeBlockUtils";
|
|
4
|
+
import { CodeBlockBaseButton } from "./CodeBlockBaseButton";
|
|
5
|
+
const CodeBlockWrapButton = ({ className, editor, active, onToggle, size = "xs", }) => {
|
|
6
|
+
const isWrapped = active !== null && active !== void 0 ? active : getCodeBlockWrap(editor || null);
|
|
7
|
+
return (_jsx(CodeBlockBaseButton, { className: className, size: size, variant: "outlined", title: isWrapped ? "Disable code wrapping" : "Enable code wrapping", "aria-label": isWrapped ? "Disable code wrapping" : "Enable code wrapping", selected: isWrapped, disabled: !onToggle && !(editor === null || editor === void 0 ? void 0 : editor.isActive("codeBlock")), onClick: (event) => {
|
|
8
|
+
event.preventDefault();
|
|
9
|
+
event.stopPropagation();
|
|
10
|
+
if (onToggle) {
|
|
11
|
+
onToggle();
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
toggleCodeBlockWrap(editor || null);
|
|
15
|
+
}, children: _jsx(WrapTextIcon, { size: 14 }) }));
|
|
16
|
+
};
|
|
17
|
+
export default CodeBlockWrapButton;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useMemo, useRef, useState, } from "react";
|
|
3
|
+
import styled from "styled-components";
|
|
4
|
+
import { ExternalLinkIcon, SaveIcon, UnlinkIcon } from "lucide-react";
|
|
5
|
+
import Input from "../../Input";
|
|
6
|
+
import { Button } from "../../Button";
|
|
7
|
+
import { getLinkAttributes, normalizeLinkUrl, openLink, } from "../Utils/linkUtils";
|
|
8
|
+
const LinkEditorContent = styled.form `
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
gap: 6px;
|
|
12
|
+
min-width: 280px;
|
|
13
|
+
`;
|
|
14
|
+
const LinkInput = styled(Input) `
|
|
15
|
+
min-width: 190px;
|
|
16
|
+
`;
|
|
17
|
+
const LinkActions = styled.div `
|
|
18
|
+
display: flex;
|
|
19
|
+
align-items: center;
|
|
20
|
+
gap: 4px;
|
|
21
|
+
`;
|
|
22
|
+
const LinkEditorButton = styled(Button) `
|
|
23
|
+
padding: 0 6px;
|
|
24
|
+
`;
|
|
25
|
+
const getInitialHref = (editor) => editor.getAttributes("link").href || "";
|
|
26
|
+
export const LinkEditor = ({ editor, onClose, autoFocus, }) => {
|
|
27
|
+
const inputRef = useRef(null);
|
|
28
|
+
const [href, setHref] = useState(() => getInitialHref(editor));
|
|
29
|
+
const currentHref = getInitialHref(editor);
|
|
30
|
+
const normalizedLink = useMemo(() => normalizeLinkUrl(href), [href]);
|
|
31
|
+
const hasLink = Boolean(currentHref);
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
setHref(getInitialHref(editor));
|
|
34
|
+
}, [editor, editor.state.selection.from, editor.state.selection.to]);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (!autoFocus)
|
|
37
|
+
return;
|
|
38
|
+
window.requestAnimationFrame(() => {
|
|
39
|
+
var _a, _b;
|
|
40
|
+
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
41
|
+
(_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.select();
|
|
42
|
+
});
|
|
43
|
+
}, [autoFocus]);
|
|
44
|
+
const handleSave = () => {
|
|
45
|
+
if (!normalizedLink.isValid)
|
|
46
|
+
return;
|
|
47
|
+
const { from, to, empty } = editor.state.selection;
|
|
48
|
+
const attributes = getLinkAttributes(normalizedLink.href);
|
|
49
|
+
if (empty && hasLink) {
|
|
50
|
+
editor.chain().focus().extendMarkRange("link").setLink(attributes).run();
|
|
51
|
+
}
|
|
52
|
+
else if (empty) {
|
|
53
|
+
editor
|
|
54
|
+
.chain()
|
|
55
|
+
.focus()
|
|
56
|
+
.insertContent({
|
|
57
|
+
type: "text",
|
|
58
|
+
text: normalizedLink.href,
|
|
59
|
+
marks: [
|
|
60
|
+
{
|
|
61
|
+
type: "link",
|
|
62
|
+
attrs: attributes,
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
})
|
|
66
|
+
.run();
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
editor
|
|
70
|
+
.chain()
|
|
71
|
+
.focus()
|
|
72
|
+
.setTextSelection({ from, to })
|
|
73
|
+
.setLink(attributes)
|
|
74
|
+
.run();
|
|
75
|
+
}
|
|
76
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
77
|
+
};
|
|
78
|
+
const handleRemove = () => {
|
|
79
|
+
editor.chain().focus().extendMarkRange("link").unsetLink().run();
|
|
80
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
81
|
+
};
|
|
82
|
+
const handleSubmit = (event) => {
|
|
83
|
+
event.preventDefault();
|
|
84
|
+
handleSave();
|
|
85
|
+
};
|
|
86
|
+
const handleKeyDown = (event) => {
|
|
87
|
+
if (event.key === "Escape") {
|
|
88
|
+
event.preventDefault();
|
|
89
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
return (_jsxs(LinkEditorContent, { onSubmit: handleSubmit, children: [_jsx(LinkInput, { ref: inputRef, "aria-label": "Enter URL", placeholder: "https://example.com/", size: "xs", variant: "outlined", value: href, onChange: (event) => setHref(event.target.value), onKeyDown: handleKeyDown }), _jsxs(LinkActions, { children: [hasLink && (_jsxs(_Fragment, { children: [_jsx(LinkEditorButton, { "aria-label": "Open link", title: "Open link", size: "xs", variant: "subtle", type: "button", onClick: () => openLink(currentHref), children: _jsx(ExternalLinkIcon, { size: 14 }) }), _jsx(LinkEditorButton, { "aria-label": "Remove link", title: "Remove link", size: "xs", variant: "subtle", type: "button", onClick: handleRemove, children: _jsx(UnlinkIcon, { size: 14 }) })] })), _jsx(LinkEditorButton, { "aria-label": "Save link", title: "Save link", size: "xs", variant: "subtle", type: "submit", disabled: !normalizedLink.isValid, children: _jsx(SaveIcon, { size: 14 }) })] })] }));
|
|
93
|
+
};
|
|
94
|
+
export default LinkEditor;
|
|
@@ -5,6 +5,8 @@ export declare enum Controls {
|
|
|
5
5
|
ITALIC = "italic",
|
|
6
6
|
UNDERLINE = "underline",
|
|
7
7
|
STRIKE = "strike",
|
|
8
|
+
CODE = "code",
|
|
9
|
+
CODE_BLOCK = "codeBlock",
|
|
8
10
|
HEADING_1 = "heading_1",
|
|
9
11
|
HEADING_2 = "heading_2",
|
|
10
12
|
HEADING_3 = "heading_3",
|
|
@@ -16,5 +18,7 @@ export declare enum Controls {
|
|
|
16
18
|
TEXT_ALIGN_RIGHT = "textAlignRight",
|
|
17
19
|
TEXT_ALIGN_JUSTIFIED = "textAlignJustified",
|
|
18
20
|
FONT = "font",
|
|
19
|
-
COLOR = "color"
|
|
21
|
+
COLOR = "color",
|
|
22
|
+
HIGHLIGHT = "highlight",
|
|
23
|
+
LINK = "link"
|
|
20
24
|
}
|
|
@@ -6,6 +6,8 @@ export var Controls;
|
|
|
6
6
|
Controls["ITALIC"] = "italic";
|
|
7
7
|
Controls["UNDERLINE"] = "underline";
|
|
8
8
|
Controls["STRIKE"] = "strike";
|
|
9
|
+
Controls["CODE"] = "code";
|
|
10
|
+
Controls["CODE_BLOCK"] = "codeBlock";
|
|
9
11
|
Controls["HEADING_1"] = "heading_1";
|
|
10
12
|
Controls["HEADING_2"] = "heading_2";
|
|
11
13
|
Controls["HEADING_3"] = "heading_3";
|
|
@@ -18,4 +20,6 @@ export var Controls;
|
|
|
18
20
|
Controls["TEXT_ALIGN_JUSTIFIED"] = "textAlignJustified";
|
|
19
21
|
Controls["FONT"] = "font";
|
|
20
22
|
Controls["COLOR"] = "color";
|
|
23
|
+
Controls["HIGHLIGHT"] = "highlight";
|
|
24
|
+
Controls["LINK"] = "link";
|
|
21
25
|
})(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,6 +6,8 @@ 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
13
|
Image = "Image"
|
|
@@ -7,6 +7,8 @@ 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";
|
|
@@ -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, } 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.",
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import { Extension } from "@tiptap/core";
|
|
2
2
|
import { HandleImageUpload } from "../Plugins";
|
|
3
3
|
import { Extensions } from "../Enums";
|
|
4
|
-
|
|
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[];
|