Rough out chat

This commit is contained in:
Jon Staab
2024-10-08 11:39:16 -07:00
parent 7ffd02b736
commit 8698dcc359
59 changed files with 833 additions and 437 deletions
+9 -4
View File
@@ -1,5 +1,5 @@
<script lang="ts">
import cx from 'classnames'
import cx from "classnames"
import type {NodeViewProps} from "@tiptap/core"
import {NodeViewWrapper} from "svelte-tiptap"
import {ellipsize, nthEq} from "@welshman/lib"
@@ -11,9 +11,11 @@
export let selected: NodeViewProps["selected"]
const displayEvent = (e: TrustedEvent) => {
const content = e?.tags.find(nthEq(0, 'alt'))?.[1] || e?.content
const content = e?.tags.find(nthEq(0, "alt"))?.[1] || e?.content
return content.length > 1 ? ellipsize(content, 30) : fromNostrURI(nevent || naddr).slice(0, 16) + "..."
return content.length > 1
? ellipsize(content, 30)
: fromNostrURI(nevent || naddr).slice(0, 16) + "..."
}
$: ({identifier, pubkey, kind, id, relays = [], nevent, naddr} = node.attrs)
@@ -21,7 +23,10 @@
</script>
<NodeViewWrapper class="inline">
<Link external href={entityLink(node.attrs.nevent)} class={cx("link-content", {"link-content-selected": selected})}>
<Link
external
href={entityLink(node.attrs.nevent)}
class={cx("link-content", {"link-content-selected": selected})}>
{displayEvent($event)}
</Link>
</NodeViewWrapper>
+1 -1
View File
@@ -5,7 +5,7 @@
import {displayProfile} from "@welshman/util"
import {deriveProfile} from "@welshman/app"
import Link from "@lib/components/Link.svelte"
import {entityLink} from '@app/state'
import {entityLink} from "@app/state"
export let node: NodeViewProps["node"]
export let selected: NodeViewProps["selected"]
+1 -1
View File
@@ -1,5 +1,5 @@
<script lang="ts">
import Profile from '@app/components/Profile.svelte'
import Profile from "@app/components/Profile.svelte"
export let value
</script>
+3 -3
View File
@@ -4,7 +4,7 @@
import {throttle} from "throttle-debounce"
import {fly, slide} from "svelte/transition"
import {clamp} from "@welshman/lib"
import Icon from '@lib/components/Icon.svelte'
import Icon from "@lib/components/Icon.svelte"
import {theme} from "@app/theme"
export let term
@@ -77,11 +77,11 @@
{/if}
{#each items as value, i (value)}
<button
class="white-space-nowrap block w-full min-w-0 cursor-pointer overflow-x-hidden text-ellipsis px-4 py-2 text-left transition-all hover:brightness-150 flex items-center"
class="white-space-nowrap block flex w-full min-w-0 cursor-pointer items-center overflow-x-hidden text-ellipsis px-4 py-2 text-left transition-all hover:brightness-150"
on:mousedown|preventDefault
on:click|preventDefault={() => select(value)}>
{#if index === i}
<div transition:slide|local={{axis: 'x'}} class="pr-2">
<div transition:slide|local={{axis: "x"}} class="pr-2">
<Icon icon="alt-arrow-right" />
</div>
{/if}
+26 -18
View File
@@ -56,29 +56,37 @@ export const findMarks = (type: string, json: JSONContent) => {
export const getEditorTags = (editor: Editor) => {
const json = editor.getJSON()
const topicTags = findMarks("tag", json).map(
({attrs}: any) => ["t", attrs.tag.replace(/^#/, '').toLowerCase()],
)
const topicTags = findMarks("tag", json).map(({attrs}: any) => [
"t",
attrs.tag.replace(/^#/, "").toLowerCase(),
])
const naddrTags = findNodes("naddr", json).map(
({kind, pubkey, identifier, relays}: any) => {
const address = new Address(kind, pubkey, identifier).toString()
const naddrTags = findNodes("naddr", json).map(({kind, pubkey, identifier, relays}: any) => {
const address = new Address(kind, pubkey, identifier).toString()
return ["q", address, choice(relays) || "", pubkey]
},
)
return ["q", address, choice(relays) || "", pubkey]
})
const neventTags = findNodes("nevent", json).map(
({id, author, relays}: any) => ["q", id, choice(relays) || "", author || ""],
)
const neventTags = findNodes("nevent", json).map(({id, author, relays}: any) => [
"q",
id,
choice(relays) || "",
author || "",
])
const mentionTags = findNodes("nprofile", json).map(
({pubkey, relays}: any) => ["p", pubkey, choice(relays) || "", ""],
)
const mentionTags = findNodes("nprofile", json).map(({pubkey, relays}: any) => [
"p",
pubkey,
choice(relays) || "",
"",
])
const imetaTags = findNodes("image", json).map(
({src, sha256}: any) => ["imeta", `url ${src}`, `x ${sha256}`, `ox ${sha256}`],
)
const imetaTags = findNodes("image", json).map(({src, sha256}: any) => [
"imeta",
`url ${src}`,
`x ${sha256}`,
`ox ${sha256}`,
])
return [...topicTags, ...naddrTags, ...neventTags, ...mentionTags, ...imetaTags]
}