diff --git a/src/components/Editor.vue b/src/components/Editor.vue index ae3a0aa6047..00ebe86fed2 100644 --- a/src/components/Editor.vue +++ b/src/components/Editor.vue @@ -700,7 +700,7 @@ export default { * @param {object} editor The Tiptap editor */ debugContent(editor) { - const proseMirrorMarkdown = this.$syncService.options.serialize(editor.state.doc) + const proseMirrorMarkdown = this.$syncService.serialize(editor.state.doc) const markdownItHtml = markdownit.render(proseMirrorMarkdown) logger.debug('markdown, serialized from editor state by prosemirror-markdown') diff --git a/src/extensions/Mention.js b/src/extensions/Mention.js index 8f9e6b59386..9afd3729eaa 100644 --- a/src/extensions/Mention.js +++ b/src/extensions/Mention.js @@ -10,7 +10,7 @@ export default TipTapMention.extend({ tag: 'span[data-type="user"]', getAttrs: element => { return { - id: element.getAttribute('data-id'), + id: decodeURIComponent(element.getAttribute('data-id')), label: element.innerText || element.textContent || element.getAttribute('data-label'), } }, @@ -36,7 +36,7 @@ export default TipTapMention.extend({ toMarkdown(state, node) { state.write(' ') - state.write(`@[${node.attrs.label}](mention://user/${node.attrs.id})`) + 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 ca6fbc12e2a..61c6375dc51 100644 --- a/src/tests/markdown.spec.js +++ b/src/tests/markdown.spec.js @@ -221,6 +221,7 @@ 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) ') }) }) diff --git a/src/tests/markdownit.spec.js b/src/tests/markdownit.spec.js index 90c73d3524a..3d6cc8178e3 100644 --- a/src/tests/markdownit.spec.js +++ b/src/tests/markdownit.spec.js @@ -39,8 +39,15 @@ describe('markdownit', () => {
whitespace user
` + )) }) describe('callouts', () => {