代码库二级issue滚动条
This commit is contained in:
parent
6d1b410ba1
commit
7a06e21933
|
@ -52,68 +52,74 @@ class m_editor extends Component {
|
||||||
|
|
||||||
const handleEditorMount = (editor, monaco) => {
|
const handleEditorMount = (editor, monaco) => {
|
||||||
editor.onDidChangeModelDecorations(() => {
|
editor.onDidChangeModelDecorations(() => {
|
||||||
updateEditorHeight(); // typing
|
updateEditorHeight(); // typing
|
||||||
requestAnimationFrame(updateEditorHeight); //folding
|
requestAnimationFrame(updateEditorHeight); // folding
|
||||||
});
|
});
|
||||||
|
|
||||||
const updateEditorHeight = () => {
|
const updateEditorHeight = () => {
|
||||||
const editorElement = editor.getDomNode();
|
const editorElement = editor.getDomNode();
|
||||||
|
|
||||||
if (!editorElement) {
|
if (!editorElement) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const padding = 40;
|
const padding = 40;
|
||||||
|
|
||||||
const lineHeight = editor.getOption(
|
const lineHeight = editor.getOption(
|
||||||
monaco.editor.EditorOption.lineHeight
|
monaco.editor.EditorOption.lineHeight
|
||||||
);
|
);
|
||||||
const lineCount = editor.getModel().getLineCount() || 1;
|
|
||||||
const height =
|
const lineCount = editor.getModel().getLineCount() || 1;
|
||||||
editor.getTopForLineNumber(lineCount + 1) +
|
const height =
|
||||||
lineHeight +
|
editor.getTopForLineNumber(lineCount + 1) +
|
||||||
padding;
|
lineHeight +
|
||||||
|
padding;
|
||||||
if (this.state.prevHeight !== height) {
|
|
||||||
this.setState({
|
if (this.state.prevHeight !== height) {
|
||||||
prevHeight:height
|
this.setState({
|
||||||
})
|
prevHeight:height
|
||||||
|
})
|
||||||
// setPrevHeight(height);
|
// setPrevHeight(height);
|
||||||
editorElement.style.height = `${height}px`;
|
editorElement.style.height = `${height}px`;
|
||||||
editor.layout();
|
editor.layout();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
|
||||||
<div className="">
|
|
||||||
<Editor
|
<React.Fragment>
|
||||||
height="400px"
|
<div>
|
||||||
language={language ? language : "plaintext"}
|
<div className="">
|
||||||
theme={"vs-grey"}
|
<Editor
|
||||||
placeholder="请输入内容"
|
// height={this.state.x}
|
||||||
value={editorValue}
|
language={language ? language : "plaintext"}
|
||||||
options={editor_options}
|
theme={"vs-grey"}
|
||||||
onChange={this.changeEditor}
|
placeholder="请输入内容"
|
||||||
editorWillMount={this.editorWillMount}
|
value={editorValue}
|
||||||
editorDidMount={handleEditorMount}
|
options={editor_options}
|
||||||
/>
|
onChange={this.changeEditor}
|
||||||
</div>
|
editorWillMount={this.editorWillMount}
|
||||||
{!readOnly && (
|
editorDidMount={handleEditorMount}
|
||||||
<div style={{marginTop:"20px",padding:"20px"}}>
|
/>
|
||||||
<UserSubmitComponent
|
</div>
|
||||||
{...this.props}
|
{!readOnly && (
|
||||||
{...this.state}
|
<div style={{marginTop:"20px",padding:"20px"}}>
|
||||||
filepath={`${this.props.filepath}`}
|
<UserSubmitComponent
|
||||||
content={editorValue}
|
{...this.props}
|
||||||
editor_type={editorType}
|
{...this.state}
|
||||||
currentBranch={currentBranch}
|
filepath={`${this.props.filepath}`}
|
||||||
descName={descName}
|
content={editorValue}
|
||||||
></UserSubmitComponent>
|
editor_type={editorType}
|
||||||
</div>
|
currentBranch={currentBranch}
|
||||||
)}
|
descName={descName}
|
||||||
</div>
|
></UserSubmitComponent>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue