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

Add copy and paste commands to terminal context menu #13535

Merged
merged 1 commit into from
Dec 6, 2022

Conversation

krassowski
Copy link
Member

@krassowski krassowski commented Dec 4, 2022

References

Closes #3011

Re-uses the same interface to Clipboard API that we use in FileEditor's context menu for over two years now (#8425, JupyterLab 2.2).

Code changes

  • add new methods to ITerminal interface: getSelection, hasSelection and paste following the underlying naming of xterjm.js implementation
  • implement the new methods in Terminal by passing them over to xterm.js methods
  • add new commands: terminal:paste and terminal:copy
  • add the new commands to context menu

User-facing changes

  • 'Refresh terminal' command now uses refresh icon when in context menu
  • 'Copy' and 'Paste' context menu actions added

Screenshot from 2022-12-04 14-44-37

When pasting for the first time the browser may (depending on browser/settings) ask for confirmation to allow access to the clipboard:

Screenshot from 2022-12-04 14-51-32

All the caveats of this not working if browser restricts Clipboard API apply, see browser compatibility table.

For example, Firefox does not permit copy in non-secure contexts (https is ok) and does not allow paste at all. This is also the case for file editor, so this is not new. Ideally we would detect support and disable the command if support is not available but this is tricky for browsers which allow support after user consent.

Backwards-incompatible changes

Adds new non-optional methods to the interface.

If would like to backport to 3.6 if time permits, making the new methods optional in backport (but required for 4.0).

@krassowski krassowski added this to the 3.6.0 milestone Dec 4, 2022
@jupyterlab-probot
Copy link

Thanks for making a pull request to jupyterlab!
To try out this branch on binder, follow this link: Binder

Copy link
Member

@fcollonval fcollonval left a comment

Choose a reason for hiding this comment

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

Thanks @krassowski

Do you have time to make the backport this week. I'll like to get a beta out this week for 3.6; so we can focus on 4.0.0?

@fcollonval fcollonval merged commit 43f4428 into jupyterlab:master Dec 6, 2022
@fcollonval
Copy link
Member

@meeseeksdev please backport to 3.6.x

It will likely fail but that will set the bot label

@lumberbot-app
Copy link

lumberbot-app bot commented Dec 6, 2022

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
git checkout 3.6.x
git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
git cherry-pick -x -m1 43f4428916cbc3a83f9faa05091cd2bee523cd1c
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
git commit -am 'Backport PR #13535: Add copy and paste commands to terminal context menu'
  1. Push to a named branch:
git push YOURFORK 3.6.x:auto-backport-of-pr-13535-on-3.6.x
  1. Create a PR against branch 3.6.x, I would have named this PR:

"Backport PR #13535 on branch 3.6.x (Add copy and paste commands to terminal context menu)"

And apply the correct labels and milestones.

Congratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon!

Remember to remove the Still Needs Manual Backport label once the PR gets merged.

If these instructions are inaccurate, feel free to suggest an improvement.

krassowski added a commit to krassowski/jupyterlab that referenced this pull request Dec 7, 2022
krassowski added a commit to krassowski/jupyterlab that referenced this pull request Dec 7, 2022
krassowski added a commit to krassowski/jupyterlab that referenced this pull request Dec 7, 2022
krassowski added a commit to krassowski/jupyterlab that referenced this pull request Dec 7, 2022
krassowski added a commit that referenced this pull request Dec 8, 2022
@dhirschfeld
Copy link
Member

For example, Firefox does not permit copy in non-secure contexts (https is ok) and does not allow paste at all. This is also the case for file editor, so this is not new. Ideally we would detect support and disable the command if support is not available but this is tricky for browsers which allow support after user consent.

Thanks for the heads-up. No paste is a bit disappointing 😢 From the link you posted it seems you also need to opt-in to the read feature on Firefox:

image

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Copy/Paste to the terminal right-click menu
3 participants