Skip to content

Commit

Permalink
Merge pull request #6562 from nextcloud/backport/6508/stable29
Browse files Browse the repository at this point in the history
[stable29] Fix(plaintext): multiple linebreaks at end
  • Loading branch information
mejo- authored Dec 10, 2024
2 parents 5f394c6 + 116a483 commit abae069
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/EditorFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,14 @@ const createEditor = ({ language, onCreate = () => {}, onUpdate = () => {}, exte
FocusTrap,
]
} else {
defaultExtensions = [PlainText, CodeBlockLowlight.configure({ lowlight, defaultLanguage: language })]
defaultExtensions = [
PlainText,
CodeBlockLowlight.configure({
lowlight,
defaultLanguage: language,
exitOnTripleEnter: false,
}),
]
}

return new Editor({
Expand Down
13 changes: 13 additions & 0 deletions src/tests/plaintext.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,17 @@ describe('html as plain text', () => {
expect(plaintextThroughEditor('"\';&.-#><')).toBe('"\';&.-#><')
expect(plaintextThroughEditor(xssFuzzVectors)).toBe(xssFuzzVectors)
})
} )

describe('regression tests', () => {
test('tripple enter creates new lines at end (#6507)', () => {
const tiptap = createEditor({
enableRichEditing: false
})
tiptap.commands.enter()
tiptap.commands.enter()
tiptap.commands.enter()
expect(serializePlainText(tiptap.state.doc))
.toEqual("\n\n\n")
})
})

0 comments on commit abae069

Please sign in to comment.