Skip to content

Commit

Permalink
make post content selectable with clickable links
Browse files Browse the repository at this point in the history
  • Loading branch information
prolic committed Feb 21, 2025
1 parent 7d2bcf7 commit b1015d8
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions resources/qml/content/Components/PostContent.ui.qml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,21 @@ Pane {
spacing: Constants.spacing_xs

// Main post content
Text {
TextEdit {
Layout.fillWidth: true
text: (post.content || "").replace(/nostr:(note|nevent|naddr)1[a-zA-Z0-9]+/g, '').trim()
text: {
let content = (post.content || "").replace(/nostr:(note|nevent|naddr)1[a-zA-Z0-9]+/g, '').trim();
content = content.replace(/</g, '&lt;').replace(/>/g, '&gt;'); // Escape any HTML first
content = content.replace(/(https?:\/\/[^\s]+)/g, '<a href="$1" style="color: ' + Material.accentColor + '">$1</a>');
return content;
}
visible: post.postType === "short_text_note" || post.postType === "quote_repost"
wrapMode: Text.Wrap
color: Material.foreground
readOnly: true
selectByMouse: true
textFormat: TextEdit.RichText
onLinkActivated: (link) => Qt.openUrlExternally(link)
}

Repeater {
Expand Down

0 comments on commit b1015d8

Please sign in to comment.