@rolder/kit 3.0.0-alpha.17 → 3.0.0-alpha.19
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/ai/index.d.ts +2 -0
- package/dist/ai/index.js +2 -0
- package/dist/ai/ui/conversation/ConversationContext.d.ts +7 -0
- package/dist/ai/ui/conversation/ConversationContext.js +8 -0
- package/dist/ai/ui/conversation/ConversationProvider.d.ts +2 -0
- package/dist/ai/ui/conversation/ConversationProvider.js +14 -0
- package/dist/ai/ui/conversation/Empty.d.ts +1 -0
- package/dist/ai/ui/conversation/Empty.js +21 -0
- package/dist/ai/ui/conversation/File.d.ts +4 -0
- package/dist/ai/ui/conversation/File.js +42 -0
- package/dist/ai/ui/conversation/FileIcon.d.ts +3 -0
- package/dist/ai/ui/conversation/FileIcon.js +43 -0
- package/dist/ai/ui/conversation/Loader.d.ts +2 -0
- package/dist/ai/ui/conversation/Loader.js +12 -0
- package/dist/ai/ui/conversation/Message.d.ts +4 -0
- package/dist/ai/ui/conversation/Message.js +25 -0
- package/dist/ai/ui/conversation/Root.d.ts +2 -0
- package/dist/ai/ui/conversation/Root.js +26 -0
- package/dist/ai/ui/conversation/index.d.ts +13 -0
- package/dist/ai/ui/conversation/index.js +15 -0
- package/dist/ai/ui/conversation/types.d.ts +7 -0
- package/dist/ai/ui/conversation/types.js +0 -0
- package/dist/ai/ui/conversation/useChatMessage.d.ts +2 -0
- package/dist/ai/ui/conversation/useChatMessage.js +12 -0
- package/dist/ai/ui/index.d.ts +2 -0
- package/dist/ai/ui/index.js +2 -0
- package/dist/ai/ui/promptInput/File.d.ts +2 -0
- package/dist/ai/ui/promptInput/File.js +68 -0
- package/dist/ai/ui/promptInput/FileIcon.d.ts +3 -0
- package/dist/ai/ui/promptInput/FileIcon.js +43 -0
- package/dist/ai/ui/promptInput/Footer.d.ts +2 -0
- package/dist/ai/ui/promptInput/Footer.js +8 -0
- package/dist/ai/ui/promptInput/PromptInputContext.d.ts +12 -0
- package/dist/ai/ui/promptInput/PromptInputContext.js +8 -0
- package/dist/ai/ui/promptInput/PromptInputProvider.d.ts +2 -0
- package/dist/ai/ui/promptInput/PromptInputProvider.js +50 -0
- package/dist/ai/ui/promptInput/Root.d.ts +3 -0
- package/dist/ai/ui/promptInput/Root.js +17 -0
- package/dist/ai/ui/promptInput/Submit.d.ts +2 -0
- package/dist/ai/ui/promptInput/Submit.js +21 -0
- package/dist/ai/ui/promptInput/Textarea.d.ts +2 -0
- package/dist/ai/ui/promptInput/Textarea.js +33 -0
- package/dist/ai/ui/promptInput/index.d.ts +8 -0
- package/dist/ai/ui/promptInput/index.js +14 -0
- package/dist/ai/ui/promptInput/types.d.ts +11 -0
- package/dist/ai/ui/promptInput/types.js +0 -0
- package/dist/ai/utils/convertFileUIPartBlobToDataURL.d.ts +5 -0
- package/dist/ai/utils/convertFileUIPartBlobToDataURL.js +21 -0
- package/dist/ai/utils/index.d.ts +2 -0
- package/dist/ai/utils/index.js +2 -0
- package/dist/ai/utils/parseAiMessagePart.d.ts +2 -0
- package/dist/ai/utils/parseAiMessagePart.js +12 -0
- package/dist/app/defaultTheme.d.ts +1 -1
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/useMutation.d.ts +4 -0
- package/dist/hooks/useMutation.js +8 -0
- package/dist/hooks/useMutationWithInvalidate.d.ts +4 -0
- package/dist/hooks/useMutationWithInvalidate.js +16 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/styles.css +74 -0
- package/dist/ui/AnimatedChevron.d.ts +6 -0
- package/dist/ui/AnimatedChevron.js +13 -0
- package/dist/ui/JsonInput.d.ts +2 -0
- package/dist/ui/JsonInput.js +45 -0
- package/dist/ui/RouterLink.d.ts +16 -0
- package/dist/ui/RouterLink.js +36 -0
- package/dist/ui/editor/Content.d.ts +3 -0
- package/dist/ui/editor/Content.js +13 -0
- package/dist/ui/editor/Provider.d.ts +17 -0
- package/dist/ui/editor/Provider.js +80 -0
- package/dist/ui/editor/Root.d.ts +2 -0
- package/dist/ui/editor/Root.js +18 -0
- package/dist/ui/editor/Toolbar.d.ts +5 -0
- package/dist/ui/editor/Toolbar.js +138 -0
- package/dist/ui/editor/index.d.ts +12 -0
- package/dist/ui/editor/index.js +11 -0
- package/dist/ui/editor/types.d.ts +7 -0
- package/dist/ui/editor/types.js +0 -0
- package/dist/ui/error/DefaultError.d.ts +2 -0
- package/dist/ui/error/DefaultError.js +62 -0
- package/dist/ui/error/DefaultNotFound.d.ts +1 -0
- package/dist/ui/error/DefaultNotFound.js +37 -0
- package/dist/ui/error/Forbidden.d.ts +1 -0
- package/dist/ui/error/Forbidden.js +32 -0
- package/dist/ui/error/defaultErrorNotification.d.ts +0 -0
- package/dist/ui/error/defaultErrorNotification.js +0 -0
- package/dist/ui/error/index.d.ts +3 -0
- package/dist/ui/error/index.js +4 -0
- package/dist/ui/form/blurOnError.d.ts +4 -0
- package/dist/ui/form/blurOnError.js +11 -0
- package/dist/ui/form/buttons/CancelButton.d.ts +5 -0
- package/dist/ui/form/buttons/CancelButton.js +22 -0
- package/dist/ui/form/buttons/SubmitButton.d.ts +5 -0
- package/dist/ui/form/buttons/SubmitButton.js +22 -0
- package/dist/ui/form/buttons/SubscribeActionIcon.d.ts +4 -0
- package/dist/ui/form/buttons/SubscribeActionIcon.js +15 -0
- package/dist/ui/form/buttons/SubscribeButton.d.ts +5 -0
- package/dist/ui/form/buttons/SubscribeButton.js +16 -0
- package/dist/ui/form/buttons/index.d.ts +4 -0
- package/dist/ui/form/buttons/index.js +4 -0
- package/dist/ui/form/context.d.ts +83 -0
- package/dist/ui/form/context.js +26 -0
- package/dist/ui/form/fields/JsonField.d.ts +2 -0
- package/dist/ui/form/fields/JsonField.js +13 -0
- package/dist/ui/form/fields/MultiSelectField.d.ts +2 -0
- package/dist/ui/form/fields/MultiSelectField.js +15 -0
- package/dist/ui/form/fields/NumberField.d.ts +2 -0
- package/dist/ui/form/fields/NumberField.js +15 -0
- package/dist/ui/form/fields/PassowrdField.d.ts +2 -0
- package/dist/ui/form/fields/PassowrdField.js +18 -0
- package/dist/ui/form/fields/SelectField.d.ts +2 -0
- package/dist/ui/form/fields/SelectField.js +15 -0
- package/dist/ui/form/fields/SwitchField.d.ts +2 -0
- package/dist/ui/form/fields/SwitchField.js +15 -0
- package/dist/ui/form/fields/TextField.d.ts +2 -0
- package/dist/ui/form/fields/TextField.js +15 -0
- package/dist/ui/form/fields/TextPassowrdField.d.ts +2 -0
- package/dist/ui/form/fields/TextPassowrdField.js +29 -0
- package/dist/ui/form/fields/TextareaField.d.ts +2 -0
- package/dist/ui/form/fields/TextareaField.js +15 -0
- package/dist/ui/form/fields/index.d.ts +9 -0
- package/dist/ui/form/fields/index.js +9 -0
- package/dist/ui/form/fieldsSchema.d.ts +12 -0
- package/dist/ui/form/fieldsSchema.js +13 -0
- package/dist/ui/form/index.d.ts +3 -0
- package/dist/ui/form/index.js +4 -0
- package/dist/ui/hoverPaper/HoverPaper.d.ts +6 -0
- package/dist/ui/hoverPaper/HoverPaper.js +15 -0
- package/dist/ui/hoverPaper/index.d.ts +2 -0
- package/dist/ui/hoverPaper/index.js +3 -0
- package/dist/ui/hoverPaper/usePaperHover.d.ts +4 -0
- package/dist/ui/hoverPaper/usePaperHover.js +9 -0
- package/dist/ui/index.d.ts +9 -0
- package/dist/ui/index.js +9 -0
- package/dist/ui/saveInput/JsonInput.d.ts +6 -0
- package/dist/ui/saveInput/JsonInput.js +34 -0
- package/dist/ui/saveInput/NumberInput.d.ts +6 -0
- package/dist/ui/saveInput/NumberInput.js +27 -0
- package/dist/ui/saveInput/SaveInput.d.ts +36 -0
- package/dist/ui/saveInput/SaveInput.js +15 -0
- package/dist/ui/saveInput/Select.d.ts +6 -0
- package/dist/ui/saveInput/Select.js +27 -0
- package/dist/ui/saveInput/Switch.d.ts +6 -0
- package/dist/ui/saveInput/Switch.js +30 -0
- package/dist/ui/saveInput/TextInput.d.ts +6 -0
- package/dist/ui/saveInput/TextInput.js +26 -0
- package/dist/ui/saveInput/Textarea.d.ts +6 -0
- package/dist/ui/saveInput/Textarea.js +26 -0
- package/dist/ui/saveInput/index.d.ts +1 -0
- package/dist/ui/saveInput/index.js +2 -0
- package/dist/ui/scrollArea/ScrollArea.d.ts +62 -0
- package/dist/ui/scrollArea/ScrollArea.js +30 -0
- package/dist/ui/scrollArea/ScrollAreaButton.d.ts +5 -0
- package/dist/ui/scrollArea/ScrollAreaButton.js +30 -0
- package/dist/ui/scrollArea/ScrollAreaContent.d.ts +6 -0
- package/dist/ui/scrollArea/ScrollAreaContent.js +29 -0
- package/dist/ui/scrollArea/context.d.ts +28 -0
- package/dist/ui/scrollArea/context.js +10 -0
- package/dist/ui/scrollArea/index.d.ts +3 -0
- package/dist/ui/scrollArea/index.js +3 -0
- package/dist/ui/scrollArea/types.d.ts +65 -0
- package/dist/ui/scrollArea/types.js +0 -0
- package/dist/ui/scrollArea/useScrollArea.d.ts +9 -0
- package/dist/ui/scrollArea/useScrollArea.js +146 -0
- package/package.json +1 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { File } from "./File.js";
|
|
2
|
+
import { Footer } from "./Footer.js";
|
|
3
|
+
import { Root } from "./Root.js";
|
|
4
|
+
import { Submit } from "./Submit.js";
|
|
5
|
+
import { Textarea } from "./Textarea.js";
|
|
6
|
+
export * from "./types.js";
|
|
7
|
+
const PromptInput = {
|
|
8
|
+
Root: Root,
|
|
9
|
+
Textarea: Textarea,
|
|
10
|
+
Footer: Footer,
|
|
11
|
+
Submit: Submit,
|
|
12
|
+
File: File
|
|
13
|
+
};
|
|
14
|
+
export { PromptInput };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type Accept = 'text' | 'image' | 'pdf' | 'excel' | 'word';
|
|
2
|
+
export interface PromptInputProps {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
onSubmit: ({ text, file }: {
|
|
5
|
+
text: string;
|
|
6
|
+
file?: File;
|
|
7
|
+
}) => void;
|
|
8
|
+
submiting: boolean;
|
|
9
|
+
uploading: boolean;
|
|
10
|
+
accept?: Accept[];
|
|
11
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
async function blobToDataURL(blobUrl) {
|
|
2
|
+
const response = await fetch(blobUrl);
|
|
3
|
+
const blob = await response.blob();
|
|
4
|
+
return new Promise((resolve, reject)=>{
|
|
5
|
+
const reader = new FileReader();
|
|
6
|
+
reader.onload = ()=>resolve(reader.result);
|
|
7
|
+
reader.onerror = reject;
|
|
8
|
+
reader.readAsDataURL(blob);
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
async function convertFileUIPartBlobToDataURL(file) {
|
|
12
|
+
if (file.url.startsWith('blob:')) {
|
|
13
|
+
const dataUrl = await blobToDataURL(file.url);
|
|
14
|
+
return {
|
|
15
|
+
...file,
|
|
16
|
+
url: dataUrl
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
return file;
|
|
20
|
+
}
|
|
21
|
+
export { convertFileUIPartBlobToDataURL };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { parsePartialJson } from "ai";
|
|
2
|
+
const parseAiMessagePart = async (part)=>{
|
|
3
|
+
if (!part.text.startsWith('{')) return part;
|
|
4
|
+
try {
|
|
5
|
+
const result = await parsePartialJson(part.text);
|
|
6
|
+
return result?.value || part;
|
|
7
|
+
} catch (error) {
|
|
8
|
+
console.error('Error parsing partial JSON:', error);
|
|
9
|
+
return part;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
export { parseAiMessagePart };
|
|
@@ -34,7 +34,7 @@ export declare const defaultTheme: {
|
|
|
34
34
|
headings?: {
|
|
35
35
|
fontFamily?: string | undefined;
|
|
36
36
|
fontWeight?: string | undefined;
|
|
37
|
-
textWrap?: "
|
|
37
|
+
textWrap?: "balance" | "nowrap" | "wrap" | "stable" | "pretty" | undefined;
|
|
38
38
|
sizes?: {
|
|
39
39
|
h1?: {
|
|
40
40
|
fontSize?: string | undefined;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type UseMutationOptions } from '@tanstack/react-query';
|
|
2
|
+
export declare const useMutation: <T, K = void>(fn: ({ data }: {
|
|
3
|
+
data: T;
|
|
4
|
+
}) => Promise<K>, options?: Omit<UseMutationOptions<K, Error, T>, "mutationFn">) => import("@tanstack/react-query").UseMutationResult<K, Error, T, unknown>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type UseMutationOptions } from '@tanstack/react-query';
|
|
2
|
+
export declare const useMutationWithInvalidate: <T, K = void>(fn: ({ data }: {
|
|
3
|
+
data: T;
|
|
4
|
+
}) => Promise<K>, queryKey: string[], options?: Omit<UseMutationOptions<K, Error, T>, "mutationFn" | "onSettled">) => import("@tanstack/react-query").UseMutationResult<K, Error, T, unknown>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
2
|
+
const useMutationWithInvalidate = (fn, queryKey, options)=>{
|
|
3
|
+
const queryClient = useQueryClient();
|
|
4
|
+
return useMutation({
|
|
5
|
+
mutationFn: (data)=>fn({
|
|
6
|
+
data
|
|
7
|
+
}),
|
|
8
|
+
onSettled: async (_, error)=>{
|
|
9
|
+
if (!error && queryKey.length) await queryClient.invalidateQueries({
|
|
10
|
+
queryKey
|
|
11
|
+
});
|
|
12
|
+
},
|
|
13
|
+
...options
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
export { useMutationWithInvalidate };
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/styles.css
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
.rolder-prompt-input-root {
|
|
2
|
+
background-color: light-dark(var(--mantine-color-white), var(--mantine-color-dark-6));
|
|
3
|
+
|
|
4
|
+
&:focus-within {
|
|
5
|
+
border-color: var(--mantine-primary-color-filled);
|
|
6
|
+
border-color: var(--mantine-primary-color-filled);
|
|
7
|
+
outline: none;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.rolder-prompt-input-textarea {
|
|
12
|
+
border: 0;
|
|
13
|
+
border-radius: 8px;
|
|
14
|
+
overflow: hidden;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.rolder-prompt-input-file-action-action {
|
|
18
|
+
color: light-dark(var(--mantine-color-gray-7), var(--mantine-color-dark-1));
|
|
19
|
+
|
|
20
|
+
&[data-disabled] {
|
|
21
|
+
color: light-dark(var(--mantine-color-gray-5), var(--mantine-color-dark-3));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.rolder-editor-root {
|
|
26
|
+
--editor-border-color: light-dark(var(--mantine-color-gray-3), var(--mantine-color-dark-4));
|
|
27
|
+
border: rem(1px) solid var(--editor-border-color);
|
|
28
|
+
border-radius: var(--mantine-radius-md);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.rolder-editor-content {
|
|
32
|
+
border-radius: var(--mantine-radius-md);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.rolder-editor-toolbar {
|
|
36
|
+
border-color: var(--editor-border-color);
|
|
37
|
+
border-top-left-radius: var(--mantine-radius-md);
|
|
38
|
+
border-top-right-radius: var(--mantine-radius-md);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.rolder-hover-paper-root {
|
|
42
|
+
transition: background-color .2s ease-in-out;
|
|
43
|
+
|
|
44
|
+
&:hover {
|
|
45
|
+
background-color: light-dark(var(--mantine-color-gray-0), var(--mantine-color-dark-6));
|
|
46
|
+
cursor: pointer;
|
|
47
|
+
transition: background-color .2s ease-in-out;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
&[data-disabled] {
|
|
51
|
+
background-color: unset;
|
|
52
|
+
cursor: default;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.rolder-router-link-root {
|
|
57
|
+
color: inherit;
|
|
58
|
+
text-decoration: none;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.rolder-scroll-area-viewport {
|
|
62
|
+
border-radius: var(--radius);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.rolder-scroll-area-content {
|
|
66
|
+
width: 100%;
|
|
67
|
+
height: 100%;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.rolder-scroll-area-scrollbar {
|
|
71
|
+
border-top-right-radius: var(--radius);
|
|
72
|
+
border-bottom-right-radius: var(--radius);
|
|
73
|
+
}
|
|
74
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { IconChevronDown } from "@tabler/icons-react";
|
|
3
|
+
const AnimatedChevron = ({ expanded, style, ...props })=>/*#__PURE__*/ jsx(IconChevronDown, {
|
|
4
|
+
strokeWidth: 1.5,
|
|
5
|
+
"data-expanded": expanded,
|
|
6
|
+
style: {
|
|
7
|
+
transition: 'transform 0.2s ease-in-out',
|
|
8
|
+
transform: expanded ? 'rotate(180deg)' : 'rotate(0deg)',
|
|
9
|
+
...style
|
|
10
|
+
},
|
|
11
|
+
...props
|
|
12
|
+
});
|
|
13
|
+
export { AnimatedChevron };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { indentSelection } from "@codemirror/commands";
|
|
3
|
+
import { json, jsonParseLinter } from "@codemirror/lang-json";
|
|
4
|
+
import { linter } from "@codemirror/lint";
|
|
5
|
+
import { keymap } from "@codemirror/view";
|
|
6
|
+
import { vscodeDark, vscodeLight } from "@uiw/codemirror-theme-vscode";
|
|
7
|
+
import react_codemirror from "@uiw/react-codemirror";
|
|
8
|
+
import { getCookie } from "../functions/index.js";
|
|
9
|
+
const formatJson = (view)=>{
|
|
10
|
+
try {
|
|
11
|
+
const text = view.state.doc.toString();
|
|
12
|
+
const parsed = JSON.parse(text);
|
|
13
|
+
const formatted = JSON.stringify(parsed, null, 2);
|
|
14
|
+
view.dispatch({
|
|
15
|
+
changes: {
|
|
16
|
+
from: 0,
|
|
17
|
+
to: view.state.doc.length,
|
|
18
|
+
insert: formatted
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
return true;
|
|
22
|
+
} catch (_) {
|
|
23
|
+
return indentSelection(view);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const extensions = [
|
|
27
|
+
json(),
|
|
28
|
+
linter(jsonParseLinter()),
|
|
29
|
+
keymap.of([
|
|
30
|
+
{
|
|
31
|
+
key: 'Mod-Shift-f',
|
|
32
|
+
run: formatJson
|
|
33
|
+
}
|
|
34
|
+
])
|
|
35
|
+
];
|
|
36
|
+
const JsonInput = (props)=>{
|
|
37
|
+
const colorScheme = getCookie('colorScheme');
|
|
38
|
+
return /*#__PURE__*/ jsx(react_codemirror, {
|
|
39
|
+
height: "280px",
|
|
40
|
+
theme: 'light' === colorScheme ? vscodeLight : vscodeDark,
|
|
41
|
+
extensions: extensions,
|
|
42
|
+
...props
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
export { JsonInput };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ActionIconProps, type AnchorProps, type ButtonProps, type UnstyledButtonProps } from '@mantine/core';
|
|
2
|
+
import { type LinkComponent } from '@tanstack/react-router';
|
|
3
|
+
interface MantineAnchorProps extends Omit<AnchorProps, 'href'> {
|
|
4
|
+
}
|
|
5
|
+
interface MantineButtonProps extends Omit<ButtonProps, 'href'> {
|
|
6
|
+
}
|
|
7
|
+
interface MantineActionIconProps extends Omit<ActionIconProps, 'href'> {
|
|
8
|
+
}
|
|
9
|
+
interface MantineUnstyledButtonProps extends Omit<UnstyledButtonProps, 'href'> {
|
|
10
|
+
}
|
|
11
|
+
export declare const RouterLink: LinkComponent<import("react").ForwardRefExoticComponent<MantineAnchorProps & import("react").RefAttributes<HTMLAnchorElement>>> & {
|
|
12
|
+
Button: LinkComponent<import("react").ForwardRefExoticComponent<MantineButtonProps & import("react").RefAttributes<HTMLButtonElement>>>;
|
|
13
|
+
ActionIcon: LinkComponent<import("react").ForwardRefExoticComponent<MantineActionIconProps & import("react").RefAttributes<HTMLButtonElement>>>;
|
|
14
|
+
UnstyledButton: LinkComponent<import("react").ForwardRefExoticComponent<MantineUnstyledButtonProps & import("react").RefAttributes<HTMLButtonElement>>>;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ActionIcon, Anchor, Button, UnstyledButton } from "@mantine/core";
|
|
3
|
+
import { createLink } from "@tanstack/react-router";
|
|
4
|
+
import { forwardRef } from "react";
|
|
5
|
+
const MantineLinkComponent = /*#__PURE__*/ forwardRef(({ classNames, ...props }, ref)=>/*#__PURE__*/ jsx(Anchor, {
|
|
6
|
+
ref: ref,
|
|
7
|
+
classNames: {
|
|
8
|
+
root: 'rolder-router-link-root',
|
|
9
|
+
...classNames
|
|
10
|
+
},
|
|
11
|
+
c: "inherit",
|
|
12
|
+
underline: "never",
|
|
13
|
+
...props
|
|
14
|
+
}));
|
|
15
|
+
const MantineButtonComponent = /*#__PURE__*/ forwardRef((props, ref)=>/*#__PURE__*/ jsx(Button, {
|
|
16
|
+
ref: ref,
|
|
17
|
+
...props
|
|
18
|
+
}));
|
|
19
|
+
const MantineActionIconComponent = /*#__PURE__*/ forwardRef((props, ref)=>/*#__PURE__*/ jsx(ActionIcon, {
|
|
20
|
+
ref: ref,
|
|
21
|
+
...props
|
|
22
|
+
}));
|
|
23
|
+
const MantineUnstyledButtonComponent = /*#__PURE__*/ forwardRef((props, ref)=>/*#__PURE__*/ jsx(UnstyledButton, {
|
|
24
|
+
ref: ref,
|
|
25
|
+
...props
|
|
26
|
+
}));
|
|
27
|
+
const RouterLinkBase = createLink(MantineLinkComponent);
|
|
28
|
+
const RouterLinkButton = createLink(MantineButtonComponent);
|
|
29
|
+
const RouterLinkActionIcon = createLink(MantineActionIconComponent);
|
|
30
|
+
const RouterLinkUnstyledButton = createLink(MantineUnstyledButtonComponent);
|
|
31
|
+
const RouterLink = Object.assign(RouterLinkBase, {
|
|
32
|
+
Button: RouterLinkButton,
|
|
33
|
+
ActionIcon: RouterLinkActionIcon,
|
|
34
|
+
UnstyledButton: RouterLinkUnstyledButton
|
|
35
|
+
});
|
|
36
|
+
export { RouterLink };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { RichTextEditor } from "@mantine/tiptap";
|
|
3
|
+
import { ScrollArea } from "../scrollArea/index.js";
|
|
4
|
+
const Content = ({ height })=>/*#__PURE__*/ jsxs(ScrollArea, {
|
|
5
|
+
h: height,
|
|
6
|
+
autoScroll: true,
|
|
7
|
+
radius: "md",
|
|
8
|
+
children: [
|
|
9
|
+
/*#__PURE__*/ jsx(RichTextEditor.Content, {}),
|
|
10
|
+
/*#__PURE__*/ jsx(ScrollArea.ScrollButton, {})
|
|
11
|
+
]
|
|
12
|
+
});
|
|
13
|
+
export { Content };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Editor } from '@tiptap/react';
|
|
2
|
+
import type { EditorProps } from './types';
|
|
3
|
+
interface EditorContext {
|
|
4
|
+
editor: Editor | null;
|
|
5
|
+
editable?: boolean;
|
|
6
|
+
setEditable: (value: boolean) => void;
|
|
7
|
+
disabledToolbar: boolean;
|
|
8
|
+
setDisabledToolbar: (value: boolean) => void;
|
|
9
|
+
focused: boolean;
|
|
10
|
+
setFocused: (value: boolean) => void;
|
|
11
|
+
editedByUser: boolean;
|
|
12
|
+
setEditedByUser: (value: boolean) => void;
|
|
13
|
+
}
|
|
14
|
+
declare const EditorContext: import("react").Context<EditorContext | null>;
|
|
15
|
+
export declare const Provider: ({ children, initialContent, initialEditable, initialDisabledToolbar, onChange, }: EditorProps) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export declare const useEditor: () => EditorContext;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Link, getTaskListExtension } from "@mantine/tiptap";
|
|
3
|
+
import extension_highlight from "@tiptap/extension-highlight";
|
|
4
|
+
import extension_placeholder from "@tiptap/extension-placeholder";
|
|
5
|
+
import { TableKit } from "@tiptap/extension-table";
|
|
6
|
+
import extension_task_item from "@tiptap/extension-task-item";
|
|
7
|
+
import extension_task_list from "@tiptap/extension-task-list";
|
|
8
|
+
import extension_text_align from "@tiptap/extension-text-align";
|
|
9
|
+
import { useEditor } from "@tiptap/react";
|
|
10
|
+
import starter_kit from "@tiptap/starter-kit";
|
|
11
|
+
import { createContext, useContext, useEffect, useState } from "react";
|
|
12
|
+
const EditorContext = /*#__PURE__*/ createContext(null);
|
|
13
|
+
const Provider = ({ children, initialContent, initialEditable = true, initialDisabledToolbar, onChange })=>{
|
|
14
|
+
const editor = useEditor({
|
|
15
|
+
shouldRerenderOnTransaction: false,
|
|
16
|
+
immediatelyRender: false,
|
|
17
|
+
extensions: [
|
|
18
|
+
starter_kit.configure({
|
|
19
|
+
link: false
|
|
20
|
+
}),
|
|
21
|
+
extension_placeholder.configure({
|
|
22
|
+
placeholder: 'Документ пуст'
|
|
23
|
+
}),
|
|
24
|
+
Link,
|
|
25
|
+
extension_highlight,
|
|
26
|
+
extension_text_align.configure({
|
|
27
|
+
types: [
|
|
28
|
+
'heading',
|
|
29
|
+
'paragraph'
|
|
30
|
+
]
|
|
31
|
+
}),
|
|
32
|
+
getTaskListExtension(extension_task_list),
|
|
33
|
+
extension_task_item.configure({
|
|
34
|
+
nested: true
|
|
35
|
+
}),
|
|
36
|
+
TableKit
|
|
37
|
+
],
|
|
38
|
+
content: initialContent,
|
|
39
|
+
onUpdate: ({ editor })=>{
|
|
40
|
+
onChange?.(editor.getHTML());
|
|
41
|
+
},
|
|
42
|
+
editable: initialEditable
|
|
43
|
+
});
|
|
44
|
+
const [editable, setEditable] = useState(initialEditable);
|
|
45
|
+
const [disabledToolbar, setDisabledToolbar] = useState(!!initialDisabledToolbar);
|
|
46
|
+
const [editedByUser, setEditedByUser] = useState(true);
|
|
47
|
+
const [focused, setFocused] = useState(false);
|
|
48
|
+
useEffect(()=>{
|
|
49
|
+
editor?.on('focus', ()=>setFocused(true));
|
|
50
|
+
editor?.on('blur', ()=>setFocused(false));
|
|
51
|
+
editor?.on('update', ({ transaction })=>{
|
|
52
|
+
if (transaction.docChanged && focused) setEditedByUser(true);
|
|
53
|
+
if (transaction.docChanged && !focused) setEditedByUser(false);
|
|
54
|
+
});
|
|
55
|
+
}, [
|
|
56
|
+
editor,
|
|
57
|
+
focused
|
|
58
|
+
]);
|
|
59
|
+
const value = {
|
|
60
|
+
editor,
|
|
61
|
+
editable,
|
|
62
|
+
setEditable,
|
|
63
|
+
disabledToolbar,
|
|
64
|
+
setDisabledToolbar,
|
|
65
|
+
editedByUser,
|
|
66
|
+
setEditedByUser,
|
|
67
|
+
focused,
|
|
68
|
+
setFocused
|
|
69
|
+
};
|
|
70
|
+
return /*#__PURE__*/ jsx(EditorContext.Provider, {
|
|
71
|
+
value: value,
|
|
72
|
+
children: children
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
const Provider_useEditor = ()=>{
|
|
76
|
+
const context = useContext(EditorContext);
|
|
77
|
+
if (!context) throw new Error('useEditor must be used within EditorProvider');
|
|
78
|
+
return context;
|
|
79
|
+
};
|
|
80
|
+
export { Provider, Provider_useEditor as useEditor };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { RichTextEditor } from "@mantine/tiptap";
|
|
3
|
+
import { useEditor } from "./Provider.js";
|
|
4
|
+
const Root = ({ children, classNames, ...props })=>{
|
|
5
|
+
const { editor } = useEditor();
|
|
6
|
+
return /*#__PURE__*/ jsx(RichTextEditor, {
|
|
7
|
+
editor: editor,
|
|
8
|
+
classNames: {
|
|
9
|
+
root: 'rolder-editor-root',
|
|
10
|
+
content: 'rolder-editor-content',
|
|
11
|
+
toolbar: 'rolder-editor-toolbar',
|
|
12
|
+
...classNames
|
|
13
|
+
},
|
|
14
|
+
...props,
|
|
15
|
+
children: children
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
export { Root };
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Loader } from "@mantine/core";
|
|
3
|
+
import { RichTextEditor } from "@mantine/tiptap";
|
|
4
|
+
import { IconCheck } from "@tabler/icons-react";
|
|
5
|
+
import { useEditor } from "./Provider.js";
|
|
6
|
+
const Toolbar = ({ saving, children })=>{
|
|
7
|
+
const { editor, disabledToolbar } = useEditor();
|
|
8
|
+
return disabledToolbar ? null : /*#__PURE__*/ jsxs(RichTextEditor.Toolbar, {
|
|
9
|
+
sticky: true,
|
|
10
|
+
children: [
|
|
11
|
+
/*#__PURE__*/ jsxs(RichTextEditor.ControlsGroup, {
|
|
12
|
+
children: [
|
|
13
|
+
/*#__PURE__*/ jsx(RichTextEditor.Bold, {
|
|
14
|
+
disabled: !editor?.isEditable
|
|
15
|
+
}),
|
|
16
|
+
/*#__PURE__*/ jsx(RichTextEditor.Italic, {
|
|
17
|
+
disabled: !editor?.isEditable
|
|
18
|
+
}),
|
|
19
|
+
/*#__PURE__*/ jsx(RichTextEditor.Underline, {
|
|
20
|
+
disabled: !editor?.isEditable
|
|
21
|
+
}),
|
|
22
|
+
/*#__PURE__*/ jsx(RichTextEditor.Strikethrough, {
|
|
23
|
+
disabled: !editor?.isEditable
|
|
24
|
+
}),
|
|
25
|
+
/*#__PURE__*/ jsx(RichTextEditor.ClearFormatting, {
|
|
26
|
+
disabled: !editor?.isEditable
|
|
27
|
+
}),
|
|
28
|
+
/*#__PURE__*/ jsx(RichTextEditor.Highlight, {
|
|
29
|
+
disabled: !editor?.isEditable
|
|
30
|
+
}),
|
|
31
|
+
/*#__PURE__*/ jsx(RichTextEditor.Code, {
|
|
32
|
+
disabled: !editor?.isEditable
|
|
33
|
+
})
|
|
34
|
+
]
|
|
35
|
+
}),
|
|
36
|
+
/*#__PURE__*/ jsxs(RichTextEditor.ControlsGroup, {
|
|
37
|
+
children: [
|
|
38
|
+
/*#__PURE__*/ jsx(RichTextEditor.H1, {
|
|
39
|
+
disabled: !editor?.isEditable
|
|
40
|
+
}),
|
|
41
|
+
/*#__PURE__*/ jsx(RichTextEditor.H2, {
|
|
42
|
+
disabled: !editor?.isEditable
|
|
43
|
+
}),
|
|
44
|
+
/*#__PURE__*/ jsx(RichTextEditor.H3, {
|
|
45
|
+
disabled: !editor?.isEditable
|
|
46
|
+
}),
|
|
47
|
+
/*#__PURE__*/ jsx(RichTextEditor.H4, {
|
|
48
|
+
disabled: !editor?.isEditable
|
|
49
|
+
})
|
|
50
|
+
]
|
|
51
|
+
}),
|
|
52
|
+
/*#__PURE__*/ jsxs(RichTextEditor.ControlsGroup, {
|
|
53
|
+
children: [
|
|
54
|
+
/*#__PURE__*/ jsx(RichTextEditor.Blockquote, {
|
|
55
|
+
disabled: !editor?.isEditable
|
|
56
|
+
}),
|
|
57
|
+
/*#__PURE__*/ jsx(RichTextEditor.Hr, {
|
|
58
|
+
disabled: !editor?.isEditable
|
|
59
|
+
}),
|
|
60
|
+
/*#__PURE__*/ jsx(RichTextEditor.BulletList, {
|
|
61
|
+
disabled: !editor?.isEditable
|
|
62
|
+
}),
|
|
63
|
+
/*#__PURE__*/ jsx(RichTextEditor.OrderedList, {
|
|
64
|
+
disabled: !editor?.isEditable
|
|
65
|
+
})
|
|
66
|
+
]
|
|
67
|
+
}),
|
|
68
|
+
/*#__PURE__*/ jsxs(RichTextEditor.ControlsGroup, {
|
|
69
|
+
children: [
|
|
70
|
+
/*#__PURE__*/ jsx(RichTextEditor.TaskList, {
|
|
71
|
+
disabled: !editor?.isEditable
|
|
72
|
+
}),
|
|
73
|
+
/*#__PURE__*/ jsx(RichTextEditor.TaskListLift, {
|
|
74
|
+
disabled: !editor?.isEditable
|
|
75
|
+
}),
|
|
76
|
+
/*#__PURE__*/ jsx(RichTextEditor.TaskListSink, {
|
|
77
|
+
disabled: !editor?.isEditable
|
|
78
|
+
})
|
|
79
|
+
]
|
|
80
|
+
}),
|
|
81
|
+
/*#__PURE__*/ jsxs(RichTextEditor.ControlsGroup, {
|
|
82
|
+
children: [
|
|
83
|
+
/*#__PURE__*/ jsx(RichTextEditor.Link, {
|
|
84
|
+
disabled: !editor?.isEditable
|
|
85
|
+
}),
|
|
86
|
+
/*#__PURE__*/ jsx(RichTextEditor.Unlink, {
|
|
87
|
+
disabled: !editor?.isEditable
|
|
88
|
+
})
|
|
89
|
+
]
|
|
90
|
+
}),
|
|
91
|
+
/*#__PURE__*/ jsxs(RichTextEditor.ControlsGroup, {
|
|
92
|
+
children: [
|
|
93
|
+
/*#__PURE__*/ jsx(RichTextEditor.AlignLeft, {
|
|
94
|
+
disabled: !editor?.isEditable
|
|
95
|
+
}),
|
|
96
|
+
/*#__PURE__*/ jsx(RichTextEditor.AlignCenter, {
|
|
97
|
+
disabled: !editor?.isEditable
|
|
98
|
+
}),
|
|
99
|
+
/*#__PURE__*/ jsx(RichTextEditor.AlignJustify, {
|
|
100
|
+
disabled: !editor?.isEditable
|
|
101
|
+
}),
|
|
102
|
+
/*#__PURE__*/ jsx(RichTextEditor.AlignRight, {
|
|
103
|
+
disabled: !editor?.isEditable
|
|
104
|
+
})
|
|
105
|
+
]
|
|
106
|
+
}),
|
|
107
|
+
/*#__PURE__*/ jsxs(RichTextEditor.ControlsGroup, {
|
|
108
|
+
children: [
|
|
109
|
+
/*#__PURE__*/ jsx(RichTextEditor.Undo, {
|
|
110
|
+
disabled: !editor?.isEditable
|
|
111
|
+
}),
|
|
112
|
+
/*#__PURE__*/ jsx(RichTextEditor.Redo, {
|
|
113
|
+
disabled: !editor?.isEditable
|
|
114
|
+
})
|
|
115
|
+
]
|
|
116
|
+
}),
|
|
117
|
+
/*#__PURE__*/ jsxs(RichTextEditor.ControlsGroup, {
|
|
118
|
+
ml: "auto",
|
|
119
|
+
children: [
|
|
120
|
+
children,
|
|
121
|
+
/*#__PURE__*/ jsx(RichTextEditor.Control, {
|
|
122
|
+
ml: "10px",
|
|
123
|
+
style: {
|
|
124
|
+
cursor: 'default'
|
|
125
|
+
},
|
|
126
|
+
children: saving ? /*#__PURE__*/ jsx(Loader, {
|
|
127
|
+
size: 14
|
|
128
|
+
}) : /*#__PURE__*/ jsx(IconCheck, {
|
|
129
|
+
stroke: 1.5,
|
|
130
|
+
size: 16
|
|
131
|
+
})
|
|
132
|
+
})
|
|
133
|
+
]
|
|
134
|
+
})
|
|
135
|
+
]
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
export { Toolbar };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const Editor: {
|
|
2
|
+
Root: ({ children, classNames, ...props }: Omit<import("@mantine/tiptap").RichTextEditorProps, "editor">) => import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
Content: ({ height }: {
|
|
4
|
+
height: string;
|
|
5
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
Toolbar: ({ saving, children, }: {
|
|
7
|
+
saving?: boolean;
|
|
8
|
+
children?: import("react").ReactNode;
|
|
9
|
+
}) => import("react/jsx-runtime").JSX.Element | null;
|
|
10
|
+
Provider: ({ children, initialContent, initialEditable, initialDisabledToolbar, onChange, }: import("./types").EditorProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
};
|
|
12
|
+
export { useEditor } from './Provider';
|