Skip to content

[WEB-3489] improvement: add support to disable extensions in rich and lite text editor#6721

Merged
sriramveeraghanta merged 2 commits intopreviewfrom
improvement-disabled-extensions
Mar 7, 2025
Merged

[WEB-3489] improvement: add support to disable extensions in rich and lite text editor#6721
sriramveeraghanta merged 2 commits intopreviewfrom
improvement-disabled-extensions

Conversation

@prateekshourya29
Copy link
Member

@prateekshourya29 prateekshourya29 commented Mar 7, 2025

Description

In this PR, I have added an option to disable rich text editor extensions.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Improvement (change that would cause existing functionality to not work as expected)
  • Code refactoring
  • Performance improvements
  • Documentation update

References

WEB-3489

Summary by CodeRabbit

  • New Features
    • Introduced a customizable option in the rich text editor that allows developers to disable specific extensions. This enhancement enables a more tailored editing experience by merging preset and user-specified disabled extensions.
    • Enhanced flexibility in the LiteTextEditor and LiteTextReadOnlyEditor components by allowing the disabledExtensions property to be optional.
    • Updated handling of the disabledExtensions prop in the RichTextReadOnlyEditor, allowing for a dynamic configuration of disabled extensions.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 7, 2025

Walkthrough

The changes introduce an optional property, disabledExtensions, to the RichTextEditorWrapperProps interface and other related editor components. The MakeOptional utility type is utilized to make disabledExtensions optional while omitting other properties. The destructuring of props is updated to handle the new property, which is renamed to additionalDisabledExtensions. The components now merge both the default disabled extensions and the provided additional extensions before passing them to their respective editor components.

Changes

File Change Summary
web/core/…/rich-text-editor.tsx Updated RichTextEditorWrapperProps to use MakeOptional, made disabledExtensions optional, modified props destructuring, and merged default and additional disabled extensions.
packages/types/src/utils.d.ts Added type alias MakeOptional<T, K extends keyof T> for optional properties.
space/core/…/lite-text-editor.tsx Updated LiteTextEditorWrapperProps to use MakeOptional, made disabledExtensions optional, and merged disabled extensions in LiteTextEditor.
space/core/…/lite-text-read-only-editor.tsx Updated LiteTextReadOnlyEditorWrapperProps to use MakeOptional, made disabledExtensions optional, and modified props handling in LiteTextReadOnlyEditor.
space/core/…/rich-text-read-only-editor.tsx Updated RichTextReadOnlyEditorWrapperProps to use MakeOptional, made disabledExtensions optional, and modified props handling in RichTextReadOnlyEditor.
web/core/…/lite-text-editor/lite-text-editor.tsx Updated LiteTextEditorWrapperProps to use MakeOptional, made disabledExtensions optional, and merged disabled extensions in LiteTextEditor.
web/core/…/lite-text-editor/lite-text-read-only-editor.tsx Updated LiteTextReadOnlyEditorWrapperProps to use MakeOptional, made disabledExtensions optional, and modified props handling in LiteTextReadOnlyEditor.

Sequence Diagram(s)

sequenceDiagram
    participant C as Caller
    participant R as RichTextEditor
    participant W as RichTextEditorWithRef

    C->>R: Call with props (including additionalDisabledExtensions)
    R->>R: Retrieve default disabledExtensions
    R->>R: Merge default with additionalDisabledExtensions
    R->>W: Pass merged disabledExtensions
Loading

Possibly related PRs

Suggested labels

🌟improvement, 🛠️refactor, ✍️editor, pages

Suggested reviewers

  • aaryan610
  • SatishGandham

Poem

I'm a rabbit in the code field, so spry,
Hopping on changes as I pass by.
Extensions merged in a graceful run,
Bringing clarity like a ray of sun.
With every byte and line that's new,
I cheer, "Hooray for code that grew!" 🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 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.

@prateekshourya29 prateekshourya29 marked this pull request as draft March 7, 2025 08:38
@prateekshourya29 prateekshourya29 changed the title [WEB-3489] improvement: add support to disable extensions in rich text editor [WEB-3489] improvement: add support to disable extensions in rich and lite text editor Mar 7, 2025
@prateekshourya29 prateekshourya29 marked this pull request as ready for review March 7, 2025 08:55
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)
web/core/components/editor/lite-text-editor/lite-text-editor.tsx (1)

53-53: Good approach for combining default and custom disabled extensions.

The renaming of disabledExtensions to additionalDisabledExtensions in the destructuring and the merging of both arrays of disabled extensions is a good approach, allowing users to add their own extensions on top of the default ones from useEditorFlagging.

Note: This implementation is slightly different from the other editor components where the prop is still called disabledExtensions and there's no array merging. Consider standardizing this approach across all editor components if they should behave consistently.

Also applies to: 86-86

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7c4210c and 24b08bb.

