Skip to content

Commit abae069

Browse files
authored
Merge pull request #6562 from nextcloud/backport/6508/stable29
[stable29] Fix(plaintext): multiple linebreaks at end
2 parents 5f394c6 + 116a483 commit abae069

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

src/EditorFactory.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,14 @@ const createEditor = ({ language, onCreate = () => {}, onUpdate = () => {}, exte
6868
FocusTrap,
6969
]
7070
} else {
71-
defaultExtensions = [PlainText, CodeBlockLowlight.configure({ lowlight, defaultLanguage: language })]
71+
defaultExtensions = [
72+
PlainText,
73+
CodeBlockLowlight.configure({
74+
lowlight,
75+
defaultLanguage: language,
76+
exitOnTripleEnter: false,
77+
}),
78+
]
7279
}
7380

7481
return new Editor({

src/tests/plaintext.spec.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,17 @@ describe('html as plain text', () => {
7979
expect(plaintextThroughEditor('"\';&.-#><')).toBe('"\';&.-#><')
8080
expect(plaintextThroughEditor(xssFuzzVectors)).toBe(xssFuzzVectors)
8181
})
82+
} )
83+
84+
describe('regression tests', () => {
85+
test('tripple enter creates new lines at end (#6507)', () => {
86+
const tiptap = createEditor({
87+
enableRichEditing: false
88+
})
89+
tiptap.commands.enter()
90+
tiptap.commands.enter()
91+
tiptap.commands.enter()
92+
expect(serializePlainText(tiptap.state.doc))
93+
.toEqual("\n\n\n")
94+
})
8295
})

0 commit comments

Comments
 (0)