feat: clickable URLs in chat log
Adds a parsing step when constructing `Message` objects that scans the message content for anything that looks URL-like, and inserts new `TextChunk`s into the message content with a URIPayload set. Hovering over a URL shows an on-hover effect. Clicking a URL opens it in the default browser. Right clicking shows the hostname, with an option to open and an option to copy the URL to the clipboard.
This commit is contained in:
@@ -86,6 +86,11 @@ internal class Store : IDisposable {
|
||||
["Type"] = new("PartyFinder"),
|
||||
["Id"] = new(partyFinder.Id),
|
||||
});
|
||||
case URIPayload uri:
|
||||
return new BsonDocument(new Dictionary<string, BsonValue> {
|
||||
["Type"] = new("URI"),
|
||||
["Uri"] = new(uri.Uri.ToString()),
|
||||
});
|
||||
}
|
||||
|
||||
return payload?.Encode();
|
||||
@@ -99,6 +104,7 @@ internal class Store : IDisposable {
|
||||
return bson["Type"].AsString switch {
|
||||
"Achievement" => new AchievementPayload((uint) bson["Id"].AsInt64),
|
||||
"PartyFinder" => new PartyFinderPayload((uint) bson["Id"].AsInt64),
|
||||
"URI" => new URIPayload(new Uri(bson["Uri"].AsString)),
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user