mirror of
https://github.com/wassname/talk.git
synced 2026-07-31 12:50:48 +08:00
Support for both htmlBody and original body
This commit is contained in:
@@ -16,7 +16,11 @@ class Editor extends React.Component {
|
||||
|
||||
init({
|
||||
element: this.ref,
|
||||
onChange: html => onChange(html),
|
||||
onChange: htmlBody => {
|
||||
// We want to save the original comment body
|
||||
const originalBody = this.ref.childNodes[1].innerText;
|
||||
onChange(originalBody, { htmlBody });
|
||||
},
|
||||
actions,
|
||||
classes: {
|
||||
actionbar: cn(
|
||||
|
||||
@@ -1 +1,13 @@
|
||||
module.exports = {};
|
||||
const { readFileSync } = require('fs');
|
||||
const path = require('path');
|
||||
const hooks = require('./server/hooks');
|
||||
const resolvers = require('./server/resolvers');
|
||||
|
||||
module.exports = {
|
||||
typeDefs: readFileSync(
|
||||
path.join(__dirname, 'server/typeDefs.graphql'),
|
||||
'utf8'
|
||||
),
|
||||
hooks,
|
||||
resolvers,
|
||||
};
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
"author": "The Coral Project Team <coral@mozillafoundation.org>",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"marked": "^0.3.16",
|
||||
"pell": "^0.7.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
const TurndownService = require('turndown');
|
||||
|
||||
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);
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
const marked = require('marked');
|
||||
|
||||
module.exports = {
|
||||
Comment: {
|
||||
body: comment => marked(comment.body),
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
input CreateCommentInput {
|
||||
htmlBody: String
|
||||
}
|
||||
|
||||
type Comment {
|
||||
htmlBody: String
|
||||
}
|
||||
@@ -2,6 +2,10 @@
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
marked@^0.3.16:
|
||||
version "0.3.16"
|
||||
resolved "https://registry.yarnpkg.com/marked/-/marked-0.3.16.tgz#2f188b7dfcfa6540fe9940adaf0f3b791c9a5cba"
|
||||
|
||||
pell@^0.7.0:
|
||||
version "0.7.0"
|
||||
resolved "https://registry.yarnpkg.com/pell/-/pell-0.7.0.tgz#46b3fcdfa8dd7e5999f73c550a337ecc80193dcc"
|
||||
|
||||
Reference in New Issue
Block a user