Skip to content

[WIKI-466] refactor: remove rich text read only editor #7241

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: preview
Choose a base branch
from

Conversation

aaryan610
Copy link
Member

@aaryan610 aaryan610 commented Jun 19, 2025

Description

This PR gets rid of the rich text read only editor, resulting in-

  1. Better code maintainability.
  2. Removal of repeated code.

Type of Change

  • Code refactoring

Summary by CodeRabbit

  • New Features

    • Introduced an explicit editable prop for all rich text editor components, allowing precise control over editability for each instance.
  • Refactor

    • Unified editable and read-only editor components into a single RichTextEditor component, controlled via the editable prop.
    • Updated prop types and component signatures to support conditional requirements based on editability (e.g., file upload handlers only required when editable).
    • Simplified usage by removing specialized read-only editor components and related exports.
  • Chores

    • Updated all usages across the application to use the new editable prop, ensuring consistent behavior for editable and read-only states.

Copy link
Contributor

coderabbitai bot commented Jun 19, 2025

Walkthrough

This update removes all dedicated read-only rich text editor components and consolidates editable and read-only functionality into a single RichTextEditor component, controlled via a new required editable boolean prop. Type definitions and prop signatures are updated accordingly, and all usages across the codebase are refactored to use the unified component with explicit editable control.

Changes

Files/Groups Change Summary
packages/editor/src/core/components/editors/editor-wrapper.tsx, lite-text/editor.tsx Added a required editable prop to EditorWrapper and its consumers, passing it to the editor logic.
packages/editor/src/core/types/editor.ts Updated IRichTextEditorProps to a type alias with a required editable boolean; removed unused IRichTextReadOnlyEditorProps.
packages/editor/src/core/components/editors/rich-text/index.ts Removed export of read-only-editor.
packages/editor/src/core/components/editors/rich-text/read-only-editor.tsx Deleted the dedicated read-only editor component.
packages/editor/src/index.ts Removed export of RichTextReadOnlyEditorWithRef.
space/core/components/editor/index.ts Switched export from rich-text-read-only-editor to rich-text-editor.
space/core/components/editor/rich-text-editor.tsx Refactored prop types to a discriminated union on editable; uploadFile now required only if editable is true; updated logic to use editable for file handling.
space/core/components/editor/rich-text-read-only-editor.tsx Deleted the dedicated read-only editor component.
web/core/components/editor/rich-text-editor/index.ts Removed export of rich-text-read-only-editor.
web/core/components/editor/rich-text-editor/rich-text-editor.tsx Refactored prop types to a discriminated union on editable; conditional mention/file handler logic based on editable.
web/core/components/editor/rich-text-editor/rich-text-read-only-editor.tsx Deleted the dedicated read-only editor component.
web/core/components/issues/description-input.tsx Unified editor usage: always renders RichTextEditor with editable prop, removing conditional logic and dedicated read-only component.
web/core/components/issues/issue-modal/components/description-editor.tsx Added editable prop to RichTextEditor.
web/core/components/inbox/modals/create-modal/issue-description.tsx Added explicit editable prop to RichTextEditor.
web/ce/components/pages/editor/ai/ask-pi-menu.tsx, menu.tsx Replaced RichTextReadOnlyEditor with RichTextEditor editable={false}.
web/core/components/core/description-versions/modal.tsx, gpt-assistant-popover.tsx Replaced read-only editor usage with RichTextEditor editable={false}; updated editor ref types.
space/core/components/issues/peek-overview/issue-details.tsx Replaced RichTextReadOnlyEditor with RichTextEditor editable={false}.
web/core/components/profile/activity/activity-list.tsx, profile-activity-list.tsx Replaced read-only editor usage with RichTextEditor editable={false}.

Sequence Diagram(s)

sequenceDiagram
    participant ParentComponent
    participant RichTextEditor
    participant EditorWrapper
    participant useEditor

    ParentComponent->>RichTextEditor: Render with editable={true|false}
    RichTextEditor->>EditorWrapper: Pass editable prop
    EditorWrapper->>useEditor: Pass editable prop
    useEditor-->>EditorWrapper: Editor instance (editable state set)
    EditorWrapper-->>RichTextEditor: Rendered editor
    RichTextEditor-->>ParentComponent: Editor UI (editable or read-only)
Loading

Suggested labels

🌐frontend, 🛠️refactor, ✍️editor, ready to merge

Suggested reviewers

  • Palanikannan1437
  • prateekshourya29
  • sriramveeraghanta

Poem

A single editor, bold and bright,
Now handles both "edit" and "read-only" right.
No more split, no more fuss,
Just set editable—it’s easy for us!
The code is clean, the bunnies cheer,
One rich text hop for all, far and near!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

makeplane bot commented Jun 19, 2025

Pull Request Linked with Plane Work Items

Comment Automatically Generated by Plane

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
space/core/components/editor/rich-text-editor.tsx (1)

44-44: Consider extracting the no-op function to improve performance.

