naive-ui
naive-ui copied to clipboard
support vscode naive-ui doc copy
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 }, '*');
}
});
How should we support
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 }, '*');
}
});
Seems to be the problem of vscode. A simple workaround could help, according to this comment.