diff --git a/packages/ui/src/panelup.ts b/packages/ui/src/panelup.ts index ff1522ab49..7cb9db0fb6 100644 --- a/packages/ui/src/panelup.ts +++ b/packages/ui/src/panelup.ts @@ -16,13 +16,16 @@ let currentLocation: string | undefined location.subscribe((loc) => { if (loc.fragment !== currentLocation && loc.fragment !== undefined && loc.fragment.trim().length > 0) { const props = decodeURIComponent(loc.fragment).split('|') - showPanel( - props[0] as AnyComponent, - props[1], - props[2], - (props[3] ?? undefined) as PopupAlignment, - (props[4] ?? undefined) as AnyComponent - ) + + if (props.length >= 3) { + showPanel( + props[0] as AnyComponent, + props[1], + props[2], + (props[3] ?? undefined) as PopupAlignment, + (props[4] ?? undefined) as AnyComponent + ) + } } else if ( (loc.fragment === undefined || (loc.fragment !== undefined && loc.fragment.trim().length === 0)) && currentLocation !== undefined diff --git a/plugins/chunter-assets/lang/en.json b/plugins/chunter-assets/lang/en.json index bd152c4291..7362e14e02 100644 --- a/plugins/chunter-assets/lang/en.json +++ b/plugins/chunter-assets/lang/en.json @@ -65,6 +65,7 @@ "ThreadMessage": "Thread message", "ChunterBrowser": "Search", "Messages": "Messages", - "NoResults": "No results" + "NoResults": "No results", + "CopyLink": "Copy link" } } \ No newline at end of file diff --git a/plugins/chunter-assets/lang/ru.json b/plugins/chunter-assets/lang/ru.json index 9a9588123e..ca8a9a42de 100644 --- a/plugins/chunter-assets/lang/ru.json +++ b/plugins/chunter-assets/lang/ru.json @@ -64,6 +64,7 @@ "ThreadMessage": "Сообщение в обсуждении", "ChunterBrowser": "Поиск", "Messages": "Сообщения", - "NoResults": "Нет результатов" + "NoResults": "Нет результатов", + "CopyLink": "Копировать ссылку" } } \ No newline at end of file diff --git a/plugins/chunter-resources/src/components/Channel.svelte b/plugins/chunter-resources/src/components/Channel.svelte index 4887450cca..640eb06d32 100644 --- a/plugins/chunter-resources/src/components/Channel.svelte +++ b/plugins/chunter-resources/src/components/Channel.svelte @@ -19,6 +19,7 @@ import core, { Doc, Ref, Space, Timestamp, WithLookup } from '@anticrm/core' import { NotificationClientImpl } from '@anticrm/notification-resources' import { createQuery } from '@anticrm/presentation' + import { getCurrentLocation, navigate } from '@anticrm/ui' import { afterUpdate, beforeUpdate } from 'svelte' import chunter from '../plugin' import { getDay } from '../utils' @@ -34,12 +35,27 @@ let div: HTMLDivElement | undefined let autoscroll: boolean = false + let messageIdForScroll = '' + let isMessageHighlighted = false beforeUpdate(() => { autoscroll = div !== undefined && div.offsetHeight + div.scrollTop > div.scrollHeight - 20 }) afterUpdate(() => { + if (messageIdForScroll && !isMessageHighlighted) { + const messageElement = document.getElementById(messageIdForScroll) + + messageElement?.scrollIntoView() + isMessageHighlighted = true + + setTimeout(() => { + messageIdForScroll = '' + isMessageHighlighted = false + }, 2000) + + return + } if (div && (autoscroll || isScrollForced)) { div.scrollTo(0, div.scrollHeight) isScrollForced = false @@ -85,6 +101,15 @@ messages = res newMessagesPos = newMessagesStart(messages) notificationClient.updateLastView(space, chunter.class.ChunterSpace) + + const location = getCurrentLocation() + const messageId = location.fragment + + if (messageId && location.path.length === 3) { + messageIdForScroll = messageId + location.fragment = undefined + navigate(location) + } }, { lookup: { @@ -205,6 +230,7 @@ {/if} { + const location = getCurrentLocation() + + location.fragment = message._id + location.path[2] = message.space + + if (message.attachedToClass === chunter.class.Message) { + location.path.length = 4 + location.path[3] = message.attachedTo + } else { + location.path.length = 3 + } + await navigator.clipboard.writeText(`${window.location.origin}${locationToUrl(location)}`) + } + } + let menuShowed = false const showMenu = async (ev: Event): Promise => { @@ -115,6 +144,7 @@ await impl(message, evt) } })), + copyLinkAction, ...(getCurrentAccount()._id === message.createBy ? [editAction, deleteAction] : []) ] }, @@ -176,7 +206,7 @@ } -
+
@@ -253,11 +283,20 @@