* integrate websocket redis adapter
* use APP_SECRET for jwt signing
* auto migrate database on startup in production
* add updatedAt to update db operations
* create enterprise ee package directory
* fix comment editor focus
* other fixes
This commit is contained in:
Philipinho
2024-06-07 17:29:34 +01:00
parent eef9081aaf
commit 38ef610e5e
36 changed files with 541 additions and 166 deletions

View File

@ -0,0 +1,4 @@
node_modules
.git
.gitignore
dist

View File

@ -1,12 +1,12 @@
import { EditorContent, useEditor } from '@tiptap/react';
import { Placeholder } from '@tiptap/extension-placeholder';
import { Underline } from '@tiptap/extension-underline';
import { Link } from '@tiptap/extension-link';
import { StarterKit } from '@tiptap/starter-kit';
import classes from './comment.module.css';
import { useFocusWithin } from '@mantine/hooks';
import clsx from 'clsx';
import { forwardRef, useImperativeHandle } from 'react';
import { EditorContent, useEditor } from "@tiptap/react";
import { Placeholder } from "@tiptap/extension-placeholder";
import { Underline } from "@tiptap/extension-underline";
import { Link } from "@tiptap/extension-link";
import { StarterKit } from "@tiptap/starter-kit";
import classes from "./comment.module.css";
import { useFocusWithin } from "@mantine/hooks";
import clsx from "clsx";
import { forwardRef, useEffect, useImperativeHandle } from "react";
interface CommentEditorProps {
defaultContent?: any;
@ -16,43 +16,62 @@ interface CommentEditorProps {
autofocus?: boolean;
}
const CommentEditor = forwardRef(({ defaultContent, onUpdate, editable, placeholder, autofocus }: CommentEditorProps,
ref) => {
const { ref: focusRef, focused } = useFocusWithin();
const CommentEditor = forwardRef(
(
{
defaultContent,
onUpdate,
editable,
placeholder,
autofocus,
}: CommentEditorProps,
ref,
) => {
const { ref: focusRef, focused } = useFocusWithin();
const commentEditor = useEditor({
extensions: [
StarterKit.configure({
gapcursor: false,
dropcursor: false,
}),
Placeholder.configure({
placeholder: placeholder || 'Reply...',
}),
Underline,
Link,
],
onUpdate({ editor }) {
if (onUpdate) onUpdate(editor.getJSON());
},
content: defaultContent,
editable,
autofocus: (autofocus && 'end') || false,
});
const commentEditor = useEditor({
extensions: [
StarterKit.configure({
gapcursor: false,
dropcursor: false,
}),
Placeholder.configure({
placeholder: placeholder || "Reply...",
}),
Underline,
Link,
],
onUpdate({ editor }) {
if (onUpdate) onUpdate(editor.getJSON());
},
content: defaultContent,
editable,
autofocus: (autofocus && "end") || false,
});
useImperativeHandle(ref, () => ({
clearContent: () => {
commentEditor.commands.clearContent();
},
}));
useEffect(() => {
setTimeout(() => {
if (autofocus) {
commentEditor?.commands.focus("end");
}
}, 10);
}, [commentEditor, autofocus]);
return (
<div ref={focusRef} className={classes.commentEditor}>
<EditorContent editor={commentEditor}
className={clsx(classes.ProseMirror, { [classes.focused]: focused })}
/>
</div>
);
});
useImperativeHandle(ref, () => ({
clearContent: () => {
commentEditor.commands.clearContent();
},
}));
return (
<div ref={focusRef} className={classes.commentEditor}>
<EditorContent
editor={commentEditor}
className={clsx(classes.ProseMirror, { [classes.focused]: focused })}
/>
</div>
);
},
);
export default CommentEditor;

View File

@ -15,7 +15,7 @@ export function UserProvider({ children }: React.PropsWithChildren) {
if (isLoading) return <></>;
if (!data.user && !data.workspace) return <></>;
if (!data?.user && !data?.workspace) return <></>;
if (error) {
return <>an error occurred</>;