Make links clickable in follow user view
This commit is contained in:
@@ -15,7 +15,7 @@ public struct Markdown {
|
|||||||
return url.contains("://") ? url : "https://" + url
|
return url.contains("://") ? url : "https://" + url
|
||||||
}
|
}
|
||||||
|
|
||||||
static func parseMarkdown(content: String) -> AttributedString {
|
public static func parse(content: String) -> AttributedString {
|
||||||
// Similar to the parsing in NoteContentView
|
// Similar to the parsing in NoteContentView
|
||||||
let md_opts: AttributedString.MarkdownParsingOptions =
|
let md_opts: AttributedString.MarkdownParsingOptions =
|
||||||
.init(interpretedSyntax: .inlineOnlyPreservingWhitespace)
|
.init(interpretedSyntax: .inlineOnlyPreservingWhitespace)
|
||||||
@@ -38,6 +38,6 @@ public struct Markdown {
|
|||||||
output.replaceSubrange(range, with: "[\(url)](\(Markdown.withScheme(url)))")
|
output.replaceSubrange(range, with: "[\(url)](\(Markdown.withScheme(url)))")
|
||||||
}
|
}
|
||||||
// TODO: escape unintentional markdown
|
// TODO: escape unintentional markdown
|
||||||
return Markdown.parseMarkdown(content: output)
|
return Markdown.parse(content: output)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ struct FollowUserView: View {
|
|||||||
let target: FollowTarget
|
let target: FollowTarget
|
||||||
let damus_state: DamusState
|
let damus_state: DamusState
|
||||||
|
|
||||||
|
static let markdown = Markdown()
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
HStack(alignment: .top) {
|
HStack(alignment: .top) {
|
||||||
let pmodel = ProfileModel(pubkey: target.pubkey, damus: damus_state)
|
let pmodel = ProfileModel(pubkey: target.pubkey, damus: damus_state)
|
||||||
@@ -23,8 +25,8 @@ struct FollowUserView: View {
|
|||||||
VStack(alignment: .leading) {
|
VStack(alignment: .leading) {
|
||||||
let profile = damus_state.profiles.lookup(id: target.pubkey)
|
let profile = damus_state.profiles.lookup(id: target.pubkey)
|
||||||
ProfileName(pubkey: target.pubkey, profile: profile, contacts: damus_state.contacts, show_friend_confirmed: false)
|
ProfileName(pubkey: target.pubkey, profile: profile, contacts: damus_state.contacts, show_friend_confirmed: false)
|
||||||
if let about = profile.flatMap { $0.about } {
|
if let about = profile?.about {
|
||||||
Text(about)
|
Text(FollowUserView.markdown.process(about))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,17 +60,10 @@ struct NoteContentView: View {
|
|||||||
let size: EventViewKind
|
let size: EventViewKind
|
||||||
|
|
||||||
func MainContent() -> some View {
|
func MainContent() -> some View {
|
||||||
let md_opts: AttributedString.MarkdownParsingOptions =
|
|
||||||
.init(interpretedSyntax: .inlineOnlyPreservingWhitespace)
|
|
||||||
|
|
||||||
return VStack(alignment: .leading) {
|
return VStack(alignment: .leading) {
|
||||||
if let txt = try? AttributedString(markdown: artifacts.content, options: md_opts) {
|
Text(Markdown.parse(content: artifacts.content))
|
||||||
Text(txt)
|
.font(eventviewsize_to_font(size))
|
||||||
.font(eventviewsize_to_font(size))
|
|
||||||
} else {
|
|
||||||
Text(artifacts.content)
|
|
||||||
.font(eventviewsize_to_font(size))
|
|
||||||
}
|
|
||||||
if show_images && artifacts.images.count > 0 {
|
if show_images && artifacts.images.count > 0 {
|
||||||
ImageCarousel(urls: artifacts.images)
|
ImageCarousel(urls: artifacts.images)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ struct ProfileView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static let markdownHelper = Markdown()
|
static let markdown = Markdown()
|
||||||
|
|
||||||
var DMButton: some View {
|
var DMButton: some View {
|
||||||
let dm_model = damus_state.dms.lookup_or_create(profile.pubkey)
|
let dm_model = damus_state.dms.lookup_or_create(profile.pubkey)
|
||||||
@@ -197,7 +197,7 @@ struct ProfileView: View {
|
|||||||
ProfileNameView(pubkey: profile.pubkey, profile: data, contacts: damus_state.contacts)
|
ProfileNameView(pubkey: profile.pubkey, profile: data, contacts: damus_state.contacts)
|
||||||
.padding(.bottom)
|
.padding(.bottom)
|
||||||
|
|
||||||
Text(ProfileView.markdownHelper.process(data?.about ?? ""))
|
Text(ProfileView.markdown.process(data?.about ?? ""))
|
||||||
.font(.subheadline)
|
.font(.subheadline)
|
||||||
|
|
||||||
Divider()
|
Divider()
|
||||||
|
|||||||
Reference in New Issue
Block a user