diff --git a/editors/demo/src/HHMI/MultipleChoiceQuestionService/MultipleChoiceQuestionService.js b/editors/demo/src/HHMI/MultipleChoiceQuestionService/MultipleChoiceQuestionService.js index 5053c0221852fe3ede712da66e45660c3f8b7817..794f208ed4a2ff5ac8f001126c213ce32bf21986 100644 --- a/editors/demo/src/HHMI/MultipleChoiceQuestionService/MultipleChoiceQuestionService.js +++ b/editors/demo/src/HHMI/MultipleChoiceQuestionService/MultipleChoiceQuestionService.js @@ -25,7 +25,7 @@ class MultipleChoiceQuestionService extends Service { createNode({ question_wrapper: { group: 'block', - // atom: true, + atom: true, content: 'inline*', attrs: { class: { default: 'paragraph' }, diff --git a/editors/demo/src/HHMI/MultipleChoiceQuestionService/components/EditorComponent.js b/editors/demo/src/HHMI/MultipleChoiceQuestionService/components/EditorComponent.js index 4cec8c470f5a32fe57aba5796bf744aebd915e4e..1359e83cccac04281b69160f52375ca98c8db886 100644 --- a/editors/demo/src/HHMI/MultipleChoiceQuestionService/components/EditorComponent.js +++ b/editors/demo/src/HHMI/MultipleChoiceQuestionService/components/EditorComponent.js @@ -2,7 +2,7 @@ import React, { useContext, useRef, useEffect } from 'react'; import styled from 'styled-components'; import { EditorView } from 'prosemirror-view'; -import { EditorState } from 'prosemirror-state'; +import { EditorState, TextSelection } from 'prosemirror-state'; import { StepMap } from 'prosemirror-transform'; import { keymap } from 'prosemirror-keymap'; import { baseKeymap } from 'prosemirror-commands'; @@ -19,7 +19,12 @@ const EditorComponent = ({ node, view, getPos }) => { return editable; }); - if (context.activeViewId === node.attrs.id) { + const { + view: { main }, + activeViewId, + } = context; + + if (activeViewId === node.attrs.id && context.view[activeViewId].focused) { } useEffect(() => { @@ -36,6 +41,14 @@ const EditorComponent = ({ node, view, getPos }) => { handleDOMEvents: { mousedown: () => { context.updateView({}, questionId); + context.view[activeViewId].dispatch( + context.view[activeViewId].state.tr.setSelection( + TextSelection.between( + context.view[activeViewId].state.selection.$anchor, + context.view[activeViewId].state.selection.$head, + ), + ), + ); // Kludge to prevent issues due to the fact that the whole // footnote is node-selected (and thus DOM-selected) when // the parent editor is focused.