Skip to content

Commit e82b767

Browse files
committed
fix resizing
1 parent 3179a01 commit e82b767

File tree

2 files changed

+13
-18
lines changed

2 files changed

+13
-18
lines changed

src/lib/client/viewer/Editor.svelte

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
/** @type {import('monaco-editor').editor.IStandaloneCodeEditor}*/
1212
let editor;
1313
14+
let w = 0;
15+
let h = 0;
16+
1417
onMount(() => {
1518
editor = monaco.editor.create(container);
1619
@@ -19,27 +22,24 @@
1922
};
2023
});
2124
22-
export function resize() {
23-
if (editor) {
24-
editor.layout();
25-
}
26-
}
27-
2825
$: if (editor) {
2926
editor.setModel(model);
3027
}
28+
29+
$: if ((editor && w) || h) {
30+
editor.layout();
31+
}
3132
</script>
3233

33-
<div bind:this={container} />
34+
<div bind:clientWidth={w} bind:clientHeight={h}>
35+
<div bind:this={container} />
36+
</div>
3437

3538
<!-- <textarea value={file ? file.contents : 'loading...'} on:input /> -->
3639
<style>
3740
div {
3841
width: 100%;
3942
height: 100%;
40-
resize: none;
41-
border: none;
42-
box-sizing: border-box;
4343
tab-size: 2;
4444
}
4545
</style>

src/lib/client/viewer/Viewer.svelte

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,20 @@
55
import Folder from './FileTree/Folder.svelte';
66
77
const { files, current, active, started, base, update } = getContext('filetree');
8-
9-
/** @type {import('svelte').SvelteComponent} */
10-
let editor;
11-
12-
const resize = () => editor.resize();
138
</script>
149

1510
<div class="viewer">
16-
<SplitPane type="vertical" min="100px" max="-100px" pos="50%" on:change={resize}>
11+
<SplitPane type="vertical" min="100px" max="-100px" pos="50%">
1712
<section slot="a">
18-
<SplitPane type="horizontal" min="20px" max="-20px" pos="200px" on:change={resize}>
13+
<SplitPane type="horizontal" min="20px" max="-20px" pos="200px">
1914
<section slot="a">
2015
<div class="filetree">
2116
<Folder {...$current.chapter.scope} files={$files} expanded />
2217
</div>
2318
</section>
2419

2520
<section slot="b">
26-
<Editor bind:this={editor} model={$active} />
21+
<Editor model={$active} />
2722
</section>
2823
</SplitPane>
2924
</section>

0 commit comments

Comments
 (0)