markdown insert media
This commit is contained in:
@@ -1,37 +1,18 @@
|
||||
<script>
|
||||
import Icon from "../../common/Icon.svelte";
|
||||
|
||||
import { createEventDispatcher, getContext } from "svelte";
|
||||
import { createEventDispatcher } from "svelte";
|
||||
import Preview from "../../files/Preview.svelte";
|
||||
import Dropdown from "../../common/Dropdown.svelte";
|
||||
import { htmlurl } from "../../files/imageserver";
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
const channel = getContext("channel");
|
||||
|
||||
export let file;
|
||||
export let hasDelete = false;
|
||||
export let hasInsert = false;
|
||||
|
||||
let imagePresets = Object.keys(channel.imageFilters);
|
||||
|
||||
function remove(e) {
|
||||
e.preventDefault();
|
||||
dispatch("remove_file", file.id);
|
||||
}
|
||||
|
||||
function insert(e, preset) {
|
||||
e.preventDefault();
|
||||
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,
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="preview-file">
|
||||
@@ -48,25 +29,6 @@
|
||||
<div
|
||||
style="display: flex;gap:4px; align-items: center; margin-right: 10px;"
|
||||
>
|
||||
{#if hasInsert}
|
||||
<div class="reference-action">
|
||||
<Dropdown>
|
||||
<div slot="button">
|
||||
<Icon icon="photo-film" />
|
||||
</div>
|
||||
<button
|
||||
class="dropdown-item button"
|
||||
on:click={(e) => insert(e, null)}>original</button
|
||||
>
|
||||
{#each imagePresets as preset}
|
||||
<button
|
||||
class="dropdown-item button"
|
||||
on:click={(e) => insert(e, preset)}>{preset}</button
|
||||
>
|
||||
{/each}
|
||||
</Dropdown>
|
||||
</div>
|
||||
{/if}
|
||||
{#if hasDelete}
|
||||
<div class="reference-action">
|
||||
<button class="button" on:click={remove}>
|
||||
|
||||
Reference in New Issue
Block a user