當使用者選取一段帶有連結的文字時
可以直接複製成markdown的連結
有點不太確定監聽事件應該放在哪裡
還有被選取的時候該怎麼寫
請教各位前端大師
更新:已經完成 如下
const source = document.querySelector('body');
source.addEventListener('copy', (event) => {
    const selection = document.getSelection();
    var contain=selection.toString().trim();links=$("a").filter(function() {
    return $(this).text() == contain;
})[0].href
    
    if ((typeof links)=="string"){
    
    event.clipboardData.setData('text/plain', `[${contain}](${links})`);}
    event.preventDefault();
});
MDN 文檔上有寫到 Element: copy event
大概是這樣的概念
const source = document.querySelector('div.source');
source.addEventListener('copy', (event) => {
    const selection = document.getSelection();
    event.clipboardData.setData('text/plain', `[連結](${selection.toString()})`);
    event.preventDefault();
});