2022-02-02 16:17:59 +01:00
|
|
|
<script>
|
|
|
|
import SpectrumMDE from "./SpectrumMDE.svelte"
|
|
|
|
import { onMount } from "svelte"
|
|
|
|
|
|
|
|
export let value
|
2022-02-02 22:22:49 +01:00
|
|
|
export let height
|
2022-02-02 16:17:59 +01:00
|
|
|
|
|
|
|
let mde
|
|
|
|
|
|
|
|
// Keep the value up to date
|
|
|
|
$: mde && mde.value(value || "")
|
|
|
|
|
|
|
|
onMount(() => {
|
|
|
|
// Turn on preview mode
|
|
|
|
mde.togglePreview()
|
|
|
|
})
|
|
|
|
</script>
|
|
|
|
|
2022-02-02 22:22:49 +01:00
|
|
|
<div class="markdown-viewer" style="height:{height};">
|
2022-02-02 16:17:59 +01:00
|
|
|
<SpectrumMDE
|
|
|
|
bind:mde
|
|
|
|
scroll={false}
|
|
|
|
easyMDEOptions={{
|
|
|
|
initialValue: value,
|
|
|
|
toolbar: false,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<style>
|
2022-02-02 22:22:49 +01:00
|
|
|
.markdown-viewer {
|
|
|
|
overflow: auto;
|
|
|
|
}
|
2022-02-02 16:17:59 +01:00
|
|
|
/* Remove padding, borders and background colors */
|
|
|
|
.markdown-viewer :global(.editor-preview) {
|
|
|
|
padding: 0;
|
|
|
|
border: none;
|
|
|
|
background: transparent;
|
|
|
|
}
|
|
|
|
.markdown-viewer :global(.CodeMirror) {
|
|
|
|
border: none;
|
|
|
|
background: transparent;
|
|
|
|
padding: 0;
|
|
|
|
}
|
|
|
|
.markdown-viewer :global(.EasyMDEContainer) {
|
|
|
|
background: transparent;
|
|
|
|
}
|
|
|
|
/* Hide the actual code editor */
|
|
|
|
.markdown-viewer :global(.CodeMirror-scroll) {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
/*Hide the scrollbar*/
|
|
|
|
.markdown-viewer :global(.CodeMirror-vscrollbar) {
|
|
|
|
display: none !important;
|
|
|
|
}
|
|
|
|
/*Position relatively so we only consume whatever space we need */
|
|
|
|
.markdown-viewer :global(.editor-preview-full) {
|
|
|
|
position: relative;
|
|
|
|
}
|
|
|
|
/* Remove margin on the final component to fully trim the preview */
|
|
|
|
.markdown-viewer :global(.editor-preview-full > :last-child) {
|
|
|
|
margin-bottom: 0;
|
|
|
|
}
|
|
|
|
</style>
|