Skip to content

Commit

Permalink
Show errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
thesoftwarephilosopher committed Aug 22, 2024
1 parent 8e52efb commit 02a7f76
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions site/monarch/monarch-playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ document.getElementById('root')?.append(<>
{editorContainer2}
</>);

const status = <div style='opacity:0.5' /> as HTMLDivElement;

document.body.append(status);

const editor1 = monaco.editor.create(editorContainer1, {
lineNumbers: 'off',
fontSize: 12,
Expand Down Expand Up @@ -53,8 +57,8 @@ const editor2 = monaco.editor.create(editorContainer2, {
tabSize: 2,
});

editor1.layout({ width: 700, height: 1200 });
editor2.layout({ width: 700, height: 1200 });
editor1.layout({ width: 900, height: 1200 });
editor2.layout({ width: 900, height: 1200 });

_updateTokenProvider();
editor1.onDidChangeModelContent(throttle(200, _updateTokenProvider));
Expand All @@ -63,11 +67,19 @@ async function _updateTokenProvider() {
const code = editor1.getModel()!.getValue();
const blob = new Blob([code], { type: 'text/javascript' });
const url = URL.createObjectURL(blob);
const mod = await import(url);
URL.revokeObjectURL(url);

monaco.languages.setMonarchTokensProvider('typescript', mod.tokenProvider);
setupTheme(mod.rules);
try {
const mod = await import(url);
URL.revokeObjectURL(url);

monaco.languages.setMonarchTokensProvider('typescript', mod.tokenProvider);
setupTheme(mod.rules);

status.textContent = '';
}
catch (e: any) {
status.textContent = e.message;
}
}

window.onbeforeunload = (e) => {
Expand Down

0 comments on commit 02a7f76

Please sign in to comment.