fix: intake form asset upload (#1691)

This commit is contained in:
Aaryan Khandelwal
2024-11-11 18:26:51 +05:30
committed by GitHub
parent 009c866cc0
commit cd88622fd9
2 changed files with 22 additions and 23 deletions

View File

@@ -1,22 +1,17 @@
import React, { forwardRef } from "react";
// editor
// plane editor
import { EditorRefApi, IMentionHighlight, IRichTextEditor, RichTextEditorWithRef } from "@plane/editor";
// types
// helpers
import { cn } from "@/helpers/common.helper";
import { getEditorFileHandlers } from "@/helpers/editor.helper";
interface RichTextEditorWrapperProps extends Omit<IRichTextEditor, "fileHandler" | "mentionHandler"> {
anchor: string;
uploadFile: (file: File) => Promise<string>;
workspaceId: string;
}
export const RichTextEditor = forwardRef<EditorRefApi, RichTextEditorWrapperProps>((props, ref) => {
const { containerClassName, uploadFile, ...rest } = props;
// store hooks
// use-mention
// file size
const { anchor, containerClassName, uploadFile, workspaceId, ...rest } = props;
return (
<RichTextEditorWithRef
@@ -29,12 +24,12 @@ export const RichTextEditor = forwardRef<EditorRefApi, RichTextEditorWrapperProp
ref={ref}
fileHandler={getEditorFileHandlers({
uploadFile,
workspaceId: "",
anchor: "",
workspaceId,
anchor,
})}
{...rest}
containerClassName={containerClassName}
editorClassName="min-h-[100px] max-h-[50vh] border border-gray-100 rounded-md pl-3 pb-3 overflow-y-scroll"
editorClassName="min-h-[100px] max-h-[50vh] border-[0.5px] border-custom-border-200 rounded-md pl-3 pb-3 overflow-y-scroll"
/>
);
});

View File

@@ -1,9 +1,16 @@
import { observer } from "mobx-react";
// plane types
import { IProject } from "@plane/types";
// plane ui
import { Button, Input } from "@plane/ui";
// components
import { ProjectLogo } from "@/components/common";
import { RichTextEditor } from "@/components/editor/rich-text-editor";
import { useIssueDetails } from "@/hooks/store";
// hooks
import { useIssueDetails, usePublish } from "@/hooks/store";
// helpers
import { getDescriptionPlaceholder } from "@/plane-web/helpers/issue.helper";
// local types
import { TFormData } from "./create-issue-modal";
type TProps = {
@@ -19,15 +26,10 @@ type TProps = {
placeholder?: string | ((isFocused: boolean, value: string) => string);
};
const IssueForm = ({
project,
isSubmitting,
descriptionEditorRef,
anchor,
handleFormData,
formData,
placeholder,
}: TProps) => {
const IssueForm = observer((props: TProps) => {
const { project, isSubmitting, descriptionEditorRef, anchor, handleFormData, formData, placeholder } = props;
// store hooks
const { workspace: workspaceID } = usePublish(anchor);
const { uploadIssueAsset } = useIssueDetails();
return (
@@ -94,6 +96,8 @@ const IssueForm = ({
const { asset_id } = await uploadIssueAsset(file, anchor);
return asset_id;
}}
anchor={anchor}
workspaceId={workspaceID?.toString() ?? ""}
/>
<Button variant="primary" size="sm" type="submit" loading={isSubmitting} className="mx-auto mr-0">
@@ -102,6 +106,6 @@ const IssueForm = ({
</div>
</>
);
};
});
export default IssueForm;