diff --git a/packages/types/src/utils.d.ts b/packages/types/src/utils.d.ts index aae5fd90ced..d7f7067b1d5 100644 --- a/packages/types/src/utils.d.ts +++ b/packages/types/src/utils.d.ts @@ -3,3 +3,5 @@ export type PartialDeep = { }; export type CompleteOrEmpty = T | Record; + +export type MakeOptional = Omit & Partial>; diff --git a/space/core/components/editor/lite-text-editor.tsx b/space/core/components/editor/lite-text-editor.tsx index 9f2cda4ad51..6c6a19641ae 100644 --- a/space/core/components/editor/lite-text-editor.tsx +++ b/space/core/components/editor/lite-text-editor.tsx @@ -1,6 +1,7 @@ import React from "react"; -// editor +// plane imports import { EditorRefApi, ILiteTextEditor, LiteTextEditorWithRef, TFileHandler } from "@plane/editor"; +import { MakeOptional } from "@plane/types"; // components import { EditorMentionsRoot, IssueCommentToolbar } from "@/components/editor"; // helpers @@ -9,7 +10,7 @@ import { getEditorFileHandlers } from "@/helpers/editor.helper"; import { isCommentEmpty } from "@/helpers/string.helper"; interface LiteTextEditorWrapperProps - extends Omit { + extends MakeOptional, "disabledExtensions"> { anchor: string; workspaceId: string; isSubmitting?: boolean; @@ -25,6 +26,7 @@ export const LiteTextEditor = React.forwardRef(ref: React.ForwardedRef): ref is React.MutableRefObject { @@ -38,7 +40,7 @@ export const LiteTextEditor = React.forwardRef , + "disabledExtensions" > & { anchor: string; workspaceId: string; }; export const LiteTextReadOnlyEditor = React.forwardRef( - ({ anchor, workspaceId, ...props }, ref) => ( + ({ anchor, workspaceId, disabledExtensions, ...props }, ref) => ( { + extends MakeOptional, "disabledExtensions"> { anchor: string; uploadFile: TFileHandler["upload"]; workspaceId: string; } export const RichTextEditor = forwardRef((props, ref) => { - const { anchor, containerClassName, uploadFile, workspaceId, ...rest } = props; + const { anchor, containerClassName, uploadFile, workspaceId, disabledExtensions, ...rest } = props; return ( , }} ref={ref} - disabledExtensions={[]} + disabledExtensions={disabledExtensions ?? []} fileHandler={getEditorFileHandlers({ anchor, uploadFile, diff --git a/space/core/components/editor/rich-text-read-only-editor.tsx b/space/core/components/editor/rich-text-read-only-editor.tsx index c2d8c746fa6..b989e1e411c 100644 --- a/space/core/components/editor/rich-text-read-only-editor.tsx +++ b/space/core/components/editor/rich-text-read-only-editor.tsx @@ -1,25 +1,26 @@ import React from "react"; -// editor +// plane imports import { EditorReadOnlyRefApi, IRichTextReadOnlyEditor, RichTextReadOnlyEditorWithRef } from "@plane/editor"; +import { MakeOptional } from "@plane/types"; // components import { EditorMentionsRoot } from "@/components/editor"; // helpers import { cn } from "@/helpers/common.helper"; import { getReadOnlyEditorFileHandlers } from "@/helpers/editor.helper"; -type RichTextReadOnlyEditorWrapperProps = Omit< - IRichTextReadOnlyEditor, - "disabledExtensions" | "fileHandler" | "mentionHandler" +type RichTextReadOnlyEditorWrapperProps = MakeOptional< + Omit, + "disabledExtensions" > & { anchor: string; workspaceId: string; }; export const RichTextReadOnlyEditor = React.forwardRef( - ({ anchor, workspaceId, ...props }, ref) => ( + ({ anchor, workspaceId, disabledExtensions, ...props }, ref) => ( { + extends MakeOptional, "disabledExtensions"> { workspaceSlug: string; workspaceId: string; projectId: string; @@ -49,6 +50,7 @@ export const LiteTextEditor = React.forwardRef , + "disabledExtensions" > & { workspaceId: string; workspaceSlug: string; @@ -20,7 +21,7 @@ type LiteTextReadOnlyEditorWrapperProps = Omit< }; export const LiteTextReadOnlyEditor = React.forwardRef( - ({ workspaceId, workspaceSlug, projectId, ...props }, ref) => { + ({ workspaceId, workspaceSlug, projectId, disabledExtensions: additionalDisabledExtensions, ...props }, ref) => { // editor flaggings const { liteTextEditor: disabledExtensions } = useEditorFlagging(workspaceSlug?.toString()); // editor config @@ -29,7 +30,7 @@ export const LiteTextReadOnlyEditor = React.forwardRef { + extends MakeOptional, "disabledExtensions"> { searchMentionCallback: (payload: TSearchEntityRequestPayload) => Promise; workspaceSlug: string; workspaceId: string; @@ -22,8 +21,16 @@ interface RichTextEditorWrapperProps } export const RichTextEditor = forwardRef((props, ref) => { - const { containerClassName, workspaceSlug, workspaceId, projectId, searchMentionCallback, uploadFile, ...rest } = - props; + const { + containerClassName, + workspaceSlug, + workspaceId, + projectId, + searchMentionCallback, + uploadFile, + disabledExtensions: additionalDisabledExtensions, + ...rest + } = props; // editor flaggings const { richTextEditor: disabledExtensions } = useEditorFlagging(workspaceSlug?.toString()); // use editor mention @@ -36,7 +43,7 @@ export const RichTextEditor = forwardRef, + "disabledExtensions" > & { workspaceId: string; workspaceSlug: string; @@ -20,7 +21,7 @@ type RichTextReadOnlyEditorWrapperProps = Omit< }; export const RichTextReadOnlyEditor = React.forwardRef( - ({ workspaceId, workspaceSlug, projectId, ...props }, ref) => { + ({ workspaceId, workspaceSlug, projectId, disabledExtensions: additionalDisabledExtensions, ...props }, ref) => { // editor flaggings const { richTextEditor: disabledExtensions } = useEditorFlagging(workspaceSlug?.toString()); // editor config @@ -29,7 +30,7 @@ export const RichTextReadOnlyEditor = React.forwardRef