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

container tool

parent 77f8fd16
No related branches found
No related tags found
1 merge request!396add inputs
import { injectable } from 'inversify';
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 {
......@@ -8,14 +11,45 @@ class FillTheGapQuestion extends Tools {
name = 'Multiple Drop Down';
get run() {
return (state, dispatch, view) => {};
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.multiple_drop_down_container,
{
id: uuidv4(),
},
);
if (!wrapping) return false;
tr.wrap(range, wrapping);
dispatch(tr);
};
}
get active() {
return state => {};
}
select = (state, activeViewId, activeView) => {};
select = (state, activeViewId, activeView) => {
const { disallowedTools } = activeView.props;
let status = true;
const { from, to } = state.selection;
if (from === null || disallowedTools.includes('MultipleDropDown'))
return false;
state.doc.nodesBetween(from, to, (node, pos) => {
if (node.type.groups.includes('questions')) {
status = false;
}
});
return status;
};
get enable() {
return state => {};
......
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