11import { Disclosure , Menu , Transition } from '@headlessui/react' ;
22import { BellIcon , MenuIcon , XIcon } from '@heroicons/react/outline' ;
3+ import Editor from '@monaco-editor/react' ;
34import { Fragment } from 'react' ;
45
56const navigation = [ 'Dashboard' , 'Team' , 'Projects' , 'Calendar' , 'Reports' ] ;
@@ -10,6 +11,9 @@ function classNames(...classes: any[]) {
1011}
1112
1213export default function Example ( ) {
14+ // function showValue() {
15+ // alert(editorRef.current.getValue());
16+ // }
1317 return (
1418 < div >
1519 < Disclosure as = "nav" className = "bg-gray-800" >
@@ -194,7 +198,19 @@ export default function Example() {
194198 < div className = "max-w-7xl mx-auto py-6 sm:px-6 lg:px-8" >
195199 { /* Replace with your content */ }
196200 < div className = "px-4 py-6 sm:px-0" >
197- < div className = "border-4 border-dashed border-gray-200 rounded-lg h-96" />
201+ < div className = "border-4 border-dashed border-gray-200 rounded-lg h-96" >
202+ { /* <button onClick={showValue}>Show value</button> */ }
203+ < Editor
204+ height = "90vh"
205+ defaultLanguage = "python"
206+ defaultValue = { `def _clip_grad(clr, grad, group_grad_clip):
207+ if group_grad_clip > 0:
208+ norm = grad.norm(2).item()
209+ if norm > group_grad_clip:
210+ clr *= group_grad_clip / (norm + 1e-10)
211+ return clr` }
212+ />
213+ </ div >
198214 </ div >
199215 { /* /End replace */ }
200216 </ div >
0 commit comments