Files
ghostgram/submodules/TelegramUI/Sources/Chat/ChatTextInputStateFromComposedRichMessage.swift
ichmagmaus111andClaude Opus 5.5 0622057a4f Ghostgram: open-source release
Ghostgram for iOS, rebuilt from scratch on Telegram iOS 13.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 17:57:09 +01:00

21 lines
977 B
Swift

import Foundation
import TelegramCore
import AccountContext
import TextFormat
/// The composer input state carrying a `ComposedRichMessage` result back into the chat text input.
/// `.rich` keeps its structure via `ChatInputContent` — the same `InstantPage → ChatInputContent`
/// hop the edit-a-rich-message path uses — while `.plain` goes through the entity-applied
/// attributed string.
func chatTextInputState(fromComposedRichMessage message: ComposedRichMessage) -> ChatTextInputState {
switch message {
case let .rich(instantPage):
let content = chatInputContent(fromInstantPage: instantPage)
return ChatTextInputState(content: content, selectionRange: content.length ..< content.length)
case let .plain(text, entities):
return ChatTextInputState(inputText: chatInputStateStringWithAppliedEntities(text, entities: entities))
case .empty:
return ChatTextInputState(inputText: NSAttributedString(string: ""))
}
}