update monaco-editor

dev_aliyun2
harry 5 years ago
parent afadd23dfd
commit 29d4501aab

@ -1,12 +1,10 @@
import React, { Component } from "react"; import React, { Component } from "react";
import { Input,Checkbox,Table, Pagination, Modal,Menu, Tooltip,Spin,Button,Form,Icon,message,Progress,notification} from "antd"; import { Modal, Spin, Button, Form, Icon, message, Progress, notification } from "antd";
import { WordsBtn,on, off, trigger,markdownToHTML,getImageUrl} from 'educoder';
import './myelearning.css' import './myelearning.css'
import axios from 'axios'; import axios from 'axios';
import YslDetailCards from "./YslDetailCards.js"; import YslDetailCards from "./YslDetailCards.js";
import Jointheclass from '../../modals/Jointheclass'; import Jointheclass from '../../modals/Jointheclass';
import LoginDialog from "../../login/LoginDialog"; import LoginDialog from "../../login/LoginDialog";
import NoneData from '../../../modules/courses/coursesPublic/NoneData'
//在线学习 //在线学习
class Elearning extends Component { class Elearning extends Component {
@ -229,7 +227,8 @@ class Elearning extends Component{
// message.success('重置成功,正在进入实训!'); // message.success('重置成功,正在进入实训!');
// this.startshixunCombat(); // this.startshixunCombat();
}} }
}
).catch((error) => { ).catch((error) => {
this.setState({ this.setState({
isSpins: false, isSpins: false,

@ -478,17 +478,16 @@ class LoginDialog extends Component {
} }
render() { render() {
let { qqlogin, login, isGoing, isGoingValue, disabled, bottonclass, Phonenumberisnotco, let { login, isGoing, isGoingValue, disabled, Phonenumberisnotco,
dialogBox, isRender, weixinlogin } = this.state; dialogBox, isRender, weixinlogin } = this.state;
if (isRender === undefined) { if (isRender === undefined) {
isRender = false isRender = false
} }
return ( return (
<Modal visible={isRender} id="DialogID" <Modal visible={isRender} id="DialogID"
className="zindextest" className="zindextest"
onClose={() => this.handleDialogClose()} onCancel={() => this.handleDialogClose()}
footer={null}
> >
<Notcompletedysl <Notcompletedysl
modalsType={this.state.MyEduCoderModals} modalsType={this.state.MyEduCoderModals}

@ -163,7 +163,7 @@ class MainContent extends Component {
<div style={{ display: (codeLoading ? 'block' : 'none'), textAlign: 'center' }}> <div style={{ display: (codeLoading ? 'block' : 'none'), textAlign: 'center' }}>
<span style={{ color: '#ddd', display: 'block' }}>正在加载中请稍后...</span> <span style={{ color: '#ddd', display: 'block' }}>正在加载中请稍后...</span>
</div> </div>
<div style={{ display: (codeLoading ? 'none' : 'block') }}> <div style={{ display: (codeLoading ? 'none' : 'block'), height: '100%' }}>
<CodeRepositoryViewContainer {...this.props} ></CodeRepositoryViewContainer> <CodeRepositoryViewContainer {...this.props} ></CodeRepositoryViewContainer>
</div> </div>
</React.Fragment> </React.Fragment>

@ -68,7 +68,7 @@ class TPIMonaco extends Component {
render() { render() {
const { repositoryCode, showSettingDrawer, shixun, isEditablePath, settingDrawerOpen, mirror_name } = this.props; const { repositoryCode, showSettingDrawer, shixun, isEditablePath, settingDrawerOpen, mirror_name, onRepositoryCodeUpdate } = this.props;
const { cmFontSize, cmCodeMode } = this.state const { cmFontSize, cmCodeMode } = this.state
const editorOptions = { const editorOptions = {
value: repositoryCode, value: repositoryCode,

@ -78,6 +78,23 @@ export default ({
const editor = useRef({}) const editor = useRef({})
const [init, setInit] = useState(false) const [init, setInit] = useState(false)
function onLayout() {
if (window.ResizeObserver) {
const ro = new window.ResizeObserver(entries => {
for (let entry of entries) {
if (entry.target.offsetHeight > 0) {
editor.current.instance.layout()
}
}
})
ro.observe(editorEl.current.parentElement)
} else {
setTimeout(() => {
editor.current.instance.layout()
}, 100);
}
}
useEffect(() => { useEffect(() => {
editor.current.instance = monaco.editor.create( editor.current.instance = monaco.editor.create(
editorEl.current, { editorEl.current, {
@ -98,6 +115,7 @@ export default ({
const resizeHandler = debounce(() => { editor.current.instance.layout() }, 100) const resizeHandler = debounce(() => { editor.current.instance.layout() }, 100)
window.addEventListener('resize', resizeHandler) window.addEventListener('resize', resizeHandler)
onLayout()
return () => { return () => {
const el = editor.current.instance const el = editor.current.instance
el.dispose() el.dispose()

@ -479,7 +479,7 @@ class CodeRepositoryView extends Component {
</ul> </ul>
<div className="cl"></div> <div className="cl"></div>
<div id="codetab_con_1" style={{ display: 'block', flex: 'auto' }} style={tabIndex === 0 ? { display: 'block' } : { display: 'none' }}> <div id="codetab_con_1" style={{ display: tabIndex === 0 ? 'block' : 'none', flex: 'auto', height: '100%' }} >
{this.props.readRepoTimeout === true ? <div className="readRepoFailed"> {this.props.readRepoTimeout === true ? <div className="readRepoFailed">
代码加载失败<a className="retry" 代码加载失败<a className="retry"
onClick={() => this.props.fetchRepositoryCode(this.props, null, null, true, true)}>重试</a> onClick={() => this.props.fetchRepositoryCode(this.props, null, null, true, true)}>重试</a>

Loading…
Cancel
Save