diff --git a/Sources/Shared/UI/Components/MessageBubble.swift b/Sources/Shared/UI/Components/MessageBubble.swift index 0d2dd17..1625cc6 100644 --- a/Sources/Shared/UI/Components/MessageBubble.swift +++ b/Sources/Shared/UI/Components/MessageBubble.swift @@ -72,14 +72,7 @@ struct MessageBubble: View { } } if message.hasText { - Button(action: { - #if os(macOS) - NSPasteboard.general.clearContents() - NSPasteboard.general.setString(message.text, forType: .string) - #else - UIPasteboard.general.string = message.text - #endif - }) { + Button(action: copyText(message.body)) { Label("Копировать текст", systemImage: "doc.on.doc") } } @@ -117,6 +110,15 @@ struct MessageBubble: View { } } + private func copyText(body: String) { + #if os(macOS) + NSPasteboard.general.clearContents() + NSPasteboard.general.setString(message.body, forType: .string) + #else + UIPasteboard.general.string = message.body + #endif + } + private var messageContainer: some View { HStack(spacing: 2) { if isSelectionMode {