From 6f1490ec08cf954787d334b36137ef1923a3658e Mon Sep 17 00:00:00 2001 From: Jonas Date: Wed, 4 Sep 2024 18:09:49 +0200 Subject: [PATCH] fix(mention): No extra whitespace in markdown before/after mentions Fixes: #6314 Signed-off-by: Jonas --- src/extensions/Mention.js | 2 -- src/tests/markdown.spec.js | 8 +++++--- 2 files changed, 5 insertions(+), 5 deletions(-) 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') }) })