mirror of
https://github.com/coracle-social/flotilla.git
synced 2025-12-11 11:27:03 +00:00
Add nostr: prefix to editor
This commit is contained in:
@@ -20,6 +20,7 @@ import {
|
|||||||
TagExtension,
|
TagExtension,
|
||||||
} from "nostr-editor"
|
} from "nostr-editor"
|
||||||
import type {StampedEvent} from "@welshman/util"
|
import type {StampedEvent} from "@welshman/util"
|
||||||
|
import {toNostrURI} from "@welshman/util"
|
||||||
import {signer, profileSearch} from "@welshman/app"
|
import {signer, profileSearch} from "@welshman/app"
|
||||||
import {FileUploadExtension} from "./FileUpload"
|
import {FileUploadExtension} from "./FileUpload"
|
||||||
import {createSuggestions} from "./Suggestions"
|
import {createSuggestions} from "./Suggestions"
|
||||||
@@ -107,6 +108,7 @@ export const getEditorOptions = ({
|
|||||||
Bolt11Extension.extend(asInline({addNodeView: () => SvelteNodeViewRenderer(EditBolt11)})),
|
Bolt11Extension.extend(asInline({addNodeView: () => SvelteNodeViewRenderer(EditBolt11)})),
|
||||||
NProfileExtension.extend({
|
NProfileExtension.extend({
|
||||||
addNodeView: () => SvelteNodeViewRenderer(EditMention),
|
addNodeView: () => SvelteNodeViewRenderer(EditMention),
|
||||||
|
renderText: props => toNostrURI(props.node.attrs.nprofile),
|
||||||
addProseMirrorPlugins() {
|
addProseMirrorPlugins() {
|
||||||
return [
|
return [
|
||||||
createSuggestions({
|
createSuggestions({
|
||||||
@@ -126,8 +128,18 @@ export const getEditorOptions = ({
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
NEventExtension.extend(asInline({addNodeView: () => SvelteNodeViewRenderer(EditEvent)})),
|
NEventExtension.extend(
|
||||||
NAddrExtension.extend(asInline({addNodeView: () => SvelteNodeViewRenderer(EditEvent)})),
|
asInline({
|
||||||
|
addNodeView: () => SvelteNodeViewRenderer(EditEvent),
|
||||||
|
renderText: (props: any) => toNostrURI(props.node.attrs.nevent),
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
NAddrExtension.extend(
|
||||||
|
asInline({
|
||||||
|
addNodeView: () => SvelteNodeViewRenderer(EditEvent),
|
||||||
|
renderText: (props: any) => toNostrURI(props.node.attrs.nevent),
|
||||||
|
}),
|
||||||
|
),
|
||||||
ImageExtension.extend(
|
ImageExtension.extend(
|
||||||
asInline({addNodeView: () => SvelteNodeViewRenderer(EditImage)}),
|
asInline({addNodeView: () => SvelteNodeViewRenderer(EditImage)}),
|
||||||
).configure({defaultUploadUrl, defaultUploadType: uploadType}),
|
).configure({defaultUploadUrl, defaultUploadType: uploadType}),
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import type {JSONContent, PasteRuleMatch, InputRuleMatch} from "@tiptap/core"
|
|||||||
import {Editor} from "@tiptap/core"
|
import {Editor} from "@tiptap/core"
|
||||||
import {ctx} from "@welshman/lib"
|
import {ctx} from "@welshman/lib"
|
||||||
import {Address} from "@welshman/util"
|
import {Address} from "@welshman/util"
|
||||||
|
import {repository} from "@welshman/app"
|
||||||
|
|
||||||
export const asInline = (extend: Record<string, any>) => ({
|
export const asInline = (extend: Record<string, any>) => ({
|
||||||
inline: true,
|
inline: true,
|
||||||
@@ -69,12 +70,13 @@ export const getEditorTags = (editor: Editor) => {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
const neventTags = findNodes("nevent", json).map(({attrs: {id, author, relays = []}}: any) => [
|
const neventTags = findNodes("nevent", json).map(({attrs: {id, author, relays = []}}: any) => {
|
||||||
"q",
|
const event = repository.getEvent(id)
|
||||||
id,
|
const pubkey = author || repository.getEvent(id)?.pubkey || ""
|
||||||
ctx.app.router.FromRelays(relays).getUrl(),
|
const scenario = event ? ctx.app.router.Event(event) : ctx.app.router.FromPubkeys([pubkey])
|
||||||
author || "",
|
|
||||||
])
|
return ["q", id, scenario.getUrl(), pubkey]
|
||||||
|
})
|
||||||
|
|
||||||
const mentionTags = findNodes("nprofile", json).map(({attrs: {pubkey, relays = []}}: any) => [
|
const mentionTags = findNodes("nprofile", json).map(({attrs: {pubkey, relays = []}}: any) => [
|
||||||
"p",
|
"p",
|
||||||
|
|||||||
Reference in New Issue
Block a user