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

add active

parent bf49ae46
No related branches found
No related tags found
1 merge request!430Hhmi issues
...@@ -104,6 +104,17 @@ class EssayQuestion extends Tools { ...@@ -104,6 +104,17 @@ class EssayQuestion extends Tools {
}; };
} }
get active() {
return state => {
if (
Commands.isParentOfType(state, state.config.schema.nodes.essay_question)
) {
return true;
}
return false;
};
}
select = (state, activeView) => { select = (state, activeView) => {
let status = true; let status = true;
const { from, to } = state.selection; const { from, to } = state.selection;
......
import { injectable } from 'inversify'; import { injectable } from 'inversify';
import { findWrapping } from 'prosemirror-transform'; import { findWrapping } from 'prosemirror-transform';
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
import { Tools } from 'wax-prosemirror-core'; import { Commands, Tools } from 'wax-prosemirror-core';
import helpers from '../MultipleChoiceQuestionService/helpers/helpers'; import helpers from '../MultipleChoiceQuestionService/helpers/helpers';
@injectable() @injectable()
...@@ -30,6 +30,20 @@ class FillTheGapQuestion extends Tools { ...@@ -30,6 +30,20 @@ class FillTheGapQuestion extends Tools {
}; };
} }
get active() {
return state => {
if (
Commands.isParentOfType(
state,
state.config.schema.nodes.fill_the_gap_container,
)
) {
return true;
}
return false;
};
}
select = (state, activeViewId, activeView) => { select = (state, activeViewId, activeView) => {
const { disallowedTools } = activeView.props; const { disallowedTools } = activeView.props;
let status = true; let status = true;
......
...@@ -3,7 +3,7 @@ import { Fragment } from 'prosemirror-model'; ...@@ -3,7 +3,7 @@ import { Fragment } from 'prosemirror-model';
import { findWrapping } from 'prosemirror-transform'; import { findWrapping } from 'prosemirror-transform';
import { TextSelection } from 'prosemirror-state'; import { TextSelection } from 'prosemirror-state';
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
import { Tools } from 'wax-prosemirror-core'; import { Tools, Commands } from 'wax-prosemirror-core';
import helpers from '../MultipleChoiceQuestionService/helpers/helpers'; import helpers from '../MultipleChoiceQuestionService/helpers/helpers';
@injectable() @injectable()
...@@ -48,6 +48,20 @@ class MatchingQuestion extends Tools { ...@@ -48,6 +48,20 @@ class MatchingQuestion extends Tools {
}; };
} }
get active() {
return state => {
if (
Commands.isParentOfType(
state,
state.config.schema.nodes.matching_container,
)
) {
return true;
}
return false;
};
}
select = (state, activeViewId, activeView) => { select = (state, activeViewId, activeView) => {
const { disallowedTools } = activeView.props; const { disallowedTools } = activeView.props;
let status = true; let status = true;
...@@ -61,13 +75,5 @@ class MatchingQuestion extends Tools { ...@@ -61,13 +75,5 @@ class MatchingQuestion extends Tools {
}); });
return status; return status;
}; };
get active() {
return state => {};
}
get enable() {
return state => {};
}
} }
export default MatchingQuestion; export default MatchingQuestion;
import { injectable } from 'inversify'; import { injectable } from 'inversify';
import { findWrapping } from 'prosemirror-transform'; import { findWrapping } from 'prosemirror-transform';
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
import { Tools } from 'wax-prosemirror-core'; import { Tools, Commands } from 'wax-prosemirror-core';
import helpers from '../MultipleChoiceQuestionService/helpers/helpers'; import helpers from '../MultipleChoiceQuestionService/helpers/helpers';
@injectable() @injectable()
...@@ -35,7 +35,17 @@ class MultipleDropDownQuestion extends Tools { ...@@ -35,7 +35,17 @@ class MultipleDropDownQuestion extends Tools {
} }
get active() { get active() {
return state => {}; return state => {
if (
Commands.isParentOfType(
state,
state.config.schema.nodes.multiple_drop_down_container,
)
) {
return true;
}
return false;
};
} }
select = (state, activeViewId, activeView) => { select = (state, activeViewId, activeView) => {
......
...@@ -94,8 +94,8 @@ const DropDownComponent = ({ view, tools }) => { ...@@ -94,8 +94,8 @@ const DropDownComponent = ({ view, tools }) => {
]; ];
useEffect(() => { useEffect(() => {
setLabel('Question Types'); setLabel('Question Type');
dropDownOptions.forEach((option, i) => { dropDownOptions.forEach(option => {
if (option.item.active(main.state)) { if (option.item.active(main.state)) {
setTimeout(() => { setTimeout(() => {
setLabel(option.label); setLabel(option.label);
...@@ -118,7 +118,7 @@ const DropDownComponent = ({ view, tools }) => { ...@@ -118,7 +118,7 @@ const DropDownComponent = ({ view, tools }) => {
key={uuidv4()} key={uuidv4()}
onChange={option => onChange(option)} onChange={option => onChange(option)}
options={dropDownOptions} options={dropDownOptions}
placeholder="Question Types" placeholder="Question Type"
select={isDisabled} select={isDisabled}
value={label} value={label}
/> />
......
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