[PE-232] chore: management of disabled extensions#6317
Conversation
WalkthroughThe changes focus on refactoring the extension configuration and handling mechanism in the document editor. A new Changes
Sequence DiagramsequenceDiagram
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
Poem
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
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
ExtensionConfigtype, 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:
- Adding documentation for each extension configuration
- 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
📒 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 ofdisabledExtensionsproperty.The
disabledExtensionsproperty 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 fordisabledExtensions.Since
disabledExtensionsis 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.
Description
Better management of disabled extensions
Summary by CodeRabbit
New Features
Refactor
Code Quality