diff --git a/packages/presentation/src/utils.ts b/packages/presentation/src/utils.ts index ed6d4739b6..65975ed3eb 100644 --- a/packages/presentation/src/utils.ts +++ b/packages/presentation/src/utils.ts @@ -148,6 +148,20 @@ export async function getBlobURL (blob: Blob): Promise { }) } +export async function copyTextToClipboard (text: string): Promise { + try { + // Safari specific behavior + // see https://bugs.webkit.org/show_bug.cgi?id=222262 + const clipboardItem = new ClipboardItem({ + 'text/plain': Promise.resolve(text) + }) + await navigator.clipboard.write([clipboardItem]) + } catch { + // Fallback to default clipboard API implementation + await navigator.clipboard.writeText(text) + } +} + export type AttributeCategory = 'attribute' | 'inplace' | 'collection' | 'array' export const AttributeCategoryOrder = { attribute: 0, inplace: 1, collection: 2, array: 2 } diff --git a/plugins/chunter-resources/src/components/Message.svelte b/plugins/chunter-resources/src/components/Message.svelte index 5fa4f708b0..6080c1bc81 100644 --- a/plugins/chunter-resources/src/components/Message.svelte +++ b/plugins/chunter-resources/src/components/Message.svelte @@ -21,7 +21,7 @@ import { Ref, WithLookup, getCurrentAccount } from '@hcengineering/core' import { NotificationClientImpl } from '@hcengineering/notification-resources' import { getResource } from '@hcengineering/platform' - import { Avatar, getClient, MessageViewer } from '@hcengineering/presentation' + import { Avatar, copyTextToClipboard, getClient, MessageViewer } from '@hcengineering/presentation' import ui, { ActionIcon, IconMoreH, @@ -121,7 +121,7 @@ } else { location.path.length = 4 } - await navigator.clipboard.writeText(`${window.location.origin}${locationToUrl(location)}`) + await copyTextToClipboard(`${window.location.origin}${locationToUrl(location)}`) } } diff --git a/plugins/contact-resources/src/components/ChannelEditor.svelte b/plugins/contact-resources/src/components/ChannelEditor.svelte index 5a4046e498..ca00a07a03 100644 --- a/plugins/contact-resources/src/components/ChannelEditor.svelte +++ b/plugins/contact-resources/src/components/ChannelEditor.svelte @@ -15,6 +15,7 @@