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