mirror of
https://github.com/coracle-social/coracle.git
synced 2024-09-18 19:23:40 +00:00
Fix auto mention on person detail
This commit is contained in:
parent
35f1431ae2
commit
72203afb94
@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import {nip19} from "nostr-tools"
|
||||
import user from "src/agent/user"
|
||||
import {modal, location} from "src/app/ui"
|
||||
|
||||
@ -7,7 +8,8 @@
|
||||
const {canPublish} = user
|
||||
|
||||
const createNote = () => {
|
||||
const pubkey = null // TODO use $location.pathname
|
||||
const matches = $location.pathname.match(/people\/(npub1[0-9a-z]+)/)
|
||||
const pubkey = matches ? nip19.decode(matches[1]).data : null
|
||||
|
||||
modal.set({type: "note/create", pubkey})
|
||||
}
|
||||
|
@ -43,7 +43,7 @@
|
||||
return {selection, node, offset, word}
|
||||
}
|
||||
|
||||
const autocomplete = ({person}) => {
|
||||
const autocomplete = ({person, force = false}) => {
|
||||
const {selection, node, offset, word} = getInfo()
|
||||
|
||||
const annotate = (prefix, text, value) => {
|
||||
@ -70,12 +70,12 @@
|
||||
}
|
||||
|
||||
// Mentions
|
||||
if (word.length > 1 && word.startsWith("@")) {
|
||||
if ((force || word.length > 1) && word.startsWith("@")) {
|
||||
annotate("@", displayPerson(person).trim(), pubkeyEncoder.encode(person.pubkey))
|
||||
}
|
||||
|
||||
// Topics
|
||||
if (word.length > 1 && word.startsWith("#")) {
|
||||
if ((force || word.length > 1) && word.startsWith("#")) {
|
||||
annotate("#", word.slice(1), word.slice(1))
|
||||
}
|
||||
|
||||
@ -139,7 +139,7 @@
|
||||
selection.getRangeAt(0).insertNode(spaceNode)
|
||||
selection.collapse(input, 1)
|
||||
|
||||
autocomplete({person})
|
||||
autocomplete({person, force: true})
|
||||
}
|
||||
|
||||
const createNewLines = (n = 1) => {
|
||||
|
Loading…
Reference in New Issue
Block a user