From c9b9726eccadc9fa2c9bb015938ae3ebb5726757 Mon Sep 17 00:00:00 2001 From: chris <kokosias@yahoo.gr> Date: Thu, 30 Sep 2021 17:10:10 +0300 Subject: [PATCH] add create tool and service --- .../CreateGapService/CreateGap.js | 25 ++++++++++++++++ .../CreateGapService/CreateGapService.js | 10 +++++++ .../FillTheGapQuestion.js | 2 +- .../FillTheGapQuestionService.js | 2 ++ .../FillTheGapToolGroupService/FillTheGap.js | 7 +++-- .../demo/src/HHMI/layout/EditorElements.js | 29 +++++++++++++++++++ .../src/BaseService/BaseService.js | 4 +-- .../InlineAnnotationsService.js | 4 +-- .../src/ListsService/ListsService.js | 4 +-- .../src/TablesService/TablesService.js | 4 +-- .../TextBlockLevel/TextBlockLevelService.js | 4 +-- 11 files changed, 82 insertions(+), 13 deletions(-) create mode 100644 editors/demo/src/HHMI/FillTheGapQuestionService/CreateGapService/CreateGap.js create mode 100644 editors/demo/src/HHMI/FillTheGapQuestionService/CreateGapService/CreateGapService.js diff --git a/editors/demo/src/HHMI/FillTheGapQuestionService/CreateGapService/CreateGap.js b/editors/demo/src/HHMI/FillTheGapQuestionService/CreateGapService/CreateGap.js new file mode 100644 index 000000000..35d40e082 --- /dev/null +++ b/editors/demo/src/HHMI/FillTheGapQuestionService/CreateGapService/CreateGap.js @@ -0,0 +1,25 @@ +import { injectable } from 'inversify'; +import { Tools } from 'wax-prosemirror-services'; + +@injectable() +class CreateGap extends Tools { + title = 'Create Gap Option'; + label = 'Create Gap'; + name = 'Create Gap'; + + get run() { + return (state, dispatch) => {}; + } + + get active() { + return state => {}; + } + + select = (state, activeViewId) => {}; + + get enable() { + return state => {}; + } +} + +export default CreateGap; diff --git a/editors/demo/src/HHMI/FillTheGapQuestionService/CreateGapService/CreateGapService.js b/editors/demo/src/HHMI/FillTheGapQuestionService/CreateGapService/CreateGapService.js new file mode 100644 index 000000000..02083ffd0 --- /dev/null +++ b/editors/demo/src/HHMI/FillTheGapQuestionService/CreateGapService/CreateGapService.js @@ -0,0 +1,10 @@ +import { Service } from 'wax-prosemirror-services'; +import CreateGap from './CreateGap'; + +class FillTheGapQuestionService extends Service { + register() { + this.container.bind('CreateGap').to(CreateGap); + } +} + +export default FillTheGapQuestionService; diff --git a/editors/demo/src/HHMI/FillTheGapQuestionService/FillTheGapQuestion.js b/editors/demo/src/HHMI/FillTheGapQuestionService/FillTheGapQuestion.js index 18449bebd..d8be5076e 100644 --- a/editors/demo/src/HHMI/FillTheGapQuestionService/FillTheGapQuestion.js +++ b/editors/demo/src/HHMI/FillTheGapQuestionService/FillTheGapQuestion.js @@ -1,7 +1,7 @@ import { injectable } from 'inversify'; import { wrapIn } from 'prosemirror-commands'; - import { Tools } from 'wax-prosemirror-services'; + @injectable() class FillTheGapQuestion extends Tools { title = 'Add Fill The Gap Question'; diff --git a/editors/demo/src/HHMI/FillTheGapQuestionService/FillTheGapQuestionService.js b/editors/demo/src/HHMI/FillTheGapQuestionService/FillTheGapQuestionService.js index 49d73887d..60612d55d 100644 --- a/editors/demo/src/HHMI/FillTheGapQuestionService/FillTheGapQuestionService.js +++ b/editors/demo/src/HHMI/FillTheGapQuestionService/FillTheGapQuestionService.js @@ -2,6 +2,7 @@ import { Service } from 'wax-prosemirror-services'; import FillTheGapQuestion from './FillTheGapQuestion'; import fillTheGapContainerNode from './schema/fillTheGapContainerNode'; import fillTheGapNode from './schema/fillTheGapNode'; +import CreateGapService from './CreateGapService/CreateGapService'; class FillTheGapQuestionService extends Service { register() { @@ -13,6 +14,7 @@ class FillTheGapQuestionService extends Service { fill_the_gap_container: fillTheGapContainerNode, }); } + dependencies = [new CreateGapService()]; } export default FillTheGapQuestionService; diff --git a/editors/demo/src/HHMI/FillTheGapToolGroupService/FillTheGap.js b/editors/demo/src/HHMI/FillTheGapToolGroupService/FillTheGap.js index 40220ac4c..6318c164e 100644 --- a/editors/demo/src/HHMI/FillTheGapToolGroupService/FillTheGap.js +++ b/editors/demo/src/HHMI/FillTheGapToolGroupService/FillTheGap.js @@ -4,9 +4,12 @@ import { ToolGroup } from 'wax-prosemirror-services'; @injectable() class FillTheGap extends ToolGroup { tools = []; - constructor(@inject('FillTheGapQuestion') FillTheGapQuestion) { + constructor( + @inject('FillTheGapQuestion') FillTheGapQuestion, + @inject('CreateGap') CreateGap, + ) { super(); - this.tools = [FillTheGapQuestion]; + this.tools = [FillTheGapQuestion, CreateGap]; } } diff --git a/editors/demo/src/HHMI/layout/EditorElements.js b/editors/demo/src/HHMI/layout/EditorElements.js index 87ac8cb98..f25b22af6 100644 --- a/editors/demo/src/HHMI/layout/EditorElements.js +++ b/editors/demo/src/HHMI/layout/EditorElements.js @@ -345,4 +345,33 @@ export default css` padding: 5px 5px 0 5px; } } + + /* -- Fill The Gap ---------------------------------- */ + + .fill-the-gap { + border: 3px solid #f5f5f7; + margin-bottom: 30px; + margin-top: 30px; + padding: 3px; + + &:before { + background-color: #fff; + bottom: 22px; + color: #535e76; + content: 'Fill The Gap'; + height: 10px; + left: -1px; + position: relative; + width: 30px; + } + + p { + bottom: 22px; + position: relative; + } + + p:last-child { + margin-bottom: -1em; + } + } `; diff --git a/wax-prosemirror-services/src/BaseService/BaseService.js b/wax-prosemirror-services/src/BaseService/BaseService.js index f19184172..83525bb3e 100644 --- a/wax-prosemirror-services/src/BaseService/BaseService.js +++ b/wax-prosemirror-services/src/BaseService/BaseService.js @@ -1,5 +1,5 @@ -import Service from "../Service"; -import BaseServices from "./index"; +import Service from '../Service'; +import BaseServices from './index'; class BaseService extends Service { dependencies = BaseServices; diff --git a/wax-prosemirror-services/src/InlineAnnotations/InlineAnnotationsService.js b/wax-prosemirror-services/src/InlineAnnotations/InlineAnnotationsService.js index 76e753be9..ddf4f112b 100644 --- a/wax-prosemirror-services/src/InlineAnnotations/InlineAnnotationsService.js +++ b/wax-prosemirror-services/src/InlineAnnotations/InlineAnnotationsService.js @@ -1,5 +1,5 @@ -import Service from "../Service"; -import InlineServices from "./index"; +import Service from '../Service'; +import InlineServices from './index'; class InlineAnnotationsService extends Service { dependencies = InlineServices; diff --git a/wax-prosemirror-services/src/ListsService/ListsService.js b/wax-prosemirror-services/src/ListsService/ListsService.js index 3e1fd3507..4a87bf910 100644 --- a/wax-prosemirror-services/src/ListsService/ListsService.js +++ b/wax-prosemirror-services/src/ListsService/ListsService.js @@ -1,5 +1,5 @@ -import Service from "../Service"; -import ListsServices from "./index"; +import Service from '../Service'; +import ListsServices from './index'; class ListsService extends Service { dependencies = ListsServices; diff --git a/wax-prosemirror-services/src/TablesService/TablesService.js b/wax-prosemirror-services/src/TablesService/TablesService.js index 1172660ad..ceef94284 100644 --- a/wax-prosemirror-services/src/TablesService/TablesService.js +++ b/wax-prosemirror-services/src/TablesService/TablesService.js @@ -1,5 +1,5 @@ -import Service from "../Service"; -import TablesServices from "./index"; +import Service from '../Service'; +import TablesServices from './index'; class TablesService extends Service { dependencies = TablesServices; diff --git a/wax-prosemirror-services/src/TextBlockLevel/TextBlockLevelService.js b/wax-prosemirror-services/src/TextBlockLevel/TextBlockLevelService.js index 756956f3c..e19aa29a9 100644 --- a/wax-prosemirror-services/src/TextBlockLevel/TextBlockLevelService.js +++ b/wax-prosemirror-services/src/TextBlockLevel/TextBlockLevelService.js @@ -1,5 +1,5 @@ -import Service from "../Service"; -import TextServices from "./index"; +import Service from '../Service'; +import TextServices from './index'; class TextBlockLevelService extends Service { dependencies = TextServices; -- GitLab