10 changed files with 130 additions and 5 deletions
@ -0,0 +1,43 @@ |
|||||||
|
<script> |
||||||
|
import { api } from '../../urls.svelte.js'; |
||||||
|
import { t } from '../../translations.svelte.js'; |
||||||
|
|
||||||
|
import Editor from '../../Components/MarkdownEditor.svelte'; |
||||||
|
|
||||||
|
let comment = $state({source:null,rendered:null}); |
||||||
|
let error = $state(null); |
||||||
|
let link = $state(null); |
||||||
|
|
||||||
|
async function onclick(ev){ |
||||||
|
let data = { |
||||||
|
url : link, |
||||||
|
comment : comment.source |
||||||
|
}; |
||||||
|
const url = api('bookmark/save'); |
||||||
|
const resp = await fetch(url,{ |
||||||
|
credentials : 'include', |
||||||
|
method : 'POST', |
||||||
|
body : JSON.stringify(data) |
||||||
|
}); |
||||||
|
if (resp.ok) { |
||||||
|
} else { |
||||||
|
error = await resp.text(); |
||||||
|
} |
||||||
|
} |
||||||
|
</script> |
||||||
|
|
||||||
|
<fieldset> |
||||||
|
<legend>{t('Bookmarks')}</legend> |
||||||
|
{#if error} |
||||||
|
<span class="error">{error}</span> |
||||||
|
{/if} |
||||||
|
<label> |
||||||
|
{t('URL')} |
||||||
|
<input bind:value={link} /> |
||||||
|
</label> |
||||||
|
<label> |
||||||
|
{t('Comment')} |
||||||
|
<Editor simple={true} bind:value={comment} /> |
||||||
|
</label> |
||||||
|
<button {onclick}>{t('save')}</button> |
||||||
|
</fieldset> |
||||||
Loading…
Reference in new issue