📒 Files selected for processing (9)
  • packages/types/src/utils.d.ts (1 hunks)
  • space/core/components/editor/lite-text-editor.tsx (4 hunks)
  • space/core/components/editor/lite-text-read-only-editor.tsx (1 hunks)
  • space/core/components/editor/rich-text-editor.tsx (1 hunks)
  • space/core/components/editor/rich-text-read-only-editor.tsx (1 hunks)
  • web/core/components/editor/lite-text-editor/lite-text-editor.tsx (4 hunks)
  • web/core/components/editor/lite-text-editor/lite-text-read-only-editor.tsx (3 hunks)
  • web/core/components/editor/rich-text-editor/rich-text-editor.tsx (4 hunks)
  • web/core/components/editor/rich-text-editor/rich-text-read-only-editor.tsx (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/core/components/editor/rich-text-editor/rich-text-editor.tsx
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (22)
packages/types/src/utils.d.ts (1)

7-7: Good addition of a useful type utility.

The MakeOptional type utility is a well-crafted helper that allows making specific properties of a type optional while keeping others required. This is a clean implementation using TypeScript's built-in utility types.

space/core/components/editor/lite-text-read-only-editor.tsx (2)

4-4: Appropriate use of MakeOptional type.

Good job using the new MakeOptional utility type to make the disabledExtensions property optional while keeping other properties required. This improves the flexibility of the component.

Also applies to: 11-14


20-23: Proper handling of optional disabledExtensions prop.

The component now correctly handles the optional disabledExtensions prop using the nullish coalescing operator (??) to default to an empty array when undefined.

space/core/components/editor/rich-text-read-only-editor.tsx (2)

4-4: Appropriate use of MakeOptional type.

Good job using the new MakeOptional utility type to make the disabledExtensions property optional while keeping other properties required. This improves the flexibility of the component.

Also applies to: 11-14


20-23: Proper handling of optional disabledExtensions prop.

The component now correctly handles the optional disabledExtensions prop using the nullish coalescing operator (??) to default to an empty array when undefined.

web/core/components/editor/lite-text-editor/lite-text-editor.tsx (1)

9-9: Appropriate use of MakeOptional type.

Good job using the new MakeOptional utility type to make the disabledExtensions property optional while keeping other properties required. This improves the flexibility of the component's API.

Also applies to: 22-24

space/core/components/editor/lite-text-editor.tsx (4)

4-4: Nice addition of MakeOptional utility

Good use of the MakeOptional utility type from @plane/types to make specific properties optional without affecting others.


12-13: Clean type definition update

The interface has been properly updated to make only the disabledExtensions property optional while keeping the type safety for other properties.


29-29: Good addition of disabledExtensions to destructured props

Correctly extracting the new property from props.


43-43: Property handling with nullish coalescing

Well-implemented fallback using the nullish coalescing operator to provide an empty array when the property is not specified.

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

4-4: Consistent import of MakeOptional

Good use of the MakeOptional utility type, consistent with other editor components.


10-11: Clean type definition update

The interface properly uses MakeOptional to make just the disabledExtensions property optional.


18-18: Properly destructured disabledExtensions prop

Good extraction of the new property from props.


26-26: Consistent handling of optional disabledExtensions

The nullish coalescing operator is used appropriately to provide a default empty array.

web/core/components/editor/rich-text-editor/rich-text-read-only-editor.tsx (4)

4-4: Consistent import of MakeOptional

Appropriate import of the MakeOptional utility type, consistent with other editor components.


14-17: Well-structured type definition

Good use of MakeOptional in type definition, making just the disabledExtensions property optional.


24-24: Thoughtful prop renaming

Excellent approach to rename disabledExtensions to additionalDisabledExtensions, which clarifies its purpose when merging with existing disabled extensions.


33-33: Smart extension merging approach

Well-implemented merging of extensions from the hook and the additional extensions from props, providing flexibility in disabling extensions from multiple sources.

web/core/components/editor/lite-text-editor/lite-text-read-only-editor.tsx (4)

4-4: Consistent import of MakeOptional

Appropriate import of the MakeOptional utility type, consistent with other editor components.


14-17: Well-structured type definition

Good use of MakeOptional in type definition, making just the disabledExtensions property optional.


24-24: Thoughtful prop renaming

Excellent approach to rename disabledExtensions to additionalDisabledExtensions, which clarifies its purpose when merging with existing disabled extensions.


33-33: Smart extension merging approach

Well-implemented merging of extensions from the hook and the additional extensions from props, providing flexibility in disabling extensions from multiple sources.

@prateekshourya29 prateekshourya29 self-assigned this Mar 7, 2025
@sriramveeraghanta sriramveeraghanta merged commit a953013 into preview Mar 7, 2025
5 of 6 checks passed
@sriramveeraghanta sriramveeraghanta deleted the improvement-disabled-extensions branch March 7, 2025 11:04
@sriramveeraghanta sriramveeraghanta added this to the v0.25.2 milestone Mar 9, 2025
lifeiscontent pushed a commit that referenced this pull request Aug 18, 2025
… lite text editor (#6721)

* [WEB-3489] improvement: add support to disable extensions in rich text editor

* improvements: disabled extensions prop for all editor components
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants