({
onToggle,
appliedOptions,
}: {
onToggle: () => void;
appliedOptions: PluginOptions | null;
})
| 70 | } |
| 71 | |
| 72 | function ExpandedEditor({ |
| 73 | onToggle, |
| 74 | appliedOptions, |
| 75 | }: { |
| 76 | onToggle: () => void; |
| 77 | appliedOptions: PluginOptions | null; |
| 78 | }): React.ReactElement { |
| 79 | const store = useStore(); |
| 80 | const dispatchStore = useStoreDispatch(); |
| 81 | const debounceTimerRef = useRef<NodeJS.Timeout | null>(null); |
| 82 | |
| 83 | const handleChange: (value: string | undefined) => void = ( |
| 84 | value: string | undefined, |
| 85 | ) => { |
| 86 | if (value === undefined) return; |
| 87 | |
| 88 | if (debounceTimerRef.current) { |
| 89 | clearTimeout(debounceTimerRef.current); |
| 90 | } |
| 91 | |
| 92 | debounceTimerRef.current = setTimeout(() => { |
| 93 | dispatchStore({ |
| 94 | type: 'updateConfig', |
| 95 | payload: { |
| 96 | config: value, |
| 97 | }, |
| 98 | }); |
| 99 | }, 500); // 500ms debounce delay |
| 100 | }; |
| 101 | |
| 102 | const handleMount: ( |
| 103 | _: editor.IStandaloneCodeEditor, |
| 104 | monaco: Monaco, |
| 105 | ) => void = (_, monaco) => { |
| 106 | // Add the babel-plugin-react-compiler type definitions to Monaco |
| 107 | monaco.languages.typescript.typescriptDefaults.addExtraLib( |
| 108 | //@ts-expect-error - compilerTypeDefs is a string |
| 109 | compilerTypeDefs, |
| 110 | 'file:///node_modules/babel-plugin-react-compiler/dist/index.d.ts', |
| 111 | ); |
| 112 | monaco.languages.typescript.typescriptDefaults.setCompilerOptions({ |
| 113 | target: monaco.languages.typescript.ScriptTarget.Latest, |
| 114 | allowNonTsExtensions: true, |
| 115 | moduleResolution: monaco.languages.typescript.ModuleResolutionKind.NodeJs, |
| 116 | module: monaco.languages.typescript.ModuleKind.ESNext, |
| 117 | noEmit: true, |
| 118 | strict: false, |
| 119 | esModuleInterop: true, |
| 120 | allowSyntheticDefaultImports: true, |
| 121 | jsx: monaco.languages.typescript.JsxEmit.React, |
| 122 | }); |
| 123 | }; |
| 124 | |
| 125 | const formattedAppliedOptions = appliedOptions |
| 126 | ? prettyFormat(appliedOptions, { |
| 127 | printFunctionName: false, |
| 128 | printBasicPrototype: false, |
| 129 | }) |
nothing calls this directly
no test coverage detected