mirror of
https://github.com/makeplane/plane.git
synced 2026-01-25 07:38:46 -06:00
[WEB-2233] fix: intake issue comment (#5368)
* fix: intake issue comment * chore: issue comment improvement
This commit is contained in:
committed by
GitHub
parent
4a71eef72e
commit
3e83eed398
@@ -1,6 +1,6 @@
|
||||
import { Extension } from "@tiptap/core";
|
||||
|
||||
export const EnterKeyExtension = (onEnterKeyPress?: (descriptionHTML: string) => void) =>
|
||||
export const EnterKeyExtension = (onEnterKeyPress?: () => void) =>
|
||||
Extension.create({
|
||||
name: "enterKey",
|
||||
|
||||
@@ -8,7 +8,9 @@ export const EnterKeyExtension = (onEnterKeyPress?: (descriptionHTML: string) =>
|
||||
return {
|
||||
Enter: () => {
|
||||
if (!this.editor.storage.mentionsOpen) {
|
||||
onEnterKeyPress?.(this.editor.getHTML());
|
||||
if (onEnterKeyPress) {
|
||||
onEnterKeyPress();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -35,7 +35,7 @@ export interface IEditorProps {
|
||||
suggestions?: () => Promise<IMentionSuggestion[]>;
|
||||
};
|
||||
onChange?: (json: object, html: string) => void;
|
||||
onEnterKeyPress?: (descriptionHTML: string) => void;
|
||||
onEnterKeyPress?: (e?: any) => void;
|
||||
placeholder?: string | ((isFocused: boolean, value: string) => string);
|
||||
tabIndex?: number;
|
||||
value?: string | null;
|
||||
|
||||
@@ -64,11 +64,7 @@ export const LiteTextEditor = React.forwardRef<EditorRefApi, LiteTextEditorWrapp
|
||||
}}
|
||||
isSubmitting={isSubmitting}
|
||||
showSubmitButton={showSubmitButton}
|
||||
handleSubmit={() => {
|
||||
if (isMutableRefObject<EditorRefApi>(ref)) {
|
||||
rest.onEnterKeyPress?.(ref.current?.getHTML() ?? "");
|
||||
}
|
||||
}}
|
||||
handleSubmit={(e) => rest.onEnterKeyPress?.(e)}
|
||||
isCommentEmpty={isEmpty}
|
||||
editorRef={isMutableRefObject<EditorRefApi>(ref) ? ref : null}
|
||||
/>
|
||||
|
||||
@@ -12,7 +12,7 @@ import { cn } from "@/helpers/common.helper";
|
||||
|
||||
type Props = {
|
||||
executeCommand: (commandKey: TEditorCommands) => void;
|
||||
handleSubmit: () => void;
|
||||
handleSubmit: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
||||
isCommentEmpty: boolean;
|
||||
isSubmitting: boolean;
|
||||
showSubmitButton: boolean;
|
||||
|
||||
@@ -66,8 +66,8 @@ export const AddComment: React.FC<Props> = observer((props) => {
|
||||
control={control}
|
||||
render={({ field: { value, onChange } }) => (
|
||||
<LiteTextEditor
|
||||
onEnterKeyPress={() => {
|
||||
if (currentUser) handleSubmit(onSubmit)();
|
||||
onEnterKeyPress={(e) => {
|
||||
if (currentUser) handleSubmit(onSubmit)(e);
|
||||
}}
|
||||
workspaceId={workspaceID?.toString() ?? ""}
|
||||
workspaceSlug={workspaceSlug?.toString() ?? ""}
|
||||
|
||||
@@ -103,7 +103,7 @@ export const CommentCard: React.FC<Props> = observer((props) => {
|
||||
<LiteTextEditor
|
||||
workspaceId={workspaceID?.toString() ?? ""}
|
||||
workspaceSlug={workspaceSlug?.toString() ?? ""}
|
||||
onEnterKeyPress={() => handleSubmit(handleCommentUpdate)()}
|
||||
onEnterKeyPress={handleSubmit(handleCommentUpdate)}
|
||||
ref={editorRef}
|
||||
id={comment.id}
|
||||
initialValue={value}
|
||||
|
||||
@@ -94,11 +94,7 @@ export const LiteTextEditor = React.forwardRef<EditorRefApi, LiteTextEditorWrapp
|
||||
}
|
||||
}}
|
||||
handleAccessChange={handleAccessChange}
|
||||
handleSubmit={() => {
|
||||
if (isMutableRefObject<EditorRefApi>(ref)) {
|
||||
rest.onEnterKeyPress?.(ref.current?.getHTML() ?? "");
|
||||
}
|
||||
}}
|
||||
handleSubmit={(e) => rest.onEnterKeyPress?.(e)}
|
||||
isCommentEmpty={isEmpty}
|
||||
isSubmitting={isSubmitting}
|
||||
showAccessSpecifier={showAccessSpecifier}
|
||||
|
||||
@@ -137,7 +137,11 @@ export const IssueCommentCard: FC<TIssueCommentCard> = observer((props) => {
|
||||
>
|
||||
<>
|
||||
<form className={`flex-col gap-2 ${isEditing ? "flex" : "hidden"}`}>
|
||||
<div>
|
||||
<div
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter" && !e.shiftKey && !e.ctrlKey && !e.metaKey && !isEmpty) handleSubmit(onEnter)(e);
|
||||
}}
|
||||
>
|
||||
<LiteTextEditor
|
||||
workspaceId={workspaceId}
|
||||
projectId={projectId}
|
||||
@@ -147,13 +151,9 @@ export const IssueCommentCard: FC<TIssueCommentCard> = observer((props) => {
|
||||
initialValue={watch("comment_html") ?? ""}
|
||||
value={null}
|
||||
onChange={(comment_json, comment_html) => setValue("comment_html", comment_html)}
|
||||
onEnterKeyPress={(commentHTML) => {
|
||||
const isCommentEmpty =
|
||||
commentHTML?.trim() === "" ||
|
||||
commentHTML === "<p></p>" ||
|
||||
(isEmptyHtmlString(commentHTML ?? "") && !commentHTML?.includes("mention-component"));
|
||||
if (!isCommentEmpty && !isSubmitting) {
|
||||
handleSubmit(onEnter)();
|
||||
onEnterKeyPress={(e) => {
|
||||
if (!isEmpty && !isSubmitting) {
|
||||
handleSubmit(onEnter)(e);
|
||||
}
|
||||
}}
|
||||
showSubmitButton={false}
|
||||
|
||||
@@ -33,6 +33,7 @@ export const IssueCommentCreate: FC<TIssueCommentCreate> = (props) => {
|
||||
const {
|
||||
handleSubmit,
|
||||
control,
|
||||
watch,
|
||||
formState: { isSubmitting },
|
||||
reset,
|
||||
} = useForm<Partial<TIssueComment>>({
|
||||
@@ -49,8 +50,19 @@ export const IssueCommentCreate: FC<TIssueCommentCreate> = (props) => {
|
||||
editorRef.current?.clearEditor();
|
||||
});
|
||||
|
||||
const commentHTML = watch("comment_html");
|
||||
const isEmpty =
|
||||
commentHTML?.trim() === "" ||
|
||||
commentHTML === "<p></p>" ||
|
||||
(isEmptyHtmlString(commentHTML ?? "") && !commentHTML?.includes("mention-component"));
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter" && !e.shiftKey && !e.ctrlKey && !e.metaKey && !isEmpty && !isSubmitting)
|
||||
handleSubmit(onSubmit)(e);
|
||||
}}
|
||||
>
|
||||
<Controller
|
||||
name="access"
|
||||
control={control}
|
||||
@@ -65,13 +77,9 @@ export const IssueCommentCreate: FC<TIssueCommentCreate> = (props) => {
|
||||
value={"<p></p>"}
|
||||
projectId={projectId}
|
||||
workspaceSlug={workspaceSlug}
|
||||
onEnterKeyPress={(commentHTML) => {
|
||||
const isEmpty =
|
||||
commentHTML?.trim() === "" ||
|
||||
commentHTML === "<p></p>" ||
|
||||
(isEmptyHtmlString(commentHTML ?? "") && !commentHTML?.includes("mention-component"));
|
||||
onEnterKeyPress={(e) => {
|
||||
if (!isEmpty && !isSubmitting) {
|
||||
handleSubmit(onSubmit)();
|
||||
handleSubmit(onSubmit)(e);
|
||||
}
|
||||
}}
|
||||
ref={editorRef}
|
||||
|
||||
Reference in New Issue
Block a user