Skip to content

Added RTF Copy and Cut Feature #3407

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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 !

@raclim raclim added Feature Request Area:Editor For CodeMirror-related features Status: On Hold labels Apr 10, 2025
@raclim
Copy link
Collaborator

raclim commented Apr 10, 2025

Thanks for looking into this!

I think this overall looks pretty good so far. One note is that we're currently in the process of upgrading CodeMirror to v6, which involves some major refactoring of the Editor component. Since this component will be undergoing some major changes that we're planning to implement in the near future, I put this PR on hold until these changes have come out.

@VenomHare
Copy link
Author

Sure!

I checked out the Codemirror v6 branch, and it looks like the migration mainly involves updating the event listeners for the copy and cut events. However, I'll wait for the final update before making any changes to ensure everything aligns properly.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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