working on saving wiki pages
This commit is contained in:
@@ -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}
|
||||
Reference in New Issue
Block a user