|
|
|
@ -79,6 +79,8 @@ class ChoquesEditor extends Component{
|
|
|
|
|
question_titlesysl:this.props.question_titlesysl||'',
|
|
|
|
|
question_titleysl:this.props.question_title || '',
|
|
|
|
|
item_banksedit:[],
|
|
|
|
|
bindinginputs:null,
|
|
|
|
|
url:"",
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
addOption = () => {
|
|
|
|
@ -175,7 +177,14 @@ class ChoquesEditor extends Component{
|
|
|
|
|
this.props.onEditorCancel()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
handleShowUploadImage = (url,i) => {
|
|
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
|
url:url,
|
|
|
|
|
bindinginputs:i
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentDidMount = () => {
|
|
|
|
|
try {
|
|
|
|
@ -228,10 +237,22 @@ class ChoquesEditor extends Component{
|
|
|
|
|
}
|
|
|
|
|
var texts;
|
|
|
|
|
const _text = quill.getText();
|
|
|
|
|
// console.log("onOptionContentChange");
|
|
|
|
|
// console.log(value);
|
|
|
|
|
// console.log(value.ops.length);
|
|
|
|
|
// console.log(_text);
|
|
|
|
|
const reg = /^[\s\S]*.*[^\s][\s\S]*$/;
|
|
|
|
|
if (!reg.test(_text)) {
|
|
|
|
|
// 处理编辑器内容为空
|
|
|
|
|
texts="";
|
|
|
|
|
try {
|
|
|
|
|
if(value.ops.length>1){
|
|
|
|
|
//单独图片的话 _text是为空的
|
|
|
|
|
texts=JSON.stringify(value);
|
|
|
|
|
}
|
|
|
|
|
}catch (e) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if(_text.length>=500){
|
|
|
|
|
var result = _text.substring(0,450);
|
|
|
|
@ -288,40 +309,68 @@ class ChoquesEditor extends Component{
|
|
|
|
|
if (!reg.test(_text)) {
|
|
|
|
|
// 处理编辑器内容为空
|
|
|
|
|
this.setState({
|
|
|
|
|
question_titleysl:""
|
|
|
|
|
question_titleysl:"",
|
|
|
|
|
})
|
|
|
|
|
try {
|
|
|
|
|
if(value.ops.length>1) {
|
|
|
|
|
this.setState({
|
|
|
|
|
question_titleysl:JSON.stringify(value),
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}catch (e) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// 提交到后台的内容需要处理一下;
|
|
|
|
|
try {
|
|
|
|
|
let texts = JSON.stringify(value);
|
|
|
|
|
this.setState({
|
|
|
|
|
question_titleysl:texts
|
|
|
|
|
question_titleysl:texts,
|
|
|
|
|
})
|
|
|
|
|
}catch (e) {
|
|
|
|
|
this.setState({
|
|
|
|
|
question_titleysl:""
|
|
|
|
|
question_titleysl:"",
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
bindinginputs=(i)=>{
|
|
|
|
|
this.setState({
|
|
|
|
|
bindinginputs:i
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onContentChanges=(value,quill)=>{
|
|
|
|
|
const _text = quill.getText();
|
|
|
|
|
const reg = /^[\s\S]*.*[^\s][\s\S]*$/;
|
|
|
|
|
if (!reg.test(_text)) {
|
|
|
|
|
// 处理编辑器内容为空
|
|
|
|
|
this.setState({
|
|
|
|
|
question_titlesysl:""
|
|
|
|
|
question_titlesysl:"",
|
|
|
|
|
})
|
|
|
|
|
try {
|
|
|
|
|
if(value.ops.length>1){
|
|
|
|
|
//单独图片的话 _text是为空的
|
|
|
|
|
this.setState({
|
|
|
|
|
question_titlesysl:JSON.stringify(value),
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}catch (e) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// 提交到后台的内容需要处理一下;
|
|
|
|
|
try {
|
|
|
|
|
let texts = JSON.stringify(value);
|
|
|
|
|
this.setState({
|
|
|
|
|
question_titlesysl:texts
|
|
|
|
|
question_titlesysl:texts,
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
}catch (e) {
|
|
|
|
|
this.setState({
|
|
|
|
|
question_titlesysl:""
|
|
|
|
|
question_titlesysl:"",
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -330,7 +379,7 @@ class ChoquesEditor extends Component{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
let { question_title, question_score, question_type, question_choices, standard_answers,question_titles} = this.state;
|
|
|
|
|
let { question_title, question_score, question_type, question_choices, standard_answers,question_titles,bindinginputs} = this.state;
|
|
|
|
|
let { question_id, index, exerciseIsPublish,
|
|
|
|
|
// question_title,
|
|
|
|
|
// question_type,
|
|
|
|
@ -382,6 +431,20 @@ class ChoquesEditor extends Component{
|
|
|
|
|
.signleEditor .quill_editor_for_react_area .ql-container .ql-editor p{
|
|
|
|
|
font-family: MicrosoftYaHei;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.content_editorMd_show{
|
|
|
|
|
display: flex !important;
|
|
|
|
|
margin-top:0px !important;
|
|
|
|
|
border-radius:2px !important;
|
|
|
|
|
max-width: 1056px !important;
|
|
|
|
|
word-break:break-all !important;
|
|
|
|
|
border:1px solid rgba(221,221,221,1) !important;
|
|
|
|
|
}
|
|
|
|
|
.contestedtext{
|
|
|
|
|
font-size:14px;
|
|
|
|
|
font-family:MicrosoftYaHei;
|
|
|
|
|
color:rgba(172,172,172,1);
|
|
|
|
|
}
|
|
|
|
|
`}</style>
|
|
|
|
|
<p className="mb10 clearfix">
|
|
|
|
|
{/* {!question_id ? '新建' : '编辑'} */}
|
|
|
|
@ -391,7 +454,7 @@ class ChoquesEditor extends Component{
|
|
|
|
|
|
|
|
|
|
<QuillForEditor
|
|
|
|
|
autoFocus={true}
|
|
|
|
|
imgAttrs={{width: '146px', height: '136px'}}
|
|
|
|
|
imgAttrs={{width: '200px', height: '200px'}}
|
|
|
|
|
style={{ height: '155px'}}
|
|
|
|
|
placeholder="请您输入题干"
|
|
|
|
|
options={options}
|
|
|
|
@ -407,6 +470,8 @@ class ChoquesEditor extends Component{
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{question_choices.map( (item, index) => {
|
|
|
|
|
// console.log("question_choices");
|
|
|
|
|
// console.log(item);
|
|
|
|
|
const bg = standard_answers[index] ? 'check-option-bg' : ''
|
|
|
|
|
return <div key={index} className={index>0?"df optionRow mt15": "df optionRow"} >
|
|
|
|
|
{/* 点击设置答案 */}
|
|
|
|
@ -423,25 +488,51 @@ class ChoquesEditor extends Component{
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
item===undefined||item===null||item===""?
|
|
|
|
|
<div style={{width:'100%'}}>
|
|
|
|
|
{
|
|
|
|
|
bindinginputs===null||bindinginputs!==index?
|
|
|
|
|
<div className="content_editorMd_show" onClick={()=>this.bindinginputs(index)}>
|
|
|
|
|
{/*<p className="contestedtext">请您输入选项</p>*/}
|
|
|
|
|
</div>:
|
|
|
|
|
<QuillForEditor
|
|
|
|
|
autoFocus={false}
|
|
|
|
|
imgAttrs={{width: '146px', height: '136px'}}
|
|
|
|
|
imgAttrs={{width: '200px', height: '200px'}}
|
|
|
|
|
style={{ height: '166px'}}
|
|
|
|
|
placeholder="请您输入选项"
|
|
|
|
|
options={options}
|
|
|
|
|
value={item}
|
|
|
|
|
onContentChange={(value,quill) => this.onOptionContentChange(value,quill,index)}
|
|
|
|
|
showUploadImage={(url)=>this.handleShowUploadImage(url,index)}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
:
|
|
|
|
|
<div style={{width:'100%'}}>
|
|
|
|
|
{
|
|
|
|
|
bindinginputs===null||bindinginputs!==index?
|
|
|
|
|
<div className="content_editorMd_show" onClick={()=>this.bindinginputs(index)}>
|
|
|
|
|
|
|
|
|
|
<QuillForEditor
|
|
|
|
|
readOnly={true}
|
|
|
|
|
value={JSON.parse(item)}
|
|
|
|
|
showUploadImage={(url)=>this.handleShowUploadImage(url,index)}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
:
|
|
|
|
|
<QuillForEditor
|
|
|
|
|
autoFocus={false}
|
|
|
|
|
imgAttrs={{width: '146px', height: '136px'}}
|
|
|
|
|
imgAttrs={{width: '200px', height: '200px'}}
|
|
|
|
|
style={{ height: '166px'}}
|
|
|
|
|
placeholder="请您输入选项"
|
|
|
|
|
options={options}
|
|
|
|
|
value={JSON.parse(item)}
|
|
|
|
|
onContentChange={(value,quill) => this.onOptionContentChange(value,quill,index)}
|
|
|
|
|
showUploadImage={(url)=>this.handleShowUploadImage(url,index)}
|
|
|
|
|
/>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
@ -474,12 +565,13 @@ class ChoquesEditor extends Component{
|
|
|
|
|
<div className="mt10"></div>
|
|
|
|
|
<QuillForEditor
|
|
|
|
|
autoFocus={false}
|
|
|
|
|
imgAttrs={{width: '146px', height: '136px'}}
|
|
|
|
|
imgAttrs={{width: '200px', height: '200px'}}
|
|
|
|
|
style={{height: '166px' }}
|
|
|
|
|
placeholder="请您输入题目解析"
|
|
|
|
|
options={options}
|
|
|
|
|
value={question_titles}
|
|
|
|
|
onContentChange={this.onContentChanges}
|
|
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|