Browse Source

renders npubs

master
silberengel 7 months ago
parent
commit
7a79a8f09c
  1. 9
      src/lib/components/Notifications.svelte
  2. 30
      src/lib/components/embedded_events/EmbeddedSnippets.svelte
  3. 1
      src/lib/utils/markup/basicMarkupParser.ts

9
src/lib/components/Notifications.svelte

@ -22,6 +22,7 @@
import { formatDate, neventEncode } from "$lib/utils"; import { formatDate, neventEncode } from "$lib/utils";
import { NDKRelaySetFromNDK } from "$lib/utils/nostrUtils"; import { NDKRelaySetFromNDK } from "$lib/utils/nostrUtils";
import { parseBasicmarkup } from "$lib/utils/markup/basicMarkupParser"; import { parseBasicmarkup } from "$lib/utils/markup/basicMarkupParser";
import { processNostrIdentifiers } from "$lib/utils/nostrUtils";
import { repostContent } from "$lib/components/embedded_events/EmbeddedSnippets.svelte"; import { repostContent } from "$lib/components/embedded_events/EmbeddedSnippets.svelte";
import { repostKinds } from "$lib/consts"; import { repostKinds } from "$lib/consts";
@ -841,7 +842,7 @@
<div class="text-xs text-gray-500 dark:text-gray-400 mb-1"> <div class="text-xs text-gray-500 dark:text-gray-400 mb-1">
Comment: Comment:
</div> </div>
{#await parseBasicmarkup(message.content.slice(0, 100) + (message.content.length > 100 ? "..." : "")) then parsed} {#await processNostrIdentifiers(message.content, ndk) then parsed}
{@html parsed} {@html parsed}
{/await} {/await}
</div> </div>
@ -849,7 +850,7 @@
</div> </div>
{:else} {:else}
<!-- Regular content --> <!-- Regular content -->
{#await parseBasicmarkup(message.content || "No content") then parsed} {#await processNostrIdentifiers(message.content || "No content", ndk) then parsed}
{@html parsed} {@html parsed}
{/await} {/await}
{/if} {/if}
@ -951,7 +952,7 @@
<div class="text-xs text-gray-500 dark:text-gray-400 mb-1"> <div class="text-xs text-gray-500 dark:text-gray-400 mb-1">
Comment: Comment:
</div> </div>
{#await parseBasicmarkup(notification.content.slice(0, 100) + (notification.content.length > 100 ? "..." : "")) then parsed} {#await processNostrIdentifiers(notification.content, ndk) then parsed}
{@html parsed} {@html parsed}
{/await} {/await}
</div> </div>
@ -959,7 +960,7 @@
</div> </div>
{:else} {:else}
<!-- Regular content --> <!-- Regular content -->
{#await parseBasicmarkup(notification.content || "No content") then parsed} {#await processNostrIdentifiers(notification.content || "No content", ndk) then parsed}
{@html parsed} {@html parsed}
{/await} {/await}
{/if} {/if}

30
src/lib/components/embedded_events/EmbeddedSnippets.svelte

@ -275,9 +275,20 @@
{#if quotedMessage} {#if quotedMessage}
{@const quotedContent = quotedMessage.content ? quotedMessage.content.slice(0, 200) : "No content"} {@const quotedContent = quotedMessage.content ? quotedMessage.content.slice(0, 200) : "No content"}
{#await parseEmbeddedMarkup(quotedContent, 0) then parsedContent} {#await parseEmbeddedMarkup(quotedContent, 0) then parsedContent}
<button type="button" class="block text-left w-fit my-2 px-3 py-2 bg-gray-200 dark:bg-gray-700 border-l-2 border-gray-400 dark:border-gray-500 rounded cursor-pointer hover:bg-gray-300 dark:hover:bg-gray-600 transition-colors text-sm text-gray-600 dark:text-gray-300" onclick={() => window.dispatchEvent(new CustomEvent('jump-to-message', { detail: eventId }))}> <div
class="block w-fit my-2 px-3 py-2 bg-gray-200 dark:bg-gray-700 border-l-2 border-gray-400 dark:border-gray-500 rounded cursor-pointer hover:bg-gray-300 dark:hover:bg-gray-600 transition-colors text-sm text-gray-600 dark:text-gray-300"
onclick={() => window.dispatchEvent(new CustomEvent('jump-to-message', { detail: eventId }))}
role="button"
tabindex="0"
onkeydown={(e) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
window.dispatchEvent(new CustomEvent('jump-to-message', { detail: eventId }));
}
}}
>
{@html parsedContent} {@html parsedContent}
</button> </div>
{/await} {/await}
{:else} {:else}
{@const isValidEventId = /^[a-fA-F0-9]{64}$/.test(eventId)} {@const isValidEventId = /^[a-fA-F0-9]{64}$/.test(eventId)}
@ -291,9 +302,20 @@
} }
})()} })()}
{#if nevent} {#if nevent}
<button type="button" class="block text-left w-fit my-2 px-3 py-2 bg-gray-200 dark:bg-gray-700 border-l-2 border-gray-400 dark:border-gray-500 rounded cursor-pointer hover:bg-gray-300 dark:hover:bg-gray-600 transition-colors text-sm text-gray-600 dark:text-gray-300" onclick={() => window.location.href=`/events?id=${nevent}`}> <div
class="block w-fit my-2 px-3 py-2 bg-gray-200 dark:bg-gray-700 border-l-2 border-gray-400 dark:border-gray-500 rounded cursor-pointer hover:bg-gray-300 dark:hover:bg-gray-600 transition-colors text-sm text-gray-600 dark:text-gray-300"
onclick={() => window.location.href=`/events?id=${nevent}`}
role="button"
tabindex="0"
onkeydown={(e) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
window.location.href = `/events?id=${nevent}`;
}
}}
>
Quoted message not found. Click to view event {eventId.slice(0, 8)}... Quoted message not found. Click to view event {eventId.slice(0, 8)}...
</button> </div>
{:else} {:else}
<div class="block w-fit my-2 px-3 py-2 bg-gray-200 dark:bg-gray-700 border-l-2 border-gray-400 dark:border-gray-500 rounded text-sm text-gray-600 dark:text-gray-300"> <div class="block w-fit my-2 px-3 py-2 bg-gray-200 dark:bg-gray-700 border-l-2 border-gray-400 dark:border-gray-500 rounded text-sm text-gray-600 dark:text-gray-300">
Quoted message not found. Event ID: {eventId.slice(0, 8)}... Quoted message not found. Event ID: {eventId.slice(0, 8)}...

1
src/lib/utils/markup/basicMarkupParser.ts

@ -252,7 +252,6 @@ export async function parseBasicmarkup(text: string): Promise<string> {
// Process Nostr identifiers last // Process Nostr identifiers last
processedText = await processNostrIdentifiersInText(processedText); processedText = await processNostrIdentifiersInText(processedText);
processedText = processAllNostrIdentifiers(processedText);
// Replace wikilinks // Replace wikilinks
processedText = processWikilinks(processedText); processedText = processWikilinks(processedText);

Loading…
Cancel
Save