diff --git a/src/composables/useEditorMethods.ts b/src/composables/useEditorMethods.ts index bba464f1fed..2c08bf41cc4 100644 --- a/src/composables/useEditorMethods.ts +++ b/src/composables/useEditorMethods.ts @@ -25,7 +25,7 @@ export const useEditorMethods = (editor: Editor) => { editor.extensionManager.extensions.includes(Markdown) const html = hasMarkdownContent ? markdownit.render(content) + '
' - : `${escapeHtml(content)}`
+ : `\n${escapeHtml(content)}`
editor
.chain()
.setContent(html, { emitUpdate: addToHistory })
diff --git a/src/helpers/setInitialYjsState.ts b/src/helpers/setInitialYjsState.ts
index 7a9e79ae22d..b8a5cf0f08f 100644
--- a/src/helpers/setInitialYjsState.ts
+++ b/src/helpers/setInitialYjsState.ts
@@ -17,7 +17,7 @@ export const setInitialYjsState = (
) => {
const html = isRichEditor
? markdownit.render(content) + ''
- : `${escapeHtml(content)}`
+ : `\n${escapeHtml(content)}`
const editor = isRichEditor ? createRichEditor() : createPlainEditor()
editor.commands.setContent(html)
diff --git a/src/helpers/updateFromContent.ts b/src/helpers/updateFromContent.ts
index 371253b6d89..1632de12a3b 100644
--- a/src/helpers/updateFromContent.ts
+++ b/src/helpers/updateFromContent.ts
@@ -30,7 +30,7 @@ const setContent = (
) => {
const html = isRichEditor
? markdownit.render(content) + ''
- : `${escapeHtml(content)}`
+ : `\n${escapeHtml(content)}`
const editor = isRichEditor
? createRichEditor({
extensions: [Collaboration.configure({ document: doc })],
diff --git a/src/tests/plaintext.spec.js b/src/tests/plaintext.spec.js
index 2329bea4220..0b9fabf0026 100644
--- a/src/tests/plaintext.spec.js
+++ b/src/tests/plaintext.spec.js
@@ -18,7 +18,7 @@ const escapeHTML = (s) => {
}
const plaintextThroughEditor = (markdown) => {
- const content = '' + escapeHTML(markdown) + '' + const content = '
\n' + escapeHTML(markdown) + '' const tiptap = createPlainEditor() tiptap.commands.setContent(content) const plaintext = serializePlainText(tiptap.state.doc) || 'failed' @@ -27,14 +27,7 @@ const plaintextThroughEditor = (markdown) => { } describe('commonmark as plaintext', () => { - // FIXME: Those two tests currently fail as trailing whitespace seems to be stripped, - // if it occurs in the first line which is empty otherwise. - const skippedMarkdownTests = [97, 117] - spec.forEach((entry) => { - if (skippedMarkdownTests.indexOf(entry.example) !== -1) { - return - } test('commonmark ' + entry.example, () => { expect(plaintextThroughEditor(entry.markdown)).toBe(entry.markdown) })