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

multiple drop down toolbar

parent 39692512
No related branches found
No related tags found
1 merge request!426Questions ToolGroup
Showing
with 67 additions and 25 deletions
...@@ -59,6 +59,10 @@ export default { ...@@ -59,6 +59,10 @@ export default {
templateArea: 'fillTheGap', templateArea: 'fillTheGap',
toolGroups: ['FillTheGap'], toolGroups: ['FillTheGap'],
}, },
{
templateArea: 'MultipleDropDown',
toolGroups: ['MultipleDropDown'],
},
], ],
SchemaService: DefaultSchema, SchemaService: DefaultSchema,
......
...@@ -12,6 +12,12 @@ const FillTheGapContainer = styled.div` ...@@ -12,6 +12,12 @@ const FillTheGapContainer = styled.div`
const FillTheGapContainerTool = styled.div` const FillTheGapContainerTool = styled.div`
background: #f5f5f7; background: #f5f5f7;
span {
position: relative;
left: 5px;
top: 3px;
}
`; `;
const FillTheGapWrapper = styled.div` const FillTheGapWrapper = styled.div`
...@@ -41,6 +47,7 @@ export default ({ node, view, getPos }) => { ...@@ -41,6 +47,7 @@ export default ({ node, view, getPos }) => {
<div> <div>
<span> Fill The Gap</span> <span> Fill The Gap</span>
<FillTheGapContainerTool> <FillTheGapContainerTool>
<span> Insert Gap :</span>
<FillTheGapTool /> <FillTheGapTool />
</FillTheGapContainerTool> </FillTheGapContainerTool>
</div> </div>
......
/* -- Multiple Choice ---------------------------------- */ /* -- Multiple Choice ---------------------------------- */
.ProseMirror {
counter-reset: multiple-question;
}
.multiple-choice, .multiple-choice,
.multiple-choice-single-correct, .multiple-choice-single-correct,
.true-false, .true-false,
.true-false-single-correct { .true-false-single-correct {
border: 3px solid #f5f5f7; border: 3px solid #f5f5f7;
counter-reset: question-item-multiple;
margin: 38px; margin: 38px;
padding: 20px; padding: 20px;
padding-top: 0px; padding-top: 0px;
...@@ -20,7 +15,6 @@ ...@@ -20,7 +15,6 @@
.true-false:before, .true-false:before,
.true-false-single-correct:before { .true-false-single-correct:before {
bottom: 25px; bottom: 25px;
counter-increment: multiple-question;
position: relative; position: relative;
right: 20px; right: 20px;
} }
...@@ -35,19 +29,19 @@ ...@@ -35,19 +29,19 @@
.multiple-choice:before { .multiple-choice:before {
content: 'Answer Group ' counter(multiple-question) ' (multiple choice)'; content: 'Multiple Choice' ;
} }
.multiple-choice-single-correct:before { .multiple-choice-single-correct:before {
content: 'Answer Group ' counter(multiple-question)' (multiple choice single correct)'; content: 'Multiple Choice Single Correct';
} }
.true-false:before { .true-false:before {
content: 'Answer Group ' counter(multiple-question) ' (true/false)'; content: 'True False';
} }
.true-false-single-correct:before { .true-false-single-correct:before {
content: 'Answer Group ' counter(multiple-question)' (true/false single correct)'; content: 'True False Single Correct';
} }
.rc-switch { .rc-switch {
......
...@@ -29,20 +29,13 @@ class CreateDropDown extends Tools { ...@@ -29,20 +29,13 @@ class CreateDropDown extends Tools {
} }
select = (state, activeViewId, activeView) => { select = (state, activeViewId, activeView) => {
let status = false; if (
const { from, to } = state.selection; activeView.props.type &&
const { disallowedTools } = activeView.props; activeView.props.type === 'MultipleDropDownContaier'
)
return true;
state.doc.nodesBetween(from, to, (node, pos) => { return false;
if (node.type.name === 'multiple_drop_down_container') {
status = true;
}
});
if (from === null || disallowedTools.includes('MultipleDropDown'))
status = false;
return status;
}; };
get active() { get active() {
......
...@@ -4,6 +4,7 @@ import multipleDropDownOptionNode from '../schema/multipleDropDownOptionNode'; ...@@ -4,6 +4,7 @@ import multipleDropDownOptionNode from '../schema/multipleDropDownOptionNode';
import MultipleDropDownNodeView from './MultipleDropDownNodeView'; import MultipleDropDownNodeView from './MultipleDropDownNodeView';
import MultipleDropDownComponent from '../components/MultipleDropDownComponent'; import MultipleDropDownComponent from '../components/MultipleDropDownComponent';
import DropDownComponent from '../components/DropDownComponent'; import DropDownComponent from '../components/DropDownComponent';
import MultipleDropDownToolGroupService from '../../WaxToolGroups/MultipleDropDownToolGroupService/MultipleDropDownToolGroupService';
class CreateDropDownService extends Service { class CreateDropDownService extends Service {
name = 'CreateDropDownService'; name = 'CreateDropDownService';
...@@ -37,6 +38,8 @@ class CreateDropDownService extends Service { ...@@ -37,6 +38,8 @@ class CreateDropDownService extends Service {
context: this.app, context: this.app,
}); });
} }
dependencies = [new MultipleDropDownToolGroupService()];
} }
export default CreateDropDownService; export default CreateDropDownService;
...@@ -122,6 +122,7 @@ const ContainerEditor = ({ node, view, getPos }) => { ...@@ -122,6 +122,7 @@ const ContainerEditor = ({ node, view, getPos }) => {
}), }),
dispatchTransaction, dispatchTransaction,
disallowedTools: ['Images', 'FillTheGap', 'MultipleChoice'], disallowedTools: ['Images', 'FillTheGap', 'MultipleChoice'],
type: 'MultipleDropDownContaier',
handleDOMEvents: { handleDOMEvents: {
mousedown: () => { mousedown: () => {
main.dispatch( main.dispatch(
......
/* eslint-disable react/prop-types */ /* eslint-disable react/prop-types */
import React, { useContext } from 'react'; import React, { useContext } from 'react';
import { WaxContext } from 'wax-prosemirror-core'; import { WaxContext, ComponentPlugin } from 'wax-prosemirror-core';
import styled from 'styled-components'; import styled from 'styled-components';
import ContainerEditor from './ContainerEditor'; import ContainerEditor from './ContainerEditor';
import FeedbackComponent from './FeedbackComponent'; import FeedbackComponent from './FeedbackComponent';
...@@ -10,6 +10,15 @@ const MultipleDropDownpWrapper = styled.div` ...@@ -10,6 +10,15 @@ const MultipleDropDownpWrapper = styled.div`
margin-top: 10px; margin-top: 10px;
`; `;
const MultipleDropDownContainerTool = styled.div`
background: #f5f5f7;
span {
position: relative;
left: 5px;
top: 3px;
}
`;
const MultipleDropDownpContainer = styled.div` const MultipleDropDownpContainer = styled.div`
border: 3px solid #f5f5f7; border: 3px solid #f5f5f7;
margin-bottom: 30px; margin-bottom: 30px;
...@@ -21,6 +30,8 @@ export default ({ node, view, getPos }) => { ...@@ -21,6 +30,8 @@ export default ({ node, view, getPos }) => {
pmViews: { main }, pmViews: { main },
} = context; } = context;
const MultipleDropDown = ComponentPlugin('MultipleDropDown');
const customProps = main.props.customValues; const customProps = main.props.customValues;
const isEditable = main.props.editable(editable => { const isEditable = main.props.editable(editable => {
...@@ -32,7 +43,13 @@ export default ({ node, view, getPos }) => { ...@@ -32,7 +43,13 @@ export default ({ node, view, getPos }) => {
return ( return (
<MultipleDropDownpWrapper> <MultipleDropDownpWrapper>
<span>Multiple Drop Down</span> <div>
<span>Multiple Drop Down</span>
<MultipleDropDownContainerTool>
<span> Insert Drop Down :</span>
<MultipleDropDown />
</MultipleDropDownContainerTool>
</div>
<MultipleDropDownpContainer className="multiple-drop-down"> <MultipleDropDownpContainer className="multiple-drop-down">
<ContainerEditor getPos={getPos} node={node} view={view} /> <ContainerEditor getPos={getPos} node={node} view={view} />
{!testMode && ( {!testMode && (
......
import { injectable, inject } from 'inversify';
import { ToolGroup } from 'wax-prosemirror-core';
@injectable()
class MultipleDropDown extends ToolGroup {
tools = [];
constructor(@inject('CreateDropDown') CreateDropDown) {
super();
this.tools = [CreateDropDown];
}
}
export default MultipleDropDown;
import { Service } from 'wax-prosemirror-core';
import MultipleDropDown from './MultipleDropDown';
class MultipleDropDownToolGroupService extends Service {
register() {
this.container.bind('MultipleDropDown').to(MultipleDropDown);
}
}
export default MultipleDropDownToolGroupService;
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