Skip to content

[PE-232] chore: management of disabled extensions#6317

Merged
pushya22 merged 3 commits intopreviewfrom
chore/mobile-editor
Jan 15, 2025
Merged

[PE-232] chore: management of disabled extensions#6317
pushya22 merged 3 commits intopreviewfrom
chore/mobile-editor

Conversation

@Palanikannan1437
Copy link
Member

@Palanikannan1437 Palanikannan1437 commented Jan 3, 2025

Description

Better management of disabled extensions

Summary by CodeRabbit

  • New Features

    • Enhanced extension configuration system with more flexible and modular approach to managing document editor extensions
    • Improved slash commands extension with optional disabled extensions configuration
  • Refactor

    • Restructured extension handling logic to support more dynamic extension management
    • Updated type definitions to provide more flexibility in component and function configurations
  • Code Quality

    • Simplified type signatures and function parameters for slash commands
    • Made extension configuration more adaptable for future extensions

@Palanikannan1437 Palanikannan1437 self-assigned this Jan 3, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 3, 2025

Walkthrough

The changes focus on refactoring the extension configuration and handling mechanism in the document editor. A new ExtensionConfig type is introduced to provide a more modular approach to managing extensions. The extensionRegistry array is created to hold extension configurations, specifically for Slash Commands. The changes make the extension handling more flexible by making disabledExtensions optional across multiple files and introducing a more abstract way of determining which extensions are enabled.

Changes

File Change Summary
packages/editor/src/ce/extensions/document-extensions.tsx - Added ExtensionConfig type
- Created extensionRegistry array
- Refactored extension filtering logic
packages/editor/src/ce/extensions/slash-commands.tsx - Made disabledExtensions optional in Props type
packages/editor/src/core/extensions/slash-commands/command-items-list.tsx - Removed TArgs type
- Updated getSlashCommandFilteredSections parameter type
packages/editor/src/core/extensions/slash-commands/root.tsx - Exported TExtensionProps type
- Made disabledExtensions optional

Sequence Diagram

sequenceDiagram
    participant Editor
    participant ExtensionRegistry
    participant SlashCommands

    Editor->>ExtensionRegistry: Request enabled extensions
    ExtensionRegistry-->>Editor: Filter and return enabled extensions
    Editor->>SlashCommands: Initialize with optional disabled extensions
Loading

Poem

🐰 In the realm of code, extensions dance free,
Optional configs, a new modularity!
Slash commands leap with configurable might,
Flexibility blooms, a programmer's delight!
Hop, hop, hooray for extensible design! 🚀


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • 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. (Beta)
  • @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
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 (2)
packages/editor/src/ce/extensions/document-extensions.tsx (2)

17-20: Add JSDoc documentation for the new type.

Consider adding documentation to explain the purpose and usage of the ExtensionConfig type, as it's a key part of the extension management system.

+/**
+ * Configuration type for document editor extensions.
+ * @property isEnabled - Function to determine if the extension is enabled based on disabled extensions list
+ * @property getExtension - Function to retrieve the extension instance with given props
+ */
 type ExtensionConfig = {
   isEnabled: (disabledExtensions: TExtensions[]) => boolean;
   getExtension: (props: Props) => AnyExtension;
 };

22-27: Consider making the registry more maintainable.

The registry could be improved by:

  1. Adding documentation for each extension configuration
  2. Making it easier to add new extensions in the future
+/**
+ * Registry of document editor extensions.
+ * Each entry configures how an extension is enabled and instantiated.
+ */
 const extensionRegistry: ExtensionConfig[] = [
   {
+    // Slash Commands extension configuration
     isEnabled: (disabledExtensions) => !disabledExtensions.includes("slash-commands"),
     getExtension: () => SlashCommands({}),
   },
 ];
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 79fff47 and ce2e9a7.

📒 Files selected for processing (4)
  • packages/editor/src/ce/extensions/document-extensions.tsx (2 hunks)
  • packages/editor/src/ce/extensions/slash-commands.tsx (1 hunks)
  • packages/editor/src/core/extensions/slash-commands/command-items-list.tsx (1 hunks)
  • packages/editor/src/core/extensions/slash-commands/root.tsx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (python)
🔇 Additional comments (3)
packages/editor/src/ce/extensions/slash-commands.tsx (1)

7-7: Verify the usage of disabledExtensions property.

The disabledExtensions property is destructured but not used in the function implementation. Consider removing the empty destructuring if the property is not needed.

Also applies to: 10-13

packages/editor/src/core/extensions/slash-commands/root.tsx (1)

106-109: Consider providing a default value for disabledExtensions.

Since disabledExtensions is now optional, ensure that functions using this type handle the undefined case appropriately.

packages/editor/src/core/extensions/slash-commands/command-items-list.tsx (1)

54-56: LGTM! Good use of nullish coalescing.

The implementation correctly handles optional properties using the nullish coalescing operator for additionalOptions.

@pushya22 pushya22 changed the title chore: management of disabled extensions [PE-232] chore: management of disabled extensions Jan 15, 2025
@pushya22 pushya22 merged commit a908bf9 into preview Jan 15, 2025
10 of 14 checks passed
@pushya22 pushya22 deleted the chore/mobile-editor branch January 15, 2025 14:53
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.

4 participants