The conditional logic correctly handles file uploads, but the no-op function async () => "" is recreated on every render when editable is false.

Extract the no-op function to a constant outside the component:

+const NO_OP_UPLOAD_HANDLER = async () => "";

export const RichTextEditor = forwardRef<EditorRefApi, RichTextEditorWrapperProps>((props, ref) => {
  // ... existing code ...
  fileHandler={getEditorFileHandlers({
    anchor,
-    uploadFile: editable ? props.uploadFile : async () => "",
+    uploadFile: editable ? props.uploadFile : NO_OP_UPLOAD_HANDLER,
    workspaceId,
  })}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c3c1aef and 4d93f85.

📒 Files selected for processing (22)
  • packages/editor/src/core/components/editors/editor-wrapper.tsx (3 hunks)
  • packages/editor/src/core/components/editors/lite-text/editor.tsx (1 hunks)
  • packages/editor/src/core/components/editors/rich-text/index.ts (0 hunks)
  • packages/editor/src/core/components/editors/rich-text/read-only-editor.tsx (0 hunks)
  • packages/editor/src/core/types/editor.ts (1 hunks)
  • packages/editor/src/index.ts (0 hunks)
  • space/core/components/editor/index.ts (1 hunks)
  • space/core/components/editor/rich-text-editor.tsx (2 hunks)
  • space/core/components/editor/rich-text-read-only-editor.tsx (0 hunks)
  • space/core/components/issues/peek-overview/issue-details.tsx (2 hunks)
  • web/ce/components/pages/editor/ai/ask-pi-menu.tsx (2 hunks)
  • web/ce/components/pages/editor/ai/menu.tsx (2 hunks)
  • web/core/components/core/description-versions/modal.tsx (4 hunks)
  • web/core/components/core/modals/gpt-assistant-popover.tsx (4 hunks)
  • web/core/components/editor/rich-text-editor/index.ts (0 hunks)
  • web/core/components/editor/rich-text-editor/rich-text-editor.tsx (3 hunks)
  • web/core/components/editor/rich-text-editor/rich-text-read-only-editor.tsx (0 hunks)
  • web/core/components/inbox/modals/create-modal/issue-description.tsx (1 hunks)
  • web/core/components/issues/description-input.tsx (2 hunks)
  • web/core/components/issues/issue-modal/components/description-editor.tsx (1 hunks)
  • web/core/components/profile/activity/activity-list.tsx (2 hunks)
  • web/core/components/profile/activity/profile-activity-list.tsx (2 hunks)
💤 Files with no reviewable changes (6)
  • packages/editor/src/index.ts
  • packages/editor/src/core/components/editors/rich-text/index.ts
  • web/core/components/editor/rich-text-editor/index.ts
  • web/core/components/editor/rich-text-editor/rich-text-read-only-editor.tsx
  • space/core/components/editor/rich-text-read-only-editor.tsx
  • packages/editor/src/core/components/editors/rich-text/read-only-editor.tsx
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (37)
packages/editor/src/core/types/editor.ts (1)

141-144: LGTM! Type definition correctly updated for unified editor component.

The change from interface to type alias is appropriate and the new required editable prop ensures explicit control over editor behavior. The optional dragDropEnabled prop maintains backward compatibility.

Note: The required editable prop is a breaking change that requires all consumers to explicitly specify editability, which aligns well with the PR's goal of removing implicit read-only behavior.

web/core/components/inbox/modals/create-modal/issue-description.tsx (1)

70-70: LGTM! Correctly added editable prop for issue creation context.

The editable={true} prop is appropriate since this component is used for creating and editing issue descriptions. This change aligns with the unified editor pattern and type requirements.

web/ce/components/pages/editor/ai/ask-pi-menu.tsx (2)

7-7: LGTM! Import correctly updated for unified editor component.


41-42: LGTM! Component migration preserves read-only behavior for AI response display.

The change from RichTextReadOnlyEditor to RichTextEditor with editable={false} maintains the intended read-only behavior while aligning with the unified component approach.

packages/editor/src/core/components/editors/lite-text/editor.tsx (1)

22-22: Verify if editable should be configurable for LiteTextEditor.

The addition of editable prop to EditorWrapper aligns with the unified editor approach. However, consider whether LiteTextEditor should accept an editable prop parameter to make it configurable, or if it should always be editable by design.

Based on the component name and usage pattern, hardcoding editable={true} seems appropriate, but please verify this aligns with the intended API design.

space/core/components/issues/peek-overview/issue-details.tsx (2)

3-3: LGTM! Import correctly updated for unified editor component.


28-29: LGTM! Component migration preserves read-only behavior for issue details display.

The change from RichTextReadOnlyEditor to RichTextEditor with editable={false} correctly maintains read-only behavior for the issue details peek overview while adopting the unified component pattern.

web/core/components/issues/issue-modal/components/description-editor.tsx (1)

181-181: LGTM: Correct implementation of unified editor component.

The addition of editable prop with true value is appropriate for this issue description editor, maintaining the expected editable behavior while using the unified RichTextEditor component.

space/core/components/editor/index.ts (1)

4-4: LGTM: Correct consolidation of editor exports.

The export change from read-only editor to the unified rich text editor aligns with the refactoring objective to remove dedicated read-only components.

web/ce/components/pages/editor/ai/menu.tsx (2)

11-11: LGTM: Correct import update for unified editor component.

The import change from RichTextReadOnlyEditor to RichTextEditor aligns with the refactoring to use a single editor component.


211-215: LGTM: Proper implementation of read-only behavior.

The component usage correctly maintains read-only behavior by setting editable={false} for displaying AI-generated responses, which is the appropriate configuration for this use case.

web/core/components/profile/activity/activity-list.tsx (2)

12-12: LGTM: Correct import update for unified editor component.

The import change from the read-only editor to the unified RichTextEditor component aligns with the refactoring objective.


76-77: LGTM: Proper read-only configuration for activity comments.

The component usage correctly maintains read-only behavior with editable={false} for displaying activity comments, which is appropriate for historical activity data.

packages/editor/src/core/components/editors/editor-wrapper.tsx (3)

15-15: LGTM: Proper TypeScript typing for editable prop.

The addition of the required editable: boolean prop to the Props type correctly supports the unified editor approach.


25-25: LGTM: Correct prop destructuring.

The editable prop is properly destructured from the component props, maintaining consistency with the existing code pattern.


44-44: LGTM: Proper propagation to useEditor hook.

The editable prop is correctly passed to the useEditor hook, enabling the foundational control over editor editability that supports the entire refactoring effort.

web/core/components/profile/activity/profile-activity-list.tsx (2)

10-10: LGTM - Import updated correctly for refactoring.

The import change from RichTextReadOnlyEditor to RichTextEditor aligns with the refactoring objective.


99-100: LGTM - Component usage correctly updated.

The component usage correctly switches from RichTextReadOnlyEditor to RichTextEditor with editable={false} to maintain read-only behavior.

web/core/components/core/description-versions/modal.tsx (4)

5-5: LGTM - Type import unified correctly.

The change from EditorReadOnlyRefApi to EditorRefApi unifies the editor API types.


22-22: LGTM - Component import updated for refactoring.

The import change aligns with the consolidation of editor components.


55-55: LGTM - Ref type updated correctly.

The ref type change from EditorReadOnlyRefApi to EditorRefApi maintains consistency with the unified API.


134-135: LGTM - Component usage correctly maintains read-only behavior.

The switch to RichTextEditor with editable={false} preserves the read-only functionality for version descriptions.

web/core/components/core/modals/gpt-assistant-popover.tsx (5)

10-10: LGTM - Type import unified correctly.

The API type consolidation is consistent with the refactoring.


14-14: LGTM - Component import updated for refactoring.

The import change aligns with the editor component consolidation.


58-59: LGTM - Ref types updated consistently.

Both editor refs are correctly updated to use the unified EditorRefApi type.


220-221: LGTM - Prompt editor correctly updated.

The prompt editor maintains read-only behavior with editable={false}.


235-236: LGTM - Response editor correctly updated.

The response editor maintains read-only behavior with editable={false}.

web/core/components/issues/description-input.tsx (2)

15-15: LGTM - Import updated for unified editor component.

The import change supports the consolidation of editor components.


113-161: LGTM - Excellent simplification of conditional rendering.

The refactoring eliminates the conditional logic between RichTextEditor and RichTextReadOnlyEditor, using a single component with editable={!disabled}. The addition of searchMentionCallback and uploadFile props correctly supports the editable mode requirements.

web/core/components/editor/rich-text-editor/rich-text-editor.tsx (5)

16-32: Excellent type safety with discriminated union.

The discriminated union type based on the editable prop ensures that when editable=true, the required props searchMentionCallback and uploadFile are enforced at compile time. This prevents runtime errors and provides clear API contracts.


37-37: LGTM - Prop destructuring updated correctly.

The editable prop is properly extracted for use in the component logic.


50-50: LGTM - Conditional search entity function.

The search entity function is correctly conditionally assigned based on the editable prop, using a no-op function when not editable.


59-59: LGTM - Editable prop passed correctly.

The editable prop is properly passed to the underlying RichTextEditorWithRef component.


63-63: LGTM - Conditional upload file function.

The upload file function is correctly conditionally assigned, using a no-op function when not editable to prevent file uploads in read-only mode.

space/core/components/editor/rich-text-editor.tsx (3)

12-26: Well-implemented discriminated union type for type safety.

The discriminated union pattern ensures that when editable is true, the uploadFile function is required, and when editable is false, it's properly omitted. This provides excellent compile-time type safety and prevents runtime errors.


29-29: Proper destructuring of the new required editable prop.

The explicit destructuring of the editable prop is necessary and correctly implemented to support the new unified component interface.


41-41: Correct implementation of the editable prop passing.

The editable prop is properly passed down to the underlying RichTextEditorWithRef component, completing the unified editor interface.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants