<template>
	<div>
		<div class="exersices-content">
			<IconText :text="$t('evaluation.compose') + $t('evaluation.newExercise.stem')" :color="'#2d8cf0'" :icon="'ios-create'" style="margin-bottom:15px;"></IconText>
			<div>
				<div ref="editor" style="text-align:left"></div>
			</div>
		</div>
	</div>
</template>
<script>
	import E from 'wangeditor'
	import IconText from '@/components/evaluation/IconText.vue'
	export default {
		components: {
			IconText
		},
		props: ['editInfo'],
		data() {
			return {
				defaultConfig: {
					uploadImgShowBase64: true,
					menus: this.$tools.wangEditorMenu
				},
				stemContent: '',
				stemEditor: null
			}
		},
		methods: {

		},
		mounted() {
			let stemEditor = new E(this.$refs.editor)
			stemEditor.config.onchange = (html) => {
				this.stemContent = html
			}
			stemEditor.config.uploadImgShowBase64 = true;
			this.$editorTools.initMyEditor(stemEditor,this)
			stemEditor.create()
			this.stemEditor = stemEditor
			
			if(this.editInfo && this.editInfo.question){
				console.log('综合题Mount编辑')
				this.stemContent = this.editInfo.question
				this.stemEditor.txt.html(this.editInfo.question)
			}
		},
		watch:{
			editInfo:{
				handler(n){
					console.log('主观题富文本接收到的数据')
					console.log(n)
					if(n){
						this.stemContent = this.editInfo.question
						this.stemEditor.txt.html(this.editInfo.question)
					}
				}
			}
		}
	}
</script>
<style lang="less" scoped>
	@import"../index/CreateExercises.less";
</style>
