From a8df46fb83cbf4319c0ade3d4f145c062bab3ea1 Mon Sep 17 00:00:00 2001 From: Vipin Chaudhary Date: Tue, 18 Nov 2025 18:05:10 +0530 Subject: [PATCH] [WEB-5449] fix: update inbox issue description loading condition (#4785) --- .../rich-text/description-input/root.tsx | 16 +++++++++++++--- .../components/editor/rich-text/editor.tsx | 16 +++------------- .../components/inbox/content/issue-root.tsx | 1 - apps/web/ee/hooks/use-editor-flagging.ts | 8 ++++++++ packages/constants/src/application.ts | 2 +- packages/constants/src/feature-flag.ts | 1 + .../components/editors/rich-text/editor.tsx | 3 +-- .../src/core/components/menus/block-menu.tsx | 12 ++++++------ .../editor/src/core/extensions/extensions.ts | 3 --- packages/editor/src/core/types/editor.ts | 1 - packages/editor/src/core/types/extensions.ts | 3 ++- .../src/ee/extensions/core/extensions.ts | 18 +++++++++++++++--- .../editor/src/ee/types/editor-extended.ts | 1 + packages/mobile-editor/package.json | 12 ++++++------ 14 files changed, 57 insertions(+), 40 deletions(-) diff --git a/apps/web/core/components/editor/rich-text/description-input/root.tsx b/apps/web/core/components/editor/rich-text/description-input/root.tsx index 13e05dc711..d019258aaf 100644 --- a/apps/web/core/components/editor/rich-text/description-input/root.tsx +++ b/apps/web/core/components/editor/rich-text/description-input/root.tsx @@ -1,6 +1,6 @@ "use client"; -import { useCallback, useEffect, useState, useRef } from "react"; +import { useCallback, useEffect, useState, useRef, useMemo } from "react"; import { debounce } from "lodash-es"; import { observer } from "mobx-react"; import { Controller, useForm } from "react-hook-form"; @@ -13,6 +13,7 @@ import { getDescriptionPlaceholderI18n } from "@plane/utils"; import { RichTextEditor } from "@/components/editor/rich-text"; // hooks import { useEditorAsset } from "@/hooks/store/use-editor-asset"; +import { useProject } from "@/hooks/store/use-project"; import { useWorkspace } from "@/hooks/store/use-workspace"; // plane web services import { WorkspaceService } from "@/plane-web/services"; @@ -104,7 +105,6 @@ export const DescriptionInput: React.FC = observer((props) => { setIsSubmitting, swrDescription, workspaceSlug, - issueSequenceId, } = props; // states const [localDescription, setLocalDescription] = useState({ @@ -187,6 +187,16 @@ export const DescriptionInput: React.FC = observer((props) => { [] ); + const { getProjectIdentifierById } = useProject(); + const workItemUrl = useMemo(() => { + const projectIdentifier = getProjectIdentifierById(projectId); + if (!projectIdentifier || !props.issueSequenceId) { + return undefined; + } + const origin = window.location.origin; + return `${origin}/${workspaceSlug}/browse/${projectIdentifier}-${props.issueSequenceId}/`; + }, [projectId, workspaceSlug, props.issueSequenceId, getProjectIdentifierById]); + if (!workspaceDetails) return null; return ( @@ -200,7 +210,7 @@ export const DescriptionInput: React.FC = observer((props) => { editable={!disabled} ref={editorRef} id={entityId} - issueSequenceId={issueSequenceId} + workItemUrl={workItemUrl} disabledExtensions={disabledExtensions} initialValue={localDescription.description_html ?? "

"} value={swrDescription ?? null} diff --git a/apps/web/core/components/editor/rich-text/editor.tsx b/apps/web/core/components/editor/rich-text/editor.tsx index 7793072883..3036c83c2a 100644 --- a/apps/web/core/components/editor/rich-text/editor.tsx +++ b/apps/web/core/components/editor/rich-text/editor.tsx @@ -9,7 +9,6 @@ import { EditorMentionsRoot } from "@/components/editor/embeds/mentions"; // hooks import { useEditorConfig, useEditorMention } from "@/hooks/editor"; import { useMember } from "@/hooks/store/use-member"; -import { useProject } from "@/hooks/store/use-project"; import { useUserProfile } from "@/hooks/store/use-user-profile"; // plane web components import { EmbedHandler } from "@/plane-web/components/pages/editor/external-embed/embed-handler"; @@ -23,7 +22,7 @@ type RichTextEditorWrapperProps = MakeOptional< workspaceSlug: string; workspaceId: string; projectId?: string; - issueSequenceId?: number; + workItemUrl?: string; } & ( | { editable: false; @@ -43,6 +42,7 @@ export const RichTextEditor = forwardRef { - const projectIdentifier = getProjectIdentifierById(projectId); - if (!projectIdentifier || !props.issueSequenceId) { - return null; - } - const origin = window.location.origin; - return `${origin}/${workspaceSlug}/browse/${projectIdentifier}-${props.issueSequenceId}/`; - }, [projectId, workspaceSlug, props.issueSequenceId, getProjectIdentifierById]); - return ( = observer((props) => { ) : ( = (props) => { fileHandler, flaggedExtensions, extendedEditorProps, - workItemIdentifier, } = props; const getExtensions = useCallback(() => { @@ -48,7 +47,7 @@ const RichTextEditor: React.FC = (props) => { editor={editor} flaggedExtensions={flaggedExtensions} disabledExtensions={disabledExtensions} - workItemIdentifier={workItemIdentifier} + workItemUrl={extendedEditorProps?.workItemUrl} /> )} diff --git a/packages/editor/src/core/components/menus/block-menu.tsx b/packages/editor/src/core/components/menus/block-menu.tsx index 5876327c8e..95bf8596ab 100644 --- a/packages/editor/src/core/components/menus/block-menu.tsx +++ b/packages/editor/src/core/components/menus/block-menu.tsx @@ -24,7 +24,7 @@ import { ADDITIONAL_EXTENSIONS } from "@/plane-editor/constants/extensions"; import { useBlockMenu } from "@/plane-editor/hooks/use-block-menu"; // types import { EExternalEmbedAttributeNames } from "@/types"; -import type { IEditorProps } from "@/types"; +import type { IEditorProps, IEditorPropsExtended } from "@/types"; // components import { getNodeOptions } from "./block-menu-options"; @@ -32,7 +32,7 @@ type Props = { disabledExtensions?: IEditorProps["disabledExtensions"]; editor: Editor; flaggedExtensions?: IEditorProps["flaggedExtensions"]; - workItemIdentifier?: IEditorProps["workItemIdentifier"]; + workItemUrl?: IEditorPropsExtended["workItemUrl"]; }; export type BlockMenuOption = { icon: LucideIcon; @@ -74,7 +74,7 @@ const stripCommentMarksFromJSON = (node: JSONContent | null | undefined): JSONCo }; export const BlockMenu = (props: Props) => { - const { editor, flaggedExtensions, disabledExtensions, workItemIdentifier } = props; + const { editor, flaggedExtensions, disabledExtensions, workItemUrl } = props; const [isOpen, setIsOpen] = useState(false); const [isAnimatedIn, setIsAnimatedIn] = useState(false); const menuRef = useRef(null); @@ -210,9 +210,9 @@ export const BlockMenu = (props: Props) => { let urlToCopy: string; const currentPageUrl = window.location.href.split("#")[0]; - const workItemUrl = workItemIdentifier; - if (workItemUrl) { - urlToCopy = nodeId ? `${workItemUrl}#${nodeId}` : workItemUrl; + const baseWorkItemUrl = workItemUrl; + if (baseWorkItemUrl) { + urlToCopy = nodeId ? `${baseWorkItemUrl}#${nodeId}` : baseWorkItemUrl; } else { urlToCopy = nodeId ? `${currentPageUrl}#${nodeId}` : currentPageUrl; } diff --git a/packages/editor/src/core/extensions/extensions.ts b/packages/editor/src/core/extensions/extensions.ts index ba68f868c6..1bbddfe500 100644 --- a/packages/editor/src/core/extensions/extensions.ts +++ b/packages/editor/src/core/extensions/extensions.ts @@ -36,7 +36,6 @@ import { CustomImageExtension } from "./custom-image/extension"; import { EmojiExtension } from "./emoji/extension"; import { CustomPlaceholderExtension } from "./placeholder"; import { CustomStarterKitExtension } from "./starter-kit"; -import { UniqueID } from "./unique-id/extension"; type TArguments = Pick< IEditorProps, @@ -122,8 +121,6 @@ export const CoreEditorExtensions = (args: TArguments): Extensions => { extendedEditorProps, flaggedExtensions, fileHandler, - }), - UniqueID.configure({ provider, }), ]; diff --git a/packages/editor/src/core/types/editor.ts b/packages/editor/src/core/types/editor.ts index 7080c06671..ba5d719170 100644 --- a/packages/editor/src/core/types/editor.ts +++ b/packages/editor/src/core/types/editor.ts @@ -184,7 +184,6 @@ export type IEditorProps = { tabIndex?: number; value?: Content | null; extendedEditorProps: IEditorPropsExtended; - workItemIdentifier?: string | null; }; export type ILiteTextEditorProps = IEditorProps; diff --git a/packages/editor/src/core/types/extensions.ts b/packages/editor/src/core/types/extensions.ts index 16dea5aaa6..65392d6798 100644 --- a/packages/editor/src/core/types/extensions.ts +++ b/packages/editor/src/core/types/extensions.ts @@ -12,4 +12,5 @@ export type TExtensions = | "comments" | "mathematics" | "drawio" - | "copy-block-link"; + | "copy-block-link" + | "unique-id"; diff --git a/packages/editor/src/ee/extensions/core/extensions.ts b/packages/editor/src/ee/extensions/core/extensions.ts index a65dfcd0c3..1cc2eb5c51 100644 --- a/packages/editor/src/ee/extensions/core/extensions.ts +++ b/packages/editor/src/ee/extensions/core/extensions.ts @@ -1,5 +1,7 @@ +import type { HocuspocusProvider } from "@hocuspocus/provider"; import type { Extensions } from "@tiptap/core"; // ce imports +import { UniqueID } from "@/extensions/unique-id/extension"; import { ADDITIONAL_EXTENSIONS } from "@/plane-editor/constants/extensions"; import type { IEditorPropsExtended } from "@/plane-editor/types/editor-extended"; // types @@ -11,10 +13,12 @@ import { MathematicsExtension } from "../mathematics/extension"; import { NodeHighlightExtension } from "../node-highlight/extension"; import { SmoothCursorExtension } from "../smooth-cursor"; -type Props = TCoreAdditionalExtensionsProps & { extendedEditorProps?: IEditorPropsExtended }; +type Props = TCoreAdditionalExtensionsProps & { extendedEditorProps?: IEditorPropsExtended } & { + provider: HocuspocusProvider | undefined; +}; export const CoreEditorAdditionalExtensions = (props: Props): Extensions => { - const { flaggedExtensions, extendedEditorProps, disabledExtensions } = props; + const { flaggedExtensions, extendedEditorProps, disabledExtensions, provider } = props; const { extensionOptions } = extendedEditorProps ?? {}; const { embedHandler, isSmoothCursorEnabled } = extendedEditorProps ?? {}; const extensions: Extensions = []; @@ -34,8 +38,16 @@ export const CoreEditorAdditionalExtensions = (props: Props): Extensions => { if (isSmoothCursorEnabled) { extensions.push(SmoothCursorExtension); } - if (!disabledExtensions?.includes("copy-block-link")) { + if (!disabledExtensions?.includes("unique-id") && !disabledExtensions?.includes("copy-block-link")) { extensions.push(NodeHighlightExtension); } + + if (!disabledExtensions?.includes("unique-id")) { + extensions.push( + UniqueID.configure({ + provider, + }) + ); + } return extensions; }; diff --git a/packages/editor/src/ee/types/editor-extended.ts b/packages/editor/src/ee/types/editor-extended.ts index 28e7bb6a75..082913df76 100644 --- a/packages/editor/src/ee/types/editor-extended.ts +++ b/packages/editor/src/ee/types/editor-extended.ts @@ -18,6 +18,7 @@ export type IEditorPropsExtended = { commentConfig?: TCommentConfig; isSmoothCursorEnabled: boolean; logoSpinner?: React.ComponentType; + workItemUrl?: string | null; }; export type ICollaborativeDocumentEditorPropsExtended = unknown; diff --git a/packages/mobile-editor/package.json b/packages/mobile-editor/package.json index 1a136423a4..593146644b 100644 --- a/packages/mobile-editor/package.json +++ b/packages/mobile-editor/package.json @@ -4,14 +4,14 @@ "version": "0.0.0", "scripts": { "dev": "vite", - "lint": "eslint .", + "lint-mobile": "eslint .", "preview": "vite preview", "clean": "rm -rf .turbo && rm -rf .next && rm -rf node_modules && rm -rf dist", - "check:lint": "eslint . --max-warnings 28", - "check:types": "tsc --noEmit", - "check:format": "prettier --check \"**/*.{ts,tsx,md,json,css,scss}\"", - "fix:lint": "eslint . --fix", - "fix:format": "prettier --write \"**/*.{ts,tsx,md,json,css,scss}\"" + "check:lint-mobile": "eslint . --max-warnings 28", + "check:types-mobile": "tsc --noEmit", + "check:format-mobile": "prettier --check \"**/*.{ts,tsx,md,json,css,scss}\"", + "fix:lint-mobile": "eslint . --fix", + "fix:format-mobile": "prettier --write \"**/*.{ts,tsx,md,json,css,scss}\"" }, "dependencies": { "@plane/editor": "workspace:*",