mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 14:29:34 +00:00
merge
This commit is contained in:
commit
01314fcccc
1 file changed
+11
-30
@@ -27,45 +27,26 @@ export function prepareHTMLDescription(description) {
|
||||
|
||||
const os = detectOS()
|
||||
|
||||
// make an array from the description of strings from between <p> and </p> tags
|
||||
const paragraphs = description.split('<p>').map(p => p.split('</p>')[0])
|
||||
if (os === 'mac') {
|
||||
description = description.replace(/\\\\/g, 'smb://')
|
||||
|
||||
const modifiedParagraphs = paragraphs.map(paragraph => {
|
||||
const words = paragraph.split(' ')
|
||||
// find all smb links and replace them with clickable links, separated by ' ', '<', '>', '"', and '(', ')' characters
|
||||
description = description.replace(/(smb:\/\/[^\s<>"()]+)/g, '<a href="$1">$1</a>')
|
||||
} else {
|
||||
description = description.replace(/smb:\/\//g, '\\\\')
|
||||
|
||||
const modifiedWords = words.map(word => {
|
||||
let link = null
|
||||
|
||||
if (os === 'mac' && word.startsWith('smb://')) {
|
||||
link = word
|
||||
} else if (os === 'win' && word.startsWith('\\\\')) {
|
||||
link = `${word.replace(/\//g, '\\')}`
|
||||
} else if (os === 'mac' && word.startsWith('\\\\')) {
|
||||
const smbLink = 'smb:' + word.replace(/\\/g, '/')
|
||||
link = smbLink
|
||||
} else if (os === 'win' && word.startsWith('smb://')) {
|
||||
const windowsLink = word.replace(/^smb:/, '').replace(/\//g, '\\')
|
||||
link = `${windowsLink}`
|
||||
}
|
||||
|
||||
if (!link) return word
|
||||
|
||||
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>`
|
||||
})
|
||||
|
||||
description = modifiedParagraphs.join('')
|
||||
// find all windows links and replace them with clickable links, separated by ' ', '<', '>', '"', and '(', ')' characters
|
||||
description = description.replace(/(\\\\[^\s<>"()]+)/g, function(match) {
|
||||
return '<span style="cursor: pointer; text-decoration: underline" onclick="' + getCopyFunction(match) + '">' + match + '</span>';
|
||||
});
|
||||
}
|
||||
|
||||
return description;
|
||||
}
|
||||
|
||||
function getCopyFunction(text) {
|
||||
return `
|
||||
console.log('${text.replace(/\\/g, '\\\\')}')
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||
navigator.clipboard.writeText('${text.replace(/\\/g, '\\\\')}').then(() => {
|
||||
window.toast.success('Link copied to clipboard!')
|
||||
|
||||
Reference in new issue
Block a user