Skip to content
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

Added RTF Copy and Cut Feature #3407

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

VenomHare
Copy link

Fixes #445

Changes Made:

Added event listeners for copy and cut to support RTF (Rich Text Format) when copying text.
Implemented functionality based on a previous PR, but now utilizing the Copy and Cut events provided by CodeMirror.

Functionality:

The implemented solution works with:
✅ Keyboard Shortcuts: Ctrl + C (Copy) and Ctrl + X (Cut).
✅ Copy option via Context Menu.

I have verified that this pull request:

  • [✅] has no linting errors (npm run lint)
  • [✅] has no test errors (npm run test)
  • [✅] is from a uniquely-named feature branch and is up to date with the develop branch.
  • [✅] is descriptively named and links to an issue number, i.e. Fixes #445

This is my first contribution to Open Source, and I appreciate any feedback or suggestions for improvement.

Copy link

welcome bot commented Mar 18, 2025

🎉 Thanks for opening this pull request! Please check out our contributing guidelines if you haven't already.

@Jatin24062005
Copy link
Contributor

@VenomHare Thank you for looking on these. but I tested the copy and cut functionality, and it already works as expected. Copying and pasting into Google Docs maintains the original formatting. This change might not be necessary.

@VenomHare
Copy link
Author

Thanks for reviewing it, @Jatin24062005 ! While the existing functionality preserves formatting when copying to Google Docs, this change also ensures that color, font size, and weight are retained. However, I understand if the maintainers prefer not to add it unnecessarily.

@Jatin24062005
Copy link
Contributor

@VenomHare apologies for the confusion. Your approach ensures better RTF handling, and I appreciate the effort you put into this!

One small suggestion: I noticed that while the font weight and color are correctly copied, the font name itself isn’t retained. It would be even better if the copied content also preserved the font name when pasted into editors like Google Docs or Word. Would it be possible to include that as well?

@VenomHare
Copy link
Author

@Jatin24062005 Appreciate your suggestion! I looked into it and made some changes.

However, there's a limitation—CodeMirror uses the Inconsolata, monospace font, which isn't available in Google Docs by default. As a result, it falls back to Courier New. This can be fixed by manually adding the Inconsolata or another monospace font in Google Docs.

Let me know your thoughts on it !

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.

Feature-request: copy-as-rtf, copy-selection-as-rtf
2 participants