forked from Gitlink/forgeplus-react
Merge pull request '代码库二级页面issue滚动条更改' (#106) from hc1913847458/forgeplus-react:feature_repo_second_page into feature_repo_second_page
This commit is contained in:
commit
4c0f059ae5
|
@ -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 (
|
||||
<div>
|
||||
<div className="">
|
||||
<Editor
|
||||
height="400px"
|
||||
language={language ? language : "plaintext"}
|
||||
theme={"vs-grey"}
|
||||
placeholder="请输入内容"
|
||||
value={editorValue}
|
||||
options={editor_options}
|
||||
onChange={this.changeEditor}
|
||||
editorWillMount={this.editorWillMount}
|
||||
editorDidMount={handleEditorMount}
|
||||
/>
|
||||
</div>
|
||||
{!readOnly && (
|
||||
<div style={{marginTop:"20px",padding:"20px"}}>
|
||||
<UserSubmitComponent
|
||||
{...this.props}
|
||||
{...this.state}
|
||||
filepath={`${this.props.filepath}`}
|
||||
content={editorValue}
|
||||
editor_type={editorType}
|
||||
currentBranch={currentBranch}
|
||||
descName={descName}
|
||||
></UserSubmitComponent>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
|
||||
<React.Fragment>
|
||||
<div>
|
||||
<div className="">
|
||||
<Editor
|
||||
// height={this.state.x}
|
||||
language={language ? language : "plaintext"}
|
||||
theme={"vs-grey"}
|
||||
placeholder="请输入内容"
|
||||
value={editorValue}
|
||||
options={editor_options}
|
||||
onChange={this.changeEditor}
|
||||
editorWillMount={this.editorWillMount}
|
||||
editorDidMount={handleEditorMount}
|
||||
/>
|
||||
</div>
|
||||
{!readOnly && (
|
||||
<div style={{marginTop:"20px",padding:"20px"}}>
|
||||
<UserSubmitComponent
|
||||
{...this.props}
|
||||
{...this.state}
|
||||
filepath={`${this.props.filepath}`}
|
||||
content={editorValue}
|
||||
editor_type={editorType}
|
||||
currentBranch={currentBranch}
|
||||
descName={descName}
|
||||
></UserSubmitComponent>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue