-
-
-
+
+
+
Import Prompts
+
Upload a JSON file to import prompts.
+
+
+
+
+
+
+
+
Export Prompts
+
Select prompts to export, or leave all unchecked to export everything.
+
+
+
+
+
+
@@ -178,6 +195,70 @@ const supabaseKey = import.meta.env.PUBLIC_SUPABASE_ANON_KEY;
errorBox.style.display = 'block';
}
});
+
+ async function loadPromptCheckboxes() {
+ const promptList = document.getElementById('prompt-list');
+ const { data, error } = await supabase.from('prompts').select('id, title');
+
+ if (error) {
+ promptList.innerHTML = `
Failed to load prompts: ${error.message}
`;
+ return;
+ }
+
+ promptList.innerHTML = data
+ .map(
+ prompt => `
+
`
+ )
+ .join('');
+ }
+
+ document.getElementById('exportBtn').addEventListener('click', async () => {
+ const checkboxes = Array.from(document.querySelectorAll('#prompt-list input[type="checkbox"]'));
+ const selectedIds = checkboxes.filter(cb => cb.checked).map(cb => cb.value);
+
+ const { data, error } = selectedIds.length > 0
+ ? await supabase.from('prompts').select('*').in('id', selectedIds)
+ : await supabase.from('prompts').select('*');
+
+ const successBox = document.getElementById('success');
+ const errorBox = document.getElementById('error');
+ successBox.style.display = 'none';
+ errorBox.style.display = 'none';
+
+ if (error) {
+ errorBox.innerText = `Export failed: ${error.message}`;
+ errorBox.style.display = 'block';
+ return;
+ }
+
+ const output = data.map(p => ({
+ id: p.id,
+ type: p.type.toLowerCase(),
+ title: p.title,
+ description: p.description,
+ tags: `{${(p.tags || []).join(',')}}`,
+ createdat: p.createdat,
+ notes: p.notes || ''
+ }));
+
+ const blob = new Blob([JSON.stringify(output, null, 2)], {
+ type: 'application/json'
+ });
+
+ const url = URL.createObjectURL(blob);
+ const link = document.createElement('a');
+ link.href = url;
+ link.download = selectedIds.length > 0 ? 'selected-prompts.json' : 'all-prompts.json';
+ link.click();
+ URL.revokeObjectURL(url);
+ });
+
+ // Load checkboxes on DOM load
+ loadPromptCheckboxes();