From c65bbf865d19963eb6d25abdfb9cf7dc329da8a8 Mon Sep 17 00:00:00 2001 From: sriram veeraghanta Date: Mon, 28 Aug 2023 15:54:49 +0530 Subject: [PATCH] fix: tiptap editor export fixes (#2001) --- .../core/modals/gpt-assistant-modal.tsx | 31 +++++------- .../components/issues/comment/add-comment.tsx | 15 ++---- .../issues/comment/comment-card.tsx | 19 ++++--- .../components/issues/description-form.tsx | 4 +- apps/app/components/issues/form.tsx | 11 +---- .../pages/create-update-block-inline.tsx | 33 +++++-------- .../components/pages/single-page-block.tsx | 49 +++++++++---------- apps/app/components/tiptap/index.tsx | 18 ++++--- .../[workspaceSlug]/me/profile/activity.tsx | 4 +- 9 files changed, 77 insertions(+), 107 deletions(-) diff --git a/apps/app/components/core/modals/gpt-assistant-modal.tsx b/apps/app/components/core/modals/gpt-assistant-modal.tsx index 35f282040..81c9b7d71 100644 --- a/apps/app/components/core/modals/gpt-assistant-modal.tsx +++ b/apps/app/components/core/modals/gpt-assistant-modal.tsx @@ -1,7 +1,5 @@ import React, { useEffect, useState, forwardRef, useRef } from "react"; - import { useRouter } from "next/router"; - // react-hook-form import { useForm } from "react-hook-form"; // services @@ -12,9 +10,10 @@ import useToast from "hooks/use-toast"; import useUserAuth from "hooks/use-user-auth"; // ui import { Input, PrimaryButton, SecondaryButton } from "components/ui"; - +import { TipTapEditor } from "components/tiptap"; +// types import { IIssue, IPageBlock } from "types"; -import Tiptap, { ITiptapRichTextEditor } from "components/tiptap"; + type Props = { isOpen: boolean; handleClose: () => void; @@ -32,12 +31,6 @@ type FormData = { task: string; }; -const TiptapEditor = React.forwardRef( - (props, ref) => -); - -TiptapEditor.displayName = "TiptapEditor"; - export const GptAssistantModal: React.FC = ({ isOpen, handleClose, @@ -140,13 +133,14 @@ export const GptAssistantModal: React.FC = ({ return (
{((content && content !== "") || (htmlContent && htmlContent !== "

")) && (
Content: - ${content}

`} customClassName="-m-3" @@ -160,7 +154,7 @@ export const GptAssistantModal: React.FC = ({ {response !== "" && (
Response: - ${response}

`} customClassName="-mx-3 -my-3" @@ -180,10 +174,11 @@ export const GptAssistantModal: React.FC = ({ type="text" name="task" register={register} - placeholder={`${content && content !== "" + placeholder={`${ + content && content !== "" ? "Tell AI what action to perform on this content..." : "Ask AI anything..." - }`} + }`} autoComplete="off" />
@@ -219,8 +214,8 @@ export const GptAssistantModal: React.FC = ({ {isSubmitting ? "Generating response..." : response === "" - ? "Generate response" - : "Generate again"} + ? "Generate response" + : "Generate again"}
diff --git a/apps/app/components/issues/comment/add-comment.tsx b/apps/app/components/issues/comment/add-comment.tsx index 540577447..4d64a90ba 100644 --- a/apps/app/components/issues/comment/add-comment.tsx +++ b/apps/app/components/issues/comment/add-comment.tsx @@ -1,21 +1,12 @@ import React from "react"; - import { useRouter } from "next/router"; - // react-hook-form import { useForm, Controller } from "react-hook-form"; -// ui +// components import { SecondaryButton } from "components/ui"; +import { TipTapEditor } from "components/tiptap"; // types import type { IIssueComment } from "types"; -// fetch-keys -import Tiptap, { ITiptapRichTextEditor } from "components/tiptap"; - -const TiptapEditor = React.forwardRef( - (props, ref) => -); - -TiptapEditor.displayName = "TiptapEditor"; const defaultValues: Partial = { comment_json: "", @@ -59,7 +50,7 @@ export const AddComment: React.FC = ({ disabled = false, onSubmit }) => { name="comment_html" control={control} render={({ field: { value, onChange } }) => ( - ( - (props, ref) => -); - -TiptapEditor.displayName = "TiptapEditor"; type Props = { workspaceSlug: string; @@ -28,7 +22,12 @@ type Props = { handleCommentDeletion: (comment: string) => void; }; -export const CommentCard: React.FC = ({ comment, workspaceSlug, onSubmit, handleCommentDeletion }) => { +export const CommentCard: React.FC = ({ + comment, + workspaceSlug, + onSubmit, + handleCommentDeletion, +}) => { const { user } = useUser(); const editorRef = React.useRef(null); @@ -109,7 +108,7 @@ export const CommentCard: React.FC = ({ comment, workspaceSlug, onSubmit, onSubmit={handleSubmit(onEnter)} >
- = ({ comment, workspaceSlug, onSubmit,
- = ({ if (!value) return <>; return ( - ( - (props, ref) => -); - -TiptapEditor.displayName = "TiptapEditor"; const defaultValues: Partial = { project: "", @@ -369,7 +362,7 @@ export const IssueForm: FC = ({ if (!value && !watch("description_html")) return <>; return ( - void; @@ -39,12 +33,6 @@ const defaultValues = { description_html: null, }; -const TiptapEditor = React.forwardRef( - (props, ref) => -); - -TiptapEditor.displayName = "TiptapEditor"; - export const CreateUpdateBlockInline: React.FC = ({ handleClose, data, @@ -231,9 +219,9 @@ export const CreateUpdateBlockInline: React.FC = ({ description: !data.description || data.description === "" ? { - type: "doc", - content: [{ type: "paragraph" }], - } + type: "doc", + content: [{ type: "paragraph" }], + } : data.description, description_html: data.description_html ?? "

", }); @@ -291,7 +279,7 @@ export const CreateUpdateBlockInline: React.FC = ({ render={({ field: { value, onChange } }) => { if (!data) return ( -

"} @@ -311,7 +299,7 @@ export const CreateUpdateBlockInline: React.FC = ({ ); return ( - = ({
diff --git a/apps/app/components/pages/single-page-block.tsx b/apps/app/components/pages/single-page-block.tsx index 0c192990a..e4c1d94ac 100644 --- a/apps/app/components/pages/single-page-block.tsx +++ b/apps/app/components/pages/single-page-block.tsx @@ -19,6 +19,7 @@ import useOutsideClickDetector from "hooks/use-outside-click-detector"; // components import { GptAssistantModal } from "components/core"; import { CreateUpdateBlockInline } from "components/pages"; +import { TipTapEditor } from "components/tiptap"; // ui import { CustomMenu, TextArea } from "components/ui"; // icons @@ -38,7 +39,6 @@ import { copyTextToClipboard } from "helpers/string.helper"; import { ICurrentUserResponse, IIssue, IPageBlock, IProject } from "types"; // fetch-keys import { PAGE_BLOCKS_LIST } from "constants/fetch-keys"; -import Tiptap, { ITiptapRichTextEditor } from "components/tiptap"; type Props = { block: IPageBlock; @@ -48,13 +48,6 @@ type Props = { user: ICurrentUserResponse | undefined; }; -const TiptapEditor = React.forwardRef< - ITiptapRichTextEditor, - ITiptapRichTextEditor ->((props, ref) => ); - -TiptapEditor.displayName = "TiptapEditor"; - export const SinglePageBlock: React.FC = ({ block, projectDetails, @@ -328,8 +321,9 @@ export const SinglePageBlock: React.FC = ({
) : (
@@ -343,8 +337,9 @@ export const SinglePageBlock: React.FC = ({ { +const Tiptap = (props: ITipTapRichTextEditor) => { const { onChange, debouncedUpdatesEnabled, @@ -75,8 +75,8 @@ const Tiptap = (props: ITiptapRichTextEditor) => { const editorClassNames = `relative w-full max-w-full sm:rounded-lg mt-2 p-3 relative focus:outline-none rounded-md ${noBorder ? "" : "border border-custom-border-200"} ${ - borderOnFocus ? "focus:border border-custom-border-300" : "focus:border-0" - } ${customClassName}`; + borderOnFocus ? "focus:border border-custom-border-300" : "focus:border-0" + } ${customClassName}`; if (!editor) return null; editorRef.current = editor; @@ -98,4 +98,10 @@ const Tiptap = (props: ITiptapRichTextEditor) => { ); }; -export default Tiptap; +const TipTapEditor = forwardRef((props, ref) => ( + +)); + +TipTapEditor.displayName = "TipTapEditor"; + +export { TipTapEditor }; diff --git a/apps/app/pages/[workspaceSlug]/me/profile/activity.tsx b/apps/app/pages/[workspaceSlug]/me/profile/activity.tsx index 3a8e9f8da..20f278427 100644 --- a/apps/app/pages/[workspaceSlug]/me/profile/activity.tsx +++ b/apps/app/pages/[workspaceSlug]/me/profile/activity.tsx @@ -10,7 +10,7 @@ import { WorkspaceAuthorizationLayout } from "layouts/auth-layout"; import SettingsNavbar from "layouts/settings-navbar"; // components import { ActivityIcon, ActivityMessage } from "components/core"; -import Tiptap, { ITiptapRichTextEditor } from "components/tiptap"; +import { TipTapEditor } from "components/tiptap"; // icons import { ArrowTopRightOnSquareIcon, ChatBubbleLeftEllipsisIcon } from "@heroicons/react/24/outline"; // ui @@ -97,7 +97,7 @@ const ProfileActivity = () => {

-