@monolith-forensics/monolith-ui 1.9.1-dev.9 → 1.9.3-dev.1
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/Charts/BarChart/BarChart.js +28 -14
- package/dist/Charts/BarChart/BarChart.styled.d.ts +7 -2
- package/dist/Charts/BarChart/BarChart.styled.js +5 -1
- package/dist/Charts/BarChart/BarChart.types.d.ts +13 -5
- package/dist/Charts/ChartUtils/chartSizing.d.ts +20 -0
- package/dist/Charts/ChartUtils/chartSizing.js +83 -0
- package/dist/Charts/ChartUtils/index.d.ts +1 -0
- package/dist/Charts/ChartUtils/index.js +1 -0
- package/dist/Charts/HeatMap/HeatMap.js +28 -7
- package/dist/Charts/HeatMap/HeatMap.styled.d.ts +6 -2
- package/dist/Charts/HeatMap/HeatMap.styled.js +3 -0
- package/dist/Charts/HeatMap/HeatMap.types.d.ts +7 -1
- package/dist/Charts/LineChart/LineChart.js +34 -15
- package/dist/Charts/LineChart/LineChart.styled.d.ts +7 -2
- package/dist/Charts/LineChart/LineChart.styled.js +5 -1
- package/dist/Charts/LineChart/LineChart.types.d.ts +13 -5
- package/dist/Charts/PieChart/PieChart.js +48 -33
- package/dist/Charts/PieChart/PieChart.styled.d.ts +7 -2
- package/dist/Charts/PieChart/PieChart.styled.js +6 -1
- package/dist/Charts/PieChart/PieChart.types.d.ts +7 -3
- package/dist/DropDownMenu/components/MenuItemList.js +32 -12
- package/dist/DropDownMenu/components/StyledContent.js +1 -1
- package/dist/DropDownMenu/components/StyledInnerItemContainer.js +1 -0
- package/dist/FieldLabel/FieldLabel.js +3 -18
- package/dist/FileViewer/FileViewer.js +32 -8
- package/dist/FileViewer/viewers/ImageViewer.d.ts +1 -0
- package/dist/FileViewer/viewers/ImageViewer.js +36 -15
- package/dist/MonolithUIProvider/MonolithUIProvider.d.ts +23 -0
- package/dist/RichTextEditor/Components/BubbleMenu.d.ts +3 -3
- package/dist/RichTextEditor/Components/BubbleMenu.js +190 -51
- 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/Components/TableTools/TableCornerMenu.d.ts +2 -0
- package/dist/RichTextEditor/Components/TableTools/TableCornerMenu.js +19 -0
- package/dist/RichTextEditor/Components/TableTools/TableInsertControls.d.ts +2 -0
- package/dist/RichTextEditor/Components/TableTools/TableInsertControls.js +24 -0
- package/dist/RichTextEditor/Components/TableTools/TableRails.d.ts +2 -0
- package/dist/RichTextEditor/Components/TableTools/TableRails.js +180 -0
- package/dist/RichTextEditor/Components/TableTools/TableToolMenu.d.ts +5 -0
- package/dist/RichTextEditor/Components/TableTools/TableToolMenu.js +6 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.actions.d.ts +5 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.actions.js +183 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.commands.d.ts +16 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.commands.js +217 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.constants.d.ts +8 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.constants.js +11 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.d.ts +3 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.geometry.d.ts +23 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.geometry.js +75 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.js +3 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.selectors.d.ts +16 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.selectors.js +53 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.styled.d.ts +40 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.styled.js +167 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.types.d.ts +76 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.types.js +1 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.utils.d.ts +4 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.utils.js +4 -0
- package/dist/RichTextEditor/Components/TableTools/TableToolsPopover.d.ts +2 -0
- package/dist/RichTextEditor/Components/TableTools/TableToolsPopover.js +12 -0
- package/dist/RichTextEditor/Components/TableTools/index.d.ts +3 -0
- package/dist/RichTextEditor/Components/TableTools/index.js +2 -0
- package/dist/RichTextEditor/Enums/Controls.d.ts +7 -1
- package/dist/RichTextEditor/Enums/Controls.js +6 -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 +4 -1
- package/dist/RichTextEditor/Enums/SlashCommands.js +3 -0
- package/dist/RichTextEditor/Extensions/SlashCommandList.js +0 -1
- package/dist/RichTextEditor/Extensions/getSlashCommand.d.ts +23 -3
- package/dist/RichTextEditor/Extensions/getSlashCommand.js +53 -7
- package/dist/RichTextEditor/Extensions/getTiptapExtensions.d.ts +15 -2
- package/dist/RichTextEditor/Extensions/getTiptapExtensions.js +159 -24
- package/dist/RichTextEditor/Plugins/ImageActionsPlugin.js +4 -7
- package/dist/RichTextEditor/RichTextEditor.d.ts +9 -4
- package/dist/RichTextEditor/RichTextEditor.js +352 -14
- package/dist/RichTextEditor/Toolbar/Control.d.ts +6 -2
- package/dist/RichTextEditor/Toolbar/Control.js +13 -6
- package/dist/RichTextEditor/Toolbar/Controls.d.ts +6 -0
- package/dist/RichTextEditor/Toolbar/Controls.js +118 -1
- package/dist/RichTextEditor/Toolbar/ControlsGroup.js +17 -6
- package/dist/RichTextEditor/Toolbar/Labels.d.ts +1 -0
- package/dist/RichTextEditor/Toolbar/Labels.js +1 -0
- package/dist/RichTextEditor/Toolbar/Toolbar.d.ts +1 -2
- package/dist/RichTextEditor/Toolbar/Toolbar.js +32 -67
- 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/RichTextEditor/Utils/tableUtils.d.ts +1 -0
- package/dist/RichTextEditor/Utils/tableUtils.js +1 -0
- package/dist/SegmentedControl/SegmentedControl.js +1 -1
- package/dist/SegmentedControl/SegmentedControl.styles.d.ts +1 -0
- package/dist/SegmentedControl/SegmentedControl.styles.js +30 -14
- package/dist/SegmentedControl/SegmentedControl.utils.d.ts +1 -0
- package/dist/SegmentedControl/SegmentedControl.utils.js +5 -2
- package/dist/Table/Table.js +4 -3
- package/dist/Table/TableComponents.d.ts +3 -0
- package/dist/Table/TableComponents.js +47 -0
- package/dist/Table/TableHeader.js +1 -1
- package/dist/Table/TableMenu/TableMenu.js +4 -3
- package/dist/Table/TableProvider.js +39 -0
- package/dist/Table/TableRow.js +1 -1
- package/dist/Table/types.d.ts +6 -0
- package/dist/Utilities/getImageTextContent.d.ts +78 -0
- package/dist/Utilities/getImageTextContent.js +222 -0
- package/dist/core/controlSizes.js +9 -9
- package/dist/theme/variants.js +46 -0
- package/package.json +8 -1
|
@@ -0,0 +1,42 @@
|
|
|
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, CopyIcon } from "lucide-react";
|
|
13
|
+
import { copyCodeBlockText, getActiveCodeBlockText, } from "../Utils/codeBlockUtils";
|
|
14
|
+
import { CodeBlockBaseButton } from "./CodeBlockBaseButton";
|
|
15
|
+
const CodeBlockCopyButton = ({ className, editor, text, size = "xs", }) => {
|
|
16
|
+
const [copied, setCopied] = useState(false);
|
|
17
|
+
const [copyFailed, setCopyFailed] = useState(false);
|
|
18
|
+
const code = text !== null && text !== void 0 ? text : getActiveCodeBlockText(editor || null);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (!copied && !copyFailed)
|
|
21
|
+
return;
|
|
22
|
+
const timeout = window.setTimeout(() => {
|
|
23
|
+
setCopied(false);
|
|
24
|
+
setCopyFailed(false);
|
|
25
|
+
}, 1400);
|
|
26
|
+
return () => window.clearTimeout(timeout);
|
|
27
|
+
}, [copied, copyFailed]);
|
|
28
|
+
return (_jsx(CodeBlockBaseButton, { className: className, size: size, variant: "outlined", title: copyFailed ? "Unable to copy" : copied ? "Copied" : "Copy code", "aria-label": copyFailed ? "Unable to copy code" : copied ? "Copied" : "Copy code", disabled: !code, onClick: (event) => __awaiter(void 0, void 0, void 0, function* () {
|
|
29
|
+
event.preventDefault();
|
|
30
|
+
event.stopPropagation();
|
|
31
|
+
try {
|
|
32
|
+
yield copyCodeBlockText(code);
|
|
33
|
+
setCopied(true);
|
|
34
|
+
setCopyFailed(false);
|
|
35
|
+
}
|
|
36
|
+
catch (_a) {
|
|
37
|
+
setCopied(false);
|
|
38
|
+
setCopyFailed(true);
|
|
39
|
+
}
|
|
40
|
+
}), children: copied ? _jsx(CheckIcon, { size: 14 }) : _jsx(CopyIcon, { size: 14 }) }));
|
|
41
|
+
};
|
|
42
|
+
export default CodeBlockCopyButton;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Editor } from "@tiptap/react";
|
|
2
|
+
type CodeBlockFormatButtonProps = {
|
|
3
|
+
className?: string;
|
|
4
|
+
editor?: Editor | null;
|
|
5
|
+
language?: string;
|
|
6
|
+
onFormat?: () => Promise<void>;
|
|
7
|
+
size?: "xs" | "sm";
|
|
8
|
+
};
|
|
9
|
+
declare const CodeBlockFormatButton: ({ className, editor, language, onFormat, size, }: CodeBlockFormatButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export default CodeBlockFormatButton;
|
|
@@ -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;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { TablePropertiesIcon } from "lucide-react";
|
|
3
|
+
import { Button } from "../../../Button";
|
|
4
|
+
import { Popover } from "../../../Popover";
|
|
5
|
+
import { getTableActionGroups } from "./TableTools.actions";
|
|
6
|
+
import { CornerRoot, MenuDropdown } from "./TableTools.styled";
|
|
7
|
+
import { getCornerRect } from "./TableTools.geometry";
|
|
8
|
+
import { TableToolMenu } from "./TableToolMenu";
|
|
9
|
+
export const TableCornerMenu = ({ editor, target, opened, onOpen, onClose, onAction, onMouseEnter, onMouseLeave, onMouseDown, }) => {
|
|
10
|
+
const rect = getCornerRect(target);
|
|
11
|
+
const groups = getTableActionGroups(editor, target);
|
|
12
|
+
return (_jsx(CornerRoot, { "data-monolith-table-rail": true, "$top": rect.top, "$left": rect.left, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, children: _jsxs(Popover, { opened: opened, onChange: (nextOpened) => {
|
|
13
|
+
if (nextOpened) {
|
|
14
|
+
onOpen();
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
onClose();
|
|
18
|
+
}, position: "bottom-start", width: 245, trapFocus: true, children: [_jsx(Popover.Target, { children: _jsx(Button, { type: "button", size: "xs", variant: "outlined", title: "Table options", "aria-label": "Table options", selected: opened, onMouseDown: onMouseDown, children: _jsx(TablePropertiesIcon, { size: 12 }) }) }), _jsx(MenuDropdown, { children: _jsx(TableToolMenu, { groups: groups, onAction: onAction }) })] }) }));
|
|
19
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { Button } from "../../../Button";
|
|
4
|
+
import Input from "../../../Input";
|
|
5
|
+
import { Switch } from "../../../Switch";
|
|
6
|
+
import { Field, InsertGrid, SwitchRow, TableToolsPanel, TableToolsSection, TableToolsSectionTitle, } from "./TableTools.styled";
|
|
7
|
+
import { DEFAULT_TABLE_OPTIONS, MAX_TABLE_SIZE, MIN_TABLE_SIZE, } from "./TableTools.constants";
|
|
8
|
+
import { runTableCommand } from "./TableTools.commands";
|
|
9
|
+
import { clampTableSize, hasTableExtension } from "./TableTools.selectors";
|
|
10
|
+
export const TableToolsContent = ({ editor, showInsert = false, onInsert, onAction, }) => {
|
|
11
|
+
const [insertOptions, setInsertOptions] = useState(DEFAULT_TABLE_OPTIONS);
|
|
12
|
+
const tableAvailable = hasTableExtension(editor) && (editor === null || editor === void 0 ? void 0 : editor.isEditable);
|
|
13
|
+
const updateInsertOption = (key, value) => {
|
|
14
|
+
setInsertOptions((current) => (Object.assign(Object.assign({}, current), { [key]: typeof value === "number" ? clampTableSize(value) : value })));
|
|
15
|
+
};
|
|
16
|
+
const insertTable = () => {
|
|
17
|
+
if (!tableAvailable)
|
|
18
|
+
return;
|
|
19
|
+
runTableCommand(editor, "insertTable", [insertOptions]);
|
|
20
|
+
onInsert === null || onInsert === void 0 ? void 0 : onInsert();
|
|
21
|
+
onAction === null || onAction === void 0 ? void 0 : onAction();
|
|
22
|
+
};
|
|
23
|
+
return (_jsx(TableToolsPanel, { children: showInsert && (_jsxs(TableToolsSection, { children: [_jsx(TableToolsSectionTitle, { description: "Create and insert a table at the current editor position.", children: "Insert Table" }), _jsxs(TableToolsSection, { style: { gap: "1rem" }, children: [_jsxs(InsertGrid, { children: [_jsxs(Field, { children: ["Rows", _jsx(Input, { type: "number", min: MIN_TABLE_SIZE, max: MAX_TABLE_SIZE, size: "xs", value: insertOptions.rows, onChange: (event) => updateInsertOption("rows", Number(event.target.value)) })] }), _jsxs(Field, { children: ["Columns", _jsx(Input, { type: "number", min: MIN_TABLE_SIZE, max: MAX_TABLE_SIZE, size: "xs", value: insertOptions.cols, onChange: (event) => updateInsertOption("cols", Number(event.target.value)) })] })] }), _jsx(SwitchRow, { children: _jsx(Switch, { size: "xs", label: "Include Header Row", description: "The first row will be formatted as a header.", value: insertOptions.withHeaderRow, onChange: (checked) => updateInsertOption("withHeaderRow", checked) }) }), _jsx(Button, { size: "xs", variant: "outlined", fullWidth: true, disabled: !tableAvailable, onClick: insertTable, children: "Insert Table" })] })] })) }));
|
|
24
|
+
};
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { MoreHorizontalIcon, MoreVerticalIcon } from "lucide-react";
|
|
3
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
4
|
+
import { Button } from "../../../Button";
|
|
5
|
+
import { Popover } from "../../../Popover";
|
|
6
|
+
import { TableCornerMenu } from "./TableCornerMenu";
|
|
7
|
+
import { getColumnActionGroups, getRowActionGroups, } from "./TableTools.actions";
|
|
8
|
+
import { RAIL_HIDE_DELAY } from "./TableTools.constants";
|
|
9
|
+
import { getRailRect, getRailTargetFromCell } from "./TableTools.geometry";
|
|
10
|
+
import { MenuDropdown, RailRoot } from "./TableTools.styled";
|
|
11
|
+
import { getCellsInTableTarget, getCellsInTarget, hasTableExtension, } from "./TableTools.selectors";
|
|
12
|
+
import { TableToolMenu } from "./TableToolMenu";
|
|
13
|
+
export const TableRails = ({ editor }) => {
|
|
14
|
+
const [hoverTarget, setHoverTarget] = useState(null);
|
|
15
|
+
const [lockedTarget, setLockedTarget] = useState(null);
|
|
16
|
+
const [openRail, setOpenRail] = useState(null);
|
|
17
|
+
const hideTimerRef = useRef(null);
|
|
18
|
+
const lastPointerRef = useRef(null);
|
|
19
|
+
const activeTarget = openRail && lockedTarget ? lockedTarget : hoverTarget;
|
|
20
|
+
const clearHideTimer = useCallback(() => {
|
|
21
|
+
if (hideTimerRef.current) {
|
|
22
|
+
clearTimeout(hideTimerRef.current);
|
|
23
|
+
hideTimerRef.current = null;
|
|
24
|
+
}
|
|
25
|
+
}, []);
|
|
26
|
+
const clearTarget = useCallback(() => {
|
|
27
|
+
var _a;
|
|
28
|
+
clearHideTimer();
|
|
29
|
+
if (!openRail) {
|
|
30
|
+
const pointer = lastPointerRef.current;
|
|
31
|
+
const element = pointer
|
|
32
|
+
? document.elementFromPoint(pointer.x, pointer.y)
|
|
33
|
+
: null;
|
|
34
|
+
if ((_a = element === null || element === void 0 ? void 0 : element.closest) === null || _a === void 0 ? void 0 : _a.call(element, "[data-monolith-table-rail]")) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
setHoverTarget(null);
|
|
38
|
+
}
|
|
39
|
+
}, [clearHideTimer, openRail]);
|
|
40
|
+
const scheduleClearTarget = useCallback(() => {
|
|
41
|
+
clearHideTimer();
|
|
42
|
+
hideTimerRef.current = setTimeout(clearTarget, RAIL_HIDE_DELAY);
|
|
43
|
+
}, [clearHideTimer, clearTarget]);
|
|
44
|
+
const refreshTargetFromPoint = useCallback(() => {
|
|
45
|
+
var _a, _b;
|
|
46
|
+
if (!editor || !lastPointerRef.current) {
|
|
47
|
+
setHoverTarget(null);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const element = document.elementFromPoint(lastPointerRef.current.x, lastPointerRef.current.y);
|
|
51
|
+
if ((_a = element === null || element === void 0 ? void 0 : element.closest) === null || _a === void 0 ? void 0 : _a.call(element, "[data-monolith-table-rail]")) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const cell = (_b = element === null || element === void 0 ? void 0 : element.closest) === null || _b === void 0 ? void 0 : _b.call(element, "td, th");
|
|
55
|
+
if (cell instanceof HTMLTableCellElement &&
|
|
56
|
+
editor.view.dom.contains(cell)) {
|
|
57
|
+
const target = getRailTargetFromCell(editor, cell);
|
|
58
|
+
setHoverTarget(target);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
setHoverTarget(null);
|
|
62
|
+
}, [editor]);
|
|
63
|
+
const closeMenu = useCallback(() => {
|
|
64
|
+
setOpenRail(null);
|
|
65
|
+
setLockedTarget(null);
|
|
66
|
+
requestAnimationFrame(refreshTargetFromPoint);
|
|
67
|
+
}, [refreshTargetFromPoint]);
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
if (!editor || !hasTableExtension(editor))
|
|
70
|
+
return;
|
|
71
|
+
const handleMouseMove = (event) => {
|
|
72
|
+
var _a, _b;
|
|
73
|
+
const target = event.target;
|
|
74
|
+
const cell = (_a = target === null || target === void 0 ? void 0 : target.closest) === null || _a === void 0 ? void 0 : _a.call(target, "td, th");
|
|
75
|
+
lastPointerRef.current = { x: event.clientX, y: event.clientY };
|
|
76
|
+
if ((_b = target === null || target === void 0 ? void 0 : target.closest) === null || _b === void 0 ? void 0 : _b.call(target, "[data-monolith-table-rail]")) {
|
|
77
|
+
clearHideTimer();
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (openRail) {
|
|
81
|
+
clearHideTimer();
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (!(cell instanceof HTMLTableCellElement) ||
|
|
85
|
+
!editor.view.dom.contains(cell)) {
|
|
86
|
+
if (!openRail) {
|
|
87
|
+
scheduleClearTarget();
|
|
88
|
+
}
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const railTarget = getRailTargetFromCell(editor, cell);
|
|
92
|
+
if (railTarget) {
|
|
93
|
+
clearHideTimer();
|
|
94
|
+
setHoverTarget(railTarget);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
const handleMouseLeave = () => {
|
|
98
|
+
if (!openRail) {
|
|
99
|
+
scheduleClearTarget();
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
editor.view.dom.addEventListener("mousemove", handleMouseMove);
|
|
103
|
+
editor.view.dom.addEventListener("mouseleave", handleMouseLeave);
|
|
104
|
+
window.addEventListener("mousemove", handleMouseMove);
|
|
105
|
+
window.addEventListener("scroll", refreshTargetFromPoint, true);
|
|
106
|
+
window.addEventListener("resize", refreshTargetFromPoint);
|
|
107
|
+
return () => {
|
|
108
|
+
editor.view.dom.removeEventListener("mousemove", handleMouseMove);
|
|
109
|
+
editor.view.dom.removeEventListener("mouseleave", handleMouseLeave);
|
|
110
|
+
window.removeEventListener("mousemove", handleMouseMove);
|
|
111
|
+
window.removeEventListener("scroll", refreshTargetFromPoint, true);
|
|
112
|
+
window.removeEventListener("resize", refreshTargetFromPoint);
|
|
113
|
+
clearHideTimer();
|
|
114
|
+
};
|
|
115
|
+
}, [
|
|
116
|
+
clearHideTimer,
|
|
117
|
+
editor,
|
|
118
|
+
openRail,
|
|
119
|
+
refreshTargetFromPoint,
|
|
120
|
+
scheduleClearTarget,
|
|
121
|
+
]);
|
|
122
|
+
useEffect(() => {
|
|
123
|
+
const highlighted = Array.from(document.querySelectorAll(".monolith-table-rail-target"));
|
|
124
|
+
highlighted.forEach((element) => element.classList.remove("monolith-table-rail-target"));
|
|
125
|
+
if (!activeTarget || !openRail)
|
|
126
|
+
return;
|
|
127
|
+
const cells = openRail === "table"
|
|
128
|
+
? getCellsInTableTarget(activeTarget)
|
|
129
|
+
: getCellsInTarget(Object.assign(Object.assign({}, activeTarget), { kind: openRail }));
|
|
130
|
+
cells.forEach((cell) => {
|
|
131
|
+
const dom = editor === null || editor === void 0 ? void 0 : editor.view.nodeDOM(activeTarget.tableContext.start + cell.pos);
|
|
132
|
+
if (dom instanceof HTMLElement) {
|
|
133
|
+
dom.classList.add("monolith-table-rail-target");
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
return () => {
|
|
137
|
+
cells.forEach((cell) => {
|
|
138
|
+
const dom = editor === null || editor === void 0 ? void 0 : editor.view.nodeDOM(activeTarget.tableContext.start + cell.pos);
|
|
139
|
+
if (dom instanceof HTMLElement) {
|
|
140
|
+
dom.classList.remove("monolith-table-rail-target");
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
};
|
|
144
|
+
}, [activeTarget, editor, openRail]);
|
|
145
|
+
const keepEditorSelection = (event) => {
|
|
146
|
+
event.preventDefault();
|
|
147
|
+
};
|
|
148
|
+
if (!activeTarget || !(editor === null || editor === void 0 ? void 0 : editor.isEditable))
|
|
149
|
+
return null;
|
|
150
|
+
const keepTargetVisible = () => {
|
|
151
|
+
clearHideTimer();
|
|
152
|
+
};
|
|
153
|
+
const scheduleTargetClearIfClosed = () => {
|
|
154
|
+
if (!openRail) {
|
|
155
|
+
scheduleClearTarget();
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
const renderRail = (kind) => {
|
|
159
|
+
const railTarget = Object.assign(Object.assign({}, activeTarget), { kind });
|
|
160
|
+
const groups = kind === "column"
|
|
161
|
+
? getColumnActionGroups(editor, railTarget)
|
|
162
|
+
: getRowActionGroups(editor, railTarget);
|
|
163
|
+
return (_jsx(RailRoot, { "data-monolith-table-rail": true, "$kind": kind, "$rect": getRailRect(activeTarget, kind), onMouseEnter: keepTargetVisible, onMouseLeave: scheduleTargetClearIfClosed, children: _jsxs(Popover, { opened: openRail === kind, onChange: (opened) => {
|
|
164
|
+
if (opened) {
|
|
165
|
+
clearHideTimer();
|
|
166
|
+
setLockedTarget(railTarget);
|
|
167
|
+
setOpenRail(kind);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
setOpenRail(null);
|
|
171
|
+
setLockedTarget(null);
|
|
172
|
+
refreshTargetFromPoint();
|
|
173
|
+
}, position: kind === "column" ? "bottom" : "right", width: 245, trapFocus: true, children: [_jsx(Popover.Target, { children: _jsx(Button, { type: "button", size: "xs", variant: "outlined", title: kind === "column" ? "Column options" : "Row options", "aria-label": kind === "column" ? "Column options" : "Row options", selected: openRail === kind, onMouseDown: keepEditorSelection, children: kind === "column" ? (_jsx(MoreHorizontalIcon, { size: 14 })) : (_jsx(MoreVerticalIcon, { size: 14 })) }) }), _jsx(MenuDropdown, { children: _jsx(TableToolMenu, { groups: groups, onAction: closeMenu }) })] }) }, kind));
|
|
174
|
+
};
|
|
175
|
+
return (_jsxs(_Fragment, { children: [_jsx(TableCornerMenu, { editor: editor, target: activeTarget, opened: openRail === "table", onOpen: () => {
|
|
176
|
+
clearHideTimer();
|
|
177
|
+
setLockedTarget(activeTarget);
|
|
178
|
+
setOpenRail("table");
|
|
179
|
+
}, onClose: closeMenu, onAction: closeMenu, onMouseEnter: keepTargetVisible, onMouseLeave: scheduleTargetClearIfClosed, onMouseDown: keepEditorSelection }), renderRail("column"), renderRail("row")] }));
|
|
180
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { MenuButton, MenuGroup, MenuPanel } from "./TableTools.styled";
|
|
3
|
+
export const TableToolMenu = ({ groups, onAction, }) => (_jsx(MenuPanel, { children: groups.map((group, index) => (_jsx(MenuGroup, { "$withDivider": index > 0, children: group.actions.map((action) => (_jsx(MenuButton, { "$danger": action.danger, size: "sm", variant: "subtle", leftSection: action.leftSection, disabled: action.disabled, justify: "start", onClick: () => {
|
|
4
|
+
action.onClick();
|
|
5
|
+
onAction();
|
|
6
|
+
}, children: action.label }, action.label))) }, group.label))) }));
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Editor } from "@tiptap/react";
|
|
2
|
+
import type { RailTarget, TableRailTarget, TableToolActionGroup } from "./TableTools.types";
|
|
3
|
+
export declare const getColumnActionGroups: (editor: Editor | null, target: RailTarget) => TableToolActionGroup[];
|
|
4
|
+
export declare const getRowActionGroups: (editor: Editor | null, target: RailTarget) => TableToolActionGroup[];
|
|
5
|
+
export declare const getTableActionGroups: (editor: Editor | null, target: TableRailTarget) => TableToolActionGroup[];
|