-
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: copying mentions as text #6583
base: preview
Are you sure you want to change the base?
Conversation
WalkthroughThe pull request updates several components within the editor. The Markdown extension now disables text transformation on copy, while the mention extension is enhanced with new configuration options, helper methods, and type updates to support detailed entity retrieval and markdown serialization. Additionally, the editor component now integrates a member hook to fetch user details for mentions. Changes
Sequence Diagram(s)sequenceDiagram
participant E as EditorBody
participant CME as CustomMentionExtension
participant CMC as CustomMentionConfig
participant S as MarkdownSerializer
participant U as useMember
E->>CME: Initialize mention (with new options)
CME->>CMC: Configure mention (adding getMentionedEntityDetails & renderText)
CMC->>S: Serialize mention using getMentionDisplayText
E->>U: Call getUserDetails to fetch entity details
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
✨ Finishing Touches
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.
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/core/extensions/mentions/extension-config.ts (1)
67-67
: Consider optimizing the fallback chain for mention display text.The current fallback chain (
display_name
→id
→entity_identifier
) might not be optimal. Consider prioritizingentity_identifier
overid
as it's more likely to be a meaningful identifier.- return `@${mentionEntityDetails?.display_name ?? attrs[EMentionComponentAttributeNames.ID] ?? mentionEntityId}`; + return `@${mentionEntityDetails?.display_name ?? mentionEntityId ?? attrs[EMentionComponentAttributeNames.ID]}`;web/core/components/pages/editor/editor-body.tsx (1)
193-193
: Consider adding error handling for user details retrieval.While the implementation fixes the mention text copying issue, it might benefit from error handling when user details cannot be retrieved.
Consider wrapping the user details retrieval with error handling:
- getMentionedEntityDetails: (id: string) => getUserDetails(id), + getMentionedEntityDetails: (id: string) => { + const userDetails = getUserDetails(id); + if (!userDetails) { + console.warn(`User details not found for ID: ${id}`); + return null; + } + return userDetails; + },
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
packages/editor/src/core/extensions/extensions.tsx
(1 hunks)packages/editor/src/core/extensions/mentions/extension-config.ts
(2 hunks)packages/editor/src/core/extensions/mentions/extension.tsx
(1 hunks)packages/editor/src/core/types/mention.ts
(2 hunks)web/core/components/pages/editor/editor-body.tsx
(3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Analyze (javascript)
- GitHub Check: Analyze (python)
🔇 Additional comments (6)
packages/editor/src/core/types/mention.ts (1)
2-2
: LGTM! Well-structured type enhancement.The addition of
getMentionedEntityDetails
method toTReadOnlyMentionHandler
type is well-designed:
- Clear input/output types
- Optional for backward compatibility
- Properly imports and utilizes
IUserLite
typeAlso applies to: 23-23
packages/editor/src/core/extensions/mentions/extension.tsx (1)
12-12
: LGTM! Clean integration of the new method.The
getMentionedEntityDetails
method is properly integrated into the extension configuration without affecting existing functionality.Also applies to: 18-18
packages/editor/src/core/extensions/mentions/extension-config.ts (1)
46-48
: LGTM! Well-implemented text copying for mentions.The implementation properly handles text copying through:
renderText
method for direct text copying- Markdown serialization support
- Consistent text format using
getMentionDisplayText
helperAlso applies to: 63-68
packages/editor/src/core/extensions/extensions.tsx (1)
140-140
: LGTM! Correctly disables markdown transformation for copied text.Setting
transformCopiedText
tofalse
allows the mention extension'srenderText
method to handle the text format, fixing the HTML copying issue.web/core/components/pages/editor/editor-body.tsx (2)
24-24
: LGTM!The addition of
useMember
hook follows the existing import pattern and is correctly grouped with other store hooks.
69-70
: LGTM!The
getUserDetails
hook extraction is well-placed with other store hooks and maintains consistent code style.
Description
Before: The whole html of the mention node got copied
Now: The renderText method calculates and returns the correct the text properly as
@{userDisplayName}
Type of Change
Screenshots and Media (if applicable)
Test Scenarios
References
Summary by CodeRabbit