@@ -5,6 +5,12 @@ import { useEffect, useRef, useState } from "react";
5
5
import { shikiToMonaco } from "@shikijs/monaco" ;
6
6
import { createHighlighter } from "shiki" ;
7
7
8
+ const ReactSource = require . context (
9
+ "!!raw-loader!../../../node_modules/@types/react" ,
10
+ true ,
11
+ / ^ \. \/ ( .* \. d \. t s | p a c k a g e .j s o n ) $ / ,
12
+ ) ;
13
+
8
14
const CCCSource = require . context (
9
15
"!!raw-loader!../../../../" ,
10
16
true ,
@@ -78,7 +84,7 @@ export function Editor({
78
84
< div className = "relative h-full w-full" >
79
85
< MonacoEditor
80
86
className = "h-[60vh] w-full lg:h-auto"
81
- defaultLanguage = "tsx "
87
+ defaultLanguage = "typescript "
82
88
defaultPath = "/index.tsx"
83
89
options = { {
84
90
padding : { top : 20 } ,
@@ -105,6 +111,13 @@ export function Editor({
105
111
] ,
106
112
} ) ;
107
113
114
+ ReactSource . keys ( ) . forEach ( ( key : string ) => {
115
+ monaco . languages . typescript . typescriptDefaults . addExtraLib (
116
+ ReactSource ( key ) . default ,
117
+ "file:///node_modules/@types/react/" + key . replace ( "./" , "" ) ,
118
+ ) ;
119
+ } ) ;
120
+
108
121
CCCSource . keys ( ) . forEach ( ( key : string ) => {
109
122
monaco . languages . typescript . typescriptDefaults . addExtraLib (
110
123
CCCSource ( key ) . default ,
@@ -116,10 +129,10 @@ export function Editor({
116
129
"file:///node_modules/@ckb-ccc/playground/index.d.ts" ,
117
130
) ;
118
131
119
- monaco . languages . register ( { id : "tsx " } ) ;
132
+ monaco . languages . register ( { id : "typescript " } ) ;
120
133
createHighlighter ( {
121
134
themes : [ "github-dark" ] ,
122
- langs : [ "tsx " ] ,
135
+ langs : [ "typescript " ] ,
123
136
} ) . then ( ( highlighter ) => {
124
137
shikiToMonaco ( highlighter , monaco ) ;
125
138
} ) ;
0 commit comments