Skip to content

Conversation

aaryan610
Copy link
Member

@aaryan610 aaryan610 commented Jun 4, 2025

Description

This PR improves rich text editor extensions handling.

Type of Change

  • Code refactoring

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Added support for enabling or disabling specific editor extensions across document and rich text editors, including read-only mode.
    • Introduced the ability to pass custom file handlers and embed configurations to editor components.
    • Rich text editors now support additional extensions through a flexible registry system.
  • Improvements

    • Enhanced file and image handling to respect disabled extensions, preventing certain file types (like images) from being inserted if their extension is disabled.
    • Read-only editors can now accept custom extensions for more tailored viewing experiences.

Copy link
Contributor

coderabbitai bot commented Jun 4, 2025

Walkthrough

The changes introduce a new, unified approach for managing additional editor extensions, including support for disabling extensions and handling files. Types and function signatures are refactored for clarity and extensibility, and new modules are added for rich text and read-only editor extensions. Drop handling and utility extension logic are updated to respect disabled extensions.

Changes

Files/Groups Change Summary
packages/editor/src/ce/extensions/document-extensions.tsx Refactored types and function signatures for additional document editor extensions; unified props, added fileHandler, and improved extension registry typing.
packages/editor/src/ce/extensions/rich-text/extensions.tsx,
.../rich-text/read-only-extensions.tsx
Added new modules to manage additional rich text and read-only editor extensions with registry-based configuration and disabled extensions support.
packages/editor/src/core/components/editors/rich-text/editor.tsx Updated to accept fileHandler prop and include new additional extensions; removed direct SlashCommands extension usage.
packages/editor/src/core/components/editors/rich-text/read-only-editor.tsx Refactored to compute and pass additional read-only extensions via new module and props.
packages/editor/src/core/extensions/extensions.ts,
.../read-only-extensions.ts
Changed argument order for UtilityExtension to include disabledExtensions before fileHandler and isEditable.
packages/editor/src/core/extensions/utility.ts Updated to accept disabledExtensions in props and propagate to drop handler; refactored destructuring for file handler.
packages/editor/src/core/hooks/use-collaborative-editor.ts Changed how additional editor extensions are configured: now passes embedConfig and fileHandler instead of only issueEmbedConfig.
packages/editor/src/core/plugins/drop.ts Refactored to accept disabledExtensions in handler and block image insertion if disabled; updated function signatures accordingly.
packages/editor/src/core/types/editor.ts Added optional extensions property to IReadOnlyEditorProps.
packages/editor/src/core/components/editors/read-only-editor-wrapper.tsx Added extensions prop to ReadOnlyEditorWrapper and passed it to useReadOnlyEditor hook.

Sequence Diagram(s)

sequenceDiagram
  participant Editor
  participant ExtensionsRegistry
  participant UtilityExtension
  participant DropHandlerPlugin

  Editor->>ExtensionsRegistry: Provide { disabledExtensions, fileHandler, ... }
  ExtensionsRegistry->>ExtensionsRegistry: Filter enabled extensions
  ExtensionsRegistry->>Editor: Return array of enabled extensions
  Editor->>UtilityExtension: Pass { disabledExtensions, fileHandler, isEditable }
  UtilityExtension->>DropHandlerPlugin: Pass { editor, disabledExtensions }
  DropHandlerPlugin->>DropHandlerPlugin: On drop/paste, check disabledExtensions
  DropHandlerPlugin->>Editor: Insert files only if not disabled
Loading

Suggested labels

ready to merge

Suggested reviewers

  • prateekshourya29
  • Palanikannan1437

Poem

In fields of code where editors grow,
Extensions now can come or go.
With files in paw and types anew,
A rabbit hops through changes true.
Drop an image? Only if allowed—
Disabled ones are not endowed!
🐇✨


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 270ca86 and 4bba998.

📒 Files selected for processing (1)
  • packages/editor/src/core/components/editors/read-only-editor-wrapper.tsx (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (2)
packages/editor/src/core/components/editors/read-only-editor-wrapper.tsx (2)

18-18: LGTM! Extension prop extraction follows existing pattern.

The addition of the extensions prop to the destructuring is consistent with the existing code structure and aligns with the broader refactoring to improve editor extension handling.


29-29:

✅ Verification successful

Verify hook signature consistency.

The extensions prop is being passed to the useReadOnlyEditor hook. Please ensure that the hook signature has been updated to accept this parameter.


🏁 Script executed:

#!/bin/bash
# Description: Verify that useReadOnlyEditor hook accepts the extensions parameter
# Expected: The hook should have extensions in its parameter interface

# Search for the useReadOnlyEditor hook definition
ast-grep --pattern $'export const useReadOnlyEditor = ($$$) => {
  $$$
}'

# Also search for any interface or type definition for useReadOnlyEditor parameters
rg -A 10 "useReadOnlyEditor.*\(" --type ts --type tsx

Length of output: 7765


No action needed: useReadOnlyEditor already accepts extensions
The hook signature in use-read-only-editor.ts destructures and defaults the extensions prop:

  • packages/editor/src/core/hooks/use-read-only-editor.ts: lines 36–37 – extensions = []
✨ 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 4, 2025

Pull Request Linked with Plane Work Items

Comment Automatically Generated by Plane

@aaryan610 aaryan610 changed the title [WIKI-412] chore: code split for rich text editor extensions [WIKI-412] chore: improved rich text editor extensions handling Jun 4, 2025
@sriramveeraghanta sriramveeraghanta merged commit 2792d48 into preview Jun 4, 2025
5 of 6 checks passed
@sriramveeraghanta sriramveeraghanta deleted the chore/rich-text-code-split branch June 4, 2025 10:02
lifeiscontent pushed a commit that referenced this pull request Aug 18, 2025
* chore: code split for rich text editor extensions

* chore: update type

* chore: add missing prop
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