[macos links via href]

This commit is contained in:
JakubPapso committed 2024-07-03 15:43:32 +02:00
1 parent d547ded59f
commit 86d97c0130
1 file changed
+6 -3
@@ -50,7 +50,9 @@ export function prepareHTMLDescription(description) {
if (!link) return word
return `<span style="cursor: pointer" onclick="${getCopyFunction(link)}">${link}</span>`
if (os === 'mac') return `<a href="${link}">${link}</a>`
return `<span style="cursor: pointer; text-decoration: underline" onclick="${getCopyFunction(link)}">${link}</span>`
})
return `<p>${modifiedWords.join(' ')}</p>`
@@ -63,8 +65,9 @@ export function prepareHTMLDescription(description) {
function getCopyFunction(text) {
return `
console.log('${text.replace(/\\/g, '\\\\')}')
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText('${text}').then(() => {
navigator.clipboard.writeText('${text.replace(/\\/g, '\\\\')}').then(() => {
window.toast.success('Link copied to clipboard!')
}).catch(err => {
window.toast.error('Failed to copy link to clipboard!')
@@ -74,7 +77,7 @@ function getCopyFunction(text) {
input.style.position = 'fixed';
input.style.opacity = 0;
input.style.pointerEvents = 'none';
input.value = '\\\\${text}';
input.value = '${text.replace(/\\/g, '\\\\')}';
document.body.appendChild(input);
input.select();
input.focus();