get schema button
This commit is contained in:
@@ -130,6 +130,25 @@
|
|||||||
function cancel() {
|
function cancel() {
|
||||||
push('/');
|
push('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let copied = false;
|
||||||
|
function copyJson() {
|
||||||
|
const payload = {
|
||||||
|
title,
|
||||||
|
description,
|
||||||
|
config,
|
||||||
|
questions: questions.map((q) => ({
|
||||||
|
prompt: q.prompt,
|
||||||
|
explanation: q.explanation,
|
||||||
|
answers: q.answers,
|
||||||
|
correct_answer_indices: q.correct_answer_indices,
|
||||||
|
})),
|
||||||
|
};
|
||||||
|
navigator.clipboard.writeText(JSON.stringify(payload, null, 2)).then(() => {
|
||||||
|
copied = true;
|
||||||
|
setTimeout(() => { copied = false; }, 2000);
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<header class="page-header page-header-fixed">
|
<header class="page-header page-header-fixed">
|
||||||
@@ -166,7 +185,10 @@
|
|||||||
placeholder="Paste deck JSON (title, description, config, questions)"
|
placeholder="Paste deck JSON (title, description, config, questions)"
|
||||||
rows="8"
|
rows="8"
|
||||||
></textarea>
|
></textarea>
|
||||||
|
<div class="json-actions">
|
||||||
<button type="button" class="btn btn-secondary" onclick={loadFromJson}>Load from JSON</button>
|
<button type="button" class="btn btn-secondary" onclick={loadFromJson}>Load from JSON</button>
|
||||||
|
<button type="button" class="btn btn-secondary" onclick={copyJson}>{copied ? 'Copied!' : 'Copy JSON'}</button>
|
||||||
|
</div>
|
||||||
{#if jsonError}
|
{#if jsonError}
|
||||||
<p class="error">{jsonError}</p>
|
<p class="error">{jsonError}</p>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -291,6 +313,12 @@
|
|||||||
margin-bottom: 0.5rem;
|
margin-bottom: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.json-actions {
|
||||||
|
display: flex;
|
||||||
|
gap: 0.5rem;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
.form-group {
|
.form-group {
|
||||||
margin-bottom: 1rem;
|
margin-bottom: 1rem;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user