Skip to content

Commit 2943a90

Browse files
committed
html-sandbox: Implement basic unsandboxed preview
1 parent 853622a commit 2943a90

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
},
3030
"type": "module",
3131
"dependencies": {
32+
"@codemirror/lang-html": "^6.4.9",
3233
"@codemirror/lang-json": "^6.0.1",
3334
"@codemirror/lang-markdown": "^6.2.5",
3435
"@codemirror/lang-yaml": "^6.1.1",

pnpm-lock.yaml

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/routes/html-sandbox/+page.svelte

+26-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,38 @@
11
<script>
2+
import CodeMirror from "svelte-codemirror-editor";
3+
import { html } from "@codemirror/lang-html";
4+
import { theme } from "$lib/stores/codemirror.js";
5+
26
import Tool from "$lib/components/tool.svelte";
37
import TwoColumnView from "$lib/components/two-column-view.svelte";
8+
9+
let htmlText;
410
</script>
511

612
<Tool>
7-
<TwoColumnView leftTitle="HTML" rightTitle="Preview">
13+
<TwoColumnView leftTitle="HTML" rightTitle="Preview" hasPadding={false}>
814
<div slot="left">
9-
15+
<div class="codemirror-outer-wrapper">
16+
<CodeMirror
17+
bind:value={htmlText}
18+
lang={html()}
19+
theme={$theme} />
20+
</div>
1021
</div>
1122

1223
<div slot="right">
13-
24+
{@html htmlText}
1425
</div>
1526
</TwoColumnView>
16-
</Tool>
27+
</Tool>
28+
29+
<style>
30+
[slot=left],
31+
[slot=right] {
32+
height: 100%;
33+
}
34+
35+
.codemirror-outer-wrapper {
36+
height: 100%;
37+
}
38+
</style>

0 commit comments

Comments
 (0)