Skip to content
Snippets Groups Projects
Commit c97878b4 authored by chris's avatar chris
Browse files

set selection

parent fe695ca9
No related branches found
No related tags found
1 merge request!301Question controls
......@@ -25,7 +25,7 @@ class MultipleChoiceQuestionService extends Service {
createNode({
question_wrapper: {
group: 'block',
// atom: true,
atom: true,
content: 'inline*',
attrs: {
class: { default: 'paragraph' },
......
......@@ -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.
......
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