mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-21 05:56:00 +00:00
markdown view tab
This commit is contained in:
47
packages/web/src/tabs/MarkdownViewTab.svelte
Normal file
47
packages/web/src/tabs/MarkdownViewTab.svelte
Normal file
@@ -0,0 +1,47 @@
|
||||
<script lang="ts" context="module">
|
||||
export const allowAddToFavorites = props => true;
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import LoadingInfo from '../elements/LoadingInfo.svelte';
|
||||
import Markdown from '../elements/Markdown.svelte';
|
||||
|
||||
import axiosInstance from '../utility/axiosInstance';
|
||||
|
||||
export let savedFile;
|
||||
|
||||
let isLoading = false;
|
||||
let text = null;
|
||||
|
||||
const handleLoad = async () => {
|
||||
isLoading = true;
|
||||
const resp = await axiosInstance.post('files/load', {
|
||||
folder: 'markdown',
|
||||
file: savedFile,
|
||||
format: 'text',
|
||||
});
|
||||
text = resp.data;
|
||||
isLoading = false;
|
||||
};
|
||||
|
||||
onMount(() => {
|
||||
handleLoad();
|
||||
});
|
||||
</script>
|
||||
|
||||
{#if isLoading}
|
||||
<LoadingInfo message="Loading markdown page" />
|
||||
{:else}
|
||||
<div>
|
||||
<Markdown source={text || ''} />
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
div {
|
||||
padding: 10px;
|
||||
overflow: auto;
|
||||
flex: 1;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user