Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addCommand "Create Query Block" and "Preview" kb shortcut #178

Merged
merged 8 commits into from
Nov 30, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
addCommand "Create Query Block"
mdroidian committed Nov 22, 2023
commit 4661155f10fa9e69fddf780a5c7aa86876b377d8
54 changes: 54 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -606,6 +606,60 @@ svg.rs-svg-container {
})
),
});
extensionAPI.ui.commandPalette.addCommand({
label: "Create Query Block",
callback: async () => {
const uid = window.roamAlphaAPI.ui.getFocusedBlock()?.["block-uid"];
if (!uid) return;
await updateBlock({
uid,
text: "{{query block}}",
open: false,
});

await createBlock({
node: {
text: "scratch",
children: [
{
text: "custom",
},
{
text: "selections",
},
{
text: "conditions",
children: [
{
text: "clause",
children: [
{
text: "source",
children: [{ text: "node" }],
},
{
text: "relation",
},
],
},
],
},
],
},
parentUid: uid,
});
document.querySelector("body")?.click();
setTimeout(() => {
const conditionEl = document.querySelector(
".roamjs-query-condition-relation"
mdroidian marked this conversation as resolved.
Show resolved Hide resolved
);
const conditionInput = conditionEl?.querySelector(
"input"
) as HTMLInputElement;
conditionInput?.focus();
}, 200);
},
});

const renderCustomBlockView = ({
view,