From 559f268c6e4f014d735032731d361c181a256105 Mon Sep 17 00:00:00 2001 From: chris <kokosias@yahoo.gr> Date: Wed, 13 May 2020 18:29:35 +0300 Subject: [PATCH] fix: always wrap into comment or link inner marks --- editors/editoria/src/config/config.js | 8 +++-- .../src/marks/commentMark.js | 34 +++++++++++-------- .../src/CommentsService/CommentsService.js | 9 +++-- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/editors/editoria/src/config/config.js b/editors/editoria/src/config/config.js index 08f4a99e4..1e332ab95 100644 --- a/editors/editoria/src/config/config.js +++ b/editors/editoria/src/config/config.js @@ -56,12 +56,15 @@ export default { PmPlugins: [columnResizing(), tableEditing(), invisibles([hardBreak()])], + // Always load first CommentsService and LinkService, + //as it matters on how PM treats nodes and marks services: [ + new CommentsService(), + new LinkService(), new PlaceholderService(), new ImageService(), new ListsService(), new InlineAnnotationsService(), - new LinkService(), new TablesService(), new TextBlockLevelService(), new BaseService(), @@ -75,7 +78,6 @@ export default { new AnnotationToolGroupService(), new NoteToolGroupService(), new ListToolGroupService(), - new TrackChangeService(), - new CommentsService() + new TrackChangeService() ] }; diff --git a/wax-prosemirror-schema/src/marks/commentMark.js b/wax-prosemirror-schema/src/marks/commentMark.js index e297644dd..3e46d3b2a 100644 --- a/wax-prosemirror-schema/src/marks/commentMark.js +++ b/wax-prosemirror-schema/src/marks/commentMark.js @@ -1,33 +1,37 @@ const comment = { attrs: { + class: { default: "comment" }, id: { default: "" }, group: { default: "" }, conversation: [] }, inclusive: false, - // excludes: "", parseDOM: [ { - tag: "span.comment[data-conversation]", - getAttrs(dom) { - return { - id: dom.dataset.id, - group: dom.dataset.group, - conversation: JSON.parse(dom.dataset.conversation) - }; + tag: "span.comment", + getAttrs(hook, next) { + Object.assign(hook, { + class: hook.dom.getAttribute("class"), + id: hook.dom.dataset.id, + group: hook.dom.dataset.group, + conversation: hook.dom.dataset.conversation + }); + next(); } } ], - toDOM(node) { - return [ + toDOM(hook, next) { + hook.value = [ "span", { - class: "comment", - "data-id": node.attrs.id, - "data-group": node.attrs.group, - "data-conversation": JSON.stringify(node.attrs.conversation) - } + class: hook.node.attrs.class, + "data-id": hook.node.attrs.id, + "data-track": JSON.stringify(hook.node.attrs.track), + "data-group": hook.node.attrs.group + }, + 0 ]; + next(); } }; diff --git a/wax-prosemirror-services/src/CommentsService/CommentsService.js b/wax-prosemirror-services/src/CommentsService/CommentsService.js index 96d9ef630..1a3525516 100644 --- a/wax-prosemirror-services/src/CommentsService/CommentsService.js +++ b/wax-prosemirror-services/src/CommentsService/CommentsService.js @@ -29,8 +29,11 @@ export default class CommentsService extends Service { register() { const createMark = this.container.get("CreateMark"); - createMark({ - comment: commentMark - }); + createMark( + { + comment: commentMark + }, + { toWaxSchema: true } + ); } } -- GitLab