@monolith-forensics/monolith-ui 1.3.4 → 1.3.61
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/Divider/Divider.d.ts +6 -0
- package/dist/Divider/Divider.js +25 -0
- package/dist/Divider/index.d.ts +1 -0
- package/dist/Divider/index.js +1 -0
- package/dist/Input/Input.d.ts +3 -0
- package/dist/Input/Input.js +70 -4
- package/dist/ItemTotal/ItemTotal.d.ts +11 -0
- package/dist/ItemTotal/ItemTotal.js +22 -0
- package/dist/ItemTotal/index.d.ts +2 -0
- package/dist/ItemTotal/index.js +1 -0
- package/dist/RichTextEditor/Enums/Controls.d.ts +1 -2
- package/dist/RichTextEditor/Enums/Controls.js +0 -1
- package/dist/RichTextEditor/Enums/SlashCommands.d.ts +0 -1
- package/dist/RichTextEditor/Enums/SlashCommands.js +0 -1
- package/dist/RichTextEditor/Extensions/SlashCommandList.d.ts +4 -6
- package/dist/RichTextEditor/Extensions/SlashCommandList.js +1 -15
- package/dist/RichTextEditor/Extensions/getSlashCommand.d.ts +1 -12
- package/dist/RichTextEditor/Extensions/getSlashCommand.js +1 -10
- package/dist/RichTextEditor/Extensions/getTiptapExtensions.js +19 -7
- package/dist/RichTextEditor/Plugins/UploadImagesPlugin.js +1 -2
- package/dist/RichTextEditor/RichTextEditor.js +3 -101
- package/dist/RichTextEditor/Toolbar/Toolbar.d.ts +2 -2
- package/dist/RichTextEditor/Toolbar/Toolbar.js +13 -92
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2 -0
- package/package.json +17 -18
- package/dist/RichTextEditor/Extensions/CustomTableView.d.ts +0 -22
- package/dist/RichTextEditor/Extensions/CustomTableView.js +0 -137
- package/dist/RichTextEditor/Toolbar/useToolbarState.d.ts +0 -30
- package/dist/RichTextEditor/Toolbar/useToolbarState.js +0 -44
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { forwardRef } from "react";
|
|
14
|
+
import styled from "styled-components";
|
|
15
|
+
const StyledDivider = styled.div `
|
|
16
|
+
height: 1px;
|
|
17
|
+
width: 100%;
|
|
18
|
+
background-color: ${({ theme }) => theme.palette.divider};
|
|
19
|
+
margin: 16px 0;
|
|
20
|
+
`;
|
|
21
|
+
export const Divider = forwardRef((_a, ref) => {
|
|
22
|
+
var { className, style } = _a, other = __rest(_a, ["className", "style"]);
|
|
23
|
+
return (_jsx(StyledDivider, Object.assign({ ref: ref, className: className, style: style }, other)));
|
|
24
|
+
});
|
|
25
|
+
Divider.displayName = "Divider";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Divider";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Divider";
|
package/dist/Input/Input.d.ts
CHANGED
|
@@ -5,6 +5,9 @@ export interface InputProps {
|
|
|
5
5
|
size?: Size;
|
|
6
6
|
variant?: Variant;
|
|
7
7
|
width?: string | number | null | undefined;
|
|
8
|
+
password?: boolean;
|
|
9
|
+
clearable?: boolean;
|
|
10
|
+
onClear?: () => void;
|
|
8
11
|
}
|
|
9
12
|
declare const Input: import("react").ForwardRefExoticComponent<Omit<InputProps, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
|
|
10
13
|
export default Input;
|
package/dist/Input/Input.js
CHANGED
|
@@ -9,9 +9,10 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import styled from "styled-components";
|
|
14
|
-
import { forwardRef } from "react";
|
|
14
|
+
import { forwardRef, useState } from "react";
|
|
15
|
+
import { Eye, EyeOff, X } from "lucide-react";
|
|
15
16
|
const StyledInput = styled.input `
|
|
16
17
|
font-family: ${({ theme }) => theme.typography.fontFamily};
|
|
17
18
|
pointer-events: "all";
|
|
@@ -143,8 +144,73 @@ const StyledInput = styled.input `
|
|
|
143
144
|
opacity: 0.5;
|
|
144
145
|
}
|
|
145
146
|
`;
|
|
147
|
+
const InputContainer = styled.div `
|
|
148
|
+
position: relative;
|
|
149
|
+
display: flex;
|
|
150
|
+
align-items: center;
|
|
151
|
+
width: ${({ width }) => {
|
|
152
|
+
if (typeof width === "undefined")
|
|
153
|
+
return "100%";
|
|
154
|
+
if (width === null)
|
|
155
|
+
return "100%";
|
|
156
|
+
if (typeof width === "string")
|
|
157
|
+
return width;
|
|
158
|
+
if (typeof width === "number")
|
|
159
|
+
return `${width}px`;
|
|
160
|
+
}};
|
|
161
|
+
`;
|
|
162
|
+
const InputButton = styled.button `
|
|
163
|
+
position: absolute;
|
|
164
|
+
right: 8px;
|
|
165
|
+
background: none;
|
|
166
|
+
border: none;
|
|
167
|
+
cursor: pointer;
|
|
168
|
+
display: flex;
|
|
169
|
+
align-items: center;
|
|
170
|
+
justify-content: center;
|
|
171
|
+
color: ${(props) => props.theme.palette.text.secondary};
|
|
172
|
+
padding: 4px;
|
|
173
|
+
border-radius: 4px;
|
|
174
|
+
transition: all 0.2s ease;
|
|
175
|
+
|
|
176
|
+
&:hover {
|
|
177
|
+
color: ${(props) => props.theme.palette.text.primary};
|
|
178
|
+
background-color: ${(props) => props.theme.palette.action.hover};
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
&:focus {
|
|
182
|
+
outline: none;
|
|
183
|
+
box-shadow: 0 0 0 2px ${(props) => props.theme.palette.primary.main}40;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
svg {
|
|
187
|
+
width: 16px;
|
|
188
|
+
height: 16px;
|
|
189
|
+
}
|
|
190
|
+
`;
|
|
146
191
|
const Input = forwardRef((_a, ref) => {
|
|
147
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
148
|
-
|
|
192
|
+
var { className, password = false, clearable = false, onClear, width, value } = _a, props = __rest(_a, ["className", "password", "clearable", "onClear", "width", "value"]);
|
|
193
|
+
const [passwordVisible, setPasswordVisible] = useState(false);
|
|
194
|
+
const hasButton = password || (clearable && value);
|
|
195
|
+
const handlePasswordToggle = (e) => {
|
|
196
|
+
e.preventDefault();
|
|
197
|
+
e.stopPropagation();
|
|
198
|
+
setPasswordVisible((prev) => !prev);
|
|
199
|
+
};
|
|
200
|
+
const handleClear = (e) => {
|
|
201
|
+
e.preventDefault();
|
|
202
|
+
e.stopPropagation();
|
|
203
|
+
onClear === null || onClear === void 0 ? void 0 : onClear();
|
|
204
|
+
};
|
|
205
|
+
return (_jsxs(InputContainer, { className: className, width: width, children: [_jsx(StyledInput, Object.assign({ ref: ref, value: value, width: width, type: password && !passwordVisible ? "password" : "text", style: {
|
|
206
|
+
paddingRight: hasButton ? "36px" : undefined,
|
|
207
|
+
} }, props)), password ? (_jsx(InputButton, { onClick: handlePasswordToggle, onMouseDown: (e) => {
|
|
208
|
+
e.preventDefault();
|
|
209
|
+
e.stopPropagation();
|
|
210
|
+
}, type: "button", children: passwordVisible ? _jsx(Eye, {}) : _jsx(EyeOff, {}) })) : clearable && value ? (_jsx(InputButton, { onClick: handleClear, onMouseDown: (e) => {
|
|
211
|
+
e.preventDefault();
|
|
212
|
+
e.stopPropagation();
|
|
213
|
+
}, type: "button", children: _jsx(X, {}) })) : null] }));
|
|
149
214
|
});
|
|
215
|
+
Input.displayName = "Input";
|
|
150
216
|
export default Input;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface ItemTotalProps {
|
|
3
|
+
className?: string;
|
|
4
|
+
total: number;
|
|
5
|
+
Icon: React.ComponentType<any>;
|
|
6
|
+
style?: React.CSSProperties;
|
|
7
|
+
title?: string;
|
|
8
|
+
}
|
|
9
|
+
declare const ItemTotal: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<ItemTotalProps, never>> & string & Omit<({ className, total, Icon, style, title, }: ItemTotalProps) => import("react/jsx-runtime").JSX.Element, keyof React.Component<any, {}, any>>;
|
|
10
|
+
export default ItemTotal;
|
|
11
|
+
export type { ItemTotalProps };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import styled from "styled-components";
|
|
3
|
+
const ItemTotal = styled(({ className, total, Icon, style = {}, title = "Total Items", }) => {
|
|
4
|
+
return (_jsxs("div", { className: className, title: title, style: style, children: [_jsx(Icon, { size: 14, style: {
|
|
5
|
+
fontSize: 14,
|
|
6
|
+
marginRight: 5,
|
|
7
|
+
} }), _jsx("div", { style: {
|
|
8
|
+
fontSize: 12,
|
|
9
|
+
}, children: total || 0 })] }));
|
|
10
|
+
}) `
|
|
11
|
+
display: flex;
|
|
12
|
+
align-content: center;
|
|
13
|
+
align-items: center;
|
|
14
|
+
margin-left: 10px;
|
|
15
|
+
cursor: pointer;
|
|
16
|
+
color: ${({ theme }) => theme.palette.text.secondary};
|
|
17
|
+
|
|
18
|
+
&:hover {
|
|
19
|
+
color: ${({ theme }) => theme.palette.text.primary};
|
|
20
|
+
}
|
|
21
|
+
`;
|
|
22
|
+
export default ItemTotal;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./ItemTotal";
|
|
@@ -7,7 +7,6 @@ export var SlashCommands;
|
|
|
7
7
|
SlashCommands["Heading4"] = "Heading 4";
|
|
8
8
|
SlashCommands["BulletList"] = "Bullet List";
|
|
9
9
|
SlashCommands["NumberedList"] = "Numbered List";
|
|
10
|
-
SlashCommands["Table"] = "Table";
|
|
11
10
|
SlashCommands["CurrentDate"] = "Current Date";
|
|
12
11
|
SlashCommands["CurrentTimestamp"] = "Current Timestamp";
|
|
13
12
|
SlashCommands["Image"] = "Image";
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { SuggestionItem } from "./getSlashCommand";
|
|
2
|
-
import { Editor, Range } from "@tiptap/react";
|
|
3
1
|
interface SlashCommandListProps {
|
|
4
2
|
className?: string;
|
|
5
|
-
items:
|
|
6
|
-
command: (item:
|
|
7
|
-
editor:
|
|
8
|
-
range:
|
|
3
|
+
items: any[];
|
|
4
|
+
command: (item: any) => void;
|
|
5
|
+
editor: any;
|
|
6
|
+
range: any;
|
|
9
7
|
}
|
|
10
8
|
declare const SlashCommandList: ({ items, command, editor, range, }: SlashCommandListProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
11
9
|
export default SlashCommandList;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useEffect, useLayoutEffect, useRef, useState, } from "react";
|
|
3
3
|
import styled from "styled-components";
|
|
4
|
-
import { useToolbarState } from "../Toolbar/useToolbarState";
|
|
5
|
-
import { SlashCommands } from "../Enums";
|
|
6
4
|
const SlashCommandListContainer = styled.div `
|
|
7
5
|
display: flex;
|
|
8
6
|
flex-direction: column;
|
|
@@ -40,11 +38,6 @@ const SlashCommandItem = styled.button `
|
|
|
40
38
|
&.selected {
|
|
41
39
|
background-color: ${({ theme }) => theme.palette.action.hover};
|
|
42
40
|
}
|
|
43
|
-
|
|
44
|
-
&:disabled {
|
|
45
|
-
opacity: 0.5;
|
|
46
|
-
cursor: not-allowed;
|
|
47
|
-
}
|
|
48
41
|
`;
|
|
49
42
|
const CommandIcon = styled.div `
|
|
50
43
|
display: flex;
|
|
@@ -85,7 +78,6 @@ const updateScrollView = (container, item) => {
|
|
|
85
78
|
};
|
|
86
79
|
const SlashCommandList = ({ items, command, editor, range, }) => {
|
|
87
80
|
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
88
|
-
const { isInsideTable } = useToolbarState(editor);
|
|
89
81
|
const selectItem = useCallback((index) => {
|
|
90
82
|
const item = items[index];
|
|
91
83
|
if (item) {
|
|
@@ -113,9 +105,6 @@ const SlashCommandList = ({ items, command, editor, range, }) => {
|
|
|
113
105
|
return true;
|
|
114
106
|
}
|
|
115
107
|
if (e.key === "Enter") {
|
|
116
|
-
if (items[selectedIndex].disabled) {
|
|
117
|
-
return true;
|
|
118
|
-
}
|
|
119
108
|
selectItem(selectedIndex);
|
|
120
109
|
return true;
|
|
121
110
|
}
|
|
@@ -138,10 +127,7 @@ const SlashCommandList = ({ items, command, editor, range, }) => {
|
|
|
138
127
|
updateScrollView(container, item);
|
|
139
128
|
}, [selectedIndex]);
|
|
140
129
|
return items.length > 0 ? (_jsx(SlashCommandListContainer, { ref: commandListContainer, className: "slash-command", children: items.map((item, index) => {
|
|
141
|
-
|
|
142
|
-
item.disabled = true;
|
|
143
|
-
}
|
|
144
|
-
return (_jsxs(SlashCommandItem, { className: `slash-command-item ${index === selectedIndex ? "selected" : ""}`, onClick: () => selectItem(index), disabled: item.disabled, children: [_jsx(CommandIcon, { className: "item-icon", children: _jsx(item.icon, { size: 18 }) }), _jsxs("div", { children: [_jsx(CommandTitle, { className: "item-title", children: item.title }), _jsx(CommandDescription, { className: "item-description", children: item.description })] })] }, index));
|
|
130
|
+
return (_jsxs(SlashCommandItem, { className: `slash-command-item ${index === selectedIndex ? "selected" : ""}`, onClick: () => selectItem(index), children: [_jsx(CommandIcon, { className: "item-icon", children: _jsx(item.icon, { size: 18 }) }), _jsxs("div", { children: [_jsx(CommandTitle, { className: "item-title", children: item.title }), _jsx(CommandDescription, { className: "item-description", children: item.description })] })] }, index));
|
|
145
131
|
}) })) : null;
|
|
146
132
|
};
|
|
147
133
|
export default SlashCommandList;
|
|
@@ -1,18 +1,7 @@
|
|
|
1
|
-
import { Extension
|
|
1
|
+
import { Extension } from "@tiptap/core";
|
|
2
2
|
import { HandleImageUpload } from "../Plugins/UploadImagesPlugin.js";
|
|
3
3
|
import { SlashCommands } from "../Enums";
|
|
4
4
|
type CommandName = keyof typeof SlashCommands;
|
|
5
|
-
export type SuggestionItem = {
|
|
6
|
-
title: CommandName;
|
|
7
|
-
description: string;
|
|
8
|
-
searchTerms?: string[];
|
|
9
|
-
icon: any;
|
|
10
|
-
disabled?: boolean;
|
|
11
|
-
command: (props: {
|
|
12
|
-
editor: Editor;
|
|
13
|
-
range: any;
|
|
14
|
-
}) => void;
|
|
15
|
-
};
|
|
16
5
|
interface SlashCommandOptions {
|
|
17
6
|
handleImageUpload?: HandleImageUpload;
|
|
18
7
|
commands?: CommandName[];
|
|
@@ -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, Image as ImageIcon, Calendar, ClockIcon,
|
|
14
|
+
import { Heading1, Heading2, Heading3, Heading4, List, ListOrdered, Text, Image as ImageIcon, Calendar, ClockIcon, } 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";
|
|
@@ -115,15 +115,6 @@ const getCommandItems = (values, options) => {
|
|
|
115
115
|
editor.chain().focus().deleteRange(range).toggleOrderedList().run();
|
|
116
116
|
},
|
|
117
117
|
},
|
|
118
|
-
{
|
|
119
|
-
title: SlashCommands.Table,
|
|
120
|
-
description: "Create a table.",
|
|
121
|
-
searchTerms: ["table"],
|
|
122
|
-
icon: Table,
|
|
123
|
-
command: ({ editor, range }) => {
|
|
124
|
-
editor.chain().focus().deleteRange(range).insertTable().run();
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
118
|
{
|
|
128
119
|
title: SlashCommands.CurrentDate,
|
|
129
120
|
description: "Insert the current date.",
|
|
@@ -3,10 +3,13 @@ import StarterKit from "@tiptap/starter-kit";
|
|
|
3
3
|
import HorizontalRule from "@tiptap/extension-horizontal-rule";
|
|
4
4
|
import Underline from "@tiptap/extension-underline";
|
|
5
5
|
import TextAlign from "@tiptap/extension-text-align";
|
|
6
|
-
import
|
|
6
|
+
import Table from "@tiptap/extension-table";
|
|
7
|
+
import TableCell from "@tiptap/extension-table-cell";
|
|
8
|
+
import TableHeader from "@tiptap/extension-table-header";
|
|
9
|
+
import TableRow from "@tiptap/extension-table-row";
|
|
7
10
|
import Placeholder from "@tiptap/extension-placeholder";
|
|
8
11
|
import { Color } from "@tiptap/extension-color";
|
|
9
|
-
import
|
|
12
|
+
import TextStyle from "@tiptap/extension-text-style";
|
|
10
13
|
import { InputRule, Extension } from "@tiptap/core";
|
|
11
14
|
import Focus from "@tiptap/extension-focus";
|
|
12
15
|
import { UploadImagesPlugin } from "../Plugins";
|
|
@@ -118,13 +121,22 @@ const getTipTapExtensions = ({ extensions = [], slashCommands = [], bubbleMenuOp
|
|
|
118
121
|
},
|
|
119
122
|
{
|
|
120
123
|
name: Extensions.Table,
|
|
121
|
-
extension:
|
|
122
|
-
|
|
123
|
-
resizable: true,
|
|
124
|
-
// View: CustomTableView,
|
|
125
|
-
},
|
|
124
|
+
extension: Table.configure({
|
|
125
|
+
resizable: true,
|
|
126
126
|
}),
|
|
127
127
|
},
|
|
128
|
+
{
|
|
129
|
+
name: Extensions.TableRow,
|
|
130
|
+
extension: TableRow,
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
name: Extensions.TableHeader,
|
|
134
|
+
extension: TableHeader,
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
name: Extensions.TableCell,
|
|
138
|
+
extension: TableCell,
|
|
139
|
+
},
|
|
128
140
|
{
|
|
129
141
|
name: Extensions.Image,
|
|
130
142
|
extension: CustomImage.configure({
|
|
@@ -107,8 +107,7 @@ export const UploadImagesPlugin = () => new Plugin({
|
|
|
107
107
|
},
|
|
108
108
|
props: {
|
|
109
109
|
decorations(state) {
|
|
110
|
-
|
|
111
|
-
return decos !== null && decos !== void 0 ? decos : null;
|
|
110
|
+
return this.getState(state);
|
|
112
111
|
},
|
|
113
112
|
},
|
|
114
113
|
});
|
|
@@ -59,119 +59,23 @@ const StyledContent = styled.div `
|
|
|
59
59
|
word-break: break-word;
|
|
60
60
|
text-rendering: optimizeLegibility;
|
|
61
61
|
|
|
62
|
-
.tableWrapper {
|
|
63
|
-
position: relative;
|
|
64
|
-
|
|
65
|
-
.tiptap-table-menu-container {
|
|
66
|
-
position: absolute;
|
|
67
|
-
left: -20px;
|
|
68
|
-
top: 0;
|
|
69
|
-
|
|
70
|
-
display: flex;
|
|
71
|
-
flex-direction: column;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
.tiptap-table-menu {
|
|
75
|
-
display: none;
|
|
76
|
-
flex-direction: column;
|
|
77
|
-
align-items: center;
|
|
78
|
-
justify-content: center;
|
|
79
|
-
background-color: ${({ theme }) => theme.palette.background.default};
|
|
80
|
-
border-radius: 4px;
|
|
81
|
-
border: 1px solid ${({ theme }) => theme.palette.divider};
|
|
82
|
-
padding: 10px;
|
|
83
|
-
width: 100px;
|
|
84
|
-
height: 100px;
|
|
85
|
-
|
|
86
|
-
z-index: 1000;
|
|
87
|
-
position: absolute;
|
|
88
|
-
top: 30px;
|
|
89
|
-
left: 0px;
|
|
90
|
-
|
|
91
|
-
&.show {
|
|
92
|
-
display: flex;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
.tiptap-table-menu-btn {
|
|
97
|
-
display: none;
|
|
98
|
-
align-items: center;
|
|
99
|
-
justify-content: center;
|
|
100
|
-
flex-direction: column;
|
|
101
|
-
cursor: pointer;
|
|
102
|
-
|
|
103
|
-
padding: 3px;
|
|
104
|
-
border-radius: 4px;
|
|
105
|
-
color: ${({ theme }) => theme.palette.text.secondary};
|
|
106
|
-
font-weight: 500;
|
|
107
|
-
font-size: 1.25rem;
|
|
108
|
-
|
|
109
|
-
&:hover {
|
|
110
|
-
background-color: ${({ theme }) => theme.palette.action.hover};
|
|
111
|
-
color: ${({ theme }) => theme.palette.text.primary};
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
.tiptap-table-addcol-btn {
|
|
116
|
-
display: none;
|
|
117
|
-
align-items: center;
|
|
118
|
-
justify-content: center;
|
|
119
|
-
flex-direction: column;
|
|
120
|
-
cursor: pointer;
|
|
121
|
-
position: absolute;
|
|
122
|
-
right: -20px;
|
|
123
|
-
top: 0;
|
|
124
|
-
width: 20px;
|
|
125
|
-
height: 100%;
|
|
126
|
-
background-color: transparent;
|
|
127
|
-
font-weight: 500;
|
|
128
|
-
border-radius: 0 4px 4px 0;
|
|
129
|
-
border-top: 1px solid ${({ theme }) => theme.palette.action.hover};
|
|
130
|
-
border-bottom: 1px solid ${({ theme }) => theme.palette.action.hover};
|
|
131
|
-
border-right: 1px solid ${({ theme }) => theme.palette.action.hover};
|
|
132
|
-
color: ${({ theme }) => theme.palette.text.secondary};
|
|
133
|
-
|
|
134
|
-
&:hover {
|
|
135
|
-
background-color: ${({ theme }) => theme.palette.action.hover};
|
|
136
|
-
color: ${({ theme }) => theme.palette.text.primary};
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
62
|
table {
|
|
142
|
-
position: relative;
|
|
143
63
|
border-collapse: collapse;
|
|
144
64
|
width: 100%;
|
|
145
|
-
table-layout: fixed;
|
|
146
|
-
|
|
147
|
-
tr.is-empty::before {
|
|
148
|
-
display: none;
|
|
149
|
-
}
|
|
150
65
|
|
|
151
66
|
th,
|
|
152
67
|
td {
|
|
153
68
|
border: 1px solid ${({ theme }) => theme.palette.divider};
|
|
154
|
-
padding:
|
|
69
|
+
padding: 0.5rem;
|
|
155
70
|
min-width: 100px;
|
|
156
|
-
white-space: normal;
|
|
157
|
-
word-break: break-word;
|
|
158
|
-
overflow-wrap: anywhere;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
th.is-empty p::before {
|
|
162
|
-
display: none;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
td.is-empty p::before {
|
|
166
|
-
display: none;
|
|
167
71
|
}
|
|
168
72
|
|
|
169
73
|
// for table header
|
|
170
74
|
th {
|
|
171
|
-
background-color: ${({ theme }) => theme.palette.background.alt};
|
|
172
75
|
border: 1px solid ${({ theme }) => theme.palette.divider};
|
|
173
|
-
padding:
|
|
76
|
+
padding: 0.5rem;
|
|
174
77
|
min-width: 100px;
|
|
78
|
+
background-color: ${({ theme }) => theme.palette.action.hover};
|
|
175
79
|
font-weight: 500;
|
|
176
80
|
}
|
|
177
81
|
}
|
|
@@ -235,7 +139,6 @@ const StyledContent = styled.div `
|
|
|
235
139
|
color: #888;
|
|
236
140
|
pointer-events: none;
|
|
237
141
|
height: 0;
|
|
238
|
-
white-space: nowrap;
|
|
239
142
|
}
|
|
240
143
|
.ProseMirror .is-empty::before {
|
|
241
144
|
content: attr(data-placeholder);
|
|
@@ -243,7 +146,6 @@ const StyledContent = styled.div `
|
|
|
243
146
|
color: #888;
|
|
244
147
|
pointer-events: none;
|
|
245
148
|
height: 0;
|
|
246
|
-
white-space: nowrap;
|
|
247
149
|
}
|
|
248
150
|
|
|
249
151
|
.ProseMirror .monolith-image.uploading {
|
|
@@ -18,7 +18,7 @@ export type ToolbarOptions = {
|
|
|
18
18
|
};
|
|
19
19
|
export type ToolbarProps = {
|
|
20
20
|
className?: string;
|
|
21
|
-
editor: Editor;
|
|
21
|
+
editor: Editor | null;
|
|
22
22
|
toolbarOptions?: ToolbarOptions;
|
|
23
23
|
};
|
|
24
|
-
export declare const Toolbar:
|
|
24
|
+
export declare const Toolbar: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<ToolbarProps, never>> & string & Omit<({ className, editor, toolbarOptions }: ToolbarProps) => import("react/jsx-runtime").JSX.Element, keyof import("react").Component<any, {}, any>>;
|
|
@@ -10,27 +10,14 @@ import RichTextEditorContext from "../Contexts/RichTextEditorContext";
|
|
|
10
10
|
import { Button } from "../../Button";
|
|
11
11
|
import TextColors from "../Enums/TextColors";
|
|
12
12
|
import { SquircleIcon } from "lucide-react";
|
|
13
|
-
|
|
14
|
-
const ToolbarContainer = styled.div `
|
|
15
|
-
display: flex;
|
|
16
|
-
flex-direction: row;
|
|
17
|
-
flex-wrap: wrap;
|
|
18
|
-
justify-content: center;
|
|
19
|
-
align-items: center;
|
|
20
|
-
gap: 5px;
|
|
21
|
-
margin-bottom: 10px;
|
|
22
|
-
border-radius: 5px 5px 0 0;
|
|
23
|
-
border: 1px solid transparent;
|
|
24
|
-
`;
|
|
25
|
-
export const Toolbar = ({ className, editor, toolbarOptions, }) => {
|
|
13
|
+
export const Toolbar = styled(({ className, editor, toolbarOptions }) => {
|
|
26
14
|
var _a;
|
|
27
15
|
const theme = useTheme();
|
|
28
16
|
const { controls } = toolbarOptions || {};
|
|
29
17
|
const customItems = controls === null || controls === void 0 ? void 0 : controls.filter((control) => typeof control !== "string" &&
|
|
30
18
|
(control.type === "menu" || control.type === "button"));
|
|
31
19
|
const { font, setFont } = useContext(RichTextEditorContext);
|
|
32
|
-
|
|
33
|
-
return (_jsxs(ToolbarContainer, { className: className, children: [(_a = customItems === null || customItems === void 0 ? void 0 : customItems.map) === null || _a === void 0 ? void 0 : _a.call(customItems, (item, index) => {
|
|
20
|
+
return (_jsxs("div", { className: className, children: [(_a = customItems === null || customItems === void 0 ? void 0 : customItems.map) === null || _a === void 0 ? void 0 : _a.call(customItems, (item, index) => {
|
|
34
21
|
var _a, _b;
|
|
35
22
|
if (item.type === "button") {
|
|
36
23
|
return (_jsx(Button, Object.assign({}, item.options, { children: (_a = item === null || item === void 0 ? void 0 : item.options) === null || _a === void 0 ? void 0 : _a.label }), index));
|
|
@@ -73,80 +60,14 @@ export const Toolbar = ({ className, editor, toolbarOptions, }) => {
|
|
|
73
60
|
borderRadius: "3px",
|
|
74
61
|
} }), item.label] })), size: "xxs", variant: "outlined", arrow: true, buttonProps: {
|
|
75
62
|
title: "Select Color",
|
|
76
|
-
}, children: "Color" })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
value: "insert-column-before",
|
|
88
|
-
onClick: () => {
|
|
89
|
-
editor === null || editor === void 0 ? void 0 : editor.chain().focus().addColumnBefore().run();
|
|
90
|
-
},
|
|
91
|
-
disabled: !isInsideTable,
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
label: "Insert Column After",
|
|
95
|
-
value: "insert-column-after",
|
|
96
|
-
onClick: () => {
|
|
97
|
-
editor === null || editor === void 0 ? void 0 : editor.chain().focus().addColumnAfter().run();
|
|
98
|
-
},
|
|
99
|
-
disabled: !isInsideTable,
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
label: "Delete Column",
|
|
103
|
-
value: "delete-column",
|
|
104
|
-
onClick: () => {
|
|
105
|
-
editor === null || editor === void 0 ? void 0 : editor.chain().focus().deleteColumn().run();
|
|
106
|
-
},
|
|
107
|
-
disabled: !isInsideTable,
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
label: "Insert Row Before",
|
|
111
|
-
value: "insert-row-before",
|
|
112
|
-
onClick: () => {
|
|
113
|
-
editor === null || editor === void 0 ? void 0 : editor.chain().focus().addRowBefore().run();
|
|
114
|
-
},
|
|
115
|
-
disabled: !isInsideTable,
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
label: "Insert Row After",
|
|
119
|
-
value: "insert-row-after",
|
|
120
|
-
onClick: () => {
|
|
121
|
-
editor === null || editor === void 0 ? void 0 : editor.chain().focus().addRowAfter().run();
|
|
122
|
-
},
|
|
123
|
-
disabled: !isInsideTable,
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
label: "Delete Row",
|
|
127
|
-
value: "delete-row",
|
|
128
|
-
onClick: () => {
|
|
129
|
-
editor === null || editor === void 0 ? void 0 : editor.chain().focus().deleteRow().run();
|
|
130
|
-
},
|
|
131
|
-
disabled: !isInsideTable,
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
label: "Toggle Header Row",
|
|
135
|
-
value: "toggle-header-row",
|
|
136
|
-
onClick: () => {
|
|
137
|
-
editor === null || editor === void 0 ? void 0 : editor.chain().focus().toggleHeaderRow().run();
|
|
138
|
-
},
|
|
139
|
-
disabled: !isInsideTable,
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
label: "Delete Table",
|
|
143
|
-
value: "delete-table",
|
|
144
|
-
onClick: () => {
|
|
145
|
-
editor === null || editor === void 0 ? void 0 : editor.chain().focus().deleteTable().run();
|
|
146
|
-
},
|
|
147
|
-
disabled: !isInsideTable,
|
|
148
|
-
},
|
|
149
|
-
], size: "xxs", variant: "outlined", arrow: true, buttonProps: {
|
|
150
|
-
title: "Select Color",
|
|
151
|
-
}, children: "Table" })), _jsxs(ControlsGroup, { children: [(controls === null || controls === void 0 ? void 0 : controls.includes(Controls.BOLD)) && _jsx(BoldControl, { editor: editor }), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.ITALIC)) && (_jsx(ItalicControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.UNDERLINE)) && (_jsx(UnderlineControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.STRIKE)) && (_jsx(StrikeThroughControl, { editor: editor }))] }), _jsxs(ControlsGroup, { children: [(controls === null || controls === void 0 ? void 0 : controls.includes(Controls.HEADING_1)) && (_jsx(Heading1Control, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.HEADING_2)) && (_jsx(Heading2Control, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.HEADING_3)) && (_jsx(Heading3Control, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.HEADING_4)) && (_jsx(Heading4Control, { editor: editor }))] }), _jsxs(ControlsGroup, { children: [(controls === null || controls === void 0 ? void 0 : controls.includes(Controls.BULLET_LIST)) && (_jsx(BulletListControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.ORDERED_LIST)) && (_jsx(OrderedListControl, { editor: editor }))] }), _jsxs(ControlsGroup, { children: [(controls === null || controls === void 0 ? void 0 : controls.includes(Controls.TEXT_ALIGN_LEFT)) && (_jsx(AlignLeftControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.TEXT_ALIGN_CENTER)) && (_jsx(AlignCenterControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.TEXT_ALIGN_RIGHT)) && (_jsx(AlignRightControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.TEXT_ALIGN_JUSTIFIED)) && (_jsx(AlignJustifiedControl, { editor: editor }))] })] }));
|
|
152
|
-
};
|
|
63
|
+
}, children: "Color" })), _jsxs(ControlsGroup, { children: [(controls === null || controls === void 0 ? void 0 : controls.includes(Controls.BOLD)) && _jsx(BoldControl, { editor: editor }), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.ITALIC)) && (_jsx(ItalicControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.UNDERLINE)) && (_jsx(UnderlineControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.STRIKE)) && (_jsx(StrikeThroughControl, { editor: editor }))] }), _jsxs(ControlsGroup, { children: [(controls === null || controls === void 0 ? void 0 : controls.includes(Controls.HEADING_1)) && (_jsx(Heading1Control, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.HEADING_2)) && (_jsx(Heading2Control, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.HEADING_3)) && (_jsx(Heading3Control, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.HEADING_4)) && (_jsx(Heading4Control, { editor: editor }))] }), _jsxs(ControlsGroup, { children: [(controls === null || controls === void 0 ? void 0 : controls.includes(Controls.BULLET_LIST)) && (_jsx(BulletListControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.ORDERED_LIST)) && (_jsx(OrderedListControl, { editor: editor }))] }), _jsxs(ControlsGroup, { children: [(controls === null || controls === void 0 ? void 0 : controls.includes(Controls.TEXT_ALIGN_LEFT)) && (_jsx(AlignLeftControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.TEXT_ALIGN_CENTER)) && (_jsx(AlignCenterControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.TEXT_ALIGN_RIGHT)) && (_jsx(AlignRightControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.TEXT_ALIGN_JUSTIFIED)) && (_jsx(AlignJustifiedControl, { editor: editor }))] })] }));
|
|
64
|
+
}) `
|
|
65
|
+
display: flex;
|
|
66
|
+
flex-direction: row;
|
|
67
|
+
justify-content: center;
|
|
68
|
+
align-items: center;
|
|
69
|
+
gap: 5px;
|
|
70
|
+
margin-bottom: 10px;
|
|
71
|
+
border-radius: 5px 5px 0 0;
|
|
72
|
+
border: 1px solid transparent;
|
|
73
|
+
`;
|
package/dist/index.d.ts
CHANGED
|
@@ -28,6 +28,8 @@ export { default as Tooltip } from "./Tooltip";
|
|
|
28
28
|
export { default as Pill } from "./Pill";
|
|
29
29
|
export { default as Calendar } from "./Calendar";
|
|
30
30
|
export { default as Typography } from "./Typography";
|
|
31
|
+
export { default as ItemTotal } from "./ItemTotal";
|
|
32
|
+
export type { ItemTotalProps } from "./ItemTotal";
|
|
31
33
|
export * from "./RichTextEditor";
|
|
32
34
|
export { default as Loader } from "./Loader";
|
|
33
35
|
export type { LoaderProps } from "./Loader";
|
|
@@ -38,3 +40,4 @@ export * from "./FileViewer";
|
|
|
38
40
|
export * from "./Table";
|
|
39
41
|
export type { ColumnProps, TableProps } from "./Table";
|
|
40
42
|
export * from "./Tabs";
|
|
43
|
+
export * from "./Divider";
|
package/dist/index.js
CHANGED
|
@@ -21,6 +21,7 @@ export { default as Tooltip } from "./Tooltip";
|
|
|
21
21
|
export { default as Pill } from "./Pill";
|
|
22
22
|
export { default as Calendar } from "./Calendar";
|
|
23
23
|
export { default as Typography } from "./Typography";
|
|
24
|
+
export { default as ItemTotal } from "./ItemTotal";
|
|
24
25
|
export * from "./RichTextEditor";
|
|
25
26
|
export { default as Loader } from "./Loader";
|
|
26
27
|
export * from "./QueryFilter";
|
|
@@ -29,3 +30,4 @@ export * from "./MonolithUIProvider";
|
|
|
29
30
|
export * from "./FileViewer";
|
|
30
31
|
export * from "./Table";
|
|
31
32
|
export * from "./Tabs";
|
|
33
|
+
export * from "./Divider";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monolith-forensics/monolith-ui",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.61",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"author": "Matt Danner (Monolith Forensics LLC)",
|
|
@@ -33,23 +33,22 @@
|
|
|
33
33
|
"@radix-ui/react-switch": "^1.0.7",
|
|
34
34
|
"@radix-ui/react-tooltip": "^1.0.7",
|
|
35
35
|
"@tabler/icons-react": "^3.11.0",
|
|
36
|
-
"@tiptap/extension-color": "^
|
|
37
|
-
"@tiptap/extension-focus": "^
|
|
38
|
-
"@tiptap/extension-horizontal-rule": "^
|
|
39
|
-
"@tiptap/extension-image": "^
|
|
40
|
-
"@tiptap/extension-placeholder": "^
|
|
41
|
-
"@tiptap/extension-table": "^
|
|
42
|
-
"@tiptap/extension-table-cell": "^
|
|
43
|
-
"@tiptap/extension-table-header": "^
|
|
44
|
-
"@tiptap/extension-table-row": "^
|
|
45
|
-
"@tiptap/extension-text-align": "^
|
|
46
|
-
"@tiptap/extension-text-style": "^
|
|
47
|
-
"@tiptap/extension-underline": "^
|
|
48
|
-
"@tiptap/
|
|
49
|
-
"@tiptap/
|
|
50
|
-
"@tiptap/
|
|
51
|
-
"@tiptap/
|
|
52
|
-
"@tiptap/suggestion": "^3.0.9",
|
|
36
|
+
"@tiptap/extension-color": "^2.9.1",
|
|
37
|
+
"@tiptap/extension-focus": "^2.5.9",
|
|
38
|
+
"@tiptap/extension-horizontal-rule": "^2.5.9",
|
|
39
|
+
"@tiptap/extension-image": "^2.5.9",
|
|
40
|
+
"@tiptap/extension-placeholder": "^2.5.9",
|
|
41
|
+
"@tiptap/extension-table": "^2.5.8",
|
|
42
|
+
"@tiptap/extension-table-cell": "^2.5.8",
|
|
43
|
+
"@tiptap/extension-table-header": "^2.5.8",
|
|
44
|
+
"@tiptap/extension-table-row": "^2.5.8",
|
|
45
|
+
"@tiptap/extension-text-align": "^2.5.8",
|
|
46
|
+
"@tiptap/extension-text-style": "^2.9.1",
|
|
47
|
+
"@tiptap/extension-underline": "^2.5.8",
|
|
48
|
+
"@tiptap/pm": "^2.5.8",
|
|
49
|
+
"@tiptap/react": "^2.5.8",
|
|
50
|
+
"@tiptap/starter-kit": "^2.5.8",
|
|
51
|
+
"@tiptap/suggestion": "^2.5.9",
|
|
53
52
|
"@uiw/codemirror-theme-vscode": "^4.23.6",
|
|
54
53
|
"@uiw/react-codemirror": "^4.23.6",
|
|
55
54
|
"deepmerge": "^4.3.1",
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { TableView as DefaultTableView } from "@tiptap/extension-table";
|
|
2
|
-
import { EditorView } from "@tiptap/pm/view";
|
|
3
|
-
import type { Node as PMNode } from "prosemirror-model";
|
|
4
|
-
export declare class CustomTableView extends DefaultTableView {
|
|
5
|
-
private addColumnBtn;
|
|
6
|
-
private tableMenuBtn;
|
|
7
|
-
private tableMenu;
|
|
8
|
-
private isOpen;
|
|
9
|
-
private selectionHandler;
|
|
10
|
-
private clickOutsideHandler;
|
|
11
|
-
private view;
|
|
12
|
-
constructor(node: PMNode, cellMinWidth: number, view: EditorView);
|
|
13
|
-
update(node: PMNode): boolean;
|
|
14
|
-
destroy(): void;
|
|
15
|
-
private renderTableMenu;
|
|
16
|
-
private renderAddColumnBtn;
|
|
17
|
-
private updateColumnButtonVisibility;
|
|
18
|
-
private updateTableMenuVisibility;
|
|
19
|
-
private toggleMenu;
|
|
20
|
-
private openMenu;
|
|
21
|
-
private closeMenu;
|
|
22
|
-
}
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { TableView as DefaultTableView } from "@tiptap/extension-table";
|
|
2
|
-
import { addColumnAfter, } from "prosemirror-tables";
|
|
3
|
-
/** Walk up from $pos to find the nearest ancestor table. */
|
|
4
|
-
function findTable(state) {
|
|
5
|
-
const { $from } = state.selection;
|
|
6
|
-
return findAncestorOfType($from, "table");
|
|
7
|
-
}
|
|
8
|
-
/** Generic ancestor finder by node.type.name */
|
|
9
|
-
function findAncestorOfType($pos, typeName) {
|
|
10
|
-
var _a;
|
|
11
|
-
for (let depth = $pos.depth; depth >= 0; depth--) {
|
|
12
|
-
const node = $pos.node(depth);
|
|
13
|
-
if (((_a = node.type) === null || _a === void 0 ? void 0 : _a.name) === typeName) {
|
|
14
|
-
const pos = depth === 0 ? 0 : $pos.before(depth);
|
|
15
|
-
return { node, pos };
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
export class CustomTableView extends DefaultTableView {
|
|
21
|
-
// NOTE: signature has NO getPos
|
|
22
|
-
constructor(node, cellMinWidth, view) {
|
|
23
|
-
// keep default resizing/DOM from the base TableView
|
|
24
|
-
super(node, cellMinWidth);
|
|
25
|
-
this.isOpen = true;
|
|
26
|
-
this.view = view;
|
|
27
|
-
this.addColumnBtn = null;
|
|
28
|
-
this.tableMenuBtn = null;
|
|
29
|
-
this.tableMenu = null;
|
|
30
|
-
this.selectionHandler = null;
|
|
31
|
-
this.clickOutsideHandler = () => { };
|
|
32
|
-
// this.renderTableMenu();
|
|
33
|
-
this.renderAddColumnBtn();
|
|
34
|
-
}
|
|
35
|
-
update(node) {
|
|
36
|
-
const ok = super.update(node);
|
|
37
|
-
if (ok)
|
|
38
|
-
this.updateColumnButtonVisibility();
|
|
39
|
-
// if (ok) this.updateTableMenuVisibility();
|
|
40
|
-
return ok;
|
|
41
|
-
}
|
|
42
|
-
destroy() {
|
|
43
|
-
if (this.selectionHandler) {
|
|
44
|
-
this.view.dom.ownerDocument.removeEventListener("selectionchange", this.selectionHandler);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
renderTableMenu() {
|
|
48
|
-
var _a;
|
|
49
|
-
const tableMenuContainer = document.createElement("div");
|
|
50
|
-
tableMenuContainer.className = "tiptap-table-menu-container";
|
|
51
|
-
this.tableMenuBtn = document.createElement("div");
|
|
52
|
-
this.tableMenuBtn.textContent = "⋮";
|
|
53
|
-
this.tableMenuBtn.title = "Table menu";
|
|
54
|
-
this.tableMenuBtn.className = "tiptap-table-menu-btn";
|
|
55
|
-
tableMenuContainer.appendChild(this.tableMenuBtn);
|
|
56
|
-
this.tableMenu = document.createElement("div");
|
|
57
|
-
this.tableMenu.className = "tiptap-table-menu";
|
|
58
|
-
this.tableMenu.style.display = this.isOpen ? "block" : "none";
|
|
59
|
-
tableMenuContainer.appendChild(this.tableMenu);
|
|
60
|
-
this.tableMenuBtn.addEventListener("mousedown", (e) => e.preventDefault());
|
|
61
|
-
this.tableMenuBtn.addEventListener("click", () => {
|
|
62
|
-
this.toggleMenu();
|
|
63
|
-
});
|
|
64
|
-
(_a = this.table.parentElement) === null || _a === void 0 ? void 0 : _a.appendChild(tableMenuContainer);
|
|
65
|
-
// Visibility & lifecycle
|
|
66
|
-
this.selectionHandler = () => this.updateTableMenuVisibility();
|
|
67
|
-
this.view.dom.ownerDocument.addEventListener("selectionchange", this.selectionHandler);
|
|
68
|
-
this.updateTableMenuVisibility();
|
|
69
|
-
this.clickOutsideHandler = (e) => {
|
|
70
|
-
var _a;
|
|
71
|
-
if (!this.isOpen)
|
|
72
|
-
return;
|
|
73
|
-
const target = e.target;
|
|
74
|
-
if (!((_a = this.tableMenu) === null || _a === void 0 ? void 0 : _a.contains(target)) && target !== this.tableMenuBtn) {
|
|
75
|
-
this.closeMenu();
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
this.view.dom.ownerDocument.addEventListener("mousedown", this.clickOutsideHandler);
|
|
79
|
-
}
|
|
80
|
-
renderAddColumnBtn() {
|
|
81
|
-
var _a;
|
|
82
|
-
// Create the left-side button
|
|
83
|
-
this.addColumnBtn = document.createElement("div");
|
|
84
|
-
this.addColumnBtn.textContent = "+";
|
|
85
|
-
this.addColumnBtn.title = "Add column";
|
|
86
|
-
this.addColumnBtn.className = "tiptap-table-addcol-btn";
|
|
87
|
-
this.addColumnBtn.addEventListener("mousedown", (e) => e.preventDefault());
|
|
88
|
-
this.addColumnBtn.addEventListener("click", () => {
|
|
89
|
-
addColumnAfter(this.view.state, this.view.dispatch);
|
|
90
|
-
this.view.focus();
|
|
91
|
-
});
|
|
92
|
-
// The default TableView sets up a wrapper div at this.dom
|
|
93
|
-
if (getComputedStyle(this.dom).position === "static") {
|
|
94
|
-
this.dom.style.position = "relative";
|
|
95
|
-
}
|
|
96
|
-
(_a = this.table.parentElement) === null || _a === void 0 ? void 0 : _a.appendChild(this.addColumnBtn);
|
|
97
|
-
// Toggle visibility on selection changes
|
|
98
|
-
const doc = this.view.dom.ownerDocument;
|
|
99
|
-
this.selectionHandler = () => this.updateColumnButtonVisibility();
|
|
100
|
-
doc.addEventListener("selectionchange", this.selectionHandler);
|
|
101
|
-
this.updateColumnButtonVisibility();
|
|
102
|
-
}
|
|
103
|
-
updateColumnButtonVisibility() {
|
|
104
|
-
const found = findTable(this.view.state);
|
|
105
|
-
const isInsideThisTable = !!found && found.node === this.node;
|
|
106
|
-
if (this.addColumnBtn) {
|
|
107
|
-
this.addColumnBtn.style.display = isInsideThisTable ? "flex" : "none";
|
|
108
|
-
}
|
|
109
|
-
if (this.tableMenuBtn) {
|
|
110
|
-
this.tableMenuBtn.style.display = isInsideThisTable ? "flex" : "none";
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
updateTableMenuVisibility() {
|
|
114
|
-
const found = findTable(this.view.state);
|
|
115
|
-
const inside = !!found && found.node === this.node;
|
|
116
|
-
if (!inside)
|
|
117
|
-
this.closeMenu();
|
|
118
|
-
// Optional: update position relative to table (e.g., snap left/top)
|
|
119
|
-
// You can also use the selected cell rect for context-sensitive placement.
|
|
120
|
-
}
|
|
121
|
-
toggleMenu() {
|
|
122
|
-
this.isOpen ? this.closeMenu() : this.openMenu();
|
|
123
|
-
}
|
|
124
|
-
openMenu() {
|
|
125
|
-
this.isOpen = true;
|
|
126
|
-
if (this.tableMenu) {
|
|
127
|
-
this.tableMenu.style.display = "block";
|
|
128
|
-
this.tableMenu.focus();
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
closeMenu() {
|
|
132
|
-
this.isOpen = false;
|
|
133
|
-
if (this.tableMenu) {
|
|
134
|
-
this.tableMenu.style.display = "none";
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Editor } from "@tiptap/react";
|
|
2
|
-
export declare const useToolbarState: (editor: Editor) => {
|
|
3
|
-
isBold: boolean;
|
|
4
|
-
canBold: boolean;
|
|
5
|
-
isItalic: boolean;
|
|
6
|
-
canItalic: boolean;
|
|
7
|
-
isStrike: boolean;
|
|
8
|
-
canStrike: boolean;
|
|
9
|
-
isCode: boolean;
|
|
10
|
-
canCode: boolean;
|
|
11
|
-
canClearMarks: boolean;
|
|
12
|
-
isParagraph: boolean;
|
|
13
|
-
isHeading1: boolean;
|
|
14
|
-
isHeading2: boolean;
|
|
15
|
-
isHeading3: boolean;
|
|
16
|
-
isHeading4: boolean;
|
|
17
|
-
isHeading5: boolean;
|
|
18
|
-
isHeading6: boolean;
|
|
19
|
-
isBulletList: boolean;
|
|
20
|
-
isOrderedList: boolean;
|
|
21
|
-
isCodeBlock: boolean;
|
|
22
|
-
isBlockquote: boolean;
|
|
23
|
-
canUndo: boolean;
|
|
24
|
-
canRedo: boolean;
|
|
25
|
-
isTable: boolean;
|
|
26
|
-
isTableRow: boolean;
|
|
27
|
-
isTableCell: boolean;
|
|
28
|
-
isTableHeader: boolean;
|
|
29
|
-
isInsideTable: boolean;
|
|
30
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { useEditorState } from "@tiptap/react";
|
|
2
|
-
export const useToolbarState = (editor) => {
|
|
3
|
-
const editorState = useEditorState({
|
|
4
|
-
editor,
|
|
5
|
-
selector: (ctx) => {
|
|
6
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1;
|
|
7
|
-
const isTable = (_a = ctx.editor.isActive("table")) !== null && _a !== void 0 ? _a : false;
|
|
8
|
-
const isTableRow = (_b = ctx.editor.isActive("tableRow")) !== null && _b !== void 0 ? _b : false;
|
|
9
|
-
const isTableCell = (_c = ctx.editor.isActive("tableCell")) !== null && _c !== void 0 ? _c : false;
|
|
10
|
-
const isTableHeader = (_d = ctx.editor.isActive("tableHeader")) !== null && _d !== void 0 ? _d : false;
|
|
11
|
-
const isInsideTable = isTable || isTableRow || isTableCell || isTableHeader;
|
|
12
|
-
return {
|
|
13
|
-
isBold: (_e = ctx.editor.isActive("bold")) !== null && _e !== void 0 ? _e : false,
|
|
14
|
-
canBold: (_f = ctx.editor.can().chain().toggleBold().run()) !== null && _f !== void 0 ? _f : false,
|
|
15
|
-
isItalic: (_g = ctx.editor.isActive("italic")) !== null && _g !== void 0 ? _g : false,
|
|
16
|
-
canItalic: (_h = ctx.editor.can().chain().toggleItalic().run()) !== null && _h !== void 0 ? _h : false,
|
|
17
|
-
isStrike: (_j = ctx.editor.isActive("strike")) !== null && _j !== void 0 ? _j : false,
|
|
18
|
-
canStrike: (_k = ctx.editor.can().chain().toggleStrike().run()) !== null && _k !== void 0 ? _k : false,
|
|
19
|
-
isCode: (_l = ctx.editor.isActive("code")) !== null && _l !== void 0 ? _l : false,
|
|
20
|
-
canCode: (_m = ctx.editor.can().chain().toggleCode().run()) !== null && _m !== void 0 ? _m : false,
|
|
21
|
-
canClearMarks: (_o = ctx.editor.can().chain().unsetAllMarks().run()) !== null && _o !== void 0 ? _o : false,
|
|
22
|
-
isParagraph: (_p = ctx.editor.isActive("paragraph")) !== null && _p !== void 0 ? _p : false,
|
|
23
|
-
isHeading1: (_q = ctx.editor.isActive("heading", { level: 1 })) !== null && _q !== void 0 ? _q : false,
|
|
24
|
-
isHeading2: (_r = ctx.editor.isActive("heading", { level: 2 })) !== null && _r !== void 0 ? _r : false,
|
|
25
|
-
isHeading3: (_s = ctx.editor.isActive("heading", { level: 3 })) !== null && _s !== void 0 ? _s : false,
|
|
26
|
-
isHeading4: (_t = ctx.editor.isActive("heading", { level: 4 })) !== null && _t !== void 0 ? _t : false,
|
|
27
|
-
isHeading5: (_u = ctx.editor.isActive("heading", { level: 5 })) !== null && _u !== void 0 ? _u : false,
|
|
28
|
-
isHeading6: (_v = ctx.editor.isActive("heading", { level: 6 })) !== null && _v !== void 0 ? _v : false,
|
|
29
|
-
isBulletList: (_w = ctx.editor.isActive("bulletList")) !== null && _w !== void 0 ? _w : false,
|
|
30
|
-
isOrderedList: (_x = ctx.editor.isActive("orderedList")) !== null && _x !== void 0 ? _x : false,
|
|
31
|
-
isCodeBlock: (_y = ctx.editor.isActive("codeBlock")) !== null && _y !== void 0 ? _y : false,
|
|
32
|
-
isBlockquote: (_z = ctx.editor.isActive("blockquote")) !== null && _z !== void 0 ? _z : false,
|
|
33
|
-
canUndo: (_0 = ctx.editor.can().chain().undo().run()) !== null && _0 !== void 0 ? _0 : false,
|
|
34
|
-
canRedo: (_1 = ctx.editor.can().chain().redo().run()) !== null && _1 !== void 0 ? _1 : false,
|
|
35
|
-
isTable,
|
|
36
|
-
isTableRow,
|
|
37
|
-
isTableCell,
|
|
38
|
-
isTableHeader,
|
|
39
|
-
isInsideTable,
|
|
40
|
-
};
|
|
41
|
-
},
|
|
42
|
-
});
|
|
43
|
-
return editorState;
|
|
44
|
-
};
|