mirror of
https://github.com/hcengineering/platform.git
synced 2024-11-30 02:37:46 +03:00
[UBER-169] Allow to click and open links in contact information (#3337)
Signed-off-by: Ruslan Bayandinov <wazsone@ya.ru>
This commit is contained in:
parent
2aff844540
commit
ce34a7e6d7
@ -173,6 +173,22 @@ export function replaceURLs (text: string): string {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse first URL from the given text or html
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* replaceURLs("github.com")
|
||||||
|
* returns: "http://github.com"
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @param {string} text
|
||||||
|
* @returns {string} string with parsed URL
|
||||||
|
*/
|
||||||
|
export function parseURL (text: string): string {
|
||||||
|
const matches = autolinker.parse(text, { urls: true })
|
||||||
|
return matches.length > 0 ? matches[0].getAnchorHref() : ''
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
|
@ -19,7 +19,7 @@ import { Class, Client, DocumentQuery, Ref, RelatedDocument, WithLookup } from '
|
|||||||
import login from '@hcengineering/login'
|
import login from '@hcengineering/login'
|
||||||
import { IntlString, Resources, getResource } from '@hcengineering/platform'
|
import { IntlString, Resources, getResource } from '@hcengineering/platform'
|
||||||
import { MessageBox, ObjectSearchResult, getClient, getFileUrl } from '@hcengineering/presentation'
|
import { MessageBox, ObjectSearchResult, getClient, getFileUrl } from '@hcengineering/presentation'
|
||||||
import { AnyComponent, AnySvelteComponent, TooltipAlignment, showPopup } from '@hcengineering/ui'
|
import { AnyComponent, AnySvelteComponent, TooltipAlignment, parseURL, showPopup } from '@hcengineering/ui'
|
||||||
import AccountArrayEditor from './components/AccountArrayEditor.svelte'
|
import AccountArrayEditor from './components/AccountArrayEditor.svelte'
|
||||||
import AccountBox from './components/AccountBox.svelte'
|
import AccountBox from './components/AccountBox.svelte'
|
||||||
import AssigneeBox from './components/AssigneeBox.svelte'
|
import AssigneeBox from './components/AssigneeBox.svelte'
|
||||||
@ -240,8 +240,9 @@ async function kickEmployee (doc: Employee): Promise<void> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
async function openChannelURL (doc: Channel): Promise<void> {
|
async function openChannelURL (doc: Channel): Promise<void> {
|
||||||
if (doc.value.startsWith('http://') || doc.value.startsWith('https://')) {
|
const url = parseURL(doc.value)
|
||||||
window.open(doc.value)
|
if (url.startsWith('http://') || url.startsWith('https://')) {
|
||||||
|
window.open(url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user