想要复制类似“ Google”的内容,当我将其粘贴到 Markdown 编辑器中时,它应该显示为 Google,这将是可点击的文本。
如何使用最新的剪贴板 API 将超链接复制到 Angular 中的剪贴板。
您可以使用的示例方法:
copyGoogleLinkMarkupToClipboard(): void {
const textArea = document.createElement("textarea");
textArea.value = "<a href='https://www.google.com'>Google</a>";
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
try {
document.execCommand('copy');
} catch (err) {
alert('unable to write to clipboard');
}
document.body.removeChild(textArea);
}