Skip to content

Commit 7ab9d75

Browse files
committed
update demo
1 parent 1086943 commit 7ab9d75

File tree

1 file changed

+12
-33
lines changed

1 file changed

+12
-33
lines changed

explorer-v2/src/lib/MonacoEditor.svelte

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
<script context="module">
2+
const appStarting = new Promise((resolve) => setTimeout(resolve, 300));
3+
</script>
4+
15
<script>
26
import { onDestroy, onMount, createEventDispatcher } from 'svelte';
37
@@ -23,8 +27,9 @@
2327
getLeftEditor,
2428
codeActionProviderDisposable;
2529
const loadingMonaco = loadMonacoEditor();
30+
const starting = appStarting;
2631
// eslint-disable-next-line no-use-before-define -- TODO
27-
$: loading = Promise.all([waiting, loadingMonaco]);
32+
$: loading = Promise.all([waiting, loadingMonaco, starting]);
2833
$: {
2934
if (setLeftValue) {
3035
setLeftValue(code);
@@ -214,42 +219,23 @@
214219
}
215220
}
216221
217-
function typewriter(node, { speed = 50 }) {
218-
const valid =
219-
node.childNodes.length === 0 ||
220-
(node.childNodes.length === 1 && node.childNodes[0].nodeType === Node.TEXT_NODE);
221-
222-
if (!valid) {
223-
throw new Error(`This transition only works on elements with a single text node child`);
224-
}
225-
226-
const texts = node.textContent.split(/(?=\S)/);
227-
const duration = texts.length * speed;
222+
function loadingTypewriter(node) {
223+
const text = 'Loading...';
224+
const duration = 300;
228225
229226
return {
230227
duration,
231228
tick: (t) => {
232-
const i = ~~(texts.length * t);
233-
node.textContent = texts.slice(0, i).join('');
229+
const i = ~~(text.length * t);
230+
node.textContent = text.slice(0, i);
234231
}
235232
};
236233
}
237234
</script>
238235
239236
{#await loading}
240237
{#if started}
241-
{#if diffEditor}
242-
<div
243-
class="eslint-editor-monaco-root eslint-editor-monaco-root--wait eslint-editor-monaco-root__flex"
244-
>
245-
<pre in:typewriter>Loading...</pre>
246-
<pre in:typewriter>Loading...</pre>
247-
</div>
248-
{:else}
249-
<pre
250-
class="eslint-editor-monaco-root eslint-editor-monaco-root--wait"
251-
in:typewriter>Loading...</pre>
252-
{/if}
238+
<pre class="eslint-editor-monaco-root eslint-editor-monaco-root--wait" in:loadingTypewriter />
253239
{/if}
254240
{:then _}
255241
<div bind:this={rootElement} class="eslint-editor-monaco-root" />
@@ -270,11 +256,4 @@
270256
line-height: 21px;
271257
padding-left: 52px;
272258
}
273-
.eslint-editor-monaco-root__flex {
274-
display: flex;
275-
}
276-
.eslint-editor-monaco-root__flex > * {
277-
height: 100%;
278-
width: 50%;
279-
}
280259
</style>

0 commit comments

Comments
 (0)