File tree Expand file tree Collapse file tree 5 files changed +48
-77
lines changed Expand file tree Collapse file tree 5 files changed +48
-77
lines changed Original file line number Diff line number Diff line change 8181 "hash-sum" : " ^2.0.0" ,
8282 "lint-staged" : " ^15.1.0" ,
8383 "monaco-editor-core" : " ^0.44.0" ,
84- "monaco-editor-textmate" : " ^4.0.0" ,
85- "monaco-textmate" : " ^3.0.1" ,
86- "monaco-volar" : " ^0.4.0" ,
87- "onigasm" : " ^2.2.5" ,
8884 "prettier" : " ^3.1.0" ,
85+ "shikiji" : " ^0.9.6" ,
86+ "shikiji-monaco" : " ^0.9.6" ,
8987 "simple-git-hooks" : " ^2.9.0" ,
9088 "sucrase" : " ^3.34.0" ,
9189 "typescript" : " ^5.3.2" ,
Original file line number Diff line number Diff line change @@ -13,7 +13,6 @@ import {
1313import * as monaco from ' monaco-editor-core'
1414import { initMonaco } from ' ./env'
1515import { getOrCreateModel } from ' ./utils'
16- import { loadGrammars , loadTheme } from ' monaco-volar'
1716import { Store } from ' ../store'
1817import type { PreviewMode } from ' ../editor/types'
1918
@@ -44,7 +43,7 @@ const lang = computed(() => (props.mode === 'css' ? 'css' : 'javascript'))
4443
4544const replTheme = inject <Ref <' dark' | ' light' >>(' theme' )!
4645onMounted (async () => {
47- const theme = await loadTheme ( monaco . editor )
46+ const theme = await import ( ' ./highlight ' ). then ( r => r . registerHighlighter () )
4847 ready .value = true
4948 await nextTick ()
5049
@@ -68,7 +67,6 @@ onMounted(async () => {
6867 inlineSuggest: {
6968 enabled: false ,
7069 },
71- ' semanticHighlighting.enabled' : true ,
7270 fixedOverflowWidgets: true ,
7371 })
7472 editor .value = editorInstance
@@ -137,8 +135,6 @@ onMounted(async () => {
137135 )
138136 }
139137
140- await loadGrammars (monaco , editorInstance )
141-
142138 editorInstance .addCommand (monaco .KeyMod .CtrlCmd | monaco .KeyCode .KeyS , () => {
143139 // ignore save event
144140 })
Original file line number Diff line number Diff line change @@ -2,8 +2,6 @@ import { jsDelivrUriBase } from '@volar/cdn'
22import * as volar from '@volar/monaco'
33import { editor , languages , Uri } from 'monaco-editor-core'
44import editorWorker from 'monaco-editor-core/esm/vs/editor/editor.worker?worker'
5- import * as onigasm from 'onigasm'
6- import onigasmWasm from 'onigasm/lib/onigasm.wasm?url'
75import { watchEffect } from 'vue'
86import { Store } from '../store'
97import { getOrCreateModel } from './utils'
@@ -14,7 +12,6 @@ let initted = false
1412export function initMonaco ( store : Store ) {
1513 if ( initted ) return
1614 loadMonacoEnv ( store )
17- loadWasm ( )
1815
1916 watchEffect ( ( ) => {
2017 // create a model for each file in the store
@@ -62,10 +59,6 @@ export function initMonaco(store: Store) {
6259 initted = true
6360}
6461
65- export function loadWasm ( ) {
66- return onigasm . loadWASM ( onigasmWasm )
67- }
68-
6962export class WorkerHost {
7063 onFetchCdnFile ( uri : string , text : string ) {
7164 getOrCreateModel ( Uri . parse ( uri ) , undefined , text )
Original file line number Diff line number Diff line change 1+ import * as monaco from 'monaco-editor-core'
2+ import { getHighlighterCore } from 'shikiji/core'
3+ import { getWasmInlined } from 'shikiji/wasm'
4+ import { shikijiToMonaco } from 'shikiji-monaco'
5+
6+ import langVue from 'shikiji/langs/vue.mjs'
7+ import themeDark from 'shikiji/themes/dark-plus.mjs'
8+ import themeLight from 'shikiji/themes/light-plus.mjs'
9+
10+
11+ export async function registerHighlighter ( ) {
12+ const highlighter = await getHighlighterCore ( {
13+ themes : [ themeDark , themeLight ] ,
14+ langs : [ langVue ] ,
15+ loadWasm : getWasmInlined
16+ } )
17+ monaco . languages . register ( { id : 'vue' } )
18+ shikijiToMonaco ( highlighter , monaco )
19+ return {
20+ light : themeLight . name ! ,
21+ dark : themeDark . name !
22+ }
23+ }
You can’t perform that action at this time.
0 commit comments