浏览代码

website: monaco loading improvements

Henning Dieterichs 1 年之前
父节点
当前提交
5181be1011
共有 2 个文件被更改,包括 8 次插入0 次删除
  1. 4 0
      website/src/monaco-loader.ts
  2. 4 0
      website/src/website/components/monaco/MonacoEditor.tsx

+ 4 - 0
website/src/monaco-loader.ts

@@ -62,6 +62,10 @@ async function _loadMonaco(setup: IMonacoSetup): Promise<typeof monaco> {
 	return new Promise((res) => {
 		// First load editor.main. If it inlines the plugins, we don't want to try to load them from the server.
 		req(["vs/editor/editor.main"], () => {
+			if ((setup as any).onlyCore) {
+				res(monaco);
+				return;
+			}
 			req(
 				[
 					"vs/basic-languages/monaco.contribution",

+ 4 - 0
website/src/website/components/monaco/MonacoEditor.tsx

@@ -17,6 +17,10 @@ export class ControlledMonacoEditor extends React.Component<{
 
 	private lastSubscription: monaco.IDisposable | undefined;
 
+	componentDidMount(): void {
+		this.componentDidUpdate({ value: "" });
+	}
+
 	componentDidUpdate(lastProps: this["props"]) {
 		const newOnDidValueChange = this.props.onDidValueChange;
 		if (newOnDidValueChange !== lastProps.onDidValueChange) {