diff --git a/editors/demo/src/Editors.js b/editors/demo/src/Editors.js index fa52e35509b57dc1e5f1d06514566f8cc480bbe7..977ed5cc4dbf7c694157ede01a713d4b2f5b983e 100644 --- a/editors/demo/src/Editors.js +++ b/editors/demo/src/Editors.js @@ -54,7 +54,7 @@ const Editors = () => { case 'ncbi': break; default: - return <Editoria />; + return <HHMI />; } }; diff --git a/editors/demo/src/HHMI/HHMI.js b/editors/demo/src/HHMI/HHMI.js index a0ed4a909162c625bb6ee8cfe917326084a2af39..3de249ab081c5ab16a17604036c95bbf722431de 100644 --- a/editors/demo/src/HHMI/HHMI.js +++ b/editors/demo/src/HHMI/HHMI.js @@ -14,7 +14,6 @@ const renderImage = file => { setTimeout(() => reader.readAsDataURL(file), 150); }); }; -const t = `<p class="paragraph">sdfsd</p><p class="paragraph">fdfs</p><div id="4cdb7e13-514d-4c6d-b2f3-f5b1a07af10a" class="mutiple-choice"><div class="mutiple-choice-option" id="d394ff84-5153-49e2-af12-141b05883be4" correct="false" feedback=""><p class="paragraph">rwerewrwer</p></div><div class="mutiple-choice-option" id="4efaa449-4d06-448b-98cd-a3b1c58b5b62" correct="false" feedback=""><p class="paragraph"></p></div></div>`; const Hhmi = () => { return ( @@ -23,10 +22,10 @@ const Hhmi = () => { config={config} autoFocus fileUpload={file => renderImage(file)} - value={t} + value="" // readonly layout={HhmiLayout} - onChange={source => console.log(source)} + // onChange={source => console.log(source)} /> </> ); diff --git a/editors/demo/src/HHMI/MultipleChoiceQuestionService/components/EditorComponent.js b/editors/demo/src/HHMI/MultipleChoiceQuestionService/components/EditorComponent.js index a7f6a6eabd8abaaafcfce7e444aab85c0cd15f1b..4f6f721873790aab1d88fd8c082801f672ad5a79 100644 --- a/editors/demo/src/HHMI/MultipleChoiceQuestionService/components/EditorComponent.js +++ b/editors/demo/src/HHMI/MultipleChoiceQuestionService/components/EditorComponent.js @@ -120,11 +120,6 @@ const EditorComponent = ({ node, view, getPos }) => { if (questionView.hasFocus()) questionView.focus(); }, }, - handleKeyDown: (editoView, keyEvent) => { - if (keyEvent.key === 'Enter') { - console.log('create new'); - } - }, attributes: { spellcheck: 'false', diff --git a/editors/demo/src/HHMI/MultipleChoiceQuestionService/components/FeedbackComponent.js b/editors/demo/src/HHMI/MultipleChoiceQuestionService/components/FeedbackComponent.js index 584f515a751cabeea79af2aebfaffdfa378a9d1c..bd5c9537f255c23e9956b0c4b057d2109b4cf963 100644 --- a/editors/demo/src/HHMI/MultipleChoiceQuestionService/components/FeedbackComponent.js +++ b/editors/demo/src/HHMI/MultipleChoiceQuestionService/components/FeedbackComponent.js @@ -56,11 +56,11 @@ export default ({ node, view, getPos }) => { const saveFeedBack = () => { const allNodes = getNodes(context.view.main); - allNodes.forEach(singNode => { - if (singNode.node.attrs.id === node.attrs.id) { + allNodes.forEach(singleNode => { + if (singleNode.node.attrs.id === node.attrs.id) { context.view.main.dispatch( context.view.main.state.tr.setNodeMarkup(getPos(), undefined, { - ...node.attrs, + ...singleNode.node.attrs, feedback: feedBack, }), ); diff --git a/editors/demo/src/HHMI/MultipleChoiceQuestionService/components/SwitchComponent.js b/editors/demo/src/HHMI/MultipleChoiceQuestionService/components/SwitchComponent.js index c09f657a6eb3f4d2d14397e3c91390f79bcdcccc..6231f290cf63212639f4bb08a40a77d5f947cbe0 100644 --- a/editors/demo/src/HHMI/MultipleChoiceQuestionService/components/SwitchComponent.js +++ b/editors/demo/src/HHMI/MultipleChoiceQuestionService/components/SwitchComponent.js @@ -37,12 +37,17 @@ const CustomSwitch = ({ node, getPos }) => { const handleChange = () => { setChecked(!checked); - context.view.main.dispatch( - context.view.main.state.tr.setNodeMarkup(getPos(), undefined, { - ...node.attrs, - correct: !checked, - }), - ); + const allNodes = getNodes(context.view.main); + allNodes.forEach(singleNode => { + if (singleNode.node.attrs.id === node.attrs.id) { + context.view.main.dispatch( + context.view.main.state.tr.setNodeMarkup(getPos(), undefined, { + ...singleNode.node.attrs, + correct: !checked, + }), + ); + } + }); }; return ( diff --git a/editors/demo/src/HHMI/MultipleChoiceQuestionService/schema/multipleChoiceContainerNode.js b/editors/demo/src/HHMI/MultipleChoiceQuestionService/schema/multipleChoiceContainerNode.js index 14eed4e36a87be6342c8860f4856b3e2337bf757..2b0fd0081ba47ff3f4b6d056e5db02d6880e7186 100644 --- a/editors/demo/src/HHMI/MultipleChoiceQuestionService/schema/multipleChoiceContainerNode.js +++ b/editors/demo/src/HHMI/MultipleChoiceQuestionService/schema/multipleChoiceContainerNode.js @@ -4,9 +4,9 @@ const multipleChoiceContainerNode = { class: { default: 'mutiple-choice' }, }, group: 'block', - // atom: true, + atom: true, selectable: true, - draggable: false, + draggable: true, content: 'multiple_choice+', parseDOM: [ { diff --git a/editors/demo/src/HHMI/MultipleChoiceQuestionService/schema/multipleChoiceNode.js b/editors/demo/src/HHMI/MultipleChoiceQuestionService/schema/multipleChoiceNode.js index c7e79e9d25df6b5559c8cc9cc826aa7eb2a5c4ae..4617a88cabe27563aafb8e3171da3070b82dbe3e 100644 --- a/editors/demo/src/HHMI/MultipleChoiceQuestionService/schema/multipleChoiceNode.js +++ b/editors/demo/src/HHMI/MultipleChoiceQuestionService/schema/multipleChoiceNode.js @@ -19,7 +19,7 @@ const multipleChoiceNode = { return { id: dom.getAttribute('id'), class: dom.getAttribute('class'), - correct: dom.getAttribute('correct'), + correct: JSON.parse(dom.getAttribute('correct').toLowerCase()), feedback: dom.getAttribute('feedback'), }; }, diff --git a/editors/demo/src/HHMI/layout/EditorElements.js b/editors/demo/src/HHMI/layout/EditorElements.js index 7201b0de261de9726636805f0e482b573deeaea2..87ac8cb9855caf77cb8673d3890d7c1c781a7878 100644 --- a/editors/demo/src/HHMI/layout/EditorElements.js +++ b/editors/demo/src/HHMI/layout/EditorElements.js @@ -333,7 +333,7 @@ export default css` padding-top: 0px; &:before { - bottom: 45px; + bottom: 25px; content: 'Answer Group ' counter(multiple-question) '.'; counter-increment: multiple-question; position: relative; @@ -345,8 +345,4 @@ export default css` padding: 5px 5px 0 5px; } } - - .mutiple-choice.ProseMirror-selectednode { - outline: none; - } `;