Skip to content

Commit

Permalink
fix(docs): add debouncing to math stack exchange example
Browse files Browse the repository at this point in the history
  • Loading branch information
BearToCode committed Nov 6, 2024
1 parent 4e920ef commit 0a39360
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions docs/src/lib/examples/MathStackExchangeExample.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import '$lib/styles/math-stack-exchange.scss';
import 'katex/dist/katex.min.css';
import { debounce } from '$lib/utils';
const carta = new Carta({
sanitizer: false,
Expand All @@ -28,12 +29,19 @@
});
export let value = placeholder;
let debouncedValue = value;
const updateValue = debounce((value: string) => {
debouncedValue = value;
}, 500);
$: updateValue(value);
</script>

<div class="math-stack-exchange-container">
<MarkdownEditor bind:value mode="tabs" theme="math-stack-exchange" {carta} />

{#key value}
<Markdown theme="math-stack-exchange" {value} {carta} />
{#key debouncedValue}
<Markdown theme="math-stack-exchange" value={debouncedValue} {carta} />
{/key}
</div>

0 comments on commit 0a39360

Please sign in to comment.