提交 dfbab756 编写于 作者: P Peng Lyu

Fix #83598. Copy from Problems Panel

上级 9cd06aca
......@@ -18,7 +18,24 @@ export class BrowserClipboardService implements IClipboardService {
return; // TODO@sbatten
}
return navigator.clipboard.writeText(text);
if (navigator.clipboard && navigator.clipboard.writeText) {
return navigator.clipboard.writeText(text);
} else {
const activeElement = <HTMLElement>document.activeElement;
const newTextarea = document.createElement('textarea');
newTextarea.className = 'clipboard-copy';
newTextarea.style.visibility = 'false';
newTextarea.style.height = '1px';
newTextarea.style.width = '1px';
document.body.appendChild(newTextarea);
newTextarea.value = text;
newTextarea.focus();
newTextarea.select();
document.execCommand('copy');
activeElement.focus();
document.body.removeChild(newTextarea);
}
return;
}
async readText(type?: string): Promise<string> {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册