naive-ui icon indicating copy to clipboard operation
naive-ui copied to clipboard

support vscode naive-ui doc copy

Open Simon-He95 opened this issue 2 years ago • 3 comments

This function solves the problem (这个功能解决的问题)

I want to open doc in vscode webview,it will be more helpful to solve the problem of frequent switching between browsers and vscode

Expected API (期望的 API)

document.addEventListener('keydown', e => {
if ((e.metaKey || e.ctrlKey) && e.key === 'c') {
const selection = document.getSelection();
if (!selection || !selection.toString()) return;
const text = selection.toString();
window.parent.postMessage({ eventType: 'copy', text }, '*');
}
});

Simon-He95 avatar Sep 18 '23 13:09 Simon-He95

How should we support

jahnli avatar Jan 24 '25 09:01 jahnli

Because I will use the official iframe document in vscode, I hope to send the copy and shortcut key ctrl+c events to window.parent. I also posted the code above.

document.addEventListener('keydown', e => {
if ((e.metaKey || e.ctrlKey) && e.key === 'c') {
const selection = document.getSelection();
if (!selection || !selection.toString()) return;
const text = selection.toString();
window.parent.postMessage({ eventType: 'copy', text }, '*');
}
});

Simon-He95 avatar Jan 24 '25 12:01 Simon-He95

Seems to be the problem of vscode. A simple workaround could help, according to this comment.

neko-para avatar Jun 11 '25 07:06 neko-para