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:
@@ -1,6 +1,7 @@
|
||||
using ChatTwo.Code;
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using Dalamud.Game.Text.SeStringHandling.Payloads;
|
||||
using System.Text;
|
||||
|
||||
namespace ChatTwo.Util;
|
||||
|
||||
@@ -100,6 +101,10 @@ internal static class ChunkUtil {
|
||||
var reader = new BinaryReader(new MemoryStream(rawPayload.Data[4..]));
|
||||
var id = GetInteger(reader);
|
||||
link = new AchievementPayload(id);
|
||||
} else if (rawPayload.Data.Length > 5 && rawPayload.Data[1] == 0x27 && rawPayload.Data[3] == 0x07) {
|
||||
// uri payload
|
||||
var uri = new Uri(Encoding.UTF8.GetString(rawPayload.Data[4..]));
|
||||
link = new URIPayload(uri);
|
||||
} else if (Equals(rawPayload, RawPayload.LinkTerminator)) {
|
||||
link = null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user