replaced all read-only instances

This commit is contained in:
Palanikannan1437 2023-10-02 16:35:54 +05:30
parent de07f63089
commit 51e281592f
5 changed files with 44 additions and 75 deletions

View File

@ -6,8 +6,8 @@ import { DeleteImage } from '@/types/delete-image';
import { getEditorClassNames } from '@/lib/utils'; import { getEditorClassNames } from '@/lib/utils';
import { EditorProps } from '@tiptap/pm/view'; import { EditorProps } from '@tiptap/pm/view';
import { useEditor } from './hooks/useEditor'; import { useEditor } from './hooks/useEditor';
import { EditorContainer } from '@/ui/editor-container'; import { EditorContainer } from '@/ui/components/editor-container';
import { EditorContentWrapper } from '@/ui/editor-content'; import { EditorContentWrapper } from '@/ui/components/editor-content';
interface ICoreEditor { interface ICoreEditor {
value: string; value: string;

View File

@ -9,7 +9,7 @@ import { Menu, Transition } from "@headlessui/react";
// lib // lib
import { useMobxStore } from "lib/mobx/store-provider"; import { useMobxStore } from "lib/mobx/store-provider";
// components // components
import { RichTextEditorWithRef } from "@plane/rich-text-editor"; import { LiteReadOnlyEditorWithRef, LiteTextEditorWithRef } from "@plane/lite-text-editor";
import { CommentReactions } from "components/issues/peek-overview"; import { CommentReactions } from "components/issues/peek-overview";
// icons // icons
@ -103,7 +103,7 @@ export const CommentCard: React.FC<Props> = observer((props) => {
control={control} control={control}
name="comment_html" name="comment_html"
render={({ field: { onChange, value } }) => ( render={({ field: { onChange, value } }) => (
<RichTextEditorWithRef <LiteTextEditorWithRef
uploadFile={fileService.getUploadFileFunction(workspaceSlug)} uploadFile={fileService.getUploadFileFunction(workspaceSlug)}
deleteFile={fileService.deleteImage} deleteFile={fileService.deleteImage}
ref={editorRef} ref={editorRef}
@ -135,12 +135,9 @@ export const CommentCard: React.FC<Props> = observer((props) => {
</div> </div>
</form> </form>
<div className={`${isEditing ? "hidden" : ""}`}> <div className={`${isEditing ? "hidden" : ""}`}>
<RichTextEditorWithRef <LiteReadOnlyEditorWithRef
uploadFile={fileService.getUploadFileFunction(workspaceSlug)}
deleteFile={fileService.deleteImage}
ref={showEditorRef} ref={showEditorRef}
value={comment.comment_html} value={comment.comment_html}
editable={false}
customClassName="text-xs border border-custom-border-200 bg-custom-background-100" customClassName="text-xs border border-custom-border-200 bg-custom-background-100"
/> />
<CommentReactions commentId={comment.id} projectId={comment.project} /> <CommentReactions commentId={comment.id} projectId={comment.project} />

View File

@ -1,43 +1,28 @@
import { IssueReactions } from "components/issues/peek-overview"; import { IssueReactions } from "components/issues/peek-overview";
import { RichTextEditor } from "@plane/rich-text-editor"; import { RichReadOnlyEditor } from "@plane/rich-text-editor";
import { useRouter } from "next/router";
// types // types
import { IIssue } from "types/issue"; import { IIssue } from "types/issue";
// services
import fileService from "@/services/file.service";
type Props = { type Props = {
issueDetails: IIssue; issueDetails: IIssue;
}; };
export const PeekOverviewIssueDetails: React.FC<Props> = ({ issueDetails }) => { export const PeekOverviewIssueDetails: React.FC<Props> = ({ issueDetails }) => (
const router = useRouter();
const { workspace_slug } = router.query;
return (
<div className="space-y-2"> <div className="space-y-2">
<h6 className="font-medium text-custom-text-200"> <h6 className="font-medium text-custom-text-200">
{issueDetails.project_detail.identifier}-{issueDetails.sequence_id} {issueDetails.project_detail.identifier}-{issueDetails.sequence_id}
</h6> </h6>
<h4 className="break-words text-2xl font-semibold">{issueDetails.name}</h4> <h4 className="break-words text-2xl font-semibold">{issueDetails.name}</h4>
{issueDetails.description_html !== "" && issueDetails.description_html !== "<p></p>" && ( {issueDetails.description_html !== "" && issueDetails.description_html !== "<p></p>" && (
<RichTextEditor <RichReadOnlyEditor
uploadFile={fileService.getUploadFileFunction(workspace_slug as string)} value={!issueDetails.description_html ||
deleteFile={fileService.deleteImage}
value={
!issueDetails.description_html ||
issueDetails.description_html === "" || issueDetails.description_html === "" ||
(typeof issueDetails.description_html === "object" && (typeof issueDetails.description_html === "object" &&
Object.keys(issueDetails.description_html).length === 0) Object.keys(issueDetails.description_html).length === 0)
? "<p></p>" ? "<p></p>"
: issueDetails.description_html : issueDetails.description_html}
} customClassName="p-3 min-h-[50px] shadow-sm" />
customClassName="p-3 min-h-[50px] shadow-sm"
debouncedUpdatesEnabled={false}
editable={false}
/>
)} )}
<IssueReactions /> <IssueReactions />
</div> </div>
); );
};

View File

@ -11,11 +11,9 @@ import useUserAuth from "hooks/use-user-auth";
// ui // ui
import { Input, PrimaryButton, SecondaryButton } from "components/ui"; import { Input, PrimaryButton, SecondaryButton } from "components/ui";
// components // components
import { RichTextEditor, RichTextEditorWithRef } from "@plane/rich-text-editor"; import { RichReadOnlyEditor, RichReadOnlyEditorWithRef } from "@plane/rich-text-editor";
// types // types
import { IIssue, IPageBlock } from "types"; import { IIssue, IPageBlock } from "types";
// services
import fileService from "@/services/file.service";
type Props = { type Props = {
isOpen: boolean; isOpen: boolean;
@ -136,21 +134,17 @@ export const GptAssistantModal: React.FC<Props> = ({
return ( return (
<div <div
className={`absolute ${inset} z-20 w-full space-y-4 rounded-[10px] border border-custom-border-200 bg-custom-background-100 p-4 shadow ${ className={`absolute ${inset} z-20 w-full space-y-4 rounded-[10px] border border-custom-border-200 bg-custom-background-100 p-4 shadow ${isOpen ? "block" : "hidden"
isOpen ? "block" : "hidden"
}`} }`}
> >
{((content && content !== "") || (htmlContent && htmlContent !== "<p></p>")) && ( {((content && content !== "") || (htmlContent && htmlContent !== "<p></p>")) && (
<div className="text-sm"> <div className="text-sm">
Content: Content:
<RichTextEditorWithRef <RichReadOnlyEditorWithRef
uploadFile={fileService.getUploadFileFunction(workspaceSlug as string)}
deleteFile={fileService.deleteImage}
value={htmlContent ?? `<p>${content}</p>`} value={htmlContent ?? `<p>${content}</p>`}
customClassName="-m-3" customClassName="-m-3"
noBorder noBorder
borderOnFocus={false} borderOnFocus={false}
editable={false}
ref={editorRef} ref={editorRef}
/> />
</div> </div>
@ -158,14 +152,11 @@ export const GptAssistantModal: React.FC<Props> = ({
{response !== "" && ( {response !== "" && (
<div className="page-block-section text-sm"> <div className="page-block-section text-sm">
Response: Response:
<RichTextEditor <RichReadOnlyEditor
uploadFile={fileService.getUploadFileFunction(workspaceSlug as string)}
deleteFile={fileService.deleteImage}
value={`<p>${response}</p>`} value={`<p>${response}</p>`}
customClassName="-mx-3 -my-3" customClassName="-mx-3 -my-3"
noBorder noBorder
borderOnFocus={false} borderOnFocus={false}
editable={false}
/> />
</div> </div>
)} )}
@ -179,8 +170,7 @@ export const GptAssistantModal: React.FC<Props> = ({
type="text" type="text"
name="task" name="task"
register={register} register={register}
placeholder={`${ placeholder={`${content && content !== ""
content && content !== ""
? "Tell AI what action to perform on this content..." ? "Tell AI what action to perform on this content..."
: "Ask AI anything..." : "Ask AI anything..."
}`} }`}

View File

@ -9,7 +9,7 @@ import userService from "services/user.service";
import { WorkspaceAuthorizationLayout } from "layouts/auth-layout"; import { WorkspaceAuthorizationLayout } from "layouts/auth-layout";
// components // components
import { ActivityIcon, ActivityMessage } from "components/core"; import { ActivityIcon, ActivityMessage } from "components/core";
import { RichTextEditor } from "@plane/rich-text-editor"; import { RichReadOnlyEditor } from "@plane/rich-text-editor";
// icons // icons
import { ArrowTopRightOnSquareIcon, ChatBubbleLeftEllipsisIcon } from "@heroicons/react/24/outline"; import { ArrowTopRightOnSquareIcon, ChatBubbleLeftEllipsisIcon } from "@heroicons/react/24/outline";
// ui // ui
@ -98,9 +98,7 @@ const ProfileActivity = () => {
</p> </p>
</div> </div>
<div className="issue-comments-section p-0"> <div className="issue-comments-section p-0">
<RichTextEditor <RichReadOnlyEditor
uploadFile={fileService.getUploadFileFunction(workspaceSlug as string)}
deleteFile={fileService.deleteImage}
value={ value={
activityItem?.new_value !== "" activityItem?.new_value !== ""
? activityItem.new_value ? activityItem.new_value
@ -109,7 +107,6 @@ const ProfileActivity = () => {
customClassName="text-xs border border-custom-border-200 bg-custom-background-100" customClassName="text-xs border border-custom-border-200 bg-custom-background-100"
noBorder noBorder
borderOnFocus={false} borderOnFocus={false}
editable={false}
/> />
</div> </div>
</div> </div>