-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
fix: character count to work properly on editor rerenders and read only mode #5554
Conversation
WalkthroughThe pull request introduces several changes across multiple files, primarily focusing on enhancing the handling of document information in the editor. The Changes
Suggested labels
Poem
Tip New featuresWalkthrough comment now includes:
Notes:
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 (
|
ff47e34
to
50d429c
Compare
There was a problem hiding this 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
Outside diff range, codebase verification and nitpick comments (1)
packages/editor/src/core/types/editor.ts (1)
23-23
: Update Required: Transition togetDocumentInfo
Method IncompleteThe transition from the
documentInfo
property to thegetDocumentInfo
method is incomplete. There are still references to the old property in the codebase that need to be updated to ensure consistency and prevent potential errors.
- File to Update:
web/core/components/pages/editor/header/info-popover.tsx
Please update all instances of
documentInfo
to use thegetDocumentInfo
method.Analysis chain
Approved: Method implementation for dynamic document information retrieval.
The change from a static property to a dynamic method in
EditorReadOnlyRefApi
enhances the API's flexibility and responsiveness. Ensure that all parts of the application that previously accessed thedocumentInfo
property are updated to call thegetDocumentInfo
method.Run the following script to verify the usage of
getDocumentInfo
across the codebase:Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all references to `getDocumentInfo` and ensure no remaining references to `documentInfo`. # Test: Search for the old property and new method usage. Expect: No occurrences of the old property. rg --type typescript -A 5 $'documentInfo' rg --type typescript -A 5 $'getDocumentInfo'Length of output: 154
Script:
#!/bin/bash # Description: Verify all references to `getDocumentInfo` and ensure no remaining references to `documentInfo`. # Test: Search for the old property and new method usage. Expect: No occurrences of the old property. rg --type ts -A 5 $'documentInfo' rg --type ts -A 5 $'getDocumentInfo'Length of output: 3440
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (5)
- packages/editor/src/core/extensions/read-only-extensions.tsx (2 hunks)
- packages/editor/src/core/hooks/use-editor.ts (1 hunks)
- packages/editor/src/core/hooks/use-read-only-editor.ts (1 hunks)
- packages/editor/src/core/types/editor.ts (1 hunks)
- web/core/components/pages/editor/header/info-popover.tsx (2 hunks)
Additional comments not posted (5)
packages/editor/src/core/extensions/read-only-extensions.tsx (2)
1-1
: Approved import statement for CharacterCount.The import statement is correctly formatted and sourced from the expected package.
108-108
: Approved addition of CharacterCount to CoreReadOnlyEditorExtensions.The addition is correctly implemented. Ensure to verify the integration and functionality in the read-only mode of the editor.
Run the following script to verify the integration of CharacterCount:
Verification successful
Integration of CharacterCount Verified
The
CharacterCount
extension is correctly integrated into both read-only and regular editor extensions. Ensure to manually verify its functionality in read-only mode to confirm expected behavior.
- Files Involved:
packages/editor/src/core/extensions/read-only-extensions.tsx
packages/editor/src/core/extensions/extensions.tsx
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the integration of CharacterCount in read-only mode. # Test: Search for the usage of CharacterCount in read-only mode. Expect: Proper integration and no errors. rg --type typescript -A 5 $'CharacterCount'Length of output: 77
Script:
#!/bin/bash # Description: Verify the integration of CharacterCount in read-only mode. # Test: Search for the usage of CharacterCount in read-only mode. Expect: Proper integration and no errors. rg --type ts -A 5 $'CharacterCount'Length of output: 1646
web/core/components/pages/editor/header/info-popover.tsx (1)
25-25
: Approved refactoring for document information retrieval.The changes centralize the document information retrieval into a single variable, enhancing code clarity and maintainability. Ensure to test these changes thoroughly to confirm that the document statistics are accurately retrieved and displayed.
Also applies to: 28-28, 37-37, 42-42, 47-47
packages/editor/src/core/hooks/use-read-only-editor.ts (1)
85-90
: Approved changes to document information retrieval method.The introduction of
getDocumentInfo
enhances modularity and reusability. Verify the integration and functionality of this new method in various scenarios to ensure it accurately retrieves document statistics.Run the following script to verify the integration of
getDocumentInfo
:Verification successful
Integration of
getDocumentInfo
is successful.The
getDocumentInfo
method is well-integrated into the codebase, as evidenced by its usage in multiple files, including a component file for displaying document statistics. This confirms its functionality and proper integration.
- Files Involved:
- Definition:
packages/editor/src/core/hooks/use-read-only-editor.ts
,packages/editor/src/core/hooks/use-editor.ts
- Usage:
web/core/components/pages/editor/header/info-popover.tsx
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the integration of `getDocumentInfo`. # Test: Search for the usage of `getDocumentInfo`. Expect: Proper integration and no errors. rg --type typescript -A 5 $'getDocumentInfo'Length of output: 78
Script:
#!/bin/bash # Description: Verify the integration of `getDocumentInfo`. # Test: Search for the usage of `getDocumentInfo`. Expect: Proper integration and no errors. rg --type ts -A 5 $'getDocumentInfo'Length of output: 2284
packages/editor/src/core/hooks/use-editor.ts (1)
233-238
: Approved: Refactored document information retrieval inuseEditor
hook.The
getDocumentInfo
method encapsulates the logic for dynamically fetching document stats, enhancing modularity and potential reuse. Ensure that this change integrates seamlessly with the rest of the editor functionalities and that all dependent components are updated to use this new method.Run the following script to verify the integration of
getDocumentInfo
with the editor functionalities:Verification successful
Verified:
getDocumentInfo
method is well-integrated into the editor functionalities.The
getDocumentInfo
method is utilized in the editor's UI components and is part of the editor's type definitions, indicating proper integration. It is implemented in bothuse-editor.ts
anduse-read-only-editor.ts
hooks, ensuring consistent functionality across different editor states.
- Usage in UI Component:
web/core/components/pages/editor/header/info-popover.tsx
- Type Definition:
packages/editor/src/core/types/editor.ts
- Implementation in Hooks:
packages/editor/src/core/hooks/use-editor.ts
,packages/editor/src/core/hooks/use-read-only-editor.ts
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the integration of `getDocumentInfo` method in the editor functionalities. # Test: Search for the usage of `getDocumentInfo` in the editor components. Expect: Proper integration without issues. rg --type typescript -A 5 $'getDocumentInfo'Length of output: 78
Script:
#!/bin/bash # Description: Verify the integration of `getDocumentInfo` method in the editor functionalities. # Test: Search for the usage of `getDocumentInfo` in the editor components. Expect: Proper integration without issues. rg --type ts -A 5 $'getDocumentInfo'Length of output: 2284
Description
Fixes the issue with Page info not being shown correctly during re rerenders and also not being shown entirely on read only editors.
Summary by CodeRabbit
New Features
Improvements
Bug Fixes