@silverbulletmd/silverbullet 2.8.0 → 2.8.1
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.
|
@@ -464,20 +464,14 @@ export function editorSyscalls(client: Client): SysCallMapping {
|
|
|
464
464
|
}
|
|
465
465
|
},
|
|
466
466
|
"editor.moveCursor": (_ctx, pos: number, center = false) => {
|
|
467
|
+
// Always scroll into view so callers don't strand the cursor
|
|
468
|
+
// off-screen; `nearest` (default) is a no-op when already visible.
|
|
467
469
|
client.editorView.dispatch({
|
|
468
|
-
selection: {
|
|
469
|
-
|
|
470
|
-
|
|
470
|
+
selection: { anchor: pos },
|
|
471
|
+
effects: [
|
|
472
|
+
EditorView.scrollIntoView(pos, center ? { y: "center" } : {}),
|
|
473
|
+
],
|
|
471
474
|
});
|
|
472
|
-
if (center) {
|
|
473
|
-
client.editorView.dispatch({
|
|
474
|
-
effects: [
|
|
475
|
-
EditorView.scrollIntoView(pos, {
|
|
476
|
-
y: "center",
|
|
477
|
-
}),
|
|
478
|
-
],
|
|
479
|
-
});
|
|
480
|
-
}
|
|
481
475
|
client.editorView.focus();
|
|
482
476
|
},
|
|
483
477
|
"editor.moveCursorToLine": (
|
|
@@ -17,8 +17,25 @@ export function indexSyscalls(
|
|
|
17
17
|
client: Client,
|
|
18
18
|
): SysCallMapping {
|
|
19
19
|
return {
|
|
20
|
+
// Query collection API
|
|
20
21
|
"index.tag": (_ctx, tagName: string): LuaQueryCollection => {
|
|
21
|
-
return objectIndex.
|
|
22
|
+
return objectIndex.objectsWithTag(tagName);
|
|
23
|
+
},
|
|
24
|
+
// Alias for tag
|
|
25
|
+
"index.objects": (_ctx, tagName: string): LuaQueryCollection => {
|
|
26
|
+
return objectIndex.objectsWithTag(tagName);
|
|
27
|
+
},
|
|
28
|
+
"index.pages": (_ctx, tagName?: string): LuaQueryCollection => {
|
|
29
|
+
return objectIndex.rootTaggedObjects("page", tagName);
|
|
30
|
+
},
|
|
31
|
+
"index.subPages": (_ctx, pageName: string): LuaQueryCollection => {
|
|
32
|
+
return objectIndex.subPages(pageName);
|
|
33
|
+
},
|
|
34
|
+
"index.documents": (): LuaQueryCollection => {
|
|
35
|
+
return objectIndex.objectsWithTag("document");
|
|
36
|
+
},
|
|
37
|
+
"index.links": (): LuaQueryCollection => {
|
|
38
|
+
return objectIndex.objectsWithTag("link");
|
|
22
39
|
},
|
|
23
40
|
"index.contentPages": (): LuaQueryCollection => {
|
|
24
41
|
return objectIndex.contentPages();
|
|
@@ -26,6 +43,28 @@ export function indexSyscalls(
|
|
|
26
43
|
"index.metaPages": (): LuaQueryCollection => {
|
|
27
44
|
return objectIndex.metaPages();
|
|
28
45
|
},
|
|
46
|
+
"index.tasks": (_ctx, tagName?: string): LuaQueryCollection => {
|
|
47
|
+
return objectIndex.rootTaggedObjects("task", tagName);
|
|
48
|
+
},
|
|
49
|
+
"index.headers": (_ctx, tagName?: string): LuaQueryCollection => {
|
|
50
|
+
return objectIndex.rootTaggedObjects("header", tagName);
|
|
51
|
+
},
|
|
52
|
+
"index.items": (_ctx, tagName?: string): LuaQueryCollection => {
|
|
53
|
+
return objectIndex.rootTaggedObjects("item", tagName);
|
|
54
|
+
},
|
|
55
|
+
"index.paragraphs": (_ctx, tagName?: string): LuaQueryCollection => {
|
|
56
|
+
return objectIndex.rootTaggedObjects("paragraph", tagName);
|
|
57
|
+
},
|
|
58
|
+
"index.tables": (_ctx, tagName?: string): LuaQueryCollection => {
|
|
59
|
+
return objectIndex.rootTaggedObjects("table", tagName);
|
|
60
|
+
},
|
|
61
|
+
"index.tags": (): LuaQueryCollection => {
|
|
62
|
+
return objectIndex.objectsWithTag("tag");
|
|
63
|
+
},
|
|
64
|
+
"index.aspiringPages": (): LuaQueryCollection => {
|
|
65
|
+
return objectIndex.aspiringPages();
|
|
66
|
+
},
|
|
67
|
+
// Internals
|
|
29
68
|
"index.aggregates": (): LuaQueryCollection => {
|
|
30
69
|
return objectIndex.aggregates();
|
|
31
70
|
},
|
package/dist/plug-compile.js
CHANGED
package/package.json
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
LuaCollectionQuery,
|
|
3
|
+
LuaQueryCollection,
|
|
4
|
+
} from "../../client/space_lua/query_collection.ts";
|
|
2
5
|
import { syscall } from "@silverbulletmd/silverbullet/syscall";
|
|
3
6
|
import type { ObjectValue } from "../../plug-api/types/index.ts";
|
|
4
7
|
|
|
@@ -39,6 +42,91 @@ export function previewProcessedObjects(
|
|
|
39
42
|
return syscall("index.previewProcessedObjects", page, objects);
|
|
40
43
|
}
|
|
41
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Returns objects carrying the given tag as a query collection.
|
|
47
|
+
*/
|
|
48
|
+
export function objects(tagName: string): Promise<LuaQueryCollection> {
|
|
49
|
+
return syscall("index.objects", tagName);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Returns all pages (optionally filtered by an additional tag) as a query collection.
|
|
54
|
+
*/
|
|
55
|
+
export function pages(tagName?: string): Promise<LuaQueryCollection> {
|
|
56
|
+
return syscall("index.pages", tagName);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Returns all sub-pages of the given page (pages whose name starts with `<pageName>/`)
|
|
61
|
+
* as a query collection.
|
|
62
|
+
*/
|
|
63
|
+
export function subPages(pageName: string): Promise<LuaQueryCollection> {
|
|
64
|
+
return syscall("index.subPages", pageName);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Returns all documents as a query collection.
|
|
69
|
+
*/
|
|
70
|
+
export function documents(): Promise<LuaQueryCollection> {
|
|
71
|
+
return syscall("index.documents");
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Returns all links as a query collection.
|
|
76
|
+
*/
|
|
77
|
+
export function links(): Promise<LuaQueryCollection> {
|
|
78
|
+
return syscall("index.links");
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Returns all tasks (optionally filtered by an additional tag) as a query collection.
|
|
83
|
+
*/
|
|
84
|
+
export function tasks(tagName?: string): Promise<LuaQueryCollection> {
|
|
85
|
+
return syscall("index.tasks", tagName);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Returns all headers (optionally filtered by an additional tag) as a query collection.
|
|
90
|
+
*/
|
|
91
|
+
export function headers(tagName?: string): Promise<LuaQueryCollection> {
|
|
92
|
+
return syscall("index.headers", tagName);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Returns all list items (optionally filtered by an additional tag) as a query collection.
|
|
97
|
+
*/
|
|
98
|
+
export function items(tagName?: string): Promise<LuaQueryCollection> {
|
|
99
|
+
return syscall("index.items", tagName);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Returns all paragraphs (optionally filtered by an additional tag) as a query collection.
|
|
104
|
+
*/
|
|
105
|
+
export function paragraphs(tagName?: string): Promise<LuaQueryCollection> {
|
|
106
|
+
return syscall("index.paragraphs", tagName);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Returns all tables (optionally filtered by an additional tag) as a query collection.
|
|
111
|
+
*/
|
|
112
|
+
export function tables(tagName?: string): Promise<LuaQueryCollection> {
|
|
113
|
+
return syscall("index.tables", tagName);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Returns all aspiring (referenced but not yet created) pages as a query collection.
|
|
118
|
+
*/
|
|
119
|
+
export function aspiringPages(): Promise<LuaQueryCollection> {
|
|
120
|
+
return syscall("index.aspiringPages");
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Returns all tag objects as a query collection.
|
|
125
|
+
*/
|
|
126
|
+
export function tags(): Promise<LuaQueryCollection> {
|
|
127
|
+
return syscall("index.tags");
|
|
128
|
+
}
|
|
129
|
+
|
|
42
130
|
/**
|
|
43
131
|
* Queries objects using a Lua-based collection query
|
|
44
132
|
* @param tag - The tag to filter objects by
|