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

nodeview plus schema files

parent e9994e7b
No related branches found
No related tags found
1 merge request!387Short cuts
...@@ -70,7 +70,7 @@ const Editors = () => { ...@@ -70,7 +70,7 @@ const Editors = () => {
case 'ncbi': case 'ncbi':
return <NCBI />; return <NCBI />;
default: default:
return <Editoria />; return <HHMI />;
} }
}; };
......
...@@ -27,6 +27,8 @@ import { ...@@ -27,6 +27,8 @@ import {
MultipleDropDownToolGroupService, MultipleDropDownToolGroupService,
EssayService, EssayService,
EssayToolGroupService, EssayToolGroupService,
MatchingService,
MatchingToolGroupService,
} from 'wax-prosemirror-services'; } from 'wax-prosemirror-services';
import { DefaultSchema } from 'wax-prosemirror-utilities'; import { DefaultSchema } from 'wax-prosemirror-utilities';
...@@ -55,6 +57,7 @@ export default { ...@@ -55,6 +57,7 @@ export default {
'MultipleDropDown', 'MultipleDropDown',
'Essay', 'Essay',
'FillTheGap', 'FillTheGap',
'Matching',
'FullScreen', 'FullScreen',
], ],
}, },
...@@ -66,6 +69,8 @@ export default { ...@@ -66,6 +69,8 @@ export default {
PmPlugins: [columnResizing(), tableEditing(), invisibles([hardBreak()])], PmPlugins: [columnResizing(), tableEditing(), invisibles([hardBreak()])],
services: [ services: [
new MatchingService(),
new MatchingToolGroupService(),
new FillTheGapQuestionService(), new FillTheGapQuestionService(),
new FillTheGapToolGroupService(), new FillTheGapToolGroupService(),
new MultipleChoiceQuestionService(), new MultipleChoiceQuestionService(),
......
...@@ -48,7 +48,7 @@ const TopMenu = styled.div` ...@@ -48,7 +48,7 @@ const TopMenu = styled.div`
margin-right: ${grid(5)}; margin-right: ${grid(5)};
} }
> div[data-name='FillTheGap'] { > div[data-name='Matching'] {
border-right: none; border-right: none;
} }
`; `;
......
import QuestionsNodeView from '../lib/helpers/QuestionsNodeView';
export default class MatchingContainerNodeView extends QuestionsNodeView {
constructor(
node,
view,
getPos,
decorations,
createPortal,
Component,
context,
) {
super(node, view, getPos, decorations, createPortal, Component, context);
this.node = node;
this.outerView = view;
this.getPos = getPos;
this.context = context;
}
static name() {
return 'matching_container';
}
stopEvent(event) {
if (event.target.type === 'text') {
return true;
}
const innerView = this.context.pmViews[this.node.attrs.id];
return innerView && innerView.dom.contains(event.target);
}
}
...@@ -3,9 +3,9 @@ import Tools from '../lib/Tools'; ...@@ -3,9 +3,9 @@ import Tools from '../lib/Tools';
@injectable() @injectable()
class MatchingQuestion extends Tools { class MatchingQuestion extends Tools {
title = 'Change to Block Quote'; title = 'Add Matching';
label = 'Block Quote'; label = 'Matching';
name = 'BlockQuote'; name = 'Matching';
get run() { get run() {
return (state, dispatch) => {}; return (state, dispatch) => {};
......
import Service from '../Service'; import Service from '../Service';
import MatchingQuestion from './MatchingQuestion'; import MatchingQuestion from './MatchingQuestion';
import matchingContainerNode from './schema/matchingContainerNode';
import MatchingContainerNodeView from './MatchingContainerNodeView';
class MatchingService extends Service { class MatchingService extends Service {
name = 'MatchingService'; name = 'MatchingService';
boot() {}
register() { register() {
this.container.bind('MatchingQuestion').to(MatchingQuestion); this.container.bind('MatchingQuestion').to(MatchingQuestion);
const createNode = this.container.get('CreateNode');
const addPortal = this.container.get('AddPortal');
createNode({
matching_container: matchingContainerNode,
});
// addPortal({
// nodeView: MatchingContainerNodeView,
// component: QuestionComponent,
// context: this.app,
// });
} }
} }
......
const matchingContainerNode = {
attrs: {
id: { default: '' },
class: { default: 'matching-container' },
},
group: 'block questions',
atom: true,
content: 'block*',
parseDOM: [
{
tag: 'div.matching-container',
getAttrs(dom) {
return {
id: dom.getAttribute('id'),
class: dom.getAttribute('class'),
};
},
},
],
toDOM(node) {
return ['div', node.attrs, 0];
},
};
export default matchingContainerNode;
...@@ -4,9 +4,9 @@ import ToolGroup from '../../lib/ToolGroup'; ...@@ -4,9 +4,9 @@ import ToolGroup from '../../lib/ToolGroup';
@injectable() @injectable()
class Matching extends ToolGroup { class Matching extends ToolGroup {
tools = []; tools = [];
constructor() { constructor(@inject('MatchingQuestion') matchingQuestion) {
super(); super();
this.tools = []; this.tools = [matchingQuestion];
} }
} }
......
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