From 7a06e219339d881361059a285dff3995e19ee5f7 Mon Sep 17 00:00:00 2001 From: hucong <1422588487@qq.com> Date: Thu, 30 Sep 2021 19:47:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=BA=93=E4=BA=8C=E7=BA=A7is?= =?UTF-8?q?sue=E6=BB=9A=E5=8A=A8=E6=9D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/forge/Newfile/m_editor.js | 106 ++++++++++++++++++---------------- 1 file changed, 56 insertions(+), 50 deletions(-) diff --git a/src/forge/Newfile/m_editor.js b/src/forge/Newfile/m_editor.js index 3b8a9205..de4b8289 100644 --- a/src/forge/Newfile/m_editor.js +++ b/src/forge/Newfile/m_editor.js @@ -52,68 +52,74 @@ class m_editor extends Component { const handleEditorMount = (editor, monaco) => { editor.onDidChangeModelDecorations(() => { - updateEditorHeight(); // typing - requestAnimationFrame(updateEditorHeight); //folding + updateEditorHeight(); // typing + requestAnimationFrame(updateEditorHeight); // folding }); const updateEditorHeight = () => { - const editorElement = editor.getDomNode(); + const editorElement = editor.getDomNode(); - if (!editorElement) { - return; - } + if (!editorElement) { + return; + } - const padding = 40; + const padding = 40; - const lineHeight = editor.getOption( - monaco.editor.EditorOption.lineHeight - ); - const lineCount = editor.getModel().getLineCount() || 1; - const height = - editor.getTopForLineNumber(lineCount + 1) + - lineHeight + - padding; - - if (this.state.prevHeight !== height) { - this.setState({ - prevHeight:height - }) + const lineHeight = editor.getOption( + monaco.editor.EditorOption.lineHeight + ); + + const lineCount = editor.getModel().getLineCount() || 1; + const height = + editor.getTopForLineNumber(lineCount + 1) + + lineHeight + + padding; + + if (this.state.prevHeight !== height) { + this.setState({ + prevHeight:height + }) // setPrevHeight(height); editorElement.style.height = `${height}px`; editor.layout(); - } + } }; - }; + }; + return ( -