-
Notifications
You must be signed in to change notification settings - Fork 2
/
typings.d.ts
161 lines (152 loc) · 4.74 KB
/
typings.d.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
declare const BUILD_VERSION: string;
declare namespace Roam {
interface Block {
string?: string; // block
title?: string; //页面
uid: string;
order: number;
heading: number;
"view-type": "document" | "bullet" | "numbered";
open: boolean;
children: Block[];
}
}
type Menu = import("./src/contextmenu/types").Menu;
type ClickArea = import("./src/contextmenu/types").ClickArea;
type ClickArgs = import("./src/contextmenu/types").ClickArgs;
type registerMenu = (
menu: Menu[],
clickArea: ClickArea,
onClickArgs: ClickArgs
) => PromiseOrNot<void>;
type registerMenuCommand = (
clickArea: ClickArea,
menuMap: Record<string, Menu> | (() => Record<string, Menu>)
) => void;
type RoamEnhance = {
dependencyMap?: {
plugin: Record<string, string[]>;
dynamicMenu: Record<string, string[]>;
};
plugins?: ["metadata"?];
dynamicMenu?: ["pull-zhihu"?];
_plugins?: {};
_dynamicMenu?: {};
loaded?: Set<string>;
host?: string;
contextMenu?: {
menus: {
commonMenu: Menu[];
blockMenu: Menu[];
pageTitleMenu: Menu[];
pageTitleMenu_Sidebar: Menu[];
};
// 2 个 registerMenu 是直接帮用户注册 menu
registerMenu?: Set<registerMenu>;
registerMenuCommand?: registerMenuCommand;
dynamicMenu: { loaded: Set<string> };
onClickArgs: Partial<ClickArgs>;
};
libs?: {
react: typeof import("react");
ReactDOM: typeof import("react-dom");
};
} & typeof import("./src/globals").default;
declare interface document {
arrive: typeof import("arrive");
}
declare interface Window {
roamjs?: {
alerted: boolean;
loaded: Set<string>;
extension: {
[id: string]: {
[method: string]: (args?: unknown) => void;
};
};
dynamicElements: Set<HTMLElement>;
};
roamAlphaAPI?: {
ui: {
rightSidebar: {
getWindows: () => {
"collapsed?": boolean;
order: number;
"page-uid"?: string;
"block-uid"?: string;
"pinned?": false;
type: "outline" | "block";
"window-id": string;
}[];
addWindow: (options: { window: { "block-uid": uid; type: "outline" } }) => Promise<void>;
};
};
};
roam42?: {
help: {
displayMessage: (s: string, delay: number) => void;
};
smartBlocks?: {
exclusionBlockSymbol: string;
replaceFirstBlock: string;
addCommands: (array: any[]) => void;
customCommands: {
key: string; // `<% ${string} %> (SmartBlock function)`, sad - https://github.com/microsoft/TypeScript/issues/13969
icon: string;
value: string | Function;
processor: string;
}[];
activeWorkflow: {
outputAdditionalBlock: (text: string) => void;
arrayToWrite: any[];
};
proccessBlockWithSmartness: (s: string) => Promise<string>;
outputArrayWrite: () => Promise<void>;
};
dateProcessing: {
testIfRoamDateAndConvert: (s: string) => string;
};
common: {
sleep: (ms: number) => Promise<void>;
simulateMouseClick: (el: HTMLElement) => void;
navigateUiTo: (title: string) => void;
getPageUidByTitle: (title: string) => Promise<string>;
getBlockInfoByUID: (uid: string, withChild?: boolean) => Promise<[[Roam.Block]] | null>;
createBlock: (uid: string, order: number, string: string) => Promise<string>;
createPage: (pageTitle: string) => Promise<string>;
currentPageUID: () => Promise<string>;
batchCreateBlocks: (uid: string, order: number, array: string[]) => Promise<void>;
updateBlock: (uid: string, string: string, open?: boolean) => Promise<void>;
deleteBlock: (uid: string) => Promise<void>;
getDirectBlockParentUid: (
uid: string
) => Promise<{ parentUID: string; order: number } | null>;
getBlocksReferringToThisPage: (title: string) => Promise<[Roam.Block][]>;
getBlocksReferringToThisBlockRef: (uid: string) => Promise<[Roam.Block][]>;
getPageNamesFromBlockUidList: (
uids: string[]
) => Promise<[Roam.Block, { uid: string; title: string }][]>;
baseUrl: () => URL;
};
wB: {
commandAddRunFromAnywhere: (command: string, fn: () => void) => Promise<void>;
commandAddRunFromBlock: (command: string, fn: () => void) => Promise<void>;
path: {
launch: (
displayOutput: (outputUID: string, outputText: string) => Promise<void>,
excludeUIDs: string[],
startUID?: string,
startString?: string
) => void;
};
};
};
roam42KeyboardLib: {
changeHeading: (heading: number) => Promise<void>;
};
iziToast?: import("izitoast").IziToast;
roamEnhance?: RoamEnhance;
yoyo?: RoamEnhance;
}
declare const API_URL: string;
type PromiseOrNot<T> = Promise<T> | T;