@silverbulletmd/silverbullet 2.10.0 → 2.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/client/asset_bundle/bundle.ts +0 -1
- package/client/config.ts +343 -0
- package/client/data/kv_primitives.ts +2 -2
- package/client/markdown_parser/constants.ts +5 -1
- package/client/plugos/hooks/command.ts +8 -6
- package/client/plugos/hooks/event.ts +60 -24
- package/client/plugos/hooks/mq.ts +0 -3
- package/client/plugos/hooks/slash_command.ts +3 -20
- package/client/plugos/hooks/syscall.ts +0 -4
- package/client/plugos/manifest_cache.ts +2 -34
- package/client/plugos/plug.ts +0 -3
- package/client/plugos/plug_compile.ts +3 -13
- package/client/plugos/sandboxes/sandbox.ts +2 -2
- package/client/plugos/sandboxes/worker_sandbox.ts +19 -9
- package/client/plugos/syscalls/capture.ts +104 -0
- package/client/plugos/syscalls/editor.ts +197 -56
- package/client/plugos/syscalls/event.ts +12 -9
- package/client/plugos/syscalls/fetch.ts +0 -4
- package/client/plugos/syscalls/icon.ts +46 -0
- package/client/plugos/syscalls/index.ts +33 -13
- package/client/plugos/syscalls/jsonschema.ts +0 -1
- package/client/plugos/syscalls/mq.ts +0 -1
- package/client/plugos/syscalls/navigator.ts +138 -0
- package/client/plugos/syscalls/search.ts +44 -0
- package/client/plugos/syscalls/shell.ts +0 -1
- package/client/plugos/syscalls/space.ts +250 -7
- package/client/plugos/syscalls/sync.ts +70 -4
- package/client/plugos/syscalls/system.ts +39 -0
- package/client/plugos/system.ts +9 -7
- package/client/plugos/types.ts +6 -6
- package/client/plugos/worker_runtime.ts +0 -2
- package/client/space_lua/aggregates.ts +6 -22
- package/client/space_lua/ast.ts +0 -5
- package/client/space_lua/ast_narrow.ts +0 -5
- package/client/space_lua/budget.ts +113 -0
- package/client/space_lua/budget_ui.ts +49 -0
- package/client/space_lua/eval.ts +113 -88
- package/client/space_lua/labels.ts +0 -4
- package/client/space_lua/numeric.ts +2 -7
- package/client/space_lua/parse.ts +0 -17
- package/client/space_lua/quarantine.ts +127 -0
- package/client/space_lua/query_collection.ts +18 -51
- package/client/space_lua/query_env.ts +0 -2
- package/client/space_lua/render_lua_markdown.ts +2 -7
- package/client/space_lua/render_widget.ts +18 -1
- package/client/space_lua/runtime.ts +64 -77
- package/client/space_lua/stdlib/format.ts +0 -12
- package/client/space_lua/stdlib/js.ts +0 -2
- package/client/space_lua/stdlib/load.ts +0 -1
- package/client/space_lua/stdlib/math.ts +0 -7
- package/client/space_lua/stdlib/net.ts +0 -4
- package/client/space_lua/stdlib/os.ts +0 -10
- package/client/space_lua/stdlib/pattern.ts +18 -23
- package/client/space_lua/stdlib/space_lua.ts +1 -2
- package/client/space_lua/stdlib/string_pack.ts +4 -7
- package/client/space_lua/stdlib/table.ts +0 -5
- package/client/space_lua/stdlib.ts +18 -31
- package/client/space_lua/tonumber.ts +0 -9
- package/dist/plug-compile.js +3 -4
- package/package.json +52 -41
- package/plug-api/lib/async.ts +1 -6
- package/plug-api/lib/collation.ts +22 -0
- package/plug-api/lib/crypto.ts +16 -15
- package/plug-api/lib/dates.ts +33 -0
- package/plug-api/lib/fuzzy.ts +282 -0
- package/plug-api/lib/json.ts +0 -6
- package/plug-api/lib/limited_map.ts +0 -2
- package/plug-api/lib/link_write.ts +27 -0
- package/plug-api/lib/ref.ts +28 -5
- package/plug-api/lib/resolve.ts +1 -9
- package/plug-api/lib/resolve_path.ts +290 -0
- package/plug-api/lib/shortcut.ts +15 -0
- package/plug-api/lib/tags.ts +0 -3
- package/plug-api/lib/transclusion.ts +28 -1
- package/plug-api/lib/tree.ts +0 -5
- package/plug-api/lib/yaml.ts +5 -44
- package/plug-api/syscall.ts +1 -5
- package/plug-api/syscalls/config.ts +2 -2
- package/plug-api/syscalls/editor.ts +75 -213
- package/plug-api/syscalls/icon.ts +18 -0
- package/plug-api/syscalls/index.ts +22 -4
- package/plug-api/syscalls/search.ts +11 -0
- package/plug-api/syscalls/space.ts +122 -5
- package/plug-api/syscalls/sync.ts +31 -2
- package/plug-api/syscalls/system.ts +46 -0
- package/plug-api/syscalls.ts +2 -0
- package/plug-api/system_mock.ts +13 -0
- package/plug-api/types/client.ts +20 -4
- package/plug-api/types/datastore.ts +11 -2
- package/plug-api/types/index.ts +10 -0
- package/plug-api/types/manifest.ts +7 -0
- package/plug-api/types/profile.ts +13 -0
- package/plug-api/types/revisions.ts +67 -0
- package/plug-api/ui/description.ts +64 -0
- package/plug-api/ui/hover.ts +69 -0
- package/plug-api/ui/index.ts +58 -2
- package/plug-api/ui/scroll.ts +30 -0
- package/plug-api/ui/tree_model.ts +285 -0
- package/plug-api/ui/tree_types.ts +67 -0
- package/plug-api/ui/use_fit_collapse.ts +67 -0
- package/plugs/builtin_plugs.ts +0 -1
- package/plugs/index/types.ts +9 -0
- package/plug-api/lib/memory_cache.ts +0 -21
- /package/plug-api/{ui → lib}/panel_styles.ts +0 -0
|
@@ -1,61 +1,66 @@
|
|
|
1
|
-
import { syscall } from "../syscall.ts";
|
|
2
1
|
import type {
|
|
2
|
+
DocumentCapability,
|
|
3
|
+
DocumentCapabilityDescriptor,
|
|
3
4
|
FilterOption,
|
|
4
5
|
NotificationType,
|
|
5
6
|
UploadFile,
|
|
6
7
|
} from "../../plug-api/types/client.ts";
|
|
7
|
-
import type { Path, Ref } from "../lib/ref.ts";
|
|
8
8
|
import type { PageMeta } from "../../plug-api/types/index.ts";
|
|
9
|
+
import type { Path, Ref } from "../lib/ref.ts";
|
|
10
|
+
import { syscall } from "../syscall.ts";
|
|
11
|
+
import type { PanelMode } from "../types/client.ts";
|
|
9
12
|
|
|
10
13
|
/**
|
|
11
|
-
* Exposes various editor utilities.
|
|
12
14
|
* Important: These syscalls are only available in the client.
|
|
13
15
|
* @module
|
|
14
16
|
*/
|
|
15
17
|
|
|
16
|
-
/**
|
|
17
|
-
* Returns the name of the page or document currently open in the editor.
|
|
18
|
-
* @returns the current page name
|
|
19
|
-
*/
|
|
20
18
|
export function getCurrentPage(): Promise<string> {
|
|
21
19
|
return syscall("editor.getCurrentPage");
|
|
22
20
|
}
|
|
23
21
|
|
|
24
|
-
/**
|
|
25
|
-
* Returns the meta data of the page or document currently open in the editor.
|
|
26
|
-
* @returns the current page meta data
|
|
27
|
-
*/
|
|
28
22
|
export function getCurrentPageMeta(): Promise<PageMeta | undefined> {
|
|
29
23
|
return syscall("editor.getCurrentPageMeta");
|
|
30
24
|
}
|
|
31
25
|
|
|
32
|
-
/**
|
|
33
|
-
* Returns the path of the page or document currently open in the editor.
|
|
34
|
-
* @returns the current page path
|
|
35
|
-
*/
|
|
36
26
|
export function getCurrentPath(): Promise<Path> {
|
|
37
27
|
return syscall("editor.getCurrentPath");
|
|
38
28
|
}
|
|
39
29
|
|
|
40
|
-
/**
|
|
41
|
-
* Returns the names of the pages that have been recently opened
|
|
42
|
-
* @returns the names of the recently opened pages
|
|
43
|
-
*/
|
|
44
30
|
export function getRecentlyOpenedPages(): Promise<PageMeta[]> {
|
|
45
31
|
return syscall("editor.getRecentlyOpenedPages");
|
|
46
32
|
}
|
|
47
33
|
|
|
48
34
|
/**
|
|
49
|
-
* Returns
|
|
50
|
-
*
|
|
35
|
+
* Returns a map of page name to the epoch-millisecond time it was last opened
|
|
36
|
+
* on this client. Only pages that have ever been opened appear in it.
|
|
51
37
|
*/
|
|
52
|
-
export function
|
|
53
|
-
return syscall("editor.
|
|
38
|
+
export function getLastOpenedMap(): Promise<Record<string, number>> {
|
|
39
|
+
return syscall("editor.getLastOpenedMap");
|
|
54
40
|
}
|
|
55
41
|
|
|
56
42
|
/**
|
|
57
|
-
* Returns the
|
|
43
|
+
* Returns the file extensions (without a leading dot) claimed by explicitly
|
|
44
|
+
* registered document editors.
|
|
58
45
|
*/
|
|
46
|
+
export function getViewableExtensions(): Promise<string[]> {
|
|
47
|
+
return syscall("editor.getViewableExtensions");
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Resolves the editor capability for a batch of documents without reading
|
|
52
|
+
* their bodies.
|
|
53
|
+
*/
|
|
54
|
+
export function getDocumentCapabilities(
|
|
55
|
+
documents: DocumentCapabilityDescriptor[],
|
|
56
|
+
): Promise<DocumentCapability[]> {
|
|
57
|
+
return syscall("editor.getDocumentCapabilities", documents);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function getCurrentEditor(): Promise<string> {
|
|
61
|
+
return syscall("editor.getCurrentEditor");
|
|
62
|
+
}
|
|
63
|
+
|
|
59
64
|
export function getText(): Promise<string> {
|
|
60
65
|
return syscall("editor.getText");
|
|
61
66
|
}
|
|
@@ -78,9 +83,6 @@ export function getCursor(): Promise<number> {
|
|
|
78
83
|
return syscall("editor.getCursor");
|
|
79
84
|
}
|
|
80
85
|
|
|
81
|
-
/**
|
|
82
|
-
* Returns the line number and column number of the cursor in the editor
|
|
83
|
-
*/
|
|
84
86
|
export function getSelection(): Promise<{
|
|
85
87
|
from: number;
|
|
86
88
|
to: number;
|
|
@@ -89,38 +91,21 @@ export function getSelection(): Promise<{
|
|
|
89
91
|
return syscall("editor.getSelection");
|
|
90
92
|
}
|
|
91
93
|
|
|
92
|
-
/**
|
|
93
|
-
* Sets the position of the cursor in the editor
|
|
94
|
-
* @param from the start position of the selection
|
|
95
|
-
* @param to the end position of the selection
|
|
96
|
-
*/
|
|
97
94
|
export function setSelection(from: number, to: number): Promise<void> {
|
|
98
95
|
return syscall("editor.setSelection", from, to);
|
|
99
96
|
}
|
|
100
97
|
|
|
101
98
|
/**
|
|
102
|
-
* Invoke a client command by name
|
|
103
99
|
* Note: only available on the client
|
|
104
|
-
* @param name name of the command
|
|
105
|
-
* @param args arguments to pass to the command
|
|
106
100
|
*/
|
|
107
101
|
export function invokeCommand(name: string, args?: string[]): Promise<any> {
|
|
108
102
|
return syscall("editor.invokeCommand", name, args);
|
|
109
103
|
}
|
|
110
104
|
|
|
111
|
-
/**
|
|
112
|
-
* Forces a save of the current page
|
|
113
|
-
*/
|
|
114
105
|
export function save(): Promise<void> {
|
|
115
106
|
return syscall("editor.save");
|
|
116
107
|
}
|
|
117
108
|
|
|
118
|
-
/**
|
|
119
|
-
* Navigates to the specified page reference
|
|
120
|
-
* @param pageRef the page reference to navigate to
|
|
121
|
-
* @param replaceState whether to replace the current history state in the browser history
|
|
122
|
-
* @param newWindow whether to open the page in a new window
|
|
123
|
-
*/
|
|
124
109
|
export function navigate(
|
|
125
110
|
ref: Ref | string,
|
|
126
111
|
replaceState = false,
|
|
@@ -133,9 +118,6 @@ export function navigate(
|
|
|
133
118
|
* Opens the specified page reference, restoring the previous cursor and scroll
|
|
134
119
|
* position for that page when one is remembered from the current session. Like
|
|
135
120
|
* navigate(), an explicit pointer in the ref (e.g. `#header`, `@123`) still wins.
|
|
136
|
-
* @param ref the page reference to open
|
|
137
|
-
* @param replaceState whether to replace the current history state in the browser history
|
|
138
|
-
* @param newWindow whether to open the page in a new window
|
|
139
121
|
*/
|
|
140
122
|
export function open(
|
|
141
123
|
ref: Ref | string,
|
|
@@ -145,26 +127,33 @@ export function open(
|
|
|
145
127
|
return syscall("editor.open", ref, replaceState, newWindow);
|
|
146
128
|
}
|
|
147
129
|
|
|
148
|
-
/**
|
|
149
|
-
* Opens the page navigator
|
|
150
|
-
* @param mode the mode to open the navigator in
|
|
151
|
-
*/
|
|
152
130
|
export function openPageNavigator(
|
|
153
131
|
mode: "page" | "meta" | "document" | "all" = "page",
|
|
154
132
|
): Promise<void> {
|
|
155
133
|
return syscall("editor.openPageNavigator", mode);
|
|
156
134
|
}
|
|
157
135
|
|
|
158
|
-
/**
|
|
159
|
-
* Opens the command palette
|
|
160
|
-
*/
|
|
161
136
|
export function openCommandPalette(): Promise<void> {
|
|
162
137
|
return syscall("editor.openCommandPalette");
|
|
163
138
|
}
|
|
164
139
|
|
|
165
140
|
/**
|
|
166
|
-
*
|
|
141
|
+
* Opens a navigator view by name.
|
|
142
|
+
* @returns whether a view actually opened. `false` means there was none to
|
|
143
|
+
* open.
|
|
167
144
|
*/
|
|
145
|
+
export function openNavigator(
|
|
146
|
+
name: string,
|
|
147
|
+
opts?: {
|
|
148
|
+
segment?: string;
|
|
149
|
+
phrase?: string;
|
|
150
|
+
dropdown?: unknown;
|
|
151
|
+
focus?: boolean;
|
|
152
|
+
},
|
|
153
|
+
): Promise<boolean> {
|
|
154
|
+
return syscall("editor.openNavigator", name, opts);
|
|
155
|
+
}
|
|
156
|
+
|
|
168
157
|
export function reloadPage(): Promise<void> {
|
|
169
158
|
return syscall("editor.reloadPage");
|
|
170
159
|
}
|
|
@@ -174,16 +163,10 @@ export function forceLint(): Promise<void> {
|
|
|
174
163
|
return syscall("editor.forceLint");
|
|
175
164
|
}
|
|
176
165
|
|
|
177
|
-
/**
|
|
178
|
-
* Force reloads the browser UI
|
|
179
|
-
*/
|
|
180
166
|
export function reloadUI(): Promise<void> {
|
|
181
167
|
return syscall("editor.reloadUI");
|
|
182
168
|
}
|
|
183
169
|
|
|
184
|
-
/**
|
|
185
|
-
* Rebuilds the editor state to ensure the dispatch updates the state.
|
|
186
|
-
*/
|
|
187
170
|
export function rebuildEditorState(): Promise<void> {
|
|
188
171
|
return syscall("editor.rebuildEditorState");
|
|
189
172
|
}
|
|
@@ -195,11 +178,6 @@ export function reloadConfigAndCommands(): Promise<void> {
|
|
|
195
178
|
return syscall("editor.reloadConfigAndCommands");
|
|
196
179
|
}
|
|
197
180
|
|
|
198
|
-
/**
|
|
199
|
-
* Opens the specified URL in the browser
|
|
200
|
-
* @param url the URL to open
|
|
201
|
-
* @param existingWindow whether to open the URL in an existing window
|
|
202
|
-
*/
|
|
203
181
|
export function openUrl(url: string, existingWindow = false): Promise<void> {
|
|
204
182
|
return syscall("editor.openUrl", url, existingWindow);
|
|
205
183
|
}
|
|
@@ -217,20 +195,14 @@ export function goHistory(delta: number): Promise<void> {
|
|
|
217
195
|
return syscall("editor.goHistory", delta);
|
|
218
196
|
}
|
|
219
197
|
|
|
220
|
-
/**
|
|
221
|
-
* Force the client to download the file in dataUrl with filename as file name
|
|
222
|
-
* @param filename the name of the file to download
|
|
223
|
-
* @param dataUrl the dataUrl of the file to download
|
|
224
|
-
*/
|
|
225
198
|
export function downloadFile(filename: string, dataUrl: string): Promise<void> {
|
|
226
199
|
return syscall("editor.downloadFile", filename, dataUrl);
|
|
227
200
|
}
|
|
228
201
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
*/
|
|
202
|
+
export function downloadSpaceFile(name: string): Promise<void> {
|
|
203
|
+
return syscall("editor.downloadSpaceFile", name);
|
|
204
|
+
}
|
|
205
|
+
|
|
234
206
|
export function uploadFile(
|
|
235
207
|
accept?: string,
|
|
236
208
|
capture?: string,
|
|
@@ -240,8 +212,6 @@ export function uploadFile(
|
|
|
240
212
|
|
|
241
213
|
/**
|
|
242
214
|
* Shows a flash notification to the user (top right corner)
|
|
243
|
-
* @param message the message to show
|
|
244
|
-
* @param type the type of notification to show
|
|
245
215
|
*/
|
|
246
216
|
export function flashNotification(
|
|
247
217
|
message: string,
|
|
@@ -252,10 +222,6 @@ export function flashNotification(
|
|
|
252
222
|
|
|
253
223
|
/**
|
|
254
224
|
* Exposes a filter box UI (similar to the page navigator and command palette)
|
|
255
|
-
* @param label the label to show left of the input box
|
|
256
|
-
* @param options the options to show and to filter on
|
|
257
|
-
* @param helpText the help text to show below the input box
|
|
258
|
-
* @param placeHolder the placeholder text to show in the input box
|
|
259
225
|
*/
|
|
260
226
|
export function filterBox(
|
|
261
227
|
label: string,
|
|
@@ -266,59 +232,48 @@ export function filterBox(
|
|
|
266
232
|
return syscall("editor.filterBox", label, options, helpText, placeHolder);
|
|
267
233
|
}
|
|
268
234
|
|
|
269
|
-
/**
|
|
270
|
-
* Shows a panel in the editor
|
|
271
|
-
* @param id the location of the panel to show
|
|
272
|
-
* @param mode the mode or "size" of the panel
|
|
273
|
-
* @param html the html content of the panel
|
|
274
|
-
* @param script the script content of the panel
|
|
275
|
-
*/
|
|
276
235
|
export function showPanel(
|
|
277
236
|
id: "lhs" | "rhs" | "bhs" | "modal",
|
|
278
|
-
mode:
|
|
237
|
+
mode: PanelMode,
|
|
279
238
|
html: HTMLElement | HTMLElement[] | string,
|
|
280
239
|
script = "",
|
|
281
240
|
): Promise<void> {
|
|
282
241
|
return syscall("editor.showPanel", id, mode, html, script);
|
|
283
242
|
}
|
|
284
243
|
|
|
285
|
-
/**
|
|
286
|
-
* Hides a panel in the editor
|
|
287
|
-
* @param id the location of the panel to hide
|
|
288
|
-
*/
|
|
289
244
|
export function hidePanel(id: "lhs" | "rhs" | "bhs" | "modal"): Promise<void> {
|
|
290
245
|
return syscall("editor.hidePanel", id);
|
|
291
246
|
}
|
|
292
247
|
|
|
293
|
-
/**
|
|
294
|
-
* Returns focus to the main editor.
|
|
295
|
-
*/
|
|
296
248
|
export function focus(): Promise<void> {
|
|
297
249
|
return syscall("editor.focus");
|
|
298
250
|
}
|
|
299
251
|
|
|
252
|
+
/**
|
|
253
|
+
* The slot of the panel whose iframe currently holds focus, or `undefined`
|
|
254
|
+
* if none does (focus is in the editor, or nowhere in particular).
|
|
255
|
+
*/
|
|
256
|
+
export function getFocusedPanelSlot(): Promise<
|
|
257
|
+
"lhs" | "rhs" | "bhs" | "modal" | undefined
|
|
258
|
+
> {
|
|
259
|
+
return syscall("editor.getFocusedPanelSlot");
|
|
260
|
+
}
|
|
261
|
+
|
|
300
262
|
export function showProgress(
|
|
301
|
-
|
|
302
|
-
|
|
263
|
+
progressType: "sync" | "index",
|
|
264
|
+
progressPercentage: number,
|
|
303
265
|
): Promise<void> {
|
|
304
|
-
return syscall("editor.showProgress",
|
|
266
|
+
return syscall("editor.showProgress", progressType, progressPercentage);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export function hideProgress(progressType: "sync" | "index"): Promise<void> {
|
|
270
|
+
return syscall("editor.showProgress", progressType);
|
|
305
271
|
}
|
|
306
272
|
|
|
307
|
-
/**
|
|
308
|
-
* Insert text at the specified position into the editor
|
|
309
|
-
* @param text the text to insert
|
|
310
|
-
* @param pos
|
|
311
|
-
*/
|
|
312
273
|
export function insertAtPos(text: string, pos: number): Promise<void> {
|
|
313
274
|
return syscall("editor.insertAtPos", text, pos);
|
|
314
275
|
}
|
|
315
276
|
|
|
316
|
-
/**
|
|
317
|
-
* Replace the text in the specified range in the editor
|
|
318
|
-
* @param from the start position of the range
|
|
319
|
-
* @param to the end position of the range
|
|
320
|
-
* @param text the text to replace with
|
|
321
|
-
*/
|
|
322
277
|
export function replaceRange(
|
|
323
278
|
from: number,
|
|
324
279
|
to: number,
|
|
@@ -327,21 +282,10 @@ export function replaceRange(
|
|
|
327
282
|
return syscall("editor.replaceRange", from, to, text);
|
|
328
283
|
}
|
|
329
284
|
|
|
330
|
-
/**
|
|
331
|
-
* Move the cursor to the specified position in the editor
|
|
332
|
-
* @param pos the position to move the cursor to
|
|
333
|
-
* @param center whether to center the cursor in the editor after moving
|
|
334
|
-
*/
|
|
335
285
|
export function moveCursor(pos: number, center = false): Promise<void> {
|
|
336
286
|
return syscall("editor.moveCursor", pos, center);
|
|
337
287
|
}
|
|
338
288
|
|
|
339
|
-
/**
|
|
340
|
-
* Move the cursor to the specified line and column in the editor
|
|
341
|
-
* @param line the line number to move the cursor to
|
|
342
|
-
* @param column the column number to move the cursor to
|
|
343
|
-
* @param center whether to center the cursor in the editor after moving
|
|
344
|
-
*/
|
|
345
289
|
export function moveCursorToLine(
|
|
346
290
|
line: number,
|
|
347
291
|
column = 1,
|
|
@@ -350,10 +294,6 @@ export function moveCursorToLine(
|
|
|
350
294
|
return syscall("editor.moveCursorToLine", line, column, center);
|
|
351
295
|
}
|
|
352
296
|
|
|
353
|
-
/**
|
|
354
|
-
* Insert text at the cursor position in the editor
|
|
355
|
-
* @param text the text to insert
|
|
356
|
-
*/
|
|
357
297
|
export function insertAtCursor(
|
|
358
298
|
text: string,
|
|
359
299
|
scrollIntoView = false,
|
|
@@ -374,12 +314,6 @@ export function dispatch(change: any): Promise<void> {
|
|
|
374
314
|
return syscall("editor.dispatch", change);
|
|
375
315
|
}
|
|
376
316
|
|
|
377
|
-
/**
|
|
378
|
-
* Prompt the user for text input
|
|
379
|
-
* @param message the message to show in the prompt
|
|
380
|
-
* @param defaultValue a default value pre-filled in the prompt
|
|
381
|
-
* @returns
|
|
382
|
-
*/
|
|
383
317
|
export function prompt(
|
|
384
318
|
message: string,
|
|
385
319
|
defaultValue = "",
|
|
@@ -388,11 +322,8 @@ export function prompt(
|
|
|
388
322
|
}
|
|
389
323
|
|
|
390
324
|
/**
|
|
391
|
-
* Prompt the user for confirmation
|
|
392
|
-
* @param message the message to show in the confirmation dialog
|
|
393
325
|
* @param options optional settings; set `destructive: true` to style the
|
|
394
326
|
* confirm button as a destructive (danger) action
|
|
395
|
-
* @returns
|
|
396
327
|
*/
|
|
397
328
|
export function confirm(
|
|
398
329
|
message: string,
|
|
@@ -401,128 +332,70 @@ export function confirm(
|
|
|
401
332
|
return syscall("editor.confirm", message, options);
|
|
402
333
|
}
|
|
403
334
|
|
|
404
|
-
/**
|
|
405
|
-
* Prompt the user for confirmation
|
|
406
|
-
* @param message the message to show in the confirmation dialog
|
|
407
|
-
* @returns
|
|
408
|
-
*/
|
|
409
335
|
export function alert(message: string): Promise<boolean> {
|
|
410
336
|
return syscall("editor.alert", message);
|
|
411
337
|
}
|
|
412
338
|
|
|
413
|
-
/**
|
|
414
|
-
* Get the value of a UI option
|
|
415
|
-
* @param key the key of the UI option to get
|
|
416
|
-
* @returns
|
|
417
|
-
*/
|
|
418
339
|
export function getUiOption(key: string): Promise<any> {
|
|
419
340
|
return syscall("editor.getUiOption", key);
|
|
420
341
|
}
|
|
421
342
|
|
|
422
|
-
/**
|
|
423
|
-
* Set the value of a UI option
|
|
424
|
-
* @param key the key of the UI option to set
|
|
425
|
-
* @param value the value to set the UI option to
|
|
426
|
-
*/
|
|
427
343
|
export function setUiOption(key: string, value: any): Promise<void> {
|
|
428
344
|
return syscall("editor.setUiOption", key, value);
|
|
429
345
|
}
|
|
430
346
|
|
|
431
|
-
/**
|
|
432
|
-
* Perform a fold at the current cursor position
|
|
433
|
-
*/
|
|
434
347
|
export function fold(): Promise<void> {
|
|
435
348
|
return syscall("editor.fold");
|
|
436
349
|
}
|
|
437
350
|
|
|
438
|
-
/**
|
|
439
|
-
* Perform an unfold at the current cursor position
|
|
440
|
-
*/
|
|
441
351
|
export function unfold(): Promise<void> {
|
|
442
352
|
return syscall("editor.unfold");
|
|
443
353
|
}
|
|
444
354
|
|
|
445
|
-
/**
|
|
446
|
-
* Toggle the fold at the current cursor position
|
|
447
|
-
*/
|
|
448
355
|
export function toggleFold(): Promise<void> {
|
|
449
356
|
return syscall("editor.toggleFold");
|
|
450
357
|
}
|
|
451
358
|
|
|
452
|
-
/**
|
|
453
|
-
* Fold all code blocks in the editor
|
|
454
|
-
*/
|
|
455
359
|
export function foldAll(): Promise<void> {
|
|
456
360
|
return syscall("editor.foldAll");
|
|
457
361
|
}
|
|
458
362
|
|
|
459
|
-
/**
|
|
460
|
-
* Unfold all code blocks in the editor
|
|
461
|
-
*/
|
|
462
363
|
export function unfoldAll(): Promise<void> {
|
|
463
364
|
return syscall("editor.unfoldAll");
|
|
464
365
|
}
|
|
465
366
|
|
|
466
|
-
/**
|
|
467
|
-
* Perform an undo operation of the last edit in the editor
|
|
468
|
-
*/
|
|
469
367
|
export function undo(): Promise<void> {
|
|
470
368
|
return syscall("editor.undo");
|
|
471
369
|
}
|
|
472
370
|
|
|
473
|
-
/**
|
|
474
|
-
* Perform a redo operation of the last undo in the editor
|
|
475
|
-
*/
|
|
476
371
|
export function redo(): Promise<void> {
|
|
477
372
|
return syscall("editor.redo");
|
|
478
373
|
}
|
|
479
374
|
|
|
480
|
-
/**
|
|
481
|
-
* Open the editor's native search panel
|
|
482
|
-
*/
|
|
483
375
|
export function openSearchPanel(): Promise<void> {
|
|
484
376
|
return syscall("editor.openSearchPanel");
|
|
485
377
|
}
|
|
486
378
|
|
|
487
|
-
/**
|
|
488
|
-
* Copy the specified data to the clipboard
|
|
489
|
-
* @param data the data to copy
|
|
490
|
-
*/
|
|
491
379
|
export function copyToClipboard(data: string | Blob): Promise<void> {
|
|
492
380
|
return syscall("editor.copyToClipboard", data);
|
|
493
381
|
}
|
|
494
382
|
|
|
495
|
-
/**
|
|
496
|
-
* Delete the current line in the editor
|
|
497
|
-
*/
|
|
498
383
|
export function deleteLine(): Promise<void> {
|
|
499
384
|
return syscall("editor.deleteLine");
|
|
500
385
|
}
|
|
501
386
|
|
|
502
|
-
/**
|
|
503
|
-
* Select the entire document
|
|
504
|
-
*/
|
|
505
387
|
export function selectAll(): Promise<void> {
|
|
506
388
|
return syscall("editor.selectAll");
|
|
507
389
|
}
|
|
508
390
|
|
|
509
|
-
/**
|
|
510
|
-
* Increase indentation of the current line or selection
|
|
511
|
-
*/
|
|
512
391
|
export function indentMore(): Promise<void> {
|
|
513
392
|
return syscall("editor.indentMore");
|
|
514
393
|
}
|
|
515
394
|
|
|
516
|
-
/**
|
|
517
|
-
* Decrease indentation of the current line or selection
|
|
518
|
-
*/
|
|
519
395
|
export function indentLess(): Promise<void> {
|
|
520
396
|
return syscall("editor.indentLess");
|
|
521
397
|
}
|
|
522
398
|
|
|
523
|
-
/**
|
|
524
|
-
* Comment or uncomment the current line in the editor
|
|
525
|
-
*/
|
|
526
399
|
export function toggleComment(): Promise<void> {
|
|
527
400
|
return syscall("editor.toggleComment");
|
|
528
401
|
}
|
|
@@ -535,7 +408,6 @@ export function moveLineDown(): Promise<void> {
|
|
|
535
408
|
return syscall("editor.moveLineDown");
|
|
536
409
|
}
|
|
537
410
|
|
|
538
|
-
// Cursor motion syscalls (wrappers around @codemirror/commands functions)
|
|
539
411
|
export function cursorCharLeft(): Promise<void> {
|
|
540
412
|
return syscall("editor.cursorCharLeft");
|
|
541
413
|
}
|
|
@@ -579,7 +451,6 @@ export function cursorPageDown(): Promise<void> {
|
|
|
579
451
|
return syscall("editor.cursorPageDown");
|
|
580
452
|
}
|
|
581
453
|
|
|
582
|
-
// Selection-extending motions
|
|
583
454
|
export function selectCharLeft(): Promise<void> {
|
|
584
455
|
return syscall("editor.selectCharLeft");
|
|
585
456
|
}
|
|
@@ -623,7 +494,6 @@ export function selectPageDown(): Promise<void> {
|
|
|
623
494
|
return syscall("editor.selectPageDown");
|
|
624
495
|
}
|
|
625
496
|
|
|
626
|
-
// Delete
|
|
627
497
|
export function deleteCharBackward(): Promise<void> {
|
|
628
498
|
return syscall("editor.deleteCharBackward");
|
|
629
499
|
}
|
|
@@ -651,7 +521,6 @@ export function insertNewline(): Promise<void> {
|
|
|
651
521
|
return syscall("editor.insertNewline");
|
|
652
522
|
}
|
|
653
523
|
|
|
654
|
-
// Completion popup
|
|
655
524
|
export function acceptCompletion(): Promise<boolean> {
|
|
656
525
|
return syscall("editor.acceptCompletion");
|
|
657
526
|
}
|
|
@@ -662,12 +531,6 @@ export function closeCompletion(): Promise<void> {
|
|
|
662
531
|
return syscall("editor.closeCompletion");
|
|
663
532
|
}
|
|
664
533
|
|
|
665
|
-
// Vim-mode specific syscalls
|
|
666
|
-
|
|
667
|
-
/**
|
|
668
|
-
* Execute a Vim ex command
|
|
669
|
-
* @param exCommand the ex command to execute
|
|
670
|
-
*/
|
|
671
534
|
export function vimEx(exCommand: string): Promise<any> {
|
|
672
535
|
return syscall("editor.vimEx", exCommand);
|
|
673
536
|
}
|
|
@@ -679,20 +542,19 @@ export function configureVimMode(): Promise<any> {
|
|
|
679
542
|
return syscall("editor.configureVimMode");
|
|
680
543
|
}
|
|
681
544
|
|
|
682
|
-
// Document editor specific syscalls
|
|
683
|
-
|
|
684
|
-
/**
|
|
685
|
-
* Send a message - or event if you will - to the currently used document editor
|
|
686
|
-
* @param type the message type, which can be listend to
|
|
687
|
-
* @param data data attached to the message
|
|
688
|
-
*/
|
|
689
545
|
export function sendMessage(type: string, data?: any): Promise<void> {
|
|
690
546
|
return syscall("editor.sendMessage", type, data);
|
|
691
547
|
}
|
|
692
548
|
|
|
693
|
-
/**
|
|
694
|
-
* Check if the editor is running on a mobile device
|
|
695
|
-
*/
|
|
696
549
|
export function isMobile(): Promise<boolean> {
|
|
697
550
|
return syscall("editor.isMobile");
|
|
698
551
|
}
|
|
552
|
+
|
|
553
|
+
/**
|
|
554
|
+
* Whether the client is currently laid out for a narrow screen — the
|
|
555
|
+
* breakpoint below which sidebar panels render as full-width drawers over the
|
|
556
|
+
* editor. A layout question, unlike `isMobile`, which asks about the pointer.
|
|
557
|
+
*/
|
|
558
|
+
export function isNarrowScreen(): Promise<boolean> {
|
|
559
|
+
return syscall("editor.isNarrowScreen");
|
|
560
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { syscall } from "../syscall.ts";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @returns the icon's SVG markup, or null if the name isn't a Feather icon
|
|
5
|
+
*/
|
|
6
|
+
export function feather(name: string): Promise<string | null> {
|
|
7
|
+
return syscall("icon.feather", name);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Renders a batch of Feather icons to SVG markup in one round trip.
|
|
12
|
+
* @returns map of icon name to SVG markup; unknown names are omitted
|
|
13
|
+
*/
|
|
14
|
+
export function resolveFeather(
|
|
15
|
+
names: string[],
|
|
16
|
+
): Promise<Record<string, string>> {
|
|
17
|
+
return syscall("icon.resolveFeather", names);
|
|
18
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { syscall } from "@silverbulletmd/silverbullet/syscall";
|
|
1
2
|
import type {
|
|
2
3
|
LuaCollectionQuery,
|
|
3
4
|
LuaQueryCollection,
|
|
4
5
|
} from "../../client/space_lua/query_collection.ts";
|
|
5
|
-
import { syscall } from "@silverbulletmd/silverbullet/syscall";
|
|
6
6
|
import type { ObjectValue } from "../../plug-api/types/index.ts";
|
|
7
7
|
/**
|
|
8
8
|
* Exposes the SilverBullet object indexing system
|
|
@@ -78,10 +78,10 @@ export function links(): Promise<LuaQueryCollection> {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
|
-
* Returns all relation objects as a query collection.
|
|
81
|
+
* Returns all relation objects, optionally filtered by kind, as a query collection.
|
|
82
82
|
*/
|
|
83
|
-
export function relations(): Promise<LuaQueryCollection> {
|
|
84
|
-
return syscall("index.relations");
|
|
83
|
+
export function relations(kind?: string): Promise<LuaQueryCollection> {
|
|
84
|
+
return syscall("index.relations", kind);
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
/**
|
|
@@ -119,6 +119,16 @@ export function tables(tagName?: string): Promise<LuaQueryCollection> {
|
|
|
119
119
|
return syscall("index.tables", tagName);
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
+
/**
|
|
123
|
+
* Whether a full indexing pass has ever completed for this space. False on a
|
|
124
|
+
* fresh client, and for as long as the first index takes on a large one --
|
|
125
|
+
* during which every object query answers with whatever has been indexed so
|
|
126
|
+
* far. Code that has to work in that window reads the space directly instead.
|
|
127
|
+
*/
|
|
128
|
+
export function isAvailable(): Promise<boolean> {
|
|
129
|
+
return syscall("index.isAvailable");
|
|
130
|
+
}
|
|
131
|
+
|
|
122
132
|
/**
|
|
123
133
|
* Returns all aspiring (referenced but not yet created) pages as a query collection.
|
|
124
134
|
*/
|
|
@@ -174,6 +184,13 @@ export function reindexSpace(): Promise<void> {
|
|
|
174
184
|
return syscall("index.reindexSpace");
|
|
175
185
|
}
|
|
176
186
|
|
|
187
|
+
/**
|
|
188
|
+
* Drops every indexed object belonging to a file.
|
|
189
|
+
*/
|
|
190
|
+
export function clearFileIndex(path: string): Promise<void> {
|
|
191
|
+
return syscall("index.clearFileIndex", path);
|
|
192
|
+
}
|
|
193
|
+
|
|
177
194
|
export function deleteObject(
|
|
178
195
|
page: string,
|
|
179
196
|
tag: string,
|
|
@@ -186,6 +203,7 @@ export type {
|
|
|
186
203
|
AnchorHit,
|
|
187
204
|
ResolveAnchorResult,
|
|
188
205
|
} from "../../plugs/index/types.ts";
|
|
206
|
+
|
|
189
207
|
import type { ResolveAnchorResult } from "../../plugs/index/types.ts";
|
|
190
208
|
|
|
191
209
|
/**
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { syscall } from "../syscall.ts";
|
|
2
|
+
|
|
3
|
+
export function rankObjects(
|
|
4
|
+
objects: any[],
|
|
5
|
+
phrase: string,
|
|
6
|
+
options?: {
|
|
7
|
+
fields?: Record<string, number | { weight: number; segments?: boolean }>;
|
|
8
|
+
},
|
|
9
|
+
): Promise<any[]> {
|
|
10
|
+
return syscall("search.rank", objects, phrase, options);
|
|
11
|
+
}
|