# markdown: Add support for right-click menu copy item \(\#45572\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/1281f4672c64cd44ea7f6b9f3d55a7b8ae4dc8e3)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 1281f4672c64cd44ea7f6b9f3d55a7b8ae4dc8e3

Requested commit: 1281f4672c64cd44ea7f6b9f3d55a7b8ae4dc8e3

Commit: 1281f4672c64cd44ea7f6b9f3d55a7b8ae4dc8e3

Tree: 9d53a9f35e8584d7cca929bffc94a7b7da22df9e

Author: Danilo Leal

Committer: GitHub

## Message

```
markdown: Add support for right-click menu copy item (#45572)

In https://github.com/zed-industries/zed/pull/45440, we're implementing
the ability to right-click in the agent panel and copy the rendered
markdown. However, that presented itself as not as straightforward as
just making the menu item fire the `CopyAsMarkdown` action because any
selection in markdown is cleared after a new mouse click, and for the
right-click copy menu item to work, we need to persist that selection
even after the menu itself is opened and the "Copy" menu item is
clicked.

This all demanded a bit of work in the markdown file itself, and given
we may want to use this functionality for other non-agent thread view
markdown use cases in the future, I felt like it'd be better breaking it
down into a separate PR that we can more easily track in the future.

The context menu still needs to be built in the place where the markdown
is created and rendered, though. This PR only adds the infrastructure
needed so that this menu can simply fire the `CopyAsMarkdown` and make
the copying work.

Release Notes:

- N/A
```

## Parents

- [ed705c0cbc089374c91b97568e993e3279744298](https://git.cafe/gitcafe/zed/commit/ed705c0cbc089374c91b97568e993e3279744298?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/1281f4672c64cd44ea7f6b9f3d55a7b8ae4dc8e3?format=markdown)
