working on saving wiki pages

This commit is contained in:
2025-09-10 08:51:03 +02:00
parent 4f6f969041
commit c63def1b85
5 changed files with 100 additions and 24 deletions

View File

@@ -20,9 +20,21 @@
}
}
async function onSet(newVal){
console.log('TODO: implement patch',newVal);
return true;
async function patch(data){
const url = api(`wiki/page/${id}`);
const res = await fetch(url,{
credentials:'include',
method:'PATCH',
body:JSON.stringify(data)
});
if (res.ok){
return true;
error = null;
} else {
error = await res.text();
return false;
}
}
onMount(loadPage);
@@ -32,5 +44,5 @@
<span class="error">{error}</span>
{/if}
{#if page}
<Editor editable={true} value={page.content} {onSet}></Editor>
<Editor editable={true} value={page.content} onSet={s => patch({content:s})}></Editor>
{/if}