Skip to content

Commit

Permalink
Keep checkboxes as plain text (#149)
Browse files Browse the repository at this point in the history
Keep checkboxes as plain text
  • Loading branch information
juliushaertl committed Jul 10, 2019
2 parents 010ba7e + e16deb0 commit eb155ec
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/EditorFactory.js
Expand Up @@ -120,10 +120,16 @@ const createMarkdownSerializer = (_nodes, _marks) => {
...items,
[name]: toMarkdown
}), {})
return new MarkdownSerializer(
{ ...defaultMarkdownSerializer.nodes, ...nodes },
{ ...defaultMarkdownSerializer.marks, ...marks }
)
return {
serializer: new MarkdownSerializer(
{ ...defaultMarkdownSerializer.nodes, ...nodes },
{ ...defaultMarkdownSerializer.marks, ...marks }
),
serialize: function(content, options) {
return this.serializer.serialize(content, options).split('\\[ \\]').join('[ ]')
.split('\\[x\\]').join('[x]')
}
}
}

const serializePlainText = (tiptap) => {
Expand Down
5 changes: 5 additions & 0 deletions src/tests/markdown.spec.js
Expand Up @@ -78,6 +78,11 @@ describe('Markdown though editor', () => {
test('special characters', () => {
expect(markdownThroughEditor('"\';&.-#><')).toBe('"\';&.-#><')
})
test('checkboxes', () => {
expect(markdownThroughEditor('- [ ] [asd](sdf)')).toBe('* [ ] [asd](sdf)')
expect(markdownThroughEditor('- [x] [asd](sdf)')).toBe('* [x] [asd](sdf)')
expect(markdownThroughEditor('- [ [asd](sdf)')).toBe('* \\[ [asd](sdf)')
})
})

describe('Markdown serializer from html', () => {
Expand Down

0 comments on commit eb155ec

Please sign in to comment.