From ebd0b469e37d8430af84f5797c10e9e91160cec2 Mon Sep 17 00:00:00 2001 From: chris <kokosias@yahoo.gr> Date: Tue, 21 Sep 2021 23:21:39 +0300 Subject: [PATCH] fix node update issues --- .../components/EditorComponent.js | 5 ----- .../components/FeedbackComponent.js | 6 +++--- .../components/SwitchComponent.js | 17 +++++++++++------ .../schema/multipleChoiceContainerNode.js | 4 ++-- .../schema/multipleChoiceNode.js | 2 +- editors/demo/src/HHMI/layout/EditorElements.js | 6 +----- 6 files changed, 18 insertions(+), 22 deletions(-) diff --git a/editors/demo/src/HHMI/MultipleChoiceQuestionService/components/EditorComponent.js b/editors/demo/src/HHMI/MultipleChoiceQuestionService/components/EditorComponent.js index a7f6a6eab..4f6f72187 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 584f515a7..bd5c9537f 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 c09f657a6..6231f290c 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 14eed4e36..2b0fd0081 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 c7e79e9d2..4617a88ca 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 7201b0de2..87ac8cb98 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; - } `; -- GitLab