Merge branch 'dev_item_bank' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_new_shixunsrepository

dev_new_shixunsrepository
杨树林 5 years ago
commit e20c5333c4

@ -1,7 +1,7 @@
/* /*
* @Description: quill 编辑器 * @Description: quill 编辑器
* @Author: tangjiang * @Author: tangjiang
* @Github: * @Github:
* @Date: 2019-12-18 08:49:30 * @Date: 2019-12-18 08:49:30
* @LastEditors : tangjiang * @LastEditors : tangjiang
* @LastEditTime : 2020-01-10 15:05:27 * @LastEditTime : 2020-01-10 15:05:27
@ -57,7 +57,7 @@ function QuillForEditor ({
{size: ['12px', '14px', '16px', '18px', '20px']}, {size: ['12px', '14px', '16px', '18px', '20px']},
{align: []}, {list: 'ordered'}, {list: 'bullet'}, // 列表 {align: []}, {list: 'ordered'}, {list: 'bullet'}, // 列表
{script: 'sub'}, {script: 'super'}, {script: 'sub'}, {script: 'super'},
{ 'color': [] }, { 'background': [] }, { 'color': [] }, { 'background': [] },
{header: [1,2,3,4,5,false]}, {header: [1,2,3,4,5,false]},
'blockquote', 'code-block', 'blockquote', 'code-block',
'link', 'image', 'video', 'link', 'image', 'video',
@ -67,7 +67,7 @@ function QuillForEditor ({
const editorRef = useRef(null); const editorRef = useRef(null);
// quill 实例 // quill 实例
const [quill, setQuill] = useState(null); const [quill, setQuill] = useState(null);
const [selection, setSelection] = useState(null); const [selection, setSelection] = useState(null);
const [fillCount, setFillCount] = useState(0); const [fillCount, setFillCount] = useState(0);
const [quillCtx, setQuillCtx] = useState({}); const [quillCtx, setQuillCtx] = useState({});
@ -77,7 +77,7 @@ function QuillForEditor ({
// getQuillContent && getQuillContent(quill); // getQuillContent && getQuillContent(quill);
onContentChange && onContentChange(content, quill); onContentChange && onContentChange(content, quill);
}; };
const renderOptions = options || defaultConfig; const renderOptions = options || defaultConfig;
const bindings = { const bindings = {
@ -96,10 +96,10 @@ function QuillForEditor ({
backspace: { backspace: {
key: 'Backspace', key: 'Backspace',
/** /**
* @param {*} range * @param {*} range
* { index, // 删除元素的位置 * { index, // 删除元素的位置
* length // 删除元素的个数, 当删除一个时, length=0 其它等于删除的元素的个数 * length // 删除元素的个数, 当删除一个时, length=0 其它等于删除的元素的个数
* } * }
* @param {*} context 上下文 * @param {*} context 上下文
*/ */
handler: function (range, context) { handler: function (range, context) {
@ -126,7 +126,7 @@ function QuillForEditor ({
// } else { // } else {
// return false; // return false;
// } // }
return true; return true;
} }
} }
}; };
@ -190,7 +190,7 @@ function QuillForEditor ({
onClick: showUploadImage, onClick: showUploadImage,
width, width,
height height
}); });
} }
} }
}); });
@ -208,19 +208,19 @@ function QuillForEditor ({
// 1. 获取编辑器内容 // 1. 获取编辑器内容
}); });
// TODO // TODO
/** /**
* 1.获取键盘删除事件 * 1.获取键盘删除事件
* 2.点击时获取删除的叶子节点 getLeaf(range.index) * 2.点击时获取删除的叶子节点 getLeaf(range.index)
*/ */
}, []); }, []);
// 设置值 // 设置值
useEffect(() => { useEffect(() => {
if (!quill) return if (!quill) return
const previous = quill.getContents() const previous = quill.getContents()
if (value && value.hasOwnProperty('ops')) { if (value && value.hasOwnProperty('ops')) {
// console.log(value.ops); // console.log(value.ops);
const ops = value.ops || []; const ops = value.ops || [];
@ -234,7 +234,8 @@ function QuillForEditor ({
const current = value const current = value
if (!deepEqual(previous, current)) { if (!deepEqual(previous, current)) {
setSelection(quill.getSelection()) setSelection(quill.getSelection())
if (typeof value === 'string') { if (typeof value === 'string' && value) {
// debugger
quill.clipboard.dangerouslyPasteHTML(value, 'api'); quill.clipboard.dangerouslyPasteHTML(value, 'api');
if (autoFocus) { if (autoFocus) {
quill.focus(); quill.focus();
@ -268,7 +269,7 @@ function QuillForEditor ({
if (typeof handleOnChange !== 'function') return; if (typeof handleOnChange !== 'function') return;
let handler; let handler;
quill.on( quill.on(
'text-change', 'text-change',
(handler = (delta, oldDelta, source) => { (handler = (delta, oldDelta, source) => {
const _ctx = quill.getContents(); const _ctx = quill.getContents();
setQuillCtx(_ctx); setQuillCtx(_ctx);

@ -476,7 +476,7 @@ class Questionitem_banks extends Component {
this.setState({ this.setState({
item_type: item_type item_type: item_type
}) })
this.scrollToAnchor("Itembankstopid");
} }
render() { render() {
@ -515,6 +515,7 @@ class Questionitem_banks extends Component {
> >
</Itembankstop> </Itembankstop>
<div >
{ {
item_type && item_type === "SINGLE" ? item_type && item_type === "SINGLE" ?
@ -555,9 +556,8 @@ class Questionitem_banks extends Component {
: item_type && item_type === "PROGRAM" ? : item_type && item_type === "PROGRAM" ?
"" ""
: "" : ""
} }
</div>
</div> </div>

@ -399,7 +399,7 @@ class ChoquesEditor extends Component{
{ {
item===undefined||item===null||item===""? item===undefined||item===null||item===""?
<QuillForEditor <QuillForEditor
autoFocus={false} autoFocus={false}
imgAttrs={{width: '146px', height: '136px'}} imgAttrs={{width: '146px', height: '136px'}}
style={{ height: '166px'}} style={{ height: '166px'}}
placeholder="请您输入题干" placeholder="请您输入题干"

@ -207,7 +207,6 @@ class SingleEditor extends Component{
}catch (e) { }catch (e) {
} }
} }
componentDidUpdate(prevProps) { componentDidUpdate(prevProps) {
//console.log("componentDidUpdate"); //console.log("componentDidUpdate");
@ -363,6 +362,7 @@ class SingleEditor extends Component{
// ////console.log(!exerciseIsPublish); // ////console.log(!exerciseIsPublish);
return( return(
<div className="padding20-30 signleEditor danxuano" id={qNumber}> <div className="padding20-30 signleEditor danxuano" id={qNumber}>
<style>{` <style>{`
.optionMdEditor { .optionMdEditor {
flex:1 flex:1
@ -421,7 +421,7 @@ class SingleEditor extends Component{
{ {
item===undefined||item===null||item===""? item===undefined||item===null||item===""?
<QuillForEditor <QuillForEditor
autoFocus={false}
imgAttrs={{width: '146px', height: '136px'}} imgAttrs={{width: '146px', height: '136px'}}
style={{ height: '166px'}} style={{ height: '166px'}}
placeholder="请您输入题干" placeholder="请您输入题干"
@ -431,7 +431,7 @@ class SingleEditor extends Component{
/> />
: :
<QuillForEditor <QuillForEditor
autoFocus={false}
imgAttrs={{width: '146px', height: '136px'}} imgAttrs={{width: '146px', height: '136px'}}
style={{ height: '166px'}} style={{ height: '166px'}}
placeholder="请您输入题干" placeholder="请您输入题干"
@ -472,7 +472,7 @@ class SingleEditor extends Component{
</p> </p>
<div className="mt10"></div> <div className="mt10"></div>
<QuillForEditor <QuillForEditor
autoFocus={false}
imgAttrs={{width: '146px', height: '136px'}} imgAttrs={{width: '146px', height: '136px'}}
style={{height: '166px' }} style={{height: '166px' }}
placeholder="请您输入题目解析" placeholder="请您输入题目解析"

Loading…
Cancel
Save