|
|
@ -1,6 +1,6 @@ |
|
|
<script> |
|
|
<script> |
|
|
import SpectrumMDE from "./SpectrumMDE.svelte" |
|
|
import SpectrumMDE from "./SpectrumMDE.svelte" |
|
|
import { createEventDispatcher, onMount } from "svelte" |
|
|
import { createEventDispatcher } from "svelte" |
|
|
|
|
|
|
|
|
export let value = null |
|
|
export let value = null |
|
|
export let height = "300px" |
|
|
export let height = "300px" |
|
|
@ -15,6 +15,7 @@ |
|
|
// Ensure the value is updated if the value prop changes outside the editor's |
|
|
// Ensure the value is updated if the value prop changes outside the editor's |
|
|
// control |
|
|
// control |
|
|
$: checkValue(value) |
|
|
$: checkValue(value) |
|
|
|
|
|
$: mde?.codemirror.on("change", debouncedUpdate) |
|
|
|
|
|
|
|
|
const checkValue = val => { |
|
|
const checkValue = val => { |
|
|
if (mde && val !== latestValue) { |
|
|
if (mde && val !== latestValue) { |
|
|
@ -37,19 +38,17 @@ |
|
|
|
|
|
|
|
|
// Debounce the update function to avoid spamming it constantly |
|
|
// Debounce the update function to avoid spamming it constantly |
|
|
const debouncedUpdate = debounce(update, 250) |
|
|
const debouncedUpdate = debounce(update, 250) |
|
|
|
|
|
|
|
|
onMount(() => { |
|
|
|
|
|
mde.codemirror.on("change", debouncedUpdate) |
|
|
|
|
|
}) |
|
|
|
|
|
</script> |
|
|
</script> |
|
|
|
|
|
|
|
|
<SpectrumMDE |
|
|
{#key height} |
|
|
bind:mde |
|
|
<SpectrumMDE |
|
|
scroll={true} |
|
|
bind:mde |
|
|
{height} |
|
|
scroll={true} |
|
|
{id} |
|
|
{height} |
|
|
easyMDEOptions={{ |
|
|
{id} |
|
|
initialValue: value, |
|
|
easyMDEOptions={{ |
|
|
placeholder, |
|
|
initialValue: value, |
|
|
}} |
|
|
placeholder, |
|
|
/> |
|
|
}} |
|
|
|
|
|
/> |
|
|
|
|
|
{/key} |
|
|
|