diff --git a/packages/editor/lite-text-editor/src/ui/extensions/enter-key-extension.tsx b/packages/editor/lite-text-editor/src/ui/extensions/enter-key-extension.tsx index 3d19703ec..04c4a1fbe 100644 --- a/packages/editor/lite-text-editor/src/ui/extensions/enter-key-extension.tsx +++ b/packages/editor/lite-text-editor/src/ui/extensions/enter-key-extension.tsx @@ -1,12 +1,14 @@ import { Extension } from '@tiptap/core'; -export const EnterKeyExtension = Extension.create({ +export const EnterKeyExtension = (onEnterKeyPress?: () => void) => Extension.create({ name: 'enterKey', addKeyboardShortcuts() { return { 'Enter': () => { - console.log('Submit comment'); + if (onEnterKeyPress) { + onEnterKeyPress(); + } return true; }, } diff --git a/packages/editor/lite-text-editor/src/ui/extensions/index.tsx b/packages/editor/lite-text-editor/src/ui/extensions/index.tsx index 764188302..358f15294 100644 --- a/packages/editor/lite-text-editor/src/ui/extensions/index.tsx +++ b/packages/editor/lite-text-editor/src/ui/extensions/index.tsx @@ -1,5 +1,5 @@ import { EnterKeyExtension } from "./enter-key-extension"; -export const LiteTextEditorExtensions = () => [ - EnterKeyExtension, +export const LiteTextEditorExtensions = (onEnterKeyPress?: () => void) => [ + EnterKeyExtension(onEnterKeyPress), ]; diff --git a/packages/editor/lite-text-editor/src/ui/index.tsx b/packages/editor/lite-text-editor/src/ui/index.tsx index dfdee1505..34edaf878 100644 --- a/packages/editor/lite-text-editor/src/ui/index.tsx +++ b/packages/editor/lite-text-editor/src/ui/index.tsx @@ -30,7 +30,8 @@ interface ILiteTextEditor { key: string; label: "Private" | "Public"; }[] - } + }; + onEnterKeyPress?: (e?: any) => void; } interface LiteTextEditorProps extends ILiteTextEditor { @@ -57,6 +58,7 @@ const LiteTextEditor = ({ customClassName, forwardedRef, commentAccessSpecifier, + onEnterKeyPress }: LiteTextEditorProps) => { const editor = useEditor({ onChange, @@ -68,7 +70,7 @@ const LiteTextEditor = ({ uploadFile, deleteFile, forwardedRef, - extensions: LiteTextEditorExtensions(), + extensions: LiteTextEditorExtensions(onEnterKeyPress), }); const editorClassNames = getEditorClassNames({ noBorder, borderOnFocus, customClassName }); diff --git a/space/components/issues/peek-overview/comment/add-comment.tsx b/space/components/issues/peek-overview/comment/add-comment.tsx index c06634fc6..c7852a47b 100644 --- a/space/components/issues/peek-overview/comment/add-comment.tsx +++ b/space/components/issues/peek-overview/comment/add-comment.tsx @@ -11,7 +11,7 @@ import { SecondaryButton } from "components/ui"; // types import { Comment } from "types/issue"; // components -import { RichTextEditorWithRef } from "@plane/rich-text-editor"; +import { LiteTextEditorWithRef } from "@plane/lite-text-editor"; // service import fileService from "@/services/file.service"; @@ -71,7 +71,12 @@ export const AddComment: React.FC = observer((props) => { name="comment_html" control={control} render={({ field: { value, onChange } }) => ( - { + userStore.requiredLogin(() => { + handleSubmit(onSubmit)(e); + }); + }} uploadFile={fileService.getUploadFileFunction(workspace_slug as string)} deleteFile={fileService.deleteImage} ref={editorRef} diff --git a/space/components/issues/peek-overview/comment/comment-detail-card.tsx b/space/components/issues/peek-overview/comment/comment-detail-card.tsx index cfd7ba493..6857fca71 100644 --- a/space/components/issues/peek-overview/comment/comment-detail-card.tsx +++ b/space/components/issues/peek-overview/comment/comment-detail-card.tsx @@ -104,6 +104,7 @@ export const CommentCard: React.FC = observer((props) => { name="comment_html" render={({ field: { onChange, value } }) => ( = observer((props) => { {}} + onClick={() => { }} className="relative grid place-items-center rounded p-1 text-custom-text-200 hover:text-custom-text-100 outline-none cursor-pointer hover:bg-custom-background-80" > @@ -173,9 +174,8 @@ export const CommentCard: React.FC = observer((props) => { onClick={() => { setIsEditing(true); }} - className={`w-full select-none truncate rounded px-1 py-1.5 text-left text-custom-text-200 hover:bg-custom-background-80 ${ - active ? "bg-custom-background-80" : "" - }`} + className={`w-full select-none truncate rounded px-1 py-1.5 text-left text-custom-text-200 hover:bg-custom-background-80 ${active ? "bg-custom-background-80" : "" + }`} > Edit @@ -188,9 +188,8 @@ export const CommentCard: React.FC = observer((props) => { diff --git a/web/components/issues/comment/add-comment.tsx b/web/components/issues/comment/add-comment.tsx index 4b0e92ba7..2fb3912d1 100644 --- a/web/components/issues/comment/add-comment.tsx +++ b/web/components/issues/comment/add-comment.tsx @@ -80,6 +80,7 @@ export const AddComment: React.FC = ({ control={control} render={({ field: { onChange: onCommentChange, value: commentValue } }) => ( = ({ >