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 e80d2112817..6f1b6258a01 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')
})
test('details', () => {
@@ -197,8 +198,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')
})
test('details', () => {