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
+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]
}