feat: add room mentions and clickable room/relay refs
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
import Danger from "@assets/icons/danger-triangle.svg?dataurl"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
import ContentText from "@app/components/ContentText.svelte"
|
||||
import ContentToken from "@app/components/ContentToken.svelte"
|
||||
import ContentEmoji from "@app/components/ContentEmoji.svelte"
|
||||
import ContentCode from "@app/components/ContentCode.svelte"
|
||||
@@ -155,6 +156,8 @@
|
||||
{#each shortContent as parsed, i}
|
||||
{#if isNewline(parsed) && !isBlock(i - 1)}
|
||||
<ContentNewline value={parsed.value} />
|
||||
{:else if isText(parsed)}
|
||||
<ContentText value={parsed.value} />
|
||||
{:else if isTopic(parsed)}
|
||||
<ContentTopic value={parsed.value} />
|
||||
{:else if isEmoji(parsed)}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
import Danger from "@assets/icons/danger-triangle.svg?dataurl"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
import ContentText from "@app/components/ContentText.svelte"
|
||||
import ContentToken from "@app/components/ContentToken.svelte"
|
||||
import ContentEmoji from "@app/components/ContentEmoji.svelte"
|
||||
import ContentCode from "@app/components/ContentCode.svelte"
|
||||
@@ -105,6 +106,8 @@
|
||||
{#each shortContent as parsed, i}
|
||||
{#if isNewline(parsed)}
|
||||
<ContentNewline value={parsed.value} />
|
||||
{:else if isText(parsed)}
|
||||
<ContentText value={parsed.value} />
|
||||
{:else if isTopic(parsed)}
|
||||
<ContentTopic value={parsed.value} />
|
||||
{:else if isEmoji(parsed)}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<script lang="ts">
|
||||
import Link from "@lib/components/Link.svelte"
|
||||
import {parseContentTextParts} from "@lib/content-text"
|
||||
import {makeRoomPath, makeSpacePath} from "@app/util/routes"
|
||||
|
||||
type Props = {
|
||||
value: string
|
||||
}
|
||||
|
||||
const {value}: Props = $props()
|
||||
|
||||
const parts = $derived(parseContentTextParts(value))
|
||||
</script>
|
||||
|
||||
{#each parts as part, i (i)}
|
||||
{#if part.type === "room"}
|
||||
<Link href={makeRoomPath(part.url, part.h)} class="link-content whitespace-nowrap"
|
||||
>{part.value}</Link>
|
||||
{:else if part.type === "relay"}
|
||||
<Link href={makeSpacePath(part.url)} class="link-content whitespace-nowrap">{part.value}</Link>
|
||||
{:else}
|
||||
{part.value}
|
||||
{/if}
|
||||
{/each}
|
||||
Reference in New Issue
Block a user