slate-md-serializer 3.1.0 now escapes correctly

This commit is contained in:
Matthew Hodgson 2018-05-23 02:15:34 +01:00
parent 6fba8311f9
commit fc1c4996fc
2 changed files with 2 additions and 10 deletions

View file

@ -86,7 +86,7 @@
"slate": "^0.33.4", "slate": "^0.33.4",
"slate-react": "^0.12.4", "slate-react": "^0.12.4",
"slate-html-serializer": "^0.6.1", "slate-html-serializer": "^0.6.1",
"slate-md-serializer": "^3.0.3", "slate-md-serializer": "^3.1.0",
"sanitize-html": "^1.14.1", "sanitize-html": "^1.14.1",
"text-encoding-utf-8": "^1.0.1", "text-encoding-utf-8": "^1.0.1",
"url": "^0.11.0", "url": "^0.11.0",

View file

@ -178,15 +178,7 @@ export default class MessageComposerInput extends React.Component {
rules: [ rules: [
{ {
serialize: (obj, children) => { serialize: (obj, children) => {
if (obj.object === 'string') { if (obj.object === 'inline') {
// escape any MD in it. i have no idea why the serializer doesn't
// do this already.
// TODO: this can probably be more robust - it doesn't consider
// indenting or lists for instance.
return children.replace(/([*_~`+])/g, '\\$1')
.replace(/^([>#\|])/mg, '\\$1');
}
else if (obj.object === 'inline') {
switch (obj.type) { switch (obj.type) {
case 'pill': case 'pill':
return `[${ obj.data.get('completion') }](${ obj.data.get('href') })`; return `[${ obj.data.get('completion') }](${ obj.data.get('href') })`;