cinny
cinny copied to clipboard
Add code block copy and collapse functionality
Description
The ability to copy and collapse code blocks have been requested in #1110 and #1592. This PR aims to add this functionality in a similar way to Element web and Discord.
This PR makes it so that:
- Large code blocks (currently more than 14 lines) are collapsed into a scrollable 10-line preview that can be expanded to the full message length
- Adds a copy button that copies the contents of the code block
- Adds a collapse/expand button to code blocks
This prevents large code blocks from clogging up conversations.
Example Images
Collapsed, non-hovered
Expanded, hovered
Fixes #1110, Fixes #1592
Type of change
- [x] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [o] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [o] This change requires a documentation update
Checklist:
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings