Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/text.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2019-07-10 17:09:40 +0300
committerGitHub <noreply@github.com>2019-07-10 17:09:40 +0300
commiteb155ec1e94f33574d990fb33459b91bce311e18 (patch)
tree4f754f7ba76befddb7fb4653d705bbb74327db32 /src
parent010ba7ec79606303c5c41d263a05242264dd5e11 (diff)
parente16deb0f52780621d2cfb589562db5ea19581ba2 (diff)
Keep checkboxes as plain text (#149)
Keep checkboxes as plain text
Diffstat (limited to 'src')
-rw-r--r--src/EditorFactory.js14
-rw-r--r--src/tests/markdown.spec.js5
2 files changed, 15 insertions, 4 deletions
diff --git a/src/EditorFactory.js b/src/EditorFactory.js
index ec9a8835e..e0cbd3206 100644
--- a/src/EditorFactory.js
+++ b/src/EditorFactory.js
@@ -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) => {
diff --git a/src/tests/markdown.spec.js b/src/tests/markdown.spec.js
index cf011929b..83ed81c5d 100644
--- a/src/tests/markdown.spec.js
+++ b/src/tests/markdown.spec.js
@@ -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', () => {