Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Add Copy Message Contents option in Context Menu #3756

Closed
wants to merge 1 commit into from

Conversation

dashwav
Copy link

@dashwav dashwav commented Dec 20, 2019

Fixes element-hq/element-web#10649 and a few hackernews comments I saw earlier today with the second option from the issue (as I think it is the more common pattern I have seen for regular messages)

First time contributing to a react project, so I did it as simply as I could - very much so open to feedback if there is a more "react" or "matrix" way of doing this.

Copies the content from a message to clipboard - tested in firefox, chrome, safari and with the electron app

Uglier solution, but has much wider support including Safari+SafariIOS

Remove unused code
@t3chguy
Copy link
Member

t3chguy commented Dec 20, 2019

See CONTRIBUTING doc https://github.com/matrix-org/matrix-react-sdk/blob/develop/CONTRIBUTING.rst

Needs sign-off

@@ -253,6 +253,16 @@ module.exports = createReactClass({
this.closeMenu();
},

onCopyClick: function(e: Event) {
const textField = document.createElement('textarea');
textField.innerText = this.props.mxEvent.event.content.body;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

event body does not have to match what is rendered due to the html portion of events so this could easily be abused to make people copy-paste things they didn't know they were.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stumbled on this, thinking out loud: This just implies there's no way to use body safely. If a client doesn't support rendering formatted_body, then it will just use body, but then it might show its users something entirely different from what users of clients which do support formatted_body will see.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yet clients do, EW/ED will use body for desktop notifications for example.

@t3chguy
Copy link
Member

t3chguy commented Mar 29, 2020

Hey @dashwav are you still interested in working on this?

Thanks

@jryans
Copy link
Collaborator

jryans commented Mar 4, 2021

Thanks for making this contribution a while back. Since the code base has changed since this was opened, it no longer applies cleanly, and I don't think there's a need to keep it open in this state, as we can always find the code here again if needed. If you are still interested in pursuing this feature, please discuss with us in #element-dev:matrix.org to find a good approach forward.

@jryans jryans closed this Mar 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add copy to clipboard button to the message action bar
4 participants