Files
lucent-laravel/front/js/svelte/records/previews/PreviewFile.svelte
T

81 lines
2.5 KiB
Svelte
Raw Normal View History

2024-08-15 22:11:26 +03:00
<script>
import Icon from "../../common/Icon.svelte";
2026-05-06 18:11:42 +03:00
import { createEventDispatcher, getContext } from "svelte";
2024-08-15 22:11:26 +03:00
import Preview from "../../files/Preview.svelte";
2026-05-06 18:11:42 +03:00
import { previewTitle } from "./../Preview";
import { fileurl, htmlurl } from "../../files/imageserver.js";
2024-08-15 22:11:26 +03:00
import Status from "./../Status.svelte";
2024-08-18 17:23:18 +03:00
import Dropdown from "../../common/Dropdown.svelte";
2024-08-15 22:11:26 +03:00
const dispatch = createEventDispatcher();
const channel = getContext("channel");
2026-05-06 18:11:42 +03:00
export let file;
2024-08-15 22:11:26 +03:00
export let hasDelete = false;
2024-08-18 17:23:18 +03:00
export let hasInsert = false;
2024-08-15 22:11:26 +03:00
2024-08-18 17:23:18 +03:00
let imagePresets = Object.keys(channel.imageFilters);
2024-08-15 22:11:26 +03:00
function remove(e) {
e.preventDefault();
2026-05-06 18:11:42 +03:00
dispatch("remove_file", file.id);
2024-08-15 22:11:26 +03:00
}
2024-08-18 17:23:18 +03:00
function insert(e, preset) {
e.preventDefault();
2026-05-06 18:11:42 +03:00
// let html = htmlurl(channel, record, preset);
// let url = !preset
// ? `/${record._file.path}`
// : `/templates/${preset}/${record._file.path}`;
// dispatch("editor-insert", {
// html: html,
// url: channel.filesUrl + url,
// originalUrl: channel.filesUrl + "/" + record._file.path,
// record: record,
// });
2024-08-18 17:23:18 +03:00
}
2024-08-15 22:11:26 +03:00
</script>
<div class="preview-file">
2024-08-16 14:34:39 +03:00
<div style="display: flex;align-items: center;gap: 10px;">
<div class="image">
2026-05-06 18:11:42 +03:00
<Preview {file} size="small" />
2024-08-15 22:11:26 +03:00
</div>
2024-08-16 14:34:39 +03:00
<div class="title">
<div>
2026-05-06 18:11:42 +03:00
{file.filename}
2024-08-16 14:34:39 +03:00
</div>
</div>
2024-08-15 22:11:26 +03:00
</div>
2026-05-06 18:11:42 +03:00
<div
style="display: flex;gap:4px; align-items: center; margin-right: 10px;"
>
2024-08-18 17:23:18 +03:00
{#if hasInsert}
<div class="reference-action">
<Dropdown>
<div slot="button">
2026-05-06 18:11:42 +03:00
<Icon icon="photo-film" />
2024-08-18 17:23:18 +03:00
</div>
2026-05-06 18:11:42 +03:00
<button
class="dropdown-item button"
on:click={(e) => insert(e, null)}>original</button
>
2024-08-18 17:23:18 +03:00
{#each imagePresets as preset}
2026-05-06 18:11:42 +03:00
<button
class="dropdown-item button"
on:click={(e) => insert(e, preset)}>{preset}</button
>
2024-08-18 17:23:18 +03:00
{/each}
</Dropdown>
</div>
{/if}
{#if hasDelete}
<div class="reference-action">
2026-05-06 18:11:42 +03:00
<button class="button" on:click={remove}>
<Icon icon="trash-can" />
2024-08-18 17:23:18 +03:00
</button>
</div>
{/if}
</div>
2024-08-15 22:11:26 +03:00
</div>