MCPcopy Create free account
hub / github.com/UNLINEARITY/Obsidian-CodeSpace / initEditor

Method initEditor

src/code_view.ts:1073–1097  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1071 // Use requestAnimationFrame to ensure DOM is ready, especially after "Move to New Window"
1072 // which may recreate the view before the container structure is fully ready.
1073 const initEditor = () => {
1074 // 从设置中初始化字体大小
1075 const plugin = this.getPlugin();
1076 if (plugin && plugin.settings) {
1077 this.fontSize = plugin.settings.editorFontSize || 16;
1078 }
1079
1080 const container = this.containerEl.children[1];
1081 if (!container) {
1082 console.warn("Code Space: Container not ready, retrying...");
1083 // Retry after a short delay if container is not ready yet
1084 window.requestAnimationFrame(initEditor);
1085 return;
1086 }
1087 container.empty();
1088
1089 const root = container.createDiv({ cls: "code-space-container" });
1090 this.rootEl = root;
1091
1092 // Debug: Log file extension and language extension
1093 const ext = this.file?.extension.toLowerCase();
1094 console.debug("Code Space: Opening file", this.file?.name, "with extension:", ext);
1095
1096 this.initCodeMirror(root);
1097 };
1098
1099 window.requestAnimationFrame(initEditor);
1100 }

Callers

nothing calls this directly

Calls 2

getPluginMethod · 0.95
initCodeMirrorMethod · 0.95

Tested by

no test coverage detected