Support slashes in file names
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
"invoke": "word_count_command"
|
||||
},
|
||||
"Navigate To page": {
|
||||
"invoke": "link_navigate",
|
||||
"invoke": "linkNavigate",
|
||||
"key": "Ctrl-Enter",
|
||||
"mac": "Cmd-Enter"
|
||||
},
|
||||
@@ -24,9 +24,13 @@
|
||||
}
|
||||
},
|
||||
"events": {
|
||||
"page:click": ["taskToggle", "clickNavigate"]
|
||||
"page:click": ["taskToggle", "clickNavigate"],
|
||||
"editor:complete": ["pageComplete"]
|
||||
},
|
||||
"functions": {
|
||||
"pageComplete": {
|
||||
"path": "./navigate.ts:pageComplete"
|
||||
},
|
||||
"linkNavigate": {
|
||||
"path": "./navigate.ts:linkNavigate"
|
||||
},
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
import {syscall} from "./syscall.ts";
|
||||
|
||||
export async function publish(event: string, data?: object) {
|
||||
return await syscall("event.publish", event, data);
|
||||
}
|
||||
+15
-15
@@ -1,16 +1,16 @@
|
||||
export function syscall(name: string, ...args: Array<any>): any {
|
||||
let reqId = Math.floor(Math.random() * 1000000);
|
||||
// console.log("Syscall", name, reqId);
|
||||
return new Promise((resolve, reject) => {
|
||||
self.dispatchEvent(
|
||||
new CustomEvent("syscall", {
|
||||
detail: {
|
||||
id: reqId,
|
||||
name: name,
|
||||
args: args,
|
||||
callback: resolve,
|
||||
},
|
||||
}),
|
||||
);
|
||||
});
|
||||
export function syscall(name: string, ...args: any[]): any {
|
||||
let reqId = Math.floor(Math.random() * 1000000);
|
||||
// console.log("Syscall", name, reqId);
|
||||
return new Promise((resolve, reject) => {
|
||||
self.dispatchEvent(
|
||||
new CustomEvent("syscall", {
|
||||
detail: {
|
||||
id: reqId,
|
||||
name: name,
|
||||
args: args,
|
||||
callback: resolve,
|
||||
},
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -19,3 +19,18 @@ export async function clickNavigate(event: ClickEvent) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function pageComplete() {
|
||||
let prefix = await syscall("editor.matchBefore", "\\[\\[[\\w\\s]*");
|
||||
if (!prefix) {
|
||||
return null;
|
||||
}
|
||||
let allPages = await syscall("space.listPages");
|
||||
return {
|
||||
from: prefix.from + 2,
|
||||
options: allPages.map((pageMeta: any) => ({
|
||||
label: pageMeta.name,
|
||||
type: "page",
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user