From 845e2e99fd869be1d8d12f69590131bdfb988768 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sat, 30 Jun 2018 10:42:00 +0200 Subject: Preserve newlines when converting plain to html --- framework/qml/TextEditor.qml | 2 +- framework/qml/tests/tst_texteditor.qml | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/framework/qml/TextEditor.qml b/framework/qml/TextEditor.qml index ec5993b7..e5cc665c 100644 --- a/framework/qml/TextEditor.qml +++ b/framework/qml/TextEditor.qml @@ -39,7 +39,7 @@ FocusScope { onHtmlEnabledChanged: { if (htmlEnabled) { - var t = document.plainText + var t = document.htmlText edit.textFormat = Qt.RichText edit.text = t } else { diff --git a/framework/qml/tests/tst_texteditor.qml b/framework/qml/tests/tst_texteditor.qml index e6773aaa..e4813a0d 100644 --- a/framework/qml/tests/tst_texteditor.qml +++ b/framework/qml/tests/tst_texteditor.qml @@ -30,7 +30,7 @@ TestCase { Kube.TextEditor { id: editor - initialText: "Foobar" + initialText: "Foobar\nBarBar" htmlEnabled: false } @@ -41,7 +41,9 @@ TestCase { function test_2htmlConversion() { editor.htmlEnabled = true verify(editor.text.indexOf("") !== -1) - verify(editor.text.indexOf(editor.initialText) !== -1) + //It's converted into two paragraphs, so we can't check as a single string + verify(editor.text.indexOf("Foobar") !== -1) + verify(editor.text.indexOf("BarBar") !== -1) editor.htmlEnabled = false compare(editor.text, editor.initialText) } -- cgit v1.2.3