merge 编辑器滚动问题‘

This commit is contained in:
caishi 2021-11-01 14:11:39 +08:00 committed by caishi
parent 131d8fa81c
commit 8b4fc88b1d
2 changed files with 31 additions and 20 deletions

View File

@ -1,3 +1,11 @@
.editorBorderBox .CodeMirror
{
height: unset;
}
.editorBorderBox .CodeMirror .CodeMirror-scroll{
min-height: 300px;
}
.setInputAddon{
width: 350px;
margin-right: 20px;
@ -9,12 +17,16 @@
border-right: none!important;
}
.editorBorder .editorBorderBox{
border:1px solid #eee;
border:1px solid #d0d0d0;
border-radius: 2px;
border-bottom: none;
}
.editorBorder .editorBorderSubmitBox{
padding:20px 0px!important;
}
.editorBorderSubmitBox{
border-top: 1px solid #d0d0d0;
}
.userScrew{
margin:20px 0px;
border:1px solid #f4f4f4;

View File

@ -1,6 +1,10 @@
import React, { Component } from "react";
import Editor from "react-monaco-editor";
// import {UnControlled as CodeMirror} from 'react-codemirror2'
import {UnControlled as CodeMirror} from 'react-codemirror2';
import 'codemirror/addon/selection/active-line.js';
import 'codemirror/mode/javascript/javascript.js';
import 'codemirror/mode/clike/clike';
import 'codemirror/mode/css/css';
import UserSubmitComponent from "./UserSubmitComponent";
@ -12,6 +16,7 @@ class m_editor extends Component {
super(props);
this.state = {
editorValue: this.props.content,
changeValue:this.props.content,
prevHeight:0
};
}
@ -22,14 +27,14 @@ class m_editor extends Component {
})
}
}
changeEditor = (editorValue) => {
changeEditor = (editorValue,data) => {
this.setState({
editorValue,
changeValue:editorValue.getValue(),
});
};
render() {
const { editorValue } = this.state;
const { editorValue , changeValue } = this.state;
const { readOnly, editorType, language , currentBranch , descName } = this.props;
const editor_options = {
lineNumbers: "on",
@ -91,11 +96,10 @@ class m_editor extends Component {
updateEditorHeight(); // typing
};
return (
<React.Fragment>
<div className="editorBorderBox">
<Editor
{/* <Editor
language={language ? language : "plaintext"}
theme={"vs-grey"}
placeholder="请输入内容"
@ -104,26 +108,21 @@ class m_editor extends Component {
onChange={this.changeEditor}
editorWillMount={this.editorWillMount}
editorDidMount={handleEditorMount}
/>
{/* <CodeMirror
value={editorValue}
options={{
theme: 'monokai',
mode: 'JavaScript',
extraKeys: {"Ctrl": "autocomplete"},//ctrl可以弹出提示
styleActiveLine: true,
lineNumbers: true,
readOnly:true
}}
/> */}
<CodeMirror
placeholder="请输入内容"
value={editorValue}
options={editor_options}
onChange={this.changeEditor}
/>
</div>
{!readOnly && (
<div className="editorBorderSubmitBox" style={{marginTop:"20px",padding:"20px"}}>
<div className="editorBorderSubmitBox" style={{padding:"20px"}}>
<UserSubmitComponent
{...this.props}
{...this.state}
filepath={`${this.props.filepath}`}
content={editorValue}
content={changeValue}
editor_type={editorType}
currentBranch={currentBranch}
descName={descName}