From 1ed207a058fb32cc43faa5f25aae5ef26593e442 Mon Sep 17 00:00:00 2001 From: chris <kokosias@yahoo.gr> Date: Thu, 16 Sep 2021 12:45:33 +0300 Subject: [PATCH] main service file --- .../FillTheGapQuestionService.js | 10 +++++++ .../MultipleChoiceQuestionService.js | 29 ++----------------- .../schema/multipleChoiceContainerNode.js | 25 ++++++++++++++++ 3 files changed, 38 insertions(+), 26 deletions(-) create mode 100644 editors/demo/src/HHMI/FillTheGapQuestionService/FillTheGapQuestionService.js create mode 100644 editors/demo/src/HHMI/MultipleChoiceQuestionService/schema/multipleChoiceContainerNode.js diff --git a/editors/demo/src/HHMI/FillTheGapQuestionService/FillTheGapQuestionService.js b/editors/demo/src/HHMI/FillTheGapQuestionService/FillTheGapQuestionService.js new file mode 100644 index 000000000..dc8a934a4 --- /dev/null +++ b/editors/demo/src/HHMI/FillTheGapQuestionService/FillTheGapQuestionService.js @@ -0,0 +1,10 @@ +import { Service } from 'wax-prosemirror-services'; + +class FillTheGapQuestionService extends Service { + register() { + const createNode = this.container.get('CreateNode'); + const addPortal = this.container.get('AddPortal'); + } +} + +export default FillTheGapQuestionService; diff --git a/editors/demo/src/HHMI/MultipleChoiceQuestionService/MultipleChoiceQuestionService.js b/editors/demo/src/HHMI/MultipleChoiceQuestionService/MultipleChoiceQuestionService.js index af4260c29..1101b7e12 100644 --- a/editors/demo/src/HHMI/MultipleChoiceQuestionService/MultipleChoiceQuestionService.js +++ b/editors/demo/src/HHMI/MultipleChoiceQuestionService/MultipleChoiceQuestionService.js @@ -1,47 +1,24 @@ import { Service } from 'wax-prosemirror-services'; import MultipleChoiceQuestion from './MultipleChoiceQuestion'; import multipleChoiceNode from './schema/multipleChoiceNode'; +import multipleChoiceContainerNode from './schema/multipleChoiceContainerNode'; import QuestionComponent from './components/QuestionComponent'; import MultipleChoiceNodeView from './MultipleChoiceNodeView'; class MultipleChoiceQuestionService extends Service { - boot() {} - register() { this.container.bind('MultipleChoiceQuestion').to(MultipleChoiceQuestion); const createNode = this.container.get('CreateNode'); + const addPortal = this.container.get('AddPortal'); createNode({ multiple_choice: multipleChoiceNode, }); createNode({ - multiple_choice_container: { - attrs: { - id: { default: '' }, - class: { default: 'mutiple-choice' }, - }, - group: 'block', - atom: true, - content: 'block+', - parseDOM: [ - { - tag: 'div.mutiple-choice', - getAttrs(dom) { - return { - id: dom.dataset.id, - class: dom.getAttribute('class'), - }; - }, - }, - ], - toDOM(node) { - return ['div', node.attrs, 0]; - }, - }, + multiple_choice_container: multipleChoiceContainerNode, }); - const addPortal = this.container.get('AddPortal'); addPortal({ nodeView: MultipleChoiceNodeView, component: QuestionComponent, diff --git a/editors/demo/src/HHMI/MultipleChoiceQuestionService/schema/multipleChoiceContainerNode.js b/editors/demo/src/HHMI/MultipleChoiceQuestionService/schema/multipleChoiceContainerNode.js new file mode 100644 index 000000000..e63cf2aab --- /dev/null +++ b/editors/demo/src/HHMI/MultipleChoiceQuestionService/schema/multipleChoiceContainerNode.js @@ -0,0 +1,25 @@ +const multipleChoiceContainerNode = { + attrs: { + id: { default: '' }, + class: { default: 'mutiple-choice' }, + }, + group: 'block', + atom: true, + content: 'block+', + parseDOM: [ + { + tag: 'div.mutiple-choice', + getAttrs(dom) { + return { + id: dom.dataset.id, + class: dom.getAttribute('class'), + }; + }, + }, + ], + toDOM(node) { + return ['div', node.attrs, 0]; + }, +}; + +export default multipleChoiceContainerNode; -- GitLab