From a3b943f74430f962527578b63aa92e6fbf1c39b3 Mon Sep 17 00:00:00 2001 From: caishi Date: Mon, 1 Nov 2021 17:08:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E4=B8=8A-=E4=BB=A3=E7=A0=81=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E5=99=A8=E9=80=89=E4=B8=AD=E9=AB=98=E4=BA=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/forge/Newfile/m_editor.js | 56 ++--------------------------------- 1 file changed, 3 insertions(+), 53 deletions(-) diff --git a/src/forge/Newfile/m_editor.js b/src/forge/Newfile/m_editor.js index 8e90d51f2..d4446e3f2 100644 --- a/src/forge/Newfile/m_editor.js +++ b/src/forge/Newfile/m_editor.js @@ -1,5 +1,4 @@ import React, { Component } from "react"; -import Editor from "react-monaco-editor"; import {UnControlled as CodeMirror} from 'react-codemirror2'; import 'codemirror/addon/selection/active-line.js'; import 'codemirror/mode/javascript/javascript.js'; @@ -35,10 +34,10 @@ class m_editor extends Component { render() { const { editorValue , changeValue } = this.state; - const { readOnly, editorType, language , currentBranch , descName } = this.props; + const { readOnly, editorType, currentBranch , descName } = this.props; const editor_options = { lineNumbers: "on", - wordWrap: true, //强制换行 + lineWrapping: true, //强制换行 selectOnLineNumbers: true, lineHeight: 24, renderLineHighlight: "line", @@ -51,64 +50,15 @@ class m_editor extends Component { automaticLayout: true, // 自适应布局 overviewRulerBorder: false, // 不要滚动条的边框 scrollBeyondLastLine: false, // 取消代码后面一大段空白 + styleActiveLine:true,//光标代码高亮 minimap: { // 不要小地图 enabled: false, }, }; - - const handleEditorMount = (editor, monaco) => { - editor.onDidChangeModelDecorations(() => { - requestAnimationFrame(updateEditorHeight); // folding - }); - - const updateEditorHeight = () => { - const editorElement = editor.getDomNode(); - - if (!editorElement) { - return; - } - - const padding = 40; - - const lineHeight = editor.getOption( - monaco.editor.EditorOption.lineHeight - ); - - const lineCount = editor.getModel().getLineCount() || 1; - let height = - editor.getTopForLineNumber(lineCount + 1) + - lineHeight + - padding ; - - if(height<400){height = 400;} - - if (this.state.prevHeight !== height) { - this.setState({ - prevHeight:height - }) - // setPrevHeight(height); - editorElement.style.height = `${height}px`; - editor.layout(); - } - }; - - updateEditorHeight(); // typing - }; - return (
- {/* */}