From 26c87c1925b8cc2b35614a6d374302974f00f711 Mon Sep 17 00:00:00 2001 From: chris <kokosias@yahoo.gr> Date: Wed, 15 Sep 2021 12:10:35 +0300 Subject: [PATCH] render wrapper element for inline --- editors/demo/src/Editors.js | 2 +- .../HHMI/FillTheGapToolGroupService/FillTheGap.js | 13 +++++++++++++ .../FillTheGapToolGroupService.js | 10 ++++++++++ .../QuestionsToolGroupService.js | 2 -- .../src/PortalService/AbstractNodeView.js | 9 ++++++++- 5 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 editors/demo/src/HHMI/FillTheGapToolGroupService/FillTheGap.js create mode 100644 editors/demo/src/HHMI/FillTheGapToolGroupService/FillTheGapToolGroupService.js diff --git a/editors/demo/src/Editors.js b/editors/demo/src/Editors.js index fa52e3550..977ed5cc4 100644 --- a/editors/demo/src/Editors.js +++ b/editors/demo/src/Editors.js @@ -54,7 +54,7 @@ const Editors = () => { case 'ncbi': break; default: - return <Editoria />; + return <HHMI />; } }; diff --git a/editors/demo/src/HHMI/FillTheGapToolGroupService/FillTheGap.js b/editors/demo/src/HHMI/FillTheGapToolGroupService/FillTheGap.js new file mode 100644 index 000000000..40220ac4c --- /dev/null +++ b/editors/demo/src/HHMI/FillTheGapToolGroupService/FillTheGap.js @@ -0,0 +1,13 @@ +import { injectable, inject } from 'inversify'; +import { ToolGroup } from 'wax-prosemirror-services'; + +@injectable() +class FillTheGap extends ToolGroup { + tools = []; + constructor(@inject('FillTheGapQuestion') FillTheGapQuestion) { + super(); + this.tools = [FillTheGapQuestion]; + } +} + +export default FillTheGap; diff --git a/editors/demo/src/HHMI/FillTheGapToolGroupService/FillTheGapToolGroupService.js b/editors/demo/src/HHMI/FillTheGapToolGroupService/FillTheGapToolGroupService.js new file mode 100644 index 000000000..2aae43e05 --- /dev/null +++ b/editors/demo/src/HHMI/FillTheGapToolGroupService/FillTheGapToolGroupService.js @@ -0,0 +1,10 @@ +import { Service } from 'wax-prosemirror-services'; +import FillTheGap from './FillTheGap'; + +class FillTheGapToolGroupService extends Service { + register() { + this.container.bind('FillTheGap').to(FillTheGap); + } +} + +export default FillTheGapToolGroupService; diff --git a/editors/demo/src/HHMI/QuestionsToolGroupService/QuestionsToolGroupService.js b/editors/demo/src/HHMI/QuestionsToolGroupService/QuestionsToolGroupService.js index 972dfbaed..daaed80e7 100644 --- a/editors/demo/src/HHMI/QuestionsToolGroupService/QuestionsToolGroupService.js +++ b/editors/demo/src/HHMI/QuestionsToolGroupService/QuestionsToolGroupService.js @@ -2,8 +2,6 @@ import { Service } from 'wax-prosemirror-services'; import Questions from './Questions'; class QuestionsToolGroupService extends Service { - boot() {} - register() { this.container.bind('Questions').to(Questions); } diff --git a/wax-prosemirror-services/src/PortalService/AbstractNodeView.js b/wax-prosemirror-services/src/PortalService/AbstractNodeView.js index d51b293b3..43539bc90 100644 --- a/wax-prosemirror-services/src/PortalService/AbstractNodeView.js +++ b/wax-prosemirror-services/src/PortalService/AbstractNodeView.js @@ -11,7 +11,9 @@ export default class AbstractNodeView { Component, context, ) { - this.dom = document.createElement('div'); + this.dom = node.type.spec.inline + ? document.createElement('span') + : document.createElement('div'); this.dom.id = uuidv4(); this.dom.classList.add('portal'); this.node = node; @@ -23,6 +25,7 @@ export default class AbstractNodeView { } update(node) { + if (node.type !== this.node.type) return false; if (!node.sameMarkup(this.node)) return false; this.node = node; if (this.context.view[node.attrs.id]) { @@ -59,4 +62,8 @@ export default class AbstractNodeView { ignoreMutation() { return true; } + + selectNode() {} + + deselectNode() {} } -- GitLab