Shortcut menu instead of buttons

pull/3/head
Zef Hemel 2022-06-17 20:17:22 +02:00
parent 763775cdd3
commit 5fe10e441b
10 changed files with 202 additions and 137 deletions

View File

@ -30,7 +30,8 @@ function $255163dfff8c42fb$export$6dcbc6776594ee95(tree, matchFn) {
return null;
}
function $255163dfff8c42fb$export$dddeb721bf64f8df(tree, nodeType) {
return $255163dfff8c42fb$export$b86407c733c9fe3(tree, (n)=>n.type === nodeType);
return $255163dfff8c42fb$export$b86407c733c9fe3(tree, (n)=>n.type === nodeType
);
}
function $255163dfff8c42fb$export$b86407c733c9fe3(tree, matchFn) {
if (matchFn(tree)) return [
@ -61,7 +62,8 @@ function $255163dfff8c42fb$export$4d49acedd23f9b0a(tree, matchFn) {
return $255163dfff8c42fb$export$b86407c733c9fe3(tree, matchFn)[0];
}
function $255163dfff8c42fb$export$80a8b4335833eeeb(tree, nodeType) {
return $255163dfff8c42fb$export$b86407c733c9fe3(tree, (n)=>n.type === nodeType)[0];
return $255163dfff8c42fb$export$b86407c733c9fe3(tree, (n)=>n.type === nodeType
)[0];
}
function $255163dfff8c42fb$export$a41716fb83443983(tree, pos) {
if (pos < tree.from || pos > tree.to) return null;
@ -156,12 +158,12 @@ function $88d466d5aaf7a497$export$98e6a39c04603d36(language, text) {
const $d85524f23de2149a$export$8f49e4af10703ce3 = (0, $hVExJ$lezerlr.LRParser).deserialize({
const $d85524f23de2149a$export$8f49e4af10703ce3 = $hVExJ$lezerlr.LRParser.deserialize({
version: 13,
states: "&fOVQPOOOmQQO'#C^QOQPOOOtQPO'#C`OyQQO'#CkO!OQPO'#CmO!TQPO'#CnO!YQPO'#CoOOQO'#Cp'#CpO!_QQO,58xO!fQQO'#CcO#TQQO'#CaOOQO'#Ca'#CaOOQO,58z,58zO#lQPO,59VOOQO,59X,59XO#qQQO'#D`OOQO,59Y,59YOOQO,59Z,59ZOOQO-E6n-E6nO$YQQO,58}OtQPO,58|O$qQQO1G.qO%]QPO'#CrO%bQQO,59zOOQO'#Cg'#CgOOQO'#Ci'#CiO$YQQO'#CjOOQO'#Cd'#CdOOQO1G.i1G.iOOQO1G.h1G.hOOQO'#Cl'#ClOOQO7+$]7+$]OOQO,59^,59^OOQO-E6p-E6pO%yQPO'#C|O&RQPO,59UO$YQQO'#CqO&WQPO,59hOOQO1G.p1G.pOOQO,59],59]OOQO-E6o-E6o",
stateData: "&`~OiOS~ORPO~OjRO|SO!QTO!RUO!TVO~OgQX~P[ORYO~O}^O~OX_O~OR`O~OYbO~OgQa~P[OkdOsdOtdOudOvdOwdOxdOydOzdO~O{eOgTXjTX|TX!QTX!RTX!TTX~ORfO~OqgOg!SXj!SX|!SX!Q!SX!R!SX!T!SX~OXlOYlO[lOliOmiOnjOokO~O!OoO!PoOg_ij_i|_i!Q_i!R_i!T_i~ORqO~OqgOg!Saj!Sa|!Sa!Q!Sa!R!Sa!T!Sa~OquOrpX~OrwO~OquOrpa~O",
goto: "#d!TPP!UP!X!]!`!c!iPP!rP!r!r!X!w!X!X!X!z#Q#WPPPPPPPPP#^PPPPPPPPPPPPPPPPP#aRQOTWPXR]RR[RQZRRneQmdQskRxuVldkuRpfQXPRcXQvsRyvQh`RrhRtkRaU",
nodeNames: "\u26A0 Program Query Name WhereClause LogicalExpr AndExpr FilterExpr Value Number String Bool Regex Null List OrderClause Order LimitClause SelectClause RenderClause",
nodeNames: " Program Query Name WhereClause LogicalExpr AndExpr FilterExpr Value Number String Bool Regex Null List OrderClause Order LimitClause SelectClause RenderClause",
maxTerm: 51,
skippedNodes: [
0
@ -186,88 +188,88 @@ const $4ba3510c824e3aea$export$c5be9092dbf465c = self.syscall;
async function $2780e5830b4782c9$export$c3455d2d4767a60b(unfiltered = false) {
return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("space.listPages", unfiltered);
return $4ba3510c824e3aea$export$c5be9092dbf465c("space.listPages", unfiltered);
}
async function $2780e5830b4782c9$export$126f79da5c357ad(name) {
return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("space.readPage", name);
return $4ba3510c824e3aea$export$c5be9092dbf465c("space.readPage", name);
}
async function $2780e5830b4782c9$export$7ed3b3f07f54e00c(name, text) {
return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("space.writePage", name, text);
return $4ba3510c824e3aea$export$c5be9092dbf465c("space.writePage", name, text);
}
async function $2780e5830b4782c9$export$2e9858c25869c949(name) {
return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("space.deletePage", name);
return $4ba3510c824e3aea$export$c5be9092dbf465c("space.deletePage", name);
}
function $11a7e2bff790f35a$export$7945ba8eb1c827e6() {
return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.getCurrentPage");
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.getCurrentPage");
}
function $11a7e2bff790f35a$export$5e830c5f3cd8a610(newName) {
return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.setPage", newName);
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.setPage", newName);
}
function $11a7e2bff790f35a$export$c72d34660a162238() {
return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.getText");
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.getText");
}
function $11a7e2bff790f35a$export$da3f040fb23d21f() {
return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.getCursor");
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.getCursor");
}
function $11a7e2bff790f35a$export$a1544dad697b423d() {
return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.save");
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.save");
}
function $11a7e2bff790f35a$export$ff7962acd6052c28(name, pos) {
return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.navigate", name, pos);
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.navigate", name, pos);
}
function $11a7e2bff790f35a$export$da22d4a5076a7905() {
return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.reloadPage");
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.reloadPage");
}
function $11a7e2bff790f35a$export$a238cfe4a10e6279(url) {
return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.openUrl", url);
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.openUrl", url);
}
function $11a7e2bff790f35a$export$4f02334034b5dd8c(message) {
return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.flashNotification", message);
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.flashNotification", message);
}
function $11a7e2bff790f35a$export$83b9d7a71bc0a208(label, options, helpText = "", placeHolder = "") {
return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.filterBox", label, options, helpText, placeHolder);
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.filterBox", label, options, helpText, placeHolder);
}
function $11a7e2bff790f35a$export$53ed0b99a5f8822e(html, script, flex = 1) {
return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.showRhs", html, script, flex);
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.showRhs", html, script, flex);
}
function $11a7e2bff790f35a$export$f19f28e8a128fabe() {
return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.hideRhs");
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.hideRhs");
}
function $11a7e2bff790f35a$export$dcf0ace441f4b3a4(html, script, flex = 1) {
return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.showLhs", html, script, flex);
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.showLhs", html, script, flex);
}
function $11a7e2bff790f35a$export$1be2ad20c6324dcf() {
return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.hideLhs");
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.hideLhs");
}
function $11a7e2bff790f35a$export$6ebe231c70cc6efb(html, script, flex = 1) {
return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.showBhs", html, script, flex);
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.showBhs", html, script, flex);
}
function $11a7e2bff790f35a$export$a7a5aa8ba1cd9dc3() {
return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.hideBhs");
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.hideBhs");
}
function $11a7e2bff790f35a$export$f1124a4ce9f9bf29(text, pos) {
return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.insertAtPos", text, pos);
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.insertAtPos", text, pos);
}
function $11a7e2bff790f35a$export$54cb80d99fa58e48(from, to, text) {
return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.replaceRange", from, to, text);
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.replaceRange", from, to, text);
}
function $11a7e2bff790f35a$export$185d1f0722e636b2(pos) {
return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.moveCursor", pos);
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.moveCursor", pos);
}
function $11a7e2bff790f35a$export$df659347c0c138a9(text) {
return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.insertAtCursor", text);
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.insertAtCursor", text);
}
function $11a7e2bff790f35a$export$c4c1b7dbe675fa50(re) {
return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.matchBefore", re);
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.matchBefore", re);
}
function $11a7e2bff790f35a$export$635e15bbd66f01ea(change) {
return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.dispatch", change);
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.dispatch", change);
}
function $11a7e2bff790f35a$export$195ba6d62321b933(message, defaultValue = "") {
return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.prompt", message, defaultValue);
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.prompt", message, defaultValue);
}
@ -276,19 +278,19 @@ function $c3893eec0c49ec96$export$5dc1410f87262ed6(d) {
return d.toISOString().split("T")[0];
}
async function $c3893eec0c49ec96$export$151bb3c215c78d5a() {
await (0, $11a7e2bff790f35a$export$df659347c0c138a9)($c3893eec0c49ec96$export$5dc1410f87262ed6(new Date()));
await $11a7e2bff790f35a$export$df659347c0c138a9($c3893eec0c49ec96$export$5dc1410f87262ed6(new Date()));
}
async function $c3893eec0c49ec96$export$2177dd573df27382() {
let d = new Date();
d.setDate(d.getDate() + 1);
await (0, $11a7e2bff790f35a$export$df659347c0c138a9)($c3893eec0c49ec96$export$5dc1410f87262ed6(d));
await $11a7e2bff790f35a$export$df659347c0c138a9($c3893eec0c49ec96$export$5dc1410f87262ed6(d));
}
function $9072202279b76d33$export$1e8473eaf75b0d10(query) {
let n1 = (0, $88d466d5aaf7a497$export$87cc1c28aef74af1)(query, (0, $d85524f23de2149a$export$8f49e4af10703ce3).parse(query).topNode);
let n1 = $88d466d5aaf7a497$export$87cc1c28aef74af1(query, $d85524f23de2149a$export$8f49e4af10703ce3.parse(query).topNode);
// Clean the tree a bit
(0, $255163dfff8c42fb$export$90b8ac453fa63932)(n1, (n)=>{
$255163dfff8c42fb$export$90b8ac453fa63932(n1, (n)=>{
if (!n.type) {
let trimmed = n.text.trim();
if (!trimmed) return null;
@ -301,19 +303,19 @@ function $9072202279b76d33$export$1e8473eaf75b0d10(query) {
table: queryNode.children[0].children[0].text,
filter: []
};
let orderByNode = (0, $255163dfff8c42fb$export$80a8b4335833eeeb)(queryNode, "OrderClause");
let orderByNode = $255163dfff8c42fb$export$80a8b4335833eeeb(queryNode, "OrderClause");
if (orderByNode) {
let nameNode = (0, $255163dfff8c42fb$export$80a8b4335833eeeb)(orderByNode, "Name");
let nameNode = $255163dfff8c42fb$export$80a8b4335833eeeb(orderByNode, "Name");
parsedQuery.orderBy = nameNode.children[0].text;
let orderNode = (0, $255163dfff8c42fb$export$80a8b4335833eeeb)(orderByNode, "Order");
let orderNode = $255163dfff8c42fb$export$80a8b4335833eeeb(orderByNode, "Order");
parsedQuery.orderDesc = orderNode ? orderNode.children[0].text === "desc" : false;
}
let limitNode = (0, $255163dfff8c42fb$export$80a8b4335833eeeb)(queryNode, "LimitClause");
let limitNode = $255163dfff8c42fb$export$80a8b4335833eeeb(queryNode, "LimitClause");
if (limitNode) {
let nameNode = (0, $255163dfff8c42fb$export$80a8b4335833eeeb)(limitNode, "Number");
let nameNode = $255163dfff8c42fb$export$80a8b4335833eeeb(limitNode, "Number");
parsedQuery.limit = $9072202279b76d33$var$valueNodeToVal(nameNode);
}
let filterNodes = (0, $255163dfff8c42fb$export$dddeb721bf64f8df)(queryNode, "FilterExpr");
let filterNodes = $255163dfff8c42fb$export$dddeb721bf64f8df(queryNode, "FilterExpr");
for (let filterNode of filterNodes){
let val = undefined;
let valNode = filterNode.children[2].children[0];
@ -325,19 +327,19 @@ function $9072202279b76d33$export$1e8473eaf75b0d10(query) {
};
parsedQuery.filter.push(f);
}
let selectNode = (0, $255163dfff8c42fb$export$80a8b4335833eeeb)(queryNode, "SelectClause");
let selectNode = $255163dfff8c42fb$export$80a8b4335833eeeb(queryNode, "SelectClause");
if (selectNode) {
// console.log("Select node", JSON.stringify(selectNode));
parsedQuery.select = [];
(0, $255163dfff8c42fb$export$dddeb721bf64f8df)(selectNode, "Name").forEach((t)=>{
$255163dfff8c42fb$export$dddeb721bf64f8df(selectNode, "Name").forEach((t)=>{
parsedQuery.select.push(t.children[0].text);
});
// let nameNode = findNodeOfType(selectNode, "Number");
// parsedQuery.limit = +nameNode!.children![0].text!;
}
let renderNode = (0, $255163dfff8c42fb$export$80a8b4335833eeeb)(queryNode, "RenderClause");
let renderNode = $255163dfff8c42fb$export$80a8b4335833eeeb(queryNode, "RenderClause");
if (renderNode) {
let renderNameNode = (0, $255163dfff8c42fb$export$80a8b4335833eeeb)(renderNode, "String");
let renderNameNode = $255163dfff8c42fb$export$80a8b4335833eeeb(renderNode, "String");
parsedQuery.render = $9072202279b76d33$var$valueNodeToVal(renderNameNode);
}
// console.log(JSON.stringify(queryNode, null, 2));
@ -360,7 +362,8 @@ function $9072202279b76d33$var$valueNodeToVal(valNode) {
let stringVal = valNode.children[0].text;
return stringVal.substring(1, stringVal.length - 1);
case "List":
return (0, $255163dfff8c42fb$export$dddeb721bf64f8df)(valNode, "Value").map((t)=>$9072202279b76d33$var$valueNodeToVal(t.children[0]));
return $255163dfff8c42fb$export$dddeb721bf64f8df(valNode, "Value").map((t)=>$9072202279b76d33$var$valueNodeToVal(t.children[0])
);
}
}
function $9072202279b76d33$export$5884dae03c64f759(parsedQuery, records) {
@ -418,17 +421,19 @@ function $9072202279b76d33$export$5884dae03c64f759(parsedQuery, records) {
}
async function $9072202279b76d33$export$b3c659c1456e61b0(parsedQuery, data) {
if (parsedQuery.render) {
(0, ($parcel$interopDefault($hVExJ$handlebars))).registerHelper("json", (v)=>JSON.stringify(v));
(0, ($parcel$interopDefault($hVExJ$handlebars))).registerHelper("niceDate", (ts)=>(0, $c3893eec0c49ec96$export$5dc1410f87262ed6)(new Date(ts)));
(0, ($parcel$interopDefault($hVExJ$handlebars))).registerHelper("yaml", (v, prefix)=>{
($parcel$interopDefault($hVExJ$handlebars)).registerHelper("json", (v)=>JSON.stringify(v)
);
($parcel$interopDefault($hVExJ$handlebars)).registerHelper("niceDate", (ts)=>$c3893eec0c49ec96$export$5dc1410f87262ed6(new Date(ts))
);
($parcel$interopDefault($hVExJ$handlebars)).registerHelper("yaml", (v, prefix)=>{
if (typeof prefix === "string") {
let yaml = (0, ($parcel$interopDefault($hVExJ$yaml))).stringify(v).split("\n").join("\n" + prefix).trim();
let yaml = ($parcel$interopDefault($hVExJ$yaml)).stringify(v).split("\n").join("\n" + prefix).trim();
if (Array.isArray(v)) return "\n" + prefix + yaml;
else return yaml;
} else return (0, ($parcel$interopDefault($hVExJ$yaml))).stringify(v).trim();
} else return ($parcel$interopDefault($hVExJ$yaml)).stringify(v).trim();
});
let { text: templateText } = await (0, $2780e5830b4782c9$export$126f79da5c357ad)(parsedQuery.render);
let template = (0, ($parcel$interopDefault($hVExJ$handlebars))).compile(templateText, {
let { text: templateText } = await $2780e5830b4782c9$export$126f79da5c357ad(parsedQuery.render);
let template = ($parcel$interopDefault($hVExJ$handlebars)).compile(templateText, {
noEscape: true
});
return template(data);
@ -437,49 +442,49 @@ async function $9072202279b76d33$export$b3c659c1456e61b0(parsedQuery, data) {
}
(0, $hVExJ$jestglobals.test)("Test parser", ()=>{
let parsedBasicQuery = (0, $9072202279b76d33$export$1e8473eaf75b0d10)(`page`);
(0, $hVExJ$jestglobals.expect)(parsedBasicQuery.table).toBe("page");
let parsedQuery1 = (0, $9072202279b76d33$export$1e8473eaf75b0d10)(`task where completed = false and dueDate <= "{{today}}" order by dueDate desc limit 5`);
(0, $hVExJ$jestglobals.expect)(parsedQuery1.table).toBe("task");
(0, $hVExJ$jestglobals.expect)(parsedQuery1.orderBy).toBe("dueDate");
(0, $hVExJ$jestglobals.expect)(parsedQuery1.orderDesc).toBe(true);
(0, $hVExJ$jestglobals.expect)(parsedQuery1.limit).toBe(5);
(0, $hVExJ$jestglobals.expect)(parsedQuery1.filter.length).toBe(2);
(0, $hVExJ$jestglobals.expect)(parsedQuery1.filter[0]).toStrictEqual({
$hVExJ$jestglobals.test("Test parser", ()=>{
let parsedBasicQuery = $9072202279b76d33$export$1e8473eaf75b0d10(`page`);
$hVExJ$jestglobals.expect(parsedBasicQuery.table).toBe("page");
let parsedQuery1 = $9072202279b76d33$export$1e8473eaf75b0d10(`task where completed = false and dueDate <= "{{today}}" order by dueDate desc limit 5`);
$hVExJ$jestglobals.expect(parsedQuery1.table).toBe("task");
$hVExJ$jestglobals.expect(parsedQuery1.orderBy).toBe("dueDate");
$hVExJ$jestglobals.expect(parsedQuery1.orderDesc).toBe(true);
$hVExJ$jestglobals.expect(parsedQuery1.limit).toBe(5);
$hVExJ$jestglobals.expect(parsedQuery1.filter.length).toBe(2);
$hVExJ$jestglobals.expect(parsedQuery1.filter[0]).toStrictEqual({
op: "=",
prop: "completed",
value: false
});
(0, $hVExJ$jestglobals.expect)(parsedQuery1.filter[1]).toStrictEqual({
$hVExJ$jestglobals.expect(parsedQuery1.filter[1]).toStrictEqual({
op: "<=",
prop: "dueDate",
value: "{{today}}"
});
let parsedQuery2 = (0, $9072202279b76d33$export$1e8473eaf75b0d10)(`page where name =~ /interview\\/.*/"`);
(0, $hVExJ$jestglobals.expect)(parsedQuery2.table).toBe("page");
(0, $hVExJ$jestglobals.expect)(parsedQuery2.filter.length).toBe(1);
(0, $hVExJ$jestglobals.expect)(parsedQuery2.filter[0]).toStrictEqual({
let parsedQuery2 = $9072202279b76d33$export$1e8473eaf75b0d10(`page where name =~ /interview\\/.*/"`);
$hVExJ$jestglobals.expect(parsedQuery2.table).toBe("page");
$hVExJ$jestglobals.expect(parsedQuery2.filter.length).toBe(1);
$hVExJ$jestglobals.expect(parsedQuery2.filter[0]).toStrictEqual({
op: "=~",
prop: "name",
value: "interview\\/.*"
});
let parsedQuery3 = (0, $9072202279b76d33$export$1e8473eaf75b0d10)(`page where something != null`);
(0, $hVExJ$jestglobals.expect)(parsedQuery3.table).toBe("page");
(0, $hVExJ$jestglobals.expect)(parsedQuery3.filter.length).toBe(1);
(0, $hVExJ$jestglobals.expect)(parsedQuery3.filter[0]).toStrictEqual({
let parsedQuery3 = $9072202279b76d33$export$1e8473eaf75b0d10(`page where something != null`);
$hVExJ$jestglobals.expect(parsedQuery3.table).toBe("page");
$hVExJ$jestglobals.expect(parsedQuery3.filter.length).toBe(1);
$hVExJ$jestglobals.expect(parsedQuery3.filter[0]).toStrictEqual({
op: "!=",
prop: "something",
value: null
});
(0, $hVExJ$jestglobals.expect)((0, $9072202279b76d33$export$1e8473eaf75b0d10)(`page select name`).select).toStrictEqual([
$hVExJ$jestglobals.expect($9072202279b76d33$export$1e8473eaf75b0d10(`page select name`).select).toStrictEqual([
"name"
]);
(0, $hVExJ$jestglobals.expect)((0, $9072202279b76d33$export$1e8473eaf75b0d10)(`page select name, age`).select).toStrictEqual([
$hVExJ$jestglobals.expect($9072202279b76d33$export$1e8473eaf75b0d10(`page select name, age`).select).toStrictEqual([
"name",
"age",
]);
(0, $hVExJ$jestglobals.expect)((0, $9072202279b76d33$export$1e8473eaf75b0d10)(`gh-events where type in ["PushEvent", "somethingElse"]`)).toStrictEqual({
$hVExJ$jestglobals.expect($9072202279b76d33$export$1e8473eaf75b0d10(`gh-events where type in ["PushEvent", "somethingElse"]`)).toStrictEqual({
table: "gh-events",
filter: [
{
@ -492,13 +497,13 @@ async function $9072202279b76d33$export$b3c659c1456e61b0(parsedQuery, data) {
},
]
});
(0, $hVExJ$jestglobals.expect)((0, $9072202279b76d33$export$1e8473eaf75b0d10)(`something render "template/table"`)).toStrictEqual({
$hVExJ$jestglobals.expect($9072202279b76d33$export$1e8473eaf75b0d10(`something render "template/table"`)).toStrictEqual({
table: "something",
filter: [],
render: "template/table"
});
});
(0, $hVExJ$jestglobals.test)("Test performing the queries", ()=>{
$hVExJ$jestglobals.test("Test performing the queries", ()=>{
let data = [
{
name: "interview/My Interview",
@ -517,7 +522,7 @@ async function $9072202279b76d33$export$b3c659c1456e61b0(parsedQuery, data) {
age: 28
},
];
(0, $hVExJ$jestglobals.expect)((0, $9072202279b76d33$export$5884dae03c64f759)((0, $9072202279b76d33$export$1e8473eaf75b0d10)(`page where name =~ /interview\\/.*/`), data)).toStrictEqual([
$hVExJ$jestglobals.expect($9072202279b76d33$export$5884dae03c64f759($9072202279b76d33$export$1e8473eaf75b0d10(`page where name =~ /interview\\/.*/`), data)).toStrictEqual([
{
name: "interview/My Interview",
lastModified: 1
@ -527,7 +532,7 @@ async function $9072202279b76d33$export$b3c659c1456e61b0(parsedQuery, data) {
lastModified: 2
},
]);
(0, $hVExJ$jestglobals.expect)((0, $9072202279b76d33$export$5884dae03c64f759)((0, $9072202279b76d33$export$1e8473eaf75b0d10)(`page where name =~ /interview\\/.*/ order by lastModified`), data)).toStrictEqual([
$hVExJ$jestglobals.expect($9072202279b76d33$export$5884dae03c64f759($9072202279b76d33$export$1e8473eaf75b0d10(`page where name =~ /interview\\/.*/ order by lastModified`), data)).toStrictEqual([
{
name: "interview/My Interview",
lastModified: 1
@ -537,7 +542,7 @@ async function $9072202279b76d33$export$b3c659c1456e61b0(parsedQuery, data) {
lastModified: 2
},
]);
(0, $hVExJ$jestglobals.expect)((0, $9072202279b76d33$export$5884dae03c64f759)((0, $9072202279b76d33$export$1e8473eaf75b0d10)(`page where name =~ /interview\\/.*/ order by lastModified desc`), data)).toStrictEqual([
$hVExJ$jestglobals.expect($9072202279b76d33$export$5884dae03c64f759($9072202279b76d33$export$1e8473eaf75b0d10(`page where name =~ /interview\\/.*/ order by lastModified desc`), data)).toStrictEqual([
{
name: "interview/My Interview 2",
lastModified: 2
@ -547,19 +552,19 @@ async function $9072202279b76d33$export$b3c659c1456e61b0(parsedQuery, data) {
lastModified: 1
},
]);
(0, $hVExJ$jestglobals.expect)((0, $9072202279b76d33$export$5884dae03c64f759)((0, $9072202279b76d33$export$1e8473eaf75b0d10)(`page where age > 30`), data)).toStrictEqual([
$hVExJ$jestglobals.expect($9072202279b76d33$export$5884dae03c64f759($9072202279b76d33$export$1e8473eaf75b0d10(`page where age > 30`), data)).toStrictEqual([
{
name: "Pete",
age: 38
},
]);
(0, $hVExJ$jestglobals.expect)((0, $9072202279b76d33$export$5884dae03c64f759)((0, $9072202279b76d33$export$1e8473eaf75b0d10)(`page where age > 28 and age < 38`), data)).toStrictEqual([]);
(0, $hVExJ$jestglobals.expect)((0, $9072202279b76d33$export$5884dae03c64f759)((0, $9072202279b76d33$export$1e8473eaf75b0d10)(`page where age > 30 select name`), data)).toStrictEqual([
$hVExJ$jestglobals.expect($9072202279b76d33$export$5884dae03c64f759($9072202279b76d33$export$1e8473eaf75b0d10(`page where age > 28 and age < 38`), data)).toStrictEqual([]);
$hVExJ$jestglobals.expect($9072202279b76d33$export$5884dae03c64f759($9072202279b76d33$export$1e8473eaf75b0d10(`page where age > 30 select name`), data)).toStrictEqual([
{
name: "Pete"
}
]);
(0, $hVExJ$jestglobals.expect)((0, $9072202279b76d33$export$5884dae03c64f759)((0, $9072202279b76d33$export$1e8473eaf75b0d10)(`page where name in ["Pete"] select name`), data)).toStrictEqual([
$hVExJ$jestglobals.expect($9072202279b76d33$export$5884dae03c64f759($9072202279b76d33$export$1e8473eaf75b0d10(`page where name in ["Pete"] select name`), data)).toStrictEqual([
{
name: "Pete"
}

File diff suppressed because one or more lines are too long

View File

@ -123,8 +123,8 @@ functions:
command:
name: "Template: Quick Note"
key: "Alt-Shift-n"
button:
label: "🗒"
shortcut:
label: "Quick note"
quickTaskCommand:
path: ./template.ts:quickTaskCommand
command:

View File

@ -10,8 +10,8 @@ functions:
command:
name: "Materialized Queries: Update"
key: "Alt-q"
button:
label: "🔄"
shortcut:
label: "Update queries"
events:
- editor:pageLoaded
indexData:

View File

@ -1,4 +1,5 @@
import { ActionButton, Notification } from "../types";
import { useEffect, useState } from "react";
import { ShortcutItem, Notification } from "../types";
function prettyName(s: string | undefined): string {
if (!s) {
@ -11,7 +12,7 @@ export function TopBar({
pageName,
unsavedChanges,
notifications,
actionButtons,
shortcutItems,
onClick,
lhs,
rhs,
@ -19,11 +20,25 @@ export function TopBar({
pageName?: string;
unsavedChanges: boolean;
notifications: Notification[];
actionButtons: ActionButton[];
shortcutItems: ShortcutItem[];
onClick: () => void;
lhs?: React.ReactNode;
rhs?: React.ReactNode;
}) {
const [menuExpanded, setMenuExpanded] = useState(false);
useEffect(() => {
function closer() {
setMenuExpanded(false);
}
document.addEventListener("click", closer);
return () => {
document.removeEventListener("click", closer);
};
}, []);
return (
<div id="top" onClick={onClick}>
{lhs}
@ -42,18 +57,33 @@ export function TopBar({
</div>
)}
<div className="actions">
{actionButtons.map((actionButton, idx) => (
<button
key={idx}
onClick={(e) => {
e.stopPropagation();
actionButton.run();
}}
title={actionButton.tooltip}
>
{actionButton.label}
</button>
))}
<button
onClick={(e) => {
setMenuExpanded(!menuExpanded);
e.stopPropagation();
}}
>
...
</button>
{menuExpanded && (
<ul>
{shortcutItems.map((actionButton, idx) => (
<li key={idx}>
<a
href="#"
onClick={(e) => {
e.preventDefault();
e.stopPropagation();
setMenuExpanded(false);
actionButton.run();
}}
>
{actionButton.label}
</a>
</li>
))}
</ul>
)}
</div>
</div>
</div>

View File

@ -127,11 +127,11 @@ export class Editor {
// Command hook
this.commandHook = new CommandHook();
this.commandHook.on({
commandsUpdated: (commandMap, actionButtons) => {
commandsUpdated: (commandMap, shortcutItems) => {
this.viewDispatch({
type: "update-commands",
commands: commandMap,
actionButtons: actionButtons,
shortcutItems: shortcutItems,
});
},
});
@ -669,15 +669,15 @@ export class Editor {
pageName={viewState.currentPage}
notifications={viewState.notifications}
unsavedChanges={viewState.unsavedChanges}
actionButtons={[
shortcutItems={[
{
label: "⚡️",
label: "Run command",
orderId: 0,
run: () => {
this.viewDispatch({ type: "show-palette" });
},
},
...viewState.actionButtons,
...viewState.shortcutItems,
]}
onClick={() => {
dispatch({ type: "start-navigate" });

View File

@ -1,7 +1,7 @@
import { Hook, Manifest } from "@plugos/plugos/types";
import { System } from "@plugos/plugos/system";
import { EventEmitter } from "@plugos/plugos/event";
import { ActionButton } from "../types";
import { ShortcutItem } from "../types";
export type CommandDef = {
name: string;
@ -12,13 +12,12 @@ export type CommandDef = {
key?: string;
mac?: string;
// Action button
button?: ButtonDef;
// Shortcuts in UI
shortcut?: ShortcutDef;
};
export type ButtonDef = {
export type ShortcutDef = {
label: string;
tooltip?: string;
};
export type AppCommand = {
@ -33,7 +32,7 @@ export type CommandHookT = {
export type CommandHookEvents = {
commandsUpdated(
commandMap: Map<string, AppCommand>,
appButtons: ActionButton[]
appButtons: ShortcutItem[]
): void;
};
@ -42,11 +41,11 @@ export class CommandHook
implements Hook<CommandHookT>
{
editorCommands = new Map<string, AppCommand>();
actionButtons: ActionButton[] = [];
shortcutItems: ShortcutItem[] = [];
buildAllCommands(system: System<CommandHookT>) {
this.editorCommands.clear();
this.actionButtons = [];
this.shortcutItems = [];
for (let plug of system.loadedPlugs.values()) {
for (const [name, functionDef] of Object.entries(
plug.manifest!.functions
@ -61,10 +60,9 @@ export class CommandHook
return plug.invoke(name, []);
},
});
if (cmd.button) {
this.actionButtons.push({
label: cmd.button.label,
tooltip: cmd.button.tooltip,
if (cmd.shortcut) {
this.shortcutItems.push({
label: cmd.shortcut.label,
run: () => {
return plug.invoke(name, []);
},
@ -72,7 +70,7 @@ export class CommandHook
}
}
}
this.emit("commandsUpdated", this.editorCommands, this.actionButtons);
this.emit("commandsUpdated", this.editorCommands, this.shortcutItems);
}
apply(system: System<CommandHookT>): void {

View File

@ -76,7 +76,7 @@ export default function reducer(
return {
...state,
commands: action.commands,
actionButtons: action.actionButtons,
shortcutItems: action.shortcutItems,
};
case "show-notification":
return {

View File

@ -58,12 +58,12 @@ body {
#top {
display: flex;
flex-direction: row;
z-index: 20;
height: $top-bar-height;
background-color: rgb(213, 213, 213);
border-bottom: rgb(193, 193, 193) 1px solid;
color: rgb(55, 55, 55);
.main {
flex: 2;
@ -73,6 +73,10 @@ body {
font-size: 28px;
padding: 10px 20px;
@media (max-width: $max-editor-width) {
width: 800px;
}
.status {
position: absolute;
font-family: "iA-Mono";
@ -90,6 +94,14 @@ body {
.current-page {
font-family: var(--ui-font);
font-weight: bold;
overflow: hidden;
white-space: nowrap;
margin-right: 40px;
display: block;
text-overflow: ellipsis;
direction: rtl;
text-align: left;
}
.icon {
@ -107,15 +119,36 @@ body {
}
.actions {
float: right;
text-align: right;
margin-top: -35px;
button {
border: 0;
// border-radius: 5px;
// background-color: rgba(77,141,255,0.07);
background-color: transparent;
padding: 3px;
font-family: "IA-Mono", "Menlo";
font-size: 80%;
ul {
list-style: none;
margin-left: 0;
padding-left: 0;
margin-top: 0;
list-style: none;
background: #fff;
border: #000 1px solid;
text-align: left;
a {
padding: 3px;
font-family: var(--ui-font);
font-size: 50%;
text-decoration: none;
color: #000;
}
li {
padding-left: 10px;
padding-right: 10px;
padding-bottom: 5px;
}
li:hover {
background-color: #4d8dff12;
}
}
}
}

View File

@ -9,9 +9,8 @@ export type Notification = {
date: Date;
};
export type ActionButton = {
export type ShortcutItem = {
label: string;
tooltip?: string;
orderId?: number;
run: () => void;
};
@ -35,7 +34,7 @@ export type AppViewState = {
allPages: Set<PageMeta>;
commands: Map<string, AppCommand>;
notifications: Notification[];
actionButtons: ActionButton[];
shortcutItems: ShortcutItem[];
recentCommands: Map<string, Date>;
showFilterBox: boolean;
@ -61,7 +60,7 @@ export const initialViewState: AppViewState = {
commands: new Map(),
recentCommands: new Map(),
notifications: [],
actionButtons: [],
shortcutItems: [],
showFilterBox: false,
filterBoxHelpText: "",
filterBoxLabel: "",
@ -80,7 +79,7 @@ export type Action =
| {
type: "update-commands";
commands: Map<string, AppCommand>;
actionButtons: ActionButton[];
shortcutItems: ShortcutItem[];
}
| { type: "show-palette"; context?: string }
| { type: "hide-palette" }