|
|
|
@ -4,14 +4,19 @@
|
|
|
|
|
* @Github:
|
|
|
|
|
* @Date: 2019-11-27 14:59:51
|
|
|
|
|
* @LastEditors : tangjiang
|
|
|
|
|
* @LastEditTime: 2019-12-20 14:01:57
|
|
|
|
|
* @LastEditTime : 2019-12-26 17:56:51
|
|
|
|
|
*/
|
|
|
|
|
import React, { useState, useEffect } from 'react';
|
|
|
|
|
import {connect} from 'react-redux';
|
|
|
|
|
import MyMonacoEditor from '../../components/myMonacoEditor';
|
|
|
|
|
import ControlSetting from '../../components/controlSetting';
|
|
|
|
|
import actions from '../../../../redux/actions';
|
|
|
|
|
|
|
|
|
|
// import QuillForEditor from '../../../../common/quillForEditor';
|
|
|
|
|
// import TextArea from 'antd/lib/input/TextArea';
|
|
|
|
|
import { Input, Form, Button } from 'antd';
|
|
|
|
|
// import FormItem from 'antd/lib/form/FormItem';
|
|
|
|
|
const { TextArea } = Input;
|
|
|
|
|
const FormItem = Form.Item;
|
|
|
|
|
const RightPane = (props) => {
|
|
|
|
|
|
|
|
|
|
const {
|
|
|
|
@ -20,6 +25,7 @@ const RightPane = (props) => {
|
|
|
|
|
submitUserCode,
|
|
|
|
|
input,
|
|
|
|
|
hack,
|
|
|
|
|
loading,
|
|
|
|
|
notice,
|
|
|
|
|
updateCode,
|
|
|
|
|
hadCodeUpdate,
|
|
|
|
@ -27,12 +33,15 @@ const RightPane = (props) => {
|
|
|
|
|
updateNotice,
|
|
|
|
|
saveUserInputCode,
|
|
|
|
|
restoreInitialCode,
|
|
|
|
|
saveOpacityType,
|
|
|
|
|
saveUserCodeForInterval
|
|
|
|
|
// saveOpacityType,
|
|
|
|
|
saveUserCodeForInterval,
|
|
|
|
|
addNotes,
|
|
|
|
|
changeLoadingState
|
|
|
|
|
} = props;
|
|
|
|
|
|
|
|
|
|
const [editorCode, setEditorCode] = useState('');
|
|
|
|
|
|
|
|
|
|
const [noteClazz, setNoteClazz] = useState('editor_nodte_area');
|
|
|
|
|
const [noteCount] = useState(5000);
|
|
|
|
|
let initFlag = true;
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (editor_code) {
|
|
|
|
@ -86,6 +95,28 @@ const RightPane = (props) => {
|
|
|
|
|
updateNotice && updateNotice();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleClickNote = () => {
|
|
|
|
|
setNoteClazz('editor_nodte_area active');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleCancelNote = () => {
|
|
|
|
|
props.form.resetFields();
|
|
|
|
|
setNoteClazz('editor_nodte_area');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleSubmitNote = () => {
|
|
|
|
|
props.form.validateFields((err, values) => {
|
|
|
|
|
if (!err) {
|
|
|
|
|
changeLoadingState(true);
|
|
|
|
|
addNotes(identifier, values, function () {
|
|
|
|
|
setNoteClazz('editor_nodte_area');
|
|
|
|
|
props.form.resetFields();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const { getFieldDecorator } = props.form;
|
|
|
|
|
return (
|
|
|
|
|
<div className={'right_pane_code_wrap'}>
|
|
|
|
|
<MyMonacoEditor
|
|
|
|
@ -98,6 +129,40 @@ const RightPane = (props) => {
|
|
|
|
|
onUpdateNotice={handleUpdateNotice}
|
|
|
|
|
onRestoreInitialCode={handleRestoreInitialCode}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<span
|
|
|
|
|
className="iconfont icon-biji student_notes"
|
|
|
|
|
onClick={handleClickNote}
|
|
|
|
|
></span>
|
|
|
|
|
|
|
|
|
|
{/* <div className="student_notes">
|
|
|
|
|
<TextArea rows={5} />
|
|
|
|
|
</div> */}
|
|
|
|
|
<div className={noteClazz}>
|
|
|
|
|
<Form>
|
|
|
|
|
<FormItem>
|
|
|
|
|
{
|
|
|
|
|
getFieldDecorator('notes',{
|
|
|
|
|
rules: [
|
|
|
|
|
{ required: true, message: '笔记不能为空' },
|
|
|
|
|
{ max: noteCount, message: `笔记最大字数为${noteCount}` }
|
|
|
|
|
],
|
|
|
|
|
initialValue: (hack && hack.notes) || ''
|
|
|
|
|
})(<TextArea
|
|
|
|
|
max={noteCount}
|
|
|
|
|
placeholder="请输入笔记内容"
|
|
|
|
|
rows="5"
|
|
|
|
|
/>)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</FormItem>
|
|
|
|
|
<FormItem style={{ textAlign: 'right' }}>
|
|
|
|
|
<Button loading={loading} style={{ marginRight: '10px' }} onClick={handleCancelNote}>取消</Button>
|
|
|
|
|
<Button type="primary" onClick={handleSubmitNote}>提交</Button>
|
|
|
|
|
</FormItem>
|
|
|
|
|
</Form>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<ControlSetting
|
|
|
|
|
identifier={identifier}
|
|
|
|
|
inputValue={input}
|
|
|
|
@ -117,10 +182,14 @@ const mapStateToProps = (state) => {
|
|
|
|
|
notice,
|
|
|
|
|
hadCodeUpdate
|
|
|
|
|
} = state.ojForUserReducer;
|
|
|
|
|
const {
|
|
|
|
|
loading
|
|
|
|
|
} = state.commonReducer;
|
|
|
|
|
// const { language, code } = hack;
|
|
|
|
|
return {
|
|
|
|
|
hack,
|
|
|
|
|
notice,
|
|
|
|
|
loading,
|
|
|
|
|
hadCodeUpdate,
|
|
|
|
|
editor_code,
|
|
|
|
|
input: userTestInput,
|
|
|
|
@ -141,9 +210,12 @@ const mapDispatchToProps = (dispatch) => ({
|
|
|
|
|
// 恢复初始代码
|
|
|
|
|
restoreInitialCode: (identifier, msg) => dispatch(actions.restoreInitialCode(identifier, msg)),
|
|
|
|
|
// saveOpacityType: (type) => dispatch(actions.saveOpacityType(type))
|
|
|
|
|
// 添加笔记
|
|
|
|
|
addNotes: (identifier, params, cb) => dispatch(actions.addNotes(identifier, params, cb)),
|
|
|
|
|
changeLoadingState: (flag) => dispatch(actions.changeLoadingState(flag))
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export default connect(
|
|
|
|
|
mapStateToProps,
|
|
|
|
|
mapDispatchToProps
|
|
|
|
|
)(RightPane);
|
|
|
|
|
)(Form.create()(RightPane));
|