import { decode } from 'light-bolt11-decoder'; import { DecodedResult } from 'nostr-tools/nip19'; import { Editor } from '@tiptap/core'; import { EditorView } from 'prosemirror-view'; import { Extension } from '@tiptap/core'; import { ImageOptions as ImageOptions_2 } from '@tiptap/extension-image'; import { LinkOptions } from '@tiptap/extension-link'; import { Mark as Mark_2 } from '@tiptap/core'; import { MarkConfig } from '@tiptap/core'; import { Node as Node_3 } from '@tiptap/core'; import { NodeConfig } from '@tiptap/core'; import { NostrEvent } from 'nostr-tools'; import { NostrEvent as NostrEvent_2 } from 'nostr-tools/core'; import { Slice } from 'prosemirror-model'; import { StarterKitOptions } from '@tiptap/starter-kit'; import { YoutubeOptions } from '@tiptap/extension-youtube'; export declare type BlockQuoteNode = { type: Extensions<'blockquote'>; content: Node_2[]; }; export declare type BoldMark = { type: 'bold'; }; export declare interface Bolt11Attributes { lnbc: string; bolt11: ReturnType; } export declare const Bolt11Extension: Node_3; export declare type Bolt11Node = { type: 'bolt11'; attrs: Bolt11Attributes; }; export declare type BulletListNode = { type: Extensions<'bulletList'>; content: ListItemNode[]; }; /** * Override default clipboard serialization behavior to avoid doubling new lines */ declare function clipboardTextSerializer(slice: Slice): string; export declare type CodeBlockNode = { type: Extensions<'codeBlock'>; content: Node_2[]; attrs: { language: string; }; }; export declare type CodeMark = { type: 'code'; }; export declare type ContentSchema = { type: 'doc'; content: Node_2[]; }; export declare const editorProps: { handlePaste: typeof handlePaste; clipboardTextSerializer: typeof clipboardTextSerializer; }; declare type Extensions = T; export declare type FileAttributes = ImageAttributes | VideoAttributes; export declare const FileUploadExtension: Extension; export declare interface FileUploadOptions { allowedMimeTypes: string[]; immediateUpload: boolean; upload: (attrs: FileAttributes) => Promise; onDrop: (currentEditor: Editor, file: File, pos: number) => void; onStart: (currentEditor: Editor) => void; onUpload: (currentEditor: Editor, task: UploadTask) => void; onUploadError: (currentEditor: Editor, task: UploadTask) => void; onComplete: (currentEditor: Editor, files: FileAttributes[]) => void; } export declare interface FileUploadStorage { uploader: Uploader | null; getFiles: () => FileAttributes[]; } /** * Override default paste behavior to avoid stripping new lines * From: https://stackoverflow.com/q/79019919/1467342 */ declare function handlePaste(view: EditorView, event: ClipboardEvent): boolean; export declare type HardBreak = { type: Extensions<'hardBreak'>; }; export declare type HeadingNode = { type: Extensions<'heading'>; content: Node_2[]; attrs: { level: number; }; }; export declare type HorizontalRule = { type: Extensions<'horizontalRule'>; }; export declare interface ImageAttributes { src: string; alt: string; title: string; file: File; tags: NostrEvent['tags']; sha256: string; uploading: boolean; error: string; } export declare const ImageExtension: Node_3; export declare type ImageNode = { type: 'image'; attrs: ImageOptions_2['HTMLAttributes']; }; export declare interface ImageOptions { inline: boolean; } declare type IMetaFields = { url?: string; m?: string; x?: string; blurhash?: string; bh?: string; dim?: { width: number; height: number; }; alt?: string; summary?: string; fallback?: string[]; thumb?: string; }; export declare type IMetaTags = Record; export declare const isBlockQuoteNode: (node: Node_2) => node is BlockQuoteNode; export declare const isBoldMark: (mark: Mark) => mark is BoldMark; export declare const isBolt11Node: (node: Node_2) => node is Bolt11Node; export declare const isBulletListNode: (node: Node_2) => node is BulletListNode; export declare const isCodeBlockNode: (node: Node_2) => node is CodeBlockNode; export declare const isCodeMark: (mark: Mark) => mark is CodeMark; export declare const isHardBreak: (node: Node_2) => node is HardBreak; export declare const isHeadingNode: (node: Node_2) => node is HeadingNode; export declare const isHorizontalRule: (node: Node_2) => node is HorizontalRule; export declare const isImageNode: (node: Node_2) => node is ImageNode; export declare const isItalicMark: (mark: Mark) => mark is ItalicMark; export declare const isLinkMark: (mark: Mark) => mark is LinkMark; export declare const isNAddrNode: (node: Node_2) => node is NAddrNode; export declare const isNEventNode: (node: Node_2) => node is NEventNode; export declare const isNProfileNode: (node: Node_2) => node is NProfileNode; export declare const isOrderedListNode: (node: Node_2) => node is OrderedListNode; export declare const isParagraphNode: (node: Node_2) => node is ParagraphNode; export declare const isStrikeMark: (mark: Mark) => mark is StrikeMark; export declare const isTagMark: (mark: Mark) => mark is TagMark; export declare const isTextNode: (node: Node_2) => node is TextNode; export declare const isTweetNode: (node: Node_2) => node is TweetNode; export declare const isVideoNode: (node: Node_2) => node is VideoNode; export declare const isYoutubeNode: (node: Node_2) => node is YoutubeNode; export declare type ItalicMark = { type: 'italic'; }; export declare type LinkAttributes = { href: string; }; export declare const LinkExtension: Mark_2; export declare type LinkMark = { type: 'link'; attrs: LinkAttributes; }; export { LinkOptions } export declare type ListItemNode = { type: Extensions<'listItem'>; content: Node_2[]; attrs: { closed: boolean; nested: boolean; }; }; export declare const makeBolt11Attrs: (lnbc: string) => { bolt11: { paymentRequest: string; sections: Array<{ name: string; letters: string; value?: string | Record; tag?: string; }>; expiry: number; }; lnbc: string; }; export declare const makeBolt11Node: (lnbc: string) => { type: string; attrs: { bolt11: { paymentRequest: string; sections: Array<{ name: string; letters: string; value?: string | Record; tag?: string; }>; expiry: number; }; lnbc: string; }; }; export declare const makeNAddrAttrs: (input: string, options?: Nip19Options) => NAddrAttributes; export declare const makeNAddrNode: (bech32: string, options?: Nip19Options) => { type: string; attrs: NAddrAttributes; }; export declare const makeNEventAttrs: (input: string, options?: Nip19Options) => NEventAttributes; export declare const makeNEventNode: (bech32: string, options?: Nip19Options) => { type: string; attrs: NEventAttributes; }; export declare const makeNProfileAttrs: (input: string, options?: Nip19Options) => NProfileAttributes; export declare const makeNProfileNode: (bech32: string, options?: Nip19Options) => { type: string; attrs: NProfileAttributes; }; export declare type Mark = TagMark | LinkMark | CodeMark | ItalicMark | BoldMark | StrikeMark; export declare type NAddrAttributes = { type: 'naddr'; bech32: string; identifier: string; pubkey: string; kind: number; relays: string[]; }; export declare const NAddrExtension: Node_3; export declare type NAddrNode = { type: 'naddr'; attrs: NAddrAttributes; }; declare type NAddrOptions = Nip19Options; export declare type NEventAttributes = { type: 'nevent' | 'note'; bech32: string; relays: string[]; id: string; kind?: number; author?: string; }; export declare const NEventExtension: Node_3; export declare type NEventNode = { type: 'nevent'; attrs: NEventAttributes; }; declare type NEventOptions = Nip19Options; declare type Nip19Options = { getRelayHints?: (pointer: DecodedResult) => string[]; }; declare type Node_2 = ParagraphNode | TextNode | HardBreak | HorizontalRule | NProfileNode | NEventNode | NAddrNode | ImageNode | VideoNode | HeadingNode | CodeBlockNode | BulletListNode | OrderedListNode | BlockQuoteNode | TweetNode | YoutubeNode | Bolt11Node; export { Node_2 as Node } export declare const NostrExtension: Extension; export declare interface NostrOptions { extend?: { nprofile?: Partial; nevent?: Partial; naddr?: Partial; link?: Partial; image?: Partial; youtube?: Partial; tweet?: Partial; video?: Partial; tag?: Partial; bolt11?: Partial; nsecReject?: Partial; fileUpload?: Partial; }; tweet?: boolean; tag?: boolean; bolt11?: boolean; link?: Partial | false; image?: Partial | false; video?: Partial | false; youtube?: Partial | false; nsecReject?: Partial | false; fileUpload?: (Partial & Pick) | false; nprofile?: Partial | false; nevent?: Partial | false; naddr?: Partial | false; } export declare interface NostrStorage { imeta: IMetaTags | null; setImeta: (imeta: IMetaTags) => void; getTags: () => TagAttributes[]; getNprofiles: () => NProfileAttributes[]; getNevents: () => NEventAttributes[]; getNaddrs: () => NAddrAttributes[]; getTtags: () => NostrEvent['tags']; getImetaTags: () => NostrEvent['tags']; getPtags: (hints?: boolean) => NostrEvent['tags']; getQtags: (hints?: boolean) => NostrEvent['tags']; getAtags: (hints?: boolean) => NostrEvent['tags']; getEditorTags: (hints?: boolean) => NostrEvent['tags']; } export declare type NProfileAttributes = { type: 'nprofile' | 'npub'; bech32: string; pubkey: string; relays: string[]; }; export declare const NProfileExtension: Node_3; export declare type NProfileNode = { type: 'nprofile'; attrs: NProfileAttributes; }; declare type NProfileOptions = Nip19Options; export declare const NSecRejectExtension: Extension; export declare type NSecRejectOptions = { onError?: (props: unknown) => void; }; export declare type OrderedListNode = { type: Extensions<'orderedList'>; content: ListItemNode[]; }; export declare type ParagraphNode = { type: Extensions<'paragraph'>; content?: Node_2[]; }; export declare type StrikeMark = { type: 'strike'; }; export declare interface TagAttributes { tag: string; } export declare const TagExtension: Mark_2; export declare type TagMark = { type: 'tag'; attrs: TagAttributes; }; export declare type TextNode = { type: Extensions<'text'>; marks?: Mark[]; text: string; }; export declare type TweetAttributes = { src: string; }; export declare const TweetExtension: Node_3; declare type TweetNode = { type: 'tweet'; attrs: TweetAttributes; }; declare class Uploader { editor: Editor; private options; constructor(editor: Editor, options: FileUploadOptions); get view(): EditorView; addFile(file: File, pos: number): boolean; getFiles(): FileAttributes[]; private findNodes; private updateNodeAttributes; private onUploadDone; private upload; start(): Promise; selectFiles(): Promise; handleDrop(event: DragEvent): boolean; handlePaste(event: ClipboardEvent): boolean | undefined; } export declare interface UploadResult { url: string; sha256: string; tags: NostrEvent_2['tags']; } export declare interface UploadTask { result?: UploadResult; error?: string; } export declare interface VideoAttributes { src: string; alt: string; sha256: string; file: File; tags: NostrEvent['tags']; uploading: boolean; error: string; } export declare const VideoExtension: Node_3; export declare type VideoNode = { type: 'video'; attrs: VideoAttributes; }; declare type YoutubeNode = { type: 'youtube'; attrs: { src: string; width?: number; height?: number; start?: number; }; }; export { } declare module '@tiptap/core' { interface Commands { bolt11: { insertBolt11: (options: { lnbc: string; }) => ReturnType; }; } } declare module '@tiptap/core' { interface Commands { naddr: { insertNAddr: (options: { bech32: string; }) => ReturnType; }; } } declare module '@tiptap/core' { interface Commands { fileUpload: { addFile: (file: File, pos: number) => ReturnType; selectFiles: () => ReturnType; uploadFiles: () => ReturnType; removeFailedUploads: () => ReturnType; removePendingUploads: () => ReturnType; }; } } declare module '@tiptap/core' { interface Commands { nevent: { insertNEvent: (options: { bech32: string; }) => ReturnType; }; } } declare module '@tiptap/core' { interface Commands { nostr: { setEventContent: (event: UnsignedEvent, imeta?: IMetaTags) => ReturnType; setEventContentKind0: (event: UnsignedEvent) => ReturnType; }; } } declare module '@tiptap/core' { interface Commands { nprofile: { insertNProfile: (options: { bech32: string; }) => ReturnType; }; } }