From 25cb9014c4ff55834035aca7d1f2a43de2d68465 Mon Sep 17 00:00:00 2001 From: JakubPapso <“jakubpapso@gmail.com”> Date: Tue, 9 Jul 2024 13:35:01 +0200 Subject: [PATCH 1/3] [server links] styling support (lists, bold, italic..) --- .../plugins/tm@_utils/server-links.utils.ts | 43 ++++++------------- 1 file changed, 12 insertions(+), 31 deletions(-) diff --git a/app/src/plugins/tm@_utils/server-links.utils.ts b/app/src/plugins/tm@_utils/server-links.utils.ts index 22f972a..f52b3ff 100644 --- a/app/src/plugins/tm@_utils/server-links.utils.ts +++ b/app/src/plugins/tm@_utils/server-links.utils.ts @@ -27,45 +27,26 @@ export function prepareHTMLDescription(description) { const os = detectOS() - // make an array from the description of strings from between

and

tags - const paragraphs = description.split('

').map(p => p.split('

')[0]) + if (os === 'mac') { + description = description.replace(/\\\\/g, 'smb://') + + // find all smb links and replace them with clickable links, separated by ' ', '<', '>', '"', and '(', ')' characters + description = description.replace(/(smb:\/\/[^\s<>"()]+)/g, '$1') + } else { + description = description.replace(/smb:\/\//g, '\\\\') - const modifiedParagraphs = paragraphs.map(paragraph => { - const words = paragraph.split(' ') - 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 `${link}` - - return `${link}` - }) - - return `

${modifiedWords.join(' ')}

` - }) - - 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 '' + match + ''; + }); + } 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!') From 4de8ffec1bbc7ad8d7431ca543ddc2d69f54036a Mon Sep 17 00:00:00 2001 From: JakubPapso <“jakubpapso@gmail.com”> Date: Tue, 9 Jul 2024 15:31:02 +0200 Subject: [PATCH 2/3] [description] list indentation --- app/src/plugins/app/_theme/global.sass | 44 ++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/app/src/plugins/app/_theme/global.sass b/app/src/plugins/app/_theme/global.sass index 2382e8e..7ff4fb9 100644 --- a/app/src/plugins/app/_theme/global.sass +++ b/app/src/plugins/app/_theme/global.sass @@ -29,11 +29,6 @@ padding: 5px 20px 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 background: #6200EE color: #fff @@ -115,4 +110,41 @@ input[type="time"]::-webkit-calendar-picker-indicator @media (max-width: 534px) .mobile-view flex-direction: column - gap: 20px \ No newline at end of file + 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 \ No newline at end of file From 3e23b72257835f25bf481bebfb8b4864a1ae2d95 Mon Sep 17 00:00:00 2001 From: JakubPapso <“jakubpapso@gmail.com”> Date: Thu, 11 Jul 2024 11:35:01 +0200 Subject: [PATCH 3/3] [server links] forward / backward slashes --- app/src/plugins/tm@_utils/server-links.utils.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/plugins/tm@_utils/server-links.utils.ts b/app/src/plugins/tm@_utils/server-links.utils.ts index f52b3ff..aca5125 100644 --- a/app/src/plugins/tm@_utils/server-links.utils.ts +++ b/app/src/plugins/tm@_utils/server-links.utils.ts @@ -31,13 +31,16 @@ export function prepareHTMLDescription(description) { description = description.replace(/\\\\/g, 'smb://') // find all smb links and replace them with clickable links, separated by ' ', '<', '>', '"', and '(', ')' characters - description = description.replace(/(smb:\/\/[^\s<>"()]+)/g, '$1') + description = description = description.replace(/(smb:\/\/[^\s<>"()]+)/g, function(match) { + return '' + match.replace(/\\/g, '/') + '' + }) } else { description = description.replace(/smb:\/\//g, '\\\\') // 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 '' + match + ''; }); }