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 81
81
"hash-sum" : " ^2.0.0" ,
82
82
"lint-staged" : " ^15.1.0" ,
83
83
"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" ,
88
84
"prettier" : " ^3.1.0" ,
85
+ "shikiji" : " ^0.9.6" ,
86
+ "shikiji-monaco" : " ^0.9.6" ,
89
87
"simple-git-hooks" : " ^2.9.0" ,
90
88
"sucrase" : " ^3.34.0" ,
91
89
"typescript" : " ^5.3.2" ,
Original file line number Diff line number Diff line change @@ -13,7 +13,6 @@ import {
13
13
import * as monaco from ' monaco-editor-core'
14
14
import { initMonaco } from ' ./env'
15
15
import { getOrCreateModel } from ' ./utils'
16
- import { loadGrammars , loadTheme } from ' monaco-volar'
17
16
import { Store } from ' ../store'
18
17
import type { PreviewMode } from ' ../editor/types'
19
18
@@ -44,7 +43,7 @@ const lang = computed(() => (props.mode === 'css' ? 'css' : 'javascript'))
44
43
45
44
const replTheme = inject <Ref <' dark' | ' light' >>(' theme' )!
46
45
onMounted (async () => {
47
- const theme = await loadTheme ( monaco . editor )
46
+ const theme = await import ( ' ./highlight ' ). then ( r => r . registerHighlighter () )
48
47
ready .value = true
49
48
await nextTick ()
50
49
@@ -68,7 +67,6 @@ onMounted(async () => {
68
67
inlineSuggest: {
69
68
enabled: false ,
70
69
},
71
- ' semanticHighlighting.enabled' : true ,
72
70
fixedOverflowWidgets: true ,
73
71
})
74
72
editor .value = editorInstance
@@ -137,8 +135,6 @@ onMounted(async () => {
137
135
)
138
136
}
139
137
140
- await loadGrammars (monaco , editorInstance )
141
-
142
138
editorInstance .addCommand (monaco .KeyMod .CtrlCmd | monaco .KeyCode .KeyS , () => {
143
139
// ignore save event
144
140
})
Original file line number Diff line number Diff line change @@ -2,8 +2,6 @@ import { jsDelivrUriBase } from '@volar/cdn'
2
2
import * as volar from '@volar/monaco'
3
3
import { editor , languages , Uri } from 'monaco-editor-core'
4
4
import 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'
7
5
import { watchEffect } from 'vue'
8
6
import { Store } from '../store'
9
7
import { getOrCreateModel } from './utils'
@@ -14,7 +12,6 @@ let initted = false
14
12
export function initMonaco ( store : Store ) {
15
13
if ( initted ) return
16
14
loadMonacoEnv ( store )
17
- loadWasm ( )
18
15
19
16
watchEffect ( ( ) => {
20
17
// create a model for each file in the store
@@ -62,10 +59,6 @@ export function initMonaco(store: Store) {
62
59
initted = true
63
60
}
64
61
65
- export function loadWasm ( ) {
66
- return onigasm . loadWASM ( onigasmWasm )
67
- }
68
-
69
62
export class WorkerHost {
70
63
onFetchCdnFile ( uri : string , text : string ) {
71
64
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