parent
0a9aad7b03
commit
c702928e1e
|
@ -15,16 +15,13 @@ const PARSED_TEXT_CHILD_TYPE_STRONG_EMPH* = "strong-emph"
|
|||
const PARSED_TEXT_CHILD_TYPE_MENTION* = "mention"
|
||||
const PARSED_TEXT_CHILD_TYPE_STATUS_TAG* = "status-tag"
|
||||
const PARSED_TEXT_CHILD_TYPE_DEL* = "del"
|
||||
|
||||
type ParsedTextChild* = object
|
||||
`type`*: string
|
||||
literal*: string
|
||||
destination*: string
|
||||
const PARSED_TEXT_CHILD_TYPE_LINK* = "link"
|
||||
|
||||
type ParsedText* = object
|
||||
`type`*: string
|
||||
literal*: string
|
||||
children*: seq[ParsedTextChild]
|
||||
destination*: string
|
||||
children*: seq[ParsedText]
|
||||
|
||||
type QuotedMessage* = object
|
||||
`from`*: string
|
||||
|
@ -67,21 +64,16 @@ type MessageDto* = object
|
|||
links*: seq[string]
|
||||
editedAt*: int
|
||||
|
||||
proc toParsedTextChild*(jsonObj: JsonNode): ParsedTextChild =
|
||||
result = ParsedTextChild()
|
||||
discard jsonObj.getProp("type", result.type)
|
||||
discard jsonObj.getProp("literal", result.literal)
|
||||
discard jsonObj.getProp("destination", result.destination)
|
||||
|
||||
proc toParsedText*(jsonObj: JsonNode): ParsedText =
|
||||
result = ParsedText()
|
||||
discard jsonObj.getProp("type", result.type)
|
||||
discard jsonObj.getProp("literal", result.literal)
|
||||
discard jsonObj.getProp("destination", result.destination)
|
||||
|
||||
var childrenArr: JsonNode
|
||||
if(jsonObj.getProp("children", childrenArr) and childrenArr.kind == JArray):
|
||||
for childObj in childrenArr:
|
||||
result.children.add(toParsedTextChild(childObj))
|
||||
result.children.add(toParsedText(childObj))
|
||||
|
||||
proc toQuotedMessage*(jsonObj: JsonNode): QuotedMessage =
|
||||
result = QuotedMessage()
|
||||
|
|
|
@ -555,13 +555,13 @@ QtObject:
|
|||
self.threadpool.start(arg)
|
||||
|
||||
# See render-inline in status-react/src/status_im/ui/screens/chat/message/message.cljs
|
||||
proc renderInline(self: Service, parsedTextChild: ParsedTextChild): string =
|
||||
let value = escape_html(parsedTextChild.literal)
|
||||
proc renderInline(self: Service, parsedText: ParsedText): string =
|
||||
let value = escape_html(parsedText.literal)
|
||||
.multiReplace(("\r\n", "<br/>"))
|
||||
.multiReplace(("\n", "<br/>"))
|
||||
.multiReplace((" ", " "))
|
||||
|
||||
case parsedTextChild.type:
|
||||
case parsedText.type:
|
||||
of "":
|
||||
result = value
|
||||
of PARSED_TEXT_CHILD_TYPE_CODE:
|
||||
|
@ -579,6 +579,8 @@ proc renderInline(self: Service, parsedTextChild: ParsedTextChild): string =
|
|||
result = fmt("<a href=\"#{value}\" class=\"status-tag\">#{value}</a>")
|
||||
of PARSED_TEXT_CHILD_TYPE_DEL:
|
||||
result = fmt("<del>{value}</del>")
|
||||
of PARSED_TEXT_CHILD_TYPE_LINK:
|
||||
result = fmt("{parsedText.destination}")
|
||||
else:
|
||||
result = fmt(" {value} ")
|
||||
|
||||
|
|
Loading…
Reference in New Issue