Parent node contains the question
This commit is contained in:
parent
00f4e08627
commit
405113e639
1 changed files with 12 additions and 12 deletions
|
@ -18,7 +18,7 @@ async function fetchQuizzes() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const main = () => {
|
const main = () => {
|
||||||
console.log("logseq-quizhub-plugin LOADED!");
|
console.log("logseq-probo-plugin LOADED!");
|
||||||
|
|
||||||
logseq.Editor.registerSlashCommand("Get All Quizzes", async () => {
|
logseq.Editor.registerSlashCommand("Get All Quizzes", async () => {
|
||||||
const currBlock = await logseq.Editor.getCurrentBlock();
|
const currBlock = await logseq.Editor.getCurrentBlock();
|
||||||
|
@ -34,16 +34,16 @@ const main = () => {
|
||||||
|
|
||||||
logseq.Editor.registerSlashCommand("Create a new Probo quiz", async () => {
|
logseq.Editor.registerSlashCommand("Create a new Probo quiz", async () => {
|
||||||
await logseq.Editor.insertAtEditingCursor(
|
await logseq.Editor.insertAtEditingCursor(
|
||||||
`{{renderer :quizhub_${uniqueIdentifier()}}}`
|
`{{renderer :probo_${uniqueIdentifier()}}}`
|
||||||
);
|
);
|
||||||
|
|
||||||
const currBlock = await logseq.Editor.getCurrentBlock();
|
// const currBlock = await logseq.Editor.getCurrentBlock();
|
||||||
await logseq.Editor.insertBlock(currBlock.uuid, 'Write your question here...',
|
// await logseq.Editor.insertBlock(currBlock.uuid, 'Write your question here...',
|
||||||
{
|
// {
|
||||||
sibling: false,
|
// sibling: false,
|
||||||
before: false,
|
// before: false,
|
||||||
}
|
// }
|
||||||
);
|
// );
|
||||||
|
|
||||||
// await logseq.Editor.exitEditingMode();
|
// await logseq.Editor.exitEditingMode();
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ const main = () => {
|
||||||
logseq.App.onMacroRendererSlotted(async ({ slot, payload }) => {
|
logseq.App.onMacroRendererSlotted(async ({ slot, payload }) => {
|
||||||
const [type] = payload.arguments;
|
const [type] = payload.arguments;
|
||||||
const id = type.split("_")[1]?.trim();
|
const id = type.split("_")[1]?.trim();
|
||||||
const quizhubId = `quizhub_${id}`;
|
const proboId = `probo_${id}`;
|
||||||
|
|
||||||
logseq.provideModel({
|
logseq.provideModel({
|
||||||
async postQuiz() {
|
async postQuiz() {
|
||||||
|
@ -64,7 +64,7 @@ const main = () => {
|
||||||
})
|
})
|
||||||
return { question: question, answers: answers, uuid: child.uuid }
|
return { question: question, answers: answers, uuid: child.uuid }
|
||||||
});
|
});
|
||||||
quizzes.forEach(async (quiz, i) => {
|
quizzes.forEach(async (quiz, i) => {
|
||||||
const res = await fetch(endpoint, { method: 'POST', body: JSON.stringify(quiz) })
|
const res = await fetch(endpoint, { method: 'POST', body: JSON.stringify(quiz) })
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
const block = await logseq.Editor.getBlock(quiz.uuid)
|
const block = await logseq.Editor.getBlock(quiz.uuid)
|
||||||
|
@ -90,7 +90,7 @@ const main = () => {
|
||||||
`);
|
`);
|
||||||
|
|
||||||
logseq.provideUI({
|
logseq.provideUI({
|
||||||
key: `${quizhubId}`,
|
key: `${proboId}`,
|
||||||
slot,
|
slot,
|
||||||
reset: true,
|
reset: true,
|
||||||
template: `<button data-on-click="postQuiz" class="renderBtn">Save</button>`,
|
template: `<button data-on-click="postQuiz" class="renderBtn">Save</button>`,
|
||||||
|
|
Loading…
Reference in a new issue