Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Adding copy/paste provider API proposal #107283

Merged
merged 2 commits into from
May 25, 2022
Merged

Conversation

mjbvz
Copy link
Collaborator

@mjbvz mjbvz commented Sep 23, 2020

For #30066

This adds a new documentCopyPaste api proposal that lets extensions hook into copy and paste

This can be used to do things such as:

  • Create link when pasting an image
  • Bring along imports when copy and pasting code

@mjbvz mjbvz self-assigned this Sep 23, 2020
@mjbvz mjbvz force-pushed the dev/mjbvz/copypaste-actions branch from 9401beb to 7806751 Compare September 23, 2020 19:17
@joaomoreno joaomoreno changed the base branch from master to main February 15, 2021 08:51
@mjbvz mjbvz force-pushed the dev/mjbvz/copypaste-actions branch from 94ca340 to 13d6df2 Compare May 10, 2022 23:03
@mjbvz mjbvz changed the title Initial sketches for copy/paste action provider API Adding copy/paste provider API proposal May 10, 2022
@mjbvz mjbvz added this to the May 2022 milestone May 10, 2022
@mjbvz mjbvz marked this pull request as ready for review May 10, 2022 23:05
For #30066

This adds a new `documentPaste` api proposal that lets extensions hook into copy and paste.

This can be used to do things such as:

- Create link when pasting an image
- Bring along imports when copy and pasting code
@mjbvz mjbvz force-pushed the dev/mjbvz/copypaste-actions branch from a43762b to da6ea9d Compare May 23, 2022 23:55
@mjbvz mjbvz enabled auto-merge (squash) May 23, 2022 23:56
Copy link
Collaborator Author

@mjbvz mjbvz left a comment

Choose a reason for hiding this comment

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

Notes from discussions:

  • Right now we always apply the first edit from a paste provider. In the future we may instead want to show UI on paste that lets users select which edit to use

  • Instead of returning a WorkspaceEdit directly, we may want to return a new type such as PasteAction that has a WorkspaceEdit. This would let extensions provide names if we show the action in the UI, and also potentially let us split the paste into two phases: provide and resolve

  • The current implementation does not apply data transfer contributed by extensions to the global clipboard

    This means that you cannot copy and paste data that comes from a provider in VS Code into out into another application. This is likely something we can fix, but means we would need permissions to access the clipboard api

Copy link
Member

@jrieken jrieken left a comment

Choose a reason for hiding this comment

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

Looking good, but API proposals need to be enforced 👮🏼‍♂️

src/vs/editor/browser/widget/codeEditorWidget.ts Outdated Show resolved Hide resolved
@mjbvz mjbvz merged commit e4f7f6a into main May 25, 2022
@mjbvz mjbvz deleted the dev/mjbvz/copypaste-actions branch May 25, 2022 10:27
@lramos15 lramos15 mentioned this pull request Jun 2, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jul 10, 2022
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.

2 participants