feat: add auto-load profile pictures setting (#712)

This commit is contained in:
gzuuus 2025-12-29 15:42:02 +01:00 committed by GitHub
parent ec03a49e32
commit 6dc662bd2b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
28 changed files with 170 additions and 47 deletions

View file

@ -7,25 +7,27 @@ export function parseEditorJsonToText(node?: JSONContent) {
const text = _parseEditorJsonToText(node)
const regex = /(^|\s+|@)(nostr:)?(nevent|naddr|nprofile|npub)1[a-zA-Z0-9]+/g
return text.replace(regex, (match, leadingWhitespace) => {
let bech32 = match.trim()
const whitespace = leadingWhitespace || ''
return text
.replace(regex, (match, leadingWhitespace) => {
let bech32 = match.trim()
const whitespace = leadingWhitespace || ''
if (bech32.startsWith('@nostr:')) {
bech32 = bech32.slice(7)
} else if (bech32.startsWith('@')) {
bech32 = bech32.slice(1)
} else if (bech32.startsWith('nostr:')) {
bech32 = bech32.slice(6)
}
if (bech32.startsWith('@nostr:')) {
bech32 = bech32.slice(7)
} else if (bech32.startsWith('@')) {
bech32 = bech32.slice(1)
} else if (bech32.startsWith('nostr:')) {
bech32 = bech32.slice(6)
}
try {
nip19.decode(bech32)
return `${whitespace}nostr:${bech32}`
} catch {
return match
}
}).trim()
try {
nip19.decode(bech32)
return `${whitespace}nostr:${bech32}`
} catch {
return match
}
})
.trim()
}
function _parseEditorJsonToText(node?: JSONContent): string {