mirror of
https://github.com/ichmagmaus111/ghostgram.git
synced 2026-11-03 22:27:13 +01:00
Ghostgram for iOS, rebuilt from scratch on Telegram iOS 13.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
21 lines
977 B
Swift
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: ""))
|
|
}
|
|
}
|