Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/text.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFerdinand Thiessen <rpm@fthiessen.de>2022-11-10 15:50:01 +0300
committerFerdinand Thiessen <rpm@fthiessen.de>2022-11-10 15:52:59 +0300
commite1b1b62b053b0baa5d4f8888daceae79c04c08a6 (patch)
treeb759b9721b2244e60e31995c64ab6cc91203df12
parent3121d3b9cfb570827e8ad3bf246bdc1f0d31b69c (diff)
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>
-rw-r--r--src/tests/markdown.spec.js1
-rw-r--r--src/tests/tiptap.spec.js23
2 files changed, 24 insertions, 0 deletions
diff --git a/src/tests/markdown.spec.js b/src/tests/markdown.spec.js
index 0194ea739..8eef0f706 100644
--- a/src/tests/markdown.spec.js
+++ b/src/tests/markdown.spec.js
@@ -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) => {
diff --git a/src/tests/tiptap.spec.js b/src/tests/tiptap.spec.js
new file mode 100644
index 000000000..c4c84fd28
--- /dev/null
+++ b/src/tests/tiptap.spec.js
@@ -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>')
+ })
+})