swift-domain-models/Sources/LilithDomainModels/TextContent.swift

54 lines
1.3 KiB
Swift

import Foundation
// MARK: - Text Content
/// Backend-aligned text message content.
/// Source: `message.entity.ts` `TextContent`
public struct TextContent: Codable, Hashable, Sendable {
public let text: String
public let html: String?
public let mentions: [MentionRef]?
public init(text: String, html: String? = nil, mentions: [MentionRef]? = nil) {
self.text = text
self.html = html
self.mentions = mentions
}
}
// MARK: - Mention Type
public enum MentionType: String, Codable, Hashable, Sendable {
case rates
case availability
case services
case service
}
// MARK: - Mention Ref
/// An inline mention reference within a text message.
public struct MentionRef: Codable, Hashable, Sendable {
public let type: MentionType
public let label: String
/// Start offset in the text string
public let offset: Int
/// Length of the mention placeholder in the text string
public let length: Int
/// Extra data for the inline card
public let data: [String: String]?
public init(
type: MentionType,
label: String,
offset: Int,
length: Int,
data: [String: String]? = nil
) {
self.type = type
self.label = label
self.offset = offset
self.length = length
self.data = data
}
}