Added test for rendering of hard breaks within the editor

No additional new line should be added after hard line breaks,
this is tested by a new tiptap test.
Modified CommonMark rendering test to allow hard breaks without
newline.

Signed-off-by: Ferdinand Thiessen <rpm@fthiessen.de>
This commit is contained in:
Ferdinand Thiessen 2022-11-10 13:50:01 +01:00
Родитель 3121d3b9cf
Коммит e1b1b62b05
2 изменённых файлов: 24 добавлений и 0 удалений

Просмотреть файл

@ -34,6 +34,7 @@ describe('Commonmark', () => {
// https://github.com/markdown-it/markdown-it/blob/df4607f1d4d4be7fdc32e71c04109aea8cc373fa/test/commonmark.js#L10
return str.replace(/<blockquote><\/blockquote>/g, '<blockquote>\n</blockquote>')
.replace(/<span class="keep-md">([^<]+)<\/span>/g, '$1')
.replace(/<br \/>/, '<br />\n')
}
spec.forEach((entry) => {

23
src/tests/tiptap.spec.js Normal file
Просмотреть файл

@ -0,0 +1,23 @@
import createEditor from '../EditorFactory'
import markdownit from '../markdownit'
const renderedHTML = ( markdown ) => {
const editor = createEditor({
content: markdownit.render(markdown),
enableRichEditing: true
})
// Remove TrailingNode
return editor.getHTML().replace(/<p><\/p>$/, '')
}
describe('TipTap', () => {
it('render softbreaks', () => {
const markdown = 'This\nis\none\nparagraph'
expect(renderedHTML(markdown)).toEqual(`<p>${markdown}</p>`)
})
it('render hardbreak', () => {
const markdown = 'Hard line break \nNext Paragraph'
expect(renderedHTML(markdown)).toEqual('<p>Hard line break<br>Next Paragraph</p>')
})
})