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

Function initEditor

src/web-ui/src/tools/editor/core/MonacoDiffCore.tsx:188–245  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

186 const container = containerRef.current;
187
188 const initEditor = async () => {
189 try {
190 await monacoInitManager.initialize();
191
192 if (isUnmountedRef.current) return;
193
194 themeManager.initialize();
195
196 const originalModel = monaco.editor.createModel(
197 originalContentRef.current,
198 languageRef.current,
199 generateUri('original')
200 );
201 const modifiedModel = monaco.editor.createModel(
202 modifiedContentRef.current,
203 languageRef.current,
204 generateUri('modified')
205 );
206 originalModelRef.current = originalModel;
207 modifiedModelRef.current = modifiedModel;
208
209 const overrides: EditorOptionsOverrides = {
210 readOnly: readOnlyRef.current,
211 minimap: showMinimapRef.current,
212 theme: themeRef.current,
213 };
214
215 const diffOptions = buildDiffEditorOptions({
216 config: configRef.current,
217 preset: presetRef.current,
218 overrides,
219 });
220
221 const diffEditor = monaco.editor.createDiffEditor(container, {
222 ...diffOptions,
223 renderSideBySide: renderSideBySideRef.current,
224 renderOverviewRuler: renderOverviewRulerRef.current,
225 renderIndicators: renderIndicatorsRef.current,
226 originalEditable: originalEditableRef.current,
227 ignoreTrimWhitespace: ignoreTrimWhitespaceRef.current,
228 });
229 diffEditorRef.current = diffEditor;
230
231 diffEditor.setModel({
232 original: originalModel,
233 modified: modifiedModel,
234 });
235
236 registerEventListeners(diffEditor, modifiedModel);
237
238 setIsReady(true);
239
240 onEditorReadyRef.current?.(diffEditor, originalModel, modifiedModel);
241
242 } catch (error) {
243 log.error('Failed to initialize diff editor', error);
244 }
245 };

Callers 1

MonacoDiffCore.tsxFile · 0.70

Calls 4

buildDiffEditorOptionsFunction · 0.90
initializeMethod · 0.45
currentMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected