-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
logseq-context.ts
63 lines (60 loc) · 1.75 KB
/
logseq-context.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import React from 'react'
export interface SearchResult {
pages?: string[]
blocks?: { content: string; page: number; uuid: string }[]
files?: string[]
}
export interface LogseqContextValue {
renderers: {
Page: React.FC<{
pageName: string
}>
Block: React.FC<{
blockId: string
}>
Breadcrumb: React.FC<{
blockId: string
levelLimit?: number
endSeparator?: boolean
}>
Tweet: React.FC<{
tweetId: string
}>
PageName: React.FC<{
pageName: string
}>
BlockReference: React.FC<{
blockId: string
}>
BacklinksCount: React.FC<{
id: string
className?: string
options?: {
'portal?'?: boolean
'hover?'?: boolean
renderFn?: (open?: boolean, count?: number) => React.ReactNode
}
}>
}
handlers: {
search: (
query: string,
filters: { 'pages?': boolean; 'blocks?': boolean; 'files?': boolean }
) => Promise<SearchResult>
addNewWhiteboard: (pageName: string) => void
addNewBlock: (content: string) => string // returns the new block uuid
queryBlockByUUID: (uuid: string) => any
getBlockPageName: (uuid: string) => string
getRedirectPageName: (uuidOrPageName: string) => string
insertFirstPageBlock: (pageName: string) => string
isWhiteboardPage: (pageName: string) => boolean
isMobile: () => boolean
saveAsset: (file: File) => Promise<string>
makeAssetUrl: (relativeUrl: string) => string
sidebarAddBlock: (uuid: string, type: 'block' | 'page') => void
redirectToPage: (uuidOrPageName: string) => void
copyToClipboard: (text: string, html: string) => void
}
isPublishing: boolean
}
export const LogseqContext = React.createContext<LogseqContextValue>({} as LogseqContextValue)