This commit is contained in:
JakubPapso committed 2024-07-11 14:52:22 +02:00
commit 9ed4ffef62
2 files changed
+50 -34

No files matched your search

+37 -5
View File
@@ -29,11 +29,6 @@
padding: 5px 20px padding: 5px 20px
min-width: 50px min-width: 50px
.description-detail
background: rgba(0, 0, 0, 0.04)
color: rgba(0, 0, 0, 0.6)
height: fit-content
.employee-selected-avatar .employee-selected-avatar
background: #6200EE background: #6200EE
color: #fff color: #fff
@@ -116,3 +111,40 @@ input[type="time"]::-webkit-calendar-picker-indicator
.mobile-view .mobile-view
flex-direction: column flex-direction: column
gap: 20px gap: 20px
.description-detail
background: rgba(0, 0, 0, 0.04)
color: rgba(0, 0, 0, 0.6)
height: fit-content
$indentSize: 15px
li
margin-left: $indentSize
&.ql-indent-1
margin-left: 2 * $indentSize
&.ql-indent-2
margin-left: 3 * $indentSize
&.ql-indent-3
margin-left: 4 * $indentSize
&.ql-indent-4
margin-left: 5 * $indentSize
&.ql-indent-5
margin-left: 6 * $indentSize
&.ql-indent-6
margin-left: 7 * $indentSize
&.ql-indent-7
margin-left: 8 * $indentSize
&.ql-indent-8
margin-left: 9 * $indentSize
&.ql-indent-9
margin-left: 10 * $indentSize
+13 -29
View File
@@ -27,45 +27,29 @@ export function prepareHTMLDescription(description) {
const os = detectOS() const os = detectOS()
// make an array from the description of strings from between <p> and </p> tags if (os === 'mac') {
const paragraphs = description.split('<p>').map(p => p.split('</p>')[0]) description = description.replace(/\\\\/g, 'smb://')
const modifiedParagraphs = paragraphs.map(paragraph => { // find all smb links and replace them with clickable links, separated by ' ', '<', '>', '"', and '(', ')' characters
const words = paragraph.split(' ') description = description = description.replace(/(smb:\/\/[^\s<>"()]+)/g, function(match) {
return '<a href="' + match.replace(/\\/g, '/') + '">' + match.replace(/\\/g, '/') + '</a>'
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>`
}) })
} else {
description = description.replace(/smb:\/\//g, '\\\\')
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) {
match = match.replaceAll('/', '\\')
return '<span style="cursor: pointer; text-decoration: underline" onclick="' + getCopyFunction(match) + '">' + match + '</span>';
});
}
return description; return description;
} }
function getCopyFunction(text) { function getCopyFunction(text) {
return ` return `
console.log('${text.replace(/\\/g, '\\\\')}')
if (navigator.clipboard && navigator.clipboard.writeText) { if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText('${text.replace(/\\/g, '\\\\')}').then(() => { navigator.clipboard.writeText('${text.replace(/\\/g, '\\\\')}').then(() => {
window.toast.success('Link copied to clipboard!') window.toast.success('Link copied to clipboard!')