diff --git a/src/extensions/Mention.js b/src/extensions/Mention.js
index 5f5fdffe6c7..792b754c8e1 100644
--- a/src/extensions/Mention.js
+++ b/src/extensions/Mention.js
@@ -40,8 +40,6 @@ export default TipTapMention.extend({
},
toMarkdown(state, node) {
- state.write(' ')
state.write(`@[${node.attrs.label}](mention://user/${encodeURIComponent(node.attrs.id)})`)
- state.write(' ')
},
})
diff --git a/src/tests/markdown.spec.js b/src/tests/markdown.spec.js
index 931c4d680e9..b14897afe99 100644
--- a/src/tests/markdown.spec.js
+++ b/src/tests/markdown.spec.js
@@ -124,7 +124,8 @@ describe('Markdown though editor', () => {
})
test('mentions', () => {
- expect(markdownThroughEditor('@[username](mention://user/id)')).toBe(' @[username](mention://user/id) ')
+ expect(markdownThroughEditor('@[username](mention://user/id)')).toBe('@[username](mention://user/id)')
+ expect(markdownThroughEditor('pretext @[username](mention://user/id) posttext')).toBe('pretext @[username](mention://user/id) posttext')
})
})
@@ -187,8 +188,9 @@ describe('Markdown serializer from html', () => {
})
test('mentions', () => {
- expect(markdownThroughEditorHtml('username')).toBe(' @[username](mention://user/id) ')
- expect(markdownThroughEditorHtml('whitespace user')).toBe(' @[whitespace user](mention://user/whitespace%20user) ')
+ expect(markdownThroughEditorHtml('username')).toBe('@[username](mention://user/id)')
+ expect(markdownThroughEditorHtml('whitespace user')).toBe('@[whitespace user](mention://user/whitespace%20user)')
+ expect(markdownThroughEditorHtml('pretext username posttext')).toBe('pretext @[username](mention://user/id) posttext')
})
})