-
-
Notifications
You must be signed in to change notification settings - Fork 382
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(monaco): editor colors interop, fix #594
- Loading branch information
Showing
9 changed files
with
98 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Vite + TS</title> | ||
</head> | ||
<body> | ||
<style> | ||
body { | ||
font-family: Arial, sans-serif; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
#app { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
height: 100vh; | ||
background-color: #f3f4f6; | ||
} | ||
</style> | ||
<div id="app"></div> | ||
<script type="module" src="/src/main.ts"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "playground", | ||
"type": "module", | ||
"version": "0.0.0", | ||
"private": true, | ||
"scripts": { | ||
"play": "vite" | ||
}, | ||
"devDependencies": { | ||
"typescript": "^5.2.2", | ||
"vite": "^5.1.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { getHighlighter } from 'shiki' | ||
import { shikiToMonaco } from '@shikijs/monaco' | ||
import * as monaco from 'monaco-editor-core' | ||
|
||
// Create the highlighter, it can be reused | ||
const highlighter = await getHighlighter({ | ||
themes: [ | ||
'min-dark', | ||
], | ||
langs: [ | ||
'javascript', | ||
'typescript', | ||
'vue', | ||
], | ||
}) | ||
|
||
// Register the languageIds first. Only registered languages will be highlighted. | ||
monaco.languages.register({ id: 'vue' }) | ||
monaco.languages.register({ id: 'typescript' }) | ||
monaco.languages.register({ id: 'javascript' }) | ||
|
||
// Register the themes from Shiki, and provide syntax highlighting for Monaco. // [!code highlight:2] | ||
shikiToMonaco(highlighter, monaco) | ||
|
||
// Create the editor | ||
monaco.editor.create(document.getElementById('app')!, { | ||
value: 'const a = 1', | ||
language: 'javascript', | ||
theme: 'min-dark', | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { fileURLToPath } from 'node:url' | ||
import { defineConfig } from 'vite' | ||
|
||
export default defineConfig({ | ||
resolve: { | ||
alias: { | ||
'@shikijs/monaco': fileURLToPath(new URL('../src/index.ts', import.meta.url)), | ||
}, | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
packages: | ||
- packages/* | ||
- packages/*/playground | ||
- playground | ||
- examples/* | ||
- docs | ||
|