π₯π₯π₯ Open-source Jira, Linear, Monday, and ClickUp alternative. Plane is a modern project management platform to manage tasks, sprints, docs, and triage.
TypeScript boardsbug-trackerdjangodockerganttissue-trackerjirajira-alternativekanbanlinearpostgresqlproduct-managementproject-managementproject-planningpythonreactredistypesciptvitework-management
[WEB-3489] improvement: add support to disable extensions in rich and lite text editor (#6721)
Prateek Shouryaa953013f70cb
diff --git a/packages/types/src/utils.d.ts b/packages/types/src/utils.d.tsindex aae5fd90ce..d7f7067b1d 100644--- a/packages/types/src/utils.d.ts+++ b/packages/types/src/utils.d.ts@@ -3,3 +3,5 @@ export type PartialDeep<K> = {};export type CompleteOrEmpty<T> = T | Record<string, never>;++export type MakeOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;diff --git a/space/core/components/editor/lite-text-editor.tsx b/space/core/components/editor/lite-text-editor.tsxindex 9f2cda4ad5..6c6a19641a 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 importsimport { EditorRefApi, ILiteTextEditor, LiteTextEditorWithRef, TFileHandler } from "@plane/editor";+import { MakeOptional } from "@plane/types";// componentsimport { 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<ILiteTextEditor, "disabledExtensions" | "fileHandler" | "mentionHandler"> {+ extends MakeOptional<Omit<ILiteTextEditor, "fileHandler" | "mentionHandler">, "disabledExtensions"> {anchor: string;workspaceId: string;isSubmitting?: boolean;@@ -25,6 +26,7 @@ export const LiteTextEditor = React.forwardRef<EditorRefApi, LiteTextEditorWrappisSubmitting = false,showSubmitButton = true,uploadFile,+ disabledExtensions,...rest} = props;function isMutableRefObject<T>(ref: React.ForwardedRef<T>): ref is React.MutableRefObject<T | null> {@@ -38,7 +40,7 @@ export const LiteTextEditor = React.forwardRef<EditorRefApi, LiteTextEditorWrapp<div className="border border-custom-border-200 rounded p-3 space-y-3"><LiteTextEditorWithRefref={ref}- disabledExtensions={[]}+ disabledExtensions={disabledExtensions ?? []}fileHandler={getEditorFileHandlers({anchor,uploadFile,diff --git a/space/core/components/editor/lite-text-read-only-editor.tsx b/space/core/components/editor/lite-text-read-only-editor.tsxindex f9889f2ab6..5c8785e90b 100644--- a/space/core/components/editor/lite-text-read-only-editor.tsx+++ b/space/core/components/editor/lite-text-read-only-editor.tsx@@ -1,25 +1,26 @@import React from "react";-// editor+// plane importsimport { EditorReadOnlyRefApi, ILiteTextReadOnlyEditor, LiteTextReadOnlyEditorWithRef } from "@plane/editor";+import { MakeOptional } from "@plane/types";// componentsimport { EditorMentionsRoot } from "@/components/editor";// helpersimport { cn } from "@/helpers/common.helper";import { getReadOnlyEditorFileHandlers } from "@/helpers/editor.helper";-type LiteTextReadOnlyEditorWrapperProps = Omit<- ILiteTextReadOnlyEditor,- "disabledExtensions" | "fileHandler" | "mentionHandler"+type LiteTextReadOnlyEditorWrapperProps = MakeOptional<+ Omit<ILiteTextReadOnlyEditor, "fileHandler" | "mentionHandler">,+ "disabledExtensions"> & {anchor: string;workspaceId: string;};export const LiteTextReadOnlyEditor = React.forwardRef<EditorReadOnlyRefApi, LiteTextReadOnlyEditorWrapperProps>(- ({ anchor, workspaceId, ...props }, ref) => (+ ({ anchor, workspaceId, disabledExtensions, ...props }, ref) => (<LiteTextReadOnlyEditorWithRefref={ref}- disabledExtensions={[]}+ disabledExtensions={disabledExtensions ?? []}fileHandler={getReadOnlyEditorFileHandlers({anchor,workspaceId,diff --git a/space/core/components/editor/rich-text-editor.tsx b/space/core/components/editor/rich-text-editor.tsxindex c9e795d7bd..9296b25d2d 100644--- a/space/core/components/editor/rich-text-editor.tsx+++ b/space/core/components/editor/rich-text-editor.tsx@@ -1,20 +1,21 @@import React, { forwardRef } from "react";-// editor+// plane importsimport { EditorRefApi, IRichTextEditor, RichTextEditorWithRef, TFileHandler } from "@plane/editor";+import { MakeOptional } from "@plane/types";// componentsimport { EditorMentionsRoot } from "@/components/editor";// helpersimport { getEditorFileHandlers } from "@/helpers/editor.helper";interface RichTextEditorWrapperProps- extends Omit<IRichTextEditor, "disabledExtensions" | "fileHandler" | "mentionHandler"> {+ extends MakeOptional<Omit<IRichTextEditor, "fileHandler" | "mentionHandler">, "disabledExtensions"> {anchor: string;uploadFile: TFileHandler["upload"];workspaceId: string;}export const RichTextEditor = forwardRef<EditorRefApi, RichTextEditorWrapperProps>((props, ref) => {- const { anchor, containerClassName, uploadFile, workspaceId, ...rest } = props;+ const { anchor, containerClassName, uploadFile, workspaceId, disabledExtensions, ...rest } = props;return (<RichTextEditorWithRef@@ -22,7 +23,7 @@ export const RichTextEditor = forwardRef<EditorRefApi, RichTextEditorWrapperProprenderComponent: (props) => <EditorMentionsRoot {...props} />,}}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.tsxindex c2d8c746fa..b989e1e411 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 importsimport { EditorReadOnlyRefApi, IRichTextReadOnlyEditor, RichTextReadOnlyEditorWithRef } from "@plane/editor";+import { MakeOptional } from "@plane/types";// componentsimport { EditorMentionsRoot } from "@/components/editor";// helpersimport { cn } from "@/helpers/common.helper";import { getReadOnlyEditorFileHandlers } from "@/helpers/editor.helper";-type RichTextReadOnlyEditorWrapperProps = Omit<- IRichTextReadOnlyEditor,- "disabledExtensions" | "fileHandler" | "mentionHandler"+type RichTextReadOnlyEditorWrapperProps = MakeOptional<+ Omit<IRichTextReadOnlyEditor, "fileHandler" | "mentionHandler">,+ "disabledExtensions"> & {anchor: string;workspaceId: string;};export const RichTextReadOnlyEditor = React.forwardRef<EditorReadOnlyRefApi, RichTextReadOnlyEditorWrapperProps>(- ({ anchor, workspaceId, ...props }, ref) => (+ ({ anchor, workspaceId, disabledExtensions, ...props }, ref) => (<RichTextReadOnlyEditorWithRefref={ref}- disabledExtensions={[]}+ disabledExtensions={disabledExtensions ?? []}fileHandler={getReadOnlyEditorFileHandlers({anchor,workspaceId,diff --git a/web/core/components/editor/lite-text-editor/lite-text-editor.tsx b/web/core/components/editor/lite-text-editor/lite-text-editor.tsxindex 63de65bc62..b06d39c855 100644--- a/web/core/components/editor/lite-text-editor/lite-text-editor.tsx+++ b/web/core/components/editor/lite-text-editor/lite-text-editor.tsx@@ -6,6 +6,7 @@ import { EditorRefApi, ILiteTextEditor, LiteTextEditorWithRef, TFileHandler } fr// i18nimport { useTranslation } from "@plane/i18n";// components+import { MakeOptional } from "@plane/types";import { EditorMentionsRoot, IssueCommentToolbar } from "@/components/editor";// helpersimport { cn } from "@/helpers/common.helper";@@ -19,7 +20,7 @@ import { WorkspaceService } from "@/plane-web/services";const workspaceService = new WorkspaceService();interface LiteTextEditorWrapperProps- extends Omit<ILiteTextEditor, "disabledExtensions" | "fileHandler" | "mentionHandler"> {+ extends MakeOptional<Omit<ILiteTextEditor, "fileHandler" | "mentionHandler">, "disabledExtensions"> {workspaceSlug: string;workspaceId: string;projectId: string;@@ -49,6 +50,7 @@ export const LiteTextEditor = React.forwardRef<EditorRefApi, LiteTextEditorWrappshowToolbarInitially = true,placeholder = t("issue.comments.placeholder"),uploadFile,+ disabledExtensions: additionalDisabledExtensions,...rest} = props;// states@@ -81,7 +83,7 @@ export const LiteTextEditor = React.forwardRef<EditorRefApi, LiteTextEditorWrapp><LiteTextEditorWithRefref={ref}- disabledExtensions={disabledExtensions}+ disabledExtensions={[...disabledExtensions, ...(additionalDisabledExtensions ?? [])]}fileHandler={getEditorFileHandlers({projectId,uploadFile,diff --git a/web/core/components/editor/lite-text-editor/lite-text-read-only-editor.tsx b/web/core/components/editor/lite-text-editor/lite-text-read-only-editor.tsxindex 007e2a37b8..0763a49f96 100644--- a/web/core/components/editor/lite-text-editor/lite-text-read-only-editor.tsx+++ b/web/core/components/editor/lite-text-editor/lite-text-read-only-editor.tsx@@ -1,6 +1,7 @@import React from "react";-// plane editor+// plane importsimport { EditorReadOnlyRefApi, ILiteTextReadOnlyEditor, LiteTextReadOnlyEditorWithRef } from "@plane/editor";+import { MakeOptional } from "@plane/types";// componentsimport { EditorMentionsRoot } from "@/components/editor";// helpers@@ -10,9 +11,9 @@ import { useEditorConfig } from "@/hooks/editor";// plane web hooksimport { useEditorFlagging } from "@/plane-web/hooks/use-editor-flagging";-type LiteTextReadOnlyEditorWrapperProps = Omit<- ILiteTextReadOnlyEditor,- "disabledExtensions" | "fileHandler" | "mentionHandler"+type LiteTextReadOnlyEditorWrapperProps = MakeOptional<+ Omit<ILiteTextReadOnlyEditor, "fileHandler" | "mentionHandler">,+ "disabledExtensions"> & {workspaceId: string;workspaceSlug: string;@@ -20,7 +21,7 @@ type LiteTextReadOnlyEditorWrapperProps = Omit<};export const LiteTextReadOnlyEditor = React.forwardRef<EditorReadOnlyRefApi, LiteTextReadOnlyEditorWrapperProps>(- ({ workspaceId, workspaceSlug, projectId, ...props }, ref) => {+ ({ workspaceId, workspaceSlug, projectId, disabledExtensions: additionalDisabledExtensions, ...props }, ref) => {// editor flaggingsconst { liteTextEditor: disabledExtensions } = useEditorFlagging(workspaceSlug?.toString());// editor config@@ -29,7 +30,7 @@ export const LiteTextReadOnlyEditor = React.forwardRef<EditorReadOnlyRefApi, Litreturn (<LiteTextReadOnlyEditorWithRefref={ref}- disabledExtensions={disabledExtensions}+ disabledExtensions={[...disabledExtensions, ...(additionalDisabledExtensions ?? [])]}fileHandler={getReadOnlyEditorFileHandlers({projectId,workspaceId,diff --git a/web/core/components/editor/rich-text-editor/rich-text-editor.tsx b/web/core/components/editor/rich-text-editor/rich-text-editor.tsxindex fdd17f2c05..b18fc18590 100644--- a/web/core/components/editor/rich-text-editor/rich-text-editor.tsx+++ b/web/core/components/editor/rich-text-editor/rich-text-editor.tsx@@ -1,8 +1,7 @@import React, { forwardRef } from "react";-// editor+// plane importsimport { EditorRefApi, IRichTextEditor, RichTextEditorWithRef, TFileHandler } from "@plane/editor";-// plane types-import { TSearchEntityRequestPayload, TSearchResponse } from "@plane/types";+import { MakeOptional, TSearchEntityRequestPayload, TSearchResponse } from "@plane/types";// componentsimport { EditorMentionsRoot } from "@/components/editor";// helpers@@ -13,7 +12,7 @@ import { useEditorConfig, useEditorMention } from "@/hooks/editor";import { useEditorFlagging } from "@/plane-web/hooks/use-editor-flagging";interface RichTextEditorWrapperProps- extends Omit<IRichTextEditor, "disabledExtensions" | "fileHandler" | "mentionHandler"> {+ extends MakeOptional<Omit<IRichTextEditor, "fileHandler" | "mentionHandler">, "disabledExtensions"> {searchMentionCallback: (payload: TSearchEntityRequestPayload) => Promise<TSearchResponse>;workspaceSlug: string;workspaceId: string;@@ -22,8 +21,16 @@ interface RichTextEditorWrapperProps}export const RichTextEditor = forwardRef<EditorRefApi, RichTextEditorWrapperProps>((props, ref) => {- const { containerClassName, workspaceSlug, workspaceId, projectId, searchMentionCallback, uploadFile, ...rest } =- props;+ const {+ containerClassName,+ workspaceSlug,+ workspaceId,+ projectId,+ searchMentionCallback,+ uploadFile,+ disabledExtensions: additionalDisabledExtensions,+ ...rest+ } = props;// editor flaggingsconst { richTextEditor: disabledExtensions } = useEditorFlagging(workspaceSlug?.toString());// use editor mention@@ -36,7 +43,7 @@ export const RichTextEditor = forwardRef<EditorRefApi, RichTextEditorWrapperPropreturn (<RichTextEditorWithRefref={ref}- disabledExtensions={disabledExtensions}+ disabledExtensions={[...disabledExtensions, ...(additionalDisabledExtensions ?? [])]}fileHandler={getEditorFileHandlers({projectId,uploadFile,diff --git a/web/core/components/editor/rich-text-editor/rich-text-read-only-editor.tsx b/web/core/components/editor/rich-text-editor/rich-text-read-only-editor.tsxindex 950f655cb9..31ce65159d 100644--- a/web/core/components/editor/rich-text-editor/rich-text-read-only-editor.tsx+++ b/web/core/components/editor/rich-text-editor/rich-text-read-only-editor.tsx@@ -1,6 +1,7 @@import React from "react";-// editor+// plane importsimport { EditorReadOnlyRefApi, IRichTextReadOnlyEditor, RichTextReadOnlyEditorWithRef } from "@plane/editor";+import { MakeOptional } from "@plane/types";// componentsimport { EditorMentionsRoot } from "@/components/editor";// helpers@@ -10,9 +11,9 @@ import { useEditorConfig } from "@/hooks/editor";// plane web hooksimport { useEditorFlagging } from "@/plane-web/hooks/use-editor-flagging";-type RichTextReadOnlyEditorWrapperProps = Omit<- IRichTextReadOnlyEditor,- "disabledExtensions" | "fileHandler" | "mentionHandler"+type RichTextReadOnlyEditorWrapperProps = MakeOptional<+ Omit<IRichTextReadOnlyEditor, "fileHandler" | "mentionHandler">,+ "disabledExtensions"> & {workspaceId: string;workspaceSlug: string;@@ -20,7 +21,7 @@ type RichTextReadOnlyEditorWrapperProps = Omit<};export const RichTextReadOnlyEditor = React.forwardRef<EditorReadOnlyRefApi, RichTextReadOnlyEditorWrapperProps>(- ({ workspaceId, workspaceSlug, projectId, ...props }, ref) => {+ ({ workspaceId, workspaceSlug, projectId, disabledExtensions: additionalDisabledExtensions, ...props }, ref) => {// editor flaggingsconst { richTextEditor: disabledExtensions } = useEditorFlagging(workspaceSlug?.toString());// editor config@@ -29,7 +30,7 @@ export const RichTextReadOnlyEditor = React.forwardRef<EditorReadOnlyRefApi, Ricreturn (<RichTextReadOnlyEditorWithRefref={ref}- disabledExtensions={disabledExtensions}+ disabledExtensions={[...disabledExtensions, ...(additionalDisabledExtensions ?? [])]}fileHandler={getReadOnlyEditorFileHandlers({projectId,workspaceId,