Commit 001f5860 authored by chris's avatar chris
Browse files

feedback fix

parent 9df2dcec
......@@ -15,7 +15,7 @@ const renderImage = file => {
});
};
const t = `<p class="paragraph">Based on the equation below</p><math-display class="math-node">x + y = 5</math-display><p class="paragraph">Which ones are correct?</p><p class="paragraph"></p><div id="" class="multiple-choice"><div class="multiple-choice-option" id="d7b65415-ff82-446f-afa4-accaa3837f4a" correct="false" feedback=""><p class="paragraph">answer 1</p><p class="paragraph"><math-inline class="math-node">x+y=1</math-inline></p></div><div class="multiple-choice-option" id="e7d6bb2f-7cd7-44f1-92a0-281e72157538" correct="true" feedback=""><p class="paragraph">answer 2</p></div><div class="multiple-choice-option" id="d6fc749f-afae-4203-9562-d68c380a86e5" correct="false" feedback=""><p class="paragraph">answer 3</p></div></div><div id="" class="fill-the-gap"><p class="paragraph">A <span id="bfd4376c-4424-455e-9187-f53282fa1024" class="fill-the-gap">DNA</span> molecule is very long and usually consists of hundreds or thousands of genes.</p><p class="paragraph">An electron having a certain discrete amount of <span id="14dedf44-728f-4384-835f-e3af82b25623" class="fill-the-gap">energy</span> is something like a ball on a staircase.</p></div><p class="paragraph"></p>`;
const t = `<p class="paragraph">Based on the equation below</p><math-display class="math-node">x + y = 5</math-display><p class="paragraph">Which ones are correct?</p><p class="paragraph"></p><div id="" class="multiple-choice"><div class="multiple-choice-option" id="d7b65415-ff82-446f-afa4-accaa3837f4a" correct="false" feedback=""><p class="paragraph">answer 1</p><p class="paragraph"><math-inline class="math-node">x+y=1</math-inline></p></div><div class="multiple-choice-option" id="e7d6bb2f-7cd7-44f1-92a0-281e72157538" correct="true" feedback=""><p class="paragraph">answer 2</p></div><div class="multiple-choice-option" id="d6fc749f-afae-4203-9562-d68c380a86e5" correct="false" feedback="1111111"><p class="paragraph">answer 3</p></div></div><div id="" class="fill-the-gap"><p class="paragraph">A <span id="bfd4376c-4424-455e-9187-f53282fa1024" class="fill-the-gap">DNA</span> molecule is very long and usually consists of hundreds or thousands of genes.</p><p class="paragraph">An electron having a certain discrete amount of <span id="14dedf44-728f-4384-835f-e3af82b25623" class="fill-the-gap">energy</span> is something like a ball on a staircase.</p></div><p class="paragraph"></p>`;
const Hhmi = () => {
return (
......@@ -24,7 +24,7 @@ const Hhmi = () => {
config={config}
autoFocus
fileUpload={file => renderImage(file)}
value=""
value={t}
// readonly
layout={HhmiLayout}
// onChange={source => console.log(source)}
......
......@@ -26,23 +26,24 @@ export default ({ node, view, getPos }) => {
const context = useContext(WaxContext);
const [feedBack, setFeedBack] = useState('');
const [isFirstRun, setFirstRun] = useState(true);
const [typing, setTyping] = useState(false);
const feedBackRef = useRef(null);
useEffect(() => {
const allNodes = getNodes(context.view.main);
allNodes.forEach(singNode => {
if (singNode.node.attrs.id === node.attrs.id) {
if (!typing) setFeedBack(singNode.node.attrs.feedback);
if (!isFirstRun) {
if (singNode.node.attrs.feedback === '')
setFeedBack(singNode.node.attrs.feedback);
}
if (singNode.node.attrs.feedback !== '')
setFeedBack(singNode.node.attrs.feedback);
}
});
}, [getNodes(context.view.main)]);
const handleKeyDown = e => {
setTyping(true);
if (e.key === 'Backspace') {
context.view.main.dispatch(
context.view.main.state.tr.setSelection(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment