MCPcopy Create free account
hub / github.com/GCWing/BitFun / initEditor

Function initEditor

src/web-ui/src/tools/editor/core/MonacoEditorCore.tsx:184–254  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

182 });
183
184 const initEditor = async () => {
185 try {
186 await monacoInitManager.initialize();
187
188 if (isUnmountedRef.current) return;
189
190 themeManager.initialize();
191
192 const model = monacoModelManager.getOrCreateModel(
193 currentFilePath,
194 languageRef.current,
195 initialContentRef.current,
196 workspacePathRef.current
197 );
198 modelRef.current = model;
199
200 const overrides: EditorOptionsOverrides = {
201 readOnly: readOnlyRef.current,
202 lineNumbers: showLineNumbersRef.current,
203 minimap: showMinimapRef.current,
204 theme: themeRef.current,
205 };
206
207 const editorOptions = buildEditorOptions({
208 config: configRef.current,
209 preset: presetRef.current,
210 overrides,
211 });
212
213 const editor = monaco.editor.create(container, {
214 ...editorOptions,
215 model,
216 });
217 editorRef.current = editor;
218 const editTarget = createMonacoEditTarget(editor);
219 const unbindEditTarget = activeEditTargetService.bindTarget(editTarget);
220 const focusDisposable = editor.onDidFocusEditorText(() => {
221 activeEditTargetService.setActiveTarget(editTarget.id);
222 });
223 const blurDisposable = editor.onDidBlurEditorText(() => {
224 window.setTimeout(() => {
225 if (editor.hasTextFocus()) {
226 return;
227 }
228
229 activeEditTargetService.clearActiveTarget(editTarget.id);
230 }, 0);
231 });
232 macosEditorBindingCleanupRef.current = () => {
233 focusDisposable.dispose();
234 blurDisposable.dispose();
235 unbindEditTarget();
236 };
237
238 registerEventListeners(editor, model);
239
240 editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyS, () => {
241 const content = model.getValue();

Callers 1

Calls 13

buildEditorOptionsFunction · 0.90
createMonacoEditTargetFunction · 0.90
getOrCreateModelMethod · 0.80
bindTargetMethod · 0.80
setActiveTargetMethod · 0.80
clearActiveTargetMethod · 0.80
getValueMethod · 0.80
notifyEditorCreatedMethod · 0.80
disposeMethod · 0.65
initializeMethod · 0.45
createMethod · 0.45
currentMethod · 0.45

Tested by

no test coverage detected