From 38352e9e3c558dd3a2c2c04e55c00b6b56d0261c Mon Sep 17 00:00:00 2001 From: okbel Date: Wed, 21 Feb 2018 16:59:02 -0300 Subject: [PATCH] Using metadata to store html comment --- plugins/talk-plugin-rte/server/hooks.js | 11 +++++++---- plugins/talk-plugin-rte/server/resolvers.js | 4 +--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/plugins/talk-plugin-rte/server/hooks.js b/plugins/talk-plugin-rte/server/hooks.js index 359c15788..a7633fb1e 100644 --- a/plugins/talk-plugin-rte/server/hooks.js +++ b/plugins/talk-plugin-rte/server/hooks.js @@ -1,12 +1,15 @@ -const TurndownService = require('turndown'); +const { merge } = require('lodash'); module.exports = { RootMutation: { createComment: { async pre(_, { input }, _context, _info) { - // Saving the HTML comment as Markdown - const ts = new TurndownService(); - input.body = ts.turndown(input.body); + input.metadata = merge( + {}, + { + htmlBody: input.htmlBody, + } + ); }, }, }, diff --git a/plugins/talk-plugin-rte/server/resolvers.js b/plugins/talk-plugin-rte/server/resolvers.js index 71cf7cfbc..015f39cb9 100644 --- a/plugins/talk-plugin-rte/server/resolvers.js +++ b/plugins/talk-plugin-rte/server/resolvers.js @@ -1,7 +1,5 @@ -const marked = require('marked'); - module.exports = { Comment: { - body: comment => marked(comment.body), + htmlBody: comment => comment.metadata.htmlBody, }, };