eclipse-theia/theia

Investigate the possibility of improving ClipboardService usage

Open

#6,209 创建于 2019年9月18日

在 GitHub 查看
 (1 评论) (2 反应) (0 负责人)TypeScript (2,478 fork)batch import
clipboardcorehelp wanted

仓库指标

Star
 (18,676 star)
PR 合并指标
 (平均合并 15天 4小时) (30 天内合并 75 个 PR)

描述

Description

This is the follow-up issue for the PR https://github.com/eclipse-theia/theia/pull/5994.

There're two problems with the BrowserClipboardService impl which relies on Async Clipboard API for accessing the system clipboard: 1/ It works only for localhost and for the pages, loaded over https. But for non-secure http pages, it's prohibited due to the security concerns. 2/ It works well in Chrome but it requires performing additional steps in FireFox to unlock Async Clipboard API. One needs to enable API through the dom.events.testing.asyncClipboard preference. See the PR https://github.com/eclipse-theia/theia/pull/5994 description for the details.

It looks like BrowserClipboardService needs to use both Async Clipboard API and document.execCommand API to work properly for the different cases.

Note, FF requires calling document.execCommand('cut'/'copy') inside the short-living event handlers of user actions like mouse click, keypress etc. See https://github.com/eclipse-theia/theia/pull/5994#issuecomment-528883872 for the details. So it won't work when a plugin calls it through env.clipboard plugin API.

Also:

TerminalCopyOnSelectionHander has to be replaced with ClipboardService and copy on select for terminals has to be tested as a part of this issue

see https://github.com/eclipse-theia/theia/pull/6536#issuecomment-553446153

贡献者指南