implemented image embedding links
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
import { t } from '../../translations.svelte';
|
||||
import { user } from '../../user.svelte';
|
||||
|
||||
const image_extensions = ['jpg','jpeg','gif','png','svg'];
|
||||
const router = useTinyRouter();
|
||||
let children = $state({});
|
||||
let new_dir = $state(null);
|
||||
@@ -80,12 +81,17 @@
|
||||
yikes();
|
||||
}
|
||||
|
||||
function is_image(file){
|
||||
let parts = file.toLowerCase().split('.');
|
||||
let ext = parts.pop();
|
||||
return image_extensions.includes(ext);
|
||||
}
|
||||
|
||||
async function loadChildren(p){
|
||||
p = p.substring(6);
|
||||
if (p == '') p = '/';
|
||||
children = { dirs : {}, files : {}, title : p};
|
||||
path = p;
|
||||
console.log(p);
|
||||
if (p == '/'){
|
||||
children.dirs[`/user/${user.id}`] = t('my_files');
|
||||
children.dirs['/project'] = t('projects')
|
||||
@@ -106,6 +112,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
function markdown(file){
|
||||
let parts = file.split('/');
|
||||
let md = ``;
|
||||
navigator.clipboard.writeText(md);
|
||||
}
|
||||
|
||||
function onclick(ev){
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
@@ -178,8 +190,11 @@
|
||||
<li class="file">
|
||||
<span class="symbol"></span>
|
||||
<a href={`/api/files${k}`} target="_blank">{v}</a>
|
||||
{#if is_image(k)}
|
||||
<button class="symbol" title={'markdown_code'} onclick={e => markdown(k)}></button>
|
||||
{/if}
|
||||
{#if delete_allowed}
|
||||
<button class="symbol" onclick={e => dropFile(`/api/files${k}`,v)}></button>
|
||||
<button class="symbol" title={t('delete_object',{'object':t('file')})} onclick={e => dropFile(`/api/files${k}`,v)}></button>
|
||||
{/if}
|
||||
</li>
|
||||
{/each}
|
||||
|
||||
Reference in New Issue
Block a user