# gpui_web: Implement clipboard write and paste \(\#60890\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 084b5d21f67cdbe06edd2822ce34e58b3cd774f7

Requested commit: 084b5d21f67cdbe06edd2822ce34e58b3cd774f7

Commit: 084b5d21f67cdbe06edd2822ce34e58b3cd774f7

Tree: 4b7200b377316c403ceb9258ba9741d416c64e15

Author: Baris Palaska

Committer: GitHub

## Message

```
gpui_web: Implement clipboard write and paste (#60890)

# Objective

write_to_clipboard was a no-op and read_from_clipboard returned None.

## Solution

Writes go through the browser's asynchronous Clipboard API,
fire-and-forget, invoked synchronously inside the user's input event so
the user-activation requirement holds.

Reads cannot be implemented the same way: the async clipboard read API
cannot fit read_from_clipboard's synchronous signature. Paste is instead
delivered by a DOM paste listener on the hidden input, whose
ClipboardEvent exposes clipboardData synchronously; the text feeds the
active input handler. This covers keyboard-, menu-bar- and
context-menu-initiated paste. Note the keyboard path requires the paste
chord's keydown to reach the browser unconsumed (apps should not bind
cmd/ctrl-v on web).

## Testing

Tested locally

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- N/A
```

## Parents

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

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