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

fix command

parent 98374dfb
No related branches found
No related tags found
1 merge request!396add inputs
import { injectable } from 'inversify';
import { wrapIn } from 'prosemirror-commands';
import { findWrapping } from 'prosemirror-transform';
import { v4 as uuidv4 } from 'uuid';
import Tools from '../lib/Tools';
import helpers from '../MultipleChoiceQuestionService/helpers/helpers';
@injectable()
class FillTheGapQuestion extends Tools {
......@@ -10,10 +11,20 @@ class FillTheGapQuestion extends Tools {
name = 'Fill The Gap';
get run() {
return (state, dispatch) => {
wrapIn(state.config.schema.nodes.fill_the_gap_container, {
id: uuidv4(),
})(state, dispatch);
return (state, dispatch, view) => {
helpers.checkifEmpty(view);
const { $from, $to } = view.state.selection;
const range = $from.blockRange($to);
const { tr } = view.state;
const wrapping =
range &&
findWrapping(range, state.config.schema.nodes.fill_the_gap_container, {
id: uuidv4(),
});
if (!wrapping) return false;
tr.wrap(range, wrapping);
dispatch(tr);
};
}
......
......@@ -3,31 +3,16 @@
import React, { useContext, useRef, useEffect } from 'react';
import styled from 'styled-components';
import { EditorView } from 'prosemirror-view';
import { EditorState, TextSelection } from 'prosemirror-state';
import { EditorState } from 'prosemirror-state';
import { StepMap } from 'prosemirror-transform';
import { keymap } from 'prosemirror-keymap';
import { baseKeymap } from 'prosemirror-commands';
import { undo, redo } from 'prosemirror-history';
import { WaxContext } from 'wax-prosemirror-core';
const EditorWrapper = styled.div`
> .ProseMirror {
padding: 5px;
padding: 0px;
&:focus {
outline: none;
}
p.empty-node:first-child::before {
content: attr(data-content);
}
.empty-node::before {
color: rgb(170, 170, 170);
float: left;
font-style: italic;
height: 0px;
pointer-events: none;
}
}
`;
......
......@@ -110,7 +110,13 @@ const EditorComponent = ({ node, view, getPos }) => {
plugins: finalPlugins,
}),
dispatchTransaction,
disallowedTools: ['Images', 'Lists', 'lift', 'MultipleChoice'],
disallowedTools: [
'Images',
'Lists',
'lift',
'MultipleChoice',
'Tables',
],
handleDOMEvents: {
mousedown: () => {
main.dispatch(
......
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